@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,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as e from "react";
|
|
3
|
+
//#region src/components/feedback/MessageBar.reflow.ts
|
|
4
|
+
var t = class {
|
|
5
|
+
reflowing = !1;
|
|
6
|
+
neededWidth = 0;
|
|
7
|
+
listeners = /* @__PURE__ */ new Set();
|
|
8
|
+
subscribe = (e) => (this.listeners.add(e), () => {
|
|
9
|
+
this.listeners.delete(e);
|
|
10
|
+
});
|
|
11
|
+
getSnapshot = () => this.reflowing ? "multiline" : "singleline";
|
|
12
|
+
getServerSnapshot = () => "singleline";
|
|
13
|
+
measure(e, t) {
|
|
14
|
+
if (this.reflowing) {
|
|
15
|
+
if (e.clientWidth < this.neededWidth) return;
|
|
16
|
+
this.reflowing = !1, this.neededWidth = 0;
|
|
17
|
+
} else {
|
|
18
|
+
let n = t.scrollWidth - t.clientWidth;
|
|
19
|
+
if (n <= 0) return;
|
|
20
|
+
this.reflowing = !0, this.neededWidth = e.clientWidth + n;
|
|
21
|
+
}
|
|
22
|
+
this.emit();
|
|
23
|
+
}
|
|
24
|
+
reset(e = !0) {
|
|
25
|
+
this.reflowing && (this.reflowing = !1, this.neededWidth = 0, e && this.emit());
|
|
26
|
+
}
|
|
27
|
+
connect(e, t) {
|
|
28
|
+
let n = [], r = () => this.measure(e, t);
|
|
29
|
+
if (typeof ResizeObserver < "u") {
|
|
30
|
+
let t = 0, i = new ResizeObserver(() => {
|
|
31
|
+
cancelAnimationFrame(t), t = requestAnimationFrame(r);
|
|
32
|
+
});
|
|
33
|
+
i.observe(e, { box: "border-box" }), n.push(() => {
|
|
34
|
+
i.disconnect(), cancelAnimationFrame(t);
|
|
35
|
+
});
|
|
36
|
+
} else typeof window < "u" && (window.addEventListener("resize", r), n.push(() => window.removeEventListener("resize", r)));
|
|
37
|
+
if (typeof MutationObserver < "u") {
|
|
38
|
+
let e = new MutationObserver(() => {
|
|
39
|
+
this.reflowing ? this.reset() : r();
|
|
40
|
+
});
|
|
41
|
+
e.observe(t, {
|
|
42
|
+
childList: !0,
|
|
43
|
+
subtree: !0,
|
|
44
|
+
characterData: !0
|
|
45
|
+
}), n.push(() => e.disconnect());
|
|
46
|
+
}
|
|
47
|
+
return () => {
|
|
48
|
+
for (let e of n) e();
|
|
49
|
+
this.reset(!1);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
emit() {
|
|
53
|
+
for (let e of Array.from(this.listeners)) e();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
function n(n, r, i) {
|
|
57
|
+
let [a] = e.useState(() => new t()), o = e.useSyncExternalStore(a.subscribe, a.getSnapshot, a.getServerSnapshot), [, s] = e.useReducer((e) => e + 1, 0);
|
|
58
|
+
return e.useLayoutEffect(() => {
|
|
59
|
+
if (i && n && r) return a.connect(n, r);
|
|
60
|
+
}, [
|
|
61
|
+
a,
|
|
62
|
+
i,
|
|
63
|
+
n,
|
|
64
|
+
r
|
|
65
|
+
]), e.useLayoutEffect(() => {
|
|
66
|
+
if (!i || !n || !r || a.getSnapshot() !== "singleline") return;
|
|
67
|
+
let e = a.subscribe(s);
|
|
68
|
+
a.measure(n, r), e();
|
|
69
|
+
}), i ? o : "singleline";
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { n as useMessageBarReflow };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=MessageBar.reflow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBar.reflow.mjs","names":["React","MessageBarReflowStore","listener","root","overflow","text","notify","cleanups","measure","frame","observer","mutations","cleanup","useMessageBarReflow","store","layout","forceRender","count","enabled","unsubscribe"],"sources":["../../../src/components/feedback/MessageBar.reflow.ts"],"sourcesContent":["import * as React from 'react';\n\n/** The layout an `'auto'` MessageBar with actions renders. */\nexport type MessageBarReflowLayout = 'singleline' | 'multiline';\n\n/**\n * One bar's measurement (spec D17): whether its text needs the multiline layout, and the bar width\n * at which the text fits on one line again. Read through `useSyncExternalStore`.\n */\nclass MessageBarReflowStore {\n private reflowing = false;\n /** The bar's client width at which its text fits on one line. */\n private neededWidth = 0;\n private readonly listeners = new Set<() => void>();\n\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n getSnapshot = (): MessageBarReflowLayout => (this.reflowing ? 'multiline' : 'singleline');\n\n /** The server HTML and hydration use the one-row layout. */\n getServerSnapshot = (): MessageBarReflowLayout => 'singleline';\n\n /**\n * The two-way rule. One row: text wider than its column (`scrollWidth > clientWidth`; the column\n * does not wrap while measured) switches to multiline and remembers the bar width it needed,\n * `root.clientWidth + text.scrollWidth - text.clientWidth`. Multiline: a bar at least that wide\n * switches back.\n */\n measure(root: HTMLElement, text: HTMLElement): void {\n if (this.reflowing) {\n if (root.clientWidth < this.neededWidth) return;\n this.reflowing = false;\n this.neededWidth = 0;\n } else {\n const overflow = text.scrollWidth - text.clientWidth;\n if (overflow <= 0) return;\n this.reflowing = true;\n this.neededWidth = root.clientWidth + overflow;\n }\n this.emit();\n }\n\n /** Forgets the measurement: the next render uses the one-row layout and measures again. */\n reset(notify = true): void {\n if (!this.reflowing) return;\n this.reflowing = false;\n this.neededWidth = 0;\n if (notify) this.emit();\n }\n\n /**\n * Observes `root` and `text` until the returned teardown runs, which also forgets the\n * measurement.\n * - The root's size (a ResizeObserver): measured in the next animation frame, so the layout\n * change never resizes the observed root while the observer is still delivering (browsers\n * report that as a loop error). Without ResizeObserver: window size changes.\n * - Text changed inside the column without a render of the bar (a MutationObserver): measured at\n * once in the one-row layout; in the multiline layout the measurement starts over from the\n * one-row layout (the render that follows measures before paint).\n */\n connect(root: HTMLElement, text: HTMLElement): () => void {\n const cleanups: Array<() => void> = [];\n const measure = () => this.measure(root, text);\n if (typeof ResizeObserver !== 'undefined') {\n let frame = 0;\n const observer = new ResizeObserver(() => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(measure);\n });\n observer.observe(root, { box: 'border-box' });\n cleanups.push(() => {\n observer.disconnect();\n cancelAnimationFrame(frame);\n });\n } else if (typeof window !== 'undefined') {\n window.addEventListener('resize', measure);\n cleanups.push(() => window.removeEventListener('resize', measure));\n }\n if (typeof MutationObserver !== 'undefined') {\n const mutations = new MutationObserver(() => {\n if (this.reflowing) this.reset();\n else measure();\n });\n mutations.observe(text, { childList: true, subtree: true, characterData: true });\n cleanups.push(() => mutations.disconnect());\n }\n return () => {\n for (const cleanup of cleanups) cleanup();\n // Silent: on unmount the layout cleanups run before useSyncExternalStore unsubscribes, and a\n // notification would schedule an update on a deleted fiber. A bar that stays mounted reads\n // the reset snapshot on its next render (useSyncExternalStore re-checks it after each commit).\n this.reset(false);\n };\n }\n\n private emit(): void {\n for (const listener of Array.from(this.listeners)) listener();\n }\n}\n\n/**\n * The layout of a MessageBar with `layout=\"auto\"` and actions: `'singleline'` on the server, on the\n * first client render and while the text fits on one line; `'multiline'` otherwise. `root` is the\n * bar's root element and `text` its text column, both held in state through callback refs\n * (C-POPUPS). With `enabled` false (every other bar) nothing is observed or measured and the result\n * is `'singleline'`.\n */\nexport function useMessageBarReflow(\n root: HTMLElement | null,\n text: HTMLElement | null,\n enabled: boolean,\n): MessageBarReflowLayout {\n const [store] = React.useState(() => new MessageBarReflowStore());\n const layout = React.useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getServerSnapshot,\n );\n const [, forceRender] = React.useReducer((count: number) => count + 1, 0);\n\n // The observers follow the elements. Their teardown forgets the measurement, so a bar that\n // measures again (its actions back, or `layout` back to 'auto') starts from one row.\n React.useLayoutEffect(() => {\n if (!enabled || !root || !text) return undefined;\n return store.connect(root, text);\n }, [store, enabled, root, text]);\n\n // After every commit in the one-row layout, before paint: useSyncExternalStore subscribes only in\n // a passive effect, which can run after the browser painted, so a change found here re-renders\n // through `forceRender` (the pattern of Overflow's `useIsOverflowing`).\n React.useLayoutEffect(() => {\n if (!enabled || !root || !text || store.getSnapshot() !== 'singleline') return;\n const unsubscribe = store.subscribe(forceRender);\n store.measure(root, text);\n unsubscribe();\n });\n\n return enabled ? layout : 'singleline';\n}\n"],"mappings":";;;AASA,IAAMC,IAAN,MAA4B;CAC1B,YAAoB;CAEpB,cAAsB;CACtB,4BAA6B,IAAI,IAAgB;CAEjD,aAAa,OACX,KAAK,UAAU,IAAIC,CAAQ,SACd;EACX,KAAK,UAAU,OAAOA,CAAQ;CAChC;CAGF,oBAA6C,KAAK,YAAY,cAAc;CAG5E,0BAAkD;CAQlD,QAAQ,GAAmB,GAAyB;EAClD,IAAI,KAAK,WAAW;GAClB,IAAIC,EAAK,cAAc,KAAK,aAAa;GAEzC,AADA,KAAK,YAAY,IACjB,KAAK,cAAc;EACrB,OAAO;GACL,IAAMC,IAAWC,EAAK,cAAcA,EAAK;GACzC,IAAID,KAAY,GAAG;GAEnB,AADA,KAAK,YAAY,IACjB,KAAK,cAAcD,EAAK,cAAcC;EACxC;EACA,KAAK,KAAK;CACZ;CAGA,MAAM,IAAS,IAAY;EACzB,AAAK,KAAK,cACV,KAAK,YAAY,IACjB,KAAK,cAAc,GACfE,KAAQ,KAAK,KAAK;CACxB;CAYA,QAAQ,GAAmB,GAA+B;EACxD,IAAMC,IAA8B,CAAC,GAC/BC,UAAgB,KAAK,QAAQL,GAAME,CAAI;EAC7C,IAAI,OAAO,iBAAmB,KAAa;GACzC,IAAII,IAAQ,GACNC,IAAW,IAAI,qBAAqB;IAExC,AADA,qBAAqBD,CAAK,GAC1B,IAAQ,sBAAsBD,CAAO;GACvC,CAAC;GAED,AADAE,EAAS,QAAQP,GAAM,EAAE,KAAK,aAAa,CAAC,GAC5CI,EAAS,WAAW;IAElB,AADAG,EAAS,WAAW,GACpB,qBAAqBD,CAAK;GAC5B,CAAC;EACH,OAAO,AAAI,OAAO,SAAW,QAC3B,OAAO,iBAAiB,UAAUD,CAAO,GACzCD,EAAS,WAAW,OAAO,oBAAoB,UAAUC,CAAO,CAAC;EAEnE,IAAI,OAAO,mBAAqB,KAAa;GAC3C,IAAMG,IAAY,IAAI,uBAAuB;IAC3C,AAAI,KAAK,YAAW,KAAK,MAAM,IAC1BH,EAAQ;GACf,CAAC;GAED,AADAG,EAAU,QAAQN,GAAM;IAAE,WAAW;IAAM,SAAS;IAAM,eAAe;GAAK,CAAC,GAC/EE,EAAS,WAAWI,EAAU,WAAW,CAAC;EAC5C;EACA,aAAa;GACX,KAAK,IAAMC,KAAWL,GAAU,EAAQ;GAIxC,KAAK,MAAM,EAAK;EAClB;CACF;CAEA,OAAqB;EACnB,KAAK,IAAML,KAAY,MAAM,KAAK,KAAK,SAAS,GAAG,EAAS;CAC9D;AACF;AASA,SAAgBW,EACd,GACA,GACA,GACwB;CACxB,IAAM,CAACC,KAASd,EAAM,eAAe,IAAIC,EAAsB,CAAC,GAC1Dc,IAASf,EAAM,qBACnBc,EAAM,WACNA,EAAM,aACNA,EAAM,iBACR,GACM,GAAGE,KAAehB,EAAM,YAAY,MAAkBiB,IAAQ,GAAG,CAAC;CAmBxE,OAfAjB,EAAM,sBAAsB;EAC1B,IAAKkB,KAAYf,KAASE,GAC1B,OAAOS,EAAM,QAAQX,GAAME,CAAI;CACjC,GAAG;EAACS;EAAOI;EAASf;EAAME;CAAI,CAAC,GAK/BL,EAAM,sBAAsB;EAC1B,IAAI,CAACkB,KAAW,CAACf,KAAQ,CAACE,KAAQS,EAAM,YAAY,MAAM,cAAc;EACxE,IAAMK,IAAcL,EAAM,UAAUE,CAAW;EAE/C,AADAF,EAAM,QAAQX,GAAME,CAAI,GACxBc,EAAY;CACd,CAAC,GAEMD,IAAUH,IAAS;AAC5B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/icons.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("react/jsx-runtime");var i={info:`Info:`,success:`Success:`,warning:`Warning:`,error:`Error:`},a={info:t.InfoIcon,success:t.SuccessIcon,warning:t.WarningIcon,error:t.ErrorIcon},o={info:`text-info-tint-foreground`,success:`text-success-tint-foreground`,warning:`text-warning-tint-foreground`,error:`text-error-tint-foreground`},s={info:`border-s-info`,success:`border-s-success`,warning:`border-s-warning`,error:`border-s-error`};function c(e,t){return t??i[e]}function l({status:e,size:t}){let n=a[e];return(0,r.jsx)(n,{size:t})}l.displayName=`StatusIcon`;function u({label:e,id:t}){return e?(0,r.jsx)(`span`,{id:t,className:`sr-only`,children:`${e} `}):null}u.displayName=`StatusText`,exports.STATUS_BORDER=s,exports.STATUS_ICON_COLOR=o,exports.STATUS_LABELS=i,exports.StatusIcon=l,exports.StatusText=u,exports.getStatusLabel=c;
|
|
2
|
+
//# sourceMappingURL=MessageBar.status.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBar.status.cjs","names":["InfoIcon","SuccessIcon","WarningIcon","ErrorIcon","require_runtime","require_icons","react","react_jsx_runtime","STATUS_LABELS","STATUS_ICONS","STATUS_ICON_COLOR","STATUS_BORDER","getStatusLabel","statusLabel","status","StatusIcon","Icon","StatusText","label"],"sources":["../../../src/components/feedback/MessageBar.status.tsx"],"sourcesContent":["/**\n * Internal status building blocks shared by MessageBar and Toast (spec §5.7): the status icons and\n * the visually hidden status text that tells screen-reader users the severity\n * (feedback-navigation#4). Not exported from the package.\n */\nimport * as React from 'react';\nimport { ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from '../../lib/icons';\nimport type { IconComponent } from '../../lib/icons';\nimport type { Status } from '../../lib/types';\n\n/** Default visually hidden status text, read before the message (\"Warning: Disk almost full\"). */\nexport const STATUS_LABELS: Readonly<Record<Status, string>> = {\n info: 'Info:',\n success: 'Success:',\n warning: 'Warning:',\n error: 'Error:',\n};\n\nconst STATUS_ICONS: Readonly<Record<Status, IconComponent>> = {\n info: InfoIcon,\n success: SuccessIcon,\n warning: WarningIcon,\n error: ErrorIcon,\n};\n\n/**\n * Icon color per status. The `*-tint-foreground` tokens keep ≥ 4.5:1 on both the status tints\n * (MessageBar) and the page background (Toast) in every theme, unlike the `warning` fill.\n */\nexport const STATUS_ICON_COLOR: Readonly<Record<Status, string>> = {\n info: 'text-info-tint-foreground',\n success: 'text-success-tint-foreground',\n warning: 'text-warning-tint-foreground',\n error: 'text-error-tint-foreground',\n};\n\n/** Logical start border color per status. */\nexport const STATUS_BORDER: Readonly<Record<Status, string>> = {\n info: 'border-s-info',\n success: 'border-s-success',\n warning: 'border-s-warning',\n error: 'border-s-error',\n};\n\n/** The resolved status text: `statusLabel` when given (`''` hides it), else the default. */\nexport function getStatusLabel(status: Status, statusLabel: string | undefined): string {\n return statusLabel ?? STATUS_LABELS[status];\n}\n\n/** The default status glyph (decorative: `aria-hidden`, `currentColor`). */\nexport function StatusIcon({ status, size }: { status: Status; size?: number }) {\n const Icon = STATUS_ICONS[status];\n return <Icon size={size} />;\n}\nStatusIcon.displayName = 'StatusIcon';\n\n/**\n * Visually hidden status text, followed by a space so it reads apart from the message. `id` lets\n * a labelled MessageBar or a toast container point `aria-labelledby` at it; an empty label\n * renders nothing, so pass the id only while the text renders.\n */\nexport function StatusText({ label, id }: { label: string; id?: string }) {\n if (!label) return null;\n return (\n <span id={id} className=\"sr-only\">\n {`${label} `}\n </span>\n );\n}\nStatusText.displayName = 'StatusText';\n"],"mappings":"iLAWA,IAAaQ,EAAkD,CAC7D,KAAM,QACN,QAAS,WACT,QAAS,WACT,MAAO,QACT,EAEMC,EAAwD,CAC5D,KAAMT,EAAAA,SACN,QAASC,EAAAA,YACT,QAASC,EAAAA,YACT,MAAOC,EAAAA,SACT,EAMaO,EAAsD,CACjE,KAAM,4BACN,QAAS,+BACT,QAAS,+BACT,MAAO,4BACT,EAGaC,EAAkD,CAC7D,KAAM,gBACN,QAAS,mBACT,QAAS,mBACT,MAAO,gBACT,EAGA,SAAgBC,EAAe,EAAgB,EAAyC,CACtF,OAAOC,GAAeL,EAAcM,EACtC,CAGA,SAAgBC,EAAW,CAAE,SAAQ,QAA2C,CAC9E,IAAMC,EAAOP,EAAaK,GAC1B,OAAO,EAAAP,EAAA,IAAA,CAACS,EAAD,CAAY,MAAO,CAAA,CAC5B,CACA,EAAW,YAAc,aAOzB,SAAgBC,EAAW,CAAE,QAAO,MAAsC,CAExE,OADKC,GAEH,EAAAX,EAAA,IAAA,CAAC,OAAD,CAAU,KAAI,UAAU,UACrB,SAAA,GAAGW,EAAM,EACN,CAAA,EAJW,IAMrB,CACA,EAAW,YAAc"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ErrorIcon as e, InfoIcon as t, SuccessIcon as n, WarningIcon as r } from "../../lib/icons.mjs";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/feedback/MessageBar.status.tsx
|
|
6
|
+
var a = {
|
|
7
|
+
info: "Info:",
|
|
8
|
+
success: "Success:",
|
|
9
|
+
warning: "Warning:",
|
|
10
|
+
error: "Error:"
|
|
11
|
+
}, o = {
|
|
12
|
+
info: t,
|
|
13
|
+
success: n,
|
|
14
|
+
warning: r,
|
|
15
|
+
error: e
|
|
16
|
+
}, s = {
|
|
17
|
+
info: "text-info-tint-foreground",
|
|
18
|
+
success: "text-success-tint-foreground",
|
|
19
|
+
warning: "text-warning-tint-foreground",
|
|
20
|
+
error: "text-error-tint-foreground"
|
|
21
|
+
}, c = {
|
|
22
|
+
info: "border-s-info",
|
|
23
|
+
success: "border-s-success",
|
|
24
|
+
warning: "border-s-warning",
|
|
25
|
+
error: "border-s-error"
|
|
26
|
+
};
|
|
27
|
+
function l(e, t) {
|
|
28
|
+
return t ?? a[e];
|
|
29
|
+
}
|
|
30
|
+
function u({ status: e, size: t }) {
|
|
31
|
+
let n = o[e];
|
|
32
|
+
return /* @__PURE__ */ i(n, { size: t });
|
|
33
|
+
}
|
|
34
|
+
u.displayName = "StatusIcon";
|
|
35
|
+
function d({ label: e, id: t }) {
|
|
36
|
+
return e ? /* @__PURE__ */ i("span", {
|
|
37
|
+
id: t,
|
|
38
|
+
className: "sr-only",
|
|
39
|
+
children: `${e} `
|
|
40
|
+
}) : null;
|
|
41
|
+
}
|
|
42
|
+
d.displayName = "StatusText";
|
|
43
|
+
//#endregion
|
|
44
|
+
export { c as STATUS_BORDER, s as STATUS_ICON_COLOR, a as STATUS_LABELS, u as StatusIcon, d as StatusText, l as getStatusLabel };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=MessageBar.status.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBar.status.mjs","names":["STATUS_LABELS","STATUS_ICONS","InfoIcon","SuccessIcon","WarningIcon","ErrorIcon","STATUS_ICON_COLOR","STATUS_BORDER","getStatusLabel","statusLabel","status","StatusIcon","Icon","StatusText","label"],"sources":["../../../src/components/feedback/MessageBar.status.tsx"],"sourcesContent":["/**\n * Internal status building blocks shared by MessageBar and Toast (spec §5.7): the status icons and\n * the visually hidden status text that tells screen-reader users the severity\n * (feedback-navigation#4). Not exported from the package.\n */\nimport * as React from 'react';\nimport { ErrorIcon, InfoIcon, SuccessIcon, WarningIcon } from '../../lib/icons';\nimport type { IconComponent } from '../../lib/icons';\nimport type { Status } from '../../lib/types';\n\n/** Default visually hidden status text, read before the message (\"Warning: Disk almost full\"). */\nexport const STATUS_LABELS: Readonly<Record<Status, string>> = {\n info: 'Info:',\n success: 'Success:',\n warning: 'Warning:',\n error: 'Error:',\n};\n\nconst STATUS_ICONS: Readonly<Record<Status, IconComponent>> = {\n info: InfoIcon,\n success: SuccessIcon,\n warning: WarningIcon,\n error: ErrorIcon,\n};\n\n/**\n * Icon color per status. The `*-tint-foreground` tokens keep ≥ 4.5:1 on both the status tints\n * (MessageBar) and the page background (Toast) in every theme, unlike the `warning` fill.\n */\nexport const STATUS_ICON_COLOR: Readonly<Record<Status, string>> = {\n info: 'text-info-tint-foreground',\n success: 'text-success-tint-foreground',\n warning: 'text-warning-tint-foreground',\n error: 'text-error-tint-foreground',\n};\n\n/** Logical start border color per status. */\nexport const STATUS_BORDER: Readonly<Record<Status, string>> = {\n info: 'border-s-info',\n success: 'border-s-success',\n warning: 'border-s-warning',\n error: 'border-s-error',\n};\n\n/** The resolved status text: `statusLabel` when given (`''` hides it), else the default. */\nexport function getStatusLabel(status: Status, statusLabel: string | undefined): string {\n return statusLabel ?? STATUS_LABELS[status];\n}\n\n/** The default status glyph (decorative: `aria-hidden`, `currentColor`). */\nexport function StatusIcon({ status, size }: { status: Status; size?: number }) {\n const Icon = STATUS_ICONS[status];\n return <Icon size={size} />;\n}\nStatusIcon.displayName = 'StatusIcon';\n\n/**\n * Visually hidden status text, followed by a space so it reads apart from the message. `id` lets\n * a labelled MessageBar or a toast container point `aria-labelledby` at it; an empty label\n * renders nothing, so pass the id only while the text renders.\n */\nexport function StatusText({ label, id }: { label: string; id?: string }) {\n if (!label) return null;\n return (\n <span id={id} className=\"sr-only\">\n {`${label} `}\n </span>\n );\n}\nStatusText.displayName = 'StatusText';\n"],"mappings":";;;;;AAWA,IAAaA,IAAkD;CAC7D,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT,GAEMC,IAAwD;CAC5D,MAAMC;CACN,SAASC;CACT,SAASC;CACT,OAAOC;AACT,GAMaC,IAAsD;CACjE,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT,GAGaC,IAAkD;CAC7D,MAAM;CACN,SAAS;CACT,SAAS;CACT,OAAO;AACT;AAGA,SAAgBC,EAAe,GAAgB,GAAyC;CACtF,OAAOC,KAAeT,EAAcU;AACtC;AAGA,SAAgBC,EAAW,EAAE,WAAQ,WAA2C;CAC9E,IAAMC,IAAOX,EAAaS;CAC1B,OAAO,kBAACE,GAAD,EAAY,QAAO,CAAA;AAC5B;AACA,EAAW,cAAc;AAOzB,SAAgBC,EAAW,EAAE,UAAO,SAAsC;CAExE,OADKC,IAEH,kBAAC,QAAD;EAAU;EAAI,WAAU;EACrB,UAAA,GAAGA,EAAM;CACN,CAAA,IAJW;AAMrB;AACA,EAAW,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../hooks/useId.cjs"),a=require("../../hooks/useFieldControl.cjs"),o=require("../../lib/styles.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("react/jsx-runtime");var l={brand:`bg-primary`,success:`bg-success`,warning:`bg-severe`,error:`bg-error`},u={error:`error`,warning:`warning`,success:`success`};function d(e){return typeof e==`string`&&e.trim()!==``}var f=({value:e,max:f=100,label:p,showLabel:m,color:h,id:g,"aria-describedby":_,"aria-invalid":v,"aria-required":y,className:b,ref:x,...S})=>{let C=i.useId(`progress-label`),w=i.useId(`progress`),T=a.useFieldContext(),E=a.useFieldControl({id:g??(T?w:void 0),"aria-describedby":_},{labelable:!1}),D=T?T.validationState??(T.invalid?`error`:`none`):`none`,O=h??u[D]??`brand`,k=e===void 0,A=Number.isFinite(f)&&f>0,j=k||Number.isFinite(e),M=!k&&A&&j?Math.min(f,Math.max(0,e)):0,N=A?M/f*100:0,P=d(p),F=d(S[`aria-label`]),I=d(S[`aria-labelledby`]),L=E[`aria-labelledby`],R=!P&&!F&&!I&&d(L);s.useEffect(()=>{n.isDev&&(!P&&!F&&!I&&!R&&n.warnOnce(`ProgressBar:name`,"ProgressBar: a progress bar needs an accessible name. Pass `label` (add `showLabel` to show it), `aria-label` or `aria-labelledby`."),m&&!P&&n.warnOnce(`ProgressBar:show-label`,"ProgressBar: `showLabel` renders the `label` prop, which is empty."),A||n.warnOnce(`ProgressBar:max`,`ProgressBar: \`max\` must be a finite number greater than 0 (got ${String(f)}); the bar renders 0%.`),j||n.warnOnce(`ProgressBar:value`,`ProgressBar: \`value\` must be a finite number (got ${String(e)}); the bar renders 0%.`))},[P,F,I,R,m,A,j,f,e]);let z=!!(m&&P),B={role:`progressbar`,"aria-valuenow":k?void 0:M,"aria-valuemin":0,"aria-valuemax":A?f:100,"data-color":O};E.id!==void 0&&(B.id=E.id),E[`aria-describedby`]!==void 0&&(B[`aria-describedby`]=E[`aria-describedby`]),!F&&!I&&(z?B[`aria-labelledby`]=C:P?B[`aria-label`]=p:R&&(B[`aria-labelledby`]=L));for(let[e,t]of Object.entries(S))t!==void 0&&(e!==`aria-label`&&e!==`aria-labelledby`||d(t))&&(B[e]=t);let V=(0,c.jsx)(`div`,{...B,ref:x,className:t.cn(r.progressBarClassNames.root,`h-2 overflow-hidden rounded-full bg-track`,`forced-colors:border`,o.forcedColors.border,b),children:(0,c.jsx)(`div`,{className:t.cn(r.progressBarClassNames.bar,`h-full rounded-full`,l[O],o.forcedColors.selectedLeaf,k&&`w-2/5 animate-wave-indeterminate wave-rtl:animate-wave-indeterminate-rtl motion-reduce:w-full motion-reduce:translate-x-0 motion-reduce:animate-wave-pulse wave-rtl:motion-reduce:animate-wave-pulse`),style:k?void 0:{width:`${N}%`}})});return z?(0,c.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,c.jsx)(`span`,{id:C,className:t.cn(r.progressBarClassNames.label,`text-body-1 text-foreground`),children:p}),V]}):V};f.displayName=`ProgressBar`,exports.ProgressBar=f;
|
|
2
|
+
//# sourceMappingURL=ProgressBar.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.cjs","names":["useId","useFieldContext","useFieldControl","isDev","cn","progressBarClassNames","forcedColors","require_runtime","require_cn","require_dev","require_classNames","require_useId","require_useFieldControl","require_styles","react","react_jsx_runtime","fillColorClasses","fieldColors","isName","value","ProgressBar","ariaDescribedBy","_ariaInvalid","_ariaRequired","rest","labelId","ownId","field","fieldProps","id","fieldState","resolvedColor","color","isIndeterminate","validMax","max","validValue","clamped","percentage","hasLabel","label","hasAriaLabel","hasAriaLabelledBy","fieldLabelledBy","hasFieldName","showLabel","visibleLabel","barProps","key","propValue","bar","className"],"sources":["../../../src/components/feedback/ProgressBar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { progressBarClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { isDev, warnOnce } from '../../lib/dev';\nimport { forcedColors } from '../../lib/styles';\nimport type { ValidationState } from '../../lib/types';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useId } from '../../hooks/useId';\n\n/** Color of a {@link ProgressBar}'s fill. */\nexport type ProgressBarColor = 'brand' | 'success' | 'warning' | 'error';\n\n/** Properties for the ProgressBar component. */\nexport interface ProgressBarProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Current progress value, clamped to `0…max` for both the fill and `aria-valuenow`. Omit for\n * indeterminate mode. A non-finite value renders 0% (development warning).\n */\n value?: number;\n /**\n * Maximum progress value. A `max` of 0 or less, or a non-finite `max`, renders 0% (development\n * warning) and is reported to assistive technology as 0 of 100.\n * @default 100\n */\n max?: number;\n /**\n * Accessible name of the progress bar: `aria-label` by default, or a visible label with\n * `showLabel`. A progress bar needs a name (`label`, `aria-label` or `aria-labelledby`); a\n * development warning fires without one. A consumer `aria-label` or `aria-labelledby` takes\n * precedence over `label`; an empty or whitespace-only one counts as absent (it is not rendered).\n * Inside a `Field`, the Field's label names the bar when neither `label` nor a consumer name is\n * given.\n */\n label?: string;\n /**\n * Renders `label` as visible text above the bar and names the bar with it (`aria-labelledby`)\n * instead of `aria-label`, unless a consumer `aria-label` or `aria-labelledby` names the bar\n * (keep the visible text in that name, WCAG 2.5.3). The label and the bar are then wrapped in a\n * `div`; `ref`, `className`, `style` and the other props stay on the progress bar element.\n */\n showLabel?: boolean;\n /**\n * Color of the fill. Inside a `Field` it follows the Field's validation state (error, warning,\n * success) unless you set it. `warning` fills with the dark orange of the `severe` color, which\n * keeps 3:1 against the track in every theme. The bar carries `data-color` with the resolved\n * color.\n * @default 'brand'\n */\n color?: ProgressBarColor;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst fillColorClasses: Record<ProgressBarColor, string> = {\n brand: 'bg-primary',\n success: 'bg-success',\n // The warning token (a light yellow) is 1.02:1 on the light track: the severe orange passes 3:1.\n warning: 'bg-severe',\n error: 'bg-error',\n};\n\n/** The fill color a Field's validation state gives the bar (`none` keeps the default). */\nconst fieldColors: Partial<Record<ValidationState, ProgressBarColor>> = {\n error: 'error',\n warning: 'warning',\n success: 'success',\n};\n\n/** Whether a name prop (`label`, `aria-label`, `aria-labelledby`) holds more than whitespace. */\nfunction isName(value: unknown): value is string {\n return typeof value === 'string' && value.trim() !== '';\n}\n\n/**\n * Shows the progress of a task, or that a task is running (indeterminate, `value` omitted).\n *\n * - Name it with `label` (or `aria-label` / `aria-labelledby`); `showLabel` shows the label above\n * the bar.\n * - `value` is clamped to `0…max`; invalid numbers render an empty bar and warn in development.\n * - `color` picks the fill (`brand`, `success`, `warning`, `error`).\n * - Inside a `Field`, the Field's label names a bar that has no name of its own, its validation\n * message and hint describe the bar, and its validation state (error, warning, success) colors\n * the fill unless `color` is set. A progress bar is never invalid or required: the\n * `aria-invalid` and `aria-required` a Field adds are not rendered. Next to another control in\n * a Field's wrapper element, the bar gets an id of its own and leaves the Field's\n * `<label htmlFor>` to that control.\n * - The indeterminate animation follows the writing direction and becomes a full-width pulse for\n * reduced motion. In forced-colors mode the fill uses `Highlight` and the track gets a border.\n *\n * @example\n * <ProgressBar value={uploaded} max={total} label=\"Uploading photos\" showLabel />\n *\n * @example\n * <Field label=\"Upload\" validationState=\"warning\" validationMessage=\"The connection is slow.\">\n * <ProgressBar value={uploaded} max={total} />\n * </Field>\n */\nexport const ProgressBar = ({\n value,\n max = 100,\n label,\n showLabel,\n color,\n id,\n 'aria-describedby': ariaDescribedBy,\n // Field merges both into its first child; neither is allowed on role=\"progressbar\".\n 'aria-invalid': _ariaInvalid,\n 'aria-required': _ariaRequired,\n className,\n ref,\n ...rest\n}: ProgressBarProps) => {\n const labelId = useId('progress-label');\n const ownId = useId('progress');\n const field = useFieldContext();\n // A <label htmlFor> cannot name a progress bar, so inside a Field a bar without an id (Field\n // passes its control id to a first child as `id`) takes its own instead of claiming the\n // control id: that stays with the control the label names (an Input next to the bar in a\n // wrapper). No name props are passed, so with `labelable: false` the merged `aria-labelledby`\n // is exactly the Field's label id (or absent); it is used only when the bar has no name of its\n // own.\n const fieldProps = useFieldControl(\n { id: id ?? (field ? ownId : undefined), 'aria-describedby': ariaDescribedBy },\n { labelable: false },\n );\n // A context built before 0.6 has no validation state: read it from `invalid`.\n const fieldState = field ? (field.validationState ?? (field.invalid ? 'error' : 'none')) : 'none';\n const resolvedColor = color ?? fieldColors[fieldState] ?? 'brand';\n const isIndeterminate = value === undefined;\n const validMax = Number.isFinite(max) && max > 0;\n const validValue = isIndeterminate || Number.isFinite(value);\n /** Clamped once, used for both the fill width and `aria-valuenow`. */\n const clamped =\n !isIndeterminate && validMax && validValue ? Math.min(max, Math.max(0, value)) : 0;\n const percentage = validMax ? (clamped / max) * 100 : 0;\n\n // An empty or whitespace-only `label`, `aria-label` or `aria-labelledby` names nothing: it is\n // treated like `undefined` by the precedence, the rendered attributes and the warning alike.\n const hasLabel = isName(label);\n const hasAriaLabel = isName(rest['aria-label']);\n const hasAriaLabelledBy = isName(rest['aria-labelledby']);\n const fieldLabelledBy = fieldProps['aria-labelledby'];\n const hasFieldName = !hasLabel && !hasAriaLabel && !hasAriaLabelledBy && isName(fieldLabelledBy);\n\n // Development diagnostics (C-DEV): emitted from an effect, once per page.\n React.useEffect(() => {\n if (!isDev) return;\n if (!hasLabel && !hasAriaLabel && !hasAriaLabelledBy && !hasFieldName) {\n warnOnce(\n 'ProgressBar:name',\n 'ProgressBar: a progress bar needs an accessible name. Pass `label` (add `showLabel` to show it), `aria-label` or `aria-labelledby`.',\n );\n }\n if (showLabel && !hasLabel) {\n warnOnce(\n 'ProgressBar:show-label',\n 'ProgressBar: `showLabel` renders the `label` prop, which is empty.',\n );\n }\n if (!validMax) {\n warnOnce(\n 'ProgressBar:max',\n `ProgressBar: \\`max\\` must be a finite number greater than 0 (got ${String(max)}); the bar renders 0%.`,\n );\n }\n if (!validValue) {\n warnOnce(\n 'ProgressBar:value',\n `ProgressBar: \\`value\\` must be a finite number (got ${String(value)}); the bar renders 0%.`,\n );\n }\n }, [\n hasLabel,\n hasAriaLabel,\n hasAriaLabelledBy,\n hasFieldName,\n showLabel,\n validMax,\n validValue,\n max,\n value,\n ]);\n\n const visibleLabel = Boolean(showLabel && hasLabel);\n\n /**\n * The bar's attributes. Defaults the consumer may override (C-COMPOSE) apply wherever the\n * consumer's value is `undefined` — also when the key is present, e.g. a wrapper that forwards\n * `aria-label={props['aria-label']}` — so a forwarded `undefined` never strips the role, the\n * values or the name derived from `label`. An empty `aria-label`/`aria-labelledby` is dropped\n * the same way instead of rendering a nameless attribute.\n */\n const barProps: Record<string, unknown> = {\n role: 'progressbar',\n 'aria-valuenow': isIndeterminate ? undefined : clamped,\n 'aria-valuemin': 0,\n 'aria-valuemax': validMax ? max : 100,\n 'data-color': resolvedColor,\n };\n // The consumer's id (or the control id Field passes to its first child), else its own id inside\n // a Field; the consumer's description, then the Field's validation message and hint.\n if (fieldProps.id !== undefined) barProps.id = fieldProps.id;\n if (fieldProps['aria-describedby'] !== undefined) {\n barProps['aria-describedby'] = fieldProps['aria-describedby'];\n }\n // A consumer `aria-label` or `aria-labelledby` wins over the name derived from `label`, also\n // with `showLabel` (the visible label then stays unreferenced text). The Field's label names\n // only a bar without a name of its own.\n if (!hasAriaLabel && !hasAriaLabelledBy) {\n if (visibleLabel) barProps['aria-labelledby'] = labelId;\n else if (hasLabel) barProps['aria-label'] = label;\n else if (hasFieldName) barProps['aria-labelledby'] = fieldLabelledBy;\n }\n for (const [key, propValue] of Object.entries(rest)) {\n if (propValue === undefined) continue;\n if ((key === 'aria-label' || key === 'aria-labelledby') && !isName(propValue)) continue;\n barProps[key] = propValue;\n }\n\n const bar = (\n <div\n {...barProps}\n ref={ref}\n className={cn(\n progressBarClassNames.root,\n 'h-2 overflow-hidden rounded-full bg-track',\n 'forced-colors:border',\n forcedColors.border,\n className,\n )}\n >\n <div\n className={cn(\n progressBarClassNames.bar,\n 'h-full rounded-full',\n fillColorClasses[resolvedColor],\n forcedColors.selectedLeaf,\n isIndeterminate &&\n 'w-2/5 animate-wave-indeterminate wave-rtl:animate-wave-indeterminate-rtl motion-reduce:w-full motion-reduce:translate-x-0 motion-reduce:animate-wave-pulse wave-rtl:motion-reduce:animate-wave-pulse',\n )}\n style={isIndeterminate ? undefined : { width: `${percentage}%` }}\n />\n </div>\n );\n\n if (!visibleLabel) return bar;\n\n return (\n <div className=\"flex flex-col gap-1\">\n <span id={labelId} className={cn(progressBarClassNames.label, 'text-body-1 text-foreground')}>\n {label}\n </span>\n {bar}\n </div>\n );\n};\n\nProgressBar.displayName = 'ProgressBar';\n"],"mappings":"qWAoDA,IAAMgB,EAAqD,CACzD,MAAO,aACP,QAAS,aAET,QAAS,YACT,MAAO,UACT,EAGMC,EAAkE,CACtE,MAAO,QACP,QAAS,UACT,QAAS,SACX,EAGA,SAASC,EAAO,EAAiC,CAC/C,OAAO,OAAOC,GAAU,UAAYA,EAAM,KAAK,IAAM,EACvD,CA0BA,IAAaC,GAAe,CAC1B,QACA,MAAM,IACN,QACA,YACA,QACA,KACA,mBAAoBC,EAEpB,eAAgBC,EAChB,gBAAiBC,EACjB,YACA,MACA,GAAGC,KACmB,CACtB,IAAMC,EAAUzB,EAAAA,MAAM,gBAAgB,EAChC0B,EAAQ1B,EAAAA,MAAM,UAAU,EACxB2B,EAAQ1B,EAAAA,gBAAgB,EAOxB2B,EAAa1B,EAAAA,gBACjB,CAAE,GAAI2B,IAAOF,EAAQD,EAAQ,IAAA,IAAY,mBAAoBL,CAAgB,EAC7E,CAAE,UAAW,EAAM,CACrB,EAEMS,EAAaH,EAASA,EAAM,kBAAoBA,EAAM,QAAU,QAAU,QAAW,OACrFI,EAAgBC,GAASf,EAAYa,IAAe,QACpDG,EAAkBd,IAAU,IAAA,GAC5Be,EAAW,OAAO,SAASC,CAAG,GAAKA,EAAM,EACzCC,EAAaH,GAAmB,OAAO,SAASd,CAAK,EAErDkB,EACJ,CAACJ,GAAmBC,GAAYE,EAAa,KAAK,IAAID,EAAK,KAAK,IAAI,EAAGhB,CAAK,CAAC,EAAI,EAC7EmB,EAAaJ,EAAYG,EAAUF,EAAO,IAAM,EAIhDI,EAAWrB,EAAOsB,CAAK,EACvBC,EAAevB,EAAOM,EAAK,aAAa,EACxCkB,EAAoBxB,EAAOM,EAAK,kBAAkB,EAClDmB,EAAkBf,EAAW,mBAC7BgB,EAAe,CAACL,GAAY,CAACE,GAAgB,CAACC,GAAqBxB,EAAOyB,CAAe,EAG/F7B,EAAM,cAAgB,CACfX,EAAAA,QACD,CAACoC,GAAY,CAACE,GAAgB,CAACC,GAAqB,CAACE,GACvDnC,EAAA,SACE,mBACA,qIACF,EAEEoC,GAAa,CAACN,GAChB9B,EAAA,SACE,yBACA,oEACF,EAEGyB,GACHzB,EAAA,SACE,kBACA,oEAAoE,OAAO0B,CAAG,EAAE,uBAClF,EAEGC,GACH3B,EAAA,SACE,oBACA,uDAAuD,OAAOU,CAAK,EAAE,uBACvE,EAEJ,EAAG,CACDoB,EACAE,EACAC,EACAE,EACAC,EACAX,EACAE,EACAD,EACAhB,CACF,CAAC,EAED,IAAM2B,EAAe,GAAQD,GAAaN,GASpCQ,EAAoC,CACxC,KAAM,cACN,gBAAiBd,EAAkB,IAAA,GAAYI,EAC/C,gBAAiB,EACjB,gBAAiBH,EAAWC,EAAM,IAClC,aAAcJ,CAChB,EAGIH,EAAW,KAAO,IAAA,KAAW,EAAS,GAAKA,EAAW,IACtDA,EAAW,sBAAwB,IAAA,KACrC,EAAS,oBAAsBA,EAAW,qBAKxC,CAACa,GAAgB,CAACC,IAChBI,EAAc,EAAS,mBAAqBrB,EACvCc,EAAU,EAAS,cAAgBC,EACnCI,IAAc,EAAS,mBAAqBD,IAEvD,IAAK,GAAM,CAACK,EAAKC,KAAc,OAAO,QAAQzB,CAAI,EAC5CyB,IAAc,IAAA,KACbD,IAAQ,cAAgBA,IAAQ,mBAAuB9B,EAAO+B,CAAS,KAC5E,EAASD,GAAOC,GAGlB,IAAMC,GACJ,EAAAnC,EAAA,IAAA,CAAC,MAAD,CACE,GAAIgC,EACC,MACL,UAAW3C,EAAAA,GACTC,EAAAA,sBAAsB,KACtB,4CACA,uBACAC,EAAAA,aAAa,OACb6C,CACF,EAEA,UAAA,EAAApC,EAAA,IAAA,CAAC,MAAD,CACE,UAAWX,EAAAA,GACTC,EAAAA,sBAAsB,IACtB,sBACAW,EAAiBe,GACjBzB,EAAAA,aAAa,aACb2B,GACE,sMACJ,EACA,MAAOA,EAAkB,IAAA,GAAY,CAAE,MAAO,GAAGK,EAAW,EAAG,CAChE,CAAA,CACE,CAAA,EAKP,OAFKQ,GAGH,EAAA/B,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,sBAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,GAAIU,EAAS,UAAWrB,EAAAA,GAAGC,EAAAA,sBAAsB,MAAO,6BAA6B,EACxF,SAAAmC,CACG,CAAA,EACLU,CACE,IARmBA,CAU5B,EAEA,EAAY,YAAc"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { isDev as t, warnOnce as n } from "../../lib/dev.mjs";
|
|
4
|
+
import { progressBarClassNames as r } from "../../lib/classNames.mjs";
|
|
5
|
+
import { useId as i } from "../../hooks/useId.mjs";
|
|
6
|
+
import { useFieldContext as a, useFieldControl as o } from "../../hooks/useFieldControl.mjs";
|
|
7
|
+
import { forcedColors as s } from "../../lib/styles.mjs";
|
|
8
|
+
import * as c from "react";
|
|
9
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/feedback/ProgressBar.tsx
|
|
11
|
+
var d = {
|
|
12
|
+
brand: "bg-primary",
|
|
13
|
+
success: "bg-success",
|
|
14
|
+
warning: "bg-severe",
|
|
15
|
+
error: "bg-error"
|
|
16
|
+
}, f = {
|
|
17
|
+
error: "error",
|
|
18
|
+
warning: "warning",
|
|
19
|
+
success: "success"
|
|
20
|
+
};
|
|
21
|
+
function p(e) {
|
|
22
|
+
return typeof e == "string" && e.trim() !== "";
|
|
23
|
+
}
|
|
24
|
+
var m = ({ value: m, max: h = 100, label: g, showLabel: _, color: v, id: y, "aria-describedby": b, "aria-invalid": x, "aria-required": S, className: C, ref: w, ...T }) => {
|
|
25
|
+
let E = i("progress-label"), D = i("progress"), O = a(), k = o({
|
|
26
|
+
id: y ?? (O ? D : void 0),
|
|
27
|
+
"aria-describedby": b
|
|
28
|
+
}, { labelable: !1 }), A = O ? O.validationState ?? (O.invalid ? "error" : "none") : "none", j = v ?? f[A] ?? "brand", M = m === void 0, N = Number.isFinite(h) && h > 0, P = M || Number.isFinite(m), F = !M && N && P ? Math.min(h, Math.max(0, m)) : 0, I = N ? F / h * 100 : 0, L = p(g), R = p(T["aria-label"]), z = p(T["aria-labelledby"]), B = k["aria-labelledby"], V = !L && !R && !z && p(B);
|
|
29
|
+
c.useEffect(() => {
|
|
30
|
+
t && (!L && !R && !z && !V && n("ProgressBar:name", "ProgressBar: a progress bar needs an accessible name. Pass `label` (add `showLabel` to show it), `aria-label` or `aria-labelledby`."), _ && !L && n("ProgressBar:show-label", "ProgressBar: `showLabel` renders the `label` prop, which is empty."), N || n("ProgressBar:max", `ProgressBar: \`max\` must be a finite number greater than 0 (got ${String(h)}); the bar renders 0%.`), P || n("ProgressBar:value", `ProgressBar: \`value\` must be a finite number (got ${String(m)}); the bar renders 0%.`));
|
|
31
|
+
}, [
|
|
32
|
+
L,
|
|
33
|
+
R,
|
|
34
|
+
z,
|
|
35
|
+
V,
|
|
36
|
+
_,
|
|
37
|
+
N,
|
|
38
|
+
P,
|
|
39
|
+
h,
|
|
40
|
+
m
|
|
41
|
+
]);
|
|
42
|
+
let H = !!(_ && L), U = {
|
|
43
|
+
role: "progressbar",
|
|
44
|
+
"aria-valuenow": M ? void 0 : F,
|
|
45
|
+
"aria-valuemin": 0,
|
|
46
|
+
"aria-valuemax": N ? h : 100,
|
|
47
|
+
"data-color": j
|
|
48
|
+
};
|
|
49
|
+
k.id !== void 0 && (U.id = k.id), k["aria-describedby"] !== void 0 && (U["aria-describedby"] = k["aria-describedby"]), !R && !z && (H ? U["aria-labelledby"] = E : L ? U["aria-label"] = g : V && (U["aria-labelledby"] = B));
|
|
50
|
+
for (let [e, t] of Object.entries(T)) t !== void 0 && (e !== "aria-label" && e !== "aria-labelledby" || p(t)) && (U[e] = t);
|
|
51
|
+
let W = /* @__PURE__ */ l("div", {
|
|
52
|
+
...U,
|
|
53
|
+
ref: w,
|
|
54
|
+
className: e(r.root, "h-2 overflow-hidden rounded-full bg-track", "forced-colors:border", s.border, C),
|
|
55
|
+
children: /* @__PURE__ */ l("div", {
|
|
56
|
+
className: e(r.bar, "h-full rounded-full", d[j], s.selectedLeaf, M && "w-2/5 animate-wave-indeterminate wave-rtl:animate-wave-indeterminate-rtl motion-reduce:w-full motion-reduce:translate-x-0 motion-reduce:animate-wave-pulse wave-rtl:motion-reduce:animate-wave-pulse"),
|
|
57
|
+
style: M ? void 0 : { width: `${I}%` }
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
return H ? /* @__PURE__ */ u("div", {
|
|
61
|
+
className: "flex flex-col gap-1",
|
|
62
|
+
children: [/* @__PURE__ */ l("span", {
|
|
63
|
+
id: E,
|
|
64
|
+
className: e(r.label, "text-body-1 text-foreground"),
|
|
65
|
+
children: g
|
|
66
|
+
}), W]
|
|
67
|
+
}) : W;
|
|
68
|
+
};
|
|
69
|
+
m.displayName = "ProgressBar";
|
|
70
|
+
//#endregion
|
|
71
|
+
export { m as ProgressBar };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=ProgressBar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressBar.mjs","names":["useId","useId$1","React","fillColorClasses","fieldColors","isName","value","ProgressBar","ariaDescribedBy","_ariaInvalid","_ariaRequired","rest","labelId","ownId","field","useFieldContext","fieldProps","useFieldControl","id","fieldState","resolvedColor","color","isIndeterminate","validMax","max","validValue","clamped","percentage","hasLabel","label","hasAriaLabel","hasAriaLabelledBy","fieldLabelledBy","hasFieldName","isDev","warnOnce","showLabel","visibleLabel","barProps","key","propValue","bar","cn","progressBarClassNames","forcedColors","className"],"sources":["../../../src/components/feedback/ProgressBar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { progressBarClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { isDev, warnOnce } from '../../lib/dev';\nimport { forcedColors } from '../../lib/styles';\nimport type { ValidationState } from '../../lib/types';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useId } from '../../hooks/useId';\n\n/** Color of a {@link ProgressBar}'s fill. */\nexport type ProgressBarColor = 'brand' | 'success' | 'warning' | 'error';\n\n/** Properties for the ProgressBar component. */\nexport interface ProgressBarProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Current progress value, clamped to `0…max` for both the fill and `aria-valuenow`. Omit for\n * indeterminate mode. A non-finite value renders 0% (development warning).\n */\n value?: number;\n /**\n * Maximum progress value. A `max` of 0 or less, or a non-finite `max`, renders 0% (development\n * warning) and is reported to assistive technology as 0 of 100.\n * @default 100\n */\n max?: number;\n /**\n * Accessible name of the progress bar: `aria-label` by default, or a visible label with\n * `showLabel`. A progress bar needs a name (`label`, `aria-label` or `aria-labelledby`); a\n * development warning fires without one. A consumer `aria-label` or `aria-labelledby` takes\n * precedence over `label`; an empty or whitespace-only one counts as absent (it is not rendered).\n * Inside a `Field`, the Field's label names the bar when neither `label` nor a consumer name is\n * given.\n */\n label?: string;\n /**\n * Renders `label` as visible text above the bar and names the bar with it (`aria-labelledby`)\n * instead of `aria-label`, unless a consumer `aria-label` or `aria-labelledby` names the bar\n * (keep the visible text in that name, WCAG 2.5.3). The label and the bar are then wrapped in a\n * `div`; `ref`, `className`, `style` and the other props stay on the progress bar element.\n */\n showLabel?: boolean;\n /**\n * Color of the fill. Inside a `Field` it follows the Field's validation state (error, warning,\n * success) unless you set it. `warning` fills with the dark orange of the `severe` color, which\n * keeps 3:1 against the track in every theme. The bar carries `data-color` with the resolved\n * color.\n * @default 'brand'\n */\n color?: ProgressBarColor;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst fillColorClasses: Record<ProgressBarColor, string> = {\n brand: 'bg-primary',\n success: 'bg-success',\n // The warning token (a light yellow) is 1.02:1 on the light track: the severe orange passes 3:1.\n warning: 'bg-severe',\n error: 'bg-error',\n};\n\n/** The fill color a Field's validation state gives the bar (`none` keeps the default). */\nconst fieldColors: Partial<Record<ValidationState, ProgressBarColor>> = {\n error: 'error',\n warning: 'warning',\n success: 'success',\n};\n\n/** Whether a name prop (`label`, `aria-label`, `aria-labelledby`) holds more than whitespace. */\nfunction isName(value: unknown): value is string {\n return typeof value === 'string' && value.trim() !== '';\n}\n\n/**\n * Shows the progress of a task, or that a task is running (indeterminate, `value` omitted).\n *\n * - Name it with `label` (or `aria-label` / `aria-labelledby`); `showLabel` shows the label above\n * the bar.\n * - `value` is clamped to `0…max`; invalid numbers render an empty bar and warn in development.\n * - `color` picks the fill (`brand`, `success`, `warning`, `error`).\n * - Inside a `Field`, the Field's label names a bar that has no name of its own, its validation\n * message and hint describe the bar, and its validation state (error, warning, success) colors\n * the fill unless `color` is set. A progress bar is never invalid or required: the\n * `aria-invalid` and `aria-required` a Field adds are not rendered. Next to another control in\n * a Field's wrapper element, the bar gets an id of its own and leaves the Field's\n * `<label htmlFor>` to that control.\n * - The indeterminate animation follows the writing direction and becomes a full-width pulse for\n * reduced motion. In forced-colors mode the fill uses `Highlight` and the track gets a border.\n *\n * @example\n * <ProgressBar value={uploaded} max={total} label=\"Uploading photos\" showLabel />\n *\n * @example\n * <Field label=\"Upload\" validationState=\"warning\" validationMessage=\"The connection is slow.\">\n * <ProgressBar value={uploaded} max={total} />\n * </Field>\n */\nexport const ProgressBar = ({\n value,\n max = 100,\n label,\n showLabel,\n color,\n id,\n 'aria-describedby': ariaDescribedBy,\n // Field merges both into its first child; neither is allowed on role=\"progressbar\".\n 'aria-invalid': _ariaInvalid,\n 'aria-required': _ariaRequired,\n className,\n ref,\n ...rest\n}: ProgressBarProps) => {\n const labelId = useId('progress-label');\n const ownId = useId('progress');\n const field = useFieldContext();\n // A <label htmlFor> cannot name a progress bar, so inside a Field a bar without an id (Field\n // passes its control id to a first child as `id`) takes its own instead of claiming the\n // control id: that stays with the control the label names (an Input next to the bar in a\n // wrapper). No name props are passed, so with `labelable: false` the merged `aria-labelledby`\n // is exactly the Field's label id (or absent); it is used only when the bar has no name of its\n // own.\n const fieldProps = useFieldControl(\n { id: id ?? (field ? ownId : undefined), 'aria-describedby': ariaDescribedBy },\n { labelable: false },\n );\n // A context built before 0.6 has no validation state: read it from `invalid`.\n const fieldState = field ? (field.validationState ?? (field.invalid ? 'error' : 'none')) : 'none';\n const resolvedColor = color ?? fieldColors[fieldState] ?? 'brand';\n const isIndeterminate = value === undefined;\n const validMax = Number.isFinite(max) && max > 0;\n const validValue = isIndeterminate || Number.isFinite(value);\n /** Clamped once, used for both the fill width and `aria-valuenow`. */\n const clamped =\n !isIndeterminate && validMax && validValue ? Math.min(max, Math.max(0, value)) : 0;\n const percentage = validMax ? (clamped / max) * 100 : 0;\n\n // An empty or whitespace-only `label`, `aria-label` or `aria-labelledby` names nothing: it is\n // treated like `undefined` by the precedence, the rendered attributes and the warning alike.\n const hasLabel = isName(label);\n const hasAriaLabel = isName(rest['aria-label']);\n const hasAriaLabelledBy = isName(rest['aria-labelledby']);\n const fieldLabelledBy = fieldProps['aria-labelledby'];\n const hasFieldName = !hasLabel && !hasAriaLabel && !hasAriaLabelledBy && isName(fieldLabelledBy);\n\n // Development diagnostics (C-DEV): emitted from an effect, once per page.\n React.useEffect(() => {\n if (!isDev) return;\n if (!hasLabel && !hasAriaLabel && !hasAriaLabelledBy && !hasFieldName) {\n warnOnce(\n 'ProgressBar:name',\n 'ProgressBar: a progress bar needs an accessible name. Pass `label` (add `showLabel` to show it), `aria-label` or `aria-labelledby`.',\n );\n }\n if (showLabel && !hasLabel) {\n warnOnce(\n 'ProgressBar:show-label',\n 'ProgressBar: `showLabel` renders the `label` prop, which is empty.',\n );\n }\n if (!validMax) {\n warnOnce(\n 'ProgressBar:max',\n `ProgressBar: \\`max\\` must be a finite number greater than 0 (got ${String(max)}); the bar renders 0%.`,\n );\n }\n if (!validValue) {\n warnOnce(\n 'ProgressBar:value',\n `ProgressBar: \\`value\\` must be a finite number (got ${String(value)}); the bar renders 0%.`,\n );\n }\n }, [\n hasLabel,\n hasAriaLabel,\n hasAriaLabelledBy,\n hasFieldName,\n showLabel,\n validMax,\n validValue,\n max,\n value,\n ]);\n\n const visibleLabel = Boolean(showLabel && hasLabel);\n\n /**\n * The bar's attributes. Defaults the consumer may override (C-COMPOSE) apply wherever the\n * consumer's value is `undefined` — also when the key is present, e.g. a wrapper that forwards\n * `aria-label={props['aria-label']}` — so a forwarded `undefined` never strips the role, the\n * values or the name derived from `label`. An empty `aria-label`/`aria-labelledby` is dropped\n * the same way instead of rendering a nameless attribute.\n */\n const barProps: Record<string, unknown> = {\n role: 'progressbar',\n 'aria-valuenow': isIndeterminate ? undefined : clamped,\n 'aria-valuemin': 0,\n 'aria-valuemax': validMax ? max : 100,\n 'data-color': resolvedColor,\n };\n // The consumer's id (or the control id Field passes to its first child), else its own id inside\n // a Field; the consumer's description, then the Field's validation message and hint.\n if (fieldProps.id !== undefined) barProps.id = fieldProps.id;\n if (fieldProps['aria-describedby'] !== undefined) {\n barProps['aria-describedby'] = fieldProps['aria-describedby'];\n }\n // A consumer `aria-label` or `aria-labelledby` wins over the name derived from `label`, also\n // with `showLabel` (the visible label then stays unreferenced text). The Field's label names\n // only a bar without a name of its own.\n if (!hasAriaLabel && !hasAriaLabelledBy) {\n if (visibleLabel) barProps['aria-labelledby'] = labelId;\n else if (hasLabel) barProps['aria-label'] = label;\n else if (hasFieldName) barProps['aria-labelledby'] = fieldLabelledBy;\n }\n for (const [key, propValue] of Object.entries(rest)) {\n if (propValue === undefined) continue;\n if ((key === 'aria-label' || key === 'aria-labelledby') && !isName(propValue)) continue;\n barProps[key] = propValue;\n }\n\n const bar = (\n <div\n {...barProps}\n ref={ref}\n className={cn(\n progressBarClassNames.root,\n 'h-2 overflow-hidden rounded-full bg-track',\n 'forced-colors:border',\n forcedColors.border,\n className,\n )}\n >\n <div\n className={cn(\n progressBarClassNames.bar,\n 'h-full rounded-full',\n fillColorClasses[resolvedColor],\n forcedColors.selectedLeaf,\n isIndeterminate &&\n 'w-2/5 animate-wave-indeterminate wave-rtl:animate-wave-indeterminate-rtl motion-reduce:w-full motion-reduce:translate-x-0 motion-reduce:animate-wave-pulse wave-rtl:motion-reduce:animate-wave-pulse',\n )}\n style={isIndeterminate ? undefined : { width: `${percentage}%` }}\n />\n </div>\n );\n\n if (!visibleLabel) return bar;\n\n return (\n <div className=\"flex flex-col gap-1\">\n <span id={labelId} className={cn(progressBarClassNames.label, 'text-body-1 text-foreground')}>\n {label}\n </span>\n {bar}\n </div>\n );\n};\n\nProgressBar.displayName = 'ProgressBar';\n"],"mappings":";;;;;;;;;;AAoDA,IAAMG,IAAqD;CACzD,OAAO;CACP,SAAS;CAET,SAAS;CACT,OAAO;AACT,GAGMC,IAAkE;CACtE,OAAO;CACP,SAAS;CACT,SAAS;AACX;AAGA,SAASC,EAAO,GAAiC;CAC/C,OAAO,OAAOC,KAAU,YAAYA,EAAM,KAAK,MAAM;AACvD;AA0BA,IAAaC,KAAe,EAC1B,UACA,SAAM,KACN,UACA,cACA,UACA,OACA,oBAAoBC,GAEpB,gBAAgBC,GAChB,iBAAiBC,GACjB,cACA,QACA,GAAGC,QACmB;CACtB,IAAMC,IAAUZ,EAAM,gBAAgB,GAChCa,IAAQb,EAAM,UAAU,GACxBc,IAAQC,EAAgB,GAOxBC,IAAaC,EACjB;EAAE,IAAIC,MAAOJ,IAAQD,IAAQ,KAAA;EAAY,oBAAoBL;CAAgB,GAC7E,EAAE,WAAW,GAAM,CACrB,GAEMW,IAAaL,IAASA,EAAM,oBAAoBA,EAAM,UAAU,UAAU,UAAW,QACrFM,IAAgBC,KAASjB,EAAYe,MAAe,SACpDG,IAAkBhB,MAAU,KAAA,GAC5BiB,IAAW,OAAO,SAASC,CAAG,KAAKA,IAAM,GACzCC,IAAaH,KAAmB,OAAO,SAAShB,CAAK,GAErDoB,IACJ,CAACJ,KAAmBC,KAAYE,IAAa,KAAK,IAAID,GAAK,KAAK,IAAI,GAAGlB,CAAK,CAAC,IAAI,GAC7EqB,IAAaJ,IAAYG,IAAUF,IAAO,MAAM,GAIhDI,IAAWvB,EAAOwB,CAAK,GACvBC,IAAezB,EAAOM,EAAK,aAAa,GACxCoB,IAAoB1B,EAAOM,EAAK,kBAAkB,GAClDqB,IAAkBhB,EAAW,oBAC7BiB,IAAe,CAACL,KAAY,CAACE,KAAgB,CAACC,KAAqB1B,EAAO2B,CAAe;CAG/F,EAAM,gBAAgB;EACpB,AAAKE,MACD,CAACN,KAAY,CAACE,KAAgB,CAACC,KAAqB,CAACE,KACvDE,EACE,oBACA,qIACF,GAEEC,KAAa,CAACR,KAChBO,EACE,0BACA,oEACF,GAEGZ,KACHY,EACE,mBACA,oEAAoE,OAAOX,CAAG,EAAE,uBAClF,GAEGC,KACHU,EACE,qBACA,uDAAuD,OAAO7B,CAAK,EAAE,uBACvE;CAEJ,GAAG;EACDsB;EACAE;EACAC;EACAE;EACAG;EACAb;EACAE;EACAD;EACAlB;CACF,CAAC;CAED,IAAM+B,IAAe,GAAQD,KAAaR,IASpCU,IAAoC;EACxC,MAAM;EACN,iBAAiBhB,IAAkB,KAAA,IAAYI;EAC/C,iBAAiB;EACjB,iBAAiBH,IAAWC,IAAM;EAClC,cAAcJ;CAChB;CAUA,AAPIJ,EAAW,OAAO,KAAA,MAAW,EAAS,KAAKA,EAAW,KACtDA,EAAW,wBAAwB,KAAA,MACrC,EAAS,sBAAsBA,EAAW,sBAKxC,CAACc,KAAgB,CAACC,MAChBM,IAAc,EAAS,qBAAqBzB,IACvCgB,IAAU,EAAS,gBAAgBC,IACnCI,MAAc,EAAS,qBAAqBD;CAEvD,KAAK,IAAM,CAACO,GAAKC,MAAc,OAAO,QAAQ7B,CAAI,GAChD,AAAI6B,MAAc,KAAA,MACbD,MAAQ,gBAAgBA,MAAQ,qBAAuBlC,EAAOmC,CAAS,OAC5E,EAASD,KAAOC;CAGlB,IAAMC,IACJ,kBAAC,OAAD;EACE,GAAIH;EACC;EACL,WAAWI,EACTC,EAAsB,MACtB,6CACA,wBACAC,EAAa,QACbC,CACF;EAEA,UAAA,kBAAC,OAAD;GACE,WAAWH,EACTC,EAAsB,KACtB,uBACAxC,EAAiBiB,IACjBwB,EAAa,cACbtB,KACE,sMACJ;GACA,OAAOA,IAAkB,KAAA,IAAY,EAAE,OAAO,GAAGK,EAAW,GAAG;EAChE,CAAA;CACE,CAAA;CAKP,OAFKU,IAGH,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAAC,QAAD;GAAM,IAAIzB;GAAS,WAAW8B,EAAGC,EAAsB,OAAO,6BAA6B;GACxF,UAAAd;EACG,CAAA,GACLY,CACE;MARmBA;AAU5B;AAEA,EAAY,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/classNames.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("react/jsx-runtime");var o={text:`rounded`,circular:`circular`,rectangular:`rounded`},s=`forced-colors:bg-[GrayText] forced-colors:forced-color-adjust-none`,c={rounded:`rounded`,circular:`rounded-full`,square:`rounded-none`},l=({width:e,height:i,shape:l,variant:u,className:d,style:f,ref:p,...m})=>{let h=n.resolveDeprecatedProp(`Skeleton`,l,u===void 0?void 0:o[u],`variant`,`shape`)??`rounded`;return(0,a.jsx)(`div`,{"aria-hidden":`true`,...m,ref:p,className:t.cn(r.skeletonClassNames.root,`bg-skeleton animate-wave-pulse motion-reduce:animate-none`,s,c[h],d),style:{width:e,height:i,...f}})};l.displayName=`Skeleton`;var u=({label:e=`Loading`,"aria-busy":n=!0,className:i,children:o,ref:s,...c})=>{let l=n!==!1&&n!==`false`;return(0,a.jsxs)(`div`,{...c,"aria-busy":n,ref:s,className:t.cn(r.skeletonGroupClassNames.root,i),children:[l&&(0,a.jsx)(`span`,{className:`sr-only`,children:e}),o]})};u.displayName=`SkeletonGroup`;var d=Object.assign(l,{Group:u});exports.Skeleton=d,exports.SkeletonGroup=u;
|
|
2
|
+
//# sourceMappingURL=Skeleton.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Skeleton.cjs","names":["resolveDeprecatedProp","cn","skeletonClassNames","skeletonGroupClassNames","require_runtime","require_cn","require_dev","require_classNames","react","react_jsx_runtime","variantShapes","forcedColorsFill","shapeClasses","SkeletonRoot","shapeProp","rest","shape","variant","className","style","SkeletonGroup","busy","loading","label","children","Skeleton"],"sources":["../../../src/components/feedback/Skeleton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { skeletonClassNames, skeletonGroupClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { resolveDeprecatedProp } from '../../lib/dev';\nimport type { Shape } from '../../lib/types';\n\n/** The 0.4 `variant` values (deprecated; written out in {@link SkeletonProps}, not a public name). */\ntype SkeletonVariant = NonNullable<SkeletonProps['variant']>;\n\n/** `rectangular` rendered with the default 4px radius in 0.4, so it maps to `rounded`. */\nconst variantShapes: Record<SkeletonVariant, Shape> = {\n text: 'rounded',\n circular: 'circular',\n rectangular: 'rounded',\n};\n\n/**\n * Forced colors replace the author fill with the page color, so the placeholder would vanish: it\n * is painted `GrayText` instead (a leaf element, so opting out of forced colors reaches nothing\n * else).\n */\nconst forcedColorsFill = 'forced-colors:bg-[GrayText] forced-colors:forced-color-adjust-none';\n\nconst shapeClasses: Record<Shape, string> = {\n rounded: 'rounded',\n circular: 'rounded-full',\n square: 'rounded-none',\n};\n\n/** Properties for the Skeleton component. */\nexport interface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Width of the skeleton placeholder. */\n width?: string | number;\n /** Height of the skeleton placeholder. */\n height?: string | number;\n /**\n * Geometry of the placeholder: `rounded` (4px radius), `circular` (avatars) or `square`.\n * @default 'rounded'\n */\n shape?: Shape;\n /**\n * @deprecated Use `shape`: `text` and `rectangular` → `rounded` (their 0.4 look), `circular` →\n * `circular`. Still works, warns once in development, and `shape` wins when both are given.\n */\n variant?: 'text' | 'circular' | 'rectangular';\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// The component-level JSDoc sits on the exported `Skeleton` below (it reaches index.d.ts).\nconst SkeletonRoot = ({\n width,\n height,\n shape: shapeProp,\n variant,\n className,\n style,\n ref,\n ...rest\n}: SkeletonProps) => {\n const shape =\n resolveDeprecatedProp(\n 'Skeleton',\n shapeProp,\n variant === undefined ? undefined : variantShapes[variant],\n 'variant',\n 'shape',\n ) ?? 'rounded';\n\n return (\n <div\n aria-hidden=\"true\"\n {...rest}\n ref={ref}\n className={cn(\n skeletonClassNames.root,\n 'bg-skeleton animate-wave-pulse motion-reduce:animate-none',\n forcedColorsFill,\n shapeClasses[shape],\n className,\n )}\n style={{ width, height, ...style }}\n />\n );\n};\nSkeletonRoot.displayName = 'Skeleton';\n\n/** Properties for the Skeleton.Group component. */\nexport interface SkeletonGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Visually hidden text announced in place of the decorative placeholders. Localize it.\n * @default 'Loading'\n */\n label?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Container for the Skeletons of a loading region: `aria-busy=\"true\"` plus a visually hidden\n * `label` (\"Loading\"), while the placeholders stay decorative. It uses no live-region role, so it\n * does not interrupt; announce completion separately if needed. When the content arrives, remove\n * the group or pass `aria-busy={false}`, which also drops the hidden label (no stale \"Loading\" is\n * read before the content). A forwarded `aria-busy={undefined}` keeps the busy default. Flat\n * export for React Server Components (`Skeleton.Group` in client files).\n */\nexport const SkeletonGroup = ({\n label = 'Loading',\n // Destructured with a default rather than set before `{...rest}`: a wrapper that forwards\n // `aria-busy={props['aria-busy']}` passes `undefined`, which must not strip the busy state.\n 'aria-busy': busy = true,\n className,\n children,\n ref,\n ...rest\n}: SkeletonGroupProps) => {\n const loading = busy !== false && busy !== 'false';\n return (\n <div\n {...rest}\n aria-busy={busy}\n ref={ref}\n className={cn(skeletonGroupClassNames.root, className)}\n >\n {loading && <span className=\"sr-only\">{label}</span>}\n {children}\n </div>\n );\n};\nSkeletonGroup.displayName = 'SkeletonGroup';\n\n/**\n * A decorative loading placeholder. Each Skeleton is `aria-hidden` (a consumer `aria-hidden`\n * overrides it); wrap the placeholders of a loading region in {@link SkeletonGroup}\n * (`Skeleton.Group`), which marks it busy and gives it a visually hidden \"Loading\" label.\n * The pulse animation stops for reduced motion; in forced-colors mode the placeholders are\n * painted `GrayText`. In React Server Components use the flat export `SkeletonGroup` instead of\n * `Skeleton.Group`.\n *\n * @example\n * <Skeleton.Group label=\"Loading profile\">\n * <Skeleton shape=\"circular\" width={32} height={32} />\n * <Skeleton width={160} height={12} />\n * </Skeleton.Group>\n */\nexport const Skeleton = /* @__PURE__ */ Object.assign(SkeletonRoot, { Group: SkeletonGroup });\n"],"mappings":"mPAUA,IAAMU,EAAgD,CACpD,KAAM,UACN,SAAU,WACV,YAAa,SACf,EAOMC,EAAmB,qEAEnBC,EAAsC,CAC1C,QAAS,UACT,SAAU,eACV,OAAQ,cACV,EAsBMC,GAAgB,CACpB,QACA,SACA,MAAOC,EACP,UACA,YACA,QACA,MACA,GAAGC,KACgB,CACnB,IAAMC,EACJhB,EAAAA,sBACE,WACAc,EACAG,IAAY,IAAA,GAAY,IAAA,GAAYP,EAAcO,GAClD,UACA,OACF,GAAK,UAEP,OACE,EAAAR,EAAA,IAAA,CAAC,MAAD,CACE,cAAY,OACZ,GAAIM,EACC,MACL,UAAWd,EAAAA,GACTC,EAAAA,mBAAmB,KACnB,4DACAS,EACAC,EAAaI,GACbE,CACF,EACA,MAAO,CAAE,QAAO,SAAQ,GAAGC,CAAM,CAClC,CAAA,CAEL,EACA,EAAa,YAAc,WAoB3B,IAAaC,GAAiB,CAC5B,QAAQ,UAGR,YAAaC,EAAO,GACpB,YACA,WACA,MACA,GAAGN,KACqB,CACxB,IAAMO,EAAUD,IAAS,IAASA,IAAS,QAC3C,OACE,EAAAZ,EAAA,KAAA,CAAC,MAAD,CACE,GAAIM,EACJ,YAAWM,EACN,MACL,UAAWpB,EAAAA,GAAGE,EAAAA,wBAAwB,KAAMe,CAAS,EAJvD,SAAA,CAMGI,IAAW,EAAAb,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,UAAW,SAAAc,CAAY,CAAA,EAClDC,CACE,GAET,EACA,EAAc,YAAc,gBAgB5B,IAAaC,EAA2B,OAAO,OAAOZ,EAAc,CAAE,MAAOO,CAAc,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { resolveDeprecatedProp as t } from "../../lib/dev.mjs";
|
|
4
|
+
import { skeletonClassNames as n, skeletonGroupClassNames as r } from "../../lib/classNames.mjs";
|
|
5
|
+
import "react";
|
|
6
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/feedback/Skeleton.tsx
|
|
8
|
+
var o = {
|
|
9
|
+
text: "rounded",
|
|
10
|
+
circular: "circular",
|
|
11
|
+
rectangular: "rounded"
|
|
12
|
+
}, s = "forced-colors:bg-[GrayText] forced-colors:forced-color-adjust-none", c = {
|
|
13
|
+
rounded: "rounded",
|
|
14
|
+
circular: "rounded-full",
|
|
15
|
+
square: "rounded-none"
|
|
16
|
+
}, l = ({ width: r, height: a, shape: l, variant: u, className: d, style: f, ref: p, ...m }) => {
|
|
17
|
+
let h = t("Skeleton", l, u === void 0 ? void 0 : o[u], "variant", "shape") ?? "rounded";
|
|
18
|
+
return /* @__PURE__ */ i("div", {
|
|
19
|
+
"aria-hidden": "true",
|
|
20
|
+
...m,
|
|
21
|
+
ref: p,
|
|
22
|
+
className: e(n.root, "bg-skeleton animate-wave-pulse motion-reduce:animate-none", s, c[h], d),
|
|
23
|
+
style: {
|
|
24
|
+
width: r,
|
|
25
|
+
height: a,
|
|
26
|
+
...f
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
l.displayName = "Skeleton";
|
|
31
|
+
var u = ({ label: t = "Loading", "aria-busy": n = !0, className: o, children: s, ref: c, ...l }) => {
|
|
32
|
+
let u = n !== !1 && n !== "false";
|
|
33
|
+
return /* @__PURE__ */ a("div", {
|
|
34
|
+
...l,
|
|
35
|
+
"aria-busy": n,
|
|
36
|
+
ref: c,
|
|
37
|
+
className: e(r.root, o),
|
|
38
|
+
children: [u && /* @__PURE__ */ i("span", {
|
|
39
|
+
className: "sr-only",
|
|
40
|
+
children: t
|
|
41
|
+
}), s]
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
u.displayName = "SkeletonGroup";
|
|
45
|
+
var d = /* @__PURE__ */ Object.assign(l, { Group: u });
|
|
46
|
+
//#endregion
|
|
47
|
+
export { d as Skeleton, u as SkeletonGroup };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=Skeleton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Skeleton.mjs","names":["variantShapes","forcedColorsFill","shapeClasses","SkeletonRoot","shapeProp","rest","shape","resolveDeprecatedProp","variant","cn","skeletonClassNames","className","style","SkeletonGroup","busy","loading","skeletonGroupClassNames","label","children","Skeleton"],"sources":["../../../src/components/feedback/Skeleton.tsx"],"sourcesContent":["import * as React from 'react';\nimport { skeletonClassNames, skeletonGroupClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { resolveDeprecatedProp } from '../../lib/dev';\nimport type { Shape } from '../../lib/types';\n\n/** The 0.4 `variant` values (deprecated; written out in {@link SkeletonProps}, not a public name). */\ntype SkeletonVariant = NonNullable<SkeletonProps['variant']>;\n\n/** `rectangular` rendered with the default 4px radius in 0.4, so it maps to `rounded`. */\nconst variantShapes: Record<SkeletonVariant, Shape> = {\n text: 'rounded',\n circular: 'circular',\n rectangular: 'rounded',\n};\n\n/**\n * Forced colors replace the author fill with the page color, so the placeholder would vanish: it\n * is painted `GrayText` instead (a leaf element, so opting out of forced colors reaches nothing\n * else).\n */\nconst forcedColorsFill = 'forced-colors:bg-[GrayText] forced-colors:forced-color-adjust-none';\n\nconst shapeClasses: Record<Shape, string> = {\n rounded: 'rounded',\n circular: 'rounded-full',\n square: 'rounded-none',\n};\n\n/** Properties for the Skeleton component. */\nexport interface SkeletonProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Width of the skeleton placeholder. */\n width?: string | number;\n /** Height of the skeleton placeholder. */\n height?: string | number;\n /**\n * Geometry of the placeholder: `rounded` (4px radius), `circular` (avatars) or `square`.\n * @default 'rounded'\n */\n shape?: Shape;\n /**\n * @deprecated Use `shape`: `text` and `rectangular` → `rounded` (their 0.4 look), `circular` →\n * `circular`. Still works, warns once in development, and `shape` wins when both are given.\n */\n variant?: 'text' | 'circular' | 'rectangular';\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// The component-level JSDoc sits on the exported `Skeleton` below (it reaches index.d.ts).\nconst SkeletonRoot = ({\n width,\n height,\n shape: shapeProp,\n variant,\n className,\n style,\n ref,\n ...rest\n}: SkeletonProps) => {\n const shape =\n resolveDeprecatedProp(\n 'Skeleton',\n shapeProp,\n variant === undefined ? undefined : variantShapes[variant],\n 'variant',\n 'shape',\n ) ?? 'rounded';\n\n return (\n <div\n aria-hidden=\"true\"\n {...rest}\n ref={ref}\n className={cn(\n skeletonClassNames.root,\n 'bg-skeleton animate-wave-pulse motion-reduce:animate-none',\n forcedColorsFill,\n shapeClasses[shape],\n className,\n )}\n style={{ width, height, ...style }}\n />\n );\n};\nSkeletonRoot.displayName = 'Skeleton';\n\n/** Properties for the Skeleton.Group component. */\nexport interface SkeletonGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Visually hidden text announced in place of the decorative placeholders. Localize it.\n * @default 'Loading'\n */\n label?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Container for the Skeletons of a loading region: `aria-busy=\"true\"` plus a visually hidden\n * `label` (\"Loading\"), while the placeholders stay decorative. It uses no live-region role, so it\n * does not interrupt; announce completion separately if needed. When the content arrives, remove\n * the group or pass `aria-busy={false}`, which also drops the hidden label (no stale \"Loading\" is\n * read before the content). A forwarded `aria-busy={undefined}` keeps the busy default. Flat\n * export for React Server Components (`Skeleton.Group` in client files).\n */\nexport const SkeletonGroup = ({\n label = 'Loading',\n // Destructured with a default rather than set before `{...rest}`: a wrapper that forwards\n // `aria-busy={props['aria-busy']}` passes `undefined`, which must not strip the busy state.\n 'aria-busy': busy = true,\n className,\n children,\n ref,\n ...rest\n}: SkeletonGroupProps) => {\n const loading = busy !== false && busy !== 'false';\n return (\n <div\n {...rest}\n aria-busy={busy}\n ref={ref}\n className={cn(skeletonGroupClassNames.root, className)}\n >\n {loading && <span className=\"sr-only\">{label}</span>}\n {children}\n </div>\n );\n};\nSkeletonGroup.displayName = 'SkeletonGroup';\n\n/**\n * A decorative loading placeholder. Each Skeleton is `aria-hidden` (a consumer `aria-hidden`\n * overrides it); wrap the placeholders of a loading region in {@link SkeletonGroup}\n * (`Skeleton.Group`), which marks it busy and gives it a visually hidden \"Loading\" label.\n * The pulse animation stops for reduced motion; in forced-colors mode the placeholders are\n * painted `GrayText`. In React Server Components use the flat export `SkeletonGroup` instead of\n * `Skeleton.Group`.\n *\n * @example\n * <Skeleton.Group label=\"Loading profile\">\n * <Skeleton shape=\"circular\" width={32} height={32} />\n * <Skeleton width={160} height={12} />\n * </Skeleton.Group>\n */\nexport const Skeleton = /* @__PURE__ */ Object.assign(SkeletonRoot, { Group: SkeletonGroup });\n"],"mappings":";;;;;;;AAUA,IAAMA,IAAgD;CACpD,MAAM;CACN,UAAU;CACV,aAAa;AACf,GAOMC,IAAmB,sEAEnBC,IAAsC;CAC1C,SAAS;CACT,UAAU;CACV,QAAQ;AACV,GAsBMC,KAAgB,EACpB,UACA,WACA,OAAOC,GACP,YACA,cACA,UACA,QACA,GAAGC,QACgB;CACnB,IAAMC,IACJC,EACE,YACAH,GACAI,MAAY,KAAA,IAAY,KAAA,IAAYR,EAAcQ,IAClD,WACA,OACF,KAAK;CAEP,OACE,kBAAC,OAAD;EACE,eAAY;EACZ,GAAIH;EACC;EACL,WAAWI,EACTC,EAAmB,MACnB,6DACAT,GACAC,EAAaI,IACbK,CACF;EACA,OAAO;GAAE;GAAO;GAAQ,GAAGC;EAAM;CAClC,CAAA;AAEL;AACA,EAAa,cAAc;AAoB3B,IAAaC,KAAiB,EAC5B,WAAQ,WAGR,aAAaC,IAAO,IACpB,cACA,aACA,QACA,GAAGT,QACqB;CACxB,IAAMU,IAAUD,MAAS,MAASA,MAAS;CAC3C,OACE,kBAAC,OAAD;EACE,GAAIT;EACJ,aAAWS;EACN;EACL,WAAWL,EAAGO,EAAwB,MAAML,CAAS;EAJvD,UAAA,CAMGI,KAAW,kBAAC,QAAD;GAAM,WAAU;GAAW,UAAAE;EAAY,CAAA,GAClDC,CACE;;AAET;AACA,EAAc,cAAc;AAgB5B,IAAaC,IAA2B,uBAAO,OAAOhB,GAAc,EAAE,OAAOU,EAAc,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/classNames.cjs"),r=require("../../lib/styles.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("react/jsx-runtime");function o(e){return typeof e==`string`&&e.trim()!==``}var s={"extra-small":`w-3 h-3`,small:`w-4 h-4`,medium:`w-6 h-6`,large:`w-9 h-9`,"extra-large":`w-12 h-12`},c={primary:{ring:`border-track border-t-primary`,label:`text-muted-foreground`},inverted:{ring:`border-current/30 border-t-current`,label:`text-current`}},l=({size:e=`medium`,label:l=`Loading`,labelVisible:u,appearance:d=`primary`,delay:f=0,className:p,role:m=`status`,ref:h,...g})=>{let _=Number.isFinite(f)&&f>0?f:0,[v,y]=i.useState(_===0),[b,x]=i.useState(!1);i.useEffect(()=>{if(v)return;let e=setTimeout(()=>y(!0),_);return()=>clearTimeout(e)},[v,_]),i.useEffect(()=>{if(!v)return;let e=requestAnimationFrame(()=>x(!0));return()=>cancelAnimationFrame(e)},[v]);let S=m===`progressbar`&&!o(g[`aria-label`])&&!o(g[`aria-labelledby`]),C=Object.hasOwn(c,d??``)?d:`primary`,w=c[C];return(0,a.jsxs)(`span`,{"data-appearance":C,"data-state":v?`shown`:`delayed`,...g,role:m,"aria-label":S?l:g[`aria-label`],ref:h,className:t.cn(n.spinnerClassNames.root,`inline-flex items-center gap-2`,p),children:[v?(0,a.jsx)(`span`,{"aria-hidden":`true`,"data-wave-spinner-ring":``,className:t.cn(n.spinnerClassNames.spinner,`rounded-full border-2 animate-wave-spin motion-reduce:animate-wave-spin-slow`,w.ring,r.forcedColors.ringArc,s[e])}):null,(0,a.jsx)(`span`,{"data-wave-spinner-label":``,className:t.cn(n.spinnerClassNames.label,u?t.cn(`text-body-1`,w.label):`sr-only`),children:b?l:null})]})};l.displayName=`Spinner`,exports.Spinner=l;
|
|
2
|
+
//# sourceMappingURL=Spinner.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spinner.cjs","names":["React","cn","spinnerClassNames","forcedColors","require_runtime","require_cn","require_classNames","require_styles","react","react_jsx_runtime","isName","value","sizeClasses","appearanceClasses","Spinner","rest","wait","delay","shown","setShown","announced","setAnnounced","handle","frame","nameFromLabel","role","resolvedAppearance","appearance","colors","label","className","size","labelVisible"],"sources":["../../../src/components/feedback/Spinner.tsx"],"sourcesContent":["import * as React from 'react';\nimport { spinnerClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { forcedColors } from '../../lib/styles';\nimport type { Size } from '../../lib/types';\n\n/** Color treatment of a {@link Spinner}. */\nexport type SpinnerAppearance = 'primary' | 'inverted';\n\n/** Properties for the Spinner component. */\nexport interface SpinnerProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Size of the spinner.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Text announced by the spinner's status region (and shown with `labelVisible`). Localize it.\n * @default 'Loading'\n */\n label?: string;\n /** Whether the label text is visually displayed alongside the spinner. */\n labelVisible?: boolean;\n /**\n * `primary`: a primary arc on the track color. `inverted`: drawn in the current text color (a\n * 30% track), for brand or inverted surfaces such as a primary Button.\n * @default 'primary'\n */\n appearance?: SpinnerAppearance;\n /**\n * Milliseconds to wait before the ring and the label appear, so a fast load does not flash the\n * spinner. The status region is mounted (empty) at once and announces the label once shown.\n * A non-finite or negative value means 0.\n * @default 0\n */\n delay?: number;\n /**\n * Role of the root; a forwarded `undefined` keeps the default live region. Use `none` inside a\n * region that already announces the busy state, or `progressbar`, which `label` names\n * (`aria-label`) unless you pass `aria-label` or `aria-labelledby` (a progress bar is not named by\n * its content).\n * @default 'status'\n */\n role?: React.AriaRole;\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** Whether a name prop (`aria-label`, `aria-labelledby`) holds more than whitespace. */\nfunction isName(value: unknown): value is string {\n return typeof value === 'string' && value.trim() !== '';\n}\n\nconst sizeClasses: Record<Size, string> = {\n 'extra-small': 'w-3 h-3',\n small: 'w-4 h-4',\n medium: 'w-6 h-6',\n large: 'w-9 h-9',\n 'extra-large': 'w-12 h-12',\n};\n\n/** Ring (track, then arc) and visible-label colors of each appearance. */\nconst appearanceClasses: Record<SpinnerAppearance, { ring: string; label: string }> = {\n primary: { ring: 'border-track border-t-primary', label: 'text-muted-foreground' },\n // The current text color matches any surface the spinner sits on (on-brand text in a primary\n // Button, the inverted foreground), so no token is needed.\n inverted: { ring: 'border-current/30 border-t-current', label: 'text-current' },\n};\n\n/**\n * An indeterminate loading indicator.\n *\n * - The root is a `role=\"status\"` live region (override `role`, e.g. `role=\"none\"` inside a region\n * that already announces the busy state, or `role=\"progressbar\"`, which `label` names unless you\n * pass `aria-label` or `aria-labelledby`).\n * - The region mounts **empty** and receives its `label` (default \"Loading\") one animation frame\n * after the spinner is shown, so screen readers announce it (a live region that mounts with its\n * content is often not announced). With `labelVisible` the label also shows next to the ring\n * from that frame on.\n * - `delay` holds back the ring and the label for that many milliseconds (the region mounts at\n * once), so a fast load does not flash the spinner. The root's `data-state` is `delayed`, then\n * `shown`.\n * - `appearance=\"inverted\"` draws the spinner in the current text color, for a primary Button or\n * another brand or inverted surface. The root carries `data-appearance`.\n * - The ring is decorative (`aria-hidden`) and spins slower for reduced motion. In forced-colors\n * mode its arc is drawn in `Highlight` on a `Canvas` track, so the rotation stays perceivable.\n *\n * @example\n * <Spinner label=\"Loading results\" delay={300} />\n *\n * @example\n * // In a primary Button's (decorative) icon slot; the Button's text names the busy state.\n * <Button appearance=\"primary\" icon={<Spinner appearance=\"inverted\" size=\"extra-small\" />}>\n * Saving\n * </Button>\n */\nexport const Spinner = ({\n size = 'medium',\n label = 'Loading',\n labelVisible,\n appearance = 'primary',\n delay = 0,\n className,\n // Destructured with a default rather than set before `{...rest}`: a wrapper that forwards\n // `role={props.role}` passes `undefined`, which must not strip the live region.\n role = 'status',\n ref,\n ...rest\n}: SpinnerProps) => {\n const wait = Number.isFinite(delay) && delay > 0 ? delay : 0;\n const [shown, setShown] = React.useState(wait === 0);\n const [announced, setAnnounced] = React.useState(false);\n\n // C-HOOKS deferred updates: each state is set in its callback, never in the effect body. Once\n // shown, the spinner stays shown; a delay that changes while it waits starts the wait again.\n React.useEffect(() => {\n if (shown) return;\n const handle = setTimeout(() => setShown(true), wait);\n return () => clearTimeout(handle);\n }, [shown, wait]);\n\n React.useEffect(() => {\n if (!shown) return;\n const frame = requestAnimationFrame(() => setAnnounced(true));\n return () => cancelAnimationFrame(frame);\n }, [shown]);\n\n // A progressbar takes its name from the author, never from its content (the label text): name it\n // with `label` unless the consumer does. Also applies to a forwarded `aria-label={undefined}`.\n const nameFromLabel =\n role === 'progressbar' && !isName(rest['aria-label']) && !isName(rest['aria-labelledby']);\n // An appearance outside the union (from untyped code) renders as primary instead of throwing.\n const resolvedAppearance: SpinnerAppearance = Object.hasOwn(appearanceClasses, appearance ?? '')\n ? appearance\n : 'primary';\n const colors = appearanceClasses[resolvedAppearance];\n\n return (\n <span\n data-appearance={resolvedAppearance}\n data-state={shown ? 'shown' : 'delayed'}\n {...rest}\n role={role}\n aria-label={nameFromLabel ? label : rest['aria-label']}\n ref={ref}\n className={cn(spinnerClassNames.root, 'inline-flex items-center gap-2', className)}\n >\n {shown ? (\n <span\n aria-hidden=\"true\"\n data-wave-spinner-ring=\"\"\n className={cn(\n spinnerClassNames.spinner,\n 'rounded-full border-2 animate-wave-spin motion-reduce:animate-wave-spin-slow',\n colors.ring,\n forcedColors.ringArc,\n sizeClasses[size],\n )}\n />\n ) : null}\n <span\n data-wave-spinner-label=\"\"\n className={cn(\n spinnerClassNames.label,\n labelVisible ? cn('text-body-1', colors.label) : 'sr-only',\n )}\n >\n {announced ? label : null}\n </span>\n </span>\n );\n};\n\nSpinner.displayName = 'Spinner';\n"],"mappings":"sPA+CA,SAASU,EAAO,EAAiC,CAC/C,OAAO,OAAOC,GAAU,UAAYA,EAAM,KAAK,IAAM,EACvD,CAEA,IAAMC,EAAoC,CACxC,cAAe,UACf,MAAO,UACP,OAAQ,UACR,MAAO,UACP,cAAe,WACjB,EAGMC,EAAgF,CACpF,QAAS,CAAE,KAAM,gCAAiC,MAAO,uBAAwB,EAGjF,SAAU,CAAE,KAAM,qCAAsC,MAAO,cAAe,CAChF,EA6BaC,GAAW,CACtB,OAAO,SACP,QAAQ,UACR,eACA,aAAa,UACb,QAAQ,EACR,YAGA,OAAO,SACP,MACA,GAAGC,KACe,CAClB,IAAMC,EAAO,OAAO,SAASC,CAAK,GAAKA,EAAQ,EAAIA,EAAQ,EACrD,CAACC,EAAOC,GAAYnB,EAAM,SAASgB,IAAS,CAAC,EAC7C,CAACI,EAAWC,GAAgBrB,EAAM,SAAS,EAAK,EAItDQ,EAAM,cAAgB,CACpB,GAAIU,EAAO,OACX,IAAMI,EAAS,eAAiBH,EAAS,EAAI,EAAGH,CAAI,EACpD,UAAa,aAAaM,CAAM,CAClC,EAAG,CAACJ,EAAOF,CAAI,CAAC,EAEhBR,EAAM,cAAgB,CACpB,GAAI,CAACU,EAAO,OACZ,IAAMK,EAAQ,0BAA4BF,EAAa,EAAI,CAAC,EAC5D,UAAa,qBAAqBE,CAAK,CACzC,EAAG,CAACL,CAAK,CAAC,EAIV,IAAMM,EACJC,IAAS,eAAiB,CAACf,EAAOK,EAAK,aAAa,GAAK,CAACL,EAAOK,EAAK,kBAAkB,EAEpFW,EAAwC,OAAO,OAAOb,EAAmBc,GAAc,EAAE,EAC3FA,EACA,UACEC,EAASf,EAAkBa,GAEjC,OACE,EAAAjB,EAAA,KAAA,CAAC,OAAD,CACE,kBAAiBiB,EACjB,aAAYR,EAAQ,QAAU,UAC9B,GAAIH,EACE,OACN,aAAYS,EAAgBK,EAAQd,EAAK,cACpC,MACL,UAAWd,EAAAA,GAAGC,EAAAA,kBAAkB,KAAM,iCAAkC4B,CAAS,EAPnF,SAAA,CASGZ,GACC,EAAAT,EAAA,IAAA,CAAC,OAAD,CACE,cAAY,OACZ,yBAAuB,GACvB,UAAWR,EAAAA,GACTC,EAAAA,kBAAkB,QAClB,+EACA0B,EAAO,KACPzB,EAAAA,aAAa,QACbS,EAAYmB,EACd,CACD,CAAA,EACC,MACJ,EAAAtB,EAAA,IAAA,CAAC,OAAD,CACE,0BAAwB,GACxB,UAAWR,EAAAA,GACTC,EAAAA,kBAAkB,MAClB8B,EAAe/B,EAAAA,GAAG,cAAe2B,EAAO,KAAK,EAAI,SACnD,EAEC,SAAAR,EAAYS,EAAQ,IACjB,CAAA,CACF,GAEV,EAEA,EAAQ,YAAc"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { spinnerClassNames as t } from "../../lib/classNames.mjs";
|
|
4
|
+
import { forcedColors as n } from "../../lib/styles.mjs";
|
|
5
|
+
import * as r from "react";
|
|
6
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/feedback/Spinner.tsx
|
|
8
|
+
function o(e) {
|
|
9
|
+
return typeof e == "string" && e.trim() !== "";
|
|
10
|
+
}
|
|
11
|
+
var s = {
|
|
12
|
+
"extra-small": "w-3 h-3",
|
|
13
|
+
small: "w-4 h-4",
|
|
14
|
+
medium: "w-6 h-6",
|
|
15
|
+
large: "w-9 h-9",
|
|
16
|
+
"extra-large": "w-12 h-12"
|
|
17
|
+
}, c = {
|
|
18
|
+
primary: {
|
|
19
|
+
ring: "border-track border-t-primary",
|
|
20
|
+
label: "text-muted-foreground"
|
|
21
|
+
},
|
|
22
|
+
inverted: {
|
|
23
|
+
ring: "border-current/30 border-t-current",
|
|
24
|
+
label: "text-current"
|
|
25
|
+
}
|
|
26
|
+
}, l = ({ size: l = "medium", label: u = "Loading", labelVisible: d, appearance: f = "primary", delay: p = 0, className: m, role: h = "status", ref: g, ..._ }) => {
|
|
27
|
+
let v = Number.isFinite(p) && p > 0 ? p : 0, [y, b] = r.useState(v === 0), [x, S] = r.useState(!1);
|
|
28
|
+
r.useEffect(() => {
|
|
29
|
+
if (y) return;
|
|
30
|
+
let e = setTimeout(() => b(!0), v);
|
|
31
|
+
return () => clearTimeout(e);
|
|
32
|
+
}, [y, v]), r.useEffect(() => {
|
|
33
|
+
if (!y) return;
|
|
34
|
+
let e = requestAnimationFrame(() => S(!0));
|
|
35
|
+
return () => cancelAnimationFrame(e);
|
|
36
|
+
}, [y]);
|
|
37
|
+
let C = h === "progressbar" && !o(_["aria-label"]) && !o(_["aria-labelledby"]), w = Object.hasOwn(c, f ?? "") ? f : "primary", T = c[w];
|
|
38
|
+
return /* @__PURE__ */ a("span", {
|
|
39
|
+
"data-appearance": w,
|
|
40
|
+
"data-state": y ? "shown" : "delayed",
|
|
41
|
+
..._,
|
|
42
|
+
role: h,
|
|
43
|
+
"aria-label": C ? u : _["aria-label"],
|
|
44
|
+
ref: g,
|
|
45
|
+
className: e(t.root, "inline-flex items-center gap-2", m),
|
|
46
|
+
children: [y ? /* @__PURE__ */ i("span", {
|
|
47
|
+
"aria-hidden": "true",
|
|
48
|
+
"data-wave-spinner-ring": "",
|
|
49
|
+
className: e(t.spinner, "rounded-full border-2 animate-wave-spin motion-reduce:animate-wave-spin-slow", T.ring, n.ringArc, s[l])
|
|
50
|
+
}) : null, /* @__PURE__ */ i("span", {
|
|
51
|
+
"data-wave-spinner-label": "",
|
|
52
|
+
className: e(t.label, d ? e("text-body-1", T.label) : "sr-only"),
|
|
53
|
+
children: x ? u : null
|
|
54
|
+
})]
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
l.displayName = "Spinner";
|
|
58
|
+
//#endregion
|
|
59
|
+
export { l as Spinner };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=Spinner.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spinner.mjs","names":["React","isName","value","sizeClasses","appearanceClasses","Spinner","rest","wait","delay","shown","setShown","announced","setAnnounced","handle","frame","nameFromLabel","role","resolvedAppearance","appearance","colors","label","cn","spinnerClassNames","className","forcedColors","size","labelVisible"],"sources":["../../../src/components/feedback/Spinner.tsx"],"sourcesContent":["import * as React from 'react';\nimport { spinnerClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { forcedColors } from '../../lib/styles';\nimport type { Size } from '../../lib/types';\n\n/** Color treatment of a {@link Spinner}. */\nexport type SpinnerAppearance = 'primary' | 'inverted';\n\n/** Properties for the Spinner component. */\nexport interface SpinnerProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Size of the spinner.\n * @default 'medium'\n */\n size?: Size;\n /**\n * Text announced by the spinner's status region (and shown with `labelVisible`). Localize it.\n * @default 'Loading'\n */\n label?: string;\n /** Whether the label text is visually displayed alongside the spinner. */\n labelVisible?: boolean;\n /**\n * `primary`: a primary arc on the track color. `inverted`: drawn in the current text color (a\n * 30% track), for brand or inverted surfaces such as a primary Button.\n * @default 'primary'\n */\n appearance?: SpinnerAppearance;\n /**\n * Milliseconds to wait before the ring and the label appear, so a fast load does not flash the\n * spinner. The status region is mounted (empty) at once and announces the label once shown.\n * A non-finite or negative value means 0.\n * @default 0\n */\n delay?: number;\n /**\n * Role of the root; a forwarded `undefined` keeps the default live region. Use `none` inside a\n * region that already announces the busy state, or `progressbar`, which `label` names\n * (`aria-label`) unless you pass `aria-label` or `aria-labelledby` (a progress bar is not named by\n * its content).\n * @default 'status'\n */\n role?: React.AriaRole;\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** Whether a name prop (`aria-label`, `aria-labelledby`) holds more than whitespace. */\nfunction isName(value: unknown): value is string {\n return typeof value === 'string' && value.trim() !== '';\n}\n\nconst sizeClasses: Record<Size, string> = {\n 'extra-small': 'w-3 h-3',\n small: 'w-4 h-4',\n medium: 'w-6 h-6',\n large: 'w-9 h-9',\n 'extra-large': 'w-12 h-12',\n};\n\n/** Ring (track, then arc) and visible-label colors of each appearance. */\nconst appearanceClasses: Record<SpinnerAppearance, { ring: string; label: string }> = {\n primary: { ring: 'border-track border-t-primary', label: 'text-muted-foreground' },\n // The current text color matches any surface the spinner sits on (on-brand text in a primary\n // Button, the inverted foreground), so no token is needed.\n inverted: { ring: 'border-current/30 border-t-current', label: 'text-current' },\n};\n\n/**\n * An indeterminate loading indicator.\n *\n * - The root is a `role=\"status\"` live region (override `role`, e.g. `role=\"none\"` inside a region\n * that already announces the busy state, or `role=\"progressbar\"`, which `label` names unless you\n * pass `aria-label` or `aria-labelledby`).\n * - The region mounts **empty** and receives its `label` (default \"Loading\") one animation frame\n * after the spinner is shown, so screen readers announce it (a live region that mounts with its\n * content is often not announced). With `labelVisible` the label also shows next to the ring\n * from that frame on.\n * - `delay` holds back the ring and the label for that many milliseconds (the region mounts at\n * once), so a fast load does not flash the spinner. The root's `data-state` is `delayed`, then\n * `shown`.\n * - `appearance=\"inverted\"` draws the spinner in the current text color, for a primary Button or\n * another brand or inverted surface. The root carries `data-appearance`.\n * - The ring is decorative (`aria-hidden`) and spins slower for reduced motion. In forced-colors\n * mode its arc is drawn in `Highlight` on a `Canvas` track, so the rotation stays perceivable.\n *\n * @example\n * <Spinner label=\"Loading results\" delay={300} />\n *\n * @example\n * // In a primary Button's (decorative) icon slot; the Button's text names the busy state.\n * <Button appearance=\"primary\" icon={<Spinner appearance=\"inverted\" size=\"extra-small\" />}>\n * Saving\n * </Button>\n */\nexport const Spinner = ({\n size = 'medium',\n label = 'Loading',\n labelVisible,\n appearance = 'primary',\n delay = 0,\n className,\n // Destructured with a default rather than set before `{...rest}`: a wrapper that forwards\n // `role={props.role}` passes `undefined`, which must not strip the live region.\n role = 'status',\n ref,\n ...rest\n}: SpinnerProps) => {\n const wait = Number.isFinite(delay) && delay > 0 ? delay : 0;\n const [shown, setShown] = React.useState(wait === 0);\n const [announced, setAnnounced] = React.useState(false);\n\n // C-HOOKS deferred updates: each state is set in its callback, never in the effect body. Once\n // shown, the spinner stays shown; a delay that changes while it waits starts the wait again.\n React.useEffect(() => {\n if (shown) return;\n const handle = setTimeout(() => setShown(true), wait);\n return () => clearTimeout(handle);\n }, [shown, wait]);\n\n React.useEffect(() => {\n if (!shown) return;\n const frame = requestAnimationFrame(() => setAnnounced(true));\n return () => cancelAnimationFrame(frame);\n }, [shown]);\n\n // A progressbar takes its name from the author, never from its content (the label text): name it\n // with `label` unless the consumer does. Also applies to a forwarded `aria-label={undefined}`.\n const nameFromLabel =\n role === 'progressbar' && !isName(rest['aria-label']) && !isName(rest['aria-labelledby']);\n // An appearance outside the union (from untyped code) renders as primary instead of throwing.\n const resolvedAppearance: SpinnerAppearance = Object.hasOwn(appearanceClasses, appearance ?? '')\n ? appearance\n : 'primary';\n const colors = appearanceClasses[resolvedAppearance];\n\n return (\n <span\n data-appearance={resolvedAppearance}\n data-state={shown ? 'shown' : 'delayed'}\n {...rest}\n role={role}\n aria-label={nameFromLabel ? label : rest['aria-label']}\n ref={ref}\n className={cn(spinnerClassNames.root, 'inline-flex items-center gap-2', className)}\n >\n {shown ? (\n <span\n aria-hidden=\"true\"\n data-wave-spinner-ring=\"\"\n className={cn(\n spinnerClassNames.spinner,\n 'rounded-full border-2 animate-wave-spin motion-reduce:animate-wave-spin-slow',\n colors.ring,\n forcedColors.ringArc,\n sizeClasses[size],\n )}\n />\n ) : null}\n <span\n data-wave-spinner-label=\"\"\n className={cn(\n spinnerClassNames.label,\n labelVisible ? cn('text-body-1', colors.label) : 'sr-only',\n )}\n >\n {announced ? label : null}\n </span>\n </span>\n );\n};\n\nSpinner.displayName = 'Spinner';\n"],"mappings":";;;;;;;AA+CA,SAASC,EAAO,GAAiC;CAC/C,OAAO,OAAOC,KAAU,YAAYA,EAAM,KAAK,MAAM;AACvD;AAEA,IAAMC,IAAoC;CACxC,eAAe;CACf,OAAO;CACP,QAAQ;CACR,OAAO;CACP,eAAe;AACjB,GAGMC,IAAgF;CACpF,SAAS;EAAE,MAAM;EAAiC,OAAO;CAAwB;CAGjF,UAAU;EAAE,MAAM;EAAsC,OAAO;CAAe;AAChF,GA6BaC,KAAW,EACtB,UAAO,UACP,WAAQ,WACR,iBACA,gBAAa,WACb,WAAQ,GACR,cAGA,UAAO,UACP,QACA,GAAGC,QACe;CAClB,IAAMC,IAAO,OAAO,SAASC,CAAK,KAAKA,IAAQ,IAAIA,IAAQ,GACrD,CAACC,GAAOC,KAAYV,EAAM,SAASO,MAAS,CAAC,GAC7C,CAACI,GAAWC,KAAgBZ,EAAM,SAAS,EAAK;CAUtD,AANAA,EAAM,gBAAgB;EACpB,IAAIS,GAAO;EACX,IAAMI,IAAS,iBAAiBH,EAAS,EAAI,GAAGH,CAAI;EACpD,aAAa,aAAaM,CAAM;CAClC,GAAG,CAACJ,GAAOF,CAAI,CAAC,GAEhBP,EAAM,gBAAgB;EACpB,IAAI,CAACS,GAAO;EACZ,IAAMK,IAAQ,4BAA4BF,EAAa,EAAI,CAAC;EAC5D,aAAa,qBAAqBE,CAAK;CACzC,GAAG,CAACL,CAAK,CAAC;CAIV,IAAMM,IACJC,MAAS,iBAAiB,CAACf,EAAOK,EAAK,aAAa,KAAK,CAACL,EAAOK,EAAK,kBAAkB,GAEpFW,IAAwC,OAAO,OAAOb,GAAmBc,KAAc,EAAE,IAC3FA,IACA,WACEC,IAASf,EAAkBa;CAEjC,OACE,kBAAC,QAAD;EACE,mBAAiBA;EACjB,cAAYR,IAAQ,UAAU;EAC9B,GAAIH;EACE;EACN,cAAYS,IAAgBK,IAAQd,EAAK;EACpC;EACL,WAAWe,EAAGC,EAAkB,MAAM,kCAAkCC,CAAS;EAPnF,UAAA,CASGd,IACC,kBAAC,QAAD;GACE,eAAY;GACZ,0BAAuB;GACvB,WAAWY,EACTC,EAAkB,SAClB,gFACAH,EAAO,MACPK,EAAa,SACbrB,EAAYsB,EACd;EACD,CAAA,IACC,MACJ,kBAAC,QAAD;GACE,2BAAwB;GACxB,WAAWJ,EACTC,EAAkB,OAClBI,IAAeL,EAAG,eAAeF,EAAO,KAAK,IAAI,SACnD;GAEC,UAAAR,IAAYS,IAAQ;EACjB,CAAA,CACF;;AAEV;AAEA,EAAQ,cAAc"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("./Toast.parts.cjs"),t=require("./Toast.root.cjs"),n=require("./Toaster.cjs");var r=Object.assign(t.ToastRoot,{Title:e.ToastTitle,Body:e.ToastBody,Footer:e.ToastFooter,Close:e.ToastClose});exports.Toast=r,exports.ToastBody=e.ToastBody,exports.ToastClose=e.ToastClose,exports.ToastFooter=e.ToastFooter,exports.ToastTitle=e.ToastTitle,exports.Toaster=n.Toaster,exports.useToastController=n.useToastController;
|
|
2
|
+
//# sourceMappingURL=Toast.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.cjs","names":["ToastRoot","ToastTitle","ToastBody","ToastFooter","ToastClose","require_Toast_parts","require_Toast_root","require_Toaster","Toast"],"sources":["../../../src/components/feedback/Toast.tsx"],"sourcesContent":["import { ToastBody, ToastClose, ToastFooter, ToastTitle } from './Toast.parts';\nimport { ToastRoot } from './Toast.root';\n\nexport type { ToastProps } from './Toast.root';\nexport type {\n ToastTitleProps,\n ToastBodyProps,\n ToastFooterProps,\n ToastCloseProps,\n ToastCloseRenderProps,\n} from './Toast.parts';\nexport { Toaster, useToastController } from './Toaster';\nexport type {\n ToasterProps,\n ToastOptions,\n ToastController,\n ToastPosition,\n ToastDispatchOptions,\n ToasterShortcuts,\n} from './Toaster';\n\n/**\n * A notification: status icon, visually hidden severity text, title, body, footer and a Dismiss\n * button. Its parts are direct children: `Toast.Title` (the title row, with an optional\n * `action`), `Toast.Body` (with an optional `subtitle`) and `Toast.Footer` (a row of actions); a\n * `Toast.Close` anywhere inside makes its child dismiss the toast. The `title` prop and plain\n * children are the 0.5 form and render as a Title and a Body.\n *\n * Dispatch it with `useToastController().dispatchToast(<Toast>…</Toast>)`, or render it yourself.\n *\n * - **In a Toaster**: not a live region itself; the Toaster announces it once per dispatch through\n * its permanent live regions (its severity text, then its title, body and the labels of its\n * actions, never the Dismiss button, or, after the severity text, the dispatch's\n * `announcement`), politely or, for `error`, assertively, and names its container by the\n * severity text and title. Every Toast there shows the Dismiss button.\n * - **On its own** (your own container, an inline notice): a live region, as in 0.4 —\n * `role=\"status\"` with `aria-live=\"polite\"`, or `role=\"alert\"` with `aria-live=\"assertive\"` for\n * `error` (override with `role`/`aria-live`). A live region that is added together with its\n * text is not announced by every screen reader, so render the Toast in advance and change its\n * content, or dispatch it through a Toaster.\n *\n * Sub-components are also exported under flat names (`ToastTitle`, `ToastBody`, `ToastFooter`,\n * `ToastClose`): React Server Components import those, because dotted access (`Toast.Title`)\n * needs a client file.\n */\nexport const Toast = /* @__PURE__ */ Object.assign(ToastRoot, {\n Title: ToastTitle,\n Body: ToastBody,\n Footer: ToastFooter,\n Close: ToastClose,\n});\n\nexport { ToastTitle, ToastBody, ToastFooter, ToastClose };\n"],"mappings":"2GA6CA,IAAaQ,EAAwB,OAAO,OAAOR,EAAAA,UAAW,CAC5D,MAAOC,EAAAA,WACP,KAAMC,EAAAA,UACN,OAAQC,EAAAA,YACR,MAAOC,EAAAA,UACT,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/dev.cjs");let n=require("react");n=e.__toESM(n,1);var r=n.createContext(null);r.displayName=`ToasterContext`;var i=n.createContext(null);i.displayName=`ToastContext`;var a=n.createContext(!1);a.displayName=`ToastUnscannedContext`;var o=()=>{},s={titleId:void 0,dismiss:void 0,registerPart:()=>o,registerToast:null};function c(e){return n.useContext(i)||(t.reportMissingContext(e,`<Toast>`),s)}exports.INERT_TOAST_CONTEXT=s,exports.ToastContext=i,exports.ToastUnscannedContext=a,exports.ToasterContext=r,exports.useToastContext=c;
|
|
2
|
+
//# sourceMappingURL=Toast.context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.context.cjs","names":["React","require_runtime","require_dev","react","ToasterContext","ToastContext","ToastUnscannedContext","unregisterNothing","INERT_TOAST_CONTEXT","useToastContext","componentName"],"sources":["../../../src/components/feedback/Toast.context.ts"],"sourcesContent":["import * as React from 'react';\nimport { reportMissingContext } from '../../lib/dev';\nimport type { Status } from '../../lib/types';\nimport type { ToastController } from './Toaster';\n\n/** The controller of the enclosing Toaster (`useToastController`); `null` outside one. */\nexport const ToasterContext = React.createContext<ToastController | null>(null);\nToasterContext.displayName = 'ToasterContext';\n\n/**\n * A part registered with its toast (D9, D10): the title (its label names the toast), the body (it\n * describes the toast) or the footer (its controls are actions). The getters are read when the\n * container composes its name, timer and announcement, after the parts have mounted.\n */\nexport type ToastPartRegistration =\n | {\n kind: 'title';\n id: string;\n getLabel: () => HTMLElement | null;\n getRow: () => HTMLElement | null;\n }\n | { kind: 'body'; id: string; getElement: () => HTMLElement | null }\n | { kind: 'footer'; getElement: () => HTMLElement | null };\n\n/** What a Toast rendered inside the Toaster's container registers with it (D10–D12). */\nexport interface ToastRegistration {\n status: Status;\n /** The resolved severity text (`''` when hidden). */\n statusLabel: string;\n /** The id of the visually hidden severity text, while it renders. */\n statusTextId: string | undefined;\n /** The Toast's `onDismiss`, called before the container dismisses the toast. */\n onDismiss: (() => void) | undefined;\n /** The Toast's built-in Dismiss button, which is no action. */\n getDismissButton: () => HTMLElement | null;\n}\n\n/** One per toast: provided by a standalone Toast and by the Toaster's container (D9). */\nexport interface ToastContextValue {\n /** The id of the title text that names the toast (`Toast.Title`'s label). */\n titleId: string | undefined;\n /**\n * What `Toast.Close` and the Dismiss button call: the Toast's `onDismiss` (when there is one),\n * then, inside the Toaster, the toast's dismissal. `undefined` when there is nothing to call.\n */\n dismiss: (() => void) | undefined;\n /** Registers a part (a no-op in a standalone Toast); returns the unregister function. */\n registerPart: (part: ToastPartRegistration) => () => void;\n /** Registers the Toast rendered inside a Toaster container; `null` everywhere else. */\n registerToast: ((toast: ToastRegistration) => () => void) | null;\n}\n\nexport const ToastContext = React.createContext<ToastContextValue | null>(null);\nToastContext.displayName = 'ToastContext';\n\n/** `true` inside the body a Toast wraps around children in which its scan found no part (D15 rule). */\nexport const ToastUnscannedContext = React.createContext(false);\nToastUnscannedContext.displayName = 'ToastUnscannedContext';\n\nconst unregisterNothing = () => {};\n\n/** The context a part gets in production outside a Toast (C-CONTEXT). */\nexport const INERT_TOAST_CONTEXT: ToastContextValue = {\n titleId: undefined,\n dismiss: undefined,\n registerPart: () => unregisterNothing,\n registerToast: null,\n};\n\n/**\n * The per-toast context of a part. Outside a Toast and a Toaster's container it throws\n * `[WaveUI] <componentName> must be used within <Toast>` in development and returns an inert\n * context in production (C-CONTEXT).\n */\nexport function useToastContext(componentName: string): ToastContextValue {\n const context = React.useContext(ToastContext);\n if (context) return context;\n reportMissingContext(componentName, '<Toast>');\n return INERT_TOAST_CONTEXT;\n}\n"],"mappings":"4IAMA,IAAaI,EAAiBJ,EAAM,cAAsC,IAAI,EAC9E,EAAe,YAAc,iBA6C7B,IAAaK,EAAeL,EAAM,cAAwC,IAAI,EAC9E,EAAa,YAAc,eAG3B,IAAaM,EAAwBN,EAAM,cAAc,EAAK,EAC9D,EAAsB,YAAc,wBAEpC,IAAMO,MAA0B,CAAC,EAGpBC,EAAyC,CACpD,QAAS,IAAA,GACT,QAAS,IAAA,GACT,iBAAoBD,EACpB,cAAe,IACjB,EAOA,SAAgBE,EAAgB,EAA0C,CAIxE,OAHgBT,EAAM,WAAWK,CAC7B,IACJH,EAAA,qBAAqBQ,EAAe,SAAS,EACtCF,EACT"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { reportMissingContext as e } from "../../lib/dev.mjs";
|
|
3
|
+
import * as t from "react";
|
|
4
|
+
//#region src/components/feedback/Toast.context.ts
|
|
5
|
+
var n = t.createContext(null);
|
|
6
|
+
n.displayName = "ToasterContext";
|
|
7
|
+
var r = t.createContext(null);
|
|
8
|
+
r.displayName = "ToastContext";
|
|
9
|
+
var i = t.createContext(!1);
|
|
10
|
+
i.displayName = "ToastUnscannedContext";
|
|
11
|
+
var a = () => {}, o = {
|
|
12
|
+
titleId: void 0,
|
|
13
|
+
dismiss: void 0,
|
|
14
|
+
registerPart: () => a,
|
|
15
|
+
registerToast: null
|
|
16
|
+
};
|
|
17
|
+
function s(n) {
|
|
18
|
+
return t.useContext(r) || (e(n, "<Toast>"), o);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { o as INERT_TOAST_CONTEXT, r as ToastContext, i as ToastUnscannedContext, n as ToasterContext, s as useToastContext };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=Toast.context.mjs.map
|