@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,21 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { cn } from "../../utils/cn";
|
|
3
|
+
|
|
4
|
+
const Textarea = forwardRef<
|
|
5
|
+
HTMLTextAreaElement,
|
|
6
|
+
React.TextareaHTMLAttributes<HTMLTextAreaElement>
|
|
7
|
+
>(({ className, ...props }, ref) => {
|
|
8
|
+
return (
|
|
9
|
+
<textarea
|
|
10
|
+
className={cn(
|
|
11
|
+
"flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
ref={ref}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
Textarea.displayName = "Textarea";
|
|
20
|
+
|
|
21
|
+
export { Textarea };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useRef,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
} from "react";
|
|
6
|
+
import {
|
|
7
|
+
View,
|
|
8
|
+
Text,
|
|
9
|
+
Pressable,
|
|
10
|
+
Animated,
|
|
11
|
+
} from "react-native";
|
|
12
|
+
import { cva } from "class-variance-authority";
|
|
13
|
+
import { cn } from "../../utils/cn";
|
|
14
|
+
import { toast, useToast, type ToasterToast } from "./useToast";
|
|
15
|
+
import type {
|
|
16
|
+
ToastVariant,
|
|
17
|
+
ToastProps,
|
|
18
|
+
ToastProviderProps,
|
|
19
|
+
ToastViewportProps,
|
|
20
|
+
ToastTitleProps,
|
|
21
|
+
ToastDescriptionProps,
|
|
22
|
+
ToastActionProps,
|
|
23
|
+
ToastCloseProps,
|
|
24
|
+
} from "./Toast.types";
|
|
25
|
+
|
|
26
|
+
const toastContainerVariants = cva(
|
|
27
|
+
"flex-row items-center justify-between bg-background rounded-lg border-[0.5px] border-border p-4 shadow-lg elevation-5",
|
|
28
|
+
{
|
|
29
|
+
variants: {
|
|
30
|
+
variant: {
|
|
31
|
+
default: "",
|
|
32
|
+
destructive: "bg-destructive border-destructive",
|
|
33
|
+
} satisfies Record<ToastVariant, string>,
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
variant: "default",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const toastTitleVariants = cva("text-sm font-semibold", {
|
|
42
|
+
variants: {
|
|
43
|
+
variant: {
|
|
44
|
+
default: "text-foreground",
|
|
45
|
+
destructive: "text-destructive-foreground",
|
|
46
|
+
} satisfies Record<ToastVariant, string>,
|
|
47
|
+
},
|
|
48
|
+
defaultVariants: {
|
|
49
|
+
variant: "default",
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const toastDescriptionVariants = cva("text-[13px] mt-0.5", {
|
|
54
|
+
variants: {
|
|
55
|
+
variant: {
|
|
56
|
+
default: "text-muted-foreground",
|
|
57
|
+
destructive: "text-destructive-foreground",
|
|
58
|
+
} satisfies Record<ToastVariant, string>,
|
|
59
|
+
},
|
|
60
|
+
defaultVariants: {
|
|
61
|
+
variant: "default",
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const toastCloseVariants = cva("text-lg", {
|
|
66
|
+
variants: {
|
|
67
|
+
variant: {
|
|
68
|
+
default: "text-muted-foreground",
|
|
69
|
+
destructive: "text-destructive-foreground",
|
|
70
|
+
} satisfies Record<ToastVariant, string>,
|
|
71
|
+
},
|
|
72
|
+
defaultVariants: {
|
|
73
|
+
variant: "default",
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// ---- Toast UI Components ----
|
|
78
|
+
|
|
79
|
+
function ToastProvider({ children }: ToastProviderProps) {
|
|
80
|
+
return <>{children}</>;
|
|
81
|
+
}
|
|
82
|
+
ToastProvider.displayName = "ToastProvider";
|
|
83
|
+
|
|
84
|
+
function ToastViewport({ children, className }: ToastViewportProps & { children?: ReactNode }) {
|
|
85
|
+
const { toasts, dismiss } = useToast();
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<View
|
|
89
|
+
className={cn(
|
|
90
|
+
"absolute top-0 left-0 right-0 z-[100] p-4 gap-2",
|
|
91
|
+
className,
|
|
92
|
+
)}
|
|
93
|
+
style={{ paddingTop: 50 }}
|
|
94
|
+
>
|
|
95
|
+
{toasts.map((t) => (
|
|
96
|
+
<ToastItem key={t.id} toast={t} onDismiss={() => dismiss(t.id)} />
|
|
97
|
+
))}
|
|
98
|
+
{children}
|
|
99
|
+
</View>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
ToastViewport.displayName = "ToastViewport";
|
|
103
|
+
|
|
104
|
+
function ToastItem({ toast: t, onDismiss }: { toast: ToasterToast; onDismiss: () => void }) {
|
|
105
|
+
const translateY = useRef(new Animated.Value(-100)).current;
|
|
106
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
Animated.parallel([
|
|
110
|
+
Animated.spring(translateY, {
|
|
111
|
+
toValue: 0,
|
|
112
|
+
useNativeDriver: true,
|
|
113
|
+
damping: 15,
|
|
114
|
+
stiffness: 150,
|
|
115
|
+
}),
|
|
116
|
+
Animated.timing(opacity, {
|
|
117
|
+
toValue: 1,
|
|
118
|
+
duration: 200,
|
|
119
|
+
useNativeDriver: true,
|
|
120
|
+
}),
|
|
121
|
+
]).start();
|
|
122
|
+
|
|
123
|
+
const duration = t.duration ?? 5000;
|
|
124
|
+
const timer = setTimeout(() => {
|
|
125
|
+
Animated.parallel([
|
|
126
|
+
Animated.timing(translateY, {
|
|
127
|
+
toValue: -100,
|
|
128
|
+
duration: 300,
|
|
129
|
+
useNativeDriver: true,
|
|
130
|
+
}),
|
|
131
|
+
Animated.timing(opacity, {
|
|
132
|
+
toValue: 0,
|
|
133
|
+
duration: 300,
|
|
134
|
+
useNativeDriver: true,
|
|
135
|
+
}),
|
|
136
|
+
]).start(() => onDismiss());
|
|
137
|
+
}, duration);
|
|
138
|
+
|
|
139
|
+
return () => clearTimeout(timer);
|
|
140
|
+
}, [translateY, opacity, t.duration, onDismiss]);
|
|
141
|
+
|
|
142
|
+
const variant = t.variant ?? "default";
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<Animated.View
|
|
146
|
+
className={cn(toastContainerVariants({ variant }))}
|
|
147
|
+
style={[
|
|
148
|
+
{ transform: [{ translateY }], opacity },
|
|
149
|
+
]}
|
|
150
|
+
>
|
|
151
|
+
<View className="flex-1 mr-2">
|
|
152
|
+
{t.title && (
|
|
153
|
+
<Text className={cn(toastTitleVariants({ variant }))}>
|
|
154
|
+
{t.title}
|
|
155
|
+
</Text>
|
|
156
|
+
)}
|
|
157
|
+
{t.description && (
|
|
158
|
+
<Text className={cn(toastDescriptionVariants({ variant }))}>
|
|
159
|
+
{t.description}
|
|
160
|
+
</Text>
|
|
161
|
+
)}
|
|
162
|
+
</View>
|
|
163
|
+
<View className="flex-row items-center gap-1">
|
|
164
|
+
{t.action && (
|
|
165
|
+
<Pressable
|
|
166
|
+
className="px-3 py-1.5 rounded-sm border-[0.5px] border-border"
|
|
167
|
+
onPress={t.action.onPress}
|
|
168
|
+
>
|
|
169
|
+
<Text className="text-xs font-medium text-foreground">
|
|
170
|
+
{t.action.label}
|
|
171
|
+
</Text>
|
|
172
|
+
</Pressable>
|
|
173
|
+
)}
|
|
174
|
+
<Pressable onPress={onDismiss} className="p-1">
|
|
175
|
+
<Text className={cn(toastCloseVariants({ variant }))}>
|
|
176
|
+
×
|
|
177
|
+
</Text>
|
|
178
|
+
</Pressable>
|
|
179
|
+
</View>
|
|
180
|
+
</Animated.View>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function Toast({ children, className }: ToastProps) {
|
|
185
|
+
return (
|
|
186
|
+
<View
|
|
187
|
+
className={cn(
|
|
188
|
+
"flex-row items-center justify-between bg-background rounded-lg border border-border p-4 shadow-lg elevation-5",
|
|
189
|
+
className,
|
|
190
|
+
)}
|
|
191
|
+
>
|
|
192
|
+
{children}
|
|
193
|
+
</View>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
Toast.displayName = "Toast";
|
|
197
|
+
|
|
198
|
+
function ToastTitle({ children, className }: ToastTitleProps) {
|
|
199
|
+
return (
|
|
200
|
+
<Text className={cn("text-sm font-semibold text-foreground", className)}>
|
|
201
|
+
{children}
|
|
202
|
+
</Text>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
ToastTitle.displayName = "ToastTitle";
|
|
206
|
+
|
|
207
|
+
function ToastDescription({ children, className }: ToastDescriptionProps) {
|
|
208
|
+
return (
|
|
209
|
+
<Text className={cn("text-[13px] text-muted-foreground mt-0.5", className)}>
|
|
210
|
+
{children}
|
|
211
|
+
</Text>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
ToastDescription.displayName = "ToastDescription";
|
|
215
|
+
|
|
216
|
+
interface ToastActionNativeProps extends ToastActionProps {
|
|
217
|
+
onPress?: () => void;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function ToastAction({
|
|
221
|
+
children,
|
|
222
|
+
onPress,
|
|
223
|
+
className,
|
|
224
|
+
}: ToastActionNativeProps) {
|
|
225
|
+
return (
|
|
226
|
+
<Pressable
|
|
227
|
+
className={cn(
|
|
228
|
+
"px-3 py-1.5 rounded-sm border border-border",
|
|
229
|
+
className,
|
|
230
|
+
)}
|
|
231
|
+
onPress={onPress}
|
|
232
|
+
>
|
|
233
|
+
{children}
|
|
234
|
+
</Pressable>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
ToastAction.displayName = "ToastAction";
|
|
238
|
+
|
|
239
|
+
interface ToastCloseNativeProps extends ToastCloseProps {
|
|
240
|
+
onPress?: () => void;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function ToastClose({ onPress }: ToastCloseNativeProps) {
|
|
244
|
+
return (
|
|
245
|
+
<Pressable className="p-1" onPress={onPress}>
|
|
246
|
+
<Text className="text-lg text-muted-foreground">×</Text>
|
|
247
|
+
</Pressable>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
ToastClose.displayName = "ToastClose";
|
|
251
|
+
|
|
252
|
+
export {
|
|
253
|
+
Toast,
|
|
254
|
+
ToastProvider,
|
|
255
|
+
ToastViewport,
|
|
256
|
+
ToastTitle,
|
|
257
|
+
ToastDescription,
|
|
258
|
+
ToastAction,
|
|
259
|
+
ToastClose,
|
|
260
|
+
toast,
|
|
261
|
+
useToast,
|
|
262
|
+
toastContainerVariants,
|
|
263
|
+
toastTitleVariants,
|
|
264
|
+
toastDescriptionVariants,
|
|
265
|
+
toastCloseVariants,
|
|
266
|
+
type ToasterToast,
|
|
267
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import {
|
|
3
|
+
Toast,
|
|
4
|
+
ToastProvider,
|
|
5
|
+
ToastViewport,
|
|
6
|
+
ToastTitle,
|
|
7
|
+
ToastDescription,
|
|
8
|
+
} from "./Toast.web";
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Toast> = {
|
|
11
|
+
title: "Components/Toast",
|
|
12
|
+
component: Toast,
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
parameters: {
|
|
15
|
+
layout: "centered",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof Toast>;
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
render: () => (
|
|
24
|
+
<ToastProvider>
|
|
25
|
+
<Toast open>
|
|
26
|
+
<ToastTitle>Notification</ToastTitle>
|
|
27
|
+
<ToastDescription>
|
|
28
|
+
Your changes have been saved successfully.
|
|
29
|
+
</ToastDescription>
|
|
30
|
+
</Toast>
|
|
31
|
+
<ToastViewport />
|
|
32
|
+
</ToastProvider>
|
|
33
|
+
),
|
|
34
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export type ToastVariant = "default" | "destructive";
|
|
4
|
+
|
|
5
|
+
export interface ToastProps {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
variant?: ToastVariant;
|
|
9
|
+
open?: boolean;
|
|
10
|
+
onOpenChange?: (open: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ToastProviderProps {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ToastViewportProps {
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ToastTitleProps {
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
className?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ToastDescriptionProps {
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ToastActionProps {
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
className?: string;
|
|
34
|
+
altText: string;
|
|
35
|
+
onClick?: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ToastCloseProps {
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ToasterToast {
|
|
43
|
+
id: string;
|
|
44
|
+
title?: ReactNode;
|
|
45
|
+
description?: ReactNode;
|
|
46
|
+
action?: ReactNode;
|
|
47
|
+
variant?: ToastVariant;
|
|
48
|
+
open?: boolean;
|
|
49
|
+
onOpenChange?: (open: boolean) => void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { forwardRef, useState, useEffect, type ReactNode } from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
|
|
5
|
+
function XIcon(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="M18 6 6 18"/><path d="m6 6 12 12"/>
|
|
9
|
+
</svg>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const toastKeyframes = `@keyframes byld-toast-slide-in{from{transform:translateY(100%);opacity:0}to{transform:translateY(0);opacity:1}}`;
|
|
14
|
+
let toastStyleInjected = false;
|
|
15
|
+
|
|
16
|
+
const toastVariants = cva(
|
|
17
|
+
"group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg [animation:byld-toast-slide-in_0.3s_ease-out]",
|
|
18
|
+
{
|
|
19
|
+
variants: {
|
|
20
|
+
variant: {
|
|
21
|
+
default: "border bg-background text-foreground",
|
|
22
|
+
destructive:
|
|
23
|
+
"destructive group border-destructive bg-destructive text-destructive-foreground",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
variant: "default",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// ---- Toast primitives (portal-based) ----
|
|
33
|
+
|
|
34
|
+
const ToastProvider = ({ children }: { children?: ReactNode }) => {
|
|
35
|
+
return <>{children}</>;
|
|
36
|
+
};
|
|
37
|
+
ToastProvider.displayName = "ToastProvider";
|
|
38
|
+
|
|
39
|
+
const ToastViewport = forwardRef<
|
|
40
|
+
HTMLOListElement,
|
|
41
|
+
React.HTMLAttributes<HTMLOListElement>
|
|
42
|
+
>(({ className, ...props }, ref) => {
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (toastStyleInjected) return;
|
|
45
|
+
toastStyleInjected = true;
|
|
46
|
+
const style = document.createElement("style");
|
|
47
|
+
style.textContent = toastKeyframes;
|
|
48
|
+
document.head.appendChild(style);
|
|
49
|
+
}, []);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ol
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn(
|
|
55
|
+
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
ToastViewport.displayName = "ToastViewport";
|
|
63
|
+
|
|
64
|
+
interface ToastWebProps
|
|
65
|
+
extends React.HTMLAttributes<HTMLLIElement>,
|
|
66
|
+
VariantProps<typeof toastVariants> {
|
|
67
|
+
open?: boolean;
|
|
68
|
+
onOpenChange?: (open: boolean) => void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const Toast = forwardRef<HTMLLIElement, ToastWebProps>(
|
|
72
|
+
({ className, variant, open = true, onOpenChange, ...props }, ref) => {
|
|
73
|
+
if (!open) return null;
|
|
74
|
+
return (
|
|
75
|
+
<li
|
|
76
|
+
ref={ref}
|
|
77
|
+
className={cn(toastVariants({ variant }), className)}
|
|
78
|
+
data-state={open ? "open" : "closed"}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
Toast.displayName = "Toast";
|
|
85
|
+
|
|
86
|
+
const ToastAction = forwardRef<
|
|
87
|
+
HTMLButtonElement,
|
|
88
|
+
React.ButtonHTMLAttributes<HTMLButtonElement> & { altText?: string }
|
|
89
|
+
>(({ className, altText, ...props }, ref) => (
|
|
90
|
+
<button
|
|
91
|
+
ref={ref}
|
|
92
|
+
className={cn(
|
|
93
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
|
94
|
+
className,
|
|
95
|
+
)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
));
|
|
99
|
+
ToastAction.displayName = "ToastAction";
|
|
100
|
+
|
|
101
|
+
const ToastClose = forwardRef<
|
|
102
|
+
HTMLButtonElement,
|
|
103
|
+
React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
104
|
+
>(({ className, ...props }, ref) => (
|
|
105
|
+
<button
|
|
106
|
+
ref={ref}
|
|
107
|
+
className={cn(
|
|
108
|
+
"absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
109
|
+
className,
|
|
110
|
+
)}
|
|
111
|
+
toast-close=""
|
|
112
|
+
{...props}
|
|
113
|
+
>
|
|
114
|
+
<XIcon className="h-4 w-4" />
|
|
115
|
+
</button>
|
|
116
|
+
));
|
|
117
|
+
ToastClose.displayName = "ToastClose";
|
|
118
|
+
|
|
119
|
+
const ToastTitle = forwardRef<
|
|
120
|
+
HTMLDivElement,
|
|
121
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
122
|
+
>(({ className, ...props }, ref) => (
|
|
123
|
+
<div
|
|
124
|
+
ref={ref}
|
|
125
|
+
className={cn("text-sm font-semibold [&+div]:text-xs", className)}
|
|
126
|
+
{...props}
|
|
127
|
+
/>
|
|
128
|
+
));
|
|
129
|
+
ToastTitle.displayName = "ToastTitle";
|
|
130
|
+
|
|
131
|
+
const ToastDescription = forwardRef<
|
|
132
|
+
HTMLDivElement,
|
|
133
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
134
|
+
>(({ className, ...props }, ref) => (
|
|
135
|
+
<div
|
|
136
|
+
ref={ref}
|
|
137
|
+
className={cn("text-sm opacity-90", className)}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
));
|
|
141
|
+
ToastDescription.displayName = "ToastDescription";
|
|
142
|
+
|
|
143
|
+
// ---- useToast hook ----
|
|
144
|
+
|
|
145
|
+
type ToasterToast = {
|
|
146
|
+
id: string;
|
|
147
|
+
title?: ReactNode;
|
|
148
|
+
description?: ReactNode;
|
|
149
|
+
action?: ReactNode;
|
|
150
|
+
variant?: "default" | "destructive";
|
|
151
|
+
open?: boolean;
|
|
152
|
+
onOpenChange?: (open: boolean) => void;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
type ToastAction =
|
|
156
|
+
| { type: "ADD_TOAST"; toast: ToasterToast }
|
|
157
|
+
| { type: "UPDATE_TOAST"; toast: Partial<ToasterToast> }
|
|
158
|
+
| { type: "DISMISS_TOAST"; toastId?: string }
|
|
159
|
+
| { type: "REMOVE_TOAST"; toastId?: string };
|
|
160
|
+
|
|
161
|
+
const TOAST_LIMIT = 1;
|
|
162
|
+
const TOAST_REMOVE_DELAY = 5000;
|
|
163
|
+
|
|
164
|
+
let count = 0;
|
|
165
|
+
function genId() {
|
|
166
|
+
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
167
|
+
return count.toString();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
171
|
+
|
|
172
|
+
const addToRemoveQueue = (toastId: string) => {
|
|
173
|
+
if (toastTimeouts.has(toastId)) return;
|
|
174
|
+
|
|
175
|
+
const timeout = setTimeout(() => {
|
|
176
|
+
toastTimeouts.delete(toastId);
|
|
177
|
+
dispatch({ type: "REMOVE_TOAST", toastId });
|
|
178
|
+
}, TOAST_REMOVE_DELAY);
|
|
179
|
+
|
|
180
|
+
toastTimeouts.set(toastId, timeout);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const reducer = (state: ToasterToast[], action: ToastAction): ToasterToast[] => {
|
|
184
|
+
switch (action.type) {
|
|
185
|
+
case "ADD_TOAST":
|
|
186
|
+
return [action.toast, ...state].slice(0, TOAST_LIMIT);
|
|
187
|
+
case "UPDATE_TOAST":
|
|
188
|
+
return state.map((t) =>
|
|
189
|
+
t.id === action.toast.id ? { ...t, ...action.toast } : t,
|
|
190
|
+
);
|
|
191
|
+
case "DISMISS_TOAST": {
|
|
192
|
+
const { toastId } = action;
|
|
193
|
+
if (toastId) {
|
|
194
|
+
addToRemoveQueue(toastId);
|
|
195
|
+
} else {
|
|
196
|
+
state.forEach((t) => addToRemoveQueue(t.id));
|
|
197
|
+
}
|
|
198
|
+
return state.map((t) =>
|
|
199
|
+
t.id === toastId || toastId === undefined
|
|
200
|
+
? { ...t, open: false }
|
|
201
|
+
: t,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
case "REMOVE_TOAST":
|
|
205
|
+
if (action.toastId === undefined) return [];
|
|
206
|
+
return state.filter((t) => t.id !== action.toastId);
|
|
207
|
+
default:
|
|
208
|
+
return state;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const listeners: Array<(state: ToasterToast[]) => void> = [];
|
|
213
|
+
let memoryState: ToasterToast[] = [];
|
|
214
|
+
|
|
215
|
+
function dispatch(action: ToastAction) {
|
|
216
|
+
memoryState = reducer(memoryState, action);
|
|
217
|
+
listeners.forEach((listener) => listener(memoryState));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function toast({
|
|
221
|
+
...props
|
|
222
|
+
}: Omit<ToasterToast, "id">) {
|
|
223
|
+
const id = genId();
|
|
224
|
+
|
|
225
|
+
const update = (updateProps: Partial<ToasterToast>) =>
|
|
226
|
+
dispatch({ type: "UPDATE_TOAST", toast: { ...updateProps, id } });
|
|
227
|
+
|
|
228
|
+
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
|
|
229
|
+
|
|
230
|
+
dispatch({
|
|
231
|
+
type: "ADD_TOAST",
|
|
232
|
+
toast: {
|
|
233
|
+
...props,
|
|
234
|
+
id,
|
|
235
|
+
open: true,
|
|
236
|
+
onOpenChange: (open) => {
|
|
237
|
+
if (!open) dismiss();
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// Auto-dismiss after delay
|
|
243
|
+
setTimeout(() => {
|
|
244
|
+
dismiss();
|
|
245
|
+
}, TOAST_REMOVE_DELAY);
|
|
246
|
+
|
|
247
|
+
return { id, dismiss, update };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function useToast() {
|
|
251
|
+
const [state, setState] = useState<ToasterToast[]>(memoryState);
|
|
252
|
+
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
listeners.push(setState);
|
|
255
|
+
return () => {
|
|
256
|
+
const index = listeners.indexOf(setState);
|
|
257
|
+
if (index > -1) listeners.splice(index, 1);
|
|
258
|
+
};
|
|
259
|
+
}, []);
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
toasts: state,
|
|
263
|
+
toast,
|
|
264
|
+
dismiss: (toastId?: string) =>
|
|
265
|
+
dispatch({ type: "DISMISS_TOAST", toastId }),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export {
|
|
270
|
+
Toast,
|
|
271
|
+
ToastProvider,
|
|
272
|
+
ToastViewport,
|
|
273
|
+
ToastTitle,
|
|
274
|
+
ToastDescription,
|
|
275
|
+
ToastAction,
|
|
276
|
+
ToastClose,
|
|
277
|
+
toast,
|
|
278
|
+
useToast,
|
|
279
|
+
toastVariants,
|
|
280
|
+
type ToasterToast,
|
|
281
|
+
type ToastWebProps,
|
|
282
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Toast,
|
|
3
|
+
ToastProvider,
|
|
4
|
+
ToastViewport,
|
|
5
|
+
ToastTitle,
|
|
6
|
+
ToastDescription,
|
|
7
|
+
ToastAction,
|
|
8
|
+
ToastClose,
|
|
9
|
+
toast,
|
|
10
|
+
useToast,
|
|
11
|
+
toastContainerVariants,
|
|
12
|
+
toastTitleVariants,
|
|
13
|
+
toastDescriptionVariants,
|
|
14
|
+
toastCloseVariants,
|
|
15
|
+
type ToasterToast,
|
|
16
|
+
} from "./Toast.native";
|
|
17
|
+
export type { ToastProps } from "./Toast.types";
|