@appica/ui-react 1.0.0
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/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/components/accordion/accordion.d.ts +29 -0
- package/dist/components/accordion/accordion.d.ts.map +1 -0
- package/dist/components/accordion/accordion.js +210 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/alert/alert.d.ts +32 -0
- package/dist/components/alert/alert.d.ts.map +1 -0
- package/dist/components/alert/alert.js +203 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +28 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts.map +1 -0
- package/dist/components/alert-dialog/alert-dialog.js +127 -0
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -0
- package/dist/components/autocomplete/autocomplete.d.ts +48 -0
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -0
- package/dist/components/autocomplete/autocomplete.js +299 -0
- package/dist/components/autocomplete/autocomplete.js.map +1 -0
- package/dist/components/avatar/avatar.d.ts +29 -0
- package/dist/components/avatar/avatar.d.ts.map +1 -0
- package/dist/components/avatar/avatar.js +115 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/background-pattern/background-pattern-interactive.d.ts +10 -0
- package/dist/components/background-pattern/background-pattern-interactive.d.ts.map +1 -0
- package/dist/components/background-pattern/background-pattern-interactive.js +72 -0
- package/dist/components/background-pattern/background-pattern-interactive.js.map +1 -0
- package/dist/components/background-pattern/background-pattern-shared.d.ts +12 -0
- package/dist/components/background-pattern/background-pattern-shared.d.ts.map +1 -0
- package/dist/components/background-pattern/background-pattern-shared.js +73 -0
- package/dist/components/background-pattern/background-pattern-shared.js.map +1 -0
- package/dist/components/background-pattern/background-pattern.d.ts +23 -0
- package/dist/components/background-pattern/background-pattern.d.ts.map +1 -0
- package/dist/components/background-pattern/background-pattern.js +49 -0
- package/dist/components/background-pattern/background-pattern.js.map +1 -0
- package/dist/components/background-pattern/index.d.ts +4 -0
- package/dist/components/background-pattern/index.d.ts.map +1 -0
- package/dist/components/background-pattern/index.js +3 -0
- package/dist/components/background-pattern/index.js.map +1 -0
- package/dist/components/badge/badge.d.ts +17 -0
- package/dist/components/badge/badge.d.ts.map +1 -0
- package/dist/components/badge/badge.js +134 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +24 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.js +106 -0
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -0
- package/dist/components/button/button-variants.d.ts +6 -0
- package/dist/components/button/button-variants.d.ts.map +1 -0
- package/dist/components/button/button-variants.js +69 -0
- package/dist/components/button/button-variants.js.map +1 -0
- package/dist/components/button/button.d.ts +10 -0
- package/dist/components/button/button.d.ts.map +1 -0
- package/dist/components/button/button.js +26 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/index.d.ts +3 -0
- package/dist/components/button/index.d.ts.map +1 -0
- package/dist/components/button/index.js +3 -0
- package/dist/components/button/index.js.map +1 -0
- package/dist/components/button-group/button-group-context.d.ts +13 -0
- package/dist/components/button-group/button-group-context.d.ts.map +1 -0
- package/dist/components/button-group/button-group-context.js +7 -0
- package/dist/components/button-group/button-group-context.js.map +1 -0
- package/dist/components/button-group/button-group.d.ts +12 -0
- package/dist/components/button-group/button-group.d.ts.map +1 -0
- package/dist/components/button-group/button-group.js +45 -0
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/calendar/calendar.d.ts +14 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +228 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/carousel/carousel.d.ts +128 -0
- package/dist/components/carousel/carousel.d.ts.map +1 -0
- package/dist/components/carousel/carousel.js +795 -0
- package/dist/components/carousel/carousel.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +7 -0
- package/dist/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.js +128 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +9 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts.map +1 -0
- package/dist/components/checkbox-group/checkbox-group.js +18 -0
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -0
- package/dist/components/chip/chip.d.ts +36 -0
- package/dist/components/chip/chip.d.ts.map +1 -0
- package/dist/components/chip/chip.js +159 -0
- package/dist/components/chip/chip.js.map +1 -0
- package/dist/components/collapsible/collapsible.d.ts +11 -0
- package/dist/components/collapsible/collapsible.d.ts.map +1 -0
- package/dist/components/collapsible/collapsible.js +41 -0
- package/dist/components/collapsible/collapsible.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +57 -0
- package/dist/components/combobox/combobox.d.ts.map +1 -0
- package/dist/components/combobox/combobox.js +456 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/context-menu/context-menu.d.ts +43 -0
- package/dist/components/context-menu/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu/context-menu.js +243 -0
- package/dist/components/context-menu/context-menu.js.map +1 -0
- package/dist/components/copy-button/copy-button.d.ts +15 -0
- package/dist/components/copy-button/copy-button.d.ts.map +1 -0
- package/dist/components/copy-button/copy-button.js +126 -0
- package/dist/components/copy-button/copy-button.js.map +1 -0
- package/dist/components/countdown/countdown.d.ts +26 -0
- package/dist/components/countdown/countdown.d.ts.map +1 -0
- package/dist/components/countdown/countdown.js +111 -0
- package/dist/components/countdown/countdown.js.map +1 -0
- package/dist/components/date-field/date-field.d.ts +25 -0
- package/dist/components/date-field/date-field.d.ts.map +1 -0
- package/dist/components/date-field/date-field.js +403 -0
- package/dist/components/date-field/date-field.js.map +1 -0
- package/dist/components/date-picker/date-picker.d.ts +58 -0
- package/dist/components/date-picker/date-picker.d.ts.map +1 -0
- package/dist/components/date-picker/date-picker.js +449 -0
- package/dist/components/date-picker/date-picker.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +30 -0
- package/dist/components/dialog/dialog.d.ts.map +1 -0
- package/dist/components/dialog/dialog.js +138 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +39 -0
- package/dist/components/drawer/drawer.d.ts.map +1 -0
- package/dist/components/drawer/drawer.js +270 -0
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +43 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +235 -0
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -0
- package/dist/components/field/field.d.ts +15 -0
- package/dist/components/field/field.d.ts.map +1 -0
- package/dist/components/field/field.js +62 -0
- package/dist/components/field/field.js.map +1 -0
- package/dist/components/fieldset/fieldset.d.ts +9 -0
- package/dist/components/fieldset/fieldset.d.ts.map +1 -0
- package/dist/components/fieldset/fieldset.js +20 -0
- package/dist/components/fieldset/fieldset.js.map +1 -0
- package/dist/components/form/form.d.ts +7 -0
- package/dist/components/form/form.d.ts.map +1 -0
- package/dist/components/form/form.js +9 -0
- package/dist/components/form/form.js.map +1 -0
- package/dist/components/gradient-glow/gradient-glow.d.ts +21 -0
- package/dist/components/gradient-glow/gradient-glow.d.ts.map +1 -0
- package/dist/components/gradient-glow/gradient-glow.js +99 -0
- package/dist/components/gradient-glow/gradient-glow.js.map +1 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/index.d.ts.map +1 -0
- package/dist/components/input/index.js +3 -0
- package/dist/components/input/index.js.map +1 -0
- package/dist/components/input/input-variants.d.ts +7 -0
- package/dist/components/input/input-variants.d.ts.map +1 -0
- package/dist/components/input/input-variants.js +52 -0
- package/dist/components/input/input-variants.js.map +1 -0
- package/dist/components/input/input.d.ts +19 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/input.js +96 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/kbd/kbd.d.ts +13 -0
- package/dist/components/kbd/kbd.d.ts.map +1 -0
- package/dist/components/kbd/kbd.js +34 -0
- package/dist/components/kbd/kbd.js.map +1 -0
- package/dist/components/loader/loader.d.ts +10 -0
- package/dist/components/loader/loader.d.ts.map +1 -0
- package/dist/components/loader/loader.js +137 -0
- package/dist/components/loader/loader.js.map +1 -0
- package/dist/components/menubar/menubar.d.ts +44 -0
- package/dist/components/menubar/menubar.d.ts.map +1 -0
- package/dist/components/menubar/menubar.js +114 -0
- package/dist/components/menubar/menubar.js.map +1 -0
- package/dist/components/meter/meter.d.ts +24 -0
- package/dist/components/meter/meter.d.ts.map +1 -0
- package/dist/components/meter/meter.js +105 -0
- package/dist/components/meter/meter.js.map +1 -0
- package/dist/components/navigation/index.d.ts +4 -0
- package/dist/components/navigation/index.d.ts.map +1 -0
- package/dist/components/navigation/index.js +4 -0
- package/dist/components/navigation/index.js.map +1 -0
- package/dist/components/navigation/navigation-context.d.ts +16 -0
- package/dist/components/navigation/navigation-context.d.ts.map +1 -0
- package/dist/components/navigation/navigation-context.js +10 -0
- package/dist/components/navigation/navigation-context.js.map +1 -0
- package/dist/components/navigation/navigation-link-variants.d.ts +9 -0
- package/dist/components/navigation/navigation-link-variants.d.ts.map +1 -0
- package/dist/components/navigation/navigation-link-variants.js +189 -0
- package/dist/components/navigation/navigation-link-variants.js.map +1 -0
- package/dist/components/navigation/navigation-link.d.ts +20 -0
- package/dist/components/navigation/navigation-link.d.ts.map +1 -0
- package/dist/components/navigation/navigation-link.js +54 -0
- package/dist/components/navigation/navigation-link.js.map +1 -0
- package/dist/components/navigation/navigation.d.ts +21 -0
- package/dist/components/navigation/navigation.d.ts.map +1 -0
- package/dist/components/navigation/navigation.js +41 -0
- package/dist/components/navigation/navigation.js.map +1 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +41 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts.map +1 -0
- package/dist/components/navigation-menu/navigation-menu.js +329 -0
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -0
- package/dist/components/number-field/number-field.d.ts +17 -0
- package/dist/components/number-field/number-field.d.ts.map +1 -0
- package/dist/components/number-field/number-field.js +270 -0
- package/dist/components/number-field/number-field.js.map +1 -0
- package/dist/components/otp-field/otp-field.d.ts +19 -0
- package/dist/components/otp-field/otp-field.d.ts.map +1 -0
- package/dist/components/otp-field/otp-field.js +66 -0
- package/dist/components/otp-field/otp-field.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +29 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -0
- package/dist/components/pagination/pagination.js +92 -0
- package/dist/components/pagination/pagination.js.map +1 -0
- package/dist/components/popover/popover.d.ts +22 -0
- package/dist/components/popover/popover.d.ts.map +1 -0
- package/dist/components/popover/popover.js +108 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/preview-card/preview-card.d.ts +16 -0
- package/dist/components/preview-card/preview-card.d.ts.map +1 -0
- package/dist/components/preview-card/preview-card.js +92 -0
- package/dist/components/preview-card/preview-card.js.map +1 -0
- package/dist/components/progress/progress.d.ts +18 -0
- package/dist/components/progress/progress.d.ts.map +1 -0
- package/dist/components/progress/progress.js +134 -0
- package/dist/components/progress/progress.js.map +1 -0
- package/dist/components/radio/radio.d.ts +7 -0
- package/dist/components/radio/radio.d.ts.map +1 -0
- package/dist/components/radio/radio.js +73 -0
- package/dist/components/radio/radio.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +9 -0
- package/dist/components/radio-group/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group/radio-group.js +19 -0
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/scroll-area/scroll-area.d.ts +14 -0
- package/dist/components/scroll-area/scroll-area.d.ts.map +1 -0
- package/dist/components/scroll-area/scroll-area.js +87 -0
- package/dist/components/scroll-area/scroll-area.js.map +1 -0
- package/dist/components/select/select.d.ts +36 -0
- package/dist/components/select/select.d.ts.map +1 -0
- package/dist/components/select/select.js +345 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/separator/separator.d.ts +10 -0
- package/dist/components/separator/separator.d.ts.map +1 -0
- package/dist/components/separator/separator.js +81 -0
- package/dist/components/separator/separator.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +9 -0
- package/dist/components/skeleton/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton.js +27 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/slider/slider.d.ts +11 -0
- package/dist/components/slider/slider.d.ts.map +1 -0
- package/dist/components/slider/slider.js +187 -0
- package/dist/components/slider/slider.js.map +1 -0
- package/dist/components/sparkline/sparkline.d.ts +39 -0
- package/dist/components/sparkline/sparkline.d.ts.map +1 -0
- package/dist/components/sparkline/sparkline.js +356 -0
- package/dist/components/sparkline/sparkline.js.map +1 -0
- package/dist/components/spinner/spinner.d.ts +10 -0
- package/dist/components/spinner/spinner.d.ts.map +1 -0
- package/dist/components/spinner/spinner.js +179 -0
- package/dist/components/spinner/spinner.js.map +1 -0
- package/dist/components/switch/switch.d.ts +33 -0
- package/dist/components/switch/switch.d.ts.map +1 -0
- package/dist/components/switch/switch.js +137 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/table/table.d.ts +34 -0
- package/dist/components/table/table.d.ts.map +1 -0
- package/dist/components/table/table.js +108 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +35 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -0
- package/dist/components/tabs/tabs.js +192 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/text-animate/text-animate.d.ts +31 -0
- package/dist/components/text-animate/text-animate.d.ts.map +1 -0
- package/dist/components/text-animate/text-animate.js +230 -0
- package/dist/components/text-animate/text-animate.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +17 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -0
- package/dist/components/textarea/textarea.js +117 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/thumbnail/thumbnail.d.ts +26 -0
- package/dist/components/thumbnail/thumbnail.d.ts.map +1 -0
- package/dist/components/thumbnail/thumbnail.js +116 -0
- package/dist/components/thumbnail/thumbnail.js.map +1 -0
- package/dist/components/time-field/time-field.d.ts +25 -0
- package/dist/components/time-field/time-field.d.ts.map +1 -0
- package/dist/components/time-field/time-field.js +488 -0
- package/dist/components/time-field/time-field.js.map +1 -0
- package/dist/components/toast/toast.d.ts +59 -0
- package/dist/components/toast/toast.d.ts.map +1 -0
- package/dist/components/toast/toast.js +239 -0
- package/dist/components/toast/toast.js.map +1 -0
- package/dist/components/toc/toc.d.ts +21 -0
- package/dist/components/toc/toc.d.ts.map +1 -0
- package/dist/components/toc/toc.js +185 -0
- package/dist/components/toc/toc.js.map +1 -0
- package/dist/components/toggle/toggle.d.ts +7 -0
- package/dist/components/toggle/toggle.d.ts.map +1 -0
- package/dist/components/toggle/toggle.js +9 -0
- package/dist/components/toggle/toggle.js.map +1 -0
- package/dist/components/toggle-group/toggle-group.d.ts +7 -0
- package/dist/components/toggle-group/toggle-group.d.ts.map +1 -0
- package/dist/components/toggle-group/toggle-group.js +21 -0
- package/dist/components/toggle-group/toggle-group.js.map +1 -0
- package/dist/components/toolbar/toolbar.d.ts +23 -0
- package/dist/components/toolbar/toolbar.d.ts.map +1 -0
- package/dist/components/toolbar/toolbar.js +56 -0
- package/dist/components/toolbar/toolbar.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +16 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.js +64 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/floating.d.ts +47 -0
- package/dist/floating.d.ts.map +1 -0
- package/dist/floating.js +35 -0
- package/dist/floating.js.map +1 -0
- package/dist/hooks/use-direction.d.ts +2 -0
- package/dist/hooks/use-direction.d.ts.map +1 -0
- package/dist/hooks/use-direction.js +3 -0
- package/dist/hooks/use-direction.js.map +1 -0
- package/dist/hooks/use-dismissible.d.ts +16 -0
- package/dist/hooks/use-dismissible.d.ts.map +1 -0
- package/dist/hooks/use-dismissible.js +17 -0
- package/dist/hooks/use-dismissible.js.map +1 -0
- package/dist/hooks/use-local-storage.d.ts +24 -0
- package/dist/hooks/use-local-storage.d.ts.map +1 -0
- package/dist/hooks/use-local-storage.js +127 -0
- package/dist/hooks/use-local-storage.js.map +1 -0
- package/dist/hooks/use-media-query.d.ts +20 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +19 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-reduced-motion.d.ts +7 -0
- package/dist/hooks/use-reduced-motion.d.ts.map +1 -0
- package/dist/hooks/use-reduced-motion.js +13 -0
- package/dist/hooks/use-reduced-motion.js.map +1 -0
- package/dist/hooks/use-theme.d.ts +11 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/hooks/use-theme.js +9 -0
- package/dist/hooks/use-theme.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/modal.d.ts +42 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +18 -0
- package/dist/modal.js.map +1 -0
- package/dist/providers/direction-provider.d.ts +21 -0
- package/dist/providers/direction-provider.d.ts.map +1 -0
- package/dist/providers/direction-provider.js +9 -0
- package/dist/providers/direction-provider.js.map +1 -0
- package/dist/providers/reduced-motion-provider.d.ts +30 -0
- package/dist/providers/reduced-motion-provider.d.ts.map +1 -0
- package/dist/providers/reduced-motion-provider.js +27 -0
- package/dist/providers/reduced-motion-provider.js.map +1 -0
- package/dist/providers/theme-provider/index.d.ts +5 -0
- package/dist/providers/theme-provider/index.d.ts.map +1 -0
- package/dist/providers/theme-provider/index.js +3 -0
- package/dist/providers/theme-provider/index.js.map +1 -0
- package/dist/providers/theme-provider/theme-provider.d.ts +39 -0
- package/dist/providers/theme-provider/theme-provider.d.ts.map +1 -0
- package/dist/providers/theme-provider/theme-provider.js +118 -0
- package/dist/providers/theme-provider/theme-provider.js.map +1 -0
- package/dist/providers/theme-provider/theme-script.d.ts +28 -0
- package/dist/providers/theme-provider/theme-script.d.ts.map +1 -0
- package/dist/providers/theme-provider/theme-script.js +59 -0
- package/dist/providers/theme-provider/theme-script.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +51 -0
- package/dist/utils.js.map +1 -0
- package/package.json +479 -0
- package/src/components/accordion/accordion.test.tsx +220 -0
- package/src/components/accordion/accordion.tsx +269 -0
- package/src/components/alert/alert.test.tsx +188 -0
- package/src/components/alert/alert.tsx +243 -0
- package/src/components/alert-dialog/alert-dialog.test.tsx +141 -0
- package/src/components/alert-dialog/alert-dialog.tsx +179 -0
- package/src/components/autocomplete/autocomplete.test.tsx +384 -0
- package/src/components/autocomplete/autocomplete.tsx +442 -0
- package/src/components/avatar/avatar.test.tsx +368 -0
- package/src/components/avatar/avatar.tsx +142 -0
- package/src/components/background-pattern/background-pattern-interactive.tsx +93 -0
- package/src/components/background-pattern/background-pattern-shared.tsx +96 -0
- package/src/components/background-pattern/background-pattern.test.tsx +97 -0
- package/src/components/background-pattern/background-pattern.tsx +67 -0
- package/src/components/background-pattern/index.ts +3 -0
- package/src/components/badge/badge.test.tsx +58 -0
- package/src/components/badge/badge.tsx +149 -0
- package/src/components/breadcrumb/breadcrumb.test.tsx +174 -0
- package/src/components/breadcrumb/breadcrumb.tsx +146 -0
- package/src/components/button/button-variants.ts +69 -0
- package/src/components/button/button.test.tsx +79 -0
- package/src/components/button/button.tsx +28 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/button-group/button-group-context.ts +18 -0
- package/src/components/button-group/button-group.test.tsx +223 -0
- package/src/components/button-group/button-group.tsx +59 -0
- package/src/components/calendar/calendar.test.tsx +69 -0
- package/src/components/calendar/calendar.tsx +295 -0
- package/src/components/carousel/carousel.test.tsx +493 -0
- package/src/components/carousel/carousel.tsx +1003 -0
- package/src/components/checkbox/checkbox.test.tsx +100 -0
- package/src/components/checkbox/checkbox.tsx +154 -0
- package/src/components/checkbox-group/checkbox-group.test.tsx +86 -0
- package/src/components/checkbox-group/checkbox-group.tsx +21 -0
- package/src/components/chip/chip.test.tsx +242 -0
- package/src/components/chip/chip.tsx +234 -0
- package/src/components/collapsible/collapsible.test.tsx +126 -0
- package/src/components/collapsible/collapsible.tsx +47 -0
- package/src/components/combobox/combobox.test.tsx +410 -0
- package/src/components/combobox/combobox.tsx +598 -0
- package/src/components/context-menu/context-menu.test.tsx +226 -0
- package/src/components/context-menu/context-menu.tsx +345 -0
- package/src/components/copy-button/copy-button.test.tsx +147 -0
- package/src/components/copy-button/copy-button.tsx +141 -0
- package/src/components/countdown/countdown.test.tsx +130 -0
- package/src/components/countdown/countdown.tsx +170 -0
- package/src/components/date-field/date-field.test.tsx +373 -0
- package/src/components/date-field/date-field.tsx +512 -0
- package/src/components/date-picker/date-picker.test.tsx +291 -0
- package/src/components/date-picker/date-picker.tsx +572 -0
- package/src/components/dialog/dialog.test.tsx +173 -0
- package/src/components/dialog/dialog.tsx +190 -0
- package/src/components/drawer/drawer.test.tsx +191 -0
- package/src/components/drawer/drawer.tsx +365 -0
- package/src/components/dropdown-menu/dropdown-menu.test.tsx +227 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +341 -0
- package/src/components/field/field.test.tsx +84 -0
- package/src/components/field/field.tsx +71 -0
- package/src/components/fieldset/fieldset.test.tsx +62 -0
- package/src/components/fieldset/fieldset.tsx +24 -0
- package/src/components/form/form.test.tsx +61 -0
- package/src/components/form/form.tsx +11 -0
- package/src/components/gradient-glow/gradient-glow.test.tsx +110 -0
- package/src/components/gradient-glow/gradient-glow.tsx +132 -0
- package/src/components/input/index.ts +2 -0
- package/src/components/input/input-variants.ts +52 -0
- package/src/components/input/input.test.tsx +118 -0
- package/src/components/input/input.tsx +120 -0
- package/src/components/kbd/kbd.test.tsx +119 -0
- package/src/components/kbd/kbd.tsx +48 -0
- package/src/components/loader/loader.test.tsx +57 -0
- package/src/components/loader/loader.tsx +163 -0
- package/src/components/menubar/menubar.test.tsx +162 -0
- package/src/components/menubar/menubar.tsx +226 -0
- package/src/components/meter/meter.test.tsx +172 -0
- package/src/components/meter/meter.tsx +144 -0
- package/src/components/navigation/index.ts +3 -0
- package/src/components/navigation/navigation-context.ts +24 -0
- package/src/components/navigation/navigation-link-variants.ts +197 -0
- package/src/components/navigation/navigation-link.tsx +90 -0
- package/src/components/navigation/navigation.test.tsx +253 -0
- package/src/components/navigation/navigation.tsx +74 -0
- package/src/components/navigation-menu/navigation-menu.test.tsx +258 -0
- package/src/components/navigation-menu/navigation-menu.tsx +410 -0
- package/src/components/number-field/number-field.test.tsx +224 -0
- package/src/components/number-field/number-field.tsx +310 -0
- package/src/components/otp-field/otp-field.test.tsx +113 -0
- package/src/components/otp-field/otp-field.tsx +105 -0
- package/src/components/pagination/pagination.test.tsx +147 -0
- package/src/components/pagination/pagination.tsx +139 -0
- package/src/components/popover/popover.test.tsx +135 -0
- package/src/components/popover/popover.tsx +134 -0
- package/src/components/preview-card/preview-card.test.tsx +99 -0
- package/src/components/preview-card/preview-card.tsx +103 -0
- package/src/components/progress/progress.test.tsx +109 -0
- package/src/components/progress/progress.tsx +151 -0
- package/src/components/radio/radio.test.tsx +141 -0
- package/src/components/radio/radio.tsx +94 -0
- package/src/components/radio-group/radio-group.test.tsx +80 -0
- package/src/components/radio-group/radio-group.tsx +22 -0
- package/src/components/scroll-area/scroll-area.test.tsx +133 -0
- package/src/components/scroll-area/scroll-area.tsx +101 -0
- package/src/components/select/select.test.tsx +251 -0
- package/src/components/select/select.tsx +446 -0
- package/src/components/separator/separator.test.tsx +46 -0
- package/src/components/separator/separator.tsx +95 -0
- package/src/components/skeleton/skeleton.test.tsx +55 -0
- package/src/components/skeleton/skeleton.tsx +33 -0
- package/src/components/slider/slider.test.tsx +123 -0
- package/src/components/slider/slider.tsx +262 -0
- package/src/components/sparkline/sparkline.test.tsx +249 -0
- package/src/components/sparkline/sparkline.tsx +446 -0
- package/src/components/spinner/spinner.test.tsx +57 -0
- package/src/components/spinner/spinner.tsx +219 -0
- package/src/components/switch/switch.test.tsx +100 -0
- package/src/components/switch/switch.tsx +166 -0
- package/src/components/table/table.test.tsx +175 -0
- package/src/components/table/table.tsx +157 -0
- package/src/components/tabs/tabs.test.tsx +165 -0
- package/src/components/tabs/tabs.tsx +246 -0
- package/src/components/text-animate/text-animate.test.tsx +125 -0
- package/src/components/text-animate/text-animate.tsx +354 -0
- package/src/components/textarea/textarea.test.tsx +188 -0
- package/src/components/textarea/textarea.tsx +144 -0
- package/src/components/thumbnail/thumbnail.test.tsx +217 -0
- package/src/components/thumbnail/thumbnail.tsx +139 -0
- package/src/components/time-field/time-field.test.tsx +376 -0
- package/src/components/time-field/time-field.tsx +625 -0
- package/src/components/toast/toast.test.tsx +277 -0
- package/src/components/toast/toast.tsx +377 -0
- package/src/components/toc/toc.test.tsx +197 -0
- package/src/components/toc/toc.tsx +233 -0
- package/src/components/toggle/toggle.test.tsx +109 -0
- package/src/components/toggle/toggle.tsx +10 -0
- package/src/components/toggle-group/toggle-group.test.tsx +95 -0
- package/src/components/toggle-group/toggle-group.tsx +21 -0
- package/src/components/toolbar/toolbar.test.tsx +78 -0
- package/src/components/toolbar/toolbar.tsx +77 -0
- package/src/components/tooltip/tooltip.test.tsx +100 -0
- package/src/components/tooltip/tooltip.tsx +78 -0
- package/src/floating.test.ts +40 -0
- package/src/floating.ts +103 -0
- package/src/globals.d.ts +34 -0
- package/src/hooks/use-direction.ts +3 -0
- package/src/hooks/use-dismissible.ts +33 -0
- package/src/hooks/use-local-storage.test.tsx +63 -0
- package/src/hooks/use-local-storage.ts +190 -0
- package/src/hooks/use-media-query.test.tsx +65 -0
- package/src/hooks/use-media-query.ts +38 -0
- package/src/hooks/use-reduced-motion.ts +17 -0
- package/src/hooks/use-theme.ts +16 -0
- package/src/index.ts +76 -0
- package/src/modal.test.ts +34 -0
- package/src/modal.ts +80 -0
- package/src/providers/direction-provider.test.tsx +20 -0
- package/src/providers/direction-provider.tsx +26 -0
- package/src/providers/reduced-motion-provider.test.tsx +42 -0
- package/src/providers/reduced-motion-provider.tsx +58 -0
- package/src/providers/theme-provider/index.ts +4 -0
- package/src/providers/theme-provider/theme-provider.test.tsx +97 -0
- package/src/providers/theme-provider/theme-provider.tsx +169 -0
- package/src/providers/theme-provider/theme-script.tsx +108 -0
- package/src/test/setup.ts +27 -0
- package/src/test/vitest-axe.d.ts +7 -0
- package/src/utils.test.tsx +63 -0
- package/src/utils.ts +57 -0
- package/styles.css +523 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useCallback, useRef, useSyncExternalStore } from 'react'
|
|
4
|
+
|
|
5
|
+
export type StorageBackend = 'local' | 'session'
|
|
6
|
+
|
|
7
|
+
export interface UseStorageOptions<T> {
|
|
8
|
+
/** Serialize a value to its stored string form. Defaults to `JSON.stringify`. */
|
|
9
|
+
serializer?: (value: T) => string
|
|
10
|
+
/** Parse the stored string back into a value. Defaults to `JSON.parse`. */
|
|
11
|
+
deserializer?: (raw: string) => T
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type UseStorageReturn<T> = readonly [T, (value: T | ((prev: T) => T)) => void, () => void]
|
|
15
|
+
|
|
16
|
+
// Same-tab fan-out: the `storage` event only fires in *other* tabs, so we keep a
|
|
17
|
+
// per-backend, per-key registry to sync components within the current tab.
|
|
18
|
+
const registries: Record<StorageBackend, Map<string, Set<() => void>>> = {
|
|
19
|
+
local: new Map(),
|
|
20
|
+
session: new Map(),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function subscribers(backend: StorageBackend, key: string) {
|
|
24
|
+
const reg = registries[backend]
|
|
25
|
+
let set = reg.get(key)
|
|
26
|
+
if (!set) {
|
|
27
|
+
set = new Set()
|
|
28
|
+
reg.set(key, set)
|
|
29
|
+
}
|
|
30
|
+
return set
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function notify(backend: StorageBackend, key: string) {
|
|
34
|
+
registries[backend].get(key)?.forEach((cb) => cb())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getStore(backend: StorageBackend): Storage | null {
|
|
38
|
+
try {
|
|
39
|
+
return backend === 'session' ? window.sessionStorage : window.localStorage
|
|
40
|
+
} catch {
|
|
41
|
+
// SSR, privacy mode, or disabled storage.
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// A single `storage` listener shared by every hook instance — installed at the
|
|
47
|
+
// first subscriber, removed at zero — dispatching through the registries above.
|
|
48
|
+
let globalListenerCount = 0
|
|
49
|
+
|
|
50
|
+
function handleGlobalStorage(e: StorageEvent) {
|
|
51
|
+
for (const backend of ['local', 'session'] as StorageBackend[]) {
|
|
52
|
+
const store = getStore(backend)
|
|
53
|
+
if (e.storageArea && store && e.storageArea !== store) continue
|
|
54
|
+
if (e.key === null) {
|
|
55
|
+
// storage.clear() invalidates every key in this backend.
|
|
56
|
+
registries[backend].forEach((set) => set.forEach((cb) => cb()))
|
|
57
|
+
} else {
|
|
58
|
+
registries[backend].get(e.key)?.forEach((cb) => cb())
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function addGlobalStorageListener() {
|
|
64
|
+
if (globalListenerCount === 0 && typeof window !== 'undefined') {
|
|
65
|
+
window.addEventListener('storage', handleGlobalStorage)
|
|
66
|
+
}
|
|
67
|
+
globalListenerCount++
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function removeGlobalStorageListener() {
|
|
71
|
+
globalListenerCount--
|
|
72
|
+
if (globalListenerCount === 0 && typeof window !== 'undefined') {
|
|
73
|
+
window.removeEventListener('storage', handleGlobalStorage)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Cache parsed values keyed by `backend:key`, invalidated by the raw string.
|
|
78
|
+
// Without this, `JSON.parse` in the snapshot would return a fresh object every
|
|
79
|
+
// render and drive `useSyncExternalStore` into an infinite loop.
|
|
80
|
+
const parseCache = new Map<string, { raw: string; value: unknown }>()
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* SSR-safe `localStorage`/`sessionStorage` hook. Reads via `useSyncExternalStore`
|
|
84
|
+
* (server and first client render return `defaultValue`), syncs across tabs via
|
|
85
|
+
* the `storage` event, and syncs other components in the same tab via an internal
|
|
86
|
+
* registry. Returns `[value, setValue, remove]`.
|
|
87
|
+
*
|
|
88
|
+
* Values are JSON-serialized by default; pass a `serializer`/`deserializer` to
|
|
89
|
+
* store raw strings (e.g. a theme name the no-flash script reads directly).
|
|
90
|
+
*
|
|
91
|
+
* Prefer the `useLocalStorage` / `useSessionStorage` wrappers unless the backend
|
|
92
|
+
* is chosen at runtime.
|
|
93
|
+
*/
|
|
94
|
+
export function useStorage<T>(
|
|
95
|
+
backend: StorageBackend,
|
|
96
|
+
key: string,
|
|
97
|
+
defaultValue: T,
|
|
98
|
+
options: UseStorageOptions<T> = {},
|
|
99
|
+
): UseStorageReturn<T> {
|
|
100
|
+
// Stabilize so subscribe/snapshot identities depend only on backend+key.
|
|
101
|
+
const defaultRef = useRef(defaultValue)
|
|
102
|
+
const serializeRef = useRef(options.serializer)
|
|
103
|
+
const deserializeRef = useRef(options.deserializer)
|
|
104
|
+
serializeRef.current = options.serializer
|
|
105
|
+
deserializeRef.current = options.deserializer
|
|
106
|
+
|
|
107
|
+
const read = useCallback((): T => {
|
|
108
|
+
// An empty key means "no persistence" — behave like storage is unavailable
|
|
109
|
+
// instead of touching `getItem('')` and registering a listener.
|
|
110
|
+
if (!key) return defaultRef.current
|
|
111
|
+
const store = getStore(backend)
|
|
112
|
+
let raw: string | null = null
|
|
113
|
+
try {
|
|
114
|
+
raw = store?.getItem(key) ?? null
|
|
115
|
+
} catch {
|
|
116
|
+
raw = null
|
|
117
|
+
}
|
|
118
|
+
if (raw === null) return defaultRef.current
|
|
119
|
+
|
|
120
|
+
const id = backend + ':' + key
|
|
121
|
+
const cached = parseCache.get(id)
|
|
122
|
+
if (cached && cached.raw === raw) return cached.value as T
|
|
123
|
+
|
|
124
|
+
let value: T
|
|
125
|
+
try {
|
|
126
|
+
value = deserializeRef.current ? deserializeRef.current(raw) : (JSON.parse(raw) as T)
|
|
127
|
+
} catch {
|
|
128
|
+
value = defaultRef.current
|
|
129
|
+
}
|
|
130
|
+
parseCache.set(id, { raw, value })
|
|
131
|
+
return value
|
|
132
|
+
}, [backend, key])
|
|
133
|
+
|
|
134
|
+
const subscribe = useCallback(
|
|
135
|
+
(onChange: () => void) => {
|
|
136
|
+
if (!key) return () => {}
|
|
137
|
+
const set = subscribers(backend, key)
|
|
138
|
+
set.add(onChange)
|
|
139
|
+
addGlobalStorageListener()
|
|
140
|
+
return () => {
|
|
141
|
+
set.delete(onChange)
|
|
142
|
+
removeGlobalStorageListener()
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
[backend, key],
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
const getServerSnapshot = useCallback(() => defaultRef.current, [])
|
|
149
|
+
|
|
150
|
+
const value = useSyncExternalStore(subscribe, read, getServerSnapshot)
|
|
151
|
+
|
|
152
|
+
const setValue = useCallback(
|
|
153
|
+
(update: T | ((prev: T) => T)) => {
|
|
154
|
+
if (!key) return
|
|
155
|
+
const next = typeof update === 'function' ? (update as (prev: T) => T)(read()) : update
|
|
156
|
+
try {
|
|
157
|
+
const raw = serializeRef.current ? serializeRef.current(next) : JSON.stringify(next)
|
|
158
|
+
getStore(backend)?.setItem(key, raw)
|
|
159
|
+
} catch {
|
|
160
|
+
// ignore write failures (quota, privacy mode, SSR)
|
|
161
|
+
}
|
|
162
|
+
notify(backend, key)
|
|
163
|
+
},
|
|
164
|
+
[backend, key, read],
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
const remove = useCallback(() => {
|
|
168
|
+
if (!key) return
|
|
169
|
+
try {
|
|
170
|
+
getStore(backend)?.removeItem(key)
|
|
171
|
+
} catch {
|
|
172
|
+
// ignore
|
|
173
|
+
}
|
|
174
|
+
notify(backend, key)
|
|
175
|
+
}, [backend, key])
|
|
176
|
+
|
|
177
|
+
return [value, setValue, remove] as const
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function useLocalStorage<T>(key: string, defaultValue: T, options?: UseStorageOptions<T>): UseStorageReturn<T> {
|
|
181
|
+
return useStorage('local', key, defaultValue, options)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function useSessionStorage<T>(
|
|
185
|
+
key: string,
|
|
186
|
+
defaultValue: T,
|
|
187
|
+
options?: UseStorageOptions<T>,
|
|
188
|
+
): UseStorageReturn<T> {
|
|
189
|
+
return useStorage('session', key, defaultValue, options)
|
|
190
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { act, renderHook } from '@testing-library/react'
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { useMediaQuery } from './use-media-query'
|
|
4
|
+
|
|
5
|
+
type Listener = (e: MediaQueryListEvent) => void
|
|
6
|
+
|
|
7
|
+
function createMatchMediaMock(initial: Record<string, boolean> = {}) {
|
|
8
|
+
const entries = new Map<string, { matches: boolean; listeners: Set<Listener> }>()
|
|
9
|
+
const entry = (query: string) => {
|
|
10
|
+
let e = entries.get(query)
|
|
11
|
+
if (!e) {
|
|
12
|
+
e = { matches: initial[query] ?? false, listeners: new Set() }
|
|
13
|
+
entries.set(query, e)
|
|
14
|
+
}
|
|
15
|
+
return e
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const matchMedia = (query: string): MediaQueryList => {
|
|
19
|
+
const e = entry(query)
|
|
20
|
+
return {
|
|
21
|
+
get matches() {
|
|
22
|
+
return e.matches
|
|
23
|
+
},
|
|
24
|
+
media: query,
|
|
25
|
+
onchange: null,
|
|
26
|
+
addEventListener: (_: string, cb: Listener) => e.listeners.add(cb),
|
|
27
|
+
removeEventListener: (_: string, cb: Listener) => e.listeners.delete(cb),
|
|
28
|
+
addListener: () => {},
|
|
29
|
+
removeListener: () => {},
|
|
30
|
+
dispatchEvent: () => false,
|
|
31
|
+
} as unknown as MediaQueryList
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const set = (query: string, matches: boolean) => {
|
|
35
|
+
const e = entry(query)
|
|
36
|
+
e.matches = matches
|
|
37
|
+
e.listeners.forEach((cb) => cb({ matches } as MediaQueryListEvent))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { matchMedia, set }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('useMediaQuery', () => {
|
|
44
|
+
const original = window.matchMedia
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
window.matchMedia = original
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('returns the current match state for the query', () => {
|
|
50
|
+
const { matchMedia } = createMatchMediaMock({ '(min-width: 768px)': true })
|
|
51
|
+
window.matchMedia = vi.fn(matchMedia)
|
|
52
|
+
const { result } = renderHook(() => useMediaQuery('(min-width: 768px)'))
|
|
53
|
+
expect(result.current).toBe(true)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('re-renders when the query match changes', () => {
|
|
57
|
+
const { matchMedia, set } = createMatchMediaMock({ '(min-width: 768px)': false })
|
|
58
|
+
window.matchMedia = vi.fn(matchMedia)
|
|
59
|
+
const { result } = renderHook(() => useMediaQuery('(min-width: 768px)'))
|
|
60
|
+
expect(result.current).toBe(false)
|
|
61
|
+
|
|
62
|
+
act(() => set('(min-width: 768px)', true))
|
|
63
|
+
expect(result.current).toBe(true)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useCallback, useSyncExternalStore } from 'react'
|
|
4
|
+
|
|
5
|
+
export interface UseMediaQueryOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Value returned on the server and during the first client render before
|
|
8
|
+
* hydration, when `window.matchMedia` is unavailable. Defaults to `false`.
|
|
9
|
+
*/
|
|
10
|
+
defaultValue?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* SSR-safe `matchMedia` hook. Returns whether `query` currently matches and
|
|
15
|
+
* re-renders when it changes. Works in any React environment (Vite, CRA,
|
|
16
|
+
* Next.js, Remix, Astro): on the server and the first client render it returns
|
|
17
|
+
* `defaultValue`, then the real value resolves on hydration via
|
|
18
|
+
* `useSyncExternalStore`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const isDesktop = useMediaQuery('(min-width: 768px)')
|
|
22
|
+
* return isDesktop ? <Dialog … /> : <Drawer … />
|
|
23
|
+
*/
|
|
24
|
+
export function useMediaQuery(query: string, { defaultValue = false }: UseMediaQueryOptions = {}): boolean {
|
|
25
|
+
const subscribe = useCallback(
|
|
26
|
+
(onChange: () => void) => {
|
|
27
|
+
const mq = window.matchMedia(query)
|
|
28
|
+
mq.addEventListener('change', onChange)
|
|
29
|
+
return () => mq.removeEventListener('change', onChange)
|
|
30
|
+
},
|
|
31
|
+
[query],
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
const getSnapshot = useCallback(() => window.matchMedia(query).matches, [query])
|
|
35
|
+
const getServerSnapshot = useCallback(() => defaultValue, [defaultValue])
|
|
36
|
+
|
|
37
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)
|
|
38
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useMediaQuery } from './use-media-query'
|
|
4
|
+
import { useReducedMotionContext } from '../providers/reduced-motion-provider'
|
|
5
|
+
|
|
6
|
+
const QUERY = '(prefers-reduced-motion: reduce)'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns `true` when animations should be skipped — either because the OS
|
|
10
|
+
* exposes `prefers-reduced-motion: reduce` or because a parent
|
|
11
|
+
* `<ReducedMotionProvider disableAnimations>` opted out globally.
|
|
12
|
+
*/
|
|
13
|
+
export function useReducedMotion(): boolean {
|
|
14
|
+
const osPrefersReduced = useMediaQuery(QUERY)
|
|
15
|
+
const { disableAnimations } = useReducedMotionContext()
|
|
16
|
+
return disableAnimations || osPrefersReduced
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useThemeContext, type ThemeContextValue } from '../providers/theme-provider/theme-provider'
|
|
4
|
+
|
|
5
|
+
export type UseThemeReturn = ThemeContextValue
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Read and control the active theme. Returns the stored `theme`, the
|
|
9
|
+
* `resolvedTheme` (`'system'` resolved to `'light'`/`'dark'`), `systemTheme`,
|
|
10
|
+
* the available `themes`, any `forcedTheme`, a `setTheme` setter, and
|
|
11
|
+
* `mounted` — guard theme-dependent UI (e.g. a sun/moon icon) with `mounted`
|
|
12
|
+
* to avoid hydration mismatches. Returns inert values with no `<ThemeProvider>`.
|
|
13
|
+
*/
|
|
14
|
+
export function useTheme(): UseThemeReturn {
|
|
15
|
+
return useThemeContext()
|
|
16
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Auto-generated by scripts/sync-exports.mjs from src/{components,hooks,providers}/*.
|
|
2
|
+
// Do not edit by hand — your changes will be overwritten on the next build.
|
|
3
|
+
|
|
4
|
+
export * from './components/accordion/accordion'
|
|
5
|
+
export * from './components/alert/alert'
|
|
6
|
+
export * from './components/alert-dialog/alert-dialog'
|
|
7
|
+
export * from './components/autocomplete/autocomplete'
|
|
8
|
+
export * from './components/avatar/avatar'
|
|
9
|
+
export * from './components/background-pattern/index'
|
|
10
|
+
export * from './components/badge/badge'
|
|
11
|
+
export * from './components/breadcrumb/breadcrumb'
|
|
12
|
+
export * from './components/button/index'
|
|
13
|
+
export * from './components/button-group/button-group'
|
|
14
|
+
export * from './components/calendar/calendar'
|
|
15
|
+
export * from './components/carousel/carousel'
|
|
16
|
+
export * from './components/checkbox/checkbox'
|
|
17
|
+
export * from './components/checkbox-group/checkbox-group'
|
|
18
|
+
export * from './components/chip/chip'
|
|
19
|
+
export * from './components/collapsible/collapsible'
|
|
20
|
+
export * from './components/combobox/combobox'
|
|
21
|
+
export * from './components/context-menu/context-menu'
|
|
22
|
+
export * from './components/copy-button/copy-button'
|
|
23
|
+
export * from './components/countdown/countdown'
|
|
24
|
+
export * from './components/date-field/date-field'
|
|
25
|
+
export * from './components/date-picker/date-picker'
|
|
26
|
+
export * from './components/dialog/dialog'
|
|
27
|
+
export * from './components/drawer/drawer'
|
|
28
|
+
export * from './components/dropdown-menu/dropdown-menu'
|
|
29
|
+
export * from './components/field/field'
|
|
30
|
+
export * from './components/fieldset/fieldset'
|
|
31
|
+
export * from './components/form/form'
|
|
32
|
+
export * from './components/gradient-glow/gradient-glow'
|
|
33
|
+
export * from './components/input/index'
|
|
34
|
+
export * from './components/kbd/kbd'
|
|
35
|
+
export * from './components/loader/loader'
|
|
36
|
+
export * from './components/menubar/menubar'
|
|
37
|
+
export * from './components/meter/meter'
|
|
38
|
+
export * from './components/navigation/index'
|
|
39
|
+
export * from './components/navigation-menu/navigation-menu'
|
|
40
|
+
export * from './components/number-field/number-field'
|
|
41
|
+
export * from './components/otp-field/otp-field'
|
|
42
|
+
export * from './components/pagination/pagination'
|
|
43
|
+
export * from './components/popover/popover'
|
|
44
|
+
export * from './components/preview-card/preview-card'
|
|
45
|
+
export * from './components/progress/progress'
|
|
46
|
+
export * from './components/radio/radio'
|
|
47
|
+
export * from './components/radio-group/radio-group'
|
|
48
|
+
export * from './components/scroll-area/scroll-area'
|
|
49
|
+
export * from './components/select/select'
|
|
50
|
+
export * from './components/separator/separator'
|
|
51
|
+
export * from './components/skeleton/skeleton'
|
|
52
|
+
export * from './components/slider/slider'
|
|
53
|
+
export * from './components/sparkline/sparkline'
|
|
54
|
+
export * from './components/spinner/spinner'
|
|
55
|
+
export * from './components/switch/switch'
|
|
56
|
+
export * from './components/table/table'
|
|
57
|
+
export * from './components/tabs/tabs'
|
|
58
|
+
export * from './components/text-animate/text-animate'
|
|
59
|
+
export * from './components/textarea/textarea'
|
|
60
|
+
export * from './components/thumbnail/thumbnail'
|
|
61
|
+
export * from './components/time-field/time-field'
|
|
62
|
+
export * from './components/toast/toast'
|
|
63
|
+
export * from './components/toc/toc'
|
|
64
|
+
export * from './components/toggle/toggle'
|
|
65
|
+
export * from './components/toggle-group/toggle-group'
|
|
66
|
+
export * from './components/toolbar/toolbar'
|
|
67
|
+
export * from './components/tooltip/tooltip'
|
|
68
|
+
export * from './hooks/use-direction'
|
|
69
|
+
export * from './hooks/use-dismissible'
|
|
70
|
+
export * from './hooks/use-local-storage'
|
|
71
|
+
export * from './hooks/use-media-query'
|
|
72
|
+
export * from './hooks/use-reduced-motion'
|
|
73
|
+
export * from './hooks/use-theme'
|
|
74
|
+
export * from './providers/direction-provider'
|
|
75
|
+
export * from './providers/reduced-motion-provider'
|
|
76
|
+
export * from './providers/theme-provider/index'
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { splitModalProps } from './modal'
|
|
3
|
+
|
|
4
|
+
describe('splitModalProps', () => {
|
|
5
|
+
it('routes portal props to portal and everything else to popup', () => {
|
|
6
|
+
const { portal, popup } = splitModalProps({
|
|
7
|
+
container: 'node',
|
|
8
|
+
keepMounted: true,
|
|
9
|
+
id: 'dialog-1',
|
|
10
|
+
role: 'dialog',
|
|
11
|
+
initialFocus: 'ref',
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
expect(portal).toEqual({ container: 'node', keepMounted: true })
|
|
15
|
+
expect(popup).toEqual({ id: 'dialog-1', role: 'dialog', initialFocus: 'ref' })
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('merges portalProps, with flat portal props winning over it', () => {
|
|
19
|
+
const { portal } = splitModalProps({
|
|
20
|
+
container: 'flat-node',
|
|
21
|
+
portalProps: { container: 'object-node', keepMounted: false },
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
expect(portal).toEqual({ container: 'flat-node', keepMounted: false })
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('drops undefined flat portal props', () => {
|
|
28
|
+
const { portal, popup } = splitModalProps({ container: undefined, keepMounted: true, id: 'x' })
|
|
29
|
+
|
|
30
|
+
expect('container' in portal).toBe(false)
|
|
31
|
+
expect(portal).toEqual({ keepMounted: true })
|
|
32
|
+
expect(popup).toEqual({ id: 'x' })
|
|
33
|
+
})
|
|
34
|
+
})
|
package/src/modal.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Shared plumbing for modal/overlay *Content components — the ones that wrap a
|
|
2
|
+
// Base UI Portal → Backdrop → Viewport → Popup structure (Dialog, AlertDialog,
|
|
3
|
+
// Drawer). Sibling to src/floating.ts (which handles the Positioner-based trio).
|
|
4
|
+
//
|
|
5
|
+
// As with floating, consumers don't get direct access to the inner Portal,
|
|
6
|
+
// Backdrop, or Viewport elements, so *Content must map them itself:
|
|
7
|
+
//
|
|
8
|
+
// 1. The two Portal props (`container`, `keepMounted`) are promoted to flat
|
|
9
|
+
// props on *Content.
|
|
10
|
+
// 2. `portalProps` / `backdropProps` / `viewportProps` escape hatches forward
|
|
11
|
+
// the rest (e.g. `className`, `style`, `render`) without each component
|
|
12
|
+
// re-enumerating it.
|
|
13
|
+
//
|
|
14
|
+
// The Popup is what *Content represents, so its `className`/`style`/`render`
|
|
15
|
+
// stay bound to it (via the regular spread) — reach the other elements through
|
|
16
|
+
// the escape hatches.
|
|
17
|
+
|
|
18
|
+
/** Portal props promoted to flat props on every modal *Content. */
|
|
19
|
+
export const MODAL_PORTAL_KEYS = ['container', 'keepMounted'] as const
|
|
20
|
+
|
|
21
|
+
type ModalPortalKey = (typeof MODAL_PORTAL_KEYS)[number]
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Flat Portal props + typed escape hatches for the Backdrop/Viewport/Portal,
|
|
25
|
+
* derived from a component's own Base UI types so each *Content stays in
|
|
26
|
+
* lockstep with Base UI. Intersect with the Popup props to build a *Content
|
|
27
|
+
* prop type:
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* type DialogContentProps = ModalContentProps<
|
|
31
|
+
* React.ComponentProps<typeof BaseDialog.Popup>,
|
|
32
|
+
* React.ComponentProps<typeof BaseDialog.Portal>,
|
|
33
|
+
* React.ComponentProps<typeof BaseDialog.Backdrop>,
|
|
34
|
+
* React.ComponentProps<typeof BaseDialog.Viewport>
|
|
35
|
+
* > & { closeButton?: boolean }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export type ModalContentProps<Popup, Portal, Backdrop, Viewport> = Popup &
|
|
39
|
+
Pick<Portal, Extract<keyof Portal, ModalPortalKey>> & {
|
|
40
|
+
/** Escape hatch: extra props forwarded to the Base UI Portal. */
|
|
41
|
+
portalProps?: Omit<Portal, ModalPortalKey | 'children'>
|
|
42
|
+
/** Escape hatch: props forwarded to the Base UI Backdrop (e.g. `className`, `style`, `render`). */
|
|
43
|
+
backdropProps?: Omit<Backdrop, 'children'>
|
|
44
|
+
/** Escape hatch: props forwarded to the Base UI Viewport (e.g. `className`, `style`, `render`). */
|
|
45
|
+
viewportProps?: Omit<Viewport, 'children'>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface SplitModalProps {
|
|
49
|
+
portal: Record<string, unknown>
|
|
50
|
+
popup: Record<string, unknown>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Partition a modal *Content component's spread props into the Portal and Popup
|
|
55
|
+
* targets. Flat portal props win over the same keys inside `portalProps`.
|
|
56
|
+
*
|
|
57
|
+
* Destructure `className`/`children`, the `backdropProps`/`viewportProps` escape
|
|
58
|
+
* hatches, and any component-specific props (`backdrop`, `closeButton`, …) out of
|
|
59
|
+
* the props object before calling this — everything left that isn't a known
|
|
60
|
+
* Portal prop is treated as a Popup prop.
|
|
61
|
+
*/
|
|
62
|
+
export function splitModalProps(props: Record<string, unknown>): SplitModalProps {
|
|
63
|
+
const { portalProps, ...rest } = props as {
|
|
64
|
+
portalProps?: Record<string, unknown>
|
|
65
|
+
} & Record<string, unknown>
|
|
66
|
+
|
|
67
|
+
const portal: Record<string, unknown> = { ...portalProps }
|
|
68
|
+
const popup: Record<string, unknown> = {}
|
|
69
|
+
|
|
70
|
+
for (const key of Object.keys(rest)) {
|
|
71
|
+
const value = rest[key]
|
|
72
|
+
if ((MODAL_PORTAL_KEYS as readonly string[]).includes(key)) {
|
|
73
|
+
if (value !== undefined) portal[key] = value
|
|
74
|
+
} else {
|
|
75
|
+
popup[key] = value
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return { portal, popup }
|
|
80
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react'
|
|
2
|
+
import { type ReactNode } from 'react'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import { DirectionProvider } from './direction-provider'
|
|
5
|
+
import { useDirection } from '../hooks/use-direction'
|
|
6
|
+
|
|
7
|
+
describe('DirectionProvider', () => {
|
|
8
|
+
it('defaults to ltr with no provider', () => {
|
|
9
|
+
const { result } = renderHook(() => useDirection())
|
|
10
|
+
expect(result.current).toBe('ltr')
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('provides the configured direction to descendants', () => {
|
|
14
|
+
const wrapper = ({ children }: { children: ReactNode }) => (
|
|
15
|
+
<DirectionProvider dir="rtl">{children}</DirectionProvider>
|
|
16
|
+
)
|
|
17
|
+
const { result } = renderHook(() => useDirection(), { wrapper })
|
|
18
|
+
expect(result.current).toBe('rtl')
|
|
19
|
+
})
|
|
20
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { DirectionProvider as BaseDirectionProvider } from '@base-ui/react/direction-provider'
|
|
3
|
+
|
|
4
|
+
export type Direction = 'ltr' | 'rtl'
|
|
5
|
+
|
|
6
|
+
export interface DirectionProviderProps {
|
|
7
|
+
children: ReactNode
|
|
8
|
+
/**
|
|
9
|
+
* Reading direction for components with bidirectional layout (Switch, Slider,
|
|
10
|
+
* Carousel, etc.). Matches the HTML `dir` attribute; descendants read it via
|
|
11
|
+
* our `useDirection()` hook. Defaults to `ltr`.
|
|
12
|
+
*/
|
|
13
|
+
dir?: Direction
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Sets the reading direction for descendant components. Thin wrapper over Base
|
|
18
|
+
* UI's direction provider so consumers depend on `@appica/ui-react` rather than
|
|
19
|
+
* the underlying primitive.
|
|
20
|
+
*
|
|
21
|
+
* Optional — components default to `ltr` with no provider, so reach for this
|
|
22
|
+
* only when supporting RTL.
|
|
23
|
+
*/
|
|
24
|
+
export function DirectionProvider({ children, dir = 'ltr' }: DirectionProviderProps) {
|
|
25
|
+
return <BaseDirectionProvider direction={dir}>{children}</BaseDirectionProvider>
|
|
26
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { render, renderHook } from '@testing-library/react'
|
|
2
|
+
import { type ReactNode } from 'react'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import { ReducedMotionProvider } from './reduced-motion-provider'
|
|
5
|
+
import { useReducedMotion } from '../hooks/use-reduced-motion'
|
|
6
|
+
|
|
7
|
+
const ATTR = 'data-disable-animations'
|
|
8
|
+
|
|
9
|
+
describe('ReducedMotionProvider', () => {
|
|
10
|
+
it('useReducedMotion is false with no provider (test env reports motion allowed)', () => {
|
|
11
|
+
const { result } = renderHook(() => useReducedMotion())
|
|
12
|
+
expect(result.current).toBe(false)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('forces reduced motion for descendants when disableAnimations is set', () => {
|
|
16
|
+
const wrapper = ({ children }: { children: ReactNode }) => (
|
|
17
|
+
<ReducedMotionProvider disableAnimations>{children}</ReducedMotionProvider>
|
|
18
|
+
)
|
|
19
|
+
const { result } = renderHook(() => useReducedMotion(), { wrapper })
|
|
20
|
+
expect(result.current).toBe(true)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('writes the data-disable-animations attribute on <html> and removes it on unmount', () => {
|
|
24
|
+
const { unmount } = render(
|
|
25
|
+
<ReducedMotionProvider disableAnimations>
|
|
26
|
+
<span />
|
|
27
|
+
</ReducedMotionProvider>,
|
|
28
|
+
)
|
|
29
|
+
expect(document.documentElement.hasAttribute(ATTR)).toBe(true)
|
|
30
|
+
unmount()
|
|
31
|
+
expect(document.documentElement.hasAttribute(ATTR)).toBe(false)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('does not set the attribute when disableAnimations is false', () => {
|
|
35
|
+
render(
|
|
36
|
+
<ReducedMotionProvider>
|
|
37
|
+
<span />
|
|
38
|
+
</ReducedMotionProvider>,
|
|
39
|
+
)
|
|
40
|
+
expect(document.documentElement.hasAttribute(ATTR)).toBe(false)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { createContext, use, useEffect, useMemo, type ReactNode } from 'react'
|
|
4
|
+
|
|
5
|
+
export interface ReducedMotionContextValue {
|
|
6
|
+
disableAnimations: boolean
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const DEFAULT_CONTEXT: ReducedMotionContextValue = {
|
|
10
|
+
disableAnimations: false,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const ReducedMotionContext = createContext<ReducedMotionContextValue>(DEFAULT_CONTEXT)
|
|
14
|
+
|
|
15
|
+
export interface ReducedMotionProviderProps {
|
|
16
|
+
children: ReactNode
|
|
17
|
+
/**
|
|
18
|
+
* Force-disable all component animations regardless of OS `prefers-reduced-motion`.
|
|
19
|
+
* Components also respect the OS preference automatically — this is the global override.
|
|
20
|
+
*
|
|
21
|
+
* The attribute is set on `<html>` (not on a wrapper div) so it reaches Base UI's portaled
|
|
22
|
+
* popups, which render under `document.body` and therefore escape the React subtree. The
|
|
23
|
+
* `motion-reduce:` / `motion-safe:` custom variants in styles.css already target
|
|
24
|
+
* `[data-disable-animations] *`.
|
|
25
|
+
*/
|
|
26
|
+
disableAnimations?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const ATTR = 'data-disable-animations'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Opts a subtree out of animation. The JS channel (`useReducedMotion()`) is
|
|
33
|
+
* scoped to this provider's React subtree; the CSS channel (the
|
|
34
|
+
* `motion-reduce:` variant) is driven by a `data-disable-animations` attribute
|
|
35
|
+
* written to `<html>`, so it applies page-wide while mounted and covers
|
|
36
|
+
* portaled popups.
|
|
37
|
+
*
|
|
38
|
+
* Optional — components already respect the OS `prefers-reduced-motion`
|
|
39
|
+
* preference with no provider. Reach for this only to force-disable animations.
|
|
40
|
+
*/
|
|
41
|
+
export function ReducedMotionProvider({ children, disableAnimations = false }: ReducedMotionProviderProps) {
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!disableAnimations) return
|
|
44
|
+
const html = document.documentElement
|
|
45
|
+
html.setAttribute(ATTR, '')
|
|
46
|
+
return () => {
|
|
47
|
+
html.removeAttribute(ATTR)
|
|
48
|
+
}
|
|
49
|
+
}, [disableAnimations])
|
|
50
|
+
|
|
51
|
+
const value = useMemo<ReducedMotionContextValue>(() => ({ disableAnimations }), [disableAnimations])
|
|
52
|
+
|
|
53
|
+
return <ReducedMotionContext value={value}>{children}</ReducedMotionContext>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function useReducedMotionContext(): ReducedMotionContextValue {
|
|
57
|
+
return use(ReducedMotionContext)
|
|
58
|
+
}
|