@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,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import { useTableContext } from './TableContext';
|
|
5
|
+
import TableActionsComponent from './TableActions/TableActions';
|
|
6
|
+
|
|
7
|
+
export interface TableActionsProps<T extends Record<string, unknown> = Record<string, unknown>> extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
row: T;
|
|
9
|
+
align?: 'left' | 'right';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* TableActions Component
|
|
14
|
+
*
|
|
15
|
+
* Renders action dropdown menu for a table row.
|
|
16
|
+
* Uses actions configuration from Table context.
|
|
17
|
+
* Must be used within a Table component.
|
|
18
|
+
*/
|
|
19
|
+
export default function TableActions<T extends Record<string, unknown> = Record<string, unknown>>({
|
|
20
|
+
row,
|
|
21
|
+
align = 'right',
|
|
22
|
+
className = '',
|
|
23
|
+
...props
|
|
24
|
+
}: TableActionsProps<T>) {
|
|
25
|
+
const { actions } = useTableContext<T>();
|
|
26
|
+
|
|
27
|
+
if (!actions) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const rowActions = actions(row);
|
|
32
|
+
|
|
33
|
+
if (rowActions.length === 0) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<TableActionsComponent
|
|
39
|
+
row={row}
|
|
40
|
+
actions={rowActions}
|
|
41
|
+
align={align}
|
|
42
|
+
className={className}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo, type HTMLAttributes, ReactNode } from 'react';
|
|
4
|
+
import { useTableContext } from './TableContext';
|
|
5
|
+
import { Skeleton } from '../../atoms';
|
|
6
|
+
import TableRow from './TableRow';
|
|
7
|
+
import TableEmptyState from './TableEmptyState';
|
|
8
|
+
import { useVirtualScrolling } from './useVirtualScrolling';
|
|
9
|
+
|
|
10
|
+
export interface TableBodyProps<T extends Record<string, unknown> = Record<string, unknown>> extends Omit<HTMLAttributes<HTMLTableSectionElement>, 'children'> {
|
|
11
|
+
children?: (row: T, index: number) => ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* TableBody Component
|
|
17
|
+
*
|
|
18
|
+
* Renders the table body (tbody) with rows.
|
|
19
|
+
* Can render loading skeleton, empty state, or data rows.
|
|
20
|
+
* Must be used within a Table component.
|
|
21
|
+
*/
|
|
22
|
+
export default function TableBody({
|
|
23
|
+
children,
|
|
24
|
+
className = '',
|
|
25
|
+
...props
|
|
26
|
+
}: TableBodyProps) {
|
|
27
|
+
const {
|
|
28
|
+
paginatedData,
|
|
29
|
+
loading,
|
|
30
|
+
columns,
|
|
31
|
+
selectable,
|
|
32
|
+
actions,
|
|
33
|
+
virtualScrolling,
|
|
34
|
+
virtualScrollingOptions,
|
|
35
|
+
} = useTableContext();
|
|
36
|
+
|
|
37
|
+
// Calculate total columns for colspan
|
|
38
|
+
const totalColumns = columns.length + (selectable ? 1 : 0) + (actions ? 1 : 0);
|
|
39
|
+
|
|
40
|
+
// Virtual scrolling
|
|
41
|
+
const virtualScrollingResult = useVirtualScrolling(
|
|
42
|
+
paginatedData,
|
|
43
|
+
{
|
|
44
|
+
itemHeight: virtualScrollingOptions?.itemHeight || 50,
|
|
45
|
+
containerHeight: virtualScrollingOptions?.containerHeight,
|
|
46
|
+
overscan: virtualScrollingOptions?.overscan || 5,
|
|
47
|
+
enabled: virtualScrolling || false,
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const rowsToRender = useMemo(() => {
|
|
52
|
+
if (virtualScrolling && virtualScrollingResult.virtualItems.length > 0) {
|
|
53
|
+
return virtualScrollingResult.virtualItems
|
|
54
|
+
.map((item) => ({
|
|
55
|
+
row: paginatedData[item.index],
|
|
56
|
+
index: item.index,
|
|
57
|
+
}))
|
|
58
|
+
.filter((item) => item.row !== undefined);
|
|
59
|
+
}
|
|
60
|
+
return paginatedData.map((row, index) => ({ row, index }));
|
|
61
|
+
}, [virtualScrolling, virtualScrollingResult.virtualItems, paginatedData]);
|
|
62
|
+
|
|
63
|
+
if (loading) {
|
|
64
|
+
return (
|
|
65
|
+
<tbody className={`bg-white divide-y divide-gray-200 ${className}`} {...props}>
|
|
66
|
+
{Array.from({ length: 5 }).map((_, index) => (
|
|
67
|
+
<tr key={index}>
|
|
68
|
+
{Array.from({ length: totalColumns }).map((_, colIndex) => (
|
|
69
|
+
<td key={colIndex} className="px-6 py-4">
|
|
70
|
+
<Skeleton className="h-4 w-full" />
|
|
71
|
+
</td>
|
|
72
|
+
))}
|
|
73
|
+
</tr>
|
|
74
|
+
))}
|
|
75
|
+
</tbody>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (paginatedData.length === 0) {
|
|
80
|
+
return (
|
|
81
|
+
<tbody className={`bg-white divide-y divide-gray-200 ${className}`} {...props}>
|
|
82
|
+
<tr>
|
|
83
|
+
<td colSpan={totalColumns} className="px-6 py-12">
|
|
84
|
+
<TableEmptyState />
|
|
85
|
+
</td>
|
|
86
|
+
</tr>
|
|
87
|
+
</tbody>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// If children is a render function, use it
|
|
92
|
+
if (typeof children === 'function') {
|
|
93
|
+
return (
|
|
94
|
+
<tbody className={`bg-white divide-y divide-gray-200 ${className}`} {...props}>
|
|
95
|
+
{paginatedData.map((row, index) => children(row, index))}
|
|
96
|
+
</tbody>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Default: render TableRow for each data item
|
|
101
|
+
return (
|
|
102
|
+
<tbody
|
|
103
|
+
className={`bg-white divide-y divide-gray-200 ${className}`}
|
|
104
|
+
role="rowgroup"
|
|
105
|
+
{...props}
|
|
106
|
+
>
|
|
107
|
+
{virtualScrolling && virtualScrollingResult.virtualItems.length > 0 && rowsToRender.length > 0 ? (
|
|
108
|
+
// Virtual scrolling: render with spacer rows
|
|
109
|
+
<>
|
|
110
|
+
{virtualScrollingResult.virtualItems[0]?.start > 0 && (
|
|
111
|
+
<tr style={{ height: virtualScrollingResult.virtualItems[0].start }} aria-hidden="true">
|
|
112
|
+
<td colSpan={totalColumns} />
|
|
113
|
+
</tr>
|
|
114
|
+
)}
|
|
115
|
+
{rowsToRender.map(({ row, index }) => (
|
|
116
|
+
<TableRow key={index} row={row} rowIndex={index} />
|
|
117
|
+
))}
|
|
118
|
+
{virtualScrollingResult.virtualItems.length > 0 && (
|
|
119
|
+
<tr
|
|
120
|
+
style={{
|
|
121
|
+
height: Math.max(0, virtualScrollingResult.totalHeight - (virtualScrollingResult.virtualItems[virtualScrollingResult.virtualItems.length - 1]?.end || 0)),
|
|
122
|
+
}}
|
|
123
|
+
aria-hidden="true"
|
|
124
|
+
>
|
|
125
|
+
<td colSpan={totalColumns} />
|
|
126
|
+
</tr>
|
|
127
|
+
)}
|
|
128
|
+
</>
|
|
129
|
+
) : (
|
|
130
|
+
// Normal rendering
|
|
131
|
+
rowsToRender.map(({ row, index }) => (
|
|
132
|
+
<TableRow key={index} row={row} rowIndex={index} />
|
|
133
|
+
))
|
|
134
|
+
)}
|
|
135
|
+
</tbody>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import type { TableColumn } from './TableTypes';
|
|
5
|
+
|
|
6
|
+
export interface TableCellProps<T = unknown> extends HTMLAttributes<HTMLTableCellElement> {
|
|
7
|
+
column: TableColumn<T>;
|
|
8
|
+
row: T;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* TableCell Component
|
|
13
|
+
*
|
|
14
|
+
* Renders a table cell (td) for a column.
|
|
15
|
+
* Uses column.render if available, otherwise renders the raw value.
|
|
16
|
+
* Must be used within a Table component.
|
|
17
|
+
*/
|
|
18
|
+
export default function TableCell<T extends Record<string, unknown> = Record<string, unknown>>({
|
|
19
|
+
column,
|
|
20
|
+
row,
|
|
21
|
+
className = '',
|
|
22
|
+
...props
|
|
23
|
+
}: TableCellProps<T>) {
|
|
24
|
+
const value = column.key in row ? row[column.key as keyof T] : undefined;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<td
|
|
28
|
+
className={`px-6 py-4 whitespace-nowrap text-sm text-gray-900 ${
|
|
29
|
+
column.hiddenOnMobile ? 'hidden md:table-cell' : ''
|
|
30
|
+
} ${className}`}
|
|
31
|
+
{...props}
|
|
32
|
+
>
|
|
33
|
+
{column.render ? column.render(value, row) : String(value ?? '')}
|
|
34
|
+
</td>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import type { TableColumn } from './TableTypes';
|
|
6
|
+
import type { FilterConfig } from './TableFilters/TableFilters';
|
|
7
|
+
import type { TableAction } from './TableActions/TableActions';
|
|
8
|
+
|
|
9
|
+
export type PaginationMode = 'client' | 'server' | 'auto';
|
|
10
|
+
|
|
11
|
+
export interface PaginationState {
|
|
12
|
+
page: number;
|
|
13
|
+
pageSize: number;
|
|
14
|
+
total: number;
|
|
15
|
+
totalPages: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SortState {
|
|
19
|
+
column: string;
|
|
20
|
+
direction: 'asc' | 'desc';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
import type { FilterValue } from './TableFilters/TableFilters';
|
|
24
|
+
|
|
25
|
+
export interface FilterState {
|
|
26
|
+
values: Record<string, FilterValue>;
|
|
27
|
+
config: FilterConfig[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SelectionState {
|
|
31
|
+
selectedRows: string[];
|
|
32
|
+
isAllSelected: boolean;
|
|
33
|
+
isIndeterminate: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface TableContextValue<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
37
|
+
// Data
|
|
38
|
+
columns: TableColumn<T>[];
|
|
39
|
+
data: T[];
|
|
40
|
+
paginatedData: T[];
|
|
41
|
+
loading: boolean;
|
|
42
|
+
|
|
43
|
+
// State
|
|
44
|
+
paginationState: PaginationState;
|
|
45
|
+
sortState: SortState;
|
|
46
|
+
filterState: FilterState;
|
|
47
|
+
selectionState: SelectionState;
|
|
48
|
+
|
|
49
|
+
// Configuration
|
|
50
|
+
paginationMode: PaginationMode;
|
|
51
|
+
selectable: boolean;
|
|
52
|
+
rowId?: (row: T) => string;
|
|
53
|
+
actions?: (row: T) => TableAction<T>[];
|
|
54
|
+
resizable?: boolean;
|
|
55
|
+
columnWidths?: Record<string, number>;
|
|
56
|
+
virtualScrolling?: boolean;
|
|
57
|
+
|
|
58
|
+
// Empty state
|
|
59
|
+
emptyMessage?: string;
|
|
60
|
+
emptyStateTitle?: string;
|
|
61
|
+
emptyStateMessage?: string;
|
|
62
|
+
emptyStateIllustration?: ReactNode;
|
|
63
|
+
emptyStateAction?: ReactNode;
|
|
64
|
+
|
|
65
|
+
// Methods
|
|
66
|
+
setPage: (page: number) => void;
|
|
67
|
+
setPageSize: (size: number) => void;
|
|
68
|
+
setSorting: (column: string, direction: 'asc' | 'desc') => void;
|
|
69
|
+
setFilters: (filters: Record<string, FilterValue>) => void;
|
|
70
|
+
setSelection: (selected: string[]) => void;
|
|
71
|
+
toggleRowSelection: (rowId: string) => void;
|
|
72
|
+
toggleSelectAll: () => void;
|
|
73
|
+
getRowId: (row: T, index: number) => string;
|
|
74
|
+
setColumnWidth?: (columnKey: string, width: number) => void;
|
|
75
|
+
|
|
76
|
+
// Callbacks (for controlled components)
|
|
77
|
+
onPageChange?: (page: number) => void;
|
|
78
|
+
onPageSizeChange?: (size: number) => void;
|
|
79
|
+
onSort?: (column: string, direction: 'asc' | 'desc') => void;
|
|
80
|
+
onFilter?: (filters: Record<string, FilterValue>) => void;
|
|
81
|
+
onSelectionChange?: (selected: string[]) => void;
|
|
82
|
+
onRowClick?: (row: T) => void;
|
|
83
|
+
onColumnResize?: (columnKey: string, width: number) => void;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const TableContext = createContext<TableContextValue<Record<string, unknown>> | undefined>(undefined);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Hook to access Table context
|
|
90
|
+
*
|
|
91
|
+
* @throws Error if used outside of Table component
|
|
92
|
+
*/
|
|
93
|
+
export function useTableContext<T extends Record<string, unknown> = Record<string, unknown>>(): TableContextValue<T> {
|
|
94
|
+
const context = useContext(TableContext);
|
|
95
|
+
|
|
96
|
+
if (context === undefined) {
|
|
97
|
+
throw new Error('useTableContext must be used within a Table component');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return context as unknown as TableContextValue<T>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Hook to access Table context (optional, returns undefined if not in Table)
|
|
105
|
+
*/
|
|
106
|
+
export function useTableContextOptional<T extends Record<string, unknown> = Record<string, unknown>>(): TableContextValue<T> | undefined {
|
|
107
|
+
const context = useContext(TableContext);
|
|
108
|
+
return context ? (context as unknown as TableContextValue<T>) : undefined;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { TableContext };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import { useTableContext } from './TableContext';
|
|
5
|
+
import { EmptyState } from '../../molecules';
|
|
6
|
+
|
|
7
|
+
export type TableEmptyStateProps = HTMLAttributes<HTMLDivElement>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* TableEmptyState Component
|
|
11
|
+
*
|
|
12
|
+
* Renders empty state when table has no data.
|
|
13
|
+
* Uses empty state configuration from Table context.
|
|
14
|
+
* Must be used within a Table component.
|
|
15
|
+
*/
|
|
16
|
+
export default function TableEmptyState({
|
|
17
|
+
className = '',
|
|
18
|
+
...props
|
|
19
|
+
}: TableEmptyStateProps) {
|
|
20
|
+
const {
|
|
21
|
+
emptyMessage,
|
|
22
|
+
emptyStateTitle,
|
|
23
|
+
emptyStateMessage,
|
|
24
|
+
emptyStateIllustration,
|
|
25
|
+
emptyStateAction,
|
|
26
|
+
} = useTableContext();
|
|
27
|
+
|
|
28
|
+
if (emptyStateTitle || emptyStateMessage || emptyStateIllustration) {
|
|
29
|
+
return (
|
|
30
|
+
<div className={className} {...props}>
|
|
31
|
+
<EmptyState
|
|
32
|
+
title={emptyStateTitle || "No data available"}
|
|
33
|
+
message={emptyStateMessage || emptyMessage || "No data available"}
|
|
34
|
+
variant={emptyStateIllustration ? "withIllustration" : "default"}
|
|
35
|
+
illustration={emptyStateIllustration}
|
|
36
|
+
/>
|
|
37
|
+
{emptyStateAction && (
|
|
38
|
+
<div className="mt-4 flex justify-center">
|
|
39
|
+
{emptyStateAction}
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<div className={`text-center text-gray-500 ${className}`} {...props}>
|
|
48
|
+
{emptyMessage || "No data available"}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import TableFilters from "./TableFilters";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof TableFilters> = {
|
|
6
|
+
title: "Organisms/Table/TableFilters",
|
|
7
|
+
component: TableFilters,
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: "Filter controls for tables with support for text, select, and date filters.",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Default: StoryObj<typeof TableFilters> = {
|
|
18
|
+
render: () => {
|
|
19
|
+
const [_filters, setFilters] = useState<Record<string, string>>({});
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<TableFilters
|
|
23
|
+
filters={[
|
|
24
|
+
{
|
|
25
|
+
key: 'status',
|
|
26
|
+
label: 'Status',
|
|
27
|
+
type: 'select',
|
|
28
|
+
options: [
|
|
29
|
+
{ value: 'ACTIVE', label: 'Active' },
|
|
30
|
+
{ value: 'DRAFT', label: 'Draft' },
|
|
31
|
+
{ value: 'COMPLETED', label: 'Completed' },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
key: 'priority',
|
|
36
|
+
label: 'Priority',
|
|
37
|
+
type: 'select',
|
|
38
|
+
options: [
|
|
39
|
+
{ value: 'HIGH', label: 'High' },
|
|
40
|
+
{ value: 'MEDIUM', label: 'Medium' },
|
|
41
|
+
{ value: 'LOW', label: 'Low' },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: 'search',
|
|
46
|
+
label: 'Search',
|
|
47
|
+
type: 'text',
|
|
48
|
+
placeholder: 'Search by name...',
|
|
49
|
+
},
|
|
50
|
+
]}
|
|
51
|
+
onFilter={(newFilters) => {
|
|
52
|
+
setFilters(newFilters);
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const WithInitialValues: StoryObj<typeof TableFilters> = {
|
|
60
|
+
render: () => {
|
|
61
|
+
const [_filters, setFilters] = useState<Record<string, unknown>>({});
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<TableFilters
|
|
65
|
+
filters={[
|
|
66
|
+
{
|
|
67
|
+
key: 'status',
|
|
68
|
+
label: 'Status',
|
|
69
|
+
type: 'select',
|
|
70
|
+
options: [
|
|
71
|
+
{ value: 'ACTIVE', label: 'Active' },
|
|
72
|
+
{ value: 'DRAFT', label: 'Draft' },
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
]}
|
|
76
|
+
onFilter={(newFilters) => {
|
|
77
|
+
setFilters(newFilters);
|
|
78
|
+
}}
|
|
79
|
+
initialValues={{ status: 'ACTIVE' }}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const WithDateFilter: StoryObj<typeof TableFilters> = {
|
|
86
|
+
render: () => {
|
|
87
|
+
const [_filters, setFilters] = useState<Record<string, string>>({});
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<TableFilters
|
|
91
|
+
filters={[
|
|
92
|
+
{
|
|
93
|
+
key: 'startDate',
|
|
94
|
+
label: 'Start Date',
|
|
95
|
+
type: 'date',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
key: 'endDate',
|
|
99
|
+
label: 'End Date',
|
|
100
|
+
type: 'date',
|
|
101
|
+
},
|
|
102
|
+
]}
|
|
103
|
+
onFilter={(newFilters) => {
|
|
104
|
+
setFilters(newFilters);
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export default meta;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
3
|
+
import TableFilters from './TableFilters';
|
|
4
|
+
|
|
5
|
+
describe('TableFilters', () => {
|
|
6
|
+
it('renders filter controls', () => {
|
|
7
|
+
const onFilter = vi.fn();
|
|
8
|
+
|
|
9
|
+
render(
|
|
10
|
+
<TableFilters
|
|
11
|
+
filters={[
|
|
12
|
+
{
|
|
13
|
+
key: 'status',
|
|
14
|
+
label: 'Status',
|
|
15
|
+
type: 'select',
|
|
16
|
+
options: [{ value: 'ACTIVE', label: 'Active' }],
|
|
17
|
+
},
|
|
18
|
+
]}
|
|
19
|
+
onFilter={onFilter}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expect(screen.getByText('Filters')).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('expands filters when clicked', () => {
|
|
27
|
+
const onFilter = vi.fn();
|
|
28
|
+
|
|
29
|
+
render(
|
|
30
|
+
<TableFilters
|
|
31
|
+
filters={[
|
|
32
|
+
{
|
|
33
|
+
key: 'status',
|
|
34
|
+
label: 'Status',
|
|
35
|
+
type: 'select',
|
|
36
|
+
options: [{ value: 'ACTIVE', label: 'Active' }],
|
|
37
|
+
},
|
|
38
|
+
]}
|
|
39
|
+
onFilter={onFilter}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const filterButton = screen.getByText('Filters');
|
|
44
|
+
fireEvent.click(filterButton);
|
|
45
|
+
|
|
46
|
+
expect(screen.getByLabelText('Status')).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('calls onFilter when filter value changes', () => {
|
|
50
|
+
const onFilter = vi.fn();
|
|
51
|
+
|
|
52
|
+
render(
|
|
53
|
+
<TableFilters
|
|
54
|
+
filters={[
|
|
55
|
+
{
|
|
56
|
+
key: 'status',
|
|
57
|
+
label: 'Status',
|
|
58
|
+
type: 'select',
|
|
59
|
+
options: [
|
|
60
|
+
{ value: '', label: 'All Status' },
|
|
61
|
+
{ value: 'ACTIVE', label: 'Active' },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
]}
|
|
65
|
+
onFilter={onFilter}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const filterButton = screen.getByText('Filters');
|
|
70
|
+
fireEvent.click(filterButton);
|
|
71
|
+
|
|
72
|
+
const select = screen.getByLabelText('Status');
|
|
73
|
+
fireEvent.change(select, { target: { value: 'ACTIVE' } });
|
|
74
|
+
|
|
75
|
+
expect(onFilter).toHaveBeenCalledWith({ status: 'ACTIVE' });
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('clears all filters when clear all is clicked', () => {
|
|
79
|
+
const onFilter = vi.fn();
|
|
80
|
+
|
|
81
|
+
render(
|
|
82
|
+
<TableFilters
|
|
83
|
+
filters={[
|
|
84
|
+
{
|
|
85
|
+
key: 'status',
|
|
86
|
+
label: 'Status',
|
|
87
|
+
type: 'select',
|
|
88
|
+
options: [{ value: 'ACTIVE', label: 'Active' }],
|
|
89
|
+
},
|
|
90
|
+
]}
|
|
91
|
+
onFilter={onFilter}
|
|
92
|
+
initialValues={{ status: 'ACTIVE' }}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const filterButton = screen.getByText('Filters');
|
|
97
|
+
fireEvent.click(filterButton);
|
|
98
|
+
|
|
99
|
+
const clearAllButton = screen.getByText('Clear all');
|
|
100
|
+
fireEvent.click(clearAllButton);
|
|
101
|
+
|
|
102
|
+
expect(onFilter).toHaveBeenCalledWith({ status: '' });
|
|
103
|
+
});
|
|
104
|
+
});
|