@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,55 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { cn } from "../../utils/cn";
|
|
5
|
+
import type { ButtonVariant, ButtonSize, ButtonProps } from "./Button.types";
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
14
|
+
destructive:
|
|
15
|
+
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
16
|
+
outline:
|
|
17
|
+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
18
|
+
secondary:
|
|
19
|
+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
20
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
21
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
22
|
+
} satisfies Record<ButtonVariant, string>,
|
|
23
|
+
size: {
|
|
24
|
+
default: "h-9 px-4 py-2",
|
|
25
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
26
|
+
lg: "h-10 rounded-md px-8",
|
|
27
|
+
icon: "h-9 w-9",
|
|
28
|
+
} satisfies Record<ButtonSize, string>,
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
variant: "default",
|
|
32
|
+
size: "default",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export interface ButtonWebProps
|
|
38
|
+
extends ButtonProps,
|
|
39
|
+
React.ButtonHTMLAttributes<HTMLButtonElement> {}
|
|
40
|
+
|
|
41
|
+
const Button = forwardRef<HTMLButtonElement, ButtonWebProps>(
|
|
42
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
43
|
+
const Comp = asChild ? Slot : "button";
|
|
44
|
+
return (
|
|
45
|
+
<Comp
|
|
46
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
47
|
+
ref={ref}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
Button.displayName = "Button";
|
|
54
|
+
|
|
55
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
View,
|
|
3
|
+
Text,
|
|
4
|
+
Pressable,
|
|
5
|
+
type ViewProps,
|
|
6
|
+
} from "react-native";
|
|
7
|
+
import type { CalendarProps } from "./Calendar.types";
|
|
8
|
+
import { useCalendar, isSameDay, isToday } from "./useCalendar";
|
|
9
|
+
import { cn } from "../../utils/cn";
|
|
10
|
+
|
|
11
|
+
const DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
12
|
+
|
|
13
|
+
interface CalendarNativeProps extends CalendarProps, ViewProps {}
|
|
14
|
+
|
|
15
|
+
function Calendar({
|
|
16
|
+
selected,
|
|
17
|
+
onSelect,
|
|
18
|
+
month: controlledMonth,
|
|
19
|
+
onMonthChange,
|
|
20
|
+
disabled = false,
|
|
21
|
+
className,
|
|
22
|
+
...props
|
|
23
|
+
}: CalendarNativeProps) {
|
|
24
|
+
const {
|
|
25
|
+
year,
|
|
26
|
+
monthIndex,
|
|
27
|
+
monthLabel,
|
|
28
|
+
cells,
|
|
29
|
+
goToPrevMonth,
|
|
30
|
+
goToNextMonth,
|
|
31
|
+
handleDayPress,
|
|
32
|
+
} = useCalendar({
|
|
33
|
+
selected,
|
|
34
|
+
onSelect,
|
|
35
|
+
month: controlledMonth,
|
|
36
|
+
onMonthChange,
|
|
37
|
+
disabled,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<View className={cn("p-3", className)} {...props}>
|
|
42
|
+
<View className="flex-row items-center justify-between mb-4">
|
|
43
|
+
<Pressable
|
|
44
|
+
onPress={goToPrevMonth}
|
|
45
|
+
disabled={disabled}
|
|
46
|
+
className="w-7 h-7 rounded-md border border-border items-center justify-center shadow-sm elevation-1"
|
|
47
|
+
>
|
|
48
|
+
<Text className="text-sm text-foreground">‹</Text>
|
|
49
|
+
</Pressable>
|
|
50
|
+
<Text className="text-sm font-medium text-foreground">
|
|
51
|
+
{monthLabel}
|
|
52
|
+
</Text>
|
|
53
|
+
<Pressable
|
|
54
|
+
onPress={goToNextMonth}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
className="w-7 h-7 rounded-md border border-border items-center justify-center shadow-sm elevation-1"
|
|
57
|
+
>
|
|
58
|
+
<Text className="text-sm text-foreground">›</Text>
|
|
59
|
+
</Pressable>
|
|
60
|
+
</View>
|
|
61
|
+
|
|
62
|
+
<View className="flex-row flex-wrap">
|
|
63
|
+
{DAYS.map((day) => (
|
|
64
|
+
<View key={day} className="w-8 h-8 items-center justify-center">
|
|
65
|
+
<Text className="text-xs font-medium text-muted-foreground">{day}</Text>
|
|
66
|
+
</View>
|
|
67
|
+
))}
|
|
68
|
+
|
|
69
|
+
{cells.map((day, i) => {
|
|
70
|
+
if (day === null) {
|
|
71
|
+
return <View key={`empty-${i}`} className="w-8 h-8" />;
|
|
72
|
+
}
|
|
73
|
+
const date = new Date(year, monthIndex, day);
|
|
74
|
+
const isSelected = selected && isSameDay(date, selected);
|
|
75
|
+
const isTodayDate = isToday(date);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Pressable
|
|
79
|
+
key={day}
|
|
80
|
+
onPress={() => handleDayPress(day)}
|
|
81
|
+
disabled={disabled}
|
|
82
|
+
className={cn(
|
|
83
|
+
"w-8 h-8 items-center justify-center rounded-md",
|
|
84
|
+
isTodayDate && !isSelected && "bg-secondary",
|
|
85
|
+
isSelected && "bg-primary",
|
|
86
|
+
disabled && "opacity-50",
|
|
87
|
+
)}
|
|
88
|
+
>
|
|
89
|
+
<Text
|
|
90
|
+
className={cn(
|
|
91
|
+
"text-sm",
|
|
92
|
+
isSelected ? "text-primary-foreground" : "text-foreground",
|
|
93
|
+
)}
|
|
94
|
+
>
|
|
95
|
+
{day}
|
|
96
|
+
</Text>
|
|
97
|
+
</Pressable>
|
|
98
|
+
);
|
|
99
|
+
})}
|
|
100
|
+
</View>
|
|
101
|
+
</View>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Calendar.displayName = "Calendar";
|
|
106
|
+
|
|
107
|
+
export { Calendar };
|
|
108
|
+
export type { CalendarNativeProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Calendar } from "./Calendar.web";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Components/Calendar",
|
|
6
|
+
component: Calendar,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
} satisfies Meta<typeof Calendar>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {},
|
|
18
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { forwardRef, useState } from "react";
|
|
2
|
+
import { cn } from "../../utils/cn";
|
|
3
|
+
import type { CalendarProps } from "./Calendar.types";
|
|
4
|
+
|
|
5
|
+
const DAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
6
|
+
|
|
7
|
+
function getDaysInMonth(year: number, month: number): number {
|
|
8
|
+
return new Date(year, month + 1, 0).getDate();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getFirstDayOfMonth(year: number, month: number): number {
|
|
12
|
+
return new Date(year, month, 1).getDay();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isSameDay(a: Date, b: Date): boolean {
|
|
16
|
+
return (
|
|
17
|
+
a.getFullYear() === b.getFullYear() &&
|
|
18
|
+
a.getMonth() === b.getMonth() &&
|
|
19
|
+
a.getDate() === b.getDate()
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isToday(date: Date): boolean {
|
|
24
|
+
return isSameDay(date, new Date());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const Calendar = forwardRef<HTMLDivElement, CalendarProps & Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect">>(
|
|
28
|
+
(
|
|
29
|
+
{
|
|
30
|
+
selected,
|
|
31
|
+
onSelect,
|
|
32
|
+
month: controlledMonth,
|
|
33
|
+
onMonthChange,
|
|
34
|
+
disabled = false,
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
},
|
|
38
|
+
ref,
|
|
39
|
+
) => {
|
|
40
|
+
const [internalMonth, setInternalMonth] = useState(
|
|
41
|
+
controlledMonth || selected || new Date(),
|
|
42
|
+
);
|
|
43
|
+
const displayMonth = controlledMonth || internalMonth;
|
|
44
|
+
|
|
45
|
+
const year = displayMonth.getFullYear();
|
|
46
|
+
const monthIndex = displayMonth.getMonth();
|
|
47
|
+
const daysInMonth = getDaysInMonth(year, monthIndex);
|
|
48
|
+
const firstDay = getFirstDayOfMonth(year, monthIndex);
|
|
49
|
+
|
|
50
|
+
const monthLabel = displayMonth.toLocaleString("default", {
|
|
51
|
+
month: "long",
|
|
52
|
+
year: "numeric",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const goToPrevMonth = () => {
|
|
56
|
+
const prev = new Date(year, monthIndex - 1, 1);
|
|
57
|
+
if (controlledMonth === undefined) setInternalMonth(prev);
|
|
58
|
+
onMonthChange?.(prev);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const goToNextMonth = () => {
|
|
62
|
+
const next = new Date(year, monthIndex + 1, 1);
|
|
63
|
+
if (controlledMonth === undefined) setInternalMonth(next);
|
|
64
|
+
onMonthChange?.(next);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const handleDayClick = (day: number) => {
|
|
68
|
+
if (disabled) return;
|
|
69
|
+
const date = new Date(year, monthIndex, day);
|
|
70
|
+
onSelect?.(date);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const cells: (number | null)[] = [];
|
|
74
|
+
for (let i = 0; i < firstDay; i++) {
|
|
75
|
+
cells.push(null);
|
|
76
|
+
}
|
|
77
|
+
for (let d = 1; d <= daysInMonth; d++) {
|
|
78
|
+
cells.push(d);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div ref={ref} className={cn("p-3", className)} {...props}>
|
|
83
|
+
<div className="flex items-center justify-between mb-4">
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
onClick={goToPrevMonth}
|
|
87
|
+
className="inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-transparent text-sm shadow-sm hover:bg-accent hover:text-accent-foreground"
|
|
88
|
+
disabled={disabled}
|
|
89
|
+
>
|
|
90
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m15 18-6-6 6-6"/></svg>
|
|
91
|
+
</button>
|
|
92
|
+
<div className="text-sm font-medium">{monthLabel}</div>
|
|
93
|
+
<button
|
|
94
|
+
type="button"
|
|
95
|
+
onClick={goToNextMonth}
|
|
96
|
+
className="inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-transparent text-sm shadow-sm hover:bg-accent hover:text-accent-foreground"
|
|
97
|
+
disabled={disabled}
|
|
98
|
+
>
|
|
99
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m9 18 6-6-6-6"/></svg>
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
<div className="grid grid-cols-7 gap-0">
|
|
103
|
+
{DAYS.map((day) => (
|
|
104
|
+
<div
|
|
105
|
+
key={day}
|
|
106
|
+
className="flex h-8 w-8 items-center justify-center text-[0.8rem] text-muted-foreground font-medium"
|
|
107
|
+
>
|
|
108
|
+
{day}
|
|
109
|
+
</div>
|
|
110
|
+
))}
|
|
111
|
+
{cells.map((day, i) => {
|
|
112
|
+
if (day === null) {
|
|
113
|
+
return <div key={`empty-${i}`} className="h-8 w-8" />;
|
|
114
|
+
}
|
|
115
|
+
const date = new Date(year, monthIndex, day);
|
|
116
|
+
const isSelected = selected && isSameDay(date, selected);
|
|
117
|
+
const isTodayDate = isToday(date);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<button
|
|
121
|
+
key={day}
|
|
122
|
+
type="button"
|
|
123
|
+
onClick={() => handleDayClick(day)}
|
|
124
|
+
disabled={disabled}
|
|
125
|
+
className={cn(
|
|
126
|
+
"inline-flex h-8 w-8 items-center justify-center rounded-md text-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
127
|
+
isSelected &&
|
|
128
|
+
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground",
|
|
129
|
+
isTodayDate && !isSelected && "bg-accent text-accent-foreground",
|
|
130
|
+
)}
|
|
131
|
+
>
|
|
132
|
+
{day}
|
|
133
|
+
</button>
|
|
134
|
+
);
|
|
135
|
+
})}
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
Calendar.displayName = "Calendar";
|
|
142
|
+
|
|
143
|
+
export { Calendar };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import { renderHook, act } from "@testing-library/react";
|
|
3
|
+
import {
|
|
4
|
+
useCalendar,
|
|
5
|
+
getDaysInMonth,
|
|
6
|
+
getFirstDayOfMonth,
|
|
7
|
+
isSameDay,
|
|
8
|
+
} from "./useCalendar";
|
|
9
|
+
|
|
10
|
+
describe("getDaysInMonth", () => {
|
|
11
|
+
it("returns 31 for January", () => {
|
|
12
|
+
expect(getDaysInMonth(2024, 0)).toBe(31);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("returns 29 for Feb in a leap year", () => {
|
|
16
|
+
expect(getDaysInMonth(2024, 1)).toBe(29);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("returns 28 for Feb in a non-leap year", () => {
|
|
20
|
+
expect(getDaysInMonth(2023, 1)).toBe(28);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("returns 30 for April", () => {
|
|
24
|
+
expect(getDaysInMonth(2024, 3)).toBe(30);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("getFirstDayOfMonth", () => {
|
|
29
|
+
it("returns the correct day of week", () => {
|
|
30
|
+
// Jan 1, 2024 is a Monday (1)
|
|
31
|
+
expect(getFirstDayOfMonth(2024, 0)).toBe(1);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("isSameDay", () => {
|
|
36
|
+
it("returns true for same dates", () => {
|
|
37
|
+
const a = new Date(2024, 5, 15);
|
|
38
|
+
const b = new Date(2024, 5, 15);
|
|
39
|
+
expect(isSameDay(a, b)).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("returns false for different dates", () => {
|
|
43
|
+
const a = new Date(2024, 5, 15);
|
|
44
|
+
const b = new Date(2024, 5, 16);
|
|
45
|
+
expect(isSameDay(a, b)).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("ignores time differences", () => {
|
|
49
|
+
const a = new Date(2024, 5, 15, 10, 30);
|
|
50
|
+
const b = new Date(2024, 5, 15, 22, 0);
|
|
51
|
+
expect(isSameDay(a, b)).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe("useCalendar", () => {
|
|
56
|
+
it("initializes with current month when no props", () => {
|
|
57
|
+
const now = new Date();
|
|
58
|
+
const { result } = renderHook(() => useCalendar({}));
|
|
59
|
+
expect(result.current.year).toBe(now.getFullYear());
|
|
60
|
+
expect(result.current.monthIndex).toBe(now.getMonth());
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("initializes with selected date's month", () => {
|
|
64
|
+
const selected = new Date(2024, 5, 15); // June 2024
|
|
65
|
+
const { result } = renderHook(() => useCalendar({ selected }));
|
|
66
|
+
expect(result.current.year).toBe(2024);
|
|
67
|
+
expect(result.current.monthIndex).toBe(5);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("navigates to previous month (uncontrolled)", () => {
|
|
71
|
+
const selected = new Date(2024, 5, 15); // June 2024
|
|
72
|
+
const { result } = renderHook(() => useCalendar({ selected }));
|
|
73
|
+
|
|
74
|
+
act(() => result.current.goToPrevMonth());
|
|
75
|
+
expect(result.current.monthIndex).toBe(4); // May
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("navigates to next month (uncontrolled)", () => {
|
|
79
|
+
const selected = new Date(2024, 5, 15); // June 2024
|
|
80
|
+
const { result } = renderHook(() => useCalendar({ selected }));
|
|
81
|
+
|
|
82
|
+
act(() => result.current.goToNextMonth());
|
|
83
|
+
expect(result.current.monthIndex).toBe(6); // July
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("wraps around year boundary going backward (uncontrolled)", () => {
|
|
87
|
+
const selected = new Date(2024, 0, 15); // January 2024
|
|
88
|
+
const { result } = renderHook(() => useCalendar({ selected }));
|
|
89
|
+
|
|
90
|
+
act(() => result.current.goToPrevMonth());
|
|
91
|
+
expect(result.current.monthIndex).toBe(11); // December
|
|
92
|
+
expect(result.current.year).toBe(2023);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("calls onMonthChange in controlled mode", () => {
|
|
96
|
+
const onMonthChange = vi.fn();
|
|
97
|
+
const month = new Date(2024, 5, 1);
|
|
98
|
+
const { result } = renderHook(() =>
|
|
99
|
+
useCalendar({ month, onMonthChange }),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
act(() => result.current.goToNextMonth());
|
|
103
|
+
expect(onMonthChange).toHaveBeenCalled();
|
|
104
|
+
// Controlled: monthIndex stays the same
|
|
105
|
+
expect(result.current.monthIndex).toBe(5);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("calls onSelect when a day is pressed", () => {
|
|
109
|
+
const onSelect = vi.fn();
|
|
110
|
+
const month = new Date(2024, 5, 1);
|
|
111
|
+
const { result } = renderHook(() => useCalendar({ month, onSelect }));
|
|
112
|
+
|
|
113
|
+
act(() => result.current.handleDayPress(15));
|
|
114
|
+
expect(onSelect).toHaveBeenCalledWith(new Date(2024, 5, 15));
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("does not call onSelect when disabled", () => {
|
|
118
|
+
const onSelect = vi.fn();
|
|
119
|
+
const month = new Date(2024, 5, 1);
|
|
120
|
+
const { result } = renderHook(() =>
|
|
121
|
+
useCalendar({ month, onSelect, disabled: true }),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
act(() => result.current.handleDayPress(15));
|
|
125
|
+
expect(onSelect).not.toHaveBeenCalled();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("generates correct cells array", () => {
|
|
129
|
+
const month = new Date(2024, 5, 1); // June 2024 starts on Saturday (6)
|
|
130
|
+
const { result } = renderHook(() => useCalendar({ month }));
|
|
131
|
+
|
|
132
|
+
// June 2024: first day is Saturday (6), 30 days
|
|
133
|
+
expect(result.current.cells.filter((c) => c === null)).toHaveLength(
|
|
134
|
+
result.current.firstDay,
|
|
135
|
+
);
|
|
136
|
+
expect(result.current.cells.filter((c) => c !== null)).toHaveLength(30);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("provides a human-readable month label", () => {
|
|
140
|
+
const month = new Date(2024, 5, 1);
|
|
141
|
+
const { result } = renderHook(() => useCalendar({ month }));
|
|
142
|
+
expect(result.current.monthLabel).toContain("June");
|
|
143
|
+
expect(result.current.monthLabel).toContain("2024");
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useControllableState } from "../../hooks/useControllableState";
|
|
3
|
+
|
|
4
|
+
interface UseCalendarProps {
|
|
5
|
+
selected?: Date;
|
|
6
|
+
onSelect?: (date: Date | undefined) => void;
|
|
7
|
+
month?: Date;
|
|
8
|
+
onMonthChange?: (month: Date) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getDaysInMonth(year: number, month: number): number {
|
|
13
|
+
return new Date(year, month + 1, 0).getDate();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function getFirstDayOfMonth(year: number, month: number): number {
|
|
17
|
+
return new Date(year, month, 1).getDay();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isSameDay(a: Date, b: Date): boolean {
|
|
21
|
+
return (
|
|
22
|
+
a.getFullYear() === b.getFullYear() &&
|
|
23
|
+
a.getMonth() === b.getMonth() &&
|
|
24
|
+
a.getDate() === b.getDate()
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function isToday(date: Date): boolean {
|
|
29
|
+
return isSameDay(date, new Date());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function useCalendar({
|
|
33
|
+
selected,
|
|
34
|
+
onSelect,
|
|
35
|
+
month: controlledMonth,
|
|
36
|
+
onMonthChange,
|
|
37
|
+
disabled = false,
|
|
38
|
+
}: UseCalendarProps) {
|
|
39
|
+
const [displayMonth, setDisplayMonth] = useControllableState<Date>({
|
|
40
|
+
value: controlledMonth,
|
|
41
|
+
defaultValue: controlledMonth || selected || new Date(),
|
|
42
|
+
onChange: onMonthChange,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const year = displayMonth.getFullYear();
|
|
46
|
+
const monthIndex = displayMonth.getMonth();
|
|
47
|
+
const daysInMonth = getDaysInMonth(year, monthIndex);
|
|
48
|
+
const firstDay = getFirstDayOfMonth(year, monthIndex);
|
|
49
|
+
|
|
50
|
+
const monthLabel = displayMonth.toLocaleString("default", {
|
|
51
|
+
month: "long",
|
|
52
|
+
year: "numeric",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const goToPrevMonth = useCallback(() => {
|
|
56
|
+
const prev = new Date(year, monthIndex - 1, 1);
|
|
57
|
+
setDisplayMonth(prev);
|
|
58
|
+
}, [year, monthIndex, setDisplayMonth]);
|
|
59
|
+
|
|
60
|
+
const goToNextMonth = useCallback(() => {
|
|
61
|
+
const next = new Date(year, monthIndex + 1, 1);
|
|
62
|
+
setDisplayMonth(next);
|
|
63
|
+
}, [year, monthIndex, setDisplayMonth]);
|
|
64
|
+
|
|
65
|
+
const handleDayPress = useCallback(
|
|
66
|
+
(day: number) => {
|
|
67
|
+
if (disabled) return;
|
|
68
|
+
const date = new Date(year, monthIndex, day);
|
|
69
|
+
onSelect?.(date);
|
|
70
|
+
},
|
|
71
|
+
[disabled, year, monthIndex, onSelect],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const cells: (number | null)[] = [];
|
|
75
|
+
for (let i = 0; i < firstDay; i++) {
|
|
76
|
+
cells.push(null);
|
|
77
|
+
}
|
|
78
|
+
for (let d = 1; d <= daysInMonth; d++) {
|
|
79
|
+
cells.push(d);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
displayMonth,
|
|
84
|
+
year,
|
|
85
|
+
monthIndex,
|
|
86
|
+
daysInMonth,
|
|
87
|
+
firstDay,
|
|
88
|
+
monthLabel,
|
|
89
|
+
cells,
|
|
90
|
+
goToPrevMonth,
|
|
91
|
+
goToNextMonth,
|
|
92
|
+
handleDayPress,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { View, type ViewProps } from "react-native";
|
|
2
|
+
import type { CardProps } from "./Card.types";
|
|
3
|
+
import { cn } from "../../utils/cn";
|
|
4
|
+
import type { GlassProps } from "../../utils/glass.native";
|
|
5
|
+
import { GlassWrapper, useGlassActive } from "../../utils/withGlass.native";
|
|
6
|
+
import { useTheme, remToNumber } from "../../theme/native";
|
|
7
|
+
|
|
8
|
+
interface CardNativeProps extends CardProps, GlassProps, ViewProps {}
|
|
9
|
+
|
|
10
|
+
function CardContent({ children, className, ...props }: Omit<CardNativeProps, "glass" | "glassEffect" | "glassTextColor">) {
|
|
11
|
+
const glassActive = useGlassActive();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<View
|
|
15
|
+
className={cn(
|
|
16
|
+
"rounded-xl shadow-sm",
|
|
17
|
+
!glassActive && "border border-border bg-card text-card-foreground",
|
|
18
|
+
className,
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</View>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function Card({ children, className, glass, glassEffect, glassTextColor: _, ...props }: CardNativeProps) {
|
|
28
|
+
const { tokens, glass: themeGlass } = useTheme();
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<GlassWrapper enabled={glass ?? themeGlass} effect={glassEffect} style={{ borderRadius: remToNumber(tokens.radius.xl) }}>
|
|
32
|
+
<CardContent className={className} {...props}>
|
|
33
|
+
{children}
|
|
34
|
+
</CardContent>
|
|
35
|
+
</GlassWrapper>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Card.displayName = "Card";
|
|
40
|
+
|
|
41
|
+
export { Card };
|
|
42
|
+
export type { CardNativeProps };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Card } from "./Card.web";
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Components/Card",
|
|
6
|
+
component: Card,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
} satisfies Meta<typeof Card>;
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
type Story = StoryObj<typeof meta>;
|
|
15
|
+
|
|
16
|
+
export const Default: Story = {
|
|
17
|
+
args: {
|
|
18
|
+
children: (
|
|
19
|
+
<div style={{ padding: "1.5rem" }}>
|
|
20
|
+
<h3 style={{ fontSize: "1.125rem", fontWeight: 600, marginBottom: "0.5rem" }}>
|
|
21
|
+
Card Title
|
|
22
|
+
</h3>
|
|
23
|
+
<p style={{ fontSize: "0.875rem", color: "var(--color-muted-foreground)" }}>
|
|
24
|
+
This is a basic card component with some example content.
|
|
25
|
+
</p>
|
|
26
|
+
</div>
|
|
27
|
+
),
|
|
28
|
+
style: { width: 350 },
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Simple: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
children: (
|
|
35
|
+
<div style={{ padding: "1.5rem" }}>
|
|
36
|
+
<p style={{ fontSize: "0.875rem" }}>A simple card with just text content.</p>
|
|
37
|
+
</div>
|
|
38
|
+
),
|
|
39
|
+
style: { width: 300 },
|
|
40
|
+
},
|
|
41
|
+
};
|