@mortenbrudvik/waveui 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +564 -155
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.mjs +36 -35
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/button/Button.slots.cjs +1 -1
- package/dist/components/button/Button.slots.cjs.map +1 -1
- package/dist/components/button/Button.slots.mjs +31 -21
- package/dist/components/button/Button.slots.mjs.map +1 -1
- package/dist/components/button/CompoundButton.cjs +1 -1
- package/dist/components/button/CompoundButton.cjs.map +1 -1
- package/dist/components/button/CompoundButton.mjs +31 -29
- package/dist/components/button/CompoundButton.mjs.map +1 -1
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +24 -23
- package/dist/components/button/Link.mjs.map +1 -1
- package/dist/components/button/MenuButton.cjs +1 -1
- package/dist/components/button/MenuButton.cjs.map +1 -1
- package/dist/components/button/MenuButton.mjs +29 -28
- package/dist/components/button/MenuButton.mjs.map +1 -1
- package/dist/components/button/SplitButton.cjs +1 -1
- package/dist/components/button/SplitButton.cjs.map +1 -1
- package/dist/components/button/SplitButton.mjs +46 -45
- package/dist/components/button/SplitButton.mjs.map +1 -1
- package/dist/components/button/ToggleButton.cjs +1 -1
- package/dist/components/button/ToggleButton.cjs.map +1 -1
- package/dist/components/button/ToggleButton.mjs +38 -35
- package/dist/components/button/ToggleButton.mjs.map +1 -1
- package/dist/components/button/Toolbar.cjs +1 -1
- package/dist/components/button/Toolbar.cjs.map +1 -1
- package/dist/components/button/Toolbar.mjs +43 -42
- package/dist/components/button/Toolbar.mjs.map +1 -1
- package/dist/components/button/Toolbar.parts.cjs +1 -1
- package/dist/components/button/Toolbar.parts.cjs.map +1 -1
- package/dist/components/button/Toolbar.parts.mjs +76 -81
- package/dist/components/button/Toolbar.parts.mjs.map +1 -1
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.mjs +72 -67
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.mjs +89 -88
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
- package/dist/components/data-display/Badge.cjs +1 -1
- package/dist/components/data-display/Badge.cjs.map +1 -1
- package/dist/components/data-display/Badge.mjs +17 -16
- package/dist/components/data-display/Badge.mjs.map +1 -1
- package/dist/components/data-display/CounterBadge.cjs +1 -1
- package/dist/components/data-display/CounterBadge.cjs.map +1 -1
- package/dist/components/data-display/CounterBadge.mjs +18 -17
- package/dist/components/data-display/CounterBadge.mjs.map +1 -1
- package/dist/components/data-display/Divider.cjs +1 -1
- package/dist/components/data-display/Divider.cjs.map +1 -1
- package/dist/components/data-display/Divider.mjs +31 -30
- package/dist/components/data-display/Divider.mjs.map +1 -1
- package/dist/components/data-display/Image.cjs +1 -1
- package/dist/components/data-display/Image.cjs.map +1 -1
- package/dist/components/data-display/Image.mjs +16 -15
- package/dist/components/data-display/Image.mjs.map +1 -1
- package/dist/components/data-display/InfoButton.cjs +2 -0
- package/dist/components/data-display/InfoButton.cjs.map +1 -0
- package/dist/components/data-display/InfoButton.mjs +173 -0
- package/dist/components/data-display/InfoButton.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +36 -92
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +175 -174
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/Persona.cjs +1 -1
- package/dist/components/data-display/Persona.cjs.map +1 -1
- package/dist/components/data-display/Persona.mjs +31 -29
- package/dist/components/data-display/Persona.mjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.cjs +1 -1
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.mjs +25 -24
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +87 -82
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.cjs +1 -1
- package/dist/components/feedback/MessageBar.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.mjs +129 -71
- package/dist/components/feedback/MessageBar.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.parts.cjs +2 -0
- package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.parts.mjs +84 -0
- package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
- package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
- package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +1 -1
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.status.mjs +2 -1
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
- package/dist/components/feedback/ProgressBar.cjs +1 -1
- package/dist/components/feedback/ProgressBar.cjs.map +1 -1
- package/dist/components/feedback/ProgressBar.mjs +44 -43
- package/dist/components/feedback/ProgressBar.mjs.map +1 -1
- package/dist/components/feedback/Skeleton.cjs +1 -1
- package/dist/components/feedback/Skeleton.cjs.map +1 -1
- package/dist/components/feedback/Skeleton.mjs +26 -24
- package/dist/components/feedback/Skeleton.mjs.map +1 -1
- package/dist/components/feedback/Spinner.cjs +1 -1
- package/dist/components/feedback/Spinner.cjs.map +1 -1
- package/dist/components/feedback/Spinner.mjs +32 -31
- package/dist/components/feedback/Spinner.mjs.map +1 -1
- package/dist/components/feedback/Toast.cjs +1 -1
- package/dist/components/feedback/Toast.cjs.map +1 -1
- package/dist/components/feedback/Toast.context.cjs +2 -0
- package/dist/components/feedback/Toast.context.cjs.map +1 -0
- package/dist/components/feedback/Toast.context.mjs +23 -0
- package/dist/components/feedback/Toast.context.mjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +10 -342
- package/dist/components/feedback/Toast.mjs.map +1 -1
- package/dist/components/feedback/Toast.parts.cjs +2 -0
- package/dist/components/feedback/Toast.parts.cjs.map +1 -0
- package/dist/components/feedback/Toast.parts.mjs +98 -0
- package/dist/components/feedback/Toast.parts.mjs.map +1 -0
- package/dist/components/feedback/Toast.root.cjs +2 -0
- package/dist/components/feedback/Toast.root.cjs.map +1 -0
- package/dist/components/feedback/Toast.root.mjs +109 -0
- package/dist/components/feedback/Toast.root.mjs.map +1 -0
- package/dist/components/feedback/Toaster.cjs +2 -0
- package/dist/components/feedback/Toaster.cjs.map +1 -0
- package/dist/components/feedback/Toaster.mjs +564 -0
- package/dist/components/feedback/Toaster.mjs.map +1 -0
- package/dist/components/input/AlphaSlider.cjs +2 -0
- package/dist/components/input/AlphaSlider.cjs.map +1 -0
- package/dist/components/input/AlphaSlider.mjs +115 -0
- package/dist/components/input/AlphaSlider.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +1 -1
- package/dist/components/input/Checkbox.cjs.map +1 -1
- package/dist/components/input/Checkbox.mjs +87 -70
- package/dist/components/input/Checkbox.mjs.map +1 -1
- package/dist/components/input/ColorArea.cjs +2 -0
- package/dist/components/input/ColorArea.cjs.map +1 -0
- package/dist/components/input/ColorArea.mjs +204 -0
- package/dist/components/input/ColorArea.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +5 -5
- package/dist/components/input/ColorPicker.cjs.map +1 -1
- package/dist/components/input/ColorPicker.mjs +142 -165
- package/dist/components/input/ColorPicker.mjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.cjs +2 -0
- package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
- package/dist/components/input/ColorPicker.parts.mjs +192 -0
- package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
- package/dist/components/input/ColorSlider.cjs +2 -0
- package/dist/components/input/ColorSlider.cjs.map +1 -0
- package/dist/components/input/ColorSlider.mjs +138 -0
- package/dist/components/input/ColorSlider.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +22 -22
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +151 -141
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +239 -234
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +109 -100
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Field.cjs +1 -1
- package/dist/components/input/Field.cjs.map +1 -1
- package/dist/components/input/Field.mjs +139 -105
- package/dist/components/input/Field.mjs.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.mjs +80 -55
- package/dist/components/input/Input.mjs.map +1 -1
- package/dist/components/input/Label.cjs +1 -1
- package/dist/components/input/Label.cjs.map +1 -1
- package/dist/components/input/Label.mjs +19 -12
- package/dist/components/input/Label.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +100 -98
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/RadioGroup.cjs +1 -1
- package/dist/components/input/RadioGroup.cjs.map +1 -1
- package/dist/components/input/RadioGroup.mjs +89 -88
- package/dist/components/input/RadioGroup.mjs.map +1 -1
- package/dist/components/input/Rating.cjs +1 -1
- package/dist/components/input/Rating.cjs.map +1 -1
- package/dist/components/input/Rating.item.cjs +2 -0
- package/dist/components/input/Rating.item.cjs.map +1 -0
- package/dist/components/input/Rating.item.mjs +255 -0
- package/dist/components/input/Rating.item.mjs.map +1 -0
- package/dist/components/input/Rating.mjs +152 -152
- package/dist/components/input/Rating.mjs.map +1 -1
- package/dist/components/input/SearchBox.cjs +1 -1
- package/dist/components/input/SearchBox.cjs.map +1 -1
- package/dist/components/input/SearchBox.mjs +162 -132
- package/dist/components/input/SearchBox.mjs.map +1 -1
- package/dist/components/input/Select.cjs +1 -1
- package/dist/components/input/Select.cjs.map +1 -1
- package/dist/components/input/Select.mjs +34 -24
- package/dist/components/input/Select.mjs.map +1 -1
- package/dist/components/input/Slider.cjs +1 -1
- package/dist/components/input/Slider.cjs.map +1 -1
- package/dist/components/input/Slider.mjs +78 -54
- package/dist/components/input/Slider.mjs.map +1 -1
- package/dist/components/input/SpinButton.cjs +1 -1
- package/dist/components/input/SpinButton.cjs.map +1 -1
- package/dist/components/input/SpinButton.mjs +202 -99
- package/dist/components/input/SpinButton.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.mjs +38 -37
- package/dist/components/input/SwatchPicker.mjs.map +1 -1
- package/dist/components/input/Switch.cjs +1 -1
- package/dist/components/input/Switch.cjs.map +1 -1
- package/dist/components/input/Switch.mjs +75 -58
- package/dist/components/input/Switch.mjs.map +1 -1
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.mjs +199 -169
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/Textarea.cjs +1 -1
- package/dist/components/input/Textarea.cjs.map +1 -1
- package/dist/components/input/Textarea.mjs +31 -23
- package/dist/components/input/Textarea.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +185 -177
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/input/colorName.cjs +2 -0
- package/dist/components/input/colorName.cjs.map +1 -0
- package/dist/components/input/colorName.mjs +30 -0
- package/dist/components/input/colorName.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +1 -1
- package/dist/components/input/colorUtils.cjs.map +1 -1
- package/dist/components/input/colorUtils.mjs +154 -56
- package/dist/components/input/colorUtils.mjs.map +1 -1
- package/dist/components/input/fieldLabel.cjs +2 -0
- package/dist/components/input/fieldLabel.cjs.map +1 -0
- package/dist/components/input/fieldLabel.mjs +17 -0
- package/dist/components/input/fieldLabel.mjs.map +1 -0
- package/dist/components/input/inputLook.cjs +2 -0
- package/dist/components/input/inputLook.cjs.map +1 -0
- package/dist/components/input/inputLook.mjs +28 -0
- package/dist/components/input/inputLook.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +1 -1
- package/dist/components/input/pickerStyles.cjs.map +1 -1
- package/dist/components/input/pickerStyles.mjs +42 -4
- package/dist/components/input/pickerStyles.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs +130 -129
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/layout/Card.cjs +1 -1
- package/dist/components/layout/Card.cjs.map +1 -1
- package/dist/components/layout/Card.mjs +78 -77
- package/dist/components/layout/Card.mjs.map +1 -1
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.mjs +111 -110
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/Flex.cjs +1 -1
- package/dist/components/layout/Flex.cjs.map +1 -1
- package/dist/components/layout/Flex.mjs +22 -21
- package/dist/components/layout/Flex.mjs.map +1 -1
- package/dist/components/layout/Grid.cjs +1 -1
- package/dist/components/layout/Grid.cjs.map +1 -1
- package/dist/components/layout/Grid.mjs +19 -18
- package/dist/components/layout/Grid.mjs.map +1 -1
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +92 -91
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Stack.cjs +1 -1
- package/dist/components/layout/Stack.cjs.map +1 -1
- package/dist/components/layout/Stack.mjs +14 -13
- package/dist/components/layout/Stack.mjs.map +1 -1
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +118 -117
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/layout/Tree.cjs +1 -1
- package/dist/components/layout/Tree.cjs.map +1 -1
- package/dist/components/layout/Tree.context.cjs +2 -0
- package/dist/components/layout/Tree.context.cjs.map +1 -0
- package/dist/components/layout/Tree.context.mjs +33 -0
- package/dist/components/layout/Tree.context.mjs.map +1 -0
- package/dist/components/layout/Tree.core.cjs +2 -0
- package/dist/components/layout/Tree.core.cjs.map +1 -0
- package/dist/components/layout/Tree.core.mjs +416 -0
- package/dist/components/layout/Tree.core.mjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
- package/dist/components/layout/Tree.mjs +7 -215
- package/dist/components/layout/Tree.mjs.map +1 -1
- package/dist/components/layout/Tree.selection.cjs +2 -0
- package/dist/components/layout/Tree.selection.cjs.map +1 -0
- package/dist/components/layout/Tree.selection.mjs +73 -0
- package/dist/components/layout/Tree.selection.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +76 -75
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/navigation/Menu.group.cjs +1 -1
- package/dist/components/navigation/Menu.group.cjs.map +1 -1
- package/dist/components/navigation/Menu.group.mjs +39 -37
- package/dist/components/navigation/Menu.group.mjs.map +1 -1
- package/dist/components/navigation/Menu.items.cjs +1 -1
- package/dist/components/navigation/Menu.items.cjs.map +1 -1
- package/dist/components/navigation/Menu.items.mjs +67 -61
- package/dist/components/navigation/Menu.items.mjs.map +1 -1
- package/dist/components/navigation/Menu.link.cjs +1 -1
- package/dist/components/navigation/Menu.link.cjs.map +1 -1
- package/dist/components/navigation/Menu.link.mjs +34 -28
- package/dist/components/navigation/Menu.link.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +114 -113
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +171 -170
- package/dist/components/navigation/Menu.root.mjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.cjs +1 -1
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.mjs +85 -63
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.cjs +1 -1
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.mjs +6 -6
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.mjs +170 -155
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination.cjs.map +1 -1
- package/dist/components/navigation/Pagination.mjs +73 -65
- package/dist/components/navigation/Pagination.mjs.map +1 -1
- package/dist/components/navigation/Stepper.cjs +1 -1
- package/dist/components/navigation/Stepper.cjs.map +1 -1
- package/dist/components/navigation/Stepper.mjs +110 -109
- package/dist/components/navigation/Stepper.mjs.map +1 -1
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +109 -108
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Drawer.cjs +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.mjs +110 -109
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +148 -151
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/Popover.shared.cjs +1 -1
- package/dist/components/overlays/Popover.shared.cjs.map +1 -1
- package/dist/components/overlays/Popover.shared.mjs +82 -77
- package/dist/components/overlays/Popover.shared.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +41 -37
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +87 -86
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +33 -32
- package/dist/components/portal/Portal.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +36 -29
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +228 -227
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +60 -59
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/typography/Text.cjs +1 -1
- package/dist/components/typography/Text.cjs.map +1 -1
- package/dist/components/typography/Text.mjs +12 -11
- package/dist/components/typography/Text.mjs.map +1 -1
- package/dist/hooks/useFieldControl.cjs.map +1 -1
- package/dist/hooks/useFieldControl.mjs.map +1 -1
- package/dist/hooks/useMediaQuery.cjs +2 -0
- package/dist/hooks/useMediaQuery.cjs.map +1 -0
- package/dist/hooks/useMediaQuery.mjs +20 -0
- package/dist/hooks/useMediaQuery.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +3 -3
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2890 -197
- package/dist/index.d.ts +2890 -197
- package/dist/index.mjs +101 -87
- package/dist/lib/classNames.cjs +2 -0
- package/dist/lib/classNames.cjs.map +1 -0
- package/dist/lib/classNames.mjs +423 -0
- package/dist/lib/classNames.mjs.map +1 -0
- package/dist/lib/color.cjs +2 -0
- package/dist/lib/color.cjs.map +1 -0
- package/dist/lib/color.mjs +86 -0
- package/dist/lib/color.mjs.map +1 -0
- package/dist/lib/globalRegistry.cjs.map +1 -1
- package/dist/lib/globalRegistry.mjs.map +1 -1
- package/dist/lib/styles.cjs +1 -1
- package/dist/lib/styles.cjs.map +1 -1
- package/dist/lib/styles.mjs +21 -4
- package/dist/lib/styles.mjs.map +1 -1
- package/dist/lib/toaster.cjs +2 -0
- package/dist/lib/toaster.cjs.map +1 -0
- package/dist/lib/toaster.mjs +77 -0
- package/dist/lib/toaster.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +13 -0
|
@@ -2,57 +2,59 @@
|
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
3
|
import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
|
|
4
4
|
import { reportMissingContext as r, warnOnce as i } from "../../lib/dev.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import { menuGroupClassNames as a, menuGroupHeaderClassNames as o } from "../../lib/classNames.mjs";
|
|
6
|
+
import { useId as s } from "../../hooks/useId.mjs";
|
|
7
|
+
import { MenuColumnSpacers as c } from "./Menu.items.mjs";
|
|
8
|
+
import * as l from "react";
|
|
9
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/navigation/Menu.group.tsx
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var
|
|
11
|
+
var f = l.createContext(null);
|
|
12
|
+
f.displayName = "MenuGroupContext";
|
|
13
|
+
var p = {
|
|
13
14
|
headerId: "",
|
|
14
15
|
headerProps: void 0,
|
|
15
16
|
labelled: !0
|
|
16
17
|
};
|
|
17
|
-
function
|
|
18
|
-
return
|
|
18
|
+
function m(e) {
|
|
19
|
+
return l.useContext(f) || (r(e, "Menu.Group"), p);
|
|
19
20
|
}
|
|
20
|
-
var
|
|
21
|
-
let
|
|
22
|
-
headerId:
|
|
23
|
-
headerProps:
|
|
24
|
-
labelled:
|
|
21
|
+
var h = ({ children: r, className: i, ref: o, ...c }) => {
|
|
22
|
+
let d = s("menu-group-header"), p = t(r).find(({ node: e }) => n(e, g))?.node, m = p?.props, h = m?.id || d, _ = c["aria-label"] !== void 0 || c["aria-labelledby"] !== void 0, v = p !== void 0 || _, y = _ ? c["aria-labelledby"] : p === void 0 ? void 0 : h, b = l.useMemo(() => ({
|
|
23
|
+
headerId: h,
|
|
24
|
+
headerProps: m,
|
|
25
|
+
labelled: v
|
|
25
26
|
}), [
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
h,
|
|
28
|
+
m,
|
|
29
|
+
v
|
|
29
30
|
]);
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
-
value:
|
|
32
|
-
children: /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ u(f.Provider, {
|
|
32
|
+
value: b,
|
|
33
|
+
children: /* @__PURE__ */ u("div", {
|
|
33
34
|
role: "group",
|
|
34
|
-
...
|
|
35
|
-
ref:
|
|
36
|
-
"aria-labelledby":
|
|
37
|
-
|
|
35
|
+
...c,
|
|
36
|
+
ref: o,
|
|
37
|
+
"aria-labelledby": y,
|
|
38
|
+
className: e(a.root, i),
|
|
39
|
+
children: r
|
|
38
40
|
})
|
|
39
41
|
});
|
|
40
42
|
};
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
let { id: n, className: r, children: a, ref:
|
|
44
|
-
return !
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
...
|
|
48
|
-
ref:
|
|
49
|
-
id: (
|
|
50
|
-
className: e("flex items-center gap-2 px-3 pb-1 pt-2 text-caption-1 font-semibold text-muted-foreground", r),
|
|
51
|
-
children: [/* @__PURE__ */ c
|
|
43
|
+
h.displayName = "MenuGroup";
|
|
44
|
+
var g = (t) => {
|
|
45
|
+
let { id: n, className: r, children: a, ref: s, ...f } = t, p = m("Menu.GroupHeader"), h = p.headerProps === t, g = null;
|
|
46
|
+
return !h && p.headerProps !== void 0 ? g = "extra-header" : !h && !p.labelled && (g = "unlabelled"), l.useEffect(() => {
|
|
47
|
+
g === "unlabelled" ? i("Menu.GroupHeader:unlabelled", "Menu.GroupHeader: this header is not a direct child of Menu.Group (or of a Fragment in it), so it does not label the group. Make it a direct child, or pass aria-label to Menu.Group.") : g === "extra-header" && i("Menu.GroupHeader:extra-header", "Menu.GroupHeader: this Menu.Group already has a header (its first direct child header), so this one does not label the group. Give a group one header, or put this one in a Menu.Group of its own.");
|
|
48
|
+
}, [g]), /* @__PURE__ */ d("div", {
|
|
49
|
+
...f,
|
|
50
|
+
ref: s,
|
|
51
|
+
id: (h ? p.headerId : n) || void 0,
|
|
52
|
+
className: e(o.root, "flex items-center gap-2 px-3 pb-1 pt-2 text-caption-1 font-semibold text-muted-foreground", r),
|
|
53
|
+
children: [/* @__PURE__ */ u(c, {}), a]
|
|
52
54
|
});
|
|
53
55
|
};
|
|
54
|
-
|
|
56
|
+
g.displayName = "MenuGroupHeader";
|
|
55
57
|
//#endregion
|
|
56
|
-
export {
|
|
58
|
+
export { h as MenuGroup, g as MenuGroupHeader };
|
|
57
59
|
|
|
58
60
|
//# sourceMappingURL=Menu.group.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.group.mjs","names":["useId","useId$1","React","MenuGroupContext","INERT_GROUP_CONTEXT","useMenuGroupContext","reportMissingContext","componentName","MenuGroup","rest","generatedId","header","flattenChildren","children","isElementOfType","node","MenuGroupHeader","headerProps","headerId","ownName","labelled","labelledBy","context","props","group","scanned","problem","warnOnce","id","
|
|
1
|
+
{"version":3,"file":"Menu.group.mjs","names":["useId","useId$1","React","MenuGroupContext","INERT_GROUP_CONTEXT","useMenuGroupContext","reportMissingContext","componentName","MenuGroup","rest","generatedId","header","flattenChildren","children","isElementOfType","node","MenuGroupHeader","headerProps","headerId","ownName","labelled","labelledBy","context","cn","menuGroupClassNames","className","props","group","scanned","problem","warnOnce","id","menuGroupHeaderClassNames","MenuColumnSpacers"],"sources":["../../../src/components/navigation/Menu.group.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuGroupClassNames, menuGroupHeaderClassNames } from '../../lib/classNames';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { reportMissingContext, warnOnce } from '../../lib/dev';\nimport { useId } from '../../hooks/useId';\nimport { MenuColumnSpacers } from './Menu.items';\n\n/** Properties for the MenuGroup sub-component. */\nexport interface MenuGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the `role=\"group\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the MenuGroupHeader sub-component. */\nexport interface MenuGroupHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the header element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\ninterface MenuGroupContextValue {\n /** The id the group's header renders (its own `id`, else a generated one). */\n headerId: string;\n /**\n * The props object of the header the group's scan found (the first one among its direct\n * children or Fragments), or `undefined`. React renders an element with that same object, so\n * the header whose props are these is the scanned one: only it renders `headerId`.\n */\n headerProps: MenuGroupHeaderProps | undefined;\n /**\n * Whether the group has a name: a header among its direct children (or Fragments), or the\n * consumer's `aria-label`/`aria-labelledby`. A header the scan did not find, in a group whose\n * scan found none, warns only without.\n */\n labelled: boolean;\n}\n\nconst MenuGroupContext = React.createContext<MenuGroupContextValue | null>(null);\nMenuGroupContext.displayName = 'MenuGroupContext';\n\n/** What a misplaced header renders with in production (C-CONTEXT): its own id only, no warning. */\nconst INERT_GROUP_CONTEXT: MenuGroupContextValue = {\n headerId: '',\n headerProps: undefined,\n labelled: true,\n};\n\n/** C-CONTEXT: throws in development, logs once and returns an inert value in production. */\nfunction useMenuGroupContext(componentName: string): MenuGroupContextValue {\n const context = React.useContext(MenuGroupContext);\n if (context) return context;\n reportMissingContext(componentName, 'Menu.Group');\n return INERT_GROUP_CONTEXT;\n}\n\n/**\n * A labelled group of menu items (`role=\"group\"`), for example the radio items of one choice.\n * Labelled by its `Menu.GroupHeader` when the header is a direct child (or inside a Fragment; a\n * header written in a Server Component counts too); a header nested deeper does not label it\n * (development warning). Pass `aria-label` for a group without a visible header; a consumer\n * `aria-label` or `aria-labelledby` wins over the header (one that holds `undefined` does not).\n * Give a group one header: only the first header among its direct children labels it, and any\n * other header renders only its own `id` (development warning). The group changes nothing about\n * the keyboard: its items stay items of the menu. Separate groups with `Menu.Divider`.\n *\n * Also exported as `MenuGroup` (import the flat name from React Server Components).\n */\nexport const MenuGroup = ({ children, className, ref, ...rest }: MenuGroupProps) => {\n const generatedId = useId('menu-group-header');\n // A static scan, so the reference is in the server HTML and never points at a missing id.\n const header = flattenChildren(children).find(({ node }) =>\n isElementOfType<MenuGroupHeaderProps>(node, MenuGroupHeader),\n )?.node as React.ReactElement<MenuGroupHeaderProps> | undefined;\n const headerProps = header?.props;\n const headerId = headerProps?.id || generatedId;\n // A prop that holds `undefined` (a wrapper forwarding it) is no name of the consumer's.\n const ownName = rest['aria-label'] !== undefined || rest['aria-labelledby'] !== undefined;\n const labelled = header !== undefined || ownName;\n // Written after the spread, so a forwarded `aria-labelledby={undefined}` cannot remove it.\n const labelledBy = ownName\n ? rest['aria-labelledby']\n : header !== undefined\n ? headerId\n : undefined;\n\n const context = React.useMemo<MenuGroupContextValue>(\n () => ({ headerId, headerProps, labelled }),\n [headerId, headerProps, labelled],\n );\n\n return (\n <MenuGroupContext.Provider value={context}>\n <div\n role=\"group\"\n {...rest}\n ref={ref}\n aria-labelledby={labelledBy}\n className={cn(menuGroupClassNames.root, className)}\n >\n {children}\n </div>\n </MenuGroupContext.Provider>\n );\n};\nMenuGroup.displayName = 'MenuGroup';\n\n/**\n * The visible heading of a `Menu.Group`. It is not a menu item: arrow keys and typeahead skip it.\n * Its text lines up with the item labels (it keeps the menu's check and icon columns). It labels\n * the group when it is the group's first header among its direct children (or inside a Fragment\n * there); any other header labels nothing and renders only its own `id` (development warning).\n * Must be used inside `Menu.Group`.\n *\n * Also exported as `MenuGroupHeader` (import the flat name from React Server Components).\n */\nexport const MenuGroupHeader = (props: MenuGroupHeaderProps) => {\n const { id, className, children, ref, ...rest } = props;\n const group = useMenuGroupContext('Menu.GroupHeader');\n\n // The header the group's scan found is the one rendered with the scanned element's props object.\n // Only it renders the id the group points at: any other header (inside a custom component or an\n // element, or a second one) keeps only its own id, so no two headers share one. This relies on\n // React passing an element's own props object to its component (the client, Fizz, a lazy client\n // reference and `Children.toArray` clones all do in React 19, though React does not document it).\n // If a React upgrade breaks it, the scanned header loses its id: Menu.group.test.tsx's \"the header\n // its scan found keeps labelling the group in StrictMode, after a re-render and as a Server\n // Component reference\" and the server-HTML dangling-reference test fail.\n const scanned = group.headerProps === props;\n // C-DEV: any other header labels nothing and warns, except in a group that has no header its\n // scan found and is named by the consumer's label (that label is the unlabelled warning's remedy).\n let problem: 'unlabelled' | 'extra-header' | null = null;\n if (!scanned && group.headerProps !== undefined) problem = 'extra-header';\n else if (!scanned && !group.labelled) problem = 'unlabelled';\n React.useEffect(() => {\n if (problem === 'unlabelled') {\n warnOnce(\n 'Menu.GroupHeader:unlabelled',\n 'Menu.GroupHeader: this header is not a direct child of Menu.Group (or of a Fragment in it), so it does not label the group. Make it a direct child, or pass aria-label to Menu.Group.',\n );\n } else if (problem === 'extra-header') {\n warnOnce(\n 'Menu.GroupHeader:extra-header',\n 'Menu.GroupHeader: this Menu.Group already has a header (its first direct child header), so this one does not label the group. Give a group one header, or put this one in a Menu.Group of its own.',\n );\n }\n }, [problem]);\n\n return (\n <div\n {...rest}\n ref={ref}\n id={(scanned ? group.headerId : id) || undefined}\n className={cn(\n menuGroupHeaderClassNames.root,\n 'flex items-center gap-2 px-3 pb-1 pt-2 text-caption-1 font-semibold text-muted-foreground',\n className,\n )}\n >\n <MenuColumnSpacers />\n {children}\n </div>\n );\n};\nMenuGroupHeader.displayName = 'MenuGroupHeader';\n"],"mappings":";;;;;;;;;;AAqCA,IAAMG,IAAmBD,EAAM,cAA4C,IAAI;AAC/E,EAAiB,cAAc;AAG/B,IAAME,IAA6C;CACjD,UAAU;CACV,aAAa,KAAA;CACb,UAAU;AACZ;AAGA,SAASC,EAAoB,GAA8C;CAIzE,OAHgBH,EAAM,WAAWC,CAC7B,MACJG,EAAqBC,GAAe,YAAY,GACzCH;AACT;AAcA,IAAaI,KAAa,EAAE,aAAU,cAAW,QAAK,GAAGC,QAA2B;CAClF,IAAMC,IAAcV,EAAM,mBAAmB,GAEvCW,IAASC,EAAgBC,CAAQ,CAAC,CAAC,MAAM,EAAE,cAC/CC,EAAsCC,GAAMC,CAAe,CAC7D,CAAC,EAAE,MACGC,IAAcN,GAAQ,OACtBO,IAAWD,GAAa,MAAMP,GAE9BS,IAAUV,EAAK,kBAAkB,KAAA,KAAaA,EAAK,uBAAuB,KAAA,GAC1EW,IAAWT,MAAW,KAAA,KAAaQ,GAEnCE,IAAaF,IACfV,EAAK,qBACLE,MAAW,KAAA,IAET,KAAA,IADAO,GAGAI,IAAUpB,EAAM,eACb;EAAE;EAAU;EAAa;CAAS,IACzC;EAACgB;EAAUD;EAAaG;CAAQ,CAClC;CAEA,OACE,kBAACjB,EAAiB,UAAlB;EAA2B,OAAOmB;EAChC,UAAA,kBAAC,OAAD;GACE,MAAK;GACL,GAAIb;GACC;GACL,mBAAiBY;GACjB,WAAWE,EAAGC,EAAoB,MAAMC,CAAS;GAEhD;EACE,CAAA;CACoB,CAAA;AAE/B;AACA,EAAU,cAAc;AAWxB,IAAaT,KAAmB,MAAgC;CAC9D,IAAM,EAAE,OAAI,cAAW,aAAU,QAAK,GAAGP,MAASiB,GAC5CC,IAAQtB,EAAoB,kBAAkB,GAU9CuB,IAAUD,EAAM,gBAAgBD,GAGlCG,IAAgD;CAiBpD,OAhBI,CAACD,KAAWD,EAAM,gBAAgB,KAAA,IAAW,IAAU,iBAClD,CAACC,KAAW,CAACD,EAAM,aAAU,IAAU,eAChDzB,EAAM,gBAAgB;EACpB,AAAI2B,MAAY,eACdC,EACE,+BACA,uLACF,IACSD,MAAY,kBACrBC,EACE,iCACA,oMACF;CAEJ,GAAG,CAACD,CAAO,CAAC,GAGV,kBAAC,OAAD;EACE,GAAIpB;EACC;EACL,KAAKmB,IAAUD,EAAM,WAAWI,MAAO,KAAA;EACvC,WAAWR,EACTS,EAA0B,MAC1B,6FACAP,CACF;EARF,UAAA,CAUE,kBAACQ,GAAD,CAAoB,CAAA,GACnBpB,CACE;;AAET;AACA,EAAgB,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../lib/icons.cjs"),o=require("../../lib/events.cjs"),s=require("./Menu.context.cjs"),c=require("./Menu.shared.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("react/jsx-runtime");function d(e){return e===`checkmark`?(0,u.jsx)(`span`,{"aria-hidden":`true`,"data-menu-column-space":`checkmark`,className:`hidden w-4 shrink-0 group-has-[[data-menu-checkmark]]/menu:inline-flex`}):(0,u.jsx)(`span`,{"aria-hidden":`true`,"data-menu-column-space":`icon`,className:`hidden h-5 w-5 shrink-0 group-has-[[data-menu-icon]]/menu:inline-flex`})}function f({checkmark:e,icon:n,label:i,shortcut:a,end:o,markLabel:s=!0,partClassNames:c}){let l=r.slotRendersContent(i),f=n&&r.slotRendersContent(n)?r.renderSlot(n,`span`,t.cn(c?.icon,`flex h-5 w-5 shrink-0 items-center justify-center`),{"aria-hidden":!0,"data-menu-icon":``}):null;return(0,u.jsxs)(u.Fragment,{children:[e===void 0?l&&d(`checkmark`):(0,u.jsx)(`span`,{"aria-hidden":`true`,"data-menu-checkmark":``,className:t.cn(c?.checkmark,`inline-flex w-4 shrink-0 items-center justify-center`),children:e}),f??(l&&d(`icon`)),(0,u.jsx)(`span`,{className:t.cn(c?.content,`flex-1`),"data-menu-label":s&&l&&typeof i!=`string`?``:void 0,children:r.materialiseSlotContent(i)}),a&&(0,u.jsx)(`span`,{dir:`auto`,className:t.cn(c?.shortcut,`ms-4 text-caption-1 text-muted-foreground`),children:a}),o]})}f.displayName=`MenuItemRow`;function p(){return(0,u.jsxs)(u.Fragment,{children:[d(`checkmark`),d(`icon`)]})}p.displayName=`MenuColumnSpacers`;function m({disabled:e,persistOnClick:t,onClick:n,onKeyDown:r,onActivate:i,keepOpenOnSpace:a=!1,nativeEnter:c=!1,hasSubmenu:u=!1}){let d=s.useMenuListContext(),f=l.useRef(!1);return{onClick:r=>{let s=o.isOwnEvent(r);if(e){s&&r.preventDefault();return}n?.(r),s&&!r.defaultPrevented&&(i?.(r),!(r.defaultPrevented||u)&&(a&&f.current||(t??d?.menu.persistOnItemClick??!1)||d?.closeFromItem()))},onKeyDown:t=>{if(r?.(t),!t.defaultPrevented&&o.isOwnEvent(t)&&(t.key===`Enter`||t.key===` `)&&!(t.key===`Enter`&&c)&&!(t.ctrlKey||t.altKey||t.metaKey)&&(t.preventDefault(),!e)){f.current=t.key===` `;try{t.currentTarget.click()}finally{f.current=!1}}}}}function h(e){let t=s.useMenuListContext(),r=s.useOptionalMenuContext(),i=r!==null&&r.popup&&t===null;l.useEffect(()=>{i&&n.warnOnce(`Menu:item-outside-popover`,`${e}: rendered in a popup menu outside Menu.Popover, so it has no \`role="menu"\` parent. A Menu with \`open\`, \`defaultOpen\` or \`onOpenChange\` is a popup menu that renders no element of its own: put the items in Menu.Popover, or leave these props out for a static menu.`)},[i,e])}var g=({icon:e,shortcut:n,disabled:r=!1,persistOnClick:o,onClick:d,onKeyDown:p,children:g,className:_,ref:v,...y})=>{let b=l.useContext(s.MenuSubmenuTriggerContext);h(`Menu.Item`);let x=typeof g==`string`?g:void 0,S=y[`data-roving-text`]!==void 0,C=m({disabled:r,persistOnClick:o,onClick:d,onKeyDown:p,hasSubmenu:b});return(0,u.jsx)(`div`,{role:`menuitem`,"data-roving-text":x,...y,ref:v,"aria-disabled":r?!0:y[`aria-disabled`],"data-disabled":r?``:void 0,"data-has-submenu":b?``:void 0,onClick:C.onClick,onKeyDown:C.onKeyDown,className:t.cn(i.menuItemClassNames.root,c.menuItemClasses,_),children:(0,u.jsx)(f,{icon:e,label:g,shortcut:n,markLabel:!S,partClassNames:{icon:i.menuItemClassNames.icon,content:i.menuItemClassNames.content,shortcut:i.menuItemClassNames.shortcut},end:b?(0,u.jsx)(a.ChevronRightIcon,{size:16,className:t.cn(i.menuItemClassNames.submenuIndicator,`ms-auto shrink-0 wave-rtl:-scale-x-100`)}):void 0})})};g.displayName=`MenuItem`;var _=({className:e,ref:n,...r})=>(0,u.jsx)(`div`,{role:`separator`,...r,ref:n,className:t.cn(i.menuDividerClassNames.root,`my-1 border-t border-border`,e)});_.displayName=`MenuDivider`,exports.MenuColumnSpacers=p,exports.MenuDivider=_,exports.MenuItem=g,exports.MenuItemRow=f,exports.useMenuItemActivation=m,exports.useMenuItemPlacementWarning=h;
|
|
2
2
|
//# sourceMappingURL=Menu.items.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.items.cjs","names":["slotRendersContent","renderSlot","_Fragment","materialiseSlotContent","useMenuListContext","React","isOwnEvent","useOptionalMenuContext","MenuSubmenuTriggerContext","cn","menuItemClasses","ChevronRightIcon","require_runtime","require_cn","require_dev","require_slot","require_icons","require_events","require_Menu_context","require_Menu_shared","react","react_jsx_runtime","renderColumnSpace","column","MenuItemRow","hasLabel","label","iconNode","icon","checkmark","markLabel","shortcut","end","MenuColumnSpacers","useMenuItemActivation","list","clickFromSpaceRef","own","event","disabled","onClick","onActivate","hasSubmenu","keepOpenOnSpace","persistOnClick","onKeyDown","nativeEnter","useMenuItemPlacementWarning","menu","outsidePopover","componentName","MenuItem","rest","isSubmenuTrigger","stringLabel","children","ownRovingText","activation","className","MenuDivider"],"sources":["../../../src/components/navigation/Menu.items.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport type { Slot } from '../../lib/types';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport { warnOnce } from '../../lib/dev';\nimport { isOwnEvent } from '../../lib/events';\nimport { ChevronRightIcon } from '../../lib/icons';\nimport {\n MenuSubmenuTriggerContext,\n useMenuListContext,\n useOptionalMenuContext,\n} from './Menu.context';\nimport { menuItemClasses } from './Menu.shared';\n\n/** Properties for the MenuItem sub-component. */\nexport interface MenuItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Slot for an icon displayed before the item text. Rendered with `aria-hidden=\"true\"`. A falsy\n * icon (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Keyboard shortcut text displayed at the end of the item. Its direction comes from its own text\n * (`dir=\"auto\"`), so \"Ctrl+,\" keeps its order in an RTL menu.\n */\n shortcut?: string;\n /** Whether the menu item is disabled (`aria-disabled`; skipped by keyboard navigation). */\n disabled?: boolean;\n /**\n * Keep a popup menu open after this item is activated. `true` or `false` here wins over the\n * Menu's `persistOnItemClick`.\n * @default the Menu's `persistOnItemClick` (`false`)\n */\n persistOnClick?: boolean;\n /**\n * Label content of the menu item. Leave it out only for the submenu half of a\n * `Menu.SplitGroup`, which then needs `aria-label`.\n */\n children?: React.ReactNode;\n /**\n * Ref to the item element (`role=\"menuitem\"`; `menuitemcheckbox` or `menuitemradio` for the\n * checkable items).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the MenuDivider sub-component. */\nexport interface MenuDividerProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the `role=\"separator\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ---------------------------------------------------------------------------\n// The item row and the column alignment\n// ---------------------------------------------------------------------------\n\n/** Internal: the content of one menu item row, rendered inside the item element. */\nexport interface MenuItemRowProps {\n /**\n * Checkable items: the checkmark column's content (the glyph, or `null` while unchecked); the\n * column renders in both states, marked `data-menu-checkmark`. `undefined` for other items,\n * which render a hidden placeholder instead.\n */\n checkmark?: React.ReactNode | null;\n /** The icon slot (a falsy icon or a list of nothing is no icon). */\n icon?: Slot<'span'>;\n /** The label (typeahead reads a non-string label through its `data-menu-label` element). */\n label: React.ReactNode;\n /** The shortcut text (rendered with `dir=\"auto\"`). */\n shortcut?: string;\n /** Content at the row's end: the submenu chevron or a switch. */\n end?: React.ReactNode;\n /**\n * Whether a non-string label is marked `data-menu-label` for typeahead. Pass `false` when the\n * item carries its own `data-roving-text`, which the label's text must not replace.\n * @default true\n */\n markLabel?: boolean;\n}\n\n/**\n * The placeholder of the checkmark or the icon column: hidden, and shown as soon as any item of\n * the same menu list (the `group/menu` element) renders that column, so every label starts at the\n * same place. Decorative (`aria-hidden`).\n */\nfunction renderColumnSpace(column: 'checkmark' | 'icon'): React.ReactElement {\n return column === 'checkmark' ? (\n <span\n aria-hidden=\"true\"\n data-menu-column-space=\"checkmark\"\n className=\"hidden w-4 shrink-0 group-has-[[data-menu-checkmark]]/menu:inline-flex\"\n />\n ) : (\n <span\n aria-hidden=\"true\"\n data-menu-column-space=\"icon\"\n className=\"hidden h-5 w-5 shrink-0 group-has-[[data-menu-icon]]/menu:inline-flex\"\n />\n );\n}\n\n/**\n * Internal: one menu item row, in DOM order (RTL mirrors it): the checkmark column, the icon\n * column, the label, the shortcut and the end content. A row without a checkmark or an icon\n * renders the column's placeholder instead; a row whose label renders nothing (the icon-only\n * submenu half of a split group) renders no placeholders.\n */\nexport function MenuItemRow({\n checkmark,\n icon,\n label,\n shortcut,\n end,\n markLabel = true,\n}: MenuItemRowProps): React.ReactElement {\n // The check does not consume a one-shot iterable label: it is rendered materialised.\n const hasLabel = slotRendersContent(label);\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in Nav,\n // Tree and Avatar, and so is a collection whose items render nothing: no empty 20px box before\n // the label. The check does not consume a generator: renderSlot still renders its items.\n const iconNode =\n icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', 'flex h-5 w-5 shrink-0 items-center justify-center', {\n 'aria-hidden': true,\n 'data-menu-icon': '',\n })\n : null;\n\n return (\n <>\n {checkmark !== undefined ? (\n <span\n aria-hidden=\"true\"\n data-menu-checkmark=\"\"\n className=\"inline-flex w-4 shrink-0 items-center justify-center\"\n >\n {checkmark}\n </span>\n ) : (\n hasLabel && renderColumnSpace('checkmark')\n )}\n {iconNode ?? (hasLabel && renderColumnSpace('icon'))}\n <span\n className=\"flex-1\"\n data-menu-label={markLabel && hasLabel && typeof label !== 'string' ? '' : undefined}\n >\n {materialiseSlotContent(label)}\n </span>\n {/* The shortcut takes its direction from its own text (`dir=\"auto\"` also isolates it): in an\n RTL menu, \"Ctrl+,\" would otherwise be reordered to \",+Ctrl\". */}\n {shortcut && (\n <span dir=\"auto\" className=\"ms-4 text-caption-1 text-muted-foreground\">\n {shortcut}\n </span>\n )}\n {end}\n </>\n );\n}\nMenuItemRow.displayName = 'MenuItemRow';\n\n/** Internal: the two column placeholders alone, for a row that is not an item (a group header). */\nexport function MenuColumnSpacers(): React.ReactElement {\n return (\n <>\n {renderColumnSpace('checkmark')}\n {renderColumnSpace('icon')}\n </>\n );\n}\nMenuColumnSpacers.displayName = 'MenuColumnSpacers';\n\n// ---------------------------------------------------------------------------\n// Item activation\n// ---------------------------------------------------------------------------\n\n/** Internal: the activation of every menu item kind. */\nexport interface MenuItemActivationOptions {\n disabled: boolean;\n /**\n * The item's own `persistOnClick`; `undefined` falls back to the Menu's `persistOnItemClick`.\n * A link item passes `false` (a link always closes).\n */\n persistOnClick: boolean | undefined;\n /** The consumer's handlers, composed consumer first (C-COMPOSE). */\n onClick?: React.MouseEventHandler<HTMLElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLElement>;\n /**\n * Runs on an own, enabled click after the consumer's `onClick`, unless it prevented the default.\n * Its own `preventDefault()` keeps the menu open.\n */\n onActivate?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Space activates and keeps the menu open (checkbox, radio and switch items). */\n keepOpenOnSpace?: boolean;\n /** Enter is left to the element's native activation (links); Space still clicks. */\n nativeEnter?: boolean;\n /** The item opens a submenu: activation never closes its menu. */\n hasSubmenu?: boolean;\n}\n\n/**\n * Internal: the click and key handlers of a menu item.\n *\n * - Events from a portal opened inside the item (a Popover, a Dialog) reach the consumer's\n * handlers, as React bubbles them, but never activate the item or close the menu.\n * - A disabled item calls no `onClick` and prevents its own click; its Enter and Space are still\n * consumed.\n * - Enter and Space are consumed (no page scroll) and click the item; with Ctrl, Alt or Meta they\n * are left to the page. A Space that continues a typeahead search is skipped (the roving\n * capture handler prevented it). With `nativeEnter`, Enter is left to the element.\n * - After the consumer's `onClick` and `onActivate`, the item closes its menu through the list's\n * `closeFromItem`, unless the click was not its own, its default was prevented, `hasSubmenu` is\n * set, `keepOpenOnSpace` is set and Space caused the click, or\n * `persistOnClick ?? menu.persistOnItemClick` is `true`.\n */\nexport function useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n onActivate,\n keepOpenOnSpace = false,\n nativeEnter = false,\n hasSubmenu = false,\n}: MenuItemActivationOptions): {\n onClick: React.MouseEventHandler<HTMLElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n} {\n const list = useMenuListContext();\n // Set while the key handler's click runs, so the click knows that Space caused it.\n const clickFromSpaceRef = React.useRef(false);\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n // A click inside a portal opened from the item reaches the consumer's onClick (React bubbles\n // it), but is not a click on the item: it never activates the item or closes the menu. A\n // disabled item calls no onClick, as a disabled button; a portal's click keeps its default.\n const own = isOwnEvent(event);\n if (disabled) {\n if (own) event.preventDefault();\n return;\n }\n onClick?.(event);\n if (!own || event.defaultPrevented) return;\n onActivate?.(event);\n if (event.defaultPrevented || hasSubmenu) return;\n if (keepOpenOnSpace && clickFromSpaceRef.current) return;\n if (persistOnClick ?? list?.menu.persistOnItemClick ?? false) return;\n list?.closeFromItem();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n // C-COMPOSE: the consumer's onKeyDown runs first; preventDefault() skips the built-in keys.\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n // Enter and Space typed in a portal opened from the item belong to that portal.\n if (!isOwnEvent(event)) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n // A link follows itself on Enter (Shift, Ctrl and Meta keep opening a new window or tab).\n if (event.key === 'Enter' && nativeEnter) return;\n // With Ctrl, Alt or Meta (Ctrl+Alt+Space included) the key is a shortcut, left to the page.\n if (event.ctrlKey || event.altKey || event.metaKey) return;\n // Menu items consume Enter/Space (no page scroll), whether or not they can be activated.\n event.preventDefault();\n if (disabled) return;\n clickFromSpaceRef.current = event.key === ' ';\n try {\n event.currentTarget.click();\n } finally {\n clickFromSpaceRef.current = false;\n }\n };\n\n return { onClick: handleClick, onKeyDown: handleKeyDown };\n}\n\n/**\n * Internal (C-DEV): warns once, from an effect, when an item of any kind renders in a popup menu\n * outside `Menu.Popover`. A Menu with `open`, `defaultOpen` or `onOpenChange` is a popup menu that\n * renders no element of its own, so such an item has no `role=\"menu\"` parent.\n *\n * @param componentName The item's name in the message, e.g. `'Menu.ItemCheckbox'`.\n */\nexport function useMenuItemPlacementWarning(componentName: string): void {\n const list = useMenuListContext();\n const menu = useOptionalMenuContext();\n const outsidePopover = menu !== null && menu.popup && list === null;\n React.useEffect(() => {\n if (!outsidePopover) return;\n warnOnce(\n 'Menu:item-outside-popover',\n `${componentName}: rendered in a popup menu outside Menu.Popover, so it has no \\`role=\"menu\"\\` parent. A Menu with \\`open\\`, \\`defaultOpen\\` or \\`onOpenChange\\` is a popup menu that renders no element of its own: put the items in Menu.Popover, or leave these props out for a static menu.`,\n );\n }, [outsidePopover, componentName]);\n}\n\n// ---------------------------------------------------------------------------\n// Menu.Item / Menu.Divider\n// ---------------------------------------------------------------------------\n\n/**\n * An action in a menu (`role=\"menuitem\"`). Enter and Space activate it (a Space typed within 500 ms\n * of a typeahead character continues the search instead; with Ctrl, Alt or Meta they are left to\n * the page); in a popup menu, activation closes the menu and returns focus to the trigger unless\n * `persistOnClick` (or the Menu's `persistOnItemClick`) keeps it open or the consumer's `onClick`\n * calls `preventDefault()`. Disabled items are `aria-disabled`, skipped by keyboard navigation and\n * never activated: their `onClick` is not called. A consumer `aria-disabled` without `disabled`\n * only changes the look and keyboard navigation: activation still runs `onClick` (guard it\n * yourself), as on Button. The item's tab index is managed by the menu. Typeahead matches the\n * label (`children`), not the icon or the shortcut; a `data-roving-text` you pass replaces the\n * label's text. Clicks and keys from a portal opened inside the item (a Popover, a Dialog) still\n * reach your `onClick` (on an enabled item) and `onKeyDown`, as React bubbles them, but never\n * activate the item or close the menu.\n *\n * The labels of a menu line up: when any item of the menu shows an icon (or a check), every item\n * keeps an empty column of that width before its label.\n *\n * As the child of a submenu's `Menu.Trigger` (a `Menu` nested in a menu list), the item is the\n * submenu's trigger: it shows a chevron at its end (mirrored in RTL) and `data-has-submenu`, and\n * activating it never closes its own menu. ArrowRight (ArrowLeft in RTL), Enter, Space and a click\n * open the submenu and move focus to its first item; resting the mouse on the item opens it\n * without moving focus.\n *\n * Also exported as `MenuItem` (import the flat name from React Server Components).\n */\nexport const MenuItem = ({\n icon,\n shortcut,\n disabled = false,\n persistOnClick,\n onClick,\n onKeyDown,\n children,\n className,\n ref,\n ...rest\n}: MenuItemProps) => {\n const isSubmenuTrigger = React.useContext(MenuSubmenuTriggerContext);\n useMenuItemPlacementWarning('Menu.Item');\n\n // Typeahead text: a string label directly; any other label through its marked element.\n const stringLabel = typeof children === 'string' ? children : undefined;\n const ownRovingText = (rest as Record<string, unknown>)['data-roving-text'] !== undefined;\n\n // A submenu trigger item opens its submenu (the trigger's composed onClick): activating it never\n // closes its own menu.\n const activation = useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n hasSubmenu: isSubmenuTrigger,\n });\n\n return (\n <div\n role=\"menuitem\"\n data-roving-text={stringLabel}\n {...rest}\n ref={ref}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n data-disabled={disabled ? '' : undefined}\n data-has-submenu={isSubmenuTrigger ? '' : undefined}\n onClick={activation.onClick}\n onKeyDown={activation.onKeyDown}\n className={cn(menuItemClasses, className)}\n >\n <MenuItemRow\n icon={icon}\n label={children}\n shortcut={shortcut}\n markLabel={!ownRovingText}\n end={\n isSubmenuTrigger ? (\n <ChevronRightIcon size={16} className=\"ms-auto shrink-0 wave-rtl:-scale-x-100\" />\n ) : undefined\n }\n />\n </div>\n );\n};\nMenuItem.displayName = 'MenuItem';\n\n/**\n * A separator between groups of menu items (`role=\"separator\"`).\n *\n * Also exported as `MenuDivider` (import the flat name from React Server Components).\n */\nexport const MenuDivider = ({ className, ref, ...rest }: MenuDividerProps) => {\n return (\n <div\n role=\"separator\"\n {...rest}\n ref={ref}\n className={cn('my-1 border-t border-border', className)}\n />\n );\n};\nMenuDivider.displayName = 'MenuDivider';\n"],"mappings":"+WAqFA,SAASsB,EAAkB,EAAkD,CAC3E,OAAOC,IAAW,aAChB,EAAAF,EAAA,IAAA,CAAC,OAAD,CACE,cAAY,OACZ,yBAAuB,YACvB,UAAU,wEACX,CAAA,GAED,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,cAAY,OACZ,yBAAuB,OACvB,UAAU,uEACX,CAAA,CAEL,CAQA,SAAgBG,EAAY,CAC1B,YACA,OACA,QACA,WACA,MACA,YAAY,IAC2B,CAEvC,IAAMC,EAAWzB,EAAAA,mBAAmB0B,CAAK,EAInCC,EACJC,GAAQ5B,E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QACpB,UAAWA,EAAW,UACtB,UAAWhD,EAAAA,GAAGC,EAAAA,gBAAiBgD,CAAS,EAExC,UAAA,EAAArC,EAAA,IAAA,CAACG,EAAD,CACQ,OACN,MAAO+B,EACG,WACV,UAAW,CAACC,EACZ,IACEH,GACE,EAAAhC,EAAA,IAAA,CAACV,EAAAA,iBAAD,CAAkB,KAAM,GAAI,UAAU,wCAA0C,CAAA,EAC9E,IAAA,EAEP,CAAA,CACE,CAAA,CAET,EACA,EAAS,YAAc,WAOvB,IAAagD,GAAe,CAAE,YAAW,MAAK,GAAGP,MAE7C,EAAA/B,EAAA,IAAA,CAAC,MAAD,CACE,KAAK,YACL,GAAI+B,EACC,MACL,UAAW3C,EAAAA,GAAG,8BAA+BiD,CAAS,CACvD,CAAA,EAGL,EAAY,YAAc"}
|
|
1
|
+
{"version":3,"file":"Menu.items.cjs","names":["slotRendersContent","renderSlot","cn","_Fragment","materialiseSlotContent","useMenuListContext","React","isOwnEvent","useOptionalMenuContext","MenuSubmenuTriggerContext","menuItemClassNames","menuItemClasses","ChevronRightIcon","menuDividerClassNames","require_runtime","require_cn","require_dev","require_slot","require_classNames","require_icons","require_events","require_Menu_context","require_Menu_shared","react","react_jsx_runtime","renderColumnSpace","column","MenuItemRow","hasLabel","label","iconNode","icon","partClassNames","checkmark","markLabel","shortcut","end","MenuColumnSpacers","useMenuItemActivation","list","clickFromSpaceRef","own","event","disabled","onClick","onActivate","hasSubmenu","keepOpenOnSpace","persistOnClick","onKeyDown","nativeEnter","useMenuItemPlacementWarning","menu","outsidePopover","componentName","MenuItem","rest","isSubmenuTrigger","stringLabel","children","ownRovingText","activation","className","MenuDivider"],"sources":["../../../src/components/navigation/Menu.items.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuDividerClassNames, menuItemClassNames } from '../../lib/classNames';\nimport type { Slot } from '../../lib/types';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport { warnOnce } from '../../lib/dev';\nimport { isOwnEvent } from '../../lib/events';\nimport { ChevronRightIcon } from '../../lib/icons';\nimport {\n MenuSubmenuTriggerContext,\n useMenuListContext,\n useOptionalMenuContext,\n} from './Menu.context';\nimport { menuItemClasses } from './Menu.shared';\n\n/** Properties for the MenuItem sub-component. */\nexport interface MenuItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Slot for an icon displayed before the item text. Rendered with `aria-hidden=\"true\"`. A falsy\n * icon (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Keyboard shortcut text displayed at the end of the item. Its direction comes from its own text\n * (`dir=\"auto\"`), so \"Ctrl+,\" keeps its order in an RTL menu.\n */\n shortcut?: string;\n /** Whether the menu item is disabled (`aria-disabled`; skipped by keyboard navigation). */\n disabled?: boolean;\n /**\n * Keep a popup menu open after this item is activated. `true` or `false` here wins over the\n * Menu's `persistOnItemClick`.\n * @default the Menu's `persistOnItemClick` (`false`)\n */\n persistOnClick?: boolean;\n /**\n * Label content of the menu item. Leave it out only for the submenu half of a\n * `Menu.SplitGroup`, which then needs `aria-label`.\n */\n children?: React.ReactNode;\n /**\n * Ref to the item element (`role=\"menuitem\"`; `menuitemcheckbox` or `menuitemradio` for the\n * checkable items).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the MenuDivider sub-component. */\nexport interface MenuDividerProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the `role=\"separator\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ---------------------------------------------------------------------------\n// The item row and the column alignment\n// ---------------------------------------------------------------------------\n\n/** Internal: the content of one menu item row, rendered inside the item element. */\nexport interface MenuItemRowProps {\n /**\n * Checkable items: the checkmark column's content (the glyph, or `null` while unchecked); the\n * column renders in both states, marked `data-menu-checkmark`. `undefined` for other items,\n * which render a hidden placeholder instead.\n */\n checkmark?: React.ReactNode | null;\n /** The icon slot (a falsy icon or a list of nothing is no icon). */\n icon?: Slot<'span'>;\n /** The label (typeahead reads a non-string label through its `data-menu-label` element). */\n label: React.ReactNode;\n /** The shortcut text (rendered with `dir=\"auto\"`). */\n shortcut?: string;\n /** Content at the row's end: the submenu chevron or a switch. */\n end?: React.ReactNode;\n /**\n * Whether a non-string label is marked `data-menu-label` for typeahead. Pass `false` when the\n * item carries its own `data-roving-text`, which the label's text must not replace.\n * @default true\n */\n markLabel?: boolean;\n /**\n * Stable classes of the row's parts, written literally by each item kind (the check column,\n * the icon box, the label and the shortcut).\n */\n partClassNames?: MenuItemRowPartClassNames;\n}\n\n/** Internal: the stable classes of an item row's parts (see `MenuItemRowProps.partClassNames`). */\nexport interface MenuItemRowPartClassNames {\n checkmark?: string;\n icon?: string;\n content?: string;\n shortcut?: string;\n}\n\n/**\n * The placeholder of the checkmark or the icon column: hidden, and shown as soon as any item of\n * the same menu list (the `group/menu` element) renders that column, so every label starts at the\n * same place. Decorative (`aria-hidden`).\n */\nfunction renderColumnSpace(column: 'checkmark' | 'icon'): React.ReactElement {\n return column === 'checkmark' ? (\n <span\n aria-hidden=\"true\"\n data-menu-column-space=\"checkmark\"\n className=\"hidden w-4 shrink-0 group-has-[[data-menu-checkmark]]/menu:inline-flex\"\n />\n ) : (\n <span\n aria-hidden=\"true\"\n data-menu-column-space=\"icon\"\n className=\"hidden h-5 w-5 shrink-0 group-has-[[data-menu-icon]]/menu:inline-flex\"\n />\n );\n}\n\n/**\n * Internal: one menu item row, in DOM order (RTL mirrors it): the checkmark column, the icon\n * column, the label, the shortcut and the end content. A row without a checkmark or an icon\n * renders the column's placeholder instead; a row whose label renders nothing (the icon-only\n * submenu half of a split group) renders no placeholders.\n */\nexport function MenuItemRow({\n checkmark,\n icon,\n label,\n shortcut,\n end,\n markLabel = true,\n partClassNames,\n}: MenuItemRowProps): React.ReactElement {\n // The check does not consume a one-shot iterable label: it is rendered materialised.\n const hasLabel = slotRendersContent(label);\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in Nav,\n // Tree and Avatar, and so is a collection whose items render nothing: no empty 20px box before\n // the label. The check does not consume a generator: renderSlot still renders its items.\n const iconNode =\n icon && slotRendersContent(icon)\n ? renderSlot(\n icon,\n 'span',\n cn(partClassNames?.icon, 'flex h-5 w-5 shrink-0 items-center justify-center'),\n { 'aria-hidden': true, 'data-menu-icon': '' },\n )\n : null;\n\n return (\n <>\n {checkmark !== undefined ? (\n <span\n aria-hidden=\"true\"\n data-menu-checkmark=\"\"\n className={cn(\n partClassNames?.checkmark,\n 'inline-flex w-4 shrink-0 items-center justify-center',\n )}\n >\n {checkmark}\n </span>\n ) : (\n hasLabel && renderColumnSpace('checkmark')\n )}\n {iconNode ?? (hasLabel && renderColumnSpace('icon'))}\n <span\n className={cn(partClassNames?.content, 'flex-1')}\n data-menu-label={markLabel && hasLabel && typeof label !== 'string' ? '' : undefined}\n >\n {materialiseSlotContent(label)}\n </span>\n {/* The shortcut takes its direction from its own text (`dir=\"auto\"` also isolates it): in an\n RTL menu, \"Ctrl+,\" would otherwise be reordered to \",+Ctrl\". */}\n {shortcut && (\n <span\n dir=\"auto\"\n className={cn(partClassNames?.shortcut, 'ms-4 text-caption-1 text-muted-foreground')}\n >\n {shortcut}\n </span>\n )}\n {end}\n </>\n );\n}\nMenuItemRow.displayName = 'MenuItemRow';\n\n/** Internal: the two column placeholders alone, for a row that is not an item (a group header). */\nexport function MenuColumnSpacers(): React.ReactElement {\n return (\n <>\n {renderColumnSpace('checkmark')}\n {renderColumnSpace('icon')}\n </>\n );\n}\nMenuColumnSpacers.displayName = 'MenuColumnSpacers';\n\n// ---------------------------------------------------------------------------\n// Item activation\n// ---------------------------------------------------------------------------\n\n/** Internal: the activation of every menu item kind. */\nexport interface MenuItemActivationOptions {\n disabled: boolean;\n /**\n * The item's own `persistOnClick`; `undefined` falls back to the Menu's `persistOnItemClick`.\n * A link item passes `false` (a link always closes).\n */\n persistOnClick: boolean | undefined;\n /** The consumer's handlers, composed consumer first (C-COMPOSE). */\n onClick?: React.MouseEventHandler<HTMLElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLElement>;\n /**\n * Runs on an own, enabled click after the consumer's `onClick`, unless it prevented the default.\n * Its own `preventDefault()` keeps the menu open.\n */\n onActivate?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Space activates and keeps the menu open (checkbox, radio and switch items). */\n keepOpenOnSpace?: boolean;\n /** Enter is left to the element's native activation (links); Space still clicks. */\n nativeEnter?: boolean;\n /** The item opens a submenu: activation never closes its menu. */\n hasSubmenu?: boolean;\n}\n\n/**\n * Internal: the click and key handlers of a menu item.\n *\n * - Events from a portal opened inside the item (a Popover, a Dialog) reach the consumer's\n * handlers, as React bubbles them, but never activate the item or close the menu.\n * - A disabled item calls no `onClick` and prevents its own click; its Enter and Space are still\n * consumed.\n * - Enter and Space are consumed (no page scroll) and click the item; with Ctrl, Alt or Meta they\n * are left to the page. A Space that continues a typeahead search is skipped (the roving\n * capture handler prevented it). With `nativeEnter`, Enter is left to the element.\n * - After the consumer's `onClick` and `onActivate`, the item closes its menu through the list's\n * `closeFromItem`, unless the click was not its own, its default was prevented, `hasSubmenu` is\n * set, `keepOpenOnSpace` is set and Space caused the click, or\n * `persistOnClick ?? menu.persistOnItemClick` is `true`.\n */\nexport function useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n onActivate,\n keepOpenOnSpace = false,\n nativeEnter = false,\n hasSubmenu = false,\n}: MenuItemActivationOptions): {\n onClick: React.MouseEventHandler<HTMLElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n} {\n const list = useMenuListContext();\n // Set while the key handler's click runs, so the click knows that Space caused it.\n const clickFromSpaceRef = React.useRef(false);\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n // A click inside a portal opened from the item reaches the consumer's onClick (React bubbles\n // it), but is not a click on the item: it never activates the item or closes the menu. A\n // disabled item calls no onClick, as a disabled button; a portal's click keeps its default.\n const own = isOwnEvent(event);\n if (disabled) {\n if (own) event.preventDefault();\n return;\n }\n onClick?.(event);\n if (!own || event.defaultPrevented) return;\n onActivate?.(event);\n if (event.defaultPrevented || hasSubmenu) return;\n if (keepOpenOnSpace && clickFromSpaceRef.current) return;\n if (persistOnClick ?? list?.menu.persistOnItemClick ?? false) return;\n list?.closeFromItem();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n // C-COMPOSE: the consumer's onKeyDown runs first; preventDefault() skips the built-in keys.\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n // Enter and Space typed in a portal opened from the item belong to that portal.\n if (!isOwnEvent(event)) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n // A link follows itself on Enter (Shift, Ctrl and Meta keep opening a new window or tab).\n if (event.key === 'Enter' && nativeEnter) return;\n // With Ctrl, Alt or Meta (Ctrl+Alt+Space included) the key is a shortcut, left to the page.\n if (event.ctrlKey || event.altKey || event.metaKey) return;\n // Menu items consume Enter/Space (no page scroll), whether or not they can be activated.\n event.preventDefault();\n if (disabled) return;\n clickFromSpaceRef.current = event.key === ' ';\n try {\n event.currentTarget.click();\n } finally {\n clickFromSpaceRef.current = false;\n }\n };\n\n return { onClick: handleClick, onKeyDown: handleKeyDown };\n}\n\n/**\n * Internal (C-DEV): warns once, from an effect, when an item of any kind renders in a popup menu\n * outside `Menu.Popover`. A Menu with `open`, `defaultOpen` or `onOpenChange` is a popup menu that\n * renders no element of its own, so such an item has no `role=\"menu\"` parent.\n *\n * @param componentName The item's name in the message, e.g. `'Menu.ItemCheckbox'`.\n */\nexport function useMenuItemPlacementWarning(componentName: string): void {\n const list = useMenuListContext();\n const menu = useOptionalMenuContext();\n const outsidePopover = menu !== null && menu.popup && list === null;\n React.useEffect(() => {\n if (!outsidePopover) return;\n warnOnce(\n 'Menu:item-outside-popover',\n `${componentName}: rendered in a popup menu outside Menu.Popover, so it has no \\`role=\"menu\"\\` parent. A Menu with \\`open\\`, \\`defaultOpen\\` or \\`onOpenChange\\` is a popup menu that renders no element of its own: put the items in Menu.Popover, or leave these props out for a static menu.`,\n );\n }, [outsidePopover, componentName]);\n}\n\n// ---------------------------------------------------------------------------\n// Menu.Item / Menu.Divider\n// ---------------------------------------------------------------------------\n\n/**\n * An action in a menu (`role=\"menuitem\"`). Enter and Space activate it (a Space typed within 500 ms\n * of a typeahead character continues the search instead; with Ctrl, Alt or Meta they are left to\n * the page); in a popup menu, activation closes the menu and returns focus to the trigger unless\n * `persistOnClick` (or the Menu's `persistOnItemClick`) keeps it open or the consumer's `onClick`\n * calls `preventDefault()`. Disabled items are `aria-disabled`, skipped by keyboard navigation and\n * never activated: their `onClick` is not called. A consumer `aria-disabled` without `disabled`\n * only changes the look and keyboard navigation: activation still runs `onClick` (guard it\n * yourself), as on Button. The item's tab index is managed by the menu. Typeahead matches the\n * label (`children`), not the icon or the shortcut; a `data-roving-text` you pass replaces the\n * label's text. Clicks and keys from a portal opened inside the item (a Popover, a Dialog) still\n * reach your `onClick` (on an enabled item) and `onKeyDown`, as React bubbles them, but never\n * activate the item or close the menu.\n *\n * The labels of a menu line up: when any item of the menu shows an icon (or a check), every item\n * keeps an empty column of that width before its label.\n *\n * As the child of a submenu's `Menu.Trigger` (a `Menu` nested in a menu list), the item is the\n * submenu's trigger: it shows a chevron at its end (mirrored in RTL) and `data-has-submenu`, and\n * activating it never closes its own menu. ArrowRight (ArrowLeft in RTL), Enter, Space and a click\n * open the submenu and move focus to its first item; resting the mouse on the item opens it\n * without moving focus.\n *\n * Also exported as `MenuItem` (import the flat name from React Server Components).\n */\nexport const MenuItem = ({\n icon,\n shortcut,\n disabled = false,\n persistOnClick,\n onClick,\n onKeyDown,\n children,\n className,\n ref,\n ...rest\n}: MenuItemProps) => {\n const isSubmenuTrigger = React.useContext(MenuSubmenuTriggerContext);\n useMenuItemPlacementWarning('Menu.Item');\n\n // Typeahead text: a string label directly; any other label through its marked element.\n const stringLabel = typeof children === 'string' ? children : undefined;\n const ownRovingText = (rest as Record<string, unknown>)['data-roving-text'] !== undefined;\n\n // A submenu trigger item opens its submenu (the trigger's composed onClick): activating it never\n // closes its own menu.\n const activation = useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n hasSubmenu: isSubmenuTrigger,\n });\n\n return (\n <div\n role=\"menuitem\"\n data-roving-text={stringLabel}\n {...rest}\n ref={ref}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n data-disabled={disabled ? '' : undefined}\n data-has-submenu={isSubmenuTrigger ? '' : undefined}\n onClick={activation.onClick}\n onKeyDown={activation.onKeyDown}\n className={cn(menuItemClassNames.root, menuItemClasses, className)}\n >\n <MenuItemRow\n icon={icon}\n label={children}\n shortcut={shortcut}\n markLabel={!ownRovingText}\n partClassNames={{\n icon: menuItemClassNames.icon,\n content: menuItemClassNames.content,\n shortcut: menuItemClassNames.shortcut,\n }}\n end={\n isSubmenuTrigger ? (\n <ChevronRightIcon\n size={16}\n className={cn(\n menuItemClassNames.submenuIndicator,\n 'ms-auto shrink-0 wave-rtl:-scale-x-100',\n )}\n />\n ) : undefined\n }\n />\n </div>\n );\n};\nMenuItem.displayName = 'MenuItem';\n\n/**\n * A separator between groups of menu items (`role=\"separator\"`).\n *\n * Also exported as `MenuDivider` (import the flat name from React Server Components).\n */\nexport const MenuDivider = ({ className, ref, ...rest }: MenuDividerProps) => {\n return (\n <div\n role=\"separator\"\n {...rest}\n ref={ref}\n className={cn(menuDividerClassNames.root, 'my-1 border-t border-border', className)}\n />\n );\n};\nMenuDivider.displayName = 'MenuDivider';\n"],"mappings":"qZAmGA,SAASyB,EAAkB,EAAkD,CAC3E,OAAOC,IAAW,aAChB,EAAAF,EAAA,IAAA,CAAC,OAAD,CACE,cAAY,OACZ,yBAAuB,YACvB,UAAU,wEACX,CAAA,GAED,EAAAA,EAAA,IAAA,CAAC,OAAD,CACE,cAAY,OACZ,yBAAuB,OACvB,UAAU,uEACX,CAAA,CAEL,CAQA,SAAgBG,EAAY,CAC1B,YACA,OACA,QACA,WACA,MACA,YAAY,GACZ,k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mB,CACd,CAAC,EAED,OACE,EAAAjC,EAAA,IAAA,CAAC,MAAD,CACE,KAAK,WACL,mBAAkBkC,EAClB,GAAIF,EACC,MACL,gBAAeb,EAAW,GAAOa,EAAK,iBACtC,gBAAeb,EAAW,GAAK,IAAA,GAC/B,mBAAkBc,EAAmB,GAAK,IAAA,GAC1C,QAASI,EAAW,QACpB,UAAWA,EAAW,UACtB,UAAW3D,EAAAA,GAAGQ,EAAAA,mBAAmB,KAAMC,EAAAA,gBAAiBmD,CAAS,EAEjE,UAAA,EAAAtC,EAAA,IAAA,CAACG,EAAD,CACQ,OACN,MAAOgC,EACG,WACV,UAAW,CAACC,EACZ,eAAgB,CACd,KAAMlD,EAAAA,mBAAmB,KACzB,QAASA,EAAAA,mBAAmB,QAC5B,SAAUA,EAAAA,mBAAmB,QAC/B,EACA,IACE+C,GACE,EAAAjC,EAAA,IAAA,CAACZ,EAAAA,iBAAD,CACE,KAAM,GACN,UAAWV,EAAAA,GACTQ,EAAAA,mBAAmB,iBACnB,wCACF,CACD,CAAA,EACC,IAAA,EAEP,CAAA,CACE,CAAA,CAET,EACA,EAAS,YAAc,WAOvB,IAAaqD,GAAe,CAAE,YAAW,MAAK,GAAGP,MAE7C,EAAAhC,EAAA,IAAA,CAAC,MAAD,CACE,KAAK,YACL,GAAIgC,EACC,MACL,UAAWtD,EAAAA,GAAGW,EAAAA,sBAAsB,KAAM,8BAA+BiD,CAAS,CACnF,CAAA,EAGL,EAAY,YAAc"}
|
|
@@ -2,126 +2,132 @@
|
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
3
|
import { warnOnce as t } from "../../lib/dev.mjs";
|
|
4
4
|
import { materialiseSlotContent as n, renderSlot as r, slotRendersContent as i } from "../../lib/slot.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
5
|
+
import { menuDividerClassNames as a, menuItemClassNames as o } from "../../lib/classNames.mjs";
|
|
6
|
+
import { ChevronRightIcon as s } from "../../lib/icons.mjs";
|
|
7
|
+
import { isOwnEvent as c } from "../../lib/events.mjs";
|
|
8
|
+
import { MenuSubmenuTriggerContext as l, useMenuListContext as u, useOptionalMenuContext as d } from "./Menu.context.mjs";
|
|
9
|
+
import { menuItemClasses as f } from "./Menu.shared.mjs";
|
|
10
|
+
import * as p from "react";
|
|
11
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
11
12
|
//#region src/components/navigation/Menu.items.tsx
|
|
12
|
-
function
|
|
13
|
-
return e === "checkmark" ? /* @__PURE__ */
|
|
13
|
+
function _(e) {
|
|
14
|
+
return e === "checkmark" ? /* @__PURE__ */ h("span", {
|
|
14
15
|
"aria-hidden": "true",
|
|
15
16
|
"data-menu-column-space": "checkmark",
|
|
16
17
|
className: "hidden w-4 shrink-0 group-has-[[data-menu-checkmark]]/menu:inline-flex"
|
|
17
|
-
}) : /* @__PURE__ */
|
|
18
|
+
}) : /* @__PURE__ */ h("span", {
|
|
18
19
|
"aria-hidden": "true",
|
|
19
20
|
"data-menu-column-space": "icon",
|
|
20
21
|
className: "hidden h-5 w-5 shrink-0 group-has-[[data-menu-icon]]/menu:inline-flex"
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
let
|
|
24
|
+
function v({ checkmark: t, icon: a, label: o, shortcut: s, end: c, markLabel: l = !0, partClassNames: u }) {
|
|
25
|
+
let d = i(o), f = a && i(a) ? r(a, "span", e(u?.icon, "flex h-5 w-5 shrink-0 items-center justify-center"), {
|
|
25
26
|
"aria-hidden": !0,
|
|
26
27
|
"data-menu-icon": ""
|
|
27
28
|
}) : null;
|
|
28
|
-
return /* @__PURE__ */ m
|
|
29
|
-
|
|
29
|
+
return /* @__PURE__ */ g(m, { children: [
|
|
30
|
+
t === void 0 ? d && _("checkmark") : /* @__PURE__ */ h("span", {
|
|
30
31
|
"aria-hidden": "true",
|
|
31
32
|
"data-menu-checkmark": "",
|
|
32
|
-
className: "inline-flex w-4 shrink-0 items-center justify-center",
|
|
33
|
-
children:
|
|
33
|
+
className: e(u?.checkmark, "inline-flex w-4 shrink-0 items-center justify-center"),
|
|
34
|
+
children: t
|
|
34
35
|
}),
|
|
35
|
-
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
className: "flex-1",
|
|
38
|
-
"data-menu-label":
|
|
39
|
-
children: n(
|
|
36
|
+
f ?? (d && _("icon")),
|
|
37
|
+
/* @__PURE__ */ h("span", {
|
|
38
|
+
className: e(u?.content, "flex-1"),
|
|
39
|
+
"data-menu-label": l && d && typeof o != "string" ? "" : void 0,
|
|
40
|
+
children: n(o)
|
|
40
41
|
}),
|
|
41
|
-
|
|
42
|
+
s && /* @__PURE__ */ h("span", {
|
|
42
43
|
dir: "auto",
|
|
43
|
-
className: "ms-4 text-caption-1 text-muted-foreground",
|
|
44
|
-
children:
|
|
44
|
+
className: e(u?.shortcut, "ms-4 text-caption-1 text-muted-foreground"),
|
|
45
|
+
children: s
|
|
45
46
|
}),
|
|
46
|
-
|
|
47
|
+
c
|
|
47
48
|
] });
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
function
|
|
51
|
-
return /* @__PURE__ */ m
|
|
50
|
+
v.displayName = "MenuItemRow";
|
|
51
|
+
function y() {
|
|
52
|
+
return /* @__PURE__ */ g(m, { children: [_("checkmark"), _("icon")] });
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
function
|
|
55
|
-
let
|
|
54
|
+
y.displayName = "MenuColumnSpacers";
|
|
55
|
+
function b({ disabled: e, persistOnClick: t, onClick: n, onKeyDown: r, onActivate: i, keepOpenOnSpace: a = !1, nativeEnter: o = !1, hasSubmenu: s = !1 }) {
|
|
56
|
+
let l = u(), d = p.useRef(!1);
|
|
56
57
|
return {
|
|
57
58
|
onClick: (r) => {
|
|
58
|
-
let
|
|
59
|
+
let o = c(r);
|
|
59
60
|
if (e) {
|
|
60
|
-
|
|
61
|
+
o && r.preventDefault();
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
63
|
-
n?.(r),
|
|
64
|
+
n?.(r), o && !r.defaultPrevented && (i?.(r), !(r.defaultPrevented || s) && (a && d.current || (t ?? l?.menu.persistOnItemClick ?? !1) || l?.closeFromItem()));
|
|
64
65
|
},
|
|
65
66
|
onKeyDown: (t) => {
|
|
66
|
-
if (r?.(t), !t.defaultPrevented &&
|
|
67
|
-
|
|
67
|
+
if (r?.(t), !t.defaultPrevented && c(t) && (t.key === "Enter" || t.key === " ") && !(t.key === "Enter" && o) && !(t.ctrlKey || t.altKey || t.metaKey) && (t.preventDefault(), !e)) {
|
|
68
|
+
d.current = t.key === " ";
|
|
68
69
|
try {
|
|
69
70
|
t.currentTarget.click();
|
|
70
71
|
} finally {
|
|
71
|
-
|
|
72
|
+
d.current = !1;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
let n =
|
|
79
|
-
|
|
78
|
+
function x(e) {
|
|
79
|
+
let n = u(), r = d(), i = r !== null && r.popup && n === null;
|
|
80
|
+
p.useEffect(() => {
|
|
80
81
|
i && t("Menu:item-outside-popover", `${e}: rendered in a popup menu outside Menu.Popover, so it has no \`role="menu"\` parent. A Menu with \`open\`, \`defaultOpen\` or \`onOpenChange\` is a popup menu that renders no element of its own: put the items in Menu.Popover, or leave these props out for a static menu.`);
|
|
81
82
|
}, [i, e]);
|
|
82
83
|
}
|
|
83
|
-
var
|
|
84
|
-
let _ =
|
|
85
|
-
|
|
86
|
-
let
|
|
84
|
+
var S = ({ icon: t, shortcut: n, disabled: r = !1, persistOnClick: i, onClick: a, onKeyDown: c, children: u, className: d, ref: m, ...g }) => {
|
|
85
|
+
let _ = p.useContext(l);
|
|
86
|
+
x("Menu.Item");
|
|
87
|
+
let y = typeof u == "string" ? u : void 0, S = g["data-roving-text"] !== void 0, C = b({
|
|
87
88
|
disabled: r,
|
|
88
89
|
persistOnClick: i,
|
|
89
|
-
onClick:
|
|
90
|
+
onClick: a,
|
|
90
91
|
onKeyDown: c,
|
|
91
92
|
hasSubmenu: _
|
|
92
93
|
});
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ h("div", {
|
|
94
95
|
role: "menuitem",
|
|
95
|
-
"data-roving-text":
|
|
96
|
-
...
|
|
96
|
+
"data-roving-text": y,
|
|
97
|
+
...g,
|
|
97
98
|
ref: m,
|
|
98
|
-
"aria-disabled": r ? !0 :
|
|
99
|
+
"aria-disabled": r ? !0 : g["aria-disabled"],
|
|
99
100
|
"data-disabled": r ? "" : void 0,
|
|
100
101
|
"data-has-submenu": _ ? "" : void 0,
|
|
101
|
-
onClick:
|
|
102
|
-
onKeyDown:
|
|
103
|
-
className: e(
|
|
104
|
-
children: /* @__PURE__ */
|
|
102
|
+
onClick: C.onClick,
|
|
103
|
+
onKeyDown: C.onKeyDown,
|
|
104
|
+
className: e(o.root, f, d),
|
|
105
|
+
children: /* @__PURE__ */ h(v, {
|
|
105
106
|
icon: t,
|
|
106
|
-
label:
|
|
107
|
+
label: u,
|
|
107
108
|
shortcut: n,
|
|
108
|
-
markLabel: !
|
|
109
|
-
|
|
109
|
+
markLabel: !S,
|
|
110
|
+
partClassNames: {
|
|
111
|
+
icon: o.icon,
|
|
112
|
+
content: o.content,
|
|
113
|
+
shortcut: o.shortcut
|
|
114
|
+
},
|
|
115
|
+
end: _ ? /* @__PURE__ */ h(s, {
|
|
110
116
|
size: 16,
|
|
111
|
-
className: "ms-auto shrink-0 wave-rtl:-scale-x-100"
|
|
117
|
+
className: e(o.submenuIndicator, "ms-auto shrink-0 wave-rtl:-scale-x-100")
|
|
112
118
|
}) : void 0
|
|
113
119
|
})
|
|
114
120
|
});
|
|
115
121
|
};
|
|
116
|
-
|
|
117
|
-
var
|
|
122
|
+
S.displayName = "MenuItem";
|
|
123
|
+
var C = ({ className: t, ref: n, ...r }) => /* @__PURE__ */ h("div", {
|
|
118
124
|
role: "separator",
|
|
119
125
|
...r,
|
|
120
126
|
ref: n,
|
|
121
|
-
className: e("my-1 border-t border-border", t)
|
|
127
|
+
className: e(a.root, "my-1 border-t border-border", t)
|
|
122
128
|
});
|
|
123
|
-
|
|
129
|
+
C.displayName = "MenuDivider";
|
|
124
130
|
//#endregion
|
|
125
|
-
export {
|
|
131
|
+
export { y as MenuColumnSpacers, C as MenuDivider, S as MenuItem, v as MenuItemRow, b as useMenuItemActivation, x as useMenuItemPlacementWarning };
|
|
126
132
|
|
|
127
133
|
//# sourceMappingURL=Menu.items.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.items.mjs","names":["_Fragment","React","renderColumnSpace","column","MenuItemRow","hasLabel","slotRendersContent","label","iconNode","icon","renderSlot","Fragment","checkmark","markLabel","materialiseSlotContent","shortcut","end","MenuColumnSpacers","useMenuItemActivation","list","useMenuListContext","clickFromSpaceRef","own","isOwnEvent","event","disabled","onClick","onActivate","hasSubmenu","keepOpenOnSpace","persistOnClick","onKeyDown","nativeEnter","useMenuItemPlacementWarning","menu","useOptionalMenuContext","outsidePopover","warnOnce","componentName","MenuItem","rest","isSubmenuTrigger","MenuSubmenuTriggerContext","stringLabel","children","ownRovingText","activation","cn","menuItemClasses","className","ChevronRightIcon","MenuDivider"],"sources":["../../../src/components/navigation/Menu.items.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport type { Slot } from '../../lib/types';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport { warnOnce } from '../../lib/dev';\nimport { isOwnEvent } from '../../lib/events';\nimport { ChevronRightIcon } from '../../lib/icons';\nimport {\n MenuSubmenuTriggerContext,\n useMenuListContext,\n useOptionalMenuContext,\n} from './Menu.context';\nimport { menuItemClasses } from './Menu.shared';\n\n/** Properties for the MenuItem sub-component. */\nexport interface MenuItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Slot for an icon displayed before the item text. Rendered with `aria-hidden=\"true\"`. A falsy\n * icon (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Keyboard shortcut text displayed at the end of the item. Its direction comes from its own text\n * (`dir=\"auto\"`), so \"Ctrl+,\" keeps its order in an RTL menu.\n */\n shortcut?: string;\n /** Whether the menu item is disabled (`aria-disabled`; skipped by keyboard navigation). */\n disabled?: boolean;\n /**\n * Keep a popup menu open after this item is activated. `true` or `false` here wins over the\n * Menu's `persistOnItemClick`.\n * @default the Menu's `persistOnItemClick` (`false`)\n */\n persistOnClick?: boolean;\n /**\n * Label content of the menu item. Leave it out only for the submenu half of a\n * `Menu.SplitGroup`, which then needs `aria-label`.\n */\n children?: React.ReactNode;\n /**\n * Ref to the item element (`role=\"menuitem\"`; `menuitemcheckbox` or `menuitemradio` for the\n * checkable items).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the MenuDivider sub-component. */\nexport interface MenuDividerProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the `role=\"separator\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ---------------------------------------------------------------------------\n// The item row and the column alignment\n// ---------------------------------------------------------------------------\n\n/** Internal: the content of one menu item row, rendered inside the item element. */\nexport interface MenuItemRowProps {\n /**\n * Checkable items: the checkmark column's content (the glyph, or `null` while unchecked); the\n * column renders in both states, marked `data-menu-checkmark`. `undefined` for other items,\n * which render a hidden placeholder instead.\n */\n checkmark?: React.ReactNode | null;\n /** The icon slot (a falsy icon or a list of nothing is no icon). */\n icon?: Slot<'span'>;\n /** The label (typeahead reads a non-string label through its `data-menu-label` element). */\n label: React.ReactNode;\n /** The shortcut text (rendered with `dir=\"auto\"`). */\n shortcut?: string;\n /** Content at the row's end: the submenu chevron or a switch. */\n end?: React.ReactNode;\n /**\n * Whether a non-string label is marked `data-menu-label` for typeahead. Pass `false` when the\n * item carries its own `data-roving-text`, which the label's text must not replace.\n * @default true\n */\n markLabel?: boolean;\n}\n\n/**\n * The placeholder of the checkmark or the icon column: hidden, and shown as soon as any item of\n * the same menu list (the `group/menu` element) renders that column, so every label starts at the\n * same place. Decorative (`aria-hidden`).\n */\nfunction renderColumnSpace(column: 'checkmark' | 'icon'): React.ReactElement {\n return column === 'checkmark' ? (\n <span\n aria-hidden=\"true\"\n data-menu-column-space=\"checkmark\"\n className=\"hidden w-4 shrink-0 group-has-[[data-menu-checkmark]]/menu:inline-flex\"\n />\n ) : (\n <span\n aria-hidden=\"true\"\n data-menu-column-space=\"icon\"\n className=\"hidden h-5 w-5 shrink-0 group-has-[[data-menu-icon]]/menu:inline-flex\"\n />\n );\n}\n\n/**\n * Internal: one menu item row, in DOM order (RTL mirrors it): the checkmark column, the icon\n * column, the label, the shortcut and the end content. A row without a checkmark or an icon\n * renders the column's placeholder instead; a row whose label renders nothing (the icon-only\n * submenu half of a split group) renders no placeholders.\n */\nexport function MenuItemRow({\n checkmark,\n icon,\n label,\n shortcut,\n end,\n markLabel = true,\n}: MenuItemRowProps): React.ReactElement {\n // The check does not consume a one-shot iterable label: it is rendered materialised.\n const hasLabel = slotRendersContent(label);\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in Nav,\n // Tree and Avatar, and so is a collection whose items render nothing: no empty 20px box before\n // the label. The check does not consume a generator: renderSlot still renders its items.\n const iconNode =\n icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', 'flex h-5 w-5 shrink-0 items-center justify-center', {\n 'aria-hidden': true,\n 'data-menu-icon': '',\n })\n : null;\n\n return (\n <>\n {checkmark !== undefined ? (\n <span\n aria-hidden=\"true\"\n data-menu-checkmark=\"\"\n className=\"inline-flex w-4 shrink-0 items-center justify-center\"\n >\n {checkmark}\n </span>\n ) : (\n hasLabel && renderColumnSpace('checkmark')\n )}\n {iconNode ?? (hasLabel && renderColumnSpace('icon'))}\n <span\n className=\"flex-1\"\n data-menu-label={markLabel && hasLabel && typeof label !== 'string' ? '' : undefined}\n >\n {materialiseSlotContent(label)}\n </span>\n {/* The shortcut takes its direction from its own text (`dir=\"auto\"` also isolates it): in an\n RTL menu, \"Ctrl+,\" would otherwise be reordered to \",+Ctrl\". */}\n {shortcut && (\n <span dir=\"auto\" className=\"ms-4 text-caption-1 text-muted-foreground\">\n {shortcut}\n </span>\n )}\n {end}\n </>\n );\n}\nMenuItemRow.displayName = 'MenuItemRow';\n\n/** Internal: the two column placeholders alone, for a row that is not an item (a group header). */\nexport function MenuColumnSpacers(): React.ReactElement {\n return (\n <>\n {renderColumnSpace('checkmark')}\n {renderColumnSpace('icon')}\n </>\n );\n}\nMenuColumnSpacers.displayName = 'MenuColumnSpacers';\n\n// ---------------------------------------------------------------------------\n// Item activation\n// ---------------------------------------------------------------------------\n\n/** Internal: the activation of every menu item kind. */\nexport interface MenuItemActivationOptions {\n disabled: boolean;\n /**\n * The item's own `persistOnClick`; `undefined` falls back to the Menu's `persistOnItemClick`.\n * A link item passes `false` (a link always closes).\n */\n persistOnClick: boolean | undefined;\n /** The consumer's handlers, composed consumer first (C-COMPOSE). */\n onClick?: React.MouseEventHandler<HTMLElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLElement>;\n /**\n * Runs on an own, enabled click after the consumer's `onClick`, unless it prevented the default.\n * Its own `preventDefault()` keeps the menu open.\n */\n onActivate?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Space activates and keeps the menu open (checkbox, radio and switch items). */\n keepOpenOnSpace?: boolean;\n /** Enter is left to the element's native activation (links); Space still clicks. */\n nativeEnter?: boolean;\n /** The item opens a submenu: activation never closes its menu. */\n hasSubmenu?: boolean;\n}\n\n/**\n * Internal: the click and key handlers of a menu item.\n *\n * - Events from a portal opened inside the item (a Popover, a Dialog) reach the consumer's\n * handlers, as React bubbles them, but never activate the item or close the menu.\n * - A disabled item calls no `onClick` and prevents its own click; its Enter and Space are still\n * consumed.\n * - Enter and Space are consumed (no page scroll) and click the item; with Ctrl, Alt or Meta they\n * are left to the page. A Space that continues a typeahead search is skipped (the roving\n * capture handler prevented it). With `nativeEnter`, Enter is left to the element.\n * - After the consumer's `onClick` and `onActivate`, the item closes its menu through the list's\n * `closeFromItem`, unless the click was not its own, its default was prevented, `hasSubmenu` is\n * set, `keepOpenOnSpace` is set and Space caused the click, or\n * `persistOnClick ?? menu.persistOnItemClick` is `true`.\n */\nexport function useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n onActivate,\n keepOpenOnSpace = false,\n nativeEnter = false,\n hasSubmenu = false,\n}: MenuItemActivationOptions): {\n onClick: React.MouseEventHandler<HTMLElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n} {\n const list = useMenuListContext();\n // Set while the key handler's click runs, so the click knows that Space caused it.\n const clickFromSpaceRef = React.useRef(false);\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n // A click inside a portal opened from the item reaches the consumer's onClick (React bubbles\n // it), but is not a click on the item: it never activates the item or closes the menu. A\n // disabled item calls no onClick, as a disabled button; a portal's click keeps its default.\n const own = isOwnEvent(event);\n if (disabled) {\n if (own) event.preventDefault();\n return;\n }\n onClick?.(event);\n if (!own || event.defaultPrevented) return;\n onActivate?.(event);\n if (event.defaultPrevented || hasSubmenu) return;\n if (keepOpenOnSpace && clickFromSpaceRef.current) return;\n if (persistOnClick ?? list?.menu.persistOnItemClick ?? false) return;\n list?.closeFromItem();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n // C-COMPOSE: the consumer's onKeyDown runs first; preventDefault() skips the built-in keys.\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n // Enter and Space typed in a portal opened from the item belong to that portal.\n if (!isOwnEvent(event)) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n // A link follows itself on Enter (Shift, Ctrl and Meta keep opening a new window or tab).\n if (event.key === 'Enter' && nativeEnter) return;\n // With Ctrl, Alt or Meta (Ctrl+Alt+Space included) the key is a shortcut, left to the page.\n if (event.ctrlKey || event.altKey || event.metaKey) return;\n // Menu items consume Enter/Space (no page scroll), whether or not they can be activated.\n event.preventDefault();\n if (disabled) return;\n clickFromSpaceRef.current = event.key === ' ';\n try {\n event.currentTarget.click();\n } finally {\n clickFromSpaceRef.current = false;\n }\n };\n\n return { onClick: handleClick, onKeyDown: handleKeyDown };\n}\n\n/**\n * Internal (C-DEV): warns once, from an effect, when an item of any kind renders in a popup menu\n * outside `Menu.Popover`. A Menu with `open`, `defaultOpen` or `onOpenChange` is a popup menu that\n * renders no element of its own, so such an item has no `role=\"menu\"` parent.\n *\n * @param componentName The item's name in the message, e.g. `'Menu.ItemCheckbox'`.\n */\nexport function useMenuItemPlacementWarning(componentName: string): void {\n const list = useMenuListContext();\n const menu = useOptionalMenuContext();\n const outsidePopover = menu !== null && menu.popup && list === null;\n React.useEffect(() => {\n if (!outsidePopover) return;\n warnOnce(\n 'Menu:item-outside-popover',\n `${componentName}: rendered in a popup menu outside Menu.Popover, so it has no \\`role=\"menu\"\\` parent. A Menu with \\`open\\`, \\`defaultOpen\\` or \\`onOpenChange\\` is a popup menu that renders no element of its own: put the items in Menu.Popover, or leave these props out for a static menu.`,\n );\n }, [outsidePopover, componentName]);\n}\n\n// ---------------------------------------------------------------------------\n// Menu.Item / Menu.Divider\n// ---------------------------------------------------------------------------\n\n/**\n * An action in a menu (`role=\"menuitem\"`). Enter and Space activate it (a Space typed within 500 ms\n * of a typeahead character continues the search instead; with Ctrl, Alt or Meta they are left to\n * the page); in a popup menu, activation closes the menu and returns focus to the trigger unless\n * `persistOnClick` (or the Menu's `persistOnItemClick`) keeps it open or the consumer's `onClick`\n * calls `preventDefault()`. Disabled items are `aria-disabled`, skipped by keyboard navigation and\n * never activated: their `onClick` is not called. A consumer `aria-disabled` without `disabled`\n * only changes the look and keyboard navigation: activation still runs `onClick` (guard it\n * yourself), as on Button. The item's tab index is managed by the menu. Typeahead matches the\n * label (`children`), not the icon or the shortcut; a `data-roving-text` you pass replaces the\n * label's text. Clicks and keys from a portal opened inside the item (a Popover, a Dialog) still\n * reach your `onClick` (on an enabled item) and `onKeyDown`, as React bubbles them, but never\n * activate the item or close the menu.\n *\n * The labels of a menu line up: when any item of the menu shows an icon (or a check), every item\n * keeps an empty column of that width before its label.\n *\n * As the child of a submenu's `Menu.Trigger` (a `Menu` nested in a menu list), the item is the\n * submenu's trigger: it shows a chevron at its end (mirrored in RTL) and `data-has-submenu`, and\n * activating it never closes its own menu. ArrowRight (ArrowLeft in RTL), Enter, Space and a click\n * open the submenu and move focus to its first item; resting the mouse on the item opens it\n * without moving focus.\n *\n * Also exported as `MenuItem` (import the flat name from React Server Components).\n */\nexport const MenuItem = ({\n icon,\n shortcut,\n disabled = false,\n persistOnClick,\n onClick,\n onKeyDown,\n children,\n className,\n ref,\n ...rest\n}: MenuItemProps) => {\n const isSubmenuTrigger = React.useContext(MenuSubmenuTriggerContext);\n useMenuItemPlacementWarning('Menu.Item');\n\n // Typeahead text: a string label directly; any other label through its marked element.\n const stringLabel = typeof children === 'string' ? children : undefined;\n const ownRovingText = (rest as Record<string, unknown>)['data-roving-text'] !== undefined;\n\n // A submenu trigger item opens its submenu (the trigger's composed onClick): activating it never\n // closes its own menu.\n const activation = useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n hasSubmenu: isSubmenuTrigger,\n });\n\n return (\n <div\n role=\"menuitem\"\n data-roving-text={stringLabel}\n {...rest}\n ref={ref}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n data-disabled={disabled ? '' : undefined}\n data-has-submenu={isSubmenuTrigger ? '' : undefined}\n onClick={activation.onClick}\n onKeyDown={activation.onKeyDown}\n className={cn(menuItemClasses, className)}\n >\n <MenuItemRow\n icon={icon}\n label={children}\n shortcut={shortcut}\n markLabel={!ownRovingText}\n end={\n isSubmenuTrigger ? (\n <ChevronRightIcon size={16} className=\"ms-auto shrink-0 wave-rtl:-scale-x-100\" />\n ) : undefined\n }\n />\n </div>\n );\n};\nMenuItem.displayName = 'MenuItem';\n\n/**\n * A separator between groups of menu items (`role=\"separator\"`).\n *\n * Also exported as `MenuDivider` (import the flat name from React Server Components).\n */\nexport const MenuDivider = ({ className, ref, ...rest }: MenuDividerProps) => {\n return (\n <div\n role=\"separator\"\n {...rest}\n ref={ref}\n className={cn('my-1 border-t border-border', className)}\n />\n );\n};\nMenuDivider.displayName = 'MenuDivider';\n"],"mappings":";;;;;;;;;;;AAqFA,SAASE,EAAkB,GAAkD;CAC3E,OAAOC,MAAW,cAChB,kBAAC,QAAD;EACE,eAAY;EACZ,0BAAuB;EACvB,WAAU;CACX,CAAA,IAED,kBAAC,QAAD;EACE,eAAY;EACZ,0BAAuB;EACvB,WAAU;CACX,CAAA;AAEL;AAQA,SAAgBC,EAAY,EAC1B,cACA,SACA,UACA,aACA,QACA,eAAY,MAC2B;CAEvC,IAAMC,IAAWC,EAAmBC,CAAK,GAInCC,IACJC,KAAQH,EAAmBG,CAAI,IAC3BC,EAAWD,GAAM,QAAQ,qDAAqD;EAC5E,eAAe;EACf,kBAAkB;CACpB,CAAC,IACD;CAEN,OACE,kBAAAT,GAAA,EAAA,UAAA;EACGY,MAAc,KAAA,IASbP,KAAYH,EAAkB,WAAW,IARzC,kBAAC,QAAD;GACE,eAAY;GACZ,uBAAoB;GACpB,WAAU;GAET,UAAAU;EACG,CAAA;EAIPJ,MAAaH,KAAYH,EAAkB,MAAM;EAClD,kBAAC,QAAD;GACE,WAAU;GACV,mBAAiBW,KAAaR,KAAY,OAAOE,KAAU,WAAW,KAAK,KAAA;GAE1E,UAAAO,EAAuBP,CAAK;EACzB,CAAA;EAGLQ,KACC,kBAAC,QAAD;GAAM,KAAI;GAAO,WAAU;GACxB,UAAAA;EACG,CAAA;EAEPC;CACD,EAAA,CAAA;AAEN;AACA,EAAY,cAAc;AAG1B,SAAgBC,IAAwC;CACtD,OACE,kBAAAjB,GAAA,EAAA,UAAA,CACGE,EAAkB,WAAW,GAC7BA,EAAkB,MAAM,CACzB,EAAA,CAAA;AAEN;A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W;CAGvC,IAAMC,IAAc,OAAOC,KAAa,WAAWA,IAAW,KAAA,GACxDC,IAAiBL,EAAiC,wBAAwB,KAAA,GAI1EM,IAAa5B,EAAsB;EACvC;EACA;EACA;EACA;EACA,YAAYuB;CACd,CAAC;CAED,OACE,kBAAC,OAAD;EACE,MAAK;EACL,oBAAkBE;EAClB,GAAIH;EACC;EACL,iBAAef,IAAW,KAAOe,EAAK;EACtC,iBAAef,IAAW,KAAK,KAAA;EAC/B,oBAAkBgB,IAAmB,KAAK,KAAA;EAC1C,SAASK,EAAW;EACpB,WAAWA,EAAW;EACtB,WAAWC,EAAGC,GAAiBC,CAAS;EAExC,UAAA,kBAAC7C,GAAD;GACQ;GACN,OAAOwC;GACG;GACV,WAAW,CAACC;GACZ,KACEJ,IACE,kBAACS,GAAD;IAAkB,MAAM;IAAI,WAAU;GAA0C,CAAA,IAC9E,KAAA;EAEP,CAAA;CACE,CAAA;AAET;AACA,EAAS,cAAc;AAOvB,IAAaC,KAAe,EAAE,cAAW,QAAK,GAAGX,QAE7C,kBAAC,OAAD;CACE,MAAK;CACL,GAAIA;CACC;CACL,WAAWO,EAAG,+BAA+BE,CAAS;AACvD,CAAA;AAGL,EAAY,cAAc"}
|
|
1
|
+
{"version":3,"file":"Menu.items.mjs","names":["_Fragment","React","renderColumnSpace","column","MenuItemRow","hasLabel","slotRendersContent","label","iconNode","icon","renderSlot","cn","partClassNames","Fragment","checkmark","markLabel","materialiseSlotContent","shortcut","end","MenuColumnSpacers","useMenuItemActivation","list","useMenuListContext","clickFromSpaceRef","own","isOwnEvent","event","disabled","onClick","onActivate","hasSubmenu","keepOpenOnSpace","persistOnClick","onKeyDown","nativeEnter","useMenuItemPlacementWarning","menu","useOptionalMenuContext","outsidePopover","warnOnce","componentName","MenuItem","rest","isSubmenuTrigger","MenuSubmenuTriggerContext","stringLabel","children","ownRovingText","activation","menuItemClassNames","menuItemClasses","className","ChevronRightIcon","MenuDivider","menuDividerClassNames"],"sources":["../../../src/components/navigation/Menu.items.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuDividerClassNames, menuItemClassNames } from '../../lib/classNames';\nimport type { Slot } from '../../lib/types';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport { warnOnce } from '../../lib/dev';\nimport { isOwnEvent } from '../../lib/events';\nimport { ChevronRightIcon } from '../../lib/icons';\nimport {\n MenuSubmenuTriggerContext,\n useMenuListContext,\n useOptionalMenuContext,\n} from './Menu.context';\nimport { menuItemClasses } from './Menu.shared';\n\n/** Properties for the MenuItem sub-component. */\nexport interface MenuItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Slot for an icon displayed before the item text. Rendered with `aria-hidden=\"true\"`. A falsy\n * icon (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Keyboard shortcut text displayed at the end of the item. Its direction comes from its own text\n * (`dir=\"auto\"`), so \"Ctrl+,\" keeps its order in an RTL menu.\n */\n shortcut?: string;\n /** Whether the menu item is disabled (`aria-disabled`; skipped by keyboard navigation). */\n disabled?: boolean;\n /**\n * Keep a popup menu open after this item is activated. `true` or `false` here wins over the\n * Menu's `persistOnItemClick`.\n * @default the Menu's `persistOnItemClick` (`false`)\n */\n persistOnClick?: boolean;\n /**\n * Label content of the menu item. Leave it out only for the submenu half of a\n * `Menu.SplitGroup`, which then needs `aria-label`.\n */\n children?: React.ReactNode;\n /**\n * Ref to the item element (`role=\"menuitem\"`; `menuitemcheckbox` or `menuitemradio` for the\n * checkable items).\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Properties for the MenuDivider sub-component. */\nexport interface MenuDividerProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the `role=\"separator\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ---------------------------------------------------------------------------\n// The item row and the column alignment\n// ---------------------------------------------------------------------------\n\n/** Internal: the content of one menu item row, rendered inside the item element. */\nexport interface MenuItemRowProps {\n /**\n * Checkable items: the checkmark column's content (the glyph, or `null` while unchecked); the\n * column renders in both states, marked `data-menu-checkmark`. `undefined` for other items,\n * which render a hidden placeholder instead.\n */\n checkmark?: React.ReactNode | null;\n /** The icon slot (a falsy icon or a list of nothing is no icon). */\n icon?: Slot<'span'>;\n /** The label (typeahead reads a non-string label through its `data-menu-label` element). */\n label: React.ReactNode;\n /** The shortcut text (rendered with `dir=\"auto\"`). */\n shortcut?: string;\n /** Content at the row's end: the submenu chevron or a switch. */\n end?: React.ReactNode;\n /**\n * Whether a non-string label is marked `data-menu-label` for typeahead. Pass `false` when the\n * item carries its own `data-roving-text`, which the label's text must not replace.\n * @default true\n */\n markLabel?: boolean;\n /**\n * Stable classes of the row's parts, written literally by each item kind (the check column,\n * the icon box, the label and the shortcut).\n */\n partClassNames?: MenuItemRowPartClassNames;\n}\n\n/** Internal: the stable classes of an item row's parts (see `MenuItemRowProps.partClassNames`). */\nexport interface MenuItemRowPartClassNames {\n checkmark?: string;\n icon?: string;\n content?: string;\n shortcut?: string;\n}\n\n/**\n * The placeholder of the checkmark or the icon column: hidden, and shown as soon as any item of\n * the same menu list (the `group/menu` element) renders that column, so every label starts at the\n * same place. Decorative (`aria-hidden`).\n */\nfunction renderColumnSpace(column: 'checkmark' | 'icon'): React.ReactElement {\n return column === 'checkmark' ? (\n <span\n aria-hidden=\"true\"\n data-menu-column-space=\"checkmark\"\n className=\"hidden w-4 shrink-0 group-has-[[data-menu-checkmark]]/menu:inline-flex\"\n />\n ) : (\n <span\n aria-hidden=\"true\"\n data-menu-column-space=\"icon\"\n className=\"hidden h-5 w-5 shrink-0 group-has-[[data-menu-icon]]/menu:inline-flex\"\n />\n );\n}\n\n/**\n * Internal: one menu item row, in DOM order (RTL mirrors it): the checkmark column, the icon\n * column, the label, the shortcut and the end content. A row without a checkmark or an icon\n * renders the column's placeholder instead; a row whose label renders nothing (the icon-only\n * submenu half of a split group) renders no placeholders.\n */\nexport function MenuItemRow({\n checkmark,\n icon,\n label,\n shortcut,\n end,\n markLabel = true,\n partClassNames,\n}: MenuItemRowProps): React.ReactElement {\n // The check does not consume a one-shot iterable label: it is rendered materialised.\n const hasLabel = slotRendersContent(label);\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in Nav,\n // Tree and Avatar, and so is a collection whose items render nothing: no empty 20px box before\n // the label. The check does not consume a generator: renderSlot still renders its items.\n const iconNode =\n icon && slotRendersContent(icon)\n ? renderSlot(\n icon,\n 'span',\n cn(partClassNames?.icon, 'flex h-5 w-5 shrink-0 items-center justify-center'),\n { 'aria-hidden': true, 'data-menu-icon': '' },\n )\n : null;\n\n return (\n <>\n {checkmark !== undefined ? (\n <span\n aria-hidden=\"true\"\n data-menu-checkmark=\"\"\n className={cn(\n partClassNames?.checkmark,\n 'inline-flex w-4 shrink-0 items-center justify-center',\n )}\n >\n {checkmark}\n </span>\n ) : (\n hasLabel && renderColumnSpace('checkmark')\n )}\n {iconNode ?? (hasLabel && renderColumnSpace('icon'))}\n <span\n className={cn(partClassNames?.content, 'flex-1')}\n data-menu-label={markLabel && hasLabel && typeof label !== 'string' ? '' : undefined}\n >\n {materialiseSlotContent(label)}\n </span>\n {/* The shortcut takes its direction from its own text (`dir=\"auto\"` also isolates it): in an\n RTL menu, \"Ctrl+,\" would otherwise be reordered to \",+Ctrl\". */}\n {shortcut && (\n <span\n dir=\"auto\"\n className={cn(partClassNames?.shortcut, 'ms-4 text-caption-1 text-muted-foreground')}\n >\n {shortcut}\n </span>\n )}\n {end}\n </>\n );\n}\nMenuItemRow.displayName = 'MenuItemRow';\n\n/** Internal: the two column placeholders alone, for a row that is not an item (a group header). */\nexport function MenuColumnSpacers(): React.ReactElement {\n return (\n <>\n {renderColumnSpace('checkmark')}\n {renderColumnSpace('icon')}\n </>\n );\n}\nMenuColumnSpacers.displayName = 'MenuColumnSpacers';\n\n// ---------------------------------------------------------------------------\n// Item activation\n// ---------------------------------------------------------------------------\n\n/** Internal: the activation of every menu item kind. */\nexport interface MenuItemActivationOptions {\n disabled: boolean;\n /**\n * The item's own `persistOnClick`; `undefined` falls back to the Menu's `persistOnItemClick`.\n * A link item passes `false` (a link always closes).\n */\n persistOnClick: boolean | undefined;\n /** The consumer's handlers, composed consumer first (C-COMPOSE). */\n onClick?: React.MouseEventHandler<HTMLElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLElement>;\n /**\n * Runs on an own, enabled click after the consumer's `onClick`, unless it prevented the default.\n * Its own `preventDefault()` keeps the menu open.\n */\n onActivate?: (event: React.MouseEvent<HTMLElement>) => void;\n /** Space activates and keeps the menu open (checkbox, radio and switch items). */\n keepOpenOnSpace?: boolean;\n /** Enter is left to the element's native activation (links); Space still clicks. */\n nativeEnter?: boolean;\n /** The item opens a submenu: activation never closes its menu. */\n hasSubmenu?: boolean;\n}\n\n/**\n * Internal: the click and key handlers of a menu item.\n *\n * - Events from a portal opened inside the item (a Popover, a Dialog) reach the consumer's\n * handlers, as React bubbles them, but never activate the item or close the menu.\n * - A disabled item calls no `onClick` and prevents its own click; its Enter and Space are still\n * consumed.\n * - Enter and Space are consumed (no page scroll) and click the item; with Ctrl, Alt or Meta they\n * are left to the page. A Space that continues a typeahead search is skipped (the roving\n * capture handler prevented it). With `nativeEnter`, Enter is left to the element.\n * - After the consumer's `onClick` and `onActivate`, the item closes its menu through the list's\n * `closeFromItem`, unless the click was not its own, its default was prevented, `hasSubmenu` is\n * set, `keepOpenOnSpace` is set and Space caused the click, or\n * `persistOnClick ?? menu.persistOnItemClick` is `true`.\n */\nexport function useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n onActivate,\n keepOpenOnSpace = false,\n nativeEnter = false,\n hasSubmenu = false,\n}: MenuItemActivationOptions): {\n onClick: React.MouseEventHandler<HTMLElement>;\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n} {\n const list = useMenuListContext();\n // Set while the key handler's click runs, so the click knows that Space caused it.\n const clickFromSpaceRef = React.useRef(false);\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n // A click inside a portal opened from the item reaches the consumer's onClick (React bubbles\n // it), but is not a click on the item: it never activates the item or closes the menu. A\n // disabled item calls no onClick, as a disabled button; a portal's click keeps its default.\n const own = isOwnEvent(event);\n if (disabled) {\n if (own) event.preventDefault();\n return;\n }\n onClick?.(event);\n if (!own || event.defaultPrevented) return;\n onActivate?.(event);\n if (event.defaultPrevented || hasSubmenu) return;\n if (keepOpenOnSpace && clickFromSpaceRef.current) return;\n if (persistOnClick ?? list?.menu.persistOnItemClick ?? false) return;\n list?.closeFromItem();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n // C-COMPOSE: the consumer's onKeyDown runs first; preventDefault() skips the built-in keys.\n onKeyDown?.(event);\n if (event.defaultPrevented) return;\n // Enter and Space typed in a portal opened from the item belong to that portal.\n if (!isOwnEvent(event)) return;\n if (event.key !== 'Enter' && event.key !== ' ') return;\n // A link follows itself on Enter (Shift, Ctrl and Meta keep opening a new window or tab).\n if (event.key === 'Enter' && nativeEnter) return;\n // With Ctrl, Alt or Meta (Ctrl+Alt+Space included) the key is a shortcut, left to the page.\n if (event.ctrlKey || event.altKey || event.metaKey) return;\n // Menu items consume Enter/Space (no page scroll), whether or not they can be activated.\n event.preventDefault();\n if (disabled) return;\n clickFromSpaceRef.current = event.key === ' ';\n try {\n event.currentTarget.click();\n } finally {\n clickFromSpaceRef.current = false;\n }\n };\n\n return { onClick: handleClick, onKeyDown: handleKeyDown };\n}\n\n/**\n * Internal (C-DEV): warns once, from an effect, when an item of any kind renders in a popup menu\n * outside `Menu.Popover`. A Menu with `open`, `defaultOpen` or `onOpenChange` is a popup menu that\n * renders no element of its own, so such an item has no `role=\"menu\"` parent.\n *\n * @param componentName The item's name in the message, e.g. `'Menu.ItemCheckbox'`.\n */\nexport function useMenuItemPlacementWarning(componentName: string): void {\n const list = useMenuListContext();\n const menu = useOptionalMenuContext();\n const outsidePopover = menu !== null && menu.popup && list === null;\n React.useEffect(() => {\n if (!outsidePopover) return;\n warnOnce(\n 'Menu:item-outside-popover',\n `${componentName}: rendered in a popup menu outside Menu.Popover, so it has no \\`role=\"menu\"\\` parent. A Menu with \\`open\\`, \\`defaultOpen\\` or \\`onOpenChange\\` is a popup menu that renders no element of its own: put the items in Menu.Popover, or leave these props out for a static menu.`,\n );\n }, [outsidePopover, componentName]);\n}\n\n// ---------------------------------------------------------------------------\n// Menu.Item / Menu.Divider\n// ---------------------------------------------------------------------------\n\n/**\n * An action in a menu (`role=\"menuitem\"`). Enter and Space activate it (a Space typed within 500 ms\n * of a typeahead character continues the search instead; with Ctrl, Alt or Meta they are left to\n * the page); in a popup menu, activation closes the menu and returns focus to the trigger unless\n * `persistOnClick` (or the Menu's `persistOnItemClick`) keeps it open or the consumer's `onClick`\n * calls `preventDefault()`. Disabled items are `aria-disabled`, skipped by keyboard navigation and\n * never activated: their `onClick` is not called. A consumer `aria-disabled` without `disabled`\n * only changes the look and keyboard navigation: activation still runs `onClick` (guard it\n * yourself), as on Button. The item's tab index is managed by the menu. Typeahead matches the\n * label (`children`), not the icon or the shortcut; a `data-roving-text` you pass replaces the\n * label's text. Clicks and keys from a portal opened inside the item (a Popover, a Dialog) still\n * reach your `onClick` (on an enabled item) and `onKeyDown`, as React bubbles them, but never\n * activate the item or close the menu.\n *\n * The labels of a menu line up: when any item of the menu shows an icon (or a check), every item\n * keeps an empty column of that width before its label.\n *\n * As the child of a submenu's `Menu.Trigger` (a `Menu` nested in a menu list), the item is the\n * submenu's trigger: it shows a chevron at its end (mirrored in RTL) and `data-has-submenu`, and\n * activating it never closes its own menu. ArrowRight (ArrowLeft in RTL), Enter, Space and a click\n * open the submenu and move focus to its first item; resting the mouse on the item opens it\n * without moving focus.\n *\n * Also exported as `MenuItem` (import the flat name from React Server Components).\n */\nexport const MenuItem = ({\n icon,\n shortcut,\n disabled = false,\n persistOnClick,\n onClick,\n onKeyDown,\n children,\n className,\n ref,\n ...rest\n}: MenuItemProps) => {\n const isSubmenuTrigger = React.useContext(MenuSubmenuTriggerContext);\n useMenuItemPlacementWarning('Menu.Item');\n\n // Typeahead text: a string label directly; any other label through its marked element.\n const stringLabel = typeof children === 'string' ? children : undefined;\n const ownRovingText = (rest as Record<string, unknown>)['data-roving-text'] !== undefined;\n\n // A submenu trigger item opens its submenu (the trigger's composed onClick): activating it never\n // closes its own menu.\n const activation = useMenuItemActivation({\n disabled,\n persistOnClick,\n onClick,\n onKeyDown,\n hasSubmenu: isSubmenuTrigger,\n });\n\n return (\n <div\n role=\"menuitem\"\n data-roving-text={stringLabel}\n {...rest}\n ref={ref}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n data-disabled={disabled ? '' : undefined}\n data-has-submenu={isSubmenuTrigger ? '' : undefined}\n onClick={activation.onClick}\n onKeyDown={activation.onKeyDown}\n className={cn(menuItemClassNames.root, menuItemClasses, className)}\n >\n <MenuItemRow\n icon={icon}\n label={children}\n shortcut={shortcut}\n markLabel={!ownRovingText}\n partClassNames={{\n icon: menuItemClassNames.icon,\n content: menuItemClassNames.content,\n shortcut: menuItemClassNames.shortcut,\n }}\n end={\n isSubmenuTrigger ? (\n <ChevronRightIcon\n size={16}\n className={cn(\n menuItemClassNames.submenuIndicator,\n 'ms-auto shrink-0 wave-rtl:-scale-x-100',\n )}\n />\n ) : undefined\n }\n />\n </div>\n );\n};\nMenuItem.displayName = 'MenuItem';\n\n/**\n * A separator between groups of menu items (`role=\"separator\"`).\n *\n * Also exported as `MenuDivider` (import the flat name from React Server Components).\n */\nexport const MenuDivider = ({ className, ref, ...rest }: MenuDividerProps) => {\n return (\n <div\n role=\"separator\"\n {...rest}\n ref={ref}\n className={cn(menuDividerClassNames.root, 'my-1 border-t border-border', className)}\n />\n );\n};\nMenuDivider.displayName = 'MenuDivider';\n"],"mappings":";;;;;;;;;;;;AAmGA,SAASE,EAAkB,GAAkD;CAC3E,OAAOC,MAAW,cAChB,kBAAC,QAAD;EACE,eAAY;EACZ,0BAAu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