@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,191 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { Input, Select, Label, Button } from '../../../atoms';
|
|
6
|
+
import { X, Filter } from 'lucide-react';
|
|
7
|
+
|
|
8
|
+
export type FilterType = 'text' | 'select' | 'date';
|
|
9
|
+
|
|
10
|
+
export interface FilterConfig {
|
|
11
|
+
key: string;
|
|
12
|
+
label: string;
|
|
13
|
+
type: FilterType;
|
|
14
|
+
options?: Array<{ value: string; label: string }>;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type FilterValue = string | number | boolean | null | undefined;
|
|
19
|
+
|
|
20
|
+
export interface TableFiltersProps extends HTMLAttributes<HTMLDivElement> {
|
|
21
|
+
filters: FilterConfig[];
|
|
22
|
+
onFilter: (filters: Record<string, FilterValue>) => void;
|
|
23
|
+
initialValues?: Record<string, FilterValue>;
|
|
24
|
+
showClearAll?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* TableFilters Component
|
|
29
|
+
*
|
|
30
|
+
* Filter controls for tables with support for text, select, and date filters.
|
|
31
|
+
* Follows Atomic Design principles as a Molecule component.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <TableFilters
|
|
36
|
+
* filters={[
|
|
37
|
+
* { key: 'status', label: 'Status', type: 'select', options: [...] },
|
|
38
|
+
* { key: 'search', label: 'Search', type: 'text', placeholder: 'Search...' }
|
|
39
|
+
* ]}
|
|
40
|
+
* onFilter={(filters) => handleFilter(filters)}
|
|
41
|
+
* />
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export default function TableFilters({
|
|
45
|
+
filters,
|
|
46
|
+
onFilter,
|
|
47
|
+
initialValues = {},
|
|
48
|
+
showClearAll = true,
|
|
49
|
+
className = '',
|
|
50
|
+
...props
|
|
51
|
+
}: TableFiltersProps) {
|
|
52
|
+
const [filterValues, setFilterValues] = useState<Record<string, FilterValue>>(initialValues);
|
|
53
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
54
|
+
|
|
55
|
+
const hasActiveFilters = Object.values(filterValues).some(
|
|
56
|
+
(value) => value !== '' && value !== null && value !== undefined
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const handleFilterChange = (key: string, value: FilterValue) => {
|
|
60
|
+
const newFilters = { ...filterValues, [key]: value };
|
|
61
|
+
setFilterValues(newFilters);
|
|
62
|
+
onFilter(newFilters);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const handleClearAll = () => {
|
|
66
|
+
const clearedFilters: Record<string, FilterValue> = {};
|
|
67
|
+
filters.forEach((filter) => {
|
|
68
|
+
clearedFilters[filter.key] = '';
|
|
69
|
+
});
|
|
70
|
+
setFilterValues(clearedFilters);
|
|
71
|
+
onFilter(clearedFilters);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleClearFilter = (key: string) => {
|
|
75
|
+
const newFilters = { ...filterValues, [key]: '' };
|
|
76
|
+
setFilterValues(newFilters);
|
|
77
|
+
onFilter(newFilters);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const activeFilterCount = Object.values(filterValues).filter(
|
|
81
|
+
(value) => value !== '' && value !== null && value !== undefined
|
|
82
|
+
).length;
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className={`bg-white border-b border-gray-200 ${className}`} {...props}>
|
|
86
|
+
<div className="px-4 py-3 sm:px-6">
|
|
87
|
+
<div className="flex items-center justify-between">
|
|
88
|
+
<button
|
|
89
|
+
type="button"
|
|
90
|
+
onClick={() => setIsExpanded(!isExpanded)}
|
|
91
|
+
className="flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-gray-900"
|
|
92
|
+
>
|
|
93
|
+
<Filter className="h-4 w-4" />
|
|
94
|
+
<span>Filters</span>
|
|
95
|
+
{activeFilterCount > 0 && (
|
|
96
|
+
<span className="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-indigo-100 text-indigo-800">
|
|
97
|
+
{activeFilterCount}
|
|
98
|
+
</span>
|
|
99
|
+
)}
|
|
100
|
+
</button>
|
|
101
|
+
|
|
102
|
+
{hasActiveFilters && showClearAll && (
|
|
103
|
+
<Button
|
|
104
|
+
variant="ghost"
|
|
105
|
+
size="sm"
|
|
106
|
+
onClick={handleClearAll}
|
|
107
|
+
className="text-sm"
|
|
108
|
+
>
|
|
109
|
+
Clear all
|
|
110
|
+
</Button>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
{isExpanded && (
|
|
115
|
+
<div className="mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
116
|
+
{filters.map((filter) => {
|
|
117
|
+
const value = filterValues[filter.key] || '';
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<div key={filter.key} className="space-y-1">
|
|
121
|
+
<Label htmlFor={`filter-${filter.key}`} variant="optional">
|
|
122
|
+
{filter.label}
|
|
123
|
+
</Label>
|
|
124
|
+
<div className="relative">
|
|
125
|
+
{filter.type === 'text' && (
|
|
126
|
+
<Input
|
|
127
|
+
id={`filter-${filter.key}`}
|
|
128
|
+
type="text"
|
|
129
|
+
value={value}
|
|
130
|
+
onChange={(e) => handleFilterChange(filter.key, e.target.value)}
|
|
131
|
+
placeholder={filter.placeholder || `Filter by ${filter.label.toLowerCase()}`}
|
|
132
|
+
size="sm"
|
|
133
|
+
variant="outlined"
|
|
134
|
+
/>
|
|
135
|
+
)}
|
|
136
|
+
|
|
137
|
+
{filter.type === 'select' && (
|
|
138
|
+
<div className="relative">
|
|
139
|
+
<Select
|
|
140
|
+
id={`filter-${filter.key}`}
|
|
141
|
+
options={[
|
|
142
|
+
{ value: '', label: `All ${filter.label}` },
|
|
143
|
+
...(filter.options || []),
|
|
144
|
+
]}
|
|
145
|
+
value={value}
|
|
146
|
+
onChange={(e) => handleFilterChange(filter.key, e.target.value)}
|
|
147
|
+
/>
|
|
148
|
+
{value && (
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
onClick={() => handleClearFilter(filter.key)}
|
|
152
|
+
className="absolute right-8 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"
|
|
153
|
+
aria-label={`Clear ${filter.label} filter`}
|
|
154
|
+
>
|
|
155
|
+
<X className="h-4 w-4" />
|
|
156
|
+
</button>
|
|
157
|
+
)}
|
|
158
|
+
</div>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
{filter.type === 'date' && (
|
|
162
|
+
<Input
|
|
163
|
+
id={`filter-${filter.key}`}
|
|
164
|
+
type="date"
|
|
165
|
+
value={value}
|
|
166
|
+
onChange={(e) => handleFilterChange(filter.key, e.target.value)}
|
|
167
|
+
size="sm"
|
|
168
|
+
variant="outlined"
|
|
169
|
+
/>
|
|
170
|
+
)}
|
|
171
|
+
|
|
172
|
+
{value && filter.type !== 'select' && (
|
|
173
|
+
<button
|
|
174
|
+
type="button"
|
|
175
|
+
onClick={() => handleClearFilter(filter.key)}
|
|
176
|
+
className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"
|
|
177
|
+
aria-label={`Clear ${filter.label} filter`}
|
|
178
|
+
>
|
|
179
|
+
<X className="h-4 w-4" />
|
|
180
|
+
</button>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
);
|
|
185
|
+
})}
|
|
186
|
+
</div>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import { useTableContext } from './TableContext';
|
|
5
|
+
import TableFiltersComponent from './TableFilters/TableFilters';
|
|
6
|
+
|
|
7
|
+
export interface TableFiltersProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
showClearAll?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* TableFilters Component
|
|
13
|
+
*
|
|
14
|
+
* Renders filter controls for the table.
|
|
15
|
+
* Uses filter configuration from Table context.
|
|
16
|
+
* Must be used within a Table component.
|
|
17
|
+
*/
|
|
18
|
+
export default function TableFilters({
|
|
19
|
+
showClearAll = true,
|
|
20
|
+
className = '',
|
|
21
|
+
...props
|
|
22
|
+
}: TableFiltersProps) {
|
|
23
|
+
const { filterState, setFilters } = useTableContext();
|
|
24
|
+
|
|
25
|
+
if (filterState.config.length === 0) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<TableFiltersComponent
|
|
31
|
+
filters={filterState.config}
|
|
32
|
+
onFilter={setFilters}
|
|
33
|
+
initialValues={filterState.values}
|
|
34
|
+
showClearAll={showClearAll}
|
|
35
|
+
className={className}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import { useTableContext } from './TableContext';
|
|
5
|
+
import TableHeaderRow from './TableHeaderRow';
|
|
6
|
+
|
|
7
|
+
export interface TableHeaderProps extends Omit<HTMLAttributes<HTMLTableSectionElement>, 'children'> {
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* TableHeader Component
|
|
13
|
+
*
|
|
14
|
+
* Renders the table header (thead) with columns.
|
|
15
|
+
* Must be used within a Table component.
|
|
16
|
+
*/
|
|
17
|
+
export default function TableHeader({
|
|
18
|
+
className = '',
|
|
19
|
+
...props
|
|
20
|
+
}: TableHeaderProps) {
|
|
21
|
+
useTableContext(); // Ensure we're within Table context
|
|
22
|
+
// columns is accessed via TableHeaderRow which uses useTableContext
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<thead className={`bg-gray-50 sticky top-0 z-10 ${className}`} {...props}>
|
|
26
|
+
<TableHeaderRow />
|
|
27
|
+
</thead>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useRef, type HTMLAttributes, type MouseEvent, type KeyboardEvent } from 'react';
|
|
4
|
+
import { useTableContext } from './TableContext';
|
|
5
|
+
import type { TableColumn } from './TableTypes';
|
|
6
|
+
|
|
7
|
+
export interface TableHeaderCellProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
8
|
+
column: TableColumn;
|
|
9
|
+
resizable?: boolean;
|
|
10
|
+
width?: number;
|
|
11
|
+
onResize?: (columnKey: string, width: number) => void;
|
|
12
|
+
minWidth?: number;
|
|
13
|
+
maxWidth?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* TableHeaderCell Component
|
|
18
|
+
*
|
|
19
|
+
* Renders a header cell (th) for a column.
|
|
20
|
+
* Supports sorting if column is sortable.
|
|
21
|
+
* Must be used within a Table component.
|
|
22
|
+
*/
|
|
23
|
+
export default function TableHeaderCell({
|
|
24
|
+
column,
|
|
25
|
+
resizable = false,
|
|
26
|
+
width,
|
|
27
|
+
onResize,
|
|
28
|
+
minWidth = 50,
|
|
29
|
+
maxWidth,
|
|
30
|
+
className = '',
|
|
31
|
+
...props
|
|
32
|
+
}: TableHeaderCellProps) {
|
|
33
|
+
const { sortState, setSorting, onSort } = useTableContext();
|
|
34
|
+
const resizeHandleRef = useRef<HTMLDivElement>(null);
|
|
35
|
+
const cellRef = useRef<HTMLTableCellElement>(null);
|
|
36
|
+
const resizeStartRef = useRef<{ x: number; width: number } | null>(null);
|
|
37
|
+
|
|
38
|
+
const handleSort = () => {
|
|
39
|
+
if (!column.sortable || (!onSort && !setSorting)) return;
|
|
40
|
+
|
|
41
|
+
const newDirection =
|
|
42
|
+
sortState.column === column.key && sortState.direction === 'asc' ? 'desc' : 'asc';
|
|
43
|
+
|
|
44
|
+
if (onSort) {
|
|
45
|
+
onSort(column.key, newDirection);
|
|
46
|
+
} else {
|
|
47
|
+
setSorting(column.key, newDirection);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleKeyDown = (e: KeyboardEvent<HTMLTableCellElement>) => {
|
|
52
|
+
if (!isSortable) return;
|
|
53
|
+
|
|
54
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
handleSort();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const handleResizeStart = (e: MouseEvent<HTMLDivElement>) => {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
|
|
64
|
+
if (!cellRef.current || !onResize) return;
|
|
65
|
+
|
|
66
|
+
const currentWidth = width || cellRef.current.offsetWidth;
|
|
67
|
+
resizeStartRef.current = {
|
|
68
|
+
x: e.clientX,
|
|
69
|
+
width: currentWidth,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const handleMouseMove = (moveEvent: MouseEvent) => {
|
|
73
|
+
if (!resizeStartRef.current) return;
|
|
74
|
+
|
|
75
|
+
const deltaX = moveEvent.clientX - resizeStartRef.current.x;
|
|
76
|
+
const newWidth = resizeStartRef.current.width + deltaX;
|
|
77
|
+
const clampedWidth = Math.max(minWidth, maxWidth ? Math.min(newWidth, maxWidth) : newWidth);
|
|
78
|
+
|
|
79
|
+
onResize(column.key, clampedWidth);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleMouseUp = () => {
|
|
83
|
+
document.removeEventListener('mousemove', handleMouseMove as unknown);
|
|
84
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
85
|
+
resizeStartRef.current = null;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
document.addEventListener('mousemove', handleMouseMove as unknown);
|
|
89
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const isSorted = sortState.column === column.key;
|
|
93
|
+
const isSortable = column.sortable && (onSort || setSorting);
|
|
94
|
+
const sortDirection = isSorted ? sortState.direction : undefined;
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<th
|
|
98
|
+
ref={cellRef}
|
|
99
|
+
scope="col"
|
|
100
|
+
role="columnheader"
|
|
101
|
+
aria-sort={
|
|
102
|
+
isSorted
|
|
103
|
+
? sortDirection === 'asc'
|
|
104
|
+
? 'ascending'
|
|
105
|
+
: 'descending'
|
|
106
|
+
: isSortable
|
|
107
|
+
? 'none'
|
|
108
|
+
: undefined
|
|
109
|
+
}
|
|
110
|
+
className={`px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider ${
|
|
111
|
+
isSortable
|
|
112
|
+
? 'cursor-pointer hover:bg-gray-100 focus:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 select-none'
|
|
113
|
+
: ''
|
|
114
|
+
} ${column.hiddenOnMobile ? 'hidden md:table-cell' : ''} ${className}`}
|
|
115
|
+
onClick={isSortable ? handleSort : undefined}
|
|
116
|
+
onKeyDown={isSortable ? handleKeyDown : undefined}
|
|
117
|
+
tabIndex={isSortable ? 0 : undefined}
|
|
118
|
+
style={width ? { width: `${width}px`, minWidth: `${width}px` } : undefined}
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
<div className="flex items-center gap-2 relative">
|
|
122
|
+
<span>{column.label}</span>
|
|
123
|
+
{isSorted && (
|
|
124
|
+
<span className="text-gray-400" aria-hidden="true">
|
|
125
|
+
{sortState.direction === 'asc' ? '↑' : '↓'}
|
|
126
|
+
</span>
|
|
127
|
+
)}
|
|
128
|
+
{resizable && onResize && (
|
|
129
|
+
<div
|
|
130
|
+
ref={resizeHandleRef}
|
|
131
|
+
className="absolute right-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-indigo-500 transition-colors"
|
|
132
|
+
onMouseDown={handleResizeStart}
|
|
133
|
+
role="separator"
|
|
134
|
+
aria-orientation="vertical"
|
|
135
|
+
aria-label={`Resize ${column.label} column`}
|
|
136
|
+
style={{ touchAction: 'none' }}
|
|
137
|
+
/>
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
</th>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { HTMLAttributes } from 'react';
|
|
4
|
+
import { useTableContext } from './TableContext';
|
|
5
|
+
import { Checkbox } from '../../atoms';
|
|
6
|
+
import TableHeaderCell from './TableHeaderCell';
|
|
7
|
+
|
|
8
|
+
export type TableHeaderRowProps = HTMLAttributes<HTMLTableRowElement>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* TableHeaderRow Component
|
|
12
|
+
*
|
|
13
|
+
* Renders a header row (tr) with header cells.
|
|
14
|
+
* Must be used within a Table component.
|
|
15
|
+
*/
|
|
16
|
+
export default function TableHeaderRow({
|
|
17
|
+
className = '',
|
|
18
|
+
...props
|
|
19
|
+
}: TableHeaderRowProps) {
|
|
20
|
+
const {
|
|
21
|
+
columns,
|
|
22
|
+
selectable,
|
|
23
|
+
selectionState,
|
|
24
|
+
toggleSelectAll,
|
|
25
|
+
actions,
|
|
26
|
+
resizable,
|
|
27
|
+
columnWidths,
|
|
28
|
+
setColumnWidth,
|
|
29
|
+
} = useTableContext();
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<tr role="row" className={className} {...props}>
|
|
33
|
+
{selectable && (
|
|
34
|
+
<th
|
|
35
|
+
scope="col"
|
|
36
|
+
role="columnheader"
|
|
37
|
+
className="px-6 py-3 w-12"
|
|
38
|
+
aria-label="Select all"
|
|
39
|
+
>
|
|
40
|
+
<Checkbox
|
|
41
|
+
checked={selectionState.isAllSelected}
|
|
42
|
+
onChange={toggleSelectAll}
|
|
43
|
+
aria-label="Select all rows"
|
|
44
|
+
className="my-0"
|
|
45
|
+
indeterminate={selectionState.isIndeterminate}
|
|
46
|
+
/>
|
|
47
|
+
</th>
|
|
48
|
+
)}
|
|
49
|
+
|
|
50
|
+
{columns.map((column) => (
|
|
51
|
+
<TableHeaderCell
|
|
52
|
+
key={column.key}
|
|
53
|
+
column={column}
|
|
54
|
+
resizable={resizable}
|
|
55
|
+
width={columnWidths?.[column.key]}
|
|
56
|
+
onResize={setColumnWidth}
|
|
57
|
+
/>
|
|
58
|
+
))}
|
|
59
|
+
|
|
60
|
+
{actions && (
|
|
61
|
+
<th
|
|
62
|
+
scope="col"
|
|
63
|
+
role="columnheader"
|
|
64
|
+
className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider w-12"
|
|
65
|
+
aria-label="Actions"
|
|
66
|
+
>
|
|
67
|
+
<span className="sr-only">Actions</span>
|
|
68
|
+
</th>
|
|
69
|
+
)}
|
|
70
|
+
</tr>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import TablePagination from "./TablePagination";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof TablePagination> = {
|
|
6
|
+
title: "Organisms/Table/TablePagination",
|
|
7
|
+
component: TablePagination,
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component: "Pagination controls for tables with page navigation and page size selection.",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Default: StoryObj<typeof TablePagination> = {
|
|
18
|
+
render: () => {
|
|
19
|
+
const [page, setPage] = useState(1);
|
|
20
|
+
const [pageSize, setPageSize] = useState(10);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<TablePagination
|
|
24
|
+
page={page}
|
|
25
|
+
pageSize={pageSize}
|
|
26
|
+
total={100}
|
|
27
|
+
onPageChange={setPage}
|
|
28
|
+
onPageSizeChange={setPageSize}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const WithoutPageSizeSelector: StoryObj<typeof TablePagination> = {
|
|
35
|
+
render: () => {
|
|
36
|
+
const [page, setPage] = useState(1);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<TablePagination
|
|
40
|
+
page={page}
|
|
41
|
+
pageSize={10}
|
|
42
|
+
total={100}
|
|
43
|
+
onPageChange={setPage}
|
|
44
|
+
onPageSizeChange={() => {}}
|
|
45
|
+
showPageSizeSelector={false}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const WithoutPageInfo: StoryObj<typeof TablePagination> = {
|
|
52
|
+
render: () => {
|
|
53
|
+
const [page, setPage] = useState(1);
|
|
54
|
+
const [pageSize, setPageSize] = useState(10);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<TablePagination
|
|
58
|
+
page={page}
|
|
59
|
+
pageSize={pageSize}
|
|
60
|
+
total={100}
|
|
61
|
+
onPageChange={setPage}
|
|
62
|
+
onPageSizeChange={setPageSize}
|
|
63
|
+
showPageInfo={false}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const LargeDataset: StoryObj<typeof TablePagination> = {
|
|
70
|
+
render: () => {
|
|
71
|
+
const [page, setPage] = useState(1);
|
|
72
|
+
const [pageSize, setPageSize] = useState(25);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<TablePagination
|
|
76
|
+
page={page}
|
|
77
|
+
pageSize={pageSize}
|
|
78
|
+
total={1250}
|
|
79
|
+
onPageChange={setPage}
|
|
80
|
+
onPageSizeChange={setPageSize}
|
|
81
|
+
pageSizeOptions={[10, 25, 50, 100, 250]}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default meta;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
3
|
+
import TablePagination from './TablePagination';
|
|
4
|
+
|
|
5
|
+
describe('TablePagination', () => {
|
|
6
|
+
it('renders pagination controls', () => {
|
|
7
|
+
const onPageChange = vi.fn();
|
|
8
|
+
const onPageSizeChange = vi.fn();
|
|
9
|
+
|
|
10
|
+
render(
|
|
11
|
+
<TablePagination
|
|
12
|
+
page={1}
|
|
13
|
+
pageSize={10}
|
|
14
|
+
total={100}
|
|
15
|
+
onPageChange={onPageChange}
|
|
16
|
+
onPageSizeChange={onPageSizeChange}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
// The "Showing" text is inside a Text component that may be split across elements
|
|
21
|
+
expect(screen.getByText(/Showing/i)).toBeInTheDocument();
|
|
22
|
+
// Check for key parts of the pagination info text - use more specific queries
|
|
23
|
+
const showingText = screen.getByText(/Showing/i);
|
|
24
|
+
const container = showingText.closest('div');
|
|
25
|
+
expect(container?.textContent).toContain('1'); // startItem
|
|
26
|
+
expect(container?.textContent).toContain('10'); // endItem
|
|
27
|
+
expect(container?.textContent).toContain('of');
|
|
28
|
+
expect(container?.textContent).toContain('results');
|
|
29
|
+
expect(container?.textContent).toContain('100'); // total
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('calls onPageChange when clicking next', () => {
|
|
33
|
+
const onPageChange = vi.fn();
|
|
34
|
+
const onPageSizeChange = vi.fn();
|
|
35
|
+
|
|
36
|
+
render(
|
|
37
|
+
<TablePagination
|
|
38
|
+
page={1}
|
|
39
|
+
pageSize={10}
|
|
40
|
+
total={100}
|
|
41
|
+
onPageChange={onPageChange}
|
|
42
|
+
onPageSizeChange={onPageSizeChange}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const nextButton = screen.getByLabelText('Next page');
|
|
47
|
+
fireEvent.click(nextButton);
|
|
48
|
+
|
|
49
|
+
expect(onPageChange).toHaveBeenCalledWith(2);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('disables previous button on first page', () => {
|
|
53
|
+
const onPageChange = vi.fn();
|
|
54
|
+
const onPageSizeChange = vi.fn();
|
|
55
|
+
|
|
56
|
+
render(
|
|
57
|
+
<TablePagination
|
|
58
|
+
page={1}
|
|
59
|
+
pageSize={10}
|
|
60
|
+
total={100}
|
|
61
|
+
onPageChange={onPageChange}
|
|
62
|
+
onPageSizeChange={onPageSizeChange}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const prevButton = screen.getByLabelText('Previous page');
|
|
67
|
+
expect(prevButton).toBeDisabled();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('calls onPageSizeChange when changing page size', () => {
|
|
71
|
+
const onPageChange = vi.fn();
|
|
72
|
+
const onPageSizeChange = vi.fn();
|
|
73
|
+
|
|
74
|
+
render(
|
|
75
|
+
<TablePagination
|
|
76
|
+
page={1}
|
|
77
|
+
pageSize={10}
|
|
78
|
+
total={100}
|
|
79
|
+
onPageChange={onPageChange}
|
|
80
|
+
onPageSizeChange={onPageSizeChange}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const select = screen.getByDisplayValue('10');
|
|
85
|
+
fireEvent.change(select, { target: { value: '25' } });
|
|
86
|
+
|
|
87
|
+
expect(onPageSizeChange).toHaveBeenCalledWith(25);
|
|
88
|
+
expect(onPageChange).toHaveBeenCalledWith(1);
|
|
89
|
+
});
|
|
90
|
+
});
|