@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,101 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { BaseComponentProps, ExtendedComponentSize } from '../../../types/component.types';
|
|
3
|
+
import { SpinnerSpeed, SpinnerStyle, SpinnerVariant } from '../../display/Spinner';
|
|
4
|
+
/**
|
|
5
|
+
* Loading overlay mode
|
|
6
|
+
*/
|
|
7
|
+
export type LoadingOverlayMode = 'container' | 'fullscreen';
|
|
8
|
+
/**
|
|
9
|
+
* Props for the LoadingOverlay component
|
|
10
|
+
*/
|
|
11
|
+
export interface LoadingOverlayProps extends BaseComponentProps {
|
|
12
|
+
/**
|
|
13
|
+
* Whether the overlay is visible
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Mode: cover parent container or full screen
|
|
19
|
+
* @default 'container'
|
|
20
|
+
*/
|
|
21
|
+
mode?: LoadingOverlayMode;
|
|
22
|
+
/**
|
|
23
|
+
* Spinner style to use
|
|
24
|
+
* @default 'circular'
|
|
25
|
+
*/
|
|
26
|
+
spinnerStyle?: SpinnerStyle;
|
|
27
|
+
/**
|
|
28
|
+
* Spinner size
|
|
29
|
+
* @default 'lg'
|
|
30
|
+
*/
|
|
31
|
+
spinnerSize?: ExtendedComponentSize;
|
|
32
|
+
/**
|
|
33
|
+
* Spinner color variant
|
|
34
|
+
* @default 'primary'
|
|
35
|
+
*/
|
|
36
|
+
spinnerVariant?: SpinnerVariant;
|
|
37
|
+
/**
|
|
38
|
+
* Spinner animation speed
|
|
39
|
+
* @default 'normal'
|
|
40
|
+
*/
|
|
41
|
+
spinnerSpeed?: SpinnerSpeed;
|
|
42
|
+
/**
|
|
43
|
+
* Optional message to display below spinner
|
|
44
|
+
*/
|
|
45
|
+
message?: ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Enable backdrop blur effect
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
blur?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Backdrop opacity (0-1)
|
|
53
|
+
* @default 0.7
|
|
54
|
+
*/
|
|
55
|
+
backdropOpacity?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Custom z-index for the overlay
|
|
58
|
+
*/
|
|
59
|
+
zIndex?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Transition duration in milliseconds
|
|
62
|
+
* @default 200
|
|
63
|
+
*/
|
|
64
|
+
transitionDuration?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Custom spinner element (overrides spinnerStyle, spinnerSize, spinnerVariant)
|
|
67
|
+
*/
|
|
68
|
+
customSpinner?: ReactNode;
|
|
69
|
+
/**
|
|
70
|
+
* Border radius for the overlay to match child content
|
|
71
|
+
* Accepts any valid CSS border-radius value
|
|
72
|
+
*/
|
|
73
|
+
borderRadius?: string | number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* LoadingOverlay - Overlay component for showing loading state over content
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* // Container mode - wraps content
|
|
81
|
+
* <LoadingOverlay visible={isLoading}>
|
|
82
|
+
* <div>Content to overlay</div>
|
|
83
|
+
* </LoadingOverlay>
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* // Fullscreen mode
|
|
89
|
+
* <LoadingOverlay visible={isLoading} mode="fullscreen" message="Loading..." />
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```tsx
|
|
94
|
+
* // With blur effect
|
|
95
|
+
* <LoadingOverlay visible={isLoading} blur backdropOpacity={0.5}>
|
|
96
|
+
* <div>Blurred content</div>
|
|
97
|
+
* </LoadingOverlay>
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare const LoadingOverlay: React.ForwardRefExoticComponent<LoadingOverlayProps & React.RefAttributes<HTMLDivElement>>;
|
|
101
|
+
export default LoadingOverlay;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { IconName } from '../../display/Icon/icons';
|
|
3
|
+
import { BaseComponentProps } from '../../../types';
|
|
4
|
+
/**
|
|
5
|
+
* Toast position options
|
|
6
|
+
*/
|
|
7
|
+
export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
8
|
+
/**
|
|
9
|
+
* Toast variant types
|
|
10
|
+
*/
|
|
11
|
+
export type ToastVariant = 'info' | 'success' | 'warning' | 'error' | 'loading';
|
|
12
|
+
/**
|
|
13
|
+
* Toast animation state
|
|
14
|
+
*/
|
|
15
|
+
export type ToastAnimationState = 'entering' | 'entered' | 'exiting' | 'exited';
|
|
16
|
+
/**
|
|
17
|
+
* Single toast props
|
|
18
|
+
*/
|
|
19
|
+
export interface ToastProps extends BaseComponentProps {
|
|
20
|
+
/**
|
|
21
|
+
* Unique toast ID
|
|
22
|
+
*/
|
|
23
|
+
id: string;
|
|
24
|
+
/**
|
|
25
|
+
* Toast variant
|
|
26
|
+
* @default 'info'
|
|
27
|
+
*/
|
|
28
|
+
variant?: ToastVariant;
|
|
29
|
+
/**
|
|
30
|
+
* Toast title
|
|
31
|
+
*/
|
|
32
|
+
title?: ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Toast message/description
|
|
35
|
+
*/
|
|
36
|
+
message?: ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* Custom icon (overrides variant default)
|
|
39
|
+
*/
|
|
40
|
+
icon?: IconName | ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Hide the icon
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
hideIcon?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Duration in milliseconds (0 for persistent)
|
|
48
|
+
* @default 5000
|
|
49
|
+
*/
|
|
50
|
+
duration?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Whether toast can be dismissed by user
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
dismissible?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Action button configuration
|
|
58
|
+
*/
|
|
59
|
+
action?: {
|
|
60
|
+
label: string;
|
|
61
|
+
onClick: () => void;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Callback when toast is dismissed
|
|
65
|
+
*/
|
|
66
|
+
onDismiss?: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to show progress bar for duration
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
showProgress?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Whether to pause duration on hover
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
pauseOnHover?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Custom render function for toast content
|
|
79
|
+
*/
|
|
80
|
+
render?: (props: {
|
|
81
|
+
toast: ToastProps;
|
|
82
|
+
dismiss: () => void;
|
|
83
|
+
}) => ReactNode;
|
|
84
|
+
/**
|
|
85
|
+
* Animation state (managed by container)
|
|
86
|
+
*/
|
|
87
|
+
animationState?: ToastAnimationState;
|
|
88
|
+
/**
|
|
89
|
+
* Animation duration in ms
|
|
90
|
+
* @default 200
|
|
91
|
+
*/
|
|
92
|
+
animationDuration?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Position (for animation direction)
|
|
95
|
+
*/
|
|
96
|
+
position?: ToastPosition;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Toast component
|
|
100
|
+
* Single toast notification with auto-dismiss and actions
|
|
101
|
+
*/
|
|
102
|
+
export declare const Toast: React.FC<ToastProps>;
|
|
103
|
+
export default Toast;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { BaseComponentProps } from '../../../types';
|
|
3
|
+
import { ToastPosition } from './Toast';
|
|
4
|
+
/**
|
|
5
|
+
* Toast container props
|
|
6
|
+
*/
|
|
7
|
+
export interface ToastContainerProps extends BaseComponentProps {
|
|
8
|
+
/**
|
|
9
|
+
* Position for toasts
|
|
10
|
+
* @default 'top-right'
|
|
11
|
+
*/
|
|
12
|
+
position?: ToastPosition;
|
|
13
|
+
/**
|
|
14
|
+
* Gap between toasts in pixels
|
|
15
|
+
* @default 12
|
|
16
|
+
*/
|
|
17
|
+
gap?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Offset from viewport edge
|
|
20
|
+
* @default 16
|
|
21
|
+
*/
|
|
22
|
+
offset?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Custom z-index
|
|
25
|
+
*/
|
|
26
|
+
zIndex?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Children (toast elements)
|
|
29
|
+
*/
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Toast container component
|
|
34
|
+
* Positions and stacks toast notifications
|
|
35
|
+
*/
|
|
36
|
+
export declare const ToastContainer: React.FC<ToastContainerProps>;
|
|
37
|
+
export default ToastContainer;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ToastProps, ToastPosition } from './Toast';
|
|
2
|
+
/**
|
|
3
|
+
* Toast data for creating new toasts
|
|
4
|
+
*/
|
|
5
|
+
export interface ToastData extends Omit<ToastProps, 'id' | 'animationState' | 'onDismiss'> {
|
|
6
|
+
/**
|
|
7
|
+
* Optional ID (auto-generated if not provided)
|
|
8
|
+
*/
|
|
9
|
+
id?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Toast instance with full props and internal state
|
|
13
|
+
*/
|
|
14
|
+
export interface ToastInstance extends ToastProps {
|
|
15
|
+
/**
|
|
16
|
+
* Timestamp when toast was created
|
|
17
|
+
*/
|
|
18
|
+
createdAt: number;
|
|
19
|
+
/**
|
|
20
|
+
* Timestamp when toast was paused (if paused)
|
|
21
|
+
*/
|
|
22
|
+
pausedAt?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Remaining duration when paused
|
|
25
|
+
*/
|
|
26
|
+
remainingDuration?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Promise toast options
|
|
30
|
+
*/
|
|
31
|
+
export interface PromiseToastOptions<T> {
|
|
32
|
+
/**
|
|
33
|
+
* Message or data to show while loading
|
|
34
|
+
*/
|
|
35
|
+
loading: string | Partial<ToastData>;
|
|
36
|
+
/**
|
|
37
|
+
* Message or data to show on success
|
|
38
|
+
* Can be a function that receives the result
|
|
39
|
+
*/
|
|
40
|
+
success: string | Partial<ToastData> | ((data: T) => string | Partial<ToastData>);
|
|
41
|
+
/**
|
|
42
|
+
* Message or data to show on error
|
|
43
|
+
* Can be a function that receives the error
|
|
44
|
+
*/
|
|
45
|
+
error: string | Partial<ToastData> | ((error: Error) => string | Partial<ToastData>);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Toast context value
|
|
49
|
+
*/
|
|
50
|
+
export interface ToastContextValue {
|
|
51
|
+
/**
|
|
52
|
+
* Current toast instances
|
|
53
|
+
*/
|
|
54
|
+
toasts: ToastInstance[];
|
|
55
|
+
/**
|
|
56
|
+
* Add a new toast
|
|
57
|
+
* @returns Toast ID
|
|
58
|
+
*/
|
|
59
|
+
addToast: (data: ToastData) => string;
|
|
60
|
+
/**
|
|
61
|
+
* Remove a toast by ID
|
|
62
|
+
*/
|
|
63
|
+
removeToast: (id: string) => void;
|
|
64
|
+
/**
|
|
65
|
+
* Update a toast
|
|
66
|
+
*/
|
|
67
|
+
updateToast: (id: string, data: Partial<ToastData>) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Remove all toasts
|
|
70
|
+
*/
|
|
71
|
+
removeAllToasts: () => void;
|
|
72
|
+
/**
|
|
73
|
+
* Pause a toast's timer
|
|
74
|
+
*/
|
|
75
|
+
pauseToast: (id: string) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Resume a toast's timer
|
|
78
|
+
*/
|
|
79
|
+
resumeToast: (id: string) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Show a success toast
|
|
82
|
+
*/
|
|
83
|
+
success: (message: string, options?: Partial<ToastData>) => string;
|
|
84
|
+
/**
|
|
85
|
+
* Show an error toast
|
|
86
|
+
*/
|
|
87
|
+
error: (message: string, options?: Partial<ToastData>) => string;
|
|
88
|
+
/**
|
|
89
|
+
* Show a warning toast
|
|
90
|
+
*/
|
|
91
|
+
warning: (message: string, options?: Partial<ToastData>) => string;
|
|
92
|
+
/**
|
|
93
|
+
* Show an info toast
|
|
94
|
+
*/
|
|
95
|
+
info: (message: string, options?: Partial<ToastData>) => string;
|
|
96
|
+
/**
|
|
97
|
+
* Show a loading toast
|
|
98
|
+
*/
|
|
99
|
+
loading: (message: string, options?: Partial<ToastData>) => string;
|
|
100
|
+
/**
|
|
101
|
+
* Promise-based toast that shows loading, then success/error
|
|
102
|
+
* @returns Original promise result
|
|
103
|
+
*/
|
|
104
|
+
promise: <T>(promise: Promise<T>, options: PromiseToastOptions<T>) => Promise<T>;
|
|
105
|
+
/**
|
|
106
|
+
* Container position
|
|
107
|
+
*/
|
|
108
|
+
position: ToastPosition;
|
|
109
|
+
/**
|
|
110
|
+
* Maximum visible toasts
|
|
111
|
+
*/
|
|
112
|
+
maxVisible: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Toast context
|
|
116
|
+
*/
|
|
117
|
+
export declare const ToastContext: import('react').Context<ToastContextValue | null>;
|
|
118
|
+
/**
|
|
119
|
+
* Hook to access toast context (returns null if not in provider)
|
|
120
|
+
*/
|
|
121
|
+
export declare function useToastContext(): ToastContextValue | null;
|
|
122
|
+
/**
|
|
123
|
+
* Hook to access toast context (throws if not in provider)
|
|
124
|
+
* @throws Error if used outside of ToastProvider
|
|
125
|
+
*/
|
|
126
|
+
export declare function useToastContextStrict(): ToastContextValue;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ToastPosition } from './Toast';
|
|
3
|
+
import { ToastData } from './ToastContext';
|
|
4
|
+
/**
|
|
5
|
+
* Toast provider props
|
|
6
|
+
*/
|
|
7
|
+
export interface ToastProviderProps {
|
|
8
|
+
/**
|
|
9
|
+
* Children to render
|
|
10
|
+
*/
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Position for toasts
|
|
14
|
+
* @default 'top-right'
|
|
15
|
+
*/
|
|
16
|
+
position?: ToastPosition;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum number of visible toasts
|
|
19
|
+
* @default 5
|
|
20
|
+
*/
|
|
21
|
+
maxVisible?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Gap between toasts in pixels
|
|
24
|
+
* @default 12
|
|
25
|
+
*/
|
|
26
|
+
gap?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Offset from viewport edge
|
|
29
|
+
* @default 16
|
|
30
|
+
*/
|
|
31
|
+
offset?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Default duration for toasts in milliseconds
|
|
34
|
+
* @default 5000
|
|
35
|
+
*/
|
|
36
|
+
defaultDuration?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Animation duration in milliseconds
|
|
39
|
+
* @default 200
|
|
40
|
+
*/
|
|
41
|
+
animationDuration?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Default props to apply to all toasts
|
|
44
|
+
*/
|
|
45
|
+
defaultToastProps?: Partial<ToastData>;
|
|
46
|
+
/**
|
|
47
|
+
* Custom z-index for toast container
|
|
48
|
+
*/
|
|
49
|
+
zIndex?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Toast provider component
|
|
53
|
+
* Manages a stack of toasts for programmatic creation
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <ToastProvider position="top-right" maxVisible={5}>
|
|
58
|
+
* <App />
|
|
59
|
+
* </ToastProvider>
|
|
60
|
+
*
|
|
61
|
+
* // In a component:
|
|
62
|
+
* const toast = useToast();
|
|
63
|
+
*
|
|
64
|
+
* toast.success('Changes saved successfully');
|
|
65
|
+
* toast.error('Failed to save changes');
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function ToastProvider({ children, position, maxVisible, gap, offset, defaultDuration, animationDuration, defaultToastProps, zIndex, }: ToastProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
export declare namespace ToastProvider {
|
|
70
|
+
var displayName: string;
|
|
71
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toast component exports
|
|
3
|
+
*/
|
|
4
|
+
export { Toast } from './Toast';
|
|
5
|
+
export type { ToastProps, ToastPosition, ToastVariant, ToastAnimationState, } from './Toast';
|
|
6
|
+
export { ToastContainer } from './ToastContainer';
|
|
7
|
+
export type { ToastContainerProps } from './ToastContainer';
|
|
8
|
+
export { ToastProvider } from './ToastProvider';
|
|
9
|
+
export type { ToastProviderProps } from './ToastProvider';
|
|
10
|
+
export { ToastContext, useToastContext, useToastContextStrict, } from './ToastContext';
|
|
11
|
+
export type { ToastContextValue, ToastData, ToastInstance, PromiseToastOptions, } from './ToastContext';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { PageMessageStateConfig, LoadingStateConfig, PageMessagesProps } from '../../components/display/PageMessages/types';
|
|
3
|
+
/**
|
|
4
|
+
* Default configurations for all page message states
|
|
5
|
+
*/
|
|
6
|
+
export interface PageMessagesDefaults {
|
|
7
|
+
/** Default loading configuration */
|
|
8
|
+
loading?: LoadingStateConfig;
|
|
9
|
+
/** Default error configuration */
|
|
10
|
+
error?: PageMessageStateConfig;
|
|
11
|
+
/** Default forbidden configuration */
|
|
12
|
+
forbidden?: PageMessageStateConfig;
|
|
13
|
+
/** Default not-found configuration */
|
|
14
|
+
notFound?: PageMessageStateConfig;
|
|
15
|
+
/** Default unauthorized configuration */
|
|
16
|
+
unauthorized?: PageMessageStateConfig;
|
|
17
|
+
/** Default maintenance configuration */
|
|
18
|
+
maintenance?: PageMessageStateConfig;
|
|
19
|
+
/** Default offline configuration */
|
|
20
|
+
offline?: PageMessageStateConfig;
|
|
21
|
+
/** Default timeout configuration */
|
|
22
|
+
timeout?: PageMessageStateConfig;
|
|
23
|
+
/** Default empty configuration */
|
|
24
|
+
empty?: PageMessageStateConfig;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Global actions that can be provided app-wide
|
|
28
|
+
*/
|
|
29
|
+
export interface PageMessagesGlobalActions {
|
|
30
|
+
/** Default retry handler */
|
|
31
|
+
onRetry?: () => void;
|
|
32
|
+
/** Default go back handler */
|
|
33
|
+
onGoBack?: () => void;
|
|
34
|
+
/** Default go home handler */
|
|
35
|
+
onGoHome?: () => void;
|
|
36
|
+
/** Default login handler */
|
|
37
|
+
onLogin?: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Context value for PageMessages
|
|
41
|
+
*/
|
|
42
|
+
export interface PageMessagesContextValue {
|
|
43
|
+
/** Default state configurations */
|
|
44
|
+
defaults: PageMessagesDefaults;
|
|
45
|
+
/** Global action handlers */
|
|
46
|
+
actions: PageMessagesGlobalActions;
|
|
47
|
+
/** Default component props */
|
|
48
|
+
defaultProps?: Partial<Pick<PageMessagesProps, 'size' | 'fullScreen' | 'centerVertically' | 'minHeight'>>;
|
|
49
|
+
}
|
|
50
|
+
export interface PageMessagesProviderProps {
|
|
51
|
+
children: ReactNode;
|
|
52
|
+
/** Default configurations for page message states */
|
|
53
|
+
defaults?: PageMessagesDefaults;
|
|
54
|
+
/** Global action handlers */
|
|
55
|
+
actions?: PageMessagesGlobalActions;
|
|
56
|
+
/** Default component props */
|
|
57
|
+
defaultProps?: PageMessagesContextValue['defaultProps'];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Provider for PageMessages defaults and global configuration
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <PageMessagesProvider
|
|
65
|
+
* defaults={{
|
|
66
|
+
* error: {
|
|
67
|
+
* title: 'Oops! Something went wrong',
|
|
68
|
+
* description: 'Please try again later',
|
|
69
|
+
* icon: 'error',
|
|
70
|
+
* },
|
|
71
|
+
* }}
|
|
72
|
+
* actions={{
|
|
73
|
+
* onGoHome: () => router.push('/'),
|
|
74
|
+
* onLogin: () => router.push('/login'),
|
|
75
|
+
* }}
|
|
76
|
+
* >
|
|
77
|
+
* <App />
|
|
78
|
+
* </PageMessagesProvider>
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function PageMessagesProvider({ children, defaults, actions, defaultProps, }: PageMessagesProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
/**
|
|
83
|
+
* Hook to access PageMessages context
|
|
84
|
+
* Returns undefined if not within provider (uses built-in defaults)
|
|
85
|
+
*/
|
|
86
|
+
export declare function usePageMessages(): PageMessagesContextValue | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Hook to get merged configuration (context defaults + component props)
|
|
89
|
+
* For internal use by PageMessages component
|
|
90
|
+
*/
|
|
91
|
+
export declare function usePageMessagesConfig(componentProps: Partial<PageMessagesProps>): PageMessagesContextValue;
|
package/lib/contexts/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { ThemeProvider, useTheme } from './ThemeContext';
|
|
2
2
|
export type { ThemeProviderProps } from './ThemeContext';
|
|
3
|
+
export { PageMessagesProvider, usePageMessages } from './PageMessagesContext';
|
|
4
|
+
export type { PageMessagesProviderProps, PageMessagesContextValue, PageMessagesDefaults, PageMessagesGlobalActions, } from './PageMessagesContext';
|
package/lib/hooks/index.d.ts
CHANGED
|
@@ -9,3 +9,13 @@ export type { UsePopoverPositionOptions, UsePopoverPositionReturn, } from './use
|
|
|
9
9
|
export { useHover } from './useHover';
|
|
10
10
|
export type { UseHoverOptions, UseHoverReturn, HoverProps } from './useHover';
|
|
11
11
|
export { useDebounce } from './useDebounce';
|
|
12
|
+
export { useDialog } from './useDialog';
|
|
13
|
+
export type { UseDialogOptions, UseDialogReturn } from './useDialog';
|
|
14
|
+
export { useAlert } from './useAlert';
|
|
15
|
+
export type { UseAlertOptions, UseAlertReturn } from './useAlert';
|
|
16
|
+
export { useToast } from './useToast';
|
|
17
|
+
export type { UseToastOptions, UseToastReturn } from './useToast';
|
|
18
|
+
export { useAsyncToast } from './useAsyncToast';
|
|
19
|
+
export type { UseAsyncToastReturn, AsyncToastConfig } from './useAsyncToast';
|
|
20
|
+
export { useResizeObserver } from './useResizeObserver';
|
|
21
|
+
export type { UseResizeObserverOptions, UseResizeObserverReturn } from './useResizeObserver';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AlertProps } from '../../components/overlays/Alert';
|
|
2
|
+
/**
|
|
3
|
+
* Hook options
|
|
4
|
+
*/
|
|
5
|
+
export interface UseAlertOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Default props to apply to all alerts
|
|
8
|
+
*/
|
|
9
|
+
defaultProps?: Partial<AlertProps>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Hook return type
|
|
13
|
+
*/
|
|
14
|
+
export interface UseAlertReturn {
|
|
15
|
+
/**
|
|
16
|
+
* Show a custom alert
|
|
17
|
+
* @returns Promise<boolean> - true if confirmed, false if cancelled
|
|
18
|
+
*/
|
|
19
|
+
alert: (props: Omit<AlertProps, 'isOpen' | 'onConfirm' | 'onCancel'>) => Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Show a confirmation dialog
|
|
22
|
+
* @param title - Alert title
|
|
23
|
+
* @param description - Alert description
|
|
24
|
+
* @param options - Additional alert options
|
|
25
|
+
* @returns Promise<boolean> - true if confirmed, false if cancelled
|
|
26
|
+
*/
|
|
27
|
+
confirm: (title: string, description?: string, options?: Partial<AlertProps>) => Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Show an error alert
|
|
30
|
+
* @param title - Alert title
|
|
31
|
+
* @param description - Alert description
|
|
32
|
+
* @param options - Additional alert options
|
|
33
|
+
* @returns Promise<boolean> - true when dismissed
|
|
34
|
+
*/
|
|
35
|
+
error: (title: string, description?: string, options?: Partial<AlertProps>) => Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Show a success alert
|
|
38
|
+
* @param title - Alert title
|
|
39
|
+
* @param description - Alert description
|
|
40
|
+
* @param options - Additional alert options
|
|
41
|
+
* @returns Promise<boolean> - true when dismissed
|
|
42
|
+
*/
|
|
43
|
+
success: (title: string, description?: string, options?: Partial<AlertProps>) => Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Show a warning alert
|
|
46
|
+
* @param title - Alert title
|
|
47
|
+
* @param description - Alert description
|
|
48
|
+
* @param options - Additional alert options
|
|
49
|
+
* @returns Promise<boolean> - true when dismissed
|
|
50
|
+
*/
|
|
51
|
+
warning: (title: string, description?: string, options?: Partial<AlertProps>) => Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Show an info alert
|
|
54
|
+
* @param title - Alert title
|
|
55
|
+
* @param description - Alert description
|
|
56
|
+
* @param options - Additional alert options
|
|
57
|
+
* @returns Promise<boolean> - true when dismissed
|
|
58
|
+
*/
|
|
59
|
+
info: (title: string, description?: string, options?: Partial<AlertProps>) => Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Dismiss current alert
|
|
62
|
+
*/
|
|
63
|
+
dismiss: () => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Hook for programmatically creating alerts
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* function MyComponent() {
|
|
71
|
+
* const alert = useAlert();
|
|
72
|
+
*
|
|
73
|
+
* const handleDelete = async () => {
|
|
74
|
+
* const confirmed = await alert.confirm(
|
|
75
|
+
* 'Delete Item',
|
|
76
|
+
* 'Are you sure you want to delete this item? This action cannot be undone.',
|
|
77
|
+
* { confirmVariant: 'danger' }
|
|
78
|
+
* );
|
|
79
|
+
*
|
|
80
|
+
* if (confirmed) {
|
|
81
|
+
* // Perform deletion
|
|
82
|
+
* await deleteItem();
|
|
83
|
+
* alert.success('Deleted', 'Item has been deleted successfully.');
|
|
84
|
+
* }
|
|
85
|
+
* };
|
|
86
|
+
*
|
|
87
|
+
* const handleError = () => {
|
|
88
|
+
* alert.error('Operation Failed', 'Something went wrong. Please try again.');
|
|
89
|
+
* };
|
|
90
|
+
*
|
|
91
|
+
* return (
|
|
92
|
+
* <Button onClick={handleDelete} variant="danger">
|
|
93
|
+
* Delete
|
|
94
|
+
* </Button>
|
|
95
|
+
* );
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function useAlert(options?: UseAlertOptions): UseAlertReturn;
|