@true-tech-team/react-components 0.0.3 → 0.0.5
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/README.md +138 -0
- package/index.css +1 -1
- package/index.d.ts +12 -0
- package/index.js +1 -1
- package/index.mjs +10774 -5477
- package/lib/components/buttons/Button/Button.d.ts +14 -3
- package/lib/components/buttons/ButtonToggleGroup/ButtonToggleGroup.d.ts +79 -0
- package/lib/components/buttons/ButtonToggleGroup/ButtonToggleGroupContext.d.ts +38 -0
- package/lib/components/buttons/ButtonToggleGroup/ButtonToggleGroupItem.d.ts +37 -0
- package/lib/components/buttons/ButtonToggleGroup/index.d.ts +7 -0
- package/lib/components/buttons/ToggleButton/ToggleButton.d.ts +96 -0
- package/lib/components/buttons/ToggleButton/index.d.ts +3 -0
- package/lib/components/display/Accordion/Accordion.d.ts +112 -0
- package/lib/components/display/Accordion/AccordionContainer.d.ts +101 -0
- package/lib/components/display/Accordion/AccordionContext.d.ts +57 -0
- package/lib/components/display/Accordion/index.d.ts +6 -0
- package/lib/components/display/Avatar/Avatar.d.ts +1 -1
- package/lib/components/display/Card/Card.d.ts +101 -0
- package/lib/components/display/Card/index.d.ts +3 -0
- package/lib/components/display/Carousel/Carousel.d.ts +125 -0
- package/lib/components/display/Carousel/index.d.ts +3 -0
- package/lib/components/display/Collapse/Collapse.d.ts +57 -0
- package/lib/components/display/Collapse/index.d.ts +2 -0
- package/lib/components/display/CountUp/CountUp.d.ts +119 -0
- package/lib/components/display/CountUp/index.d.ts +3 -0
- package/lib/components/display/FlipCard/FlipCard.d.ts +125 -0
- package/lib/components/display/FlipCard/index.d.ts +3 -0
- package/lib/components/display/Icon/icons/BookmarkFilled.d.ts +3 -0
- package/lib/components/display/Icon/icons/ChevronsLeft.d.ts +3 -0
- package/lib/components/display/Icon/icons/ChevronsRight.d.ts +3 -0
- package/lib/components/display/Icon/icons/HeartFilled.d.ts +3 -0
- package/lib/components/display/Icon/icons/More.d.ts +3 -0
- package/lib/components/display/Icon/icons/StarFilled.d.ts +3 -0
- package/lib/components/display/Icon/icons/ThumbsUpFilled.d.ts +3 -0
- package/lib/components/display/Icon/icons/index.d.ts +15 -1
- package/lib/components/display/Icon/index.d.ts +1 -0
- package/lib/components/display/OverflowText/OverflowText.d.ts +81 -0
- package/lib/components/display/OverflowText/index.d.ts +2 -0
- package/lib/components/display/PageMessages/PageMessageContent.d.ts +19 -0
- package/lib/components/display/PageMessages/PageMessages.d.ts +49 -0
- package/lib/components/display/PageMessages/defaultConfigs.d.ts +5 -0
- package/lib/components/display/PageMessages/index.d.ts +3 -0
- package/lib/components/display/PageMessages/types.d.ts +175 -0
- package/lib/components/display/ProgressBar/ProgressBar.d.ts +11 -0
- package/lib/components/display/Reveal/Reveal.d.ts +109 -0
- package/lib/components/display/Reveal/index.d.ts +3 -0
- package/lib/components/display/ScrollArea/ScrollArea.d.ts +112 -0
- package/lib/components/display/ScrollArea/index.d.ts +3 -0
- package/lib/components/display/Spinner/Spinner.d.ts +79 -0
- package/lib/components/display/Spinner/index.d.ts +3 -0
- package/lib/components/display/StatusIndicator/StatusIndicator.d.ts +1 -1
- package/lib/components/display/Tabs/Tab.d.ts +41 -0
- package/lib/components/display/Tabs/TabList.d.ts +27 -0
- package/lib/components/display/Tabs/TabPanel.d.ts +31 -0
- package/lib/components/display/Tabs/Tabs.d.ts +90 -0
- package/lib/components/display/Tabs/TabsContext.d.ts +63 -0
- package/lib/components/display/Tabs/index.d.ts +11 -0
- package/lib/components/display/TruncatedList/TruncatedList.d.ts +69 -0
- package/lib/components/display/TruncatedList/index.d.ts +2 -0
- package/lib/components/display/index.d.ts +3 -0
- package/lib/components/index.d.ts +65 -0
- package/lib/components/inputs/CheckboxGroup/CheckboxGroup.d.ts +122 -0
- package/lib/components/inputs/CheckboxGroup/CheckboxGroupContext.d.ts +42 -0
- package/lib/components/inputs/CheckboxGroup/CheckboxGroupItem.d.ts +50 -0
- package/lib/components/inputs/CheckboxGroup/index.d.ts +7 -0
- package/lib/components/inputs/Toggle/Toggle.d.ts +5 -0
- package/lib/components/layout/AdaptiveGrid/AdaptiveGrid.d.ts +100 -0
- package/lib/components/layout/AdaptiveGrid/index.d.ts +2 -0
- package/lib/components/layout/MasonryLayout/MasonryLayout.d.ts +74 -0
- package/lib/components/layout/MasonryLayout/index.d.ts +2 -0
- package/lib/components/layout/Panes/Pane.d.ts +72 -0
- package/lib/components/layout/Panes/Panes.d.ts +75 -0
- package/lib/components/layout/Panes/PanesContext.d.ts +60 -0
- package/lib/components/layout/Panes/index.d.ts +6 -0
- package/lib/components/layout/ResponsiveStack/ResponsiveStack.d.ts +99 -0
- package/lib/components/layout/ResponsiveStack/index.d.ts +2 -0
- package/lib/components/layout/index.d.ts +4 -0
- package/lib/components/navigation/BottomNavigation/BottomNavigation.d.ts +53 -0
- package/lib/components/navigation/BottomNavigation/BottomNavigationContext.d.ts +27 -0
- package/lib/components/navigation/BottomNavigation/BottomNavigationItem.d.ts +59 -0
- package/lib/components/navigation/BottomNavigation/index.d.ts +7 -0
- package/lib/components/navigation/Breadcrumbs/BreadcrumbItem.d.ts +37 -0
- package/lib/components/navigation/Breadcrumbs/BreadcrumbSeparator.d.ts +22 -0
- package/lib/components/navigation/Breadcrumbs/Breadcrumbs.d.ts +96 -0
- package/lib/components/navigation/Breadcrumbs/index.d.ts +9 -0
- package/lib/components/navigation/Breadcrumbs/useBreadcrumbsFromPath.d.ts +73 -0
- package/lib/components/navigation/CollapsibleSidebar/CollapsibleSidebar.d.ts +113 -0
- package/lib/components/navigation/CollapsibleSidebar/index.d.ts +2 -0
- package/lib/components/navigation/NavLink/NavLink.d.ts +74 -0
- package/lib/components/navigation/NavLink/index.d.ts +3 -0
- package/lib/components/navigation/Navbar/Navbar.d.ts +81 -0
- package/lib/components/navigation/Navbar/NavbarActions.d.ts +21 -0
- package/lib/components/navigation/Navbar/NavbarBrand.d.ts +29 -0
- package/lib/components/navigation/Navbar/NavbarCollapse.d.ts +26 -0
- package/lib/components/navigation/Navbar/NavbarContext.d.ts +50 -0
- package/lib/components/navigation/Navbar/NavbarNav.d.ts +22 -0
- package/lib/components/navigation/Navbar/NavbarToggle.d.ts +21 -0
- package/lib/components/navigation/Navbar/index.d.ts +15 -0
- package/lib/components/navigation/Pagination/Pagination.d.ts +99 -0
- package/lib/components/navigation/Pagination/index.d.ts +3 -0
- package/lib/components/navigation/SideNav/SideNav.d.ts +89 -0
- package/lib/components/navigation/SideNav/SideNavContext.d.ts +43 -0
- package/lib/components/navigation/SideNav/SideNavDivider.d.ts +22 -0
- package/lib/components/navigation/SideNav/SideNavGroup.d.ts +44 -0
- package/lib/components/navigation/SideNav/SideNavItem.d.ts +71 -0
- package/lib/components/navigation/SideNav/index.d.ts +11 -0
- package/lib/components/navigation/Stepper/Step.d.ts +57 -0
- package/lib/components/navigation/Stepper/Stepper.d.ts +80 -0
- package/lib/components/navigation/Stepper/StepperContext.d.ts +58 -0
- package/lib/components/navigation/Stepper/index.d.ts +7 -0
- package/lib/components/navigation/index.d.ts +16 -0
- package/lib/components/overlays/Alert/Alert.d.ts +102 -0
- package/lib/components/overlays/Alert/AlertContext.d.ts +94 -0
- package/lib/components/overlays/Alert/AlertPresets.d.ts +42 -0
- package/lib/components/overlays/Alert/AlertProvider.d.ts +40 -0
- package/lib/components/overlays/Alert/index.d.ts +11 -0
- package/lib/components/overlays/Dialog/Dialog.d.ts +197 -0
- package/lib/components/overlays/Dialog/DialogContext.d.ts +75 -0
- package/lib/components/overlays/Dialog/DialogProvider.d.ts +30 -0
- package/lib/components/overlays/Dialog/index.d.ts +9 -0
- package/lib/components/overlays/LoadingOverlay/LoadingOverlay.d.ts +101 -0
- package/lib/components/overlays/LoadingOverlay/index.d.ts +3 -0
- package/lib/components/overlays/Toast/Toast.d.ts +103 -0
- package/lib/components/overlays/Toast/ToastContainer.d.ts +37 -0
- package/lib/components/overlays/Toast/ToastContext.d.ts +126 -0
- package/lib/components/overlays/Toast/ToastProvider.d.ts +71 -0
- package/lib/components/overlays/Toast/index.d.ts +11 -0
- package/lib/contexts/PageMessagesContext/PageMessagesContext.d.ts +91 -0
- package/lib/contexts/PageMessagesContext/index.d.ts +2 -0
- package/lib/contexts/index.d.ts +2 -0
- package/lib/hooks/index.d.ts +10 -0
- package/lib/hooks/useAlert/index.d.ts +2 -0
- package/lib/hooks/useAlert/useAlert.d.ts +99 -0
- package/lib/hooks/useAsyncToast/index.d.ts +2 -0
- package/lib/hooks/useAsyncToast/useAsyncToast.d.ts +93 -0
- package/lib/hooks/useDialog/index.d.ts +2 -0
- package/lib/hooks/useDialog/useDialog.d.ts +58 -0
- package/lib/hooks/useResizeObserver/index.d.ts +2 -0
- package/lib/hooks/useResizeObserver/useResizeObserver.d.ts +69 -0
- package/lib/hooks/useToast/index.d.ts +2 -0
- package/lib/hooks/useToast/useToast.d.ts +97 -0
- package/lib/providers/GlobalProvider/GlobalProvider.d.ts +21 -1
- package/package.json +1 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { UseToastReturn } from '../useToast';
|
|
2
|
+
import { ToastData } from '../../components/overlays/Toast';
|
|
3
|
+
/**
|
|
4
|
+
* Async toast configuration
|
|
5
|
+
*/
|
|
6
|
+
export interface AsyncToastConfig<TData, TError = Error> {
|
|
7
|
+
/**
|
|
8
|
+
* Message or data to show while loading
|
|
9
|
+
*/
|
|
10
|
+
loading: string | Partial<ToastData>;
|
|
11
|
+
/**
|
|
12
|
+
* Message or data to show on success
|
|
13
|
+
* Can be a function that receives the result
|
|
14
|
+
*/
|
|
15
|
+
success: string | Partial<ToastData> | ((data: TData) => string | Partial<ToastData>);
|
|
16
|
+
/**
|
|
17
|
+
* Message or data to show on error
|
|
18
|
+
* Can be a function that receives the error
|
|
19
|
+
*/
|
|
20
|
+
error: string | Partial<ToastData> | ((error: TError) => string | Partial<ToastData>);
|
|
21
|
+
/**
|
|
22
|
+
* Duration for success toast (default: 5000)
|
|
23
|
+
*/
|
|
24
|
+
successDuration?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Duration for error toast (default: 5000)
|
|
27
|
+
*/
|
|
28
|
+
errorDuration?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Hook return type
|
|
32
|
+
*/
|
|
33
|
+
export interface UseAsyncToastReturn {
|
|
34
|
+
/**
|
|
35
|
+
* Wrap an async function with toast notifications
|
|
36
|
+
* Returns a function that when called, shows loading toast,
|
|
37
|
+
* then success/error based on result
|
|
38
|
+
*/
|
|
39
|
+
wrap: <TArgs extends unknown[], TData, TError = Error>(fn: (...args: TArgs) => Promise<TData>, config: AsyncToastConfig<TData, TError>) => (...args: TArgs) => Promise<TData>;
|
|
40
|
+
/**
|
|
41
|
+
* Execute a promise with toast notifications
|
|
42
|
+
*/
|
|
43
|
+
execute: <TData, TError = Error>(promise: Promise<TData>, config: AsyncToastConfig<TData, TError>) => Promise<TData>;
|
|
44
|
+
/**
|
|
45
|
+
* Access to underlying toast methods
|
|
46
|
+
*/
|
|
47
|
+
toast: UseToastReturn;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Hook for API endpoint toasts with loading -> success/error flow
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* function UserForm() {
|
|
55
|
+
* const { wrap, execute } = useAsyncToast();
|
|
56
|
+
*
|
|
57
|
+
* // Method 1: Wrap an existing function
|
|
58
|
+
* const saveUser = wrap(
|
|
59
|
+
* async (data: UserData) => api.saveUser(data),
|
|
60
|
+
* {
|
|
61
|
+
* loading: 'Saving user...',
|
|
62
|
+
* success: (user) => `User ${user.name} saved successfully`,
|
|
63
|
+
* error: (err) => `Failed to save: ${err.message}`,
|
|
64
|
+
* }
|
|
65
|
+
* );
|
|
66
|
+
*
|
|
67
|
+
* // Method 2: Execute a one-off promise
|
|
68
|
+
* const handleFetch = async () => {
|
|
69
|
+
* try {
|
|
70
|
+
* const data = await execute(
|
|
71
|
+
* fetch('/api/data').then(r => r.json()),
|
|
72
|
+
* {
|
|
73
|
+
* loading: { message: 'Fetching data...', title: 'Loading' },
|
|
74
|
+
* success: 'Data loaded!',
|
|
75
|
+
* error: 'Failed to load data',
|
|
76
|
+
* }
|
|
77
|
+
* );
|
|
78
|
+
* // Use data...
|
|
79
|
+
* } catch (err) {
|
|
80
|
+
* // Handle error if needed
|
|
81
|
+
* }
|
|
82
|
+
* };
|
|
83
|
+
*
|
|
84
|
+
* const handleSubmit = async (formData: UserData) => {
|
|
85
|
+
* const user = await saveUser(formData);
|
|
86
|
+
* // user is typed as the return value of api.saveUser
|
|
87
|
+
* };
|
|
88
|
+
*
|
|
89
|
+
* return <form onSubmit={handleSubmit}>...</form>;
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function useAsyncToast(): UseAsyncToastReturn;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DialogContextValue, DialogProps } from '../../components/overlays/Dialog';
|
|
2
|
+
/**
|
|
3
|
+
* Hook options
|
|
4
|
+
*/
|
|
5
|
+
export interface UseDialogOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Default props to apply to all dialogs
|
|
8
|
+
*/
|
|
9
|
+
defaultProps?: Partial<DialogProps>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hook return type
|
|
13
|
+
*/
|
|
14
|
+
export interface UseDialogReturn extends Pick<DialogContextValue, 'closeDialog' | 'closeTopDialog' | 'closeAllDialogs' | 'isDialogOpen' | 'dialogCount'> {
|
|
15
|
+
/**
|
|
16
|
+
* Open a dialog with optional default props merged
|
|
17
|
+
* @returns Promise that resolves when dialog closes
|
|
18
|
+
*/
|
|
19
|
+
open: <T = void>(props: Omit<DialogProps, 'isOpen'>) => Promise<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Update props of an open dialog
|
|
22
|
+
*/
|
|
23
|
+
update: (id: string, props: Partial<DialogProps>) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hook for programmatically creating and managing dialogs
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* function MyComponent() {
|
|
31
|
+
* const dialog = useDialog();
|
|
32
|
+
*
|
|
33
|
+
* const handleClick = async () => {
|
|
34
|
+
* const result = await dialog.open({
|
|
35
|
+
* title: 'Confirm Action',
|
|
36
|
+
* children: 'Are you sure you want to proceed?',
|
|
37
|
+
* actions: (
|
|
38
|
+
* <>
|
|
39
|
+
* <Button variant="ghost" onClick={() => dialog.closeTopDialog(false)}>
|
|
40
|
+
* Cancel
|
|
41
|
+
* </Button>
|
|
42
|
+
* <Button onClick={() => dialog.closeTopDialog(true)}>
|
|
43
|
+
* Confirm
|
|
44
|
+
* </Button>
|
|
45
|
+
* </>
|
|
46
|
+
* ),
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* if (result) {
|
|
50
|
+
* // User confirmed
|
|
51
|
+
* }
|
|
52
|
+
* };
|
|
53
|
+
*
|
|
54
|
+
* return <Button onClick={handleClick}>Open Dialog</Button>;
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function useDialog(options?: UseDialogOptions): UseDialogReturn;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for the resize observer hook
|
|
3
|
+
*/
|
|
4
|
+
export interface UseResizeObserverOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Callback when size changes
|
|
7
|
+
*/
|
|
8
|
+
onResize?: (entry: ResizeObserverEntry) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Debounce delay for resize callback (ms)
|
|
11
|
+
* @default 0
|
|
12
|
+
*/
|
|
13
|
+
debounce?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Which box model to observe
|
|
16
|
+
* @default 'border-box'
|
|
17
|
+
*/
|
|
18
|
+
box?: ResizeObserverBoxOptions;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to disable the observer
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Return value from useResizeObserver
|
|
27
|
+
*/
|
|
28
|
+
export interface UseResizeObserverReturn {
|
|
29
|
+
/**
|
|
30
|
+
* Ref callback to attach to the observed element
|
|
31
|
+
*/
|
|
32
|
+
ref: (node: HTMLElement | null) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Current width of the element
|
|
35
|
+
*/
|
|
36
|
+
width: number;
|
|
37
|
+
/**
|
|
38
|
+
* Current height of the element
|
|
39
|
+
*/
|
|
40
|
+
height: number;
|
|
41
|
+
/**
|
|
42
|
+
* The observed element
|
|
43
|
+
*/
|
|
44
|
+
element: HTMLElement | null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Hook that observes element resize using ResizeObserver
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```tsx
|
|
51
|
+
* const { ref, width, height } = useResizeObserver();
|
|
52
|
+
*
|
|
53
|
+
* return (
|
|
54
|
+
* <div ref={ref}>
|
|
55
|
+
* Width: {width}, Height: {height}
|
|
56
|
+
* </div>
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* const { ref, width } = useResizeObserver({
|
|
63
|
+
* onResize: (entry) => console.log('Resized:', entry),
|
|
64
|
+
* debounce: 100,
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function useResizeObserver(options?: UseResizeObserverOptions): UseResizeObserverReturn;
|
|
69
|
+
export default useResizeObserver;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ToastContextValue, ToastData } from '../../components/overlays/Toast';
|
|
2
|
+
/**
|
|
3
|
+
* Hook options
|
|
4
|
+
*/
|
|
5
|
+
export interface UseToastOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Default props to apply to all toasts
|
|
8
|
+
*/
|
|
9
|
+
defaultProps?: Partial<ToastData>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hook return type
|
|
13
|
+
*/
|
|
14
|
+
export interface UseToastReturn {
|
|
15
|
+
/**
|
|
16
|
+
* Add a toast with full configuration
|
|
17
|
+
* @returns Toast ID
|
|
18
|
+
*/
|
|
19
|
+
toast: (data: ToastData) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Show a success toast
|
|
22
|
+
* @returns Toast ID
|
|
23
|
+
*/
|
|
24
|
+
success: (message: string, options?: Partial<ToastData>) => string;
|
|
25
|
+
/**
|
|
26
|
+
* Show an error toast
|
|
27
|
+
* @returns Toast ID
|
|
28
|
+
*/
|
|
29
|
+
error: (message: string, options?: Partial<ToastData>) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Show a warning toast
|
|
32
|
+
* @returns Toast ID
|
|
33
|
+
*/
|
|
34
|
+
warning: (message: string, options?: Partial<ToastData>) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Show an info toast
|
|
37
|
+
* @returns Toast ID
|
|
38
|
+
*/
|
|
39
|
+
info: (message: string, options?: Partial<ToastData>) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Show a loading toast
|
|
42
|
+
* @returns Toast ID
|
|
43
|
+
*/
|
|
44
|
+
loading: (message: string, options?: Partial<ToastData>) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Update an existing toast
|
|
47
|
+
*/
|
|
48
|
+
update: (id: string, data: Partial<ToastData>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Dismiss a specific toast
|
|
51
|
+
*/
|
|
52
|
+
dismiss: (id: string) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Dismiss all toasts
|
|
55
|
+
*/
|
|
56
|
+
dismissAll: () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Promise-based toast that shows loading, then success/error
|
|
59
|
+
*/
|
|
60
|
+
promise: ToastContextValue['promise'];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Hook for programmatically creating toasts
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```tsx
|
|
67
|
+
* function MyComponent() {
|
|
68
|
+
* const toast = useToast();
|
|
69
|
+
*
|
|
70
|
+
* const handleSave = () => {
|
|
71
|
+
* toast.success('Changes saved successfully');
|
|
72
|
+
* };
|
|
73
|
+
*
|
|
74
|
+
* const handleError = () => {
|
|
75
|
+
* toast.error('Failed to save changes', {
|
|
76
|
+
* action: { label: 'Retry', onClick: handleSave }
|
|
77
|
+
* });
|
|
78
|
+
* };
|
|
79
|
+
*
|
|
80
|
+
* const handleAsyncOperation = async () => {
|
|
81
|
+
* await toast.promise(
|
|
82
|
+
* fetchData(),
|
|
83
|
+
* {
|
|
84
|
+
* loading: 'Fetching data...',
|
|
85
|
+
* success: (data) => `Loaded ${data.length} items`,
|
|
86
|
+
* error: (err) => `Error: ${err.message}`,
|
|
87
|
+
* }
|
|
88
|
+
* );
|
|
89
|
+
* };
|
|
90
|
+
*
|
|
91
|
+
* return (
|
|
92
|
+
* <Button onClick={handleSave}>Save</Button>
|
|
93
|
+
* );
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function useToast(options?: UseToastOptions): UseToastReturn;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { PageMessagesProviderProps } from '../../contexts/PageMessagesContext';
|
|
3
|
+
import { DialogProviderProps } from '../../components/overlays/Dialog';
|
|
4
|
+
import { AlertProviderProps } from '../../components/overlays/Alert';
|
|
5
|
+
import { ToastProviderProps } from '../../components/overlays/Toast';
|
|
2
6
|
import { ThemeConfig } from '../../types';
|
|
3
7
|
export interface GlobalProviderProps {
|
|
4
8
|
/**
|
|
@@ -13,6 +17,22 @@ export interface GlobalProviderProps {
|
|
|
13
17
|
* Whether to inject global styles (default: true)
|
|
14
18
|
*/
|
|
15
19
|
injectGlobalStyles?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* PageMessages default configuration
|
|
22
|
+
*/
|
|
23
|
+
pageMessagesConfig?: Omit<PageMessagesProviderProps, 'children'>;
|
|
24
|
+
/**
|
|
25
|
+
* Dialog provider configuration
|
|
26
|
+
*/
|
|
27
|
+
dialogConfig?: Omit<DialogProviderProps, 'children'>;
|
|
28
|
+
/**
|
|
29
|
+
* Alert provider configuration
|
|
30
|
+
*/
|
|
31
|
+
alertConfig?: Omit<AlertProviderProps, 'children'>;
|
|
32
|
+
/**
|
|
33
|
+
* Toast provider configuration
|
|
34
|
+
*/
|
|
35
|
+
toastConfig?: Omit<ToastProviderProps, 'children'>;
|
|
16
36
|
}
|
|
17
37
|
/**
|
|
18
38
|
* GlobalProvider component that wraps the entire application
|
|
@@ -52,5 +72,5 @@ export interface GlobalProviderProps {
|
|
|
52
72
|
* </GlobalProvider>
|
|
53
73
|
* ```
|
|
54
74
|
*/
|
|
55
|
-
export declare function GlobalProvider({ children, themeConfig, injectGlobalStyles, }: GlobalProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
export declare function GlobalProvider({ children, themeConfig, injectGlobalStyles, pageMessagesConfig, dialogConfig, alertConfig, toastConfig, }: GlobalProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
56
76
|
export default GlobalProvider;
|