@mortenbrudvik/waveui 0.7.0 → 0.8.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 +395 -132
- 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/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +74 -73
- 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 +47 -46
- 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 +9 -9
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +90 -85
- 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 +186 -185
- 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 +71 -68
- 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 +113 -112
- 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 +55 -54
- 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 +12 -11
- 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.mjs +110 -109
- 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 +118 -119
- 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 +25 -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 +47 -46
- 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 +76 -75
- 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 +65 -64
- 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 +161 -157
- 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 +24 -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 +202 -199
- 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/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 +110 -109
- 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 +229 -227
- package/dist/components/overlays/Popover.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 +31 -30
- 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/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 +2089 -102
- package/dist/index.d.ts +2089 -102
- package/dist/index.mjs +99 -87
- package/dist/lib/classNames.cjs +2 -0
- package/dist/lib/classNames.cjs.map +1 -0
- package/dist/lib/classNames.mjs +415 -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/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
|
@@ -1,89 +1,90 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
-
import { warnDeprecated as t, warnOnce as
|
|
4
|
-
import { materialiseSlotContent as
|
|
5
|
-
import { composeEventHandlers as
|
|
3
|
+
import { warnDeprecated as t, warnOnce as ee } from "../../lib/dev.mjs";
|
|
4
|
+
import { materialiseSlotContent as te, slotRendersContent as n } from "../../lib/slot.mjs";
|
|
5
|
+
import { composeEventHandlers as r } from "../../lib/composeEventHandlers.mjs";
|
|
6
|
+
import { checkboxClassNames as i } from "../../lib/classNames.mjs";
|
|
6
7
|
import { useControllable as ne } from "../../hooks/useControllable.mjs";
|
|
7
|
-
import { useId as
|
|
8
|
-
import { useMergedRefs as
|
|
9
|
-
import { focusableDisabledProps as
|
|
10
|
-
import { useFieldContext as
|
|
11
|
-
import { focusRing as
|
|
12
|
-
import { CheckIcon as
|
|
13
|
-
import { useFormReset as
|
|
14
|
-
import { HiddenInput as
|
|
15
|
-
import * as
|
|
16
|
-
import { jsx as
|
|
8
|
+
import { useId as a } from "../../hooks/useId.mjs";
|
|
9
|
+
import { useMergedRefs as re } from "../../hooks/useMergedRefs.mjs";
|
|
10
|
+
import { focusableDisabledProps as ie, joinIds as o } from "../../lib/aria.mjs";
|
|
11
|
+
import { useFieldContext as s, useFieldControl as c } from "../../hooks/useFieldControl.mjs";
|
|
12
|
+
import { focusRing as l, forcedColors as u } from "../../lib/styles.mjs";
|
|
13
|
+
import { CheckIcon as d, SubtractIcon as f } from "../../lib/icons.mjs";
|
|
14
|
+
import { useFormReset as ae } from "../../hooks/useFormReset.mjs";
|
|
15
|
+
import { HiddenInput as oe } from "../internal/HiddenInput.mjs";
|
|
16
|
+
import * as p from "react";
|
|
17
|
+
import { jsx as m, jsxs as se } from "react/jsx-runtime";
|
|
17
18
|
//#region src/components/input/Checkbox.tsx
|
|
18
|
-
var
|
|
19
|
+
var ce = "forced-colors:border-[Highlight] forced-colors:bg-[Highlight]", le = "forced-colors:border-[GrayText] forced-colors:bg-[Canvas]", ue = "forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none", h = ({ checked: h, defaultChecked: g = !1, indeterminate: _ = !1, onCheckedChange: de, onChange: v, disabled: y = !1, disabledFocusable: b = !1, label: x, labelPosition: S = "after", name: C, value: w, required: T, form: E, id: D, "aria-label": O, "aria-labelledby": k, "aria-describedby": A, "aria-invalid": j, "aria-required": M, "aria-errormessage": N, "aria-details": P, "aria-disabled": F, autoFocus: I, tabIndex: fe, onClick: L, onFocus: R, onBlur: z, onKeyDown: B, onKeyUp: V, controlRef: pe, className: me, children: he, ref: ge, ..._e }) => {
|
|
19
20
|
v !== void 0 && t("Checkbox", "onChange", "onCheckedChange");
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}, [
|
|
24
|
-
let [
|
|
25
|
-
|
|
26
|
-
}),
|
|
21
|
+
let H = n(he);
|
|
22
|
+
p.useEffect(() => {
|
|
23
|
+
H && ee("Checkbox:children", "Checkbox: children are not rendered. Pass the label in `label`.");
|
|
24
|
+
}, [H]);
|
|
25
|
+
let [U, W] = ne(h, g, (e) => {
|
|
26
|
+
de?.(e), v?.(e);
|
|
27
|
+
}), ve = a("checkbox"), G = a("checkbox-label"), K = s(), q = c({
|
|
27
28
|
id: D,
|
|
28
29
|
"aria-label": O,
|
|
29
30
|
"aria-labelledby": k,
|
|
30
31
|
"aria-describedby": A,
|
|
31
32
|
"aria-invalid": j,
|
|
32
33
|
"aria-required": M ?? T
|
|
33
|
-
}),
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
id:
|
|
37
|
-
className: "text-body-1 text-foreground",
|
|
38
|
-
children:
|
|
34
|
+
}), J = T ?? K?.required ?? !1, Y = n(x), ye = Y && q["aria-label"] === void 0 ? o(q["aria-labelledby"], K && q.id === K.controlId ? K.labelId : void 0, G) : q["aria-labelledby"], X = p.useRef(null), be = re(X, pe);
|
|
35
|
+
ae(X, () => W(g), E);
|
|
36
|
+
let xe = U || _, Z = y || b, Q = Z ? ue : u.selectedLeaf, $ = Y ? /* @__PURE__ */ m("span", {
|
|
37
|
+
id: G,
|
|
38
|
+
className: e(i.label, "text-body-1 text-foreground"),
|
|
39
|
+
children: te(x)
|
|
39
40
|
}) : null;
|
|
40
|
-
return /* @__PURE__ */
|
|
41
|
-
ref:
|
|
41
|
+
return /* @__PURE__ */ se("label", {
|
|
42
|
+
ref: ge,
|
|
42
43
|
"data-label-position": S,
|
|
43
|
-
className: e("relative inline-flex items-start gap-2 select-none", Z ? "cursor-not-allowed opacity-50 has-focus-visible:opacity-100" : "cursor-pointer",
|
|
44
|
-
...
|
|
44
|
+
className: e(i.root, "relative inline-flex items-start gap-2 select-none", Z ? "cursor-not-allowed opacity-50 has-focus-visible:opacity-100" : "cursor-pointer", me),
|
|
45
|
+
..._e,
|
|
45
46
|
children: [
|
|
46
47
|
S === "before" && $,
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
id:
|
|
48
|
+
/* @__PURE__ */ m("button", {
|
|
49
|
+
id: ve,
|
|
49
50
|
type: "button",
|
|
50
|
-
...
|
|
51
|
-
"aria-labelledby":
|
|
51
|
+
...q,
|
|
52
|
+
"aria-labelledby": ye,
|
|
52
53
|
"aria-errormessage": N,
|
|
53
54
|
"aria-details": P,
|
|
54
55
|
"aria-disabled": F,
|
|
55
56
|
autoFocus: I,
|
|
56
|
-
tabIndex:
|
|
57
|
+
tabIndex: fe,
|
|
57
58
|
onFocus: R,
|
|
58
59
|
onBlur: z,
|
|
59
60
|
onKeyDown: B,
|
|
60
61
|
onKeyUp: V,
|
|
61
|
-
ref:
|
|
62
|
+
ref: be,
|
|
62
63
|
role: "checkbox",
|
|
63
|
-
"aria-checked": _ ? "mixed" :
|
|
64
|
+
"aria-checked": _ ? "mixed" : U,
|
|
64
65
|
disabled: y && !b,
|
|
65
|
-
...
|
|
66
|
+
...ie(b, { reachable: !0 }),
|
|
66
67
|
onClick: b ? (e) => {
|
|
67
68
|
e.preventDefault(), e.stopPropagation();
|
|
68
|
-
} :
|
|
69
|
-
className: e("flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none", Y && "mt-px",
|
|
70
|
-
children: _ ? /* @__PURE__ */
|
|
69
|
+
} : r(L, () => W((e) => !e)),
|
|
70
|
+
className: e(i.indicator, "flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none", Y && "mt-px", l, xe ? e("border-primary bg-primary text-primary-foreground", Z ? le : ce) : e("border-stroke-accessible bg-transparent", Z ? u.disabled : u.control)),
|
|
71
|
+
children: _ ? /* @__PURE__ */ m(f, {
|
|
71
72
|
size: 12,
|
|
72
73
|
className: Q
|
|
73
|
-
}) :
|
|
74
|
+
}) : U ? /* @__PURE__ */ m(d, {
|
|
74
75
|
size: 12,
|
|
75
76
|
className: Q
|
|
76
77
|
}) : null
|
|
77
78
|
}),
|
|
78
79
|
S !== "before" && $,
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
+
/* @__PURE__ */ m(oe, {
|
|
80
81
|
type: "checkbox",
|
|
81
82
|
name: C,
|
|
82
83
|
form: E,
|
|
83
84
|
disabled: Z,
|
|
84
85
|
value: w,
|
|
85
|
-
checked:
|
|
86
|
-
required:
|
|
86
|
+
checked: U,
|
|
87
|
+
required: J,
|
|
87
88
|
onInvalid: () => X.current?.focus()
|
|
88
89
|
})
|
|
89
90
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.mjs","names":["useId","useId$1","React","checkedBox","disabledCheckedBox","disabledGlyph","Checkbox","checkedProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","ariaDisabled","rest","onChange","warnDeprecated","hasChildren","slotRendersContent","children","warnOnce","checked","setChecked","useControllable","defaultChecked","onCheckedChange","next","generatedId","labelTextId","field","useFieldContext","fieldProps","useFieldControl","required","isRequired","hasLabel","label","labelledBy","joinIds","buttonRef","mergedControlRef","useMergedRefs","controlRef","form","on","indeterminate","unavailable","disabled","disabledFocusable","glyphClassName","forcedColors","labelText","materialiseSlotContent","labelPosition","cn","className","focusableDisabledProps","event","composeEventHandlers","onClick","prev","focusRing","SubtractIcon","CheckIcon","HiddenInput"],"sources":["../../../src/components/input/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { focusableDisabledProps, joinIds } from '../../lib/aria';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { CheckIcon, SubtractIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { LabelPosition } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { 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';\n\n/*\n * Forced colors: the focusable box keeps system-color utilities, so the browser still forces its\n * focus outline and border; only the glyph (the leaf indicator) opts out of forced colors. A\n * disabled box draws a GrayText glyph and border on Canvas, without the Highlight fill.\n */\nconst checkedBox = 'forced-colors:border-[Highlight] forced-colors:bg-[Highlight]';\nconst disabledCheckedBox = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\nconst disabledGlyph = 'forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none';\n\n/** Handlers that run on the `role=\"checkbox\"` button instead of the root label (C-ROUTING). */\ntype CheckboxControlHandlers = 'onClick' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp';\n\n/** Where a Checkbox renders its label: after the box (default) or before it. */\nexport type CheckboxLabelPosition = Extract<LabelPosition, 'before' | 'after'>;\n\n/** Properties for the Checkbox component. */\nexport interface CheckboxProps extends Omit<\n React.HTMLAttributes<HTMLLabelElement>,\n 'onChange' | 'defaultChecked' | CheckboxControlHandlers\n> {\n /** Controlled checked state. */\n checked?: boolean;\n /** Initial checked state for uncontrolled usage (also the value a form reset restores).\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * Shows the mixed state: the dash glyph and `aria-checked=\"mixed\"`, whatever `checked` is. A\n * click still toggles `checked` and calls `onCheckedChange`, but the checkbox keeps showing and\n * announcing \"mixed\" until you clear `indeterminate`. For a tri-state \"select all\", derive\n * `checked` and `indeterminate` from the items and set every item in `onCheckedChange`.\n * @default false\n */\n indeterminate?: boolean;\n /** Called with the new checked state when it changes (not for no-op updates). */\n onCheckedChange?: (checked: boolean) => void;\n /**\n * Called with the new checked state when it changes.\n * @deprecated Use `onCheckedChange`.\n */\n onChange?: (checked: boolean) => void;\n /** Whether the checkbox is disabled and non-interactive. */\n disabled?: boolean;\n /**\n * Marks the checkbox unavailable but keeps it focusable and in the tab order: for a disabled\n * checkbox that needs a Tooltip, or one in a toolbar. Renders `aria-disabled=\"true\"`,\n * `data-disabled` and `data-disabled-focusable` on the checkbox instead of the native `disabled`\n * attribute. The checkbox cannot be toggled and is not submitted with its form; your `onClick`\n * is not called, and a click on the checkbox (or Space and Enter) does not reach ancestor click\n * handlers, as for a natively disabled control. Wins over `disabled` when both are set. In a\n * roving container (a `Toolbar`) it stays in the arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n /**\n * Label next to the control (any phrasing content, links included, but no other form\n * controls). It names the control through `aria-labelledby`, after a consumer or Field\n * `aria-labelledby`; a consumer `aria-label` names it instead. Clicking its text toggles the\n * control; clicking a link inside it follows the link. `children` are not rendered: pass the\n * label here.\n */\n label?: React.ReactNode;\n /**\n * Where the label renders: after the control (default) or before it. The DOM order follows the\n * visual order.\n * @default 'after'\n */\n labelPosition?: CheckboxLabelPosition;\n /**\n * Form field name. With a name, the checkbox takes part in native form submission: it submits\n * `name=value` while checked.\n */\n name?: string;\n /** Value submitted while checked.\n * @default 'on'\n */\n value?: string;\n /** The form must not be submitted while the checkbox is unchecked (native validation). */\n required?: boolean;\n /** Id of the form the checkbox belongs to, when it is rendered outside that form. */\n form?: string;\n /** Click handler of the checkbox control (the `role=\"checkbox\"` button). */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n /** Focus handler of the checkbox control. */\n onFocus?: React.FocusEventHandler<HTMLButtonElement>;\n /** Blur handler of the checkbox control. */\n onBlur?: React.FocusEventHandler<HTMLButtonElement>;\n /** Keydown handler of the checkbox control. */\n onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Keyup handler of the checkbox control. */\n onKeyUp?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Ref to the focusable `role=\"checkbox\"` button. */\n controlRef?: React.Ref<HTMLButtonElement>;\n /** Ref to the root `<label>` element. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\n/**\n * A checkbox for a boolean (or mixed) choice, drawn as a `role=\"checkbox\"` button inside a\n * `<label>`.\n *\n * - The root `<label>` receives `ref`, `className`, `style` and `data-*`; the control receives\n * `id`, `aria-label`/`-labelledby`/`-describedby`/`-invalid`/`-required`/`-errormessage`/\n * `-details`/`-disabled`, `tabIndex`, `autoFocus` and the click, focus and key handlers\n * (`controlRef` exposes it). A consumer `onClick` runs once per activation, before the toggle;\n * `preventDefault()` in it cancels the toggle.\n * - Inside a `Field` it is named by the Field label (followed by its own `label` text) and described\n * by the Field message and hint.\n * - With `name` (or `required`) it takes part in native forms like `<input type=\"checkbox\">`, and\n * a form reset restores `defaultChecked`.\n * - `label` takes rich content (a link to the terms) and renders after the box, or before it with\n * `labelPosition=\"before\"` (the root carries `data-label-position`). The box lines up with the\n * first line of a label that wraps or has a second line. `children` are not rendered (a\n * development warning says so).\n */\nexport const Checkbox = ({\n checked: checkedProp,\n defaultChecked = false,\n indeterminate = false,\n onCheckedChange,\n onChange,\n disabled = false,\n disabledFocusable = false,\n label,\n labelPosition = 'after',\n name,\n value,\n required,\n form,\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 'aria-details': ariaDetails,\n 'aria-disabled': ariaDisabled,\n autoFocus,\n tabIndex,\n onClick,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n children,\n ref,\n ...rest\n}: CheckboxProps) => {\n if (onChange !== undefined) warnDeprecated('Checkbox', 'onChange', 'onCheckedChange');\n const hasChildren = slotRendersContent(children);\n React.useEffect(() => {\n if (hasChildren) {\n warnOnce(\n 'Checkbox:children',\n 'Checkbox: children are not rendered. Pass the label in `label`.',\n );\n }\n }, [hasChildren]);\n const [checked, setChecked] = useControllable(checkedProp, defaultChecked, (next: boolean) => {\n onCheckedChange?.(next);\n onChange?.(next);\n });\n\n const generatedId = useId('checkbox');\n const labelTextId = useId('checkbox-label');\n const field = useFieldContext();\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required always matches\n // the native validation below (`isRequired`).\n 'aria-required': ariaRequired ?? required,\n });\n const isRequired = required ?? field?.required ?? false;\n // `0` is a label; `null`, `false`, `''` and empty collections are not (C-SLOTS).\n const hasLabel = slotRendersContent(label);\n // The label text names the control through aria-labelledby, disabled or not: axe exempts the\n // dimmed text of a disabled control only when the control references it this way (its <label>\n // exemption covers native inputs only). A consumer aria-label still names the control alone.\n // The ids already there (the consumer's, the Field label from useFieldControl) come first, then\n // the Field label whose <label htmlFor> targets this control (aria-labelledby would hide it), so\n // the name keeps every label.\n const labelledBy =\n hasLabel && fieldProps['aria-label'] === undefined\n ? joinIds(\n fieldProps['aria-labelledby'],\n field && fieldProps.id === field.controlId ? field.labelId : undefined,\n labelTextId,\n )\n : fieldProps['aria-labelledby'];\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const mergedControlRef = useMergedRefs(buttonRef, controlRef);\n useFormReset(buttonRef, () => setChecked(defaultChecked), form);\n\n const on = checked || indeterminate;\n // Focusable-disabled wins over `disabled`: the box stays focusable but looks and acts disabled.\n const unavailable = disabled || disabledFocusable;\n // The glyph is the forced-colors leaf; the box stays on system colors (see `checkedBox`).\n const glyphClassName = unavailable ? disabledGlyph : forcedColors.selectedLeaf;\n const labelText = hasLabel ? (\n <span id={labelTextId} className=\"text-body-1 text-foreground\">\n {materialiseSlotContent(label)}\n </span>\n ) : null;\n\n return (\n <label\n ref={ref}\n data-label-position={labelPosition}\n className={cn(\n // items-start: the box lines up with the first line of a label that wraps or has a second\n // line, not with its middle.\n 'relative inline-flex items-start gap-2 select-none',\n // The dimmed look lifts while a focus ring shows inside the root (the control's, under\n // disabledFocusable, or a link's in the label): opacity would dim the ring below 3:1.\n unavailable\n ? 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100'\n : 'cursor-pointer',\n className,\n )}\n {...rest}\n >\n {labelPosition === 'before' && labelText}\n <button\n id={generatedId}\n type=\"button\"\n {...fieldProps}\n aria-labelledby={labelledBy}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n aria-disabled={ariaDisabled}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n ref={mergedControlRef}\n role=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : checked}\n disabled={disabled && !disabledFocusable}\n {...focusableDisabledProps(disabledFocusable, { reachable: true })}\n onClick={\n disabledFocusable\n ? // Clicks, Space and Enter (which click a button) neither toggle nor reach `onClick`,\n // and, as a natively disabled control dispatches no click, no ancestor sees them.\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n }\n : composeEventHandlers(onClick, () => setChecked((prev) => !prev))\n }\n className={cn(\n // p-0 and the unchecked bg-transparent are set here, not left to the native reset, which\n // any app button style overrides (C-NATIVE).\n 'flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none',\n // Centred on the 20px first line of the label text.\n hasLabel && 'mt-px',\n focusRing,\n on\n ? cn(\n 'border-primary bg-primary text-primary-foreground',\n unavailable ? disabledCheckedBox : checkedBox,\n )\n : cn(\n 'border-stroke-accessible bg-transparent',\n unavailable ? forcedColors.disabled : forcedColors.control,\n ),\n )}\n >\n {indeterminate ? (\n <SubtractIcon size={12} className={glyphClassName} />\n ) : checked ? (\n <CheckIcon size={12} className={glyphClassName} />\n ) : null}\n </button>\n {labelPosition !== 'before' && labelText}\n <HiddenInput\n type=\"checkbox\"\n name={name}\n form={form}\n disabled={unavailable}\n value={value}\n checked={checked}\n required={isRequired}\n onInvalid={() => buttonRef.current?.focus()}\n />\n </label>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,IAAMG,IAAa,iEACbC,IAAqB,6DACrBC,KAAgB,wEA4GTC,KAAY,EACvB,SAASC,GACT,oBAAiB,IACjB,mBAAgB,IAChB,qBACA,aACA,cAAW,IACX,uBAAoB,IACpB,UACA,mBAAgB,SAChB,SACA,UACA,aACA,SACA,OACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC,GACpB,gBAAgBC,GAChB,iBAAiBC,GACjB,qBAAqBC,GACrB,gBAAgBC,GAChB,iBAAiBC,GACjB,cACA,cACA,YACA,YACA,WACA,cACA,YACA,eACA,eACA,cACA,SACA,GAAGC,SACgB;CACnB,AAAIC,MAAa,KAAA,KAAWC,EAAe,YAAY,YAAY,iBAAiB;CACpF,IAAMC,IAAcC,EAAmBC,EAAQ;CAC/C,EAAM,gBAAgB;EACpB,AAAIF,KACFG,EACE,qBACA,iEACF;CAEJ,GAAG,CAACH,CAAW,CAAC;CAChB,IAAM,CAACI,GAASC,KAAcC,GAAgBlB,GAAamB,IAAiB,MAAkB;EAE5F,AADAC,KAAkBC,CAAI,GACtBX,IAAWW,CAAI;CACjB,CAAC,GAEKC,KAAc7B,EAAM,UAAU,GAC9B8B,IAAc9B,EAAM,gBAAgB,GACpC+B,IAAQC,GAAgB,GACxBC,IAAaC,GAAgB;EACjC;EACA,cAAc1B;EACd,mBAAmBC;EACnB,oBAAoBC;EACpB,gBAAgBC;EAGhB,iBAAiBC,KAAgBuB;CACnC,CAAC,GACKC,KAAaD,KAAYJ,GAAO,YAAY,IAE5CM,IAAWjB,EAAmBkB,CAAK,GAOnCC,KACJF,KAAYJ,EAAW,kBAAkB,K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AC0C,GAAD;KAAW,MAAM;KAAI,WAAWd;IAAiB,CAAA,IAC/C;GACE,CAAA;GACPI,MAAkB,YAAYF;GAC/B,kBAACa,IAAD;IACE,MAAK;IACC;IACA;IACN,UAAUlB;IACH;IACE;IACT,UAAUZ;IACV,iBAAiBK,EAAU,SAAS,MAAM;GAC3C,CAAA;EACI;;AAEX;AAEA,EAAS,cAAc"}
|
|
1
|
+
{"version":3,"file":"Checkbox.mjs","names":["useId","useId$1","React","checkedBox","disabledCheckedBox","disabledGlyph","Checkbox","checkedProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","ariaDisabled","rest","onChange","warnDeprecated","hasChildren","slotRendersContent","children","warnOnce","checked","setChecked","useControllable","defaultChecked","onCheckedChange","next","generatedId","labelTextId","field","useFieldContext","fieldProps","useFieldControl","required","isRequired","hasLabel","label","labelledBy","joinIds","buttonRef","mergedControlRef","useMergedRefs","controlRef","form","on","indeterminate","unavailable","disabled","disabledFocusable","glyphClassName","forcedColors","labelText","cn","checkboxClassNames","materialiseSlotContent","labelPosition","className","focusableDisabledProps","event","composeEventHandlers","onClick","prev","focusRing","SubtractIcon","CheckIcon","HiddenInput"],"sources":["../../../src/components/input/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { focusableDisabledProps, joinIds } from '../../lib/aria';\nimport { checkboxClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { CheckIcon, SubtractIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { LabelPosition } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { 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';\n\n/*\n * Forced colors: the focusable box keeps system-color utilities, so the browser still forces its\n * focus outline and border; only the glyph (the leaf indicator) opts out of forced colors. A\n * disabled box draws a GrayText glyph and border on Canvas, without the Highlight fill.\n */\nconst checkedBox = 'forced-colors:border-[Highlight] forced-colors:bg-[Highlight]';\nconst disabledCheckedBox = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\nconst disabledGlyph = 'forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none';\n\n/** Handlers that run on the `role=\"checkbox\"` button instead of the root label (C-ROUTING). */\ntype CheckboxControlHandlers = 'onClick' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp';\n\n/** Where a Checkbox renders its label: after the box (default) or before it. */\nexport type CheckboxLabelPosition = Extract<LabelPosition, 'before' | 'after'>;\n\n/** Properties for the Checkbox component. */\nexport interface CheckboxProps extends Omit<\n React.HTMLAttributes<HTMLLabelElement>,\n 'onChange' | 'defaultChecked' | CheckboxControlHandlers\n> {\n /** Controlled checked state. */\n checked?: boolean;\n /** Initial checked state for uncontrolled usage (also the value a form reset restores).\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * Shows the mixed state: the dash glyph and `aria-checked=\"mixed\"`, whatever `checked` is. A\n * click still toggles `checked` and calls `onCheckedChange`, but the checkbox keeps showing and\n * announcing \"mixed\" until you clear `indeterminate`. For a tri-state \"select all\", derive\n * `checked` and `indeterminate` from the items and set every item in `onCheckedChange`.\n * @default false\n */\n indeterminate?: boolean;\n /** Called with the new checked state when it changes (not for no-op updates). */\n onCheckedChange?: (checked: boolean) => void;\n /**\n * Called with the new checked state when it changes.\n * @deprecated Use `onCheckedChange`.\n */\n onChange?: (checked: boolean) => void;\n /** Whether the checkbox is disabled and non-interactive. */\n disabled?: boolean;\n /**\n * Marks the checkbox unavailable but keeps it focusable and in the tab order: for a disabled\n * checkbox that needs a Tooltip, or one in a toolbar. Renders `aria-disabled=\"true\"`,\n * `data-disabled` and `data-disabled-focusable` on the checkbox instead of the native `disabled`\n * attribute. The checkbox cannot be toggled and is not submitted with its form; your `onClick`\n * is not called, and a click on the checkbox (or Space and Enter) does not reach ancestor click\n * handlers, as for a natively disabled control. Wins over `disabled` when both are set. In a\n * roving container (a `Toolbar`) it stays in the arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n /**\n * Label next to the control (any phrasing content, links included, but no other form\n * controls). It names the control through `aria-labelledby`, after a consumer or Field\n * `aria-labelledby`; a consumer `aria-label` names it instead. Clicking its text toggles the\n * control; clicking a link inside it follows the link. `children` are not rendered: pass the\n * label here.\n */\n label?: React.ReactNode;\n /**\n * Where the label renders: after the control (default) or before it. The DOM order follows the\n * visual order.\n * @default 'after'\n */\n labelPosition?: CheckboxLabelPosition;\n /**\n * Form field name. With a name, the checkbox takes part in native form submission: it submits\n * `name=value` while checked.\n */\n name?: string;\n /** Value submitted while checked.\n * @default 'on'\n */\n value?: string;\n /** The form must not be submitted while the checkbox is unchecked (native validation). */\n required?: boolean;\n /** Id of the form the checkbox belongs to, when it is rendered outside that form. */\n form?: string;\n /** Click handler of the checkbox control (the `role=\"checkbox\"` button). */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n /** Focus handler of the checkbox control. */\n onFocus?: React.FocusEventHandler<HTMLButtonElement>;\n /** Blur handler of the checkbox control. */\n onBlur?: React.FocusEventHandler<HTMLButtonElement>;\n /** Keydown handler of the checkbox control. */\n onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Keyup handler of the checkbox control. */\n onKeyUp?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Ref to the focusable `role=\"checkbox\"` button. */\n controlRef?: React.Ref<HTMLButtonElement>;\n /** Ref to the root `<label>` element. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\n/**\n * A checkbox for a boolean (or mixed) choice, drawn as a `role=\"checkbox\"` button inside a\n * `<label>`.\n *\n * - The root `<label>` receives `ref`, `className`, `style` and `data-*`; the control receives\n * `id`, `aria-label`/`-labelledby`/`-describedby`/`-invalid`/`-required`/`-errormessage`/\n * `-details`/`-disabled`, `tabIndex`, `autoFocus` and the click, focus and key handlers\n * (`controlRef` exposes it). A consumer `onClick` runs once per activation, before the toggle;\n * `preventDefault()` in it cancels the toggle.\n * - Inside a `Field` it is named by the Field label (followed by its own `label` text) and described\n * by the Field message and hint.\n * - With `name` (or `required`) it takes part in native forms like `<input type=\"checkbox\">`, and\n * a form reset restores `defaultChecked`.\n * - `label` takes rich content (a link to the terms) and renders after the box, or before it with\n * `labelPosition=\"before\"` (the root carries `data-label-position`). The box lines up with the\n * first line of a label that wraps or has a second line. `children` are not rendered (a\n * development warning says so).\n */\nexport const Checkbox = ({\n checked: checkedProp,\n defaultChecked = false,\n indeterminate = false,\n onCheckedChange,\n onChange,\n disabled = false,\n disabledFocusable = false,\n label,\n labelPosition = 'after',\n name,\n value,\n required,\n form,\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 'aria-details': ariaDetails,\n 'aria-disabled': ariaDisabled,\n autoFocus,\n tabIndex,\n onClick,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n children,\n ref,\n ...rest\n}: CheckboxProps) => {\n if (onChange !== undefined) warnDeprecated('Checkbox', 'onChange', 'onCheckedChange');\n const hasChildren = slotRendersContent(children);\n React.useEffect(() => {\n if (hasChildren) {\n warnOnce(\n 'Checkbox:children',\n 'Checkbox: children are not rendered. Pass the label in `label`.',\n );\n }\n }, [hasChildren]);\n const [checked, setChecked] = useControllable(checkedProp, defaultChecked, (next: boolean) => {\n onCheckedChange?.(next);\n onChange?.(next);\n });\n\n const generatedId = useId('checkbox');\n const labelTextId = useId('checkbox-label');\n const field = useFieldContext();\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required always matches\n // the native validation below (`isRequired`).\n 'aria-required': ariaRequired ?? required,\n });\n const isRequired = required ?? field?.required ?? false;\n // `0` is a label; `null`, `false`, `''` and empty collections are not (C-SLOTS).\n const hasLabel = slotRendersContent(label);\n // The label text names the control through aria-labelledby, disabled or not: axe exempts the\n // dimmed text of a disabled control only when the control references it this way (its <label>\n // exemption covers native inputs only). A consumer aria-label still names the control alone.\n // The ids already there (the consumer's, the Field label from useFieldControl) come first, then\n // the Field label whose <label htmlFor> targets this control (aria-labelledby would hide it), so\n // the name keeps every label.\n const labelledBy =\n hasLabel && fieldProps['aria-label'] === undefined\n ? joinIds(\n fieldProps['aria-labelledby'],\n field && fieldProps.id === field.controlId ? field.labelId : undefined,\n labelTextId,\n )\n : fieldProps['aria-labelledby'];\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const mergedControlRef = useMergedRefs(buttonRef, controlRef);\n useFormReset(buttonRef, () => setChecked(defaultChecked), form);\n\n const on = checked || indeterminate;\n // Focusable-disabled wins over `disabled`: the box stays focusable but looks and acts disabled.\n const unavailable = disabled || disabledFocusable;\n // The glyph is the forced-colors leaf; the box stays on system colors (see `checkedBox`).\n const glyphClassName = unavailable ? disabledGlyph : forcedColors.selectedLeaf;\n const labelText = hasLabel ? (\n <span id={labelTextId} className={cn(checkboxClassNames.label, 'text-body-1 text-foreground')}>\n {materialiseSlotContent(label)}\n </span>\n ) : null;\n\n return (\n <label\n ref={ref}\n data-label-position={labelPosition}\n className={cn(\n checkboxClassNames.root,\n // items-start: the box lines up with the first line of a label that wraps or has a second\n // line, not with its middle.\n 'relative inline-flex items-start gap-2 select-none',\n // The dimmed look lifts while a focus ring shows inside the root (the control's, under\n // disabledFocusable, or a link's in the label): opacity would dim the ring below 3:1.\n unavailable\n ? 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100'\n : 'cursor-pointer',\n className,\n )}\n {...rest}\n >\n {labelPosition === 'before' && labelText}\n <button\n id={generatedId}\n type=\"button\"\n {...fieldProps}\n aria-labelledby={labelledBy}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n aria-disabled={ariaDisabled}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n ref={mergedControlRef}\n role=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : checked}\n disabled={disabled && !disabledFocusable}\n {...focusableDisabledProps(disabledFocusable, { reachable: true })}\n onClick={\n disabledFocusable\n ? // Clicks, Space and Enter (which click a button) neither toggle nor reach `onClick`,\n // and, as a natively disabled control dispatches no click, no ancestor sees them.\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n }\n : composeEventHandlers(onClick, () => setChecked((prev) => !prev))\n }\n className={cn(\n checkboxClassNames.indicator,\n // p-0 and the unchecked bg-transparent are set here, not left to the native reset, which\n // any app button style overrides (C-NATIVE).\n 'flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none',\n // Centred on the 20px first line of the label text.\n hasLabel && 'mt-px',\n focusRing,\n on\n ? cn(\n 'border-primary bg-primary text-primary-foreground',\n unavailable ? disabledCheckedBox : checkedBox,\n )\n : cn(\n 'border-stroke-accessible bg-transparent',\n unavailable ? forcedColors.disabled : forcedColors.control,\n ),\n )}\n >\n {indeterminate ? (\n <SubtractIcon size={12} className={glyphClassName} />\n ) : checked ? (\n <CheckIcon size={12} className={glyphClassName} />\n ) : null}\n </button>\n {labelPosition !== 'before' && labelText}\n <HiddenInput\n type=\"checkbox\"\n name={name}\n form={form}\n disabled={unavailable}\n value={value}\n checked={checked}\n required={isRequired}\n onInvalid={() => buttonRef.current?.focus()}\n />\n </label>\n );\n};\n\nC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;IACC;IACA;IACN,UAAUnB;IACH;IACE;IACT,UAAUZ;IACV,iBAAiBK,EAAU,SAAS,MAAM;GAC3C,CAAA;EACI;;AAEX;AAEA,EAAS,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/composeEventHandlers.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../lib/color.cjs"),a=require("../../hooks/useEventCallback.cjs"),o=require("../../lib/direction.cjs"),s=require("../../hooks/useMergedRefs.cjs"),c=require("../../hooks/useFieldControl.cjs"),ee=require("../../hooks/useMediaQuery.cjs"),l=require("../../hooks/useFormReset.cjs"),u=require("../internal/HiddenInput.cjs"),d=require("./colorUtils.cjs"),f=require("./ColorPicker.parts.cjs"),p=require("../../lib/events.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var te={saturation:`Saturation`,brightness:`Brightness`,roleDescription:`2D slider`};function g(e){return Math.min(100,Math.max(0,e))}var _=`(pointer: coarse)`,v=({value:e,defaultValue:v,onValueChange:y,shape:b,labels:x,disabled:S=!1,name:C,form:w,required:ne,controlRef:re,className:ie,style:ae,id:oe,"aria-label":se,"aria-labelledby":T,"aria-describedby":ce,"aria-invalid":le,"aria-required":E,"aria-errormessage":ue,autoFocus:de,tabIndex:fe,onKeyDown:D,onPointerDown:O,onPointerMove:k,ref:A,...j})=>{let M=f.useColorPartState({value:e,defaultValue:v,onValueChange:y,disabled:S}),{picker:N}=M,P={...te,...N&&{saturation:N.labels.saturation,brightness:N.labels.brightness,roleDescription:N.labels.roleDescription,colorName:N.labels.colorName,valueText:N.labels.valueText},...x},F=b??N?.shape??`rounded`,I=M.color,L=d.displayColor(I),R=d.toPercent(L.s),z=d.toPercent(L.v),[B,V]=m.useState(`saturation`),pe=ee.useMediaQuery(_),H=m.useRef(null),[U,me]=m.useState(0),W=m.useRef(null),G=m.useRef(null),K=m.useRef(null),he=s.useMergedRefs(A,W),ge=s.useMergedRefs(G,re),q=m.useRef(0);m.useLayoutEffect(()=>{q.current!==U&&(q.current=U,(B===`saturation`?G:K).current?.focus({preventScroll:!0}))},[B,U]);let _e=c.useFieldContext(),{"aria-invalid":J,"aria-required":ve,required:ye,...be}=c.useFieldControl({id:oe,"aria-label":se??(N&&T===void 0?N.labels.area:void 0),"aria-labelledby":T,"aria-describedby":ce,"aria-invalid":le},{labelable:!1}),xe=J!==void 0&&J!==!1&&J!==`false`&&ue||void 0,Se=ne??(E===!0||E===`true`||(_e?.required??!1));l.useFormReset(W,M.reset,w);let Y=(e,t)=>{t!==(e===`saturation`?R:z)&&M.setColor(e===`saturation`?{...I,s:t/100}:{...I,v:t/100})},Ce=n.composeEventHandlers(D,e=>{if(M.disabled||!p.isOwnEvent(e)||e.nativeEvent.isComposing||e.altKey||e.ctrlKey||e.metaKey)return;let t=e.shiftKey?10:1,n,r;switch(e.key){case`ArrowLeft`:case`ArrowRight`:{let i=o.getArrowIntent(e.key,{orientation:`horizontal`,dir:o.getDirection(e.currentTarget)});n=`saturation`,r=R+(i===`next`?t:-t);break}case`ArrowUp`:n=`value`,r=z+t;break;case`ArrowDown`:n=`value`,r=z-t;break;case`PageUp`:n=`value`,r=z+10;break;case`PageDown`:n=`value`,r=z-10;break;case`Home`:n=`saturation`,r=0;break;case`End`:n=`saturation`,r=100;break;default:return}e.preventDefault(),n!==B&&V(n),me(e=>e+1),Y(n,g(r))}),X=e=>t=>{M.disabled||(e!==B&&V(e),Y(e,g(Math.round(Number(t.currentTarget.value)))))},we=e=>()=>{e!==B&&V(e)},Z=a.useEventCallback(e=>{let t=H.current;if(!t)return;let n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return;let r=Math.min(1,Math.max(0,(e.clientX-n.left)/n.width)),i=o.getDirection(e.currentTarget)===`rtl`?1-r:r,a=Math.min(1,Math.max(0,1-(e.clientY-n.top)/n.height));(i!==L.s||a!==L.v)&&M.setColor({...I,s:i,v:a})}),Te=a.useEventCallback(()=>{(B===`saturation`?G:K).current?.focus({preventScroll:!0,focusVisible:!1})}),Ee=n.composeEventHandlers(O,e=>{!M.disabled&&e.button===0&&e.isPrimary&&p.isOwnEvent(e)&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),Z(e),Te())}),De=n.composeEventHandlers(k,e=>{!M.disabled&&e.currentTarget.hasPointerCapture(e.pointerId)&&Z(e)}),Q={saturation:P.saturation,brightness:P.brightness,colorName:P.colorName,valueText:P.valueText},Oe={...ae,"--wave-color-area-gradient":d.colorAreaGradient(L.h),"--wave-color-area-x":d.toPosition(L.s),"--wave-color-area-y":d.toPosition(L.v),"--wave-color-thumb":i.hsvToHex({h:L.h,s:L.s,v:L.v})},$=e=>({type:`range`,min:0,max:100,step:1,disabled:M.disabled,"aria-roledescription":P.roleDescription,"aria-invalid":J,"aria-errormessage":xe,tabIndex:e===B?fe??0:-1,"aria-hidden":e!==B&&!pe||void 0,onChange:X(e),onFocus:we(e),className:`sr-only`});return(0,h.jsxs)(`div`,{role:`group`,"data-disabled":M.disabled?``:void 0,...be,className:t.cn(r.colorAreaClassNames.root,`group/color-area relative h-40 w-full min-w-40 touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,F===`square`?`rounded-none`:`rounded`,ie),style:Oe,...j,ref:he,onKeyDown:Ce,onPointerDown:Ee,onPointerMove:De,children:[(0,h.jsx)(`div`,{ref:H,"aria-hidden":`true`,className:t.cn(r.colorAreaClassNames.field,`absolute inset-0 rounded-[inherit] bg-(image:--wave-color-area-gradient) wave-rtl:-scale-x-100 forced-colors:forced-color-adjust-none`)}),(0,h.jsx)(`span`,{"aria-hidden":`true`,className:t.cn(r.colorAreaClassNames.thumb,d.COLOR_THUMB_CLASSES,`start-(--wave-color-area-x) bottom-(--wave-color-area-y) -translate-x-1/2 wave-rtl:translate-x-1/2 translate-y-1/2`,`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]`)}),(0,h.jsx)(`input`,{...$(`saturation`),ref:ge,value:R,"aria-label":P.saturation,"aria-valuetext":d.areaValueText(L,`saturation`,Q),autoFocus:de}),(0,h.jsx)(`input`,{...$(`value`),ref:K,value:z,"aria-label":P.brightness,"aria-orientation":`vertical`,"aria-valuetext":d.areaValueText(L,`value`,Q)}),!N&&(0,h.jsx)(u.HiddenInput,{type:`text`,name:C,form:w,disabled:M.disabled,value:i.hsvToHex(I),required:Se,onInvalid:()=>(B===`saturation`?G:K).current?.focus()})]})};v.displayName=`ColorArea`,exports.ColorArea=v;
|
|
2
|
+
//# sourceMappingURL=ColorArea.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorArea.cjs","names":["useColorPartState","displayColor","toPercent","React","useMediaQuery","useMergedRefs","useFieldContext","useFieldControl","composeEventHandlers","isOwnEvent","getArrowIntent","getDirection","useEventCallback","colorAreaGradient","toPosition","hsvToHex","cn","colorAreaClassNames","COLOR_THUMB_CLASSES","areaValueText","HiddenInput","require_runtime","require_cn","require_composeEventHandlers","require_classNames","require_color","require_useEventCallback","require_direction","require_useMergedRefs","require_useFieldControl","require_useMediaQuery","require_useFormReset","require_HiddenInput","require_colorUtils","require_ColorPicker_parts","require_events","react","react_jsx_runtime","DEFAULT_LABELS","clampPercent","value","COARSE_POINTER","ColorArea","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","rest","part","strings","picker","labels","resolvedShape","shape","color","shown","saturation","brightness","activeAxis","setActiveAxis","coarsePointer","fieldRef","focusToken","setFocusToken","rootRef","saturationRef","brightnessRef","mergedRootRef","ref","mergedSaturationRef","controlRef","handledFocusTokenRef","field","invalid","_ariaRequired","_required","groupProps","errorMessageId","isRequired","required","form","applyAxis","percent","axis","handleKeyDown","onKeyDown","event","step","next","intent","token","handleInputChange","handleInputFocus","moveToPointer","fieldElement","rect","x","s","v","focusActiveAxis","handlePointerDown","onPointerDown","handlePointerMove","onPointerMove","textLabels","areaStyle","style","inputProps","tabIndex","className"],"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":"orBAkGA,IAAMsC,GAAiB,CACrB,WAAY,aACZ,WAAY,aACZ,gBAAiB,WACnB,EAGA,SAASC,EAAa,EAAuB,CAC3C,OAAO,KAAK,IAAI,IAAK,KAAK,IAAI,EAAGC,CAAK,CAAC,CACzC,CAGA,IAAMC,EAAiB,oBAiBVC,GAAa,CACxB,QACA,eACA,gBACA,QACA,SACA,WAAW,GACX,OACA,OACA,YACA,cACA,aACA,SACA,MACA,aAAcC,GACd,kBAAmBC,EACnB,mBAAoBC,GACpB,eAAgBC,GAChB,gBAAiBC,EACjB,oBAAqBC,GACrB,aACA,YACA,YACA,gBACA,gBACA,MACA,GAAGC,KACiB,CACpB,IAAMC,EAAOlD,EAAAA,kBAAkB,CAAE,QAAO,eAAc,gBAAe,UAAS,CAAC,EACzE,CAAE,UAAWkD,EACbC,EAAU,CACd,GAAGb,GACH,GAAIc,GAAU,CACZ,WAAYA,EAAO,OAAO,WAC1B,WAAYA,EAAO,OAAO,WAC1B,gBAAiBA,EAAO,OAAO,gBAC/B,UAA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ACD,CAAA,GACD,EAAAmB,EAAA,IAAA,CAAC,QAAD,CACE,GAAIwE,EAAW,YAAY,EAC3B,IAAKtC,GACL,MAAOb,EACP,aAAYP,EAAQ,WACpB,iBAAgBhC,EAAAA,cAAcsC,EAAO,aAAciD,CAAU,EAClD,YACZ,CAAA,GACD,EAAArE,EAAA,IAAA,CAAC,QAAD,CACE,GAAIwE,EAAW,OAAO,EACtB,IAAKzC,EACL,MAAOT,EACP,aAAYR,EAAQ,WACpB,mBAAiB,WACjB,iBAAgBhC,EAAAA,cAAcsC,EAAO,QAASiD,CAAU,CACzD,CAAA,EACA,CAACtD,IACA,EAAAf,EAAA,IAAA,CAACjB,EAAAA,YAAD,CACE,KAAK,OACC,OACA,OACN,SAAU8B,EAAK,SACf,MAAOnC,EAAAA,SAASyC,CAAK,EACrB,SAAUwB,GACV,eACGpB,IAAe,aAAeO,EAAgBC,EAAA,CAAe,SAAS,MAAM,CAEhF,CAAA,CAEA,GAET,EAEA,EAAU,YAAc"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { composeEventHandlers as t } from "../../lib/composeEventHandlers.mjs";
|
|
4
|
+
import { colorAreaClassNames as n } from "../../lib/classNames.mjs";
|
|
5
|
+
import { hsvToHex as r } from "../../lib/color.mjs";
|
|
6
|
+
import { useEventCallback as i } from "../../hooks/useEventCallback.mjs";
|
|
7
|
+
import { getArrowIntent as a, getDirection as o } from "../../lib/direction.mjs";
|
|
8
|
+
import { useMergedRefs as s } from "../../hooks/useMergedRefs.mjs";
|
|
9
|
+
import { useFieldContext as ee, useFieldControl as c } from "../../hooks/useFieldControl.mjs";
|
|
10
|
+
import { useMediaQuery as l } from "../../hooks/useMediaQuery.mjs";
|
|
11
|
+
import { useFormReset as u } from "../../hooks/useFormReset.mjs";
|
|
12
|
+
import { HiddenInput as te } from "../internal/HiddenInput.mjs";
|
|
13
|
+
import { COLOR_THUMB_CLASSES as ne, areaValueText as d, colorAreaGradient as re, displayColor as ie, toPercent as f, toPosition as p } from "./colorUtils.mjs";
|
|
14
|
+
import { useColorPartState as m } from "./ColorPicker.parts.mjs";
|
|
15
|
+
import { isOwnEvent as h } from "../../lib/events.mjs";
|
|
16
|
+
import * as g from "react";
|
|
17
|
+
import { jsx as _, jsxs as ae } from "react/jsx-runtime";
|
|
18
|
+
//#region src/components/input/ColorArea.tsx
|
|
19
|
+
var oe = {
|
|
20
|
+
saturation: "Saturation",
|
|
21
|
+
brightness: "Brightness",
|
|
22
|
+
roleDescription: "2D slider"
|
|
23
|
+
};
|
|
24
|
+
function v(e) {
|
|
25
|
+
return Math.min(100, Math.max(0, e));
|
|
26
|
+
}
|
|
27
|
+
var se = "(pointer: coarse)", y = ({ value: y, defaultValue: ce, onValueChange: le, shape: ue, labels: de, disabled: fe = !1, name: pe, form: b, required: me, controlRef: he, className: ge, style: _e, id: ve, "aria-label": ye, "aria-labelledby": x, "aria-describedby": S, "aria-invalid": C, "aria-required": w, "aria-errormessage": T, autoFocus: E, tabIndex: D, onKeyDown: O, onPointerDown: k, onPointerMove: A, ref: j, ...M }) => {
|
|
28
|
+
let N = m({
|
|
29
|
+
value: y,
|
|
30
|
+
defaultValue: ce,
|
|
31
|
+
onValueChange: le,
|
|
32
|
+
disabled: fe
|
|
33
|
+
}), { picker: P } = N, F = {
|
|
34
|
+
...oe,
|
|
35
|
+
...P && {
|
|
36
|
+
saturation: P.labels.saturation,
|
|
37
|
+
brightness: P.labels.brightness,
|
|
38
|
+
roleDescription: P.labels.roleDescription,
|
|
39
|
+
colorName: P.labels.colorName,
|
|
40
|
+
valueText: P.labels.valueText
|
|
41
|
+
},
|
|
42
|
+
...de
|
|
43
|
+
}, be = ue ?? P?.shape ?? "rounded", I = N.color, L = ie(I), R = f(L.s), z = f(L.v), [B, V] = g.useState("saturation"), xe = l(se), H = g.useRef(null), [U, Se] = g.useState(0), W = g.useRef(null), G = g.useRef(null), K = g.useRef(null), Ce = s(j, W), we = s(G, he), q = g.useRef(0);
|
|
44
|
+
g.useLayoutEffect(() => {
|
|
45
|
+
q.current !== U && (q.current = U, (B === "saturation" ? G : K).current?.focus({ preventScroll: !0 }));
|
|
46
|
+
}, [B, U]);
|
|
47
|
+
let Te = ee(), { "aria-invalid": J, "aria-required": Ee, required: De, ...Oe } = c({
|
|
48
|
+
id: ve,
|
|
49
|
+
"aria-label": ye ?? (P && x === void 0 ? P.labels.area : void 0),
|
|
50
|
+
"aria-labelledby": x,
|
|
51
|
+
"aria-describedby": S,
|
|
52
|
+
"aria-invalid": C
|
|
53
|
+
}, { labelable: !1 }), ke = J !== void 0 && J !== !1 && J !== "false" && T || void 0, Ae = me ?? (w === !0 || w === "true" || (Te?.required ?? !1));
|
|
54
|
+
u(W, N.reset, b);
|
|
55
|
+
let Y = (e, t) => {
|
|
56
|
+
t !== (e === "saturation" ? R : z) && N.setColor(e === "saturation" ? {
|
|
57
|
+
...I,
|
|
58
|
+
s: t / 100
|
|
59
|
+
} : {
|
|
60
|
+
...I,
|
|
61
|
+
v: t / 100
|
|
62
|
+
});
|
|
63
|
+
}, X = t(O, (e) => {
|
|
64
|
+
if (N.disabled || !h(e) || e.nativeEvent.isComposing || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
65
|
+
let t = e.shiftKey ? 10 : 1, n, r;
|
|
66
|
+
switch (e.key) {
|
|
67
|
+
case "ArrowLeft":
|
|
68
|
+
case "ArrowRight": {
|
|
69
|
+
let i = a(e.key, {
|
|
70
|
+
orientation: "horizontal",
|
|
71
|
+
dir: o(e.currentTarget)
|
|
72
|
+
});
|
|
73
|
+
n = "saturation", r = R + (i === "next" ? t : -t);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case "ArrowUp":
|
|
77
|
+
n = "value", r = z + t;
|
|
78
|
+
break;
|
|
79
|
+
case "ArrowDown":
|
|
80
|
+
n = "value", r = z - t;
|
|
81
|
+
break;
|
|
82
|
+
case "PageUp":
|
|
83
|
+
n = "value", r = z + 10;
|
|
84
|
+
break;
|
|
85
|
+
case "PageDown":
|
|
86
|
+
n = "value", r = z - 10;
|
|
87
|
+
break;
|
|
88
|
+
case "Home":
|
|
89
|
+
n = "saturation", r = 0;
|
|
90
|
+
break;
|
|
91
|
+
case "End":
|
|
92
|
+
n = "saturation", r = 100;
|
|
93
|
+
break;
|
|
94
|
+
default: return;
|
|
95
|
+
}
|
|
96
|
+
e.preventDefault(), n !== B && V(n), Se((e) => e + 1), Y(n, v(r));
|
|
97
|
+
}), je = (e) => (t) => {
|
|
98
|
+
N.disabled || (e !== B && V(e), Y(e, v(Math.round(Number(t.currentTarget.value)))));
|
|
99
|
+
}, Me = (e) => () => {
|
|
100
|
+
e !== B && V(e);
|
|
101
|
+
}, Z = i((e) => {
|
|
102
|
+
let t = H.current;
|
|
103
|
+
if (!t) return;
|
|
104
|
+
let n = t.getBoundingClientRect();
|
|
105
|
+
if (n.width <= 0 || n.height <= 0) return;
|
|
106
|
+
let r = Math.min(1, Math.max(0, (e.clientX - n.left) / n.width)), i = o(e.currentTarget) === "rtl" ? 1 - r : r, a = Math.min(1, Math.max(0, 1 - (e.clientY - n.top) / n.height));
|
|
107
|
+
(i !== L.s || a !== L.v) && N.setColor({
|
|
108
|
+
...I,
|
|
109
|
+
s: i,
|
|
110
|
+
v: a
|
|
111
|
+
});
|
|
112
|
+
}), Ne = i(() => {
|
|
113
|
+
(B === "saturation" ? G : K).current?.focus({
|
|
114
|
+
preventScroll: !0,
|
|
115
|
+
focusVisible: !1
|
|
116
|
+
});
|
|
117
|
+
}), Pe = t(k, (e) => {
|
|
118
|
+
!N.disabled && e.button === 0 && e.isPrimary && h(e) && (e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), Z(e), Ne());
|
|
119
|
+
}), Fe = t(A, (e) => {
|
|
120
|
+
!N.disabled && e.currentTarget.hasPointerCapture(e.pointerId) && Z(e);
|
|
121
|
+
}), Q = {
|
|
122
|
+
saturation: F.saturation,
|
|
123
|
+
brightness: F.brightness,
|
|
124
|
+
colorName: F.colorName,
|
|
125
|
+
valueText: F.valueText
|
|
126
|
+
}, Ie = {
|
|
127
|
+
..._e,
|
|
128
|
+
"--wave-color-area-gradient": re(L.h),
|
|
129
|
+
"--wave-color-area-x": p(L.s),
|
|
130
|
+
"--wave-color-area-y": p(L.v),
|
|
131
|
+
"--wave-color-thumb": r({
|
|
132
|
+
h: L.h,
|
|
133
|
+
s: L.s,
|
|
134
|
+
v: L.v
|
|
135
|
+
})
|
|
136
|
+
}, $ = (e) => ({
|
|
137
|
+
type: "range",
|
|
138
|
+
min: 0,
|
|
139
|
+
max: 100,
|
|
140
|
+
step: 1,
|
|
141
|
+
disabled: N.disabled,
|
|
142
|
+
"aria-roledescription": F.roleDescription,
|
|
143
|
+
"aria-invalid": J,
|
|
144
|
+
"aria-errormessage": ke,
|
|
145
|
+
tabIndex: e === B ? D ?? 0 : -1,
|
|
146
|
+
"aria-hidden": e !== B && !xe || void 0,
|
|
147
|
+
onChange: je(e),
|
|
148
|
+
onFocus: Me(e),
|
|
149
|
+
className: "sr-only"
|
|
150
|
+
});
|
|
151
|
+
return /* @__PURE__ */ ae("div", {
|
|
152
|
+
role: "group",
|
|
153
|
+
"data-disabled": N.disabled ? "" : void 0,
|
|
154
|
+
...Oe,
|
|
155
|
+
className: e(n.root, "group/color-area relative h-40 w-full min-w-40 touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50", be === "square" ? "rounded-none" : "rounded", ge),
|
|
156
|
+
style: Ie,
|
|
157
|
+
...M,
|
|
158
|
+
ref: Ce,
|
|
159
|
+
onKeyDown: X,
|
|
160
|
+
onPointerDown: Pe,
|
|
161
|
+
onPointerMove: Fe,
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ _("div", {
|
|
164
|
+
ref: H,
|
|
165
|
+
"aria-hidden": "true",
|
|
166
|
+
className: e(n.field, "absolute inset-0 rounded-[inherit] bg-(image:--wave-color-area-gradient) wave-rtl:-scale-x-100 forced-colors:forced-color-adjust-none")
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ _("span", {
|
|
169
|
+
"aria-hidden": "true",
|
|
170
|
+
className: e(n.thumb, ne, "start-(--wave-color-area-x) bottom-(--wave-color-area-y) -translate-x-1/2 wave-rtl:translate-x-1/2 translate-y-1/2", "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]")
|
|
171
|
+
}),
|
|
172
|
+
/* @__PURE__ */ _("input", {
|
|
173
|
+
...$("saturation"),
|
|
174
|
+
ref: we,
|
|
175
|
+
value: R,
|
|
176
|
+
"aria-label": F.saturation,
|
|
177
|
+
"aria-valuetext": d(L, "saturation", Q),
|
|
178
|
+
autoFocus: E
|
|
179
|
+
}),
|
|
180
|
+
/* @__PURE__ */ _("input", {
|
|
181
|
+
...$("value"),
|
|
182
|
+
ref: K,
|
|
183
|
+
value: z,
|
|
184
|
+
"aria-label": F.brightness,
|
|
185
|
+
"aria-orientation": "vertical",
|
|
186
|
+
"aria-valuetext": d(L, "value", Q)
|
|
187
|
+
}),
|
|
188
|
+
!P && /* @__PURE__ */ _(te, {
|
|
189
|
+
type: "text",
|
|
190
|
+
name: pe,
|
|
191
|
+
form: b,
|
|
192
|
+
disabled: N.disabled,
|
|
193
|
+
value: r(I),
|
|
194
|
+
required: Ae,
|
|
195
|
+
onInvalid: () => (B === "saturation" ? G : K).current?.focus()
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
y.displayName = "ColorArea";
|
|
201
|
+
//#endregion
|
|
202
|
+
export { y as ColorArea };
|
|
203
|
+
|
|
204
|
+
//# sourceMappingURL=ColorArea.mjs.map
|
|
@@ -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,GA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