@breadstone/mosaik-elements-react 0.0.206 → 0.0.210
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +194 -0
- package/Cdk/Index.d.ts +2 -0
- package/Cdk/Index.d.ts.map +1 -0
- package/Cdk/Index.js +4 -0
- package/Cdk/Index.js.map +1 -0
- package/Cdk/Overlays/BottomSheet/BottomSheetContext.d.ts +63 -0
- package/Cdk/Overlays/BottomSheet/BottomSheetContext.d.ts.map +1 -0
- package/Cdk/Overlays/BottomSheet/BottomSheetContext.js +69 -0
- package/Cdk/Overlays/BottomSheet/BottomSheetContext.js.map +1 -0
- package/Cdk/Overlays/BottomSheet/Index.d.ts +3 -0
- package/Cdk/Overlays/BottomSheet/Index.d.ts.map +1 -0
- package/Cdk/Overlays/BottomSheet/Index.js +5 -0
- package/Cdk/Overlays/BottomSheet/Index.js.map +1 -0
- package/Cdk/Overlays/BottomSheet/useBottomSheet.d.ts +65 -0
- package/Cdk/Overlays/BottomSheet/useBottomSheet.d.ts.map +1 -0
- package/Cdk/Overlays/BottomSheet/useBottomSheet.js +49 -0
- package/Cdk/Overlays/BottomSheet/useBottomSheet.js.map +1 -0
- package/Cdk/Overlays/Dialog/DialogContext.d.ts +63 -0
- package/Cdk/Overlays/Dialog/DialogContext.d.ts.map +1 -0
- package/Cdk/Overlays/Dialog/DialogContext.js +69 -0
- package/Cdk/Overlays/Dialog/DialogContext.js.map +1 -0
- package/Cdk/Overlays/Dialog/Index.d.ts +3 -0
- package/Cdk/Overlays/Dialog/Index.d.ts.map +1 -0
- package/Cdk/Overlays/Dialog/Index.js +5 -0
- package/Cdk/Overlays/Dialog/Index.js.map +1 -0
- package/Cdk/Overlays/Dialog/useDialog.d.ts +66 -0
- package/Cdk/Overlays/Dialog/useDialog.d.ts.map +1 -0
- package/Cdk/Overlays/Dialog/useDialog.js +55 -0
- package/Cdk/Overlays/Dialog/useDialog.js.map +1 -0
- package/Cdk/Overlays/Drawer/DrawerContext.d.ts +63 -0
- package/Cdk/Overlays/Drawer/DrawerContext.d.ts.map +1 -0
- package/Cdk/Overlays/Drawer/DrawerContext.js +69 -0
- package/Cdk/Overlays/Drawer/DrawerContext.js.map +1 -0
- package/Cdk/Overlays/Drawer/Index.d.ts +3 -0
- package/Cdk/Overlays/Drawer/Index.d.ts.map +1 -0
- package/Cdk/Overlays/Drawer/Index.js +5 -0
- package/Cdk/Overlays/Drawer/Index.js.map +1 -0
- package/Cdk/Overlays/Drawer/useDrawer.d.ts +66 -0
- package/Cdk/Overlays/Drawer/useDrawer.d.ts.map +1 -0
- package/Cdk/Overlays/Drawer/useDrawer.js +50 -0
- package/Cdk/Overlays/Drawer/useDrawer.js.map +1 -0
- package/Cdk/Overlays/Index.d.ts +6 -0
- package/Cdk/Overlays/Index.d.ts.map +1 -0
- package/Cdk/Overlays/Index.js +8 -0
- package/Cdk/Overlays/Index.js.map +1 -0
- package/Cdk/Overlays/MessageBox/Index.d.ts +3 -0
- package/Cdk/Overlays/MessageBox/Index.d.ts.map +1 -0
- package/Cdk/Overlays/MessageBox/Index.js +5 -0
- package/Cdk/Overlays/MessageBox/Index.js.map +1 -0
- package/Cdk/Overlays/MessageBox/MessageBoxContext.d.ts +63 -0
- package/Cdk/Overlays/MessageBox/MessageBoxContext.d.ts.map +1 -0
- package/Cdk/Overlays/MessageBox/MessageBoxContext.js +69 -0
- package/Cdk/Overlays/MessageBox/MessageBoxContext.js.map +1 -0
- package/Cdk/Overlays/MessageBox/useMessageBox.d.ts +62 -0
- package/Cdk/Overlays/MessageBox/useMessageBox.d.ts.map +1 -0
- package/Cdk/Overlays/MessageBox/useMessageBox.js +57 -0
- package/Cdk/Overlays/MessageBox/useMessageBox.js.map +1 -0
- package/Cdk/Overlays/Sheet/Index.d.ts +3 -0
- package/Cdk/Overlays/Sheet/Index.d.ts.map +1 -0
- package/Cdk/Overlays/Sheet/Index.js +5 -0
- package/Cdk/Overlays/Sheet/Index.js.map +1 -0
- package/Cdk/Overlays/Sheet/SheetContext.d.ts +63 -0
- package/Cdk/Overlays/Sheet/SheetContext.d.ts.map +1 -0
- package/Cdk/Overlays/Sheet/SheetContext.js +69 -0
- package/Cdk/Overlays/Sheet/SheetContext.js.map +1 -0
- package/Cdk/Overlays/Sheet/useSheet.d.ts +65 -0
- package/Cdk/Overlays/Sheet/useSheet.d.ts.map +1 -0
- package/Cdk/Overlays/Sheet/useSheet.js +49 -0
- package/Cdk/Overlays/Sheet/useSheet.js.map +1 -0
- package/Cdk/Overlays/Toast/Index.d.ts +3 -0
- package/Cdk/Overlays/Toast/Index.d.ts.map +1 -0
- package/Cdk/Overlays/Toast/Index.js +5 -0
- package/Cdk/Overlays/Toast/Index.js.map +1 -0
- package/Cdk/Overlays/Toast/ToastContext.d.ts +63 -0
- package/Cdk/Overlays/Toast/ToastContext.d.ts.map +1 -0
- package/Cdk/Overlays/Toast/ToastContext.js +69 -0
- package/Cdk/Overlays/Toast/ToastContext.js.map +1 -0
- package/Cdk/Overlays/Toast/useToast.d.ts +62 -0
- package/Cdk/Overlays/Toast/useToast.d.ts.map +1 -0
- package/Cdk/Overlays/Toast/useToast.js +51 -0
- package/Cdk/Overlays/Toast/useToast.js.map +1 -0
- package/Controls/Components/Grouping/Region/RegionComponent.d.ts +19 -0
- package/Controls/Components/Grouping/Region/RegionComponent.d.ts.map +1 -0
- package/Controls/Components/Grouping/Region/RegionComponent.js +27 -0
- package/Controls/Components/Grouping/Region/RegionComponent.js.map +1 -0
- package/Controls/Components/Grouping/Region/RegionViewComponent.d.ts +18 -0
- package/Controls/Components/Grouping/Region/RegionViewComponent.d.ts.map +1 -0
- package/Controls/Components/Grouping/Region/RegionViewComponent.js +26 -0
- package/Controls/Components/Grouping/Region/RegionViewComponent.js.map +1 -0
- package/Controls/Components/Inputs/AutoCompleteBox/AutoCompleteBoxComponent.d.ts +4 -0
- package/Controls/Components/Inputs/AutoCompleteBox/AutoCompleteBoxComponent.d.ts.map +1 -1
- package/Controls/Components/Inputs/AutoCompleteBox/AutoCompleteBoxComponent.js +4 -0
- package/Controls/Components/Inputs/AutoCompleteBox/AutoCompleteBoxComponent.js.map +1 -1
- package/Controls/Components/Inputs/ColorBox/ColorBoxComponent.d.ts +4 -0
- package/Controls/Components/Inputs/ColorBox/ColorBoxComponent.d.ts.map +1 -1
- package/Controls/Components/Inputs/ColorBox/ColorBoxComponent.js +4 -0
- package/Controls/Components/Inputs/ColorBox/ColorBoxComponent.js.map +1 -1
- package/Controls/Components/Inputs/NumberBox/NumberBoxComponent.d.ts +1 -0
- package/Controls/Components/Inputs/NumberBox/NumberBoxComponent.d.ts.map +1 -1
- package/Controls/Components/Inputs/NumberBox/NumberBoxComponent.js +1 -0
- package/Controls/Components/Inputs/NumberBox/NumberBoxComponent.js.map +1 -1
- package/Controls/Components/Media/Timeline/TimelineComponent.d.ts +18 -0
- package/Controls/Components/Media/Timeline/TimelineComponent.d.ts.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineComponent.js +26 -0
- package/Controls/Components/Media/Timeline/TimelineComponent.js.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineContentComponent.d.ts +18 -0
- package/Controls/Components/Media/Timeline/TimelineContentComponent.d.ts.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineContentComponent.js +26 -0
- package/Controls/Components/Media/Timeline/TimelineContentComponent.js.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineItemComponent.d.ts +18 -0
- package/Controls/Components/Media/Timeline/TimelineItemComponent.d.ts.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineItemComponent.js +26 -0
- package/Controls/Components/Media/Timeline/TimelineItemComponent.js.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineMarkerComponent.d.ts +18 -0
- package/Controls/Components/Media/Timeline/TimelineMarkerComponent.d.ts.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineMarkerComponent.js +26 -0
- package/Controls/Components/Media/Timeline/TimelineMarkerComponent.js.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineOppositeComponent.d.ts +18 -0
- package/Controls/Components/Media/Timeline/TimelineOppositeComponent.d.ts.map +1 -0
- package/Controls/Components/Media/Timeline/TimelineOppositeComponent.js +26 -0
- package/Controls/Components/Media/Timeline/TimelineOppositeComponent.js.map +1 -0
- package/Controls/Components/Overlays/Drawer/DrawerFooterComponent.d.ts +18 -0
- package/Controls/Components/Overlays/Drawer/DrawerFooterComponent.d.ts.map +1 -0
- package/Controls/Components/Overlays/Drawer/DrawerFooterComponent.js +26 -0
- package/Controls/Components/Overlays/Drawer/DrawerFooterComponent.js.map +1 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderComponent.d.ts +18 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderComponent.d.ts.map +1 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderComponent.js +26 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderComponent.js.map +1 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderSubTextComponent.d.ts +18 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderSubTextComponent.d.ts.map +1 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderSubTextComponent.js +26 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderSubTextComponent.js.map +1 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderTextComponent.d.ts +18 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderTextComponent.d.ts.map +1 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderTextComponent.js +26 -0
- package/Controls/Components/Overlays/Drawer/DrawerHeaderTextComponent.js.map +1 -0
- package/Controls/Components/Overlays/Sheet/SheetComponent.d.ts +20 -0
- package/Controls/Components/Overlays/Sheet/SheetComponent.d.ts.map +1 -0
- package/Controls/Components/Overlays/Sheet/SheetComponent.js +28 -0
- package/Controls/Components/Overlays/Sheet/SheetComponent.js.map +1 -0
- package/Controls/Components/Selectors/Stepper/StepperComponent.d.ts +21 -0
- package/Controls/Components/Selectors/Stepper/StepperComponent.d.ts.map +1 -0
- package/Controls/Components/Selectors/Stepper/StepperComponent.js +29 -0
- package/Controls/Components/Selectors/Stepper/StepperComponent.js.map +1 -0
- package/Controls/Components/Selectors/Stepper/StepperItemComponent.d.ts +20 -0
- package/Controls/Components/Selectors/Stepper/StepperItemComponent.d.ts.map +1 -0
- package/Controls/Components/Selectors/Stepper/StepperItemComponent.js +28 -0
- package/Controls/Components/Selectors/Stepper/StepperItemComponent.js.map +1 -0
- package/Index.d.ts +14 -1
- package/Index.d.ts.map +1 -1
- package/Index.js +14 -1
- package/Index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type IDialogOptions } from '@breadstone/mosaik-elements-foundation';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the return type of the `useDialog` hook.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IUseDialogReturn {
|
|
8
|
+
/**
|
|
9
|
+
* Opens a dialog with the specified wrapper component.
|
|
10
|
+
*
|
|
11
|
+
* @template T - Type of the wrapper component extending HTMLElement.
|
|
12
|
+
* @template TData - Type of data provided to the wrapper component.
|
|
13
|
+
* @template TResult - Expected return type of the resolved dialog result.
|
|
14
|
+
* @param dialogId - Unique identifier for the dialog.
|
|
15
|
+
* @param wrapperClass - Constructor for the wrapper component.
|
|
16
|
+
* @param data - Optional data to pass to the wrapper.
|
|
17
|
+
* @param options - Optional dialog configuration.
|
|
18
|
+
* @returns Promise resolving to the dialog result.
|
|
19
|
+
*/
|
|
20
|
+
open<T extends HTMLElement, TData, TResult>(dialogId: string, wrapperClass: new (args?: TData) => T, data?: TData, options?: IDialogOptions): Promise<TResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Closes a dialog by its identifier.
|
|
23
|
+
*
|
|
24
|
+
* @template TResult - Type of the result to return.
|
|
25
|
+
* @param dialogId - The identifier of the dialog to close.
|
|
26
|
+
* @param result - Optional result to pass to the dialog opener.
|
|
27
|
+
* @returns Promise that resolves when the dialog is closed.
|
|
28
|
+
*/
|
|
29
|
+
close<TResult>(dialogId: string, result?: TResult): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* React hook for managing dialogs using the foundation DialogService singleton.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* This hook provides a React-idiomatic interface to the foundation DialogService.
|
|
36
|
+
* The service should be configured at application startup using `DialogService.configure()`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* // In your app setup
|
|
41
|
+
* DialogService.configure({
|
|
42
|
+
* behaviors: [withDialogStackBehavior({ baseWidth: '80%' })],
|
|
43
|
+
* closeOnNavigation: true
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // In your component
|
|
47
|
+
* function MyComponent() {
|
|
48
|
+
* const dialog = useDialog();
|
|
49
|
+
*
|
|
50
|
+
* const handleOpen = async () => {
|
|
51
|
+
* const result = await dialog.open('myDialog', MyDialogWrapper, {
|
|
52
|
+
* header: 'Confirm Action',
|
|
53
|
+
* closeable: true
|
|
54
|
+
* });
|
|
55
|
+
* console.log('Dialog result:', result);
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* return <button onClick={handleOpen}>Open Dialog</button>;
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @returns An object containing dialog management functions.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useDialog(): IUseDialogReturn;
|
|
66
|
+
//# sourceMappingURL=useDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDialog.d.ts","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/Dialog/useDialog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAI5F;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAE7B;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,EACtC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,EACrC,IAAI,CAAC,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAErE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,SAAS,IAAI,gBAAgB,CA4B5C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { DialogService } from '@breadstone/mosaik-elements-foundation';
|
|
4
|
+
/**
|
|
5
|
+
* React hook for managing dialogs using the foundation DialogService singleton.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This hook provides a React-idiomatic interface to the foundation DialogService.
|
|
9
|
+
* The service should be configured at application startup using `DialogService.configure()`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // In your app setup
|
|
14
|
+
* DialogService.configure({
|
|
15
|
+
* behaviors: [withDialogStackBehavior({ baseWidth: '80%' })],
|
|
16
|
+
* closeOnNavigation: true
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // In your component
|
|
20
|
+
* function MyComponent() {
|
|
21
|
+
* const dialog = useDialog();
|
|
22
|
+
*
|
|
23
|
+
* const handleOpen = async () => {
|
|
24
|
+
* const result = await dialog.open('myDialog', MyDialogWrapper, {
|
|
25
|
+
* header: 'Confirm Action',
|
|
26
|
+
* closeable: true
|
|
27
|
+
* });
|
|
28
|
+
* console.log('Dialog result:', result);
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* return <button onClick={handleOpen}>Open Dialog</button>;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
* @returns An object containing dialog management functions.
|
|
37
|
+
*/
|
|
38
|
+
export function useDialog() {
|
|
39
|
+
// #region Methods
|
|
40
|
+
const open = useCallback((dialogId, wrapperClass, data, options) => {
|
|
41
|
+
if (data !== undefined) {
|
|
42
|
+
return DialogService.instance.open(dialogId, wrapperClass, data, options);
|
|
43
|
+
}
|
|
44
|
+
return DialogService.instance.open(dialogId, wrapperClass, options);
|
|
45
|
+
}, []);
|
|
46
|
+
const close = useCallback((dialogId, result) => DialogService.instance.close(dialogId, result), []);
|
|
47
|
+
// #endregion
|
|
48
|
+
// #region Properties
|
|
49
|
+
return useMemo(() => ({
|
|
50
|
+
open,
|
|
51
|
+
close
|
|
52
|
+
}), [open, close]);
|
|
53
|
+
// #endregion
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=useDialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDialog.js","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/Dialog/useDialog.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAuB,MAAM,wCAAwC,CAAC;AA0C5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,SAAS;IACrB,kBAAkB;IAElB,MAAM,IAAI,GAAG,WAAW,CAAC,CACrB,QAAgB,EAChB,YAAqC,EACrC,IAAY,EACZ,OAAwB,EACR,EAAE;QAClB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,OAAO,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAoB,QAAQ,EAAE,YAAsC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3H,CAAC;QAED,OAAO,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAa,QAAQ,EAAE,YAA2B,EAAE,OAAO,CAAC,CAAC;IACnG,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAAG,WAAW,CAAC,CAAU,QAAgB,EAAE,MAAgB,EAAiB,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IAE9I,aAAa;IAEb,qBAAqB;IAErB,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAClB,IAAI;QACJ,KAAK;KACR,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAEnB,aAAa;AACjB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type IUseDrawerReturn } from './useDrawer';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the DrawerProvider component.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface IDrawerProviderProps {
|
|
9
|
+
/**
|
|
10
|
+
* Child components that will have access to the drawer context.
|
|
11
|
+
*/
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Provider component that makes drawer functionality available to all child components.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Place this provider at the root of your application or at a level where all
|
|
19
|
+
* components that need drawer access are descendants.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // In your app root
|
|
24
|
+
* function App() {
|
|
25
|
+
* return (
|
|
26
|
+
* <DrawerProvider>
|
|
27
|
+
* <YourAppContent />
|
|
28
|
+
* </DrawerProvider>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @param props - The provider props.
|
|
35
|
+
* @returns The provider component wrapping children.
|
|
36
|
+
*/
|
|
37
|
+
export declare function DrawerProvider({ children }: IDrawerProviderProps): ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Hook to access the drawer context.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* This hook must be used within a DrawerProvider. If you don't need the provider pattern,
|
|
43
|
+
* use `useDrawer` directly instead.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* function MyComponent() {
|
|
48
|
+
* const drawer = useDrawerContext();
|
|
49
|
+
*
|
|
50
|
+
* return (
|
|
51
|
+
* <button onClick={() => drawer.open('myDrawer', MyWrapper)}>
|
|
52
|
+
* Open
|
|
53
|
+
* </button>
|
|
54
|
+
* );
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @returns The drawer context value.
|
|
60
|
+
* @throws Error if used outside of a DrawerProvider.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useDrawerContext(): IUseDrawerReturn;
|
|
63
|
+
//# sourceMappingURL=DrawerContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerContext.d.ts","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/Drawer/DrawerContext.tsx"],"names":[],"mappings":"AAEA,OAAc,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,aAAa,CAAC;AAW/D;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IAEjC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CAEvB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,oBAAoB,GAAG,SAAS,CAQ5E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAQnD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import React, { createContext, useContext } from 'react';
|
|
3
|
+
import { useDrawer } from './useDrawer';
|
|
4
|
+
// #endregion
|
|
5
|
+
/**
|
|
6
|
+
* Context for providing drawer functionality throughout the React component tree.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const DrawerContext = createContext(null);
|
|
11
|
+
/**
|
|
12
|
+
* Provider component that makes drawer functionality available to all child components.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Place this provider at the root of your application or at a level where all
|
|
16
|
+
* components that need drawer access are descendants.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // In your app root
|
|
21
|
+
* function App() {
|
|
22
|
+
* return (
|
|
23
|
+
* <DrawerProvider>
|
|
24
|
+
* <YourAppContent />
|
|
25
|
+
* </DrawerProvider>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @param props - The provider props.
|
|
32
|
+
* @returns The provider component wrapping children.
|
|
33
|
+
*/
|
|
34
|
+
export function DrawerProvider({ children }) {
|
|
35
|
+
const drawer = useDrawer();
|
|
36
|
+
return (React.createElement(DrawerContext.Provider, { value: drawer }, children));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Hook to access the drawer context.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* This hook must be used within a DrawerProvider. If you don't need the provider pattern,
|
|
43
|
+
* use `useDrawer` directly instead.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* function MyComponent() {
|
|
48
|
+
* const drawer = useDrawerContext();
|
|
49
|
+
*
|
|
50
|
+
* return (
|
|
51
|
+
* <button onClick={() => drawer.open('myDrawer', MyWrapper)}>
|
|
52
|
+
* Open
|
|
53
|
+
* </button>
|
|
54
|
+
* );
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @returns The drawer context value.
|
|
60
|
+
* @throws Error if used outside of a DrawerProvider.
|
|
61
|
+
*/
|
|
62
|
+
export function useDrawerContext() {
|
|
63
|
+
const context = useContext(DrawerContext);
|
|
64
|
+
if (!context) {
|
|
65
|
+
throw new Error('useDrawerContext must be used within a DrawerProvider');
|
|
66
|
+
}
|
|
67
|
+
return context;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=DrawerContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerContext.js","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/Drawer/DrawerContext.tsx"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AACzE,OAAO,EAAyB,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/D,aAAa;AAEb;;;;GAIG;AACH,MAAM,aAAa,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAC;AAgBnE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAwB;IAC7D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,OAAO,CACH,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,IAChC,QAAQ,CACY,CAC5B,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,gBAAgB;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAE1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/Drawer/Index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/Drawer/Index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAA6B,MAAM,iBAAiB,CAAC;AAE9F,aAAa"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type IDrawerOptions } from '@breadstone/mosaik-elements-foundation';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the return type of the `useDrawer` hook.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IUseDrawerReturn {
|
|
8
|
+
/**
|
|
9
|
+
* Opens a drawer with the specified wrapper component.
|
|
10
|
+
*
|
|
11
|
+
* @template T - Type of the wrapper component extending HTMLElement.
|
|
12
|
+
* @template TData - Type of data provided to the wrapper component.
|
|
13
|
+
* @template TResult - Expected return type of the resolved drawer result.
|
|
14
|
+
* @param drawerId - Unique identifier for the drawer.
|
|
15
|
+
* @param wrapperClass - Constructor for the wrapper component.
|
|
16
|
+
* @param options - Optional drawer configuration.
|
|
17
|
+
* @param data - Optional data to pass to the wrapper.
|
|
18
|
+
* @returns Promise resolving to the drawer result.
|
|
19
|
+
*/
|
|
20
|
+
open<T extends HTMLElement, TData, TResult>(drawerId: string, wrapperClass: new (args?: TData) => T, options?: IDrawerOptions, data?: TData): Promise<TResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Closes a drawer by its identifier.
|
|
23
|
+
*
|
|
24
|
+
* @template TResult - Type of the result to return.
|
|
25
|
+
* @param drawerId - The identifier of the drawer to close.
|
|
26
|
+
* @param result - Optional result to pass to the drawer opener.
|
|
27
|
+
* @returns Promise that resolves when the drawer is closed.
|
|
28
|
+
*/
|
|
29
|
+
close<TResult>(drawerId: string, result?: TResult): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* React hook for managing drawers using the foundation DrawerService singleton.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* This hook provides a React-idiomatic interface to the foundation DrawerService.
|
|
36
|
+
* The service should be configured at application startup using `DrawerService.configure()`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* // In your app setup
|
|
41
|
+
* DrawerService.configure({
|
|
42
|
+
* behaviors: [withDrawerStackBehavior({ baseWidth: '400px' })],
|
|
43
|
+
* closeOnNavigation: true
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // In your component
|
|
47
|
+
* function MyComponent() {
|
|
48
|
+
* const drawer = useDrawer();
|
|
49
|
+
*
|
|
50
|
+
* const handleOpen = async () => {
|
|
51
|
+
* const result = await drawer.open('myDrawer', MyDrawerWrapper, {
|
|
52
|
+
* position: 'right',
|
|
53
|
+
* width: '400px'
|
|
54
|
+
* });
|
|
55
|
+
* console.log('Drawer result:', result);
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* return <button onClick={handleOpen}>Open Drawer</button>;
|
|
59
|
+
* }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @returns An object containing drawer management functions.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useDrawer(): IUseDrawerReturn;
|
|
66
|
+
//# sourceMappingURL=useDrawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDrawer.d.ts","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/Drawer/useDrawer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAI5F;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAE7B;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,OAAO,EACtC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,EACrC,OAAO,CAAC,EAAE,cAAc,EACxB,IAAI,CAAC,EAAE,KAAK,GACb,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAErE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,SAAS,IAAI,gBAAgB,CAsB5C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { DrawerService } from '@breadstone/mosaik-elements-foundation';
|
|
4
|
+
/**
|
|
5
|
+
* React hook for managing drawers using the foundation DrawerService singleton.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This hook provides a React-idiomatic interface to the foundation DrawerService.
|
|
9
|
+
* The service should be configured at application startup using `DrawerService.configure()`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // In your app setup
|
|
14
|
+
* DrawerService.configure({
|
|
15
|
+
* behaviors: [withDrawerStackBehavior({ baseWidth: '400px' })],
|
|
16
|
+
* closeOnNavigation: true
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // In your component
|
|
20
|
+
* function MyComponent() {
|
|
21
|
+
* const drawer = useDrawer();
|
|
22
|
+
*
|
|
23
|
+
* const handleOpen = async () => {
|
|
24
|
+
* const result = await drawer.open('myDrawer', MyDrawerWrapper, {
|
|
25
|
+
* position: 'right',
|
|
26
|
+
* width: '400px'
|
|
27
|
+
* });
|
|
28
|
+
* console.log('Drawer result:', result);
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* return <button onClick={handleOpen}>Open Drawer</button>;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
* @returns An object containing drawer management functions.
|
|
37
|
+
*/
|
|
38
|
+
export function useDrawer() {
|
|
39
|
+
// #region Methods
|
|
40
|
+
const open = useCallback((drawerId, wrapperClass, options, data) => DrawerService.instance.open(drawerId, wrapperClass, options, data), []);
|
|
41
|
+
const close = useCallback((drawerId, result) => DrawerService.instance.close(drawerId, result), []);
|
|
42
|
+
// #endregion
|
|
43
|
+
// #region Properties
|
|
44
|
+
return useMemo(() => ({
|
|
45
|
+
open,
|
|
46
|
+
close
|
|
47
|
+
}), [open, close]);
|
|
48
|
+
// #endregion
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=useDrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDrawer.js","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/Drawer/useDrawer.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAuB,MAAM,wCAAwC,CAAC;AA0C5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,UAAU,SAAS;IACrB,kBAAkB;IAElB,MAAM,IAAI,GAAG,WAAW,CAAC,CACrB,QAAgB,EAChB,YAAqC,EACrC,OAAwB,EACxB,IAAY,EACI,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAoB,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAElH,MAAM,KAAK,GAAG,WAAW,CAAC,CAAU,QAAgB,EAAE,MAAgB,EAAiB,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;IAE9I,aAAa;IAEb,qBAAqB;IAErB,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAClB,IAAI;QACJ,KAAK;KACR,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAEnB,aAAa;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../../../src/Cdk/Overlays/Index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../src/Cdk/Overlays/Index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAE9B,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/MessageBox/Index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,KAAK,wBAAwB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/MessageBox/Index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAAE,aAAa,EAA6B,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAiC,MAAM,qBAAqB,CAAC;AAE9G,aAAa"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type IUseMessageBoxReturn } from './useMessageBox';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the MessageBoxProvider component.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface IMessageBoxProviderProps {
|
|
9
|
+
/**
|
|
10
|
+
* Child components that will have access to the message box context.
|
|
11
|
+
*/
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Provider component that makes message box functionality available to all child components.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Place this provider at the root of your application or at a level where all
|
|
19
|
+
* components that need message box access are descendants.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // In your app root
|
|
24
|
+
* function App() {
|
|
25
|
+
* return (
|
|
26
|
+
* <MessageBoxProvider>
|
|
27
|
+
* <YourAppContent />
|
|
28
|
+
* </MessageBoxProvider>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @param props - The provider props.
|
|
35
|
+
* @returns The provider component wrapping children.
|
|
36
|
+
*/
|
|
37
|
+
export declare function MessageBoxProvider({ children }: IMessageBoxProviderProps): ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Hook to access the message box context.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* This hook must be used within a MessageBoxProvider. If you don't need the provider pattern,
|
|
43
|
+
* use `useMessageBox` directly instead.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* function MyComponent() {
|
|
48
|
+
* const messageBox = useMessageBoxContext();
|
|
49
|
+
*
|
|
50
|
+
* return (
|
|
51
|
+
* <button onClick={() => messageBox.open({ header: 'Info', content: 'Hello!' })}>
|
|
52
|
+
* Show Message
|
|
53
|
+
* </button>
|
|
54
|
+
* );
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @returns The message box context value.
|
|
60
|
+
* @throws Error if used outside of a MessageBoxProvider.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useMessageBoxContext(): IUseMessageBoxReturn;
|
|
63
|
+
//# sourceMappingURL=MessageBoxContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBoxContext.d.ts","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/MessageBox/MessageBoxContext.tsx"],"names":[],"mappings":"AAEA,OAAc,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,KAAK,oBAAoB,EAAiB,MAAM,iBAAiB,CAAC;AAW3E;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IAErC;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CAEvB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE,wBAAwB,GAAG,SAAS,CAQpF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,IAAI,oBAAoB,CAQ3D"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// #region Imports
|
|
2
|
+
import React, { createContext, useContext } from 'react';
|
|
3
|
+
import { useMessageBox } from './useMessageBox';
|
|
4
|
+
// #endregion
|
|
5
|
+
/**
|
|
6
|
+
* Context for providing message box functionality throughout the React component tree.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const MessageBoxContext = createContext(null);
|
|
11
|
+
/**
|
|
12
|
+
* Provider component that makes message box functionality available to all child components.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Place this provider at the root of your application or at a level where all
|
|
16
|
+
* components that need message box access are descendants.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // In your app root
|
|
21
|
+
* function App() {
|
|
22
|
+
* return (
|
|
23
|
+
* <MessageBoxProvider>
|
|
24
|
+
* <YourAppContent />
|
|
25
|
+
* </MessageBoxProvider>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @param props - The provider props.
|
|
32
|
+
* @returns The provider component wrapping children.
|
|
33
|
+
*/
|
|
34
|
+
export function MessageBoxProvider({ children }) {
|
|
35
|
+
const messageBox = useMessageBox();
|
|
36
|
+
return (React.createElement(MessageBoxContext.Provider, { value: messageBox }, children));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Hook to access the message box context.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* This hook must be used within a MessageBoxProvider. If you don't need the provider pattern,
|
|
43
|
+
* use `useMessageBox` directly instead.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* function MyComponent() {
|
|
48
|
+
* const messageBox = useMessageBoxContext();
|
|
49
|
+
*
|
|
50
|
+
* return (
|
|
51
|
+
* <button onClick={() => messageBox.open({ header: 'Info', content: 'Hello!' })}>
|
|
52
|
+
* Show Message
|
|
53
|
+
* </button>
|
|
54
|
+
* );
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @returns The message box context value.
|
|
60
|
+
* @throws Error if used outside of a MessageBoxProvider.
|
|
61
|
+
*/
|
|
62
|
+
export function useMessageBoxContext() {
|
|
63
|
+
const context = useContext(MessageBoxContext);
|
|
64
|
+
if (!context) {
|
|
65
|
+
throw new Error('useMessageBoxContext must be used within a MessageBoxProvider');
|
|
66
|
+
}
|
|
67
|
+
return context;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=MessageBoxContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBoxContext.js","sourceRoot":"","sources":["../../../../src/Cdk/Overlays/MessageBox/MessageBoxContext.tsx"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AACzE,OAAO,EAA6B,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3E,aAAa;AAEb;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,aAAa,CAA8B,IAAI,CAAC,CAAC;AAgB3E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAE,QAAQ,EAA4B;IACrE,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,OAAO,CACH,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,IACxC,QAAQ,CACgB,CAChC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,oBAAoB;IAChC,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE9C,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type IMessageBoxOptions, type MessageBoxResult } from '@breadstone/mosaik-elements-foundation';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the return type of the `useMessageBox` hook.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface IUseMessageBoxReturn {
|
|
8
|
+
/**
|
|
9
|
+
* Opens a message box with the specified options.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Message box configuration options.
|
|
12
|
+
* @returns Promise resolving to the MessageBoxResult.
|
|
13
|
+
*/
|
|
14
|
+
open(options?: Partial<IMessageBoxOptions>): Promise<MessageBoxResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Closes a message box by its identifier.
|
|
17
|
+
*
|
|
18
|
+
* @param messageBoxId - The identifier of the message box to close.
|
|
19
|
+
* @returns Promise that resolves when the message box is closed.
|
|
20
|
+
*/
|
|
21
|
+
close(messageBoxId: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* React hook for managing message boxes using the foundation MessageBoxService singleton.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* This hook provides a React-idiomatic interface to the foundation MessageBoxService.
|
|
28
|
+
* The service should be configured at application startup using `MessageBoxService.configure()`.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // In your app setup
|
|
33
|
+
* MessageBoxService.configure({
|
|
34
|
+
* closeOnNavigation: true,
|
|
35
|
+
* behaviors: []
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // In your component
|
|
39
|
+
* function MyComponent() {
|
|
40
|
+
* const messageBox = useMessageBox();
|
|
41
|
+
*
|
|
42
|
+
* const handleConfirm = async () => {
|
|
43
|
+
* const result = await messageBox.open({
|
|
44
|
+
* header: 'Confirm Delete',
|
|
45
|
+
* content: 'Are you sure you want to delete this item?',
|
|
46
|
+
* buttons: MessageBoxButtons.YesNo
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* if (result === MessageBoxResult.Yes) {
|
|
50
|
+
* // User confirmed
|
|
51
|
+
* }
|
|
52
|
+
* };
|
|
53
|
+
*
|
|
54
|
+
* return <button onClick={handleConfirm}>Delete Item</button>;
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @returns An object containing message box management functions.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useMessageBox(): IUseMessageBoxReturn;
|
|
62
|
+
//# sourceMappingURL=useMessageBox.d.ts.map
|