@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,19 @@
|
|
|
1
|
+
export interface CollapsibleProps {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
defaultOpen?: boolean;
|
|
4
|
+
onOpenChange?: (open: boolean) => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CollapsibleTriggerProps {
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
asChild?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface CollapsibleContentProps {
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
2
|
+
|
|
3
|
+
const Collapsible = CollapsiblePrimitive.Root;
|
|
4
|
+
|
|
5
|
+
const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
6
|
+
|
|
7
|
+
const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
|
|
8
|
+
|
|
9
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import { useCollapsible } from "./useCollapsible";
|
|
4
|
+
|
|
5
|
+
describe("useCollapsible", () => {
|
|
6
|
+
it("defaults to closed", () => {
|
|
7
|
+
const { result } = renderHook(() => useCollapsible({}));
|
|
8
|
+
expect(result.current.open).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("uses defaultOpen", () => {
|
|
12
|
+
const { result } = renderHook(() => useCollapsible({ defaultOpen: true }));
|
|
13
|
+
expect(result.current.open).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("toggles open state", () => {
|
|
17
|
+
const { result } = renderHook(() => useCollapsible({}));
|
|
18
|
+
act(() => result.current.toggle());
|
|
19
|
+
expect(result.current.open).toBe(true);
|
|
20
|
+
act(() => result.current.toggle());
|
|
21
|
+
expect(result.current.open).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("sets open state directly", () => {
|
|
25
|
+
const { result } = renderHook(() => useCollapsible({}));
|
|
26
|
+
act(() => result.current.setOpen(true));
|
|
27
|
+
expect(result.current.open).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("calls onOpenChange", () => {
|
|
31
|
+
const onChange = vi.fn();
|
|
32
|
+
const { result } = renderHook(() =>
|
|
33
|
+
useCollapsible({ onOpenChange: onChange }),
|
|
34
|
+
);
|
|
35
|
+
act(() => result.current.toggle());
|
|
36
|
+
expect(onChange).toHaveBeenCalledWith(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("does not toggle when disabled", () => {
|
|
40
|
+
const { result } = renderHook(() =>
|
|
41
|
+
useCollapsible({ disabled: true }),
|
|
42
|
+
);
|
|
43
|
+
act(() => result.current.toggle());
|
|
44
|
+
expect(result.current.open).toBe(false);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("exposes disabled state", () => {
|
|
48
|
+
const { result } = renderHook(() =>
|
|
49
|
+
useCollapsible({ disabled: true }),
|
|
50
|
+
);
|
|
51
|
+
expect(result.current.disabled).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
3
|
+
|
|
4
|
+
interface UseCollapsibleProps {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
defaultOpen?: boolean;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface UseCollapsibleReturn {
|
|
12
|
+
open: boolean;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
setOpen: (open: boolean) => void;
|
|
15
|
+
toggle: () => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useCollapsible({
|
|
19
|
+
open: controlledOpen,
|
|
20
|
+
defaultOpen = false,
|
|
21
|
+
onOpenChange,
|
|
22
|
+
disabled = false,
|
|
23
|
+
}: UseCollapsibleProps): UseCollapsibleReturn {
|
|
24
|
+
const [open, setOpen] = useControllableState({
|
|
25
|
+
value: controlledOpen,
|
|
26
|
+
defaultValue: defaultOpen,
|
|
27
|
+
onChange: onOpenChange,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const toggle = useCallback(() => {
|
|
31
|
+
if (disabled) return;
|
|
32
|
+
setOpen((prev) => !prev);
|
|
33
|
+
}, [disabled, setOpen]);
|
|
34
|
+
|
|
35
|
+
return { open, disabled, setOpen, toggle };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type { UseCollapsibleProps, UseCollapsibleReturn };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
View,
|
|
3
|
+
Text,
|
|
4
|
+
TextInput,
|
|
5
|
+
Pressable,
|
|
6
|
+
FlatList,
|
|
7
|
+
Modal,
|
|
8
|
+
TouchableWithoutFeedback,
|
|
9
|
+
type ViewProps,
|
|
10
|
+
} from "react-native";
|
|
11
|
+
import { ChevronDown, Search, Check } from "lucide-react-native";
|
|
12
|
+
import type { ComboboxOption, ComboboxProps } from "./Combobox.types";
|
|
13
|
+
import { useCombobox } from "./useCombobox";
|
|
14
|
+
import { Icon } from "../Icon/Icon.native";
|
|
15
|
+
import { cn } from "../../utils/cn";
|
|
16
|
+
|
|
17
|
+
interface ComboboxNativeProps extends ComboboxProps, ViewProps {}
|
|
18
|
+
|
|
19
|
+
function Combobox({
|
|
20
|
+
options,
|
|
21
|
+
value,
|
|
22
|
+
onValueChange,
|
|
23
|
+
placeholder = "Select...",
|
|
24
|
+
searchPlaceholder = "Search...",
|
|
25
|
+
emptyMessage = "No results found.",
|
|
26
|
+
disabled = false,
|
|
27
|
+
...props
|
|
28
|
+
}: ComboboxNativeProps) {
|
|
29
|
+
const {
|
|
30
|
+
onValueChange: handleSelect,
|
|
31
|
+
open,
|
|
32
|
+
setOpen,
|
|
33
|
+
search,
|
|
34
|
+
setSearch,
|
|
35
|
+
filteredItems: filtered,
|
|
36
|
+
} = useCombobox<ComboboxOption>({
|
|
37
|
+
items: options,
|
|
38
|
+
value,
|
|
39
|
+
onValueChange,
|
|
40
|
+
filterFn: (item, search) =>
|
|
41
|
+
item.label.toLowerCase().includes(search.toLowerCase()),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<View {...props}>
|
|
48
|
+
<Pressable
|
|
49
|
+
onPress={() => !disabled && setOpen(true)}
|
|
50
|
+
disabled={disabled}
|
|
51
|
+
className={cn(
|
|
52
|
+
"flex-row items-center justify-between h-9 w-full rounded-md border border-input px-3 py-2 shadow-sm elevation-1",
|
|
53
|
+
disabled && "opacity-50",
|
|
54
|
+
)}
|
|
55
|
+
>
|
|
56
|
+
<Text
|
|
57
|
+
className={cn(
|
|
58
|
+
"text-sm leading-none flex-1",
|
|
59
|
+
selectedOption ? "text-foreground" : "text-muted-foreground",
|
|
60
|
+
)}
|
|
61
|
+
>
|
|
62
|
+
{selectedOption ? selectedOption.label : placeholder}
|
|
63
|
+
</Text>
|
|
64
|
+
<View className="ml-2 opacity-50">
|
|
65
|
+
<Icon icon={ChevronDown} size={16} className="text-muted-foreground" />
|
|
66
|
+
</View>
|
|
67
|
+
</Pressable>
|
|
68
|
+
|
|
69
|
+
<Modal
|
|
70
|
+
visible={open}
|
|
71
|
+
transparent
|
|
72
|
+
animationType="fade"
|
|
73
|
+
onRequestClose={() => setOpen(false)}
|
|
74
|
+
>
|
|
75
|
+
<TouchableWithoutFeedback onPress={() => setOpen(false)}>
|
|
76
|
+
<View className="flex-1 justify-center items-center bg-black/50">
|
|
77
|
+
<View
|
|
78
|
+
onStartShouldSetResponder={() => true}
|
|
79
|
+
className="bg-popover rounded-lg min-w-[250px] max-h-[400px] shadow-md elevation-3"
|
|
80
|
+
>
|
|
81
|
+
<View className="flex-row items-center border-b border-border px-3">
|
|
82
|
+
<View className="mr-3 opacity-50">
|
|
83
|
+
<Icon icon={Search} size={16} className="text-muted-foreground" />
|
|
84
|
+
</View>
|
|
85
|
+
<TextInput
|
|
86
|
+
value={search}
|
|
87
|
+
onChangeText={setSearch}
|
|
88
|
+
placeholder={searchPlaceholder}
|
|
89
|
+
placeholderTextColor="#a3a3a3"
|
|
90
|
+
className="flex-1 h-9 text-sm text-foreground leading-tight"
|
|
91
|
+
autoFocus
|
|
92
|
+
/>
|
|
93
|
+
</View>
|
|
94
|
+
{filtered.length === 0 ? (
|
|
95
|
+
<View className="p-6 items-center">
|
|
96
|
+
<Text className="text-sm text-muted-foreground">
|
|
97
|
+
{emptyMessage}
|
|
98
|
+
</Text>
|
|
99
|
+
</View>
|
|
100
|
+
) : (
|
|
101
|
+
<FlatList
|
|
102
|
+
data={filtered}
|
|
103
|
+
keyExtractor={(item: ComboboxOption) => item.value}
|
|
104
|
+
className="max-h-[300px] p-1"
|
|
105
|
+
renderItem={({ item }: { item: ComboboxOption }) => {
|
|
106
|
+
const isSelected = value === item.value;
|
|
107
|
+
return (
|
|
108
|
+
<Pressable
|
|
109
|
+
onPress={() => handleSelect(item.value)}
|
|
110
|
+
className={cn(
|
|
111
|
+
"flex-row items-center py-1.5 pl-2 pr-8 rounded-sm",
|
|
112
|
+
isSelected ? "bg-accent" : "bg-transparent",
|
|
113
|
+
)}
|
|
114
|
+
>
|
|
115
|
+
<Text
|
|
116
|
+
className={cn(
|
|
117
|
+
"text-sm flex-1",
|
|
118
|
+
isSelected
|
|
119
|
+
? "text-accent-foreground"
|
|
120
|
+
: "text-foreground",
|
|
121
|
+
)}
|
|
122
|
+
>
|
|
123
|
+
{item.label}
|
|
124
|
+
</Text>
|
|
125
|
+
{isSelected && (
|
|
126
|
+
<View className="absolute right-2">
|
|
127
|
+
<Icon icon={Check} size={16} className="text-foreground" />
|
|
128
|
+
</View>
|
|
129
|
+
)}
|
|
130
|
+
</Pressable>
|
|
131
|
+
);
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
)}
|
|
135
|
+
</View>
|
|
136
|
+
</View>
|
|
137
|
+
</TouchableWithoutFeedback>
|
|
138
|
+
</Modal>
|
|
139
|
+
</View>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
Combobox.displayName = "Combobox";
|
|
144
|
+
|
|
145
|
+
export { Combobox };
|
|
146
|
+
export type { ComboboxNativeProps };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Combobox } from "./Combobox.web";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Combobox> = {
|
|
6
|
+
title: "Components/Combobox",
|
|
7
|
+
component: Combobox,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: "centered",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
type Story = StoryObj<typeof Combobox>;
|
|
16
|
+
|
|
17
|
+
const frameworks = [
|
|
18
|
+
{ value: "react", label: "React" },
|
|
19
|
+
{ value: "vue", label: "Vue" },
|
|
20
|
+
{ value: "angular", label: "Angular" },
|
|
21
|
+
{ value: "svelte", label: "Svelte" },
|
|
22
|
+
{ value: "solid", label: "Solid" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const ComboboxDemo = () => {
|
|
26
|
+
const [value, setValue] = useState("");
|
|
27
|
+
return (
|
|
28
|
+
<div style={{ width: 250 }}>
|
|
29
|
+
<Combobox
|
|
30
|
+
options={frameworks}
|
|
31
|
+
value={value}
|
|
32
|
+
onValueChange={setValue}
|
|
33
|
+
placeholder="Select a framework..."
|
|
34
|
+
searchPlaceholder="Search frameworks..."
|
|
35
|
+
emptyMessage="No framework found."
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Default: Story = {
|
|
42
|
+
render: () => <ComboboxDemo />,
|
|
43
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ComboboxOption {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ComboboxProps {
|
|
7
|
+
options: ComboboxOption[];
|
|
8
|
+
value?: string;
|
|
9
|
+
onValueChange?: (value: string) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
searchPlaceholder?: string;
|
|
12
|
+
emptyMessage?: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { forwardRef, useState } from "react";
|
|
2
|
+
import * as Popover from "@radix-ui/react-popover";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
import type { ComboboxProps } from "./Combobox.types";
|
|
5
|
+
|
|
6
|
+
const Combobox = forwardRef<HTMLDivElement, ComboboxProps & React.HTMLAttributes<HTMLDivElement>>(
|
|
7
|
+
(
|
|
8
|
+
{
|
|
9
|
+
options,
|
|
10
|
+
value,
|
|
11
|
+
onValueChange,
|
|
12
|
+
placeholder = "Select...",
|
|
13
|
+
searchPlaceholder = "Search...",
|
|
14
|
+
emptyMessage = "No results found.",
|
|
15
|
+
disabled = false,
|
|
16
|
+
className,
|
|
17
|
+
...props
|
|
18
|
+
},
|
|
19
|
+
ref,
|
|
20
|
+
) => {
|
|
21
|
+
const [open, setOpen] = useState(false);
|
|
22
|
+
const [search, setSearch] = useState("");
|
|
23
|
+
|
|
24
|
+
const selectedOption = options.find((o) => o.value === value);
|
|
25
|
+
const filtered = options.filter((o) =>
|
|
26
|
+
o.label.toLowerCase().includes(search.toLowerCase()),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const handleSelect = (val: string) => {
|
|
30
|
+
onValueChange?.(val === value ? "" : val);
|
|
31
|
+
setOpen(false);
|
|
32
|
+
setSearch("");
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Popover.Root open={open} onOpenChange={setOpen}>
|
|
37
|
+
<Popover.Trigger asChild disabled={disabled}>
|
|
38
|
+
<button
|
|
39
|
+
type="button"
|
|
40
|
+
role="combobox"
|
|
41
|
+
aria-expanded={open}
|
|
42
|
+
className={cn(
|
|
43
|
+
"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 focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
>
|
|
47
|
+
<span className={cn(!selectedOption && "text-muted-foreground")}>
|
|
48
|
+
{selectedOption ? selectedOption.label : placeholder}
|
|
49
|
+
</span>
|
|
50
|
+
<svg
|
|
51
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
52
|
+
width="16"
|
|
53
|
+
height="16"
|
|
54
|
+
viewBox="0 0 24 24"
|
|
55
|
+
fill="none"
|
|
56
|
+
stroke="currentColor"
|
|
57
|
+
strokeWidth="2"
|
|
58
|
+
strokeLinecap="round"
|
|
59
|
+
strokeLinejoin="round"
|
|
60
|
+
className="ml-2 h-4 w-4 shrink-0 opacity-50"
|
|
61
|
+
>
|
|
62
|
+
<path d="m6 9 6 6 6-6" />
|
|
63
|
+
</svg>
|
|
64
|
+
</button>
|
|
65
|
+
</Popover.Trigger>
|
|
66
|
+
<Popover.Portal>
|
|
67
|
+
<Popover.Content
|
|
68
|
+
ref={ref}
|
|
69
|
+
className="z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95"
|
|
70
|
+
align="start"
|
|
71
|
+
sideOffset={4}
|
|
72
|
+
onCloseAutoFocus={(e) => e.preventDefault()}
|
|
73
|
+
{...props}
|
|
74
|
+
>
|
|
75
|
+
<div className="flex items-center border-b px-3">
|
|
76
|
+
<svg
|
|
77
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
78
|
+
width="16"
|
|
79
|
+
height="16"
|
|
80
|
+
viewBox="0 0 24 24"
|
|
81
|
+
fill="none"
|
|
82
|
+
stroke="currentColor"
|
|
83
|
+
strokeWidth="2"
|
|
84
|
+
strokeLinecap="round"
|
|
85
|
+
strokeLinejoin="round"
|
|
86
|
+
className="mr-2 h-4 w-4 shrink-0 opacity-50"
|
|
87
|
+
>
|
|
88
|
+
<circle cx="11" cy="11" r="8" />
|
|
89
|
+
<path d="m21 21-4.3-4.3" />
|
|
90
|
+
</svg>
|
|
91
|
+
<input
|
|
92
|
+
value={search}
|
|
93
|
+
onChange={(e) => setSearch(e.target.value)}
|
|
94
|
+
placeholder={searchPlaceholder}
|
|
95
|
+
className="flex h-9 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50"
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
<div className="max-h-[300px] overflow-y-auto p-1">
|
|
99
|
+
{filtered.length === 0 ? (
|
|
100
|
+
<div className="py-6 text-center text-sm text-muted-foreground">
|
|
101
|
+
{emptyMessage}
|
|
102
|
+
</div>
|
|
103
|
+
) : (
|
|
104
|
+
filtered.map((option) => (
|
|
105
|
+
<button
|
|
106
|
+
key={option.value}
|
|
107
|
+
type="button"
|
|
108
|
+
onClick={() => handleSelect(option.value)}
|
|
109
|
+
className={cn(
|
|
110
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none hover:bg-accent hover:text-accent-foreground",
|
|
111
|
+
value === option.value && "bg-accent",
|
|
112
|
+
)}
|
|
113
|
+
>
|
|
114
|
+
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
115
|
+
{value === option.value && (
|
|
116
|
+
<svg
|
|
117
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
118
|
+
width="16"
|
|
119
|
+
height="16"
|
|
120
|
+
viewBox="0 0 24 24"
|
|
121
|
+
fill="none"
|
|
122
|
+
stroke="currentColor"
|
|
123
|
+
strokeWidth="2"
|
|
124
|
+
strokeLinecap="round"
|
|
125
|
+
strokeLinejoin="round"
|
|
126
|
+
className="h-4 w-4"
|
|
127
|
+
>
|
|
128
|
+
<polyline points="20 6 9 17 4 12" />
|
|
129
|
+
</svg>
|
|
130
|
+
)}
|
|
131
|
+
</span>
|
|
132
|
+
{option.label}
|
|
133
|
+
</button>
|
|
134
|
+
))
|
|
135
|
+
)}
|
|
136
|
+
</div>
|
|
137
|
+
</Popover.Content>
|
|
138
|
+
</Popover.Portal>
|
|
139
|
+
</Popover.Root>
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
);
|
|
143
|
+
Combobox.displayName = "Combobox";
|
|
144
|
+
|
|
145
|
+
export { Combobox };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import { useCombobox } from "./useCombobox";
|
|
4
|
+
|
|
5
|
+
const items = [
|
|
6
|
+
{ value: "apple", label: "Apple" },
|
|
7
|
+
{ value: "banana", label: "Banana" },
|
|
8
|
+
{ value: "cherry", label: "Cherry" },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
describe("useCombobox", () => {
|
|
12
|
+
it("returns all items when no search", () => {
|
|
13
|
+
const { result } = renderHook(() =>
|
|
14
|
+
useCombobox({ items, filterFn: (item, search) => item.label.toLowerCase().includes(search.toLowerCase()) }),
|
|
15
|
+
);
|
|
16
|
+
expect(result.current.filteredItems).toEqual(items);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("filters items based on search", () => {
|
|
20
|
+
const { result } = renderHook(() =>
|
|
21
|
+
useCombobox({
|
|
22
|
+
items,
|
|
23
|
+
filterFn: (item, search) => item.label.toLowerCase().includes(search.toLowerCase()),
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
act(() => result.current.setSearch("ban"));
|
|
27
|
+
expect(result.current.filteredItems).toEqual([items[1]]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("starts closed", () => {
|
|
31
|
+
const { result } = renderHook(() => useCombobox({ items }));
|
|
32
|
+
expect(result.current.open).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("closes dropdown and clears search on value change", () => {
|
|
36
|
+
const onChange = vi.fn();
|
|
37
|
+
const { result } = renderHook(() =>
|
|
38
|
+
useCombobox({ items, onValueChange: onChange }),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
act(() => result.current.setOpen(true));
|
|
42
|
+
act(() => result.current.setSearch("test"));
|
|
43
|
+
act(() => result.current.onValueChange("apple"));
|
|
44
|
+
|
|
45
|
+
expect(result.current.open).toBe(false);
|
|
46
|
+
expect(result.current.search).toBe("");
|
|
47
|
+
expect(onChange).toHaveBeenCalledWith("apple");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("toggles value off when selecting same value", () => {
|
|
51
|
+
const onChange = vi.fn();
|
|
52
|
+
const { result } = renderHook(() =>
|
|
53
|
+
useCombobox({ items, value: "apple", onValueChange: onChange }),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
act(() => result.current.onValueChange("apple"));
|
|
57
|
+
expect(onChange).toHaveBeenCalledWith("");
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useState, useCallback, useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
interface UseComboboxProps<T> {
|
|
4
|
+
items: T[];
|
|
5
|
+
value?: string;
|
|
6
|
+
onValueChange?: (value: string) => void;
|
|
7
|
+
filterFn?: (item: T, search: string) => boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useCombobox<T>({
|
|
11
|
+
items,
|
|
12
|
+
value,
|
|
13
|
+
onValueChange,
|
|
14
|
+
filterFn,
|
|
15
|
+
}: UseComboboxProps<T>) {
|
|
16
|
+
const [open, setOpen] = useState(false);
|
|
17
|
+
const [search, setSearch] = useState("");
|
|
18
|
+
|
|
19
|
+
const filteredItems = useMemo(() => {
|
|
20
|
+
if (!search || !filterFn) return items;
|
|
21
|
+
return items.filter((item) => filterFn(item, search));
|
|
22
|
+
}, [items, search, filterFn]);
|
|
23
|
+
|
|
24
|
+
const handleValueChange = useCallback(
|
|
25
|
+
(val: string) => {
|
|
26
|
+
onValueChange?.(val === value ? "" : val);
|
|
27
|
+
setOpen(false);
|
|
28
|
+
setSearch("");
|
|
29
|
+
},
|
|
30
|
+
[value, onValueChange],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
value,
|
|
35
|
+
onValueChange: handleValueChange,
|
|
36
|
+
open,
|
|
37
|
+
setOpen,
|
|
38
|
+
search,
|
|
39
|
+
setSearch,
|
|
40
|
+
filteredItems,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import {
|
|
3
|
+
Command,
|
|
4
|
+
CommandInput,
|
|
5
|
+
CommandList,
|
|
6
|
+
CommandEmpty,
|
|
7
|
+
CommandGroup,
|
|
8
|
+
CommandItem,
|
|
9
|
+
} from "./Command.web";
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof Command> = {
|
|
12
|
+
title: "Components/Command",
|
|
13
|
+
component: Command,
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
parameters: {
|
|
16
|
+
layout: "centered",
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof Command>;
|
|
22
|
+
|
|
23
|
+
export const Default: Story = {
|
|
24
|
+
render: () => (
|
|
25
|
+
<Command style={{ width: 350, border: "1px solid #e5e7eb", borderRadius: 8 }}>
|
|
26
|
+
<CommandInput placeholder="Type a command or search..." />
|
|
27
|
+
<CommandList>
|
|
28
|
+
<CommandEmpty>No results found.</CommandEmpty>
|
|
29
|
+
<CommandGroup heading="Suggestions">
|
|
30
|
+
<CommandItem>Calendar</CommandItem>
|
|
31
|
+
<CommandItem>Search</CommandItem>
|
|
32
|
+
<CommandItem>Settings</CommandItem>
|
|
33
|
+
</CommandGroup>
|
|
34
|
+
</CommandList>
|
|
35
|
+
</Command>
|
|
36
|
+
),
|
|
37
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command is a web-heavy component (command palette / cmdk-style).
|
|
3
|
+
* The native implementation is a placeholder — this component is primarily designed for web.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface CommandProps {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface CommandInputProps {
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
value?: string;
|
|
14
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CommandListProps {
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface CommandEmptyProps {
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CommandGroupProps {
|
|
29
|
+
heading?: string;
|
|
30
|
+
children?: React.ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface CommandItemProps {
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
onSelect?: () => void;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface CommandSeparatorProps {
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|