@mortenbrudvik/waveui 0.4.0 → 0.7.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 +1221 -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 +50 -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 +47 -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 +53 -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 +37 -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 +45 -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 +66 -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 +65 -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 +63 -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 +131 -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 +157 -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 +134 -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 +32 -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 +28 -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 +52 -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 +32 -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 +104 -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 +381 -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 +48 -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 +71 -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 +147 -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 +144 -0
- package/dist/components/feedback/MessageBar.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 +45 -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 +72 -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 +47 -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 +60 -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.mjs +347 -0
- package/dist/components/feedback/Toast.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 +96 -0
- package/dist/components/input/Checkbox.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 +236 -0
- package/dist/components/input/ColorPicker.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 +187 -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 +340 -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 +128 -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 +200 -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 +81 -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 +28 -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 +169 -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 +139 -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 +196 -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 +205 -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 +33 -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 +79 -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 +157 -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 +113 -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 +92 -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 +249 -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 +32 -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 +292 -0
- package/dist/components/input/TimePicker.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 +96 -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 +236 -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 +121 -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 +205 -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 +54 -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 +62 -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 +269 -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 +39 -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 +238 -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.mjs +220 -0
- package/dist/components/layout/Tree.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 +144 -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 +58 -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 +127 -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 +41 -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 +231 -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 +308 -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 +89 -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 +51 -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 +276 -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 +110 -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 +204 -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 +180 -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 +192 -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 +365 -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 +181 -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 +160 -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 +45 -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 +51 -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 +489 -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 +99 -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 +38 -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/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 +24 -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 +9099 -0
- package/dist/index.d.ts +7688 -1027
- package/dist/index.mjs +91 -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/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/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/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,110 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { warnOnce as t } from "../../lib/dev.mjs";
|
|
4
|
+
import { useEventCallback as n } from "../../hooks/useEventCallback.mjs";
|
|
5
|
+
import { useControllable as r } from "../../hooks/useControllable.mjs";
|
|
6
|
+
import { focusableDisabledProps as i, preventIfDisabled as a } from "../../lib/aria.mjs";
|
|
7
|
+
import { disabledStyles as o, focusRing as s, forcedColors as c } from "../../lib/styles.mjs";
|
|
8
|
+
import { ChevronDoubleLeftIcon as l, ChevronDoubleRightIcon as u, ChevronLeftIcon as d, ChevronRightIcon as f } from "../../lib/icons.mjs";
|
|
9
|
+
import * as p from "react";
|
|
10
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
11
|
+
//#region src/components/navigation/Pagination.tsx
|
|
12
|
+
function g(e, t) {
|
|
13
|
+
switch (e) {
|
|
14
|
+
case "first": return "First page";
|
|
15
|
+
case "previous": return "Previous page";
|
|
16
|
+
case "next": return "Next page";
|
|
17
|
+
case "last": return "Last page";
|
|
18
|
+
default: return `Page ${t}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function _(e, t) {
|
|
22
|
+
return Number.isFinite(e) ? Math.max(0, Math.floor(e)) : t;
|
|
23
|
+
}
|
|
24
|
+
function v(e, t) {
|
|
25
|
+
return Number.isNaN(e) ? 1 : Math.min(Math.max(1, Math.floor(e)), t);
|
|
26
|
+
}
|
|
27
|
+
function y(e, t, n = 1, r = 1) {
|
|
28
|
+
let i = _(e, 0);
|
|
29
|
+
if (i < 1) return [];
|
|
30
|
+
let a = v(t, i), o = _(n, 1), s = _(r, 1);
|
|
31
|
+
if (i <= s * 2 + o * 2 + 3) return Array.from({ length: i }, (e, t) => t + 1);
|
|
32
|
+
let c = /* @__PURE__ */ new Set();
|
|
33
|
+
for (let e = 1; e <= Math.min(s, i); e++) c.add(e);
|
|
34
|
+
for (let e = Math.max(1, i - s + 1); e <= i; e++) c.add(e);
|
|
35
|
+
for (let e = Math.max(1, a - o); e <= Math.min(i, a + o); e++) c.add(e);
|
|
36
|
+
c.add(a);
|
|
37
|
+
let l = Array.from(c).sort((e, t) => e - t), u = [], d = (e, t) => {
|
|
38
|
+
let n = t - e;
|
|
39
|
+
n === 2 ? u.push(e + 1) : n > 2 && u.push("ellipsis");
|
|
40
|
+
}, f = 0;
|
|
41
|
+
for (let e of l) d(f, e), u.push(e), f = e;
|
|
42
|
+
return d(f, i + 1), u;
|
|
43
|
+
}
|
|
44
|
+
var b = e("inline-flex items-center justify-center rounded border cursor-pointer transition-colors motion-reduce:transition-none", s, o), x = "border-border bg-transparent text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed", S = e("border-primary bg-primary text-primary-foreground", c.selectedLeaf), C = "wave-rtl:-scale-x-100", w = ({ currentPage: o, defaultCurrentPage: s = 1, totalPages: c, onPageChange: w, siblingCount: T = 1, boundaryCount: E = 1, showPreviousNext: D = !0, showFirstLast: O = !1, disabled: k = !1, size: A = "medium", getItemAriaLabel: j = g, className: M, ref: N, ...P }) => {
|
|
45
|
+
let [F, I, L] = r(o, s), R = n(w), z = _(c, 0), B = !L, [V, H] = p.useState(null), U = B && V !== null ? V : F, W = v(U, Math.max(1, z));
|
|
46
|
+
B && z >= 1 && !Object.is(W, U) && H(W), p.useEffect(() => {
|
|
47
|
+
Number.isInteger(c) || t("Pagination:totalPages", `Pagination: \`totalPages\` must be an integer, received ${String(c)}. Fractional values are rounded down; NaN and infinite values render nothing.`);
|
|
48
|
+
}, [c]);
|
|
49
|
+
let G = p.useRef(null);
|
|
50
|
+
if (p.useEffect(() => {
|
|
51
|
+
if (z < 1) return;
|
|
52
|
+
if (Object.is(W, F)) {
|
|
53
|
+
G.current = null;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let e = `${String(F)}->${W}`;
|
|
57
|
+
G.current !== e && (G.current = e, R(W));
|
|
58
|
+
}, [
|
|
59
|
+
W,
|
|
60
|
+
F,
|
|
61
|
+
z,
|
|
62
|
+
R
|
|
63
|
+
]), z < 1) return null;
|
|
64
|
+
let K = y(z, W, T, E), q = A === "small" ? "h-7 w-7 text-caption-1" : "h-8 w-8 text-body-1", J = W <= 1, Y = W >= z, X = (e) => {
|
|
65
|
+
k || e < 1 || e > z || (H(null), I(e), R(e));
|
|
66
|
+
}, Z = (t, n, r, o) => /* @__PURE__ */ m("li", { children: /* @__PURE__ */ m("button", {
|
|
67
|
+
type: "button",
|
|
68
|
+
"aria-label": j(t, n, !1),
|
|
69
|
+
disabled: k,
|
|
70
|
+
...k ? {} : i(r),
|
|
71
|
+
onClick: a(r, () => X(n)),
|
|
72
|
+
className: e(b, q, x),
|
|
73
|
+
children: o
|
|
74
|
+
}) });
|
|
75
|
+
return /* @__PURE__ */ m("nav", {
|
|
76
|
+
ref: N,
|
|
77
|
+
"aria-label": "Pagination",
|
|
78
|
+
...P,
|
|
79
|
+
className: e(M),
|
|
80
|
+
children: /* @__PURE__ */ h("ol", {
|
|
81
|
+
className: "m-0 flex list-none items-center gap-1 p-0",
|
|
82
|
+
children: [
|
|
83
|
+
O && Z("first", 1, J, /* @__PURE__ */ m(l, { className: C })),
|
|
84
|
+
D && Z("previous", Math.max(1, W - 1), J, /* @__PURE__ */ m(d, { className: C })),
|
|
85
|
+
K.map((t, n) => t === "ellipsis" ? /* @__PURE__ */ m("li", {
|
|
86
|
+
"aria-hidden": "true",
|
|
87
|
+
children: /* @__PURE__ */ m("span", {
|
|
88
|
+
className: e("inline-flex items-center justify-center text-muted-foreground", q),
|
|
89
|
+
children: "…"
|
|
90
|
+
})
|
|
91
|
+
}, n < K.length / 2 ? "start-ellipsis" : "end-ellipsis") : /* @__PURE__ */ m("li", { children: /* @__PURE__ */ m("button", {
|
|
92
|
+
type: "button",
|
|
93
|
+
"aria-label": j("page", t, t === W),
|
|
94
|
+
"aria-current": t === W ? "page" : void 0,
|
|
95
|
+
disabled: k,
|
|
96
|
+
onClick: () => X(t),
|
|
97
|
+
className: e(b, q, t === W ? S : x),
|
|
98
|
+
children: t
|
|
99
|
+
}) }, t)),
|
|
100
|
+
D && Z("next", Math.min(z, W + 1), Y, /* @__PURE__ */ m(f, { className: C })),
|
|
101
|
+
O && Z("last", z, Y, /* @__PURE__ */ m(u, { className: C }))
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
w.displayName = "Pagination";
|
|
107
|
+
//#endregion
|
|
108
|
+
export { w as Pagination, y as getPaginationRange };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=Pagination.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.mjs","names":["React","defaultGetItemAriaLabel","type","page","toCount","value","fallback","clampPage","pageCount","getPaginationRange","total","totalPages","current","currentPage","siblings","siblingCount","boundaries","boundaryCount","i","pages","sorted","a","b","range","fillGap","gap","after","before","previous","pageNumber","itemBaseClasses","cn","focusRing","disabledStyles","idleItemClasses","currentItemClasses","forcedColors","chevronClasses","Pagination","controlledPage","rest","rawPage","setPage","isControlled","useControllable","defaultCurrentPage","emitPageChange","useEventCallback","onPageChange","uncontrolled","storedClamp","setStoredClamp","basePage","warnOnce","notifiedClampRef","clamp","sizeClasses","size","atStart","atEnd","goTo","disabled","target","renderNavButton","getItemAriaLabel","focusableDisabledProps","unavailable","preventIfDisabled","icon","className","showFirstLast","ChevronDoubleLeftIcon","showPreviousNext","ChevronLeftIcon","item","index","ChevronRightIcon","ChevronDoubleRightIcon"],"sources":["../../../src/components/navigation/Pagination.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { focusableDisabledProps, preventIfDisabled } from '../../lib/aria';\nimport { warnOnce } from '../../lib/dev';\nimport {\n ChevronDoubleLeftIcon,\n ChevronDoubleRightIcon,\n ChevronLeftIcon,\n ChevronRightIcon,\n} from '../../lib/icons';\nimport { disabledStyles, focusRing, forcedColors } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\n\n/** The kinds of Pagination buttons, as passed to `getItemAriaLabel`. */\nexport type PaginationItemType = 'first' | 'previous' | 'page' | 'next' | 'last';\n\n/** Properties for the Pagination component. */\nexport interface PaginationProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {\n /**\n * Controlled current page number (1-based). A value outside `1…totalPages` is shown clamped, and\n * `onPageChange` is called once with the clamped page so the parent can resync. The prop stays\n * authoritative: if the parent keeps the old value, it is shown again once it is back in range.\n */\n currentPage?: number;\n /**\n * Default current page for uncontrolled usage. When the current page falls outside\n * `1…totalPages` (for example because `totalPages` shrinks), the clamped page is kept and\n * reported once through `onPageChange`; it does not jump back when `totalPages` grows again.\n * @default 1\n */\n defaultCurrentPage?: number;\n /**\n * Total number of pages. A fractional value is rounded down; `0`, a negative value or `NaN`\n * renders nothing (non-integer values log a development warning).\n */\n totalPages: number;\n /**\n * Called with the target page whenever a page, First, Previous, Next or Last button is activated\n * — also when the current page is activated again (0.4 semantics) — and once when the current\n * page is clamped into `1…totalPages`.\n */\n onPageChange?: (page: number) => void;\n /** Number of page buttons to show on each side of the current page.\n * @default 1\n */\n siblingCount?: number;\n /**\n * Number of page buttons to always show at the start and end. With `0` no page is pinned there,\n * and an ellipsis marks the pages before or after the shown range.\n * @default 1\n */\n boundaryCount?: number;\n /** Whether to show previous/next navigation buttons.\n * @default true\n */\n showPreviousNext?: boolean;\n /** Whether to show first/last page navigation buttons.\n * @default false\n */\n showFirstLast?: boolean;\n /**\n * Whether the entire pagination control is disabled (every button gets the native `disabled`\n * attribute). Boundary buttons that point at the current page are not natively disabled: they use\n * `aria-disabled=\"true\"` and stay focusable.\n * @default false\n */\n disabled?: boolean;\n /** Size of the pagination buttons.\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n /**\n * Accessible name of each button, for localization. `page` is the page the button navigates to\n * (for `'page'` items, the page it shows); `selected` is `true` for the current page. Defaults:\n * `'First page'`, `'Previous page'`, `` `Page ${page}` ``, `'Next page'`, `'Last page'`. The\n * landmark itself is named with `aria-label` (default `'Pagination'`) or `aria-labelledby`.\n */\n getItemAriaLabel?: (type: PaginationItemType, page: number, selected: boolean) => string;\n /** Ref to the root `<nav>` element. */\n ref?: React.Ref<HTMLElement>;\n}\n\nfunction defaultGetItemAriaLabel(type: PaginationItemType, page: number): string {\n switch (type) {\n case 'first':\n return 'First page';\n case 'previous':\n return 'Previous page';\n case 'next':\n return 'Next page';\n case 'last':\n return 'Last page';\n default:\n return `Page ${page}`;\n }\n}\n\n/** A non-negative integer count, or `fallback` for `NaN`/`±Infinity`. */\nfunction toCount(value: number, fallback: number): number {\n return Number.isFinite(value) ? Math.max(0, Math.floor(value)) : fallback;\n}\n\n/** `page` rounded down and clamped into `1…pageCount` (`NaN` → 1). */\nfunction clampPage(page: number, pageCount: number): number {\n if (Number.isNaN(page)) return 1;\n return Math.min(Math.max(1, Math.floor(page)), pageCount);\n}\n\n/**\n * The page items Pagination renders: page numbers and `'ellipsis'` markers, in order.\n *\n * Always shows `boundaryCount` pages at each end and `siblingCount` pages on each side of the\n * current page; a gap of exactly one page is filled with that page instead of an ellipsis. With\n * `boundaryCount` 0 no page is pinned at the ends, so a gap before the first or after the last\n * shown page gets an ellipsis too. When `totalPages` fits into those slots\n * (`2 × boundaryCount + 2 × siblingCount + 3`), every page is listed. `currentPage` is clamped\n * into `1…totalPages`; `totalPages < 1` returns `[]`.\n *\n * Exported from this module for tests and custom pagers; not part of the package barrel.\n *\n * @example getPaginationRange(20, 10) // [1, 'ellipsis', 9, 10, 11, 'ellipsis', 20]\n * @example getPaginationRange(20, 10, 1, 0) // ['ellipsis', 9, 10, 11, 'ellipsis']\n */\nexport function getPaginationRange(\n totalPages: number,\n currentPage: number,\n siblingCount = 1,\n boundaryCount = 1,\n): Array<number | 'ellipsis'> {\n const total = toCount(totalPages, 0);\n if (total < 1) return [];\n const current = clampPage(currentPage, total);\n const siblings = toCount(siblingCount, 1);\n const boundaries = toCount(boundaryCount, 1);\n\n // boundaries + siblings + current + 2 ellipsis slots\n const totalSlots = boundaries * 2 + siblings * 2 + 3;\n if (total <= totalSlots) {\n return Array.from({ length: total }, (_, i) => i + 1);\n }\n\n const pages = new Set<number>();\n for (let i = 1; i <= Math.min(boundaries, total); i++) pages.add(i);\n for (let i = Math.max(1, total - boundaries + 1); i <= total; i++) pages.add(i);\n for (let i = Math.max(1, current - siblings); i <= Math.min(total, current + siblings); i++) {\n pages.add(i);\n }\n pages.add(current);\n\n const sorted = Array.from(pages).sort((a, b) => a - b);\n const range: Array<number | 'ellipsis'> = [];\n /** Marks the pages between `before` and `after` (both exclusive). */\n const fillGap = (before: number, after: number) => {\n const gap = after - before;\n if (gap === 2) {\n // A single missing page: show it instead of an ellipsis.\n range.push(before + 1);\n } else if (gap > 2) {\n range.push('ellipsis');\n }\n };\n // The ends are virtual neighbours 0 and total + 1, so with `boundaryCount` 0 (no page pinned at\n // an end) a gap before the first or after the last shown page is marked as well.\n let previous = 0;\n for (const pageNumber of sorted) {\n fillGap(previous, pageNumber);\n range.push(pageNumber);\n previous = pageNumber;\n }\n fillGap(previous, total + 1);\n return range;\n}\n\nconst itemBaseClasses = cn(\n 'inline-flex items-center justify-center rounded border cursor-pointer transition-colors motion-reduce:transition-none',\n focusRing,\n disabledStyles,\n);\n\nconst idleItemClasses =\n 'border-border bg-transparent text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed';\n\nconst currentItemClasses = cn(\n 'border-primary bg-primary text-primary-foreground',\n forcedColors.selectedLeaf,\n);\n\n/**\n * Directional glyphs point the other way in right-to-left layouts (C-LOGICAL), by the glyph's own\n * direction: Tailwind's bare variant would also match inside an LTR subtree of an RTL page.\n */\nconst chevronClasses = 'wave-rtl:-scale-x-100';\n\n/**\n * Page navigation for paged content: page buttons with ellipses, optional Previous/Next and\n * First/Last buttons, inside a `<nav>` landmark named \"Pagination\" (override with `aria-label`).\n *\n * `onPageChange` is an event callback: it fires on every activation, including the current page.\n * Boundary buttons that point at the current page use `aria-disabled` and keep focus; the whole\n * control is disabled with `disabled`. Button names are localized with `getItemAriaLabel`.\n */\nconst Pagination = ({\n currentPage: controlledPage,\n defaultCurrentPage = 1,\n totalPages,\n onPageChange,\n siblingCount = 1,\n boundaryCount = 1,\n showPreviousNext = true,\n showFirstLast = false,\n disabled = false,\n size = 'medium',\n getItemAriaLabel = defaultGetItemAriaLabel,\n className,\n ref,\n ...rest\n}: PaginationProps) => {\n // `isControlled` is useControllable's sticky mode: a pager that was ever controlled stays\n // controlled, also when `currentPage` later becomes `undefined` (misuse; the hook warns and\n // reports `defaultCurrentPage`, which is then clamped like a controlled value).\n const [rawPage, setPage, isControlled] = useControllable(controlledPage, defaultCurrentPage);\n const emitPageChange = useEventCallback(onPageChange);\n\n const pageCount = toCount(totalPages, 0);\n const uncontrolled = !isControlled;\n // Uncontrolled: a clamp is stored, so the page does not jump back to the out-of-range value — and\n // out of sync with the last `onPageChange` — when `totalPages` grows again. Navigation clears it.\n // Controlled: the prop always wins.\n const [storedClamp, setStoredClamp] = React.useState<number | null>(null);\n const basePage = uncontrolled && storedClamp !== null ? storedClamp : rawPage;\n const page = clampPage(basePage, Math.max(1, pageCount));\n if (uncontrolled && pageCount >= 1 && !Object.is(page, basePage)) {\n setStoredClamp(page);\n }\n\n React.useEffect(() => {\n if (!Number.isInteger(totalPages)) {\n warnOnce(\n 'Pagination:totalPages',\n `Pagination: \\`totalPages\\` must be an integer, received ${String(totalPages)}. ` +\n 'Fractional values are rounded down; NaN and infinite values render nothing.',\n );\n }\n }, [totalPages]);\n\n // Tell the parent about a clamped page once per clamp (also under StrictMode's double effects). A\n // stored uncontrolled clamp keeps `page !== rawPage`, so growing `totalPages` does not re-notify;\n // neither does a pass through `totalPages={0}` (nothing rendered, the last clamp is kept).\n const notifiedClampRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n if (pageCount < 1) return;\n if (Object.is(page, rawPage)) {\n notifiedClampRef.current = null;\n return;\n }\n const clamp = `${String(rawPage)}->${page}`;\n if (notifiedClampRef.current === clamp) return;\n notifiedClampRef.current = clamp;\n emitPageChange(page);\n }, [page, rawPage, pageCount, emitPageChange]);\n\n if (pageCount < 1) return null;\n\n const range = getPaginationRange(pageCount, page, siblingCount, boundaryCount);\n const sizeClasses = size === 'small' ? 'h-7 w-7 text-caption-1' : 'h-8 w-8 text-body-1';\n const atStart = page <= 1;\n const atEnd = page >= pageCount;\n\n /** Event callback semantics: every activation of an available button emits (C-NAMING). */\n const goTo = (target: number) => {\n if (disabled || target < 1 || target > pageCount) return;\n setStoredClamp(null);\n setPage(target);\n emitPageChange(target);\n };\n\n const renderNavButton = (\n type: Exclude<PaginationItemType, 'page'>,\n target: number,\n unavailable: boolean,\n icon: React.ReactNode,\n ) => (\n <li>\n <button\n type=\"button\"\n aria-label={getItemAriaLabel(type, target, false)}\n disabled={disabled}\n {...(disabled ? {} : focusableDisabledProps(unavailable))}\n onClick={preventIfDisabled(unavailable, () => goTo(target))}\n className={cn(itemBaseClasses, sizeClasses, idleItemClasses)}\n >\n {icon}\n </button>\n </li>\n );\n\n return (\n <nav ref={ref} aria-label=\"Pagination\" {...rest} className={cn(className)}>\n <ol className=\"m-0 flex list-none items-center gap-1 p-0\">\n {showFirstLast &&\n renderNavButton(\n 'first',\n 1,\n atStart,\n <ChevronDoubleLeftIcon className={chevronClasses} />,\n )}\n {showPreviousNext &&\n renderNavButton(\n 'previous',\n Math.max(1, page - 1),\n atStart,\n <ChevronLeftIcon className={chevronClasses} />,\n )}\n\n {range.map((item, index) =>\n item === 'ellipsis' ? (\n <li\n key={index < range.length / 2 ? 'start-ellipsis' : 'end-ellipsis'}\n aria-hidden=\"true\"\n >\n <span\n className={cn(\n 'inline-flex items-center justify-center text-muted-foreground',\n sizeClasses,\n )}\n >\n …\n </span>\n </li>\n ) : (\n <li key={item}>\n <button\n type=\"button\"\n aria-label={getItemAriaLabel('page', item, item === page)}\n aria-current={item === page ? 'page' : undefined}\n disabled={disabled}\n onClick={() => goTo(item)}\n className={cn(\n itemBaseClasses,\n sizeClasses,\n item === page ? currentItemClasses : idleItemClasses,\n )}\n >\n {item}\n </button>\n </li>\n ),\n )}\n\n {showPreviousNext &&\n renderNavButton(\n 'next',\n Math.min(pageCount, page + 1),\n atEnd,\n <ChevronRightIcon className={chevronClasses} />,\n )}\n {showFirstLast &&\n renderNavButton(\n 'last',\n pageCount,\n atEnd,\n <ChevronDoubleR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CP,EACE,SACA,GACAL,GACA,kBAACa,GAAD,EAAuB,WAAWlC,EAAiB,CAAA,CACrD;IACDmC,KACCT,EACE,YACA,KAAK,IAAI,GAAG5D,IAAO,CAAC,GACpBuD,GACA,kBAACe,GAAD,EAAiB,WAAWpC,EAAiB,CAAA,CAC/C;IAEDd,EAAM,KAAK,GAAM,MAChBmD,MAAS,aACP,kBAAC,MAAD;KAEE,eAAY;KAEZ,UAAA,kBAAC,QAAD;MACE,WAAW3C,EACT,iEACAyB,CACF;MACD,UAAA;KAEK,CAAA;IACJ,GAXGmB,IAAQpD,EAAM,SAAS,IAAI,mBAAmB,cAWjD,IAEJ,kBAAC,MAAD,EAAA,UACE,kBAAC,UAAD;KACE,MAAK;KACL,cAAYyC,EAAiB,QAAQU,GAAMA,MAASvE,CAAI;KACxD,gBAAcuE,MAASvE,IAAO,SAAS,KAAA;KAC7B;KACV,eAAeyD,EAAKc,CAAI;KACxB,WAAW3C,EACTD,GACA0B,GACAkB,MAASvE,IAAOgC,IAAqBD,CACvC;KAEC,UAAAwC;IACK,CAAA,EACN,GAfKA,CAeL,CAER;IAECF,KACCT,EACE,QACA,KAAK,IAAIvD,GAAWL,IAAO,CAAC,GAC5BwD,GACA,kBAACiB,GAAD,EAAkB,WAAWvC,EAAiB,CAAA,CAChD;IACDiC,KACCP,EACE,QACAvD,GACAmD,GACA,kBAACkB,GAAD,EAAwB,WAAWxC,EAAiB,CAAA,CACtD;GACA;;CACD,CAAA;AAET;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/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../hooks/useEventCallback.cjs"),o=require("../../hooks/useControllable.cjs"),s=require("../../hooks/useId.cjs"),c=require("../../lib/styles.cjs"),l=require("../../lib/icons.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f=`Completed:`,p=`Error:`,m=[],h=()=>m;function g(){let e=new Map,t=new Set,n=m,r=()=>{if(n.length!==e.size)return!1;let t;for(let r of n){let n=e.get(r);if(!n||t&&!(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING))return!1;t=n}return!0},i=()=>{if(r())return;let i=Array.from(e.entries()).sort(([,e],[,t])=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1).map(([e])=>e);i.length===n.length&&i.every((e,t)=>e===n[t])||(n=i,t.forEach(e=>e()))};return{register(t,n){return e.set(t,n),i(),()=>{e.get(t)===n&&e.delete(t),i()}},subscribe(e){return t.add(e),()=>{t.delete(e)}},getOrder:()=>n,sync:i}}var _=u.createContext(null),v=u.createContext(null),y=()=>{},b={activeStep:0,select:y,orientation:`horizontal`,linear:!1,order:m,childCount:0,completedLabel:f,errorLabel:p,register:()=>y,sync:y};function x(e){return u.useContext(_)||(r.reportMissingContext(e,`Stepper`),b)}function S(e){let t=0;return n.flattenChildren(e).map(({key:e,node:n})=>({key:e,node:n,slot:u.isValidElement(n)?t++:null}))}var C=`inline-flex items-center justify-center`,w=t.cn(`bg-success`,c.forcedColors.fill),T=`bg-border forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none`,E=({label:e,description:n,icon:r,disabled:a=!1,completed:o,error:f=!1,index:p,className:m,onClick:h,ref:g,..._})=>{let{activeStep:y,select:b,orientation:S,linear:E,order:D,childCount:O,completedLabel:k,errorLabel:A,register:j,sync:M}=x(`Stepper.Step`),N=u.useContext(v),P=s.useId(`wave-step`),F=`${P}-label`,I=`${P}-description`,L=u.useCallback(e=>e?j(P,e):void 0,[j,P]);u.useLayoutEffect(()=>{M()});let R=D.indexOf(P),z=p??(R===-1?N??0:R),B=z>=(R===-1?O:D.length)-1,V=z===y,H=o??z<y,U=!a&&(!E||z<=y+1),W=S===`horizontal`,G=e=>{if(!U){e.preventDefault();return}h?.(e),!e.defaultPrevented&&b(z)},K=e=>{e.target===e.currentTarget&&(e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault())},q=e=>{e.target===e.currentTarget&&e.key===` `&&(e.preventDefault(),e.currentTarget.click())},J=f?A:H?k:``,Y=J?`${J} ${z+1}.`:`${z+1}.`,X=!!r&&i.slotRendersContent(r),Z;Z=f?(0,d.jsx)(l.DismissIcon,{}):H&&!X?(0,d.jsx)(l.CheckIcon,{}):X?i.renderSlot(r,`span`,C,{"aria-hidden":!0}):(0,d.jsx)(`span`,{className:`text-caption-1 font-semibold`,children:z+1});let Q=f?`text-error`:V?`text-primary`:H?`text-success`:`text-foreground`;return(0,d.jsx)(`li`,{ref:L,className:t.cn(`flex min-w-0`,W&&!B&&`flex-1`),children:(0,d.jsxs)(`div`,{ref:g,"data-active":V?``:void 0,"data-completed":H?``:void 0,"data-error":f?``:void 0,"data-disabled":a?``:void 0,..._,className:t.cn(W?`flex flex-1 items-center`:`flex flex-1 flex-col`,m),children:[(0,d.jsxs)(`div`,{role:`button`,tabIndex:U?0:-1,"aria-current":V?`step`:void 0,"aria-disabled":!U||void 0,"aria-labelledby":F,"aria-describedby":n?I:void 0,onClick:G,onKeyDown:K,onKeyUp:q,className:t.cn(`relative flex rounded`,W?`flex-col items-center gap-1`:`items-center gap-3`,c.focusRing,U?`cursor-pointer`:`cursor-default`,a&&`opacity-50`),children:[(0,d.jsx)(`span`,{"aria-hidden":`true`,className:t.cn(`flex size-8 shrink-0 items-center justify-center rounded-full border-2 transition-colors motion-reduce:transition-none`,f?`border-error bg-error-tint text-error-tint-foreground`:V?t.cn(`border-primary bg-primary text-primary-foreground`,c.forcedColors.selectedLeaf):H?`border-success bg-success-tint text-success-tint-foreground`:`border-border bg-background text-muted-foreground`),children:Z}),(0,d.jsxs)(`span`,{className:t.cn(`flex flex-col`,W&&`items-center text-center`),children:[(0,d.jsxs)(`span`,{id:F,className:t.cn(`font-semibold`,W?`text-caption-1 whitespace-nowrap`:`text-body-1`,Q),children:[(0,d.jsx)(`span`,{className:`sr-only`,children:Y}),` `,e]}),n&&(0,d.jsx)(`span`,{id:I,className:t.cn(`text-muted-foreground`,W?`text-caption-2 whitespace-nowrap`:`text-caption-1`),children:n})]})]}),!B&&(0,d.jsx)(`div`,{"data-wave-stepper-connector":``,"aria-hidden":`true`,className:t.cn(`transition-colors motion-reduce:transition-none`,W?`mx-2 h-0.5 flex-1`:`my-1 ms-3.75 min-h-6 w-0.5`,H?w:T)})]})})};E.displayName=`Step`;var D=({activeStep:e,defaultActiveStep:n=0,onStepChange:r,orientation:i=`horizontal`,linear:s=!1,statusLabels:c,className:l,children:m,ref:y,...b})=>{let x=c?.completed??f,C=c?.error??p,[w,T]=o.useControllable(e,n),E=a.useEventCallback(r),D=u.useCallback(e=>{T(e),E(e)},[T,E]),[O]=u.useState(g),k=u.useSyncExternalStore(O.subscribe,O.getOrder,h),A=u.useRef(null);u.useEffect(()=>{let e=A.current;if(!e)return;let t=new MutationObserver(O.sync);return t.observe(e,{childList:!0,subtree:!0}),()=>t.disconnect()},[O]);let j=u.useMemo(()=>S(m),[m]),M=j.filter(e=>e.slot!==null).length,N=u.useMemo(()=>({activeStep:w,select:D,orientation:i,linear:s,order:k,childCount:M,completedLabel:x,errorLabel:C,register:O.register,sync:O.sync}),[w,D,i,s,k,M,x,C,O]),P=i===`horizontal`;return(0,d.jsx)(_.Provider,{value:N,children:(0,d.jsx)(`div`,{ref:y,role:`group`,"aria-label":`Progress`,"data-orientation":i,...b,className:t.cn(`flex`,P?`flex-row items-start`:`flex-col`,l),children:(0,d.jsx)(`ol`,{ref:A,role:`list`,className:t.cn(`m-0 flex list-none p-0`,P?`flex-1 flex-row items-start`:`flex-col`),children:j.map(e=>e.slot===null?e.node:(0,d.jsx)(v.Provider,{value:e.slot,children:e.node},e.key))})})})};D.displayName=`Stepper`;var O=Object.assign(D,{Step:E});exports.Stepper=O,exports.StepperStep=E;
|
|
2
|
+
//# sourceMappingURL=Stepper.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stepper.cjs","names":["React","flattenChildren","cn","forcedColors","useId","slotRendersContent","DismissIcon","CheckIcon","renderSlot","focusRing","useControllable","useEventCallback","require_runtime","require_cn","require_children","require_dev","require_slot","require_useEventCallback","require_useControllable","require_useId","require_styles","require_icons","react","react_jsx_runtime","DEFAULT_COMPLETED_LABEL","DEFAULT_ERROR_LABEL","EMPTY_ORDER","getServerOrder","createStepRegistry","elements","listeners","order","isCurrent","previous","key","element","sync","next","a","b","i","listener","StepperContext","StepSlotContext","noop","INERT_CONTEXT","useStepperContext","componentName","numberChildren","slot","children","node","indicatorSlotClasses","connectorCompletedClasses","connectorPendingClasses","StepperStep","indexProp","rest","slotIndex","labelId","descriptionId","registerItem","register","position","index","isLast","childCount","isActive","activeStep","isCompleted","completed","isClickable","disabled","linear","horizontal","orientation","activate","event","onClick","select","handleKeyDown","handleKeyUp","status","error","errorLabel","completedLabel","statusText","hasIcon","icon","indicator","toneClass","className","description","label","StepperRoot","controlledStep","statusLabels","setActiveStep","defaultActiveStep","emitStepChange","onStepChange","step","registry","listRef","list","observer","items","item","context","Stepper"],"sources":["../../../src/components/navigation/Stepper.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { reportMissingContext } from '../../lib/dev';\nimport { CheckIcon, DismissIcon } from '../../lib/icons';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport type { Slot } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { Orientation } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\n\n/** Properties for the Stepper component. */\nexport interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Controlled index (0-based) of the currently active step. */\n activeStep?: number;\n /** Default active step index for uncontrolled usage.\n * @default 0\n */\n defaultActiveStep?: number;\n /**\n * Called with the step index whenever a step is activated (click, Enter or Space) — also when the\n * active step is activated again (0.4 semantics). Not called for disabled or unreachable steps.\n */\n onStepChange?: (step: number) => void;\n /** Layout orientation of the stepper.\n * @default 'horizontal'\n */\n orientation?: Orientation;\n /**\n * Whether navigation is restricted to sequential steps: only steps up to the one after the active\n * step can be activated; later steps are `aria-disabled` and leave the tab order.\n * @default false\n */\n linear?: boolean;\n /**\n * Visually hidden status text read before the number of a completed or error step (\"Completed:\n * 2. Profile\"), for localization: `{ completed: 'Fullført:', error: 'Feil:' }`. A label that is\n * not given keeps its English default; `''` leaves that status out of the step names.\n * @default { completed: 'Completed:', error: 'Error:' }\n */\n statusLabels?: { completed?: string; error?: string };\n /** Ref to the root `<div>` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst DEFAULT_COMPLETED_LABEL = 'Completed:';\nconst DEFAULT_ERROR_LABEL = 'Error:';\n\n/** Properties for the Step sub-component. */\nexport interface StepProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Label text for the step. */\n label: string;\n /** Optional description text displayed below the label (the step button's description). */\n description?: string;\n /**\n * Custom icon to display in the step indicator (`Slot<'span'>`: a node, or a slot object for full\n * control). Decorative: rendered with `aria-hidden=\"true\"`; the step number stays in the name. A\n * falsy icon (`''`, `0`) or a list of nothing is no icon: the step shows its number (or its check\n * mark when completed).\n */\n icon?: Slot<'span'>;\n /**\n * Whether the step is disabled and non-interactive.\n * @default false\n */\n disabled?: boolean;\n /** Whether the step is marked as completed. Defaults to `true` for steps before the active step. */\n completed?: boolean;\n /**\n * Whether the step is in an error state.\n * @default false\n */\n error?: boolean;\n /**\n * Zero-based position of the step. Normally derived from the step's position in the Stepper\n * (Fragments, conditional steps and wrapper components included); set it only to override that.\n * In server HTML (and the first client render, before the steps register) each Stepper child\n * counts as one step, so steps inside a wrapper component that renders more or fewer than one\n * step are numbered correctly only after hydration; set `index` on them to pin the server HTML.\n */\n index?: number;\n /** Ref to the step's root `<div>` (rendered inside the step's `<li>`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ---------------------------------------------------------------------------\n// Step registry: a useId-keyed descendant list in DOM order\n// ---------------------------------------------------------------------------\n\nconst EMPTY_ORDER: readonly string[] = [];\nconst getServerOrder = () => EMPTY_ORDER;\n\ninterface StepRegistry {\n /** Registers a step's list item under its key; returns the cleanup that unregisters it. */\n register: (key: string, element: HTMLElement) => () => void;\n subscribe: (listener: () => void) => () => void;\n /** Keys of the registered steps in DOM order (a new array only when the order changed). */\n getOrder: () => readonly string[];\n /**\n * Re-reads the DOM order and notifies subscribers when it changed. Cheap when nothing moved (one\n * pass over adjacent pairs), so every Step calls it after each of its commits. A commit that\n * re-renders all n steps (an `activeStep` change) therefore costs n passes, O(n²) position\n * checks, and the root's observer adds one pass per list mutation (indicator swaps included):\n * negligible for step counts a stepper can show. If that ever matters, coalesce the per-step calls\n * into one pass per commit (a dirty flag set by the steps, flushed once) — keeping this per-step\n * call or the observer as the path for commits in which the root does not re-render.\n */\n sync: () => void;\n}\n\nfunction createStepRegistry(): StepRegistry {\n const elements = new Map<string, HTMLElement>();\n const listeners = new Set<() => void>();\n let order = EMPTY_ORDER;\n\n /** Whether `order` still lists exactly the registered elements, in DOM order. */\n const isCurrent = () => {\n if (order.length !== elements.size) return false;\n let previous: HTMLElement | undefined;\n for (const key of order) {\n const element = elements.get(key);\n if (!element) return false;\n if (\n previous &&\n !(previous.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING)\n ) {\n return false;\n }\n previous = element;\n }\n return true;\n };\n\n const sync = () => {\n if (isCurrent()) return;\n const next = Array.from(elements.entries())\n .sort(([, a], [, b]) =>\n a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n )\n .map(([key]) => key);\n if (next.length === order.length && next.every((key, i) => key === order[i])) return;\n order = next;\n listeners.forEach((listener) => listener());\n };\n\n return {\n register(key, element) {\n elements.set(key, element);\n sync();\n return () => {\n if (elements.get(key) === element) elements.delete(key);\n sync();\n };\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n getOrder: () => order,\n sync,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Contexts\n// ---------------------------------------------------------------------------\n\ninterface StepperContextValue {\n activeStep: number;\n /** Activates a step: updates the (uncontrolled) state and calls `onStepChange`. */\n select: (step: number) => void;\n orientation: Orientation;\n linear: boolean;\n /** Registered step keys in DOM order (empty on the server and before the first commit). */\n order: readonly string[];\n /** Number of element children after flattening Fragments (the pre-registration step count). */\n childCount: number;\n /** Resolved `statusLabels.completed`. */\n completedLabel: string;\n /** Resolved `statusLabels.error`. */\n errorLabel: string;\n register: StepRegistry['register'];\n sync: StepRegistry['sync'];\n}\n\nconst StepperContext = React.createContext<StepperContextValue | null>(null);\n\n/**\n * Position of a Stepper child among the element children (Fragments flattened), set by the root\n * around each child. It numbers the steps on the server and in the first render; after mount the\n * registry's DOM order takes over (it also covers wrappers that render several steps or none, which\n * the slot numbering gets wrong — documented on `Stepper` and `StepProps.index`).\n */\nconst StepSlotContext = React.createContext<number | null>(null);\n\nconst noop = () => {};\nconst INERT_CONTEXT: StepperContextValue = {\n activeStep: 0,\n select: noop,\n orientation: 'horizontal',\n linear: false,\n order: EMPTY_ORDER,\n childCount: 0,\n completedLabel: DEFAULT_COMPLETED_LABEL,\n errorLabel: DEFAULT_ERROR_LABEL,\n register: () => noop,\n sync: noop,\n};\n\n/**\n * Reads the Stepper context; a Step outside a Stepper throws in development and logs once in\n * production, where it renders inert (C-CONTEXT).\n */\nfunction useStepperContext(componentName: string): StepperContextValue {\n const context = React.useContext(StepperContext);\n if (context) return context;\n reportMissingContext(componentName, 'Stepper');\n return INERT_CONTEXT;\n}\n\n/** A Stepper child after flattening; an element carries its position among the elements. */\ninterface StepperChild {\n key: string;\n node: React.ReactNode;\n slot: number | null;\n}\n\n/**\n * The Stepper's children with Fragments flattened at any depth (`flattenChildren`: keys unique,\n * `null`/booleans dropped) and every element numbered in order.\n */\nfunction numberChildren(children: React.ReactNode): StepperChild[] {\n let slot = 0;\n return flattenChildren(children).map(({ key, node }) => ({\n key,\n node,\n slot: React.isValidElement(node) ? slot++ : null,\n }));\n}\n\n// ---------------------------------------------------------------------------\n// Step\n// ---------------------------------------------------------------------------\n\nconst indicatorSlotClasses = 'inline-flex items-center justify-center';\n\n/**\n * Connector colors. A connector is drawn by its background only, which forced colors replace with\n * Canvas, so it opts out there: a completed one is painted `Highlight` (`forcedColors.fill`), the\n * others `CanvasText`, like a Slider rail.\n */\nconst connectorCompletedClasses = cn('bg-success', forcedColors.fill);\nconst connectorPendingClasses =\n 'bg-border forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none';\n\n/**\n * One step of a {@link Stepper}: a `role=\"button\"` step (indicator, label, optional description)\n * inside its own `<li>`, followed by a connector unless it is the last step. `ref`, `className` and\n * rest props land on the step's root `<div>`; `onClick` runs on activation by mouse, Enter or Space\n * (not for disabled or unreachable steps). Must be rendered inside a `Stepper` (throws in\n * development otherwise). Flat name `StepperStep`, importable from React Server Components.\n */\nconst StepperStep = ({\n label,\n description,\n icon,\n disabled = false,\n completed,\n error = false,\n index: indexProp,\n className,\n onClick,\n ref,\n ...rest\n}: StepProps) => {\n const {\n activeStep,\n select,\n orientation,\n linear,\n order,\n childCount,\n completedLabel,\n errorLabel,\n register,\n sync,\n } = useStepperContext('Stepper.Step');\n const slotIndex = React.useContext(StepSlotContext);\n const key = useId('wave-step');\n const labelId = `${key}-label`;\n const descriptionId = `${key}-description`;\n\n // The list item registers itself under this step's id; the registry sorts by DOM position.\n const registerItem = React.useCallback(\n (element: HTMLLIElement | null) => (element ? register(key, element) : undefined),\n [register, key],\n );\n // A keyed reorder moves list items without re-running their ref callbacks, and a wrapper component\n // can reorder its own steps without re-rendering the root: re-read the DOM order after every commit\n // of this step (a changed order re-renders before paint). Moves that re-render no step at all\n // (reused elements) are caught by the root's MutationObserver.\n React.useLayoutEffect(() => {\n sync();\n });\n\n const position = order.indexOf(key);\n const index = indexProp ?? (position !== -1 ? position : (slotIndex ?? 0));\n const stepCount = position !== -1 ? order.length : childCount;\n const isLast = index >= stepCount - 1;\n const isActive = index === activeStep;\n const isCompleted = completed ?? index < activeStep;\n const isClickable = !disabled && (!linear || index <= activeStep + 1);\n const horizontal = orientation === 'horizontal';\n\n /**\n * The single activation path for mouse and keyboard (Enter/Space dispatch a click): an\n * unavailable step does nothing — neither the consumer `onClick` nor `onStepChange` runs; a\n * consumer `onClick` that calls `preventDefault()` suppresses the step change (C-COMPOSE).\n */\n const activate = (event: React.MouseEvent<HTMLDivElement>) => {\n if (!isClickable) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n if (event.defaultPrevented) return;\n select(index);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.target !== event.currentTarget) return;\n if (event.key === 'Enter') {\n event.preventDefault();\n event.currentTarget.click();\n } else if (event.key === ' ') {\n // Space activates on keyup, like a native button; stop the page from scrolling.\n event.preventDefault();\n }\n };\n\n const handleKeyUp = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.target !== event.currentTarget || event.key !== ' ') return;\n event.preventDefault();\n event.currentTarget.click();\n };\n\n const status = error ? errorLabel : isCompleted ? completedLabel : '';\n const statusText = status ? `${status} ${index + 1}.` : `${index + 1}.`;\n\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in Menu,\n // Nav, Tree and Avatar, and so is a collection whose items render nothing: the step keeps its\n // number or check mark. The check does not consume a generator: renderSlot still renders it.\n const hasIcon = !!icon && slotRendersContent(icon);\n let indicator: React.ReactNode;\n if (error) {\n indicator = <DismissIcon />;\n } else if (isCompleted && !hasIcon) {\n indicator = <CheckIcon />;\n } else if (hasIcon) {\n indicator = renderSlot(icon, 'span', indicatorSlotClasses, { 'aria-hidden': true });\n } else {\n indicator = <span className=\"text-caption-1 font-semibold\">{index + 1}</span>;\n }\n\n const toneClass = error\n ? 'text-error'\n : isActive\n ? 'text-primary'\n : isCompleted\n ? 'text-success'\n : 'text-foreground';\n\n return (\n <li ref={registerItem} className={cn('flex min-w-0', horizontal && !isLast && 'flex-1')}>\n <div\n ref={ref}\n data-active={isActive ? '' : undefined}\n data-completed={isCompleted ? '' : undefined}\n data-error={error ? '' : undefined}\n data-disabled={disabled ? '' : undefined}\n {...rest}\n className={cn(horizontal ? 'flex flex-1 items-center' : 'flex flex-1 flex-col', className)}\n >\n <div\n role=\"button\"\n tabIndex={isClickable ? 0 : -1}\n aria-current={isActive ? 'step' : undefined}\n aria-disabled={isClickable ? undefined : true}\n aria-labelledby={labelId}\n aria-describedby={description ? descriptionId : undefined}\n onClick={activate}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n className={cn(\n 'relative flex rounded',\n horizontal ? 'flex-col items-center gap-1' : 'items-center gap-3',\n focusRing,\n isClickable ? 'cursor-pointer' : 'cursor-default',\n disabled && 'opacity-50',\n )}\n >\n <span\n aria-hidden=\"true\"\n className={cn(\n 'flex size-8 shrink-0 items-center justify-center rounded-full border-2 transition-colors motion-reduce:transition-none',\n error\n ? 'border-error bg-error-tint text-error-tint-foreground'\n : isActive\n ? cn(\n 'border-primary bg-primary text-primary-foreground',\n forcedColors.selectedLeaf,\n )\n : isCompleted\n ? 'border-success bg-success-tint text-success-tint-foreground'\n : 'border-border bg-background text-muted-foreground',\n )}\n >\n {indicator}\n </span>\n <span className={cn('flex flex-col', horizontal && 'items-center text-center')}>\n <span\n id={labelId}\n className={cn(\n 'font-semibold',\n horizontal ? 'text-caption-1 whitespace-nowrap' : 'text-body-1',\n toneClass,\n )}\n >\n <span className=\"sr-only\">{statusText}</span> {label}\n </span>\n {description && (\n <span\n id={descriptionId}\n className={cn(\n 'text-muted-foreground',\n horizontal ? 'text-caption-2 whitespace-nowrap' : 'text-caption-1',\n )}\n >\n {description}\n </span>\n )}\n </span>\n </div>\n {!isLast && (\n <div\n data-wave-stepper-connector=\"\"\n aria-hidden=\"true\"\n className={cn(\n 'transition-colors motion-reduce:transition-none',\n // Vertical: centred under the size-8 circle, (8 - 0.5) / 2 spacing units in, so the\n // offset scales with the circle at any root font size.\n horizontal ? 'mx-2 h-0.5 flex-1' : 'my-1 ms-3.75 min-h-6 w-0.5',\n isCompleted ? connectorCompletedClasses : connectorPendingClasses,\n )}\n />\n )}\n </div>\n </li>\n );\n};\nStepperStep.displayName = 'Step';\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\nconst StepperRoot = ({\n activeStep: controlledStep,\n defaultActiveStep = 0,\n onStepChange,\n orientation = 'horizontal',\n linear = false,\n statusLabels,\n className,\n children,\n ref,\n ...rest\n}: StepperProps) => {\n // Resolved to strings, so an inline `statusLabels` object does not change the context each render.\n const completedLabel = statusLabels?.completed ?? DEFAULT_COMPLETED_LABEL;\n const errorLabel = statusLabels?.error ?? DEFAULT_ERROR_LABEL;\n const [activeStep, setActiveStep] = useControllable(controlledStep, defaultActiveStep);\n const emitStepChange = useEventCallback(onStepChange);\n // Event callback semantics (C-NAMING): every activation emits, also of the active step.\n const select = React.useCallback(\n (step: number) => {\n setActiveStep(step);\n emitStepChange(step);\n },\n [setActiveStep, emitStepChange],\n );\n\n const [registry] = React.useState(createStepRegistry);\n const order = React.useSyncExternalStore(registry.subscribe, registry.getOrder, getServerOrder);\n // Steps re-sync after each of their commits. A move that re-renders no step (a wrapper reordering\n // reused step elements) only shows up in the DOM: observe the list for it (C-HOOKS DOM-derived\n // collection; the callback runs in a microtask, before paint).\n const listRef = React.useRef<HTMLOListElement>(null);\n React.useEffect(() => {\n const list = listRef.current;\n if (!list) return;\n const observer = new MutationObserver(registry.sync);\n observer.observe(list, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [registry]);\n\n const items = React.useMemo(() => numberChildren(children), [children]);\n const childCount = items.filter((item) => item.slot !== null).length;\n\n const context = React.useMemo<StepperContextValue>(\n () => ({\n activeStep,\n select,\n orientation,\n linear,\n order,\n childCount,\n completedLabel,\n errorLabel,\n register: registry.register,\n sync: registry.sync,\n }),\n [\n activeStep,\n select,\n orientation,\n linear,\n order,\n childCount,\n completedLabel,\n errorLabel,\n registry,\n ],\n );\n\n const horizontal = orientation === 'horizontal';\n\n return (\n <StepperContext.Provider value={context}>\n <div\n ref={ref}\n role=\"group\"\n aria-label=\"Progress\"\n data-orientation={orientation}\n {...rest}\n className={cn('flex', horizontal ? 'flex-row items-start' : 'flex-col', className)}\n >\n {/* role=\"list\" is not redundant: WebKit/VoiceOver drops list semantics from a\n `list-style: none` list outside a <nav> unless the role is explicit. */}\n <ol\n ref={listRef}\n role=\"list\"\n className={cn(\n 'm-0 flex list-none p-0',\n horizontal ? 'flex-1 flex-row items-start' : 'flex-col',\n )}\n >\n {items.map((item) =>\n item.slot === null ? (\n item.node\n ) : (\n <StepSlotContext.Provider key={item.key} value={item.slot}>\n {item.node}\n </StepSlotContext.Provider>\n ),\n )}\n </ol>\n </div>\n </StepperContext.Provider>\n );\n};\nStepperRoot.displayName = 'Stepper';\n\n/**\n * A multi-step progress indicator. Steps are `Stepper.Step` children (Fragments, conditional steps\n * and wrapper components are numbered in DOM order) rendered as an ordered list inside a\n * `role=\"group\"` root named \"Progress\" (override with `aria-label`). The active step's button\n * carries `aria-current=\"step\"`; completed and error steps announce their status (\"Completed:\",\n * \"Error:\"; localized with `statusLabels`).\n *\n * Server rendering: before hydration, steps are numbered by their position among the Stepper's\n * children (Fragments flattened), so a wrapper component that renders more or fewer than one step\n * is numbered correctly only after hydration. Pin such steps with `index` if the server HTML must\n * already be exact.\n *\n * Compound access (`Stepper.Step`) needs a client module; React Server Components import the flat\n * name `StepperStep` instead.\n */\nexport const Stepper = /* @__PURE__ */ Object.assign(StepperRoot, { Step: StepperStep });\n\n// Flat name of `Stepper.Step` (C-COMPOUND).\nexport { StepperStep };\n"],"mappings":"kdA+CA,IAAMwB,EAA0B,aAC1BC,EAAsB,SA2CtBC,EAAiC,CAAC,EAClCC,MAAuBD,EAoB7B,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EAEM5B,EAAaC,IAAgB,aAEnC,OACE,EAAApD,EAAA,IAAA,CAACmB,EAAe,SAAhB,CAAyB,MAAOkE,EAC9B,UAAA,EAAArF,EAAA,IAAA,CAAC,MAAD,CACO,MACL,KAAK,QACL,aAAW,WACX,mBAAkBoD,EAClB,GAAIlB,EACJ,UAAWvD,EAAAA,GAAG,OAAQwE,EAAa,uBAAyB,WAAYiB,CAAS,EAIjF,UAAA,EAAApE,EAAA,IAAA,CAAC,KAAD,CACE,IAAKgF,EACL,KAAK,OACL,UAAWrG,EAAAA,GACT,yBACAwE,EAAa,8BAAgC,UAC/C,EAEC,SAAAgC,EAAM,IAAK,GACVC,EAAK,OAAS,KACZA,EAAK,MAEL,EAAApF,EAAA,IAAA,CAACoB,EAAgB,SAAjB,CAAyC,MAAOgE,EAAK,KAClD,SAAAA,EAAK,IACkB,EAFKA,EAAK,GAEV,CAE9B,CACE,CAAA,CACD,CAAA,CACkB,CAAA,CAE7B,EACA,EAAY,YAAc,UAiB1B,IAAaE,EAA0B,OAAO,OAAOf,EAAa,CAAE,KAAMvC,CAAY,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { flattenChildren as t } from "../../lib/children.mjs";
|
|
4
|
+
import { reportMissingContext as n } from "../../lib/dev.mjs";
|
|
5
|
+
import { renderSlot as r, slotRendersContent as i } from "../../lib/slot.mjs";
|
|
6
|
+
import { useEventCallback as a } from "../../hooks/useEventCallback.mjs";
|
|
7
|
+
import { useControllable as o } from "../../hooks/useControllable.mjs";
|
|
8
|
+
import { useId as s } from "../../hooks/useId.mjs";
|
|
9
|
+
import { focusRing as c, forcedColors as l } from "../../lib/styles.mjs";
|
|
10
|
+
import { CheckIcon as u, DismissIcon as d } from "../../lib/icons.mjs";
|
|
11
|
+
import * as f from "react";
|
|
12
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
13
|
+
//#region src/components/navigation/Stepper.tsx
|
|
14
|
+
var h = "Completed:", g = "Error:", _ = [], v = () => _;
|
|
15
|
+
function y() {
|
|
16
|
+
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = _, r = () => {
|
|
17
|
+
if (n.length !== e.size) return !1;
|
|
18
|
+
let t;
|
|
19
|
+
for (let r of n) {
|
|
20
|
+
let n = e.get(r);
|
|
21
|
+
if (!n || t && !(t.compareDocumentPosition(n) & Node.DOCUMENT_POSITION_FOLLOWING)) return !1;
|
|
22
|
+
t = n;
|
|
23
|
+
}
|
|
24
|
+
return !0;
|
|
25
|
+
}, i = () => {
|
|
26
|
+
if (r()) return;
|
|
27
|
+
let i = Array.from(e.entries()).sort(([, e], [, t]) => e.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1).map(([e]) => e);
|
|
28
|
+
i.length === n.length && i.every((e, t) => e === n[t]) || (n = i, t.forEach((e) => e()));
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
register(t, n) {
|
|
32
|
+
return e.set(t, n), i(), () => {
|
|
33
|
+
e.get(t) === n && e.delete(t), i();
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
subscribe(e) {
|
|
37
|
+
return t.add(e), () => {
|
|
38
|
+
t.delete(e);
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
getOrder: () => n,
|
|
42
|
+
sync: i
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var b = f.createContext(null), x = f.createContext(null), S = () => {}, C = {
|
|
46
|
+
activeStep: 0,
|
|
47
|
+
select: S,
|
|
48
|
+
orientation: "horizontal",
|
|
49
|
+
linear: !1,
|
|
50
|
+
order: _,
|
|
51
|
+
childCount: 0,
|
|
52
|
+
completedLabel: h,
|
|
53
|
+
errorLabel: g,
|
|
54
|
+
register: () => S,
|
|
55
|
+
sync: S
|
|
56
|
+
};
|
|
57
|
+
function w(e) {
|
|
58
|
+
return f.useContext(b) || (n(e, "Stepper"), C);
|
|
59
|
+
}
|
|
60
|
+
function T(e) {
|
|
61
|
+
let n = 0;
|
|
62
|
+
return t(e).map(({ key: e, node: t }) => ({
|
|
63
|
+
key: e,
|
|
64
|
+
node: t,
|
|
65
|
+
slot: f.isValidElement(t) ? n++ : null
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
var E = "inline-flex items-center justify-center", D = e("bg-success", l.fill), O = "bg-border forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none", k = ({ label: t, description: n, icon: a, disabled: o = !1, completed: h, error: g = !1, index: _, className: v, onClick: y, ref: b, ...S }) => {
|
|
69
|
+
let { activeStep: C, select: T, orientation: k, linear: A, order: j, childCount: M, completedLabel: N, errorLabel: P, register: F, sync: I } = w("Stepper.Step"), L = f.useContext(x), R = s("wave-step"), z = `${R}-label`, B = `${R}-description`, V = f.useCallback((e) => e ? F(R, e) : void 0, [F, R]);
|
|
70
|
+
f.useLayoutEffect(() => {
|
|
71
|
+
I();
|
|
72
|
+
});
|
|
73
|
+
let H = j.indexOf(R), U = _ ?? (H === -1 ? L ?? 0 : H), W = U >= (H === -1 ? M : j.length) - 1, G = U === C, K = h ?? U < C, q = !o && (!A || U <= C + 1), J = k === "horizontal", Y = (e) => {
|
|
74
|
+
if (!q) {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
y?.(e), !e.defaultPrevented && T(U);
|
|
79
|
+
}, X = (e) => {
|
|
80
|
+
e.target === e.currentTarget && (e.key === "Enter" ? (e.preventDefault(), e.currentTarget.click()) : e.key === " " && e.preventDefault());
|
|
81
|
+
}, ee = (e) => {
|
|
82
|
+
e.target === e.currentTarget && e.key === " " && (e.preventDefault(), e.currentTarget.click());
|
|
83
|
+
}, Z = g ? P : K ? N : "", te = Z ? `${Z} ${U + 1}.` : `${U + 1}.`, Q = !!a && i(a), $;
|
|
84
|
+
$ = g ? /* @__PURE__ */ p(d, {}) : K && !Q ? /* @__PURE__ */ p(u, {}) : Q ? r(a, "span", E, { "aria-hidden": !0 }) : /* @__PURE__ */ p("span", {
|
|
85
|
+
className: "text-caption-1 font-semibold",
|
|
86
|
+
children: U + 1
|
|
87
|
+
});
|
|
88
|
+
let ne = g ? "text-error" : G ? "text-primary" : K ? "text-success" : "text-foreground";
|
|
89
|
+
return /* @__PURE__ */ p("li", {
|
|
90
|
+
ref: V,
|
|
91
|
+
className: e("flex min-w-0", J && !W && "flex-1"),
|
|
92
|
+
children: /* @__PURE__ */ m("div", {
|
|
93
|
+
ref: b,
|
|
94
|
+
"data-active": G ? "" : void 0,
|
|
95
|
+
"data-completed": K ? "" : void 0,
|
|
96
|
+
"data-error": g ? "" : void 0,
|
|
97
|
+
"data-disabled": o ? "" : void 0,
|
|
98
|
+
...S,
|
|
99
|
+
className: e(J ? "flex flex-1 items-center" : "flex flex-1 flex-col", v),
|
|
100
|
+
children: [/* @__PURE__ */ m("div", {
|
|
101
|
+
role: "button",
|
|
102
|
+
tabIndex: q ? 0 : -1,
|
|
103
|
+
"aria-current": G ? "step" : void 0,
|
|
104
|
+
"aria-disabled": !q || void 0,
|
|
105
|
+
"aria-labelledby": z,
|
|
106
|
+
"aria-describedby": n ? B : void 0,
|
|
107
|
+
onClick: Y,
|
|
108
|
+
onKeyDown: X,
|
|
109
|
+
onKeyUp: ee,
|
|
110
|
+
className: e("relative flex rounded", J ? "flex-col items-center gap-1" : "items-center gap-3", c, q ? "cursor-pointer" : "cursor-default", o && "opacity-50"),
|
|
111
|
+
children: [/* @__PURE__ */ p("span", {
|
|
112
|
+
"aria-hidden": "true",
|
|
113
|
+
className: e("flex size-8 shrink-0 items-center justify-center rounded-full border-2 transition-colors motion-reduce:transition-none", g ? "border-error bg-error-tint text-error-tint-foreground" : G ? e("border-primary bg-primary text-primary-foreground", l.selectedLeaf) : K ? "border-success bg-success-tint text-success-tint-foreground" : "border-border bg-background text-muted-foreground"),
|
|
114
|
+
children: $
|
|
115
|
+
}), /* @__PURE__ */ m("span", {
|
|
116
|
+
className: e("flex flex-col", J && "items-center text-center"),
|
|
117
|
+
children: [/* @__PURE__ */ m("span", {
|
|
118
|
+
id: z,
|
|
119
|
+
className: e("font-semibold", J ? "text-caption-1 whitespace-nowrap" : "text-body-1", ne),
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ p("span", {
|
|
122
|
+
className: "sr-only",
|
|
123
|
+
children: te
|
|
124
|
+
}),
|
|
125
|
+
" ",
|
|
126
|
+
t
|
|
127
|
+
]
|
|
128
|
+
}), n && /* @__PURE__ */ p("span", {
|
|
129
|
+
id: B,
|
|
130
|
+
className: e("text-muted-foreground", J ? "text-caption-2 whitespace-nowrap" : "text-caption-1"),
|
|
131
|
+
children: n
|
|
132
|
+
})]
|
|
133
|
+
})]
|
|
134
|
+
}), !W && /* @__PURE__ */ p("div", {
|
|
135
|
+
"data-wave-stepper-connector": "",
|
|
136
|
+
"aria-hidden": "true",
|
|
137
|
+
className: e("transition-colors motion-reduce:transition-none", J ? "mx-2 h-0.5 flex-1" : "my-1 ms-3.75 min-h-6 w-0.5", K ? D : O)
|
|
138
|
+
})]
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
k.displayName = "Step";
|
|
143
|
+
var A = ({ activeStep: t, defaultActiveStep: n = 0, onStepChange: r, orientation: i = "horizontal", linear: s = !1, statusLabels: c, className: l, children: u, ref: d, ...m }) => {
|
|
144
|
+
let _ = c?.completed ?? h, S = c?.error ?? g, [C, w] = o(t, n), E = a(r), D = f.useCallback((e) => {
|
|
145
|
+
w(e), E(e);
|
|
146
|
+
}, [w, E]), [O] = f.useState(y), k = f.useSyncExternalStore(O.subscribe, O.getOrder, v), A = f.useRef(null);
|
|
147
|
+
f.useEffect(() => {
|
|
148
|
+
let e = A.current;
|
|
149
|
+
if (!e) return;
|
|
150
|
+
let t = new MutationObserver(O.sync);
|
|
151
|
+
return t.observe(e, {
|
|
152
|
+
childList: !0,
|
|
153
|
+
subtree: !0
|
|
154
|
+
}), () => t.disconnect();
|
|
155
|
+
}, [O]);
|
|
156
|
+
let j = f.useMemo(() => T(u), [u]), M = j.filter((e) => e.slot !== null).length, N = f.useMemo(() => ({
|
|
157
|
+
activeStep: C,
|
|
158
|
+
select: D,
|
|
159
|
+
orientation: i,
|
|
160
|
+
linear: s,
|
|
161
|
+
order: k,
|
|
162
|
+
childCount: M,
|
|
163
|
+
completedLabel: _,
|
|
164
|
+
errorLabel: S,
|
|
165
|
+
register: O.register,
|
|
166
|
+
sync: O.sync
|
|
167
|
+
}), [
|
|
168
|
+
C,
|
|
169
|
+
D,
|
|
170
|
+
i,
|
|
171
|
+
s,
|
|
172
|
+
k,
|
|
173
|
+
M,
|
|
174
|
+
_,
|
|
175
|
+
S,
|
|
176
|
+
O
|
|
177
|
+
]), P = i === "horizontal";
|
|
178
|
+
return /* @__PURE__ */ p(b.Provider, {
|
|
179
|
+
value: N,
|
|
180
|
+
children: /* @__PURE__ */ p("div", {
|
|
181
|
+
ref: d,
|
|
182
|
+
role: "group",
|
|
183
|
+
"aria-label": "Progress",
|
|
184
|
+
"data-orientation": i,
|
|
185
|
+
...m,
|
|
186
|
+
className: e("flex", P ? "flex-row items-start" : "flex-col", l),
|
|
187
|
+
children: /* @__PURE__ */ p("ol", {
|
|
188
|
+
ref: A,
|
|
189
|
+
role: "list",
|
|
190
|
+
className: e("m-0 flex list-none p-0", P ? "flex-1 flex-row items-start" : "flex-col"),
|
|
191
|
+
children: j.map((e) => e.slot === null ? e.node : /* @__PURE__ */ p(x.Provider, {
|
|
192
|
+
value: e.slot,
|
|
193
|
+
children: e.node
|
|
194
|
+
}, e.key))
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
A.displayName = "Stepper";
|
|
200
|
+
var j = /* @__PURE__ */ Object.assign(A, { Step: k });
|
|
201
|
+
//#endregion
|
|
202
|
+
export { j as Stepper, k as StepperStep };
|
|
203
|
+
|
|
204
|
+
//# sourceMappingURL=Stepper.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stepper.mjs","names":["useId","useId$1","React","DEFAULT_COMPLETED_LABEL","DEFAULT_ERROR_LABEL","EMPTY_ORDER","getServerOrder","createStepRegistry","elements","listeners","order","isCurrent","previous","key","element","sync","next","a","b","i","listener","StepperContext","StepSlotContext","noop","INERT_CONTEXT","useStepperContext","reportMissingContext","componentName","numberChildren","slot","flattenChildren","children","node","indicatorSlotClasses","connectorCompletedClasses","cn","forcedColors","connectorPendingClasses","StepperStep","indexProp","rest","slotIndex","labelId","descriptionId","registerItem","register","position","index","isLast","childCount","isActive","activeStep","isCompleted","completed","isClickable","disabled","linear","horizontal","orientation","activate","onClick","event","select","handleKeyDown","handleKeyUp","status","error","errorLabel","completedLabel","statusText","hasIcon","icon","slotRendersContent","indicator","DismissIcon","CheckIcon","renderSlot","toneClass","className","description","focusRing","label","StepperRoot","controlledStep","statusLabels","setActiveStep","useControllable","defaultActiveStep","emitStepChange","useEventCallback","onStepChange","step","registry","listRef","list","observer","items","item","context","Stepper"],"sources":["../../../src/components/navigation/Stepper.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { reportMissingContext } from '../../lib/dev';\nimport { CheckIcon, DismissIcon } from '../../lib/icons';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport type { Slot } from '../../lib/slot';\nimport { focusRing, forcedColors } from '../../lib/styles';\nimport type { Orientation } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\n\n/** Properties for the Stepper component. */\nexport interface StepperProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Controlled index (0-based) of the currently active step. */\n activeStep?: number;\n /** Default active step index for uncontrolled usage.\n * @default 0\n */\n defaultActiveStep?: number;\n /**\n * Called with the step index whenever a step is activated (click, Enter or Space) — also when the\n * active step is activated again (0.4 semantics). Not called for disabled or unreachable steps.\n */\n onStepChange?: (step: number) => void;\n /** Layout orientation of the stepper.\n * @default 'horizontal'\n */\n orientation?: Orientation;\n /**\n * Whether navigation is restricted to sequential steps: only steps up to the one after the active\n * step can be activated; later steps are `aria-disabled` and leave the tab order.\n * @default false\n */\n linear?: boolean;\n /**\n * Visually hidden status text read before the number of a completed or error step (\"Completed:\n * 2. Profile\"), for localization: `{ completed: 'Fullført:', error: 'Feil:' }`. A label that is\n * not given keeps its English default; `''` leaves that status out of the step names.\n * @default { completed: 'Completed:', error: 'Error:' }\n */\n statusLabels?: { completed?: string; error?: string };\n /** Ref to the root `<div>` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst DEFAULT_COMPLETED_LABEL = 'Completed:';\nconst DEFAULT_ERROR_LABEL = 'Error:';\n\n/** Properties for the Step sub-component. */\nexport interface StepProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Label text for the step. */\n label: string;\n /** Optional description text displayed below the label (the step button's description). */\n description?: string;\n /**\n * Custom icon to display in the step indicator (`Slot<'span'>`: a node, or a slot object for full\n * control). Decorative: rendered with `aria-hidden=\"true\"`; the step number stays in the name. A\n * falsy icon (`''`, `0`) or a list of nothing is no icon: the step shows its number (or its check\n * mark when completed).\n */\n icon?: Slot<'span'>;\n /**\n * Whether the step is disabled and non-interactive.\n * @default false\n */\n disabled?: boolean;\n /** Whether the step is marked as completed. Defaults to `true` for steps before the active step. */\n completed?: boolean;\n /**\n * Whether the step is in an error state.\n * @default false\n */\n error?: boolean;\n /**\n * Zero-based position of the step. Normally derived from the step's position in the Stepper\n * (Fragments, conditional steps and wrapper components included); set it only to override that.\n * In server HTML (and the first client render, before the steps register) each Stepper child\n * counts as one step, so steps inside a wrapper component that renders more or fewer than one\n * step are numbered correctly only after hydration; set `index` on them to pin the server HTML.\n */\n index?: number;\n /** Ref to the step's root `<div>` (rendered inside the step's `<li>`). */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ---------------------------------------------------------------------------\n// Step registry: a useId-keyed descendant list in DOM order\n// ---------------------------------------------------------------------------\n\nconst EMPTY_ORDER: readonly string[] = [];\nconst getServerOrder = () => EMPTY_ORDER;\n\ninterface StepRegistry {\n /** Registers a step's list item under its key; returns the cleanup that unregisters it. */\n register: (key: string, element: HTMLElement) => () => void;\n subscribe: (listener: () => void) => () => void;\n /** Keys of the registered steps in DOM order (a new array only when the order changed). */\n getOrder: () => readonly string[];\n /**\n * Re-reads the DOM order and notifies subscribers when it changed. Cheap when nothing moved (one\n * pass over adjacent pairs), so every Step calls it after each of its commits. A commit that\n * re-renders all n steps (an `activeStep` change) therefore costs n passes, O(n²) position\n * checks, and the root's observer adds one pass per list mutation (indicator swaps included):\n * negligible for step counts a stepper can show. If that ever matters, coalesce the per-step calls\n * into one pass per commit (a dirty flag set by the steps, flushed once) — keeping this per-step\n * call or the observer as the path for commits in which the root does not re-render.\n */\n sync: () => void;\n}\n\nfunction createStepRegistry(): StepRegistry {\n const elements = new Map<string, HTMLElement>();\n const listeners = new Set<() => void>();\n let order = EMPTY_ORDER;\n\n /** Whether `order` still lists exactly the registered elements, in DOM order. */\n const isCurrent = () => {\n if (order.length !== elements.size) return false;\n let previous: HTMLElement | undefined;\n for (const key of order) {\n const element = elements.get(key);\n if (!element) return false;\n if (\n previous &&\n !(previous.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING)\n ) {\n return false;\n }\n previous = element;\n }\n return true;\n };\n\n const sync = () => {\n if (isCurrent()) return;\n const next = Array.from(elements.entries())\n .sort(([, a], [, b]) =>\n a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1,\n )\n .map(([key]) => key);\n if (next.length === order.length && next.every((key, i) => key === order[i])) return;\n order = next;\n listeners.forEach((listener) => listener());\n };\n\n return {\n register(key, element) {\n elements.set(key, element);\n sync();\n return () => {\n if (elements.get(key) === element) elements.delete(key);\n sync();\n };\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n getOrder: () => order,\n sync,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Contexts\n// ---------------------------------------------------------------------------\n\ninterface StepperContextValue {\n activeStep: number;\n /** Activates a step: updates the (uncontrolled) state and calls `onStepChange`. */\n select: (step: number) => void;\n orientation: Orientation;\n linear: boolean;\n /** Registered step keys in DOM order (empty on the server and before the first commit). */\n order: readonly string[];\n /** Number of element children after flattening Fragments (the pre-registration step count). */\n childCount: number;\n /** Resolved `statusLabels.completed`. */\n completedLabel: string;\n /** Resolved `statusLabels.error`. */\n errorLabel: string;\n register: StepRegistry['register'];\n sync: StepRegistry['sync'];\n}\n\nconst StepperContext = React.createContext<StepperContextValue | null>(null);\n\n/**\n * Position of a Stepper child among the element children (Fragments flattened), set by the root\n * around each child. It numbers the steps on the server and in the first render; after mount the\n * registry's DOM order takes over (it also covers wrappers that render several steps or none, which\n * the slot numbering gets wrong — documented on `Stepper` and `StepProps.index`).\n */\nconst StepSlotContext = React.createContext<number | null>(null);\n\nconst noop = () => {};\nconst INERT_CONTEXT: StepperContextValue = {\n activeStep: 0,\n select: noop,\n orientation: 'horizontal',\n linear: false,\n order: EMPTY_ORDER,\n childCount: 0,\n completedLabel: DEFAULT_COMPLETED_LABEL,\n errorLabel: DEFAULT_ERROR_LABEL,\n register: () => noop,\n sync: noop,\n};\n\n/**\n * Reads the Stepper context; a Step outside a Stepper throws in development and logs once in\n * production, where it renders inert (C-CONTEXT).\n */\nfunction useStepperContext(componentName: string): StepperContextValue {\n const context = React.useContext(StepperContext);\n if (context) return context;\n reportMissingContext(componentName, 'Stepper');\n return INERT_CONTEXT;\n}\n\n/** A Stepper child after flattening; an element carries its position among the elements. */\ninterface StepperChild {\n key: string;\n node: React.ReactNode;\n slot: number | null;\n}\n\n/**\n * The Stepper's children with Fragments flattened at any depth (`flattenChildren`: keys unique,\n * `null`/booleans dropped) and every element numbered in order.\n */\nfunction numberChildren(children: React.ReactNode): StepperChild[] {\n let slot = 0;\n return flattenChildren(children).map(({ key, node }) => ({\n key,\n node,\n slot: React.isValidElement(node) ? slot++ : null,\n }));\n}\n\n// ---------------------------------------------------------------------------\n// Step\n// ---------------------------------------------------------------------------\n\nconst indicatorSlotClasses = 'inline-flex items-center justify-center';\n\n/**\n * Connector colors. A connector is drawn by its background only, which forced colors replace with\n * Canvas, so it opts out there: a completed one is painted `Highlight` (`forcedColors.fill`), the\n * others `CanvasText`, like a Slider rail.\n */\nconst connectorCompletedClasses = cn('bg-success', forcedColors.fill);\nconst connectorPendingClasses =\n 'bg-border forced-colors:bg-[CanvasText] forced-colors:forced-color-adjust-none';\n\n/**\n * One step of a {@link Stepper}: a `role=\"button\"` step (indicator, label, optional description)\n * inside its own `<li>`, followed by a connector unless it is the last step. `ref`, `className` and\n * rest props land on the step's root `<div>`; `onClick` runs on activation by mouse, Enter or Space\n * (not for disabled or unreachable steps). Must be rendered inside a `Stepper` (throws in\n * development otherwise). Flat name `StepperStep`, importable from React Server Components.\n */\nconst StepperStep = ({\n label,\n description,\n icon,\n disabled = false,\n completed,\n error = false,\n index: indexProp,\n className,\n onClick,\n ref,\n ...rest\n}: StepProps) => {\n const {\n activeStep,\n select,\n orientation,\n linear,\n order,\n childCount,\n completedLabel,\n errorLabel,\n register,\n sync,\n } = useStepperContext('Stepper.Step');\n const slotIndex = React.useContext(StepSlotContext);\n const key = useId('wave-step');\n const labelId = `${key}-label`;\n const descriptionId = `${key}-description`;\n\n // The list item registers itself under this step's id; the registry sorts by DOM position.\n const registerItem = React.useCallback(\n (element: HTMLLIElement | null) => (element ? register(key, element) : undefined),\n [register, key],\n );\n // A keyed reorder moves list items without re-running their ref callbacks, and a wrapper component\n // can reorder its own steps without re-rendering the root: re-read the DOM order after every commit\n // of this step (a changed order re-renders before paint). Moves that re-render no step at all\n // (reused elements) are caught by the root's MutationObserver.\n React.useLayoutEffect(() => {\n sync();\n });\n\n const position = order.indexOf(key);\n const index = indexProp ?? (position !== -1 ? position : (slotIndex ?? 0));\n const stepCount = position !== -1 ? order.length : childCount;\n const isLast = index >= stepCount - 1;\n const isActive = index === activeStep;\n const isCompleted = completed ?? index < activeStep;\n const isClickable = !disabled && (!linear || index <= activeStep + 1);\n const horizontal = orientation === 'horizontal';\n\n /**\n * The single activation path for mouse and keyboard (Enter/Space dispatch a click): an\n * unavailable step does nothing — neither the consumer `onClick` nor `onStepChange` runs; a\n * consumer `onClick` that calls `preventDefault()` suppresses the step change (C-COMPOSE).\n */\n const activate = (event: React.MouseEvent<HTMLDivElement>) => {\n if (!isClickable) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n if (event.defaultPrevented) return;\n select(index);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.target !== event.currentTarget) return;\n if (event.key === 'Enter') {\n event.preventDefault();\n event.currentTarget.click();\n } else if (event.key === ' ') {\n // Space activates on keyup, like a native button; stop the page from scrolling.\n event.preventDefault();\n }\n };\n\n const handleKeyUp = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.target !== event.currentTarget || event.key !== ' ') return;\n event.preventDefault();\n event.currentTarget.click();\n };\n\n const status = error ? errorLabel : isCompleted ? completedLabel : '';\n const statusText = status ? `${status} ${index + 1}.` : `${index + 1}.`;\n\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in Menu,\n // Nav, Tree and Avatar, and so is a collection whose items render nothing: the step keeps its\n // number or check mark. The check does not consume a generator: renderSlot still renders it.\n const hasIcon = !!icon && slotRendersContent(icon);\n let indicator: React.ReactNode;\n if (error) {\n indicator = <DismissIcon />;\n } else if (isCompleted && !hasIcon) {\n indicator = <CheckIcon />;\n } else if (hasIcon) {\n indicator = renderSlot(icon, 'span', indicatorSlotClasses, { 'aria-hidden': true });\n } else {\n indicator = <span className=\"text-caption-1 font-semibold\">{index + 1}</span>;\n }\n\n const toneClass = error\n ? 'text-error'\n : isActive\n ? 'text-primary'\n : isCompleted\n ? 'text-success'\n : 'text-foreground';\n\n return (\n <li ref={registerItem} className={cn('flex min-w-0', horizontal && !isLast && 'flex-1')}>\n <div\n ref={ref}\n data-active={isActive ? '' : undefined}\n data-completed={isCompleted ? '' : undefined}\n data-error={error ? '' : undefined}\n data-disabled={disabled ? '' : undefined}\n {...rest}\n className={cn(horizontal ? 'flex flex-1 items-center' : 'flex flex-1 flex-col', className)}\n >\n <div\n role=\"button\"\n tabIndex={isClickable ? 0 : -1}\n aria-current={isActive ? 'step' : undefined}\n aria-disabled={isClickable ? undefined : true}\n aria-labelledby={labelId}\n aria-describedby={description ? descriptionId : undefined}\n onClick={activate}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n className={cn(\n 'relative flex rounded',\n horizontal ? 'flex-col items-center gap-1' : 'items-center gap-3',\n focusRing,\n isClickable ? 'cursor-pointer' : 'cursor-default',\n disabled && 'opacity-50',\n )}\n >\n <span\n aria-hidden=\"true\"\n className={cn(\n 'flex size-8 shrink-0 items-center justify-center rounded-full border-2 transition-colors motion-reduce:transition-none',\n error\n ? 'border-error bg-error-tint text-error-tint-foreground'\n : isActive\n ? cn(\n 'border-primary bg-primary text-primary-foreground',\n forcedColors.selectedLeaf,\n )\n : isCompleted\n ? 'border-success bg-success-tint text-success-tint-foreground'\n : 'border-border bg-background text-muted-foreground',\n )}\n >\n {indicator}\n </span>\n <span className={cn('flex flex-col', horizontal && 'items-center text-center')}>\n <span\n id={labelId}\n className={cn(\n 'font-semibold',\n horizontal ? 'text-caption-1 whitespace-nowrap' : 'text-body-1',\n toneClass,\n )}\n >\n <span className=\"sr-only\">{statusText}</span> {label}\n </span>\n {description && (\n <span\n id={descriptionId}\n className={cn(\n 'text-muted-foreground',\n horizontal ? 'text-caption-2 whitespace-nowrap' : 'text-caption-1',\n )}\n >\n {description}\n </span>\n )}\n </span>\n </div>\n {!isLast && (\n <div\n data-wave-stepper-connector=\"\"\n aria-hidden=\"true\"\n className={cn(\n 'transition-colors motion-reduce:transition-none',\n // Vertical: centred under the size-8 circle, (8 - 0.5) / 2 spacing units in, so the\n // offset scales with the circle at any root font size.\n horizontal ? 'mx-2 h-0.5 flex-1' : 'my-1 ms-3.75 min-h-6 w-0.5',\n isCompleted ? connectorCompletedClasses : connectorPendingClasses,\n )}\n />\n )}\n </div>\n </li>\n );\n};\nStepperStep.displayName = 'Step';\n\n// ---------------------------------------------------------------------------\n// Root\n// ---------------------------------------------------------------------------\n\nconst StepperRoot = ({\n activeStep: controlledStep,\n defaultActiveStep = 0,\n onStepChange,\n orientation = 'horizontal',\n linear = false,\n statusLabels,\n className,\n children,\n ref,\n ...rest\n}: StepperProps) => {\n // Resolved to strings, so an inline `statusLabels` object does not change the context each render.\n const completedLabel = statusLabels?.completed ?? DEFAULT_COMPLETED_LABEL;\n const errorLabel = statusLabels?.error ?? DEFAULT_ERROR_LABEL;\n const [activeStep, setActiveStep] = useControllable(controlledStep, defaultActiveStep);\n const emitStepChange = useEventCallback(onStepChange);\n // Event callback semantics (C-NAMING): every activation emits, also of the active step.\n const select = React.useCallback(\n (step: number) => {\n setActiveStep(step);\n emitStepChange(step);\n },\n [setActiveStep, emitStepChange],\n );\n\n const [registry] = React.useState(createStepRegistry);\n const order = React.useSyncExternalStore(registry.subscribe, registry.getOrder, getServerOrder);\n // Steps re-sync after each of their commits. A move that re-renders no step (a wrapper reordering\n // reused step elements) only shows up in the DOM: observe the list for it (C-HOOKS DOM-derived\n // collection; the callback runs in a microtask, before paint).\n const listRef = React.useRef<HTMLOListElement>(null);\n React.useEffect(() => {\n const list = listRef.current;\n if (!list) return;\n const observer = new MutationObserver(registry.sync);\n observer.observe(list, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, [registry]);\n\n const items = React.useMemo(() => numberChildren(children), [children]);\n const childCount = items.filter((item) => item.slot !== null).length;\n\n const context = React.useMemo<StepperContextValue>(\n () => ({\n activeStep,\n select,\n orientation,\n linear,\n order,\n childCount,\n completedLabel,\n errorLabel,\n register: registry.register,\n sync: registry.sync,\n }),\n [\n activeStep,\n select,\n orientation,\n linear,\n order,\n childCount,\n completedLabel,\n errorLabel,\n registry,\n ],\n );\n\n const horizontal = orientation === 'horizontal';\n\n return (\n <StepperContext.Provider value={context}>\n <div\n ref={ref}\n role=\"group\"\n aria-label=\"Progress\"\n data-orientation={orientation}\n {...rest}\n className={cn('flex', horizontal ? 'flex-row items-start' : 'flex-col', className)}\n >\n {/* role=\"list\" is not redundant: WebKit/VoiceOver drops list semantics from a\n `list-style: none` list outside a <nav> unless the role is explicit. */}\n <ol\n ref={listRef}\n role=\"list\"\n className={cn(\n 'm-0 flex list-none p-0',\n horizontal ? 'flex-1 flex-row items-start' : 'flex-col',\n )}\n >\n {items.map((item) =>\n item.slot === null ? (\n item.node\n ) : (\n <StepSlotContext.Provider key={item.key} value={item.slot}>\n {item.node}\n </StepSlotContext.Provider>\n ),\n )}\n </ol>\n </div>\n </StepperContext.Provider>\n );\n};\nStepperRoot.displayName = 'Stepper';\n\n/**\n * A multi-step progress indicator. Steps are `Stepper.Step` children (Fragments, conditional steps\n * and wrapper components are numbered in DOM order) rendered as an ordered list inside a\n * `role=\"group\"` root named \"Progress\" (override with `aria-label`). The active step's button\n * carries `aria-current=\"step\"`; completed and error steps announce their status (\"Completed:\",\n * \"Error:\"; localized with `statusLabels`).\n *\n * Server rendering: before hydration, steps are numbered by their position among the Stepper's\n * children (Fragments flattened), so a wrapper component that renders more or fewer than one step\n * is numbered correctly only after hydration. Pin such steps with `index` if the server HTML must\n * already be exact.\n *\n * Compound access (`Stepper.Step`) needs a client module; React Server Components import the flat\n * name `StepperStep` instead.\n */\nexport const Stepper = /* @__PURE__ */ Object.assign(StepperRoot, { Step: StepperStep });\n\n// Flat name of `Stepper.Step` (C-COMPOUND).\nexport { StepperStep };\n"],"mappings":";;;;;;;;;;;;;AA+CA,IAAMG,IAA0B,cAC1BC,IAAsB,UA2CtBC,IAAiC,CAAC,GAClCC,UAAuBD;AAoB7B,SAASE,IAAmC;CAC1C,IA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B;KAAyC,OAAO2E,EAAK;KAClD,UAAAA,EAAK;IACkB,GAFKA,EAAK,GAEV,CAE9B;GACE,CAAA;EACD,CAAA;CACkB,CAAA;AAE7B;AACA,EAAY,cAAc;AAiB1B,IAAaE,IAA0B,uBAAO,OAAOjB,GAAa,EAAE,MAAM5C,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/slot.cjs"),i=require("../../hooks/useId.cjs"),a=require("../../hooks/useMergedRefs.cjs"),o=require("../../hooks/useIsClient.cjs"),s=require("../portal/Portal.cjs"),c=require("../button/Button.cjs"),l=require("../../lib/icons.cjs"),u=require("../../hooks/useModalLayer.cjs"),d=require("./Dialog.shared.cjs");let f=require("react");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m=f.createContext(null);m.displayName=`DialogContext`;var h={open:!1,requestOpen:()=>{},modalType:`modal`,trigger:d.inertModalTrigger,finalFocusRef:void 0,contentId:void 0,registerContentId:()=>()=>{}};function g(e){return d.useRequiredContext(m,e,`Dialog`,()=>h)}var _=({open:e,defaultOpen:t,onOpenChange:n,modalType:r=`modal`,finalFocusRef:i,children:a})=>{let[s,c]=d.useModalOpenState(e,t,n),l=o.useIsClient(),u=s&&l,h=d.useModalTrigger();d.useModalTriggerSession(h,u);let[g,_]=f.useState(void 0),v=f.useCallback(e=>(_(e),()=>_(t=>t===e?void 0:t)),[]),y=f.useMemo(()=>({open:u,requestOpen:c,modalType:r,trigger:h,finalFocusRef:i,contentId:g,registerContentId:v}),[u,c,r,h,i,g,v]);return(0,p.jsx)(m.Provider,{value:y,children:a})};_.displayName=`Dialog`;var v=e=>{let{open:t,requestOpen:n,trigger:r,contentId:i}=g(`Dialog.Trigger`);return d.useModalTriggerPart({open:t,requestOpen:n,trigger:r,controlsId:i},e,`Dialog.Trigger`)};v.displayName=`DialogTrigger`;var y=e=>{let{requestOpen:t}=g(`Dialog.Close`);return d.useModalClosePart(t,e,`Dialog.Close`)};y.displayName=`DialogClose`;var b={small:`max-w-[400px]`,medium:`max-w-[600px]`},x=({title:e,size:n=`medium`,closeLabel:o=`Close`,children:m,className:h,id:_,ref:v,...y})=>{let{open:x,requestOpen:S,modalType:C,trigger:w,finalFocusRef:T,registerContentId:E}=g(`Dialog.Content`),D=i.useId(`wave-dialog`),O=_??D,k=i.useId(`wave-dialog-title`),A=d.useTitleRegistry(),[j,M]=f.useState(null),N=f.useRef(null),P=f.useCallback(e=>{N.current=e,M(e)},[]),F=f.useCallback(e=>e?E(O):void 0,[E,O]),I=a.useMergedRefs(v,P,F),L=C!==`alert`,R=d.useBackdropPress(N,L),z=d.useModalDismiss(S,`Dialog`,R.afterOutsidePress),B=u.useModalLayer({open:x,onDismiss:z,refs:[N],outsidePress:L,container:j,triggerRef:w.focusRef,finalFocusRef:T});d.useUnnamedModalWarning(x?j:null,A.hasTitle,`Dialog.Content`,`Dialog.Title`);let[V,H]=f.useState(null),U=f.useMemo(()=>({...A.context,setFooterHeight:H}),[A.context]);if(!x)return null;let W=r.slotRendersContent(e);return(0,p.jsx)(s.Portal,{layerId:B.layerId,children:(0,p.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-backdrop p-4`,onMouseDown:R.onMouseDown,children:(0,p.jsx)(`div`,{ref:I,role:C===`alert`?`alertdialog`:`dialog`,id:O,"aria-labelledby":W?k:A.titleId,tabIndex:-1,"data-modal-type":C,...y,className:t.cn(`relative flex max-h-[calc(100dvh-2rem)] w-full flex-col rounded-lg border border-border bg-background p-6 text-foreground shadow-64`,b[n],h),children:(0,p.jsxs)(d.ModalSurfaceContext.Provider,{value:U,children:[W&&(0,p.jsx)(`h2`,{id:k,className:`pe-8 text-subtitle-1 font-semibold`,children:e}),(0,p.jsx)(c.Button,{appearance:`subtle`,size:`small`,icon:(0,p.jsx)(l.DismissIcon,{}),"aria-label":o,onClick:e=>S(!1,{reason:`close-button`,event:e.nativeEvent}),className:`absolute end-4 top-4 text-muted-foreground`}),(0,p.jsx)(`div`,{className:`-mx-1 mt-1 min-h-0 flex-1 overflow-y-auto scroll-pb-(--wave-dialog-footer-height) p-1 text-body-1 text-muted-foreground`,style:V===null?void 0:{"--wave-dialog-footer-height":`${V}px`},children:m})]})})})})};x.displayName=`DialogContent`;var S=({id:e,className:n,children:r,ref:i,...a})=>{let{id:o,ref:s}=d.useModalTitle(`Dialog.Title`,`Dialog.Content`,e,i);return(0,p.jsx)(`h2`,{...a,id:o,ref:s,className:t.cn(`pe-8 text-subtitle-1 font-semibold text-foreground`,n),children:r})};S.displayName=`DialogTitle`;var C=`sticky -bottom-1 z-10 -mx-1 -mb-1 mt-6 flex justify-end gap-2 bg-background px-1 pb-2 pt-3`,w=`mt-6 flex justify-end gap-2`,T=({children:e,className:r,ref:i,...o})=>{let s=f.useContext(d.ModalSurfaceContext),c=s===null,l=s?.setFooterHeight,[u,m]=f.useState(null),h=a.useMergedRefs(i,m);return f.useEffect(()=>{c&&n.warnOnce(`Dialog.Footer:outside-content`,`Dialog.Footer must be rendered inside Dialog.Content. Outside it, the footer stays on the page while the dialog is closed.`)},[c]),f.useLayoutEffect(()=>{if(!u||!l||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(e=>{let t=e[e.length-1];t&&l(t.borderBoxSize?.[0]?.blockSize??u.offsetHeight)});return e.observe(u,{box:`border-box`}),()=>{e.disconnect(),l(null)}},[u,l]),(0,p.jsx)(`div`,{ref:h,...o,className:t.cn(l?C:w,r),children:e})};T.displayName=`DialogFooter`;var E=Object.assign(_,{Trigger:v,Content:x,Footer:T,Title:S,Close:y});exports.Dialog=E,exports.DialogClose=y,exports.DialogContent=x,exports.DialogFooter=T,exports.DialogTitle=S,exports.DialogTrigger=v;
|
|
2
|
+
//# sourceMappingURL=Dialog.cjs.map
|