@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,2 @@
|
|
|
1
|
+
var e=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;function t(t){let n=e.exec(t.trim());if(!n)return null;let r=n[1],i=r.length<=4?r.split(``).map(e=>e+e).join(``):r,a=e=>parseInt(i.slice(e,e+2),16),o=i.length===8;return{r:a(0),g:a(2),b:a(4),alpha:o?a(6):255,hasAlpha:o}}function n(e){return Number.isFinite(e)?(e%360+360)%360:0}function r(e,t){return e===void 0||Number.isNaN(e)?t:Math.min(1,Math.max(0,e))}function i(e){let t=n(e.h)/60,i=r(e.s,0),a=r(e.v,0),o=a*i,s=o*(1-Math.abs(t%2-1)),c=a-o,l;return l=t<1?[o,s,0]:t<2?[s,o,0]:t<3?[0,o,s]:t<4?[0,s,o]:t<5?[s,0,o]:[o,0,s],{r:(l[0]+c)*255,g:(l[1]+c)*255,b:(l[2]+c)*255}}function a(e,t,n){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=o-Math.min(r,i,a),c=0;return s!==0&&(c=o===r?(i-a)/s%6:o===i?(a-r)/s+2:(r-i)/s+4,c*=60,c<0&&(c+=360)),{h:c,s:o===0?0:s/o,v:o}}function o(e){return Math.round(e).toString(16).padStart(2,`0`)}function s(e){let{r:t,g:n,b:a}=i(e),s=Math.round(r(e.a,1)*255),c=`#${o(t)}${o(n)}${o(a)}`;return s===255?c:c+o(s)}function c(e){let n=t(e);if(!n)return null;let{h:r,s:i,v:o}=a(n.r,n.g,n.b);return n.hasAlpha?{h:r,s:i,v:o,a:n.alpha/255}:{h:r,s:i,v:o}}exports.clampUnit=r,exports.hexToHsv=c,exports.hsvToHex=s,exports.hsvToRgb=i,exports.parseHexBytes=t,exports.rgbToHsv=a,exports.wrapHue=n;
|
|
2
|
+
//# sourceMappingURL=color.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.cjs","names":["HEX_COLOR","parseHexBytes","match","value","digits","long","d","byte","index","hasAlpha","wrapHue","h","clampUnit","fallback","hsvToRgb","color","s","v","c","x","m","rgb","rgbToHsv","red","r","green","g","blue","b","max","delta","toHexByte","hsvToHex","alpha","hex","hexToHsv","bytes"],"sources":["../../src/lib/color.ts"],"sourcesContent":["/**\n * Conversions between HSV colors and hex strings (spec P3-05, D18). Server-safe: no React and no\n * DOM, so the helpers run in a Server Component and during server rendering.\n *\n * Public: `hsvToHex` and `hexToHsv`, exported from the package entry. The other exports are\n * internal helpers of the color components (not exported from the package).\n */\nimport type { HsvColor } from './types';\n\nconst HEX_COLOR = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\n/** @internal The channels of a hex color as bytes (0–255). */\nexport interface HexBytes {\n r: number;\n g: number;\n b: number;\n /** The alpha byte; 255 when the input has no alpha digits. */\n alpha: number;\n /** Whether the input has alpha digits (`#rgba`, `#rrggbbaa`). */\n hasAlpha: boolean;\n}\n\n/**\n * @internal Parses `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` (surrounding whitespace ignored, any\n * case), else `null`. The one hex grammar of the library: `colorUtils.parseHexColor` reads it too.\n */\nexport function parseHexBytes(value: string): HexBytes | null {\n const match = HEX_COLOR.exec(value.trim());\n if (!match) return null;\n const digits = match[1];\n const long =\n digits.length <= 4\n ? digits\n .split('')\n .map((d) => d + d)\n .join('')\n : digits;\n const byte = (index: number) => parseInt(long.slice(index, index + 2), 16);\n const hasAlpha = long.length === 8;\n return { r: byte(0), g: byte(2), b: byte(4), alpha: hasAlpha ? byte(6) : 255, hasAlpha };\n}\n\n/** @internal `h` wrapped into [0, 360); a hue that is not finite reads as 0. */\nexport function wrapHue(h: number): number {\n return Number.isFinite(h) ? ((h % 360) + 360) % 360 : 0;\n}\n\n/** @internal `value` clamped to [0, 1]; `NaN` or `undefined` reads as `fallback`. */\nexport function clampUnit(value: number | undefined, fallback: number): number {\n if (value === undefined || Number.isNaN(value)) return fallback;\n return Math.min(1, Math.max(0, value));\n}\n\n/** @internal An HSV color, normalized first, as sRGB channels from 0 to 255 (unrounded). */\nexport function hsvToRgb(color: HsvColor): { r: number; g: number; b: number } {\n const h = wrapHue(color.h) / 60;\n const s = clampUnit(color.s, 0);\n const v = clampUnit(color.v, 0);\n const c = v * s;\n const x = c * (1 - Math.abs((h % 2) - 1));\n const m = v - c;\n let rgb: [number, number, number];\n if (h < 1) rgb = [c, x, 0];\n else if (h < 2) rgb = [x, c, 0];\n else if (h < 3) rgb = [0, c, x];\n else if (h < 4) rgb = [0, x, c];\n else if (h < 5) rgb = [x, 0, c];\n else rgb = [c, 0, x];\n return { r: (rgb[0] + m) * 255, g: (rgb[1] + m) * 255, b: (rgb[2] + m) * 255 };\n}\n\n/** @internal sRGB channels (0–255) as a hue in degrees and saturation and brightness from 0 to 1. */\nexport function rgbToHsv(r: number, g: number, b: number): { h: number; s: number; v: number } {\n const red = r / 255;\n const green = g / 255;\n const blue = b / 255;\n const max = Math.max(red, green, blue);\n const delta = max - Math.min(red, green, blue);\n let h = 0;\n if (delta !== 0) {\n if (max === red) h = ((green - blue) / delta) % 6;\n else if (max === green) h = (blue - red) / delta + 2;\n else h = (red - green) / delta + 4;\n h *= 60;\n if (h < 0) h += 360;\n }\n return { h, s: max === 0 ? 0 : delta / max, v: max };\n}\n\nfunction toHexByte(value: number): string {\n return Math.round(value).toString(16).padStart(2, '0');\n}\n\n/**\n * The hex string of an HSV color: lowercase `#rrggbb`, or `#rrggbbaa` when `a` is below 1\n * (ColorPicker's value format). The hue wraps into [0, 360); saturation, brightness and alpha are\n * clamped to [0, 1]; a channel that is not a number reads as 0 (alpha: as left out, so opaque).\n *\n * @example hsvToHex({ h: 208, s: 0.92, v: 0.74 }) // '#0f6cbd'\n */\nexport function hsvToHex(color: HsvColor): string {\n const { r, g, b } = hsvToRgb(color);\n const alpha = Math.round(clampUnit(color.a, 1) * 255);\n const hex = `#${toHexByte(r)}${toHexByte(g)}${toHexByte(b)}`;\n return alpha === 255 ? hex : hex + toHexByte(alpha);\n}\n\n/**\n * The HSV color of a hex string: `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` (surrounding whitespace\n * ignored, any case). `a` is set only when the input has alpha digits. Returns `null` for anything\n * else (named colors, `rgb()`, a missing `#`). `hsvToHex(hexToHsv(x))` gives `x` back in\n * ColorPicker's normal form.\n *\n * @example hexToHsv('#ff000080') // { h: 0, s: 1, v: 1, a: 0.50196… }\n */\nexport function hexToHsv(hex: string): HsvColor | null {\n const bytes = parseHexBytes(hex);\n if (!bytes) return null;\n const { h, s, v } = rgbToHsv(bytes.r, bytes.g, bytes.b);\n return bytes.hasAlpha ? { h, s, v, a: bytes.alpha / 255 } : { h, s, v };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//#region src/lib/color.ts
|
|
2
|
+
var e = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = e.exec(t.trim());
|
|
5
|
+
if (!n) return null;
|
|
6
|
+
let r = n[1], i = r.length <= 4 ? r.split("").map((e) => e + e).join("") : r, a = (e) => parseInt(i.slice(e, e + 2), 16), o = i.length === 8;
|
|
7
|
+
return {
|
|
8
|
+
r: a(0),
|
|
9
|
+
g: a(2),
|
|
10
|
+
b: a(4),
|
|
11
|
+
alpha: o ? a(6) : 255,
|
|
12
|
+
hasAlpha: o
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function n(e) {
|
|
16
|
+
return Number.isFinite(e) ? (e % 360 + 360) % 360 : 0;
|
|
17
|
+
}
|
|
18
|
+
function r(e, t) {
|
|
19
|
+
return e === void 0 || Number.isNaN(e) ? t : Math.min(1, Math.max(0, e));
|
|
20
|
+
}
|
|
21
|
+
function i(e) {
|
|
22
|
+
let t = n(e.h) / 60, i = r(e.s, 0), a = r(e.v, 0), o = a * i, s = o * (1 - Math.abs(t % 2 - 1)), c = a - o, l;
|
|
23
|
+
return l = t < 1 ? [
|
|
24
|
+
o,
|
|
25
|
+
s,
|
|
26
|
+
0
|
|
27
|
+
] : t < 2 ? [
|
|
28
|
+
s,
|
|
29
|
+
o,
|
|
30
|
+
0
|
|
31
|
+
] : t < 3 ? [
|
|
32
|
+
0,
|
|
33
|
+
o,
|
|
34
|
+
s
|
|
35
|
+
] : t < 4 ? [
|
|
36
|
+
0,
|
|
37
|
+
s,
|
|
38
|
+
o
|
|
39
|
+
] : t < 5 ? [
|
|
40
|
+
s,
|
|
41
|
+
0,
|
|
42
|
+
o
|
|
43
|
+
] : [
|
|
44
|
+
o,
|
|
45
|
+
0,
|
|
46
|
+
s
|
|
47
|
+
], {
|
|
48
|
+
r: (l[0] + c) * 255,
|
|
49
|
+
g: (l[1] + c) * 255,
|
|
50
|
+
b: (l[2] + c) * 255
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function a(e, t, n) {
|
|
54
|
+
let r = e / 255, i = t / 255, a = n / 255, o = Math.max(r, i, a), s = o - Math.min(r, i, a), c = 0;
|
|
55
|
+
return s !== 0 && (c = o === r ? (i - a) / s % 6 : o === i ? (a - r) / s + 2 : (r - i) / s + 4, c *= 60, c < 0 && (c += 360)), {
|
|
56
|
+
h: c,
|
|
57
|
+
s: o === 0 ? 0 : s / o,
|
|
58
|
+
v: o
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function o(e) {
|
|
62
|
+
return Math.round(e).toString(16).padStart(2, "0");
|
|
63
|
+
}
|
|
64
|
+
function s(e) {
|
|
65
|
+
let { r: t, g: n, b: a } = i(e), s = Math.round(r(e.a, 1) * 255), c = `#${o(t)}${o(n)}${o(a)}`;
|
|
66
|
+
return s === 255 ? c : c + o(s);
|
|
67
|
+
}
|
|
68
|
+
function c(e) {
|
|
69
|
+
let n = t(e);
|
|
70
|
+
if (!n) return null;
|
|
71
|
+
let { h: r, s: i, v: o } = a(n.r, n.g, n.b);
|
|
72
|
+
return n.hasAlpha ? {
|
|
73
|
+
h: r,
|
|
74
|
+
s: i,
|
|
75
|
+
v: o,
|
|
76
|
+
a: n.alpha / 255
|
|
77
|
+
} : {
|
|
78
|
+
h: r,
|
|
79
|
+
s: i,
|
|
80
|
+
v: o
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { r as clampUnit, c as hexToHsv, s as hsvToHex, i as hsvToRgb, t as parseHexBytes, a as rgbToHsv, n as wrapHue };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=color.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color.mjs","names":["HEX_COLOR","parseHexBytes","match","value","digits","long","d","byte","index","hasAlpha","wrapHue","h","clampUnit","fallback","hsvToRgb","color","s","v","c","x","m","rgb","rgbToHsv","red","r","green","g","blue","b","max","delta","toHexByte","hsvToHex","alpha","hex","hexToHsv","bytes"],"sources":["../../src/lib/color.ts"],"sourcesContent":["/**\n * Conversions between HSV colors and hex strings (spec P3-05, D18). Server-safe: no React and no\n * DOM, so the helpers run in a Server Component and during server rendering.\n *\n * Public: `hsvToHex` and `hexToHsv`, exported from the package entry. The other exports are\n * internal helpers of the color components (not exported from the package).\n */\nimport type { HsvColor } from './types';\n\nconst HEX_COLOR = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\n/** @internal The channels of a hex color as bytes (0–255). */\nexport interface HexBytes {\n r: number;\n g: number;\n b: number;\n /** The alpha byte; 255 when the input has no alpha digits. */\n alpha: number;\n /** Whether the input has alpha digits (`#rgba`, `#rrggbbaa`). */\n hasAlpha: boolean;\n}\n\n/**\n * @internal Parses `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` (surrounding whitespace ignored, any\n * case), else `null`. The one hex grammar of the library: `colorUtils.parseHexColor` reads it too.\n */\nexport function parseHexBytes(value: string): HexBytes | null {\n const match = HEX_COLOR.exec(value.trim());\n if (!match) return null;\n const digits = match[1];\n const long =\n digits.length <= 4\n ? digits\n .split('')\n .map((d) => d + d)\n .join('')\n : digits;\n const byte = (index: number) => parseInt(long.slice(index, index + 2), 16);\n const hasAlpha = long.length === 8;\n return { r: byte(0), g: byte(2), b: byte(4), alpha: hasAlpha ? byte(6) : 255, hasAlpha };\n}\n\n/** @internal `h` wrapped into [0, 360); a hue that is not finite reads as 0. */\nexport function wrapHue(h: number): number {\n return Number.isFinite(h) ? ((h % 360) + 360) % 360 : 0;\n}\n\n/** @internal `value` clamped to [0, 1]; `NaN` or `undefined` reads as `fallback`. */\nexport function clampUnit(value: number | undefined, fallback: number): number {\n if (value === undefined || Number.isNaN(value)) return fallback;\n return Math.min(1, Math.max(0, value));\n}\n\n/** @internal An HSV color, normalized first, as sRGB channels from 0 to 255 (unrounded). */\nexport function hsvToRgb(color: HsvColor): { r: number; g: number; b: number } {\n const h = wrapHue(color.h) / 60;\n const s = clampUnit(color.s, 0);\n const v = clampUnit(color.v, 0);\n const c = v * s;\n const x = c * (1 - Math.abs((h % 2) - 1));\n const m = v - c;\n let rgb: [number, number, number];\n if (h < 1) rgb = [c, x, 0];\n else if (h < 2) rgb = [x, c, 0];\n else if (h < 3) rgb = [0, c, x];\n else if (h < 4) rgb = [0, x, c];\n else if (h < 5) rgb = [x, 0, c];\n else rgb = [c, 0, x];\n return { r: (rgb[0] + m) * 255, g: (rgb[1] + m) * 255, b: (rgb[2] + m) * 255 };\n}\n\n/** @internal sRGB channels (0–255) as a hue in degrees and saturation and brightness from 0 to 1. */\nexport function rgbToHsv(r: number, g: number, b: number): { h: number; s: number; v: number } {\n const red = r / 255;\n const green = g / 255;\n const blue = b / 255;\n const max = Math.max(red, green, blue);\n const delta = max - Math.min(red, green, blue);\n let h = 0;\n if (delta !== 0) {\n if (max === red) h = ((green - blue) / delta) % 6;\n else if (max === green) h = (blue - red) / delta + 2;\n else h = (red - green) / delta + 4;\n h *= 60;\n if (h < 0) h += 360;\n }\n return { h, s: max === 0 ? 0 : delta / max, v: max };\n}\n\nfunction toHexByte(value: number): string {\n return Math.round(value).toString(16).padStart(2, '0');\n}\n\n/**\n * The hex string of an HSV color: lowercase `#rrggbb`, or `#rrggbbaa` when `a` is below 1\n * (ColorPicker's value format). The hue wraps into [0, 360); saturation, brightness and alpha are\n * clamped to [0, 1]; a channel that is not a number reads as 0 (alpha: as left out, so opaque).\n *\n * @example hsvToHex({ h: 208, s: 0.92, v: 0.74 }) // '#0f6cbd'\n */\nexport function hsvToHex(color: HsvColor): string {\n const { r, g, b } = hsvToRgb(color);\n const alpha = Math.round(clampUnit(color.a, 1) * 255);\n const hex = `#${toHexByte(r)}${toHexByte(g)}${toHexByte(b)}`;\n return alpha === 255 ? hex : hex + toHexByte(alpha);\n}\n\n/**\n * The HSV color of a hex string: `#rgb`, `#rgba`, `#rrggbb` or `#rrggbbaa` (surrounding whitespace\n * ignored, any case). `a` is set only when the input has alpha digits. Returns `null` for anything\n * else (named colors, `rgb()`, a missing `#`). `hsvToHex(hexToHsv(x))` gives `x` back in\n * ColorPicker's normal form.\n *\n * @example hexToHsv('#ff000080') // { h: 0, s: 1, v: 1, a: 0.50196… }\n */\nexport function hexToHsv(hex: string): HsvColor | null {\n const bytes = parseHexBytes(hex);\n if (!bytes) return null;\n const { h, s, v } = rgbToHsv(bytes.r, bytes.g, bytes.b);\n return bytes.hasAlpha ? { h, s, v, a: bytes.alpha / 255 } : { h, s, v };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeEventHandlers.cjs","names":["composeEventHandlers","checkDefaultPrevented","options","theirs","event","ours"],"sources":["../../src/lib/composeEventHandlers.ts"],"sourcesContent":["/**\n * Composes a consumer's event handler with a component's internal one (C-COMPOSE).\n *\n * The consumer handler (`theirs`) runs first; the internal handler (`ours`) runs afterwards unless\n * the event's default was prevented — by the consumer, or already upstream — so consumers can opt\n * out of built-in behaviour with `event.preventDefault()`. Pass `{ checkDefaultPrevented: false }`\n * for internal work that must always run (bookkeeping, state that mirrors the DOM).\n *\n * @example\n * <button onClick={composeEventHandlers(onClick, () => onSelect(value))} />\n */\nexport function composeEventHandlers<E extends { defaultPrevented: boolean }>(\n theirs?: (event: E) => void,\n ours?: (event: E) => void,\n options?: { checkDefaultPrevented?: boolean },\n): (event: E) => void {\n const checkDefaultPrevented = options?.checkDefaultPrevented !== false;\n return (event: E) => {\n theirs?.(event);\n if (!checkDefaultPrevented || !event.defaultPrevented) {\n ours?.(event);\n }\n };\n}\n"],"mappings":"AAWA,SAAgBA,EACd,EACA,EACA,EACoB,CACpB,IAAMC,EAAwBC,GAAS,wBAA0B,GACjE,MAAQ,IAAa,CACnBC,IAASC,CAAK,GACV,CAACH,GAAyB,CAACG,EAAM,mBACnCC,IAAOD,CAAK,CAEhB,CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/lib/composeEventHandlers.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
let r = n?.checkDefaultPrevented !== !1;
|
|
4
|
+
return (n) => {
|
|
5
|
+
e?.(n), (!r || !n.defaultPrevented) && t?.(n);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { e as composeEventHandlers };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=composeEventHandlers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeEventHandlers.mjs","names":["composeEventHandlers","checkDefaultPrevented","options","theirs","event","ours"],"sources":["../../src/lib/composeEventHandlers.ts"],"sourcesContent":["/**\n * Composes a consumer's event handler with a component's internal one (C-COMPOSE).\n *\n * The consumer handler (`theirs`) runs first; the internal handler (`ours`) runs afterwards unless\n * the event's default was prevented — by the consumer, or already upstream — so consumers can opt\n * out of built-in behaviour with `event.preventDefault()`. Pass `{ checkDefaultPrevented: false }`\n * for internal work that must always run (bookkeeping, state that mirrors the DOM).\n *\n * @example\n * <button onClick={composeEventHandlers(onClick, () => onSelect(value))} />\n */\nexport function composeEventHandlers<E extends { defaultPrevented: boolean }>(\n theirs?: (event: E) => void,\n ours?: (event: E) => void,\n options?: { checkDefaultPrevented?: boolean },\n): (event: E) => void {\n const checkDefaultPrevented = options?.checkDefaultPrevented !== false;\n return (event: E) => {\n theirs?.(event);\n if (!checkDefaultPrevented || !event.defaultPrevented) {\n ours?.(event);\n }\n };\n}\n"],"mappings":";AAWA,SAAgBA,EACd,GACA,GACA,GACoB;CACpB,IAAMC,IAAwBC,GAAS,0BAA0B;CACjE,QAAQ,MAAa;EAEnB,AADAC,IAASC,CAAK,IACV,CAACH,KAAyB,CAACG,EAAM,qBACnCC,IAAOD,CAAK;CAEhB;AACF"}
|
package/dist/lib/dev.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./globalRegistry.cjs");var t=`[WaveUI] `;function n(){try{return process.env.NODE_ENV!==`production`}catch{return!0}}var r=n();function i(){return e.getGlobalRegistry(`warnings`,()=>new Set)}function a(e,r){if(!n())return;let a=i();a.has(e)||(a.add(e),console.warn(t+r))}function o(e){return i().has(e)}function s(e,t,n,r){let i=`${e}: \`${t}\` is deprecated and will be removed in 1.0. Use \`${n}\` instead.`+(r?` ${r}`:``);a(`deprecated:${e}:${t}`,i)}function c(e,t,n,r,i){return n!==void 0&&s(e,r,i),t===void 0?n:t}function l(){return e.getGlobalRegistry(`missing-context`,()=>new Set)}function u(e,r,i){let a=t+(i??`${e} must be used within ${r}`);if(n())throw Error(a);let o=l();o.has(a)||(o.add(a),console.error(a))}exports.hasWarned=o,exports.isDev=r,exports.reportMissingContext=u,exports.resolveDeprecatedProp=c,exports.warnDeprecated=s,exports.warnOnce=a;
|
|
2
|
+
//# sourceMappingURL=dev.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.cjs","names":["getGlobalRegistry","require_globalRegistry","PREFIX","isDevEnvironment","isDev","getWarnedKeys","warnOnce","warned","key","message","hasWarned","warnDeprecated","component","oldName","newName","extra","resolveDeprecatedProp","oldValue","newValue","getReportedMissingContexts","reportMissingContext","text","componentName","parentName","reported"],"sources":["../../src/lib/dev.ts"],"sourcesContent":["import { getGlobalRegistry } from './globalRegistry';\n\nconst PREFIX = '[WaveUI] ';\n\n/**\n * Reads the bundler-injected `process.env.NODE_ENV` at call time. The expression is written out\n * literally so bundlers replace it (Vite, webpack, esbuild, Rollup); when no bundler replaced it and\n * `process` does not exist (an unbundled ESM import in the browser), development mode is assumed.\n */\nfunction isDevEnvironment(): boolean {\n try {\n return process.env.NODE_ENV !== 'production';\n } catch {\n return true;\n }\n}\n\n/**\n * `true` unless the consumer builds with `NODE_ENV=production`. Guard development-only work with\n * it (`if (isDev) { … }`). The warning helpers below already check the environment themselves.\n */\nexport const isDev: boolean = isDevEnvironment();\n\nfunction getWarnedKeys(): Set<string> {\n return getGlobalRegistry('warnings', () => new Set<string>());\n}\n\n/**\n * Logs a development warning prefixed with `[WaveUI] `. Not deduplicated; prefer {@link warnOnce}\n * for anything that can happen on every render. No-op in production.\n *\n * @param message The message without the prefix.\n */\nexport function devWarn(message: string): void {\n if (!isDevEnvironment()) return;\n console.warn(PREFIX + message);\n}\n\n/**\n * Logs a development warning once per `key` per page. The set of emitted keys lives in the global\n * registry (`getGlobalRegistry('warnings')`), so duplicate copies of the library share it, and it\n * is cleared between tests by {@link __resetWarnings}. No-op in production (the key is not consumed).\n *\n * Component diagnostics belong in effects (C-DEV). Because it is idempotent, the pure helpers built\n * on it — {@link resolveDeprecatedProp}, `resolveSlot`/`renderSlot` and `renderTrigger` — warn at\n * call time, which is safe during render: StrictMode double renders, discarded concurrent renders\n * and re-renders all log the key once.\n *\n * @param key Deduplication key, e.g. `'Tooltip:children'`.\n * @param message The message without the prefix.\n */\nexport function warnOnce(key: string, message: string): void {\n if (!isDevEnvironment()) return;\n const warned = getWarnedKeys();\n if (warned.has(key)) return;\n warned.add(key);\n console.warn(PREFIX + message);\n}\n\n/**\n * Whether {@link warnOnce} already emitted `key` (in any copy of the library, since the set lives\n * in the shared `'warnings'` global registry). A pure read: it never consumes the key, so a later\n * `warnOnce(key, …)` still warns when this returns `false`.\n *\n * Use it to skip development-only DOM work in an effect (a subtree scan, a focus-order check) once\n * its warning has fired. It returns `false` in production, where `warnOnce` consumes no key, so\n * guard that work with {@link isDev} as well.\n *\n * @param key The deduplication key passed to `warnOnce`, e.g. `'Card:nested-interactive'`.\n */\nexport function hasWarned(key: string): boolean {\n return getWarnedKeys().has(key);\n}\n\n/**\n * Warns once per (component, prop) that a prop or value is deprecated (§5.10 format):\n *\n * `[WaveUI] TabList: \\`selectedValue\\` is deprecated and will be removed in 1.0. Use \\`value\\` instead.`\n *\n * @param component The public component name, e.g. `'TabList'`.\n * @param oldName The deprecated prop or value.\n * @param newName Its replacement.\n * @param extra Optional extra sentence appended to the message.\n */\nexport function warnDeprecated(\n component: string,\n oldName: string,\n newName: string,\n extra?: string,\n): void {\n const message =\n `${component}: \\`${oldName}\\` is deprecated and will be removed in 1.0. Use \\`${newName}\\` instead.` +\n (extra ? ` ${extra}` : '');\n warnOnce(`deprecated:${component}:${oldName}`, message);\n}\n\n/**\n * Resolves a renamed prop: returns `newValue` when it is defined, otherwise `oldValue`. Warns once\n * (via {@link warnDeprecated}) whenever the deprecated prop is used, including when both are given\n * (the new value wins, C-NAMING).\n *\n * The warning is emitted at call time, and calling it during render is the intended use: the\n * warn-once key makes it idempotent, so StrictMode double renders and re-renders log once per page\n * (a C-DEV call-time exception, like `resolveSlot` and `renderTrigger`). A component that must\n * warn from an effect instead resolves `newValue !== undefined ? newValue : oldValue` itself and\n * calls {@link warnDeprecated} in that effect.\n *\n * @example\n * const orientation = resolveDeprecatedProp('Stack', props.orientation, props.direction, 'direction', 'orientation') ?? 'vertical';\n */\nexport function resolveDeprecatedProp<T>(\n component: string,\n newValue: T | undefined,\n oldValue: T | undefined,\n oldName: string,\n newName: string,\n): T | undefined {\n if (oldValue !== undefined) warnDeprecated(component, oldName, newName);\n return newValue !== undefined ? newValue : oldValue;\n}\n\nfunction getReportedMissingContexts(): Set<string> {\n return getGlobalRegistry('missing-context', () => new Set<string>());\n}\n\n/**\n * The C-CONTEXT guard for a compound part rendered outside its root: call it from the context\n * hook when the context is `null`, then return the hook's inert value.\n *\n * The text is `[WaveUI] <componentName> must be used within <parentName>`, or `[WaveUI] <message>`\n * when `message` is given. In development it throws `new Error(text)`. In production it logs the\n * text with `console.error` once per text per page (not on every render of every misplaced\n * instance) and returns; the set of logged texts lives in the global registry\n * (`getGlobalRegistry('missing-context')`), shared by every copy of the library and cleared\n * between tests by {@link __resetWarnings}.\n *\n * @param componentName The part as the consumer writes it, e.g. `'TabList.Tab'`.\n * @param parentName The root it must be rendered in, e.g. `'<TabList>'`.\n * @param message Replaces the default text (without the prefix).\n *\n * @example\n * function useTabListContext(component: string): TabListContextValue {\n * const context = React.useContext(TabListContext);\n * if (context) return context;\n * reportMissingContext(component, '<TabList>');\n * return INERT_CONTEXT;\n * }\n */\nexport function reportMissingContext(\n componentName: string,\n parentName: string,\n message?: string,\n): void {\n const text = PREFIX + (message ?? `${componentName} must be used within ${parentName}`);\n if (isDevEnvironment()) throw new Error(text);\n const reported = getReportedMissingContexts();\n if (reported.has(text)) return;\n reported.add(text);\n console.error(text);\n}\n\n/**\n * Test-only: forgets every emitted warn-once key and every missing-context text logged by\n * {@link reportMissingContext}, so each test starts clean (called from `src/test-setup.ts` after\n * each test).\n */\nexport function __resetWarnings(): void {\n getWarnedKeys().clear();\n getReportedMissingContexts().clear();\n}\n"],"mappings":"wCAEA,IAAME,EAAS,YAOf,SAASC,GAA4B,CACnC,GAAI,CACF,OAAA,QAAA,IAAA,WAAgC,YAClC,MAAQ,CACN,MAAO,EACT,CACF,CAMA,IAAaC,EAAiBD,EAAiB,EAE/C,SAASE,GAA6B,CACpC,OAAOL,EAAAA,kBAAkB,eAAkB,IAAI,GAAa,CAC9D,CA0BA,SAAgBM,EAAS,EAAa,EAAuB,CAC3D,GAAI,CAACH,EAAiB,EAAG,OACzB,IAAMI,EAASF,EAAc,EACzBE,EAAO,IAAIC,CAAG,IAClBD,EAAO,IAAIC,CAAG,EACd,QAAQ,KAAKN,EAASO,CAAO,EAC/B,CAaA,SAAgBC,EAAU,EAAsB,CAC9C,OAAOL,EAAc,CAAC,CAAC,IAAIG,CAAG,CAChC,CAYA,SAAgBG,EACd,EACA,EACA,EACA,EACM,CACN,IAAMF,EACJ,GAAGG,EAAU,MAAMC,EAAQ,qDAAqDC,EAAQ,cACvFC,EAAQ,IAAIA,IAAU,IACzBT,EAAS,cAAcM,EAAU,GAAGC,IAAWJ,CAAO,CACxD,CAgBA,SAAgBO,EACd,EACA,EACA,EACA,EACA,EACe,CAEf,OADIC,IAAa,IAAA,IAAWN,EAAeC,EAAWC,EAASC,CAAO,EAC/DI,IAAa,IAAA,GAAuBD,EAAXC,CAClC,CAEA,SAASC,GAA0C,CACjD,OAAOnB,EAAAA,kBAAkB,sBAAyB,IAAI,GAAa,CACrE,CAyBA,SAAgBoB,EACd,EACA,EACA,EACM,CACN,IAAMC,EAAOnB,GAAUO,GAAW,GAAGa,EAAc,uBAAuBC,KAC1E,GAAIpB,EAAiB,EAAG,MAAU,MAAMkB,CAAI,EAC5C,IAAMG,EAAWL,EAA2B,EACxCK,EAAS,IAAIH,CAAI,IACrBG,EAAS,IAAIH,CAAI,EACjB,QAAQ,MAAMA,CAAI,EACpB"}
|
package/dist/lib/dev.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getGlobalRegistry as e } from "./globalRegistry.mjs";
|
|
2
|
+
//#region src/lib/dev.ts
|
|
3
|
+
var t = "[WaveUI] ";
|
|
4
|
+
function n() {
|
|
5
|
+
try {
|
|
6
|
+
return process.env.NODE_ENV !== "production";
|
|
7
|
+
} catch {
|
|
8
|
+
return !0;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
var r = n();
|
|
12
|
+
function i() {
|
|
13
|
+
return e("warnings", () => /* @__PURE__ */ new Set());
|
|
14
|
+
}
|
|
15
|
+
function a(e, r) {
|
|
16
|
+
if (!n()) return;
|
|
17
|
+
let a = i();
|
|
18
|
+
a.has(e) || (a.add(e), console.warn(t + r));
|
|
19
|
+
}
|
|
20
|
+
function o(e) {
|
|
21
|
+
return i().has(e);
|
|
22
|
+
}
|
|
23
|
+
function s(e, t, n, r) {
|
|
24
|
+
let i = `${e}: \`${t}\` is deprecated and will be removed in 1.0. Use \`${n}\` instead.` + (r ? ` ${r}` : "");
|
|
25
|
+
a(`deprecated:${e}:${t}`, i);
|
|
26
|
+
}
|
|
27
|
+
function c(e, t, n, r, i) {
|
|
28
|
+
return n !== void 0 && s(e, r, i), t === void 0 ? n : t;
|
|
29
|
+
}
|
|
30
|
+
function l() {
|
|
31
|
+
return e("missing-context", () => /* @__PURE__ */ new Set());
|
|
32
|
+
}
|
|
33
|
+
function u(e, r, i) {
|
|
34
|
+
let a = t + (i ?? `${e} must be used within ${r}`);
|
|
35
|
+
if (n()) throw Error(a);
|
|
36
|
+
let o = l();
|
|
37
|
+
o.has(a) || (o.add(a), console.error(a));
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { o as hasWarned, r as isDev, u as reportMissingContext, c as resolveDeprecatedProp, s as warnDeprecated, a as warnOnce };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=dev.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.mjs","names":["PREFIX","isDevEnvironment","isDev","getWarnedKeys","getGlobalRegistry","warnOnce","warned","key","message","hasWarned","warnDeprecated","component","oldName","newName","extra","resolveDeprecatedProp","oldValue","newValue","getReportedMissingContexts","reportMissingContext","text","componentName","parentName","reported"],"sources":["../../src/lib/dev.ts"],"sourcesContent":["import { getGlobalRegistry } from './globalRegistry';\n\nconst PREFIX = '[WaveUI] ';\n\n/**\n * Reads the bundler-injected `process.env.NODE_ENV` at call time. The expression is written out\n * literally so bundlers replace it (Vite, webpack, esbuild, Rollup); when no bundler replaced it and\n * `process` does not exist (an unbundled ESM import in the browser), development mode is assumed.\n */\nfunction isDevEnvironment(): boolean {\n try {\n return process.env.NODE_ENV !== 'production';\n } catch {\n return true;\n }\n}\n\n/**\n * `true` unless the consumer builds with `NODE_ENV=production`. Guard development-only work with\n * it (`if (isDev) { … }`). The warning helpers below already check the environment themselves.\n */\nexport const isDev: boolean = isDevEnvironment();\n\nfunction getWarnedKeys(): Set<string> {\n return getGlobalRegistry('warnings', () => new Set<string>());\n}\n\n/**\n * Logs a development warning prefixed with `[WaveUI] `. Not deduplicated; prefer {@link warnOnce}\n * for anything that can happen on every render. No-op in production.\n *\n * @param message The message without the prefix.\n */\nexport function devWarn(message: string): void {\n if (!isDevEnvironment()) return;\n console.warn(PREFIX + message);\n}\n\n/**\n * Logs a development warning once per `key` per page. The set of emitted keys lives in the global\n * registry (`getGlobalRegistry('warnings')`), so duplicate copies of the library share it, and it\n * is cleared between tests by {@link __resetWarnings}. No-op in production (the key is not consumed).\n *\n * Component diagnostics belong in effects (C-DEV). Because it is idempotent, the pure helpers built\n * on it — {@link resolveDeprecatedProp}, `resolveSlot`/`renderSlot` and `renderTrigger` — warn at\n * call time, which is safe during render: StrictMode double renders, discarded concurrent renders\n * and re-renders all log the key once.\n *\n * @param key Deduplication key, e.g. `'Tooltip:children'`.\n * @param message The message without the prefix.\n */\nexport function warnOnce(key: string, message: string): void {\n if (!isDevEnvironment()) return;\n const warned = getWarnedKeys();\n if (warned.has(key)) return;\n warned.add(key);\n console.warn(PREFIX + message);\n}\n\n/**\n * Whether {@link warnOnce} already emitted `key` (in any copy of the library, since the set lives\n * in the shared `'warnings'` global registry). A pure read: it never consumes the key, so a later\n * `warnOnce(key, …)` still warns when this returns `false`.\n *\n * Use it to skip development-only DOM work in an effect (a subtree scan, a focus-order check) once\n * its warning has fired. It returns `false` in production, where `warnOnce` consumes no key, so\n * guard that work with {@link isDev} as well.\n *\n * @param key The deduplication key passed to `warnOnce`, e.g. `'Card:nested-interactive'`.\n */\nexport function hasWarned(key: string): boolean {\n return getWarnedKeys().has(key);\n}\n\n/**\n * Warns once per (component, prop) that a prop or value is deprecated (§5.10 format):\n *\n * `[WaveUI] TabList: \\`selectedValue\\` is deprecated and will be removed in 1.0. Use \\`value\\` instead.`\n *\n * @param component The public component name, e.g. `'TabList'`.\n * @param oldName The deprecated prop or value.\n * @param newName Its replacement.\n * @param extra Optional extra sentence appended to the message.\n */\nexport function warnDeprecated(\n component: string,\n oldName: string,\n newName: string,\n extra?: string,\n): void {\n const message =\n `${component}: \\`${oldName}\\` is deprecated and will be removed in 1.0. Use \\`${newName}\\` instead.` +\n (extra ? ` ${extra}` : '');\n warnOnce(`deprecated:${component}:${oldName}`, message);\n}\n\n/**\n * Resolves a renamed prop: returns `newValue` when it is defined, otherwise `oldValue`. Warns once\n * (via {@link warnDeprecated}) whenever the deprecated prop is used, including when both are given\n * (the new value wins, C-NAMING).\n *\n * The warning is emitted at call time, and calling it during render is the intended use: the\n * warn-once key makes it idempotent, so StrictMode double renders and re-renders log once per page\n * (a C-DEV call-time exception, like `resolveSlot` and `renderTrigger`). A component that must\n * warn from an effect instead resolves `newValue !== undefined ? newValue : oldValue` itself and\n * calls {@link warnDeprecated} in that effect.\n *\n * @example\n * const orientation = resolveDeprecatedProp('Stack', props.orientation, props.direction, 'direction', 'orientation') ?? 'vertical';\n */\nexport function resolveDeprecatedProp<T>(\n component: string,\n newValue: T | undefined,\n oldValue: T | undefined,\n oldName: string,\n newName: string,\n): T | undefined {\n if (oldValue !== undefined) warnDeprecated(component, oldName, newName);\n return newValue !== undefined ? newValue : oldValue;\n}\n\nfunction getReportedMissingContexts(): Set<string> {\n return getGlobalRegistry('missing-context', () => new Set<string>());\n}\n\n/**\n * The C-CONTEXT guard for a compound part rendered outside its root: call it from the context\n * hook when the context is `null`, then return the hook's inert value.\n *\n * The text is `[WaveUI] <componentName> must be used within <parentName>`, or `[WaveUI] <message>`\n * when `message` is given. In development it throws `new Error(text)`. In production it logs the\n * text with `console.error` once per text per page (not on every render of every misplaced\n * instance) and returns; the set of logged texts lives in the global registry\n * (`getGlobalRegistry('missing-context')`), shared by every copy of the library and cleared\n * between tests by {@link __resetWarnings}.\n *\n * @param componentName The part as the consumer writes it, e.g. `'TabList.Tab'`.\n * @param parentName The root it must be rendered in, e.g. `'<TabList>'`.\n * @param message Replaces the default text (without the prefix).\n *\n * @example\n * function useTabListContext(component: string): TabListContextValue {\n * const context = React.useContext(TabListContext);\n * if (context) return context;\n * reportMissingContext(component, '<TabList>');\n * return INERT_CONTEXT;\n * }\n */\nexport function reportMissingContext(\n componentName: string,\n parentName: string,\n message?: string,\n): void {\n const text = PREFIX + (message ?? `${componentName} must be used within ${parentName}`);\n if (isDevEnvironment()) throw new Error(text);\n const reported = getReportedMissingContexts();\n if (reported.has(text)) return;\n reported.add(text);\n console.error(text);\n}\n\n/**\n * Test-only: forgets every emitted warn-once key and every missing-context text logged by\n * {@link reportMissingContext}, so each test starts clean (called from `src/test-setup.ts` after\n * each test).\n */\nexport function __resetWarnings(): void {\n getWarnedKeys().clear();\n getReportedMissingContexts().clear();\n}\n"],"mappings":";;AAEA,IAAMA,IAAS;AAOf,SAASC,IAA4B;CACnC,IAAI;EACF,OAAA,QAAA,IAAA,aAAgC;CAClC,QAAQ;EACN,OAAO;CACT;AACF;AAMA,IAAaC,IAAiBD,EAAiB;AAE/C,SAASE,IAA6B;CACpC,OAAOC,EAAkB,kCAAkB,IAAI,IAAY,CAAC;AAC9D;AA0BA,SAAgBC,EAAS,GAAa,GAAuB;CAC3D,IAAI,CAACJ,EAAiB,GAAG;CACzB,IAAMK,IAASH,EAAc;CAC7B,AAAIG,EAAO,IAAIC,CAAG,MAClBD,EAAO,IAAIC,CAAG,GACd,QAAQ,KAAKP,IAASQ,CAAO;AAC/B;AAaA,SAAgBC,EAAU,GAAsB;CAC9C,OAAON,EAAc,CAAC,CAAC,IAAII,CAAG;AAChC;AAYA,SAAgBG,EACd,GACA,GACA,GACA,GACM;CACN,IAAMF,IACJ,GAAGG,EAAU,MAAMC,EAAQ,qDAAqDC,EAAQ,gBACvFC,IAAQ,IAAIA,MAAU;CACzB,EAAS,cAAcH,EAAU,GAAGC,KAAWJ,CAAO;AACxD;AAgBA,SAAgBO,EACd,GACA,GACA,GACA,GACA,GACe;CAEf,OADIC,MAAa,KAAA,KAAWN,EAAeC,GAAWC,GAASC,CAAO,GAC/DI,MAAa,KAAA,IAAuBD,IAAXC;AAClC;AAEA,SAASC,IAA0C;CACjD,OAAOd,EAAkB,yCAAyB,IAAI,IAAY,CAAC;AACrE;AAyBA,SAAgBe,EACd,GACA,GACA,GACM;CACN,IAAMC,IAAOpB,KAAUQ,KAAW,GAAGa,EAAc,uBAAuBC;CAC1E,IAAIrB,EAAiB,GAAG,MAAU,MAAMmB,CAAI;CAC5C,IAAMG,IAAWL,EAA2B;CAC5C,AAAIK,EAAS,IAAIH,CAAI,MACrBG,EAAS,IAAIH,CAAI,GACjB,QAAQ,MAAMA,CAAI;AACpB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){let t=e?.trim().toLowerCase();return t===`rtl`||t===`ltr`?t:null}function t(t){if(typeof document>`u`)return`ltr`;let n=t??document.documentElement,r=n.closest(`[dir]`);for(;r;){let t=r.getAttribute(`dir`),n=e(t);if(n)return n;if(t?.trim().toLowerCase()===`auto`)break;r=r.parentElement?r.parentElement.closest(`[dir]`):null}let i=n.ownerDocument.defaultView;if(i&&n.isConnected)for(let t=n;t;t=t.parentElement){let n=e(i.getComputedStyle(t).direction);if(n)return n}return e(n.ownerDocument.dir)??e(document.dir)??`ltr`}function n(e,t){let{orientation:n,dir:r}=t,i=n===`horizontal`||n===`both`,a=n===`vertical`||n===`both`;switch(e){case`ArrowRight`:return i?r===`rtl`?`prev`:`next`:null;case`ArrowLeft`:return i?r===`rtl`?`next`:`prev`:null;case`ArrowDown`:return a?`next`:null;case`ArrowUp`:return a?`prev`:null;default:return null}}exports.getArrowIntent=n,exports.getDirection=t;
|
|
2
|
+
//# sourceMappingURL=direction.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.cjs","names":["asDirection","normalised","value","getDirection","start","el","node","direction","view","current","computed","getArrowIntent","options","horizontal","orientation","vertical","key","dir"],"sources":["../../src/lib/direction.ts"],"sourcesContent":["/** Writing direction. */\nexport type Direction = 'ltr' | 'rtl';\n\n/** The axis (or axes) an arrow-key navigation follows. */\nexport type ArrowOrientation = 'horizontal' | 'vertical' | 'both';\n\n/** What an arrow key means for a composite: move to the next or previous item, or nothing. */\nexport type ArrowIntent = 'next' | 'prev' | null;\n\nfunction asDirection(value: string | null | undefined): Direction | null {\n const normalised = value?.trim().toLowerCase();\n return normalised === 'rtl' || normalised === 'ltr' ? normalised : null;\n}\n\n/**\n * The writing direction that applies to `el`:\n * 1. the nearest `[dir=\"ltr\" | \"rtl\"]` attribute on `el` or an ancestor (`dir=\"auto\"` stops the\n * search, because only the browser can resolve it);\n * 2. the computed CSS `direction` of `el` (or of its nearest ancestor that reports one);\n * 3. `document.dir`;\n * 4. `'ltr'`.\n *\n * Without an element it reads `document.documentElement`. Returns `'ltr'` on the server.\n * Components with a WaveProvider context read `useDirection()` during render and call this\n * at event time (`getDirection(event.currentTarget)`).\n */\nexport function getDirection(el?: Element | null): Direction {\n if (typeof document === 'undefined') return 'ltr';\n const start = el ?? document.documentElement;\n\n let node: Element | null = start.closest('[dir]');\n while (node) {\n const value = node.getAttribute('dir');\n const direction = asDirection(value);\n if (direction) return direction;\n if (value?.trim().toLowerCase() === 'auto') break;\n node = node.parentElement ? node.parentElement.closest('[dir]') : null;\n }\n\n const view = start.ownerDocument.defaultView;\n if (view && start.isConnected) {\n for (let current: Element | null = start; current; current = current.parentElement) {\n const computed = asDirection(view.getComputedStyle(current).direction);\n if (computed) return computed;\n }\n }\n\n return asDirection(start.ownerDocument.dir) ?? asDirection(document.dir) ?? 'ltr';\n}\n\n/**\n * Maps an arrow key to a navigation intent for a composite widget (C-LOGICAL):\n * - `'horizontal'`: ArrowRight/ArrowLeft (swapped in `rtl`); Up/Down are ignored.\n * - `'vertical'`: ArrowDown/ArrowUp; Left/Right are ignored.\n * - `'both'`: all four (Left/Right swapped in `rtl`).\n *\n * @example\n * const intent = getArrowIntent(event.key, { orientation: 'horizontal', dir: getDirection(event.currentTarget) });\n */\nexport function getArrowIntent(\n key: string,\n options: { orientation: ArrowOrientation; dir: Direction },\n): ArrowIntent {\n const { orientation, dir } = options;\n const horizontal = orientation === 'horizontal' || orientation === 'both';\n const vertical = orientation === 'vertical' || orientation === 'both';\n\n switch (key) {\n case 'ArrowRight':\n return horizontal ? (dir === 'rtl' ? 'prev' : 'next') : null;\n case 'ArrowLeft':\n return horizontal ? (dir === 'rtl' ? 'next' : 'prev') : null;\n case 'ArrowDown':\n return vertical ? 'next' : null;\n case 'ArrowUp':\n return vertical ? 'prev' : null;\n default:\n return null;\n }\n}\n"],"mappings":"AASA,SAASA,EAAY,EAAoD,CACvE,IAAMC,EAAaC,GAAO,KAAK,CAAC,CAAC,YAAY,EAC7C,OAAOD,IAAe,OAASA,IAAe,MAAQA,EAAa,IACrE,CAcA,SAAgBE,EAAa,EAAgC,CAC3D,GAAI,OAAO,SAAa,IAAa,MAAO,MAC5C,IAAMC,EAAQC,GAAM,SAAS,gBAEzBC,EAAuBF,EAAM,QAAQ,OAAO,EAChD,KAAOE,GAAM,CACX,IAAMJ,EAAQI,EAAK,aAAa,KAAK,EAC/BC,EAAYP,EAAYE,CAAK,EACnC,GAAIK,EAAW,OAAOA,EACtB,GAAIL,GAAO,KAAK,CAAC,CAAC,YAAY,IAAM,OAAQ,MAC5C,EAAOI,EAAK,cAAgBA,EAAK,cAAc,QAAQ,OAAO,EAAI,IACpE,CAEA,IAAME,EAAOJ,EAAM,cAAc,YACjC,GAAII,GAAQJ,EAAM,YAChB,IAAK,IAAIK,EAA0BL,EAAOK,EAAS,EAAUA,EAAQ,cAAe,CAClF,IAAMC,EAAWV,EAAYQ,EAAK,iBAAiBC,CAAO,CAAC,CAAC,SAAS,EACrE,GAAIC,EAAU,OAAOA,CACvB,CAGF,OAAOV,EAAYI,EAAM,cAAc,GAAG,GAAKJ,EAAY,SAAS,GAAG,GAAK,KAC9E,CAWA,SAAgBW,EACd,EACA,EACa,CACb,GAAM,CAAE,cAAa,OAAQC,EACvBC,EAAaC,IAAgB,cAAgBA,IAAgB,OAC7DC,EAAWD,IAAgB,YAAcA,IAAgB,OAE/D,OAAQE,EAAR,CACE,IAAK,aACH,OAAOH,EAAcI,IAAQ,MAAQ,OAAS,OAAU,KAC1D,IAAK,YACH,OAAOJ,EAAcI,IAAQ,MAAQ,OAAS,OAAU,KAC1D,IAAK,YACH,OAAOF,EAAW,OAAS,KAC7B,IAAK,UACH,OAAOA,EAAW,OAAS,KAC7B,QACE,OAAO,IACX,CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/lib/direction.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = e?.trim().toLowerCase();
|
|
4
|
+
return t === "rtl" || t === "ltr" ? t : null;
|
|
5
|
+
}
|
|
6
|
+
function t(t) {
|
|
7
|
+
if (typeof document > "u") return "ltr";
|
|
8
|
+
let n = t ?? document.documentElement, r = n.closest("[dir]");
|
|
9
|
+
for (; r;) {
|
|
10
|
+
let t = r.getAttribute("dir"), n = e(t);
|
|
11
|
+
if (n) return n;
|
|
12
|
+
if (t?.trim().toLowerCase() === "auto") break;
|
|
13
|
+
r = r.parentElement ? r.parentElement.closest("[dir]") : null;
|
|
14
|
+
}
|
|
15
|
+
let i = n.ownerDocument.defaultView;
|
|
16
|
+
if (i && n.isConnected) for (let t = n; t; t = t.parentElement) {
|
|
17
|
+
let n = e(i.getComputedStyle(t).direction);
|
|
18
|
+
if (n) return n;
|
|
19
|
+
}
|
|
20
|
+
return e(n.ownerDocument.dir) ?? e(document.dir) ?? "ltr";
|
|
21
|
+
}
|
|
22
|
+
function n(e, t) {
|
|
23
|
+
let { orientation: n, dir: r } = t, i = n === "horizontal" || n === "both", a = n === "vertical" || n === "both";
|
|
24
|
+
switch (e) {
|
|
25
|
+
case "ArrowRight": return i ? r === "rtl" ? "prev" : "next" : null;
|
|
26
|
+
case "ArrowLeft": return i ? r === "rtl" ? "next" : "prev" : null;
|
|
27
|
+
case "ArrowDown": return a ? "next" : null;
|
|
28
|
+
case "ArrowUp": return a ? "prev" : null;
|
|
29
|
+
default: return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { n as getArrowIntent, t as getDirection };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=direction.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.mjs","names":["asDirection","normalised","value","getDirection","start","el","node","direction","view","current","computed","getArrowIntent","options","horizontal","orientation","vertical","key","dir"],"sources":["../../src/lib/direction.ts"],"sourcesContent":["/** Writing direction. */\nexport type Direction = 'ltr' | 'rtl';\n\n/** The axis (or axes) an arrow-key navigation follows. */\nexport type ArrowOrientation = 'horizontal' | 'vertical' | 'both';\n\n/** What an arrow key means for a composite: move to the next or previous item, or nothing. */\nexport type ArrowIntent = 'next' | 'prev' | null;\n\nfunction asDirection(value: string | null | undefined): Direction | null {\n const normalised = value?.trim().toLowerCase();\n return normalised === 'rtl' || normalised === 'ltr' ? normalised : null;\n}\n\n/**\n * The writing direction that applies to `el`:\n * 1. the nearest `[dir=\"ltr\" | \"rtl\"]` attribute on `el` or an ancestor (`dir=\"auto\"` stops the\n * search, because only the browser can resolve it);\n * 2. the computed CSS `direction` of `el` (or of its nearest ancestor that reports one);\n * 3. `document.dir`;\n * 4. `'ltr'`.\n *\n * Without an element it reads `document.documentElement`. Returns `'ltr'` on the server.\n * Components with a WaveProvider context read `useDirection()` during render and call this\n * at event time (`getDirection(event.currentTarget)`).\n */\nexport function getDirection(el?: Element | null): Direction {\n if (typeof document === 'undefined') return 'ltr';\n const start = el ?? document.documentElement;\n\n let node: Element | null = start.closest('[dir]');\n while (node) {\n const value = node.getAttribute('dir');\n const direction = asDirection(value);\n if (direction) return direction;\n if (value?.trim().toLowerCase() === 'auto') break;\n node = node.parentElement ? node.parentElement.closest('[dir]') : null;\n }\n\n const view = start.ownerDocument.defaultView;\n if (view && start.isConnected) {\n for (let current: Element | null = start; current; current = current.parentElement) {\n const computed = asDirection(view.getComputedStyle(current).direction);\n if (computed) return computed;\n }\n }\n\n return asDirection(start.ownerDocument.dir) ?? asDirection(document.dir) ?? 'ltr';\n}\n\n/**\n * Maps an arrow key to a navigation intent for a composite widget (C-LOGICAL):\n * - `'horizontal'`: ArrowRight/ArrowLeft (swapped in `rtl`); Up/Down are ignored.\n * - `'vertical'`: ArrowDown/ArrowUp; Left/Right are ignored.\n * - `'both'`: all four (Left/Right swapped in `rtl`).\n *\n * @example\n * const intent = getArrowIntent(event.key, { orientation: 'horizontal', dir: getDirection(event.currentTarget) });\n */\nexport function getArrowIntent(\n key: string,\n options: { orientation: ArrowOrientation; dir: Direction },\n): ArrowIntent {\n const { orientation, dir } = options;\n const horizontal = orientation === 'horizontal' || orientation === 'both';\n const vertical = orientation === 'vertical' || orientation === 'both';\n\n switch (key) {\n case 'ArrowRight':\n return horizontal ? (dir === 'rtl' ? 'prev' : 'next') : null;\n case 'ArrowLeft':\n return horizontal ? (dir === 'rtl' ? 'next' : 'prev') : null;\n case 'ArrowDown':\n return vertical ? 'next' : null;\n case 'ArrowUp':\n return vertical ? 'prev' : null;\n default:\n return null;\n }\n}\n"],"mappings":";AASA,SAASA,EAAY,GAAoD;CACvE,IAAMC,IAAaC,GAAO,KAAK,CAAC,CAAC,YAAY;CAC7C,OAAOD,MAAe,SAASA,MAAe,QAAQA,IAAa;AACrE;AAcA,SAAgBE,EAAa,GAAgC;CAC3D,IAAI,OAAO,WAAa,KAAa,OAAO;CAC5C,IAAMC,IAAQC,KAAM,SAAS,iBAEzBC,IAAuBF,EAAM,QAAQ,OAAO;CAChD,OAAOE,IAAM;EACX,IAAMJ,IAAQI,EAAK,aAAa,KAAK,GAC/BC,IAAYP,EAAYE,CAAK;EACnC,IAAIK,GAAW,OAAOA;EACtB,IAAIL,GAAO,KAAK,CAAC,CAAC,YAAY,MAAM,QAAQ;EAC5C,IAAOI,EAAK,gBAAgBA,EAAK,cAAc,QAAQ,OAAO,IAAI;CACpE;CAEA,IAAME,IAAOJ,EAAM,cAAc;CACjC,IAAII,KAAQJ,EAAM,aAChB,KAAK,IAAIK,IAA0BL,GAAOK,GAAS,IAAUA,EAAQ,eAAe;EAClF,IAAMC,IAAWV,EAAYQ,EAAK,iBAAiBC,CAAO,CAAC,CAAC,SAAS;EACrE,IAAIC,GAAU,OAAOA;CACvB;CAGF,OAAOV,EAAYI,EAAM,cAAc,GAAG,KAAKJ,EAAY,SAAS,GAAG,KAAK;AAC9E;AAWA,SAAgBW,EACd,GACA,GACa;CACb,IAAM,EAAE,gBAAa,WAAQC,GACvBC,IAAaC,MAAgB,gBAAgBA,MAAgB,QAC7DC,IAAWD,MAAgB,cAAcA,MAAgB;CAE/D,QAAQE,GAAR;EACE,KAAK,cACH,OAAOH,IAAcI,MAAQ,QAAQ,SAAS,SAAU;EAC1D,KAAK,aACH,OAAOJ,IAAcI,MAAQ,QAAQ,SAAS,SAAU;EAC1D,KAAK,aACH,OAAOF,IAAW,SAAS;EAC7B,KAAK,WACH,OAAOA,IAAW,SAAS;EAC7B,SACE,OAAO;CACX;AACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e){let t=e.target;return!!t&&typeof t.nodeType==`number`&&e.currentTarget.contains(t)}function t(e){let t=e.target,n=typeof t?.closest==`function`?t.closest(`[aria-disabled="true"]`):null;return n!==null&&e.currentTarget.contains(n)}var n=new Set([`text`,`search`,`url`,`tel`,`email`,`password`,`number`]);function r(e){if(!e||e.nodeType!==1)return!1;let t=e;if(t.localName===`textarea`)return!0;if(t.localName===`input`)return n.has(t.type);if(typeof t.isContentEditable==`boolean`)return t.isContentEditable;let r=t.closest(`[contenteditable]`);return r!==null&&r.getAttribute(`contenteditable`)!==`false`}exports.isDisabledTrigger=t,exports.isEditableTarget=r,exports.isOwnEvent=e;
|
|
2
|
+
//# sourceMappingURL=events.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.cjs","names":["isOwnEvent","target","event","isDisabledTrigger","disabled","TEXT_INPUT_TYPES","isEditableTarget","el","editable"],"sources":["../../src/lib/events.ts"],"sourcesContent":["import type * as React from 'react';\n\n/**\n * Event predicates shared by the menu, popover, hover and context-menu code. Server-safe: this\n * module imports nothing from React at run time.\n */\n\n/**\n * Whether an event started in the element that handles it (`currentTarget`) or inside its DOM.\n * React bubbles the events of a portal (a Popover or Dialog opened from an item) through the item\n * and the menu surface although their target lives elsewhere in the document: those are not the\n * menu's to handle. The target is duck typed, so a menu rendered into another realm's document\n * (an iframe) still handles its own events.\n */\nexport function isOwnEvent(event: React.SyntheticEvent<HTMLElement>): boolean {\n const target = event.target as Partial<Node> | null;\n return (\n !!target && typeof target.nodeType === 'number' && event.currentTarget.contains(target as Node)\n );\n}\n\n/**\n * Whether an event comes from an `aria-disabled=\"true\"` element at or inside the element that\n * handles it (`currentTarget`): the trigger element itself, or the focusable element inside a\n * wrapper span, where `currentTarget` is the span. An `aria-disabled` ancestor outside the trigger\n * does not count.\n */\nexport function isDisabledTrigger(event: React.SyntheticEvent<HTMLElement>): boolean {\n const target = event.target as Partial<Element> | null;\n const disabled =\n typeof target?.closest === 'function' ? target.closest('[aria-disabled=\"true\"]') : null;\n return disabled !== null && event.currentTarget.contains(disabled);\n}\n\n/** `<input>` types whose value is text the user edits (a missing or unknown type is `text`). */\nconst TEXT_INPUT_TYPES = new Set(['text', 'search', 'url', 'tel', 'email', 'password', 'number']);\n\n/**\n * Whether `target` is a field where the browser's own context menu matters (paste, spelling\n * suggestions): a text-type `<input>` (`text`, `search`, `url`, `tel`, `email`, `password`,\n * `number`, or no `type`), a `<textarea>`, or an element whose `isContentEditable` is `true`\n * (read from the nearest `contenteditable` attribute where the engine lacks the property). Duck\n * typed, so an element of another realm (an iframe) counts too.\n */\nexport function isEditableTarget(target: EventTarget | null): boolean {\n if (!target || (target as Partial<Node>).nodeType !== 1) return false;\n const el = target as HTMLElement;\n if (el.localName === 'textarea') return true;\n if (el.localName === 'input') return TEXT_INPUT_TYPES.has((el as HTMLInputElement).type);\n if (typeof el.isContentEditable === 'boolean') return el.isContentEditable;\n const editable = el.closest('[contenteditable]');\n return editable !== null && editable.getAttribute('contenteditable') !== 'false';\n}\n"],"mappings":"AAcA,SAAgBA,EAAW,EAAmD,CAC5E,IAAMC,EAASC,EAAM,OACrB,MACE,CAAC,CAACD,GAAU,OAAOA,EAAO,UAAa,UAAYC,EAAM,cAAc,SAASD,CAAc,CAElG,CAQA,SAAgBE,EAAkB,EAAmD,CACnF,IAAMF,EAASC,EAAM,OACfE,EACJ,OAAOH,GAAQ,SAAY,WAAaA,EAAO,QAAQ,wBAAwB,EAAI,KACrF,OAAOG,IAAa,MAAQF,EAAM,cAAc,SAASE,CAAQ,CACnE,CAGA,IAAMC,EAAmB,IAAI,IAAI,CAAC,OAAQ,SAAU,MAAO,MAAO,QAAS,WAAY,QAAQ,CAAC,EAShG,SAAgBC,EAAiB,EAAqC,CACpE,GAAI,CAACL,GAAWA,EAAyB,WAAa,EAAG,MAAO,GAChE,IAAMM,EAAKN,EACX,GAAIM,EAAG,YAAc,WAAY,MAAO,GACxC,GAAIA,EAAG,YAAc,QAAS,OAAOF,EAAiB,IAAKE,EAAwB,IAAI,EACvF,GAAI,OAAOA,EAAG,mBAAsB,UAAW,OAAOA,EAAG,kBACzD,IAAMC,EAAWD,EAAG,QAAQ,mBAAmB,EAC/C,OAAOC,IAAa,MAAQA,EAAS,aAAa,iBAAiB,IAAM,OAC3E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/lib/events.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = e.target;
|
|
4
|
+
return !!t && typeof t.nodeType == "number" && e.currentTarget.contains(t);
|
|
5
|
+
}
|
|
6
|
+
function t(e) {
|
|
7
|
+
let t = e.target, n = typeof t?.closest == "function" ? t.closest("[aria-disabled=\"true\"]") : null;
|
|
8
|
+
return n !== null && e.currentTarget.contains(n);
|
|
9
|
+
}
|
|
10
|
+
var n = /* @__PURE__ */ new Set([
|
|
11
|
+
"text",
|
|
12
|
+
"search",
|
|
13
|
+
"url",
|
|
14
|
+
"tel",
|
|
15
|
+
"email",
|
|
16
|
+
"password",
|
|
17
|
+
"number"
|
|
18
|
+
]);
|
|
19
|
+
function r(e) {
|
|
20
|
+
if (!e || e.nodeType !== 1) return !1;
|
|
21
|
+
let t = e;
|
|
22
|
+
if (t.localName === "textarea") return !0;
|
|
23
|
+
if (t.localName === "input") return n.has(t.type);
|
|
24
|
+
if (typeof t.isContentEditable == "boolean") return t.isContentEditable;
|
|
25
|
+
let r = t.closest("[contenteditable]");
|
|
26
|
+
return r !== null && r.getAttribute("contenteditable") !== "false";
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { t as isDisabledTrigger, r as isEditableTarget, e as isOwnEvent };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=events.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.mjs","names":["isOwnEvent","target","event","isDisabledTrigger","disabled","TEXT_INPUT_TYPES","isEditableTarget","el","editable"],"sources":["../../src/lib/events.ts"],"sourcesContent":["import type * as React from 'react';\n\n/**\n * Event predicates shared by the menu, popover, hover and context-menu code. Server-safe: this\n * module imports nothing from React at run time.\n */\n\n/**\n * Whether an event started in the element that handles it (`currentTarget`) or inside its DOM.\n * React bubbles the events of a portal (a Popover or Dialog opened from an item) through the item\n * and the menu surface although their target lives elsewhere in the document: those are not the\n * menu's to handle. The target is duck typed, so a menu rendered into another realm's document\n * (an iframe) still handles its own events.\n */\nexport function isOwnEvent(event: React.SyntheticEvent<HTMLElement>): boolean {\n const target = event.target as Partial<Node> | null;\n return (\n !!target && typeof target.nodeType === 'number' && event.currentTarget.contains(target as Node)\n );\n}\n\n/**\n * Whether an event comes from an `aria-disabled=\"true\"` element at or inside the element that\n * handles it (`currentTarget`): the trigger element itself, or the focusable element inside a\n * wrapper span, where `currentTarget` is the span. An `aria-disabled` ancestor outside the trigger\n * does not count.\n */\nexport function isDisabledTrigger(event: React.SyntheticEvent<HTMLElement>): boolean {\n const target = event.target as Partial<Element> | null;\n const disabled =\n typeof target?.closest === 'function' ? target.closest('[aria-disabled=\"true\"]') : null;\n return disabled !== null && event.currentTarget.contains(disabled);\n}\n\n/** `<input>` types whose value is text the user edits (a missing or unknown type is `text`). */\nconst TEXT_INPUT_TYPES = new Set(['text', 'search', 'url', 'tel', 'email', 'password', 'number']);\n\n/**\n * Whether `target` is a field where the browser's own context menu matters (paste, spelling\n * suggestions): a text-type `<input>` (`text`, `search`, `url`, `tel`, `email`, `password`,\n * `number`, or no `type`), a `<textarea>`, or an element whose `isContentEditable` is `true`\n * (read from the nearest `contenteditable` attribute where the engine lacks the property). Duck\n * typed, so an element of another realm (an iframe) counts too.\n */\nexport function isEditableTarget(target: EventTarget | null): boolean {\n if (!target || (target as Partial<Node>).nodeType !== 1) return false;\n const el = target as HTMLElement;\n if (el.localName === 'textarea') return true;\n if (el.localName === 'input') return TEXT_INPUT_TYPES.has((el as HTMLInputElement).type);\n if (typeof el.isContentEditable === 'boolean') return el.isContentEditable;\n const editable = el.closest('[contenteditable]');\n return editable !== null && editable.getAttribute('contenteditable') !== 'false';\n}\n"],"mappings":";AAcA,SAAgBA,EAAW,GAAmD;CAC5E,IAAMC,IAASC,EAAM;CACrB,OACE,CAAC,CAACD,KAAU,OAAOA,EAAO,YAAa,YAAYC,EAAM,cAAc,SAASD,CAAc;AAElG;AAQA,SAAgBE,EAAkB,GAAmD;CACnF,IAAMF,IAASC,EAAM,QACfE,IACJ,OAAOH,GAAQ,WAAY,aAAaA,EAAO,QAAQ,0BAAwB,IAAI;CACrF,OAAOG,MAAa,QAAQF,EAAM,cAAc,SAASE,CAAQ;AACnE;AAGA,IAAMC,oBAAmB,IAAI,IAAI;CAAC;CAAQ;CAAU;CAAO;CAAO;CAAS;CAAY;AAAQ,CAAC;AAShG,SAAgBC,EAAiB,GAAqC;CACpE,IAAI,CAACL,KAAWA,EAAyB,aAAa,GAAG,OAAO;CAChE,IAAMM,IAAKN;CACX,IAAIM,EAAG,cAAc,YAAY,OAAO;CACxC,IAAIA,EAAG,cAAc,SAAS,OAAOF,EAAiB,IAAKE,EAAwB,IAAI;CACvF,IAAI,OAAOA,EAAG,qBAAsB,WAAW,OAAOA,EAAG;CACzD,IAAMC,IAAWD,EAAG,QAAQ,mBAAmB;CAC/C,OAAOC,MAAa,QAAQA,EAAS,aAAa,iBAAiB,MAAM;AAC3E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=[`a[href]`,`area[href]`,`button`,`input`,`select`,`textarea`,`iframe`,`audio[controls]`,`video[controls]`,`summary`,`[contenteditable]:not([contenteditable="false"])`].join(`, `),t=`${e}, [tabindex]`;function n(e){let t=e.getAttribute(`tabindex`);if(t===null)return null;let n=Number.parseInt(t,10);return Number.isNaN(n)?null:n}function r(t){return t.matches(e)}function i(e){let t=n(e);return t===null?r(e)?0:-1:t}function a(e){try{return e.matches(`:disabled`)}catch{return e.disabled===!0}}function o(e){return e.localName===`input`&&e.type===`hidden`}function s(e){let t=e.parentElement;return!t||t.localName!==`details`?!1:Array.from(t.children).find(e=>e.localName===`summary`)===e}function c(e){let t=e.ownerDocument.defaultView;return t?t.getComputedStyle(e):null}function l(e,t){let n=t?.get(e);if(n!==void 0)return n;let r=!1;if(e.hasAttribute(`hidden`)||c(e)?.display===`none`)r=!0;else{let n=e.parentElement;n&&(r=n.localName===`details`&&!n.hasAttribute(`open`)&&e!==Array.from(n.children).find(e=>e.localName===`summary`)||l(n,t))}return t?.set(e,r),r}function u(e,t){if(e.closest(`[inert]`)||l(e,t))return!0;let n=c(e)?.visibility;return n===`hidden`||n===`collapse`}function d(e,t){return!r(e)&&n(e)===null||a(e)||o(e)||e.localName===`summary`&&!s(e)&&n(e)===null?!1:!u(e,t)}function f(e){let t=e.form;return(t?Array.from(t.elements):Array.from(e.getRootNode().querySelectorAll(`input[type="radio"]`))).filter(n=>n.localName===`input`&&n.type===`radio`&&n.name===e.name&&n.form===t)}function p(e){return e.getRootNode().activeElement??null}function m(e){if(e.localName!==`input`)return!0;let t=e;if(t.type!==`radio`||!t.name)return!0;let n=f(t),r=p(t);if(r&&n.includes(r))return r===t;let i=n.find(e=>e.checked);return!i||i===t}function h(e,t){return d(e,t)&&i(e)>=0&&m(e)}function g(e){return d(e)}function _(e,n){let r=new Map,a=Array.from(e.querySelectorAll(t));n?.includeContainer&&e.matches(t)&&a.unshift(e);let o=a.filter(e=>h(e,r)),s=o.map((e,t)=>({el:e,index:t,tabIndex:i(e)})).filter(e=>e.tabIndex>0).sort((e,t)=>e.tabIndex-t.tabIndex||e.index-t.index).map(e=>e.el),c=o.filter(e=>i(e)===0);return[...s,...c]}function v(e,t){return _(e,t)[0]??null}function y(e,t){let n=_(e,t);return n[n.length-1]??null}function b(e){return!!e&&e.isConnected&&g(e)}function x(e,t){if(!e||!b(e))return!1;try{e.focus(t)}catch{return!1}return e.ownerDocument.activeElement===e}exports.FOCUSABLE_SELECTOR=t,exports.focusElement=x,exports.getFirstTabbable=v,exports.getLastTabbable=y,exports.getTabbableElements=_,exports.isConnectedAndFocusable=b,exports.isFocusable=g,exports.isHiddenInput=o;
|
|
2
|
+
//# sourceMappingURL=focus.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.cjs","names":["NATIVELY_FOCUSABLE_SELECTOR","FOCUSABLE_SELECTOR","parseTabIndexAttribute","value","el","parsed","isNativelyFocusable","getTabIndex","attribute","isDisabled","isHiddenInput","isDetailsSummary","parent","summary","child","getComputed","view","isRemovedFromLayout","cached","cache","hidden","isHidden","visibility","isFocusableInternal","getRadioGroup","form","radio","getActiveElementFor","isRadioTabStop","group","active","checked","member","isTabbableInternal","isFocusable","getTabbableElements","candidates","container","options","tabbable","positive","entry","a","b","natural","getFirstTabbable","getLastTabbable","isConnectedAndFocusable","focusElement"],"sources":["../../src/lib/focus.ts"],"sourcesContent":["/**\n * Focus utilities that work in browsers and in jsdom (no layout APIs such as `offsetParent` or\n * `getClientRects`; visibility comes from attributes and computed style).\n */\n\nconst NATIVELY_FOCUSABLE_SELECTOR = [\n 'a[href]',\n 'area[href]',\n 'button',\n 'input',\n 'select',\n 'textarea',\n 'iframe',\n 'audio[controls]',\n 'video[controls]',\n 'summary',\n '[contenteditable]:not([contenteditable=\"false\"])',\n].join(', ');\n\n/**\n * Selector for every element that may be able to receive focus. Candidates are filtered further by\n * {@link isFocusable} (disabled, hidden, inert, …) and {@link isTabbable}.\n */\nexport const FOCUSABLE_SELECTOR = `${NATIVELY_FOCUSABLE_SELECTOR}, [tabindex]`;\n\ntype HiddenCache = Map<Element, boolean>;\n\nfunction parseTabIndexAttribute(el: Element): number | null {\n const value = el.getAttribute('tabindex');\n if (value === null) return null;\n const parsed = Number.parseInt(value, 10);\n return Number.isNaN(parsed) ? null : parsed;\n}\n\nfunction isNativelyFocusable(el: Element): boolean {\n return el.matches(NATIVELY_FOCUSABLE_SELECTOR);\n}\n\n/** The tab index browsers use (jsdom reports -1 for contenteditable and 0 for `<a>` without href). */\nfunction getTabIndex(el: Element): number {\n const attribute = parseTabIndexAttribute(el);\n if (attribute !== null) return attribute;\n return isNativelyFocusable(el) ? 0 : -1;\n}\n\nfunction isDisabled(el: Element): boolean {\n try {\n return el.matches(':disabled');\n } catch {\n return (el as { disabled?: unknown }).disabled === true;\n }\n}\n\n/** Whether `el` is an `<input type=\"hidden\">` (a form value, never focusable). */\nexport function isHiddenInput(el: Element): boolean {\n return el.localName === 'input' && (el as HTMLInputElement).type === 'hidden';\n}\n\n/** `<summary>` is focusable only as the first summary child of a `<details>`. */\nfunction isDetailsSummary(summary: Element): boolean {\n const parent = summary.parentElement;\n if (!parent || parent.localName !== 'details') return false;\n return Array.from(parent.children).find((child) => child.localName === 'summary') === summary;\n}\n\nfunction getComputed(el: Element): CSSStyleDeclaration | null {\n const view = el.ownerDocument.defaultView;\n return view ? view.getComputedStyle(el) : null;\n}\n\n/** Hidden by `hidden`, `display: none` on itself or an ancestor, or a closed `<details>`. */\nfunction isRemovedFromLayout(el: Element, cache?: HiddenCache): boolean {\n const cached = cache?.get(el);\n if (cached !== undefined) return cached;\n\n let hidden = false;\n if (el.hasAttribute('hidden') || getComputed(el)?.display === 'none') {\n hidden = true;\n } else {\n const parent = el.parentElement;\n if (parent) {\n if (parent.localName === 'details' && !parent.hasAttribute('open')) {\n // Only the first <summary> of a closed <details> is rendered.\n const summary = Array.from(parent.children).find((child) => child.localName === 'summary');\n hidden = el !== summary || isRemovedFromLayout(parent, cache);\n } else {\n hidden = isRemovedFromLayout(parent, cache);\n }\n }\n }\n\n cache?.set(el, hidden);\n return hidden;\n}\n\nfunction isHidden(el: Element, cache?: HiddenCache): boolean {\n if (el.closest('[inert]')) return true;\n if (isRemovedFromLayout(el, cache)) return true;\n const visibility = getComputed(el)?.visibility;\n return visibility === 'hidden' || visibility === 'collapse';\n}\n\nfunction isFocusableInternal(el: Element, cache?: HiddenCache): boolean {\n if (!isNativelyFocusable(el) && parseTabIndexAttribute(el) === null) return false;\n if (isDisabled(el) || isHiddenInput(el)) return false;\n if (el.localName === 'summary' && !isDetailsSummary(el) && parseTabIndexAttribute(el) === null) {\n return false;\n }\n return !isHidden(el, cache);\n}\n\nfunction getRadioGroup(radio: HTMLInputElement): HTMLInputElement[] {\n const form = radio.form;\n const candidates: Element[] = form\n ? Array.from(form.elements)\n : Array.from(\n (radio.getRootNode() as Document | ShadowRoot).querySelectorAll('input[type=\"radio\"]'),\n );\n return candidates.filter(\n (el): el is HTMLInputElement =>\n el.localName === 'input' &&\n (el as HTMLInputElement).type === 'radio' &&\n (el as HTMLInputElement).name === radio.name &&\n (el as HTMLInputElement).form === form,\n );\n}\n\n/**\n * The focused element of `el`'s document or shadow root (`null` when `el` is disconnected). Duck\n * typed rather than `instanceof`, so elements of another realm (iframes) work too.\n */\nfunction getActiveElementFor(el: Element): Element | null {\n const root = el.getRootNode() as Node & { activeElement?: Element | null };\n return root.activeElement ?? null;\n}\n\n/**\n * A named radio group is one tab stop, following browsers (Chromium's\n * `RadioInputType::IsKeyboardFocusable`, the `tabbable` library):\n * - while focus is on a member of the group, only that member (Tab and Shift+Tab leave the group);\n * - otherwise the checked radio (the whole group is skipped when it cannot take focus);\n * - otherwise, with no checked radio, every member: Tab enters at the first one, Shift+Tab at the\n * last one, so both `getFirstTabbable` and `getLastTabbable` return the browser's entry radio.\n * Members that are not focusable (disabled, hidden) are filtered out before this check.\n */\nfunction isRadioTabStop(el: Element): boolean {\n if (el.localName !== 'input') return true;\n const radio = el as HTMLInputElement;\n if (radio.type !== 'radio' || !radio.name) return true;\n const group = getRadioGroup(radio);\n const active = getActiveElementFor(radio);\n if (active && (group as Element[]).includes(active)) return active === radio;\n const checked = group.find((member) => member.checked);\n return checked ? checked === radio : true;\n}\n\nfunction isTabbableInternal(el: Element, cache?: HiddenCache): boolean {\n return isFocusableInternal(el, cache) && getTabIndex(el) >= 0 && isRadioTabStop(el);\n}\n\n/**\n * Whether `el` can receive focus (programmatically or by pointer): a natively focusable element or\n * one with a valid `tabindex`, that is not disabled (including via a disabled `<fieldset>`), not\n * `input[type=hidden]`, and not inside `[inert]`, `[hidden]`, `display: none`, `visibility:\n * hidden` or a closed `<details>` (except its summary).\n */\nexport function isFocusable(el: Element): boolean {\n return isFocusableInternal(el);\n}\n\n/**\n * Whether `el` is reached by Tab: focusable, `tabIndex >= 0`, and — for a radio in a named group —\n * the group's tab stop: the focused member while focus is in the group, else the checked radio,\n * else (nothing checked) every focusable member, as browsers enter such a group at its first radio\n * going forward and at its last radio going backward.\n */\nexport function isTabbable(el: Element): boolean {\n return isTabbableInternal(el);\n}\n\n/**\n * The tabbable elements inside `container` in sequential focus order: positive `tabindex` first\n * (ascending), then `tabindex=0` / natively tabbable elements in document order. Named radio\n * groups follow {@link isTabbable}, so the result depends on where focus currently is: when focus\n * is on a radio, the rest of its group is left out, which makes the focused radio the last entry\n * when its group ends the container (the element a focus trap wraps from).\n *\n * @param options.includeContainer Also consider `container` itself.\n */\nexport function getTabbableElements(\n container: Element,\n options?: { includeContainer?: boolean },\n): HTMLElement[] {\n const cache: HiddenCache = new Map();\n const candidates = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR));\n if (options?.includeContainer && container.matches(FOCUSABLE_SELECTOR)) {\n candidates.unshift(container as HTMLElement);\n }\n const tabbable = candidates.filter((el) => isTabbableInternal(el, cache));\n const positive = tabbable\n .map((el, index) => ({ el, index, tabIndex: getTabIndex(el) }))\n .filter((entry) => entry.tabIndex > 0)\n .sort((a, b) => a.tabIndex - b.tabIndex || a.index - b.index)\n .map((entry) => entry.el);\n const natural = tabbable.filter((el) => getTabIndex(el) === 0);\n return [...positive, ...natural];\n}\n\n/** The first tabbable element inside `container`, or `null`. */\nexport function getFirstTabbable(\n container: Element,\n options?: { includeContainer?: boolean },\n): HTMLElement | null {\n return getTabbableElements(container, options)[0] ?? null;\n}\n\n/** The last tabbable element inside `container`, or `null`. */\nexport function getLastTabbable(\n container: Element,\n options?: { includeContainer?: boolean },\n): HTMLElement | null {\n const tabbable = getTabbableElements(container, options);\n return tabbable[tabbable.length - 1] ?? null;\n}\n\n/** Whether `el` exists, is attached to a document and {@link isFocusable}. */\nexport function isConnectedAndFocusable(el: Element | null | undefined): boolean {\n return !!el && el.isConnected && isFocusable(el);\n}\n\n/**\n * Focuses `el` when it is connected and focusable. Returns `true` when focus actually moved to it.\n */\nexport function focusElement(\n el: HTMLElement | SVGElement | null | undefined,\n options?: FocusOptions,\n): boolean {\n if (!el || !isConnectedAndFocusable(el)) return false;\n try {\n el.focus(options);\n } catch {\n return false;\n }\n return el.ownerDocument.activeElement === el;\n}\n\n/** Whether the focused element of `container`'s document is `container` or inside it. */\nexport function containsFocus(container: Element | null | undefined): boolean {\n if (!container) return false;\n const active = container.ownerDocument.activeElement;\n return !!active && container.contains(active);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
//#region src/lib/focus.ts
|
|
2
|
+
var e = [
|
|
3
|
+
"a[href]",
|
|
4
|
+
"area[href]",
|
|
5
|
+
"button",
|
|
6
|
+
"input",
|
|
7
|
+
"select",
|
|
8
|
+
"textarea",
|
|
9
|
+
"iframe",
|
|
10
|
+
"audio[controls]",
|
|
11
|
+
"video[controls]",
|
|
12
|
+
"summary",
|
|
13
|
+
"[contenteditable]:not([contenteditable=\"false\"])"
|
|
14
|
+
].join(", "), t = `${e}, [tabindex]`;
|
|
15
|
+
function n(e) {
|
|
16
|
+
let t = e.getAttribute("tabindex");
|
|
17
|
+
if (t === null) return null;
|
|
18
|
+
let n = Number.parseInt(t, 10);
|
|
19
|
+
return Number.isNaN(n) ? null : n;
|
|
20
|
+
}
|
|
21
|
+
function r(t) {
|
|
22
|
+
return t.matches(e);
|
|
23
|
+
}
|
|
24
|
+
function i(e) {
|
|
25
|
+
let t = n(e);
|
|
26
|
+
return t === null ? r(e) ? 0 : -1 : t;
|
|
27
|
+
}
|
|
28
|
+
function a(e) {
|
|
29
|
+
try {
|
|
30
|
+
return e.matches(":disabled");
|
|
31
|
+
} catch {
|
|
32
|
+
return e.disabled === !0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function o(e) {
|
|
36
|
+
return e.localName === "input" && e.type === "hidden";
|
|
37
|
+
}
|
|
38
|
+
function s(e) {
|
|
39
|
+
let t = e.parentElement;
|
|
40
|
+
return !t || t.localName !== "details" ? !1 : Array.from(t.children).find((e) => e.localName === "summary") === e;
|
|
41
|
+
}
|
|
42
|
+
function c(e) {
|
|
43
|
+
let t = e.ownerDocument.defaultView;
|
|
44
|
+
return t ? t.getComputedStyle(e) : null;
|
|
45
|
+
}
|
|
46
|
+
function l(e, t) {
|
|
47
|
+
let n = t?.get(e);
|
|
48
|
+
if (n !== void 0) return n;
|
|
49
|
+
let r = !1;
|
|
50
|
+
if (e.hasAttribute("hidden") || c(e)?.display === "none") r = !0;
|
|
51
|
+
else {
|
|
52
|
+
let n = e.parentElement;
|
|
53
|
+
n && (r = n.localName === "details" && !n.hasAttribute("open") && e !== Array.from(n.children).find((e) => e.localName === "summary") || l(n, t));
|
|
54
|
+
}
|
|
55
|
+
return t?.set(e, r), r;
|
|
56
|
+
}
|
|
57
|
+
function u(e, t) {
|
|
58
|
+
if (e.closest("[inert]") || l(e, t)) return !0;
|
|
59
|
+
let n = c(e)?.visibility;
|
|
60
|
+
return n === "hidden" || n === "collapse";
|
|
61
|
+
}
|
|
62
|
+
function d(e, t) {
|
|
63
|
+
return !r(e) && n(e) === null || a(e) || o(e) || e.localName === "summary" && !s(e) && n(e) === null ? !1 : !u(e, t);
|
|
64
|
+
}
|
|
65
|
+
function f(e) {
|
|
66
|
+
let t = e.form;
|
|
67
|
+
return (t ? Array.from(t.elements) : Array.from(e.getRootNode().querySelectorAll("input[type=\"radio\"]"))).filter((n) => n.localName === "input" && n.type === "radio" && n.name === e.name && n.form === t);
|
|
68
|
+
}
|
|
69
|
+
function p(e) {
|
|
70
|
+
return e.getRootNode().activeElement ?? null;
|
|
71
|
+
}
|
|
72
|
+
function m(e) {
|
|
73
|
+
if (e.localName !== "input") return !0;
|
|
74
|
+
let t = e;
|
|
75
|
+
if (t.type !== "radio" || !t.name) return !0;
|
|
76
|
+
let n = f(t), r = p(t);
|
|
77
|
+
if (r && n.includes(r)) return r === t;
|
|
78
|
+
let i = n.find((e) => e.checked);
|
|
79
|
+
return !i || i === t;
|
|
80
|
+
}
|
|
81
|
+
function h(e, t) {
|
|
82
|
+
return d(e, t) && i(e) >= 0 && m(e);
|
|
83
|
+
}
|
|
84
|
+
function g(e) {
|
|
85
|
+
return d(e);
|
|
86
|
+
}
|
|
87
|
+
function _(e, n) {
|
|
88
|
+
let r = /* @__PURE__ */ new Map(), a = Array.from(e.querySelectorAll(t));
|
|
89
|
+
n?.includeContainer && e.matches(t) && a.unshift(e);
|
|
90
|
+
let o = a.filter((e) => h(e, r)), s = o.map((e, t) => ({
|
|
91
|
+
el: e,
|
|
92
|
+
index: t,
|
|
93
|
+
tabIndex: i(e)
|
|
94
|
+
})).filter((e) => e.tabIndex > 0).sort((e, t) => e.tabIndex - t.tabIndex || e.index - t.index).map((e) => e.el), c = o.filter((e) => i(e) === 0);
|
|
95
|
+
return [...s, ...c];
|
|
96
|
+
}
|
|
97
|
+
function v(e, t) {
|
|
98
|
+
return _(e, t)[0] ?? null;
|
|
99
|
+
}
|
|
100
|
+
function y(e, t) {
|
|
101
|
+
let n = _(e, t);
|
|
102
|
+
return n[n.length - 1] ?? null;
|
|
103
|
+
}
|
|
104
|
+
function b(e) {
|
|
105
|
+
return !!e && e.isConnected && g(e);
|
|
106
|
+
}
|
|
107
|
+
function x(e, t) {
|
|
108
|
+
if (!e || !b(e)) return !1;
|
|
109
|
+
try {
|
|
110
|
+
e.focus(t);
|
|
111
|
+
} catch {
|
|
112
|
+
return !1;
|
|
113
|
+
}
|
|
114
|
+
return e.ownerDocument.activeElement === e;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { t as FOCUSABLE_SELECTOR, x as focusElement, v as getFirstTabbable, y as getLastTabbable, _ as getTabbableElements, b as isConnectedAndFocusable, g as isFocusable, o as isHiddenInput };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=focus.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus.mjs","names":["NATIVELY_FOCUSABLE_SELECTOR","FOCUSABLE_SELECTOR","parseTabIndexAttribute","value","el","parsed","isNativelyFocusable","getTabIndex","attribute","isDisabled","isHiddenInput","isDetailsSummary","parent","summary","child","getComputed","view","isRemovedFromLayout","cached","cache","hidden","isHidden","visibility","isFocusableInternal","getRadioGroup","form","radio","getActiveElementFor","isRadioTabStop","group","active","checked","member","isTabbableInternal","isFocusable","getTabbableElements","candidates","container","options","tabbable","positive","entry","a","b","natural","getFirstTabbable","getLastTabbable","isConnectedAndFocusable","focusElement"],"sources":["../../src/lib/focus.ts"],"sourcesContent":["/**\n * Focus utilities that work in browsers and in jsdom (no layout APIs such as `offsetParent` or\n * `getClientRects`; visibility comes from attributes and computed style).\n */\n\nconst NATIVELY_FOCUSABLE_SELECTOR = [\n 'a[href]',\n 'area[href]',\n 'button',\n 'input',\n 'select',\n 'textarea',\n 'iframe',\n 'audio[controls]',\n 'video[controls]',\n 'summary',\n '[contenteditable]:not([contenteditable=\"false\"])',\n].join(', ');\n\n/**\n * Selector for every element that may be able to receive focus. Candidates are filtered further by\n * {@link isFocusable} (disabled, hidden, inert, …) and {@link isTabbable}.\n */\nexport const FOCUSABLE_SELECTOR = `${NATIVELY_FOCUSABLE_SELECTOR}, [tabindex]`;\n\ntype HiddenCache = Map<Element, boolean>;\n\nfunction parseTabIndexAttribute(el: Element): number | null {\n const value = el.getAttribute('tabindex');\n if (value === null) return null;\n const parsed = Number.parseInt(value, 10);\n return Number.isNaN(parsed) ? null : parsed;\n}\n\nfunction isNativelyFocusable(el: Element): boolean {\n return el.matches(NATIVELY_FOCUSABLE_SELECTOR);\n}\n\n/** The tab index browsers use (jsdom reports -1 for contenteditable and 0 for `<a>` without href). */\nfunction getTabIndex(el: Element): number {\n const attribute = parseTabIndexAttribute(el);\n if (attribute !== null) return attribute;\n return isNativelyFocusable(el) ? 0 : -1;\n}\n\nfunction isDisabled(el: Element): boolean {\n try {\n return el.matches(':disabled');\n } catch {\n return (el as { disabled?: unknown }).disabled === true;\n }\n}\n\n/** Whether `el` is an `<input type=\"hidden\">` (a form value, never focusable). */\nexport function isHiddenInput(el: Element): boolean {\n return el.localName === 'input' && (el as HTMLInputElement).type === 'hidden';\n}\n\n/** `<summary>` is focusable only as the first summary child of a `<details>`. */\nfunction isDetailsSummary(summary: Element): boolean {\n const parent = summary.parentElement;\n if (!parent || parent.localName !== 'details') return false;\n return Array.from(parent.children).find((child) => child.localName === 'summary') === summary;\n}\n\nfunction getComputed(el: Element): CSSStyleDeclaration | null {\n const view = el.ownerDocument.defaultView;\n return view ? view.getComputedStyle(el) : null;\n}\n\n/** Hidden by `hidden`, `display: none` on itself or an ancestor, or a closed `<details>`. */\nfunction isRemovedFromLayout(el: Element, cache?: HiddenCache): boolean {\n const cached = cache?.get(el);\n if (cached !== undefined) return cached;\n\n let hidden = false;\n if (el.hasAttribute('hidden') || getComputed(el)?.display === 'none') {\n hidden = true;\n } else {\n const parent = el.parentElement;\n if (parent) {\n if (parent.localName === 'details' && !parent.hasAttribute('open')) {\n // Only the first <summary> of a closed <details> is rendered.\n const summary = Array.from(parent.children).find((child) => child.localName === 'summary');\n hidden = el !== summary || isRemovedFromLayout(parent, cache);\n } else {\n hidden = isRemovedFromLayout(parent, cache);\n }\n }\n }\n\n cache?.set(el, hidden);\n return hidden;\n}\n\nfunction isHidden(el: Element, cache?: HiddenCache): boolean {\n if (el.closest('[inert]')) return true;\n if (isRemovedFromLayout(el, cache)) return true;\n const visibility = getComputed(el)?.visibility;\n return visibility === 'hidden' || visibility === 'collapse';\n}\n\nfunction isFocusableInternal(el: Element, cache?: HiddenCache): boolean {\n if (!isNativelyFocusable(el) && parseTabIndexAttribute(el) === null) return false;\n if (isDisabled(el) || isHiddenInput(el)) return false;\n if (el.localName === 'summary' && !isDetailsSummary(el) && parseTabIndexAttribute(el) === null) {\n return false;\n }\n return !isHidden(el, cache);\n}\n\nfunction getRadioGroup(radio: HTMLInputElement): HTMLInputElement[] {\n const form = radio.form;\n const candidates: Element[] = form\n ? Array.from(form.elements)\n : Array.from(\n (radio.getRootNode() as Document | ShadowRoot).querySelectorAll('input[type=\"radio\"]'),\n );\n return candidates.filter(\n (el): el is HTMLInputElement =>\n el.localName === 'input' &&\n (el as HTMLInputElement).type === 'radio' &&\n (el as HTMLInputElement).name === radio.name &&\n (el as HTMLInputElement).form === form,\n );\n}\n\n/**\n * The focused element of `el`'s document or shadow root (`null` when `el` is disconnected). Duck\n * typed rather than `instanceof`, so elements of another realm (iframes) work too.\n */\nfunction getActiveElementFor(el: Element): Element | null {\n const root = el.getRootNode() as Node & { activeElement?: Element | null };\n return root.activeElement ?? null;\n}\n\n/**\n * A named radio group is one tab stop, following browsers (Chromium's\n * `RadioInputType::IsKeyboardFocusable`, the `tabbable` library):\n * - while focus is on a member of the group, only that member (Tab and Shift+Tab leave the group);\n * - otherwise the checked radio (the whole group is skipped when it cannot take focus);\n * - otherwise, with no checked radio, every member: Tab enters at the first one, Shift+Tab at the\n * last one, so both `getFirstTabbable` and `getLastTabbable` return the browser's entry radio.\n * Members that are not focusable (disabled, hidden) are filtered out before this check.\n */\nfunction isRadioTabStop(el: Element): boolean {\n if (el.localName !== 'input') return true;\n const radio = el as HTMLInputElement;\n if (radio.type !== 'radio' || !radio.name) return true;\n const group = getRadioGroup(radio);\n const active = getActiveElementFor(radio);\n if (active && (group as Element[]).includes(active)) return active === radio;\n const checked = group.find((member) => member.checked);\n return checked ? checked === radio : true;\n}\n\nfunction isTabbableInternal(el: Element, cache?: HiddenCache): boolean {\n return isFocusableInternal(el, cache) && getTabIndex(el) >= 0 && isRadioTabStop(el);\n}\n\n/**\n * Whether `el` can receive focus (programmatically or by pointer): a natively focusable element or\n * one with a valid `tabindex`, that is not disabled (including via a disabled `<fieldset>`), not\n * `input[type=hidden]`, and not inside `[inert]`, `[hidden]`, `display: none`, `visibility:\n * hidden` or a closed `<details>` (except its summary).\n */\nexport function isFocusable(el: Element): boolean {\n return isFocusableInternal(el);\n}\n\n/**\n * Whether `el` is reached by Tab: focusable, `tabIndex >= 0`, and — for a radio in a named group —\n * the group's tab stop: the focused member while focus is in the group, else the checked radio,\n * else (nothing checked) every focusable member, as browsers enter such a group at its first radio\n * going forward and at its last radio going backward.\n */\nexport function isTabbable(el: Element): boolean {\n return isTabbableInternal(el);\n}\n\n/**\n * The tabbable elements inside `container` in sequential focus order: positive `tabindex` first\n * (ascending), then `tabindex=0` / natively tabbable elements in document order. Named radio\n * groups follow {@link isTabbable}, so the result depends on where focus currently is: when focus\n * is on a radio, the rest of its group is left out, which makes the focused radio the last entry\n * when its group ends the container (the element a focus trap wraps from).\n *\n * @param options.includeContainer Also consider `container` itself.\n */\nexport function getTabbableElements(\n container: Element,\n options?: { includeContainer?: boolean },\n): HTMLElement[] {\n const cache: HiddenCache = new Map();\n const candidates = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR));\n if (options?.includeContainer && container.matches(FOCUSABLE_SELECTOR)) {\n candidates.unshift(container as HTMLElement);\n }\n const tabbable = candidates.filter((el) => isTabbableInternal(el, cache));\n const positive = tabbable\n .map((el, index) => ({ el, index, tabIndex: getTabIndex(el) }))\n .filter((entry) => entry.tabIndex > 0)\n .sort((a, b) => a.tabIndex - b.tabIndex || a.index - b.index)\n .map((entry) => entry.el);\n const natural = tabbable.filter((el) => getTabIndex(el) === 0);\n return [...positive, ...natural];\n}\n\n/** The first tabbable element inside `container`, or `null`. */\nexport function getFirstTabbable(\n container: Element,\n options?: { includeContainer?: boolean },\n): HTMLElement | null {\n return getTabbableElements(container, options)[0] ?? null;\n}\n\n/** The last tabbable element inside `container`, or `null`. */\nexport function getLastTabbable(\n container: Element,\n options?: { includeContainer?: boolean },\n): HTMLElement | null {\n const tabbable = getTabbableElements(container, options);\n return tabbable[tabbable.length - 1] ?? null;\n}\n\n/** Whether `el` exists, is attached to a document and {@link isFocusable}. */\nexport function isConnectedAndFocusable(el: Element | null | undefined): boolean {\n return !!el && el.isConnected && isFocusable(el);\n}\n\n/**\n * Focuses `el` when it is connected and focusable. Returns `true` when focus actually moved to it.\n */\nexport function focusElement(\n el: HTMLElement | SVGElement | null | undefined,\n options?: FocusOptions,\n): boolean {\n if (!el || !isConnectedAndFocusable(el)) return false;\n try {\n el.focus(options);\n } catch {\n return false;\n }\n return el.ownerDocument.activeElement === el;\n}\n\n/** Whether the focused element of `container`'s document is `container` or inside it. */\nexport function containsFocus(container: Element | null | undefined): boolean {\n if (!container) return false;\n const active = container.ownerDocument.activeElement;\n return !!active && container.contains(active);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function e(e,t){let n=Symbol.for(`@mortenbrudvik/waveui/`+e),r=globalThis;return Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:t(),configurable:!0,enumerable:!1,writable:!0}),r[n]}exports.getGlobalRegistry=e;
|
|
2
|
+
//# sourceMappingURL=globalRegistry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalRegistry.cjs","names":["getGlobalRegistry","symbol","key","store","create"],"sources":["../../src/lib/globalRegistry.ts"],"sourcesContent":["const NAMESPACE = '@mortenbrudvik/waveui/';\n\ntype GlobalStore = Record<symbol, unknown>;\n\n/**\n * Returns the module singleton registered under `key`, creating it with `create` on first use.\n *\n * The value is stored on `globalThis[Symbol.for('@mortenbrudvik/waveui/' + key)]` (non-enumerable),\n * so an app that evaluates the library twice — the ESM and the CJS build side by side (Next.js\n * server CJS + client ESM, or a dependency that `require`s the package) — still shares one state\n * per key. A change to the value shape stored under a key must stay compatible with the other copy.\n *\n * Keys and their users:\n * - `'layers'` — the dismiss-layer stack (`layers.ts`);\n * - `'traps'` — the focus-trap stack (`useFocusTrap`);\n * - `'scrollLock'` — the scroll-lock counter (`useScrollLock`);\n * - `'inert'` — the elements made inert behind a modal (`useModalIsolation`);\n * - `'restoreFocusTracker'` — the pointer/focus tracker of `useRestoreFocus`;\n * - `'announcer'` — the live-region announcer (`useAnnounce`);\n * - `'orderedSurfaces'` — the open surfaces whose keyboard order `usePopoverTabOrder` manages\n * (`Popover.shared.tsx`);\n * - `'toasterHandles'` — the state of every `createToaster()` handle (`toaster.ts`);\n * - `'warnings'` and `'missing-context'` — the warn-once keys and the logged missing-context\n * texts (`dev.ts`).\n *\n * @param key Registry name, e.g. `'warnings'` or `'layers'`.\n * @param create Factory for the initial value; called at most once per realm.\n */\nexport function getGlobalRegistry<T>(key: string, create: () => T): T {\n const symbol = Symbol.for(NAMESPACE + key);\n const store = globalThis as unknown as GlobalStore;\n if (!Object.prototype.hasOwnProperty.call(store, symbol)) {\n Object.defineProperty(store, symbol, {\n value: create(),\n configurable: true,\n enumerable: false,\n writable: true,\n });\n }\n return store[symbol] as T;\n}\n"],"mappings":"AA4BA,SAAgBA,EAAqB,EAAa,EAAoB,CACpE,IAAMC,EAAS,OAAO,IAAI,yBAAYC,CAAG,EACnCC,EAAQ,WASd,OARK,OAAO,UAAU,eAAe,KAAKA,EAAOF,CAAM,GACrD,OAAO,eAAeE,EAAOF,EAAQ,CACnC,MAAOG,EAAO,EACd,aAAc,GACd,WAAY,GACZ,SAAU,EACZ,CAAC,EAEID,EAAMF,EACf"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function e(e, t) {
|
|
2
|
+
let n = Symbol.for("@mortenbrudvik/waveui/" + e), r = globalThis;
|
|
3
|
+
return Object.prototype.hasOwnProperty.call(r, n) || Object.defineProperty(r, n, {
|
|
4
|
+
value: t(),
|
|
5
|
+
configurable: !0,
|
|
6
|
+
enumerable: !1,
|
|
7
|
+
writable: !0
|
|
8
|
+
}), r[n];
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as getGlobalRegistry };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=globalRegistry.mjs.map
|