@mortenbrudvik/waveui 0.7.0 → 0.9.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 +564 -155
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.mjs +36 -35
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/button/Button.slots.cjs +1 -1
- package/dist/components/button/Button.slots.cjs.map +1 -1
- package/dist/components/button/Button.slots.mjs +31 -21
- package/dist/components/button/Button.slots.mjs.map +1 -1
- package/dist/components/button/CompoundButton.cjs +1 -1
- package/dist/components/button/CompoundButton.cjs.map +1 -1
- package/dist/components/button/CompoundButton.mjs +31 -29
- package/dist/components/button/CompoundButton.mjs.map +1 -1
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +24 -23
- package/dist/components/button/Link.mjs.map +1 -1
- package/dist/components/button/MenuButton.cjs +1 -1
- package/dist/components/button/MenuButton.cjs.map +1 -1
- package/dist/components/button/MenuButton.mjs +29 -28
- package/dist/components/button/MenuButton.mjs.map +1 -1
- package/dist/components/button/SplitButton.cjs +1 -1
- package/dist/components/button/SplitButton.cjs.map +1 -1
- package/dist/components/button/SplitButton.mjs +46 -45
- package/dist/components/button/SplitButton.mjs.map +1 -1
- package/dist/components/button/ToggleButton.cjs +1 -1
- package/dist/components/button/ToggleButton.cjs.map +1 -1
- package/dist/components/button/ToggleButton.mjs +38 -35
- package/dist/components/button/ToggleButton.mjs.map +1 -1
- package/dist/components/button/Toolbar.cjs +1 -1
- package/dist/components/button/Toolbar.cjs.map +1 -1
- package/dist/components/button/Toolbar.mjs +43 -42
- package/dist/components/button/Toolbar.mjs.map +1 -1
- package/dist/components/button/Toolbar.parts.cjs +1 -1
- package/dist/components/button/Toolbar.parts.cjs.map +1 -1
- package/dist/components/button/Toolbar.parts.mjs +76 -81
- package/dist/components/button/Toolbar.parts.mjs.map +1 -1
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.mjs +72 -67
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.mjs +89 -88
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
- package/dist/components/data-display/Badge.cjs +1 -1
- package/dist/components/data-display/Badge.cjs.map +1 -1
- package/dist/components/data-display/Badge.mjs +17 -16
- package/dist/components/data-display/Badge.mjs.map +1 -1
- package/dist/components/data-display/CounterBadge.cjs +1 -1
- package/dist/components/data-display/CounterBadge.cjs.map +1 -1
- package/dist/components/data-display/CounterBadge.mjs +18 -17
- package/dist/components/data-display/CounterBadge.mjs.map +1 -1
- package/dist/components/data-display/Divider.cjs +1 -1
- package/dist/components/data-display/Divider.cjs.map +1 -1
- package/dist/components/data-display/Divider.mjs +31 -30
- package/dist/components/data-display/Divider.mjs.map +1 -1
- package/dist/components/data-display/Image.cjs +1 -1
- package/dist/components/data-display/Image.cjs.map +1 -1
- package/dist/components/data-display/Image.mjs +16 -15
- package/dist/components/data-display/Image.mjs.map +1 -1
- package/dist/components/data-display/InfoButton.cjs +2 -0
- package/dist/components/data-display/InfoButton.cjs.map +1 -0
- package/dist/components/data-display/InfoButton.mjs +173 -0
- package/dist/components/data-display/InfoButton.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +36 -92
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +175 -174
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/Persona.cjs +1 -1
- package/dist/components/data-display/Persona.cjs.map +1 -1
- package/dist/components/data-display/Persona.mjs +31 -29
- package/dist/components/data-display/Persona.mjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.cjs +1 -1
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.mjs +25 -24
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +87 -82
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.cjs +1 -1
- package/dist/components/feedback/MessageBar.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.mjs +129 -71
- package/dist/components/feedback/MessageBar.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.parts.cjs +2 -0
- package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.parts.mjs +84 -0
- package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
- package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
- package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +1 -1
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.status.mjs +2 -1
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
- package/dist/components/feedback/ProgressBar.cjs +1 -1
- package/dist/components/feedback/ProgressBar.cjs.map +1 -1
- package/dist/components/feedback/ProgressBar.mjs +44 -43
- package/dist/components/feedback/ProgressBar.mjs.map +1 -1
- package/dist/components/feedback/Skeleton.cjs +1 -1
- package/dist/components/feedback/Skeleton.cjs.map +1 -1
- package/dist/components/feedback/Skeleton.mjs +26 -24
- package/dist/components/feedback/Skeleton.mjs.map +1 -1
- package/dist/components/feedback/Spinner.cjs +1 -1
- package/dist/components/feedback/Spinner.cjs.map +1 -1
- package/dist/components/feedback/Spinner.mjs +32 -31
- package/dist/components/feedback/Spinner.mjs.map +1 -1
- package/dist/components/feedback/Toast.cjs +1 -1
- package/dist/components/feedback/Toast.cjs.map +1 -1
- package/dist/components/feedback/Toast.context.cjs +2 -0
- package/dist/components/feedback/Toast.context.cjs.map +1 -0
- package/dist/components/feedback/Toast.context.mjs +23 -0
- package/dist/components/feedback/Toast.context.mjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +10 -342
- package/dist/components/feedback/Toast.mjs.map +1 -1
- package/dist/components/feedback/Toast.parts.cjs +2 -0
- package/dist/components/feedback/Toast.parts.cjs.map +1 -0
- package/dist/components/feedback/Toast.parts.mjs +98 -0
- package/dist/components/feedback/Toast.parts.mjs.map +1 -0
- package/dist/components/feedback/Toast.root.cjs +2 -0
- package/dist/components/feedback/Toast.root.cjs.map +1 -0
- package/dist/components/feedback/Toast.root.mjs +109 -0
- package/dist/components/feedback/Toast.root.mjs.map +1 -0
- package/dist/components/feedback/Toaster.cjs +2 -0
- package/dist/components/feedback/Toaster.cjs.map +1 -0
- package/dist/components/feedback/Toaster.mjs +564 -0
- package/dist/components/feedback/Toaster.mjs.map +1 -0
- package/dist/components/input/AlphaSlider.cjs +2 -0
- package/dist/components/input/AlphaSlider.cjs.map +1 -0
- package/dist/components/input/AlphaSlider.mjs +115 -0
- package/dist/components/input/AlphaSlider.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +1 -1
- package/dist/components/input/Checkbox.cjs.map +1 -1
- package/dist/components/input/Checkbox.mjs +87 -70
- package/dist/components/input/Checkbox.mjs.map +1 -1
- package/dist/components/input/ColorArea.cjs +2 -0
- package/dist/components/input/ColorArea.cjs.map +1 -0
- package/dist/components/input/ColorArea.mjs +204 -0
- package/dist/components/input/ColorArea.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +5 -5
- package/dist/components/input/ColorPicker.cjs.map +1 -1
- package/dist/components/input/ColorPicker.mjs +142 -165
- package/dist/components/input/ColorPicker.mjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.cjs +2 -0
- package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
- package/dist/components/input/ColorPicker.parts.mjs +192 -0
- package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
- package/dist/components/input/ColorSlider.cjs +2 -0
- package/dist/components/input/ColorSlider.cjs.map +1 -0
- package/dist/components/input/ColorSlider.mjs +138 -0
- package/dist/components/input/ColorSlider.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +22 -22
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +151 -141
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +239 -234
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +109 -100
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Field.cjs +1 -1
- package/dist/components/input/Field.cjs.map +1 -1
- package/dist/components/input/Field.mjs +139 -105
- package/dist/components/input/Field.mjs.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.mjs +80 -55
- package/dist/components/input/Input.mjs.map +1 -1
- package/dist/components/input/Label.cjs +1 -1
- package/dist/components/input/Label.cjs.map +1 -1
- package/dist/components/input/Label.mjs +19 -12
- package/dist/components/input/Label.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +100 -98
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/RadioGroup.cjs +1 -1
- package/dist/components/input/RadioGroup.cjs.map +1 -1
- package/dist/components/input/RadioGroup.mjs +89 -88
- package/dist/components/input/RadioGroup.mjs.map +1 -1
- package/dist/components/input/Rating.cjs +1 -1
- package/dist/components/input/Rating.cjs.map +1 -1
- package/dist/components/input/Rating.item.cjs +2 -0
- package/dist/components/input/Rating.item.cjs.map +1 -0
- package/dist/components/input/Rating.item.mjs +255 -0
- package/dist/components/input/Rating.item.mjs.map +1 -0
- package/dist/components/input/Rating.mjs +152 -152
- package/dist/components/input/Rating.mjs.map +1 -1
- package/dist/components/input/SearchBox.cjs +1 -1
- package/dist/components/input/SearchBox.cjs.map +1 -1
- package/dist/components/input/SearchBox.mjs +162 -132
- package/dist/components/input/SearchBox.mjs.map +1 -1
- package/dist/components/input/Select.cjs +1 -1
- package/dist/components/input/Select.cjs.map +1 -1
- package/dist/components/input/Select.mjs +34 -24
- package/dist/components/input/Select.mjs.map +1 -1
- package/dist/components/input/Slider.cjs +1 -1
- package/dist/components/input/Slider.cjs.map +1 -1
- package/dist/components/input/Slider.mjs +78 -54
- package/dist/components/input/Slider.mjs.map +1 -1
- package/dist/components/input/SpinButton.cjs +1 -1
- package/dist/components/input/SpinButton.cjs.map +1 -1
- package/dist/components/input/SpinButton.mjs +202 -99
- package/dist/components/input/SpinButton.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.mjs +38 -37
- package/dist/components/input/SwatchPicker.mjs.map +1 -1
- package/dist/components/input/Switch.cjs +1 -1
- package/dist/components/input/Switch.cjs.map +1 -1
- package/dist/components/input/Switch.mjs +75 -58
- package/dist/components/input/Switch.mjs.map +1 -1
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.mjs +199 -169
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/Textarea.cjs +1 -1
- package/dist/components/input/Textarea.cjs.map +1 -1
- package/dist/components/input/Textarea.mjs +31 -23
- package/dist/components/input/Textarea.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +185 -177
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/input/colorName.cjs +2 -0
- package/dist/components/input/colorName.cjs.map +1 -0
- package/dist/components/input/colorName.mjs +30 -0
- package/dist/components/input/colorName.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +1 -1
- package/dist/components/input/colorUtils.cjs.map +1 -1
- package/dist/components/input/colorUtils.mjs +154 -56
- package/dist/components/input/colorUtils.mjs.map +1 -1
- package/dist/components/input/fieldLabel.cjs +2 -0
- package/dist/components/input/fieldLabel.cjs.map +1 -0
- package/dist/components/input/fieldLabel.mjs +17 -0
- package/dist/components/input/fieldLabel.mjs.map +1 -0
- package/dist/components/input/inputLook.cjs +2 -0
- package/dist/components/input/inputLook.cjs.map +1 -0
- package/dist/components/input/inputLook.mjs +28 -0
- package/dist/components/input/inputLook.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +1 -1
- package/dist/components/input/pickerStyles.cjs.map +1 -1
- package/dist/components/input/pickerStyles.mjs +42 -4
- package/dist/components/input/pickerStyles.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs +130 -129
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/layout/Card.cjs +1 -1
- package/dist/components/layout/Card.cjs.map +1 -1
- package/dist/components/layout/Card.mjs +78 -77
- package/dist/components/layout/Card.mjs.map +1 -1
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.mjs +111 -110
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/Flex.cjs +1 -1
- package/dist/components/layout/Flex.cjs.map +1 -1
- package/dist/components/layout/Flex.mjs +22 -21
- package/dist/components/layout/Flex.mjs.map +1 -1
- package/dist/components/layout/Grid.cjs +1 -1
- package/dist/components/layout/Grid.cjs.map +1 -1
- package/dist/components/layout/Grid.mjs +19 -18
- package/dist/components/layout/Grid.mjs.map +1 -1
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +92 -91
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Stack.cjs +1 -1
- package/dist/components/layout/Stack.cjs.map +1 -1
- package/dist/components/layout/Stack.mjs +14 -13
- package/dist/components/layout/Stack.mjs.map +1 -1
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +118 -117
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/layout/Tree.cjs +1 -1
- package/dist/components/layout/Tree.cjs.map +1 -1
- package/dist/components/layout/Tree.context.cjs +2 -0
- package/dist/components/layout/Tree.context.cjs.map +1 -0
- package/dist/components/layout/Tree.context.mjs +33 -0
- package/dist/components/layout/Tree.context.mjs.map +1 -0
- package/dist/components/layout/Tree.core.cjs +2 -0
- package/dist/components/layout/Tree.core.cjs.map +1 -0
- package/dist/components/layout/Tree.core.mjs +416 -0
- package/dist/components/layout/Tree.core.mjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
- package/dist/components/layout/Tree.mjs +7 -215
- package/dist/components/layout/Tree.mjs.map +1 -1
- package/dist/components/layout/Tree.selection.cjs +2 -0
- package/dist/components/layout/Tree.selection.cjs.map +1 -0
- package/dist/components/layout/Tree.selection.mjs +73 -0
- package/dist/components/layout/Tree.selection.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +76 -75
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/navigation/Menu.group.cjs +1 -1
- package/dist/components/navigation/Menu.group.cjs.map +1 -1
- package/dist/components/navigation/Menu.group.mjs +39 -37
- package/dist/components/navigation/Menu.group.mjs.map +1 -1
- package/dist/components/navigation/Menu.items.cjs +1 -1
- package/dist/components/navigation/Menu.items.cjs.map +1 -1
- package/dist/components/navigation/Menu.items.mjs +67 -61
- package/dist/components/navigation/Menu.items.mjs.map +1 -1
- package/dist/components/navigation/Menu.link.cjs +1 -1
- package/dist/components/navigation/Menu.link.cjs.map +1 -1
- package/dist/components/navigation/Menu.link.mjs +34 -28
- package/dist/components/navigation/Menu.link.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +114 -113
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +171 -170
- package/dist/components/navigation/Menu.root.mjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.cjs +1 -1
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.mjs +85 -63
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.cjs +1 -1
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.mjs +6 -6
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.mjs +170 -155
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination.cjs.map +1 -1
- package/dist/components/navigation/Pagination.mjs +73 -65
- package/dist/components/navigation/Pagination.mjs.map +1 -1
- package/dist/components/navigation/Stepper.cjs +1 -1
- package/dist/components/navigation/Stepper.cjs.map +1 -1
- package/dist/components/navigation/Stepper.mjs +110 -109
- package/dist/components/navigation/Stepper.mjs.map +1 -1
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +109 -108
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Drawer.cjs +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.mjs +110 -109
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +148 -151
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/Popover.shared.cjs +1 -1
- package/dist/components/overlays/Popover.shared.cjs.map +1 -1
- package/dist/components/overlays/Popover.shared.mjs +82 -77
- package/dist/components/overlays/Popover.shared.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +41 -37
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +87 -86
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +33 -32
- package/dist/components/portal/Portal.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +36 -29
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +228 -227
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +60 -59
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/typography/Text.cjs +1 -1
- package/dist/components/typography/Text.cjs.map +1 -1
- package/dist/components/typography/Text.mjs +12 -11
- package/dist/components/typography/Text.mjs.map +1 -1
- package/dist/hooks/useFieldControl.cjs.map +1 -1
- package/dist/hooks/useFieldControl.mjs.map +1 -1
- package/dist/hooks/useMediaQuery.cjs +2 -0
- package/dist/hooks/useMediaQuery.cjs.map +1 -0
- package/dist/hooks/useMediaQuery.mjs +20 -0
- package/dist/hooks/useMediaQuery.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +3 -3
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2890 -197
- package/dist/index.d.ts +2890 -197
- package/dist/index.mjs +101 -87
- package/dist/lib/classNames.cjs +2 -0
- package/dist/lib/classNames.cjs.map +1 -0
- package/dist/lib/classNames.mjs +423 -0
- package/dist/lib/classNames.mjs.map +1 -0
- package/dist/lib/color.cjs +2 -0
- package/dist/lib/color.cjs.map +1 -0
- package/dist/lib/color.mjs +86 -0
- package/dist/lib/color.mjs.map +1 -0
- package/dist/lib/globalRegistry.cjs.map +1 -1
- package/dist/lib/globalRegistry.mjs.map +1 -1
- package/dist/lib/styles.cjs +1 -1
- package/dist/lib/styles.cjs.map +1 -1
- package/dist/lib/styles.mjs +21 -4
- package/dist/lib/styles.mjs.map +1 -1
- package/dist/lib/toaster.cjs +2 -0
- package/dist/lib/toaster.cjs.map +1 -0
- package/dist/lib/toaster.mjs +77 -0
- package/dist/lib/toaster.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +13 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorArea.mjs","names":["React","DEFAULT_LABELS","clampPercent","value","COARSE_POINTER","ColorArea","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","rest","part","useColorPartState","strings","picker","labels","resolvedShape","shape","color","shown","displayColor","saturation","toPercent","brightness","activeAxis","setActiveAxis","coarsePointer","useMediaQuery","fieldRef","focusToken","setFocusToken","rootRef","saturationRef","brightnessRef","mergedRootRef","useMergedRefs","ref","mergedSaturationRef","controlRef","handledFocusTokenRef","field","useFieldContext","invalid","_ariaRequired","_required","groupProps","useFieldControl","errorMessageId","isRequired","required","form","applyAxis","percent","axis","handleKeyDown","composeEventHandlers","onKeyDown","isOwnEvent","event","step","next","intent","getArrowIntent","getDirection","token","handleInputChange","handleInputFocus","moveToPointer","useEventCallback","fieldElement","rect","x","s","v","focusActiveAxis","handlePointerDown","onPointerDown","handlePointerMove","onPointerMove","textLabels","areaStyle","style","colorAreaGradient","toPosition","hsvToHex","inputProps","tabIndex","cn","colorAreaClassNames","className","COLOR_THUMB_CLASSES","areaValueText","HiddenInput"],"sources":["../../../src/components/input/ColorArea.tsx"],"sourcesContent":["import * as React from 'react';\nimport { colorAreaClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { hsvToHex } from '../../lib/color';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isOwnEvent } from '../../lib/events';\nimport type { ColorPickerShape, HsvColor } from '../../lib/types';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { useColorPartState } from './ColorPicker.parts';\nimport {\n COLOR_THUMB_CLASSES,\n areaValueText,\n colorAreaGradient,\n displayColor,\n toPercent,\n toPosition,\n} from './colorUtils';\n\n/** Texts of a ColorArea, for localisation. Every key is optional. */\nexport interface ColorAreaLabels {\n /** Name of the horizontal slider.\n * @default 'Saturation'\n */\n saturation?: string;\n /** Name of the vertical slider (the `value` channel).\n * @default 'Brightness'\n */\n brightness?: string;\n /** Role description of both sliders.\n * @default '2D slider'\n */\n roleDescription?: string;\n /** Names the color at the end of each value text; return `''` to leave it out.\n * @default an English namer (\"dark blue\")\n */\n colorName?: (color: HsvColor) => string;\n /** Replaces a whole value text, for languages whose order differs. */\n valueText?: (color: HsvColor, channel: 'saturation' | 'value') => string;\n}\n\n/** Properties for the ColorArea component. */\nexport interface ColorAreaProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'defaultValue' | 'onChange'\n> {\n /**\n * The color (Fluent's `color`). Inside a ColorPicker, leave `value` and `defaultValue` out to\n * bind the area to the picker.\n */\n value?: HsvColor;\n /**\n * Initial color for uncontrolled usage (also what a form reset restores).\n * @default the brand blue, `{ h: 208, s: 0.92, v: 0.74 }` (`#0f6cbd`)\n */\n defaultValue?: HsvColor;\n /**\n * Called with the new color on every step (a key, a pointer move or assistive technology) that\n * changes it (Fluent's `onChange`). A bound area calls it too.\n */\n onValueChange?: (value: HsvColor) => void;\n /**\n * `'square'` removes the corner radius (the thumb stays round). Bound to a ColorPicker, the\n * picker's shape unless you pass one.\n * @default 'rounded'\n */\n shape?: ColorPickerShape;\n /** Texts of the area; bound to a ColorPicker, the picker's `labels` fill the keys you leave out. */\n labels?: ColorAreaLabels;\n /**\n * Unavailable: both inputs are natively disabled, pointer presses are ignored and the area is\n * dimmed. A bound area is also disabled while the picker's value is not a hex color.\n * @default false\n */\n disabled?: boolean;\n /** Form field name: the color is submitted as hex (`hsvToHex`). Ignored while bound to a ColorPicker. */\n name?: string;\n /** Id of the form the area belongs to, when it is rendered outside that form. */\n form?: string;\n /**\n * Marks the hidden form input required (a color is always set, so it never blocks). A consumer\n * `aria-required` does the same: a group supports neither, so neither is set on it.\n */\n required?: boolean;\n /** Ref to the saturation `<input type=\"range\">`. */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root `role=\"group\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** The two axes: saturation (x) and brightness (y, the `value` channel). */\ntype AreaAxis = 'saturation' | 'value';\n\nconst DEFAULT_LABELS = {\n saturation: 'Saturation',\n brightness: 'Brightness',\n roleDescription: '2D slider',\n} as const;\n\n/** A whole percentage clamped to 0–100. */\nfunction clampPercent(value: number): number {\n return Math.min(100, Math.max(0, value));\n}\n\n/** Touch-primary devices expose both inputs, so a touch screen reader can swipe each (D19). */\nconst COARSE_POINTER = '(pointer: coarse)';\n\n/**\n * A 2-D color field: saturation from left to right (mirrored in right-to-left layouts) and\n * brightness from bottom to top, at the value's hue. ArrowLeft and ArrowRight move saturation by\n * 1 %, ArrowUp and ArrowDown brightness; Shift with an arrow moves by 10, Page Up and Page Down\n * move brightness by 10, and Home and End set saturation to 0 and 100. A press or drag (mouse,\n * touch or pen) moves the thumb to the pointer. It is one Tab stop holding two sliders for\n * assistive technology, \"Saturation\" and \"Brightness\", whose value texts start with their own\n * channel and name the color; focus follows the axis a key moves, and unless the primary pointer\n * is coarse (touch), only the slider with the Tab stop is exposed. Inside a ColorPicker, leave\n * `value` and `defaultValue` out and it binds to the picker. Fluent's\n * `ColorArea`, with `value`/`onValueChange` for its `color`/`onChange`.\n *\n * @example\n * <ColorArea aria-label=\"Accent color\" value={color} onValueChange={setColor} />\n */\nexport const ColorArea = ({\n value,\n defaultValue,\n onValueChange,\n shape,\n labels,\n disabled = false,\n name,\n form,\n required,\n controlRef,\n className,\n style,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n autoFocus,\n tabIndex,\n onKeyDown,\n onPointerDown,\n onPointerMove,\n ref,\n ...rest\n}: ColorAreaProps) => {\n const part = useColorPartState({ value, defaultValue, onValueChange, disabled });\n const { picker } = part;\n const strings = {\n ...DEFAULT_LABELS,\n ...(picker && {\n saturation: picker.labels.saturation,\n brightness: picker.labels.brightness,\n roleDescription: picker.labels.roleDescription,\n colorName: picker.labels.colorName,\n valueText: picker.labels.valueText,\n }),\n ...labels,\n };\n const resolvedShape = shape ?? picker?.shape ?? 'rounded';\n const color = part.color;\n const shown = displayColor(color);\n const saturation = toPercent(shown.s);\n const brightness = toPercent(shown.v);\n\n const [activeAxis, setActiveAxis] = React.useState<AreaAxis>('saturation');\n const coarsePointer = useMediaQuery(COARSE_POINTER);\n const fieldRef = React.useRef<HTMLDivElement>(null);\n // Bumped on every handled key (not only an axis change), so the layout effect below moves focus\n // to the axis's input even when the key's axis is the one an earlier assistive-technology change\n // already made the Tab stop, without moving focus; focusing an input that already has focus does\n // nothing. Never bumped for an AT-driven change (`handleInputChange`) or a real focus event. A\n // plain counter, not a ref: react-hooks/refs only allows a ref's `current` to be touched from an\n // effect, a ref callback or a function assigned directly to a JSX handler prop, not one passed\n // through `composeEventHandlers`.\n const [focusToken, setFocusToken] = React.useState(0);\n const rootRef = React.useRef<HTMLDivElement>(null);\n const saturationRef = React.useRef<HTMLInputElement>(null);\n const brightnessRef = React.useRef<HTMLInputElement>(null);\n const mergedRootRef = useMergedRefs(ref, rootRef);\n const mergedSaturationRef = useMergedRefs(saturationRef, controlRef);\n /** The last `focusToken` this component already moved focus for (read/written in the effect only). */\n const handledFocusTokenRef = React.useRef(0);\n\n React.useLayoutEffect(() => {\n if (handledFocusTokenRef.current === focusToken) return;\n handledFocusTokenRef.current = focusToken;\n (activeAxis === 'saturation' ? saturationRef : brightnessRef).current?.focus({\n preventScroll: true,\n });\n }, [activeAxis, focusToken]);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label':\n ariaLabel ?? (picker && ariaLabelledBy === undefined ? picker.labels.area : undefined),\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n },\n { labelable: false },\n );\n // A group supports neither aria-invalid, aria-required nor `required` (ARIA 1.2): the invalid\n // state goes to both inputs and the required state to the hidden input.\n const {\n 'aria-invalid': invalid,\n 'aria-required': _ariaRequired,\n required: _required,\n ...groupProps\n } = fieldProps;\n const isInvalid = invalid !== undefined && invalid !== false && invalid !== 'false';\n const errorMessageId = (isInvalid && ariaErrorMessage) || undefined;\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n\n useFormReset(rootRef, part.reset, form);\n\n /** Applies a whole percentage to one axis, keeping the other channels as given. */\n const applyAxis = (axis: AreaAxis, percent: number) => {\n if (percent === (axis === 'saturation' ? saturation : brightness)) return;\n part.setColor(\n axis === 'saturation' ? { ...color, s: percent / 100 } : { ...color, v: percent / 100 },\n );\n };\n\n const handleKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (part.disabled || !isOwnEvent(event) || event.nativeEvent.isComposing) return;\n // A key with Alt, Ctrl or Meta belongs to the browser (Alt+Left is \"back\").\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const step = event.shiftKey ? 10 : 1;\n let axis: AreaAxis;\n let next: number;\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowRight': {\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n axis = 'saturation';\n next = saturation + (intent === 'next' ? step : -step);\n break;\n }\n case 'ArrowUp':\n axis = 'value';\n next = brightness + step;\n break;\n case 'ArrowDown':\n axis = 'value';\n next = brightness - step;\n break;\n case 'PageUp':\n axis = 'value';\n next = brightness + 10;\n break;\n case 'PageDown':\n axis = 'value';\n next = brightness - 10;\n break;\n case 'Home':\n axis = 'saturation';\n next = 0;\n break;\n case 'End':\n axis = 'saturation';\n next = 100;\n break;\n default:\n return;\n }\n // Prevented, so the native range input never moves on its own.\n event.preventDefault();\n if (axis !== activeAxis) setActiveAxis(axis);\n // Every handled key moves focus to its axis's input, even when an earlier\n // assistive-technology change already made that axis the Tab stop.\n setFocusToken((token) => token + 1);\n applyAxis(axis, clampPercent(next));\n },\n );\n\n /** A change event from assistive technology (a swipe): that input becomes the Tab stop. */\n const handleInputChange = (axis: AreaAxis) => (event: React.ChangeEvent<HTMLInputElement>) => {\n if (part.disabled) return;\n if (axis !== activeAxis) setActiveAxis(axis);\n applyAxis(axis, clampPercent(Math.round(Number(event.currentTarget.value))));\n };\n\n const handleInputFocus = (axis: AreaAxis) => () => {\n if (axis !== activeAxis) setActiveAxis(axis);\n };\n\n // Both read a ref (`fieldRef`, or `saturationRef`/`brightnessRef`): `useEventCallback` (a custom\n // hook, opaque to react-hooks/refs) keeps that safe to call from the handler below, unlike a\n // plain function or `React.useCallback` passed into the generic `composeEventHandlers`.\n /** Moves the thumb to the pointer: saturation along x (mirrored in RTL), brightness along y. */\n const moveToPointer = useEventCallback((event: React.PointerEvent<HTMLDivElement>) => {\n const fieldElement = fieldRef.current;\n if (!fieldElement) return;\n const rect = fieldElement.getBoundingClientRect();\n if (rect.width <= 0 || rect.height <= 0) return;\n const x = Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n const s = getDirection(event.currentTarget) === 'rtl' ? 1 - x : x;\n const v = Math.min(1, Math.max(0, 1 - (event.clientY - rect.top) / rect.height));\n if (s === shown.s && v === shown.v) return;\n part.setColor({ ...color, s, v });\n });\n /**\n * Focuses the input of the active axis (the press moves focus there instead of the point),\n * without the focus ring: Chromium treats this script focus as keyboard focus, where the\n * browser's own focus of a pressed control shows none. Browsers without the `focusVisible`\n * option ignore it.\n */\n const focusActiveAxis = useEventCallback(() => {\n const options: FocusOptions = { preventScroll: true, focusVisible: false };\n (activeAxis === 'saturation' ? saturationRef : brightnessRef).current?.focus(options);\n });\n\n const handlePointerDown = composeEventHandlers(\n onPointerDown,\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (part.disabled || event.button !== 0 || !event.isPrimary || !isOwnEvent(event)) return;\n // No text selection and no focus move of the press: focus goes to the Tab stop instead.\n event.preventDefault();\n event.currentTarget.setPointerCapture(event.pointerId);\n moveToPointer(event);\n focusActiveAxis();\n },\n );\n\n // The drag lasts while the root holds the pointer; losing the capture (pointerup,\n // lostpointercapture) ends it.\n const handlePointerMove = composeEventHandlers(\n onPointerMove,\n (event: React.PointerEvent<HTMLDivElement>) => {\n if (part.disabled || !event.currentTarget.hasPointerCapture(event.pointerId)) return;\n moveToPointer(event);\n },\n );\n\n const textLabels = {\n saturation: strings.saturation,\n brightness: strings.brightness,\n colorName: strings.colorName,\n valueText: strings.valueText,\n };\n\n const areaStyle = {\n ...style,\n '--wave-color-area-gradient': colorAreaGradient(shown.h),\n '--wave-color-area-x': toPosition(shown.s),\n '--wave-color-area-y': toPosition(shown.v),\n '--wave-color-thumb': hsvToHex({ h: shown.h, s: shown.s, v: shown.v }),\n } as React.CSSProperties;\n\n const inputProps = (axis: AreaAxis) => ({\n type: 'range' as const,\n min: 0,\n max: 100,\n step: 1,\n disabled: part.disabled,\n 'aria-roledescription': strings.roleDescription,\n 'aria-invalid': invalid,\n 'aria-errormessage': errorMessageId,\n // One Tab stop: the input used last (C-ROUTING: a consumer tabIndex applies to it).\n tabIndex: axis === activeAxis ? (tabIndex ?? 0) : -1,\n // Where the primary pointer is not coarse, desktop screen readers meet one 2-D slider: the\n // input without the Tab stop is hidden (it stays focusable by script, never by Tab).\n 'aria-hidden': axis !== activeAxis && !coarsePointer ? true : undefined,\n onChange: handleInputChange(axis),\n onFocus: handleInputFocus(axis),\n className: 'sr-only',\n });\n\n return (\n <div\n role=\"group\"\n data-disabled={part.disabled ? '' : undefined}\n {...groupProps}\n className={cn(\n colorAreaClassNames.root,\n 'group/color-area relative h-40 w-full min-w-40 touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',\n resolvedShape === 'square' ? 'rounded-none' : 'rounded',\n className,\n )}\n style={areaStyle}\n {...rest}\n ref={mergedRootRef}\n onKeyDown={handleKeyDown}\n onPointerDown={handlePointerDown}\n onPointerMove={handlePointerMove}\n >\n <div\n ref={fieldRef}\n aria-hidden=\"true\"\n className={cn(\n colorAreaClassNames.field,\n 'absolute inset-0 rounded-[inherit] bg-(image:--wave-color-area-gradient) wave-rtl:-scale-x-100 forced-colors:forced-color-adjust-none',\n )}\n />\n <span\n aria-hidden=\"true\"\n className={cn(\n colorAreaClassNames.thumb,\n COLOR_THUMB_CLASSES,\n 'start-(--wave-color-area-x) bottom-(--wave-color-area-y) -translate-x-1/2 wave-rtl:translate-x-1/2 translate-y-1/2',\n 'group-has-[:focus-visible]/color-area:ring-2 group-has-[:focus-visible]/color-area:ring-background forced-colors:group-has-[:focus-visible]/color-area:ring-[Canvas] group-has-[:focus-visible]/color-area:outline-2 group-has-[:focus-visible]/color-area:outline-offset-2 group-has-[:focus-visible]/color-area:outline-ring forced-colors:group-has-[:focus-visible]/color-area:outline-[Highlight]',\n )}\n />\n <input\n {...inputProps('saturation')}\n ref={mergedSaturationRef}\n value={saturation}\n aria-label={strings.saturation}\n aria-valuetext={areaValueText(shown, 'saturation', textLabels)}\n autoFocus={autoFocus}\n />\n <input\n {...inputProps('value')}\n ref={brightnessRef}\n value={brightness}\n aria-label={strings.brightness}\n aria-orientation=\"vertical\"\n aria-valuetext={areaValueText(shown, 'value', textLabels)}\n />\n {!picker && (\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n disabled={part.disabled}\n value={hsvToHex(color)}\n required={isRequired}\n onInvalid={() =>\n (activeAxis === 'saturation' ? saturationRef : brightnessRef).current?.focus()\n }\n />\n )}\n </div>\n );\n};\n\nColorArea.displayName = 'ColorArea';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkGA,IAAMC,KAAiB;CACrB,YAAY;CACZ,YAAY;CACZ,iBAAiB;AACnB;AAGA,SAASC,EAAa,GAAuB;CAC3C,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,GAAGC,CAAK,CAAC;AACzC;AAGA,IAAMC,KAAiB,qBAiBVC,KAAa,EACxB,UACA,kBACA,mBACA,WACA,YACA,eAAW,IACX,UACA,SACA,cACA,gBACA,eACA,WACA,QACA,cAAcC,IACd,mBAAmBC,GACnB,oBAAoBC,GACpB,gBAAgBC,GAChB,iBAAiBC,GACjB,qBAAqBC,GACrB,cACA,aACA,cACA,kBACA,kBACA,QACA,GAAGC,QACiB;CACpB,IAAMC,IAAOC,EAAkB;EAAE;EAAO;EAAc;EAAe;CAAS,CAAC,GACzE,EAAE,cAAWD,GACbE,IAAU;EACd,GAAGd;EACH,GAAIe,KAAU;GACZ,YAAYA,EAAO,OAAO;GAC1B,YAAYA,EAAO,OAAO;GAC1B,iBAAiBA,EAAO,OAAO;GAC/B,WAAWA,EAAO,OAAO;GACzB,WAAWA,EAAO,OAAO;EAC3B;EACA,GAAGC;CACL,GACMC,KAAgBC,MAASH,GAAQ,SAAS,WAC1CI,IAAQP,EAAK,OACbQ,IAA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BAAC8E,IAAD;IACE,MAAK;IACC;IACA;IACN,UAAUjF,EAAK;IACf,OAAOyE,EAASlE,CAAK;IACrB,UAAU8B;IACV,kBACGxB,MAAe,eAAeQ,IAAgBC,EAAA,CAAe,SAAS,MAAM;GAEhF,CAAA;EAEA;;AAET;AAEA,EAAU,cAAc"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../
|
|
2
|
-
`),
|
|
3
|
-
`),
|
|
4
|
-
`))n.warnOnce(`ColorPicker:invalid-preset:${e}`,`ColorPicker: preset "${e}" is not a hex color (#rgb or #rrggbb) and is not shown.`)},[
|
|
5
|
-
`))n.warnOnce(`ColorPicker:alpha-preset:${e}`,`ColorPicker: preset "${e}" has an alpha byte, which is ignored: picking a preset keeps the current opacity. Pass the color as #rgb or #rrggbb.`)},[
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../lib/color.cjs"),o=require("../../hooks/useEventCallback.cjs"),s=require("../../hooks/useControllable.cjs"),c=require("../../lib/focus.cjs"),ee=require("../../hooks/useMergedRefs.cjs"),l=require("../../hooks/useFieldControl.cjs"),te=require("../../hooks/useFormReset.cjs"),ne=require("../internal/HiddenInput.cjs"),u=require("./colorUtils.cjs"),d=require("./ColorPicker.parts.cjs"),re=require("./AlphaSlider.cjs"),ie=require("./ColorArea.cjs"),ae=require("./ColorSlider.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=[{color:`#0f6cbd`,label:`Blue`},{color:`#d13438`,label:`Red`},{color:`#107c10`,label:`Green`},{color:`#ffb900`,label:`Yellow`},{color:`#5c2d91`,label:`Purple`},{color:`#008272`,label:`Teal`},{color:`#e3008c`,label:`Pink`},{color:`#242424`,label:`Black`}];function oe(e){let t=[],n=[],r=[],i=new Set;for(let a of e){let e=typeof a==`string`?a:a.color,o=u.parseHexColor(e);if(!o){n.push(e);continue}let s=o.alpha!==255;if(s&&r.push(e),i.has(o.rgb))continue;i.add(o.rgb);let c=s?o.rgb:e;t.push({value:o.rgb,color:o.rgb,label:typeof a==`string`?c:a.label})}return{items:t,invalid:n,translucent:r}}function h(e,t){let n=a.hexToHsv(e);return n?n.v===0?{...n,h:t.h,s:t.s}:n.s===0?{...n,h:t.h}:n:t}var g=({value:e,defaultValue:g,onValueChange:_,onChange:v,presets:y=m,showOpacity:se=!1,labels:b,shape:x=`rounded`,name:S,required:C,form:w,className:ce,id:le,"aria-label":ue,"aria-labelledby":de,"aria-describedby":fe,"aria-invalid":pe,"aria-required":T,"aria-errormessage":me,children:E,ref:he,...ge})=>{v!==void 0&&n.warnDeprecated(`ColorPicker`,`onChange`,`onValueChange`);let D=g??`#0f6cbd`,O=u.normalizeHexColor(D)??D,k=f.useMemo(()=>({...d.DEFAULT_COLOR_PICKER_LABELS,...b}),[b]),[A,j]=s.useControllable(e,O,e=>{_?.(e),v?.(e)}),M=f.useMemo(()=>u.parseHexColor(A),[A]),N=M?.alpha??255,P=u.alphaToOpacity(N),{items:F,invalid:I,translucent:_e}=f.useMemo(()=>oe(y),[y]),L=I.join(`
|
|
2
|
+
`),R=_e.join(`
|
|
3
|
+
`),z=M?null:A;f.useEffect(()=>{z!==null&&n.warnOnce(`ColorPicker:invalid-value`,`ColorPicker: "${z}" is not a hex color (#rrggbb or #rrggbbaa). Pass a hex value; the color area and sliders are disabled until then.`)},[z]),f.useEffect(()=>{if(L)for(let e of L.split(`
|
|
4
|
+
`))n.warnOnce(`ColorPicker:invalid-preset:${e}`,`ColorPicker: preset "${e}" is not a hex color (#rgb or #rrggbb) and is not shown.`)},[L]),f.useEffect(()=>{if(R)for(let e of R.split(`
|
|
5
|
+
`))n.warnOnce(`ColorPicker:alpha-preset:${e}`,`ColorPicker: preset "${e}" has an alpha byte, which is ignored: picking a preset keeps the current opacity. Pass the color as #rgb or #rrggbb.`)},[R]);let B=f.useRef(null),V=f.useRef(null),ve=ee.useMergedRefs(he,B),H=f.useCallback(e=>{V.current=e},[]),[U,W]=f.useState(0),G=l.useFieldContext(),{"aria-invalid":K,"aria-required":ye,required:be,...xe}=l.useFieldControl({id:le,"aria-label":ue,"aria-labelledby":de,"aria-describedby":fe,"aria-invalid":pe},{labelable:!1}),Se=K!==void 0&&K!==!1&&K!==`false`,q=C??(T===!0||T===`true`||(G?.required??!1)),J=Se&&me||void 0;te.useFormReset(B,()=>{(u.normalizeHexColor(A)??A)!==O&&j(O),W(e=>e+1)},w);let Y=o.useEventCallback(e=>{let t=u.parseHexColor(e);t&&(W(e=>e+1),j(u.formatHexColor(t.rgb,N)))}),[X,Z]=f.useState(()=>h(A,d.DEFAULT_PART_COLOR)),Q=M?u.formatHexColor(M.rgb,M.alpha):null;Q!==null&&a.hsvToHex(X)!==Q&&Z(h(Q,X));let $=o.useEventCallback(e=>{M&&(Z(e),j(a.hsvToHex(e)))}),Ce=f.useMemo(()=>({hsv:X,setHsv:$,color:A,parsed:M,setColor:j,pickPreset:Y,presetItems:F,shape:x,labels:k,disabled:M===null,draftResetKey:U,field:G,groupInvalid:K,errorMessageId:J,registerHexInput:H}),[X,$,A,M,j,Y,F,x,k,U,G,K,J,H]),we=()=>{let e=B.current;(V.current??(e?c.getFirstTabbable(e):null))?.focus()};return(0,p.jsxs)(`div`,{role:`group`,...xe,className:t.cn(i.colorPickerClassNames.root,`relative inline-flex flex-col gap-3 rounded border border-border bg-background p-3 shadow-4`,ce),...ge,ref:ve,children:[(0,p.jsx)(d.ColorPickerContext.Provider,{value:Ce,children:(0,p.jsx)(l.FieldContext.Provider,{value:null,children:r.slotRendersContent(E)?E:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(ie.ColorArea,{}),(0,p.jsx)(ae.ColorSlider,{}),(0,p.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,p.jsx)(d.ColorPickerPreview,{}),(0,p.jsx)(d.ColorPickerHexField,{})]}),(0,p.jsx)(d.ColorPickerSwatches,{}),se&&(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:t.cn(i.colorPickerClassNames.opacityLabel,`w-14 text-caption-1 text-muted-foreground`),children:k.opacity}),(0,p.jsx)(re.AlphaSlider,{className:`min-w-0 flex-1`}),(0,p.jsxs)(`span`,{className:t.cn(i.colorPickerClassNames.opacityValue,`w-10 text-end text-caption-1 text-muted-foreground`),children:[P,`%`]})]})]})})}),(0,p.jsx)(ne.HiddenInput,{type:`text`,name:S,form:w,value:A,required:q,onInvalid:we})]})};g.displayName=`ColorPicker`;var _=Object.assign(g,{HexField:d.ColorPickerHexField,Swatches:d.ColorPickerSwatches,Preview:d.ColorPickerPreview});exports.ColorPicker=_,exports.ColorPickerHexField=d.ColorPickerHexField,exports.ColorPickerPreview=d.ColorPickerPreview,exports.ColorPickerSwatches=d.ColorPickerSwatches;
|
|
6
6
|
//# sourceMappingURL=ColorPicker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker.cjs","names":["parseHexColor","normalizeHexColor","useControllable","alphaToOpacity","formatHexColor","React","isHexDraft","useMergedRefs","useFieldContext","useFieldControl","useId","isInvalidLook","parseHexInput","opacityToAlpha","cn","joinIds","inputFocus","FieldContext","SwatchPicker","HiddenInput","require_runtime","require_cn","require_dev","require_useControllable","require_useId","require_useMergedRefs","require_aria","require_useFieldControl","require_styles","require_Input","require_useFormReset","require_HiddenInput","require_colorUtils","require_SwatchPicker","react","react_jsx_runtime","DEFAULT_COLOR","DEFAULT_LABELS","DEFAULT_PRESETS","resolvePresets","items","invalid","translucent","seen","preset","presets","color","parsed","hasAlpha","stringLabel","isBlankDraft","trimmed","text","hasAlphaDigits","digits","ColorPicker","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","rest","onChange","rawDefault","defaultValue","initialValue","strings","labels","setColor","onValueChange","next","alpha","opacity","commit","rgb","nextAlpha","draft","setDraft","syncedColor","setSyncedColor","hexText","draftInvalid","presetItems","invalidPresets","translucentPresets","invalidPresetKey","translucentPresetKey","invalidValue","rootRef","hexInputRef","mergedRef","ref","field","groupInvalid","_ariaRequired","_required","groupProps","fieldInvalid","isRequired","required","errorMessageId","form","errorId","hexAriaInvalid","hexInvalidLook","handleHexChange","typed","finishHexDraft","handleHexKeyDown","handlePreset","handleOpacityChange","selectedPreset","className","showOpacity"],"sources":["../../../src/components/input/ColorPicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { joinIds } from '../../lib/aria';\nimport { focusRing, inputFocus, inputInvalid } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { FieldContext, useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { isInvalidLook } from './Input';\nimport { SwatchPicker } from './SwatchPicker';\nimport type { SwatchItem } from './SwatchPicker';\nimport {\n alphaToOpacity,\n formatHexColor,\n isHexDraft,\n normalizeHexColor,\n opacityToAlpha,\n parseHexColor,\n parseHexInput,\n} from './colorUtils';\n\n/** A named preset color. */\nexport interface ColorPickerPreset {\n /**\n * Hex color (`#rrggbb`; `#rgb` is expanded). A preset has no opacity of its own: picking it keeps\n * the current opacity, so its alpha digits (`#rgba`, `#rrggbbaa`) are ignored. An alpha below\n * `f`/`ff` logs a development warning; an opaque one (`#rgbf`, `#rrggbbff`) changes nothing.\n */\n color: string;\n /** Accessible name of the preset swatch, e.g. `'Cranberry'`. */\n label: string;\n}\n\n/**\n * Texts of the ColorPicker's own parts, for localisation. Every key is optional; missing keys use\n * the English default.\n */\nexport interface ColorPickerLabels {\n /** Visible caption above the hex field.\n * @default 'Hex'\n */\n hex?: string;\n /** Accessible name of the hex text field.\n * @default 'Hex color value'\n */\n hexInput?: string;\n /** Error text shown (and used as the hex field's description) while the typed text can never be\n * a hex color, or when the field is left with text that is not one (such as `#12345`).\n * @default 'Enter a hex color such as #0f6cbd.'\n */\n hexError?: string;\n /** Accessible name of the preset swatches radiogroup.\n * @default 'Preset colors'\n */\n presets?: string;\n /** Visible label and accessible name of the opacity slider.\n * @default 'Opacity'\n */\n opacity?: string;\n}\n\n/** Properties for the ColorPicker component. */\nexport interface ColorPickerProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /**\n * Controlled hex color: `#rrggbb`, or `#rrggbbaa` with an alpha byte (e.g. `'#0f6cbd80'` for\n * 50% opacity). Other formats are not supported (development warning).\n */\n value?: string;\n /**\n * Initial hex color for uncontrolled usage (also what a form reset restores). Like every edit it\n * is shown, submitted and reported as a lowercase `#rrggbb`, or `#rrggbbaa` when it is not fully\n * opaque (`'#ABC'` becomes `'#aabbcc'`).\n * @default '#0f6cbd'\n */\n defaultValue?: string;\n /**\n * Called with the new color when it changes: a lowercase `#rrggbb`, or `#rrggbbaa` when the color\n * is not fully opaque.\n */\n onValueChange?: (color: string) => void;\n /**\n * Called with the new color when it changes.\n * @deprecated Use `onValueChange`.\n */\n onChange?: (color: string) => void;\n /**\n * Preset colors shown as quick-select swatches. Pass `{ color, label }` objects so screen reader\n * users hear a name; a plain hex string is announced by its hex code. Non-hex presets are\n * skipped (development warning). Picking a preset keeps the current opacity, so a preset's alpha\n * digits are ignored. With an alpha below `f`/`ff` (`#rgba`, `#rrggbbaa`) there is a development\n * warning, and a string preset is announced by the `#rrggbb` color it applies; an opaque alpha\n * (`#rgbf`, `#rrggbbff`) changes nothing, and the string stays the name as written.\n * @default Blue, Red, Green, Yellow, Purple, Teal, Pink and Black (Fluent brand colors)\n */\n presets?: ReadonlyArray<string | ColorPickerPreset>;\n /** Whether to show the opacity slider. The opacity is the alpha byte of `value`.\n * @default false\n */\n showOpacity?: boolean;\n /** Texts of the picker's own parts (hex field, error, presets, opacity), for localisation. */\n labels?: ColorPickerLabels;\n /** Form field name. With a name, the current color is submitted with the form. */\n name?: string;\n /**\n * Marks the hidden form input as required (a color is always chosen, so it never blocks). A\n * consumer `aria-required` has the same effect: `role=\"group\"` does not support it, so it is not\n * rendered on the group.\n */\n required?: boolean;\n /** Id of the form the picker belongs to, when it is rendered outside that form. */\n form?: string;\n /** Ref to the root `role=\"group\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// wave-allow-color: default color value (user color data, C-TOKENS exception)\nconst DEFAULT_COLOR = '#0f6cbd';\n\nconst DEFAULT_LABELS: Required<ColorPickerLabels> = {\n hex: 'Hex',\n hexInput: 'Hex color value',\n hexError: `Enter a hex color such as ${DEFAULT_COLOR}.`,\n presets: 'Preset colors',\n opacity: 'Opacity',\n};\n\nconst DEFAULT_PRESETS: readonly ColorPickerPreset[] = [\n { color: '#0f6cbd', label: 'Blue' }, // wave-allow-color: preset swatch data\n { color: '#d13438', label: 'Red' }, // wave-allow-color: preset swatch data\n { color: '#107c10', label: 'Green' }, // wave-allow-color: preset swatch data\n { color: '#ffb900', label: 'Yellow' }, // wave-allow-color: preset swatch data\n { color: '#5c2d91', label: 'Purple' }, // wave-allow-color: preset swatch data\n { color: '#008272', label: 'Teal' }, // wave-allow-color: preset swatch data\n { color: '#e3008c', label: 'Pink' }, // wave-allow-color: preset swatch data\n { color: '#242424', label: 'Black' }, // wave-allow-color: preset swatch data\n];\n\ninterface ResolvedPresets {\n items: SwatchItem[];\n /** Presets that are not hex colors (skipped). */\n invalid: string[];\n /** Presets with an alpha byte below 255, which a preset cannot apply (ignored). */\n translucent: string[];\n}\n\n/** Normalises presets to swatch items keyed by their lowercase `#rrggbb` (duplicates dropped). */\nfunction resolvePresets(presets: ReadonlyArray<string | ColorPickerPreset>): ResolvedPresets {\n const items: SwatchItem[] = [];\n const invalid: string[] = [];\n const translucent: string[] = [];\n const seen = new Set<string>();\n for (const preset of presets) {\n const color = typeof preset === 'string' ? preset : preset.color;\n const parsed = parseHexColor(color);\n if (!parsed) {\n invalid.push(color);\n continue;\n }\n // Picking a preset keeps the current opacity, so its own alpha never applies.\n const hasAlpha = parsed.alpha !== 255;\n if (hasAlpha) translucent.push(color);\n if (seen.has(parsed.rgb)) continue;\n seen.add(parsed.rgb);\n // A string preset is announced by its hex code: the color it applies, without the alpha.\n const stringLabel = hasAlpha ? parsed.rgb : color;\n items.push({\n value: parsed.rgb,\n color: parsed.rgb,\n label: typeof preset === 'string' ? stringLabel : preset.label,\n });\n }\n return { items, invalid, translucent };\n}\n\n/** The hex field's text while the user edits it (`null` state = the field shows the value). */\ninterface HexDraft {\n /** The typed text. */\n text: string;\n /** Kept after leaving the field because it is not a hex color, so it is flagged as invalid. */\n flagged: boolean;\n}\n\n/** A hex draft without digits (`''` or a lone `#`): leaving the field shows the value again. */\nfunction isBlankDraft(text: string): boolean {\n const trimmed = text.trim();\n return trimmed === '' || trimmed === '#';\n}\n\n/** Whether typed hex text carries its own alpha digits (`#rgba` or `#rrggbbaa`). */\nfunction hasAlphaDigits(text: string): boolean {\n const digits = text.trim().replace(/^#/, '').length;\n return digits === 4 || digits === 8;\n}\n\n/**\n * A color picker: a preview, a hex text field, optional preset swatches and an optional opacity\n * slider, grouped as a named `role=\"group\"`.\n *\n * - **Value**: a hex color, `#rrggbb` or `#rrggbbaa`. The opacity slider shows and edits the\n * value's alpha byte; picking a preset or typing a 6-digit hex keeps the current opacity.\n * - **Hex field**: the text is a draft (surrounding whitespace is dropped). Complete 6- or 8-digit\n * values are applied while typing; text that can never be a hex color is flagged at once\n * (`aria-invalid` plus the `hexError` description). Leaving the field or pressing Enter applies\n * a short `#rgb` (keeping the current opacity) or `#rgba`, then shows the current value again\n * (also when a controlled parent rejected the typed color); an empty field (or a lone `#`) also\n * shows the current value again. Any other text is kept and flagged instead of being thrown\n * away, until it is corrected, cleared, or the value changes from elsewhere (a preset, the\n * opacity slider, the parent, a form reset). Enter still submits the surrounding form, with the\n * color just applied; while the text is flagged, the form submits the last applied color.\n * - **Presets** render as a SwatchPicker radiogroup (\"Preset colors\"): one tab stop, arrow keys\n * move and pick, and the selected preset shows a ring and a check glyph.\n * - **Naming**: `aria-label`/`aria-labelledby` name the group; inside a `Field` its label does, and\n * the Field's hint and error describe the group. The invalid state (`aria-invalid`, from the\n * Field or the prop) is set on the hex field, since `role=\"group\"` does not support it, and the\n * hex field is then also described by the Field's error and by a consumer `aria-errormessage`\n * (which is routed to the hex field too). A consumer `aria-required` makes the hidden form input\n * required instead of reaching the group. The texts of the picker's own parts are localised with\n * `labels`.\n * - **Forms**: with `name` the color is submitted with the form; a form reset restores\n * `defaultValue` and reports it through `onValueChange` only when the color changes.\n *\n * @example\n * <ColorPicker aria-label=\"Accent color\" showOpacity value={color} onValueChange={setColor} />\n */\nexport const ColorPicker = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n presets = DEFAULT_PRESETS,\n showOpacity = false,\n labels,\n name,\n required,\n form,\n className,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n ref,\n ...rest\n}: ColorPickerProps) => {\n if (onChange !== undefined) warnDeprecated('ColorPicker', 'onChange', 'onValueChange');\n // The default is written like every edit (C-FORMS): the picker shows, submits and restores it as\n // a lowercase `#rrggbb`/`#rrggbbaa`. A value that is not a hex color stays as given (warning\n // below).\n const rawDefault = defaultValue ?? DEFAULT_COLOR;\n const initialValue = normalizeHexColor(rawDefault) ?? rawDefault;\n const strings = { ...DEFAULT_LABELS, ...labels };\n const [color, setColor] = useControllable(valueProp, initialValue, (next: string) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n const parsed = parseHexColor(color);\n const alpha = parsed?.alpha ?? 255;\n const opacity = alphaToOpacity(alpha);\n\n /** The single commit path: every edit is `#rrggbb` + an alpha byte. */\n const commit = (rgb: string, nextAlpha: number) => setColor(formatHexColor(rgb, nextAlpha));\n\n // The hex text is a draft over `color` while the user edits it (null = show `color`).\n const [draft, setDraft] = React.useState<HexDraft | null>(null);\n // A value change from elsewhere (a preset, the opacity slider, the parent, a form reset) replaces\n // a flagged draft, so the field never shows stale text next to the new preview (input-pickers#25).\n // While the user types, the draft is not flagged and stays.\n const [syncedColor, setSyncedColor] = React.useState(color);\n if (color !== syncedColor) {\n setSyncedColor(color);\n if (draft?.flagged) setDraft(null);\n }\n const hexText = draft?.text ?? color;\n // Text that can never be a hex color is flagged while typing; an incomplete one once the user\n // leaves the field with it (`flagged`).\n const draftInvalid =\n draft !== null && !isBlankDraft(draft.text) && (draft.flagged || !isHexDraft(draft.text));\n\n const {\n items: presetItems,\n invalid: invalidPresets,\n translucent: translucentPresets,\n } = resolvePresets(presets);\n const invalidPresetKey = invalidPresets.join('\\n');\n const translucentPresetKey = translucentPresets.join('\\n');\n const invalidValue = parsed ? null : color;\n\n React.useEffect(() => {\n if (invalidValue !== null) {\n warnOnce(\n 'ColorPicker:invalid-value',\n `ColorPicker: \"${invalidValue}\" is not a hex color (#rrggbb or #rrggbbaa). Pass a hex value; the opacity slider is disabled until then.`,\n );\n }\n }, [invalidValue]);\n React.useEffect(() => {\n if (!invalidPresetKey) return;\n for (const preset of invalidPresetKey.split('\\n')) {\n warnOnce(\n `ColorPicker:invalid-preset:${preset}`,\n `ColorPicker: preset \"${preset}\" is not a hex color (#rgb or #rrggbb) and is not shown.`,\n );\n }\n }, [invalidPresetKey]);\n React.useEffect(() => {\n if (!translucentPresetKey) return;\n for (const preset of translucentPresetKey.split('\\n')) {\n warnOnce(\n `ColorPicker:alpha-preset:${preset}`,\n `ColorPicker: preset \"${preset}\" has an alpha byte, which is ignored: picking a preset keeps the current opacity. Pass the color as #rgb or #rrggbb.`,\n );\n }\n }, [translucentPresetKey]);\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const hexInputRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rootRef);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n },\n { labelable: false },\n );\n // A group supports neither aria-invalid, aria-required nor a native `required` (ARIA 1.2): the\n // invalid state goes to the hex field and the required state to the hidden form input.\n const {\n 'aria-invalid': groupInvalid,\n 'aria-required': _ariaRequired,\n required: _required,\n ...groupProps\n } = fieldProps;\n // Any invalid state from outside (the prop or the Field, `grammar`/`spelling` included) is set on\n // the hex field as is; only `true` shows the error look.\n const fieldInvalid =\n groupInvalid !== undefined && groupInvalid !== false && groupInvalid !== 'false';\n // A consumer aria-required is not supported on the group either: it requires the hidden input.\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n // The consumer's error message belongs to the invalid state set from outside (the prop or the\n // Field), so it is routed to the hex field only while that state is set.\n const errorMessageId = (fieldInvalid && ariaErrorMessage) || undefined;\n\n useFormReset(\n rootRef,\n () => {\n // Only a real change is reported: the same color in another spelling (a controlled `#ABC`\n // against the default `#aabbcc`) is not one.\n if ((normalizeHexColor(color) ?? color) !== initialValue) setColor(initialValue);\n setDraft(null);\n },\n form,\n );\n\n const errorId = useId('wave-color-picker-error');\n // The hex field carries the picker's invalid state: its own flagged text, or the Field's/prop's.\n const hexAriaInvalid = draftInvalid ? true : fieldInvalid ? groupInvalid : undefined;\n const hexInvalidLook = isInvalidLook(false, hexAriaInvalid);\n\n const handleHexChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n // Surrounding whitespace (a pasted `'#abcdef '`) is dropped, so the text that is checked,\n // committed and shown is the same.\n let text = e.target.value.trim();\n if (text !== '' && !text.startsWith('#')) text = `#${text}`;\n setDraft({ text, flagged: false });\n const typed = parseHexInput(text);\n // A 6-digit hex keeps the current opacity; an 8-digit one brings its own alpha.\n if (typed) commit(typed.rgb, hasAlphaDigits(text) ? typed.alpha : alpha);\n };\n\n /** Finishes the hex draft when the field is left or Enter is pressed. */\n const finishHexDraft = () => {\n if (draft === null || draft.flagged) return;\n const typed = parseHexColor(draft.text);\n if (typed || isBlankDraft(draft.text)) {\n // A short `#rgb` (current opacity) or `#rgba` is applied here; complete 6- and 8-digit\n // values were applied while typing, so a rejecting parent is not asked twice. Then the field\n // shows the current value (also when a controlled parent rejected it).\n if (typed && !parseHexInput(draft.text)) {\n commit(typed.rgb, hasAlphaDigits(draft.text) ? typed.alpha : alpha);\n }\n setDraft(null);\n return;\n }\n // Text that is not a hex color is kept and flagged instead of silently thrown away (WCAG 3.3.1).\n setDraft({ text: draft.text, flagged: true });\n };\n\n const handleHexKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // Not prevented: Enter still submits the surrounding form, which then carries the color just\n // applied (the submit follows the keydown, after React has rendered the new value).\n if (e.key === 'Enter' && !e.defaultPrevented && !e.nativeEvent.isComposing) finishHexDraft();\n };\n\n const handlePreset = (rgb: string) => {\n // Only a preset color is committed. The presets' own form reset reports `''` (no swatch): it\n // is ignored here, and the picker's reset restores `defaultValue` (input-basic#12).\n const preset = parseHexColor(rgb);\n if (!preset) return;\n setDraft(null);\n commit(preset.rgb, alpha);\n };\n\n const handleOpacityChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (!parsed) return;\n commit(parsed.rgb, opacityToAlpha(Number(e.target.value)));\n };\n\n const selectedPreset = parsed ? parsed.rgb : '';\n\n return (\n <div\n role=\"group\"\n {...groupProps}\n className={cn(\n 'relative inline-flex flex-col gap-3 rounded border border-border bg-background p-3 shadow-4',\n className,\n )}\n {...rest}\n ref={mergedRef}\n >\n {/* Color preview and hex input */}\n <div className=\"flex items-center gap-2\">\n <div\n data-color-preview=\"\"\n className=\"h-10 w-10 shrink-0 rounded border border-border\"\n style={{ backgroundColor: parsed ? formatHexColor(parsed.rgb, parsed.alpha) : color }}\n aria-hidden=\"true\"\n />\n <label className=\"flex flex-col gap-1\">\n <span className=\"text-caption-1 text-muted-foreground\">{strings.hex}</span>\n <input\n ref={hexInputRef}\n type=\"text\"\n value={hexText}\n onChange={handleHexChange}\n onKeyDown={handleHexKeyDown}\n onBlur={finishHexDraft}\n aria-label={strings.hexInput}\n aria-invalid={hexAriaInvalid}\n aria-errormessage={errorMessageId}\n aria-describedby={joinIds(\n draftInvalid && errorId,\n field?.validationMessageId ?? (fieldInvalid ? field?.errorId : undefined),\n errorMessageId,\n )}\n maxLength={9}\n spellCheck={false}\n autoComplete=\"off\"\n className={cn(\n 'w-24 rounded border border-input border-b-stroke-accessible bg-background px-2 py-1 text-body-1 text-foreground',\n inputFocus,\n hexInvalidLook && inputInvalid,\n )}\n />\n </label>\n </div>\n {draftInvalid && (\n <span id={errorId} className=\"text-caption-1 text-error\">\n {strings.hexError}\n </span>\n )}\n\n {/* Preset swatches: the Field wiring (id, label, hint/error, invalid, required) stays on the\n group, so the nested radiogroup does not read the surrounding FieldContext. */}\n {presetItems.length > 0 && (\n <FieldContext.Provider value={null}>\n <SwatchPicker\n items={presetItems}\n value={selectedPreset}\n onValueChange={handlePreset}\n aria-label={strings.presets}\n size=\"small\"\n shape=\"rounded\"\n />\n </FieldContext.Provider>\n )}\n\n {/* Opacity slider */}\n {showOpacity && (\n <div className=\"flex items-center gap-2\">\n <span className=\"w-14 text-caption-1 text-muted-foreground\">{strings.opacity}</span>\n <input\n type=\"range\"\n min={0}\n max={100}\n value={opacity}\n onChange={handleOpacityChange}\n disabled={!parsed}\n aria-label={strings.opacity}\n aria-valuetext={`${opacity}%`}\n className={cn(\n 'h-1 flex-1 accent-primary disabled:cursor-not-allowed disabled:opacity-50',\n focusRing,\n )}\n />\n <span className=\"w-10 text-end text-caption-1 text-muted-foreground\">{opacity}%</span>\n </div>\n )}\n\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n value={color}\n required={isRequired}\n onInvalid={() => hexInputRef.current?.focus()}\n />\n </div>\n );\n};\n\nColorPicker.displayName = 'ColorPicker';\n"],"mappings":"mmBA0HA,IAAMoC,EAAgB,UAEhBC,EAA8C,CAClD,IAAK,MACL,SAAU,kBACV,SAAU,6BAA6BD,EAAc,GACrD,QAAS,gBACT,QAAS,SACX,EAEME,GAAgD,CACpD,CAAE,MAAO,UAAW,MAAO,MAAO,EAClC,CAAE,MAAO,UAAW,MAAO,KAAM,EACjC,CAAE,MAAO,UAAW,MAAO,OAAQ,EACnC,CAAE,MAAO,UAAW,MAAO,QAAS,EACpC,CAAE,MAAO,UAAW,MAAO,QAAS,EACpC,CAAE,MAAO,UAAW,MAAO,MAAO,EAClC,CAAE,MAAO,UAAW,MAAO,MAAO,EAClC,CAAE,MAAO,UAAW,MAAO,OAAQ,CACrC,EAWA,SAASC,EAAe,EAAqE,CAC3F,IAAMC,EAAsB,CAAC,EACvBC,EAAoB,CAAC,EACrBC,EAAwB,CAAC,EACzBC,EAAO,IAAI,IACjB,IAAK,IAAMC,KAAUC,EAAS,CAC5B,IAAMC,EAAQ,OAAOF,GAAW,SAAWA,EAASA,EAAO,MACrDG,EAAS/C,EAAAA,cAAc8C,CAAK,EAClC,GAAI,CAACC,EAAQ,CACXN,EAAQ,KAAKK,CAAK,EAClB,QACF,CAEA,IAAME,EAAWD,EAAO,QAAU,IAElC,GADIC,GAAUN,EAAY,KAAKI,CAAK,EAChCH,EAAK,IAAII,EAAO,GAAG,EAAG,SAC1BJ,EAAK,IAAII,EAAO,GAAG,EAEnB,IAAME,EAAcD,EAAWD,EAAO,IAAMD,EAC5CN,EAAM,KAAK,CACT,MAAOO,EAAO,IACd,MAAOA,EAAO,IACd,MAAO,OAAOH,GAAW,SAAWK,EAAcL,EAAO,KAC3D,CAAC,CACH,CACA,MAAO,CAAE,QAAO,UAAS,aAAY,CACvC,CAWA,SAASM,EAAa,EAAuB,CA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AO6B,GACP,cAAeF,GACf,aAAY3C,EAAQ,QACpB,KAAK,QACL,MAAM,SACP,CAAA,CACoB,CAAA,EAIxB+C,KACC,EAAAhF,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,0BAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,4CAA6C,SAAAiC,EAAQ,OAAc,CAAA,GACnF,EAAAjC,EAAA,IAAA,CAAC,QAAD,CACE,KAAK,QACL,IAAK,EACL,IAAK,IACL,MAAOuC,EACP,SAAUsC,GACV,SAAU,CAACjE,EACX,aAAYqB,EAAQ,QACpB,iBAAgB,GAAGM,EAAQ,GAC3B,UAAW5D,EAAAA,GACT,4EAAA,mFAEF,CACD,CAAA,GACD,EAAAqB,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,qDAAhB,SAAA,CAAsEuC,EAAQ,GAAO,GAClF,KAGP,EAAAvC,EAAA,IAAA,CAAChB,EAAAA,YAAD,CACE,KAAK,OACC,QACA,OACN,MAAO2B,EACP,SAAUsD,EACV,cAAiBT,EAAY,SAAS,MAAM,CAC7C,CAAA,CACE,GAET,EAEA,EAAY,YAAc"}
|
|
1
|
+
{"version":3,"file":"ColorPicker.cjs","names":["parseHexColor","hexToHsv","normalizeHexColor","React","DEFAULT_COLOR_PICKER_LABELS","useControllable","alphaToOpacity","useMergedRefs","useFieldContext","useFieldControl","useEventCallback","formatHexColor","DEFAULT_PART_COLOR","hsvToHex","getFirstTabbable","cn","colorPickerClassNames","ColorPickerContext","FieldContext","slotRendersContent","_Fragment","ColorArea","ColorSlider","ColorPickerPreview","ColorPickerHexField","ColorPickerSwatches","AlphaSlider","HiddenInput","require_runtime","require_cn","require_dev","require_slot","require_classNames","require_color","require_useEventCallback","require_useControllable","require_focus","require_useMergedRefs","require_useFieldControl","require_useFormReset","require_HiddenInput","require_colorUtils","require_ColorPicker_parts","require_AlphaSlider","require_ColorArea","require_ColorSlider","react","react_jsx_runtime","DEFAULT_PRESETS","resolvePresets","items","invalid","translucent","seen","preset","presets","color","parsed","hasAlpha","stringLabel","deriveWorkingColor","next","hex","previous","ColorPickerRoot","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","rest","onChange","rawDefault","defaultValue","initialValue","strings","labels","setColor","onValueChange","alpha","opacity","presetItems","invalidPresets","translucentPresets","invalidPresetKey","translucentPresetKey","invalidValue","rootRef","hexInputRef","mergedRef","ref","registerHexInput","input","draftResetKey","setDraftResetKey","field","groupInvalid","_ariaRequired","_required","groupProps","fieldInvalid","isRequired","required","errorMessageId","key","form","pickPreset","rgb","hsv","setHsvState","normalized","setHsv","context","shape","focusInvalidTarget","root","className","children","showOpacity","ColorPicker"],"sources":["../../../src/components/input/ColorPicker.tsx"],"sourcesContent":["import * as React from 'react';\nimport { colorPickerClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { hexToHsv, hsvToHex } from '../../lib/color';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { getFirstTabbable } from '../../lib/focus';\nimport { slotRendersContent } from '../../lib/slot';\nimport type { ColorPickerShape, HsvColor } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { FieldContext, useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { AlphaSlider } from './AlphaSlider';\nimport { ColorArea } from './ColorArea';\nimport { ColorSlider } from './ColorSlider';\nimport type { SwatchItem } from './SwatchPicker';\nimport {\n ColorPickerContext,\n ColorPickerHexField,\n ColorPickerPreview,\n ColorPickerSwatches,\n DEFAULT_COLOR,\n DEFAULT_COLOR_PICKER_LABELS,\n DEFAULT_PART_COLOR,\n type ColorPickerContextValue,\n type ColorPickerLabels,\n} from './ColorPicker.parts';\nimport { alphaToOpacity, formatHexColor, normalizeHexColor, parseHexColor } from './colorUtils';\n\nexport { ColorPickerHexField, ColorPickerPreview, ColorPickerSwatches };\nexport type { ColorPickerLabels };\nexport type {\n ColorPickerHexFieldProps,\n ColorPickerPreviewProps,\n ColorPickerSwatchesProps,\n} from './ColorPicker.parts';\n\n/** A named preset color. */\nexport interface ColorPickerPreset {\n /**\n * Hex color (`#rrggbb`; `#rgb` is expanded). A preset has no opacity of its own: picking it keeps\n * the current opacity, so its alpha digits (`#rgba`, `#rrggbbaa`) are ignored. An alpha below\n * `f`/`ff` logs a development warning; an opaque one (`#rgbf`, `#rrggbbff`) changes nothing.\n */\n color: string;\n /** Accessible name of the preset swatch, e.g. `'Cranberry'`. */\n label: string;\n}\n\n/** Properties for the ColorPicker component. */\nexport interface ColorPickerProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /**\n * Controlled hex color: `#rrggbb`, or `#rrggbbaa` with an alpha byte (e.g. `'#0f6cbd80'` for\n * 50% opacity). Other formats are not supported (development warning).\n */\n value?: string;\n /**\n * Initial hex color for uncontrolled usage (also what a form reset restores). Like every edit it\n * is shown, submitted and reported as a lowercase `#rrggbb`, or `#rrggbbaa` when it is not fully\n * opaque (`'#ABC'` becomes `'#aabbcc'`).\n * @default '#0f6cbd'\n */\n defaultValue?: string;\n /**\n * Called with the new color when it changes: a lowercase `#rrggbb`, or `#rrggbbaa` when the color\n * is not fully opaque.\n */\n onValueChange?: (color: string) => void;\n /**\n * Called with the new color when it changes.\n * @deprecated Use `onValueChange`.\n */\n onChange?: (color: string) => void;\n /**\n * Preset colors shown as quick-select swatches. Pass `{ color, label }` objects so screen reader\n * users hear a name; a plain hex string is announced by its hex code. Non-hex presets are\n * skipped (development warning). Picking a preset keeps the current opacity, so a preset's alpha\n * digits are ignored. With an alpha below `f`/`ff` (`#rgba`, `#rrggbbaa`) there is a development\n * warning, and a string preset is announced by the `#rrggbb` color it applies; an opaque alpha\n * (`#rgbf`, `#rrggbbff`) changes nothing, and the string stays the name as written. With\n * `children`, the presets feed only `ColorPicker.Swatches`.\n * @default Blue, Red, Green, Yellow, Purple, Teal, Pink and Black (Fluent brand colors)\n */\n presets?: ReadonlyArray<string | ColorPickerPreset>;\n /**\n * Whether the default layout shows the opacity row: the caption, an alpha slider (0–100 %,\n * named by `labels.opacity`) and the percentage. The opacity is the alpha byte of `value`. Does\n * nothing with `children`.\n * @default false\n */\n showOpacity?: boolean;\n /** Texts of the picker's own parts and of the color parts bound to it, for localisation. */\n labels?: ColorPickerLabels;\n /**\n * `'square'` removes the corner radius of the preview and of the area and the rails of the\n * color parts bound to it, including those of the default layout.\n * @default 'rounded'\n */\n shape?: ColorPickerShape;\n /**\n * Your own layout: `ColorArea`, `ColorSlider` and `AlphaSlider` (bound to the picker while they\n * have neither `value` nor `defaultValue`) and the parts `ColorPicker.HexField`,\n * `ColorPicker.Swatches` and `ColorPicker.Preview`. Without children the picker renders its\n * default layout. With children, `showOpacity` does nothing and `presets` feed only\n * `ColorPicker.Swatches`.\n */\n children?: React.ReactNode;\n /** Form field name. With a name, the current color is submitted with the form. */\n name?: string;\n /**\n * Marks the hidden form input as required (a color is always chosen, so it never blocks). A\n * consumer `aria-required` has the same effect: `role=\"group\"` does not support it, so it is not\n * rendered on the group.\n */\n required?: boolean;\n /** Id of the form the picker belongs to, when it is rendered outside that form. */\n form?: string;\n /** Ref to the root `role=\"group\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst DEFAULT_PRESETS: readonly ColorPickerPreset[] = [\n { color: '#0f6cbd', label: 'Blue' }, // wave-allow-color: preset swatch data\n { color: '#d13438', label: 'Red' }, // wave-allow-color: preset swatch data\n { color: '#107c10', label: 'Green' }, // wave-allow-color: preset swatch data\n { color: '#ffb900', label: 'Yellow' }, // wave-allow-color: preset swatch data\n { color: '#5c2d91', label: 'Purple' }, // wave-allow-color: preset swatch data\n { color: '#008272', label: 'Teal' }, // wave-allow-color: preset swatch data\n { color: '#e3008c', label: 'Pink' }, // wave-allow-color: preset swatch data\n { color: '#242424', label: 'Black' }, // wave-allow-color: preset swatch data\n];\n\ninterface ResolvedPresets {\n items: SwatchItem[];\n /** Presets that are not hex colors (skipped). */\n invalid: string[];\n /** Presets with an alpha byte below 255, which a preset cannot apply (ignored). */\n translucent: string[];\n}\n\n/** Normalises presets to swatch items keyed by their lowercase `#rrggbb` (duplicates dropped). */\nfunction resolvePresets(presets: ReadonlyArray<string | ColorPickerPreset>): ResolvedPresets {\n const items: SwatchItem[] = [];\n const invalid: string[] = [];\n const translucent: string[] = [];\n const seen = new Set<string>();\n for (const preset of presets) {\n const color = typeof preset === 'string' ? preset : preset.color;\n const parsed = parseHexColor(color);\n if (!parsed) {\n invalid.push(color);\n continue;\n }\n // Picking a preset keeps the current opacity, so its own alpha never applies.\n const hasAlpha = parsed.alpha !== 255;\n if (hasAlpha) translucent.push(color);\n if (seen.has(parsed.rgb)) continue;\n seen.add(parsed.rgb);\n // A string preset is announced by its hex code: the color it applies, without the alpha.\n const stringLabel = hasAlpha ? parsed.rgb : color;\n items.push({\n value: parsed.rgb,\n color: parsed.rgb,\n label: typeof preset === 'string' ? stringLabel : preset.label,\n });\n }\n return { items, invalid, translucent };\n}\n\n/**\n * The working color for a hex value that differs from it: the value's HSV, keeping the previous\n * hue when the new color has no hue of its own (a gray, white or black) and the previous\n * saturation too at zero brightness, so a hue slider does not jump to red when the color reaches\n * gray. `hsvToHex` of the result is `hex` again.\n */\nfunction deriveWorkingColor(hex: string, previous: HsvColor): HsvColor {\n const next = hexToHsv(hex);\n if (!next) return previous;\n if (next.v === 0) return { ...next, h: previous.h, s: previous.s };\n if (next.s === 0) return { ...next, h: previous.h };\n return next;\n}\n\n// The ColorPicker root, documented on the exported `ColorPicker` const.\nconst ColorPickerRoot = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n presets = DEFAULT_PRESETS,\n showOpacity = false,\n labels,\n shape = 'rounded',\n name,\n required,\n form,\n className,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n children,\n ref,\n ...rest\n}: ColorPickerProps) => {\n if (onChange !== undefined) warnDeprecated('ColorPicker', 'onChange', 'onValueChange');\n // The default is written like every edit (C-FORMS): the picker shows, submits and restores it as\n // a lowercase `#rrggbb`/`#rrggbbaa`. A value that is not a hex color stays as given (warning\n // below).\n const rawDefault = defaultValue ?? DEFAULT_COLOR;\n const initialValue = normalizeHexColor(rawDefault) ?? rawDefault;\n const strings = React.useMemo(() => ({ ...DEFAULT_COLOR_PICKER_LABELS, ...labels }), [labels]);\n const [color, setColor] = useControllable(valueProp, initialValue, (next: string) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n const parsed = React.useMemo(() => parseHexColor(color), [color]);\n const alpha = parsed?.alpha ?? 255;\n const opacity = alphaToOpacity(alpha);\n\n const {\n items: presetItems,\n invalid: invalidPresets,\n translucent: translucentPresets,\n } = React.useMemo(() => resolvePresets(presets), [presets]);\n const invalidPresetKey = invalidPresets.join('\\n');\n const translucentPresetKey = translucentPresets.join('\\n');\n const invalidValue = parsed ? null : color;\n\n React.useEffect(() => {\n if (invalidValue !== null) {\n warnOnce(\n 'ColorPicker:invalid-value',\n `ColorPicker: \"${invalidValue}\" is not a hex color (#rrggbb or #rrggbbaa). Pass a hex value; the color area and sliders are disabled until then.`,\n );\n }\n }, [invalidValue]);\n React.useEffect(() => {\n if (!invalidPresetKey) return;\n for (const preset of invalidPresetKey.split('\\n')) {\n warnOnce(\n `ColorPicker:invalid-preset:${preset}`,\n `ColorPicker: preset \"${preset}\" is not a hex color (#rgb or #rrggbb) and is not shown.`,\n );\n }\n }, [invalidPresetKey]);\n React.useEffect(() => {\n if (!translucentPresetKey) return;\n for (const preset of translucentPresetKey.split('\\n')) {\n warnOnce(\n `ColorPicker:alpha-preset:${preset}`,\n `ColorPicker: preset \"${preset}\" has an alpha byte, which is ignored: picking a preset keeps the current opacity. Pass the color as #rgb or #rrggbb.`,\n );\n }\n }, [translucentPresetKey]);\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const hexInputRef = React.useRef<HTMLInputElement | null>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rootRef);\n const registerHexInput = React.useCallback((input: HTMLInputElement | null) => {\n hexInputRef.current = input;\n }, []);\n // Changes whenever the hex field must drop its draft: a form reset or a preset pick.\n const [draftResetKey, setDraftResetKey] = React.useState(0);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n },\n { labelable: false },\n );\n // A group supports neither aria-invalid, aria-required nor a native `required` (ARIA 1.2): the\n // invalid state goes to the hex field and the required state to the hidden form input.\n const {\n 'aria-invalid': groupInvalid,\n 'aria-required': _ariaRequired,\n required: _required,\n ...groupProps\n } = fieldProps;\n const fieldInvalid =\n groupInvalid !== undefined && groupInvalid !== false && groupInvalid !== 'false';\n // A consumer aria-required is not supported on the group either: it requires the hidden input.\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n // The consumer's error message belongs to the invalid state set from outside (the prop or the\n // Field), so it is routed to the hex field only while that state is set.\n const errorMessageId = (fieldInvalid && ariaErrorMessage) || undefined;\n\n useFormReset(\n rootRef,\n () => {\n // Only a real change is reported: the same color in another spelling (a controlled `#ABC`\n // against the default `#aabbcc`) is not one.\n if ((normalizeHexColor(color) ?? color) !== initialValue) setColor(initialValue);\n setDraftResetKey((key) => key + 1);\n },\n form,\n );\n\n const pickPreset = useEventCallback((rgb: string) => {\n // Only a preset color is committed. The presets' own form reset reports `''` (no swatch): it\n // is ignored here, and the picker's reset restores `defaultValue` (input-basic#12).\n const preset = parseHexColor(rgb);\n if (!preset) return;\n setDraftResetKey((key) => key + 1);\n setColor(formatHexColor(preset.rgb, alpha));\n });\n\n // The working color: HSV, so hue and saturation survive gray, white and black (hex keeps\n // neither). The value stays the source of truth: whenever it differs from the working color (a\n // change from outside, a form reset, or a controlled parent that ignored onValueChange), the\n // working color follows it. A parent that accepts a change sets exactly `hsvToHex(hsv)`, so the\n // working color is kept.\n const [hsv, setHsvState] = React.useState<HsvColor>(() =>\n deriveWorkingColor(color, DEFAULT_PART_COLOR),\n );\n const normalized = parsed ? formatHexColor(parsed.rgb, parsed.alpha) : null;\n if (normalized !== null && hsvToHex(hsv) !== normalized) {\n setHsvState(deriveWorkingColor(normalized, hsv));\n }\n const setHsv = useEventCallback((next: HsvColor) => {\n if (!parsed) return;\n setHsvState(next);\n setColor(hsvToHex(next));\n });\n\n const context = React.useMemo<ColorPickerContextValue>(\n () => ({\n hsv,\n setHsv,\n color,\n parsed,\n setColor,\n pickPreset,\n presetItems,\n shape,\n labels: strings,\n disabled: parsed === null,\n draftResetKey,\n field,\n groupInvalid,\n errorMessageId,\n registerHexInput,\n }),\n [\n hsv,\n setHsv,\n color,\n parsed,\n setColor,\n pickPreset,\n presetItems,\n shape,\n strings,\n draftResetKey,\n field,\n groupInvalid,\n errorMessageId,\n registerHexInput,\n ],\n );\n\n /** The hidden input's `onInvalid`: the hex field when there is one, else the first tabbable element. */\n const focusInvalidTarget = () => {\n const root = rootRef.current;\n (hexInputRef.current ?? (root ? getFirstTabbable(root) : null))?.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...groupProps}\n className={cn(\n colorPickerClassNames.root,\n 'relative inline-flex flex-col gap-3 rounded border border-border bg-background p-3 shadow-4',\n className,\n )}\n {...rest}\n ref={mergedRef}\n >\n <ColorPickerContext.Provider value={context}>\n {/* The Field wiring (id, label, hint and error, invalid, required) stays on the group:\n the parts inside never read the surrounding FieldContext. */}\n <FieldContext.Provider value={null}>\n {slotRendersContent(children) ? (\n children\n ) : (\n <>\n <ColorArea />\n <ColorSlider />\n <div className=\"flex items-start gap-2\">\n <ColorPickerPreview />\n <ColorPickerHexField />\n </div>\n <ColorPickerSwatches />\n {showOpacity && (\n <div className=\"flex items-center gap-2\">\n <span\n className={cn(\n colorPickerClassNames.opacityLabel,\n 'w-14 text-caption-1 text-muted-foreground',\n )}\n >\n {strings.opacity}\n </span>\n <AlphaSlider className=\"min-w-0 flex-1\" />\n <span\n className={cn(\n colorPickerClassNames.opacityValue,\n 'w-10 text-end text-caption-1 text-muted-foreground',\n )}\n >\n {opacity}%\n </span>\n </div>\n )}\n </>\n )}\n </FieldContext.Provider>\n </ColorPickerContext.Provider>\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n value={color}\n required={isRequired}\n onInvalid={focusInvalidTarget}\n />\n </div>\n );\n};\n\nColorPickerRoot.displayName = 'ColorPicker';\n\n/**\n * A color picker whose value is a hex string (`#rrggbb`, or `#rrggbbaa` with an alpha byte),\n * grouped as a named `role=\"group\"`.\n *\n * - **Default layout** (no children): a color area (saturation and brightness) and a hue slider,\n * then a preview and the hex field, preset swatches and, with `showOpacity`, an opacity row\n * whose slider is an `AlphaSlider` (0–100 %). Dragging to gray, white or black keeps the hue.\n * - **Your own layout** (children): `ColorArea`, `ColorSlider` and `AlphaSlider`, which bind to\n * the picker while they have neither `value` nor `defaultValue`, and the parts\n * `ColorPicker.HexField`, `ColorPicker.Swatches` and `ColorPicker.Preview`.\n * - **Hex field**: the text is a draft. Complete 6- and 8-digit values apply while typing; text\n * that can never be a hex color is flagged at once (`aria-invalid` plus the `hexError`\n * description). Leaving the field or pressing Enter applies a short `#rgb` (keeping the current\n * opacity) or `#rgba`, then shows the current value again; other text stays flagged until it is\n * corrected, cleared, or the value changes from elsewhere. Enter still submits the surrounding\n * form, with the color just applied.\n * - **Presets** render as a SwatchPicker radiogroup (\"Preset colors\"): one tab stop, arrow keys\n * move and pick, and picking keeps the current opacity.\n * - **Naming**: `aria-label`/`aria-labelledby` name the group; inside a `Field` its label does,\n * and the Field's hint and error describe the group. The invalid state (`aria-invalid`, from the\n * Field or the prop) is set on the hex field, since `role=\"group\"` does not support it, and a\n * consumer `aria-errormessage` goes there too. A consumer `aria-required` makes the hidden form\n * input required instead. The built-in texts are localised with `labels`.\n * - **Forms**: with `name` the color is submitted with the form; a form reset restores\n * `defaultValue` and reports it through `onValueChange` only when the color changes.\n *\n * React Server Components cannot dot into a client module: import the flat names\n * `ColorPickerHexField`, `ColorPickerSwatches` and `ColorPickerPreview` there;\n * `ColorPicker.HexField` etc. work in client files.\n *\n * @example\n * <ColorPicker aria-label=\"Accent color\" showOpacity value={color} onValueChange={setColor} />\n *\n * <ColorPicker aria-label=\"Accent color\" value={color} onValueChange={setColor}>\n * <ColorArea />\n * <ColorSlider />\n * <ColorPicker.HexField />\n * </ColorPicker>\n */\nexport const ColorPicker = /* @__PURE__ */ Object.assign(ColorPickerRoot, {\n HexField: ColorPickerHexField,\n Swatches: ColorPickerSwatches,\n Preview: ColorPickerPreview,\n});\n"],"mappings":"+vBA8HA,IAAMgD,EAAgD,CACpD,CAAE,MAAO,UAAW,MAAO,MAAO,EAClC,CAAE,MAAO,UAAW,MAAO,KAAM,EACjC,CAAE,MAAO,UAAW,MAAO,OAAQ,EACnC,CAAE,MAAO,UAAW,MAAO,QAAS,EACpC,CAAE,MAAO,UAAW,MAAO,QAAS,EACpC,CAAE,MAAO,UAAW,MAAO,MAAO,EAClC,CAAE,MAAO,UAAW,MAAO,MAAO,EAClC,CAAE,MAAO,UAAW,MAAO,OAAQ,CACrC,EAWA,SAASC,GAAe,EAAqE,CAC3F,IAAMC,EAAsB,CAAC,EACvBC,EAAoB,CAAC,EACrBC,EAAwB,CAAC,EACzBC,EAAO,IAAI,IACjB,IAAK,IAAMC,KAAUC,EAAS,CAC5B,IAAMC,EAAQ,OAAOF,GAAW,SAAWA,EAASA,EAAO,MACrDG,EAASzD,EAAAA,cAAcwD,CAAK,EAClC,GAAI,CAACC,EAAQ,CACXN,EAAQ,KAAKK,CAAK,EAClB,QACF,CAEA,IAAME,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AA,CAEiB,CAAA,CACI,CAAA,GAC7B,EAAAnC,EAAA,IAAA,CAACpB,GAAAA,YAAD,CACE,KAAK,OACC,OACA,OACN,MAAO6B,EACP,SAAU+C,EACV,UAAWa,EACZ,CAAA,CACE,GAET,EAEA,EAAgB,YAAc,cAyC9B,IAAaK,EAA8B,OAAO,OAAOzD,EAAiB,CACxE,SAAUxC,EAAAA,oBACV,SAAUC,EAAAA,oBACV,QAASF,EAAAA,kBACX,CAAC"}
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
3
|
import { warnDeprecated as t, warnOnce as n } from "../../lib/dev.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
4
|
+
import { slotRendersContent as r } from "../../lib/slot.mjs";
|
|
5
|
+
import { colorPickerClassNames as i } from "../../lib/classNames.mjs";
|
|
6
|
+
import { hexToHsv as a, hsvToHex as o } from "../../lib/color.mjs";
|
|
7
|
+
import { useEventCallback as s } from "../../hooks/useEventCallback.mjs";
|
|
8
|
+
import { useControllable as c } from "../../hooks/useControllable.mjs";
|
|
9
|
+
import { getFirstTabbable as ee } from "../../lib/focus.mjs";
|
|
10
|
+
import { useMergedRefs as te } from "../../hooks/useMergedRefs.mjs";
|
|
11
|
+
import { FieldContext as ne, useFieldContext as re, useFieldControl as ie } from "../../hooks/useFieldControl.mjs";
|
|
12
|
+
import { useFormReset as ae } from "../../hooks/useFormReset.mjs";
|
|
13
|
+
import { HiddenInput as oe } from "../internal/HiddenInput.mjs";
|
|
14
|
+
import { alphaToOpacity as se, formatHexColor as l, normalizeHexColor as u, parseHexColor as d } from "./colorUtils.mjs";
|
|
15
|
+
import { ColorPickerContext as ce, ColorPickerHexField as f, ColorPickerPreview as p, ColorPickerSwatches as m, DEFAULT_COLOR_PICKER_LABELS as le, DEFAULT_PART_COLOR as ue } from "./ColorPicker.parts.mjs";
|
|
16
|
+
import { AlphaSlider as de } from "./AlphaSlider.mjs";
|
|
17
|
+
import { ColorArea as fe } from "./ColorArea.mjs";
|
|
18
|
+
import { ColorSlider as pe } from "./ColorSlider.mjs";
|
|
19
|
+
import * as h from "react";
|
|
20
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
17
21
|
//#region src/components/input/ColorPicker.tsx
|
|
18
|
-
var
|
|
19
|
-
hex: "Hex",
|
|
20
|
-
hexInput: "Hex color value",
|
|
21
|
-
hexError: `Enter a hex color such as ${y}.`,
|
|
22
|
-
presets: "Preset colors",
|
|
23
|
-
opacity: "Opacity"
|
|
24
|
-
}, oe = [
|
|
22
|
+
var me = [
|
|
25
23
|
{
|
|
26
24
|
color: "#0f6cbd",
|
|
27
25
|
label: "Blue"
|
|
@@ -55,10 +53,10 @@ var y = "#0f6cbd", b = {
|
|
|
55
53
|
label: "Black"
|
|
56
54
|
}
|
|
57
55
|
];
|
|
58
|
-
function
|
|
56
|
+
function he(e) {
|
|
59
57
|
let t = [], n = [], r = [], i = /* @__PURE__ */ new Set();
|
|
60
58
|
for (let a of e) {
|
|
61
|
-
let e = typeof a == "string" ? a : a.color, o =
|
|
59
|
+
let e = typeof a == "string" ? a : a.color, o = d(e);
|
|
62
60
|
if (!o) {
|
|
63
61
|
n.push(e);
|
|
64
62
|
continue;
|
|
@@ -79,158 +77,137 @@ function se(e) {
|
|
|
79
77
|
translucent: r
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
|
-
function
|
|
83
|
-
let
|
|
84
|
-
return
|
|
80
|
+
function y(e, t) {
|
|
81
|
+
let n = a(e);
|
|
82
|
+
return n ? n.v === 0 ? {
|
|
83
|
+
...n,
|
|
84
|
+
h: t.h,
|
|
85
|
+
s: t.s
|
|
86
|
+
} : n.s === 0 ? {
|
|
87
|
+
...n,
|
|
88
|
+
h: t.h
|
|
89
|
+
} : n : t;
|
|
85
90
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
(
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
91
|
+
var b = ({ value: a, defaultValue: b, onValueChange: x, onChange: S, presets: C = me, showOpacity: w = !1, labels: T, shape: E = "rounded", name: ge, required: _e, form: D, className: ve, id: ye, "aria-label": be, "aria-labelledby": xe, "aria-describedby": Se, "aria-invalid": Ce, "aria-required": O, "aria-errormessage": we, children: k, ref: Te, ...Ee }) => {
|
|
92
|
+
S !== void 0 && t("ColorPicker", "onChange", "onValueChange");
|
|
93
|
+
let A = b ?? "#0f6cbd", j = u(A) ?? A, M = h.useMemo(() => ({
|
|
94
|
+
...le,
|
|
95
|
+
...T
|
|
96
|
+
}), [T]), [N, P] = c(a, j, (e) => {
|
|
97
|
+
x?.(e), S?.(e);
|
|
98
|
+
}), F = h.useMemo(() => d(N), [N]), I = F?.alpha ?? 255, De = se(I), { items: L, invalid: Oe, translucent: ke } = h.useMemo(() => he(C), [C]), R = Oe.join("\n"), z = ke.join("\n"), B = F ? null : N;
|
|
99
|
+
h.useEffect(() => {
|
|
100
|
+
B !== null && n("ColorPicker:invalid-value", `ColorPicker: "${B}" is not a hex color (#rrggbb or #rrggbbaa). Pass a hex value; the color area and sliders are disabled until then.`);
|
|
101
|
+
}, [B]), h.useEffect(() => {
|
|
102
|
+
if (R) for (let e of R.split("\n")) n(`ColorPicker:invalid-preset:${e}`, `ColorPicker: preset "${e}" is not a hex color (#rgb or #rrggbb) and is not shown.`);
|
|
103
|
+
}, [R]), h.useEffect(() => {
|
|
104
|
+
if (z) for (let e of z.split("\n")) n(`ColorPicker:alpha-preset:${e}`, `ColorPicker: preset "${e}" has an alpha byte, which is ignored: picking a preset keeps the current opacity. Pass the color as #rgb or #rrggbb.`);
|
|
105
|
+
}, [z]);
|
|
106
|
+
let V = h.useRef(null), H = h.useRef(null), Ae = te(Te, V), U = h.useCallback((e) => {
|
|
107
|
+
H.current = e;
|
|
108
|
+
}, []), [W, G] = h.useState(0), K = re(), { "aria-invalid": q, "aria-required": je, required: Me, ...Ne } = ie({
|
|
109
|
+
id: ye,
|
|
110
|
+
"aria-label": be,
|
|
111
|
+
"aria-labelledby": xe,
|
|
112
|
+
"aria-describedby": Se,
|
|
113
|
+
"aria-invalid": Ce
|
|
114
|
+
}, { labelable: !1 }), Pe = q !== void 0 && q !== !1 && q !== "false", Fe = _e ?? (O === !0 || O === "true" || (K?.required ?? !1)), J = Pe && we || void 0;
|
|
115
|
+
ae(V, () => {
|
|
116
|
+
(u(N) ?? N) !== j && P(j), G((e) => e + 1);
|
|
117
|
+
}, D);
|
|
118
|
+
let Y = s((e) => {
|
|
119
|
+
let t = d(e);
|
|
120
|
+
t && (G((e) => e + 1), P(l(t.rgb, I)));
|
|
121
|
+
}), [X, Z] = h.useState(() => y(N, ue)), Q = F ? l(F.rgb, F.alpha) : null;
|
|
122
|
+
Q !== null && o(X) !== Q && Z(y(Q, X));
|
|
123
|
+
let $ = s((e) => {
|
|
124
|
+
F && (Z(e), P(o(e)));
|
|
125
|
+
}), Ie = h.useMemo(() => ({
|
|
126
|
+
hsv: X,
|
|
127
|
+
setHsv: $,
|
|
128
|
+
color: N,
|
|
129
|
+
parsed: F,
|
|
130
|
+
setColor: P,
|
|
131
|
+
pickPreset: Y,
|
|
132
|
+
presetItems: L,
|
|
133
|
+
shape: E,
|
|
134
|
+
labels: M,
|
|
135
|
+
disabled: F === null,
|
|
136
|
+
draftResetKey: W,
|
|
137
|
+
field: K,
|
|
138
|
+
groupInvalid: q,
|
|
139
|
+
errorMessageId: J,
|
|
140
|
+
registerHexInput: U
|
|
141
|
+
}), [
|
|
142
|
+
X,
|
|
143
|
+
$,
|
|
144
|
+
N,
|
|
145
|
+
F,
|
|
146
|
+
P,
|
|
147
|
+
Y,
|
|
148
|
+
L,
|
|
149
|
+
E,
|
|
150
|
+
M,
|
|
151
|
+
W,
|
|
152
|
+
K,
|
|
153
|
+
q,
|
|
154
|
+
J,
|
|
155
|
+
U
|
|
156
|
+
]), Le = () => {
|
|
157
|
+
let e = V.current;
|
|
158
|
+
(H.current ?? (e ? ee(e) : null))?.focus();
|
|
159
|
+
};
|
|
144
160
|
return /* @__PURE__ */ v("div", {
|
|
145
161
|
role: "group",
|
|
146
|
-
...
|
|
147
|
-
className: e("relative inline-flex flex-col gap-3 rounded border border-border bg-background p-3 shadow-4",
|
|
148
|
-
...
|
|
149
|
-
ref:
|
|
150
|
-
children: [
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
children: [/* @__PURE__ */ _("div", {
|
|
154
|
-
"data-color-preview": "",
|
|
155
|
-
className: "h-10 w-10 shrink-0 rounded border border-border",
|
|
156
|
-
style: { backgroundColor: N ? d(N.rgb, N.alpha) : j },
|
|
157
|
-
"aria-hidden": "true"
|
|
158
|
-
}), /* @__PURE__ */ v("label", {
|
|
159
|
-
className: "flex flex-col gap-1",
|
|
160
|
-
children: [/* @__PURE__ */ _("span", {
|
|
161
|
-
className: "text-caption-1 text-muted-foreground",
|
|
162
|
-
children: A.hex
|
|
163
|
-
}), /* @__PURE__ */ _("input", {
|
|
164
|
-
ref: G,
|
|
165
|
-
type: "text",
|
|
166
|
-
value: Te,
|
|
167
|
-
onChange: Ne,
|
|
168
|
-
onKeyDown: Pe,
|
|
169
|
-
onBlur: $,
|
|
170
|
-
"aria-label": A.hexInput,
|
|
171
|
-
"aria-invalid": Q,
|
|
172
|
-
"aria-errormessage": X,
|
|
173
|
-
"aria-describedby": o(z && Z, K?.validationMessageId ?? (J ? K?.errorId : void 0), X),
|
|
174
|
-
maxLength: 9,
|
|
175
|
-
spellCheck: !1,
|
|
176
|
-
autoComplete: "off",
|
|
177
|
-
className: e("w-24 rounded border border-input border-b-stroke-accessible bg-background px-2 py-1 text-body-1 text-foreground", ee, Me && "border-destructive focus:border-b-destructive")
|
|
178
|
-
})]
|
|
179
|
-
})]
|
|
180
|
-
}),
|
|
181
|
-
z && /* @__PURE__ */ _("span", {
|
|
182
|
-
id: Z,
|
|
183
|
-
className: "text-caption-1 text-error",
|
|
184
|
-
children: A.hexError
|
|
185
|
-
}),
|
|
186
|
-
B.length > 0 && /* @__PURE__ */ _(s.Provider, {
|
|
162
|
+
...Ne,
|
|
163
|
+
className: e(i.root, "relative inline-flex flex-col gap-3 rounded border border-border bg-background p-3 shadow-4", ve),
|
|
164
|
+
...Ee,
|
|
165
|
+
ref: Ae,
|
|
166
|
+
children: [/* @__PURE__ */ _(ce.Provider, {
|
|
167
|
+
value: Ie,
|
|
168
|
+
children: /* @__PURE__ */ _(ne.Provider, {
|
|
187
169
|
value: null,
|
|
188
|
-
children: /* @__PURE__ */
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
shape: "rounded"
|
|
195
|
-
})
|
|
196
|
-
}),
|
|
197
|
-
de && /* @__PURE__ */ v("div", {
|
|
198
|
-
className: "flex items-center gap-2",
|
|
199
|
-
children: [
|
|
200
|
-
/* @__PURE__ */ _("span", {
|
|
201
|
-
className: "w-14 text-caption-1 text-muted-foreground",
|
|
202
|
-
children: A.opacity
|
|
203
|
-
}),
|
|
204
|
-
/* @__PURE__ */ _("input", {
|
|
205
|
-
type: "range",
|
|
206
|
-
min: 0,
|
|
207
|
-
max: 100,
|
|
208
|
-
value: F,
|
|
209
|
-
onChange: Ie,
|
|
210
|
-
disabled: !N,
|
|
211
|
-
"aria-label": A.opacity,
|
|
212
|
-
"aria-valuetext": `${F}%`,
|
|
213
|
-
className: e("h-1 flex-1 accent-primary disabled:cursor-not-allowed disabled:opacity-50", "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring")
|
|
170
|
+
children: r(k) ? k : /* @__PURE__ */ v(g, { children: [
|
|
171
|
+
/* @__PURE__ */ _(fe, {}),
|
|
172
|
+
/* @__PURE__ */ _(pe, {}),
|
|
173
|
+
/* @__PURE__ */ v("div", {
|
|
174
|
+
className: "flex items-start gap-2",
|
|
175
|
+
children: [/* @__PURE__ */ _(p, {}), /* @__PURE__ */ _(f, {})]
|
|
214
176
|
}),
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
|
|
217
|
-
|
|
177
|
+
/* @__PURE__ */ _(m, {}),
|
|
178
|
+
w && /* @__PURE__ */ v("div", {
|
|
179
|
+
className: "flex items-center gap-2",
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ _("span", {
|
|
182
|
+
className: e(i.opacityLabel, "w-14 text-caption-1 text-muted-foreground"),
|
|
183
|
+
children: M.opacity
|
|
184
|
+
}),
|
|
185
|
+
/* @__PURE__ */ _(de, { className: "min-w-0 flex-1" }),
|
|
186
|
+
/* @__PURE__ */ v("span", {
|
|
187
|
+
className: e(i.opacityValue, "w-10 text-end text-caption-1 text-muted-foreground"),
|
|
188
|
+
children: [De, "%"]
|
|
189
|
+
})
|
|
190
|
+
]
|
|
218
191
|
})
|
|
219
|
-
]
|
|
220
|
-
}),
|
|
221
|
-
/* @__PURE__ */ _(re, {
|
|
222
|
-
type: "text",
|
|
223
|
-
name: pe,
|
|
224
|
-
form: T,
|
|
225
|
-
value: j,
|
|
226
|
-
required: Y,
|
|
227
|
-
onInvalid: () => G.current?.focus()
|
|
192
|
+
] })
|
|
228
193
|
})
|
|
229
|
-
|
|
194
|
+
}), /* @__PURE__ */ _(oe, {
|
|
195
|
+
type: "text",
|
|
196
|
+
name: ge,
|
|
197
|
+
form: D,
|
|
198
|
+
value: N,
|
|
199
|
+
required: Fe,
|
|
200
|
+
onInvalid: Le
|
|
201
|
+
})]
|
|
230
202
|
});
|
|
231
203
|
};
|
|
232
|
-
|
|
204
|
+
b.displayName = "ColorPicker";
|
|
205
|
+
var x = /* @__PURE__ */ Object.assign(b, {
|
|
206
|
+
HexField: f,
|
|
207
|
+
Swatches: m,
|
|
208
|
+
Preview: p
|
|
209
|
+
});
|
|
233
210
|
//#endregion
|
|
234
|
-
export {
|
|
211
|
+
export { x as ColorPicker, f as ColorPickerHexField, p as ColorPickerPreview, m as ColorPickerSwatches };
|
|
235
212
|
|
|
236
213
|
//# sourceMappingURL=ColorPicker.mjs.map
|