@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,197 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { warnDeprecated as t, warnOnce as n } from "../../lib/dev.mjs";
|
|
4
|
+
import { composeEventHandlers as r } from "../../lib/composeEventHandlers.mjs";
|
|
5
|
+
import { ratingClassNames as i, ratingDisplayClassNames as a } from "../../lib/classNames.mjs";
|
|
6
|
+
import { useControllable as o } from "../../hooks/useControllable.mjs";
|
|
7
|
+
import { getArrowIntent as s, getDirection as c } from "../../lib/direction.mjs";
|
|
8
|
+
import { useRovingTabIndex as l } from "../../hooks/useRovingTabIndex.mjs";
|
|
9
|
+
import { useMergedRefs as u } from "../../hooks/useMergedRefs.mjs";
|
|
10
|
+
import { useFieldContext as d, useFieldControl as f } from "../../hooks/useFieldControl.mjs";
|
|
11
|
+
import { focusRing as p } from "../../lib/styles.mjs";
|
|
12
|
+
import { StarIcon as m } from "../../lib/icons.mjs";
|
|
13
|
+
import { useFormReset as h } from "../../hooks/useFormReset.mjs";
|
|
14
|
+
import { HiddenInput as g } from "../internal/HiddenInput.mjs";
|
|
15
|
+
import * as _ from "react";
|
|
16
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
17
|
+
//#region src/components/input/Rating.tsx
|
|
18
|
+
var b = (e) => `${e} star${e === 1 ? "" : "s"}`, x = {
|
|
19
|
+
"extra-small": "h-3 w-3",
|
|
20
|
+
small: "h-4 w-4",
|
|
21
|
+
medium: "h-5 w-5",
|
|
22
|
+
large: "h-6 w-6",
|
|
23
|
+
"extra-large": "h-8 w-8"
|
|
24
|
+
}, S = {
|
|
25
|
+
"extra-small": "p-1.5",
|
|
26
|
+
small: "p-1",
|
|
27
|
+
medium: "p-0.5",
|
|
28
|
+
large: "p-0.5",
|
|
29
|
+
"extra-large": "p-0.5"
|
|
30
|
+
};
|
|
31
|
+
function C({ filled: e, className: t }) {
|
|
32
|
+
return e ? /* @__PURE__ */ v(m, { className: t }) : /* @__PURE__ */ v(m, {
|
|
33
|
+
className: t,
|
|
34
|
+
fill: "none",
|
|
35
|
+
stroke: "currentColor",
|
|
36
|
+
strokeWidth: 1.5
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
var w = ({ value: n, defaultValue: a, onValueChange: m, onChange: w, max: T = 5, size: E = "medium", disabled: D = !1, name: O, required: k, form: A, labels: j, className: M, id: N, "aria-label": P, "aria-labelledby": F, "aria-describedby": I, "aria-invalid": ee, "aria-required": te, onKeyDown: ne, onFocus: L, onMouseLeave: R, ref: z, ...B }) => {
|
|
40
|
+
w !== void 0 && t("Rating", "onChange", "onValueChange");
|
|
41
|
+
let V = a ?? 0, [H, U] = o(n, V, (e) => {
|
|
42
|
+
m?.(e), w?.(e);
|
|
43
|
+
}), [W, G] = _.useState(0), [K, q] = _.useState(D);
|
|
44
|
+
K !== D && (q(D), D && G(0));
|
|
45
|
+
let J = D ? H : W || H, { containerProps: Y, getTabIndex: X, focusValue: re } = l({ activeValue: H > 0 ? String(H) : null }), ie = (e) => {
|
|
46
|
+
if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
47
|
+
let t;
|
|
48
|
+
if (e.key === "Home") t = 1;
|
|
49
|
+
else if (e.key === "End") t = T;
|
|
50
|
+
else if (e.key === "ArrowUp") t = H + 1;
|
|
51
|
+
else if (e.key === "ArrowDown") t = H - 1;
|
|
52
|
+
else {
|
|
53
|
+
let n = s(e.key, {
|
|
54
|
+
orientation: "horizontal",
|
|
55
|
+
dir: c(e.currentTarget)
|
|
56
|
+
});
|
|
57
|
+
if (!n) return;
|
|
58
|
+
t = n === "next" ? H + 1 : H - 1;
|
|
59
|
+
}
|
|
60
|
+
e.preventDefault(), t = Math.min(t, T), !(D || t < 1 || t === H) && (re(String(t)), U(t));
|
|
61
|
+
}, Z = _.useRef(null), ae = u(z, Y.ref, Z), oe = d(), Q = f({
|
|
62
|
+
id: N,
|
|
63
|
+
"aria-label": P,
|
|
64
|
+
"aria-labelledby": F,
|
|
65
|
+
"aria-describedby": I,
|
|
66
|
+
"aria-invalid": ee,
|
|
67
|
+
"aria-required": te ?? k
|
|
68
|
+
}, { labelable: !1 }), se = k ?? oe?.required ?? !1, ce = Q["aria-label"] === void 0 && Q["aria-labelledby"] === void 0 ? "Rating" : void 0;
|
|
69
|
+
h(Z, () => U(V), A);
|
|
70
|
+
let le = () => {
|
|
71
|
+
Z.current?.querySelector("[data-roving-value][tabindex=\"0\"]")?.focus();
|
|
72
|
+
}, $ = x[E], ue = j?.star ?? b;
|
|
73
|
+
return /* @__PURE__ */ y("div", {
|
|
74
|
+
role: "radiogroup",
|
|
75
|
+
"aria-label": ce,
|
|
76
|
+
...Q,
|
|
77
|
+
"aria-disabled": D || void 0,
|
|
78
|
+
className: e(i.root, "relative inline-flex items-center gap-0.5", D && "pointer-events-none opacity-50", M),
|
|
79
|
+
...B,
|
|
80
|
+
ref: ae,
|
|
81
|
+
"data-roving-container": "",
|
|
82
|
+
onKeyDown: r(ne, ie),
|
|
83
|
+
onFocus: r(L, Y.onFocus, { checkDefaultPrevented: !1 }),
|
|
84
|
+
onMouseLeave: r(R, () => G(0), { checkDefaultPrevented: !1 }),
|
|
85
|
+
children: [Array.from({ length: T }, (t, n) => {
|
|
86
|
+
let r = n + 1, a = String(r), o = J >= r;
|
|
87
|
+
return /* @__PURE__ */ v("button", {
|
|
88
|
+
type: "button",
|
|
89
|
+
role: "radio",
|
|
90
|
+
"aria-checked": H === r,
|
|
91
|
+
"aria-label": ue(r, T),
|
|
92
|
+
"data-roving-value": a,
|
|
93
|
+
tabIndex: D ? -1 : X(a),
|
|
94
|
+
disabled: D,
|
|
95
|
+
className: e(i.star, "inline-flex cursor-pointer rounded border-0 bg-transparent transition-colors motion-reduce:transition-none disabled:cursor-not-allowed", S[E], p, o ? "text-rating" : "text-stroke-accessible"),
|
|
96
|
+
onClick: () => {
|
|
97
|
+
D || U(r);
|
|
98
|
+
},
|
|
99
|
+
onMouseEnter: () => {
|
|
100
|
+
D || G(r);
|
|
101
|
+
},
|
|
102
|
+
children: /* @__PURE__ */ v(C, {
|
|
103
|
+
filled: o,
|
|
104
|
+
className: e(i.icon, $)
|
|
105
|
+
})
|
|
106
|
+
}, a);
|
|
107
|
+
}), /* @__PURE__ */ v(g, {
|
|
108
|
+
type: "radio",
|
|
109
|
+
name: O,
|
|
110
|
+
form: A,
|
|
111
|
+
disabled: D,
|
|
112
|
+
value: H > 0 ? String(H) : "",
|
|
113
|
+
required: se,
|
|
114
|
+
onInvalid: le
|
|
115
|
+
})]
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
w.displayName = "Rating";
|
|
119
|
+
var T = {
|
|
120
|
+
"extra-small": "text-caption-1",
|
|
121
|
+
small: "text-caption-1",
|
|
122
|
+
medium: "text-body-1",
|
|
123
|
+
large: "text-body-2",
|
|
124
|
+
"extra-large": "text-body-2"
|
|
125
|
+
}, E = (e, t, n) => `Rating: ${n} out of ${t}`, D = (e, t) => e === 1 ? "1 rating" : `${t} ratings`;
|
|
126
|
+
function O(e) {
|
|
127
|
+
if (e !== void 0) try {
|
|
128
|
+
return Intl.getCanonicalLocales(e), e;
|
|
129
|
+
} catch {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
var k = ({ value: t, max: r = 5, size: i = "medium", showValue: o = !1, count: s, compact: c = !1, locale: l, labels: u, className: d, ref: f, ...p }) => {
|
|
134
|
+
let m = x[i], h = O(l), g = l !== void 0 && h === void 0;
|
|
135
|
+
_.useEffect(() => {
|
|
136
|
+
g && n(`RatingDisplay:invalid-locale:${l}`, `RatingDisplay: \`locale\` "${l}" is not a valid BCP 47 language tag (use hyphens, as in "en-US"). The runtime default locale formats the value instead, so the server and the browser may render different text.`);
|
|
137
|
+
}, [g, l]);
|
|
138
|
+
let b = new Intl.NumberFormat(h, { maximumFractionDigits: 1 }).format(t), S = s === void 0 ? void 0 : new Intl.NumberFormat(h).format(s), w = (u?.rating ?? E)(t, r, b), k = s === void 0 || S === void 0 ? w : `${w}, ${(u?.count ?? D)(s, S)}`, A = o || c || s !== void 0, j = T[i];
|
|
139
|
+
return /* @__PURE__ */ y("div", {
|
|
140
|
+
ref: f,
|
|
141
|
+
role: "img",
|
|
142
|
+
"aria-label": k,
|
|
143
|
+
"data-compact": c ? "" : void 0,
|
|
144
|
+
className: e(a.root, "inline-flex items-center gap-0.5", d),
|
|
145
|
+
...p,
|
|
146
|
+
children: [
|
|
147
|
+
c ? /* @__PURE__ */ v("span", {
|
|
148
|
+
className: e(a.star, "inline-flex text-rating"),
|
|
149
|
+
children: /* @__PURE__ */ v(C, {
|
|
150
|
+
filled: !0,
|
|
151
|
+
className: e(a.icon, m)
|
|
152
|
+
})
|
|
153
|
+
}) : Array.from({ length: r }, (n, r) => {
|
|
154
|
+
let i = Math.round(Math.min(1, Math.max(0, t - r)) * 100);
|
|
155
|
+
if (i > 0 && i < 100) return /* @__PURE__ */ y("span", {
|
|
156
|
+
className: e(a.star, "relative inline-flex text-stroke-accessible"),
|
|
157
|
+
children: [/* @__PURE__ */ v(C, {
|
|
158
|
+
filled: !1,
|
|
159
|
+
className: e(a.icon, m)
|
|
160
|
+
}), /* @__PURE__ */ v("span", {
|
|
161
|
+
className: "absolute inset-y-0 start-0 flex overflow-hidden text-rating",
|
|
162
|
+
style: { width: `${i}%` },
|
|
163
|
+
children: /* @__PURE__ */ v(C, {
|
|
164
|
+
filled: !0,
|
|
165
|
+
className: e(a.icon, m, "shrink-0")
|
|
166
|
+
})
|
|
167
|
+
})]
|
|
168
|
+
}, r);
|
|
169
|
+
let o = i === 100;
|
|
170
|
+
return /* @__PURE__ */ v("span", {
|
|
171
|
+
className: e(a.star, "inline-flex", o ? "text-rating" : "text-stroke-accessible"),
|
|
172
|
+
children: /* @__PURE__ */ v(C, {
|
|
173
|
+
filled: o,
|
|
174
|
+
className: e(a.icon, m)
|
|
175
|
+
})
|
|
176
|
+
}, r);
|
|
177
|
+
}),
|
|
178
|
+
A && /* @__PURE__ */ v("span", {
|
|
179
|
+
className: e(a.value, "ms-1 font-semibold text-foreground", j),
|
|
180
|
+
children: b
|
|
181
|
+
}),
|
|
182
|
+
S !== void 0 && /* @__PURE__ */ y("span", {
|
|
183
|
+
className: e(a.count, "ms-1 text-muted-foreground", j),
|
|
184
|
+
children: [
|
|
185
|
+
"(",
|
|
186
|
+
S,
|
|
187
|
+
")"
|
|
188
|
+
]
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
k.displayName = "RatingDisplay";
|
|
194
|
+
//#endregion
|
|
195
|
+
export { w as Rating, k as RatingDisplay };
|
|
196
|
+
|
|
197
|
+
//# sourceMappingURL=Rating.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rating.mjs","names":["React","defaultStarLabel","value","sizeMap","targetPaddingMap","Star","filled","StarIcon","Rating","valueProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","rest","onChange","warnDeprecated","initialValue","defaultValue","setValue","useControllable","onValueChange","next","hovered","setHovered","prevDisabled","setPrevDisabled","disabled","displayValue","useRovingTabIndex","handleKeyDown","max","intent","getArrowIntent","getDirection","focusValue","rootRef","mergedRef","useMergedRefs","ref","containerProps","field","useFieldContext","fieldProps","useFieldControl","required","isRequired","defaultName","form","focusTabStop","starSize","size","starLabel","labels","cn","ratingClassNames","className","composeEventHandlers","onKeyDown","onFocus","onMouseLeave","starValue","i","key","getTabIndex","focusRing","HiddenInput","textSizeMap","defaultRatingLabel","formattedValue","defaultCountLabel","count","formattedCount","supportedLocale","locale","RatingDisplay","formatLocale","invalidLocale","warnOnce","ratingName","name","showText","showValue","compact","textSize","ratingDisplayClassNames","percent"],"sources":["../../../src/components/input/Rating.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ratingClassNames, ratingDisplayClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { StarIcon } from '../../lib/icons';\nimport { focusRing } from '../../lib/styles';\nimport type { Size } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { HiddenInput } from '../internal/HiddenInput';\n\n/**\n * The Rating's built-in star names, for localization. Each member is optional and falls back to\n * its English default.\n */\nexport interface RatingLabels {\n /**\n * Accessible name of the star that chooses `value` (1 to `max`).\n * @default (value) => value === 1 ? '1 star' : `${value} stars`\n */\n star?: (value: number, max: number) => string;\n}\n\nconst defaultStarLabel = (value: number) => `${value} star${value !== 1 ? 's' : ''}`;\n\n/** Properties for the Rating component. */\nexport interface RatingProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /** Controlled rating value (`0` = no rating). */\n value?: number;\n /** Initial rating for uncontrolled usage (also the value a form reset restores).\n * @default 0\n */\n defaultValue?: number;\n /** Called with the new rating when it changes (not when the current star is chosen again). */\n onValueChange?: (value: number) => void;\n /**\n * Called with the new rating, exactly like `onValueChange`: only when the rating changes (0.4\n * also called it when the current star was clicked again, or a key was pressed at an end).\n * @deprecated Use `onValueChange`.\n */\n onChange?: (value: number) => void;\n /** Maximum number of stars.\n * @default 5\n */\n max?: number;\n /** Size of the star icons. Every size keeps a target of at least 24×24px.\n * @default 'medium'\n */\n size?: Size;\n /** Whether the rating is disabled and non-interactive.\n * @default false\n */\n disabled?: boolean;\n /**\n * Form field name. With a name, the chosen rating is submitted with the form (nothing while no\n * star is chosen).\n */\n name?: string;\n /** A star must be chosen before the form can be submitted (native validation). */\n required?: boolean;\n /** Id of the form the rating belongs to, when it is rendered outside that form. */\n form?: string;\n /**\n * Names of the stars (\"1 star\", \"2 stars\", …), for localization. The group's own name is\n * `aria-label` (default \"Rating\"). Unset members keep their English defaults.\n */\n labels?: RatingLabels;\n /** Ref to the `role=\"radiogroup\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Built-in texts of RatingDisplay, for localization. */\nexport interface RatingDisplayLabels {\n /**\n * Accessible name. `formattedValue` is `value` formatted with `locale` (as shown).\n * @default (value, max, formattedValue) => `Rating: ${formattedValue} out of ${max}`\n */\n rating?: (value: number, max: number, formattedValue: string) => string;\n /**\n * Count part of the name.\n * @default (count, formatted) => count === 1 ? '1 rating' : `${formatted} ratings`\n */\n count?: (count: number, formattedCount: string) => string;\n}\n\n/** Properties for the RatingDisplay (read-only) component. */\nexport interface RatingDisplayProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Rating value to display. A fraction is drawn as a partly filled star (`4.6` fills 60% of the\n * fifth star), so the stars show the value the accessible name reports.\n */\n value: number;\n /** Maximum number of stars.\n * @default 5\n */\n max?: number;\n /** Size of the star icons (and of the value and count text).\n * @default 'medium'\n */\n size?: Size;\n /**\n * Shows the value as text after the stars, formatted with `locale` (up to one decimal).\n * @default false\n */\n showValue?: boolean;\n /**\n * Number of ratings: shown as \"(1,160)\" after the value with the locale's digit grouping, and\n * added to the accessible name (\"…, 1,160 ratings\").\n */\n count?: number;\n /**\n * One filled star followed by the value (and the count) instead of `max` stars. Implies\n * `showValue`.\n * @default false\n */\n compact?: boolean;\n /**\n * BCP 47 locale of the value and count formatting (runtime default when omitted; pass it when\n * rendering on the server). A tag `Intl` rejects (the POSIX `de_DE`, a typo) falls back to the\n * runtime default locale (development warning).\n */\n locale?: string;\n /** Built-in texts, for localization. */\n labels?: RatingDisplayLabels;\n /** Ref to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst sizeMap: Record<Size, string> = {\n 'extra-small': 'h-3 w-3',\n small: 'h-4 w-4',\n medium: 'h-5 w-5',\n large: 'h-6 w-6',\n 'extra-large': 'h-8 w-8',\n};\n\n/** Padding that gives every interactive star a target of at least 24×24px (WCAG 2.5.8). */\nconst targetPaddingMap: Record<Size, string> = {\n 'extra-small': 'p-1.5', // 12px icon + 12px\n small: 'p-1', // 16px icon + 8px\n medium: 'p-0.5', // 20px icon + 4px\n large: 'p-0.5',\n 'extra-large': 'p-0.5',\n};\n\n/** A filled star, or an outlined one (the outline keeps a 3:1 non-text contrast). */\nfunction Star({ filled, className }: { filled: boolean; className: string }) {\n return filled ? (\n <StarIcon className={className} />\n ) : (\n <StarIcon className={className} fill=\"none\" stroke=\"currentColor\" strokeWidth={1.5} />\n );\n}\n\n/**\n * A star rating input (`role=\"radiogroup\"` of `role=\"radio\"` stars).\n *\n * - One tab stop (the chosen star, else the first). Keys choose relative to the current rating and\n * move focus to the chosen star, as in 0.4: Right/Up one star more, Left/Down one fewer\n * (Left/Right mirrored under `dir=\"rtl\"`), Home/End the first/last star. From an empty rating,\n * Right/Up/Home choose 1 star. Keys at the ends (and Left/Down while empty) emit nothing.\n * - The keyboard cannot clear a rating: Left/Down stop at 1 star (APG radio group; 0.4 went down\n * to 0). Only a controlled `value={0}` (or a form reset while `defaultValue` is 0) clears it.\n * - `onValueChange` (and the deprecated `onChange` alias) fire only when the rating changes, so\n * choosing the current star again calls neither.\n * - Hovering previews a value; the preview never outlives the hover or a disabled state.\n * - Inside a `Field` it is named by the Field label (instead of the default \"Rating\") and\n * described by its hint and error. The stars are named \"1 star\", \"2 stars\", …; `labels`\n * localizes these names.\n * - With `name` (or `required`) it takes part in native forms; a form reset restores\n * `defaultValue`.\n */\nexport const Rating = ({\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n max = 5,\n size = 'medium',\n disabled = false,\n name,\n required,\n form,\n labels,\n className,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n onKeyDown,\n onFocus,\n onMouseLeave,\n ref,\n ...rest\n}: RatingProps) => {\n if (onChange !== undefined) warnDeprecated('Rating', 'onChange', 'onValueChange');\n const initialValue = defaultValue ?? 0;\n const [value, setValue] = useControllable(valueProp, initialValue, (next: number) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n const [hovered, setHovered] = React.useState(0);\n // A hover preview must not survive the rating becoming disabled (adjust state during render).\n const [prevDisabled, setPrevDisabled] = React.useState(disabled);\n if (prevDisabled !== disabled) {\n setPrevDisabled(disabled);\n if (disabled) setHovered(0);\n }\n const displayValue = disabled ? value : hovered || value;\n\n // Roving tab stop (the chosen star, else the first) and focus moves; the keys are handled below.\n const { containerProps, getTabIndex, focusValue } = useRovingTabIndex({\n activeValue: value > 0 ? String(value) : null,\n });\n\n // Keys count from the current rating, not from the focused star (0.4 semantics): from an empty\n // rating, Tab lands on the unchosen first star and Right/Up/Home choose it. Never wraps.\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;\n let next: number;\n if (e.key === 'Home') next = 1;\n else if (e.key === 'End') next = max;\n else if (e.key === 'ArrowUp') next = value + 1;\n else if (e.key === 'ArrowDown') next = value - 1;\n else {\n const intent = getArrowIntent(e.key, {\n orientation: 'horizontal',\n dir: getDirection(e.currentTarget),\n });\n if (!intent) return;\n next = intent === 'next' ? value + 1 : value - 1;\n }\n e.preventDefault();\n next = Math.min(next, max);\n // The ends are no-ops (nothing is emitted, focus stays), and Left/Down never clear to 0.\n if (disabled || next < 1 || next === value) return;\n focusValue(String(next));\n setValue(next);\n };\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, containerProps.ref, rootRef);\n\n const field = useFieldContext();\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required always\n // matches the native validation below (`isRequired`).\n 'aria-required': ariaRequired ?? required,\n },\n { labelable: false },\n );\n const isRequired = required ?? field?.required ?? false;\n const defaultName =\n fieldProps['aria-label'] === undefined && fieldProps['aria-labelledby'] === undefined\n ? 'Rating'\n : undefined;\n\n useFormReset(rootRef, () => setValue(initialValue), form);\n\n const focusTabStop = () => {\n rootRef.current?.querySelector<HTMLElement>('[data-roving-value][tabindex=\"0\"]')?.focus();\n };\n\n const starSize = sizeMap[size];\n const starLabel = labels?.star ?? defaultStarLabel;\n\n return (\n <div\n role=\"radiogroup\"\n aria-label={defaultName}\n {...fieldProps}\n aria-disabled={disabled || undefined}\n className={cn(\n ratingClassNames.root,\n 'relative inline-flex items-center gap-0.5',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...rest}\n ref={mergedRef}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onFocus={composeEventHandlers(onFocus, containerProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onMouseLeave={composeEventHandlers(onMouseLeave, () => setHovered(0), {\n checkDefaultPrevented: false,\n })}\n >\n {Array.from({ length: max }, (_, i) => {\n const starValue = i + 1;\n const key = String(starValue);\n const filled = displayValue >= starValue;\n return (\n <button\n key={key}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === starValue}\n aria-label={starLabel(starValue, max)}\n data-roving-value={key}\n tabIndex={disabled ? -1 : getTabIndex(key)}\n disabled={disabled}\n className={cn(\n ratingClassNames.star,\n 'inline-flex cursor-pointer rounded border-0 bg-transparent transition-colors motion-reduce:transition-none disabled:cursor-not-allowed',\n targetPaddingMap[size],\n focusRing,\n filled ? 'text-rating' : 'text-stroke-accessible',\n )}\n onClick={() => {\n // Choosing the current star again is a no-op for both callbacks (useControllable).\n if (!disabled) setValue(starValue);\n }}\n onMouseEnter={() => {\n if (!disabled) setHovered(starValue);\n }}\n >\n <Star filled={filled} className={cn(ratingClassNames.icon, starSize)} />\n </button>\n );\n })}\n <HiddenInput\n type=\"radio\"\n name={name}\n form={form}\n disabled={disabled}\n value={value > 0 ? String(value) : ''}\n required={isRequired}\n onInvalid={focusTabStop}\n />\n </div>\n );\n};\nRating.displayName = 'Rating';\n\n/** Text size of the value and the count, following the star size. */\nconst textSizeMap: Record<Size, string> = {\n 'extra-small': 'text-caption-1',\n small: 'text-caption-1',\n medium: 'text-body-1',\n large: 'text-body-2',\n 'extra-large': 'text-body-2',\n};\n\nconst defaultRatingLabel = (_value: number, max: number, formattedValue: string) =>\n `Rating: ${formattedValue} out of ${max}`;\nconst defaultCountLabel = (count: number, formattedCount: string) =>\n count === 1 ? '1 rating' : `${formattedCount} ratings`;\n\n/** `locale` when `Intl` accepts it as a language tag, else `undefined` (the runtime default). */\nfunction supportedLocale(locale: string | undefined): string | undefined {\n if (locale === undefined) return undefined;\n try {\n Intl.getCanonicalLocales(locale);\n return locale;\n } catch {\n return undefined;\n }\n}\n\n/**\n * A read-only star rating (`role=\"img\"` named \"Rating: <value> out of <max>\"). A fractional value\n * is drawn with a partly filled star, so the stars and the name show the same value.\n *\n * - `showValue` adds the value as text after the stars, `count` the number of ratings (\"(1,160)\",\n * also added to the name), and `compact` shows one filled star with the value instead of `max`\n * stars (the root carries `data-compact`). Without them only the stars show.\n * - The value (up to one decimal) and the count are formatted with `locale`, in the text and in\n * the name; `labels` localizes the name. Pass `locale` when rendering on the server.\n */\nexport const RatingDisplay = ({\n value,\n max = 5,\n size = 'medium',\n showValue = false,\n count,\n compact = false,\n locale,\n labels,\n className,\n ref,\n ...rest\n}: RatingDisplayProps) => {\n const starSize = sizeMap[size];\n const formatLocale = supportedLocale(locale);\n const invalidLocale = locale !== undefined && formatLocale === undefined;\n React.useEffect(() => {\n if (invalidLocale) {\n warnOnce(\n `RatingDisplay:invalid-locale:${locale}`,\n `RatingDisplay: \\`locale\\` \"${locale}\" is not a valid BCP 47 language tag (use hyphens, as ` +\n 'in \"en-US\"). The runtime default locale formats the value instead, so the server and ' +\n 'the browser may render different text.',\n );\n }\n }, [invalidLocale, locale]);\n\n const formattedValue = new Intl.NumberFormat(formatLocale, { maximumFractionDigits: 1 }).format(\n value,\n );\n const formattedCount =\n count === undefined ? undefined : new Intl.NumberFormat(formatLocale).format(count);\n const ratingName = (labels?.rating ?? defaultRatingLabel)(value, max, formattedValue);\n const name =\n count === undefined || formattedCount === undefined\n ? ratingName\n : `${ratingName}, ${(labels?.count ?? defaultCountLabel)(count, formattedCount)}`;\n const showText = showValue || compact || count !== undefined;\n const textSize = textSizeMap[size];\n\n return (\n <div\n ref={ref}\n role=\"img\"\n aria-label={name}\n data-compact={compact ? '' : undefined}\n className={cn(ratingDisplayClassNames.root, 'inline-flex items-center gap-0.5', className)}\n {...rest}\n >\n {compact ? (\n <span className={cn(ratingDisplayClassNames.star, 'inline-flex text-rating')}>\n <Star filled className={cn(ratingDisplayClassNames.icon, starSize)} />\n </span>\n ) : (\n Array.from({ length: max }, (_, i) => {\n // The share of this star that the value covers, in whole percent.\n const percent = Math.round(Math.min(1, Math.max(0, value - i)) * 100);\n if (percent > 0 && percent < 100) {\n // The outline of an empty star, with the filled star clipped to the fraction over it\n // from the inline start (the reading direction of the stars, also under RTL).\n return (\n <span\n key={i}\n className={cn(\n ratingDisplayClassNames.star,\n 'relative inline-flex text-stroke-accessible',\n )}\n >\n <Star filled={false} className={cn(ratingDisplayClassNames.icon, starSize)} />\n <span\n className=\"absolute inset-y-0 start-0 flex overflow-hidden text-rating\"\n style={{ width: `${percent}%` }}\n >\n <Star filled className={cn(ratingDisplayClassNames.icon, starSize, 'shrink-0')} />\n </span>\n </span>\n );\n }\n const filled = percent === 100;\n return (\n <span\n key={i}\n className={cn(\n ratingDisplayClassNames.star,\n 'inline-flex',\n filled ? 'text-rating' : 'text-stroke-accessible',\n )}\n >\n <Star filled={filled} className={cn(ratingDisplayClassNames.icon, starSize)} />\n </span>\n );\n })\n )}\n {showText && (\n <span\n className={cn(\n ratingDisplayClassNames.value,\n 'ms-1 font-semibold text-foreground',\n textSize,\n )}\n >\n {formattedValue}\n </span>\n )}\n {formattedCount !== undefined && (\n <span className={cn(ratingDisplayClassNames.count, 'ms-1 text-muted-foreground', textSize)}>\n ({formattedCount})\n </span>\n )}\n </div>\n );\n};\nRatingDisplay.displayName = 'RatingDisplay';\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,IAAMC,KAAoB,MAAkB,GAAGC,EAAM,OAAOA,MAAU,IAAU,KAAN,OA4GpEC,IAAgC;CACpC,e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uD,IAAU,KAAK,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,GAAGrF,IAAQ6D,CAAC,CAAC,IAAI,GAAG;IACpE,IAAIwB,IAAU,KAAKA,IAAU,KAG3B,OACE,kBAAC,QAAD;KAEE,WAAWhC,EACT+B,EAAwB,MACxB,6CACF;KALF,UAAA,CAOE,kBAACjF,GAAD;MAAM,QAAQ;MAAO,WAAWkD,EAAG+B,EAAwB,MAAMnC,CAAQ;KAAI,CAAA,GAC7E,kBAAC,QAAD;MACE,WAAU;MACV,OAAO,EAAE,OAAO,GAAGoC,EAAQ,GAAG;MAE9B,UAAA,kBAAClF,GAAD;OAAM,QAAA;OAAO,WAAWkD,EAAG+B,EAAwB,MAAMnC,GAAU,UAAU;MAAI,CAAA;KAC7E,CAAA,CACF;IAbC,GAAAY,CAaD;IAGV,IAAMzD,IAASiF,MAAY;IAC3B,OACE,kBAAC,QAAD;KAEE,WAAWhC,EACT+B,EAAwB,MACxB,eACAhF,IAAS,gBAAgB,wBAC3B;KAEA,UAAA,kBAACD,GAAD;MAAc;MAAQ,WAAWkD,EAAG+B,EAAwB,MAAMnC,CAAQ;KAAI,CAAA;IAC1E,GARCY,CAQD;GAEV,CAAC;GAEFmB,KACC,kBAAC,QAAD;IACE,WAAW3B,EACT+B,EAAwB,OACxB,sCACAD,CACF;IAEC,UAAAf;GACG,CAAA;GAEPG,MAAmB,KAAA,KAClB,kBAAC,QAAD;IAAM,WAAWlB,EAAG+B,EAAwB,OAAO,8BAA8BD,CAAQ;IAAzF,UAAA;KAA4F;KACxFZ;KAAe;IACb;;EAEL;;AAET;AACA,EAAc,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../lib/classNames.cjs"),s=require("../../hooks/useControllable.cjs"),c=require("../../hooks/useMergedRefs.cjs"),l=require("../../hooks/useFieldControl.cjs"),u=require("../../lib/styles.cjs"),d=require("../button/Button.cjs"),f=require("../button/Button.slots.cjs"),p=require("../../lib/icons.cjs"),m=require("../../lib/mergeProps.cjs"),h=require("./Input.cjs"),g=require("../../hooks/useFormReset.cjs"),_=require("../../lib/labelInName.cjs");let v=require("react");v=e.__toESM(v,1);let y=require("react/jsx-runtime");var b=new Set([`type`,`disabled`,`form`,`formAction`,`formEncType`,`formMethod`,`formNoValidate`,`formTarget`,`name`,`value`,`popoverTarget`,`popoverTargetAction`]),x=/^on[A-Z]/,S=new Set([`aria-label`,`aria-labelledby`,`title`]),C=`Clear search`,w=()=>{},T=`a[href], button, input, select, textarea, [tabindex], [contenteditable]:not([contenteditable="false"])`,E={kind:`default`,buttonProps:{},content:null,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1};function D(e){return e===`button`||e===d.Button}function O(e,n,r){let a=i.slotRendersContent(r),s=i.materialiseSlotContent(r),c=_.hasTextLabel(s);if(e===d.Button){let e={};for(let[t,r]of Object.entries(n))t!==`children`&&!f.BUTTON_OWN_PROP_KEYS.has(t)&&(e[t]=r);let r=i.renderSlot(n.icon,`span`,t.cn(o.searchBoxClassNames.dismissIcon,`inline-flex`),{"aria-hidden":!0});return{buttonProps:e,content:r||a?f.placeButtonIcon(r,s,n.iconPosition):null,contentMayName:!0,literalTextLabel:c,disabledFocusable:!!n.disabledFocusable}}let{as:l,children:u,...p}=n;return{buttonProps:p,content:a?s:null,contentMayName:!0,literalTextLabel:c,disabledFocusable:!1}}function k(e){let r=e;if(n.isElementOfType(r,`button`,d.Button)){let e=r.props.children;return{kind:`element`,...O(n.getElementType(r),r.props,e)}}let a=i.resolveSlot(e,`span`);if(!a)return E;let{Component:s,props:c,children:l}=a;if(D(s))return{kind:`button-object`,...O(s,c,l)};let u={},f={},m=!1;for(let[e,t]of Object.entries(c))t!==void 0&&(b.has(e)||x.test(e)?(u[e]=t,m=!0):S.has(e)?u[e]=t:f[e]=t);let h=i.slotRendersContent(l),g=i.slotWrapsDefaultContent(s,{...f,children:l});if(g&&Object.keys(u).length===0&&Object.keys(f).length===0)return E;let _=g?(0,y.jsx)(p.DismissIcon,{}):h?l:void 0,C={"aria-hidden":!0,...f,className:t.cn(o.searchBoxClassNames.dismissIcon,f.className)},w=_===void 0?v.createElement(s,C):v.createElement(s,C,_);return{kind:m?`button-object`:`content`,buttonProps:u,content:w,contentMayName:!1,literalTextLabel:!1,disabledFocusable:!1}}var A=({value:e,defaultValue:n=``,onValueChange:d,onChange:b,onClear:x,placeholder:E=`Search`,disabled:D,contentBefore:O,contentAfter:A,dismiss:ee,className:te,ref:ne,controlRef:re,id:ie,"aria-label":ae,"aria-labelledby":oe,"aria-describedby":se,"aria-invalid":ce,"aria-required":le,"aria-errormessage":ue,"aria-details":de,required:fe,name:pe,form:j,readOnly:M,autoComplete:N,autoFocus:P,autoCapitalize:F,autoCorrect:I,inputMode:L,enterKeyHint:R,spellCheck:z,maxLength:B,minLength:me,pattern:he,tabIndex:ge,onFocus:_e,onBlur:ve,onKeyDown:ye,onKeyUp:be,onMouseDown:xe,hidden:Se,...Ce})=>{b!==void 0&&r.warnDeprecated(`SearchBox`,`onChange`,`onValueChange`);let[V,H]=s.useControllable(e,n,e=>{d?.(e),b?.(e)}),U=v.useRef(null),we=c.useMergedRefs(U,re);g.useFormReset(U,()=>H(n),j);let W=l.useFieldControl({id:ie,"aria-label":ae,"aria-labelledby":oe,"aria-describedby":se,"aria-invalid":ce,"aria-required":le,required:fe},{nativeRequired:!0}),Te=h.isInvalidLook(!1,W[`aria-invalid`]),G=k(ee),K=G.kind;v.useEffect(()=>{K===`element`?r.warnOnce(`SearchBox:dismiss-button-element`,"SearchBox: `dismiss` received a button element; its props were merged into the built-in clear button (buttons cannot be nested). Pass icon content instead, e.g. `dismiss={<MyIcon />}`."):K===`button-object`&&r.warnOnce(`SearchBox:dismiss-button-object`,'SearchBox: `dismiss` with button props (`as: "button"`, `onClick`, `type`, …) is deprecated and will be removed in 1.0; the props were merged into the built-in clear button. Pass icon content instead, e.g. `dismiss={<MyIcon />}`.')},[K]);let Ee=()=>{H(``),x?.(),U.current?.focus()},De=e=>{e.key!==`Escape`||e.nativeEvent.isComposing||!V||M||D||(e.preventDefault(),H(``),x?.())},Oe=e=>{let t=U.current,n=e.currentTarget,r=e.target;if(!t||D||e.button!==0||r===t||!(r instanceof Element)||!n.contains(r))return;let i=r.closest(T);i&&n.contains(i)||(e.preventDefault(),t.focus())},{onClick:ke,ref:Ae,...q}=G.buttonProps,J=Object.keys(q).some(e=>S.has(e)&&q[e]!=null),Y=G.contentMayName&&!J,X=G.literalTextLabel,[Z,je]=v.useState(null),Q=v.useCallback(e=>Z?_.observeTextLabel(Z,e):w,[Z]),Me=v.useSyncExternalStore(Q,()=>Z?_.hasRenderedTextLabel(Z):X,()=>X),Ne=Y&&Me,Pe=c.useMergedRefs(Ae,Y?je:void 0),$=m.mergeProps({type:`button`,disabled:D,"aria-label":J||Ne?void 0:C,className:t.cn(o.searchBoxClassNames.dismissButton,`me-1 flex h-6 w-6 shrink-0 items-center justify-center rounded bg-transparent p-0 text-muted-foreground`,`not-disabled:not-aria-disabled:hover:text-foreground`,u.focusRing,`disabled:cursor-not-allowed`,f.mergedAriaDisabledClasses)},q),Fe=$.dangerouslySetInnerHTML==null?K===`content`?G.content:G.content??(0,y.jsx)(p.DismissIcon,{className:o.searchBoxClassNames.dismissIcon}):void 0,Ie=i.slotRendersContent(O),Le=i.slotRendersContent(A);return(0,y.jsxs)(`div`,{ref:ne,className:t.cn(o.searchBoxClassNames.root,`relative inline-flex h-8 w-full items-center rounded border border-input border-b-stroke-accessible bg-background text-body-1 text-foreground`,u.inputFocusWithin,Te&&`border-destructive focus-within:border-b-destructive`,D&&`cursor-not-allowed opacity-50 has-focus-visible:opacity-100`,te),hidden:Se,...Ce,onMouseDown:e=>a.composeEventHandlers(xe,Oe)(e),children:[(0,y.jsx)(`span`,{className:t.cn(o.searchBoxClassNames.contentBefore,`flex shrink-0 items-center ps-2`),children:Ie?i.renderSlot(O,`span`,`shrink-0`):(0,y.jsx)(p.SearchIcon,{className:`text-muted-foreground`})}),(0,y.jsx)(`input`,{ref:we,type:`search`,value:V,onChange:e=>H(e.target.value),placeholder:E,disabled:D,className:t.cn(o.searchBoxClassNames.input,`h-full min-w-0 flex-1 appearance-none border-none bg-transparent px-2 text-body-1 text-foreground`,`placeholder:text-muted-foreground`,`focus:outline-hidden`,`disabled:cursor-not-allowed`,`[&::-webkit-search-cancel-button]:hidden`),"aria-errormessage":ue,"aria-details":de,name:pe,form:j,readOnly:M,autoComplete:N,autoFocus:P,autoCapitalize:F,autoCorrect:I,inputMode:L,enterKeyHint:R,spellCheck:z,maxLength:B,minLength:me,pattern:he,tabIndex:ge,onFocus:_e,onBlur:ve,onKeyDown:a.composeEventHandlers(ye,De),onKeyUp:be,...W}),Le&&(0,y.jsx)(`span`,{className:t.cn(o.searchBoxClassNames.contentAfter,`flex shrink-0 items-center pe-2`),children:i.renderSlot(A,`span`,`shrink-0`)}),V&&!M?(0,y.jsx)(`button`,{...$,ref:Pe,type:$.type??`button`,disabled:D||$.disabled,onClick:e=>a.composeEventHandlers(ke,Ee)(e),...G.disabledFocusable?f.MERGED_DISABLED_FOCUSABLE_PROPS:void 0,children:Fe}):null]})};A.displayName=`SearchBox`,exports.SearchBox=A;
|
|
2
|
+
//# sourceMappingURL=SearchBox.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBox.cjs","names":["Button","slotRendersContent","materialiseSlotContent","hasTextLabel","BUTTON_OWN_PROP_KEYS","renderSlot","cn","searchBoxClassNames","placeButtonIcon","isElementOfType","getElementType","resolveSlot","slotWrapsDefaultContent","DismissIcon","React","useControllable","useMergedRefs","useFieldControl","isInvalidLook","observeTextLabel","hasRenderedTextLabel","mergeProps","focusRing","mergedAriaDisabledClasses","inputFocusWithin","composeEventHandlers","SearchIcon","MERGED_DISABLED_FOCUSABLE_PROPS","require_runtime","require_cn","require_children","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_useControllable","require_useMergedRefs","require_useFieldControl","require_styles","require_Button","require_Button_slots","require_icons","require_mergeProps","require_Input","require_useFormReset","require_labelInName","react","react_jsx_runtime","BUTTON_ONLY_KEYS","HANDLER_KEY","NAMING_KEYS","DEFAULT_CLEAR_LABEL","noop","INTERACTIVE_CONTENT","DEFAULT_DISMISS","isButtonType","type","splitButtonLike","hasChildren","children","content","literalTextLabel","buttonProps","key","value","props","iconNode","_children","resolveDismiss","node","dismiss","resolved","Component","contentProps","hasButtonProps","empty","contentChildren","iconProps","SearchBox","controlledValue","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","onChange","setValue","defaultValue","onValueChange","next","inputRef","mergedInputRef","controlRef","form","fieldProps","invalidLook","dismissParts","dismissKind","handleClear","onClear","handleKeyDown","event","readOnly","disabled","handleRootMouseDown","input","root","target","control","slotOnClick","slotRef","slotButtonProps","hasOwnName","checksContent","labelTarget","setLabelTarget","subscribeToContent","contentHasTextLabel","namedByContent","clearRef","clearButtonProps","clearContent","hasBefore","contentBefore","hasAfter","contentAfter","className","onMouseDown","onKeyDown"],"sources":["../../../src/components/input/SearchBox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getElementType, isElementOfType } from '../../lib/children';\nimport { searchBoxClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport { DismissIcon, SearchIcon } from '../../lib/icons';\nimport { hasRenderedTextLabel, hasTextLabel, observeTextLabel } from '../../lib/labelInName';\nimport { mergeProps } from '../../lib/mergeProps';\nimport {\n materialiseSlotContent,\n renderSlot,\n resolveSlot,\n slotRendersContent,\n slotWrapsDefaultContent,\n} from '../../lib/slot';\nimport { focusRing, inputFocusWithin, inputInvalidWithin } from '../../lib/styles';\nimport type { Slot, SlotObject } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { Button } from '../button/Button';\nimport {\n BUTTON_OWN_PROP_KEYS,\n MERGED_DISABLED_FOCUSABLE_PROPS,\n mergedAriaDisabledClasses,\n placeButtonIcon,\n} from '../button/Button.slots';\nimport { isInvalidLook } from './Input';\n\n/**\n * Props that SearchBox routes to its `<input>` (C-ROUTING): the id, the ARIA naming/validation\n * attributes, native text-input attributes and the focus/keyboard handlers.\n */\nexport type SearchBoxInputProps = Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'id'\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-describedby'\n | 'aria-invalid'\n | 'aria-required'\n | 'aria-errormessage'\n | 'aria-details'\n | 'name'\n | 'form'\n | 'required'\n | 'readOnly'\n | 'autoComplete'\n | 'autoFocus'\n | 'autoCapitalize'\n | 'autoCorrect'\n | 'inputMode'\n | 'enterKeyHint'\n | 'spellCheck'\n | 'maxLength'\n | 'minLength'\n | 'pattern'\n | 'tabIndex'\n | 'onFocus'\n | 'onBlur'\n | 'onKeyDown'\n | 'onKeyUp'\n>;\n\n/** Properties for the SearchBox component. */\nexport interface SearchBoxProps\n extends\n Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | keyof SearchBoxInputProps\n >,\n SearchBoxInputProps {\n /** Controlled search text value. */\n value?: string;\n /** Initial search text for uncontrolled usage (also what a form reset restores).\n * @default ''\n */\n defaultValue?: string;\n /** Called with the new search text when it changes (typing or clearing). */\n onValueChange?: (value: string) => void;\n /**\n * Called with the new search text when it changes.\n * @deprecated Use `onValueChange`. (`onChange` is reserved for native change events.)\n */\n onChange?: (value: string) => void;\n /**\n * Called when the user clears the search: with the clear button, or with Escape while there is\n * text (after `onValueChange('')`).\n */\n onClear?: () => void;\n /** Placeholder text shown when the input is empty.\n * @default 'Search'\n */\n placeholder?: string;\n /** Whether the search box is disabled and non-interactive. */\n disabled?: boolean;\n /**\n * Slot rendered before the text (replaces the default search icon). It takes the room it needs;\n * the text starts after it. A value that renders nothing (`null`, `false`, `''`, an empty array\n * or Fragment) keeps the default icon.\n */\n contentBefore?: Slot<'span'>;\n /**\n * Slot rendered after the text, before the clear button. It takes the room it needs; the text\n * ends before it. A value that renders nothing (`false`, `''`, an empty array or Fragment) is no\n * slot: nothing takes room.\n */\n contentAfter?: Slot<'span'>;\n /**\n * Content of the clear button (replaces the default dismiss icon). It always renders **inside**\n * the built-in `<button type=\"button\" aria-label=\"Clear search\">`, which clears the value, calls\n * `onClear` and moves focus back to the input. The slot cannot hide the clear button or leave\n * it empty: content that renders nothing (`null`, `false`, `true`, `''`, or an array, `Set`,\n * generator or Fragment of only those) keeps the default icon, and a slot object without\n * children (`{ className: 'text-error' }`) wraps the default icon in its element (not when it\n * brings markup of its own through `dangerouslySetInnerHTML`, or is a void or component element).\n *\n * A `<button>` element or a Wave `Button` passed here is not nested: its props are merged into\n * the built-in button (its `onClick` runs first; `preventDefault()` cancels the clear) and its\n * children become the content, with a development warning. A Wave `Button`'s own props are not\n * attributes: its `icon` becomes decorative content before its children (after them with\n * `iconPosition=\"after\"`), `disabledFocusable` makes the clear button unavailable but focusable\n * as on the Button (nothing is cleared), and `appearance` and `size` are ignored. The 0.4\n * button-object form (`{ as: 'button', onClick, … }` or an object with button props) is\n * **deprecated**: its button props are merged the same way. Pass icon content instead.\n *\n * Name (WCAG 2.5.3 Label in Name): content is decorative (`aria-hidden`), so the button keeps\n * the name \"Clear search\". An `aria-label`, `aria-labelledby` or `title` on the merged button or\n * on a slot object names the button instead (`{ children: 'Reset', 'aria-label': 'Reset' }`).\n * The children of a merged `<button>`/`Button` (or of `{ as: 'button' }`) are rendered as is:\n * when they render a text label (at least two letters or digits outside `aria-hidden`/`hidden`\n * content, text from components such as translations included), that text names the button;\n * an icon or a lone character (`X`, `×`) keeps \"Clear search\". Text hidden only with CSS still\n * counts as the label, so give a button with a responsive label an explicit `aria-label`.\n */\n dismiss?: Slot<'span'> | SlotObject<'button'>;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n /** Ref to the `<input type=\"search\">` (the focusable control). */\n controlRef?: React.Ref<HTMLInputElement>;\n}\n\ntype UnknownProps = Record<string, unknown>;\n\n/** Attributes that only make sense on the clear `<button>` itself (merged onto it). */\nconst BUTTON_ONLY_KEYS: ReadonlySet<string> = new Set([\n 'type',\n 'disabled',\n 'form',\n 'formAction',\n 'formEncType',\n 'formMethod',\n 'formNoValidate',\n 'formTarget',\n 'name',\n 'value',\n 'popoverTarget',\n 'popoverTargetAction',\n]);\nconst HANDLER_KEY = /^on[A-Z]/;\n\n/**\n * Attributes that name the clear button (C-SLOTS naming). On a merged button or a slot object they\n * go to the clear button (slot content is `aria-hidden`), and any of them replaces the default\n * `aria-label`.\n */\nconst NAMING_KEYS: ReadonlySet<string> = new Set(['aria-label', 'aria-labelledby', 'title']);\n\n/** Default name of the clear button. */\nconst DEFAULT_CLEAR_LABEL = 'Clear search';\n\ninterface DismissParts {\n /**\n * `default`: no slot (default icon); `content`: icon content; `element`: a `<button>`/`Button`\n * element; `button-object`: the deprecated button-object form.\n */\n kind: 'default' | 'content' | 'element' | 'button-object';\n /** Props merged onto the built-in clear button. */\n buttonProps: UnknownProps;\n /** Content of the clear button (`null` = the default icon, except for `content`). */\n content: React.ReactNode;\n /**\n * `true` when the content is rendered as is (a merged `<button>`/`Button` or `{ as: 'button' }`),\n * so a text label in it names the button (C-SLOTS naming, WCAG 2.5.3); `false` when the content\n * is decorative (`aria-hidden`).\n */\n contentMayName: boolean;\n /**\n * Whether the literal children contain a text label: the name for the server render and the\n * first client render. After mount the rendered button's text decides.\n */\n literalTextLabel: boolean;\n /**\n * Whether a merged Wave `Button` set `disabledFocusable`: the clear button is then unavailable\n * but focusable, as the Button would be.\n */\n disabledFocusable: boolean;\n}\n\nconst noop = () => {};\n\n/**\n * Elements inside the field that keep a press to themselves: a control in a slot, the clear\n * button.\n */\nconst INTERACTIVE_CONTENT =\n 'a[href], button, input, select, textarea, [tabindex], [contenteditable]:not([contenteditable=\"false\"])';\n\nconst DEFAULT_DISMISS: DismissParts = {\n kind: 'default',\n buttonProps: {},\n content: null,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n};\n\nfunction isButtonType(type: unknown): boolean {\n return type === 'button' || type === Button;\n}\n\n/**\n * Splits the props of a button-like element or object into button props and content. The content\n * is rendered as is, so a text label in it names the button (C-SLOTS naming). Content that renders\n * nothing is `null` (the default icon); a generator is read once and rendered as its items.\n */\nfunction splitButtonLike(type: unknown, props: UnknownProps, children: React.ReactNode) {\n const hasChildren = slotRendersContent(children);\n const content = materialiseSlotContent(children);\n const literalTextLabel = hasTextLabel(content);\n if (type === Button) {\n // Wave Button's own props do not belong on a native <button>: its icon becomes content (after\n // the children with `iconPosition=\"after\"`) and `disabledFocusable` is applied by the caller.\n const buttonProps: UnknownProps = {};\n for (const [key, value] of Object.entries(props)) {\n if (key !== 'children' && !BUTTON_OWN_PROP_KEYS.has(key)) buttonProps[key] = value;\n }\n const iconNode = renderSlot(\n props.icon as Slot<'span'>,\n 'span',\n cn(searchBoxClassNames.dismissIcon, 'inline-flex'),\n { 'aria-hidden': true },\n );\n const buttonContent =\n iconNode || hasChildren ? placeButtonIcon(iconNode, content, props.iconPosition) : null;\n return {\n buttonProps,\n content: buttonContent,\n contentMayName: true,\n literalTextLabel,\n disabledFocusable: Boolean(props.disabledFocusable),\n };\n }\n const { as, children: _children, ...buttonProps } = props;\n // `null` content falls back to the default icon.\n return {\n buttonProps,\n content: hasChildren ? content : null,\n contentMayName: true,\n literalTextLabel,\n disabledFocusable: false,\n };\n}\n\n/**\n * Splits `dismiss` into the props merged onto the built-in clear button and its content. Content\n * that renders nothing (`slotRendersContent`) never leaves the button empty: without other props\n * it is the default icon; a slot object with its own content props (`className`, `style`, …)\n * wraps the default icon in its element.\n */\nfunction resolveDismiss(dismiss: SearchBoxProps['dismiss']): DismissParts {\n // The type is unwrapped (C-COMPOUND): a Button written in a Server Component arrives as a lazy\n // client reference, and must be merged like a plain one rather than nested inside the clear\n // button. A slot object is never an element, so the check can take any slot value as a node.\n const node = dismiss as React.ReactNode;\n if (isElementOfType<UnknownProps>(node, 'button', Button)) {\n const children = node.props.children as React.ReactNode;\n return {\n kind: 'element',\n ...splitButtonLike(getElementType(node), node.props, children),\n };\n }\n // Resolved once: a generator is materialised (and cached) by resolveSlot, so it can be checked\n // for emptiness and rendered without being consumed twice.\n const resolved = resolveSlot(dismiss as Slot<'span'>, 'span');\n if (!resolved) return DEFAULT_DISMISS;\n const { Component, props, children } = resolved;\n if (isButtonType(Component)) {\n return { kind: 'button-object', ...splitButtonLike(Component, props, children) };\n }\n const buttonProps: UnknownProps = {};\n const contentProps: UnknownProps = {};\n let hasButtonProps = false;\n for (const [key, value] of Object.entries(props)) {\n // resolveSlot sets `className: undefined` when there are no classes.\n if (value === undefined) continue;\n if (BUTTON_ONLY_KEYS.has(key) || HANDLER_KEY.test(key)) {\n buttonProps[key] = value;\n hasButtonProps = true;\n } else if (NAMING_KEYS.has(key)) {\n // The content is aria-hidden, so a naming attribute names the clear button instead (not the\n // deprecated button-object form).\n buttonProps[key] = value;\n } else {\n contentProps[key] = value;\n }\n }\n // A void (`img`), component (`{ as: MyIcon }`) or markup (`dangerouslySetInnerHTML`) slot\n // renders content of its own.\n const hasChildren = slotRendersContent(children);\n const empty = slotWrapsDefaultContent(Component, { ...contentProps, children });\n if (empty && Object.keys(buttonProps).length === 0 && Object.keys(contentProps).length === 0) {\n return DEFAULT_DISMISS;\n }\n // A button object without content (`{ onClick }`, `{ type: 'button' }`) or a content object\n // without children (`{ className }`) keeps the default icon inside the object's own element (its\n // className/style/attributes still apply). Markup of its own takes no children at all.\n const contentChildren = empty ? <DismissIcon /> : hasChildren ? children : undefined;\n // The element the slot renders carries the dismissIcon part class, before the slot's own.\n const iconProps = {\n 'aria-hidden': true,\n ...contentProps,\n className: cn(searchBoxClassNames.dismissIcon, contentProps.className as string | undefined),\n };\n const content =\n contentChildren === undefined\n ? React.createElement(Component, iconProps)\n : React.createElement(Component, iconProps, contentChildren);\n return {\n kind: hasButtonProps ? 'button-object' : 'content',\n buttonProps,\n content,\n contentMayName: false,\n literalTextLabel: false,\n disabledFocusable: false,\n };\n}\n\n/**\n * A search input with a leading search icon and a clear button that appears while there is text\n * (not while `readOnly`).\n *\n * - **Layout**: the root `<div>` draws the field (its outline, focus and invalid look). The icon\n * (or `contentBefore`), the text, `contentAfter` and the clear button sit side by side in it, so\n * no slot covers the text. Pressing the field outside a control of its own focuses the input.\n * - **Clearing**: the clear button clears the text and moves focus back to the input. Escape\n * clears the text too while there is any, and is then consumed, so an enclosing Dialog, Drawer\n * or Popover stays open; in an empty field Escape reaches them. Both call `onClear`.\n * - **Routing**: `id`, ARIA and native input attributes and the focus/keyboard handlers go to the\n * `<input type=\"search\">` (role `searchbox`); `className`, `style`, `data-*`, other handlers and\n * `ref` stay on the root `<div>` (`controlRef` reaches the input). Inside a `Field` it picks up\n * the label, hint, error and required state automatically.\n * - **Forms**: with `name` the text is submitted with the form; a form reset restores\n * `defaultValue`.\n *\n * @example\n * <SearchBox aria-label=\"Search files\" value={query} onValueChange={setQuery} />\n */\nexport const SearchBox = ({\n value: controlledValue,\n defaultValue = '',\n onValueChange,\n onChange,\n onClear,\n placeholder = 'Search',\n disabled,\n contentBefore,\n contentAfter,\n dismiss,\n className,\n ref,\n controlRef,\n // Routed to the input (C-ROUTING)\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n required,\n name,\n form,\n readOnly,\n autoComplete,\n autoFocus,\n autoCapitalize,\n autoCorrect,\n inputMode,\n enterKeyHint,\n spellCheck,\n maxLength,\n minLength,\n pattern,\n tabIndex,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n onMouseDown,\n hidden,\n ...rest\n}: SearchBoxProps) => {\n if (onChange !== undefined) warnDeprecated('SearchBox', 'onChange', 'onValueChange');\n\n const [value, setValue] = useControllable(controlledValue, defaultValue, (next: string) => {\n onValueChange?.(next);\n onChange?.(next);\n });\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedInputRef = useMergedRefs(inputRef, controlRef);\n // The input is always React-controlled, so the browser's own reset would put the current text\n // back: restore the default here instead (C-FORMS).\n useFormReset(inputRef, () => setValue(defaultValue), form);\n\n const fieldProps = useFieldControl(\n {\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n required,\n },\n { nativeRequired: true },\n );\n const invalidLook = isInvalidLook(false, fieldProps['aria-invalid']);\n\n const dismissParts = resolveDismiss(dismiss);\n const dismissKind = dismissParts.kind;\n React.useEffect(() => {\n if (dismissKind === 'element') {\n warnOnce(\n 'SearchBox:dismiss-button-element',\n 'SearchBox: `dismiss` received a button element; its props were merged into the built-in clear button (buttons cannot be nested). Pass icon content instead, e.g. `dismiss={<MyIcon />}`.',\n );\n } else if (dismissKind === 'button-object') {\n warnOnce(\n 'SearchBox:dismiss-button-object',\n 'SearchBox: `dismiss` with button props (`as: \"button\"`, `onClick`, `type`, …) is deprecated and will be removed in 1.0; the props were merged into the built-in clear button. Pass icon content instead, e.g. `dismiss={<MyIcon />}`.',\n );\n }\n }, [dismissKind]);\n\n const handleClear = () => {\n setValue('');\n onClear?.();\n inputRef.current?.focus();\n };\n\n // Escape clears the text first, as native search fields do, and is consumed so an enclosing\n // Dialog, Drawer or Popover stays open; with an empty field it reaches them (C-POPUPS).\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== 'Escape' || event.nativeEvent.isComposing) return;\n if (!value || readOnly || disabled) return;\n event.preventDefault();\n setValue('');\n onClear?.();\n };\n\n // The whole box is the field: pressing the icon, a slot or the padding around the text focuses\n // the input, as it does in a native search field. A control inside a slot keeps its press.\n const handleRootMouseDown = (event: React.MouseEvent<HTMLDivElement>) => {\n const input = inputRef.current;\n const root = event.currentTarget;\n const target = event.target;\n if (!input || disabled || event.button !== 0 || target === input) return;\n // Events that bubble through React portals from outside this box are not ours (C-COMPOSE).\n if (!(target instanceof Element) || !root.contains(target)) return;\n const control = target.closest(INTERACTIVE_CONTENT);\n if (control && root.contains(control)) return;\n event.preventDefault(); // keeps the press from moving focus to the page\n input.focus();\n };\n\n // The slot's onClick is composed at click time (it runs first; preventDefault() cancels the\n // clear), so handleClear, which reads the input ref, is never passed to a render-time helper.\n // The slot's ref joins ours through a stable merged ref (never a new callback per render).\n const {\n onClick: slotOnClick,\n ref: slotRef,\n ...slotButtonProps\n } = dismissParts.buttonProps as UnknownProps & {\n onClick?: React.MouseEventHandler<HTMLButtonElement>;\n ref?: React.Ref<HTMLButtonElement>;\n };\n\n // C-SLOTS naming (WCAG 2.5.3 Label in Name): a consumer naming attribute names the clear button;\n // otherwise content rendered as is names it when it has a text label, and the default\n // `aria-label` would hide that label. The literal children decide on the server and on the first\n // render; after mount, the rendered button's text does (text from components, later changes).\n const hasOwnName = Object.keys(slotButtonProps).some(\n (key) => NAMING_KEYS.has(key) && slotButtonProps[key] != null,\n );\n const checksContent = dismissParts.contentMayName && !hasOwnName;\n const literalTextLabel = dismissParts.literalTextLabel;\n const [labelTarget, setLabelTarget] = React.useState<HTMLButtonElement | null>(null);\n const subscribeToContent = React.useCallback(\n (onChange: () => void) => (labelTarget ? observeTextLabel(labelTarget, onChange) : noop),\n [labelTarget],\n );\n const contentHasTextLabel = React.useSyncExternalStore(\n subscribeToContent,\n () => (labelTarget ? hasRenderedTextLabel(labelTarget) : literalTextLabel),\n () => literalTextLabel,\n );\n const namedByContent = checksContent && contentHasTextLabel;\n const clearRef = useMergedRefs<HTMLButtonElement>(\n slotRef,\n checksContent ? setLabelTarget : undefined,\n );\n\n const clearButtonProps = mergeProps(\n {\n type: 'button',\n disabled,\n 'aria-label': hasOwnName || namedByContent ? undefined : DEFAULT_CLEAR_LABEL,\n className: cn(\n searchBoxClassNames.dismissButton,\n // Padding and background set here (C-NATIVE): an app-wide `button` rule cannot fill it.\n 'me-1 flex h-6 w-6 shrink-0 items-center justify-center rounded bg-transparent p-0 text-muted-foreground',\n 'not-disabled:not-aria-disabled:hover:text-foreground',\n focusRing,\n 'disabled:cursor-not-allowed',\n mergedAriaDisabledClasses,\n ),\n },\n slotButtonProps,\n ) as React.ComponentPropsWithoutRef<'button'>;\n\n // A merged button with markup of its own (`dangerouslySetInnerHTML`) takes no children.\n const clearContent =\n clearButtonProps.dangerouslySetInnerHTML != null\n ? undefined\n : dismissKind === 'content'\n ? dismissParts.content\n : (dismissParts.content ?? <DismissIcon className={searchBoxClassNames.dismissIcon} />);\n // A slot value that renders nothing is no slot (the default icon before the text, no box after).\n const hasBefore = slotRendersContent(contentBefore);\n const hasAfter = slotRendersContent(contentAfter);\n\n return (\n <div\n ref={ref}\n className={cn(\n searchBoxClassNames.root,\n // The root draws the field; the slots, the text and the clear button are laid out side by\n // side inside it, so a slot never covers the text.\n 'relative 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 root (a clear button kept\n // focusable by a merged `disabledFocusable` Button, focusable slot content; the disabled\n // input never takes focus): opacity would dim the ring below 3:1.\n disabled && 'cursor-not-allowed opacity-50 has-focus-visible:opacity-100',\n className,\n )}\n hidden={hidden}\n {...rest}\n // Composed at press time, like the clear button's click: the handler reads the input ref.\n onMouseDown={(event) => composeEventHandlers(onMouseDown, handleRootMouseDown)(event)}\n >\n <span className={cn(searchBoxClassNames.contentBefore, 'flex shrink-0 items-center ps-2')}>\n {hasBefore ? (\n renderSlot(contentBefore, 'span', 'shrink-0')\n ) : (\n <SearchIcon className=\"text-muted-foreground\" />\n )}\n </span>\n\n <input\n ref={mergedInputRef}\n type=\"search\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n placeholder={placeholder}\n disabled={disabled}\n className={cn(\n searchBoxClassNames.input,\n 'h-full min-w-0 flex-1 appearance-none border-none bg-transparent px-2 text-body-1 text-foreground',\n 'placeholder:text-muted-foreground',\n 'focus:outline-hidden',\n 'disabled:cursor-not-allowed',\n '[&::-webkit-search-cancel-button]:hidden',\n )}\n aria-errormessage={ariaErrorMessage}\n aria-details={ariaDetails}\n name={name}\n form={form}\n readOnly={readOnly}\n autoComplete={autoComplete}\n autoFocus={autoFocus}\n autoCapitalize={autoCapitalize}\n autoCorrect={autoCorrect}\n inputMode={inputMode}\n enterKeyHint={enterKeyHint}\n spellCheck={spellCheck}\n maxLength={maxLength}\n minLength={minLength}\n pattern={pattern}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onKeyUp={onKeyUp}\n {...fieldProps}\n />\n\n {hasAfter && (\n <span className={cn(searchBoxClassNames.contentAfter, 'flex shrink-0 items-center pe-2')}>\n {renderSlot(contentAfter, 'span', 'shrink-0')}\n </span>\n )}\n\n {/* No clear button while read-only: clearing would change a value the user cannot edit. */}\n {value && !readOnly ? (\n <button\n {...clearButtonProps}\n ref={clearRef}\n // mergeProps keeps a slot's `type: null`, which would drop the attribute and make the\n // button submit its form; only nullish falls back (an explicit type is kept).\n type={clearButtonProps.type ?? 'button'}\n disabled={disabled || clearButtonProps.disabled}\n onClick={(event) => composeEventHandlers(slotOnClick, handleClear)(event)}\n // A merged `disabledFocusable` Button makes the clear button unavailable but focusable\n // (spread last: it wins over `disabled` and the clear handler).\n {...(dismissParts.disabledFocusable ? MERGED_DISABLED_FOCUSABLE_PROPS : undefined)}\n >\n {clearContent}\n </button>\n ) : null}\n </div>\n );\n};\n\nSearchBox.displayName = 'SearchBox';\n"],"mappings":"ywBAmJA,IAAMgD,EAAwC,IAAI,IAAI,CACpD,OACA,WACA,OACA,aACA,cACA,aACA,iBACA,aACA,OACA,QACA,gBACA,qBACF,CAAC,EACKC,EAAc,WAOdC,EAAmC,IAAI,IAAI,CAAC,aAAc,kBAAmB,OAAO,CAAC,EAGrFC,EAAsB,eA8BtBC,MAAa,CAAC,EAMdC,EACJ,yGAEIC,EAAgC,CACpC,KAAM,UACN,YAAa,CAAC,EACd,QAAS,KACT,eAAgB,GAChB,iBAAkB,GAClB,kBAAmB,EACrB,EAEA,SAASC,EAAa,EAAwB,CAC5C,OAAOC,IAAS,UAAYA,IAASxD,EAAAA,MACvC,CAOA,SAASyD,EAAgB,EAAe,EAAqB,EAA2B,CACtF,IAAMC,EAAczD,EAAAA,mBAAmB0D,CAAQ,EACzCC,EAAU1D,EAAAA,uBAAuByD,CAAQ,EACzCE,EAAmB1D,EAAAA,aAAayD,CAAO,EAC7C,GAAIJ,IAASxD,EAAAA,OAAQ,CAGnB,IAAM8D,EAA4B,CAAC,EACnC,IAAK,GAAM,CAACC,EAAKC,KAAU,OAAO,QAAQC,CAAK,EACzCF,IAAQ,YAAc,CAAC3D,EAAAA,qBAAqB,IAAI2D,CAAG,IAAG,EAAYA,GAAOC,GAE/E,IAAME,EAAW7D,EAAAA,WACf4D,EAAM,KACN,OACA3D,EAAAA,GAAGC,EAAAA,oBAAoB,YAAa,aAAa,EACjD,CAAE,cAAe,EAAK,CACxB,EAGA,MAAO,CACL,cACA,QAHA2D,GAAYR,EAAclD,EAAAA,gBAAgB0D,EAAUN,EAASK,EAAM,YAAY,EAAI,KAInF,eAAgB,GAChB,mBACA,kBAAmB,EAAQA,EAAM,iBACnC,CACF,CACA,GAAM,CAAE,KAAI,SAAUE,EAAW,GAAGL,GAAgBG,EAEpD,MAAO,CACL,cACA,QAASP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,YACG,eACF,aACD,YACA,aACF,WACC,YACD,WACD,UACR,UAAW7D,EAAAA,qBAAqB0G,GAAW5B,EAAa,EAC/C,WACT,GAAIN,CACL,CAAA,EAEA8B,KACC,EAAAhF,EAAA,IAAA,CAAC,OAAD,CAAM,UAAWzC,EAAAA,GAAGC,EAAAA,oBAAoB,aAAc,iCAAiC,EACpF,SAAAF,EAAAA,WAAW2H,EAAc,OAAQ,UAAU,CACxC,CAAA,EAIPhE,GAAS,CAACyC,GACT,EAAA1D,EAAA,IAAA,CAAC,SAAD,CACE,GAAI4E,EACJ,IAAKD,GAGL,KAAMC,EAAiB,MAAQ,SAC/B,SAAUjB,GAAYiB,EAAiB,SACvC,QAAU,GAAUlG,EAAAA,qBAAqBuF,GAAaX,EAAW,CAAC,CAACG,CAAK,EAGxE,GAAKL,EAAa,kBAAoBxE,EAAAA,gCAAkC,IAAA,GAEvE,SAAAiG,EACK,CAAA,EACN,IACD,GAET,EAEA,EAAU,YAAc"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { getElementType as t, isElementOfType as n } from "../../lib/children.mjs";
|
|
4
|
+
import { warnDeprecated as r, warnOnce as i } from "../../lib/dev.mjs";
|
|
5
|
+
import { materialiseSlotContent as a, renderSlot as o, resolveSlot as s, slotRendersContent as c, slotWrapsDefaultContent as l } from "../../lib/slot.mjs";
|
|
6
|
+
import { composeEventHandlers as u } from "../../lib/composeEventHandlers.mjs";
|
|
7
|
+
import { searchBoxClassNames as d } from "../../lib/classNames.mjs";
|
|
8
|
+
import { useControllable as f } from "../../hooks/useControllable.mjs";
|
|
9
|
+
import { useMergedRefs as p } from "../../hooks/useMergedRefs.mjs";
|
|
10
|
+
import { useFieldControl as m } from "../../hooks/useFieldControl.mjs";
|
|
11
|
+
import { focusRing as h, inputFocusWithin as g } from "../../lib/styles.mjs";
|
|
12
|
+
import { Button as _ } from "../button/Button.mjs";
|
|
13
|
+
import { BUTTON_OWN_PROP_KEYS as v, MERGED_DISABLED_FOCUSABLE_PROPS as y, mergedAriaDisabledClasses as b, placeButtonIcon as x } from "../button/Button.slots.mjs";
|
|
14
|
+
import { DismissIcon as S, SearchIcon as ee } from "../../lib/icons.mjs";
|
|
15
|
+
import { mergeProps as te } from "../../lib/mergeProps.mjs";
|
|
16
|
+
import { isInvalidLook as ne } from "./Input.mjs";
|
|
17
|
+
import { useFormReset as C } from "../../hooks/useFormReset.mjs";
|
|
18
|
+
import { hasRenderedTextLabel as w, hasTextLabel as T, observeTextLabel as re } from "../../lib/labelInName.mjs";
|
|
19
|
+
import * as E from "react";
|
|
20
|
+
import { jsx as D, jsxs as ie } from "react/jsx-runtime";
|
|
21
|
+
//#region src/components/input/SearchBox.tsx
|
|
22
|
+
var O = /* @__PURE__ */ new Set([
|
|
23
|
+
"type",
|
|
24
|
+
"disabled",
|
|
25
|
+
"form",
|
|
26
|
+
"formAction",
|
|
27
|
+
"formEncType",
|
|
28
|
+
"formMethod",
|
|
29
|
+
"formNoValidate",
|
|
30
|
+
"formTarget",
|
|
31
|
+
"name",
|
|
32
|
+
"value",
|
|
33
|
+
"popoverTarget",
|
|
34
|
+
"popoverTargetAction"
|
|
35
|
+
]), k = /^on[A-Z]/, A = /* @__PURE__ */ new Set([
|
|
36
|
+
"aria-label",
|
|
37
|
+
"aria-labelledby",
|
|
38
|
+
"title"
|
|
39
|
+
]), ae = "Clear search", oe = () => {}, se = "a[href], button, input, select, textarea, [tabindex], [contenteditable]:not([contenteditable=\"false\"])", j = {
|
|
40
|
+
kind: "default",
|
|
41
|
+
buttonProps: {},
|
|
42
|
+
content: null,
|
|
43
|
+
contentMayName: !1,
|
|
44
|
+
literalTextLabel: !1,
|
|
45
|
+
disabledFocusable: !1
|
|
46
|
+
};
|
|
47
|
+
function M(e) {
|
|
48
|
+
return e === "button" || e === _;
|
|
49
|
+
}
|
|
50
|
+
function N(t, n, r) {
|
|
51
|
+
let i = c(r), s = a(r), l = T(s);
|
|
52
|
+
if (t === _) {
|
|
53
|
+
let t = {};
|
|
54
|
+
for (let [e, r] of Object.entries(n)) e !== "children" && !v.has(e) && (t[e] = r);
|
|
55
|
+
let r = o(n.icon, "span", e(d.dismissIcon, "inline-flex"), { "aria-hidden": !0 });
|
|
56
|
+
return {
|
|
57
|
+
buttonProps: t,
|
|
58
|
+
content: r || i ? x(r, s, n.iconPosition) : null,
|
|
59
|
+
contentMayName: !0,
|
|
60
|
+
literalTextLabel: l,
|
|
61
|
+
disabledFocusable: !!n.disabledFocusable
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
let { as: u, children: f, ...p } = n;
|
|
65
|
+
return {
|
|
66
|
+
buttonProps: p,
|
|
67
|
+
content: i ? s : null,
|
|
68
|
+
contentMayName: !0,
|
|
69
|
+
literalTextLabel: l,
|
|
70
|
+
disabledFocusable: !1
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function ce(r) {
|
|
74
|
+
let i = r;
|
|
75
|
+
if (n(i, "button", _)) {
|
|
76
|
+
let e = i.props.children;
|
|
77
|
+
return {
|
|
78
|
+
kind: "element",
|
|
79
|
+
...N(t(i), i.props, e)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
let a = s(r, "span");
|
|
83
|
+
if (!a) return j;
|
|
84
|
+
let { Component: o, props: u, children: f } = a;
|
|
85
|
+
if (M(o)) return {
|
|
86
|
+
kind: "button-object",
|
|
87
|
+
...N(o, u, f)
|
|
88
|
+
};
|
|
89
|
+
let p = {}, m = {}, h = !1;
|
|
90
|
+
for (let [e, t] of Object.entries(u)) t !== void 0 && (O.has(e) || k.test(e) ? (p[e] = t, h = !0) : A.has(e) ? p[e] = t : m[e] = t);
|
|
91
|
+
let g = c(f), v = l(o, {
|
|
92
|
+
...m,
|
|
93
|
+
children: f
|
|
94
|
+
});
|
|
95
|
+
if (v && Object.keys(p).length === 0 && Object.keys(m).length === 0) return j;
|
|
96
|
+
let y = v ? /* @__PURE__ */ D(S, {}) : g ? f : void 0, b = {
|
|
97
|
+
"aria-hidden": !0,
|
|
98
|
+
...m,
|
|
99
|
+
className: e(d.dismissIcon, m.className)
|
|
100
|
+
}, x = y === void 0 ? E.createElement(o, b) : E.createElement(o, b, y);
|
|
101
|
+
return {
|
|
102
|
+
kind: h ? "button-object" : "content",
|
|
103
|
+
buttonProps: p,
|
|
104
|
+
content: x,
|
|
105
|
+
contentMayName: !1,
|
|
106
|
+
literalTextLabel: !1,
|
|
107
|
+
disabledFocusable: !1
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
var P = ({ value: t, defaultValue: n = "", onValueChange: a, onChange: s, onClear: l, placeholder: _ = "Search", disabled: v, contentBefore: x, contentAfter: T, dismiss: O, className: k, ref: j, controlRef: M, id: N, "aria-label": P, "aria-labelledby": le, "aria-describedby": ue, "aria-invalid": de, "aria-required": fe, "aria-errormessage": pe, "aria-details": F, required: I, name: L, form: R, readOnly: z, autoComplete: B, autoFocus: me, autoCapitalize: he, autoCorrect: ge, inputMode: _e, enterKeyHint: ve, spellCheck: ye, maxLength: be, minLength: xe, pattern: Se, tabIndex: Ce, onFocus: we, onBlur: Te, onKeyDown: Ee, onKeyUp: De, onMouseDown: Oe, hidden: ke, ...Ae }) => {
|
|
111
|
+
s !== void 0 && r("SearchBox", "onChange", "onValueChange");
|
|
112
|
+
let [V, H] = f(t, n, (e) => {
|
|
113
|
+
a?.(e), s?.(e);
|
|
114
|
+
}), U = E.useRef(null), je = p(U, M);
|
|
115
|
+
C(U, () => H(n), R);
|
|
116
|
+
let W = m({
|
|
117
|
+
id: N,
|
|
118
|
+
"aria-label": P,
|
|
119
|
+
"aria-labelledby": le,
|
|
120
|
+
"aria-describedby": ue,
|
|
121
|
+
"aria-invalid": de,
|
|
122
|
+
"aria-required": fe,
|
|
123
|
+
required: I
|
|
124
|
+
}, { nativeRequired: !0 }), Me = ne(!1, W["aria-invalid"]), G = ce(O), K = G.kind;
|
|
125
|
+
E.useEffect(() => {
|
|
126
|
+
K === "element" ? i("SearchBox:dismiss-button-element", "SearchBox: `dismiss` received a button element; its props were merged into the built-in clear button (buttons cannot be nested). Pass icon content instead, e.g. `dismiss={<MyIcon />}`.") : K === "button-object" && i("SearchBox:dismiss-button-object", "SearchBox: `dismiss` with button props (`as: \"button\"`, `onClick`, `type`, …) is deprecated and will be removed in 1.0; the props were merged into the built-in clear button. Pass icon content instead, e.g. `dismiss={<MyIcon />}`.");
|
|
127
|
+
}, [K]);
|
|
128
|
+
let Ne = () => {
|
|
129
|
+
H(""), l?.(), U.current?.focus();
|
|
130
|
+
}, Pe = (e) => {
|
|
131
|
+
e.key !== "Escape" || e.nativeEvent.isComposing || !V || z || v || (e.preventDefault(), H(""), l?.());
|
|
132
|
+
}, Fe = (e) => {
|
|
133
|
+
let t = U.current, n = e.currentTarget, r = e.target;
|
|
134
|
+
if (!t || v || e.button !== 0 || r === t || !(r instanceof Element) || !n.contains(r)) return;
|
|
135
|
+
let i = r.closest(se);
|
|
136
|
+
i && n.contains(i) || (e.preventDefault(), t.focus());
|
|
137
|
+
}, { onClick: Ie, ref: Le, ...q } = G.buttonProps, J = Object.keys(q).some((e) => A.has(e) && q[e] != null), Y = G.contentMayName && !J, X = G.literalTextLabel, [Z, Re] = E.useState(null), Q = E.useCallback((e) => Z ? re(Z, e) : oe, [Z]), ze = E.useSyncExternalStore(Q, () => Z ? w(Z) : X, () => X), Be = Y && ze, Ve = p(Le, Y ? Re : void 0), $ = te({
|
|
138
|
+
type: "button",
|
|
139
|
+
disabled: v,
|
|
140
|
+
"aria-label": J || Be ? void 0 : ae,
|
|
141
|
+
className: e(d.dismissButton, "me-1 flex h-6 w-6 shrink-0 items-center justify-center rounded bg-transparent p-0 text-muted-foreground", "not-disabled:not-aria-disabled:hover:text-foreground", h, "disabled:cursor-not-allowed", b)
|
|
142
|
+
}, q), He = $.dangerouslySetInnerHTML == null ? K === "content" ? G.content : G.content ?? /* @__PURE__ */ D(S, { className: d.dismissIcon }) : void 0, Ue = c(x), We = c(T);
|
|
143
|
+
return /* @__PURE__ */ ie("div", {
|
|
144
|
+
ref: j,
|
|
145
|
+
className: e(d.root, "relative inline-flex h-8 w-full items-center rounded border border-input border-b-stroke-accessible bg-background text-body-1 text-foreground", g, Me && "border-destructive focus-within:border-b-destructive", v && "cursor-not-allowed opacity-50 has-focus-visible:opacity-100", k),
|
|
146
|
+
hidden: ke,
|
|
147
|
+
...Ae,
|
|
148
|
+
onMouseDown: (e) => u(Oe, Fe)(e),
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ D("span", {
|
|
151
|
+
className: e(d.contentBefore, "flex shrink-0 items-center ps-2"),
|
|
152
|
+
children: Ue ? o(x, "span", "shrink-0") : /* @__PURE__ */ D(ee, { className: "text-muted-foreground" })
|
|
153
|
+
}),
|
|
154
|
+
/* @__PURE__ */ D("input", {
|
|
155
|
+
ref: je,
|
|
156
|
+
type: "search",
|
|
157
|
+
value: V,
|
|
158
|
+
onChange: (e) => H(e.target.value),
|
|
159
|
+
placeholder: _,
|
|
160
|
+
disabled: v,
|
|
161
|
+
className: e(d.input, "h-full min-w-0 flex-1 appearance-none border-none bg-transparent px-2 text-body-1 text-foreground", "placeholder:text-muted-foreground", "focus:outline-hidden", "disabled:cursor-not-allowed", "[&::-webkit-search-cancel-button]:hidden"),
|
|
162
|
+
"aria-errormessage": pe,
|
|
163
|
+
"aria-details": F,
|
|
164
|
+
name: L,
|
|
165
|
+
form: R,
|
|
166
|
+
readOnly: z,
|
|
167
|
+
autoComplete: B,
|
|
168
|
+
autoFocus: me,
|
|
169
|
+
autoCapitalize: he,
|
|
170
|
+
autoCorrect: ge,
|
|
171
|
+
inputMode: _e,
|
|
172
|
+
enterKeyHint: ve,
|
|
173
|
+
spellCheck: ye,
|
|
174
|
+
maxLength: be,
|
|
175
|
+
minLength: xe,
|
|
176
|
+
pattern: Se,
|
|
177
|
+
tabIndex: Ce,
|
|
178
|
+
onFocus: we,
|
|
179
|
+
onBlur: Te,
|
|
180
|
+
onKeyDown: u(Ee, Pe),
|
|
181
|
+
onKeyUp: De,
|
|
182
|
+
...W
|
|
183
|
+
}),
|
|
184
|
+
We && /* @__PURE__ */ D("span", {
|
|
185
|
+
className: e(d.contentAfter, "flex shrink-0 items-center pe-2"),
|
|
186
|
+
children: o(T, "span", "shrink-0")
|
|
187
|
+
}),
|
|
188
|
+
V && !z ? /* @__PURE__ */ D("button", {
|
|
189
|
+
...$,
|
|
190
|
+
ref: Ve,
|
|
191
|
+
type: $.type ?? "button",
|
|
192
|
+
disabled: v || $.disabled,
|
|
193
|
+
onClick: (e) => u(Ie, Ne)(e),
|
|
194
|
+
...G.disabledFocusable ? y : void 0,
|
|
195
|
+
children: He
|
|
196
|
+
}) : null
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
P.displayName = "SearchBox";
|
|
201
|
+
//#endregion
|
|
202
|
+
export { P as SearchBox };
|
|
203
|
+
|
|
204
|
+
//# sourceMappingURL=SearchBox.mjs.map
|