@mortenbrudvik/waveui 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +564 -155
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.mjs +36 -35
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/button/Button.slots.cjs +1 -1
- package/dist/components/button/Button.slots.cjs.map +1 -1
- package/dist/components/button/Button.slots.mjs +31 -21
- package/dist/components/button/Button.slots.mjs.map +1 -1
- package/dist/components/button/CompoundButton.cjs +1 -1
- package/dist/components/button/CompoundButton.cjs.map +1 -1
- package/dist/components/button/CompoundButton.mjs +31 -29
- package/dist/components/button/CompoundButton.mjs.map +1 -1
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +24 -23
- package/dist/components/button/Link.mjs.map +1 -1
- package/dist/components/button/MenuButton.cjs +1 -1
- package/dist/components/button/MenuButton.cjs.map +1 -1
- package/dist/components/button/MenuButton.mjs +29 -28
- package/dist/components/button/MenuButton.mjs.map +1 -1
- package/dist/components/button/SplitButton.cjs +1 -1
- package/dist/components/button/SplitButton.cjs.map +1 -1
- package/dist/components/button/SplitButton.mjs +46 -45
- package/dist/components/button/SplitButton.mjs.map +1 -1
- package/dist/components/button/ToggleButton.cjs +1 -1
- package/dist/components/button/ToggleButton.cjs.map +1 -1
- package/dist/components/button/ToggleButton.mjs +38 -35
- package/dist/components/button/ToggleButton.mjs.map +1 -1
- package/dist/components/button/Toolbar.cjs +1 -1
- package/dist/components/button/Toolbar.cjs.map +1 -1
- package/dist/components/button/Toolbar.mjs +43 -42
- package/dist/components/button/Toolbar.mjs.map +1 -1
- package/dist/components/button/Toolbar.parts.cjs +1 -1
- package/dist/components/button/Toolbar.parts.cjs.map +1 -1
- package/dist/components/button/Toolbar.parts.mjs +76 -81
- package/dist/components/button/Toolbar.parts.mjs.map +1 -1
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.mjs +72 -67
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.mjs +89 -88
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
- package/dist/components/data-display/Badge.cjs +1 -1
- package/dist/components/data-display/Badge.cjs.map +1 -1
- package/dist/components/data-display/Badge.mjs +17 -16
- package/dist/components/data-display/Badge.mjs.map +1 -1
- package/dist/components/data-display/CounterBadge.cjs +1 -1
- package/dist/components/data-display/CounterBadge.cjs.map +1 -1
- package/dist/components/data-display/CounterBadge.mjs +18 -17
- package/dist/components/data-display/CounterBadge.mjs.map +1 -1
- package/dist/components/data-display/Divider.cjs +1 -1
- package/dist/components/data-display/Divider.cjs.map +1 -1
- package/dist/components/data-display/Divider.mjs +31 -30
- package/dist/components/data-display/Divider.mjs.map +1 -1
- package/dist/components/data-display/Image.cjs +1 -1
- package/dist/components/data-display/Image.cjs.map +1 -1
- package/dist/components/data-display/Image.mjs +16 -15
- package/dist/components/data-display/Image.mjs.map +1 -1
- package/dist/components/data-display/InfoButton.cjs +2 -0
- package/dist/components/data-display/InfoButton.cjs.map +1 -0
- package/dist/components/data-display/InfoButton.mjs +173 -0
- package/dist/components/data-display/InfoButton.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +36 -92
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +175 -174
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/Persona.cjs +1 -1
- package/dist/components/data-display/Persona.cjs.map +1 -1
- package/dist/components/data-display/Persona.mjs +31 -29
- package/dist/components/data-display/Persona.mjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.cjs +1 -1
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.mjs +25 -24
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +87 -82
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.cjs +1 -1
- package/dist/components/feedback/MessageBar.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.mjs +129 -71
- package/dist/components/feedback/MessageBar.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.parts.cjs +2 -0
- package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.parts.mjs +84 -0
- package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
- package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
- package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +1 -1
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.status.mjs +2 -1
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
- package/dist/components/feedback/ProgressBar.cjs +1 -1
- package/dist/components/feedback/ProgressBar.cjs.map +1 -1
- package/dist/components/feedback/ProgressBar.mjs +44 -43
- package/dist/components/feedback/ProgressBar.mjs.map +1 -1
- package/dist/components/feedback/Skeleton.cjs +1 -1
- package/dist/components/feedback/Skeleton.cjs.map +1 -1
- package/dist/components/feedback/Skeleton.mjs +26 -24
- package/dist/components/feedback/Skeleton.mjs.map +1 -1
- package/dist/components/feedback/Spinner.cjs +1 -1
- package/dist/components/feedback/Spinner.cjs.map +1 -1
- package/dist/components/feedback/Spinner.mjs +32 -31
- package/dist/components/feedback/Spinner.mjs.map +1 -1
- package/dist/components/feedback/Toast.cjs +1 -1
- package/dist/components/feedback/Toast.cjs.map +1 -1
- package/dist/components/feedback/Toast.context.cjs +2 -0
- package/dist/components/feedback/Toast.context.cjs.map +1 -0
- package/dist/components/feedback/Toast.context.mjs +23 -0
- package/dist/components/feedback/Toast.context.mjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +10 -342
- package/dist/components/feedback/Toast.mjs.map +1 -1
- package/dist/components/feedback/Toast.parts.cjs +2 -0
- package/dist/components/feedback/Toast.parts.cjs.map +1 -0
- package/dist/components/feedback/Toast.parts.mjs +98 -0
- package/dist/components/feedback/Toast.parts.mjs.map +1 -0
- package/dist/components/feedback/Toast.root.cjs +2 -0
- package/dist/components/feedback/Toast.root.cjs.map +1 -0
- package/dist/components/feedback/Toast.root.mjs +109 -0
- package/dist/components/feedback/Toast.root.mjs.map +1 -0
- package/dist/components/feedback/Toaster.cjs +2 -0
- package/dist/components/feedback/Toaster.cjs.map +1 -0
- package/dist/components/feedback/Toaster.mjs +564 -0
- package/dist/components/feedback/Toaster.mjs.map +1 -0
- package/dist/components/input/AlphaSlider.cjs +2 -0
- package/dist/components/input/AlphaSlider.cjs.map +1 -0
- package/dist/components/input/AlphaSlider.mjs +115 -0
- package/dist/components/input/AlphaSlider.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +1 -1
- package/dist/components/input/Checkbox.cjs.map +1 -1
- package/dist/components/input/Checkbox.mjs +87 -70
- package/dist/components/input/Checkbox.mjs.map +1 -1
- package/dist/components/input/ColorArea.cjs +2 -0
- package/dist/components/input/ColorArea.cjs.map +1 -0
- package/dist/components/input/ColorArea.mjs +204 -0
- package/dist/components/input/ColorArea.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +5 -5
- package/dist/components/input/ColorPicker.cjs.map +1 -1
- package/dist/components/input/ColorPicker.mjs +142 -165
- package/dist/components/input/ColorPicker.mjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.cjs +2 -0
- package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
- package/dist/components/input/ColorPicker.parts.mjs +192 -0
- package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
- package/dist/components/input/ColorSlider.cjs +2 -0
- package/dist/components/input/ColorSlider.cjs.map +1 -0
- package/dist/components/input/ColorSlider.mjs +138 -0
- package/dist/components/input/ColorSlider.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +22 -22
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +151 -141
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +239 -234
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +109 -100
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Field.cjs +1 -1
- package/dist/components/input/Field.cjs.map +1 -1
- package/dist/components/input/Field.mjs +139 -105
- package/dist/components/input/Field.mjs.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.mjs +80 -55
- package/dist/components/input/Input.mjs.map +1 -1
- package/dist/components/input/Label.cjs +1 -1
- package/dist/components/input/Label.cjs.map +1 -1
- package/dist/components/input/Label.mjs +19 -12
- package/dist/components/input/Label.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +100 -98
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/RadioGroup.cjs +1 -1
- package/dist/components/input/RadioGroup.cjs.map +1 -1
- package/dist/components/input/RadioGroup.mjs +89 -88
- package/dist/components/input/RadioGroup.mjs.map +1 -1
- package/dist/components/input/Rating.cjs +1 -1
- package/dist/components/input/Rating.cjs.map +1 -1
- package/dist/components/input/Rating.item.cjs +2 -0
- package/dist/components/input/Rating.item.cjs.map +1 -0
- package/dist/components/input/Rating.item.mjs +255 -0
- package/dist/components/input/Rating.item.mjs.map +1 -0
- package/dist/components/input/Rating.mjs +152 -152
- package/dist/components/input/Rating.mjs.map +1 -1
- package/dist/components/input/SearchBox.cjs +1 -1
- package/dist/components/input/SearchBox.cjs.map +1 -1
- package/dist/components/input/SearchBox.mjs +162 -132
- package/dist/components/input/SearchBox.mjs.map +1 -1
- package/dist/components/input/Select.cjs +1 -1
- package/dist/components/input/Select.cjs.map +1 -1
- package/dist/components/input/Select.mjs +34 -24
- package/dist/components/input/Select.mjs.map +1 -1
- package/dist/components/input/Slider.cjs +1 -1
- package/dist/components/input/Slider.cjs.map +1 -1
- package/dist/components/input/Slider.mjs +78 -54
- package/dist/components/input/Slider.mjs.map +1 -1
- package/dist/components/input/SpinButton.cjs +1 -1
- package/dist/components/input/SpinButton.cjs.map +1 -1
- package/dist/components/input/SpinButton.mjs +202 -99
- package/dist/components/input/SpinButton.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.mjs +38 -37
- package/dist/components/input/SwatchPicker.mjs.map +1 -1
- package/dist/components/input/Switch.cjs +1 -1
- package/dist/components/input/Switch.cjs.map +1 -1
- package/dist/components/input/Switch.mjs +75 -58
- package/dist/components/input/Switch.mjs.map +1 -1
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.mjs +199 -169
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/Textarea.cjs +1 -1
- package/dist/components/input/Textarea.cjs.map +1 -1
- package/dist/components/input/Textarea.mjs +31 -23
- package/dist/components/input/Textarea.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +185 -177
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/input/colorName.cjs +2 -0
- package/dist/components/input/colorName.cjs.map +1 -0
- package/dist/components/input/colorName.mjs +30 -0
- package/dist/components/input/colorName.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +1 -1
- package/dist/components/input/colorUtils.cjs.map +1 -1
- package/dist/components/input/colorUtils.mjs +154 -56
- package/dist/components/input/colorUtils.mjs.map +1 -1
- package/dist/components/input/fieldLabel.cjs +2 -0
- package/dist/components/input/fieldLabel.cjs.map +1 -0
- package/dist/components/input/fieldLabel.mjs +17 -0
- package/dist/components/input/fieldLabel.mjs.map +1 -0
- package/dist/components/input/inputLook.cjs +2 -0
- package/dist/components/input/inputLook.cjs.map +1 -0
- package/dist/components/input/inputLook.mjs +28 -0
- package/dist/components/input/inputLook.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +1 -1
- package/dist/components/input/pickerStyles.cjs.map +1 -1
- package/dist/components/input/pickerStyles.mjs +42 -4
- package/dist/components/input/pickerStyles.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs +130 -129
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/layout/Card.cjs +1 -1
- package/dist/components/layout/Card.cjs.map +1 -1
- package/dist/components/layout/Card.mjs +78 -77
- package/dist/components/layout/Card.mjs.map +1 -1
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.mjs +111 -110
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/Flex.cjs +1 -1
- package/dist/components/layout/Flex.cjs.map +1 -1
- package/dist/components/layout/Flex.mjs +22 -21
- package/dist/components/layout/Flex.mjs.map +1 -1
- package/dist/components/layout/Grid.cjs +1 -1
- package/dist/components/layout/Grid.cjs.map +1 -1
- package/dist/components/layout/Grid.mjs +19 -18
- package/dist/components/layout/Grid.mjs.map +1 -1
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +92 -91
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Stack.cjs +1 -1
- package/dist/components/layout/Stack.cjs.map +1 -1
- package/dist/components/layout/Stack.mjs +14 -13
- package/dist/components/layout/Stack.mjs.map +1 -1
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +118 -117
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/layout/Tree.cjs +1 -1
- package/dist/components/layout/Tree.cjs.map +1 -1
- package/dist/components/layout/Tree.context.cjs +2 -0
- package/dist/components/layout/Tree.context.cjs.map +1 -0
- package/dist/components/layout/Tree.context.mjs +33 -0
- package/dist/components/layout/Tree.context.mjs.map +1 -0
- package/dist/components/layout/Tree.core.cjs +2 -0
- package/dist/components/layout/Tree.core.cjs.map +1 -0
- package/dist/components/layout/Tree.core.mjs +416 -0
- package/dist/components/layout/Tree.core.mjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
- package/dist/components/layout/Tree.mjs +7 -215
- package/dist/components/layout/Tree.mjs.map +1 -1
- package/dist/components/layout/Tree.selection.cjs +2 -0
- package/dist/components/layout/Tree.selection.cjs.map +1 -0
- package/dist/components/layout/Tree.selection.mjs +73 -0
- package/dist/components/layout/Tree.selection.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +76 -75
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/navigation/Menu.group.cjs +1 -1
- package/dist/components/navigation/Menu.group.cjs.map +1 -1
- package/dist/components/navigation/Menu.group.mjs +39 -37
- package/dist/components/navigation/Menu.group.mjs.map +1 -1
- package/dist/components/navigation/Menu.items.cjs +1 -1
- package/dist/components/navigation/Menu.items.cjs.map +1 -1
- package/dist/components/navigation/Menu.items.mjs +67 -61
- package/dist/components/navigation/Menu.items.mjs.map +1 -1
- package/dist/components/navigation/Menu.link.cjs +1 -1
- package/dist/components/navigation/Menu.link.cjs.map +1 -1
- package/dist/components/navigation/Menu.link.mjs +34 -28
- package/dist/components/navigation/Menu.link.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +114 -113
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +171 -170
- package/dist/components/navigation/Menu.root.mjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.cjs +1 -1
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.mjs +85 -63
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.cjs +1 -1
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.mjs +6 -6
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.mjs +170 -155
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination.cjs.map +1 -1
- package/dist/components/navigation/Pagination.mjs +73 -65
- package/dist/components/navigation/Pagination.mjs.map +1 -1
- package/dist/components/navigation/Stepper.cjs +1 -1
- package/dist/components/navigation/Stepper.cjs.map +1 -1
- package/dist/components/navigation/Stepper.mjs +110 -109
- package/dist/components/navigation/Stepper.mjs.map +1 -1
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +109 -108
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Drawer.cjs +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.mjs +110 -109
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +148 -151
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/Popover.shared.cjs +1 -1
- package/dist/components/overlays/Popover.shared.cjs.map +1 -1
- package/dist/components/overlays/Popover.shared.mjs +82 -77
- package/dist/components/overlays/Popover.shared.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +41 -37
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +87 -86
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +33 -32
- package/dist/components/portal/Portal.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +36 -29
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +228 -227
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +60 -59
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/typography/Text.cjs +1 -1
- package/dist/components/typography/Text.cjs.map +1 -1
- package/dist/components/typography/Text.mjs +12 -11
- package/dist/components/typography/Text.mjs.map +1 -1
- package/dist/hooks/useFieldControl.cjs.map +1 -1
- package/dist/hooks/useFieldControl.mjs.map +1 -1
- package/dist/hooks/useMediaQuery.cjs +2 -0
- package/dist/hooks/useMediaQuery.cjs.map +1 -0
- package/dist/hooks/useMediaQuery.mjs +20 -0
- package/dist/hooks/useMediaQuery.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +3 -3
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2890 -197
- package/dist/index.d.ts +2890 -197
- package/dist/index.mjs +101 -87
- package/dist/lib/classNames.cjs +2 -0
- package/dist/lib/classNames.cjs.map +1 -0
- package/dist/lib/classNames.mjs +423 -0
- package/dist/lib/classNames.mjs.map +1 -0
- package/dist/lib/color.cjs +2 -0
- package/dist/lib/color.cjs.map +1 -0
- package/dist/lib/color.mjs +86 -0
- package/dist/lib/color.mjs.map +1 -0
- package/dist/lib/globalRegistry.cjs.map +1 -1
- package/dist/lib/globalRegistry.mjs.map +1 -1
- package/dist/lib/styles.cjs +1 -1
- package/dist/lib/styles.cjs.map +1 -1
- package/dist/lib/styles.mjs +21 -4
- package/dist/lib/styles.mjs.map +1 -1
- package/dist/lib/toaster.cjs +2 -0
- package/dist/lib/toaster.cjs.map +1 -0
- package/dist/lib/toaster.mjs +77 -0
- package/dist/lib/toaster.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +13 -0
|
@@ -1,56 +1,51 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { clampUnit as e, hsvToHex as t, parseHexBytes as n, wrapHue as r } from "../../lib/color.mjs";
|
|
3
|
+
import { getArrowIntent as i } from "../../lib/direction.mjs";
|
|
4
|
+
import { getColorName as a } from "./colorName.mjs";
|
|
2
5
|
//#region src/components/input/colorUtils.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
6
|
+
var o = "#000000", s = "#ffffff", c = /^#([0-9a-f]{6}|[0-9a-f]{8})$/i, l = /^#?[0-9a-f]{0,8}$/i;
|
|
7
|
+
function u(e, t, n) {
|
|
5
8
|
return Math.min(n, Math.max(t, e));
|
|
6
9
|
}
|
|
7
|
-
function
|
|
8
|
-
return Math.round(
|
|
9
|
-
}
|
|
10
|
-
function s(e) {
|
|
11
|
-
let t = (e.length <= 4 ? e.split("").map((e) => e + e).join("") : e).toLowerCase();
|
|
12
|
-
return {
|
|
13
|
-
rgb: `#${t.slice(0, 6)}`,
|
|
14
|
-
alpha: t.length === 8 ? parseInt(t.slice(6, 8), 16) : 255
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function c(e) {
|
|
18
|
-
let t = n.exec(e.trim());
|
|
19
|
-
return t ? s(t[1]) : null;
|
|
20
|
-
}
|
|
21
|
-
function l(e) {
|
|
22
|
-
let t = r.exec(e.trim());
|
|
23
|
-
return t ? s(t[1]) : null;
|
|
24
|
-
}
|
|
25
|
-
function u(e) {
|
|
26
|
-
return i.test(e.trim());
|
|
27
|
-
}
|
|
28
|
-
function d(e, t = 255) {
|
|
29
|
-
let n = Math.round(a(t, 0, 255));
|
|
30
|
-
return n === 255 ? e : e + o(n);
|
|
10
|
+
function d(e) {
|
|
11
|
+
return Math.round(u(e, 0, 255)).toString(16).padStart(2, "0");
|
|
31
12
|
}
|
|
32
13
|
function f(e) {
|
|
33
|
-
let t =
|
|
34
|
-
return t ?
|
|
14
|
+
let t = n(e);
|
|
15
|
+
return t ? {
|
|
16
|
+
rgb: `#${d(t.r)}${d(t.g)}${d(t.b)}`,
|
|
17
|
+
alpha: t.alpha
|
|
18
|
+
} : null;
|
|
35
19
|
}
|
|
36
20
|
function p(e) {
|
|
37
|
-
return
|
|
21
|
+
return c.test(e.trim()) ? f(e) : null;
|
|
38
22
|
}
|
|
39
23
|
function m(e) {
|
|
40
|
-
return
|
|
24
|
+
return l.test(e.trim());
|
|
41
25
|
}
|
|
42
|
-
function h(e) {
|
|
43
|
-
let
|
|
44
|
-
return
|
|
26
|
+
function h(e, t = 255) {
|
|
27
|
+
let n = Math.round(u(t, 0, 255));
|
|
28
|
+
return n === 255 ? e : e + d(n);
|
|
45
29
|
}
|
|
46
30
|
function g(e) {
|
|
31
|
+
let t = f(e);
|
|
32
|
+
return t ? h(t.rgb, t.alpha) : null;
|
|
33
|
+
}
|
|
34
|
+
function _(e) {
|
|
35
|
+
return Math.round(u(e, 0, 255) / 255 * 100);
|
|
36
|
+
}
|
|
37
|
+
function v(e) {
|
|
38
|
+
let t = e.endsWith("%"), n = Number(t ? e.slice(0, -1) : e);
|
|
39
|
+
return Number.isFinite(n) ? u(t ? n / 100 * 255 : n, 0, 255) : null;
|
|
40
|
+
}
|
|
41
|
+
function y(e) {
|
|
47
42
|
if (e === void 0) return 1;
|
|
48
43
|
let t = e.endsWith("%"), n = Number(t ? e.slice(0, -1) : e);
|
|
49
|
-
return Number.isFinite(n) ?
|
|
44
|
+
return Number.isFinite(n) ? u(t ? n / 100 : n, 0, 1) : null;
|
|
50
45
|
}
|
|
51
|
-
var
|
|
52
|
-
function
|
|
53
|
-
let t = e.trim(), n =
|
|
46
|
+
var b = /^rgba?\(\s*([^)]*)\)$/i;
|
|
47
|
+
function x(e) {
|
|
48
|
+
let t = e.trim(), n = f(t);
|
|
54
49
|
if (n) {
|
|
55
50
|
let e = parseInt(n.rgb.slice(1), 16);
|
|
56
51
|
return {
|
|
@@ -60,37 +55,140 @@ function v(e) {
|
|
|
60
55
|
a: n.alpha / 255
|
|
61
56
|
};
|
|
62
57
|
}
|
|
63
|
-
let r =
|
|
58
|
+
let r = b.exec(t);
|
|
64
59
|
if (!r) return null;
|
|
65
60
|
let [i, a] = r[1].split("/"), o = (i ?? "").split(/[\s,]+/).map((e) => e.trim()).filter(Boolean), s = a?.trim();
|
|
66
61
|
if (s === void 0 && o.length === 4 && (s = o.pop()), o.length !== 3) return null;
|
|
67
|
-
let [l, u
|
|
68
|
-
return
|
|
69
|
-
r:
|
|
70
|
-
g:
|
|
71
|
-
b:
|
|
72
|
-
a:
|
|
62
|
+
let [c, l, u] = o.map(v), d = y(s);
|
|
63
|
+
return c === null || l === null || u === null || d === null ? null : {
|
|
64
|
+
r: c,
|
|
65
|
+
g: l,
|
|
66
|
+
b: u,
|
|
67
|
+
a: d
|
|
73
68
|
};
|
|
74
69
|
}
|
|
75
|
-
function
|
|
70
|
+
function S(e) {
|
|
76
71
|
let t = e / 255;
|
|
77
72
|
return t <= .04045 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
78
73
|
}
|
|
79
|
-
function
|
|
80
|
-
let t =
|
|
81
|
-
return t ? .2126 *
|
|
74
|
+
function C(e) {
|
|
75
|
+
let t = x(e);
|
|
76
|
+
return t ? .2126 * S(t.r) + .7152 * S(t.g) + .0722 * S(t.b) : null;
|
|
82
77
|
}
|
|
83
|
-
function
|
|
84
|
-
let
|
|
85
|
-
return
|
|
86
|
-
glyph:
|
|
87
|
-
halo:
|
|
78
|
+
function w(e) {
|
|
79
|
+
let t = C(e);
|
|
80
|
+
return t === null || (t + .05) / .05 >= 1.05 / (t + .05) ? {
|
|
81
|
+
glyph: o,
|
|
82
|
+
halo: s
|
|
88
83
|
} : {
|
|
89
|
-
glyph:
|
|
90
|
-
halo:
|
|
84
|
+
glyph: s,
|
|
85
|
+
halo: o
|
|
91
86
|
};
|
|
92
87
|
}
|
|
88
|
+
function T(e) {
|
|
89
|
+
return Number.isFinite(e) && e >= 0 && e <= 360 ? e : r(e);
|
|
90
|
+
}
|
|
91
|
+
function E(t) {
|
|
92
|
+
return {
|
|
93
|
+
h: T(t.h),
|
|
94
|
+
s: e(t.s, 0),
|
|
95
|
+
v: e(t.v, 0),
|
|
96
|
+
a: e(t.a, 1)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function D(e) {
|
|
100
|
+
return Math.round(e * 100);
|
|
101
|
+
}
|
|
102
|
+
function O(e) {
|
|
103
|
+
return `${Math.round(e * 1e4) / 100}%`;
|
|
104
|
+
}
|
|
105
|
+
function k(e, t) {
|
|
106
|
+
return e.h === t.h && e.s === t.s && e.v === t.v && (e.a ?? 1) === (t.a ?? 1);
|
|
107
|
+
}
|
|
108
|
+
function A(e, t, n, r, a) {
|
|
109
|
+
if (t.altKey || t.ctrlKey || t.metaKey) return null;
|
|
110
|
+
let o = t.shiftKey ? 10 : 1, s;
|
|
111
|
+
switch (e) {
|
|
112
|
+
case "ArrowUp":
|
|
113
|
+
s = r + o;
|
|
114
|
+
break;
|
|
115
|
+
case "ArrowDown":
|
|
116
|
+
s = r - o;
|
|
117
|
+
break;
|
|
118
|
+
case "ArrowRight":
|
|
119
|
+
case "ArrowLeft":
|
|
120
|
+
s = r + (i(e, {
|
|
121
|
+
orientation: "horizontal",
|
|
122
|
+
dir: n
|
|
123
|
+
}) === "next" ? o : -o);
|
|
124
|
+
break;
|
|
125
|
+
case "PageUp":
|
|
126
|
+
s = r + 10;
|
|
127
|
+
break;
|
|
128
|
+
case "PageDown":
|
|
129
|
+
s = r - 10;
|
|
130
|
+
break;
|
|
131
|
+
case "Home":
|
|
132
|
+
s = 0;
|
|
133
|
+
break;
|
|
134
|
+
case "End":
|
|
135
|
+
s = a;
|
|
136
|
+
break;
|
|
137
|
+
default: return null;
|
|
138
|
+
}
|
|
139
|
+
return Math.min(a, Math.max(0, s));
|
|
140
|
+
}
|
|
141
|
+
var j = (e) => e === "vertical" ? "to top" : "to right";
|
|
142
|
+
function M(e) {
|
|
143
|
+
return `linear-gradient(to top, #000000, transparent), linear-gradient(to right, #ffffff, ${t({
|
|
144
|
+
h: e,
|
|
145
|
+
s: 1,
|
|
146
|
+
v: 1
|
|
147
|
+
})})`;
|
|
148
|
+
}
|
|
149
|
+
var N = "#ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000";
|
|
150
|
+
function P(e, n, r) {
|
|
151
|
+
let i = j(r);
|
|
152
|
+
return e === "hue" ? `linear-gradient(${i}, ${N})` : e === "saturation" ? `linear-gradient(${i}, ${t({
|
|
153
|
+
h: n.h,
|
|
154
|
+
s: 0,
|
|
155
|
+
v: n.v
|
|
156
|
+
})}, ${t({
|
|
157
|
+
h: n.h,
|
|
158
|
+
s: 1,
|
|
159
|
+
v: n.v
|
|
160
|
+
})})` : `linear-gradient(${i}, #000000, ${t({
|
|
161
|
+
h: n.h,
|
|
162
|
+
s: n.s,
|
|
163
|
+
v: 1
|
|
164
|
+
})})`;
|
|
165
|
+
}
|
|
166
|
+
function F(e, n, r) {
|
|
167
|
+
let i = t({
|
|
168
|
+
h: e.h,
|
|
169
|
+
s: e.s,
|
|
170
|
+
v: e.v
|
|
171
|
+
}), a = j(r);
|
|
172
|
+
return n ? `linear-gradient(${a}, ${i}, transparent)` : `linear-gradient(${a}, transparent, ${i})`;
|
|
173
|
+
}
|
|
174
|
+
function I(e, t, n) {
|
|
175
|
+
if (n.valueText) return n.valueText(e, t);
|
|
176
|
+
let r = `${n.saturation} ${D(e.s)}%`, i = `${n.brightness} ${D(e.v)}%`, o = t === "saturation" ? `${r}, ${i}` : `${i}, ${r}`, s = (n.colorName ?? a)(e);
|
|
177
|
+
return s ? `${o}, ${s}` : o;
|
|
178
|
+
}
|
|
179
|
+
function L(e, t, n) {
|
|
180
|
+
if (n.valueText) return n.valueText(e, t);
|
|
181
|
+
if (t !== "hue") return `${D(t === "saturation" ? e.s : e.v)}%`;
|
|
182
|
+
let r = `${Math.round(e.h)}°`, i = (n.colorName ?? a)(e);
|
|
183
|
+
return i ? `${r}, ${i}` : r;
|
|
184
|
+
}
|
|
185
|
+
function R(e, t, n) {
|
|
186
|
+
if (n) return n(e, t);
|
|
187
|
+
let r = D(e.a);
|
|
188
|
+
return `${t ? 100 - r : r}%`;
|
|
189
|
+
}
|
|
190
|
+
var z = "pointer-events-none absolute size-6 rounded-full border-2 border-background bg-(--wave-color-thumb) ring-1 ring-foreground forced-colors:forced-color-adjust-none forced-colors:border-[Canvas] forced-colors:ring-[CanvasText]", B = "h-6 w-full items-center", V = "h-40 w-6 flex-col items-center [container-type:size]", H = "mx-3 h-3 flex-1 wave-rtl:-scale-x-100", U = "my-3 w-3 flex-1", W = "bg-(image:--wave-color-slider-gradient)", G = "absolute m-0 cursor-pointer appearance-none opacity-0 disabled:cursor-not-allowed [&::-webkit-slider-thumb]:size-6 [&::-webkit-slider-thumb]:appearance-none [&::-moz-range-thumb]:size-6", K = "inset-0 size-full", q = "start-1/2 top-1/2 h-6 w-[100cqh] -translate-x-1/2 wave-rtl:translate-x-1/2 -translate-y-1/2 -rotate-90", J = "pointer-events-none absolute inset-x-3 inset-y-0", Y = "pointer-events-none absolute inset-x-0 inset-y-3", X = "start-(--wave-color-slider-position) top-1/2 -translate-x-1/2 wave-rtl:translate-x-1/2 -translate-y-1/2", Z = "bottom-(--wave-color-slider-position) start-1/2 -translate-x-1/2 wave-rtl:translate-x-1/2 translate-y-1/2";
|
|
93
191
|
//#endregion
|
|
94
|
-
export {
|
|
192
|
+
export { z as COLOR_THUMB_CLASSES, W as RAIL_GRADIENT, G as RAIL_INPUT_CLASSES, K as RAIL_INPUT_HORIZONTAL, q as RAIL_INPUT_VERTICAL, B as RAIL_ROOT_HORIZONTAL, V as RAIL_ROOT_VERTICAL, H as RAIL_TRACK_HORIZONTAL, U as RAIL_TRACK_VERTICAL, X as THUMB_POSITION_HORIZONTAL, Z as THUMB_POSITION_VERTICAL, J as THUMB_TRACK_HORIZONTAL, Y as THUMB_TRACK_VERTICAL, F as alphaSliderGradient, _ as alphaToOpacity, R as alphaValueText, I as areaValueText, M as colorAreaGradient, P as colorSliderGradient, E as displayColor, T as displayHue, h as formatHexColor, w as getCheckColors, C as getRelativeLuminance, m as isHexDraft, g as normalizeHexColor, x as parseCssColor, f as parseHexColor, p as parseHexInput, A as railKeyTarget, k as sameColor, L as sliderValueText, D as toPercent, O as toPosition };
|
|
95
193
|
|
|
96
194
|
//# sourceMappingURL=colorUtils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorUtils.mjs","names":["BLACK","WHITE","HEX_COLOR","HEX_INPUT","HEX_DRAFT","clamp","max","min","value","toHexByte","fromDigits","lower","digits","d","parseHexColor","match","parseHexInput","text","isHexDraft","formatHexColor","byte","alpha","rgb","normalizeHexColor","parsed","alphaToOpacity","opacityToAlpha","opacity","parseChannel","percent","token","parseAlpha","RGB_FUNCTION","parseCssColor","hex","n","channelsPart","alphaPart","tokens","t","alphaToken","r","g","b","a","linearize","c","channel","getRelativeLuminance","color","getCheckColors","luminance"],"sources":["../../../src/components/input/colorUtils.ts"],"sourcesContent":["/**\n * Color helpers for ColorPicker and SwatchPicker: hex parsing/normalisation, the alpha byte ↔\n * opacity percentage, and the luminance-picked check glyph drawn on a user-supplied swatch.\n *\n * Internal (not exported from the package). Pure functions, no DOM access, so they run on the\n * server and in tests.\n */\n\n/** A parsed hex color: the `#rrggbb` part (lowercase) and the alpha byte (0–255). */\nexport interface HexColor {\n /** `#rrggbb`, lowercase. */\n rgb: string;\n /** Alpha byte, 0 (transparent) … 255 (opaque). */\n alpha: number;\n}\n\n/** An sRGB color with 0–255 channels and a 0–1 alpha. */\nexport interface RgbaColor {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\n/** Colors of the selected-swatch check glyph: the glyph and the halo drawn under it. */\nexport interface CheckColors {\n glyph: string;\n halo: string;\n}\n\n// wave-allow-color: luminance-picked check glyph on a user swatch (C-TOKENS exception, input-pickers#16)\nconst BLACK = '#000000';\n// wave-allow-color: luminance-picked check glyph on a user swatch (C-TOKENS exception, input-pickers#16)\nconst WHITE = '#ffffff';\n\nconst HEX_COLOR = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst HEX_INPUT = /^#([0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst HEX_DRAFT = /^#?[0-9a-f]{0,8}$/i;\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction toHexByte(value: number): string {\n return Math.round(clamp(value, 0, 255))\n .toString(16)\n .padStart(2, '0');\n}\n\nfunction fromDigits(digits: string): HexColor {\n const long =\n digits.length <= 4\n ? digits\n .split('')\n .map((d) => d + d)\n .join('')\n : digits;\n const lower = long.toLowerCase();\n return {\n rgb: `#${lower.slice(0, 6)}`,\n alpha: lower.length === 8 ? parseInt(lower.slice(6, 8), 16) : 255,\n };\n}\n\n/**\n * Parses a hex color (`#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, case-insensitive, surrounding\n * whitespace ignored). Returns `null` for anything else (named colors, `rgb()`, a missing `#`).\n *\n * @example parseHexColor('#0F6CBD80') // { rgb: '#0f6cbd', alpha: 128 }\n */\nexport function parseHexColor(value: string): HexColor | null {\n const match = HEX_COLOR.exec(value.trim());\n return match ? fromDigits(match[1]) : null;\n}\n\n/**\n * Parses text typed into a hex field: only complete `#rrggbb` / `#rrggbbaa` values are accepted,\n * so the short forms a user passes through while typing (`#abc`) are never committed.\n */\nexport function parseHexInput(text: string): HexColor | null {\n const match = HEX_INPUT.exec(text.trim());\n return match ? fromDigits(match[1]) : null;\n}\n\n/**\n * Whether typed text can still become a hex color by typing more characters (an optional `#`\n * followed by at most 8 hex digits; surrounding whitespace ignored, like the parsers). `false`\n * means the text is invalid whatever follows.\n */\nexport function isHexDraft(text: string): boolean {\n return HEX_DRAFT.test(text.trim());\n}\n\n/**\n * Formats `#rrggbb` plus an alpha byte: `#rrggbb` when opaque (`alpha` 255, the default),\n * `#rrggbbaa` otherwise. The alpha byte is rounded and clamped to 0–255.\n */\nexport function formatHexColor(rgb: string, alpha = 255): string {\n const byte = Math.round(clamp(alpha, 0, 255));\n return byte === 255 ? rgb : rgb + toHexByte(byte);\n}\n\n/**\n * A hex color in the one form ColorPicker reports: `#rrggbb` in lower case, or `#rrggbbaa` when\n * the alpha byte is not 255 (short forms expanded, surrounding whitespace dropped). Returns `null`\n * for anything {@link parseHexColor} rejects.\n *\n * @example normalizeHexColor('#ABC') // '#aabbcc'\n * @example normalizeHexColor('#0f6cbdff') // '#0f6cbd'\n */\nexport function normalizeHexColor(value: string): string | null {\n const parsed = parseHexColor(value);\n return parsed ? formatHexColor(parsed.rgb, parsed.alpha) : null;\n}\n\n/** Alpha byte (0–255) → whole opacity percentage (0–100). */\nexport function alphaToOpacity(alpha: number): number {\n return Math.round((clamp(alpha, 0, 255) / 255) * 100);\n}\n\n/** Opacity percentage (0–100) → alpha byte (0–255). Inverse of {@link alphaToOpacity}. */\nexport function opacityToAlpha(opacity: number): number {\n return Math.round((clamp(opacity, 0, 100) / 100) * 255);\n}\n\nfunction parseChannel(token: string): number | null {\n const percent = token.endsWith('%');\n const n = Number(percent ? token.slice(0, -1) : token);\n if (!Number.isFinite(n)) return null;\n return clamp(percent ? (n / 100) * 255 : n, 0, 255);\n}\n\nfunction parseAlpha(token: string | undefined): number | null {\n if (token === undefined) return 1;\n const percent = token.endsWith('%');\n const n = Number(percent ? token.slice(0, -1) : token);\n if (!Number.isFinite(n)) return null;\n return clamp(percent ? n / 100 : n, 0, 1);\n}\n\nconst RGB_FUNCTION = /^rgba?\\(\\s*([^)]*)\\)$/i;\n\n/**\n * Parses the CSS colors that can be resolved without a browser: hex colors and `rgb()`/`rgba()`\n * (comma or space syntax, numbers or percentages, optional alpha). Returns `null` for named\n * colors, other color spaces and variables.\n */\nexport function parseCssColor(value: string): RgbaColor | null {\n const text = value.trim();\n const hex = parseHexColor(text);\n if (hex) {\n const n = parseInt(hex.rgb.slice(1), 16);\n return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255, a: hex.alpha / 255 };\n }\n const match = RGB_FUNCTION.exec(text);\n if (!match) return null;\n const [channelsPart, alphaPart]: Array<string | undefined> = match[1].split('/');\n const tokens = (channelsPart ?? '')\n .split(/[\\s,]+/)\n .map((t) => t.trim())\n .filter(Boolean);\n let alphaToken: string | undefined = alphaPart?.trim();\n if (alphaToken === undefined && tokens.length === 4) alphaToken = tokens.pop();\n if (tokens.length !== 3) return null;\n const [r, g, b] = tokens.map(parseChannel);\n const a = parseAlpha(alphaToken);\n if (r === null || g === null || b === null || a === null) return null;\n return { r, g, b, a };\n}\n\nfunction linearize(channel: number): number {\n const c = channel / 255;\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n}\n\n/**\n * WCAG 2.x relative luminance (0 = black … 1 = white) of a color {@link parseCssColor} understands,\n * or `null`. Alpha is ignored (the swatch is treated as opaque).\n */\nexport function getRelativeLuminance(color: string): number | null {\n const parsed = parseCssColor(color);\n if (!parsed) return null;\n return 0.2126 * linearize(parsed.r) + 0.7152 * linearize(parsed.g) + 0.0722 * linearize(parsed.b);\n}\n\n/**\n * Colors of the check glyph drawn on a selected swatch (`input-pickers#16`): black or white,\n * whichever has the higher WCAG contrast ratio against the swatch color, with the other one as a\n * halo under it so the glyph stays visible on any color. Colors that cannot be parsed without a\n * browser (named colors, `hsl()`, variables) get a black glyph with a white halo.\n *\n * This is the one runtime-computed exception to the token rule (C-TOKENS): the glyph sits on a\n * consumer-supplied color, not on a theme surface.\n */\nexport function getCheckColors(color: string): CheckColors {\n const luminance = getRelativeLuminance(color);\n if (luminance === null) return { glyph: BLACK, halo: WHITE };\n const onBlack = (luminance + 0.05) / 0.05;\n const onWhite = 1.05 / (luminance + 0.05);\n return onBlack >= onWhite ? { glyph: BLACK, halo: WHITE } : { glyph: WHITE, halo: BLACK };\n}\n"],"mappings":";;AA+BA,IAAMA,IAAQ,WAERC,IAAQ,WAERC,IAAY,yDACZC,IAAY,iCACZC,IAAY;AAElB,SAASC,EAAM,GAAe,GAAa,GAAqB;CAC9D,OAAO,KAAK,IAAIC,GAAK,KAAK,IAAIC,GAAKC,CAAK,CAAC;AAC3C;AAEA,SAASC,EAAU,GAAuB;CACxC,OAAO,KAAK,MAAMJ,EAAMG,GAAO,GAAG,GAAG,CAAC,CAAC,CACpC,SAAS,EAAE,CAAC,CACZ,SAAS,GAAG,GAAG;AACpB;AAEA,SAASE,EAAW,GAA0B;CAQ5C,IAAMC,KANJC,EAAO,UAAU,IACbA,EACG,MAAM,EAAE,CAAC,CACT,KAAK,MAAMC,IAAIA,CAAC,CAAC,CACjB,KAAK,EAAE,IACVD,EAAA,CACa,YAAY;CAC/B,OAAO;EACL,KAAK,IAAID,EAAM,MAAM,GAAG,CAAC;EACzB,OAAOA,EAAM,WAAW,IAAI,SAASA,EAAM,MAAM,GAAG,CAAC,GAAG,EAAE,IAAI;CAChE;AACF;AAQA,SAAgBG,EAAc,GAAgC;CAC5D,IAAMC,IAAQb,EAAU,KAAKM,EAAM,KAAK,CAAC;CACzC,OAAOO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A4B;CACzD,IAAMC,IAAYH,EAAqBC,CAAK;CAI5C,OAHIE,MAAc,SACDA,IAAY,OAAQ,OACrB,QAAQA,IAAY,OAFL;EAAE,OAAOnD;EAAO,MAAMC;CAAM,IAGC;EAAE,OAAOA;EAAO,MAAMD;CAAM;AAC1F"}
|
|
1
|
+
{"version":3,"file":"colorUtils.mjs","names":["BLACK","WHITE","HEX_INPUT","HEX_DRAFT","clamp","max","min","value","toHexByte","parseHexColor","bytes","parseHexBytes","parseHexInput","text","isHexDraft","formatHexColor","byte","alpha","rgb","normalizeHexColor","parsed","alphaToOpacity","parseChannel","percent","token","parseAlpha","RGB_FUNCTION","parseCssColor","hex","n","match","channelsPart","alphaPart","tokens","t","alphaToken","r","g","b","a","linearize","c","channel","getRelativeLuminance","color","getCheckColors","luminance","displayHue","h","wrapHue","displayColor","clampUnit","toPercent","toPosition","sameColor","railKeyTarget","modifiers","step","next","key","current","getArrowIntent","toward","orientation","colorAreaGradient","hsvToHex","HUE_SPECTRUM","colorSliderGradient","direction","alphaSliderGradient","opaque","transparency","areaValueText","labels","saturation","brightness","channels","name","getColorName","sliderValueText","degrees","alphaValueText","valueText","opacity","COLOR_THUMB_CLASSES","RAIL_ROOT_HORIZONTAL","RAIL_ROOT_VERTICAL","RAIL_TRACK_HORIZONTAL","RAIL_TRACK_VERTICAL","RAIL_GRADIENT","RAIL_INPUT_CLASSES","RAIL_INPUT_HORIZONTAL","RAIL_INPUT_VERTICAL","THUMB_TRACK_HORIZONTAL","THUMB_TRACK_VERTICAL","THUMB_POSITION_HORIZONTAL","THUMB_POSITION_VERTICAL"],"sources":["../../../src/components/input/colorUtils.ts"],"sourcesContent":["/**\n * Color helpers for ColorPicker, SwatchPicker and the HSV color parts: hex parsing and\n * normalisation (on the grammar of `src/lib/color.ts`), the alpha byte ↔ opacity percentage, and\n * the luminance-picked check glyph drawn on a user-supplied swatch.\n *\n * Internal (not exported from the package). Pure functions, no DOM access, so they run on the\n * server and in tests.\n */\nimport { clampUnit, hsvToHex, parseHexBytes, wrapHue } from '../../lib/color';\nimport { getArrowIntent, type Direction } from '../../lib/direction';\nimport type { HsvColor } from '../../lib/types';\nimport { getColorName } from './colorName';\n\n/** A parsed hex color: the `#rrggbb` part (lowercase) and the alpha byte (0–255). */\nexport interface HexColor {\n /** `#rrggbb`, lowercase. */\n rgb: string;\n /** Alpha byte, 0 (transparent) … 255 (opaque). */\n alpha: number;\n}\n\n/** An sRGB color with 0–255 channels and a 0–1 alpha. */\nexport interface RgbaColor {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\n/** Colors of the selected-swatch check glyph: the glyph and the halo drawn under it. */\nexport interface CheckColors {\n glyph: string;\n halo: string;\n}\n\n// wave-allow-color: luminance-picked check glyph on a user swatch (C-TOKENS exception, input-pickers#16)\nconst BLACK = '#000000';\n// wave-allow-color: luminance-picked check glyph on a user swatch (C-TOKENS exception, input-pickers#16)\nconst WHITE = '#ffffff';\n\nconst HEX_INPUT = /^#([0-9a-f]{6}|[0-9a-f]{8})$/i;\nconst HEX_DRAFT = /^#?[0-9a-f]{0,8}$/i;\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction toHexByte(value: number): string {\n return Math.round(clamp(value, 0, 255))\n .toString(16)\n .padStart(2, '0');\n}\n\n/**\n * Parses a hex color (`#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa`, case-insensitive, surrounding\n * whitespace ignored). Returns `null` for anything else (named colors, `rgb()`, a missing `#`).\n *\n * @example parseHexColor('#0F6CBD80') // { rgb: '#0f6cbd', alpha: 128 }\n */\nexport function parseHexColor(value: string): HexColor | null {\n const bytes = parseHexBytes(value);\n return bytes\n ? {\n rgb: `#${toHexByte(bytes.r)}${toHexByte(bytes.g)}${toHexByte(bytes.b)}`,\n alpha: bytes.alpha,\n }\n : null;\n}\n\n/**\n * Parses text typed into a hex field: only complete `#rrggbb` / `#rrggbbaa` values are accepted,\n * so the short forms a user passes through while typing (`#abc`) are never committed.\n */\nexport function parseHexInput(text: string): HexColor | null {\n return HEX_INPUT.test(text.trim()) ? parseHexColor(text) : null;\n}\n\n/**\n * Whether typed text can still become a hex color by typing more characters (an optional `#`\n * followed by at most 8 hex digits; surrounding whitespace ignored, like the parsers). `false`\n * means the text is invalid whatever follows.\n */\nexport function isHexDraft(text: string): boolean {\n return HEX_DRAFT.test(text.trim());\n}\n\n/**\n * Formats `#rrggbb` plus an alpha byte: `#rrggbb` when opaque (`alpha` 255, the default),\n * `#rrggbbaa` otherwise. The alpha byte is rounded and clamped to 0–255.\n */\nexport function formatHexColor(rgb: string, alpha = 255): string {\n const byte = Math.round(clamp(alpha, 0, 255));\n return byte === 255 ? rgb : rgb + toHexByte(byte);\n}\n\n/**\n * A hex color in the one form ColorPicker reports: `#rrggbb` in lower case, or `#rrggbbaa` when\n * the alpha byte is not 255 (short forms expanded, surrounding whitespace dropped). Returns `null`\n * for anything {@link parseHexColor} rejects.\n *\n * @example normalizeHexColor('#ABC') // '#aabbcc'\n * @example normalizeHexColor('#0f6cbdff') // '#0f6cbd'\n */\nexport function normalizeHexColor(value: string): string | null {\n const parsed = parseHexColor(value);\n return parsed ? formatHexColor(parsed.rgb, parsed.alpha) : null;\n}\n\n/** Alpha byte (0–255) → whole opacity percentage (0–100). */\nexport function alphaToOpacity(alpha: number): number {\n return Math.round((clamp(alpha, 0, 255) / 255) * 100);\n}\n\n/** Opacity percentage (0–100) → alpha byte (0–255). Inverse of {@link alphaToOpacity}. */\nexport function opacityToAlpha(opacity: number): number {\n return Math.round((clamp(opacity, 0, 100) / 100) * 255);\n}\n\nfunction parseChannel(token: string): number | null {\n const percent = token.endsWith('%');\n const n = Number(percent ? token.slice(0, -1) : token);\n if (!Number.isFinite(n)) return null;\n return clamp(percent ? (n / 100) * 255 : n, 0, 255);\n}\n\nfunction parseAlpha(token: string | undefined): number | null {\n if (token === undefined) return 1;\n const percent = token.endsWith('%');\n const n = Number(percent ? token.slice(0, -1) : token);\n if (!Number.isFinite(n)) return null;\n return clamp(percent ? n / 100 : n, 0, 1);\n}\n\nconst RGB_FUNCTION = /^rgba?\\(\\s*([^)]*)\\)$/i;\n\n/**\n * Parses the CSS colors that can be resolved without a browser: hex colors and `rgb()`/`rgba()`\n * (comma or space syntax, numbers or percentages, optional alpha). Returns `null` for named\n * colors, other color spaces and variables.\n */\nexport function parseCssColor(value: string): RgbaColor | null {\n const text = value.trim();\n const hex = parseHexColor(text);\n if (hex) {\n const n = parseInt(hex.rgb.slice(1), 16);\n return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255, a: hex.alpha / 255 };\n }\n const match = RGB_FUNCTION.exec(text);\n if (!match) return null;\n const [channelsPart, alphaPart]: Array<string | undefined> = match[1].split('/');\n const tokens = (channelsPart ?? '')\n .split(/[\\s,]+/)\n .map((t) => t.trim())\n .filter(Boolean);\n let alphaToken: string | undefined = alphaPart?.trim();\n if (alphaToken === undefined && tokens.length === 4) alphaToken = tokens.pop();\n if (tokens.length !== 3) return null;\n const [r, g, b] = tokens.map(parseChannel);\n const a = parseAlpha(alphaToken);\n if (r === null || g === null || b === null || a === null) return null;\n return { r, g, b, a };\n}\n\nfunction linearize(channel: number): number {\n const c = channel / 255;\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n}\n\n/**\n * WCAG 2.x relative luminance (0 = black … 1 = white) of a color {@link parseCssColor} understands,\n * or `null`. Alpha is ignored (the swatch is treated as opaque).\n */\nexport function getRelativeLuminance(color: string): number | null {\n const parsed = parseCssColor(color);\n if (!parsed) return null;\n return 0.2126 * linearize(parsed.r) + 0.7152 * linearize(parsed.g) + 0.0722 * linearize(parsed.b);\n}\n\n/**\n * Colors of the check glyph drawn on a selected swatch (`input-pickers#16`): black or white,\n * whichever has the higher WCAG contrast ratio against the swatch color, with the other one as a\n * halo under it so the glyph stays visible on any color. Colors that cannot be parsed without a\n * browser (named colors, `hsl()`, variables) get a black glyph with a white halo.\n *\n * This is the one runtime-computed exception to the token rule (C-TOKENS): the glyph sits on a\n * consumer-supplied color, not on a theme surface.\n */\nexport function getCheckColors(color: string): CheckColors {\n const luminance = getRelativeLuminance(color);\n if (luminance === null) return { glyph: BLACK, halo: WHITE };\n const onBlack = (luminance + 0.05) / 0.05;\n const onWhite = 1.05 / (luminance + 0.05);\n return onBlack >= onWhite ? { glyph: BLACK, halo: WHITE } : { glyph: WHITE, halo: BLACK };\n}\n\n// ---------------------------------------------------------------------------------------------\n// The HSV color parts: ColorArea, ColorSlider and AlphaSlider (spec P3-05)\n// ---------------------------------------------------------------------------------------------\n\n/** The channels of an HSV color that a part edits or names in a value text. */\nexport type ColorChannel = 'hue' | 'saturation' | 'value' | 'alpha';\n\n/** Which way a rail runs: left to right (mirrored in right-to-left layouts), or bottom to top. */\nexport type RailOrientation = 'horizontal' | 'vertical';\n\n/** The modifier keys of a key press. */\nexport interface KeyModifiers {\n shiftKey: boolean;\n altKey: boolean;\n ctrlKey: boolean;\n metaKey: boolean;\n}\n\n/**\n * A hue as a part shows it: 0–360 kept as given (360 is the end of a hue rail), any other finite\n * hue wrapped into [0, 360), and a hue that is not finite as 0.\n */\nexport function displayHue(h: number): number {\n return Number.isFinite(h) && h >= 0 && h <= 360 ? h : wrapHue(h);\n}\n\n/**\n * A color as a part shows it: the hue for display, saturation and brightness clamped to [0, 1]\n * (not a number: 0) and alpha clamped to [0, 1] (left out or not a number: 1).\n */\nexport function displayColor(color: HsvColor): Required<HsvColor> {\n return {\n h: displayHue(color.h),\n s: clampUnit(color.s, 0),\n v: clampUnit(color.v, 0),\n a: clampUnit(color.a, 1),\n };\n}\n\n/** A 0–1 channel as the whole percentage the range inputs and value texts use. */\nexport function toPercent(value: number): number {\n return Math.round(value * 100);\n}\n\n/** A 0–1 position as a CSS percentage with at most two decimals, for an inline custom property. */\nexport function toPosition(value: number): string {\n return `${Math.round(value * 10000) / 100}%`;\n}\n\n/** Whether two colors have the same channels (a missing alpha equals 1). */\nexport function sameColor(a: HsvColor, b: HsvColor): boolean {\n return a.h === b.h && a.s === b.s && a.v === b.v && (a.a ?? 1) === (b.a ?? 1);\n}\n\n/**\n * The value a rail (a range from 0 to `max`) moves to for a key press, or `null` for a key it\n * leaves alone: ArrowUp and ArrowDown by 1; ArrowRight and ArrowLeft by 1 toward the reading\n * direction's end and start (so mirrored in right-to-left layouts); Shift with an arrow, Page Up\n * and Page Down by 10; Home and End to 0 and `max`. A key with Alt, Ctrl or Meta belongs to the\n * browser. The result is clamped to the range.\n */\nexport function railKeyTarget(\n key: string,\n modifiers: KeyModifiers,\n dir: Direction,\n current: number,\n max: number,\n): number | null {\n if (modifiers.altKey || modifiers.ctrlKey || modifiers.metaKey) return null;\n const step = modifiers.shiftKey ? 10 : 1;\n let next: number;\n switch (key) {\n case 'ArrowUp':\n next = current + step;\n break;\n case 'ArrowDown':\n next = current - step;\n break;\n case 'ArrowRight':\n case 'ArrowLeft':\n next =\n current +\n (getArrowIntent(key, { orientation: 'horizontal', dir }) === 'next' ? step : -step);\n break;\n case 'PageUp':\n next = current + 10;\n break;\n case 'PageDown':\n next = current - 10;\n break;\n case 'Home':\n next = 0;\n break;\n case 'End':\n next = max;\n break;\n default:\n return null;\n }\n return Math.min(max, Math.max(0, next));\n}\n\nconst toward = (orientation: RailOrientation) =>\n orientation === 'vertical' ? 'to top' : 'to right';\n\n/** The field of a ColorArea at hue `h`: white to the pure hue left to right, black toward the bottom. */\nexport function colorAreaGradient(h: number): string {\n const hue = hsvToHex({ h, s: 1, v: 1 });\n // wave-allow-color: the saturation and brightness field of the user's color (runtime gradient)\n return `linear-gradient(to top, #000000, transparent), linear-gradient(to right, #ffffff, ${hue})`;\n}\n\n// wave-allow-color: the hue spectrum of a hue rail (runtime gradient data, not a theme color)\nconst HUE_SPECTRUM = '#ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000';\n\n/**\n * The rail of a ColorSlider: the hue spectrum, gray to the full color at the color's brightness\n * (saturation), or black to the color at full brightness (brightness).\n */\nexport function colorSliderGradient(\n channel: 'hue' | 'saturation' | 'value',\n color: Required<HsvColor>,\n orientation: RailOrientation,\n): string {\n const direction = toward(orientation);\n if (channel === 'hue') return `linear-gradient(${direction}, ${HUE_SPECTRUM})`;\n if (channel === 'saturation') {\n const gray = hsvToHex({ h: color.h, s: 0, v: color.v });\n const full = hsvToHex({ h: color.h, s: 1, v: color.v });\n return `linear-gradient(${direction}, ${gray}, ${full})`;\n }\n const bright = hsvToHex({ h: color.h, s: color.s, v: 1 });\n // wave-allow-color: the brightness rail runs from black to the color (runtime gradient)\n return `linear-gradient(${direction}, #000000, ${bright})`;\n}\n\n/** The rail of an AlphaSlider: transparent to the opaque color, or the reverse with `transparency`. */\nexport function alphaSliderGradient(\n color: Required<HsvColor>,\n transparency: boolean,\n orientation: RailOrientation,\n): string {\n const opaque = hsvToHex({ h: color.h, s: color.s, v: color.v });\n const direction = toward(orientation);\n return transparency\n ? `linear-gradient(${direction}, ${opaque}, transparent)`\n : `linear-gradient(${direction}, transparent, ${opaque})`;\n}\n\n/**\n * The value text of one of ColorArea's inputs: its own channel first, then the other one, then\n * the color's name (\"Saturation 72%, Brightness 40%, dark blue\"). `colorName` replaces the namer\n * (`''` leaves the name out); `valueText` replaces the whole text.\n */\nexport function areaValueText(\n color: Required<HsvColor>,\n channel: 'saturation' | 'value',\n labels: {\n saturation: string;\n brightness: string;\n colorName?: (color: HsvColor) => string;\n valueText?: (color: HsvColor, channel: 'saturation' | 'value') => string;\n },\n): string {\n if (labels.valueText) return labels.valueText(color, channel);\n const saturation = `${labels.saturation} ${toPercent(color.s)}%`;\n const brightness = `${labels.brightness} ${toPercent(color.v)}%`;\n const channels =\n channel === 'saturation' ? `${saturation}, ${brightness}` : `${brightness}, ${saturation}`;\n const name = (labels.colorName ?? getColorName)(color);\n return name ? `${channels}, ${name}` : channels;\n}\n\n/** The value text of a ColorSlider: \"210°, blue\" for hue, \"72%\" for saturation and brightness. */\nexport function sliderValueText(\n color: Required<HsvColor>,\n channel: 'hue' | 'saturation' | 'value',\n labels: {\n colorName?: (color: HsvColor) => string;\n valueText?: (color: HsvColor, channel: 'hue' | 'saturation' | 'value') => string;\n },\n): string {\n if (labels.valueText) return labels.valueText(color, channel);\n if (channel !== 'hue') return `${toPercent(channel === 'saturation' ? color.s : color.v)}%`;\n const degrees = `${Math.round(color.h)}°`;\n const name = (labels.colorName ?? getColorName)(color);\n return name ? `${degrees}, ${name}` : degrees;\n}\n\n/** The value text of an AlphaSlider: the opacity (\"40%\"), or the transparency with `transparency`. */\nexport function alphaValueText(\n color: Required<HsvColor>,\n transparency: boolean,\n valueText?: (color: HsvColor, transparency: boolean) => string,\n): string {\n if (valueText) return valueText(color, transparency);\n const opacity = toPercent(color.a);\n return `${transparency ? 100 - opacity : opacity}%`;\n}\n\n/**\n * The thumb of ColorArea, ColorSlider and AlphaSlider (decorative; the focused input is what\n * assistive technology reads): 24 px, filled from `--wave-color-thumb`, with a two-tone edge (a\n * `background` border inside a `foreground` ring) that shows on any color. Forced colors keep the\n * fill and draw the edge in system colors. Each part adds its own focus classes, keyed on its\n * named group, and its part class.\n */\nexport const COLOR_THUMB_CLASSES =\n 'pointer-events-none absolute size-6 rounded-full border-2 border-background bg-(--wave-color-thumb) ring-1 ring-foreground forced-colors:forced-color-adjust-none forced-colors:border-[Canvas] forced-colors:ring-[CanvasText]';\n\n/** The root of a horizontal ColorSlider or AlphaSlider (24 px, as tall as the thumb). */\nexport const RAIL_ROOT_HORIZONTAL = 'h-6 w-full items-center';\n/** The root of a vertical one: a size container, so the turned input can be as long as it is tall. */\nexport const RAIL_ROOT_VERTICAL = 'h-40 w-6 flex-col items-center [container-type:size]';\n/** The drawn rail, inset by half a thumb at both ends (a horizontal one mirrors in right-to-left layouts). */\nexport const RAIL_TRACK_HORIZONTAL = 'mx-3 h-3 flex-1 wave-rtl:-scale-x-100';\nexport const RAIL_TRACK_VERTICAL = 'my-3 w-3 flex-1';\n/** The rail's gradient, read from the inline `--wave-color-slider-gradient` property. */\nexport const RAIL_GRADIENT = 'bg-(image:--wave-color-slider-gradient)';\n/**\n * The native range input of a rail: over the whole slider and invisible, with its own thumb as\n * wide as the drawn one, so a press lands on the value under the drawn thumb.\n */\nexport const RAIL_INPUT_CLASSES =\n 'absolute m-0 cursor-pointer appearance-none opacity-0 disabled:cursor-not-allowed [&::-webkit-slider-thumb]:size-6 [&::-webkit-slider-thumb]:appearance-none [&::-moz-range-thumb]:size-6';\nexport const RAIL_INPUT_HORIZONTAL = 'inset-0 size-full';\n/** Turned a quarter, so its start (the minimum) is at the bottom; it carries `dir=\"ltr\"`. */\nexport const RAIL_INPUT_VERTICAL =\n 'start-1/2 top-1/2 h-6 w-[100cqh] -translate-x-1/2 wave-rtl:translate-x-1/2 -translate-y-1/2 -rotate-90';\n/** The box the thumb moves in: the rail's length, so its center meets the native thumb's. */\nexport const THUMB_TRACK_HORIZONTAL = 'pointer-events-none absolute inset-x-3 inset-y-0';\nexport const THUMB_TRACK_VERTICAL = 'pointer-events-none absolute inset-x-0 inset-y-3';\n/** The thumb's place along the rail, read from the inline `--wave-color-slider-position` property. */\nexport const THUMB_POSITION_HORIZONTAL =\n 'start-(--wave-color-slider-position) top-1/2 -translate-x-1/2 wave-rtl:translate-x-1/2 -translate-y-1/2';\nexport const THUMB_POSITION_VERTICAL =\n 'bottom-(--wave-color-slider-position) start-1/2 -translate-x-1/2 wave-rtl:translate-x-1/2 translate-y-1/2';\n"],"mappings":";;;;;AAoCA,IAAMA,IAAQ,WAERC,IAAQ,WAERC,IAAY,iCACZC,IAAY;AAElB,SAASC,EAAM,GAAe,GAAa,GAAqB;CAC9D,OAAO,KAAK,IAAIC,GAAK,KAAK,IAAIC,GAAKC,CAAK,CAAC;AAC3C;AAEA,SAASC,EAAU,GAAuB;CACxC,OAAO,KAAK,MAAMJ,EAAMG,GAAO,GAAG,GAAG,CAAC,CAAC,CACpC,SAAS,EAAE,CAAC,CACZ,SAAS,GAAG,GAAG;AACpB;AAQA,SAAgBE,EAAc,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GAAGF,EAAO,WAAW,GAAGrB,EAAUR,EAAM,CAAC,EAAE,IACxDgC,IACJlC,MAAY,eAAe,GAAGgC,EAAW,IAAIC,MAAe,GAAGA,EAAW,IAAID,KAC1EG,KAAQJ,EAAO,aAAaK,EAAA,CAAclC,CAAK;CACrD,OAAOiC,IAAO,GAAGD,EAAS,IAAIC,MAASD;AACzC;AAGA,SAAgBG,EACd,GACA,GACA,GAIQ;CACR,IAAIN,EAAO,WAAW,OAAOA,EAAO,UAAU7B,GAAOF,CAAO;CAC5D,IAAIA,MAAY,OAAO,OAAO,GAAGU,EAAUV,MAAY,eAAeE,EAAM,IAAIA,EAAM,CAAC,EAAE;CACzF,IAAMoC,IAAU,GAAG,KAAK,MAAMpC,EAAM,CAAC,EAAE,IACjCiC,KAAQJ,EAAO,aAAaK,EAAA,CAAclC,CAAK;CACrD,OAAOiC,IAAO,GAAGG,EAAQ,IAAIH,MAASG;AACxC;AAGA,SAAgBC,EACd,GACA,GACA,GACQ;CACR,IAAIC,GAAW,OAAOA,EAAUtC,GAAO2B,CAAY;CACnD,IAAMY,IAAU/B,EAAUR,EAAM,CAAC;CACjC,OAAO,GAAG2B,IAAe,MAAMY,IAAUA,EAAQ;AACnD;AASA,IAAaC,IACX,mOAGWC,IAAuB,2BAEvBC,IAAqB,wDAErBC,IAAwB,yCACxBC,IAAsB,mBAEtBC,IAAgB,2CAKhBC,IACX,6LACWC,IAAwB,qBAExBC,IACX,0GAEWC,IAAyB,oDACzBC,IAAuB,oDAEvBC,IACX,2GACWC,IACX"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/children.cjs");let n=require("react");n=e.__toESM(n,1);var r=Symbol.for(`wave.fieldLabel`);function i(e){return e[r]=!0,e}function a(e){if(!n.isValidElement(e))return!1;let i=t.getElementType(e);return(typeof i==`function`||typeof i==`object`&&!!i)&&i[r]===!0}exports.FIELD_LABEL=r,exports.isFieldLabelElement=a,exports.markFieldLabel=i;
|
|
2
|
+
//# sourceMappingURL=fieldLabel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldLabel.cjs","names":["React","getElementType","require_runtime","require_children","react","FIELD_LABEL","markFieldLabel","component","isFieldLabelElement","node","type"],"sources":["../../../src/components/input/fieldLabel.ts"],"sourcesContent":["import * as React from 'react';\nimport { getElementType } from '../../lib/children';\nimport type { CoreSize, TextWeight } from '../../lib/types';\n\n/**\n * Marks the components whose element Field renders as its label instead of wrapping it in its own\n * `<label>` (Label, InfoLabel). A marker, not an import, so that Field never pulls InfoLabel's\n * overlay code into a bundle. Internal.\n */\nexport const FIELD_LABEL: symbol = Symbol.for('wave.fieldLabel');\n\n/** The props Field gives a label element (each only when the element does not set it). */\nexport interface FieldLabelElementProps {\n id?: string;\n htmlFor?: string;\n required?: boolean | React.ReactNode;\n size?: CoreSize;\n weight?: TextWeight;\n className?: string;\n}\n\n/** Marks `component` as a Field label element; call it next to `displayName`. */\nexport function markFieldLabel<T extends object>(component: T): T {\n (component as Record<symbol, unknown>)[FIELD_LABEL] = true;\n return component;\n}\n\n/** Whether `node` is an element of a marked component (lazy client references resolved). */\nexport function isFieldLabelElement(\n node: React.ReactNode,\n): node is React.ReactElement<FieldLabelElementProps> {\n if (!React.isValidElement(node)) return false;\n const type = getElementType(node);\n return (\n (typeof type === 'function' || (typeof type === 'object' && type !== null)) &&\n (type as Record<symbol, unknown>)[FIELD_LABEL] === true\n );\n}\n"],"mappings":"iJASA,IAAaK,EAAsB,OAAO,IAAI,iBAAiB,EAa/D,SAAgBC,EAAiC,EAAiB,CAEhE,MADA,GAAuCD,GAAe,GAC/CE,CACT,CAGA,SAAgBC,EACd,EACoD,CACpD,GAAI,CAACR,EAAM,eAAeS,CAAI,EAAG,MAAO,GACxC,IAAMC,EAAOT,EAAAA,eAAeQ,CAAI,EAChC,OACG,OAAOC,GAAS,YAAe,OAAOA,GAAS,YAAYA,IAC3DA,EAAiCL,KAAiB,EAEvD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getElementType as e } from "../../lib/children.mjs";
|
|
3
|
+
import * as t from "react";
|
|
4
|
+
//#region src/components/input/fieldLabel.ts
|
|
5
|
+
var n = Symbol.for("wave.fieldLabel");
|
|
6
|
+
function r(e) {
|
|
7
|
+
return e[n] = !0, e;
|
|
8
|
+
}
|
|
9
|
+
function i(r) {
|
|
10
|
+
if (!t.isValidElement(r)) return !1;
|
|
11
|
+
let i = e(r);
|
|
12
|
+
return (typeof i == "function" || typeof i == "object" && !!i) && i[n] === !0;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { n as FIELD_LABEL, i as isFieldLabelElement, r as markFieldLabel };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=fieldLabel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldLabel.mjs","names":["React","FIELD_LABEL","markFieldLabel","component","isFieldLabelElement","node","type","getElementType"],"sources":["../../../src/components/input/fieldLabel.ts"],"sourcesContent":["import * as React from 'react';\nimport { getElementType } from '../../lib/children';\nimport type { CoreSize, TextWeight } from '../../lib/types';\n\n/**\n * Marks the components whose element Field renders as its label instead of wrapping it in its own\n * `<label>` (Label, InfoLabel). A marker, not an import, so that Field never pulls InfoLabel's\n * overlay code into a bundle. Internal.\n */\nexport const FIELD_LABEL: symbol = Symbol.for('wave.fieldLabel');\n\n/** The props Field gives a label element (each only when the element does not set it). */\nexport interface FieldLabelElementProps {\n id?: string;\n htmlFor?: string;\n required?: boolean | React.ReactNode;\n size?: CoreSize;\n weight?: TextWeight;\n className?: string;\n}\n\n/** Marks `component` as a Field label element; call it next to `displayName`. */\nexport function markFieldLabel<T extends object>(component: T): T {\n (component as Record<symbol, unknown>)[FIELD_LABEL] = true;\n return component;\n}\n\n/** Whether `node` is an element of a marked component (lazy client references resolved). */\nexport function isFieldLabelElement(\n node: React.ReactNode,\n): node is React.ReactElement<FieldLabelElementProps> {\n if (!React.isValidElement(node)) return false;\n const type = getElementType(node);\n return (\n (typeof type === 'function' || (typeof type === 'object' && type !== null)) &&\n (type as Record<symbol, unknown>)[FIELD_LABEL] === true\n );\n}\n"],"mappings":";;;;AASA,IAAaC,IAAsB,OAAO,IAAI,iBAAiB;AAa/D,SAAgBC,EAAiC,GAAiB;CAEhE,OADA,EAAuCD,KAAe,IAC/CE;AACT;AAGA,SAAgBC,EACd,GACoD;CACpD,IAAI,CAACJ,EAAM,eAAeK,CAAI,GAAG,OAAO;CACxC,IAAMC,IAAOC,EAAeF,CAAI;CAChC,QACG,OAAOC,KAAS,cAAe,OAAOA,KAAS,cAAYA,MAC3DA,EAAiCL,OAAiB;AAEvD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../hooks/useFieldControl.cjs"),t=require("../provider/WaveProvider.cjs");var n=[`small`,`medium`,`large`],r=[`outline`,`underline`,`filled-darker`,`filled-lighter`];function i(i,a,o={}){let s=e.useFieldContext(),{inputDefaults:c}=t.useWaveTheme(),l=o.sizes??n,u=e=>e!==void 0&&l.includes(e),d=e=>typeof e==`string`&&r.includes(e);return{size:(u(i)?i:void 0)??(u(s?.size)?s.size:void 0)??(u(c.size)?c.size:void 0)??o.defaultSize??`medium`,appearance:(d(a)?a:void 0)??(d(c.appearance)?c.appearance:void 0)??`outline`}}function a(e){return typeof e==`number`?e:typeof e==`string`&&/^\d+$/.test(e)?Number(e):void 0}exports.legacyNativeSize=a,exports.useInputLook=i;
|
|
2
|
+
//# sourceMappingURL=inputLook.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputLook.cjs","names":["useFieldContext","useWaveTheme","require_useFieldControl","require_WaveProvider","CORE_SIZES","APPEARANCES","useInputLook","field","sizes","options","fits","candidate","isAppearance","size","inputDefaults","appearance","legacyNativeSize"],"sources":["../../../src/components/input/inputLook.ts"],"sourcesContent":["import type { CoreSize, InputAppearance, Size } from '../../lib/types';\nimport { useFieldContext } from '../../hooks/useFieldControl';\nimport { useWaveTheme } from '../provider/WaveProvider';\n\nconst CORE_SIZES: readonly CoreSize[] = ['small', 'medium', 'large'];\nconst APPEARANCES: readonly string[] = [\n 'outline',\n 'underline',\n 'filled-darker',\n 'filled-lighter',\n] satisfies readonly InputAppearance[];\n\n/** Options of {@link useInputLook}. */\nexport interface InputLookOptions<S extends Size> {\n /**\n * The sizes the control supports; an own, Field or provider size outside them is skipped.\n * @default the three core sizes (`small`, `medium`, `large`)\n */\n sizes?: readonly S[];\n /**\n * The size when nothing else applies. Pass it when `sizes` leaves out `medium`: the fallback is\n * not checked against `sizes`.\n * @default 'medium'\n */\n defaultSize?: S;\n}\n\n/**\n * The size and appearance a text control or picker renders (Phase 4 D6): its own props, then the\n * surrounding Field's `size`, then `WaveProvider inputDefaults`, then the defaults (`medium`,\n * `outline`). `undefined` props fall through like absent ones, and so do values outside the\n * unions (from untyped code: plain JS, CMS config, an untyped `inputDefaults`): an own or provider\n * size outside `sizes`, or an appearance other than the four, is skipped, so the returned values\n * (and the `data-size`/`data-appearance` attributes built from them) are always supported ones.\n *\n * @internal Not exported from the package.\n */\nexport function useInputLook<S extends Size = CoreSize>(\n size: S | undefined,\n appearance: InputAppearance | undefined,\n options: InputLookOptions<S> = {},\n): { size: S; appearance: InputAppearance } {\n const field = useFieldContext();\n const { inputDefaults } = useWaveTheme();\n const sizes = (options.sizes ?? CORE_SIZES) as readonly Size[];\n const fits = (candidate: Size | undefined): candidate is S =>\n candidate !== undefined && sizes.includes(candidate);\n const isAppearance = (candidate: unknown): candidate is InputAppearance =>\n typeof candidate === 'string' && APPEARANCES.includes(candidate);\n const resolvedSize =\n (fits(size) ? size : undefined) ??\n (fits(field?.size) ? field.size : undefined) ??\n (fits(inputDefaults.size) ? inputDefaults.size : undefined) ??\n options.defaultSize ??\n ('medium' as S);\n const resolvedAppearance =\n (isAppearance(appearance) ? appearance : undefined) ??\n (isAppearance(inputDefaults.appearance) ? inputDefaults.appearance : undefined) ??\n 'outline';\n return { size: resolvedSize, appearance: resolvedAppearance };\n}\n\n/**\n * The numeric legacy form of `size` on Input and Select (the native attribute, deprecated in\n * favour of `htmlSize`): a number, or a string of digits only, which untyped code wrote HTML style\n * before 0.9 (`size=\"20\"`). `undefined` for anything else, which `useInputLook` then resolves as a\n * design size.\n *\n * @internal Not exported from the package.\n */\nexport function legacyNativeSize(size: unknown): number | undefined {\n if (typeof size === 'number') return size;\n return typeof size === 'string' && /^\\d+$/.test(size) ? Number(size) : undefined;\n}\n"],"mappings":"0GAIA,IAAMI,EAAkC,CAAC,QAAS,SAAU,OAAO,EAC7DC,EAAiC,CACrC,UACA,YACA,gBACA,gBACF,EA2BA,SAAgBC,EACd,EACA,EACA,EAA+B,CAAC,EACU,CAC1C,IAAMC,EAAQP,EAAAA,gBAAgB,EACxB,CAAE,iBAAkBC,EAAAA,aAAa,EACjCO,EAASC,EAAQ,OAASL,EAC1BM,EAAQ,GACZC,IAAc,IAAA,IAAaH,EAAM,SAASG,CAAS,EAC/CC,EAAgB,GACpB,OAAOD,GAAc,UAAYN,EAAY,SAASM,CAAS,EAWjE,MAAO,CAAE,MATND,EAAKG,CAAI,EAAIA,EAAO,IAAA,MACpBH,EAAKH,GAAO,IAAI,EAAIA,EAAM,KAAO,IAAA,MACjCG,EAAKI,EAAc,IAAI,EAAIA,EAAc,KAAO,IAAA,KACjDL,EAAQ,aACP,SAK0B,YAH1BG,EAAaG,CAAU,EAAIA,EAAa,IAAA,MACxCH,EAAaE,EAAc,UAAU,EAAIA,EAAc,WAAa,IAAA,KACrE,SAC0D,CAC9D,CAUA,SAAgBE,EAAiB,EAAmC,CAElE,OADI,OAAOH,GAAS,SAAiBA,EAC9B,OAAOA,GAAS,UAAY,QAAQ,KAAKA,CAAI,EAAI,OAAOA,CAAI,EAAI,IAAA,EACzE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useFieldContext as e } from "../../hooks/useFieldControl.mjs";
|
|
3
|
+
import { useWaveTheme as t } from "../provider/WaveProvider.mjs";
|
|
4
|
+
//#region src/components/input/inputLook.ts
|
|
5
|
+
var n = [
|
|
6
|
+
"small",
|
|
7
|
+
"medium",
|
|
8
|
+
"large"
|
|
9
|
+
], r = [
|
|
10
|
+
"outline",
|
|
11
|
+
"underline",
|
|
12
|
+
"filled-darker",
|
|
13
|
+
"filled-lighter"
|
|
14
|
+
];
|
|
15
|
+
function i(i, a, o = {}) {
|
|
16
|
+
let s = e(), { inputDefaults: c } = t(), l = o.sizes ?? n, u = (e) => e !== void 0 && l.includes(e), d = (e) => typeof e == "string" && r.includes(e);
|
|
17
|
+
return {
|
|
18
|
+
size: (u(i) ? i : void 0) ?? (u(s?.size) ? s.size : void 0) ?? (u(c.size) ? c.size : void 0) ?? o.defaultSize ?? "medium",
|
|
19
|
+
appearance: (d(a) ? a : void 0) ?? (d(c.appearance) ? c.appearance : void 0) ?? "outline"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function a(e) {
|
|
23
|
+
return typeof e == "number" ? e : typeof e == "string" && /^\d+$/.test(e) ? Number(e) : void 0;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { a as legacyNativeSize, i as useInputLook };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=inputLook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputLook.mjs","names":["CORE_SIZES","APPEARANCES","useInputLook","field","useFieldContext","useWaveTheme","sizes","options","fits","candidate","isAppearance","size","inputDefaults","appearance","legacyNativeSize"],"sources":["../../../src/components/input/inputLook.ts"],"sourcesContent":["import type { CoreSize, InputAppearance, Size } from '../../lib/types';\nimport { useFieldContext } from '../../hooks/useFieldControl';\nimport { useWaveTheme } from '../provider/WaveProvider';\n\nconst CORE_SIZES: readonly CoreSize[] = ['small', 'medium', 'large'];\nconst APPEARANCES: readonly string[] = [\n 'outline',\n 'underline',\n 'filled-darker',\n 'filled-lighter',\n] satisfies readonly InputAppearance[];\n\n/** Options of {@link useInputLook}. */\nexport interface InputLookOptions<S extends Size> {\n /**\n * The sizes the control supports; an own, Field or provider size outside them is skipped.\n * @default the three core sizes (`small`, `medium`, `large`)\n */\n sizes?: readonly S[];\n /**\n * The size when nothing else applies. Pass it when `sizes` leaves out `medium`: the fallback is\n * not checked against `sizes`.\n * @default 'medium'\n */\n defaultSize?: S;\n}\n\n/**\n * The size and appearance a text control or picker renders (Phase 4 D6): its own props, then the\n * surrounding Field's `size`, then `WaveProvider inputDefaults`, then the defaults (`medium`,\n * `outline`). `undefined` props fall through like absent ones, and so do values outside the\n * unions (from untyped code: plain JS, CMS config, an untyped `inputDefaults`): an own or provider\n * size outside `sizes`, or an appearance other than the four, is skipped, so the returned values\n * (and the `data-size`/`data-appearance` attributes built from them) are always supported ones.\n *\n * @internal Not exported from the package.\n */\nexport function useInputLook<S extends Size = CoreSize>(\n size: S | undefined,\n appearance: InputAppearance | undefined,\n options: InputLookOptions<S> = {},\n): { size: S; appearance: InputAppearance } {\n const field = useFieldContext();\n const { inputDefaults } = useWaveTheme();\n const sizes = (options.sizes ?? CORE_SIZES) as readonly Size[];\n const fits = (candidate: Size | undefined): candidate is S =>\n candidate !== undefined && sizes.includes(candidate);\n const isAppearance = (candidate: unknown): candidate is InputAppearance =>\n typeof candidate === 'string' && APPEARANCES.includes(candidate);\n const resolvedSize =\n (fits(size) ? size : undefined) ??\n (fits(field?.size) ? field.size : undefined) ??\n (fits(inputDefaults.size) ? inputDefaults.size : undefined) ??\n options.defaultSize ??\n ('medium' as S);\n const resolvedAppearance =\n (isAppearance(appearance) ? appearance : undefined) ??\n (isAppearance(inputDefaults.appearance) ? inputDefaults.appearance : undefined) ??\n 'outline';\n return { size: resolvedSize, appearance: resolvedAppearance };\n}\n\n/**\n * The numeric legacy form of `size` on Input and Select (the native attribute, deprecated in\n * favour of `htmlSize`): a number, or a string of digits only, which untyped code wrote HTML style\n * before 0.9 (`size=\"20\"`). `undefined` for anything else, which `useInputLook` then resolves as a\n * design size.\n *\n * @internal Not exported from the package.\n */\nexport function legacyNativeSize(size: unknown): number | undefined {\n if (typeof size === 'number') return size;\n return typeof size === 'string' && /^\\d+$/.test(size) ? Number(size) : undefined;\n}\n"],"mappings":";;;;AAIA,IAAMA,IAAkC;CAAC;CAAS;CAAU;AAAO,GAC7DC,IAAiC;CACrC;CACA;CACA;CACA;AACF;AA2BA,SAAgBC,EACd,GACA,GACA,IAA+B,CAAC,GACU;CAC1C,IAAMC,IAAQC,EAAgB,GACxB,EAAE,qBAAkBC,EAAa,GACjCC,IAASC,EAAQ,SAASP,GAC1BQ,KAAQ,MACZC,MAAc,KAAA,KAAaH,EAAM,SAASG,CAAS,GAC/CC,KAAgB,MACpB,OAAOD,KAAc,YAAYR,EAAY,SAASQ,CAAS;CAWjE,OAAO;EAAE,OATND,EAAKG,CAAI,IAAIA,IAAO,KAAA,OACpBH,EAAKL,GAAO,IAAI,IAAIA,EAAM,OAAO,KAAA,OACjCK,EAAKI,EAAc,IAAI,IAAIA,EAAc,OAAO,KAAA,MACjDL,EAAQ,eACP;EAK0B,aAH1BG,EAAaG,CAAU,IAAIA,IAAa,KAAA,OACxCH,EAAaE,EAAc,UAAU,IAAIA,EAAc,aAAa,KAAA,MACrE;CAC0D;AAC9D;AAUA,SAAgBE,EAAiB,GAAmC;CAElE,OADI,OAAOH,KAAS,WAAiBA,IAC9B,OAAOA,KAAS,YAAY,QAAQ,KAAKA,CAAI,IAAI,OAAOA,CAAI,IAAI,KAAA;AACzE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";var
|
|
1
|
+
"use client";const e=require("../../lib/cn.cjs"),t=require("../../lib/styles.cjs");var n=`absolute flex h-6 w-6 items-center justify-center rounded bg-transparent p-0 text-muted-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:hover:text-foreground`,r={small:e.cn(`size-5`,t.hitAreaLayer),medium:``,large:`size-8`};function i(t=`medium`,i=`outline`){return e.cn(n,r[t],i===`filled-darker`&&`not-disabled:not-aria-disabled:hover:bg-subtle-pressed`)}var a={small:[`end-1`,`end-7`],medium:[`end-1`,`end-7`],large:[`end-1`,`end-9`]};function o(e,t){return a[e][t-1]}var s={small:[`pe-7`,`pe-13`],medium:[`pe-8`,`pe-14`],large:[`pe-10`,`pe-18`]},c={small:{chevron:12,icon:12},medium:{chevron:12,icon:16},large:{chevron:16,icon:20}};function l(e,t){return c[e][t]}function u(e,t=`medium`){if(!(e<=0))return s[t][+(e>=2)]}exports.PICKER_ICON_BUTTON_CLASSES=n,exports.pickerButtonOffset=o,exports.pickerEndPadding=u,exports.pickerGlyphSize=l,exports.pickerIconButtonClasses=i;
|
|
2
2
|
//# sourceMappingURL=pickerStyles.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickerStyles.cjs","names":["PICKER_ICON_BUTTON_CLASSES","
|
|
1
|
+
{"version":3,"file":"pickerStyles.cjs","names":["cn","hitAreaLayer","require_cn","require_styles","PICKER_ICON_BUTTON_CLASSES","BUTTON_BOX","pickerIconButtonClasses","size","appearance","BUTTON_OFFSETS","pickerButtonOffset","position","END_PADDINGS","GLYPHS","pickerGlyphSize","kind","pickerEndPadding"],"sources":["../../../src/components/input/pickerStyles.ts"],"sourcesContent":["/**\n * Classes shared by the pickers of the combobox family (Combobox, Dropdown, TimePicker).\n * Component-private: not exported from the package.\n */\n\nimport { cn } from '../../lib/cn';\nimport { hitAreaLayer } from '../../lib/styles';\nimport type { CoreSize, InputAppearance } from '../../lib/types';\n\n/**\n * An icon button at the end of a picker's control (its clear and expand buttons): a 24×24px\n * target that the caller positions (`end-1`, `end-7`) and gives `focusRing` and `disabledStyles`.\n * It sets its own padding and background (C-NATIVE: an app-wide `button` rule would otherwise pad\n * and fill it) and gates its hover colors on the enabled state.\n */\nexport const PICKER_ICON_BUTTON_CLASSES =\n 'absolute flex h-6 w-6 items-center justify-center rounded bg-transparent p-0 text-muted-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:hover:text-foreground';\n\n/** The button box of each size: 20px with a 24px hit layer, 24px (the 0.7 box) or 32px. */\nconst BUTTON_BOX: Readonly<Record<CoreSize, string>> = {\n small: cn('size-5', hitAreaLayer),\n medium: '',\n large: 'size-8',\n};\n\n/**\n * The classes of a picker's icon button at a size and appearance (Phase 4 D11): the 0.7 classes,\n * the size's box and, on `filled-darker`, a hover fill one step darker than the field.\n */\nexport function pickerIconButtonClasses(\n size: CoreSize = 'medium',\n appearance: InputAppearance = 'outline',\n): string {\n return cn(\n PICKER_ICON_BUTTON_CLASSES,\n BUTTON_BOX[size],\n appearance === 'filled-darker' && 'not-disabled:not-aria-disabled:hover:bg-subtle-pressed',\n );\n}\n\nconst BUTTON_OFFSETS: Readonly<Record<CoreSize, readonly [string, string]>> = {\n small: ['end-1', 'end-7'],\n medium: ['end-1', 'end-7'],\n large: ['end-1', 'end-9'],\n};\n\n/** The inline-end offset of a picker's first or second icon button (the second sits before it). */\nexport function pickerButtonOffset(size: CoreSize, position: 1 | 2): string {\n return BUTTON_OFFSETS[size][position - 1];\n}\n\nconst END_PADDINGS: Readonly<Record<CoreSize, readonly [string, string]>> = {\n small: ['pe-7', 'pe-13'],\n medium: ['pe-8', 'pe-14'],\n large: ['pe-10', 'pe-18'],\n};\n\n/** The glyph sizes of each size: the chevron, and the other icons (clear, calendar). */\nconst GLYPHS: Readonly<Record<CoreSize, { chevron: number; icon: number }>> = {\n small: { chevron: 12, icon: 12 },\n medium: { chevron: 12, icon: 16 },\n large: { chevron: 16, icon: 20 },\n};\n\n/** The pixel size of a picker glyph at a size. */\nexport function pickerGlyphSize(size: CoreSize, kind: 'chevron' | 'icon'): number {\n return GLYPHS[size][kind];\n}\n\n/**\n * The end padding that keeps a picker's text clear of the buttons at its end: per size and button\n * count (one or two buttons at the end). At medium (the default), `pe-8` for one button, `pe-14`\n * for two, nothing without one.\n */\nexport function pickerEndPadding(buttons: number, size: CoreSize = 'medium'): string | undefined {\n if (buttons <= 0) return undefined;\n return END_PADDINGS[size][buttons >= 2 ? 1 : 0];\n}\n"],"mappings":"mFAeA,IAAaI,EACX,+MAGIC,EAAiD,CACrD,MAAOL,EAAAA,GAAG,SAAUC,EAAAA,YAAY,EAChC,OAAQ,GACR,MAAO,QACT,EAMA,SAAgBK,EACd,EAAiB,SACjB,EAA8B,UACtB,CACR,OAAON,EAAAA,GACLI,EACAC,EAAWE,GACXC,IAAe,iBAAmB,wDACpC,CACF,CAEA,IAAMC,EAAwE,CAC5E,MAAO,CAAC,QAAS,OAAO,EACxB,OAAQ,CAAC,QAAS,OAAO,EACzB,MAAO,CAAC,QAAS,OAAO,CAC1B,EAGA,SAAgBC,EAAmB,EAAgB,EAAyB,CAC1E,OAAOD,EAAeF,EAAK,CAACI,EAAW,EACzC,CAEA,IAAMC,EAAsE,CAC1E,MAAO,CAAC,OAAQ,OAAO,EACvB,OAAQ,CAAC,OAAQ,OAAO,EACxB,MAAO,CAAC,QAAS,OAAO,CAC1B,EAGMC,EAAwE,CAC5E,MAAO,CAAE,QAAS,GAAI,KAAM,EAAG,EAC/B,OAAQ,CAAE,QAAS,GAAI,KAAM,EAAG,EAChC,MAAO,CAAE,QAAS,GAAI,KAAM,EAAG,CACjC,EAGA,SAAgBC,EAAgB,EAAgB,EAAkC,CAChF,OAAOD,EAAON,EAAK,CAACQ,EACtB,CAOA,SAAgBC,EAAiB,EAAiB,EAAiB,SAA8B,CAC/F,GAAI,KAAW,GACf,OAAOJ,EAAaL,EAAK,CAAC,KAAW,GACvC"}
|
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { hitAreaLayer as t } from "../../lib/styles.mjs";
|
|
2
4
|
//#region src/components/input/pickerStyles.ts
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
var n = "absolute flex h-6 w-6 items-center justify-center rounded bg-transparent p-0 text-muted-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:hover:text-foreground", r = {
|
|
6
|
+
small: e("size-5", t),
|
|
7
|
+
medium: "",
|
|
8
|
+
large: "size-8"
|
|
9
|
+
};
|
|
10
|
+
function i(t = "medium", i = "outline") {
|
|
11
|
+
return e(n, r[t], i === "filled-darker" && "not-disabled:not-aria-disabled:hover:bg-subtle-pressed");
|
|
12
|
+
}
|
|
13
|
+
var a = {
|
|
14
|
+
small: ["end-1", "end-7"],
|
|
15
|
+
medium: ["end-1", "end-7"],
|
|
16
|
+
large: ["end-1", "end-9"]
|
|
17
|
+
};
|
|
18
|
+
function o(e, t) {
|
|
19
|
+
return a[e][t - 1];
|
|
20
|
+
}
|
|
21
|
+
var s = {
|
|
22
|
+
small: ["pe-7", "pe-13"],
|
|
23
|
+
medium: ["pe-8", "pe-14"],
|
|
24
|
+
large: ["pe-10", "pe-18"]
|
|
25
|
+
}, c = {
|
|
26
|
+
small: {
|
|
27
|
+
chevron: 12,
|
|
28
|
+
icon: 12
|
|
29
|
+
},
|
|
30
|
+
medium: {
|
|
31
|
+
chevron: 12,
|
|
32
|
+
icon: 16
|
|
33
|
+
},
|
|
34
|
+
large: {
|
|
35
|
+
chevron: 16,
|
|
36
|
+
icon: 20
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
function l(e, t) {
|
|
40
|
+
return c[e][t];
|
|
41
|
+
}
|
|
42
|
+
function u(e, t = "medium") {
|
|
43
|
+
if (!(e <= 0)) return s[t][+(e >= 2)];
|
|
6
44
|
}
|
|
7
45
|
//#endregion
|
|
8
|
-
export {
|
|
46
|
+
export { n as PICKER_ICON_BUTTON_CLASSES, o as pickerButtonOffset, u as pickerEndPadding, l as pickerGlyphSize, i as pickerIconButtonClasses };
|
|
9
47
|
|
|
10
48
|
//# sourceMappingURL=pickerStyles.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickerStyles.mjs","names":["PICKER_ICON_BUTTON_CLASSES","
|
|
1
|
+
{"version":3,"file":"pickerStyles.mjs","names":["PICKER_ICON_BUTTON_CLASSES","BUTTON_BOX","cn","hitAreaLayer","pickerIconButtonClasses","size","appearance","BUTTON_OFFSETS","pickerButtonOffset","position","END_PADDINGS","GLYPHS","pickerGlyphSize","kind","pickerEndPadding"],"sources":["../../../src/components/input/pickerStyles.ts"],"sourcesContent":["/**\n * Classes shared by the pickers of the combobox family (Combobox, Dropdown, TimePicker).\n * Component-private: not exported from the package.\n */\n\nimport { cn } from '../../lib/cn';\nimport { hitAreaLayer } from '../../lib/styles';\nimport type { CoreSize, InputAppearance } from '../../lib/types';\n\n/**\n * An icon button at the end of a picker's control (its clear and expand buttons): a 24×24px\n * target that the caller positions (`end-1`, `end-7`) and gives `focusRing` and `disabledStyles`.\n * It sets its own padding and background (C-NATIVE: an app-wide `button` rule would otherwise pad\n * and fill it) and gates its hover colors on the enabled state.\n */\nexport const PICKER_ICON_BUTTON_CLASSES =\n 'absolute flex h-6 w-6 items-center justify-center rounded bg-transparent p-0 text-muted-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:hover:text-foreground';\n\n/** The button box of each size: 20px with a 24px hit layer, 24px (the 0.7 box) or 32px. */\nconst BUTTON_BOX: Readonly<Record<CoreSize, string>> = {\n small: cn('size-5', hitAreaLayer),\n medium: '',\n large: 'size-8',\n};\n\n/**\n * The classes of a picker's icon button at a size and appearance (Phase 4 D11): the 0.7 classes,\n * the size's box and, on `filled-darker`, a hover fill one step darker than the field.\n */\nexport function pickerIconButtonClasses(\n size: CoreSize = 'medium',\n appearance: InputAppearance = 'outline',\n): string {\n return cn(\n PICKER_ICON_BUTTON_CLASSES,\n BUTTON_BOX[size],\n appearance === 'filled-darker' && 'not-disabled:not-aria-disabled:hover:bg-subtle-pressed',\n );\n}\n\nconst BUTTON_OFFSETS: Readonly<Record<CoreSize, readonly [string, string]>> = {\n small: ['end-1', 'end-7'],\n medium: ['end-1', 'end-7'],\n large: ['end-1', 'end-9'],\n};\n\n/** The inline-end offset of a picker's first or second icon button (the second sits before it). */\nexport function pickerButtonOffset(size: CoreSize, position: 1 | 2): string {\n return BUTTON_OFFSETS[size][position - 1];\n}\n\nconst END_PADDINGS: Readonly<Record<CoreSize, readonly [string, string]>> = {\n small: ['pe-7', 'pe-13'],\n medium: ['pe-8', 'pe-14'],\n large: ['pe-10', 'pe-18'],\n};\n\n/** The glyph sizes of each size: the chevron, and the other icons (clear, calendar). */\nconst GLYPHS: Readonly<Record<CoreSize, { chevron: number; icon: number }>> = {\n small: { chevron: 12, icon: 12 },\n medium: { chevron: 12, icon: 16 },\n large: { chevron: 16, icon: 20 },\n};\n\n/** The pixel size of a picker glyph at a size. */\nexport function pickerGlyphSize(size: CoreSize, kind: 'chevron' | 'icon'): number {\n return GLYPHS[size][kind];\n}\n\n/**\n * The end padding that keeps a picker's text clear of the buttons at its end: per size and button\n * count (one or two buttons at the end). At medium (the default), `pe-8` for one button, `pe-14`\n * for two, nothing without one.\n */\nexport function pickerEndPadding(buttons: number, size: CoreSize = 'medium'): string | undefined {\n if (buttons <= 0) return undefined;\n return END_PADDINGS[size][buttons >= 2 ? 1 : 0];\n}\n"],"mappings":";;;;AAeA,IAAaA,IACX,gNAGIC,IAAiD;CACrD,OAAOC,EAAG,UAAUC,CAAY;CAChC,QAAQ;CACR,OAAO;AACT;AAMA,SAAgBC,EACd,IAAiB,UACjB,IAA8B,WACtB;CACR,OAAOF,EACLF,GACAC,EAAWI,IACXC,MAAe,mBAAmB,wDACpC;AACF;AAEA,IAAMC,IAAwE;CAC5E,OAAO,CAAC,SAAS,OAAO;CACxB,QAAQ,CAAC,SAAS,OAAO;CACzB,OAAO,CAAC,SAAS,OAAO;AAC1B;AAGA,SAAgBC,EAAmB,GAAgB,GAAyB;CAC1E,OAAOD,EAAeF,EAAK,CAACI,IAAW;AACzC;AAEA,IAAMC,IAAsE;CAC1E,OAAO,CAAC,QAAQ,OAAO;CACvB,QAAQ,CAAC,QAAQ,OAAO;CACxB,OAAO,CAAC,SAAS,OAAO;AAC1B,GAGMC,IAAwE;CAC5E,OAAO;EAAE,SAAS;EAAI,MAAM;CAAG;CAC/B,QAAQ;EAAE,SAAS;EAAI,MAAM;CAAG;CAChC,OAAO;EAAE,SAAS;EAAI,MAAM;CAAG;AACjC;AAGA,SAAgBC,EAAgB,GAAgB,GAAkC;CAChF,OAAOD,EAAON,EAAK,CAACQ;AACtB;AAOA,SAAgBC,EAAiB,GAAiB,IAAiB,UAA8B;CAC/F,IAAI,OAAW,IACf,OAAOJ,EAAaL,EAAK,CAAC,OAAW;AACvC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/composeEventHandlers.cjs"),a=require("../../hooks/useControllable.cjs"),
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/composeEventHandlers.cjs"),a=require("../../lib/classNames.cjs"),o=require("../../hooks/useControllable.cjs"),s=require("../../hooks/useId.cjs"),c=require("../../lib/styles.cjs"),l=require("../../lib/icons.cjs"),u=require("./disclosureIds.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=d.createContext(null),m=d.createContext(null),h=d.createContext(null),g=[],_={openItems:g,toggle:()=>{},registerItem:()=>()=>{},baseId:`wave-accordion-inert`,headingLevel:3},v={value:``,isOpen:!1,triggerId:`wave-accordion-inert-trigger`,panelId:`wave-accordion-inert-panel`,hasPanelContent:!1,headingLevel:3,toggle:()=>{}},y={extra:null,inPanel:!0},b=d.createContext(!1),x=`m-0 grid`;function S(e){return d.useContext(p)||(r.reportMissingContext(e,`<Accordion>`),_)}function C(e){return d.useContext(m)||(r.reportMissingContext(e,`<Accordion.Item>`),v)}function w(e){r.warnOnce(`Accordion:duplicate:${e}`,`Accordion: several items share the value "${e}". Item values must be unique within an Accordion; items with the same value open and close together and share their trigger and panel ids.`)}function T(e){if(e!==void 0)return e===null?g:[e]}var E=e=>{let{type:n,openItem:i,defaultOpenItem:c,onOpenItemChange:l,openItems:u,defaultOpenItems:_,onOpenItemsChange:v,headingLevel:y=3,className:x,children:S,ref:C,...E}=e,D=n===`multiple`;D||(u!==void 0&&r.warnDeprecated(`Accordion`,`openItems`,`openItem`,`In single mode the Accordion takes one value.`),_!==void 0&&r.warnDeprecated(`Accordion`,`defaultOpenItems`,`defaultOpenItem`,`In single mode the Accordion takes one value.`),v!==void 0&&r.warnDeprecated(`Accordion`,`onOpenItemsChange`,`onOpenItemChange`,`In single mode the Accordion reports one value.`));let O=D?void 0:i,k=d.useMemo(()=>T(O)??u,[O,u]),[A]=d.useState(()=>(D?void 0:T(c))??_??g),[j,M]=o.useControllable(k,A,e=>{let t=[...e];D||l?.(t[0]??null),v?.(t)}),N=j.length;d.useEffect(()=>{!D&&N>1&&r.warnOnce(`Accordion:single-multiple-open`,`Accordion: type="single" allows one open item, but ${N} are open. Pass \`openItem\`, or use type="multiple".`)},[D,N]);let P=d.useCallback(e=>{M(t=>t.includes(e)?t.filter(t=>t!==e):D?[...t,e]:[e])},[D,M]),F=d.useRef(null),I=d.useCallback(e=>{F.current??=new Map;let t=F.current,n=(t.get(e)??0)+1;return t.set(e,n),n>1&&w(e),()=>{let n=(t.get(e)??1)-1;n>0?t.set(e,n):t.delete(e)}},[]),L=s.useId(`accordion`),R=d.useMemo(()=>({openItems:j,toggle:P,registerItem:I,baseId:L,headingLevel:y}),[j,P,I,L,y]);return(0,f.jsx)(p.Provider,{value:R,children:(0,f.jsx)(m.Provider,{value:null,children:(0,f.jsx)(h.Provider,{value:null,children:(0,f.jsx)(b.Provider,{value:!1,children:(0,f.jsx)(`div`,{ref:C,className:t.cn(a.accordionClassNames.root,`divide-y divide-border`,x),...E,children:S})})})})})};E.displayName=`Accordion`;function D(e,t,r){if(Array.isArray(e)){for(let n of e){let e=D(n,t,r);if(e)return e}return}if(!d.isValidElement(e))return;let i=n.getElementType(e,{suspend:!1});if(i===t)return e;if(i!==r&&i!==E&&i!==j)return D(e.props.children,t,r)}function O(e){let t=e?.props.id;return typeof t==`string`&&t!==``?t:void 0}function k(e){if(!d.isValidElement(e))return!1;let t=n.getElementType(e,{suspend:!1});if(typeof t==`string`||t===M||t===N||t===E||t===j)return!1;let r=e.props.children;return n.getElementType(r,{suspend:!1})===M||k(r)}function A(e){return`${e} was rendered inside the panel of an Accordion.Item, so it is not the item's ${e===`Accordion.Trigger`?`header`:`panel`}. Place Accordion.Trigger and Accordion.Panel directly in Accordion.Item, in a Fragment, or in an element that wraps them as \`children\` (such as a Tooltip). The Item cannot see inside a component that renders them itself and treats that component as panel content.`}var j=({value:e,headingLevel:r,className:i,children:o,ref:s,...c})=>{let l=S(`Accordion.Item`),p=l.openItems.includes(e),{toggle:g,baseId:_,registerItem:v}=l;d.useEffect(()=>v(e),[v,e]);let y=r??l.headingLevel,C=`h${y}`,w,T,E=[],A=[];for(let{key:e,node:r}of n.flattenChildren(o)){let n=(0,f.jsx)(d.Fragment,{children:r},e),i=D(r,M,N),o=D(r,N,M);i||o?(w??=i,T??=o,E.push(k(r)?(0,f.jsx)(C,{className:t.cn(a.accordionTriggerClassNames.heading,x),children:(0,f.jsx)(b.Provider,{value:!0,children:r})},e):n)):A.push(n)}let j=w!==void 0,P=T!==void 0,F=O(w),I=O(T),L=P||A.length>0,R=P&&A.length>0?A:null,z=d.useMemo(()=>({value:e,isOpen:p,triggerId:F??u.getPartId(_,`trigger`,e),panelId:I??u.getPartId(_,`panel`,e),hasPanelContent:L,headingLevel:y,toggle:()=>g(e)}),[e,p,_,F,I,L,y,g]),B=d.useMemo(()=>({extra:R,inPanel:!1}),[R]);return(0,f.jsx)(m.Provider,{value:z,children:(0,f.jsx)(h.Provider,{value:B,children:(0,f.jsxs)(`div`,{ref:s,"data-state":p?`open`:`closed`,className:t.cn(a.accordionItemClassNames.root,i),...c,children:[j?null:(0,f.jsx)(M,{children:e}),E,!P&&A.length>0?(0,f.jsx)(N,{children:A}):null]})})})};j.displayName=`AccordionItem`;var M=({id:e,className:n,children:o,onClick:s,ref:u,...p})=>{let m=C(`Accordion.Trigger`),g=d.useContext(h)?.inPanel??!1;d.useEffect(()=>{g&&r.warnOnce(`Accordion.Trigger:inside-panel`,A(`Accordion.Trigger`))},[g]);let _=d.useContext(b),v=`h${m.headingLevel}`,y=m.isOpen?`open`:`closed`,S=(0,f.jsxs)(`button`,{type:`button`,className:t.cn(a.accordionTriggerClassNames.root,`flex w-full items-center justify-between gap-2 px-4 py-3 text-start text-body-1 font-semibold text-foreground`,`not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed`,c.disabledStyles,c.focusRingInset,n),...p,id:e||(g?void 0:m.triggerId),"aria-controls":!g&&m.hasPanelContent?m.panelId:void 0,"aria-expanded":m.isOpen,"data-state":y,onClick:i.composeEventHandlers(s,m.toggle),ref:u,children:[o,(0,f.jsx)(l.ChevronDownIcon,{size:16,className:t.cn(a.accordionTriggerClassNames.expandIcon,`shrink-0 transition-transform motion-reduce:transition-none`,m.isOpen&&`rotate-180`)})]});return _?S:(0,f.jsx)(v,{className:t.cn(a.accordionTriggerClassNames.heading,x),children:S})};M.displayName=`AccordionTrigger`;var N=({id:e,className:n,children:i,ref:o,...s})=>{let c=C(`Accordion.Panel`),l=d.useContext(h),u=l?.inPanel??!1;return d.useEffect(()=>{u&&r.warnOnce(`Accordion.Panel:inside-panel`,A(`Accordion.Panel`))},[u]),c.isOpen?u?(0,f.jsx)(`div`,{className:t.cn(a.accordionPanelClassNames.root,n),...s,id:e||void 0,ref:o,children:i}):(0,f.jsx)(h.Provider,{value:y,children:(0,f.jsxs)(`div`,{role:`region`,className:t.cn(a.accordionPanelClassNames.root,`px-4 pb-3 text-body-1 text-muted-foreground`,n),...s,id:e||c.panelId,"aria-labelledby":c.triggerId,"data-state":`open`,ref:o,children:[i,l?.extra]})}):null};N.displayName=`AccordionPanel`;var P=Object.assign(E,{Item:j,Trigger:M,Panel:N});exports.Accordion=P,exports.AccordionItem=j,exports.AccordionPanel=N,exports.AccordionTrigger=M;
|
|
2
2
|
//# sourceMappingURL=Accordion.cjs.map
|