@mortenbrudvik/waveui 0.4.0 → 0.8.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 +1484 -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 +51 -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 +57 -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 +55 -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 +38 -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 +46 -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 +67 -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 +68 -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 +64 -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 +126 -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 +162 -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 +135 -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 +33 -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 +29 -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 +53 -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 +33 -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 +105 -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 +382 -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 +50 -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 +72 -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 +152 -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 +202 -0
- package/dist/components/feedback/MessageBar.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.parts.cjs +2 -0
- package/dist/components/feedback/MessageBar.parts.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.parts.mjs +84 -0
- package/dist/components/feedback/MessageBar.parts.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.cjs +2 -0
- package/dist/components/feedback/MessageBar.reflow.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.reflow.mjs +74 -0
- package/dist/components/feedback/MessageBar.reflow.mjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.cjs +2 -0
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -0
- package/dist/components/feedback/MessageBar.status.mjs +46 -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 +73 -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 +49 -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 +61 -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.context.cjs +2 -0
- package/dist/components/feedback/Toast.context.cjs.map +1 -0
- package/dist/components/feedback/Toast.context.mjs +23 -0
- package/dist/components/feedback/Toast.context.mjs.map +1 -0
- package/dist/components/feedback/Toast.mjs +15 -0
- package/dist/components/feedback/Toast.mjs.map +1 -0
- package/dist/components/feedback/Toast.parts.cjs +2 -0
- package/dist/components/feedback/Toast.parts.cjs.map +1 -0
- package/dist/components/feedback/Toast.parts.mjs +98 -0
- package/dist/components/feedback/Toast.parts.mjs.map +1 -0
- package/dist/components/feedback/Toast.root.cjs +2 -0
- package/dist/components/feedback/Toast.root.cjs.map +1 -0
- package/dist/components/feedback/Toast.root.mjs +109 -0
- package/dist/components/feedback/Toast.root.mjs.map +1 -0
- package/dist/components/feedback/Toaster.cjs +2 -0
- package/dist/components/feedback/Toaster.cjs.map +1 -0
- package/dist/components/feedback/Toaster.mjs +564 -0
- package/dist/components/feedback/Toaster.mjs.map +1 -0
- package/dist/components/input/AlphaSlider.cjs +2 -0
- package/dist/components/input/AlphaSlider.cjs.map +1 -0
- package/dist/components/input/AlphaSlider.mjs +115 -0
- package/dist/components/input/AlphaSlider.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +2 -0
- package/dist/components/input/Checkbox.cjs.map +1 -0
- package/dist/components/input/Checkbox.mjs +97 -0
- package/dist/components/input/Checkbox.mjs.map +1 -0
- package/dist/components/input/ColorArea.cjs +2 -0
- package/dist/components/input/ColorArea.cjs.map +1 -0
- package/dist/components/input/ColorArea.mjs +204 -0
- package/dist/components/input/ColorArea.mjs.map +1 -0
- package/dist/components/input/ColorPicker.cjs +6 -0
- package/dist/components/input/ColorPicker.cjs.map +1 -0
- package/dist/components/input/ColorPicker.mjs +213 -0
- package/dist/components/input/ColorPicker.mjs.map +1 -0
- package/dist/components/input/ColorPicker.parts.cjs +2 -0
- package/dist/components/input/ColorPicker.parts.cjs.map +1 -0
- package/dist/components/input/ColorPicker.parts.mjs +192 -0
- package/dist/components/input/ColorPicker.parts.mjs.map +1 -0
- package/dist/components/input/ColorSlider.cjs +2 -0
- package/dist/components/input/ColorSlider.cjs.map +1 -0
- package/dist/components/input/ColorSlider.mjs +138 -0
- package/dist/components/input/ColorSlider.mjs.map +1 -0
- package/dist/components/input/Combobox.cjs +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 +192 -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 +341 -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 +131 -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 +201 -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 +82 -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 +29 -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 +171 -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 +140 -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 +197 -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 +204 -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 +34 -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 +80 -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 +158 -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 +114 -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 +93 -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 +253 -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 +33 -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 +295 -0
- package/dist/components/input/TimePicker.mjs.map +1 -0
- package/dist/components/input/colorName.cjs +2 -0
- package/dist/components/input/colorName.cjs.map +1 -0
- package/dist/components/input/colorName.mjs +30 -0
- package/dist/components/input/colorName.mjs.map +1 -0
- package/dist/components/input/colorUtils.cjs +2 -0
- package/dist/components/input/colorUtils.cjs.map +1 -0
- package/dist/components/input/colorUtils.mjs +194 -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 +237 -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 +122 -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 +206 -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 +55 -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 +63 -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 +270 -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 +40 -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 +239 -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.context.cjs +2 -0
- package/dist/components/layout/Tree.context.cjs.map +1 -0
- package/dist/components/layout/Tree.context.mjs +33 -0
- package/dist/components/layout/Tree.context.mjs.map +1 -0
- package/dist/components/layout/Tree.core.cjs +2 -0
- package/dist/components/layout/Tree.core.cjs.map +1 -0
- package/dist/components/layout/Tree.core.mjs +416 -0
- package/dist/components/layout/Tree.core.mjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs +2 -0
- package/dist/components/layout/Tree.itemPersonaLayout.cjs.map +1 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs +46 -0
- package/dist/components/layout/Tree.itemPersonaLayout.mjs.map +1 -0
- package/dist/components/layout/Tree.mjs +12 -0
- package/dist/components/layout/Tree.mjs.map +1 -0
- package/dist/components/layout/Tree.selection.cjs +2 -0
- package/dist/components/layout/Tree.selection.cjs.map +1 -0
- package/dist/components/layout/Tree.selection.mjs +73 -0
- package/dist/components/layout/Tree.selection.mjs.map +1 -0
- package/dist/components/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 +145 -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 +60 -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 +133 -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 +47 -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 +232 -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 +309 -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 +111 -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 +52 -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 +291 -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 +118 -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 +205 -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 +181 -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 +193 -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 +367 -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 +185 -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 +161 -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 +46 -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 +52 -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 +490 -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 +100 -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 +39 -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/useMediaQuery.cjs +2 -0
- package/dist/hooks/useMediaQuery.cjs.map +1 -0
- package/dist/hooks/useMediaQuery.mjs +20 -0
- package/dist/hooks/useMediaQuery.mjs.map +1 -0
- package/dist/hooks/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 +10 -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 +11086 -0
- package/dist/index.d.ts +10405 -1757
- package/dist/index.mjs +103 -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/classNames.cjs +2 -0
- package/dist/lib/classNames.cjs.map +1 -0
- package/dist/lib/classNames.mjs +415 -0
- package/dist/lib/classNames.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/color.cjs +2 -0
- package/dist/lib/color.cjs.map +1 -0
- package/dist/lib/color.mjs +86 -0
- package/dist/lib/color.mjs.map +1 -0
- package/dist/lib/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/lib/toaster.cjs +2 -0
- package/dist/lib/toaster.cjs.map +1 -0
- package/dist/lib/toaster.mjs +77 -0
- package/dist/lib/toaster.mjs.map +1 -0
- package/dist/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 @@
|
|
|
1
|
+
{"version":3,"file":"Toaster.mjs","names":["useId","useId$1","React","promoteQueued","active","waiting","toast","toasts","limit","markDismissed","index","id","next","markAllDismissed","findNewestToast","newest","isInToastRegion","viewport","node","getOpenLayers","anchor","layer","isInsideLayerTree","hasAction","dismissButton","getTabbableElements","container","el","resolveLimit","INERT_CONTROLLER","isToastOptions","first","second","MISSING_TOASTER_MESSAGE","useToastController","ToasterContext","reportMissingContext","DEFAULT_TIMEOUT","createToastTimers","timers","pauses","started","inBackground","suspended","sync","timer","canRun","onExpire","syncAll","stop","seq","timeout","reason","paused","value","positionClasses","EDGE_GAP","isOnRightSide","inline","position","rtl","getDirection","getSidePanelOffset","modals","doc","view","width","height","right","top","offset","box","onSide","onEdge","ANNOUNCEMENT_DURATION","LiveMessage","present","setPresent","handle","text","isTitlePart","part","isBodyPart","isFooterPart","INLINE_ELEMENTS","NOT_TEXT_ELEMENTS","NATIVE_NAMED_BY_LABEL","ROLES_NAMED_BY_LABEL","isNamedByLabel","role","isNotRendered","getAccessibleText","root","parts","visit","isRoot","skip","label","separate","child","getChildTexts","composeToastText","title","body","ownStatusTextId","row","titleActions","slot","footer","ToastContainer","entry","presenceRef","usePresence","dismissed","onExited","containerRef","lastElementRef","attach","registerContainer","mergedRef","useMergedRefs","getFocusFallback","titleId","setParts","partsRef","registerPart","item","setToast","toastRef","registerToast","registration","dismiss","useEventCallback","onDismiss","context","titlePart","bodyPart","ownSeverityLabel","getStatusLabel","severityId","registered","status","announce","optionStatus","toastStatus","warnOnce","handleKeyDown","event","isOwnEvent","isEditableTarget","isMounted","joinIds","cn","toasterClassNames","focusRing","presenceProps","StatusText","ToastContext","ToastRoot","Toaster","limitProp","rest","setToasts","announcements","setAnnouncements","current","prev","announcement","settled","shownToasts","prefix","counterRef","viewportRef","viewportRefs","ref","previousFocusRef","dir","useDirection","sideOffset","setSideOffset","update","unsubscribe","subscribeLayers","blurred","handleBlur","handleFocus","dispatchToast","dispatched","t","shown","dismissToast","dismissAllToasts","removeExited","controller","handleOwner","binding","bindToasterHandle","containers","onContainer","from","isLive","previous","candidate","target","getFirstTabbable","previousFocus","reconcileFocus","held","origin","isConnectedAndFocusable","regionPointerOverRef","handlePointerOver","fromRegion","toastsRef","containersRef","hasFocusShortcut","shortcuts","handleShortcut","listener","rememberFocusOrigin","forgetFocusOrigin","to","handleEscape","polite","assertive","message","viewportStyle","style","children","Portal","onFocus","onBlur","onPointerEnter","onPointerLeave","onPointerOver","composeEventHandlers","onKeyDown","className"],"sources":["../../../src/components/feedback/Toaster.tsx"],"sourcesContent":["import * as React from 'react';\nimport { joinIds } from '../../lib/aria';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { toasterClassNames } from '../../lib/classNames';\nimport { reportMissingContext, warnOnce } from '../../lib/dev';\nimport { getDirection } from '../../lib/direction';\nimport { isEditableTarget, isOwnEvent } from '../../lib/events';\nimport { getFirstTabbable, getTabbableElements, isConnectedAndFocusable } from '../../lib/focus';\nimport { getOpenLayers, isInsideLayerTree, subscribeLayers } from '../../lib/layers';\nimport { focusRing } from '../../lib/styles';\nimport { bindToasterHandle, isToastOptions } from '../../lib/toaster';\nimport type { ToasterHandle } from '../../lib/toaster';\nimport type { Status } from '../../lib/types';\nimport { useDirection } from '../../hooks/useDirection';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { usePresence } from '../../hooks/usePresence';\nimport { usePreserveFocus } from '../../hooks/usePreserveFocus';\nimport { Portal } from '../portal/Portal';\nimport { StatusText, getStatusLabel } from './MessageBar.status';\nimport { ToastContext, ToasterContext } from './Toast.context';\nimport type { ToastContextValue, ToastPartRegistration, ToastRegistration } from './Toast.context';\nimport { ToastRoot } from './Toast.root';\n\n/* ------------------------------------------------------------------ */\n/* Types */\n/* ------------------------------------------------------------------ */\n\n/** Options for dispatching a toast notification. */\nexport interface ToastOptions {\n /** Status level controlling the toast color, icon, status text and announcement politeness\n * (`error` is announced assertively, every other status politely).\n * @default 'info'\n */\n status?: Status;\n /** Title text of the toast. */\n title: string;\n /** Optional body text displayed below the title. */\n body?: string;\n /**\n * Auto-dismiss timeout in milliseconds. The countdown starts when the toast is shown (a toast\n * waiting beyond the Toaster's `limit` does not count down) and pauses while the pointer or\n * focus is anywhere in the toast region (a menu or popover opened from a toast included) and\n * while the browser window is in the background (it has lost focus, or the page is not shown, as\n * in a background tab, also when the Toaster mounts there). `0` (or any value that is not a\n * positive finite number) keeps the toast until it is dismissed.\n * @default 5000\n */\n timeout?: number;\n /**\n * Identifier of the toast. `dispatchToast` returns it (a generated one when omitted). Dispatching\n * again with the id of a toast that is shown, or still exiting after its dismissal, replaces or\n * revives that toast (content and timer); with the id of a toast that waits beyond the Toaster's\n * `limit`, it replaces its options and the toast keeps its place in the queue.\n */\n toastId?: string;\n /**\n * Visually hidden status text read before the toast (`'Info:'`, `'Success:'`, `'Warning:'`,\n * `'Error:'` by default). Pass a translation for other languages, or `''` to omit it.\n */\n statusLabel?: string;\n /**\n * Accessible name of the toast's dismiss button. Pass a translation for other languages.\n * @default 'Dismiss'\n */\n dismissLabel?: string;\n}\n\n/** Options of `dispatchToast(content, options)`, the form that shows your own React content. */\nexport interface ToastDispatchOptions {\n /** As `ToastOptions.toastId`: dispatching again with the id of a shown or exiting toast replaces it. */\n toastId?: string;\n /**\n * Auto-dismiss timeout in milliseconds, as `ToastOptions.timeout`. A toast that holds an action\n * (an interactive element besides its Dismiss button) stays until it is dismissed unless you\n * pass one: people using a screen reader, a switch or voice control need time to reach it.\n * @default 5000, or no timeout for a toast with an action\n */\n timeout?: number;\n /**\n * Severity of content that renders no `Toast`: the announcement's politeness (`error` is\n * assertive), its spoken prefix and the container's name. A rendered `Toast` uses its own\n * `status`; a different value passed here warns in development.\n * @default 'info'\n */\n status?: Status;\n /** Visually hidden severity text for content that renders no `Toast` (as `Toast.statusLabel`). */\n statusLabel?: string;\n /**\n * Text announced instead of the toast's title, body and action labels (the severity text still\n * comes first), for a toast whose visible text is no good announcement, such as a progress toast.\n */\n announcement?: string;\n}\n\n/** The toast API returned by {@link useToastController}. */\nexport interface ToastController {\n /**\n * Shows a toast and returns its id. `dispatchToast(content, options?)` shows your content,\n * usually a `<Toast>` with parts; `dispatchToast(options)` builds a toast from text (0.5). A\n * plain object is read as options; anything else (an element, a portal, a string) is content. A\n * toast with the same id is replaced (revived while it exits); beyond the Toaster's `limit` the\n * toast waits in a queue. Fluent's `dispatchToast(content, options)` returns nothing.\n */\n dispatchToast: {\n (content: React.ReactNode, options?: ToastDispatchOptions): string;\n (options: ToastOptions): string;\n };\n /**\n * Dismisses the toast with this id and cancels its timer: a shown toast exits (it stays, inert,\n * until an exit motion of yours ends), a waiting one is removed. Unknown ids are ignored.\n */\n dismissToast: (id: string) => void;\n /**\n * Dismisses every toast and cancels their timers: shown toasts exit (as `dismissToast`), queued\n * ones are removed.\n */\n dismissAllToasts: () => void;\n}\n\n/** What a dispatch stores: the options form, or your content with its options. */\ntype DispatchedToast =\n | { form: 'options'; options: ToastOptions }\n | { form: 'content'; content: React.ReactNode; options: ToastDispatchOptions };\n\ntype ToastEntry = DispatchedToast & {\n id: string;\n /** Increases with every dispatch, so a replaced toast is announced again. */\n seq: number;\n /**\n * Whether the toast is shown (rendered, announced, its timer running) or still waits beyond the\n * Toaster's `limit`. Only {@link promoteQueued} sets it; it never goes back to `false`.\n */\n shown: boolean;\n /**\n * Dismissed: its container exits (not announced, no timer, not counted toward `limit`) and the\n * entry is removed when the exit ends; a dispatch with its id revives it (D29).\n */\n dismissed: boolean;\n};\n\n/**\n * Flags the oldest waiting toasts as shown while fewer than `limit` toasts are shown and not\n * dismissed. Returns `toasts` itself when nothing changes, so the Toaster's render-time update\n * settles.\n */\nfunction promoteQueued(toasts: ToastEntry[], limit: number): ToastEntry[] {\n let active = 0;\n let waiting = false;\n for (const toast of toasts) {\n if (!toast.shown) waiting = true;\n else if (!toast.dismissed) active += 1;\n }\n if (!waiting || active >= limit) return toasts;\n return toasts.map((toast) => {\n if (toast.shown || active >= limit) return toast;\n active += 1;\n return { ...toast, shown: true };\n });\n}\n\n/** Dismisses a shown toast (it exits) and drops a waiting one; `toasts` itself when nothing changes. */\nfunction markDismissed(toasts: ToastEntry[], id: string): ToastEntry[] {\n const index = toasts.findIndex((toast) => toast.id === id);\n if (index === -1) return toasts;\n const toast = toasts[index];\n if (!toast.shown) return [...toasts.slice(0, index), ...toasts.slice(index + 1)];\n if (toast.dismissed) return toasts;\n const next = toasts.slice();\n next[index] = { ...toast, dismissed: true };\n return next;\n}\n\n/** Dismisses every shown toast and drops the waiting ones; `toasts` itself when nothing changes. */\nfunction markAllDismissed(toasts: ToastEntry[]): ToastEntry[] {\n if (toasts.every((toast) => toast.shown && toast.dismissed)) return toasts;\n return toasts\n .filter((toast) => toast.shown)\n .map((toast) => (toast.dismissed ? toast : { ...toast, dismissed: true }));\n}\n\n/** The shown, not dismissed toast dispatched last (the highest `seq`), or `undefined`. */\nfunction findNewestToast(toasts: readonly ToastEntry[]): ToastEntry | undefined {\n let newest: ToastEntry | undefined;\n for (const toast of toasts) {\n if (toast.shown && !toast.dismissed && (!newest || toast.seq > newest.seq)) newest = toast;\n }\n return newest;\n}\n\n/**\n * Whether `node` is in the toast region: inside the viewport, or inside an open dismiss layer\n * anchored inside it (a Menu, Popover or Tooltip opened from a toast, whose portal lives elsewhere\n * in the document).\n */\nfunction isInToastRegion(viewport: HTMLElement, node: Node): boolean {\n if (viewport.contains(node)) return true;\n return getOpenLayers().some((layer) => {\n const anchor = layer.getAnchor();\n return anchor !== null && viewport.contains(anchor) && isInsideLayerTree(layer.id, node);\n });\n}\n\n/** Whether a toast holds an action: an element in its Tab order other than its Dismiss button. */\nfunction hasAction(container: HTMLElement, toast: ToastRegistration | null): boolean {\n const dismissButton = toast?.getDismissButton() ?? null;\n return getTabbableElements(container).some((el) => el !== dismissButton);\n}\n\n/** `limit` as the Toaster applies it: whole toasts, at least 1; `undefined` means no limit. */\nfunction resolveLimit(limit: number | undefined): number {\n if (limit === undefined) return Infinity;\n return limit >= 1 ? Math.floor(limit) : 1;\n}\n\n/* ------------------------------------------------------------------ */\n/* Context */\n/* ------------------------------------------------------------------ */\n\nconst INERT_CONTROLLER: ToastController = {\n dispatchToast: (first: React.ReactNode | ToastOptions, second?: ToastDispatchOptions) =>\n (isToastOptions(first) ? first.toastId : second?.toastId) ?? '',\n dismissToast: () => {},\n dismissAllToasts: () => {},\n};\n\n/** The C-CONTEXT message without the `[WaveUI] ` prefix, which `reportMissingContext` adds. */\nconst MISSING_TOASTER_MESSAGE =\n 'useToastController must be used within <Toaster>. Wrap your app (or the part of it that shows toasts) in <Toaster>: it provides the controller to its children.';\n\n/**\n * Returns the {@link ToastController} of the enclosing `<Toaster>`: `dispatchToast(content,\n * options?)` shows your content (usually a `<Toast>` with parts) and `dispatchToast(options)` a\n * toast built from text; both return the toast's id. `dismissToast(id)` dismisses one toast,\n * `dismissAllToasts()` every toast.\n *\n * Must be called inside `<Toaster>`, which provides the controller to its children — wrap the app\n * (or the part of it that shows toasts) in `<Toaster>`; a sibling `<Toaster />` does not work.\n * Outside a Toaster it throws in development; in production it logs an error (once) and returns a\n * controller that does nothing.\n *\n * @example\n * function SaveButton() {\n * const { dispatchToast } = useToastController();\n * return (\n * <Button\n * onClick={() =>\n * dispatchToast(\n * <Toast status=\"success\">\n * <Toast.Title>Saved</Toast.Title>\n * </Toast>,\n * )\n * }\n * >\n * Save\n * </Button>\n * );\n * }\n * // <Toaster><App /></Toaster>\n */\nexport function useToastController(): ToastController {\n const controller = React.useContext(ToasterContext);\n if (controller) return controller;\n reportMissingContext('useToastController', '<Toaster>', MISSING_TOASTER_MESSAGE);\n return INERT_CONTROLLER;\n}\n\n/* ------------------------------------------------------------------ */\n/* Timers */\n/* ------------------------------------------------------------------ */\n\nconst DEFAULT_TIMEOUT = 5000;\n\ntype PauseReason = 'hover' | 'focus';\n\ninterface RunningTimer {\n handle: ReturnType<typeof setTimeout> | null;\n remaining: number;\n startedAt: number;\n}\n\n/**\n * Auto-dismiss timers of one Toaster. A timer runs only while neither the pointer nor focus is in\n * the toast region (D14), the window is in the foreground and the Toaster is mounted; otherwise it\n * is suspended and keeps its remaining time. Every method is called from event handlers or\n * effects, never during render.\n */\ninterface ToastTimers {\n /**\n * Starts the timer of the shown toast `id` for its dispatch `seq`, once: a call with the `seq`\n * already started does nothing, a new `seq` (the toast was replaced) restarts it. A timeout that\n * is not a positive finite number means none. A toast replaced while the region is paused stays\n * paused.\n */\n start(id: string, seq: number, timeout: number): void;\n /** Cancels the timer of `id`. */\n remove(id: string): void;\n /** Cancels every timer; the region's pause is kept. */\n clear(): void;\n /** `true` while the pointer (`'hover'`) or focus (`'focus'`) is in the toast region. */\n setPaused(reason: PauseReason, paused: boolean): void;\n /** Whether the region is paused for `reason`. */\n isPaused(reason: PauseReason): boolean;\n /** `true` while the window has lost focus or the page is not shown (a background tab). */\n setInBackground(inBackground: boolean): void;\n /** `true` while the Toaster is unmounted (including StrictMode's simulated unmount). */\n setSuspended(suspended: boolean): void;\n}\n\nfunction createToastTimers(onExpire: (id: string) => void): ToastTimers {\n const timers = new Map<string, RunningTimer>();\n /** Why the region pauses every timer. */\n const pauses = new Set<PauseReason>();\n /** The dispatch (`seq`) whose timer was started last, per toast. */\n const started = new Map<string, number>();\n let inBackground = false;\n let suspended = false;\n\n const sync = (id: string) => {\n const timer = timers.get(id);\n if (!timer) return;\n const canRun = !suspended && !inBackground && pauses.size === 0;\n if (canRun && timer.handle === null) {\n timer.startedAt = Date.now();\n timer.handle = setTimeout(() => {\n timers.delete(id);\n started.delete(id);\n onExpire(id);\n }, timer.remaining);\n } else if (!canRun && timer.handle !== null) {\n clearTimeout(timer.handle);\n timer.handle = null;\n timer.remaining = Math.max(0, timer.remaining - (Date.now() - timer.startedAt));\n }\n };\n const syncAll = () => {\n for (const id of Array.from(timers.keys())) sync(id);\n };\n const stop = (id: string) => {\n const timer = timers.get(id);\n if (timer?.handle != null) clearTimeout(timer.handle);\n timers.delete(id);\n };\n\n return {\n start(id, seq, timeout) {\n if (started.get(id) === seq) return;\n started.set(id, seq);\n stop(id);\n if (!(timeout > 0) || !Number.isFinite(timeout)) return;\n timers.set(id, { handle: null, remaining: timeout, startedAt: 0 });\n sync(id);\n },\n remove(id) {\n stop(id);\n started.delete(id);\n },\n clear() {\n for (const id of Array.from(timers.keys())) stop(id);\n started.clear();\n },\n isPaused(reason) {\n return pauses.has(reason);\n },\n setPaused(reason, paused) {\n if (paused) pauses.add(reason);\n else pauses.delete(reason);\n syncAll();\n },\n setInBackground(value) {\n inBackground = value;\n syncAll();\n },\n setSuspended(value) {\n suspended = value;\n syncAll();\n },\n };\n}\n\n/* ------------------------------------------------------------------ */\n/* Toaster (container) */\n/* ------------------------------------------------------------------ */\n\n/**\n * Corner of the viewport a {@link Toaster} shows its toasts in (`ToasterProps.position`).\n * `start`/`end` follow the writing direction; `left`/`right` are physical.\n */\nexport type ToastPosition =\n | 'top-start'\n | 'top-end'\n | 'bottom-start'\n | 'bottom-end'\n | 'top-right'\n | 'top-left'\n | 'bottom-right'\n | 'bottom-left';\n\n/** Keyboard shortcuts of a Toaster (Fluent's shape). */\nexport interface ToasterShortcuts {\n /**\n * Returns `true` for the key press that moves focus to the most recently dispatched toast, for\n * example `(event) => event.altKey && event.shiftKey && event.code === 'KeyN'`. Use a modifier\n * (or let people change or turn off the shortcut): a single-character shortcut fails WCAG 2.1.4.\n */\n focus?: (event: KeyboardEvent) => boolean;\n}\n\n/** Properties for the Toaster container component. */\nexport interface ToasterProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Corner of the viewport the toasts appear in. `start`/`end` follow the writing direction (the\n * `end` side is the right in LTR and the left in RTL); `left`/`right` are physical.\n * @default 'bottom-end'\n */\n position?: ToastPosition;\n /**\n * Most toasts shown at once. Further toasts wait in a queue (in dispatch order) and appear when\n * a shown toast goes; a queued toast is not announced and its timer does not run until then.\n * Lowering it never hides a toast that is already shown, and a toast dispatched again with its id\n * while it exits comes back at once, even when `limit` toasts are already shown. A value below 1\n * counts as 1 (development warning); `Infinity` means no limit.\n * @default Infinity\n */\n limit?: number;\n /** Keyboard shortcuts; Escape, Delete and Backspace need none (see the component docs). */\n shortcuts?: ToasterShortcuts;\n /**\n * Binds this Toaster to a handle from `createToaster()`: toasts dispatched through the handle\n * render here. A handle binds one Toaster: a second Toaster given a bound handle does not bind\n * (development warning), and does not take the handle over when the first unmounts; the handle\n * queues again until a Toaster binds it.\n */\n toaster?: ToasterHandle;\n /** Ref to the toast region (the portaled `<div role=\"region\">`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Corner placement. The margin on the toasts' side is `--wave-toaster-offset`, which the Toaster\n * sets while a modal panel covers that side (see {@link getSidePanelOffset}); unset, it is `0`.\n */\nconst positionClasses: Record<ToastPosition, string> = {\n 'top-start': 'top-4 start-4 ms-(--wave-toaster-offset)',\n 'top-end': 'top-4 end-4 me-(--wave-toaster-offset)',\n 'bottom-start': 'bottom-4 start-4 ms-(--wave-toaster-offset)',\n 'bottom-end': 'bottom-4 end-4 me-(--wave-toaster-offset)',\n 'top-right': 'top-4 right-4 mr-(--wave-toaster-offset)', // wave-allow-physical: explicit physical position value\n 'top-left': 'top-4 left-4 ml-(--wave-toaster-offset)', // wave-allow-physical: explicit physical position value\n 'bottom-right': 'bottom-4 right-4 mr-(--wave-toaster-offset)', // wave-allow-physical: explicit physical position value\n 'bottom-left': 'bottom-4 left-4 ml-(--wave-toaster-offset)', // wave-allow-physical: explicit physical position value\n};\n\n/** The toasts' distance from the window edges (`*-4`), also the tolerance for \"at the edge\". */\nconst EDGE_GAP = 16;\n\n/** Whether the toasts sit at the right edge of the window (`end` is the right in LTR). */\nfunction isOnRightSide(position: ToastPosition, viewport: HTMLElement): boolean {\n const inline = position.slice(position.indexOf('-') + 1);\n if (inline === 'right' || inline === 'left') return inline === 'right';\n const rtl = getDirection(viewport) === 'rtl';\n return inline === 'end' ? !rtl : rtl;\n}\n\n/**\n * How far the toasts move away from their side while an open modal surface (a Drawer panel) covers\n * their corner, so they never hide the panel's controls (WCAG 2.4.11 Focus Not Obscured): the\n * surface's width from that side of the window, which leaves the usual gap between toasts and\n * panel. A surface counts when it reaches the toasts' side and their top or bottom edge (a centered\n * Dialog does not). `0` when no such surface is open, or when the toasts would not fit beside it\n * (a full-width panel on a phone): then they keep their corner.\n */\nfunction getSidePanelOffset(viewport: HTMLElement, position: ToastPosition): number {\n const modals = getOpenLayers().filter((layer) => layer.kind === 'modal');\n if (modals.length === 0) return 0;\n const doc = viewport.ownerDocument;\n const view = doc.defaultView;\n if (!view) return 0;\n // The box fixed elements are placed in: the window without its scrollbars.\n const width = doc.documentElement.clientWidth || view.innerWidth;\n const height = doc.documentElement.clientHeight || view.innerHeight;\n const right = isOnRightSide(position, viewport);\n const top = position.startsWith('top');\n\n let offset = 0;\n for (const layer of modals) {\n for (const el of layer.getElements()) {\n if (!el?.isConnected) continue;\n const box = el.getBoundingClientRect();\n if (box.width <= 0 || box.height <= 0) continue;\n const onSide = right ? box.right >= width - EDGE_GAP : box.left <= EDGE_GAP;\n const onEdge = top ? box.top <= EDGE_GAP : box.bottom >= height - EDGE_GAP;\n if (onSide && onEdge) offset = Math.max(offset, right ? width - box.left : box.right);\n }\n }\n if (offset <= 0 || width - offset < viewport.offsetWidth + 2 * EDGE_GAP) return 0;\n return Math.ceil(offset);\n}\n\n/**\n * How long a toast's text stays in the live region: long enough for screen readers to pick it up\n * (also a polite message queued behind other speech), short enough that someone browsing the\n * Notifications region later meets the text once, in the toast, not a second time in the region.\n */\nconst ANNOUNCEMENT_DURATION = 2000;\n\n/** A toast's message for the live regions, composed by its container after it mounts (D13). */\ninterface Announcement {\n /** The dispatch it belongs to: a replacement (a new `seq`) is announced again. */\n seq: number;\n text: string;\n /** `error` toasts are announced assertively, every other status politely. */\n assertive: boolean;\n}\n\n/**\n * One toast's message in a live region. It is added when the toast is shown (at dispatch, or when\n * a waiting toast appears; a replacement remounts it, so it is read again) and removed after\n * {@link ANNOUNCEMENT_DURATION} or with the toast. Removal is not announced (`aria-relevant` stays\n * at its default, additions and text).\n */\nfunction LiveMessage({ text }: { text: string }) {\n const [present, setPresent] = React.useState(true);\n React.useEffect(() => {\n const handle = setTimeout(() => setPresent(false), ANNOUNCEMENT_DURATION);\n return () => clearTimeout(handle);\n }, []);\n return present ? <div>{text}</div> : null;\n}\nLiveMessage.displayName = 'LiveMessage';\n\ninterface ToastContainerProps {\n entry: ToastEntry;\n timers: ToastTimers;\n onDismiss: (id: string) => void;\n onExited: (id: string) => void;\n getFocusFallback: (from: HTMLElement | null) => HTMLElement | null;\n announce: (id: string, announcement: Announcement) => void;\n registerContainer: (id: string, node: HTMLElement | null) => void;\n}\n\nfunction isTitlePart(\n part: ToastPartRegistration,\n): part is Extract<ToastPartRegistration, { kind: 'title' }> {\n return part.kind === 'title';\n}\n\nfunction isBodyPart(\n part: ToastPartRegistration,\n): part is Extract<ToastPartRegistration, { kind: 'body' }> {\n return part.kind === 'body';\n}\n\nfunction isFooterPart(\n part: ToastPartRegistration,\n): part is Extract<ToastPartRegistration, { kind: 'footer' }> {\n return part.kind === 'footer';\n}\n\n/** Elements whose text runs on without a break; every other element separates its text. */\nconst INLINE_ELEMENTS = new Set([\n 'a',\n 'abbr',\n 'b',\n 'bdi',\n 'bdo',\n 'cite',\n 'code',\n 'data',\n 'dfn',\n 'em',\n 'i',\n 'kbd',\n 'label',\n 'mark',\n 'q',\n 's',\n 'samp',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'sup',\n 'time',\n 'u',\n 'var',\n 'wbr',\n]);\n\n/** Elements browsers never render as text. */\nconst NOT_TEXT_ELEMENTS = new Set(['noscript', 'script', 'style', 'template']);\n\n/** Native elements a screen reader names by their `aria-label` rather than by their content. */\nconst NATIVE_NAMED_BY_LABEL = new Set(['button', 'img', 'input', 'select', 'textarea']);\n\n/** Roles of controls and images, which are named by their `aria-label` rather than by content. */\nconst ROLES_NAMED_BY_LABEL = new Set([\n 'button',\n 'checkbox',\n 'combobox',\n 'img',\n 'link',\n 'option',\n 'radio',\n 'slider',\n 'spinbutton',\n 'switch',\n 'tab',\n 'textbox',\n]);\n\n/**\n * Whether `aria-label` replaces the content of `el` (a control, a link or an image); any other\n * element, such as a labelled toolbar or group, is read through its content.\n */\nfunction isNamedByLabel(el: Element): boolean {\n const role = el.getAttribute('role')?.trim().split(/\\s+/)[0];\n if (role) return ROLES_NAMED_BY_LABEL.has(role) || role.startsWith('menuitem');\n if (el.localName === 'a') return el.hasAttribute('href');\n return NATIVE_NAMED_BY_LABEL.has(el.localName);\n}\n\n/**\n * Whether `el` is left out of the accessible text: the `hidden` attribute, `aria-hidden=\"true\"` and\n * elements that are no text. Text hidden by a style sheet is still read: the spec defines hidden as\n * the attribute and `aria-hidden`, and reading computed styles would make the text depend on CSS.\n */\nfunction isNotRendered(el: Element): boolean {\n return (\n el.getAttribute('aria-hidden') === 'true' ||\n el.hasAttribute('hidden') ||\n NOT_TEXT_ELEMENTS.has(el.localName)\n );\n}\n\n/**\n * The text a screen reader reads for `root`'s content (D13): text nodes, an image's `alt` and the\n * `aria-label` of a control; `aria-hidden=\"true\"` and `hidden` subtrees, elements that are no text\n * and elements `skip` accepts are left out; whitespace is collapsed. Fluent reads the raw text\n * content instead, which includes hidden text and misses `alt` text.\n */\nfunction getAccessibleText(root: Element | null, skip?: (el: Element) => boolean): string {\n if (!root) return '';\n const parts: string[] = [];\n const visit = (node: Node, isRoot: boolean): void => {\n if (node.nodeType === Node.TEXT_NODE) {\n parts.push(node.textContent ?? '');\n return;\n }\n if (node.nodeType !== Node.ELEMENT_NODE) return;\n const el = node as Element;\n if (!isRoot && skip?.(el)) return;\n if (isNotRendered(el)) return;\n const label = el.getAttribute('aria-label');\n if (label && isNamedByLabel(el)) {\n parts.push(` ${label} `);\n return;\n }\n if (el.localName === 'img') {\n parts.push(` ${el.getAttribute('alt') ?? ''} `);\n return;\n }\n const separate = !INLINE_ELEMENTS.has(el.localName);\n if (separate) parts.push(' ');\n for (const child of Array.from(el.childNodes)) visit(child, false);\n if (separate) parts.push(' ');\n };\n visit(root, true);\n return parts.join('').replace(/\\s+/g, ' ').trim();\n}\n\n/**\n * The accessible text of each child of `root` on its own, so adjacent actions that a flex row lays\n * out side by side (two links, two span-rooted buttons) are not read as one word.\n */\nfunction getChildTexts(root: Element | null): string[] {\n if (!root || isNotRendered(root)) return [];\n return Array.from(root.childNodes, (node) => {\n if (node.nodeType === Node.TEXT_NODE) {\n return (node.textContent ?? '').replace(/\\s+/g, ' ').trim();\n }\n return node.nodeType === Node.ELEMENT_NODE ? getAccessibleText(node as Element) : '';\n }).filter(Boolean);\n}\n\n/**\n * A toast's announced text after its severity (D13): the title, the body (its subtitle included),\n * then the labels of its actions (the title's `action` and the footer, never the Dismiss button),\n * each action on its own. Content without a title or body part is read whole, without the severity\n * texts.\n */\nfunction composeToastText(\n container: HTMLElement,\n parts: readonly ToastPartRegistration[],\n toast: ToastRegistration | null,\n ownStatusTextId: string,\n): string {\n const title = parts.find(isTitlePart);\n const body = parts.find(isBodyPart);\n if (!title && !body) {\n const dismissButton = toast?.getDismissButton() ?? null;\n return getAccessibleText(\n container,\n (el) =>\n el === dismissButton ||\n (el.id !== '' && (el.id === ownStatusTextId || el.id === toast?.statusTextId)),\n );\n }\n const label = title?.getLabel() ?? null;\n // The title row without its text: the `action` slot, whose children are the actions.\n const row = title?.getRow() ?? null;\n const titleActions = row\n ? Array.from(row.children)\n .filter((child) => child !== label)\n .flatMap((slot) => getChildTexts(slot))\n : [];\n return [\n getAccessibleText(label),\n getAccessibleText(body?.getElement() ?? null),\n ...titleActions,\n ...parts.filter(isFooterPart).flatMap((footer) => getChildTexts(footer.getElement())),\n ]\n .filter(Boolean)\n .join(' ');\n}\n\n/**\n * One toast of the Toaster (D10): a `role=\"group\"` container, focusable by script (no Tab stop),\n * named by the toast's severity text and title and described by its body while a Toast inside\n * has registered them (so no id reference dangles). It provides the per-toast context, pauses the\n * timers and keeps focus when the toast goes.\n */\nfunction ToastContainer({\n entry,\n timers,\n onDismiss,\n onExited,\n getFocusFallback,\n announce,\n registerContainer,\n}: ToastContainerProps) {\n const { id, dismissed } = entry;\n // Mounted through the presence core (D29): a dismissed toast exits, `inert`, and is removed when\n // its exit ends (at once without motion); dispatching its id again revives it.\n const {\n isMounted,\n ref: presenceRef,\n presenceProps,\n } = usePresence(!dismissed, {\n appear: true,\n onExited: () => onExited(id),\n });\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n // The last element, for the focus fallback, which may run after the container has unmounted.\n const lastElementRef = React.useRef<HTMLDivElement | null>(null);\n const attach = React.useCallback(\n (node: HTMLDivElement | null) => {\n containerRef.current = node;\n if (node) lastElementRef.current = node;\n registerContainer(id, node);\n },\n [id, registerContainer],\n );\n const mergedRef = useMergedRefs<HTMLDivElement>(attach, presenceRef);\n // Focus leaves a dismissed toast in its dismissing commit: `enabled` flipping to `false` moves it\n // in the layout phase, while the inert node is still there; a toast removed with the Toaster\n // moves it after the unmount.\n usePreserveFocus(containerRef, () => getFocusFallback(lastElementRef.current), {\n enabled: !dismissed,\n });\n const titleId = useId('wave-toast-title');\n const ownStatusTextId = useId('wave-toast-status');\n\n // The registrations of the parts and of the Toast inside, whose layout effects run before this\n // component's: in state for the name and description, in refs for reads after mount.\n const [parts, setParts] = React.useState<readonly ToastPartRegistration[]>([]);\n const partsRef = React.useRef<readonly ToastPartRegistration[]>([]);\n const registerPart = React.useCallback((part: ToastPartRegistration) => {\n partsRef.current = [...partsRef.current, part];\n setParts(partsRef.current);\n return () => {\n partsRef.current = partsRef.current.filter((item) => item !== part);\n setParts(partsRef.current);\n };\n }, []);\n const [toast, setToast] = React.useState<ToastRegistration | null>(null);\n const toastRef = React.useRef<ToastRegistration | null>(null);\n const registerToast = React.useCallback((registration: ToastRegistration) => {\n toastRef.current = registration;\n setToast(registration);\n return () => {\n if (toastRef.current !== registration) return;\n toastRef.current = null;\n setToast(null);\n };\n }, []);\n\n // `Toast.Close` and the Dismiss button: the Toast's `onDismiss`, then the dismissal (D9, D11).\n const dismiss = useEventCallback(() => {\n toastRef.current?.onDismiss?.();\n onDismiss(id);\n });\n const context = React.useMemo<ToastContextValue>(\n () => ({ titleId, dismiss, registerPart, registerToast }),\n [titleId, dismiss, registerPart, registerToast],\n );\n\n const titlePart = parts.find(isTitlePart);\n const bodyPart = parts.find(isBodyPart);\n // Content without a Toast (D10): a visually hidden severity text from the dispatch options,\n // first in the container, while no Toast has registered its own.\n const ownSeverityLabel =\n entry.form === 'content' && toast === null\n ? getStatusLabel(entry.options.status ?? 'info', entry.options.statusLabel)\n : '';\n const severityId = toast ? toast.statusTextId : ownSeverityLabel ? ownStatusTextId : undefined;\n // The timer of each dispatch (D12), started once the content has mounted (its registrations ran\n // first): the dispatch's `timeout`, else none for a toast with an action — people using a screen\n // reader, a switch or voice control need time to reach it — else 5000 ms.\n React.useLayoutEffect(() => {\n const node = containerRef.current;\n if (entry.dismissed || !node) return;\n const timeout =\n entry.options.timeout ?? (hasAction(node, toastRef.current) ? 0 : DEFAULT_TIMEOUT);\n timers.start(entry.id, entry.seq, timeout);\n }, [entry, timers]);\n\n // What screen readers hear (D13), once per dispatch after the content has mounted: the severity\n // text of the rendered Toast (else the dispatch options'), then `announcement` or the text the\n // toast renders; `error` is assertive. `toast` re-runs it for a Toast that registers after this\n // commit (content that renders it later); `announce` drops a repeat of the same message.\n React.useLayoutEffect(() => {\n const node = containerRef.current;\n if (entry.dismissed || !node) return;\n const registered = toastRef.current;\n const status = registered?.status ?? entry.options.status ?? 'info';\n const label = registered\n ? registered.statusLabel\n : getStatusLabel(status, entry.options.statusLabel);\n const text =\n entry.form === 'content' && entry.options.announcement !== undefined\n ? entry.options.announcement\n : composeToastText(node, partsRef.current, registered, ownStatusTextId);\n announce(entry.id, {\n seq: entry.seq,\n text: [label, text].filter(Boolean).join(' '),\n assertive: status === 'error',\n });\n }, [entry, announce, ownStatusTextId, toast]);\n\n // A rendered Toast's severity wins over the dispatch options' (D12); an explicit, different\n // `status` in the options warns once. Read from the ref, not the `toast` state, inside the\n // effect: replacing a registered Toast with content that renders none (a replacement by\n // `toastId`) unregisters it by clearing the ref synchronously, while `setToast(null)` only lands\n // on a later render — depending on the state would fire this effect once against the\n // just-unregistered Toast's stale status. `toast` still triggers the effect (without being read\n // directly), so it also re-runs when a Toast registers after this commit (content that renders\n // its Toast later, inside the consumer's own `<Suspense>`) or changes its own `status` without a\n // new dispatch; `entry` alone would never trigger a re-check for either.\n const optionStatus = entry.form === 'content' ? entry.options.status : undefined;\n React.useEffect(() => {\n const toastStatus = toastRef.current?.status;\n if (optionStatus === undefined || toastStatus === undefined || optionStatus === toastStatus) {\n return;\n }\n warnOnce(\n 'Toaster:status-conflict',\n `Toaster: the dispatched Toast has status \"${toastStatus}\" but the dispatch options pass \"${optionStatus}\"; the Toast's status is used. Remove \\`status\\` from the options.`,\n );\n }, [entry, optionStatus, toast]);\n // Delete or Backspace on the container or inside it dismisses the toast (D14; Backspace is the\n // delete key of Mac keyboards), except in an editable field and for a key pressed in a portal\n // opened from the toast (its target is outside the container).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Delete' && event.key !== 'Backspace') return;\n if (event.defaultPrevented || !isOwnEvent(event) || isEditableTarget(event.target)) return;\n event.preventDefault();\n onDismiss(id);\n };\n\n if (!isMounted) return null;\n return (\n <div\n ref={mergedRef}\n role=\"group\"\n tabIndex={-1}\n data-wave-toast=\"\"\n aria-labelledby={joinIds(severityId, titlePart?.id)}\n aria-describedby={bodyPart?.id}\n className={cn(toasterClassNames.toast, 'rounded', focusRing)}\n {...presenceProps}\n onKeyDown={handleKeyDown}\n >\n {ownSeverityLabel ? <StatusText label={ownSeverityLabel} id={ownStatusTextId} /> : null}\n <ToastContext.Provider value={context}>\n {entry.form === 'options' ? (\n <ToastRoot\n status={entry.options.status}\n statusLabel={entry.options.statusLabel}\n title={entry.options.title}\n dismissLabel={entry.options.dismissLabel}\n >\n {entry.options.body}\n </ToastRoot>\n ) : (\n entry.content\n )}\n </ToastContext.Provider>\n </div>\n );\n}\nToastContainer.displayName = 'ToastContainer';\n\n/**\n * Provides {@link useToastController} to its children and shows the dispatched toasts.\n *\n * - **Wrap the app** in `<Toaster>`; components below it call `useToastController()`, and code\n * outside components (a query-cache callback, a server-event handler) dispatches through a\n * handle from `createToaster()` bound with `toaster`, which also runs several Toasters side by\n * side (one handle each).\n * - **Two ways to dispatch:** `dispatchToast(<Toast>…</Toast>)` shows your content, usually a\n * `Toast` with `Toast.Title`, `Toast.Body` and `Toast.Footer`; `dispatchToast({ title, body })`\n * builds a toast from text. Both return the toast's id. Content without a `Toast` takes its\n * severity from the options (`status`, `statusLabel`) and shows no Dismiss button (add a\n * `Toast.Close`).\n * - The toasts render in a portal (the `toast` layer, above dialogs) inside a region labelled\n * \"Notifications\" (override with `aria-label`). The region is allow-listed for modals\n * (`data-wave-focus-trap-allow`): it stays reachable by Tab and exposed to assistive technology\n * while a Dialog or Drawer is open, and clicking a toast never dismisses the overlay below.\n * - Two permanent, visually hidden live regions (polite, and assertive for `error`) announce every\n * toast once per dispatch, read from what it renders after it mounts: the severity text, then\n * the title, the body and the labels of its actions (never the Dismiss button) or, instead of\n * those, the dispatch's `announcement`.\n * The toasts themselves are not live regions. Each message stays in its live region for 2\n * seconds (or until its toast goes), so browsing the region later meets the text only once.\n * - While an open modal panel covers the toasts' corner (a Drawer on the same side), the toasts\n * move beside it, so they never hide its focused controls (WCAG 2.4.11). Without room beside it\n * (a full-width panel on a narrow screen) they keep their corner.\n * - Timers pause while the pointer or focus is anywhere in the toast region, a menu or popover\n * opened from a toast included (someone reading or operating one toast is reading the stack),\n * and while the window is in the background (it has lost focus, or the page is not shown, as in\n * a background tab). When a toast that contains focus goes away, focus moves to the next toast\n * (or the previous one), or back to the element that was focused before focus entered the\n * toasts once no toast is left.\n * - **Keyboard:** `shortcuts.focus` names a key press that moves focus to the newest toast (use a\n * modifier, WCAG 2.1.4); Escape in the toast region dismisses every toast and returns focus to\n * where it was before focus entered the toasts (a tooltip or menu of a toast closes first, and a\n * Dialog below stays open); Delete or Backspace dismisses the focused toast.\n * - Each toast's dismiss button is named \"Dismiss\"; pass `dismissLabel` to `dispatchToast` for\n * other languages.\n * - `limit` caps how many toasts show at once: the others wait in a queue, in dispatch order,\n * unannounced and without a running timer, and appear as shown toasts go.\n * `dismissAllToasts()` removes every toast, shown and queued.\n *\n * @example\n * <Toaster position=\"bottom-end\" limit={3}>\n * <App />\n * </Toaster>\n */\nexport const Toaster = ({\n position = 'bottom-end',\n limit: limitProp,\n shortcuts,\n toaster: handle,\n className,\n style,\n children,\n onFocus,\n onBlur,\n onKeyDown,\n onPointerEnter,\n onPointerLeave,\n onPointerOver,\n ref,\n ...rest\n}: ToasterProps) => {\n const [toasts, setToasts] = React.useState<ToastEntry[]>([]);\n // Each toast's message, written by its container after the toast mounts (a layout effect), so\n // the severity is the rendered Toast's and the text what the toast renders.\n const [announcements, setAnnouncements] = React.useState<ReadonlyMap<string, Announcement>>(\n () => new Map(),\n );\n const announce = React.useCallback((id: string, announcement: Announcement) => {\n setAnnouncements((prev) => {\n const current = prev.get(id);\n if (\n current &&\n current.seq === announcement.seq &&\n current.text === announcement.text &&\n current.assertive === announcement.assertive\n ) {\n return prev;\n }\n const next = new Map(prev);\n next.set(id, announcement);\n return next;\n });\n }, []);\n const limit = resolveLimit(limitProp);\n // Waiting toasts are shown here, during render, with the current limit (adjust state while\n // rendering, C-HOOKS): every path that frees a place or raises the limit promotes them, and a\n // lowered limit never hides a shown toast. `promoteQueued` returns the same array once settled.\n const settled = promoteQueued(toasts, limit);\n if (settled !== toasts) setToasts(settled);\n const shownToasts = settled.filter((toast) => toast.shown);\n\n // Development diagnostics (C-DEV): emitted from an effect, once per page.\n React.useEffect(() => {\n if (limitProp !== undefined && !(limitProp >= 1)) {\n warnOnce(\n 'Toaster:limit',\n `Toaster: \\`limit\\` must be 1 or more (got ${String(limitProp)}); it counts as 1.`,\n );\n }\n }, [limitProp]);\n const prefix = useId('toast');\n const counterRef = React.useRef(0);\n const viewportRef = React.useRef<HTMLDivElement | null>(null);\n const viewportRefs = useMergedRefs(ref, viewportRef);\n const previousFocusRef = React.useRef<HTMLElement | null>(null);\n const dir = useDirection();\n\n // Beside an open modal panel on the toasts' side (a Drawer), not over its controls. Measured when\n // a layer opens or closes (synchronously in its layout effect, before paint), on resize, and\n // after a transition or animation (a panel that slides in reaches its place only then).\n const [sideOffset, setSideOffset] = React.useState(0);\n React.useLayoutEffect(() => {\n const update = () => {\n const viewport = viewportRef.current;\n setSideOffset(viewport ? getSidePanelOffset(viewport, position) : 0);\n };\n update();\n const unsubscribe = subscribeLayers(update);\n window.addEventListener('resize', update);\n document.addEventListener('transitionend', update, true);\n document.addEventListener('animationend', update, true);\n return () => {\n unsubscribe();\n window.removeEventListener('resize', update);\n document.removeEventListener('transitionend', update, true);\n document.removeEventListener('animationend', update, true);\n };\n }, [position, dir]);\n\n const [timers] = React.useState(() =>\n createToastTimers((id) => setToasts((prev) => markDismissed(prev, id))),\n );\n\n // Timers run only while mounted (StrictMode's simulated unmount suspends and resumes them) and\n // pause while the window is in the background: after the window loses focus, and while the page\n // is not shown. The page visibility is read at mount too, so a Toaster that mounts in a\n // background tab waits until the tab is shown. (Focus is not read at mount: `hasFocus()` is also\n // false in an embedded frame nobody clicked yet and in test DOMs.)\n React.useEffect(() => {\n const doc = document;\n let blurred = false;\n const update = () => timers.setInBackground(blurred || doc.visibilityState === 'hidden');\n // Only the window's own blur/focus (element focus events do not bubble to a bubble-phase\n // window listener; anything targeted at a node is ignored).\n const handleBlur = (event: FocusEvent) => {\n if (event.target instanceof Node) return;\n blurred = true;\n update();\n };\n const handleFocus = (event: FocusEvent) => {\n if (event.target instanceof Node) return;\n blurred = false;\n update();\n };\n update();\n timers.setSuspended(false);\n window.addEventListener('blur', handleBlur);\n window.addEventListener('focus', handleFocus);\n doc.addEventListener('visibilitychange', update);\n return () => {\n window.removeEventListener('blur', handleBlur);\n window.removeEventListener('focus', handleFocus);\n doc.removeEventListener('visibilitychange', update);\n timers.setSuspended(true);\n };\n }, [timers]);\n\n // A new toast waits until the render promotes it; a replaced one keeps its place and whether it\n // is shown (a waiting toast keeps waiting with the new content), and an exiting one is revived.\n const dispatchToast = React.useCallback<ToastController['dispatchToast']>(\n (first: React.ReactNode | ToastOptions, second?: ToastDispatchOptions): string => {\n counterRef.current += 1;\n const seq = counterRef.current;\n const dispatched: DispatchedToast = isToastOptions(first)\n ? { form: 'options', options: first }\n : { form: 'content', content: first, options: second ?? {} };\n const id = dispatched.options.toastId ?? `${prefix}-${seq}`;\n setToasts((prev) => {\n const index = prev.findIndex((t) => t.id === id);\n const shown = index === -1 ? false : prev[index].shown;\n const entry: ToastEntry = { ...dispatched, id, seq, shown, dismissed: false };\n if (index === -1) return [...prev, entry];\n const next = prev.slice();\n next[index] = entry;\n return next;\n });\n return id;\n },\n [prefix],\n );\n\n const dismissToast = React.useCallback(\n (id: string) => {\n timers.remove(id);\n setToasts((prev) => markDismissed(prev, id));\n },\n [timers],\n );\n\n const dismissAllToasts = React.useCallback(() => {\n timers.clear();\n setToasts((prev) => markAllDismissed(prev));\n }, [timers]);\n\n // The exit of a dismissed toast ended: remove it and its message (one revived meanwhile stays).\n const removeExited = React.useCallback((id: string) => {\n setToasts((prev) =>\n prev.some((t) => t.id === id && t.dismissed)\n ? prev.filter((t) => !(t.id === id && t.dismissed))\n : prev,\n );\n setAnnouncements((prev) => {\n if (!prev.has(id)) return prev;\n const next = new Map(prev);\n next.delete(id);\n return next;\n });\n }, []);\n\n const controller = React.useMemo<ToastController>(\n () => ({ dispatchToast, dismissToast, dismissAllToasts }),\n [dispatchToast, dismissToast, dismissAllToasts],\n );\n\n // A handle from createToaster() (P3-08, D33): bound in a layout effect, so dispatches that waited\n // in its queue show before the first paint, and unbound on unmount (StrictMode binds again and\n // finds the queue taken). A handle bound to another Toaster stays there.\n const [handleOwner] = React.useState(() => ({}));\n React.useLayoutEffect(() => {\n if (!handle) return undefined;\n const binding = bindToasterHandle(handle, handleOwner, controller);\n if (binding.status === 'bound') return binding.unbind;\n if (binding.status === 'taken') {\n warnOnce(\n 'Toaster:handle-bound',\n 'Toaster: this handle is already bound to another Toaster; a handle binds one Toaster. Create one handle per Toaster.',\n );\n } else {\n warnOnce(\n 'Toaster:handle-unknown',\n 'Toaster: `toaster` is not a handle from createToaster(), so nothing is bound. Pass the value createToaster() returns.',\n );\n }\n return undefined;\n }, [handle, handleOwner, controller]);\n\n // Where focus goes when the focused toast is dismissed (in its dismissing commit) or removed with\n // the Toaster: the next toast that is not exiting, else the previous one — that container itself\n // when focus was on the dismissed container (after Delete or the shortcut), else its first\n // tabbable element — else the element focused before focus entered the toasts. Runs possibly\n // after the whole Toaster is gone: never throws.\n const getFocusFallback = React.useCallback((from: HTMLElement | null): HTMLElement | null => {\n const viewport = viewportRef.current;\n const containers = viewport\n ? Array.from(viewport.children).filter(\n (el): el is HTMLElement =>\n el instanceof HTMLElement && el.hasAttribute('data-wave-toast'),\n )\n : [];\n const onContainer = !!from && from.ownerDocument.activeElement === from;\n const index = from ? containers.indexOf(from) : -1;\n const isLive = (el: HTMLElement) =>\n el !== from && el.isConnected && el.getAttribute('data-presence') !== 'exiting';\n const next = containers.slice(index + 1).find(isLive);\n const previous = index > 0 ? containers.slice(0, index).reverse().find(isLive) : undefined;\n for (const candidate of [next, previous]) {\n if (!candidate) continue;\n const target = onContainer ? candidate : getFirstTabbable(candidate);\n if (target) return target;\n }\n // Focus leaves the toasts here without a blur of the viewport (the focused node is inert or\n // gone), so the element is forgotten as it is used: a toast focused later from nowhere does not\n // send focus back to it.\n const previousFocus = previousFocusRef.current;\n previousFocusRef.current = null;\n return previousFocus?.isConnected ? previousFocus : null;\n }, []);\n\n // Focus can fall to the page body without a blur reaching the viewport: the node that had it\n // (a layer opened from a toast, a button replaced by text) is gone. A move to a real element\n // always sends blur and focus through React, so only a fall to the body is reconciled, whenever\n // the toasts or the layers change: the 'focus' pause ends, and while the region still held it,\n // focus returns to the remembered origin, as it does when a focused toast goes. The origin is\n // forgotten either way.\n const reconcileFocus = useEventCallback(() => {\n const viewport = viewportRef.current;\n if (!viewport) return;\n const doc = viewport.ownerDocument;\n if (doc.activeElement && doc.activeElement !== doc.body) return;\n const held = timers.isPaused('focus');\n timers.setPaused('focus', false);\n const origin = previousFocusRef.current;\n previousFocusRef.current = null;\n if (held && origin && isConnectedAndFocusable(origin)) origin.focus({ preventScroll: true });\n });\n React.useLayoutEffect(() => {\n reconcileFocus();\n }, [settled, reconcileFocus]);\n // A layer's cleanup can notify while its focused node is still connected: look a tick later.\n React.useLayoutEffect(\n () => subscribeLayers(() => queueMicrotask(reconcileFocus)),\n [reconcileFocus],\n );\n\n // The pointer can leave the region without a leave reaching it: when the node under the pointer\n // is removed (a hovered toast dismissed, timed out or pushed out by the limit, a menu item that\n // closed its menu), the browser's next boundary event is a `pointerover` on the element now under\n // the pointer with no related target, from which React synthesises no leave. So the 'hover' pause\n // also ends on any `pointerover` that did not pass through the region in React's tree, which\n // takes in a portal opened from a toast (D14, as the enter and leave handlers do). The DOM and\n // layer check after it (`isInToastRegion`) is defensive: it keeps the pause for a layer anchored\n // in a toast but rendered outside the Toaster's tree. A document listener in the bubble phase, so\n // React's own listeners (on the root and portal containers, below the document) have marked the\n // event first.\n const regionPointerOverRef = React.useRef<Event | null>(null);\n React.useEffect(() => {\n const handlePointerOver = (event: Event) => {\n const fromRegion = regionPointerOverRef.current === event;\n regionPointerOverRef.current = null;\n if (fromRegion || !timers.isPaused('hover')) return;\n const viewport = viewportRef.current;\n if (viewport && event.target instanceof Node && isInToastRegion(viewport, event.target)) {\n return;\n }\n timers.setPaused('hover', false);\n };\n document.addEventListener('pointerover', handlePointerOver);\n return () => document.removeEventListener('pointerover', handlePointerOver);\n }, [timers]);\n\n // The latest entries and every container element, for the shortcut's document listener.\n const toastsRef = React.useRef<ToastEntry[]>(settled);\n React.useLayoutEffect(() => {\n toastsRef.current = settled;\n });\n const containersRef = React.useRef(new Map<string, HTMLElement>());\n const registerContainer = React.useCallback((id: string, node: HTMLElement | null) => {\n if (node) containersRef.current.set(id, node);\n else containersRef.current.delete(id);\n }, []);\n\n // The focus shortcut (D14): a document listener, so the key works wherever focus is. It focuses\n // the container of the newest toast that is shown and not dismissed and remembers where focus\n // was (unless it is already in the toasts).\n const hasFocusShortcut = typeof shortcuts?.focus === 'function';\n const handleShortcut = useEventCallback((event: KeyboardEvent) => {\n if (event.defaultPrevented || event.isComposing || !shortcuts?.focus?.(event)) return;\n const newest = findNewestToast(toastsRef.current);\n const target = newest ? containersRef.current.get(newest.id) : undefined;\n if (!target?.isConnected) return;\n event.preventDefault();\n const viewport = viewportRef.current;\n const active = target.ownerDocument.activeElement;\n if (\n active instanceof HTMLElement &&\n active !== target.ownerDocument.body &&\n !(viewport && isInToastRegion(viewport, active))\n ) {\n previousFocusRef.current = active;\n }\n target.focus({ preventScroll: false });\n });\n React.useEffect(() => {\n if (!hasFocusShortcut) return undefined;\n const listener = (event: KeyboardEvent) => handleShortcut(event);\n document.addEventListener('keydown', listener);\n return () => document.removeEventListener('keydown', listener);\n }, [hasFocusShortcut, handleShortcut]);\n\n // Focus entering the toast region from an element outside it: return there when the focused\n // toast goes and after Escape. Focus arriving with no related target keeps what is remembered\n // (the Toaster's own move to the next toast, the window regaining focus). Moves inside the region\n // — a layer opened from a toast included — change nothing, and an element that cannot take focus\n // (inside a closing, inert surface) is never remembered.\n const rememberFocusOrigin = (event: React.FocusEvent<HTMLDivElement>) => {\n const from = event.relatedTarget;\n if (!(from instanceof HTMLElement) || !isConnectedAndFocusable(from)) return;\n if (isInToastRegion(event.currentTarget, from)) return;\n previousFocusRef.current = from;\n };\n\n // Focus leaving the region for another element or for `<body>` forgets the element, so a toast\n // focused again later from nowhere never sends focus back to something focused long before.\n // Kept: moves inside the region (a layer opened from a toast included), a removed or dismissed\n // toast (its node is gone or inert; the Toaster moves focus itself) and the window losing focus\n // (the element keeps document focus while another window is active).\n const forgetFocusOrigin = (event: React.FocusEvent<HTMLDivElement>) => {\n const viewport = event.currentTarget;\n const to = event.relatedTarget;\n if (to instanceof Node && isInToastRegion(viewport, to)) return;\n // A blur from inside a dismissed (exiting, inert) toast: the Toaster has moved focus itself,\n // or a browser's focus fix-up blurs the inert subtree later.\n if (event.target.closest('[data-wave-toast][data-presence=\"exiting\"]')) return;\n if (to === null) {\n const from = event.target;\n if (!from.isConnected) return;\n const active = from.ownerDocument.activeElement;\n if (active && isInToastRegion(viewport, active)) return;\n }\n previousFocusRef.current = null;\n };\n\n // Escape in the toast region (D14) dismisses every toast and returns focus to where it was\n // before focus entered the toasts. Left alone: a key pressed in a portal opened from a toast\n // (its target is outside the viewport; the portal's own widget handles it) and one that an open\n // Escape-enabled layer anchored in the viewport takes first (a Tooltip on a toast's button, a\n // Menu opened from a toast). Prevented, so the dismiss-layer stack does not route it to a Dialog\n // or Drawer below (the region counts as inside every layer).\n const handleEscape = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== 'Escape' && event.key !== 'Esc') return;\n if (event.defaultPrevented || event.nativeEvent.isComposing || !isOwnEvent(event)) return;\n const viewport = event.currentTarget;\n if (getOpenLayers().some((layer) => layer.escape && viewport.contains(layer.getAnchor()))) {\n return;\n }\n event.preventDefault();\n const origin = previousFocusRef.current;\n previousFocusRef.current = null;\n if (origin?.isConnected) origin.focus({ preventScroll: true });\n dismissAllToasts();\n };\n\n // Each shown toast's message for its first 2 s, while it is not dismissed (a waiting toast is\n // announced when it appears); a replacement is a new dispatch, so it is read again.\n const polite: React.ReactNode[] = [];\n const assertive: React.ReactNode[] = [];\n for (const toast of shownToasts) {\n if (toast.dismissed) continue;\n const announcement = announcements.get(toast.id);\n if (!announcement || announcement.seq !== toast.seq || !announcement.text) continue;\n const message = <LiveMessage key={announcement.seq} text={announcement.text} />;\n (announcement.assertive ? assertive : polite).push(message);\n }\n\n const viewportStyle =\n sideOffset > 0\n ? ({ ...style, '--wave-toaster-offset': `${sideOffset}px` } as React.CSSProperties)\n : style;\n\n return (\n <ToasterContext.Provider value={controller}>\n {children}\n <Portal layer=\"toast\">\n <div\n ref={viewportRefs}\n role=\"region\"\n aria-label=\"Notifications\"\n data-wave-focus-trap-allow=\"\"\n data-position={position}\n {...rest}\n style={viewportStyle}\n onFocus={(event) => {\n // Bookkeeping always runs (a consumer's preventDefault() cannot cancel a focus change).\n // Focus in a portal opened from a toast arrives here too (React bubbles focus events\n // through portals) and counts as focus in the region (D14).\n onFocus?.(event);\n rememberFocusOrigin(event);\n timers.setPaused('focus', true);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n forgetFocusOrigin(event);\n const next = event.relatedTarget;\n if (next instanceof Node && isInToastRegion(event.currentTarget, next)) return;\n timers.setPaused('focus', false);\n }}\n onPointerEnter={(event) => {\n onPointerEnter?.(event);\n timers.setPaused('hover', true);\n }}\n onPointerLeave={(event) => {\n onPointerLeave?.(event);\n timers.setPaused('hover', false);\n }}\n onPointerOver={(event) => {\n // Bookkeeping always runs. A portal opened from a toast counts as the region (D14):\n // React bubbles its pointer events here too.\n onPointerOver?.(event);\n regionPointerOverRef.current = event.nativeEvent;\n }}\n onKeyDown={(event) => composeEventHandlers(onKeyDown, handleEscape)(event)}\n className={cn(\n toasterClassNames.root,\n 'fixed flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2',\n positionClasses[position],\n className,\n )}\n >\n {/* One message per toast for its first 2 s; not atomic, so only the added one is read. */}\n <div role=\"status\" aria-live=\"polite\" aria-atomic=\"false\" className=\"sr-only\">\n {polite}\n </div>\n <div aria-live=\"assertive\" aria-atomic=\"false\" className=\"sr-only\">\n {assertive}\n </div>\n {/* Shown toasts, exiting ones included: getFocusFallback walks the containers in this order. */}\n {shownToasts.map((toast) => (\n <ToastContainer\n key={toast.id}\n entry={toast}\n timers={timers}\n onDismiss={dismissToast}\n onExited={removeExited}\n getFocusFallback={getFocusFallback}\n announce={announce}\n registerContainer={registerContainer}\n />\n ))}\n </div>\n </Portal>\n </ToasterContext.Provider>\n );\n};\nToaster.displayName = 'Toaster';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoJA,SAASG,GAAc,GAAsB,GAA6B;CACxE,IAAIC,IAAS,GACTC,IAAU;CACd,KAAK,IAAMC,KAASC,GAClB,AAAKD,EAAM,QACDA,EAAM,cAAW,KAAU,KADnB,IAAU;CAI9B,OADI,CAACD,KAAWD,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Q,WAAU;MACtD,UAAAC;KACE,CAAA;KAEJvD,EAAY,KAAK,MAChB,kBAAC5D,IAAD;MAEE,OAAOvG;MACC;MACR,WAAWwL;MACX,UAAUE;MACQ;MACR;MACS;KACpB,GARM1L,EAAM,EAQZ,CACF;IACE;;EACC,CAAA,CACe;;AAE7B;AACA,EAAQ,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),ee=require("../../lib/composeEventHandlers.cjs"),n=require("../../lib/classNames.cjs"),r=require("../../lib/color.cjs"),i=require("../../lib/direction.cjs"),a=require("../../hooks/useMergedRefs.cjs"),o=require("../../hooks/useFieldControl.cjs"),s=require("../../hooks/useFormReset.cjs"),c=require("../internal/HiddenInput.cjs"),l=require("./colorUtils.cjs"),u=require("./ColorPicker.parts.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var te={opacity:`Opacity`,transparency:`Transparency`},p=({transparency:e=!1,orientation:p=`horizontal`,value:m,defaultValue:h,onValueChange:g,shape:_,labels:v,disabled:ne=!1,name:y,form:b,required:x,controlRef:S,className:re,style:C,id:w,"aria-label":T,"aria-labelledby":E,"aria-describedby":D,"aria-invalid":O,"aria-required":k,"aria-errormessage":A,"aria-details":j,autoFocus:M,tabIndex:N,onFocus:P,onBlur:F,onKeyDown:I,onKeyUp:L,ref:R,...z})=>{let B=u.useColorPartState({value:m,defaultValue:h,onValueChange:g,disabled:ne}),{picker:V}=B,H=V?.labels.valueText,U={...te,...V&&{opacity:V.labels.opacity,transparency:V.labels.transparency,valueText:H&&(e=>H(e,`alpha`))},...v},W=_??V?.shape??`rounded`,G=p===`vertical`,K=l.displayColor(B.color),q=l.toPercent(K.a),J=e?100-q:q,Y=o.useFieldContext(),{"aria-required":ie,required:ae,...X}=o.useFieldControl({id:w,"aria-label":T??(Y===null&&E===void 0?e?U.transparency:U.opacity:void 0),"aria-labelledby":E,"aria-describedby":D,"aria-invalid":O}),Z=X[`aria-invalid`],oe=Z!==void 0&&Z!==!1&&Z!==`false`,se=x??(k===!0||k===`true`||(Y?.required??!1)),Q=d.useRef(null),ce=a.useMergedRefs(Q,S);s.useFormReset(Q,B.reset,b);let $=t=>{t!==J&&B.setColor({...B.color,a:(e?100-t:t)/100})},le=ee.composeEventHandlers(I,e=>{if(B.disabled||e.nativeEvent.isComposing)return;let t=l.railKeyTarget(e.key,e,i.getDirection(e.currentTarget),J,100);t!==null&&(e.preventDefault(),$(t))}),ue=e=>{B.disabled||$(Math.min(100,Math.max(0,Math.round(Number(e.currentTarget.value)))))},de={...C,"--wave-color-slider-gradient":l.alphaSliderGradient(K,e,p),"--wave-color-slider-position":l.toPosition(J/100),"--wave-color-thumb":r.hsvToHex(K)};return(0,f.jsxs)(`div`,{"data-orientation":p,"data-disabled":B.disabled?``:void 0,className:t.cn(n.alphaSliderClassNames.root,`group/alpha-slider relative flex touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,G?l.RAIL_ROOT_VERTICAL:l.RAIL_ROOT_HORIZONTAL,re),style:de,...z,ref:R,children:[(0,f.jsx)(`div`,{"aria-hidden":`true`,className:t.cn(n.alphaSliderClassNames.rail,`relative overflow-hidden rounded-full bg-[conic-gradient(var(--wave-stroke)_25%,var(--wave-background)_0_50%,var(--wave-stroke)_0_75%,var(--wave-background)_0)] bg-size-[8px_8px] forced-colors:forced-color-adjust-none`,G?l.RAIL_TRACK_VERTICAL:l.RAIL_TRACK_HORIZONTAL,W===`square`&&`rounded-none`),children:(0,f.jsx)(`span`,{className:t.cn(`absolute inset-0`,l.RAIL_GRADIENT)})}),(0,f.jsx)(`input`,{type:`range`,...X,ref:ce,min:0,max:100,step:1,value:J,disabled:B.disabled,dir:G?`ltr`:void 0,"aria-orientation":G?`vertical`:void 0,"aria-valuetext":l.alphaValueText(K,e,U.valueText),"aria-errormessage":oe&&A||void 0,"aria-details":j,autoFocus:M,tabIndex:N,onFocus:P,onBlur:F,onKeyDown:le,onKeyUp:L,onChange:ue,className:t.cn(l.RAIL_INPUT_CLASSES,G?l.RAIL_INPUT_VERTICAL:l.RAIL_INPUT_HORIZONTAL)}),(0,f.jsx)(`span`,{"aria-hidden":`true`,className:G?l.THUMB_TRACK_VERTICAL:l.THUMB_TRACK_HORIZONTAL,children:(0,f.jsx)(`span`,{className:t.cn(n.alphaSliderClassNames.thumb,l.COLOR_THUMB_CLASSES,G?l.THUMB_POSITION_VERTICAL:l.THUMB_POSITION_HORIZONTAL,`group-has-[:focus-visible]/alpha-slider:ring-2 group-has-[:focus-visible]/alpha-slider:ring-background forced-colors:group-has-[:focus-visible]/alpha-slider:ring-[Canvas] group-has-[:focus-visible]/alpha-slider:outline-2 group-has-[:focus-visible]/alpha-slider:outline-offset-2 group-has-[:focus-visible]/alpha-slider:outline-ring forced-colors:group-has-[:focus-visible]/alpha-slider:outline-[Highlight]`)})}),!V&&(0,f.jsx)(c.HiddenInput,{type:`text`,name:y,form:b,disabled:B.disabled,value:r.hsvToHex(B.color),required:se,onInvalid:()=>Q.current?.focus()})]})};p.displayName=`AlphaSlider`,exports.AlphaSlider=p;
|
|
2
|
+
//# sourceMappingURL=AlphaSlider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlphaSlider.cjs","names":["useColorPartState","displayColor","toPercent","useFieldContext","useFieldControl","React","useMergedRefs","composeEventHandlers","railKeyTarget","getDirection","alphaSliderGradient","toPosition","hsvToHex","cn","alphaSliderClassNames","RAIL_ROOT_VERTICAL","RAIL_ROOT_HORIZONTAL","RAIL_TRACK_VERTICAL","RAIL_TRACK_HORIZONTAL","RAIL_GRADIENT","alphaValueText","RAIL_INPUT_CLASSES","RAIL_INPUT_VERTICAL","RAIL_INPUT_HORIZONTAL","THUMB_TRACK_VERTICAL","THUMB_TRACK_HORIZONTAL","COLOR_THUMB_CLASSES","THUMB_POSITION_VERTICAL","THUMB_POSITION_HORIZONTAL","HiddenInput","require_runtime","require_cn","require_composeEventHandlers","require_classNames","require_color","require_direction","require_useMergedRefs","require_useFieldControl","require_useFormReset","require_HiddenInput","require_colorUtils","require_ColorPicker_parts","react","react_jsx_runtime","DEFAULT_LABELS","AlphaSlider","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","part","pickerValueText","picker","strings","color","labels","resolvedShape","shape","vertical","orientation","shown","opacity","current","transparency","field","_ariaRequired","_required","inputFieldProps","invalid","isInvalid","isRequired","required","inputRef","mergedControlRef","controlRef","form","apply","next","handleKeyDown","onKeyDown","event","target","handleChange","sliderStyle","style","className"],"sources":["../../../src/components/input/AlphaSlider.tsx"],"sourcesContent":["import * as React from 'react';\nimport { alphaSliderClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { hsvToHex } from '../../lib/color';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { getDirection } from '../../lib/direction';\nimport type { HsvColor } from '../../lib/types';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { useColorPartState } from './ColorPicker.parts';\nimport type { ColorSliderProps } from './ColorSlider';\nimport {\n COLOR_THUMB_CLASSES,\n RAIL_GRADIENT,\n RAIL_INPUT_CLASSES,\n RAIL_INPUT_HORIZONTAL,\n RAIL_INPUT_VERTICAL,\n RAIL_ROOT_HORIZONTAL,\n RAIL_ROOT_VERTICAL,\n RAIL_TRACK_HORIZONTAL,\n RAIL_TRACK_VERTICAL,\n THUMB_POSITION_HORIZONTAL,\n THUMB_POSITION_VERTICAL,\n THUMB_TRACK_HORIZONTAL,\n THUMB_TRACK_VERTICAL,\n alphaSliderGradient,\n alphaValueText,\n displayColor,\n railKeyTarget,\n toPercent,\n toPosition,\n} from './colorUtils';\n\n/** Texts of an AlphaSlider, for localisation. Every key is optional. */\nexport interface AlphaSliderLabels {\n /** Name of the slider.\n * @default 'Opacity'\n */\n opacity?: string;\n /** Name of the slider with `transparency`.\n * @default 'Transparency'\n */\n transparency?: string;\n /** Replaces the value text (\"40%\"), for languages whose order differs. */\n valueText?: (color: HsvColor, transparency: boolean) => string;\n}\n\n/** Properties for the AlphaSlider component. */\nexport interface AlphaSliderProps extends Omit<ColorSliderProps, 'channel' | 'labels'> {\n /**\n * Shows transparency (100 % is fully transparent) instead of opacity: the rail, the input's\n * value, the value text and the arrow direction all follow it, while `value.a` stays the\n * opacity (Fluent's `transparency`).\n * @default false\n */\n transparency?: boolean;\n /** Texts of the slider; bound to a ColorPicker, the picker's `labels` fill the keys you leave out. */\n labels?: AlphaSliderLabels;\n}\n\nconst DEFAULT_LABELS = { opacity: 'Opacity', transparency: 'Transparency' } as const;\n\n/**\n * A slider for a color's opacity, drawn over a checkerboard, horizontal (mirrored in right-to-left\n * layouts) or vertical (bottom to top); `transparency` shows transparency instead. The arrow keys\n * move by 1 %, Shift with an arrow and Page Up or Page Down by 10, Home and End to the ends. It is\n * named by `aria-label`, else the surrounding Field's label, else \"Opacity\" (\"Transparency\").\n * Inside a ColorPicker, leave `value` and `defaultValue` out and it binds to the picker. Fluent's\n * `AlphaSlider`, with `value`/`onValueChange` for its `color`/`onChange`.\n *\n * @example\n * <AlphaSlider value={color} onValueChange={setColor} />\n */\nexport const AlphaSlider = ({\n transparency = false,\n orientation = 'horizontal',\n value,\n defaultValue,\n onValueChange,\n shape,\n labels,\n disabled = false,\n name,\n form,\n required,\n controlRef,\n className,\n style,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n autoFocus,\n tabIndex,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n ref,\n ...rest\n}: AlphaSliderProps) => {\n const part = useColorPartState({ value, defaultValue, onValueChange, disabled });\n const { picker } = part;\n const pickerValueText = picker?.labels.valueText;\n const strings = {\n ...DEFAULT_LABELS,\n ...(picker && {\n opacity: picker.labels.opacity,\n transparency: picker.labels.transparency,\n valueText: pickerValueText && ((color: HsvColor) => pickerValueText(color, 'alpha')),\n }),\n ...labels,\n };\n const resolvedShape = shape ?? picker?.shape ?? 'rounded';\n const vertical = orientation === 'vertical';\n const shown = displayColor(part.color);\n const opacity = toPercent(shown.a);\n const current = transparency ? 100 - opacity : opacity;\n\n const field = useFieldContext();\n const fieldProps = useFieldControl({\n id,\n 'aria-label':\n ariaLabel ??\n (field === null && ariaLabelledBy === undefined\n ? transparency\n ? strings.transparency\n : strings.opacity\n : undefined),\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n // A slider supports neither aria-required nor a native `required`: the hidden input carries it.\n const { 'aria-required': _ariaRequired, required: _required, ...inputFieldProps } = fieldProps;\n const invalid = inputFieldProps['aria-invalid'];\n const isInvalid = invalid !== undefined && invalid !== false && invalid !== 'false';\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedControlRef = useMergedRefs(inputRef, controlRef);\n useFormReset(inputRef, part.reset, form);\n\n /** Applies a value of the input's range: the opacity in percent, or the transparency. */\n const apply = (next: number) => {\n if (next === current) return;\n part.setColor({ ...part.color, a: (transparency ? 100 - next : next) / 100 });\n };\n\n const handleKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (part.disabled || event.nativeEvent.isComposing) return;\n const target = railKeyTarget(\n event.key,\n event,\n getDirection(event.currentTarget),\n current,\n 100,\n );\n if (target === null) return;\n event.preventDefault();\n apply(target);\n },\n );\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (part.disabled) return;\n apply(Math.min(100, Math.max(0, Math.round(Number(event.currentTarget.value)))));\n };\n\n const sliderStyle = {\n ...style,\n '--wave-color-slider-gradient': alphaSliderGradient(shown, transparency, orientation),\n '--wave-color-slider-position': toPosition(current / 100),\n '--wave-color-thumb': hsvToHex(shown),\n } as React.CSSProperties;\n\n return (\n <div\n data-orientation={orientation}\n data-disabled={part.disabled ? '' : undefined}\n className={cn(\n alphaSliderClassNames.root,\n 'group/alpha-slider relative flex touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',\n vertical ? RAIL_ROOT_VERTICAL : RAIL_ROOT_HORIZONTAL,\n className,\n )}\n style={sliderStyle}\n {...rest}\n ref={ref}\n >\n <div\n aria-hidden=\"true\"\n className={cn(\n alphaSliderClassNames.rail,\n 'relative overflow-hidden rounded-full bg-[conic-gradient(var(--wave-stroke)_25%,var(--wave-background)_0_50%,var(--wave-stroke)_0_75%,var(--wave-background)_0)] bg-size-[8px_8px] forced-colors:forced-color-adjust-none',\n vertical ? RAIL_TRACK_VERTICAL : RAIL_TRACK_HORIZONTAL,\n resolvedShape === 'square' && 'rounded-none',\n )}\n >\n <span className={cn('absolute inset-0', RAIL_GRADIENT)} />\n </div>\n <input\n type=\"range\"\n {...inputFieldProps}\n ref={mergedControlRef}\n min={0}\n max={100}\n step={1}\n value={current}\n disabled={part.disabled}\n dir={vertical ? 'ltr' : undefined}\n aria-orientation={vertical ? 'vertical' : undefined}\n aria-valuetext={alphaValueText(shown, transparency, strings.valueText)}\n aria-errormessage={(isInvalid && ariaErrorMessage) || undefined}\n aria-details={ariaDetails}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onChange={handleChange}\n className={cn(RAIL_INPUT_CLASSES, vertical ? RAIL_INPUT_VERTICAL : RAIL_INPUT_HORIZONTAL)}\n />\n <span aria-hidden=\"true\" className={vertical ? THUMB_TRACK_VERTICAL : THUMB_TRACK_HORIZONTAL}>\n <span\n className={cn(\n alphaSliderClassNames.thumb,\n COLOR_THUMB_CLASSES,\n vertical ? THUMB_POSITION_VERTICAL : THUMB_POSITION_HORIZONTAL,\n 'group-has-[:focus-visible]/alpha-slider:ring-2 group-has-[:focus-visible]/alpha-slider:ring-background forced-colors:group-has-[:focus-visible]/alpha-slider:ring-[Canvas] group-has-[:focus-visible]/alpha-slider:outline-2 group-has-[:focus-visible]/alpha-slider:outline-offset-2 group-has-[:focus-visible]/alpha-slider:outline-ring forced-colors:group-has-[:focus-visible]/alpha-slider:outline-[Highlight]',\n )}\n />\n </span>\n {!picker && (\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n disabled={part.disabled}\n value={hsvToHex(part.color)}\n required={isRequired}\n onInvalid={() => inputRef.current?.focus()}\n />\n )}\n </div>\n );\n};\n\nAlphaSlider.displayName = 'AlphaSlider';\n"],"mappings":"yjBA8DA,IAAM4C,GAAiB,CAAE,QAAS,UAAW,aAAc,cAAe,EAa7DC,GAAe,CAC1B,eAAe,GACf,cAAc,aACd,QACA,eACA,gBACA,QACA,SACA,YAAW,GACX,OACA,OACA,WACA,aACA,aACA,QACA,KACA,aAAcC,EACd,kBAAmBC,EACnB,mBAAoBC,EACpB,eAAgBC,EAChB,gBAAiBC,EACjB,oBAAqBC,EACrB,eAAgBC,EAChB,YACA,WACA,UACA,SACA,YACA,UACA,MACA,GAAGC,KACmB,CACtB,IAAMC,EAAOtD,EAAAA,kBAAkB,CAAE,QAAO,eAAc,gBAAe,WAAS,CAAC,EACzE,CAAE,UAAWsD,EACbC,EAAkBC,GAAQ,OAAO,UACjCC,EAAU,CACd,GAAGb,GACH,GAAIY,GAAU,CACZ,QAASA,EAAO,OAAO,QACvB,aAAcA,EAAO,OAAO,aAC5B,UAAWD,IAAqB,GAAoBA,EAAgBG,EAAO,OAAO,EACpF,EACA,GAAGC,CACL,EACMC,EAAgBC,GAASL,GAAQ,OAAS,UAC1CM,EAAWC,IAAgB,WAC3BC,E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A,uBACpE,UAAA,EAAAkB,EAAA,IAAA,CAAC,OAAD,CACE,UAAW9B,EAAAA,GACTC,EAAAA,sBAAsB,MACtBY,EAAAA,oBACAoC,EAAWnC,EAAAA,wBAA0BC,EAAAA,0BACrC,sZACF,CACD,CAAA,CACG,CAAA,EACL,CAAC4B,IACA,EAAAb,EAAA,IAAA,CAACd,EAAAA,YAAD,CACE,KAAK,OACC,OACA,OACN,SAAUyB,EAAK,SACf,MAAO1C,EAAAA,SAAS0C,EAAK,KAAK,EAC1B,SAAUoB,GACV,cAAiBE,EAAS,SAAS,MAAM,CAC1C,CAAA,CAEA,GAET,EAEA,EAAY,YAAc"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { composeEventHandlers as t } from "../../lib/composeEventHandlers.mjs";
|
|
4
|
+
import { alphaSliderClassNames as n } from "../../lib/classNames.mjs";
|
|
5
|
+
import { hsvToHex as r } from "../../lib/color.mjs";
|
|
6
|
+
import { getDirection as i } from "../../lib/direction.mjs";
|
|
7
|
+
import { useMergedRefs as a } from "../../hooks/useMergedRefs.mjs";
|
|
8
|
+
import { useFieldContext as o, useFieldControl as s } from "../../hooks/useFieldControl.mjs";
|
|
9
|
+
import { useFormReset as c } from "../../hooks/useFormReset.mjs";
|
|
10
|
+
import { HiddenInput as l } from "../internal/HiddenInput.mjs";
|
|
11
|
+
import { COLOR_THUMB_CLASSES as u, RAIL_GRADIENT as ee, RAIL_INPUT_CLASSES as te, RAIL_INPUT_HORIZONTAL as ne, RAIL_INPUT_VERTICAL as re, RAIL_ROOT_HORIZONTAL as ie, RAIL_ROOT_VERTICAL as ae, RAIL_TRACK_HORIZONTAL as oe, RAIL_TRACK_VERTICAL as se, THUMB_POSITION_HORIZONTAL as ce, THUMB_POSITION_VERTICAL as le, THUMB_TRACK_HORIZONTAL as ue, THUMB_TRACK_VERTICAL as de, alphaSliderGradient as fe, alphaValueText as d, displayColor as f, railKeyTarget as p, toPercent as m, toPosition as h } from "./colorUtils.mjs";
|
|
12
|
+
import { useColorPartState as g } from "./ColorPicker.parts.mjs";
|
|
13
|
+
import * as _ from "react";
|
|
14
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
15
|
+
//#region src/components/input/AlphaSlider.tsx
|
|
16
|
+
var b = {
|
|
17
|
+
opacity: "Opacity",
|
|
18
|
+
transparency: "Transparency"
|
|
19
|
+
}, x = ({ transparency: x = !1, orientation: S = "horizontal", value: C, defaultValue: w, onValueChange: T, shape: E, labels: D, disabled: O = !1, name: k, form: A, required: j, controlRef: M, className: N, style: P, id: F, "aria-label": I, "aria-labelledby": L, "aria-describedby": R, "aria-invalid": pe, "aria-required": z, "aria-errormessage": B, "aria-details": me, autoFocus: he, tabIndex: ge, onFocus: _e, onBlur: ve, onKeyDown: ye, onKeyUp: be, ref: xe, ...Se }) => {
|
|
20
|
+
let V = g({
|
|
21
|
+
value: C,
|
|
22
|
+
defaultValue: w,
|
|
23
|
+
onValueChange: T,
|
|
24
|
+
disabled: O
|
|
25
|
+
}), { picker: H } = V, U = H?.labels.valueText, W = {
|
|
26
|
+
...b,
|
|
27
|
+
...H && {
|
|
28
|
+
opacity: H.labels.opacity,
|
|
29
|
+
transparency: H.labels.transparency,
|
|
30
|
+
valueText: U && ((e) => U(e, "alpha"))
|
|
31
|
+
},
|
|
32
|
+
...D
|
|
33
|
+
}, Ce = E ?? H?.shape ?? "rounded", G = S === "vertical", K = f(V.color), q = m(K.a), J = x ? 100 - q : q, Y = o(), { "aria-required": we, required: Te, ...X } = s({
|
|
34
|
+
id: F,
|
|
35
|
+
"aria-label": I ?? (Y === null && L === void 0 ? x ? W.transparency : W.opacity : void 0),
|
|
36
|
+
"aria-labelledby": L,
|
|
37
|
+
"aria-describedby": R,
|
|
38
|
+
"aria-invalid": pe
|
|
39
|
+
}), Z = X["aria-invalid"], Ee = Z !== void 0 && Z !== !1 && Z !== "false", De = j ?? (z === !0 || z === "true" || (Y?.required ?? !1)), Q = _.useRef(null), Oe = a(Q, M);
|
|
40
|
+
c(Q, V.reset, A);
|
|
41
|
+
let $ = (e) => {
|
|
42
|
+
e !== J && V.setColor({
|
|
43
|
+
...V.color,
|
|
44
|
+
a: (x ? 100 - e : e) / 100
|
|
45
|
+
});
|
|
46
|
+
}, ke = t(ye, (e) => {
|
|
47
|
+
if (V.disabled || e.nativeEvent.isComposing) return;
|
|
48
|
+
let t = p(e.key, e, i(e.currentTarget), J, 100);
|
|
49
|
+
t !== null && (e.preventDefault(), $(t));
|
|
50
|
+
}), Ae = (e) => {
|
|
51
|
+
V.disabled || $(Math.min(100, Math.max(0, Math.round(Number(e.currentTarget.value)))));
|
|
52
|
+
}, je = {
|
|
53
|
+
...P,
|
|
54
|
+
"--wave-color-slider-gradient": fe(K, x, S),
|
|
55
|
+
"--wave-color-slider-position": h(J / 100),
|
|
56
|
+
"--wave-color-thumb": r(K)
|
|
57
|
+
};
|
|
58
|
+
return /* @__PURE__ */ y("div", {
|
|
59
|
+
"data-orientation": S,
|
|
60
|
+
"data-disabled": V.disabled ? "" : void 0,
|
|
61
|
+
className: e(n.root, "group/alpha-slider relative flex touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50", G ? ae : ie, N),
|
|
62
|
+
style: je,
|
|
63
|
+
...Se,
|
|
64
|
+
ref: xe,
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ v("div", {
|
|
67
|
+
"aria-hidden": "true",
|
|
68
|
+
className: e(n.rail, "relative overflow-hidden rounded-full bg-[conic-gradient(var(--wave-stroke)_25%,var(--wave-background)_0_50%,var(--wave-stroke)_0_75%,var(--wave-background)_0)] bg-size-[8px_8px] forced-colors:forced-color-adjust-none", G ? se : oe, Ce === "square" && "rounded-none"),
|
|
69
|
+
children: /* @__PURE__ */ v("span", { className: e("absolute inset-0", ee) })
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ v("input", {
|
|
72
|
+
type: "range",
|
|
73
|
+
...X,
|
|
74
|
+
ref: Oe,
|
|
75
|
+
min: 0,
|
|
76
|
+
max: 100,
|
|
77
|
+
step: 1,
|
|
78
|
+
value: J,
|
|
79
|
+
disabled: V.disabled,
|
|
80
|
+
dir: G ? "ltr" : void 0,
|
|
81
|
+
"aria-orientation": G ? "vertical" : void 0,
|
|
82
|
+
"aria-valuetext": d(K, x, W.valueText),
|
|
83
|
+
"aria-errormessage": Ee && B || void 0,
|
|
84
|
+
"aria-details": me,
|
|
85
|
+
autoFocus: he,
|
|
86
|
+
tabIndex: ge,
|
|
87
|
+
onFocus: _e,
|
|
88
|
+
onBlur: ve,
|
|
89
|
+
onKeyDown: ke,
|
|
90
|
+
onKeyUp: be,
|
|
91
|
+
onChange: Ae,
|
|
92
|
+
className: e(te, G ? re : ne)
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ v("span", {
|
|
95
|
+
"aria-hidden": "true",
|
|
96
|
+
className: G ? de : ue,
|
|
97
|
+
children: /* @__PURE__ */ v("span", { className: e(n.thumb, u, G ? le : ce, "group-has-[:focus-visible]/alpha-slider:ring-2 group-has-[:focus-visible]/alpha-slider:ring-background forced-colors:group-has-[:focus-visible]/alpha-slider:ring-[Canvas] group-has-[:focus-visible]/alpha-slider:outline-2 group-has-[:focus-visible]/alpha-slider:outline-offset-2 group-has-[:focus-visible]/alpha-slider:outline-ring forced-colors:group-has-[:focus-visible]/alpha-slider:outline-[Highlight]") })
|
|
98
|
+
}),
|
|
99
|
+
!H && /* @__PURE__ */ v(l, {
|
|
100
|
+
type: "text",
|
|
101
|
+
name: k,
|
|
102
|
+
form: A,
|
|
103
|
+
disabled: V.disabled,
|
|
104
|
+
value: r(V.color),
|
|
105
|
+
required: De,
|
|
106
|
+
onInvalid: () => Q.current?.focus()
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
x.displayName = "AlphaSlider";
|
|
112
|
+
//#endregion
|
|
113
|
+
export { x as AlphaSlider };
|
|
114
|
+
|
|
115
|
+
//# sourceMappingURL=AlphaSlider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlphaSlider.mjs","names":["React","DEFAULT_LABELS","AlphaSlider","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","part","useColorPartState","pickerValueText","picker","strings","color","labels","resolvedShape","shape","vertical","orientation","shown","displayColor","opacity","toPercent","current","transparency","field","useFieldContext","_ariaRequired","_required","inputFieldProps","useFieldControl","invalid","isInvalid","isRequired","required","inputRef","mergedControlRef","useMergedRefs","controlRef","form","apply","next","handleKeyDown","composeEventHandlers","onKeyDown","event","target","railKeyTarget","getDirection","handleChange","sliderStyle","style","alphaSliderGradient","toPosition","hsvToHex","cn","alphaSliderClassNames","RAIL_ROOT_VERTICAL","RAIL_ROOT_HORIZONTAL","className","RAIL_TRACK_VERTICAL","RAIL_TRACK_HORIZONTAL","RAIL_GRADIENT","alphaValueText","RAIL_INPUT_CLASSES","RAIL_INPUT_VERTICAL","RAIL_INPUT_HORIZONTAL","THUMB_TRACK_VERTICAL","THUMB_TRACK_HORIZONTAL","COLOR_THUMB_CLASSES","THUMB_POSITION_VERTICAL","THUMB_POSITION_HORIZONTAL","HiddenInput"],"sources":["../../../src/components/input/AlphaSlider.tsx"],"sourcesContent":["import * as React from 'react';\nimport { alphaSliderClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { hsvToHex } from '../../lib/color';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { getDirection } from '../../lib/direction';\nimport type { HsvColor } from '../../lib/types';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { useColorPartState } from './ColorPicker.parts';\nimport type { ColorSliderProps } from './ColorSlider';\nimport {\n COLOR_THUMB_CLASSES,\n RAIL_GRADIENT,\n RAIL_INPUT_CLASSES,\n RAIL_INPUT_HORIZONTAL,\n RAIL_INPUT_VERTICAL,\n RAIL_ROOT_HORIZONTAL,\n RAIL_ROOT_VERTICAL,\n RAIL_TRACK_HORIZONTAL,\n RAIL_TRACK_VERTICAL,\n THUMB_POSITION_HORIZONTAL,\n THUMB_POSITION_VERTICAL,\n THUMB_TRACK_HORIZONTAL,\n THUMB_TRACK_VERTICAL,\n alphaSliderGradient,\n alphaValueText,\n displayColor,\n railKeyTarget,\n toPercent,\n toPosition,\n} from './colorUtils';\n\n/** Texts of an AlphaSlider, for localisation. Every key is optional. */\nexport interface AlphaSliderLabels {\n /** Name of the slider.\n * @default 'Opacity'\n */\n opacity?: string;\n /** Name of the slider with `transparency`.\n * @default 'Transparency'\n */\n transparency?: string;\n /** Replaces the value text (\"40%\"), for languages whose order differs. */\n valueText?: (color: HsvColor, transparency: boolean) => string;\n}\n\n/** Properties for the AlphaSlider component. */\nexport interface AlphaSliderProps extends Omit<ColorSliderProps, 'channel' | 'labels'> {\n /**\n * Shows transparency (100 % is fully transparent) instead of opacity: the rail, the input's\n * value, the value text and the arrow direction all follow it, while `value.a` stays the\n * opacity (Fluent's `transparency`).\n * @default false\n */\n transparency?: boolean;\n /** Texts of the slider; bound to a ColorPicker, the picker's `labels` fill the keys you leave out. */\n labels?: AlphaSliderLabels;\n}\n\nconst DEFAULT_LABELS = { opacity: 'Opacity', transparency: 'Transparency' } as const;\n\n/**\n * A slider for a color's opacity, drawn over a checkerboard, horizontal (mirrored in right-to-left\n * layouts) or vertical (bottom to top); `transparency` shows transparency instead. The arrow keys\n * move by 1 %, Shift with an arrow and Page Up or Page Down by 10, Home and End to the ends. It is\n * named by `aria-label`, else the surrounding Field's label, else \"Opacity\" (\"Transparency\").\n * Inside a ColorPicker, leave `value` and `defaultValue` out and it binds to the picker. Fluent's\n * `AlphaSlider`, with `value`/`onValueChange` for its `color`/`onChange`.\n *\n * @example\n * <AlphaSlider value={color} onValueChange={setColor} />\n */\nexport const AlphaSlider = ({\n transparency = false,\n orientation = 'horizontal',\n value,\n defaultValue,\n onValueChange,\n shape,\n labels,\n disabled = false,\n name,\n form,\n required,\n controlRef,\n className,\n style,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n autoFocus,\n tabIndex,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n ref,\n ...rest\n}: AlphaSliderProps) => {\n const part = useColorPartState({ value, defaultValue, onValueChange, disabled });\n const { picker } = part;\n const pickerValueText = picker?.labels.valueText;\n const strings = {\n ...DEFAULT_LABELS,\n ...(picker && {\n opacity: picker.labels.opacity,\n transparency: picker.labels.transparency,\n valueText: pickerValueText && ((color: HsvColor) => pickerValueText(color, 'alpha')),\n }),\n ...labels,\n };\n const resolvedShape = shape ?? picker?.shape ?? 'rounded';\n const vertical = orientation === 'vertical';\n const shown = displayColor(part.color);\n const opacity = toPercent(shown.a);\n const current = transparency ? 100 - opacity : opacity;\n\n const field = useFieldContext();\n const fieldProps = useFieldControl({\n id,\n 'aria-label':\n ariaLabel ??\n (field === null && ariaLabelledBy === undefined\n ? transparency\n ? strings.transparency\n : strings.opacity\n : undefined),\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n });\n // A slider supports neither aria-required nor a native `required`: the hidden input carries it.\n const { 'aria-required': _ariaRequired, required: _required, ...inputFieldProps } = fieldProps;\n const invalid = inputFieldProps['aria-invalid'];\n const isInvalid = invalid !== undefined && invalid !== false && invalid !== 'false';\n const isRequired =\n required ?? (ariaRequired === true || ariaRequired === 'true' || (field?.required ?? false));\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedControlRef = useMergedRefs(inputRef, controlRef);\n useFormReset(inputRef, part.reset, form);\n\n /** Applies a value of the input's range: the opacity in percent, or the transparency. */\n const apply = (next: number) => {\n if (next === current) return;\n part.setColor({ ...part.color, a: (transparency ? 100 - next : next) / 100 });\n };\n\n const handleKeyDown = composeEventHandlers(\n onKeyDown,\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (part.disabled || event.nativeEvent.isComposing) return;\n const target = railKeyTarget(\n event.key,\n event,\n getDirection(event.currentTarget),\n current,\n 100,\n );\n if (target === null) return;\n event.preventDefault();\n apply(target);\n },\n );\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n if (part.disabled) return;\n apply(Math.min(100, Math.max(0, Math.round(Number(event.currentTarget.value)))));\n };\n\n const sliderStyle = {\n ...style,\n '--wave-color-slider-gradient': alphaSliderGradient(shown, transparency, orientation),\n '--wave-color-slider-position': toPosition(current / 100),\n '--wave-color-thumb': hsvToHex(shown),\n } as React.CSSProperties;\n\n return (\n <div\n data-orientation={orientation}\n data-disabled={part.disabled ? '' : undefined}\n className={cn(\n alphaSliderClassNames.root,\n 'group/alpha-slider relative flex touch-none select-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',\n vertical ? RAIL_ROOT_VERTICAL : RAIL_ROOT_HORIZONTAL,\n className,\n )}\n style={sliderStyle}\n {...rest}\n ref={ref}\n >\n <div\n aria-hidden=\"true\"\n className={cn(\n alphaSliderClassNames.rail,\n 'relative overflow-hidden rounded-full bg-[conic-gradient(var(--wave-stroke)_25%,var(--wave-background)_0_50%,var(--wave-stroke)_0_75%,var(--wave-background)_0)] bg-size-[8px_8px] forced-colors:forced-color-adjust-none',\n vertical ? RAIL_TRACK_VERTICAL : RAIL_TRACK_HORIZONTAL,\n resolvedShape === 'square' && 'rounded-none',\n )}\n >\n <span className={cn('absolute inset-0', RAIL_GRADIENT)} />\n </div>\n <input\n type=\"range\"\n {...inputFieldProps}\n ref={mergedControlRef}\n min={0}\n max={100}\n step={1}\n value={current}\n disabled={part.disabled}\n dir={vertical ? 'ltr' : undefined}\n aria-orientation={vertical ? 'vertical' : undefined}\n aria-valuetext={alphaValueText(shown, transparency, strings.valueText)}\n aria-errormessage={(isInvalid && ariaErrorMessage) || undefined}\n aria-details={ariaDetails}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n onChange={handleChange}\n className={cn(RAIL_INPUT_CLASSES, vertical ? RAIL_INPUT_VERTICAL : RAIL_INPUT_HORIZONTAL)}\n />\n <span aria-hidden=\"true\" className={vertical ? THUMB_TRACK_VERTICAL : THUMB_TRACK_HORIZONTAL}>\n <span\n className={cn(\n alphaSliderClassNames.thumb,\n COLOR_THUMB_CLASSES,\n vertical ? THUMB_POSITION_VERTICAL : THUMB_POSITION_HORIZONTAL,\n 'group-has-[:focus-visible]/alpha-slider:ring-2 group-has-[:focus-visible]/alpha-slider:ring-background forced-colors:group-has-[:focus-visible]/alpha-slider:ring-[Canvas] group-has-[:focus-visible]/alpha-slider:outline-2 group-has-[:focus-visible]/alpha-slider:outline-offset-2 group-has-[:focus-visible]/alpha-slider:outline-ring forced-colors:group-has-[:focus-visible]/alpha-slider:outline-[Highlight]',\n )}\n />\n </span>\n {!picker && (\n <HiddenInput\n type=\"text\"\n name={name}\n form={form}\n disabled={part.disabled}\n value={hsvToHex(part.color)}\n required={isRequired}\n onInvalid={() => inputRef.current?.focus()}\n />\n )}\n </div>\n );\n};\n\nAlphaSlider.displayName = 'AlphaSlider';\n"],"mappings":";;;;;;;;;;;;;;;AA8DA,IAAMC,IAAiB;CAAE,SAAS;CAAW,cAAc;AAAe,GAa7DC,KAAe,EAC1B,kBAAe,IACf,iBAAc,cACd,UACA,iBACA,kBACA,UACA,WACA,cAAW,IACX,SACA,SACA,aACA,eACA,cACA,UACA,OACA,cAAcC,GACd,mBAAmBC,GACnB,oBAAoBC,GACpB,gBAAgBC,IAChB,iBAAiBC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S,IAAoB/C,IAAWgD,KAAsBC,EAAqB;GACzF,CAAA;GACD,kBAAC,QAAD;IAAM,eAAY;IAAO,WAAWjD,IAAWkD,KAAuBC;IACpE,UAAA,kBAAC,QAAD,EACE,WAAWb,EACTC,EAAsB,OACtBa,GACApD,IAAWqD,KAA0BC,IACrC,sZACF,EACD,CAAA;GACG,CAAA;GACL,CAAC5D,KACA,kBAAC6D,GAAD;IACE,MAAK;IACC;IACA;IACN,UAAUhE,EAAK;IACf,OAAO8C,EAAS9C,EAAK,KAAK;IAC1B,UAAUyB;IACV,iBAAiBE,EAAS,SAAS,MAAM;GAC1C,CAAA;EAEA;;AAET;AAEA,EAAY,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),ee=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),te=require("../../hooks/useControllable.cjs"),a=require("../../hooks/useId.cjs"),ne=require("../../hooks/useMergedRefs.cjs"),o=require("../../lib/aria.cjs"),s=require("../../hooks/useFieldControl.cjs"),c=require("../../lib/styles.cjs"),l=require("../../lib/icons.cjs"),u=require("../../hooks/useFormReset.cjs"),re=require("../internal/HiddenInput.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var ie=`forced-colors:border-[Highlight] forced-colors:bg-[Highlight]`,ae=`forced-colors:border-[GrayText] forced-colors:bg-[Canvas]`,oe=`forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none`,p=({checked:e,defaultChecked:p=!1,indeterminate:m=!1,onCheckedChange:h,onChange:g,disabled:_=!1,disabledFocusable:v=!1,label:y,labelPosition:b=`after`,name:se,value:ce,required:x,form:S,id:le,"aria-label":C,"aria-labelledby":w,"aria-describedby":T,"aria-invalid":E,"aria-required":D,"aria-errormessage":O,"aria-details":k,"aria-disabled":A,autoFocus:j,tabIndex:M,onClick:N,onFocus:P,onBlur:F,onKeyDown:I,onKeyUp:L,controlRef:R,className:ue,children:z,ref:B,...V})=>{g!==void 0&&n.warnDeprecated(`Checkbox`,`onChange`,`onCheckedChange`);let H=r.slotRendersContent(z);d.useEffect(()=>{H&&n.warnOnce(`Checkbox:children`,"Checkbox: children are not rendered. Pass the label in `label`.")},[H]);let[U,W]=te.useControllable(e,p,e=>{h?.(e),g?.(e)}),de=a.useId(`checkbox`),G=a.useId(`checkbox-label`),K=s.useFieldContext(),q=s.useFieldControl({id:le,"aria-label":C,"aria-labelledby":w,"aria-describedby":T,"aria-invalid":E,"aria-required":D??x}),J=x??K?.required??!1,Y=r.slotRendersContent(y),fe=Y&&q[`aria-label`]===void 0?o.joinIds(q[`aria-labelledby`],K&&q.id===K.controlId?K.labelId:void 0,G):q[`aria-labelledby`],X=d.useRef(null),pe=ne.useMergedRefs(X,R);u.useFormReset(X,()=>W(p),S);let me=U||m,Z=_||v,Q=Z?oe:c.forcedColors.selectedLeaf,$=Y?(0,f.jsx)(`span`,{id:G,className:t.cn(i.checkboxClassNames.label,`text-body-1 text-foreground`),children:r.materialiseSlotContent(y)}):null;return(0,f.jsxs)(`label`,{ref:B,"data-label-position":b,className:t.cn(i.checkboxClassNames.root,`relative inline-flex items-start gap-2 select-none`,Z?`cursor-not-allowed opacity-50 has-focus-visible:opacity-100`:`cursor-pointer`,ue),...V,children:[b===`before`&&$,(0,f.jsx)(`button`,{id:de,type:`button`,...q,"aria-labelledby":fe,"aria-errormessage":O,"aria-details":k,"aria-disabled":A,autoFocus:j,tabIndex:M,onFocus:P,onBlur:F,onKeyDown:I,onKeyUp:L,ref:pe,role:`checkbox`,"aria-checked":m?`mixed`:U,disabled:_&&!v,...o.focusableDisabledProps(v,{reachable:!0}),onClick:v?e=>{e.preventDefault(),e.stopPropagation()}:ee.composeEventHandlers(N,()=>W(e=>!e)),className:t.cn(i.checkboxClassNames.indicator,`flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none`,Y&&`mt-px`,c.focusRing,me?t.cn(`border-primary bg-primary text-primary-foreground`,Z?ae:ie):t.cn(`border-stroke-accessible bg-transparent`,Z?c.forcedColors.disabled:c.forcedColors.control)),children:m?(0,f.jsx)(l.SubtractIcon,{size:12,className:Q}):U?(0,f.jsx)(l.CheckIcon,{size:12,className:Q}):null}),b!==`before`&&$,(0,f.jsx)(re.HiddenInput,{type:`checkbox`,name:se,form:S,disabled:Z,value:ce,checked:U,required:J,onInvalid:()=>X.current?.focus()})]})};p.displayName=`Checkbox`,exports.Checkbox=p;
|
|
2
|
+
//# sourceMappingURL=Checkbox.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.cjs","names":["slotRendersContent","useControllable","useId","useFieldContext","useFieldControl","joinIds","React","useMergedRefs","forcedColors","cn","checkboxClassNames","materialiseSlotContent","focusableDisabledProps","composeEventHandlers","focusRing","SubtractIcon","CheckIcon","HiddenInput","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_useControllable","require_useId","require_useMergedRefs","require_aria","require_useFieldControl","require_styles","require_icons","require_useFormReset","require_HiddenInput","react","react_jsx_runtime","checkedBox","disabledCheckedBox","disabledGlyph","Checkbox","checkedProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","ariaDisabled","rest","onChange","hasChildren","children","checked","setChecked","defaultChecked","onCheckedChange","next","generatedId","labelTextId","field","fieldProps","required","isRequired","hasLabel","label","labelledBy","buttonRef","mergedControlRef","controlRef","form","on","indeterminate","unavailable","disabled","disabledFocusable","glyphClassName","labelText","labelPosition","className","event","onClick","prev"],"sources":["../../../src/components/input/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { focusableDisabledProps, joinIds } from '../../lib/aria';\nimport { checkboxClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { CheckIcon, SubtractIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { LabelPosition } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\n\n/*\n * Forced colors: the focusable box keeps system-color utilities, so the browser still forces its\n * focus outline and border; only the glyph (the leaf indicator) opts out of forced colors. A\n * disabled box draws a GrayText glyph and border on Canvas, without the Highlight fill.\n */\nconst checkedBox = 'forced-colors:border-[Highlight] forced-colors:bg-[Highlight]';\nconst disabledCheckedBox = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\nconst disabledGlyph = 'forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none';\n\n/** Handlers that run on the `role=\"checkbox\"` button instead of the root label (C-ROUTING). */\ntype CheckboxControlHandlers = 'onClick' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp';\n\n/** Where a Checkbox renders its label: after the box (default) or before it. */\nexport type CheckboxLabelPosition = Extract<LabelPosition, 'before' | 'after'>;\n\n/** Properties for the Checkbox component. */\nexport interface CheckboxProps extends Omit<\n React.HTMLAttributes<HTMLLabelElement>,\n 'onChange' | 'defaultChecked' | CheckboxControlHandlers\n> {\n /** Controlled checked state. */\n checked?: boolean;\n /** Initial checked state for uncontrolled usage (also the value a form reset restores).\n * @default false\n */\n defaultChecked?: boolean;\n /**\n * Shows the mixed state: the dash glyph and `aria-checked=\"mixed\"`, whatever `checked` is. A\n * click still toggles `checked` and calls `onCheckedChange`, but the checkbox keeps showing and\n * announcing \"mixed\" until you clear `indeterminate`. For a tri-state \"select all\", derive\n * `checked` and `indeterminate` from the items and set every item in `onCheckedChange`.\n * @default false\n */\n indeterminate?: boolean;\n /** Called with the new checked state when it changes (not for no-op updates). */\n onCheckedChange?: (checked: boolean) => void;\n /**\n * Called with the new checked state when it changes.\n * @deprecated Use `onCheckedChange`.\n */\n onChange?: (checked: boolean) => void;\n /** Whether the checkbox is disabled and non-interactive. */\n disabled?: boolean;\n /**\n * Marks the checkbox unavailable but keeps it focusable and in the tab order: for a disabled\n * checkbox that needs a Tooltip, or one in a toolbar. Renders `aria-disabled=\"true\"`,\n * `data-disabled` and `data-disabled-focusable` on the checkbox instead of the native `disabled`\n * attribute. The checkbox cannot be toggled and is not submitted with its form; your `onClick`\n * is not called, and a click on the checkbox (or Space and Enter) does not reach ancestor click\n * handlers, as for a natively disabled control. Wins over `disabled` when both are set. In a\n * roving container (a `Toolbar`) it stays in the arrow-key order.\n * @default false\n */\n disabledFocusable?: boolean;\n /**\n * Label next to the control (any phrasing content, links included, but no other form\n * controls). It names the control through `aria-labelledby`, after a consumer or Field\n * `aria-labelledby`; a consumer `aria-label` names it instead. Clicking its text toggles the\n * control; clicking a link inside it follows the link. `children` are not rendered: pass the\n * label here.\n */\n label?: React.ReactNode;\n /**\n * Where the label renders: after the control (default) or before it. The DOM order follows the\n * visual order.\n * @default 'after'\n */\n labelPosition?: CheckboxLabelPosition;\n /**\n * Form field name. With a name, the checkbox takes part in native form submission: it submits\n * `name=value` while checked.\n */\n name?: string;\n /** Value submitted while checked.\n * @default 'on'\n */\n value?: string;\n /** The form must not be submitted while the checkbox is unchecked (native validation). */\n required?: boolean;\n /** Id of the form the checkbox belongs to, when it is rendered outside that form. */\n form?: string;\n /** Click handler of the checkbox control (the `role=\"checkbox\"` button). */\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n /** Focus handler of the checkbox control. */\n onFocus?: React.FocusEventHandler<HTMLButtonElement>;\n /** Blur handler of the checkbox control. */\n onBlur?: React.FocusEventHandler<HTMLButtonElement>;\n /** Keydown handler of the checkbox control. */\n onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Keyup handler of the checkbox control. */\n onKeyUp?: React.KeyboardEventHandler<HTMLButtonElement>;\n /** Ref to the focusable `role=\"checkbox\"` button. */\n controlRef?: React.Ref<HTMLButtonElement>;\n /** Ref to the root `<label>` element. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\n/**\n * A checkbox for a boolean (or mixed) choice, drawn as a `role=\"checkbox\"` button inside a\n * `<label>`.\n *\n * - The root `<label>` receives `ref`, `className`, `style` and `data-*`; the control receives\n * `id`, `aria-label`/`-labelledby`/`-describedby`/`-invalid`/`-required`/`-errormessage`/\n * `-details`/`-disabled`, `tabIndex`, `autoFocus` and the click, focus and key handlers\n * (`controlRef` exposes it). A consumer `onClick` runs once per activation, before the toggle;\n * `preventDefault()` in it cancels the toggle.\n * - Inside a `Field` it is named by the Field label (followed by its own `label` text) and described\n * by the Field message and hint.\n * - With `name` (or `required`) it takes part in native forms like `<input type=\"checkbox\">`, and\n * a form reset restores `defaultChecked`.\n * - `label` takes rich content (a link to the terms) and renders after the box, or before it with\n * `labelPosition=\"before\"` (the root carries `data-label-position`). The box lines up with the\n * first line of a label that wraps or has a second line. `children` are not rendered (a\n * development warning says so).\n */\nexport const Checkbox = ({\n checked: checkedProp,\n defaultChecked = false,\n indeterminate = false,\n onCheckedChange,\n onChange,\n disabled = false,\n disabledFocusable = false,\n label,\n labelPosition = 'after',\n name,\n value,\n required,\n form,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n 'aria-disabled': ariaDisabled,\n autoFocus,\n tabIndex,\n onClick,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n children,\n ref,\n ...rest\n}: CheckboxProps) => {\n if (onChange !== undefined) warnDeprecated('Checkbox', 'onChange', 'onCheckedChange');\n const hasChildren = slotRendersContent(children);\n React.useEffect(() => {\n if (hasChildren) {\n warnOnce(\n 'Checkbox:children',\n 'Checkbox: children are not rendered. Pass the label in `label`.',\n );\n }\n }, [hasChildren]);\n const [checked, setChecked] = useControllable(checkedProp, defaultChecked, (next: boolean) => {\n onCheckedChange?.(next);\n onChange?.(next);\n });\n\n const generatedId = useId('checkbox');\n const labelTextId = useId('checkbox-label');\n const field = useFieldContext();\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required always matches\n // the native validation below (`isRequired`).\n 'aria-required': ariaRequired ?? required,\n });\n const isRequired = required ?? field?.required ?? false;\n // `0` is a label; `null`, `false`, `''` and empty collections are not (C-SLOTS).\n const hasLabel = slotRendersContent(label);\n // The label text names the control through aria-labelledby, disabled or not: axe exempts the\n // dimmed text of a disabled control only when the control references it this way (its <label>\n // exemption covers native inputs only). A consumer aria-label still names the control alone.\n // The ids already there (the consumer's, the Field label from useFieldControl) come first, then\n // the Field label whose <label htmlFor> targets this control (aria-labelledby would hide it), so\n // the name keeps every label.\n const labelledBy =\n hasLabel && fieldProps['aria-label'] === undefined\n ? joinIds(\n fieldProps['aria-labelledby'],\n field && fieldProps.id === field.controlId ? field.labelId : undefined,\n labelTextId,\n )\n : fieldProps['aria-labelledby'];\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const mergedControlRef = useMergedRefs(buttonRef, controlRef);\n useFormReset(buttonRef, () => setChecked(defaultChecked), form);\n\n const on = checked || indeterminate;\n // Focusable-disabled wins over `disabled`: the box stays focusable but looks and acts disabled.\n const unavailable = disabled || disabledFocusable;\n // The glyph is the forced-colors leaf; the box stays on system colors (see `checkedBox`).\n const glyphClassName = unavailable ? disabledGlyph : forcedColors.selectedLeaf;\n const labelText = hasLabel ? (\n <span id={labelTextId} className={cn(checkboxClassNames.label, 'text-body-1 text-foreground')}>\n {materialiseSlotContent(label)}\n </span>\n ) : null;\n\n return (\n <label\n ref={ref}\n data-label-position={labelPosition}\n className={cn(\n checkboxClassNames.root,\n // items-start: the box lines up with the first line of a label that wraps or has a second\n // line, not with its middle.\n 'relative inline-flex items-start gap-2 select-none',\n // The dimmed look lifts while a focus ring shows inside the root (the control's, under\n // disabledFocusable, or a link's in the label): opacity would dim the ring below 3:1.\n unavailable\n ? 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100'\n : 'cursor-pointer',\n className,\n )}\n {...rest}\n >\n {labelPosition === 'before' && labelText}\n <button\n id={generatedId}\n type=\"button\"\n {...fieldProps}\n aria-labelledby={labelledBy}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n aria-disabled={ariaDisabled}\n autoFocus={autoFocus}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n onKeyUp={onKeyUp}\n ref={mergedControlRef}\n role=\"checkbox\"\n aria-checked={indeterminate ? 'mixed' : checked}\n disabled={disabled && !disabledFocusable}\n {...focusableDisabledProps(disabledFocusable, { reachable: true })}\n onClick={\n disabledFocusable\n ? // Clicks, Space and Enter (which click a button) neither toggle nor reach `onClick`,\n // and, as a natively disabled control dispatches no click, no ancestor sees them.\n (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.stopPropagation();\n }\n : composeEventHandlers(onClick, () => setChecked((prev) => !prev))\n }\n className={cn(\n checkboxClassNames.indicator,\n // p-0 and the unchecked bg-transparent are set here, not left to the native reset, which\n // any app button style overrides (C-NATIVE).\n 'flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none',\n // Centred on the 20px first line of the label text.\n hasLabel && 'mt-px',\n focusRing,\n on\n ? cn(\n 'border-primary bg-primary text-primary-foreground',\n unavailable ? disabledCheckedBox : checkedBox,\n )\n : cn(\n 'border-stroke-accessible bg-transparent',\n unavailable ? forcedColors.disabled : forcedColors.control,\n ),\n )}\n >\n {indeterminate ? (\n <SubtractIcon size={12} className={glyphClassName} />\n ) : checked ? (\n <CheckIcon size={12} className={glyphClassName} />\n ) : null}\n </button>\n {labelPosition !== 'before' && labelText}\n <HiddenInput\n type=\"checkbox\"\n name={name}\n form={form}\n disabled={unavailable}\n value={value}\n checked={checked}\n required={isRequired}\n onInvalid={() => buttonRef.current?.focus()}\n />\n </label>\n );\n};\n\nCheckbox.displayName = 'Checkbox';\n"],"mappings":"qqBAsBA,IAAMmC,GAAa,gEACbC,GAAqB,4DACrBC,GAAgB,uEA4GTC,GAAY,CACvB,QAASC,EACT,iBAAiB,GACjB,gBAAgB,GAChB,kBACA,WACA,WAAW,GACX,oBAAoB,GACpB,QACA,gBAAgB,QAChB,QACA,SACA,WACA,OACA,MACA,aAAcC,EACd,kBAAmBC,EACnB,mBAAoBC,EACpB,eAAgBC,EAChB,gBAAiBC,EACjB,oBAAqBC,EACrB,eAAgBC,EAChB,gBAAiBC,EACjB,YACA,WACA,UACA,UACA,SACA,YACA,UACA,aACA,aACA,WACA,MACA,GAAGC,KACgB,CACfC,IAAa,IAAA,IAAW7B,EAAA,eAAe,WAAY,WAAY,iBAAiB,EACpF,IAAM8B,EAAclD,EAAAA,mBAAmBmD,CAAQ,EAC/ClB,EAAM,cAAgB,CAChBiB,GACF9B,EAAA,SACE,oBACA,iEACF,CAEJ,EAAG,CAAC8B,CAAW,CAAC,EAChB,GAAM,CAACE,EAASC,GAAcpD,GAAAA,gBAAgBsC,EAAae,EAAiB,GAAkB,CAC5FC,IAAkBC,CAAI,EACtBP,IAAWO,CAAI,CACjB,CAAC,EAEKC,GAAcvD,EAAAA,MAAM,UAAU,EAC9BwD,EAAcxD,EAAAA,MAAM,gBAAgB,EACpCyD,EAAQxD,EAAAA,gBAAgB,EACxByD,EAAaxD,EAAAA,gBAAgB,CACjC,MACA,aAAcoC,EACd,kBAAmBC,EACnB,mBAAoB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,GAA+C,CAC9CK,EAAM,eAAe,EACrBA,EAAM,gBAAgB,CACxB,EACAlE,GAAAA,qBAAqBmE,MAAe3B,EAAY,GAAS,CAAC4B,CAAI,CAAC,EAErE,UAAWxE,EAAAA,GACTC,EAAAA,mBAAmB,UAGnB,oIAEAqD,GAAY,QACZjD,EAAAA,UACAwD,GACI7D,EAAAA,GACE,oDACA+D,EAAcpC,GAAqBD,EACrC,EACA1B,EAAAA,GACE,0CACA+D,EAAchE,EAAAA,aAAa,SAAWA,EAAAA,aAAa,OACrD,CACN,EAEC,SAAA+D,GACC,EAAArC,EAAA,IAAA,CAACnB,EAAAA,aAAD,CAAc,KAAM,GAAI,UAAW4D,CAAiB,CAAA,EAClDvB,GACF,EAAAlB,EAAA,IAAA,CAAClB,EAAAA,UAAD,CAAW,KAAM,GAAI,UAAW2D,CAAiB,CAAA,EAC/C,IACE,CAAA,EACPE,IAAkB,UAAYD,GAC/B,EAAA1C,EAAA,IAAA,CAACjB,GAAAA,YAAD,CACE,KAAK,WACC,QACA,OACN,SAAUuD,EACH,SACE,UACT,SAAUV,EACV,cAAiBI,EAAU,SAAS,MAAM,CAC3C,CAAA,CACI,GAEX,EAEA,EAAS,YAAc"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { warnDeprecated as t, warnOnce as ee } from "../../lib/dev.mjs";
|
|
4
|
+
import { materialiseSlotContent as te, slotRendersContent as n } from "../../lib/slot.mjs";
|
|
5
|
+
import { composeEventHandlers as r } from "../../lib/composeEventHandlers.mjs";
|
|
6
|
+
import { checkboxClassNames as i } from "../../lib/classNames.mjs";
|
|
7
|
+
import { useControllable as ne } from "../../hooks/useControllable.mjs";
|
|
8
|
+
import { useId as a } from "../../hooks/useId.mjs";
|
|
9
|
+
import { useMergedRefs as re } from "../../hooks/useMergedRefs.mjs";
|
|
10
|
+
import { focusableDisabledProps as ie, joinIds as o } from "../../lib/aria.mjs";
|
|
11
|
+
import { useFieldContext as s, useFieldControl as c } from "../../hooks/useFieldControl.mjs";
|
|
12
|
+
import { focusRing as l, forcedColors as u } from "../../lib/styles.mjs";
|
|
13
|
+
import { CheckIcon as d, SubtractIcon as f } from "../../lib/icons.mjs";
|
|
14
|
+
import { useFormReset as ae } from "../../hooks/useFormReset.mjs";
|
|
15
|
+
import { HiddenInput as oe } from "../internal/HiddenInput.mjs";
|
|
16
|
+
import * as p from "react";
|
|
17
|
+
import { jsx as m, jsxs as se } from "react/jsx-runtime";
|
|
18
|
+
//#region src/components/input/Checkbox.tsx
|
|
19
|
+
var ce = "forced-colors:border-[Highlight] forced-colors:bg-[Highlight]", le = "forced-colors:border-[GrayText] forced-colors:bg-[Canvas]", ue = "forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none", h = ({ checked: h, defaultChecked: g = !1, indeterminate: _ = !1, onCheckedChange: de, onChange: v, disabled: y = !1, disabledFocusable: b = !1, label: x, labelPosition: S = "after", name: C, value: w, required: T, form: E, id: D, "aria-label": O, "aria-labelledby": k, "aria-describedby": A, "aria-invalid": j, "aria-required": M, "aria-errormessage": N, "aria-details": P, "aria-disabled": F, autoFocus: I, tabIndex: fe, onClick: L, onFocus: R, onBlur: z, onKeyDown: B, onKeyUp: V, controlRef: pe, className: me, children: he, ref: ge, ..._e }) => {
|
|
20
|
+
v !== void 0 && t("Checkbox", "onChange", "onCheckedChange");
|
|
21
|
+
let H = n(he);
|
|
22
|
+
p.useEffect(() => {
|
|
23
|
+
H && ee("Checkbox:children", "Checkbox: children are not rendered. Pass the label in `label`.");
|
|
24
|
+
}, [H]);
|
|
25
|
+
let [U, W] = ne(h, g, (e) => {
|
|
26
|
+
de?.(e), v?.(e);
|
|
27
|
+
}), ve = a("checkbox"), G = a("checkbox-label"), K = s(), q = c({
|
|
28
|
+
id: D,
|
|
29
|
+
"aria-label": O,
|
|
30
|
+
"aria-labelledby": k,
|
|
31
|
+
"aria-describedby": A,
|
|
32
|
+
"aria-invalid": j,
|
|
33
|
+
"aria-required": M ?? T
|
|
34
|
+
}), J = T ?? K?.required ?? !1, Y = n(x), ye = Y && q["aria-label"] === void 0 ? o(q["aria-labelledby"], K && q.id === K.controlId ? K.labelId : void 0, G) : q["aria-labelledby"], X = p.useRef(null), be = re(X, pe);
|
|
35
|
+
ae(X, () => W(g), E);
|
|
36
|
+
let xe = U || _, Z = y || b, Q = Z ? ue : u.selectedLeaf, $ = Y ? /* @__PURE__ */ m("span", {
|
|
37
|
+
id: G,
|
|
38
|
+
className: e(i.label, "text-body-1 text-foreground"),
|
|
39
|
+
children: te(x)
|
|
40
|
+
}) : null;
|
|
41
|
+
return /* @__PURE__ */ se("label", {
|
|
42
|
+
ref: ge,
|
|
43
|
+
"data-label-position": S,
|
|
44
|
+
className: e(i.root, "relative inline-flex items-start gap-2 select-none", Z ? "cursor-not-allowed opacity-50 has-focus-visible:opacity-100" : "cursor-pointer", me),
|
|
45
|
+
..._e,
|
|
46
|
+
children: [
|
|
47
|
+
S === "before" && $,
|
|
48
|
+
/* @__PURE__ */ m("button", {
|
|
49
|
+
id: ve,
|
|
50
|
+
type: "button",
|
|
51
|
+
...q,
|
|
52
|
+
"aria-labelledby": ye,
|
|
53
|
+
"aria-errormessage": N,
|
|
54
|
+
"aria-details": P,
|
|
55
|
+
"aria-disabled": F,
|
|
56
|
+
autoFocus: I,
|
|
57
|
+
tabIndex: fe,
|
|
58
|
+
onFocus: R,
|
|
59
|
+
onBlur: z,
|
|
60
|
+
onKeyDown: B,
|
|
61
|
+
onKeyUp: V,
|
|
62
|
+
ref: be,
|
|
63
|
+
role: "checkbox",
|
|
64
|
+
"aria-checked": _ ? "mixed" : U,
|
|
65
|
+
disabled: y && !b,
|
|
66
|
+
...ie(b, { reachable: !0 }),
|
|
67
|
+
onClick: b ? (e) => {
|
|
68
|
+
e.preventDefault(), e.stopPropagation();
|
|
69
|
+
} : r(L, () => W((e) => !e)),
|
|
70
|
+
className: e(i.indicator, "flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-xs border p-0 transition-colors motion-reduce:transition-none", Y && "mt-px", l, xe ? e("border-primary bg-primary text-primary-foreground", Z ? le : ce) : e("border-stroke-accessible bg-transparent", Z ? u.disabled : u.control)),
|
|
71
|
+
children: _ ? /* @__PURE__ */ m(f, {
|
|
72
|
+
size: 12,
|
|
73
|
+
className: Q
|
|
74
|
+
}) : U ? /* @__PURE__ */ m(d, {
|
|
75
|
+
size: 12,
|
|
76
|
+
className: Q
|
|
77
|
+
}) : null
|
|
78
|
+
}),
|
|
79
|
+
S !== "before" && $,
|
|
80
|
+
/* @__PURE__ */ m(oe, {
|
|
81
|
+
type: "checkbox",
|
|
82
|
+
name: C,
|
|
83
|
+
form: E,
|
|
84
|
+
disabled: Z,
|
|
85
|
+
value: w,
|
|
86
|
+
checked: U,
|
|
87
|
+
required: J,
|
|
88
|
+
onInvalid: () => X.current?.focus()
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
h.displayName = "Checkbox";
|
|
94
|
+
//#endregion
|
|
95
|
+
export { h as Checkbox };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=Checkbox.mjs.map
|