@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,11 @@
|
|
|
1
|
+
interface UseProgressProps {
|
|
2
|
+
value?: number;
|
|
3
|
+
max?: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function useProgress({ value = 0, max = 100 }: UseProgressProps = {}) {
|
|
7
|
+
const clampedValue = Math.min(Math.max(value, 0), max);
|
|
8
|
+
const percentage = max > 0 ? clampedValue / max : 0;
|
|
9
|
+
|
|
10
|
+
return { clampedValue, percentage, max };
|
|
11
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Pressable,
|
|
5
|
+
type ViewProps,
|
|
6
|
+
type PressableProps,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
import type { RadioGroupProps, RadioGroupItemProps } from "./RadioGroup.types";
|
|
9
|
+
import { useRadioGroup } from "./useRadioGroup";
|
|
10
|
+
import { cn } from "../../utils/cn";
|
|
11
|
+
|
|
12
|
+
interface RadioGroupContextValue {
|
|
13
|
+
value: string;
|
|
14
|
+
onValueChange: (value: string) => void;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const RadioGroupContext = createContext<RadioGroupContextValue>({
|
|
19
|
+
value: "",
|
|
20
|
+
onValueChange: () => {},
|
|
21
|
+
disabled: false,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
interface RadioGroupNativeProps extends RadioGroupProps, ViewProps {}
|
|
25
|
+
|
|
26
|
+
function RadioGroup({
|
|
27
|
+
value: controlledValue,
|
|
28
|
+
defaultValue,
|
|
29
|
+
onValueChange,
|
|
30
|
+
disabled: disabledProp,
|
|
31
|
+
children,
|
|
32
|
+
style,
|
|
33
|
+
...props
|
|
34
|
+
}: RadioGroupNativeProps) {
|
|
35
|
+
const { value, disabled, selectValue } = useRadioGroup({
|
|
36
|
+
value: controlledValue,
|
|
37
|
+
defaultValue,
|
|
38
|
+
onValueChange,
|
|
39
|
+
disabled: disabledProp,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<RadioGroupContext.Provider
|
|
44
|
+
value={{ value, onValueChange: selectValue, disabled }}
|
|
45
|
+
>
|
|
46
|
+
<View className="gap-2" style={style} {...props}>
|
|
47
|
+
{children}
|
|
48
|
+
</View>
|
|
49
|
+
</RadioGroupContext.Provider>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface RadioGroupItemNativeProps extends Omit<RadioGroupItemProps, "disabled">, Omit<PressableProps, "children"> {}
|
|
54
|
+
|
|
55
|
+
function RadioGroupItem({
|
|
56
|
+
value,
|
|
57
|
+
disabled: itemDisabled = false,
|
|
58
|
+
style,
|
|
59
|
+
children,
|
|
60
|
+
...props
|
|
61
|
+
}: RadioGroupItemNativeProps) {
|
|
62
|
+
const ctx = useContext(RadioGroupContext);
|
|
63
|
+
const isSelected = ctx.value === value;
|
|
64
|
+
const isDisabled = ctx.disabled || itemDisabled;
|
|
65
|
+
|
|
66
|
+
const handlePress = () => {
|
|
67
|
+
if (!isDisabled) {
|
|
68
|
+
ctx.onValueChange(value);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Pressable
|
|
74
|
+
onPress={handlePress}
|
|
75
|
+
disabled={isDisabled}
|
|
76
|
+
className={cn(
|
|
77
|
+
"w-4 h-4 rounded-full border border-primary items-center justify-center shadow-sm elevation-1",
|
|
78
|
+
isDisabled && "opacity-50"
|
|
79
|
+
)}
|
|
80
|
+
style={style}
|
|
81
|
+
accessibilityRole="radio"
|
|
82
|
+
accessibilityState={{ selected: isSelected, disabled: isDisabled || false }}
|
|
83
|
+
{...props}
|
|
84
|
+
>
|
|
85
|
+
{isSelected && (
|
|
86
|
+
<View className="w-2 h-2 rounded-full bg-primary" />
|
|
87
|
+
)}
|
|
88
|
+
</Pressable>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
RadioGroup.displayName = "RadioGroup";
|
|
93
|
+
RadioGroupItem.displayName = "RadioGroupItem";
|
|
94
|
+
|
|
95
|
+
export { RadioGroup, RadioGroupItem };
|
|
96
|
+
export type { RadioGroupNativeProps, RadioGroupItemNativeProps };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { RadioGroup, RadioGroupItem } from "./RadioGroup.web";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof RadioGroup> = {
|
|
5
|
+
title: "Components/RadioGroup",
|
|
6
|
+
component: RadioGroup,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
parameters: { layout: "centered" },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof RadioGroup>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<RadioGroup defaultValue="option-one">
|
|
17
|
+
<div style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
18
|
+
<RadioGroupItem value="option-one" id="option-one" />
|
|
19
|
+
<label htmlFor="option-one">Option One</label>
|
|
20
|
+
</div>
|
|
21
|
+
<div style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
22
|
+
<RadioGroupItem value="option-two" id="option-two" />
|
|
23
|
+
<label htmlFor="option-two">Option Two</label>
|
|
24
|
+
</div>
|
|
25
|
+
<div style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
|
26
|
+
<RadioGroupItem value="option-three" id="option-three" />
|
|
27
|
+
<label htmlFor="option-three">Option Three</label>
|
|
28
|
+
</div>
|
|
29
|
+
</RadioGroup>
|
|
30
|
+
),
|
|
31
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface RadioGroupProps {
|
|
2
|
+
value?: string;
|
|
3
|
+
defaultValue?: string;
|
|
4
|
+
onValueChange?: (value: string) => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface RadioGroupItemProps {
|
|
11
|
+
value: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
const RadioGroup = forwardRef<
|
|
6
|
+
React.ComponentRef<typeof RadioGroupPrimitive.Root>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
|
8
|
+
>(({ className, ...props }, ref) => {
|
|
9
|
+
return (
|
|
10
|
+
<RadioGroupPrimitive.Root
|
|
11
|
+
className={cn("grid gap-2", className)}
|
|
12
|
+
{...props}
|
|
13
|
+
ref={ref}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
18
|
+
|
|
19
|
+
const RadioGroupItem = forwardRef<
|
|
20
|
+
React.ComponentRef<typeof RadioGroupPrimitive.Item>,
|
|
21
|
+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
|
22
|
+
>(({ className, ...props }, ref) => {
|
|
23
|
+
return (
|
|
24
|
+
<RadioGroupPrimitive.Item
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={cn(
|
|
27
|
+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
28
|
+
className,
|
|
29
|
+
)}
|
|
30
|
+
{...props}
|
|
31
|
+
>
|
|
32
|
+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
|
33
|
+
<svg
|
|
34
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
35
|
+
viewBox="0 0 24 24"
|
|
36
|
+
fill="currentColor"
|
|
37
|
+
className="h-3.5 w-3.5"
|
|
38
|
+
>
|
|
39
|
+
<circle cx="12" cy="12" r="6" />
|
|
40
|
+
</svg>
|
|
41
|
+
</RadioGroupPrimitive.Indicator>
|
|
42
|
+
</RadioGroupPrimitive.Item>
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
46
|
+
|
|
47
|
+
export { RadioGroup, RadioGroupItem };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import { useRadioGroup } from "./useRadioGroup";
|
|
4
|
+
|
|
5
|
+
describe("useRadioGroup", () => {
|
|
6
|
+
it("defaults to empty string", () => {
|
|
7
|
+
const { result } = renderHook(() => useRadioGroup({}));
|
|
8
|
+
expect(result.current.value).toBe("");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("uses defaultValue", () => {
|
|
12
|
+
const { result } = renderHook(() =>
|
|
13
|
+
useRadioGroup({ defaultValue: "opt-1" }),
|
|
14
|
+
);
|
|
15
|
+
expect(result.current.value).toBe("opt-1");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("selects a value", () => {
|
|
19
|
+
const { result } = renderHook(() => useRadioGroup({}));
|
|
20
|
+
act(() => result.current.selectValue("opt-2"));
|
|
21
|
+
expect(result.current.value).toBe("opt-2");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("calls onValueChange", () => {
|
|
25
|
+
const onChange = vi.fn();
|
|
26
|
+
const { result } = renderHook(() =>
|
|
27
|
+
useRadioGroup({ onValueChange: onChange }),
|
|
28
|
+
);
|
|
29
|
+
act(() => result.current.selectValue("opt-1"));
|
|
30
|
+
expect(onChange).toHaveBeenCalledWith("opt-1");
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("does not select when disabled", () => {
|
|
34
|
+
const { result } = renderHook(() =>
|
|
35
|
+
useRadioGroup({ disabled: true }),
|
|
36
|
+
);
|
|
37
|
+
act(() => result.current.selectValue("opt-1"));
|
|
38
|
+
expect(result.current.value).toBe("");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("works in controlled mode", () => {
|
|
42
|
+
const onChange = vi.fn();
|
|
43
|
+
const { result } = renderHook(() =>
|
|
44
|
+
useRadioGroup({ value: "opt-1", onValueChange: onChange }),
|
|
45
|
+
);
|
|
46
|
+
act(() => result.current.selectValue("opt-2"));
|
|
47
|
+
expect(result.current.value).toBe("opt-1");
|
|
48
|
+
expect(onChange).toHaveBeenCalledWith("opt-2");
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
3
|
+
|
|
4
|
+
interface UseRadioGroupProps {
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface UseRadioGroupReturn {
|
|
12
|
+
value: string;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
selectValue: (value: string) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function useRadioGroup({
|
|
18
|
+
value: controlledValue,
|
|
19
|
+
defaultValue = "",
|
|
20
|
+
onValueChange,
|
|
21
|
+
disabled = false,
|
|
22
|
+
}: UseRadioGroupProps): UseRadioGroupReturn {
|
|
23
|
+
const [value, setValue] = useControllableState({
|
|
24
|
+
value: controlledValue,
|
|
25
|
+
defaultValue,
|
|
26
|
+
onChange: onValueChange,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const selectValue = useCallback(
|
|
30
|
+
(val: string) => {
|
|
31
|
+
if (disabled) return;
|
|
32
|
+
setValue(val);
|
|
33
|
+
},
|
|
34
|
+
[disabled, setValue],
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return { value, disabled, selectValue };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type { UseRadioGroupProps, UseRadioGroupReturn };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { View, Text, type ViewProps } from "react-native";
|
|
2
|
+
import type { ResizablePanelGroupProps, ResizablePanelProps, ResizableHandleProps } from "./ResizablePanel.types";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
interface ResizablePanelGroupNativeProps extends ResizablePanelGroupProps, ViewProps {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ResizablePanelGroup on native is a placeholder.
|
|
9
|
+
* Resize interactions are not meaningful on mobile.
|
|
10
|
+
*/
|
|
11
|
+
function ResizablePanelGroup({
|
|
12
|
+
direction = "horizontal",
|
|
13
|
+
children,
|
|
14
|
+
style,
|
|
15
|
+
...props
|
|
16
|
+
}: ResizablePanelGroupNativeProps) {
|
|
17
|
+
return (
|
|
18
|
+
<View
|
|
19
|
+
className={cn(
|
|
20
|
+
"flex-1",
|
|
21
|
+
direction === "horizontal" ? "flex-row" : "flex-col"
|
|
22
|
+
)}
|
|
23
|
+
style={style}
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
</View>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
ResizablePanelGroup.displayName = "ResizablePanelGroup";
|
|
31
|
+
|
|
32
|
+
interface ResizablePanelNativeProps extends ResizablePanelProps, ViewProps {}
|
|
33
|
+
|
|
34
|
+
function ResizablePanel({
|
|
35
|
+
defaultSize,
|
|
36
|
+
children,
|
|
37
|
+
style,
|
|
38
|
+
...props
|
|
39
|
+
}: ResizablePanelNativeProps) {
|
|
40
|
+
return (
|
|
41
|
+
<View
|
|
42
|
+
className="overflow-hidden"
|
|
43
|
+
style={[{ flex: defaultSize ?? 1 }, style]}
|
|
44
|
+
{...props}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
</View>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
ResizablePanel.displayName = "ResizablePanel";
|
|
51
|
+
|
|
52
|
+
interface ResizableHandleNativeProps extends ResizableHandleProps, ViewProps {}
|
|
53
|
+
|
|
54
|
+
function ResizableHandle({
|
|
55
|
+
style,
|
|
56
|
+
...props
|
|
57
|
+
}: ResizableHandleNativeProps) {
|
|
58
|
+
return (
|
|
59
|
+
<View
|
|
60
|
+
className="w-px bg-border items-center justify-center"
|
|
61
|
+
style={style}
|
|
62
|
+
{...props}
|
|
63
|
+
>
|
|
64
|
+
<Text className="text-muted-foreground text-[10px]">{"\u22EE"}</Text>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
ResizableHandle.displayName = "ResizableHandle";
|
|
69
|
+
|
|
70
|
+
export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
|
|
71
|
+
export type {
|
|
72
|
+
ResizablePanelGroupNativeProps,
|
|
73
|
+
ResizablePanelNativeProps,
|
|
74
|
+
ResizableHandleNativeProps,
|
|
75
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import {
|
|
3
|
+
ResizablePanelGroup,
|
|
4
|
+
ResizablePanel,
|
|
5
|
+
ResizableHandle,
|
|
6
|
+
} from "./ResizablePanel.web";
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "Components/ResizablePanel",
|
|
10
|
+
component: ResizablePanelGroup,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: "centered",
|
|
13
|
+
},
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
} satisfies Meta<typeof ResizablePanelGroup>;
|
|
16
|
+
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: () => (
|
|
22
|
+
<div style={{ width: 500, height: 200 }} className="rounded-lg border">
|
|
23
|
+
<ResizablePanelGroup direction="horizontal">
|
|
24
|
+
<ResizablePanel defaultSize={50}>
|
|
25
|
+
<div className="flex h-full items-center justify-center p-6">
|
|
26
|
+
<span className="font-semibold">Panel One</span>
|
|
27
|
+
</div>
|
|
28
|
+
</ResizablePanel>
|
|
29
|
+
<ResizableHandle withHandle />
|
|
30
|
+
<ResizablePanel defaultSize={50}>
|
|
31
|
+
<div className="flex h-full items-center justify-center p-6">
|
|
32
|
+
<span className="font-semibold">Panel Two</span>
|
|
33
|
+
</div>
|
|
34
|
+
</ResizablePanel>
|
|
35
|
+
</ResizablePanelGroup>
|
|
36
|
+
</div>
|
|
37
|
+
),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Vertical: Story = {
|
|
41
|
+
render: () => (
|
|
42
|
+
<div style={{ width: 500, height: 300 }} className="rounded-lg border">
|
|
43
|
+
<ResizablePanelGroup direction="vertical">
|
|
44
|
+
<ResizablePanel defaultSize={50}>
|
|
45
|
+
<div className="flex h-full items-center justify-center p-6">
|
|
46
|
+
<span className="font-semibold">Top Panel</span>
|
|
47
|
+
</div>
|
|
48
|
+
</ResizablePanel>
|
|
49
|
+
<ResizableHandle withHandle />
|
|
50
|
+
<ResizablePanel defaultSize={50}>
|
|
51
|
+
<div className="flex h-full items-center justify-center p-6">
|
|
52
|
+
<span className="font-semibold">Bottom Panel</span>
|
|
53
|
+
</div>
|
|
54
|
+
</ResizablePanel>
|
|
55
|
+
</ResizablePanelGroup>
|
|
56
|
+
</div>
|
|
57
|
+
),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const ThreePanels: Story = {
|
|
61
|
+
render: () => (
|
|
62
|
+
<div style={{ width: 500, height: 200 }} className="rounded-lg border">
|
|
63
|
+
<ResizablePanelGroup direction="horizontal">
|
|
64
|
+
<ResizablePanel defaultSize={25}>
|
|
65
|
+
<div className="flex h-full items-center justify-center p-6">
|
|
66
|
+
<span className="font-semibold">Left</span>
|
|
67
|
+
</div>
|
|
68
|
+
</ResizablePanel>
|
|
69
|
+
<ResizableHandle />
|
|
70
|
+
<ResizablePanel defaultSize={50}>
|
|
71
|
+
<div className="flex h-full items-center justify-center p-6">
|
|
72
|
+
<span className="font-semibold">Center</span>
|
|
73
|
+
</div>
|
|
74
|
+
</ResizablePanel>
|
|
75
|
+
<ResizableHandle />
|
|
76
|
+
<ResizablePanel defaultSize={25}>
|
|
77
|
+
<div className="flex h-full items-center justify-center p-6">
|
|
78
|
+
<span className="font-semibold">Right</span>
|
|
79
|
+
</div>
|
|
80
|
+
</ResizablePanel>
|
|
81
|
+
</ResizablePanelGroup>
|
|
82
|
+
</div>
|
|
83
|
+
),
|
|
84
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type ResizableDirection = "horizontal" | "vertical";
|
|
2
|
+
|
|
3
|
+
export interface ResizablePanelGroupProps {
|
|
4
|
+
direction?: ResizableDirection;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ResizablePanelProps {
|
|
10
|
+
defaultSize?: number;
|
|
11
|
+
minSize?: number;
|
|
12
|
+
maxSize?: number;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ResizableHandleProps {
|
|
18
|
+
withHandle?: boolean;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import {
|
|
4
|
+
ResizablePanelGroup,
|
|
5
|
+
ResizablePanel,
|
|
6
|
+
ResizableHandle,
|
|
7
|
+
} from "./ResizablePanel.web";
|
|
8
|
+
|
|
9
|
+
// react-resizable-panels requires ResizeObserver
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
global.ResizeObserver = class {
|
|
12
|
+
observe() {}
|
|
13
|
+
unobserve() {}
|
|
14
|
+
disconnect() {}
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("ResizablePanelGroup", () => {
|
|
19
|
+
it("renders children panels", () => {
|
|
20
|
+
render(
|
|
21
|
+
<ResizablePanelGroup direction="horizontal">
|
|
22
|
+
<ResizablePanel defaultSize={50}>Left</ResizablePanel>
|
|
23
|
+
<ResizableHandle />
|
|
24
|
+
<ResizablePanel defaultSize={50}>Right</ResizablePanel>
|
|
25
|
+
</ResizablePanelGroup>,
|
|
26
|
+
);
|
|
27
|
+
expect(screen.getByText("Left")).toBeDefined();
|
|
28
|
+
expect(screen.getByText("Right")).toBeDefined();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("merges custom className on group", () => {
|
|
32
|
+
const { container } = render(
|
|
33
|
+
<ResizablePanelGroup direction="horizontal" className="my-group">
|
|
34
|
+
<ResizablePanel defaultSize={100}>content</ResizablePanel>
|
|
35
|
+
</ResizablePanelGroup>,
|
|
36
|
+
);
|
|
37
|
+
const group = container.firstChild as HTMLElement;
|
|
38
|
+
expect(group.className).toContain("my-group");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("renders handle with visual grip when withHandle", () => {
|
|
42
|
+
render(
|
|
43
|
+
<ResizablePanelGroup direction="horizontal">
|
|
44
|
+
<ResizablePanel defaultSize={50}>Left</ResizablePanel>
|
|
45
|
+
<ResizableHandle withHandle />
|
|
46
|
+
<ResizablePanel defaultSize={50}>Right</ResizablePanel>
|
|
47
|
+
</ResizablePanelGroup>,
|
|
48
|
+
);
|
|
49
|
+
const handle = screen.getByRole("separator");
|
|
50
|
+
expect(handle.querySelector("svg")).not.toBeNull();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Group,
|
|
3
|
+
Panel,
|
|
4
|
+
Separator,
|
|
5
|
+
} from "react-resizable-panels";
|
|
6
|
+
import { cn } from "../../utils/cn";
|
|
7
|
+
import type {
|
|
8
|
+
ResizablePanelGroupProps,
|
|
9
|
+
ResizablePanelProps,
|
|
10
|
+
ResizableHandleProps,
|
|
11
|
+
} from "./ResizablePanel.types";
|
|
12
|
+
|
|
13
|
+
function ResizablePanelGroup({
|
|
14
|
+
className,
|
|
15
|
+
direction = "horizontal",
|
|
16
|
+
children,
|
|
17
|
+
}: ResizablePanelGroupProps) {
|
|
18
|
+
return (
|
|
19
|
+
<Group
|
|
20
|
+
orientation={direction}
|
|
21
|
+
className={cn(
|
|
22
|
+
"flex h-full w-full data-[orientation=vertical]:flex-col",
|
|
23
|
+
className,
|
|
24
|
+
)}
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
</Group>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function ResizablePanel({
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}: ResizablePanelProps & React.ComponentProps<typeof Panel>) {
|
|
35
|
+
return <Panel className={cn("relative overflow-auto", className)} {...props} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function ResizableHandle({
|
|
39
|
+
className,
|
|
40
|
+
withHandle,
|
|
41
|
+
...props
|
|
42
|
+
}: ResizableHandleProps & React.ComponentProps<typeof Separator>) {
|
|
43
|
+
return (
|
|
44
|
+
<Separator
|
|
45
|
+
className={cn(
|
|
46
|
+
"relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[orientation=vertical]:h-px data-[orientation=vertical]:w-full data-[orientation=vertical]:after:left-0 data-[orientation=vertical]:after:h-1 data-[orientation=vertical]:after:w-full data-[orientation=vertical]:after:-translate-y-1/2 data-[orientation=vertical]:after:translate-x-0 [&[data-orientation=vertical]>div]:rotate-90",
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
{withHandle && (
|
|
52
|
+
<div className="z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border">
|
|
53
|
+
<svg
|
|
54
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
55
|
+
width="10"
|
|
56
|
+
height="10"
|
|
57
|
+
viewBox="0 0 24 24"
|
|
58
|
+
fill="none"
|
|
59
|
+
stroke="currentColor"
|
|
60
|
+
strokeWidth="2"
|
|
61
|
+
strokeLinecap="round"
|
|
62
|
+
strokeLinejoin="round"
|
|
63
|
+
>
|
|
64
|
+
<circle cx="12" cy="5" r="1" />
|
|
65
|
+
<circle cx="12" cy="12" r="1" />
|
|
66
|
+
<circle cx="12" cy="19" r="1" />
|
|
67
|
+
<circle cx="19" cy="5" r="1" />
|
|
68
|
+
<circle cx="19" cy="12" r="1" />
|
|
69
|
+
<circle cx="19" cy="19" r="1" />
|
|
70
|
+
</svg>
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
</Separator>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { ResizablePanelGroup, ResizablePanel, ResizableHandle };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ScrollView, type ScrollViewProps } from "react-native";
|
|
2
|
+
import type { ScrollAreaProps, ScrollBarProps } from "./ScrollArea.types";
|
|
3
|
+
|
|
4
|
+
interface ScrollAreaNativeProps extends ScrollAreaProps, ScrollViewProps {
|
|
5
|
+
orientation?: "vertical" | "horizontal";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function ScrollArea({
|
|
9
|
+
children,
|
|
10
|
+
orientation = "vertical",
|
|
11
|
+
style,
|
|
12
|
+
...props
|
|
13
|
+
}: ScrollAreaNativeProps) {
|
|
14
|
+
return (
|
|
15
|
+
<ScrollView
|
|
16
|
+
horizontal={orientation === "horizontal"}
|
|
17
|
+
showsVerticalScrollIndicator={orientation === "vertical"}
|
|
18
|
+
showsHorizontalScrollIndicator={orientation === "horizontal"}
|
|
19
|
+
className="flex-1"
|
|
20
|
+
style={style}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</ScrollView>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
ScrollArea.displayName = "ScrollArea";
|
|
29
|
+
|
|
30
|
+
interface ScrollBarNativeProps extends ScrollBarProps {}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ScrollBar is a no-op on native as React Native's ScrollView
|
|
34
|
+
* handles its own scroll indicators natively.
|
|
35
|
+
*/
|
|
36
|
+
function ScrollBar(_props: ScrollBarNativeProps) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ScrollBar.displayName = "ScrollBar";
|
|
41
|
+
|
|
42
|
+
export { ScrollArea, ScrollBar };
|
|
43
|
+
export type { ScrollAreaNativeProps, ScrollBarNativeProps };
|