@byldpartners/ui 0.0.1
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 +284 -0
- package/dist/chunk-464G63BO.cjs +224 -0
- package/dist/chunk-464G63BO.cjs.map +1 -0
- package/dist/chunk-JFJY6DZZ.js +224 -0
- package/dist/chunk-JFJY6DZZ.js.map +1 -0
- package/dist/index.cjs +3894 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1543 -0
- package/dist/index.d.ts +1543 -0
- package/dist/index.js +3894 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/web.cjs +16 -0
- package/dist/theme/web.cjs.map +1 -0
- package/dist/theme/web.d.cts +81 -0
- package/dist/theme/web.d.ts +81 -0
- package/dist/theme/web.js +16 -0
- package/dist/theme/web.js.map +1 -0
- package/package.json +117 -0
- package/src/components/Accordion/Accordion.native.tsx +195 -0
- package/src/components/Accordion/Accordion.stories.tsx +49 -0
- package/src/components/Accordion/Accordion.types.ts +28 -0
- package/src/components/Accordion/Accordion.web.tsx +61 -0
- package/src/components/Accordion/index.native.ts +12 -0
- package/src/components/Accordion/index.ts +12 -0
- package/src/components/Accordion/useAccordion.test.ts +114 -0
- package/src/components/Accordion/useAccordion.ts +65 -0
- package/src/components/Alert/Alert.native.tsx +86 -0
- package/src/components/Alert/Alert.stories.tsx +43 -0
- package/src/components/Alert/Alert.types.ts +17 -0
- package/src/components/Alert/Alert.web.test.tsx +49 -0
- package/src/components/Alert/Alert.web.tsx +59 -0
- package/src/components/Alert/index.native.ts +2 -0
- package/src/components/Alert/index.ts +2 -0
- package/src/components/Alert/useAlert.test.ts +19 -0
- package/src/components/Alert/useAlert.ts +10 -0
- package/src/components/AlertDialog/AlertDialog.native.tsx +281 -0
- package/src/components/AlertDialog/AlertDialog.stories.tsx +49 -0
- package/src/components/AlertDialog/AlertDialog.types.ts +49 -0
- package/src/components/AlertDialog/AlertDialog.web.tsx +138 -0
- package/src/components/AlertDialog/index.native.ts +22 -0
- package/src/components/AlertDialog/index.ts +24 -0
- package/src/components/AlertDialog/useAlertDialog.test.ts +40 -0
- package/src/components/AlertDialog/useAlertDialog.ts +36 -0
- package/src/components/AspectRatio/AspectRatio.native.tsx +37 -0
- package/src/components/AspectRatio/AspectRatio.stories.tsx +44 -0
- package/src/components/AspectRatio/AspectRatio.types.ts +5 -0
- package/src/components/AspectRatio/AspectRatio.web.tsx +5 -0
- package/src/components/AspectRatio/index.native.ts +2 -0
- package/src/components/AspectRatio/index.ts +2 -0
- package/src/components/AspectRatio/useAspectRatio.test.ts +40 -0
- package/src/components/AspectRatio/useAspectRatio.ts +12 -0
- package/src/components/Avatar/Avatar.native.tsx +95 -0
- package/src/components/Avatar/Avatar.stories.tsx +31 -0
- package/src/components/Avatar/Avatar.types.ts +17 -0
- package/src/components/Avatar/Avatar.web.tsx +47 -0
- package/src/components/Avatar/index.native.ts +2 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Avatar/useAvatarImage.test.ts +66 -0
- package/src/components/Avatar/useAvatarImage.ts +31 -0
- package/src/components/Badge/Badge.native.tsx +64 -0
- package/src/components/Badge/Badge.stories.tsx +42 -0
- package/src/components/Badge/Badge.types.ts +7 -0
- package/src/components/Badge/Badge.web.test.tsx +40 -0
- package/src/components/Badge/Badge.web.tsx +41 -0
- package/src/components/Badge/index.native.ts +2 -0
- package/src/components/Badge/index.ts +2 -0
- package/src/components/Breadcrumb/Breadcrumb.native.tsx +158 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +41 -0
- package/src/components/Breadcrumb/Breadcrumb.types.ts +37 -0
- package/src/components/Breadcrumb/Breadcrumb.web.tsx +125 -0
- package/src/components/Breadcrumb/index.native.ts +18 -0
- package/src/components/Breadcrumb/index.ts +18 -0
- package/src/components/Button/Button.native.tsx +118 -0
- package/src/components/Button/Button.stories.tsx +97 -0
- package/src/components/Button/Button.types.ts +19 -0
- package/src/components/Button/Button.web.test.tsx +69 -0
- package/src/components/Button/Button.web.tsx +55 -0
- package/src/components/Button/index.native.ts +2 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Calendar/Calendar.native.tsx +108 -0
- package/src/components/Calendar/Calendar.stories.tsx +18 -0
- package/src/components/Calendar/Calendar.types.ts +8 -0
- package/src/components/Calendar/Calendar.web.tsx +143 -0
- package/src/components/Calendar/index.native.ts +2 -0
- package/src/components/Calendar/index.ts +2 -0
- package/src/components/Calendar/useCalendar.test.ts +145 -0
- package/src/components/Calendar/useCalendar.ts +94 -0
- package/src/components/Card/Card.native.tsx +42 -0
- package/src/components/Card/Card.stories.tsx +41 -0
- package/src/components/Card/Card.types.ts +4 -0
- package/src/components/Card/Card.web.test.tsx +29 -0
- package/src/components/Card/Card.web.tsx +23 -0
- package/src/components/Card/index.native.ts +2 -0
- package/src/components/Card/index.ts +2 -0
- package/src/components/Carousel/Carousel.native.tsx +193 -0
- package/src/components/Carousel/Carousel.stories.tsx +51 -0
- package/src/components/Carousel/Carousel.types.ts +29 -0
- package/src/components/Carousel/Carousel.web.tsx +272 -0
- package/src/components/Carousel/index.native.ts +2 -0
- package/src/components/Carousel/index.ts +2 -0
- package/src/components/Carousel/useCarousel.test.ts +111 -0
- package/src/components/Carousel/useCarousel.ts +48 -0
- package/src/components/Chart/Chart.native.tsx +7 -0
- package/src/components/Chart/Chart.stories.tsx +57 -0
- package/src/components/Chart/Chart.types.ts +13 -0
- package/src/components/Chart/Chart.web.tsx +36 -0
- package/src/components/Chart/index.native.ts +2 -0
- package/src/components/Chart/index.ts +3 -0
- package/src/components/Checkbox/Checkbox.native.tsx +47 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +30 -0
- package/src/components/Checkbox/Checkbox.types.ts +12 -0
- package/src/components/Checkbox/Checkbox.web.tsx +37 -0
- package/src/components/Checkbox/index.native.ts +2 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Checkbox/useCheckbox.test.ts +66 -0
- package/src/components/Checkbox/useCheckbox.ts +37 -0
- package/src/components/Collapsible/Collapsible.native.tsx +111 -0
- package/src/components/Collapsible/Collapsible.stories.tsx +35 -0
- package/src/components/Collapsible/Collapsible.types.ts +19 -0
- package/src/components/Collapsible/Collapsible.web.tsx +9 -0
- package/src/components/Collapsible/index.native.ts +2 -0
- package/src/components/Collapsible/index.ts +2 -0
- package/src/components/Collapsible/useCollapsible.test.ts +53 -0
- package/src/components/Collapsible/useCollapsible.ts +38 -0
- package/src/components/Combobox/Combobox.native.tsx +146 -0
- package/src/components/Combobox/Combobox.stories.tsx +43 -0
- package/src/components/Combobox/Combobox.types.ts +15 -0
- package/src/components/Combobox/Combobox.web.tsx +145 -0
- package/src/components/Combobox/index.native.ts +2 -0
- package/src/components/Combobox/index.ts +2 -0
- package/src/components/Combobox/useCombobox.test.ts +59 -0
- package/src/components/Combobox/useCombobox.ts +42 -0
- package/src/components/Command/Command.native.tsx +7 -0
- package/src/components/Command/Command.stories.tsx +37 -0
- package/src/components/Command/Command.types.ts +43 -0
- package/src/components/Command/Command.web.tsx +134 -0
- package/src/components/Command/index.native.ts +2 -0
- package/src/components/Command/index.ts +18 -0
- package/src/components/ContextMenu/ContextMenu.native.tsx +241 -0
- package/src/components/ContextMenu/ContextMenu.stories.tsx +43 -0
- package/src/components/ContextMenu/ContextMenu.types.ts +69 -0
- package/src/components/ContextMenu/ContextMenu.web.tsx +220 -0
- package/src/components/ContextMenu/index.native.ts +28 -0
- package/src/components/ContextMenu/index.ts +2 -0
- package/src/components/ContextMenu/useContextMenu.test.ts +44 -0
- package/src/components/ContextMenu/useContextMenu.ts +36 -0
- package/src/components/DataTable/DataTable.native.tsx +85 -0
- package/src/components/DataTable/DataTable.stories.tsx +72 -0
- package/src/components/DataTable/DataTable.types.ts +16 -0
- package/src/components/DataTable/DataTable.web.tsx +135 -0
- package/src/components/DataTable/index.native.ts +2 -0
- package/src/components/DataTable/index.ts +3 -0
- package/src/components/DataTable/useDataTable.test.ts +98 -0
- package/src/components/DataTable/useDataTable.ts +68 -0
- package/src/components/DatePicker/DatePicker.native.tsx +82 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +68 -0
- package/src/components/DatePicker/DatePicker.types.ts +7 -0
- package/src/components/DatePicker/DatePicker.web.tsx +85 -0
- package/src/components/DatePicker/index.native.ts +2 -0
- package/src/components/DatePicker/index.ts +2 -0
- package/src/components/DatePicker/useDatePicker.test.ts +62 -0
- package/src/components/DatePicker/useDatePicker.ts +54 -0
- package/src/components/Dialog/Dialog.native.tsx +188 -0
- package/src/components/Dialog/Dialog.stories.tsx +42 -0
- package/src/components/Dialog/Dialog.types.ts +45 -0
- package/src/components/Dialog/Dialog.web.tsx +126 -0
- package/src/components/Dialog/index.native.ts +2 -0
- package/src/components/Dialog/index.ts +2 -0
- package/src/components/Dialog/useDialog.test.ts +44 -0
- package/src/components/Dialog/useDialog.ts +36 -0
- package/src/components/Drawer/Drawer.native.tsx +244 -0
- package/src/components/Drawer/Drawer.stories.tsx +39 -0
- package/src/components/Drawer/Drawer.types.ts +44 -0
- package/src/components/Drawer/Drawer.web.tsx +133 -0
- package/src/components/Drawer/index.native.ts +2 -0
- package/src/components/Drawer/index.ts +2 -0
- package/src/components/Drawer/useDrawer.test.ts +33 -0
- package/src/components/Drawer/useDrawer.ts +19 -0
- package/src/components/DropdownMenu/DropdownMenu.native.tsx +272 -0
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +36 -0
- package/src/components/DropdownMenu/DropdownMenu.types.ts +73 -0
- package/src/components/DropdownMenu/DropdownMenu.web.tsx +225 -0
- package/src/components/DropdownMenu/index.native.ts +2 -0
- package/src/components/DropdownMenu/index.ts +2 -0
- package/src/components/DropdownMenu/useDropdownMenu.test.ts +44 -0
- package/src/components/DropdownMenu/useDropdownMenu.ts +36 -0
- package/src/components/Form/Form.native.tsx +98 -0
- package/src/components/Form/Form.stories.tsx +83 -0
- package/src/components/Form/Form.types.ts +35 -0
- package/src/components/Form/Form.web.test.tsx +73 -0
- package/src/components/Form/Form.web.tsx +111 -0
- package/src/components/Form/index.native.ts +18 -0
- package/src/components/Form/index.ts +18 -0
- package/src/components/Form/useFormField.test.ts +25 -0
- package/src/components/Form/useFormField.ts +22 -0
- package/src/components/HoverCard/HoverCard.native.tsx +15 -0
- package/src/components/HoverCard/HoverCard.stories.tsx +34 -0
- package/src/components/HoverCard/HoverCard.types.ts +18 -0
- package/src/components/HoverCard/HoverCard.web.test.tsx +35 -0
- package/src/components/HoverCard/HoverCard.web.tsx +26 -0
- package/src/components/HoverCard/index.native.ts +2 -0
- package/src/components/HoverCard/index.ts +2 -0
- package/src/components/Icon/Icon.native.tsx +27 -0
- package/src/components/Icon/index.native.ts +2 -0
- package/src/components/Input/Input.native.tsx +32 -0
- package/src/components/Input/Input.stories.tsx +42 -0
- package/src/components/Input/Input.types.ts +10 -0
- package/src/components/Input/Input.web.test.tsx +39 -0
- package/src/components/Input/Input.web.tsx +21 -0
- package/src/components/Input/index.native.ts +2 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/InputOTP/InputOTP.native.tsx +93 -0
- package/src/components/InputOTP/InputOTP.stories.tsx +56 -0
- package/src/components/InputOTP/InputOTP.types.ts +14 -0
- package/src/components/InputOTP/InputOTP.web.tsx +128 -0
- package/src/components/InputOTP/index.native.ts +2 -0
- package/src/components/InputOTP/index.ts +2 -0
- package/src/components/InputOTP/useInputOTP.test.ts +97 -0
- package/src/components/InputOTP/useInputOTP.ts +69 -0
- package/src/components/Label/Label.native.tsx +25 -0
- package/src/components/Label/Label.stories.tsx +20 -0
- package/src/components/Label/Label.types.ts +6 -0
- package/src/components/Label/Label.web.test.tsx +27 -0
- package/src/components/Label/Label.web.tsx +23 -0
- package/src/components/Label/index.native.ts +2 -0
- package/src/components/Label/index.ts +2 -0
- package/src/components/Menubar/Menubar.native.tsx +287 -0
- package/src/components/Menubar/Menubar.stories.tsx +46 -0
- package/src/components/Menubar/Menubar.types.ts +70 -0
- package/src/components/Menubar/Menubar.web.tsx +256 -0
- package/src/components/Menubar/index.native.ts +28 -0
- package/src/components/Menubar/index.ts +2 -0
- package/src/components/Menubar/useMenubar.test.ts +35 -0
- package/src/components/Menubar/useMenubar.ts +19 -0
- package/src/components/NavigationMenu/NavigationMenu.native.tsx +128 -0
- package/src/components/NavigationMenu/NavigationMenu.stories.tsx +35 -0
- package/src/components/NavigationMenu/NavigationMenu.types.ts +35 -0
- package/src/components/NavigationMenu/NavigationMenu.web.test.tsx +56 -0
- package/src/components/NavigationMenu/NavigationMenu.web.tsx +134 -0
- package/src/components/NavigationMenu/index.native.ts +16 -0
- package/src/components/NavigationMenu/index.ts +2 -0
- package/src/components/Pagination/Pagination.native.tsx +192 -0
- package/src/components/Pagination/Pagination.stories.tsx +49 -0
- package/src/components/Pagination/Pagination.types.ts +41 -0
- package/src/components/Pagination/Pagination.web.test.tsx +101 -0
- package/src/components/Pagination/Pagination.web.tsx +185 -0
- package/src/components/Pagination/index.native.ts +19 -0
- package/src/components/Pagination/index.ts +2 -0
- package/src/components/Popover/Popover.native.tsx +97 -0
- package/src/components/Popover/Popover.stories.tsx +25 -0
- package/src/components/Popover/Popover.types.ts +20 -0
- package/src/components/Popover/Popover.web.tsx +30 -0
- package/src/components/Popover/index.native.ts +2 -0
- package/src/components/Popover/index.ts +2 -0
- package/src/components/Popover/usePopover.test.ts +40 -0
- package/src/components/Popover/usePopover.ts +36 -0
- package/src/components/Progress/Progress.native.tsx +65 -0
- package/src/components/Progress/Progress.stories.tsx +36 -0
- package/src/components/Progress/Progress.types.ts +6 -0
- package/src/components/Progress/Progress.web.test.tsx +27 -0
- package/src/components/Progress/Progress.web.tsx +30 -0
- package/src/components/Progress/index.native.ts +2 -0
- package/src/components/Progress/index.ts +2 -0
- package/src/components/Progress/useProgress.test.ts +44 -0
- package/src/components/Progress/useProgress.ts +11 -0
- package/src/components/RadioGroup/RadioGroup.native.tsx +96 -0
- package/src/components/RadioGroup/RadioGroup.stories.tsx +31 -0
- package/src/components/RadioGroup/RadioGroup.types.ts +16 -0
- package/src/components/RadioGroup/RadioGroup.web.tsx +47 -0
- package/src/components/RadioGroup/index.native.ts +2 -0
- package/src/components/RadioGroup/index.ts +2 -0
- package/src/components/RadioGroup/useRadioGroup.test.ts +50 -0
- package/src/components/RadioGroup/useRadioGroup.ts +40 -0
- package/src/components/ResizablePanel/ResizablePanel.native.tsx +75 -0
- package/src/components/ResizablePanel/ResizablePanel.stories.tsx +84 -0
- package/src/components/ResizablePanel/ResizablePanel.types.ts +20 -0
- package/src/components/ResizablePanel/ResizablePanel.web.test.tsx +52 -0
- package/src/components/ResizablePanel/ResizablePanel.web.tsx +77 -0
- package/src/components/ResizablePanel/index.native.ts +2 -0
- package/src/components/ResizablePanel/index.ts +2 -0
- package/src/components/ScrollArea/ScrollArea.native.tsx +43 -0
- package/src/components/ScrollArea/ScrollArea.stories.tsx +46 -0
- package/src/components/ScrollArea/ScrollArea.types.ts +11 -0
- package/src/components/ScrollArea/ScrollArea.web.test.tsx +19 -0
- package/src/components/ScrollArea/ScrollArea.web.tsx +45 -0
- package/src/components/ScrollArea/index.native.ts +2 -0
- package/src/components/ScrollArea/index.ts +2 -0
- package/src/components/Select/Select.native.tsx +203 -0
- package/src/components/Select/Select.stories.tsx +33 -0
- package/src/components/Select/Select.types.ts +14 -0
- package/src/components/Select/Select.web.tsx +204 -0
- package/src/components/Select/index.native.ts +11 -0
- package/src/components/Select/index.ts +2 -0
- package/src/components/Select/useSelect.test.ts +38 -0
- package/src/components/Select/useSelect.ts +33 -0
- package/src/components/Separator/Separator.native.tsx +38 -0
- package/src/components/Separator/Separator.stories.tsx +34 -0
- package/src/components/Separator/Separator.types.ts +7 -0
- package/src/components/Separator/Separator.web.test.tsx +32 -0
- package/src/components/Separator/Separator.web.tsx +38 -0
- package/src/components/Separator/index.native.ts +2 -0
- package/src/components/Separator/index.ts +2 -0
- package/src/components/Sheet/Sheet.native.tsx +246 -0
- package/src/components/Sheet/Sheet.stories.tsx +43 -0
- package/src/components/Sheet/Sheet.types.ts +47 -0
- package/src/components/Sheet/Sheet.web.tsx +144 -0
- package/src/components/Sheet/index.native.ts +2 -0
- package/src/components/Sheet/index.ts +2 -0
- package/src/components/Sheet/useSheet.test.ts +40 -0
- package/src/components/Sheet/useSheet.ts +19 -0
- package/src/components/Sidebar/Sidebar.native.tsx +7 -0
- package/src/components/Sidebar/Sidebar.stories.tsx +100 -0
- package/src/components/Sidebar/Sidebar.types.ts +30 -0
- package/src/components/Sidebar/Sidebar.web.test.tsx +74 -0
- package/src/components/Sidebar/Sidebar.web.tsx +200 -0
- package/src/components/Sidebar/index.native.ts +2 -0
- package/src/components/Sidebar/index.ts +2 -0
- package/src/components/Sidebar/useSidebar.test.ts +51 -0
- package/src/components/Sidebar/useSidebar.ts +26 -0
- package/src/components/Skeleton/Skeleton.native.tsx +45 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +32 -0
- package/src/components/Skeleton/Skeleton.types.ts +6 -0
- package/src/components/Skeleton/Skeleton.web.test.tsx +35 -0
- package/src/components/Skeleton/Skeleton.web.tsx +18 -0
- package/src/components/Skeleton/index.native.ts +2 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/Slider/Slider.native.tsx +98 -0
- package/src/components/Slider/Slider.stories.tsx +23 -0
- package/src/components/Slider/Slider.types.ts +10 -0
- package/src/components/Slider/Slider.web.tsx +25 -0
- package/src/components/Slider/index.native.ts +2 -0
- package/src/components/Slider/index.ts +2 -0
- package/src/components/Slider/useSlider.test.ts +68 -0
- package/src/components/Slider/useSlider.ts +55 -0
- package/src/components/Switch/Switch.native.tsx +36 -0
- package/src/components/Switch/Switch.stories.tsx +28 -0
- package/src/components/Switch/Switch.types.ts +7 -0
- package/src/components/Switch/Switch.web.test.tsx +44 -0
- package/src/components/Switch/Switch.web.tsx +26 -0
- package/src/components/Switch/index.native.ts +2 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/Table/Table.native.tsx +165 -0
- package/src/components/Table/Table.stories.tsx +54 -0
- package/src/components/Table/Table.types.ts +41 -0
- package/src/components/Table/Table.web.test.tsx +77 -0
- package/src/components/Table/Table.web.tsx +119 -0
- package/src/components/Table/index.native.ts +2 -0
- package/src/components/Table/index.ts +2 -0
- package/src/components/Tabs/Tabs.native.tsx +136 -0
- package/src/components/Tabs/Tabs.stories.tsx +35 -0
- package/src/components/Tabs/Tabs.types.ts +25 -0
- package/src/components/Tabs/Tabs.web.tsx +52 -0
- package/src/components/Tabs/index.native.ts +2 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Tabs/useTabs.test.ts +40 -0
- package/src/components/Tabs/useTabs.ts +20 -0
- package/src/components/Textarea/Textarea.native.tsx +33 -0
- package/src/components/Textarea/Textarea.stories.tsx +27 -0
- package/src/components/Textarea/Textarea.types.ts +10 -0
- package/src/components/Textarea/Textarea.web.test.tsx +33 -0
- package/src/components/Textarea/Textarea.web.tsx +21 -0
- package/src/components/Textarea/index.native.ts +2 -0
- package/src/components/Textarea/index.ts +2 -0
- package/src/components/Toast/Toast.native.tsx +267 -0
- package/src/components/Toast/Toast.stories.tsx +34 -0
- package/src/components/Toast/Toast.types.ts +50 -0
- package/src/components/Toast/Toast.web.tsx +282 -0
- package/src/components/Toast/index.native.ts +17 -0
- package/src/components/Toast/index.ts +11 -0
- package/src/components/Toast/useToast.test.ts +122 -0
- package/src/components/Toast/useToast.ts +64 -0
- package/src/components/Toggle/Toggle.native.tsx +70 -0
- package/src/components/Toggle/Toggle.stories.tsx +34 -0
- package/src/components/Toggle/Toggle.types.ts +13 -0
- package/src/components/Toggle/Toggle.web.tsx +42 -0
- package/src/components/Toggle/index.native.ts +2 -0
- package/src/components/Toggle/index.ts +2 -0
- package/src/components/Toggle/useToggle.test.ts +48 -0
- package/src/components/Toggle/useToggle.ts +37 -0
- package/src/components/ToggleGroup/ToggleGroup.native.tsx +103 -0
- package/src/components/ToggleGroup/ToggleGroup.stories.tsx +24 -0
- package/src/components/ToggleGroup/ToggleGroup.types.ts +22 -0
- package/src/components/ToggleGroup/ToggleGroup.web.tsx +56 -0
- package/src/components/ToggleGroup/index.native.ts +2 -0
- package/src/components/ToggleGroup/index.ts +2 -0
- package/src/components/ToggleGroup/useToggleGroup.test.ts +79 -0
- package/src/components/ToggleGroup/useToggleGroup.ts +63 -0
- package/src/components/Tooltip/Tooltip.native.tsx +7 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +32 -0
- package/src/components/Tooltip/Tooltip.types.ts +27 -0
- package/src/components/Tooltip/Tooltip.web.test.tsx +42 -0
- package/src/components/Tooltip/Tooltip.web.tsx +29 -0
- package/src/components/Tooltip/index.native.ts +2 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/index.native.ts +50 -0
- package/src/components/index.ts +49 -0
- package/src/hooks/useControllableState.test.ts +89 -0
- package/src/hooks/useControllableState.ts +37 -0
- package/src/index.native.ts +20 -0
- package/src/index.ts +12 -0
- package/src/theme/native.ts +211 -0
- package/src/theme/presets/aurora.ts +56 -0
- package/src/theme/presets/dark.ts +30 -0
- package/src/theme/presets/default.ts +30 -0
- package/src/theme/theme.types.ts +64 -0
- package/src/theme/tokens.ts +31 -0
- package/src/theme/web.ts +123 -0
- package/src/uniwind.d.ts +38 -0
- package/src/utils/cn.native.ts +10 -0
- package/src/utils/cn.test.ts +28 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/glass.native.ts +22 -0
- package/src/utils/withGlass.native.tsx +59 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Card } from "./Card.web";
|
|
4
|
+
|
|
5
|
+
describe("Card", () => {
|
|
6
|
+
it("renders children", () => {
|
|
7
|
+
render(<Card>Card content</Card>);
|
|
8
|
+
expect(screen.getByText("Card content")).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("applies base classes", () => {
|
|
12
|
+
render(<Card>content</Card>);
|
|
13
|
+
const el = screen.getByText("content");
|
|
14
|
+
expect(el.className).toContain("rounded-xl");
|
|
15
|
+
expect(el.className).toContain("border");
|
|
16
|
+
expect(el.className).toContain("bg-card");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("merges custom className", () => {
|
|
20
|
+
render(<Card className="my-card">content</Card>);
|
|
21
|
+
expect(screen.getByText("content").className).toContain("my-card");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("forwards ref", () => {
|
|
25
|
+
let ref: HTMLDivElement | null = null;
|
|
26
|
+
render(<Card ref={(el) => { ref = el; }}>content</Card>);
|
|
27
|
+
expect(ref).toBeInstanceOf(HTMLDivElement);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { cn } from "../../utils/cn";
|
|
3
|
+
import type { CardProps } from "./Card.types";
|
|
4
|
+
|
|
5
|
+
const Card = forwardRef<HTMLDivElement, CardProps & React.HTMLAttributes<HTMLDivElement>>(
|
|
6
|
+
({ className, children, ...props }, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
ref={ref}
|
|
10
|
+
className={cn(
|
|
11
|
+
"rounded-xl border border-border bg-card text-card-foreground shadow-sm",
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
{...props}
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
Card.displayName = "Card";
|
|
22
|
+
|
|
23
|
+
export { Card };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useRef,
|
|
3
|
+
createContext,
|
|
4
|
+
useContext,
|
|
5
|
+
useCallback,
|
|
6
|
+
Children,
|
|
7
|
+
} from "react";
|
|
8
|
+
import {
|
|
9
|
+
View,
|
|
10
|
+
ScrollView,
|
|
11
|
+
Pressable,
|
|
12
|
+
Text,
|
|
13
|
+
type LayoutChangeEvent,
|
|
14
|
+
type ViewProps,
|
|
15
|
+
} from "react-native";
|
|
16
|
+
import type { CarouselOrientation, CarouselProps, CarouselContentProps, CarouselItemProps, CarouselPreviousProps, CarouselNextProps } from "./Carousel.types";
|
|
17
|
+
import { cn } from "../../utils/cn";
|
|
18
|
+
import { useCarouselState } from "./useCarousel";
|
|
19
|
+
|
|
20
|
+
interface CarouselContextValue {
|
|
21
|
+
orientation: CarouselOrientation;
|
|
22
|
+
currentIndex: number;
|
|
23
|
+
totalItems: number;
|
|
24
|
+
scrollPrevious: () => void;
|
|
25
|
+
scrollNext: () => void;
|
|
26
|
+
canScrollPrevious: boolean;
|
|
27
|
+
canScrollNext: boolean;
|
|
28
|
+
scrollViewRef: React.RefObject<ScrollView | null>;
|
|
29
|
+
itemWidth: number;
|
|
30
|
+
setTotalItems: (count: number) => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const CarouselContext = createContext<CarouselContextValue | null>(null);
|
|
34
|
+
|
|
35
|
+
function useCarousel() {
|
|
36
|
+
const context = useContext(CarouselContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
39
|
+
}
|
|
40
|
+
return context;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface CarouselNativeProps extends CarouselProps, ViewProps {}
|
|
44
|
+
|
|
45
|
+
function Carousel({
|
|
46
|
+
orientation = "horizontal",
|
|
47
|
+
children,
|
|
48
|
+
onLayout,
|
|
49
|
+
...props
|
|
50
|
+
}: CarouselNativeProps) {
|
|
51
|
+
const carouselState = useCarouselState({ orientation });
|
|
52
|
+
const { setItemWidth, scrollPrevious: corePrev, scrollNext: coreNext } = carouselState;
|
|
53
|
+
const scrollViewRef = useRef<ScrollView | null>(null);
|
|
54
|
+
|
|
55
|
+
const handleLayout = useCallback(
|
|
56
|
+
(e: LayoutChangeEvent) => {
|
|
57
|
+
setItemWidth(e.nativeEvent.layout.width);
|
|
58
|
+
onLayout?.(e);
|
|
59
|
+
},
|
|
60
|
+
[onLayout, setItemWidth],
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const scrollPrevious = useCallback(() => {
|
|
64
|
+
const pos = corePrev();
|
|
65
|
+
scrollViewRef.current?.scrollTo({ x: pos.x, y: pos.y, animated: true });
|
|
66
|
+
}, [corePrev]);
|
|
67
|
+
|
|
68
|
+
const scrollNext = useCallback(() => {
|
|
69
|
+
const pos = coreNext();
|
|
70
|
+
scrollViewRef.current?.scrollTo({ x: pos.x, y: pos.y, animated: true });
|
|
71
|
+
}, [coreNext]);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<CarouselContext.Provider
|
|
75
|
+
value={{
|
|
76
|
+
orientation: carouselState.orientation,
|
|
77
|
+
currentIndex: carouselState.currentIndex,
|
|
78
|
+
totalItems: carouselState.totalItems,
|
|
79
|
+
scrollPrevious,
|
|
80
|
+
scrollNext,
|
|
81
|
+
canScrollPrevious: carouselState.canScrollPrevious,
|
|
82
|
+
canScrollNext: carouselState.canScrollNext,
|
|
83
|
+
scrollViewRef,
|
|
84
|
+
itemWidth: carouselState.itemWidth,
|
|
85
|
+
setTotalItems: carouselState.setTotalItems,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<View onLayout={handleLayout} {...props}>{children}</View>
|
|
89
|
+
</CarouselContext.Provider>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
Carousel.displayName = "Carousel";
|
|
93
|
+
|
|
94
|
+
interface CarouselContentNativeProps extends CarouselContentProps, ViewProps {}
|
|
95
|
+
|
|
96
|
+
function CarouselContent({ children, ...props }: CarouselContentNativeProps) {
|
|
97
|
+
const { orientation, scrollViewRef, itemWidth, setTotalItems } =
|
|
98
|
+
useCarousel();
|
|
99
|
+
const items = Children.toArray(children);
|
|
100
|
+
const countRef = useRef(0);
|
|
101
|
+
|
|
102
|
+
if (items.length !== countRef.current) {
|
|
103
|
+
countRef.current = items.length;
|
|
104
|
+
setTimeout(() => setTotalItems(items.length), 0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const isHorizontal = orientation === "horizontal";
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<ScrollView
|
|
111
|
+
ref={scrollViewRef}
|
|
112
|
+
horizontal={isHorizontal}
|
|
113
|
+
pagingEnabled
|
|
114
|
+
showsHorizontalScrollIndicator={false}
|
|
115
|
+
showsVerticalScrollIndicator={false}
|
|
116
|
+
decelerationRate="fast"
|
|
117
|
+
snapToInterval={itemWidth}
|
|
118
|
+
snapToAlignment="start"
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
</ScrollView>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
CarouselContent.displayName = "CarouselContent";
|
|
126
|
+
|
|
127
|
+
interface CarouselItemNativeProps extends CarouselItemProps, ViewProps {}
|
|
128
|
+
|
|
129
|
+
function CarouselItem({ children, style, ...props }: CarouselItemNativeProps) {
|
|
130
|
+
const { itemWidth } = useCarousel();
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<View style={{ width: itemWidth }} {...props}>
|
|
134
|
+
{children}
|
|
135
|
+
</View>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
CarouselItem.displayName = "CarouselItem";
|
|
139
|
+
|
|
140
|
+
interface CarouselButtonNativeProps extends CarouselPreviousProps, ViewProps {}
|
|
141
|
+
|
|
142
|
+
function CarouselPrevious({
|
|
143
|
+
children,
|
|
144
|
+
...props
|
|
145
|
+
}: CarouselButtonNativeProps) {
|
|
146
|
+
const { scrollPrevious, canScrollPrevious } = useCarousel();
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<Pressable
|
|
150
|
+
onPress={scrollPrevious}
|
|
151
|
+
disabled={!canScrollPrevious}
|
|
152
|
+
className={cn(
|
|
153
|
+
"items-center justify-center h-8 w-8 rounded-md border border-border bg-background shadow-sm elevation-1",
|
|
154
|
+
!canScrollPrevious && "opacity-50",
|
|
155
|
+
)}
|
|
156
|
+
{...props}
|
|
157
|
+
>
|
|
158
|
+
{children ?? <Text className="text-base text-foreground">{"\u2039"}</Text>}
|
|
159
|
+
</Pressable>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
CarouselPrevious.displayName = "CarouselPrevious";
|
|
163
|
+
|
|
164
|
+
function CarouselNext({
|
|
165
|
+
children,
|
|
166
|
+
...props
|
|
167
|
+
}: CarouselButtonNativeProps) {
|
|
168
|
+
const { scrollNext, canScrollNext } = useCarousel();
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<Pressable
|
|
172
|
+
onPress={scrollNext}
|
|
173
|
+
disabled={!canScrollNext}
|
|
174
|
+
className={cn(
|
|
175
|
+
"items-center justify-center h-8 w-8 rounded-md border border-border bg-background shadow-sm elevation-1",
|
|
176
|
+
!canScrollNext && "opacity-50",
|
|
177
|
+
)}
|
|
178
|
+
{...props}
|
|
179
|
+
>
|
|
180
|
+
{children ?? <Text className="text-base text-foreground">{"\u203A"}</Text>}
|
|
181
|
+
</Pressable>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
CarouselNext.displayName = "CarouselNext";
|
|
185
|
+
|
|
186
|
+
export {
|
|
187
|
+
Carousel,
|
|
188
|
+
CarouselContent,
|
|
189
|
+
CarouselItem,
|
|
190
|
+
CarouselPrevious,
|
|
191
|
+
CarouselNext,
|
|
192
|
+
};
|
|
193
|
+
export type { CarouselNativeProps, CarouselContentNativeProps, CarouselItemNativeProps, CarouselButtonNativeProps };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import {
|
|
3
|
+
Carousel,
|
|
4
|
+
CarouselContent,
|
|
5
|
+
CarouselItem,
|
|
6
|
+
CarouselPrevious,
|
|
7
|
+
CarouselNext,
|
|
8
|
+
} from "./Carousel.web";
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Carousel> = {
|
|
11
|
+
title: "Components/Carousel",
|
|
12
|
+
component: Carousel,
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "centered",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof Carousel>;
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
render: () => (
|
|
24
|
+
<div style={{ width: 400, padding: "0 40px" }}>
|
|
25
|
+
<Carousel>
|
|
26
|
+
<CarouselContent>
|
|
27
|
+
{[1, 2, 3, 4, 5].map((num) => (
|
|
28
|
+
<CarouselItem key={num}>
|
|
29
|
+
<div
|
|
30
|
+
style={{
|
|
31
|
+
display: "flex",
|
|
32
|
+
alignItems: "center",
|
|
33
|
+
justifyContent: "center",
|
|
34
|
+
height: 200,
|
|
35
|
+
border: "1px solid #e5e7eb",
|
|
36
|
+
borderRadius: 8,
|
|
37
|
+
fontSize: 32,
|
|
38
|
+
fontWeight: 600,
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
{num}
|
|
42
|
+
</div>
|
|
43
|
+
</CarouselItem>
|
|
44
|
+
))}
|
|
45
|
+
</CarouselContent>
|
|
46
|
+
<CarouselPrevious />
|
|
47
|
+
<CarouselNext />
|
|
48
|
+
</Carousel>
|
|
49
|
+
</div>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type CarouselOrientation = "horizontal" | "vertical";
|
|
2
|
+
|
|
3
|
+
export interface CarouselProps {
|
|
4
|
+
orientation?: CarouselOrientation;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface CarouselContentProps {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CarouselItemProps {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CarouselPreviousProps {
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
onPress?: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface CarouselNextProps {
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
className?: string;
|
|
28
|
+
onPress?: () => void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
createContext,
|
|
4
|
+
useContext,
|
|
5
|
+
useState,
|
|
6
|
+
useCallback,
|
|
7
|
+
Children,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { cva } from "class-variance-authority";
|
|
10
|
+
import { cn } from "../../utils/cn";
|
|
11
|
+
import type {
|
|
12
|
+
CarouselProps,
|
|
13
|
+
CarouselContentProps,
|
|
14
|
+
CarouselItemProps,
|
|
15
|
+
CarouselOrientation,
|
|
16
|
+
} from "./Carousel.types";
|
|
17
|
+
|
|
18
|
+
interface CarouselContextValue {
|
|
19
|
+
orientation: CarouselOrientation;
|
|
20
|
+
currentIndex: number;
|
|
21
|
+
totalItems: number;
|
|
22
|
+
scrollPrevious: () => void;
|
|
23
|
+
scrollNext: () => void;
|
|
24
|
+
canScrollPrevious: boolean;
|
|
25
|
+
canScrollNext: boolean;
|
|
26
|
+
setTotalItems: (count: number) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const CarouselContext = createContext<CarouselContextValue | null>(null);
|
|
30
|
+
|
|
31
|
+
function useCarousel() {
|
|
32
|
+
const context = useContext(CarouselContext);
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error("useCarousel must be used within a <Carousel />");
|
|
35
|
+
}
|
|
36
|
+
return context;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const carouselContentVariants = cva(
|
|
40
|
+
"flex transition-transform duration-300 ease-in-out",
|
|
41
|
+
{
|
|
42
|
+
variants: {
|
|
43
|
+
orientation: {
|
|
44
|
+
horizontal: "-ml-4",
|
|
45
|
+
vertical: "-mt-4 flex-col",
|
|
46
|
+
} satisfies Record<CarouselOrientation, string>,
|
|
47
|
+
},
|
|
48
|
+
defaultVariants: {
|
|
49
|
+
orientation: "horizontal",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const carouselItemVariants = cva("min-w-0 shrink-0 grow-0 basis-full", {
|
|
55
|
+
variants: {
|
|
56
|
+
orientation: {
|
|
57
|
+
horizontal: "pl-4",
|
|
58
|
+
vertical: "pt-4",
|
|
59
|
+
} satisfies Record<CarouselOrientation, string>,
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: {
|
|
62
|
+
orientation: "horizontal",
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const carouselPreviousVariants = cva(
|
|
67
|
+
"absolute inline-flex h-8 w-8 items-center justify-center rounded-full border border-input bg-background shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50",
|
|
68
|
+
{
|
|
69
|
+
variants: {
|
|
70
|
+
orientation: {
|
|
71
|
+
horizontal: "-left-12 top-1/2 -translate-y-1/2",
|
|
72
|
+
vertical: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
73
|
+
} satisfies Record<CarouselOrientation, string>,
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
orientation: "horizontal",
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const carouselNextVariants = cva(
|
|
82
|
+
"absolute inline-flex h-8 w-8 items-center justify-center rounded-full border border-input bg-background shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground disabled:pointer-events-none disabled:opacity-50",
|
|
83
|
+
{
|
|
84
|
+
variants: {
|
|
85
|
+
orientation: {
|
|
86
|
+
horizontal: "-right-12 top-1/2 -translate-y-1/2",
|
|
87
|
+
vertical: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
88
|
+
} satisfies Record<CarouselOrientation, string>,
|
|
89
|
+
},
|
|
90
|
+
defaultVariants: {
|
|
91
|
+
orientation: "horizontal",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const Carousel = forwardRef<
|
|
97
|
+
HTMLDivElement,
|
|
98
|
+
CarouselProps & React.HTMLAttributes<HTMLDivElement>
|
|
99
|
+
>(({ className, orientation = "horizontal", children, ...props }, ref) => {
|
|
100
|
+
const [currentIndex, setCurrentIndex] = useState(0);
|
|
101
|
+
const [totalItems, setTotalItems] = useState(0);
|
|
102
|
+
|
|
103
|
+
const canScrollPrevious = currentIndex > 0;
|
|
104
|
+
const canScrollNext = currentIndex < totalItems - 1;
|
|
105
|
+
|
|
106
|
+
const scrollPrevious = useCallback(() => {
|
|
107
|
+
setCurrentIndex((prev) => Math.max(0, prev - 1));
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
const scrollNext = useCallback(() => {
|
|
111
|
+
setCurrentIndex((prev) => Math.min(totalItems - 1, prev + 1));
|
|
112
|
+
}, [totalItems]);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<CarouselContext.Provider
|
|
116
|
+
value={{
|
|
117
|
+
orientation,
|
|
118
|
+
currentIndex,
|
|
119
|
+
totalItems,
|
|
120
|
+
scrollPrevious,
|
|
121
|
+
scrollNext,
|
|
122
|
+
canScrollPrevious,
|
|
123
|
+
canScrollNext,
|
|
124
|
+
setTotalItems,
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
<div
|
|
128
|
+
ref={ref}
|
|
129
|
+
role="region"
|
|
130
|
+
aria-roledescription="carousel"
|
|
131
|
+
className={cn("relative", className)}
|
|
132
|
+
{...props}
|
|
133
|
+
>
|
|
134
|
+
{children}
|
|
135
|
+
</div>
|
|
136
|
+
</CarouselContext.Provider>
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
Carousel.displayName = "Carousel";
|
|
140
|
+
|
|
141
|
+
const CarouselContent = forwardRef<
|
|
142
|
+
HTMLDivElement,
|
|
143
|
+
CarouselContentProps & React.HTMLAttributes<HTMLDivElement>
|
|
144
|
+
>(({ className, children, ...props }, ref) => {
|
|
145
|
+
const { orientation, currentIndex, setTotalItems } = useCarousel();
|
|
146
|
+
const items = Children.toArray(children);
|
|
147
|
+
|
|
148
|
+
// Update total items count
|
|
149
|
+
if (items.length !== 0) {
|
|
150
|
+
// Using a ref-like pattern to avoid re-render loops
|
|
151
|
+
queueMicrotask(() => setTotalItems(items.length));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<div className="overflow-hidden" ref={ref}>
|
|
156
|
+
<div
|
|
157
|
+
className={cn(carouselContentVariants({ orientation }), className)}
|
|
158
|
+
style={{
|
|
159
|
+
transform: orientation === "horizontal"
|
|
160
|
+
? `translateX(-${currentIndex * 100}%)`
|
|
161
|
+
: `translateY(-${currentIndex * 100}%)`,
|
|
162
|
+
}}
|
|
163
|
+
{...props}
|
|
164
|
+
>
|
|
165
|
+
{children}
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
CarouselContent.displayName = "CarouselContent";
|
|
171
|
+
|
|
172
|
+
const CarouselItem = forwardRef<
|
|
173
|
+
HTMLDivElement,
|
|
174
|
+
CarouselItemProps & React.HTMLAttributes<HTMLDivElement>
|
|
175
|
+
>(({ className, ...props }, ref) => {
|
|
176
|
+
const { orientation } = useCarousel();
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<div
|
|
180
|
+
ref={ref}
|
|
181
|
+
role="group"
|
|
182
|
+
aria-roledescription="slide"
|
|
183
|
+
className={cn(carouselItemVariants({ orientation }), className)}
|
|
184
|
+
{...props}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
});
|
|
188
|
+
CarouselItem.displayName = "CarouselItem";
|
|
189
|
+
|
|
190
|
+
const CarouselPrevious = forwardRef<
|
|
191
|
+
HTMLButtonElement,
|
|
192
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
193
|
+
>(({ className, children, ...props }, ref) => {
|
|
194
|
+
const { orientation, scrollPrevious, canScrollPrevious } = useCarousel();
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<button
|
|
198
|
+
ref={ref}
|
|
199
|
+
className={cn(carouselPreviousVariants({ orientation }), className)}
|
|
200
|
+
disabled={!canScrollPrevious}
|
|
201
|
+
onClick={scrollPrevious}
|
|
202
|
+
aria-label="Previous slide"
|
|
203
|
+
{...props}
|
|
204
|
+
>
|
|
205
|
+
{children ?? (
|
|
206
|
+
<svg
|
|
207
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
208
|
+
width="16"
|
|
209
|
+
height="16"
|
|
210
|
+
viewBox="0 0 24 24"
|
|
211
|
+
fill="none"
|
|
212
|
+
stroke="currentColor"
|
|
213
|
+
strokeWidth="2"
|
|
214
|
+
strokeLinecap="round"
|
|
215
|
+
strokeLinejoin="round"
|
|
216
|
+
>
|
|
217
|
+
<path d="m15 18-6-6 6-6" />
|
|
218
|
+
</svg>
|
|
219
|
+
)}
|
|
220
|
+
<span className="sr-only">Previous slide</span>
|
|
221
|
+
</button>
|
|
222
|
+
);
|
|
223
|
+
});
|
|
224
|
+
CarouselPrevious.displayName = "CarouselPrevious";
|
|
225
|
+
|
|
226
|
+
const CarouselNext = forwardRef<
|
|
227
|
+
HTMLButtonElement,
|
|
228
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
229
|
+
>(({ className, children, ...props }, ref) => {
|
|
230
|
+
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<button
|
|
234
|
+
ref={ref}
|
|
235
|
+
className={cn(carouselNextVariants({ orientation }), className)}
|
|
236
|
+
disabled={!canScrollNext}
|
|
237
|
+
onClick={scrollNext}
|
|
238
|
+
aria-label="Next slide"
|
|
239
|
+
{...props}
|
|
240
|
+
>
|
|
241
|
+
{children ?? (
|
|
242
|
+
<svg
|
|
243
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
244
|
+
width="16"
|
|
245
|
+
height="16"
|
|
246
|
+
viewBox="0 0 24 24"
|
|
247
|
+
fill="none"
|
|
248
|
+
stroke="currentColor"
|
|
249
|
+
strokeWidth="2"
|
|
250
|
+
strokeLinecap="round"
|
|
251
|
+
strokeLinejoin="round"
|
|
252
|
+
>
|
|
253
|
+
<path d="m9 18 6-6-6-6" />
|
|
254
|
+
</svg>
|
|
255
|
+
)}
|
|
256
|
+
<span className="sr-only">Next slide</span>
|
|
257
|
+
</button>
|
|
258
|
+
);
|
|
259
|
+
});
|
|
260
|
+
CarouselNext.displayName = "CarouselNext";
|
|
261
|
+
|
|
262
|
+
export {
|
|
263
|
+
Carousel,
|
|
264
|
+
CarouselContent,
|
|
265
|
+
CarouselItem,
|
|
266
|
+
CarouselPrevious,
|
|
267
|
+
CarouselNext,
|
|
268
|
+
carouselContentVariants,
|
|
269
|
+
carouselItemVariants,
|
|
270
|
+
carouselPreviousVariants,
|
|
271
|
+
carouselNextVariants,
|
|
272
|
+
};
|