@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,219 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { animate, LazyMotion, domAnimation, m, useMotionValue, useTransform } from 'motion/react'
|
|
5
|
+
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
6
|
+
import { cn } from '../../utils'
|
|
7
|
+
|
|
8
|
+
type SpinnerVariant = 'circular' | 'dots' | 'sparkle'
|
|
9
|
+
|
|
10
|
+
interface SpinnerProps extends Omit<React.ComponentProps<'span'>, 'children'> {
|
|
11
|
+
variant?: SpinnerVariant
|
|
12
|
+
currentColor?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type VariantColors = { indicator: string; track: string }
|
|
16
|
+
type VariantInnerProps = { colors: VariantColors; reduced: boolean }
|
|
17
|
+
|
|
18
|
+
const SPINNER_SIZE = 'text-[2.5rem]'
|
|
19
|
+
|
|
20
|
+
const PRIMARY_COLORS: VariantColors = { indicator: 'text-primary', track: 'text-primary-soft' }
|
|
21
|
+
const CURRENT_COLORS: VariantColors = { indicator: 'text-current', track: 'text-current/20' }
|
|
22
|
+
|
|
23
|
+
function Circular({ colors, reduced }: VariantInnerProps) {
|
|
24
|
+
return (
|
|
25
|
+
<svg
|
|
26
|
+
width="1em"
|
|
27
|
+
height="1em"
|
|
28
|
+
viewBox="0 0 40 40"
|
|
29
|
+
fill="none"
|
|
30
|
+
stroke="currentColor"
|
|
31
|
+
strokeWidth="4"
|
|
32
|
+
strokeLinecap="round"
|
|
33
|
+
aria-hidden="true"
|
|
34
|
+
className={cn('size-[1em] stroke-4!', colors.indicator)}
|
|
35
|
+
>
|
|
36
|
+
<circle cx="20" cy="20" r="16" className={colors.track} />
|
|
37
|
+
{reduced ? (
|
|
38
|
+
<circle cx="20" cy="20" r="16" pathLength={1} strokeDasharray="0.25 0.75" />
|
|
39
|
+
) : (
|
|
40
|
+
<m.circle
|
|
41
|
+
cx="20"
|
|
42
|
+
cy="20"
|
|
43
|
+
r="16"
|
|
44
|
+
pathLength={1}
|
|
45
|
+
strokeDasharray="0.25 0.75"
|
|
46
|
+
initial={{ strokeDashoffset: 0 }}
|
|
47
|
+
animate={{ strokeDashoffset: -1 }}
|
|
48
|
+
transition={{ duration: 0.9, repeat: Infinity, ease: 'linear' }}
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
51
|
+
</svg>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const DOT_COUNT = 12
|
|
56
|
+
const DOT_CYCLE = 1.2
|
|
57
|
+
|
|
58
|
+
function Dots({ colors, reduced }: VariantInnerProps) {
|
|
59
|
+
return (
|
|
60
|
+
<svg
|
|
61
|
+
width="1em"
|
|
62
|
+
height="1em"
|
|
63
|
+
viewBox="0 0 40 40"
|
|
64
|
+
fill="currentColor"
|
|
65
|
+
aria-hidden="true"
|
|
66
|
+
className={cn('size-[1em]', colors.indicator)}
|
|
67
|
+
>
|
|
68
|
+
{Array.from({ length: DOT_COUNT }, (_, i) => {
|
|
69
|
+
const angle = i * (360 / DOT_COUNT)
|
|
70
|
+
const sharedProps = {
|
|
71
|
+
x: 18,
|
|
72
|
+
y: 2,
|
|
73
|
+
width: 4,
|
|
74
|
+
height: 6,
|
|
75
|
+
rx: 2,
|
|
76
|
+
transform: `rotate(${angle} 20 20)`,
|
|
77
|
+
} as const
|
|
78
|
+
|
|
79
|
+
return reduced ? (
|
|
80
|
+
<rect key={i} {...sharedProps} opacity={0.25} />
|
|
81
|
+
) : (
|
|
82
|
+
<m.rect
|
|
83
|
+
key={i}
|
|
84
|
+
{...sharedProps}
|
|
85
|
+
initial={{ opacity: 0 }}
|
|
86
|
+
animate={{ opacity: [0, 1, 0.5, 0] }}
|
|
87
|
+
transition={{
|
|
88
|
+
duration: DOT_CYCLE,
|
|
89
|
+
repeat: Infinity,
|
|
90
|
+
ease: 'linear',
|
|
91
|
+
delay: (i / DOT_COUNT) * DOT_CYCLE - DOT_CYCLE,
|
|
92
|
+
times: [0, 0.1, 0.5, 1],
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
)
|
|
96
|
+
})}
|
|
97
|
+
</svg>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const SPARKLE_MORPH_PATH =
|
|
102
|
+
'M12.846 3.581C12.711 3.231 12.375 3 12 3C11.625 3 11.278 3.263 11.154 3.581C10.604 5.011 10.054 6.442 9.504 7.872C8.752 8.16 8.159 8.752 7.871 9.504C6.441 10.054 5.011 10.604 3.581 11.154C3.41 11.22 3.263 11.336 3.159 11.487C3.055 11.638 3 11.817 3 12C3 12.183 3.056 12.362 3.159 12.513C3.262 12.664 3.41 12.78 3.581 12.846C5.011 13.396 6.442 13.946 7.872 14.496C8.16 15.248 8.752 15.841 9.504 16.129C10.054 17.559 10.604 18.989 11.154 20.419C11.22 20.59 11.336 20.737 11.487 20.841C11.638 20.945 11.817 21 12 21C12.183 21 12.362 20.945 12.513 20.841C12.664 20.737 12.78 20.59 12.846 20.419C13.396 18.989 13.946 17.559 14.496 16.129C15.248 15.841 15.841 15.248 16.129 14.496C17.559 13.946 18.989 13.396 20.419 12.846C20.59 12.78 20.737 12.664 20.841 12.513C20.945 12.362 21 12.183 21 12C21 11.817 20.945 11.638 20.841 11.487C20.737 11.336 20.59 11.22 20.419 11.154C18.989 10.604 17.559 10.054 16.129 9.504C15.841 8.752 15.248 8.16 14.496 7.871C13.946 6.441 13.396 5.011 12.846 3.581Z'
|
|
103
|
+
|
|
104
|
+
const SQUARE_MORPH_PATH =
|
|
105
|
+
'M12.704 5C12.469 5 12.235 5 12 5C11.765 5 11.531 5 11.296 5C10.161 5.053 9.025 5.106 7.889 5.159C6.979 6.069 6.069 6.979 5.159 7.889C5.106 9.025 5.053 10.161 5 11.296C5 11.395 5 11.494 5 11.593C5 11.729 5 11.864 5 12C5 12.136 5 12.271 5 12.407C5 12.506 5 12.605 5 12.704C5.053 13.839 5.106 14.975 5.159 16.111C6.069 17.021 6.979 17.931 7.889 18.841C9.025 18.894 10.161 18.947 11.296 19C11.395 19 11.494 19 11.593 19C11.729 19 11.864 19 12 19C12.136 19 12.271 19 12.407 19C12.506 19 12.605 19 12.704 19C13.839 18.947 14.975 18.894 16.111 18.841C17.021 17.931 17.931 17.021 18.841 16.111C18.894 14.975 18.947 13.839 19 12.704C19 12.605 19 12.506 19 12.407C19 12.271 19 12.136 19 12C19 11.864 19 11.729 19 11.593C19 11.494 19 11.395 19 11.296C18.947 10.161 18.894 9.025 18.841 7.889C17.931 6.979 17.021 6.069 16.111 5.159C14.975 5.106 13.839 5.053 12.704 5Z'
|
|
106
|
+
|
|
107
|
+
function parsePathNumbers(d: string): number[] {
|
|
108
|
+
return d.match(/-?\d+(?:\.\d+)?/g)?.map(Number) ?? []
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const SPARKLE_NUMBERS = parsePathNumbers(SPARKLE_MORPH_PATH)
|
|
112
|
+
const SQUARE_NUMBERS = parsePathNumbers(SQUARE_MORPH_PATH)
|
|
113
|
+
const MORPH_CUBIC_COUNT = (SPARKLE_NUMBERS.length - 2) / 6
|
|
114
|
+
|
|
115
|
+
function buildSparklePath(nums: number[]): string {
|
|
116
|
+
let d = `M${nums[0]} ${nums[1]}`
|
|
117
|
+
for (let i = 0; i < MORPH_CUBIC_COUNT; i++) {
|
|
118
|
+
const o = 2 + i * 6
|
|
119
|
+
d += `C${nums[o]} ${nums[o + 1]} ${nums[o + 2]} ${nums[o + 3]} ${nums[o + 4]} ${nums[o + 5]}`
|
|
120
|
+
}
|
|
121
|
+
return d + 'Z'
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function lerp(a: number, b: number, t: number): number {
|
|
125
|
+
return a + (b - a) * t
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function easeInOut(t: number): number {
|
|
129
|
+
return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const SPARKLE_CYCLE = 2.5
|
|
133
|
+
const SPARKLE_MORPH_END = 0.4
|
|
134
|
+
|
|
135
|
+
function Sparkle({ colors, reduced }: VariantInnerProps) {
|
|
136
|
+
const progress = useMotionValue(0)
|
|
137
|
+
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
if (reduced) return
|
|
140
|
+
const controls = animate(progress, 1, {
|
|
141
|
+
duration: SPARKLE_CYCLE,
|
|
142
|
+
repeat: Infinity,
|
|
143
|
+
ease: 'linear',
|
|
144
|
+
})
|
|
145
|
+
return () => controls.stop()
|
|
146
|
+
}, [reduced, progress])
|
|
147
|
+
|
|
148
|
+
const d = useTransform(progress, (t) => {
|
|
149
|
+
if (t < SPARKLE_MORPH_END / 2) {
|
|
150
|
+
const sub = easeInOut(t / (SPARKLE_MORPH_END / 2))
|
|
151
|
+
return buildSparklePath(SPARKLE_NUMBERS.map((a, i) => lerp(a, SQUARE_NUMBERS[i]!, sub)))
|
|
152
|
+
}
|
|
153
|
+
if (t < SPARKLE_MORPH_END) {
|
|
154
|
+
const sub = easeInOut((t - SPARKLE_MORPH_END / 2) / (SPARKLE_MORPH_END / 2))
|
|
155
|
+
return buildSparklePath(SQUARE_NUMBERS.map((a, i) => lerp(a, SPARKLE_NUMBERS[i]!, sub)))
|
|
156
|
+
}
|
|
157
|
+
return SPARKLE_MORPH_PATH
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const rotate = useTransform(progress, (t) => (t < SPARKLE_MORPH_END ? easeInOut(t / SPARKLE_MORPH_END) * 360 : 360))
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<svg
|
|
164
|
+
width="1em"
|
|
165
|
+
height="1em"
|
|
166
|
+
viewBox="0 0 24 24"
|
|
167
|
+
fill="none"
|
|
168
|
+
stroke="currentColor"
|
|
169
|
+
strokeWidth="2"
|
|
170
|
+
strokeLinejoin="round"
|
|
171
|
+
strokeLinecap="round"
|
|
172
|
+
aria-hidden="true"
|
|
173
|
+
className={cn('size-[1em]', colors.indicator)}
|
|
174
|
+
>
|
|
175
|
+
{reduced ? <path d={SPARKLE_MORPH_PATH} /> : <m.path d={d} style={{ transformOrigin: '12px 12px', rotate }} />}
|
|
176
|
+
</svg>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const VARIANT_COMPONENTS: Record<SpinnerVariant, React.ComponentType<VariantInnerProps>> = {
|
|
181
|
+
circular: Circular,
|
|
182
|
+
dots: Dots,
|
|
183
|
+
sparkle: Sparkle,
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function Spinner({
|
|
187
|
+
variant = 'circular',
|
|
188
|
+
currentColor = false,
|
|
189
|
+
'aria-label': ariaLabel = 'Loading',
|
|
190
|
+
className,
|
|
191
|
+
...props
|
|
192
|
+
}: SpinnerProps) {
|
|
193
|
+
const reduced = useReducedMotion()
|
|
194
|
+
const colors = currentColor ? CURRENT_COLORS : PRIMARY_COLORS
|
|
195
|
+
const Variant = VARIANT_COMPONENTS[variant]
|
|
196
|
+
|
|
197
|
+
const inner = <Variant colors={colors} reduced={reduced} />
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<span
|
|
201
|
+
data-slot="spinner"
|
|
202
|
+
role="status"
|
|
203
|
+
aria-label={ariaLabel}
|
|
204
|
+
className={cn('inline-flex shrink-0 items-center justify-center align-middle', SPINNER_SIZE, className)}
|
|
205
|
+
{...props}
|
|
206
|
+
>
|
|
207
|
+
{reduced ? (
|
|
208
|
+
inner
|
|
209
|
+
) : (
|
|
210
|
+
<LazyMotion features={domAnimation} strict>
|
|
211
|
+
{inner}
|
|
212
|
+
</LazyMotion>
|
|
213
|
+
)}
|
|
214
|
+
</span>
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { Spinner }
|
|
219
|
+
export type { SpinnerProps }
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import userEvent from '@testing-library/user-event'
|
|
3
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
4
|
+
import { axe } from 'vitest-axe'
|
|
5
|
+
import { Field as BaseField } from '@base-ui/react/field'
|
|
6
|
+
import { Switch } from './switch'
|
|
7
|
+
|
|
8
|
+
describe('Switch', () => {
|
|
9
|
+
it('renders with switch role', () => {
|
|
10
|
+
render(<Switch aria-label="Notifications" />)
|
|
11
|
+
expect(screen.getByRole('switch', { name: 'Notifications' })).toBeInTheDocument()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('reflects defaultChecked', () => {
|
|
15
|
+
render(<Switch defaultChecked aria-label="On" />)
|
|
16
|
+
expect(screen.getByRole('switch')).toBeChecked()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('bridges aria-invalid to data-invalid for error styling', () => {
|
|
20
|
+
render(<Switch aria-invalid aria-label="Invalid" />)
|
|
21
|
+
const sw = screen.getByRole('switch')
|
|
22
|
+
expect(sw).toHaveAttribute('aria-invalid', 'true')
|
|
23
|
+
expect(sw).toHaveAttribute('data-invalid')
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('does not set data-invalid when valid', () => {
|
|
27
|
+
render(<Switch aria-label="Valid" />)
|
|
28
|
+
expect(screen.getByRole('switch')).not.toHaveAttribute('data-invalid')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('keeps Field-context data-invalid when no standalone aria-invalid is set', () => {
|
|
32
|
+
render(
|
|
33
|
+
<BaseField.Root invalid>
|
|
34
|
+
<Switch aria-label="Field switch" />
|
|
35
|
+
</BaseField.Root>,
|
|
36
|
+
)
|
|
37
|
+
expect(screen.getByRole('switch')).toHaveAttribute('data-invalid')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('toggles when clicked', async () => {
|
|
41
|
+
const user = userEvent.setup()
|
|
42
|
+
const onCheckedChange = vi.fn()
|
|
43
|
+
render(<Switch aria-label="Toggle" onCheckedChange={onCheckedChange} />)
|
|
44
|
+
|
|
45
|
+
const sw = screen.getByRole('switch')
|
|
46
|
+
expect(sw).not.toBeChecked()
|
|
47
|
+
|
|
48
|
+
await user.click(sw)
|
|
49
|
+
expect(onCheckedChange).toHaveBeenCalledWith(true, expect.anything())
|
|
50
|
+
expect(sw).toBeChecked()
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('toggles via keyboard (Space)', async () => {
|
|
54
|
+
const user = userEvent.setup()
|
|
55
|
+
const onCheckedChange = vi.fn()
|
|
56
|
+
render(<Switch aria-label="Toggle" onCheckedChange={onCheckedChange} />)
|
|
57
|
+
|
|
58
|
+
const sw = screen.getByRole('switch')
|
|
59
|
+
sw.focus()
|
|
60
|
+
await user.keyboard(' ')
|
|
61
|
+
expect(onCheckedChange).toHaveBeenCalledOnce()
|
|
62
|
+
expect(sw).toBeChecked()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('does not toggle when disabled', async () => {
|
|
66
|
+
const user = userEvent.setup()
|
|
67
|
+
const onCheckedChange = vi.fn()
|
|
68
|
+
render(<Switch disabled aria-label="Disabled" onCheckedChange={onCheckedChange} />)
|
|
69
|
+
|
|
70
|
+
await user.click(screen.getByRole('switch'))
|
|
71
|
+
expect(onCheckedChange).not.toHaveBeenCalled()
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('honours controlled checked prop', async () => {
|
|
75
|
+
const user = userEvent.setup()
|
|
76
|
+
const onCheckedChange = vi.fn()
|
|
77
|
+
render(<Switch checked={false} aria-label="Controlled" onCheckedChange={onCheckedChange} />)
|
|
78
|
+
|
|
79
|
+
const sw = screen.getByRole('switch')
|
|
80
|
+
await user.click(sw)
|
|
81
|
+
expect(onCheckedChange).toHaveBeenCalledWith(true, expect.anything())
|
|
82
|
+
// Stays unchecked because parent never updates
|
|
83
|
+
expect(sw).not.toBeChecked()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('applies size styles to the root', () => {
|
|
87
|
+
render(<Switch size="lg" aria-label="Large" />)
|
|
88
|
+
expect(screen.getByRole('switch').className).toContain('h-6')
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('forwards className to the root', () => {
|
|
92
|
+
render(<Switch className="custom-class" aria-label="Styled" />)
|
|
93
|
+
expect(screen.getByRole('switch').className).toContain('custom-class')
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('has no accessibility violations', async () => {
|
|
97
|
+
const { container } = render(<Switch aria-label="Notifications" />)
|
|
98
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
99
|
+
})
|
|
100
|
+
})
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Switch as BaseSwitch } from '@base-ui/react/switch'
|
|
5
|
+
import { LazyMotion, domAnimation, m, useAnimate } from 'motion/react'
|
|
6
|
+
import { useDirection } from '../../hooks/use-direction'
|
|
7
|
+
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
8
|
+
import { cn, useComposedRefs } from '../../utils'
|
|
9
|
+
|
|
10
|
+
const switchSizes = {
|
|
11
|
+
sm: {
|
|
12
|
+
root: 'h-4 w-7.5',
|
|
13
|
+
thumb: 'size-3',
|
|
14
|
+
thumbWidthKeyframes: ['0.75rem', '1.25rem', '0.75rem'],
|
|
15
|
+
thumbXKeyframes: [0, '0.3125rem', '0.875rem'],
|
|
16
|
+
check: 'size-2.5',
|
|
17
|
+
},
|
|
18
|
+
md: {
|
|
19
|
+
root: 'h-5 w-9.5',
|
|
20
|
+
thumb: 'size-4',
|
|
21
|
+
thumbWidthKeyframes: ['1rem', '1.6875rem', '1rem'],
|
|
22
|
+
thumbXKeyframes: [0, '0.4375rem', '1.125rem'],
|
|
23
|
+
check: 'size-3',
|
|
24
|
+
},
|
|
25
|
+
lg: {
|
|
26
|
+
root: 'h-6 w-11.5',
|
|
27
|
+
thumb: 'size-5',
|
|
28
|
+
thumbWidthKeyframes: ['1.25rem', '2.125rem', '1.25rem'],
|
|
29
|
+
thumbXKeyframes: [0, '0.5rem', '1.375rem'],
|
|
30
|
+
check: 'size-4',
|
|
31
|
+
},
|
|
32
|
+
} as const
|
|
33
|
+
|
|
34
|
+
type SwitchSize = keyof typeof switchSizes
|
|
35
|
+
type SizeConfig = (typeof switchSizes)[SwitchSize]
|
|
36
|
+
|
|
37
|
+
const THUMB_TRANSITION = { duration: 0.25, ease: [0.4, 0, 0.2, 1] satisfies [number, number, number, number] }
|
|
38
|
+
|
|
39
|
+
type Keyframe = number | string
|
|
40
|
+
|
|
41
|
+
function applyDirection(keyframes: ReadonlyArray<Keyframe>, dirSign: 1 | -1): Keyframe[] {
|
|
42
|
+
if (dirSign === 1) return [...keyframes]
|
|
43
|
+
return keyframes.map((v) => (typeof v === 'number' ? -v : `-${v}`))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function SwitchThumb({
|
|
47
|
+
renderProps,
|
|
48
|
+
state,
|
|
49
|
+
dirSign,
|
|
50
|
+
sizeConfig,
|
|
51
|
+
reduced,
|
|
52
|
+
}: {
|
|
53
|
+
renderProps: React.ComponentPropsWithRef<'span'>
|
|
54
|
+
state: { checked: boolean }
|
|
55
|
+
dirSign: 1 | -1
|
|
56
|
+
sizeConfig: SizeConfig
|
|
57
|
+
reduced: boolean
|
|
58
|
+
}) {
|
|
59
|
+
const { checked } = state
|
|
60
|
+
const { ref, onDrag, onDragStart, onDragEnd, onAnimationStart, onAnimationEnd, ...htmlProps } = renderProps
|
|
61
|
+
|
|
62
|
+
const xKeyframes = React.useMemo(() => {
|
|
63
|
+
const directional = applyDirection(sizeConfig.thumbXKeyframes, dirSign)
|
|
64
|
+
return checked ? directional : directional.reverse()
|
|
65
|
+
}, [checked, dirSign, sizeConfig])
|
|
66
|
+
|
|
67
|
+
const xFinal = xKeyframes[xKeyframes.length - 1]
|
|
68
|
+
|
|
69
|
+
const [scope, animate] = useAnimate()
|
|
70
|
+
const composedRef = useComposedRefs(ref, scope)
|
|
71
|
+
const prevChecked = React.useRef(checked)
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
const toggled = prevChecked.current !== checked
|
|
74
|
+
prevChecked.current = checked
|
|
75
|
+
if (toggled && !reduced) {
|
|
76
|
+
animate(scope.current, { x: xKeyframes, width: sizeConfig.thumbWidthKeyframes }, THUMB_TRANSITION)
|
|
77
|
+
} else {
|
|
78
|
+
animate(scope.current, { x: xFinal }, { duration: 0 })
|
|
79
|
+
}
|
|
80
|
+
}, [checked, sizeConfig, animate, scope, reduced, xKeyframes, xFinal])
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<m.span {...htmlProps} ref={composedRef} initial={{ x: xFinal }}>
|
|
84
|
+
<m.svg
|
|
85
|
+
className={cn('text-foreground-intense', sizeConfig.check)}
|
|
86
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
87
|
+
viewBox="0 0 12 12"
|
|
88
|
+
fill="none"
|
|
89
|
+
stroke="currentColor"
|
|
90
|
+
strokeWidth="1.5"
|
|
91
|
+
strokeLinecap="round"
|
|
92
|
+
strokeLinejoin="round"
|
|
93
|
+
style={{ strokeDasharray: 12 }}
|
|
94
|
+
initial={false}
|
|
95
|
+
animate={{ strokeDashoffset: checked ? 0 : 12 }}
|
|
96
|
+
transition={
|
|
97
|
+
reduced
|
|
98
|
+
? { duration: 0 }
|
|
99
|
+
: {
|
|
100
|
+
strokeDashoffset: {
|
|
101
|
+
duration: checked ? 0.3 : 0,
|
|
102
|
+
ease: 'easeOut',
|
|
103
|
+
delay: checked ? 0.25 : 0,
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
>
|
|
108
|
+
<path d="M3 6l2 2 4-4" />
|
|
109
|
+
</m.svg>
|
|
110
|
+
</m.span>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface SwitchProps extends React.ComponentProps<typeof BaseSwitch.Root> {
|
|
115
|
+
size?: SwitchSize
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function Switch({ className, size = 'md', ...props }: SwitchProps) {
|
|
119
|
+
const direction = useDirection()
|
|
120
|
+
const dirSign: 1 | -1 = direction === 'rtl' ? -1 : 1
|
|
121
|
+
const sizeConfig = switchSizes[size]
|
|
122
|
+
const reduced = useReducedMotion()
|
|
123
|
+
|
|
124
|
+
const ariaInvalid = props['aria-invalid']
|
|
125
|
+
const invalid = ariaInvalid === true || ariaInvalid === 'true'
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<LazyMotion features={domAnimation} strict>
|
|
129
|
+
<BaseSwitch.Root
|
|
130
|
+
data-slot="switch"
|
|
131
|
+
className={cn(
|
|
132
|
+
'bg-background-strong outline-ring flex shrink-0 rounded-full border border-transparent p-px outline-offset-1',
|
|
133
|
+
sizeConfig.root,
|
|
134
|
+
'transition-background duration-200 motion-reduce:transition-none',
|
|
135
|
+
'data-checked:bg-primary data-checked:outline-ring-primary',
|
|
136
|
+
'data-disabled:not-data-checked:border-border-strong data-disabled:opacity-disabled data-disabled:cursor-not-allowed data-disabled:not-data-checked:border-dashed',
|
|
137
|
+
'data-invalid:border-error data-invalid:not-data-checked:bg-error-subtle data-invalid:outline-ring-error',
|
|
138
|
+
className,
|
|
139
|
+
)}
|
|
140
|
+
{...props}
|
|
141
|
+
{...(invalid ? { 'data-invalid': '' } : {})}
|
|
142
|
+
>
|
|
143
|
+
<BaseSwitch.Thumb
|
|
144
|
+
data-slot="switch-thumb"
|
|
145
|
+
className={cn(
|
|
146
|
+
'group flex items-center justify-center rounded-full bg-white shadow-2xs',
|
|
147
|
+
sizeConfig.thumb,
|
|
148
|
+
'data-checked:bg-primary-foreground',
|
|
149
|
+
)}
|
|
150
|
+
render={(renderProps, state) => (
|
|
151
|
+
<SwitchThumb
|
|
152
|
+
renderProps={renderProps}
|
|
153
|
+
state={state}
|
|
154
|
+
dirSign={dirSign}
|
|
155
|
+
sizeConfig={sizeConfig}
|
|
156
|
+
reduced={reduced}
|
|
157
|
+
/>
|
|
158
|
+
)}
|
|
159
|
+
/>
|
|
160
|
+
</BaseSwitch.Root>
|
|
161
|
+
</LazyMotion>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export { Switch }
|
|
166
|
+
export type { SwitchProps }
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
import { describe, it, expect } from 'vitest'
|
|
4
|
+
import { axe } from 'vitest-axe'
|
|
5
|
+
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from './table'
|
|
6
|
+
|
|
7
|
+
function Demo(props: React.ComponentProps<typeof Table> = {}) {
|
|
8
|
+
return (
|
|
9
|
+
<Table {...props}>
|
|
10
|
+
<TableCaption>Recent transactions</TableCaption>
|
|
11
|
+
<TableHeader>
|
|
12
|
+
<TableRow>
|
|
13
|
+
<TableHead>Date</TableHead>
|
|
14
|
+
<TableHead>Description</TableHead>
|
|
15
|
+
<TableHead className="text-end">Amount</TableHead>
|
|
16
|
+
</TableRow>
|
|
17
|
+
</TableHeader>
|
|
18
|
+
<TableBody>
|
|
19
|
+
<TableRow>
|
|
20
|
+
<TableCell>Aug 30</TableCell>
|
|
21
|
+
<TableCell>Salary</TableCell>
|
|
22
|
+
<TableCell className="text-end">+ $4,150.00</TableCell>
|
|
23
|
+
</TableRow>
|
|
24
|
+
<TableRow highlighted>
|
|
25
|
+
<TableCell>Aug 24</TableCell>
|
|
26
|
+
<TableCell>Netflix</TableCell>
|
|
27
|
+
<TableCell className="text-end">- $20.00</TableCell>
|
|
28
|
+
</TableRow>
|
|
29
|
+
<TableRow>
|
|
30
|
+
<TableCell>Aug 17</TableCell>
|
|
31
|
+
<TableCell>Electricity</TableCell>
|
|
32
|
+
<TableCell className="text-end">- $186.35</TableCell>
|
|
33
|
+
</TableRow>
|
|
34
|
+
</TableBody>
|
|
35
|
+
</Table>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
describe('Table', () => {
|
|
40
|
+
it('renders the full semantic composition', () => {
|
|
41
|
+
render(<Demo />)
|
|
42
|
+
const table = screen.getByRole('table')
|
|
43
|
+
expect(table).toHaveAttribute('data-slot', 'table')
|
|
44
|
+
expect(screen.getAllByRole('columnheader')).toHaveLength(3)
|
|
45
|
+
expect(screen.getAllByRole('row')).toHaveLength(4) // header + 3 body rows
|
|
46
|
+
expect(screen.getAllByRole('cell')).toHaveLength(9)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('applies size padding via parent descendant selectors', () => {
|
|
50
|
+
const { rerender } = render(<Demo size="sm" />)
|
|
51
|
+
expect(screen.getByRole('table').className).toContain('[&_td]:p-3')
|
|
52
|
+
expect(screen.getByRole('table').className).toContain('p-1 ')
|
|
53
|
+
|
|
54
|
+
rerender(<Demo size="md" />)
|
|
55
|
+
expect(screen.getByRole('table').className).toContain('[&_td]:p-3.5')
|
|
56
|
+
|
|
57
|
+
rerender(<Demo size="lg" />)
|
|
58
|
+
expect(screen.getByRole('table').className).toContain('[&_td]:p-4')
|
|
59
|
+
expect(screen.getByRole('table').className).toContain('p-1.5')
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('applies dashed border style on body cells via parent selector', () => {
|
|
63
|
+
render(<Demo borderStyle="dashed" />)
|
|
64
|
+
const className = screen.getByRole('table').className
|
|
65
|
+
expect(className).toContain('[&_td]:border-dashed')
|
|
66
|
+
expect(className).toContain('[&_td]:border-border-strong')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('strips cell borders when borderStyle="none"', () => {
|
|
70
|
+
render(<Demo borderStyle="none" />)
|
|
71
|
+
const className = screen.getByRole('table').className
|
|
72
|
+
expect(className).toContain('[&_td]:border-b-0')
|
|
73
|
+
expect(className).toContain('[&>tbody_th]:border-b-0')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('toggles data-highlighted on the row when highlighted prop is set', () => {
|
|
77
|
+
render(<Demo />)
|
|
78
|
+
const rows = screen.getAllByRole('row')
|
|
79
|
+
// header (idx 0), then three body rows; idx 2 is highlighted
|
|
80
|
+
expect(rows[2]).toHaveAttribute('data-highlighted', '')
|
|
81
|
+
expect(rows[1]).not.toHaveAttribute('data-highlighted')
|
|
82
|
+
expect(rows[3]).not.toHaveAttribute('data-highlighted')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('opts into striped rows only when stripedRows is set', () => {
|
|
86
|
+
const { rerender } = render(<Demo />)
|
|
87
|
+
expect(screen.getByRole('table').className).not.toContain('[&>tbody>tr:nth-child(2n)]:bg-background-subtle')
|
|
88
|
+
|
|
89
|
+
rerender(<Demo stripedRows />)
|
|
90
|
+
expect(screen.getByRole('table').className).toContain('[&>tbody>tr:nth-child(2n)]:bg-background-subtle')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('opts into striped columns only when stripedColumns is set', () => {
|
|
94
|
+
const { rerender } = render(<Demo />)
|
|
95
|
+
expect(screen.getByRole('table').className).not.toContain('[&>tbody>tr>:nth-child(2n)]:bg-background-subtle')
|
|
96
|
+
|
|
97
|
+
rerender(<Demo stripedColumns />)
|
|
98
|
+
expect(screen.getByRole('table').className).toContain('[&>tbody>tr>:nth-child(2n)]:bg-background-subtle')
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('opts into row hover styling only when hoverableRows is set', () => {
|
|
102
|
+
const { rerender } = render(<Demo />)
|
|
103
|
+
expect(screen.getByRole('table').className).not.toContain('[&>tbody>tr:hover]:bg-background-subtle')
|
|
104
|
+
|
|
105
|
+
rerender(<Demo hoverableRows />)
|
|
106
|
+
expect(screen.getByRole('table').className).toContain('[&>tbody>tr:hover]:bg-background-subtle')
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('applies bottom inner-radius classes to last body row cells', () => {
|
|
110
|
+
render(<Demo size="md" />)
|
|
111
|
+
const className = screen.getByRole('table').className
|
|
112
|
+
expect(className).toContain('[&>tbody:last-of-type>tr:last-child>:first-child]:rounded-es-md')
|
|
113
|
+
expect(className).toContain('[&>tbody:last-of-type>tr:last-child>:last-child]:rounded-ee-md')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('keeps top inner-radius classes ready for the no-header case', () => {
|
|
117
|
+
// The classes are always present on the table; CSS :not(:has(thead)) handles
|
|
118
|
+
// whether they actually apply at paint time. Verify the literal class is emitted.
|
|
119
|
+
render(<Demo size="md" />)
|
|
120
|
+
const className = screen.getByRole('table').className
|
|
121
|
+
expect(className).toContain('[&:not(:has(thead))>tbody:first-of-type>tr:first-child>:first-child]:rounded-ss-md')
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('applies header pill background and corner classes', () => {
|
|
125
|
+
render(<Demo size="md" />)
|
|
126
|
+
const className = screen.getByRole('table').className
|
|
127
|
+
expect(className).toContain('[&>thead>tr>th]:bg-background-muted')
|
|
128
|
+
expect(className).toContain('[&>thead>tr:first-child>th:first-child]:rounded-ss-md')
|
|
129
|
+
expect(className).toContain('[&>thead>tr:last-child>th:last-child]:rounded-ee-md')
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('renders <th scope="row"> inside <tbody> as a row-header cell', () => {
|
|
133
|
+
render(
|
|
134
|
+
<Table>
|
|
135
|
+
<TableBody>
|
|
136
|
+
<TableRow>
|
|
137
|
+
<TableHead scope="row">Monday</TableHead>
|
|
138
|
+
<TableCell>Standup</TableCell>
|
|
139
|
+
</TableRow>
|
|
140
|
+
</TableBody>
|
|
141
|
+
</Table>,
|
|
142
|
+
)
|
|
143
|
+
expect(screen.getByRole('rowheader', { name: 'Monday' })).toBeInTheDocument()
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('places the caption above when position="top"', () => {
|
|
147
|
+
render(
|
|
148
|
+
<Table>
|
|
149
|
+
<TableCaption position="top">Title</TableCaption>
|
|
150
|
+
<TableBody>
|
|
151
|
+
<TableRow>
|
|
152
|
+
<TableCell>cell</TableCell>
|
|
153
|
+
</TableRow>
|
|
154
|
+
</TableBody>
|
|
155
|
+
</Table>,
|
|
156
|
+
)
|
|
157
|
+
const caption = screen.getByText('Title')
|
|
158
|
+
expect(caption.tagName).toBe('CAPTION')
|
|
159
|
+
expect(caption.className).toContain('caption-top')
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('emits data-slot on each sub-component', () => {
|
|
163
|
+
render(<Demo />)
|
|
164
|
+
expect(screen.getByRole('table')).toHaveAttribute('data-slot', 'table')
|
|
165
|
+
expect(screen.getByText('Recent transactions')).toHaveAttribute('data-slot', 'table-caption')
|
|
166
|
+
expect(screen.getAllByRole('columnheader')[0]).toHaveAttribute('data-slot', 'table-head')
|
|
167
|
+
expect(screen.getAllByRole('cell')[0]).toHaveAttribute('data-slot', 'table-cell')
|
|
168
|
+
expect(screen.getAllByRole('row')[1]).toHaveAttribute('data-slot', 'table-row')
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
it('has no accessibility violations', async () => {
|
|
172
|
+
const { container } = render(<Demo />)
|
|
173
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
174
|
+
})
|
|
175
|
+
})
|