@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { mergeProps } from '@base-ui/react/merge-props'
|
|
5
5
|
import { useRender } from '@base-ui/react/use-render'
|
|
6
|
-
import { cn, focusableProps } from '../../utils'
|
|
6
|
+
import { cn, focusableProps } from '../../internal/utils'
|
|
7
7
|
import { buttonVariants } from '../button/button-variants'
|
|
8
8
|
|
|
9
9
|
type PaginationVariant = 'outline' | 'soft'
|
|
@@ -25,7 +25,15 @@ function usePaginationContext() {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
interface PaginationProps extends React.ComponentPropsWithoutRef<'nav'> {
|
|
28
|
+
/**
|
|
29
|
+
* Link style, shared with every link via context.
|
|
30
|
+
* @default 'outline'
|
|
31
|
+
*/
|
|
28
32
|
variant?: PaginationVariant
|
|
33
|
+
/**
|
|
34
|
+
* Link sizing, shared via context.
|
|
35
|
+
* @default 'md'
|
|
36
|
+
*/
|
|
29
37
|
size?: PaginationSize
|
|
30
38
|
}
|
|
31
39
|
|
|
@@ -65,7 +73,15 @@ type PaginationLinkState = {
|
|
|
65
73
|
}
|
|
66
74
|
|
|
67
75
|
interface PaginationLinkProps extends useRender.ComponentProps<'a', PaginationLinkState> {
|
|
76
|
+
/**
|
|
77
|
+
* Mark the current page. Renders a non-interactive, filled link with `aria-current="page"`.
|
|
78
|
+
* @default false
|
|
79
|
+
*/
|
|
68
80
|
active?: boolean
|
|
81
|
+
/**
|
|
82
|
+
* Make the link non-interactive and dimmed (`aria-disabled`); used for out-of-range controls.
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
69
85
|
disabled?: boolean
|
|
70
86
|
}
|
|
71
87
|
|
|
@@ -48,7 +48,7 @@ describe('Popover', () => {
|
|
|
48
48
|
</Popover>,
|
|
49
49
|
)
|
|
50
50
|
// Never opened, yet present in the DOM (hidden) so a consumer's animated
|
|
51
|
-
// content doesn't re-mount
|
|
51
|
+
// content doesn't re-mount - and re-animate - on every open.
|
|
52
52
|
expect(document.querySelector('[data-slot="popover-content"]')).not.toBeNull()
|
|
53
53
|
expect(screen.getByText('Always in the DOM')).toBeInTheDocument()
|
|
54
54
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { Popover as BasePopover } from '@base-ui/react/popover'
|
|
3
|
-
import { cn } from '../../utils'
|
|
4
|
-
import { type FloatingContentProps, splitFloatingProps } from '../../floating'
|
|
3
|
+
import { cn } from '../../internal/utils'
|
|
4
|
+
import { type FloatingContentProps, splitFloatingProps } from '../../internal/floating'
|
|
5
5
|
|
|
6
6
|
type PopoverProps = React.ComponentProps<typeof BasePopover.Root>
|
|
7
7
|
|
|
@@ -23,6 +23,10 @@ type PopoverContentProps = React.ComponentProps<typeof BasePopover.Popup> &
|
|
|
23
23
|
React.ComponentProps<typeof BasePopover.Positioner>,
|
|
24
24
|
React.ComponentProps<typeof BasePopover.Portal>
|
|
25
25
|
> & {
|
|
26
|
+
/**
|
|
27
|
+
* Render the pointer and the thicker anchored border.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
26
30
|
arrow?: boolean
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { PreviewCard as BasePreviewCard } from '@base-ui/react/preview-card'
|
|
3
|
-
import { cn } from '../../utils'
|
|
4
|
-
import { type FloatingContentProps, splitFloatingProps } from '../../floating'
|
|
3
|
+
import { cn } from '../../internal/utils'
|
|
4
|
+
import { type FloatingContentProps, splitFloatingProps } from '../../internal/floating'
|
|
5
5
|
|
|
6
6
|
type PreviewCardProps = React.ComponentProps<typeof BasePreviewCard.Root>
|
|
7
7
|
|
|
@@ -23,6 +23,10 @@ type PreviewCardContentProps = React.ComponentProps<typeof BasePreviewCard.Popup
|
|
|
23
23
|
React.ComponentProps<typeof BasePreviewCard.Positioner>,
|
|
24
24
|
React.ComponentProps<typeof BasePreviewCard.Portal>
|
|
25
25
|
> & {
|
|
26
|
+
/**
|
|
27
|
+
* Render the pointer and the thicker anchored border.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
26
30
|
arrow?: boolean
|
|
27
31
|
}
|
|
28
32
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { Progress as BaseProgress } from '@base-ui/react/progress'
|
|
3
|
-
import { cn } from '../../utils'
|
|
3
|
+
import { cn } from '../../internal/utils'
|
|
4
4
|
|
|
5
5
|
type ProgressVariant = 'bar' | 'circular'
|
|
6
6
|
|
|
@@ -8,10 +8,27 @@ type ProgressLabelProps = BaseProgress.Label.Props
|
|
|
8
8
|
type ProgressValueProps = BaseProgress.Value.Props
|
|
9
9
|
|
|
10
10
|
interface ProgressProps extends Omit<BaseProgress.Root.Props, 'value'> {
|
|
11
|
+
/**
|
|
12
|
+
* Horizontal track or SVG ring.
|
|
13
|
+
* @default 'bar'
|
|
14
|
+
*/
|
|
11
15
|
variant?: ProgressVariant
|
|
16
|
+
/**
|
|
17
|
+
* Diameter of the ring in pixels (`circular` only).
|
|
18
|
+
* @default 56
|
|
19
|
+
*/
|
|
12
20
|
size?: number
|
|
21
|
+
/**
|
|
22
|
+
* Track weight in pixels. Defaults to `6` for `bar`, `4` for `circular`.
|
|
23
|
+
* @default 6` / `4
|
|
24
|
+
*/
|
|
13
25
|
thickness?: number
|
|
26
|
+
/**
|
|
27
|
+
* Any CSS color for the fill (e.g. `var(--success-emphasis)`).
|
|
28
|
+
* @default primary token
|
|
29
|
+
*/
|
|
14
30
|
indicatorColor?: string
|
|
31
|
+
/** Current value, from `min` to `max`. Pass `null` for an indeterminate state. */
|
|
15
32
|
value?: number | null
|
|
16
33
|
}
|
|
17
34
|
|
|
@@ -104,7 +104,7 @@ describe('Radio', () => {
|
|
|
104
104
|
expect(onValueChange).not.toHaveBeenCalled()
|
|
105
105
|
})
|
|
106
106
|
|
|
107
|
-
it('
|
|
107
|
+
it('honors controlled value', async () => {
|
|
108
108
|
const user = userEvent.setup()
|
|
109
109
|
const onValueChange = vi.fn()
|
|
110
110
|
render(
|
|
@@ -4,7 +4,7 @@ import * as React from 'react'
|
|
|
4
4
|
import { Radio as BaseRadio } from '@base-ui/react/radio'
|
|
5
5
|
import { LazyMotion, domAnimation, m, useAnimate } from 'motion/react'
|
|
6
6
|
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
7
|
-
import { cn, useComposedRefs } from '../../utils'
|
|
7
|
+
import { cn, useComposedRefs } from '../../internal/utils'
|
|
8
8
|
|
|
9
9
|
const SQUISH_TRANSITION = {
|
|
10
10
|
duration: 0.3,
|
|
@@ -62,7 +62,7 @@ describe('RadioGroup', () => {
|
|
|
62
62
|
</RadioGroup>,
|
|
63
63
|
)
|
|
64
64
|
const group = screen.getByTestId('group')
|
|
65
|
-
// tailwind-merge dedupes conflicting display utilities
|
|
65
|
+
// tailwind-merge dedupes conflicting display utilities - `grid` wins over `flex`.
|
|
66
66
|
expect(group.className).toContain('grid')
|
|
67
67
|
expect(group.className).toContain('grid-cols-2')
|
|
68
68
|
expect(group.className).not.toMatch(/(^|\s)flex(\s|$)/)
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { RadioGroup as BaseRadioGroup } from '@base-ui/react/radio-group'
|
|
3
|
-
import { cn } from '../../utils'
|
|
3
|
+
import { cn } from '../../internal/utils'
|
|
4
4
|
|
|
5
5
|
interface RadioGroupProps extends React.ComponentProps<typeof BaseRadioGroup> {
|
|
6
|
+
/**
|
|
7
|
+
* Lay options out in a row or column; sets which arrow keys move selection.
|
|
8
|
+
* @default 'vertical'
|
|
9
|
+
*/
|
|
6
10
|
orientation?: 'horizontal' | 'vertical'
|
|
7
11
|
}
|
|
8
12
|
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { fireEvent, render, screen, waitFor } 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 { DirectionProvider } from '../../providers/direction-provider'
|
|
6
|
+
import { Rating } from './rating'
|
|
7
|
+
|
|
8
|
+
describe('Rating', () => {
|
|
9
|
+
it('renders a radiogroup with one radio per item', () => {
|
|
10
|
+
render(<Rating aria-label="Rating" />)
|
|
11
|
+
expect(screen.getByRole('radiogroup', { name: 'Rating' })).toHaveAttribute('data-slot', 'rating')
|
|
12
|
+
expect(screen.getAllByRole('radio')).toHaveLength(5)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('honors count and marks the item holding the value as checked', () => {
|
|
16
|
+
render(<Rating aria-label="Rating" count={3} defaultValue={2} />)
|
|
17
|
+
const radios = screen.getAllByRole('radio')
|
|
18
|
+
expect(radios).toHaveLength(3)
|
|
19
|
+
expect(radios[1]).toBeChecked()
|
|
20
|
+
expect(radios[0]).not.toBeChecked()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('selects on click and reports the new value', async () => {
|
|
24
|
+
const user = userEvent.setup()
|
|
25
|
+
const onValueChange = vi.fn()
|
|
26
|
+
render(<Rating aria-label="Rating" onValueChange={onValueChange} />)
|
|
27
|
+
|
|
28
|
+
await user.click(screen.getAllByRole('radio')[3])
|
|
29
|
+
|
|
30
|
+
expect(onValueChange).toHaveBeenCalledWith(4)
|
|
31
|
+
expect(screen.getAllByRole('radio')[3]).toBeChecked()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('stays on the controlled value until the consumer updates it', async () => {
|
|
35
|
+
const user = userEvent.setup()
|
|
36
|
+
const onValueChange = vi.fn()
|
|
37
|
+
render(<Rating aria-label="Rating" value={2} onValueChange={onValueChange} />)
|
|
38
|
+
|
|
39
|
+
await user.click(screen.getAllByRole('radio')[4])
|
|
40
|
+
|
|
41
|
+
expect(onValueChange).toHaveBeenCalledWith(5)
|
|
42
|
+
expect(screen.getAllByRole('radio')[1]).toBeChecked()
|
|
43
|
+
expect(screen.getAllByRole('radio')[4]).not.toBeChecked()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('clears the rating when clearable and the current item is picked again', async () => {
|
|
47
|
+
const user = userEvent.setup()
|
|
48
|
+
const onValueChange = vi.fn()
|
|
49
|
+
render(<Rating aria-label="Rating" defaultValue={3} clearable onValueChange={onValueChange} />)
|
|
50
|
+
|
|
51
|
+
await user.click(screen.getAllByRole('radio')[2])
|
|
52
|
+
|
|
53
|
+
expect(onValueChange).toHaveBeenCalledWith(0)
|
|
54
|
+
expect(screen.getAllByRole('radio').some((radio) => radio.getAttribute('aria-checked') === 'true')).toBe(false)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('moves the value by step with the arrow keys', async () => {
|
|
58
|
+
const user = userEvent.setup()
|
|
59
|
+
const onValueChange = vi.fn()
|
|
60
|
+
render(<Rating aria-label="Rating" defaultValue={2} step={0.5} onValueChange={onValueChange} />)
|
|
61
|
+
|
|
62
|
+
await user.tab()
|
|
63
|
+
await user.keyboard('{ArrowRight}')
|
|
64
|
+
expect(onValueChange).toHaveBeenLastCalledWith(2.5)
|
|
65
|
+
|
|
66
|
+
await user.keyboard('{ArrowLeft}{ArrowLeft}')
|
|
67
|
+
expect(onValueChange).toHaveBeenLastCalledWith(1.5)
|
|
68
|
+
|
|
69
|
+
await user.keyboard('{End}')
|
|
70
|
+
expect(onValueChange).toHaveBeenLastCalledWith(5)
|
|
71
|
+
|
|
72
|
+
await user.keyboard('{Home}')
|
|
73
|
+
expect(onValueChange).toHaveBeenLastCalledWith(0.5)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('flips the horizontal arrow keys in RTL', async () => {
|
|
77
|
+
const user = userEvent.setup()
|
|
78
|
+
const onValueChange = vi.fn()
|
|
79
|
+
render(
|
|
80
|
+
<DirectionProvider dir="rtl">
|
|
81
|
+
<Rating aria-label="Rating" defaultValue={3} onValueChange={onValueChange} />
|
|
82
|
+
</DirectionProvider>,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
await user.tab()
|
|
86
|
+
await user.keyboard('{ArrowRight}')
|
|
87
|
+
|
|
88
|
+
expect(onValueChange).toHaveBeenLastCalledWith(2)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('steps to the next item with Down/Right and the previous with Up/Left', async () => {
|
|
92
|
+
const user = userEvent.setup()
|
|
93
|
+
const onValueChange = vi.fn()
|
|
94
|
+
render(<Rating aria-label="Rating" defaultValue={3} onValueChange={onValueChange} />)
|
|
95
|
+
|
|
96
|
+
await user.tab()
|
|
97
|
+
await user.keyboard('{ArrowDown}')
|
|
98
|
+
expect(onValueChange).toHaveBeenLastCalledWith(4)
|
|
99
|
+
|
|
100
|
+
await user.keyboard('{ArrowUp}{ArrowUp}')
|
|
101
|
+
expect(onValueChange).toHaveBeenLastCalledWith(2)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('renders vertically and fills from the top', async () => {
|
|
105
|
+
const onValueChange = vi.fn()
|
|
106
|
+
const { container } = render(
|
|
107
|
+
<Rating aria-label="Rating" count={3} orientation="vertical" value={2} onValueChange={onValueChange} />,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
const root = screen.getByRole('radiogroup')
|
|
111
|
+
expect(root).toHaveAttribute('data-orientation', 'vertical')
|
|
112
|
+
expect(root).toHaveAttribute('aria-orientation', 'vertical')
|
|
113
|
+
|
|
114
|
+
const clips = [...container.querySelectorAll<HTMLElement>('[data-slot=rating-item-fill]')].map(
|
|
115
|
+
(el) => el.style.clipPath,
|
|
116
|
+
)
|
|
117
|
+
expect(clips).toEqual(['inset(0 0 0% 0)', 'inset(0 0 0% 0)', 'inset(0 0 100% 0)'])
|
|
118
|
+
|
|
119
|
+
vi.spyOn(root, 'getBoundingClientRect').mockReturnValue({ top: 0, height: 300 } as DOMRect)
|
|
120
|
+
fireEvent.pointerMove(root, { clientY: 250 })
|
|
121
|
+
fireEvent.click(screen.getAllByRole('radio')[2], { detail: 1 })
|
|
122
|
+
expect(onValueChange).toHaveBeenCalledWith(3)
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('keeps a single tab stop on the checked item', async () => {
|
|
126
|
+
const user = userEvent.setup()
|
|
127
|
+
render(<Rating aria-label="Rating" defaultValue={4} />)
|
|
128
|
+
|
|
129
|
+
await user.tab()
|
|
130
|
+
|
|
131
|
+
expect(screen.getAllByRole('radio')[3]).toHaveFocus()
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('exposes a read-only rating as one labeled image', () => {
|
|
135
|
+
render(<Rating readOnly value={4.5} step={0.5} />)
|
|
136
|
+
expect(screen.getByRole('img', { name: '4.5 out of 5' })).toHaveAttribute('data-readonly', '')
|
|
137
|
+
expect(screen.queryAllByRole('radio')).toHaveLength(0)
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it('blocks interaction when disabled', async () => {
|
|
141
|
+
const user = userEvent.setup()
|
|
142
|
+
const onValueChange = vi.fn()
|
|
143
|
+
render(<Rating aria-label="Rating" disabled onValueChange={onValueChange} />)
|
|
144
|
+
|
|
145
|
+
await user.click(screen.getAllByRole('radio')[2])
|
|
146
|
+
|
|
147
|
+
expect(onValueChange).not.toHaveBeenCalled()
|
|
148
|
+
expect(screen.getByRole('radiogroup')).toHaveAttribute('data-disabled', '')
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('submits the value through a hidden input', () => {
|
|
152
|
+
const { container } = render(<Rating aria-label="Rating" name="score" defaultValue={3} />)
|
|
153
|
+
expect(container.querySelector('input[name="score"]')).toHaveValue('3')
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('renders the built-in star by default and swaps in a custom icon pair', () => {
|
|
157
|
+
const { container, rerender } = render(<Rating aria-label="Rating" count={1} />)
|
|
158
|
+
expect(container.querySelectorAll('svg')).toHaveLength(2)
|
|
159
|
+
|
|
160
|
+
rerender(
|
|
161
|
+
<Rating
|
|
162
|
+
aria-label="Rating"
|
|
163
|
+
count={1}
|
|
164
|
+
icon={{ empty: <svg data-testid="empty" />, filled: <svg data-testid="filled" /> }}
|
|
165
|
+
variant="outline"
|
|
166
|
+
/>,
|
|
167
|
+
)
|
|
168
|
+
expect(screen.getByTestId('empty')).toBeInTheDocument()
|
|
169
|
+
expect(screen.getByTestId('filled')).toBeInTheDocument()
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it('still fills the selection when the hover preview is off', async () => {
|
|
173
|
+
const { container } = render(<Rating aria-label="Rating" count={3} hoverable={false} />)
|
|
174
|
+
const root = screen.getByRole('radiogroup')
|
|
175
|
+
vi.spyOn(root, 'getBoundingClientRect').mockReturnValue({ left: 0, width: 300 } as DOMRect)
|
|
176
|
+
|
|
177
|
+
fireEvent.pointerMove(root, { clientX: 150 })
|
|
178
|
+
fireEvent.click(screen.getAllByRole('radio')[1], { detail: 1 })
|
|
179
|
+
|
|
180
|
+
await waitFor(() => {
|
|
181
|
+
const clips = [...container.querySelectorAll<HTMLElement>('[data-slot=rating-item-fill]')].map(
|
|
182
|
+
(el) => el.style.clipPath,
|
|
183
|
+
)
|
|
184
|
+
expect(clips).toEqual(['inset(0 0% 0 0)', 'inset(0 0% 0 0)', 'inset(0 100% 0 0)'])
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('holds the pressed item scaled down until the pointer is released', async () => {
|
|
189
|
+
const { container } = render(<Rating aria-label="Rating" count={3} />)
|
|
190
|
+
const icon = () => container.querySelectorAll<HTMLElement>('[data-slot=rating-item] > span')[1]!
|
|
191
|
+
const scaleOf = (el: HTMLElement) => Number(/scale\(([\d.]+)\)/.exec(el.style.transform)?.[1] ?? 1)
|
|
192
|
+
|
|
193
|
+
fireEvent.pointerDown(screen.getAllByRole('radio')[1])
|
|
194
|
+
await waitFor(() => expect(scaleOf(icon())).toBeLessThan(1))
|
|
195
|
+
|
|
196
|
+
fireEvent.pointerUp(screen.getAllByRole('radio')[1])
|
|
197
|
+
await waitFor(() => expect(scaleOf(icon())).toBe(1))
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it('presses an item even while another one holds focus', async () => {
|
|
201
|
+
const { container } = render(<Rating aria-label="Rating" count={3} />)
|
|
202
|
+
const radios = screen.getAllByRole('radio')
|
|
203
|
+
const icon = () => container.querySelectorAll<HTMLElement>('[data-slot=rating-item] > span')[0]!
|
|
204
|
+
const scaleOf = (el: HTMLElement) => Number(/scale\(([\d.]+)\)/.exec(el.style.transform)?.[1] ?? 1)
|
|
205
|
+
|
|
206
|
+
radios[2].focus()
|
|
207
|
+
fireEvent.pointerDown(radios[0])
|
|
208
|
+
fireEvent.blur(radios[2])
|
|
209
|
+
|
|
210
|
+
await waitFor(() => expect(scaleOf(icon())).toBeLessThan(1))
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
it('clips each item fill to the value it holds', () => {
|
|
214
|
+
const { container } = render(<Rating aria-label="Rating" value={2.4} step={0.2} count={3} />)
|
|
215
|
+
const clips = [...container.querySelectorAll<HTMLElement>('[data-slot=rating-item-fill]')].map(
|
|
216
|
+
(el) => el.style.clipPath,
|
|
217
|
+
)
|
|
218
|
+
expect(clips).toEqual(['inset(0 0% 0 0)', 'inset(0 0% 0 0)', 'inset(0 60% 0 0)'])
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it('sizes the icons from a number of pixels or any CSS length', () => {
|
|
222
|
+
const { container, rerender } = render(<Rating aria-label="Rating" />)
|
|
223
|
+
const root = () => container.querySelector<HTMLElement>('[data-slot=rating]')!
|
|
224
|
+
|
|
225
|
+
expect(root().style.getPropertyValue('--rating-size')).toBe('24px')
|
|
226
|
+
|
|
227
|
+
rerender(<Rating aria-label="Rating" size={40} />)
|
|
228
|
+
expect(root().style.getPropertyValue('--rating-size')).toBe('40px')
|
|
229
|
+
|
|
230
|
+
rerender(<Rating aria-label="Rating" size="1.5em" style={{ opacity: 0.5 }} />)
|
|
231
|
+
expect(root().style.getPropertyValue('--rating-size')).toBe('1.5em')
|
|
232
|
+
expect(root().style.opacity).toBe('0.5')
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
it('merges className with the layout classes', () => {
|
|
236
|
+
render(<Rating aria-label="Rating" className="custom-class" />)
|
|
237
|
+
const root = screen.getByRole('radiogroup')
|
|
238
|
+
expect(root.className).toContain('custom-class')
|
|
239
|
+
expect(root.className).toContain('inline-flex')
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it('has no accessibility violations', async () => {
|
|
243
|
+
const { container } = render(<Rating aria-label="Rating" defaultValue={3} />)
|
|
244
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
245
|
+
})
|
|
246
|
+
})
|