@fabio.caffarello/react-design-system 1.7.0 → 1.8.0
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 +48 -3
- package/dist/docs/components/ComponentStatusTable.d.ts +11 -0
- package/dist/ui/atoms/Accordion/Accordion.d.ts +34 -0
- package/dist/ui/atoms/Accordion/Accordion.stories.d.ts +11 -0
- package/dist/ui/atoms/Accordion/Accordion.test.d.ts +1 -0
- package/dist/ui/atoms/Accordion/index.d.ts +2 -0
- package/dist/ui/atoms/Avatar/Avatar.d.ts +30 -0
- package/dist/ui/atoms/Avatar/Avatar.stories.d.ts +13 -0
- package/dist/ui/atoms/Avatar/Avatar.test.d.ts +1 -0
- package/dist/ui/atoms/Avatar/AvatarGroup.d.ts +26 -0
- package/dist/ui/atoms/Avatar/index.d.ts +9 -0
- package/dist/ui/atoms/Badge/Badge.d.ts +14 -6
- package/dist/ui/atoms/Badge/Badge.stories.d.ts +8 -9
- package/dist/ui/atoms/BoxWrapper/BoxWrapper.d.ts +3 -3
- package/dist/ui/atoms/BoxWrapper/BoxWrapper.test.d.ts +1 -0
- package/dist/ui/atoms/Button/Button.d.ts +32 -10
- package/dist/ui/atoms/Button/Button.stories.d.ts +7 -0
- package/dist/ui/atoms/Button/Button.test.d.ts +1 -0
- package/dist/ui/atoms/Checkbox/Checkbox.d.ts +2 -1
- package/dist/ui/atoms/Collapsible/Collapsible.stories.d.ts +2 -0
- package/dist/ui/atoms/Info/Info.d.ts +2 -3
- package/dist/ui/atoms/Info/Info.test.d.ts +1 -0
- package/dist/ui/atoms/Input/Input.d.ts +14 -4
- package/dist/ui/atoms/Input/Input.stories.d.ts +6 -0
- package/dist/ui/atoms/Popover/Popover.d.ts +35 -0
- package/dist/ui/atoms/Popover/Popover.stories.d.ts +11 -0
- package/dist/ui/atoms/Popover/Popover.test.d.ts +1 -0
- package/dist/ui/atoms/Popover/index.d.ts +2 -0
- package/dist/ui/atoms/Progress/Progress.d.ts +33 -0
- package/dist/ui/atoms/Progress/Progress.stories.d.ts +12 -0
- package/dist/ui/atoms/Progress/Progress.test.d.ts +1 -0
- package/dist/ui/atoms/Select/Select.d.ts +18 -6
- package/dist/ui/atoms/Select/Select.stories.d.ts +11 -8
- package/dist/ui/atoms/Separator/Separator.d.ts +23 -0
- package/dist/ui/atoms/Separator/Separator.stories.d.ts +10 -0
- package/dist/ui/atoms/Separator/Separator.test.d.ts +1 -0
- package/dist/ui/atoms/Separator/index.d.ts +2 -0
- package/dist/ui/atoms/Skeleton/Skeleton.d.ts +1 -1
- package/dist/ui/atoms/Skeleton/Skeleton.stories.d.ts +24 -0
- package/dist/ui/atoms/Slider/Slider.d.ts +45 -0
- package/dist/ui/atoms/Slider/Slider.stories.d.ts +13 -0
- package/dist/ui/atoms/Slider/Slider.test.d.ts +1 -0
- package/dist/ui/atoms/Slider/index.d.ts +2 -0
- package/dist/ui/atoms/Spinner/Spinner.d.ts +22 -0
- package/dist/ui/atoms/Spinner/Spinner.stories.d.ts +9 -0
- package/dist/ui/atoms/Spinner/Spinner.test.d.ts +1 -0
- package/dist/ui/atoms/Switch/Switch.d.ts +28 -0
- package/dist/ui/atoms/Switch/Switch.stories.d.ts +11 -0
- package/dist/ui/atoms/Switch/Switch.test.d.ts +1 -0
- package/dist/ui/atoms/Switch/index.d.ts +2 -0
- package/dist/ui/atoms/Tooltip/Tooltip.d.ts +2 -1
- package/dist/ui/atoms/Tooltip/Tooltip.stories.d.ts +17 -0
- package/dist/ui/atoms/index.d.ts +20 -3
- package/dist/ui/index.d.ts +6 -1
- package/dist/ui/molecules/Card/Card.d.ts +6 -2
- package/dist/ui/molecules/Card/Card.stories.d.ts +2 -0
- package/dist/ui/molecules/ColorPicker/ColorPicker.d.ts +28 -0
- package/dist/ui/molecules/ColorPicker/ColorPicker.stories.d.ts +12 -0
- package/dist/ui/molecules/ColorPicker/ColorPicker.test.d.ts +1 -0
- package/dist/ui/molecules/ColorPicker/index.d.ts +2 -0
- package/dist/ui/molecules/DatePicker/DatePicker.d.ts +74 -0
- package/dist/ui/molecules/DatePicker/DatePicker.stories.d.ts +12 -0
- package/dist/ui/molecules/DatePicker/DatePicker.test.d.ts +1 -0
- package/dist/ui/molecules/DatePicker/DatePickerCalendar.d.ts +6 -0
- package/dist/ui/molecules/DatePicker/DatePickerContext.d.ts +28 -0
- package/dist/ui/molecules/DatePicker/DatePickerInput.d.ts +9 -0
- package/dist/ui/molecules/DatePicker/DatePickerProvider.d.ts +23 -0
- package/dist/ui/molecules/DatePicker/index.d.ts +14 -0
- package/dist/ui/molecules/Dropdown/Dropdown.d.ts +2 -1
- package/dist/ui/molecules/Dropdown/Dropdown.stories.d.ts +13 -0
- package/dist/ui/molecules/EmptyState/EmptyState.stories.d.ts +22 -0
- package/dist/ui/molecules/FileUpload/FileUpload.d.ts +37 -0
- package/dist/ui/molecules/FileUpload/FileUpload.stories.d.ts +12 -0
- package/dist/ui/molecules/FileUpload/FileUpload.test.d.ts +1 -0
- package/dist/ui/molecules/FileUpload/index.d.ts +2 -0
- package/dist/ui/molecules/Form/Form.d.ts +29 -4
- package/dist/ui/molecules/Form/Form.stories.d.ts +2 -0
- package/dist/ui/molecules/Form/FormContext.d.ts +17 -0
- package/dist/ui/molecules/Form/FormField.d.ts +36 -0
- package/dist/ui/molecules/Form/FormProvider.d.ts +14 -0
- package/dist/ui/molecules/Form/index.d.ts +13 -0
- package/dist/ui/molecules/Form/useFormFieldArray.d.ts +28 -0
- package/dist/ui/molecules/InputWithLabel/InputWithLabel.test.d.ts +1 -0
- package/dist/ui/molecules/Rating/Rating.d.ts +33 -0
- package/dist/ui/molecules/Rating/Rating.stories.d.ts +13 -0
- package/dist/ui/molecules/Rating/Rating.test.d.ts +1 -0
- package/dist/ui/molecules/Rating/index.d.ts +2 -0
- package/dist/ui/molecules/SearchInput/SearchInput.d.ts +24 -0
- package/dist/ui/molecules/SearchInput/SearchInput.stories.d.ts +10 -0
- package/dist/ui/molecules/SearchInput/SearchInput.test.d.ts +1 -0
- package/dist/ui/molecules/SearchInput/index.d.ts +2 -0
- package/dist/ui/molecules/SidebarHeader/SidebarHeader.test.d.ts +1 -0
- package/dist/ui/molecules/TableActions/TableActions.d.ts +31 -0
- package/dist/ui/molecules/TableActions/TableActions.stories.d.ts +7 -0
- package/dist/ui/molecules/TableActions/TableActions.test.d.ts +1 -0
- package/dist/ui/molecules/TableFilters/TableFilters.d.ts +37 -0
- package/dist/ui/molecules/TableFilters/TableFilters.stories.d.ts +7 -0
- package/dist/ui/molecules/TableFilters/TableFilters.test.d.ts +1 -0
- package/dist/ui/molecules/TablePagination/TablePagination.d.ts +29 -0
- package/dist/ui/molecules/TablePagination/TablePagination.stories.d.ts +8 -0
- package/dist/ui/molecules/TablePagination/TablePagination.test.d.ts +1 -0
- package/dist/ui/molecules/Tabs/Tabs.d.ts +15 -0
- package/dist/ui/molecules/Tabs/Tabs.stories.d.ts +10 -0
- package/dist/ui/molecules/Tabs/Tabs.test.d.ts +1 -0
- package/dist/ui/molecules/Tabs/TabsContent.d.ts +14 -0
- package/dist/ui/molecules/Tabs/TabsContext.d.ts +18 -0
- package/dist/ui/molecules/Tabs/TabsList.d.ts +12 -0
- package/dist/ui/molecules/Tabs/TabsProvider.d.ts +16 -0
- package/dist/ui/molecules/Tabs/TabsTrigger.d.ts +13 -0
- package/dist/ui/molecules/Tabs/index.d.ts +17 -0
- package/dist/ui/molecules/TimePicker/TimePicker.d.ts +29 -0
- package/dist/ui/molecules/TimePicker/TimePicker.stories.d.ts +12 -0
- package/dist/ui/molecules/TimePicker/TimePicker.test.d.ts +1 -0
- package/dist/ui/molecules/TimePicker/index.d.ts +2 -0
- package/dist/ui/molecules/index.d.ts +13 -5
- package/dist/ui/organisms/CommandPalette/CommandPalette.d.ts +37 -0
- package/dist/ui/organisms/CommandPalette/CommandPalette.stories.d.ts +11 -0
- package/dist/ui/organisms/CommandPalette/CommandPalette.test.d.ts +1 -0
- package/dist/ui/organisms/CommandPalette/index.d.ts +2 -0
- package/dist/ui/organisms/DataGrid/DataGrid.d.ts +84 -0
- package/dist/ui/organisms/DataGrid/DataGrid.stories.d.ts +14 -0
- package/dist/ui/organisms/DataGrid/DataGrid.test.d.ts +1 -0
- package/dist/ui/organisms/DataGrid/index.d.ts +2 -0
- package/dist/ui/organisms/Dialog/AlertDialog.d.ts +34 -0
- package/dist/ui/organisms/Dialog/Dialog.d.ts +58 -0
- package/dist/ui/organisms/Dialog/Dialog.stories.d.ts +13 -0
- package/dist/ui/organisms/Dialog/Dialog.test.d.ts +1 -0
- package/dist/ui/organisms/Dialog/DialogClose.d.ts +8 -0
- package/dist/ui/organisms/Dialog/DialogContent.d.ts +8 -0
- package/dist/ui/organisms/Dialog/DialogContext.d.ts +10 -0
- package/dist/ui/organisms/Dialog/DialogDescription.d.ts +4 -0
- package/dist/ui/organisms/Dialog/DialogFooter.d.ts +5 -0
- package/dist/ui/organisms/Dialog/DialogHeader.d.ts +5 -0
- package/dist/ui/organisms/Dialog/DialogProvider.d.ts +10 -0
- package/dist/ui/organisms/Dialog/DialogTitle.d.ts +5 -0
- package/dist/ui/organisms/Dialog/DialogTrigger.d.ts +6 -0
- package/dist/ui/organisms/Dialog/index.d.ts +22 -0
- package/dist/ui/organisms/Sidebar/Sidebar.d.ts +7 -4
- package/dist/ui/organisms/Sidebar/SidebarGroup/SidebarGroup.d.ts +27 -0
- package/dist/ui/organisms/Sidebar/SidebarGroup/SidebarGroup.stories.d.ts +11 -0
- package/dist/ui/organisms/Sidebar/SidebarGroup/SidebarGroup.test.d.ts +1 -0
- package/dist/ui/organisms/Sidebar/SidebarHeader/SidebarHeader.d.ts +19 -0
- package/dist/ui/organisms/Sidebar/SidebarHeader/SidebarHeader.test.d.ts +1 -0
- package/dist/ui/organisms/Sidebar/SidebarItem/SidebarItem.d.ts +23 -0
- package/dist/ui/organisms/Sidebar/SidebarItem/SidebarItem.stories.d.ts +10 -0
- package/dist/ui/organisms/Sidebar/SidebarItem/SidebarItem.test.d.ts +1 -0
- package/dist/ui/organisms/Sidebar/index.d.ts +8 -0
- package/dist/ui/organisms/Stepper/Stepper.d.ts +40 -0
- package/dist/ui/organisms/Stepper/Stepper.stories.d.ts +12 -0
- package/dist/ui/organisms/Stepper/Stepper.test.d.ts +1 -0
- package/dist/ui/organisms/Stepper/index.d.ts +2 -0
- package/dist/ui/organisms/Table/Table.d.ts +84 -16
- package/dist/ui/organisms/Table/Table.stories.d.ts +15 -0
- package/dist/ui/organisms/Table/TableActions/TableActions.d.ts +31 -0
- package/dist/ui/organisms/Table/TableActions/TableActions.stories.d.ts +7 -0
- package/dist/ui/organisms/Table/TableActions/TableActions.test.d.ts +1 -0
- package/dist/ui/organisms/Table/TableActions.d.ts +13 -0
- package/dist/ui/organisms/Table/TableBody.d.ts +12 -0
- package/dist/ui/organisms/Table/TableCell.d.ts +14 -0
- package/dist/ui/organisms/Table/TableContext.d.ts +75 -0
- package/dist/ui/organisms/Table/TableEmptyState.d.ts +11 -0
- package/dist/ui/organisms/Table/TableFilters/TableFilters.d.ts +37 -0
- package/dist/ui/organisms/Table/TableFilters/TableFilters.stories.d.ts +7 -0
- package/dist/ui/organisms/Table/TableFilters/TableFilters.test.d.ts +1 -0
- package/dist/ui/organisms/Table/TableFilters.d.ts +12 -0
- package/dist/ui/organisms/Table/TableHeader.d.ts +10 -0
- package/dist/ui/organisms/Table/TableHeaderCell.d.ts +18 -0
- package/dist/ui/organisms/Table/TableHeaderRow.d.ts +10 -0
- package/dist/ui/organisms/Table/TablePagination/TablePagination.d.ts +29 -0
- package/dist/ui/organisms/Table/TablePagination/TablePagination.stories.d.ts +8 -0
- package/dist/ui/organisms/Table/TablePagination/TablePagination.test.d.ts +1 -0
- package/dist/ui/organisms/Table/TablePagination.d.ts +14 -0
- package/dist/ui/organisms/Table/TableProvider.d.ts +55 -0
- package/dist/ui/organisms/Table/TableRow.d.ts +14 -0
- package/dist/ui/organisms/Table/TableTypes.d.ts +8 -0
- package/dist/ui/organisms/Table/index.d.ts +30 -0
- package/dist/ui/organisms/Table/useColumnResizing.d.ts +39 -0
- package/dist/ui/organisms/Table/useVirtualScrolling.d.ts +35 -0
- package/dist/ui/organisms/Timeline/Timeline.d.ts +34 -0
- package/dist/ui/organisms/Timeline/Timeline.stories.d.ts +12 -0
- package/dist/ui/organisms/Timeline/Timeline.test.d.ts +1 -0
- package/dist/ui/organisms/Timeline/index.d.ts +2 -0
- package/dist/ui/organisms/Toast/Toast.d.ts +8 -0
- package/dist/ui/organisms/Toast/Toast.stories.d.ts +14 -0
- package/dist/ui/organisms/Toast/Toast.test.d.ts +1 -0
- package/dist/ui/organisms/Toast/ToastContainer.d.ts +5 -0
- package/dist/ui/organisms/Toast/ToastContext.d.ts +21 -0
- package/dist/ui/organisms/Toast/ToastProvider.d.ts +7 -0
- package/dist/ui/organisms/Toast/index.d.ts +15 -0
- package/dist/ui/organisms/Toast/useToast.d.ts +35 -0
- package/dist/ui/organisms/index.d.ts +12 -2
- package/dist/ui/providers/AdvancedThemeProvider.d.ts +52 -0
- package/dist/ui/providers/index.d.ts +9 -0
- package/dist/ui/themes/ThemeBuilder.d.ts +28 -0
- package/dist/ui/themes/ThemeRegistry.d.ts +55 -0
- package/dist/ui/themes/index.d.ts +9 -0
- package/dist/ui/themes/types.d.ts +48 -0
- package/dist/ui/themes/utils.d.ts +21 -0
- package/dist/ui/tokens/TokenVisualizations.d.ts +41 -0
- package/dist/ui/tokens/animations.d.ts +65 -0
- package/dist/ui/tokens/borders.d.ts +61 -0
- package/dist/ui/tokens/gradients.d.ts +55 -0
- package/dist/ui/tokens/index.d.ts +31 -0
- package/dist/ui/tokens/opacity.d.ts +51 -0
- package/dist/ui/tokens/radius.d.ts +45 -0
- package/dist/ui/tokens/shadows.d.ts +42 -0
- package/dist/ui/tokens/themes/dark.d.ts +26 -26
- package/dist/ui/tokens/themes/light.d.ts +26 -26
- package/dist/ui/tokens/tokens.factory.d.ts +42 -0
- package/dist/ui/tokens/z-index.d.ts +44 -0
- package/dist/ui/utils/index.d.ts +6 -0
- package/package.json +50 -6
- package/src/docs/Accessibility.mdx +402 -0
- package/src/docs/BestPractices.mdx +315 -0
- package/src/docs/ComponentComposition.mdx +381 -0
- package/src/docs/ComponentStatus.mdx +177 -0
- package/src/docs/DesignSystem.mdx +121 -0
- package/src/docs/GettingStarted.mdx +284 -0
- package/src/docs/MigrationGuide.mdx +297 -0
- package/src/docs/Performance.mdx +206 -0
- package/src/docs/components/ComponentStatusTable.tsx +184 -0
- package/src/setupTests.ts +32 -0
- package/src/ui/atoms/Accordion/Accordion.stories.tsx +147 -0
- package/src/ui/atoms/Accordion/Accordion.test.tsx +86 -0
- package/src/ui/atoms/Accordion/Accordion.tsx +147 -0
- package/src/ui/atoms/Accordion/index.ts +2 -0
- package/src/ui/atoms/Avatar/Avatar.stories.tsx +226 -0
- package/src/ui/atoms/Avatar/Avatar.test.tsx +233 -0
- package/src/ui/atoms/Avatar/Avatar.tsx +128 -0
- package/src/ui/atoms/Avatar/AvatarGroup.tsx +96 -0
- package/src/ui/atoms/Avatar/index.ts +11 -0
- package/src/ui/atoms/Badge/Badge.stories.tsx +65 -56
- package/src/ui/atoms/Badge/Badge.test.tsx +27 -50
- package/src/ui/atoms/Badge/Badge.tsx +70 -27
- package/src/ui/atoms/BoxWrapper/BoxWrapper.stories.tsx +1 -1
- package/src/ui/atoms/BoxWrapper/BoxWrapper.test.tsx +27 -0
- package/src/ui/atoms/BoxWrapper/BoxWrapper.tsx +5 -2
- package/src/ui/atoms/Button/Button.stories.tsx +130 -1
- package/src/ui/atoms/Button/Button.test.tsx +233 -0
- package/src/ui/atoms/Button/Button.tsx +160 -53
- package/src/ui/atoms/Checkbox/Checkbox.tsx +14 -1
- package/src/ui/atoms/Collapsible/Collapsible.stories.tsx +47 -1
- package/src/ui/atoms/Collapsible/Collapsible.test.tsx +36 -24
- package/src/ui/atoms/Collapsible/Collapsible.tsx +9 -1
- package/src/ui/atoms/ErrorMessage/ErrorMessage.stories.tsx +1 -1
- package/src/ui/atoms/Info/Info.stories.tsx +1 -1
- package/src/ui/atoms/Info/Info.test.tsx +45 -0
- package/src/ui/atoms/Info/Info.tsx +2 -2
- package/src/ui/atoms/Input/Input.stories.tsx +80 -0
- package/src/ui/atoms/Input/Input.test.tsx +190 -36
- package/src/ui/atoms/Input/Input.tsx +144 -25
- package/src/ui/atoms/Label/Label.stories.tsx +1 -1
- package/src/ui/atoms/NavLink/NavLink.stories.tsx +1 -1
- package/src/ui/atoms/Popover/Popover.stories.tsx +157 -0
- package/src/ui/atoms/Popover/Popover.test.tsx +80 -0
- package/src/ui/atoms/Popover/Popover.tsx +256 -0
- package/src/ui/atoms/Popover/index.ts +2 -0
- package/src/ui/atoms/Progress/Progress.css +17 -0
- package/src/ui/atoms/Progress/Progress.stories.tsx +170 -0
- package/src/ui/atoms/Progress/Progress.test.tsx +134 -0
- package/src/ui/atoms/Progress/Progress.tsx +138 -0
- package/src/ui/atoms/Radio/Radio.tsx +1 -1
- package/src/ui/atoms/Select/Select.stories.tsx +93 -58
- package/src/ui/atoms/Select/Select.test.tsx +162 -46
- package/src/ui/atoms/Select/Select.tsx +142 -44
- package/src/ui/atoms/Separator/Separator.stories.tsx +88 -0
- package/src/ui/atoms/Separator/Separator.test.tsx +34 -0
- package/src/ui/atoms/Separator/Separator.tsx +81 -0
- package/src/ui/atoms/Separator/index.ts +2 -0
- package/src/ui/atoms/Skeleton/Skeleton.stories.tsx +62 -0
- package/src/ui/atoms/Skeleton/Skeleton.tsx +19 -2
- package/src/ui/atoms/Slider/Slider.stories.tsx +205 -0
- package/src/ui/atoms/Slider/Slider.test.tsx +53 -0
- package/src/ui/atoms/Slider/Slider.tsx +307 -0
- package/src/ui/atoms/Slider/index.ts +2 -0
- package/src/ui/atoms/Spinner/Spinner.stories.tsx +56 -0
- package/src/ui/atoms/Spinner/Spinner.test.tsx +35 -0
- package/src/ui/atoms/Spinner/Spinner.tsx +88 -0
- package/src/ui/atoms/Switch/Switch.stories.tsx +182 -0
- package/src/ui/atoms/Switch/Switch.test.tsx +90 -0
- package/src/ui/atoms/Switch/Switch.tsx +181 -0
- package/src/ui/atoms/Switch/index.ts +2 -0
- package/src/ui/atoms/Text/Text.stories.tsx +1 -1
- package/src/ui/atoms/Text/Text.test.tsx +48 -32
- package/src/ui/atoms/Textarea/Textarea.stories.tsx +1 -1
- package/src/ui/atoms/Tooltip/Tooltip.stories.tsx +44 -0
- package/src/ui/atoms/Tooltip/Tooltip.tsx +94 -6
- package/src/ui/atoms/index.ts +27 -4
- package/src/ui/index.ts +6 -1
- package/src/ui/molecules/Breadcrumb/Breadcrumb.stories.tsx +1 -1
- package/src/ui/molecules/Breadcrumb/Breadcrumb.tsx +1 -1
- package/src/ui/molecules/Card/Card.stories.tsx +49 -1
- package/src/ui/molecules/Card/Card.tsx +40 -5
- package/src/ui/molecules/ColorPicker/ColorPicker.stories.tsx +156 -0
- package/src/ui/molecules/ColorPicker/ColorPicker.test.tsx +47 -0
- package/src/ui/molecules/ColorPicker/ColorPicker.tsx +271 -0
- package/src/ui/molecules/ColorPicker/index.ts +2 -0
- package/src/ui/molecules/DatePicker/DatePicker.mdx +150 -0
- package/src/ui/molecules/DatePicker/DatePicker.stories.tsx +188 -0
- package/src/ui/molecules/DatePicker/DatePicker.test.tsx +381 -0
- package/src/ui/molecules/DatePicker/DatePicker.tsx +231 -0
- package/src/ui/molecules/DatePicker/DatePickerCalendar.tsx +277 -0
- package/src/ui/molecules/DatePicker/DatePickerContext.tsx +39 -0
- package/src/ui/molecules/DatePicker/DatePickerInput.tsx +147 -0
- package/src/ui/molecules/DatePicker/DatePickerProvider.tsx +100 -0
- package/src/ui/molecules/DatePicker/index.ts +16 -0
- package/src/ui/molecules/Dropdown/Dropdown.stories.tsx +50 -8
- package/src/ui/molecules/Dropdown/Dropdown.test.tsx +272 -12
- package/src/ui/molecules/Dropdown/Dropdown.tsx +176 -10
- package/src/ui/molecules/EmptyState/EmptyState.stories.tsx +24 -2
- package/src/ui/molecules/EmptyState/EmptyState.tsx +9 -3
- package/src/ui/molecules/FileUpload/FileUpload.stories.tsx +177 -0
- package/src/ui/molecules/FileUpload/FileUpload.test.tsx +114 -0
- package/src/ui/molecules/FileUpload/FileUpload.tsx +312 -0
- package/src/ui/molecules/FileUpload/index.ts +2 -0
- package/src/ui/molecules/Form/Form.mdx +145 -0
- package/src/ui/molecules/Form/Form.stories.tsx +121 -1
- package/src/ui/molecules/Form/Form.test.tsx +1 -3
- package/src/ui/molecules/Form/Form.tsx +95 -15
- package/src/ui/molecules/Form/FormContext.tsx +35 -0
- package/src/ui/molecules/Form/FormField.tsx +83 -0
- package/src/ui/molecules/Form/FormProvider.tsx +34 -0
- package/src/ui/molecules/Form/index.ts +21 -0
- package/src/ui/molecules/Form/useFormFieldArray.ts +46 -0
- package/src/ui/molecules/InputWithLabel/InputWithLabel.stories.tsx +1 -1
- package/src/ui/molecules/InputWithLabel/InputWithLabel.test.tsx +44 -0
- package/src/ui/molecules/InputWithLabel/InputWithLabel.tsx +3 -1
- package/src/ui/molecules/NavbarGroup/NavbarGroup.stories.tsx +1 -1
- package/src/ui/molecules/Pagination/Pagination.stories.tsx +1 -1
- package/src/ui/molecules/Rating/Rating.stories.tsx +206 -0
- package/src/ui/molecules/Rating/Rating.test.tsx +60 -0
- package/src/ui/molecules/Rating/Rating.tsx +173 -0
- package/src/ui/molecules/Rating/index.ts +2 -0
- package/src/ui/molecules/SearchInput/SearchInput.stories.tsx +146 -0
- package/src/ui/molecules/SearchInput/SearchInput.test.tsx +82 -0
- package/src/ui/molecules/SearchInput/SearchInput.tsx +133 -0
- package/src/ui/molecules/SearchInput/index.ts +2 -0
- package/src/ui/molecules/Tabs/Tabs.stories.tsx +229 -0
- package/src/ui/molecules/Tabs/Tabs.test.tsx +497 -0
- package/src/ui/molecules/Tabs/Tabs.tsx +58 -0
- package/src/ui/molecules/Tabs/TabsContent.tsx +50 -0
- package/src/ui/molecules/Tabs/TabsContext.tsx +36 -0
- package/src/ui/molecules/Tabs/TabsList.tsx +98 -0
- package/src/ui/molecules/Tabs/TabsProvider.tsx +53 -0
- package/src/ui/molecules/Tabs/TabsTrigger.tsx +111 -0
- package/src/ui/molecules/Tabs/index.ts +23 -0
- package/src/ui/molecules/TimePicker/TimePicker.stories.tsx +145 -0
- package/src/ui/molecules/TimePicker/TimePicker.test.tsx +41 -0
- package/src/ui/molecules/TimePicker/TimePicker.tsx +264 -0
- package/src/ui/molecules/TimePicker/index.ts +2 -0
- package/src/ui/molecules/index.ts +20 -7
- package/src/ui/organisms/CommandPalette/CommandPalette.stories.tsx +218 -0
- package/src/ui/organisms/CommandPalette/CommandPalette.test.tsx +85 -0
- package/src/ui/organisms/CommandPalette/CommandPalette.tsx +333 -0
- package/src/ui/organisms/CommandPalette/index.ts +2 -0
- package/src/ui/organisms/DataGrid/DataGrid.stories.tsx +196 -0
- package/src/ui/organisms/DataGrid/DataGrid.test.tsx +53 -0
- package/src/ui/organisms/DataGrid/DataGrid.tsx +294 -0
- package/src/ui/organisms/DataGrid/index.ts +2 -0
- package/src/ui/organisms/Dialog/AlertDialog.tsx +92 -0
- package/src/ui/organisms/Dialog/Dialog.mdx +200 -0
- package/src/ui/organisms/Dialog/Dialog.stories.tsx +226 -0
- package/src/ui/organisms/Dialog/Dialog.test.tsx +435 -0
- package/src/ui/organisms/Dialog/Dialog.tsx +79 -0
- package/src/ui/organisms/Dialog/DialogClose.tsx +45 -0
- package/src/ui/organisms/Dialog/DialogContent.tsx +149 -0
- package/src/ui/organisms/Dialog/DialogContext.tsx +25 -0
- package/src/ui/organisms/Dialog/DialogDescription.tsx +28 -0
- package/src/ui/organisms/Dialog/DialogFooter.tsx +18 -0
- package/src/ui/organisms/Dialog/DialogHeader.tsx +18 -0
- package/src/ui/organisms/Dialog/DialogProvider.tsx +73 -0
- package/src/ui/organisms/Dialog/DialogTitle.tsx +31 -0
- package/src/ui/organisms/Dialog/DialogTrigger.tsx +34 -0
- package/src/ui/organisms/Dialog/index.ts +24 -0
- package/src/ui/organisms/LoginBox/LoginBox.stories.tsx +1 -1
- package/src/ui/organisms/Modal/Modal.stories.tsx +2 -2
- package/src/ui/organisms/Modal/Modal.test.tsx +1 -1
- package/src/ui/organisms/Sidebar/Sidebar.stories.tsx +1 -1
- package/src/ui/organisms/Sidebar/Sidebar.test.tsx +5 -3
- package/src/ui/organisms/Sidebar/Sidebar.tsx +21 -6
- package/src/ui/{molecules → organisms/Sidebar}/SidebarGroup/SidebarGroup.stories.tsx +2 -2
- package/src/ui/{molecules → organisms/Sidebar}/SidebarGroup/SidebarGroup.test.tsx +32 -9
- package/src/ui/{molecules → organisms/Sidebar}/SidebarGroup/SidebarGroup.tsx +7 -7
- package/src/ui/organisms/Sidebar/SidebarHeader/SidebarHeader.test.tsx +66 -0
- package/src/ui/{molecules → organisms/Sidebar}/SidebarHeader/SidebarHeader.tsx +1 -2
- package/src/ui/{atoms → organisms/Sidebar}/SidebarItem/SidebarItem.stories.tsx +1 -1
- package/src/ui/{atoms → organisms/Sidebar}/SidebarItem/SidebarItem.test.tsx +9 -8
- package/src/ui/{atoms → organisms/Sidebar}/SidebarItem/SidebarItem.tsx +9 -3
- package/src/ui/organisms/Sidebar/index.ts +13 -0
- package/src/ui/organisms/Stepper/Stepper.stories.tsx +253 -0
- package/src/ui/organisms/Stepper/Stepper.test.tsx +76 -0
- package/src/ui/organisms/Stepper/Stepper.tsx +323 -0
- package/src/ui/organisms/Stepper/index.ts +2 -0
- package/src/ui/organisms/Table/Table.mdx +154 -0
- package/src/ui/organisms/Table/Table.stories.tsx +614 -4
- package/src/ui/organisms/Table/Table.test.tsx +86 -4
- package/src/ui/organisms/Table/Table.tsx +215 -99
- package/src/ui/organisms/Table/TableActions/TableActions.stories.tsx +88 -0
- package/src/ui/organisms/Table/TableActions/TableActions.test.tsx +64 -0
- package/src/ui/organisms/Table/TableActions/TableActions.tsx +71 -0
- package/src/ui/organisms/Table/TableActions.tsx +46 -0
- package/src/ui/organisms/Table/TableBody.tsx +137 -0
- package/src/ui/organisms/Table/TableCell.tsx +36 -0
- package/src/ui/organisms/Table/TableContext.tsx +111 -0
- package/src/ui/organisms/Table/TableEmptyState.tsx +51 -0
- package/src/ui/organisms/Table/TableFilters/TableFilters.stories.tsx +111 -0
- package/src/ui/organisms/Table/TableFilters/TableFilters.test.tsx +104 -0
- package/src/ui/organisms/Table/TableFilters/TableFilters.tsx +191 -0
- package/src/ui/organisms/Table/TableFilters.tsx +39 -0
- package/src/ui/organisms/Table/TableHeader.tsx +29 -0
- package/src/ui/organisms/Table/TableHeaderCell.tsx +142 -0
- package/src/ui/organisms/Table/TableHeaderRow.tsx +72 -0
- package/src/ui/organisms/Table/TablePagination/TablePagination.stories.tsx +87 -0
- package/src/ui/organisms/Table/TablePagination/TablePagination.test.tsx +90 -0
- package/src/ui/organisms/Table/TablePagination/TablePagination.tsx +207 -0
- package/src/ui/organisms/Table/TablePagination.tsx +48 -0
- package/src/ui/organisms/Table/TableProvider.tsx +429 -0
- package/src/ui/organisms/Table/TableRow.tsx +85 -0
- package/src/ui/organisms/Table/TableTypes.ts +11 -0
- package/src/ui/organisms/Table/index.ts +55 -0
- package/src/ui/organisms/Table/useColumnResizing.ts +134 -0
- package/src/ui/organisms/Table/useVirtualScrolling.ts +116 -0
- package/src/ui/organisms/Timeline/Timeline.stories.tsx +230 -0
- package/src/ui/organisms/Timeline/Timeline.test.tsx +47 -0
- package/src/ui/organisms/Timeline/Timeline.tsx +179 -0
- package/src/ui/organisms/Timeline/index.ts +2 -0
- package/src/ui/organisms/Toast/Toast.stories.tsx +169 -0
- package/src/ui/organisms/Toast/Toast.test.tsx +537 -0
- package/src/ui/organisms/Toast/Toast.tsx +144 -0
- package/src/ui/organisms/Toast/ToastContainer.tsx +54 -0
- package/src/ui/organisms/Toast/ToastContext.tsx +38 -0
- package/src/ui/organisms/Toast/ToastProvider.tsx +56 -0
- package/src/ui/organisms/Toast/index.ts +17 -0
- package/src/ui/organisms/Toast/useToast.ts +70 -0
- package/src/ui/organisms/index.ts +17 -2
- package/src/ui/providers/AdvancedThemeProvider.tsx +229 -0
- package/src/ui/providers/index.ts +14 -0
- package/src/ui/themes/README.md +281 -0
- package/src/ui/themes/ThemeBuilder.ts +149 -0
- package/src/ui/themes/ThemeRegistry.ts +187 -0
- package/src/ui/themes/index.ts +20 -0
- package/src/ui/themes/types.ts +53 -0
- package/src/ui/themes/utils.ts +70 -0
- package/src/ui/tokens/README.md +212 -0
- package/src/ui/tokens/TokenVisualizations.tsx +273 -0
- package/src/ui/tokens/Tokens.mdx +348 -0
- package/src/ui/tokens/animations.ts +157 -0
- package/src/ui/tokens/borders.ts +121 -0
- package/src/ui/tokens/gradients.ts +154 -0
- package/src/ui/tokens/index.ts +57 -0
- package/src/ui/tokens/opacity.ts +107 -0
- package/src/ui/tokens/radius.ts +107 -0
- package/src/ui/tokens/shadows.ts +92 -0
- package/src/ui/tokens/tokens.factory.ts +124 -0
- package/src/ui/tokens/z-index.ts +113 -0
- package/src/ui/utils/index.ts +10 -0
- package/src/App.css +0 -42
- package/src/App.tsx +0 -35
- package/src/index.css +0 -68
- package/src/main.tsx +0 -15
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { useToastContext } from './ToastContext';
|
|
5
|
+
import { Toast } from './Toast';
|
|
6
|
+
|
|
7
|
+
export interface ToastContainerProps {
|
|
8
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
9
|
+
maxToasts?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ToastContainer({
|
|
13
|
+
position = 'top-right',
|
|
14
|
+
maxToasts,
|
|
15
|
+
}: ToastContainerProps) {
|
|
16
|
+
const { toasts, removeToast } = useToastContext();
|
|
17
|
+
|
|
18
|
+
const toastsToShow = maxToasts ? toasts.slice(0, maxToasts) : toasts;
|
|
19
|
+
|
|
20
|
+
if (toastsToShow.length === 0) return null;
|
|
21
|
+
|
|
22
|
+
const container = (
|
|
23
|
+
<div
|
|
24
|
+
className="fixed inset-0 pointer-events-none z-50"
|
|
25
|
+
aria-live="polite"
|
|
26
|
+
aria-label="Notifications"
|
|
27
|
+
>
|
|
28
|
+
{toastsToShow.map((toast, index) => {
|
|
29
|
+
const isTop = position.includes('top');
|
|
30
|
+
// Calculate offset: base 1rem + (index * 5rem for spacing)
|
|
31
|
+
const offset = 1 + index * 5;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Toast
|
|
35
|
+
key={toast.id}
|
|
36
|
+
toast={toast}
|
|
37
|
+
onDismiss={removeToast}
|
|
38
|
+
position={position}
|
|
39
|
+
style={{
|
|
40
|
+
[isTop ? 'top' : 'bottom']: `${offset}rem`,
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
})}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// Portal rendering
|
|
49
|
+
if (typeof window !== 'undefined') {
|
|
50
|
+
return createPortal(container, document.body);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return container;
|
|
54
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
|
|
5
|
+
export type ToastVariant = 'success' | 'error' | 'warning' | 'info';
|
|
6
|
+
|
|
7
|
+
export interface Toast {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
variant: ToastVariant;
|
|
12
|
+
duration?: number; // in milliseconds, undefined = no auto-dismiss
|
|
13
|
+
action?: {
|
|
14
|
+
label: string;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ToastContextValue {
|
|
20
|
+
toasts: Toast[];
|
|
21
|
+
addToast: (toast: Omit<Toast, 'id'>) => string;
|
|
22
|
+
removeToast: (id: string) => void;
|
|
23
|
+
clearAll: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const ToastContext = createContext<ToastContextValue | undefined>(undefined);
|
|
27
|
+
|
|
28
|
+
export function useToastContext(): ToastContextValue {
|
|
29
|
+
const context = useContext(ToastContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error('Toast components must be used within a ToastProvider');
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function useToastContextOptional(): ToastContextValue | undefined {
|
|
37
|
+
return useContext(ToastContext);
|
|
38
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback, type ReactNode } from 'react';
|
|
4
|
+
import { ToastContext, type Toast, type ToastContextValue } from './ToastContext';
|
|
5
|
+
|
|
6
|
+
export interface ToastProviderProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
defaultDuration?: number; // Default auto-dismiss duration in ms
|
|
9
|
+
maxToasts?: number; // Maximum number of toasts to show
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ToastProvider({
|
|
13
|
+
children,
|
|
14
|
+
defaultDuration = 5000,
|
|
15
|
+
maxToasts = 5,
|
|
16
|
+
}: ToastProviderProps) {
|
|
17
|
+
const [toasts, setToasts] = useState<Toast[]>([]);
|
|
18
|
+
|
|
19
|
+
const addToast = useCallback((toast: Omit<Toast, 'id'>): string => {
|
|
20
|
+
const id = `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
21
|
+
const newToast: Toast = {
|
|
22
|
+
...toast,
|
|
23
|
+
id,
|
|
24
|
+
duration: toast.duration ?? defaultDuration,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
setToasts((prev) => {
|
|
28
|
+
const updated = [newToast, ...prev];
|
|
29
|
+
// Limit number of toasts
|
|
30
|
+
return updated.slice(0, maxToasts);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return id;
|
|
34
|
+
}, [defaultDuration, maxToasts]);
|
|
35
|
+
|
|
36
|
+
const removeToast = useCallback((id: string) => {
|
|
37
|
+
setToasts((prev) => prev.filter((toast) => toast.id !== id));
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
const clearAll = useCallback(() => {
|
|
41
|
+
setToasts([]);
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const contextValue: ToastContextValue = {
|
|
45
|
+
toasts,
|
|
46
|
+
addToast,
|
|
47
|
+
removeToast,
|
|
48
|
+
clearAll,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ToastContext.Provider value={contextValue}>
|
|
53
|
+
{children}
|
|
54
|
+
</ToastContext.Provider>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toast Components
|
|
3
|
+
*
|
|
4
|
+
* Toast notification system with provider, hook, and container.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { ToastProvider } from './ToastProvider';
|
|
8
|
+
export { ToastContainer } from './ToastContainer';
|
|
9
|
+
export { Toast } from './Toast';
|
|
10
|
+
export { useToast } from './useToast';
|
|
11
|
+
export { useToastContext, useToastContextOptional } from './ToastContext';
|
|
12
|
+
|
|
13
|
+
export type { ToastProviderProps } from './ToastProvider';
|
|
14
|
+
export type { ToastContainerProps } from './ToastContainer';
|
|
15
|
+
export type { ToastProps } from './Toast';
|
|
16
|
+
export type { ToastOptions } from './useToast';
|
|
17
|
+
export type { Toast as ToastType, ToastVariant, ToastContextValue } from './ToastContext';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useToastContext, type ToastVariant } from './ToastContext';
|
|
5
|
+
|
|
6
|
+
export interface ToastOptions {
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
variant?: ToastVariant;
|
|
10
|
+
duration?: number; // in milliseconds, undefined = no auto-dismiss
|
|
11
|
+
action?: {
|
|
12
|
+
label: string;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* useToast Hook
|
|
19
|
+
*
|
|
20
|
+
* Hook for showing toast notifications.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const toast = useToast();
|
|
25
|
+
*
|
|
26
|
+
* toast.success('Success!', 'Operation completed successfully');
|
|
27
|
+
* toast.error('Error!', 'Something went wrong');
|
|
28
|
+
* toast.info('Info', 'Here is some information');
|
|
29
|
+
* toast.warning('Warning', 'Please be careful');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function useToast() {
|
|
33
|
+
const { addToast, removeToast, clearAll } = useToastContext();
|
|
34
|
+
|
|
35
|
+
const show = useCallback((options: ToastOptions) => {
|
|
36
|
+
return addToast({
|
|
37
|
+
title: options.title,
|
|
38
|
+
description: options.description,
|
|
39
|
+
variant: options.variant || 'info',
|
|
40
|
+
duration: options.duration,
|
|
41
|
+
action: options.action,
|
|
42
|
+
});
|
|
43
|
+
}, [addToast]);
|
|
44
|
+
|
|
45
|
+
const success = useCallback((title: string, description?: string, options?: Omit<ToastOptions, 'title' | 'description' | 'variant'>) => {
|
|
46
|
+
return show({ title, description, variant: 'success', ...options });
|
|
47
|
+
}, [show]);
|
|
48
|
+
|
|
49
|
+
const error = useCallback((title: string, description?: string, options?: Omit<ToastOptions, 'title' | 'description' | 'variant'>) => {
|
|
50
|
+
return show({ title, description, variant: 'error', ...options });
|
|
51
|
+
}, [show]);
|
|
52
|
+
|
|
53
|
+
const warning = useCallback((title: string, description?: string, options?: Omit<ToastOptions, 'title' | 'description' | 'variant'>) => {
|
|
54
|
+
return show({ title, description, variant: 'warning', ...options });
|
|
55
|
+
}, [show]);
|
|
56
|
+
|
|
57
|
+
const info = useCallback((title: string, description?: string, options?: Omit<ToastOptions, 'title' | 'description' | 'variant'>) => {
|
|
58
|
+
return show({ title, description, variant: 'info', ...options });
|
|
59
|
+
}, [show]);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
show,
|
|
63
|
+
success,
|
|
64
|
+
error,
|
|
65
|
+
warning,
|
|
66
|
+
info,
|
|
67
|
+
dismiss: removeToast,
|
|
68
|
+
clearAll,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -3,7 +3,22 @@ export { default as LoginBox } from "./LoginBox/LoginBox";
|
|
|
3
3
|
export { default as Modal } from "./Modal/Modal";
|
|
4
4
|
|
|
5
5
|
export { default as Table } from "./Table/Table";
|
|
6
|
-
export
|
|
6
|
+
export * from "./Table";
|
|
7
7
|
|
|
8
8
|
export { default as Sidebar } from "./Sidebar/Sidebar";
|
|
9
|
-
export
|
|
9
|
+
export * from "./Sidebar";
|
|
10
|
+
|
|
11
|
+
export * from "./Dialog";
|
|
12
|
+
export * from "./Toast";
|
|
13
|
+
|
|
14
|
+
export { default as Stepper } from "./Stepper/Stepper";
|
|
15
|
+
export type { StepperProps, StepperStep, StepperStatus } from "./Stepper/Stepper";
|
|
16
|
+
|
|
17
|
+
export { default as Timeline } from "./Timeline/Timeline";
|
|
18
|
+
export type { TimelineProps, TimelineItem, TimelineOrientation } from "./Timeline/Timeline";
|
|
19
|
+
|
|
20
|
+
export { default as CommandPalette } from "./CommandPalette/CommandPalette";
|
|
21
|
+
export type { CommandPaletteProps, CommandItem } from "./CommandPalette/CommandPalette";
|
|
22
|
+
|
|
23
|
+
export { default as DataGrid } from "./DataGrid/DataGrid";
|
|
24
|
+
export type { DataGridProps, DataGridColumn, DataGridGroup } from "./DataGrid/DataGrid";
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advanced Theme Provider
|
|
3
|
+
*
|
|
4
|
+
* Enhanced ThemeProvider with support for:
|
|
5
|
+
* - Multiple themes simultaneously
|
|
6
|
+
* - CSS variables
|
|
7
|
+
* - Theme inheritance
|
|
8
|
+
* - Smooth transitions
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use client';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
createContext,
|
|
15
|
+
useContext,
|
|
16
|
+
useEffect,
|
|
17
|
+
useState,
|
|
18
|
+
useMemo,
|
|
19
|
+
useCallback,
|
|
20
|
+
type ReactNode,
|
|
21
|
+
} from 'react';
|
|
22
|
+
import { themeRegistry } from '../themes/ThemeRegistry';
|
|
23
|
+
import { applyCSSVariables, removeCSSVariables } from '../themes/utils';
|
|
24
|
+
import type { Theme, CustomThemeConfig, ThemeBuilderOptions } from '../themes/types';
|
|
25
|
+
|
|
26
|
+
export interface AdvancedThemeContextValue {
|
|
27
|
+
// Current active theme
|
|
28
|
+
currentTheme: string;
|
|
29
|
+
themes: Record<string, Theme>;
|
|
30
|
+
|
|
31
|
+
// Theme operations
|
|
32
|
+
setTheme: (themeName: string) => void;
|
|
33
|
+
registerTheme: (config: CustomThemeConfig) => Theme;
|
|
34
|
+
removeTheme: (themeName: string) => boolean;
|
|
35
|
+
|
|
36
|
+
// Get theme
|
|
37
|
+
getTheme: (themeName?: string) => Theme | undefined;
|
|
38
|
+
|
|
39
|
+
// Theme tokens (from current theme)
|
|
40
|
+
tokens: Theme | null;
|
|
41
|
+
|
|
42
|
+
// Options
|
|
43
|
+
options: ThemeBuilderOptions;
|
|
44
|
+
setOptions: (options: Partial<ThemeBuilderOptions>) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const AdvancedThemeContext = createContext<AdvancedThemeContextValue | undefined>(undefined);
|
|
48
|
+
|
|
49
|
+
export interface AdvancedThemeProviderProps {
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
defaultTheme?: string;
|
|
52
|
+
options?: ThemeBuilderOptions;
|
|
53
|
+
initialThemes?: CustomThemeConfig[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Advanced ThemeProvider Component
|
|
58
|
+
*
|
|
59
|
+
* Provides advanced theme management with support for multiple themes,
|
|
60
|
+
* CSS variables, inheritance, and smooth transitions.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```tsx
|
|
64
|
+
* <AdvancedThemeProvider
|
|
65
|
+
* defaultTheme="light"
|
|
66
|
+
* options={{
|
|
67
|
+
* enableCSSVariables: true,
|
|
68
|
+
* enableTransitions: true,
|
|
69
|
+
* }}
|
|
70
|
+
* >
|
|
71
|
+
* <App />
|
|
72
|
+
* </AdvancedThemeProvider>
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export function AdvancedThemeProvider({
|
|
76
|
+
children,
|
|
77
|
+
defaultTheme = 'light',
|
|
78
|
+
options: initialOptions = {},
|
|
79
|
+
initialThemes = [],
|
|
80
|
+
}: AdvancedThemeProviderProps) {
|
|
81
|
+
const [currentThemeName, setCurrentThemeName] = useState<string>(() => {
|
|
82
|
+
if (typeof window === 'undefined') {
|
|
83
|
+
return defaultTheme;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
const storageKey = initialOptions.storageKey || 'theme';
|
|
88
|
+
const stored = localStorage.getItem(storageKey);
|
|
89
|
+
if (stored && themeRegistry.has(stored)) {
|
|
90
|
+
return stored;
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.warn('Failed to read theme from localStorage:', error);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return defaultTheme;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const [options, setOptionsState] = useState<ThemeBuilderOptions>({
|
|
100
|
+
enableCSSVariables: true,
|
|
101
|
+
enableTransitions: true,
|
|
102
|
+
transitionDuration: '200ms',
|
|
103
|
+
storageKey: 'theme',
|
|
104
|
+
...initialOptions,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Register initial themes
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
for (const config of initialThemes) {
|
|
110
|
+
themeRegistry.register(config);
|
|
111
|
+
}
|
|
112
|
+
}, [initialThemes]);
|
|
113
|
+
|
|
114
|
+
// Get current theme
|
|
115
|
+
const currentTheme = useMemo(() => {
|
|
116
|
+
return themeRegistry.get(currentThemeName);
|
|
117
|
+
}, [currentThemeName]);
|
|
118
|
+
|
|
119
|
+
// Get all themes
|
|
120
|
+
const themes = useMemo(() => {
|
|
121
|
+
return themeRegistry.getAll();
|
|
122
|
+
}, [currentThemeName]);
|
|
123
|
+
|
|
124
|
+
// Apply CSS variables
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!currentTheme || !options.enableCSSVariables) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const root = document.documentElement;
|
|
131
|
+
const variableNames = Object.keys(currentTheme.cssVariables);
|
|
132
|
+
|
|
133
|
+
// Apply transition if enabled
|
|
134
|
+
if (options.enableTransitions) {
|
|
135
|
+
const duration = options.transitionDuration || '200ms';
|
|
136
|
+
root.style.setProperty('--theme-transition', `all ${duration} ease-in-out`);
|
|
137
|
+
root.style.transition = 'var(--theme-transition)';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Apply CSS variables
|
|
141
|
+
applyCSSVariables(root, currentTheme.cssVariables);
|
|
142
|
+
|
|
143
|
+
// Apply theme class
|
|
144
|
+
root.classList.remove(...themeRegistry.getThemeNames());
|
|
145
|
+
root.classList.add(currentThemeName);
|
|
146
|
+
|
|
147
|
+
// Cleanup function
|
|
148
|
+
return () => {
|
|
149
|
+
if (options.enableTransitions) {
|
|
150
|
+
root.style.removeProperty('--theme-transition');
|
|
151
|
+
root.style.removeProperty('transition');
|
|
152
|
+
}
|
|
153
|
+
removeCSSVariables(root, variableNames);
|
|
154
|
+
};
|
|
155
|
+
}, [currentTheme, currentThemeName, options]);
|
|
156
|
+
|
|
157
|
+
// Persist theme to localStorage
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (typeof window === 'undefined') {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
const storageKey = options.storageKey || 'theme';
|
|
165
|
+
localStorage.setItem(storageKey, currentThemeName);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.warn('Failed to save theme to localStorage:', error);
|
|
168
|
+
}
|
|
169
|
+
}, [currentThemeName, options.storageKey]);
|
|
170
|
+
|
|
171
|
+
// Set theme
|
|
172
|
+
const setTheme = useCallback((themeName: string) => {
|
|
173
|
+
if (themeRegistry.has(themeName)) {
|
|
174
|
+
setCurrentThemeName(themeName);
|
|
175
|
+
} else {
|
|
176
|
+
console.warn(`Theme "${themeName}" not found. Available themes: ${themeRegistry.getThemeNames().join(', ')}`);
|
|
177
|
+
}
|
|
178
|
+
}, []);
|
|
179
|
+
|
|
180
|
+
// Register new theme
|
|
181
|
+
const registerTheme = useCallback((config: CustomThemeConfig): Theme => {
|
|
182
|
+
return themeRegistry.register(config);
|
|
183
|
+
}, []);
|
|
184
|
+
|
|
185
|
+
// Remove theme
|
|
186
|
+
const removeTheme = useCallback((themeName: string): boolean => {
|
|
187
|
+
return themeRegistry.remove(themeName);
|
|
188
|
+
}, []);
|
|
189
|
+
|
|
190
|
+
// Get theme
|
|
191
|
+
const getTheme = useCallback((themeName?: string): Theme | undefined => {
|
|
192
|
+
const name = themeName || currentThemeName;
|
|
193
|
+
return themeRegistry.get(name);
|
|
194
|
+
}, [currentThemeName]);
|
|
195
|
+
|
|
196
|
+
// Set options
|
|
197
|
+
const setOptions = useCallback((newOptions: Partial<ThemeBuilderOptions>) => {
|
|
198
|
+
setOptionsState((prev) => ({ ...prev, ...newOptions }));
|
|
199
|
+
}, []);
|
|
200
|
+
|
|
201
|
+
const value: AdvancedThemeContextValue = {
|
|
202
|
+
currentTheme: currentThemeName,
|
|
203
|
+
themes,
|
|
204
|
+
setTheme,
|
|
205
|
+
registerTheme,
|
|
206
|
+
removeTheme,
|
|
207
|
+
getTheme,
|
|
208
|
+
tokens: currentTheme || null,
|
|
209
|
+
options,
|
|
210
|
+
setOptions,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<AdvancedThemeContext.Provider value={value}>
|
|
215
|
+
{children}
|
|
216
|
+
</AdvancedThemeContext.Provider>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Hook to use advanced theme context
|
|
222
|
+
*/
|
|
223
|
+
export function useAdvancedTheme(): AdvancedThemeContextValue {
|
|
224
|
+
const context = useContext(AdvancedThemeContext);
|
|
225
|
+
if (context === undefined) {
|
|
226
|
+
throw new Error('useAdvancedTheme must be used within an AdvancedThemeProvider');
|
|
227
|
+
}
|
|
228
|
+
return context;
|
|
229
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Providers Module
|
|
3
|
+
*
|
|
4
|
+
* Exports for theme and context providers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { ThemeProvider, useTheme } from './ThemeProvider';
|
|
8
|
+
export type { ThemeContextValue, ThemeProviderProps } from './ThemeProvider';
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
AdvancedThemeProvider,
|
|
12
|
+
useAdvancedTheme,
|
|
13
|
+
} from './AdvancedThemeProvider';
|
|
14
|
+
export type { AdvancedThemeContextValue, AdvancedThemeProviderProps } from './AdvancedThemeProvider';
|