@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,207 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import { Button, Select, Text } from '../../../atoms';
|
|
5
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
6
|
+
|
|
7
|
+
export interface TablePaginationProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
page: number;
|
|
9
|
+
pageSize: number;
|
|
10
|
+
total: number;
|
|
11
|
+
onPageChange: (page: number) => void;
|
|
12
|
+
onPageSizeChange: (size: number) => void;
|
|
13
|
+
pageSizeOptions?: number[];
|
|
14
|
+
showPageSizeSelector?: boolean;
|
|
15
|
+
showPageInfo?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* TablePagination Component
|
|
20
|
+
*
|
|
21
|
+
* Pagination controls for tables with page navigation and page size selection.
|
|
22
|
+
* Follows Atomic Design principles as a Molecule component.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <TablePagination
|
|
27
|
+
* page={1}
|
|
28
|
+
* pageSize={10}
|
|
29
|
+
* total={100}
|
|
30
|
+
* onPageChange={(page) => setPage(page)}
|
|
31
|
+
* onPageSizeChange={(size) => setPageSize(size)}
|
|
32
|
+
* />
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export default function TablePagination({
|
|
36
|
+
page,
|
|
37
|
+
pageSize,
|
|
38
|
+
total,
|
|
39
|
+
onPageChange,
|
|
40
|
+
onPageSizeChange,
|
|
41
|
+
pageSizeOptions = [10, 25, 50, 100],
|
|
42
|
+
showPageSizeSelector = true,
|
|
43
|
+
showPageInfo = true,
|
|
44
|
+
className = '',
|
|
45
|
+
...props
|
|
46
|
+
}: TablePaginationProps) {
|
|
47
|
+
const totalPages = Math.ceil(total / pageSize);
|
|
48
|
+
const startItem = total === 0 ? 0 : (page - 1) * pageSize + 1;
|
|
49
|
+
const endItem = Math.min(page * pageSize, total);
|
|
50
|
+
|
|
51
|
+
const handlePrevious = () => {
|
|
52
|
+
if (page > 1) {
|
|
53
|
+
onPageChange(page - 1);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleNext = () => {
|
|
58
|
+
if (page < totalPages) {
|
|
59
|
+
onPageChange(page + 1);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleFirst = () => {
|
|
64
|
+
if (page > 1) {
|
|
65
|
+
onPageChange(1);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleLast = () => {
|
|
70
|
+
if (page < totalPages) {
|
|
71
|
+
onPageChange(totalPages);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
className={`flex items-center justify-between px-4 py-3 bg-white border-t border-gray-200 sm:px-6 ${className}`}
|
|
78
|
+
{...props}
|
|
79
|
+
>
|
|
80
|
+
<div className="flex flex-1 justify-between sm:hidden">
|
|
81
|
+
<Button
|
|
82
|
+
variant="outline"
|
|
83
|
+
size="sm"
|
|
84
|
+
onClick={handlePrevious}
|
|
85
|
+
disabled={page === 1}
|
|
86
|
+
>
|
|
87
|
+
Previous
|
|
88
|
+
</Button>
|
|
89
|
+
<Button
|
|
90
|
+
variant="outline"
|
|
91
|
+
size="sm"
|
|
92
|
+
onClick={handleNext}
|
|
93
|
+
disabled={page >= totalPages}
|
|
94
|
+
>
|
|
95
|
+
Next
|
|
96
|
+
</Button>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div className="hidden sm:flex sm:flex-1 sm:items-center sm:justify-between">
|
|
100
|
+
{showPageInfo && (
|
|
101
|
+
<div>
|
|
102
|
+
<Text as="p" className="text-sm text-gray-700">
|
|
103
|
+
Showing <span className="font-medium">{startItem}</span> to{' '}
|
|
104
|
+
<span className="font-medium">{endItem}</span> of{' '}
|
|
105
|
+
<span className="font-medium">{total}</span> results
|
|
106
|
+
</Text>
|
|
107
|
+
</div>
|
|
108
|
+
)}
|
|
109
|
+
|
|
110
|
+
<div className="flex items-center gap-4">
|
|
111
|
+
{showPageSizeSelector && (
|
|
112
|
+
<div className="flex items-center gap-2">
|
|
113
|
+
<Text as="span" className="text-sm text-gray-700">
|
|
114
|
+
Show:
|
|
115
|
+
</Text>
|
|
116
|
+
<Select
|
|
117
|
+
options={pageSizeOptions.map(size => ({
|
|
118
|
+
value: size.toString(),
|
|
119
|
+
label: size.toString(),
|
|
120
|
+
}))}
|
|
121
|
+
value={pageSize.toString()}
|
|
122
|
+
onChange={(e) => {
|
|
123
|
+
const newSize = parseInt(e.target.value);
|
|
124
|
+
onPageSizeChange(newSize);
|
|
125
|
+
// Reset to first page when changing page size
|
|
126
|
+
onPageChange(1);
|
|
127
|
+
}}
|
|
128
|
+
className="w-20"
|
|
129
|
+
/>
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
|
|
133
|
+
<nav className="flex items-center gap-1" aria-label="Pagination">
|
|
134
|
+
<Button
|
|
135
|
+
variant="ghost"
|
|
136
|
+
size="sm"
|
|
137
|
+
onClick={handleFirst}
|
|
138
|
+
disabled={page === 1}
|
|
139
|
+
aria-label="First page"
|
|
140
|
+
>
|
|
141
|
+
<ChevronLeft className="h-4 w-4" />
|
|
142
|
+
<ChevronLeft className="h-4 w-4 -ml-2" />
|
|
143
|
+
</Button>
|
|
144
|
+
<Button
|
|
145
|
+
variant="ghost"
|
|
146
|
+
size="sm"
|
|
147
|
+
onClick={handlePrevious}
|
|
148
|
+
disabled={page === 1}
|
|
149
|
+
aria-label="Previous page"
|
|
150
|
+
>
|
|
151
|
+
<ChevronLeft className="h-4 w-4" />
|
|
152
|
+
</Button>
|
|
153
|
+
|
|
154
|
+
<div className="flex items-center gap-1">
|
|
155
|
+
{Array.from({ length: Math.min(5, totalPages) }, (_, i) => {
|
|
156
|
+
let pageNum: number;
|
|
157
|
+
if (totalPages <= 5) {
|
|
158
|
+
pageNum = i + 1;
|
|
159
|
+
} else if (page <= 3) {
|
|
160
|
+
pageNum = i + 1;
|
|
161
|
+
} else if (page >= totalPages - 2) {
|
|
162
|
+
pageNum = totalPages - 4 + i;
|
|
163
|
+
} else {
|
|
164
|
+
pageNum = page - 2 + i;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<Button
|
|
169
|
+
key={pageNum}
|
|
170
|
+
variant={page === pageNum ? 'primary' : 'ghost'}
|
|
171
|
+
size="sm"
|
|
172
|
+
onClick={() => onPageChange(pageNum)}
|
|
173
|
+
className="min-w-[2.5rem]"
|
|
174
|
+
aria-label={`Page ${pageNum}`}
|
|
175
|
+
aria-current={page === pageNum ? 'page' : undefined}
|
|
176
|
+
>
|
|
177
|
+
{pageNum}
|
|
178
|
+
</Button>
|
|
179
|
+
);
|
|
180
|
+
})}
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<Button
|
|
184
|
+
variant="ghost"
|
|
185
|
+
size="sm"
|
|
186
|
+
onClick={handleNext}
|
|
187
|
+
disabled={page >= totalPages}
|
|
188
|
+
aria-label="Next page"
|
|
189
|
+
>
|
|
190
|
+
<ChevronRight className="h-4 w-4" />
|
|
191
|
+
</Button>
|
|
192
|
+
<Button
|
|
193
|
+
variant="ghost"
|
|
194
|
+
size="sm"
|
|
195
|
+
onClick={handleLast}
|
|
196
|
+
disabled={page >= totalPages}
|
|
197
|
+
aria-label="Last page"
|
|
198
|
+
>
|
|
199
|
+
<ChevronRight className="h-4 w-4" />
|
|
200
|
+
<ChevronRight className="h-4 w-4 -ml-2" />
|
|
201
|
+
</Button>
|
|
202
|
+
</nav>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import { useTableContext } from './TableContext';
|
|
5
|
+
import TablePaginationComponent from './TablePagination/TablePagination';
|
|
6
|
+
|
|
7
|
+
export interface TablePaginationProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
showPageSizeSelector?: boolean;
|
|
9
|
+
showPageInfo?: boolean;
|
|
10
|
+
pageSizeOptions?: number[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* TablePagination Component
|
|
15
|
+
*
|
|
16
|
+
* Renders pagination controls for the table.
|
|
17
|
+
* Uses pagination state from Table context.
|
|
18
|
+
* Must be used within a Table component.
|
|
19
|
+
*/
|
|
20
|
+
export default function TablePagination({
|
|
21
|
+
showPageSizeSelector = true,
|
|
22
|
+
showPageInfo = true,
|
|
23
|
+
pageSizeOptions,
|
|
24
|
+
className = '',
|
|
25
|
+
...props
|
|
26
|
+
}: TablePaginationProps) {
|
|
27
|
+
const { paginationState, setPage, setPageSize, paginationMode } = useTableContext();
|
|
28
|
+
|
|
29
|
+
// Only show pagination if there's more than one page or if in server mode
|
|
30
|
+
if (paginationMode === 'client' && paginationState.totalPages <= 1) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<TablePaginationComponent
|
|
36
|
+
page={paginationState.page}
|
|
37
|
+
pageSize={paginationState.pageSize}
|
|
38
|
+
total={paginationState.total}
|
|
39
|
+
onPageChange={setPage}
|
|
40
|
+
onPageSizeChange={setPageSize}
|
|
41
|
+
pageSizeOptions={pageSizeOptions}
|
|
42
|
+
showPageSizeSelector={showPageSizeSelector}
|
|
43
|
+
showPageInfo={showPageInfo}
|
|
44
|
+
className={className}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useMemo, useCallback } from 'react';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import { TableContext, type TableContextValue, type PaginationMode } from './TableContext';
|
|
6
|
+
import type { TableColumn } from './TableTypes';
|
|
7
|
+
import type { FilterConfig, FilterValue } from './TableFilters/TableFilters';
|
|
8
|
+
import type { TableAction } from './TableActions/TableActions';
|
|
9
|
+
|
|
10
|
+
export interface TableProviderProps<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
11
|
+
columns: TableColumn<T>[];
|
|
12
|
+
data: T[];
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
|
|
15
|
+
// Pagination
|
|
16
|
+
paginationMode?: PaginationMode;
|
|
17
|
+
page?: number; // controlled
|
|
18
|
+
pageSize?: number; // controlled
|
|
19
|
+
total?: number; // required for server mode
|
|
20
|
+
onPageChange?: (page: number) => void; // required for server mode
|
|
21
|
+
onPageSizeChange?: (size: number) => void;
|
|
22
|
+
defaultPageSize?: number;
|
|
23
|
+
pageSizeOptions?: number[];
|
|
24
|
+
|
|
25
|
+
// Sorting
|
|
26
|
+
sortColumn?: string; // controlled
|
|
27
|
+
sortDirection?: 'asc' | 'desc'; // controlled
|
|
28
|
+
onSort?: (column: string, direction: 'asc' | 'desc') => void;
|
|
29
|
+
defaultSortColumn?: string;
|
|
30
|
+
defaultSortDirection?: 'asc' | 'desc';
|
|
31
|
+
|
|
32
|
+
// Filters
|
|
33
|
+
filters?: FilterConfig[];
|
|
34
|
+
filterValues?: Record<string, FilterValue>; // controlled
|
|
35
|
+
onFilter?: (filters: Record<string, FilterValue>) => void;
|
|
36
|
+
initialFilterValues?: Record<string, FilterValue>;
|
|
37
|
+
|
|
38
|
+
// Selection
|
|
39
|
+
selectable?: boolean;
|
|
40
|
+
selectedRows?: string[]; // controlled
|
|
41
|
+
onSelectionChange?: (selected: string[]) => void;
|
|
42
|
+
rowId?: (row: T) => string;
|
|
43
|
+
|
|
44
|
+
// Actions
|
|
45
|
+
actions?: (row: T) => TableAction<T>[];
|
|
46
|
+
|
|
47
|
+
// Empty state
|
|
48
|
+
emptyMessage?: string;
|
|
49
|
+
emptyStateTitle?: string;
|
|
50
|
+
emptyStateMessage?: string;
|
|
51
|
+
emptyStateIllustration?: ReactNode;
|
|
52
|
+
emptyStateAction?: ReactNode;
|
|
53
|
+
|
|
54
|
+
// Callbacks
|
|
55
|
+
onRowClick?: (row: T) => void;
|
|
56
|
+
|
|
57
|
+
// Column resizing
|
|
58
|
+
resizable?: boolean;
|
|
59
|
+
columnWidths?: Record<string, number>;
|
|
60
|
+
onColumnResize?: (columnKey: string, width: number) => void;
|
|
61
|
+
|
|
62
|
+
// Virtual scrolling
|
|
63
|
+
virtualScrolling?: boolean;
|
|
64
|
+
virtualScrollingOptions?: {
|
|
65
|
+
itemHeight?: number;
|
|
66
|
+
containerHeight?: number;
|
|
67
|
+
overscan?: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* TableProvider Component
|
|
75
|
+
*
|
|
76
|
+
* Manages table state (pagination, sorting, filters, selection) and provides it via Context.
|
|
77
|
+
* Supports both client-side and server-side pagination with auto-detection.
|
|
78
|
+
*/
|
|
79
|
+
export function TableProvider<T extends Record<string, unknown> = Record<string, unknown>>({
|
|
80
|
+
columns,
|
|
81
|
+
data,
|
|
82
|
+
loading = false,
|
|
83
|
+
paginationMode: explicitMode,
|
|
84
|
+
page: controlledPage,
|
|
85
|
+
pageSize: controlledPageSize,
|
|
86
|
+
total: externalTotal,
|
|
87
|
+
onPageChange,
|
|
88
|
+
onPageSizeChange,
|
|
89
|
+
defaultPageSize = 10,
|
|
90
|
+
pageSizeOptions: _pageSizeOptions,
|
|
91
|
+
sortColumn: controlledSortColumn,
|
|
92
|
+
sortDirection: controlledSortDirection,
|
|
93
|
+
onSort,
|
|
94
|
+
defaultSortColumn,
|
|
95
|
+
defaultSortDirection = 'asc',
|
|
96
|
+
filters,
|
|
97
|
+
filterValues: controlledFilterValues,
|
|
98
|
+
onFilter,
|
|
99
|
+
initialFilterValues = {},
|
|
100
|
+
selectable = false,
|
|
101
|
+
selectedRows: controlledSelectedRows,
|
|
102
|
+
onSelectionChange,
|
|
103
|
+
rowId,
|
|
104
|
+
actions,
|
|
105
|
+
emptyMessage = "No data available",
|
|
106
|
+
emptyStateTitle,
|
|
107
|
+
emptyStateMessage,
|
|
108
|
+
emptyStateIllustration,
|
|
109
|
+
emptyStateAction,
|
|
110
|
+
onRowClick,
|
|
111
|
+
resizable = false,
|
|
112
|
+
columnWidths,
|
|
113
|
+
onColumnResize,
|
|
114
|
+
virtualScrolling,
|
|
115
|
+
virtualScrollingOptions: _virtualScrollingOptions,
|
|
116
|
+
children,
|
|
117
|
+
}: TableProviderProps<T>) {
|
|
118
|
+
// Detect pagination mode
|
|
119
|
+
const paginationMode: PaginationMode = useMemo(() => {
|
|
120
|
+
if (explicitMode) return explicitMode;
|
|
121
|
+
|
|
122
|
+
// Auto-detect: if total and onPageChange are provided, it's server-side
|
|
123
|
+
if (externalTotal !== undefined && onPageChange) {
|
|
124
|
+
return 'server';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return 'client';
|
|
128
|
+
}, [explicitMode, externalTotal, onPageChange]);
|
|
129
|
+
|
|
130
|
+
// Pagination state
|
|
131
|
+
const isPaginationControlled = controlledPage !== undefined;
|
|
132
|
+
const [internalPage, setInternalPage] = useState(1);
|
|
133
|
+
const [internalPageSize, setInternalPageSize] = useState(defaultPageSize);
|
|
134
|
+
|
|
135
|
+
const page = isPaginationControlled ? controlledPage! : internalPage;
|
|
136
|
+
const pageSize = controlledPageSize ?? internalPageSize;
|
|
137
|
+
|
|
138
|
+
const total = useMemo(() => {
|
|
139
|
+
if (paginationMode === 'server') {
|
|
140
|
+
return externalTotal ?? 0;
|
|
141
|
+
}
|
|
142
|
+
return data.length;
|
|
143
|
+
}, [paginationMode, externalTotal, data.length]);
|
|
144
|
+
|
|
145
|
+
const totalPages = useMemo(() => {
|
|
146
|
+
return Math.ceil(total / pageSize);
|
|
147
|
+
}, [total, pageSize]);
|
|
148
|
+
|
|
149
|
+
// Sorting state
|
|
150
|
+
const isSortingControlled = controlledSortColumn !== undefined;
|
|
151
|
+
const [internalSortColumn, setInternalSortColumn] = useState(defaultSortColumn || '');
|
|
152
|
+
const [internalSortDirection, setInternalSortDirection] = useState<'asc' | 'desc'>(defaultSortDirection);
|
|
153
|
+
|
|
154
|
+
const sortColumn = isSortingControlled ? controlledSortColumn! : internalSortColumn;
|
|
155
|
+
const sortDirection = isSortingControlled ? (controlledSortDirection || 'asc') : internalSortDirection;
|
|
156
|
+
|
|
157
|
+
// Filter state
|
|
158
|
+
const isFilterControlled = controlledFilterValues !== undefined;
|
|
159
|
+
const [internalFilterValues, setInternalFilterValues] = useState<Record<string, unknown>>(initialFilterValues);
|
|
160
|
+
|
|
161
|
+
const filterValues = isFilterControlled ? controlledFilterValues! : internalFilterValues;
|
|
162
|
+
|
|
163
|
+
// Selection state
|
|
164
|
+
const isSelectionControlled = controlledSelectedRows !== undefined;
|
|
165
|
+
const [internalSelectedRows, setInternalSelectedRows] = useState<string[]>([]);
|
|
166
|
+
|
|
167
|
+
const selectedRows = isSelectionControlled ? controlledSelectedRows! : internalSelectedRows;
|
|
168
|
+
|
|
169
|
+
// Apply client-side filtering
|
|
170
|
+
const filteredData = useMemo(() => {
|
|
171
|
+
if (!filters || filters.length === 0) return data;
|
|
172
|
+
|
|
173
|
+
return data.filter((row) => {
|
|
174
|
+
return filters.every((filter) => {
|
|
175
|
+
const value = filterValues[filter.key];
|
|
176
|
+
if (!value || value === '') return true;
|
|
177
|
+
|
|
178
|
+
const rowValue = (row as unknown)[filter.key];
|
|
179
|
+
if (filter.type === 'text') {
|
|
180
|
+
return String(rowValue || '').toLowerCase().includes(String(value).toLowerCase());
|
|
181
|
+
}
|
|
182
|
+
return String(rowValue) === String(value);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}, [data, filters, filterValues]);
|
|
186
|
+
|
|
187
|
+
// Apply client-side sorting (only if not controlled externally)
|
|
188
|
+
const sortedData = useMemo(() => {
|
|
189
|
+
// If sorting is controlled externally (onSort provided), don't sort here
|
|
190
|
+
// The parent component should handle sorting on the server or before passing data
|
|
191
|
+
// However, we still apply sorting if sortColumn is set and no onSort callback
|
|
192
|
+
if (isSortingControlled && onSort) {
|
|
193
|
+
// When controlled, assume data is already sorted by parent
|
|
194
|
+
return filteredData;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Only apply internal sorting if sortColumn is set
|
|
198
|
+
if (!sortColumn) return filteredData;
|
|
199
|
+
|
|
200
|
+
// Apply internal sorting
|
|
201
|
+
const sorted = [...filteredData];
|
|
202
|
+
sorted.sort((a, b) => {
|
|
203
|
+
const aValue = (a as unknown)[sortColumn];
|
|
204
|
+
const bValue = (b as unknown)[sortColumn];
|
|
205
|
+
const comparison = String(aValue || '').localeCompare(String(bValue || ''));
|
|
206
|
+
return sortDirection === 'asc' ? comparison : -comparison;
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
return sorted;
|
|
210
|
+
}, [filteredData, sortColumn, sortDirection, onSort, isSortingControlled]);
|
|
211
|
+
|
|
212
|
+
// Apply client-side pagination
|
|
213
|
+
const paginatedData = useMemo(() => {
|
|
214
|
+
if (paginationMode === 'server') {
|
|
215
|
+
return sortedData; // Server already paginated
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const startIndex = (page - 1) * pageSize;
|
|
219
|
+
const endIndex = startIndex + pageSize;
|
|
220
|
+
return sortedData.slice(startIndex, endIndex);
|
|
221
|
+
}, [sortedData, paginationMode, page, pageSize]);
|
|
222
|
+
|
|
223
|
+
// Selection helpers
|
|
224
|
+
const getRowId = useCallback((row: T, index: number): string => {
|
|
225
|
+
if (rowId) {
|
|
226
|
+
return rowId(row);
|
|
227
|
+
}
|
|
228
|
+
return (row as unknown)?.id?.toString() || index.toString();
|
|
229
|
+
}, [rowId]);
|
|
230
|
+
|
|
231
|
+
const isAllSelected = useMemo(() => {
|
|
232
|
+
if (!selectable || paginatedData.length === 0) return false;
|
|
233
|
+
return paginatedData.every((row, index) => {
|
|
234
|
+
const id = getRowId(row, index);
|
|
235
|
+
return selectedRows.includes(id);
|
|
236
|
+
});
|
|
237
|
+
}, [selectable, paginatedData, selectedRows, getRowId]);
|
|
238
|
+
|
|
239
|
+
const isIndeterminate = useMemo(() => {
|
|
240
|
+
if (!selectable) return false;
|
|
241
|
+
const selectedCount = selectedRows.length;
|
|
242
|
+
return selectedCount > 0 && selectedCount < paginatedData.length;
|
|
243
|
+
}, [selectable, selectedRows.length, paginatedData.length]);
|
|
244
|
+
|
|
245
|
+
// Methods
|
|
246
|
+
const setPage = useCallback((newPage: number) => {
|
|
247
|
+
if (isPaginationControlled) {
|
|
248
|
+
onPageChange?.(newPage);
|
|
249
|
+
} else {
|
|
250
|
+
setInternalPage(newPage);
|
|
251
|
+
}
|
|
252
|
+
}, [isPaginationControlled, onPageChange]);
|
|
253
|
+
|
|
254
|
+
const setPageSize = useCallback((newSize: number) => {
|
|
255
|
+
if (onPageSizeChange) {
|
|
256
|
+
onPageSizeChange(newSize);
|
|
257
|
+
} else {
|
|
258
|
+
setInternalPageSize(newSize);
|
|
259
|
+
}
|
|
260
|
+
setPage(1); // Reset to first page
|
|
261
|
+
}, [onPageSizeChange, setPage]);
|
|
262
|
+
|
|
263
|
+
const setSorting = useCallback((column: string, direction: 'asc' | 'desc') => {
|
|
264
|
+
if (isSortingControlled) {
|
|
265
|
+
onSort?.(column, direction);
|
|
266
|
+
} else {
|
|
267
|
+
setInternalSortColumn(column);
|
|
268
|
+
setInternalSortDirection(direction);
|
|
269
|
+
}
|
|
270
|
+
}, [isSortingControlled, onSort]);
|
|
271
|
+
|
|
272
|
+
const setFilters = useCallback((newFilters: Record<string, FilterValue>) => {
|
|
273
|
+
if (isFilterControlled) {
|
|
274
|
+
onFilter?.(newFilters);
|
|
275
|
+
} else {
|
|
276
|
+
setInternalFilterValues(newFilters);
|
|
277
|
+
}
|
|
278
|
+
// Reset to first page when filters change
|
|
279
|
+
setPage(1);
|
|
280
|
+
}, [isFilterControlled, onFilter, setPage]);
|
|
281
|
+
|
|
282
|
+
const setSelection = useCallback((selected: string[]) => {
|
|
283
|
+
if (isSelectionControlled) {
|
|
284
|
+
onSelectionChange?.(selected);
|
|
285
|
+
} else {
|
|
286
|
+
setInternalSelectedRows(selected);
|
|
287
|
+
}
|
|
288
|
+
}, [isSelectionControlled, onSelectionChange]);
|
|
289
|
+
|
|
290
|
+
const toggleRowSelection = useCallback((rowId: string) => {
|
|
291
|
+
const newSelected = selectedRows.includes(rowId)
|
|
292
|
+
? selectedRows.filter((id) => id !== rowId)
|
|
293
|
+
: [...selectedRows, rowId];
|
|
294
|
+
setSelection(newSelected);
|
|
295
|
+
}, [selectedRows, setSelection]);
|
|
296
|
+
|
|
297
|
+
const toggleSelectAll = useCallback(() => {
|
|
298
|
+
if (isAllSelected) {
|
|
299
|
+
setSelection([]);
|
|
300
|
+
} else {
|
|
301
|
+
const allIds = paginatedData.map((row, index) => getRowId(row, index));
|
|
302
|
+
setSelection(allIds);
|
|
303
|
+
}
|
|
304
|
+
}, [isAllSelected, paginatedData, getRowId, setSelection]);
|
|
305
|
+
|
|
306
|
+
// Column resizing state
|
|
307
|
+
const [internalColumnWidths, setInternalColumnWidths] = useState<Record<string, number>>({});
|
|
308
|
+
const isColumnWidthsControlled = columnWidths !== undefined;
|
|
309
|
+
const finalColumnWidths = isColumnWidthsControlled ? columnWidths! : internalColumnWidths;
|
|
310
|
+
|
|
311
|
+
const setColumnWidth = useCallback((columnKey: string, width: number) => {
|
|
312
|
+
if (isColumnWidthsControlled) {
|
|
313
|
+
onColumnResize?.(columnKey, width);
|
|
314
|
+
} else {
|
|
315
|
+
setInternalColumnWidths((prev) => ({
|
|
316
|
+
...prev,
|
|
317
|
+
[columnKey]: width,
|
|
318
|
+
}));
|
|
319
|
+
}
|
|
320
|
+
}, [isColumnWidthsControlled, onColumnResize]);
|
|
321
|
+
|
|
322
|
+
// Use controlledColumnWidths from props if provided
|
|
323
|
+
const _controlledColumnWidths = columnWidths;
|
|
324
|
+
|
|
325
|
+
// Context value
|
|
326
|
+
const contextValue: TableContextValue<T> = useMemo(() => ({
|
|
327
|
+
columns,
|
|
328
|
+
data,
|
|
329
|
+
paginatedData,
|
|
330
|
+
loading,
|
|
331
|
+
paginationState: {
|
|
332
|
+
page,
|
|
333
|
+
pageSize,
|
|
334
|
+
total,
|
|
335
|
+
totalPages,
|
|
336
|
+
},
|
|
337
|
+
sortState: {
|
|
338
|
+
column: sortColumn,
|
|
339
|
+
direction: sortDirection,
|
|
340
|
+
},
|
|
341
|
+
filterState: {
|
|
342
|
+
values: filterValues,
|
|
343
|
+
config: filters || [],
|
|
344
|
+
},
|
|
345
|
+
selectionState: {
|
|
346
|
+
selectedRows,
|
|
347
|
+
isAllSelected,
|
|
348
|
+
isIndeterminate,
|
|
349
|
+
},
|
|
350
|
+
paginationMode,
|
|
351
|
+
selectable,
|
|
352
|
+
rowId,
|
|
353
|
+
actions,
|
|
354
|
+
resizable,
|
|
355
|
+
columnWidths: finalColumnWidths,
|
|
356
|
+
virtualScrolling,
|
|
357
|
+
emptyMessage,
|
|
358
|
+
emptyStateTitle,
|
|
359
|
+
emptyStateMessage,
|
|
360
|
+
emptyStateIllustration,
|
|
361
|
+
emptyStateAction,
|
|
362
|
+
setPage,
|
|
363
|
+
setPageSize,
|
|
364
|
+
setSorting,
|
|
365
|
+
setFilters,
|
|
366
|
+
setSelection,
|
|
367
|
+
toggleRowSelection,
|
|
368
|
+
toggleSelectAll,
|
|
369
|
+
getRowId,
|
|
370
|
+
setColumnWidth,
|
|
371
|
+
onPageChange,
|
|
372
|
+
onPageSizeChange,
|
|
373
|
+
onSort,
|
|
374
|
+
onFilter,
|
|
375
|
+
onSelectionChange,
|
|
376
|
+
onRowClick,
|
|
377
|
+
onColumnResize,
|
|
378
|
+
}), [
|
|
379
|
+
columns,
|
|
380
|
+
data,
|
|
381
|
+
paginatedData,
|
|
382
|
+
loading,
|
|
383
|
+
page,
|
|
384
|
+
pageSize,
|
|
385
|
+
total,
|
|
386
|
+
totalPages,
|
|
387
|
+
sortColumn,
|
|
388
|
+
sortDirection,
|
|
389
|
+
filterValues,
|
|
390
|
+
filters,
|
|
391
|
+
selectedRows,
|
|
392
|
+
isAllSelected,
|
|
393
|
+
isIndeterminate,
|
|
394
|
+
paginationMode,
|
|
395
|
+
selectable,
|
|
396
|
+
rowId,
|
|
397
|
+
actions,
|
|
398
|
+
emptyMessage,
|
|
399
|
+
emptyStateTitle,
|
|
400
|
+
emptyStateMessage,
|
|
401
|
+
emptyStateIllustration,
|
|
402
|
+
emptyStateAction,
|
|
403
|
+
setPage,
|
|
404
|
+
setPageSize,
|
|
405
|
+
setSorting,
|
|
406
|
+
setFilters,
|
|
407
|
+
setSelection,
|
|
408
|
+
toggleRowSelection,
|
|
409
|
+
toggleSelectAll,
|
|
410
|
+
getRowId,
|
|
411
|
+
setColumnWidth,
|
|
412
|
+
onPageChange,
|
|
413
|
+
onPageSizeChange,
|
|
414
|
+
onSort,
|
|
415
|
+
onFilter,
|
|
416
|
+
onSelectionChange,
|
|
417
|
+
onRowClick,
|
|
418
|
+
onColumnResize,
|
|
419
|
+
resizable,
|
|
420
|
+
columnWidths,
|
|
421
|
+
virtualScrolling,
|
|
422
|
+
]);
|
|
423
|
+
|
|
424
|
+
return (
|
|
425
|
+
<TableContext.Provider value={contextValue}>
|
|
426
|
+
{children}
|
|
427
|
+
</TableContext.Provider>
|
|
428
|
+
);
|
|
429
|
+
}
|