@mortenbrudvik/waveui 0.7.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 +395 -132
- package/dist/components/button/Button.cjs +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.mjs +36 -35
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/button/Button.slots.cjs +1 -1
- package/dist/components/button/Button.slots.cjs.map +1 -1
- package/dist/components/button/Button.slots.mjs +31 -21
- package/dist/components/button/Button.slots.mjs.map +1 -1
- package/dist/components/button/CompoundButton.cjs +1 -1
- package/dist/components/button/CompoundButton.cjs.map +1 -1
- package/dist/components/button/CompoundButton.mjs +31 -29
- package/dist/components/button/CompoundButton.mjs.map +1 -1
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +24 -23
- package/dist/components/button/Link.mjs.map +1 -1
- package/dist/components/button/MenuButton.cjs +1 -1
- package/dist/components/button/MenuButton.cjs.map +1 -1
- package/dist/components/button/MenuButton.mjs +29 -28
- package/dist/components/button/MenuButton.mjs.map +1 -1
- package/dist/components/button/SplitButton.cjs +1 -1
- package/dist/components/button/SplitButton.cjs.map +1 -1
- package/dist/components/button/SplitButton.mjs +46 -45
- package/dist/components/button/SplitButton.mjs.map +1 -1
- package/dist/components/button/ToggleButton.cjs +1 -1
- package/dist/components/button/ToggleButton.cjs.map +1 -1
- package/dist/components/button/ToggleButton.mjs +38 -35
- package/dist/components/button/ToggleButton.mjs.map +1 -1
- package/dist/components/button/Toolbar.cjs +1 -1
- package/dist/components/button/Toolbar.cjs.map +1 -1
- package/dist/components/button/Toolbar.mjs +43 -42
- package/dist/components/button/Toolbar.mjs.map +1 -1
- package/dist/components/button/Toolbar.parts.cjs +1 -1
- package/dist/components/button/Toolbar.parts.cjs.map +1 -1
- package/dist/components/button/Toolbar.parts.mjs +76 -81
- package/dist/components/button/Toolbar.parts.mjs.map +1 -1
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.mjs +72 -67
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.mjs +89 -88
- package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
- package/dist/components/data-display/Badge.cjs +1 -1
- package/dist/components/data-display/Badge.cjs.map +1 -1
- package/dist/components/data-display/Badge.mjs +17 -16
- package/dist/components/data-display/Badge.mjs.map +1 -1
- package/dist/components/data-display/CounterBadge.cjs +1 -1
- package/dist/components/data-display/CounterBadge.cjs.map +1 -1
- package/dist/components/data-display/CounterBadge.mjs +18 -17
- package/dist/components/data-display/CounterBadge.mjs.map +1 -1
- package/dist/components/data-display/Divider.cjs +1 -1
- package/dist/components/data-display/Divider.cjs.map +1 -1
- package/dist/components/data-display/Divider.mjs +31 -30
- package/dist/components/data-display/Divider.mjs.map +1 -1
- package/dist/components/data-display/Image.cjs +1 -1
- package/dist/components/data-display/Image.cjs.map +1 -1
- package/dist/components/data-display/Image.mjs +16 -15
- package/dist/components/data-display/Image.mjs.map +1 -1
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +74 -73
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +175 -174
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/Persona.cjs +1 -1
- package/dist/components/data-display/Persona.cjs.map +1 -1
- package/dist/components/data-display/Persona.mjs +31 -29
- package/dist/components/data-display/Persona.mjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.cjs +1 -1
- package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
- package/dist/components/data-display/PresenceBadge.mjs +25 -24
- package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +87 -82
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/feedback/MessageBar.cjs +1 -1
- package/dist/components/feedback/MessageBar.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.mjs +129 -71
- package/dist/components/feedback/MessageBar.mjs.map +1 -1
- 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 +1 -1
- package/dist/components/feedback/MessageBar.status.cjs.map +1 -1
- package/dist/components/feedback/MessageBar.status.mjs +2 -1
- package/dist/components/feedback/MessageBar.status.mjs.map +1 -1
- package/dist/components/feedback/ProgressBar.cjs +1 -1
- package/dist/components/feedback/ProgressBar.cjs.map +1 -1
- package/dist/components/feedback/ProgressBar.mjs +44 -43
- package/dist/components/feedback/ProgressBar.mjs.map +1 -1
- package/dist/components/feedback/Skeleton.cjs +1 -1
- package/dist/components/feedback/Skeleton.cjs.map +1 -1
- package/dist/components/feedback/Skeleton.mjs +26 -24
- package/dist/components/feedback/Skeleton.mjs.map +1 -1
- package/dist/components/feedback/Spinner.cjs +1 -1
- package/dist/components/feedback/Spinner.cjs.map +1 -1
- package/dist/components/feedback/Spinner.mjs +32 -31
- package/dist/components/feedback/Spinner.mjs.map +1 -1
- package/dist/components/feedback/Toast.cjs +1 -1
- package/dist/components/feedback/Toast.cjs.map +1 -1
- 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 +10 -342
- package/dist/components/feedback/Toast.mjs.map +1 -1
- 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 +1 -1
- package/dist/components/input/Checkbox.cjs.map +1 -1
- package/dist/components/input/Checkbox.mjs +47 -46
- package/dist/components/input/Checkbox.mjs.map +1 -1
- 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 +5 -5
- package/dist/components/input/ColorPicker.cjs.map +1 -1
- package/dist/components/input/ColorPicker.mjs +142 -165
- package/dist/components/input/ColorPicker.mjs.map +1 -1
- 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 +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +9 -9
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +90 -85
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +186 -185
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +71 -68
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Field.cjs +1 -1
- package/dist/components/input/Field.cjs.map +1 -1
- package/dist/components/input/Field.mjs +113 -112
- package/dist/components/input/Field.mjs.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.mjs +55 -54
- package/dist/components/input/Input.mjs.map +1 -1
- package/dist/components/input/Label.cjs +1 -1
- package/dist/components/input/Label.cjs.map +1 -1
- package/dist/components/input/Label.mjs +12 -11
- package/dist/components/input/Label.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +100 -98
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/RadioGroup.cjs +1 -1
- package/dist/components/input/RadioGroup.cjs.map +1 -1
- package/dist/components/input/RadioGroup.mjs +89 -88
- package/dist/components/input/RadioGroup.mjs.map +1 -1
- package/dist/components/input/Rating.cjs +1 -1
- package/dist/components/input/Rating.cjs.map +1 -1
- package/dist/components/input/Rating.mjs +110 -109
- package/dist/components/input/Rating.mjs.map +1 -1
- package/dist/components/input/SearchBox.cjs +1 -1
- package/dist/components/input/SearchBox.cjs.map +1 -1
- package/dist/components/input/SearchBox.mjs +118 -119
- package/dist/components/input/SearchBox.mjs.map +1 -1
- package/dist/components/input/Select.cjs +1 -1
- package/dist/components/input/Select.cjs.map +1 -1
- package/dist/components/input/Select.mjs +25 -24
- package/dist/components/input/Select.mjs.map +1 -1
- package/dist/components/input/Slider.cjs +1 -1
- package/dist/components/input/Slider.cjs.map +1 -1
- package/dist/components/input/Slider.mjs +47 -46
- package/dist/components/input/Slider.mjs.map +1 -1
- package/dist/components/input/SpinButton.cjs +1 -1
- package/dist/components/input/SpinButton.cjs.map +1 -1
- package/dist/components/input/SpinButton.mjs +76 -75
- package/dist/components/input/SpinButton.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.mjs +38 -37
- package/dist/components/input/SwatchPicker.mjs.map +1 -1
- package/dist/components/input/Switch.cjs +1 -1
- package/dist/components/input/Switch.cjs.map +1 -1
- package/dist/components/input/Switch.mjs +65 -64
- package/dist/components/input/Switch.mjs.map +1 -1
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.mjs +161 -157
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/Textarea.cjs +1 -1
- package/dist/components/input/Textarea.cjs.map +1 -1
- package/dist/components/input/Textarea.mjs +24 -23
- package/dist/components/input/Textarea.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +202 -199
- package/dist/components/input/TimePicker.mjs.map +1 -1
- 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 +1 -1
- package/dist/components/input/colorUtils.cjs.map +1 -1
- package/dist/components/input/colorUtils.mjs +154 -56
- package/dist/components/input/colorUtils.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs +130 -129
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/layout/Card.cjs +1 -1
- package/dist/components/layout/Card.cjs.map +1 -1
- package/dist/components/layout/Card.mjs +78 -77
- package/dist/components/layout/Card.mjs.map +1 -1
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.mjs +111 -110
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/Flex.cjs +1 -1
- package/dist/components/layout/Flex.cjs.map +1 -1
- package/dist/components/layout/Flex.mjs +22 -21
- package/dist/components/layout/Flex.mjs.map +1 -1
- package/dist/components/layout/Grid.cjs +1 -1
- package/dist/components/layout/Grid.cjs.map +1 -1
- package/dist/components/layout/Grid.mjs +19 -18
- package/dist/components/layout/Grid.mjs.map +1 -1
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +92 -91
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Stack.cjs +1 -1
- package/dist/components/layout/Stack.cjs.map +1 -1
- package/dist/components/layout/Stack.mjs +14 -13
- package/dist/components/layout/Stack.mjs.map +1 -1
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +118 -117
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/layout/Tree.cjs +1 -1
- package/dist/components/layout/Tree.cjs.map +1 -1
- 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 +7 -215
- package/dist/components/layout/Tree.mjs.map +1 -1
- 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/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +76 -75
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/navigation/Menu.group.cjs +1 -1
- package/dist/components/navigation/Menu.group.cjs.map +1 -1
- package/dist/components/navigation/Menu.group.mjs +39 -37
- package/dist/components/navigation/Menu.group.mjs.map +1 -1
- package/dist/components/navigation/Menu.items.cjs +1 -1
- package/dist/components/navigation/Menu.items.cjs.map +1 -1
- package/dist/components/navigation/Menu.items.mjs +67 -61
- package/dist/components/navigation/Menu.items.mjs.map +1 -1
- package/dist/components/navigation/Menu.link.cjs +1 -1
- package/dist/components/navigation/Menu.link.cjs.map +1 -1
- package/dist/components/navigation/Menu.link.mjs +34 -28
- package/dist/components/navigation/Menu.link.mjs.map +1 -1
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +110 -109
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +171 -170
- package/dist/components/navigation/Menu.root.mjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.cjs +1 -1
- package/dist/components/navigation/Menu.selectable.cjs.map +1 -1
- package/dist/components/navigation/Menu.selectable.mjs +85 -63
- package/dist/components/navigation/Menu.selectable.mjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs +1 -1
- package/dist/components/navigation/Menu.splitGroup.cjs.map +1 -1
- package/dist/components/navigation/Menu.splitGroup.mjs +27 -26
- package/dist/components/navigation/Menu.splitGroup.mjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.cjs +1 -1
- package/dist/components/navigation/Menu.trigger.cjs.map +1 -1
- package/dist/components/navigation/Menu.trigger.mjs +6 -6
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.mjs +170 -155
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/Pagination.cjs +1 -1
- package/dist/components/navigation/Pagination.cjs.map +1 -1
- package/dist/components/navigation/Pagination.mjs +73 -65
- package/dist/components/navigation/Pagination.mjs.map +1 -1
- package/dist/components/navigation/Stepper.cjs +1 -1
- package/dist/components/navigation/Stepper.cjs.map +1 -1
- package/dist/components/navigation/Stepper.mjs +110 -109
- package/dist/components/navigation/Stepper.mjs.map +1 -1
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +109 -108
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Drawer.cjs +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.mjs +110 -109
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +229 -227
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +41 -37
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +87 -86
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +33 -32
- package/dist/components/portal/Portal.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +31 -30
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +228 -227
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +60 -59
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/typography/Text.cjs +1 -1
- package/dist/components/typography/Text.cjs.map +1 -1
- package/dist/components/typography/Text.mjs +12 -11
- package/dist/components/typography/Text.mjs.map +1 -1
- 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/usePrefersReducedMotion.cjs +1 -1
- package/dist/hooks/usePrefersReducedMotion.cjs.map +1 -1
- package/dist/hooks/usePrefersReducedMotion.mjs +4 -18
- package/dist/hooks/usePrefersReducedMotion.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +3 -3
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2089 -102
- package/dist/index.d.ts +2089 -102
- package/dist/index.mjs +99 -87
- 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/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/globalRegistry.cjs.map +1 -1
- package/dist/lib/globalRegistry.mjs.map +1 -1
- 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/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoLabel.cjs","names":["useId","React","usePopupPosition","useDismiss","useMergedRefs","cn","focusRing","InfoIcon","Portal","require_runtime","require_cn","require_useId","require_useMergedRefs","require_useDismiss","require_Portal","require_styles","require_icons","require_usePopupPosition","react","react_jsx_runtime","SHOW_DELAY","HIDE_DELAY","InfoLabel","props","descriptionId","openReason","setOpenReason","open","triggerRef","surfaceRef","pointerPressRef","pressTimerRef","showTimerRef","hideTimerRef","clearShowTimer","clearHideTimer","close","triggerRefs","setReference","surfaceRefs","setFloating","scheduleHide","reason","handlePointerEnter","event","handlePointerLeave","handlePointerDown","handleFocus","handleBlur","handleClick","className","label","infoButtonLabel","info","floatingProps"],"sources":["../../../src/components/data-display/InfoLabel.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { focusRing } from '../../lib/styles';\nimport { InfoIcon } from '../../lib/icons';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { Portal } from '../portal/Portal';\n\n/** Properties for the InfoLabel component. */\nexport interface InfoLabelProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Primary label text to display. */\n label: string;\n /**\n * Additional information about the label. It describes the info button\n * (`aria-describedby`, available from the first render) and is shown in a popup on hover,\n * keyboard focus or click.\n */\n info: string;\n /**\n * Accessible name of the info button. Localise it here.\n * @default 'Information'\n */\n infoButtonLabel?: string;\n /** Ref to the root `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** Why the popup is open: a click pins it; hover and keyboard focus open it transiently. */\ntype OpenReason = 'hover' | 'focus' | 'click';\n\n/** Hover delay before the popup opens, and before it closes after the pointer leaves (ms). */\nconst SHOW_DELAY = 250;\nconst HIDE_DELAY = 250;\n\ntype Timer = ReturnType<typeof setTimeout>;\n\n/**\n * A label with an info button that reveals additional information (a \"toggletip\").\n *\n * - The info button is a `<button type=\"button\">` named `infoButtonLabel` (\"Information\"). The\n * info text is rendered inline in a `hidden` element and linked with `aria-describedby`, so it is\n * announced from the first render (also after server rendering), whether the popup is open or not.\n * - The visual popup is portaled only while open. It is `aria-hidden` because it duplicates the\n * description, and it holds no focusable content, so focus stays on the button.\n * - Opens on keyboard focus (not on focus that comes from a pointer press), on hover after a\n * short delay (the popup itself can be hovered) and on click. A click pins it: a click while it is\n * open because of hover or focus keeps it open, a click on a pinned popup closes it.\n * - Closes on Escape, on a press outside, when focus moves elsewhere and — unless pinned — when\n * the pointer leaves or the button loses focus (WCAG 1.4.13). A popup opened by hover that then\n * receives keyboard focus stays open while the button keeps focus, even after the pointer leaves.\n *\n * @example\n * <InfoLabel label=\"Password\" info=\"Use at least 8 characters.\" />\n */\nexport const InfoLabel = ({\n label,\n info,\n infoButtonLabel = 'Information',\n className,\n ref,\n ...props\n}: InfoLabelProps) => {\n const descriptionId = useId('info-label-description');\n const [openReason, setOpenReason] = React.useState<OpenReason | null>(null);\n const open = openReason !== null;\n\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n /**\n * Set by a pointer press on the button, so the focus that follows does not open the popup. It\n * lasts only for the event turn of the press (see `handlePointerDown`).\n */\n const pointerPressRef = React.useRef(false);\n const pressTimerRef = React.useRef<Timer | null>(null);\n const showTimerRef = React.useRef<Timer | null>(null);\n const hideTimerRef = React.useRef<Timer | null>(null);\n\n const clearShowTimer = () => {\n if (showTimerRef.current !== null) clearTimeout(showTimerRef.current);\n showTimerRef.current = null;\n };\n const clearHideTimer = () => {\n if (hideTimerRef.current !== null) clearTimeout(hideTimerRef.current);\n hideTimerRef.current = null;\n };\n\n React.useEffect(\n () => () => {\n if (pressTimerRef.current !== null) clearTimeout(pressTimerRef.current);\n if (showTimerRef.current !== null) clearTimeout(showTimerRef.current);\n if (hideTimerRef.current !== null) clearTimeout(hideTimerRef.current);\n },\n [],\n );\n\n const close = () => {\n clearShowTimer();\n clearHideTimer();\n setOpenReason(null);\n };\n\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open,\n side: 'top',\n align: 'center',\n offset: 8,\n });\n const { layerId } = useDismiss({\n open,\n onDismiss: close,\n refs: [triggerRef, surfaceRef],\n anchorRef: triggerRef,\n focusOutside: true,\n });\n const triggerRefs = useMergedRefs<HTMLButtonElement>(triggerRef, setReference);\n const surfaceRefs = useMergedRefs<HTMLDivElement>(surfaceRef, setFloating);\n\n /** Pointer left the button or the popup: a hover-opened popup closes after a delay. */\n const scheduleHide = () => {\n clearShowTimer();\n clearHideTimer();\n hideTimerRef.current = setTimeout(() => {\n hideTimerRef.current = null;\n setOpenReason((reason) => (reason === 'hover' ? null : reason));\n }, HIDE_DELAY);\n };\n\n const handlePointerEnter = (event: React.PointerEvent) => {\n if (event.pointerType === 'touch') return;\n clearHideTimer();\n if (open || showTimerRef.current !== null) return;\n showTimerRef.current = setTimeout(() => {\n showTimerRef.current = null;\n setOpenReason((reason) => reason ?? 'hover');\n }, SHOW_DELAY);\n };\n\n const handlePointerLeave = (event: React.PointerEvent) => {\n if (event.pointerType === 'touch') return;\n scheduleHide();\n };\n\n const handlePointerDown = () => {\n pointerPressRef.current = true;\n // A press focuses the button (where it does) as the default action of `mousedown`, in the same\n // event turn. Forget the press after that turn: a press that does not focus the button (Safari\n // and Firefox on macOS, iOS) and ends without a click (dragged off, or a touch that becomes a\n // scroll) must not turn a later keyboard focus into pointer focus. A touch tap dispatches its\n // compatibility `mousedown` (and the focus) after the touch ends; that `mousedown` sets the\n // flag again.\n if (pressTimerRef.current !== null) clearTimeout(pressTimerRef.current);\n pressTimerRef.current = setTimeout(() => {\n pressTimerRef.current = null;\n pointerPressRef.current = false;\n }, 0);\n };\n\n const handleFocus = () => {\n // Keyboard focus opens; focus that comes from a pointer press waits for the click.\n if (pointerPressRef.current) return;\n // A popup opened by hover becomes focus-owned, so it stays while the button has focus even\n // after the pointer leaves (WCAG 1.4.13 persistent). A pinned popup stays pinned.\n setOpenReason((reason) => (reason === 'click' ? reason : 'focus'));\n };\n\n const handleBlur = () => {\n setOpenReason((reason) => (reason === 'focus' ? null : reason));\n };\n\n const handleClick = () => {\n clearShowTimer();\n clearHideTimer();\n // Closed → pinned; open because of hover or focus → pinned; pinned → closed.\n setOpenReason((reason) => (reason === 'click' ? null : 'click'));\n };\n\n return (\n <span\n ref={ref}\n className={cn('inline-flex items-center gap-1 text-body-1', className)}\n {...props}\n >\n {label}\n <button\n ref={triggerRefs}\n type=\"button\"\n aria-label={infoButtonLabel}\n aria-expanded={open}\n aria-describedby={descriptionId}\n className={cn(\n 'inline-flex size-4 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-muted-foreground',\n 'not-disabled:not-aria-disabled:hover:text-foreground',\n focusRing,\n )}\n onPointerDown={handlePointerDown}\n onMouseDown={handlePointerDown}\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={handleClick}\n >\n <InfoIcon size={16} />\n </button>\n <span id={descriptionId} hidden>\n {info}\n </span>\n {open && (\n <Portal layerId={layerId}>\n <div\n ref={surfaceRefs}\n aria-hidden=\"true\"\n data-wave-infolabel-surface=\"\"\n data-state=\"open\"\n {...floatingProps}\n className=\"w-max max-w-xs rounded-md border border-border bg-background px-3 py-2 text-caption-1 text-foreground shadow-16\"\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n >\n {info}\n </div>\n </Portal>\n )}\n </span>\n );\n};\n\nInfoLabel.displayName = 'InfoLabel';\n"],"mappings":"ubAiCA,IAAMoB,EAAa,IACbC,EAAa,IAsBNC,GAAa,CACxB,QACA,OACA,kBAAkB,cAClB,YACA,MACA,GAAGC,KACiB,CACpB,IAAMC,EAAgBxB,EAAAA,MAAM,wBAAwB,EAC9C,CAACyB,EAAYC,GAAiBzB,EAAM,SAA4B,IAAI,EACpE0B,EAAOF,IAAe,KAEtBG,EAAa3B,EAAM,OAAiC,IAAI,EACxD4B,EAAa5B,EAAM,OAA8B,IAAI,EAKrD6B,EAAkB7B,EAAM,OAAO,EAAK,EACpC8B,EAAgB9B,EAAM,OAAqB,IAAI,EAC/C+B,EAAe/B,EAAM,OAAqB,IAAI,EAC9CgC,EAAehC,EAAM,OAAqB,IAAI,EAE9CiC,MAAuB,CACvBF,EAAa,UAAY,MAAM,aAAaA,EAAa,OAAO,EACpE,EAAa,QAAU,IACzB,EACMG,MAAuB,CACvBF,EAAa,UAAY,MAAM,aAAaA,EAAa,OAAO,EACpE,EAAa,QAAU,IACzB,EAEAf,EAAM,k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gB,IAAW,QAAU,KAAOA,CAAO,CAChE,EAEMO,MAAoB,CACxBf,EAAe,EACfC,EAAe,EAEfT,EAAe,GAAYgB,IAAW,QAAU,KAAO,OAAQ,CACjE,EAEA,OACE,EAAAvB,EAAA,KAAA,CAAC,OAAD,CACO,MACL,UAAWd,EAAAA,GAAG,6CAA8C6C,CAAS,EACrE,GAAI3B,EAHN,SAAA,CAKG4B,GACD,EAAAhC,EAAA,IAAA,CAAC,SAAD,CACE,IAAKkB,EACL,KAAK,SACL,aAAYe,EACZ,gBAAezB,EACf,mBAAkBH,EAClB,UAAWnB,EAAAA,GACT,yHACA,uDACAC,EAAAA,SACF,EACA,cAAewC,EACf,YAAaA,EACb,eAAgBH,EAChB,eAAgBE,EAChB,QAASE,EACT,OAAQC,EACR,QAASC,EAET,UAAA,EAAA9B,EAAA,IAAA,CAACZ,EAAAA,SAAD,CAAU,KAAM,EAAK,CAAA,CACf,CAAA,GACR,EAAAY,EAAA,IAAA,CAAC,OAAD,CAAM,GAAIK,EAAe,OAAA,GACtB,SAAA6B,CACG,CAAA,EACL1B,IACC,EAAAR,EAAA,IAAA,CAACX,EAAAA,OAAD,CAAiB,UACf,UAAA,EAAAW,EAAA,IAAA,CAAC,MAAD,CACE,IAAKoB,EACL,cAAY,OACZ,8BAA4B,GAC5B,aAAW,OACX,GAAIe,EACJ,UAAU,kHACV,eAAgBX,EAChB,eAAgBE,EAEf,SAAAQ,CACE,CAAA,CACC,CAAA,CAEN,GAEV,EAEA,EAAU,YAAc"}
|
|
1
|
+
{"version":3,"file":"InfoLabel.cjs","names":["useId","React","usePopupPosition","useDismiss","useMergedRefs","cn","infoLabelClassNames","focusRing","InfoIcon","Portal","require_runtime","require_cn","require_classNames","require_useId","require_useMergedRefs","require_useDismiss","require_Portal","require_styles","require_icons","require_usePopupPosition","react","react_jsx_runtime","SHOW_DELAY","HIDE_DELAY","InfoLabel","props","descriptionId","openReason","setOpenReason","open","triggerRef","surfaceRef","pointerPressRef","pressTimerRef","showTimerRef","hideTimerRef","clearShowTimer","clearHideTimer","close","triggerRefs","setReference","surfaceRefs","setFloating","scheduleHide","reason","handlePointerEnter","event","handlePointerLeave","handlePointerDown","handleFocus","handleBlur","handleClick","className","label","infoButtonLabel","info","floatingProps"],"sources":["../../../src/components/data-display/InfoLabel.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { infoLabelClassNames } from '../../lib/classNames';\nimport { focusRing } from '../../lib/styles';\nimport { InfoIcon } from '../../lib/icons';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { Portal } from '../portal/Portal';\n\n/** Properties for the InfoLabel component. */\nexport interface InfoLabelProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Primary label text to display. */\n label: string;\n /**\n * Additional information about the label. It describes the info button\n * (`aria-describedby`, available from the first render) and is shown in a popup on hover,\n * keyboard focus or click.\n */\n info: string;\n /**\n * Accessible name of the info button. Localise it here.\n * @default 'Information'\n */\n infoButtonLabel?: string;\n /** Ref to the root `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** Why the popup is open: a click pins it; hover and keyboard focus open it transiently. */\ntype OpenReason = 'hover' | 'focus' | 'click';\n\n/** Hover delay before the popup opens, and before it closes after the pointer leaves (ms). */\nconst SHOW_DELAY = 250;\nconst HIDE_DELAY = 250;\n\ntype Timer = ReturnType<typeof setTimeout>;\n\n/**\n * A label with an info button that reveals additional information (a \"toggletip\").\n *\n * - The info button is a `<button type=\"button\">` named `infoButtonLabel` (\"Information\"). The\n * info text is rendered inline in a `hidden` element and linked with `aria-describedby`, so it is\n * announced from the first render (also after server rendering), whether the popup is open or not.\n * - The visual popup is portaled only while open. It is `aria-hidden` because it duplicates the\n * description, and it holds no focusable content, so focus stays on the button.\n * - Opens on keyboard focus (not on focus that comes from a pointer press), on hover after a\n * short delay (the popup itself can be hovered) and on click. A click pins it: a click while it is\n * open because of hover or focus keeps it open, a click on a pinned popup closes it.\n * - Closes on Escape, on a press outside, when focus moves elsewhere and — unless pinned — when\n * the pointer leaves or the button loses focus (WCAG 1.4.13). A popup opened by hover that then\n * receives keyboard focus stays open while the button keeps focus, even after the pointer leaves.\n *\n * @example\n * <InfoLabel label=\"Password\" info=\"Use at least 8 characters.\" />\n */\nexport const InfoLabel = ({\n label,\n info,\n infoButtonLabel = 'Information',\n className,\n ref,\n ...props\n}: InfoLabelProps) => {\n const descriptionId = useId('info-label-description');\n const [openReason, setOpenReason] = React.useState<OpenReason | null>(null);\n const open = openReason !== null;\n\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n /**\n * Set by a pointer press on the button, so the focus that follows does not open the popup. It\n * lasts only for the event turn of the press (see `handlePointerDown`).\n */\n const pointerPressRef = React.useRef(false);\n const pressTimerRef = React.useRef<Timer | null>(null);\n const showTimerRef = React.useRef<Timer | null>(null);\n const hideTimerRef = React.useRef<Timer | null>(null);\n\n const clearShowTimer = () => {\n if (showTimerRef.current !== null) clearTimeout(showTimerRef.current);\n showTimerRef.current = null;\n };\n const clearHideTimer = () => {\n if (hideTimerRef.current !== null) clearTimeout(hideTimerRef.current);\n hideTimerRef.current = null;\n };\n\n React.useEffect(\n () => () => {\n if (pressTimerRef.current !== null) clearTimeout(pressTimerRef.current);\n if (showTimerRef.current !== null) clearTimeout(showTimerRef.current);\n if (hideTimerRef.current !== null) clearTimeout(hideTimerRef.current);\n },\n [],\n );\n\n const close = () => {\n clearShowTimer();\n clearHideTimer();\n setOpenReason(null);\n };\n\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open,\n side: 'top',\n align: 'center',\n offset: 8,\n });\n const { layerId } = useDismiss({\n open,\n onDismiss: close,\n refs: [triggerRef, surfaceRef],\n anchorRef: triggerRef,\n focusOutside: true,\n });\n const triggerRefs = useMergedRefs<HTMLButtonElement>(triggerRef, setReference);\n const surfaceRefs = useMergedRefs<HTMLDivElement>(surfaceRef, setFloating);\n\n /** Pointer left the button or the popup: a hover-opened popup closes after a delay. */\n const scheduleHide = () => {\n clearShowTimer();\n clearHideTimer();\n hideTimerRef.current = setTimeout(() => {\n hideTimerRef.current = null;\n setOpenReason((reason) => (reason === 'hover' ? null : reason));\n }, HIDE_DELAY);\n };\n\n const handlePointerEnter = (event: React.PointerEvent) => {\n if (event.pointerType === 'touch') return;\n clearHideTimer();\n if (open || showTimerRef.current !== null) return;\n showTimerRef.current = setTimeout(() => {\n showTimerRef.current = null;\n setOpenReason((reason) => reason ?? 'hover');\n }, SHOW_DELAY);\n };\n\n const handlePointerLeave = (event: React.PointerEvent) => {\n if (event.pointerType === 'touch') return;\n scheduleHide();\n };\n\n const handlePointerDown = () => {\n pointerPressRef.current = true;\n // A press focuses the button (where it does) as the default action of `mousedown`, in the same\n // event turn. Forget the press after that turn: a press that does not focus the button (Safari\n // and Firefox on macOS, iOS) and ends without a click (dragged off, or a touch that becomes a\n // scroll) must not turn a later keyboard focus into pointer focus. A touch tap dispatches its\n // compatibility `mousedown` (and the focus) after the touch ends; that `mousedown` sets the\n // flag again.\n if (pressTimerRef.current !== null) clearTimeout(pressTimerRef.current);\n pressTimerRef.current = setTimeout(() => {\n pressTimerRef.current = null;\n pointerPressRef.current = false;\n }, 0);\n };\n\n const handleFocus = () => {\n // Keyboard focus opens; focus that comes from a pointer press waits for the click.\n if (pointerPressRef.current) return;\n // A popup opened by hover becomes focus-owned, so it stays while the button has focus even\n // after the pointer leaves (WCAG 1.4.13 persistent). A pinned popup stays pinned.\n setOpenReason((reason) => (reason === 'click' ? reason : 'focus'));\n };\n\n const handleBlur = () => {\n setOpenReason((reason) => (reason === 'focus' ? null : reason));\n };\n\n const handleClick = () => {\n clearShowTimer();\n clearHideTimer();\n // Closed → pinned; open because of hover or focus → pinned; pinned → closed.\n setOpenReason((reason) => (reason === 'click' ? null : 'click'));\n };\n\n return (\n <span\n ref={ref}\n className={cn(\n infoLabelClassNames.root,\n 'inline-flex items-center gap-1 text-body-1',\n className,\n )}\n {...props}\n >\n {label}\n <button\n ref={triggerRefs}\n type=\"button\"\n aria-label={infoButtonLabel}\n aria-expanded={open}\n aria-describedby={descriptionId}\n className={cn(\n infoLabelClassNames.infoButton,\n 'inline-flex size-4 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-muted-foreground',\n 'not-disabled:not-aria-disabled:hover:text-foreground',\n focusRing,\n )}\n onPointerDown={handlePointerDown}\n onMouseDown={handlePointerDown}\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={handleClick}\n >\n <InfoIcon size={16} />\n </button>\n <span id={descriptionId} hidden>\n {info}\n </span>\n {open && (\n <Portal layerId={layerId}>\n <div\n ref={surfaceRefs}\n aria-hidden=\"true\"\n data-wave-infolabel-surface=\"\"\n data-state=\"open\"\n {...floatingProps}\n className={cn(\n infoLabelClassNames.info,\n 'w-max max-w-xs rounded-md border border-border bg-background px-3 py-2 text-caption-1 text-foreground shadow-16',\n )}\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n >\n {info}\n </div>\n </Portal>\n )}\n </span>\n );\n};\n\nInfoLabel.displayName = 'InfoLabel';\n"],"mappings":"6dAkCA,IAAMsB,EAAa,IACbC,EAAa,IAsBNC,GAAa,CACxB,QACA,OACA,kBAAkB,cAClB,YACA,MACA,GAAGC,KACiB,CACpB,IAAMC,EAAgB1B,EAAAA,MAAM,wBAAwB,EAC9C,CAAC2B,EAAYC,GAAiB3B,EAAM,SAA4B,IAAI,EACpE4B,EAAOF,IAAe,KAEtBG,EAAa7B,EAAM,OAAiC,IAAI,EACxD8B,EAAa9B,EAAM,OAA8B,IAAI,EAKrD+B,EAAkB/B,EAAM,OAAO,EAAK,EACpCgC,EAAgBhC,EAAM,OAAqB,IAAI,EAC/CiC,EAAejC,EAAM,OAA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AEA,EAAU,YAAc"}
|
|
@@ -1,104 +1,105 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
3
|
+
import { infoLabelClassNames as t } from "../../lib/classNames.mjs";
|
|
4
|
+
import { useId as n } from "../../hooks/useId.mjs";
|
|
5
|
+
import { useMergedRefs as r } from "../../hooks/useMergedRefs.mjs";
|
|
6
|
+
import { useDismiss as i } from "../../hooks/useDismiss.mjs";
|
|
7
|
+
import { Portal as a } from "../portal/Portal.mjs";
|
|
8
|
+
import { focusRing as o } from "../../lib/styles.mjs";
|
|
9
|
+
import { InfoIcon as s } from "../../lib/icons.mjs";
|
|
10
|
+
import { usePopupPosition as c } from "../../hooks/usePopupPosition.mjs";
|
|
11
|
+
import * as l from "react";
|
|
12
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
12
13
|
//#region src/components/data-display/InfoLabel.tsx
|
|
13
|
-
var
|
|
14
|
-
let
|
|
15
|
-
D.current !== null && clearTimeout(D.current), D.current = null;
|
|
16
|
-
}, A = () => {
|
|
14
|
+
var f = 250, p = 250, m = ({ label: m, info: h, infoButtonLabel: g = "Information", className: _, ref: v, ...y }) => {
|
|
15
|
+
let b = n("info-label-description"), [x, S] = l.useState(null), C = x !== null, w = l.useRef(null), T = l.useRef(null), E = l.useRef(!1), D = l.useRef(null), O = l.useRef(null), k = l.useRef(null), A = () => {
|
|
17
16
|
O.current !== null && clearTimeout(O.current), O.current = null;
|
|
17
|
+
}, j = () => {
|
|
18
|
+
k.current !== null && clearTimeout(k.current), k.current = null;
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
l.useEffect(() => () => {
|
|
21
|
+
D.current !== null && clearTimeout(D.current), O.current !== null && clearTimeout(O.current), k.current !== null && clearTimeout(k.current);
|
|
21
22
|
}, []);
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
}, { setReference:
|
|
25
|
-
open:
|
|
23
|
+
let M = () => {
|
|
24
|
+
A(), j(), S(null);
|
|
25
|
+
}, { setReference: N, setFloating: P, floatingProps: F } = c({
|
|
26
|
+
open: C,
|
|
26
27
|
side: "top",
|
|
27
28
|
align: "center",
|
|
28
29
|
offset: 8
|
|
29
|
-
}), { layerId:
|
|
30
|
-
open:
|
|
31
|
-
onDismiss:
|
|
32
|
-
refs: [
|
|
33
|
-
anchorRef:
|
|
30
|
+
}), { layerId: I } = i({
|
|
31
|
+
open: C,
|
|
32
|
+
onDismiss: M,
|
|
33
|
+
refs: [w, T],
|
|
34
|
+
anchorRef: w,
|
|
34
35
|
focusOutside: !0
|
|
35
|
-
}),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
}, z = (e) => {
|
|
40
|
-
e.pointerType !== "touch" && (A(), !(S || D.current !== null) && (D.current = setTimeout(() => {
|
|
41
|
-
D.current = null, x((e) => e ?? "hover");
|
|
42
|
-
}, d)));
|
|
36
|
+
}), L = r(w, N), R = r(T, P), z = () => {
|
|
37
|
+
A(), j(), k.current = setTimeout(() => {
|
|
38
|
+
k.current = null, S((e) => e === "hover" ? null : e);
|
|
39
|
+
}, p);
|
|
43
40
|
}, B = (e) => {
|
|
44
|
-
e.pointerType !== "touch" &&
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
e.pointerType !== "touch" && (j(), !(C || O.current !== null) && (O.current = setTimeout(() => {
|
|
42
|
+
O.current = null, S((e) => e ?? "hover");
|
|
43
|
+
}, f)));
|
|
44
|
+
}, V = (e) => {
|
|
45
|
+
e.pointerType !== "touch" && z();
|
|
49
46
|
}, H = () => {
|
|
50
|
-
|
|
47
|
+
E.current = !0, D.current !== null && clearTimeout(D.current), D.current = setTimeout(() => {
|
|
48
|
+
D.current = null, E.current = !1;
|
|
49
|
+
}, 0);
|
|
51
50
|
}, U = () => {
|
|
52
|
-
|
|
51
|
+
E.current || S((e) => e === "click" ? e : "focus");
|
|
53
52
|
}, W = () => {
|
|
54
|
-
|
|
53
|
+
S((e) => e === "focus" ? null : e);
|
|
54
|
+
}, G = () => {
|
|
55
|
+
A(), j(), S((e) => e === "click" ? null : "click");
|
|
55
56
|
};
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
ref:
|
|
58
|
-
className: e("inline-flex items-center gap-1 text-body-1",
|
|
59
|
-
...
|
|
57
|
+
return /* @__PURE__ */ d("span", {
|
|
58
|
+
ref: v,
|
|
59
|
+
className: e(t.root, "inline-flex items-center gap-1 text-body-1", _),
|
|
60
|
+
...y,
|
|
60
61
|
children: [
|
|
61
|
-
|
|
62
|
-
/* @__PURE__ */
|
|
63
|
-
ref:
|
|
62
|
+
m,
|
|
63
|
+
/* @__PURE__ */ u("button", {
|
|
64
|
+
ref: L,
|
|
64
65
|
type: "button",
|
|
65
|
-
"aria-label":
|
|
66
|
-
"aria-expanded":
|
|
67
|
-
"aria-describedby":
|
|
68
|
-
className: e("inline-flex size-4 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-muted-foreground", "not-disabled:not-aria-disabled:hover:text-foreground",
|
|
69
|
-
onPointerDown:
|
|
70
|
-
onMouseDown:
|
|
71
|
-
onPointerEnter:
|
|
72
|
-
onPointerLeave:
|
|
73
|
-
onFocus:
|
|
74
|
-
onBlur:
|
|
75
|
-
onClick:
|
|
76
|
-
children: /* @__PURE__ */
|
|
66
|
+
"aria-label": g,
|
|
67
|
+
"aria-expanded": C,
|
|
68
|
+
"aria-describedby": b,
|
|
69
|
+
className: e(t.infoButton, "inline-flex size-4 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-muted-foreground", "not-disabled:not-aria-disabled:hover:text-foreground", o),
|
|
70
|
+
onPointerDown: H,
|
|
71
|
+
onMouseDown: H,
|
|
72
|
+
onPointerEnter: B,
|
|
73
|
+
onPointerLeave: V,
|
|
74
|
+
onFocus: U,
|
|
75
|
+
onBlur: W,
|
|
76
|
+
onClick: G,
|
|
77
|
+
children: /* @__PURE__ */ u(s, { size: 16 })
|
|
77
78
|
}),
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
id:
|
|
79
|
+
/* @__PURE__ */ u("span", {
|
|
80
|
+
id: b,
|
|
80
81
|
hidden: !0,
|
|
81
|
-
children:
|
|
82
|
+
children: h
|
|
82
83
|
}),
|
|
83
|
-
|
|
84
|
-
layerId:
|
|
85
|
-
children: /* @__PURE__ */
|
|
86
|
-
ref:
|
|
84
|
+
C && /* @__PURE__ */ u(a, {
|
|
85
|
+
layerId: I,
|
|
86
|
+
children: /* @__PURE__ */ u("div", {
|
|
87
|
+
ref: R,
|
|
87
88
|
"aria-hidden": "true",
|
|
88
89
|
"data-wave-infolabel-surface": "",
|
|
89
90
|
"data-state": "open",
|
|
90
|
-
...
|
|
91
|
-
className: "w-max max-w-xs rounded-md border border-border bg-background px-3 py-2 text-caption-1 text-foreground shadow-16",
|
|
92
|
-
onPointerEnter:
|
|
93
|
-
onPointerLeave:
|
|
94
|
-
children:
|
|
91
|
+
...F,
|
|
92
|
+
className: e(t.info, "w-max max-w-xs rounded-md border border-border bg-background px-3 py-2 text-caption-1 text-foreground shadow-16"),
|
|
93
|
+
onPointerEnter: B,
|
|
94
|
+
onPointerLeave: V,
|
|
95
|
+
children: h
|
|
95
96
|
})
|
|
96
97
|
})
|
|
97
98
|
]
|
|
98
99
|
});
|
|
99
100
|
};
|
|
100
|
-
|
|
101
|
+
m.displayName = "InfoLabel";
|
|
101
102
|
//#endregion
|
|
102
|
-
export {
|
|
103
|
+
export { m as InfoLabel };
|
|
103
104
|
|
|
104
105
|
//# sourceMappingURL=InfoLabel.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoLabel.mjs","names":["useId","useId$1","React","SHOW_DELAY","HIDE_DELAY","InfoLabel","props","descriptionId","openReason","setOpenReason","open","triggerRef","surfaceRef","pointerPressRef","pressTimerRef","showTimerRef","hideTimerRef","clearShowTimer","clearHideTimer","close","usePopupPosition","useDismiss","triggerRefs","useMergedRefs","setReference","surfaceRefs","setFloating","scheduleHide","reason","handlePointerEnter","event","handlePointerLeave","handlePointerDown","handleFocus","handleBlur","handleClick","cn","className","label","infoButtonLabel","focusRing","InfoIcon","info","Portal","floatingProps"],"sources":["../../../src/components/data-display/InfoLabel.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { focusRing } from '../../lib/styles';\nimport { InfoIcon } from '../../lib/icons';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { Portal } from '../portal/Portal';\n\n/** Properties for the InfoLabel component. */\nexport interface InfoLabelProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Primary label text to display. */\n label: string;\n /**\n * Additional information about the label. It describes the info button\n * (`aria-describedby`, available from the first render) and is shown in a popup on hover,\n * keyboard focus or click.\n */\n info: string;\n /**\n * Accessible name of the info button. Localise it here.\n * @default 'Information'\n */\n infoButtonLabel?: string;\n /** Ref to the root `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** Why the popup is open: a click pins it; hover and keyboard focus open it transiently. */\ntype OpenReason = 'hover' | 'focus' | 'click';\n\n/** Hover delay before the popup opens, and before it closes after the pointer leaves (ms). */\nconst SHOW_DELAY = 250;\nconst HIDE_DELAY = 250;\n\ntype Timer = ReturnType<typeof setTimeout>;\n\n/**\n * A label with an info button that reveals additional information (a \"toggletip\").\n *\n * - The info button is a `<button type=\"button\">` named `infoButtonLabel` (\"Information\"). The\n * info text is rendered inline in a `hidden` element and linked with `aria-describedby`, so it is\n * announced from the first render (also after server rendering), whether the popup is open or not.\n * - The visual popup is portaled only while open. It is `aria-hidden` because it duplicates the\n * description, and it holds no focusable content, so focus stays on the button.\n * - Opens on keyboard focus (not on focus that comes from a pointer press), on hover after a\n * short delay (the popup itself can be hovered) and on click. A click pins it: a click while it is\n * open because of hover or focus keeps it open, a click on a pinned popup closes it.\n * - Closes on Escape, on a press outside, when focus moves elsewhere and — unless pinned — when\n * the pointer leaves or the button loses focus (WCAG 1.4.13). A popup opened by hover that then\n * receives keyboard focus stays open while the button keeps focus, even after the pointer leaves.\n *\n * @example\n * <InfoLabel label=\"Password\" info=\"Use at least 8 characters.\" />\n */\nexport const InfoLabel = ({\n label,\n info,\n infoButtonLabel = 'Information',\n className,\n ref,\n ...props\n}: InfoLabelProps) => {\n const descriptionId = useId('info-label-description');\n const [openReason, setOpenReason] = React.useState<OpenReason | null>(null);\n const open = openReason !== null;\n\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n /**\n * Set by a pointer press on the button, so the focus that follows does not open the popup. It\n * lasts only for the event turn of the press (see `handlePointerDown`).\n */\n const pointerPressRef = React.useRef(false);\n const pressTimerRef = React.useRef<Timer | null>(null);\n const showTimerRef = React.useRef<Timer | null>(null);\n const hideTimerRef = React.useRef<Timer | null>(null);\n\n const clearShowTimer = () => {\n if (showTimerRef.current !== null) clearTimeout(showTimerRef.current);\n showTimerRef.current = null;\n };\n const clearHideTimer = () => {\n if (hideTimerRef.current !== null) clearTimeout(hideTimerRef.current);\n hideTimerRef.current = null;\n };\n\n React.useEffect(\n () => () => {\n if (pressTimerRef.current !== null) clearTimeout(pressTimerRef.current);\n if (showTimerRef.current !== null) clearTimeout(showTimerRef.current);\n if (hideTimerRef.current !== null) clearTimeout(hideTimerRef.current);\n },\n [],\n );\n\n const close = () => {\n clearShowTimer();\n clearHideTimer();\n setOpenReason(null);\n };\n\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open,\n side: 'top',\n align: 'center',\n offset: 8,\n });\n const { layerId } = useDismiss({\n open,\n onDismiss: close,\n refs: [triggerRef, surfaceRef],\n anchorRef: triggerRef,\n focusOutside: true,\n });\n const triggerRefs = useMergedRefs<HTMLButtonElement>(triggerRef, setReference);\n const surfaceRefs = useMergedRefs<HTMLDivElement>(surfaceRef, setFloating);\n\n /** Pointer left the button or the popup: a hover-opened popup closes after a delay. */\n const scheduleHide = () => {\n clearShowTimer();\n clearHideTimer();\n hideTimerRef.current = setTimeout(() => {\n hideTimerRef.current = null;\n setOpenReason((reason) => (reason === 'hover' ? null : reason));\n }, HIDE_DELAY);\n };\n\n const handlePointerEnter = (event: React.PointerEvent) => {\n if (event.pointerType === 'touch') return;\n clearHideTimer();\n if (open || showTimerRef.current !== null) return;\n showTimerRef.current = setTimeout(() => {\n showTimerRef.current = null;\n setOpenReason((reason) => reason ?? 'hover');\n }, SHOW_DELAY);\n };\n\n const handlePointerLeave = (event: React.PointerEvent) => {\n if (event.pointerType === 'touch') return;\n scheduleHide();\n };\n\n const handlePointerDown = () => {\n pointerPressRef.current = true;\n // A press focuses the button (where it does) as the default action of `mousedown`, in the same\n // event turn. Forget the press after that turn: a press that does not focus the button (Safari\n // and Firefox on macOS, iOS) and ends without a click (dragged off, or a touch that becomes a\n // scroll) must not turn a later keyboard focus into pointer focus. A touch tap dispatches its\n // compatibility `mousedown` (and the focus) after the touch ends; that `mousedown` sets the\n // flag again.\n if (pressTimerRef.current !== null) clearTimeout(pressTimerRef.current);\n pressTimerRef.current = setTimeout(() => {\n pressTimerRef.current = null;\n pointerPressRef.current = false;\n }, 0);\n };\n\n const handleFocus = () => {\n // Keyboard focus opens; focus that comes from a pointer press waits for the click.\n if (pointerPressRef.current) return;\n // A popup opened by hover becomes focus-owned, so it stays while the button has focus even\n // after the pointer leaves (WCAG 1.4.13 persistent). A pinned popup stays pinned.\n setOpenReason((reason) => (reason === 'click' ? reason : 'focus'));\n };\n\n const handleBlur = () => {\n setOpenReason((reason) => (reason === 'focus' ? null : reason));\n };\n\n const handleClick = () => {\n clearShowTimer();\n clearHideTimer();\n // Closed → pinned; open because of hover or focus → pinned; pinned → closed.\n setOpenReason((reason) => (reason === 'click' ? null : 'click'));\n };\n\n return (\n <span\n ref={ref}\n className={cn('inline-flex items-center gap-1 text-body-1', className)}\n {...props}\n >\n {label}\n <button\n ref={triggerRefs}\n type=\"button\"\n aria-label={infoButtonLabel}\n aria-expanded={open}\n aria-describedby={descriptionId}\n className={cn(\n 'inline-flex size-4 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-muted-foreground',\n 'not-disabled:not-aria-disabled:hover:text-foreground',\n focusRing,\n )}\n onPointerDown={handlePointerDown}\n onMouseDown={handlePointerDown}\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={handleClick}\n >\n <InfoIcon size={16} />\n </button>\n <span id={descriptionId} hidden>\n {info}\n </span>\n {open && (\n <Portal layerId={layerId}>\n <div\n ref={surfaceRefs}\n aria-hidden=\"true\"\n data-wave-infolabel-surface=\"\"\n data-state=\"open\"\n {...floatingProps}\n className=\"w-max max-w-xs rounded-md border border-border bg-background px-3 py-2 text-caption-1 text-foreground shadow-16\"\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n >\n {info}\n </div>\n </Portal>\n )}\n </span>\n );\n};\n\nInfoLabel.displayName = 'InfoLabel';\n"],"mappings":";;;;;;;;;;;;AAiCA,IAAMG,IAAa,KACbC,IAAa,KAsBNC,KAAa,EACxB,UACA,SACA,qBAAkB,eAClB,cACA,QACA,GAAGC,QACiB;CACpB,IAAMC,IAAgBP,EAAM,wBAAwB,GAC9C,CAACQ,GAAYC,KAAiBP,EAAM,SAA4B,IAAI,GACpEQ,IAAOF,MAAe,MAEtBG,IAAaT,EAAM,OAAiC,IAAI,GACxDU,IAAaV,EAAM,OAA8B,IAAI,GAKrDW,IAAkBX,EAAM,OAAO,EAAK,GACpCY,IAAgBZ,EAAM,OAAqB,IAAI,GAC/Ca,IAAeb,EAAM,OAA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AU,IAOtBlB,EAAc,YAAY,QAAM,aAAaA,EAAc,OAAO,GACtE,EAAc,UAAU,iBAAiB;GAEvC,AADA,EAAc,UAAU,MACxB,EAAgB,UAAU;EAC5B,GAAG,CAAC;CACN,GAEMmB,UAAoB;EAExB,AAAIpB,EAAgB,WAGpBJ,GAAe,MAAYmB,MAAW,UAAUA,IAAS,OAAQ;CACnE,GAEMM,UAAmB;EACvB,GAAe,MAAYN,MAAW,UAAU,OAAOA,CAAO;CAChE,GAEMO,UAAoB;EAIxB,AAHAlB,EAAe,GACfC,EAAe,GAEfT,GAAe,MAAYmB,MAAW,UAAU,OAAO,OAAQ;CACjE;CAEA,OACE,kBAAC,QAAD;EACO;EACL,WAAWQ,EAAG,8CAA8CC,CAAS;EACrE,GAAI/B;EAHN,UAAA;GAKGgC;GACD,kBAAC,UAAD;IACE,KAAKhB;IACL,MAAK;IACL,cAAYiB;IACZ,iBAAe7B;IACf,oBAAkBH;IAClB,WAAW6B,EACT,0HACA,wDACAI,CACF;IACA,eAAeR;IACf,aAAaA;IACb,gBAAgBH;IAChB,gBAAgBE;IAChB,SAASE;IACT,QAAQC;IACR,SAASC;IAET,UAAA,kBAACM,GAAD,EAAU,MAAM,GAAK,CAAA;GACf,CAAA;GACR,kBAAC,QAAD;IAAM,IAAIlC;IAAe,QAAA;IACtB,UAAAmC;GACG,CAAA;GACLhC,KACC,kBAACiC,GAAD;IAAiB;IACf,UAAA,kBAAC,OAAD;KACE,KAAKlB;KACL,eAAY;KACZ,+BAA4B;KAC5B,cAAW;KACX,GAAImB;KACJ,WAAU;KACV,gBAAgBf;KAChB,gBAAgBE;KAEf,UAAAW;IACE,CAAA;GACC,CAAA;EAEN;;AAEV;AAEA,EAAU,cAAc"}
|
|
1
|
+
{"version":3,"file":"InfoLabel.mjs","names":["useId","useId$1","React","SHOW_DELAY","HIDE_DELAY","InfoLabel","props","descriptionId","openReason","setOpenReason","open","triggerRef","surfaceRef","pointerPressRef","pressTimerRef","showTimerRef","hideTimerRef","clearShowTimer","clearHideTimer","close","usePopupPosition","useDismiss","triggerRefs","useMergedRefs","setReference","surfaceRefs","setFloating","scheduleHide","reason","handlePointerEnter","event","handlePointerLeave","handlePointerDown","handleFocus","handleBlur","handleClick","cn","infoLabelClassNames","className","label","infoButtonLabel","focusRing","InfoIcon","info","Portal","floatingProps"],"sources":["../../../src/components/data-display/InfoLabel.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { infoLabelClassNames } from '../../lib/classNames';\nimport { focusRing } from '../../lib/styles';\nimport { InfoIcon } from '../../lib/icons';\nimport { useId } from '../../hooks/useId';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { Portal } from '../portal/Portal';\n\n/** Properties for the InfoLabel component. */\nexport interface InfoLabelProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Primary label text to display. */\n label: string;\n /**\n * Additional information about the label. It describes the info button\n * (`aria-describedby`, available from the first render) and is shown in a popup on hover,\n * keyboard focus or click.\n */\n info: string;\n /**\n * Accessible name of the info button. Localise it here.\n * @default 'Information'\n */\n infoButtonLabel?: string;\n /** Ref to the root `<span>`. */\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/** Why the popup is open: a click pins it; hover and keyboard focus open it transiently. */\ntype OpenReason = 'hover' | 'focus' | 'click';\n\n/** Hover delay before the popup opens, and before it closes after the pointer leaves (ms). */\nconst SHOW_DELAY = 250;\nconst HIDE_DELAY = 250;\n\ntype Timer = ReturnType<typeof setTimeout>;\n\n/**\n * A label with an info button that reveals additional information (a \"toggletip\").\n *\n * - The info button is a `<button type=\"button\">` named `infoButtonLabel` (\"Information\"). The\n * info text is rendered inline in a `hidden` element and linked with `aria-describedby`, so it is\n * announced from the first render (also after server rendering), whether the popup is open or not.\n * - The visual popup is portaled only while open. It is `aria-hidden` because it duplicates the\n * description, and it holds no focusable content, so focus stays on the button.\n * - Opens on keyboard focus (not on focus that comes from a pointer press), on hover after a\n * short delay (the popup itself can be hovered) and on click. A click pins it: a click while it is\n * open because of hover or focus keeps it open, a click on a pinned popup closes it.\n * - Closes on Escape, on a press outside, when focus moves elsewhere and — unless pinned — when\n * the pointer leaves or the button loses focus (WCAG 1.4.13). A popup opened by hover that then\n * receives keyboard focus stays open while the button keeps focus, even after the pointer leaves.\n *\n * @example\n * <InfoLabel label=\"Password\" info=\"Use at least 8 characters.\" />\n */\nexport const InfoLabel = ({\n label,\n info,\n infoButtonLabel = 'Information',\n className,\n ref,\n ...props\n}: InfoLabelProps) => {\n const descriptionId = useId('info-label-description');\n const [openReason, setOpenReason] = React.useState<OpenReason | null>(null);\n const open = openReason !== null;\n\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const surfaceRef = React.useRef<HTMLDivElement | null>(null);\n /**\n * Set by a pointer press on the button, so the focus that follows does not open the popup. It\n * lasts only for the event turn of the press (see `handlePointerDown`).\n */\n const pointerPressRef = React.useRef(false);\n const pressTimerRef = React.useRef<Timer | null>(null);\n const showTimerRef = React.useRef<Timer | null>(null);\n const hideTimerRef = React.useRef<Timer | null>(null);\n\n const clearShowTimer = () => {\n if (showTimerRef.current !== null) clearTimeout(showTimerRef.current);\n showTimerRef.current = null;\n };\n const clearHideTimer = () => {\n if (hideTimerRef.current !== null) clearTimeout(hideTimerRef.current);\n hideTimerRef.current = null;\n };\n\n React.useEffect(\n () => () => {\n if (pressTimerRef.current !== null) clearTimeout(pressTimerRef.current);\n if (showTimerRef.current !== null) clearTimeout(showTimerRef.current);\n if (hideTimerRef.current !== null) clearTimeout(hideTimerRef.current);\n },\n [],\n );\n\n const close = () => {\n clearShowTimer();\n clearHideTimer();\n setOpenReason(null);\n };\n\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open,\n side: 'top',\n align: 'center',\n offset: 8,\n });\n const { layerId } = useDismiss({\n open,\n onDismiss: close,\n refs: [triggerRef, surfaceRef],\n anchorRef: triggerRef,\n focusOutside: true,\n });\n const triggerRefs = useMergedRefs<HTMLButtonElement>(triggerRef, setReference);\n const surfaceRefs = useMergedRefs<HTMLDivElement>(surfaceRef, setFloating);\n\n /** Pointer left the button or the popup: a hover-opened popup closes after a delay. */\n const scheduleHide = () => {\n clearShowTimer();\n clearHideTimer();\n hideTimerRef.current = setTimeout(() => {\n hideTimerRef.current = null;\n setOpenReason((reason) => (reason === 'hover' ? null : reason));\n }, HIDE_DELAY);\n };\n\n const handlePointerEnter = (event: React.PointerEvent) => {\n if (event.pointerType === 'touch') return;\n clearHideTimer();\n if (open || showTimerRef.current !== null) return;\n showTimerRef.current = setTimeout(() => {\n showTimerRef.current = null;\n setOpenReason((reason) => reason ?? 'hover');\n }, SHOW_DELAY);\n };\n\n const handlePointerLeave = (event: React.PointerEvent) => {\n if (event.pointerType === 'touch') return;\n scheduleHide();\n };\n\n const handlePointerDown = () => {\n pointerPressRef.current = true;\n // A press focuses the button (where it does) as the default action of `mousedown`, in the same\n // event turn. Forget the press after that turn: a press that does not focus the button (Safari\n // and Firefox on macOS, iOS) and ends without a click (dragged off, or a touch that becomes a\n // scroll) must not turn a later keyboard focus into pointer focus. A touch tap dispatches its\n // compatibility `mousedown` (and the focus) after the touch ends; that `mousedown` sets the\n // flag again.\n if (pressTimerRef.current !== null) clearTimeout(pressTimerRef.current);\n pressTimerRef.current = setTimeout(() => {\n pressTimerRef.current = null;\n pointerPressRef.current = false;\n }, 0);\n };\n\n const handleFocus = () => {\n // Keyboard focus opens; focus that comes from a pointer press waits for the click.\n if (pointerPressRef.current) return;\n // A popup opened by hover becomes focus-owned, so it stays while the button has focus even\n // after the pointer leaves (WCAG 1.4.13 persistent). A pinned popup stays pinned.\n setOpenReason((reason) => (reason === 'click' ? reason : 'focus'));\n };\n\n const handleBlur = () => {\n setOpenReason((reason) => (reason === 'focus' ? null : reason));\n };\n\n const handleClick = () => {\n clearShowTimer();\n clearHideTimer();\n // Closed → pinned; open because of hover or focus → pinned; pinned → closed.\n setOpenReason((reason) => (reason === 'click' ? null : 'click'));\n };\n\n return (\n <span\n ref={ref}\n className={cn(\n infoLabelClassNames.root,\n 'inline-flex items-center gap-1 text-body-1',\n className,\n )}\n {...props}\n >\n {label}\n <button\n ref={triggerRefs}\n type=\"button\"\n aria-label={infoButtonLabel}\n aria-expanded={open}\n aria-describedby={descriptionId}\n className={cn(\n infoLabelClassNames.infoButton,\n 'inline-flex size-4 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 text-muted-foreground',\n 'not-disabled:not-aria-disabled:hover:text-foreground',\n focusRing,\n )}\n onPointerDown={handlePointerDown}\n onMouseDown={handlePointerDown}\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onClick={handleClick}\n >\n <InfoIcon size={16} />\n </button>\n <span id={descriptionId} hidden>\n {info}\n </span>\n {open && (\n <Portal layerId={layerId}>\n <div\n ref={surfaceRefs}\n aria-hidden=\"true\"\n data-wave-infolabel-surface=\"\"\n data-state=\"open\"\n {...floatingProps}\n className={cn(\n infoLabelClassNames.info,\n 'w-max max-w-xs rounded-md border border-border bg-background px-3 py-2 text-caption-1 text-foreground shadow-16',\n )}\n onPointerEnter={handlePointerEnter}\n onPointerLeave={handlePointerLeave}\n >\n {info}\n </div>\n </Portal>\n )}\n </span>\n );\n};\n\nInfoLabel.displayName = 'InfoLabel';\n"],"mappings":";;;;;;;;;;;;;AAkCA,IAAMG,IAAa,KACbC,IAAa,KAsBNC,KAAa,EACxB,UACA,SACA,qBAAkB,eAClB,cACA,QACA,GAAGC,QACiB;CACpB,IAAMC,IAAgBP,EAAM,wBAAwB,GAC9C,CAACQ,GAAYC,KAAiBP,EAAM,SAA4B,IAAI,GACpEQ,IAAOF,MAAe,MAEtBG,IAAaT,EAAM,OAAiC,IAAI,GACxDU,IAAaV,EAAM,OAA8B,IAAI,GAKrDW,IAAkBX,EAAM,OAAO,EAAK,GACpCY,IAAgBZ,EAA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time.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../hooks/useEventCallback.cjs"),
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../lib/classNames.cjs"),s=require("../../hooks/useEventCallback.cjs"),c=require("../../hooks/useControllable.cjs"),l=require("../../hooks/useId.cjs"),u=require("../../lib/direction.cjs"),d=require("../../lib/focus.cjs"),f=require("../../hooks/useRovingTabIndex.cjs"),p=require("../../hooks/useMergedRefs.cjs"),m=require("../../lib/styles.cjs"),h=require("./List.registry.cjs");let g=require("react");g=e.__toESM(g,1);let _=require("react/jsx-runtime");var v=g.createContext(null);v.displayName=`ListContext`;var y=null;function b(){return y??={mode:`list`,selectedValues:new Set,toggleItem:()=>{},getTabIndex:()=>-1,registry:new h.ListRegistry},y}function x(e){return g.useContext(v)||(r.reportMissingContext(e,`a List`),b())}var S=[];function C(e){r.warnOnce(`List:duplicate:${e}`,`List: several items share the value "${e}". Item values must be unique within a List; items with the same value are selected (and tab stops) together.`)}function w(e){return n.flattenChildren(e).some(({node:e})=>n.isElementOfType(e,L)&&i.slotRendersContent(e.props.action))}var T=[d.FOCUSABLE_SELECTOR,`[data-list-action]`,`label`,`[role="button"]`,`[role="link"]`,`[role="checkbox"]`,`[role="switch"]`,`[role="radio"]`,`[role="menuitem"]`,`[role="textbox"]`,`[role="combobox"]`,`[role="slider"]`,`[role="spinbutton"]`].join(`, `);function E(e){let t=e.currentTarget,n=e.target;if(!n||typeof n.nodeType!=`number`||!t.contains(n))return!0;let r=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement??null;for(;r&&r!==t;r=r.parentElement)if(r.matches(T))return!0;return!1}function D(e){return e.ctrlKey||e.altKey||e.metaKey?!1:e.key===`Enter`||e.key===` `}var O=new Set([`textbox`,`searchbox`,`combobox`,`spinbutton`,`slider`]),k=new Set([`button`,`checkbox`,`color`,`file`,`hidden`,`image`,`radio`,`reset`,`submit`]);function A(e){let t=e.getAttribute(`role`);if(t!==null&&O.has(t))return!0;let n=e.localName;return n===`textarea`||n===`select`?!0:n===`input`?!k.has(e.type):e.matches(`[contenteditable]:not([contenteditable="false"])`)}function j(e){return Array.from(e.querySelectorAll(d.FOCUSABLE_SELECTOR)).filter(e=>d.isFocusable(e))}function M(e){if(!e.parentElement)return-1;let t=0;for(let n=e.previousElementSibling;n;n=n.previousElementSibling)t++;return t}function N(e,t){let n=null,r=null,i=null,a=0;for(let o=e.firstElementChild;o;o=o.nextElementSibling,a++){if(t.value!==void 0&&o.getAttribute(`data-roving-value`)===t.value){n=o;break}a===t.index&&(r=o),i=o}let o=n??r??(t.index>=0?i:null);return o?o.hasAttribute(`tabindex`)?o:j(o)[0]??null:null}function P(e){for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(t.hasAttribute(`data-list-action`))return t;return null}function F(e){let t=[];for(let n of j(e)){let r=A(n)?e:n;t.includes(r)||t.push(r)}return t}var I=e=>{let{selectable:n=!1,selectionMode:i,selectedItems:s,defaultSelectedItems:l,onSelectionChange:u,selectedItem:d,defaultSelectedItem:m,onSelectedItemChange:y,className:b,children:x,ref:T,onKeyDown:E,onKeyDownCapture:D,onFocus:O,...k}=e;i===`multi`&&r.warnDeprecated(`List`,`selectionMode="multi"`,`selectionMode="multiple"`);let A=i===`multiple`||i===`multi`,j=g.useMemo(()=>!A&&d!==void 0?d===null?S:[d]:s,[A,d,s]),M=g.useMemo(()=>!A&&m!=null?[m]:l??S,[A,m,l]),[P,F]=c.useControllable(j,M,e=>{let t=[...e];u?.(t),A||y?.(t[0]??null)}),[I]=g.useState(()=>new h.ListRegistry);g.useLayoutEffect(()=>{I.setActive(n)},[I,n]);let L=g.useSyncExternalStore(I.subscribe,I.getSnapshot,I.getServerSnapshot),R=g.useMemo(()=>L?P.filter(e=>L.valueSet.has(e)):P,[L,P]),z=g.useMemo(()=>new Set(R),[R]),B=n&&(L?L.hasActions:w(x)),V=n?B?`grid`:`listbox`:`list`,H=L?L.values.find(e=>z.has(e))??null:R[0]??null,{containerProps:U,getTabIndex:W}=f.useRovingTabIndex({activeValue:H,orientation:`vertical`,typeahead:(L?.count??0)>7,tabStop:`active`,itemSelector:`:scope > [data-roving-value]`}),{ref:G,onKeyDown:K,onKeyDownCapture:q,onFocus:J}=U,Y=g.useRef(null),X=p.useMergedRefs(T,n?G:null,Y);g.useLayoutEffect(()=>{let e=I.takeFocusLoss(),t=Y.current;if(!e||!t)return;let n=t.ownerDocument,r=n.activeElement;r&&r!==n.body&&r.isConnected||N(t,e)?.focus()},[V,I]),g.useLayoutEffect(()=>{I.syncOrder(Y.current)});let Z=g.useCallback(e=>{F(t=>{let n=I.prune(t),r=n.includes(e);return A?r?n.filter(t=>t!==e):[...n,e]:r?[]:[e]})},[A,I,F]),Q=L?.duplicates??S;g.useEffect(()=>{for(let e of Q)C(e)},[Q]);let $=R.length;g.useEffect(()=>{n&&!A&&$>1&&r.warnOnce(`List:single-several-selected`,`List: a single-selection list (selectionMode "single") received ${$} selected items. Pass one value with \`selectedItem\`, or use selectionMode="multiple".`)},[n,A,$]);let ee=g.useMemo(()=>({mode:V,selectedValues:z,toggleItem:Z,getTabIndex:W,registry:I}),[V,z,Z,W,I]),te=V===`grid`?`div`:`ul`,ne=V===`grid`?`grid`:V===`listbox`?`listbox`:`list`;return(0,_.jsx)(v.Provider,{value:ee,children:(0,_.jsx)(te,{role:ne,"aria-multiselectable":n&&A?!0:void 0,className:t.cn(o.listClassNames.root,`m-0 list-none p-0`,b),...k,ref:X,"data-roving-container":n?``:void 0,onKeyDown:n?a.composeEventHandlers(E,K):E,onKeyDownCapture:n?a.composeEventHandlers(D,q):D,onFocus:n?a.composeEventHandlers(O,J,{checkDefaultPrevented:!1}):O,children:x})})};I.displayName=`List`;var L=({value:e,action:n,className:r,children:c,onClick:d,onKeyDown:f,ref:h,...v})=>{let{mode:y,selectedValues:b,toggleItem:S,getTabIndex:C,registry:w}=x(`ListItem`),T=l.useId(`list-item`),O=e||void 0,k=O??T,N=i.slotRendersContent(n),[I]=g.useState(()=>({})),L=g.useRef(null),R=p.useMergedRefs(h,L);g.useLayoutEffect(()=>{w.set(I,{value:O,hasAction:N,element:L})},[w,I,O,N]),g.useLayoutEffect(()=>()=>w.delete(I),[w,I]);let z=s.useEventCallback(e=>{let t=e.parentElement;w.recordFocusLoss({value:O,index:t?M(t):-1})});g.useLayoutEffect(()=>{let e=L.current;return()=>{if(!e)return;let t=e.ownerDocument.activeElement;t&&e.contains(t)&&w.recordFocusLoss({value:O,index:M(e)})}},[w,O]);let B=O!==void 0&&b.has(O),H=y!==`list`,U=()=>{O!==void 0&&S(O)},W=e=>{E(e)||U()},G=e=>{E(e)||D(e)&&(e.preventDefault(),U())},K=e=>{let t=e.currentTarget,n=e.target,r=P(t);if(!r||!r.contains(n)){if(n!==t)return;if(D(e)){e.preventDefault(),U();return}let i=u.getArrowIntent(e.key,{orientation:`horizontal`,dir:u.getDirection(t)})===`next`&&r?F(r)[0]:void 0;i&&(e.preventDefault(),i.focus());return}if(n!==r&&A(n)){e.key===`Escape`&&(e.preventDefault(),r.focus());return}if(n===r&&(e.key===`Enter`||e.key===`F2`)){let t=j(r).find(e=>A(e));t&&(e.preventDefault(),t.focus());return}let i=u.getArrowIntent(e.key,{orientation:`horizontal`,dir:u.getDirection(t)});if(!i)return;e.preventDefault();let a=F(r),o=a.indexOf(n);i===`next`?a[o+1]?.focus():o>0?a[o-1].focus():t.focus()},q=y===`grid`?`div`:`li`,J=y===`grid`?`div`:`span`,Y=y===`grid`?`row`:y===`listbox`?`option`:`listitem`,X=H?{"aria-selected":B,tabIndex:C(k),"data-roving-value":k,"data-selected":B?``:void 0,onClick:a.composeEventHandlers(d,W),onKeyDown:a.composeEventHandlers(f,y===`grid`?K:G)}:{onClick:d,onKeyDown:f};return(0,_.jsxs)(q,{role:Y,className:t.cn(o.listItemClassNames.root,`flex items-center border-b border-border px-4 py-2 text-body-1`,H&&[`relative cursor-pointer`,`focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring`],H&&(B?[`bg-subtle-selected before:absolute before:inset-y-2 before:start-0 before:w-0.5 before:rounded-full before:bg-primary`,m.forcedColors.selectedContainer]:`hover:bg-subtle-hover`),r),...v,ref:R,...X,children:[(0,_.jsx)(J,{role:y===`grid`?`gridcell`:void 0,className:t.cn(o.listItemClassNames.content,`min-w-0 flex-1`),children:c}),N&&(0,_.jsx)(V,{grid:y===`grid`,onRemovedWithFocus:z,children:i.materialiseSlotContent(n)})]})};L.displayName=`ListItem`;var R=[`[data-roving-container]`,...[`toolbar`,`radiogroup`,`listbox`,`grid`,`treegrid`,`tablist`,`menu`,`menubar`,`tree`].map(e=>`[role="${e}"]`)].join(`, `),z=[`tabindex`,`href`,`contenteditable`,`controls`];function B(e){let t=new Map,n=new WeakSet,r=()=>{for(let n of t.keys())e.contains(n)||t.delete(n);for(let r of e.querySelectorAll(d.FOCUSABLE_SELECTOR)){let i=r.getAttribute(`tabindex`);if(i===`-1`||n.has(r))continue;let a=r.closest(R);a&&e.contains(a)||(t.set(r,i),r.setAttribute(`tabindex`,`-1`))}};if(r(),typeof MutationObserver>`u`)return()=>{};let i=new MutationObserver(e=>{let a=new Set;for(let n of e){let e=n.target;n.attributeName===`tabindex`&&t.has(e)&&a.add(e)}for(let e of a){let r=e.getAttribute(`tabindex`);r!==`-1`&&r===t.get(e)?(t.delete(e),n.add(e)):t.set(e,r)}r(),i.takeRecords()});return i.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:z}),()=>{i.disconnect();for(let[e,n]of t)n===null?e.removeAttribute(`tabindex`):e.setAttribute(`tabindex`,n);t.clear()}}function V({grid:e,onRemovedWithFocus:n,children:r}){let i=g.useRef(null);return g.useLayoutEffect(()=>{let e=i.current;return()=>{if(!e)return;let t=e.ownerDocument.activeElement;t&&e.contains(t)&&n(e)}},[n,e]),g.useLayoutEffect(()=>{let t=i.current;return e&&t?B(t):void 0},[e]),(0,_.jsx)(e?`div`:`span`,{ref:i,role:e?`gridcell`:void 0,tabIndex:e?-1:void 0,"data-list-action":``,className:t.cn(o.listItemClassNames.action,`ms-2 shrink-0`,e&&`focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring`),children:r})}V.displayName=`ListActionCell`;var H=Object.assign(I,{Item:L});exports.List=H,exports.ListItem=L;
|
|
2
2
|
//# sourceMappingURL=List.cjs.map
|