@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,158 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Pressable,
|
|
3
|
+
Text,
|
|
4
|
+
View,
|
|
5
|
+
type ViewProps,
|
|
6
|
+
type TextProps,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
import { cn } from "../../utils/cn";
|
|
9
|
+
import type {
|
|
10
|
+
BreadcrumbProps,
|
|
11
|
+
BreadcrumbListProps,
|
|
12
|
+
BreadcrumbItemProps,
|
|
13
|
+
BreadcrumbLinkProps,
|
|
14
|
+
BreadcrumbPageProps,
|
|
15
|
+
BreadcrumbSeparatorProps,
|
|
16
|
+
BreadcrumbEllipsisProps,
|
|
17
|
+
} from "./Breadcrumb.types";
|
|
18
|
+
|
|
19
|
+
// --- Breadcrumb ---
|
|
20
|
+
|
|
21
|
+
interface BreadcrumbNativeProps extends BreadcrumbProps, ViewProps {}
|
|
22
|
+
|
|
23
|
+
function Breadcrumb({ children, className, ...props }: BreadcrumbNativeProps) {
|
|
24
|
+
return (
|
|
25
|
+
<View
|
|
26
|
+
accessibilityRole="header"
|
|
27
|
+
className={cn("flex-row", className)}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</View>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
35
|
+
|
|
36
|
+
// --- BreadcrumbList ---
|
|
37
|
+
|
|
38
|
+
interface BreadcrumbListNativeProps extends BreadcrumbListProps, ViewProps {}
|
|
39
|
+
|
|
40
|
+
function BreadcrumbList({
|
|
41
|
+
children,
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
}: BreadcrumbListNativeProps) {
|
|
45
|
+
return (
|
|
46
|
+
<View
|
|
47
|
+
className={cn("flex-row flex-wrap items-center gap-1.5", className)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
BreadcrumbList.displayName = "BreadcrumbList";
|
|
55
|
+
|
|
56
|
+
// --- BreadcrumbItem ---
|
|
57
|
+
|
|
58
|
+
interface BreadcrumbItemNativeProps extends BreadcrumbItemProps, ViewProps {}
|
|
59
|
+
|
|
60
|
+
function BreadcrumbItem({
|
|
61
|
+
children,
|
|
62
|
+
className,
|
|
63
|
+
...props
|
|
64
|
+
}: BreadcrumbItemNativeProps) {
|
|
65
|
+
return (
|
|
66
|
+
<View
|
|
67
|
+
className={cn("flex-row items-center gap-1.5", className)}
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</View>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
75
|
+
|
|
76
|
+
// --- BreadcrumbLink ---
|
|
77
|
+
|
|
78
|
+
interface BreadcrumbLinkNativeProps extends BreadcrumbLinkProps {}
|
|
79
|
+
|
|
80
|
+
function BreadcrumbLink({
|
|
81
|
+
children,
|
|
82
|
+
onPress,
|
|
83
|
+
}: BreadcrumbLinkNativeProps) {
|
|
84
|
+
return (
|
|
85
|
+
<Pressable onPress={onPress}>
|
|
86
|
+
{typeof children === "string" ? (
|
|
87
|
+
<Text className="text-sm text-muted-foreground">
|
|
88
|
+
{children}
|
|
89
|
+
</Text>
|
|
90
|
+
) : (
|
|
91
|
+
children
|
|
92
|
+
)}
|
|
93
|
+
</Pressable>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
97
|
+
|
|
98
|
+
// --- BreadcrumbPage ---
|
|
99
|
+
|
|
100
|
+
interface BreadcrumbPageNativeProps extends BreadcrumbPageProps, TextProps {}
|
|
101
|
+
|
|
102
|
+
function BreadcrumbPage({
|
|
103
|
+
children,
|
|
104
|
+
className,
|
|
105
|
+
...props
|
|
106
|
+
}: BreadcrumbPageNativeProps) {
|
|
107
|
+
return (
|
|
108
|
+
<Text
|
|
109
|
+
className={cn("text-sm font-normal text-foreground", className)}
|
|
110
|
+
{...props}
|
|
111
|
+
>
|
|
112
|
+
{children}
|
|
113
|
+
</Text>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
117
|
+
|
|
118
|
+
// --- BreadcrumbSeparator ---
|
|
119
|
+
|
|
120
|
+
interface BreadcrumbSeparatorNativeProps extends BreadcrumbSeparatorProps {}
|
|
121
|
+
|
|
122
|
+
function BreadcrumbSeparator({ children }: BreadcrumbSeparatorNativeProps) {
|
|
123
|
+
return (
|
|
124
|
+
<Text className="text-sm text-muted-foreground">
|
|
125
|
+
{children ?? "/"}
|
|
126
|
+
</Text>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
130
|
+
|
|
131
|
+
// --- BreadcrumbEllipsis ---
|
|
132
|
+
|
|
133
|
+
function BreadcrumbEllipsis(_props: BreadcrumbEllipsisProps) {
|
|
134
|
+
return (
|
|
135
|
+
<View className="h-9 w-9 items-center justify-center">
|
|
136
|
+
<Text className="text-sm text-muted-foreground">{"\u2026"}</Text>
|
|
137
|
+
</View>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
BreadcrumbEllipsis.displayName = "BreadcrumbEllipsis";
|
|
141
|
+
|
|
142
|
+
export {
|
|
143
|
+
Breadcrumb,
|
|
144
|
+
BreadcrumbList,
|
|
145
|
+
BreadcrumbItem,
|
|
146
|
+
BreadcrumbLink,
|
|
147
|
+
BreadcrumbPage,
|
|
148
|
+
BreadcrumbSeparator,
|
|
149
|
+
BreadcrumbEllipsis,
|
|
150
|
+
};
|
|
151
|
+
export type {
|
|
152
|
+
BreadcrumbNativeProps,
|
|
153
|
+
BreadcrumbListNativeProps,
|
|
154
|
+
BreadcrumbItemNativeProps,
|
|
155
|
+
BreadcrumbLinkNativeProps,
|
|
156
|
+
BreadcrumbPageNativeProps,
|
|
157
|
+
BreadcrumbSeparatorNativeProps,
|
|
158
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import {
|
|
3
|
+
Breadcrumb,
|
|
4
|
+
BreadcrumbList,
|
|
5
|
+
BreadcrumbItem,
|
|
6
|
+
BreadcrumbLink,
|
|
7
|
+
BreadcrumbPage,
|
|
8
|
+
BreadcrumbSeparator,
|
|
9
|
+
} from "./Breadcrumb.web";
|
|
10
|
+
|
|
11
|
+
const meta = {
|
|
12
|
+
title: "Components/Breadcrumb",
|
|
13
|
+
component: Breadcrumb,
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "centered",
|
|
16
|
+
},
|
|
17
|
+
tags: ["autodocs"],
|
|
18
|
+
} satisfies Meta<typeof Breadcrumb>;
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
export const Default: Story = {
|
|
24
|
+
args: {
|
|
25
|
+
children: (
|
|
26
|
+
<BreadcrumbList>
|
|
27
|
+
<BreadcrumbItem>
|
|
28
|
+
<BreadcrumbLink href="/">Home</BreadcrumbLink>
|
|
29
|
+
</BreadcrumbItem>
|
|
30
|
+
<BreadcrumbSeparator />
|
|
31
|
+
<BreadcrumbItem>
|
|
32
|
+
<BreadcrumbLink href="/components">Components</BreadcrumbLink>
|
|
33
|
+
</BreadcrumbItem>
|
|
34
|
+
<BreadcrumbSeparator />
|
|
35
|
+
<BreadcrumbItem>
|
|
36
|
+
<BreadcrumbPage>Breadcrumb</BreadcrumbPage>
|
|
37
|
+
</BreadcrumbItem>
|
|
38
|
+
</BreadcrumbList>
|
|
39
|
+
),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface BreadcrumbProps {
|
|
2
|
+
separator?: React.ReactNode;
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface BreadcrumbListProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface BreadcrumbItemProps {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface BreadcrumbLinkProps {
|
|
18
|
+
href?: string;
|
|
19
|
+
asChild?: boolean;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
onPress?: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface BreadcrumbPageProps {
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface BreadcrumbSeparatorProps {
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface BreadcrumbEllipsisProps {
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
function ChevronRightIcon(props: React.SVGProps<SVGSVGElement>) {
|
|
6
|
+
return (
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" {...props}>
|
|
8
|
+
<path d="m9 18 6-6-6-6"/>
|
|
9
|
+
</svg>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function MoreHorizontalIcon(props: React.SVGProps<SVGSVGElement>) {
|
|
14
|
+
return (
|
|
15
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" {...props}>
|
|
16
|
+
<circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/>
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const Breadcrumb = forwardRef<
|
|
22
|
+
HTMLElement,
|
|
23
|
+
React.ComponentPropsWithoutRef<"nav"> & { separator?: React.ReactNode }
|
|
24
|
+
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />);
|
|
25
|
+
Breadcrumb.displayName = "Breadcrumb";
|
|
26
|
+
|
|
27
|
+
const BreadcrumbList = forwardRef<
|
|
28
|
+
HTMLOListElement,
|
|
29
|
+
React.ComponentPropsWithoutRef<"ol">
|
|
30
|
+
>(({ className, ...props }, ref) => (
|
|
31
|
+
<ol
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={cn(
|
|
34
|
+
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
|
|
35
|
+
className,
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
));
|
|
40
|
+
BreadcrumbList.displayName = "BreadcrumbList";
|
|
41
|
+
|
|
42
|
+
const BreadcrumbItem = forwardRef<
|
|
43
|
+
HTMLLIElement,
|
|
44
|
+
React.ComponentPropsWithoutRef<"li">
|
|
45
|
+
>(({ className, ...props }, ref) => (
|
|
46
|
+
<li
|
|
47
|
+
ref={ref}
|
|
48
|
+
className={cn("inline-flex items-center gap-1.5", className)}
|
|
49
|
+
{...props}
|
|
50
|
+
/>
|
|
51
|
+
));
|
|
52
|
+
BreadcrumbItem.displayName = "BreadcrumbItem";
|
|
53
|
+
|
|
54
|
+
const BreadcrumbLink = forwardRef<
|
|
55
|
+
HTMLAnchorElement,
|
|
56
|
+
React.ComponentPropsWithoutRef<"a"> & { asChild?: boolean }
|
|
57
|
+
>(({ asChild, className, ...props }, ref) => {
|
|
58
|
+
const Comp = asChild ? Slot : "a";
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Comp
|
|
62
|
+
ref={ref}
|
|
63
|
+
className={cn("transition-colors hover:text-foreground", className)}
|
|
64
|
+
{...props}
|
|
65
|
+
/>
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
BreadcrumbLink.displayName = "BreadcrumbLink";
|
|
69
|
+
|
|
70
|
+
const BreadcrumbPage = forwardRef<
|
|
71
|
+
HTMLSpanElement,
|
|
72
|
+
React.ComponentPropsWithoutRef<"span">
|
|
73
|
+
>(({ className, ...props }, ref) => (
|
|
74
|
+
<span
|
|
75
|
+
ref={ref}
|
|
76
|
+
role="link"
|
|
77
|
+
aria-disabled="true"
|
|
78
|
+
aria-current="page"
|
|
79
|
+
className={cn("font-normal text-foreground", className)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
));
|
|
83
|
+
BreadcrumbPage.displayName = "BreadcrumbPage";
|
|
84
|
+
|
|
85
|
+
const BreadcrumbSeparator = ({
|
|
86
|
+
children,
|
|
87
|
+
className,
|
|
88
|
+
...props
|
|
89
|
+
}: React.ComponentProps<"li">) => (
|
|
90
|
+
<li
|
|
91
|
+
role="presentation"
|
|
92
|
+
aria-hidden="true"
|
|
93
|
+
className={cn("[&>svg]:h-3.5 [&>svg]:w-3.5", className)}
|
|
94
|
+
{...props}
|
|
95
|
+
>
|
|
96
|
+
{children ?? <ChevronRightIcon />}
|
|
97
|
+
</li>
|
|
98
|
+
);
|
|
99
|
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator";
|
|
100
|
+
|
|
101
|
+
const BreadcrumbEllipsis = ({
|
|
102
|
+
className,
|
|
103
|
+
...props
|
|
104
|
+
}: React.ComponentProps<"span">) => (
|
|
105
|
+
<span
|
|
106
|
+
role="presentation"
|
|
107
|
+
aria-hidden="true"
|
|
108
|
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
|
109
|
+
{...props}
|
|
110
|
+
>
|
|
111
|
+
<MoreHorizontalIcon className="h-4 w-4" />
|
|
112
|
+
<span className="sr-only">More</span>
|
|
113
|
+
</span>
|
|
114
|
+
);
|
|
115
|
+
BreadcrumbEllipsis.displayName = "BreadcrumbEllipsis";
|
|
116
|
+
|
|
117
|
+
export {
|
|
118
|
+
Breadcrumb,
|
|
119
|
+
BreadcrumbList,
|
|
120
|
+
BreadcrumbItem,
|
|
121
|
+
BreadcrumbLink,
|
|
122
|
+
BreadcrumbPage,
|
|
123
|
+
BreadcrumbSeparator,
|
|
124
|
+
BreadcrumbEllipsis,
|
|
125
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Breadcrumb,
|
|
3
|
+
BreadcrumbList,
|
|
4
|
+
BreadcrumbItem,
|
|
5
|
+
BreadcrumbLink,
|
|
6
|
+
BreadcrumbPage,
|
|
7
|
+
BreadcrumbSeparator,
|
|
8
|
+
BreadcrumbEllipsis,
|
|
9
|
+
} from "./Breadcrumb.native";
|
|
10
|
+
export type {
|
|
11
|
+
BreadcrumbProps,
|
|
12
|
+
BreadcrumbListProps,
|
|
13
|
+
BreadcrumbItemProps,
|
|
14
|
+
BreadcrumbLinkProps,
|
|
15
|
+
BreadcrumbPageProps,
|
|
16
|
+
BreadcrumbSeparatorProps,
|
|
17
|
+
BreadcrumbEllipsisProps,
|
|
18
|
+
} from "./Breadcrumb.types";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Breadcrumb,
|
|
3
|
+
BreadcrumbList,
|
|
4
|
+
BreadcrumbItem,
|
|
5
|
+
BreadcrumbLink,
|
|
6
|
+
BreadcrumbPage,
|
|
7
|
+
BreadcrumbSeparator,
|
|
8
|
+
BreadcrumbEllipsis,
|
|
9
|
+
} from "./Breadcrumb.web";
|
|
10
|
+
export type {
|
|
11
|
+
BreadcrumbProps,
|
|
12
|
+
BreadcrumbListProps,
|
|
13
|
+
BreadcrumbItemProps,
|
|
14
|
+
BreadcrumbLinkProps,
|
|
15
|
+
BreadcrumbPageProps,
|
|
16
|
+
BreadcrumbSeparatorProps,
|
|
17
|
+
BreadcrumbEllipsisProps,
|
|
18
|
+
} from "./Breadcrumb.types";
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Pressable, Text, type PressableProps } from "react-native";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import type { ButtonVariant, ButtonSize, ButtonProps } from "./Button.types";
|
|
4
|
+
import { cn } from "../../utils/cn";
|
|
5
|
+
import { GLASS_TEXT_DEFAULT, type GlassProps } from "../../utils/glass.native";
|
|
6
|
+
import { GlassWrapper, useGlassActive } from "../../utils/withGlass.native";
|
|
7
|
+
import { useTheme, remToNumber } from "../../theme/native";
|
|
8
|
+
|
|
9
|
+
interface ButtonNativeProps extends ButtonProps, GlassProps, Omit<PressableProps, "children" | "disabled" | "onPress"> {}
|
|
10
|
+
|
|
11
|
+
const BUTTON_BASE = "flex-row items-center justify-center rounded-md gap-2";
|
|
12
|
+
|
|
13
|
+
const SIZE_CLASSES: Record<ButtonSize, string> = {
|
|
14
|
+
default: "h-9 px-4 py-2",
|
|
15
|
+
sm: "h-8 px-3",
|
|
16
|
+
lg: "h-10 px-8",
|
|
17
|
+
icon: "h-9 w-9",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const VARIANT_CLASSES: Record<ButtonVariant, string> = {
|
|
21
|
+
default: "bg-primary shadow elevation-1",
|
|
22
|
+
destructive: "bg-destructive shadow-sm elevation-1",
|
|
23
|
+
outline: "bg-transparent border border-input shadow-sm elevation-1",
|
|
24
|
+
secondary: "bg-secondary shadow-sm elevation-1",
|
|
25
|
+
ghost: "bg-transparent",
|
|
26
|
+
link: "bg-transparent",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const buttonContainerVariants = cva(BUTTON_BASE, {
|
|
30
|
+
variants: {
|
|
31
|
+
variant: VARIANT_CLASSES satisfies Record<ButtonVariant, string>,
|
|
32
|
+
size: SIZE_CLASSES satisfies Record<ButtonSize, string>,
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: "default",
|
|
36
|
+
size: "default",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const buttonTextVariants = cva("font-medium leading-tight", {
|
|
41
|
+
variants: {
|
|
42
|
+
variant: {
|
|
43
|
+
default: "text-primary-foreground",
|
|
44
|
+
destructive: "text-destructive-foreground",
|
|
45
|
+
outline: "text-foreground",
|
|
46
|
+
secondary: "text-secondary-foreground",
|
|
47
|
+
ghost: "text-foreground",
|
|
48
|
+
link: "text-foreground underline",
|
|
49
|
+
} satisfies Record<ButtonVariant, string>,
|
|
50
|
+
size: {
|
|
51
|
+
default: "text-sm",
|
|
52
|
+
sm: "text-xs",
|
|
53
|
+
lg: "text-sm",
|
|
54
|
+
icon: "text-sm",
|
|
55
|
+
} satisfies Record<ButtonSize, string>,
|
|
56
|
+
},
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
variant: "default",
|
|
59
|
+
size: "default",
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
function ButtonContent({
|
|
64
|
+
variant = "default",
|
|
65
|
+
size = "default",
|
|
66
|
+
disabled,
|
|
67
|
+
children,
|
|
68
|
+
onPress,
|
|
69
|
+
className,
|
|
70
|
+
glassTextColor = GLASS_TEXT_DEFAULT,
|
|
71
|
+
...props
|
|
72
|
+
}: Omit<ButtonNativeProps, "glass" | "glassEffect">) {
|
|
73
|
+
const glassActive = useGlassActive();
|
|
74
|
+
|
|
75
|
+
const containerClassName = glassActive
|
|
76
|
+
? cn(BUTTON_BASE, SIZE_CLASSES[size], disabled && "opacity-50", className)
|
|
77
|
+
: cn(buttonContainerVariants({ variant, size }), disabled && "opacity-50", className);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<Pressable
|
|
81
|
+
onPress={onPress}
|
|
82
|
+
disabled={disabled}
|
|
83
|
+
className={containerClassName}
|
|
84
|
+
{...props}
|
|
85
|
+
>
|
|
86
|
+
{typeof children === "string" ? (
|
|
87
|
+
<Text className={cn(
|
|
88
|
+
buttonTextVariants({ size }),
|
|
89
|
+
glassActive ? glassTextColor : buttonTextVariants({ variant }),
|
|
90
|
+
)}>
|
|
91
|
+
{children}
|
|
92
|
+
</Text>
|
|
93
|
+
) : (
|
|
94
|
+
children
|
|
95
|
+
)}
|
|
96
|
+
</Pressable>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function Button({
|
|
101
|
+
glass,
|
|
102
|
+
glassEffect,
|
|
103
|
+
glassTextColor,
|
|
104
|
+
...props
|
|
105
|
+
}: ButtonNativeProps) {
|
|
106
|
+
const { tokens, glass: themeGlass } = useTheme();
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<GlassWrapper enabled={glass ?? themeGlass} effect={glassEffect} style={{ borderRadius: remToNumber(tokens.radius.md) }}>
|
|
110
|
+
<ButtonContent glassTextColor={glassTextColor} {...props} />
|
|
111
|
+
</GlassWrapper>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Button.displayName = "Button";
|
|
116
|
+
|
|
117
|
+
export { Button, buttonContainerVariants, buttonTextVariants };
|
|
118
|
+
export type { ButtonNativeProps };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Button } from "./Button.web";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Components/Button",
|
|
6
|
+
component: Button,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
argTypes: {
|
|
12
|
+
variant: {
|
|
13
|
+
control: "select",
|
|
14
|
+
options: ["default", "destructive", "outline", "secondary", "ghost", "link"],
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
control: "select",
|
|
18
|
+
options: ["default", "sm", "lg", "icon"],
|
|
19
|
+
},
|
|
20
|
+
disabled: {
|
|
21
|
+
control: "boolean",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
} satisfies Meta<typeof Button>;
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
type Story = StoryObj<typeof meta>;
|
|
28
|
+
|
|
29
|
+
export const Default: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
children: "Button",
|
|
32
|
+
variant: "default",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Secondary: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
children: "Secondary",
|
|
39
|
+
variant: "secondary",
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const Destructive: Story = {
|
|
44
|
+
args: {
|
|
45
|
+
children: "Destructive",
|
|
46
|
+
variant: "destructive",
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Outline: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
children: "Outline",
|
|
53
|
+
variant: "outline",
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Ghost: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
children: "Ghost",
|
|
60
|
+
variant: "ghost",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const Link: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
children: "Link",
|
|
67
|
+
variant: "link",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const Small: Story = {
|
|
72
|
+
args: {
|
|
73
|
+
children: "Small",
|
|
74
|
+
size: "sm",
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const Large: Story = {
|
|
79
|
+
args: {
|
|
80
|
+
children: "Large",
|
|
81
|
+
size: "lg",
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const Icon: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
children: "+",
|
|
88
|
+
size: "icon",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const Disabled: Story = {
|
|
93
|
+
args: {
|
|
94
|
+
children: "Disabled",
|
|
95
|
+
disabled: true,
|
|
96
|
+
},
|
|
97
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ButtonVariant =
|
|
2
|
+
| "default"
|
|
3
|
+
| "destructive"
|
|
4
|
+
| "outline"
|
|
5
|
+
| "secondary"
|
|
6
|
+
| "ghost"
|
|
7
|
+
| "link";
|
|
8
|
+
|
|
9
|
+
export type ButtonSize = "default" | "sm" | "lg" | "icon";
|
|
10
|
+
|
|
11
|
+
export interface ButtonProps {
|
|
12
|
+
variant?: ButtonVariant;
|
|
13
|
+
size?: ButtonSize;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
onPress?: () => void;
|
|
17
|
+
className?: string;
|
|
18
|
+
asChild?: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Button, buttonVariants } from "./Button.web";
|
|
4
|
+
|
|
5
|
+
describe("Button", () => {
|
|
6
|
+
it("renders with children", () => {
|
|
7
|
+
render(<Button>Click me</Button>);
|
|
8
|
+
expect(screen.getByRole("button", { name: "Click me" })).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("merges custom className", () => {
|
|
12
|
+
render(<Button className="custom-class">btn</Button>);
|
|
13
|
+
expect(screen.getByRole("button").className).toContain("custom-class");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("applies default variant classes", () => {
|
|
17
|
+
render(<Button>btn</Button>);
|
|
18
|
+
const el = screen.getByRole("button");
|
|
19
|
+
expect(el.className).toContain("bg-primary");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("applies destructive variant", () => {
|
|
23
|
+
render(<Button variant="destructive">btn</Button>);
|
|
24
|
+
expect(screen.getByRole("button").className).toContain("bg-destructive");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("applies outline variant", () => {
|
|
28
|
+
render(<Button variant="outline">btn</Button>);
|
|
29
|
+
expect(screen.getByRole("button").className).toContain("border");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("applies size variants", () => {
|
|
33
|
+
render(<Button size="sm">btn</Button>);
|
|
34
|
+
expect(screen.getByRole("button").className).toContain("h-8");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("applies icon size", () => {
|
|
38
|
+
render(<Button size="icon">btn</Button>);
|
|
39
|
+
expect(screen.getByRole("button").className).toContain("w-9");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("forwards disabled prop", () => {
|
|
43
|
+
render(<Button disabled>btn</Button>);
|
|
44
|
+
expect(screen.getByRole("button")).toHaveProperty("disabled", true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("renders as child element when asChild", () => {
|
|
48
|
+
render(
|
|
49
|
+
<Button asChild>
|
|
50
|
+
<a href="/test">link</a>
|
|
51
|
+
</Button>,
|
|
52
|
+
);
|
|
53
|
+
const link = screen.getByRole("link", { name: "link" });
|
|
54
|
+
expect(link.tagName).toBe("A");
|
|
55
|
+
expect(link.className).toContain("bg-primary");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("forwards ref", () => {
|
|
59
|
+
let ref: HTMLButtonElement | null = null;
|
|
60
|
+
render(<Button ref={(el) => { ref = el; }}>btn</Button>);
|
|
61
|
+
expect(ref).toBeInstanceOf(HTMLButtonElement);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("buttonVariants generates correct classes", () => {
|
|
65
|
+
const classes = buttonVariants({ variant: "ghost", size: "lg" });
|
|
66
|
+
expect(classes).toContain("hover:bg-accent");
|
|
67
|
+
expect(classes).toContain("h-10");
|
|
68
|
+
});
|
|
69
|
+
});
|