@true-tech-team/react-components 0.0.4 → 0.0.6

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.
Files changed (213) hide show
  1. package/index.css +1 -1
  2. package/index.d.ts +10 -0
  3. package/index.js +1 -1
  4. package/index.mjs +15961 -6871
  5. package/lib/components/buttons/ButtonToggleGroup/ButtonToggleGroup.d.ts +79 -0
  6. package/lib/components/buttons/ButtonToggleGroup/ButtonToggleGroupContext.d.ts +38 -0
  7. package/lib/components/buttons/ButtonToggleGroup/ButtonToggleGroupItem.d.ts +37 -0
  8. package/lib/components/buttons/ButtonToggleGroup/index.d.ts +7 -0
  9. package/lib/components/buttons/ToggleButton/ToggleButton.d.ts +96 -0
  10. package/lib/components/buttons/ToggleButton/index.d.ts +3 -0
  11. package/lib/components/display/Icon/icons/BookmarkFilled.d.ts +3 -0
  12. package/lib/components/display/Icon/icons/ChevronsLeft.d.ts +3 -0
  13. package/lib/components/display/Icon/icons/ChevronsRight.d.ts +3 -0
  14. package/lib/components/display/Icon/icons/HeartFilled.d.ts +3 -0
  15. package/lib/components/display/Icon/icons/More.d.ts +3 -0
  16. package/lib/components/display/Icon/icons/StarFilled.d.ts +3 -0
  17. package/lib/components/display/Icon/icons/ThumbsUpFilled.d.ts +3 -0
  18. package/lib/components/display/Icon/icons/index.d.ts +15 -1
  19. package/lib/components/display/List/List.d.ts +6 -0
  20. package/lib/components/display/List/ListContext.d.ts +15 -0
  21. package/lib/components/display/List/ListEmpty.d.ts +25 -0
  22. package/lib/components/display/List/ListGroup.d.ts +36 -0
  23. package/lib/components/display/List/ListHeader.d.ts +62 -0
  24. package/lib/components/display/List/ListItem.d.ts +19 -0
  25. package/lib/components/display/List/ListSearch.d.ts +32 -0
  26. package/lib/components/display/List/ListSkeleton.d.ts +27 -0
  27. package/lib/components/display/List/hooks/index.d.ts +5 -0
  28. package/lib/components/display/List/hooks/useListExpand.d.ts +6 -0
  29. package/lib/components/display/List/hooks/useListFilter.d.ts +6 -0
  30. package/lib/components/display/List/hooks/useListGroups.d.ts +6 -0
  31. package/lib/components/display/List/hooks/useListKeyboardNav.d.ts +6 -0
  32. package/lib/components/display/List/hooks/useListSelection.d.ts +6 -0
  33. package/lib/components/display/List/index.d.ts +11 -0
  34. package/lib/components/display/List/types.d.ts +485 -0
  35. package/lib/components/display/List/utils.d.ts +47 -0
  36. package/lib/components/display/OverflowText/OverflowText.d.ts +81 -0
  37. package/lib/components/display/OverflowText/index.d.ts +2 -0
  38. package/lib/components/display/ScrollArea/ScrollArea.d.ts +112 -0
  39. package/lib/components/display/ScrollArea/index.d.ts +3 -0
  40. package/lib/components/display/Table/Table.d.ts +6 -0
  41. package/lib/components/display/Table/TableBody.d.ts +4 -0
  42. package/lib/components/display/Table/TableCell.d.ts +12 -0
  43. package/lib/components/display/Table/TableContext.d.ts +10 -0
  44. package/lib/components/display/Table/TableHeader.d.ts +4 -0
  45. package/lib/components/display/Table/TableRow.d.ts +9 -0
  46. package/lib/components/display/Table/TableSearch.d.ts +32 -0
  47. package/lib/components/display/Table/TableSkeleton.d.ts +12 -0
  48. package/lib/components/display/Table/hooks/index.d.ts +10 -0
  49. package/lib/components/display/Table/hooks/useInfiniteScroll.d.ts +11 -0
  50. package/lib/components/display/Table/hooks/useTableExpand.d.ts +10 -0
  51. package/lib/components/display/Table/hooks/useTableFilter.d.ts +22 -0
  52. package/lib/components/display/Table/hooks/useTableSelection.d.ts +16 -0
  53. package/lib/components/display/Table/hooks/useTableSort.d.ts +11 -0
  54. package/lib/components/display/Table/index.d.ts +13 -0
  55. package/lib/components/display/Table/types.d.ts +295 -0
  56. package/lib/components/display/Table/utils.d.ts +37 -0
  57. package/lib/components/display/Tabs/Tab.d.ts +41 -0
  58. package/lib/components/display/Tabs/TabList.d.ts +27 -0
  59. package/lib/components/display/Tabs/TabPanel.d.ts +31 -0
  60. package/lib/components/display/Tabs/Tabs.d.ts +90 -0
  61. package/lib/components/display/Tabs/TabsContext.d.ts +63 -0
  62. package/lib/components/display/Tabs/index.d.ts +11 -0
  63. package/lib/components/display/TruncatedList/TruncatedList.d.ts +69 -0
  64. package/lib/components/display/TruncatedList/index.d.ts +2 -0
  65. package/lib/components/display/index.d.ts +4 -0
  66. package/lib/components/dnd/DndProvider/DndContext.d.ts +91 -0
  67. package/lib/components/dnd/DndProvider/DndProvider.d.ts +37 -0
  68. package/lib/components/dnd/DndProvider/index.d.ts +3 -0
  69. package/lib/components/dnd/DragHandle/DragHandle.d.ts +41 -0
  70. package/lib/components/dnd/DragHandle/index.d.ts +2 -0
  71. package/lib/components/dnd/DragOverlay/DragOverlay.d.ts +39 -0
  72. package/lib/components/dnd/DragOverlay/index.d.ts +2 -0
  73. package/lib/components/dnd/KanbanBoard/KanbanBoard.d.ts +126 -0
  74. package/lib/components/dnd/KanbanBoard/KanbanBoardContext.d.ts +62 -0
  75. package/lib/components/dnd/KanbanBoard/KanbanCard.d.ts +76 -0
  76. package/lib/components/dnd/KanbanBoard/KanbanColumn.d.ts +43 -0
  77. package/lib/components/dnd/KanbanBoard/index.d.ts +5 -0
  78. package/lib/components/dnd/ResizablePanels/ResizablePanel.d.ts +53 -0
  79. package/lib/components/dnd/ResizablePanels/ResizablePanels.d.ts +43 -0
  80. package/lib/components/dnd/ResizablePanels/ResizablePanelsContext.d.ts +64 -0
  81. package/lib/components/dnd/ResizablePanels/ResizeHandle.d.ts +28 -0
  82. package/lib/components/dnd/ResizablePanels/index.d.ts +5 -0
  83. package/lib/components/dnd/SortableGrid/SortableGrid.d.ts +76 -0
  84. package/lib/components/dnd/SortableGrid/SortableGridItem.d.ts +47 -0
  85. package/lib/components/dnd/SortableGrid/index.d.ts +3 -0
  86. package/lib/components/dnd/SortableList/SortableItem.d.ts +76 -0
  87. package/lib/components/dnd/SortableList/SortableList.d.ts +98 -0
  88. package/lib/components/dnd/SortableList/SortableListContext.d.ts +42 -0
  89. package/lib/components/dnd/SortableList/index.d.ts +4 -0
  90. package/lib/components/dnd/hooks/index.d.ts +3 -0
  91. package/lib/components/dnd/hooks/useDraggable.d.ts +66 -0
  92. package/lib/components/dnd/hooks/useDroppable.d.ts +73 -0
  93. package/lib/components/dnd/hooks/useSortable.d.ts +94 -0
  94. package/lib/components/dnd/index.d.ts +8 -0
  95. package/lib/components/filters/FilterContext.d.ts +34 -0
  96. package/lib/components/filters/core/ActiveFilters/ActiveFilters.d.ts +16 -0
  97. package/lib/components/filters/core/ActiveFilters/index.d.ts +2 -0
  98. package/lib/components/filters/core/FilterField/FilterField.d.ts +17 -0
  99. package/lib/components/filters/core/FilterField/index.d.ts +2 -0
  100. package/lib/components/filters/core/FilterProvider/FilterProvider.d.ts +4 -0
  101. package/lib/components/filters/core/FilterProvider/index.d.ts +2 -0
  102. package/lib/components/filters/core/FilterSection/FilterSection.d.ts +16 -0
  103. package/lib/components/filters/core/FilterSection/index.d.ts +2 -0
  104. package/lib/components/filters/core/index.d.ts +7 -0
  105. package/lib/components/filters/fields/CheckboxFilter.d.ts +17 -0
  106. package/lib/components/filters/fields/DateFilter.d.ts +21 -0
  107. package/lib/components/filters/fields/DateRangeFilter.d.ts +19 -0
  108. package/lib/components/filters/fields/ListSelectFilter.d.ts +19 -0
  109. package/lib/components/filters/fields/MultiSelectFilter.d.ts +19 -0
  110. package/lib/components/filters/fields/NumberFilter.d.ts +19 -0
  111. package/lib/components/filters/fields/NumberRangeFilter.d.ts +19 -0
  112. package/lib/components/filters/fields/RatingFilter.d.ts +19 -0
  113. package/lib/components/filters/fields/SelectFilter.d.ts +21 -0
  114. package/lib/components/filters/fields/TextFilter.d.ts +21 -0
  115. package/lib/components/filters/fields/ToggleFilter.d.ts +17 -0
  116. package/lib/components/filters/fields/index.d.ts +25 -0
  117. package/lib/components/filters/hooks/index.d.ts +9 -0
  118. package/lib/components/filters/hooks/useFilter.d.ts +57 -0
  119. package/lib/components/filters/hooks/useFilterDependencies.d.ts +40 -0
  120. package/lib/components/filters/hooks/useFilterOptions.d.ts +70 -0
  121. package/lib/components/filters/index.d.ts +43 -0
  122. package/lib/components/filters/layouts/FilterAccordion/FilterAccordion.d.ts +15 -0
  123. package/lib/components/filters/layouts/FilterAccordion/index.d.ts +2 -0
  124. package/lib/components/filters/layouts/FilterBar/FilterBar.d.ts +18 -0
  125. package/lib/components/filters/layouts/FilterBar/index.d.ts +2 -0
  126. package/lib/components/filters/layouts/FilterModal/FilterModal.d.ts +24 -0
  127. package/lib/components/filters/layouts/FilterModal/index.d.ts +2 -0
  128. package/lib/components/filters/layouts/FilterPopover/FilterPopover.d.ts +19 -0
  129. package/lib/components/filters/layouts/FilterPopover/index.d.ts +2 -0
  130. package/lib/components/filters/layouts/FilterSidebar/FilterSidebar.d.ts +20 -0
  131. package/lib/components/filters/layouts/FilterSidebar/index.d.ts +2 -0
  132. package/lib/components/filters/layouts/index.d.ts +8 -0
  133. package/lib/components/filters/types.d.ts +937 -0
  134. package/lib/components/index.d.ts +52 -0
  135. package/lib/components/inputs/Checkbox/Checkbox.d.ts +2 -2
  136. package/lib/components/inputs/CheckboxGroup/CheckboxGroup.d.ts +122 -0
  137. package/lib/components/inputs/CheckboxGroup/CheckboxGroupContext.d.ts +42 -0
  138. package/lib/components/inputs/CheckboxGroup/CheckboxGroupItem.d.ts +50 -0
  139. package/lib/components/inputs/CheckboxGroup/index.d.ts +7 -0
  140. package/lib/components/inputs/NumberInput/NumberInput.d.ts +3 -1
  141. package/lib/components/layout/AdaptiveGrid/AdaptiveGrid.d.ts +100 -0
  142. package/lib/components/layout/AdaptiveGrid/index.d.ts +2 -0
  143. package/lib/components/layout/MasonryLayout/MasonryLayout.d.ts +74 -0
  144. package/lib/components/layout/MasonryLayout/index.d.ts +2 -0
  145. package/lib/components/layout/Panes/Pane.d.ts +72 -0
  146. package/lib/components/layout/Panes/Panes.d.ts +75 -0
  147. package/lib/components/layout/Panes/PanesContext.d.ts +60 -0
  148. package/lib/components/layout/Panes/index.d.ts +6 -0
  149. package/lib/components/layout/ResponsiveStack/ResponsiveStack.d.ts +99 -0
  150. package/lib/components/layout/ResponsiveStack/index.d.ts +2 -0
  151. package/lib/components/layout/index.d.ts +4 -0
  152. package/lib/components/navigation/BottomNavigation/BottomNavigation.d.ts +53 -0
  153. package/lib/components/navigation/BottomNavigation/BottomNavigationContext.d.ts +27 -0
  154. package/lib/components/navigation/BottomNavigation/BottomNavigationItem.d.ts +59 -0
  155. package/lib/components/navigation/BottomNavigation/index.d.ts +7 -0
  156. package/lib/components/navigation/Breadcrumbs/BreadcrumbItem.d.ts +37 -0
  157. package/lib/components/navigation/Breadcrumbs/BreadcrumbSeparator.d.ts +22 -0
  158. package/lib/components/navigation/Breadcrumbs/Breadcrumbs.d.ts +96 -0
  159. package/lib/components/navigation/Breadcrumbs/index.d.ts +9 -0
  160. package/lib/components/navigation/Breadcrumbs/useBreadcrumbsFromPath.d.ts +73 -0
  161. package/lib/components/navigation/CollapsibleSidebar/CollapsibleSidebar.d.ts +113 -0
  162. package/lib/components/navigation/CollapsibleSidebar/index.d.ts +2 -0
  163. package/lib/components/navigation/NavLink/NavLink.d.ts +74 -0
  164. package/lib/components/navigation/NavLink/index.d.ts +3 -0
  165. package/lib/components/navigation/Navbar/Navbar.d.ts +81 -0
  166. package/lib/components/navigation/Navbar/NavbarActions.d.ts +21 -0
  167. package/lib/components/navigation/Navbar/NavbarBrand.d.ts +29 -0
  168. package/lib/components/navigation/Navbar/NavbarCollapse.d.ts +26 -0
  169. package/lib/components/navigation/Navbar/NavbarContext.d.ts +50 -0
  170. package/lib/components/navigation/Navbar/NavbarNav.d.ts +22 -0
  171. package/lib/components/navigation/Navbar/NavbarToggle.d.ts +21 -0
  172. package/lib/components/navigation/Navbar/index.d.ts +15 -0
  173. package/lib/components/navigation/Pagination/Pagination.d.ts +99 -0
  174. package/lib/components/navigation/Pagination/index.d.ts +3 -0
  175. package/lib/components/navigation/SideNav/SideNav.d.ts +89 -0
  176. package/lib/components/navigation/SideNav/SideNavContext.d.ts +43 -0
  177. package/lib/components/navigation/SideNav/SideNavDivider.d.ts +22 -0
  178. package/lib/components/navigation/SideNav/SideNavGroup.d.ts +44 -0
  179. package/lib/components/navigation/SideNav/SideNavItem.d.ts +71 -0
  180. package/lib/components/navigation/SideNav/index.d.ts +11 -0
  181. package/lib/components/navigation/Stepper/Step.d.ts +57 -0
  182. package/lib/components/navigation/Stepper/Stepper.d.ts +80 -0
  183. package/lib/components/navigation/Stepper/StepperContext.d.ts +58 -0
  184. package/lib/components/navigation/Stepper/index.d.ts +7 -0
  185. package/lib/components/navigation/index.d.ts +16 -0
  186. package/lib/components/overlays/Alert/Alert.d.ts +102 -0
  187. package/lib/components/overlays/Alert/AlertContext.d.ts +94 -0
  188. package/lib/components/overlays/Alert/AlertPresets.d.ts +42 -0
  189. package/lib/components/overlays/Alert/AlertProvider.d.ts +40 -0
  190. package/lib/components/overlays/Alert/index.d.ts +11 -0
  191. package/lib/components/overlays/Dialog/Dialog.d.ts +197 -0
  192. package/lib/components/overlays/Dialog/DialogContext.d.ts +75 -0
  193. package/lib/components/overlays/Dialog/DialogProvider.d.ts +30 -0
  194. package/lib/components/overlays/Dialog/index.d.ts +9 -0
  195. package/lib/components/overlays/Toast/Toast.d.ts +103 -0
  196. package/lib/components/overlays/Toast/ToastContainer.d.ts +37 -0
  197. package/lib/components/overlays/Toast/ToastContext.d.ts +126 -0
  198. package/lib/components/overlays/Toast/ToastProvider.d.ts +71 -0
  199. package/lib/components/overlays/Toast/index.d.ts +11 -0
  200. package/lib/hooks/index.d.ts +10 -0
  201. package/lib/hooks/useAlert/index.d.ts +2 -0
  202. package/lib/hooks/useAlert/useAlert.d.ts +99 -0
  203. package/lib/hooks/useAsyncToast/index.d.ts +2 -0
  204. package/lib/hooks/useAsyncToast/useAsyncToast.d.ts +93 -0
  205. package/lib/hooks/useDialog/index.d.ts +2 -0
  206. package/lib/hooks/useDialog/useDialog.d.ts +58 -0
  207. package/lib/hooks/useResizeObserver/index.d.ts +2 -0
  208. package/lib/hooks/useResizeObserver/useResizeObserver.d.ts +69 -0
  209. package/lib/hooks/useToast/index.d.ts +2 -0
  210. package/lib/hooks/useToast/useToast.d.ts +97 -0
  211. package/lib/providers/GlobalProvider/GlobalProvider.d.ts +16 -1
  212. package/package.json +1 -1
  213. package/README.md +0 -688
@@ -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';
@@ -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,2 @@
1
+ export { useAlert } from './useAlert';
2
+ export type { UseAlertOptions, UseAlertReturn } from './useAlert';
@@ -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;
@@ -0,0 +1,2 @@
1
+ export { useAsyncToast } from './useAsyncToast';
2
+ export type { UseAsyncToastReturn, AsyncToastConfig } from './useAsyncToast';
@@ -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,2 @@
1
+ export { useDialog } from './useDialog';
2
+ export type { UseDialogOptions, UseDialogReturn } from './useDialog';
@@ -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,2 @@
1
+ export { useResizeObserver } from './useResizeObserver';
2
+ export type { UseResizeObserverOptions, UseResizeObserverReturn } from './useResizeObserver';
@@ -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,2 @@
1
+ export { useToast } from './useToast';
2
+ export type { UseToastOptions, UseToastReturn } from './useToast';
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@true-tech-team/react-components",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "React TypeScript component library",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",