@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,227 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { reportMissingContext as e, warnOnce as t } from "../../lib/dev.mjs";
|
|
3
|
+
import { useControllable as n } from "../../hooks/useControllable.mjs";
|
|
4
|
+
import { useId as r } from "../../hooks/useId.mjs";
|
|
5
|
+
import { focusElement as i } from "../../lib/focus.mjs";
|
|
6
|
+
import { useMergedRefs as a } from "../../hooks/useMergedRefs.mjs";
|
|
7
|
+
import { mergeProps as o } from "../../lib/mergeProps.mjs";
|
|
8
|
+
import { STATE_ARIA as s } from "../../lib/renderTrigger.mjs";
|
|
9
|
+
import { getTriggerFocusTarget as c, useTriggerElement as l } from "../../hooks/useTriggerElement.mjs";
|
|
10
|
+
import * as u from "react";
|
|
11
|
+
//#region src/components/overlays/Dialog.shared.tsx
|
|
12
|
+
function d(e, t, r) {
|
|
13
|
+
let i = u.useRef(void 0), [a, o] = n(e, t ?? !1, (e) => r?.(e, i.current));
|
|
14
|
+
return [a, u.useCallback((e, t) => {
|
|
15
|
+
i.current = t;
|
|
16
|
+
try {
|
|
17
|
+
o(e);
|
|
18
|
+
} finally {
|
|
19
|
+
i.current = void 0;
|
|
20
|
+
}
|
|
21
|
+
}, [o])];
|
|
22
|
+
}
|
|
23
|
+
function f(e, n, r) {
|
|
24
|
+
return u.useCallback((i, a) => {
|
|
25
|
+
switch (i) {
|
|
26
|
+
case "escape":
|
|
27
|
+
e(!1, {
|
|
28
|
+
reason: i,
|
|
29
|
+
event: a
|
|
30
|
+
});
|
|
31
|
+
break;
|
|
32
|
+
case "outside-press":
|
|
33
|
+
e(!1, {
|
|
34
|
+
reason: i,
|
|
35
|
+
event: a
|
|
36
|
+
}), r?.();
|
|
37
|
+
break;
|
|
38
|
+
case "focus-outside":
|
|
39
|
+
t(`${n}:focus-outside`, `${n} ignored a focus-outside dismissal: a modal surface does not close when focus leaves it.`);
|
|
40
|
+
break;
|
|
41
|
+
default: return i;
|
|
42
|
+
}
|
|
43
|
+
}, [
|
|
44
|
+
e,
|
|
45
|
+
n,
|
|
46
|
+
r
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
function p(e, t) {
|
|
50
|
+
let n = u.useRef(null);
|
|
51
|
+
return {
|
|
52
|
+
onMouseDown: u.useCallback((r) => {
|
|
53
|
+
if (r.target !== r.currentTarget) return;
|
|
54
|
+
if (!t) {
|
|
55
|
+
r.preventDefault();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let i = v();
|
|
59
|
+
n.current = i && e.current?.contains(i) ? i : null;
|
|
60
|
+
}, [t, e]),
|
|
61
|
+
afterOutsidePress: u.useCallback(() => {
|
|
62
|
+
let t = n.current;
|
|
63
|
+
n.current = null, t && queueMicrotask(() => {
|
|
64
|
+
v() === null && e.current?.contains(t) && i(t, { preventScroll: !0 });
|
|
65
|
+
});
|
|
66
|
+
}, [e])
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function m(e) {
|
|
70
|
+
return typeof e == "object" && !!e && typeof e.type == "string" && typeof e.stopPropagation == "function" && !("nativeEvent" in e);
|
|
71
|
+
}
|
|
72
|
+
function h(e) {
|
|
73
|
+
let t = typeof e == "object" && e ? e.nativeEvent : void 0;
|
|
74
|
+
return m(t) ? t : m(e) ? e : new Event("click");
|
|
75
|
+
}
|
|
76
|
+
var g = {
|
|
77
|
+
attach: () => void 0,
|
|
78
|
+
activate: () => {},
|
|
79
|
+
startSession: () => {},
|
|
80
|
+
endSession: () => {},
|
|
81
|
+
focusRef: { current: null }
|
|
82
|
+
};
|
|
83
|
+
function _(e) {
|
|
84
|
+
return typeof e == "object" && !!e && e.nodeType === 1;
|
|
85
|
+
}
|
|
86
|
+
function v() {
|
|
87
|
+
if (typeof document > "u") return null;
|
|
88
|
+
let e = document.activeElement;
|
|
89
|
+
return !e || e === document.body || e === document.documentElement ? null : e.isConnected ? e : null;
|
|
90
|
+
}
|
|
91
|
+
function y() {
|
|
92
|
+
let e = /* @__PURE__ */ new Set(), t = null, n = !1;
|
|
93
|
+
return {
|
|
94
|
+
attach: (n) => {
|
|
95
|
+
if (n) return e.add(n), () => {
|
|
96
|
+
e.delete(n), t === n && (t = null);
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
activate: (e) => {
|
|
100
|
+
_(e) && (t = e, !n && setTimeout(() => {
|
|
101
|
+
!n && t === e && (t = null);
|
|
102
|
+
}, 0));
|
|
103
|
+
},
|
|
104
|
+
startSession: () => {
|
|
105
|
+
n = !0;
|
|
106
|
+
},
|
|
107
|
+
endSession: () => {
|
|
108
|
+
n = !1, t = null;
|
|
109
|
+
},
|
|
110
|
+
focusRef: { get current() {
|
|
111
|
+
let n = v();
|
|
112
|
+
if (n) return e.has(n) ? c(n) : null;
|
|
113
|
+
if (t?.isConnected) return c(t);
|
|
114
|
+
for (let t of e) {
|
|
115
|
+
if (!t.isConnected) continue;
|
|
116
|
+
let e = c(t);
|
|
117
|
+
if (e) return e;
|
|
118
|
+
}
|
|
119
|
+
return null;
|
|
120
|
+
} }
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function b() {
|
|
124
|
+
let [e] = u.useState(y);
|
|
125
|
+
return e;
|
|
126
|
+
}
|
|
127
|
+
function x(e) {
|
|
128
|
+
let t = null;
|
|
129
|
+
return {
|
|
130
|
+
attach: (n) => {
|
|
131
|
+
if (!n) return;
|
|
132
|
+
t = n;
|
|
133
|
+
let r = e.attach(n);
|
|
134
|
+
return () => {
|
|
135
|
+
t === n && (t = null), typeof r == "function" && r();
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
activate: (n) => {
|
|
139
|
+
let r = typeof n == "object" && n ? n.currentTarget : void 0;
|
|
140
|
+
e.activate(t ?? r);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function S(e) {
|
|
145
|
+
return u.useMemo(() => x(e), [e]);
|
|
146
|
+
}
|
|
147
|
+
function C(e, { children: t, asChild: n, ref: r, ...i }, c) {
|
|
148
|
+
let { open: d, requestOpen: f, trigger: p, controlsId: m } = e, { attach: g, activate: _ } = S(p), v = a(g, r), y = u.useCallback((e) => {
|
|
149
|
+
_(e), f(!0, {
|
|
150
|
+
reason: "trigger",
|
|
151
|
+
event: h(e)
|
|
152
|
+
});
|
|
153
|
+
}, [_, f]), b = o({
|
|
154
|
+
"aria-haspopup": "dialog",
|
|
155
|
+
"aria-expanded": d,
|
|
156
|
+
"aria-controls": d ? m : void 0,
|
|
157
|
+
onClick: y,
|
|
158
|
+
ref: v
|
|
159
|
+
}, i, { oursWin: s });
|
|
160
|
+
return l(t, b, {
|
|
161
|
+
componentName: c,
|
|
162
|
+
asChild: n
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function w(e, { children: t, asChild: n, ref: r, ...i }, s) {
|
|
166
|
+
let c = a(r), d = u.useCallback((t) => e(!1, {
|
|
167
|
+
reason: "close",
|
|
168
|
+
event: h(t)
|
|
169
|
+
}), [e]), f = o({
|
|
170
|
+
onClick: d,
|
|
171
|
+
ref: c
|
|
172
|
+
}, i);
|
|
173
|
+
return l(t, f, {
|
|
174
|
+
componentName: s,
|
|
175
|
+
asChild: n
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function T(e, t) {
|
|
179
|
+
u.useLayoutEffect(() => {
|
|
180
|
+
t ? e.startSession() : e.endSession();
|
|
181
|
+
}, [e, t]);
|
|
182
|
+
}
|
|
183
|
+
function E(t, n, r, i) {
|
|
184
|
+
let a = u.useContext(t);
|
|
185
|
+
return a === null ? (e(n, r), i()) : a;
|
|
186
|
+
}
|
|
187
|
+
var D = u.createContext(null);
|
|
188
|
+
D.displayName = "ModalSurfaceContext";
|
|
189
|
+
var O = { registerTitle: () => () => {} };
|
|
190
|
+
function k() {
|
|
191
|
+
let [e, t] = u.useState([]), n = u.useRef(0), r = u.useCallback((e) => {
|
|
192
|
+
n.current += 1, t((t) => [...t, e]);
|
|
193
|
+
let r = !0;
|
|
194
|
+
return () => {
|
|
195
|
+
r && (r = !1, --n.current, t((t) => {
|
|
196
|
+
let n = t.indexOf(e);
|
|
197
|
+
return n === -1 ? t : [...t.slice(0, n), ...t.slice(n + 1)];
|
|
198
|
+
}));
|
|
199
|
+
};
|
|
200
|
+
}, []), i = u.useCallback(() => n.current > 0, []), a = u.useMemo(() => ({ registerTitle: r }), [r]);
|
|
201
|
+
return {
|
|
202
|
+
titleId: e[0],
|
|
203
|
+
hasTitle: i,
|
|
204
|
+
context: a
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function A(e, t, n, i) {
|
|
208
|
+
let { registerTitle: o } = E(D, e, t, () => O), s = r("wave-modal-title"), c = n ?? s, l = u.useCallback((e) => e ? o(c) : void 0, [o, c]);
|
|
209
|
+
return {
|
|
210
|
+
id: c,
|
|
211
|
+
ref: a(i, l)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function j(e, n, r, i) {
|
|
215
|
+
u.useEffect(() => {
|
|
216
|
+
e && (e.hasAttribute("aria-label") || e.hasAttribute("aria-labelledby") || n() || t(`${r}:unnamed`, `${r} has no accessible name. Pass \`title\`, render a ${i} inside it, or give it \`aria-label\` or \`aria-labelledby\`.`));
|
|
217
|
+
}, [
|
|
218
|
+
e,
|
|
219
|
+
n,
|
|
220
|
+
r,
|
|
221
|
+
i
|
|
222
|
+
]);
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
export { D as ModalSurfaceContext, h as getNativeEvent, g as inertModalTrigger, p as useBackdropPress, w as useModalClosePart, f as useModalDismiss, d as useModalOpenState, A as useModalTitle, b as useModalTrigger, C as useModalTriggerPart, T as useModalTriggerSession, E as useRequiredContext, k as useTitleRegistry, j as useUnnamedModalWarning };
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=Dialog.shared.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.shared.mjs","names":["unmapped","useId","useId$1","React","useModalOpenState","detailsRef","value","setOpen","useControllable","open","defaultOpen","onOpenChange","next","details","useModalDismiss","reason","requestOpen","afterOutsidePress","componentName","useBackdropPress","pressFocusRef","event","closesOnPress","focused","getFocusedElement","surfaceRef","element","focusElement","isDomEvent","getNativeEvent","native","inertModalTrigger","isElementTarget","target","active","createModalTrigger","attached","activated","sessionOpen","getTriggerFocusTarget","useModalTrigger","trigger","createModalTriggerElement","node","detach","currentTarget","useModalTriggerElement","useModalTriggerPart","rest","modal","mergedRef","useMergedRefs","attach","ref","openModal","activate","triggerProps","mergeProps","controlsId","STATE_ARIA","useTriggerElement","children","useModalClosePart","close","closeProps","useModalTriggerSession","useRequiredContext","context","reportMissingContext","parentName","getInert","ModalSurfaceContext","inertSurface","useTitleRegistry","ids","setIds","countRef","registerTitle","current","id","registered","index","hasTitle","useModalTitle","generatedId","idProp","register","useUnnamedModalWarning","surface","warnOnce","titleName"],"sources":["../../../src/components/overlays/Dialog.shared.tsx"],"sourcesContent":["import * as React from 'react';\nimport { reportMissingContext, warnOnce } from '../../lib/dev';\nimport { focusElement } from '../../lib/focus';\nimport type { DismissReason } from '../../lib/layers';\nimport { mergeProps } from '../../lib/mergeProps';\nimport { STATE_ARIA } from '../../lib/renderTrigger';\nimport type { ModalOpenChangeReason, OpenChangeDetails } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { getTriggerFocusTarget, useTriggerElement } from '../../hooks/useTriggerElement';\n\n/*\n * Internal helpers shared by Dialog and Drawer (P15). Not exported from the package.\n */\n\n/** Why a modal root asks to open or close, and the event (`DialogOpenChangeDetails`). */\nexport type ModalOpenChangeDetails = OpenChangeDetails<ModalOpenChangeReason>;\n\n/** Asks a modal root to open or close; see {@link useModalOpenState}. */\nexport type ModalRequestOpen = (open: boolean, details: ModalOpenChangeDetails) => void;\n\n/**\n * The open state of a modal root (`Dialog`, `Drawer`): `useControllable`, plus the details of the\n * request behind each change. Every internal path asks through `requestOpen(next, details)`, which\n * writes `details` to a ref, calls the setter and clears the ref once the setter returns.\n * `useControllable` calls its `onChange` synchronously inside the setter, only when the value\n * changes, and that `onChange` passes the ref's details on as `onOpenChange(next, details)`.\n * Clearing the ref afterwards means a change that no request caused can never report a stale\n * reason.\n */\nexport function useModalOpenState(\n open: boolean | undefined,\n defaultOpen: boolean | undefined,\n onOpenChange: ((open: boolean, details?: ModalOpenChangeDetails) => void) | undefined,\n): [open: boolean, requestOpen: ModalRequestOpen] {\n const detailsRef = React.useRef<ModalOpenChangeDetails | undefined>(undefined);\n const [value, setOpen] = useControllable(open, defaultOpen ?? false, (next: boolean) =>\n onOpenChange?.(next, detailsRef.current),\n );\n const requestOpen = React.useCallback<ModalRequestOpen>(\n (next, details) => {\n detailsRef.current = details;\n try {\n setOpen(next);\n } finally {\n detailsRef.current = undefined;\n }\n },\n [setOpen],\n );\n return [value, requestOpen];\n}\n\n/**\n * The `onDismiss` of a modal root's layer (`useModalLayer`): Escape and a backdrop press ask the\n * root to close, with their reason and event. `focus-outside` never reaches a modal layer (only a\n * layer registered with `focusOutside: true` gets it), so it is ignored with a development warning.\n *\n * @param requestOpen The root's request function, from {@link useModalOpenState}.\n * @param componentName The public name for the warning, e.g. `'Dialog'`.\n * @param afterOutsidePress Called right after an `outside-press` request (see\n * {@link useBackdropPress}).\n */\nexport function useModalDismiss(\n requestOpen: ModalRequestOpen,\n componentName: string,\n afterOutsidePress?: () => void,\n): (reason: DismissReason, event: Event) => void {\n return React.useCallback(\n (reason: DismissReason, event: Event) => {\n switch (reason) {\n case 'escape':\n requestOpen(false, { reason, event });\n break;\n case 'outside-press':\n requestOpen(false, { reason, event });\n afterOutsidePress?.();\n break;\n case 'focus-outside':\n warnOnce(\n `${componentName}:focus-outside`,\n `${componentName} ignored a focus-outside dismissal: a modal surface does not close when focus leaves it.`,\n );\n break;\n default: {\n // Exhaustive: a new DismissReason does not compile here until it is mapped.\n const unmapped: never = reason;\n return unmapped;\n }\n }\n },\n [requestOpen, componentName, afterOutsidePress],\n );\n}\n\n/** Returned by {@link useBackdropPress}. */\nexport interface BackdropPress {\n /** `onMouseDown` of the backdrop element. Stable while `closesOnPress` stays the same. */\n onMouseDown: (event: React.MouseEvent<HTMLElement>) => void;\n /** Pass it to {@link useModalDismiss}, which calls it after an `outside-press` request. Stable. */\n afterOutsidePress: () => void;\n}\n\n/**\n * What a press on a modal's backdrop does to focus (`Dialog.Content`, the Drawer panel). Presses\n * that start inside the surface bubble through unchanged.\n *\n * - When the press closes the modal (`closesOnPress`), the browser moves focus to `<body>` as\n * usual, so the focused control blurs while it is still mounted and its blur-time commit runs\n * (the typed text of a SpinButton or a picker, a consumer's `onBlur` autosave or validation)\n * before the click closes the surface. The element inside the surface that had focus is\n * remembered: when the surface is still open after the `outside-press` request (a controlled\n * modal refused it), it gets focus back, in a microtask that runs after React has committed the\n * request, and only while focus is still on `<body>` (a confirm dialog the refusal opened keeps\n * its focus).\n * - When the press never closes the modal (an alert dialog), the press does not move focus at all\n * (`preventDefault()`), so nothing blurs.\n *\n * @param surfaceRef The surface element (the dialog or the drawer panel).\n * @param closesOnPress Whether a backdrop press asks the modal to close (its layer's `outsidePress`).\n */\nexport function useBackdropPress(\n surfaceRef: React.RefObject<HTMLElement | null>,\n closesOnPress: boolean,\n): BackdropPress {\n // The element inside the surface that had focus when the last backdrop press started.\n const pressFocusRef = React.useRef<HTMLElement | null>(null);\n\n const onMouseDown = React.useCallback(\n (event: React.MouseEvent<HTMLElement>) => {\n if (event.target !== event.currentTarget) return;\n if (!closesOnPress) {\n event.preventDefault();\n return;\n }\n const focused = getFocusedElement();\n pressFocusRef.current = focused && surfaceRef.current?.contains(focused) ? focused : null;\n },\n [closesOnPress, surfaceRef],\n );\n\n const afterOutsidePress = React.useCallback(() => {\n const element = pressFocusRef.current;\n pressFocusRef.current = null;\n if (!element) return;\n // A close requested from the click is committed first (React flushes the update in a\n // microtask queued before this one), so a closed surface no longer contains the element.\n queueMicrotask(() => {\n if (getFocusedElement() !== null || !surfaceRef.current?.contains(element)) return;\n focusElement(element, { preventScroll: true });\n });\n }, [surfaceRef]);\n\n return { onMouseDown, afterOutsidePress };\n}\n\n/** Whether `value` is a DOM event (duck-typed, so an event from another window counts too). */\nfunction isDomEvent(value: unknown): value is Event {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Partial<Event>).type === 'string' &&\n typeof (value as Partial<Event>).stopPropagation === 'function' &&\n !('nativeEvent' in value)\n );\n}\n\n/**\n * The DOM event behind a part's click handler call: a React event's `nativeEvent`, or a DOM event\n * passed as is. A render-prop child that calls the handler without its event (or with another\n * value) gets a new `click` event, so `details.event` is always an event.\n */\nexport function getNativeEvent(value: unknown): Event {\n const native =\n typeof value === 'object' && value !== null\n ? (value as { nativeEvent?: unknown }).nativeEvent\n : undefined;\n if (isDomEvent(native)) return native;\n if (isDomEvent(value)) return value;\n return new Event('click');\n}\n\n/** Returned by {@link useModalTrigger}. */\nexport interface ModalTrigger {\n /**\n * Callback ref for the element a trigger renders: the consumer's child, or the wrapper `<span>`\n * of `asChild={false}` and of the automatic fallback for a child that does not forward its ref.\n * Every trigger of the root attaches it (a root may have several). It returns a React 19 cleanup\n * that forgets that one element, so a trigger that unmounts never unregisters another. Stable.\n */\n attach: React.RefCallback<HTMLElement>;\n /**\n * Records the trigger that is opening the modal, for the open session that follows (anything that\n * is not an element is ignored). Focus returns to that trigger, not to another one of the same\n * root. Triggers call it through {@link useModalTriggerPart}.\n *\n * An activation the modal did not open for by the end of the task (a click that the parent of a\n * controlled modal rejected) is dropped, so it does not decide where focus returns after a later\n * open that no trigger started. React commits an accepted open within the same task.\n */\n activate: (target: unknown) => void;\n /**\n * Starts the open session: the activated trigger belongs to it until {@link endSession}.\n * {@link useModalTriggerSession} calls it when the modal opens.\n */\n startSession: () => void;\n /**\n * Ends the open session: forgets the activated trigger, so it does not decide where focus\n * returns after a later open that no trigger started. {@link useModalTriggerSession} calls it\n * when the modal closes.\n */\n endSession: () => void;\n /**\n * The focus-restore target, for the modal layer's `triggerRef`. Its `current` is resolved when it\n * is read (when the modal opens, and again on close if the opener captured then cannot take\n * focus any more):\n *\n * 1. `null` while an element other than `<body>` has focus: that element opened the modal (the\n * clicked trigger, the button inside a trigger's wrapper span, or the parent's own button of\n * a controlled modal), and the restore captures it. A trigger element itself with focus (a\n * `tabIndex={-1}` wrapper span that a press focused, as Safari does for a click on the button\n * inside it) resolves like any trigger instead.\n * 2. Otherwise (Safari does not focus a clicked button; a modal opened from code), the trigger\n * activated in this open session while it is still in the document.\n * 3. Otherwise the first mounted trigger that can take focus.\n *\n * A trigger resolves with `getTriggerFocusTarget`, the rule of every trigger's focus return: the\n * element that carries the state ARIA (the button inside a wrapper span, the span when you made\n * it the trigger), else the first tabbable element inside it, else itself when it can take\n * focus, else `null`. Read-only.\n */\n focusRef: React.RefObject<HTMLElement | null>;\n}\n\n/** A trigger for components rendered outside their root (C-CONTEXT inert fallback). */\nexport const inertModalTrigger: ModalTrigger = {\n attach: () => undefined,\n activate: () => {},\n startSession: () => {},\n endSession: () => {},\n focusRef: { current: null },\n};\n\nfunction isElementTarget(target: unknown): target is HTMLElement {\n return typeof target === 'object' && target !== null && (target as Partial<Node>).nodeType === 1;\n}\n\n/** The element that has focus, or `null` when focus is on `<body>` (or nowhere). */\nfunction getFocusedElement(): HTMLElement | null {\n if (typeof document === 'undefined') return null;\n const active = document.activeElement;\n if (!active || active === document.body || active === document.documentElement) return null;\n return active.isConnected ? (active as HTMLElement) : null;\n}\n\nfunction createModalTrigger(): ModalTrigger {\n // Every mounted trigger element, in the order they attached.\n const attached = new Set<HTMLElement>();\n // The trigger clicked in the current open session (or in the task that is opening it);\n // forgotten when the modal closes, when the element detaches, or when no open followed the click.\n let activated: HTMLElement | null = null;\n // Whether an open session is running (between startSession and endSession).\n let sessionOpen = false;\n return {\n attach: (element) => {\n // Detaching runs the cleanup below (React 19 and useMergedRefs call it instead of passing\n // `null`), which knows which element leaves.\n if (!element) return undefined;\n attached.add(element);\n return () => {\n attached.delete(element);\n if (activated === element) activated = null;\n };\n },\n activate: (target) => {\n if (!isElementTarget(target)) return;\n activated = target;\n if (sessionOpen) return;\n // An accepted open commits before the next task starts; a rejected click leaves the modal\n // closed, and its activation must not outlive the task.\n setTimeout(() => {\n if (!sessionOpen && activated === target) activated = null;\n }, 0);\n },\n startSession: () => {\n sessionOpen = true;\n },\n endSession: () => {\n sessionOpen = false;\n activated = null;\n },\n focusRef: {\n get current() {\n // A focused element is the opener: the restore captures it (see ModalTrigger.focusRef),\n // unless it is a trigger element, which resolves like any trigger.\n const focused = getFocusedElement();\n if (focused) return attached.has(focused) ? getTriggerFocusTarget(focused) : null;\n // The trigger that opened the modal decides, also when it cannot take focus any more.\n if (activated?.isConnected) return getTriggerFocusTarget(activated);\n for (const element of attached) {\n if (!element.isConnected) continue;\n const target = getTriggerFocusTarget(element);\n if (target) return target;\n }\n return null;\n },\n },\n };\n}\n\n/**\n * The triggers of a modal root (`Dialog`, `Drawer`), overlays#9. Each `Dialog.Trigger`/\n * `Drawer.Trigger` attaches its element and activates it from its click handler through\n * {@link useModalTriggerPart}; the root passes `focusRef` to `useModalLayer` as its\n * `triggerRef` and scopes the activation to one open session with {@link useModalTriggerSession}.\n * Focus returns to the element that had focus when the modal opened; when nothing had focus, to\n * the trigger that opened it, else to the first mounted trigger. For a wrapper `<span>`, the\n * restore target is the element inside it that carries the state ARIA. Resolving when the ref is\n * read, not when it attaches, keeps a trigger that was disabled at mount (or whose content\n * changed) a valid target.\n */\nexport function useModalTrigger(): ModalTrigger {\n const [trigger] = React.useState(createModalTrigger);\n return trigger;\n}\n\n/** Returned by {@link useModalTriggerElement}. */\ninterface ModalTriggerElement {\n /**\n * Callback ref for the element one trigger renders (merge it with the consumer's ref): registers\n * it with the root's triggers and remembers it for `activate`. Stable.\n */\n attach: React.RefCallback<HTMLElement>;\n /**\n * Records this trigger as the one opening the modal: call it from the click handler, before\n * opening, with whatever the handler received. The element `attach` received wins, else the\n * event's `currentTarget`, so a render-prop child that calls `onClick()` without the event (or\n * with another value) is still recorded. Stable.\n */\n activate: (event?: unknown) => void;\n}\n\nfunction createModalTriggerElement(trigger: ModalTrigger): ModalTriggerElement {\n // The element this trigger rendered; a closure variable, not a React ref, so the click handler\n // that reads it can be passed around during render (C-HOOKS).\n let element: HTMLElement | null = null;\n return {\n attach: (node) => {\n if (!node) return undefined;\n element = node;\n const detach = trigger.attach(node);\n return () => {\n if (element === node) element = null;\n if (typeof detach === 'function') detach();\n };\n },\n activate: (event) => {\n const currentTarget =\n typeof event === 'object' && event !== null\n ? (event as { currentTarget?: unknown }).currentTarget\n : undefined;\n trigger.activate(element ?? currentTarget);\n },\n };\n}\n\n/**\n * One `Dialog.Trigger`/`Drawer.Trigger` of a modal root (overlays#9): attach `attach` to the\n * element the trigger renders and call `activate` from its click handler.\n */\nfunction useModalTriggerElement(trigger: ModalTrigger): ModalTriggerElement {\n return React.useMemo(() => createModalTriggerElement(trigger), [trigger]);\n}\n\n/** The props of a trigger or close part (`Dialog.Trigger`, `Drawer.Close`, …). */\nexport interface ModalPartProps<RenderProps> extends Omit<\n React.HTMLAttributes<HTMLElement>,\n 'children'\n> {\n /** A single element that receives the part's props, or a function that receives them. */\n children: React.ReactNode | ((props: RenderProps) => React.ReactNode);\n /** `false` renders a wrapper `<span>` carrying the click handler. */\n asChild?: boolean;\n /** Ref to the element the part renders. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** What {@link useModalTriggerPart} reads from the modal root. */\nexport interface ModalTriggerState {\n open: boolean;\n /** Asks the root to open (reason `trigger`). */\n requestOpen: ModalRequestOpen;\n trigger: ModalTrigger;\n /** The surface's id for `aria-controls` while the modal is open. */\n controlsId: string | undefined;\n}\n\n/**\n * Renders a `Dialog.Trigger`/`Drawer.Trigger`: its element gets `aria-haspopup=\"dialog\"`,\n * `aria-expanded`, `aria-controls` (while open; these always win over the child's own), a click\n * handler that records the trigger (for the focus return) and asks the root to open (reason\n * `trigger`, with the click event), and a ref that registers it with the root's triggers. On a\n * wrapper span (`asChild={false}`, the automatic fallback), the state ARIA goes to the first\n * element in the tab order inside it (`useTriggerElement`).\n *\n * @param modal The root's state, from its context.\n * @param props The part's props.\n * @param componentName The public name for development warnings, e.g. `'Dialog.Trigger'`.\n */\nexport function useModalTriggerPart<RenderProps>(\n modal: ModalTriggerState,\n { children, asChild, ref, ...rest }: ModalPartProps<RenderProps>,\n componentName: string,\n): React.ReactNode {\n const { open, requestOpen, trigger, controlsId } = modal;\n const { attach, activate } = useModalTriggerElement(trigger);\n const mergedRef = useMergedRefs<HTMLElement>(attach, ref);\n const openModal = React.useCallback(\n (event?: React.MouseEvent<HTMLElement>) => {\n // Focus returns to this trigger, also when the root has several (overlays#9), and also when\n // a render-prop child calls `onClick()` without the event.\n activate(event);\n requestOpen(true, { reason: 'trigger', event: getNativeEvent(event) });\n },\n [activate, requestOpen],\n );\n\n const stateAria = {\n 'aria-haspopup': 'dialog' as const,\n 'aria-expanded': open,\n 'aria-controls': open ? controlsId : undefined,\n };\n const triggerProps = mergeProps({ ...stateAria, onClick: openModal, ref: mergedRef }, rest, {\n oursWin: STATE_ARIA,\n });\n\n return useTriggerElement(children, triggerProps as RenderProps, { componentName, asChild });\n}\n\n/**\n * Renders a `Dialog.Close`/`Drawer.Close`: composes a click handler that asks the root to close\n * (reason `close`, with the click event) onto its element (the child's own `onClick` runs first;\n * `preventDefault()` there keeps the modal open).\n *\n * @param requestOpen The root's request function, from its context.\n * @param props The part's props.\n * @param componentName The public name for development warnings, e.g. `'Dialog.Close'`.\n */\nexport function useModalClosePart<RenderProps>(\n requestOpen: ModalRequestOpen,\n { children, asChild, ref, ...rest }: ModalPartProps<RenderProps>,\n componentName: string,\n): React.ReactNode {\n const mergedRef = useMergedRefs<HTMLElement>(ref);\n const close = React.useCallback(\n (event?: React.MouseEvent<HTMLElement>) =>\n requestOpen(false, { reason: 'close', event: getNativeEvent(event) }),\n [requestOpen],\n );\n const closeProps = mergeProps({ onClick: close, ref: mergedRef }, rest);\n return useTriggerElement(children, closeProps as RenderProps, { componentName, asChild });\n}\n\n/**\n * Scopes a trigger's activation to one open session (overlays#9): when the modal opens, the\n * activated trigger joins the session; when it closes, the trigger is forgotten, so a later open\n * that no trigger started (a controlled modal opened by the parent) does not return focus to it.\n *\n * It updates the session in a layout effect, after the modal's focus restore has used the\n * activation: call it in the root component (whose effects run after its children's) and, when\n * that component also calls `useModalLayer`, after that call (a component's effects run in order).\n */\nexport function useModalTriggerSession(trigger: ModalTrigger, open: boolean): void {\n React.useLayoutEffect(() => {\n if (open) trigger.startSession();\n else trigger.endSession();\n }, [trigger, open]);\n}\n\n/**\n * C-CONTEXT: reads a compound component's context. Outside its root it throws\n * `[WaveUI] <componentName> must be used within <parentName>` in development, and in production\n * logs the same message once per page (`reportMissingContext`) and returns the inert value from\n * `getInert`.\n */\nexport function useRequiredContext<T>(\n context: React.Context<T | null>,\n componentName: string,\n parentName: string,\n getInert: () => T,\n): T {\n const value = React.useContext(context);\n if (value !== null) return value;\n reportMissingContext(componentName, parentName);\n return getInert();\n}\n\n/** What a modal surface (`Dialog.Content`, the Drawer panel) provides to its descendants. */\nexport interface ModalSurfaceContextValue {\n /**\n * Registers the id of a title element (`Dialog.Title`, `Drawer.Title`) for the surface's\n * `aria-labelledby`. Returns the unregister function.\n */\n registerTitle: (id: string) => () => void;\n /**\n * Receives the measured border-box height of the surface's sticky footer (`Dialog.Footer`) in\n * px, or `null` once it unmounts; the surface reserves it as the scroll padding of its body.\n * Absent on a surface without a footer part (the Drawer panel).\n */\n setFooterHeight?: (px: number | null) => void;\n}\n\n/**\n * Provided by every modal surface; `null` outside one. Titles register with it, and\n * `Dialog.Footer` reads it to report its height and to warn when it is rendered outside\n * `Dialog.Content`.\n */\nexport const ModalSurfaceContext = React.createContext<ModalSurfaceContextValue | null>(null);\nModalSurfaceContext.displayName = 'ModalSurfaceContext';\n\nconst inertSurface: ModalSurfaceContextValue = { registerTitle: () => () => {} };\n\n/** Returned by {@link useTitleRegistry}. */\nexport interface TitleRegistry {\n /** The id of the first registered title, for `aria-labelledby`. */\n titleId: string | undefined;\n /** Whether a title is registered right now. Read it in effects and handlers, not during render. */\n hasTitle: () => boolean;\n /** The memoised value for `ModalSurfaceContext.Provider`. */\n context: ModalSurfaceContextValue;\n}\n\n/**\n * The title registry of a modal surface. A title registers its id from its ref callback (when its\n * element attaches), so the surface's `aria-labelledby` follows the title elements that are\n * actually rendered.\n */\nexport function useTitleRegistry(): TitleRegistry {\n const [ids, setIds] = React.useState<readonly string[]>([]);\n const countRef = React.useRef(0);\n\n const registerTitle = React.useCallback((id: string) => {\n countRef.current += 1;\n setIds((current) => [...current, id]);\n let registered = true;\n return () => {\n if (!registered) return;\n registered = false;\n countRef.current -= 1;\n setIds((current) => {\n const index = current.indexOf(id);\n return index === -1 ? current : [...current.slice(0, index), ...current.slice(index + 1)];\n });\n };\n }, []);\n\n const hasTitle = React.useCallback(() => countRef.current > 0, []);\n const context = React.useMemo(() => ({ registerTitle }), [registerTitle]);\n return { titleId: ids[0], hasTitle, context };\n}\n\n/**\n * The `id` and `ref` of a title sub-component (`Dialog.Title`, `Drawer.Title`): the consumer's\n * `id` (or a generated one), registered with the enclosing surface while the element is mounted.\n */\nexport function useModalTitle(\n componentName: string,\n parentName: string,\n idProp: string | undefined,\n ref: React.Ref<HTMLHeadingElement> | undefined,\n): { id: string; ref: React.RefCallback<HTMLHeadingElement> } {\n const { registerTitle } = useRequiredContext(\n ModalSurfaceContext,\n componentName,\n parentName,\n () => inertSurface,\n );\n const generatedId = useId('wave-modal-title');\n const id = idProp ?? generatedId;\n const register = React.useCallback(\n (node: HTMLHeadingElement | null) => (node ? registerTitle(id) : undefined),\n [registerTitle, id],\n );\n const mergedRef = useMergedRefs<HTMLHeadingElement>(ref, register);\n return { id, ref: mergedRef };\n}\n\n/**\n * Development warning (once per component) when an open modal surface has no accessible name:\n * no `title`, no registered title element, no `aria-label` and no `aria-labelledby`.\n *\n * @param surface The open surface element (`null` while closed).\n * @param hasTitle From {@link useTitleRegistry}.\n * @param componentName The public name, e.g. `'Dialog.Content'`.\n * @param titleName The title sub-component to recommend, e.g. `'Dialog.Title'`.\n */\nexport function useUnnamedModalWarning(\n surface: HTMLElement | null,\n hasTitle: () => boolean,\n componentName: string,\n titleName: string,\n): void {\n React.useEffect(() => {\n if (!surface) return;\n if (\n surface.hasAttribute('aria-label') ||\n surface.hasAttribute('aria-labelledby') ||\n hasTitle()\n ) {\n return;\n }\n warnOnce(\n `${componentName}:unnamed`,\n `${componentName} has no accessible name. Pass \\`title\\`, render a ${titleName} inside it, or give it \\`aria-label\\` or \\`aria-labelledby\\`.`,\n );\n }, [surface, hasTitle, componentName, titleName]);\n}\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgBI,EACd,GACA,GACA,GACgD;CAChD,IAAMC,IAAaF,EAAM,OAA2C,KAAA,CAAS,GACvE,CAACG,GAAOC,KAAWC,EAAgBC,GAAMC,KAAe,KAAQ,MACpEC,IAAeC,GAAMP,EAAW,OAAO,CACzC;CAYA,OAAO,CAACC,GAXYH,EAAM,aACvB,GAAM,MAAY;EACjB,EAAW,UAAUU;EACrB,IAAI;GACF,EAAQD,CAAI;EACd,UAAU;GACR,EAAW,UAAU,KAAA;EACvB;CACF,GACA,CAACL,CAAO,CAEK,CAAW;AAC5B;AAYA,SAAgBO,EACd,GACA,GACA,GAC+C;CAC/C,OAAOX,EAAM,aACV,GAAuB,MAAiB;EACvC,QAAQY,GAAR;GACE,KAAK;IACH,EAAY,IAAO;KAAE;KAAQ;IAAM,CAAC;IACpC;GACF,KAAK;IAEH,AADAC,EAAY,IAAO;KAAE;KAAQ;IAAM,CAAC,GACpCC,IAAoB;IACpB;GACF,KAAK;IACH,EACE,GAAGC,EAAc,iBACjB,GAAGA,EAAc,yFACnB;IACA;GACF,SAGE,OAAOlB;EAEX;CACF,GACA;EAACgB;EAAaE;EAAeD;CAAiB,CAChD;AACF;AA4BA,SAAgBE,EACd,GACA,GACe;CAEf,IAAMC,IAAgBjB,EAAM,OAA2B,IAAI;CA2B3D,OAAO;EAAE,aAzBWA,EAAM,aACvB,MAAyC;GACxC,IAAIkB,EAAM,WAAWA,EAAM,eAAe;GAC1C,IAAI,CAACC,GAAe;IAClB,EAAM,eAAe;IACrB;GACF;GACA,IAAMC,IAAUC,EAAkB;GAClC,EAAc,UAAUD,KAAWE,EAAW,SAAS,SAASF,CAAO,IAAIA,IAAU;EACvF,GACA,CAACD,GAAeG,CAAU,CAenB;EAAa,mBAZItB,EAAM,kBAAkB;GAChD,IAAMuB,IAAUN,EAAc;GAE9B,AADA,EAAc,UA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AG;EAACF;EAASN;EAAUhE;EAAewE;CAAS,CAAC;AAClD"}
|
|
@@ -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("../../hooks/useId.cjs"),o=require("../../hooks/useMergedRefs.cjs"),s=require("../../hooks/useIsClient.cjs"),c=require("../portal/Portal.cjs"),l=require("../button/Button.cjs"),ee=require("../../lib/icons.cjs"),te=require("../../hooks/useModalLayer.cjs"),u=require("./Dialog.shared.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=d.createContext(null);p.displayName=`DrawerContext`;var m={open:!1,requestOpen:()=>{},trigger:u.inertModalTrigger,panelId:``,inPanel:!1};function h(e){return u.useRequiredContext(p,e,`Drawer`,()=>m)}var g={start:`start-0 border-e`,end:`end-0 border-s`,left:`left-0 border-r`,right:`right-0 border-l`},_=`Drawer.Trigger:nested`,v="Drawer.Trigger must be a direct child of Drawer (a Fragment is fine). Inside another element or a component it is rendered as panel content, which exists only while the drawer is open, so it cannot open the drawer. Make it a direct child, put wrappers such as a Tooltip inside the trigger, or control the Drawer with `open`/`onOpenChange` and open it from your own button.",y=`Drawer:unreachable`,b="Drawer has no way to open: a second after mounting it is still uncontrolled (no `open` prop), closed, and has no Drawer.Trigger as a direct child (or in a Fragment there). A Drawer.Trigger rendered by a component or nested in an element is panel content, which exists only while the drawer is open. Make the trigger a direct child of Drawer, or control the Drawer with `open`/`onOpenChange`.",x=1e3,S=e=>{let{open:t,requestOpen:n,trigger:i,panelId:a,inPanel:o}=h(`Drawer.Trigger`);return d.useEffect(()=>{o&&r.warnOnce(_,v)},[o]),u.useModalTriggerPart({open:t,requestOpen:n,trigger:i,controlsId:a},e,`Drawer.Trigger`)};S.displayName=`DrawerTrigger`;var C=e=>{let{requestOpen:t}=h(`Drawer.Close`);return u.useModalClosePart(t,e,`Drawer.Close`)};C.displayName=`DrawerClose`;var w=({id:e,className:n,children:r,ref:i,...a})=>{let{id:o,ref:s}=u.useModalTitle(`Drawer.Title`,`Drawer`,e,i);return(0,f.jsx)(`h2`,{...a,id:o,ref:s,className:t.cn(`text-subtitle-1 font-semibold text-foreground`,n),children:r})};w.displayName=`DrawerTitle`;var T=32;function E(e){let t=(e,r,i)=>{if(i>T||typeof e!=`object`||!e)return!1;if(Array.isArray(e))return e.some(e=>t(e,r,i));if(!d.isValidElement(e))return!1;let a=n.getElementType(e,{suspend:!1});if(a===S)return r>0;let o=a===d.Fragment;if(typeof a!=`string`&&!o)return!1;let{children:s}=e.props;return t(s,o?r:r+1,i+1)};return t(e,0,0)}function D(e){let t=[],r=[];for(let{key:i,node:a}of n.flattenChildren(e)){let e=d.isValidElement(a)?d.cloneElement(a,{key:i}):a;n.isElementOfType(a,S)?t.push(e):r.push(e)}return{triggers:t,content:r}}var O=({open:e,defaultOpen:n,onOpenChange:m,position:h=`end`,title:S,closeLabel:C=`Close`,finalFocusRef:w,children:T,className:O,id:k,ref:A,...j})=>{let[M,N]=u.useModalOpenState(e,n,m),P=s.useIsClient(),F=M&&P,I=u.useModalTrigger(),L=a.useId(`wave-drawer`),R=k??L,z=a.useId(`wave-drawer-title`),B=u.useTitleRegistry(),[V,H]=d.useState(null),U=d.useRef(null),W=d.useCallback(e=>{U.current=e,H(e)},[]),G=o.useMergedRefs(A,W),K=u.useBackdropPress(U,!0),q=u.useModalDismiss(N,`Drawer`,K.afterOutsidePress),ne=te.useModalLayer({open:F,onDismiss:q,refs:[U],container:V,triggerRef:I.focusRef,finalFocusRef:w});u.useModalTriggerSession(I,F),u.useUnnamedModalWarning(F?V:null,B.hasTitle,`Drawer`,`Drawer.Title`);let{triggers:J,content:re}=D(T),Y=d.useRef(!1);d.useEffect(()=>{r.isDev&&!Y.current&&E(T)&&(Y.current=!0,r.warnOnce(_,v))},[T]);let X=e===void 0&&!n&&J.length===0,Z=d.useRef({unreachable:X,children:T});d.useLayoutEffect(()=>{Z.current={unreachable:X,children:T}}),d.useEffect(()=>{if(!r.isDev||!Z.current.unreachable)return;let e=setTimeout(()=>{let e=Z.current;e.unreachable&&!E(e.children)&&r.warnOnce(y,b)},x);return()=>clearTimeout(e)},[]);let Q=d.useMemo(()=>({open:F,requestOpen:N,trigger:I,panelId:R,inPanel:!1}),[F,N,I,R]),ie=d.useMemo(()=>({...Q,inPanel:!0}),[Q]),$=i.slotRendersContent(S);return(0,f.jsxs)(p.Provider,{value:Q,children:[J,F&&(0,f.jsx)(c.Portal,{layerId:ne.layerId,children:(0,f.jsx)(`div`,{className:`fixed inset-0 bg-backdrop`,onMouseDown:K.onMouseDown,children:(0,f.jsx)(`div`,{ref:G,role:`dialog`,id:R,"aria-labelledby":$?z:B.titleId,tabIndex:-1,...j,className:t.cn(`fixed top-0 flex h-full w-80 max-w-full flex-col border-border bg-background text-foreground shadow-64`,g[h],O),children:(0,f.jsx)(p.Provider,{value:ie,children:(0,f.jsxs)(u.ModalSurfaceContext.Provider,{value:B.context,children:[(0,f.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border p-4`,children:[$&&(0,f.jsx)(`h2`,{id:z,className:`text-subtitle-1 font-semibold`,children:S}),(0,f.jsx)(l.Button,{appearance:`subtle`,size:`small`,icon:(0,f.jsx)(ee.DismissIcon,{}),"aria-label":C,onClick:e=>N(!1,{reason:`close-button`,event:e.nativeEvent}),className:`ms-auto text-muted-foreground`})]}),(0,f.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:re})]})})})})})]})};O.displayName=`Drawer`;var k=Object.assign(O,{Trigger:S,Close:C,Title:w});exports.Drawer=k,exports.DrawerClose=C,exports.DrawerTitle=w,exports.DrawerTrigger=S;
|
|
2
|
+
//# sourceMappingURL=Drawer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.cjs","names":["React","inertModalTrigger","useRequiredContext","useModalTriggerPart","useModalClosePart","useModalTitle","cn","getElementType","flattenChildren","isElementOfType","useModalOpenState","useIsClient","useModalTrigger","useId","useTitleRegistry","useMergedRefs","useBackdropPress","useModalDismiss","useModalLayer","isDev","slotRendersContent","Portal","ModalSurfaceContext","Button","DismissIcon","require_runtime","require_cn","require_children","require_dev","require_slot","require_useId","require_useMergedRefs","require_useIsClient","require_Portal","require_Button","require_icons","require_useModalLayer","require_Dialog_shared","react","react_jsx_runtime","DrawerContext","inertDrawerContext","useDrawerContext","componentName","positionClasses","NESTED_TRIGGER_WARNING_KEY","NESTED_TRIGGER_WARNING","UNREACHABLE_WARNING_KEY","UNREACHABLE_WARNING","REACHABILITY_CHECK_DELAY","DrawerTrigger","inPanel","panelId","props","DrawerClose","requestOpen","DrawerTitle","rest","titleId","titleRef","id","ref","className","NESTED_TRIGGER_MAX_DEPTH","hasNestedTrigger","visit","level","node","item","depth","type","isFragment","nested","children","splitChildren","triggers","content","keyed","DrawerRoot","openProp","openState","defaultOpen","onOpenChange","isClient","open","trigger","generatedId","propTitleId","titles","panel","setPanel","panelRef","attachPanel","mergedRef","backdropPress","onDismiss","layer","nestedWarnedRef","unreachable","latestRef","timer","latest","context","panelContext","hasTitle","title","position","closeLabel","event","Drawer"],"sources":["../../../src/components/overlays/Drawer.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, getElementType, isElementOfType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { isDev, warnOnce } from '../../lib/dev';\nimport { DismissIcon } from '../../lib/icons';\nimport { slotRendersContent } from '../../lib/slot';\nimport type { ModalOpenChangeReason, OpenChangeDetails } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useModalLayer } from '../../hooks/useModalLayer';\nimport { Button } from '../button/Button';\nimport { Portal } from '../portal/Portal';\nimport {\n inertModalTrigger,\n ModalSurfaceContext,\n useBackdropPress,\n useModalClosePart,\n useModalDismiss,\n useModalOpenState,\n useModalTitle,\n useModalTrigger,\n useModalTriggerPart,\n useModalTriggerSession,\n useRequiredContext,\n useTitleRegistry,\n useUnnamedModalWarning,\n type ModalRequestOpen,\n type ModalTrigger,\n} from './Dialog.shared';\n\n/**\n * Side of the screen the drawer is attached to. `start`/`end` follow the text direction (in a\n * right-to-left layout `end` is the left edge); `left`/`right` are physical sides.\n */\nexport type DrawerPosition = 'start' | 'end' | 'left' | 'right';\n\n/**\n * Why a {@link Drawer} asks to open or close: `trigger` (`Drawer.Trigger`), `close`\n * (`Drawer.Close`), `close-button` (the built-in Close button), `escape`, `outside-press` (the\n * backdrop). The shared `ModalOpenChangeReason`, as for Dialog.\n */\nexport type DrawerOpenChangeReason = ModalOpenChangeReason;\n\n/** The second argument of a {@link Drawer}'s `onOpenChange`: the reason and the DOM event. */\nexport type DrawerOpenChangeDetails = OpenChangeDetails<DrawerOpenChangeReason>;\n\n/** Properties for the Drawer component. */\nexport interface DrawerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {\n /**\n * Controlled open state of the drawer. The panel renders only in the browser: an open drawer\n * is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Default open state for uncontrolled usage. The panel renders only in the browser: a drawer\n * open by default is closed in the server HTML and opens once it has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Called with the new open state when it changes. `details.reason` tells how — `trigger`,\n * `close` (a `.Close` part), `close-button` (the built-in Close button), `escape` or\n * `outside-press` (the backdrop) — so a controlled drawer can refuse only some ways of closing\n * (for example keep a form with unsaved changes open on `outside-press`); `details.event` is the\n * DOM event behind the request. WaveUI always passes `details`; it is typed optional until 1.0\n * so that code which calls this prop itself keeps compiling.\n *\n * Fires only when the value changes; a controlled drawer stays as it is until the parent updates\n * `open`.\n */\n onOpenChange?: (open: boolean, details?: DrawerOpenChangeDetails) => void;\n /**\n * Side of the screen the drawer is attached to. `start`/`end` follow the text direction;\n * `left`/`right` are physical sides.\n * @default 'end'\n */\n position?: DrawerPosition;\n /**\n * Title displayed in the drawer header; it names the drawer (`aria-labelledby`). Without it,\n * render a `Drawer.Title` or pass `aria-label`/`aria-labelledby`. A title that renders nothing\n * (`''`, `[]`, `true`) counts as none.\n */\n title?: React.ReactNode;\n /**\n * Accessible name of the built-in Close button (an icon-only button). Localize it with the\n * page's language.\n * @default 'Close'\n */\n closeLabel?: string;\n /**\n * Where focus goes when the drawer closes, if it can take focus. Otherwise focus returns to the\n * element that had focus when the drawer opened, then to the trigger, then to an element next to\n * where that opener was.\n */\n finalFocusRef?: React.RefObject<HTMLElement | null>;\n /**\n * The drawer body. `Drawer.Trigger` children placed directly inside the Drawer, or in a Fragment\n * there (`{isMobile && <>…</>}`), render in place (outside the panel); everything else renders in\n * the panel's scrolling body. A `Drawer.Trigger` nested in another element, or rendered by a\n * component, is panel content, so it only exists while the drawer is open (development warnings\n * say so, also when an uncontrolled drawer still has no direct trigger a second after it mounts\n * and therefore cannot open; a controlled drawer whose trigger a component such as a Tooltip\n * wraps warns only once it opens).\n * Put wrappers inside the trigger instead: see `Drawer.Trigger`.\n */\n children: React.ReactNode;\n /** Ref to the drawer panel (`role=\"dialog\"`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Props a `Drawer.Trigger` puts on its element (and passes to a render-prop child). */\nexport interface DrawerTriggerRenderProps extends React.HTMLAttributes<HTMLElement> {\n 'aria-haspopup': 'dialog';\n 'aria-expanded': boolean;\n /** The panel's id, while the drawer is open. */\n 'aria-controls'?: string;\n onClick: React.MouseEventHandler<HTMLElement>;\n /** A callback ref, so the props spread onto any element type. */\n ref: React.RefCallback<HTMLElement>;\n}\n\n/** Properties for the DrawerTrigger sub-component. */\nexport interface DrawerTriggerProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * The element that opens the drawer. A single element receives the trigger props (merged with its\n * own); a function receives them.\n */\n children: React.ReactNode | ((props: DrawerTriggerRenderProps) => React.ReactNode);\n /**\n * `false` renders a wrapper `<span>` around the children instead of merging the trigger props\n * onto the child. The span carries the click handler; `aria-haspopup`, `aria-expanded` and\n * `aria-controls` go to the first element in the tab order inside it.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span). */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Props a `Drawer.Close` puts on its element (and passes to a render-prop child). */\nexport interface DrawerCloseRenderProps extends React.HTMLAttributes<HTMLElement> {\n onClick: React.MouseEventHandler<HTMLElement>;\n /** A callback ref, so the props spread onto any element type. */\n ref: React.RefCallback<HTMLElement>;\n}\n\n/** Properties for the DrawerClose sub-component. */\nexport interface DrawerCloseProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * The element that closes the drawer. A single element receives an `onClick` composed with its own\n * (its handler runs first; `preventDefault()` keeps the drawer open); a function receives the\n * props.\n */\n children: React.ReactNode | ((props: DrawerCloseRenderProps) => React.ReactNode);\n /** `false` renders a wrapper `<span>` that closes the drawer on click. @default true */\n asChild?: boolean;\n /** Ref to the close element (the child, or the wrapper span). */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Properties for the DrawerTitle sub-component. */\nexport interface DrawerTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /** The title; any content. */\n children: React.ReactNode;\n /** Ref to the heading element. */\n ref?: React.Ref<HTMLHeadingElement>;\n}\n\ninterface DrawerContextValue {\n open: boolean;\n /** Asks the root to open or close, with the reason and event for `onOpenChange`. */\n requestOpen: ModalRequestOpen;\n /** The trigger element (`attach`) and the focus-restore target resolved from it (`focusRef`). */\n trigger: ModalTrigger;\n /** The panel's id (for the trigger's `aria-controls`). */\n panelId: string;\n /** `true` for sub-components rendered inside the panel (a `Drawer.Trigger` there is misplaced). */\n inPanel: boolean;\n}\n\nconst DrawerContext = React.createContext<DrawerContextValue | null>(null);\nDrawerContext.displayName = 'DrawerContext';\n\nconst inertDrawerContext: DrawerContextValue = {\n open: false,\n requestOpen: () => {},\n trigger: inertModalTrigger,\n panelId: '',\n inPanel: false,\n};\n\nfunction useDrawerContext(componentName: string): DrawerContextValue {\n return useRequiredContext(DrawerContext, componentName, 'Drawer', () => inertDrawerContext);\n}\n\n/**\n * The side the panel is pinned to, and a border on its inner edge (the one facing the page): it\n * marks the panel where the shadow cannot, in high contrast (page, backdrop and panel are black)\n * and in forced colors (which drop shadows).\n */\nconst positionClasses: Record<DrawerPosition, string> = {\n start: 'start-0 border-e',\n end: 'end-0 border-s',\n left: 'left-0 border-r', // wave-allow-physical: the consumer asked for the physical left edge\n right: 'right-0 border-l', // wave-allow-physical: the consumer asked for the physical right edge\n};\n\nconst NESTED_TRIGGER_WARNING_KEY = 'Drawer.Trigger:nested';\nconst NESTED_TRIGGER_WARNING =\n 'Drawer.Trigger must be a direct child of Drawer (a Fragment is fine). Inside another element or a component it is rendered as panel content, which exists only while the drawer is open, so it cannot open the drawer. Make it a direct child, put wrappers such as a Tooltip inside the trigger, or control the Drawer with `open`/`onOpenChange` and open it from your own button.';\n\nconst UNREACHABLE_WARNING_KEY = 'Drawer:unreachable';\nconst UNREACHABLE_WARNING =\n 'Drawer has no way to open: a second after mounting it is still uncontrolled (no `open` prop), closed, and has no Drawer.Trigger as a direct child (or in a Fragment there). A Drawer.Trigger rendered by a component or nested in an element is panel content, which exists only while the drawer is open. Make the trigger a direct child of Drawer, or control the Drawer with `open`/`onOpenChange`.';\n\n/**\n * How long after mount (ms) the development check for a drawer without a trigger waits: long\n * enough for a trigger that a conditional Fragment renders once the page knows its layout.\n */\nconst REACHABILITY_CHECK_DELAY = 1000;\n\n/**\n * Opens the drawer. Place it directly inside `Drawer`, or in a Fragment there (not inside a wrapper\n * element or a component of your own): it renders in place, not in the panel; a misplaced one warns\n * in development. A Drawer may have several triggers: focus returns to the one that opened it. Puts\n * `aria-haspopup=\"dialog\"`, `aria-expanded`, `aria-controls` (while open), a click handler and a\n * ref on its single child, or passes them to a render-prop child. A custom child component must\n * forward `ref` and spread its props; one that does not is wrapped in a `<span>` automatically\n * (with a development warning), the span that `asChild={false}` renders. Focus returns to the\n * trigger when the drawer closes. On the span, the state ARIA goes to the first element in the tab\n * order inside it, and focus returns to that element (to the span when you made it the trigger\n * with a `role` such as `button` and `tabIndex={0}`, or when nothing inside it can take focus).\n *\n * A Tooltip (or any other wrapper) goes inside the trigger, not around it. Use a render-prop child\n * so the trigger props land on the button and the Tooltip describes that same button:\n *\n * @example\n * <Drawer title=\"Filters\">\n * <Drawer.Trigger>\n * {(triggerProps) => (\n * <Tooltip content=\"Narrow the list\">\n * <Button {...triggerProps}>Filters</Button>\n * </Tooltip>\n * )}\n * </Drawer.Trigger>\n * <FilterForm />\n * </Drawer>\n */\nexport const DrawerTrigger = (props: DrawerTriggerProps) => {\n const { open, requestOpen, trigger, panelId, inPanel } = useDrawerContext('Drawer.Trigger');\n\n // Rendered inside its own drawer's panel (e.g. by a component): it only exists while open.\n React.useEffect(() => {\n if (inPanel) warnOnce(NESTED_TRIGGER_WARNING_KEY, NESTED_TRIGGER_WARNING);\n }, [inPanel]);\n\n return useModalTriggerPart<DrawerTriggerRenderProps>(\n { open, requestOpen, trigger, controlsId: panelId },\n props,\n 'Drawer.Trigger',\n );\n};\nDrawerTrigger.displayName = 'DrawerTrigger';\n\n/**\n * Closes the drawer: composes a click handler onto its single child (its own `onClick` runs first;\n * calling `preventDefault()` there keeps the drawer open), or passes it to a render-prop child.\n */\nexport const DrawerClose = (props: DrawerCloseProps) => {\n const { requestOpen } = useDrawerContext('Drawer.Close');\n return useModalClosePart<DrawerCloseRenderProps>(requestOpen, props, 'Drawer.Close');\n};\nDrawerClose.displayName = 'DrawerClose';\n\n/**\n * A heading that names the drawer (`aria-labelledby`), for rich titles or custom layouts. Render it\n * inside the Drawer's content (instead of the `title` prop).\n */\nexport const DrawerTitle = ({ id, className, children, ref, ...rest }: DrawerTitleProps) => {\n const { id: titleId, ref: titleRef } = useModalTitle('Drawer.Title', 'Drawer', id, ref);\n return (\n <h2\n {...rest}\n id={titleId}\n ref={titleRef}\n className={cn('text-subtitle-1 font-semibold text-foreground', className)}\n >\n {children}\n </h2>\n );\n};\nDrawerTitle.displayName = 'DrawerTitle';\n\n/** Deepest element level the development check for nested triggers looks at. */\nconst NESTED_TRIGGER_MAX_DEPTH = 32;\n\n/**\n * Development check: whether the Drawer's children hold a `Drawer.Trigger` inside a host element\n * (at any depth, also through Fragments), which would become panel content; a trigger inside\n * Fragments only is direct (see `splitChildren`). Walks the element tree the consumer wrote, not\n * rendered output, so it descends only into host elements (`<div>`, `<span>`, …) and Fragments,\n * which render their `children` as written. A component's\n * output is unknown here — a wrapper that renders its own Drawer around its children, for one —\n * so components are not walked; a trigger rendered by a component is caught when it renders in the\n * open panel, or, while the drawer cannot open, by the unreachable-drawer check.\n */\nfunction hasNestedTrigger(children: React.ReactNode): boolean {\n // `depth` counts host elements only: a Fragment adds no level, as `splitChildren` flattens it.\n const visit = (node: unknown, depth: number, level: number): boolean => {\n if (level > NESTED_TRIGGER_MAX_DEPTH || typeof node !== 'object' || node === null) return false;\n if (Array.isArray(node)) return node.some((item) => visit(item, depth, level));\n if (!React.isValidElement(node)) return false;\n // A part written in a Server Component has a lazy type. The walk runs in effects, outside\n // render: a lazy part that is still loading must not throw its thenable there, so it counts\n // as no trigger (`suspend: false` returns the lazy itself, which matches nothing).\n const type = getElementType(node, { suspend: false });\n if (type === DrawerTrigger) return depth > 0;\n const isFragment = type === React.Fragment;\n if (typeof type !== 'string' && !isFragment) return false;\n const { children: nested } = node.props as { children?: unknown };\n return visit(nested, isFragment ? depth : depth + 1, level + 1);\n };\n return visit(children, 0, 0);\n}\n\n/**\n * Splits the Drawer's children into its direct `Drawer.Trigger` elements and the panel content.\n * Fragments are flattened (recursively), so a `Drawer.Trigger` in a Fragment —\n * `{isMobile && <><Drawer.Trigger>…</Drawer.Trigger><Filters /></>}` — counts as a direct child.\n * Every element keeps the key `flattenChildren` gives it: unique across Fragments and stable when a\n * sibling Fragment toggles, so panel content keeps its state. A trigger is recognised also when it\n * was written in a Server Component (a lazy type).\n */\nfunction splitChildren(children: React.ReactNode): {\n triggers: React.ReactNode[];\n content: React.ReactNode[];\n} {\n const triggers: React.ReactNode[] = [];\n const content: React.ReactNode[] = [];\n for (const { key, node } of flattenChildren(children)) {\n const keyed = React.isValidElement(node) ? React.cloneElement(node, { key }) : node;\n if (isElementOfType(node, DrawerTrigger)) triggers.push(keyed);\n else content.push(keyed);\n }\n return { triggers, content };\n}\n\n// The root of `Drawer` (documented on the export below).\nconst DrawerRoot = ({\n open: openProp,\n defaultOpen,\n onOpenChange,\n position = 'end',\n title,\n closeLabel = 'Close',\n finalFocusRef,\n children,\n className,\n id,\n ref,\n ...rest\n}: DrawerProps) => {\n const [openState, requestOpen] = useModalOpenState(openProp, defaultOpen, onOpenChange);\n // The panel lives in a portal, which renders only in the browser: until then (the server HTML,\n // hydration) the drawer reports itself closed, so the trigger's aria-expanded and aria-controls\n // never describe a panel that is not there.\n const isClient = useIsClient();\n const open = openState && isClient;\n const trigger = useModalTrigger();\n const generatedId = useId('wave-drawer');\n const panelId = id ?? generatedId;\n const propTitleId = useId('wave-drawer-title');\n const titles = useTitleRegistry();\n\n const [panel, setPanel] = React.useState<HTMLDivElement | null>(null);\n const panelRef = React.useRef<HTMLDivElement | null>(null);\n const attachPanel = React.useCallback((node: HTMLDivElement | null) => {\n panelRef.current = node;\n setPanel(node);\n }, []);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, attachPanel);\n\n // Every backdrop press asks the drawer to close.\n const backdropPress = useBackdropPress(panelRef, true);\n const onDismiss = useModalDismiss(requestOpen, 'Drawer', backdropPress.afterOutsidePress);\n const layer = useModalLayer({\n open,\n onDismiss,\n refs: [panelRef],\n container: panel,\n triggerRef: trigger.focusRef,\n finalFocusRef,\n });\n // After useModalLayer's focus restore (effects run in order), start the trigger session, or end\n // it and forget the trigger that opened it.\n useModalTriggerSession(trigger, open);\n useUnnamedModalWarning(open ? panel : null, titles.hasTitle, 'Drawer', 'Drawer.Title');\n\n const { triggers, content } = splitChildren(children);\n\n // A trigger nested in the children is panel content: never rendered while the drawer is closed.\n // The children change on every parent render; once this drawer has warned, it stops walking.\n const nestedWarnedRef = React.useRef(false);\n React.useEffect(() => {\n if (!isDev || nestedWarnedRef.current || !hasNestedTrigger(children)) return;\n nestedWarnedRef.current = true;\n warnOnce(NESTED_TRIGGER_WARNING_KEY, NESTED_TRIGGER_WARNING);\n }, [children]);\n\n // An uncontrolled closed drawer without a direct trigger cannot open (e.g.\n // `<Drawer><FilterTrigger /></Drawer>`, whose trigger is panel content). Checked once, a moment\n // after mount, against the latest render: a trigger that a conditional Fragment adds right after\n // mount (`{isMobile && <>…</>}` with an SSR-safe media query) counts. A trigger nested in an\n // element already has the more specific warning above.\n const unreachable = openProp === undefined && !defaultOpen && triggers.length === 0;\n const latestRef = React.useRef({ unreachable, children });\n React.useLayoutEffect(() => {\n latestRef.current = { unreachable, children };\n });\n React.useEffect(() => {\n if (!isDev || !latestRef.current.unreachable) return;\n const timer = setTimeout(() => {\n const latest = latestRef.current;\n if (latest.unreachable && !hasNestedTrigger(latest.children)) {\n warnOnce(UNREACHABLE_WARNING_KEY, UNREACHABLE_WARNING);\n }\n }, REACHABILITY_CHECK_DELAY);\n return () => clearTimeout(timer);\n }, []);\n\n const context = React.useMemo<DrawerContextValue>(\n () => ({ open, requestOpen, trigger, panelId, inPanel: false }),\n [open, requestOpen, trigger, panelId],\n );\n const panelContext = React.useMemo<DrawerContextValue>(\n () => ({ ...context, inPanel: true }),\n [context],\n );\n\n const hasTitle = slotRendersContent(title);\n\n return (\n <DrawerContext.Provider value={context}>\n {triggers}\n {open && (\n <Portal layerId={layer.layerId}>\n <div className=\"fixed inset-0 bg-backdrop\" onMouseDown={backdropPress.onMouseDown}>\n <div\n ref={mergedRef}\n role=\"dialog\"\n id={panelId}\n aria-labelledby={hasTitle ? propTitleId : titles.titleId}\n tabIndex={-1}\n {...rest}\n className={cn(\n 'fixed top-0 flex h-full w-80 max-w-full flex-col border-border bg-background text-foreground shadow-64',\n positionClasses[position],\n className,\n )}\n >\n <DrawerContext.Provider value={panelContext}>\n <ModalSurfaceContext.Provider value={titles.context}>\n <div className=\"flex items-center justify-between gap-2 border-b border-border p-4\">\n {hasTitle && (\n <h2 id={propTitleId} className=\"text-subtitle-1 font-semibold\">\n {title}\n </h2>\n )}\n <Button\n appearance=\"subtle\"\n size=\"small\"\n icon={<DismissIcon />}\n aria-label={closeLabel}\n onClick={(event) =>\n requestOpen(false, { reason: 'close-button', event: event.nativeEvent })\n }\n className=\"ms-auto text-muted-foreground\"\n />\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto p-4\">{content}</div>\n </ModalSurfaceContext.Provider>\n </DrawerContext.Provider>\n </div>\n </div>\n </Portal>\n )}\n </DrawerContext.Provider>\n );\n};\nDrawerRoot.displayName = 'Drawer';\n\n/**\n * A modal panel attached to a side of the screen (Fluent UI v2 style), rendered in a portal\n * (inheriting the WaveProvider theme) while open.\n *\n * - **Opening**: controlled (`open`), or uncontrolled with a `Drawer.Trigger` placed directly inside\n * the Drawer or in a Fragment there (it renders in place, outside the panel).\n * - **Modal**: focus moves into the panel and Tab stays inside it (toasts included), the rest of the\n * page is `inert` (instead of `aria-modal`), and the page does not scroll.\n * - **Closing**: Escape (only the topmost layer: a popup opened inside closes first), a click on the\n * backdrop (a drag that starts inside does not close it), the Close button and `Drawer.Close`.\n * `onOpenChange` gets the reason as its second argument (`details.reason`), so a controlled\n * drawer can refuse some of them. A backdrop press blurs the focused field before the drawer\n * closes, so a typed value is committed as with the Close button; when a controlled drawer\n * refuses the press, the field gets focus back. Focus returns to the first of these that can\n * take focus: `finalFocusRef`, the element that had focus when the drawer opened, the trigger,\n * an element next to where that opener was.\n * - **Position**: `end` (default) and `start` follow the text direction.\n *\n * The sub-components are also exported under flat names (`DrawerTrigger`, `DrawerClose`,\n * `DrawerTitle`) for React Server Components, which cannot use the dotted form; dotted access\n * (`Drawer.Trigger`) needs a client file.\n *\n * @example\n * <Drawer title=\"Filters\">\n * <Drawer.Trigger><Button>Filters</Button></Drawer.Trigger>\n * <FilterForm />\n * <Drawer.Close><Button appearance=\"primary\">Apply</Button></Drawer.Close>\n * </Drawer>\n */\nexport const Drawer = /* @__PURE__ */ Object.assign(DrawerRoot, {\n Trigger: DrawerTrigger,\n Close: DrawerClose,\n Title: DrawerTitle,\n});\n"],"mappings":"2jBAqLA,IAAMwC,EAAgBxC,EAAM,cAAyC,IAAI,EACzE,EAAc,YAAc,gBAE5B,IAAMyC,EAAyC,CAC7C,KAAM,GACN,gBAAmB,CAAC,EACpB,QAASxC,EAAAA,kBACT,QAAS,GACT,QAAS,EACX,EAEA,SAASyC,EAAiB,EAA2C,CACnE,OAAOxC,EAAAA,mBAAmBsC,EAAeG,EAAe,aAAgBF,CAAkB,CAC5F,CAOA,IAAMG,EAAkD,CACtD,MAAO,mBACP,IAAK,iBACL,KAAM,kBACN,MAAO,kBACT,EAEMC,EAA6B,wBAC7BC,EACJ,uXAEIC,EAA0B,qBAC1BC,EACJ,0YAMIC,EAA2B,IA6BpBC,EAAiB,GAA8B,CAC1D,GAAM,CAAE,OAAM,cAAa,UAAS,UAAS,WAAYR,EAAiB,gBAAgB,EAO1F,OAJAJ,EAAM,cAAgB,CAChBa,GAASvB,EAAA,SAASiB,EAA4BC,CAAsB,CAC1E,EAAG,CAACK,CAAO,CAAC,EAELhD,EAAAA,oBACL,CAAE,OAAM,cAAa,UAAS,WAAYiD,CAAQ,EAClDC,EACA,gBACF,CACF,EACA,EAAc,YAAc,gBAM5B,IAAaC,EAAe,GAA4B,CACtD,GAAM,CAAE,eAAgBZ,EAAiB,cAAc,EACvD,OAAOtC,EAAAA,kBAA0CmD,EAAaF,EAAO,cAAc,CACrF,EACA,EAAY,YAAc,cAM1B,IAAaG,GAAe,CAAE,KAAI,YAAW,WAAU,MAAK,GAAGC,KAA6B,CAC1F,GAAM,CAAE,GAAIC,EAAS,IAAKC,GAAatD,EAAAA,cAAc,eAAgB,SAAUuD,E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A,KAAA,CAACjB,EAAAA,oBAAoB,SAArB,CAA8B,MAAOkE,EAAO,QAA5C,SAAA,EACE,EAAAjD,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,qEAAf,SAAA,CACGiE,IACC,EAAAjE,EAAA,IAAA,CAAC,KAAD,CAAI,GAAIgD,EAAa,UAAU,gCAC5B,SAAAkB,CACC,CAAA,GAEN,EAAAlE,EAAA,IAAA,CAAChB,EAAAA,OAAD,CACE,WAAW,SACX,KAAK,QACL,MAAM,EAAAgB,EAAA,IAAA,CAACf,GAAAA,YAAD,CAAc,CAAA,EACpB,aAAYmF,EACZ,QAAU,GACRpD,EAAY,GAAO,CAAE,OAAQ,eAAgB,MAAOqD,EAAM,WAAY,CAAC,EAEzE,UAAU,+BACX,CAAA,CACE,CACL,CAAA,GAAA,EAAArE,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,qCAAsC,SAAAqC,EAAa,CAAA,CACtC,GACR,CAAA,CACrB,CAAA,CACF,CAAA,CACC,CAAA,CAEY,GAE5B,EACA,EAAW,YAAc,SA+BzB,IAAaiC,EAAyB,OAAO,OAAO/B,EAAY,CAC9D,QAAS5B,EACT,MAAOI,EACP,MAAOE,CACT,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { flattenChildren as t, getElementType as n, isElementOfType as r } from "../../lib/children.mjs";
|
|
4
|
+
import { isDev as i, warnOnce as a } from "../../lib/dev.mjs";
|
|
5
|
+
import { slotRendersContent as o } from "../../lib/slot.mjs";
|
|
6
|
+
import { useId as s } from "../../hooks/useId.mjs";
|
|
7
|
+
import { useMergedRefs as ee } from "../../hooks/useMergedRefs.mjs";
|
|
8
|
+
import { useIsClient as c } from "../../hooks/useIsClient.mjs";
|
|
9
|
+
import { Portal as l } from "../portal/Portal.mjs";
|
|
10
|
+
import { Button as u } from "../button/Button.mjs";
|
|
11
|
+
import { DismissIcon as d } from "../../lib/icons.mjs";
|
|
12
|
+
import { useModalLayer as te } from "../../hooks/useModalLayer.mjs";
|
|
13
|
+
import { ModalSurfaceContext as ne, inertModalTrigger as f, useBackdropPress as p, useModalClosePart as m, useModalDismiss as h, useModalOpenState as re, useModalTitle as g, useModalTrigger as _, useModalTriggerPart as v, useModalTriggerSession as y, useRequiredContext as b, useTitleRegistry as ie, useUnnamedModalWarning as ae } from "./Dialog.shared.mjs";
|
|
14
|
+
import * as x from "react";
|
|
15
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
16
|
+
//#region src/components/overlays/Drawer.tsx
|
|
17
|
+
var w = x.createContext(null);
|
|
18
|
+
w.displayName = "DrawerContext";
|
|
19
|
+
var T = {
|
|
20
|
+
open: !1,
|
|
21
|
+
requestOpen: () => {},
|
|
22
|
+
trigger: f,
|
|
23
|
+
panelId: "",
|
|
24
|
+
inPanel: !1
|
|
25
|
+
};
|
|
26
|
+
function E(e) {
|
|
27
|
+
return b(w, e, "Drawer", () => T);
|
|
28
|
+
}
|
|
29
|
+
var D = {
|
|
30
|
+
start: "start-0 border-e",
|
|
31
|
+
end: "end-0 border-s",
|
|
32
|
+
left: "left-0 border-r",
|
|
33
|
+
right: "right-0 border-l"
|
|
34
|
+
}, O = "Drawer.Trigger:nested", k = "Drawer.Trigger must be a direct child of Drawer (a Fragment is fine). Inside another element or a component it is rendered as panel content, which exists only while the drawer is open, so it cannot open the drawer. Make it a direct child, put wrappers such as a Tooltip inside the trigger, or control the Drawer with `open`/`onOpenChange` and open it from your own button.", oe = "Drawer:unreachable", se = "Drawer has no way to open: a second after mounting it is still uncontrolled (no `open` prop), closed, and has no Drawer.Trigger as a direct child (or in a Fragment there). A Drawer.Trigger rendered by a component or nested in an element is panel content, which exists only while the drawer is open. Make the trigger a direct child of Drawer, or control the Drawer with `open`/`onOpenChange`.", ce = 1e3, A = (e) => {
|
|
35
|
+
let { open: t, requestOpen: n, trigger: r, panelId: i, inPanel: o } = E("Drawer.Trigger");
|
|
36
|
+
return x.useEffect(() => {
|
|
37
|
+
o && a(O, k);
|
|
38
|
+
}, [o]), v({
|
|
39
|
+
open: t,
|
|
40
|
+
requestOpen: n,
|
|
41
|
+
trigger: r,
|
|
42
|
+
controlsId: i
|
|
43
|
+
}, e, "Drawer.Trigger");
|
|
44
|
+
};
|
|
45
|
+
A.displayName = "DrawerTrigger";
|
|
46
|
+
var j = (e) => {
|
|
47
|
+
let { requestOpen: t } = E("Drawer.Close");
|
|
48
|
+
return m(t, e, "Drawer.Close");
|
|
49
|
+
};
|
|
50
|
+
j.displayName = "DrawerClose";
|
|
51
|
+
var M = ({ id: t, className: n, children: r, ref: i, ...a }) => {
|
|
52
|
+
let { id: o, ref: s } = g("Drawer.Title", "Drawer", t, i);
|
|
53
|
+
return /* @__PURE__ */ S("h2", {
|
|
54
|
+
...a,
|
|
55
|
+
id: o,
|
|
56
|
+
ref: s,
|
|
57
|
+
className: e("text-subtitle-1 font-semibold text-foreground", n),
|
|
58
|
+
children: r
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
M.displayName = "DrawerTitle";
|
|
62
|
+
var N = 32;
|
|
63
|
+
function P(e) {
|
|
64
|
+
let t = (e, r, i) => {
|
|
65
|
+
if (i > N || typeof e != "object" || !e) return !1;
|
|
66
|
+
if (Array.isArray(e)) return e.some((e) => t(e, r, i));
|
|
67
|
+
if (!x.isValidElement(e)) return !1;
|
|
68
|
+
let a = n(e, { suspend: !1 });
|
|
69
|
+
if (a === A) return r > 0;
|
|
70
|
+
let o = a === x.Fragment;
|
|
71
|
+
if (typeof a != "string" && !o) return !1;
|
|
72
|
+
let { children: s } = e.props;
|
|
73
|
+
return t(s, o ? r : r + 1, i + 1);
|
|
74
|
+
};
|
|
75
|
+
return t(e, 0, 0);
|
|
76
|
+
}
|
|
77
|
+
function F(e) {
|
|
78
|
+
let n = [], i = [];
|
|
79
|
+
for (let { key: a, node: o } of t(e)) {
|
|
80
|
+
let e = x.isValidElement(o) ? x.cloneElement(o, { key: a }) : o;
|
|
81
|
+
r(o, A) ? n.push(e) : i.push(e);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
triggers: n,
|
|
85
|
+
content: i
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
var I = ({ open: t, defaultOpen: n, onOpenChange: r, position: f = "end", title: m, closeLabel: g = "Close", finalFocusRef: v, children: b, className: T, id: E, ref: A, ...j }) => {
|
|
89
|
+
let [M, N] = re(t, n, r), I = c(), L = M && I, R = _(), z = s("wave-drawer"), B = E ?? z, V = s("wave-drawer-title"), H = ie(), [U, W] = x.useState(null), G = x.useRef(null), le = x.useCallback((e) => {
|
|
90
|
+
G.current = e, W(e);
|
|
91
|
+
}, []), ue = ee(A, le), K = p(G, !0), de = h(N, "Drawer", K.afterOutsidePress), fe = te({
|
|
92
|
+
open: L,
|
|
93
|
+
onDismiss: de,
|
|
94
|
+
refs: [G],
|
|
95
|
+
container: U,
|
|
96
|
+
triggerRef: R.focusRef,
|
|
97
|
+
finalFocusRef: v
|
|
98
|
+
});
|
|
99
|
+
y(R, L), ae(L ? U : null, H.hasTitle, "Drawer", "Drawer.Title");
|
|
100
|
+
let { triggers: q, content: J } = F(b), Y = x.useRef(!1);
|
|
101
|
+
x.useEffect(() => {
|
|
102
|
+
i && !Y.current && P(b) && (Y.current = !0, a(O, k));
|
|
103
|
+
}, [b]);
|
|
104
|
+
let X = t === void 0 && !n && q.length === 0, Z = x.useRef({
|
|
105
|
+
unreachable: X,
|
|
106
|
+
children: b
|
|
107
|
+
});
|
|
108
|
+
x.useLayoutEffect(() => {
|
|
109
|
+
Z.current = {
|
|
110
|
+
unreachable: X,
|
|
111
|
+
children: b
|
|
112
|
+
};
|
|
113
|
+
}), x.useEffect(() => {
|
|
114
|
+
if (!i || !Z.current.unreachable) return;
|
|
115
|
+
let e = setTimeout(() => {
|
|
116
|
+
let e = Z.current;
|
|
117
|
+
e.unreachable && !P(e.children) && a(oe, se);
|
|
118
|
+
}, ce);
|
|
119
|
+
return () => clearTimeout(e);
|
|
120
|
+
}, []);
|
|
121
|
+
let Q = x.useMemo(() => ({
|
|
122
|
+
open: L,
|
|
123
|
+
requestOpen: N,
|
|
124
|
+
trigger: R,
|
|
125
|
+
panelId: B,
|
|
126
|
+
inPanel: !1
|
|
127
|
+
}), [
|
|
128
|
+
L,
|
|
129
|
+
N,
|
|
130
|
+
R,
|
|
131
|
+
B
|
|
132
|
+
]), pe = x.useMemo(() => ({
|
|
133
|
+
...Q,
|
|
134
|
+
inPanel: !0
|
|
135
|
+
}), [Q]), $ = o(m);
|
|
136
|
+
return /* @__PURE__ */ C(w.Provider, {
|
|
137
|
+
value: Q,
|
|
138
|
+
children: [q, L && /* @__PURE__ */ S(l, {
|
|
139
|
+
layerId: fe.layerId,
|
|
140
|
+
children: /* @__PURE__ */ S("div", {
|
|
141
|
+
className: "fixed inset-0 bg-backdrop",
|
|
142
|
+
onMouseDown: K.onMouseDown,
|
|
143
|
+
children: /* @__PURE__ */ S("div", {
|
|
144
|
+
ref: ue,
|
|
145
|
+
role: "dialog",
|
|
146
|
+
id: B,
|
|
147
|
+
"aria-labelledby": $ ? V : H.titleId,
|
|
148
|
+
tabIndex: -1,
|
|
149
|
+
...j,
|
|
150
|
+
className: e("fixed top-0 flex h-full w-80 max-w-full flex-col border-border bg-background text-foreground shadow-64", D[f], T),
|
|
151
|
+
children: /* @__PURE__ */ S(w.Provider, {
|
|
152
|
+
value: pe,
|
|
153
|
+
children: /* @__PURE__ */ C(ne.Provider, {
|
|
154
|
+
value: H.context,
|
|
155
|
+
children: [/* @__PURE__ */ C("div", {
|
|
156
|
+
className: "flex items-center justify-between gap-2 border-b border-border p-4",
|
|
157
|
+
children: [$ && /* @__PURE__ */ S("h2", {
|
|
158
|
+
id: V,
|
|
159
|
+
className: "text-subtitle-1 font-semibold",
|
|
160
|
+
children: m
|
|
161
|
+
}), /* @__PURE__ */ S(u, {
|
|
162
|
+
appearance: "subtle",
|
|
163
|
+
size: "small",
|
|
164
|
+
icon: /* @__PURE__ */ S(d, {}),
|
|
165
|
+
"aria-label": g,
|
|
166
|
+
onClick: (e) => N(!1, {
|
|
167
|
+
reason: "close-button",
|
|
168
|
+
event: e.nativeEvent
|
|
169
|
+
}),
|
|
170
|
+
className: "ms-auto text-muted-foreground"
|
|
171
|
+
})]
|
|
172
|
+
}), /* @__PURE__ */ S("div", {
|
|
173
|
+
className: "min-h-0 flex-1 overflow-y-auto p-4",
|
|
174
|
+
children: J
|
|
175
|
+
})]
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
})]
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
I.displayName = "Drawer";
|
|
184
|
+
var L = /* @__PURE__ */ Object.assign(I, {
|
|
185
|
+
Trigger: A,
|
|
186
|
+
Close: j,
|
|
187
|
+
Title: M
|
|
188
|
+
});
|
|
189
|
+
//#endregion
|
|
190
|
+
export { L as Drawer, j as DrawerClose, M as DrawerTitle, A as DrawerTrigger };
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=Drawer.mjs.map
|