@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,201 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { warnOnce as t } from "../../lib/dev.mjs";
|
|
4
|
+
import { materialiseSlotContent as n, renderSlot as r, slotRendersContent as i } from "../../lib/slot.mjs";
|
|
5
|
+
import { fieldClassNames as a } from "../../lib/classNames.mjs";
|
|
6
|
+
import { useId as o } from "../../hooks/useId.mjs";
|
|
7
|
+
import { joinIds as s } from "../../lib/aria.mjs";
|
|
8
|
+
import { FieldContext as c, createFieldControlIdClaim as l } from "../../hooks/useFieldControl.mjs";
|
|
9
|
+
import { ErrorIcon as u, SuccessIcon as d, WarningIcon as f } from "../../lib/icons.mjs";
|
|
10
|
+
import * as p from "react";
|
|
11
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
12
|
+
//#region src/components/input/Field.tsx
|
|
13
|
+
var _ = /* @__PURE__ */ new Set([
|
|
14
|
+
"button",
|
|
15
|
+
"input",
|
|
16
|
+
"meter",
|
|
17
|
+
"output",
|
|
18
|
+
"progress",
|
|
19
|
+
"select",
|
|
20
|
+
"textarea"
|
|
21
|
+
]), v = /* @__PURE__ */ new Set([
|
|
22
|
+
"button",
|
|
23
|
+
"image",
|
|
24
|
+
"reset",
|
|
25
|
+
"submit"
|
|
26
|
+
]), y = /* @__PURE__ */ new Set([
|
|
27
|
+
"caption",
|
|
28
|
+
"code",
|
|
29
|
+
"deletion",
|
|
30
|
+
"emphasis",
|
|
31
|
+
"generic",
|
|
32
|
+
"insertion",
|
|
33
|
+
"none",
|
|
34
|
+
"paragraph",
|
|
35
|
+
"presentation",
|
|
36
|
+
"strong",
|
|
37
|
+
"subscript",
|
|
38
|
+
"superscript"
|
|
39
|
+
]), b = /* @__PURE__ */ new Set([
|
|
40
|
+
"checkbox",
|
|
41
|
+
"columnheader",
|
|
42
|
+
"combobox",
|
|
43
|
+
"gridcell",
|
|
44
|
+
"listbox",
|
|
45
|
+
"radiogroup",
|
|
46
|
+
"rowheader",
|
|
47
|
+
"searchbox",
|
|
48
|
+
"spinbutton",
|
|
49
|
+
"switch",
|
|
50
|
+
"textbox",
|
|
51
|
+
"tree",
|
|
52
|
+
"treegrid"
|
|
53
|
+
]);
|
|
54
|
+
function x(e) {
|
|
55
|
+
if (typeof e == "string") return e.trim().split(/\s+/)[0]?.toLowerCase() || void 0;
|
|
56
|
+
}
|
|
57
|
+
function S(e) {
|
|
58
|
+
return typeof e == "string" && e.includes("-");
|
|
59
|
+
}
|
|
60
|
+
function C(e, t) {
|
|
61
|
+
return e === "select" || e === "textarea" ? !0 : e === "input" ? typeof t != "string" || !v.has(t.trim().toLowerCase()) : !1;
|
|
62
|
+
}
|
|
63
|
+
function w(e) {
|
|
64
|
+
if (typeof e.type != "string") return !0;
|
|
65
|
+
let t = x(e.props.role);
|
|
66
|
+
return t === void 0 ? C(e.type, e.props.type) : b.has(t);
|
|
67
|
+
}
|
|
68
|
+
function T(e) {
|
|
69
|
+
if (e.type === p.Fragment) return;
|
|
70
|
+
if (typeof e.type != "string" || _.has(e.type)) return "label-for";
|
|
71
|
+
let t = x(e.props.role);
|
|
72
|
+
return t === void 0 ? S(e.type) ? "label-for" : void 0 : y.has(t) ? void 0 : "labelledby";
|
|
73
|
+
}
|
|
74
|
+
function E(e) {
|
|
75
|
+
let t, n = 0;
|
|
76
|
+
p.Children.forEach(e, (e) => {
|
|
77
|
+
p.isValidElement(e) && (n += 1, t === void 0 && (t = e));
|
|
78
|
+
});
|
|
79
|
+
let r = t ? T(t) : void 0;
|
|
80
|
+
return {
|
|
81
|
+
target: r ? t : void 0,
|
|
82
|
+
mode: r,
|
|
83
|
+
elementCount: n
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function D(e, t) {
|
|
87
|
+
let { target: n, mode: r } = E(e);
|
|
88
|
+
if (!n || !r) return p.Children.map(e, (e) => e);
|
|
89
|
+
let i = n.props, a = !S(n.type) || "true", o = {};
|
|
90
|
+
return r === "label-for" ? i.id === void 0 && (o.id = t.controlId) : t.labelId !== void 0 && i["aria-label"] === void 0 && (o["aria-labelledby"] = s(i["aria-labelledby"], t.labelId)), (t.messageId || t.hintId) && (o["aria-describedby"] = s(i["aria-describedby"], t.messageId, t.hintId)), t.invalid && i["aria-invalid"] === void 0 && (o["aria-invalid"] = a), t.required && i.required !== !1 && (i["aria-required"] === void 0 && w(n) && (o["aria-required"] = a), typeof n.type == "string" && C(n.type, i.type) && i.required === void 0 && (o.required = !0)), p.Children.map(e, (e) => e === n ? p.cloneElement(n, o) : e);
|
|
91
|
+
}
|
|
92
|
+
function O(e) {
|
|
93
|
+
let { target: t, mode: n, elementCount: r } = E(e), i = n === "label-for";
|
|
94
|
+
return {
|
|
95
|
+
elementCount: r,
|
|
96
|
+
targetId: i ? t?.props.id : void 0,
|
|
97
|
+
controlIdAssigned: i
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
var k = {
|
|
101
|
+
error: u,
|
|
102
|
+
warning: f,
|
|
103
|
+
success: d,
|
|
104
|
+
none: null
|
|
105
|
+
}, A = {
|
|
106
|
+
error: "text-error",
|
|
107
|
+
warning: "text-warning-tint-foreground",
|
|
108
|
+
success: "text-success-tint-foreground",
|
|
109
|
+
none: "text-muted-foreground"
|
|
110
|
+
}, j = "[&>:first-child:has([role=checkbox],[role=switch],label>[role=radio])]:py-1.5", M = "mt-0.5 inline-flex shrink-0";
|
|
111
|
+
function N(t, n) {
|
|
112
|
+
if (n !== void 0) return i(n) ? r(n, "span", e(a.validationMessageIcon, M), { "aria-hidden": !0 }) : null;
|
|
113
|
+
let o = k[t];
|
|
114
|
+
return o ? /* @__PURE__ */ h("span", {
|
|
115
|
+
"aria-hidden": "true",
|
|
116
|
+
className: e(a.validationMessageIcon, M),
|
|
117
|
+
children: /* @__PURE__ */ h(o, { size: 12 })
|
|
118
|
+
}) : null;
|
|
119
|
+
}
|
|
120
|
+
var P = ({ label: r, hint: s, error: u, validationState: d, validationMessage: f, validationMessageIcon: _, orientation: v = "vertical", required: y = !1, htmlFor: b, className: x, children: S, ref: C, ...w }) => {
|
|
121
|
+
let T = o("field"), [E] = p.useState(l), { elementCount: k, targetId: M, controlIdAssigned: P } = O(S), F = i(u), I = u === !0 || F, L = i(f), R = I ? "error" : d ?? (L ? "error" : "none"), z = I ? F ? u : void 0 : f, B = I ? F : L, V = R === "error", H = i(s), U = I && (L || d !== void 0 && d !== "error"), W = M ?? b ?? T, G = i(r), K = G ? `${T}-label` : void 0, q = B ? `${T}-${V ? "error" : "message"}` : void 0, J = V ? q : void 0, Y = V && B, X = H ? `${T}-hint` : void 0;
|
|
122
|
+
p.useEffect(() => {
|
|
123
|
+
k > 1 && t("Field:multiple-children", `Field: only the first element child receives the Field's id and ARIA attributes; the other ${k - 1} element child(ren) are rendered unchanged. Wrap each control in its own Field.`);
|
|
124
|
+
}, [k]), p.useEffect(() => {
|
|
125
|
+
U && t("Field:error-and-validation", "Field: `error` and `validationMessage`/`validationState` are both set; `error` wins. Use one of them.");
|
|
126
|
+
}, [U]);
|
|
127
|
+
let Z = p.useMemo(() => ({
|
|
128
|
+
controlId: W,
|
|
129
|
+
labelId: K,
|
|
130
|
+
hintId: X,
|
|
131
|
+
errorId: J,
|
|
132
|
+
invalid: V,
|
|
133
|
+
required: y,
|
|
134
|
+
hasErrorMessage: Y,
|
|
135
|
+
controlIdAssigned: P,
|
|
136
|
+
controlIdClaim: E,
|
|
137
|
+
validationState: R,
|
|
138
|
+
validationMessageId: q
|
|
139
|
+
}), [
|
|
140
|
+
W,
|
|
141
|
+
K,
|
|
142
|
+
X,
|
|
143
|
+
J,
|
|
144
|
+
V,
|
|
145
|
+
y,
|
|
146
|
+
Y,
|
|
147
|
+
P,
|
|
148
|
+
E,
|
|
149
|
+
R,
|
|
150
|
+
q
|
|
151
|
+
]), ee = D(S, {
|
|
152
|
+
controlId: W,
|
|
153
|
+
labelId: K,
|
|
154
|
+
messageId: q,
|
|
155
|
+
hintId: X,
|
|
156
|
+
invalid: V,
|
|
157
|
+
required: y
|
|
158
|
+
}), Q = v === "horizontal", $ = /* @__PURE__ */ g(m, { children: [
|
|
159
|
+
/* @__PURE__ */ h(c.Provider, {
|
|
160
|
+
value: Z,
|
|
161
|
+
children: ee
|
|
162
|
+
}),
|
|
163
|
+
B ? /* @__PURE__ */ g("p", {
|
|
164
|
+
id: q,
|
|
165
|
+
role: R === "error" || R === "warning" ? "alert" : void 0,
|
|
166
|
+
"data-validation-state": R,
|
|
167
|
+
className: e(a.validationMessage, "mt-1 flex items-start gap-1 text-caption-1", A[R]),
|
|
168
|
+
children: [N(R, _), /* @__PURE__ */ h("span", { children: n(z) })]
|
|
169
|
+
}, `message-${R}`) : null,
|
|
170
|
+
H ? /* @__PURE__ */ h("p", {
|
|
171
|
+
id: X,
|
|
172
|
+
className: e(a.hint, "mt-1 text-caption-1 text-muted-foreground"),
|
|
173
|
+
children: n(s)
|
|
174
|
+
}, "hint") : null
|
|
175
|
+
] });
|
|
176
|
+
return /* @__PURE__ */ g("div", {
|
|
177
|
+
ref: C,
|
|
178
|
+
"data-orientation": v,
|
|
179
|
+
"data-validation-state": R,
|
|
180
|
+
className: e(a.root, "flex", Q ? "flex-row items-start gap-x-3" : "flex-col", x),
|
|
181
|
+
...w,
|
|
182
|
+
children: [G ? /* @__PURE__ */ g("label", {
|
|
183
|
+
id: K,
|
|
184
|
+
htmlFor: W,
|
|
185
|
+
className: e(a.label, "mb-1 text-body-1 font-semibold text-foreground", Q && "mb-0 shrink-0 basis-1/3 pt-1.5"),
|
|
186
|
+
children: [n(r), y && /* @__PURE__ */ h("span", {
|
|
187
|
+
"aria-hidden": "true",
|
|
188
|
+
className: e(a.required, "ms-0.5 text-error"),
|
|
189
|
+
children: "*"
|
|
190
|
+
})]
|
|
191
|
+
}) : null, Q ? /* @__PURE__ */ h("div", {
|
|
192
|
+
className: e("flex min-w-0 flex-1 flex-col", j),
|
|
193
|
+
children: $
|
|
194
|
+
}) : $]
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
P.displayName = "Field";
|
|
198
|
+
//#endregion
|
|
199
|
+
export { P as Field };
|
|
200
|
+
|
|
201
|
+
//# sourceMappingURL=Field.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Field.mjs","names":["useId","_Fragment","useId$1","React","LABELABLE_ELEMENTS","BUTTON_INPUT_TYPES","UNNAMED_ROLES","ARIA_REQUIRED_ROLES","explicitRole","role","isCustomElement","type","isNativeValueControl","tag","inputType","supportsAriaRequired","child","getMergeMode","inspectChildren","first","elementCount","children","mode","mergeIntoFirstChild","target","childProps","ariaTrue","injected","state","joinIds","getChildInfo","assigned","MESSAGE_ICONS","ErrorIcon","WarningIcon","SuccessIcon","MESSAGE_COLORS","SHORT_ROW_FIRST_CHILD","MESSAGE_ICON_CLASSES","renderMessageIcon","icon","slotRendersContent","renderSlot","cn","fieldClassNames","Icon","Field","rest","fieldId","controlIdClaim","createFieldControlIdClaim","errorRendersContent","error","usesError","validationMessageRendersContent","validationMessage","validationState","message","hasMessage","invalid","hasHint","hint","errorAndValidation","controlId","targetId","htmlFor","hasLabel","label","labelId","messageId","errorId","hasErrorMessage","hintId","warnOnce","context","required","controlIdAssigned","content","horizontal","orientation","control","Fragment","FieldContext","validationMessageIcon","materialiseSlotContent","className"],"sources":["../../../src/components/input/Field.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { joinIds } from '../../lib/aria';\nimport { fieldClassNames } from '../../lib/classNames';\nimport { warnOnce } from '../../lib/dev';\nimport { ErrorIcon, SuccessIcon, WarningIcon, type IconComponent } from '../../lib/icons';\nimport { materialiseSlotContent, renderSlot, slotRendersContent, type Slot } from '../../lib/slot';\nimport type { Orientation, ValidationState } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport {\n FieldContext,\n createFieldControlIdClaim,\n type FieldContextValue,\n} from '../../hooks/useFieldControl';\n\n/** Props Field reads from and merges into its first element child. */\ninterface InjectedFieldProps {\n id?: string;\n role?: string;\n type?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n 'aria-required'?: React.AriaAttributes['aria-required'];\n required?: boolean;\n}\n\n/** Properties for the Field component. */\nexport interface FieldProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Label displayed above the control (beside it with `orientation=\"horizontal\"`); names the\n * control.\n */\n label?: React.ReactNode;\n /** Hint shown below the control, after any validation message; describes the control. */\n hint?: React.ReactNode;\n /**\n * Validation error. Content is rendered below the control in a `role=\"alert\"` element that\n * describes the control, and the control is marked `aria-invalid`. `true` marks the control\n * invalid without a message. A value that renders nothing (`null`, `false`, `''`, or an array of\n * only those, such as an empty `errors.map(…)`) is no error; `0` is content.\n *\n * Shorthand for `validationState=\"error\"` with this message; wins over `validationMessage` and\n * `validationState` (development warning when both are set).\n */\n error?: React.ReactNode;\n /**\n * Validation state of `validationMessage`: `error` marks the control invalid (`aria-invalid`) and\n * announces the message (`role=\"alert\"`); `warning` announces it without marking the control\n * invalid; `success` and `none` show it without announcing. Default: `'error'` when\n * `validationMessage` renders content, else `'none'`. Ignored while `error` is set.\n */\n validationState?: ValidationState;\n /**\n * Message below the control, styled and announced by `validationState`; it describes the control\n * (`aria-describedby`). `error` is the shorthand for an error message and wins over this prop.\n */\n validationMessage?: React.ReactNode;\n /**\n * Icon before the message. Default: an error, warning or success glyph per state; none for\n * `'none'`. `null` (or content that renders nothing) shows no icon. Decorative (`aria-hidden`).\n */\n validationMessageIcon?: Slot<'span'>;\n /**\n * `vertical`: the label above the control. `horizontal`: the label in a start column (a third\n * of the width) beside the control; the message and the hint stay below the control. The\n * label's first line lines up with a 32px control (Input, Select, …) and with the first line of\n * a Checkbox, Switch or RadioGroup, which gets 6px of padding above and below for it. The\n * horizontal layout wraps the control in a column, so changing `orientation` on a mounted Field\n * remounts the control: an uncontrolled control loses its state and focus (control it, or keep\n * one orientation while the Field is mounted).\n * @default 'vertical'\n */\n orientation?: Orientation;\n /**\n * Whether the field is required: shows a decorative asterisk next to the label, sets\n * `aria-required`, and turns on native constraint validation. `<input>`, `<select>`,\n * `<textarea>` and Input, Select, Textarea, Slider, SearchBox and SpinButton get the native\n * `required` attribute. Checkbox, Switch, RadioGroup, Rating, ColorPicker, SwatchPicker,\n * Combobox, Dropdown, TagPicker, DatePicker and TimePicker render a hidden required input (with\n * or without `name`), so submit is blocked until they are checked, switched on or have a value.\n * An explicit `required={false}` on the control wins, including for `aria-required`.\n */\n required?: boolean;\n /**\n * The id of the control the label points at, when the control has no `id` of its own\n * (default: a generated id).\n */\n htmlFor?: string;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Intrinsic elements a `<label htmlFor>` can name (HTML \"labelable elements\"). */\nconst LABELABLE_ELEMENTS: ReadonlySet<string> = new Set([\n 'button',\n 'input',\n 'meter',\n 'output',\n 'progress',\n 'select',\n 'textarea',\n]);\n\n/** `<input>` types whose implicit role is `button`: they take neither `aria-required` nor `required`. */\nconst BUTTON_INPUT_TYPES: ReadonlySet<string> = new Set(['button', 'image', 'reset', 'submit']);\n\n/**\n * Roles that cannot be named (ARIA 1.2 \"name prohibited\") or that remove semantics: an element\n * with one of them is a layout wrapper, not a widget, and Field leaves it alone.\n */\nconst UNNAMED_ROLES: ReadonlySet<string> = new Set([\n 'caption',\n 'code',\n 'deletion',\n 'emphasis',\n 'generic',\n 'insertion',\n 'none',\n 'paragraph',\n 'presentation',\n 'strong',\n 'subscript',\n 'superscript',\n]);\n\n/** Roles that support `aria-required` (ARIA 1.2, including the roles that inherit it). */\nconst ARIA_REQUIRED_ROLES: ReadonlySet<string> = new Set([\n 'checkbox',\n 'columnheader',\n 'combobox',\n 'gridcell',\n 'listbox',\n 'radiogroup',\n 'rowheader',\n 'searchbox',\n 'spinbutton',\n 'switch',\n 'textbox',\n 'tree',\n 'treegrid',\n]);\n\n/**\n * How Field merges into its first element child:\n * - `label-for`: components (library controls, consumer inputs, wrappers such as Tooltip),\n * labelable intrinsic elements (`<input>`, `<select>`, `<button>`, …) and role-less custom\n * elements (`<my-text-field>`, possibly form-associated). The child receives the `id` the\n * `<label htmlFor>` points at (unless it has its own id, which the label then uses).\n * - `labelledby`: an intrinsic element with an explicit widget `role` (a consumer's own\n * `<div role=\"radiogroup\">`). A `<label htmlFor>` cannot name it, so it is named through\n * `aria-labelledby` and receives no `id` (a library control inside it keeps the control id).\n */\ntype MergeMode = 'label-for' | 'labelledby';\n\n/** The first token of an explicit `role` attribute (lower case), or `undefined`. */\nfunction explicitRole(role: unknown): string | undefined {\n if (typeof role !== 'string') return undefined;\n return role.trim().split(/\\s+/)[0]?.toLowerCase() || undefined;\n}\n\n/** Whether `type` is an autonomous custom element (`<my-text-field>`): its tag name has a hyphen. */\nfunction isCustomElement(type: unknown): type is string {\n return typeof type === 'string' && type.includes('-');\n}\n\n/**\n * Whether an intrinsic element is a native form control that takes a value (`<select>`,\n * `<textarea>`, or an `<input>` that is not a button): it takes the native `required` attribute\n * and, without an explicit role, `aria-required`.\n */\nfunction isNativeValueControl(tag: string, inputType: unknown): boolean {\n if (tag === 'select' || tag === 'textarea') return true;\n if (tag !== 'input') return false;\n return typeof inputType !== 'string' || !BUTTON_INPUT_TYPES.has(inputType.trim().toLowerCase());\n}\n\n/**\n * Whether Field may add `aria-required` to `child`: a component (it may render any control and\n * decides where the attribute goes), an element whose explicit role supports it, or a native form\n * control that takes a value. Never a `<button>`, `<meter>`, `<output>`, `<progress>`, button-type\n * `<input>` or role-less custom element, where axe reports `aria-allowed-attr`.\n */\nfunction supportsAriaRequired(child: React.ReactElement<InjectedFieldProps>): boolean {\n if (typeof child.type !== 'string') return true;\n const role = explicitRole(child.props.role);\n if (role !== undefined) return ARIA_REQUIRED_ROLES.has(role);\n return isNativeValueControl(child.type, child.props.type);\n}\n\n/**\n * Whether and how Field merges its props into `child` (see {@link MergeMode}). A Fragment and a\n * role-less (or presentational) non-labelable intrinsic wrapper (`<div>`, `<span>`) are left\n * alone; the library control inside them reads `FieldContext`. A role-less custom element\n * (`<my-text-field>`) is treated like a component: it may be a form-associated element, which a\n * `<label htmlFor>` names.\n */\nfunction getMergeMode(child: React.ReactElement<InjectedFieldProps>): MergeMode | undefined {\n if (child.type === React.Fragment) return undefined;\n if (typeof child.type !== 'string' || LABELABLE_ELEMENTS.has(child.type)) return 'label-for';\n const role = explicitRole(child.props.role);\n if (role !== undefined) return UNNAMED_ROLES.has(role) ? undefined : 'labelledby';\n return isCustomElement(child.type) ? 'label-for' : undefined;\n}\n\ninterface FieldChildren {\n /** The element child Field merges into, or `undefined`. */\n target: React.ReactElement<InjectedFieldProps> | undefined;\n /** How Field merges into `target` (`undefined` when there is no target). */\n mode: MergeMode | undefined;\n /** How many element children there are (only the first one is merged). */\n elementCount: number;\n}\n\nfunction inspectChildren(children: React.ReactNode): FieldChildren {\n let first: React.ReactElement<InjectedFieldProps> | undefined;\n let elementCount = 0;\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement<InjectedFieldProps>(child)) return;\n elementCount += 1;\n if (first === undefined) first = child;\n });\n const mode = first ? getMergeMode(first) : undefined;\n return { target: mode ? first : undefined, mode, elementCount };\n}\n\n/** What Field merges into its first element child. */\ninterface FieldMergeState {\n controlId: string;\n labelId: string | undefined;\n /** The id of the rendered validation message, in any state. */\n messageId: string | undefined;\n hintId: string | undefined;\n /** Only the `error` validation state is invalid. */\n invalid: boolean;\n required: boolean;\n}\n\n/**\n * Returns `children` with Field's props merged into the merge target (only defined keys; the\n * child's own `id`, `aria-label`, `aria-invalid`, `aria-required` and `required` are kept, its\n * `aria-labelledby` and `aria-describedby` are joined with the message and the hint).\n */\nfunction mergeIntoFirstChild(children: React.ReactNode, state: FieldMergeState): React.ReactNode {\n const { target, mode } = inspectChildren(children);\n // Always map, so the children keep the same keys whether or not one of them is merged.\n if (!target || !mode) return React.Children.map(children, (child) => child);\n\n const childProps = target.props;\n // React renders a boolean `true` on a custom element as an empty attribute (`aria-invalid=\"\"`).\n const ariaTrue = isCustomElement(target.type) ? 'true' : true;\n const injected: InjectedFieldProps = {};\n if (mode === 'label-for') {\n if (childProps.id === undefined) injected.id = state.controlId;\n } else if (state.labelId !== undefined && childProps['aria-label'] === undefined) {\n injected['aria-labelledby'] = joinIds(childProps['aria-labelledby'], state.labelId);\n }\n if (state.messageId || state.hintId) {\n injected['aria-describedby'] = joinIds(\n childProps['aria-describedby'],\n state.messageId,\n state.hintId,\n );\n }\n // The child's own `aria-invalid` wins, as `useFieldControl` lets it win for a nested control.\n if (state.invalid && childProps['aria-invalid'] === undefined) {\n injected['aria-invalid'] = ariaTrue;\n }\n // A child's own `required={false}` wins: it gets neither `aria-required` nor `required`, so what\n // is announced matches what is validated.\n if (state.required && childProps.required !== false) {\n if (childProps['aria-required'] === undefined && supportsAriaRequired(target)) {\n injected['aria-required'] = ariaTrue;\n }\n if (\n typeof target.type === 'string' &&\n isNativeValueControl(target.type, childProps.type) &&\n childProps.required === undefined\n ) {\n injected.required = true;\n }\n }\n return React.Children.map(children, (child) =>\n child === target ? React.cloneElement(target, injected) : child,\n );\n}\n\n/** Primitive facts about the children, read during render (no element objects escape). */\nfunction getChildInfo(children: React.ReactNode): {\n elementCount: number;\n targetId: string | undefined;\n controlIdAssigned: boolean;\n} {\n const { target, mode, elementCount } = inspectChildren(children);\n // Only a label-for target holds the control id (Field merges it, or the target's own id becomes\n // the control id). A <label htmlFor> cannot name a role widget, so the library control inside\n // one keeps the control id. With `controlIdAssigned`, a library control that receives no id is\n // nested in the target or is a later sibling: useFieldControl gives it an id of its own and\n // names it through aria-labelledby.\n const assigned = mode === 'label-for';\n return {\n elementCount,\n targetId: assigned ? target?.props.id : undefined,\n controlIdAssigned: assigned,\n };\n}\n\n/** The default glyph of each message state (`none` has none). */\nconst MESSAGE_ICONS: Readonly<Record<ValidationState, IconComponent | null>> = {\n error: ErrorIcon,\n warning: WarningIcon,\n success: SuccessIcon,\n none: null,\n};\n\n/** Text color of each message state (the `*-tint-foreground` tokens keep 4.5:1 on page and card). */\nconst MESSAGE_COLORS: Readonly<Record<ValidationState, string>> = {\n error: 'text-error',\n warning: 'text-warning-tint-foreground',\n success: 'text-success-tint-foreground',\n none: 'text-muted-foreground',\n};\n\n/**\n * Horizontal layout: the label's first line is centred on a 32px row, the height of an Input, a\n * Select and the other text controls. Checkbox, Switch and RadioGroup rows are one 20px line, so a\n * first child that holds one (also a wrapper of several) gets 6px above and below: its first line\n * then lines up with the label's, also when its label wraps or a group lists its items one below\n * the other.\n */\nconst SHORT_ROW_FIRST_CHILD =\n '[&>:first-child:has([role=checkbox],[role=switch],label>[role=radio])]:py-1.5';\n\n/** The icon box before a message: 12px glyphs line up with the first line of caption text. */\nconst MESSAGE_ICON_CLASSES = 'mt-0.5 inline-flex shrink-0';\n\n/**\n * The icon before a message: the state's glyph while `icon` is `undefined`, else the consumer's\n * slot (`null` or content that renders nothing shows none).\n */\nfunction renderMessageIcon(state: ValidationState, icon: Slot<'span'> | undefined) {\n if (icon !== undefined) {\n return slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(fieldClassNames.validationMessageIcon, MESSAGE_ICON_CLASSES), {\n 'aria-hidden': true,\n })\n : null;\n }\n const Icon = MESSAGE_ICONS[state];\n return Icon ? (\n <span\n aria-hidden=\"true\"\n className={cn(fieldClassNames.validationMessageIcon, MESSAGE_ICON_CLASSES)}\n >\n <Icon size={12} />\n </span>\n ) : null;\n}\n\n/**\n * Lays out a form control with a label, a validation message, a hint and a required indicator,\n * and wires them to the control.\n *\n * - Validation: `validationMessage` with a `validationState` (`error`, `warning`, `success`,\n * `none`), or `error`, the shorthand for an error message. The message renders below the\n * control with the state's icon and color, followed by the hint (which stays visible); both\n * describe the control. Only the `error` state marks the control `aria-invalid`; `error` and\n * `warning` messages are announced (`role=\"alert\"`). The root carries `data-validation-state`\n * and `data-orientation`.\n * - `orientation=\"horizontal\"` puts the label in a start column beside the control, with the\n * message and the hint below the control. The label lines up with the first line of the\n * control (a Checkbox, Switch or RadioGroup gets 6px of padding above and below for it).\n * - Provides `FieldContext`: the library's inputs (Input, Select, Textarea, Slider, SearchBox,\n * Checkbox, Switch, RadioGroup, Rating, SpinButton, pickers, …) read it wherever they are inside\n * the Field and are named by the label, described by the message and the hint and marked\n * invalid/required.\n * - Merges into its **first** element child (a native `<input>`/`<select>`/`<textarea>`, a\n * library control or your own component): `id` (unless the child has one — the label then\n * points at the child's id), `aria-describedby` (joined with the child's own ids),\n * `aria-invalid` (in the error state), `aria-required` and, for native form controls that take a\n * value, `required`. Only defined values are merged; the child's own values are kept, so a\n * child's `aria-invalid={false}` stays valid while the Field error still describes it (as for a\n * library control nested deeper). Further element children are rendered as they are.\n * - `aria-required` is added only where it is allowed: components (Field cannot see what they\n * render, so they decide where it goes — see the wrapper note below), `<input>` (not\n * `type=\"button\"`/`\"submit\"`/`\"reset\"`/`\"image\"`), `<select>`, `<textarea>`, and elements\n * whose explicit `role` supports it (`checkbox`, `combobox`, `switch`, `textbox`, …). A\n * `<button>`, `<meter>`, `<output>` or `<progress>` is labelled and described but not marked\n * required.\n * - Your own widget built on an element with an explicit `role` (`<div role=\"radiogroup\">`) is\n * named through `aria-labelledby` (joined with its own; not added when it has an\n * `aria-label`), described, marked invalid, and gets `aria-required` when its role supports\n * it. It receives no `id`, because a `<label htmlFor>` cannot name it. A role-less `<div>` or\n * `<span>` wrapper (or a `role=\"presentation\"`/`\"none\"` one) is left alone: the library\n * control inside it reads `FieldContext`.\n * - A custom element (`<my-text-field>`) without a role is treated like a component: it receives\n * the `id`, the description and `aria-invalid` (a form-associated custom element is named by\n * the label). Field does not guess its semantics: pass `required`/`aria-required` or an\n * explicit `role` yourself.\n * - **One control per Field.** A Field labels and describes a single control; wrap each control\n * in its own Field (a development warning is logged when a Field has more than one element\n * child). Further element children are rendered as they are. A library control among them\n * still reads `FieldContext`, so it shares the Field's name and description (when the first\n * child holds the control id, it gets an id of its own and is named through\n * `aria-labelledby`). Several library controls inside one plain wrapper element (`<div>`) are\n * all named and described too: the first one takes the control id the label points at, the\n * others get ids of their own and are named through `aria-labelledby` (when the first one is\n * removed, the next one takes the control id over).\n * - **Wrapper and layout components around a library control** (a `Tooltip`, your own `Row`):\n * put them inside a plain element (`<div>`, `<div className=\"flex\">`), which Field leaves\n * alone; the library control inside then holds the control id and is labelled, described and\n * marked invalid/required through `FieldContext`. Field cannot see inside a component, so a\n * component **first child** is treated as the control (it may be your own input): it receives\n * the control `id`, `aria-describedby`, `aria-invalid` and, with `required`, `aria-required`,\n * and a wrapper puts them on its own element (Tooltip's `<span>`, the layout `<div>`). The\n * library control inside still gets an id of its own and is named by the label through\n * `aria-labelledby`, but clicking the label does not focus it, and with `required`,\n * `aria-required` on the wrapper's non-widget element is an ARIA error (axe\n * `aria-allowed-attr`), even though the control inside is correctly marked required.\n *\n * @example\n * <Field label=\"Email\" hint=\"We never share it\" error={errors.email} required>\n * <Input type=\"email\" value={email} onValueChange={setEmail} />\n * </Field>\n *\n * @example\n * <Field label=\"Password\" hint=\"At least 12 characters\" validationState=\"warning\"\n * validationMessage=\"This password is common\">\n * <Input type=\"password\" />\n * </Field>\n *\n * @example\n * // A wrapper component goes inside a plain element.\n * <Field label=\"Name\" required>\n * <div>\n * <Tooltip content=\"As on your passport\">\n * <Input />\n * </Tooltip>\n * </div>\n * </Field>\n */\nexport const Field = ({\n label,\n hint,\n error,\n validationState,\n validationMessage,\n validationMessageIcon,\n orientation = 'vertical',\n required = false,\n htmlFor,\n className,\n children,\n ref,\n ...rest\n}: FieldProps) => {\n const fieldId = useId('field');\n // Hands the control id to one library control when Field leaves its first child alone.\n const [controlIdClaim] = React.useState(createFieldControlIdClaim);\n const { elementCount, targetId, controlIdAssigned } = getChildInfo(children);\n\n // The library's \"renders nothing\" rule: nullish, booleans, '' and collections of only those (an\n // empty `errors.map(…)`) are no label, hint or message; `0` is content.\n const errorRendersContent = slotRendersContent(error);\n const usesError = error === true || errorRendersContent;\n const validationMessageRendersContent = slotRendersContent(validationMessage);\n // `error` is the shorthand for an error message and wins over the validation props.\n const state: ValidationState = usesError\n ? 'error'\n : (validationState ?? (validationMessageRendersContent ? 'error' : 'none'));\n const message = usesError ? (errorRendersContent ? error : undefined) : validationMessage;\n const hasMessage = usesError ? errorRendersContent : validationMessageRendersContent;\n const invalid = state === 'error';\n const hasHint = slotRendersContent(hint);\n const errorAndValidation =\n usesError &&\n (validationMessageRendersContent ||\n (validationState !== undefined && validationState !== 'error'));\n\n const controlId = targetId ?? htmlFor ?? fieldId;\n const hasLabel = slotRendersContent(label);\n const labelId = hasLabel ? `${fieldId}-label` : undefined;\n // The error message keeps its 0.5 id; the other states get their own.\n const messageId = hasMessage ? `${fieldId}-${invalid ? 'error' : 'message'}` : undefined;\n const errorId = invalid ? messageId : undefined;\n const hasErrorMessage = invalid && hasMessage;\n const hintId = hasHint ? `${fieldId}-hint` : undefined;\n\n React.useEffect(() => {\n if (elementCount > 1) {\n warnOnce(\n 'Field:multiple-children',\n \"Field: only the first element child receives the Field's id and ARIA attributes; the other \" +\n `${elementCount - 1} element child(ren) are rendered unchanged. Wrap each control in its own Field.`,\n );\n }\n }, [elementCount]);\n\n React.useEffect(() => {\n if (errorAndValidation) {\n warnOnce(\n 'Field:error-and-validation',\n 'Field: `error` and `validationMessage`/`validationState` are both set; `error` wins. Use one of them.',\n );\n }\n }, [errorAndValidation]);\n\n const context = React.useMemo<FieldContextValue>(\n () => ({\n controlId,\n labelId,\n hintId,\n errorId,\n invalid,\n required,\n hasErrorMessage,\n controlIdAssigned,\n controlIdClaim,\n validationState: state,\n validationMessageId: messageId,\n }),\n [\n controlId,\n labelId,\n hintId,\n errorId,\n invalid,\n required,\n hasErrorMessage,\n controlIdAssigned,\n controlIdClaim,\n state,\n messageId,\n ],\n );\n\n const content = mergeIntoFirstChild(children, {\n controlId,\n labelId,\n messageId,\n hintId,\n invalid,\n required,\n });\n\n const horizontal = orientation === 'horizontal';\n const control = (\n <>\n <FieldContext.Provider value={context}>{content}</FieldContext.Provider>\n {/* Keyed by state: a message whose state changes (a hint-only Field that gets an error, a\n warning that becomes an error) is a newly inserted element, which screen readers\n announce reliably as an alert, not an existing node with a new role. */}\n {hasMessage ? (\n <p\n key={`message-${state}`}\n id={messageId}\n role={state === 'error' || state === 'warning' ? 'alert' : undefined}\n data-validation-state={state}\n className={cn(\n fieldClassNames.validationMessage,\n 'mt-1 flex items-start gap-1 text-caption-1',\n MESSAGE_COLORS[state],\n )}\n >\n {renderMessageIcon(state, validationMessageIcon)}\n <span>{materialiseSlotContent(message)}</span>\n </p>\n ) : null}\n {hasHint ? (\n <p\n key=\"hint\"\n id={hintId}\n className={cn(fieldClassNames.hint, 'mt-1 text-caption-1 text-muted-foreground')}\n >\n {materialiseSlotContent(hint)}\n </p>\n ) : null}\n </>\n );\n\n return (\n <div\n ref={ref}\n data-orientation={orientation}\n data-validation-state={state}\n className={cn(\n fieldClassNames.root,\n 'flex',\n horizontal ? 'flex-row items-start gap-x-3' : 'flex-col',\n className,\n )}\n {...rest}\n >\n {hasLabel ? (\n <label\n id={labelId}\n htmlFor={controlId}\n className={cn(\n fieldClassNames.label,\n 'mb-1 text-body-1 font-semibold text-foreground',\n // Beside the control: a third of the width, its first line centred on a 32px row.\n horizontal && 'mb-0 shrink-0 basis-1/3 pt-1.5',\n )}\n >\n {materialiseSlotContent(label)}\n {required && (\n <span aria-hidden=\"true\" className={cn(fieldClassNames.required, 'ms-0.5 text-error')}>\n *\n </span>\n )}\n </label>\n ) : null}\n {horizontal ? (\n <div className={cn('flex min-w-0 flex-1 flex-col', SHORT_ROW_FIRST_CHILD)}>{control}</div>\n ) : (\n control\n )}\n </div>\n );\n};\n\nField.displayName = 'Field';\n"],"mappings":";;;;;;;;;;;;AA+FA,IAAMI,oBAA0C,IAAI,IAAI;CACtD;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GAGKC,oBAA0C,IAAI,IAAI;CAAC;CAAU;CAAS;CAAS;AAAQ,CAAC,GAMxFC,oBAAqC,IAAI,IAAI;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GAGKC,oBAA2C,IAAI,IAAI;CACvD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAeD,SAASC,EAAa,GAAmC;CACvD,IAAI,OAAOC,KAAS,UACpB,OAAOA,EAAK,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,EA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,IAAIE;GACJ,SAASL;GACT,WAAWpB,EACTC,EAAgB,OAChB,kDAEAkC,KAAc,gCAChB;GARF,UAAA,CAUGM,EAAuBjB,CAAK,GAC5BQ,KACC,kBAAC,QAAD;IAAM,eAAY;IAAO,WAAWhC,EAAGC,EAAgB,UAAU,mBAAmB;IAAG,UAAA;GAEjF,CAAA,CAEH;EACL,CAAA,IAAA,MACHkC,IACC,kBAAC,OAAD;GAAK,WAAWnC,EAAG,gCAAgCN,CAAqB;GAAI,UAAA2C;EAAa,CAAA,IAEzFA,CAEC;;AAET;AAEA,EAAM,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/slot.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../hooks/useId.cjs"),a=require("../../lib/aria.cjs"),o=require("../../hooks/useFieldControl.cjs"),s=require("../../lib/styles.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("react/jsx-runtime");function u(e){return e===!1||e===`false`}function d(e,n,r,a){let s=o.useFieldContext(),c=i.useId(`error`),d=!u(r)&&(e===!0||typeof e==`string`&&e!==``);if(!d||typeof e!=`string`||s?.hasErrorMessage)return{invalid:d,messageId:void 0,message:null};let{id:f,className:p,...m}=n??{},h=f??c;return{invalid:d,messageId:h,message:(0,l.jsx)(`span`,{role:`alert`,...m,id:h,className:t.cn(a,`mt-1 block text-caption-1 text-error`,p),children:e})}}function f(e,t){return u(t)?!1:e||t===!0||t===`true`}var p=({error:e,errorMessageProps:i,contentBefore:c,contentAfter:u,onChange:p,onValueChange:m,className:h,ref:g,id:_,"aria-label":v,"aria-labelledby":y,"aria-describedby":b,"aria-invalid":x,"aria-required":S,"aria-errormessage":C,required:w,...T})=>{let{invalid:E,messageId:D,message:O}=d(e,i,x,r.inputClassNames.errorMessage),k=o.useFieldControl({id:_,"aria-label":v,"aria-labelledby":y,"aria-describedby":a.joinIds(b,D),"aria-invalid":x??(E||void 0),"aria-required":S,required:w},{nativeRequired:!0}),A=f(E,k[`aria-invalid`]),j=p||m?e=>{p?.(e),m?.(e.currentTarget.value)}:void 0,M={...T,...k,"aria-errormessage":a.joinIds(C,D),onChange:j},N=n.slotRendersContent(c),P=n.slotRendersContent(u),F;if(N||P){let{style:e,hidden:i,...a}=M;F=(0,l.jsxs)(`span`,{hidden:i,style:e,className:t.cn(r.inputClassNames.root,`inline-flex h-8 w-full items-center rounded border border-input border-b-stroke-accessible bg-background text-body-1 text-foreground`,s.inputFocusWithin,A&&`border-destructive focus-within:border-b-destructive`,T.disabled&&`cursor-not-allowed opacity-50 has-focus-visible:opacity-100`,h),children:[N&&n.renderSlot(c,`span`,t.cn(r.inputClassNames.contentBefore,`shrink-0 ps-2`)),(0,l.jsx)(`input`,{ref:g,className:t.cn(r.inputClassNames.input,`h-full w-full min-w-0 bg-transparent px-2 text-body-1 text-foreground`,`placeholder:text-muted-foreground`,`focus:outline-hidden`,`disabled:cursor-not-allowed`),...a}),P&&n.renderSlot(u,`span`,t.cn(r.inputClassNames.contentAfter,`shrink-0 pe-2`))]})}else F=(0,l.jsx)(`input`,{ref:g,className:t.cn(r.inputClassNames.root,r.inputClassNames.input,`h-8 w-full rounded border border-input border-b-stroke-accessible bg-background px-3 text-body-1 text-foreground`,`placeholder:text-muted-foreground`,s.inputFocus,`disabled:cursor-not-allowed disabled:opacity-50`,A&&`border-destructive focus:border-b-destructive`,h),...M});return O?(0,l.jsxs)(l.Fragment,{children:[F,O]}):F};p.displayName=`Input`,exports.Input=p,exports.isInvalidLook=f,exports.useControlErrorMessage=d;
|
|
2
|
+
//# sourceMappingURL=Input.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.cjs","names":["useFieldContext","useId","_jsx","cn","inputClassNames","useFieldControl","joinIds","slotRendersContent","inputFocusWithin","renderSlot","inputFocus","_Fragment","require_runtime","require_cn","require_slot","require_classNames","require_useId","require_aria","require_useFieldControl","require_styles","react","react_jsx_runtime","isAriaValid","ariaInvalid","useControlErrorMessage","field","generatedId","invalid","consumerAriaInvalid","error","ownId","messageClassName","messageRest","errorMessageProps","messageId","partClassName","isInvalidLook","ownError","Input","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaRequired","ariaErrorMessage","props","fieldProps","invalidLook","handleChange","onChange","onValueChange","event","controlProps","hasBefore","contentBefore","hasAfter","contentAfter","control","inputProps","className","message"],"sources":["../../../src/components/input/Input.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { joinIds } from '../../lib/aria';\nimport { inputClassNames } from '../../lib/classNames';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { inputFocus, inputFocusWithin, inputInvalid, inputInvalidWithin } from '../../lib/styles';\nimport type { Slot } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\n\n/**\n * Props of the error message element that {@link Input}, `Select` and `Textarea` render after the\n * control for a string `error` (`id`, `className`, `role`, data attributes, …).\n */\nexport interface InputErrorMessageProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Ref to the message `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n /** Any `data-*` attribute. */\n [dataAttribute: `data-${string}`]: unknown;\n}\n\n/**\n * Result of {@link useControlErrorMessage}.\n *\n * @internal Not exported from the package.\n */\nexport interface ControlErrorMessage {\n /**\n * Whether `error` marks the control invalid (a non-empty string or `true`), unless the consumer\n * set `aria-invalid` to `false`/`\"false\"`.\n */\n invalid: boolean;\n /** The id of the rendered message, joined into `aria-describedby`/`aria-errormessage`. */\n messageId: string | undefined;\n /** The message element to render after the control, or `null`. */\n message: React.ReactElement | null;\n}\n\n/** Whether an `aria-invalid` value explicitly reports the control as valid. */\nfunction isAriaValid(ariaInvalid: React.AriaAttributes['aria-invalid']): boolean {\n return ariaInvalid === false || ariaInvalid === 'false';\n}\n\n/**\n * Shared by Input, Select and Textarea (internal): a non-empty string `error` renders a sibling\n * `<span role=\"alert\">` message, unless the surrounding `Field` already renders its own error\n * (`FieldContext.hasErrorMessage`); `true` only marks the control invalid. The consumer's\n * `aria-invalid` of `false`/`\"false\"` wins over `error`: the control is valid, so nothing is\n * marked invalid and no message is rendered or referenced (ARIA: an error message of a valid\n * control is hidden).\n *\n * `partClassName` is the host's stable `errorMessage` class, first in the message's classes\n * (Input, Select and Textarea each pass their own).\n *\n * @internal Not exported from the package.\n */\nexport function useControlErrorMessage(\n error: string | boolean | undefined,\n errorMessageProps: InputErrorMessageProps | undefined,\n consumerAriaInvalid?: React.AriaAttributes['aria-invalid'],\n partClassName?: string,\n): ControlErrorMessage {\n const field = useFieldContext();\n const generatedId = useId('error');\n const invalid =\n !isAriaValid(consumerAriaInvalid) &&\n (error === true || (typeof error === 'string' && error !== ''));\n const showMessage = invalid && typeof error === 'string' && !field?.hasErrorMessage;\n if (!showMessage) return { invalid, messageId: undefined, message: null };\n\n const { id: ownId, className: messageClassName, ...messageRest } = errorMessageProps ?? {};\n const messageId = ownId ?? generatedId;\n const message = (\n <span\n role=\"alert\"\n {...messageRest}\n id={messageId}\n className={cn(partClassName, 'mt-1 block text-caption-1 text-error', messageClassName)}\n >\n {error}\n </span>\n );\n return { invalid, messageId, message };\n}\n\n/**\n * Whether a text control shows the invalid look (error border), shared by Input, Select, Textarea\n * and SearchBox (internal): its own `error`, or a resolved `aria-invalid` of `true`/`\"true\"` —\n * from the consumer or from the surrounding `Field` (`useFieldControl`) — so the look always\n * matches the state assistive technology reports. A resolved `false`/`\"false\"` (the consumer's\n * override) never shows it, even with an own `error`. `\"grammar\"`/`\"spelling\"` alone do not\n * count; with an own `error` they keep the look (the control is reported invalid).\n *\n * @internal Not exported from the package.\n */\nexport function isInvalidLook(\n ownError: boolean,\n ariaInvalid: React.AriaAttributes['aria-invalid'],\n): boolean {\n if (isAriaValid(ariaInvalid)) return false;\n return ownError || ariaInvalid === true || ariaInvalid === 'true';\n}\n\n/** Properties for the Input component. */\nexport interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {\n /**\n * Validation error.\n * - A non-empty string renders the message in a `role=\"alert\"` element **after** the field (a\n * sibling, so it does not change which element receives `ref`, `className` or `style`) and\n * links it through `aria-describedby` and `aria-errormessage`. Inside a `Field` that renders\n * its own `error`, the message is not repeated.\n * - `true` only marks the input invalid (`aria-invalid` and the error border), as in 0.4.\n *\n * The error border also shows whenever the input ends up `aria-invalid=\"true\"` without this\n * prop (an `error` on the surrounding `Field`, or your own `aria-invalid`).\n * Your own `aria-invalid={false}` (or `\"false\"`) wins over this prop: the input is reported\n * valid and shows neither the error border nor the message.\n * Use `Field` (`label`, `hint`, `error`) for a complete field layout.\n */\n error?: string | boolean;\n /** Props of the error message element (`id`, `className`, …) rendered for a string `error`. */\n errorMessageProps?: InputErrorMessageProps;\n /**\n * Slot rendered before the input text (e.g., an icon). With content in either slot, a bordered\n * `<span>` around the input draws the field: it receives `className`, `style` and `hidden`,\n * while `ref`, `id`, `aria-*`, `data-*`, handlers and native attributes stay on the `<input>`.\n * A value that renders nothing (`false`, `''`, `[]`) is no slot.\n */\n contentBefore?: Slot<'span'>;\n /** Slot rendered after the input text (e.g., a suffix). Same wrapper as `contentBefore`. */\n contentAfter?: Slot<'span'>;\n /**\n * Called with the new string value on every change, next to the native `onChange` event\n * handler (`onValueChange={setName}` instead of `onChange={(e) => setName(e.target.value)}`).\n */\n onValueChange?: (value: string) => void;\n /** Ref to the `<input>` element (also with `contentBefore`/`contentAfter`). */\n ref?: React.Ref<HTMLInputElement>;\n}\n\n/**\n * A single-line text input with Fluent styling: a 1px border with an accessible bottom stroke, a\n * primary bottom border while focused, optional `contentBefore`/`contentAfter` slots and an\n * optional error message. Inside a `Field` it picks up the label, hint, error, `required` (native\n * attribute) and invalid state automatically.\n *\n * Every prop reaches the `<input>`, except with slot content: then a bordered `<span>` wrapper\n * draws the field and receives `className`, `style` and `hidden` (`ref` stays on the input).\n *\n * @example\n * <Field label=\"Email\" hint=\"We never share it\" required>\n * <Input type=\"email\" value={email} onValueChange={setEmail} />\n * </Field>\n */\nexport const Input = ({\n error,\n errorMessageProps,\n contentBefore,\n contentAfter,\n onChange,\n onValueChange,\n className,\n ref,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n required,\n ...props\n}: InputProps) => {\n const { invalid, messageId, message } = useControlErrorMessage(\n error,\n errorMessageProps,\n ariaInvalid,\n inputClassNames.errorMessage,\n );\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': joinIds(ariaDescribedBy, messageId),\n 'aria-invalid': ariaInvalid ?? (invalid || undefined),\n 'aria-required': ariaRequired,\n required,\n },\n { nativeRequired: true },\n );\n const invalidLook = isInvalidLook(invalid, fieldProps['aria-invalid']);\n\n const handleChange =\n onChange || onValueChange\n ? (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n onValueChange?.(event.currentTarget.value);\n }\n : undefined;\n\n const controlProps = {\n ...props,\n ...fieldProps,\n 'aria-errormessage': joinIds(ariaErrorMessage, messageId),\n onChange: handleChange,\n };\n\n const hasBefore = slotRendersContent(contentBefore);\n const hasAfter = slotRendersContent(contentAfter);\n\n let control: React.ReactElement;\n if (hasBefore || hasAfter) {\n // The bordered wrapper is the visible field: `className`, `style` and `hidden` size, style and\n // hide it; `ref`, `id`, `aria-*`, `data-*`, handlers and native attributes go to the input.\n const { style, hidden, ...inputProps } = controlProps;\n control = (\n <span\n hidden={hidden}\n style={style}\n className={cn(\n inputClassNames.root,\n 'inline-flex h-8 w-full items-center rounded border border-input border-b-stroke-accessible bg-background text-body-1 text-foreground',\n inputFocusWithin,\n invalidLook && inputInvalidWithin,\n // The dimmed look lifts while a focus ring shows inside the wrapper (focusable slot\n // content; the disabled input never takes focus): opacity would dim the ring below 3:1.\n props.disabled && 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100',\n className,\n )}\n >\n {hasBefore &&\n renderSlot(contentBefore, 'span', cn(inputClassNames.contentBefore, 'shrink-0 ps-2'))}\n <input\n ref={ref}\n className={cn(\n inputClassNames.input,\n 'h-full w-full min-w-0 bg-transparent px-2 text-body-1 text-foreground',\n 'placeholder:text-muted-foreground',\n 'focus:outline-hidden',\n 'disabled:cursor-not-allowed',\n )}\n {...inputProps}\n />\n {hasAfter &&\n renderSlot(contentAfter, 'span', cn(inputClassNames.contentAfter, 'shrink-0 pe-2'))}\n </span>\n );\n } else {\n control = (\n <input\n ref={ref}\n className={cn(\n inputClassNames.root,\n inputClassNames.input,\n 'h-8 w-full rounded border border-input border-b-stroke-accessible bg-background px-3 text-body-1 text-foreground',\n 'placeholder:text-muted-foreground',\n inputFocus,\n 'disabled:cursor-not-allowed disabled:opacity-50',\n invalidLook && inputInvalid,\n className,\n )}\n {...controlProps}\n />\n );\n }\n\n if (!message) return control;\n return (\n <>\n {control}\n {message}\n </>\n );\n};\n\nInput.displayName = 'Input';\n"],"mappings":"sYAuCA,SAASsB,EAAY,EAA4D,CAC/E,OAAOC,IAAgB,IAASA,IAAgB,OAClD,CAeA,SAAgBC,EACd,EACA,EACA,EACA,EACqB,CACrB,IAAMC,EAAQzB,EAAAA,gBAAgB,EACxB0B,EAAczB,EAAAA,MAAM,OAAO,EAC3B0B,EACJ,CAACL,EAAYM,CAAmB,IAC/BC,IAAU,IAAS,OAAOA,GAAU,UAAYA,IAAU,IAE7D,GADoB,IAAW,OAAOA,GAAU,UAAaJ,GAAO,gBAClD,MAAO,CAAE,UAAS,UAAW,IAAA,GAAW,QAAS,IAAK,EAExE,GAAM,CAAE,GAAIK,EAAO,UAAWC,EAAkB,GAAGC,GAAgBC,GAAqB,CAAC,EACnFC,EAAYJ,GAASJ,EAW3B,MAAO,CAAE,UAAS,YAAW,SAAA,EAT3BxB,EAAAA,IA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B,uIACAI,EAAAA,iBACAsC,GAAA,uDAGAF,EAAM,UAAY,8DAClBc,CACF,EAZF,SAAA,CAcGN,GACC3C,EAAAA,WAAW4C,EAAe,OAAQlD,EAAAA,GAAGC,EAAAA,gBAAgB,cAAe,eAAe,CAAC,GACtF,EAAAiB,EAAA,IAAA,CAAC,QAAD,CACO,MACL,UAAWlB,EAAAA,GACTC,EAAAA,gBAAgB,MAChB,wEACA,oCACA,uBACA,6BACF,EACA,GAAIqD,CACL,CAAA,EACAH,GACC7C,EAAAA,WAAW8C,EAAc,OAAQpD,EAAAA,GAAGC,EAAAA,gBAAgB,aAAc,eAAe,CAAC,CAChF,GAEV,KACE,IACE,EAAAiB,EAAA,IAAA,CAAC,QAAD,CACO,MACL,UAAWlB,EAAAA,GACTC,EAAAA,gBAAgB,KAChBA,EAAAA,gBAAgB,MAChB,mHACA,oCACAM,EAAAA,WACA,kDACAoC,GAAA,gDACAY,CACF,EACA,GAAIP,CACL,CAAA,EAKL,OADKQ,GAEH,EAAAtC,EAAA,KAAA,CAAAV,EAAAA,SAAA,CAAA,SAAA,CACG6C,EACAG,CACD,CAAA,CAAA,EALiBH,CAOvB,EAEA,EAAM,YAAc"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { renderSlot as t, slotRendersContent as n } from "../../lib/slot.mjs";
|
|
4
|
+
import { inputClassNames as r } from "../../lib/classNames.mjs";
|
|
5
|
+
import { useId as i } from "../../hooks/useId.mjs";
|
|
6
|
+
import { joinIds as a } from "../../lib/aria.mjs";
|
|
7
|
+
import { useFieldContext as o, useFieldControl as s } from "../../hooks/useFieldControl.mjs";
|
|
8
|
+
import { inputFocus as c, inputFocusWithin as l } from "../../lib/styles.mjs";
|
|
9
|
+
import "react";
|
|
10
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
|
+
//#region src/components/input/Input.tsx
|
|
12
|
+
function p(e) {
|
|
13
|
+
return e === !1 || e === "false";
|
|
14
|
+
}
|
|
15
|
+
function m(t, n, r, a) {
|
|
16
|
+
let s = o(), c = i("error"), l = !p(r) && (t === !0 || typeof t == "string" && t !== "");
|
|
17
|
+
if (!l || typeof t != "string" || s?.hasErrorMessage) return {
|
|
18
|
+
invalid: l,
|
|
19
|
+
messageId: void 0,
|
|
20
|
+
message: null
|
|
21
|
+
};
|
|
22
|
+
let { id: u, className: f, ...m } = n ?? {}, h = u ?? c;
|
|
23
|
+
return {
|
|
24
|
+
invalid: l,
|
|
25
|
+
messageId: h,
|
|
26
|
+
message: /* @__PURE__ */ d("span", {
|
|
27
|
+
role: "alert",
|
|
28
|
+
...m,
|
|
29
|
+
id: h,
|
|
30
|
+
className: e(a, "mt-1 block text-caption-1 text-error", f),
|
|
31
|
+
children: t
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function h(e, t) {
|
|
36
|
+
return p(t) ? !1 : e || t === !0 || t === "true";
|
|
37
|
+
}
|
|
38
|
+
var g = ({ error: i, errorMessageProps: o, contentBefore: p, contentAfter: g, onChange: _, onValueChange: v, className: y, ref: b, id: x, "aria-label": S, "aria-labelledby": C, "aria-describedby": w, "aria-invalid": T, "aria-required": E, "aria-errormessage": D, required: O, ...k }) => {
|
|
39
|
+
let { invalid: A, messageId: j, message: M } = m(i, o, T, r.errorMessage), N = s({
|
|
40
|
+
id: x,
|
|
41
|
+
"aria-label": S,
|
|
42
|
+
"aria-labelledby": C,
|
|
43
|
+
"aria-describedby": a(w, j),
|
|
44
|
+
"aria-invalid": T ?? (A || void 0),
|
|
45
|
+
"aria-required": E,
|
|
46
|
+
required: O
|
|
47
|
+
}, { nativeRequired: !0 }), P = h(A, N["aria-invalid"]), F = _ || v ? (e) => {
|
|
48
|
+
_?.(e), v?.(e.currentTarget.value);
|
|
49
|
+
} : void 0, I = {
|
|
50
|
+
...k,
|
|
51
|
+
...N,
|
|
52
|
+
"aria-errormessage": a(D, j),
|
|
53
|
+
onChange: F
|
|
54
|
+
}, L = n(p), R = n(g), z;
|
|
55
|
+
if (L || R) {
|
|
56
|
+
let { style: n, hidden: i, ...a } = I;
|
|
57
|
+
z = /* @__PURE__ */ f("span", {
|
|
58
|
+
hidden: i,
|
|
59
|
+
style: n,
|
|
60
|
+
className: e(r.root, "inline-flex h-8 w-full items-center rounded border border-input border-b-stroke-accessible bg-background text-body-1 text-foreground", l, P && "border-destructive focus-within:border-b-destructive", k.disabled && "cursor-not-allowed opacity-50 has-focus-visible:opacity-100", y),
|
|
61
|
+
children: [
|
|
62
|
+
L && t(p, "span", e(r.contentBefore, "shrink-0 ps-2")),
|
|
63
|
+
/* @__PURE__ */ d("input", {
|
|
64
|
+
ref: b,
|
|
65
|
+
className: e(r.input, "h-full w-full min-w-0 bg-transparent px-2 text-body-1 text-foreground", "placeholder:text-muted-foreground", "focus:outline-hidden", "disabled:cursor-not-allowed"),
|
|
66
|
+
...a
|
|
67
|
+
}),
|
|
68
|
+
R && t(g, "span", e(r.contentAfter, "shrink-0 pe-2"))
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
} else z = /* @__PURE__ */ d("input", {
|
|
72
|
+
ref: b,
|
|
73
|
+
className: e(r.root, r.input, "h-8 w-full rounded border border-input border-b-stroke-accessible bg-background px-3 text-body-1 text-foreground", "placeholder:text-muted-foreground", c, "disabled:cursor-not-allowed disabled:opacity-50", P && "border-destructive focus:border-b-destructive", y),
|
|
74
|
+
...I
|
|
75
|
+
});
|
|
76
|
+
return M ? /* @__PURE__ */ f(u, { children: [z, M] }) : z;
|
|
77
|
+
};
|
|
78
|
+
g.displayName = "Input";
|
|
79
|
+
//#endregion
|
|
80
|
+
export { g as Input, h as isInvalidLook, m as useControlErrorMessage };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=Input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.mjs","names":["useId","_jsx","_Fragment","useId$1","isAriaValid","ariaInvalid","useControlErrorMessage","field","useFieldContext","generatedId","invalid","consumerAriaInvalid","error","ownId","messageClassName","messageRest","errorMessageProps","messageId","cn","partClassName","isInvalidLook","ownError","Input","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaRequired","ariaErrorMessage","props","inputClassNames","fieldProps","useFieldControl","joinIds","invalidLook","handleChange","onChange","onValueChange","event","controlProps","hasBefore","slotRendersContent","contentBefore","hasAfter","contentAfter","control","inputProps","inputFocusWithin","className","renderSlot","inputFocus","message","Fragment"],"sources":["../../../src/components/input/Input.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { joinIds } from '../../lib/aria';\nimport { inputClassNames } from '../../lib/classNames';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport { inputFocus, inputFocusWithin, inputInvalid, inputInvalidWithin } from '../../lib/styles';\nimport type { Slot } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\n\n/**\n * Props of the error message element that {@link Input}, `Select` and `Textarea` render after the\n * control for a string `error` (`id`, `className`, `role`, data attributes, …).\n */\nexport interface InputErrorMessageProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Ref to the message `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n /** Any `data-*` attribute. */\n [dataAttribute: `data-${string}`]: unknown;\n}\n\n/**\n * Result of {@link useControlErrorMessage}.\n *\n * @internal Not exported from the package.\n */\nexport interface ControlErrorMessage {\n /**\n * Whether `error` marks the control invalid (a non-empty string or `true`), unless the consumer\n * set `aria-invalid` to `false`/`\"false\"`.\n */\n invalid: boolean;\n /** The id of the rendered message, joined into `aria-describedby`/`aria-errormessage`. */\n messageId: string | undefined;\n /** The message element to render after the control, or `null`. */\n message: React.ReactElement | null;\n}\n\n/** Whether an `aria-invalid` value explicitly reports the control as valid. */\nfunction isAriaValid(ariaInvalid: React.AriaAttributes['aria-invalid']): boolean {\n return ariaInvalid === false || ariaInvalid === 'false';\n}\n\n/**\n * Shared by Input, Select and Textarea (internal): a non-empty string `error` renders a sibling\n * `<span role=\"alert\">` message, unless the surrounding `Field` already renders its own error\n * (`FieldContext.hasErrorMessage`); `true` only marks the control invalid. The consumer's\n * `aria-invalid` of `false`/`\"false\"` wins over `error`: the control is valid, so nothing is\n * marked invalid and no message is rendered or referenced (ARIA: an error message of a valid\n * control is hidden).\n *\n * `partClassName` is the host's stable `errorMessage` class, first in the message's classes\n * (Input, Select and Textarea each pass their own).\n *\n * @internal Not exported from the package.\n */\nexport function useControlErrorMessage(\n error: string | boolean | undefined,\n errorMessageProps: InputErrorMessageProps | undefined,\n consumerAriaInvalid?: React.AriaAttributes['aria-invalid'],\n partClassName?: string,\n): ControlErrorMessage {\n const field = useFieldContext();\n const generatedId = useId('error');\n const invalid =\n !isAriaValid(consumerAriaInvalid) &&\n (error === true || (typeof error === 'string' && error !== ''));\n const showMessage = invalid && typeof error === 'string' && !field?.hasErrorMessage;\n if (!showMessage) return { invalid, messageId: undefined, message: null };\n\n const { id: ownId, className: messageClassName, ...messageRest } = errorMessageProps ?? {};\n const messageId = ownId ?? generatedId;\n const message = (\n <span\n role=\"alert\"\n {...messageRest}\n id={messageId}\n className={cn(partClassName, 'mt-1 block text-caption-1 text-error', messageClassName)}\n >\n {error}\n </span>\n );\n return { invalid, messageId, message };\n}\n\n/**\n * Whether a text control shows the invalid look (error border), shared by Input, Select, Textarea\n * and SearchBox (internal): its own `error`, or a resolved `aria-invalid` of `true`/`\"true\"` —\n * from the consumer or from the surrounding `Field` (`useFieldControl`) — so the look always\n * matches the state assistive technology reports. A resolved `false`/`\"false\"` (the consumer's\n * override) never shows it, even with an own `error`. `\"grammar\"`/`\"spelling\"` alone do not\n * count; with an own `error` they keep the look (the control is reported invalid).\n *\n * @internal Not exported from the package.\n */\nexport function isInvalidLook(\n ownError: boolean,\n ariaInvalid: React.AriaAttributes['aria-invalid'],\n): boolean {\n if (isAriaValid(ariaInvalid)) return false;\n return ownError || ariaInvalid === true || ariaInvalid === 'true';\n}\n\n/** Properties for the Input component. */\nexport interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {\n /**\n * Validation error.\n * - A non-empty string renders the message in a `role=\"alert\"` element **after** the field (a\n * sibling, so it does not change which element receives `ref`, `className` or `style`) and\n * links it through `aria-describedby` and `aria-errormessage`. Inside a `Field` that renders\n * its own `error`, the message is not repeated.\n * - `true` only marks the input invalid (`aria-invalid` and the error border), as in 0.4.\n *\n * The error border also shows whenever the input ends up `aria-invalid=\"true\"` without this\n * prop (an `error` on the surrounding `Field`, or your own `aria-invalid`).\n * Your own `aria-invalid={false}` (or `\"false\"`) wins over this prop: the input is reported\n * valid and shows neither the error border nor the message.\n * Use `Field` (`label`, `hint`, `error`) for a complete field layout.\n */\n error?: string | boolean;\n /** Props of the error message element (`id`, `className`, …) rendered for a string `error`. */\n errorMessageProps?: InputErrorMessageProps;\n /**\n * Slot rendered before the input text (e.g., an icon). With content in either slot, a bordered\n * `<span>` around the input draws the field: it receives `className`, `style` and `hidden`,\n * while `ref`, `id`, `aria-*`, `data-*`, handlers and native attributes stay on the `<input>`.\n * A value that renders nothing (`false`, `''`, `[]`) is no slot.\n */\n contentBefore?: Slot<'span'>;\n /** Slot rendered after the input text (e.g., a suffix). Same wrapper as `contentBefore`. */\n contentAfter?: Slot<'span'>;\n /**\n * Called with the new string value on every change, next to the native `onChange` event\n * handler (`onValueChange={setName}` instead of `onChange={(e) => setName(e.target.value)}`).\n */\n onValueChange?: (value: string) => void;\n /** Ref to the `<input>` element (also with `contentBefore`/`contentAfter`). */\n ref?: React.Ref<HTMLInputElement>;\n}\n\n/**\n * A single-line text input with Fluent styling: a 1px border with an accessible bottom stroke, a\n * primary bottom border while focused, optional `contentBefore`/`contentAfter` slots and an\n * optional error message. Inside a `Field` it picks up the label, hint, error, `required` (native\n * attribute) and invalid state automatically.\n *\n * Every prop reaches the `<input>`, except with slot content: then a bordered `<span>` wrapper\n * draws the field and receives `className`, `style` and `hidden` (`ref` stays on the input).\n *\n * @example\n * <Field label=\"Email\" hint=\"We never share it\" required>\n * <Input type=\"email\" value={email} onValueChange={setEmail} />\n * </Field>\n */\nexport const Input = ({\n error,\n errorMessageProps,\n contentBefore,\n contentAfter,\n onChange,\n onValueChange,\n className,\n ref,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n required,\n ...props\n}: InputProps) => {\n const { invalid, messageId, message } = useControlErrorMessage(\n error,\n errorMessageProps,\n ariaInvalid,\n inputClassNames.errorMessage,\n );\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': joinIds(ariaDescribedBy, messageId),\n 'aria-invalid': ariaInvalid ?? (invalid || undefined),\n 'aria-required': ariaRequired,\n required,\n },\n { nativeRequired: true },\n );\n const invalidLook = isInvalidLook(invalid, fieldProps['aria-invalid']);\n\n const handleChange =\n onChange || onValueChange\n ? (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n onValueChange?.(event.currentTarget.value);\n }\n : undefined;\n\n const controlProps = {\n ...props,\n ...fieldProps,\n 'aria-errormessage': joinIds(ariaErrorMessage, messageId),\n onChange: handleChange,\n };\n\n const hasBefore = slotRendersContent(contentBefore);\n const hasAfter = slotRendersContent(contentAfter);\n\n let control: React.ReactElement;\n if (hasBefore || hasAfter) {\n // The bordered wrapper is the visible field: `className`, `style` and `hidden` size, style and\n // hide it; `ref`, `id`, `aria-*`, `data-*`, handlers and native attributes go to the input.\n const { style, hidden, ...inputProps } = controlProps;\n control = (\n <span\n hidden={hidden}\n style={style}\n className={cn(\n inputClassNames.root,\n 'inline-flex h-8 w-full items-center rounded border border-input border-b-stroke-accessible bg-background text-body-1 text-foreground',\n inputFocusWithin,\n invalidLook && inputInvalidWithin,\n // The dimmed look lifts while a focus ring shows inside the wrapper (focusable slot\n // content; the disabled input never takes focus): opacity would dim the ring below 3:1.\n props.disabled && 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100',\n className,\n )}\n >\n {hasBefore &&\n renderSlot(contentBefore, 'span', cn(inputClassNames.contentBefore, 'shrink-0 ps-2'))}\n <input\n ref={ref}\n className={cn(\n inputClassNames.input,\n 'h-full w-full min-w-0 bg-transparent px-2 text-body-1 text-foreground',\n 'placeholder:text-muted-foreground',\n 'focus:outline-hidden',\n 'disabled:cursor-not-allowed',\n )}\n {...inputProps}\n />\n {hasAfter &&\n renderSlot(contentAfter, 'span', cn(inputClassNames.contentAfter, 'shrink-0 pe-2'))}\n </span>\n );\n } else {\n control = (\n <input\n ref={ref}\n className={cn(\n inputClassNames.root,\n inputClassNames.input,\n 'h-8 w-full rounded border border-input border-b-stroke-accessible bg-background px-3 text-body-1 text-foreground',\n 'placeholder:text-muted-foreground',\n inputFocus,\n 'disabled:cursor-not-allowed disabled:opacity-50',\n invalidLook && inputInvalid,\n className,\n )}\n {...controlProps}\n />\n );\n }\n\n if (!message) return control;\n return (\n <>\n {control}\n {message}\n </>\n );\n};\n\nInput.displayName = 'Input';\n"],"mappings":";;;;;;;;;;;AAuCA,SAASI,EAAY,GAA4D;CAC/E,OAAOC,MAAgB,MAASA,MAAgB;AAClD;AAeA,SAAgBC,EACd,GACA,GACA,GACA,GACqB;CACrB,IAAMC,IAAQC,EAAgB,GACxBC,IAAcT,EAAM,OAAO,GAC3BU,IACJ,CAACN,EAAYO,CAAmB,MAC/BC,MAAU,MAAS,OAAOA,KAAU,YAAYA,MAAU;CAE7D,IADoB,MAAW,OAAOA,KAAU,YAAaL,GAAO,iBAClD,OAAO;EAAE;EAAS,WAAW,KAAA;EAAW,SAAS;CAAK;CAExE,IAAM,EAAE,IAAIM,GAAO,WAAWC,GAAkB,GAAGC,MAAgBC,KAAqB,CAAC,GACnFC,IAAYJ,KAASJ;CAW3B,OA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ZF,UAAA;IAcGR,KACCS,EAAWP,GAAe,QAAQvB,EAAGW,EAAgB,eAAe,eAAe,CAAC;IACtF,kBAAC,SAAD;KACO;KACL,WAAWX,EACTW,EAAgB,OAChB,yEACA,qCACA,wBACA,6BACF;KACA,GAAIgB;IACL,CAAA;IACAH,KACCM,EAAWL,GAAc,QAAQzB,EAAGW,EAAgB,cAAc,eAAe,CAAC;GAChF;;CAEV,OACE,IACE,kBAAC,SAAD;EACO;EACL,WAAWX,EACTW,EAAgB,MAChBA,EAAgB,OAChB,oHACA,qCACAoB,GACA,mDACAhB,KAAA,iDACAc,CACF;EACA,GAAIT;CACL,CAAA;CAKL,OADKY,IAEH,kBAAAhD,GAAA,EAAA,UAAA,CACG0C,GACAM,CACD,EAAA,CAAA,IALiBN;AAOvB;AAEA,EAAM,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/classNames.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("react/jsx-runtime");var a={small:`text-caption-1`,medium:`text-body-1`,large:`text-body-2`},o={regular:void 0,semibold:`font-semibold`,bold:`font-bold`},s=({required:e=!1,disabled:r=!1,size:s=`medium`,weight:c=`regular`,className:l,children:u,ref:d,...f})=>(0,i.jsxs)(`label`,{ref:d,className:t.cn(n.labelClassNames.root,r?`text-muted-foreground`:`text-foreground`,a[s],o[c],l),...f,children:[u,e&&(0,i.jsx)(`span`,{className:t.cn(n.labelClassNames.required,`ms-1 text-error`),"aria-hidden":`true`,children:`*`})]});s.displayName=`Label`,exports.Label=s;
|
|
2
|
+
//# sourceMappingURL=Label.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label.cjs","names":["cn","labelClassNames","require_runtime","require_cn","require_classNames","react","react_jsx_runtime","sizeMap","weightMap","Label","rest","disabled","size","weight","className","children","required"],"sources":["../../../src/components/input/Label.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { labelClassNames } from '../../lib/classNames';\nimport type { Size, TextWeight } from '../../lib/types';\n\n/** Properties for the Label component. */\nexport interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {\n /** Whether to show a required indicator asterisk (hidden from assistive technology; mark the\n * control itself `required`).\n * @default false\n */\n required?: boolean;\n /** Whether the label is visually dimmed.\n * @default false\n */\n disabled?: boolean;\n /** Text size of the label: `small` = caption-1, `medium` = body-1, `large` = body-2.\n * @default 'medium'\n */\n size?: Extract<Size, 'small' | 'medium' | 'large'>;\n /** Font weight of the label (the shared `TextWeight` vocabulary).\n * @default 'regular'\n */\n weight?: TextWeight;\n /** Ref to the `<label>` element. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\nconst sizeMap: Record<'small' | 'medium' | 'large', string> = {\n small: 'text-caption-1',\n medium: 'text-body-1',\n large: 'text-body-2',\n};\n\nconst weightMap: Record<TextWeight, string | undefined> = {\n regular: undefined,\n semibold: 'font-semibold',\n bold: 'font-bold',\n};\n\n/**\n * A text label for a form control (`htmlFor`), on the Fluent type ramp. The optional required\n * asterisk is decorative (`aria-hidden`). `Field` renders its own label; use `Label` for custom\n * layouts.\n *\n * @example\n * <Label htmlFor=\"email\" required>Email</Label>\n * <Input id=\"email\" required />\n */\nexport const Label = ({\n required = false,\n disabled = false,\n size = 'medium',\n weight = 'regular',\n className,\n children,\n ref,\n ...rest\n}: LabelProps) => {\n return (\n <label\n ref={ref}\n className={cn(\n labelClassNames.root,\n disabled ? 'text-muted-foreground' : 'text-foreground',\n sizeMap[size],\n weightMap[weight],\n className,\n )}\n {...rest}\n >\n {children}\n {required && (\n <span className={cn(labelClassNames.required, 'ms-1 text-error')} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n );\n};\n\nLabel.displayName = 'Label';\n"],"mappings":"oNA4BA,IAAMO,EAAwD,CAC5D,MAAO,iBACP,OAAQ,cACR,MAAO,aACT,EAEMC,EAAoD,CACxD,QAAS,IAAA,GACT,SAAU,gBACV,KAAM,WACR,EAWaC,GAAS,CACpB,WAAW,GACX,WAAW,GACX,OAAO,SACP,SAAS,UACT,YACA,WACA,MACA,GAAGC,MAGD,EAAAJ,EAAA,KAAA,CAAC,QAAD,CACO,MACL,UAAWN,EAAAA,GACTC,EAAAA,gBAAgB,KAChBU,EAAW,wBAA0B,kBACrCJ,EAAQK,GACRJ,EAAUK,GACVC,CACF,EACA,GAAIJ,EATN,SAAA,CAWGK,EACAC,IACC,EAAAV,EAAA,IAAA,CAAC,OAAD,CAAM,UAAWN,EAAAA,GAAGC,EAAAA,gBAAgB,SAAU,iBAAiB,EAAG,cAAY,OAAO,SAAA,GAE/E,CAAA,CAEH,IAIX,EAAM,YAAc"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { labelClassNames as t } from "../../lib/classNames.mjs";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/input/Label.tsx
|
|
7
|
+
var i = {
|
|
8
|
+
small: "text-caption-1",
|
|
9
|
+
medium: "text-body-1",
|
|
10
|
+
large: "text-body-2"
|
|
11
|
+
}, a = {
|
|
12
|
+
regular: void 0,
|
|
13
|
+
semibold: "font-semibold",
|
|
14
|
+
bold: "font-bold"
|
|
15
|
+
}, o = ({ required: o = !1, disabled: s = !1, size: c = "medium", weight: l = "regular", className: u, children: d, ref: f, ...p }) => /* @__PURE__ */ r("label", {
|
|
16
|
+
ref: f,
|
|
17
|
+
className: e(t.root, s ? "text-muted-foreground" : "text-foreground", i[c], a[l], u),
|
|
18
|
+
...p,
|
|
19
|
+
children: [d, o && /* @__PURE__ */ n("span", {
|
|
20
|
+
className: e(t.required, "ms-1 text-error"),
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
children: "*"
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
o.displayName = "Label";
|
|
26
|
+
//#endregion
|
|
27
|
+
export { o as Label };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=Label.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label.mjs","names":["sizeMap","weightMap","Label","rest","cn","labelClassNames","disabled","size","weight","className","children","required"],"sources":["../../../src/components/input/Label.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { labelClassNames } from '../../lib/classNames';\nimport type { Size, TextWeight } from '../../lib/types';\n\n/** Properties for the Label component. */\nexport interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {\n /** Whether to show a required indicator asterisk (hidden from assistive technology; mark the\n * control itself `required`).\n * @default false\n */\n required?: boolean;\n /** Whether the label is visually dimmed.\n * @default false\n */\n disabled?: boolean;\n /** Text size of the label: `small` = caption-1, `medium` = body-1, `large` = body-2.\n * @default 'medium'\n */\n size?: Extract<Size, 'small' | 'medium' | 'large'>;\n /** Font weight of the label (the shared `TextWeight` vocabulary).\n * @default 'regular'\n */\n weight?: TextWeight;\n /** Ref to the `<label>` element. */\n ref?: React.Ref<HTMLLabelElement>;\n}\n\nconst sizeMap: Record<'small' | 'medium' | 'large', string> = {\n small: 'text-caption-1',\n medium: 'text-body-1',\n large: 'text-body-2',\n};\n\nconst weightMap: Record<TextWeight, string | undefined> = {\n regular: undefined,\n semibold: 'font-semibold',\n bold: 'font-bold',\n};\n\n/**\n * A text label for a form control (`htmlFor`), on the Fluent type ramp. The optional required\n * asterisk is decorative (`aria-hidden`). `Field` renders its own label; use `Label` for custom\n * layouts.\n *\n * @example\n * <Label htmlFor=\"email\" required>Email</Label>\n * <Input id=\"email\" required />\n */\nexport const Label = ({\n required = false,\n disabled = false,\n size = 'medium',\n weight = 'regular',\n className,\n children,\n ref,\n ...rest\n}: LabelProps) => {\n return (\n <label\n ref={ref}\n className={cn(\n labelClassNames.root,\n disabled ? 'text-muted-foreground' : 'text-foreground',\n sizeMap[size],\n weightMap[weight],\n className,\n )}\n {...rest}\n >\n {children}\n {required && (\n <span className={cn(labelClassNames.required, 'ms-1 text-error')} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n );\n};\n\nLabel.displayName = 'Label';\n"],"mappings":";;;;;;AA4BA,IAAMA,IAAwD;CAC5D,OAAO;CACP,QAAQ;CACR,OAAO;AACT,GAEMC,IAAoD;CACxD,SAAS,KAAA;CACT,UAAU;CACV,MAAM;AACR,GAWaC,KAAS,EACpB,cAAW,IACX,cAAW,IACX,UAAO,UACP,YAAS,WACT,cACA,aACA,QACA,GAAGC,QAGD,kBAAC,SAAD;CACO;CACL,WAAWC,EACTC,EAAgB,MAChBC,IAAW,0BAA0B,mBACrCN,EAAQO,IACRN,EAAUO,IACVC,CACF;CACA,GAAIN;CATN,UAAA,CAWGO,GACAC,KACC,kBAAC,QAAD;EAAM,WAAWP,EAAGC,EAAgB,UAAU,iBAAiB;EAAG,eAAY;EAAO,UAAA;CAE/E,CAAA,CAEH;;AAIX,EAAM,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/composeEventHandlers.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../hooks/useId.cjs"),a=require("../../hooks/useMergedRefs.cjs"),o=require("../../hooks/useDismiss.cjs"),s=require("../portal/Portal.cjs"),c=require("../../lib/styles.cjs"),l=require("../../lib/icons.cjs"),u=require("../../hooks/useListbox.cjs"),d=require("../../hooks/usePopupPosition.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=f.createContext(!0);m.displayName=`OptionCheckContext`;var h=t.cn(`flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground`,`bg-(--option-bg) [--option-bg:transparent]`,`not-disabled:not-aria-disabled:hover:[--option-bg:var(--wave-subtle-hover)]`,`data-[selected]:[--option-bg:var(--wave-subtle-selected)]`,`data-[active]:[--option-bg:var(--wave-subtle-hover)]`,`data-[active]:outline-2 data-[active]:-outline-offset-2 data-[active]:outline-ring`,`aria-disabled:cursor-not-allowed aria-disabled:text-muted-foreground`),g=class{counts=new Map;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});add(e){return this.counts.set(e,(this.counts.get(e)??0)+1),this.notify(),()=>{let t=(this.counts.get(e)??1)-1;t>0?this.counts.set(e,t):this.counts.delete(e),this.notify()}}allHidden(e){if(e===void 0||this.counts.size===0)return!1;for(let t of this.counts.keys())if(!e.isHidden(t))return!1;return!0}notify(){for(let e of[...this.listeners])e()}},_=f.createContext([]);_.displayName=`OptionGroupContext`;var v=f.createContext(!1);v.displayName=`OptionGroupHiddenContext`;function y(e){let t=f.useContext(_);f.useLayoutEffect(()=>{if(t.length===0)return;let n=t.map(t=>t.add(e));return()=>{for(let e of n)e()}},[t,e])}function b(e){let{value:i,label:a,textValue:o,disabled:s=!1,hidden:d=!1,className:g,children:_,onClick:b,onPointerMove:x,ref:S,...C}=e,w=f.useContext(m),T=f.useContext(v),{selected:E,optionProps:D}=u.useListboxOption({value:i,label:a,textValue:o,disabled:s,hidden:d||T},S);y(i);let{ref:O,onClick:k,onPointerMove:A,...j}=D;return(0,p.jsxs)(`li`,{"data-value":i,...C,...j,ref:O,onClick:n.composeEventHandlers(b,k),onPointerMove:n.composeEventHandlers(x,A),className:t.cn(r.optionClassNames.root,h,E&&c.forcedColors.selectedContainer,g),children:[w&&(0,p.jsx)(l.CheckIcon,{className:t.cn(r.optionClassNames.checkIcon,`shrink-0`,!E&&`invisible`)}),(0,p.jsx)(`span`,{className:t.cn(r.optionClassNames.content,`min-w-0 flex-1`),children:_??i})]})}b.displayName=`Option`;var x=f.memo(b);x.displayName=`Option`;var S=u.markListboxElement(x,`option`);function C({label:e,className:n,children:a,hidden:o,ref:s,...c}){let l=i.useId(`option-group`),d=f.useContext(u.ListboxContext)?.store,m=f.useContext(_),h=f.useContext(v)||!!o,[y]=f.useState(()=>new g),b=f.useMemo(()=>[...m,y],[m,y]),x=f.useCallback(e=>{let t=y.subscribe(e),n=d?.subscribe(e);return()=>{t(),n?.()}},[y,d]),S=f.useSyncExternalStore(x,()=>y.allHidden(d),()=>!1);return(0,p.jsxs)(`li`,{...c,ref:s,role:`presentation`,hidden:o||S||void 0,className:t.cn(r.optionGroupClassNames.root,n),children:[(0,p.jsx)(`div`,{id:l,role:`presentation`,className:t.cn(r.optionGroupClassNames.label,`px-3 py-1 text-caption-1 font-semibold text-muted-foreground`),children:e}),(0,p.jsx)(`ul`,{role:`group`,"aria-labelledby":l,className:r.optionGroupClassNames.list,children:(0,p.jsx)(v.Provider,{value:h,children:(0,p.jsx)(_.Provider,{value:b,children:a})})})]})}C.displayName=`OptionGroup`;var w=u.markListboxElement(C,`group`);function T(e){let{open:t,surfaceOpen:n,onDismiss:r,rootRef:i,anchorRef:s}=e,c=f.useRef(null),{setReference:l,setFloating:u,floatingProps:p}=d.usePopupPosition({open:n,side:`bottom`,align:`start`,matchReferenceWidth:!0,fitViewport:!0}),{layerId:m}=o.useDismiss({open:t,onDismiss:e=>r(e),refs:[i,c],anchorRef:s,kind:`listbox`,escape:n,focusOutside:!0});return{layerId:m,setReference:l,surfaceRef:a.useMergedRefs(c,u),floatingProps:p}}function E(e){e.preventDefault()}function D(e){let{listbox:n,layerId:r,surfaceRef:i,floatingProps:a,open:o,expanded:c,emptyContent:l,"aria-label":d,"aria-labelledby":f,showCheck:h=!0,listboxClassName:g,surfaceClassName:_,children:v}=e,y=(0,p.jsx)(m.Provider,{value:h,children:(0,p.jsx)(u.ListboxContext.Provider,{value:n.context,children:(0,p.jsx)(`ul`,{...n.getListboxProps(),"aria-label":d,"aria-labelledby":f,hidden:!c||void 0,className:t.cn(g,`min-h-0 max-h-60 overflow-auto`),children:v})})});return!c&&(!o||c||l==null)?y:(0,p.jsxs)(p.Fragment,{children:[!c&&y,(0,p.jsx)(s.Portal,{layerId:r,children:(0,p.jsx)(`div`,{ref:i,...a,"data-wave-listbox-surface":``,onMouseDown:E,className:t.cn(_,`flex flex-col overflow-hidden rounded border border-border bg-background py-1 text-foreground shadow-4`),children:c?y:l})})]})}D.displayName=`ListboxSurface`,exports.ListboxSurface=D,exports.Option=S,exports.OptionGroup=w,exports.useListboxPopup=T;
|
|
2
|
+
//# sourceMappingURL=Option.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Option.cjs","names":["React","cn","useListboxOption","composeEventHandlers","optionClassNames","forcedColors","CheckIcon","useId","ListboxContext","optionGroupClassNames","usePopupPosition","useDismiss","useMergedRefs","_Fragment","Portal","require_runtime","require_cn","require_composeEventHandlers","require_classNames","require_useId","require_useMergedRefs","require_useDismiss","require_Portal","require_styles","require_icons","require_useListbox","require_usePopupPosition","react","react_jsx_runtime","OptionCheckContext","OPTION_CLASSES","OptionGroupMembers","listener","value","count","store","OptionGroupContext","OptionGroupHiddenContext","useOptionGroupMembership","groups","removes","group","remove","OptionImpl","rest","props","showCheck","groupHidden","hidden","ref","optionRef","selectOption","highlightOption","optionAttributes","optionProps","onClick","onPointerMove","selected","className","children","MemoOption","Option","OptionGroupImpl","labelId","parentGroups","hiddenByConsumer","members","subscribe","unsubscribeMembers","unsubscribeStore","empty","label","OptionGroup","useListboxPopup","options","surfaceElementRef","surfaceOpen","onDismiss","reason","rootRef","setFloating","preventMouseDown","event","ListboxSurface","ariaLabel","ariaLabelledBy","list","listbox","expanded","listboxClassName","emptyContent","surfaceRef","floatingProps","surfaceClassName"],"sources":["../../../src/components/input/Option.tsx"],"sourcesContent":["import * as React from 'react';\nimport { optionClassNames, optionGroupClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { CheckIcon } from '../../lib/icons';\nimport { forcedColors } from '../../lib/styles';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport type { DismissReason } from '../../hooks/useDismiss';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport {\n ListboxContext,\n markListboxElement,\n useListboxOption,\n type ListboxStore,\n type UseListboxResult,\n} from '../../hooks/useListbox';\nimport { Portal } from '../portal/Portal';\n\n/* ------------------------------------------------------------------ */\n/* Option */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the Option component used within Combobox and Dropdown. */\nexport interface OptionProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'value'> {\n /** Value associated with this option. Unique within its listbox. */\n value: string;\n /**\n * Text shown in the combobox (Combobox input, Dropdown trigger) when this option is selected.\n * Defaults to `textValue`, then the option's text content, then `value`. Pass it when the\n * children are not plain text (icons, custom components).\n */\n label?: string;\n /** Text matched by typeahead and filtering instead of the label. */\n textValue?: string;\n /**\n * Whether the option is disabled: it stays visible but is skipped by keyboard navigation and\n * cannot be selected.\n * @default false\n */\n disabled?: boolean;\n /**\n * Hides the option, like a native `<option hidden>`: it is not shown, keyboard navigation and\n * typeahead skip it, and it never becomes the active option. Its label stays known, so a\n * selected hidden option (a placeholder) still shows in the combobox. The options of a hidden\n * `OptionGroup` are hidden the same way.\n * @default false\n */\n hidden?: boolean;\n /** Ref to the option `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/** Whether options draw the selected check mark (P05-internal; TagPicker lists no selected options). */\nconst OptionCheckContext = React.createContext(true);\nOptionCheckContext.displayName = 'OptionCheckContext';\n\n/*\n * State is exposed as data attributes (C-CLASS): `data-active` (keyboard/pointer highlight),\n * `data-selected`, `data-disabled`. State classes come before the consumer's `className` in `cn()`.\n *\n * Backgrounds (input-pickers#20): one unconditional `bg-(--option-bg)` paints the option, and the\n * hover/selected/active variants only set `--option-bg`. A variant that set `background-color`\n * itself (class + attribute or pseudo-class) would out-specify a consumer's plain `bg-*` class in\n * the cascade even though `cn()` keeps it; instead tailwind-merge replaces `bg-(--option-bg)` with\n * the consumer's class, which is then the only background declaration on the option. A consumer\n * `data-[active]:bg-…` / `data-[selected]:bg-…` restyles a single state (it out-specifies the\n * unconditional reader). The active outline is the focus indicator and stays a state variant.\n *\n * A filtered-out option carries the `hidden` attribute; base.css's scoped `[hidden]` rule hides\n * it over `flex` and over a consumer's display class.\n */\nconst OPTION_CLASSES = cn(\n 'flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground',\n 'bg-(--option-bg) [--option-bg:transparent]',\n 'not-disabled:not-aria-disabled:hover:[--option-bg:var(--wave-subtle-hover)]',\n 'data-[selected]:[--option-bg:var(--wave-subtle-selected)]',\n 'data-[active]:[--option-bg:var(--wave-subtle-hover)]',\n 'data-[active]:outline-2 data-[active]:-outline-offset-2 data-[active]:outline-ring',\n 'aria-disabled:cursor-not-allowed aria-disabled:text-muted-foreground',\n);\n\n/**\n * The values of the options rendered inside an `OptionGroup`, whatever wraps them (custom\n * components, Fragments, nested groups): each option adds its value from a layout effect.\n */\nclass OptionGroupMembers {\n private readonly counts = new Map<string, number>();\n private readonly listeners = new Set<() => void>();\n\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n add(value: string): () => void {\n this.counts.set(value, (this.counts.get(value) ?? 0) + 1);\n this.notify();\n return () => {\n const count = (this.counts.get(value) ?? 1) - 1;\n if (count > 0) this.counts.set(value, count);\n else this.counts.delete(value);\n this.notify();\n };\n }\n\n /** At least one option, and every one of them is hidden (filtered out, or by the consumer). */\n allHidden(store: ListboxStore | undefined): boolean {\n if (store === undefined || this.counts.size === 0) return false;\n for (const value of this.counts.keys()) if (!store.isHidden(value)) return false;\n return true;\n }\n\n private notify(): void {\n for (const listener of [...this.listeners]) listener();\n }\n}\n\n/** The groups around an option, outermost first (P05-internal). */\nconst OptionGroupContext = React.createContext<readonly OptionGroupMembers[]>([]);\nOptionGroupContext.displayName = 'OptionGroupContext';\n\n/** A group around the option has the consumer's `hidden` attribute (P05-internal). */\nconst OptionGroupHiddenContext = React.createContext(false);\nOptionGroupHiddenContext.displayName = 'OptionGroupHiddenContext';\n\n/** Adds an option's value to every group around it while the option is mounted. */\nfunction useOptionGroupMembership(value: string): void {\n const groups = React.useContext(OptionGroupContext);\n React.useLayoutEffect(() => {\n if (groups.length === 0) return;\n const removes = groups.map((group) => group.add(value));\n return () => {\n for (const remove of removes) remove();\n };\n }, [groups, value]);\n}\n\nfunction OptionImpl(props: OptionProps) {\n const {\n value,\n label,\n textValue,\n disabled = false,\n hidden = false,\n className,\n children,\n onClick,\n onPointerMove,\n ref,\n ...rest\n } = props;\n const showCheck = React.useContext(OptionCheckContext);\n const groupHidden = React.useContext(OptionGroupHiddenContext);\n // A consumer-hidden option is not navigable; optionProps renders `hidden`.\n const { selected, optionProps } = useListboxOption<HTMLLIElement>(\n { value, label, textValue, disabled, hidden: hidden || groupHidden },\n ref,\n );\n useOptionGroupMembership(value);\n const {\n ref: optionRef,\n onClick: selectOption,\n onPointerMove: highlightOption,\n ...optionAttributes\n } = optionProps;\n\n return (\n <li\n data-value={value}\n {...rest}\n {...optionAttributes}\n ref={optionRef}\n onClick={composeEventHandlers(onClick, selectOption)}\n onPointerMove={composeEventHandlers(onPointerMove, highlightOption)}\n className={cn(\n optionClassNames.root,\n OPTION_CLASSES,\n selected && forcedColors.selectedContainer,\n className,\n )}\n >\n {showCheck && (\n <CheckIcon\n className={cn(optionClassNames.checkIcon, 'shrink-0', !selected && 'invisible')}\n />\n )}\n <span className={cn(optionClassNames.content, 'min-w-0 flex-1')}>{children ?? value}</span>\n </li>\n );\n}\nOptionImpl.displayName = 'Option';\n\nconst MemoOption = /* @__PURE__ */ React.memo(OptionImpl);\nMemoOption.displayName = 'Option';\n\n/**\n * An option of a `Combobox`, `Dropdown` (and `TagPicker`'s generated list). Renders\n * `<li role=\"option\">` with a stable id (`aria-activedescendant` target), `aria-selected`, a check\n * mark while selected and `data-active`/`data-selected`/`data-disabled` attributes for styling.\n *\n * Options register with the surrounding listbox (in DOM order, groups included), so they can be\n * wrapped, grouped or rendered conditionally. The option is memoized: moving the highlight\n * re-renders only the previously and the newly active option.\n *\n * Styling: `className` comes last. A plain background class (`className=\"bg-primary\"`) replaces\n * the built-in hover, selected and active backgrounds in every state. To restyle one state only,\n * use its data variant (`data-[active]:bg-…`, `data-[selected]:bg-…`). The active option keeps\n * its focus outline.\n *\n * Use it inside a `Combobox` or `Dropdown` only; it throws in development elsewhere.\n */\nexport const Option: React.NamedExoticComponent<OptionProps> = /* @__PURE__ */ markListboxElement(\n MemoOption,\n 'option',\n);\n\n/* ------------------------------------------------------------------ */\n/* OptionGroup */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the OptionGroup component used to group options. */\nexport interface OptionGroupProps extends React.LiHTMLAttributes<HTMLLIElement> {\n /** Heading label for the option group (names the group). */\n label: string;\n /**\n * Hides the group and every option in it (see `Option`'s `hidden`): keyboard navigation and\n * typeahead skip its options.\n * @default false\n */\n hidden?: boolean;\n /** Ref to the group's `<li role=\"presentation\">` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\nfunction OptionGroupImpl({ label, className, children, hidden, ref, ...rest }: OptionGroupProps) {\n const labelId = useId('option-group');\n const store = React.useContext(ListboxContext)?.store;\n const parentGroups = React.useContext(OptionGroupContext);\n const hiddenByConsumer = React.useContext(OptionGroupHiddenContext) || !!hidden;\n const [members] = React.useState(() => new OptionGroupMembers());\n const groups = React.useMemo(() => [...parentGroups, members], [parentGroups, members]);\n const subscribe = React.useCallback(\n (listener: () => void) => {\n const unsubscribeMembers = members.subscribe(listener);\n const unsubscribeStore = store?.subscribe(listener);\n return () => {\n unsubscribeMembers();\n unsubscribeStore?.();\n };\n },\n [members, store],\n );\n // Hidden while every option inside it is filtered out or hidden, also options wrapped in a\n // component (the options register with the group; re-read when they do and when the listbox\n // state changes).\n // The server render and the first client render show the group: no option has registered yet.\n const empty = React.useSyncExternalStore(\n subscribe,\n () => members.allHidden(store),\n () => false,\n );\n\n return (\n <li\n {...rest}\n ref={ref}\n role=\"presentation\"\n hidden={hidden || empty || undefined}\n className={cn(optionGroupClassNames.root, className)}\n >\n <div\n id={labelId}\n role=\"presentation\"\n className={cn(\n optionGroupClassNames.label,\n 'px-3 py-1 text-caption-1 font-semibold text-muted-foreground',\n )}\n >\n {label}\n </div>\n <ul role=\"group\" aria-labelledby={labelId} className={optionGroupClassNames.list}>\n <OptionGroupHiddenContext.Provider value={hiddenByConsumer}>\n <OptionGroupContext.Provider value={groups}>{children}</OptionGroupContext.Provider>\n </OptionGroupHiddenContext.Provider>\n </ul>\n </li>\n );\n}\nOptionGroupImpl.displayName = 'OptionGroup';\n\n/**\n * Groups options under a heading: `<li role=\"presentation\">` with the heading and a\n * `<ul role=\"group\" aria-labelledby>` of the options. Hidden while a filter (or their own `hidden`)\n * hides all its options, also options wrapped in a component or in nested groups.\n */\nexport const OptionGroup: React.FC<OptionGroupProps> = /* @__PURE__ */ markListboxElement(\n OptionGroupImpl,\n 'group',\n);\n\n/* ------------------------------------------------------------------ */\n/* Listbox popup (P05-internal, shared by Combobox, Dropdown, TagPicker) */\n/* ------------------------------------------------------------------ */\n\n/** Options of {@link useListboxPopup}. */\nexport interface UseListboxPopupOptions {\n /** The listbox is open (dismiss layer registered: outside press, focus outside). */\n open: boolean;\n /**\n * The portaled surface is shown: positioning runs and the layer takes Escape. While the listbox\n * is open with nothing shown (no options), Escape is left to an enclosing layer (overlays#1).\n */\n surfaceOpen: boolean;\n /** Close the listbox. */\n onDismiss: (reason: DismissReason) => void;\n /** The component root: presses and focus inside it are not \"outside\". */\n rootRef: React.RefObject<HTMLElement | null>;\n /** The combobox element (the layer's anchor). */\n anchorRef: React.RefObject<HTMLElement | null>;\n}\n\n/** Result of {@link useListboxPopup}. Destructure it (react-hooks/refs). */\nexport interface ListboxPopup {\n /** The dismiss layer id (pass to {@link ListboxSurface}). */\n layerId: string;\n /** Ref callback for the element the surface is positioned against. */\n setReference: (el: HTMLElement | null) => void;\n /** Ref callback for the surface. */\n surfaceRef: React.RefCallback<HTMLElement>;\n /** `data-side`, `data-align` and the position style for the surface. */\n floatingProps: { 'data-side': string; 'data-align': string; style: React.CSSProperties };\n}\n\n/**\n * Dismissal and positioning of a listbox surface (C-POPUPS, spec §5.4): `useDismiss` (Escape,\n * outside press, focus outside; `kind: 'listbox'`) and `usePopupPosition` (bottom-start, flip,\n * shift, the anchor's width, limited to the available space).\n */\nexport function useListboxPopup(options: UseListboxPopupOptions): ListboxPopup {\n const { open, surfaceOpen, onDismiss, rootRef, anchorRef } = options;\n const surfaceElementRef = React.useRef<HTMLElement | null>(null);\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open: surfaceOpen,\n side: 'bottom',\n align: 'start',\n matchReferenceWidth: true,\n fitViewport: true,\n });\n const { layerId } = useDismiss({\n open,\n onDismiss: (reason) => onDismiss(reason),\n refs: [rootRef, surfaceElementRef],\n anchorRef,\n kind: 'listbox',\n escape: surfaceOpen,\n focusOutside: true,\n });\n const surfaceRef = useMergedRefs<HTMLElement>(surfaceElementRef, setFloating);\n return { layerId, setReference, surfaceRef, floatingProps };\n}\n\n/** Props of {@link ListboxSurface}. */\nexport interface ListboxSurfaceProps {\n /** The listbox (from `useListbox`). */\n listbox: UseListboxResult;\n /** From {@link useListboxPopup}. */\n layerId: string;\n surfaceRef: React.RefCallback<HTMLElement>;\n floatingProps: ListboxPopup['floatingProps'];\n /** The listbox is open: `emptyContent` is shown only while it is (input-pickers#21). */\n open: boolean;\n /** The listbox is displayed: the list renders in the portaled surface. */\n expanded: boolean;\n /** While open but not expanded, show the surface with this content (e.g. \"No matches\"). */\n emptyContent?: React.ReactNode;\n /** Accessible name of the listbox. */\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** Options draw a check mark while selected. @default true */\n showCheck?: boolean;\n /** The host's stable class for the listbox element (its `listbox` part). */\n listboxClassName?: string;\n /** The host's stable class for the portaled surface (its `surface` part). */\n surfaceClassName?: string;\n children?: React.ReactNode;\n}\n\nfunction preventMouseDown(event: React.MouseEvent) {\n event.preventDefault();\n}\n\n/**\n * Renders the option list in a single container at a time (spec §2.5, §5.5): inline and `hidden`\n * inside the component root while closed (registration and ids exist from the first client\n * commit), and in a `Portal` surface while expanded — never both.\n */\nexport function ListboxSurface(props: ListboxSurfaceProps) {\n const {\n listbox,\n layerId,\n surfaceRef,\n floatingProps,\n open,\n expanded,\n emptyContent,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n showCheck = true,\n listboxClassName,\n surfaceClassName,\n children,\n } = props;\n\n const list = (\n <OptionCheckContext.Provider value={showCheck}>\n <ListboxContext.Provider value={listbox.context}>\n <ul\n {...listbox.getListboxProps()}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n hidden={!expanded || undefined}\n className={cn(listboxClassName, 'min-h-0 max-h-60 overflow-auto')}\n >\n {children}\n </ul>\n </ListboxContext.Provider>\n </OptionCheckContext.Provider>\n );\n\n // A closed listbox never leaves a surface behind: the text typed before closing survives it.\n const showEmpty = open && !expanded && emptyContent !== undefined && emptyContent !== null;\n if (!expanded && !showEmpty) return list;\n\n return (\n <>\n {!expanded && list}\n <Portal layerId={layerId}>\n <div\n ref={surfaceRef}\n {...floatingProps}\n data-wave-listbox-surface=\"\"\n onMouseDown={preventMouseDown}\n className={cn(\n surfaceClassName,\n 'flex flex-col overflow-hidden rounded border border-border bg-background py-1 text-foreground shadow-4',\n )}\n >\n {expanded ? list : emptyContent}\n </div>\n </Portal>\n </>\n );\n}\nListboxSurface.displayName = 'ListboxSurface';\n"],"mappings":"qjBAuDA,IAAM6B,EAAqB7B,EAAM,cAAc,EAAI,EACnD,EAAmB,YAAc,qBAiBjC,IAAM8B,EAAiB7B,EAAAA,GACrB,6FACA,6CACA,8EACA,4DACA,uDACA,qFACA,sEACF,EAMM8B,EAAN,KAAyB,CACvB,OAA0B,IAAI,IAC9B,UAA6B,IAAI,IAEjC,UAAa,IACX,KAAK,UAAU,IAAIC,CAAQ,M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