@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,281 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
Pressable,
|
|
5
|
+
Text,
|
|
6
|
+
View,
|
|
7
|
+
type ViewProps,
|
|
8
|
+
type TextProps,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import { cn } from "../../utils/cn";
|
|
11
|
+
import type {
|
|
12
|
+
AlertDialogProps,
|
|
13
|
+
AlertDialogTriggerProps,
|
|
14
|
+
AlertDialogContentProps,
|
|
15
|
+
AlertDialogHeaderProps,
|
|
16
|
+
AlertDialogFooterProps,
|
|
17
|
+
AlertDialogTitleProps,
|
|
18
|
+
AlertDialogDescriptionProps,
|
|
19
|
+
AlertDialogActionProps,
|
|
20
|
+
AlertDialogCancelProps,
|
|
21
|
+
} from "./AlertDialog.types";
|
|
22
|
+
import { useAlertDialog } from "./useAlertDialog";
|
|
23
|
+
|
|
24
|
+
// --- Context ---
|
|
25
|
+
|
|
26
|
+
interface AlertDialogContextValue {
|
|
27
|
+
open: boolean;
|
|
28
|
+
onOpenChange: (open: boolean) => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const AlertDialogContext = createContext<AlertDialogContextValue>({
|
|
32
|
+
open: false,
|
|
33
|
+
onOpenChange: () => {},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// --- AlertDialog Root ---
|
|
37
|
+
|
|
38
|
+
interface AlertDialogNativeProps extends AlertDialogProps {
|
|
39
|
+
defaultOpen?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function AlertDialog({
|
|
43
|
+
open: controlledOpen,
|
|
44
|
+
defaultOpen = false,
|
|
45
|
+
onOpenChange: controlledOnOpenChange,
|
|
46
|
+
children,
|
|
47
|
+
}: AlertDialogNativeProps) {
|
|
48
|
+
const { open, onOpenChange } = useAlertDialog({
|
|
49
|
+
open: controlledOpen,
|
|
50
|
+
defaultOpen,
|
|
51
|
+
onOpenChange: controlledOnOpenChange,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<AlertDialogContext.Provider
|
|
56
|
+
value={{ open, onOpenChange }}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</AlertDialogContext.Provider>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
AlertDialog.displayName = "AlertDialog";
|
|
63
|
+
|
|
64
|
+
// --- AlertDialogTrigger ---
|
|
65
|
+
|
|
66
|
+
interface AlertDialogTriggerNativeProps extends AlertDialogTriggerProps {
|
|
67
|
+
onPress?: () => void;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function AlertDialogTrigger({
|
|
71
|
+
children,
|
|
72
|
+
onPress,
|
|
73
|
+
}: AlertDialogTriggerNativeProps) {
|
|
74
|
+
const { onOpenChange } = useContext(AlertDialogContext);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<Pressable
|
|
78
|
+
onPress={() => {
|
|
79
|
+
onOpenChange(true);
|
|
80
|
+
onPress?.();
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{children}
|
|
84
|
+
</Pressable>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
AlertDialogTrigger.displayName = "AlertDialogTrigger";
|
|
88
|
+
|
|
89
|
+
// --- AlertDialogContent ---
|
|
90
|
+
|
|
91
|
+
interface AlertDialogContentNativeProps extends AlertDialogContentProps, ViewProps {}
|
|
92
|
+
|
|
93
|
+
function AlertDialogContent({
|
|
94
|
+
children,
|
|
95
|
+
className,
|
|
96
|
+
...props
|
|
97
|
+
}: AlertDialogContentNativeProps) {
|
|
98
|
+
const { open, onOpenChange } = useContext(AlertDialogContext);
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<Modal
|
|
102
|
+
visible={open}
|
|
103
|
+
transparent
|
|
104
|
+
animationType="fade"
|
|
105
|
+
onRequestClose={() => onOpenChange(false)}
|
|
106
|
+
>
|
|
107
|
+
<View className="flex-1 justify-center items-center p-6" style={{ backgroundColor: "rgba(0, 0, 0, 0.5)" }}>
|
|
108
|
+
<View
|
|
109
|
+
className={cn(
|
|
110
|
+
"w-full max-w-lg bg-background rounded-lg p-6 gap-4 shadow-lg elevation-10",
|
|
111
|
+
className,
|
|
112
|
+
)}
|
|
113
|
+
{...props}
|
|
114
|
+
>
|
|
115
|
+
{children}
|
|
116
|
+
</View>
|
|
117
|
+
</View>
|
|
118
|
+
</Modal>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
AlertDialogContent.displayName = "AlertDialogContent";
|
|
122
|
+
|
|
123
|
+
// --- AlertDialogHeader ---
|
|
124
|
+
|
|
125
|
+
interface AlertDialogHeaderNativeProps extends AlertDialogHeaderProps, ViewProps {}
|
|
126
|
+
|
|
127
|
+
function AlertDialogHeader({
|
|
128
|
+
children,
|
|
129
|
+
className,
|
|
130
|
+
...props
|
|
131
|
+
}: AlertDialogHeaderNativeProps) {
|
|
132
|
+
return (
|
|
133
|
+
<View className={cn("gap-2", className)} {...props}>
|
|
134
|
+
{children}
|
|
135
|
+
</View>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
139
|
+
|
|
140
|
+
// --- AlertDialogFooter ---
|
|
141
|
+
|
|
142
|
+
interface AlertDialogFooterNativeProps extends AlertDialogFooterProps, ViewProps {}
|
|
143
|
+
|
|
144
|
+
function AlertDialogFooter({
|
|
145
|
+
children,
|
|
146
|
+
className,
|
|
147
|
+
...props
|
|
148
|
+
}: AlertDialogFooterNativeProps) {
|
|
149
|
+
return (
|
|
150
|
+
<View
|
|
151
|
+
className={cn("flex-row justify-end gap-2", className)}
|
|
152
|
+
{...props}
|
|
153
|
+
>
|
|
154
|
+
{children}
|
|
155
|
+
</View>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
159
|
+
|
|
160
|
+
// --- AlertDialogTitle ---
|
|
161
|
+
|
|
162
|
+
interface AlertDialogTitleNativeProps extends AlertDialogTitleProps, TextProps {}
|
|
163
|
+
|
|
164
|
+
function AlertDialogTitle({
|
|
165
|
+
children,
|
|
166
|
+
className,
|
|
167
|
+
...props
|
|
168
|
+
}: AlertDialogTitleNativeProps) {
|
|
169
|
+
return (
|
|
170
|
+
<Text
|
|
171
|
+
className={cn("text-lg font-semibold text-foreground", className)}
|
|
172
|
+
{...props}
|
|
173
|
+
>
|
|
174
|
+
{children}
|
|
175
|
+
</Text>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
AlertDialogTitle.displayName = "AlertDialogTitle";
|
|
179
|
+
|
|
180
|
+
// --- AlertDialogDescription ---
|
|
181
|
+
|
|
182
|
+
interface AlertDialogDescriptionNativeProps extends AlertDialogDescriptionProps, TextProps {}
|
|
183
|
+
|
|
184
|
+
function AlertDialogDescription({
|
|
185
|
+
children,
|
|
186
|
+
className,
|
|
187
|
+
...props
|
|
188
|
+
}: AlertDialogDescriptionNativeProps) {
|
|
189
|
+
return (
|
|
190
|
+
<Text
|
|
191
|
+
className={cn("text-sm text-muted-foreground leading-5", className)}
|
|
192
|
+
{...props}
|
|
193
|
+
>
|
|
194
|
+
{children}
|
|
195
|
+
</Text>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
AlertDialogDescription.displayName = "AlertDialogDescription";
|
|
199
|
+
|
|
200
|
+
// --- AlertDialogAction ---
|
|
201
|
+
|
|
202
|
+
interface AlertDialogActionNativeProps extends AlertDialogActionProps {}
|
|
203
|
+
|
|
204
|
+
function AlertDialogAction({
|
|
205
|
+
children,
|
|
206
|
+
onPress,
|
|
207
|
+
}: AlertDialogActionNativeProps) {
|
|
208
|
+
const { onOpenChange } = useContext(AlertDialogContext);
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<Pressable
|
|
212
|
+
onPress={() => {
|
|
213
|
+
onPress?.();
|
|
214
|
+
onOpenChange(false);
|
|
215
|
+
}}
|
|
216
|
+
className="bg-primary px-4 rounded-md h-9 items-center justify-center"
|
|
217
|
+
>
|
|
218
|
+
{typeof children === "string" ? (
|
|
219
|
+
<Text className="text-primary-foreground text-sm font-medium">
|
|
220
|
+
{children}
|
|
221
|
+
</Text>
|
|
222
|
+
) : (
|
|
223
|
+
children
|
|
224
|
+
)}
|
|
225
|
+
</Pressable>
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
AlertDialogAction.displayName = "AlertDialogAction";
|
|
229
|
+
|
|
230
|
+
// --- AlertDialogCancel ---
|
|
231
|
+
|
|
232
|
+
interface AlertDialogCancelNativeProps extends AlertDialogCancelProps {}
|
|
233
|
+
|
|
234
|
+
function AlertDialogCancel({
|
|
235
|
+
children,
|
|
236
|
+
onPress,
|
|
237
|
+
}: AlertDialogCancelNativeProps) {
|
|
238
|
+
const { onOpenChange } = useContext(AlertDialogContext);
|
|
239
|
+
|
|
240
|
+
return (
|
|
241
|
+
<Pressable
|
|
242
|
+
onPress={() => {
|
|
243
|
+
onPress?.();
|
|
244
|
+
onOpenChange(false);
|
|
245
|
+
}}
|
|
246
|
+
className="bg-transparent border border-border px-4 rounded-md h-9 items-center justify-center"
|
|
247
|
+
>
|
|
248
|
+
{typeof children === "string" ? (
|
|
249
|
+
<Text className="text-foreground text-sm font-medium">
|
|
250
|
+
{children}
|
|
251
|
+
</Text>
|
|
252
|
+
) : (
|
|
253
|
+
children
|
|
254
|
+
)}
|
|
255
|
+
</Pressable>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
AlertDialogCancel.displayName = "AlertDialogCancel";
|
|
259
|
+
|
|
260
|
+
export {
|
|
261
|
+
AlertDialog,
|
|
262
|
+
AlertDialogTrigger,
|
|
263
|
+
AlertDialogContent,
|
|
264
|
+
AlertDialogHeader,
|
|
265
|
+
AlertDialogFooter,
|
|
266
|
+
AlertDialogTitle,
|
|
267
|
+
AlertDialogDescription,
|
|
268
|
+
AlertDialogAction,
|
|
269
|
+
AlertDialogCancel,
|
|
270
|
+
};
|
|
271
|
+
export type {
|
|
272
|
+
AlertDialogNativeProps,
|
|
273
|
+
AlertDialogTriggerNativeProps,
|
|
274
|
+
AlertDialogContentNativeProps,
|
|
275
|
+
AlertDialogHeaderNativeProps,
|
|
276
|
+
AlertDialogFooterNativeProps,
|
|
277
|
+
AlertDialogTitleNativeProps,
|
|
278
|
+
AlertDialogDescriptionNativeProps,
|
|
279
|
+
AlertDialogActionNativeProps,
|
|
280
|
+
AlertDialogCancelNativeProps,
|
|
281
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import {
|
|
3
|
+
AlertDialog,
|
|
4
|
+
AlertDialogTrigger,
|
|
5
|
+
AlertDialogContent,
|
|
6
|
+
AlertDialogHeader,
|
|
7
|
+
AlertDialogFooter,
|
|
8
|
+
AlertDialogTitle,
|
|
9
|
+
AlertDialogDescription,
|
|
10
|
+
AlertDialogAction,
|
|
11
|
+
AlertDialogCancel,
|
|
12
|
+
} from "./AlertDialog.web";
|
|
13
|
+
|
|
14
|
+
const meta = {
|
|
15
|
+
title: "Components/AlertDialog",
|
|
16
|
+
component: AlertDialog,
|
|
17
|
+
parameters: {
|
|
18
|
+
layout: "centered",
|
|
19
|
+
},
|
|
20
|
+
tags: ["autodocs"],
|
|
21
|
+
} satisfies Meta<typeof AlertDialog>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryObj<typeof meta>;
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
children: (
|
|
29
|
+
<>
|
|
30
|
+
<AlertDialogTrigger asChild>
|
|
31
|
+
<button>Delete Account</button>
|
|
32
|
+
</AlertDialogTrigger>
|
|
33
|
+
<AlertDialogContent>
|
|
34
|
+
<AlertDialogHeader>
|
|
35
|
+
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
|
36
|
+
<AlertDialogDescription>
|
|
37
|
+
This action cannot be undone. This will permanently delete your
|
|
38
|
+
account and remove your data from our servers.
|
|
39
|
+
</AlertDialogDescription>
|
|
40
|
+
</AlertDialogHeader>
|
|
41
|
+
<AlertDialogFooter>
|
|
42
|
+
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
43
|
+
<AlertDialogAction>Continue</AlertDialogAction>
|
|
44
|
+
</AlertDialogFooter>
|
|
45
|
+
</AlertDialogContent>
|
|
46
|
+
</>
|
|
47
|
+
),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface AlertDialogProps {
|
|
2
|
+
open?: boolean;
|
|
3
|
+
onOpenChange?: (open: boolean) => void;
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AlertDialogTriggerProps {
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AlertDialogContentProps {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AlertDialogHeaderProps {
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface AlertDialogFooterProps {
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
className?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AlertDialogTitleProps {
|
|
30
|
+
children?: React.ReactNode;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface AlertDialogDescriptionProps {
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface AlertDialogActionProps {
|
|
40
|
+
children?: React.ReactNode;
|
|
41
|
+
className?: string;
|
|
42
|
+
onPress?: () => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface AlertDialogCancelProps {
|
|
46
|
+
children?: React.ReactNode;
|
|
47
|
+
className?: string;
|
|
48
|
+
onPress?: () => void;
|
|
49
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
import { buttonVariants } from "../Button/Button.web";
|
|
5
|
+
|
|
6
|
+
const AlertDialog = AlertDialogPrimitive.Root;
|
|
7
|
+
|
|
8
|
+
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
9
|
+
|
|
10
|
+
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
11
|
+
|
|
12
|
+
const AlertDialogOverlay = forwardRef<
|
|
13
|
+
React.ComponentRef<typeof AlertDialogPrimitive.Overlay>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
15
|
+
>(({ className, ...props }, ref) => (
|
|
16
|
+
<AlertDialogPrimitive.Overlay
|
|
17
|
+
className={cn(
|
|
18
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
{...props}
|
|
22
|
+
ref={ref}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
25
|
+
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
26
|
+
|
|
27
|
+
const AlertDialogContent = forwardRef<
|
|
28
|
+
React.ComponentRef<typeof AlertDialogPrimitive.Content>,
|
|
29
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
|
30
|
+
>(({ className, ...props }, ref) => (
|
|
31
|
+
<AlertDialogPortal>
|
|
32
|
+
<AlertDialogOverlay />
|
|
33
|
+
<AlertDialogPrimitive.Content
|
|
34
|
+
ref={ref}
|
|
35
|
+
className={cn(
|
|
36
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background text-foreground p-6 shadow-lg transition-opacity duration-200 data-[state=open]:opacity-100 data-[state=closed]:opacity-0 sm:rounded-lg",
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
</AlertDialogPortal>
|
|
42
|
+
));
|
|
43
|
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
44
|
+
|
|
45
|
+
const AlertDialogHeader = ({
|
|
46
|
+
className,
|
|
47
|
+
...props
|
|
48
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
49
|
+
<div
|
|
50
|
+
className={cn(
|
|
51
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
52
|
+
className,
|
|
53
|
+
)}
|
|
54
|
+
{...props}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
58
|
+
|
|
59
|
+
const AlertDialogFooter = ({
|
|
60
|
+
className,
|
|
61
|
+
...props
|
|
62
|
+
}: React.HTMLAttributes<HTMLDivElement>) => (
|
|
63
|
+
<div
|
|
64
|
+
className={cn(
|
|
65
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
66
|
+
className,
|
|
67
|
+
)}
|
|
68
|
+
{...props}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
72
|
+
|
|
73
|
+
const AlertDialogTitle = forwardRef<
|
|
74
|
+
React.ComponentRef<typeof AlertDialogPrimitive.Title>,
|
|
75
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
|
76
|
+
>(({ className, ...props }, ref) => (
|
|
77
|
+
<AlertDialogPrimitive.Title
|
|
78
|
+
ref={ref}
|
|
79
|
+
className={cn("text-lg font-semibold", className)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
));
|
|
83
|
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
84
|
+
|
|
85
|
+
const AlertDialogDescription = forwardRef<
|
|
86
|
+
React.ComponentRef<typeof AlertDialogPrimitive.Description>,
|
|
87
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
|
88
|
+
>(({ className, ...props }, ref) => (
|
|
89
|
+
<AlertDialogPrimitive.Description
|
|
90
|
+
ref={ref}
|
|
91
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
));
|
|
95
|
+
AlertDialogDescription.displayName =
|
|
96
|
+
AlertDialogPrimitive.Description.displayName;
|
|
97
|
+
|
|
98
|
+
const AlertDialogAction = forwardRef<
|
|
99
|
+
React.ComponentRef<typeof AlertDialogPrimitive.Action>,
|
|
100
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
|
101
|
+
>(({ className, ...props }, ref) => (
|
|
102
|
+
<AlertDialogPrimitive.Action
|
|
103
|
+
ref={ref}
|
|
104
|
+
className={cn(buttonVariants(), className)}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
));
|
|
108
|
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
109
|
+
|
|
110
|
+
const AlertDialogCancel = forwardRef<
|
|
111
|
+
React.ComponentRef<typeof AlertDialogPrimitive.Cancel>,
|
|
112
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
|
113
|
+
>(({ className, ...props }, ref) => (
|
|
114
|
+
<AlertDialogPrimitive.Cancel
|
|
115
|
+
ref={ref}
|
|
116
|
+
className={cn(
|
|
117
|
+
buttonVariants({ variant: "outline" }),
|
|
118
|
+
"mt-2 sm:mt-0",
|
|
119
|
+
className,
|
|
120
|
+
)}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
));
|
|
124
|
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
AlertDialog,
|
|
128
|
+
AlertDialogPortal,
|
|
129
|
+
AlertDialogOverlay,
|
|
130
|
+
AlertDialogTrigger,
|
|
131
|
+
AlertDialogContent,
|
|
132
|
+
AlertDialogHeader,
|
|
133
|
+
AlertDialogFooter,
|
|
134
|
+
AlertDialogTitle,
|
|
135
|
+
AlertDialogDescription,
|
|
136
|
+
AlertDialogAction,
|
|
137
|
+
AlertDialogCancel,
|
|
138
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export {
|
|
2
|
+
AlertDialog,
|
|
3
|
+
AlertDialogTrigger,
|
|
4
|
+
AlertDialogContent,
|
|
5
|
+
AlertDialogHeader,
|
|
6
|
+
AlertDialogFooter,
|
|
7
|
+
AlertDialogTitle,
|
|
8
|
+
AlertDialogDescription,
|
|
9
|
+
AlertDialogAction,
|
|
10
|
+
AlertDialogCancel,
|
|
11
|
+
} from "./AlertDialog.native";
|
|
12
|
+
export type {
|
|
13
|
+
AlertDialogProps,
|
|
14
|
+
AlertDialogTriggerProps,
|
|
15
|
+
AlertDialogContentProps,
|
|
16
|
+
AlertDialogHeaderProps,
|
|
17
|
+
AlertDialogFooterProps,
|
|
18
|
+
AlertDialogTitleProps,
|
|
19
|
+
AlertDialogDescriptionProps,
|
|
20
|
+
AlertDialogActionProps,
|
|
21
|
+
AlertDialogCancelProps,
|
|
22
|
+
} from "./AlertDialog.types";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export {
|
|
2
|
+
AlertDialog,
|
|
3
|
+
AlertDialogPortal,
|
|
4
|
+
AlertDialogOverlay,
|
|
5
|
+
AlertDialogTrigger,
|
|
6
|
+
AlertDialogContent,
|
|
7
|
+
AlertDialogHeader,
|
|
8
|
+
AlertDialogFooter,
|
|
9
|
+
AlertDialogTitle,
|
|
10
|
+
AlertDialogDescription,
|
|
11
|
+
AlertDialogAction,
|
|
12
|
+
AlertDialogCancel,
|
|
13
|
+
} from "./AlertDialog.web";
|
|
14
|
+
export type {
|
|
15
|
+
AlertDialogProps,
|
|
16
|
+
AlertDialogTriggerProps,
|
|
17
|
+
AlertDialogContentProps,
|
|
18
|
+
AlertDialogHeaderProps,
|
|
19
|
+
AlertDialogFooterProps,
|
|
20
|
+
AlertDialogTitleProps,
|
|
21
|
+
AlertDialogDescriptionProps,
|
|
22
|
+
AlertDialogActionProps,
|
|
23
|
+
AlertDialogCancelProps,
|
|
24
|
+
} from "./AlertDialog.types";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import { useAlertDialog } from "./useAlertDialog";
|
|
4
|
+
|
|
5
|
+
describe("useAlertDialog", () => {
|
|
6
|
+
it("defaults to closed", () => {
|
|
7
|
+
const { result } = renderHook(() => useAlertDialog());
|
|
8
|
+
expect(result.current.open).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("uses defaultOpen", () => {
|
|
12
|
+
const { result } = renderHook(() => useAlertDialog({ defaultOpen: true }));
|
|
13
|
+
expect(result.current.open).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("opens via onOpenChange", () => {
|
|
17
|
+
const { result } = renderHook(() => useAlertDialog());
|
|
18
|
+
act(() => result.current.onOpenChange(true));
|
|
19
|
+
expect(result.current.open).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("calls external onOpenChange", () => {
|
|
23
|
+
const onChange = vi.fn();
|
|
24
|
+
const { result } = renderHook(() =>
|
|
25
|
+
useAlertDialog({ onOpenChange: onChange }),
|
|
26
|
+
);
|
|
27
|
+
act(() => result.current.onOpenChange(true));
|
|
28
|
+
expect(onChange).toHaveBeenCalledWith(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("works in controlled mode", () => {
|
|
32
|
+
const onChange = vi.fn();
|
|
33
|
+
const { result } = renderHook(() =>
|
|
34
|
+
useAlertDialog({ open: false, onOpenChange: onChange }),
|
|
35
|
+
);
|
|
36
|
+
act(() => result.current.onOpenChange(true));
|
|
37
|
+
expect(result.current.open).toBe(false);
|
|
38
|
+
expect(onChange).toHaveBeenCalledWith(true);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
3
|
+
|
|
4
|
+
interface UseAlertDialogProps {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
defaultOpen?: boolean;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface UseAlertDialogReturn {
|
|
11
|
+
open: boolean;
|
|
12
|
+
onOpenChange: (open: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function useAlertDialog({
|
|
16
|
+
open: controlledOpen,
|
|
17
|
+
defaultOpen = false,
|
|
18
|
+
onOpenChange,
|
|
19
|
+
}: UseAlertDialogProps = {}): UseAlertDialogReturn {
|
|
20
|
+
const [open, setOpen] = useControllableState({
|
|
21
|
+
value: controlledOpen,
|
|
22
|
+
defaultValue: defaultOpen,
|
|
23
|
+
onChange: onOpenChange,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const handleOpenChange = useCallback(
|
|
27
|
+
(nextOpen: boolean) => {
|
|
28
|
+
setOpen(nextOpen);
|
|
29
|
+
},
|
|
30
|
+
[setOpen],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return { open, onOpenChange: handleOpenChange };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type { UseAlertDialogProps, UseAlertDialogReturn };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { View, type ViewProps, type LayoutChangeEvent } from "react-native";
|
|
3
|
+
import type { AspectRatioProps } from "./AspectRatio.types";
|
|
4
|
+
import { cn } from "../../utils/cn";
|
|
5
|
+
import { useAspectRatio } from "./useAspectRatio";
|
|
6
|
+
|
|
7
|
+
interface AspectRatioNativeProps extends AspectRatioProps, ViewProps {}
|
|
8
|
+
|
|
9
|
+
function AspectRatio({
|
|
10
|
+
ratio = 1,
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: AspectRatioNativeProps) {
|
|
15
|
+
const [width, setWidth] = useState(0);
|
|
16
|
+
const { height, isReady } = useAspectRatio({ ratio, width });
|
|
17
|
+
|
|
18
|
+
const handleLayout = (event: LayoutChangeEvent) => {
|
|
19
|
+
setWidth(event.nativeEvent.layout.width);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View
|
|
24
|
+
onLayout={handleLayout}
|
|
25
|
+
className={cn("relative w-full overflow-hidden", className)}
|
|
26
|
+
style={{ height: isReady ? height : undefined }}
|
|
27
|
+
{...props}
|
|
28
|
+
>
|
|
29
|
+
{isReady ? children : null}
|
|
30
|
+
</View>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
AspectRatio.displayName = "AspectRatio";
|
|
35
|
+
|
|
36
|
+
export { AspectRatio };
|
|
37
|
+
export type { AspectRatioNativeProps };
|