@true-tech-team/react-components 0.0.4 → 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 +10 -0
- package/index.js +1 -1
- package/index.mjs +10539 -6746
- 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/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/OverflowText/OverflowText.d.ts +81 -0
- package/lib/components/display/OverflowText/index.d.ts +2 -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/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 +44 -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/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/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/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 +16 -1
- package/package.json +1 -1
|
@@ -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,5 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
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';
|
|
3
6
|
import { ThemeConfig } from '../../types';
|
|
4
7
|
export interface GlobalProviderProps {
|
|
5
8
|
/**
|
|
@@ -18,6 +21,18 @@ export interface GlobalProviderProps {
|
|
|
18
21
|
* PageMessages default configuration
|
|
19
22
|
*/
|
|
20
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'>;
|
|
21
36
|
}
|
|
22
37
|
/**
|
|
23
38
|
* GlobalProvider component that wraps the entire application
|
|
@@ -57,5 +72,5 @@ export interface GlobalProviderProps {
|
|
|
57
72
|
* </GlobalProvider>
|
|
58
73
|
* ```
|
|
59
74
|
*/
|
|
60
|
-
export declare function GlobalProvider({ children, themeConfig, injectGlobalStyles, pageMessagesConfig, }: 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;
|
|
61
76
|
export default GlobalProvider;
|