@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,44 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { AspectRatio } from "./AspectRatio.web";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Components/AspectRatio",
|
|
6
|
+
component: AspectRatio,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
} satisfies Meta<typeof AspectRatio>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
ratio: 16 / 9,
|
|
19
|
+
children: (
|
|
20
|
+
<div
|
|
21
|
+
style={{
|
|
22
|
+
width: "100%",
|
|
23
|
+
height: "100%",
|
|
24
|
+
backgroundColor: "#e2e8f0",
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
borderRadius: 8,
|
|
29
|
+
color: "#64748b",
|
|
30
|
+
fontSize: 14,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
16 : 9
|
|
34
|
+
</div>
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
decorators: [
|
|
38
|
+
(Story) => (
|
|
39
|
+
<div style={{ width: 480 }}>
|
|
40
|
+
<Story />
|
|
41
|
+
</div>
|
|
42
|
+
),
|
|
43
|
+
],
|
|
44
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { useAspectRatio } from "./useAspectRatio";
|
|
3
|
+
|
|
4
|
+
describe("useAspectRatio", () => {
|
|
5
|
+
it("defaults to ratio 1 and width 0", () => {
|
|
6
|
+
const result = useAspectRatio();
|
|
7
|
+
expect(result.height).toBe(0);
|
|
8
|
+
expect(result.isReady).toBe(false);
|
|
9
|
+
expect(result.safeRatio).toBe(1);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("computes height from width and ratio", () => {
|
|
13
|
+
const result = useAspectRatio({ width: 200, ratio: 16 / 9 });
|
|
14
|
+
expect(result.height).toBeCloseTo(112.5);
|
|
15
|
+
expect(result.isReady).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("returns height equal to width when ratio is 1", () => {
|
|
19
|
+
const result = useAspectRatio({ width: 100, ratio: 1 });
|
|
20
|
+
expect(result.height).toBe(100);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("returns 0 height when width is 0", () => {
|
|
24
|
+
const result = useAspectRatio({ width: 0, ratio: 16 / 9 });
|
|
25
|
+
expect(result.height).toBe(0);
|
|
26
|
+
expect(result.isReady).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("falls back to ratio 1 when ratio is 0", () => {
|
|
30
|
+
const result = useAspectRatio({ width: 100, ratio: 0 });
|
|
31
|
+
expect(result.safeRatio).toBe(1);
|
|
32
|
+
expect(result.height).toBe(100);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("falls back to ratio 1 when ratio is negative", () => {
|
|
36
|
+
const result = useAspectRatio({ width: 100, ratio: -2 });
|
|
37
|
+
expect(result.safeRatio).toBe(1);
|
|
38
|
+
expect(result.height).toBe(100);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface UseAspectRatioProps {
|
|
2
|
+
ratio?: number;
|
|
3
|
+
width?: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function useAspectRatio({ ratio = 1, width = 0 }: UseAspectRatioProps = {}) {
|
|
7
|
+
const safeRatio = ratio > 0 ? ratio : 1;
|
|
8
|
+
const height = width > 0 ? width / safeRatio : 0;
|
|
9
|
+
const isReady = width > 0;
|
|
10
|
+
|
|
11
|
+
return { height, isReady, safeRatio };
|
|
12
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Image,
|
|
3
|
+
Text,
|
|
4
|
+
View,
|
|
5
|
+
type ViewProps,
|
|
6
|
+
type ImageProps,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
import { cn } from "../../utils/cn";
|
|
9
|
+
import type {
|
|
10
|
+
AvatarProps,
|
|
11
|
+
AvatarImageProps,
|
|
12
|
+
AvatarFallbackProps,
|
|
13
|
+
} from "./Avatar.types";
|
|
14
|
+
import { useAvatarImage } from "./useAvatarImage";
|
|
15
|
+
|
|
16
|
+
// --- Avatar ---
|
|
17
|
+
|
|
18
|
+
interface AvatarNativeProps extends AvatarProps, ViewProps {}
|
|
19
|
+
|
|
20
|
+
function Avatar({ children, className, ...props }: AvatarNativeProps) {
|
|
21
|
+
return (
|
|
22
|
+
<View
|
|
23
|
+
className={cn("relative h-10 w-10 rounded-full overflow-hidden", className)}
|
|
24
|
+
{...props}
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
</View>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
Avatar.displayName = "Avatar";
|
|
31
|
+
|
|
32
|
+
// --- AvatarImage ---
|
|
33
|
+
|
|
34
|
+
interface AvatarImageNativeProps extends AvatarImageProps, Omit<ImageProps, "source"> {}
|
|
35
|
+
|
|
36
|
+
function AvatarImage({
|
|
37
|
+
src,
|
|
38
|
+
alt,
|
|
39
|
+
className,
|
|
40
|
+
onLoadingStatusChange,
|
|
41
|
+
...props
|
|
42
|
+
}: AvatarImageNativeProps) {
|
|
43
|
+
const { showImage, onLoad, onError, onLoadStart } = useAvatarImage({
|
|
44
|
+
src,
|
|
45
|
+
onLoadingStatusChange,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (!showImage) return null;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Image
|
|
52
|
+
source={{ uri: src }}
|
|
53
|
+
accessibilityLabel={alt}
|
|
54
|
+
onLoad={onLoad}
|
|
55
|
+
onError={onError}
|
|
56
|
+
onLoadStart={onLoadStart}
|
|
57
|
+
className={cn("h-full w-full", className)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
AvatarImage.displayName = "AvatarImage";
|
|
63
|
+
|
|
64
|
+
// --- AvatarFallback ---
|
|
65
|
+
|
|
66
|
+
interface AvatarFallbackNativeProps extends AvatarFallbackProps, ViewProps {}
|
|
67
|
+
|
|
68
|
+
function AvatarFallback({
|
|
69
|
+
children,
|
|
70
|
+
className,
|
|
71
|
+
...props
|
|
72
|
+
}: AvatarFallbackNativeProps) {
|
|
73
|
+
return (
|
|
74
|
+
<View
|
|
75
|
+
className={cn("flex-1 items-center justify-center bg-muted rounded-full", className)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{typeof children === "string" ? (
|
|
79
|
+
<Text className="text-sm font-medium text-foreground">
|
|
80
|
+
{children}
|
|
81
|
+
</Text>
|
|
82
|
+
) : (
|
|
83
|
+
children
|
|
84
|
+
)}
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
AvatarFallback.displayName = "AvatarFallback";
|
|
89
|
+
|
|
90
|
+
export { Avatar, AvatarImage, AvatarFallback };
|
|
91
|
+
export type {
|
|
92
|
+
AvatarNativeProps,
|
|
93
|
+
AvatarImageNativeProps,
|
|
94
|
+
AvatarFallbackNativeProps,
|
|
95
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Avatar, AvatarImage, AvatarFallback } from "./Avatar.web";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Components/Avatar",
|
|
6
|
+
component: Avatar,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
} satisfies Meta<typeof Avatar>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const WithImage: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
children: (
|
|
19
|
+
<>
|
|
20
|
+
<AvatarImage src="https://github.com/shadcn.png" alt="@shadcn" />
|
|
21
|
+
<AvatarFallback>CN</AvatarFallback>
|
|
22
|
+
</>
|
|
23
|
+
),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const WithFallback: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
children: <AvatarFallback>CN</AvatarFallback>,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface AvatarProps {
|
|
2
|
+
children?: React.ReactNode;
|
|
3
|
+
className?: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface AvatarImageProps {
|
|
7
|
+
src?: string;
|
|
8
|
+
alt?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
onLoadingStatusChange?: (status: "idle" | "loading" | "loaded" | "error") => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AvatarFallbackProps {
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
delayMs?: number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
const Avatar = forwardRef<
|
|
6
|
+
React.ComponentRef<typeof AvatarPrimitive.Root>,
|
|
7
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
|
|
8
|
+
>(({ className, ...props }, ref) => (
|
|
9
|
+
<AvatarPrimitive.Root
|
|
10
|
+
ref={ref}
|
|
11
|
+
className={cn(
|
|
12
|
+
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
|
13
|
+
className,
|
|
14
|
+
)}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
));
|
|
18
|
+
Avatar.displayName = AvatarPrimitive.Root.displayName;
|
|
19
|
+
|
|
20
|
+
const AvatarImage = forwardRef<
|
|
21
|
+
React.ComponentRef<typeof AvatarPrimitive.Image>,
|
|
22
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
|
|
23
|
+
>(({ className, ...props }, ref) => (
|
|
24
|
+
<AvatarPrimitive.Image
|
|
25
|
+
ref={ref}
|
|
26
|
+
className={cn("aspect-square h-full w-full", className)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
));
|
|
30
|
+
AvatarImage.displayName = AvatarPrimitive.Image.displayName;
|
|
31
|
+
|
|
32
|
+
const AvatarFallback = forwardRef<
|
|
33
|
+
React.ComponentRef<typeof AvatarPrimitive.Fallback>,
|
|
34
|
+
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
|
|
35
|
+
>(({ className, ...props }, ref) => (
|
|
36
|
+
<AvatarPrimitive.Fallback
|
|
37
|
+
ref={ref}
|
|
38
|
+
className={cn(
|
|
39
|
+
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
{...props}
|
|
43
|
+
/>
|
|
44
|
+
));
|
|
45
|
+
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
|
|
46
|
+
|
|
47
|
+
export { Avatar, AvatarImage, AvatarFallback };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import { useAvatarImage } from "./useAvatarImage";
|
|
4
|
+
|
|
5
|
+
describe("useAvatarImage", () => {
|
|
6
|
+
it("starts in error status when no src", () => {
|
|
7
|
+
const { result } = renderHook(() => useAvatarImage());
|
|
8
|
+
expect(result.current.status).toBe("error");
|
|
9
|
+
expect(result.current.showImage).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("starts in idle status when src is provided", () => {
|
|
13
|
+
const { result } = renderHook(() => useAvatarImage({ src: "https://example.com/avatar.png" }));
|
|
14
|
+
expect(result.current.status).toBe("idle");
|
|
15
|
+
expect(result.current.showImage).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("transitions to loading on loadStart", () => {
|
|
19
|
+
const { result } = renderHook(() => useAvatarImage({ src: "https://example.com/avatar.png" }));
|
|
20
|
+
act(() => result.current.onLoadStart());
|
|
21
|
+
expect(result.current.status).toBe("loading");
|
|
22
|
+
expect(result.current.showImage).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("transitions to loaded on load", () => {
|
|
26
|
+
const { result } = renderHook(() => useAvatarImage({ src: "https://example.com/avatar.png" }));
|
|
27
|
+
act(() => result.current.onLoad());
|
|
28
|
+
expect(result.current.status).toBe("loaded");
|
|
29
|
+
expect(result.current.showImage).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("transitions to error on error", () => {
|
|
33
|
+
const { result } = renderHook(() => useAvatarImage({ src: "https://example.com/avatar.png" }));
|
|
34
|
+
act(() => result.current.onError());
|
|
35
|
+
expect(result.current.status).toBe("error");
|
|
36
|
+
expect(result.current.showImage).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("calls onLoadingStatusChange callback", () => {
|
|
40
|
+
const callback = vi.fn();
|
|
41
|
+
const { result } = renderHook(() =>
|
|
42
|
+
useAvatarImage({ src: "https://example.com/avatar.png", onLoadingStatusChange: callback }),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
act(() => result.current.onLoadStart());
|
|
46
|
+
expect(callback).toHaveBeenCalledWith("loading");
|
|
47
|
+
|
|
48
|
+
act(() => result.current.onLoad());
|
|
49
|
+
expect(callback).toHaveBeenCalledWith("loaded");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("calls onLoadingStatusChange with error", () => {
|
|
53
|
+
const callback = vi.fn();
|
|
54
|
+
const { result } = renderHook(() =>
|
|
55
|
+
useAvatarImage({ src: "https://example.com/avatar.png", onLoadingStatusChange: callback }),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
act(() => result.current.onError());
|
|
59
|
+
expect(callback).toHaveBeenCalledWith("error");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("showImage is false when src is empty string", () => {
|
|
63
|
+
const { result } = renderHook(() => useAvatarImage({ src: "" }));
|
|
64
|
+
expect(result.current.showImage).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
|
|
3
|
+
type ImageLoadingStatus = "idle" | "loading" | "loaded" | "error";
|
|
4
|
+
|
|
5
|
+
interface UseAvatarImageProps {
|
|
6
|
+
src?: string;
|
|
7
|
+
onLoadingStatusChange?: (status: ImageLoadingStatus) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useAvatarImage({ src, onLoadingStatusChange }: UseAvatarImageProps = {}) {
|
|
11
|
+
const [status, setStatus] = useState<ImageLoadingStatus>(src ? "idle" : "error");
|
|
12
|
+
|
|
13
|
+
const onLoadStart = useCallback(() => {
|
|
14
|
+
setStatus("loading");
|
|
15
|
+
onLoadingStatusChange?.("loading");
|
|
16
|
+
}, [onLoadingStatusChange]);
|
|
17
|
+
|
|
18
|
+
const onLoad = useCallback(() => {
|
|
19
|
+
setStatus("loaded");
|
|
20
|
+
onLoadingStatusChange?.("loaded");
|
|
21
|
+
}, [onLoadingStatusChange]);
|
|
22
|
+
|
|
23
|
+
const onError = useCallback(() => {
|
|
24
|
+
setStatus("error");
|
|
25
|
+
onLoadingStatusChange?.("error");
|
|
26
|
+
}, [onLoadingStatusChange]);
|
|
27
|
+
|
|
28
|
+
const showImage = !!src && status !== "error";
|
|
29
|
+
|
|
30
|
+
return { status, showImage, onLoadStart, onLoad, onError };
|
|
31
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { View, Text, type ViewProps } from "react-native";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import type { BadgeVariant, BadgeProps } from "./Badge.types";
|
|
4
|
+
import { cn } from "../../utils/cn";
|
|
5
|
+
|
|
6
|
+
interface BadgeNativeProps extends BadgeProps, ViewProps {}
|
|
7
|
+
|
|
8
|
+
const badgeContainerVariants = cva(
|
|
9
|
+
"flex-row items-center rounded-md border px-2.5 py-0.5 self-start",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: "bg-primary border-transparent shadow elevation-1",
|
|
14
|
+
secondary: "bg-secondary border-transparent",
|
|
15
|
+
destructive: "bg-destructive border-transparent shadow elevation-1",
|
|
16
|
+
outline: "bg-transparent border-border",
|
|
17
|
+
} satisfies Record<BadgeVariant, string>,
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
variant: "default",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const badgeTextVariants = cva("text-xs font-semibold", {
|
|
26
|
+
variants: {
|
|
27
|
+
variant: {
|
|
28
|
+
default: "text-primary-foreground",
|
|
29
|
+
secondary: "text-secondary-foreground",
|
|
30
|
+
destructive: "text-destructive-foreground",
|
|
31
|
+
outline: "text-foreground",
|
|
32
|
+
} satisfies Record<BadgeVariant, string>,
|
|
33
|
+
},
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
variant: "default",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function Badge({
|
|
40
|
+
variant = "default",
|
|
41
|
+
children,
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
}: BadgeNativeProps) {
|
|
45
|
+
return (
|
|
46
|
+
<View
|
|
47
|
+
className={cn(badgeContainerVariants({ variant }), className)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{typeof children === "string" ? (
|
|
51
|
+
<Text className={cn(badgeTextVariants({ variant }))}>
|
|
52
|
+
{children}
|
|
53
|
+
</Text>
|
|
54
|
+
) : (
|
|
55
|
+
children
|
|
56
|
+
)}
|
|
57
|
+
</View>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Badge.displayName = "Badge";
|
|
62
|
+
|
|
63
|
+
export { Badge, badgeContainerVariants, badgeTextVariants };
|
|
64
|
+
export type { BadgeNativeProps };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Badge } from "./Badge.web";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Components/Badge",
|
|
6
|
+
component: Badge,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
} satisfies Meta<typeof Badge>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
children: "Badge",
|
|
19
|
+
variant: "default",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const Secondary: Story = {
|
|
24
|
+
args: {
|
|
25
|
+
children: "Secondary",
|
|
26
|
+
variant: "secondary",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Destructive: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
children: "Destructive",
|
|
33
|
+
variant: "destructive",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Outline: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
children: "Outline",
|
|
40
|
+
variant: "outline",
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { Badge, badgeVariants } from "./Badge.web";
|
|
4
|
+
|
|
5
|
+
describe("Badge", () => {
|
|
6
|
+
it("renders with children", () => {
|
|
7
|
+
render(<Badge>Status</Badge>);
|
|
8
|
+
expect(screen.getByText("Status")).toBeDefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("applies default variant", () => {
|
|
12
|
+
render(<Badge>tag</Badge>);
|
|
13
|
+
expect(screen.getByText("tag").className).toContain("bg-primary");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("applies destructive variant", () => {
|
|
17
|
+
render(<Badge variant="destructive">err</Badge>);
|
|
18
|
+
expect(screen.getByText("err").className).toContain("bg-destructive");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("applies secondary variant", () => {
|
|
22
|
+
render(<Badge variant="secondary">sec</Badge>);
|
|
23
|
+
expect(screen.getByText("sec").className).toContain("bg-secondary");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("applies outline variant", () => {
|
|
27
|
+
render(<Badge variant="outline">out</Badge>);
|
|
28
|
+
expect(screen.getByText("out").className).toContain("text-foreground");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("merges custom className", () => {
|
|
32
|
+
render(<Badge className="my-class">tag</Badge>);
|
|
33
|
+
expect(screen.getByText("tag").className).toContain("my-class");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("badgeVariants generates correct classes", () => {
|
|
37
|
+
const classes = badgeVariants({ variant: "destructive" });
|
|
38
|
+
expect(classes).toContain("bg-destructive");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
import type { BadgeVariant, BadgeProps } from "./Badge.types";
|
|
5
|
+
|
|
6
|
+
const badgeVariants = cva(
|
|
7
|
+
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default:
|
|
12
|
+
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
|
|
13
|
+
secondary:
|
|
14
|
+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
15
|
+
destructive:
|
|
16
|
+
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
|
|
17
|
+
outline: "text-foreground",
|
|
18
|
+
} satisfies Record<BadgeVariant, string>,
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
variant: "default",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export interface BadgeWebProps
|
|
27
|
+
extends BadgeProps,
|
|
28
|
+
React.HTMLAttributes<HTMLDivElement> {}
|
|
29
|
+
|
|
30
|
+
const Badge = forwardRef<HTMLDivElement, BadgeWebProps>(
|
|
31
|
+
({ className, variant, ...props }, ref) => (
|
|
32
|
+
<div
|
|
33
|
+
ref={ref}
|
|
34
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
Badge.displayName = "Badge";
|
|
40
|
+
|
|
41
|
+
export { Badge, badgeVariants };
|