@appica/ui-react 1.0.0 → 1.2.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/CHANGELOG.md +72 -0
- package/README.md +47 -5
- package/agent-rules.md +41 -0
- package/appica.css +7 -0
- package/dist/components/accordion/accordion.d.ts +24 -0
- package/dist/components/accordion/accordion.d.ts.map +1 -1
- package/dist/components/accordion/accordion.js +2 -1
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert/alert.d.ts +30 -2
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/alert.js +2 -1
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.d.ts +12 -2
- package/dist/components/alert-dialog/alert-dialog.d.ts.map +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +10 -5
- package/dist/components/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/autocomplete/autocomplete.d.ts +21 -1
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/autocomplete.js +3 -2
- package/dist/components/autocomplete/autocomplete.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +17 -1
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/avatar.js +2 -1
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/background-pattern/background-pattern-interactive.d.ts +2 -1
- package/dist/components/background-pattern/background-pattern-interactive.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern-interactive.js +4 -2
- package/dist/components/background-pattern/background-pattern-interactive.js.map +1 -1
- package/dist/components/background-pattern/background-pattern-shared.d.ts +3 -2
- package/dist/components/background-pattern/background-pattern-shared.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern-shared.js +48 -16
- package/dist/components/background-pattern/background-pattern-shared.js.map +1 -1
- package/dist/components/background-pattern/background-pattern.d.ts +13 -5
- package/dist/components/background-pattern/background-pattern.d.ts.map +1 -1
- package/dist/components/background-pattern/background-pattern.js +13 -4
- package/dist/components/background-pattern/background-pattern.js.map +1 -1
- package/dist/components/background-pattern/index.js +1 -0
- package/dist/components/background-pattern/index.js.map +1 -1
- package/dist/components/badge/badge.d.ts +13 -3
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/badge.js +2 -1
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/border-beam/border-beam.d.ts +52 -0
- package/dist/components/border-beam/border-beam.d.ts.map +1 -0
- package/dist/components/border-beam/border-beam.js +68 -0
- package/dist/components/border-beam/border-beam.js.map +1 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +8 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js +2 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button-variants.d.ts +2 -2
- package/dist/components/button/button-variants.js +2 -1
- package/dist/components/button/button-variants.js.map +1 -1
- package/dist/components/button/button.d.ts +11 -1
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +2 -1
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/index.js +1 -0
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button-group/button-group-context.js +1 -0
- package/dist/components/button-group/button-group-context.js.map +1 -1
- package/dist/components/button-group/button-group.d.ts +10 -0
- package/dist/components/button-group/button-group.d.ts.map +1 -1
- package/dist/components/button-group/button-group.js +2 -1
- package/dist/components/button-group/button-group.js.map +1 -1
- package/dist/components/calendar/calendar.d.ts +5 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -1
- package/dist/components/calendar/calendar.js +2 -1
- package/dist/components/calendar/calendar.js.map +1 -1
- package/dist/components/card/card.d.ts +43 -0
- package/dist/components/card/card.d.ts.map +1 -0
- package/dist/components/card/card.js +104 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/carousel/carousel.d.ts +106 -6
- package/dist/components/carousel/carousel.d.ts.map +1 -1
- package/dist/components/carousel/carousel.js +180 -5
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +2 -1
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.d.ts +4 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts.map +1 -1
- package/dist/components/checkbox-group/checkbox-group.js +2 -1
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
- package/dist/components/chip/chip.d.ts +33 -1
- package/dist/components/chip/chip.d.ts.map +1 -1
- package/dist/components/chip/chip.js +2 -1
- package/dist/components/chip/chip.js.map +1 -1
- package/dist/components/collapsible/collapsible.js +2 -1
- package/dist/components/collapsible/collapsible.js.map +1 -1
- package/dist/components/color-area/color-area.d.ts +53 -0
- package/dist/components/color-area/color-area.d.ts.map +1 -0
- package/dist/components/color-area/color-area.js +246 -0
- package/dist/components/color-area/color-area.js.map +1 -0
- package/dist/components/color-picker/color-picker.d.ts +152 -0
- package/dist/components/color-picker/color-picker.d.ts.map +1 -0
- package/dist/components/color-picker/color-picker.js +328 -0
- package/dist/components/color-picker/color-picker.js.map +1 -0
- package/dist/components/color-slider/color-slider.d.ts +48 -0
- package/dist/components/color-slider/color-slider.d.ts.map +1 -0
- package/dist/components/color-slider/color-slider.js +217 -0
- package/dist/components/color-slider/color-slider.js.map +1 -0
- package/dist/components/color-swatch/color-swatch.d.ts +47 -0
- package/dist/components/color-swatch/color-swatch.d.ts.map +1 -0
- package/dist/components/color-swatch/color-swatch.js +67 -0
- package/dist/components/color-swatch/color-swatch.js.map +1 -0
- package/dist/components/color-swatch-picker/color-swatch-picker.d.ts +62 -0
- package/dist/components/color-swatch-picker/color-swatch-picker.d.ts.map +1 -0
- package/dist/components/color-swatch-picker/color-swatch-picker.js +203 -0
- package/dist/components/color-swatch-picker/color-swatch-picker.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +25 -1
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/combobox.js +3 -2
- package/dist/components/combobox/combobox.js.map +1 -1
- package/dist/components/context-menu/context-menu.d.ts +7 -1
- package/dist/components/context-menu/context-menu.d.ts.map +1 -1
- package/dist/components/context-menu/context-menu.js +11 -5
- package/dist/components/context-menu/context-menu.js.map +1 -1
- package/dist/components/copy-button/copy-button.d.ts +18 -1
- package/dist/components/copy-button/copy-button.d.ts.map +1 -1
- package/dist/components/copy-button/copy-button.js +6 -5
- package/dist/components/copy-button/copy-button.js.map +1 -1
- package/dist/components/countdown/countdown.d.ts +14 -0
- package/dist/components/countdown/countdown.d.ts.map +1 -1
- package/dist/components/countdown/countdown.js +2 -1
- package/dist/components/countdown/countdown.js.map +1 -1
- package/dist/components/date-field/date-field.d.ts +35 -0
- package/dist/components/date-field/date-field.d.ts.map +1 -1
- package/dist/components/date-field/date-field.js +2 -1
- package/dist/components/date-field/date-field.js.map +1 -1
- package/dist/components/date-picker/date-picker.d.ts +94 -0
- package/dist/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/date-picker.js +2 -1
- package/dist/components/date-picker/date-picker.js.map +1 -1
- package/dist/components/dialog/dialog.d.ts +20 -2
- package/dist/components/dialog/dialog.d.ts.map +1 -1
- package/dist/components/dialog/dialog.js +9 -4
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/drawer/drawer.d.ts +22 -2
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/drawer.js +14 -7
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +7 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +11 -5
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/field/field.js +2 -1
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/fieldset/fieldset.js +2 -1
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/form/form.js +1 -0
- package/dist/components/form/form.js.map +1 -1
- package/dist/components/gradient-glow/gradient-glow.d.ts +51 -1
- package/dist/components/gradient-glow/gradient-glow.d.ts.map +1 -1
- package/dist/components/gradient-glow/gradient-glow.js +5 -3
- package/dist/components/gradient-glow/gradient-glow.js.map +1 -1
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/input-variants.d.ts +1 -1
- package/dist/components/input/input-variants.js +2 -1
- package/dist/components/input/input-variants.js.map +1 -1
- package/dist/components/input/input.d.ts +21 -1
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +4 -3
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/kbd/kbd.d.ts +8 -0
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/kbd/kbd.js +2 -1
- package/dist/components/kbd/kbd.js.map +1 -1
- package/dist/components/loader/loader.d.ts +8 -0
- package/dist/components/loader/loader.d.ts.map +1 -1
- package/dist/components/loader/loader.js +2 -1
- package/dist/components/loader/loader.js.map +1 -1
- package/dist/components/menubar/menubar.d.ts +8 -0
- package/dist/components/menubar/menubar.d.ts.map +1 -1
- package/dist/components/menubar/menubar.js +2 -1
- package/dist/components/menubar/menubar.js.map +1 -1
- package/dist/components/meter/meter.d.ts +4 -0
- package/dist/components/meter/meter.d.ts.map +1 -1
- package/dist/components/meter/meter.js +2 -1
- package/dist/components/meter/meter.js.map +1 -1
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/index.js.map +1 -1
- package/dist/components/navigation/navigation-context.js +1 -0
- package/dist/components/navigation/navigation-context.js.map +1 -1
- package/dist/components/navigation/navigation-link-variants.d.ts +2 -2
- package/dist/components/navigation/navigation-link-variants.js +2 -1
- package/dist/components/navigation/navigation-link-variants.js.map +1 -1
- package/dist/components/navigation/navigation-link.d.ts +22 -0
- package/dist/components/navigation/navigation-link.d.ts.map +1 -1
- package/dist/components/navigation/navigation-link.js +2 -1
- package/dist/components/navigation/navigation-link.js.map +1 -1
- package/dist/components/navigation/navigation.d.ts +12 -0
- package/dist/components/navigation/navigation.d.ts.map +1 -1
- package/dist/components/navigation/navigation.js +2 -1
- package/dist/components/navigation/navigation.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.d.ts +33 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.js +2 -1
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/number-field/number-field.d.ts +14 -0
- package/dist/components/number-field/number-field.d.ts.map +1 -1
- package/dist/components/number-field/number-field.js +2 -1
- package/dist/components/number-field/number-field.js.map +1 -1
- package/dist/components/otp-field/otp-field.d.ts +9 -0
- package/dist/components/otp-field/otp-field.d.ts.map +1 -1
- package/dist/components/otp-field/otp-field.js +2 -1
- package/dist/components/otp-field/otp-field.js.map +1 -1
- package/dist/components/pagination/pagination.d.ts +16 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -1
- package/dist/components/pagination/pagination.js +2 -1
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/popover/popover.d.ts +5 -1
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/popover/popover.js +3 -2
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/preview-card/preview-card.d.ts +5 -1
- package/dist/components/preview-card/preview-card.d.ts.map +1 -1
- package/dist/components/preview-card/preview-card.js +3 -2
- package/dist/components/preview-card/preview-card.js.map +1 -1
- package/dist/components/progress/progress.d.ts +17 -0
- package/dist/components/progress/progress.d.ts.map +1 -1
- package/dist/components/progress/progress.js +2 -1
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.js +2 -1
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radio-group/radio-group.d.ts +4 -0
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/radio-group/radio-group.js +2 -1
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/rating/rating.d.ts +79 -0
- package/dist/components/rating/rating.d.ts.map +1 -0
- package/dist/components/rating/rating.js +302 -0
- package/dist/components/rating/rating.js.map +1 -0
- package/dist/components/scroll-area/scroll-area.d.ts +13 -0
- package/dist/components/scroll-area/scroll-area.d.ts.map +1 -1
- package/dist/components/scroll-area/scroll-area.js +2 -1
- package/dist/components/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/select/select.d.ts +20 -1
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +3 -2
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/separator/separator.d.ts +4 -0
- package/dist/components/separator/separator.d.ts.map +1 -1
- package/dist/components/separator/separator.js +2 -1
- package/dist/components/separator/separator.js.map +1 -1
- package/dist/components/skeleton/skeleton.d.ts +4 -0
- package/dist/components/skeleton/skeleton.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton.js +2 -1
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/slider/slider.d.ts +5 -0
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/slider/slider.js +2 -1
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/sparkline/sparkline.d.ts +44 -0
- package/dist/components/sparkline/sparkline.d.ts.map +1 -1
- package/dist/components/sparkline/sparkline.js +2 -1
- package/dist/components/sparkline/sparkline.js.map +1 -1
- package/dist/components/spinner/spinner.d.ts +8 -0
- package/dist/components/spinner/spinner.d.ts.map +1 -1
- package/dist/components/spinner/spinner.js +2 -1
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/components/switch/switch.d.ts +19 -15
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/switch/switch.js +2 -1
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/table/table.d.ts +28 -0
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +2 -1
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.d.ts +32 -2
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tabs/tabs.js +2 -1
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/text-animate/text-animate.d.ts +31 -0
- package/dist/components/text-animate/text-animate.d.ts.map +1 -1
- package/dist/components/text-animate/text-animate.js +27 -9
- package/dist/components/text-animate/text-animate.js.map +1 -1
- package/dist/components/textarea/textarea.d.ts +15 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -1
- package/dist/components/textarea/textarea.js +2 -1
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/thumbnail/thumbnail.d.ts +22 -2
- package/dist/components/thumbnail/thumbnail.d.ts.map +1 -1
- package/dist/components/thumbnail/thumbnail.js +2 -1
- package/dist/components/thumbnail/thumbnail.js.map +1 -1
- package/dist/components/time-field/time-field.d.ts +35 -0
- package/dist/components/time-field/time-field.d.ts.map +1 -1
- package/dist/components/time-field/time-field.js +2 -1
- package/dist/components/time-field/time-field.js.map +1 -1
- package/dist/components/toast/toast.d.ts +18 -0
- package/dist/components/toast/toast.d.ts.map +1 -1
- package/dist/components/toast/toast.js +2 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toc/toc.d.ts +10 -0
- package/dist/components/toc/toc.d.ts.map +1 -1
- package/dist/components/toc/toc.js +2 -1
- package/dist/components/toc/toc.js.map +1 -1
- package/dist/components/toggle/toggle.js +1 -0
- package/dist/components/toggle/toggle.js.map +1 -1
- package/dist/components/toggle-group/toggle-group.js +2 -1
- package/dist/components/toggle-group/toggle-group.js.map +1 -1
- package/dist/components/toolbar/toolbar.js +2 -1
- package/dist/components/toolbar/toolbar.js.map +1 -1
- package/dist/components/tooltip/tooltip.d.ts +5 -1
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tooltip/tooltip.js +3 -2
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/hooks/use-direction.js +1 -0
- package/dist/hooks/use-direction.js.map +1 -1
- package/dist/hooks/use-dismissible.d.ts +4 -0
- package/dist/hooks/use-dismissible.d.ts.map +1 -1
- package/dist/hooks/use-dismissible.js +1 -0
- package/dist/hooks/use-dismissible.js.map +1 -1
- package/dist/hooks/use-local-storage.js +1 -0
- package/dist/hooks/use-local-storage.js.map +1 -1
- package/dist/hooks/use-media-query.js +1 -0
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-reduced-motion.d.ts +1 -1
- package/dist/hooks/use-reduced-motion.js +1 -0
- package/dist/hooks/use-reduced-motion.js.map +1 -1
- package/dist/hooks/use-theme.d.ts +1 -1
- package/dist/hooks/use-theme.js +1 -0
- package/dist/hooks/use-theme.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/color-control.d.ts +75 -0
- package/dist/internal/color-control.d.ts.map +1 -0
- package/dist/internal/color-control.js +79 -0
- package/dist/internal/color-control.js.map +1 -0
- package/dist/internal/color-math.d.ts +9 -0
- package/dist/internal/color-math.d.ts.map +1 -0
- package/dist/internal/color-math.js +35 -0
- package/dist/internal/color-math.js.map +1 -0
- package/dist/internal/color-picker-context.d.ts +34 -0
- package/dist/internal/color-picker-context.d.ts.map +1 -0
- package/dist/internal/color-picker-context.js +42 -0
- package/dist/internal/color-picker-context.js.map +1 -0
- package/dist/{floating.d.ts → internal/floating.d.ts} +3 -3
- package/dist/internal/floating.d.ts.map +1 -0
- package/dist/{floating.js → internal/floating.js} +1 -0
- package/dist/internal/floating.js.map +1 -0
- package/dist/{modal.d.ts → internal/modal.d.ts} +2 -2
- package/dist/internal/modal.d.ts.map +1 -0
- package/dist/{modal.js → internal/modal.js} +1 -0
- package/dist/internal/modal.js.map +1 -0
- package/dist/{utils.d.ts → internal/utils.d.ts} +2 -2
- package/dist/internal/utils.d.ts.map +1 -0
- package/dist/{utils.js → internal/utils.js} +1 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/lib/color.d.ts +95 -0
- package/dist/lib/color.d.ts.map +1 -0
- package/dist/lib/color.js +329 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/providers/direction-provider.d.ts +4 -4
- package/dist/providers/direction-provider.d.ts.map +1 -1
- package/dist/providers/direction-provider.js +1 -0
- package/dist/providers/direction-provider.js.map +1 -1
- package/dist/providers/reduced-motion-provider.d.ts +4 -8
- package/dist/providers/reduced-motion-provider.d.ts.map +1 -1
- package/dist/providers/reduced-motion-provider.js +1 -0
- package/dist/providers/reduced-motion-provider.js.map +1 -1
- package/dist/providers/theme-provider/index.js +1 -0
- package/dist/providers/theme-provider/index.js.map +1 -1
- package/dist/providers/theme-provider/theme-provider.d.ts +28 -12
- package/dist/providers/theme-provider/theme-provider.d.ts.map +1 -1
- package/dist/providers/theme-provider/theme-provider.js +1 -0
- package/dist/providers/theme-provider/theme-provider.js.map +1 -1
- package/dist/providers/theme-provider/theme-script.js +1 -0
- package/dist/providers/theme-provider/theme-script.js.map +1 -1
- package/package.json +91 -31
- package/src/components/accordion/accordion.tsx +25 -1
- package/src/components/alert/alert.tsx +30 -2
- package/src/components/alert-dialog/alert-dialog.test.tsx +34 -2
- package/src/components/alert-dialog/alert-dialog.tsx +21 -5
- package/src/components/autocomplete/autocomplete.test.tsx +1 -1
- package/src/components/autocomplete/autocomplete.tsx +22 -2
- package/src/components/avatar/avatar.test.tsx +2 -2
- package/src/components/avatar/avatar.tsx +17 -1
- package/src/components/background-pattern/background-pattern-interactive.tsx +4 -2
- package/src/components/background-pattern/background-pattern-shared.tsx +56 -19
- package/src/components/background-pattern/background-pattern.test.tsx +36 -1
- package/src/components/background-pattern/background-pattern.tsx +24 -9
- package/src/components/badge/badge.tsx +14 -2
- package/src/components/border-beam/border-beam.test.tsx +91 -0
- package/src/components/border-beam/border-beam.tsx +131 -0
- package/src/components/breadcrumb/breadcrumb.tsx +9 -1
- package/src/components/button/button-variants.ts +1 -1
- package/src/components/button/button.tsx +13 -2
- package/src/components/button-group/button-group.tsx +11 -1
- package/src/components/calendar/calendar.tsx +6 -1
- package/src/components/card/card.test.tsx +98 -0
- package/src/components/card/card.tsx +154 -0
- package/src/components/carousel/carousel.test.tsx +179 -0
- package/src/components/carousel/carousel.tsx +329 -6
- package/src/components/checkbox/checkbox.test.tsx +2 -2
- package/src/components/checkbox/checkbox.tsx +1 -1
- package/src/components/checkbox-group/checkbox-group.tsx +5 -1
- package/src/components/chip/chip.tsx +33 -1
- package/src/components/collapsible/collapsible.tsx +1 -1
- package/src/components/color-area/color-area.test.tsx +242 -0
- package/src/components/color-area/color-area.tsx +356 -0
- package/src/components/color-picker/color-picker.test.tsx +286 -0
- package/src/components/color-picker/color-picker.tsx +546 -0
- package/src/components/color-slider/color-slider.test.tsx +222 -0
- package/src/components/color-slider/color-slider.tsx +330 -0
- package/src/components/color-swatch/color-swatch.test.tsx +117 -0
- package/src/components/color-swatch/color-swatch.tsx +119 -0
- package/src/components/color-swatch-picker/color-swatch-picker.test.tsx +287 -0
- package/src/components/color-swatch-picker/color-swatch-picker.tsx +327 -0
- package/src/components/combobox/combobox.test.tsx +1 -1
- package/src/components/combobox/combobox.tsx +26 -2
- package/src/components/context-menu/context-menu.test.tsx +28 -0
- package/src/components/context-menu/context-menu.tsx +16 -5
- package/src/components/copy-button/copy-button.test.tsx +14 -1
- package/src/components/copy-button/copy-button.tsx +27 -6
- package/src/components/countdown/countdown.tsx +15 -1
- package/src/components/date-field/date-field.tsx +36 -1
- package/src/components/date-picker/date-picker.test.tsx +1 -1
- package/src/components/date-picker/date-picker.tsx +95 -1
- package/src/components/dialog/dialog.test.tsx +30 -1
- package/src/components/dialog/dialog.tsx +28 -6
- package/src/components/drawer/drawer.test.tsx +32 -1
- package/src/components/drawer/drawer.tsx +37 -7
- package/src/components/dropdown-menu/dropdown-menu.test.tsx +28 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +16 -5
- package/src/components/field/field.tsx +1 -1
- package/src/components/fieldset/fieldset.tsx +1 -1
- package/src/components/gradient-glow/gradient-glow.test.tsx +7 -1
- package/src/components/gradient-glow/gradient-glow.tsx +64 -11
- package/src/components/input/input-variants.ts +1 -1
- package/src/components/input/input.tsx +24 -4
- package/src/components/kbd/kbd.tsx +9 -1
- package/src/components/loader/loader.tsx +9 -1
- package/src/components/menubar/menubar.tsx +9 -1
- package/src/components/meter/meter.tsx +5 -1
- package/src/components/navigation/navigation-link-variants.ts +1 -1
- package/src/components/navigation/navigation-link.tsx +23 -1
- package/src/components/navigation/navigation.tsx +23 -3
- package/src/components/navigation-menu/navigation-menu.tsx +34 -1
- package/src/components/number-field/number-field.tsx +15 -1
- package/src/components/otp-field/otp-field.tsx +10 -1
- package/src/components/pagination/pagination.tsx +17 -1
- package/src/components/popover/popover.test.tsx +1 -1
- package/src/components/popover/popover.tsx +6 -2
- package/src/components/preview-card/preview-card.tsx +6 -2
- package/src/components/progress/progress.tsx +18 -1
- package/src/components/radio/radio.test.tsx +1 -1
- package/src/components/radio/radio.tsx +1 -1
- package/src/components/radio-group/radio-group.test.tsx +1 -1
- package/src/components/radio-group/radio-group.tsx +5 -1
- package/src/components/rating/rating.test.tsx +246 -0
- package/src/components/rating/rating.tsx +457 -0
- package/src/components/scroll-area/scroll-area.test.tsx +1 -1
- package/src/components/scroll-area/scroll-area.tsx +14 -1
- package/src/components/select/select.tsx +21 -2
- package/src/components/separator/separator.tsx +5 -1
- package/src/components/skeleton/skeleton.tsx +5 -1
- package/src/components/slider/slider.test.tsx +1 -1
- package/src/components/slider/slider.tsx +6 -1
- package/src/components/sparkline/sparkline.test.tsx +1 -1
- package/src/components/sparkline/sparkline.tsx +45 -1
- package/src/components/spinner/spinner.tsx +9 -1
- package/src/components/switch/switch.test.tsx +1 -1
- package/src/components/switch/switch.tsx +5 -1
- package/src/components/table/table.tsx +29 -1
- package/src/components/tabs/tabs.test.tsx +1 -1
- package/src/components/tabs/tabs.tsx +33 -2
- package/src/components/text-animate/text-animate.test.tsx +62 -0
- package/src/components/text-animate/text-animate.tsx +77 -9
- package/src/components/textarea/textarea.tsx +16 -1
- package/src/components/thumbnail/thumbnail.test.tsx +1 -1
- package/src/components/thumbnail/thumbnail.tsx +21 -1
- package/src/components/time-field/time-field.tsx +36 -1
- package/src/components/toast/toast.test.tsx +1 -1
- package/src/components/toast/toast.tsx +19 -1
- package/src/components/toc/toc.tsx +11 -1
- package/src/components/toggle/toggle.test.tsx +1 -1
- package/src/components/toggle-group/toggle-group.tsx +1 -1
- package/src/components/toolbar/toolbar.tsx +1 -1
- package/src/components/tooltip/tooltip.test.tsx +1 -1
- package/src/components/tooltip/tooltip.tsx +6 -2
- package/src/hooks/use-dismissible.ts +4 -0
- package/src/hooks/use-local-storage.ts +3 -3
- package/src/hooks/use-reduced-motion.ts +1 -1
- package/src/hooks/use-theme.ts +1 -1
- package/src/index.ts +11 -2
- package/src/internal/color-control.ts +178 -0
- package/src/internal/color-math.ts +44 -0
- package/src/internal/color-picker-context.ts +80 -0
- package/src/{floating.ts → internal/floating.ts} +3 -3
- package/src/{modal.ts → internal/modal.ts} +3 -3
- package/src/lib/color.test.ts +178 -0
- package/src/lib/color.ts +471 -0
- package/src/providers/direction-provider.tsx +4 -4
- package/src/providers/reduced-motion-provider.tsx +4 -8
- package/src/providers/theme-provider/theme-provider.tsx +28 -12
- package/src/providers/theme-provider/theme-script.tsx +2 -2
- package/src/test/setup.ts +1 -1
- package/styles.css +28 -4
- package/dist/floating.d.ts.map +0 -1
- package/dist/floating.js.map +0 -1
- package/dist/modal.d.ts.map +0 -1
- package/dist/modal.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
- /package/src/{floating.test.ts → internal/floating.test.ts} +0 -0
- /package/src/{modal.test.ts → internal/modal.test.ts} +0 -0
- /package/src/{utils.test.tsx → internal/utils.test.tsx} +0 -0
- /package/src/{utils.ts → internal/utils.ts} +0 -0
|
@@ -91,6 +91,8 @@ import {
|
|
|
91
91
|
Carousel,
|
|
92
92
|
CarouselContent,
|
|
93
93
|
CarouselSlide,
|
|
94
|
+
CarouselThumbs,
|
|
95
|
+
CarouselThumb,
|
|
94
96
|
CarouselPrev,
|
|
95
97
|
CarouselNext,
|
|
96
98
|
CarouselPagination,
|
|
@@ -99,8 +101,12 @@ import {
|
|
|
99
101
|
useLinkedCarousels,
|
|
100
102
|
type CarouselApi,
|
|
101
103
|
type CarouselProps,
|
|
104
|
+
type CarouselThumbsProps,
|
|
102
105
|
} from './carousel'
|
|
103
106
|
|
|
107
|
+
// eslint-disable-next-line import/first
|
|
108
|
+
import useEmblaCarousel from 'embla-carousel-react'
|
|
109
|
+
|
|
104
110
|
// eslint-disable-next-line import/first
|
|
105
111
|
import { renderHook } from '@testing-library/react'
|
|
106
112
|
|
|
@@ -128,6 +134,8 @@ beforeEach(() => {
|
|
|
128
134
|
stubApi.slidesInView.mockReturnValue([0])
|
|
129
135
|
stubApi.scrollProgress.mockReturnValue(0)
|
|
130
136
|
stubApi.plugins.mockReturnValue({})
|
|
137
|
+
stubApi.slideNodes.mockReturnValue([])
|
|
138
|
+
stubApi.containerNode.mockReturnValue(undefined)
|
|
131
139
|
})
|
|
132
140
|
|
|
133
141
|
describe('Carousel', () => {
|
|
@@ -349,6 +357,133 @@ describe('CarouselPagination', () => {
|
|
|
349
357
|
})
|
|
350
358
|
})
|
|
351
359
|
|
|
360
|
+
describe('CarouselThumbs / CarouselThumb', () => {
|
|
361
|
+
function WithThumbs(props?: Partial<CarouselThumbsProps>) {
|
|
362
|
+
return (
|
|
363
|
+
<Carousel>
|
|
364
|
+
<CarouselContent>
|
|
365
|
+
<CarouselSlide>Slide 1</CarouselSlide>
|
|
366
|
+
<CarouselSlide>Slide 2</CarouselSlide>
|
|
367
|
+
<CarouselSlide>Slide 3</CarouselSlide>
|
|
368
|
+
</CarouselContent>
|
|
369
|
+
<CarouselThumbs {...props}>
|
|
370
|
+
<CarouselThumb>
|
|
371
|
+
<img src="/1.jpg" alt="" />
|
|
372
|
+
</CarouselThumb>
|
|
373
|
+
<CarouselThumb>
|
|
374
|
+
<img src="/2.jpg" alt="" />
|
|
375
|
+
</CarouselThumb>
|
|
376
|
+
<CarouselThumb>
|
|
377
|
+
<img src="/3.jpg" alt="" />
|
|
378
|
+
</CarouselThumb>
|
|
379
|
+
</CarouselThumbs>
|
|
380
|
+
</Carousel>
|
|
381
|
+
)
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
it('renders a labeled rail of thumbnails, one per slide', () => {
|
|
385
|
+
const { container } = render(<WithThumbs />)
|
|
386
|
+
const rail = container.querySelector('[data-slot="carousel-thumbs"]') as HTMLElement
|
|
387
|
+
expect(rail).not.toBeNull()
|
|
388
|
+
expect(rail.getAttribute('role')).toBe('group')
|
|
389
|
+
expect(rail.getAttribute('aria-label')).toBe('Choose slide to display')
|
|
390
|
+
expect(rail.getAttribute('aria-roledescription')).toBeNull()
|
|
391
|
+
expect(rail.querySelectorAll('[data-slot="carousel-thumb"]')).toHaveLength(3)
|
|
392
|
+
expect(screen.getByRole('button', { name: 'Go to slide 2' })).toBeInTheDocument()
|
|
393
|
+
})
|
|
394
|
+
|
|
395
|
+
it('marks the thumbnail of the selected slide as current', () => {
|
|
396
|
+
const { container } = render(<WithThumbs />)
|
|
397
|
+
const thumbs = container.querySelectorAll('[data-slot="carousel-thumb"]')
|
|
398
|
+
expect(thumbs[0]).toHaveAttribute('data-active')
|
|
399
|
+
expect(thumbs[0]).toHaveAttribute('aria-current', 'true')
|
|
400
|
+
expect(thumbs[1]).not.toHaveAttribute('data-active')
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
it('navigates the carousel to the clicked thumbnail', async () => {
|
|
404
|
+
const user = userEvent.setup()
|
|
405
|
+
render(<WithThumbs />)
|
|
406
|
+
await user.click(screen.getByRole('button', { name: 'Go to slide 3' }))
|
|
407
|
+
expect(stubApi.goTo).toHaveBeenCalledWith(2)
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
it('honors an explicit index over the thumbnail position', async () => {
|
|
411
|
+
const user = userEvent.setup()
|
|
412
|
+
render(
|
|
413
|
+
<Carousel>
|
|
414
|
+
<CarouselContent>
|
|
415
|
+
<CarouselSlide>Slide 1</CarouselSlide>
|
|
416
|
+
</CarouselContent>
|
|
417
|
+
<CarouselThumbs>
|
|
418
|
+
<CarouselThumb index={5}>Five</CarouselThumb>
|
|
419
|
+
</CarouselThumbs>
|
|
420
|
+
</Carousel>,
|
|
421
|
+
)
|
|
422
|
+
await user.click(screen.getByRole('button', { name: 'Go to slide 6' }))
|
|
423
|
+
expect(stubApi.goTo).toHaveBeenCalledWith(5)
|
|
424
|
+
})
|
|
425
|
+
|
|
426
|
+
it('fires the consumer onClick alongside the internal navigation', async () => {
|
|
427
|
+
const user = userEvent.setup()
|
|
428
|
+
const onClick = vi.fn()
|
|
429
|
+
render(
|
|
430
|
+
<Carousel>
|
|
431
|
+
<CarouselContent>
|
|
432
|
+
<CarouselSlide>Slide 1</CarouselSlide>
|
|
433
|
+
</CarouselContent>
|
|
434
|
+
<CarouselThumbs>
|
|
435
|
+
<CarouselThumb onClick={onClick}>One</CarouselThumb>
|
|
436
|
+
</CarouselThumbs>
|
|
437
|
+
</Carousel>,
|
|
438
|
+
)
|
|
439
|
+
await user.click(screen.getByRole('button', { name: 'Go to slide 1' }))
|
|
440
|
+
expect(onClick).toHaveBeenCalled()
|
|
441
|
+
expect(stubApi.goTo).toHaveBeenCalledWith(0)
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
it('lays the rail out on the vertical axis when asked', () => {
|
|
445
|
+
const { container } = render(<WithThumbs orientation="vertical" />)
|
|
446
|
+
const rail = container.querySelector('[data-slot="carousel-thumbs"]') as HTMLElement
|
|
447
|
+
expect(rail.getAttribute('data-orientation')).toBe('vertical')
|
|
448
|
+
const track = rail.querySelector('[data-slot="carousel-content"]') as HTMLElement
|
|
449
|
+
expect(track.getAttribute('data-orientation')).toBe('vertical')
|
|
450
|
+
})
|
|
451
|
+
|
|
452
|
+
it('applies the light variant to the thumbnails and the indicator', () => {
|
|
453
|
+
const { container } = render(<WithThumbs light />)
|
|
454
|
+
const thumb = container.querySelector('[data-slot="carousel-thumb"]') as HTMLElement
|
|
455
|
+
expect(thumb.className).toMatch(/border-white/)
|
|
456
|
+
})
|
|
457
|
+
|
|
458
|
+
it('draws the indicator over the selected thumbnail once the engine reports its slides', () => {
|
|
459
|
+
const { container, rerender } = render(<WithThumbs />)
|
|
460
|
+
expect(container.querySelector('[data-slot="carousel-thumbs-indicator"]')).toBeNull()
|
|
461
|
+
|
|
462
|
+
const rail = container.querySelector('[data-slot="carousel-thumbs"]') as HTMLElement
|
|
463
|
+
const thumbs = Array.from(rail.querySelectorAll<HTMLElement>('[data-slot="carousel-thumb"]'))
|
|
464
|
+
stubApi.slideNodes.mockReturnValue(thumbs)
|
|
465
|
+
stubApi.containerNode.mockReturnValue(rail.querySelector('[data-slot="carousel-content"]'))
|
|
466
|
+
rerender(<WithThumbs />)
|
|
467
|
+
|
|
468
|
+
const indicator = container.querySelector('[data-slot="carousel-thumbs-indicator"]') as HTMLElement
|
|
469
|
+
expect(indicator).not.toBeNull()
|
|
470
|
+
expect(indicator.style.translate).toBe('0px 0px')
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
it('excludes the indicator from the rail snap count', () => {
|
|
474
|
+
render(<WithThumbs />)
|
|
475
|
+
const options = (useEmblaCarousel as unknown as ReturnType<typeof vi.fn>).mock.calls.at(-1)?.[0]
|
|
476
|
+
expect(options.slides).toBe(':scope > [data-slot=carousel-thumb]')
|
|
477
|
+
expect(options.containScroll).toBe('keepSnaps')
|
|
478
|
+
})
|
|
479
|
+
|
|
480
|
+
it('throws when a thumbnail is used outside CarouselThumbs', () => {
|
|
481
|
+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
482
|
+
expect(() => render(<CarouselThumb>Orphan</CarouselThumb>)).toThrow(/CarouselThumb/)
|
|
483
|
+
spy.mockRestore()
|
|
484
|
+
})
|
|
485
|
+
})
|
|
486
|
+
|
|
352
487
|
describe('CarouselProgress', () => {
|
|
353
488
|
it('renders a progress bar with data-source="scroll" when no autoplay', () => {
|
|
354
489
|
const { container } = render(
|
|
@@ -412,6 +547,30 @@ describe('useCarousel + lifecycle', () => {
|
|
|
412
547
|
expect(subscribed).toEqual(expect.arrayContaining(['reinit', 'select', 'scroll', 'slidesinview', 'slideschanged']))
|
|
413
548
|
})
|
|
414
549
|
|
|
550
|
+
it('pauses autoplay on an on-axis wheel when wheel gestures are on', () => {
|
|
551
|
+
const viewport = document.createElement('div')
|
|
552
|
+
const autoplay = {
|
|
553
|
+
options: { delay: 4000 },
|
|
554
|
+
isPlaying: vi.fn(() => true),
|
|
555
|
+
play: vi.fn(),
|
|
556
|
+
stop: vi.fn(),
|
|
557
|
+
reset: vi.fn(),
|
|
558
|
+
}
|
|
559
|
+
stubApi.plugins.mockReturnValue({ wheelGestures: {}, autoplay })
|
|
560
|
+
stubApi.rootNode.mockReturnValue(viewport)
|
|
561
|
+
stubApi.internalEngine.mockReturnValue({ options: { axis: 'x' } })
|
|
562
|
+
try {
|
|
563
|
+
render(<Basic autoplay wheelGestures />)
|
|
564
|
+
viewport.dispatchEvent(new WheelEvent('wheel', { deltaX: 2, deltaY: 40 }))
|
|
565
|
+
expect(autoplay.stop).not.toHaveBeenCalled()
|
|
566
|
+
viewport.dispatchEvent(new WheelEvent('wheel', { deltaX: 40, deltaY: 2 }))
|
|
567
|
+
expect(autoplay.stop).toHaveBeenCalledTimes(1)
|
|
568
|
+
} finally {
|
|
569
|
+
stubApi.rootNode.mockReset()
|
|
570
|
+
stubApi.internalEngine.mockReset()
|
|
571
|
+
}
|
|
572
|
+
})
|
|
573
|
+
|
|
415
574
|
it('does not re-run the sync effect when re-rendered with a new-but-equal autoplay object', () => {
|
|
416
575
|
const { rerender } = render(<Basic autoplay={{ delay: 3000 }} />)
|
|
417
576
|
const initialOnCalls = stubApi.on.mock.calls.length
|
|
@@ -490,4 +649,24 @@ describe('a11y', () => {
|
|
|
490
649
|
const { container } = render(<Basic />)
|
|
491
650
|
expect(await axe(container)).toHaveNoViolations()
|
|
492
651
|
})
|
|
652
|
+
|
|
653
|
+
it('has no accessibility violations with a thumbnail rail', async () => {
|
|
654
|
+
const { container } = render(
|
|
655
|
+
<Carousel>
|
|
656
|
+
<CarouselContent>
|
|
657
|
+
<CarouselSlide>Slide 1</CarouselSlide>
|
|
658
|
+
<CarouselSlide>Slide 2</CarouselSlide>
|
|
659
|
+
</CarouselContent>
|
|
660
|
+
<CarouselThumbs>
|
|
661
|
+
<CarouselThumb>
|
|
662
|
+
<img src="/1.jpg" alt="" />
|
|
663
|
+
</CarouselThumb>
|
|
664
|
+
<CarouselThumb>
|
|
665
|
+
<img src="/2.jpg" alt="" />
|
|
666
|
+
</CarouselThumb>
|
|
667
|
+
</CarouselThumbs>
|
|
668
|
+
</Carousel>,
|
|
669
|
+
)
|
|
670
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
671
|
+
})
|
|
493
672
|
})
|
|
@@ -12,7 +12,7 @@ import ClassNames, { type ClassNamesOptionsType } from 'embla-carousel-class-nam
|
|
|
12
12
|
import Fade, { type FadeOptionsType } from 'embla-carousel-fade'
|
|
13
13
|
import { WheelGesturesPlugin, type WheelGesturesPluginOptions } from 'embla-carousel-wheel-gestures'
|
|
14
14
|
import type { EmblaCarouselType, EmblaOptionsType, EmblaPluginType } from 'embla-carousel'
|
|
15
|
-
import { cn } from '../../utils'
|
|
15
|
+
import { cn } from '../../internal/utils'
|
|
16
16
|
import { useDirection } from '../../hooks/use-direction'
|
|
17
17
|
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
18
18
|
|
|
@@ -68,30 +68,85 @@ function useCarousel(): CarouselContextValue {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
interface CarouselProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'onSelect' | 'onScroll' | 'children'> {
|
|
71
|
+
/**
|
|
72
|
+
* Scroll axis. Maps to Embla's `axis`; exposed as `data-orientation`.
|
|
73
|
+
* @default 'horizontal'
|
|
74
|
+
*/
|
|
71
75
|
orientation?: CarouselOrientation
|
|
76
|
+
/**
|
|
77
|
+
* Wrap around from the last slide to the first.
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
72
80
|
loop?: boolean
|
|
81
|
+
/**
|
|
82
|
+
* Where slides settle within the viewport.
|
|
83
|
+
* @default 'start'
|
|
84
|
+
*/
|
|
73
85
|
align?: 'start' | 'center' | 'end'
|
|
86
|
+
/**
|
|
87
|
+
* How many slides advance per step. `'auto'` groups by how many fit the viewport.
|
|
88
|
+
* @default 1
|
|
89
|
+
*/
|
|
74
90
|
slidesToScroll?: number | 'auto'
|
|
91
|
+
/**
|
|
92
|
+
* Clamp scrolling so there's no empty space at the edges. `false` disables containment.
|
|
93
|
+
* @default 'trimSnaps'
|
|
94
|
+
*/
|
|
75
95
|
containScroll?: false | 'trimSnaps' | 'keepSnaps'
|
|
76
|
-
|
|
96
|
+
/** Release snap points and glide to a momentum stop. `'snap'` glides, then settles on the nearest snap point. */
|
|
97
|
+
dragFree?: boolean | 'snap'
|
|
98
|
+
/** Index of the slide to start on. */
|
|
77
99
|
startSnap?: number
|
|
100
|
+
/**
|
|
101
|
+
* When `false`, the engine is inert (no drag/snap) - e.g. to disable at a breakpoint.
|
|
102
|
+
* @default true
|
|
103
|
+
*/
|
|
78
104
|
active?: boolean
|
|
105
|
+
/**
|
|
106
|
+
* Whether pointer dragging is enabled.
|
|
107
|
+
* @default true
|
|
108
|
+
*/
|
|
79
109
|
draggable?: boolean
|
|
110
|
+
/** Scroll animation duration (Embla's ease). Forced to `0` under reduced motion. */
|
|
80
111
|
duration?: number
|
|
112
|
+
/** Escape hatch: a raw Embla options object, merged last so it wins over the flat props. */
|
|
81
113
|
options?: CarouselOptions
|
|
114
|
+
/** Enable the Autoplay plugin. `resumeAfter` (ms) restarts the timer after user interaction. */
|
|
82
115
|
autoplay?: boolean | CarouselAutoplayOptions
|
|
116
|
+
/** Enable continuous Auto Scroll. Mutually exclusive with `autoplay`; paused under reduced motion. */
|
|
83
117
|
autoScroll?: boolean | CarouselAutoScrollOptions
|
|
118
|
+
/** Enable the Auto Height plugin; animates the viewport to each slide's height. */
|
|
84
119
|
autoHeight?: boolean | CarouselAutoHeightOptions
|
|
120
|
+
/** Enable the Fade plugin (cross-fade instead of slide). Best with one slide per view. */
|
|
85
121
|
fade?: boolean | CarouselFadeOptions
|
|
122
|
+
/** Enable the Class Names plugin, which toggles `snapped` / `inView` classes on slides. */
|
|
86
123
|
classNames?: boolean | CarouselClassNamesOptions
|
|
124
|
+
/**
|
|
125
|
+
* Keyboard/ARIA plugin for the viewport. Set `false` to opt out.
|
|
126
|
+
* @default true
|
|
127
|
+
*/
|
|
87
128
|
accessibility?: boolean | CarouselAccessibilityOptions
|
|
129
|
+
/**
|
|
130
|
+
* Enable trackpad / mouse-wheel scrolling.
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
88
133
|
wheelGestures?: boolean | CarouselWheelGesturesOptions
|
|
134
|
+
/** Additional Embla plugins to append. */
|
|
89
135
|
plugins?: CarouselPlugin[]
|
|
136
|
+
/** Receives the Embla instance once initialized - for imperative control. */
|
|
90
137
|
setApi?: (api: CarouselApi) => void
|
|
138
|
+
/** Fires on init and whenever the engine re-initializes. */
|
|
91
139
|
onReInit?: (api: CarouselApi) => void
|
|
140
|
+
/** Fires when the selected snap changes. */
|
|
92
141
|
onSelect?: (api: CarouselApi) => void
|
|
142
|
+
/** Fires continuously while scrolling. */
|
|
93
143
|
onScroll?: (api: CarouselApi) => void
|
|
144
|
+
/**
|
|
145
|
+
* Hint stored in context for light-on-dark surfaces; read via `useCarousel()`.
|
|
146
|
+
* @default false
|
|
147
|
+
*/
|
|
94
148
|
light?: boolean
|
|
149
|
+
/** The content. */
|
|
95
150
|
children: React.ReactNode
|
|
96
151
|
}
|
|
97
152
|
|
|
@@ -141,7 +196,7 @@ function Carousel({
|
|
|
141
196
|
) {
|
|
142
197
|
warnedMutualExclusive.current = true
|
|
143
198
|
// eslint-disable-next-line no-console
|
|
144
|
-
console.warn('[Carousel] `autoplay` and `autoScroll` are mutually exclusive
|
|
199
|
+
console.warn('[Carousel] `autoplay` and `autoScroll` are mutually exclusive - preferring `autoplay`.')
|
|
145
200
|
}
|
|
146
201
|
}, [autoplayEnabled, autoScrollEnabled])
|
|
147
202
|
|
|
@@ -239,8 +294,10 @@ function Carousel({
|
|
|
239
294
|
emblaApi.internalEngine().scrollBody.useDuration(0)
|
|
240
295
|
}
|
|
241
296
|
emblaApi.on('pointerup', snapToTargetInstantly)
|
|
297
|
+
emblaApi.on('scroll', snapToTargetInstantly)
|
|
242
298
|
return () => {
|
|
243
299
|
emblaApi.off('pointerup', snapToTargetInstantly)
|
|
300
|
+
emblaApi.off('scroll', snapToTargetInstantly)
|
|
244
301
|
}
|
|
245
302
|
}, [emblaApi, reducedMotion])
|
|
246
303
|
|
|
@@ -396,6 +453,26 @@ function Carousel({
|
|
|
396
453
|
}
|
|
397
454
|
}
|
|
398
455
|
|
|
456
|
+
let cleanupWheel: (() => void) | undefined
|
|
457
|
+
if (emblaApi.plugins().wheelGestures && (autoplayPlugin || autoScrollPlugin)) {
|
|
458
|
+
const viewport = emblaApi.rootNode()
|
|
459
|
+
const vertical = emblaApi.internalEngine().options.axis === 'y'
|
|
460
|
+
const onWheel = (event: WheelEvent) => {
|
|
461
|
+
const along = Math.abs(vertical ? event.deltaY : event.deltaX)
|
|
462
|
+
const across = Math.abs(vertical ? event.deltaX : event.deltaY)
|
|
463
|
+
if (along <= across) return
|
|
464
|
+
if (autoplayPlugin?.isPlaying()) {
|
|
465
|
+
autoplayPlugin.stop()
|
|
466
|
+
scheduleResume(() => emblaApi.plugins().autoplay?.play())
|
|
467
|
+
} else if (autoScrollPlugin?.isPlaying()) {
|
|
468
|
+
autoScrollPlugin.stop()
|
|
469
|
+
scheduleResume(() => emblaApi.plugins().autoScroll?.play())
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
viewport.addEventListener('wheel', onWheel, { passive: true })
|
|
473
|
+
cleanupWheel = () => viewport.removeEventListener('wheel', onWheel)
|
|
474
|
+
}
|
|
475
|
+
|
|
399
476
|
return () => {
|
|
400
477
|
emblaApi.off('reinit', handleReInit)
|
|
401
478
|
emblaApi.off('select', handleSelect)
|
|
@@ -404,6 +481,7 @@ function Carousel({
|
|
|
404
481
|
emblaApi.off('slideschanged', syncFull)
|
|
405
482
|
cleanupAutoplay?.()
|
|
406
483
|
cleanupAutoScroll?.()
|
|
484
|
+
cleanupWheel?.()
|
|
407
485
|
clearResumeTimer()
|
|
408
486
|
}
|
|
409
487
|
}, [emblaApi, autoplayEnabled, autoScrollEnabled, resumeAfterMs])
|
|
@@ -470,12 +548,16 @@ function Carousel({
|
|
|
470
548
|
)
|
|
471
549
|
}
|
|
472
550
|
|
|
473
|
-
|
|
551
|
+
interface CarouselContentProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
552
|
+
/** Props for the scroll viewport, the element that clips the track. */
|
|
553
|
+
viewportProps?: React.ComponentPropsWithoutRef<'div'>
|
|
554
|
+
}
|
|
474
555
|
|
|
475
|
-
function CarouselContent({ className, children, ...rest }: CarouselContentProps) {
|
|
556
|
+
function CarouselContent({ className, children, viewportProps, ...rest }: CarouselContentProps) {
|
|
476
557
|
const { viewportRef, orientation, autoHeight } = useCarousel()
|
|
477
558
|
return (
|
|
478
559
|
<div
|
|
560
|
+
{...viewportProps}
|
|
479
561
|
ref={viewportRef}
|
|
480
562
|
data-slot="carousel-viewport"
|
|
481
563
|
data-orientation={orientation}
|
|
@@ -483,6 +565,7 @@ function CarouselContent({ className, children, ...rest }: CarouselContentProps)
|
|
|
483
565
|
className={cn(
|
|
484
566
|
'overflow-hidden',
|
|
485
567
|
autoHeight && 'motion-safe:transition-[height] motion-safe:duration-300 motion-safe:ease-out',
|
|
568
|
+
viewportProps?.className,
|
|
486
569
|
)}
|
|
487
570
|
>
|
|
488
571
|
<div
|
|
@@ -523,6 +606,218 @@ function CarouselSlide({ className, ...rest }: CarouselSlideProps) {
|
|
|
523
606
|
)
|
|
524
607
|
}
|
|
525
608
|
|
|
609
|
+
interface CarouselThumbBox {
|
|
610
|
+
x: number
|
|
611
|
+
y: number
|
|
612
|
+
width: number
|
|
613
|
+
height: number
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function sameThumbBox(a: CarouselThumbBox | null, b: CarouselThumbBox) {
|
|
617
|
+
return a !== null && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
interface CarouselThumbsContextValue {
|
|
621
|
+
selectedIndex: number
|
|
622
|
+
select: (index: number) => void
|
|
623
|
+
light: boolean
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const CarouselThumbsContext = React.createContext<CarouselThumbsContextValue | null>(null)
|
|
627
|
+
const CarouselThumbIndexContext = React.createContext(0)
|
|
628
|
+
|
|
629
|
+
function useCarouselThumbs(): CarouselThumbsContextValue {
|
|
630
|
+
const ctx = React.useContext(CarouselThumbsContext)
|
|
631
|
+
if (!ctx) {
|
|
632
|
+
throw new Error('<CarouselThumb> must be rendered inside <CarouselThumbs>')
|
|
633
|
+
}
|
|
634
|
+
return ctx
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// Naming the slides keeps the indicator, which is a child of the track too, out
|
|
638
|
+
// of the snap count.
|
|
639
|
+
const CAROUSEL_THUMB_OPTIONS: CarouselOptions = { slides: ':scope > [data-slot=carousel-thumb]' }
|
|
640
|
+
|
|
641
|
+
const CAROUSEL_THUMB_TRANSITION = cn(
|
|
642
|
+
'transition-[opacity,translate,scale] motion-reduce:transition-none',
|
|
643
|
+
'duration-[300ms,250ms,250ms]',
|
|
644
|
+
'ease-[ease-out,cubic-bezier(0.175,0.885,0.32,1.5),cubic-bezier(0.175,0.885,0.32,1.5)]',
|
|
645
|
+
'active:duration-[300ms,100ms,100ms] active:ease-[ease-out,ease-in-out,ease-in-out]',
|
|
646
|
+
)
|
|
647
|
+
|
|
648
|
+
interface CarouselThumbsProps extends Omit<
|
|
649
|
+
React.ComponentPropsWithoutRef<'div'>,
|
|
650
|
+
'draggable' | 'onSelect' | 'onScroll'
|
|
651
|
+
> {
|
|
652
|
+
/**
|
|
653
|
+
* Lay the thumbnails out in a row or a column. Independent of the carousel's own axis.
|
|
654
|
+
* @default 'horizontal'
|
|
655
|
+
*/
|
|
656
|
+
orientation?: CarouselOrientation
|
|
657
|
+
/**
|
|
658
|
+
* Light-on-dark styling for use over imagery.
|
|
659
|
+
* @default false
|
|
660
|
+
*/
|
|
661
|
+
light?: boolean
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
function CarouselThumbs({
|
|
665
|
+
orientation = 'horizontal',
|
|
666
|
+
light: lightProp,
|
|
667
|
+
className,
|
|
668
|
+
children,
|
|
669
|
+
...rest
|
|
670
|
+
}: CarouselThumbsProps) {
|
|
671
|
+
const { selectedIndex, scrollTo, light: ctxLight } = useCarousel()
|
|
672
|
+
const light = lightProp ?? ctxLight
|
|
673
|
+
const [api, setApi] = React.useState<CarouselApi>()
|
|
674
|
+
const [box, setBox] = React.useState<CarouselThumbBox | null>(null)
|
|
675
|
+
const vertical = orientation === 'vertical'
|
|
676
|
+
|
|
677
|
+
// No dependency list: any render can add, remove or resize a thumbnail. Offsets
|
|
678
|
+
// are relative to the track, which is what Embla translates, so scrolling the
|
|
679
|
+
// rail carries the indicator along without a re-measure.
|
|
680
|
+
React.useEffect(() => {
|
|
681
|
+
const thumb = api?.slideNodes()[selectedIndex]
|
|
682
|
+
const track = api?.containerNode()
|
|
683
|
+
|
|
684
|
+
const measure = () => {
|
|
685
|
+
if (!thumb || !track) return setBox(null)
|
|
686
|
+
// Layout offsets, never rects: the thumbnail scales and shifts under the
|
|
687
|
+
// press, and a rect would catch it mid-animation. The track's transform
|
|
688
|
+
// makes it the offset parent in most engines; where it doesn't, the
|
|
689
|
+
// thumbnail is measured from further up and the track's own offset comes
|
|
690
|
+
// back off.
|
|
691
|
+
const nested = thumb.offsetParent === track
|
|
692
|
+
const next = {
|
|
693
|
+
x: thumb.offsetLeft - (nested ? 0 : track.offsetLeft),
|
|
694
|
+
y: thumb.offsetTop - (nested ? 0 : track.offsetTop),
|
|
695
|
+
width: thumb.offsetWidth,
|
|
696
|
+
height: thumb.offsetHeight,
|
|
697
|
+
}
|
|
698
|
+
setBox((previous) => (sameThumbBox(previous, next) ? previous : next))
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
measure()
|
|
702
|
+
if (!thumb || !track || typeof ResizeObserver === 'undefined') return
|
|
703
|
+
const observer = new ResizeObserver(measure)
|
|
704
|
+
observer.observe(thumb)
|
|
705
|
+
return () => observer.disconnect()
|
|
706
|
+
})
|
|
707
|
+
|
|
708
|
+
React.useEffect(() => {
|
|
709
|
+
const thumb = api?.slideNodes()[selectedIndex]
|
|
710
|
+
const viewport = api?.rootNode()
|
|
711
|
+
if (!thumb || !viewport) return
|
|
712
|
+
const slide = thumb.getBoundingClientRect()
|
|
713
|
+
const frame = viewport.getBoundingClientRect()
|
|
714
|
+
const visible = vertical
|
|
715
|
+
? slide.top >= frame.top - 1 && slide.bottom <= frame.bottom + 1
|
|
716
|
+
: slide.left >= frame.left - 1 && slide.right <= frame.right + 1
|
|
717
|
+
if (!visible) api?.goTo(selectedIndex)
|
|
718
|
+
}, [api, selectedIndex, vertical])
|
|
719
|
+
|
|
720
|
+
const context = React.useMemo<CarouselThumbsContextValue>(
|
|
721
|
+
() => ({ selectedIndex, select: scrollTo, light }),
|
|
722
|
+
[selectedIndex, scrollTo, light],
|
|
723
|
+
)
|
|
724
|
+
|
|
725
|
+
return (
|
|
726
|
+
<CarouselThumbsContext.Provider value={context}>
|
|
727
|
+
<Carousel
|
|
728
|
+
orientation={orientation}
|
|
729
|
+
align="start"
|
|
730
|
+
// One snap per thumbnail even when several share a view, so a snap index
|
|
731
|
+
// means the same thing on both carousels.
|
|
732
|
+
containScroll="keepSnaps"
|
|
733
|
+
options={CAROUSEL_THUMB_OPTIONS}
|
|
734
|
+
setApi={setApi}
|
|
735
|
+
light={light}
|
|
736
|
+
role="group"
|
|
737
|
+
aria-roledescription={undefined}
|
|
738
|
+
aria-label="Choose slide to display"
|
|
739
|
+
data-slot="carousel-thumbs"
|
|
740
|
+
className={cn(vertical ? 'shrink-0' : 'w-full', className)}
|
|
741
|
+
{...rest}
|
|
742
|
+
>
|
|
743
|
+
<CarouselContent
|
|
744
|
+
viewportProps={{
|
|
745
|
+
// Bleed, given back as padding, so focus rings aren't clipped.
|
|
746
|
+
className: cn('-m-0.5 p-0.5', vertical && 'h-[calc(100%+(--spacing(1)))]'),
|
|
747
|
+
}}
|
|
748
|
+
// The track must stay unpositioned: Embla measures it and its slides
|
|
749
|
+
// with `offsetLeft`, so they have to share an offset parent.
|
|
750
|
+
className={cn('gap-2', vertical ? 'mt-0' : 'ms-0')}
|
|
751
|
+
>
|
|
752
|
+
{React.Children.map(children, (child, index) => (
|
|
753
|
+
<CarouselThumbIndexContext.Provider value={index}>{child}</CarouselThumbIndexContext.Provider>
|
|
754
|
+
))}
|
|
755
|
+
|
|
756
|
+
{box ? (
|
|
757
|
+
<span
|
|
758
|
+
aria-hidden="true"
|
|
759
|
+
data-slot="carousel-thumbs-indicator"
|
|
760
|
+
className={cn(
|
|
761
|
+
// Anchored to the track by its transform, so it rides the scroll.
|
|
762
|
+
'pointer-events-none absolute top-0 left-0 rounded-lg border',
|
|
763
|
+
light ? 'border-white' : 'border-border-inverse',
|
|
764
|
+
'motion-safe:transition-[translate,width,height] motion-safe:duration-250',
|
|
765
|
+
)}
|
|
766
|
+
style={{ translate: `${box.x}px ${box.y}px`, width: box.width, height: box.height }}
|
|
767
|
+
/>
|
|
768
|
+
) : null}
|
|
769
|
+
</CarouselContent>
|
|
770
|
+
</Carousel>
|
|
771
|
+
</CarouselThumbsContext.Provider>
|
|
772
|
+
)
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
interface CarouselThumbProps extends React.ComponentPropsWithoutRef<'button'> {
|
|
776
|
+
/** Slide this thumbnail selects. Defaults to its position among the thumbnails. */
|
|
777
|
+
index?: number
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
function CarouselThumb({ index: indexProp, className, children, onClick, ...rest }: CarouselThumbProps) {
|
|
781
|
+
const { selectedIndex, select, light } = useCarouselThumbs()
|
|
782
|
+
const position = React.useContext(CarouselThumbIndexContext)
|
|
783
|
+
const index = indexProp ?? position
|
|
784
|
+
const active = index === selectedIndex
|
|
785
|
+
|
|
786
|
+
return (
|
|
787
|
+
<button
|
|
788
|
+
type="button"
|
|
789
|
+
aria-label={`Go to slide ${index + 1}`}
|
|
790
|
+
{...rest}
|
|
791
|
+
data-slot="carousel-thumb"
|
|
792
|
+
data-active={active || undefined}
|
|
793
|
+
aria-current={active ? 'true' : undefined}
|
|
794
|
+
onClick={(event) => {
|
|
795
|
+
onClick?.(event)
|
|
796
|
+
if (!event.defaultPrevented) select(index)
|
|
797
|
+
}}
|
|
798
|
+
className={cn(
|
|
799
|
+
'block w-18 shrink-0 grow-0 transform-gpu cursor-pointer rounded-lg border p-1',
|
|
800
|
+
light ? 'outline-ring-light border-white/25 bg-white/10 backdrop-blur-md' : 'bg-background outline-ring',
|
|
801
|
+
'focus-visible:outline-2',
|
|
802
|
+
CAROUSEL_THUMB_TRANSITION,
|
|
803
|
+
'active:translate-y-px active:scale-[0.97]',
|
|
804
|
+
!active && 'opacity-65 hover:opacity-100',
|
|
805
|
+
className,
|
|
806
|
+
)}
|
|
807
|
+
>
|
|
808
|
+
<span
|
|
809
|
+
data-slot="carousel-thumb-media"
|
|
810
|
+
className={cn(
|
|
811
|
+
'relative block aspect-square w-full overflow-hidden rounded-md',
|
|
812
|
+
light ? 'bg-white/10' : 'bg-background-muted',
|
|
813
|
+
)}
|
|
814
|
+
>
|
|
815
|
+
{children}
|
|
816
|
+
</span>
|
|
817
|
+
</button>
|
|
818
|
+
)
|
|
819
|
+
}
|
|
820
|
+
|
|
526
821
|
type CarouselButtonState = { disabled: boolean; direction: 'prev' | 'next' }
|
|
527
822
|
|
|
528
823
|
type CarouselNavPosition = 'inside' | 'outside' | 'outside-half' | 'none'
|
|
@@ -648,7 +943,15 @@ function CarouselNext({ className, position = 'inside', disabled: disabledProp,
|
|
|
648
943
|
}
|
|
649
944
|
|
|
650
945
|
interface CarouselPaginationProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
946
|
+
/**
|
|
947
|
+
* Lay the bullets out in a row or a column.
|
|
948
|
+
* @default 'horizontal'
|
|
949
|
+
*/
|
|
651
950
|
orientation?: CarouselOrientation
|
|
951
|
+
/**
|
|
952
|
+
* Light-on-dark styling for use over imagery.
|
|
953
|
+
* @default false
|
|
954
|
+
*/
|
|
652
955
|
light?: boolean
|
|
653
956
|
}
|
|
654
957
|
|
|
@@ -764,9 +1067,25 @@ function CarouselAutoplayIndicator({ delay, isPlaying, light, orientation }: Car
|
|
|
764
1067
|
}
|
|
765
1068
|
|
|
766
1069
|
interface CarouselProgressProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
1070
|
+
/**
|
|
1071
|
+
* What drives the fill. `'auto'` counts down autoplay while it plays, otherwise tracks scroll position.
|
|
1072
|
+
* @default 'auto'
|
|
1073
|
+
*/
|
|
767
1074
|
source?: 'auto' | 'autoplay' | 'scroll'
|
|
1075
|
+
/**
|
|
1076
|
+
* Straight bar or circular ring.
|
|
1077
|
+
* @default 'bar'
|
|
1078
|
+
*/
|
|
768
1079
|
variant?: 'bar' | 'circular'
|
|
1080
|
+
/**
|
|
1081
|
+
* Fill direction for the bar variant.
|
|
1082
|
+
* @default 'horizontal'
|
|
1083
|
+
*/
|
|
769
1084
|
orientation?: CarouselOrientation
|
|
1085
|
+
/**
|
|
1086
|
+
* Light-on-dark styling for use over imagery.
|
|
1087
|
+
* @default false
|
|
1088
|
+
*/
|
|
770
1089
|
light?: boolean
|
|
771
1090
|
}
|
|
772
1091
|
|
|
@@ -939,7 +1258,7 @@ function CarouselAutoplayCircularIndicator({
|
|
|
939
1258
|
}
|
|
940
1259
|
|
|
941
1260
|
/**
|
|
942
|
-
* Bidirectionally sync the selected snap between two carousels
|
|
1261
|
+
* Bidirectionally sync the selected snap between two carousels - the classic
|
|
943
1262
|
* "main + thumbnails" pattern. Wires `select` on each so navigating either
|
|
944
1263
|
* one drives the other. Both apis can be undefined initially (e.g. waiting on
|
|
945
1264
|
* `setApi`); the effect re-runs once both resolve.
|
|
@@ -975,6 +1294,8 @@ export {
|
|
|
975
1294
|
Carousel,
|
|
976
1295
|
CarouselContent,
|
|
977
1296
|
CarouselSlide,
|
|
1297
|
+
CarouselThumbs,
|
|
1298
|
+
CarouselThumb,
|
|
978
1299
|
CarouselPrev,
|
|
979
1300
|
CarouselNext,
|
|
980
1301
|
CarouselPagination,
|
|
@@ -986,6 +1307,8 @@ export type {
|
|
|
986
1307
|
CarouselProps,
|
|
987
1308
|
CarouselContentProps,
|
|
988
1309
|
CarouselSlideProps,
|
|
1310
|
+
CarouselThumbsProps,
|
|
1311
|
+
CarouselThumbProps,
|
|
989
1312
|
CarouselPrevProps,
|
|
990
1313
|
CarouselNextProps,
|
|
991
1314
|
CarouselPaginationProps,
|
|
@@ -71,13 +71,13 @@ describe('Checkbox', () => {
|
|
|
71
71
|
expect(onCheckedChange).not.toHaveBeenCalled()
|
|
72
72
|
})
|
|
73
73
|
|
|
74
|
-
it('
|
|
74
|
+
it('honors indeterminate prop', () => {
|
|
75
75
|
render(<Checkbox indeterminate aria-label="Mixed" />)
|
|
76
76
|
const cb = screen.getByRole('checkbox')
|
|
77
77
|
expect(cb).toHaveAttribute('aria-checked', 'mixed')
|
|
78
78
|
})
|
|
79
79
|
|
|
80
|
-
it('
|
|
80
|
+
it('honors controlled checked prop', async () => {
|
|
81
81
|
const user = userEvent.setup()
|
|
82
82
|
const onCheckedChange = vi.fn()
|
|
83
83
|
render(<Checkbox checked={false} aria-label="Controlled" onCheckedChange={onCheckedChange} />)
|