@stridge/noctis 1.0.0-beta.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/README.md +60 -0
- package/dist/_virtual/_rolldown/runtime.js +27 -0
- package/dist/components/accordion/accordion.context.js +15 -0
- package/dist/components/accordion/accordion.d.ts +136 -0
- package/dist/components/accordion/accordion.js +132 -0
- package/dist/components/accordion/accordion.props.d.ts +45 -0
- package/dist/components/accordion/accordion.props.js +53 -0
- package/dist/components/accordion/accordion.slots.d.ts +24 -0
- package/dist/components/accordion/accordion.slots.js +39 -0
- package/dist/components/accordion/accordion.types.d.ts +11 -0
- package/dist/components/accordion/index.d.ts +3 -0
- package/dist/components/alert-dialog/alert-dialog.context.js +16 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +324 -0
- package/dist/components/alert-dialog/alert-dialog.js +279 -0
- package/dist/components/alert-dialog/alert-dialog.props.d.ts +85 -0
- package/dist/components/alert-dialog/alert-dialog.props.js +84 -0
- package/dist/components/alert-dialog/alert-dialog.slots.d.ts +29 -0
- package/dist/components/alert-dialog/alert-dialog.slots.js +52 -0
- package/dist/components/alert-dialog/alert-dialog.types.d.ts +22 -0
- package/dist/components/alert-dialog/index.d.ts +3 -0
- package/dist/components/autocomplete/autocomplete.context.d.ts +5 -0
- package/dist/components/autocomplete/autocomplete.context.js +13 -0
- package/dist/components/autocomplete/autocomplete.d.ts +364 -0
- package/dist/components/autocomplete/autocomplete.js +373 -0
- package/dist/components/autocomplete/autocomplete.props.d.ts +83 -0
- package/dist/components/autocomplete/autocomplete.props.js +63 -0
- package/dist/components/autocomplete/autocomplete.slots.d.ts +32 -0
- package/dist/components/autocomplete/autocomplete.slots.js +61 -0
- package/dist/components/autocomplete/index.d.ts +3 -0
- package/dist/components/avatar/avatar.context.js +21 -0
- package/dist/components/avatar/avatar.d.ts +235 -0
- package/dist/components/avatar/avatar.js +208 -0
- package/dist/components/avatar/avatar.props.d.ts +86 -0
- package/dist/components/avatar/avatar.props.js +78 -0
- package/dist/components/avatar/avatar.slots.d.ts +35 -0
- package/dist/components/avatar/avatar.slots.js +49 -0
- package/dist/components/avatar/avatar.types.d.ts +28 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/button/button.d.ts +91 -0
- package/dist/components/button/button.js +82 -0
- package/dist/components/button/button.props.d.ts +48 -0
- package/dist/components/button/button.props.js +25 -0
- package/dist/components/button/button.slots.d.ts +30 -0
- package/dist/components/button/button.slots.js +40 -0
- package/dist/components/button/button.types.d.ts +12 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button-group/button-group.context.js +15 -0
- package/dist/components/button-group/button-group.d.ts +60 -0
- package/dist/components/button-group/button-group.js +50 -0
- package/dist/components/button-group/button-group.props.d.ts +22 -0
- package/dist/components/button-group/button-group.props.js +33 -0
- package/dist/components/button-group/button-group.slots.d.ts +12 -0
- package/dist/components/button-group/button-group.slots.js +18 -0
- package/dist/components/button-group/index.d.ts +2 -0
- package/dist/components/checkbox/checkbox-group.d.ts +46 -0
- package/dist/components/checkbox/checkbox-group.js +31 -0
- package/dist/components/checkbox/checkbox.context.js +15 -0
- package/dist/components/checkbox/checkbox.d.ts +130 -0
- package/dist/components/checkbox/checkbox.js +117 -0
- package/dist/components/checkbox/checkbox.props.d.ts +84 -0
- package/dist/components/checkbox/checkbox.props.js +49 -0
- package/dist/components/checkbox/checkbox.slots.d.ts +27 -0
- package/dist/components/checkbox/checkbox.slots.js +40 -0
- package/dist/components/checkbox/index.d.ts +3 -0
- package/dist/components/code-block/brand-logo.d.ts +37 -0
- package/dist/components/code-block/brand-logo.js +212 -0
- package/dist/components/code-block/code-block.context.js +13 -0
- package/dist/components/code-block/code-block.d.ts +190 -0
- package/dist/components/code-block/code-block.js +267 -0
- package/dist/components/code-block/code-block.props.d.ts +42 -0
- package/dist/components/code-block/code-block.props.js +51 -0
- package/dist/components/code-block/code-block.slots.d.ts +16 -0
- package/dist/components/code-block/code-block.slots.js +31 -0
- package/dist/components/code-block/index.d.ts +3 -0
- package/dist/components/code-block/language-label.js +43 -0
- package/dist/components/collapsible/collapsible.context.js +18 -0
- package/dist/components/collapsible/collapsible.d.ts +167 -0
- package/dist/components/collapsible/collapsible.js +182 -0
- package/dist/components/collapsible/collapsible.props.d.ts +33 -0
- package/dist/components/collapsible/collapsible.props.js +44 -0
- package/dist/components/collapsible/collapsible.slots.d.ts +25 -0
- package/dist/components/collapsible/collapsible.slots.js +40 -0
- package/dist/components/collapsible/collapsible.types.d.ts +23 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/color-picker/area.d.ts +11 -0
- package/dist/components/color-picker/area.js +148 -0
- package/dist/components/color-picker/color-picker.d.ts +110 -0
- package/dist/components/color-picker/color-picker.js +149 -0
- package/dist/components/color-picker/color-picker.props.d.ts +69 -0
- package/dist/components/color-picker/color-picker.props.js +74 -0
- package/dist/components/color-picker/color-picker.slots.js +21 -0
- package/dist/components/color-picker/color.d.ts +18 -0
- package/dist/components/color-picker/color.js +224 -0
- package/dist/components/color-picker/context.d.ts +25 -0
- package/dist/components/color-picker/context.js +23 -0
- package/dist/components/color-picker/eyedropper.d.ts +14 -0
- package/dist/components/color-picker/eyedropper.js +50 -0
- package/dist/components/color-picker/format-tabs.d.ts +11 -0
- package/dist/components/color-picker/format-tabs.js +35 -0
- package/dist/components/color-picker/index.d.ts +3 -0
- package/dist/components/color-picker/inputs.d.ts +16 -0
- package/dist/components/color-picker/inputs.js +61 -0
- package/dist/components/color-picker/sliders.d.ts +17 -0
- package/dist/components/color-picker/sliders.js +94 -0
- package/dist/components/color-picker/store.js +48 -0
- package/dist/components/color-picker/swatch.d.ts +15 -0
- package/dist/components/color-picker/swatch.js +25 -0
- package/dist/components/color-swatch/color-swatch-picker.d.ts +87 -0
- package/dist/components/color-swatch/color-swatch-picker.js +73 -0
- package/dist/components/color-swatch/color-swatch.context.js +8 -0
- package/dist/components/color-swatch/color-swatch.d.ts +55 -0
- package/dist/components/color-swatch/color-swatch.js +48 -0
- package/dist/components/color-swatch/color-swatch.props.d.ts +54 -0
- package/dist/components/color-swatch/color-swatch.props.js +32 -0
- package/dist/components/color-swatch/color-swatch.slots.js +13 -0
- package/dist/components/color-swatch/index.d.ts +2 -0
- package/dist/components/combobox/combobox.context.js +13 -0
- package/dist/components/combobox/combobox.d.ts +328 -0
- package/dist/components/combobox/combobox.js +315 -0
- package/dist/components/combobox/combobox.props.d.ts +85 -0
- package/dist/components/combobox/combobox.props.js +79 -0
- package/dist/components/combobox/combobox.slots.d.ts +28 -0
- package/dist/components/combobox/combobox.slots.js +63 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/context-menu/context-menu.d.ts +254 -0
- package/dist/components/context-menu/context-menu.js +150 -0
- package/dist/components/context-menu/context-menu.props.d.ts +22 -0
- package/dist/components/context-menu/context-menu.props.js +32 -0
- package/dist/components/context-menu/context-menu.slots.d.ts +24 -0
- package/dist/components/context-menu/context-menu.slots.js +42 -0
- package/dist/components/context-menu/index.d.ts +2 -0
- package/dist/components/copy-button/copy-button.d.ts +56 -0
- package/dist/components/copy-button/copy-button.js +88 -0
- package/dist/components/copy-button/copy-button.props.d.ts +27 -0
- package/dist/components/copy-button/copy-button.props.js +51 -0
- package/dist/components/copy-button/copy-button.slots.d.ts +20 -0
- package/dist/components/copy-button/copy-button.slots.js +36 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/dialog/dialog.context.js +15 -0
- package/dist/components/dialog/dialog.d.ts +299 -0
- package/dist/components/dialog/dialog.js +263 -0
- package/dist/components/dialog/dialog.props.d.ts +71 -0
- package/dist/components/dialog/dialog.props.js +75 -0
- package/dist/components/dialog/dialog.slots.d.ts +26 -0
- package/dist/components/dialog/dialog.slots.js +46 -0
- package/dist/components/dialog/dialog.types.d.ts +16 -0
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/field/field.d.ts +221 -0
- package/dist/components/field/field.js +192 -0
- package/dist/components/field/field.props.d.ts +66 -0
- package/dist/components/field/field.props.js +65 -0
- package/dist/components/field/field.slots.d.ts +35 -0
- package/dist/components/field/field.slots.js +54 -0
- package/dist/components/field/field.types.d.ts +5 -0
- package/dist/components/field/index.d.ts +4 -0
- package/dist/components/inline-code/index.d.ts +1 -0
- package/dist/components/inline-code/inline-code.d.ts +46 -0
- package/dist/components/inline-code/inline-code.js +36 -0
- package/dist/components/inline-code/inline-code.props.d.ts +17 -0
- package/dist/components/inline-code/inline-code.props.js +27 -0
- package/dist/components/inline-code/inline-code.slots.js +8 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/input.context.js +13 -0
- package/dist/components/input/input.d.ts +161 -0
- package/dist/components/input/input.js +117 -0
- package/dist/components/input/input.props.d.ts +51 -0
- package/dist/components/input/input.props.js +50 -0
- package/dist/components/input/input.slots.d.ts +35 -0
- package/dist/components/input/input.slots.js +46 -0
- package/dist/components/input/input.types.d.ts +12 -0
- package/dist/components/kbd/glyphs.js +45 -0
- package/dist/components/kbd/index.d.ts +1 -0
- package/dist/components/kbd/kbd.d.ts +61 -0
- package/dist/components/kbd/kbd.js +233 -0
- package/dist/components/kbd/kbd.props.d.ts +30 -0
- package/dist/components/kbd/kbd.props.js +39 -0
- package/dist/components/kbd/kbd.slots.js +14 -0
- package/dist/components/kbd/use-apple-platform.js +25 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/menu.d.ts +355 -0
- package/dist/components/menu/menu.js +263 -0
- package/dist/components/menu/menu.props.d.ts +92 -0
- package/dist/components/menu/menu.props.js +97 -0
- package/dist/components/menu/menu.slots.d.ts +32 -0
- package/dist/components/menu/menu.slots.js +60 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/menubar.context.js +13 -0
- package/dist/components/menubar/menubar.d.ts +162 -0
- package/dist/components/menubar/menubar.js +122 -0
- package/dist/components/menubar/menubar.props.d.ts +41 -0
- package/dist/components/menubar/menubar.props.js +45 -0
- package/dist/components/menubar/menubar.slots.d.ts +26 -0
- package/dist/components/menubar/menubar.slots.js +40 -0
- package/dist/components/meter/index.d.ts +2 -0
- package/dist/components/meter/meter.context.d.ts +9 -0
- package/dist/components/meter/meter.context.js +13 -0
- package/dist/components/meter/meter.d.ts +163 -0
- package/dist/components/meter/meter.js +121 -0
- package/dist/components/meter/meter.props.d.ts +50 -0
- package/dist/components/meter/meter.props.js +33 -0
- package/dist/components/meter/meter.slots.d.ts +18 -0
- package/dist/components/meter/meter.slots.js +31 -0
- package/dist/components/navigation-menu/index.d.ts +2 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +328 -0
- package/dist/components/navigation-menu/navigation-menu.js +274 -0
- package/dist/components/navigation-menu/navigation-menu.props.d.ts +98 -0
- package/dist/components/navigation-menu/navigation-menu.props.js +90 -0
- package/dist/components/navigation-menu/navigation-menu.slots.d.ts +34 -0
- package/dist/components/navigation-menu/navigation-menu.slots.js +60 -0
- package/dist/components/number-field/index.d.ts +2 -0
- package/dist/components/number-field/number-field.context.d.ts +13 -0
- package/dist/components/number-field/number-field.context.js +13 -0
- package/dist/components/number-field/number-field.d.ts +197 -0
- package/dist/components/number-field/number-field.js +187 -0
- package/dist/components/number-field/number-field.props.d.ts +66 -0
- package/dist/components/number-field/number-field.props.js +50 -0
- package/dist/components/number-field/number-field.slots.d.ts +31 -0
- package/dist/components/number-field/number-field.slots.js +48 -0
- package/dist/components/otp-field/index.d.ts +3 -0
- package/dist/components/otp-field/otp-field.context.js +13 -0
- package/dist/components/otp-field/otp-field.d.ts +99 -0
- package/dist/components/otp-field/otp-field.js +76 -0
- package/dist/components/otp-field/otp-field.props.d.ts +48 -0
- package/dist/components/otp-field/otp-field.props.js +43 -0
- package/dist/components/otp-field/otp-field.slots.d.ts +28 -0
- package/dist/components/otp-field/otp-field.slots.js +39 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/popover.d.ts +192 -0
- package/dist/components/popover/popover.js +152 -0
- package/dist/components/popover/popover.props.d.ts +34 -0
- package/dist/components/popover/popover.props.js +44 -0
- package/dist/components/popover/popover.slots.d.ts +22 -0
- package/dist/components/popover/popover.slots.js +42 -0
- package/dist/components/preview-card/index.d.ts +2 -0
- package/dist/components/preview-card/preview-card.d.ts +182 -0
- package/dist/components/preview-card/preview-card.js +146 -0
- package/dist/components/preview-card/preview-card.props.d.ts +37 -0
- package/dist/components/preview-card/preview-card.props.js +48 -0
- package/dist/components/preview-card/preview-card.slots.d.ts +22 -0
- package/dist/components/preview-card/preview-card.slots.js +39 -0
- package/dist/components/progress/index.d.ts +3 -0
- package/dist/components/progress/progress.context.d.ts +9 -0
- package/dist/components/progress/progress.context.js +13 -0
- package/dist/components/progress/progress.d.ts +139 -0
- package/dist/components/progress/progress.js +92 -0
- package/dist/components/progress/progress.props.d.ts +56 -0
- package/dist/components/progress/progress.props.js +38 -0
- package/dist/components/progress/progress.slots.d.ts +24 -0
- package/dist/components/progress/progress.slots.js +37 -0
- package/dist/components/radio/index.d.ts +2 -0
- package/dist/components/radio/radio.context.js +5 -0
- package/dist/components/radio/radio.d.ts +205 -0
- package/dist/components/radio/radio.js +168 -0
- package/dist/components/radio/radio.props.d.ts +106 -0
- package/dist/components/radio/radio.props.js +65 -0
- package/dist/components/radio/radio.slots.d.ts +29 -0
- package/dist/components/radio/radio.slots.js +44 -0
- package/dist/components/rail/index.d.ts +3 -0
- package/dist/components/rail/rail.context.d.ts +17 -0
- package/dist/components/rail/rail.context.js +23 -0
- package/dist/components/rail/rail.d.ts +232 -0
- package/dist/components/rail/rail.js +254 -0
- package/dist/components/rail/rail.props.d.ts +98 -0
- package/dist/components/rail/rail.props.js +64 -0
- package/dist/components/rail/rail.slots.d.ts +20 -0
- package/dist/components/rail/rail.slots.js +40 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/scroll-area.context.js +15 -0
- package/dist/components/scroll-area/scroll-area.d.ts +217 -0
- package/dist/components/scroll-area/scroll-area.js +153 -0
- package/dist/components/scroll-area/scroll-area.props.d.ts +73 -0
- package/dist/components/scroll-area/scroll-area.props.js +64 -0
- package/dist/components/scroll-area/scroll-area.slots.d.ts +40 -0
- package/dist/components/scroll-area/scroll-area.slots.js +54 -0
- package/dist/components/scroll-area/scroll-area.types.d.ts +24 -0
- package/dist/components/search-dialog/index.d.ts +3 -0
- package/dist/components/search-dialog/parts/input.d.ts +24 -0
- package/dist/components/search-dialog/parts/input.js +53 -0
- package/dist/components/search-dialog/parts/messages.d.ts +80 -0
- package/dist/components/search-dialog/parts/messages.js +75 -0
- package/dist/components/search-dialog/parts/results.d.ts +43 -0
- package/dist/components/search-dialog/parts/results.js +63 -0
- package/dist/components/search-dialog/parts/root.d.ts +54 -0
- package/dist/components/search-dialog/parts/root.js +99 -0
- package/dist/components/search-dialog/search-dialog.context.d.ts +15 -0
- package/dist/components/search-dialog/search-dialog.context.js +20 -0
- package/dist/components/search-dialog/search-dialog.d.ts +84 -0
- package/dist/components/search-dialog/search-dialog.js +43 -0
- package/dist/components/search-dialog/search-dialog.props.d.ts +45 -0
- package/dist/components/search-dialog/search-dialog.props.js +49 -0
- package/dist/components/search-dialog/search-dialog.slots.d.ts +16 -0
- package/dist/components/search-dialog/search-dialog.slots.js +32 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/select.context.js +17 -0
- package/dist/components/select/select.d.ts +356 -0
- package/dist/components/select/select.js +314 -0
- package/dist/components/select/select.props.d.ts +110 -0
- package/dist/components/select/select.props.js +103 -0
- package/dist/components/select/select.slots.d.ts +38 -0
- package/dist/components/select/select.slots.js +67 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/separator.d.ts +69 -0
- package/dist/components/separator/separator.js +44 -0
- package/dist/components/separator/separator.props.d.ts +30 -0
- package/dist/components/separator/separator.props.js +30 -0
- package/dist/components/separator/separator.slots.d.ts +22 -0
- package/dist/components/separator/separator.slots.js +21 -0
- package/dist/components/separator/separator.types.d.ts +5 -0
- package/dist/components/sheet/index.d.ts +3 -0
- package/dist/components/sheet/sheet-stack.d.ts +106 -0
- package/dist/components/sheet/sheet-stack.js +146 -0
- package/dist/components/sheet/sheet.d.ts +279 -0
- package/dist/components/sheet/sheet.js +264 -0
- package/dist/components/sheet/sheet.props.d.ts +74 -0
- package/dist/components/sheet/sheet.props.js +77 -0
- package/dist/components/sheet/sheet.slots.js +22 -0
- package/dist/components/sheet/sheet.types.d.ts +12 -0
- package/dist/components/slider/index.d.ts +3 -0
- package/dist/components/slider/slider.context.d.ts +5 -0
- package/dist/components/slider/slider.context.js +29 -0
- package/dist/components/slider/slider.d.ts +230 -0
- package/dist/components/slider/slider.js +274 -0
- package/dist/components/slider/slider.props.d.ts +72 -0
- package/dist/components/slider/slider.props.js +59 -0
- package/dist/components/slider/slider.slots.d.ts +30 -0
- package/dist/components/slider/slider.slots.js +50 -0
- package/dist/components/surface/index.d.ts +1 -0
- package/dist/components/surface/surface.d.ts +84 -0
- package/dist/components/surface/surface.js +48 -0
- package/dist/components/surface/surface.props.d.ts +35 -0
- package/dist/components/surface/surface.props.js +26 -0
- package/dist/components/surface/surface.slots.js +9 -0
- package/dist/components/surface/surface.types.d.ts +14 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/switch.context.js +14 -0
- package/dist/components/switch/switch.d.ts +110 -0
- package/dist/components/switch/switch.js +92 -0
- package/dist/components/switch/switch.props.d.ts +68 -0
- package/dist/components/switch/switch.props.js +41 -0
- package/dist/components/switch/switch.slots.d.ts +23 -0
- package/dist/components/switch/switch.slots.js +35 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/table.d.ts +104 -0
- package/dist/components/table/table.js +92 -0
- package/dist/components/table/table.props.d.ts +38 -0
- package/dist/components/table/table.props.js +49 -0
- package/dist/components/table/table.slots.js +17 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/tabs.context.d.ts +9 -0
- package/dist/components/tabs/tabs.context.js +13 -0
- package/dist/components/tabs/tabs.d.ts +139 -0
- package/dist/components/tabs/tabs.js +118 -0
- package/dist/components/tabs/tabs.props.d.ts +59 -0
- package/dist/components/tabs/tabs.props.js +39 -0
- package/dist/components/tabs/tabs.slots.d.ts +20 -0
- package/dist/components/tabs/tabs.slots.js +33 -0
- package/dist/components/textarea/index.d.ts +3 -0
- package/dist/components/textarea/textarea.context.js +13 -0
- package/dist/components/textarea/textarea.d.ts +142 -0
- package/dist/components/textarea/textarea.js +129 -0
- package/dist/components/textarea/textarea.props.d.ts +44 -0
- package/dist/components/textarea/textarea.props.js +32 -0
- package/dist/components/textarea/textarea.slots.d.ts +23 -0
- package/dist/components/textarea/textarea.slots.js +33 -0
- package/dist/components/textarea/textarea.types.d.ts +5 -0
- package/dist/components/toast/index.d.ts +4 -0
- package/dist/components/toast/toast.d.ts +241 -0
- package/dist/components/toast/toast.js +193 -0
- package/dist/components/toast/toast.manager.d.ts +76 -0
- package/dist/components/toast/toast.manager.js +71 -0
- package/dist/components/toast/toast.props.d.ts +66 -0
- package/dist/components/toast/toast.props.js +74 -0
- package/dist/components/toast/toast.slots.d.ts +30 -0
- package/dist/components/toast/toast.slots.js +49 -0
- package/dist/components/toast/toast.types.d.ts +19 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/toggle.context.d.ts +11 -0
- package/dist/components/toggle/toggle.context.js +14 -0
- package/dist/components/toggle/toggle.d.ts +136 -0
- package/dist/components/toggle/toggle.js +101 -0
- package/dist/components/toggle/toggle.props.d.ts +51 -0
- package/dist/components/toggle/toggle.props.js +29 -0
- package/dist/components/toggle/toggle.slots.d.ts +26 -0
- package/dist/components/toggle/toggle.slots.js +36 -0
- package/dist/components/toolbar/index.d.ts +3 -0
- package/dist/components/toolbar/toolbar.context.js +23 -0
- package/dist/components/toolbar/toolbar.d.ts +218 -0
- package/dist/components/toolbar/toolbar.js +197 -0
- package/dist/components/toolbar/toolbar.props.d.ts +54 -0
- package/dist/components/toolbar/toolbar.props.js +55 -0
- package/dist/components/toolbar/toolbar.slots.d.ts +24 -0
- package/dist/components/toolbar/toolbar.slots.js +37 -0
- package/dist/components/toolbar/toolbar.types.d.ts +15 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/tooltip.d.ts +170 -0
- package/dist/components/tooltip/tooltip.js +143 -0
- package/dist/components/tooltip/tooltip.props.d.ts +36 -0
- package/dist/components/tooltip/tooltip.props.js +42 -0
- package/dist/components/tooltip/tooltip.slots.d.ts +26 -0
- package/dist/components/tooltip/tooltip.slots.js +42 -0
- package/dist/core/derive-threshold-tone.js +35 -0
- package/dist/core/merge-class-name.d.ts +17 -0
- package/dist/core/merge-class-name.js +16 -0
- package/dist/core/noctis-provider.d.ts +38 -0
- package/dist/core/noctis-provider.js +44 -0
- package/dist/core/primitive/index.d.ts +1 -0
- package/dist/core/primitive/primitive.d.ts +44 -0
- package/dist/core/primitive/primitive.js +27 -0
- package/dist/core/radius-scope/index.d.ts +2 -0
- package/dist/core/radius-scope/radius-scope.d.ts +43 -0
- package/dist/core/radius-scope/radius-scope.js +36 -0
- package/dist/core/radius-scope/radius-scope.styles.d.ts +13 -0
- package/dist/core/radius-scope/radius-scope.styles.js +11 -0
- package/dist/core/render.d.ts +24 -0
- package/dist/core/render.js +12 -0
- package/dist/core/use-copy.d.ts +13 -0
- package/dist/core/use-copy.js +30 -0
- package/dist/core/use-injected-labels.js +55 -0
- package/dist/core/use-reduced-motion.d.ts +9 -0
- package/dist/core/use-reduced-motion.js +26 -0
- package/dist/core/visually-hidden/index.d.ts +1 -0
- package/dist/core/visually-hidden/visually-hidden.d.ts +24 -0
- package/dist/core/visually-hidden/visually-hidden.js +19 -0
- package/dist/i18n/default-messages.d.ts +12 -0
- package/dist/i18n/default-messages.js +10 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/messages/index.d.ts +2 -0
- package/dist/i18n/messages/index.js +2 -0
- package/dist/icons/glyphs.d.ts +2 -0
- package/dist/icons/glyphs.js +2 -0
- package/dist/icons/icon.d.ts +40 -0
- package/dist/icons/icon.js +26 -0
- package/dist/icons/icon.styles.d.ts +9 -0
- package/dist/icons/index.d.ts +3 -0
- package/dist/index.d.ts +126 -0
- package/dist/index.js +112 -0
- package/dist/primitives/accordion.d.ts +7 -0
- package/dist/primitives/accordion.js +8 -0
- package/dist/primitives/alert-dialog.d.ts +7 -0
- package/dist/primitives/alert-dialog.js +8 -0
- package/dist/primitives/autocomplete/autocomplete.d.ts +58 -0
- package/dist/primitives/autocomplete/autocomplete.js +58 -0
- package/dist/primitives/autocomplete/index.d.ts +1 -0
- package/dist/primitives/autocomplete.d.ts +2 -0
- package/dist/primitives/autocomplete.js +2 -0
- package/dist/primitives/avatar.d.ts +7 -0
- package/dist/primitives/avatar.js +8 -0
- package/dist/primitives/button.d.ts +7 -0
- package/dist/primitives/button.js +8 -0
- package/dist/primitives/checkbox-group.d.ts +7 -0
- package/dist/primitives/checkbox-group.js +8 -0
- package/dist/primitives/checkbox.d.ts +7 -0
- package/dist/primitives/checkbox.js +8 -0
- package/dist/primitives/collapsible.d.ts +7 -0
- package/dist/primitives/collapsible.js +8 -0
- package/dist/primitives/combobox/combobox.d.ts +71 -0
- package/dist/primitives/combobox/combobox.js +66 -0
- package/dist/primitives/combobox/index.d.ts +1 -0
- package/dist/primitives/combobox.d.ts +2 -0
- package/dist/primitives/combobox.js +2 -0
- package/dist/primitives/context-menu.d.ts +7 -0
- package/dist/primitives/context-menu.js +8 -0
- package/dist/primitives/csp-provider.d.ts +1 -0
- package/dist/primitives/csp-provider.js +2 -0
- package/dist/primitives/dialog.d.ts +7 -0
- package/dist/primitives/dialog.js +8 -0
- package/dist/primitives/direction-provider.d.ts +1 -0
- package/dist/primitives/direction-provider.js +8 -0
- package/dist/primitives/drawer.d.ts +1 -0
- package/dist/primitives/drawer.js +2 -0
- package/dist/primitives/field.d.ts +7 -0
- package/dist/primitives/field.js +8 -0
- package/dist/primitives/fieldset.d.ts +7 -0
- package/dist/primitives/fieldset.js +8 -0
- package/dist/primitives/form.d.ts +7 -0
- package/dist/primitives/form.js +8 -0
- package/dist/primitives/index.d.ts +79 -0
- package/dist/primitives/index.js +113 -0
- package/dist/primitives/input.d.ts +7 -0
- package/dist/primitives/input.js +8 -0
- package/dist/primitives/menu.d.ts +7 -0
- package/dist/primitives/menu.js +8 -0
- package/dist/primitives/menubar.d.ts +7 -0
- package/dist/primitives/menubar.js +8 -0
- package/dist/primitives/meter/index.d.ts +1 -0
- package/dist/primitives/meter/meter.d.ts +56 -0
- package/dist/primitives/meter/meter.js +59 -0
- package/dist/primitives/meter.d.ts +2 -0
- package/dist/primitives/meter.js +2 -0
- package/dist/primitives/navigation-menu.d.ts +7 -0
- package/dist/primitives/navigation-menu.js +8 -0
- package/dist/primitives/number-field/context.d.ts +13 -0
- package/dist/primitives/number-field/context.js +36 -0
- package/dist/primitives/number-field/index.d.ts +2 -0
- package/dist/primitives/number-field/number-field.d.ts +90 -0
- package/dist/primitives/number-field/number-field.js +107 -0
- package/dist/primitives/number-field.d.ts +3 -0
- package/dist/primitives/number-field.js +2 -0
- package/dist/primitives/otp-field.d.ts +7 -0
- package/dist/primitives/otp-field.js +8 -0
- package/dist/primitives/popover.d.ts +7 -0
- package/dist/primitives/popover.js +8 -0
- package/dist/primitives/preview-card.d.ts +7 -0
- package/dist/primitives/preview-card.js +8 -0
- package/dist/primitives/progress/index.d.ts +1 -0
- package/dist/primitives/progress/progress.d.ts +56 -0
- package/dist/primitives/progress/progress.js +59 -0
- package/dist/primitives/progress.d.ts +2 -0
- package/dist/primitives/progress.js +2 -0
- package/dist/primitives/radio-group.d.ts +7 -0
- package/dist/primitives/radio-group.js +8 -0
- package/dist/primitives/radio.d.ts +7 -0
- package/dist/primitives/radio.js +8 -0
- package/dist/primitives/scroll-area.d.ts +7 -0
- package/dist/primitives/scroll-area.js +8 -0
- package/dist/primitives/select.d.ts +7 -0
- package/dist/primitives/select.js +8 -0
- package/dist/primitives/separator.d.ts +7 -0
- package/dist/primitives/separator.js +8 -0
- package/dist/primitives/slider/context.d.ts +12 -0
- package/dist/primitives/slider/context.js +18 -0
- package/dist/primitives/slider/index.d.ts +2 -0
- package/dist/primitives/slider/slider.d.ts +83 -0
- package/dist/primitives/slider/slider.js +99 -0
- package/dist/primitives/slider.d.ts +3 -0
- package/dist/primitives/slider.js +2 -0
- package/dist/primitives/switch.d.ts +1 -0
- package/dist/primitives/switch.js +2 -0
- package/dist/primitives/tabs.d.ts +7 -0
- package/dist/primitives/tabs.js +8 -0
- package/dist/primitives/toast/context.d.ts +11 -0
- package/dist/primitives/toast/context.js +18 -0
- package/dist/primitives/toast/index.d.ts +2 -0
- package/dist/primitives/toast/toast.d.ts +122 -0
- package/dist/primitives/toast/toast.js +133 -0
- package/dist/primitives/toast.d.ts +3 -0
- package/dist/primitives/toast.js +2 -0
- package/dist/primitives/toggle-group.d.ts +7 -0
- package/dist/primitives/toggle-group.js +8 -0
- package/dist/primitives/toggle.d.ts +7 -0
- package/dist/primitives/toggle.js +8 -0
- package/dist/primitives/toolbar.d.ts +7 -0
- package/dist/primitives/toolbar.js +8 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.js +8 -0
- package/dist/props.d.ts +46 -0
- package/dist/props.js +46 -0
- package/dist/styles.css +11513 -0
- package/dist/tailwind/cn.d.ts +33 -0
- package/dist/tailwind/cn.js +42 -0
- package/dist/tailwind/index.d.ts +3 -0
- package/dist/tailwind/index.js +3 -0
- package/dist/tailwind/tv.d.ts +20 -0
- package/dist/tailwind/tv.js +11 -0
- package/dist/tailwind.css +485 -0
- package/dist/theme/react.d.ts +1 -0
- package/dist/theme/react.js +1 -0
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +1 -0
- package/dist/tokens/react.d.ts +1 -0
- package/dist/tokens/react.js +1 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +1 -0
- package/package.json +121 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { converter, formatHex, formatHex8, parse } from "culori";
|
|
2
|
+
//#region src/components/color-picker/color.ts
|
|
3
|
+
/**
|
|
4
|
+
* The color core for {@link ColorPicker} — the one module in the design system that legitimately
|
|
5
|
+
* authors raw color, the same exception the theme engine carries. Every conversion, every CSS color
|
|
6
|
+
* string the picker paints (thumb fills, hue spectrum, the saturation/value field, the alpha
|
|
7
|
+
* checkerboard) is produced here, so the component files stay free of raw color literals and keep to
|
|
8
|
+
* semantic tokens. `stridge/semantic-tokens` is turned off for this file alone in `.oxlintrc.json`.
|
|
9
|
+
*
|
|
10
|
+
* `culori` does the science; its color objects never leak past this module. Internally the picker
|
|
11
|
+
* stores an RGB canonical plus an HSV mirror (HSV drives the 2D field and the hue wheel, where RGB
|
|
12
|
+
* round-trips lose the hue at the gray axis). Channel scales follow editing-friendly ranges, not
|
|
13
|
+
* culori's `[0,1]`: RGB `[0,255]`, HSV/HSL `h [0,360]` · `s,v,l [0,100]`, OKLCH `l [0,100]%` ·
|
|
14
|
+
* `c [0,0.4]` · `h [0,360]`, alpha `[0,1]` throughout.
|
|
15
|
+
*/
|
|
16
|
+
/** Every format, in tab order. OKLCH first. */
|
|
17
|
+
const COLOR_FORMATS = [
|
|
18
|
+
"oklch",
|
|
19
|
+
"hex",
|
|
20
|
+
"rgb",
|
|
21
|
+
"hsl"
|
|
22
|
+
];
|
|
23
|
+
/** The default color for an uncontrolled picker with no value — the Noctis Blue accent seed. */
|
|
24
|
+
const DEFAULT_COLOR = "oklch(0.504 0.151 275.2)";
|
|
25
|
+
const toRgb = converter("rgb");
|
|
26
|
+
const toHsv = converter("hsv");
|
|
27
|
+
const toHsl = converter("hsl");
|
|
28
|
+
const toOklch = converter("oklch");
|
|
29
|
+
/** A black fallback, used when a conversion fails (out-of-range input). Keeps the channels finite. */
|
|
30
|
+
const BLACK = {
|
|
31
|
+
r: 0,
|
|
32
|
+
g: 0,
|
|
33
|
+
b: 0,
|
|
34
|
+
a: 1
|
|
35
|
+
};
|
|
36
|
+
/** Parse any CSS color string into canonical RGB, or `null` if it isn't a color. */
|
|
37
|
+
function parseColor(input) {
|
|
38
|
+
const parsed = parse(input);
|
|
39
|
+
if (!parsed) return null;
|
|
40
|
+
const rgb = toRgb(parsed);
|
|
41
|
+
if (!rgb) return null;
|
|
42
|
+
return {
|
|
43
|
+
r: to255(rgb.r),
|
|
44
|
+
g: to255(rgb.g),
|
|
45
|
+
b: to255(rgb.b),
|
|
46
|
+
a: rgb.alpha ?? 1
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Whether a string is a parseable CSS color — the validity test the text inputs commit on. */
|
|
50
|
+
function isValidColor(input) {
|
|
51
|
+
return parse(input) !== void 0;
|
|
52
|
+
}
|
|
53
|
+
/** A 6-digit hex, optionally `#`-prefixed (opaque). */
|
|
54
|
+
const HEX6 = /^#?[0-9a-f]{6}$/i;
|
|
55
|
+
/** An 8-digit hex, optionally `#`-prefixed (with alpha). */
|
|
56
|
+
const HEX8 = /^#?[0-9a-f]{8}$/i;
|
|
57
|
+
/** Convert canonical RGB to HSV (preserving hue/alpha across the gray axis where RGB can't). */
|
|
58
|
+
function rgbToHsv(rgb) {
|
|
59
|
+
const hsv = toHsv({
|
|
60
|
+
mode: "rgb",
|
|
61
|
+
r: rgb.r / 255,
|
|
62
|
+
g: rgb.g / 255,
|
|
63
|
+
b: rgb.b / 255,
|
|
64
|
+
alpha: rgb.a
|
|
65
|
+
});
|
|
66
|
+
if (!hsv) return {
|
|
67
|
+
h: 0,
|
|
68
|
+
s: 0,
|
|
69
|
+
v: 0,
|
|
70
|
+
a: rgb.a
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
h: wrapHue(hsv.h ?? 0),
|
|
74
|
+
s: round((hsv.s ?? 0) * 100),
|
|
75
|
+
v: round((hsv.v ?? 0) * 100),
|
|
76
|
+
a: rgb.a
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Convert HSV back to canonical RGB, clamped into the sRGB gamut. */
|
|
80
|
+
function hsvToRgb(hsv) {
|
|
81
|
+
const rgb = toRgb({
|
|
82
|
+
mode: "hsv",
|
|
83
|
+
h: hsv.h,
|
|
84
|
+
s: hsv.s / 100,
|
|
85
|
+
v: hsv.v / 100,
|
|
86
|
+
alpha: hsv.a
|
|
87
|
+
});
|
|
88
|
+
if (!rgb) return {
|
|
89
|
+
...BLACK,
|
|
90
|
+
a: hsv.a
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
r: to255(rgb.r),
|
|
94
|
+
g: to255(rgb.g),
|
|
95
|
+
b: to255(rgb.b),
|
|
96
|
+
a: hsv.a
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Serialize canonical RGB to the given format. `withAlpha` keeps the alpha channel in the output. */
|
|
100
|
+
function formatColor(rgb, format, withAlpha) {
|
|
101
|
+
switch (format) {
|
|
102
|
+
case "hex": return formatHexString(rgb, withAlpha);
|
|
103
|
+
case "rgb": return formatRgbString(rgb, withAlpha);
|
|
104
|
+
case "hsl": return formatHslString(toHsl({
|
|
105
|
+
mode: "rgb",
|
|
106
|
+
r: rgb.r / 255,
|
|
107
|
+
g: rgb.g / 255,
|
|
108
|
+
b: rgb.b / 255,
|
|
109
|
+
alpha: rgb.a
|
|
110
|
+
}), withAlpha);
|
|
111
|
+
case "oklch": return formatOklchString(toOklch({
|
|
112
|
+
mode: "rgb",
|
|
113
|
+
r: rgb.r / 255,
|
|
114
|
+
g: rgb.g / 255,
|
|
115
|
+
b: rgb.b / 255,
|
|
116
|
+
alpha: rgb.a
|
|
117
|
+
}), withAlpha);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** An opaque `rgb()` string for a thumb border, the field base, or a solid swatch. */
|
|
121
|
+
function rgbCss(rgb) {
|
|
122
|
+
return `rgb(${byte(rgb.r)} ${byte(rgb.g)} ${byte(rgb.b)})`;
|
|
123
|
+
}
|
|
124
|
+
/** The fully-saturated, full-value color at a hue — the base wash under the saturation/value field. */
|
|
125
|
+
function hueCss(hue) {
|
|
126
|
+
return rgbCss(hsvToRgb({
|
|
127
|
+
h: hue,
|
|
128
|
+
s: 100,
|
|
129
|
+
v: 100,
|
|
130
|
+
a: 1
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
/** The swatch fill for the current color: solid when opaque, color-over-checkerboard when translucent. */
|
|
134
|
+
function swatchFillCss(rgb, withAlpha) {
|
|
135
|
+
if (!withAlpha || rgb.a >= 1) return rgbCss(rgb);
|
|
136
|
+
return `linear-gradient(${rgbaCss(rgb)}, ${rgbaCss(rgb)}), ${CHECKERBOARD}`;
|
|
137
|
+
}
|
|
138
|
+
/** The alpha-slider track: transparent → the opaque color, laid over the checkerboard. */
|
|
139
|
+
function alphaTrackCss(rgb) {
|
|
140
|
+
return `linear-gradient(to right, rgb(0 0 0 / 0), ${rgbCss(rgb)}), ${CHECKERBOARD}`;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The slider/area handle border stack — a 2px white ring fenced by a translucent-black hairline on
|
|
144
|
+
* both sides, so the thumb stays legible over any hue (the Adobe-style color handle). Apply as the
|
|
145
|
+
* thumb's `box-shadow`, over a color-on-checkerboard `background`.
|
|
146
|
+
*/
|
|
147
|
+
const HANDLE_SHADOW = "inset 0 0 0 1px rgb(0 0 0 / 0.42), 0 0 0 2px rgb(255 255 255), 0 0 0 3px rgb(0 0 0 / 0.42)";
|
|
148
|
+
/**
|
|
149
|
+
* The "no color" diagonal slash for a fully-transparent swatch — a thin stroke in the color the
|
|
150
|
+
* element carries (set `color` to a token and the stroke follows via `currentColor`).
|
|
151
|
+
*/
|
|
152
|
+
function slashCss() {
|
|
153
|
+
return "linear-gradient(to bottom right, transparent calc(50% - 1px), currentColor calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)) no-repeat";
|
|
154
|
+
}
|
|
155
|
+
/** The full hue spectrum, left (0°) to right (360°). Flip with `rtl:-scale-x-100` for reading order. */
|
|
156
|
+
const HUE_GRADIENT = "linear-gradient(to right, oklch(63% 0.25 29), oklch(80% 0.2 86), oklch(87% 0.25 142), oklch(90% 0.18 195), oklch(60% 0.22 264), oklch(55% 0.28 328), oklch(63% 0.25 389))";
|
|
157
|
+
/** The white→transparent wash that fades the field from gray (left) to full chroma (right). */
|
|
158
|
+
const FIELD_SATURATION_GRADIENT = "linear-gradient(to right, oklch(100% 0 0), oklch(100% 0 0 / 0))";
|
|
159
|
+
/** The transparent→black wash that darkens the field from top to bottom. */
|
|
160
|
+
const FIELD_VALUE_GRADIENT = "linear-gradient(to top, oklch(0% 0 0), oklch(0% 0 0 / 0))";
|
|
161
|
+
/** A small checkerboard, the universal "transparency" backing behind translucent color. */
|
|
162
|
+
const CHECKERBOARD = "repeating-conic-gradient(oklch(75% 0 0) 0% 25%, oklch(100% 0 0) 0% 50%) 50% / 12px 12px";
|
|
163
|
+
function rgbaCss(rgb) {
|
|
164
|
+
return `rgb(${byte(rgb.r)} ${byte(rgb.g)} ${byte(rgb.b)} / ${trim(rgb.a.toFixed(3))})`;
|
|
165
|
+
}
|
|
166
|
+
function formatHexString(rgb, withAlpha) {
|
|
167
|
+
const color = {
|
|
168
|
+
mode: "rgb",
|
|
169
|
+
r: rgb.r / 255,
|
|
170
|
+
g: rgb.g / 255,
|
|
171
|
+
b: rgb.b / 255,
|
|
172
|
+
alpha: rgb.a
|
|
173
|
+
};
|
|
174
|
+
return !withAlpha || rgb.a >= 1 ? formatHex(color) : formatHex8(color);
|
|
175
|
+
}
|
|
176
|
+
function formatRgbString(rgb, withAlpha) {
|
|
177
|
+
const r = byte(rgb.r);
|
|
178
|
+
const g = byte(rgb.g);
|
|
179
|
+
const b = byte(rgb.b);
|
|
180
|
+
if (!withAlpha || rgb.a >= 1) return `rgb(${r} ${g} ${b})`;
|
|
181
|
+
return `rgb(${r} ${g} ${b} / ${trim(rgb.a.toFixed(3))})`;
|
|
182
|
+
}
|
|
183
|
+
function formatHslString(hsl, withAlpha) {
|
|
184
|
+
if (!hsl) return "hsl(0 0% 0%)";
|
|
185
|
+
const h = round(wrapHue(hsl.h ?? 0));
|
|
186
|
+
const s = round(hsl.s * 100);
|
|
187
|
+
const l = round(hsl.l * 100);
|
|
188
|
+
const a = hsl.alpha ?? 1;
|
|
189
|
+
if (!withAlpha || a >= 1) return `hsl(${h} ${s}% ${l}%)`;
|
|
190
|
+
return `hsl(${h} ${s}% ${l}% / ${trim(a.toFixed(3))})`;
|
|
191
|
+
}
|
|
192
|
+
function formatOklchString(oklch, withAlpha) {
|
|
193
|
+
if (!oklch) return "oklch(0% 0 0)";
|
|
194
|
+
const l = `${trim((oklch.l * 100).toFixed(2))}%`;
|
|
195
|
+
const c = trim(oklch.c.toFixed(3));
|
|
196
|
+
const h = trim(wrapHue(oklch.h ?? 0).toFixed(2));
|
|
197
|
+
const a = oklch.alpha ?? 1;
|
|
198
|
+
if (!withAlpha || a >= 1) return `oklch(${l} ${c} ${h})`;
|
|
199
|
+
return `oklch(${l} ${c} ${h} / ${trim(a.toFixed(3))})`;
|
|
200
|
+
}
|
|
201
|
+
/** culori `[0,1]` channel → an sRGB byte `[0,255]`. */
|
|
202
|
+
function to255(channel) {
|
|
203
|
+
if (Number.isNaN(channel)) return 0;
|
|
204
|
+
return Math.max(0, Math.min(255, Math.round(channel * 255)));
|
|
205
|
+
}
|
|
206
|
+
/** Clamp an already-`[0,255]` channel to a whole byte. */
|
|
207
|
+
function byte(channel) {
|
|
208
|
+
if (Number.isNaN(channel)) return 0;
|
|
209
|
+
return Math.max(0, Math.min(255, Math.round(channel)));
|
|
210
|
+
}
|
|
211
|
+
function round(n, decimals = 0) {
|
|
212
|
+
if (Number.isNaN(n)) return 0;
|
|
213
|
+
const factor = 10 ** decimals;
|
|
214
|
+
return Math.round(n * factor) / factor;
|
|
215
|
+
}
|
|
216
|
+
function wrapHue(n) {
|
|
217
|
+
if (Number.isNaN(n)) return 0;
|
|
218
|
+
return (n % 360 + 360) % 360;
|
|
219
|
+
}
|
|
220
|
+
function trim(s) {
|
|
221
|
+
return s.includes(".") ? s.replace(/0+$/, "").replace(/\.$/, "") : s;
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
export { COLOR_FORMATS, DEFAULT_COLOR, FIELD_SATURATION_GRADIENT, FIELD_VALUE_GRADIENT, HANDLE_SHADOW, HEX6, HEX8, HUE_GRADIENT, alphaTrackCss, formatColor, hsvToRgb, hueCss, isValidColor, parseColor, rgbCss, rgbToHsv, slashCss, swatchFillCss };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/components/color-picker/context.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The accessible names the picker's parts announce. Published as a prop on `ColorPicker.Root` so an
|
|
4
|
+
* app can localize them (the package ships no i18n runtime); the English defaults below keep an
|
|
5
|
+
* unconfigured picker fully labelled. Defined as a constant — not inline JSX — so it satisfies the
|
|
6
|
+
* no-hardcoded-strings rule, the same way a consumer passes translated strings through.
|
|
7
|
+
*/
|
|
8
|
+
interface ColorPickerLabels {
|
|
9
|
+
/** Names the 2D saturation/value field. */
|
|
10
|
+
field: string;
|
|
11
|
+
/** Names the hue slider. */
|
|
12
|
+
hue: string;
|
|
13
|
+
/** Names the alpha slider. */
|
|
14
|
+
alpha: string;
|
|
15
|
+
/** Names the current-color preview swatch. */
|
|
16
|
+
swatch: string;
|
|
17
|
+
/** The eyedropper button. */
|
|
18
|
+
eyeDropper: string;
|
|
19
|
+
/** Names the format selector group. */
|
|
20
|
+
format: string;
|
|
21
|
+
/** Names the color value text input. */
|
|
22
|
+
value: string;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ColorPickerLabels };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, use } from "react";
|
|
3
|
+
//#region src/components/color-picker/context.ts
|
|
4
|
+
/** Sensible English defaults, merged with a consumer's partial `labels` on `ColorPicker.Root`. */
|
|
5
|
+
const DEFAULT_LABELS = {
|
|
6
|
+
field: "Saturation and brightness",
|
|
7
|
+
hue: "Hue",
|
|
8
|
+
alpha: "Alpha",
|
|
9
|
+
swatch: "Selected color",
|
|
10
|
+
eyeDropper: "Pick a color from the screen",
|
|
11
|
+
format: "Color format",
|
|
12
|
+
value: "Color value"
|
|
13
|
+
};
|
|
14
|
+
const ColorPickerContext = createContext(null);
|
|
15
|
+
const ColorPickerProvider = ColorPickerContext.Provider;
|
|
16
|
+
/** Read the picker context, throwing a named error if a part is used outside `ColorPicker.Root`. */
|
|
17
|
+
function useColorPickerContext(part) {
|
|
18
|
+
const context = use(ColorPickerContext);
|
|
19
|
+
if (!context) throw new Error(`ColorPicker.${part} must be used within a ColorPicker.Root.`);
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ColorPickerProvider, DEFAULT_LABELS, useColorPickerContext };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/color-picker/eyedropper.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Samples a color from anywhere on screen via the native EyeDropper API. Renders nothing where the
|
|
6
|
+
* API is absent (Firefox, Safari), so it never offers a dead button.
|
|
7
|
+
*/
|
|
8
|
+
declare function ColorPickerEyeDropper({
|
|
9
|
+
className
|
|
10
|
+
}: {
|
|
11
|
+
className?: string;
|
|
12
|
+
}): ReactElement | null;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ColorPickerEyeDropper };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { PipetteIcon } from "../../icons/glyphs.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import { parseColor, rgbToHsv } from "./color.js";
|
|
5
|
+
import { COLOR_PICKER_SLOTS } from "./color-picker.slots.js";
|
|
6
|
+
import { useColorPickerContext } from "./context.js";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/color-picker/eyedropper.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Samples a color from anywhere on screen via the native EyeDropper API. Renders nothing where the
|
|
12
|
+
* API is absent (Firefox, Safari), so it never offers a dead button.
|
|
13
|
+
*/
|
|
14
|
+
function ColorPickerEyeDropper({ className }) {
|
|
15
|
+
const { alpha, disabled, store, labels } = useColorPickerContext("EyeDropper");
|
|
16
|
+
const [supported, setSupported] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setSupported(typeof window !== "undefined" && "EyeDropper" in window);
|
|
19
|
+
}, []);
|
|
20
|
+
if (!supported) return null;
|
|
21
|
+
const pick = async () => {
|
|
22
|
+
if (disabled) return;
|
|
23
|
+
const Ctor = window.EyeDropper;
|
|
24
|
+
if (!Ctor) return;
|
|
25
|
+
try {
|
|
26
|
+
const { sRGBHex } = await new Ctor().open();
|
|
27
|
+
const rgb = parseColor(sRGBHex);
|
|
28
|
+
if (!rgb) return;
|
|
29
|
+
const next = {
|
|
30
|
+
...rgb,
|
|
31
|
+
a: alpha ? store.getState().color.a : 1
|
|
32
|
+
};
|
|
33
|
+
store.setColorAndHsv(next, rgbToHsv(next));
|
|
34
|
+
} catch {}
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
37
|
+
"data-slot": COLOR_PICKER_SLOTS.eyeDropper,
|
|
38
|
+
type: "button",
|
|
39
|
+
variant: "ghost",
|
|
40
|
+
size: "sm",
|
|
41
|
+
iconOnly: true,
|
|
42
|
+
disabled,
|
|
43
|
+
"aria-label": labels.eyeDropper,
|
|
44
|
+
startIcon: PipetteIcon,
|
|
45
|
+
onClick: pick,
|
|
46
|
+
className
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ColorPickerEyeDropper };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/color-picker/format-tabs.d.ts
|
|
4
|
+
/** A segmented selector that switches the active output format. OKLCH leads, then HEX, RGB, HSL. */
|
|
5
|
+
declare function ColorPickerFormatTabs({
|
|
6
|
+
className
|
|
7
|
+
}: {
|
|
8
|
+
className?: string;
|
|
9
|
+
}): ReactElement;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ColorPickerFormatTabs };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { COLOR_FORMATS } from "./color.js";
|
|
3
|
+
import { COLOR_PICKER_SLOTS } from "./color-picker.slots.js";
|
|
4
|
+
import { useColorPickerContext } from "./context.js";
|
|
5
|
+
import { useColorPickerStore } from "./store.js";
|
|
6
|
+
import { toggle_exports } from "../../primitives/toggle.js";
|
|
7
|
+
import clsx$1 from "clsx";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/color-picker/format-tabs.tsx
|
|
10
|
+
/** The visible label per format — code-like names, held as data so they read as specimen text. */
|
|
11
|
+
const FORMAT_LABELS = {
|
|
12
|
+
oklch: "OKLCH",
|
|
13
|
+
hex: "HEX",
|
|
14
|
+
rgb: "RGB",
|
|
15
|
+
hsl: "HSL"
|
|
16
|
+
};
|
|
17
|
+
/** A segmented selector that switches the active output format. OKLCH leads, then HEX, RGB, HSL. */
|
|
18
|
+
function ColorPickerFormatTabs({ className }) {
|
|
19
|
+
const { disabled, store, labels } = useColorPickerContext("FormatTabs");
|
|
20
|
+
const format = useColorPickerStore(store, (state) => state.format);
|
|
21
|
+
return /* @__PURE__ */ jsx("fieldset", {
|
|
22
|
+
"aria-label": labels.format,
|
|
23
|
+
"data-slot": COLOR_PICKER_SLOTS.formatTabs,
|
|
24
|
+
"data-disabled": disabled ? "" : void 0,
|
|
25
|
+
className: clsx$1(className),
|
|
26
|
+
children: COLOR_FORMATS.map((id) => /* @__PURE__ */ jsx(toggle_exports.Toggle, {
|
|
27
|
+
pressed: format === id,
|
|
28
|
+
disabled,
|
|
29
|
+
onPressedChange: () => store.setFormat(id),
|
|
30
|
+
children: FORMAT_LABELS[id]
|
|
31
|
+
}, id))
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ColorPickerFormatTabs };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/color-picker/inputs.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The color value field, in the active format. It accepts any CSS color while you type (so pasting a
|
|
6
|
+
* `#hex` over an `oklch()` works) and re-serializes to the chosen format. Typing is held in a local
|
|
7
|
+
* draft so an in-progress value like `#ff` shows literally and flags invalid, rather than snapping
|
|
8
|
+
* back; on blur the draft is dropped and the field returns to canonical.
|
|
9
|
+
*/
|
|
10
|
+
declare function ColorPickerInput({
|
|
11
|
+
className
|
|
12
|
+
}: {
|
|
13
|
+
className?: string;
|
|
14
|
+
}): ReactElement;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ColorPickerInput };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { HEX6, HEX8, formatColor, isValidColor, parseColor, rgbToHsv } from "./color.js";
|
|
3
|
+
import { COLOR_PICKER_SLOTS } from "./color-picker.slots.js";
|
|
4
|
+
import { useColorPickerContext } from "./context.js";
|
|
5
|
+
import { useColorPickerStore } from "./store.js";
|
|
6
|
+
import { useState } from "react";
|
|
7
|
+
import clsx$1 from "clsx";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/color-picker/inputs.tsx
|
|
10
|
+
/**
|
|
11
|
+
* The color value field, in the active format. It accepts any CSS color while you type (so pasting a
|
|
12
|
+
* `#hex` over an `oklch()` works) and re-serializes to the chosen format. Typing is held in a local
|
|
13
|
+
* draft so an in-progress value like `#ff` shows literally and flags invalid, rather than snapping
|
|
14
|
+
* back; on blur the draft is dropped and the field returns to canonical.
|
|
15
|
+
*/
|
|
16
|
+
function ColorPickerInput({ className }) {
|
|
17
|
+
const { alpha, disabled, readOnly, store, labels } = useColorPickerContext("Input");
|
|
18
|
+
const color = useColorPickerStore(store, (state) => state.color);
|
|
19
|
+
const format = useColorPickerStore(store, (state) => state.format);
|
|
20
|
+
const value = formatColor(color, format, alpha);
|
|
21
|
+
const [draft, setDraft] = useState(null);
|
|
22
|
+
const display = draft ?? value;
|
|
23
|
+
const invalid = draft !== null && draft.length > 0 && !accepts(draft, format, alpha);
|
|
24
|
+
const onChange = (event) => {
|
|
25
|
+
const next = event.target.value;
|
|
26
|
+
setDraft(next);
|
|
27
|
+
if (!accepts(next, format, alpha)) return;
|
|
28
|
+
const rgb = parseColor(format === "hex" ? withHash(next) : next);
|
|
29
|
+
if (!rgb) return;
|
|
30
|
+
const constrained = {
|
|
31
|
+
...rgb,
|
|
32
|
+
a: alpha ? rgb.a : 1
|
|
33
|
+
};
|
|
34
|
+
store.setColorAndHsv(constrained, rgbToHsv(constrained));
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsx("input", {
|
|
37
|
+
"data-slot": COLOR_PICKER_SLOTS.input,
|
|
38
|
+
type: "text",
|
|
39
|
+
spellCheck: false,
|
|
40
|
+
autoComplete: "off",
|
|
41
|
+
"aria-label": labels.value,
|
|
42
|
+
"aria-invalid": invalid || void 0,
|
|
43
|
+
disabled,
|
|
44
|
+
readOnly,
|
|
45
|
+
value: display,
|
|
46
|
+
onChange,
|
|
47
|
+
onFocus: () => setDraft(value),
|
|
48
|
+
onBlur: () => setDraft(null),
|
|
49
|
+
className: clsx$1(className)
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** Hex gets a strict digit check (6 or 8, with/without `#`); other formats accept any CSS color. */
|
|
53
|
+
function accepts(raw, format, alpha) {
|
|
54
|
+
if (format === "hex") return alpha ? HEX6.test(raw) || HEX8.test(raw) : HEX6.test(raw);
|
|
55
|
+
return isValidColor(raw);
|
|
56
|
+
}
|
|
57
|
+
function withHash(raw) {
|
|
58
|
+
return raw.startsWith("#") ? raw : `#${raw}`;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { ColorPickerInput };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/color-picker/sliders.d.ts
|
|
4
|
+
/** The hue rail (0–360°), painted with the full spectrum; the thumb carries the live color. */
|
|
5
|
+
declare function ColorPickerHueSlider({
|
|
6
|
+
className
|
|
7
|
+
}: {
|
|
8
|
+
className?: string;
|
|
9
|
+
}): ReactElement;
|
|
10
|
+
/** The alpha rail (0–100%), transparent → opaque over a checkerboard. Rendered only when alpha is on. */
|
|
11
|
+
declare function ColorPickerAlphaSlider({
|
|
12
|
+
className
|
|
13
|
+
}: {
|
|
14
|
+
className?: string;
|
|
15
|
+
}): ReactElement | null;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ColorPickerAlphaSlider, ColorPickerHueSlider };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { HANDLE_SHADOW, HUE_GRADIENT, alphaTrackCss, hsvToRgb, rgbCss, swatchFillCss } from "./color.js";
|
|
3
|
+
import { COLOR_PICKER_SLOTS } from "./color-picker.slots.js";
|
|
4
|
+
import { useColorPickerContext } from "./context.js";
|
|
5
|
+
import { useColorPickerStore } from "./store.js";
|
|
6
|
+
import { Slider } from "../../primitives/slider/slider.js";
|
|
7
|
+
import clsx$1 from "clsx";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/components/color-picker/sliders.tsx
|
|
10
|
+
/** The hue rail (0–360°), painted with the full spectrum; the thumb carries the live color. */
|
|
11
|
+
function ColorPickerHueSlider({ className }) {
|
|
12
|
+
const { disabled, store, labels } = useColorPickerContext("HueSlider");
|
|
13
|
+
const hue = useColorPickerStore(store, (state) => state.hsv.h);
|
|
14
|
+
const color = useColorPickerStore(store, (state) => state.color);
|
|
15
|
+
return /* @__PURE__ */ jsx(ChannelSlider, {
|
|
16
|
+
slot: COLOR_PICKER_SLOTS.hue,
|
|
17
|
+
thumbSlot: COLOR_PICKER_SLOTS.hueThumb,
|
|
18
|
+
ariaLabel: labels.hue,
|
|
19
|
+
value: Math.round(hue),
|
|
20
|
+
max: 360,
|
|
21
|
+
disabled,
|
|
22
|
+
trackBackground: HUE_GRADIENT,
|
|
23
|
+
thumbBackground: rgbCss(color),
|
|
24
|
+
className,
|
|
25
|
+
onValueChange: (next) => {
|
|
26
|
+
const hsv = {
|
|
27
|
+
...store.getState().hsv,
|
|
28
|
+
h: next
|
|
29
|
+
};
|
|
30
|
+
store.setColorAndHsv(hsvToRgb(hsv), hsv);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** The alpha rail (0–100%), transparent → opaque over a checkerboard. Rendered only when alpha is on. */
|
|
35
|
+
function ColorPickerAlphaSlider({ className }) {
|
|
36
|
+
const { alpha, disabled, store, labels } = useColorPickerContext("AlphaSlider");
|
|
37
|
+
const color = useColorPickerStore(store, (state) => state.color);
|
|
38
|
+
if (!alpha) return null;
|
|
39
|
+
return /* @__PURE__ */ jsx(ChannelSlider, {
|
|
40
|
+
slot: COLOR_PICKER_SLOTS.alpha,
|
|
41
|
+
thumbSlot: COLOR_PICKER_SLOTS.alphaThumb,
|
|
42
|
+
ariaLabel: labels.alpha,
|
|
43
|
+
value: Math.round(color.a * 100),
|
|
44
|
+
max: 100,
|
|
45
|
+
disabled,
|
|
46
|
+
trackBackground: alphaTrackCss(color),
|
|
47
|
+
thumbBackground: swatchFillCss(color, true),
|
|
48
|
+
className,
|
|
49
|
+
onValueChange: (next) => {
|
|
50
|
+
const a = next / 100;
|
|
51
|
+
const state = store.getState();
|
|
52
|
+
store.setColorAndHsv({
|
|
53
|
+
...state.color,
|
|
54
|
+
a
|
|
55
|
+
}, {
|
|
56
|
+
...state.hsv,
|
|
57
|
+
a
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** The shared rail behind the hue and alpha sliders, built on Base UI's `Slider` for behavior + a11y. */
|
|
63
|
+
function ChannelSlider({ slot, thumbSlot, ariaLabel, value, max, disabled, trackBackground, thumbBackground, className, onValueChange }) {
|
|
64
|
+
return /* @__PURE__ */ jsx(Slider.Root, {
|
|
65
|
+
"data-slot": slot,
|
|
66
|
+
value,
|
|
67
|
+
min: 0,
|
|
68
|
+
max,
|
|
69
|
+
step: 1,
|
|
70
|
+
disabled,
|
|
71
|
+
onValueChange: (next) => onValueChange(typeof next === "number" ? next : next[0] ?? 0),
|
|
72
|
+
className: clsx$1(className),
|
|
73
|
+
children: /* @__PURE__ */ jsxs(Slider.Control, {
|
|
74
|
+
"data-color-picker-channel-control": true,
|
|
75
|
+
children: [/* @__PURE__ */ jsx(Slider.Track, {
|
|
76
|
+
"data-color-picker-channel-track": true,
|
|
77
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
78
|
+
"aria-hidden": true,
|
|
79
|
+
"data-color-picker-channel-track-fill": true,
|
|
80
|
+
style: { background: trackBackground }
|
|
81
|
+
})
|
|
82
|
+
}), /* @__PURE__ */ jsx(Slider.Thumb, {
|
|
83
|
+
"data-slot": thumbSlot,
|
|
84
|
+
getAriaLabel: () => ariaLabel,
|
|
85
|
+
style: {
|
|
86
|
+
background: thumbBackground,
|
|
87
|
+
boxShadow: HANDLE_SHADOW
|
|
88
|
+
}
|
|
89
|
+
})]
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { ColorPickerAlphaSlider, ColorPickerHueSlider };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
|
+
//#region src/components/color-picker/store.ts
|
|
4
|
+
/** Create a store seeded with the initial state. One per `ColorPicker.Root`, held across renders. */
|
|
5
|
+
function createColorPickerStore(initial) {
|
|
6
|
+
let state = initial;
|
|
7
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
8
|
+
const emit = () => {
|
|
9
|
+
for (const listener of listeners) listener();
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
getState: () => state,
|
|
13
|
+
subscribe: (listener) => {
|
|
14
|
+
listeners.add(listener);
|
|
15
|
+
return () => listeners.delete(listener);
|
|
16
|
+
},
|
|
17
|
+
setColorAndHsv: (color, hsv) => {
|
|
18
|
+
if (sameRgb(state.color, color) && sameHsv(state.hsv, hsv)) return;
|
|
19
|
+
state = {
|
|
20
|
+
...state,
|
|
21
|
+
color,
|
|
22
|
+
hsv
|
|
23
|
+
};
|
|
24
|
+
emit();
|
|
25
|
+
},
|
|
26
|
+
setFormat: (format) => {
|
|
27
|
+
if (state.format === format) return;
|
|
28
|
+
state = {
|
|
29
|
+
...state,
|
|
30
|
+
format
|
|
31
|
+
};
|
|
32
|
+
emit();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Subscribe to a slice of the store. Re-renders only when the selected value changes identity. */
|
|
37
|
+
function useColorPickerStore(store, selector) {
|
|
38
|
+
const read = () => selector(store.getState());
|
|
39
|
+
return useSyncExternalStore(store.subscribe, read, read);
|
|
40
|
+
}
|
|
41
|
+
function sameRgb(a, b) {
|
|
42
|
+
return a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a;
|
|
43
|
+
}
|
|
44
|
+
function sameHsv(a, b) {
|
|
45
|
+
return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { createColorPickerStore, useColorPickerStore };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/color-picker/swatch.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A small preview chip of the current color — solid when opaque, over a checkerboard when translucent.
|
|
6
|
+
* Decorative: the color is already announced through the value input, so the swatch stays out of the
|
|
7
|
+
* a11y tree rather than repeating it.
|
|
8
|
+
*/
|
|
9
|
+
declare function ColorPickerSwatch({
|
|
10
|
+
className
|
|
11
|
+
}: {
|
|
12
|
+
className?: string;
|
|
13
|
+
}): ReactElement;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { ColorPickerSwatch };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { swatchFillCss } from "./color.js";
|
|
3
|
+
import { COLOR_PICKER_SLOTS } from "./color-picker.slots.js";
|
|
4
|
+
import { useColorPickerContext } from "./context.js";
|
|
5
|
+
import { useColorPickerStore } from "./store.js";
|
|
6
|
+
import clsx$1 from "clsx";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/color-picker/swatch.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A small preview chip of the current color — solid when opaque, over a checkerboard when translucent.
|
|
11
|
+
* Decorative: the color is already announced through the value input, so the swatch stays out of the
|
|
12
|
+
* a11y tree rather than repeating it.
|
|
13
|
+
*/
|
|
14
|
+
function ColorPickerSwatch({ className }) {
|
|
15
|
+
const { alpha, store } = useColorPickerContext("Swatch");
|
|
16
|
+
const color = useColorPickerStore(store, (state) => state.color);
|
|
17
|
+
return /* @__PURE__ */ jsx("div", {
|
|
18
|
+
"aria-hidden": true,
|
|
19
|
+
"data-slot": COLOR_PICKER_SLOTS.swatch,
|
|
20
|
+
style: { background: swatchFillCss(color, alpha) },
|
|
21
|
+
className: clsx$1(className)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { ColorPickerSwatch };
|