@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,102 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { DialogProps, DialogSize } from '../Dialog';
|
|
3
|
+
import { IconName } from '../../display/Icon/icons';
|
|
4
|
+
import { AlertVariant } from './AlertPresets';
|
|
5
|
+
/**
|
|
6
|
+
* Alert props - extends Dialog with preset configurations
|
|
7
|
+
*/
|
|
8
|
+
export interface AlertProps extends Omit<DialogProps, 'actions' | 'renderHeader' | 'renderFooter'> {
|
|
9
|
+
/**
|
|
10
|
+
* Alert variant (determines icon, colors, default buttons)
|
|
11
|
+
* @default 'info'
|
|
12
|
+
*/
|
|
13
|
+
variant?: AlertVariant;
|
|
14
|
+
/**
|
|
15
|
+
* Alert icon (overrides variant default)
|
|
16
|
+
*/
|
|
17
|
+
icon?: IconName | ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Hide the icon
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
hideIcon?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Description/message content
|
|
25
|
+
*/
|
|
26
|
+
description?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* Confirm button text
|
|
29
|
+
* @default 'OK' (or 'Confirm' for confirm variant)
|
|
30
|
+
*/
|
|
31
|
+
confirmText?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Cancel button text (only shown for confirm variant or when explicitly provided)
|
|
34
|
+
*/
|
|
35
|
+
cancelText?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Callback when confirm is clicked
|
|
38
|
+
*/
|
|
39
|
+
onConfirm?: () => void | Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Callback when cancel is clicked
|
|
42
|
+
*/
|
|
43
|
+
onCancel?: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Whether confirm button is loading
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
loading?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Whether confirm button is disabled
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
confirmDisabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Confirm button variant
|
|
56
|
+
*/
|
|
57
|
+
confirmVariant?: 'primary' | 'danger' | 'success' | 'warning';
|
|
58
|
+
/**
|
|
59
|
+
* Additional actions to render
|
|
60
|
+
*/
|
|
61
|
+
extraActions?: ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* Override default size for alerts
|
|
64
|
+
* @default 'sm'
|
|
65
|
+
*/
|
|
66
|
+
size?: DialogSize;
|
|
67
|
+
/**
|
|
68
|
+
* Show cancel button
|
|
69
|
+
* @default true for confirm variant, false for others
|
|
70
|
+
*/
|
|
71
|
+
showCancel?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Alert component
|
|
75
|
+
* A dialog variant with preset configurations for common alert types
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* // Simple info alert
|
|
80
|
+
* <Alert
|
|
81
|
+
* isOpen={isOpen}
|
|
82
|
+
* onClose={() => setIsOpen(false)}
|
|
83
|
+
* variant="info"
|
|
84
|
+
* title="Information"
|
|
85
|
+
* description="This is an informational message."
|
|
86
|
+
* />
|
|
87
|
+
*
|
|
88
|
+
* // Confirmation alert
|
|
89
|
+
* <Alert
|
|
90
|
+
* isOpen={isOpen}
|
|
91
|
+
* onClose={() => setIsOpen(false)}
|
|
92
|
+
* variant="confirm"
|
|
93
|
+
* title="Delete Item"
|
|
94
|
+
* description="Are you sure you want to delete this item?"
|
|
95
|
+
* onConfirm={handleDelete}
|
|
96
|
+
* onCancel={() => setIsOpen(false)}
|
|
97
|
+
* confirmVariant="danger"
|
|
98
|
+
* />
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare const Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>>;
|
|
102
|
+
export default Alert;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { AlertProps } from './Alert';
|
|
2
|
+
/**
|
|
3
|
+
* Alert queue item representing a pending alert
|
|
4
|
+
*/
|
|
5
|
+
export interface AlertQueueItem {
|
|
6
|
+
/**
|
|
7
|
+
* Unique alert ID
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Alert props (excluding isOpen which is managed by context)
|
|
12
|
+
*/
|
|
13
|
+
props: Omit<AlertProps, 'isOpen' | 'onConfirm' | 'onCancel'>;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve function for promise-based alert
|
|
16
|
+
* Resolves with true if confirmed, false if cancelled
|
|
17
|
+
*/
|
|
18
|
+
resolve: (confirmed: boolean) => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Alert context value
|
|
22
|
+
*/
|
|
23
|
+
export interface AlertContextValue {
|
|
24
|
+
/**
|
|
25
|
+
* Current alert queue
|
|
26
|
+
*/
|
|
27
|
+
alerts: AlertQueueItem[];
|
|
28
|
+
/**
|
|
29
|
+
* Show an alert and wait for user response
|
|
30
|
+
* @returns Promise<boolean> - true if confirmed, false if cancelled
|
|
31
|
+
*/
|
|
32
|
+
alert: (props: Omit<AlertProps, 'isOpen' | 'onConfirm' | 'onCancel'>) => Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Show a confirmation alert
|
|
35
|
+
* @param title - Alert title
|
|
36
|
+
* @param description - Alert description
|
|
37
|
+
* @param options - Additional alert options
|
|
38
|
+
* @returns Promise<boolean> - true if confirmed, false if cancelled
|
|
39
|
+
*/
|
|
40
|
+
confirm: (title: string, description?: string, options?: Partial<Omit<AlertProps, 'isOpen' | 'onConfirm' | 'onCancel' | 'title' | 'description'>>) => Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Show an error alert
|
|
43
|
+
* @param title - Alert title
|
|
44
|
+
* @param description - Alert description
|
|
45
|
+
* @param options - Additional alert options
|
|
46
|
+
* @returns Promise<boolean> - true when dismissed
|
|
47
|
+
*/
|
|
48
|
+
error: (title: string, description?: string, options?: Partial<Omit<AlertProps, 'isOpen' | 'onConfirm' | 'onCancel' | 'title' | 'description'>>) => Promise<boolean>;
|
|
49
|
+
/**
|
|
50
|
+
* Show a success alert
|
|
51
|
+
* @param title - Alert title
|
|
52
|
+
* @param description - Alert description
|
|
53
|
+
* @param options - Additional alert options
|
|
54
|
+
* @returns Promise<boolean> - true when dismissed
|
|
55
|
+
*/
|
|
56
|
+
success: (title: string, description?: string, options?: Partial<Omit<AlertProps, 'isOpen' | 'onConfirm' | 'onCancel' | 'title' | 'description'>>) => Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Show a warning alert
|
|
59
|
+
* @param title - Alert title
|
|
60
|
+
* @param description - Alert description
|
|
61
|
+
* @param options - Additional alert options
|
|
62
|
+
* @returns Promise<boolean> - true when dismissed
|
|
63
|
+
*/
|
|
64
|
+
warning: (title: string, description?: string, options?: Partial<Omit<AlertProps, 'isOpen' | 'onConfirm' | 'onCancel' | 'title' | 'description'>>) => Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Show an info alert
|
|
67
|
+
* @param title - Alert title
|
|
68
|
+
* @param description - Alert description
|
|
69
|
+
* @param options - Additional alert options
|
|
70
|
+
* @returns Promise<boolean> - true when dismissed
|
|
71
|
+
*/
|
|
72
|
+
info: (title: string, description?: string, options?: Partial<Omit<AlertProps, 'isOpen' | 'onConfirm' | 'onCancel' | 'title' | 'description'>>) => Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Dismiss current alert (resolves with false)
|
|
75
|
+
*/
|
|
76
|
+
dismiss: () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Dismiss all alerts
|
|
79
|
+
*/
|
|
80
|
+
dismissAll: () => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Alert context
|
|
84
|
+
*/
|
|
85
|
+
export declare const AlertContext: import('react').Context<AlertContextValue | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Hook to access alert context (returns null if not in provider)
|
|
88
|
+
*/
|
|
89
|
+
export declare function useAlertContext(): AlertContextValue | null;
|
|
90
|
+
/**
|
|
91
|
+
* Hook to access alert context (throws if not in provider)
|
|
92
|
+
* @throws Error if used outside of AlertProvider
|
|
93
|
+
*/
|
|
94
|
+
export declare function useAlertContextStrict(): AlertContextValue;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IconName } from '../../display/Icon/icons';
|
|
2
|
+
/**
|
|
3
|
+
* Alert variant types
|
|
4
|
+
*/
|
|
5
|
+
export type AlertVariant = 'info' | 'success' | 'warning' | 'error' | 'confirm';
|
|
6
|
+
/**
|
|
7
|
+
* Alert preset configuration
|
|
8
|
+
*/
|
|
9
|
+
export interface AlertPreset {
|
|
10
|
+
/**
|
|
11
|
+
* Variant identifier
|
|
12
|
+
*/
|
|
13
|
+
variant: AlertVariant;
|
|
14
|
+
/**
|
|
15
|
+
* Default icon for the variant
|
|
16
|
+
*/
|
|
17
|
+
icon: IconName;
|
|
18
|
+
/**
|
|
19
|
+
* Default title for the variant
|
|
20
|
+
*/
|
|
21
|
+
title: string;
|
|
22
|
+
/**
|
|
23
|
+
* Default confirm button text
|
|
24
|
+
*/
|
|
25
|
+
confirmText: string;
|
|
26
|
+
/**
|
|
27
|
+
* Default cancel button text (only for confirm variant)
|
|
28
|
+
*/
|
|
29
|
+
cancelText?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Confirm button variant
|
|
32
|
+
*/
|
|
33
|
+
confirmVariant: 'primary' | 'danger' | 'success' | 'warning';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Preset configurations for each alert variant
|
|
37
|
+
*/
|
|
38
|
+
export declare const ALERT_PRESETS: Record<AlertVariant, AlertPreset>;
|
|
39
|
+
/**
|
|
40
|
+
* Get preset configuration for a variant
|
|
41
|
+
*/
|
|
42
|
+
export declare function getAlertPreset(variant: AlertVariant): AlertPreset;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AlertProps } from './Alert';
|
|
3
|
+
/**
|
|
4
|
+
* Alert provider props
|
|
5
|
+
*/
|
|
6
|
+
export interface AlertProviderProps {
|
|
7
|
+
/**
|
|
8
|
+
* Children to render
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Default props to apply to all alerts
|
|
13
|
+
*/
|
|
14
|
+
defaultAlertProps?: Partial<AlertProps>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Alert provider component
|
|
18
|
+
* Manages a queue of alerts for programmatic creation
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <AlertProvider>
|
|
23
|
+
* <App />
|
|
24
|
+
* </AlertProvider>
|
|
25
|
+
*
|
|
26
|
+
* // In a component:
|
|
27
|
+
* const { confirm, error, success } = useAlert();
|
|
28
|
+
*
|
|
29
|
+
* const handleDelete = async () => {
|
|
30
|
+
* const confirmed = await confirm('Delete Item', 'Are you sure?');
|
|
31
|
+
* if (confirmed) {
|
|
32
|
+
* // perform delete
|
|
33
|
+
* }
|
|
34
|
+
* };
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function AlertProvider({ children, defaultAlertProps, }: AlertProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare namespace AlertProvider {
|
|
39
|
+
var displayName: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alert component exports
|
|
3
|
+
*/
|
|
4
|
+
export { Alert } from './Alert';
|
|
5
|
+
export type { AlertProps } from './Alert';
|
|
6
|
+
export { AlertProvider } from './AlertProvider';
|
|
7
|
+
export type { AlertProviderProps } from './AlertProvider';
|
|
8
|
+
export { AlertContext, useAlertContext, useAlertContextStrict, } from './AlertContext';
|
|
9
|
+
export type { AlertContextValue, AlertQueueItem, } from './AlertContext';
|
|
10
|
+
export { ALERT_PRESETS, getAlertPreset, } from './AlertPresets';
|
|
11
|
+
export type { AlertVariant, AlertPreset, } from './AlertPresets';
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { BaseComponentProps } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Dialog size options
|
|
5
|
+
*/
|
|
6
|
+
export type DialogSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
|
|
7
|
+
/**
|
|
8
|
+
* Dialog props
|
|
9
|
+
*/
|
|
10
|
+
export interface DialogProps extends Omit<BaseComponentProps, 'children'> {
|
|
11
|
+
/**
|
|
12
|
+
* Whether the dialog is open (controlled)
|
|
13
|
+
*/
|
|
14
|
+
isOpen?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Default open state (uncontrolled)
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
defaultOpen?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback when open state changes
|
|
22
|
+
*/
|
|
23
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback when dialog requests to close
|
|
26
|
+
*/
|
|
27
|
+
onClose?: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Dialog title (rendered in header)
|
|
30
|
+
*/
|
|
31
|
+
title?: ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Dialog content (main body)
|
|
34
|
+
*/
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Actions/buttons to render in footer
|
|
38
|
+
*/
|
|
39
|
+
actions?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Dialog size preset
|
|
42
|
+
* @default 'md'
|
|
43
|
+
*/
|
|
44
|
+
size?: DialogSize;
|
|
45
|
+
/**
|
|
46
|
+
* Custom width (overrides size preset)
|
|
47
|
+
*/
|
|
48
|
+
width?: string | number;
|
|
49
|
+
/**
|
|
50
|
+
* Maximum height (content scrolls if exceeded)
|
|
51
|
+
*/
|
|
52
|
+
maxHeight?: string | number;
|
|
53
|
+
/**
|
|
54
|
+
* Close when clicking backdrop
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
closeOnBackdropClick?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Close when pressing Escape key
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
closeOnEscape?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether to show close button in header
|
|
65
|
+
* @default true
|
|
66
|
+
*/
|
|
67
|
+
showCloseButton?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Whether to trap focus within dialog
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
trapFocus?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Whether to block body scroll when open
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
77
|
+
blockScroll?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Enable backdrop blur effect
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
blurBackdrop?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Backdrop opacity (0-1)
|
|
85
|
+
* @default 0.5
|
|
86
|
+
*/
|
|
87
|
+
backdropOpacity?: number;
|
|
88
|
+
/**
|
|
89
|
+
* Custom z-index
|
|
90
|
+
*/
|
|
91
|
+
zIndex?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Animation duration in milliseconds
|
|
94
|
+
* @default 200
|
|
95
|
+
*/
|
|
96
|
+
animationDuration?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Dialog role for accessibility
|
|
99
|
+
* @default 'dialog'
|
|
100
|
+
*/
|
|
101
|
+
role?: 'dialog' | 'alertdialog';
|
|
102
|
+
/**
|
|
103
|
+
* ARIA labelledby ID
|
|
104
|
+
*/
|
|
105
|
+
'aria-labelledby'?: string;
|
|
106
|
+
/**
|
|
107
|
+
* ARIA describedby ID
|
|
108
|
+
*/
|
|
109
|
+
'aria-describedby'?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Whether dialog is modal (prevents interaction outside)
|
|
112
|
+
* @default true
|
|
113
|
+
*/
|
|
114
|
+
modal?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Render function for custom header
|
|
117
|
+
*/
|
|
118
|
+
renderHeader?: (props: {
|
|
119
|
+
title?: ReactNode;
|
|
120
|
+
onClose: () => void;
|
|
121
|
+
}) => ReactNode;
|
|
122
|
+
/**
|
|
123
|
+
* Render function for custom footer
|
|
124
|
+
*/
|
|
125
|
+
renderFooter?: (props: {
|
|
126
|
+
actions?: ReactNode;
|
|
127
|
+
onClose: () => void;
|
|
128
|
+
}) => ReactNode;
|
|
129
|
+
/**
|
|
130
|
+
* Custom class for backdrop
|
|
131
|
+
*/
|
|
132
|
+
backdropClassName?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Custom class for content container
|
|
135
|
+
*/
|
|
136
|
+
contentClassName?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Callback after open animation completes
|
|
139
|
+
*/
|
|
140
|
+
onOpenComplete?: () => void;
|
|
141
|
+
/**
|
|
142
|
+
* Callback after close animation completes
|
|
143
|
+
*/
|
|
144
|
+
onCloseComplete?: () => void;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Dialog header props (for compound component)
|
|
148
|
+
*/
|
|
149
|
+
export interface DialogHeaderProps extends BaseComponentProps {
|
|
150
|
+
/**
|
|
151
|
+
* Whether to show close button
|
|
152
|
+
* @default true
|
|
153
|
+
*/
|
|
154
|
+
showCloseButton?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Close button click handler
|
|
157
|
+
*/
|
|
158
|
+
onClose?: () => void;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Dialog body props (for compound component)
|
|
162
|
+
*/
|
|
163
|
+
export interface DialogBodyProps extends BaseComponentProps {
|
|
164
|
+
/**
|
|
165
|
+
* Enable scroll for content overflow
|
|
166
|
+
* @default true
|
|
167
|
+
*/
|
|
168
|
+
scrollable?: boolean;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Dialog footer props (for compound component)
|
|
172
|
+
*/
|
|
173
|
+
export interface DialogFooterProps extends BaseComponentProps {
|
|
174
|
+
/**
|
|
175
|
+
* Alignment of actions
|
|
176
|
+
* @default 'end'
|
|
177
|
+
*/
|
|
178
|
+
align?: 'start' | 'center' | 'end' | 'space-between';
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Dialog Header compound component
|
|
182
|
+
*/
|
|
183
|
+
export declare const DialogHeader: React.FC<DialogHeaderProps>;
|
|
184
|
+
/**
|
|
185
|
+
* Dialog Body compound component
|
|
186
|
+
*/
|
|
187
|
+
export declare const DialogBody: React.FC<DialogBodyProps>;
|
|
188
|
+
/**
|
|
189
|
+
* Dialog Footer compound component
|
|
190
|
+
*/
|
|
191
|
+
export declare const DialogFooter: React.FC<DialogFooterProps>;
|
|
192
|
+
/**
|
|
193
|
+
* Dialog component
|
|
194
|
+
* Modal dialog for user interactions with customizable content
|
|
195
|
+
*/
|
|
196
|
+
export declare const Dialog: React.ForwardRefExoticComponent<DialogProps & React.RefAttributes<HTMLDivElement>>;
|
|
197
|
+
export default Dialog;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { DialogProps } from './Dialog';
|
|
2
|
+
/**
|
|
3
|
+
* Dialog stack item representing an open dialog
|
|
4
|
+
*/
|
|
5
|
+
export interface DialogStackItem {
|
|
6
|
+
/**
|
|
7
|
+
* Unique dialog ID
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Dialog props (excluding isOpen which is managed by context)
|
|
12
|
+
*/
|
|
13
|
+
props: Omit<DialogProps, 'isOpen'>;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve function for promise-based dialog
|
|
16
|
+
*/
|
|
17
|
+
resolve?: (value: unknown) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Dialog context value
|
|
21
|
+
*/
|
|
22
|
+
export interface DialogContextValue {
|
|
23
|
+
/**
|
|
24
|
+
* Currently open dialogs (stack for nested support)
|
|
25
|
+
*/
|
|
26
|
+
dialogs: DialogStackItem[];
|
|
27
|
+
/**
|
|
28
|
+
* Open a new dialog
|
|
29
|
+
* @returns Promise that resolves when dialog closes with the result value
|
|
30
|
+
*/
|
|
31
|
+
openDialog: <T = void>(props: Omit<DialogProps, 'isOpen'>) => Promise<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Close a specific dialog by ID
|
|
34
|
+
* @param id - Dialog ID to close
|
|
35
|
+
* @param result - Optional result value to resolve the promise
|
|
36
|
+
*/
|
|
37
|
+
closeDialog: (id: string, result?: unknown) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Close the topmost dialog
|
|
40
|
+
* @param result - Optional result value to resolve the promise
|
|
41
|
+
*/
|
|
42
|
+
closeTopDialog: (result?: unknown) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Close all dialogs
|
|
45
|
+
*/
|
|
46
|
+
closeAllDialogs: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Update props of an open dialog
|
|
49
|
+
* @param id - Dialog ID to update
|
|
50
|
+
* @param props - Partial props to merge
|
|
51
|
+
*/
|
|
52
|
+
updateDialog: (id: string, props: Partial<DialogProps>) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Check if a dialog is open
|
|
55
|
+
* @param id - Dialog ID to check
|
|
56
|
+
*/
|
|
57
|
+
isDialogOpen: (id: string) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Get the count of open dialogs
|
|
60
|
+
*/
|
|
61
|
+
dialogCount: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Dialog context
|
|
65
|
+
*/
|
|
66
|
+
export declare const DialogContext: import('react').Context<DialogContextValue | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Hook to access dialog context (returns null if not in provider)
|
|
69
|
+
*/
|
|
70
|
+
export declare function useDialogContext(): DialogContextValue | null;
|
|
71
|
+
/**
|
|
72
|
+
* Hook to access dialog context (throws if not in provider)
|
|
73
|
+
* @throws Error if used outside of DialogProvider
|
|
74
|
+
*/
|
|
75
|
+
export declare function useDialogContextStrict(): DialogContextValue;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DialogProps } from './Dialog';
|
|
3
|
+
/**
|
|
4
|
+
* Dialog provider props
|
|
5
|
+
*/
|
|
6
|
+
export interface DialogProviderProps {
|
|
7
|
+
/**
|
|
8
|
+
* Children to render
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Default props to apply to all dialogs
|
|
13
|
+
*/
|
|
14
|
+
defaultDialogProps?: Partial<DialogProps>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Dialog provider component
|
|
18
|
+
* Manages a stack of dialogs for programmatic creation
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <DialogProvider>
|
|
23
|
+
* <App />
|
|
24
|
+
* </DialogProvider>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function DialogProvider({ children, defaultDialogProps, }: DialogProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare namespace DialogProvider {
|
|
29
|
+
var displayName: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dialog component exports
|
|
3
|
+
*/
|
|
4
|
+
export { Dialog, DialogHeader, DialogBody, DialogFooter, } from './Dialog';
|
|
5
|
+
export type { DialogProps, DialogSize, DialogHeaderProps, DialogBodyProps, DialogFooterProps, } from './Dialog';
|
|
6
|
+
export { DialogProvider } from './DialogProvider';
|
|
7
|
+
export type { DialogProviderProps } from './DialogProvider';
|
|
8
|
+
export { DialogContext, useDialogContext, useDialogContextStrict, } from './DialogContext';
|
|
9
|
+
export type { DialogContextValue, DialogStackItem, } from './DialogContext';
|