@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,34 @@
|
|
|
1
|
+
function srgbToLinear(c) {
|
|
2
|
+
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
3
|
+
}
|
|
4
|
+
function linearToSrgb(c) {
|
|
5
|
+
return c <= 31308e-7 ? c * 12.92 : 1.055 * c ** (1 / 2.4) - 0.055;
|
|
6
|
+
}
|
|
7
|
+
function linearRgbToOklab(r, g, b) {
|
|
8
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
9
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
10
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
11
|
+
return [
|
|
12
|
+
0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
|
|
13
|
+
1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
|
|
14
|
+
0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
function oklabToLinearRgb(L, a, b) {
|
|
18
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
19
|
+
const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
20
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
21
|
+
return [
|
|
22
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
23
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
24
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
function oklchToSrgb(L, chroma, hue) {
|
|
28
|
+
const radians = hue * Math.PI / 180;
|
|
29
|
+
const linear = oklabToLinearRgb(L, chroma * Math.cos(radians), chroma * Math.sin(radians));
|
|
30
|
+
return [linearToSrgb(linear[0]), linearToSrgb(linear[1]), linearToSrgb(linear[2])];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { linearRgbToOklab, linearToSrgb, oklabToLinearRgb, oklchToSrgb, srgbToLinear };
|
|
34
|
+
//# sourceMappingURL=color-math.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-math.js","sources":["../../src/internal/color-math.ts"],"sourcesContent":["// Matrix conversions behind lib/color.ts, kept apart from its object API and\n// clamping rules. Internal - nothing here is re-exported from the package.\n// Units are native: sRGB and linear components 0-1, OKLab L 0-1, hue in degrees.\n\n/** Applies the sRGB transfer function in reverse, giving linear light. */\nexport function srgbToLinear(c: number): number {\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n}\n\n/** Applies the sRGB transfer function, giving an encoded component. */\nexport function linearToSrgb(c: number): number {\n return c <= 0.0031308 ? c * 12.92 : 1.055 * c ** (1 / 2.4) - 0.055\n}\n\n// Matrices are Björn Ottosson's reference values, https://bottosson.github.io/posts/oklab/.\n\nexport function linearRgbToOklab(r: number, g: number, b: number): [number, number, number] {\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b)\n return [\n 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,\n 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,\n 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,\n ]\n}\n\nexport function oklabToLinearRgb(L: number, a: number, b: number): [number, number, number] {\n const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3\n const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3\n const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3\n return [\n 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n ]\n}\n\n/** Converts OKLCh to encoded sRGB components, without clamping. */\nexport function oklchToSrgb(L: number, chroma: number, hue: number): [number, number, number] {\n const radians = (hue * Math.PI) / 180\n const linear = oklabToLinearRgb(L, chroma * Math.cos(radians), chroma * Math.sin(radians))\n return [linearToSrgb(linear[0]), linearToSrgb(linear[1]), linearToSrgb(linear[2])]\n}\n"],"names":[],"mappings":"AAKO,SAAS,aAAa,CAAA,EAAmB;AAC9C,EAAA,OAAO,KAAK,OAAA,GAAU,CAAA,GAAI,KAAA,GAAA,CAAA,CAAU,CAAA,GAAI,SAAS,KAAA,KAAU,GAAA;AAC7D;AAGO,SAAS,aAAa,CAAA,EAAmB;AAC9C,EAAA,OAAO,KAAK,QAAA,GAAY,CAAA,GAAI,QAAQ,KAAA,GAAQ,CAAA,KAAM,IAAI,GAAA,CAAA,GAAO,KAAA;AAC/D;AAIO,SAAS,gBAAA,CAAiB,CAAA,EAAW,CAAA,EAAW,CAAA,EAAqC;AAC1F,EAAA,MAAM,CAAA,GAAI,KAAK,IAAA,CAAK,YAAA,GAAe,IAAI,YAAA,GAAe,CAAA,GAAI,eAAe,CAAC,CAAA;AAC1E,EAAA,MAAM,CAAA,GAAI,KAAK,IAAA,CAAK,YAAA,GAAe,IAAI,YAAA,GAAe,CAAA,GAAI,eAAe,CAAC,CAAA;AAC1E,EAAA,MAAM,CAAA,GAAI,KAAK,IAAA,CAAK,YAAA,GAAe,IAAI,YAAA,GAAe,CAAA,GAAI,eAAe,CAAC,CAAA;AAC1E,EAAA,OAAO;AAAA,IACL,YAAA,GAAe,CAAA,GAAI,WAAA,GAAc,CAAA,GAAI,YAAA,GAAe,CAAA;AAAA,IACpD,YAAA,GAAe,CAAA,GAAI,WAAA,GAAc,CAAA,GAAI,YAAA,GAAe,CAAA;AAAA,IACpD,YAAA,GAAe,CAAA,GAAI,YAAA,GAAe,CAAA,GAAI,WAAA,GAAc;AAAA,GACtD;AACF;AAEO,SAAS,gBAAA,CAAiB,CAAA,EAAW,CAAA,EAAW,CAAA,EAAqC;AAC1F,EAAA,MAAM,CAAA,GAAA,CAAK,CAAA,GAAI,YAAA,GAAe,CAAA,GAAI,eAAe,CAAA,KAAM,CAAA;AACvD,EAAA,MAAM,CAAA,GAAA,CAAK,CAAA,GAAI,YAAA,GAAe,CAAA,GAAI,eAAe,CAAA,KAAM,CAAA;AACvD,EAAA,MAAM,CAAA,GAAA,CAAK,CAAA,GAAI,YAAA,GAAe,CAAA,GAAI,cAAc,CAAA,KAAM,CAAA;AACtD,EAAA,OAAO;AAAA,IACL,YAAA,GAAe,CAAA,GAAI,YAAA,GAAe,CAAA,GAAI,YAAA,GAAe,CAAA;AAAA,IACrD,aAAA,GAAgB,CAAA,GAAI,YAAA,GAAe,CAAA,GAAI,YAAA,GAAe,CAAA;AAAA,IACtD,aAAA,GAAgB,CAAA,GAAI,YAAA,GAAe,CAAA,GAAI,WAAA,GAAc;AAAA,GACvD;AACF;AAGO,SAAS,WAAA,CAAY,CAAA,EAAW,MAAA,EAAgB,GAAA,EAAuC;AAC5F,EAAA,MAAM,OAAA,GAAW,GAAA,GAAM,IAAA,CAAK,EAAA,GAAM,GAAA;AAClC,EAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,CAAA,EAAG,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,OAAO,CAAA,EAAG,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,OAAO,CAAC,CAAA;AACzF,EAAA,OAAO,CAAC,YAAA,CAAa,MAAA,CAAO,CAAC,CAAC,CAAA,EAAG,YAAA,CAAa,MAAA,CAAO,CAAC,CAAC,CAAA,EAAG,YAAA,CAAa,MAAA,CAAO,CAAC,CAAC,CAAC,CAAA;AACnF;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Color, ColorFormat } from '../lib/color';
|
|
3
|
+
export interface ColorPickerContextValue {
|
|
4
|
+
value: Color;
|
|
5
|
+
setValue: (color: Color) => void;
|
|
6
|
+
commitValue: (color: Color) => void;
|
|
7
|
+
format: ColorFormat;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const ColorPickerContext: React.Context<ColorPickerContextValue | null>;
|
|
11
|
+
/** The enclosing picker, or `null` when the control stands on its own. */
|
|
12
|
+
export declare function useColorPickerContext(): ColorPickerContextValue | null;
|
|
13
|
+
/** The enclosing picker, for the parts that only exist inside one. */
|
|
14
|
+
export declare function useRequiredColorPickerContext(part: string): ColorPickerContextValue;
|
|
15
|
+
export interface ColorControlOptions {
|
|
16
|
+
value?: Color | string;
|
|
17
|
+
defaultValue: Color | string;
|
|
18
|
+
onValueChange?: (value: Color) => void;
|
|
19
|
+
onValueCommitted?: (value: Color) => void;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface ColorControl {
|
|
23
|
+
color: Color;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
setColor: (color: Color) => void;
|
|
26
|
+
commitColor: (color: Color) => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolves a control's color from, in order: its own `value`, the enclosing picker,
|
|
30
|
+
* its own state. Writes go to the picker and to the callbacks either way, so a
|
|
31
|
+
* control stays reportable even when the picker owns the value.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useColorControl({ value, defaultValue, onValueChange, onValueCommitted, disabled, }: ColorControlOptions): ColorControl;
|
|
34
|
+
//# sourceMappingURL=color-picker-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-picker-context.d.ts","sourceRoot":"","sources":["../../src/internal/color-picker-context.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAEtD,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACnC,MAAM,EAAE,WAAW,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,kBAAkB,+CAA4D,CAAA;AAE3F,0EAA0E;AAC1E,wBAAgB,qBAAqB,IAAI,uBAAuB,GAAG,IAAI,CAEtE;AAED,sEAAsE;AACtE,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,uBAAuB,CAInF;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IACtB,YAAY,EAAE,KAAK,GAAG,MAAM,CAAA;IAC5B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACtC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACpC;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,QAAgB,GACjB,EAAE,mBAAmB,GAAG,YAAY,CAoBpC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { normalizeColor } from './color-control.js';
|
|
4
|
+
|
|
5
|
+
const ColorPickerContext = React.createContext(null);
|
|
6
|
+
function useColorPickerContext() {
|
|
7
|
+
return React.useContext(ColorPickerContext);
|
|
8
|
+
}
|
|
9
|
+
function useRequiredColorPickerContext(part) {
|
|
10
|
+
const context = React.useContext(ColorPickerContext);
|
|
11
|
+
if (!context) throw new Error(`Appica UI: <${part}> must be used within <ColorPicker>.`);
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
14
|
+
function useColorControl({
|
|
15
|
+
value,
|
|
16
|
+
defaultValue,
|
|
17
|
+
onValueChange,
|
|
18
|
+
onValueCommitted,
|
|
19
|
+
disabled = false
|
|
20
|
+
}) {
|
|
21
|
+
const picker = useColorPickerContext();
|
|
22
|
+
const [uncontrolled, setUncontrolled] = React.useState(() => normalizeColor(defaultValue));
|
|
23
|
+
const controlled = value !== void 0;
|
|
24
|
+
const color = controlled ? normalizeColor(value) : picker?.value ?? uncontrolled;
|
|
25
|
+
return {
|
|
26
|
+
color,
|
|
27
|
+
disabled: disabled || (picker?.disabled ?? false),
|
|
28
|
+
setColor: (next) => {
|
|
29
|
+
if (!controlled && !picker) setUncontrolled(next);
|
|
30
|
+
picker?.setValue(next);
|
|
31
|
+
onValueChange?.(next);
|
|
32
|
+
},
|
|
33
|
+
commitColor: (next) => {
|
|
34
|
+
picker?.commitValue(next);
|
|
35
|
+
onValueCommitted?.(next);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { ColorPickerContext, useColorControl, useColorPickerContext, useRequiredColorPickerContext };
|
|
41
|
+
//# sourceMappingURL=color-picker-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-picker-context.js","sources":["../../src/internal/color-picker-context.ts"],"sourcesContent":["'use client'\n\n// The channel ColorPicker uses to drive the controls composed inside it. A control\n// with no `value` of its own reads the picker's color and writes back to it, which is\n// what lets an area, a slider and a palette share one value without any prop wiring.\n// Internal: nothing here is re-exported from the package.\n\nimport * as React from 'react'\nimport { normalizeColor } from './color-control'\nimport type { Color, ColorFormat } from '../lib/color'\n\nexport interface ColorPickerContextValue {\n value: Color\n setValue: (color: Color) => void\n commitValue: (color: Color) => void\n format: ColorFormat\n disabled: boolean\n}\n\nexport const ColorPickerContext = React.createContext<ColorPickerContextValue | null>(null)\n\n/** The enclosing picker, or `null` when the control stands on its own. */\nexport function useColorPickerContext(): ColorPickerContextValue | null {\n return React.useContext(ColorPickerContext)\n}\n\n/** The enclosing picker, for the parts that only exist inside one. */\nexport function useRequiredColorPickerContext(part: string): ColorPickerContextValue {\n const context = React.useContext(ColorPickerContext)\n if (!context) throw new Error(`Appica UI: <${part}> must be used within <ColorPicker>.`)\n return context\n}\n\nexport interface ColorControlOptions {\n value?: Color | string\n defaultValue: Color | string\n onValueChange?: (value: Color) => void\n onValueCommitted?: (value: Color) => void\n disabled?: boolean\n}\n\nexport interface ColorControl {\n color: Color\n disabled: boolean\n setColor: (color: Color) => void\n commitColor: (color: Color) => void\n}\n\n/**\n * Resolves a control's color from, in order: its own `value`, the enclosing picker,\n * its own state. Writes go to the picker and to the callbacks either way, so a\n * control stays reportable even when the picker owns the value.\n */\nexport function useColorControl({\n value,\n defaultValue,\n onValueChange,\n onValueCommitted,\n disabled = false,\n}: ColorControlOptions): ColorControl {\n const picker = useColorPickerContext()\n const [uncontrolled, setUncontrolled] = React.useState<Color>(() => normalizeColor(defaultValue))\n\n const controlled = value !== undefined\n const color = controlled ? normalizeColor(value) : (picker?.value ?? uncontrolled)\n\n return {\n color,\n disabled: disabled || (picker?.disabled ?? false),\n setColor: (next) => {\n if (!controlled && !picker) setUncontrolled(next)\n picker?.setValue(next)\n onValueChange?.(next)\n },\n commitColor: (next) => {\n picker?.commitValue(next)\n onValueCommitted?.(next)\n },\n }\n}\n"],"names":[],"mappings":";;;;AAmBO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,kBAAA,CAAA,CAAA,CAAqB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8C,CAAA,CAAA,CAAA,CAAI,CAAA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|
*
|
|
42
42
|
* Destructure `className`/`children` (and any component-specific props) out of the
|
|
43
|
-
* props object before calling this
|
|
43
|
+
* props object before calling this - they should not reach the generic Popup spread.
|
|
44
44
|
*/
|
|
45
45
|
export declare function splitFloatingProps(props: Record<string, unknown>): SplitFloatingProps;
|
|
46
46
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating.d.ts","sourceRoot":"","sources":["../../src/internal/floating.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,uMAa3B,CAAA;AAEV,sEAAsE;AACtE,eAAO,MAAM,oBAAoB,uCAAwC,CAAA;AAEzE,KAAK,aAAa,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAA;AAC9D,KAAK,SAAS,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEtD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,oBAAoB,CAAC,UAAU,EAAE,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,UAAU,EAAE,aAAa,CAAC,CAAC,GAC/G,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG;IAC/C,8FAA8F;IAC9F,eAAe,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,aAAa,GAAG,UAAU,CAAC,CAAA;IAC9D,0FAA0F;IAC1F,WAAW,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC,CAAA;CACnD,CAAA;AAEH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAsBrF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floating.js","sources":["../../src/internal/floating.ts"],"sourcesContent":["// Shared plumbing for floating *Content components - the ones that wrap a Base UI\n// Portal → Positioner → Popup trio (Popover, Tooltip, PreviewCard, Menu, Select,\n// Combobox, Autocomplete, …).\n//\n// Consumers of this library don't get direct access to the inner Portal/Positioner\n// elements the way a copy-paste (shadcn-style) component would. So every *Content\n// must map the Base UI surface itself. This module keeps that mapping consistent:\n//\n// 1. The common Positioner positioning props (+ the two Portal props) are\n// promoted to flat props on *Content - Radix/shadcn ergonomics.\n// 2. `positionerProps` / `portalProps` escape hatches forward the long tail\n// (e.g. `style`, `render`) without each component re-enumerating it.\n//\n// `className`/`style`/`render` are intentionally NOT promoted: *Content represents\n// the Popup, so those stay bound to it. Use the escape hatches to reach the\n// Positioner/Portal element instead.\n\n/**\n * Positioner props promoted to flat props on every floating *Content.\n * Mirrors Base UI's `UseAnchorPositioningSharedParameters` (v1.5.0).\n */\nexport const FLOATING_POSITIONER_KEYS = [\n 'side',\n 'sideOffset',\n 'align',\n 'alignOffset',\n 'anchor',\n 'positionMethod',\n 'collisionBoundary',\n 'collisionPadding',\n 'collisionAvoidance',\n 'sticky',\n 'arrowPadding',\n 'disableAnchorTracking',\n] as const\n\n/** Portal props promoted to flat props on every floating *Content. */\nexport const FLOATING_PORTAL_KEYS = ['container', 'keepMounted'] as const\n\ntype PositionerKey = (typeof FLOATING_POSITIONER_KEYS)[number]\ntype PortalKey = (typeof FLOATING_PORTAL_KEYS)[number]\n\n/**\n * Flat positioning/portal props + typed escape hatches, derived from a\n * component's own Positioner and Portal prop types so each *Content stays in\n * lockstep with Base UI. Intersect with the Popup props to build a *Content\n * prop type:\n *\n * ```ts\n * type PopoverContentProps = React.ComponentProps<typeof BasePopover.Popup> &\n * FloatingContentProps<\n * React.ComponentProps<typeof BasePopover.Positioner>,\n * React.ComponentProps<typeof BasePopover.Portal>\n * > & { arrow?: boolean }\n * ```\n */\nexport type FloatingContentProps<Positioner, Portal> = Pick<Positioner, Extract<keyof Positioner, PositionerKey>> &\n Pick<Portal, Extract<keyof Portal, PortalKey>> & {\n /** Escape hatch: extra props forwarded to the Base UI Positioner (e.g. `style`, `render`). */\n positionerProps?: Omit<Positioner, PositionerKey | 'children'>\n /** Escape hatch: extra props forwarded to the Base UI Portal (e.g. `style`, `render`). */\n portalProps?: Omit<Portal, PortalKey | 'children'>\n }\n\nexport interface SplitFloatingProps {\n positioner: Record<string, unknown>\n portal: Record<string, unknown>\n popup: Record<string, unknown>\n}\n\n/**\n * Partition a *Content component's spread props into its three Base UI targets.\n *\n * - Flat positioning/portal props win over the same keys inside\n * `positionerProps`/`portalProps` (the flat prop is the documented primary API).\n * - Anything left that isn't a known Positioner/Portal prop is treated as a Popup prop.\n *\n * Destructure `className`/`children` (and any component-specific props) out of the\n * props object before calling this - they should not reach the generic Popup spread.\n */\nexport function splitFloatingProps(props: Record<string, unknown>): SplitFloatingProps {\n const { positionerProps, portalProps, ...rest } = props as {\n positionerProps?: Record<string, unknown>\n portalProps?: Record<string, unknown>\n } & Record<string, unknown>\n\n const positioner: Record<string, unknown> = { ...positionerProps }\n const portal: Record<string, unknown> = { ...portalProps }\n const popup: Record<string, unknown> = {}\n\n for (const key of Object.keys(rest)) {\n const value = rest[key]\n if ((FLOATING_POSITIONER_KEYS as readonly string[]).includes(key)) {\n if (value !== undefined) positioner[key] = value\n } else if ((FLOATING_PORTAL_KEYS as readonly string[]).includes(key)) {\n if (value !== undefined) portal[key] = value\n } else {\n popup[key] = value\n }\n }\n\n return { positioner, portal, popup }\n}\n"],"names":[],"mappings":"AAqBO,MAAM,wBAAA,GAA2B;AAAA,EACtC,MAAA;AAAA,EACA,YAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA;AAAA,EACA,gBAAA;AAAA,EACA,mBAAA;AAAA,EACA,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA,QAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF;AAGO,MAAM,oBAAA,GAAuB,CAAC,WAAA,EAAa,aAAa;AA2CxD,SAAS,mBAAmB,KAAA,EAAoD;AACrF,EAAA,MAAM,EAAE,eAAA,EAAiB,WAAA,EAAa,GAAG,MAAK,GAAI,KAAA;AAKlD,EAAA,MAAM,UAAA,GAAsC,EAAE,GAAG,eAAA,EAAgB;AACjE,EAAA,MAAM,MAAA,GAAkC,EAAE,GAAG,WAAA,EAAY;AACzD,EAAA,MAAM,QAAiC,EAAC;AAExC,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,EAAG;AACnC,IAAA,MAAM,KAAA,GAAQ,KAAK,GAAG,CAAA;AACtB,IAAA,IAAK,wBAAA,CAA+C,QAAA,CAAS,GAAG,CAAA,EAAG;AACjE,MAAA,IAAI,KAAA,KAAU,MAAA,EAAW,UAAA,CAAW,GAAG,CAAA,GAAI,KAAA;AAAA,IAC7C,CAAA,MAAA,IAAY,oBAAA,CAA2C,QAAA,CAAS,GAAG,CAAA,EAAG;AACpE,MAAA,IAAI,KAAA,KAAU,MAAA,EAAW,MAAA,CAAO,GAAG,CAAA,GAAI,KAAA;AAAA,IACzC,CAAA,MAAO;AACL,MAAA,KAAA,CAAM,GAAG,CAAA,GAAI,KAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,UAAA,EAAY,MAAA,EAAQ,KAAA,EAAM;AACrC;;;;"}
|
|
@@ -34,7 +34,7 @@ export interface SplitModalProps {
|
|
|
34
34
|
*
|
|
35
35
|
* Destructure `className`/`children`, the `backdropProps`/`viewportProps` escape
|
|
36
36
|
* hatches, and any component-specific props (`backdrop`, `closeButton`, …) out of
|
|
37
|
-
* the props object before calling this
|
|
37
|
+
* the props object before calling this - everything left that isn't a known
|
|
38
38
|
* Portal prop is treated as a Popup prop.
|
|
39
39
|
*/
|
|
40
40
|
export declare function splitModalProps(props: Record<string, unknown>): SplitModalProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../src/internal/modal.ts"],"names":[],"mappings":"AAiBA,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,uCAAwC,CAAA;AAEtE,KAAK,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAExD;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,IAAI,KAAK,GACtE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,MAAM,EAAE,cAAc,CAAC,CAAC,GAAG;IACpD,iEAAiE;IACjE,WAAW,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAAC,CAAA;IACvD,mGAAmG;IACnG,aAAa,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IAC1C,mGAAmG;IACnG,aAAa,CAAC,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;CAC3C,CAAA;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,CAkB/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../src/internal/modal.ts"],"sourcesContent":["// Shared plumbing for modal/overlay *Content components - the ones that wrap a\n// Base UI Portal → Backdrop → Viewport → Popup structure (Dialog, AlertDialog,\n// Drawer). Sibling to src/floating.ts (which handles the Positioner-based trio).\n//\n// As with floating, consumers don't get direct access to the inner Portal,\n// Backdrop, or Viewport elements, so *Content must map them itself:\n//\n// 1. The two Portal props (`container`, `keepMounted`) are promoted to flat\n// props on *Content.\n// 2. `portalProps` / `backdropProps` / `viewportProps` escape hatches forward\n// the rest (e.g. `className`, `style`, `render`) without each component\n// re-enumerating it.\n//\n// The Popup is what *Content represents, so its `className`/`style`/`render`\n// stay bound to it (via the regular spread) - reach the other elements through\n// the escape hatches.\n\n/** Portal props promoted to flat props on every modal *Content. */\nexport const MODAL_PORTAL_KEYS = ['container', 'keepMounted'] as const\n\ntype ModalPortalKey = (typeof MODAL_PORTAL_KEYS)[number]\n\n/**\n * Flat Portal props + typed escape hatches for the Backdrop/Viewport/Portal,\n * derived from a component's own Base UI types so each *Content stays in\n * lockstep with Base UI. Intersect with the Popup props to build a *Content\n * prop type:\n *\n * ```ts\n * type DialogContentProps = ModalContentProps<\n * React.ComponentProps<typeof BaseDialog.Popup>,\n * React.ComponentProps<typeof BaseDialog.Portal>,\n * React.ComponentProps<typeof BaseDialog.Backdrop>,\n * React.ComponentProps<typeof BaseDialog.Viewport>\n * > & { closeButton?: boolean }\n * ```\n */\nexport type ModalContentProps<Popup, Portal, Backdrop, Viewport> = Popup &\n Pick<Portal, Extract<keyof Portal, ModalPortalKey>> & {\n /** Escape hatch: extra props forwarded to the Base UI Portal. */\n portalProps?: Omit<Portal, ModalPortalKey | 'children'>\n /** Escape hatch: props forwarded to the Base UI Backdrop (e.g. `className`, `style`, `render`). */\n backdropProps?: Omit<Backdrop, 'children'>\n /** Escape hatch: props forwarded to the Base UI Viewport (e.g. `className`, `style`, `render`). */\n viewportProps?: Omit<Viewport, 'children'>\n }\n\nexport interface SplitModalProps {\n portal: Record<string, unknown>\n popup: Record<string, unknown>\n}\n\n/**\n * Partition a modal *Content component's spread props into the Portal and Popup\n * targets. Flat portal props win over the same keys inside `portalProps`.\n *\n * Destructure `className`/`children`, the `backdropProps`/`viewportProps` escape\n * hatches, and any component-specific props (`backdrop`, `closeButton`, …) out of\n * the props object before calling this - everything left that isn't a known\n * Portal prop is treated as a Popup prop.\n */\nexport function splitModalProps(props: Record<string, unknown>): SplitModalProps {\n const { portalProps, ...rest } = props as {\n portalProps?: Record<string, unknown>\n } & Record<string, unknown>\n\n const portal: Record<string, unknown> = { ...portalProps }\n const popup: Record<string, unknown> = {}\n\n for (const key of Object.keys(rest)) {\n const value = rest[key]\n if ((MODAL_PORTAL_KEYS as readonly string[]).includes(key)) {\n if (value !== undefined) portal[key] = value\n } else {\n popup[key] = value\n }\n }\n\n return { portal, popup }\n}\n"],"names":[],"mappings":"AAkBO,MAAM,iBAAA,GAAoB,CAAC,WAAA,EAAa,aAAa;AA2CrD,SAAS,gBAAgB,KAAA,EAAiD;AAC/E,EAAA,MAAM,EAAE,WAAA,EAAa,GAAG,IAAA,EAAK,GAAI,KAAA;AAIjC,EAAA,MAAM,MAAA,GAAkC,EAAE,GAAG,WAAA,EAAY;AACzD,EAAA,MAAM,QAAiC,EAAC;AAExC,EAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,IAAI,CAAA,EAAG;AACnC,IAAA,MAAM,KAAA,GAAQ,KAAK,GAAG,CAAA;AACtB,IAAA,IAAK,iBAAA,CAAwC,QAAA,CAAS,GAAG,CAAA,EAAG;AAC1D,MAAA,IAAI,KAAA,KAAU,MAAA,EAAW,MAAA,CAAO,GAAG,CAAA,GAAI,KAAA;AAAA,IACzC,CAAA,MAAO;AACL,MAAA,KAAA,CAAM,GAAG,CAAA,GAAI,KAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,QAAQ,KAAA,EAAM;AACzB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/internal/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAE5C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;AAU9C,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IAC9C,MAAM,CAAC,KAAG,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAyBtC;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,8BA3B1B,IAAI,EA8BrC;AAED,wBAAgB,cAAc,CAAC,QAAQ,UAAQ;;;;;;;;EAK9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/internal/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\nimport * as React from 'react'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\ntype PossibleRef<T> = React.Ref<T> | undefined\n\nfunction setRef<T>(ref: PossibleRef<T>, value: T): (() => void) | void {\n if (typeof ref === 'function') {\n return ref(value) as (() => void) | void\n } else if (ref != null) {\n ;(ref as React.RefObject<T>).current = value\n }\n}\n\nexport function composeRefs<T>(...refs: PossibleRef<T>[]) {\n return (node: T): void | (() => void) => {\n let hasCleanup = false\n const cleanups = refs.map((ref) => {\n const cleanup = setRef(ref, node)\n if (!hasCleanup && typeof cleanup === 'function') {\n hasCleanup = true\n }\n return cleanup\n })\n\n if (hasCleanup) {\n return () => {\n for (let i = 0; i < cleanups.length; i++) {\n const cleanup = cleanups[i]\n if (typeof cleanup === 'function') {\n cleanup()\n } else {\n setRef(refs[i], null as T)\n }\n }\n }\n }\n\n return undefined\n }\n}\n\nexport function useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs)\n}\n\nexport function focusableProps(disabled = false) {\n if (disabled) {\n return { tabIndex: -1, 'aria-disabled': true, 'data-disabled': '' } as const\n }\n return { tabIndex: 0 } as const\n}\n"],"names":[],"mappings":";;;;AAIO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC7B;AAIA,SAAS,MAAA,CAAU,KAAqB,KAAA,EAA+B;AACrE,EAAA,IAAI,OAAO,QAAQ,UAAA,EAAY;AAC7B,IAAA,OAAO,IAAI,KAAK,CAAA;AAAA,EAClB,CAAA,MAAA,IAAW,OAAO,IAAA,EAAM;AACrB,IAAC,IAA2B,OAAA,GAAU,KAAA;AAAA,EACzC;AACF;AAEO,SAAS,eAAkB,IAAA,EAAwB;AACxD,EAAA,OAAO,CAAC,IAAA,KAAiC;AACvC,IAAA,IAAI,UAAA,GAAa,KAAA;AACjB,IAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,KAAQ;AACjC,MAAA,MAAM,OAAA,GAAU,MAAA,CAAO,GAAA,EAAK,IAAI,CAAA;AAChC,MAAA,IAAI,CAAC,UAAA,IAAc,OAAO,OAAA,KAAY,UAAA,EAAY;AAChD,QAAA,UAAA,GAAa,IAAA;AAAA,MACf;AACA,MAAA,OAAO,OAAA;AAAA,IACT,CAAC,CAAA;AAED,IAAA,IAAI,UAAA,EAAY;AACd,MAAA,OAAO,MAAM;AACX,QAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,QAAA,CAAS,QAAQ,CAAA,EAAA,EAAK;AACxC,UAAA,MAAM,OAAA,GAAU,SAAS,CAAC,CAAA;AAC1B,UAAA,IAAI,OAAO,YAAY,UAAA,EAAY;AACjC,YAAA,OAAA,EAAQ;AAAA,UACV,CAAA,MAAO;AACL,YAAA,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,EAAG,IAAS,CAAA;AAAA,UAC3B;AAAA,QACF;AAAA,MACF,CAAA;AAAA,IACF;AAEA,IAAA,OAAO,MAAA;AAAA,EACT,CAAA;AACF;AAEO,SAAS,mBAAsB,IAAA,EAAwB;AAE5D,EAAA,OAAO,MAAM,WAAA,CAAY,WAAA,CAAY,GAAG,IAAI,GAAG,IAAI,CAAA;AACrD;AAEO,SAAS,cAAA,CAAe,WAAW,KAAA,EAAO;AAC/C,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,OAAO,EAAE,QAAA,EAAU,EAAA,EAAI,eAAA,EAAiB,IAAA,EAAM,iBAAiB,EAAA,EAAG;AAAA,EACpE;AACA,EAAA,OAAO,EAAE,UAAU,CAAA,EAAE;AACvB;;;;"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** A color space a `Color` can be expressed in. */
|
|
2
|
+
export type ColorSpace = 'rgb' | 'hsl' | 'hsb' | 'oklch';
|
|
3
|
+
/** A single adjustable component of a color. */
|
|
4
|
+
export type ColorChannel = 'red' | 'green' | 'blue' | 'hue' | 'saturation' | 'lightness' | 'brightness' | 'chroma' | 'alpha';
|
|
5
|
+
/** A string form `formatColor` can produce and `parseColor` can read back. */
|
|
6
|
+
export type ColorFormat = 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hsb' | 'hsba' | 'oklch' | 'oklcha';
|
|
7
|
+
/** sRGB color. Channels are 0-255, alpha is 0-1. */
|
|
8
|
+
export interface RgbColor {
|
|
9
|
+
space: 'rgb';
|
|
10
|
+
red: number;
|
|
11
|
+
green: number;
|
|
12
|
+
blue: number;
|
|
13
|
+
alpha: number;
|
|
14
|
+
}
|
|
15
|
+
/** HSL color. Hue is 0-360, saturation and lightness are 0-100, alpha is 0-1. */
|
|
16
|
+
export interface HslColor {
|
|
17
|
+
space: 'hsl';
|
|
18
|
+
hue: number;
|
|
19
|
+
saturation: number;
|
|
20
|
+
lightness: number;
|
|
21
|
+
alpha: number;
|
|
22
|
+
}
|
|
23
|
+
/** HSB (a.k.a. HSV) color. Hue is 0-360, saturation and brightness are 0-100, alpha is 0-1. */
|
|
24
|
+
export interface HsbColor {
|
|
25
|
+
space: 'hsb';
|
|
26
|
+
hue: number;
|
|
27
|
+
saturation: number;
|
|
28
|
+
brightness: number;
|
|
29
|
+
alpha: number;
|
|
30
|
+
}
|
|
31
|
+
/** OKLCh color. Lightness is 0-100, chroma is 0-0.4, hue is 0-360, alpha is 0-1. */
|
|
32
|
+
export interface OklchColor {
|
|
33
|
+
space: 'oklch';
|
|
34
|
+
lightness: number;
|
|
35
|
+
chroma: number;
|
|
36
|
+
hue: number;
|
|
37
|
+
alpha: number;
|
|
38
|
+
}
|
|
39
|
+
/** A color value in one of the supported color spaces. */
|
|
40
|
+
export type Color = RgbColor | HslColor | HsbColor | OklchColor;
|
|
41
|
+
/** The bounds and increments of a channel within a given color space. */
|
|
42
|
+
export interface ColorChannelRange {
|
|
43
|
+
/** Lowest value the channel accepts. */
|
|
44
|
+
minValue: number;
|
|
45
|
+
/** Highest value the channel accepts. */
|
|
46
|
+
maxValue: number;
|
|
47
|
+
/** Increment applied by an arrow key. */
|
|
48
|
+
step: number;
|
|
49
|
+
/** Increment applied by Page Up, Page Down, or a shifted arrow key. */
|
|
50
|
+
pageSize: number;
|
|
51
|
+
}
|
|
52
|
+
/** The three channels of a color space, mapped onto the axes of a color area. */
|
|
53
|
+
export interface ColorAxes {
|
|
54
|
+
/** Channel driven by the horizontal axis. */
|
|
55
|
+
xChannel: ColorChannel;
|
|
56
|
+
/** Channel driven by the vertical axis. */
|
|
57
|
+
yChannel: ColorChannel;
|
|
58
|
+
/** Channel held constant, and so not represented by either axis. */
|
|
59
|
+
zChannel: ColorChannel;
|
|
60
|
+
}
|
|
61
|
+
/** Returns the three channels that define `space`, in canonical order. */
|
|
62
|
+
export declare function getColorChannels(space: ColorSpace): [ColorChannel, ColorChannel, ColorChannel];
|
|
63
|
+
/** Returns the bounds and increments of `channel` within `space`. */
|
|
64
|
+
export declare function getChannelRange(space: ColorSpace, channel: ColorChannel): ColorChannelRange;
|
|
65
|
+
/** Reads a single channel off a color. Throws if the channel is not in the color's space. */
|
|
66
|
+
export declare function getChannelValue(color: Color, channel: ColorChannel): number;
|
|
67
|
+
/** Returns a copy of `color` with `channel` clamped into range and set to `value`. */
|
|
68
|
+
export declare function withChannelValue(color: Color, channel: ColorChannel, value: number): Color;
|
|
69
|
+
/**
|
|
70
|
+
* Resolves the x, y and z channels of a color area. Unspecified axes fall back to
|
|
71
|
+
* the first channels of `space` that are still free.
|
|
72
|
+
*/
|
|
73
|
+
export declare function getColorSpaceAxes(space: ColorSpace, axes?: Partial<Omit<ColorAxes, 'zChannel'>>): ColorAxes;
|
|
74
|
+
/** Converts `color` into `space`. Returns the same object when it is already there. */
|
|
75
|
+
export declare function convertColor<S extends ColorSpace>(color: Color, space: S): Extract<Color, {
|
|
76
|
+
space: S;
|
|
77
|
+
}>;
|
|
78
|
+
/** Returns the English display name of `channel`, for labels and value text. */
|
|
79
|
+
export declare function getChannelName(channel: ColorChannel): string;
|
|
80
|
+
/** Formats a channel value for display, with the unit the channel is measured in. */
|
|
81
|
+
export declare function formatChannelValue(color: Color, channel: ColorChannel): string;
|
|
82
|
+
/**
|
|
83
|
+
* Parses a CSS color string into a `Color`. Accepts hex (3, 4, 6 or 8 digits),
|
|
84
|
+
* `rgb()`, `hsl()`, `oklch()` in both comma and space separated forms, plus the
|
|
85
|
+
* non-CSS `hsb()` used by design tools. Throws on anything else.
|
|
86
|
+
*/
|
|
87
|
+
export declare function parseColor(value: string): Color;
|
|
88
|
+
/** Parses `value` into a `Color`, returning `undefined` instead of throwing on bad input. */
|
|
89
|
+
export declare function safeParseColor(value: string): Color | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Serializes `color` to a CSS string. `'css'` picks the shortest form the browser
|
|
92
|
+
* understands for the color's own space, which is what you want for a `background`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function formatColor(color: Color, format?: ColorFormat | 'css'): string;
|
|
95
|
+
//# sourceMappingURL=color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/lib/color.ts"],"names":[],"mappings":"AAUA,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAA;AAExD,gDAAgD;AAChD,MAAM,MAAM,YAAY,GACtB,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAA;AAEnG,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;AAEhH,oDAAoD;AACpD,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,KAAK,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,KAAK,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,+FAA+F;AAC/F,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,KAAK,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,oFA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AAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAM,GAAG,SAAS,CAM/G;AA8HD,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC,CAavG;AAcD,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAE5D;AAED,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAO9E;AAiBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAwE/C;AAED,6FAA6F;AAC7F,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAM/D;AAWD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,WAAW,GAAG,KAAa,GAAG,MAAM,CAkCrF"}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { linearRgbToOklab, srgbToLinear, oklchToSrgb } from '../internal/color-math.js';
|
|
2
|
+
|
|
3
|
+
const CHANNELS = {
|
|
4
|
+
rgb: ["red", "green", "blue"],
|
|
5
|
+
hsl: ["hue", "saturation", "lightness"],
|
|
6
|
+
hsb: ["hue", "saturation", "brightness"],
|
|
7
|
+
oklch: ["lightness", "chroma", "hue"]
|
|
8
|
+
};
|
|
9
|
+
const RANGES = {
|
|
10
|
+
rgb: {
|
|
11
|
+
red: { minValue: 0, maxValue: 255, step: 1, pageSize: 17 },
|
|
12
|
+
green: { minValue: 0, maxValue: 255, step: 1, pageSize: 17 },
|
|
13
|
+
blue: { minValue: 0, maxValue: 255, step: 1, pageSize: 17 }
|
|
14
|
+
},
|
|
15
|
+
hsl: {
|
|
16
|
+
hue: { minValue: 0, maxValue: 360, step: 1, pageSize: 15 },
|
|
17
|
+
saturation: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 },
|
|
18
|
+
lightness: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }
|
|
19
|
+
},
|
|
20
|
+
hsb: {
|
|
21
|
+
hue: { minValue: 0, maxValue: 360, step: 1, pageSize: 15 },
|
|
22
|
+
saturation: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 },
|
|
23
|
+
brightness: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 }
|
|
24
|
+
},
|
|
25
|
+
oklch: {
|
|
26
|
+
lightness: { minValue: 0, maxValue: 100, step: 1, pageSize: 10 },
|
|
27
|
+
chroma: { minValue: 0, maxValue: 0.4, step: 5e-3, pageSize: 0.05 },
|
|
28
|
+
hue: { minValue: 0, maxValue: 360, step: 1, pageSize: 15 }
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const ALPHA_RANGE = { minValue: 0, maxValue: 1, step: 0.01, pageSize: 0.1 };
|
|
32
|
+
function getColorChannels(space) {
|
|
33
|
+
return CHANNELS[space];
|
|
34
|
+
}
|
|
35
|
+
function getChannelRange(space, channel) {
|
|
36
|
+
if (channel === "alpha") return ALPHA_RANGE;
|
|
37
|
+
const range = RANGES[space][channel];
|
|
38
|
+
if (!range) throw new Error(`Channel "${channel}" is not part of the ${space} color space`);
|
|
39
|
+
return range;
|
|
40
|
+
}
|
|
41
|
+
function getChannelValue(color, channel) {
|
|
42
|
+
const value = color[channel];
|
|
43
|
+
if (typeof value !== "number") {
|
|
44
|
+
throw new Error(`Channel "${channel}" is not part of the ${color.space} color space`);
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
function withChannelValue(color, channel, value) {
|
|
49
|
+
const { minValue, maxValue } = getChannelRange(color.space, channel);
|
|
50
|
+
return { ...color, [channel]: clamp(value, minValue, maxValue) };
|
|
51
|
+
}
|
|
52
|
+
function getColorSpaceAxes(space, axes = {}) {
|
|
53
|
+
const channels = CHANNELS[space];
|
|
54
|
+
const xChannel = axes.xChannel ?? channels.find((c) => c !== axes.yChannel);
|
|
55
|
+
const yChannel = axes.yChannel ?? channels.find((c) => c !== xChannel);
|
|
56
|
+
const zChannel = channels.find((c) => c !== xChannel && c !== yChannel);
|
|
57
|
+
return { xChannel, yChannel, zChannel };
|
|
58
|
+
}
|
|
59
|
+
function clamp(value, min, max) {
|
|
60
|
+
return Math.min(Math.max(value, min), max);
|
|
61
|
+
}
|
|
62
|
+
function mod360(hue) {
|
|
63
|
+
if (hue >= 0 && hue <= 360) return hue;
|
|
64
|
+
return (hue % 360 + 360) % 360;
|
|
65
|
+
}
|
|
66
|
+
function rgbToHsb(color) {
|
|
67
|
+
const r = color.red / 255;
|
|
68
|
+
const g = color.green / 255;
|
|
69
|
+
const b = color.blue / 255;
|
|
70
|
+
const max = Math.max(r, g, b);
|
|
71
|
+
const min = Math.min(r, g, b);
|
|
72
|
+
const delta = max - min;
|
|
73
|
+
let hue = 0;
|
|
74
|
+
if (delta !== 0) {
|
|
75
|
+
if (max === r) hue = (g - b) / delta % 6;
|
|
76
|
+
else if (max === g) hue = (b - r) / delta + 2;
|
|
77
|
+
else hue = (r - g) / delta + 4;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
space: "hsb",
|
|
81
|
+
hue: mod360(hue * 60),
|
|
82
|
+
saturation: max === 0 ? 0 : delta / max * 100,
|
|
83
|
+
brightness: max * 100,
|
|
84
|
+
alpha: color.alpha
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function hsbToRgb(color) {
|
|
88
|
+
const s = color.saturation / 100;
|
|
89
|
+
const v = color.brightness / 100;
|
|
90
|
+
const c = v * s;
|
|
91
|
+
const h = color.hue / 60;
|
|
92
|
+
const x = c * (1 - Math.abs(h % 2 - 1));
|
|
93
|
+
const m = v - c;
|
|
94
|
+
const [r, g, b] = sector(h, c, x);
|
|
95
|
+
return { space: "rgb", red: (r + m) * 255, green: (g + m) * 255, blue: (b + m) * 255, alpha: color.alpha };
|
|
96
|
+
}
|
|
97
|
+
function rgbToHsl(color) {
|
|
98
|
+
const hsb = rgbToHsb(color);
|
|
99
|
+
const v = hsb.brightness / 100;
|
|
100
|
+
const s = hsb.saturation / 100;
|
|
101
|
+
const l = v * (1 - s / 2);
|
|
102
|
+
return {
|
|
103
|
+
space: "hsl",
|
|
104
|
+
hue: hsb.hue,
|
|
105
|
+
saturation: l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l) * 100,
|
|
106
|
+
lightness: l * 100,
|
|
107
|
+
alpha: color.alpha
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function hslToRgb(color) {
|
|
111
|
+
const s = color.saturation / 100;
|
|
112
|
+
const l = color.lightness / 100;
|
|
113
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
114
|
+
const h = color.hue / 60;
|
|
115
|
+
const x = c * (1 - Math.abs(h % 2 - 1));
|
|
116
|
+
const m = l - c / 2;
|
|
117
|
+
const [r, g, b] = sector(h, c, x);
|
|
118
|
+
return { space: "rgb", red: (r + m) * 255, green: (g + m) * 255, blue: (b + m) * 255, alpha: color.alpha };
|
|
119
|
+
}
|
|
120
|
+
function sector(h, c, x) {
|
|
121
|
+
if (h < 1) return [c, x, 0];
|
|
122
|
+
if (h < 2) return [x, c, 0];
|
|
123
|
+
if (h < 3) return [0, c, x];
|
|
124
|
+
if (h < 4) return [0, x, c];
|
|
125
|
+
if (h < 5) return [x, 0, c];
|
|
126
|
+
return [c, 0, x];
|
|
127
|
+
}
|
|
128
|
+
function rgbToOklch(color) {
|
|
129
|
+
const [L, a, b] = linearRgbToOklab(
|
|
130
|
+
srgbToLinear(color.red / 255),
|
|
131
|
+
srgbToLinear(color.green / 255),
|
|
132
|
+
srgbToLinear(color.blue / 255)
|
|
133
|
+
);
|
|
134
|
+
const chroma = Math.sqrt(a * a + b * b);
|
|
135
|
+
return {
|
|
136
|
+
space: "oklch",
|
|
137
|
+
lightness: L * 100,
|
|
138
|
+
chroma,
|
|
139
|
+
// Hue is meaningless at zero chroma and float noise there swings wildly, so pin
|
|
140
|
+
// it to keep round trips through gray stable.
|
|
141
|
+
hue: chroma < 1e-6 ? 0 : mod360(Math.atan2(b, a) * 180 / Math.PI),
|
|
142
|
+
alpha: color.alpha
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function oklchToRgb(color) {
|
|
146
|
+
const [r, g, b] = oklchToSrgb(color.lightness / 100, color.chroma, color.hue);
|
|
147
|
+
return {
|
|
148
|
+
space: "rgb",
|
|
149
|
+
red: clamp(r, 0, 1) * 255,
|
|
150
|
+
green: clamp(g, 0, 1) * 255,
|
|
151
|
+
blue: clamp(b, 0, 1) * 255,
|
|
152
|
+
alpha: color.alpha
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function toRgb(color) {
|
|
156
|
+
switch (color.space) {
|
|
157
|
+
case "rgb":
|
|
158
|
+
return color;
|
|
159
|
+
case "hsl":
|
|
160
|
+
return hslToRgb(color);
|
|
161
|
+
case "hsb":
|
|
162
|
+
return hsbToRgb(color);
|
|
163
|
+
case "oklch":
|
|
164
|
+
return oklchToRgb(color);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function convertColor(color, space) {
|
|
168
|
+
if (color.space === space) return color;
|
|
169
|
+
const rgb = toRgb(color);
|
|
170
|
+
switch (space) {
|
|
171
|
+
case "rgb":
|
|
172
|
+
return rgb;
|
|
173
|
+
case "hsl":
|
|
174
|
+
return rgbToHsl(rgb);
|
|
175
|
+
case "hsb":
|
|
176
|
+
return rgbToHsb(rgb);
|
|
177
|
+
default:
|
|
178
|
+
return rgbToOklch(rgb);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const CHANNEL_NAMES = {
|
|
182
|
+
red: "Red",
|
|
183
|
+
green: "Green",
|
|
184
|
+
blue: "Blue",
|
|
185
|
+
hue: "Hue",
|
|
186
|
+
saturation: "Saturation",
|
|
187
|
+
lightness: "Lightness",
|
|
188
|
+
brightness: "Brightness",
|
|
189
|
+
chroma: "Chroma",
|
|
190
|
+
alpha: "Alpha"
|
|
191
|
+
};
|
|
192
|
+
function getChannelName(channel) {
|
|
193
|
+
return CHANNEL_NAMES[channel];
|
|
194
|
+
}
|
|
195
|
+
function formatChannelValue(color, channel) {
|
|
196
|
+
const value = getChannelValue(color, channel);
|
|
197
|
+
if (channel === "hue") return `${Math.round(value)}\xB0`;
|
|
198
|
+
if (channel === "chroma") return value.toFixed(3);
|
|
199
|
+
if (channel === "alpha") return `${Math.round(value * 100)}%`;
|
|
200
|
+
if (color.space === "rgb") return `${Math.round(value)}`;
|
|
201
|
+
return `${Math.round(value)}%`;
|
|
202
|
+
}
|
|
203
|
+
const HEX_RE = /^#([0-9a-f]{3,8})$/i;
|
|
204
|
+
const FUNC_RE = /^(rgba?|hsla?|hsba?|hsva?|oklch)\(([^)]*)\)$/i;
|
|
205
|
+
function parseComponent(raw, scale, max) {
|
|
206
|
+
const percent = raw.endsWith("%");
|
|
207
|
+
const value = Number.parseFloat(percent ? raw.slice(0, -1) : raw);
|
|
208
|
+
if (Number.isNaN(value)) throw new Error(`Invalid color component "${raw}"`);
|
|
209
|
+
return clamp(percent ? value / 100 * scale : value, 0, max);
|
|
210
|
+
}
|
|
211
|
+
function parseAlpha(raw) {
|
|
212
|
+
if (raw == null || raw === "" || raw === "none") return 1;
|
|
213
|
+
return parseComponent(raw, 1, 1);
|
|
214
|
+
}
|
|
215
|
+
function parseColor(value) {
|
|
216
|
+
const input = value.trim();
|
|
217
|
+
const hex = HEX_RE.exec(input);
|
|
218
|
+
if (hex) {
|
|
219
|
+
const digits = hex[1] ?? "";
|
|
220
|
+
if (digits.length !== 3 && digits.length !== 4 && digits.length !== 6 && digits.length !== 8) {
|
|
221
|
+
throw new Error(`Invalid hex color "${value}"`);
|
|
222
|
+
}
|
|
223
|
+
const expand = digits.length <= 4;
|
|
224
|
+
const size = expand ? 1 : 2;
|
|
225
|
+
const channel = (i) => {
|
|
226
|
+
const slice = digits.slice(i * size, i * size + size);
|
|
227
|
+
return Number.parseInt(expand ? slice + slice : slice, 16);
|
|
228
|
+
};
|
|
229
|
+
return {
|
|
230
|
+
space: "rgb",
|
|
231
|
+
red: channel(0),
|
|
232
|
+
green: channel(1),
|
|
233
|
+
blue: channel(2),
|
|
234
|
+
alpha: digits.length === 4 || digits.length === 8 ? channel(3) / 255 : 1
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const func = FUNC_RE.exec(input);
|
|
238
|
+
if (func) {
|
|
239
|
+
const name = (func[1] ?? "").toLowerCase();
|
|
240
|
+
const parts = (func[2] ?? "").replace("/", " ").split(/[\s,]+/).filter(Boolean);
|
|
241
|
+
const [first, second, third, fourth] = parts;
|
|
242
|
+
if (first == null || second == null || third == null) throw new Error(`Invalid color "${value}"`);
|
|
243
|
+
const alpha = parseAlpha(fourth);
|
|
244
|
+
if (name === "rgb" || name === "rgba") {
|
|
245
|
+
return {
|
|
246
|
+
space: "rgb",
|
|
247
|
+
red: parseComponent(first, 255, 255),
|
|
248
|
+
green: parseComponent(second, 255, 255),
|
|
249
|
+
blue: parseComponent(third, 255, 255),
|
|
250
|
+
alpha
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
if (name === "hsl" || name === "hsla") {
|
|
254
|
+
return {
|
|
255
|
+
space: "hsl",
|
|
256
|
+
hue: mod360(Number.parseFloat(first)),
|
|
257
|
+
saturation: parseComponent(second, 100, 100),
|
|
258
|
+
lightness: parseComponent(third, 100, 100),
|
|
259
|
+
alpha
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
if (name === "oklch") {
|
|
263
|
+
return {
|
|
264
|
+
space: "oklch",
|
|
265
|
+
lightness: parseComponent(first, 100, 100),
|
|
266
|
+
chroma: parseComponent(second, 0.4, Number.POSITIVE_INFINITY),
|
|
267
|
+
hue: mod360(Number.parseFloat(third)),
|
|
268
|
+
alpha
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
space: "hsb",
|
|
273
|
+
hue: mod360(Number.parseFloat(first)),
|
|
274
|
+
saturation: parseComponent(second, 100, 100),
|
|
275
|
+
brightness: parseComponent(third, 100, 100),
|
|
276
|
+
alpha
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
throw new Error(`Invalid color "${value}"`);
|
|
280
|
+
}
|
|
281
|
+
function safeParseColor(value) {
|
|
282
|
+
try {
|
|
283
|
+
return parseColor(value);
|
|
284
|
+
} catch {
|
|
285
|
+
return void 0;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function round(value, precision = 0) {
|
|
289
|
+
const factor = 10 ** precision;
|
|
290
|
+
return Math.round(value * factor) / factor;
|
|
291
|
+
}
|
|
292
|
+
function hexPair(value) {
|
|
293
|
+
return clamp(Math.round(value), 0, 255).toString(16).padStart(2, "0");
|
|
294
|
+
}
|
|
295
|
+
function formatColor(color, format = "css") {
|
|
296
|
+
if (format === "css") {
|
|
297
|
+
const space = color.space === "hsb" ? "hsl" : color.space;
|
|
298
|
+
return formatColor(color, color.alpha < 1 ? `${space}a` : space);
|
|
299
|
+
}
|
|
300
|
+
if (format === "hex" || format === "hexa") {
|
|
301
|
+
const rgb = convertColor(color, "rgb");
|
|
302
|
+
const base = `#${hexPair(rgb.red)}${hexPair(rgb.green)}${hexPair(rgb.blue)}`;
|
|
303
|
+
return format === "hexa" ? `${base}${hexPair(rgb.alpha * 255)}` : base;
|
|
304
|
+
}
|
|
305
|
+
const withAlpha = format.endsWith("a");
|
|
306
|
+
const alpha = round(color.alpha, 2);
|
|
307
|
+
if (format === "rgb" || format === "rgba") {
|
|
308
|
+
const { red, green, blue } = convertColor(color, "rgb");
|
|
309
|
+
const channels2 = `${round(red)}, ${round(green)}, ${round(blue)}`;
|
|
310
|
+
return withAlpha ? `rgba(${channels2}, ${alpha})` : `rgb(${channels2})`;
|
|
311
|
+
}
|
|
312
|
+
if (format === "hsl" || format === "hsla") {
|
|
313
|
+
const { hue: hue2, saturation, lightness: lightness2 } = convertColor(color, "hsl");
|
|
314
|
+
const channels2 = `${round(hue2, 2)}, ${round(saturation, 2)}%, ${round(lightness2, 2)}%`;
|
|
315
|
+
return withAlpha ? `hsla(${channels2}, ${alpha})` : `hsl(${channels2})`;
|
|
316
|
+
}
|
|
317
|
+
if (format === "hsb" || format === "hsba") {
|
|
318
|
+
const { hue: hue2, saturation, brightness } = convertColor(color, "hsb");
|
|
319
|
+
const channels2 = `${round(hue2, 2)}, ${round(saturation, 2)}%, ${round(brightness, 2)}%`;
|
|
320
|
+
return withAlpha ? `hsba(${channels2}, ${alpha})` : `hsb(${channels2})`;
|
|
321
|
+
}
|
|
322
|
+
const { lightness, chroma, hue } = convertColor(color, "oklch");
|
|
323
|
+
const channels = `${round(lightness, 2)}% ${round(chroma, 4)} ${round(hue, 2)}`;
|
|
324
|
+
return withAlpha ? `oklch(${channels} / ${alpha})` : `oklch(${channels})`;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export { convertColor, formatChannelValue, formatColor, getChannelName, getChannelRange, getChannelValue, getColorChannels, getColorSpaceAxes, parseColor, safeParseColor, withChannelValue };
|
|
328
|
+
//# sourceMappingURL=color.js.map
|