@@ -24,25 +24,25 @@ const PracticalContext = createContext<PracticalContextType>({
2424 rootEl : undefined ,
2525} )
2626
27- interface ToastsOptions {
27+ export interface ToastsOptions {
2828 /**
2929 * Position of toasts on the page.
3030 */
31- readonly placement : ToastsPlacement
31+ readonly placement ? : ToastsPlacement
3232 /**
3333 * Determine if toasts should be always on top (above any other modal layers),
3434 * or not (above the main application layer but below any other modal layers).
3535 *
3636 * @default true
3737 */
38- readonly alwaysOnTop : boolean
38+ readonly alwaysOnTop ? : boolean
3939 /**
4040 * Default toast durations
4141 */
42- readonly defaultDurations : SimpleToastsDurations
42+ readonly defaultDurations ? : SimpleToastsDurations
4343}
4444
45- const DEFAULT_TOASTS_OPTIONS : ToastsOptions = {
45+ const DEFAULT_TOASTS_OPTIONS : Required < ToastsOptions > = {
4646 placement : { justify : 'right' , top : '0' } ,
4747 alwaysOnTop : true ,
4848 defaultDurations : {
@@ -65,19 +65,24 @@ interface PracticalProviderProps extends SimpleToastsDurations {
6565
6666export const PracticalProvider : React . FC < PracticalProviderProps > = ( {
6767 theme = defaultTheme ,
68- toastsOptions = DEFAULT_TOASTS_OPTIONS ,
68+ toastsOptions,
6969 children,
7070} ) => {
7171 const [ rootEl , rootRef ] = useState < HTMLDivElement | null > ( null )
7272
73+ const mergedOptions = {
74+ ...DEFAULT_TOASTS_OPTIONS ,
75+ ...toastsOptions ,
76+ }
77+
7378 return (
7479 < ThemeProvider theme = { theme } >
7580 < PracticalContext . Provider value = { { rootEl } } >
76- < ToastsProvider { ...toastsOptions . defaultDurations } >
81+ < ToastsProvider { ...mergedOptions . defaultDurations } >
7782 < PracticalRoot id = "practical-root" ref = { rootRef } >
7883 < Layer > { children } </ Layer >
79- < Layer zIndex = { toastsOptions . alwaysOnTop ? 1 : 0 } >
80- < ToastsAnchor placement = { toastsOptions . placement } />
84+ < Layer zIndex = { mergedOptions . alwaysOnTop ? 1 : 0 } >
85+ < ToastsAnchor placement = { mergedOptions . placement } />
8186 </ Layer >
8287 </ PracticalRoot >
8388 </ ToastsProvider >
0 commit comments