@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,211 @@
|
|
|
1
|
+
import { createContext, useContext, useState, useCallback, useEffect, createElement } from "react";
|
|
2
|
+
import { Uniwind } from "uniwind";
|
|
3
|
+
import type { ThemeTokens, ThemePreset } from "./theme.types";
|
|
4
|
+
import { defaultPreset } from "./presets/default";
|
|
5
|
+
import { darkPreset } from "./presets/dark";
|
|
6
|
+
import { auroraPreset } from "./presets/aurora";
|
|
7
|
+
|
|
8
|
+
// --- Rem to Number Conversion (for programmatic access) ---
|
|
9
|
+
|
|
10
|
+
const BASE_FONT_SIZE = 16;
|
|
11
|
+
|
|
12
|
+
export function remToNumber(value: string): number {
|
|
13
|
+
const match = value.match(/^([\d.]+)rem$/);
|
|
14
|
+
if (match) {
|
|
15
|
+
return parseFloat(match[1]) * BASE_FONT_SIZE;
|
|
16
|
+
}
|
|
17
|
+
const pxMatch = value.match(/^([\d.]+)px$/);
|
|
18
|
+
if (pxMatch) {
|
|
19
|
+
return parseFloat(pxMatch[1]);
|
|
20
|
+
}
|
|
21
|
+
return parseFloat(value) || 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// --- Native Theme Types (for programmatic access) ---
|
|
25
|
+
|
|
26
|
+
export interface NativeThemeRadius {
|
|
27
|
+
sm: number;
|
|
28
|
+
md: number;
|
|
29
|
+
lg: number;
|
|
30
|
+
xl: number;
|
|
31
|
+
full: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface NativeThemeSpacing {
|
|
35
|
+
xs: number;
|
|
36
|
+
sm: number;
|
|
37
|
+
md: number;
|
|
38
|
+
lg: number;
|
|
39
|
+
xl: number;
|
|
40
|
+
"2xl": number;
|
|
41
|
+
"3xl": number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface NativeTheme {
|
|
45
|
+
radius: NativeThemeRadius;
|
|
46
|
+
spacing: NativeThemeSpacing;
|
|
47
|
+
typography: {
|
|
48
|
+
fontFamily: string;
|
|
49
|
+
fontFamilyMono: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function tokensToNativeTheme(tokens: ThemeTokens): NativeTheme {
|
|
54
|
+
return {
|
|
55
|
+
radius: {
|
|
56
|
+
sm: remToNumber(tokens.radius.sm),
|
|
57
|
+
md: remToNumber(tokens.radius.md),
|
|
58
|
+
lg: remToNumber(tokens.radius.lg),
|
|
59
|
+
xl: remToNumber(tokens.radius.xl),
|
|
60
|
+
full: remToNumber(tokens.radius.full),
|
|
61
|
+
},
|
|
62
|
+
spacing: {
|
|
63
|
+
xs: remToNumber(tokens.spacing.xs),
|
|
64
|
+
sm: remToNumber(tokens.spacing.sm),
|
|
65
|
+
md: remToNumber(tokens.spacing.md),
|
|
66
|
+
lg: remToNumber(tokens.spacing.lg),
|
|
67
|
+
xl: remToNumber(tokens.spacing.xl),
|
|
68
|
+
"2xl": remToNumber(tokens.spacing["2xl"]),
|
|
69
|
+
"3xl": remToNumber(tokens.spacing["3xl"]),
|
|
70
|
+
},
|
|
71
|
+
typography: { ...tokens.typography },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Pre-computed numeric values for programmatic use (animations, charts, etc.) */
|
|
76
|
+
export const themes = {
|
|
77
|
+
default: tokensToNativeTheme(defaultPreset.tokens),
|
|
78
|
+
dark: tokensToNativeTheme(darkPreset.tokens),
|
|
79
|
+
aurora: tokensToNativeTheme(auroraPreset.tokens),
|
|
80
|
+
} as const;
|
|
81
|
+
|
|
82
|
+
export function createNativeTheme(preset: ThemePreset): NativeTheme {
|
|
83
|
+
return tokensToNativeTheme(preset.tokens);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// --- ThemeProvider (mirrors web API) ---
|
|
87
|
+
|
|
88
|
+
// Map preset names to uniwind base theme ("light" / "dark")
|
|
89
|
+
// Custom themes beyond light/dark use updateCSSVariables to override colors at runtime
|
|
90
|
+
const PRESET_TO_UNIWIND: Record<string, "dark" | "light"> = {
|
|
91
|
+
default: "light",
|
|
92
|
+
dark: "dark",
|
|
93
|
+
aurora: "dark",
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Build CSS variable record from a preset's tokens (for updateCSSVariables).
|
|
97
|
+
// Colors are passed as strings (Uniwind's culori parses them to hex).
|
|
98
|
+
// Radius/spacing are converted from rem strings to pixel numbers since
|
|
99
|
+
// React Native style properties require numeric values.
|
|
100
|
+
// Typography is passed as strings (font family names).
|
|
101
|
+
function tokensToCssVars(tokens: ThemeTokens): Record<string, string | number> {
|
|
102
|
+
const vars: Record<string, string | number> = {};
|
|
103
|
+
for (const [key, value] of Object.entries(tokens.colors)) {
|
|
104
|
+
vars[`--color-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`] = value;
|
|
105
|
+
}
|
|
106
|
+
for (const [key, value] of Object.entries(tokens.radius)) {
|
|
107
|
+
vars[`--radius-${key}`] = remToNumber(value);
|
|
108
|
+
}
|
|
109
|
+
for (const [key, value] of Object.entries(tokens.spacing)) {
|
|
110
|
+
vars[`--spacing-${key}`] = remToNumber(value);
|
|
111
|
+
}
|
|
112
|
+
vars["--font-family"] = tokens.typography.fontFamily;
|
|
113
|
+
vars["--font-family-mono"] = tokens.typography.fontFamilyMono;
|
|
114
|
+
if (tokens.shadow) {
|
|
115
|
+
for (const [key, value] of Object.entries(tokens.shadow)) {
|
|
116
|
+
vars[`--shadow-${key}`] = value;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return vars;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Original CSS vars for each uniwind variant, used to restore after custom theme overrides
|
|
123
|
+
const BASE_VARS: Record<string, Record<string, string | number>> = {
|
|
124
|
+
light: tokensToCssVars(defaultPreset.tokens),
|
|
125
|
+
dark: tokensToCssVars(darkPreset.tokens),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
interface ThemeContextValue {
|
|
129
|
+
theme: string;
|
|
130
|
+
setTheme: (name: string) => void;
|
|
131
|
+
tokens: ThemeTokens;
|
|
132
|
+
glass: boolean;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const ThemeContext = createContext<ThemeContextValue | null>(null);
|
|
136
|
+
|
|
137
|
+
export function useTheme(): ThemeContextValue {
|
|
138
|
+
const ctx = useContext(ThemeContext);
|
|
139
|
+
if (!ctx) {
|
|
140
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
141
|
+
}
|
|
142
|
+
return ctx;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interface ThemeProviderProps {
|
|
146
|
+
children: React.ReactNode;
|
|
147
|
+
defaultTheme?: string;
|
|
148
|
+
presets?: ThemePreset[];
|
|
149
|
+
glass?: boolean;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function useGlass(): boolean {
|
|
153
|
+
const ctx = useContext(ThemeContext);
|
|
154
|
+
return ctx?.glass ?? false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function ThemeProvider({
|
|
158
|
+
children,
|
|
159
|
+
defaultTheme = "default",
|
|
160
|
+
presets: customPresets,
|
|
161
|
+
glass = false,
|
|
162
|
+
}: ThemeProviderProps) {
|
|
163
|
+
const presets = customPresets ?? [defaultPreset, darkPreset, auroraPreset];
|
|
164
|
+
const presetMap = new Map(presets.map((p) => [p.name, p]));
|
|
165
|
+
|
|
166
|
+
const [themeName, setThemeName] = useState(defaultTheme);
|
|
167
|
+
const currentPreset = presetMap.get(themeName) ?? presets[0];
|
|
168
|
+
const tokens = currentPreset.tokens;
|
|
169
|
+
|
|
170
|
+
// Switch uniwind to the active theme
|
|
171
|
+
// light/dark have CSS vars defined in global.css @variant blocks (generated by pnpm generate-theme)
|
|
172
|
+
// Custom themes (e.g. aurora) piggyback on a base variant then override colors via updateCSSVariables
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
const uniwindTheme = PRESET_TO_UNIWIND[themeName] ?? "light";
|
|
175
|
+
Uniwind.setTheme(uniwindTheme);
|
|
176
|
+
|
|
177
|
+
if (themeName !== "default" && themeName !== "dark") {
|
|
178
|
+
// Custom theme: override the base variant's color CSS variables
|
|
179
|
+
const vars = tokensToCssVars(tokens);
|
|
180
|
+
Uniwind.updateCSSVariables(uniwindTheme, vars);
|
|
181
|
+
} else {
|
|
182
|
+
// Built-in theme: restore original CSS variables in case a custom theme mutated them
|
|
183
|
+
const original = BASE_VARS[uniwindTheme];
|
|
184
|
+
if (original) {
|
|
185
|
+
Uniwind.updateCSSVariables(uniwindTheme, original);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, [themeName, tokens]);
|
|
189
|
+
|
|
190
|
+
const setTheme = useCallback(
|
|
191
|
+
(name: string) => {
|
|
192
|
+
if (presetMap.has(name)) {
|
|
193
|
+
setThemeName(name);
|
|
194
|
+
} else {
|
|
195
|
+
console.warn(
|
|
196
|
+
`Theme "${name}" not found. Available: ${Array.from(presetMap.keys()).join(", ")}`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
[presetMap],
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
return createElement(
|
|
204
|
+
ThemeContext.Provider,
|
|
205
|
+
{ value: { theme: themeName, setTheme, tokens, glass } },
|
|
206
|
+
children,
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { defaultPreset, darkPreset, auroraPreset };
|
|
211
|
+
export type { ThemePreset, ThemeTokens };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ThemePreset } from "../theme.types";
|
|
2
|
+
|
|
3
|
+
export const auroraPreset: ThemePreset = {
|
|
4
|
+
name: "aurora",
|
|
5
|
+
tokens: {
|
|
6
|
+
colors: {
|
|
7
|
+
background: "oklch(0.18 0.04 270)",
|
|
8
|
+
foreground: "oklch(0.93 0.01 250)",
|
|
9
|
+
card: "oklch(0.22 0.045 270)",
|
|
10
|
+
cardForeground: "oklch(0.93 0.01 250)",
|
|
11
|
+
popover: "oklch(0.22 0.045 270)",
|
|
12
|
+
popoverForeground: "oklch(0.93 0.01 250)",
|
|
13
|
+
primary: "oklch(0.75 0.15 190)",
|
|
14
|
+
primaryForeground: "oklch(0.15 0.04 270)",
|
|
15
|
+
secondary: "oklch(0.35 0.08 290)",
|
|
16
|
+
secondaryForeground: "oklch(0.90 0.03 290)",
|
|
17
|
+
muted: "oklch(0.28 0.04 270)",
|
|
18
|
+
mutedForeground: "oklch(0.65 0.04 260)",
|
|
19
|
+
accent: "oklch(0.30 0.05 270)",
|
|
20
|
+
accentForeground: "oklch(0.93 0.01 250)",
|
|
21
|
+
destructive: "oklch(0.65 0.22 15)",
|
|
22
|
+
destructiveForeground: "oklch(0.95 0.01 15)",
|
|
23
|
+
border: "oklch(0.26 0.035 270)",
|
|
24
|
+
input: "oklch(0.26 0.035 270)",
|
|
25
|
+
ring: "oklch(0.65 0.12 190)",
|
|
26
|
+
},
|
|
27
|
+
radius: {
|
|
28
|
+
sm: "0.5rem",
|
|
29
|
+
md: "0.75rem",
|
|
30
|
+
lg: "1rem",
|
|
31
|
+
xl: "1.5rem",
|
|
32
|
+
full: "9999px",
|
|
33
|
+
},
|
|
34
|
+
spacing: {
|
|
35
|
+
xs: "0.375rem",
|
|
36
|
+
sm: "0.75rem",
|
|
37
|
+
md: "1.25rem",
|
|
38
|
+
lg: "2rem",
|
|
39
|
+
xl: "2.5rem",
|
|
40
|
+
"2xl": "3.5rem",
|
|
41
|
+
"3xl": "5rem",
|
|
42
|
+
},
|
|
43
|
+
typography: {
|
|
44
|
+
fontFamily:
|
|
45
|
+
'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',
|
|
46
|
+
fontFamilyMono:
|
|
47
|
+
'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',
|
|
48
|
+
},
|
|
49
|
+
shadow: {
|
|
50
|
+
sm: "0 1px 3px 0 oklch(0.55 0.12 190 / 0.3), 0 1px 2px -1px oklch(0.55 0.12 190 / 0.2)",
|
|
51
|
+
md: "0 4px 8px -1px oklch(0.55 0.12 190 / 0.35), 0 2px 4px -2px oklch(0.55 0.12 190 / 0.25)",
|
|
52
|
+
lg: "0 10px 20px -3px oklch(0.55 0.12 190 / 0.4), 0 4px 8px -4px oklch(0.55 0.12 190 / 0.3)",
|
|
53
|
+
xl: "0 20px 30px -5px oklch(0.55 0.12 190 / 0.45), 0 8px 12px -6px oklch(0.55 0.12 190 / 0.35)",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ThemePreset } from "../theme.types";
|
|
2
|
+
import { baseTokens } from "../tokens";
|
|
3
|
+
|
|
4
|
+
export const darkPreset: ThemePreset = {
|
|
5
|
+
name: "dark",
|
|
6
|
+
tokens: {
|
|
7
|
+
...baseTokens,
|
|
8
|
+
colors: {
|
|
9
|
+
background: "oklch(0.145 0 0)",
|
|
10
|
+
foreground: "oklch(0.985 0 0)",
|
|
11
|
+
card: "oklch(0.145 0 0)",
|
|
12
|
+
cardForeground: "oklch(0.985 0 0)",
|
|
13
|
+
popover: "oklch(0.145 0 0)",
|
|
14
|
+
popoverForeground: "oklch(0.985 0 0)",
|
|
15
|
+
primary: "oklch(0.985 0 0)",
|
|
16
|
+
primaryForeground: "oklch(0.205 0 0)",
|
|
17
|
+
secondary: "oklch(0.269 0 0)",
|
|
18
|
+
secondaryForeground: "oklch(0.985 0 0)",
|
|
19
|
+
muted: "oklch(0.269 0 0)",
|
|
20
|
+
mutedForeground: "oklch(0.708 0 0)",
|
|
21
|
+
accent: "oklch(0.269 0 0)",
|
|
22
|
+
accentForeground: "oklch(0.985 0 0)",
|
|
23
|
+
destructive: "oklch(0.396 0.141 25.723)",
|
|
24
|
+
destructiveForeground: "oklch(0.637 0.237 25.331)",
|
|
25
|
+
border: "oklch(0.269 0 0)",
|
|
26
|
+
input: "oklch(0.269 0 0)",
|
|
27
|
+
ring: "oklch(0.439 0 0)",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ThemePreset } from "../theme.types";
|
|
2
|
+
import { baseTokens } from "../tokens";
|
|
3
|
+
|
|
4
|
+
export const defaultPreset: ThemePreset = {
|
|
5
|
+
name: "default",
|
|
6
|
+
tokens: {
|
|
7
|
+
...baseTokens,
|
|
8
|
+
colors: {
|
|
9
|
+
background: "oklch(1 0 0)",
|
|
10
|
+
foreground: "oklch(0.145 0 0)",
|
|
11
|
+
card: "oklch(1 0 0)",
|
|
12
|
+
cardForeground: "oklch(0.145 0 0)",
|
|
13
|
+
popover: "oklch(1 0 0)",
|
|
14
|
+
popoverForeground: "oklch(0.145 0 0)",
|
|
15
|
+
primary: "oklch(0.205 0 0)",
|
|
16
|
+
primaryForeground: "oklch(0.985 0 0)",
|
|
17
|
+
secondary: "oklch(0.965 0 0)",
|
|
18
|
+
secondaryForeground: "oklch(0.205 0 0)",
|
|
19
|
+
muted: "oklch(0.965 0 0)",
|
|
20
|
+
mutedForeground: "oklch(0.556 0 0)",
|
|
21
|
+
accent: "oklch(0.965 0 0)",
|
|
22
|
+
accentForeground: "oklch(0.205 0 0)",
|
|
23
|
+
destructive: "oklch(0.577 0.245 27.325)",
|
|
24
|
+
destructiveForeground: "oklch(0.985 0 0)",
|
|
25
|
+
border: "oklch(0.922 0 0)",
|
|
26
|
+
input: "oklch(0.922 0 0)",
|
|
27
|
+
ring: "oklch(0.708 0 0)",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface ThemeColors {
|
|
2
|
+
background: string;
|
|
3
|
+
foreground: string;
|
|
4
|
+
card: string;
|
|
5
|
+
cardForeground: string;
|
|
6
|
+
popover: string;
|
|
7
|
+
popoverForeground: string;
|
|
8
|
+
primary: string;
|
|
9
|
+
primaryForeground: string;
|
|
10
|
+
secondary: string;
|
|
11
|
+
secondaryForeground: string;
|
|
12
|
+
muted: string;
|
|
13
|
+
mutedForeground: string;
|
|
14
|
+
accent: string;
|
|
15
|
+
accentForeground: string;
|
|
16
|
+
destructive: string;
|
|
17
|
+
destructiveForeground: string;
|
|
18
|
+
border: string;
|
|
19
|
+
input: string;
|
|
20
|
+
ring: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ThemeRadius {
|
|
24
|
+
sm: string;
|
|
25
|
+
md: string;
|
|
26
|
+
lg: string;
|
|
27
|
+
xl: string;
|
|
28
|
+
full: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ThemeSpacing {
|
|
32
|
+
xs: string;
|
|
33
|
+
sm: string;
|
|
34
|
+
md: string;
|
|
35
|
+
lg: string;
|
|
36
|
+
xl: string;
|
|
37
|
+
"2xl": string;
|
|
38
|
+
"3xl": string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ThemeTypography {
|
|
42
|
+
fontFamily: string;
|
|
43
|
+
fontFamilyMono: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ThemeShadow {
|
|
47
|
+
sm: string;
|
|
48
|
+
md: string;
|
|
49
|
+
lg: string;
|
|
50
|
+
xl: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ThemeTokens {
|
|
54
|
+
colors: ThemeColors;
|
|
55
|
+
radius: ThemeRadius;
|
|
56
|
+
spacing: ThemeSpacing;
|
|
57
|
+
typography: ThemeTypography;
|
|
58
|
+
shadow?: ThemeShadow;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface ThemePreset {
|
|
62
|
+
name: string;
|
|
63
|
+
tokens: ThemeTokens;
|
|
64
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ThemeTokens } from "./theme.types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Canonical theme token definitions.
|
|
5
|
+
* All values are CSS-compatible strings.
|
|
6
|
+
* Native side converts rem → numbers automatically.
|
|
7
|
+
*/
|
|
8
|
+
export const baseTokens: Omit<ThemeTokens, "colors"> = {
|
|
9
|
+
radius: {
|
|
10
|
+
sm: "0.25rem",
|
|
11
|
+
md: "0.375rem",
|
|
12
|
+
lg: "0.5rem",
|
|
13
|
+
xl: "0.75rem",
|
|
14
|
+
full: "9999px",
|
|
15
|
+
},
|
|
16
|
+
spacing: {
|
|
17
|
+
xs: "0.25rem",
|
|
18
|
+
sm: "0.5rem",
|
|
19
|
+
md: "1rem",
|
|
20
|
+
lg: "1.5rem",
|
|
21
|
+
xl: "2rem",
|
|
22
|
+
"2xl": "3rem",
|
|
23
|
+
"3xl": "4rem",
|
|
24
|
+
},
|
|
25
|
+
typography: {
|
|
26
|
+
fontFamily:
|
|
27
|
+
'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
28
|
+
fontFamilyMono:
|
|
29
|
+
'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',
|
|
30
|
+
},
|
|
31
|
+
};
|
package/src/theme/web.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, useEffect, useState, createElement } from "react";
|
|
4
|
+
import type { ThemePreset, ThemeTokens, ThemeColors, ThemeRadius, ThemeSpacing, ThemeShadow } from "./theme.types";
|
|
5
|
+
import { defaultPreset } from "./presets/default";
|
|
6
|
+
import { darkPreset } from "./presets/dark";
|
|
7
|
+
import { auroraPreset } from "./presets/aurora";
|
|
8
|
+
|
|
9
|
+
// --- CSS Variable Generation ---
|
|
10
|
+
|
|
11
|
+
function colorToCssVar(key: string): string {
|
|
12
|
+
// camelCase → kebab-case
|
|
13
|
+
return `--color-${key.replace(/([A-Z])/g, "-$1").toLowerCase()}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function radiusToCssVar(key: string): string {
|
|
17
|
+
return `--radius-${key}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function spacingToCssVar(key: string): string {
|
|
21
|
+
return `--spacing-${key}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function generateCssVars(tokens: ThemeTokens): Record<string, string> {
|
|
25
|
+
const vars: Record<string, string> = {};
|
|
26
|
+
|
|
27
|
+
for (const [key, value] of Object.entries(tokens.colors)) {
|
|
28
|
+
vars[colorToCssVar(key)] = value;
|
|
29
|
+
}
|
|
30
|
+
for (const [key, value] of Object.entries(tokens.radius)) {
|
|
31
|
+
vars[radiusToCssVar(key)] = value;
|
|
32
|
+
}
|
|
33
|
+
for (const [key, value] of Object.entries(tokens.spacing)) {
|
|
34
|
+
vars[spacingToCssVar(key)] = value;
|
|
35
|
+
}
|
|
36
|
+
vars["--font-family"] = tokens.typography.fontFamily;
|
|
37
|
+
vars["--font-family-mono"] = tokens.typography.fontFamilyMono;
|
|
38
|
+
|
|
39
|
+
if (tokens.shadow) {
|
|
40
|
+
for (const [key, value] of Object.entries(tokens.shadow)) {
|
|
41
|
+
vars[`--shadow-${key}`] = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return vars;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Shadow CSS var keys that may have been set by a previous theme and need clearing
|
|
49
|
+
const SHADOW_KEYS = ["--shadow-sm", "--shadow-md", "--shadow-lg", "--shadow-xl"];
|
|
50
|
+
|
|
51
|
+
function applyCssVars(vars: Record<string, string>, element: HTMLElement = document.documentElement) {
|
|
52
|
+
// Clear shadow overrides that may have been set by a previous theme
|
|
53
|
+
for (const key of SHADOW_KEYS) {
|
|
54
|
+
if (!(key in vars)) {
|
|
55
|
+
element.style.removeProperty(key);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
59
|
+
element.style.setProperty(key, value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// --- Theme Context ---
|
|
64
|
+
|
|
65
|
+
interface ThemeContextValue {
|
|
66
|
+
theme: string;
|
|
67
|
+
setTheme: (name: string) => void;
|
|
68
|
+
tokens: ThemeTokens;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const ThemeContext = createContext<ThemeContextValue | null>(null);
|
|
72
|
+
|
|
73
|
+
export function useTheme(): ThemeContextValue {
|
|
74
|
+
const ctx = useContext(ThemeContext);
|
|
75
|
+
if (!ctx) {
|
|
76
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
77
|
+
}
|
|
78
|
+
return ctx;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// --- ThemeProvider ---
|
|
82
|
+
|
|
83
|
+
interface ThemeProviderProps {
|
|
84
|
+
children: React.ReactNode;
|
|
85
|
+
defaultTheme?: string;
|
|
86
|
+
presets?: ThemePreset[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function ThemeProvider({
|
|
90
|
+
children,
|
|
91
|
+
defaultTheme = "default",
|
|
92
|
+
presets: customPresets,
|
|
93
|
+
}: ThemeProviderProps) {
|
|
94
|
+
const presets = customPresets ?? [defaultPreset, darkPreset, auroraPreset];
|
|
95
|
+
const presetMap = new Map(presets.map((p) => [p.name, p]));
|
|
96
|
+
|
|
97
|
+
const [themeName, setThemeName] = useState(defaultTheme);
|
|
98
|
+
|
|
99
|
+
const currentPreset = presetMap.get(themeName) ?? presets[0];
|
|
100
|
+
const tokens = currentPreset.tokens;
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
const vars = generateCssVars(tokens);
|
|
104
|
+
applyCssVars(vars);
|
|
105
|
+
}, [tokens]);
|
|
106
|
+
|
|
107
|
+
const setTheme = (name: string) => {
|
|
108
|
+
if (presetMap.has(name)) {
|
|
109
|
+
setThemeName(name);
|
|
110
|
+
} else {
|
|
111
|
+
console.warn(`Theme "${name}" not found. Available: ${Array.from(presetMap.keys()).join(", ")}`);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return createElement(
|
|
116
|
+
ThemeContext.Provider,
|
|
117
|
+
{ value: { theme: themeName, setTheme, tokens } },
|
|
118
|
+
children,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { defaultPreset, darkPreset, auroraPreset };
|
|
123
|
+
export type { ThemePreset, ThemeTokens, ThemeColors, ThemeRadius, ThemeSpacing, ThemeShadow };
|
package/src/uniwind.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Type augmentation for uniwind — adds className prop to all React Native components
|
|
2
|
+
import "react-native";
|
|
3
|
+
|
|
4
|
+
declare module "react-native" {
|
|
5
|
+
interface ViewProps {
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
interface TextProps {
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
interface ImageProps {
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ScrollViewProps {
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
interface TextInputProps {
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
interface PressableProps {
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
interface TouchableOpacityProps {
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
interface FlatListProps<T> {
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
interface SectionListProps<T> {
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
interface ModalProps {
|
|
33
|
+
className?: string;
|
|
34
|
+
}
|
|
35
|
+
interface SwitchProps {
|
|
36
|
+
className?: string;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { clsx, type ClassValue } from "clsx";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Merge class names for React Native (via uniwind).
|
|
5
|
+
* Same API as the web cn() — just clsx without tailwind-merge
|
|
6
|
+
* since uniwind handles deduplication at build time.
|
|
7
|
+
*/
|
|
8
|
+
export function cn(...inputs: ClassValue[]) {
|
|
9
|
+
return clsx(inputs);
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { cn } from "./cn";
|
|
3
|
+
|
|
4
|
+
describe("cn", () => {
|
|
5
|
+
it("merges class names", () => {
|
|
6
|
+
expect(cn("foo", "bar")).toBe("foo bar");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("handles conditional classes", () => {
|
|
10
|
+
expect(cn("foo", false && "bar", "baz")).toBe("foo baz");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("deduplicates tailwind classes", () => {
|
|
14
|
+
expect(cn("px-2", "px-4")).toBe("px-4");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("handles undefined and null", () => {
|
|
18
|
+
expect(cn("foo", undefined, null, "bar")).toBe("foo bar");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("handles empty input", () => {
|
|
22
|
+
expect(cn()).toBe("");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("merges conflicting tailwind utilities", () => {
|
|
26
|
+
expect(cn("text-red-500", "text-blue-500")).toBe("text-blue-500");
|
|
27
|
+
});
|
|
28
|
+
});
|
package/src/utils/cn.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Platform } from "react-native";
|
|
2
|
+
|
|
3
|
+
export const GLASS_TEXT_DEFAULT = "text-foreground";
|
|
4
|
+
|
|
5
|
+
export interface GlassProps {
|
|
6
|
+
glass?: boolean;
|
|
7
|
+
glassEffect?: "regular" | "clear";
|
|
8
|
+
/** Tailwind text color class applied to text when glass is active. */
|
|
9
|
+
glassTextColor?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let _isGlassSupported = false;
|
|
13
|
+
if (Platform.OS === "ios" && parseInt(String(Platform.Version), 10) >= 26) {
|
|
14
|
+
try {
|
|
15
|
+
const { isGlassEffectAPIAvailable } = require("expo-glass-effect");
|
|
16
|
+
_isGlassSupported = isGlassEffectAPIAvailable();
|
|
17
|
+
} catch {
|
|
18
|
+
_isGlassSupported = false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const isGlassSupported = _isGlassSupported;
|