@mortenbrudvik/waveui 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +564 -155
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.mjs +36 -35
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/button/Button.slots.cjs +1 -1
- package/dist/components/button/Button.slots.cjs.map +1 -1
- package/dist/components/button/Button.slots.mjs +31 -21
- package/dist/components/button/Button.slots.mjs.map +1 -1
- package/dist/components/button/CompoundButton.cjs +1 -1
- package/dist/components/button/CompoundButton.cjs.map +1 -1
- package/dist/components/button/CompoundButton.mjs +31 -29
- package/dist/components/button/CompoundButton.mjs.map +1 -1
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +24 -23
- package/dist/components/button/Link.mjs.map +1 -1
- package/dist/components/button/MenuButton.cjs +1 -1
- package/dist/components/button/MenuButton.cjs.map +1 -1
- package/dist/components/button/MenuButton.mjs +29 -28
- package/dist/components/button/MenuButton.mjs.map +1 -1
- package/dist/components/button/SplitButton.cjs +1 -1
- package/dist/components/button/SplitButton.cjs.map +1 -1
- package/dist/components/button/SplitButton.mjs +46 -45
- package/dist/components/button/SplitButton.mjs.map +1 -1
- package/dist/components/button/ToggleButton.cjs +1 -1
- package/dist/components/button/ToggleButton.cjs.map +1 -1
- package/dist/components/button/ToggleButton.mjs +38 -35
- package/dist/components/button/ToggleButton.mjs.map +1 -1
- package/dist/components/button/Toolbar.cjs +1 -1
- package/dist/components/button/Toolbar.cjs.map +1 -1
- package/dist/components/button/Toolbar.mjs +43 -42
- package/dist/components/button/Toolbar.mjs.map +1 -1
- package/dist/components/button/Toolbar.parts.cjs +1 -1
- package/dist/components/button/Toolbar.parts.cjs.map +1 -1
- package/dist/components/button/Toolbar.parts.mjs +76 -81
- package/dist/components/button/Toolbar.parts.mjs.map +1 -1
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.mjs +72 -67
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.mjs +89 -88
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
- package/dist/components/data-display/Badge.cjs +1 -1
- package/dist/components/data-display/Badge.cjs.map +1 -1
- package/dist/components/data-display/Badge.mjs +17 -16
- package/dist/components/data-display/Badge.mjs.map +1 -1
- package/dist/components/data-display/CounterBadge.cjs +1 -1
- package/dist/components/data-display/CounterBadge.cjs.map +1 -1
- package/dist/components/data-display/CounterBadge.mjs +18 -17
- package/dist/components/data-display/CounterBadge.mjs.map +1 -1
- package/dist/components/data-display/Divider.cjs +1 -1
- package/dist/components/data-display/Divider.cjs.map +1 -1
- package/dist/components/data-display/Divider.mjs +31 -30
- package/dist/components/data-display/Divider.mjs.map +1 -1
- package/dist/components/data-display/Image.cjs +1 -1
- package/dist/components/data-display/Image.cjs.map +1 -1
- package/dist/components/data-display/Image.mjs +16 -15
- package/dist/components/data-display/Image.mjs.map +1 -1
- package/dist/components/data-display/InfoButton.cjs +2 -0
- package/dist/components/data-display/InfoButton.cjs.map +1 -0
- package/dist/components/data-display/InfoButton.mjs +173 -0
- package/dist/components/data-display/InfoButton.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +36 -92
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +175 -174
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/Persona.cjs +1 -1
- package/dist/components/data-display/Persona.cjs.map +1 -1
- package/dist/components/data-display/Persona.mjs +31 -29
- package/dist/components/data-display/Persona.mjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.cjs +1 -1
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.mjs +25 -24
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +87 -82
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.cjs +1 -1
- package/dist/components/feedback/MessageBar.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.mjs +129 -71
- package/dist/components/feedback/MessageBar.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.parts.cjs +2 -0
- package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.parts.mjs +84 -0
- package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
- package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
- package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +1 -1
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.status.mjs +2 -1
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
- package/dist/components/feedback/ProgressBar.cjs +1 -1
- package/dist/components/feedback/ProgressBar.cjs.map +1 -1
- package/dist/components/feedback/ProgressBar.mjs +44 -43
- package/dist/components/feedback/ProgressBar.mjs.map +1 -1
- package/dist/components/feedback/Skeleton.cjs +1 -1
- package/dist/components/feedback/Skeleton.cjs.map +1 -1
- package/dist/components/feedback/Skeleton.mjs +26 -24
- package/dist/components/feedback/Skeleton.mjs.map +1 -1
- package/dist/components/feedback/Spinner.cjs +1 -1
- package/dist/components/feedback/Spinner.cjs.map +1 -1
- package/dist/components/feedback/Spinner.mjs +32 -31
- package/dist/components/feedback/Spinner.mjs.map +1 -1
- package/dist/components/feedback/Toast.cjs +1 -1
- package/dist/components/feedback/Toast.cjs.map +1 -1
- package/dist/components/feedback/Toast.context.cjs +2 -0
- package/dist/components/feedback/Toast.context.cjs.map +1 -0
- package/dist/components/feedback/Toast.context.mjs +23 -0
- package/dist/components/feedback/Toast.context.mjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +10 -342
- package/dist/components/feedback/Toast.mjs.map +1 -1
- package/dist/components/feedback/Toast.parts.cjs +2 -0
- package/dist/components/feedback/Toast.parts.cjs.map +1 -0
- package/dist/components/feedback/Toast.parts.mjs +98 -0
- package/dist/components/feedback/Toast.parts.mjs.map +1 -0
- package/dist/components/feedback/Toast.root.cjs +2 -0
- package/dist/components/feedback/Toast.root.cjs.map +1 -0
- package/dist/components/feedback/Toast.root.mjs +109 -0
- package/dist/components/feedback/Toast.root.mjs.map +1 -0
- package/dist/components/feedback/Toaster.cjs +2 -0
- package/dist/components/feedback/Toaster.cjs.map +1 -0
- package/dist/components/feedback/Toaster.mjs +564 -0
- package/dist/components/feedback/Toaster.mjs.map +1 -0
- package/dist/components/input/AlphaSlider.cjs +2 -0
- package/dist/components/input/AlphaSlider.cjs.map +1 -0
- package/dist/components/input/AlphaSlider.mjs +115 -0
- package/dist/components/input/AlphaSlider.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +1 -1
- package/dist/components/input/Checkbox.cjs.map +1 -1
- package/dist/components/input/Checkbox.mjs +87 -70
- package/dist/components/input/Checkbox.mjs.map +1 -1
- package/dist/components/input/ColorArea.cjs +2 -0
- package/dist/components/input/ColorArea.cjs.map +1 -0
- package/dist/components/input/ColorArea.mjs +204 -0
- package/dist/components/input/ColorArea.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +5 -5
- package/dist/components/input/ColorPicker.cjs.map +1 -1
- package/dist/components/input/ColorPicker.mjs +142 -165
- package/dist/components/input/ColorPicker.mjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.cjs +2 -0
- package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
- package/dist/components/input/ColorPicker.parts.mjs +192 -0
- package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
- package/dist/components/input/ColorSlider.cjs +2 -0
- package/dist/components/input/ColorSlider.cjs.map +1 -0
- package/dist/components/input/ColorSlider.mjs +138 -0
- package/dist/components/input/ColorSlider.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +22 -22
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +151 -141
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +239 -234
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +109 -100
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Field.cjs +1 -1
- package/dist/components/input/Field.cjs.map +1 -1
- package/dist/components/input/Field.mjs +139 -105
- package/dist/components/input/Field.mjs.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.mjs +80 -55
- package/dist/components/input/Input.mjs.map +1 -1
- package/dist/components/input/Label.cjs +1 -1
- package/dist/components/input/Label.cjs.map +1 -1
- package/dist/components/input/Label.mjs +19 -12
- package/dist/components/input/Label.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +100 -98
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/RadioGroup.cjs +1 -1
- package/dist/components/input/RadioGroup.cjs.map +1 -1
- package/dist/components/input/RadioGroup.mjs +89 -88
- package/dist/components/input/RadioGroup.mjs.map +1 -1
- package/dist/components/input/Rating.cjs +1 -1
- package/dist/components/input/Rating.cjs.map +1 -1
- package/dist/components/input/Rating.item.cjs +2 -0
- package/dist/components/input/Rating.item.cjs.map +1 -0
- package/dist/components/input/Rating.item.mjs +255 -0
- package/dist/components/input/Rating.item.mjs.map +1 -0
- package/dist/components/input/Rating.mjs +152 -152
- package/dist/components/input/Rating.mjs.map +1 -1
- package/dist/components/input/SearchBox.cjs +1 -1
- package/dist/components/input/SearchBox.cjs.map +1 -1
- package/dist/components/input/SearchBox.mjs +162 -132
- package/dist/components/input/SearchBox.mjs.map +1 -1
- package/dist/components/input/Select.cjs +1 -1
- package/dist/components/input/Select.cjs.map +1 -1
- package/dist/components/input/Select.mjs +34 -24
- package/dist/components/input/Select.mjs.map +1 -1
- package/dist/components/input/Slider.cjs +1 -1
- package/dist/components/input/Slider.cjs.map +1 -1
- package/dist/components/input/Slider.mjs +78 -54
- package/dist/components/input/Slider.mjs.map +1 -1
- package/dist/components/input/SpinButton.cjs +1 -1
- package/dist/components/input/SpinButton.cjs.map +1 -1
- package/dist/components/input/SpinButton.mjs +202 -99
- package/dist/components/input/SpinButton.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.mjs +38 -37
- package/dist/components/input/SwatchPicker.mjs.map +1 -1
- package/dist/components/input/Switch.cjs +1 -1
- package/dist/components/input/Switch.cjs.map +1 -1
- package/dist/components/input/Switch.mjs +75 -58
- package/dist/components/input/Switch.mjs.map +1 -1
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.mjs +199 -169
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/Textarea.cjs +1 -1
- package/dist/components/input/Textarea.cjs.map +1 -1
- package/dist/components/input/Textarea.mjs +31 -23
- package/dist/components/input/Textarea.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +185 -177
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/input/colorName.cjs +2 -0
- package/dist/components/input/colorName.cjs.map +1 -0
- package/dist/components/input/colorName.mjs +30 -0
- package/dist/components/input/colorName.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +1 -1
- package/dist/components/input/colorUtils.cjs.map +1 -1
- package/dist/components/input/colorUtils.mjs +154 -56
- package/dist/components/input/colorUtils.mjs.map +1 -1
- package/dist/components/input/fieldLabel.cjs +2 -0
- package/dist/components/input/fieldLabel.cjs.map +1 -0
- package/dist/components/input/fieldLabel.mjs +17 -0
- package/dist/components/input/fieldLabel.mjs.map +1 -0
- package/dist/components/input/inputLook.cjs +2 -0
- package/dist/components/input/inputLook.cjs.map +1 -0
- package/dist/components/input/inputLook.mjs +28 -0
- package/dist/components/input/inputLook.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +1 -1
- package/dist/components/input/pickerStyles.cjs.map +1 -1
- package/dist/components/input/pickerStyles.mjs +42 -4
- package/dist/components/input/pickerStyles.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs +130 -129
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/layout/Card.cjs +1 -1
- package/dist/components/layout/Card.cjs.map +1 -1
- package/dist/components/layout/Card.mjs +78 -77
- package/dist/components/layout/Card.mjs.map +1 -1
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.mjs +111 -110
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/Flex.cjs +1 -1
- package/dist/components/layout/Flex.cjs.map +1 -1
- package/dist/components/layout/Flex.mjs +22 -21
- package/dist/components/layout/Flex.mjs.map +1 -1
- package/dist/components/layout/Grid.cjs +1 -1
- package/dist/components/layout/Grid.cjs.map +1 -1
- package/dist/components/layout/Grid.mjs +19 -18
- package/dist/components/layout/Grid.mjs.map +1 -1
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +92 -91
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Stack.cjs +1 -1
- package/dist/components/layout/Stack.cjs.map +1 -1
- package/dist/components/layout/Stack.mjs +14 -13
- package/dist/components/layout/Stack.mjs.map +1 -1
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +118 -117
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/layout/Tree.cjs +1 -1
- package/dist/components/layout/Tree.cjs.map +1 -1
- package/dist/components/layout/Tree.context.cjs +2 -0
- package/dist/components/layout/Tree.context.cjs.map +1 -0
- package/dist/components/layout/Tree.context.mjs +33 -0
- package/dist/components/layout/Tree.context.mjs.map +1 -0
- package/dist/components/layout/Tree.core.cjs +2 -0
- package/dist/components/layout/Tree.core.cjs.map +1 -0
- package/dist/components/layout/Tree.core.mjs +416 -0
- package/dist/components/layout/Tree.core.mjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
- package/dist/components/layout/Tree.mjs +7 -215
- package/dist/components/layout/Tree.mjs.map +1 -1
- package/dist/components/layout/Tree.selection.cjs +2 -0
- package/dist/components/layout/Tree.selection.cjs.map +1 -0
- package/dist/components/layout/Tree.selection.mjs +73 -0
- package/dist/components/layout/Tree.selection.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +76 -75
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/navigation/Menu.group.cjs +1 -1
- package/dist/components/navigation/Menu.group.cjs.map +1 -1
- package/dist/components/navigation/Menu.group.mjs +39 -37
- package/dist/components/navigation/Menu.group.mjs.map +1 -1
- package/dist/components/navigation/Menu.items.cjs +1 -1
- package/dist/components/navigation/Menu.items.cjs.map +1 -1
- package/dist/components/navigation/Menu.items.mjs +67 -61
- package/dist/components/navigation/Menu.items.mjs.map +1 -1
- package/dist/components/navigation/Menu.link.cjs +1 -1
- package/dist/components/navigation/Menu.link.cjs.map +1 -1
- package/dist/components/navigation/Menu.link.mjs +34 -28
- package/dist/components/navigation/Menu.link.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +114 -113
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +171 -170
- package/dist/components/navigation/Menu.root.mjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.cjs +1 -1
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.mjs +85 -63
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.cjs +1 -1
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.mjs +6 -6
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.mjs +170 -155
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination.cjs.map +1 -1
- package/dist/components/navigation/Pagination.mjs +73 -65
- package/dist/components/navigation/Pagination.mjs.map +1 -1
- package/dist/components/navigation/Stepper.cjs +1 -1
- package/dist/components/navigation/Stepper.cjs.map +1 -1
- package/dist/components/navigation/Stepper.mjs +110 -109
- package/dist/components/navigation/Stepper.mjs.map +1 -1
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +109 -108
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Drawer.cjs +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.mjs +110 -109
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +148 -151
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/Popover.shared.cjs +1 -1
- package/dist/components/overlays/Popover.shared.cjs.map +1 -1
- package/dist/components/overlays/Popover.shared.mjs +82 -77
- package/dist/components/overlays/Popover.shared.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +41 -37
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +87 -86
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +33 -32
- package/dist/components/portal/Portal.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +36 -29
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +228 -227
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +60 -59
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/typography/Text.cjs +1 -1
- package/dist/components/typography/Text.cjs.map +1 -1
- package/dist/components/typography/Text.mjs +12 -11
- package/dist/components/typography/Text.mjs.map +1 -1
- package/dist/hooks/useFieldControl.cjs.map +1 -1
- package/dist/hooks/useFieldControl.mjs.map +1 -1
- package/dist/hooks/useMediaQuery.cjs +2 -0
- package/dist/hooks/useMediaQuery.cjs.map +1 -0
- package/dist/hooks/useMediaQuery.mjs +20 -0
- package/dist/hooks/useMediaQuery.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +3 -3
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2890 -197
- package/dist/index.d.ts +2890 -197
- package/dist/index.mjs +101 -87
- package/dist/lib/classNames.cjs +2 -0
- package/dist/lib/classNames.cjs.map +1 -0
- package/dist/lib/classNames.mjs +423 -0
- package/dist/lib/classNames.mjs.map +1 -0
- package/dist/lib/color.cjs +2 -0
- package/dist/lib/color.cjs.map +1 -0
- package/dist/lib/color.mjs +86 -0
- package/dist/lib/color.mjs.map +1 -0
- package/dist/lib/globalRegistry.cjs.map +1 -1
- package/dist/lib/globalRegistry.mjs.map +1 -1
- package/dist/lib/styles.cjs +1 -1
- package/dist/lib/styles.cjs.map +1 -1
- package/dist/lib/styles.mjs +21 -4
- package/dist/lib/styles.mjs.map +1 -1
- package/dist/lib/toaster.cjs +2 -0
- package/dist/lib/toaster.cjs.map +1 -0
- package/dist/lib/toaster.mjs +77 -0
- package/dist/lib/toaster.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +13 -0
|
@@ -1,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/slot.cjs"),i=require("./Button.semantics.cjs"),
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/classNames.cjs"),a=require("./Button.semantics.cjs"),o=require("./buttonStyles.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l=e=>{let{as:l,appearance:u=`outline`,size:d=`medium`,icon:f,iconPosition:p=`before`,disabled:m=!1,disabledFocusable:h=!1,className:g,children:_,ref:v,onClick:y,onKeyDown:b,onKeyUp:x,onBlur:S,...C}=e,w=l??`button`,T=typeof w==`string`?w:null,E=T!==null&&r.VOID_ELEMENTS.has(T),{defaults:D,enforced:O,handlers:k}=a.useButtonSemantics({tag:T,href:C.href,disabled:m,disabledFocusable:h,onClick:y,onKeyDown:b,onKeyUp:x,onBlur:S}),A=C[`aria-disabled`],j=r.renderSlot(r.slotRendersContent(f)?f:void 0,`span`,t.cn(i.buttonClassNames.icon,`inline-flex shrink-0 items-center`),{"aria-hidden":!0}),M=j!==null,N=r.materialiseSlotContent(_),P=r.slotRendersContent(N),F=M&&!P,I=C[`aria-label`],L=C[`aria-labelledby`],R=C.title;s.useEffect(()=>{F&&!I&&!L&&!R&&n.warnOnce(`Button:icon-only-name`,"Button: an icon-only button has no accessible name. Pass `aria-label`, `aria-labelledby` or `title` (the icon is decorative and hidden from assistive technology).")},[F,I,L,R]);let z={...C};for(let[e,t]of Object.entries(D))z[e]??=t;let B=m||h||A===!0||A===`true`,V=N;return E?V=void 0:j&&(V=p===`after`?(0,c.jsxs)(c.Fragment,{children:[N,j]}):(0,c.jsxs)(c.Fragment,{children:[j,N]})),(0,c.jsx)(w,{...z,...k,ref:v,className:t.cn(i.buttonClassNames.root,o.buttonClassName({appearance:u,size:d,disabled:B,iconOnly:F}),M&&P&&`gap-1.5`,g),...O,children:V})};l.displayName=`Button`,exports.Button=l;
|
|
2
2
|
//# sourceMappingURL=Button.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.cjs","names":["VOID_ELEMENTS","useButtonSemantics","renderSlot","slotRendersContent","materialiseSlotContent","_Fragment","cn","buttonClassName","require_runtime","require_cn","require_dev","require_slot","require_Button_semantics","require_buttonStyles","react","react_jsx_runtime","Button","rest","props","Component","as","tag","isVoid","ariaDisabled","iconElement","icon","hasIcon","label","children","hasLabel","iconOnly","ariaLabel","ariaLabelledBy","title","elementProps","key","value","defaults","showDisabledLook","disabled","disabledFocusable","content","iconPosition","handlers","className","enforced"],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnOnce } from '../../lib/dev';\nimport {\n materialiseSlotContent,\n renderSlot,\n slotRendersContent,\n VOID_ELEMENTS,\n} from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport type { Size, Appearance, IconPosition, Slot } from '../../lib/types';\nimport { useButtonSemantics } from './Button.semantics';\nimport { buttonClassName } from './buttonStyles';\n\n/**\n * The Button's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`), so `as=\"a\"` accepts `href`/`target`\n * and types `onClick` for an anchor.\n */\nexport interface ButtonOwnProps {\n /** Visual style variant.\n * @default 'outline'\n */\n appearance?: Appearance;\n /** Size affecting height, padding and font size.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Icon slot rendered before the label (after it with `iconPosition=\"after\"`). Decorative: it\n * renders with `aria-hidden=\"true\"` (a slot object can override it). An icon-only button needs\n * `aria-label`, `aria-labelledby` or `title`.\n */\n icon?: Slot<'span'>;\n /**\n * Where the icon renders: before the label (the inline start) or after it (the inline end, e.g.\n * an \"open in new window\" glyph). Follows the writing direction through DOM order. Has no effect\n * on an icon-only button.\n * @default 'before'\n */\n iconPosition?: IconPosition;\n /**\n * Disables the button. Only the intrinsic form controls (`button`, the default, and `input`,\n * `select`, `textarea`) get the native `disabled` attribute. Every other `as` — `a`, `div`,\n * `span` and **any custom component**, including router links and styled or motion components\n * that render a native `<button>` — does not receive `disabled`: it gets `aria-disabled=\"true\"`\n * and `tabIndex={-1}` instead (neither can be overridden), its clicks and Enter/Space are\n * prevented (a click does not reach ancestor `onClick` handlers either, as with a native\n * disabled button), and an `<a>` drops its `href` (it keeps `role=\"link\"` when it had one,\n * `role=\"button\"` otherwise). Such an element leaves the tab order but, like any\n * `tabIndex={-1}` element, can still take focus from a mouse click, and a component's own\n * `:disabled` styling does not apply. Every disabled Button also renders `data-disabled`.\n * @default false\n */\n disabled?: boolean;\n /**\n * Marks the button unavailable but keeps it focusable and in the tab order: for toolbar items, a\n * button that disables itself when activated, or a disabled button that needs a Tooltip. Renders\n * `aria-disabled=\"true\"`, `data-disabled` and `data-disabled-focusable` instead of the native\n * `disabled` attribute. Clicks, Enter, Space and implicit form submission are prevented; your\n * `onClick` is not called and the click does not reach ancestor click handlers. Hover and pressed\n * colors are off. Wins over `disabled` when both are set. In a `Toolbar` it stays in the\n * arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n}\n\n/**\n * Props of {@link Button} rendered as `C` (default `'button'`). `ButtonProps` without a type\n * argument is the 0.4 name: the props of a Button rendered as a `<button>`, including `ref`.\n *\n * @example\n * interface SaveButtonProps extends ButtonProps { tracking?: string }\n * const props: ButtonProps<'a'> = { as: 'a', href: '/docs', appearance: 'primary' };\n */\nexport type ButtonProps<C extends React.ElementType = 'button'> = PolymorphicProps<\n C,\n ButtonOwnProps\n>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype ButtonImplProps = ButtonOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'onClick' | 'onKeyDown' | 'onKeyUp'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n /** An anchor's destination (`as=\"a\"`): without one, the anchor gets button semantics. */\n href?: string;\n onClick?: React.MouseEventHandler<HTMLElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLElement>;\n onKeyUp?: React.KeyboardEventHandler<HTMLElement>;\n };\n\n/**\n * A button with Fluent appearances and sizes.\n *\n * - Renders a `<button type=\"button\">` by default (pass `type=\"submit\"` to submit a form).\n * - `as` renders another element or component with correctly typed props\n * (`<Button as=\"a\" href=\"/docs\">`, `<Button as={RouterLink} to=\"/\">`).\n * - Non-button elements keep button semantics: an element that is not interactive by itself\n * (`as=\"div\"`, `as=\"span\"`) and an `as=\"a\"` without `href` get `role=\"button\"`, a tab stop and\n * Enter/Space activation (an `<a>` with any `href`, `''` included, stays a link), and\n * `disabled` becomes `aria-disabled` + `tabIndex={-1}` with clicks and keys prevented.\n * - A custom `as` component receives neither the `type=\"button\"` default nor `disabled` (see\n * `disabled`), even when it renders a native `<button>`: pass `type` yourself inside a form.\n * - The `icon` slot is decorative (`aria-hidden`); give icon-only buttons an `aria-label`.\n * - `disabledFocusable` keeps an unavailable button focusable (a Tooltip can explain why, a\n * toolbar keeps it in its arrow-key order) and blocks its activation.\n * - A consumer `aria-disabled=\"true\"` shows the disabled look and suppresses hover and pressed\n * colors, but the button stays focusable and its handlers still run: guard them yourself, or use\n * `disabledFocusable`, which does both.\n * - Colors are theme tokens; hover and pressed styles never apply while disabled.\n * - Hover and pressed colors are gated (`not-disabled:not-aria-disabled:hover:`), which gives\n * them a higher CSS specificity than a bare `hover:` class. To override them in `className`,\n * use the same prefix (`not-disabled:not-aria-disabled:hover:bg-error`, which replaces the\n * built-in class) or the important modifier (`hover:bg-error!`).\n *\n * @example\n * <Button appearance=\"primary\" icon={<SaveIcon />}>Save</Button>\n * <Button as=\"a\" href=\"/docs\">Documentation</Button>\n * <Button icon={<CloseIcon />} aria-label=\"Close\" appearance=\"subtle\" />\n */\nexport const Button: PolymorphicComponent<'button', ButtonOwnProps> = (props) => {\n const {\n as,\n appearance = 'outline',\n size = 'medium',\n icon,\n iconPosition = 'before',\n disabled = false,\n disabledFocusable = false,\n className,\n children,\n ref,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n ...rest\n } = props as ButtonImplProps;\n\n const Component: React.ElementType = as ?? 'button';\n const tag = typeof Component === 'string' ? Component : null;\n const isVoid = tag !== null && VOID_ELEMENTS.has(tag);\n // Defaults, enforced attributes and handlers per tag and disabled state (shared with Link).\n const { defaults, enforced, handlers } = useButtonSemantics({\n tag,\n href: rest.href,\n disabled,\n disabledFocusable,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n });\n const ariaDisabled = rest['aria-disabled'];\n /**\n * An `icon` that renders nothing (`''` from `icon={name && <Icon />}`, an empty array, Set or\n * Fragment) is treated like no icon: no empty `aria-hidden` span, no gap, no icon-only sizing.\n */\n const iconElement = renderSlot(\n slotRendersContent(icon) ? icon : undefined,\n 'span',\n 'inline-flex shrink-0 items-center',\n { 'aria-hidden': true },\n );\n /** Derived from what renders, so an icon that renders nothing never counts. */\n const hasIcon = iconElement !== null;\n // A generator label is read once by the check; its items are what renders.\n const label = materialiseSlotContent(children);\n const hasLabel = slotRendersContent(label);\n const iconOnly = hasIcon && !hasLabel;\n\n const ariaLabel = rest['aria-label'];\n const ariaLabelledBy = rest['aria-labelledby'];\n const title = rest.title;\n React.useEffect(() => {\n if (iconOnly && !ariaLabel && !ariaLabelledBy && !title) {\n warnOnce(\n 'Button:icon-only-name',\n 'Button: an icon-only button has no accessible name. Pass `aria-label`, `aria-labelledby` or `title` (the icon is decorative and hidden from assistive technology).',\n );\n }\n }, [iconOnly, ariaLabel, ariaLabelledBy, title]);\n\n // Defaults apply wherever the consumer's value is `undefined` or `null` (C-COMPOSE), so a wrapper\n // that forwards `type={type}` never drops `type=\"button\"`, the role or the tab stop.\n const elementProps: Record<string, unknown> = { ...rest };\n for (const [key, value] of Object.entries(defaults)) elementProps[key] ??= value;\n\n const showDisabledLook =\n disabled || disabledFocusable || ariaDisabled === true || ariaDisabled === 'true';\n let content: React.ReactNode = label;\n if (isVoid) content = undefined;\n else if (iconElement) {\n // DOM order, so the icon follows the writing direction (no physical classes).\n content =\n iconPosition === 'after' ? (\n <>\n {label}\n {iconElement}\n </>\n ) : (\n <>\n {iconElement}\n {label}\n </>\n );\n }\n\n return (\n <Component\n {...elementProps}\n {...handlers}\n ref={ref}\n className={cn(\n buttonClassName({ appearance, size, disabled: showDisabledLook, iconOnly }),\n hasIcon && hasLabel && 'gap-1.5',\n className,\n )}\n {...enforced}\n >\n {content}\n </Component>\n );\n};\n\nButton.displayName = 'Button';\n"],"mappings":"iTA0HA,IAAagB,EAA0D,GAAU,CAC/E,GAAM,CACJ,KACA,aAAa,UACb,OAAO,SACP,OACA,eAAe,SACf,WAAW,GACX,oBAAoB,GACpB,YACA,WACA,MACA,UACA,YACA,UACA,SACA,GAAGC,GACDC,EAEEC,EAA+BC,GAAM,SACrCC,EAAM,OAAOF,GAAc,SAAWA,EAAY,KAClDG,EAASD,IAAQ,MAAQrB,EAAAA,cAAc,IAAIqB,CAAG,EAE9C,CAAE,WAAU,WAAU,YAAapB,EAAAA,mBAAmB,CAC1D,MACA,KAAMgB,EAAK,KACX,WACA,oBACA,UACA,YACA,UACA,QACF,CAAC,EACKM,EAAeN,EAAK,iBAKpBO,EAActB,EAAAA,WAClBC,EAAAA,mBAAmBsB,CAAI,EAAIA,EAAO,IAAA,GAClC,OACA,oCACA,CAAE,cAAe,EAAK,CACxB,EAEMC,EAAUF,IAAgB,KAE1BG,EAAQvB,EAAAA,uBAAuBwB,CAAQ,EACvCC,EAAW1B,EAAAA,mBAAmBwB,CAAK,EACnCG,EAAWJ,GAAW,CAACG,EAEvBE,EAAYd,EAAK,cACjBe,EAAiBf,EAAK,mBACtBgB,EAAQhB,EAAK,MACnBH,EAAM,cAAgB,CAChBgB,GAAY,CAACC,GAAa,CAACC,GAAkB,CAACC,GAChDvB,EAAA,SACE,wBACA,oKACF,CAEJ,EAAG,CAACoB,EAAUC,EAAWC,EAAgBC,CAAK,CAAC,EAI/C,IAAMC,EAAwC,CAAE,GAAGjB,CAAK,EACxD,IAAK,GAAM,CAACkB,EAAKC,KAAU,OAAO,QAAQC,CAAQ,EAAG,EAAaF,KAASC,EAE3E,IAAME,EACJC,GAAYC,GAAqBjB,IAAiB,IAAQA,IAAiB,OACzEkB,EAA2Bd,EAkB/B,OAjBIL,EAAQ,EAAU,IAAA,GACbE,IAEP,EACEkB,IAAiB,SACf,EAAA3B,EAAA,KAAA,CAAAV,EAAAA,SAAA,CAAA,SAAA,CACGsB,EACAH,CACD,CAAA,CAAA,GAEF,EAAAT,EAAA,KAAA,CAAAV,EAAAA,SAAA,CAAA,SAAA,CACGmB,EACAG,CACD,CAAA,CAAA,IAKN,EAAAZ,EAAA,IAAA,CAACI,EAAD,CACE,GAAIe,EACJ,GAAIS,EACC,MACL,UAAWrC,EAAAA,GACTC,EAAAA,gBAAgB,CAAE,aAAY,OAAM,SAAU+B,EAAkB,UAAS,CAAC,EAC1EZ,GAAWG,GAAY,UACvBe,CACF,EACA,GAAIC,EAEH,SAAAJ,CACQ,CAAA,CAEf,EAEA,EAAO,YAAc"}
|
|
1
|
+
{"version":3,"file":"Button.cjs","names":["VOID_ELEMENTS","useButtonSemantics","renderSlot","slotRendersContent","cn","buttonClassNames","materialiseSlotContent","_Fragment","buttonClassName","require_runtime","require_cn","require_dev","require_slot","require_classNames","require_Button_semantics","require_buttonStyles","react","react_jsx_runtime","Button","rest","props","Component","as","tag","isVoid","ariaDisabled","iconElement","icon","hasIcon","label","children","hasLabel","iconOnly","ariaLabel","ariaLabelledBy","title","elementProps","key","value","defaults","showDisabledLook","disabled","disabledFocusable","content","iconPosition","handlers","className","enforced"],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { buttonClassNames } from '../../lib/classNames';\nimport { warnOnce } from '../../lib/dev';\nimport {\n materialiseSlotContent,\n renderSlot,\n slotRendersContent,\n VOID_ELEMENTS,\n} from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport type { Size, Appearance, IconPosition, Slot } from '../../lib/types';\nimport { useButtonSemantics } from './Button.semantics';\nimport { buttonClassName } from './buttonStyles';\n\n/**\n * The Button's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`), so `as=\"a\"` accepts `href`/`target`\n * and types `onClick` for an anchor.\n */\nexport interface ButtonOwnProps {\n /** Visual style variant.\n * @default 'outline'\n */\n appearance?: Appearance;\n /** Size affecting height, padding and font size.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Icon slot rendered before the label (after it with `iconPosition=\"after\"`). Decorative: it\n * renders with `aria-hidden=\"true\"` (a slot object can override it). An icon-only button needs\n * `aria-label`, `aria-labelledby` or `title`.\n */\n icon?: Slot<'span'>;\n /**\n * Where the icon renders: before the label (the inline start) or after it (the inline end, e.g.\n * an \"open in new window\" glyph). Follows the writing direction through DOM order. Has no effect\n * on an icon-only button.\n * @default 'before'\n */\n iconPosition?: IconPosition;\n /**\n * Disables the button. Only the intrinsic form controls (`button`, the default, and `input`,\n * `select`, `textarea`) get the native `disabled` attribute. Every other `as` — `a`, `div`,\n * `span` and **any custom component**, including router links and styled or motion components\n * that render a native `<button>` — does not receive `disabled`: it gets `aria-disabled=\"true\"`\n * and `tabIndex={-1}` instead (neither can be overridden), its clicks and Enter/Space are\n * prevented (a click does not reach ancestor `onClick` handlers either, as with a native\n * disabled button), and an `<a>` drops its `href` (it keeps `role=\"link\"` when it had one,\n * `role=\"button\"` otherwise). Such an element leaves the tab order but, like any\n * `tabIndex={-1}` element, can still take focus from a mouse click, and a component's own\n * `:disabled` styling does not apply. Every disabled Button also renders `data-disabled`.\n * @default false\n */\n disabled?: boolean;\n /**\n * Marks the button unavailable but keeps it focusable and in the tab order: for toolbar items, a\n * button that disables itself when activated, or a disabled button that needs a Tooltip. Renders\n * `aria-disabled=\"true\"`, `data-disabled` and `data-disabled-focusable` instead of the native\n * `disabled` attribute. Clicks, Enter, Space and implicit form submission are prevented; your\n * `onClick` is not called and the click does not reach ancestor click handlers. Hover and pressed\n * colors are off. Wins over `disabled` when both are set. In a `Toolbar` it stays in the\n * arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n}\n\n/**\n * Props of {@link Button} rendered as `C` (default `'button'`). `ButtonProps` without a type\n * argument is the 0.4 name: the props of a Button rendered as a `<button>`, including `ref`.\n *\n * @example\n * interface SaveButtonProps extends ButtonProps { tracking?: string }\n * const props: ButtonProps<'a'> = { as: 'a', href: '/docs', appearance: 'primary' };\n */\nexport type ButtonProps<C extends React.ElementType = 'button'> = PolymorphicProps<\n C,\n ButtonOwnProps\n>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype ButtonImplProps = ButtonOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'onClick' | 'onKeyDown' | 'onKeyUp'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n /** An anchor's destination (`as=\"a\"`): without one, the anchor gets button semantics. */\n href?: string;\n onClick?: React.MouseEventHandler<HTMLElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLElement>;\n onKeyUp?: React.KeyboardEventHandler<HTMLElement>;\n };\n\n/**\n * A button with Fluent appearances and sizes.\n *\n * - Renders a `<button type=\"button\">` by default (pass `type=\"submit\"` to submit a form).\n * - `as` renders another element or component with correctly typed props\n * (`<Button as=\"a\" href=\"/docs\">`, `<Button as={RouterLink} to=\"/\">`).\n * - Non-button elements keep button semantics: an element that is not interactive by itself\n * (`as=\"div\"`, `as=\"span\"`) and an `as=\"a\"` without `href` get `role=\"button\"`, a tab stop and\n * Enter/Space activation (an `<a>` with any `href`, `''` included, stays a link), and\n * `disabled` becomes `aria-disabled` + `tabIndex={-1}` with clicks and keys prevented.\n * - A custom `as` component receives neither the `type=\"button\"` default nor `disabled` (see\n * `disabled`), even when it renders a native `<button>`: pass `type` yourself inside a form.\n * - The `icon` slot is decorative (`aria-hidden`); give icon-only buttons an `aria-label`.\n * - `disabledFocusable` keeps an unavailable button focusable (a Tooltip can explain why, a\n * toolbar keeps it in its arrow-key order) and blocks its activation.\n * - A consumer `aria-disabled=\"true\"` shows the disabled look and suppresses hover and pressed\n * colors, but the button stays focusable and its handlers still run: guard them yourself, or use\n * `disabledFocusable`, which does both.\n * - Colors are theme tokens; hover and pressed styles never apply while disabled.\n * - Hover and pressed colors are gated (`not-disabled:not-aria-disabled:hover:`), which gives\n * them a higher CSS specificity than a bare `hover:` class. To override them in `className`,\n * use the same prefix (`not-disabled:not-aria-disabled:hover:bg-error`, which replaces the\n * built-in class) or the important modifier (`hover:bg-error!`).\n *\n * @example\n * <Button appearance=\"primary\" icon={<SaveIcon />}>Save</Button>\n * <Button as=\"a\" href=\"/docs\">Documentation</Button>\n * <Button icon={<CloseIcon />} aria-label=\"Close\" appearance=\"subtle\" />\n */\nexport const Button: PolymorphicComponent<'button', ButtonOwnProps> = (props) => {\n const {\n as,\n appearance = 'outline',\n size = 'medium',\n icon,\n iconPosition = 'before',\n disabled = false,\n disabledFocusable = false,\n className,\n children,\n ref,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n ...rest\n } = props as ButtonImplProps;\n\n const Component: React.ElementType = as ?? 'button';\n const tag = typeof Component === 'string' ? Component : null;\n const isVoid = tag !== null && VOID_ELEMENTS.has(tag);\n // Defaults, enforced attributes and handlers per tag and disabled state (shared with Link).\n const { defaults, enforced, handlers } = useButtonSemantics({\n tag,\n href: rest.href,\n disabled,\n disabledFocusable,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n });\n const ariaDisabled = rest['aria-disabled'];\n /**\n * An `icon` that renders nothing (`''` from `icon={name && <Icon />}`, an empty array, Set or\n * Fragment) is treated like no icon: no empty `aria-hidden` span, no gap, no icon-only sizing.\n */\n const iconElement = renderSlot(\n slotRendersContent(icon) ? icon : undefined,\n 'span',\n cn(buttonClassNames.icon, 'inline-flex shrink-0 items-center'),\n { 'aria-hidden': true },\n );\n /** Derived from what renders, so an icon that renders nothing never counts. */\n const hasIcon = iconElement !== null;\n // A generator label is read once by the check; its items are what renders.\n const label = materialiseSlotContent(children);\n const hasLabel = slotRendersContent(label);\n const iconOnly = hasIcon && !hasLabel;\n\n const ariaLabel = rest['aria-label'];\n const ariaLabelledBy = rest['aria-labelledby'];\n const title = rest.title;\n React.useEffect(() => {\n if (iconOnly && !ariaLabel && !ariaLabelledBy && !title) {\n warnOnce(\n 'Button:icon-only-name',\n 'Button: an icon-only button has no accessible name. Pass `aria-label`, `aria-labelledby` or `title` (the icon is decorative and hidden from assistive technology).',\n );\n }\n }, [iconOnly, ariaLabel, ariaLabelledBy, title]);\n\n // Defaults apply wherever the consumer's value is `undefined` or `null` (C-COMPOSE), so a wrapper\n // that forwards `type={type}` never drops `type=\"button\"`, the role or the tab stop.\n const elementProps: Record<string, unknown> = { ...rest };\n for (const [key, value] of Object.entries(defaults)) elementProps[key] ??= value;\n\n const showDisabledLook =\n disabled || disabledFocusable || ariaDisabled === true || ariaDisabled === 'true';\n let content: React.ReactNode = label;\n if (isVoid) content = undefined;\n else if (iconElement) {\n // DOM order, so the icon follows the writing direction (no physical classes).\n content =\n iconPosition === 'after' ? (\n <>\n {label}\n {iconElement}\n </>\n ) : (\n <>\n {iconElement}\n {label}\n </>\n );\n }\n\n return (\n <Component\n {...elementProps}\n {...handlers}\n ref={ref}\n className={cn(\n buttonClassNames.root,\n buttonClassName({ appearance, size, disabled: showDisabledLook, iconOnly }),\n hasIcon && hasLabel && 'gap-1.5',\n className,\n )}\n {...enforced}\n >\n {content}\n </Component>\n );\n};\n\nButton.displayName = 'Button';\n"],"mappings":"uVA2HA,IAAakB,EAA0D,GAAU,CAC/E,GAAM,CACJ,KACA,aAAa,UACb,OAAO,SACP,OACA,eAAe,SACf,WAAW,GACX,oBAAoB,GACpB,YACA,WACA,MACA,UACA,YACA,UACA,SACA,GAAGC,GACDC,EAEEC,EAA+BC,GAAM,SACrCC,EAAM,OAAOF,GAAc,SAAWA,EAAY,KAClDG,EAASD,IAAQ,MAAQvB,EAAAA,cAAc,IAAIuB,CAAG,EAE9C,CAAE,WAAU,WAAU,YAAatB,EAAAA,mBAAmB,CAC1D,MACA,KAAMkB,EAAK,KACX,WACA,oBACA,UACA,YACA,UACA,QACF,CAAC,EACKM,EAAeN,EAAK,iBAKpBO,EAAcxB,EAAAA,WAClBC,EAAAA,mBAAmBwB,CAAI,EAAIA,EAAO,IAAA,GAClC,OACAvB,EAAAA,GAAGC,EAAAA,iBAAiB,KAAM,mCAAmC,EAC7D,CAAE,cAAe,EAAK,CACxB,EAEMuB,EAAUF,IAAgB,KAE1BG,EAAQvB,EAAAA,uBAAuBwB,CAAQ,EACvCC,EAAW5B,EAAAA,mBAAmB0B,CAAK,EACnCG,EAAWJ,GAAW,CAACG,EAEvBE,EAAYd,EAAK,cACjBe,EAAiBf,EAAK,mBACtBgB,EAAQhB,EAAK,MACnBH,EAAM,cAAgB,CAChBgB,GAAY,CAACC,GAAa,CAACC,GAAkB,CAACC,GAChDxB,EAAA,SACE,wBACA,oKACF,CAEJ,EAAG,CAACqB,EAAUC,EAAWC,EAAgBC,CAAK,CAAC,EAI/C,IAAMC,EAAwC,CAAE,GAAGjB,CAAK,EACxD,IAAK,GAAM,CAACkB,EAAKC,KAAU,OAAO,QAAQC,CAAQ,EAAG,EAAaF,KAASC,EAE3E,IAAME,EACJC,GAAYC,GAAqBjB,IAAiB,IAAQA,IAAiB,OACzEkB,EAA2Bd,EAkB/B,OAjBIL,EAAQ,EAAU,IAAA,GACbE,IAEP,EACEkB,IAAiB,SACf,EAAA3B,EAAA,KAAA,CAAAV,EAAAA,SAAA,CAAA,SAAA,CACGsB,EACAH,CACD,CAAA,CAAA,GAEF,EAAAT,EAAA,KAAA,CAAAV,EAAAA,SAAA,CAAA,SAAA,CACGmB,EACAG,CACD,CAAA,CAAA,IAKN,EAAAZ,EAAA,IAAA,CAACI,EAAD,CACE,GAAIe,EACJ,GAAIS,EACC,MACL,UAAWzC,EAAAA,GACTC,EAAAA,iBAAiB,KACjBG,EAAAA,gBAAgB,CAAE,aAAY,OAAM,SAAUgC,EAAkB,UAAS,CAAC,EAC1EZ,GAAWG,GAAY,UACvBe,CACF,EACA,GAAIC,EAEH,SAAAJ,CACQ,CAAA,CAEf,EAEA,EAAO,YAAc"}
|
|
@@ -2,49 +2,50 @@
|
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
3
|
import { warnOnce as t } from "../../lib/dev.mjs";
|
|
4
4
|
import { VOID_ELEMENTS as n, materialiseSlotContent as r, renderSlot as i, slotRendersContent as a } from "../../lib/slot.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import { buttonClassNames as o } from "../../lib/classNames.mjs";
|
|
6
|
+
import { useButtonSemantics as s } from "./Button.semantics.mjs";
|
|
7
|
+
import { buttonClassName as c } from "./buttonStyles.mjs";
|
|
8
|
+
import * as l from "react";
|
|
9
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/button/Button.tsx
|
|
10
|
-
var
|
|
11
|
-
let { as:
|
|
12
|
-
tag:
|
|
13
|
-
href:
|
|
14
|
-
disabled:
|
|
15
|
-
disabledFocusable:
|
|
16
|
-
onClick:
|
|
17
|
-
onKeyDown:
|
|
18
|
-
onKeyUp:
|
|
19
|
-
onBlur:
|
|
20
|
-
}),
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
var p = (p) => {
|
|
12
|
+
let { as: m, appearance: h = "outline", size: g = "medium", icon: _, iconPosition: v = "before", disabled: y = !1, disabledFocusable: b = !1, className: x, children: S, ref: C, onClick: w, onKeyDown: T, onKeyUp: E, onBlur: D, ...O } = p, k = m ?? "button", A = typeof k == "string" ? k : null, j = A !== null && n.has(A), { defaults: M, enforced: N, handlers: P } = s({
|
|
13
|
+
tag: A,
|
|
14
|
+
href: O.href,
|
|
15
|
+
disabled: y,
|
|
16
|
+
disabledFocusable: b,
|
|
17
|
+
onClick: w,
|
|
18
|
+
onKeyDown: T,
|
|
19
|
+
onKeyUp: E,
|
|
20
|
+
onBlur: D
|
|
21
|
+
}), F = O["aria-disabled"], I = i(a(_) ? _ : void 0, "span", e(o.icon, "inline-flex shrink-0 items-center"), { "aria-hidden": !0 }), L = I !== null, R = r(S), z = a(R), B = L && !z, V = O["aria-label"], H = O["aria-labelledby"], U = O.title;
|
|
22
|
+
l.useEffect(() => {
|
|
23
|
+
B && !V && !H && !U && t("Button:icon-only-name", "Button: an icon-only button has no accessible name. Pass `aria-label`, `aria-labelledby` or `title` (the icon is decorative and hidden from assistive technology).");
|
|
23
24
|
}, [
|
|
24
|
-
z,
|
|
25
25
|
B,
|
|
26
26
|
V,
|
|
27
|
-
H
|
|
27
|
+
H,
|
|
28
|
+
U
|
|
28
29
|
]);
|
|
29
|
-
let
|
|
30
|
-
for (let [e, t] of Object.entries(
|
|
31
|
-
let
|
|
32
|
-
return
|
|
33
|
-
...
|
|
30
|
+
let W = { ...O };
|
|
31
|
+
for (let [e, t] of Object.entries(M)) W[e] ??= t;
|
|
32
|
+
let G = y || b || F === !0 || F === "true", K = R;
|
|
33
|
+
return j ? K = void 0 : I && (K = v === "after" ? /* @__PURE__ */ f(u, { children: [R, I] }) : /* @__PURE__ */ f(u, { children: [I, R] })), /* @__PURE__ */ d(k, {
|
|
34
|
+
...W,
|
|
35
|
+
...P,
|
|
36
|
+
ref: C,
|
|
37
|
+
className: e(o.root, c({
|
|
38
|
+
appearance: h,
|
|
39
|
+
size: g,
|
|
40
|
+
disabled: G,
|
|
41
|
+
iconOnly: B
|
|
42
|
+
}), L && z && "gap-1.5", x),
|
|
34
43
|
...N,
|
|
35
|
-
|
|
36
|
-
className: e(s({
|
|
37
|
-
appearance: m,
|
|
38
|
-
size: h,
|
|
39
|
-
disabled: W,
|
|
40
|
-
iconOnly: z
|
|
41
|
-
}), I && R && "gap-1.5", b),
|
|
42
|
-
...M,
|
|
43
|
-
children: G
|
|
44
|
+
children: K
|
|
44
45
|
});
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
p.displayName = "Button";
|
|
47
48
|
//#endregion
|
|
48
|
-
export {
|
|
49
|
+
export { p as Button };
|
|
49
50
|
|
|
50
51
|
//# sourceMappingURL=Button.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","names":["_Fragment","React","Button","rest","props","Component","as","tag","isVoid","VOID_ELEMENTS","useButtonSemantics","ariaDisabled","iconElement","renderSlot","slotRendersContent","icon","hasIcon","label","materialiseSlotContent","children","hasLabel","iconOnly","ariaLabel","ariaLabelledBy","title","warnOnce","elementProps","key","value","defaults","showDisabledLook","disabled","disabledFocusable","content","iconPosition","Fragment","handlers","cn","buttonClassName","className","enforced"],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { warnOnce } from '../../lib/dev';\nimport {\n materialiseSlotContent,\n renderSlot,\n slotRendersContent,\n VOID_ELEMENTS,\n} from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport type { Size, Appearance, IconPosition, Slot } from '../../lib/types';\nimport { useButtonSemantics } from './Button.semantics';\nimport { buttonClassName } from './buttonStyles';\n\n/**\n * The Button's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`), so `as=\"a\"` accepts `href`/`target`\n * and types `onClick` for an anchor.\n */\nexport interface ButtonOwnProps {\n /** Visual style variant.\n * @default 'outline'\n */\n appearance?: Appearance;\n /** Size affecting height, padding and font size.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Icon slot rendered before the label (after it with `iconPosition=\"after\"`). Decorative: it\n * renders with `aria-hidden=\"true\"` (a slot object can override it). An icon-only button needs\n * `aria-label`, `aria-labelledby` or `title`.\n */\n icon?: Slot<'span'>;\n /**\n * Where the icon renders: before the label (the inline start) or after it (the inline end, e.g.\n * an \"open in new window\" glyph). Follows the writing direction through DOM order. Has no effect\n * on an icon-only button.\n * @default 'before'\n */\n iconPosition?: IconPosition;\n /**\n * Disables the button. Only the intrinsic form controls (`button`, the default, and `input`,\n * `select`, `textarea`) get the native `disabled` attribute. Every other `as` — `a`, `div`,\n * `span` and **any custom component**, including router links and styled or motion components\n * that render a native `<button>` — does not receive `disabled`: it gets `aria-disabled=\"true\"`\n * and `tabIndex={-1}` instead (neither can be overridden), its clicks and Enter/Space are\n * prevented (a click does not reach ancestor `onClick` handlers either, as with a native\n * disabled button), and an `<a>` drops its `href` (it keeps `role=\"link\"` when it had one,\n * `role=\"button\"` otherwise). Such an element leaves the tab order but, like any\n * `tabIndex={-1}` element, can still take focus from a mouse click, and a component's own\n * `:disabled` styling does not apply. Every disabled Button also renders `data-disabled`.\n * @default false\n */\n disabled?: boolean;\n /**\n * Marks the button unavailable but keeps it focusable and in the tab order: for toolbar items, a\n * button that disables itself when activated, or a disabled button that needs a Tooltip. Renders\n * `aria-disabled=\"true\"`, `data-disabled` and `data-disabled-focusable` instead of the native\n * `disabled` attribute. Clicks, Enter, Space and implicit form submission are prevented; your\n * `onClick` is not called and the click does not reach ancestor click handlers. Hover and pressed\n * colors are off. Wins over `disabled` when both are set. In a `Toolbar` it stays in the\n * arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n}\n\n/**\n * Props of {@link Button} rendered as `C` (default `'button'`). `ButtonProps` without a type\n * argument is the 0.4 name: the props of a Button rendered as a `<button>`, including `ref`.\n *\n * @example\n * interface SaveButtonProps extends ButtonProps { tracking?: string }\n * const props: ButtonProps<'a'> = { as: 'a', href: '/docs', appearance: 'primary' };\n */\nexport type ButtonProps<C extends React.ElementType = 'button'> = PolymorphicProps<\n C,\n ButtonOwnProps\n>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype ButtonImplProps = ButtonOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'onClick' | 'onKeyDown' | 'onKeyUp'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n /** An anchor's destination (`as=\"a\"`): without one, the anchor gets button semantics. */\n href?: string;\n onClick?: React.MouseEventHandler<HTMLElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLElement>;\n onKeyUp?: React.KeyboardEventHandler<HTMLElement>;\n };\n\n/**\n * A button with Fluent appearances and sizes.\n *\n * - Renders a `<button type=\"button\">` by default (pass `type=\"submit\"` to submit a form).\n * - `as` renders another element or component with correctly typed props\n * (`<Button as=\"a\" href=\"/docs\">`, `<Button as={RouterLink} to=\"/\">`).\n * - Non-button elements keep button semantics: an element that is not interactive by itself\n * (`as=\"div\"`, `as=\"span\"`) and an `as=\"a\"` without `href` get `role=\"button\"`, a tab stop and\n * Enter/Space activation (an `<a>` with any `href`, `''` included, stays a link), and\n * `disabled` becomes `aria-disabled` + `tabIndex={-1}` with clicks and keys prevented.\n * - A custom `as` component receives neither the `type=\"button\"` default nor `disabled` (see\n * `disabled`), even when it renders a native `<button>`: pass `type` yourself inside a form.\n * - The `icon` slot is decorative (`aria-hidden`); give icon-only buttons an `aria-label`.\n * - `disabledFocusable` keeps an unavailable button focusable (a Tooltip can explain why, a\n * toolbar keeps it in its arrow-key order) and blocks its activation.\n * - A consumer `aria-disabled=\"true\"` shows the disabled look and suppresses hover and pressed\n * colors, but the button stays focusable and its handlers still run: guard them yourself, or use\n * `disabledFocusable`, which does both.\n * - Colors are theme tokens; hover and pressed styles never apply while disabled.\n * - Hover and pressed colors are gated (`not-disabled:not-aria-disabled:hover:`), which gives\n * them a higher CSS specificity than a bare `hover:` class. To override them in `className`,\n * use the same prefix (`not-disabled:not-aria-disabled:hover:bg-error`, which replaces the\n * built-in class) or the important modifier (`hover:bg-error!`).\n *\n * @example\n * <Button appearance=\"primary\" icon={<SaveIcon />}>Save</Button>\n * <Button as=\"a\" href=\"/docs\">Documentation</Button>\n * <Button icon={<CloseIcon />} aria-label=\"Close\" appearance=\"subtle\" />\n */\nexport const Button: PolymorphicComponent<'button', ButtonOwnProps> = (props) => {\n const {\n as,\n appearance = 'outline',\n size = 'medium',\n icon,\n iconPosition = 'before',\n disabled = false,\n disabledFocusable = false,\n className,\n children,\n ref,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n ...rest\n } = props as ButtonImplProps;\n\n const Component: React.ElementType = as ?? 'button';\n const tag = typeof Component === 'string' ? Component : null;\n const isVoid = tag !== null && VOID_ELEMENTS.has(tag);\n // Defaults, enforced attributes and handlers per tag and disabled state (shared with Link).\n const { defaults, enforced, handlers } = useButtonSemantics({\n tag,\n href: rest.href,\n disabled,\n disabledFocusable,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n });\n const ariaDisabled = rest['aria-disabled'];\n /**\n * An `icon` that renders nothing (`''` from `icon={name && <Icon />}`, an empty array, Set or\n * Fragment) is treated like no icon: no empty `aria-hidden` span, no gap, no icon-only sizing.\n */\n const iconElement = renderSlot(\n slotRendersContent(icon) ? icon : undefined,\n 'span',\n 'inline-flex shrink-0 items-center',\n { 'aria-hidden': true },\n );\n /** Derived from what renders, so an icon that renders nothing never counts. */\n const hasIcon = iconElement !== null;\n // A generator label is read once by the check; its items are what renders.\n const label = materialiseSlotContent(children);\n const hasLabel = slotRendersContent(label);\n const iconOnly = hasIcon && !hasLabel;\n\n const ariaLabel = rest['aria-label'];\n const ariaLabelledBy = rest['aria-labelledby'];\n const title = rest.title;\n React.useEffect(() => {\n if (iconOnly && !ariaLabel && !ariaLabelledBy && !title) {\n warnOnce(\n 'Button:icon-only-name',\n 'Button: an icon-only button has no accessible name. Pass `aria-label`, `aria-labelledby` or `title` (the icon is decorative and hidden from assistive technology).',\n );\n }\n }, [iconOnly, ariaLabel, ariaLabelledBy, title]);\n\n // Defaults apply wherever the consumer's value is `undefined` or `null` (C-COMPOSE), so a wrapper\n // that forwards `type={type}` never drops `type=\"button\"`, the role or the tab stop.\n const elementProps: Record<string, unknown> = { ...rest };\n for (const [key, value] of Object.entries(defaults)) elementProps[key] ??= value;\n\n const showDisabledLook =\n disabled || disabledFocusable || ariaDisabled === true || ariaDisabled === 'true';\n let content: React.ReactNode = label;\n if (isVoid) content = undefined;\n else if (iconElement) {\n // DOM order, so the icon follows the writing direction (no physical classes).\n content =\n iconPosition === 'after' ? (\n <>\n {label}\n {iconElement}\n </>\n ) : (\n <>\n {iconElement}\n {label}\n </>\n );\n }\n\n return (\n <Component\n {...elementProps}\n {...handlers}\n ref={ref}\n className={cn(\n buttonClassName({ appearance, size, disabled: showDisabledLook, iconOnly }),\n hasIcon && hasLabel && 'gap-1.5',\n className,\n )}\n {...enforced}\n >\n {content}\n </Component>\n );\n};\n\nButton.displayName = 'Button';\n"],"mappings":";;;;;;;;;AA0HA,IAAaE,KAA0D,MAAU;CAC/E,IAAM,EACJ,OACA,gBAAa,WACb,UAAO,UACP,SACA,kBAAe,UACf,cAAW,IACX,uBAAoB,IACpB,cACA,aACA,QACA,YACA,cACA,YACA,WACA,GAAGC,MACDC,GAEEC,IAA+BC,KAAM,UACrCC,IAAM,OAAOF,KAAc,WAAWA,IAAY,MAClDG,IAASD,MAAQ,QAAQE,EAAc,IAAIF,CAAG,GAE9C,EAAE,aAAU,aAAU,gBAAaG,EAAmB;EAC1D;EACA,MAAMP,EAAK;EACX;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,GACKQ,IAAeR,EAAK,kBAKpBS,IAAcC,EAClBC,EAAmBC,CAAI,IAAIA,IAAO,KAAA,GAClC,QACA,qCACA,EAAE,eAAe,GAAK,CACxB,GAEMC,IAAUJ,MAAgB,MAE1BK,IAAQC,EAAuBC,CAAQ,GACvCC,IAAWN,EAAmBG,CAAK,GACnCI,IAAWL,KAAW,CAACI,GAEvBE,IAAYnB,EAAK,eACjBoB,IAAiBpB,EAAK,oBACtBqB,IAAQrB,EAAK;CACnB,EAAM,gBAAgB;EACpB,AAAIkB,KAAY,CAACC,KAAa,CAACC,KAAkB,CAACC,KAChDC,EACE,yBACA,oKACF;CAEJ,GAAG;EAACJ;EAAUC;EAAWC;EAAgBC;CAAK,CAAC;CAI/C,IAAME,IAAwC,EAAE,GAAGvB,EAAK;CACxD,KAAK,IAAM,CAACwB,GAAKC,MAAU,OAAO,QAAQC,CAAQ,GAAG,EAAaF,OAASC;CAE3E,IAAME,IACJC,KAAYC,KAAqBrB,MAAiB,MAAQA,MAAiB,QACzEsB,IAA2BhB;CAkB/B,OAjBIT,IAAQ,IAAU,KAAA,IACbI,MAEP,IACEsB,MAAiB,UACf,kBAAAlC,GAAA,EAAA,UAAA,CACGiB,GACAL,CACD,EAAA,CAAA,IAEF,kBAAAZ,GAAA,EAAA,UAAA,CACGY,GACAK,CACD,EAAA,CAAA,IAKN,kBAACZ,GAAD;EACE,GAAIqB;EACJ,GAAIU;EACC;EACL,WAAWC,EACTC,EAAgB;GAAE;GAAY;GAAM,UAAUR;GAAkB;EAAS,CAAC,GAC1Ed,KAAWI,KAAY,WACvBmB,CACF;EACA,GAAIC;EAEH,UAAAP;CACQ,CAAA;AAEf;AAEA,EAAO,cAAc"}
|
|
1
|
+
{"version":3,"file":"Button.mjs","names":["_Fragment","React","Button","rest","props","Component","as","tag","isVoid","VOID_ELEMENTS","useButtonSemantics","ariaDisabled","iconElement","renderSlot","slotRendersContent","icon","cn","buttonClassNames","hasIcon","label","materialiseSlotContent","children","hasLabel","iconOnly","ariaLabel","ariaLabelledBy","title","warnOnce","elementProps","key","value","defaults","showDisabledLook","disabled","disabledFocusable","content","iconPosition","Fragment","handlers","buttonClassName","className","enforced"],"sources":["../../../src/components/button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { buttonClassNames } from '../../lib/classNames';\nimport { warnOnce } from '../../lib/dev';\nimport {\n materialiseSlotContent,\n renderSlot,\n slotRendersContent,\n VOID_ELEMENTS,\n} from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport type { Size, Appearance, IconPosition, Slot } from '../../lib/types';\nimport { useButtonSemantics } from './Button.semantics';\nimport { buttonClassName } from './buttonStyles';\n\n/**\n * The Button's own props (the XOwnProps rule of `PolymorphicProps`: component-specific props only).\n * Every other prop comes from the rendered element (`as`), so `as=\"a\"` accepts `href`/`target`\n * and types `onClick` for an anchor.\n */\nexport interface ButtonOwnProps {\n /** Visual style variant.\n * @default 'outline'\n */\n appearance?: Appearance;\n /** Size affecting height, padding and font size.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Icon slot rendered before the label (after it with `iconPosition=\"after\"`). Decorative: it\n * renders with `aria-hidden=\"true\"` (a slot object can override it). An icon-only button needs\n * `aria-label`, `aria-labelledby` or `title`.\n */\n icon?: Slot<'span'>;\n /**\n * Where the icon renders: before the label (the inline start) or after it (the inline end, e.g.\n * an \"open in new window\" glyph). Follows the writing direction through DOM order. Has no effect\n * on an icon-only button.\n * @default 'before'\n */\n iconPosition?: IconPosition;\n /**\n * Disables the button. Only the intrinsic form controls (`button`, the default, and `input`,\n * `select`, `textarea`) get the native `disabled` attribute. Every other `as` — `a`, `div`,\n * `span` and **any custom component**, including router links and styled or motion components\n * that render a native `<button>` — does not receive `disabled`: it gets `aria-disabled=\"true\"`\n * and `tabIndex={-1}` instead (neither can be overridden), its clicks and Enter/Space are\n * prevented (a click does not reach ancestor `onClick` handlers either, as with a native\n * disabled button), and an `<a>` drops its `href` (it keeps `role=\"link\"` when it had one,\n * `role=\"button\"` otherwise). Such an element leaves the tab order but, like any\n * `tabIndex={-1}` element, can still take focus from a mouse click, and a component's own\n * `:disabled` styling does not apply. Every disabled Button also renders `data-disabled`.\n * @default false\n */\n disabled?: boolean;\n /**\n * Marks the button unavailable but keeps it focusable and in the tab order: for toolbar items, a\n * button that disables itself when activated, or a disabled button that needs a Tooltip. Renders\n * `aria-disabled=\"true\"`, `data-disabled` and `data-disabled-focusable` instead of the native\n * `disabled` attribute. Clicks, Enter, Space and implicit form submission are prevented; your\n * `onClick` is not called and the click does not reach ancestor click handlers. Hover and pressed\n * colors are off. Wins over `disabled` when both are set. In a `Toolbar` it stays in the\n * arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n}\n\n/**\n * Props of {@link Button} rendered as `C` (default `'button'`). `ButtonProps` without a type\n * argument is the 0.4 name: the props of a Button rendered as a `<button>`, including `ref`.\n *\n * @example\n * interface SaveButtonProps extends ButtonProps { tracking?: string }\n * const props: ButtonProps<'a'> = { as: 'a', href: '/docs', appearance: 'primary' };\n */\nexport type ButtonProps<C extends React.ElementType = 'button'> = PolymorphicProps<\n C,\n ButtonOwnProps\n>;\n\n/** The props the implementation reads, for any `as` (the public typing is `PolymorphicComponent`). */\ntype ButtonImplProps = ButtonOwnProps &\n Omit<React.HTMLAttributes<HTMLElement>, 'onClick' | 'onKeyDown' | 'onKeyUp'> & {\n as?: React.ElementType;\n ref?: React.Ref<HTMLElement>;\n /** An anchor's destination (`as=\"a\"`): without one, the anchor gets button semantics. */\n href?: string;\n onClick?: React.MouseEventHandler<HTMLElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLElement>;\n onKeyUp?: React.KeyboardEventHandler<HTMLElement>;\n };\n\n/**\n * A button with Fluent appearances and sizes.\n *\n * - Renders a `<button type=\"button\">` by default (pass `type=\"submit\"` to submit a form).\n * - `as` renders another element or component with correctly typed props\n * (`<Button as=\"a\" href=\"/docs\">`, `<Button as={RouterLink} to=\"/\">`).\n * - Non-button elements keep button semantics: an element that is not interactive by itself\n * (`as=\"div\"`, `as=\"span\"`) and an `as=\"a\"` without `href` get `role=\"button\"`, a tab stop and\n * Enter/Space activation (an `<a>` with any `href`, `''` included, stays a link), and\n * `disabled` becomes `aria-disabled` + `tabIndex={-1}` with clicks and keys prevented.\n * - A custom `as` component receives neither the `type=\"button\"` default nor `disabled` (see\n * `disabled`), even when it renders a native `<button>`: pass `type` yourself inside a form.\n * - The `icon` slot is decorative (`aria-hidden`); give icon-only buttons an `aria-label`.\n * - `disabledFocusable` keeps an unavailable button focusable (a Tooltip can explain why, a\n * toolbar keeps it in its arrow-key order) and blocks its activation.\n * - A consumer `aria-disabled=\"true\"` shows the disabled look and suppresses hover and pressed\n * colors, but the button stays focusable and its handlers still run: guard them yourself, or use\n * `disabledFocusable`, which does both.\n * - Colors are theme tokens; hover and pressed styles never apply while disabled.\n * - Hover and pressed colors are gated (`not-disabled:not-aria-disabled:hover:`), which gives\n * them a higher CSS specificity than a bare `hover:` class. To override them in `className`,\n * use the same prefix (`not-disabled:not-aria-disabled:hover:bg-error`, which replaces the\n * built-in class) or the important modifier (`hover:bg-error!`).\n *\n * @example\n * <Button appearance=\"primary\" icon={<SaveIcon />}>Save</Button>\n * <Button as=\"a\" href=\"/docs\">Documentation</Button>\n * <Button icon={<CloseIcon />} aria-label=\"Close\" appearance=\"subtle\" />\n */\nexport const Button: PolymorphicComponent<'button', ButtonOwnProps> = (props) => {\n const {\n as,\n appearance = 'outline',\n size = 'medium',\n icon,\n iconPosition = 'before',\n disabled = false,\n disabledFocusable = false,\n className,\n children,\n ref,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n ...rest\n } = props as ButtonImplProps;\n\n const Component: React.ElementType = as ?? 'button';\n const tag = typeof Component === 'string' ? Component : null;\n const isVoid = tag !== null && VOID_ELEMENTS.has(tag);\n // Defaults, enforced attributes and handlers per tag and disabled state (shared with Link).\n const { defaults, enforced, handlers } = useButtonSemantics({\n tag,\n href: rest.href,\n disabled,\n disabledFocusable,\n onClick,\n onKeyDown,\n onKeyUp,\n onBlur,\n });\n const ariaDisabled = rest['aria-disabled'];\n /**\n * An `icon` that renders nothing (`''` from `icon={name && <Icon />}`, an empty array, Set or\n * Fragment) is treated like no icon: no empty `aria-hidden` span, no gap, no icon-only sizing.\n */\n const iconElement = renderSlot(\n slotRendersContent(icon) ? icon : undefined,\n 'span',\n cn(buttonClassNames.icon, 'inline-flex shrink-0 items-center'),\n { 'aria-hidden': true },\n );\n /** Derived from what renders, so an icon that renders nothing never counts. */\n const hasIcon = iconElement !== null;\n // A generator label is read once by the check; its items are what renders.\n const label = materialiseSlotContent(children);\n const hasLabel = slotRendersContent(label);\n const iconOnly = hasIcon && !hasLabel;\n\n const ariaLabel = rest['aria-label'];\n const ariaLabelledBy = rest['aria-labelledby'];\n const title = rest.title;\n React.useEffect(() => {\n if (iconOnly && !ariaLabel && !ariaLabelledBy && !title) {\n warnOnce(\n 'Button:icon-only-name',\n 'Button: an icon-only button has no accessible name. Pass `aria-label`, `aria-labelledby` or `title` (the icon is decorative and hidden from assistive technology).',\n );\n }\n }, [iconOnly, ariaLabel, ariaLabelledBy, title]);\n\n // Defaults apply wherever the consumer's value is `undefined` or `null` (C-COMPOSE), so a wrapper\n // that forwards `type={type}` never drops `type=\"button\"`, the role or the tab stop.\n const elementProps: Record<string, unknown> = { ...rest };\n for (const [key, value] of Object.entries(defaults)) elementProps[key] ??= value;\n\n const showDisabledLook =\n disabled || disabledFocusable || ariaDisabled === true || ariaDisabled === 'true';\n let content: React.ReactNode = label;\n if (isVoid) content = undefined;\n else if (iconElement) {\n // DOM order, so the icon follows the writing direction (no physical classes).\n content =\n iconPosition === 'after' ? (\n <>\n {label}\n {iconElement}\n </>\n ) : (\n <>\n {iconElement}\n {label}\n </>\n );\n }\n\n return (\n <Component\n {...elementProps}\n {...handlers}\n ref={ref}\n className={cn(\n buttonClassNames.root,\n buttonClassName({ appearance, size, disabled: showDisabledLook, iconOnly }),\n hasIcon && hasLabel && 'gap-1.5',\n className,\n )}\n {...enforced}\n >\n {content}\n </Component>\n );\n};\n\nButton.displayName = 'Button';\n"],"mappings":";;;;;;;;;;AA2HA,IAAaE,KAA0D,MAAU;CAC/E,IAAM,EACJ,OACA,gBAAa,WACb,UAAO,UACP,SACA,kBAAe,UACf,cAAW,IACX,uBAAoB,IACpB,cACA,aACA,QACA,YACA,cACA,YACA,WACA,GAAGC,MACDC,GAEEC,IAA+BC,KAAM,UACrCC,IAAM,OAAOF,KAAc,WAAWA,IAAY,MAClDG,IAASD,MAAQ,QAAQE,EAAc,IAAIF,CAAG,GAE9C,EAAE,aAAU,aAAU,gBAAaG,EAAmB;EAC1D;EACA,MAAMP,EAAK;EACX;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,GACKQ,IAAeR,EAAK,kBAKpBS,IAAcC,EAClBC,EAAmBC,CAAI,IAAIA,IAAO,KAAA,GAClC,QACAC,EAAGC,EAAiB,MAAM,mCAAmC,GAC7D,EAAE,eAAe,GAAK,CACxB,GAEMC,IAAUN,MAAgB,MAE1BO,IAAQC,EAAuBC,CAAQ,GACvCC,IAAWR,EAAmBK,CAAK,GACnCI,IAAWL,KAAW,CAACI,GAEvBE,IAAYrB,EAAK,eACjBsB,IAAiBtB,EAAK,oBACtBuB,IAAQvB,EAAK;CACnB,EAAM,gBAAgB;EACpB,AAAIoB,KAAY,CAACC,KAAa,CAACC,KAAkB,CAACC,KAChDC,EACE,yBACA,oKACF;CAEJ,GAAG;EAACJ;EAAUC;EAAWC;EAAgBC;CAAK,CAAC;CAI/C,IAAME,IAAwC,EAAE,GAAGzB,EAAK;CACxD,KAAK,IAAM,CAAC0B,GAAKC,MAAU,OAAO,QAAQC,CAAQ,GAAG,EAAaF,OAASC;CAE3E,IAAME,IACJC,KAAYC,KAAqBvB,MAAiB,MAAQA,MAAiB,QACzEwB,IAA2BhB;CAkB/B,OAjBIX,IAAQ,IAAU,KAAA,IACbI,MAEP,IACEwB,MAAiB,UACf,kBAAApC,GAAA,EAAA,UAAA,CACGmB,GACAP,CACD,EAAA,CAAA,IAEF,kBAAAZ,GAAA,EAAA,UAAA,CACGY,GACAO,CACD,EAAA,CAAA,IAKN,kBAACd,GAAD;EACE,GAAIuB;EACJ,GAAIU;EACC;EACL,WAAWtB,EACTC,EAAiB,MACjBsB,EAAgB;GAAE;GAAY;GAAM,UAAUP;GAAkB;EAAS,CAAC,GAC1Ed,KAAWI,KAAY,WACvBkB,CACF;EACA,GAAIC;EAEH,UAAAN;CACQ,CAAA;AAEf;AAEA,EAAO,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/children.cjs"),n=require("../../lib/
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/children.cjs"),n=require("../../lib/slot.cjs"),r=require("../../lib/aria.cjs"),i=require("./Button.cjs");let a=require("react");a=e.__toESM(a,1);let o=require("react/jsx-runtime");var s=new Set(Object.keys({as:!0,appearance:!0,size:!0,icon:!0,iconPosition:!0,disabledFocusable:!0}));function c(e,t,n){return n===`after`?(0,o.jsxs)(o.Fragment,{children:[t,e]}):(0,o.jsxs)(o.Fragment,{children:[e,t]})}function l(e){e.preventDefault(),e.stopPropagation()}var u={...r.focusableDisabledProps(!0,{reachable:!0}),disabled:!1,onClick:l},d=`aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100`;function f(e,t){if(!n.slotRendersContent(e))return e;let r=n.resolveSlot(e,`span`,t);return r?{...r.props,as:r.Component,children:r.children}:e}function p(e){if(typeof e!=`object`||!e||a.isValidElement(e)||Symbol.iterator in e||!(`as`in e))return!1;let{as:t}=e;return t===`button`||t===i.Button}function m(e){let n=e;return t.isElementOfType(n,`button`,i.Button)?{glyph:n.props.children,button:`a button element`}:p(e)?{glyph:e.children,button:`a slot object that renders a button`}:{glyph:e,button:null}}exports.BUTTON_OWN_PROP_KEYS=s,exports.MERGED_DISABLED_FOCUSABLE_PROPS=u,exports.mergedAriaDisabledClasses=d,exports.placeButtonIcon=c,exports.unwrapButtonGlyph=m,exports.withPartClass=f;
|
|
2
2
|
//# sourceMappingURL=Button.slots.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.slots.cjs","names":["_Fragment","focusableDisabledProps","React","Button","isElementOfType","require_runtime","require_children","require_aria","require_Button","react","react_jsx_runtime","BUTTON_OWN_PROP_KEYS","placeButtonIcon","iconPosition","content","icon","blockClick","event","MERGED_DISABLED_FOCUSABLE_PROPS","mergedAriaDisabledClasses","isButtonSlotObject","value","as","unwrapButtonGlyph","node"
|
|
1
|
+
{"version":3,"file":"Button.slots.cjs","names":["_Fragment","focusableDisabledProps","slotRendersContent","resolveSlot","React","Button","isElementOfType","require_runtime","require_children","require_slot","require_aria","require_Button","react","react_jsx_runtime","BUTTON_OWN_PROP_KEYS","placeButtonIcon","iconPosition","content","icon","blockClick","event","MERGED_DISABLED_FOCUSABLE_PROPS","mergedAriaDisabledClasses","withPartClass","slot","resolved","className","isButtonSlotObject","value","as","unwrapButtonGlyph","node"],"sources":["../../../src/components/button/Button.slots.tsx"],"sourcesContent":["/**\n * How the slots of other components treat a `<button>` or Wave `Button` passed to them (C-SLOTS).\n * Internal (not exported from the package).\n *\n * - Dismiss and clear slots (MessageBar `dismiss`, SearchBox `dismiss`, Tag `dismissIcon`) merge\n * it into their own wired `<button>`. {@link BUTTON_OWN_PROP_KEYS} lists the Button props that\n * must not reach that element; {@link placeButtonIcon} and {@link MERGED_DISABLED_FOCUSABLE_PROPS}\n * give it what the Button would have done with `icon`, `iconPosition` and `disabledFocusable`.\n * - Glyph slots inside a wired button (SplitButton and MenuButton `menuIcon`, Combobox and\n * TimePicker `expandIcon`) unwrap it: {@link unwrapButtonGlyph}.\n * - Variants that hand their `icon` to Button (ToggleButton, CompoundButton, MenuButton,\n * SplitButton, the Toolbar buttons) add their part class to it: {@link withPartClass}.\n */\nimport * as React from 'react';\nimport { focusableDisabledProps } from '../../lib/aria';\nimport { isElementOfType } from '../../lib/children';\nimport { resolveSlot, slotRendersContent } from '../../lib/slot';\nimport type { Slot, SlotObject } from '../../lib/slot';\nimport { Button } from './Button';\nimport type { ButtonOwnProps } from './Button';\n\n/**\n * The keys of {@link BUTTON_OWN_PROP_KEYS}, checked against `ButtonOwnProps`: a new own prop of\n * `Button` does not compile until it is listed here, so it cannot leak onto a wired button.\n */\nconst buttonOwnPropKeys = {\n as: true,\n appearance: true,\n size: true,\n icon: true,\n iconPosition: true,\n disabledFocusable: true,\n} satisfies Record<Exclude<keyof ButtonOwnProps, 'disabled'> | 'as', true>;\n\n/**\n * The props of a Wave `Button` that are not DOM attributes: `as` and every own prop except\n * `disabled` (a native attribute, merged as one). A component that merges a `Button` into its own\n * `<button>` never spreads these onto it; it applies `icon`, `iconPosition` and\n * `disabledFocusable` itself.\n */\nexport const BUTTON_OWN_PROP_KEYS: ReadonlySet<string> = new Set(Object.keys(buttonOwnPropKeys));\n\n/**\n * The content of a wired button that merged a Wave `Button`: the Button's decorative icon before\n * its content, or after it for `iconPosition=\"after\"`, as `Button` renders it (DOM order, so it\n * follows the writing direction).\n *\n * @param icon The rendered icon (`aria-hidden`), or `null`.\n * @param content The Button's content.\n * @param iconPosition The Button's `iconPosition` (anything but `'after'` means before).\n */\nexport function placeButtonIcon(\n icon: React.ReactNode,\n content: React.ReactNode,\n iconPosition: unknown,\n): React.ReactElement {\n return iconPosition === 'after' ? (\n <>\n {content}\n {icon}\n </>\n ) : (\n <>\n {icon}\n {content}\n </>\n );\n}\n\n/** Prevents a click and stops it, as a natively disabled button dispatches none to ancestors. */\nfunction blockClick(event: React.MouseEvent<HTMLElement>) {\n event.preventDefault();\n event.stopPropagation();\n}\n\n/**\n * Spread last on a wired button that merged a Wave `Button` with `disabledFocusable`, so it\n * behaves as that Button would: `aria-disabled`, `data-disabled` and `data-disabled-focusable`\n * instead of the native `disabled` (overridden: `disabledFocusable` wins over `disabled`), so it\n * keeps its tab stop; its click is prevented and stopped, so neither the merged `onClick` nor the\n * component's own action runs and no ancestor click handler sees it. A native `<button>` also\n * activates through a click for Enter, Space and implicit form submission, so those are blocked\n * too.\n */\nexport const MERGED_DISABLED_FOCUSABLE_PROPS = {\n ...focusableDisabledProps(true, { reachable: true }),\n disabled: false,\n onClick: blockClick,\n};\n\n/**\n * The disabled look of a wired dismiss or clear button while `aria-disabled` (a merged\n * `disabledFocusable`, or a consumer `aria-disabled`): dimmed like a disabled button, except while\n * it shows its focus ring, which `opacity` would dim too.\n */\nexport const mergedAriaDisabledClasses =\n 'aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100';\n\n/**\n * `slot` as a slot object whose element also carries `className`: a variant's part class on the\n * icon that Button draws (`icon={withPartClass(icon, toggleButtonClassNames.icon)}`), so Button's\n * icon span carries both components' classes and Button needs no class prop of its own.\n * Shorthand content becomes the children of a `<span>` with the class; a slot object keeps its\n * element, attributes, `ref` and own classes, with `className` before them (so the consumer's\n * class still wins a conflict). A slot that renders nothing (`null`, `false`, `''`, `[]`, `<></>`)\n * is returned as it is, so no empty icon element renders; applying it twice adds both classes to\n * one element.\n */\nexport function withPartClass(\n slot: Slot<'span'> | undefined,\n className: string,\n): Slot<'span'> | undefined {\n if (!slotRendersContent(slot)) return slot;\n const resolved = resolveSlot(slot, 'span', className);\n if (!resolved) return slot;\n return {\n ...resolved.props,\n as: resolved.Component,\n children: resolved.children,\n } as SlotObject<'span'>;\n}\n\n/** What {@link unwrapButtonGlyph} unwrapped, for the slot's development warning. */\nexport type UnwrappedButton = 'a button element' | 'a slot object that renders a button';\n\n/** Whether `value` is a slot object (`{ as, children, … }`) that renders a `<button>` or `Button`. */\nfunction isButtonSlotObject(value: unknown): value is { children?: React.ReactNode } {\n if (typeof value !== 'object' || value === null || React.isValidElement(value)) return false;\n if (Symbol.iterator in value || !('as' in value)) return false;\n const { as } = value as { as?: unknown };\n return as === 'button' || as === Button;\n}\n\n/**\n * A glyph slot's value with a button unwrapped. A glyph inside a wired button is decorative and a\n * button cannot contain a button (C-SLOTS), so for a `<button>` or `Button` element, or a slot\n * object whose `as` is `'button'` or `Button`, the glyph is its `children` and its props are\n * dropped; any other value is the glyph as given. `button` says what was unwrapped (`null`:\n * nothing), so the component can warn once from an effect. A `Button` written in a Server\n * Component (a lazy client reference) is unwrapped too.\n *\n * @example\n * const { glyph, button } = unwrapButtonGlyph(menuIcon);\n */\nexport function unwrapButtonGlyph(slot: Slot<'span'> | undefined): {\n glyph: Slot<'span'> | undefined;\n button: UnwrappedButton | null;\n} {\n // A slot object is never an element, so any slot value can be checked as a node.\n const node = slot as React.ReactNode;\n if (isElementOfType<{ children?: React.ReactNode }>(node, 'button', Button)) {\n return { glyph: node.props.children, button: 'a button element' };\n }\n if (isButtonSlotObject(slot)) {\n return { glyph: slot.children, button: 'a slot object that renders a button' };\n }\n return { glyph: slot, button: null };\n}\n"],"mappings":"8QAwCA,IAAac,EAA4C,IAAI,IAAI,OAAO,KAAK,CAd3E,GAAI,GACJ,WAAY,GACZ,KAAM,GACN,KAAM,GACN,aAAc,GACd,kBAAmB,EASwD,CAAiB,CAAC,EAW/F,SAAgBC,EACd,EACA,EACA,EACoB,CACpB,OAAOC,IAAiB,SACtB,EAAAH,EAAA,KAAA,CAAAb,EAAAA,SAAA,CAAA,SAAA,CACGiB,EACAC,CACD,CAAA,CAAA,GAEF,EAAAL,EAAA,KAAA,CAAAb,EAAAA,SAAA,CAAA,SAAA,CACGkB,EACAD,CACD,CAAA,CAAA,CAEN,CAGA,SAASE,EAAW,EAAsC,CACxDC,EAAM,eAAe,EACrBA,EAAM,gBAAgB,CACxB,CAWA,IAAaC,EAAkC,CAC7C,GAAGpB,EAAAA,uBAAuB,GAAM,CAAE,UAAW,EAAK,CAAC,EACnD,SAAU,GACV,QAASkB,CACX,EAOaG,EACX,oGAYF,SAAgBC,EACd,EACA,EAC0B,CAC1B,GAAI,CAACrB,EAAAA,mBAAmBsB,CAAI,EAAG,OAAOA,EACtC,IAAMC,EAAWtB,EAAAA,YAAYqB,EAAM,OAAQE,CAAS,EAEpD,OADKD,EACE,CACL,GAAGA,EAAS,MACZ,GAAIA,EAAS,UACb,SAAUA,EAAS,QACrB,EALsBD,CAMxB,CAMA,SAASG,EAAmB,EAAyD,CAEnF,GADI,OAAOC,GAAU,WAAYA,GAAkBxB,EAAM,eAAewB,CAAK,GACzE,OAAO,YAAYA,GAAS,EAAE,OAAQA,GAAQ,MAAO,GACzD,GAAM,CAAE,MAAOA,EACf,OAAOC,IAAO,UAAYA,IAAOxB,EAAAA,MACnC,CAaA,SAAgByB,EAAkB,EAGhC,CAEA,IAAMC,EAAOP,EAOb,OANIlB,EAAAA,gBAAgDyB,EAAM,SAAU1B,EAAAA,MAAM,EACjE,CAAE,MAAO0B,EAAK,MAAM,SAAU,OAAQ,kBAAmB,EAE9DJ,EAAmBH,CAAI,EAClB,CAAE,MAAOA,EAAK,SAAU,OAAQ,qCAAsC,EAExE,CAAE,MAAOA,EAAM,OAAQ,IAAK,CACrC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { isElementOfType as e } from "../../lib/children.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
3
|
+
import { resolveSlot as t, slotRendersContent as n } from "../../lib/slot.mjs";
|
|
4
|
+
import { focusableDisabledProps as r } from "../../lib/aria.mjs";
|
|
5
|
+
import { Button as i } from "./Button.mjs";
|
|
6
|
+
import * as a from "react";
|
|
7
|
+
import { Fragment as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
var c = new Set(Object.keys({
|
|
8
9
|
as: !0,
|
|
9
10
|
appearance: !0,
|
|
10
11
|
size: !0,
|
|
@@ -12,28 +13,37 @@ var o = new Set(Object.keys({
|
|
|
12
13
|
iconPosition: !0,
|
|
13
14
|
disabledFocusable: !0
|
|
14
15
|
}));
|
|
15
|
-
function
|
|
16
|
-
return n === "after" ? /* @__PURE__ */
|
|
16
|
+
function l(e, t, n) {
|
|
17
|
+
return n === "after" ? /* @__PURE__ */ s(o, { children: [t, e] }) : /* @__PURE__ */ s(o, { children: [e, t] });
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function u(e) {
|
|
19
20
|
e.preventDefault(), e.stopPropagation();
|
|
20
21
|
}
|
|
21
|
-
var
|
|
22
|
-
...
|
|
22
|
+
var d = {
|
|
23
|
+
...r(!0, { reachable: !0 }),
|
|
23
24
|
disabled: !1,
|
|
24
|
-
onClick:
|
|
25
|
-
},
|
|
26
|
-
function
|
|
27
|
-
if (
|
|
25
|
+
onClick: u
|
|
26
|
+
}, f = "aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100";
|
|
27
|
+
function p(e, r) {
|
|
28
|
+
if (!n(e)) return e;
|
|
29
|
+
let i = t(e, "span", r);
|
|
30
|
+
return i ? {
|
|
31
|
+
...i.props,
|
|
32
|
+
as: i.Component,
|
|
33
|
+
children: i.children
|
|
34
|
+
} : e;
|
|
35
|
+
}
|
|
36
|
+
function m(e) {
|
|
37
|
+
if (typeof e != "object" || !e || a.isValidElement(e) || Symbol.iterator in e || !("as" in e)) return !1;
|
|
28
38
|
let { as: t } = e;
|
|
29
|
-
return t === "button" || t ===
|
|
39
|
+
return t === "button" || t === i;
|
|
30
40
|
}
|
|
31
|
-
function
|
|
32
|
-
let
|
|
33
|
-
return e(
|
|
34
|
-
glyph:
|
|
41
|
+
function h(t) {
|
|
42
|
+
let n = t;
|
|
43
|
+
return e(n, "button", i) ? {
|
|
44
|
+
glyph: n.props.children,
|
|
35
45
|
button: "a button element"
|
|
36
|
-
} :
|
|
46
|
+
} : m(t) ? {
|
|
37
47
|
glyph: t.children,
|
|
38
48
|
button: "a slot object that renders a button"
|
|
39
49
|
} : {
|
|
@@ -42,6 +52,6 @@ function f(t) {
|
|
|
42
52
|
};
|
|
43
53
|
}
|
|
44
54
|
//#endregion
|
|
45
|
-
export {
|
|
55
|
+
export { c as BUTTON_OWN_PROP_KEYS, d as MERGED_DISABLED_FOCUSABLE_PROPS, f as mergedAriaDisabledClasses, l as placeButtonIcon, h as unwrapButtonGlyph, p as withPartClass };
|
|
46
56
|
|
|
47
57
|
//# sourceMappingURL=Button.slots.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.slots.mjs","names":["_Fragment","React","BUTTON_OWN_PROP_KEYS","placeButtonIcon","iconPosition","Fragment","content","icon","blockClick","event","MERGED_DISABLED_FOCUSABLE_PROPS","focusableDisabledProps","mergedAriaDisabledClasses","isButtonSlotObject","value","as","Button","unwrapButtonGlyph","node","
|
|
1
|
+
{"version":3,"file":"Button.slots.mjs","names":["_Fragment","React","BUTTON_OWN_PROP_KEYS","placeButtonIcon","iconPosition","Fragment","content","icon","blockClick","event","MERGED_DISABLED_FOCUSABLE_PROPS","focusableDisabledProps","mergedAriaDisabledClasses","withPartClass","slotRendersContent","slot","resolved","resolveSlot","className","isButtonSlotObject","value","as","Button","unwrapButtonGlyph","node","isElementOfType"],"sources":["../../../src/components/button/Button.slots.tsx"],"sourcesContent":["/**\n * How the slots of other components treat a `<button>` or Wave `Button` passed to them (C-SLOTS).\n * Internal (not exported from the package).\n *\n * - Dismiss and clear slots (MessageBar `dismiss`, SearchBox `dismiss`, Tag `dismissIcon`) merge\n * it into their own wired `<button>`. {@link BUTTON_OWN_PROP_KEYS} lists the Button props that\n * must not reach that element; {@link placeButtonIcon} and {@link MERGED_DISABLED_FOCUSABLE_PROPS}\n * give it what the Button would have done with `icon`, `iconPosition` and `disabledFocusable`.\n * - Glyph slots inside a wired button (SplitButton and MenuButton `menuIcon`, Combobox and\n * TimePicker `expandIcon`) unwrap it: {@link unwrapButtonGlyph}.\n * - Variants that hand their `icon` to Button (ToggleButton, CompoundButton, MenuButton,\n * SplitButton, the Toolbar buttons) add their part class to it: {@link withPartClass}.\n */\nimport * as React from 'react';\nimport { focusableDisabledProps } from '../../lib/aria';\nimport { isElementOfType } from '../../lib/children';\nimport { resolveSlot, slotRendersContent } from '../../lib/slot';\nimport type { Slot, SlotObject } from '../../lib/slot';\nimport { Button } from './Button';\nimport type { ButtonOwnProps } from './Button';\n\n/**\n * The keys of {@link BUTTON_OWN_PROP_KEYS}, checked against `ButtonOwnProps`: a new own prop of\n * `Button` does not compile until it is listed here, so it cannot leak onto a wired button.\n */\nconst buttonOwnPropKeys = {\n as: true,\n appearance: true,\n size: true,\n icon: true,\n iconPosition: true,\n disabledFocusable: true,\n} satisfies Record<Exclude<keyof ButtonOwnProps, 'disabled'> | 'as', true>;\n\n/**\n * The props of a Wave `Button` that are not DOM attributes: `as` and every own prop except\n * `disabled` (a native attribute, merged as one). A component that merges a `Button` into its own\n * `<button>` never spreads these onto it; it applies `icon`, `iconPosition` and\n * `disabledFocusable` itself.\n */\nexport const BUTTON_OWN_PROP_KEYS: ReadonlySet<string> = new Set(Object.keys(buttonOwnPropKeys));\n\n/**\n * The content of a wired button that merged a Wave `Button`: the Button's decorative icon before\n * its content, or after it for `iconPosition=\"after\"`, as `Button` renders it (DOM order, so it\n * follows the writing direction).\n *\n * @param icon The rendered icon (`aria-hidden`), or `null`.\n * @param content The Button's content.\n * @param iconPosition The Button's `iconPosition` (anything but `'after'` means before).\n */\nexport function placeButtonIcon(\n icon: React.ReactNode,\n content: React.ReactNode,\n iconPosition: unknown,\n): React.ReactElement {\n return iconPosition === 'after' ? (\n <>\n {content}\n {icon}\n </>\n ) : (\n <>\n {icon}\n {content}\n </>\n );\n}\n\n/** Prevents a click and stops it, as a natively disabled button dispatches none to ancestors. */\nfunction blockClick(event: React.MouseEvent<HTMLElement>) {\n event.preventDefault();\n event.stopPropagation();\n}\n\n/**\n * Spread last on a wired button that merged a Wave `Button` with `disabledFocusable`, so it\n * behaves as that Button would: `aria-disabled`, `data-disabled` and `data-disabled-focusable`\n * instead of the native `disabled` (overridden: `disabledFocusable` wins over `disabled`), so it\n * keeps its tab stop; its click is prevented and stopped, so neither the merged `onClick` nor the\n * component's own action runs and no ancestor click handler sees it. A native `<button>` also\n * activates through a click for Enter, Space and implicit form submission, so those are blocked\n * too.\n */\nexport const MERGED_DISABLED_FOCUSABLE_PROPS = {\n ...focusableDisabledProps(true, { reachable: true }),\n disabled: false,\n onClick: blockClick,\n};\n\n/**\n * The disabled look of a wired dismiss or clear button while `aria-disabled` (a merged\n * `disabledFocusable`, or a consumer `aria-disabled`): dimmed like a disabled button, except while\n * it shows its focus ring, which `opacity` would dim too.\n */\nexport const mergedAriaDisabledClasses =\n 'aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:focus-visible:opacity-100';\n\n/**\n * `slot` as a slot object whose element also carries `className`: a variant's part class on the\n * icon that Button draws (`icon={withPartClass(icon, toggleButtonClassNames.icon)}`), so Button's\n * icon span carries both components' classes and Button needs no class prop of its own.\n * Shorthand content becomes the children of a `<span>` with the class; a slot object keeps its\n * element, attributes, `ref` and own classes, with `className` before them (so the consumer's\n * class still wins a conflict). A slot that renders nothing (`null`, `false`, `''`, `[]`, `<></>`)\n * is returned as it is, so no empty icon element renders; applying it twice adds both classes to\n * one element.\n */\nexport function withPartClass(\n slot: Slot<'span'> | undefined,\n className: string,\n): Slot<'span'> | undefined {\n if (!slotRendersContent(slot)) return slot;\n const resolved = resolveSlot(slot, 'span', className);\n if (!resolved) return slot;\n return {\n ...resolved.props,\n as: resolved.Component,\n children: resolved.children,\n } as SlotObject<'span'>;\n}\n\n/** What {@link unwrapButtonGlyph} unwrapped, for the slot's development warning. */\nexport type UnwrappedButton = 'a button element' | 'a slot object that renders a button';\n\n/** Whether `value` is a slot object (`{ as, children, … }`) that renders a `<button>` or `Button`. */\nfunction isButtonSlotObject(value: unknown): value is { children?: React.ReactNode } {\n if (typeof value !== 'object' || value === null || React.isValidElement(value)) return false;\n if (Symbol.iterator in value || !('as' in value)) return false;\n const { as } = value as { as?: unknown };\n return as === 'button' || as === Button;\n}\n\n/**\n * A glyph slot's value with a button unwrapped. A glyph inside a wired button is decorative and a\n * button cannot contain a button (C-SLOTS), so for a `<button>` or `Button` element, or a slot\n * object whose `as` is `'button'` or `Button`, the glyph is its `children` and its props are\n * dropped; any other value is the glyph as given. `button` says what was unwrapped (`null`:\n * nothing), so the component can warn once from an effect. A `Button` written in a Server\n * Component (a lazy client reference) is unwrapped too.\n *\n * @example\n * const { glyph, button } = unwrapButtonGlyph(menuIcon);\n */\nexport function unwrapButtonGlyph(slot: Slot<'span'> | undefined): {\n glyph: Slot<'span'> | undefined;\n button: UnwrappedButton | null;\n} {\n // A slot object is never an element, so any slot value can be checked as a node.\n const node = slot as React.ReactNode;\n if (isElementOfType<{ children?: React.ReactNode }>(node, 'button', Button)) {\n return { glyph: node.props.children, button: 'a button element' };\n }\n if (isButtonSlotObject(slot)) {\n return { glyph: slot.children, button: 'a slot object that renders a button' };\n }\n return { glyph: slot, button: null };\n}\n"],"mappings":";;;;;;;AAwCA,IAAaE,IAA4C,IAAI,IAAI,OAAO,KAAK;CAd3E,IAAI;CACJ,YAAY;CACZ,MAAM;CACN,MAAM;CACN,cAAc;CACd,mBAAmB;AASwD,CAAiB,CAAC;AAW/F,SAAgBC,EACd,GACA,GACA,GACoB;CACpB,OAAOC,MAAiB,UACtB,kBAAAJ,GAAA,EAAA,UAAA,CACGM,GACAC,CACD,EAAA,CAAA,IAEF,kBAAAP,GAAA,EAAA,UAAA,CACGO,GACAD,CACD,EAAA,CAAA;AAEN;AAGA,SAASE,EAAW,GAAsC;CAExD,AADAC,EAAM,eAAe,GACrBA,EAAM,gBAAgB;AACxB;AAWA,IAAaC,IAAkC;CAC7C,GAAGC,EAAuB,IAAM,EAAE,WAAW,GAAK,CAAC;CACnD,UAAU;CACV,SAASH;AACX,GAOaI,IACX;AAYF,SAAgBC,EACd,GACA,GAC0B;CAC1B,IAAI,CAACC,EAAmBC,CAAI,GAAG,OAAOA;CACtC,IAAMC,IAAWC,EAAYF,GAAM,QAAQG,CAAS;CAEpD,OADKF,IACE;EACL,GAAGA,EAAS;EACZ,IAAIA,EAAS;EACb,UAAUA,EAAS;CACrB,IALsBD;AAMxB;AAMA,SAASI,EAAmB,GAAyD;CAEnF,IADI,OAAOC,KAAU,aAAYA,KAAkBnB,EAAM,eAAemB,CAAK,KACzE,OAAO,YAAYA,KAAS,EAAE,QAAQA,IAAQ,OAAO;CACzD,IAAM,EAAE,UAAOA;CACf,OAAOC,MAAO,YAAYA,MAAOC;AACnC;AAaA,SAAgBC,EAAkB,GAGhC;CAEA,IAAMC,IAAOT;CAOb,OANIU,EAAgDD,GAAM,UAAUF,CAAM,IACjE;EAAE,OAAOE,EAAK,MAAM;EAAU,QAAQ;CAAmB,IAE9DL,EAAmBJ,CAAI,IAClB;EAAE,OAAOA,EAAK;EAAU,QAAQ;CAAsC,IAExE;EAAE,OAAOA;EAAM,QAAQ;CAAK;AACrC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/slot.cjs"),r=require("./Button.cjs");let
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/slot.cjs"),r=require("../../lib/classNames.cjs"),i=require("./Button.cjs"),a=require("./Button.slots.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c={"extra-small":`py-0.5`,small:`py-1`,medium:`py-2`,large:`py-3`,"extra-large":`py-4`},l={"extra-small":`size-6`,small:`size-8`,medium:`size-10`,large:`size-10`,"extra-large":`size-10`},u=i.Button,d=e=>{let{secondaryText:i,appearance:o=`outline`,size:d=`medium`,icon:f,iconPosition:p=`before`,className:m,children:h,...g}=e,_=n.materialiseSlotContent(h),v=n.materialiseSlotContent(i),y=n.slotRendersContent(v);if(!n.slotRendersContent(_)&&!y)return(0,s.jsx)(u,{...g,appearance:o,size:d,icon:a.withPartClass(f,r.compoundButtonClassNames.icon),iconPosition:p,className:t.cn(r.compoundButtonClassNames.root,m)});let b=n.renderSlot(n.slotRendersContent(f)?f:void 0,`span`,t.cn(r.buttonClassNames.icon,r.compoundButtonClassNames.icon,`inline-flex shrink-0 items-center justify-center [&>svg]:size-full`,l[d]),{"aria-hidden":!0}),x=(0,s.jsxs)(`span`,{"data-wave-compound-content":``,className:t.cn(r.compoundButtonClassNames.contentContainer,`flex min-w-0 flex-col items-start`),children:[(0,s.jsx)(`span`,{className:t.cn(r.compoundButtonClassNames.primaryText,`font-bold`),children:_}),y&&(0,s.jsx)(`span`,{className:t.cn(r.compoundButtonClassNames.secondaryText,`text-caption-1 font-normal`,o===`primary`?`text-primary-foreground`:`text-muted-foreground`),children:v})]});return(0,s.jsx)(u,{...g,appearance:o,size:d,className:t.cn(r.compoundButtonClassNames.root,`h-auto items-center justify-start gap-3 text-start`,c[d],m),children:p===`after`?(0,s.jsxs)(s.Fragment,{children:[x,b]}):(0,s.jsxs)(s.Fragment,{children:[b,x]})})};d.displayName=`CompoundButton`,exports.CompoundButton=d;
|
|
2
2
|
//# sourceMappingURL=CompoundButton.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompoundButton.cjs","names":["Button","materialiseSlotContent","slotRendersContent","
|
|
1
|
+
{"version":3,"file":"CompoundButton.cjs","names":["Button","materialiseSlotContent","slotRendersContent","withPartClass","compoundButtonClassNames","cn","renderSlot","buttonClassNames","_Fragment","require_runtime","require_cn","require_slot","require_classNames","require_Button","require_Button_slots","react","react_jsx_runtime","paddingClasses","iconBoxClasses","BaseButton","CompoundButton","rest","props","label","children","secondary","secondaryText","hasSecondary","icon","className","iconElement","size","content","appearance","iconPosition"],"sources":["../../../src/components/button/CompoundButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { buttonClassNames, compoundButtonClassNames } from '../../lib/classNames';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport type { PolymorphicComponent, PolymorphicProps } from '../../lib/polymorphic';\nimport type { Size, Appearance, IconPosition, Slot } from '../../lib/types';\nimport { Button } from './Button';\nimport { withPartClass } from './Button.slots';\n\n/**\n * The CompoundButton's own props (the XOwnProps rule of `PolymorphicProps`: component-specific\n * props only). Every other prop comes from the rendered element (`as`).\n */\nexport interface CompoundButtonOwnProps {\n /**\n * Secondary descriptive text displayed below the main label (part of the accessible name).\n * Content that renders nothing (`''`, `[]`, `<></>`) renders no second line.\n */\n secondaryText?: React.ReactNode;\n /** Visual style variant.\n * @default 'outline'\n */\n appearance?: Appearance;\n /** Size affecting padding and font size.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Disables the button. As with {@link Button}: a native `disabled` attribute for form controls\n * (the default `button`); every other `as` gets `aria-disabled=\"true\"` and `tabIndex={-1}`, its\n * activation is prevented and an `<a>` drops its `href`.\n * @default false\n */\n disabled?: boolean;\n /**\n * Marks the button unavailable but keeps it focusable and in the tab order (for a Tooltip\n * that explains why, or a toolbar). Renders `aria-disabled=\"true\"`, `data-disabled` and\n * `data-disabled-focusable` instead of the native `disabled` attribute; clicks, Enter, Space\n * and implicit form submission are prevented, and your `onClick` is not called. Wins over\n * `disabled` when both are set. In a `Toolbar` it stays in the arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n /**\n * Icon shown beside the two lines of text, in a 40px box (32px at `small`, 24px at\n * `extra-small`) whose SVG fills it. Decorative (`aria-hidden`). A CompoundButton with only an\n * icon (no label, no `secondaryText`) is an icon-only button: it looks and is checked like an\n * icon-only `Button` and needs `aria-label`, `aria-labelledby` or `title`.\n */\n icon?: Slot<'span'>;\n /**\n * Where the icon renders: before the text column (the inline start) or after it (the inline\n * end). Follows the writing direction through DOM order. Has no effect without an icon or on\n * an icon-only button.\n * @default 'before'\n */\n iconPosition?: IconPosition;\n}\n\n/**\n * Props of {@link CompoundButton} rendered as `C` (default `'button'`). `CompoundButtonProps`\n * without a type argument is the 0.4 name: the props of a CompoundButton rendered as a\n * `<button>`, including `ref`.\n */\nexport type CompoundButtonProps<C extends React.ElementType = 'button'> = PolymorphicProps<\n C,\n CompoundButtonOwnProps\n>;\n\n/**\n * Vertical padding per size. The height is content-sized (`h-auto` replaces Button's fixed\n * height); horizontal padding and font size come from Button.\n */\nconst paddingClasses: Record<Size, string> = {\n 'extra-small': 'py-0.5',\n small: 'py-1',\n medium: 'py-2',\n large: 'py-3',\n 'extra-large': 'py-4',\n};\n\n/** The icon box per size (its SVG fills it): 24px at extra-small, 32px at small, else 40px. */\nconst iconBoxClasses: Record<Size, string> = {\n 'extra-small': 'size-6',\n small: 'size-8',\n medium: 'size-10',\n large: 'size-10',\n 'extra-large': 'size-10',\n};\n\n/** The props the implementation reads, for any `as`. */\ntype CompoundButtonImplProps = CompoundButtonOwnProps & {\n as?: React.ElementType;\n className?: string;\n children?: React.ReactNode;\n};\n\n/** `Button` widened to any element props, so `as` and the rest props pass through untyped. */\nconst BaseButton = Button as React.ElementType;\n\n/**\n * A button with a main label and a secondary line of text below it, and an optional icon beside\n * them. Built on {@link Button}: same appearances, sizes, token colors, `type=\"button\"` default,\n * `disabled`/`disabledFocusable` and polymorphic `as` behaviour (`as=\"a\"` renders a link; a\n * non-interactive `as` gets `role=\"button\"`, a tab stop and Enter/Space activation; `disabled`\n * becomes `aria-disabled` on non-form-control elements).\n *\n * - The text lines sit in a column wrapper (`span[data-wave-compound-content]`); the icon renders\n * before or after it (`iconPosition`).\n * - With only an icon (no label and no `secondaryText`) it is an icon-only `Button`: square, with\n * the icon-only sizing and name check.\n *\n * @example\n * <CompoundButton secondaryText=\"Opens your email client\">Send mail</CompoundButton>\n * <CompoundButton icon={<CalendarIcon />} secondaryText=\"Next Monday at 9:00\">\n * Schedule\n * </CompoundButton>\n * <CompoundButton as=\"a\" href=\"/signup\" appearance=\"primary\" secondaryText=\"Free for 30 days\">\n * Create account\n * </CompoundButton>\n */\nexport const CompoundButton: PolymorphicComponent<'button', CompoundButtonOwnProps> = (props) => {\n const {\n secondaryText,\n appearance = 'outline',\n size = 'medium',\n icon,\n iconPosition = 'before',\n className,\n children,\n ...rest\n } = props as CompoundButtonImplProps;\n // Content that renders nothing (`''`, `[]`, `<></>`) counts as absent; a generator is read once\n // by the check and its items render.\n const label = materialiseSlotContent(children);\n const secondary = materialiseSlotContent(secondaryText);\n const hasSecondary = slotRendersContent(secondary);\n\n // Without any text it is an icon-only (or empty) Button: Button's own sizing and name check.\n if (!slotRendersContent(label) && !hasSecondary) {\n return (\n <BaseButton\n {...rest}\n appearance={appearance}\n size={size}\n icon={withPartClass(icon, compoundButtonClassNames.icon)}\n iconPosition={iconPosition}\n className={cn(compoundButtonClassNames.root, className)}\n />\n );\n }\n\n const iconElement = renderSlot(\n slotRendersContent(icon) ? icon : undefined,\n 'span',\n cn(\n buttonClassNames.icon,\n compoundButtonClassNames.icon,\n 'inline-flex shrink-0 items-center justify-center [&>svg]:size-full',\n iconBoxClasses[size],\n ),\n { 'aria-hidden': true },\n );\n const content = (\n <span\n data-wave-compound-content=\"\"\n className={cn(compoundButtonClassNames.contentContainer, 'flex min-w-0 flex-col items-start')}\n >\n <span className={cn(compoundButtonClassNames.primaryText, 'font-bold')}>{label}</span>\n {hasSecondary && (\n <span\n className={cn(\n compoundButtonClassNames.secondaryText,\n 'text-caption-1 font-normal',\n appearance === 'primary' ? 'text-primary-foreground' : 'text-muted-foreground',\n )}\n >\n {secondary}\n </span>\n )}\n </span>\n );\n\n return (\n <BaseButton\n {...rest}\n appearance={appearance}\n size={size}\n className={cn(\n compoundButtonClassNames.root,\n 'h-auto items-center justify-start gap-3 text-start',\n paddingClasses[size],\n className,\n )}\n >\n {iconPosition === 'after' ? (\n <>\n {content}\n {iconElement}\n </>\n ) : (\n <>\n {iconElement}\n {content}\n </>\n )}\n </BaseButton>\n );\n};\n\nCompoundButton.displayName = 'CompoundButton';\n"],"mappings":"8SAyEA,IAAMiB,EAAuC,CAC3C,cAAe,SACf,MAAO,OACP,OAAQ,OACR,MAAO,OACP,cAAe,MACjB,EAGMC,EAAuC,CAC3C,cAAe,SACf,MAAO,SACP,OAAQ,UACR,MAAO,UACP,cAAe,SACjB,EAUMC,EAAanB,EAAAA,OAuBNoB,EAA0E,GAAU,CAC/F,GAAM,CACJ,gBACA,aAAa,UACb,OAAO,SACP,OACA,eAAe,SACf,YACA,WACA,GAAGC,GACDC,EAGEC,EAAQtB,EAAAA,uBAAuBuB,CAAQ,EACvCC,EAAYxB,EAAAA,uBAAuByB,CAAa,EAChDC,EAAezB,EAAAA,mBAAmBuB,CAAS,EAGjD,GAAI,CAACvB,EAAAA,mBAAmBqB,CAAK,GAAK,CAACI,EACjC,OACE,EAAAX,EAAA,IAAA,CAACG,EAAD,CACE,GAAIE,EACQ,aACN,OACN,KAAMlB,EAAAA,cAAcyB,EAAMxB,EAAAA,yBAAyB,IAAI,EACzC,eACd,UAAWC,EAAAA,GAAGD,EAAAA,yBAAyB,KAAMyB,CAAS,CACvD,CAAA,EAIL,IAAMC,EAAcxB,EAAAA,WAClBJ,EAAAA,mBAAmB0B,CAAI,EAAIA,EAAO,IAAA,GAClC,OACAvB,EAAAA,GACEE,EAAAA,iBAAiB,KACjBH,EAAAA,yBAAyB,KACzB,qEACAc,EAAea,EACjB,EACA,CAAE,cAAe,EAAK,CACxB,EACMC,GACJ,EAAAhB,EAAA,KAAA,CAAC,OAAD,CACE,6BAA2B,GAC3B,UAAWX,EAAAA,GAAGD,EAAAA,yBAAyB,iBAAkB,mCAAmC,EAF9F,SAAA,EAIE,EAAAY,EAAA,IAAA,CAAC,OAAD,CAAM,UAAWX,EAAAA,GAAGD,EAAAA,yBAAyB,YAAa,WAAW,EAAI,SAAAmB,CAAY,CAAA,EACpFI,IACC,EAAAX,EAAA,IAAA,CAAC,OAAD,CACE,UAAWX,EAAAA,GACTD,EAAAA,yBAAyB,cACzB,6BACA6B,IAAe,UAAY,0BAA4B,uBACzD,EAEC,SAAAR,CACG,CAAA,CAEJ,IAGR,OACE,EAAAT,EAAA,IAAA,CAACG,EAAD,CACE,GAAIE,EACQ,aACN,OACN,UAAWhB,EAAAA,GACTD,EAAAA,yBAAyB,KACzB,qDACAa,EAAec,GACfF,CACF,EAEC,SAAAK,IAAiB,SAChB,EAAAlB,EAAA,KAAA,CAAAR,EAAAA,SAAA,CAAA,SAAA,CACGwB,EACAF,CACD,CAAA,CAAA,GAEF,EAAAd,EAAA,KAAA,CAAAR,EAAAA,SAAA,CAAA,SAAA,CACGsB,EACAE,CACD,CAAA,CAAA,CAEM,CAAA,CAEhB,EAEA,EAAe,YAAc"}
|
|
@@ -1,53 +1,55 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
3
|
import { materialiseSlotContent as t, renderSlot as n, slotRendersContent as r } from "../../lib/slot.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { buttonClassNames as i, compoundButtonClassNames as a } from "../../lib/classNames.mjs";
|
|
5
|
+
import { Button as o } from "./Button.mjs";
|
|
6
|
+
import { withPartClass as s } from "./Button.slots.mjs";
|
|
5
7
|
import "react";
|
|
6
|
-
import { Fragment as
|
|
8
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
9
|
//#region src/components/button/CompoundButton.tsx
|
|
8
|
-
var
|
|
10
|
+
var d = {
|
|
9
11
|
"extra-small": "py-0.5",
|
|
10
12
|
small: "py-1",
|
|
11
13
|
medium: "py-2",
|
|
12
14
|
large: "py-3",
|
|
13
15
|
"extra-large": "py-4"
|
|
14
|
-
},
|
|
16
|
+
}, f = {
|
|
15
17
|
"extra-small": "size-6",
|
|
16
18
|
small: "size-8",
|
|
17
19
|
medium: "size-10",
|
|
18
20
|
large: "size-10",
|
|
19
21
|
"extra-large": "size-10"
|
|
20
|
-
},
|
|
21
|
-
let { secondaryText:
|
|
22
|
-
if (!r(
|
|
23
|
-
...
|
|
24
|
-
appearance:
|
|
25
|
-
size:
|
|
26
|
-
icon:
|
|
27
|
-
iconPosition:
|
|
28
|
-
className:
|
|
22
|
+
}, p = o, m = (o) => {
|
|
23
|
+
let { secondaryText: m, appearance: h = "outline", size: g = "medium", icon: _, iconPosition: v = "before", className: y, children: b, ...x } = o, S = t(b), C = t(m), w = r(C);
|
|
24
|
+
if (!r(S) && !w) return /* @__PURE__ */ l(p, {
|
|
25
|
+
...x,
|
|
26
|
+
appearance: h,
|
|
27
|
+
size: g,
|
|
28
|
+
icon: s(_, a.icon),
|
|
29
|
+
iconPosition: v,
|
|
30
|
+
className: e(a.root, y)
|
|
29
31
|
});
|
|
30
|
-
let
|
|
32
|
+
let T = n(r(_) ? _ : void 0, "span", e(i.icon, a.icon, "inline-flex shrink-0 items-center justify-center [&>svg]:size-full", f[g]), { "aria-hidden": !0 }), E = /* @__PURE__ */ u("span", {
|
|
31
33
|
"data-wave-compound-content": "",
|
|
32
|
-
className: "flex min-w-0 flex-col items-start",
|
|
33
|
-
children: [/* @__PURE__ */
|
|
34
|
-
className: "font-bold",
|
|
35
|
-
children:
|
|
36
|
-
}),
|
|
37
|
-
className: e("text-caption-1 font-normal",
|
|
38
|
-
children:
|
|
34
|
+
className: e(a.contentContainer, "flex min-w-0 flex-col items-start"),
|
|
35
|
+
children: [/* @__PURE__ */ l("span", {
|
|
36
|
+
className: e(a.primaryText, "font-bold"),
|
|
37
|
+
children: S
|
|
38
|
+
}), w && /* @__PURE__ */ l("span", {
|
|
39
|
+
className: e(a.secondaryText, "text-caption-1 font-normal", h === "primary" ? "text-primary-foreground" : "text-muted-foreground"),
|
|
40
|
+
children: C
|
|
39
41
|
})]
|
|
40
42
|
});
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
-
...
|
|
43
|
-
appearance:
|
|
44
|
-
size:
|
|
45
|
-
className: e("h-auto items-center justify-start gap-3 text-start",
|
|
46
|
-
children:
|
|
43
|
+
return /* @__PURE__ */ l(p, {
|
|
44
|
+
...x,
|
|
45
|
+
appearance: h,
|
|
46
|
+
size: g,
|
|
47
|
+
className: e(a.root, "h-auto items-center justify-start gap-3 text-start", d[g], y),
|
|
48
|
+
children: v === "after" ? /* @__PURE__ */ u(c, { children: [E, T] }) : /* @__PURE__ */ u(c, { children: [T, E] })
|
|
47
49
|
});
|
|
48
50
|
};
|
|
49
|
-
|
|
51
|
+
m.displayName = "CompoundButton";
|
|
50
52
|
//#endregion
|
|
51
|
-
export {
|
|
53
|
+
export { m as CompoundButton };
|
|
52
54
|
|
|
53
55
|
//# sourceMappingURL=CompoundButton.mjs.map
|