@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,98 @@
|
|
|
1
|
+
import { useRef, useCallback } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
PanResponder,
|
|
5
|
+
type ViewProps,
|
|
6
|
+
type LayoutChangeEvent,
|
|
7
|
+
type GestureResponderEvent,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import { cn } from "../../utils/cn";
|
|
10
|
+
import type { SliderProps } from "./Slider.types";
|
|
11
|
+
import { useSlider } from "./useSlider";
|
|
12
|
+
|
|
13
|
+
type SliderNativeProps = SliderProps & Omit<ViewProps, "className">;
|
|
14
|
+
|
|
15
|
+
function Slider({
|
|
16
|
+
value: controlledValue,
|
|
17
|
+
defaultValue = [0],
|
|
18
|
+
onValueChange,
|
|
19
|
+
min = 0,
|
|
20
|
+
max = 100,
|
|
21
|
+
step = 1,
|
|
22
|
+
disabled = false,
|
|
23
|
+
className,
|
|
24
|
+
...props
|
|
25
|
+
}: SliderNativeProps) {
|
|
26
|
+
const { setValue, fraction, getValueFromRatio } = useSlider({
|
|
27
|
+
value: controlledValue,
|
|
28
|
+
defaultValue,
|
|
29
|
+
onValueChange,
|
|
30
|
+
min,
|
|
31
|
+
max,
|
|
32
|
+
step,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const trackLayout = useRef({ x: 0, width: 0 });
|
|
36
|
+
|
|
37
|
+
const updateFromPageX = useCallback((pageX: number) => {
|
|
38
|
+
const { x, width } = trackLayout.current;
|
|
39
|
+
if (width === 0) return;
|
|
40
|
+
|
|
41
|
+
const ratio = (pageX - x) / width;
|
|
42
|
+
const newVal = getValueFromRatio(ratio);
|
|
43
|
+
setValue([newVal]);
|
|
44
|
+
}, [getValueFromRatio, setValue]);
|
|
45
|
+
|
|
46
|
+
const panResponder = useRef(
|
|
47
|
+
PanResponder.create({
|
|
48
|
+
onStartShouldSetPanResponder: () => !disabled,
|
|
49
|
+
onMoveShouldSetPanResponder: () => !disabled,
|
|
50
|
+
onPanResponderGrant: (evt: GestureResponderEvent) => {
|
|
51
|
+
updateFromPageX(evt.nativeEvent.pageX);
|
|
52
|
+
},
|
|
53
|
+
onPanResponderMove: (evt: GestureResponderEvent) => {
|
|
54
|
+
updateFromPageX(evt.nativeEvent.pageX);
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
).current;
|
|
58
|
+
|
|
59
|
+
const handleLayout = (e: LayoutChangeEvent) => {
|
|
60
|
+
const { width } = e.nativeEvent.layout;
|
|
61
|
+
trackLayout.current.width = width;
|
|
62
|
+
// Measure absolute position on screen
|
|
63
|
+
(e.target as any)?.measure?.(
|
|
64
|
+
(_x: number, _y: number, _w: number, _h: number, pageX: number) => {
|
|
65
|
+
trackLayout.current.x = pageX;
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<View
|
|
72
|
+
className={cn(
|
|
73
|
+
"w-full h-8 justify-center",
|
|
74
|
+
disabled && "opacity-50",
|
|
75
|
+
className,
|
|
76
|
+
)}
|
|
77
|
+
onLayout={handleLayout}
|
|
78
|
+
{...panResponder.panHandlers}
|
|
79
|
+
{...props}
|
|
80
|
+
>
|
|
81
|
+
<View className="h-1.5 w-full rounded-full bg-primary/20">
|
|
82
|
+
<View
|
|
83
|
+
className="h-full rounded-full bg-primary"
|
|
84
|
+
style={{ width: `${fraction * 100}%` }}
|
|
85
|
+
/>
|
|
86
|
+
</View>
|
|
87
|
+
<View
|
|
88
|
+
className="w-4 h-4 rounded-full bg-background border-2 border-primary absolute shadow elevation-1"
|
|
89
|
+
style={{ left: `${fraction * 100}%`, marginLeft: -8 }}
|
|
90
|
+
/>
|
|
91
|
+
</View>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Slider.displayName = "Slider";
|
|
96
|
+
|
|
97
|
+
export { Slider };
|
|
98
|
+
export type { SliderNativeProps };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Slider } from "./Slider.web";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Slider> = {
|
|
5
|
+
title: "Components/Slider",
|
|
6
|
+
component: Slider,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered",
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof Slider>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
defaultValue: [50],
|
|
19
|
+
max: 100,
|
|
20
|
+
step: 1,
|
|
21
|
+
style: { width: 300 },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
const Slider = forwardRef<
|
|
6
|
+
React.ComponentRef<typeof SliderPrimitive.Root>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<SliderPrimitive.Root
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
"relative flex w-full touch-none select-none items-center",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
>
|
|
17
|
+
<SliderPrimitive.Track className="relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20">
|
|
18
|
+
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
|
19
|
+
</SliderPrimitive.Track>
|
|
20
|
+
<SliderPrimitive.Thumb className="block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" />
|
|
21
|
+
</SliderPrimitive.Root>
|
|
22
|
+
));
|
|
23
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
24
|
+
|
|
25
|
+
export { Slider };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import { useSlider } from "./useSlider";
|
|
4
|
+
|
|
5
|
+
describe("useSlider", () => {
|
|
6
|
+
it("defaults to [0]", () => {
|
|
7
|
+
const { result } = renderHook(() => useSlider());
|
|
8
|
+
expect(result.current.value).toEqual([0]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("uses defaultValue", () => {
|
|
12
|
+
const { result } = renderHook(() => useSlider({ defaultValue: [50] }));
|
|
13
|
+
expect(result.current.value).toEqual([50]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("computes fraction correctly", () => {
|
|
17
|
+
const { result } = renderHook(() => useSlider({ defaultValue: [50] }));
|
|
18
|
+
expect(result.current.fraction).toBe(0.5);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("computes fraction with custom min/max", () => {
|
|
22
|
+
const { result } = renderHook(() =>
|
|
23
|
+
useSlider({ defaultValue: [25], min: 0, max: 50 }),
|
|
24
|
+
);
|
|
25
|
+
expect(result.current.fraction).toBe(0.5);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("clamps and steps values", () => {
|
|
29
|
+
const { result } = renderHook(() =>
|
|
30
|
+
useSlider({ min: 0, max: 100, step: 10 }),
|
|
31
|
+
);
|
|
32
|
+
expect(result.current.clampAndStep(15)).toBe(20);
|
|
33
|
+
expect(result.current.clampAndStep(105)).toBe(100);
|
|
34
|
+
expect(result.current.clampAndStep(-5)).toBe(0);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("getValueFromRatio computes correctly", () => {
|
|
38
|
+
const { result } = renderHook(() =>
|
|
39
|
+
useSlider({ min: 0, max: 100, step: 1 }),
|
|
40
|
+
);
|
|
41
|
+
expect(result.current.getValueFromRatio(0)).toBe(0);
|
|
42
|
+
expect(result.current.getValueFromRatio(0.5)).toBe(50);
|
|
43
|
+
expect(result.current.getValueFromRatio(1)).toBe(100);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("getValueFromRatio clamps out-of-range ratios", () => {
|
|
47
|
+
const { result } = renderHook(() =>
|
|
48
|
+
useSlider({ min: 0, max: 100, step: 1 }),
|
|
49
|
+
);
|
|
50
|
+
expect(result.current.getValueFromRatio(-0.5)).toBe(0);
|
|
51
|
+
expect(result.current.getValueFromRatio(1.5)).toBe(100);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("updates value via setValue", () => {
|
|
55
|
+
const { result } = renderHook(() => useSlider());
|
|
56
|
+
act(() => result.current.setValue([75]));
|
|
57
|
+
expect(result.current.value).toEqual([75]);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("calls onValueChange", () => {
|
|
61
|
+
const onChange = vi.fn();
|
|
62
|
+
const { result } = renderHook(() =>
|
|
63
|
+
useSlider({ onValueChange: onChange }),
|
|
64
|
+
);
|
|
65
|
+
act(() => result.current.setValue([42]));
|
|
66
|
+
expect(onChange).toHaveBeenCalledWith([42]);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
3
|
+
|
|
4
|
+
interface UseSliderProps {
|
|
5
|
+
value?: number[];
|
|
6
|
+
defaultValue?: number[];
|
|
7
|
+
onValueChange?: (value: number[]) => void;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
step?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useSlider({
|
|
14
|
+
value: controlledValue,
|
|
15
|
+
defaultValue = [0],
|
|
16
|
+
onValueChange,
|
|
17
|
+
min = 0,
|
|
18
|
+
max = 100,
|
|
19
|
+
step = 1,
|
|
20
|
+
}: UseSliderProps = {}) {
|
|
21
|
+
const [value, setValue] = useControllableState<number[]>({
|
|
22
|
+
value: controlledValue,
|
|
23
|
+
defaultValue,
|
|
24
|
+
onChange: onValueChange,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const clampAndStep = useCallback(
|
|
28
|
+
(val: number) => {
|
|
29
|
+
const stepped = Math.round((val - min) / step) * step + min;
|
|
30
|
+
return Math.min(max, Math.max(min, stepped));
|
|
31
|
+
},
|
|
32
|
+
[min, max, step],
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const getValueFromRatio = useCallback(
|
|
36
|
+
(ratio: number) => {
|
|
37
|
+
const clamped = Math.max(0, Math.min(1, ratio));
|
|
38
|
+
return clampAndStep(min + clamped * (max - min));
|
|
39
|
+
},
|
|
40
|
+
[min, max, clampAndStep],
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const fraction = (value[0] - min) / (max - min);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
value,
|
|
47
|
+
setValue,
|
|
48
|
+
fraction,
|
|
49
|
+
clampAndStep,
|
|
50
|
+
getValueFromRatio,
|
|
51
|
+
min,
|
|
52
|
+
max,
|
|
53
|
+
step,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Switch as RNSwitch, type SwitchProps as RNSwitchProps } from "react-native";
|
|
2
|
+
import { useCSSVariable } from "uniwind";
|
|
3
|
+
import type { SwitchProps } from "./Switch.types";
|
|
4
|
+
|
|
5
|
+
type SwitchNativeProps = SwitchProps & Omit<RNSwitchProps, "value" | "onValueChange" | "className">;
|
|
6
|
+
|
|
7
|
+
function Switch({
|
|
8
|
+
checked,
|
|
9
|
+
defaultChecked,
|
|
10
|
+
onCheckedChange,
|
|
11
|
+
disabled = false,
|
|
12
|
+
className: _className,
|
|
13
|
+
...props
|
|
14
|
+
}: SwitchNativeProps) {
|
|
15
|
+
const [input, primary, background] = useCSSVariable([
|
|
16
|
+
"--color-input",
|
|
17
|
+
"--color-primary",
|
|
18
|
+
"--color-background",
|
|
19
|
+
]) as [string, string, string];
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<RNSwitch
|
|
23
|
+
value={checked}
|
|
24
|
+
onValueChange={onCheckedChange}
|
|
25
|
+
disabled={disabled}
|
|
26
|
+
trackColor={{ false: input, true: primary }}
|
|
27
|
+
thumbColor={background}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Switch.displayName = "Switch";
|
|
34
|
+
|
|
35
|
+
export { Switch };
|
|
36
|
+
export type { SwitchNativeProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Switch } from "./Switch.web";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Switch> = {
|
|
5
|
+
title: "Components/Switch",
|
|
6
|
+
component: Switch,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered",
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof Switch>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {};
|
|
17
|
+
|
|
18
|
+
export const Checked: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
defaultChecked: true,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Disabled: Story = {
|
|
25
|
+
args: {
|
|
26
|
+
disabled: true,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { render, screen, fireEvent } from "@testing-library/react";
|
|
3
|
+
import { Switch } from "./Switch.web";
|
|
4
|
+
|
|
5
|
+
describe("Switch", () => {
|
|
6
|
+
it("renders with switch role", () => {
|
|
7
|
+
render(<Switch />);
|
|
8
|
+
expect(screen.getByRole("switch")).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("defaults to unchecked", () => {
|
|
12
|
+
render(<Switch />);
|
|
13
|
+
expect(screen.getByRole("switch").getAttribute("data-state")).toBe("unchecked");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("can be checked by default", () => {
|
|
17
|
+
render(<Switch defaultChecked />);
|
|
18
|
+
expect(screen.getByRole("switch").getAttribute("data-state")).toBe("checked");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("toggles on click", () => {
|
|
22
|
+
render(<Switch />);
|
|
23
|
+
const sw = screen.getByRole("switch");
|
|
24
|
+
fireEvent.click(sw);
|
|
25
|
+
expect(sw.getAttribute("data-state")).toBe("checked");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("calls onCheckedChange", () => {
|
|
29
|
+
const onChange = vi.fn();
|
|
30
|
+
render(<Switch onCheckedChange={onChange} />);
|
|
31
|
+
fireEvent.click(screen.getByRole("switch"));
|
|
32
|
+
expect(onChange).toHaveBeenCalledWith(true);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("respects disabled", () => {
|
|
36
|
+
render(<Switch disabled />);
|
|
37
|
+
expect(screen.getByRole("switch")).toHaveProperty("disabled", true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("merges custom className", () => {
|
|
41
|
+
render(<Switch className="my-switch" />);
|
|
42
|
+
expect(screen.getByRole("switch").className).toContain("my-switch");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import * as SwitchPrimitive from "@radix-ui/react-switch";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
const Switch = forwardRef<
|
|
6
|
+
React.ComponentRef<typeof SwitchPrimitive.Root>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<SwitchPrimitive.Root
|
|
10
|
+
className={cn(
|
|
11
|
+
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
{...props}
|
|
15
|
+
ref={ref}
|
|
16
|
+
>
|
|
17
|
+
<SwitchPrimitive.Thumb
|
|
18
|
+
className={cn(
|
|
19
|
+
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0",
|
|
20
|
+
)}
|
|
21
|
+
/>
|
|
22
|
+
</SwitchPrimitive.Root>
|
|
23
|
+
));
|
|
24
|
+
Switch.displayName = SwitchPrimitive.Root.displayName;
|
|
25
|
+
|
|
26
|
+
export { Switch };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { View, Text, type ViewProps } from "react-native";
|
|
2
|
+
import { cn } from "../../utils/cn";
|
|
3
|
+
import type {
|
|
4
|
+
TableProps,
|
|
5
|
+
TableHeaderProps,
|
|
6
|
+
TableBodyProps,
|
|
7
|
+
TableFooterProps,
|
|
8
|
+
TableRowProps,
|
|
9
|
+
TableHeadProps,
|
|
10
|
+
TableCellProps,
|
|
11
|
+
TableCaptionProps,
|
|
12
|
+
} from "./Table.types";
|
|
13
|
+
|
|
14
|
+
type TableNativeProps = TableProps & Omit<ViewProps, "className">;
|
|
15
|
+
|
|
16
|
+
function Table({ children, className, ...props }: TableNativeProps) {
|
|
17
|
+
return (
|
|
18
|
+
<View
|
|
19
|
+
className={cn("w-full rounded-lg overflow-hidden", className)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</View>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
Table.displayName = "Table";
|
|
27
|
+
|
|
28
|
+
type TableHeaderNativeProps = TableHeaderProps & Omit<ViewProps, "className">;
|
|
29
|
+
|
|
30
|
+
function TableHeader({ children, className, ...props }: TableHeaderNativeProps) {
|
|
31
|
+
return (
|
|
32
|
+
<View
|
|
33
|
+
className={cn("border-b border-border", className)}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
TableHeader.displayName = "TableHeader";
|
|
41
|
+
|
|
42
|
+
type TableBodyNativeProps = TableBodyProps & Omit<ViewProps, "className">;
|
|
43
|
+
|
|
44
|
+
function TableBody({ children, className, ...props }: TableBodyNativeProps) {
|
|
45
|
+
return (
|
|
46
|
+
<View className={className} {...props}>
|
|
47
|
+
{children}
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
TableBody.displayName = "TableBody";
|
|
52
|
+
|
|
53
|
+
type TableFooterNativeProps = TableFooterProps & Omit<ViewProps, "className">;
|
|
54
|
+
|
|
55
|
+
function TableFooter({ children, className, ...props }: TableFooterNativeProps) {
|
|
56
|
+
return (
|
|
57
|
+
<View
|
|
58
|
+
className={cn("border-t border-border bg-secondary/50", className)}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
</View>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
TableFooter.displayName = "TableFooter";
|
|
66
|
+
|
|
67
|
+
type TableRowNativeProps = TableRowProps & Omit<ViewProps, "className">;
|
|
68
|
+
|
|
69
|
+
function TableRow({
|
|
70
|
+
children,
|
|
71
|
+
selected,
|
|
72
|
+
className,
|
|
73
|
+
...props
|
|
74
|
+
}: TableRowNativeProps) {
|
|
75
|
+
return (
|
|
76
|
+
<View
|
|
77
|
+
className={cn(
|
|
78
|
+
"flex-row border-b border-border items-center",
|
|
79
|
+
selected && "bg-secondary",
|
|
80
|
+
className,
|
|
81
|
+
)}
|
|
82
|
+
{...props}
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
TableRow.displayName = "TableRow";
|
|
89
|
+
|
|
90
|
+
type TableHeadNativeProps = TableHeadProps & Omit<ViewProps, "className">;
|
|
91
|
+
|
|
92
|
+
function TableHead({ children, className, ...props }: TableHeadNativeProps) {
|
|
93
|
+
return (
|
|
94
|
+
<View
|
|
95
|
+
className={cn("flex-1 h-10 px-2 justify-center", className)}
|
|
96
|
+
{...props}
|
|
97
|
+
>
|
|
98
|
+
{typeof children === "string" ? (
|
|
99
|
+
<Text className="font-medium text-xs text-muted-foreground">
|
|
100
|
+
{children}
|
|
101
|
+
</Text>
|
|
102
|
+
) : (
|
|
103
|
+
children
|
|
104
|
+
)}
|
|
105
|
+
</View>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
TableHead.displayName = "TableHead";
|
|
109
|
+
|
|
110
|
+
type TableCellNativeProps = TableCellProps & Omit<ViewProps, "className">;
|
|
111
|
+
|
|
112
|
+
function TableCell({ children, className, ...props }: TableCellNativeProps) {
|
|
113
|
+
return (
|
|
114
|
+
<View
|
|
115
|
+
className={cn("flex-1 px-2 py-2 justify-center", className)}
|
|
116
|
+
{...props}
|
|
117
|
+
>
|
|
118
|
+
{typeof children === "string" ? (
|
|
119
|
+
<Text className="text-sm text-foreground">{children}</Text>
|
|
120
|
+
) : (
|
|
121
|
+
children
|
|
122
|
+
)}
|
|
123
|
+
</View>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
TableCell.displayName = "TableCell";
|
|
127
|
+
|
|
128
|
+
type TableCaptionNativeProps = TableCaptionProps & Omit<ViewProps, "className">;
|
|
129
|
+
|
|
130
|
+
function TableCaption({ children, className, ...props }: TableCaptionNativeProps) {
|
|
131
|
+
return (
|
|
132
|
+
<View
|
|
133
|
+
className={cn("mt-4 items-center", className)}
|
|
134
|
+
{...props}
|
|
135
|
+
>
|
|
136
|
+
{typeof children === "string" ? (
|
|
137
|
+
<Text className="text-sm text-muted-foreground">{children}</Text>
|
|
138
|
+
) : (
|
|
139
|
+
children
|
|
140
|
+
)}
|
|
141
|
+
</View>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
TableCaption.displayName = "TableCaption";
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
Table,
|
|
148
|
+
TableHeader,
|
|
149
|
+
TableBody,
|
|
150
|
+
TableFooter,
|
|
151
|
+
TableRow,
|
|
152
|
+
TableHead,
|
|
153
|
+
TableCell,
|
|
154
|
+
TableCaption,
|
|
155
|
+
};
|
|
156
|
+
export type {
|
|
157
|
+
TableNativeProps,
|
|
158
|
+
TableHeaderNativeProps,
|
|
159
|
+
TableBodyNativeProps,
|
|
160
|
+
TableFooterNativeProps,
|
|
161
|
+
TableRowNativeProps,
|
|
162
|
+
TableHeadNativeProps,
|
|
163
|
+
TableCellNativeProps,
|
|
164
|
+
TableCaptionNativeProps,
|
|
165
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import {
|
|
3
|
+
Table,
|
|
4
|
+
TableHeader,
|
|
5
|
+
TableBody,
|
|
6
|
+
TableRow,
|
|
7
|
+
TableHead,
|
|
8
|
+
TableCell,
|
|
9
|
+
TableCaption,
|
|
10
|
+
} from "./Table.web";
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof Table> = {
|
|
13
|
+
title: "Components/Table",
|
|
14
|
+
component: Table,
|
|
15
|
+
tags: ["autodocs"],
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "centered",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default meta;
|
|
22
|
+
type Story = StoryObj<typeof Table>;
|
|
23
|
+
|
|
24
|
+
export const Default: Story = {
|
|
25
|
+
render: () => (
|
|
26
|
+
<Table>
|
|
27
|
+
<TableCaption>A list of team members.</TableCaption>
|
|
28
|
+
<TableHeader>
|
|
29
|
+
<TableRow>
|
|
30
|
+
<TableHead>Name</TableHead>
|
|
31
|
+
<TableHead>Email</TableHead>
|
|
32
|
+
<TableHead>Role</TableHead>
|
|
33
|
+
</TableRow>
|
|
34
|
+
</TableHeader>
|
|
35
|
+
<TableBody>
|
|
36
|
+
<TableRow>
|
|
37
|
+
<TableCell>Alice Johnson</TableCell>
|
|
38
|
+
<TableCell>alice@example.com</TableCell>
|
|
39
|
+
<TableCell>Engineer</TableCell>
|
|
40
|
+
</TableRow>
|
|
41
|
+
<TableRow>
|
|
42
|
+
<TableCell>Bob Smith</TableCell>
|
|
43
|
+
<TableCell>bob@example.com</TableCell>
|
|
44
|
+
<TableCell>Designer</TableCell>
|
|
45
|
+
</TableRow>
|
|
46
|
+
<TableRow>
|
|
47
|
+
<TableCell>Carol Lee</TableCell>
|
|
48
|
+
<TableCell>carol@example.com</TableCell>
|
|
49
|
+
<TableCell>Manager</TableCell>
|
|
50
|
+
</TableRow>
|
|
51
|
+
</TableBody>
|
|
52
|
+
</Table>
|
|
53
|
+
),
|
|
54
|
+
};
|