@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
|
@@ -1,63 +1,179 @@
|
|
|
1
|
-
import { describe, it, expect } from
|
|
2
|
-
import { render, screen } from
|
|
3
|
-
import Select from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
it(
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import Select from './Select';
|
|
4
|
+
|
|
5
|
+
const options = [
|
|
6
|
+
{ value: '1', label: 'Option 1' },
|
|
7
|
+
{ value: '2', label: 'Option 2' },
|
|
8
|
+
{ value: '3', label: 'Option 3' },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
describe('Select', () => {
|
|
12
|
+
it('renders select with options', () => {
|
|
13
13
|
render(<Select options={options} />);
|
|
14
|
-
|
|
15
|
-
expect(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
expect(screen.getByText('Option 1')).toBeInTheDocument();
|
|
15
|
+
expect(screen.getByText('Option 2')).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders with label', () => {
|
|
19
|
+
render(<Select label="Choose option" options={options} />);
|
|
20
|
+
expect(screen.getByText('Choose option')).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders placeholder', () => {
|
|
24
|
+
render(<Select placeholder="Select..." options={options} />);
|
|
25
|
+
expect(screen.getByText('Select...')).toBeInTheDocument();
|
|
19
26
|
});
|
|
20
27
|
|
|
21
|
-
it(
|
|
22
|
-
render(<Select options={options}
|
|
23
|
-
const
|
|
24
|
-
expect(
|
|
25
|
-
expect(
|
|
28
|
+
it('shows error state', () => {
|
|
29
|
+
const { container } = render(<Select error helperText="Error message" options={options} />);
|
|
30
|
+
const select = container.querySelector('select');
|
|
31
|
+
expect(select).toHaveAttribute('aria-invalid', 'true');
|
|
32
|
+
expect(screen.getByText('Error message')).toBeInTheDocument();
|
|
26
33
|
});
|
|
27
34
|
|
|
28
|
-
it(
|
|
29
|
-
render(<Select options={options}
|
|
30
|
-
|
|
31
|
-
expect(select).toHaveClass("border-red-500");
|
|
32
|
-
expect(select).toHaveAttribute("aria-invalid", "true");
|
|
35
|
+
it('shows success state', () => {
|
|
36
|
+
render(<Select success helperText="Valid" options={options} />);
|
|
37
|
+
expect(screen.getByText('Valid')).toBeInTheDocument();
|
|
33
38
|
});
|
|
34
39
|
|
|
35
|
-
it(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
it('renders option groups', () => {
|
|
41
|
+
const optionGroups = [
|
|
42
|
+
{
|
|
43
|
+
label: 'Group 1',
|
|
44
|
+
options: [
|
|
45
|
+
{ value: '1', label: 'Option 1' },
|
|
46
|
+
{ value: '2', label: 'Option 2' },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
const { container } = render(<Select optionGroups={optionGroups} />);
|
|
51
|
+
const optgroup = container.querySelector('optgroup[label="Group 1"]');
|
|
52
|
+
expect(optgroup).toBeInTheDocument();
|
|
53
|
+
expect(screen.getByText('Option 1')).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('applies size classes', () => {
|
|
57
|
+
const { container } = render(<Select size="sm" options={options} />);
|
|
58
|
+
const select = container.querySelector('select');
|
|
59
|
+
expect(select).toHaveClass('h-8', 'text-sm');
|
|
39
60
|
});
|
|
40
61
|
|
|
41
|
-
it(
|
|
62
|
+
it('disables options correctly', () => {
|
|
42
63
|
const optionsWithDisabled = [
|
|
43
|
-
{ value:
|
|
44
|
-
{ value:
|
|
64
|
+
{ value: '1', label: 'Option 1' },
|
|
65
|
+
{ value: '2', label: 'Option 2', disabled: true },
|
|
45
66
|
];
|
|
46
|
-
render(<Select options={optionsWithDisabled} />);
|
|
47
|
-
const
|
|
48
|
-
expect(
|
|
67
|
+
const { container } = render(<Select options={optionsWithDisabled} />);
|
|
68
|
+
const disabledOption = container.querySelector('option[value="2"]');
|
|
69
|
+
expect(disabledOption).toBeDisabled();
|
|
49
70
|
});
|
|
50
71
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
describe('Keyboard Navigation', () => {
|
|
73
|
+
it('is focusable', () => {
|
|
74
|
+
render(<Select options={options} />);
|
|
75
|
+
const select = screen.getByRole('combobox');
|
|
76
|
+
select.focus();
|
|
77
|
+
expect(document.activeElement).toBe(select);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('is not focusable when disabled', () => {
|
|
81
|
+
render(<Select disabled options={options} />);
|
|
82
|
+
const select = screen.getByRole('combobox');
|
|
83
|
+
expect(select).toBeDisabled();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('handles Arrow key navigation', () => {
|
|
87
|
+
const handleChange = vi.fn();
|
|
88
|
+
render(<Select options={options} onChange={handleChange} />);
|
|
89
|
+
const select = screen.getByRole('combobox');
|
|
90
|
+
select.focus();
|
|
91
|
+
fireEvent.keyDown(select, { key: 'ArrowDown' });
|
|
92
|
+
// Arrow keys should navigate options
|
|
93
|
+
expect(select).toBeInTheDocument();
|
|
94
|
+
});
|
|
55
95
|
});
|
|
56
96
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
97
|
+
describe('Accessibility', () => {
|
|
98
|
+
it('has correct role', () => {
|
|
99
|
+
render(<Select options={options} />);
|
|
100
|
+
const select = screen.getByRole('combobox');
|
|
101
|
+
expect(select).toBeInTheDocument();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('associates label with select', () => {
|
|
105
|
+
render(<Select label="Choose option" id="select" options={options} />);
|
|
106
|
+
const select = screen.getByLabelText('Choose option');
|
|
107
|
+
expect(select).toBeInTheDocument();
|
|
108
|
+
expect(select).toHaveAttribute('id', 'select');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('has aria-invalid when error', () => {
|
|
112
|
+
render(<Select error options={options} />);
|
|
113
|
+
const select = screen.getByRole('combobox');
|
|
114
|
+
expect(select).toHaveAttribute('aria-invalid', 'true');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('has aria-describedby when helperText is provided', () => {
|
|
118
|
+
render(<Select helperText="Helper text" id="test-select" options={options} />);
|
|
119
|
+
const select = screen.getByRole('combobox');
|
|
120
|
+
expect(select).toHaveAttribute('aria-describedby', 'test-select-helper');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('has aria-describedby for error message', () => {
|
|
124
|
+
render(<Select error helperText="Error message" id="test-select" options={options} />);
|
|
125
|
+
const select = screen.getByRole('combobox');
|
|
126
|
+
expect(select).toHaveAttribute('aria-describedby', 'test-select-error');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('has aria-required when required', () => {
|
|
130
|
+
render(<Select required options={options} />);
|
|
131
|
+
const select = screen.getByRole('combobox');
|
|
132
|
+
expect(select).toHaveAttribute('aria-required', 'true');
|
|
133
|
+
expect(select).toHaveAttribute('required');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('has aria-label when provided', () => {
|
|
137
|
+
render(<Select aria-label="Select option" options={options} />);
|
|
138
|
+
const select = screen.getByLabelText('Select option');
|
|
139
|
+
expect(select).toBeInTheDocument();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('has correct name attribute', () => {
|
|
143
|
+
render(<Select name="test-select" options={options} />);
|
|
144
|
+
const select = screen.getByRole('combobox');
|
|
145
|
+
expect(select).toHaveAttribute('name', 'test-select');
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe('Edge Cases', () => {
|
|
150
|
+
it('handles controlled select', () => {
|
|
151
|
+
const { rerender } = render(<Select value="1" options={options} onChange={vi.fn()} />);
|
|
152
|
+
const select = screen.getByRole('combobox') as HTMLSelectElement;
|
|
153
|
+
expect(select.value).toBe('1');
|
|
154
|
+
|
|
155
|
+
rerender(<Select value="2" options={options} onChange={vi.fn()} />);
|
|
156
|
+
expect(select.value).toBe('2');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('handles uncontrolled select', () => {
|
|
160
|
+
render(<Select defaultValue="1" options={options} />);
|
|
161
|
+
const select = screen.getByRole('combobox') as HTMLSelectElement;
|
|
162
|
+
expect(select.value).toBe('1');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('handles empty options array', () => {
|
|
166
|
+
render(<Select options={[]} />);
|
|
167
|
+
const select = screen.getByRole('combobox');
|
|
168
|
+
expect(select).toBeInTheDocument();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('handles onChange event', () => {
|
|
172
|
+
const handleChange = vi.fn();
|
|
173
|
+
render(<Select options={options} onChange={handleChange} />);
|
|
174
|
+
const select = screen.getByRole('combobox');
|
|
175
|
+
fireEvent.change(select, { target: { value: '2' } });
|
|
176
|
+
expect(handleChange).toHaveBeenCalled();
|
|
177
|
+
});
|
|
62
178
|
});
|
|
63
179
|
});
|
|
@@ -1,15 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import type { SelectHTMLAttributes, ReactNode } from 'react';
|
|
5
|
+
import { getTypographyClasses } from '../../tokens/typography';
|
|
6
|
+
import { getColorClass } from '../../tokens/colors';
|
|
7
|
+
|
|
8
|
+
export type SelectSize = 'sm' | 'md' | 'lg';
|
|
9
|
+
|
|
10
|
+
export interface SelectOption {
|
|
4
11
|
value: string;
|
|
5
12
|
label: string;
|
|
6
13
|
disabled?: boolean;
|
|
7
14
|
}
|
|
8
15
|
|
|
9
|
-
interface
|
|
10
|
-
|
|
16
|
+
export interface SelectOptionGroup {
|
|
17
|
+
label: string;
|
|
18
|
+
options: SelectOption[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'children' | 'size'> {
|
|
22
|
+
options: SelectOption[];
|
|
23
|
+
optionGroups?: SelectOptionGroup[];
|
|
11
24
|
placeholder?: string;
|
|
25
|
+
label?: ReactNode;
|
|
12
26
|
error?: boolean;
|
|
27
|
+
success?: boolean;
|
|
28
|
+
helperText?: string;
|
|
29
|
+
size?: SelectSize;
|
|
13
30
|
}
|
|
14
31
|
|
|
15
32
|
/**
|
|
@@ -17,10 +34,12 @@ interface Props extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "children"
|
|
|
17
34
|
*
|
|
18
35
|
* A styled select dropdown component for forms.
|
|
19
36
|
* Follows Atomic Design principles as an Atom component.
|
|
37
|
+
* Supports both flat options and option groups.
|
|
20
38
|
*
|
|
21
39
|
* @example
|
|
22
40
|
* ```tsx
|
|
23
41
|
* <Select
|
|
42
|
+
* label="Choose option"
|
|
24
43
|
* options={[
|
|
25
44
|
* { value: "1", label: "Option 1" },
|
|
26
45
|
* { value: "2", label: "Option 2" }
|
|
@@ -29,57 +48,136 @@ interface Props extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "children"
|
|
|
29
48
|
* />
|
|
30
49
|
* ```
|
|
31
50
|
*/
|
|
32
|
-
|
|
51
|
+
const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select({
|
|
33
52
|
options,
|
|
53
|
+
optionGroups,
|
|
34
54
|
placeholder,
|
|
55
|
+
label,
|
|
35
56
|
error = false,
|
|
36
|
-
|
|
57
|
+
success = false,
|
|
58
|
+
helperText,
|
|
59
|
+
size = 'md',
|
|
60
|
+
className = '',
|
|
61
|
+
disabled = false,
|
|
62
|
+
id,
|
|
37
63
|
...props
|
|
38
|
-
}
|
|
64
|
+
}, ref) {
|
|
65
|
+
const selectId = id || `select-${Math.random().toString(36).substr(2, 9)}`;
|
|
66
|
+
const errorId = error ? `${selectId}-error` : undefined;
|
|
67
|
+
const helperId = helperText ? `${selectId}-helper` : undefined;
|
|
68
|
+
|
|
69
|
+
// Size classes
|
|
70
|
+
const sizeClasses: Record<SelectSize, string> = {
|
|
71
|
+
sm: 'h-8 text-sm px-3',
|
|
72
|
+
md: 'h-10 text-base px-4',
|
|
73
|
+
lg: 'h-12 text-lg px-5',
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// State classes
|
|
77
|
+
const stateClasses = error
|
|
78
|
+
? 'border-red-500 focus:ring-red-500'
|
|
79
|
+
: success
|
|
80
|
+
? 'border-green-500 focus:ring-green-500'
|
|
81
|
+
: 'border-gray-300 focus:ring-indigo-500';
|
|
82
|
+
|
|
39
83
|
const baseClasses = [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
84
|
+
'block',
|
|
85
|
+
'w-full',
|
|
86
|
+
'rounded-md',
|
|
87
|
+
'border',
|
|
88
|
+
'bg-white',
|
|
89
|
+
'transition-colors',
|
|
90
|
+
'focus:outline-none',
|
|
91
|
+
'focus:ring-2',
|
|
92
|
+
'focus:ring-offset-2',
|
|
93
|
+
'disabled:opacity-50',
|
|
94
|
+
'disabled:cursor-not-allowed',
|
|
95
|
+
sizeClasses[size],
|
|
96
|
+
stateClasses,
|
|
50
97
|
];
|
|
51
98
|
|
|
52
|
-
const
|
|
53
|
-
? "border-red-500 focus:ring-red-500"
|
|
54
|
-
: "border-gray-300 focus:ring-indigo-500";
|
|
55
|
-
|
|
56
|
-
const classes = [
|
|
99
|
+
const selectClasses = [
|
|
57
100
|
...baseClasses,
|
|
58
|
-
errorClasses,
|
|
59
101
|
className,
|
|
60
|
-
].filter(Boolean).join(
|
|
102
|
+
].filter(Boolean).join(' ');
|
|
103
|
+
|
|
104
|
+
const labelClasses = [
|
|
105
|
+
'block',
|
|
106
|
+
getTypographyClasses('label'),
|
|
107
|
+
'mb-1',
|
|
108
|
+
disabled ? 'opacity-50' : '',
|
|
109
|
+
].filter(Boolean).join(' ');
|
|
61
110
|
|
|
62
111
|
return (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{placeholder}
|
|
72
|
-
</option>
|
|
112
|
+
<div className="w-full">
|
|
113
|
+
{label && (
|
|
114
|
+
<label
|
|
115
|
+
htmlFor={selectId}
|
|
116
|
+
className={labelClasses}
|
|
117
|
+
>
|
|
118
|
+
{label}
|
|
119
|
+
</label>
|
|
73
120
|
)}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
121
|
+
<select
|
|
122
|
+
id={selectId}
|
|
123
|
+
ref={ref}
|
|
124
|
+
className={selectClasses}
|
|
125
|
+
disabled={disabled}
|
|
126
|
+
aria-invalid={error}
|
|
127
|
+
aria-required={props.required}
|
|
128
|
+
aria-describedby={errorId || helperId}
|
|
129
|
+
{...props}
|
|
130
|
+
>
|
|
131
|
+
{placeholder && (
|
|
132
|
+
<option value="" disabled>
|
|
133
|
+
{placeholder}
|
|
134
|
+
</option>
|
|
135
|
+
)}
|
|
136
|
+
{optionGroups ? (
|
|
137
|
+
optionGroups.map((group, groupIndex) => (
|
|
138
|
+
<optgroup key={groupIndex} label={group.label}>
|
|
139
|
+
{group.options.map((option) => (
|
|
140
|
+
<option
|
|
141
|
+
key={option.value}
|
|
142
|
+
value={option.value}
|
|
143
|
+
disabled={option.disabled}
|
|
144
|
+
>
|
|
145
|
+
{option.label}
|
|
146
|
+
</option>
|
|
147
|
+
))}
|
|
148
|
+
</optgroup>
|
|
149
|
+
))
|
|
150
|
+
) : (
|
|
151
|
+
options.map((option) => (
|
|
152
|
+
<option
|
|
153
|
+
key={option.value}
|
|
154
|
+
value={option.value}
|
|
155
|
+
disabled={option.disabled}
|
|
156
|
+
>
|
|
157
|
+
{option.label}
|
|
158
|
+
</option>
|
|
159
|
+
))
|
|
160
|
+
)}
|
|
161
|
+
</select>
|
|
162
|
+
{(error || success || helperText) && (
|
|
163
|
+
<div
|
|
164
|
+
id={errorId || helperId}
|
|
165
|
+
className={`mt-1 ${getTypographyClasses('caption')} ${
|
|
166
|
+
error
|
|
167
|
+
? getColorClass('error', 'DEFAULT', 'text')
|
|
168
|
+
: success
|
|
169
|
+
? getColorClass('success', 'DEFAULT', 'text')
|
|
170
|
+
: 'text-gray-500'
|
|
171
|
+
}`}
|
|
172
|
+
role={error || success ? 'alert' : undefined}
|
|
79
173
|
>
|
|
80
|
-
{
|
|
81
|
-
</
|
|
82
|
-
)
|
|
83
|
-
</
|
|
174
|
+
{helperText || (error ? 'Error' : success ? 'Success' : '')}
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
177
|
+
</div>
|
|
84
178
|
);
|
|
85
|
-
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
Select.displayName = 'Select';
|
|
182
|
+
|
|
183
|
+
export default Select;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import Separator from './Separator';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Separator> = {
|
|
5
|
+
title: 'Atoms/Separator',
|
|
6
|
+
component: Separator,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
},
|
|
11
|
+
argTypes: {
|
|
12
|
+
orientation: {
|
|
13
|
+
control: 'select',
|
|
14
|
+
options: ['horizontal', 'vertical'],
|
|
15
|
+
},
|
|
16
|
+
variant: {
|
|
17
|
+
control: 'select',
|
|
18
|
+
options: ['solid', 'dashed', 'dotted'],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryObj<typeof Separator>;
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
args: {},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Horizontal: Story = {
|
|
31
|
+
render: () => (
|
|
32
|
+
<div className="w-64 space-y-4">
|
|
33
|
+
<p>Content above</p>
|
|
34
|
+
<Separator />
|
|
35
|
+
<p>Content below</p>
|
|
36
|
+
</div>
|
|
37
|
+
),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Vertical: Story = {
|
|
41
|
+
render: () => (
|
|
42
|
+
<div className="flex items-center gap-4 h-32">
|
|
43
|
+
<p>Left content</p>
|
|
44
|
+
<Separator orientation="vertical" />
|
|
45
|
+
<p>Right content</p>
|
|
46
|
+
</div>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Variants: Story = {
|
|
51
|
+
render: () => (
|
|
52
|
+
<div className="w-64 space-y-4">
|
|
53
|
+
<div>
|
|
54
|
+
<p className="mb-2">Solid</p>
|
|
55
|
+
<Separator variant="solid" />
|
|
56
|
+
</div>
|
|
57
|
+
<div>
|
|
58
|
+
<p className="mb-2">Dashed</p>
|
|
59
|
+
<Separator variant="dashed" />
|
|
60
|
+
</div>
|
|
61
|
+
<div>
|
|
62
|
+
<p className="mb-2">Dotted</p>
|
|
63
|
+
<Separator variant="dotted" />
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const InContext: Story = {
|
|
70
|
+
render: () => (
|
|
71
|
+
<div className="w-96 space-y-4 p-4">
|
|
72
|
+
<div>
|
|
73
|
+
<h3 className="text-lg font-semibold">Section 1</h3>
|
|
74
|
+
<p className="text-sm text-gray-600">Content for section 1</p>
|
|
75
|
+
</div>
|
|
76
|
+
<Separator />
|
|
77
|
+
<div>
|
|
78
|
+
<h3 className="text-lg font-semibold">Section 2</h3>
|
|
79
|
+
<p className="text-sm text-gray-600">Content for section 2</p>
|
|
80
|
+
</div>
|
|
81
|
+
<Separator variant="dashed" />
|
|
82
|
+
<div>
|
|
83
|
+
<h3 className="text-lg font-semibold">Section 3</h3>
|
|
84
|
+
<p className="text-sm text-gray-600">Content for section 3</p>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
),
|
|
88
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import Separator from './Separator';
|
|
4
|
+
|
|
5
|
+
describe('Separator', () => {
|
|
6
|
+
it('renders correctly', () => {
|
|
7
|
+
render(<Separator />);
|
|
8
|
+
const separator = screen.getByRole('separator');
|
|
9
|
+
expect(separator).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('renders horizontal separator by default', () => {
|
|
13
|
+
render(<Separator />);
|
|
14
|
+
const separator = screen.getByRole('separator');
|
|
15
|
+
expect(separator).toHaveAttribute('aria-orientation', 'horizontal');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders vertical separator', () => {
|
|
19
|
+
render(<Separator orientation="vertical" />);
|
|
20
|
+
const separator = screen.getByRole('separator');
|
|
21
|
+
expect(separator).toHaveAttribute('aria-orientation', 'vertical');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('handles different variants', () => {
|
|
25
|
+
const { rerender } = render(<Separator variant="solid" />);
|
|
26
|
+
expect(screen.getByRole('separator')).toBeInTheDocument();
|
|
27
|
+
|
|
28
|
+
rerender(<Separator variant="dashed" />);
|
|
29
|
+
expect(screen.getByRole('separator')).toBeInTheDocument();
|
|
30
|
+
|
|
31
|
+
rerender(<Separator variant="dotted" />);
|
|
32
|
+
expect(screen.getByRole('separator')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { memo, useMemo } from 'react';
|
|
4
|
+
import type { HTMLAttributes } from 'react';
|
|
5
|
+
import { getColorClass } from '../../tokens/colors';
|
|
6
|
+
|
|
7
|
+
export type SeparatorOrientation = 'horizontal' | 'vertical';
|
|
8
|
+
export type SeparatorVariant = 'solid' | 'dashed' | 'dotted';
|
|
9
|
+
|
|
10
|
+
export interface SeparatorProps extends HTMLAttributes<HTMLHRElement> {
|
|
11
|
+
orientation?: SeparatorOrientation;
|
|
12
|
+
variant?: SeparatorVariant;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Separator Component
|
|
17
|
+
*
|
|
18
|
+
* A visual separator component for dividing content.
|
|
19
|
+
* Follows Atomic Design principles as an Atom component.
|
|
20
|
+
* Optimized with React.memo to prevent unnecessary re-renders.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Separator />
|
|
25
|
+
*
|
|
26
|
+
* <Separator orientation="vertical" variant="dashed" />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const Separator = memo(function Separator({
|
|
30
|
+
orientation = 'horizontal',
|
|
31
|
+
variant = 'solid',
|
|
32
|
+
className = '',
|
|
33
|
+
...props
|
|
34
|
+
}: SeparatorProps) {
|
|
35
|
+
const baseClasses = [
|
|
36
|
+
'border-0',
|
|
37
|
+
getColorClass('neutral', 'DEFAULT', 'border'),
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const orientationClasses = {
|
|
41
|
+
horizontal: 'w-full border-t',
|
|
42
|
+
vertical: 'h-full border-l self-stretch',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const variantClasses = {
|
|
46
|
+
solid: 'border-solid',
|
|
47
|
+
dashed: 'border-dashed',
|
|
48
|
+
dotted: 'border-dotted',
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const classes = useMemo(() => [
|
|
52
|
+
...baseClasses,
|
|
53
|
+
orientationClasses[orientation],
|
|
54
|
+
variantClasses[variant],
|
|
55
|
+
className,
|
|
56
|
+
].filter(Boolean).join(' '), [orientation, variant, className]);
|
|
57
|
+
|
|
58
|
+
if (orientation === 'vertical') {
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
className={classes}
|
|
62
|
+
role="separator"
|
|
63
|
+
aria-orientation="vertical"
|
|
64
|
+
{...(props as HTMLAttributes<HTMLDivElement>)}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<hr
|
|
71
|
+
className={classes}
|
|
72
|
+
role="separator"
|
|
73
|
+
aria-orientation="horizontal"
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
Separator.displayName = 'Separator';
|
|
80
|
+
|
|
81
|
+
export default Separator;
|