@mortenbrudvik/waveui 0.4.0 → 0.7.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 +1221 -173
- package/dist/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/components/button/Button.cjs +2 -0
- package/dist/components/button/Button.cjs.map +1 -0
- package/dist/components/button/Button.mjs +50 -0
- package/dist/components/button/Button.mjs.map +1 -0
- package/dist/components/button/Button.semantics.cjs +2 -0
- package/dist/components/button/Button.semantics.cjs.map +1 -0
- package/dist/components/button/Button.semantics.mjs +61 -0
- package/dist/components/button/Button.semantics.mjs.map +1 -0
- package/dist/components/button/Button.slots.cjs +2 -0
- package/dist/components/button/Button.slots.cjs.map +1 -0
- package/dist/components/button/Button.slots.mjs +47 -0
- package/dist/components/button/Button.slots.mjs.map +1 -0
- package/dist/components/button/CompoundButton.cjs +2 -0
- package/dist/components/button/CompoundButton.cjs.map +1 -0
- package/dist/components/button/CompoundButton.mjs +53 -0
- package/dist/components/button/CompoundButton.mjs.map +1 -0
- package/dist/components/button/Link.cjs +2 -0
- package/dist/components/button/Link.cjs.map +1 -0
- package/dist/components/button/Link.mjs +37 -0
- package/dist/components/button/Link.mjs.map +1 -0
- package/dist/components/button/MenuButton.cjs +2 -0
- package/dist/components/button/MenuButton.cjs.map +1 -0
- package/dist/components/button/MenuButton.mjs +45 -0
- package/dist/components/button/MenuButton.mjs.map +1 -0
- package/dist/components/button/SplitButton.cjs +2 -0
- package/dist/components/button/SplitButton.cjs.map +1 -0
- package/dist/components/button/SplitButton.mjs +66 -0
- package/dist/components/button/SplitButton.mjs.map +1 -0
- package/dist/components/button/ToggleButton.cjs +2 -0
- package/dist/components/button/ToggleButton.cjs.map +1 -0
- package/dist/components/button/ToggleButton.mjs +65 -0
- package/dist/components/button/ToggleButton.mjs.map +1 -0
- package/dist/components/button/Toolbar.cjs +2 -0
- package/dist/components/button/Toolbar.cjs.map +1 -0
- package/dist/components/button/Toolbar.context.cjs +2 -0
- package/dist/components/button/Toolbar.context.cjs.map +1 -0
- package/dist/components/button/Toolbar.context.mjs +31 -0
- package/dist/components/button/Toolbar.context.mjs.map +1 -0
- package/dist/components/button/Toolbar.mjs +63 -0
- package/dist/components/button/Toolbar.mjs.map +1 -0
- package/dist/components/button/Toolbar.parts.cjs +2 -0
- package/dist/components/button/Toolbar.parts.cjs.map +1 -0
- package/dist/components/button/Toolbar.parts.mjs +131 -0
- package/dist/components/button/Toolbar.parts.mjs.map +1 -0
- package/dist/components/button/buttonStyles.cjs +2 -0
- package/dist/components/button/buttonStyles.cjs.map +1 -0
- package/dist/components/button/buttonStyles.mjs +39 -0
- package/dist/components/button/buttonStyles.mjs.map +1 -0
- package/dist/components/data-display/Avatar.cjs +2 -0
- package/dist/components/data-display/Avatar.cjs.map +1 -0
- package/dist/components/data-display/Avatar.mjs +157 -0
- package/dist/components/data-display/Avatar.mjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.cjs +2 -0
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -0
- package/dist/components/data-display/AvatarGroup.mjs +134 -0
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -0
- package/dist/components/data-display/Badge.cjs +2 -0
- package/dist/components/data-display/Badge.cjs.map +1 -0
- package/dist/components/data-display/Badge.colors.cjs +2 -0
- package/dist/components/data-display/Badge.colors.cjs.map +1 -0
- package/dist/components/data-display/Badge.colors.mjs +58 -0
- package/dist/components/data-display/Badge.colors.mjs.map +1 -0
- package/dist/components/data-display/Badge.mjs +32 -0
- package/dist/components/data-display/Badge.mjs.map +1 -0
- package/dist/components/data-display/CounterBadge.cjs +2 -0
- package/dist/components/data-display/CounterBadge.cjs.map +1 -0
- package/dist/components/data-display/CounterBadge.mjs +28 -0
- package/dist/components/data-display/CounterBadge.mjs.map +1 -0
- package/dist/components/data-display/Divider.cjs +2 -0
- package/dist/components/data-display/Divider.cjs.map +1 -0
- package/dist/components/data-display/Divider.mjs +52 -0
- package/dist/components/data-display/Divider.mjs.map +1 -0
- package/dist/components/data-display/Image.cjs +2 -0
- package/dist/components/data-display/Image.cjs.map +1 -0
- package/dist/components/data-display/Image.mjs +32 -0
- package/dist/components/data-display/Image.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +2 -0
- package/dist/components/data-display/InfoLabel.cjs.map +1 -0
- package/dist/components/data-display/InfoLabel.mjs +104 -0
- package/dist/components/data-display/InfoLabel.mjs.map +1 -0
- package/dist/components/data-display/List.cjs +2 -0
- package/dist/components/data-display/List.cjs.map +1 -0
- package/dist/components/data-display/List.mjs +381 -0
- package/dist/components/data-display/List.mjs.map +1 -0
- package/dist/components/data-display/List.registry.cjs +2 -0
- package/dist/components/data-display/List.registry.cjs.map +1 -0
- package/dist/components/data-display/List.registry.mjs +101 -0
- package/dist/components/data-display/List.registry.mjs.map +1 -0
- package/dist/components/data-display/Persona.cjs +2 -0
- package/dist/components/data-display/Persona.cjs.map +1 -0
- package/dist/components/data-display/Persona.mjs +48 -0
- package/dist/components/data-display/Persona.mjs.map +1 -0
- package/dist/components/data-display/PresenceBadge.cjs +2 -0
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -0
- package/dist/components/data-display/PresenceBadge.mjs +71 -0
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -0
- package/dist/components/data-display/Tag.cjs +2 -0
- package/dist/components/data-display/Tag.cjs.map +1 -0
- package/dist/components/data-display/Tag.mjs +147 -0
- package/dist/components/data-display/Tag.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.cjs +2 -0
- package/dist/components/feedback/MessageBar.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.mjs +144 -0
- package/dist/components/feedback/MessageBar.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +2 -0
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.mjs +45 -0
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -0
- package/dist/components/feedback/ProgressBar.cjs +2 -0
- package/dist/components/feedback/ProgressBar.cjs.map +1 -0
- package/dist/components/feedback/ProgressBar.mjs +72 -0
- package/dist/components/feedback/ProgressBar.mjs.map +1 -0
- package/dist/components/feedback/Skeleton.cjs +2 -0
- package/dist/components/feedback/Skeleton.cjs.map +1 -0
- package/dist/components/feedback/Skeleton.mjs +47 -0
- package/dist/components/feedback/Skeleton.mjs.map +1 -0
- package/dist/components/feedback/Spinner.cjs +2 -0
- package/dist/components/feedback/Spinner.cjs.map +1 -0
- package/dist/components/feedback/Spinner.mjs +60 -0
- package/dist/components/feedback/Spinner.mjs.map +1 -0
- package/dist/components/feedback/Toast.cjs +2 -0
- package/dist/components/feedback/Toast.cjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +347 -0
- package/dist/components/feedback/Toast.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +2 -0
- package/dist/components/input/Checkbox.cjs.map +1 -0
- package/dist/components/input/Checkbox.mjs +96 -0
- package/dist/components/input/Checkbox.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +6 -0
- package/dist/components/input/ColorPicker.cjs.map +1 -0
- package/dist/components/input/ColorPicker.mjs +236 -0
- package/dist/components/input/ColorPicker.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +2 -0
- package/dist/components/input/Combobox.cjs.map +1 -0
- package/dist/components/input/Combobox.expand.cjs +2 -0
- package/dist/components/input/Combobox.expand.cjs.map +1 -0
- package/dist/components/input/Combobox.expand.mjs +38 -0
- package/dist/components/input/Combobox.expand.mjs.map +1 -0
- package/dist/components/input/Combobox.mjs +187 -0
- package/dist/components/input/Combobox.mjs.map +1 -0
- package/dist/components/input/DatePicker.cjs +2 -0
- package/dist/components/input/DatePicker.cjs.map +1 -0
- package/dist/components/input/DatePicker.mjs +340 -0
- package/dist/components/input/DatePicker.mjs.map +1 -0
- package/dist/components/input/Dropdown.cjs +2 -0
- package/dist/components/input/Dropdown.cjs.map +1 -0
- package/dist/components/input/Dropdown.mjs +128 -0
- package/dist/components/input/Dropdown.mjs.map +1 -0
- package/dist/components/input/Field.cjs +2 -0
- package/dist/components/input/Field.cjs.map +1 -0
- package/dist/components/input/Field.mjs +200 -0
- package/dist/components/input/Field.mjs.map +1 -0
- package/dist/components/input/Input.cjs +2 -0
- package/dist/components/input/Input.cjs.map +1 -0
- package/dist/components/input/Input.mjs +81 -0
- package/dist/components/input/Input.mjs.map +1 -0
- package/dist/components/input/Label.cjs +2 -0
- package/dist/components/input/Label.cjs.map +1 -0
- package/dist/components/input/Label.mjs +28 -0
- package/dist/components/input/Label.mjs.map +1 -0
- package/dist/components/input/Option.cjs +2 -0
- package/dist/components/input/Option.cjs.map +1 -0
- package/dist/components/input/Option.mjs +169 -0
- package/dist/components/input/Option.mjs.map +1 -0
- package/dist/components/input/RadioGroup.cjs +2 -0
- package/dist/components/input/RadioGroup.cjs.map +1 -0
- package/dist/components/input/RadioGroup.mjs +139 -0
- package/dist/components/input/RadioGroup.mjs.map +1 -0
- package/dist/components/input/Rating.cjs +2 -0
- package/dist/components/input/Rating.cjs.map +1 -0
- package/dist/components/input/Rating.mjs +196 -0
- package/dist/components/input/Rating.mjs.map +1 -0
- package/dist/components/input/SearchBox.cjs +2 -0
- package/dist/components/input/SearchBox.cjs.map +1 -0
- package/dist/components/input/SearchBox.mjs +205 -0
- package/dist/components/input/SearchBox.mjs.map +1 -0
- package/dist/components/input/Select.cjs +2 -0
- package/dist/components/input/Select.cjs.map +1 -0
- package/dist/components/input/Select.mjs +33 -0
- package/dist/components/input/Select.mjs.map +1 -0
- package/dist/components/input/Slider.cjs +2 -0
- package/dist/components/input/Slider.cjs.map +1 -0
- package/dist/components/input/Slider.mjs +79 -0
- package/dist/components/input/Slider.mjs.map +1 -0
- package/dist/components/input/SpinButton.cjs +2 -0
- package/dist/components/input/SpinButton.cjs.map +1 -0
- package/dist/components/input/SpinButton.mjs +157 -0
- package/dist/components/input/SpinButton.mjs.map +1 -0
- package/dist/components/input/SwatchPicker.cjs +2 -0
- package/dist/components/input/SwatchPicker.cjs.map +1 -0
- package/dist/components/input/SwatchPicker.mjs +113 -0
- package/dist/components/input/SwatchPicker.mjs.map +1 -0
- package/dist/components/input/Switch.cjs +2 -0
- package/dist/components/input/Switch.cjs.map +1 -0
- package/dist/components/input/Switch.mjs +92 -0
- package/dist/components/input/Switch.mjs.map +1 -0
- package/dist/components/input/TagPicker.cjs +2 -0
- package/dist/components/input/TagPicker.cjs.map +1 -0
- package/dist/components/input/TagPicker.mjs +249 -0
- package/dist/components/input/TagPicker.mjs.map +1 -0
- package/dist/components/input/Textarea.cjs +2 -0
- package/dist/components/input/Textarea.cjs.map +1 -0
- package/dist/components/input/Textarea.mjs +32 -0
- package/dist/components/input/Textarea.mjs.map +1 -0
- package/dist/components/input/TimePicker.cjs +2 -0
- package/dist/components/input/TimePicker.cjs.map +1 -0
- package/dist/components/input/TimePicker.mjs +292 -0
- package/dist/components/input/TimePicker.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +2 -0
- package/dist/components/input/colorUtils.cjs.map +1 -0
- package/dist/components/input/colorUtils.mjs +96 -0
- package/dist/components/input/colorUtils.mjs.map +1 -0
- package/dist/components/input/dateUtils.cjs +2 -0
- package/dist/components/input/dateUtils.cjs.map +1 -0
- package/dist/components/input/dateUtils.mjs +250 -0
- package/dist/components/input/dateUtils.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +2 -0
- package/dist/components/input/pickerStyles.cjs.map +1 -0
- package/dist/components/input/pickerStyles.mjs +10 -0
- package/dist/components/input/pickerStyles.mjs.map +1 -0
- package/dist/components/internal/HiddenInput.cjs +2 -0
- package/dist/components/internal/HiddenInput.cjs.map +1 -0
- package/dist/components/internal/HiddenInput.mjs +88 -0
- package/dist/components/internal/HiddenInput.mjs.map +1 -0
- package/dist/components/layout/Accordion.cjs +2 -0
- package/dist/components/layout/Accordion.cjs.map +1 -0
- package/dist/components/layout/Accordion.mjs +236 -0
- package/dist/components/layout/Accordion.mjs.map +1 -0
- package/dist/components/layout/Card.cjs +2 -0
- package/dist/components/layout/Card.cjs.map +1 -0
- package/dist/components/layout/Card.mjs +121 -0
- package/dist/components/layout/Card.mjs.map +1 -0
- package/dist/components/layout/Carousel.cjs +2 -0
- package/dist/components/layout/Carousel.cjs.map +1 -0
- package/dist/components/layout/Carousel.mjs +205 -0
- package/dist/components/layout/Carousel.mjs.map +1 -0
- package/dist/components/layout/Flex.cjs +2 -0
- package/dist/components/layout/Flex.cjs.map +1 -0
- package/dist/components/layout/Flex.mjs +54 -0
- package/dist/components/layout/Flex.mjs.map +1 -0
- package/dist/components/layout/Grid.cjs +2 -0
- package/dist/components/layout/Grid.cjs.map +1 -0
- package/dist/components/layout/Grid.mjs +62 -0
- package/dist/components/layout/Grid.mjs.map +1 -0
- package/dist/components/layout/Overflow.cjs +2 -0
- package/dist/components/layout/Overflow.cjs.map +1 -0
- package/dist/components/layout/Overflow.mjs +269 -0
- package/dist/components/layout/Overflow.mjs.map +1 -0
- package/dist/components/layout/Stack.cjs +2 -0
- package/dist/components/layout/Stack.cjs.map +1 -0
- package/dist/components/layout/Stack.mjs +39 -0
- package/dist/components/layout/Stack.mjs.map +1 -0
- package/dist/components/layout/TabList.cjs +2 -0
- package/dist/components/layout/TabList.cjs.map +1 -0
- package/dist/components/layout/TabList.mjs +238 -0
- package/dist/components/layout/TabList.mjs.map +1 -0
- package/dist/components/layout/Tree.cjs +2 -0
- package/dist/components/layout/Tree.cjs.map +1 -0
- package/dist/components/layout/Tree.mjs +220 -0
- package/dist/components/layout/Tree.mjs.map +1 -0
- package/dist/components/layout/disclosureIds.cjs +2 -0
- package/dist/components/layout/disclosureIds.cjs.map +1 -0
- package/dist/components/layout/disclosureIds.mjs +12 -0
- package/dist/components/layout/disclosureIds.mjs.map +1 -0
- package/dist/components/motion/Presence.cjs +2 -0
- package/dist/components/motion/Presence.cjs.map +1 -0
- package/dist/components/motion/Presence.mjs +35 -0
- package/dist/components/motion/Presence.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +2 -0
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.mjs +144 -0
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -0
- package/dist/components/navigation/Menu.cjs +2 -0
- package/dist/components/navigation/Menu.cjs.map +1 -0
- package/dist/components/navigation/Menu.context.cjs +2 -0
- package/dist/components/navigation/Menu.context.cjs.map +1 -0
- package/dist/components/navigation/Menu.context.mjs +82 -0
- package/dist/components/navigation/Menu.context.mjs.map +1 -0
- package/dist/components/navigation/Menu.group.cjs +2 -0
- package/dist/components/navigation/Menu.group.cjs.map +1 -0
- package/dist/components/navigation/Menu.group.mjs +58 -0
- package/dist/components/navigation/Menu.group.mjs.map +1 -0
- package/dist/components/navigation/Menu.items.cjs +2 -0
- package/dist/components/navigation/Menu.items.cjs.map +1 -0
- package/dist/components/navigation/Menu.items.mjs +127 -0
- package/dist/components/navigation/Menu.items.mjs.map +1 -0
- package/dist/components/navigation/Menu.link.cjs +2 -0
- package/dist/components/navigation/Menu.link.cjs.map +1 -0
- package/dist/components/navigation/Menu.link.mjs +41 -0
- package/dist/components/navigation/Menu.link.mjs.map +1 -0
- package/dist/components/navigation/Menu.mjs +27 -0
- package/dist/components/navigation/Menu.mjs.map +1 -0
- package/dist/components/navigation/Menu.popover.cjs +2 -0
- package/dist/components/navigation/Menu.popover.cjs.map +1 -0
- package/dist/components/navigation/Menu.popover.mjs +231 -0
- package/dist/components/navigation/Menu.popover.mjs.map +1 -0
- package/dist/components/navigation/Menu.root.cjs +2 -0
- package/dist/components/navigation/Menu.root.cjs.map +1 -0
- package/dist/components/navigation/Menu.root.mjs +308 -0
- package/dist/components/navigation/Menu.root.mjs.map +1 -0
- package/dist/components/navigation/Menu.selectable.cjs +2 -0
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -0
- package/dist/components/navigation/Menu.selectable.mjs +89 -0
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -0
- package/dist/components/navigation/Menu.shared.cjs +2 -0
- package/dist/components/navigation/Menu.shared.cjs.map +1 -0
- package/dist/components/navigation/Menu.shared.mjs +23 -0
- package/dist/components/navigation/Menu.shared.mjs.map +1 -0
- package/dist/components/navigation/Menu.splitGroup.cjs +2 -0
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -0
- package/dist/components/navigation/Menu.splitGroup.mjs +51 -0
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -0
- package/dist/components/navigation/Menu.trigger.cjs +2 -0
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -0
- package/dist/components/navigation/Menu.trigger.mjs +79 -0
- package/dist/components/navigation/Menu.trigger.mjs.map +1 -0
- package/dist/components/navigation/Nav.cjs +2 -0
- package/dist/components/navigation/Nav.cjs.map +1 -0
- package/dist/components/navigation/Nav.mjs +276 -0
- package/dist/components/navigation/Nav.mjs.map +1 -0
- package/dist/components/navigation/Pagination.cjs +2 -0
- package/dist/components/navigation/Pagination.cjs.map +1 -0
- package/dist/components/navigation/Pagination.mjs +110 -0
- package/dist/components/navigation/Pagination.mjs.map +1 -0
- package/dist/components/navigation/Stepper.cjs +2 -0
- package/dist/components/navigation/Stepper.cjs.map +1 -0
- package/dist/components/navigation/Stepper.mjs +204 -0
- package/dist/components/navigation/Stepper.mjs.map +1 -0
- package/dist/components/overlays/Dialog.cjs +2 -0
- package/dist/components/overlays/Dialog.cjs.map +1 -0
- package/dist/components/overlays/Dialog.mjs +180 -0
- package/dist/components/overlays/Dialog.mjs.map +1 -0
- package/dist/components/overlays/Dialog.shared.cjs +2 -0
- package/dist/components/overlays/Dialog.shared.cjs.map +1 -0
- package/dist/components/overlays/Dialog.shared.mjs +227 -0
- package/dist/components/overlays/Dialog.shared.mjs.map +1 -0
- package/dist/components/overlays/Drawer.cjs +2 -0
- package/dist/components/overlays/Drawer.cjs.map +1 -0
- package/dist/components/overlays/Drawer.mjs +192 -0
- package/dist/components/overlays/Drawer.mjs.map +1 -0
- package/dist/components/overlays/Popover.cjs +2 -0
- package/dist/components/overlays/Popover.cjs.map +1 -0
- package/dist/components/overlays/Popover.mjs +365 -0
- package/dist/components/overlays/Popover.mjs.map +1 -0
- package/dist/components/overlays/Popover.shared.cjs +2 -0
- package/dist/components/overlays/Popover.shared.cjs.map +1 -0
- package/dist/components/overlays/Popover.shared.mjs +182 -0
- package/dist/components/overlays/Popover.shared.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.mjs +181 -0
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -0
- package/dist/components/overlays/Tooltip.cjs +2 -0
- package/dist/components/overlays/Tooltip.cjs.map +1 -0
- package/dist/components/overlays/Tooltip.mjs +160 -0
- package/dist/components/overlays/Tooltip.mjs.map +1 -0
- package/dist/components/portal/Portal.cjs +2 -0
- package/dist/components/portal/Portal.cjs.map +1 -0
- package/dist/components/portal/Portal.mjs +45 -0
- package/dist/components/portal/Portal.mjs.map +1 -0
- package/dist/components/provider/WaveProvider.cjs +2 -0
- package/dist/components/provider/WaveProvider.cjs.map +1 -0
- package/dist/components/provider/WaveProvider.mjs +51 -0
- package/dist/components/provider/WaveProvider.mjs.map +1 -0
- package/dist/components/table/DataGrid.cjs +2 -0
- package/dist/components/table/DataGrid.cjs.map +1 -0
- package/dist/components/table/DataGrid.mjs +489 -0
- package/dist/components/table/DataGrid.mjs.map +1 -0
- package/dist/components/table/Table.cjs +2 -0
- package/dist/components/table/Table.cjs.map +1 -0
- package/dist/components/table/Table.mjs +99 -0
- package/dist/components/table/Table.mjs.map +1 -0
- package/dist/components/table/useGridNavigation.cjs +2 -0
- package/dist/components/table/useGridNavigation.cjs.map +1 -0
- package/dist/components/table/useGridNavigation.mjs +336 -0
- package/dist/components/table/useGridNavigation.mjs.map +1 -0
- package/dist/components/typography/Text.cjs +2 -0
- package/dist/components/typography/Text.cjs.map +1 -0
- package/dist/components/typography/Text.mjs +38 -0
- package/dist/components/typography/Text.mjs.map +1 -0
- package/dist/hooks/useAnnounce.cjs +2 -0
- package/dist/hooks/useAnnounce.cjs.map +1 -0
- package/dist/hooks/useAnnounce.mjs +88 -0
- package/dist/hooks/useAnnounce.mjs.map +1 -0
- package/dist/hooks/useCheckedValues.cjs +2 -0
- package/dist/hooks/useCheckedValues.cjs.map +1 -0
- package/dist/hooks/useCheckedValues.mjs +102 -0
- package/dist/hooks/useCheckedValues.mjs.map +1 -0
- package/dist/hooks/useContextMenuAnchor.cjs +2 -0
- package/dist/hooks/useContextMenuAnchor.cjs.map +1 -0
- package/dist/hooks/useContextMenuAnchor.mjs +132 -0
- package/dist/hooks/useContextMenuAnchor.mjs.map +1 -0
- package/dist/hooks/useControllable.cjs +2 -0
- package/dist/hooks/useControllable.cjs.map +1 -0
- package/dist/hooks/useControllable.mjs +37 -0
- package/dist/hooks/useControllable.mjs.map +1 -0
- package/dist/hooks/useDirection.cjs +2 -0
- package/dist/hooks/useDirection.cjs.map +1 -0
- package/dist/hooks/useDirection.mjs +57 -0
- package/dist/hooks/useDirection.mjs.map +1 -0
- package/dist/hooks/useDismiss.cjs +2 -0
- package/dist/hooks/useDismiss.cjs.map +1 -0
- package/dist/hooks/useDismiss.mjs +57 -0
- package/dist/hooks/useDismiss.mjs.map +1 -0
- package/dist/hooks/useEventCallback.cjs +2 -0
- package/dist/hooks/useEventCallback.cjs.map +1 -0
- package/dist/hooks/useEventCallback.mjs +16 -0
- package/dist/hooks/useEventCallback.mjs.map +1 -0
- package/dist/hooks/useFieldControl.cjs +2 -0
- package/dist/hooks/useFieldControl.cjs.map +1 -0
- package/dist/hooks/useFieldControl.mjs +62 -0
- package/dist/hooks/useFieldControl.mjs.map +1 -0
- package/dist/hooks/useFocusTrap.cjs +2 -0
- package/dist/hooks/useFocusTrap.cjs.map +1 -0
- package/dist/hooks/useFocusTrap.mjs +266 -0
- package/dist/hooks/useFocusTrap.mjs.map +1 -0
- package/dist/hooks/useFormReset.cjs +2 -0
- package/dist/hooks/useFormReset.cjs.map +1 -0
- package/dist/hooks/useFormReset.mjs +33 -0
- package/dist/hooks/useFormReset.mjs.map +1 -0
- package/dist/hooks/useHoverIntent.cjs +2 -0
- package/dist/hooks/useHoverIntent.cjs.map +1 -0
- package/dist/hooks/useHoverIntent.mjs +201 -0
- package/dist/hooks/useHoverIntent.mjs.map +1 -0
- package/dist/hooks/useId.cjs +2 -0
- package/dist/hooks/useId.cjs.map +1 -0
- package/dist/hooks/useId.mjs +11 -0
- package/dist/hooks/useId.mjs.map +1 -0
- package/dist/hooks/useIsClient.cjs +2 -0
- package/dist/hooks/useIsClient.cjs.map +1 -0
- package/dist/hooks/useIsClient.mjs +19 -0
- package/dist/hooks/useIsClient.mjs.map +1 -0
- package/dist/hooks/useListbox.cjs +2 -0
- package/dist/hooks/useListbox.cjs.map +1 -0
- package/dist/hooks/useListbox.mjs +492 -0
- package/dist/hooks/useListbox.mjs.map +1 -0
- package/dist/hooks/useMergedRefs.cjs +2 -0
- package/dist/hooks/useMergedRefs.cjs.map +1 -0
- package/dist/hooks/useMergedRefs.mjs +57 -0
- package/dist/hooks/useMergedRefs.mjs.map +1 -0
- package/dist/hooks/useModalIsolation.cjs +2 -0
- package/dist/hooks/useModalIsolation.cjs.map +1 -0
- package/dist/hooks/useModalIsolation.mjs +87 -0
- package/dist/hooks/useModalIsolation.mjs.map +1 -0
- package/dist/hooks/useModalLayer.cjs +2 -0
- package/dist/hooks/useModalLayer.cjs.map +1 -0
- package/dist/hooks/useModalLayer.mjs +30 -0
- package/dist/hooks/useModalLayer.mjs.map +1 -0
- package/dist/hooks/usePopupPosition.cjs +2 -0
- package/dist/hooks/usePopupPosition.cjs.map +1 -0
- package/dist/hooks/usePopupPosition.mjs +117 -0
- package/dist/hooks/usePopupPosition.mjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +2 -0
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -0
- package/dist/hooks/usePrefersReducedMotion.mjs +24 -0
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -0
- package/dist/hooks/usePresence.cjs +2 -0
- package/dist/hooks/usePresence.cjs.map +1 -0
- package/dist/hooks/usePresence.mjs +136 -0
- package/dist/hooks/usePresence.mjs.map +1 -0
- package/dist/hooks/usePreserveFocus.cjs +2 -0
- package/dist/hooks/usePreserveFocus.cjs.map +1 -0
- package/dist/hooks/usePreserveFocus.mjs +50 -0
- package/dist/hooks/usePreserveFocus.mjs.map +1 -0
- package/dist/hooks/useRestoreFocus.cjs +2 -0
- package/dist/hooks/useRestoreFocus.cjs.map +1 -0
- package/dist/hooks/useRestoreFocus.mjs +271 -0
- package/dist/hooks/useRestoreFocus.mjs.map +1 -0
- package/dist/hooks/useRovingTabIndex.cjs +2 -0
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -0
- package/dist/hooks/useRovingTabIndex.mjs +389 -0
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -0
- package/dist/hooks/useScrollLock.cjs +2 -0
- package/dist/hooks/useScrollLock.cjs.map +1 -0
- package/dist/hooks/useScrollLock.mjs +71 -0
- package/dist/hooks/useScrollLock.mjs.map +1 -0
- package/dist/hooks/useTriggerElement.cjs +2 -0
- package/dist/hooks/useTriggerElement.cjs.map +1 -0
- package/dist/hooks/useTriggerElement.mjs +126 -0
- package/dist/hooks/useTriggerElement.mjs.map +1 -0
- package/dist/hooks/useTypeahead.cjs +2 -0
- package/dist/hooks/useTypeahead.cjs.map +1 -0
- package/dist/hooks/useTypeahead.mjs +38 -0
- package/dist/hooks/useTypeahead.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +9099 -0
- package/dist/index.d.ts +7688 -1027
- package/dist/index.mjs +91 -5695
- package/dist/lib/aria.cjs +2 -0
- package/dist/lib/aria.cjs.map +1 -0
- package/dist/lib/aria.mjs +29 -0
- package/dist/lib/aria.mjs.map +1 -0
- package/dist/lib/children.cjs +2 -0
- package/dist/lib/children.cjs.map +1 -0
- package/dist/lib/children.mjs +37 -0
- package/dist/lib/children.mjs.map +1 -0
- package/dist/lib/cn.cjs +2 -0
- package/dist/lib/cn.cjs.map +1 -0
- package/dist/lib/cn.mjs +64 -0
- package/dist/lib/cn.mjs.map +1 -0
- package/dist/lib/composeEventHandlers.cjs +2 -0
- package/dist/lib/composeEventHandlers.cjs.map +1 -0
- package/dist/lib/composeEventHandlers.mjs +11 -0
- package/dist/lib/composeEventHandlers.mjs.map +1 -0
- package/dist/lib/dev.cjs +2 -0
- package/dist/lib/dev.cjs.map +1 -0
- package/dist/lib/dev.mjs +42 -0
- package/dist/lib/dev.mjs.map +1 -0
- package/dist/lib/direction.cjs +2 -0
- package/dist/lib/direction.cjs.map +1 -0
- package/dist/lib/direction.mjs +35 -0
- package/dist/lib/direction.mjs.map +1 -0
- package/dist/lib/events.cjs +2 -0
- package/dist/lib/events.cjs.map +1 -0
- package/dist/lib/events.mjs +31 -0
- package/dist/lib/events.mjs.map +1 -0
- package/dist/lib/focus.cjs +2 -0
- package/dist/lib/focus.cjs.map +1 -0
- package/dist/lib/focus.mjs +119 -0
- package/dist/lib/focus.mjs.map +1 -0
- package/dist/lib/globalRegistry.cjs +2 -0
- package/dist/lib/globalRegistry.cjs.map +1 -0
- package/dist/lib/globalRegistry.mjs +13 -0
- package/dist/lib/globalRegistry.mjs.map +1 -0
- package/dist/lib/icons.cjs +2 -0
- package/dist/lib/icons.cjs.map +1 -0
- package/dist/lib/icons.mjs +254 -0
- package/dist/lib/icons.mjs.map +1 -0
- package/dist/lib/labelInName.cjs +2 -0
- package/dist/lib/labelInName.cjs.map +1 -0
- package/dist/lib/labelInName.mjs +54 -0
- package/dist/lib/labelInName.mjs.map +1 -0
- package/dist/lib/layers.cjs +2 -0
- package/dist/lib/layers.cjs.map +1 -0
- package/dist/lib/layers.mjs +224 -0
- package/dist/lib/layers.mjs.map +1 -0
- package/dist/lib/mergeProps.cjs +2 -0
- package/dist/lib/mergeProps.cjs.map +1 -0
- package/dist/lib/mergeProps.mjs +21 -0
- package/dist/lib/mergeProps.mjs.map +1 -0
- package/dist/lib/mergeRefs.cjs +2 -0
- package/dist/lib/mergeRefs.cjs.map +1 -0
- package/dist/lib/mergeRefs.mjs +29 -0
- package/dist/lib/mergeRefs.mjs.map +1 -0
- package/dist/lib/renderTrigger.cjs +2 -0
- package/dist/lib/renderTrigger.cjs.map +1 -0
- package/dist/lib/renderTrigger.mjs +29 -0
- package/dist/lib/renderTrigger.mjs.map +1 -0
- package/dist/lib/slot.cjs +2 -0
- package/dist/lib/slot.cjs.map +1 -0
- package/dist/lib/slot.mjs +122 -0
- package/dist/lib/slot.mjs.map +1 -0
- package/dist/lib/styles.cjs +2 -0
- package/dist/lib/styles.cjs.map +1 -0
- package/dist/lib/styles.mjs +16 -0
- package/dist/lib/styles.mjs.map +1 -0
- package/dist/lib/theme.cjs +2 -0
- package/dist/lib/theme.cjs.map +1 -0
- package/dist/lib/theme.mjs +16 -0
- package/dist/lib/theme.mjs.map +1 -0
- package/dist/preflight.css +2 -0
- package/dist/styles.css +2 -0
- package/package.json +149 -100
- package/src/styles/animations.css +7 -39
- package/src/styles/base.css +103 -0
- package/src/styles/globals.css +10 -22
- package/src/styles/legacy-tokens.css +184 -0
- package/src/styles/preflight.css +7 -0
- package/src/styles/styles.css +32 -0
- package/src/styles/tailwind.css +17 -0
- package/src/styles/tokens.css +561 -221
- package/src/styles/variants.css +29 -0
|
@@ -0,0 +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("../../lib/composeEventHandlers.cjs"),o=require("../../hooks/useEventCallback.cjs"),s=require("../../hooks/useControllable.cjs"),c=require("../../hooks/useId.cjs"),l=require("../../lib/direction.cjs"),u=require("../../hooks/useRovingTabIndex.cjs"),d=require("../../hooks/useMergedRefs.cjs"),f=require("../../lib/styles.cjs"),p=require("../../lib/icons.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var g=m.createContext(null),_=m.createContext(null),v=m.createContext(!1),y=[],b={expanded:new Set,toggle:()=>{},expand:()=>{},activate:()=>{},selected:void 0,current:void 0,getTabIndex:()=>-1,focusValue:()=>{},onItemFocus:()=>{},registerValue:()=>()=>{}};function x(e){return m.useContext(g)||(r.reportMissingContext(e,`<Tree>`),b)}var S="Tree.Item was rendered inside the label of another Tree.Item, so it is not part of that item's child group: the parent cannot expand, its name includes the nested text, and a treeitem sits inside a label (axe aria-required-parent). A Tree.Item finds its nested items among its own children (written directly, in Fragments, or returned by a render function such as `children.map(renderNode)`), but not inside a component that renders Tree.Item itself. Build a data-driven tree with a render function instead of a recursive component.";function C(e){r.warnOnce(`Tree:duplicate:${e}`,`Tree: several items share the value "${e}". Item values must be unique within a Tree; items with the same value share their expanded, selected and focus state.`)}var w=({expandedItems:e,defaultExpandedItems:n,onExpandedItemsChange:i,onItemSelect:c,selected:l,current:f,className:p,children:b,onKeyDown:x,onKeyDownCapture:S,onFocus:w,onBlur:E,ref:D,...O})=>{let[k]=m.useState(()=>n??y),[A,j]=s.useControllable(e,k,e=>i?.([...e])),M=m.useMemo(()=>new Set(A),[A]),N=m.useCallback(e=>{j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[j]),P=m.useCallback(e=>{j(t=>{let n=e.filter(e=>!t.includes(e));return n.length>0?[...t,...n]:t})},[j]),F=o.useEventCallback(e=>{c?.(e)}),[I,L]=m.useState(null),R=m.useRef(null),z=m.useCallback(e=>{if(!r.isDev)return()=>{};R.current??=new Map;let t=R.current,n=(t.get(e)??0)+1;return t.set(e,n),n>1&&C(e),()=>{let n=(t.get(e)??1)-1;n>0?t.set(e,n):t.delete(e)}},[]),{containerProps:B,getTabIndex:V,focusValue:H}=u.useRovingTabIndex({activeValue:I??l??null,orientation:`vertical`,loop:!1,typeahead:!0}),U=m.useMemo(()=>({expanded:M,toggle:N,expand:P,activate:F,selected:l,current:f,getTabIndex:V,focusValue:H,onItemFocus:L,registerValue:z}),[M,N,P,F,l,f,V,H,z]),W=d.useMergedRefs(D,B.ref),G=e=>{e.key.length===1&&T(e.currentTarget),B.onKeyDown(e)},K=e=>{e.key===` `&&T(e.currentTarget),B.onKeyDownCapture(e)},q=e=>{let t=e.relatedTarget;(!t||!e.currentTarget.contains(t))&&L(null)};return(0,h.jsx)(g.Provider,{value:U,children:(0,h.jsx)(_.Provider,{value:null,children:(0,h.jsx)(`div`,{role:`tree`,className:t.cn(`text-body-1`,p),...O,"data-roving-container":``,onKeyDown:a.composeEventHandlers(x,G),onKeyDownCapture:a.composeEventHandlers(S,K),onFocus:a.composeEventHandlers(w,B.onFocus,{checkDefaultPrevented:!1}),onBlur:a.composeEventHandlers(E,q,{checkDefaultPrevented:!1}),ref:W,children:(0,h.jsx)(v.Provider,{value:!1,children:b})})})})};w.displayName=`Tree`;function T(e){e.querySelectorAll(`[role="treeitem"]`).forEach(e=>{let t=e.querySelector(`:scope > [data-tree-row] > [data-tree-label]`);if(!t)return;let n=t.getAttribute(`data-roving-text`)??t.textContent??``;e.getAttribute(`data-roving-text`)!==n&&e.setAttribute(`data-roving-text`,n)})}function E(e){return e.target?.closest?.(`[role="treeitem"]`)===e.currentTarget}function D(e){let t=e.target;return t===e.currentTarget||t?.closest?.(`[data-tree-row]`)?.parentElement===e.currentTarget}var O=({value:e,icon:o,leaf:s=!1,className:u,children:d,onClick:g,onKeyDown:y,onFocus:b,ref:C,...T})=>{let{"data-roving-text":k,...A}=T,j=x(`Tree.Item`),M=m.useContext(_),N=m.useContext(v),P=j.expanded.has(e),F=c.useId(`tree-item-label`),{registerValue:I}=j;m.useEffect(()=>I(e),[I,e]),m.useEffect(()=>{N&&r.warnOnce(`Tree.Item:inside-label`,S)},[N]);let L=[],R=[],z;n.flattenChildren(d).forEach(({key:e,node:t})=>{let r=(0,h.jsx)(m.Fragment,{children:t},e);n.isElementOfType(t,O)?(z??=t.props.value,L.push(r)):n.isElementOfType(t,w)?L.push(r):R.push(r)});let B=o&&i.slotRendersContent(o)?i.renderSlot(o,`span`,`inline-flex shrink-0`,{"aria-hidden":!0}):null,V=L.length>0&&!s,H=j.selected===void 0?void 0:j.selected===e,U=j.current!==void 0&&j.current!==null&&j.current===e,W=()=>{V&&j.toggle(e),j.activate(e)},G=e=>{D(e)&&(g?.(e),e.defaultPrevented||W())},K=t=>{if(!E(t)||(y?.(t),t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey))return;let n=l.getDirection(t.currentTarget)===`rtl`,r=n?`ArrowLeft`:`ArrowRight`,i=n?`ArrowRight`:`ArrowLeft`;switch(t.key){case`Enter`:case` `:t.preventDefault(),W();return;case r:if(t.preventDefault(),!V)return;P?z!==void 0&&j.focusValue(z):j.toggle(e);return;case i:t.preventDefault(),V&&P?j.toggle(e):M!==null&&j.focusValue(M);return;case`*`:{t.preventDefault();let e=t.currentTarget.parentElement?.querySelectorAll(`:scope > [role="treeitem"][aria-expanded="false"][data-roving-value]`);j.expand(Array.from(e??[],e=>e.getAttribute(`data-roving-value`)??``).filter(Boolean));return}}},q=t=>{t.target===t.currentTarget&&j.onItemFocus(e)};return(0,h.jsxs)(`div`,{role:`treeitem`,"aria-selected":H,"aria-current":U?!0:void 0,className:t.cn(`block outline-none`,`[&:focus-visible>[data-tree-row]]:outline-2 [&:focus-visible>[data-tree-row]]:-outline-offset-2 [&:focus-visible>[data-tree-row]]:outline-ring`,u),...A,"aria-labelledby":A[`aria-labelledby`]??(A[`aria-label`]===void 0?F:void 0),"aria-expanded":V?P:void 0,tabIndex:j.getTabIndex(e),"data-roving-value":e,"data-selected":H?``:void 0,"data-current":U?``:void 0,onClick:G,onKeyDown:K,onFocus:a.composeEventHandlers(b,q,{checkDefaultPrevented:!1}),ref:C,children:[(0,h.jsxs)(`div`,{"data-tree-row":``,className:t.cn(`flex cursor-pointer items-center gap-1.5 rounded px-2 py-1 hover:bg-subtle-hover`,H&&t.cn(`bg-subtle-selected font-semibold`,f.forcedColors.selectedContainer)),children:[V?(0,h.jsx)(p.ChevronRightIcon,{className:t.cn(`shrink-0 transition-transform motion-reduce:transition-none`,P?`rotate-90`:`wave-rtl:-scale-x-100`)}):(0,h.jsx)(`span`,{className:`w-3 shrink-0`,"aria-hidden":`true`}),B,(0,h.jsx)(`span`,{id:F,"data-tree-label":``,"data-roving-text":k,className:`truncate`,children:(0,h.jsx)(v.Provider,{value:!0,children:R})})]}),V&&P&&(0,h.jsx)(_.Provider,{value:e,children:(0,h.jsx)(v.Provider,{value:!1,children:(0,h.jsx)(`div`,{role:`group`,className:`ps-4`,children:L})})})]})};O.displayName=`TreeItem`;var k=Object.assign(w,{Item:O});exports.Tree=k,exports.TreeItem=O;
|
|
2
|
+
//# sourceMappingURL=Tree.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tree.cjs","names":["React","useControllable","useEventCallback","isDev","useRovingTabIndex","useMergedRefs","cn","composeEventHandlers","useId","isElementOfType","slotRendersContent","renderSlot","getDirection","forcedColors","ChevronRightIcon","require_runtime","require_cn","require_children","require_dev","require_slot","require_composeEventHandlers","require_useEventCallback","require_useControllable","require_useId","require_direction","require_useRovingTabIndex","require_useMergedRefs","require_styles","require_icons","react","react_jsx_runtime","TreeContext","TreeParentContext","TreeLabelContext","EMPTY","INERT_CONTEXT","useTreeContext","component","ITEM_IN_LABEL_MESSAGE","warnDuplicateValue","value","TreeRoot","rest","initialExpanded","defaultExpandedItems","expandedList","setExpandedList","expandedItems","onExpandedItemsChange","next","expanded","toggle","prev","v","expand","added","values","activate","onItemSelect","focusedItem","setFocusedItem","valueCounts","registerValue","counts","count","remaining","selected","context","current","getTabIndex","focusValue","mergedRef","ref","containerProps","handleKeyDown","event","syncTypeaheadText","handleKeyDownCapture","handleBlur","className","onKeyDown","onKeyDownCapture","onFocus","onBlur","tree","label","treeitem","text","isOwnKeyEvent","isOwnClick","target","TreeItem","props","typeaheadText","ctx","parent","insideLabel","isExpanded","labelId","nestedItems","labelContent","firstChildValue","children","child","keyed","key","iconNode","icon","hasChildren","leaf","isSelected","isCurrent","handleClick","onClick","rtl","forward","back","siblings","el","handleFocus","Tree"],"sources":["../../../src/components/layout/Tree.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { isDev, reportMissingContext, warnOnce } from '../../lib/dev';\nimport { getDirection } from '../../lib/direction';\nimport { ChevronRightIcon } from '../../lib/icons';\nimport { renderSlot, slotRendersContent, type Slot } from '../../lib/slot';\nimport { forcedColors } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\n\n/* ------------------------------------------------------------------ */\n/* Contexts */\n/* ------------------------------------------------------------------ */\n\ninterface TreeContextValue {\n expanded: ReadonlySet<string>;\n toggle: (value: string) => void;\n expand: (values: readonly string[]) => void;\n activate: (value: string) => void;\n selected: string | null | undefined;\n current: string | null | undefined;\n getTabIndex: (value: string) => 0 | -1;\n focusValue: (value: string) => void;\n onItemFocus: (value: string) => void;\n /**\n * Development only: counts a mounted item's value and warns once per value that several items\n * share. Returns the unregistration.\n */\n registerValue: (value: string) => () => void;\n}\n\nconst TreeContext = React.createContext<TreeContextValue | null>(null);\n\n/** Value of the enclosing Tree.Item (`null` at the top level), for ArrowLeft → parent. */\nconst TreeParentContext = React.createContext<string | null>(null);\n\n/**\n * `true` inside the label of a Tree.Item, where a nested Tree.Item ends up when a component\n * renders it (the parent cannot see it among its children); its child group and every Tree root\n * reset it.\n */\nconst TreeLabelContext = React.createContext(false);\n\nconst EMPTY: readonly string[] = [];\n\nconst INERT_CONTEXT: TreeContextValue = {\n expanded: new Set(),\n toggle: () => {},\n expand: () => {},\n activate: () => {},\n selected: undefined,\n current: undefined,\n getTabIndex: () => -1,\n focusValue: () => {},\n onItemFocus: () => {},\n registerValue: () => () => {},\n};\n\n/** C-CONTEXT: throws in development, logs once and returns an inert value in production. */\nfunction useTreeContext(component: string): TreeContextValue {\n const context = React.useContext(TreeContext);\n if (context) return context;\n reportMissingContext(component, '<Tree>');\n return INERT_CONTEXT;\n}\n\nconst ITEM_IN_LABEL_MESSAGE =\n 'Tree.Item was rendered inside the label of another Tree.Item, so it is not part of that ' +\n \"item's child group: the parent cannot expand, its name includes the nested text, and a \" +\n 'treeitem sits inside a label (axe aria-required-parent). A Tree.Item finds its nested items ' +\n 'among its own children (written directly, in Fragments, or returned by a render function such ' +\n 'as `children.map(renderNode)`), but not inside a component that renders Tree.Item itself. ' +\n 'Build a data-driven tree with a render function instead of a recursive component.';\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `Tree:duplicate:${value}`,\n `Tree: several items share the value \"${value}\". Item values must be unique within a Tree; ` +\n 'items with the same value share their expanded, selected and focus state.',\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Tree */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the Tree component. */\nexport interface TreeProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Controlled list of expanded item values. */\n expandedItems?: readonly string[];\n /**\n * Item values that are expanded initially (uncontrolled).\n * @default []\n */\n defaultExpandedItems?: readonly string[];\n /** Called with the new list of expanded item values when an item expands or collapses. */\n onExpandedItemsChange?: (expandedItems: string[]) => void;\n /**\n * Called with an item's value every time it is activated (click, Enter or Space), also when the\n * same item is activated again.\n */\n onItemSelect?: (value: string) => void;\n /**\n * Value of the selected item. When set (also to `null`), every item carries `aria-selected`, and\n * the selected item is where keyboard focus enters the tree.\n */\n selected?: string | null;\n /** Value of the current item (for example the open page): it gets `aria-current=\"true\"`. */\n current?: string | null;\n /** Ref to the `role=\"tree\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst TreeRoot = ({\n expandedItems,\n defaultExpandedItems,\n onExpandedItemsChange,\n onItemSelect,\n selected,\n current,\n className,\n children,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onBlur,\n ref,\n ...rest\n}: TreeProps) => {\n const [initialExpanded] = React.useState<readonly string[]>(() => defaultExpandedItems ?? EMPTY);\n const [expandedList, setExpandedList] = useControllable<readonly string[]>(\n expandedItems,\n initialExpanded,\n (next) => onExpandedItemsChange?.([...next]),\n );\n const expanded = React.useMemo(() => new Set(expandedList), [expandedList]);\n\n const toggle = React.useCallback(\n (value: string) => {\n setExpandedList((prev) =>\n prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value],\n );\n },\n [setExpandedList],\n );\n\n const expand = React.useCallback(\n (values: readonly string[]) => {\n setExpandedList((prev) => {\n const added = values.filter((v) => !prev.includes(v));\n return added.length > 0 ? [...prev, ...added] : prev;\n });\n },\n [setExpandedList],\n );\n\n const activate = useEventCallback((value: string) => {\n onItemSelect?.(value);\n });\n\n // The item that has focus while focus is inside the tree: it holds the tab stop, so Shift+Tab\n // leaves the tree. Cleared when focus leaves; the next entry goes to `selected`, else the first.\n const [focusedItem, setFocusedItem] = React.useState<string | null>(null);\n\n // How many mounted items carry each value (written from the items' effects only).\n const valueCounts = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback((value: string) => {\n if (!isDev) return () => {};\n valueCounts.current ??= new Map();\n const counts = valueCounts.current;\n const count = (counts.get(value) ?? 0) + 1;\n counts.set(value, count);\n if (count > 1) warnDuplicateValue(value);\n return () => {\n const remaining = (counts.get(value) ?? 1) - 1;\n if (remaining > 0) counts.set(value, remaining);\n else counts.delete(value);\n };\n }, []);\n\n const { containerProps, getTabIndex, focusValue } = useRovingTabIndex({\n activeValue: focusedItem ?? selected ?? null,\n orientation: 'vertical',\n loop: false,\n typeahead: true,\n });\n\n const context = React.useMemo<TreeContextValue>(\n () => ({\n expanded,\n toggle,\n expand,\n activate,\n selected,\n current,\n getTabIndex,\n focusValue,\n onItemFocus: setFocusedItem,\n registerValue,\n }),\n [expanded, toggle, expand, activate, selected, current, getTabIndex, focusValue, registerValue],\n );\n\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, containerProps.ref);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // Typeahead reads `data-roving-text` at key time: fill it from each item's label first.\n if (event.key.length === 1) syncTypeaheadText(event.currentTarget);\n containerProps.onKeyDown(event);\n };\n\n // A Space that continues a search is typeahead too, taken before the item would activate on it.\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === ' ') syncTypeaheadText(event.currentTarget);\n containerProps.onKeyDownCapture(event);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n const next = event.relatedTarget as Node | null;\n if (!next || !event.currentTarget.contains(next)) setFocusedItem(null);\n };\n\n return (\n <TreeContext.Provider value={context}>\n <TreeParentContext.Provider value={null}>\n <div\n role=\"tree\"\n className={cn('text-body-1', className)}\n {...rest}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onKeyDownCapture={composeEventHandlers(onKeyDownCapture, handleKeyDownCapture)}\n onFocus={composeEventHandlers(onFocus, containerProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onBlur={composeEventHandlers(onBlur, handleBlur, { checkDefaultPrevented: false })}\n ref={mergedRef}\n >\n {/* A Tree has its own items, also when it renders inside a label (a portaled popup). */}\n <TreeLabelContext.Provider value={false}>{children}</TreeLabelContext.Provider>\n </div>\n </TreeParentContext.Provider>\n </TreeContext.Provider>\n );\n};\nTreeRoot.displayName = 'Tree';\n\n/* ------------------------------------------------------------------ */\n/* Tree.Item */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the TreeItem sub-component. */\nexport interface TreeItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Unique value identifying this tree item. */\n value: string;\n /**\n * Icon displayed before the label. Rendered in a `<span>` hidden from assistive technology\n * (`aria-hidden`); pass a slot object (`{ className, children, … }`) to customise it. A falsy\n * icon (`''`, `0`) or a list of nothing renders no span.\n */\n icon?: Slot<'span'>;\n /**\n * Renders the item as a leaf even when it has nested `Tree.Item`s: they are not rendered, and\n * the item has no `aria-expanded` and does not expand. An item is expandable only while it has\n * nested items, so `leaf={false}` does not make an item without them expandable. To load the\n * children on first expansion, give the item a placeholder child (a \"Loading…\" `Tree.Item`)\n * until they arrive.\n * @default false\n */\n leaf?: boolean;\n /** Ref to the `role=\"treeitem\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Sets the typeahead text (`data-roving-text`, read by the roving hook) of every rendered\n * treeitem to the text of its label, so neither the icon nor the nested items take part. A\n * consumer `data-roving-text` on a Tree.Item is kept on its label and wins.\n */\nfunction syncTypeaheadText(tree: HTMLElement): void {\n tree.querySelectorAll<HTMLElement>('[role=\"treeitem\"]').forEach((treeitem) => {\n const label = treeitem.querySelector<HTMLElement>(\n ':scope > [data-tree-row] > [data-tree-label]',\n );\n if (!label) return;\n const text = label.getAttribute('data-roving-text') ?? label.textContent ?? '';\n if (treeitem.getAttribute('data-roving-text') !== text) {\n treeitem.setAttribute('data-roving-text', text);\n }\n });\n}\n\n/**\n * Whether a keyboard event belongs to this treeitem: its target (the focused element) is this\n * treeitem or inside its row, not a nested item.\n */\nfunction isOwnKeyEvent(event: React.KeyboardEvent<HTMLElement>): boolean {\n const target = event.target as Element | null;\n return target?.closest?.('[role=\"treeitem\"]') === event.currentTarget;\n}\n\n/**\n * Whether a click landed on this treeitem's own row (or on the treeitem element itself). Clicks\n * in its child group, including the indentation gutter beside the nested rows, and clicks on\n * nested items are not its own.\n */\nfunction isOwnClick(event: React.MouseEvent<HTMLElement>): boolean {\n const target = event.target as Element | null;\n if (target === event.currentTarget) return true;\n return target?.closest?.('[data-tree-row]')?.parentElement === event.currentTarget;\n}\n\n/**\n * One node of a Tree. Text and other content are the label; nested `Tree.Item` children form its\n * child group, which is shown while the item is expanded.\n *\n * Nested items must be `Tree.Item` elements among the item's own children: written directly, in\n * Fragments, or returned by a render function (`{node.children.map(renderNode)}`). A component\n * that renders `Tree.Item` itself (a recursive `<NodeView node={child} />`) is not recognised:\n * its output becomes part of the label, so the parent cannot expand (a development warning names\n * this). Render data-driven trees with a render function instead.\n *\n * `ref` and every other prop land on the `role=\"treeitem\"` element, which contains the label row\n * and the child group. Its `onClick` receives only clicks on its own row (not on its child group\n * or nested items) and its `onKeyDown` only keys pressed while focus is on it or in its row; both\n * run before the built-in behaviour (call `event.preventDefault()` to skip it). Its other event\n * handlers (`onFocus`, `onDoubleClick`, `onContextMenu` and the rest) are not filtered: as DOM\n * events bubble, they also receive events from its child group and nested items (compare\n * `event.target` with `event.currentTarget` to tell them apart).\n *\n * The item is named by its label (`aria-labelledby`), not by its icon or nested items; an\n * `aria-label` or `aria-labelledby` prop replaces that name. Typeahead matches the label text too\n * (a `data-roving-text` prop replaces it).\n */\nconst TreeItem = ({\n value,\n icon,\n leaf = false,\n className,\n children,\n onClick,\n onKeyDown,\n onFocus,\n ref,\n ...props\n}: TreeItemProps) => {\n const { 'data-roving-text': typeaheadText, ...rest } = props as typeof props & {\n 'data-roving-text'?: string;\n };\n const ctx = useTreeContext('Tree.Item');\n const parent = React.useContext(TreeParentContext);\n const insideLabel = React.useContext(TreeLabelContext);\n const isExpanded = ctx.expanded.has(value);\n const labelId = useId('tree-item-label');\n\n const { registerValue } = ctx;\n React.useEffect(() => registerValue(value), [registerValue, value]);\n React.useEffect(() => {\n if (insideLabel) warnOnce('Tree.Item:inside-label', ITEM_IN_LABEL_MESSAGE);\n }, [insideLabel]);\n\n // Nested Tree.Items (and, as in 0.4, nested Trees) form the child group; the rest is the label.\n // Parts are identified through their element type, so parts written in a Server Component\n // (lazy references) count too.\n const nestedItems: React.ReactNode[] = [];\n const labelContent: React.ReactNode[] = [];\n let firstChildValue: string | undefined;\n flattenChildren(children).forEach(({ key, node: child }) => {\n const keyed = <React.Fragment key={key}>{child}</React.Fragment>;\n if (isElementOfType<TreeItemProps>(child, TreeItem)) {\n firstChildValue ??= child.props.value;\n nestedItems.push(keyed);\n } else if (isElementOfType(child, TreeRoot)) {\n nestedItems.push(keyed);\n } else {\n labelContent.push(keyed);\n }\n });\n\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4\n // and as in Avatar, and so is a collection whose items render nothing: no empty span adds a gap\n // to the row. The check does not consume a generator: renderSlot still renders its items.\n const iconNode =\n icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', 'inline-flex shrink-0', { 'aria-hidden': true })\n : null;\n const hasChildren = nestedItems.length > 0 && !leaf;\n const isSelected = ctx.selected !== undefined ? ctx.selected === value : undefined;\n const isCurrent = ctx.current !== undefined && ctx.current !== null && ctx.current === value;\n\n const activate = () => {\n if (hasChildren) ctx.toggle(value);\n ctx.activate(value);\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (!isOwnClick(event)) return;\n onClick?.(event);\n if (!event.defaultPrevented) activate();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!isOwnKeyEvent(event)) return;\n onKeyDown?.(event);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n\n const rtl = getDirection(event.currentTarget) === 'rtl';\n const forward = rtl ? 'ArrowLeft' : 'ArrowRight';\n const back = rtl ? 'ArrowRight' : 'ArrowLeft';\n\n switch (event.key) {\n case 'Enter':\n case ' ':\n event.preventDefault();\n activate();\n return;\n case forward:\n event.preventDefault();\n if (!hasChildren) return;\n if (!isExpanded) ctx.toggle(value);\n else if (firstChildValue !== undefined) ctx.focusValue(firstChildValue);\n return;\n case back:\n event.preventDefault();\n if (hasChildren && isExpanded) ctx.toggle(value);\n else if (parent !== null) ctx.focusValue(parent);\n return;\n case '*': {\n event.preventDefault();\n const siblings = event.currentTarget.parentElement?.querySelectorAll<HTMLElement>(\n ':scope > [role=\"treeitem\"][aria-expanded=\"false\"][data-roving-value]',\n );\n ctx.expand(\n Array.from(siblings ?? [], (el) => el.getAttribute('data-roving-value') ?? '').filter(\n Boolean,\n ),\n );\n return;\n }\n default:\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget) ctx.onItemFocus(value);\n };\n\n return (\n <div\n role=\"treeitem\"\n aria-selected={isSelected}\n aria-current={isCurrent ? true : undefined}\n className={cn(\n // The focus ring is drawn on the row: an outline on the treeitem would surround its\n // whole subtree.\n 'block outline-none',\n '[&:focus-visible>[data-tree-row]]:outline-2 [&:focus-visible>[data-tree-row]]:-outline-offset-2 [&:focus-visible>[data-tree-row]]:outline-ring',\n className,\n )}\n {...rest}\n // Named by its label only: the treeitem also contains its icon and its child group. A\n // consumer aria-labelledby or aria-label replaces it.\n aria-labelledby={\n rest['aria-labelledby'] ?? (rest['aria-label'] === undefined ? labelId : undefined)\n }\n aria-expanded={hasChildren ? isExpanded : undefined}\n tabIndex={ctx.getTabIndex(value)}\n data-roving-value={value}\n data-selected={isSelected ? '' : undefined}\n data-current={isCurrent ? '' : undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onFocus={composeEventHandlers(onFocus, handleFocus, { checkDefaultPrevented: false })}\n ref={ref}\n >\n <div\n data-tree-row=\"\"\n className={cn(\n 'flex cursor-pointer items-center gap-1.5 rounded px-2 py-1 hover:bg-subtle-hover',\n isSelected && cn('bg-subtle-selected font-semibold', forcedColors.selectedContainer),\n )}\n >\n {hasChildren ? (\n <ChevronRightIcon\n className={cn(\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isExpanded ? 'rotate-90' : 'wave-rtl:-scale-x-100',\n )}\n />\n ) : (\n <span className=\"w-3 shrink-0\" aria-hidden=\"true\" />\n )}\n {iconNode}\n <span id={labelId} data-tree-label=\"\" data-roving-text={typeaheadText} className=\"truncate\">\n <TreeLabelContext.Provider value>{labelContent}</TreeLabelContext.Provider>\n </span>\n </div>\n {hasChildren && isExpanded && (\n <TreeParentContext.Provider value={value}>\n <TreeLabelContext.Provider value={false}>\n <div role=\"group\" className=\"ps-4\">\n {nestedItems}\n </div>\n </TreeLabelContext.Provider>\n </TreeParentContext.Provider>\n )}\n </div>\n );\n};\nTreeItem.displayName = 'TreeItem';\n\n/* ------------------------------------------------------------------ */\n/* Export */\n/* ------------------------------------------------------------------ */\n\n/**\n * A hierarchical list (WAI-ARIA Tree View pattern) with a single tab stop: Up/Down move between\n * visible items, Home/End to the first/last, Right expands or moves to the first child, Left\n * collapses or moves to the parent (both mirrored in RTL), Enter/Space activate (and toggle a\n * parent), `*` expands the siblings, and typing jumps to an item by its text.\n *\n * Keyboard focus enters at the `selected` item, else the first item; while focus is inside, the\n * tab stop follows it, so Shift+Tab leaves the tree.\n *\n * Items are `Tree.Item` elements; nested items are written in their parent's children (directly,\n * in Fragments, or returned by a render function), not rendered by a component of their own.\n * Every item needs a `value` that is unique within the Tree.\n *\n * `Tree.Item` is also exported as `TreeItem` for React Server Components, which cannot use the\n * dotted form.\n */\nexport const Tree = /* @__PURE__ */ Object.assign(TreeRoot, {\n Item: TreeItem,\n});\n\nexport { TreeItem };\n"],"mappings":"ioBAoCA,IAAM+B,EAAc/B,EAAM,cAAuC,IAAI,EAG/DgC,EAAoBhC,EAAM,cAA6B,IAAI,EAO3DiC,EAAmBjC,EAAM,cAAc,EAAK,EAE5CkC,EAA2B,CAAC,EAE5BC,EAAkC,CACtC,SAAU,IAAI,IACd,WAAc,CAAC,EACf,WAAc,CAAC,EACf,aAAgB,CAAC,EACjB,SAAU,IAAA,GACV,QAAS,IAAA,GACT,gBAAmB,GACnB,eAAkB,CAAC,EACnB,gBAAmB,CAAC,EACpB,sBAA2B,CAAC,CAC9B,EAGA,SAASC,EAAe,EAAqC,CAI3D,OAHgBpC,EAAM,WAAW+B,CAC7B,IACJb,EAAA,qBAAqBmB,EAAW,QAAQ,EACjCF,EACT,CAEA,IAAMG,EACJ,uhBAOF,SAASC,EAAmB,EAAqB,CAC/CrB,EAAA,SACE,kBAAkBs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gBAAc,GACd,UAAWxB,EAAAA,GACT,mFACAwG,GAAcxG,EAAAA,GAAG,mCAAoCO,EAAAA,aAAa,iBAAiB,CACrF,EALF,SAAA,CAOG+F,GACC,EAAA9E,EAAA,IAAA,CAAChB,EAAAA,iBAAD,CACE,UAAWR,EAAAA,GACT,8DACA2F,EAAa,YAAc,uBAC7B,CACD,CAAA,GAED,EAAAnE,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,eAAe,cAAY,MAAQ,CAAA,EAEpD4E,GACD,EAAA5E,EAAA,IAAA,CAAC,OAAD,CAAM,GAAIoE,EAAS,kBAAgB,GAAG,mBAAkBL,EAAe,UAAU,WAC/E,UAAA,EAAA/D,EAAA,IAAA,CAACG,EAAiB,SAAlB,CAA2B,MAAA,GAAO,SAAAmE,CAAwC,CAAA,CACtE,CAAA,CACH,CACJ,CAAA,EAAAQ,GAAeX,IACd,EAAAnE,EAAA,IAAA,CAACE,EAAkB,SAAnB,CAAmC,QACjC,UAAA,EAAAF,EAAA,IAAA,CAACG,EAAiB,SAAlB,CAA2B,MAAO,GAChC,UAAA,EAAAH,EAAA,IAAA,CAAC,MAAD,CAAK,KAAK,QAAQ,UAAU,OACzB,SAAAqE,CACE,CAAA,CACoB,CAAA,CACD,CAAA,CAE3B,GAET,EACA,EAAS,YAAc,WAsBvB,IAAaqB,EAAuB,OAAO,OAAO/E,EAAU,CAC1D,KAAMkD,CACR,CAAC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
|
|
4
|
+
import { isDev as r, reportMissingContext as i, warnOnce as a } from "../../lib/dev.mjs";
|
|
5
|
+
import { renderSlot as o, slotRendersContent as s } from "../../lib/slot.mjs";
|
|
6
|
+
import { composeEventHandlers as c } from "../../lib/composeEventHandlers.mjs";
|
|
7
|
+
import { useEventCallback as l } from "../../hooks/useEventCallback.mjs";
|
|
8
|
+
import { useControllable as u } from "../../hooks/useControllable.mjs";
|
|
9
|
+
import { useId as d } from "../../hooks/useId.mjs";
|
|
10
|
+
import { getDirection as f } from "../../lib/direction.mjs";
|
|
11
|
+
import { useRovingTabIndex as p } from "../../hooks/useRovingTabIndex.mjs";
|
|
12
|
+
import { useMergedRefs as m } from "../../hooks/useMergedRefs.mjs";
|
|
13
|
+
import { forcedColors as h } from "../../lib/styles.mjs";
|
|
14
|
+
import { ChevronRightIcon as g } from "../../lib/icons.mjs";
|
|
15
|
+
import * as _ from "react";
|
|
16
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
17
|
+
//#region src/components/layout/Tree.tsx
|
|
18
|
+
var b = _.createContext(null), x = _.createContext(null), S = _.createContext(!1), C = [], w = {
|
|
19
|
+
expanded: /* @__PURE__ */ new Set(),
|
|
20
|
+
toggle: () => {},
|
|
21
|
+
expand: () => {},
|
|
22
|
+
activate: () => {},
|
|
23
|
+
selected: void 0,
|
|
24
|
+
current: void 0,
|
|
25
|
+
getTabIndex: () => -1,
|
|
26
|
+
focusValue: () => {},
|
|
27
|
+
onItemFocus: () => {},
|
|
28
|
+
registerValue: () => () => {}
|
|
29
|
+
};
|
|
30
|
+
function T(e) {
|
|
31
|
+
return _.useContext(b) || (i(e, "<Tree>"), w);
|
|
32
|
+
}
|
|
33
|
+
var E = "Tree.Item was rendered inside the label of another Tree.Item, so it is not part of that item's child group: the parent cannot expand, its name includes the nested text, and a treeitem sits inside a label (axe aria-required-parent). A Tree.Item finds its nested items among its own children (written directly, in Fragments, or returned by a render function such as `children.map(renderNode)`), but not inside a component that renders Tree.Item itself. Build a data-driven tree with a render function instead of a recursive component.";
|
|
34
|
+
function D(e) {
|
|
35
|
+
a(`Tree:duplicate:${e}`, `Tree: several items share the value "${e}". Item values must be unique within a Tree; items with the same value share their expanded, selected and focus state.`);
|
|
36
|
+
}
|
|
37
|
+
var O = ({ expandedItems: t, defaultExpandedItems: n, onExpandedItemsChange: i, onItemSelect: a, selected: o, current: s, className: d, children: f, onKeyDown: h, onKeyDownCapture: g, onFocus: y, onBlur: w, ref: T, ...E }) => {
|
|
38
|
+
let [O] = _.useState(() => n ?? C), [A, j] = u(t, O, (e) => i?.([...e])), M = _.useMemo(() => new Set(A), [A]), N = _.useCallback((e) => {
|
|
39
|
+
j((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
40
|
+
}, [j]), P = _.useCallback((e) => {
|
|
41
|
+
j((t) => {
|
|
42
|
+
let n = e.filter((e) => !t.includes(e));
|
|
43
|
+
return n.length > 0 ? [...t, ...n] : t;
|
|
44
|
+
});
|
|
45
|
+
}, [j]), F = l((e) => {
|
|
46
|
+
a?.(e);
|
|
47
|
+
}), [I, L] = _.useState(null), R = _.useRef(null), z = _.useCallback((e) => {
|
|
48
|
+
if (!r) return () => {};
|
|
49
|
+
R.current ??= /* @__PURE__ */ new Map();
|
|
50
|
+
let t = R.current, n = (t.get(e) ?? 0) + 1;
|
|
51
|
+
return t.set(e, n), n > 1 && D(e), () => {
|
|
52
|
+
let n = (t.get(e) ?? 1) - 1;
|
|
53
|
+
n > 0 ? t.set(e, n) : t.delete(e);
|
|
54
|
+
};
|
|
55
|
+
}, []), { containerProps: B, getTabIndex: V, focusValue: H } = p({
|
|
56
|
+
activeValue: I ?? o ?? null,
|
|
57
|
+
orientation: "vertical",
|
|
58
|
+
loop: !1,
|
|
59
|
+
typeahead: !0
|
|
60
|
+
}), U = _.useMemo(() => ({
|
|
61
|
+
expanded: M,
|
|
62
|
+
toggle: N,
|
|
63
|
+
expand: P,
|
|
64
|
+
activate: F,
|
|
65
|
+
selected: o,
|
|
66
|
+
current: s,
|
|
67
|
+
getTabIndex: V,
|
|
68
|
+
focusValue: H,
|
|
69
|
+
onItemFocus: L,
|
|
70
|
+
registerValue: z
|
|
71
|
+
}), [
|
|
72
|
+
M,
|
|
73
|
+
N,
|
|
74
|
+
P,
|
|
75
|
+
F,
|
|
76
|
+
o,
|
|
77
|
+
s,
|
|
78
|
+
V,
|
|
79
|
+
H,
|
|
80
|
+
z
|
|
81
|
+
]), W = m(T, B.ref), G = (e) => {
|
|
82
|
+
e.key.length === 1 && k(e.currentTarget), B.onKeyDown(e);
|
|
83
|
+
}, K = (e) => {
|
|
84
|
+
e.key === " " && k(e.currentTarget), B.onKeyDownCapture(e);
|
|
85
|
+
}, q = (e) => {
|
|
86
|
+
let t = e.relatedTarget;
|
|
87
|
+
(!t || !e.currentTarget.contains(t)) && L(null);
|
|
88
|
+
};
|
|
89
|
+
return /* @__PURE__ */ v(b.Provider, {
|
|
90
|
+
value: U,
|
|
91
|
+
children: /* @__PURE__ */ v(x.Provider, {
|
|
92
|
+
value: null,
|
|
93
|
+
children: /* @__PURE__ */ v("div", {
|
|
94
|
+
role: "tree",
|
|
95
|
+
className: e("text-body-1", d),
|
|
96
|
+
...E,
|
|
97
|
+
"data-roving-container": "",
|
|
98
|
+
onKeyDown: c(h, G),
|
|
99
|
+
onKeyDownCapture: c(g, K),
|
|
100
|
+
onFocus: c(y, B.onFocus, { checkDefaultPrevented: !1 }),
|
|
101
|
+
onBlur: c(w, q, { checkDefaultPrevented: !1 }),
|
|
102
|
+
ref: W,
|
|
103
|
+
children: /* @__PURE__ */ v(S.Provider, {
|
|
104
|
+
value: !1,
|
|
105
|
+
children: f
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
O.displayName = "Tree";
|
|
112
|
+
function k(e) {
|
|
113
|
+
e.querySelectorAll("[role=\"treeitem\"]").forEach((e) => {
|
|
114
|
+
let t = e.querySelector(":scope > [data-tree-row] > [data-tree-label]");
|
|
115
|
+
if (!t) return;
|
|
116
|
+
let n = t.getAttribute("data-roving-text") ?? t.textContent ?? "";
|
|
117
|
+
e.getAttribute("data-roving-text") !== n && e.setAttribute("data-roving-text", n);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function A(e) {
|
|
121
|
+
return e.target?.closest?.("[role=\"treeitem\"]") === e.currentTarget;
|
|
122
|
+
}
|
|
123
|
+
function j(e) {
|
|
124
|
+
let t = e.target;
|
|
125
|
+
return t === e.currentTarget || t?.closest?.("[data-tree-row]")?.parentElement === e.currentTarget;
|
|
126
|
+
}
|
|
127
|
+
var M = ({ value: r, icon: i, leaf: l = !1, className: u, children: p, onClick: m, onKeyDown: b, onFocus: C, ref: w, ...D }) => {
|
|
128
|
+
let { "data-roving-text": k, ...N } = D, P = T("Tree.Item"), F = _.useContext(x), I = _.useContext(S), L = P.expanded.has(r), R = d("tree-item-label"), { registerValue: z } = P;
|
|
129
|
+
_.useEffect(() => z(r), [z, r]), _.useEffect(() => {
|
|
130
|
+
I && a("Tree.Item:inside-label", E);
|
|
131
|
+
}, [I]);
|
|
132
|
+
let B = [], V = [], H;
|
|
133
|
+
t(p).forEach(({ key: e, node: t }) => {
|
|
134
|
+
let r = /* @__PURE__ */ v(_.Fragment, { children: t }, e);
|
|
135
|
+
n(t, M) ? (H ??= t.props.value, B.push(r)) : n(t, O) ? B.push(r) : V.push(r);
|
|
136
|
+
});
|
|
137
|
+
let U = i && s(i) ? o(i, "span", "inline-flex shrink-0", { "aria-hidden": !0 }) : null, W = B.length > 0 && !l, G = P.selected === void 0 ? void 0 : P.selected === r, K = P.current !== void 0 && P.current !== null && P.current === r, q = () => {
|
|
138
|
+
W && P.toggle(r), P.activate(r);
|
|
139
|
+
}, J = (e) => {
|
|
140
|
+
j(e) && (m?.(e), e.defaultPrevented || q());
|
|
141
|
+
}, Y = (e) => {
|
|
142
|
+
if (!A(e) || (b?.(e), e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
143
|
+
let t = f(e.currentTarget) === "rtl", n = t ? "ArrowLeft" : "ArrowRight", i = t ? "ArrowRight" : "ArrowLeft";
|
|
144
|
+
switch (e.key) {
|
|
145
|
+
case "Enter":
|
|
146
|
+
case " ":
|
|
147
|
+
e.preventDefault(), q();
|
|
148
|
+
return;
|
|
149
|
+
case n:
|
|
150
|
+
if (e.preventDefault(), !W) return;
|
|
151
|
+
L ? H !== void 0 && P.focusValue(H) : P.toggle(r);
|
|
152
|
+
return;
|
|
153
|
+
case i:
|
|
154
|
+
e.preventDefault(), W && L ? P.toggle(r) : F !== null && P.focusValue(F);
|
|
155
|
+
return;
|
|
156
|
+
case "*": {
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
let t = e.currentTarget.parentElement?.querySelectorAll(":scope > [role=\"treeitem\"][aria-expanded=\"false\"][data-roving-value]");
|
|
159
|
+
P.expand(Array.from(t ?? [], (e) => e.getAttribute("data-roving-value") ?? "").filter(Boolean));
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, X = (e) => {
|
|
164
|
+
e.target === e.currentTarget && P.onItemFocus(r);
|
|
165
|
+
};
|
|
166
|
+
return /* @__PURE__ */ y("div", {
|
|
167
|
+
role: "treeitem",
|
|
168
|
+
"aria-selected": G,
|
|
169
|
+
"aria-current": K ? !0 : void 0,
|
|
170
|
+
className: e("block outline-none", "[&:focus-visible>[data-tree-row]]:outline-2 [&:focus-visible>[data-tree-row]]:-outline-offset-2 [&:focus-visible>[data-tree-row]]:outline-ring", u),
|
|
171
|
+
...N,
|
|
172
|
+
"aria-labelledby": N["aria-labelledby"] ?? (N["aria-label"] === void 0 ? R : void 0),
|
|
173
|
+
"aria-expanded": W ? L : void 0,
|
|
174
|
+
tabIndex: P.getTabIndex(r),
|
|
175
|
+
"data-roving-value": r,
|
|
176
|
+
"data-selected": G ? "" : void 0,
|
|
177
|
+
"data-current": K ? "" : void 0,
|
|
178
|
+
onClick: J,
|
|
179
|
+
onKeyDown: Y,
|
|
180
|
+
onFocus: c(C, X, { checkDefaultPrevented: !1 }),
|
|
181
|
+
ref: w,
|
|
182
|
+
children: [/* @__PURE__ */ y("div", {
|
|
183
|
+
"data-tree-row": "",
|
|
184
|
+
className: e("flex cursor-pointer items-center gap-1.5 rounded px-2 py-1 hover:bg-subtle-hover", G && e("bg-subtle-selected font-semibold", h.selectedContainer)),
|
|
185
|
+
children: [
|
|
186
|
+
W ? /* @__PURE__ */ v(g, { className: e("shrink-0 transition-transform motion-reduce:transition-none", L ? "rotate-90" : "wave-rtl:-scale-x-100") }) : /* @__PURE__ */ v("span", {
|
|
187
|
+
className: "w-3 shrink-0",
|
|
188
|
+
"aria-hidden": "true"
|
|
189
|
+
}),
|
|
190
|
+
U,
|
|
191
|
+
/* @__PURE__ */ v("span", {
|
|
192
|
+
id: R,
|
|
193
|
+
"data-tree-label": "",
|
|
194
|
+
"data-roving-text": k,
|
|
195
|
+
className: "truncate",
|
|
196
|
+
children: /* @__PURE__ */ v(S.Provider, {
|
|
197
|
+
value: !0,
|
|
198
|
+
children: V
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
}), W && L && /* @__PURE__ */ v(x.Provider, {
|
|
203
|
+
value: r,
|
|
204
|
+
children: /* @__PURE__ */ v(S.Provider, {
|
|
205
|
+
value: !1,
|
|
206
|
+
children: /* @__PURE__ */ v("div", {
|
|
207
|
+
role: "group",
|
|
208
|
+
className: "ps-4",
|
|
209
|
+
children: B
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
})]
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
M.displayName = "TreeItem";
|
|
216
|
+
var N = /* @__PURE__ */ Object.assign(O, { Item: M });
|
|
217
|
+
//#endregion
|
|
218
|
+
export { N as Tree, M as TreeItem };
|
|
219
|
+
|
|
220
|
+
//# sourceMappingURL=Tree.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tree.mjs","names":["useId","useId$1","React","TreeContext","TreeParentContext","TreeLabelContext","EMPTY","INERT_CONTEXT","useTreeContext","reportMissingContext","component","ITEM_IN_LABEL_MESSAGE","warnDuplicateValue","value","TreeRoot","rest","initialExpanded","defaultExpandedItems","expandedList","setExpandedList","useControllable","expandedItems","onExpandedItemsChange","next","expanded","toggle","prev","v","expand","added","values","activate","useEventCallback","focusedItem","setFocusedItem","valueCounts","registerValue","isDev","counts","count","remaining","useRovingTabIndex","selected","context","current","getTabIndex","focusValue","mergedRef","useMergedRefs","ref","containerProps","handleKeyDown","event","syncTypeaheadText","handleKeyDownCapture","handleBlur","cn","className","composeEventHandlers","onKeyDown","onKeyDownCapture","onFocus","onBlur","label","treeitem","text","isOwnKeyEvent","isOwnClick","target","TreeItem","props","typeaheadText","ctx","parent","insideLabel","isExpanded","labelId","warnOnce","nestedItems","labelContent","firstChildValue","children","child","keyed","key","isElementOfType","iconNode","icon","slotRendersContent","renderSlot","hasChildren","leaf","isSelected","isCurrent","handleClick","onClick","rtl","getDirection","forward","back","siblings","el","handleFocus","forcedColors","ChevronRightIcon","Tree"],"sources":["../../../src/components/layout/Tree.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { isDev, reportMissingContext, warnOnce } from '../../lib/dev';\nimport { getDirection } from '../../lib/direction';\nimport { ChevronRightIcon } from '../../lib/icons';\nimport { renderSlot, slotRendersContent, type Slot } from '../../lib/slot';\nimport { forcedColors } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\n\n/* ------------------------------------------------------------------ */\n/* Contexts */\n/* ------------------------------------------------------------------ */\n\ninterface TreeContextValue {\n expanded: ReadonlySet<string>;\n toggle: (value: string) => void;\n expand: (values: readonly string[]) => void;\n activate: (value: string) => void;\n selected: string | null | undefined;\n current: string | null | undefined;\n getTabIndex: (value: string) => 0 | -1;\n focusValue: (value: string) => void;\n onItemFocus: (value: string) => void;\n /**\n * Development only: counts a mounted item's value and warns once per value that several items\n * share. Returns the unregistration.\n */\n registerValue: (value: string) => () => void;\n}\n\nconst TreeContext = React.createContext<TreeContextValue | null>(null);\n\n/** Value of the enclosing Tree.Item (`null` at the top level), for ArrowLeft → parent. */\nconst TreeParentContext = React.createContext<string | null>(null);\n\n/**\n * `true` inside the label of a Tree.Item, where a nested Tree.Item ends up when a component\n * renders it (the parent cannot see it among its children); its child group and every Tree root\n * reset it.\n */\nconst TreeLabelContext = React.createContext(false);\n\nconst EMPTY: readonly string[] = [];\n\nconst INERT_CONTEXT: TreeContextValue = {\n expanded: new Set(),\n toggle: () => {},\n expand: () => {},\n activate: () => {},\n selected: undefined,\n current: undefined,\n getTabIndex: () => -1,\n focusValue: () => {},\n onItemFocus: () => {},\n registerValue: () => () => {},\n};\n\n/** C-CONTEXT: throws in development, logs once and returns an inert value in production. */\nfunction useTreeContext(component: string): TreeContextValue {\n const context = React.useContext(TreeContext);\n if (context) return context;\n reportMissingContext(component, '<Tree>');\n return INERT_CONTEXT;\n}\n\nconst ITEM_IN_LABEL_MESSAGE =\n 'Tree.Item was rendered inside the label of another Tree.Item, so it is not part of that ' +\n \"item's child group: the parent cannot expand, its name includes the nested text, and a \" +\n 'treeitem sits inside a label (axe aria-required-parent). A Tree.Item finds its nested items ' +\n 'among its own children (written directly, in Fragments, or returned by a render function such ' +\n 'as `children.map(renderNode)`), but not inside a component that renders Tree.Item itself. ' +\n 'Build a data-driven tree with a render function instead of a recursive component.';\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `Tree:duplicate:${value}`,\n `Tree: several items share the value \"${value}\". Item values must be unique within a Tree; ` +\n 'items with the same value share their expanded, selected and focus state.',\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Tree */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the Tree component. */\nexport interface TreeProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Controlled list of expanded item values. */\n expandedItems?: readonly string[];\n /**\n * Item values that are expanded initially (uncontrolled).\n * @default []\n */\n defaultExpandedItems?: readonly string[];\n /** Called with the new list of expanded item values when an item expands or collapses. */\n onExpandedItemsChange?: (expandedItems: string[]) => void;\n /**\n * Called with an item's value every time it is activated (click, Enter or Space), also when the\n * same item is activated again.\n */\n onItemSelect?: (value: string) => void;\n /**\n * Value of the selected item. When set (also to `null`), every item carries `aria-selected`, and\n * the selected item is where keyboard focus enters the tree.\n */\n selected?: string | null;\n /** Value of the current item (for example the open page): it gets `aria-current=\"true\"`. */\n current?: string | null;\n /** Ref to the `role=\"tree\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst TreeRoot = ({\n expandedItems,\n defaultExpandedItems,\n onExpandedItemsChange,\n onItemSelect,\n selected,\n current,\n className,\n children,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onBlur,\n ref,\n ...rest\n}: TreeProps) => {\n const [initialExpanded] = React.useState<readonly string[]>(() => defaultExpandedItems ?? EMPTY);\n const [expandedList, setExpandedList] = useControllable<readonly string[]>(\n expandedItems,\n initialExpanded,\n (next) => onExpandedItemsChange?.([...next]),\n );\n const expanded = React.useMemo(() => new Set(expandedList), [expandedList]);\n\n const toggle = React.useCallback(\n (value: string) => {\n setExpandedList((prev) =>\n prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value],\n );\n },\n [setExpandedList],\n );\n\n const expand = React.useCallback(\n (values: readonly string[]) => {\n setExpandedList((prev) => {\n const added = values.filter((v) => !prev.includes(v));\n return added.length > 0 ? [...prev, ...added] : prev;\n });\n },\n [setExpandedList],\n );\n\n const activate = useEventCallback((value: string) => {\n onItemSelect?.(value);\n });\n\n // The item that has focus while focus is inside the tree: it holds the tab stop, so Shift+Tab\n // leaves the tree. Cleared when focus leaves; the next entry goes to `selected`, else the first.\n const [focusedItem, setFocusedItem] = React.useState<string | null>(null);\n\n // How many mounted items carry each value (written from the items' effects only).\n const valueCounts = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback((value: string) => {\n if (!isDev) return () => {};\n valueCounts.current ??= new Map();\n const counts = valueCounts.current;\n const count = (counts.get(value) ?? 0) + 1;\n counts.set(value, count);\n if (count > 1) warnDuplicateValue(value);\n return () => {\n const remaining = (counts.get(value) ?? 1) - 1;\n if (remaining > 0) counts.set(value, remaining);\n else counts.delete(value);\n };\n }, []);\n\n const { containerProps, getTabIndex, focusValue } = useRovingTabIndex({\n activeValue: focusedItem ?? selected ?? null,\n orientation: 'vertical',\n loop: false,\n typeahead: true,\n });\n\n const context = React.useMemo<TreeContextValue>(\n () => ({\n expanded,\n toggle,\n expand,\n activate,\n selected,\n current,\n getTabIndex,\n focusValue,\n onItemFocus: setFocusedItem,\n registerValue,\n }),\n [expanded, toggle, expand, activate, selected, current, getTabIndex, focusValue, registerValue],\n );\n\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, containerProps.ref);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // Typeahead reads `data-roving-text` at key time: fill it from each item's label first.\n if (event.key.length === 1) syncTypeaheadText(event.currentTarget);\n containerProps.onKeyDown(event);\n };\n\n // A Space that continues a search is typeahead too, taken before the item would activate on it.\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === ' ') syncTypeaheadText(event.currentTarget);\n containerProps.onKeyDownCapture(event);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n const next = event.relatedTarget as Node | null;\n if (!next || !event.currentTarget.contains(next)) setFocusedItem(null);\n };\n\n return (\n <TreeContext.Provider value={context}>\n <TreeParentContext.Provider value={null}>\n <div\n role=\"tree\"\n className={cn('text-body-1', className)}\n {...rest}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onKeyDownCapture={composeEventHandlers(onKeyDownCapture, handleKeyDownCapture)}\n onFocus={composeEventHandlers(onFocus, containerProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onBlur={composeEventHandlers(onBlur, handleBlur, { checkDefaultPrevented: false })}\n ref={mergedRef}\n >\n {/* A Tree has its own items, also when it renders inside a label (a portaled popup). */}\n <TreeLabelContext.Provider value={false}>{children}</TreeLabelContext.Provider>\n </div>\n </TreeParentContext.Provider>\n </TreeContext.Provider>\n );\n};\nTreeRoot.displayName = 'Tree';\n\n/* ------------------------------------------------------------------ */\n/* Tree.Item */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the TreeItem sub-component. */\nexport interface TreeItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Unique value identifying this tree item. */\n value: string;\n /**\n * Icon displayed before the label. Rendered in a `<span>` hidden from assistive technology\n * (`aria-hidden`); pass a slot object (`{ className, children, … }`) to customise it. A falsy\n * icon (`''`, `0`) or a list of nothing renders no span.\n */\n icon?: Slot<'span'>;\n /**\n * Renders the item as a leaf even when it has nested `Tree.Item`s: they are not rendered, and\n * the item has no `aria-expanded` and does not expand. An item is expandable only while it has\n * nested items, so `leaf={false}` does not make an item without them expandable. To load the\n * children on first expansion, give the item a placeholder child (a \"Loading…\" `Tree.Item`)\n * until they arrive.\n * @default false\n */\n leaf?: boolean;\n /** Ref to the `role=\"treeitem\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Sets the typeahead text (`data-roving-text`, read by the roving hook) of every rendered\n * treeitem to the text of its label, so neither the icon nor the nested items take part. A\n * consumer `data-roving-text` on a Tree.Item is kept on its label and wins.\n */\nfunction syncTypeaheadText(tree: HTMLElement): void {\n tree.querySelectorAll<HTMLElement>('[role=\"treeitem\"]').forEach((treeitem) => {\n const label = treeitem.querySelector<HTMLElement>(\n ':scope > [data-tree-row] > [data-tree-label]',\n );\n if (!label) return;\n const text = label.getAttribute('data-roving-text') ?? label.textContent ?? '';\n if (treeitem.getAttribute('data-roving-text') !== text) {\n treeitem.setAttribute('data-roving-text', text);\n }\n });\n}\n\n/**\n * Whether a keyboard event belongs to this treeitem: its target (the focused element) is this\n * treeitem or inside its row, not a nested item.\n */\nfunction isOwnKeyEvent(event: React.KeyboardEvent<HTMLElement>): boolean {\n const target = event.target as Element | null;\n return target?.closest?.('[role=\"treeitem\"]') === event.currentTarget;\n}\n\n/**\n * Whether a click landed on this treeitem's own row (or on the treeitem element itself). Clicks\n * in its child group, including the indentation gutter beside the nested rows, and clicks on\n * nested items are not its own.\n */\nfunction isOwnClick(event: React.MouseEvent<HTMLElement>): boolean {\n const target = event.target as Element | null;\n if (target === event.currentTarget) return true;\n return target?.closest?.('[data-tree-row]')?.parentElement === event.currentTarget;\n}\n\n/**\n * One node of a Tree. Text and other content are the label; nested `Tree.Item` children form its\n * child group, which is shown while the item is expanded.\n *\n * Nested items must be `Tree.Item` elements among the item's own children: written directly, in\n * Fragments, or returned by a render function (`{node.children.map(renderNode)}`). A component\n * that renders `Tree.Item` itself (a recursive `<NodeView node={child} />`) is not recognised:\n * its output becomes part of the label, so the parent cannot expand (a development warning names\n * this). Render data-driven trees with a render function instead.\n *\n * `ref` and every other prop land on the `role=\"treeitem\"` element, which contains the label row\n * and the child group. Its `onClick` receives only clicks on its own row (not on its child group\n * or nested items) and its `onKeyDown` only keys pressed while focus is on it or in its row; both\n * run before the built-in behaviour (call `event.preventDefault()` to skip it). Its other event\n * handlers (`onFocus`, `onDoubleClick`, `onContextMenu` and the rest) are not filtered: as DOM\n * events bubble, they also receive events from its child group and nested items (compare\n * `event.target` with `event.currentTarget` to tell them apart).\n *\n * The item is named by its label (`aria-labelledby`), not by its icon or nested items; an\n * `aria-label` or `aria-labelledby` prop replaces that name. Typeahead matches the label text too\n * (a `data-roving-text` prop replaces it).\n */\nconst TreeItem = ({\n value,\n icon,\n leaf = false,\n className,\n children,\n onClick,\n onKeyDown,\n onFocus,\n ref,\n ...props\n}: TreeItemProps) => {\n const { 'data-roving-text': typeaheadText, ...rest } = props as typeof props & {\n 'data-roving-text'?: string;\n };\n const ctx = useTreeContext('Tree.Item');\n const parent = React.useContext(TreeParentContext);\n const insideLabel = React.useContext(TreeLabelContext);\n const isExpanded = ctx.expanded.has(value);\n const labelId = useId('tree-item-label');\n\n const { registerValue } = ctx;\n React.useEffect(() => registerValue(value), [registerValue, value]);\n React.useEffect(() => {\n if (insideLabel) warnOnce('Tree.Item:inside-label', ITEM_IN_LABEL_MESSAGE);\n }, [insideLabel]);\n\n // Nested Tree.Items (and, as in 0.4, nested Trees) form the child group; the rest is the label.\n // Parts are identified through their element type, so parts written in a Server Component\n // (lazy references) count too.\n const nestedItems: React.ReactNode[] = [];\n const labelContent: React.ReactNode[] = [];\n let firstChildValue: string | undefined;\n flattenChildren(children).forEach(({ key, node: child }) => {\n const keyed = <React.Fragment key={key}>{child}</React.Fragment>;\n if (isElementOfType<TreeItemProps>(child, TreeItem)) {\n firstChildValue ??= child.props.value;\n nestedItems.push(keyed);\n } else if (isElementOfType(child, TreeRoot)) {\n nestedItems.push(keyed);\n } else {\n labelContent.push(keyed);\n }\n });\n\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4\n // and as in Avatar, and so is a collection whose items render nothing: no empty span adds a gap\n // to the row. The check does not consume a generator: renderSlot still renders its items.\n const iconNode =\n icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', 'inline-flex shrink-0', { 'aria-hidden': true })\n : null;\n const hasChildren = nestedItems.length > 0 && !leaf;\n const isSelected = ctx.selected !== undefined ? ctx.selected === value : undefined;\n const isCurrent = ctx.current !== undefined && ctx.current !== null && ctx.current === value;\n\n const activate = () => {\n if (hasChildren) ctx.toggle(value);\n ctx.activate(value);\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (!isOwnClick(event)) return;\n onClick?.(event);\n if (!event.defaultPrevented) activate();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!isOwnKeyEvent(event)) return;\n onKeyDown?.(event);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n\n const rtl = getDirection(event.currentTarget) === 'rtl';\n const forward = rtl ? 'ArrowLeft' : 'ArrowRight';\n const back = rtl ? 'ArrowRight' : 'ArrowLeft';\n\n switch (event.key) {\n case 'Enter':\n case ' ':\n event.preventDefault();\n activate();\n return;\n case forward:\n event.preventDefault();\n if (!hasChildren) return;\n if (!isExpanded) ctx.toggle(value);\n else if (firstChildValue !== undefined) ctx.focusValue(firstChildValue);\n return;\n case back:\n event.preventDefault();\n if (hasChildren && isExpanded) ctx.toggle(value);\n else if (parent !== null) ctx.focusValue(parent);\n return;\n case '*': {\n event.preventDefault();\n const siblings = event.currentTarget.parentElement?.querySelectorAll<HTMLElement>(\n ':scope > [role=\"treeitem\"][aria-expanded=\"false\"][data-roving-value]',\n );\n ctx.expand(\n Array.from(siblings ?? [], (el) => el.getAttribute('data-roving-value') ?? '').filter(\n Boolean,\n ),\n );\n return;\n }\n default:\n }\n };\n\n const handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget) ctx.onItemFocus(value);\n };\n\n return (\n <div\n role=\"treeitem\"\n aria-selected={isSelected}\n aria-current={isCurrent ? true : undefined}\n className={cn(\n // The focus ring is drawn on the row: an outline on the treeitem would surround its\n // whole subtree.\n 'block outline-none',\n '[&:focus-visible>[data-tree-row]]:outline-2 [&:focus-visible>[data-tree-row]]:-outline-offset-2 [&:focus-visible>[data-tree-row]]:outline-ring',\n className,\n )}\n {...rest}\n // Named by its label only: the treeitem also contains its icon and its child group. A\n // consumer aria-labelledby or aria-label replaces it.\n aria-labelledby={\n rest['aria-labelledby'] ?? (rest['aria-label'] === undefined ? labelId : undefined)\n }\n aria-expanded={hasChildren ? isExpanded : undefined}\n tabIndex={ctx.getTabIndex(value)}\n data-roving-value={value}\n data-selected={isSelected ? '' : undefined}\n data-current={isCurrent ? '' : undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onFocus={composeEventHandlers(onFocus, handleFocus, { checkDefaultPrevented: false })}\n ref={ref}\n >\n <div\n data-tree-row=\"\"\n className={cn(\n 'flex cursor-pointer items-center gap-1.5 rounded px-2 py-1 hover:bg-subtle-hover',\n isSelected && cn('bg-subtle-selected font-semibold', forcedColors.selectedContainer),\n )}\n >\n {hasChildren ? (\n <ChevronRightIcon\n className={cn(\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isExpanded ? 'rotate-90' : 'wave-rtl:-scale-x-100',\n )}\n />\n ) : (\n <span className=\"w-3 shrink-0\" aria-hidden=\"true\" />\n )}\n {iconNode}\n <span id={labelId} data-tree-label=\"\" data-roving-text={typeaheadText} className=\"truncate\">\n <TreeLabelContext.Provider value>{labelContent}</TreeLabelContext.Provider>\n </span>\n </div>\n {hasChildren && isExpanded && (\n <TreeParentContext.Provider value={value}>\n <TreeLabelContext.Provider value={false}>\n <div role=\"group\" className=\"ps-4\">\n {nestedItems}\n </div>\n </TreeLabelContext.Provider>\n </TreeParentContext.Provider>\n )}\n </div>\n );\n};\nTreeItem.displayName = 'TreeItem';\n\n/* ------------------------------------------------------------------ */\n/* Export */\n/* ------------------------------------------------------------------ */\n\n/**\n * A hierarchical list (WAI-ARIA Tree View pattern) with a single tab stop: Up/Down move between\n * visible items, Home/End to the first/last, Right expands or moves to the first child, Left\n * collapses or moves to the parent (both mirrored in RTL), Enter/Space activate (and toggle a\n * parent), `*` expands the siblings, and typing jumps to an item by its text.\n *\n * Keyboard focus enters at the `selected` item, else the first item; while focus is inside, the\n * tab stop follows it, so Shift+Tab leaves the tree.\n *\n * Items are `Tree.Item` elements; nested items are written in their parent's children (directly,\n * in Fragments, or returned by a render function), not rendered by a component of their own.\n * Every item needs a `value` that is unique within the Tree.\n *\n * `Tree.Item` is also exported as `TreeItem` for React Server Components, which cannot use the\n * dotted form.\n */\nexport const Tree = /* @__PURE__ */ Object.assign(TreeRoot, {\n Item: TreeItem,\n});\n\nexport { TreeItem };\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,IAAMG,IAAcD,EAAM,cAAuC,IAAI,GAG/DE,IAAoBF,EAAM,cAA6B,IAAI,GAO3DG,IAAmBH,EAAM,cAAc,EAAK,GAE5CI,IA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AK,KAAA;EACjC,gBAAcC,IAAY,KAAK,KAAA;EAC/B,SAASC;EACT,WAAW3C;EACX,SAASO,EAAqBG,GAASyC,GAAa,EAAE,uBAAuB,GAAM,CAAC;EAC/E;EAzBP,UAAA,CA2BE,kBAAC,OAAD;GACE,iBAAc;GACd,WAAW9C,EACT,oFACAoC,KAAcpC,EAAG,oCAAoC+C,EAAa,iBAAiB,CACrF;GALF,UAAA;IAOGb,IACC,kBAACc,GAAD,EACE,WAAWhD,EACT,+DACAmB,IAAa,cAAc,uBAC7B,EACD,CAAA,IAED,kBAAC,QAAD;KAAM,WAAU;KAAe,eAAY;IAAQ,CAAA;IAEpDW;IACD,kBAAC,QAAD;KAAM,IAAIV;KAAS,mBAAgB;KAAG,oBAAkBL;KAAe,WAAU;KAC/E,UAAA,kBAAClE,EAAiB,UAAlB;MAA2B,OAAA;MAAO,UAAA0E;KAAwC,CAAA;IACtE,CAAA;GACH;EACJ,CAAA,GAAAW,KAAef,KACd,kBAACvE,EAAkB,UAAnB;GAAmC;GACjC,UAAA,kBAACC,EAAiB,UAAlB;IAA2B,OAAO;IAChC,UAAA,kBAAC,OAAD;KAAK,MAAK;KAAQ,WAAU;KACzB,UAAAyE;IACE,CAAA;GACoB,CAAA;EACD,CAAA,CAE3B;;AAET;AACA,EAAS,cAAc;AAsBvB,IAAa2B,IAAuB,uBAAO,OAAO3F,GAAU,EAC1D,MAAMuD,EACR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disclosureIds.cjs","names":["encodeIdPart","value","char","getPartId","baseId","part"],"sources":["../../../src/components/layout/disclosureIds.ts"],"sourcesContent":["/*\n * Internal id helpers shared by Accordion and TabList (P09, C-IDS). Not exported from the package.\n */\n\n/**\n * Encodes a value for use inside a DOM id without collisions: every character outside\n * `[A-Za-z0-9-]` (including `_`) becomes `_<hex code>_`, so `'a b'`, `'a.b'` and `'a_b'` stay\n * distinct.\n */\nexport function encodeIdPart(value: string): string {\n return value.replace(/[^A-Za-z0-9-]/g, (char) => `_${char.charCodeAt(0).toString(16)}_`);\n}\n\n/**\n * The one id helper (C-IDS): `${baseId}-${part}-${encoded value}`. `baseId` comes from `useId`\n * (one per Accordion or TabList), `part` names the element (`'trigger'`, `'panel'`, `'tab'`) and\n * `value` is the item or tab value.\n */\nexport function getPartId(baseId: string, part: string, value: string): string {\n return `${baseId}-${part}-${encodeIdPart(value)}`;\n}\n"],"mappings":"aASA,SAAgBA,EAAa,EAAuB,CAClD,OAAOC,EAAM,QAAQ,iBAAmB,GAAS,IAAIC,EAAK,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,CACzF,CAOA,SAAgBC,EAAU,EAAgB,EAAc,EAAuB,CAC7E,MAAO,GAAGC,EAAO,GAAGC,EAAK,GAAGL,EAAaC,CAAK,GAChD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/components/layout/disclosureIds.ts
|
|
3
|
+
function e(e) {
|
|
4
|
+
return e.replace(/[^A-Za-z0-9-]/g, (e) => `_${e.charCodeAt(0).toString(16)}_`);
|
|
5
|
+
}
|
|
6
|
+
function t(t, n, r) {
|
|
7
|
+
return `${t}-${n}-${e(r)}`;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { e as encodeIdPart, t as getPartId };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=disclosureIds.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disclosureIds.mjs","names":["encodeIdPart","value","char","getPartId","baseId","part"],"sources":["../../../src/components/layout/disclosureIds.ts"],"sourcesContent":["/*\n * Internal id helpers shared by Accordion and TabList (P09, C-IDS). Not exported from the package.\n */\n\n/**\n * Encodes a value for use inside a DOM id without collisions: every character outside\n * `[A-Za-z0-9-]` (including `_`) becomes `_<hex code>_`, so `'a b'`, `'a.b'` and `'a_b'` stay\n * distinct.\n */\nexport function encodeIdPart(value: string): string {\n return value.replace(/[^A-Za-z0-9-]/g, (char) => `_${char.charCodeAt(0).toString(16)}_`);\n}\n\n/**\n * The one id helper (C-IDS): `${baseId}-${part}-${encoded value}`. `baseId` comes from `useId`\n * (one per Accordion or TabList), `part` names the element (`'trigger'`, `'panel'`, `'tab'`) and\n * `value` is the item or tab value.\n */\nexport function getPartId(baseId: string, part: string, value: string): string {\n return `${baseId}-${part}-${encodeIdPart(value)}`;\n}\n"],"mappings":";;AASA,SAAgBA,EAAa,GAAuB;CAClD,OAAOC,EAAM,QAAQ,mBAAmB,MAAS,IAAIC,EAAK,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE;AACzF;AAOA,SAAgBC,EAAU,GAAgB,GAAc,GAAuB;CAC7E,OAAO,GAAGC,EAAO,GAAGC,EAAK,GAAGL,EAAaC,CAAK;AAChD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/dev.cjs"),n=require("../../hooks/useMergedRefs.cjs"),r=require("../../hooks/usePresence.cjs");let i=require("react");i=e.__toESM(i,1);function a(e){return i.isValidElement(e)?e.type===i.Fragment?a(e.props.children):e:null}var o=({visible:e,children:o,appear:s,unmountOnExit:c,onEntered:l,onExited:u})=>{let{isMounted:d,phase:f,ref:p,presenceProps:m}=r.usePresence(e,{appear:s,unmountOnExit:c,onEntered:l,onExited:u}),h=typeof o==`function`,g=h?null:a(o),_=n.useMergedRefs(p,g?.props.ref),v=!h&&g===null;return i.useEffect(()=>{v&&t.warnOnce(`Presence:children`,`Presence: expected a single element or a render function as its child; other children are rendered as given, without the presence attributes, and their enter and exit phases end at once.`)},[v]),d?h?o({isMounted:d,phase:f,ref:p,presenceProps:m}):g?i.cloneElement(g,{"data-presence":m[`data-presence`],inert:m.inert??g.props.inert,hidden:m.hidden??g.props.hidden,ref:_}):o:null};o.displayName=`Presence`,exports.Presence=o;
|
|
2
|
+
//# sourceMappingURL=Presence.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Presence.cjs","names":["React","usePresence","useMergedRefs","require_runtime","require_dev","require_useMergedRefs","require_usePresence","react","singleElement","children","Presence","visible","isRenderFunction","element","mergedRef","ref","invalidChildren","isMounted","presenceProps"],"sources":["../../../src/components/motion/Presence.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n usePresence,\n type UsePresenceOptions,\n type UsePresenceResult,\n} from '../../hooks/usePresence';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { warnOnce } from '../../lib/dev';\n\n/** Properties for the Presence component. */\nexport interface PresenceProps extends UsePresenceOptions {\n /** Whether the content is shown; changes run the enter and exit phases. */\n visible: boolean;\n /**\n * A single element, which receives the presence attributes and ref (merged with its own ref and\n * props: its own `inert` and `hidden` apply while the presence sets none), or a render function\n * that receives the presence result.\n */\n children: React.ReactElement | ((presence: UsePresenceResult) => React.ReactNode);\n}\n\ntype ChildProps = {\n ref?: React.Ref<HTMLElement>;\n inert?: boolean;\n hidden?: boolean;\n};\n\n/** The single element of `children` (a Fragment around one element is unwrapped), else `null`. */\nfunction singleElement(children: React.ReactNode): React.ReactElement<ChildProps> | null {\n if (!React.isValidElement<ChildProps & { children?: React.ReactNode }>(children)) return null;\n if (children.type !== React.Fragment) return children;\n return singleElement(children.props.children);\n}\n\n/**\n * Shows and hides its child with CSS enter and exit motion: the child stays mounted while its exit\n * motion runs, `inert` and marked `data-presence=\"exiting\"`, and unmounts when it ends (at once\n * under reduced motion or without motion). Style the phases on the child: a transition with the\n * `duration-wave-*` and `ease-wave-*` tokens, its start with the `starting:` variant gated on the\n * entering phase (`data-[presence=entering]:starting:` classes), its exit with\n * `data-[presence=exiting]:` classes, and a `motion-reduce:` counterpart (the `usePresence` JSDoc\n * and the Presence stories show complete class lists). An ungated `starting:` class also animates\n * a child that mounts `entered` (`appear={false}`, hydration): `@starting-style` applies to every\n * first style of an element.\n *\n * - The child is a single element (it must accept a `ref`, as DOM elements and ref-forwarding\n * components do), which receives `data-presence`, `inert` while exiting and the presence ref,\n * merged with its own ref and props; or a render function called with the presence result\n * (`isMounted`, `phase`, `ref`, `presenceProps`) to spread yourself.\n * - `appear` runs the enter phase on mount (never on the server or when hydrating),\n * `unmountOnExit={false}` keeps the exited child mounted, `hidden` and `inert`, and `onEntered`\n * and `onExited` report the end of a phase (see {@link usePresence}).\n * - Renders nothing while the child is not mounted. Other children (text, several elements) are\n * rendered as given, without the presence attributes, and a development warning is logged.\n *\n * @example\n * <Presence visible={open}>\n * <div className={fadeClasses}>Saved</div>\n * </Presence>\n */\nexport const Presence = ({\n visible,\n children,\n appear,\n unmountOnExit,\n onEntered,\n onExited,\n}: PresenceProps): React.ReactNode => {\n const { isMounted, phase, ref, presenceProps } = usePresence(visible, {\n appear,\n unmountOnExit,\n onEntered,\n onExited,\n });\n const isRenderFunction = typeof children === 'function';\n const element = isRenderFunction ? null : singleElement(children);\n const mergedRef = useMergedRefs<HTMLElement>(ref, element?.props.ref);\n const invalidChildren = !isRenderFunction && element === null;\n\n React.useEffect(() => {\n if (!invalidChildren) return;\n warnOnce(\n 'Presence:children',\n 'Presence: expected a single element or a render function as its child; other children are rendered as given, without the presence attributes, and their enter and exit phases end at once.',\n );\n }, [invalidChildren]);\n\n if (!isMounted) return null;\n if (isRenderFunction) return children({ isMounted, phase, ref, presenceProps });\n if (!element) return children as React.ReactNode;\n // Merged by hand (no mergeProps: the presence core stays free of the class merger).\n return React.cloneElement(element, {\n 'data-presence': presenceProps['data-presence'],\n inert: presenceProps.inert ?? element.props.inert,\n hidden: presenceProps.hidden ?? element.props.hidden,\n ref: mergedRef,\n } as ChildProps);\n};\nPresence.displayName = 'Presence';\n"],"mappings":"gOA4BA,SAASQ,EAAc,EAAkE,CAGvF,OAFKR,EAAM,eAA4DS,CAAQ,EAC3EA,EAAS,OAAST,EAAM,SACrBQ,EAAcC,EAAS,MAAM,QAAQ,EADCA,EAD4C,IAG3F,CA4BA,IAAaC,GAAY,CACvB,UACA,WACA,SACA,gBACA,YACA,cACoC,CACpC,GAAM,CAAE,YAAW,QAAO,MAAK,iBAAkBT,EAAAA,YAAYU,EAAS,CACpE,SACA,gBACA,YACA,UACF,CAAC,EACKC,EAAmB,OAAOH,GAAa,WACvCI,EAAUD,EAAmB,KAAOJ,EAAcC,CAAQ,EAC1DK,EAAYZ,EAAAA,cAA2Ba,EAAKF,GAAS,MAAM,GAAG,EAC9DG,EAAkB,CAACJ,GAAoBC,IAAY,KAczD,OAZAN,EAAM,cAAgB,CACfS,GACLZ,EAAA,SACE,oBACA,4LACF,CACF,EAAG,CAACY,CAAe,CAAC,EAEfC,EACDL,EAAyBH,EAAS,CAAE,YAAW,QAAO,MAAK,eAAc,CAAC,EACzEI,EAEEb,EAAM,aAAaa,EAAS,CACjC,gBAAiBK,EAAc,iBAC/B,MAAOA,EAAc,OAASL,EAAQ,MAAM,MAC5C,OAAQK,EAAc,QAAUL,EAAQ,MAAM,OAC9C,IAAKC,CACP,CAAe,EAPML,EAFE,IAUzB,EACA,EAAS,YAAc"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { warnOnce as e } from "../../lib/dev.mjs";
|
|
3
|
+
import { useMergedRefs as t } from "../../hooks/useMergedRefs.mjs";
|
|
4
|
+
import { usePresence as n } from "../../hooks/usePresence.mjs";
|
|
5
|
+
import * as r from "react";
|
|
6
|
+
//#region src/components/motion/Presence.tsx
|
|
7
|
+
function i(e) {
|
|
8
|
+
return r.isValidElement(e) ? e.type === r.Fragment ? i(e.props.children) : e : null;
|
|
9
|
+
}
|
|
10
|
+
var a = ({ visible: a, children: o, appear: s, unmountOnExit: c, onEntered: l, onExited: u }) => {
|
|
11
|
+
let { isMounted: d, phase: f, ref: p, presenceProps: m } = n(a, {
|
|
12
|
+
appear: s,
|
|
13
|
+
unmountOnExit: c,
|
|
14
|
+
onEntered: l,
|
|
15
|
+
onExited: u
|
|
16
|
+
}), h = typeof o == "function", g = h ? null : i(o), _ = t(p, g?.props.ref), v = !h && g === null;
|
|
17
|
+
return r.useEffect(() => {
|
|
18
|
+
v && e("Presence:children", "Presence: expected a single element or a render function as its child; other children are rendered as given, without the presence attributes, and their enter and exit phases end at once.");
|
|
19
|
+
}, [v]), d ? h ? o({
|
|
20
|
+
isMounted: d,
|
|
21
|
+
phase: f,
|
|
22
|
+
ref: p,
|
|
23
|
+
presenceProps: m
|
|
24
|
+
}) : g ? r.cloneElement(g, {
|
|
25
|
+
"data-presence": m["data-presence"],
|
|
26
|
+
inert: m.inert ?? g.props.inert,
|
|
27
|
+
hidden: m.hidden ?? g.props.hidden,
|
|
28
|
+
ref: _
|
|
29
|
+
}) : o : null;
|
|
30
|
+
};
|
|
31
|
+
a.displayName = "Presence";
|
|
32
|
+
//#endregion
|
|
33
|
+
export { a as Presence };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=Presence.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Presence.mjs","names":["React","singleElement","children","Presence","usePresence","visible","isRenderFunction","element","mergedRef","useMergedRefs","ref","invalidChildren","warnOnce","isMounted","presenceProps"],"sources":["../../../src/components/motion/Presence.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n usePresence,\n type UsePresenceOptions,\n type UsePresenceResult,\n} from '../../hooks/usePresence';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { warnOnce } from '../../lib/dev';\n\n/** Properties for the Presence component. */\nexport interface PresenceProps extends UsePresenceOptions {\n /** Whether the content is shown; changes run the enter and exit phases. */\n visible: boolean;\n /**\n * A single element, which receives the presence attributes and ref (merged with its own ref and\n * props: its own `inert` and `hidden` apply while the presence sets none), or a render function\n * that receives the presence result.\n */\n children: React.ReactElement | ((presence: UsePresenceResult) => React.ReactNode);\n}\n\ntype ChildProps = {\n ref?: React.Ref<HTMLElement>;\n inert?: boolean;\n hidden?: boolean;\n};\n\n/** The single element of `children` (a Fragment around one element is unwrapped), else `null`. */\nfunction singleElement(children: React.ReactNode): React.ReactElement<ChildProps> | null {\n if (!React.isValidElement<ChildProps & { children?: React.ReactNode }>(children)) return null;\n if (children.type !== React.Fragment) return children;\n return singleElement(children.props.children);\n}\n\n/**\n * Shows and hides its child with CSS enter and exit motion: the child stays mounted while its exit\n * motion runs, `inert` and marked `data-presence=\"exiting\"`, and unmounts when it ends (at once\n * under reduced motion or without motion). Style the phases on the child: a transition with the\n * `duration-wave-*` and `ease-wave-*` tokens, its start with the `starting:` variant gated on the\n * entering phase (`data-[presence=entering]:starting:` classes), its exit with\n * `data-[presence=exiting]:` classes, and a `motion-reduce:` counterpart (the `usePresence` JSDoc\n * and the Presence stories show complete class lists). An ungated `starting:` class also animates\n * a child that mounts `entered` (`appear={false}`, hydration): `@starting-style` applies to every\n * first style of an element.\n *\n * - The child is a single element (it must accept a `ref`, as DOM elements and ref-forwarding\n * components do), which receives `data-presence`, `inert` while exiting and the presence ref,\n * merged with its own ref and props; or a render function called with the presence result\n * (`isMounted`, `phase`, `ref`, `presenceProps`) to spread yourself.\n * - `appear` runs the enter phase on mount (never on the server or when hydrating),\n * `unmountOnExit={false}` keeps the exited child mounted, `hidden` and `inert`, and `onEntered`\n * and `onExited` report the end of a phase (see {@link usePresence}).\n * - Renders nothing while the child is not mounted. Other children (text, several elements) are\n * rendered as given, without the presence attributes, and a development warning is logged.\n *\n * @example\n * <Presence visible={open}>\n * <div className={fadeClasses}>Saved</div>\n * </Presence>\n */\nexport const Presence = ({\n visible,\n children,\n appear,\n unmountOnExit,\n onEntered,\n onExited,\n}: PresenceProps): React.ReactNode => {\n const { isMounted, phase, ref, presenceProps } = usePresence(visible, {\n appear,\n unmountOnExit,\n onEntered,\n onExited,\n });\n const isRenderFunction = typeof children === 'function';\n const element = isRenderFunction ? null : singleElement(children);\n const mergedRef = useMergedRefs<HTMLElement>(ref, element?.props.ref);\n const invalidChildren = !isRenderFunction && element === null;\n\n React.useEffect(() => {\n if (!invalidChildren) return;\n warnOnce(\n 'Presence:children',\n 'Presence: expected a single element or a render function as its child; other children are rendered as given, without the presence attributes, and their enter and exit phases end at once.',\n );\n }, [invalidChildren]);\n\n if (!isMounted) return null;\n if (isRenderFunction) return children({ isMounted, phase, ref, presenceProps });\n if (!element) return children as React.ReactNode;\n // Merged by hand (no mergeProps: the presence core stays free of the class merger).\n return React.cloneElement(element, {\n 'data-presence': presenceProps['data-presence'],\n inert: presenceProps.inert ?? element.props.inert,\n hidden: presenceProps.hidden ?? element.props.hidden,\n ref: mergedRef,\n } as ChildProps);\n};\nPresence.displayName = 'Presence';\n"],"mappings":";;;;;;AA4BA,SAASC,EAAc,GAAkE;CAGvF,OAFKD,EAAM,eAA4DE,CAAQ,IAC3EA,EAAS,SAASF,EAAM,WACrBC,EAAcC,EAAS,MAAM,QAAQ,IADCA,IAD4C;AAG3F;AA4BA,IAAaC,KAAY,EACvB,YACA,aACA,WACA,kBACA,cACA,kBACoC;CACpC,IAAM,EAAE,cAAW,UAAO,QAAK,qBAAkBC,EAAYC,GAAS;EACpE;EACA;EACA;EACA;CACF,CAAC,GACKC,IAAmB,OAAOJ,KAAa,YACvCK,IAAUD,IAAmB,OAAOL,EAAcC,CAAQ,GAC1DM,IAAYC,EAA2BC,GAAKH,GAAS,MAAM,GAAG,GAC9DI,IAAkB,CAACL,KAAoBC,MAAY;CAczD,OAZAP,EAAM,gBAAgB;EACpB,AAAKW,KACLC,EACE,qBACA,4LACF;CACF,GAAG,CAACD,CAAe,CAAC,GAEfE,IACDP,IAAyBJ,EAAS;EAAE;EAAW;EAAO;EAAK;CAAc,CAAC,IACzEK,IAEEP,EAAM,aAAaO,GAAS;EACjC,iBAAiBO,EAAc;EAC/B,OAAOA,EAAc,SAASP,EAAQ,MAAM;EAC5C,QAAQO,EAAc,UAAUP,EAAQ,MAAM;EAC9C,KAAKC;CACP,CAAe,IAPMN,IAFE;AAUzB;AACA,EAAS,cAAc"}
|
|
@@ -0,0 +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("../../lib/aria.cjs"),o=require("../../lib/styles.cjs"),s=require("../../lib/icons.cjs"),c=require("../../hooks/useTriggerElement.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=t.cn(`inline-flex cursor-pointer items-center text-primary no-underline not-disabled:not-aria-disabled:hover:underline`,o.focusRing,o.disabledStyles),f=`inline-flex items-center font-semibold text-foreground`,p=t.cn(f,o.focusRing,o.disabledStyles),m=`inline-flex items-center text-foreground`,h=new Set([`rel`,...Object.keys({disabled:!0,type:!0,form:!0,formAction:!0,formEncType:!0,formMethod:!0,formNoValidate:!0,formTarget:!0,name:!0,value:!0,target:!0,download:!0,hrefLang:!0,ping:!0,media:!0,referrerPolicy:!0})]);function g(e){let t={};for(let n of Object.keys(e))h.has(n)||(t[n]=e[n]);return t}var _=({children:e,className:t,ref:r,...i})=>{let a=n.flattenChildren(e);return(0,u.jsx)(`nav`,{ref:r,"aria-label":`Breadcrumb`,...i,className:t,children:(0,u.jsx)(`ol`,{className:`m-0 flex list-none items-center gap-1 p-0 text-body-1`,children:a.map(({key:e,node:t},n)=>(0,u.jsxs)(`li`,{className:`flex items-center gap-1`,children:[n>0&&(0,u.jsx)(s.ChevronRightIcon,{"data-wave-breadcrumb-separator":``,className:`shrink-0 text-muted-foreground wave-rtl:-scale-x-100`}),t]},e))})})};_.displayName=`Breadcrumb`;function v(e){let t=n.isElementOfType(e,`a`)?{href:void 0,role:`link`,disabled:void 0}:void 0;return l.cloneElement(e,{...t,"aria-disabled":!0,tabIndex:-1,onClick:void 0})}function y({child:e,icon:t,...n}){let r=t?l.cloneElement(e,void 0,t,e.props.children):e,i=c.useTriggerElement(r,n,{componentName:`Breadcrumb.Item`});return(0,u.jsx)(u.Fragment,{children:i})}function b(e){let{href:n,current:o=!1,icon:s,asChild:c=!1,children:h,className:_,onClick:b,ref:x,...S}=e,C=s&&i.slotRendersContent(s)?i.renderSlot(s,`span`,`me-1 inline-flex shrink-0`,{"aria-hidden":!0}):null,w=c&&l.isValidElement(h)?h:null,T=w?`child`:o?`current`:n===void 0?b?`button`:`text`:`link`,E=c&&w===null,D=S.disabled===!0&&(T===`text`||T===`current`),O=S[`aria-disabled`],k=w?.props??{},A=[S.disabled,O,k.disabled,k[`aria-disabled`]].some(e=>e===!0||e===`true`);if(l.useEffect(()=>{E&&r.warnOnce(`Breadcrumb.Item:asChild`,"Breadcrumb.Item: `asChild` expects a single element child (e.g. a router link); the item was rendered normally instead."),T===`text`&&r.warnOnce(`Breadcrumb.Item:no-href`,"Breadcrumb.Item: a non-current item without `href` or `onClick` renders as plain text, not a link. Pass `href` (or `onClick`, which renders a button) to make it navigable."),D&&r.warnOnce(`Breadcrumb.Item:disabled`,"Breadcrumb.Item: `disabled` applies to link, button and asChild items; it is ignored on a text or current item.")},[E,T,D]),w){let{disabled:e,...r}=S,i=n!==void 0&&!A?{href:n}:void 0;return(0,u.jsx)(y,{...r,...i,ref:x,onClick:a.preventIfDisabled(A,b),"aria-current":o?`page`:void 0,className:t.cn(o?p:d,_),icon:C,child:A?v(w):w})}if(T===`current`)return(0,u.jsxs)(`span`,{...g(S),ref:x,"aria-current":`page`,onClick:b,className:t.cn(f,_),children:[C,h]});if(T===`link`){let{disabled:e,...r}=S;return(0,u.jsxs)(`a`,{...r,ref:x,href:A?void 0:n,role:A?`link`:r.role,"aria-disabled":A?!0:O,tabIndex:A?-1:r.tabIndex,onClick:a.preventIfDisabled(A,b),className:t.cn(d,_),children:[C,h]})}if(T===`button`){let{rel:e,...n}=S;return(0,u.jsxs)(`button`,{type:`button`,...n,ref:x,onClick:b,className:t.cn(d,_),children:[C,h]})}return(0,u.jsxs)(`span`,{...g(S),ref:x,className:t.cn(m,_),children:[C,h]})}b.displayName=`BreadcrumbItem`;var x=Object.assign(_,{Item:b});exports.Breadcrumb=x,exports.BreadcrumbItem=b;
|
|
2
|
+
//# sourceMappingURL=Breadcrumb.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Breadcrumb.cjs","names":["cn","focusRing","disabledStyles","flattenChildren","ChevronRightIcon","isElementOfType","React","useTriggerElement","_Fragment","slotRendersContent","renderSlot","preventIfDisabled","require_runtime","require_cn","require_children","require_dev","require_slot","require_aria","require_styles","require_icons","require_useTriggerElement","react","react_jsx_runtime","linkClasses","currentClasses","currentChildClasses","textClasses","controlOnlyAttributes","spanAttributes","attributes","key","rest","BreadcrumbRoot","items","children","child","index","disableLinkChild","anchor","BreadcrumbItemChild","itemProps","target","icon","node","BreadcrumbItem","props","renderedIcon","asChild","kind","current","href","onClick","invalidAsChild","ignoredDisabled","ariaDisabled","childProps","linkDisabled","value","_disabled","childRest","childHref","className","anchorRest","buttonRest","Breadcrumb"],"sources":["../../../src/components/navigation/Breadcrumb.tsx"],"sourcesContent":["import * as React from 'react';\nimport { preventIfDisabled } from '../../lib/aria';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport type { Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { warnOnce } from '../../lib/dev';\nimport { ChevronRightIcon } from '../../lib/icons';\nimport { disabledStyles, focusRing } from '../../lib/styles';\nimport { useTriggerElement } from '../../hooks/useTriggerElement';\n\n/** Properties for the Breadcrumb component. */\nexport interface BreadcrumbProps extends React.HTMLAttributes<HTMLElement> {\n /**\n * Breadcrumb items to render; each one is placed in its own list item. Fragments are opened, so\n * the items of a conditional group (`{isAdmin && <>…</>}`) each get their own list item too.\n */\n children: React.ReactNode;\n /** Ref to the `<nav>` element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/**\n * The props of Breadcrumb.Item that every branch shares ({@link BreadcrumbItemAnchorProps},\n * {@link BreadcrumbItemButtonProps}, {@link BreadcrumbItemDynamicProps}).\n */\nexport interface BreadcrumbItemOwnProps {\n /**\n * Whether this item represents the current page (`aria-current=\"page\"`, rendered as text).\n * @default false\n */\n current?: boolean;\n /**\n * Slot for an icon displayed before the item text. Rendered with `aria-hidden=\"true\"`. A falsy\n * icon (`''`, `0`) or a list of nothing renders no icon span.\n */\n icon?: Slot<'span'>;\n /**\n * Merge the item's props (classes, `aria-current`, handlers, ref) onto its single child element\n * instead of rendering an element — for router links:\n * `<Breadcrumb.Item asChild><RouterLink to=\"/docs\">Docs</RouterLink></Breadcrumb.Item>`.\n * The icon is rendered inside the child. The item's `href` is passed on as a default (the\n * element's own `href` wins); with a router link, give the link its destination (`to`) instead.\n * `disabled` or `aria-disabled=\"true\"`, on the item or on the element, makes it an unavailable\n * link: `aria-disabled`, out of the tab order, its own `onClick` dropped and the click cancelled\n * (a router link does not navigate); an `<a>` also loses its `href`.\n * @default false\n */\n asChild?: boolean;\n /** Label content of the breadcrumb item (with `asChild`: the link element). */\n children: React.ReactNode;\n}\n\n/**\n * The attributes only a link has (`target`, `download`, `hrefLang`, `ping`, …). Items without\n * `href` declare them as `undefined`, so they are a type error instead of landing on a `<button>`\n * or `<span>`. `rel` cannot be listed (React types it on every element, RDFa); every non-link item\n * drops 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/** Breadcrumb.Item rendered as a link (`href` given): anchor attributes. */\nexport interface BreadcrumbItemAnchorProps\n extends\n BreadcrumbItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof BreadcrumbItemOwnProps> {\n /**\n * URL the breadcrumb item links to; renders an `<a>` (unless `current`). With `asChild` it is a\n * default for the element, whose own `href` wins. Required in this branch, so `href`\n * discriminates the union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /**\n * Makes the link unavailable, as Link's `disabled` does: no `href`, `role=\"link\"`,\n * `aria-disabled=\"true\"`, out of the tab order, and the click is cancelled (`onClick` is not\n * called). `aria-disabled=\"true\"` does the same.\n * @default false\n */\n disabled?: boolean;\n /** Ref to the rendered element (`<a>`, or `<span>` for the current item). */\n ref?: React.Ref<HTMLAnchorElement | HTMLSpanElement>;\n}\n\n/**\n * Breadcrumb.Item without `href`: a `<button type=\"button\">` when `onClick` is given (button\n * attributes; `disabled` gives it the disabled look), plain text otherwise. A `rel` is not\n * rendered on either.\n */\nexport interface BreadcrumbItemButtonProps\n extends\n BreadcrumbItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof BreadcrumbItemOwnProps> {\n /** Items without a link have no `href`. */\n href?: undefined;\n /** Ref to the rendered element (`<button>`, or `<span>` for text and the current item). */\n ref?: React.Ref<HTMLButtonElement | HTMLSpanElement>;\n}\n\n/**\n * Properties for the BreadcrumbItem 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 BreadcrumbItemAnchorProps`) or intersect\n * (`type X = BreadcrumbItemProps & { … }`). `React.ComponentProps<typeof Breadcrumb.Item>`\n * resolves to the last overload, {@link BreadcrumbItemDynamicProps}.\n */\nexport type BreadcrumbItemProps = BreadcrumbItemAnchorProps | BreadcrumbItemButtonProps;\n\n/**\n * Breadcrumb.Item with an `href` known only at run time (`string | undefined`): a link when it is\n * a string, otherwise a button (with `onClick`) or text. Handlers receive `HTMLElement` events and\n * only the attributes all kinds share are accepted (the 0.4 prop shape). Resolved after the button\n * and link signatures.\n */\nexport interface BreadcrumbItemDynamicProps\n extends\n BreadcrumbItemOwnProps,\n Omit<React.HTMLAttributes<HTMLElement>, keyof BreadcrumbItemOwnProps> {\n /** URL the breadcrumb item links to when defined. */\n href?: string;\n /**\n * Makes a link or button item unavailable (see {@link BreadcrumbItemAnchorProps} and\n * {@link BreadcrumbItemButtonProps}); ignored, with a development warning, on a text or current\n * item.\n * @default false\n */\n disabled?: boolean;\n /** Ref to the rendered element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** The props every item kind shares at runtime (the union narrowed by `href`). */\ntype BreadcrumbEntryProps = BreadcrumbItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof BreadcrumbItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n/**\n * Links, buttons and `asChild` elements. The hover underline is gated (C-TOKENS), and the\n * disabled look covers a `disabled` button and an `aria-disabled` link.\n */\nconst linkClasses = cn(\n 'inline-flex cursor-pointer items-center text-primary no-underline not-disabled:not-aria-disabled:hover:underline',\n focusRing,\n disabledStyles,\n);\nconst currentClasses = 'inline-flex items-center font-semibold text-foreground';\n/** A current `asChild` element is the consumer's link: it takes focus and can be disabled. */\nconst currentChildClasses = cn(currentClasses, focusRing, disabledStyles);\nconst textClasses = 'inline-flex items-center text-foreground';\n\n/**\n * The attributes only a `<button>` or an `<a>` has (`disabled`, `type`, `form*`, `name`, `value`;\n * `target`, `download`, `hrefLang`, `ping`, `media`, `referrerPolicy`). The button props allow\n * `disabled` without `onClick`, and a current item keeps its link attributes, so the `<span>` of\n * the text and current items drops them instead of rendering invalid markup\n * (`<span disabled>`, `<span target=\"_blank\">`). Typed as a record so a key React adds to either\n * element's attributes is a compile error until it is listed here. `rel` is dropped as well: React\n * types it on every element (RDFa), but on a breadcrumb it comes with a link.\n */\ntype ControlOnlyAttribute =\n | Exclude<\n keyof React.ButtonHTMLAttributes<HTMLButtonElement>,\n keyof React.HTMLAttributes<HTMLElement>\n >\n | Exclude<\n keyof React.AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof React.HTMLAttributes<HTMLElement> | 'href'\n >;\n\nconst controlOnlyAttributes: ReadonlySet<string> = /* @__PURE__ */ new Set([\n 'rel',\n ...Object.keys({\n disabled: true,\n type: true,\n form: true,\n formAction: true,\n formEncType: true,\n formMethod: true,\n formNoValidate: true,\n formTarget: true,\n name: true,\n value: true,\n target: true,\n download: true,\n hrefLang: true,\n ping: true,\n media: true,\n referrerPolicy: true,\n } satisfies Record<ControlOnlyAttribute, true>),\n]);\n\n/** The props that are valid on the `<span>` of a text or current item. */\nfunction spanAttributes(rest: Record<string, unknown>): React.HTMLAttributes<HTMLSpanElement> {\n const attributes: Record<string, unknown> = {};\n for (const key of Object.keys(rest)) {\n if (!controlOnlyAttributes.has(key)) attributes[key] = rest[key];\n }\n return attributes as React.HTMLAttributes<HTMLSpanElement>;\n}\n\nconst BreadcrumbRoot = ({ children, className, ref, ...rest }: BreadcrumbProps) => {\n // Fragments are opened (`{isAdmin && <>…</>}`), so every crumb gets its own list item and separator.\n const items = flattenChildren(children);\n\n return (\n <nav ref={ref} aria-label=\"Breadcrumb\" {...rest} className={className}>\n <ol className=\"m-0 flex list-none items-center gap-1 p-0 text-body-1\">\n {items.map(({ key, node: child }, index) => (\n <li key={key} className=\"flex items-center gap-1\">\n {index > 0 && (\n <ChevronRightIcon\n data-wave-breadcrumb-separator=\"\"\n className=\"shrink-0 text-muted-foreground wave-rtl:-scale-x-100\"\n />\n )}\n {child}\n </li>\n ))}\n </ol>\n </nav>\n );\n};\nBreadcrumbRoot.displayName = 'Breadcrumb';\n\ninterface BreadcrumbItemChildProps extends React.HTMLAttributes<HTMLElement> {\n /** The item's `href`, a default for the element (the element's own `href` wins). */\n href?: string;\n child: React.ReactElement<{ children?: React.ReactNode }>;\n icon: React.ReactNode;\n ref?: React.Ref<HTMLElement>;\n}\n\n/**\n * Link's disabled contract for an `asChild` element: an `<a>` drops its `href` (it is still\n * announced as a link); any element gets `aria-disabled`, leaves the tab order and loses its own\n * `onClick`. The item's click handler cancels the click, so a router link does not navigate.\n */\nfunction disableLinkChild(\n child: React.ReactElement<{ children?: React.ReactNode }>,\n): React.ReactElement<{ children?: React.ReactNode }> {\n const anchor = isElementOfType(child, 'a')\n ? { href: undefined, role: 'link', disabled: undefined }\n : undefined;\n return React.cloneElement(child as React.ReactElement<Record<string, unknown>>, {\n ...anchor,\n 'aria-disabled': true,\n tabIndex: -1,\n onClick: undefined,\n }) as React.ReactElement<{ children?: React.ReactNode }>;\n}\n\n/**\n * `asChild` rendering: the item's props are merged onto the consumer's element with\n * `useTriggerElement` (the element's own handlers run first and its classes win conflicts; its\n * ref and the item's ref are both attached). The icon is placed inside the element.\n */\nfunction BreadcrumbItemChild({ child, icon, ...itemProps }: BreadcrumbItemChildProps) {\n const target = icon ? React.cloneElement(child, undefined, icon, child.props.children) : child;\n const node = useTriggerElement(target, itemProps, { componentName: 'Breadcrumb.Item' });\n return <>{node}</>;\n}\n\n/**\n * One step of a breadcrumb trail:\n * - `href` → a link (`<a>`, anchor attributes);\n * - `current` → the current page as text (`<span aria-current=\"page\">`);\n * - no `href` with `onClick` → a `<button type=\"button\">` styled as a link;\n * - no `href` and no `onClick` → plain text (`<span>`; development warning for a non-current item);\n * - `asChild` → the props are merged onto the single child element (router links).\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 BreadcrumbItemDynamicProps}: `HTMLElement` events).\n *\n * Also exported as `BreadcrumbItem` (import the flat name from React Server Components).\n */\nfunction BreadcrumbItem(props: BreadcrumbItemButtonProps): React.ReactElement;\nfunction BreadcrumbItem(props: BreadcrumbItemAnchorProps): React.ReactElement;\nfunction BreadcrumbItem(props: BreadcrumbItemDynamicProps): React.ReactElement;\nfunction BreadcrumbItem(\n props: BreadcrumbItemProps | BreadcrumbItemDynamicProps,\n): React.ReactElement {\n const {\n href,\n current = false,\n icon,\n asChild = false,\n children,\n className,\n onClick,\n ref,\n ...rest\n } = props as BreadcrumbEntryProps;\n\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in Nav,\n // Tree and Avatar, and so is a collection whose items render nothing: no empty span and no stray\n // `me-1` margin. The check does not consume a generator: renderSlot still renders its items.\n const renderedIcon =\n icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', 'me-1 inline-flex shrink-0', { 'aria-hidden': true })\n : null;\n const child =\n asChild && React.isValidElement<{ children?: React.ReactNode }>(children) ? children : null;\n const kind = child\n ? 'child'\n : current\n ? 'current'\n : href !== undefined\n ? 'link'\n : onClick\n ? 'button'\n : 'text';\n\n const invalidAsChild = asChild && child === null;\n const ignoredDisabled = rest.disabled === true && (kind === 'text' || kind === 'current');\n // Link and asChild items follow Link's disabled contract. `<a disabled>` does not block\n // navigation, and an `aria-disabled` link only looks disabled unless the click is cancelled.\n // With asChild the element is the link, so its own `disabled`/`aria-disabled` count too.\n const ariaDisabled = rest['aria-disabled'];\n const childProps = (child?.props ?? {}) as Record<string, unknown>;\n const linkDisabled = [\n rest.disabled,\n ariaDisabled,\n childProps.disabled,\n childProps['aria-disabled'],\n ].some((value) => value === true || value === 'true');\n React.useEffect(() => {\n if (invalidAsChild) {\n warnOnce(\n 'Breadcrumb.Item:asChild',\n 'Breadcrumb.Item: `asChild` expects a single element child (e.g. a router link); the item was rendered normally instead.',\n );\n }\n if (kind === 'text') {\n warnOnce(\n 'Breadcrumb.Item:no-href',\n 'Breadcrumb.Item: a non-current item without `href` or `onClick` renders as plain text, not a link. Pass `href` (or `onClick`, which renders a button) to make it navigable.',\n );\n }\n if (ignoredDisabled) {\n warnOnce(\n 'Breadcrumb.Item:disabled',\n 'Breadcrumb.Item: `disabled` applies to link, button and asChild items; it is ignored on a text or current item.',\n );\n }\n }, [invalidAsChild, kind, ignoredDisabled]);\n\n if (child) {\n const { disabled: _disabled, ...childRest } = rest;\n // Like the other item props, `href` is a default for the element (its own `href` wins). A\n // disabled link has no destination, so it is not passed then.\n const childHref = href !== undefined && !linkDisabled ? { href } : undefined;\n return (\n <BreadcrumbItemChild\n {...(childRest as React.HTMLAttributes<HTMLElement>)}\n {...childHref}\n ref={ref}\n onClick={preventIfDisabled(linkDisabled, onClick)}\n aria-current={current ? 'page' : undefined}\n className={cn(current ? currentChildClasses : linkClasses, className)}\n icon={renderedIcon}\n child={linkDisabled ? disableLinkChild(child) : child}\n />\n );\n }\n\n if (kind === 'current') {\n return (\n <span\n {...spanAttributes(rest)}\n ref={ref as React.Ref<HTMLSpanElement>}\n aria-current=\"page\"\n onClick={onClick}\n className={cn(currentClasses, className)}\n >\n {renderedIcon}\n {children}\n </span>\n );\n }\n\n if (kind === 'link') {\n const { disabled: _disabled, ...anchorRest } = rest;\n return (\n <a\n {...(anchorRest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={linkDisabled ? undefined : href}\n role={linkDisabled ? 'link' : anchorRest.role}\n aria-disabled={linkDisabled ? true : ariaDisabled}\n tabIndex={linkDisabled ? -1 : anchorRest.tabIndex}\n onClick={preventIfDisabled(linkDisabled, onClick)}\n className={cn(linkClasses, className)}\n >\n {renderedIcon}\n {children}\n </a>\n );\n }\n\n if (kind === 'button') {\n // `rel` only belongs on a link: a button item drops it, like the text and current items.\n const { rel, ...buttonRest } = rest;\n return (\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n ref={ref as React.Ref<HTMLButtonElement>}\n onClick={onClick}\n className={cn(linkClasses, className)}\n >\n {renderedIcon}\n {children}\n </button>\n );\n }\n\n return (\n <span\n {...spanAttributes(rest)}\n ref={ref as React.Ref<HTMLSpanElement>}\n className={cn(textClasses, className)}\n >\n {renderedIcon}\n {children}\n </span>\n );\n}\nBreadcrumbItem.displayName = 'BreadcrumbItem';\n\n/**\n * A breadcrumb trail: a `<nav aria-label=\"Breadcrumb\">` landmark with an ordered list. Each child\n * is placed in its own list item (Fragments are opened, so each of their items gets one too); from\n * the second one on, the item begins with a decorative separator chevron that is mirrored in\n * right-to-left layouts.\n *\n * `Breadcrumb.Item` is also exported as `BreadcrumbItem`: React Server Components import the flat\n * name, because dotted access needs a client file.\n *\n * @example\n * <Breadcrumb>\n * <Breadcrumb.Item href=\"/\">Home</Breadcrumb.Item>\n * <Breadcrumb.Item current>Settings</Breadcrumb.Item>\n * </Breadcrumb>\n */\nexport const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