@appica/ui-react 1.0.0 → 1.1.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 +46 -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 +1 -1
- package/dist/components/accordion/accordion.js.map +1 -1
- package/dist/components/alert/alert.d.ts +29 -1
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/alert.js +1 -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 +9 -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 +2 -2
- package/dist/components/autocomplete/autocomplete.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +16 -0
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/background-pattern/background-pattern-interactive.js +1 -1
- package/dist/components/background-pattern/background-pattern-interactive.js.map +1 -1
- package/dist/components/background-pattern/background-pattern-shared.js +1 -1
- 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 +1 -1
- package/dist/components/background-pattern/background-pattern.js.map +1 -1
- package/dist/components/badge/badge.d.ts +11 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/badge.js +1 -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 +67 -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 +1 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button-variants.js +1 -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 +1 -1
- package/dist/components/button/button.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 +1 -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 +1 -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 +103 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/carousel/carousel.d.ts +105 -5
- package/dist/components/carousel/carousel.d.ts.map +1 -1
- package/dist/components/carousel/carousel.js +157 -5
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +1 -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 +1 -1
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -1
- package/dist/components/chip/chip.d.ts +32 -0
- package/dist/components/chip/chip.d.ts.map +1 -1
- package/dist/components/chip/chip.js +1 -1
- package/dist/components/chip/chip.js.map +1 -1
- package/dist/components/collapsible/collapsible.js +1 -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 +245 -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 +327 -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 +216 -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 +66 -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 +202 -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 +2 -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 +5 -5
- package/dist/components/context-menu/context-menu.js.map +1 -1
- package/dist/components/copy-button/copy-button.d.ts +15 -0
- package/dist/components/copy-button/copy-button.d.ts.map +1 -1
- package/dist/components/copy-button/copy-button.js +1 -1
- 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 +1 -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 +1 -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 +1 -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 +8 -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 +13 -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 +5 -5
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/field/field.js +1 -1
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/fieldset/fieldset.js +1 -1
- package/dist/components/fieldset/fieldset.js.map +1 -1
- package/dist/components/gradient-glow/gradient-glow.d.ts +45 -0
- package/dist/components/gradient-glow/gradient-glow.d.ts.map +1 -1
- package/dist/components/gradient-glow/gradient-glow.js +1 -1
- package/dist/components/gradient-glow/gradient-glow.js.map +1 -1
- package/dist/components/input/input-variants.js +1 -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 +3 -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 +1 -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 +1 -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 +1 -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 +1 -1
- package/dist/components/meter/meter.js.map +1 -1
- package/dist/components/navigation/navigation-link-variants.d.ts +1 -1
- package/dist/components/navigation/navigation-link-variants.js +1 -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 +1 -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 +1 -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 +1 -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 +1 -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 +1 -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 +1 -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 +2 -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 +2 -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 +1 -1
- package/dist/components/progress/progress.js.map +1 -1
- package/dist/components/radio/radio.js +1 -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 +1 -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 +301 -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 +1 -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 +2 -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 +1 -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 +1 -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 +1 -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 +1 -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 +1 -1
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/components/switch/switch.d.ts +4 -0
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/switch/switch.js +1 -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 +1 -1
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/tabs/tabs.d.ts +31 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tabs/tabs.js +1 -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 +26 -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 +1 -1
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/thumbnail/thumbnail.d.ts +20 -0
- package/dist/components/thumbnail/thumbnail.d.ts.map +1 -1
- package/dist/components/thumbnail/thumbnail.js +1 -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 +1 -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 +1 -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 +1 -1
- package/dist/components/toc/toc.js.map +1 -1
- package/dist/components/toggle-group/toggle-group.js +1 -1
- package/dist/components/toggle-group/toggle-group.js.map +1 -1
- package/dist/components/toolbar/toolbar.js +1 -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 +2 -2
- package/dist/components/tooltip/tooltip.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.map +1 -1
- package/dist/hooks/use-local-storage.js.map +1 -1
- package/dist/hooks/use-reduced-motion.d.ts +1 -1
- 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.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -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 +78 -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 +34 -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 +41 -0
- package/dist/internal/color-picker-context.js.map +1 -0
- package/dist/{floating.d.ts → internal/floating.d.ts} +1 -1
- package/dist/internal/floating.d.ts.map +1 -0
- package/dist/internal/floating.js.map +1 -0
- package/dist/{modal.d.ts → internal/modal.d.ts} +1 -1
- package/dist/internal/modal.d.ts.map +1 -0
- package/dist/internal/modal.js.map +1 -0
- package/dist/internal/utils.d.ts.map +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 +328 -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.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.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.map +1 -1
- package/dist/providers/theme-provider/theme-script.js.map +1 -1
- package/package.json +75 -17
- 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 +1 -1
- package/src/components/background-pattern/background-pattern-shared.tsx +1 -1
- package/src/components/background-pattern/background-pattern.test.tsx +1 -1
- package/src/components/background-pattern/background-pattern.tsx +14 -6
- 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 +155 -0
- package/src/components/carousel/carousel.tsx +305 -5
- 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.tsx +11 -5
- package/src/components/copy-button/copy-button.test.tsx +1 -1
- package/src/components/copy-button/copy-button.tsx +16 -1
- 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.tsx +11 -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 +1 -1
- package/src/components/gradient-glow/gradient-glow.tsx +46 -1
- 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/dist/{floating.js → internal/floating.js} +0 -0
- /package/dist/{modal.js → internal/modal.js} +0 -0
- /package/dist/{utils.d.ts → internal/utils.d.ts} +0 -0
- /package/dist/{utils.js → internal/utils.js} +0 -0
- /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
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { cn } from '../../internal/utils'
|
|
3
|
+
|
|
4
|
+
type BorderBeamTrigger = 'hover' | 'press'
|
|
5
|
+
|
|
6
|
+
interface BorderBeamProps extends React.ComponentProps<'div'> {
|
|
7
|
+
/**
|
|
8
|
+
* Beam color. It lights the head of the comet and fades to transparent along the tail, so pass a solid color
|
|
9
|
+
* rather than a gradient.
|
|
10
|
+
* @default 'var(--primary)'
|
|
11
|
+
*/
|
|
12
|
+
color?: string
|
|
13
|
+
/**
|
|
14
|
+
* How much of the border the comet spans, in percent of one lap.
|
|
15
|
+
* @default 10
|
|
16
|
+
*/
|
|
17
|
+
length?: number
|
|
18
|
+
/**
|
|
19
|
+
* Beam thickness in px.
|
|
20
|
+
* @default 1
|
|
21
|
+
*/
|
|
22
|
+
thickness?: number
|
|
23
|
+
/**
|
|
24
|
+
* Seconds for one full lap around the border.
|
|
25
|
+
* @default 5
|
|
26
|
+
*/
|
|
27
|
+
speed?: number
|
|
28
|
+
/**
|
|
29
|
+
* Seconds before the first lap starts. Negative values start the beam mid-lap, which is how you desynchronize a
|
|
30
|
+
* group of cards.
|
|
31
|
+
* @default 0
|
|
32
|
+
*/
|
|
33
|
+
delay?: number
|
|
34
|
+
/**
|
|
35
|
+
* Reveal only on interaction. `'hover'` is pointer-only; `'press'` works on touch. Combine via an array. Omit for
|
|
36
|
+
* always-on.
|
|
37
|
+
*/
|
|
38
|
+
revealOn?: BorderBeamTrigger | BorderBeamTrigger[]
|
|
39
|
+
/** Controlled visibility for programmatic states (loading, etc.); OR-ed with `revealOn`. */
|
|
40
|
+
reveal?: boolean
|
|
41
|
+
/**
|
|
42
|
+
* With `revealOn="hover"`, keep the beam visible on touch devices (which have no hover) instead of hidden.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
showOnTouch?: boolean
|
|
46
|
+
/**
|
|
47
|
+
* Scale the beam down while pressed, to track a child `Button`'s own active-press scale.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
pressScale?: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* A conic sweep clipped to the border ring by an XOR mask (same trick as GradientGlow's border), so the comet follows
|
|
54
|
+
the wrapper's radius at any corner. The RTL mirror uses `transform`, not `scale`, so it composes with `pressScale`
|
|
55
|
+
instead of losing to it. */
|
|
56
|
+
const RING_MASK = 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)'
|
|
57
|
+
|
|
58
|
+
function BorderBeam({
|
|
59
|
+
color = 'var(--primary)',
|
|
60
|
+
length = 10,
|
|
61
|
+
thickness = 1,
|
|
62
|
+
speed = 5,
|
|
63
|
+
delay = 0,
|
|
64
|
+
revealOn,
|
|
65
|
+
reveal,
|
|
66
|
+
showOnTouch = false,
|
|
67
|
+
pressScale = false,
|
|
68
|
+
className,
|
|
69
|
+
style,
|
|
70
|
+
children,
|
|
71
|
+
...props
|
|
72
|
+
}: BorderBeamProps) {
|
|
73
|
+
const triggers = revealOn == null ? [] : Array.isArray(revealOn) ? revealOn : [revealOn]
|
|
74
|
+
const managed = triggers.length > 0 || reveal !== undefined
|
|
75
|
+
const grouped = managed || pressScale
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
data-slot="border-beam"
|
|
80
|
+
data-reveal={managed ? triggers.join(' ') : undefined}
|
|
81
|
+
data-revealed={reveal ? '' : undefined}
|
|
82
|
+
data-show-on-touch={showOnTouch ? '' : undefined}
|
|
83
|
+
className={cn('relative rounded-xl', grouped && 'group/beam', className)}
|
|
84
|
+
style={
|
|
85
|
+
{ '--border-beam-duration': `${speed}s`, '--border-beam-delay': `${delay}s`, ...style } as React.CSSProperties
|
|
86
|
+
}
|
|
87
|
+
{...props}
|
|
88
|
+
>
|
|
89
|
+
{children}
|
|
90
|
+
<span
|
|
91
|
+
aria-hidden
|
|
92
|
+
data-slot="border-beam-ring"
|
|
93
|
+
className={cn(
|
|
94
|
+
'pointer-events-none absolute inset-0 rounded-[inherit] rtl:transform-[scaleX(-1)]',
|
|
95
|
+
'motion-safe:animate-border-beam motion-reduce:hidden',
|
|
96
|
+
managed && 'opacity-0 [animation-play-state:paused]',
|
|
97
|
+
managed &&
|
|
98
|
+
triggers.includes('hover') &&
|
|
99
|
+
'group-hover/beam:opacity-100 group-hover/beam:[animation-play-state:running]',
|
|
100
|
+
managed &&
|
|
101
|
+
triggers.includes('hover') &&
|
|
102
|
+
showOnTouch &&
|
|
103
|
+
'hover-none:opacity-100 hover-none:[animation-play-state:running]',
|
|
104
|
+
managed &&
|
|
105
|
+
triggers.includes('press') &&
|
|
106
|
+
'group-active/beam:opacity-100 group-active/beam:[animation-play-state:running]',
|
|
107
|
+
managed && reveal && 'opacity-100 [animation-play-state:running]',
|
|
108
|
+
pressScale && 'group-active/beam:translate-y-px group-active/beam:scale-[0.97]',
|
|
109
|
+
managed && pressScale
|
|
110
|
+
? '[transition:opacity_500ms_ease-out,scale_150ms_ease-out,translate_150ms_ease-out]'
|
|
111
|
+
: managed
|
|
112
|
+
? 'transition-opacity duration-500 ease-out'
|
|
113
|
+
: pressScale
|
|
114
|
+
? '[transition:scale_150ms_ease-out,translate_150ms_ease-out]'
|
|
115
|
+
: undefined,
|
|
116
|
+
)}
|
|
117
|
+
style={{
|
|
118
|
+
background: `conic-gradient(from var(--border-beam-angle), transparent, ${color} ${length}%, transparent calc(${length}% * 1.2))`,
|
|
119
|
+
padding: thickness,
|
|
120
|
+
WebkitMask: RING_MASK,
|
|
121
|
+
WebkitMaskComposite: 'xor',
|
|
122
|
+
mask: RING_MASK,
|
|
123
|
+
maskComposite: 'exclude',
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { BorderBeam }
|
|
131
|
+
export type { BorderBeamProps }
|
|
@@ -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
|
|
|
8
8
|
type BreadcrumbProps = React.ComponentPropsWithoutRef<'nav'>
|
|
9
9
|
|
|
@@ -52,7 +52,15 @@ type BreadcrumbLinkState = {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
interface BreadcrumbLinkProps extends useRender.ComponentProps<'a', BreadcrumbLinkState> {
|
|
55
|
+
/**
|
|
56
|
+
* Mark the current page. Renders a non-interactive `<span>` with `aria-current="page"`.
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
55
59
|
active?: boolean
|
|
60
|
+
/**
|
|
61
|
+
* Make the link non-interactive and dimmed.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
56
64
|
disabled?: boolean
|
|
57
65
|
}
|
|
58
66
|
|
|
@@ -3,11 +3,22 @@
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { Button as BaseButton } from '@base-ui/react/button'
|
|
5
5
|
import { type VariantProps } from 'class-variance-authority'
|
|
6
|
-
import { cn } from '../../utils'
|
|
6
|
+
import { cn } from '../../internal/utils'
|
|
7
7
|
import { ButtonGroupContext } from '../button-group/button-group-context'
|
|
8
8
|
import { buttonVariants } from './button-variants'
|
|
9
9
|
|
|
10
|
-
interface ButtonProps extends BaseButton.Props, VariantProps<typeof buttonVariants> {
|
|
10
|
+
interface ButtonProps extends BaseButton.Props, Omit<VariantProps<typeof buttonVariants>, 'variant' | 'size'> {
|
|
11
|
+
/**
|
|
12
|
+
* Visual style.
|
|
13
|
+
* @default 'primary'
|
|
14
|
+
*/
|
|
15
|
+
variant?: VariantProps<typeof buttonVariants>['variant']
|
|
16
|
+
/**
|
|
17
|
+
* Height and padding. The `icon-*` sizes are square, for icon-only buttons.
|
|
18
|
+
* @default 'md'
|
|
19
|
+
*/
|
|
20
|
+
size?: VariantProps<typeof buttonVariants>['size']
|
|
21
|
+
}
|
|
11
22
|
|
|
12
23
|
function Button({ className, variant, size, disabled, ...props }: ButtonProps) {
|
|
13
24
|
const group = React.useContext(ButtonGroupContext)
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import * as React from 'react'
|
|
4
|
-
import { cn } from '../../utils'
|
|
4
|
+
import { cn } from '../../internal/utils'
|
|
5
5
|
import { ButtonGroupContext, type ButtonGroupVariant, type ButtonGroupSize } from './button-group-context'
|
|
6
6
|
|
|
7
7
|
const OUTLINED_VARIANTS = new Set<ButtonGroupVariant>(['primary-outline', 'outline', 'light'])
|
|
8
8
|
|
|
9
9
|
interface ButtonGroupProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
10
|
+
/** Visual style applied to every child `Button`. Inherited unless a button sets its own `variant`. */
|
|
10
11
|
variant?: ButtonGroupVariant
|
|
12
|
+
/** Height/padding applied to every child `Button`. Inherited unless a button sets its own `size`. */
|
|
11
13
|
size?: ButtonGroupSize
|
|
14
|
+
/**
|
|
15
|
+
* Disables every child `Button`. A child can't re-enable itself; the group's `disabled` wins.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
12
18
|
disabled?: boolean
|
|
19
|
+
/**
|
|
20
|
+
* Lay the buttons out in a row or a column; controls which corners are rounded.
|
|
21
|
+
* @default 'horizontal'
|
|
22
|
+
*/
|
|
13
23
|
orientation?: 'horizontal' | 'vertical'
|
|
14
24
|
}
|
|
15
25
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from 'react-day-picker'
|
|
12
12
|
import { buttonVariants } from '../button/button-variants'
|
|
13
13
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../select/select'
|
|
14
|
-
import { cn } from '../../utils'
|
|
14
|
+
import { cn } from '../../internal/utils'
|
|
15
15
|
|
|
16
16
|
type CalendarSize = 'sm' | 'md' | 'lg'
|
|
17
17
|
|
|
@@ -20,7 +20,12 @@ type DayPickerProps = React.ComponentProps<typeof DayPicker>
|
|
|
20
20
|
type DistributiveOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K> : never
|
|
21
21
|
|
|
22
22
|
interface CalendarExtensions {
|
|
23
|
+
/**
|
|
24
|
+
* Cell size and text scale (Appica extension).
|
|
25
|
+
* @default 'md'
|
|
26
|
+
*/
|
|
23
27
|
size?: CalendarSize
|
|
28
|
+
/** Extra classes on the root, merged via `tailwind-merge`. */
|
|
24
29
|
className?: string
|
|
25
30
|
}
|
|
26
31
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { axe } from 'vitest-axe'
|
|
4
|
+
import { Card, CardDescription, CardFooter, CardHeader, CardMedia, CardTitle } from './card'
|
|
5
|
+
|
|
6
|
+
const TITLE = 'Deployment ready'
|
|
7
|
+
const DESCRIPTION = 'Your project finished building 2 minutes ago.'
|
|
8
|
+
|
|
9
|
+
function renderCard(props: Partial<React.ComponentProps<typeof Card>> = {}) {
|
|
10
|
+
return render(
|
|
11
|
+
<Card {...props}>
|
|
12
|
+
<CardMedia data-testid="media">
|
|
13
|
+
<img src="/cover.jpg" alt="" />
|
|
14
|
+
</CardMedia>
|
|
15
|
+
<CardHeader>
|
|
16
|
+
<CardTitle>{TITLE}</CardTitle>
|
|
17
|
+
<CardDescription>{DESCRIPTION}</CardDescription>
|
|
18
|
+
</CardHeader>
|
|
19
|
+
<CardFooter>
|
|
20
|
+
<button type="button">Deploy</button>
|
|
21
|
+
</CardFooter>
|
|
22
|
+
</Card>,
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getRoot() {
|
|
27
|
+
return document.querySelector('[data-slot="card"]') as HTMLElement
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('Card', () => {
|
|
31
|
+
it('renders the composed slots inside a content wrapper', () => {
|
|
32
|
+
renderCard()
|
|
33
|
+
|
|
34
|
+
const root = getRoot()
|
|
35
|
+
const content = root.querySelector('[data-slot="card-content"]')
|
|
36
|
+
|
|
37
|
+
expect(root).toBeInTheDocument()
|
|
38
|
+
expect(content).toBeInTheDocument()
|
|
39
|
+
expect(content).toContainElement(screen.getByTestId('media'))
|
|
40
|
+
expect(content).toContainElement(screen.getByRole('heading', { name: TITLE }))
|
|
41
|
+
expect(content).toContainElement(screen.getByRole('button', { name: 'Deploy' }))
|
|
42
|
+
expect(screen.getByText(DESCRIPTION)).toBeInTheDocument()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('renders unframed and inset by default', () => {
|
|
46
|
+
renderCard()
|
|
47
|
+
|
|
48
|
+
expect(getRoot()).toHaveAttribute('data-frame', 'none')
|
|
49
|
+
expect(getRoot()).toHaveAttribute('data-inset', '')
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it.each([
|
|
53
|
+
[true, 'solid'],
|
|
54
|
+
['solid' as const, 'solid'],
|
|
55
|
+
['glass' as const, 'glass'],
|
|
56
|
+
])('maps frame=%s to data-frame="%s"', (frame, expected) => {
|
|
57
|
+
renderCard({ frame })
|
|
58
|
+
expect(getRoot()).toHaveAttribute('data-frame', expected)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('drops data-inset when inset is false', () => {
|
|
62
|
+
renderCard({ inset: false })
|
|
63
|
+
expect(getRoot()).not.toHaveAttribute('data-inset')
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('forwards className to the root and contentProps to the content wrapper', () => {
|
|
67
|
+
renderCard({ className: 'w-80', contentProps: { className: 'sm:flex-row', 'data-testid': 'content' } })
|
|
68
|
+
|
|
69
|
+
expect(getRoot()).toHaveClass('w-80')
|
|
70
|
+
expect(screen.getByTestId('content')).toHaveClass('sm:flex-row')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('renders the root as another element via render', () => {
|
|
74
|
+
render(
|
|
75
|
+
<Card render={<article />}>
|
|
76
|
+
<CardHeader>
|
|
77
|
+
<CardTitle>{TITLE}</CardTitle>
|
|
78
|
+
</CardHeader>
|
|
79
|
+
</Card>,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
expect(screen.getByRole('article')).toHaveAttribute('data-slot', 'card')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('renders the title as h3 by default and honors the render escape hatch', () => {
|
|
86
|
+
const { unmount } = render(<CardTitle>{TITLE}</CardTitle>)
|
|
87
|
+
expect(screen.getByRole('heading', { level: 3, name: TITLE })).toBeInTheDocument()
|
|
88
|
+
unmount()
|
|
89
|
+
|
|
90
|
+
render(<CardTitle render={<h2 />}>{TITLE}</CardTitle>)
|
|
91
|
+
expect(screen.getByRole('heading', { level: 2, name: TITLE })).toBeInTheDocument()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it('has no accessibility violations', async () => {
|
|
95
|
+
const { container } = renderCard({ frame: 'glass' })
|
|
96
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
97
|
+
})
|
|
98
|
+
})
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { cn } from '../../internal/utils'
|
|
3
|
+
|
|
4
|
+
// Server-safe stand-in for Base UI's `useRender`, which is a hook and would
|
|
5
|
+
// make Card a client component. Element form only, so it crosses the RSC boundary.
|
|
6
|
+
type RenderProp = React.ReactElement<{ className?: string }>
|
|
7
|
+
|
|
8
|
+
function renderElement(
|
|
9
|
+
fallback: React.ElementType,
|
|
10
|
+
render: RenderProp | undefined,
|
|
11
|
+
base: string,
|
|
12
|
+
className: string | undefined,
|
|
13
|
+
props: Record<string, unknown>,
|
|
14
|
+
) {
|
|
15
|
+
if (React.isValidElement<{ className?: string }>(render)) {
|
|
16
|
+
return React.cloneElement(render, {
|
|
17
|
+
...props,
|
|
18
|
+
...render.props,
|
|
19
|
+
className: cn(base, render.props.className, className),
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
return React.createElement(fallback, { ...props, className: cn(base, className) })
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const CARD_RADIUS = '[--card-radius:var(--radius-xl)]'
|
|
26
|
+
const FRAME_RADIUS = 'rounded-[calc(var(--card-radius)*4/3)]'
|
|
27
|
+
|
|
28
|
+
type CardFrame = 'none' | 'solid' | 'glass'
|
|
29
|
+
|
|
30
|
+
const frameVariants: Record<CardFrame, string> = {
|
|
31
|
+
none: 'rounded-(--card-radius)',
|
|
32
|
+
solid: cn(FRAME_RADIUS, 'bg-background-subtle p-2 backdrop-blur-md'),
|
|
33
|
+
glass: cn(FRAME_RADIUS, 'border border-white/15 bg-white/10 p-2 backdrop-blur-sm'),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const contentFrameVariants: Record<CardFrame, string> = {
|
|
37
|
+
none: 'border',
|
|
38
|
+
solid: 'border-border-muted border',
|
|
39
|
+
glass: '',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface CardProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
43
|
+
/**
|
|
44
|
+
* Wrap the content in a padded frame. `true` is an alias for `'solid'`; `'glass'` is translucent and blurred.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
frame?: boolean | 'solid' | 'glass'
|
|
48
|
+
/**
|
|
49
|
+
* Float the slots inside the content, so media rounds all four corners. `false` gives edge-to-edge media.
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
inset?: boolean
|
|
53
|
+
/** Escape hatch for the inner content wrapper - e.g. `{ className: 'sm:flex-row' }` for a horizontal card. */
|
|
54
|
+
contentProps?: React.ComponentPropsWithoutRef<'div'>
|
|
55
|
+
/** Render as a different element, e.g. `render={<article />}` or `render={<li />}`. */
|
|
56
|
+
render?: RenderProp
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function Card({ frame = false, inset = true, className, contentProps, render, children, ...props }: CardProps) {
|
|
60
|
+
const variant: CardFrame = frame === true ? 'solid' : frame === false ? 'none' : frame
|
|
61
|
+
|
|
62
|
+
return renderElement('div', render, cn('group/card flex flex-col', CARD_RADIUS, frameVariants[variant]), className, {
|
|
63
|
+
'data-slot': 'card',
|
|
64
|
+
'data-frame': variant,
|
|
65
|
+
...(inset ? { 'data-inset': '' } : {}),
|
|
66
|
+
...props,
|
|
67
|
+
children: (
|
|
68
|
+
<div
|
|
69
|
+
data-slot="card-content"
|
|
70
|
+
{...contentProps}
|
|
71
|
+
className={cn(
|
|
72
|
+
'bg-background flex min-h-0 flex-1 flex-col overflow-hidden rounded-(--card-radius)',
|
|
73
|
+
inset && 'p-2',
|
|
74
|
+
contentFrameVariants[variant],
|
|
75
|
+
contentProps?.className,
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</div>
|
|
80
|
+
),
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface CardMediaProps extends React.ComponentPropsWithoutRef<'div'> {}
|
|
85
|
+
|
|
86
|
+
function CardMedia({ className, ...props }: CardMediaProps) {
|
|
87
|
+
return (
|
|
88
|
+
<div
|
|
89
|
+
data-slot="card-media"
|
|
90
|
+
className={cn(
|
|
91
|
+
'relative shrink-0 overflow-hidden',
|
|
92
|
+
'group-data-inset/card:rounded-[calc(var(--card-radius)*3/4)]',
|
|
93
|
+
'[&>img]:size-full [&>img]:object-cover [&>video]:size-full [&>video]:object-cover',
|
|
94
|
+
className,
|
|
95
|
+
)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface CardHeaderProps extends React.ComponentPropsWithoutRef<'div'> {}
|
|
102
|
+
|
|
103
|
+
function CardHeader({ className, ...props }: CardHeaderProps) {
|
|
104
|
+
return (
|
|
105
|
+
<div
|
|
106
|
+
data-slot="card-header"
|
|
107
|
+
className={cn('flex flex-1 flex-col gap-1.5 p-6 group-data-inset/card:px-4', className)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
interface CardTitleProps extends React.ComponentPropsWithoutRef<'h3'> {
|
|
114
|
+
/** Render as another element, e.g. `render={<h2 />}`, to fit the page outline. */
|
|
115
|
+
render?: RenderProp
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function CardTitle({ className, render, ...props }: CardTitleProps) {
|
|
119
|
+
return renderElement('h3', render, 'text-foreground-intense text-lg font-semibold', className, {
|
|
120
|
+
'data-slot': 'card-title',
|
|
121
|
+
...props,
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface CardDescriptionProps extends React.ComponentPropsWithoutRef<'p'> {
|
|
126
|
+
/** Render as another element. */
|
|
127
|
+
render?: RenderProp
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function CardDescription({ className, render, ...props }: CardDescriptionProps) {
|
|
131
|
+
return renderElement('p', render, 'text-foreground-muted text-sm', className, {
|
|
132
|
+
'data-slot': 'card-description',
|
|
133
|
+
...props,
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface CardFooterProps extends React.ComponentPropsWithoutRef<'div'> {}
|
|
138
|
+
|
|
139
|
+
function CardFooter({ className, ...props }: CardFooterProps) {
|
|
140
|
+
return (
|
|
141
|
+
<div
|
|
142
|
+
data-slot="card-footer"
|
|
143
|
+
className={cn(
|
|
144
|
+
'flex flex-col-reverse gap-2 px-6 pb-6 sm:flex-row sm:items-center',
|
|
145
|
+
'group-data-inset/card:px-4 group-data-inset/card:pb-4',
|
|
146
|
+
className,
|
|
147
|
+
)}
|
|
148
|
+
{...props}
|
|
149
|
+
/>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export { Card, CardMedia, CardHeader, CardTitle, CardDescription, CardFooter }
|
|
154
|
+
export type { CardProps, CardMediaProps, CardHeaderProps, CardTitleProps, CardDescriptionProps, CardFooterProps }
|
|
@@ -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(
|
|
@@ -490,4 +625,24 @@ describe('a11y', () => {
|
|
|
490
625
|
const { container } = render(<Basic />)
|
|
491
626
|
expect(await axe(container)).toHaveNoViolations()
|
|
492
627
|
})
|
|
628
|
+
|
|
629
|
+
it('has no accessibility violations with a thumbnail rail', async () => {
|
|
630
|
+
const { container } = render(
|
|
631
|
+
<Carousel>
|
|
632
|
+
<CarouselContent>
|
|
633
|
+
<CarouselSlide>Slide 1</CarouselSlide>
|
|
634
|
+
<CarouselSlide>Slide 2</CarouselSlide>
|
|
635
|
+
</CarouselContent>
|
|
636
|
+
<CarouselThumbs>
|
|
637
|
+
<CarouselThumb>
|
|
638
|
+
<img src="/1.jpg" alt="" />
|
|
639
|
+
</CarouselThumb>
|
|
640
|
+
<CarouselThumb>
|
|
641
|
+
<img src="/2.jpg" alt="" />
|
|
642
|
+
</CarouselThumb>
|
|
643
|
+
</CarouselThumbs>
|
|
644
|
+
</Carousel>,
|
|
645
|
+
)
|
|
646
|
+
expect(await axe(container)).toHaveNoViolations()
|
|
647
|
+
})
|
|
493
648
|
})
|