@mortenbrudvik/waveui 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +564 -155
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.mjs +36 -35
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/button/Button.slots.cjs +1 -1
- package/dist/components/button/Button.slots.cjs.map +1 -1
- package/dist/components/button/Button.slots.mjs +31 -21
- package/dist/components/button/Button.slots.mjs.map +1 -1
- package/dist/components/button/CompoundButton.cjs +1 -1
- package/dist/components/button/CompoundButton.cjs.map +1 -1
- package/dist/components/button/CompoundButton.mjs +31 -29
- package/dist/components/button/CompoundButton.mjs.map +1 -1
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +24 -23
- package/dist/components/button/Link.mjs.map +1 -1
- package/dist/components/button/MenuButton.cjs +1 -1
- package/dist/components/button/MenuButton.cjs.map +1 -1
- package/dist/components/button/MenuButton.mjs +29 -28
- package/dist/components/button/MenuButton.mjs.map +1 -1
- package/dist/components/button/SplitButton.cjs +1 -1
- package/dist/components/button/SplitButton.cjs.map +1 -1
- package/dist/components/button/SplitButton.mjs +46 -45
- package/dist/components/button/SplitButton.mjs.map +1 -1
- package/dist/components/button/ToggleButton.cjs +1 -1
- package/dist/components/button/ToggleButton.cjs.map +1 -1
- package/dist/components/button/ToggleButton.mjs +38 -35
- package/dist/components/button/ToggleButton.mjs.map +1 -1
- package/dist/components/button/Toolbar.cjs +1 -1
- package/dist/components/button/Toolbar.cjs.map +1 -1
- package/dist/components/button/Toolbar.mjs +43 -42
- package/dist/components/button/Toolbar.mjs.map +1 -1
- package/dist/components/button/Toolbar.parts.cjs +1 -1
- package/dist/components/button/Toolbar.parts.cjs.map +1 -1
- package/dist/components/button/Toolbar.parts.mjs +76 -81
- package/dist/components/button/Toolbar.parts.mjs.map +1 -1
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.mjs +72 -67
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.mjs +89 -88
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
- package/dist/components/data-display/Badge.cjs +1 -1
- package/dist/components/data-display/Badge.cjs.map +1 -1
- package/dist/components/data-display/Badge.mjs +17 -16
- package/dist/components/data-display/Badge.mjs.map +1 -1
- package/dist/components/data-display/CounterBadge.cjs +1 -1
- package/dist/components/data-display/CounterBadge.cjs.map +1 -1
- package/dist/components/data-display/CounterBadge.mjs +18 -17
- package/dist/components/data-display/CounterBadge.mjs.map +1 -1
- package/dist/components/data-display/Divider.cjs +1 -1
- package/dist/components/data-display/Divider.cjs.map +1 -1
- package/dist/components/data-display/Divider.mjs +31 -30
- package/dist/components/data-display/Divider.mjs.map +1 -1
- package/dist/components/data-display/Image.cjs +1 -1
- package/dist/components/data-display/Image.cjs.map +1 -1
- package/dist/components/data-display/Image.mjs +16 -15
- package/dist/components/data-display/Image.mjs.map +1 -1
- package/dist/components/data-display/InfoButton.cjs +2 -0
- package/dist/components/data-display/InfoButton.cjs.map +1 -0
- package/dist/components/data-display/InfoButton.mjs +173 -0
- package/dist/components/data-display/InfoButton.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +36 -92
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +175 -174
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/Persona.cjs +1 -1
- package/dist/components/data-display/Persona.cjs.map +1 -1
- package/dist/components/data-display/Persona.mjs +31 -29
- package/dist/components/data-display/Persona.mjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.cjs +1 -1
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.mjs +25 -24
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +87 -82
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.cjs +1 -1
- package/dist/components/feedback/MessageBar.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.mjs +129 -71
- package/dist/components/feedback/MessageBar.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.parts.cjs +2 -0
- package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.parts.mjs +84 -0
- package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
- package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
- package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +1 -1
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.status.mjs +2 -1
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
- package/dist/components/feedback/ProgressBar.cjs +1 -1
- package/dist/components/feedback/ProgressBar.cjs.map +1 -1
- package/dist/components/feedback/ProgressBar.mjs +44 -43
- package/dist/components/feedback/ProgressBar.mjs.map +1 -1
- package/dist/components/feedback/Skeleton.cjs +1 -1
- package/dist/components/feedback/Skeleton.cjs.map +1 -1
- package/dist/components/feedback/Skeleton.mjs +26 -24
- package/dist/components/feedback/Skeleton.mjs.map +1 -1
- package/dist/components/feedback/Spinner.cjs +1 -1
- package/dist/components/feedback/Spinner.cjs.map +1 -1
- package/dist/components/feedback/Spinner.mjs +32 -31
- package/dist/components/feedback/Spinner.mjs.map +1 -1
- package/dist/components/feedback/Toast.cjs +1 -1
- package/dist/components/feedback/Toast.cjs.map +1 -1
- package/dist/components/feedback/Toast.context.cjs +2 -0
- package/dist/components/feedback/Toast.context.cjs.map +1 -0
- package/dist/components/feedback/Toast.context.mjs +23 -0
- package/dist/components/feedback/Toast.context.mjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +10 -342
- package/dist/components/feedback/Toast.mjs.map +1 -1
- package/dist/components/feedback/Toast.parts.cjs +2 -0
- package/dist/components/feedback/Toast.parts.cjs.map +1 -0
- package/dist/components/feedback/Toast.parts.mjs +98 -0
- package/dist/components/feedback/Toast.parts.mjs.map +1 -0
- package/dist/components/feedback/Toast.root.cjs +2 -0
- package/dist/components/feedback/Toast.root.cjs.map +1 -0
- package/dist/components/feedback/Toast.root.mjs +109 -0
- package/dist/components/feedback/Toast.root.mjs.map +1 -0
- package/dist/components/feedback/Toaster.cjs +2 -0
- package/dist/components/feedback/Toaster.cjs.map +1 -0
- package/dist/components/feedback/Toaster.mjs +564 -0
- package/dist/components/feedback/Toaster.mjs.map +1 -0
- package/dist/components/input/AlphaSlider.cjs +2 -0
- package/dist/components/input/AlphaSlider.cjs.map +1 -0
- package/dist/components/input/AlphaSlider.mjs +115 -0
- package/dist/components/input/AlphaSlider.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +1 -1
- package/dist/components/input/Checkbox.cjs.map +1 -1
- package/dist/components/input/Checkbox.mjs +87 -70
- package/dist/components/input/Checkbox.mjs.map +1 -1
- package/dist/components/input/ColorArea.cjs +2 -0
- package/dist/components/input/ColorArea.cjs.map +1 -0
- package/dist/components/input/ColorArea.mjs +204 -0
- package/dist/components/input/ColorArea.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +5 -5
- package/dist/components/input/ColorPicker.cjs.map +1 -1
- package/dist/components/input/ColorPicker.mjs +142 -165
- package/dist/components/input/ColorPicker.mjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.cjs +2 -0
- package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
- package/dist/components/input/ColorPicker.parts.mjs +192 -0
- package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
- package/dist/components/input/ColorSlider.cjs +2 -0
- package/dist/components/input/ColorSlider.cjs.map +1 -0
- package/dist/components/input/ColorSlider.mjs +138 -0
- package/dist/components/input/ColorSlider.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +22 -22
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +151 -141
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +239 -234
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +109 -100
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Field.cjs +1 -1
- package/dist/components/input/Field.cjs.map +1 -1
- package/dist/components/input/Field.mjs +139 -105
- package/dist/components/input/Field.mjs.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.mjs +80 -55
- package/dist/components/input/Input.mjs.map +1 -1
- package/dist/components/input/Label.cjs +1 -1
- package/dist/components/input/Label.cjs.map +1 -1
- package/dist/components/input/Label.mjs +19 -12
- package/dist/components/input/Label.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +100 -98
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/RadioGroup.cjs +1 -1
- package/dist/components/input/RadioGroup.cjs.map +1 -1
- package/dist/components/input/RadioGroup.mjs +89 -88
- package/dist/components/input/RadioGroup.mjs.map +1 -1
- package/dist/components/input/Rating.cjs +1 -1
- package/dist/components/input/Rating.cjs.map +1 -1
- package/dist/components/input/Rating.item.cjs +2 -0
- package/dist/components/input/Rating.item.cjs.map +1 -0
- package/dist/components/input/Rating.item.mjs +255 -0
- package/dist/components/input/Rating.item.mjs.map +1 -0
- package/dist/components/input/Rating.mjs +152 -152
- package/dist/components/input/Rating.mjs.map +1 -1
- package/dist/components/input/SearchBox.cjs +1 -1
- package/dist/components/input/SearchBox.cjs.map +1 -1
- package/dist/components/input/SearchBox.mjs +162 -132
- package/dist/components/input/SearchBox.mjs.map +1 -1
- package/dist/components/input/Select.cjs +1 -1
- package/dist/components/input/Select.cjs.map +1 -1
- package/dist/components/input/Select.mjs +34 -24
- package/dist/components/input/Select.mjs.map +1 -1
- package/dist/components/input/Slider.cjs +1 -1
- package/dist/components/input/Slider.cjs.map +1 -1
- package/dist/components/input/Slider.mjs +78 -54
- package/dist/components/input/Slider.mjs.map +1 -1
- package/dist/components/input/SpinButton.cjs +1 -1
- package/dist/components/input/SpinButton.cjs.map +1 -1
- package/dist/components/input/SpinButton.mjs +202 -99
- package/dist/components/input/SpinButton.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.mjs +38 -37
- package/dist/components/input/SwatchPicker.mjs.map +1 -1
- package/dist/components/input/Switch.cjs +1 -1
- package/dist/components/input/Switch.cjs.map +1 -1
- package/dist/components/input/Switch.mjs +75 -58
- package/dist/components/input/Switch.mjs.map +1 -1
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.mjs +199 -169
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/Textarea.cjs +1 -1
- package/dist/components/input/Textarea.cjs.map +1 -1
- package/dist/components/input/Textarea.mjs +31 -23
- package/dist/components/input/Textarea.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +185 -177
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/input/colorName.cjs +2 -0
- package/dist/components/input/colorName.cjs.map +1 -0
- package/dist/components/input/colorName.mjs +30 -0
- package/dist/components/input/colorName.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +1 -1
- package/dist/components/input/colorUtils.cjs.map +1 -1
- package/dist/components/input/colorUtils.mjs +154 -56
- package/dist/components/input/colorUtils.mjs.map +1 -1
- package/dist/components/input/fieldLabel.cjs +2 -0
- package/dist/components/input/fieldLabel.cjs.map +1 -0
- package/dist/components/input/fieldLabel.mjs +17 -0
- package/dist/components/input/fieldLabel.mjs.map +1 -0
- package/dist/components/input/inputLook.cjs +2 -0
- package/dist/components/input/inputLook.cjs.map +1 -0
- package/dist/components/input/inputLook.mjs +28 -0
- package/dist/components/input/inputLook.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +1 -1
- package/dist/components/input/pickerStyles.cjs.map +1 -1
- package/dist/components/input/pickerStyles.mjs +42 -4
- package/dist/components/input/pickerStyles.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs +130 -129
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/layout/Card.cjs +1 -1
- package/dist/components/layout/Card.cjs.map +1 -1
- package/dist/components/layout/Card.mjs +78 -77
- package/dist/components/layout/Card.mjs.map +1 -1
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.mjs +111 -110
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/Flex.cjs +1 -1
- package/dist/components/layout/Flex.cjs.map +1 -1
- package/dist/components/layout/Flex.mjs +22 -21
- package/dist/components/layout/Flex.mjs.map +1 -1
- package/dist/components/layout/Grid.cjs +1 -1
- package/dist/components/layout/Grid.cjs.map +1 -1
- package/dist/components/layout/Grid.mjs +19 -18
- package/dist/components/layout/Grid.mjs.map +1 -1
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +92 -91
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Stack.cjs +1 -1
- package/dist/components/layout/Stack.cjs.map +1 -1
- package/dist/components/layout/Stack.mjs +14 -13
- package/dist/components/layout/Stack.mjs.map +1 -1
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +118 -117
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/layout/Tree.cjs +1 -1
- package/dist/components/layout/Tree.cjs.map +1 -1
- package/dist/components/layout/Tree.context.cjs +2 -0
- package/dist/components/layout/Tree.context.cjs.map +1 -0
- package/dist/components/layout/Tree.context.mjs +33 -0
- package/dist/components/layout/Tree.context.mjs.map +1 -0
- package/dist/components/layout/Tree.core.cjs +2 -0
- package/dist/components/layout/Tree.core.cjs.map +1 -0
- package/dist/components/layout/Tree.core.mjs +416 -0
- package/dist/components/layout/Tree.core.mjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
- package/dist/components/layout/Tree.mjs +7 -215
- package/dist/components/layout/Tree.mjs.map +1 -1
- package/dist/components/layout/Tree.selection.cjs +2 -0
- package/dist/components/layout/Tree.selection.cjs.map +1 -0
- package/dist/components/layout/Tree.selection.mjs +73 -0
- package/dist/components/layout/Tree.selection.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +76 -75
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/navigation/Menu.group.cjs +1 -1
- package/dist/components/navigation/Menu.group.cjs.map +1 -1
- package/dist/components/navigation/Menu.group.mjs +39 -37
- package/dist/components/navigation/Menu.group.mjs.map +1 -1
- package/dist/components/navigation/Menu.items.cjs +1 -1
- package/dist/components/navigation/Menu.items.cjs.map +1 -1
- package/dist/components/navigation/Menu.items.mjs +67 -61
- package/dist/components/navigation/Menu.items.mjs.map +1 -1
- package/dist/components/navigation/Menu.link.cjs +1 -1
- package/dist/components/navigation/Menu.link.cjs.map +1 -1
- package/dist/components/navigation/Menu.link.mjs +34 -28
- package/dist/components/navigation/Menu.link.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +114 -113
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +171 -170
- package/dist/components/navigation/Menu.root.mjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.cjs +1 -1
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.mjs +85 -63
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.cjs +1 -1
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.mjs +6 -6
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.mjs +170 -155
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination.cjs.map +1 -1
- package/dist/components/navigation/Pagination.mjs +73 -65
- package/dist/components/navigation/Pagination.mjs.map +1 -1
- package/dist/components/navigation/Stepper.cjs +1 -1
- package/dist/components/navigation/Stepper.cjs.map +1 -1
- package/dist/components/navigation/Stepper.mjs +110 -109
- package/dist/components/navigation/Stepper.mjs.map +1 -1
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +109 -108
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Drawer.cjs +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.mjs +110 -109
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +148 -151
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/Popover.shared.cjs +1 -1
- package/dist/components/overlays/Popover.shared.cjs.map +1 -1
- package/dist/components/overlays/Popover.shared.mjs +82 -77
- package/dist/components/overlays/Popover.shared.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +41 -37
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +87 -86
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +33 -32
- package/dist/components/portal/Portal.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +36 -29
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +228 -227
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +60 -59
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/typography/Text.cjs +1 -1
- package/dist/components/typography/Text.cjs.map +1 -1
- package/dist/components/typography/Text.mjs +12 -11
- package/dist/components/typography/Text.mjs.map +1 -1
- package/dist/hooks/useFieldControl.cjs.map +1 -1
- package/dist/hooks/useFieldControl.mjs.map +1 -1
- package/dist/hooks/useMediaQuery.cjs +2 -0
- package/dist/hooks/useMediaQuery.cjs.map +1 -0
- package/dist/hooks/useMediaQuery.mjs +20 -0
- package/dist/hooks/useMediaQuery.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +1 -1
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +3 -3
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2890 -197
- package/dist/index.d.ts +2890 -197
- package/dist/index.mjs +101 -87
- package/dist/lib/classNames.cjs +2 -0
- package/dist/lib/classNames.cjs.map +1 -0
- package/dist/lib/classNames.mjs +423 -0
- package/dist/lib/classNames.mjs.map +1 -0
- package/dist/lib/color.cjs +2 -0
- package/dist/lib/color.cjs.map +1 -0
- package/dist/lib/color.mjs +86 -0
- package/dist/lib/color.mjs.map +1 -0
- package/dist/lib/globalRegistry.cjs.map +1 -1
- package/dist/lib/globalRegistry.mjs.map +1 -1
- package/dist/lib/styles.cjs +1 -1
- package/dist/lib/styles.cjs.map +1 -1
- package/dist/lib/styles.mjs +21 -4
- package/dist/lib/styles.mjs.map +1 -1
- package/dist/lib/toaster.cjs +2 -0
- package/dist/lib/toaster.cjs.map +1 -0
- package/dist/lib/toaster.mjs +77 -0
- package/dist/lib/toaster.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +13 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.splitGroup.cjs","names":["flattenChildren","isElementOfType","MenuItem","MenuRoot","getArrowIntent","getDirection","composeEventHandlers","cn","require_runtime","require_cn","require_children","require_dev","require_composeEventHandlers","require_direction","require_Menu_items","require_Menu_root","react","react_jsx_runtime","hasActionAndSubmenu","nodes","children","node","index","rowItems","row","child","MenuSplitGroup","rest","complete","handleKeyDown","event","intent","items","action","half","from","to","onKeyDown","className"],"sources":["../../../src/components/navigation/Menu.splitGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { MenuItem } from './Menu.items';\nimport { MenuRoot } from './Menu.root';\nimport { MENU_ITEM_SELECTOR } from './Menu.shared';\n\n/** Properties for the MenuSplitGroup sub-component. */\nexport interface MenuSplitGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * A `Menu.Item` (the main action) followed by a submenu `<Menu>` whose `Menu.Trigger` wraps a\n * `Menu.Item` with an `aria-label` and no children, which shows only the submenu chevron:\n * `<Menu><Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover>…</Menu.Popover></Menu>`.\n */\n children: React.ReactNode;\n /** Ref to the `role=\"group\"` row. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Whether the direct children (Fragments included, Server Component references too) hold a\n * `Menu.Item` followed by a `<Menu>`.\n */\nfunction hasActionAndSubmenu(children: React.ReactNode): boolean {\n const nodes = flattenChildren(children).map(({ node }) => node);\n return nodes.some(\n (node, index) => isElementOfType(node, MenuItem) && isElementOfType(nodes[index + 1], MenuRoot),\n );\n}\n\n/** The menu items that are the row's own children (the action first, the submenu half last). */\nfunction rowItems(row: HTMLElement): HTMLElement[] {\n return Array.from(row.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement && child.matches(MENU_ITEM_SELECTOR),\n );\n}\n\n/**\n * One row with a main action and a button that opens a submenu (`role=\"group\"` holding two menu\n * items). ArrowDown and ArrowUp visit both halves; ArrowRight (ArrowLeft in RTL) moves from the\n * action to the submenu button, and on the button opens the submenu; ArrowLeft (ArrowRight in RTL)\n * moves back. The submenu half is a `Menu.Item` without children, named by its `aria-label`; it\n * shows only the submenu chevron, after a divider line. Activating the action closes the menu like\n * any item. It works the same inside a static menu.\n *\n * Also exported as `MenuSplitGroup` (import the flat name from React Server Components).\n *\n * @example\n * <Menu.SplitGroup>\n * <Menu.Item onClick={save}>Save</Menu.Item>\n * <Menu>\n * <Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={saveAs}>Save as…</Menu.Item></Menu.Popover>\n * </Menu>\n * </Menu.SplitGroup>\n */\nexport const MenuSplitGroup = ({\n children,\n className,\n onKeyDown,\n ref,\n ...rest\n}: MenuSplitGroupProps) => {\n // C-DEV: the row needs its action and its submenu to work as one.\n const complete = hasActionAndSubmenu(children);\n React.useEffect(() => {\n if (complete) return;\n warnOnce(\n 'Menu.SplitGroup:children',\n 'Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).',\n );\n }, [complete]);\n\n // Inside the row, \"next\" (ArrowRight, ArrowLeft in RTL) moves from the action to the submenu\n // half and \"previous\" back; \"next\" on the half is its trigger's (it opens the submenu, so the\n // key arrives here already handled). Keys from the submenu (a portal) are not the row's.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (!intent) return;\n const items = rowItems(event.currentTarget);\n if (items.length < 2) return;\n const action = items[0];\n const half = items[items.length - 1];\n const [from, to] = intent === 'next' ? [action, half] : [half, action];\n if (event.target !== from || to.getAttribute('aria-disabled') === 'true') return;\n event.preventDefault();\n to.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...rest}\n ref={ref}\n data-menu-split-group=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n className={cn(\n 'flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border',\n className,\n )}\n >\n {children}\n </div>\n );\n};\nMenuSplitGroup.displayName = 'MenuSplitGroup';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Menu.splitGroup.cjs","names":["flattenChildren","isElementOfType","MenuItem","MenuRoot","getArrowIntent","getDirection","composeEventHandlers","cn","menuSplitGroupClassNames","require_runtime","require_cn","require_children","require_dev","require_composeEventHandlers","require_classNames","require_direction","require_Menu_items","require_Menu_root","react","react_jsx_runtime","hasActionAndSubmenu","nodes","children","node","index","rowItems","row","child","MenuSplitGroup","rest","complete","handleKeyDown","event","intent","items","action","half","from","to","onKeyDown","className"],"sources":["../../../src/components/navigation/Menu.splitGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuSplitGroupClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { MenuItem } from './Menu.items';\nimport { MenuRoot } from './Menu.root';\nimport { MENU_ITEM_SELECTOR } from './Menu.shared';\n\n/** Properties for the MenuSplitGroup sub-component. */\nexport interface MenuSplitGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * A `Menu.Item` (the main action) followed by a submenu `<Menu>` whose `Menu.Trigger` wraps a\n * `Menu.Item` with an `aria-label` and no children, which shows only the submenu chevron:\n * `<Menu><Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover>…</Menu.Popover></Menu>`.\n */\n children: React.ReactNode;\n /** Ref to the `role=\"group\"` row. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Whether the direct children (Fragments included, Server Component references too) hold a\n * `Menu.Item` followed by a `<Menu>`.\n */\nfunction hasActionAndSubmenu(children: React.ReactNode): boolean {\n const nodes = flattenChildren(children).map(({ node }) => node);\n return nodes.some(\n (node, index) => isElementOfType(node, MenuItem) && isElementOfType(nodes[index + 1], MenuRoot),\n );\n}\n\n/** The menu items that are the row's own children (the action first, the submenu half last). */\nfunction rowItems(row: HTMLElement): HTMLElement[] {\n return Array.from(row.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement && child.matches(MENU_ITEM_SELECTOR),\n );\n}\n\n/**\n * One row with a main action and a button that opens a submenu (`role=\"group\"` holding two menu\n * items). ArrowDown and ArrowUp visit both halves; ArrowRight (ArrowLeft in RTL) moves from the\n * action to the submenu button, and on the button opens the submenu; ArrowLeft (ArrowRight in RTL)\n * moves back. The submenu half is a `Menu.Item` without children, named by its `aria-label`; it\n * shows only the submenu chevron, after a divider line. Activating the action closes the menu like\n * any item. It works the same inside a static menu.\n *\n * Also exported as `MenuSplitGroup` (import the flat name from React Server Components).\n *\n * @example\n * <Menu.SplitGroup>\n * <Menu.Item onClick={save}>Save</Menu.Item>\n * <Menu>\n * <Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={saveAs}>Save as…</Menu.Item></Menu.Popover>\n * </Menu>\n * </Menu.SplitGroup>\n */\nexport const MenuSplitGroup = ({\n children,\n className,\n onKeyDown,\n ref,\n ...rest\n}: MenuSplitGroupProps) => {\n // C-DEV: the row needs its action and its submenu to work as one.\n const complete = hasActionAndSubmenu(children);\n React.useEffect(() => {\n if (complete) return;\n warnOnce(\n 'Menu.SplitGroup:children',\n 'Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).',\n );\n }, [complete]);\n\n // Inside the row, \"next\" (ArrowRight, ArrowLeft in RTL) moves from the action to the submenu\n // half and \"previous\" back; \"next\" on the half is its trigger's (it opens the submenu, so the\n // key arrives here already handled). Keys from the submenu (a portal) are not the row's.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (!intent) return;\n const items = rowItems(event.currentTarget);\n if (items.length < 2) return;\n const action = items[0];\n const half = items[items.length - 1];\n const [from, to] = intent === 'next' ? [action, half] : [half, action];\n if (event.target !== from || to.getAttribute('aria-disabled') === 'true') return;\n event.preventDefault();\n to.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...rest}\n ref={ref}\n data-menu-split-group=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n className={cn(\n menuSplitGroupClassNames.root,\n 'flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child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AA,CAAC,MAAD,CACE,KAAK,QACL,GAAIU,EACC,MACL,wBAAsB,GACtB,UAAWvB,EAAAA,qBAAqBiC,EAAWR,CAAa,EACxD,UAAWxB,EAAAA,GACTC,EAAAA,yBAAyB,KACzB,oGACAgC,CACF,EAEC,UACE,CAAA,CAET,EACA,EAAe,YAAc"}
|
|
@@ -3,49 +3,50 @@ import { cn as e } from "../../lib/cn.mjs";
|
|
|
3
3
|
import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
|
|
4
4
|
import { warnOnce as r } from "../../lib/dev.mjs";
|
|
5
5
|
import { composeEventHandlers as i } from "../../lib/composeEventHandlers.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { menuSplitGroupClassNames as a } from "../../lib/classNames.mjs";
|
|
7
|
+
import { getArrowIntent as o, getDirection as s } from "../../lib/direction.mjs";
|
|
7
8
|
import "./Menu.shared.mjs";
|
|
8
|
-
import { MenuItem as
|
|
9
|
-
import { MenuRoot as
|
|
10
|
-
import * as
|
|
11
|
-
import { jsx as
|
|
9
|
+
import { MenuItem as c } from "./Menu.items.mjs";
|
|
10
|
+
import { MenuRoot as l } from "./Menu.root.mjs";
|
|
11
|
+
import * as u from "react";
|
|
12
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
12
13
|
//#region src/components/navigation/Menu.splitGroup.tsx
|
|
13
|
-
function
|
|
14
|
+
function f(e) {
|
|
14
15
|
let r = t(e).map(({ node: e }) => e);
|
|
15
|
-
return r.some((e, t) => n(e,
|
|
16
|
+
return r.some((e, t) => n(e, c) && n(r[t + 1], l));
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function p(e) {
|
|
18
19
|
return Array.from(e.children).filter((e) => e instanceof HTMLElement && e.matches("[role=\"menuitem\"],[role=\"menuitemcheckbox\"],[role=\"menuitemradio\"]"));
|
|
19
20
|
}
|
|
20
|
-
var
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
let
|
|
21
|
+
var m = ({ children: t, className: n, onKeyDown: c, ref: l, ...m }) => {
|
|
22
|
+
let h = f(t);
|
|
23
|
+
u.useEffect(() => {
|
|
24
|
+
h || r("Menu.SplitGroup:children", "Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).");
|
|
25
|
+
}, [h]);
|
|
26
|
+
let g = (e) => {
|
|
26
27
|
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
27
|
-
let t =
|
|
28
|
+
let t = o(e.key, {
|
|
28
29
|
orientation: "horizontal",
|
|
29
|
-
dir:
|
|
30
|
+
dir: s(e.currentTarget)
|
|
30
31
|
});
|
|
31
32
|
if (!t) return;
|
|
32
|
-
let n =
|
|
33
|
+
let n = p(e.currentTarget);
|
|
33
34
|
if (n.length < 2) return;
|
|
34
|
-
let r = n[0], i = n[n.length - 1], [
|
|
35
|
-
e.target ===
|
|
35
|
+
let r = n[0], i = n[n.length - 1], [a, c] = t === "next" ? [r, i] : [i, r];
|
|
36
|
+
e.target === a && c.getAttribute("aria-disabled") !== "true" && (e.preventDefault(), c.focus());
|
|
36
37
|
};
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
+
return /* @__PURE__ */ d("div", {
|
|
38
39
|
role: "group",
|
|
39
|
-
...
|
|
40
|
-
ref:
|
|
40
|
+
...m,
|
|
41
|
+
ref: l,
|
|
41
42
|
"data-menu-split-group": "",
|
|
42
|
-
onKeyDown: i(
|
|
43
|
-
className: e("flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border", n),
|
|
43
|
+
onKeyDown: i(c, g),
|
|
44
|
+
className: e(a.root, "flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border", n),
|
|
44
45
|
children: t
|
|
45
46
|
});
|
|
46
47
|
};
|
|
47
|
-
|
|
48
|
+
m.displayName = "MenuSplitGroup";
|
|
48
49
|
//#endregion
|
|
49
|
-
export {
|
|
50
|
+
export { m as MenuSplitGroup };
|
|
50
51
|
|
|
51
52
|
//# sourceMappingURL=Menu.splitGroup.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.splitGroup.mjs","names":["React","hasActionAndSubmenu","nodes","flattenChildren","children","node","isElementOfType","MenuItem","index","MenuRoot","rowItems","row","child","MenuSplitGroup","rest","complete","warnOnce","handleKeyDown","event","intent","getArrowIntent","getDirection","items","action","half","from","to","composeEventHandlers","onKeyDown","cn","className"],"sources":["../../../src/components/navigation/Menu.splitGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { MenuItem } from './Menu.items';\nimport { MenuRoot } from './Menu.root';\nimport { MENU_ITEM_SELECTOR } from './Menu.shared';\n\n/** Properties for the MenuSplitGroup sub-component. */\nexport interface MenuSplitGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * A `Menu.Item` (the main action) followed by a submenu `<Menu>` whose `Menu.Trigger` wraps a\n * `Menu.Item` with an `aria-label` and no children, which shows only the submenu chevron:\n * `<Menu><Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover>…</Menu.Popover></Menu>`.\n */\n children: React.ReactNode;\n /** Ref to the `role=\"group\"` row. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Whether the direct children (Fragments included, Server Component references too) hold a\n * `Menu.Item` followed by a `<Menu>`.\n */\nfunction hasActionAndSubmenu(children: React.ReactNode): boolean {\n const nodes = flattenChildren(children).map(({ node }) => node);\n return nodes.some(\n (node, index) => isElementOfType(node, MenuItem) && isElementOfType(nodes[index + 1], MenuRoot),\n );\n}\n\n/** The menu items that are the row's own children (the action first, the submenu half last). */\nfunction rowItems(row: HTMLElement): HTMLElement[] {\n return Array.from(row.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement && child.matches(MENU_ITEM_SELECTOR),\n );\n}\n\n/**\n * One row with a main action and a button that opens a submenu (`role=\"group\"` holding two menu\n * items). ArrowDown and ArrowUp visit both halves; ArrowRight (ArrowLeft in RTL) moves from the\n * action to the submenu button, and on the button opens the submenu; ArrowLeft (ArrowRight in RTL)\n * moves back. The submenu half is a `Menu.Item` without children, named by its `aria-label`; it\n * shows only the submenu chevron, after a divider line. Activating the action closes the menu like\n * any item. It works the same inside a static menu.\n *\n * Also exported as `MenuSplitGroup` (import the flat name from React Server Components).\n *\n * @example\n * <Menu.SplitGroup>\n * <Menu.Item onClick={save}>Save</Menu.Item>\n * <Menu>\n * <Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={saveAs}>Save as…</Menu.Item></Menu.Popover>\n * </Menu>\n * </Menu.SplitGroup>\n */\nexport const MenuSplitGroup = ({\n children,\n className,\n onKeyDown,\n ref,\n ...rest\n}: MenuSplitGroupProps) => {\n // C-DEV: the row needs its action and its submenu to work as one.\n const complete = hasActionAndSubmenu(children);\n React.useEffect(() => {\n if (complete) return;\n warnOnce(\n 'Menu.SplitGroup:children',\n 'Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).',\n );\n }, [complete]);\n\n // Inside the row, \"next\" (ArrowRight, ArrowLeft in RTL) moves from the action to the submenu\n // half and \"previous\" back; \"next\" on the half is its trigger's (it opens the submenu, so the\n // key arrives here already handled). Keys from the submenu (a portal) are not the row's.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (!intent) return;\n const items = rowItems(event.currentTarget);\n if (items.length < 2) return;\n const action = items[0];\n const half = items[items.length - 1];\n const [from, to] = intent === 'next' ? [action, half] : [half, action];\n if (event.target !== from || to.getAttribute('aria-disabled') === 'true') return;\n event.preventDefault();\n to.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...rest}\n ref={ref}\n data-menu-split-group=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n className={cn(\n 'flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border',\n className,\n )}\n >\n {children}\n </div>\n );\n};\nMenuSplitGroup.displayName = 'MenuSplitGroup';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Menu.splitGroup.mjs","names":["React","hasActionAndSubmenu","nodes","flattenChildren","children","node","isElementOfType","MenuItem","index","MenuRoot","rowItems","row","child","MenuSplitGroup","rest","complete","warnOnce","handleKeyDown","event","intent","getArrowIntent","getDirection","items","action","half","from","to","composeEventHandlers","onKeyDown","cn","menuSplitGroupClassNames","className"],"sources":["../../../src/components/navigation/Menu.splitGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuSplitGroupClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { MenuItem } from './Menu.items';\nimport { MenuRoot } from './Menu.root';\nimport { MENU_ITEM_SELECTOR } from './Menu.shared';\n\n/** Properties for the MenuSplitGroup sub-component. */\nexport interface MenuSplitGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * A `Menu.Item` (the main action) followed by a submenu `<Menu>` whose `Menu.Trigger` wraps a\n * `Menu.Item` with an `aria-label` and no children, which shows only the submenu chevron:\n * `<Menu><Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover>…</Menu.Popover></Menu>`.\n */\n children: React.ReactNode;\n /** Ref to the `role=\"group\"` row. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Whether the direct children (Fragments included, Server Component references too) hold a\n * `Menu.Item` followed by a `<Menu>`.\n */\nfunction hasActionAndSubmenu(children: React.ReactNode): boolean {\n const nodes = flattenChildren(children).map(({ node }) => node);\n return nodes.some(\n (node, index) => isElementOfType(node, MenuItem) && isElementOfType(nodes[index + 1], MenuRoot),\n );\n}\n\n/** The menu items that are the row's own children (the action first, the submenu half last). */\nfunction rowItems(row: HTMLElement): HTMLElement[] {\n return Array.from(row.children).filter(\n (child): child is HTMLElement =>\n child instanceof HTMLElement && child.matches(MENU_ITEM_SELECTOR),\n );\n}\n\n/**\n * One row with a main action and a button that opens a submenu (`role=\"group\"` holding two menu\n * items). ArrowDown and ArrowUp visit both halves; ArrowRight (ArrowLeft in RTL) moves from the\n * action to the submenu button, and on the button opens the submenu; ArrowLeft (ArrowRight in RTL)\n * moves back. The submenu half is a `Menu.Item` without children, named by its `aria-label`; it\n * shows only the submenu chevron, after a divider line. Activating the action closes the menu like\n * any item. It works the same inside a static menu.\n *\n * Also exported as `MenuSplitGroup` (import the flat name from React Server Components).\n *\n * @example\n * <Menu.SplitGroup>\n * <Menu.Item onClick={save}>Save</Menu.Item>\n * <Menu>\n * <Menu.Trigger><Menu.Item aria-label=\"More save options\" /></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={saveAs}>Save as…</Menu.Item></Menu.Popover>\n * </Menu>\n * </Menu.SplitGroup>\n */\nexport const MenuSplitGroup = ({\n children,\n className,\n onKeyDown,\n ref,\n ...rest\n}: MenuSplitGroupProps) => {\n // C-DEV: the row needs its action and its submenu to work as one.\n const complete = hasActionAndSubmenu(children);\n React.useEffect(() => {\n if (complete) return;\n warnOnce(\n 'Menu.SplitGroup:children',\n 'Menu.SplitGroup: expected a Menu.Item (the action) followed by a submenu <Menu> whose Menu.Trigger wraps a Menu.Item with an aria-label (its direct children, Fragments included).',\n );\n }, [complete]);\n\n // Inside the row, \"next\" (ArrowRight, ArrowLeft in RTL) moves from the action to the submenu\n // half and \"previous\" back; \"next\" on the half is its trigger's (it opens the submenu, so the\n // key arrives here already handled). Keys from the submenu (a portal) are not the row's.\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.altKey || event.ctrlKey || event.metaKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (!intent) return;\n const items = rowItems(event.currentTarget);\n if (items.length < 2) return;\n const action = items[0];\n const half = items[items.length - 1];\n const [from, to] = intent === 'next' ? [action, half] : [half, action];\n if (event.target !== from || to.getAttribute('aria-disabled') === 'true') return;\n event.preventDefault();\n to.focus();\n };\n\n return (\n <div\n role=\"group\"\n {...rest}\n ref={ref}\n data-menu-split-group=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n className={cn(\n menuSplitGroupClassNames.root,\n 'flex items-stretch [&>:first-child]:flex-1 [&>:last-child]:border-s [&>:last-child]:border-border',\n className,\n )}\n >\n {children}\n </div>\n );\n};\nMenuSplitGroup.displayName = 'MenuSplitGroup';\n"],"mappings":";;;;;;;;;;;;;AA4BA,SAASC,EAAoB,GAAoC;CAC/D,IAAMC,IAAQC,EAAgBC,CAAQ,CAAC,CAAC,KAAK,EAAE,cAAWC,CAAI;CAC9D,OAAOH,EAAM,MACV,GAAM,MAAUI,EAAgBD,GAAME,CAAQ,KAAKD,EAAgBJ,EAAMM,IAAQ,IAAIC,CAAQ,CAChG;AACF;AAGA,SAASC,EAAS,GAAiC;CACjD,OAAO,MAAM,KAAKC,EAAI,QAAQ,CAAC,CAAC,QAC7B,MACCC,aAAiB,eAAeA,EAAM,QAAA,0EAA0B,CACpE;AACF;AAqBA,IAAaC,KAAkB,EAC7B,aACA,cACA,cACA,QACA,GAAGC,QACsB;CAEzB,IAAMC,IAAWd,EAAoBG,CAAQ;CAC7C,EAAM,gBAAgB;EACpB,AAAIW,KACJC,EACE,4BACA,oLACF;CACF,GAAG,CAACD,CAAQ,CAAC;CAKb,IAAME,KAAiB,MAA+C;EACpE,IAAIC,EAAM,UAAUA,EAAM,WAAWA,EAAM,SAAS;EACpD,IAAMC,IAASC,EAAeF,EAAM,KAAK;GACvC,aAAa;GACb,KAAKG,EAAaH,EAAM,aAAa;EACvC,CAAC;EACD,IAAI,CAACC,GAAQ;EACb,IAAMG,IAAQZ,EAASQ,EAAM,aAAa;EAC1C,IAAII,EAAM,SAAS,GAAG;EACtB,IAAMC,IAASD,EAAM,IACfE,IAAOF,EAAMA,EAAM,SAAS,IAC5B,CAACG,GAAMC,KAAMP,MAAW,SAAS,CAACI,GAAQC,CAAI,IAAI,CAACA,GAAMD,CAAM;EACrE,AAAIL,EAAM,WAAWO,KAAQC,EAAG,aAAa,eAAe,MAAM,WAClER,EAAM,eAAe,GACrBQ,EAAG,MAAM;CACX;CAEA,OACE,kBAAC,OAAD;EACE,MAAK;EACL,GAAIZ;EACC;EACL,yBAAsB;EACtB,WAAWa,EAAqBC,GAAWX,CAAa;EACxD,WAAWY,EACTC,EAAyB,MACzB,qGACAC,CACF;EAEC;CACE,CAAA;AAET;AACA,EAAe,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/dev.cjs"),n=require("../../lib/direction.cjs"),r=require("../../hooks/useMergedRefs.cjs"),i=require("../../lib/mergeProps.cjs"),a=require("../../lib/
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/dev.cjs"),n=require("../../lib/direction.cjs"),r=require("../../hooks/useMergedRefs.cjs"),i=require("../../lib/mergeProps.cjs"),a=require("../../lib/events.cjs"),o=require("../../lib/renderTrigger.cjs"),s=require("../../hooks/useTriggerElement.cjs"),c=require("./Menu.context.cjs"),l=require("./Menu.shared.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f=()=>{},p=({children:e,asChild:p,ref:m,...h})=>{let{popup:g,open:_,openWithFocus:v,requestClose:y,triggerId:b,menuId:x,onTriggerId:S,triggerElement:C,setTriggerElement:w,isSubmenu:T,isHoverOpen:E,hoverTriggerHandlers:D,openOnContext:O,contextTriggerHandlers:k}=c.useMenuContext(`Menu.Trigger`);l.useStaticMenuPartWarning(`Menu.Trigger`,g);let A=r.useMergedRefs(w,m);u.useEffect(()=>{T&&C&&C.getAttribute(`role`)!==`menuitem`&&t.warnOnce(`Menu.Trigger:submenu-child`,`Menu.Trigger: a submenu's Menu.Trigger must wrap a Menu.Item: its element has no role="menuitem", so the menu does not treat it as one of its items. Put a Menu.Item inside it (and leave asChild at its default).`)},[T,C]);let j=O?typeof e==`function`?{id:b,"aria-haspopup":`menu`,"aria-expanded":!1,onClick:f,ref:A,...k}:{id:b,ref:A,...k}:{id:b,"aria-haspopup":`menu`,"aria-expanded":_,"aria-controls":_?x:void 0,onClick:e=>{e.defaultPrevented||a.isDisabledTrigger(e)||(_&&!T&&!E()?y():v(`first`))},onKeyDown:e=>{if(!(e.defaultPrevented||e.ctrlKey||e.metaKey||a.isDisabledTrigger(e))){if(T){if(e.altKey)return;(n.getArrowIntent(e.key,{orientation:`horizontal`,dir:n.getDirection(e.currentTarget)})===`next`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),v(`first`));return}switch(e.key){case`ArrowDown`:e.preventDefault(),v(`first`);break;case`ArrowUp`:e.preventDefault(),v(`last`);break;case`Enter`:case` `:e.preventDefault(),_&&!E()?y():v(`first`)}}},ref:A,...D},M=i.mergeProps(j,h,{oursWin:o.STATE_ARIA}),N=s.useTriggerElement(e,M,{componentName:`Menu.Trigger`,asChild:p,onResolvedId:S,omitStateAria:O});return T?(0,d.jsx)(c.MenuSubmenuTriggerContext.Provider,{value:!0,children:N}):N};p.displayName=`MenuTrigger`,exports.MenuTrigger=p;
|
|
2
2
|
//# sourceMappingURL=Menu.trigger.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.trigger.cjs","names":["useMenuContext","useMergedRefs","isDisabledTrigger","getArrowIntent","getDirection","mergeProps","STATE_ARIA","useTriggerElement","MenuSubmenuTriggerContext","require_runtime","require_dev","require_direction","require_useMergedRefs","require_mergeProps","require_renderTrigger","require_useTriggerElement","require_events","require_Menu_context","require_Menu_shared","react","react_jsx_runtime","noop","MenuTrigger","rest","popup","elementRef","setTriggerElement","ref","isSubmenu","triggerElement","ownProps","openOnContext","children","triggerId","contextTriggerHandlers","open","menuId","event","isHoverOpen","requestClose","openWithFocus","hoverTriggerHandlers","triggerProps","element","onTriggerId"],"sources":["../../../src/components/navigation/Menu.trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isDisabledTrigger } from '../../lib/events';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { STATE_ARIA } from '../../lib/renderTrigger';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useTriggerElement } from '../../hooks/useTriggerElement';\nimport { MenuSubmenuTriggerContext, useMenuContext } from './Menu.context';\nimport { useStaticMenuPartWarning } from './Menu.shared';\n\n/**\n * The props `Menu.Trigger` puts on its element (merged onto the single child, or passed to a\n * render-prop child — e.g. `SplitButton`'s `menuButtonProps`). A type alias (not an interface), so\n * it is assignable to prop types with index signatures such as `data-*`.\n */\nexport type MenuTriggerProps = {\n /** Generated id (the child's own `id` wins; the menu is labelled by it). */\n id: string;\n 'aria-haspopup': 'menu';\n 'aria-expanded': boolean;\n /** The menu's id, only while the menu is open. */\n 'aria-controls'?: string;\n /**\n * Toggles the menu (opening focuses the first enabled item). Ignored when the click comes from an\n * `aria-disabled=\"true\"` element at or inside the element that carries it.\n */\n onClick: React.MouseEventHandler<HTMLElement>;\n /**\n * Enter/Space/ArrowDown open and focus the first item; ArrowUp opens and focuses the last.\n * Ignored, without `preventDefault()`, when the key comes from an `aria-disabled=\"true\"` element\n * at or inside the element that carries it.\n */\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n /** Anchor for positioning and focus-restore target. */\n ref: React.RefCallback<HTMLElement>;\n /** Hover opening (`openOnHover`, and every submenu): the mouse pointer enters the trigger. */\n onPointerEnter?: React.PointerEventHandler<HTMLElement>;\n /** Hover opening: the mouse pointer moves over the trigger. */\n onPointerMove?: React.PointerEventHandler<HTMLElement>;\n /** Hover opening: the mouse pointer leaves the trigger. */\n onPointerLeave?: React.PointerEventHandler<HTMLElement>;\n /**\n * Context menus (`openOnContext`): a right click (a macOS Ctrl+click, a long press) on the\n * region opens the menu at the pointer. In that mode `aria-haspopup` is still passed to a\n * render-prop child and `aria-expanded` is always `false`, but do not spread them (or\n * `aria-controls`): a context region is no menu button, and they are removed from its element\n * after each commit.\n */\n onContextMenu?: React.MouseEventHandler<HTMLElement>;\n};\n\n/** What a context-menu region's cloned child or wrapper span receives of the trigger's own props. */\ntype ContextTriggerProps = Pick<MenuTriggerProps, 'id' | 'ref' | 'onKeyDown' | 'onContextMenu'>;\n\nconst noop = () => {};\n\n/**\n * Properties for the MenuTrigger sub-component. Other props (`aria-describedby` from a wrapping\n * `Tooltip`, `className`, `data-*`, handlers, …) are forwarded to the trigger element: merged with\n * the child's own props (handlers composed, classes joined, `aria-describedby` ids joined), or\n * passed to a render-prop child together with {@link MenuTriggerProps}.\n */\nexport interface MenuTriggerComponentProps extends Omit<\n React.HTMLAttributes<HTMLElement>,\n 'children'\n> {\n /**\n * A single element that receives {@link MenuTriggerProps} (its own handlers run first; its own\n * `id` is kept; the trigger's `aria-expanded`/`aria-controls`/`aria-haspopup` always win), or a\n * render function that receives them (plus the forwarded props).\n */\n children: React.ReactNode | ((props: MenuTriggerProps) => React.ReactNode);\n /**\n * `false` renders a wrapper `<span>` carrying the trigger props instead of merging them onto the\n * child (the 0.4-style wrapper). The state ARIA (`aria-haspopup`, `aria-expanded`,\n * `aria-controls`), which a generic span cannot carry, goes to the first element in the tab\n * order inside the span (none for text children), and focus returns to that element when the\n * menu closes. A render-prop child still receives every prop.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span); the child's own ref is kept. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/**\n * The element that opens a popup menu. Its single child receives {@link MenuTriggerProps}\n * (`aria-haspopup=\"menu\"`, `aria-expanded`, `aria-controls` while open, an id and composed\n * `onClick`/`onKeyDown`); a render function receives them instead. Click, Enter, Space and\n * ArrowDown open the menu and focus its first enabled item; ArrowUp opens it and focuses the last.\n * Other props passed to `Menu.Trigger` are forwarded to the child, so\n * `<Tooltip><Menu.Trigger><MenuButton /></Menu.Trigger></Tooltip>` describes the MenuButton.\n *\n * A trigger with `aria-disabled=\"true\"` (a `disabledFocusable` MenuButton or SplitButton) stays\n * focusable but never opens the menu: its click, Enter, Space, ArrowDown and ArrowUp are ignored\n * and keep their default. This holds for the child itself and for an element inside the wrapper\n * span; an `aria-disabled` ancestor outside the trigger does not count.\n *\n * With `asChild={false}` (and for a child that does not attach the ref, automatically) the props\n * go on a wrapper span instead; the state ARIA then goes to the first element in the tab order\n * inside it, and focus returns to that element.\n *\n * - **Hover** (`openOnHover` on the Menu): a resting mouse pointer opens the menu without moving\n * focus; a click, Enter, Space or ArrowDown on the trigger then keeps it open and focuses its\n * first item (ArrowUp: the last), instead of closing it.\n * - **Submenus**: in a `<Menu>` nested in a menu list, wrap a `Menu.Item`, which becomes the\n * submenu's trigger item (`aria-haspopup=\"menu\"`, `aria-expanded`, a chevron that mirrors in\n * RTL). ArrowRight (ArrowLeft in RTL), Enter, Space and a click open the submenu and focus its\n * first item (a click never closes it); resting the mouse on it opens the submenu without moving\n * focus. ArrowDown, ArrowUp and typeahead stay the parent list's.\n * - **Context menus** (`openOnContext` on the Menu): the child is a region (a list, a row, a\n * canvas); a right click or Shift+F10/the ContextMenu key opens the menu. A cloned child or a\n * wrapper span gets only the id, the ref and the context-gesture handlers: no state ARIA and no\n * click toggle (do not spread them from a render-prop child either).\n *\n * Also exported as `MenuTrigger` (import the flat name from React Server Components).\n *\n * @example\n * <Menu>\n * <Menu.Trigger><Button>Actions</Button></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={edit}>Edit</Menu.Item></Menu.Popover>\n * </Menu>\n */\nexport const MenuTrigger = ({ children, asChild, ref, ...rest }: MenuTriggerComponentProps) => {\n const {\n popup,\n open,\n openWithFocus,\n requestClose,\n triggerId,\n menuId,\n onTriggerId,\n triggerElement,\n setTriggerElement,\n isSubmenu,\n isHoverOpen,\n hoverTriggerHandlers,\n openOnContext,\n contextTriggerHandlers,\n } = useMenuContext('Menu.Trigger');\n useStaticMenuPartWarning('Menu.Trigger', popup);\n const elementRef = useMergedRefs<HTMLElement>(setTriggerElement, ref);\n\n // C-DEV: a submenu opens from one of its parent's items; any other element is not an item of\n // that menu (the arrow keys and typeahead skip it).\n React.useEffect(() => {\n if (!isSubmenu || !triggerElement || triggerElement.getAttribute('role') === 'menuitem') {\n return;\n }\n warnOnce(\n 'Menu.Trigger:submenu-child',\n `Menu.Trigger: a submenu's Menu.Trigger must wrap a Menu.Item: its element has no role=\"menuitem\", so the menu does not treat it as one of its items. Put a Menu.Item inside it (and leave asChild at its default).`,\n );\n }, [isSubmenu, triggerElement]);\n\n // An `aria-disabled` trigger (a focusable disabled button, a disabled trigger item) never opens\n // the menu: the event is left alone, default included, so the element keeps its own handling of\n // the key.\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (event.defaultPrevented || isDisabledTrigger(event)) return;\n // A click on the trigger of a hover-opened menu pins it and focuses its first item, as on a\n // closed menu. A submenu trigger item never toggles its submenu closed: a click on an open one\n // focuses its first item again.\n if (open && !isSubmenu && !isHoverOpen()) requestClose();\n else openWithFocus('first');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (event.defaultPrevented || event.ctrlKey || event.metaKey || isDisabledTrigger(event)) {\n return;\n }\n if (isSubmenu) {\n // \"Next\" (ArrowRight, ArrowLeft in RTL), Enter and Space open the submenu and focus its\n // first item. ArrowDown, ArrowUp and typeahead stay the parent list's.\n if (event.altKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (intent === 'next' || event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n openWithFocus('first');\n }\n return;\n }\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n openWithFocus('first');\n break;\n case 'ArrowUp':\n event.preventDefault();\n openWithFocus('last');\n break;\n case 'Enter':\n case ' ':\n // Handled here (not through the native click) so non-button children work too.\n event.preventDefault();\n if (open && !isHoverOpen()) requestClose();\n else openWithFocus('first');\n break;\n default:\n break;\n }\n };\n\n // A context-menu region is no menu button: of its own props a cloned child or a wrapper span\n // gets only the id, the ref and the context-gesture handlers (no state ARIA, no click toggle). A\n // render-prop child still receives every member (`aria-expanded` constantly false, an onClick\n // that does nothing); useTriggerElement removes the state ARIA it spreads.\n const ownProps: MenuTriggerProps | ContextTriggerProps = openOnContext\n ? typeof children === 'function'\n ? {\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': false,\n onClick: noop,\n ref: elementRef,\n ...contextTriggerHandlers,\n }\n : { id: triggerId, ref: elementRef, ...contextTriggerHandlers }\n : {\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': open,\n 'aria-controls': open ? menuId : undefined,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n ref: elementRef,\n ...hoverTriggerHandlers,\n };\n // §5.3: forwarded props merge in (a consumer `id` wins, handlers compose consumer-first), but the\n // live state ARIA always wins. On a wrapper span (`asChild={false}`, the automatic fallback)\n // useTriggerElement moves the state ARIA onto the first element in the tab order inside it.\n const triggerProps = mergeProps(ownProps, rest, { oursWin: STATE_ARIA });\n\n // A render-prop child always gets the full MenuTriggerProps; the context region's reduced props\n // reach only a cloned child or a wrapper span.\n const element = useTriggerElement(children, triggerProps as MenuTriggerProps, {\n componentName: 'Menu.Trigger',\n asChild,\n onResolvedId: onTriggerId,\n omitStateAria: openOnContext,\n });\n // The Menu.Item a submenu opens from shows the submenu chevron and never closes its own menu.\n return isSubmenu ? (\n <MenuSubmenuTriggerContext.Provider value>{element}</MenuSubmenuTriggerContext.Provider>\n ) : (\n element\n );\n};\nMenuTrigger.displayName = 'MenuTrigger';\n"],"mappings":"8dAuDA,IAAMqB,MAAa,CAAC,EAqEPC,GAAe,CAAE,WAAU,UAAS,MAAK,GAAGC,KAAsC,CAC7F,GAAM,CACJ,QACA,OACA,gBACA,eACA,YACA,SACA,cACA,iBACA,oBACA,YACA,cACA,uBACA,gBACA,0BACEvB,EAAAA,eAAe,cAAc,EACjCkB,EAAA,yBAAyB,eAAgBM,CAAK,EAC9C,IAAMC,EAAaxB,EAAAA,cAA2ByB,EAAmBC,CAAG,EAIpER,EAAM,cAAgB,CACfS,GAAcC,GAAkBA,EAAe,aAAa,MAAM,IAAM,YAG7EnB,EAAA,SACE,6BACA,oNACF,CACF,EAAG,CAACkB,EAAWC,CAAc,CAAC,EAyD9B,IAAMC,EAAmDC,EACrD,OAAOC,GAAa,WAClB,CACE,GAAIC,EACJ,gBAAiB,OACjB,gBAAiB,GACjB,QAASZ,EACT,IAAKI,EACL,GAAGS,CACL,EACA,CAAE,GAAID,EAAW,IAAKR,EAAY,GAAGS,CAAuB,EAC9D,CACE,GAAID,EACJ,gBAAiB,OACjB,gBAAiBE,EACjB,gBAAiBA,EAAOC,EAAS,IAAA,GACjC,QApEe,GAAyC,CACxDC,EAAM,kBAAoBnC,EAAAA,kBAAkBmC,CAAK,IAIjDF,GAAQ,CAACP,GAAa,CAACU,EAAY,EAAGC,EAAa,EAClDC,EAAc,OAAO,EAC5B,EA8DM,UA5DiB,GAA4C,CACjE,GAAI,IAAM,kBAAoBH,EAAM,SAAWA,EAAM,SAAWnC,EAAAA,kBAAkBmC,CAAK,GAGvF,IAAIT,EAAW,CAGb,GAAIS,EAAM,OAAQ,QACHlC,EAAAA,eAAekC,EAAM,IAAK,CACvC,YAAa,aACb,IAAKjC,EAAAA,aAAaiC,EAAM,aAAa,CACvC,CACI,IAAW,QAAUA,EAAM,MAAQ,SAAWA,EAAM,MAAQ,OAC9DA,EAAM,eAAe,EACrBG,EAAc,OAAO,GAEvB,MACF,CACA,OAAQH,EAAM,IAAd,CACE,IAAK,YACHA,EAAM,eAAe,EACrBG,EAAc,OAAO,EACrB,MACF,IAAK,UACHH,EAAM,eAAe,EACrBG,EAAc,MAAM,EACpB,MACF,IAAK,QACL,IAAK,IAEHH,EAAM,eAAe,EACjBF,GAAQ,CAACG,EAAY,EAAGC,EAAa,EACpCC,EAAc,OAAO,CAI9B,CAnBA,CAoBF,EAwBM,IAAKf,EACL,GAAGgB,CACL,EAIEC,EAAerC,EAAAA,WAAWyB,EAAUP,EAAM,CAAE,QAASjB,EAAAA,UAAW,CAAC,EAIjEqC,EAAUpC,EAAAA,kBAAkByB,EAAUU,EAAkC,CAC5E,cAAe,eACf,UACA,aAAcE,EACd,cAAeb,CACjB,CAAC,EAED,OAAOH,GACL,EAAAR,EAAA,IAAA,CAACZ,EAAAA,0BAA0B,SAA3B,CAAoC,MAAA,GAAO,SAAAmC,CAA4C,CAAA,EAEvFA,CAEJ,EACA,EAAY,YAAc"}
|
|
1
|
+
{"version":3,"file":"Menu.trigger.cjs","names":["useMenuContext","useMergedRefs","isDisabledTrigger","getArrowIntent","getDirection","mergeProps","STATE_ARIA","useTriggerElement","MenuSubmenuTriggerContext","require_runtime","require_dev","require_direction","require_useMergedRefs","require_mergeProps","require_events","require_renderTrigger","require_useTriggerElement","require_Menu_context","require_Menu_shared","react","react_jsx_runtime","noop","MenuTrigger","rest","popup","elementRef","setTriggerElement","ref","isSubmenu","triggerElement","ownProps","openOnContext","children","triggerId","contextTriggerHandlers","open","menuId","event","isHoverOpen","requestClose","openWithFocus","hoverTriggerHandlers","triggerProps","element","onTriggerId"],"sources":["../../../src/components/navigation/Menu.trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isDisabledTrigger } from '../../lib/events';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { STATE_ARIA } from '../../lib/renderTrigger';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useTriggerElement } from '../../hooks/useTriggerElement';\nimport { MenuSubmenuTriggerContext, useMenuContext } from './Menu.context';\nimport { useStaticMenuPartWarning } from './Menu.shared';\n\n/**\n * The props `Menu.Trigger` puts on its element (merged onto the single child, or passed to a\n * render-prop child — e.g. `SplitButton`'s `menuButtonProps`). A type alias (not an interface), so\n * it is assignable to prop types with index signatures such as `data-*`.\n */\nexport type MenuTriggerProps = {\n /** Generated id (the child's own `id` wins; the menu is labelled by it). */\n id: string;\n 'aria-haspopup': 'menu';\n 'aria-expanded': boolean;\n /** The menu's id, only while the menu is open. */\n 'aria-controls'?: string;\n /**\n * Toggles the menu (opening focuses the first enabled item). Ignored when the click comes from an\n * `aria-disabled=\"true\"` element at or inside the element that carries it.\n */\n onClick: React.MouseEventHandler<HTMLElement>;\n /**\n * Enter/Space/ArrowDown open and focus the first item; ArrowUp opens and focuses the last.\n * Ignored, without `preventDefault()`, when the key comes from an `aria-disabled=\"true\"` element\n * at or inside the element that carries it.\n */\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n /** Anchor for positioning and focus-restore target. */\n ref: React.RefCallback<HTMLElement>;\n /** Hover opening (`openOnHover`, and every submenu): the mouse pointer enters the trigger. */\n onPointerEnter?: React.PointerEventHandler<HTMLElement>;\n /** Hover opening: the mouse pointer moves over the trigger. */\n onPointerMove?: React.PointerEventHandler<HTMLElement>;\n /** Hover opening: the mouse pointer leaves the trigger. */\n onPointerLeave?: React.PointerEventHandler<HTMLElement>;\n /**\n * Context menus (`openOnContext`): a right click (a macOS Ctrl+click, a long press) on the\n * region opens the menu at the pointer. In that mode `aria-haspopup` is still passed to a\n * render-prop child and `aria-expanded` is always `false`, but do not spread them (or\n * `aria-controls`): a context region is no menu button, and they are removed from its element\n * after each commit.\n */\n onContextMenu?: React.MouseEventHandler<HTMLElement>;\n};\n\n/** What a context-menu region's cloned child or wrapper span receives of the trigger's own props. */\ntype ContextTriggerProps = Pick<MenuTriggerProps, 'id' | 'ref' | 'onKeyDown' | 'onContextMenu'>;\n\nconst noop = () => {};\n\n/**\n * Properties for the MenuTrigger sub-component. Other props (`aria-describedby` from a wrapping\n * `Tooltip`, `className`, `data-*`, handlers, …) are forwarded to the trigger element: merged with\n * the child's own props (handlers composed, classes joined, `aria-describedby` ids joined), or\n * passed to a render-prop child together with {@link MenuTriggerProps}.\n */\nexport interface MenuTriggerComponentProps extends Omit<\n React.HTMLAttributes<HTMLElement>,\n 'children'\n> {\n /**\n * A single element that receives {@link MenuTriggerProps} (its own handlers run first; its own\n * `id` is kept; the trigger's `aria-expanded`/`aria-controls`/`aria-haspopup` always win), or a\n * render function that receives them (plus the forwarded props).\n */\n children: React.ReactNode | ((props: MenuTriggerProps) => React.ReactNode);\n /**\n * `false` renders a wrapper `<span>` carrying the trigger props instead of merging them onto the\n * child (the 0.4-style wrapper). The state ARIA (`aria-haspopup`, `aria-expanded`,\n * `aria-controls`), which a generic span cannot carry, goes to the first element in the tab\n * order inside the span (none for text children), and focus returns to that element when the\n * menu closes. A render-prop child still receives every prop.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span); the child's own ref is kept. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/**\n * The element that opens a popup menu. Its single child receives {@link MenuTriggerProps}\n * (`aria-haspopup=\"menu\"`, `aria-expanded`, `aria-controls` while open, an id and composed\n * `onClick`/`onKeyDown`); a render function receives them instead. Click, Enter, Space and\n * ArrowDown open the menu and focus its first enabled item; ArrowUp opens it and focuses the last.\n * Other props passed to `Menu.Trigger` are forwarded to the child, so\n * `<Tooltip><Menu.Trigger><MenuButton /></Menu.Trigger></Tooltip>` describes the MenuButton.\n *\n * A trigger with `aria-disabled=\"true\"` (a `disabledFocusable` MenuButton or SplitButton) stays\n * focusable but never opens the menu: its click, Enter, Space, ArrowDown and ArrowUp are ignored\n * and keep their default. This holds for the child itself and for an element inside the wrapper\n * span; an `aria-disabled` ancestor outside the trigger does not count.\n *\n * With `asChild={false}` (and for a child that does not attach the ref, automatically) the props\n * go on a wrapper span instead; the state ARIA then goes to the first element in the tab order\n * inside it, and focus returns to that element.\n *\n * - **Hover** (`openOnHover` on the Menu): a resting mouse pointer opens the menu without moving\n * focus; a click, Enter, Space or ArrowDown on the trigger then keeps it open and focuses its\n * first item (ArrowUp: the last), instead of closing it.\n * - **Submenus**: in a `<Menu>` nested in a menu list, wrap a `Menu.Item`, which becomes the\n * submenu's trigger item (`aria-haspopup=\"menu\"`, `aria-expanded`, a chevron that mirrors in\n * RTL). ArrowRight (ArrowLeft in RTL), Enter, Space and a click open the submenu and focus its\n * first item (a click never closes it); resting the mouse on it opens the submenu without moving\n * focus. ArrowDown, ArrowUp and typeahead stay the parent list's.\n * - **Context menus** (`openOnContext` on the Menu): the child is a region (a list, a row, a\n * canvas); a right click or Shift+F10/the ContextMenu key opens the menu. A cloned child or a\n * wrapper span gets only the id, the ref and the context-gesture handlers: no state ARIA and no\n * click toggle (do not spread them from a render-prop child either).\n *\n * Also exported as `MenuTrigger` (import the flat name from React Server Components).\n *\n * @example\n * <Menu>\n * <Menu.Trigger><Button>Actions</Button></Menu.Trigger>\n * <Menu.Popover><Menu.Item onClick={edit}>Edit</Menu.Item></Menu.Popover>\n * </Menu>\n */\nexport const MenuTrigger = ({ children, asChild, ref, ...rest }: MenuTriggerComponentProps) => {\n const {\n popup,\n open,\n openWithFocus,\n requestClose,\n triggerId,\n menuId,\n onTriggerId,\n triggerElement,\n setTriggerElement,\n isSubmenu,\n isHoverOpen,\n hoverTriggerHandlers,\n openOnContext,\n contextTriggerHandlers,\n } = useMenuContext('Menu.Trigger');\n useStaticMenuPartWarning('Menu.Trigger', popup);\n const elementRef = useMergedRefs<HTMLElement>(setTriggerElement, ref);\n\n // C-DEV: a submenu opens from one of its parent's items; any other element is not an item of\n // that menu (the arrow keys and typeahead skip it).\n React.useEffect(() => {\n if (!isSubmenu || !triggerElement || triggerElement.getAttribute('role') === 'menuitem') {\n return;\n }\n warnOnce(\n 'Menu.Trigger:submenu-child',\n `Menu.Trigger: a submenu's Menu.Trigger must wrap a Menu.Item: its element has no role=\"menuitem\", so the menu does not treat it as one of its items. Put a Menu.Item inside it (and leave asChild at its default).`,\n );\n }, [isSubmenu, triggerElement]);\n\n // An `aria-disabled` trigger (a focusable disabled button, a disabled trigger item) never opens\n // the menu: the event is left alone, default included, so the element keeps its own handling of\n // the key.\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (event.defaultPrevented || isDisabledTrigger(event)) return;\n // A click on the trigger of a hover-opened menu pins it and focuses its first item, as on a\n // closed menu. A submenu trigger item never toggles its submenu closed: a click on an open one\n // focuses its first item again.\n if (open && !isSubmenu && !isHoverOpen()) requestClose();\n else openWithFocus('first');\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n if (event.defaultPrevented || event.ctrlKey || event.metaKey || isDisabledTrigger(event)) {\n return;\n }\n if (isSubmenu) {\n // \"Next\" (ArrowRight, ArrowLeft in RTL), Enter and Space open the submenu and focus its\n // first item. ArrowDown, ArrowUp and typeahead stay the parent list's.\n if (event.altKey) return;\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (intent === 'next' || event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n openWithFocus('first');\n }\n return;\n }\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n openWithFocus('first');\n break;\n case 'ArrowUp':\n event.preventDefault();\n openWithFocus('last');\n break;\n case 'Enter':\n case ' ':\n // Handled here (not through the native click) so non-button children work too.\n event.preventDefault();\n if (open && !isHoverOpen()) requestClose();\n else openWithFocus('first');\n break;\n default:\n break;\n }\n };\n\n // A context-menu region is no menu button: of its own props a cloned child or a wrapper span\n // gets only the id, the ref and the context-gesture handlers (no state ARIA, no click toggle). A\n // render-prop child still receives every member (`aria-expanded` constantly false, an onClick\n // that does nothing); useTriggerElement removes the state ARIA it spreads.\n const ownProps: MenuTriggerProps | ContextTriggerProps = openOnContext\n ? typeof children === 'function'\n ? {\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': false,\n onClick: noop,\n ref: elementRef,\n ...contextTriggerHandlers,\n }\n : { id: triggerId, ref: elementRef, ...contextTriggerHandlers }\n : {\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': open,\n 'aria-controls': open ? menuId : undefined,\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n ref: elementRef,\n ...hoverTriggerHandlers,\n };\n // §5.3: forwarded props merge in (a consumer `id` wins, handlers compose consumer-first), but the\n // live state ARIA always wins. On a wrapper span (`asChild={false}`, the automatic fallback)\n // useTriggerElement moves the state ARIA onto the first element in the tab order inside it.\n const triggerProps = mergeProps(ownProps, rest, { oursWin: STATE_ARIA });\n\n // A render-prop child always gets the full MenuTriggerProps; the context region's reduced props\n // reach only a cloned child or a wrapper span.\n const element = useTriggerElement(children, triggerProps as MenuTriggerProps, {\n componentName: 'Menu.Trigger',\n asChild,\n onResolvedId: onTriggerId,\n omitStateAria: openOnContext,\n });\n // The Menu.Item a submenu opens from shows the submenu chevron and never closes its own menu.\n return isSubmenu ? (\n <MenuSubmenuTriggerContext.Provider value>{element}</MenuSubmenuTriggerContext.Provider>\n ) : (\n element\n );\n};\nMenuTrigger.displayName = 'MenuTrigger';\n"],"mappings":"8dAuDA,IAAMqB,MAAa,CAAC,EAqEPC,GAAe,CAAE,WAAU,UAAS,MAAK,GAAGC,KAAsC,CAC7F,GAAM,CACJ,QACA,OACA,gBACA,eACA,YACA,SACA,cACA,iBACA,oBACA,YACA,cACA,uBACA,gBACA,0BACEvB,EAAAA,eAAe,cAAc,EACjCkB,EAAA,yBAAyB,eAAgBM,CAAK,EAC9C,IAAMC,EAA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AAAA,WAAWyB,EAAUP,EAAM,CAAE,QAASjB,EAAAA,UAAW,CAAC,EAIjEqC,EAAUpC,EAAAA,kBAAkByB,EAAUU,EAAkC,CAC5E,cAAe,eACf,UACA,aAAcE,EACd,cAAeb,CACjB,CAAC,EAED,OAAOH,GACL,EAAAR,EAAA,IAAA,CAACZ,EAAAA,0BAA0B,SAA3B,CAAoC,MAAA,GAAO,SAAAmC,CAA4C,CAAA,EAEvFA,CAEJ,EACA,EAAY,YAAc"}
|
|
@@ -3,9 +3,9 @@ import { warnOnce as e } from "../../lib/dev.mjs";
|
|
|
3
3
|
import { getArrowIntent as t, getDirection as n } from "../../lib/direction.mjs";
|
|
4
4
|
import { useMergedRefs as r } from "../../hooks/useMergedRefs.mjs";
|
|
5
5
|
import { mergeProps as i } from "../../lib/mergeProps.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { isDisabledTrigger as a } from "../../lib/events.mjs";
|
|
7
|
+
import { STATE_ARIA as o } from "../../lib/renderTrigger.mjs";
|
|
8
|
+
import { useTriggerElement as s } from "../../hooks/useTriggerElement.mjs";
|
|
9
9
|
import { MenuSubmenuTriggerContext as c, useMenuContext as l } from "./Menu.context.mjs";
|
|
10
10
|
import { useStaticMenuPartWarning as u } from "./Menu.shared.mjs";
|
|
11
11
|
import * as d from "react";
|
|
@@ -35,10 +35,10 @@ var p = () => {}, m = ({ children: m, asChild: h, ref: g, ..._ }) => {
|
|
|
35
35
|
"aria-expanded": y,
|
|
36
36
|
"aria-controls": y ? C : void 0,
|
|
37
37
|
onClick: (e) => {
|
|
38
|
-
e.defaultPrevented ||
|
|
38
|
+
e.defaultPrevented || a(e) || (y && !D && !O() ? x() : b("first"));
|
|
39
39
|
},
|
|
40
40
|
onKeyDown: (e) => {
|
|
41
|
-
if (!(e.defaultPrevented || e.ctrlKey || e.metaKey ||
|
|
41
|
+
if (!(e.defaultPrevented || e.ctrlKey || e.metaKey || a(e))) {
|
|
42
42
|
if (D) {
|
|
43
43
|
if (e.altKey) return;
|
|
44
44
|
(t(e.key, {
|
|
@@ -61,7 +61,7 @@ var p = () => {}, m = ({ children: m, asChild: h, ref: g, ..._ }) => {
|
|
|
61
61
|
},
|
|
62
62
|
ref: M,
|
|
63
63
|
...k
|
|
64
|
-
}, P = i(N, _, { oursWin:
|
|
64
|
+
}, P = i(N, _, { oursWin: o }), F = s(m, P, {
|
|
65
65
|
componentName: "Menu.Trigger",
|
|
66
66
|
asChild: h,
|
|
67
67
|
onResolvedId: w,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../hooks/useEventCallback.cjs"),
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/classNames.cjs"),o=require("../../hooks/useEventCallback.cjs"),s=require("../../hooks/useControllable.cjs"),c=require("../../hooks/useId.cjs"),l=require("../../lib/styles.cjs"),u=require("../../lib/icons.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");function p(){let e=new Map,t=new Set,n=()=>t.forEach(e=>e());return{record(t,r){(e.get(t)??null)!==r&&(r===null?e.delete(t):e.set(t,r),n())},forget(t,r){e.get(t)===r&&(e.delete(t),n())},get:t=>e.get(t),subscribe(e){return t.add(e),()=>{t.delete(e)}}}}var m=d.createContext(null);m.displayName=`NavContext`;var h=()=>{},g={value:``,select:h,openCategories:[],toggleCategory:h,registerValue:()=>h,currentCategory:void 0,categoryStore:{record:h,forget:h,get:()=>void 0,subscribe:()=>h}},_=d.createContext(null);_.displayName=`NavCategoryValueContext`;function v(e){return d.useContext(m)||(r.reportMissingContext(e,`Nav`),g)}function y(e,t){r.warnOnce(`Nav:duplicate-${e}:${t}`,e===`item`?`Nav: several items share the value "${t}". Nav.Item and Nav.SubItem values must be unique within a Nav; every item with the current value is marked as the current page.`:`Nav: several categories share the value "${t}". Nav.Category values must be unique within a Nav; they open and close together.`)}function b(e,t,n){let{registerValue:r}=e;d.useEffect(()=>r(t,n),[r,t,n])}function x(e,t){let n=d.useContext(_),{categoryStore:r}=e;d.useLayoutEffect(()=>{r.record(t,n)},[r,t,n])}var S=`flex h-5 w-5 shrink-0 items-center justify-center`;function C(e,n){return e&&i.slotRendersContent(e)?i.renderSlot(e,`span`,t.cn(n,S),{"aria-hidden":!0}):null}var w={base:t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,l.focusRingInset,l.disabledStyles),selected:`bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary`,idle:`text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`},T={base:t.cn(`flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,l.focusRingInset,l.disabledStyles),selected:`text-primary font-semibold`,idle:`text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`},E=t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none`,`data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary`,l.focusRingInset);function D(e){let{children:t}=e.props;return typeof t==`function`?void 0:t}function O(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&typeof e.then==`function`}function k(e,t){if(Array.isArray(e)){for(let n of e)k(n,t);return}try{d.Children.forEach(e,e=>{d.isValidElement(e)&&t(e)})}catch(e){if(!O(e))throw e}}function A(e,...t){return t.includes(n.getElementType(e,{suspend:!1}))}function j(e,t){let n=!1;return k(e,e=>{n||=A(e,I,L)&&e.props.value===t?!0:j(D(e),t)}),n}function M(e,t){let n=[];if(!t)return n;let r=e=>{k(e,e=>{let i=D(e);A(e,F)&&typeof e.props.value==`string`&&j(i,t)&&n.push(e.props.value),r(i)})};return r(e),n}function N(e){if(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;let t=e.currentTarget,n=t.getAttribute(`target`);return!!n&&n.toLowerCase()!==`_self`||t.hasAttribute(`download`)}function P(e,n,r,i,a){let{value:o,icon:s,disabled:c=!1,href:l,className:u,children:d,onClick:p,ref:m,...h}=e,g=n.value===o,_=l!==void 0,v=e=>{if(c){e.preventDefault();return}p?.(e),!(_?!e.defaultPrevented&&N(e):e.defaultPrevented)&&n.select(o)},y=(0,f.jsxs)(f.Fragment,{children:[a&&C(s,i.icon),a?(0,f.jsx)(`span`,{className:t.cn(i.content,`flex-1 text-start`),children:d}):d]}),b=t.cn(i.root,r.base,g?r.selected:r.idle,u);if(_)return(0,f.jsx)(`li`,{className:i.listItem,children:(0,f.jsx)(`a`,{...h,ref:m,href:c?void 0:l,role:c?`link`:h.role,"aria-disabled":c?!0:h[`aria-disabled`],"aria-current":g?`page`:void 0,onClick:v,className:b,children:y})});let{rel:x,...S}=h;return(0,f.jsx)(`li`,{className:i.listItem,children:(0,f.jsx)(`button`,{type:`button`,...S,ref:m,disabled:c,"aria-current":g?`page`:void 0,onClick:v,className:b,children:y})})}var F=({value:e,label:n,icon:i,className:o,children:s,ref:l,...p})=>{let m=v(`Nav.Category`),{value:h,openCategories:g,toggleCategory:y,currentCategory:x,categoryStore:S}=m;b(m,`category`,e);let w=c.useId(`wave-nav-category`),T=g.includes(e),D=!T&&h!==``&&j(s,h),O=d.useSyncExternalStore(S.subscribe,()=>h!==``&&S.get(h)===e,()=>!1);d.useLayoutEffect(()=>{if(D)return S.record(h,e),()=>S.forget(h,e)},[S,D,h,e]);let k=!T&&(x===e||O||D),A=n,M=s;if(n===void 0){r.warnDeprecated(`Nav.Category`,`text children as the label`,`label`,"Pass the category label in `label` and only the sub-items as children.");let e=d.Children.toArray(s),t=e=>typeof e==`string`||typeof e==`number`;A=e.filter(t).join(``),M=e.filter(e=>!t(e))}return(0,f.jsxs)(`li`,{ref:l,...p,className:t.cn(a.navCategoryClassNames.root,o),children:[(0,f.jsxs)(`button`,{type:`button`,"aria-expanded":T,"aria-controls":T?w:void 0,"aria-current":k?!0:void 0,"data-contains-current":k?``:void 0,onClick:()=>y(e),className:t.cn(a.navCategoryClassNames.button,E),children:[C(i,a.navCategoryClassNames.icon),(0,f.jsx)(`span`,{className:t.cn(a.navCategoryClassNames.label,`flex-1 text-start`),children:A}),(0,f.jsx)(u.ChevronDownIcon,{className:t.cn(a.navCategoryClassNames.expandIcon,`shrink-0 transition-transform motion-reduce:transition-none`,T&&`rotate-180`)})]}),T&&(0,f.jsx)(_.Provider,{value:e,children:(0,f.jsx)(`ul`,{id:w,className:t.cn(a.navCategoryClassNames.list,`m-0 list-none p-0`),children:M})})]})};F.displayName=`NavCategory`;function I(e){let t=v(`Nav.Item`);return b(t,`item`,e.value),x(t,e.value),P(e,t,w,{root:a.navItemClassNames.root,listItem:a.navItemClassNames.listItem,icon:a.navItemClassNames.icon,content:a.navItemClassNames.content},!0)}I.displayName=`NavItem`;function L(e){let t=v(`Nav.SubItem`);return b(t,`item`,e.value),x(t,e.value),P(e,t,T,{root:a.navSubItemClassNames.root,listItem:a.navSubItemClassNames.listItem},!1)}L.displayName=`NavSubItem`;var R=({value:e,defaultValue:n,onValueChange:i,selectedValue:c,defaultSelectedValue:l,onNavItemSelect:u,openCategories:h,defaultOpenCategories:g,onOpenCategoriesChange:_,currentCategory:v,className:b,children:x,ref:S,...C})=>{let w=r.resolveDeprecatedProp(`Nav`,e,c,`selectedValue`,`value`),T=r.resolveDeprecatedProp(`Nav`,n,l,`defaultSelectedValue`,`defaultValue`)??``;u!==void 0&&r.warnDeprecated(`Nav`,`onNavItemSelect`,`onValueChange`);let[E,D]=s.useControllable(w,T,i),O=o.useEventCallback(u),k=d.useCallback(e=>{D(e),O(e)},[D,O]),[A]=d.useState(()=>g??M(x,w??T)),[j,N]=s.useControllable(h,A,e=>_?.([...e])),P=d.useCallback(e=>{N(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[N]),F=d.useRef(null),I=d.useCallback((e,t)=>{let n=F.current??=new Map,r=`${e}:${t}`,i=(n.get(r)??0)+1;return n.set(r,i),i>1&&y(e,t),()=>{let e=(n.get(r)??1)-1;e>0?n.set(r,e):n.delete(r)}},[]),[L]=d.useState(p),R=d.useMemo(()=>({value:E,select:k,openCategories:j,toggleCategory:P,registerValue:I,currentCategory:v,categoryStore:L}),[E,k,j,P,I,v,L]);return(0,f.jsx)(m.Provider,{value:R,children:(0,f.jsx)(`nav`,{"aria-label":`Navigation`,...C,ref:S,className:t.cn(a.navClassNames.root,`w-60 border-e border-border bg-background py-2`,b),children:(0,f.jsx)(`ul`,{className:t.cn(a.navClassNames.list,`m-0 list-none p-0`),children:x})})})};R.displayName=`Nav`;var z=Object.assign(R,{Category:F,Item:I,SubItem:L});exports.Nav=z,exports.NavCategory=F,exports.NavItem=I,exports.NavSubItem=L;
|
|
2
2
|
//# sourceMappingURL=Nav.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Nav.cjs","names":["React","slotRendersContent","renderSlot","cn","focusRingInset","disabledStyles","getElementType","_Fragment","useId","ChevronDownIcon","resolveDeprecatedProp","useControllable","useEventCallback","require_runtime","require_cn","require_children","require_dev","require_slot","require_useEventCallback","require_useControllable","require_useId","require_styles","require_icons","react","react_jsx_runtime","createCategoryStore","categories","listeners","notify","listener","value","category","NavContext","noop","INERT_NAV_CONTEXT","NavCategoryValueContext","useNavContext","componentName","warnDuplicateValue","kind","useNavValue","context","registerValue","useRecordCategory","categoryStore","iconClasses","renderIcon","icon","itemClasses","subItemClasses","categoryButtonClasses","childrenOf","element","children","isThenable","forEachElement","nodes","node","visit","child","error","isPart","types","containsValue","found","NavItem","NavSubItem","selected","findCategoriesContaining","result","current","inner","NavCategory","opensElsewhere","event","link","target","renderNavEntry","rest","props","isSelected","isLink","href","handleClick","disabled","onClick","content","withIcon","entryClassName","classes","className","buttonRest","currentValue","listId","isOpen","openCategories","holdsCurrentChild","holdsShownCurrent","containsCurrent","currentCategory","buttonLabel","label","items","parts","isText","part","toggleCategory","NavRoot","valueProp","defaultValueProp","openCategoriesProp","controlledValue","selectedValue","defaultValue","defaultSelectedValue","onNavItemSelect","setValue","onValueChange","notifyNavItemSelect","select","next","initialOpenCategories","defaultOpenCategories","setOpenCategories","onOpenCategoriesChange","previous","entry","valueCountsRef","counts","key","count","remaining","contextValue","Nav"],"sources":["../../../src/components/navigation/Nav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport type { Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport {\n reportMissingContext,\n resolveDeprecatedProp,\n warnDeprecated,\n warnOnce,\n} from '../../lib/dev';\nimport { getElementType } from '../../lib/children';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n/** The two value namespaces of a Nav: items (Nav.Item and Nav.SubItem) and categories. */\ntype NavValueKind = 'item' | 'category';\n\n/**\n * The category each sub-item was last shown in, by sub-item value: written from layout effects by\n * the mounted sub-items and by a closed category whose children hold the current value, read by\n * the categories with `useSyncExternalStore`. An entry outlives its sub-item, so a category closed\n * after its current sub-item was shown still knows it contains the current page.\n */\ninterface NavCategoryStore {\n /**\n * Records the category a mounted item renders in, or a closed category whose children hold the\n * value; `null` (an item outside any category) forgets an earlier entry, so a value moved out of\n * a category no longer marks it.\n */\n record: (value: string, category: string | null) => void;\n /** Forgets the entry of `value` while it is still `category`. */\n forget: (value: string, category: string) => void;\n /** The category last recorded for a sub-item value. */\n get: (value: string) => string | undefined;\n subscribe: (listener: () => void) => () => void;\n}\n\nfunction createCategoryStore(): NavCategoryStore {\n const categories = new Map<string, string>();\n const listeners = new Set<() => void>();\n const notify = () => listeners.forEach((listener) => listener());\n return {\n record(value, category) {\n if ((categories.get(value) ?? null) === category) return;\n if (category === null) categories.delete(value);\n else categories.set(value, category);\n notify();\n },\n forget(value, category) {\n if (categories.get(value) !== category) return;\n categories.delete(value);\n notify();\n },\n get: (value) => categories.get(value),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\ninterface NavContextValue {\n /** The selected item value (`''` when nothing is selected). */\n value: string;\n /** Selects an item (activation handler: also fires the deprecated `onNavItemSelect`). */\n select: (value: string) => void;\n openCategories: readonly string[];\n toggleCategory: (value: string) => void;\n /** Registers a mounted item or category value (duplicate warning); returns the cleanup. */\n registerValue: (kind: NavValueKind, value: string) => () => void;\n /** The `currentCategory` hint of the Nav. */\n currentCategory: string | undefined;\n categoryStore: NavCategoryStore;\n}\n\nconst NavContext = React.createContext<NavContextValue | null>(null);\nNavContext.displayName = 'NavContext';\n\nconst noop = () => {};\nconst INERT_NAV_CONTEXT: NavContextValue = {\n value: '',\n select: noop,\n openCategories: [],\n toggleCategory: noop,\n registerValue: () => noop,\n currentCategory: undefined,\n categoryStore: { record: noop, forget: noop, get: () => undefined, subscribe: () => noop },\n};\n\n/**\n * The value of the Nav.Category a sub-item renders in (`null` outside a category). It renders no\n * element; a sub-item outside a category is valid, so there is no missing-context error.\n */\nconst NavCategoryValueContext = React.createContext<string | null>(null);\nNavCategoryValueContext.displayName = 'NavCategoryValueContext';\n\n/** C-CONTEXT: throws in development, logs once and returns an inert value in production. */\nfunction useNavContext(componentName: string): NavContextValue {\n const context = React.useContext(NavContext);\n if (context) return context;\n reportMissingContext(componentName, 'Nav');\n return INERT_NAV_CONTEXT;\n}\n\nfunction warnDuplicateValue(kind: NavValueKind, value: string): void {\n warnOnce(\n `Nav:duplicate-${kind}:${value}`,\n kind === 'item'\n ? `Nav: several items share the value \"${value}\". Nav.Item and Nav.SubItem values must be unique within a Nav; every item with the current value is marked as the current page.`\n : `Nav: several categories share the value \"${value}\". Nav.Category values must be unique within a Nav; they open and close together.`,\n );\n}\n\n/** Registers the value of a mounted item or category, so Nav can warn about duplicates. */\nfunction useNavValue(context: NavContextValue, kind: NavValueKind, value: string): void {\n const { registerValue } = context;\n React.useEffect(() => registerValue(kind, value), [registerValue, kind, value]);\n}\n\n/**\n * Records the category a mounted item renders in, which the category reads once closed (`null`\n * outside a category, which forgets a stale entry for the value).\n */\nfunction useRecordCategory(context: NavContextValue, value: string): void {\n const category = React.useContext(NavCategoryValueContext);\n const { categoryStore } = context;\n React.useLayoutEffect(() => {\n categoryStore.record(value, category);\n }, [categoryStore, value, category]);\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Properties for the Nav component. */\nexport interface NavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue'> {\n /** Controlled value of the selected nav item. */\n value?: string;\n /**\n * Selected nav item value for uncontrolled usage.\n * @default ''\n */\n defaultValue?: string;\n /** Called with the new value when the selection changes (not when the current item is re-selected). */\n onValueChange?: (value: string) => void;\n /** @deprecated Use `value`. */\n selectedValue?: string;\n /** @deprecated Use `defaultValue`. */\n defaultSelectedValue?: string;\n /**\n * @deprecated Use `onValueChange`. Unlike `onValueChange`, it fires on every activation,\n * re-selecting the current item included (0.4 behaviour).\n */\n onNavItemSelect?: (value: string) => void;\n /** Controlled list of open category values. */\n openCategories?: readonly string[];\n /**\n * Categories open initially (uncontrolled). Without it, the categories that contain the\n * selected item (`value`, else `defaultValue`) start open, so the current page is visible on the\n * first render; an empty list keeps every category closed.\n */\n defaultOpenCategories?: readonly string[];\n /** Called with the new list of open category values (a new array) when a category is toggled. */\n onOpenCategoriesChange?: (openCategories: string[]) => void;\n /**\n * The `value` of the category that contains the current item, for sub-items Nav cannot find by\n * itself (rendered by your own component inside a closed category). Usually not needed: Nav\n * finds sub-items among a category's children (through Fragments and wrapper elements) and\n * remembers the category of the current sub-item once it has been shown. A hint, not state:\n * unlike Fluent's `selectedCategoryValue` it has no default or change callback.\n */\n currentCategory?: string;\n /** Ref to the `<nav>` element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Properties for the NavCategory sub-component. */\nexport interface NavCategoryProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * Value identifying this category (used by `openCategories`), unique among the categories of\n * the Nav (a duplicate warns in development).\n */\n value: string;\n /**\n * Label of the category's toggle button (any content). Without it, the text children are used\n * as the label — deprecated: pass the label here and only the sub-items as children.\n */\n label?: React.ReactNode;\n /**\n * Icon displayed before the category label. Rendered with `aria-hidden=\"true\"`. A falsy icon\n * (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /** The category's sub-items (`Nav.SubItem`), rendered in its list while it is open. */\n children?: React.ReactNode;\n /** Ref to the category's `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/**\n * The props of Nav.Item that every branch shares ({@link NavItemAnchorProps},\n * {@link NavItemButtonProps}, {@link NavItemDynamicProps}).\n */\nexport interface NavItemOwnProps {\n /**\n * Value identifying this nav item, unique among the items and sub-items of the Nav (a duplicate\n * warns in development).\n */\n value: string;\n /**\n * Icon displayed before the item label. Rendered with `aria-hidden=\"true\"`. A falsy icon (`''`,\n * `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Whether the item is disabled: a native `disabled` button, or an `aria-disabled` link without\n * `href`. Activating a disabled item never selects it; a disabled item whose value is the\n * current `value` still shows as current (`aria-current=\"page\"` and the selected look), because\n * the current value belongs to the app.\n */\n disabled?: boolean;\n /** Label content. */\n children?: React.ReactNode;\n}\n\n/**\n * The attributes only a link has (`target`, `download`, `hrefLang`, `ping`, …). Button items\n * declare them as `undefined`, so they are a type error without `href` instead of landing on the\n * `<button>`. `rel` cannot be listed (React types it on every element, RDFa); a button item drops\n * it at run time instead.\n */\ntype NoAnchorOnlyAttributes = {\n [\n K in Exclude<\n keyof React.AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof React.ButtonHTMLAttributes<HTMLButtonElement>\n >\n ]?: undefined;\n};\n\n/**\n * Nav.Item rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement`. 0.4 typed every item's handlers on `HTMLButtonElement`, so with a string\n * `href` an unannotated 0.4 handler that reads a button-only member (such as\n * `e.currentTarget.form`) no longer compiles; a handler already typed as\n * `React.MouseEventHandler<HTMLButtonElement>` still does (React handler types are bivariant).\n */\nexport interface NavItemAnchorProps\n extends\n NavItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.Item rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavItemButtonProps\n extends\n NavItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavItemOwnProps> {\n /** Button items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavItem sub-component: link props with `href`, button props without.\n *\n * A union type (0.4 had an interface): an interface cannot extend it, so extend one branch\n * (`interface X extends NavItemButtonProps`) or intersect (`type X = NavItemProps & { … }`).\n * `React.ComponentProps<typeof Nav.Item>` resolves to the last overload,\n * {@link NavItemDynamicProps}.\n */\nexport type NavItemProps = NavItemAnchorProps | NavItemButtonProps;\n\n/**\n * Nav.Item with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Resolved after the button and link signatures.\n *\n * Only the attributes both elements share are accepted (no `target`, `download`, `type`, `form`,\n * …), and handlers receive events of either element (`HTMLAnchorElement | HTMLButtonElement`).\n * 0.4 typed them as button events (`HTMLAttributes<HTMLButtonElement>`), so an unannotated 0.4\n * handler that reads a button-only member (such as `e.currentTarget.form`) no longer compiles here;\n * narrow `e.currentTarget` first. (A string `href` types handlers on `HTMLAnchorElement`, see\n * {@link NavItemAnchorProps}; no `href` keeps `HTMLButtonElement`.)\n */\nexport interface NavItemDynamicProps\n extends\n NavItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/**\n * The props of Nav.SubItem that every branch shares: those of {@link NavItemOwnProps} without\n * `icon`.\n */\nexport type NavSubItemOwnProps = Omit<NavItemOwnProps, 'icon'>;\n\n/**\n * Nav.SubItem rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement` (0.4: `HTMLButtonElement`); see {@link NavItemAnchorProps}.\n */\nexport interface NavSubItemAnchorProps\n extends\n NavSubItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavSubItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.SubItem rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavSubItemButtonProps\n extends\n NavSubItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** Button sub-items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavSubItem sub-component: link props with `href`, button props without.\n * A union type like {@link NavItemProps} (extend a branch or intersect; `React.ComponentProps`\n * resolves to {@link NavSubItemDynamicProps}).\n */\nexport type NavSubItemProps = NavSubItemAnchorProps | NavSubItemButtonProps;\n\n/**\n * Nav.SubItem with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Only the attributes both elements share are accepted, and handlers\n * receive events of either element (0.4 typed them as button events); see\n * {@link NavItemDynamicProps}.\n */\nexport interface NavSubItemDynamicProps\n extends\n NavSubItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/** The props both entry kinds share at runtime (the union narrowed by `href`). */\ntype NavEntryProps = NavItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof NavItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst iconClasses = 'flex h-5 w-5 shrink-0 items-center justify-center';\n\n/**\n * The `icon` slot of Nav.Item and Nav.Category, or `null` when it renders nothing. A falsy icon\n * (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4 and as in\n * Avatar, and so is a collection whose items render nothing, so no empty 20px box is rendered\n * before the label. The check does not consume a generator: renderSlot still renders its items.\n */\nfunction renderIcon(icon: Slot<'span'> | undefined): React.ReactElement | null {\n return icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', iconClasses, { 'aria-hidden': true })\n : null;\n}\n\nconst itemClasses = {\n base: cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary',\n idle: 'text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n};\n\nconst subItemClasses = {\n base: cn(\n 'flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'text-primary font-semibold',\n idle: 'text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n};\n\nconst categoryButtonClasses = cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n // A closed category that contains the current page shows the selected look of an item.\n 'data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary',\n focusRingInset,\n);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ntype ElementWithChildren = React.ReactElement<{ value?: unknown; children?: React.ReactNode }>;\n\nfunction childrenOf(element: ElementWithChildren): React.ReactNode {\n const { children } = element.props;\n return typeof children === 'function' ? undefined : children;\n}\n\n/** Whether a thrown value suspends rendering (a loading lazy chunk, a pending promise). */\nfunction isThenable(value: unknown): boolean {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n\n/*\n * The walks below run during Nav's render and reach consumer content at any depth. Content that\n * is still loading inside the consumer's own <Suspense> (a promise child, a lazy node, a\n * `React.lazy` component) suspends that boundary when React renders it; walking it must never\n * suspend Nav itself, which would hide the whole Nav behind an outer boundary. So a child that\n * cannot be read yet is skipped, and a lazy type that is still loading is not a part (its\n * children are still walked). Parts written in a Server Component arrive as loaded client\n * references and are recognized.\n */\n\n/** Calls `visit` with each element of `nodes` (as `React.Children.forEach`), skipping pending ones. */\nfunction forEachElement(nodes: React.ReactNode, visit: (child: ElementWithChildren) => void): void {\n if (Array.isArray(nodes)) {\n for (const node of nodes as React.ReactNode[]) forEachElement(node, visit);\n return;\n }\n try {\n React.Children.forEach(nodes, (child) => {\n if (React.isValidElement<ElementWithChildren['props']>(child)) visit(child);\n });\n } catch (error) {\n if (!isThenable(error)) throw error;\n }\n}\n\n/** Whether `element` is one of `types`; a lazy type still loading is none (it never suspends). */\nfunction isPart(element: ElementWithChildren, ...types: unknown[]): boolean {\n return types.includes(getElementType(element, { suspend: false }));\n}\n\n/**\n * Whether `nodes` contain a Nav.Item/Nav.SubItem element with `value === selected` (parts written\n * in a Server Component, lazy client references, included). Called during render only.\n */\nfunction containsValue(nodes: React.ReactNode, selected: string): boolean {\n let found = false;\n forEachElement(nodes, (child) => {\n if (found) return;\n if (isPart(child, NavItem, NavSubItem) && child.props.value === selected) {\n found = true;\n } else {\n found = containsValue(childrenOf(child), selected);\n }\n });\n return found;\n}\n\n/** The values of the Nav.Category elements (at any depth of JSX) that contain `selected`. */\nfunction findCategoriesContaining(nodes: React.ReactNode, selected: string): string[] {\n const result: string[] = [];\n if (!selected) return result;\n const visit = (current: React.ReactNode) => {\n forEachElement(current, (child) => {\n const inner = childrenOf(child);\n if (\n isPart(child, NavCategory) &&\n typeof child.props.value === 'string' &&\n containsValue(inner, selected)\n ) {\n result.push(child.props.value);\n }\n visit(inner);\n });\n };\n visit(nodes);\n return result;\n}\n\n/**\n * Whether a click on a link opens it somewhere other than the current page, checked as routers\n * do: a modifier key (a new tab or window, a download), a mouse button other than the main one, a\n * `target` other than `_self`, or a `download` link. Only when the default is not prevented does\n * the browser actually open it there.\n */\nfunction opensElsewhere(event: React.MouseEvent<HTMLElement>): boolean {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return true;\n }\n const link = event.currentTarget;\n const target = link.getAttribute('target');\n return (!!target && target.toLowerCase() !== '_self') || link.hasAttribute('download');\n}\n\n/** Shared rendering of Nav.Item and Nav.SubItem (link or button). */\nfunction renderNavEntry(\n props: NavEntryProps,\n context: NavContextValue,\n classes: { base: string; selected: string; idle: string },\n withIcon: boolean,\n): React.ReactElement {\n const { value, icon, disabled = false, href, className, children, onClick, ref, ...rest } = props;\n const isSelected = context.value === value;\n const isLink = href !== undefined;\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n // A link is still selected when the consumer prevents its default (client-side routing:\n // `preventDefault()` + `router.push(href)`, whatever the modifier keys: the browser then opens\n // nothing elsewhere), but not when the browser opens it elsewhere (the current page does not\n // change); a button honours `preventDefault()` (C-COMPOSE).\n if (isLink ? !event.defaultPrevented && opensElsewhere(event) : event.defaultPrevented) return;\n context.select(value);\n };\n\n const content = (\n <>\n {withIcon && renderIcon(icon)}\n {withIcon ? <span className=\"flex-1 text-start\">{children}</span> : children}\n </>\n );\n\n const entryClassName = cn(classes.base, isSelected ? classes.selected : classes.idle, className);\n\n if (isLink) {\n return (\n <li>\n <a\n {...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={disabled ? undefined : href}\n role={disabled ? 'link' : rest.role}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </a>\n </li>\n );\n }\n\n // `rel` only belongs on a link: a button item drops it (React types it on every element).\n const { rel, ...buttonRest } = rest;\n return (\n <li>\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n ref={ref as React.Ref<HTMLButtonElement>}\n disabled={disabled}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </button>\n </li>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Nav.Category\n// ---------------------------------------------------------------------------\n\n/**\n * A collapsible group of sub-items. Its toggle button shows `label` and reports `aria-expanded`\n * (and `aria-controls` while open); the sub-items render in a nested list while it is open.\n * Open state lives on `Nav` (`openCategories`/`defaultOpenCategories`).\n *\n * A closed category that contains the current item marks its toggle button with\n * `aria-current=\"true\"` (the button is not the page's link, so not `\"page\"`),\n * `data-contains-current` and the selected look of `Nav.Item`. It contains the current item when\n * a `Nav.SubItem` with the current value is among its children (through Fragments and wrapper\n * elements, also in the server HTML), when the current sub-item was last shown in it (and has not\n * moved among another category's children since), or when it is the Nav's `currentCategory`. An\n * open category is not marked: its sub-item shows the current page.\n *\n * Also exported as `NavCategory` (import the flat name from React Server Components).\n */\nconst NavCategory = ({\n value,\n label,\n icon,\n className,\n children,\n ref,\n ...rest\n}: NavCategoryProps) => {\n const context = useNavContext('Nav.Category');\n const {\n value: currentValue,\n openCategories,\n toggleCategory,\n currentCategory,\n categoryStore,\n } = context;\n useNavValue(context, 'category', value);\n const listId = useId('wave-nav-category');\n const isOpen = openCategories.includes(value);\n\n // The current sub-item is among the children of this closed category (also on the server).\n const holdsCurrentChild = !isOpen && currentValue !== '' && containsValue(children, currentValue);\n // The current sub-item was last shown in this category (none on the server).\n const holdsShownCurrent = React.useSyncExternalStore(\n categoryStore.subscribe,\n () => currentValue !== '' && categoryStore.get(currentValue) === value,\n () => false,\n );\n // Children that hold the current sub-item make this the category the Nav remembers for it, so a\n // category it was shown in before it moved here is no longer marked. The entry is forgotten when\n // they stop holding it (an open category records through its mounted sub-item instead).\n React.useLayoutEffect(() => {\n if (!holdsCurrentChild) return;\n categoryStore.record(currentValue, value);\n return () => categoryStore.forget(currentValue, value);\n }, [categoryStore, holdsCurrentChild, currentValue, value]);\n const containsCurrent =\n !isOpen && (currentCategory === value || holdsShownCurrent || holdsCurrentChild);\n\n let buttonLabel: React.ReactNode = label;\n let items: React.ReactNode = children;\n if (label === undefined) {\n // Deprecated 0.4 path: the text children are the label, the other children the sub-items.\n warnDeprecated(\n 'Nav.Category',\n 'text children as the label',\n 'label',\n 'Pass the category label in `label` and only the sub-items as children.',\n );\n const parts = React.Children.toArray(children);\n const isText = (part: unknown) => typeof part === 'string' || typeof part === 'number';\n buttonLabel = parts.filter(isText).join('');\n items = parts.filter((part) => !isText(part));\n }\n\n return (\n <li ref={ref} {...rest} className={className}>\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-current={containsCurrent ? true : undefined}\n data-contains-current={containsCurrent ? '' : undefined}\n onClick={() => toggleCategory(value)}\n className={categoryButtonClasses}\n >\n {renderIcon(icon)}\n <span className=\"flex-1 text-start\">{buttonLabel}</span>\n <ChevronDownIcon\n className={cn(\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isOpen && 'rotate-180',\n )}\n />\n </button>\n {isOpen && (\n <NavCategoryValueContext.Provider value={value}>\n <ul id={listId} className=\"m-0 list-none p-0\">\n {items}\n </ul>\n </NavCategoryValueContext.Provider>\n )}\n </li>\n );\n};\nNavCategory.displayName = 'NavCategory';\n\n// ---------------------------------------------------------------------------\n// Nav.Item / Nav.SubItem\n// ---------------------------------------------------------------------------\n\n/**\n * A top-level navigation entry: a link when `href` is given (anchor props), a button otherwise\n * (button props). Clicking selects it (`aria-current=\"page\"`); activating a disabled entry never\n * selects it (a disabled entry whose value is the current value still shows as current).\n *\n * A click that opens a link somewhere other than the current page selects nothing (the consumer's\n * `onClick` still runs, and the browser opens the link): Ctrl/Cmd/Shift/Alt-click, a mouse button\n * other than the main one, a `target` other than `_self`, or a `download` link. When the consumer's\n * `onClick` calls `preventDefault()` (client-side routing), the browser opens nothing, so the item\n * is selected whatever the keys, button or `target`.\n *\n * Typed by overloads, resolved in order: without `href` (button props, button events), with a\n * string `href` (anchor props, anchor events), then an `href` that may be `undefined` at run time\n * ({@link NavItemDynamicProps}: events of either element).\n *\n * Also exported as `NavItem` (import the flat name from React Server Components).\n */\nfunction NavItem(props: NavItemButtonProps): React.ReactElement;\nfunction NavItem(props: NavItemAnchorProps): React.ReactElement;\nfunction NavItem(props: NavItemDynamicProps): React.ReactElement;\nfunction NavItem(props: NavItemProps | NavItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.Item');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n return renderNavEntry(props as NavEntryProps, context, itemClasses, true);\n}\nNavItem.displayName = 'NavItem';\n\n/**\n * An indented entry inside a `Nav.Category`: a link when `href` is given, a button otherwise.\n * Selected like `Nav.Item` (a click that the browser opens somewhere else selects nothing; one\n * whose default your `onClick` prevents is selected), and typed by overloads like `Nav.Item`\n * (button, link, then {@link NavSubItemDynamicProps}).\n *\n * Also exported as `NavSubItem` (import the flat name from React Server Components).\n */\nfunction NavSubItem(props: NavSubItemButtonProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemAnchorProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemDynamicProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemProps | NavSubItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.SubItem');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n return renderNavEntry(props as NavEntryProps, context, subItemClasses, false);\n}\nNavSubItem.displayName = 'NavSubItem';\n\n// ---------------------------------------------------------------------------\n// Nav (root)\n// ---------------------------------------------------------------------------\n\nconst NavRoot = ({\n value: valueProp,\n defaultValue: defaultValueProp,\n onValueChange,\n selectedValue,\n defaultSelectedValue,\n onNavItemSelect,\n openCategories: openCategoriesProp,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n className,\n children,\n ref,\n ...rest\n}: NavProps) => {\n const controlledValue = resolveDeprecatedProp(\n 'Nav',\n valueProp,\n selectedValue,\n 'selectedValue',\n 'value',\n );\n const defaultValue =\n resolveDeprecatedProp(\n 'Nav',\n defaultValueProp,\n defaultSelectedValue,\n 'defaultSelectedValue',\n 'defaultValue',\n ) ?? '';\n if (onNavItemSelect !== undefined) warnDeprecated('Nav', 'onNavItemSelect', 'onValueChange');\n\n const [value, setValue] = useControllable(controlledValue, defaultValue, onValueChange);\n const notifyNavItemSelect = useEventCallback(onNavItemSelect);\n const select = React.useCallback(\n (next: string) => {\n setValue(next);\n // Deprecated event-named alias: every activation, re-selection included (C-NAMING).\n notifyNavItemSelect(next);\n },\n [setValue, notifyNavItemSelect],\n );\n\n const [initialOpenCategories] = React.useState<readonly string[]>(\n () =>\n defaultOpenCategories ?? findCategoriesContaining(children, controlledValue ?? defaultValue),\n );\n const [openCategories, setOpenCategories] = useControllable<readonly string[]>(\n openCategoriesProp,\n initialOpenCategories,\n (next) => onOpenCategoriesChange?.([...next]),\n );\n const toggleCategory = React.useCallback(\n (category: string) => {\n setOpenCategories((previous) =>\n previous.includes(category)\n ? previous.filter((entry) => entry !== category)\n : [...previous, category],\n );\n },\n [setOpenCategories],\n );\n\n // Duplicate values (C-DEV): the mounted items and categories per value (written from their\n // effects only); a second one with a value already in use warns once per value.\n const valueCountsRef = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback((kind: NavValueKind, entry: string) => {\n const counts = (valueCountsRef.current ??= new Map<string, number>());\n const key = `${kind}:${entry}`;\n const count = (counts.get(key) ?? 0) + 1;\n counts.set(key, count);\n if (count > 1) warnDuplicateValue(kind, entry);\n return () => {\n const remaining = (counts.get(key) ?? 1) - 1;\n if (remaining > 0) counts.set(key, remaining);\n else counts.delete(key);\n };\n }, []);\n\n const [categoryStore] = React.useState(createCategoryStore);\n\n const contextValue = React.useMemo<NavContextValue>(\n () => ({\n value,\n select,\n openCategories,\n toggleCategory,\n registerValue,\n currentCategory,\n categoryStore,\n }),\n [value, select, openCategories, toggleCategory, registerValue, currentCategory, categoryStore],\n );\n\n return (\n <NavContext.Provider value={contextValue}>\n <nav\n aria-label=\"Navigation\"\n {...rest}\n ref={ref}\n className={cn('w-60 border-e border-border bg-background py-2', className)}\n >\n <ul className=\"m-0 list-none p-0\">{children}</ul>\n </nav>\n </NavContext.Provider>\n );\n};\nNavRoot.displayName = 'Nav';\n\n/**\n * A vertical side navigation (`<nav>` landmark, default name \"Navigation\") with items, links and\n * collapsible categories.\n *\n * - **Selection**: `value`/`defaultValue`/`onValueChange` (`onValueChange` fires only when the\n * value changes). The deprecated `selectedValue`/`defaultSelectedValue`/`onNavItemSelect` still\n * work; `onNavItemSelect` keeps firing on every activation, re-selection included. A click that\n * opens a link in another tab or window (or downloads it) selects nothing, unless the item's\n * `onClick` prevents the default (client-side routing: then nothing opens elsewhere).\n * - **Categories**: `openCategories`/`defaultOpenCategories`/`onOpenCategoriesChange`. Without\n * `defaultOpenCategories`, the categories containing the selected item (`value` or\n * `defaultValue`) start open. A closed category that contains the selected item marks its toggle\n * (`aria-current=\"true\"`, `data-contains-current`, the selected look); pass `currentCategory`\n * for sub-items your own component renders inside a closed category.\n * - **Values** are unique: among the items and sub-items, and among the categories (a duplicate\n * warns in development).\n *\n * Sub-components are also exported under flat names (`NavCategory`, `NavItem`, `NavSubItem`):\n * React Server Components import those, because dotted access (`Nav.Item`) needs a client file.\n */\nexport const Nav = /* @__PURE__ */ Object.assign(NavRoot, {\n Category: NavCategory,\n Item: NavItem,\n SubItem: NavSubItem,\n});\n\nexport { NavCategory, NavItem, NavSubItem };\n"],"mappings":"kdA4CA,SAASyB,GAAwC,CAC/C,IAAMC,EAAa,IAAI,IACjBC,EAAY,IAAI,IAChBC,MAAeD,EAAU,QAAS,GAAaE,EAAS,CAAC,EAC/D,MAAO,CACL,OAAO,EAAO,EAAU,EACjBH,EAAW,IAAII,CAAK,GAAK,QAAUC,IACpCA,IAAa,KAAML,EAAW,OAAOI,CAAK,EACzCJ,EAAW,IAAII,EAAOC,CAAQ,EACnCH,EAAO,EACT,EACA,OAAO,EAAO,EAAU,CAClBF,EAAW,IAAII,CAAK,IAAMC,IAC9BL,EAAW,OAAOI,CAAK,EACvBF,EAAO,EACT,EACA,IAAM,GAAUF,EAAW,IAAII,CAAK,EACpC,UAAU,EAAU,CAElB,OADAH,EAAU,IAAIE,CAAQ,MACT,CACXF,EAAU,OAAOE,CAAQ,CAC3B,CACF,CACF,CACF,CAgBA,IAAMG,EAAahC,EAAM,cAAsC,IAAI,EACnE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AAGuF,IACjBI,GAASF,EAAO,IAAIC,CAAG,GAAK,GAAK,EAGvC,OAFAD,EAAO,IAAIC,EAAKC,CAAK,EACjBA,EAAQ,GAAG5F,EAAmBC,EAAMuF,CAAK,MAChC,CACX,IAAMK,GAAaH,EAAO,IAAIC,CAAG,GAAK,GAAK,EACvCE,EAAY,EAAGH,EAAO,IAAIC,EAAKE,CAAS,EACvCH,EAAO,OAAOC,CAAG,CACxB,CACF,EAAG,CAAC,CAAC,EAEC,CAACrF,GAAiB5C,EAAM,SAASyB,CAAmB,EAEpD2G,EAAepI,EAAM,aAClB,CACL,QACA,SACA,iBACA,iBACA,gBACA,kBACA,eACF,GACA,CAAC8B,EAAOyF,EAAQxB,EAAgBW,EAAgBhE,EAAeyD,EAAiBvD,CAAa,CAC/F,EAEA,OACE,EAAApB,EAAA,IAAA,CAACQ,EAAW,SAAZ,CAAqB,MAAOoG,EAC1B,UAAA,EAAA5G,EAAA,IAAA,CAAC,MAAD,CACE,aAAW,aACX,GAAIsD,EACC,MACL,UAAW3E,EAAAA,GAAG,iDAAkDuF,CAAS,EAEzE,UAAA,EAAAlE,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,oBAAqB,UAAa,CAAA,CAC7C,CAAA,CACc,CAAA,CAEzB,EACA,EAAQ,YAAc,MAsBtB,IAAa6G,EAAsB,OAAO,OAAO1B,EAAS,CACxD,SAAUnC,EACV,KAAMP,EACN,QAASC,CACX,CAAC"}
|
|
1
|
+
{"version":3,"file":"Nav.cjs","names":["React","slotRendersContent","renderSlot","cn","focusRingInset","disabledStyles","getElementType","_Fragment","useId","navCategoryClassNames","ChevronDownIcon","navItemClassNames","navSubItemClassNames","resolveDeprecatedProp","useControllable","useEventCallback","navClassNames","require_runtime","require_cn","require_children","require_dev","require_slot","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_styles","require_icons","react","react_jsx_runtime","createCategoryStore","categories","listeners","notify","listener","value","category","NavContext","noop","INERT_NAV_CONTEXT","NavCategoryValueContext","useNavContext","componentName","warnDuplicateValue","kind","useNavValue","context","registerValue","useRecordCategory","categoryStore","iconClasses","renderIcon","icon","className","itemClasses","subItemClasses","categoryButtonClasses","childrenOf","element","children","isThenable","forEachElement","nodes","node","visit","child","error","isPart","types","containsValue","found","NavItem","NavSubItem","selected","findCategoriesContaining","result","current","inner","NavCategory","opensElsewhere","event","link","target","renderNavEntry","rest","props","isSelected","isLink","href","handleClick","disabled","onClick","content","withIcon","stable","entryClassName","classes","buttonRest","currentValue","listId","isOpen","openCategories","holdsCurrentChild","holdsShownCurrent","containsCurrent","currentCategory","buttonLabel","label","items","parts","isText","part","toggleCategory","NavRoot","valueProp","defaultValueProp","openCategoriesProp","controlledValue","selectedValue","defaultValue","defaultSelectedValue","onNavItemSelect","setValue","onValueChange","notifyNavItemSelect","select","next","initialOpenCategories","defaultOpenCategories","setOpenCategories","onOpenCategoriesChange","previous","entry","valueCountsRef","counts","key","count","remaining","contextValue","Nav"],"sources":["../../../src/components/navigation/Nav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n navCategoryClassNames,\n navClassNames,\n navItemClassNames,\n navSubItemClassNames,\n} from '../../lib/classNames';\nimport type { Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport {\n reportMissingContext,\n resolveDeprecatedProp,\n warnDeprecated,\n warnOnce,\n} from '../../lib/dev';\nimport { getElementType } from '../../lib/children';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n/** The two value namespaces of a Nav: items (Nav.Item and Nav.SubItem) and categories. */\ntype NavValueKind = 'item' | 'category';\n\n/**\n * The category each sub-item was last shown in, by sub-item value: written from layout effects by\n * the mounted sub-items and by a closed category whose children hold the current value, read by\n * the categories with `useSyncExternalStore`. An entry outlives its sub-item, so a category closed\n * after its current sub-item was shown still knows it contains the current page.\n */\ninterface NavCategoryStore {\n /**\n * Records the category a mounted item renders in, or a closed category whose children hold the\n * value; `null` (an item outside any category) forgets an earlier entry, so a value moved out of\n * a category no longer marks it.\n */\n record: (value: string, category: string | null) => void;\n /** Forgets the entry of `value` while it is still `category`. */\n forget: (value: string, category: string) => void;\n /** The category last recorded for a sub-item value. */\n get: (value: string) => string | undefined;\n subscribe: (listener: () => void) => () => void;\n}\n\nfunction createCategoryStore(): NavCategoryStore {\n const categories = new Map<string, string>();\n const listeners = new Set<() => void>();\n const notify = () => listeners.forEach((listener) => listener());\n return {\n record(value, category) {\n if ((categories.get(value) ?? null) === category) return;\n if (category === null) categories.delete(value);\n else categories.set(value, category);\n notify();\n },\n forget(value, category) {\n if (categories.get(value) !== category) return;\n categories.delete(value);\n notify();\n },\n get: (value) => categories.get(value),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\ninterface NavContextValue {\n /** The selected item value (`''` when nothing is selected). */\n value: string;\n /** Selects an item (activation handler: also fires the deprecated `onNavItemSelect`). */\n select: (value: string) => void;\n openCategories: readonly string[];\n toggleCategory: (value: string) => void;\n /** Registers a mounted item or category value (duplicate warning); returns the cleanup. */\n registerValue: (kind: NavValueKind, value: string) => () => void;\n /** The `currentCategory` hint of the Nav. */\n currentCategory: string | undefined;\n categoryStore: NavCategoryStore;\n}\n\nconst NavContext = React.createContext<NavContextValue | null>(null);\nNavContext.displayName = 'NavContext';\n\nconst noop = () => {};\nconst INERT_NAV_CONTEXT: NavContextValue = {\n value: '',\n select: noop,\n openCategories: [],\n toggleCategory: noop,\n registerValue: () => noop,\n currentCategory: undefined,\n categoryStore: { record: noop, forget: noop, get: () => undefined, subscribe: () => noop },\n};\n\n/**\n * The value of the Nav.Category a sub-item renders in (`null` outside a category). It renders no\n * element; a sub-item outside a category is valid, so there is no missing-context error.\n */\nconst NavCategoryValueContext = React.createContext<string | null>(null);\nNavCategoryValueContext.displayName = 'NavCategoryValueContext';\n\n/** C-CONTEXT: throws in development, logs once and returns an inert value in production. */\nfunction useNavContext(componentName: string): NavContextValue {\n const context = React.useContext(NavContext);\n if (context) return context;\n reportMissingContext(componentName, 'Nav');\n return INERT_NAV_CONTEXT;\n}\n\nfunction warnDuplicateValue(kind: NavValueKind, value: string): void {\n warnOnce(\n `Nav:duplicate-${kind}:${value}`,\n kind === 'item'\n ? `Nav: several items share the value \"${value}\". Nav.Item and Nav.SubItem values must be unique within a Nav; every item with the current value is marked as the current page.`\n : `Nav: several categories share the value \"${value}\". Nav.Category values must be unique within a Nav; they open and close together.`,\n );\n}\n\n/** Registers the value of a mounted item or category, so Nav can warn about duplicates. */\nfunction useNavValue(context: NavContextValue, kind: NavValueKind, value: string): void {\n const { registerValue } = context;\n React.useEffect(() => registerValue(kind, value), [registerValue, kind, value]);\n}\n\n/**\n * Records the category a mounted item renders in, which the category reads once closed (`null`\n * outside a category, which forgets a stale entry for the value).\n */\nfunction useRecordCategory(context: NavContextValue, value: string): void {\n const category = React.useContext(NavCategoryValueContext);\n const { categoryStore } = context;\n React.useLayoutEffect(() => {\n categoryStore.record(value, category);\n }, [categoryStore, value, category]);\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Properties for the Nav component. */\nexport interface NavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue'> {\n /** Controlled value of the selected nav item. */\n value?: string;\n /**\n * Selected nav item value for uncontrolled usage.\n * @default ''\n */\n defaultValue?: string;\n /** Called with the new value when the selection changes (not when the current item is re-selected). */\n onValueChange?: (value: string) => void;\n /** @deprecated Use `value`. */\n selectedValue?: string;\n /** @deprecated Use `defaultValue`. */\n defaultSelectedValue?: string;\n /**\n * @deprecated Use `onValueChange`. Unlike `onValueChange`, it fires on every activation,\n * re-selecting the current item included (0.4 behaviour).\n */\n onNavItemSelect?: (value: string) => void;\n /** Controlled list of open category values. */\n openCategories?: readonly string[];\n /**\n * Categories open initially (uncontrolled). Without it, the categories that contain the\n * selected item (`value`, else `defaultValue`) start open, so the current page is visible on the\n * first render; an empty list keeps every category closed.\n */\n defaultOpenCategories?: readonly string[];\n /** Called with the new list of open category values (a new array) when a category is toggled. */\n onOpenCategoriesChange?: (openCategories: string[]) => void;\n /**\n * The `value` of the category that contains the current item, for sub-items Nav cannot find by\n * itself (rendered by your own component inside a closed category). Usually not needed: Nav\n * finds sub-items among a category's children (through Fragments and wrapper elements) and\n * remembers the category of the current sub-item once it has been shown. A hint, not state:\n * unlike Fluent's `selectedCategoryValue` it has no default or change callback.\n */\n currentCategory?: string;\n /** Ref to the `<nav>` element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Properties for the NavCategory sub-component. */\nexport interface NavCategoryProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * Value identifying this category (used by `openCategories`), unique among the categories of\n * the Nav (a duplicate warns in development).\n */\n value: string;\n /**\n * Label of the category's toggle button (any content). Without it, the text children are used\n * as the label — deprecated: pass the label here and only the sub-items as children.\n */\n label?: React.ReactNode;\n /**\n * Icon displayed before the category label. Rendered with `aria-hidden=\"true\"`. A falsy icon\n * (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /** The category's sub-items (`Nav.SubItem`), rendered in its list while it is open. */\n children?: React.ReactNode;\n /** Ref to the category's `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/**\n * The props of Nav.Item that every branch shares ({@link NavItemAnchorProps},\n * {@link NavItemButtonProps}, {@link NavItemDynamicProps}).\n */\nexport interface NavItemOwnProps {\n /**\n * Value identifying this nav item, unique among the items and sub-items of the Nav (a duplicate\n * warns in development).\n */\n value: string;\n /**\n * Icon displayed before the item label. Rendered with `aria-hidden=\"true\"`. A falsy icon (`''`,\n * `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Whether the item is disabled: a native `disabled` button, or an `aria-disabled` link without\n * `href`. Activating a disabled item never selects it; a disabled item whose value is the\n * current `value` still shows as current (`aria-current=\"page\"` and the selected look), because\n * the current value belongs to the app.\n */\n disabled?: boolean;\n /** Label content. */\n children?: React.ReactNode;\n}\n\n/**\n * The attributes only a link has (`target`, `download`, `hrefLang`, `ping`, …). Button items\n * declare them as `undefined`, so they are a type error without `href` instead of landing on the\n * `<button>`. `rel` cannot be listed (React types it on every element, RDFa); a button item drops\n * it at run time instead.\n */\ntype NoAnchorOnlyAttributes = {\n [\n K in Exclude<\n keyof React.AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof React.ButtonHTMLAttributes<HTMLButtonElement>\n >\n ]?: undefined;\n};\n\n/**\n * Nav.Item rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement`. 0.4 typed every item's handlers on `HTMLButtonElement`, so with a string\n * `href` an unannotated 0.4 handler that reads a button-only member (such as\n * `e.currentTarget.form`) no longer compiles; a handler already typed as\n * `React.MouseEventHandler<HTMLButtonElement>` still does (React handler types are bivariant).\n */\nexport interface NavItemAnchorProps\n extends\n NavItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.Item rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavItemButtonProps\n extends\n NavItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavItemOwnProps> {\n /** Button items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavItem sub-component: link props with `href`, button props without.\n *\n * A union type (0.4 had an interface): an interface cannot extend it, so extend one branch\n * (`interface X extends NavItemButtonProps`) or intersect (`type X = NavItemProps & { … }`).\n * `React.ComponentProps<typeof Nav.Item>` resolves to the last overload,\n * {@link NavItemDynamicProps}.\n */\nexport type NavItemProps = NavItemAnchorProps | NavItemButtonProps;\n\n/**\n * Nav.Item with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Resolved after the button and link signatures.\n *\n * Only the attributes both elements share are accepted (no `target`, `download`, `type`, `form`,\n * …), and handlers receive events of either element (`HTMLAnchorElement | HTMLButtonElement`).\n * 0.4 typed them as button events (`HTMLAttributes<HTMLButtonElement>`), so an unannotated 0.4\n * handler that reads a button-only member (such as `e.currentTarget.form`) no longer compiles here;\n * narrow `e.currentTarget` first. (A string `href` types handlers on `HTMLAnchorElement`, see\n * {@link NavItemAnchorProps}; no `href` keeps `HTMLButtonElement`.)\n */\nexport interface NavItemDynamicProps\n extends\n NavItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/**\n * The props of Nav.SubItem that every branch shares: those of {@link NavItemOwnProps} without\n * `icon`.\n */\nexport type NavSubItemOwnProps = Omit<NavItemOwnProps, 'icon'>;\n\n/**\n * Nav.SubItem rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement` (0.4: `HTMLButtonElement`); see {@link NavItemAnchorProps}.\n */\nexport interface NavSubItemAnchorProps\n extends\n NavSubItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavSubItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.SubItem rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavSubItemButtonProps\n extends\n NavSubItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** Button sub-items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavSubItem sub-component: link props with `href`, button props without.\n * A union type like {@link NavItemProps} (extend a branch or intersect; `React.ComponentProps`\n * resolves to {@link NavSubItemDynamicProps}).\n */\nexport type NavSubItemProps = NavSubItemAnchorProps | NavSubItemButtonProps;\n\n/**\n * Nav.SubItem with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Only the attributes both elements share are accepted, and handlers\n * receive events of either element (0.4 typed them as button events); see\n * {@link NavItemDynamicProps}.\n */\nexport interface NavSubItemDynamicProps\n extends\n NavSubItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/** The props both entry kinds share at runtime (the union narrowed by `href`). */\ntype NavEntryProps = NavItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof NavItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst iconClasses = 'flex h-5 w-5 shrink-0 items-center justify-center';\n\n/**\n * The `icon` slot of Nav.Item and Nav.Category, or `null` when it renders nothing. A falsy icon\n * (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4 and as in\n * Avatar, and so is a collection whose items render nothing, so no empty 20px box is rendered\n * before the label. The check does not consume a generator: renderSlot still renders its items.\n */\nfunction renderIcon(\n icon: Slot<'span'> | undefined,\n className: string | undefined,\n): React.ReactElement | null {\n return icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(className, iconClasses), { 'aria-hidden': true })\n : null;\n}\n\nconst itemClasses = {\n base: cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary',\n idle: 'text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n};\n\nconst subItemClasses = {\n base: cn(\n 'flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'text-primary font-semibold',\n idle: 'text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n};\n\nconst categoryButtonClasses = cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n // A closed category that contains the current page shows the selected look of an item.\n 'data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary',\n focusRingInset,\n);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ntype ElementWithChildren = React.ReactElement<{ value?: unknown; children?: React.ReactNode }>;\n\nfunction childrenOf(element: ElementWithChildren): React.ReactNode {\n const { children } = element.props;\n return typeof children === 'function' ? undefined : children;\n}\n\n/** Whether a thrown value suspends rendering (a loading lazy chunk, a pending promise). */\nfunction isThenable(value: unknown): boolean {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n\n/*\n * The walks below run during Nav's render and reach consumer content at any depth. Content that\n * is still loading inside the consumer's own <Suspense> (a promise child, a lazy node, a\n * `React.lazy` component) suspends that boundary when React renders it; walking it must never\n * suspend Nav itself, which would hide the whole Nav behind an outer boundary. So a child that\n * cannot be read yet is skipped, and a lazy type that is still loading is not a part (its\n * children are still walked). Parts written in a Server Component arrive as loaded client\n * references and are recognized.\n */\n\n/** Calls `visit` with each element of `nodes` (as `React.Children.forEach`), skipping pending ones. */\nfunction forEachElement(nodes: React.ReactNode, visit: (child: ElementWithChildren) => void): void {\n if (Array.isArray(nodes)) {\n for (const node of nodes as React.ReactNode[]) forEachElement(node, visit);\n return;\n }\n try {\n React.Children.forEach(nodes, (child) => {\n if (React.isValidElement<ElementWithChildren['props']>(child)) visit(child);\n });\n } catch (error) {\n if (!isThenable(error)) throw error;\n }\n}\n\n/** Whether `element` is one of `types`; a lazy type still loading is none (it never suspends). */\nfunction isPart(element: ElementWithChildren, ...types: unknown[]): boolean {\n return types.includes(getElementType(element, { suspend: false }));\n}\n\n/**\n * Whether `nodes` contain a Nav.Item/Nav.SubItem element with `value === selected` (parts written\n * in a Server Component, lazy client references, included). Called during render only.\n */\nfunction containsValue(nodes: React.ReactNode, selected: string): boolean {\n let found = false;\n forEachElement(nodes, (child) => {\n if (found) return;\n if (isPart(child, NavItem, NavSubItem) && child.props.value === selected) {\n found = true;\n } else {\n found = containsValue(childrenOf(child), selected);\n }\n });\n return found;\n}\n\n/** The values of the Nav.Category elements (at any depth of JSX) that contain `selected`. */\nfunction findCategoriesContaining(nodes: React.ReactNode, selected: string): string[] {\n const result: string[] = [];\n if (!selected) return result;\n const visit = (current: React.ReactNode) => {\n forEachElement(current, (child) => {\n const inner = childrenOf(child);\n if (\n isPart(child, NavCategory) &&\n typeof child.props.value === 'string' &&\n containsValue(inner, selected)\n ) {\n result.push(child.props.value);\n }\n visit(inner);\n });\n };\n visit(nodes);\n return result;\n}\n\n/**\n * Whether a click on a link opens it somewhere other than the current page, checked as routers\n * do: a modifier key (a new tab or window, a download), a mouse button other than the main one, a\n * `target` other than `_self`, or a `download` link. Only when the default is not prevented does\n * the browser actually open it there.\n */\nfunction opensElsewhere(event: React.MouseEvent<HTMLElement>): boolean {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return true;\n }\n const link = event.currentTarget;\n const target = link.getAttribute('target');\n return (!!target && target.toLowerCase() !== '_self') || link.hasAttribute('download');\n}\n\n/** The stable classes of an entry, written literally by Nav.Item and Nav.SubItem. */\ninterface NavEntryClassNames {\n root: string;\n listItem: string;\n icon?: string;\n content?: string;\n}\n\n/** Shared rendering of Nav.Item and Nav.SubItem (link or button). */\nfunction renderNavEntry(\n props: NavEntryProps,\n context: NavContextValue,\n classes: { base: string; selected: string; idle: string },\n stable: NavEntryClassNames,\n withIcon: boolean,\n): React.ReactElement {\n const { value, icon, disabled = false, href, className, children, onClick, ref, ...rest } = props;\n const isSelected = context.value === value;\n const isLink = href !== undefined;\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n // A link is still selected when the consumer prevents its default (client-side routing:\n // `preventDefault()` + `router.push(href)`, whatever the modifier keys: the browser then opens\n // nothing elsewhere), but not when the browser opens it elsewhere (the current page does not\n // change); a button honours `preventDefault()` (C-COMPOSE).\n if (isLink ? !event.defaultPrevented && opensElsewhere(event) : event.defaultPrevented) return;\n context.select(value);\n };\n\n const content = (\n <>\n {withIcon && renderIcon(icon, stable.icon)}\n {withIcon ? (\n <span className={cn(stable.content, 'flex-1 text-start')}>{children}</span>\n ) : (\n children\n )}\n </>\n );\n\n const entryClassName = cn(\n stable.root,\n classes.base,\n isSelected ? classes.selected : classes.idle,\n className,\n );\n\n if (isLink) {\n return (\n <li className={stable.listItem}>\n <a\n {...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={disabled ? undefined : href}\n role={disabled ? 'link' : rest.role}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </a>\n </li>\n );\n }\n\n // `rel` only belongs on a link: a button item drops it (React types it on every element).\n const { rel, ...buttonRest } = rest;\n return (\n <li className={stable.listItem}>\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n ref={ref as React.Ref<HTMLButtonElement>}\n disabled={disabled}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </button>\n </li>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Nav.Category\n// ---------------------------------------------------------------------------\n\n/**\n * A collapsible group of sub-items. Its toggle button shows `label` and reports `aria-expanded`\n * (and `aria-controls` while open); the sub-items render in a nested list while it is open.\n * Open state lives on `Nav` (`openCategories`/`defaultOpenCategories`).\n *\n * A closed category that contains the current item marks its toggle button with\n * `aria-current=\"true\"` (the button is not the page's link, so not `\"page\"`),\n * `data-contains-current` and the selected look of `Nav.Item`. It contains the current item when\n * a `Nav.SubItem` with the current value is among its children (through Fragments and wrapper\n * elements, also in the server HTML), when the current sub-item was last shown in it (and has not\n * moved among another category's children since), or when it is the Nav's `currentCategory`. An\n * open category is not marked: its sub-item shows the current page.\n *\n * Also exported as `NavCategory` (import the flat name from React Server Components).\n */\nconst NavCategory = ({\n value,\n label,\n icon,\n className,\n children,\n ref,\n ...rest\n}: NavCategoryProps) => {\n const context = useNavContext('Nav.Category');\n const {\n value: currentValue,\n openCategories,\n toggleCategory,\n currentCategory,\n categoryStore,\n } = context;\n useNavValue(context, 'category', value);\n const listId = useId('wave-nav-category');\n const isOpen = openCategories.includes(value);\n\n // The current sub-item is among the children of this closed category (also on the server).\n const holdsCurrentChild = !isOpen && currentValue !== '' && containsValue(children, currentValue);\n // The current sub-item was last shown in this category (none on the server).\n const holdsShownCurrent = React.useSyncExternalStore(\n categoryStore.subscribe,\n () => currentValue !== '' && categoryStore.get(currentValue) === value,\n () => false,\n );\n // Children that hold the current sub-item make this the category the Nav remembers for it, so a\n // category it was shown in before it moved here is no longer marked. The entry is forgotten when\n // they stop holding it (an open category records through its mounted sub-item instead).\n React.useLayoutEffect(() => {\n if (!holdsCurrentChild) return;\n categoryStore.record(currentValue, value);\n return () => categoryStore.forget(currentValue, value);\n }, [categoryStore, holdsCurrentChild, currentValue, value]);\n const containsCurrent =\n !isOpen && (currentCategory === value || holdsShownCurrent || holdsCurrentChild);\n\n let buttonLabel: React.ReactNode = label;\n let items: React.ReactNode = children;\n if (label === undefined) {\n // Deprecated 0.4 path: the text children are the label, the other children the sub-items.\n warnDeprecated(\n 'Nav.Category',\n 'text children as the label',\n 'label',\n 'Pass the category label in `label` and only the sub-items as children.',\n );\n const parts = React.Children.toArray(children);\n const isText = (part: unknown) => typeof part === 'string' || typeof part === 'number';\n buttonLabel = parts.filter(isText).join('');\n items = parts.filter((part) => !isText(part));\n }\n\n return (\n <li ref={ref} {...rest} className={cn(navCategoryClassNames.root, className)}>\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-current={containsCurrent ? true : undefined}\n data-contains-current={containsCurrent ? '' : undefined}\n onClick={() => toggleCategory(value)}\n className={cn(navCategoryClassNames.button, categoryButtonClasses)}\n >\n {renderIcon(icon, navCategoryClassNames.icon)}\n <span className={cn(navCategoryClassNames.label, 'flex-1 text-start')}>{buttonLabel}</span>\n <ChevronDownIcon\n className={cn(\n navCategoryClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isOpen && 'rotate-180',\n )}\n />\n </button>\n {isOpen && (\n <NavCategoryValueContext.Provider value={value}>\n <ul id={listId} className={cn(navCategoryClassNames.list, 'm-0 list-none p-0')}>\n {items}\n </ul>\n </NavCategoryValueContext.Provider>\n )}\n </li>\n );\n};\nNavCategory.displayName = 'NavCategory';\n\n// ---------------------------------------------------------------------------\n// Nav.Item / Nav.SubItem\n// ---------------------------------------------------------------------------\n\n/**\n * A top-level navigation entry: a link when `href` is given (anchor props), a button otherwise\n * (button props). Clicking selects it (`aria-current=\"page\"`); activating a disabled entry never\n * selects it (a disabled entry whose value is the current value still shows as current).\n *\n * A click that opens a link somewhere other than the current page selects nothing (the consumer's\n * `onClick` still runs, and the browser opens the link): Ctrl/Cmd/Shift/Alt-click, a mouse button\n * other than the main one, a `target` other than `_self`, or a `download` link. When the consumer's\n * `onClick` calls `preventDefault()` (client-side routing), the browser opens nothing, so the item\n * is selected whatever the keys, button or `target`.\n *\n * Typed by overloads, resolved in order: without `href` (button props, button events), with a\n * string `href` (anchor props, anchor events), then an `href` that may be `undefined` at run time\n * ({@link NavItemDynamicProps}: events of either element).\n *\n * Also exported as `NavItem` (import the flat name from React Server Components).\n */\nfunction NavItem(props: NavItemButtonProps): React.ReactElement;\nfunction NavItem(props: NavItemAnchorProps): React.ReactElement;\nfunction NavItem(props: NavItemDynamicProps): React.ReactElement;\nfunction NavItem(props: NavItemProps | NavItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.Item');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n return renderNavEntry(\n props as NavEntryProps,\n context,\n itemClasses,\n {\n root: navItemClassNames.root,\n listItem: navItemClassNames.listItem,\n icon: navItemClassNames.icon,\n content: navItemClassNames.content,\n },\n true,\n );\n}\nNavItem.displayName = 'NavItem';\n\n/**\n * An indented entry inside a `Nav.Category`: a link when `href` is given, a button otherwise.\n * Selected like `Nav.Item` (a click that the browser opens somewhere else selects nothing; one\n * whose default your `onClick` prevents is selected), and typed by overloads like `Nav.Item`\n * (button, link, then {@link NavSubItemDynamicProps}).\n *\n * Also exported as `NavSubItem` (import the flat name from React Server Components).\n */\nfunction NavSubItem(props: NavSubItemButtonProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemAnchorProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemDynamicProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemProps | NavSubItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.SubItem');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n return renderNavEntry(\n props as NavEntryProps,\n context,\n subItemClasses,\n { root: navSubItemClassNames.root, listItem: navSubItemClassNames.listItem },\n false,\n );\n}\nNavSubItem.displayName = 'NavSubItem';\n\n// ---------------------------------------------------------------------------\n// Nav (root)\n// ---------------------------------------------------------------------------\n\nconst NavRoot = ({\n value: valueProp,\n defaultValue: defaultValueProp,\n onValueChange,\n selectedValue,\n defaultSelectedValue,\n onNavItemSelect,\n openCategories: openCategoriesProp,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n className,\n children,\n ref,\n ...rest\n}: NavProps) => {\n const controlledValue = resolveDeprecatedProp(\n 'Nav',\n valueProp,\n selectedValue,\n 'selectedValue',\n 'value',\n );\n const defaultValue =\n resolveDeprecatedProp(\n 'Nav',\n defaultValueProp,\n defaultSelectedValue,\n 'defaultSelectedValue',\n 'defaultValue',\n ) ?? '';\n if (onNavItemSelect !== undefined) warnDeprecated('Nav', 'onNavItemSelect', 'onValueChange');\n\n const [value, setValue] = useControllable(controlledValue, defaultValue, onValueChange);\n const notifyNavItemSelect = useEventCallback(onNavItemSelect);\n const select = React.useCallback(\n (next: string) => {\n setValue(next);\n // Deprecated event-named alias: every activation, re-selection included (C-NAMING).\n notifyNavItemSelect(next);\n },\n [setValue, notifyNavItemSelect],\n );\n\n const [initialOpenCategories] = React.useState<readonly string[]>(\n () =>\n defaultOpenCategories ?? findCategoriesContaining(children, controlledValue ?? defaultValue),\n );\n const [openCategories, setOpenCategories] = useControllable<readonly string[]>(\n openCategoriesProp,\n initialOpenCategories,\n (next) => onOpenCategoriesChange?.([...next]),\n );\n const toggleCategory = React.useCallback(\n (category: string) => {\n setOpenCategories((previous) =>\n previous.includes(category)\n ? previous.filter((entry) => entry !== category)\n : [...previous, category],\n );\n },\n [setOpenCategories],\n );\n\n // Duplicate values (C-DEV): the mounted items and categories per value (written from their\n // effects only); a second one with a value already in use warns once per value.\n const valueCountsRef = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback((kind: NavValueKind, entry: string) => {\n const counts = (valueCountsRef.current ??= new Map<string, number>());\n const key = `${kind}:${entry}`;\n const count = (counts.get(key) ?? 0) + 1;\n counts.set(key, count);\n if (count > 1) warnDuplicateValue(kind, entry);\n return () => {\n const remaining = (counts.get(key) ?? 1) - 1;\n if (remaining > 0) counts.set(key, remaining);\n else counts.delete(key);\n };\n }, []);\n\n const [categoryStore] = React.useState(createCategoryStore);\n\n const contextValue = React.useMemo<NavContextValue>(\n () => ({\n value,\n select,\n openCategories,\n toggleCategory,\n registerValue,\n currentCategory,\n categoryStore,\n }),\n [value, select, openCategories, toggleCategory, registerValue, currentCategory, categoryStore],\n );\n\n return (\n <NavContext.Provider value={contextValue}>\n <nav\n aria-label=\"Navigation\"\n {...rest}\n ref={ref}\n className={cn(\n navClassNames.root,\n 'w-60 border-e border-border bg-background py-2',\n className,\n )}\n >\n <ul className={cn(navClassNames.list, 'm-0 list-none p-0')}>{children}</ul>\n </nav>\n </NavContext.Provider>\n );\n};\nNavRoot.displayName = 'Nav';\n\n/**\n * A vertical side navigation (`<nav>` landmark, default name \"Navigation\") with items, links and\n * collapsible categories.\n *\n * - **Selection**: `value`/`defaultValue`/`onValueChange` (`onValueChange` fires only when the\n * value changes). The deprecated `selectedValue`/`defaultSelectedValue`/`onNavItemSelect` still\n * work; `onNavItemSelect` keeps firing on every activation, re-selection included. A click that\n * opens a link in another tab or window (or downloads it) selects nothing, unless the item's\n * `onClick` prevents the default (client-side routing: then nothing opens elsewhere).\n * - **Categories**: `openCategories`/`defaultOpenCategories`/`onOpenCategoriesChange`. Without\n * `defaultOpenCategories`, the categories containing the selected item (`value` or\n * `defaultValue`) start open. A closed category that contains the selected item marks its toggle\n * (`aria-current=\"true\"`, `data-contains-current`, the selected look); pass `currentCategory`\n * for sub-items your own component renders inside a closed category.\n * - **Values** are unique: among the items and sub-items, and among the categories (a duplicate\n * warns in development).\n *\n * Sub-components are also exported under flat names (`NavCategory`, `NavItem`, `NavSubItem`):\n * React Server Components import those, because dotted access (`Nav.Item`) needs a client file.\n */\nexport const Nav = /* @__PURE__ */ Object.assign(NavRoot, {\n Category: NavCategory,\n Item: NavItem,\n SubItem: NavSubItem,\n});\n\nexport { NavCategory, NavItem, NavSubItem };\n"],"mappings":"wfAkDA,SAAS8B,GAAwC,CAC/C,IAAMC,EAAa,IAAI,IACjBC,EAAY,IAAI,IAChBC,MAAeD,EAAU,QAAS,GAAaE,EAAS,CAAC,EAC/D,MAAO,CACL,OAAO,EAAO,EAAU,EACjBH,EAAW,IAAII,CAAK,GAAK,QAAUC,IACpCA,IAAa,KAAML,EAAW,OAAOI,CAAK,EACzCJ,EAAW,IAAII,EAAOC,CAAQ,EACnCH,EAAO,EACT,EACA,OAAO,EAAO,EAAU,CAClBF,EAAW,IAAII,CAAK,IAAMC,IAC9BL,EAAW,OAAOI,CAAK,EACvBF,EAAO,EACT,EACA,IAAM,GAAUF,EAAW,IAAII,CAAK,EACpC,UAAU,EAAU,CAElB,OADAH,EAAU,IAAIE,CAAQ,MACT,CACXF,EAAU,OAAOE,CAAQ,CAC3B,CACF,CACF,CACF,CAgBA,IAAMG,EAAarC,EAAM,cAAsC,IAAI,EACnE,EAAW,YAAc,aAEzB,IAAMsC,MAAa,CAAC,EACdC,EAAqC,CACzC,MAAO,GACP,OAAQD,EACR,eAAgB,CAAC,EACjB,eAAgBA,EAChB,kBAAqBA,EACrB,gBAAiB,IAAA,GACjB,cAAe,CAAE,OAAQA,EAAM,OAAQA,EAAM,QAAW,IAAA,GAAW,cAAiBA,CAAK,CAC3F,EAMME,EAA0BxC,EAAM,cAA6B,IAAI,EACvE,EAAwB,YAAc,0BAGtC,SAASyC,EAAc,EAAwC,CAI7D,OAHgBzC,EAAM,WAAWqC,CAC7B,IACJjB,EAAA,qBAAqBsB,EAAe,KAAK,EAClCH,EACT,CAEA,SAASI,EAAmB,EAAoB,EAAqB,CACnEvB,EAAA,SACE,iBAAiBwB,EAAK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