@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,123 @@
|
|
|
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 { Slider } from './slider'
|
|
6
|
+
|
|
7
|
+
describe('Slider', () => {
|
|
8
|
+
it('renders a single thumb when no value is provided', () => {
|
|
9
|
+
render(<Slider thumbAriaLabel="Volume" />)
|
|
10
|
+
const thumbs = screen.getAllByRole('slider')
|
|
11
|
+
expect(thumbs).toHaveLength(1)
|
|
12
|
+
expect(thumbs[0]).toHaveAttribute('aria-label', 'Volume')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('reflects defaultValue for a single thumb', () => {
|
|
16
|
+
render(<Slider defaultValue={42} thumbAriaLabel="Volume" />)
|
|
17
|
+
expect(screen.getByRole('slider')).toHaveAttribute('aria-valuenow', '42')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('renders one thumb per value in a range slider', () => {
|
|
21
|
+
render(<Slider defaultValue={[20, 80]} thumbAriaLabel={(i) => (i === 0 ? 'Min' : 'Max')} />)
|
|
22
|
+
const thumbs = screen.getAllByRole('slider')
|
|
23
|
+
expect(thumbs).toHaveLength(2)
|
|
24
|
+
expect(thumbs[0]).toHaveAttribute('aria-valuenow', '20')
|
|
25
|
+
expect(thumbs[1]).toHaveAttribute('aria-valuenow', '80')
|
|
26
|
+
expect(thumbs[0]).toHaveAttribute('aria-label', 'Min')
|
|
27
|
+
expect(thumbs[1]).toHaveAttribute('aria-label', 'Max')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('forwards min, max, step to the thumb input', () => {
|
|
31
|
+
render(<Slider defaultValue={5} min={0} max={20} step={2} thumbAriaLabel="Volume" />)
|
|
32
|
+
const thumb = screen.getByRole('slider')
|
|
33
|
+
expect(thumb).toHaveAttribute('min', '0')
|
|
34
|
+
expect(thumb).toHaveAttribute('max', '20')
|
|
35
|
+
expect(thumb).toHaveAttribute('step', '2')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('fires onValueChange with the new value on ArrowRight', async () => {
|
|
39
|
+
const user = userEvent.setup()
|
|
40
|
+
const onValueChange = vi.fn()
|
|
41
|
+
render(<Slider defaultValue={10} onValueChange={onValueChange} thumbAriaLabel="Volume" />)
|
|
42
|
+
|
|
43
|
+
const thumb = screen.getByRole('slider')
|
|
44
|
+
thumb.focus()
|
|
45
|
+
await user.keyboard('{ArrowRight}')
|
|
46
|
+
|
|
47
|
+
expect(onValueChange).toHaveBeenCalled()
|
|
48
|
+
expect(onValueChange.mock.calls[0]![0]).toBe(11)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('does not fire onValueChange when disabled', async () => {
|
|
52
|
+
const user = userEvent.setup()
|
|
53
|
+
const onValueChange = vi.fn()
|
|
54
|
+
render(<Slider defaultValue={10} disabled onValueChange={onValueChange} thumbAriaLabel="Volume" />)
|
|
55
|
+
|
|
56
|
+
const thumb = screen.getByRole('slider')
|
|
57
|
+
thumb.focus()
|
|
58
|
+
await user.keyboard('{ArrowRight}')
|
|
59
|
+
|
|
60
|
+
expect(onValueChange).not.toHaveBeenCalled()
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('respects controlled value', async () => {
|
|
64
|
+
const user = userEvent.setup()
|
|
65
|
+
const onValueChange = vi.fn()
|
|
66
|
+
render(<Slider value={30} onValueChange={onValueChange} thumbAriaLabel="Volume" />)
|
|
67
|
+
|
|
68
|
+
const thumb = screen.getByRole('slider')
|
|
69
|
+
thumb.focus()
|
|
70
|
+
await user.keyboard('{ArrowRight}')
|
|
71
|
+
|
|
72
|
+
expect(onValueChange).toHaveBeenCalled()
|
|
73
|
+
// Parent never updates — value stays at 30.
|
|
74
|
+
expect(thumb).toHaveAttribute('aria-valuenow', '30')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('sets data-orientation on the root for vertical sliders', () => {
|
|
78
|
+
const { container } = render(<Slider orientation="vertical" defaultValue={50} thumbAriaLabel="Volume" />)
|
|
79
|
+
const root = container.querySelector('[data-slot="slider"]')
|
|
80
|
+
expect(root).toHaveAttribute('data-orientation', 'vertical')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('does not render a tooltip when tooltipVisibility="never"', () => {
|
|
84
|
+
const { container } = render(<Slider defaultValue={50} tooltipVisibility="never" thumbAriaLabel="Volume" />)
|
|
85
|
+
expect(container.querySelector('[data-slot="slider-tooltip"]')).toBeNull()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('renders a tooltip per thumb when tooltipVisibility="always"', () => {
|
|
89
|
+
const { container } = render(
|
|
90
|
+
<Slider defaultValue={[10, 90]} tooltipVisibility="always" thumbAriaLabel={(i) => (i === 0 ? 'Min' : 'Max')} />,
|
|
91
|
+
)
|
|
92
|
+
const tooltips = container.querySelectorAll('[data-slot="slider-tooltip"]')
|
|
93
|
+
expect(tooltips).toHaveLength(2)
|
|
94
|
+
expect(tooltips[0]?.textContent).toBe('10')
|
|
95
|
+
expect(tooltips[1]?.textContent).toBe('90')
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('shows the tooltip on hover when tooltipVisibility="auto" (default)', async () => {
|
|
99
|
+
const user = userEvent.setup()
|
|
100
|
+
const { container } = render(<Slider defaultValue={50} thumbAriaLabel="Volume" />)
|
|
101
|
+
expect(container.querySelector('[data-slot="slider-tooltip"]')).toBeNull()
|
|
102
|
+
|
|
103
|
+
const thumbWrapper = container.querySelector('[data-slot="slider-thumb"]') as HTMLElement
|
|
104
|
+
expect(thumbWrapper).not.toBeNull()
|
|
105
|
+
await user.hover(thumbWrapper)
|
|
106
|
+
expect(container.querySelector('[data-slot="slider-tooltip"]')).not.toBeNull()
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('forwards className to the root', () => {
|
|
110
|
+
const { container } = render(<Slider className="custom-slider" defaultValue={50} thumbAriaLabel="Volume" />)
|
|
111
|
+
expect(container.querySelector('[data-slot="slider"]')?.className).toContain('custom-slider')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('has no accessibility violations (single thumb)', async () => {
|
|
115
|
+
const { container } = render(<Slider defaultValue={50} thumbAriaLabel="Volume" />)
|
|
116
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('has no accessibility violations (range)', async () => {
|
|
120
|
+
const { container } = render(<Slider defaultValue={[20, 80]} thumbAriaLabel={(i) => (i === 0 ? 'Min' : 'Max')} />)
|
|
121
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
122
|
+
})
|
|
123
|
+
})
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { Slider as BaseSlider } from '@base-ui/react/slider'
|
|
5
|
+
import { AnimatePresence, LazyMotion, domAnimation, m, useAnimate } from 'motion/react'
|
|
6
|
+
import { cn } from '../../utils'
|
|
7
|
+
import { useDirection } from '../../hooks/use-direction'
|
|
8
|
+
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
9
|
+
|
|
10
|
+
type SliderTooltipVisibility = 'always' | 'auto' | 'never'
|
|
11
|
+
|
|
12
|
+
type AnimDirection = 'up' | 'down'
|
|
13
|
+
|
|
14
|
+
const TOOLTIP_TILT_DEG = 8
|
|
15
|
+
const TOOLTIP_TILT_TRANSITION = {
|
|
16
|
+
duration: 0.4,
|
|
17
|
+
ease: [0.34, 1.56, 0.64, 1] satisfies [number, number, number, number],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const TOOLTIP_POPUP_TRANSITION = {
|
|
21
|
+
duration: 0.2,
|
|
22
|
+
ease: [0.175, 0.885, 0.32, 1.5] satisfies [number, number, number, number],
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const tooltipWrapperClasses =
|
|
26
|
+
'absolute z-10 pointer-events-none transition-transform duration-250 group-hover:scale-110 group-focus-within:scale-110 motion-reduce:transition-none data-[orientation=horizontal]:bottom-full data-[orientation=horizontal]:left-1/2 data-[orientation=horizontal]:-translate-x-1/2 data-[orientation=horizontal]:mb-1 data-[orientation=horizontal]:origin-bottom data-[orientation=vertical]:top-1/2 data-[orientation=vertical]:-translate-y-1/2 data-[orientation=vertical]:inset-s-full data-[orientation=vertical]:ms-1 data-[orientation=vertical]:ltr:origin-left data-[orientation=vertical]:rtl:origin-right'
|
|
27
|
+
|
|
28
|
+
const tooltipInnerClasses =
|
|
29
|
+
'bg-background-inverse text-foreground-inverse rounded-4xs block px-1 py-0.5 text-xs leading-none whitespace-nowrap data-[orientation=horizontal]:origin-bottom data-[orientation=vertical]:ltr:origin-left data-[orientation=vertical]:rtl:origin-right'
|
|
30
|
+
|
|
31
|
+
interface SliderTooltipProps {
|
|
32
|
+
index: number
|
|
33
|
+
visibility: 'always' | 'auto'
|
|
34
|
+
orientation: 'horizontal' | 'vertical'
|
|
35
|
+
changeVersion: number
|
|
36
|
+
direction: AnimDirection
|
|
37
|
+
dirSign: 1 | -1
|
|
38
|
+
reduced: boolean
|
|
39
|
+
open: boolean
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function SliderTooltip({
|
|
43
|
+
index,
|
|
44
|
+
visibility,
|
|
45
|
+
orientation,
|
|
46
|
+
changeVersion,
|
|
47
|
+
direction,
|
|
48
|
+
dirSign,
|
|
49
|
+
reduced,
|
|
50
|
+
open,
|
|
51
|
+
}: SliderTooltipProps) {
|
|
52
|
+
const [scope, animate] = useAnimate<HTMLDivElement>()
|
|
53
|
+
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
if (reduced || changeVersion === 0 || !scope.current) return
|
|
56
|
+
const sign = direction === 'up' ? 1 : -1
|
|
57
|
+
const tilt = -sign * dirSign * TOOLTIP_TILT_DEG
|
|
58
|
+
animate(scope.current, { rotate: [tilt, 0] }, TOOLTIP_TILT_TRANSITION)
|
|
59
|
+
}, [changeVersion, direction, dirSign, reduced, animate, scope])
|
|
60
|
+
|
|
61
|
+
const visible = visibility === 'always' || open
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<span data-slot="slider-tooltip-wrapper" data-orientation={orientation} className={tooltipWrapperClasses}>
|
|
65
|
+
<AnimatePresence>
|
|
66
|
+
{visible && (
|
|
67
|
+
<m.div
|
|
68
|
+
ref={scope}
|
|
69
|
+
data-slot="slider-tooltip"
|
|
70
|
+
data-orientation={orientation}
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
className={tooltipInnerClasses}
|
|
73
|
+
initial={reduced ? false : { opacity: 0, scale: 0.9 }}
|
|
74
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
75
|
+
exit={reduced ? { opacity: 0 } : { opacity: 0, scale: 0.95 }}
|
|
76
|
+
transition={reduced ? { duration: 0 } : TOOLTIP_POPUP_TRANSITION}
|
|
77
|
+
>
|
|
78
|
+
<BaseSlider.Value>
|
|
79
|
+
{(formattedValues) => <span className="leading-none">{formattedValues?.[index] ?? ''}</span>}
|
|
80
|
+
</BaseSlider.Value>
|
|
81
|
+
</m.div>
|
|
82
|
+
)}
|
|
83
|
+
</AnimatePresence>
|
|
84
|
+
</span>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const thumbClasses =
|
|
89
|
+
'group relative block size-3 shrink-0 cursor-default rounded-full select-none disabled:pointer-events-none disabled:opacity-disabled'
|
|
90
|
+
|
|
91
|
+
const thumbVisualClasses =
|
|
92
|
+
'bg-background border-primary relative block size-full rounded-full border-2 shadow-xs transition-transform duration-250 group-hover:scale-125 group-focus-within:scale-125 motion-reduce:transition-none'
|
|
93
|
+
|
|
94
|
+
interface SliderThumbProps {
|
|
95
|
+
index: number
|
|
96
|
+
ariaLabel?: string
|
|
97
|
+
tooltipVisibility: SliderTooltipVisibility
|
|
98
|
+
orientation: 'horizontal' | 'vertical'
|
|
99
|
+
changeVersion: number
|
|
100
|
+
direction: AnimDirection
|
|
101
|
+
dirSign: 1 | -1
|
|
102
|
+
reduced: boolean
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function SliderThumb({
|
|
106
|
+
index,
|
|
107
|
+
ariaLabel,
|
|
108
|
+
tooltipVisibility,
|
|
109
|
+
orientation,
|
|
110
|
+
changeVersion,
|
|
111
|
+
direction,
|
|
112
|
+
dirSign,
|
|
113
|
+
reduced,
|
|
114
|
+
}: SliderThumbProps) {
|
|
115
|
+
const [hovered, setHovered] = React.useState(false)
|
|
116
|
+
const [focused, setFocused] = React.useState(false)
|
|
117
|
+
|
|
118
|
+
const autoOpen = tooltipVisibility === 'auto' && (hovered || focused)
|
|
119
|
+
|
|
120
|
+
const eventHandlers =
|
|
121
|
+
tooltipVisibility === 'auto'
|
|
122
|
+
? {
|
|
123
|
+
onPointerEnter: () => setHovered(true),
|
|
124
|
+
onPointerLeave: () => setHovered(false),
|
|
125
|
+
onFocus: () => setFocused(true),
|
|
126
|
+
onBlur: () => setFocused(false),
|
|
127
|
+
}
|
|
128
|
+
: {}
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<BaseSlider.Thumb
|
|
132
|
+
index={index}
|
|
133
|
+
aria-label={ariaLabel}
|
|
134
|
+
data-slot="slider-thumb"
|
|
135
|
+
className={thumbClasses}
|
|
136
|
+
{...eventHandlers}
|
|
137
|
+
>
|
|
138
|
+
<span data-slot="slider-thumb-visual" className={thumbVisualClasses} />
|
|
139
|
+
{tooltipVisibility !== 'never' && (
|
|
140
|
+
<SliderTooltip
|
|
141
|
+
index={index}
|
|
142
|
+
visibility={tooltipVisibility}
|
|
143
|
+
orientation={orientation}
|
|
144
|
+
changeVersion={changeVersion}
|
|
145
|
+
direction={direction}
|
|
146
|
+
dirSign={dirSign}
|
|
147
|
+
reduced={reduced}
|
|
148
|
+
open={autoOpen}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
</BaseSlider.Thumb>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const rootClasses =
|
|
156
|
+
'data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-fit'
|
|
157
|
+
|
|
158
|
+
const controlClasses =
|
|
159
|
+
'relative flex w-full touch-none items-center select-none data-disabled:opacity-disabled data-disabled:pointer-events-none data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-40 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col'
|
|
160
|
+
|
|
161
|
+
const trackClasses =
|
|
162
|
+
'relative grow overflow-hidden rounded-full bg-background-strong select-none data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5'
|
|
163
|
+
|
|
164
|
+
const indicatorClasses =
|
|
165
|
+
'bg-primary select-none data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full'
|
|
166
|
+
|
|
167
|
+
interface SliderProps extends Omit<BaseSlider.Root.Props, 'children'> {
|
|
168
|
+
tooltipVisibility?: SliderTooltipVisibility
|
|
169
|
+
thumbAriaLabel?: string | ((index: number) => string)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function toArray(value: number | readonly number[] | undefined): number[] {
|
|
173
|
+
if (value == null) return []
|
|
174
|
+
return Array.isArray(value) ? [...value] : [value as number]
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function Slider({
|
|
178
|
+
tooltipVisibility = 'auto',
|
|
179
|
+
thumbAriaLabel,
|
|
180
|
+
className,
|
|
181
|
+
value,
|
|
182
|
+
defaultValue,
|
|
183
|
+
orientation = 'horizontal',
|
|
184
|
+
onValueChange,
|
|
185
|
+
...rootProps
|
|
186
|
+
}: SliderProps) {
|
|
187
|
+
const direction = useDirection()
|
|
188
|
+
const dirSign: 1 | -1 = direction === 'rtl' ? -1 : 1
|
|
189
|
+
const reduced = useReducedMotion()
|
|
190
|
+
|
|
191
|
+
const seed = value ?? defaultValue
|
|
192
|
+
const thumbCount = Array.isArray(seed) ? seed.length : 1
|
|
193
|
+
|
|
194
|
+
const trackTooltips = tooltipVisibility !== 'never'
|
|
195
|
+
|
|
196
|
+
const prevValuesRef = React.useRef<number[]>(toArray(seed))
|
|
197
|
+
const [tilts, setTilts] = React.useState<Array<{ direction: AnimDirection; version: number }>>(() =>
|
|
198
|
+
Array.from({ length: thumbCount }, () => ({ direction: 'up', version: 0 })),
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
const handleValueChange: NonNullable<typeof onValueChange> = (next, details) => {
|
|
202
|
+
if (trackTooltips) {
|
|
203
|
+
const nextArr = toArray(next)
|
|
204
|
+
const prevArr = prevValuesRef.current
|
|
205
|
+
prevValuesRef.current = nextArr
|
|
206
|
+
setTilts((prev) => {
|
|
207
|
+
let changed = false
|
|
208
|
+
const updated = nextArr.map((_, i) => {
|
|
209
|
+
const existing = prev[i] ?? { direction: 'up' as AnimDirection, version: 0 }
|
|
210
|
+
const p = prevArr[i] ?? 0
|
|
211
|
+
const c = nextArr[i] ?? p
|
|
212
|
+
if (c === p) return existing
|
|
213
|
+
changed = true
|
|
214
|
+
return { direction: (c > p ? 'up' : 'down') as AnimDirection, version: existing.version + 1 }
|
|
215
|
+
})
|
|
216
|
+
return changed || updated.length !== prev.length ? updated : prev
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
onValueChange?.(next, details)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const resolveAriaLabel = (index: number): string | undefined => {
|
|
223
|
+
if (typeof thumbAriaLabel === 'function') return thumbAriaLabel(index)
|
|
224
|
+
return thumbAriaLabel
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<LazyMotion features={domAnimation} strict>
|
|
229
|
+
<BaseSlider.Root
|
|
230
|
+
data-slot="slider"
|
|
231
|
+
orientation={orientation}
|
|
232
|
+
value={value}
|
|
233
|
+
defaultValue={defaultValue}
|
|
234
|
+
onValueChange={handleValueChange}
|
|
235
|
+
className={cn(rootClasses, className)}
|
|
236
|
+
{...rootProps}
|
|
237
|
+
>
|
|
238
|
+
<BaseSlider.Control data-slot="slider-control" className={controlClasses}>
|
|
239
|
+
<BaseSlider.Track data-slot="slider-track" className={trackClasses}>
|
|
240
|
+
<BaseSlider.Indicator data-slot="slider-indicator" className={indicatorClasses} />
|
|
241
|
+
</BaseSlider.Track>
|
|
242
|
+
{Array.from({ length: thumbCount }).map((_, i) => (
|
|
243
|
+
<SliderThumb
|
|
244
|
+
key={i}
|
|
245
|
+
index={i}
|
|
246
|
+
ariaLabel={resolveAriaLabel(i)}
|
|
247
|
+
tooltipVisibility={tooltipVisibility}
|
|
248
|
+
orientation={orientation}
|
|
249
|
+
changeVersion={tilts[i]?.version ?? 0}
|
|
250
|
+
direction={tilts[i]?.direction ?? 'up'}
|
|
251
|
+
dirSign={dirSign}
|
|
252
|
+
reduced={reduced}
|
|
253
|
+
/>
|
|
254
|
+
))}
|
|
255
|
+
</BaseSlider.Control>
|
|
256
|
+
</BaseSlider.Root>
|
|
257
|
+
</LazyMotion>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export { Slider }
|
|
262
|
+
export type { SliderProps, SliderTooltipVisibility }
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react'
|
|
2
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
3
|
+
import { axe } from 'vitest-axe'
|
|
4
|
+
import { Sparkline, SparklineChart, SparklineValue, SparklineLabel } from './sparkline'
|
|
5
|
+
import { DirectionProvider } from '../../providers/direction-provider'
|
|
6
|
+
|
|
7
|
+
const DATA = [4, 8, 6, 10, 7, 12]
|
|
8
|
+
const LABELS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
|
|
9
|
+
|
|
10
|
+
/** jsdom returns a 0×0 rect; give the chart a real width so pointer mapping runs. */
|
|
11
|
+
function stubRect(el: Element, width = 100) {
|
|
12
|
+
vi.spyOn(el, 'getBoundingClientRect').mockReturnValue({
|
|
13
|
+
x: 0,
|
|
14
|
+
y: 0,
|
|
15
|
+
left: 0,
|
|
16
|
+
top: 0,
|
|
17
|
+
right: width,
|
|
18
|
+
bottom: 48,
|
|
19
|
+
width,
|
|
20
|
+
height: 48,
|
|
21
|
+
toJSON: () => ({}),
|
|
22
|
+
} as DOMRect)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('Sparkline', () => {
|
|
26
|
+
it('renders a line path for the line variant', () => {
|
|
27
|
+
const { container } = render(
|
|
28
|
+
<Sparkline data={DATA}>
|
|
29
|
+
<SparklineChart variant="line" />
|
|
30
|
+
</Sparkline>,
|
|
31
|
+
)
|
|
32
|
+
expect(container.querySelector('[data-slot=sparkline-line]')).toBeInTheDocument()
|
|
33
|
+
expect(container.querySelector('[data-slot=sparkline-area]')).not.toBeInTheDocument()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('renders a baseline-anchored fill for the area variant', () => {
|
|
37
|
+
const { container } = render(
|
|
38
|
+
<Sparkline data={DATA}>
|
|
39
|
+
<SparklineChart variant="area" />
|
|
40
|
+
</Sparkline>,
|
|
41
|
+
)
|
|
42
|
+
expect(container.querySelector('[data-slot=sparkline-fill]')).toBeInTheDocument()
|
|
43
|
+
expect(container.querySelector('[data-slot=sparkline-baseline]')).toBeInTheDocument()
|
|
44
|
+
expect(container.querySelector('[data-slot=sparkline-line]')).toBeInTheDocument()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('line variant is stroke-only by default, gaining a gradient fill only when `fill` is set', () => {
|
|
48
|
+
const { container, rerender } = render(
|
|
49
|
+
<Sparkline data={DATA}>
|
|
50
|
+
<SparklineChart variant="line" />
|
|
51
|
+
</Sparkline>,
|
|
52
|
+
)
|
|
53
|
+
expect(container.querySelector('[data-slot=sparkline-fill]')).not.toBeInTheDocument()
|
|
54
|
+
expect(container.querySelector('[data-slot=sparkline-baseline]')).not.toBeInTheDocument()
|
|
55
|
+
|
|
56
|
+
rerender(
|
|
57
|
+
<Sparkline data={DATA}>
|
|
58
|
+
<SparklineChart variant="line" fill />
|
|
59
|
+
</Sparkline>,
|
|
60
|
+
)
|
|
61
|
+
expect(container.querySelector('[data-slot=sparkline-fill]')).toBeInTheDocument()
|
|
62
|
+
expect(container.querySelector('[data-slot=sparkline-baseline]')).not.toBeInTheDocument()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('renders one column per data point plus a baseline for the column variant', () => {
|
|
66
|
+
const { container } = render(
|
|
67
|
+
<Sparkline data={DATA}>
|
|
68
|
+
<SparklineChart variant="column" />
|
|
69
|
+
</Sparkline>,
|
|
70
|
+
)
|
|
71
|
+
expect(container.querySelectorAll('[data-slot=sparkline-column]')).toHaveLength(DATA.length)
|
|
72
|
+
expect(container.querySelector('[data-slot=sparkline-baseline]')).toBeInTheDocument()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('column highlight is gated on `indicator`, independent of the tooltip', () => {
|
|
76
|
+
const { container } = render(
|
|
77
|
+
<Sparkline data={DATA}>
|
|
78
|
+
<SparklineChart variant="column" indicator={false} tooltip />
|
|
79
|
+
</Sparkline>,
|
|
80
|
+
)
|
|
81
|
+
const chart = screen.getByRole('img')
|
|
82
|
+
stubRect(chart, 100)
|
|
83
|
+
fireEvent.pointerMove(chart, { clientX: 50 })
|
|
84
|
+
// Tooltip renders, but with indicator off no column is highlighted.
|
|
85
|
+
expect(container.querySelector('[data-slot=sparkline-tooltip]')).toBeInTheDocument()
|
|
86
|
+
expect(container.querySelector('[data-active]')).not.toBeInTheDocument()
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('columns pivot on the baseline: positive bars round the top, negatives round the bottom', () => {
|
|
90
|
+
const { container } = render(
|
|
91
|
+
<Sparkline data={[6, -4]}>
|
|
92
|
+
<SparklineChart variant="column" />
|
|
93
|
+
</Sparkline>,
|
|
94
|
+
)
|
|
95
|
+
const bars = container.querySelectorAll('[data-slot=sparkline-column]')
|
|
96
|
+
expect(bars[0]!.className).toContain('rounded-t-')
|
|
97
|
+
expect(bars[1]!.className).toContain('rounded-b-')
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('sets the accent color as a CSS variable on the root', () => {
|
|
101
|
+
render(
|
|
102
|
+
<Sparkline data={DATA} color="var(--color-success)" data-testid="root">
|
|
103
|
+
<SparklineChart />
|
|
104
|
+
</Sparkline>,
|
|
105
|
+
)
|
|
106
|
+
expect(screen.getByTestId('root').style.getPropertyValue('--sparkline-color')).toBe('var(--color-success)')
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('SparklineValue shows the last value by default, formatted', () => {
|
|
110
|
+
render(
|
|
111
|
+
<Sparkline data={DATA} format={{ style: 'currency', currency: 'USD', maximumFractionDigits: 0 }}>
|
|
112
|
+
<SparklineValue />
|
|
113
|
+
<SparklineChart />
|
|
114
|
+
</Sparkline>,
|
|
115
|
+
)
|
|
116
|
+
expect(screen.getByText('$12')).toBeInTheDocument()
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('SparklineLabel renders nothing without labels and the last label with them', () => {
|
|
120
|
+
const { rerender } = render(
|
|
121
|
+
<Sparkline data={DATA}>
|
|
122
|
+
<SparklineLabel data-testid="label" />
|
|
123
|
+
</Sparkline>,
|
|
124
|
+
)
|
|
125
|
+
expect(screen.queryByTestId('label')).not.toBeInTheDocument()
|
|
126
|
+
|
|
127
|
+
rerender(
|
|
128
|
+
<Sparkline data={DATA} labels={LABELS}>
|
|
129
|
+
<SparklineLabel data-testid="label" />
|
|
130
|
+
</Sparkline>,
|
|
131
|
+
)
|
|
132
|
+
expect(screen.getByTestId('label')).toHaveTextContent('Sat')
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('does not render the tooltip until hovered', () => {
|
|
136
|
+
const { container } = render(
|
|
137
|
+
<Sparkline data={DATA} labels={LABELS}>
|
|
138
|
+
<SparklineChart tooltip />
|
|
139
|
+
</Sparkline>,
|
|
140
|
+
)
|
|
141
|
+
expect(container.querySelector('[data-slot=sparkline-tooltip]')).not.toBeInTheDocument()
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
it('activates the nearest point on hover: updates value, tooltip, and onActiveChange', () => {
|
|
145
|
+
const onActiveChange = vi.fn()
|
|
146
|
+
const { container } = render(
|
|
147
|
+
<Sparkline data={DATA} labels={LABELS} onActiveChange={onActiveChange}>
|
|
148
|
+
<SparklineValue />
|
|
149
|
+
<SparklineChart tooltip />
|
|
150
|
+
</Sparkline>,
|
|
151
|
+
)
|
|
152
|
+
// Mount must NOT fire a phantom null before any interaction.
|
|
153
|
+
expect(onActiveChange).not.toHaveBeenCalled()
|
|
154
|
+
|
|
155
|
+
const chart = screen.getByRole('img')
|
|
156
|
+
stubRect(chart, 100)
|
|
157
|
+
|
|
158
|
+
// clientX 0 → t=0 → nearest index 0 (value 4).
|
|
159
|
+
fireEvent.pointerMove(chart, { clientX: 0 })
|
|
160
|
+
expect(onActiveChange).toHaveBeenLastCalledWith({ index: 0, value: 4, label: 'Mon' })
|
|
161
|
+
expect(container.querySelector('[data-slot=sparkline-value]')).toHaveTextContent('4')
|
|
162
|
+
expect(container.querySelector('[data-slot=sparkline-tooltip]')).toHaveTextContent('Mon')
|
|
163
|
+
|
|
164
|
+
// clientX 100 → t=1 → last index 5 (value 12).
|
|
165
|
+
fireEvent.pointerMove(chart, { clientX: 100 })
|
|
166
|
+
expect(onActiveChange).toHaveBeenLastCalledWith({ index: 5, value: 12, label: 'Sat' })
|
|
167
|
+
|
|
168
|
+
fireEvent.pointerLeave(chart)
|
|
169
|
+
expect(onActiveChange).toHaveBeenLastCalledWith(null)
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it('activates on a stationary touch tap and clears when the finger lifts', () => {
|
|
173
|
+
const onActiveChange = vi.fn()
|
|
174
|
+
render(
|
|
175
|
+
<Sparkline data={DATA} onActiveChange={onActiveChange}>
|
|
176
|
+
<SparklineChart tooltip />
|
|
177
|
+
</Sparkline>,
|
|
178
|
+
)
|
|
179
|
+
const chart = screen.getByRole('img')
|
|
180
|
+
stubRect(chart, 100)
|
|
181
|
+
|
|
182
|
+
// A touch tap fires pointerdown without a preceding move — it must activate immediately.
|
|
183
|
+
fireEvent.pointerDown(chart, { clientX: 100, pointerType: 'touch' })
|
|
184
|
+
expect(onActiveChange).toHaveBeenLastCalledWith({ index: 5, value: 12, label: undefined })
|
|
185
|
+
|
|
186
|
+
// Lifting the finger dismisses (there is no pointerleave on touch).
|
|
187
|
+
fireEvent.pointerUp(chart, { pointerType: 'touch' })
|
|
188
|
+
expect(onActiveChange).toHaveBeenLastCalledWith(null)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it('keeps a mouse reading visible after click (pointerup does not clear for mouse)', () => {
|
|
192
|
+
const onActiveChange = vi.fn()
|
|
193
|
+
render(
|
|
194
|
+
<Sparkline data={DATA} onActiveChange={onActiveChange}>
|
|
195
|
+
<SparklineChart tooltip />
|
|
196
|
+
</Sparkline>,
|
|
197
|
+
)
|
|
198
|
+
const chart = screen.getByRole('img')
|
|
199
|
+
stubRect(chart, 100)
|
|
200
|
+
|
|
201
|
+
fireEvent.pointerMove(chart, { clientX: 0, pointerType: 'mouse' })
|
|
202
|
+
fireEvent.pointerUp(chart, { pointerType: 'mouse' })
|
|
203
|
+
expect(onActiveChange).toHaveBeenLastCalledWith({ index: 0, value: 4, label: undefined })
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
it('mirrors the active index under RTL', () => {
|
|
207
|
+
const onActiveChange = vi.fn()
|
|
208
|
+
render(
|
|
209
|
+
<DirectionProvider dir="rtl">
|
|
210
|
+
<Sparkline data={DATA} onActiveChange={onActiveChange}>
|
|
211
|
+
<SparklineChart />
|
|
212
|
+
</Sparkline>
|
|
213
|
+
</DirectionProvider>,
|
|
214
|
+
)
|
|
215
|
+
const chart = screen.getByRole('img')
|
|
216
|
+
stubRect(chart, 100)
|
|
217
|
+
// Pointer at the left edge maps to the last index when mirrored.
|
|
218
|
+
fireEvent.pointerMove(chart, { clientX: 0 })
|
|
219
|
+
expect(onActiveChange).toHaveBeenLastCalledWith(expect.objectContaining({ index: DATA.length - 1 }))
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
it('forwards className onto the chart wrapper', () => {
|
|
223
|
+
render(
|
|
224
|
+
<Sparkline data={DATA}>
|
|
225
|
+
<SparklineChart className="custom-chart" aria-label="Revenue" />
|
|
226
|
+
</Sparkline>,
|
|
227
|
+
)
|
|
228
|
+
expect(screen.getByRole('img', { name: 'Revenue' }).className).toContain('custom-chart')
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
it('renders nothing for an empty dataset', () => {
|
|
232
|
+
const { container } = render(
|
|
233
|
+
<Sparkline data={[]}>
|
|
234
|
+
<SparklineChart />
|
|
235
|
+
</Sparkline>,
|
|
236
|
+
)
|
|
237
|
+
expect(container.querySelector('[data-slot=sparkline-svg]')).not.toBeInTheDocument()
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
it('has no accessibility violations', async () => {
|
|
241
|
+
const { container } = render(
|
|
242
|
+
<Sparkline data={DATA} labels={LABELS}>
|
|
243
|
+
<SparklineValue />
|
|
244
|
+
<SparklineChart variant="area" aria-label="Weekly revenue" />
|
|
245
|
+
</Sparkline>,
|
|
246
|
+
)
|
|
247
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
248
|
+
})
|
|
249
|
+
})
|