@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
|
@@ -2,21 +2,24 @@
|
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
3
|
import { warnDeprecated as t, warnOnce as n } from "../../lib/dev.mjs";
|
|
4
4
|
import { composeEventHandlers as r } from "../../lib/composeEventHandlers.mjs";
|
|
5
|
+
import { spinButtonClassNames as i } from "../../lib/classNames.mjs";
|
|
6
|
+
import { useEventCallback as a } from "../../hooks/useEventCallback.mjs";
|
|
5
7
|
import { useControllable as ee } from "../../hooks/useControllable.mjs";
|
|
6
8
|
import { useMergedRefs as te } from "../../hooks/useMergedRefs.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { inputFocusWithin as
|
|
9
|
-
import { AddIcon as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
9
|
+
import { useFieldContext as ne, useFieldControl as re } from "../../hooks/useFieldControl.mjs";
|
|
10
|
+
import { inputAppearanceClasses as ie, inputFocusWithin as ae, inputHeightClasses as oe, inputTextClasses as se } from "../../lib/styles.mjs";
|
|
11
|
+
import { AddIcon as ce, SubtractIcon as le } from "../../lib/icons.mjs";
|
|
12
|
+
import { useInputLook as ue } from "./inputLook.mjs";
|
|
13
|
+
import { isInvalidLook as de } from "./Input.mjs";
|
|
14
|
+
import { useFormReset as fe } from "../../hooks/useFormReset.mjs";
|
|
15
|
+
import { HiddenInput as pe } from "../internal/HiddenInput.mjs";
|
|
16
|
+
import * as o from "react";
|
|
17
|
+
import { jsx as s, jsxs as me } from "react/jsx-runtime";
|
|
15
18
|
//#region src/components/input/SpinButton.tsx
|
|
16
|
-
var
|
|
17
|
-
function
|
|
19
|
+
var c = /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?$/i, he = /^[+-]?\.?$/;
|
|
20
|
+
function ge(e) {
|
|
18
21
|
let t = e.trim();
|
|
19
|
-
if (!
|
|
22
|
+
if (!c.test(t)) return null;
|
|
20
23
|
let n = Number(t);
|
|
21
24
|
return Number.isFinite(n) ? n : null;
|
|
22
25
|
}
|
|
@@ -28,130 +31,230 @@ function l(e) {
|
|
|
28
31
|
function u(e, t) {
|
|
29
32
|
return Number(e.toFixed(Math.min(t, 20)));
|
|
30
33
|
}
|
|
31
|
-
var d =
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
var d = 300, f = 1e3;
|
|
35
|
+
function p(e) {
|
|
36
|
+
let t = Math.min(1, e / f);
|
|
37
|
+
return Math.round(d + -220 * t);
|
|
38
|
+
}
|
|
39
|
+
function _e(e) {
|
|
40
|
+
let t = d, n = setTimeout(function r() {
|
|
41
|
+
if (!e()) return;
|
|
42
|
+
let i = p(t);
|
|
43
|
+
t += i, n = setTimeout(r, i);
|
|
44
|
+
}, d);
|
|
45
|
+
return () => clearTimeout(n);
|
|
46
|
+
}
|
|
47
|
+
var m = {
|
|
48
|
+
small: {
|
|
49
|
+
button: "w-6",
|
|
50
|
+
input: "w-10",
|
|
51
|
+
glyph: 12
|
|
52
|
+
},
|
|
53
|
+
medium: {
|
|
54
|
+
button: "w-8",
|
|
55
|
+
input: "w-12",
|
|
56
|
+
glyph: 12
|
|
57
|
+
},
|
|
58
|
+
large: {
|
|
59
|
+
button: "w-10",
|
|
60
|
+
input: "w-14",
|
|
61
|
+
glyph: 16
|
|
62
|
+
}
|
|
63
|
+
}, h = e("flex h-full shrink-0 items-center justify-center bg-transparent p-0 text-foreground", "not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed", "disabled:pointer-events-none", "touch-manipulation select-none [-webkit-touch-callout:none]"), g = (c) => {
|
|
64
|
+
let { allowEmpty: d = !1, value: f, defaultValue: p, onValueChange: g, onChange: ve, ...ye } = c, { min: _ = -Infinity, max: v = Infinity, step: y = 1, largeStep: be, precision: b, disabled: x, name: xe, form: S, labels: C, displayValue: w, size: Se, appearance: Ce, className: we, hidden: Te, ref: Ee, controlRef: De, id: Oe, "aria-label": ke, "aria-labelledby": Ae, "aria-describedby": je, "aria-invalid": Me, "aria-required": Ne, "aria-errormessage": Pe, "aria-details": Fe, "aria-valuetext": Ie, required: T, readOnly: E, placeholder: Le, maxLength: Re, spellCheck: ze, autoComplete: Be = "off", autoFocus: Ve, inputMode: He, enterKeyHint: Ue, tabIndex: We, onFocus: Ge, onBlur: Ke, onKeyDown: qe, onKeyUp: Je, ...Ye } = ye;
|
|
65
|
+
ve !== void 0 && t("SpinButton", "onChange", "onValueChange");
|
|
66
|
+
let D = p === void 0 ? d ? null : 0 : p, [O, k, A] = ee(f, D, (e) => {
|
|
67
|
+
g?.(e), e !== null && ve?.(e);
|
|
68
|
+
}), [j, M] = o.useState(null), [Xe, Ze] = o.useState(O);
|
|
69
|
+
Object.is(Xe, O) || (Ze(O), M(null));
|
|
70
|
+
let [N, P] = o.useState(!1), F = o.useRef(!1), I = j === null ? null : ge(j), L = I ?? O, Qe = j !== null && I === null && j.trim() !== "" && !he.test(j.trim()), R = (e) => Math.min(v, Math.max(_, e)), z = !x && !E, B = A && w !== void 0, V = b === void 0 || !Number.isFinite(b) ? void 0 : Math.min(20, Math.max(0, Math.trunc(b))), H = (e) => {
|
|
71
|
+
M(null);
|
|
72
|
+
let t = V === void 0 ? e : u(e, V);
|
|
73
|
+
k(R(t));
|
|
74
|
+
}, U = (e, t) => {
|
|
75
|
+
let n = e ?? 0, r = V ?? Math.max(l(y), l(t), l(n));
|
|
76
|
+
return R(u(n + t, r));
|
|
77
|
+
}, W = (e) => {
|
|
78
|
+
M(null), k(U(L, e));
|
|
79
|
+
}, G = o.useRef(null), K = o.useRef(!1), q = o.useCallback(() => {
|
|
80
|
+
G.current?.stop(), G.current = null;
|
|
81
|
+
}, []), J = (e) => {
|
|
82
|
+
e.pointerId === G.current?.pointerId && q();
|
|
83
|
+
}, $e = (e) => L !== null && (e === 1 ? L >= v : L <= _), et = a(() => {
|
|
84
|
+
let e = G.current;
|
|
85
|
+
if (!e) return !1;
|
|
86
|
+
if (!z || $e(e.direction)) return q(), !1;
|
|
87
|
+
K.current = !0;
|
|
88
|
+
let t = e.direction * y;
|
|
89
|
+
return e.stepped ? (M(null), k((e) => U(e, t))) : (e.stepped = !0, W(t)), !0;
|
|
90
|
+
}), tt = (e, t) => {
|
|
91
|
+
if (!e.isPrimary || (K.current = !1, e.button !== 0 || e.pointerType === "mouse" && e.ctrlKey || !z)) return;
|
|
92
|
+
let n = e.target instanceof Element ? e.target : e.currentTarget;
|
|
93
|
+
e.pointerType !== "mouse" && n.hasPointerCapture?.(e.pointerId) && n.releasePointerCapture(e.pointerId), q(), G.current = {
|
|
94
|
+
pointerId: e.pointerId,
|
|
95
|
+
direction: t,
|
|
96
|
+
stepped: !1,
|
|
97
|
+
stop: _e(et)
|
|
98
|
+
};
|
|
99
|
+
}, Y = (e, t) => {
|
|
100
|
+
if (e.detail !== 0 && K.current) {
|
|
101
|
+
K.current = !1;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
W(t * y);
|
|
105
|
+
};
|
|
106
|
+
o.useEffect(() => {
|
|
107
|
+
let e = G.current;
|
|
108
|
+
e && (!z || $e(e.direction)) && q();
|
|
109
|
+
}), o.useEffect(() => (window.addEventListener("blur", q), () => {
|
|
110
|
+
window.removeEventListener("blur", q), q();
|
|
111
|
+
}), [q]);
|
|
112
|
+
let nt = () => {
|
|
113
|
+
if (j !== null) {
|
|
114
|
+
if (d && j.trim() === "") {
|
|
115
|
+
M(null), k(null);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
I === null ? M(null) : H(I);
|
|
119
|
+
}
|
|
120
|
+
}, X = o.useRef(null), rt = te(X, De), it = ne(), at = T ?? it?.required ?? !1, ot = re({
|
|
121
|
+
id: Oe,
|
|
122
|
+
"aria-label": ke,
|
|
123
|
+
"aria-labelledby": Ae,
|
|
124
|
+
"aria-describedby": je,
|
|
125
|
+
"aria-invalid": Me,
|
|
126
|
+
"aria-required": Ne,
|
|
127
|
+
required: T
|
|
128
|
+
}, { nativeRequired: !0 }), st = Qe ? !0 : ot["aria-invalid"], ct = de(!1, st), { size: Z, appearance: Q } = ue(Se, Ce);
|
|
129
|
+
fe(X, () => {
|
|
130
|
+
M(null), k(D);
|
|
131
|
+
}, S), o.useEffect(() => {
|
|
56
132
|
let e = X.current;
|
|
57
133
|
e && (e.hasAttribute("aria-label") || e.hasAttribute("aria-labelledby") || (e.labels?.length ?? 0) > 0 || e.hasAttribute("title") || n("SpinButton:unnamed", "SpinButton: the spinbutton has no accessible name. Pass `aria-label` or `aria-labelledby`, use a <label htmlFor>, or render it inside a Field."));
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
134
|
+
}), o.useEffect(() => {
|
|
135
|
+
w !== void 0 && !A && n("SpinButton:displayValue-uncontrolled", "SpinButton: `displayValue` is ignored while the value is uncontrolled; pass `value` (and update it in `onValueChange`).");
|
|
136
|
+
}, [w, A]);
|
|
137
|
+
let lt = a((e) => {
|
|
138
|
+
let t = e.target;
|
|
139
|
+
F.current = t.value.length > 0 && t.selectionStart === 0 && t.selectionEnd === t.value.length, P(!0);
|
|
140
|
+
}), ut = () => {
|
|
141
|
+
nt(), P(!1);
|
|
142
|
+
};
|
|
143
|
+
o.useLayoutEffect(() => {
|
|
144
|
+
N && F.current && (F.current = !1, X.current?.select());
|
|
145
|
+
}, [N]);
|
|
146
|
+
let dt = (e) => {
|
|
147
|
+
if (!z || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
148
|
+
let t = be ?? u(y * 10, l(y));
|
|
62
149
|
switch (e.key) {
|
|
63
150
|
case "ArrowUp":
|
|
64
151
|
case "ArrowDown":
|
|
65
152
|
case "PageUp":
|
|
66
153
|
case "PageDown": {
|
|
67
154
|
e.preventDefault();
|
|
68
|
-
let n = e.key === "ArrowUp" || e.key === "ArrowDown" ?
|
|
69
|
-
|
|
155
|
+
let n = e.key === "ArrowUp" || e.key === "ArrowDown" ? y : t;
|
|
156
|
+
W(e.key === "ArrowUp" || e.key === "PageUp" ? n : -n);
|
|
70
157
|
return;
|
|
71
158
|
}
|
|
72
159
|
case "Home":
|
|
73
160
|
case "End": {
|
|
74
|
-
|
|
161
|
+
if (e.shiftKey) return;
|
|
162
|
+
let t = e.key === "Home" ? _ : v;
|
|
75
163
|
if (!Number.isFinite(t)) return;
|
|
76
|
-
e.preventDefault(),
|
|
164
|
+
e.preventDefault(), H(t);
|
|
77
165
|
return;
|
|
78
166
|
}
|
|
79
167
|
case "Enter":
|
|
80
|
-
|
|
168
|
+
nt();
|
|
81
169
|
return;
|
|
82
170
|
case "Escape":
|
|
83
|
-
|
|
171
|
+
j !== null && (e.preventDefault(), M(null));
|
|
84
172
|
return;
|
|
85
173
|
}
|
|
86
|
-
},
|
|
87
|
-
return /* @__PURE__ */
|
|
88
|
-
ref:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
174
|
+
}, ft = _ < 0 ? "text" : l(y) > 0 || l(_) > 0 ? "decimal" : "numeric", $ = (e) => e.preventDefault();
|
|
175
|
+
return /* @__PURE__ */ me("div", {
|
|
176
|
+
ref: Ee,
|
|
177
|
+
"data-size": Z,
|
|
178
|
+
"data-appearance": Q,
|
|
179
|
+
className: e(i.root, "relative inline-flex items-center", oe[Z], se[Z], ie[Q], ae, ct && "border-destructive", x && "cursor-not-allowed opacity-50", we),
|
|
180
|
+
hidden: Te,
|
|
181
|
+
...Ye,
|
|
92
182
|
children: [
|
|
93
|
-
/* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ s("button", {
|
|
94
184
|
type: "button",
|
|
95
185
|
tabIndex: -1,
|
|
186
|
+
onPointerDown: (e) => tt(e, -1),
|
|
187
|
+
onPointerUp: J,
|
|
188
|
+
onPointerCancel: J,
|
|
189
|
+
onPointerLeave: J,
|
|
190
|
+
onClick: (e) => Y(e, -1),
|
|
96
191
|
onMouseDown: $,
|
|
97
|
-
|
|
98
|
-
disabled: !
|
|
99
|
-
"aria-label":
|
|
100
|
-
className: e(
|
|
101
|
-
children: /* @__PURE__ */
|
|
192
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
193
|
+
disabled: !z || L !== null && L <= _,
|
|
194
|
+
"aria-label": C?.decrement ?? "Decrement",
|
|
195
|
+
className: e(i.decrementButton, h, m[Z].button, Q === "outline" && "border-e border-input", Q === "filled-darker" && "not-disabled:not-aria-disabled:hover:bg-subtle-pressed", !x && "disabled:opacity-50"),
|
|
196
|
+
children: /* @__PURE__ */ s(le, { size: m[Z].glyph })
|
|
102
197
|
}),
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
ref:
|
|
198
|
+
/* @__PURE__ */ s("input", {
|
|
199
|
+
ref: rt,
|
|
105
200
|
type: "text",
|
|
106
201
|
role: "spinbutton",
|
|
107
|
-
inputMode:
|
|
108
|
-
autoComplete:
|
|
109
|
-
autoFocus:
|
|
110
|
-
enterKeyHint:
|
|
111
|
-
placeholder:
|
|
112
|
-
maxLength:
|
|
113
|
-
spellCheck:
|
|
114
|
-
tabIndex:
|
|
115
|
-
readOnly:
|
|
116
|
-
form:
|
|
117
|
-
...
|
|
118
|
-
"aria-invalid":
|
|
119
|
-
"aria-errormessage":
|
|
120
|
-
"aria-details":
|
|
121
|
-
"aria-valuenow":
|
|
122
|
-
"aria-valuemin": Number.isFinite(
|
|
123
|
-
"aria-valuemax": Number.isFinite(
|
|
124
|
-
"aria-valuetext":
|
|
125
|
-
value:
|
|
126
|
-
onChange: (e) =>
|
|
127
|
-
onFocus:
|
|
128
|
-
onBlur: r(
|
|
129
|
-
onKeyDown: r(
|
|
130
|
-
onKeyUp:
|
|
131
|
-
disabled:
|
|
132
|
-
className: "h-
|
|
202
|
+
inputMode: He ?? ft,
|
|
203
|
+
autoComplete: Be,
|
|
204
|
+
autoFocus: Ve,
|
|
205
|
+
enterKeyHint: Ue,
|
|
206
|
+
placeholder: Le,
|
|
207
|
+
maxLength: Re,
|
|
208
|
+
spellCheck: ze,
|
|
209
|
+
tabIndex: We,
|
|
210
|
+
readOnly: E,
|
|
211
|
+
form: S,
|
|
212
|
+
...ot,
|
|
213
|
+
"aria-invalid": st,
|
|
214
|
+
"aria-errormessage": Pe,
|
|
215
|
+
"aria-details": Fe,
|
|
216
|
+
"aria-valuenow": O ?? void 0,
|
|
217
|
+
"aria-valuemin": Number.isFinite(_) ? _ : void 0,
|
|
218
|
+
"aria-valuemax": Number.isFinite(v) ? v : void 0,
|
|
219
|
+
"aria-valuetext": Ie ?? (B ? w : void 0),
|
|
220
|
+
value: j ?? (B && !(N && z) ? w : O === null ? "" : String(O)),
|
|
221
|
+
onChange: (e) => M(e.target.value),
|
|
222
|
+
onFocus: r(Ge, lt, { checkDefaultPrevented: !1 }),
|
|
223
|
+
onBlur: r(Ke, ut, { checkDefaultPrevented: !1 }),
|
|
224
|
+
onKeyDown: r(qe, dt),
|
|
225
|
+
onKeyUp: Je,
|
|
226
|
+
disabled: x,
|
|
227
|
+
className: e(i.input, "h-full min-w-0 flex-auto border-none bg-transparent text-center text-foreground focus:outline-hidden disabled:cursor-not-allowed [appearance:textfield]", m[Z].input, se[Z])
|
|
133
228
|
}),
|
|
134
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ s("button", {
|
|
135
230
|
type: "button",
|
|
136
231
|
tabIndex: -1,
|
|
232
|
+
onPointerDown: (e) => tt(e, 1),
|
|
233
|
+
onPointerUp: J,
|
|
234
|
+
onPointerCancel: J,
|
|
235
|
+
onPointerLeave: J,
|
|
236
|
+
onClick: (e) => Y(e, 1),
|
|
137
237
|
onMouseDown: $,
|
|
138
|
-
|
|
139
|
-
disabled: !
|
|
140
|
-
"aria-label":
|
|
141
|
-
className: e(
|
|
142
|
-
children: /* @__PURE__ */
|
|
238
|
+
onContextMenu: (e) => e.preventDefault(),
|
|
239
|
+
disabled: !z || L !== null && L >= v,
|
|
240
|
+
"aria-label": C?.increment ?? "Increment",
|
|
241
|
+
className: e(i.incrementButton, h, m[Z].button, Q === "outline" && "border-s border-input", Q === "filled-darker" && "not-disabled:not-aria-disabled:hover:bg-subtle-pressed", !x && "disabled:opacity-50"),
|
|
242
|
+
children: /* @__PURE__ */ s(ce, { size: m[Z].glyph })
|
|
143
243
|
}),
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
name:
|
|
146
|
-
form:
|
|
147
|
-
disabled:
|
|
148
|
-
|
|
244
|
+
/* @__PURE__ */ s(pe, {
|
|
245
|
+
name: xe,
|
|
246
|
+
form: S,
|
|
247
|
+
disabled: x,
|
|
248
|
+
type: "text",
|
|
249
|
+
value: O === null ? "" : String(O),
|
|
250
|
+
required: d ? at : void 0,
|
|
251
|
+
onInvalid: () => X.current?.focus()
|
|
149
252
|
})
|
|
150
253
|
]
|
|
151
254
|
});
|
|
152
255
|
};
|
|
153
|
-
|
|
256
|
+
g.displayName = "SpinButton";
|
|
154
257
|
//#endregion
|
|
155
|
-
export {
|
|
258
|
+
export { g as SpinButton };
|
|
156
259
|
|
|
157
260
|
//# sourceMappingURL=SpinButton.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpinButton.mjs","names":["React","NUMBER_TEXT","PARTIAL_NUMBER_TEXT","parseNumberText","trimmed","text","decimalsOf","n","mantissa","exponent","fraction","roundTo","decimals","stepButtonClass","cn","SpinButton","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","ariaValueText","rest","onChange","warnDeprecated","initialValue","defaultValue","value","setValue","useControllable","onValueChange","next","draft","setDraft","prevValue","setPrevValue","draftNumber","current","draftInvalid","clamp","max","min","interactive","disabled","readOnly","commit","stepBy","precision","step","delta","commitDraft","inputRef","mergedInputRef","useMergedRefs","controlRef","fieldProps","useFieldControl","ariaInvalidValue","invalidLook","isInvalidLook","useFormReset","form","input","warnOnce","handleKeyDown","big","largeStep","size","bound","defaultInputMode","keepFocus","inputFocusWithin","className","labels","SubtractIcon","inputMode","composeEventHandlers","onBlur","onKeyDown","AddIcon","HiddenInput"],"sources":["../../../src/components/input/SpinButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { AddIcon, SubtractIcon } from '../../lib/icons';\nimport { inputFocusWithin, inputInvalidWithin } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { isInvalidLook } from './Input';\n\n/**\n * Props that SpinButton routes to its `<input role=\"spinbutton\">` (C-ROUTING): the id, the ARIA\n * naming/validation attributes, native text-input attributes and the focus/keyboard handlers.\n */\nexport type SpinButtonInputProps = Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'id'\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-describedby'\n | 'aria-invalid'\n | 'aria-required'\n | 'aria-errormessage'\n | 'aria-details'\n | 'aria-valuetext'\n | 'required'\n | 'readOnly'\n | 'placeholder'\n | 'maxLength'\n | 'spellCheck'\n | 'autoComplete'\n | 'autoFocus'\n | 'inputMode'\n | 'enterKeyHint'\n | 'tabIndex'\n | 'onFocus'\n | 'onBlur'\n | 'onKeyDown'\n | 'onKeyUp'\n>;\n\n/**\n * Names of the SpinButton's step buttons, for localization. Each member is optional and falls back\n * to its English default.\n */\nexport interface SpinButtonLabels {\n /** Name of the button that steps up.\n * @default 'Increment'\n */\n increment?: string;\n /** Name of the button that steps down.\n * @default 'Decrement'\n */\n decrement?: string;\n}\n\n/** Properties for the SpinButton component. */\nexport interface SpinButtonProps\n extends\n Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | keyof SpinButtonInputProps\n >,\n SpinButtonInputProps {\n /** Controlled numeric value. */\n value?: number;\n /** Initial value for uncontrolled usage (also what a form reset restores).\n * @default 0\n */\n defaultValue?: number;\n /**\n * Called with the new value when it changes: a step (buttons, arrow keys, PageUp/PageDown,\n * Home/End) or a typed value committed on blur or Enter. Not called while the user is typing,\n * nor when the value stays the same.\n */\n onValueChange?: (value: number) => void;\n /**\n * Called with the new value when it changes.\n * @deprecated Use `onValueChange`. (`onChange` is reserved for native change events.)\n */\n onChange?: (value: number) => void;\n /** Minimum allowed value.\n * @default -Infinity\n */\n min?: number;\n /** Maximum allowed value.\n * @default Infinity\n */\n max?: number;\n /** Step of the increment/decrement buttons and of ArrowUp/ArrowDown.\n * @default 1\n */\n step?: number;\n /** Step of PageUp/PageDown.\n * @default step * 10\n */\n largeStep?: number;\n /** Whether the spin button is disabled and non-interactive. */\n disabled?: boolean;\n /** Form field name. With a name, the committed value is submitted with the form. */\n name?: string;\n /** Id of the form the spin button belongs to, when it is rendered outside that form. */\n form?: string;\n /**\n * Names of the −/+ step buttons (not tab stops, but in the accessibility tree), for\n * localization. Unset members keep their English defaults.\n */\n labels?: SpinButtonLabels;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n /** Ref to the `<input role=\"spinbutton\">` (the focusable control). */\n controlRef?: React.Ref<HTMLInputElement>;\n}\n\n/** Decimal numbers as a user types them: `12`, `-3`, `1.5`, `.5`, `2.`, `1e3`. */\nconst NUMBER_TEXT = /^[+-]?(\\d+\\.?\\d*|\\.\\d+)(e[+-]?\\d+)?$/i;\n/** Text on the way to a number (`-`, `.`, `-.`): not a value yet, but not an error either. */\nconst PARTIAL_NUMBER_TEXT = /^[+-]?\\.?$/;\n\nfunction parseNumberText(text: string): number | null {\n const trimmed = text.trim();\n if (!NUMBER_TEXT.test(trimmed)) return null;\n const n = Number(trimmed);\n return Number.isFinite(n) ? n : null;\n}\n\n/** Number of decimals of `n` as written by JavaScript (`0.1` → 1, `1e-7` → 7). */\nfunction decimalsOf(n: number): number {\n if (!Number.isFinite(n)) return 0;\n const [mantissa, exponent] = String(n).toLowerCase().split('e');\n const fraction = mantissa.split('.')[1]?.length ?? 0;\n return Math.max(0, fraction - (exponent ? Number(exponent) : 0));\n}\n\nfunction roundTo(n: number, decimals: number): number {\n return Number(n.toFixed(Math.min(decimals, 20)));\n}\n\nconst stepButtonClass = cn(\n // Padding and background set here (C-NATIVE): an app-wide `button` rule cannot fill them.\n 'flex h-8 w-8 shrink-0 items-center justify-center border-input bg-transparent p-0 text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed',\n 'disabled:pointer-events-none',\n);\n\n/**\n * A numeric input with decrement/increment buttons (APG spinbutton pattern).\n *\n * - **Keyboard** on the input: ArrowUp/ArrowDown step by `step`, PageUp/PageDown by `largeStep`\n * (default ten steps), Home/End jump to `min`/`max` when they are finite. The −/+ buttons are\n * not tab stops and never take focus, so focus stays on the spinbutton and screen readers\n * announce the new value.\n * - **Typing** edits a draft: the value is parsed, clamped and committed on blur or Enter\n * (Escape reverts). Text that is not a number is flagged with `aria-invalid` and reverted on\n * blur. Steps (keys and buttons) start from the typed number, and the −/+ buttons are disabled\n * when that number is at `min`/`max`. Steps are rounded to the precision of `step` and of the\n * value, so `0.1 + 0.2` is `0.3`.\n * - **Routing**: `id`, ARIA, native input attributes and focus/keyboard handlers go to the\n * `<input role=\"spinbutton\">`; `className`, `style`, `data-*`, other handlers and `ref` stay on\n * the root (`controlRef` reaches the input). Inside a `Field` it picks up the label, hint, error\n * and required state automatically. It has no built-in name: pass `aria-label`/`aria-labelledby`\n * or use a label (development warning otherwise).\n * - **Forms**: with `name` the committed value is submitted; `required` makes the input natively\n * required; a form reset restores `defaultValue`.\n * - The −/+ buttons are named \"Decrement\"/\"Increment\"; `labels` localizes the names.\n *\n * @example\n * <SpinButton aria-label=\"Quantity\" min={1} max={10} value={qty} onValueChange={setQty} />\n */\nexport const SpinButton = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n min = -Infinity,\n max = Infinity,\n step = 1,\n largeStep,\n disabled,\n name,\n form,\n labels,\n className,\n hidden,\n ref,\n controlRef,\n // Routed to the input (C-ROUTING)\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n 'aria-valuetext': ariaValueText,\n required,\n readOnly,\n placeholder,\n maxLength,\n spellCheck,\n autoComplete = 'off',\n autoFocus,\n inputMode,\n enterKeyHint,\n tabIndex,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n ...rest\n}: SpinButtonProps) => {\n if (onChange !== undefined) warnDeprecated('SpinButton', 'onChange', 'onValueChange');\n const initialValue = defaultValue ?? 0;\n const [value, setValue] = useControllable(valueProp, initialValue, (next: number) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n // The text is a draft while the user types (null = show the value).\n const [draft, setDraft] = React.useState<string | null>(null);\n // A value that changes from outside replaces the draft (adjust state during render, C-HOOKS).\n const [prevValue, setPrevValue] = React.useState(value);\n if (!Object.is(prevValue, value)) {\n setPrevValue(value);\n setDraft(null);\n }\n\n const draftNumber = draft === null ? null : parseNumberText(draft);\n // What stepping starts from: the typed draft when it is a number, else the value. The −/+\n // buttons are enabled by it too, so they agree with ArrowUp/ArrowDown while the user types.\n const current = draftNumber ?? value;\n const draftInvalid =\n draft !== null &&\n draftNumber === null &&\n draft.trim() !== '' &&\n !PARTIAL_NUMBER_TEXT.test(draft.trim());\n\n const clamp = (n: number) => Math.min(max, Math.max(min, n));\n const interactive = !disabled && !readOnly;\n\n const commit = (next: number) => {\n setDraft(null);\n setValue(clamp(next));\n };\n\n /** Steps from the typed draft when it is a number, else from the value. */\n const stepBy = (delta: number) => {\n const precision = Math.max(decimalsOf(step), decimalsOf(delta), decimalsOf(current));\n commit(roundTo(current + delta, precision));\n };\n\n const commitDraft = () => {\n if (draft === null) return;\n if (draftNumber === null) setDraft(null);\n else commit(draftNumber);\n };\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedInputRef = useMergedRefs(inputRef, controlRef);\n\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n required,\n },\n { nativeRequired: true },\n );\n // Typed text that is not a number is invalid whatever the consumer says; otherwise the\n // consumer's or the Field's `aria-invalid` is passed through as is (`grammar` included), and the\n // error look follows the shared rule of the text controls.\n const ariaInvalidValue = draftInvalid ? true : fieldProps['aria-invalid'];\n const invalidLook = isInvalidLook(false, ariaInvalidValue);\n\n useFormReset(\n inputRef,\n () => {\n setDraft(null);\n setValue(initialValue);\n },\n form,\n );\n\n // No built-in name any more (\"Value\" named every instance the same): report unnamed inputs.\n React.useEffect(() => {\n const input = inputRef.current;\n if (!input) return;\n const named =\n input.hasAttribute('aria-label') ||\n input.hasAttribute('aria-labelledby') ||\n (input.labels?.length ?? 0) > 0 ||\n input.hasAttribute('title');\n if (!named) {\n warnOnce(\n 'SpinButton:unnamed',\n 'SpinButton: the spinbutton has no accessible name. Pass `aria-label` or `aria-labelledby`, use a <label htmlFor>, or render it inside a Field.',\n );\n }\n });\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // Read-only: the keys keep their native caret behaviour and never change the value.\n if (!interactive || e.altKey || e.ctrlKey || e.metaKey) return;\n // Ten steps, rounded: step * 10 carries float error (0.07 * 10 = 0.7000000000000001) that\n // stepBy would otherwise keep, since it rounds to the precision of the delta too.\n const big = largeStep ?? roundTo(step * 10, decimalsOf(step));\n switch (e.key) {\n case 'ArrowUp':\n case 'ArrowDown':\n case 'PageUp':\n case 'PageDown': {\n e.preventDefault();\n const size = e.key === 'ArrowUp' || e.key === 'ArrowDown' ? step : big;\n stepBy(e.key === 'ArrowUp' || e.key === 'PageUp' ? size : -size);\n return;\n }\n case 'Home':\n case 'End': {\n const bound = e.key === 'Home' ? min : max;\n if (!Number.isFinite(bound)) return; // no bound: Home/End move the caret\n e.preventDefault();\n commit(bound);\n return;\n }\n case 'Enter':\n // Not prevented: Enter still submits the surrounding form, with the committed value.\n commitDraft();\n return;\n case 'Escape':\n if (draft !== null) {\n e.preventDefault(); // enclosing layers (a Dialog) ignore this Escape\n setDraft(null);\n }\n return;\n default:\n }\n };\n\n const defaultInputMode: React.HTMLAttributes<HTMLInputElement>['inputMode'] =\n min < 0 ? 'text' : decimalsOf(step) > 0 || decimalsOf(min) > 0 ? 'decimal' : 'numeric';\n\n // The step buttons never take focus: a pointer press leaves it where it is (on the input while\n // editing), so a button that becomes disabled at a bound cannot drop focus to <body>.\n const keepFocus = (e: React.MouseEvent) => e.preventDefault();\n\n return (\n <div\n ref={ref}\n className={cn(\n 'relative inline-flex items-center rounded border border-input border-b-stroke-accessible bg-background',\n inputFocusWithin,\n invalidLook && inputInvalidWithin,\n disabled && 'cursor-not-allowed opacity-50',\n className,\n )}\n hidden={hidden}\n {...rest}\n >\n <button\n type=\"button\"\n tabIndex={-1}\n onMouseDown={keepFocus}\n onClick={() => stepBy(-step)}\n disabled={!interactive || current <= min}\n aria-label={labels?.decrement ?? 'Decrement'}\n className={cn(stepButtonClass, 'border-e', !disabled && 'disabled:opacity-50')}\n >\n <SubtractIcon size={12} />\n </button>\n\n <input\n ref={mergedInputRef}\n type=\"text\"\n role=\"spinbutton\"\n inputMode={inputMode ?? defaultInputMode}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n enterKeyHint={enterKeyHint}\n placeholder={placeholder}\n maxLength={maxLength}\n spellCheck={spellCheck}\n tabIndex={tabIndex}\n readOnly={readOnly}\n form={form}\n {...fieldProps}\n aria-invalid={ariaInvalidValue}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n aria-valuenow={value}\n aria-valuemin={Number.isFinite(min) ? min : undefined}\n aria-valuemax={Number.isFinite(max) ? max : undefined}\n aria-valuetext={ariaValueText}\n value={draft ?? String(value)}\n onChange={(e) => setDraft(e.target.value)}\n onFocus={onFocus}\n onBlur={composeEventHandlers(onBlur, commitDraft, { checkDefaultPrevented: false })}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onKeyUp={onKeyUp}\n disabled={disabled}\n className=\"h-8 w-12 min-w-0 border-none bg-transparent text-center text-body-1 text-foreground focus:outline-hidden disabled:cursor-not-allowed [appearance:textfield]\"\n />\n\n <button\n type=\"button\"\n tabIndex={-1}\n onMouseDown={keepFocus}\n onClick={() => stepBy(step)}\n disabled={!interactive || current >= max}\n aria-label={labels?.increment ?? 'Increment'}\n className={cn(stepButtonClass, 'border-s', !disabled && 'disabled:opacity-50')}\n >\n <AddIcon size={12} />\n </button>\n\n <HiddenInput name={name} form={form} disabled={disabled} value={String(value)} />\n </div>\n );\n};\n\nSpinButton.displayName = 'SpinButton';\n"],"mappings":";;;;;;;;;;;;;;;AAsHA,IAAMC,IAAc,yCAEdC,KAAsB;AAE5B,SAASC,EAAgB,GAA6B;CACpD,IAAMC,IAAUC,EAAK,KAAK;CAC1B,IAAI,CAACJ,EAAY,KAAKG,CAAO,GAAG,OAAO;CACvC,IAAM,IAAI,OAAOA,CAAO;CACxB,OAAO,OAAO,SAAS,CAAC,IAAI,IAAI;AAClC;AAGA,SAASE,EAAW,GAAmB;CACrC,IAAI,CAAC,OAAO,SAASC,CAAC,GAAG,OAAO;CAChC,IAAM,CAACC,GAAUC,KAAY,OAAOF,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,GACxDG,IAAWF,EAAS,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,UAAU;CACnD,OAAO,KAAK,IAAI,GAAGE,KAAYD,IAAW,OAAOA,CAAQ,IAAI,EAAE;AACjE;AAEA,SAASE,EAAQ,GAAW,GAA0B;CACpD,OAAO,OAAOJ,EAAE,QAAQ,KAAK,IAAIK,GAAU,EAAE,CAAC,CAAC;AACjD;AAEA,IAAMC,IAAkBC,EAEtB,qGACA,gHACA,8BACF,GA0BaC,KAAc,EACzB,OAAOC,GACP,iBACA,mBACA,aACA,SAAM,WACN,SAAM,UACN,UAAO,GACP,eACA,aACA,UACA,SACA,WACA,eACA,YACA,SACA,eAEA,OACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC,GACpB,gBAAgBC,GAChB,iBAAiBC,GACjB,qBAAqBC,GACrB,gBAAgBC,GAChB,kBAAkBC,GAClB,aACA,aACA,gBACA,cACA,eACA,kBAAe,OACf,cACA,cACA,iBACA,cACA,aACA,YACA,eACA,aACA,GAAGC,SACkB;CACrB,AAAIC,MAAa,KAAA,KAAWC,EAAe,cAAc,YAAY,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1
|
+
{"version":3,"file":"SpinButton.mjs","names":["React","NUMBER_TEXT","PARTIAL_NUMBER_TEXT","parseNumberText","trimmed","text","decimalsOf","n","mantissa","exponent","fraction","roundTo","decimals","SPIN_DELAY","SPIN_RAMP","spinDelay","elapsed","startSpin","timer","tick","step","delay","SPIN_SIZE","stepButtonClass","cn","SpinButton","valueProp","baseProps","props","sizeProp","appearanceProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","ariaValueText","rest","onChange","warnDeprecated","initialValue","defaultValue","allowEmpty","value","setValue","isControlled","useControllable","onValueChange","next","draft","setDraft","prevValue","setPrevValue","focused","setFocused","reselectRef","draftNumber","current","draftInvalid","clamp","max","min","interactive","disabled","readOnly","showsDisplay","displayValue","places","precision","commit","rounded","stepFrom","base","from","delta","stepBy","holdRef","repeatedRef","stopHold","endHold","event","atBound","direction","holdStep","useEventCallback","hold","prev","startHold","holder","clickStep","commitDraft","inputRef","mergedInputRef","useMergedRefs","controlRef","field","useFieldContext","isRequired","required","fieldProps","useFieldControl","ariaInvalidValue","invalidLook","isInvalidLook","useInputLook","useFormReset","form","input","warnOnce","handleFocus","handleBlur","handleKeyDown","big","largeStep","amount","bound","defaultInputMode","keepFocus","size","appearance","spinButtonClassNames","inputHeightClasses","inputTextClasses","inputAppearanceClasses","inputFocusWithin","className","labels","SubtractIcon","inputMode","composeEventHandlers","onFocus","onBlur","onKeyDown","AddIcon","HiddenInput"],"sources":["../../../src/components/input/SpinButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { spinButtonClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { AddIcon, SubtractIcon } from '../../lib/icons';\nimport {\n inputAppearanceClasses,\n inputFocusWithin,\n inputHeightClasses,\n inputInvalidWithin,\n inputTextClasses,\n} from '../../lib/styles';\nimport type { CoreSize, InputAppearance } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { isInvalidLook } from './Input';\nimport { useInputLook } from './inputLook';\n\n/**\n * Props that SpinButton routes to its `<input role=\"spinbutton\">` (C-ROUTING): the id, the ARIA\n * naming/validation attributes, native text-input attributes and the focus/keyboard handlers.\n */\nexport type SpinButtonInputProps = Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'id'\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-describedby'\n | 'aria-invalid'\n | 'aria-required'\n | 'aria-errormessage'\n | 'aria-details'\n | 'aria-valuetext'\n | 'required'\n | 'readOnly'\n | 'placeholder'\n | 'maxLength'\n | 'spellCheck'\n | 'autoComplete'\n | 'autoFocus'\n | 'inputMode'\n | 'enterKeyHint'\n | 'tabIndex'\n | 'onFocus'\n | 'onBlur'\n | 'onKeyDown'\n | 'onKeyUp'\n>;\n\n/**\n * Names of the SpinButton's step buttons, for localization. Each member is optional and falls back\n * to its English default.\n */\nexport interface SpinButtonLabels {\n /** Name of the button that steps up.\n * @default 'Increment'\n */\n increment?: string;\n /** Name of the button that steps down.\n * @default 'Decrement'\n */\n decrement?: string;\n}\n\n/**\n * Properties every SpinButton mode shares (every member of {@link SpinButtonProps} and\n * {@link SpinButtonAllowEmptyProps} except the value members, which differ between them).\n */\nexport interface SpinButtonBaseProps\n extends\n Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | keyof SpinButtonInputProps\n >,\n SpinButtonInputProps {\n /** Minimum allowed value.\n * @default -Infinity\n */\n min?: number;\n /** Maximum allowed value.\n * @default Infinity\n */\n max?: number;\n /** Step of the increment/decrement buttons and of ArrowUp/ArrowDown.\n * @default 1\n */\n step?: number;\n /** Step of PageUp/PageDown.\n * @default step * 10\n */\n largeStep?: number;\n /**\n * Decimals every committed value is rounded to, typed or stepped (0–20); the number is not\n * padded (use `displayValue` for `1.00`). Default: steps round to the decimals of `step` and\n * the value, typed values are kept as typed.\n */\n precision?: number;\n /** Whether the spin button is disabled and non-interactive. */\n disabled?: boolean;\n /** Form field name. With a name, the committed value is submitted with the form. */\n name?: string;\n /** Id of the form the spin button belongs to, when it is rendered outside that form. */\n form?: string;\n /**\n * Names of the −/+ step buttons (not tab stops, but in the accessibility tree), for\n * localization. Unset members keep their English defaults.\n */\n labels?: SpinButtonLabels;\n /**\n * Text shown for the value while the field is not being edited, and its `aria-valuetext` (a\n * `$1.00` for 1). While the field has focus and can be edited it shows the plain number, so\n * typing edits the number. Applies only while `value` is controlled (update it with the\n * value); Fluent's `displayValue`.\n */\n displayValue?: string;\n /**\n * Size of the field: `small` (24px tall), `medium` (32px) or `large` (40px). Default: the\n * surrounding Field's `size`, else `WaveProvider inputDefaults.size`, else `'medium'`.\n *\n * SpinButton is 24, 32 or 40px tall like every field; its buttons are square-ish, 24, 32 or\n * 40px wide.\n */\n size?: CoreSize;\n /**\n * Look of the field: `outline` (a full border), `underline` (a bottom stroke only),\n * `filled-darker` or `filled-lighter` (a fill without a visible stroke: give the field a\n * visible label). Default: `WaveProvider inputDefaults.appearance`, else `'outline'`.\n *\n * The step buttons keep a 1px separator from the input only in `outline`; the other\n * appearances have none.\n */\n appearance?: InputAppearance;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n /** Ref to the `<input role=\"spinbutton\">` (the focusable control). */\n controlRef?: React.Ref<HTMLInputElement>;\n}\n\n/** SpinButton props with a number value (the 0.7 shape). */\nexport interface SpinButtonProps extends SpinButtonBaseProps {\n /**\n * Allows an empty value (`null`). Takes the literal `true`: a `boolean` variable fits neither\n * member of the props, so branch the JSX or spread `{ allowEmpty: true, value }`.\n * @default false\n */\n allowEmpty?: false;\n /** Controlled numeric value. */\n value?: number;\n /** Initial value for uncontrolled usage (also what a form reset restores).\n * @default 0\n */\n defaultValue?: number;\n /**\n * Called with the new value when it changes: a step (buttons, arrow keys, PageUp/PageDown,\n * Home/End) or a typed value committed on blur or Enter. Not called while the user is typing,\n * nor when the value stays the same.\n */\n onValueChange?: (value: number) => void;\n /**\n * Called with the new value when it changes.\n * @deprecated Use `onValueChange`. (`onChange` is reserved for native change events.)\n */\n onChange?: (value: number) => void;\n}\n\n/** SpinButton props with `allowEmpty`: the value may be `null` (an empty field). */\nexport interface SpinButtonAllowEmptyProps extends SpinButtonBaseProps {\n /** The value may be `null`: clearing the text and committing it empties the field. */\n allowEmpty: true;\n /** Controlled value; `null` is an empty field. */\n value?: number | null;\n /** Initial value for uncontrolled usage (also what a form reset restores).\n * @default null\n */\n defaultValue?: number | null;\n /** Called with the new value when it changes, `null` when the field is emptied. */\n onValueChange?: (value: number | null) => void;\n /** Not available with `allowEmpty` (the deprecated alias of `onValueChange`). */\n onChange?: never;\n}\n\n/** Decimal numbers as a user types them: `12`, `-3`, `1.5`, `.5`, `2.`, `1e3`. */\nconst NUMBER_TEXT = /^[+-]?(\\d+\\.?\\d*|\\.\\d+)(e[+-]?\\d+)?$/i;\n/** Text on the way to a number (`-`, `.`, `-.`): not a value yet, but not an error either. */\nconst PARTIAL_NUMBER_TEXT = /^[+-]?\\.?$/;\n\nfunction parseNumberText(text: string): number | null {\n const trimmed = text.trim();\n if (!NUMBER_TEXT.test(trimmed)) return null;\n const n = Number(trimmed);\n return Number.isFinite(n) ? n : null;\n}\n\n/** Number of decimals of `n` as written by JavaScript (`0.1` → 1, `1e-7` → 7). */\nfunction decimalsOf(n: number): number {\n if (!Number.isFinite(n)) return 0;\n const [mantissa, exponent] = String(n).toLowerCase().split('e');\n const fraction = mantissa.split('.')[1]?.length ?? 0;\n return Math.max(0, fraction - (exponent ? Number(exponent) : 0));\n}\n\nfunction roundTo(n: number, decimals: number): number {\n return Number(n.toFixed(Math.min(decimals, 20)));\n}\n\n// Phase 4 D18, Fluent's timing (`DEFAULT_SPIN_DELAY_MS`, `MIN_SPIN_DELAY_MS`, `MAX_SPIN_TIME_MS`)\n// without its step on the press itself.\n/** Delay before a press becomes a hold, and the first delay between repeats (ms). */\nconst SPIN_DELAY = 300;\n/** The shortest delay between repeats, reached after SPIN_RAMP ms of holding. */\nconst SPIN_MIN_DELAY = 80;\n/** How long into a hold the delay between repeats takes to ease down to SPIN_MIN_DELAY (ms). */\nconst SPIN_RAMP = 1000;\n\n/** The delay after a step taken `elapsed` ms into a hold: 300ms easing linearly to 80ms. */\nfunction spinDelay(elapsed: number): number {\n const t = Math.min(1, elapsed / SPIN_RAMP);\n return Math.round(SPIN_DELAY + (SPIN_MIN_DELAY - SPIN_DELAY) * t);\n}\n\n/**\n * Runs the timers of a hold: calls `step` once SPIN_DELAY has passed, then again after each\n * `spinDelay` (steps at 300, 534, 717, 859, 970 and 1057ms, then every 80ms), until `step` returns\n * false or the returned function is called.\n */\nfunction startSpin(step: () => boolean): () => void {\n let elapsed = SPIN_DELAY;\n let timer = setTimeout(function tick() {\n if (!step()) return;\n const delay = spinDelay(elapsed);\n elapsed += delay;\n timer = setTimeout(tick, delay);\n }, SPIN_DELAY);\n return () => clearTimeout(timer);\n}\n\n/** Per-size widths of the step buttons and the input's flex basis, and the glyph size. */\nconst SPIN_SIZE: Readonly<Record<CoreSize, { button: string; input: string; glyph: number }>> = {\n small: { button: 'w-6', input: 'w-10', glyph: 12 },\n medium: { button: 'w-8', input: 'w-12', glyph: 12 },\n large: { button: 'w-10', input: 'w-14', glyph: 16 },\n};\n\nconst stepButtonClass = cn(\n // Padding and background set here (C-NATIVE): an app-wide `button` rule cannot fill them. The\n // size and, in `outline`, the separator are added per render (SPIN_SIZE, D13).\n 'flex h-full shrink-0 items-center justify-center bg-transparent p-0 text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed',\n 'disabled:pointer-events-none',\n // A finger holding a button (D18): no double-tap zoom, text selection or iOS callout.\n 'touch-manipulation select-none [-webkit-touch-callout:none]',\n);\n\n/**\n * A numeric input with decrement/increment buttons (APG spinbutton pattern).\n *\n * - **Keyboard** on the input: ArrowUp/ArrowDown step by `step`, PageUp/PageDown by `largeStep`\n * (default ten steps), Home/End jump to `min`/`max` when they are finite (Shift+Home and\n * Shift+End keep their native text-selection instead). The −/+ buttons are not tab stops and\n * never take focus, so focus stays on the spinbutton and screen readers announce the new\n * value.\n * - **Pointer** on the −/+ buttons (mouse, touch or pen): a short press steps once, on release\n * (its click), never on the press alone, so a finger that starts a scroll on a button changes\n * nothing. Holding a button repeats the step: the first after 300ms, then faster, every 80ms\n * after about a second (Fluent's timing). A hold stops when the button is released, the\n * pointer leaves it or the press turns into a scroll, at the bound, when the window loses\n * focus, and when the spin button becomes disabled or read-only. Only the primary button of a\n * primary pointer holds: a second finger, a secondary button or a Ctrl+press with a mouse (the\n * secondary click on macOS) neither starts a hold nor ends one. A click without a press (a\n * screen reader, `element.click()`) steps once. The buttons open no context menu (a long press\n * on touch would), show no iOS callout, and allow no text selection or double-tap zoom.\n * - **Typing** edits a draft: the value is parsed, clamped and committed on blur or Enter\n * (Escape reverts). Text that is not a number is flagged with `aria-invalid` and reverted on\n * blur. Steps (keys and buttons) start from the typed number, and the −/+ buttons are disabled\n * when that number is at `min`/`max`. Steps are rounded to the precision of `step` and of the\n * value, so `0.1 + 0.2` is `0.3`; `precision` rounds every committed value, typed or stepped,\n * to a fixed number of decimals instead, without padding it (pad with `displayValue`).\n * - **Routing**: `id`, ARIA, native input attributes and focus/keyboard handlers go to the\n * `<input role=\"spinbutton\">`; `className`, `style`, `data-*`, other handlers and `ref` stay on\n * the root (`controlRef` reaches the input). Inside a `Field` it picks up the label, hint, error\n * and required state automatically. It has no built-in name: pass `aria-label`/`aria-labelledby`\n * or use a label (development warning otherwise).\n * - **Forms**: with `name` the committed value is submitted; `required` makes the input natively\n * required; a form reset restores `defaultValue`.\n * - **Empty values**: `allowEmpty` lets the value become `null` (an empty field). Clearing the\n * text and committing it (blur or Enter) sets the value to `null`, uncontrolled too; stepping\n * up or down from an empty value starts at 0 and clamps to the nearest bound. `required` (its\n * own, or a required Field's) still blocks submitting an empty value: the check runs on the\n * `HiddenInput` that carries the committed value, not on the shown text, so it keeps working\n * even when the shown text is not empty.\n * - **Display text**: `displayValue` shows formatted text (`$1.00`) for the value while the field\n * is not being edited, and as its `aria-valuetext`; while the field has focus and can be\n * edited it shows the plain number instead, so typing still edits the number (a consumer\n * `aria-valuetext` always wins). It applies only while `value` is controlled: an uncontrolled\n * spin button ignores it and warns once in development.\n * - **Size and appearance**: `size` resolves from its own prop, then the surrounding `Field`'s\n * `size`, then `WaveProvider inputDefaults.size`, else `'medium'`; `appearance` from its own\n * prop, then `WaveProvider inputDefaults.appearance`, else `'outline'`; both render as\n * `data-size` and `data-appearance` on the root. SpinButton takes every size the other fields\n * do, and unlike 0.7 its root is now exactly as tall as theirs, with its step buttons and\n * input taking up that height; sizing the root wider widens the input instead of leaving\n * empty space inside it. The step buttons keep a 1px separator from the input only in\n * `outline`; the other appearances have none.\n * - The −/+ buttons are named \"Decrement\"/\"Increment\"; `labels` localizes the names.\n *\n * @example\n * <SpinButton aria-label=\"Quantity\" min={1} max={10} value={qty} onValueChange={setQty} />\n */\nexport const SpinButton = (props: SpinButtonProps | SpinButtonAllowEmptyProps): React.ReactNode => {\n const {\n allowEmpty = false,\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n ...baseProps\n } = props as SpinButtonBaseProps & {\n allowEmpty?: boolean;\n value?: number | null;\n defaultValue?: number | null;\n onValueChange?: (value: number | null) => void;\n onChange?: (value: number) => void;\n };\n const {\n min = -Infinity,\n max = Infinity,\n step = 1,\n largeStep,\n precision,\n disabled,\n name,\n form,\n labels,\n displayValue,\n size: sizeProp,\n appearance: appearanceProp,\n className,\n hidden,\n ref,\n controlRef,\n // Routed to the input (C-ROUTING)\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n 'aria-valuetext': ariaValueText,\n required,\n readOnly,\n placeholder,\n maxLength,\n spellCheck,\n autoComplete = 'off',\n autoFocus,\n inputMode,\n enterKeyHint,\n tabIndex,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n ...rest\n } = baseProps;\n\n if (onChange !== undefined) warnDeprecated('SpinButton', 'onChange', 'onValueChange');\n const initialValue = defaultValue !== undefined ? defaultValue : allowEmpty ? null : 0;\n const [value, setValue, isControlled] = useControllable<number | null>(\n valueProp,\n initialValue,\n (next) => {\n onValueChange?.(next);\n if (next !== null) onChange?.(next);\n },\n );\n\n // The text is a draft while the user types (null = show the value).\n const [draft, setDraft] = React.useState<string | null>(null);\n // A value that changes from outside replaces the draft (adjust state during render, C-HOOKS).\n const [prevValue, setPrevValue] = React.useState(value);\n if (!Object.is(prevValue, value)) {\n setPrevValue(value);\n setDraft(null);\n }\n // Phase 4 D15: whether the input currently has focus, tracked from the composed onFocus/onBlur\n // below (after the consumer's), for the displayValue formula.\n const [focused, setFocused] = React.useState(false);\n // Whether the whole text was selected right before the focus that `focused` now reflects, so\n // the effect below can reselect the whole new text once the shown text switches.\n const reselectRef = React.useRef(false);\n\n const draftNumber = draft === null ? null : parseNumberText(draft);\n // What stepping starts from: the typed draft when it is a number, else the value. The −/+\n // buttons are enabled by it too, so they agree with ArrowUp/ArrowDown while the user types.\n const current = draftNumber ?? value;\n const draftInvalid =\n draft !== null &&\n draftNumber === null &&\n draft.trim() !== '' &&\n !PARTIAL_NUMBER_TEXT.test(draft.trim());\n\n const clamp = (n: number) => Math.min(max, Math.max(min, n));\n const interactive = !disabled && !readOnly;\n // Phase 4 D15: displayValue applies only while the value is controlled; while the field has\n // focus and can be edited, the plain number always shows instead (never displayValue).\n const showsDisplay = isControlled && displayValue !== undefined;\n // Phase 4 D19: a non-finite precision (NaN, Infinity) behaves as unset instead of reaching\n // roundTo, since Math.trunc(NaN) is NaN and Math.min/Math.max would otherwise carry it\n // through to `toFixed`, which treats a NaN argument as 0 (rounding to whole numbers).\n const places =\n precision === undefined || !Number.isFinite(precision)\n ? undefined\n : Math.min(20, Math.max(0, Math.trunc(precision)));\n\n const commit = (next: number) => {\n setDraft(null);\n const rounded = places === undefined ? next : roundTo(next, places);\n setValue(clamp(rounded));\n };\n\n /** The value one step of `delta` from `from` (0 while empty), rounded and clamped. */\n const stepFrom = (from: number | null, delta: number) => {\n const base = from ?? 0;\n const decimals = places ?? Math.max(decimalsOf(step), decimalsOf(delta), decimalsOf(base));\n return clamp(roundTo(base + delta, decimals));\n };\n\n /** Steps from the typed draft when it is a number, else from the value (0 while empty). */\n const stepBy = (delta: number) => {\n setDraft(null);\n setValue(stepFrom(current, delta));\n };\n\n // Phase 4 D18: a press on a step button becomes a hold after SPIN_DELAY and then repeats\n // (startSpin runs the timers); a shorter press steps on its click (WCAG 2.5.2).\n const holdRef = React.useRef<{\n /** The pointer holding the button: only its release, cancel or leave ends the hold. */\n pointerId: number;\n direction: 1 | -1;\n /** Whether the hold has stepped yet. */\n stepped: boolean;\n stop: () => void;\n } | null>(null);\n // Whether the press that ends in the next pointer click has repeated (reset by every press of\n // a primary pointer).\n const repeatedRef = React.useRef(false);\n\n const stopHold = React.useCallback(() => {\n holdRef.current?.stop();\n holdRef.current = null;\n }, []);\n\n /** Ends the hold on a pointerup, pointercancel or pointerleave of the pointer holding it. */\n const endHold = (event: React.PointerEvent<HTMLButtonElement>) => {\n if (event.pointerId === holdRef.current?.pointerId) stopHold();\n };\n\n /** Whether the value the user sees is at the bound a step in `direction` moves towards. */\n const atBound = (direction: 1 | -1) =>\n current !== null && (direction === 1 ? current >= max : current <= min);\n\n // One step of the hold, with the latest render's values; returns false to end the hold.\n const holdStep = useEventCallback((): boolean => {\n const hold = holdRef.current;\n if (!hold) return false;\n if (!interactive || atBound(hold.direction)) {\n stopHold();\n return false;\n }\n repeatedRef.current = true;\n const delta = hold.direction * step;\n if (hold.stepped) {\n // Later steps start from what useControllable's updater gets, never from this render's\n // closure: a value set earlier in the same task (several steps can run before React\n // renders), else the rendered one, so a controlled parent that ignored a step is stepped\n // from its own value again.\n setDraft(null);\n setValue((prev) => stepFrom(prev, delta));\n } else {\n // The first step starts where a click would: from the typed number, else the value.\n hold.stepped = true;\n stepBy(delta);\n }\n return true;\n });\n\n const startHold = (event: React.PointerEvent<HTMLButtonElement>, direction: 1 | -1) => {\n // Only a primary pointer presses a step button: a second finger (which gets no click) neither\n // starts a hold nor resets the flag of the press that holds one.\n if (!event.isPrimary) return;\n // Every press resets the flag, so a hold that ended without a click (at a bound, or a touch\n // long press) cannot swallow the click of a later press.\n repeatedRef.current = false;\n // A hold needs the primary button: not a secondary one, nor a Ctrl+press with a mouse (the\n // secondary click on macOS).\n if (event.button !== 0 || (event.pointerType === 'mouse' && event.ctrlKey) || !interactive) {\n return;\n }\n // Touch and pen capture the pointer implicitly on the element the press landed on (the glyph\n // when the finger lands on it); release it there, so pointerleave fires when the finger slides\n // off the button.\n const holder = event.target instanceof Element ? event.target : event.currentTarget;\n if (event.pointerType !== 'mouse' && holder.hasPointerCapture?.(event.pointerId)) {\n holder.releasePointerCapture(event.pointerId);\n }\n stopHold();\n holdRef.current = {\n pointerId: event.pointerId,\n direction,\n stepped: false,\n stop: startSpin(holdStep),\n };\n };\n\n const clickStep = (event: React.MouseEvent<HTMLButtonElement>, direction: 1 | -1) => {\n // A click without a press (detail 0: a screen reader, element.click()) steps once; a pointer\n // click steps unless its press already repeated.\n if (event.detail !== 0 && repeatedRef.current) {\n repeatedRef.current = false;\n return;\n }\n stepBy(direction * step);\n };\n\n // A hold stops once the control cannot step its way any more: disabled, read-only, or at the\n // bound it steps towards (where its button is disabled).\n React.useEffect(() => {\n const hold = holdRef.current;\n if (hold && (!interactive || atBound(hold.direction))) stopHold();\n });\n // It also stops when the window loses focus (a release outside it never reaches the button),\n // and on unmount.\n React.useEffect(() => {\n window.addEventListener('blur', stopHold);\n return () => {\n window.removeEventListener('blur', stopHold);\n stopHold();\n };\n }, [stopHold]);\n\n const commitDraft = () => {\n if (draft === null) return;\n if (allowEmpty && draft.trim() === '') {\n setDraft(null);\n setValue(null);\n return;\n }\n if (draftNumber === null) setDraft(null);\n else commit(draftNumber);\n };\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedInputRef = useMergedRefs(inputRef, controlRef);\n\n const field = useFieldContext();\n const isRequired = required ?? field?.required ?? false;\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n required,\n },\n { nativeRequired: true },\n );\n // Typed text that is not a number is invalid whatever the consumer says; otherwise the\n // consumer's or the Field's `aria-invalid` is passed through as is (`grammar` included), and the\n // error look follows the shared rule of the text controls.\n const ariaInvalidValue = draftInvalid ? true : fieldProps['aria-invalid'];\n const invalidLook = isInvalidLook(false, ariaInvalidValue);\n const { size, appearance } = useInputLook(sizeProp, appearanceProp);\n\n useFormReset(\n inputRef,\n () => {\n setDraft(null);\n setValue(initialValue);\n },\n form,\n );\n\n // No built-in name any more (\"Value\" named every instance the same): report unnamed inputs.\n React.useEffect(() => {\n const input = inputRef.current;\n if (!input) return;\n const named =\n input.hasAttribute('aria-label') ||\n input.hasAttribute('aria-labelledby') ||\n (input.labels?.length ?? 0) > 0 ||\n input.hasAttribute('title');\n if (!named) {\n warnOnce(\n 'SpinButton:unnamed',\n 'SpinButton: the spinbutton has no accessible name. Pass `aria-label` or `aria-labelledby`, use a <label htmlFor>, or render it inside a Field.',\n );\n }\n });\n\n // Phase 4 D15: an uncontrolled SpinButton ignores displayValue (it would make the shown text\n // lie as soon as the value changes without a matching prop update).\n React.useEffect(() => {\n if (displayValue !== undefined && !isControlled) {\n warnOnce(\n 'SpinButton:displayValue-uncontrolled',\n 'SpinButton: `displayValue` is ignored while the value is uncontrolled; pass `value` (and update it in `onValueChange`).',\n );\n }\n }, [displayValue, isControlled]);\n\n // A stable callback, so composing it with the consumer's onFocus reads no ref during render.\n const handleFocus = useEventCallback((e: React.FocusEvent<HTMLInputElement>) => {\n const input = e.target;\n reselectRef.current =\n input.value.length > 0 &&\n input.selectionStart === 0 &&\n input.selectionEnd === input.value.length;\n setFocused(true);\n });\n\n const handleBlur = () => {\n commitDraft();\n setFocused(false);\n };\n\n // Reselects the whole text once the shown text switches (blur shows displayValue, and a\n // programmatic focus that starts the field's editing mode shows the plain number) after a\n // focus that started with everything selected (Tab, or a consumer onFocus that calls\n // select()), so typing right after still replaces the whole value.\n React.useLayoutEffect(() => {\n if (!focused || !reselectRef.current) return;\n reselectRef.current = false;\n inputRef.current?.select();\n }, [focused]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n // Read-only: the keys keep their native caret behaviour and never change the value.\n if (!interactive || e.altKey || e.ctrlKey || e.metaKey) return;\n // Ten steps, rounded: step * 10 carries float error (0.07 * 10 = 0.7000000000000001) that\n // stepBy would otherwise keep, since it rounds to the precision of the delta too.\n const big = largeStep ?? roundTo(step * 10, decimalsOf(step));\n switch (e.key) {\n case 'ArrowUp':\n case 'ArrowDown':\n case 'PageUp':\n case 'PageDown': {\n e.preventDefault();\n const amount = e.key === 'ArrowUp' || e.key === 'ArrowDown' ? step : big;\n stepBy(e.key === 'ArrowUp' || e.key === 'PageUp' ? amount : -amount);\n return;\n }\n case 'Home':\n case 'End': {\n if (e.shiftKey) return; // Shift+Home/End select text (Fluent)\n const bound = e.key === 'Home' ? min : max;\n if (!Number.isFinite(bound)) return; // no bound: Home/End move the caret\n e.preventDefault();\n commit(bound);\n return;\n }\n case 'Enter':\n // Not prevented: Enter still submits the surrounding form, with the committed value.\n commitDraft();\n return;\n case 'Escape':\n if (draft !== null) {\n e.preventDefault(); // enclosing layers (a Dialog) ignore this Escape\n setDraft(null);\n }\n return;\n default:\n }\n };\n\n const defaultInputMode: React.HTMLAttributes<HTMLInputElement>['inputMode'] =\n min < 0 ? 'text' : decimalsOf(step) > 0 || decimalsOf(min) > 0 ? 'decimal' : 'numeric';\n\n // The step buttons never take focus: a pointer press leaves it where it is (on the input while\n // editing), so a button that becomes disabled at a bound cannot drop focus to <body>.\n const keepFocus = (e: React.MouseEvent) => e.preventDefault();\n\n return (\n <div\n ref={ref}\n data-size={size}\n data-appearance={appearance}\n className={cn(\n spinButtonClassNames.root,\n 'relative inline-flex items-center',\n inputHeightClasses[size],\n inputTextClasses[size],\n inputAppearanceClasses[appearance],\n inputFocusWithin,\n invalidLook && inputInvalidWithin,\n disabled && 'cursor-not-allowed opacity-50',\n className,\n )}\n hidden={hidden}\n {...rest}\n >\n <button\n type=\"button\"\n tabIndex={-1}\n onPointerDown={(event) => startHold(event, -1)}\n onPointerUp={endHold}\n onPointerCancel={endHold}\n onPointerLeave={endHold}\n onClick={(event) => clickStep(event, -1)}\n onMouseDown={keepFocus}\n onContextMenu={(event) => event.preventDefault()}\n disabled={!interactive || (current !== null && current <= min)}\n aria-label={labels?.decrement ?? 'Decrement'}\n className={cn(\n spinButtonClassNames.decrementButton,\n stepButtonClass,\n SPIN_SIZE[size].button,\n appearance === 'outline' && 'border-e border-input',\n appearance === 'filled-darker' &&\n 'not-disabled:not-aria-disabled:hover:bg-subtle-pressed',\n !disabled && 'disabled:opacity-50',\n )}\n >\n <SubtractIcon size={SPIN_SIZE[size].glyph} />\n </button>\n\n <input\n ref={mergedInputRef}\n type=\"text\"\n role=\"spinbutton\"\n inputMode={inputMode ?? defaultInputMode}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n enterKeyHint={enterKeyHint}\n placeholder={placeholder}\n maxLength={maxLength}\n spellCheck={spellCheck}\n tabIndex={tabIndex}\n readOnly={readOnly}\n form={form}\n {...fieldProps}\n aria-invalid={ariaInvalidValue}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n aria-valuenow={value ?? undefined}\n aria-valuemin={Number.isFinite(min) ? min : undefined}\n aria-valuemax={Number.isFinite(max) ? max : undefined}\n aria-valuetext={ariaValueText ?? (showsDisplay ? displayValue : undefined)}\n value={\n draft ??\n (showsDisplay && !(focused && interactive)\n ? displayValue\n : value === null\n ? ''\n : String(value))\n }\n onChange={(e) => setDraft(e.target.value)}\n onFocus={composeEventHandlers(onFocus, handleFocus, { checkDefaultPrevented: false })}\n onBlur={composeEventHandlers(onBlur, handleBlur, { checkDefaultPrevented: false })}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onKeyUp={onKeyUp}\n disabled={disabled}\n className={cn(\n spinButtonClassNames.input,\n 'h-full min-w-0 flex-auto border-none bg-transparent text-center text-foreground focus:outline-hidden disabled:cursor-not-allowed [appearance:textfield]',\n SPIN_SIZE[size].input,\n inputTextClasses[size],\n )}\n />\n\n <button\n type=\"button\"\n tabIndex={-1}\n onPointerDown={(event) => startHold(event, 1)}\n onPointerUp={endHold}\n onPointerCancel={endHold}\n onPointerLeave={endHold}\n onClick={(event) => clickStep(event, 1)}\n onMouseDown={keepFocus}\n onContextMenu={(event) => event.preventDefault()}\n disabled={!interactive || (current !== null && current >= max)}\n aria-label={labels?.increment ?? 'Increment'}\n className={cn(\n spinButtonClassNames.incrementButton,\n stepButtonClass,\n SPIN_SIZE[size].button,\n appearance === 'outline' && 'border-s border-input',\n appearance === 'filled-darker' &&\n 'not-disabled:not-aria-disabled:hover:bg-subtle-pressed',\n !disabled && 'disabled:opacity-50',\n )}\n >\n <AddIcon size={SPIN_SIZE[size].glyph} />\n </button>\n\n <HiddenInput\n name={name}\n form={form}\n disabled={disabled}\n type=\"text\"\n value={value === null ? '' : String(value)}\n required={allowEmpty ? isRequired : undefined}\n onInvalid={() => inputRef.current?.focus()}\n />\n </div>\n );\n};\n\nSpinButton.displayName = 'SpinButton';\n"],"mappings":";;;;;;;;;;;;;;;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;IACb,gBAAgB,MAAUrC,EAAM,eAAe;IAC/C,UAAU,CAAClB,KAAgBL,MAAY,QAAQA,KAAWG;IAC1D,cAAYkE,GAAQ,aAAa;IACjC,WAAWxG,EACTkG,EAAqB,iBACrBnG,GACAD,EAAUkG,EAAK,CAAC,QAChBC,MAAe,aAAa,yBAC5BA,MAAe,mBACb,0DACF,CAACxD,KAAY,qBACf;IAEA,UAAA,kBAACsE,IAAD,EAAS,MAAMjH,EAAUkG,EAAK,CAAC,MAAQ,CAAA;GACjC,CAAA;GAER,kBAACgB,IAAD;IACQ;IACA;IACI;IACV,MAAK;IACL,OAAO3F,MAAU,OAAO,KAAK,OAAOA,CAAK;IACzC,UAAUD,IAAauD,KAAa,KAAA;IACpC,iBAAiBN,EAAS,SAAS,MAAM;GAC1C,CAAA;EACE;;AAET;AAEA,EAAW,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../hooks/useControllable.cjs"),
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useControllable.cjs"),o=require("../../hooks/useRovingTabIndex.cjs"),s=require("../../hooks/useMergedRefs.cjs"),c=require("../../hooks/useFieldControl.cjs"),l=require("../../lib/styles.cjs"),u=require("../../lib/icons.cjs"),d=require("../../hooks/useFormReset.cjs"),f=require("../internal/HiddenInput.cjs"),p=require("./colorUtils.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var g={small:`w-6 h-6`,medium:`w-8 h-8`,large:`w-10 h-10`},_={small:12,medium:16,large:20},v={circular:`rounded-full`,square:`rounded-none`,rounded:`rounded`};function y({color:e,size:t}){let{glyph:n,halo:r}=p.getCheckColors(e);return(0,h.jsxs)(`span`,{"aria-hidden":`true`,className:`pointer-events-none grid`,children:[(0,h.jsx)(u.CheckIcon,{size:t,strokeWidth:4,className:`col-start-1 row-start-1`,style:{color:r}}),(0,h.jsx)(u.CheckIcon,{size:t,strokeWidth:2,className:`col-start-1 row-start-1`,style:{color:n}})]})}var b=({items:e,value:u,defaultValue:p,onValueChange:b,onChange:x,size:S=`medium`,shape:C=`circular`,name:w,required:T,form:E,className:D,id:O,"aria-label":k,"aria-labelledby":A,"aria-describedby":j,"aria-invalid":M,"aria-required":N,onKeyDown:P,onFocus:F,ref:I,...L})=>{x!==void 0&&n.warnDeprecated(`SwatchPicker`,`onChange`,`onValueChange`);let R=p??``,[z,B]=a.useControllable(u,R,e=>{b?.(e),x?.(e)}),{containerProps:V,getTabIndex:H}=o.useRovingTabIndex({activeValue:z||null,orientation:`both`,onFocusMove:e=>B(e)}),U=m.useRef(null),W=s.useMergedRefs(I,V.ref,U),G=c.useFieldContext(),K=c.useFieldControl({id:O,"aria-label":k,"aria-labelledby":A,"aria-describedby":j,"aria-invalid":M,"aria-required":N??T},{labelable:!1}),q=T??G?.required??!1,J=K[`aria-label`]===void 0&&K[`aria-labelledby`]===void 0,Y=e.find(e=>!e.label)?.value;m.useEffect(()=>{J&&n.warnOnce(`SwatchPicker:unnamed`,"SwatchPicker: the radiogroup has no accessible name. Pass `aria-label` or `aria-labelledby`, or render it inside a Field.")},[J]),m.useEffect(()=>{Y!==void 0&&n.warnOnce(`SwatchPicker:item-label`,`SwatchPicker: swatch "${Y}" has no \`label\`, so it is announced by its color value. Give every item a \`label\`.`)},[Y]),d.useFormReset(U,()=>B(R),E);let X=()=>{U.current?.querySelector(`[data-roving-value][tabindex="0"]`)?.focus()};return(0,h.jsxs)(`div`,{role:`radiogroup`,...K,className:t.cn(i.swatchPickerClassNames.root,`relative flex flex-wrap gap-2`,D),...L,ref:W,"data-roving-container":``,onKeyDown:r.composeEventHandlers(P,V.onKeyDown),onFocus:r.composeEventHandlers(F,V.onFocus,{checkDefaultPrevented:!1}),children:[e.map(e=>{let n=z===e.value;return(0,h.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e.label||e.color,"data-roving-value":e.value,"data-selected":n?``:void 0,tabIndex:H(e.value),onClick:()=>B(e.value),className:t.cn(i.swatchPickerClassNames.swatch,g[S],v[C],`relative flex shrink-0 items-center justify-center border-2 border-transparent p-0`,l.motionSafeTransition,`forced-colors:forced-color-adjust-none`,l.forcedColors.border,l.focusRing,`focus-visible:outline-offset-4`,n?`ring-2 ring-foreground ring-offset-2 ring-offset-background`:`hover:border-stroke-hover`),style:{backgroundColor:e.color},children:n&&(0,h.jsx)(y,{color:e.color,size:_[S]})},e.value)}),(0,h.jsx)(f.HiddenInput,{type:`radio`,name:w,form:E,value:z,required:q,onInvalid:X})]})};b.displayName=`SwatchPicker`,exports.SwatchPicker=b;
|
|
2
2
|
//# sourceMappingURL=SwatchPicker.cjs.map
|