@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,46 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { ScrollArea } from "./ScrollArea.web";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof ScrollArea> = {
|
|
5
|
+
title: "Components/ScrollArea",
|
|
6
|
+
component: ScrollArea,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
parameters: { layout: "centered" },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof ScrollArea>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<ScrollArea style={{ height: 200, width: 300 }}>
|
|
17
|
+
<div style={{ padding: 16 }}>
|
|
18
|
+
<p>
|
|
19
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
|
|
20
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
|
|
21
|
+
minim veniam, quis nostrud exercitation ullamco laboris.
|
|
22
|
+
</p>
|
|
23
|
+
<p>
|
|
24
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
|
|
25
|
+
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
|
26
|
+
proident.
|
|
27
|
+
</p>
|
|
28
|
+
<p>
|
|
29
|
+
Sed ut perspiciatis unde omnis iste natus error sit voluptatem
|
|
30
|
+
accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae
|
|
31
|
+
ab illo inventore veritatis.
|
|
32
|
+
</p>
|
|
33
|
+
<p>
|
|
34
|
+
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut
|
|
35
|
+
fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem
|
|
36
|
+
sequi nesciunt.
|
|
37
|
+
</p>
|
|
38
|
+
<p>
|
|
39
|
+
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet,
|
|
40
|
+
consectetur, adipisci velit, sed quia non numquam eius modi tempora
|
|
41
|
+
incidunt ut labore et dolore magnam aliquam quaerat voluptatem.
|
|
42
|
+
</p>
|
|
43
|
+
</div>
|
|
44
|
+
</ScrollArea>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ScrollAreaProps {
|
|
2
|
+
children?: React.ReactNode;
|
|
3
|
+
className?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type ScrollBarOrientation = "vertical" | "horizontal";
|
|
7
|
+
|
|
8
|
+
export interface ScrollBarProps {
|
|
9
|
+
orientation?: ScrollBarOrientation;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { ScrollArea } from "./ScrollArea.web";
|
|
4
|
+
|
|
5
|
+
describe("ScrollArea", () => {
|
|
6
|
+
it("renders children", () => {
|
|
7
|
+
render(<ScrollArea>Scrollable content</ScrollArea>);
|
|
8
|
+
expect(screen.getByText("Scrollable content")).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("merges custom className", () => {
|
|
12
|
+
const { container } = render(
|
|
13
|
+
<ScrollArea className="h-48 w-96">Content</ScrollArea>,
|
|
14
|
+
);
|
|
15
|
+
const root = container.firstChild as HTMLElement;
|
|
16
|
+
expect(root.className).toContain("h-48");
|
|
17
|
+
expect(root.className).toContain("w-96");
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
const ScrollArea = forwardRef<
|
|
6
|
+
React.ComponentRef<typeof ScrollAreaPrimitive.Root>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
|
8
|
+
>(({ className, children, ...props }, ref) => (
|
|
9
|
+
<ScrollAreaPrimitive.Root
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn("relative overflow-hidden", className)}
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
|
15
|
+
{children}
|
|
16
|
+
</ScrollAreaPrimitive.Viewport>
|
|
17
|
+
<ScrollBar />
|
|
18
|
+
<ScrollAreaPrimitive.Corner />
|
|
19
|
+
</ScrollAreaPrimitive.Root>
|
|
20
|
+
));
|
|
21
|
+
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
22
|
+
|
|
23
|
+
const ScrollBar = forwardRef<
|
|
24
|
+
React.ComponentRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
|
25
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
26
|
+
>(({ className, orientation = "vertical", ...props }, ref) => (
|
|
27
|
+
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
28
|
+
ref={ref}
|
|
29
|
+
orientation={orientation}
|
|
30
|
+
className={cn(
|
|
31
|
+
"flex touch-none select-none transition-colors",
|
|
32
|
+
orientation === "vertical" &&
|
|
33
|
+
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
|
34
|
+
orientation === "horizontal" &&
|
|
35
|
+
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
>
|
|
40
|
+
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
|
41
|
+
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
42
|
+
));
|
|
43
|
+
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
44
|
+
|
|
45
|
+
export { ScrollArea, ScrollBar };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
Pressable,
|
|
6
|
+
Modal,
|
|
7
|
+
type ViewProps,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import { ChevronDown, Check } from "lucide-react-native";
|
|
10
|
+
import type { SelectProps } from "./Select.types";
|
|
11
|
+
import { useSelect } from "./useSelect";
|
|
12
|
+
import { Icon } from "../Icon/Icon.native";
|
|
13
|
+
import { cn } from "../../utils/cn";
|
|
14
|
+
|
|
15
|
+
interface SelectContextValue {
|
|
16
|
+
value: string | undefined;
|
|
17
|
+
onValueChange: (value: string) => void;
|
|
18
|
+
open: boolean;
|
|
19
|
+
setOpen: (open: boolean) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const SelectContext = createContext<SelectContextValue>({
|
|
23
|
+
value: undefined,
|
|
24
|
+
onValueChange: () => {},
|
|
25
|
+
open: false,
|
|
26
|
+
setOpen: () => {},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
interface SelectNativeProps extends SelectProps {}
|
|
30
|
+
|
|
31
|
+
function Select({
|
|
32
|
+
value: controlledValue,
|
|
33
|
+
defaultValue,
|
|
34
|
+
onValueChange,
|
|
35
|
+
children,
|
|
36
|
+
}: SelectNativeProps) {
|
|
37
|
+
const { value, onValueChange: handleValueChange, open, setOpen } = useSelect({
|
|
38
|
+
value: controlledValue,
|
|
39
|
+
defaultValue,
|
|
40
|
+
onValueChange,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<SelectContext.Provider
|
|
45
|
+
value={{ value, onValueChange: handleValueChange, open, setOpen }}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</SelectContext.Provider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface SelectTriggerNativeProps extends ViewProps {
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function SelectTrigger({
|
|
58
|
+
children,
|
|
59
|
+
disabled = false,
|
|
60
|
+
style,
|
|
61
|
+
...props
|
|
62
|
+
}: SelectTriggerNativeProps) {
|
|
63
|
+
const { setOpen } = useContext(SelectContext);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Pressable
|
|
67
|
+
onPress={() => !disabled && setOpen(true)}
|
|
68
|
+
disabled={disabled}
|
|
69
|
+
className={cn(
|
|
70
|
+
"flex-row items-center justify-between h-9 w-full rounded-md border border-input px-3 py-2 bg-transparent shadow-sm elevation-1",
|
|
71
|
+
disabled && "opacity-50"
|
|
72
|
+
)}
|
|
73
|
+
style={style}
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
{children}
|
|
77
|
+
<View className="opacity-50">
|
|
78
|
+
<Icon icon={ChevronDown} size={16} className="text-muted-foreground" />
|
|
79
|
+
</View>
|
|
80
|
+
</Pressable>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface SelectValueNativeProps {
|
|
85
|
+
placeholder?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function SelectValue({ placeholder }: SelectValueNativeProps) {
|
|
89
|
+
const { value } = useContext(SelectContext);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Text
|
|
93
|
+
className={cn(
|
|
94
|
+
"text-sm leading-none flex-1",
|
|
95
|
+
value ? "text-foreground" : "text-muted-foreground"
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
{value || placeholder}
|
|
99
|
+
</Text>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
interface SelectContentNativeProps {
|
|
104
|
+
children?: React.ReactNode;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function SelectContent({ children }: SelectContentNativeProps) {
|
|
108
|
+
const { open, setOpen } = useContext(SelectContext);
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<Modal visible={open} transparent animationType="fade" onRequestClose={() => setOpen(false)}>
|
|
112
|
+
<Pressable
|
|
113
|
+
onPress={() => setOpen(false)}
|
|
114
|
+
className="flex-1 justify-center items-center"
|
|
115
|
+
style={{ backgroundColor: "rgba(0,0,0,0.5)" }}
|
|
116
|
+
>
|
|
117
|
+
<Pressable
|
|
118
|
+
onPress={(e) => e.stopPropagation()}
|
|
119
|
+
className="bg-popover rounded-lg p-1 min-w-[200px] max-h-[300px] shadow-md elevation-3"
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
</Pressable>
|
|
123
|
+
</Pressable>
|
|
124
|
+
</Modal>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface SelectItemNativeProps {
|
|
129
|
+
value: string;
|
|
130
|
+
disabled?: boolean;
|
|
131
|
+
children?: React.ReactNode;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function SelectItem({ value, disabled = false, children }: SelectItemNativeProps) {
|
|
135
|
+
const ctx = useContext(SelectContext);
|
|
136
|
+
const isSelected = ctx.value === value;
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<Pressable
|
|
140
|
+
onPress={() => !disabled && ctx.onValueChange(value)}
|
|
141
|
+
disabled={disabled}
|
|
142
|
+
className={cn(
|
|
143
|
+
"flex-row items-center py-1.5 pl-2 pr-8 rounded-sm",
|
|
144
|
+
isSelected ? "bg-secondary" : "bg-transparent",
|
|
145
|
+
disabled && "opacity-50"
|
|
146
|
+
)}
|
|
147
|
+
>
|
|
148
|
+
<Text className="text-sm text-foreground flex-1">
|
|
149
|
+
{children}
|
|
150
|
+
</Text>
|
|
151
|
+
{isSelected && (
|
|
152
|
+
<Icon icon={Check} size={16} className="text-foreground" />
|
|
153
|
+
)}
|
|
154
|
+
</Pressable>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface SelectGroupNativeProps extends ViewProps {
|
|
159
|
+
children?: React.ReactNode;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function SelectGroup({ children, ...props }: SelectGroupNativeProps) {
|
|
163
|
+
return <View {...props}>{children}</View>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface SelectLabelNativeProps {
|
|
167
|
+
children?: React.ReactNode;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function SelectLabel({ children }: SelectLabelNativeProps) {
|
|
171
|
+
return (
|
|
172
|
+
<Text className="text-sm font-semibold px-3 py-1.5 text-foreground">
|
|
173
|
+
{children}
|
|
174
|
+
</Text>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function SelectSeparator() {
|
|
179
|
+
return (
|
|
180
|
+
<View className="h-px bg-border my-1 -mx-1" />
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
Select.displayName = "Select";
|
|
185
|
+
SelectTrigger.displayName = "SelectTrigger";
|
|
186
|
+
SelectValue.displayName = "SelectValue";
|
|
187
|
+
SelectContent.displayName = "SelectContent";
|
|
188
|
+
SelectItem.displayName = "SelectItem";
|
|
189
|
+
SelectGroup.displayName = "SelectGroup";
|
|
190
|
+
SelectLabel.displayName = "SelectLabel";
|
|
191
|
+
SelectSeparator.displayName = "SelectSeparator";
|
|
192
|
+
|
|
193
|
+
export {
|
|
194
|
+
Select,
|
|
195
|
+
SelectTrigger,
|
|
196
|
+
SelectValue,
|
|
197
|
+
SelectContent,
|
|
198
|
+
SelectItem,
|
|
199
|
+
SelectGroup,
|
|
200
|
+
SelectLabel,
|
|
201
|
+
SelectSeparator,
|
|
202
|
+
};
|
|
203
|
+
export type { SelectNativeProps };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import {
|
|
3
|
+
Select,
|
|
4
|
+
SelectTrigger,
|
|
5
|
+
SelectValue,
|
|
6
|
+
SelectContent,
|
|
7
|
+
SelectItem,
|
|
8
|
+
} from "./Select.web";
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Select> = {
|
|
11
|
+
title: "Components/Select",
|
|
12
|
+
component: Select,
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
parameters: { layout: "centered" },
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof Select>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: () => (
|
|
22
|
+
<Select>
|
|
23
|
+
<SelectTrigger style={{ width: 180 }}>
|
|
24
|
+
<SelectValue placeholder="Select a fruit" />
|
|
25
|
+
</SelectTrigger>
|
|
26
|
+
<SelectContent>
|
|
27
|
+
<SelectItem value="apple">Apple</SelectItem>
|
|
28
|
+
<SelectItem value="banana">Banana</SelectItem>
|
|
29
|
+
<SelectItem value="orange">Orange</SelectItem>
|
|
30
|
+
</SelectContent>
|
|
31
|
+
</Select>
|
|
32
|
+
),
|
|
33
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SelectProps {
|
|
2
|
+
value?: string;
|
|
3
|
+
defaultValue?: string;
|
|
4
|
+
onValueChange?: (value: string) => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface SelectItemOption {
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
const Select = SelectPrimitive.Root;
|
|
6
|
+
|
|
7
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
8
|
+
|
|
9
|
+
const SelectValue = SelectPrimitive.Value;
|
|
10
|
+
|
|
11
|
+
const SelectTrigger = forwardRef<
|
|
12
|
+
React.ComponentRef<typeof SelectPrimitive.Trigger>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
14
|
+
>(({ className, children, ...props }, ref) => (
|
|
15
|
+
<SelectPrimitive.Trigger
|
|
16
|
+
ref={ref}
|
|
17
|
+
className={cn(
|
|
18
|
+
"flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
<SelectPrimitive.Icon asChild>
|
|
25
|
+
<svg
|
|
26
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
+
width="16"
|
|
28
|
+
height="16"
|
|
29
|
+
viewBox="0 0 24 24"
|
|
30
|
+
fill="none"
|
|
31
|
+
stroke="currentColor"
|
|
32
|
+
strokeWidth="2"
|
|
33
|
+
strokeLinecap="round"
|
|
34
|
+
strokeLinejoin="round"
|
|
35
|
+
className="h-4 w-4 opacity-50"
|
|
36
|
+
>
|
|
37
|
+
<path d="m6 9 6 6 6-6" />
|
|
38
|
+
</svg>
|
|
39
|
+
</SelectPrimitive.Icon>
|
|
40
|
+
</SelectPrimitive.Trigger>
|
|
41
|
+
));
|
|
42
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
43
|
+
|
|
44
|
+
const SelectScrollUpButton = forwardRef<
|
|
45
|
+
React.ComponentRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
46
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
|
|
47
|
+
>(({ className, ...props }, ref) => (
|
|
48
|
+
<SelectPrimitive.ScrollUpButton
|
|
49
|
+
ref={ref}
|
|
50
|
+
className={cn(
|
|
51
|
+
"flex cursor-default items-center justify-center py-1",
|
|
52
|
+
className,
|
|
53
|
+
)}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<svg
|
|
57
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
58
|
+
width="16"
|
|
59
|
+
height="16"
|
|
60
|
+
viewBox="0 0 24 24"
|
|
61
|
+
fill="none"
|
|
62
|
+
stroke="currentColor"
|
|
63
|
+
strokeWidth="2"
|
|
64
|
+
strokeLinecap="round"
|
|
65
|
+
strokeLinejoin="round"
|
|
66
|
+
className="h-4 w-4"
|
|
67
|
+
>
|
|
68
|
+
<path d="m18 15-6-6-6 6" />
|
|
69
|
+
</svg>
|
|
70
|
+
</SelectPrimitive.ScrollUpButton>
|
|
71
|
+
));
|
|
72
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
73
|
+
|
|
74
|
+
const SelectScrollDownButton = forwardRef<
|
|
75
|
+
React.ComponentRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
76
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
|
|
77
|
+
>(({ className, ...props }, ref) => (
|
|
78
|
+
<SelectPrimitive.ScrollDownButton
|
|
79
|
+
ref={ref}
|
|
80
|
+
className={cn(
|
|
81
|
+
"flex cursor-default items-center justify-center py-1",
|
|
82
|
+
className,
|
|
83
|
+
)}
|
|
84
|
+
{...props}
|
|
85
|
+
>
|
|
86
|
+
<svg
|
|
87
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
88
|
+
width="16"
|
|
89
|
+
height="16"
|
|
90
|
+
viewBox="0 0 24 24"
|
|
91
|
+
fill="none"
|
|
92
|
+
stroke="currentColor"
|
|
93
|
+
strokeWidth="2"
|
|
94
|
+
strokeLinecap="round"
|
|
95
|
+
strokeLinejoin="round"
|
|
96
|
+
className="h-4 w-4"
|
|
97
|
+
>
|
|
98
|
+
<path d="m6 9 6 6 6-6" />
|
|
99
|
+
</svg>
|
|
100
|
+
</SelectPrimitive.ScrollDownButton>
|
|
101
|
+
));
|
|
102
|
+
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
103
|
+
|
|
104
|
+
const SelectContent = forwardRef<
|
|
105
|
+
React.ComponentRef<typeof SelectPrimitive.Content>,
|
|
106
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
107
|
+
>(({ className, children, position = "popper", ...props }, ref) => (
|
|
108
|
+
<SelectPrimitive.Portal>
|
|
109
|
+
<SelectPrimitive.Content
|
|
110
|
+
ref={ref}
|
|
111
|
+
className={cn(
|
|
112
|
+
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
113
|
+
position === "popper" &&
|
|
114
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
115
|
+
className,
|
|
116
|
+
)}
|
|
117
|
+
position={position}
|
|
118
|
+
{...props}
|
|
119
|
+
>
|
|
120
|
+
<SelectScrollUpButton />
|
|
121
|
+
<SelectPrimitive.Viewport
|
|
122
|
+
className={cn(
|
|
123
|
+
"p-1",
|
|
124
|
+
position === "popper" &&
|
|
125
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
|
|
126
|
+
)}
|
|
127
|
+
>
|
|
128
|
+
{children}
|
|
129
|
+
</SelectPrimitive.Viewport>
|
|
130
|
+
<SelectScrollDownButton />
|
|
131
|
+
</SelectPrimitive.Content>
|
|
132
|
+
</SelectPrimitive.Portal>
|
|
133
|
+
));
|
|
134
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
135
|
+
|
|
136
|
+
const SelectLabel = forwardRef<
|
|
137
|
+
React.ComponentRef<typeof SelectPrimitive.Label>,
|
|
138
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
139
|
+
>(({ className, ...props }, ref) => (
|
|
140
|
+
<SelectPrimitive.Label
|
|
141
|
+
ref={ref}
|
|
142
|
+
className={cn("px-2 py-1.5 text-sm font-semibold", className)}
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
));
|
|
146
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
147
|
+
|
|
148
|
+
const SelectItem = forwardRef<
|
|
149
|
+
React.ComponentRef<typeof SelectPrimitive.Item>,
|
|
150
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
151
|
+
>(({ className, children, ...props }, ref) => (
|
|
152
|
+
<SelectPrimitive.Item
|
|
153
|
+
ref={ref}
|
|
154
|
+
className={cn(
|
|
155
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
156
|
+
className,
|
|
157
|
+
)}
|
|
158
|
+
{...props}
|
|
159
|
+
>
|
|
160
|
+
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
161
|
+
<SelectPrimitive.ItemIndicator>
|
|
162
|
+
<svg
|
|
163
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
164
|
+
width="16"
|
|
165
|
+
height="16"
|
|
166
|
+
viewBox="0 0 24 24"
|
|
167
|
+
fill="none"
|
|
168
|
+
stroke="currentColor"
|
|
169
|
+
strokeWidth="2"
|
|
170
|
+
strokeLinecap="round"
|
|
171
|
+
strokeLinejoin="round"
|
|
172
|
+
className="h-4 w-4"
|
|
173
|
+
>
|
|
174
|
+
<polyline points="20 6 9 17 4 12" />
|
|
175
|
+
</svg>
|
|
176
|
+
</SelectPrimitive.ItemIndicator>
|
|
177
|
+
</span>
|
|
178
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
179
|
+
</SelectPrimitive.Item>
|
|
180
|
+
));
|
|
181
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
182
|
+
|
|
183
|
+
const SelectSeparator = forwardRef<
|
|
184
|
+
React.ComponentRef<typeof SelectPrimitive.Separator>,
|
|
185
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
186
|
+
>(({ className, ...props }, ref) => (
|
|
187
|
+
<SelectPrimitive.Separator
|
|
188
|
+
ref={ref}
|
|
189
|
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
190
|
+
{...props}
|
|
191
|
+
/>
|
|
192
|
+
));
|
|
193
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
194
|
+
|
|
195
|
+
export {
|
|
196
|
+
Select,
|
|
197
|
+
SelectGroup,
|
|
198
|
+
SelectValue,
|
|
199
|
+
SelectTrigger,
|
|
200
|
+
SelectContent,
|
|
201
|
+
SelectLabel,
|
|
202
|
+
SelectItem,
|
|
203
|
+
SelectSeparator,
|
|
204
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import { useSelect } from "./useSelect";
|
|
4
|
+
|
|
5
|
+
describe("useSelect", () => {
|
|
6
|
+
it("defaults to empty string", () => {
|
|
7
|
+
const { result } = renderHook(() => useSelect({}));
|
|
8
|
+
expect(result.current.value).toBe("");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("uses defaultValue", () => {
|
|
12
|
+
const { result } = renderHook(() => useSelect({ defaultValue: "opt-1" }));
|
|
13
|
+
expect(result.current.value).toBe("opt-1");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("updates value via onValueChange", () => {
|
|
17
|
+
const { result } = renderHook(() => useSelect({}));
|
|
18
|
+
act(() => result.current.onValueChange("opt-2"));
|
|
19
|
+
expect(result.current.value).toBe("opt-2");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("closes dropdown after selecting a value", () => {
|
|
23
|
+
const { result } = renderHook(() => useSelect({}));
|
|
24
|
+
act(() => result.current.setOpen(true));
|
|
25
|
+
expect(result.current.open).toBe(true);
|
|
26
|
+
act(() => result.current.onValueChange("opt-1"));
|
|
27
|
+
expect(result.current.open).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("calls external onValueChange callback", () => {
|
|
31
|
+
const onChange = vi.fn();
|
|
32
|
+
const { result } = renderHook(() =>
|
|
33
|
+
useSelect({ onValueChange: onChange }),
|
|
34
|
+
);
|
|
35
|
+
act(() => result.current.onValueChange("opt-1"));
|
|
36
|
+
expect(onChange).toHaveBeenCalledWith("opt-1");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
3
|
+
|
|
4
|
+
interface UseSelectProps {
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useSelect({ value, defaultValue = "", onValueChange }: UseSelectProps) {
|
|
11
|
+
const [currentValue, setCurrentValue] = useControllableState<string>({
|
|
12
|
+
value,
|
|
13
|
+
defaultValue,
|
|
14
|
+
onChange: onValueChange,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const [open, setOpen] = useState(false);
|
|
18
|
+
|
|
19
|
+
const handleValueChange = useCallback(
|
|
20
|
+
(val: string) => {
|
|
21
|
+
setCurrentValue(val);
|
|
22
|
+
setOpen(false);
|
|
23
|
+
},
|
|
24
|
+
[setCurrentValue],
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
value: currentValue,
|
|
29
|
+
onValueChange: handleValueChange,
|
|
30
|
+
open,
|
|
31
|
+
setOpen,
|
|
32
|
+
};
|
|
33
|
+
}
|