@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
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
5
|
+
import { cn } from '../../internal/utils'
|
|
6
|
+
import { useDirection } from '../../hooks/use-direction'
|
|
7
|
+
import { COLOR_SWATCH_SHAPES, COLOR_SWATCH_SIZES, describeColor, normalizeColor } from '../../internal/color-control'
|
|
8
|
+
import { useColorPickerContext } from '../../internal/color-picker-context'
|
|
9
|
+
import { ColorSwatch } from '../color-swatch/color-swatch'
|
|
10
|
+
import { type Color, formatColor } from '../../lib/color'
|
|
11
|
+
|
|
12
|
+
const ITEM = '[data-slot=color-swatch-picker-item]'
|
|
13
|
+
|
|
14
|
+
type ColorSwatchPickerLayout = 'grid' | 'stack'
|
|
15
|
+
|
|
16
|
+
const pickerVariants = cva('relative isolate flex gap-1', {
|
|
17
|
+
variants: {
|
|
18
|
+
size: COLOR_SWATCH_SIZES,
|
|
19
|
+
layout: {
|
|
20
|
+
grid: 'flex-row flex-wrap',
|
|
21
|
+
stack: 'flex-col',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// The button is the outer ring's box, so the swatch has to sit inside it. At 0.8em
|
|
27
|
+
// the gap either side is 0.1em, which holds at every size because both are ems.
|
|
28
|
+
const itemVariants = cva(
|
|
29
|
+
'outline-ring relative flex size-[1em] shrink-0 transform-gpu cursor-pointer items-center justify-center focus-visible:outline-3 motion-safe:transition motion-safe:duration-250 motion-safe:ease-[cubic-bezier(0.175,0.885,0.32,1.5)] motion-safe:active:translate-y-px motion-safe:active:scale-90 motion-safe:active:duration-100 motion-safe:active:ease-in-out data-disabled:pointer-events-none data-disabled:cursor-default',
|
|
30
|
+
{ variants: { shape: COLOR_SWATCH_SHAPES } },
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
type ColorSwatchPickerSize = NonNullable<VariantProps<typeof pickerVariants>['size']>
|
|
34
|
+
type ColorSwatchPickerShape = NonNullable<VariantProps<typeof itemVariants>['shape']>
|
|
35
|
+
|
|
36
|
+
interface ColorSwatchPickerContextValue {
|
|
37
|
+
colors: Map<string, Color>
|
|
38
|
+
selectedKey: string | null
|
|
39
|
+
select: (color: Color) => void
|
|
40
|
+
shape: ColorSwatchPickerShape
|
|
41
|
+
disabled: boolean
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const ColorSwatchPickerContext = React.createContext<ColorSwatchPickerContextValue | null>(null)
|
|
45
|
+
|
|
46
|
+
function usePickerContext() {
|
|
47
|
+
const context = React.useContext(ColorSwatchPickerContext)
|
|
48
|
+
if (!context) throw new Error('Appica UI: <ColorSwatchPickerItem> must be used within <ColorSwatchPicker>.')
|
|
49
|
+
return context
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Where the indicator sits, in the picker's own coordinates. */
|
|
53
|
+
interface Indicator {
|
|
54
|
+
x: number
|
|
55
|
+
y: number
|
|
56
|
+
width: number
|
|
57
|
+
height: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function sameBox(a: Indicator | null, b: Indicator) {
|
|
61
|
+
return a != null && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The item one row up or down in a wrapped grid, nearest the column the focus is
|
|
66
|
+
* already in. Rows are whatever shares an `offsetTop`, since the wrapping is the
|
|
67
|
+
* browser's to decide.
|
|
68
|
+
*/
|
|
69
|
+
function rowNeighbor(items: HTMLElement[], from: number, step: 1 | -1) {
|
|
70
|
+
const origin = items[from]!
|
|
71
|
+
const beyond = items.filter((item) =>
|
|
72
|
+
step > 0 ? item.offsetTop > origin.offsetTop : item.offsetTop < origin.offsetTop,
|
|
73
|
+
)
|
|
74
|
+
if (beyond.length === 0) return from + step
|
|
75
|
+
|
|
76
|
+
const tops = beyond.map((item) => item.offsetTop)
|
|
77
|
+
const row = step > 0 ? Math.min(...tops) : Math.max(...tops)
|
|
78
|
+
const nearest = beyond
|
|
79
|
+
.filter((item) => item.offsetTop === row)
|
|
80
|
+
.reduce((best, item) =>
|
|
81
|
+
Math.abs(item.offsetLeft - origin.offsetLeft) < Math.abs(best.offsetLeft - origin.offsetLeft) ? item : best,
|
|
82
|
+
)
|
|
83
|
+
return items.indexOf(nearest)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface ColorSwatchPickerProps extends Omit<
|
|
87
|
+
React.ComponentPropsWithoutRef<'div'>,
|
|
88
|
+
'color' | 'defaultValue' | 'onChange'
|
|
89
|
+
> {
|
|
90
|
+
/**
|
|
91
|
+
* Selected color. Pass a `Color` or any CSS color string to control the component.
|
|
92
|
+
* Inside a `ColorPicker` it can be left off: the control then reads and writes the
|
|
93
|
+
* picker's color.
|
|
94
|
+
*/
|
|
95
|
+
value?: Color | string
|
|
96
|
+
/** Color selected before any interaction, when the component is uncontrolled. */
|
|
97
|
+
defaultValue?: Color | string
|
|
98
|
+
/** Fires with the color that was picked. */
|
|
99
|
+
onValueChange?: (value: Color) => void
|
|
100
|
+
/**
|
|
101
|
+
* Wrapping rows of swatches, or a single column.
|
|
102
|
+
* @default 'grid'
|
|
103
|
+
*/
|
|
104
|
+
layout?: ColorSwatchPickerLayout
|
|
105
|
+
/**
|
|
106
|
+
* A preset scale, or a pixel number for an exact size. Sizes the button; the swatch
|
|
107
|
+
* inside is smaller, so the selected ring has somewhere to sit.
|
|
108
|
+
* @default 'md'
|
|
109
|
+
*/
|
|
110
|
+
size?: ColorSwatchPickerSize | number
|
|
111
|
+
/**
|
|
112
|
+
* Rounded square or full circle, applied to every swatch and to the ring.
|
|
113
|
+
* @default 'rounded'
|
|
114
|
+
*/
|
|
115
|
+
shape?: ColorSwatchPickerShape
|
|
116
|
+
/**
|
|
117
|
+
* Prevent interaction and swap every color for a flat muted fill.
|
|
118
|
+
* @default false
|
|
119
|
+
*/
|
|
120
|
+
disabled?: boolean
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function ColorSwatchPicker({
|
|
124
|
+
value,
|
|
125
|
+
defaultValue,
|
|
126
|
+
onValueChange,
|
|
127
|
+
layout = 'grid',
|
|
128
|
+
size = 'md',
|
|
129
|
+
shape = 'rounded',
|
|
130
|
+
disabled: disabledProp,
|
|
131
|
+
className,
|
|
132
|
+
style,
|
|
133
|
+
children,
|
|
134
|
+
...props
|
|
135
|
+
}: ColorSwatchPickerProps) {
|
|
136
|
+
const mirrored = useDirection() === 'rtl'
|
|
137
|
+
const rootRef = React.useRef<HTMLDivElement>(null)
|
|
138
|
+
const colors = React.useMemo(() => new Map<string, Color>(), [])
|
|
139
|
+
const picker = useColorPickerContext()
|
|
140
|
+
|
|
141
|
+
const [uncontrolled, setUncontrolled] = React.useState<Color | null>(() =>
|
|
142
|
+
defaultValue === undefined ? null : normalizeColor(defaultValue),
|
|
143
|
+
)
|
|
144
|
+
const [indicator, setIndicator] = React.useState<Indicator | null>(null)
|
|
145
|
+
|
|
146
|
+
const disabled = disabledProp || (picker?.disabled ?? false)
|
|
147
|
+
const resolved = value !== undefined ? normalizeColor(value) : (picker?.value ?? uncontrolled)
|
|
148
|
+
// Keyed on hexa like React Aria, so the same color written two ways is one entry.
|
|
149
|
+
const selectedKey = resolved === null ? null : formatColor(resolved, 'hexa')
|
|
150
|
+
|
|
151
|
+
const select = (color: Color) => {
|
|
152
|
+
if (value === undefined && !picker) setUncontrolled(color)
|
|
153
|
+
picker?.setValue(color)
|
|
154
|
+
picker?.commitValue(color)
|
|
155
|
+
onValueChange?.(color)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// No dependency list: this mirrors the rendered DOM back into the roving tab stop
|
|
159
|
+
// and the indicator's box, both of which any render can invalidate.
|
|
160
|
+
React.useEffect(() => {
|
|
161
|
+
const root = rootRef.current
|
|
162
|
+
if (!root) return
|
|
163
|
+
|
|
164
|
+
const sync = () => {
|
|
165
|
+
const items = Array.from(root.querySelectorAll<HTMLElement>(ITEM))
|
|
166
|
+
const selected = items.find((item) => item.getAttribute('aria-selected') === 'true')
|
|
167
|
+
const reachable = selected ?? items.find((item) => !item.hasAttribute('data-disabled'))
|
|
168
|
+
for (const item of items) item.tabIndex = item === reachable ? 0 : -1
|
|
169
|
+
|
|
170
|
+
if (!selected) return setIndicator(null)
|
|
171
|
+
const box = {
|
|
172
|
+
x: selected.offsetLeft,
|
|
173
|
+
y: selected.offsetTop,
|
|
174
|
+
width: selected.offsetWidth,
|
|
175
|
+
height: selected.offsetHeight,
|
|
176
|
+
}
|
|
177
|
+
setIndicator((previous) => (sameBox(previous, box) ? previous : box))
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
sync()
|
|
181
|
+
if (typeof ResizeObserver === 'undefined') return
|
|
182
|
+
const observer = new ResizeObserver(sync)
|
|
183
|
+
observer.observe(root)
|
|
184
|
+
return () => observer.disconnect()
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
188
|
+
const root = rootRef.current
|
|
189
|
+
if (!root) return
|
|
190
|
+
const items = Array.from(root.querySelectorAll<HTMLElement>(`${ITEM}:not([data-disabled])`))
|
|
191
|
+
const current = items.indexOf(document.activeElement as HTMLElement)
|
|
192
|
+
if (current < 0) return
|
|
193
|
+
|
|
194
|
+
const stack = layout === 'stack'
|
|
195
|
+
const forward = mirrored ? 'ArrowLeft' : 'ArrowRight'
|
|
196
|
+
const backward = mirrored ? 'ArrowRight' : 'ArrowLeft'
|
|
197
|
+
|
|
198
|
+
const next =
|
|
199
|
+
event.key === 'Home'
|
|
200
|
+
? 0
|
|
201
|
+
: event.key === 'End'
|
|
202
|
+
? items.length - 1
|
|
203
|
+
: event.key === forward
|
|
204
|
+
? current + 1
|
|
205
|
+
: event.key === backward
|
|
206
|
+
? current - 1
|
|
207
|
+
: event.key === 'ArrowDown'
|
|
208
|
+
? stack
|
|
209
|
+
? current + 1
|
|
210
|
+
: rowNeighbor(items, current, 1)
|
|
211
|
+
: event.key === 'ArrowUp'
|
|
212
|
+
? stack
|
|
213
|
+
? current - 1
|
|
214
|
+
: rowNeighbor(items, current, -1)
|
|
215
|
+
: NaN
|
|
216
|
+
if (Number.isNaN(next)) return
|
|
217
|
+
|
|
218
|
+
event.preventDefault()
|
|
219
|
+
const target = items[(next + items.length) % items.length]
|
|
220
|
+
if (!target) return
|
|
221
|
+
target.focus()
|
|
222
|
+
// Selection follows focus, which is what a single-select listbox is expected to
|
|
223
|
+
// do and what makes arrowing through a palette worth doing at all.
|
|
224
|
+
const color = colors.get(target.dataset.value ?? '')
|
|
225
|
+
if (color) select(color)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const isNumeric = typeof size === 'number'
|
|
229
|
+
const context: ColorSwatchPickerContextValue = { colors, selectedKey, select, shape, disabled }
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<ColorSwatchPickerContext.Provider value={context}>
|
|
233
|
+
<div
|
|
234
|
+
ref={rootRef}
|
|
235
|
+
role="listbox"
|
|
236
|
+
aria-orientation={layout === 'stack' ? 'vertical' : 'horizontal'}
|
|
237
|
+
{...props}
|
|
238
|
+
data-slot="color-swatch-picker"
|
|
239
|
+
data-layout={layout}
|
|
240
|
+
{...(disabled ? { 'data-disabled': '' } : {})}
|
|
241
|
+
className={cn(pickerVariants({ layout, size: isNumeric ? undefined : size }), className)}
|
|
242
|
+
style={{ ...(isNumeric ? { fontSize: `${size}px` } : undefined), ...style }}
|
|
243
|
+
onKeyDown={handleKeyDown}
|
|
244
|
+
>
|
|
245
|
+
{children}
|
|
246
|
+
|
|
247
|
+
{indicator && (
|
|
248
|
+
<span
|
|
249
|
+
aria-hidden="true"
|
|
250
|
+
data-slot="color-swatch-picker-indicator"
|
|
251
|
+
className={cn(
|
|
252
|
+
'border-border-inverse pointer-events-none absolute top-0 left-0 z-10 border',
|
|
253
|
+
COLOR_SWATCH_SHAPES[shape],
|
|
254
|
+
'motion-safe:transition-[translate,width,height] motion-safe:duration-250',
|
|
255
|
+
)}
|
|
256
|
+
style={{
|
|
257
|
+
translate: `${indicator.x}px ${indicator.y}px`,
|
|
258
|
+
width: indicator.width,
|
|
259
|
+
height: indicator.height,
|
|
260
|
+
}}
|
|
261
|
+
/>
|
|
262
|
+
)}
|
|
263
|
+
</div>
|
|
264
|
+
</ColorSwatchPickerContext.Provider>
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
interface ColorSwatchPickerItemProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'color' | 'value'> {
|
|
269
|
+
/** Color this swatch offers. Pass a `Color` or any CSS color string. */
|
|
270
|
+
color: Color | string
|
|
271
|
+
/** Name announced for the color, in place of the description built from the color itself. */
|
|
272
|
+
colorName?: string
|
|
273
|
+
/**
|
|
274
|
+
* Prevent this swatch from being picked, and swap its color for a flat muted fill.
|
|
275
|
+
* @default false
|
|
276
|
+
*/
|
|
277
|
+
disabled?: boolean
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function ColorSwatchPickerItem({
|
|
281
|
+
color,
|
|
282
|
+
colorName,
|
|
283
|
+
disabled = false,
|
|
284
|
+
className,
|
|
285
|
+
children,
|
|
286
|
+
...props
|
|
287
|
+
}: ColorSwatchPickerItemProps) {
|
|
288
|
+
const { colors, selectedKey, select, shape, disabled: pickerDisabled } = usePickerContext()
|
|
289
|
+
|
|
290
|
+
const resolved = React.useMemo(() => normalizeColor(color), [color])
|
|
291
|
+
const key = formatColor(resolved, 'hexa')
|
|
292
|
+
const selected = selectedKey === key
|
|
293
|
+
const off = disabled || pickerDisabled
|
|
294
|
+
|
|
295
|
+
React.useEffect(() => {
|
|
296
|
+
colors.set(key, resolved)
|
|
297
|
+
return () => {
|
|
298
|
+
colors.delete(key)
|
|
299
|
+
}
|
|
300
|
+
}, [colors, key, resolved])
|
|
301
|
+
|
|
302
|
+
return (
|
|
303
|
+
<button
|
|
304
|
+
type="button"
|
|
305
|
+
role="option"
|
|
306
|
+
aria-selected={selected}
|
|
307
|
+
aria-label={colorName ?? describeColor(resolved)}
|
|
308
|
+
{...props}
|
|
309
|
+
data-slot="color-swatch-picker-item"
|
|
310
|
+
data-value={key}
|
|
311
|
+
{...(off ? { 'data-disabled': '', disabled: true } : {})}
|
|
312
|
+
tabIndex={-1}
|
|
313
|
+
className={cn(itemVariants({ shape }), className)}
|
|
314
|
+
onClick={(event) => {
|
|
315
|
+
props.onClick?.(event)
|
|
316
|
+
if (!event.defaultPrevented) select(resolved)
|
|
317
|
+
}}
|
|
318
|
+
>
|
|
319
|
+
{/* The button carries the name, so a second one on the swatch would double it. */}
|
|
320
|
+
<ColorSwatch aria-hidden="true" color={resolved} shape={shape} disabled={off} className="text-[0.8em]" />
|
|
321
|
+
{children}
|
|
322
|
+
</button>
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export { ColorSwatchPicker, ColorSwatchPickerItem }
|
|
327
|
+
export type { ColorSwatchPickerProps, ColorSwatchPickerItemProps }
|
|
@@ -355,7 +355,7 @@ describe('Combobox', () => {
|
|
|
355
355
|
)
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
it('forwards grid to Base UI Root
|
|
358
|
+
it('forwards grid to Base UI Root - popup uses the grid role', async () => {
|
|
359
359
|
const user = setupUser()
|
|
360
360
|
renderGrid()
|
|
361
361
|
await user.click(screen.getByRole('combobox'))
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { Combobox as BaseCombobox } from '@base-ui/react/combobox'
|
|
5
5
|
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
6
|
-
import { cn } from '../../utils'
|
|
7
|
-
import { type FloatingContentProps, splitFloatingProps } from '../../floating'
|
|
6
|
+
import { cn } from '../../internal/utils'
|
|
7
|
+
import { type FloatingContentProps, splitFloatingProps } from '../../internal/floating'
|
|
8
8
|
import { inputVariants } from '../input/input-variants'
|
|
9
9
|
import { buttonVariants } from '../button/button-variants'
|
|
10
10
|
|
|
@@ -33,9 +33,25 @@ function useComboboxContext() {
|
|
|
33
33
|
type BaseComboboxRootProps = React.ComponentProps<typeof BaseCombobox.Root>
|
|
34
34
|
|
|
35
35
|
interface ComboboxProps extends BaseComboboxRootProps {
|
|
36
|
+
/**
|
|
37
|
+
* Input height, popup radius, and item sizing.
|
|
38
|
+
* @default 'md'
|
|
39
|
+
*/
|
|
36
40
|
size?: ComboboxSize
|
|
41
|
+
/**
|
|
42
|
+
* Input appearance - bordered or filled.
|
|
43
|
+
* @default 'outline'
|
|
44
|
+
*/
|
|
37
45
|
variant?: ComboboxVariant
|
|
46
|
+
/**
|
|
47
|
+
* Render a clear button inside the input when a value is present.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
38
50
|
clearable?: boolean
|
|
51
|
+
/**
|
|
52
|
+
* Render a chevron button that toggles the popup.
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
39
55
|
icon?: boolean
|
|
40
56
|
}
|
|
41
57
|
|
|
@@ -69,7 +85,9 @@ const ICON_SIZE: Record<ComboboxSize, string> = {
|
|
|
69
85
|
}
|
|
70
86
|
|
|
71
87
|
interface ComboboxInputProps extends Omit<React.ComponentProps<typeof BaseCombobox.Input>, 'size'> {
|
|
88
|
+
/** Adornment rendered before the field, inside the input frame. */
|
|
72
89
|
startSlot?: React.ReactNode
|
|
90
|
+
/** Adornment rendered after the field, before the controls. */
|
|
73
91
|
endSlot?: React.ReactNode
|
|
74
92
|
}
|
|
75
93
|
|
|
@@ -107,7 +125,9 @@ function ComboboxInput({ className, startSlot, endSlot, placeholder, ...props }:
|
|
|
107
125
|
}
|
|
108
126
|
|
|
109
127
|
interface ComboboxChipsProps extends React.ComponentProps<typeof BaseCombobox.InputGroup> {
|
|
128
|
+
/** Placeholder for the inline text field. */
|
|
110
129
|
placeholder?: string
|
|
130
|
+
/** Props forwarded to the inner text `input`. */
|
|
111
131
|
inputProps?: Omit<React.ComponentProps<typeof BaseCombobox.Input>, 'placeholder'>
|
|
112
132
|
}
|
|
113
133
|
|
|
@@ -185,7 +205,9 @@ function ComboboxToggleButton() {
|
|
|
185
205
|
}
|
|
186
206
|
|
|
187
207
|
interface ComboboxTriggerProps extends React.ComponentProps<typeof BaseCombobox.Trigger> {
|
|
208
|
+
/** Adornment before the value, inside the trigger frame. */
|
|
188
209
|
startSlot?: React.ReactNode
|
|
210
|
+
/** Adornment after the value, before the chevron. */
|
|
189
211
|
endSlot?: React.ReactNode
|
|
190
212
|
}
|
|
191
213
|
|
|
@@ -339,7 +361,9 @@ function ComboboxContent({ className, children, ...props }: ComboboxContentProps
|
|
|
339
361
|
}
|
|
340
362
|
|
|
341
363
|
interface ComboboxListProps<T = any> extends Omit<React.ComponentProps<typeof BaseCombobox.List>, 'children'> {
|
|
364
|
+
/** Items per row in grid mode (defaults to 2 when `grid` is set). */
|
|
342
365
|
cols?: number
|
|
366
|
+
/** A render function over the filtered items, or static `ComboboxItem`s. */
|
|
343
367
|
children?: React.ReactNode | ((item: T, index: number) => React.ReactNode)
|
|
344
368
|
}
|
|
345
369
|
|
|
@@ -86,6 +86,34 @@ describe('ContextMenu', () => {
|
|
|
86
86
|
expect(item.className).toContain('text-base')
|
|
87
87
|
})
|
|
88
88
|
|
|
89
|
+
it('marks every item kind with data-orientation="vertical"', async () => {
|
|
90
|
+
const user = setupUser()
|
|
91
|
+
render(
|
|
92
|
+
<ContextMenu>
|
|
93
|
+
<ContextMenuTrigger data-testid="trigger">Right click here</ContextMenuTrigger>
|
|
94
|
+
<ContextMenuContent>
|
|
95
|
+
<ContextMenuItem>Item</ContextMenuItem>
|
|
96
|
+
<ContextMenuLinkItem href="https://example.com">Link</ContextMenuLinkItem>
|
|
97
|
+
<ContextMenuCheckboxItem>Check</ContextMenuCheckboxItem>
|
|
98
|
+
<ContextMenuRadioGroup value="a">
|
|
99
|
+
<ContextMenuRadioItem value="a">Radio</ContextMenuRadioItem>
|
|
100
|
+
</ContextMenuRadioGroup>
|
|
101
|
+
<ContextMenuSub>
|
|
102
|
+
<ContextMenuSubTrigger>More</ContextMenuSubTrigger>
|
|
103
|
+
<ContextMenuSubContent>
|
|
104
|
+
<ContextMenuItem>Nested</ContextMenuItem>
|
|
105
|
+
</ContextMenuSubContent>
|
|
106
|
+
</ContextMenuSub>
|
|
107
|
+
</ContextMenuContent>
|
|
108
|
+
</ContextMenu>,
|
|
109
|
+
)
|
|
110
|
+
await user.pointer({ keys: '[MouseRight]', target: screen.getByTestId('trigger') })
|
|
111
|
+
await screen.findByRole('menuitem', { name: 'Item' })
|
|
112
|
+
const items = document.querySelectorAll('[data-slot$="-item"], [data-slot="context-menu-sub-trigger"]')
|
|
113
|
+
expect(items).toHaveLength(5)
|
|
114
|
+
items.forEach((item) => expect(item).toHaveAttribute('data-orientation', 'vertical'))
|
|
115
|
+
})
|
|
116
|
+
|
|
89
117
|
it('renders the popup with size-driven radius', async () => {
|
|
90
118
|
const user = setupUser()
|
|
91
119
|
render(<BasicMenu size="sm" />)
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { ContextMenu as BaseContextMenu } from '@base-ui/react/context-menu'
|
|
5
5
|
import { useReducedMotion } from '../../hooks/use-reduced-motion'
|
|
6
|
-
import { cn } from '../../utils'
|
|
7
|
-
import { type FloatingContentProps, splitFloatingProps } from '../../floating'
|
|
6
|
+
import { cn } from '../../internal/utils'
|
|
7
|
+
import { type FloatingContentProps, splitFloatingProps } from '../../internal/floating'
|
|
8
8
|
import { navigationLinkVariants } from '../navigation/navigation-link-variants'
|
|
9
9
|
|
|
10
10
|
type ContextMenuSize = 'sm' | 'md' | 'lg'
|
|
@@ -27,6 +27,10 @@ function useContextMenuContext() {
|
|
|
27
27
|
type BaseRootProps = React.ComponentProps<typeof BaseContextMenu.Root>
|
|
28
28
|
|
|
29
29
|
interface ContextMenuProps extends BaseRootProps {
|
|
30
|
+
/**
|
|
31
|
+
* Scales the popup radius, item padding, and icon size.
|
|
32
|
+
* @default 'md'
|
|
33
|
+
*/
|
|
30
34
|
size?: ContextMenuSize
|
|
31
35
|
}
|
|
32
36
|
|
|
@@ -60,7 +64,7 @@ const ICON_SIZE: Record<ContextMenuSize, string> = {
|
|
|
60
64
|
|
|
61
65
|
function popupClassName(size: ContextMenuSize, className?: string) {
|
|
62
66
|
return cn(
|
|
63
|
-
'max-h-(--available-height) bg-background border-border-overlay flex flex-col border shadow-2xl outline-none
|
|
67
|
+
'max-h-(--available-height) bg-background border-border-overlay flex flex-col border shadow-2xl outline-none',
|
|
64
68
|
POPUP_SIZE[size],
|
|
65
69
|
'origin-(--transform-origin)',
|
|
66
70
|
'motion-safe:transition-[opacity,scale] motion-safe:duration-200 motion-safe:ease-[cubic-bezier(0.175,0.885,0.32,1.5)]',
|
|
@@ -77,6 +81,7 @@ type ContextMenuFloatingProps = FloatingContentProps<
|
|
|
77
81
|
|
|
78
82
|
type ContextMenuContentProps = Omit<React.ComponentProps<typeof BaseContextMenu.Popup>, 'className'> &
|
|
79
83
|
ContextMenuFloatingProps & {
|
|
84
|
+
/** Extra classes on the popup. */
|
|
80
85
|
className?: string
|
|
81
86
|
}
|
|
82
87
|
|
|
@@ -92,7 +97,7 @@ function ContextMenuContent({ className, children, ...props }: ContextMenuConten
|
|
|
92
97
|
className={cn('isolate z-50', positioner.className as string | undefined)}
|
|
93
98
|
>
|
|
94
99
|
<BaseContextMenu.Popup data-slot="context-menu-content" className={popupClassName(size, className)} {...popup}>
|
|
95
|
-
<div className="flex flex-col gap-0.5 overflow-x-hidden overflow-y-auto
|
|
100
|
+
<div className="flex flex-col gap-0.5 overflow-x-hidden overflow-y-auto p-2">{children}</div>
|
|
96
101
|
</BaseContextMenu.Popup>
|
|
97
102
|
</BaseContextMenu.Positioner>
|
|
98
103
|
</BaseContextMenu.Portal>
|
|
@@ -114,6 +119,7 @@ function ContextMenuItem({ className, ...props }: ContextMenuItemProps) {
|
|
|
114
119
|
return (
|
|
115
120
|
<BaseContextMenu.Item
|
|
116
121
|
data-slot="context-menu-item"
|
|
122
|
+
data-orientation="vertical"
|
|
117
123
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, className)}
|
|
118
124
|
{...props}
|
|
119
125
|
/>
|
|
@@ -127,6 +133,7 @@ function ContextMenuLinkItem({ className, ...props }: ContextMenuLinkItemProps)
|
|
|
127
133
|
return (
|
|
128
134
|
<BaseContextMenu.LinkItem
|
|
129
135
|
data-slot="context-menu-link-item"
|
|
136
|
+
data-orientation="vertical"
|
|
130
137
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, className)}
|
|
131
138
|
{...props}
|
|
132
139
|
/>
|
|
@@ -183,6 +190,7 @@ function ContextMenuRadioItem({ className, children, ...props }: ContextMenuRadi
|
|
|
183
190
|
return (
|
|
184
191
|
<BaseContextMenu.RadioItem
|
|
185
192
|
data-slot="context-menu-radio-item"
|
|
193
|
+
data-orientation="vertical"
|
|
186
194
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
187
195
|
{...props}
|
|
188
196
|
>
|
|
@@ -205,6 +213,7 @@ function ContextMenuCheckboxItem({ className, children, ...props }: ContextMenuC
|
|
|
205
213
|
return (
|
|
206
214
|
<BaseContextMenu.CheckboxItem
|
|
207
215
|
data-slot="context-menu-checkbox-item"
|
|
216
|
+
data-orientation="vertical"
|
|
208
217
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
209
218
|
{...props}
|
|
210
219
|
>
|
|
@@ -234,6 +243,7 @@ function ContextMenuSubTrigger({ className, children, ...props }: ContextMenuSub
|
|
|
234
243
|
<BaseContextMenu.SubmenuTrigger className="group/submenu-trigger outline-hidden" {...props}>
|
|
235
244
|
<span
|
|
236
245
|
data-slot="context-menu-sub-trigger"
|
|
246
|
+
data-orientation="vertical"
|
|
237
247
|
className={cn(navigationLinkVariants({ variant: 'pill', size }), ITEM_BASE, 'justify-between', className)}
|
|
238
248
|
>
|
|
239
249
|
<span className={cn('flex flex-1 items-center', ITEM_TEXT[size])}>{children}</span>
|
|
@@ -245,6 +255,7 @@ function ContextMenuSubTrigger({ className, children, ...props }: ContextMenuSub
|
|
|
245
255
|
|
|
246
256
|
type ContextMenuSubContentProps = Omit<React.ComponentProps<typeof BaseContextMenu.Popup>, 'className'> &
|
|
247
257
|
ContextMenuFloatingProps & {
|
|
258
|
+
/** Extra classes on the submenu popup. */
|
|
248
259
|
className?: string
|
|
249
260
|
}
|
|
250
261
|
|
|
@@ -265,7 +276,7 @@ function ContextMenuSubContent({ className, children, ...props }: ContextMenuSub
|
|
|
265
276
|
className={popupClassName(size, cn('w-(--anchor-width)', className))}
|
|
266
277
|
{...popup}
|
|
267
278
|
>
|
|
268
|
-
<div className="flex flex-col gap-0.5 overflow-x-hidden overflow-y-auto
|
|
279
|
+
<div className="flex flex-col gap-0.5 overflow-x-hidden overflow-y-auto p-2">{children}</div>
|
|
269
280
|
</BaseContextMenu.Popup>
|
|
270
281
|
</BaseContextMenu.Positioner>
|
|
271
282
|
</BaseContextMenu.Portal>
|
|
@@ -6,7 +6,7 @@ import { axe } from 'vitest-axe'
|
|
|
6
6
|
import { CopyButton } from './copy-button'
|
|
7
7
|
|
|
8
8
|
// userEvent.setup() installs its own navigator.clipboard stub, so the spy
|
|
9
|
-
// must be created after setup()
|
|
9
|
+
// must be created after setup() - a beforeEach mock would get replaced.
|
|
10
10
|
function setup() {
|
|
11
11
|
const user = userEvent.setup()
|
|
12
12
|
const writeText = vi.spyOn(navigator.clipboard, 'writeText')
|
|
@@ -39,6 +39,19 @@ describe('CopyButton', () => {
|
|
|
39
39
|
expect(screen.getAllByText('Copied').length).toBeGreaterThanOrEqual(1)
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
+
it('renders a custom resting icon in place of the copy glyph and still swaps to the check', async () => {
|
|
43
|
+
const { user } = setup()
|
|
44
|
+
render(<CopyButton value="hello" icon={<svg data-testid="link-icon" />} />)
|
|
45
|
+
const button = screen.getByRole('button', { name: 'Copy' })
|
|
46
|
+
expect(screen.getByTestId('link-icon')).toBeInTheDocument()
|
|
47
|
+
expect(button.querySelectorAll('svg')).toHaveLength(2)
|
|
48
|
+
|
|
49
|
+
await user.click(button)
|
|
50
|
+
|
|
51
|
+
await waitFor(() => expect(button).toHaveAttribute('data-copied'))
|
|
52
|
+
expect(screen.getByTestId('link-icon')).toBeInTheDocument()
|
|
53
|
+
})
|
|
54
|
+
|
|
42
55
|
it('copies the string value on click', async () => {
|
|
43
56
|
const { user, writeText } = setup()
|
|
44
57
|
const onCopy = vi.fn()
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { Button, type ButtonProps } from '../button/button'
|
|
6
6
|
|
|
7
7
|
const CHECK_PATH = 'M4.3 12.55 L9.25 17.5 L19.7 6.5'
|
|
@@ -48,12 +48,29 @@ async function copyTextToClipboard(text: string): Promise<void> {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
interface CopyButtonProps extends Omit<ButtonProps, 'value' | 'onCopy'> {
|
|
51
|
+
/** **Required.** What to copy: a string, an element ref (its value/textContent), or a (possibly async) getter. */
|
|
51
52
|
value: CopyButtonValue
|
|
53
|
+
/**
|
|
54
|
+
* How long (ms) the copied state lasts before reverting.
|
|
55
|
+
* @default 2000
|
|
56
|
+
*/
|
|
52
57
|
timeout?: number
|
|
58
|
+
/**
|
|
59
|
+
* Accessible name (and tooltip via `title`) in the idle state.
|
|
60
|
+
* @default 'Copy'
|
|
61
|
+
*/
|
|
53
62
|
label?: string
|
|
63
|
+
/**
|
|
64
|
+
* Accessible name after a successful copy; a string child also swaps to this.
|
|
65
|
+
* @default 'Copied'
|
|
66
|
+
*/
|
|
54
67
|
copiedLabel?: string
|
|
68
|
+
/** Called with the copied text on success. */
|
|
55
69
|
onCopy?: (value: string) => void
|
|
70
|
+
/** Called if reading the value or writing to the clipboard fails. */
|
|
56
71
|
onCopyError?: (error: unknown) => void
|
|
72
|
+
/** Icon shown at rest, cross-faded to the drawn check after a copy. Defaults to a built-in copy glyph. */
|
|
73
|
+
icon?: React.ReactNode
|
|
57
74
|
}
|
|
58
75
|
|
|
59
76
|
function CopyButton({
|
|
@@ -63,6 +80,7 @@ function CopyButton({
|
|
|
63
80
|
copiedLabel = 'Copied',
|
|
64
81
|
onCopy,
|
|
65
82
|
onCopyError,
|
|
83
|
+
icon,
|
|
66
84
|
onClick,
|
|
67
85
|
variant = 'ghost',
|
|
68
86
|
size = 'icon-sm',
|
|
@@ -105,16 +123,19 @@ function CopyButton({
|
|
|
105
123
|
{...props}
|
|
106
124
|
>
|
|
107
125
|
<span data-icon={children != null ? 'start' : undefined} className="grid place-items-center *:[grid-area:1/1]">
|
|
108
|
-
<
|
|
109
|
-
{...ICON_SVG_PROPS}
|
|
126
|
+
<span
|
|
110
127
|
className={cn(
|
|
111
|
-
'transition-[opacity,scale] delay-150 duration-150 ease-out group-data-copied/copy:delay-0',
|
|
128
|
+
'grid place-items-center transition-[opacity,scale] delay-150 duration-150 ease-out group-data-copied/copy:delay-0',
|
|
112
129
|
'group-data-copied/copy:scale-50 group-data-copied/copy:opacity-0',
|
|
113
130
|
'motion-reduce:transition-none',
|
|
114
131
|
)}
|
|
115
132
|
>
|
|
116
|
-
|
|
117
|
-
|
|
133
|
+
{icon ?? (
|
|
134
|
+
<svg {...ICON_SVG_PROPS}>
|
|
135
|
+
<path d="M4.012 16.737c-.307-.175-.562-.427-.739-.732S3.001 15.353 3 15V5c0-1.1.9-2 2-2h10c.75 0 1.158.385 1.5 1M7 9.667c0-.707.281-1.386.781-1.886S8.96 7 9.667 7h8.666c.35 0 .697.069 1.021.203s.618.33.865.578.444.542.578.865A2.67 2.67 0 0 1 21 9.667v8.666a2.67 2.67 0 0 1-.781 1.886 2.67 2.67 0 0 1-1.886.781H9.667a2.67 2.67 0 0 1-1.021-.203c-.324-.134-.618-.331-.865-.578s-.444-.542-.578-.865S7 18.683 7 18.333V9.667z" />
|
|
136
|
+
</svg>
|
|
137
|
+
)}
|
|
138
|
+
</span>
|
|
118
139
|
<svg {...ICON_SVG_PROPS}>
|
|
119
140
|
<path
|
|
120
141
|
d={CHECK_PATH}
|