@aceshooting/lyra-ui 32.0.0 → 33.0.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/CHANGELOG.md +224 -1380
- package/README.md +36 -7
- package/custom-elements.slim.json +1 -0
- package/design-tokens.json +1 -1
- package/dist/accent-roles.css +1 -0
- package/dist/all.d.ts +1 -1
- package/dist/all.js +1 -1
- package/dist/autoloader.d.ts +10 -0
- package/dist/autoloader.js +1 -1
- package/dist/cli/migrate-wa.mjs +54 -44
- package/dist/cli/migration-contract.json.gz +0 -0
- package/dist/components/agent-tools/budget-meter/budget-meter.class.d.ts +1 -0
- package/dist/components/agent-tools/budget-meter/budget-meter.styles.js +1 -1
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +1 -1
- package/dist/components/charts/chart/box-plot.class.d.ts +3 -0
- package/dist/components/charts/chart/chart-band.js +1 -1
- package/dist/components/charts/chart/chart-input-projection.js +1 -1
- package/dist/components/charts/chart/chart-surface.styles.js +1 -1
- package/dist/components/charts/chart/chart-types.d.ts +16 -2
- package/dist/components/charts/chart/chart.class.d.ts +4 -1
- package/dist/components/charts/chart/chart.class.js +3 -3
- package/dist/components/charts/chart/lite-chart.class.d.ts +3 -0
- package/dist/components/charts/chart/lite-chart.styles.js +1 -1
- package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +10 -0
- package/dist/components/conversation/code-block/code-block-base.class.d.ts +31 -3
- package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-core.class.d.ts +46 -2
- package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-shared.d.ts +6 -2
- package/dist/components/conversation/code-block/code-block-shared.js +5 -4
- package/dist/components/conversation/code-block/code-block.class.d.ts +48 -3
- package/dist/components/conversation/code-block/code-block.class.js +1 -1
- package/dist/components/conversation/code-block/code-block.styles.js +1 -1
- package/dist/components/conversation/code-block/code-grammar-registry.d.ts +35 -0
- package/dist/components/conversation/code-block/code-grammar-registry.js +1 -0
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +12 -0
- package/dist/components/conversation/markdown/markdown.class.d.ts +12 -0
- package/dist/components/conversation/markdown/markdown.styles.js +1 -1
- package/dist/components/conversation/model-select/model-select.class.d.ts +12 -5
- package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +1 -1
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +1 -0
- package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +3 -0
- package/dist/components/conversation/thread-list/thread-list.styles.js +1 -1
- package/dist/components/conversation/usage-badge/usage-badge.class.d.ts +1 -1
- package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +12 -5
- package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +4 -0
- package/dist/components/data/heatmap/heatmap.class.d.ts +21 -2
- package/dist/components/data/heatmap/heatmap.class.js +2 -2
- package/dist/components/data/heatmap/heatmap.styles.js +1 -1
- package/dist/components/data/stat/stat.class.d.ts +24 -1
- package/dist/components/data/stat/stat.class.js +2 -2
- package/dist/components/data/stat/stat.styles.js +1 -1
- package/dist/components/data/table/table-row-attributes.js +1 -0
- package/dist/components/data/table/table-support.d.ts +64 -5
- package/dist/components/data/table/table-support.js +1 -1
- package/dist/components/data/table/table.class.d.ts +78 -7
- package/dist/components/data/table/table.class.js +10 -10
- package/dist/components/data/table/table.styles.js +1 -1
- package/dist/components/data/timeline/timeline-item.class.d.ts +27 -5
- package/dist/components/data/timeline/timeline-item.class.js +11 -7
- package/dist/components/data/timeline/timeline-item.styles.js +1 -1
- package/dist/components/data/timeline/timeline.class.d.ts +54 -8
- package/dist/components/data/timeline/timeline.class.js +11 -7
- package/dist/components/data/timeline/timeline.styles.js +1 -1
- package/dist/components/data/tree/tree-item.class.d.ts +2 -0
- package/dist/components/data/tree/tree-item.class.js +2 -2
- package/dist/components/data/tree/tree-item.styles.js +1 -1
- package/dist/components/forms/button/button.class.d.ts +13 -0
- package/dist/components/forms/button/button.styles.js +1 -1
- package/dist/components/forms/catalog-picker-base.d.ts +14 -1
- package/dist/components/forms/checkbox/checkbox.class.js +1 -1
- package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +28 -2
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +3 -3
- package/dist/components/forms/checkbox-group/checkbox-group.styles.js +1 -1
- package/dist/components/forms/code-editor/code-editor.class.d.ts +18 -3
- package/dist/components/forms/code-editor/code-editor.styles.js +1 -1
- package/dist/components/forms/color-picker/color-picker.class.d.ts +25 -5
- package/dist/components/forms/color-picker/color-picker.class.js +3 -3
- package/dist/components/forms/color-picker/color-picker.styles.js +1 -1
- package/dist/components/forms/combobox/combobox-option-html.js +1 -0
- package/dist/components/forms/combobox/combobox.class.d.ts +140 -12
- package/dist/components/forms/combobox/combobox.class.js +113 -22
- package/dist/components/forms/combobox/combobox.styles.js +1 -1
- package/dist/components/forms/country-picker/country-picker.class.d.ts +4 -3
- package/dist/components/forms/currency-picker/currency-picker.class.d.ts +4 -3
- package/dist/components/forms/date-picker/date-input.class.d.ts +53 -3
- package/dist/components/forms/date-picker/date-input.class.js +2 -2
- package/dist/components/forms/date-picker/date-input.styles.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +14 -0
- package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.class.d.ts +2 -1
- package/dist/components/forms/icon-button/icon-button.styles.js +1 -1
- package/dist/components/forms/input/input-shared.d.ts +24 -3
- package/dist/components/forms/input/input.styles.js +1 -1
- package/dist/components/forms/input/time-input.class.d.ts +19 -4
- package/dist/components/forms/input/time-input.styles.js +1 -1
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +17 -5
- package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
- package/dist/components/forms/otp-input/otp-input.class.d.ts +8 -3
- package/dist/components/forms/otp-input/otp-input.styles.js +1 -1
- package/dist/components/forms/phone-input/phone-input.class.d.ts +18 -3
- package/dist/components/forms/phone-input/phone-input.styles.js +1 -1
- package/dist/components/forms/radio/radio-group.class.d.ts +23 -2
- package/dist/components/forms/radio/radio-group.class.js +2 -2
- package/dist/components/forms/radio/radio-group.styles.js +1 -1
- package/dist/components/forms/radio/radio.class.js +2 -2
- package/dist/components/forms/rubric-form/rubric-form.class.d.ts +4 -0
- package/dist/components/forms/select/select.class.d.ts +16 -4
- package/dist/components/forms/select/select.class.js +1 -1
- package/dist/components/forms/select/select.styles.js +1 -1
- package/dist/components/forms/signature-pad/signature-pad.class.d.ts +8 -3
- package/dist/components/forms/signature-pad/signature-pad.styles.js +1 -1
- package/dist/components/forms/slider/slider.class.d.ts +29 -2
- package/dist/components/forms/slider/slider.class.js +3 -3
- package/dist/components/forms/slider/slider.styles.js +1 -1
- package/dist/components/forms/switch/switch.class.d.ts +2 -0
- package/dist/components/forms/switch/switch.styles.js +1 -1
- package/dist/components/forms/textarea/textarea.class.d.ts +20 -3
- package/dist/components/forms/textarea/textarea.styles.js +1 -1
- package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +4 -3
- package/dist/components/forms/token-input/token-input.class.d.ts +99 -21
- package/dist/components/forms/token-input/token-input.class.js +11 -8
- package/dist/components/forms/token-input/token-input.styles.js +1 -1
- package/dist/components/forms/unit-picker/unit-picker.class.d.ts +4 -3
- package/dist/components/layout/app-rail/app-rail.class.d.ts +3 -0
- package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
- package/dist/components/layout/button-group/button-group.class.d.ts +4 -0
- package/dist/components/layout/button-group/button-group.class.js +1 -1
- package/dist/components/layout/card/card.class.d.ts +15 -1
- package/dist/components/layout/card/card.styles.js +1 -1
- package/dist/components/layout/command-palette/command-palette.class.d.ts +1 -1
- package/dist/components/layout/details/details.class.d.ts +6 -0
- package/dist/components/layout/details/details.styles.js +1 -1
- package/dist/components/layout/filter-bar/filter-bar.class.d.ts +6 -0
- package/dist/components/layout/filter-bar/filter-bar.styles.js +1 -1
- package/dist/components/layout/index.d.ts +1 -1
- package/dist/components/layout/index.js +1 -1
- package/dist/components/layout/menu/dropdown-item.class.d.ts +8 -2
- package/dist/components/layout/menu/dropdown-item.class.js +1 -1
- package/dist/components/layout/menu/menu-item.class.d.ts +7 -0
- package/dist/components/layout/menu/menu-item.styles.js +1 -1
- package/dist/components/layout/menu/menu-label.class.d.ts +5 -0
- package/dist/components/layout/menu/menu-label.class.js +1 -1
- package/dist/components/layout/menu/menu.class.d.ts +4 -1
- package/dist/components/layout/menu/menu.styles.js +1 -1
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +1 -1
- package/dist/components/layout/page/page.class.d.ts +9 -1
- package/dist/components/layout/page/page.class.js +2 -2
- package/dist/components/layout/segmented/segmented.class.d.ts +22 -3
- package/dist/components/layout/segmented/segmented.class.js +3 -4
- package/dist/components/layout/segmented/segmented.styles.js +1 -1
- package/dist/components/layout/stepper/step.class.d.ts +102 -0
- package/dist/components/layout/stepper/step.class.js +18 -0
- package/dist/components/layout/stepper/step.styles.js +1 -0
- package/dist/components/layout/stepper/stepper.class.d.ts +106 -13
- package/dist/components/layout/stepper/stepper.class.js +6 -2
- package/dist/components/layout/stepper/stepper.styles.js +1 -1
- package/dist/components/layout/tab-group/tab-group.class.d.ts +10 -1
- package/dist/components/layout/tab-group/tab-group.class.js +1 -1
- package/dist/components/layout/tab-group/tab-group.styles.js +1 -1
- package/dist/components/layout/tab-group/tab-panel.class.d.ts +1 -0
- package/dist/components/layout/tab-group/tab-panel.class.js +1 -1
- package/dist/components/layout/tab-group/tab.class.d.ts +4 -0
- package/dist/components/layout/widget/widget.class.d.ts +1 -0
- package/dist/components/layout/widget/widget.styles.js +1 -1
- package/dist/components/lr-code-block-core.d.ts +1 -1
- package/dist/components/lr-code-block.d.ts +1 -1
- package/dist/components/lr-counter.d.ts +1 -0
- package/dist/components/lr-counter.js +1 -0
- package/dist/components/lr-lightbox-item.d.ts +1 -0
- package/dist/components/lr-lightbox-item.js +1 -0
- package/dist/components/lr-lightbox.d.ts +1 -1
- package/dist/components/lr-lightbox.js +1 -1
- package/dist/components/lr-number-ticker.d.ts +1 -0
- package/dist/components/lr-number-ticker.js +1 -0
- package/dist/components/lr-step.d.ts +1 -0
- package/dist/components/lr-step.js +1 -0
- package/dist/components/media/file-input/file-input.class.d.ts +8 -1
- package/dist/components/media/file-input/file-input.class.js +2 -2
- package/dist/components/media/file-input/file-input.styles.js +1 -1
- package/dist/components/media/index.d.ts +1 -1
- package/dist/components/media/index.js +1 -1
- package/dist/components/media/lightbox/lightbox-item.class.d.ts +67 -0
- package/dist/components/media/lightbox/lightbox-item.class.js +9 -0
- package/dist/components/media/lightbox/lightbox-item.styles.js +1 -0
- package/dist/components/media/lightbox/lightbox-source.js +1 -1
- package/dist/components/media/lightbox/lightbox-types.d.ts +4 -1
- package/dist/components/media/lightbox/lightbox.class.d.ts +123 -30
- package/dist/components/media/lightbox/lightbox.class.js +18 -12
- package/dist/components/media/lightbox/lightbox.styles.js +1 -1
- package/dist/components/media/map/map-anchor-avoid.js +1 -1
- package/dist/components/media/map/map-drawing-controller.js +1 -1
- package/dist/components/media/map/map.class.d.ts +137 -7
- package/dist/components/media/map/map.class.js +6 -6
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +9 -0
- package/dist/components/media/sequence-playback/sequence-playback.class.js +2 -2
- package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
- package/dist/components/media/video/video.class.d.ts +4 -0
- package/dist/components/media/video/video.class.js +2 -2
- package/dist/components/media/video/video.styles.js +1 -1
- package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +15 -0
- package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
- package/dist/components/overlays/badge/badge.class.d.ts +2 -0
- package/dist/components/overlays/badge/badge.styles.js +1 -1
- package/dist/components/overlays/badge/tag.class.d.ts +2 -0
- package/dist/components/overlays/badge/tag.class.js +1 -1
- package/dist/components/overlays/chip/chip-group.class.d.ts +31 -4
- package/dist/components/overlays/chip/chip-group.class.js +3 -3
- package/dist/components/overlays/context-menu/context-menu.class.d.ts +6 -1
- package/dist/components/overlays/context-menu/context-menu.class.js +1 -1
- package/dist/components/overlays/dialog/dialog.class.d.ts +54 -6
- package/dist/components/overlays/dialog/dialog.class.js +3 -3
- package/dist/components/overlays/dialog/dialog.styles.js +1 -1
- package/dist/components/overlays/dialog/prompt.d.ts +60 -0
- package/dist/components/overlays/dialog/prompt.js +1 -0
- package/dist/components/overlays/drawer/drawer.class.d.ts +22 -1
- package/dist/components/overlays/drawer/drawer.class.js +1 -1
- package/dist/components/overlays/empty/empty.class.d.ts +1 -0
- package/dist/components/overlays/empty/empty.class.js +1 -1
- package/dist/components/overlays/overlay/dropdown.class.d.ts +5 -1
- package/dist/components/overlays/overlay/dropdown.class.js +1 -1
- package/dist/components/overlays/overlay/overlay.styles.js +1 -1
- package/dist/components/overlays/overlay/popover.class.d.ts +30 -4
- package/dist/components/overlays/overlay/popover.class.js +2 -2
- package/dist/components/overlays/overlay/tooltip.class.d.ts +7 -0
- package/dist/components/overlays/overlay/tooltip.class.js +4 -4
- package/dist/components/overlays/toast/toast-item.class.d.ts +3 -2
- package/dist/components/overlays/toast/toast-item.class.js +1 -1
- package/dist/components/overlays/toast/toast-item.styles.js +1 -1
- package/dist/components/overlays/toast/toast.class.d.ts +6 -0
- package/dist/components/overlays/toast/toast.class.js +1 -1
- package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +1 -1
- package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +1 -1
- package/dist/components/utility/copy-button/copy-button.class.d.ts +4 -1
- package/dist/components/utility/copy-button/copy-button.class.js +2 -2
- package/dist/components/utility/counter/counter-time.d.ts +15 -0
- package/dist/components/utility/counter/counter-time.js +1 -0
- package/dist/components/utility/counter/counter.class.d.ts +67 -0
- package/dist/components/utility/counter/counter.class.js +1 -0
- package/dist/components/utility/counter/counter.styles.js +1 -0
- package/dist/components/utility/divider/divider.class.d.ts +21 -3
- package/dist/components/utility/divider/divider.class.js +5 -1
- package/dist/components/utility/export-button/export-button.class.d.ts +6 -1
- package/dist/components/utility/export-button/export-button.styles.js +1 -1
- package/dist/components/utility/icon/icon-library-bootstrap.d.ts +50 -0
- package/dist/components/utility/icon/icon-library-bootstrap.js +1 -0
- package/dist/components/utility/icon/icon-library-font-awesome.d.ts +68 -0
- package/dist/components/utility/icon/icon-library-font-awesome.js +1 -0
- package/dist/components/utility/icon/icon-library.d.ts +14 -1
- package/dist/components/utility/icon/icon-library.js +1 -1
- package/dist/components/utility/icon/icon-sprite.js +1 -0
- package/dist/components/utility/icon/icon.class.d.ts +4 -2
- package/dist/components/utility/icon/icon.class.js +2 -2
- package/dist/components/utility/index.d.ts +1 -1
- package/dist/components/utility/index.js +1 -1
- package/dist/components/utility/known-date/known-date.class.d.ts +14 -0
- package/dist/components/utility/mention-popover/mention-popover.class.d.ts +1 -1
- package/dist/components/utility/number-ticker/number-ticker.class.d.ts +66 -0
- package/dist/components/utility/number-ticker/number-ticker.class.js +1 -0
- package/dist/components/utility/number-ticker/number-ticker.styles.js +1 -0
- package/dist/components/utility/tour/tour.class.d.ts +1 -1
- package/dist/components/viewers/include/include.class.d.ts +4 -1
- package/dist/components/viewers/include/include.class.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +10 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.styles.js +1 -1
- package/dist/custom-elements-jsx.d.ts +1 -1
- package/dist/event-classes.d.ts +2342 -0
- package/dist/event-classes.js +1 -0
- package/dist/events.d.ts +48 -22
- package/dist/framework-types.d.ts +2 -2
- package/dist/internal/accessibility-visibility.js +1 -1
- package/dist/internal/all-defined-arguments.d.ts +19 -0
- package/dist/internal/all-defined-arguments.js +1 -0
- package/dist/internal/autoloader-manifest.js +1 -1
- package/dist/internal/autoloader-tags.d.ts +1 -1
- package/dist/internal/autoloader-tags.js +1 -1
- package/dist/internal/checked-control-label.js +1 -1
- package/dist/internal/component-loaders.generated.js +1 -1
- package/dist/internal/declarative-overlay-action.js +1 -0
- package/dist/internal/dedent.js +7 -0
- package/dist/internal/default-strings/forms.generated.js +1 -1
- package/dist/internal/default-strings/layout.generated.js +1 -1
- package/dist/internal/dev-mode-attribute-warning.development.js +1 -1
- package/dist/internal/document-token-css.generated.js +10 -0
- package/dist/internal/document-tokens.generated.js +2 -11
- package/dist/internal/document-tokens.js +2 -2
- package/dist/internal/dom-guards.js +1 -1
- package/dist/internal/external-label-association.js +1 -0
- package/dist/internal/focus-navigation.js +1 -1
- package/dist/internal/form-control/chrome.styles.js +1 -1
- package/dist/internal/form-control-labels.js +1 -1
- package/dist/internal/form-control.styles.js +1 -1
- package/dist/internal/interactive-control.styles.js +2 -2
- package/dist/internal/labeled-group.js +1 -1
- package/dist/internal/localization-runtime.d.ts +5 -0
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +2 -2
- package/dist/internal/lyra-element.d.ts +11 -2
- package/dist/internal/lyra-element.js +2 -2
- package/dist/internal/lyra-event.d.ts +22 -0
- package/dist/internal/lyra-event.js +1 -0
- package/dist/internal/overlay-shared.d.ts +5 -2
- package/dist/internal/overlay-shared.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/root-registration-allowlist.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/shiki/core.d.ts +4 -1
- package/dist/internal/shiki/tokenize.js +1 -1
- package/dist/internal/srcset.js +1 -0
- package/dist/internal/theme-observation.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/lyra.js +1 -1
- package/dist/ssr/all.d.ts +1 -1
- package/dist/ssr/all.js +1 -1
- package/dist/ssr.d.ts +5 -5
- package/dist/ssr.js +1 -1
- package/dist/styles/native.css +1 -1
- package/dist/styles/palette.css +1 -0
- package/dist/styles/tokens-root.css +1 -1
- package/dist/styles/utilities.css +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/testing/happy-dom-shims.d.ts +11 -2
- package/dist/testing/happy-dom-shims.js +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/lyra-tag-event-map.d.ts +2 -2
- package/dist/testing/lyra-tag-event-map.js +1 -1
- package/dist/theme-core.css +1 -1
- package/dist/theme.css +1 -1
- package/dist/utilities/defined.d.ts +10 -1
- package/dist/utilities/defined.js +1 -1
- package/dist/utilities/form.d.ts +9 -0
- package/dist/utilities/form.js +1 -0
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +1 -1
- package/dist/vue.d.ts +1 -1
- package/llms/components/lr-app-rail.md +4 -2
- package/llms/components/lr-badge.md +4 -4
- package/llms/components/lr-bar-chart.md +1 -1
- package/llms/components/lr-box-plot.md +6 -1
- package/llms/components/lr-bubble-chart.md +1 -1
- package/llms/components/lr-budget-meter.md +2 -2
- package/llms/components/lr-button-group.md +7 -3
- package/llms/components/lr-button.md +11 -1
- package/llms/components/lr-card.md +11 -1
- package/llms/components/lr-chart.md +21 -7
- package/llms/components/lr-checkbox-group.md +11 -1
- package/llms/components/lr-chip.md +11 -1
- package/llms/components/lr-citation-badge.md +1 -1
- package/llms/components/lr-code-block-core.md +39 -9
- package/llms/components/lr-code-block.md +59 -6
- package/llms/components/lr-code-editor.md +11 -1
- package/llms/components/lr-color-picker.md +19 -6
- package/llms/components/lr-combobox.md +81 -9
- package/llms/components/lr-context-menu.md +6 -4
- package/llms/components/lr-copy-button.md +6 -4
- package/llms/components/lr-counter.md +60 -0
- package/llms/components/lr-country-picker.md +4 -0
- package/llms/components/lr-currency-picker.md +4 -0
- package/llms/components/lr-date-input.md +1 -1
- package/llms/components/lr-date-picker.md +25 -1
- package/llms/components/lr-details.md +6 -2
- package/llms/components/lr-dialog.md +101 -9
- package/llms/components/lr-divider.md +14 -5
- package/llms/components/lr-doughnut-chart.md +1 -1
- package/llms/components/lr-drawer.md +32 -7
- package/llms/components/lr-dropdown-item.md +1 -1
- package/llms/components/lr-dropdown.md +8 -4
- package/llms/components/lr-emoji-picker.md +10 -1
- package/llms/components/lr-empty.md +3 -2
- package/llms/components/lr-entity-chip.md +1 -1
- package/llms/components/lr-export-button.md +6 -3
- package/llms/components/lr-file-input.md +13 -1
- package/llms/components/lr-filter-bar.md +6 -2
- package/llms/components/lr-graph-query-builder.md +10 -1
- package/llms/components/lr-heatmap.md +20 -3
- package/llms/components/lr-histogram.md +7 -2
- package/llms/components/lr-icon-button.md +3 -1
- package/llms/components/lr-icon.md +104 -0
- package/llms/components/lr-include.md +3 -0
- package/llms/components/lr-input.md +9 -1
- package/llms/components/lr-known-date.md +10 -1
- package/llms/components/lr-lightbox-item.md +14 -0
- package/llms/components/lr-lightbox.md +119 -14
- package/llms/components/lr-line-chart.md +7 -2
- package/llms/components/lr-lite-chart.md +3 -2
- package/llms/components/lr-locale-picker.md +17 -1
- package/llms/components/lr-map.md +122 -11
- package/llms/components/lr-markdown-core.md +15 -4
- package/llms/components/lr-markdown.md +13 -4
- package/llms/components/lr-mention-popover.md +1 -1
- package/llms/components/lr-menu-item.md +1 -1
- package/llms/components/lr-menu-label.md +5 -2
- package/llms/components/lr-menu.md +22 -7
- package/llms/components/lr-model-select.md +13 -3
- package/llms/components/lr-native-time-input.md +11 -1
- package/llms/components/lr-number-input.md +11 -1
- package/llms/components/lr-number-ticker.md +60 -0
- package/llms/components/lr-otp-input.md +11 -1
- package/llms/components/lr-page.md +7 -1
- package/llms/components/lr-pagination.md +18 -0
- package/llms/components/lr-pdf-viewer.md +6 -1
- package/llms/components/lr-phone-input.md +11 -1
- package/llms/components/lr-pie-chart.md +1 -1
- package/llms/components/lr-polar-area-chart.md +1 -1
- package/llms/components/lr-popover.md +26 -6
- package/llms/components/lr-radar-chart.md +1 -1
- package/llms/components/lr-radio-group.md +11 -1
- package/llms/components/lr-rubric-form.md +7 -1
- package/llms/components/lr-scatter-chart.md +1 -1
- package/llms/components/lr-segmented.md +20 -2
- package/llms/components/lr-select.md +11 -3
- package/llms/components/lr-selection-toolbar.md +1 -1
- package/llms/components/lr-sequence-playback.md +8 -2
- package/llms/components/lr-signature-pad.md +8 -1
- package/llms/components/lr-slider.md +17 -4
- package/llms/components/lr-stat.md +20 -5
- package/llms/components/lr-step.md +67 -0
- package/llms/components/lr-stepper.md +64 -8
- package/llms/components/lr-suggestion-chips.md +3 -2
- package/llms/components/lr-switch.md +4 -3
- package/llms/components/lr-tab-group.md +10 -3
- package/llms/components/lr-tab-panel.md +2 -2
- package/llms/components/lr-table.md +87 -8
- package/llms/components/lr-tag.md +1 -1
- package/llms/components/lr-textarea.md +17 -1
- package/llms/components/lr-thread-list.md +4 -2
- package/llms/components/lr-time-input.md +9 -2
- package/llms/components/lr-time-zone-picker.md +4 -0
- package/llms/components/lr-timeline-item.md +1 -1
- package/llms/components/lr-timeline.md +47 -3
- package/llms/components/lr-toast-item.md +1 -1
- package/llms/components/lr-toast.md +8 -3
- package/llms/components/lr-token-input.md +68 -11
- package/llms/components/lr-tool-call-chip.md +1 -1
- package/llms/components/lr-tooltip.md +8 -3
- package/llms/components/lr-tree-item.md +1 -1
- package/llms/components/lr-tree.md +2 -1
- package/llms/components/lr-unit-picker.md +4 -0
- package/llms/components/lr-usage-badge.md +1 -1
- package/llms/components/lr-video.md +5 -4
- package/llms/components/lr-voice-picker.md +10 -2
- package/llms/components/lr-widget.md +2 -2
- package/llms/components/lr-zoomable-frame.md +8 -0
- package/llms/index.md +205 -201
- package/llms/migration.md +103 -16
- package/llms/peers.md +3 -3
- package/llms/shared/events-and-types.md +36 -0
- package/llms/shared/forms-and-accessibility.md +4 -1
- package/llms/shared/frameworks-and-ssr.md +10 -1
- package/llms/shared/imports-and-registration.md +68 -2
- package/llms/shared/localization-and-rtl.md +5 -0
- package/llms/shared/native-styles-and-utilities.md +142 -7
- package/llms/shared/styles-and-tokens.md +60 -6
- package/llms/shared/testing-and-utilities.md +30 -0
- package/llms/shared.md +354 -17
- package/llms/tokens.md +6 -1
- package/llms.txt +3 -3
- package/locales.json +1 -1
- package/package.json +48 -10
- package/registrations.json +1 -1
- package/skills/compose-lyra-interfaces/SKILL.md +1 -1
- package/skills/lyra-ui/SKILL.md +1 -1
- package/skills/lyra-ui/commands/migrate.md +1 -1
|
@@ -7,6 +7,8 @@ icon?:unknown;disabled?:boolean;}
|
|
|
7
7
|
/** How `<lr-segmented>` lays out its segments: one horizontally scrolling row (`scroll`), rows
|
|
8
8
|
* that wrap (`wrap`), or a fixed-column grid (`grid`). */
|
|
9
9
|
export type LyraSegmentedLayout='scroll'|'wrap'|'grid';
|
|
10
|
+
/** Which side of each segment's label its optional `icon` renders on.*/
|
|
11
|
+
export type LyraSegmentedIconPlacement='start'|'end';
|
|
10
12
|
/** Detail of `lr-change-request`.*/
|
|
11
13
|
export interface LyraSegmentedChangeRequestDetail{
|
|
12
14
|
/** Value of the segment the user is selecting.*/
|
|
@@ -56,12 +58,18 @@ readonly previousValue:string;}export interface LyraSegmentedEventMap{'lr-change
|
|
|
56
58
|
* @cssprop [--lr-form-control-label-font-size=var(--lr-font-size-md-sm)] - Font size of the field label.
|
|
57
59
|
* @cssprop [--lr-form-control-label-font-weight=var(--lr-font-weight-semibold)] - Font weight of the field label.
|
|
58
60
|
* @cssprop [--lr-form-control-label-color=inherit] - Text color of the field label.
|
|
61
|
+
* @cssprop [--lr-form-control-label-gap=var(--lr-space-xs)] - Space between the label above the
|
|
62
|
+
* field and the field.
|
|
63
|
+
* @cssprop [--lr-form-control-label-line-height=inherit] - Line height of the field label.
|
|
64
|
+
* @cssprop [--lr-form-control-label-text-align=inherit] - Text alignment of the field label.
|
|
65
|
+
* @cssprop [--lr-form-control-label-text-transform=inherit] - Text transform of the field label.
|
|
59
66
|
* @csspart form-control-label - The noninteractive field caption, visually hidden by default.
|
|
60
67
|
* @csspart hint - Supporting text referenced by the radiogroup when supplied.
|
|
61
68
|
* @csspart base - The `role="radiogroup"` root; the horizontal scroll owner in the default
|
|
62
69
|
* `layout="scroll"`, a wrapping row or a grid otherwise.
|
|
63
70
|
* @csspart segment - A single `role="radio"` button with a 24×24 CSS pixel minimum box at every size tier.
|
|
64
|
-
* @csspart segment-icon - Optional decorative
|
|
71
|
+
* @csspart segment-icon - Optional decorative visual supplied by the item's `icon` field, before the
|
|
72
|
+
* label or, with `icon-placement="end"`, after it.
|
|
65
73
|
* Content may have a natural aspect ratio and is not restricted to a square icon; it is inert and
|
|
66
74
|
* hidden from assistive technology, so it cannot provide an independent action or accessible name.
|
|
67
75
|
* @csspart segment-label - The segment's label text.
|
|
@@ -107,6 +115,8 @@ readonly previousValue:string;}export interface LyraSegmentedEventMap{'lr-change
|
|
|
107
115
|
* @cssprop [--lr-segmented-font-size=var(--lr-form-control-font-size)] - Each segment's font size,
|
|
108
116
|
* taken from the `size` tier's shared control font size.
|
|
109
117
|
* @cssprop [--lr-segmented-track-gap=var(--lr-size-0-125rem)] - Gap between segments.
|
|
118
|
+
* @cssprop [--lr-segmented-segment-min-size=var(--lr-size-24px)] - Minimum inline and block size of each
|
|
119
|
+
* segment's hit area. Raise it for a touch target; it never goes below the default.
|
|
110
120
|
* @cssprop [--lr-segmented-columns=3] - Column count of `layout="grid"`. Columns share the track
|
|
111
121
|
* width equally.
|
|
112
122
|
* @cssprop [--lr-segmented-track-radius=var(--lr-radius)] - Track corner radius.
|
|
@@ -117,6 +127,7 @@ readonly previousValue:string;}export interface LyraSegmentedEventMap{'lr-change
|
|
|
117
127
|
* default, matching its own current absence of a background.
|
|
118
128
|
* @cssprop [--lr-segmented-track-border-color=var(--lr-color-border)] - Border color of the `base`
|
|
119
129
|
* track, which previously read that token as a literal with no override hook.
|
|
130
|
+
* @cssprop [--lr-form-control-label-line-height=inherit] - Line height of the field label.
|
|
120
131
|
* @status stable
|
|
121
132
|
* @since 4.0.0
|
|
122
133
|
*/
|
|
@@ -153,7 +164,15 @@ size:LyraSize;
|
|
|
153
164
|
* reading order in every layout: ArrowRight/ArrowLeft step along a row and continue onto the
|
|
154
165
|
* next or previous row, mirrored under RTL. Unsupported values normalize to `'scroll'`.
|
|
155
166
|
* Reflects as the `layout` attribute. */
|
|
156
|
-
get layout():LyraSegmentedLayout;set layout(next:LyraSegmentedLayout);private _layout;
|
|
167
|
+
get layout():LyraSegmentedLayout;set layout(next:LyraSegmentedLayout);private _layout;
|
|
168
|
+
/** Side of the label each item's `icon` renders on: `'start'` (default) before it, `'end'` after
|
|
169
|
+
* it, both logical so they follow the writing direction. Unsupported values normalize to
|
|
170
|
+
* `'start'`. Reflects as the `icon-placement` attribute. */
|
|
171
|
+
get iconPlacement():LyraSegmentedIconPlacement;set iconPlacement(next:LyraSegmentedIconPlacement);private _iconPlacement;
|
|
172
|
+
/** Stretches the control across its container and grows the segments to share the spare width,
|
|
173
|
+
* in every `layout`. A `'scroll'` row whose segments no longer fit still scrolls. Off by default,
|
|
174
|
+
* so the control keeps its content width. Reflects as the `full-width` attribute. */
|
|
175
|
+
fullWidth:boolean;constructor();private selectedItem?;private rehomeSegmentFocus;private scrollOverflow;private select;private segmentButtonAt;private focusItem;
|
|
157
176
|
/** Scroll the segment with the given `value` into view within the (possibly overflowing) track.
|
|
158
177
|
* Public so a consumer can reveal a segment without selecting it. Scrolls only the track. */
|
|
159
|
-
scrollToValue(value:string):void;protected updated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void;private keyboardOriginIndex;private onKeyDown;adoptedCallback():void;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-segmented':LyraSegmented;}}
|
|
178
|
+
scrollToValue(value:string):void;protected updated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void;private keyboardOriginIndex;private onKeyDown;adoptedCallback():void;private renderSegmentIcon;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-segmented':LyraSegmented;}}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{finiteCount}from"../../../internal/numbers.js";import{literalSetConverter}from"../../../internal/converters.js";import{layoutScale}from"../../../internal/layout-scale.js";import{formControlSupportingState}from"../../../internal/form-control-template.js";import{SnapshotProperty}from"../../../internal/collection-source-tracker.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{normalizeLabel}from"../../../internal/accessible-name.js";import{sizes}from"../../../internal/sizes.styles.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{shouldIgnoreNavigationKey,resolveListMove}from"../../../internal/list-navigation.js";import{motionScrollBehavior}from"../../../internal/motion.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{styles}from"./segmented.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";const SEGMENTED_LAYOUT=literalSetConverter(["scroll","wrap","grid"],"scroll"),MAX_SEGMENTED_ITEMS=256;function snapshotSegmentedItems(value,reportOmitted){try{if(!Array.isArray(value))return Object.freeze([])}catch{return Object.freeze([])}const seenValues=new Set,normalized=[];let length=0;try{const sourceLength=finiteCount(value.length);length=Math.min(sourceLength,MAX_SEGMENTED_ITEMS),reportOmitted(sourceLength-length)}catch{return Object.freeze(normalized)}for(let index=0;index<length;index+=1)try{const candidate=value[index];if(!candidate||typeof candidate!="object")continue;const record=candidate,itemValue=record.value,label=record.label,disabled=record.disabled,icon=record.icon;if(typeof itemValue!="string"||itemValue.length===0||itemValue!==itemValue.trim()||seenValues.has(itemValue)||typeof label!="string"||label.trim()===""||disabled!==void 0&&typeof disabled!="boolean")continue;seenValues.add(itemValue),normalized.push(Object.freeze({value:itemValue,label,...icon!==void 0?{icon}:{},...disabled!==void 0?{disabled}:{}}))}catch{}return Object.freeze(normalized)}class LyraSegmented extends LyraElement{static{this.styles=[LyraElement.styles,sizes,scrollOverflowFadeStyles,styles]}get omittedItems(){return this.omitted}get items(){return this.itemsSnapshot.read()}set items(value){this.itemsSnapshot.assign(this,"items",value)}get value(){return this._value}set value(next){markVetoGuardWrite(this.selectGuard),this._value=next}connectedCallback(){super.connectedCallback(),this.updateBrowserDerivedState(this.syncNativeFieldAssignments)}get layout(){return this._layout}set layout(next){const normalized=SEGMENTED_LAYOUT.normalizeReflected(this,"layout",next),old=this._layout;old!==normalized&&(this._layout=normalized,this.requestUpdate("layout",old))}constructor(){super(),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector('[part~="base"]'),()=>Array.from(this.renderRoot.querySelectorAll('[part="hint"]:not([hidden])'))),this.omitted=0,this.itemsSnapshot=new SnapshotProperty(Object.freeze([]),value=>(this.omitted=0,snapshotSegmentedItems(value,count=>{this.omitted=count}))),this.selectGuard=new VetoWriteGuard,this._value="",this.label="",this.labelDisplay="hidden",this.hint="",this.slotPresence=new SlotPresenceController(this),this.hasNativeLabelAssignment=!1,this.hasNativeHintAssignment=!1,this.syncNativeFieldAssignments=()=>{const assigned=name=>{const slot=this.renderRoot?.querySelector(`slot[name="${name}"]`);return slot?slot.assignedNodes().length>0:Array.from(this.children).some(child=>child.getAttribute("slot")===name)};this.hasNativeLabelAssignment=assigned("label"),this.hasNativeHintAssignment=assigned("hint")},this.onFieldSlotChange=()=>{this.updateBrowserDerivedState(this.syncNativeFieldAssignments)},this.disabled=!1,this.size="m",this._layout="scroll",this.rehomeSegmentFocus=!1,this.scrollOverflow=observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part="base"]')),this.onKeyDown=e=>{if(this.disabled||e.defaultPrevented||shouldIgnoreNavigationKey(e))return;const navigable=this.items.map((item,index)=>({item,index})).filter(({item})=>!item.disabled);if(navigable.length===0)return;const focusedIndex=this.keyboardOriginIndex(e),selectedIndex=this.items.indexOf(this.selectedItem),originIndex=focusedIndex>=0?focusedIndex:selectedIndex,currentIndex=selectedIndex<0&&this.segmentButtonAt(originIndex)?.tabIndex===0?-1:navigable.findIndex(({index})=>index===originIndex),track=e.currentTarget,direction=e.key==="ArrowLeft"||e.key==="ArrowRight"?track.ownerDocument.defaultView?.getComputedStyle?.(track).direction:void 0,targetIndex=resolveListMove(e,{count:navigable.length,current:currentIndex,orientation:"both",direction:direction==="ltr"||direction==="rtl"?direction:this.effectiveDirection});if(targetIndex===null)return;e.preventDefault();const target=navigable[targetIndex];this.select(target.item)&&this.focusItem(target.index)},this.requestUpdate("layout",void 0)}select(item){if(item.disabled||this.disabled)return!1;if(item!==this.selectedItem){if(item.value===this.value)this.selectedItem=item;else if(requestThenCommit({requestDetail:{value:item.value,previousValue:this.value},emitRequest:(detail,init)=>this.emit("lr-change-request",detail,init),guard:this.selectGuard,commit:()=>{item.disabled||this.disabled||(this.selectedItem=item,this.value=item.value,this.emit("lr-change",{value:item.value}))}}).defaultPrevented||this.value!==item.value)return!1}return this.isConnected&&!this.disabled&&this.value===item.value&&this.items.includes(item)&&this.emit("lr-activate",{value:item.value}),!0}segmentButtonAt(index){return this.renderRoot.querySelector(`[part="segment"][data-index="${index}"]`)}focusItem(index){this.segmentButtonAt(index)?.focus()}scrollToValue(value){const base=this.renderRoot.querySelector('[part="base"]'),segment=this.segmentButtonAt(this.items.findIndex(item=>item.value===value));if(!base||!segment)return;const track=base.getBoundingClientRect(),rect=segment.getBoundingClientRect(),scale=layoutScale(base).x,start=track.left+base.clientLeft*scale,end=start+base.clientWidth*scale,left=rect.left<start?rect.left-start:Math.max(0,rect.right-end);left&&base.scrollBy({left:left/scale,behavior:motionScrollBehavior(this)})}updated(changed){super.updated(changed),this.scrollOverflow.observeExtra(this.renderRoot.querySelectorAll('[part="segment"]')),this.rehomeSegmentFocus&&(this.rehomeSegmentFocus=!1,this.renderRoot.querySelector('[part="segment"][tabindex="0"]')?.focus()),changed.has("value")&&changed.get("value")!==void 0&&this.value&&this.scrollToValue(this.value)}willUpdate(changed){super.willUpdate(changed),changed.has("items")&&shadowFocusTarget(this)?.getAttribute("part")==="segment"&&(this.rehomeSegmentFocus=!0),(changed.has("value")||changed.has("items")&&(!this.selectedItem||!this.items.includes(this.selectedItem)||this.selectedItem.value!==this.value||this.selectedItem.disabled))&&(this.selectedItem=this.items.find(item=>item.value===this.value&&!item.disabled))}keyboardOriginIndex(event){const fromEvent=event.composedPath().find(candidate2=>candidate2.nodeType===1&&candidate2.getAttribute?.("part")==="segment"&&candidate2.getRootNode()===this.renderRoot),focused=shadowFocusTarget(this),candidate=fromEvent??(focused?.getAttribute("part")==="segment"?focused:void 0),index=Number(candidate?.dataset.index);return Number.isInteger(index)&&index>=0&&index<this.items.length?index:-1}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted()}render(){const hostLabel=hostAriaLabel(this),hasLabelSlot=this.hasNativeLabelAssignment||this.slotPresence.has("label"),hasLabel=hasLabelSlot||normalizeLabel(this.label)!==void 0,{hasHint,hintId,describedBy}=formControlSupportingState({idPrefix:"segmented",hint:this.hint,withHint:this.hasNativeHintAssignment,presence:{has:name=>name==="hint"&&this.slotPresence.has(name)}}),ariaLabel=hostLabel??(hasLabelSlot?nothing:normalizeLabel(this.label)??nothing),selectedIndex=this.items.indexOf(this.selectedItem),fallbackSelectedIndex=selectedIndex>=0?selectedIndex:this.items.findIndex(item=>item.value===this.value&&!item.disabled),tabbableIndex=fallbackSelectedIndex!==-1?fallbackSelectedIndex:this.items.findIndex(item=>!item.disabled);return html`
|
|
1
|
+
import{__decorate}from"tslib";import{finiteCount}from"../../../internal/numbers.js";import{literalSetConverter}from"../../../internal/converters.js";import{layoutScale}from"../../../internal/layout-scale.js";import{formControlSupportingState}from"../../../internal/form-control-template.js";import{SnapshotProperty}from"../../../internal/collection-source-tracker.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{normalizeLabel}from"../../../internal/accessible-name.js";import{sizes}from"../../../internal/sizes.styles.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{shouldIgnoreNavigationKey,resolveListMove}from"../../../internal/list-navigation.js";import{motionScrollBehavior}from"../../../internal/motion.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{styles}from"./segmented.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";const SEGMENTED_LAYOUT=literalSetConverter(["scroll","wrap","grid"],"scroll"),SEGMENTED_ICON_PLACEMENT=literalSetConverter(["start","end"],"start"),MAX_SEGMENTED_ITEMS=256;function snapshotSegmentedItems(value,reportOmitted){try{if(!Array.isArray(value))return Object.freeze([])}catch{return Object.freeze([])}const seenValues=new Set,normalized=[];let length=0;try{const sourceLength=finiteCount(value.length);length=Math.min(sourceLength,MAX_SEGMENTED_ITEMS),reportOmitted(sourceLength-length)}catch{return Object.freeze(normalized)}for(let index=0;index<length;index+=1)try{const candidate=value[index];if(!candidate||typeof candidate!="object")continue;const record=candidate,itemValue=record.value,label=record.label,disabled=record.disabled,icon=record.icon;if(typeof itemValue!="string"||itemValue.length===0||itemValue!==itemValue.trim()||seenValues.has(itemValue)||typeof label!="string"||label.trim()===""||disabled!==void 0&&typeof disabled!="boolean")continue;seenValues.add(itemValue),normalized.push(Object.freeze({value:itemValue,label,...icon!==void 0?{icon}:{},...disabled!==void 0?{disabled}:{}}))}catch{}return Object.freeze(normalized)}class LyraSegmented extends LyraElement{static{this.styles=[LyraElement.styles,sizes,scrollOverflowFadeStyles,styles]}get omittedItems(){return this.omitted}get items(){return this.itemsSnapshot.read()}set items(value){this.itemsSnapshot.assign(this,"items",value)}get value(){return this._value}set value(next){markVetoGuardWrite(this.selectGuard),this._value=next}connectedCallback(){super.connectedCallback(),this.updateBrowserDerivedState(this.syncNativeFieldAssignments)}get layout(){return this._layout}set layout(next){const normalized=SEGMENTED_LAYOUT.normalizeReflected(this,"layout",next),old=this._layout;old!==normalized&&(this._layout=normalized,this.requestUpdate("layout",old))}get iconPlacement(){return this._iconPlacement}set iconPlacement(next){const normalized=SEGMENTED_ICON_PLACEMENT.normalizeReflected(this,"icon-placement",next),old=this._iconPlacement;old!==normalized&&(this._iconPlacement=normalized,this.requestUpdate("iconPlacement",old))}constructor(){super(),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector('[part~="base"]'),()=>Array.from(this.renderRoot.querySelectorAll('[part="hint"]:not([hidden])'))),this.omitted=0,this.itemsSnapshot=new SnapshotProperty(Object.freeze([]),value=>(this.omitted=0,snapshotSegmentedItems(value,count=>{this.omitted=count}))),this.selectGuard=new VetoWriteGuard,this._value="",this.label="",this.labelDisplay="hidden",this.hint="",this.slotPresence=new SlotPresenceController(this),this.hasNativeLabelAssignment=!1,this.hasNativeHintAssignment=!1,this.syncNativeFieldAssignments=()=>{const assigned=name=>{const slot=this.renderRoot?.querySelector(`slot[name="${name}"]`);return slot?slot.assignedNodes().length>0:Array.from(this.children).some(child=>child.getAttribute("slot")===name)};this.hasNativeLabelAssignment=assigned("label"),this.hasNativeHintAssignment=assigned("hint")},this.onFieldSlotChange=()=>{this.updateBrowserDerivedState(this.syncNativeFieldAssignments)},this.disabled=!1,this.size="m",this._layout="scroll",this._iconPlacement="start",this.fullWidth=!1,this.rehomeSegmentFocus=!1,this.scrollOverflow=observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part="base"]')),this.onKeyDown=e=>{if(this.disabled||e.defaultPrevented||shouldIgnoreNavigationKey(e))return;const navigable=this.items.map((item,index)=>({item,index})).filter(({item})=>!item.disabled);if(navigable.length===0)return;const focusedIndex=this.keyboardOriginIndex(e),selectedIndex=this.items.indexOf(this.selectedItem),originIndex=focusedIndex>=0?focusedIndex:selectedIndex,currentIndex=selectedIndex<0&&this.segmentButtonAt(originIndex)?.tabIndex===0?-1:navigable.findIndex(({index})=>index===originIndex),track=e.currentTarget,direction=e.key==="ArrowLeft"||e.key==="ArrowRight"?track.ownerDocument.defaultView?.getComputedStyle?.(track).direction:void 0,targetIndex=resolveListMove(e,{count:navigable.length,current:currentIndex,orientation:"both",direction:direction==="ltr"||direction==="rtl"?direction:this.effectiveDirection});if(targetIndex===null)return;e.preventDefault();const target=navigable[targetIndex];this.select(target.item)&&this.focusItem(target.index)},this.requestUpdate("layout",void 0)}select(item){if(item.disabled||this.disabled)return!1;if(item!==this.selectedItem){if(item.value===this.value)this.selectedItem=item;else if(requestThenCommit({requestDetail:{value:item.value,previousValue:this.value},emitRequest:(detail,init)=>this.emit("lr-change-request",detail,init),guard:this.selectGuard,commit:()=>{item.disabled||this.disabled||(this.selectedItem=item,this.value=item.value,this.emit("lr-change",{value:item.value}))}}).defaultPrevented||this.value!==item.value)return!1}return this.isConnected&&!this.disabled&&this.value===item.value&&this.items.includes(item)&&this.emit("lr-activate",{value:item.value}),!0}segmentButtonAt(index){return this.renderRoot.querySelector(`[part="segment"][data-index="${index}"]`)}focusItem(index){this.segmentButtonAt(index)?.focus()}scrollToValue(value){const base=this.renderRoot.querySelector('[part="base"]'),segment=this.segmentButtonAt(this.items.findIndex(item=>item.value===value));if(!base||!segment)return;const track=base.getBoundingClientRect(),rect=segment.getBoundingClientRect(),scale=layoutScale(base).x,start=track.left+base.clientLeft*scale,end=start+base.clientWidth*scale,left=rect.left<start?rect.left-start:Math.max(0,rect.right-end);left&&base.scrollBy({left:left/scale,behavior:motionScrollBehavior(this)})}updated(changed){super.updated(changed),this.scrollOverflow.observeExtra(this.renderRoot.querySelectorAll('[part="segment"]')),this.rehomeSegmentFocus&&(this.rehomeSegmentFocus=!1,this.renderRoot.querySelector('[part="segment"][tabindex="0"]')?.focus()),changed.has("value")&&changed.get("value")!==void 0&&this.value&&this.scrollToValue(this.value)}willUpdate(changed){super.willUpdate(changed),changed.has("items")&&shadowFocusTarget(this)?.getAttribute("part")==="segment"&&(this.rehomeSegmentFocus=!0),(changed.has("value")||changed.has("items")&&(!this.selectedItem||!this.items.includes(this.selectedItem)||this.selectedItem.value!==this.value||this.selectedItem.disabled))&&(this.selectedItem=this.items.find(item=>item.value===this.value&&!item.disabled))}keyboardOriginIndex(event){const fromEvent=event.composedPath().find(candidate2=>candidate2.nodeType===1&&candidate2.getAttribute?.("part")==="segment"&&candidate2.getRootNode()===this.renderRoot),focused=shadowFocusTarget(this),candidate=fromEvent??(focused?.getAttribute("part")==="segment"?focused:void 0),index=Number(candidate?.dataset.index);return Number.isInteger(index)&&index>=0&&index<this.items.length?index:-1}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted()}renderSegmentIcon(item){return item.icon!==void 0?html`<span part="segment-icon" aria-hidden="true" inert>${item.icon}</span>`:nothing}render(){const hostLabel=hostAriaLabel(this),hasLabelSlot=this.hasNativeLabelAssignment||this.slotPresence.has("label"),hasLabel=hasLabelSlot||normalizeLabel(this.label)!==void 0,{hasHint,hintId,describedBy}=formControlSupportingState({idPrefix:"segmented",hint:this.hint,withHint:this.hasNativeHintAssignment,presence:{has:name=>name==="hint"&&this.slotPresence.has(name)}}),ariaLabel=hostLabel??(hasLabelSlot?nothing:normalizeLabel(this.label)??nothing),selectedIndex=this.items.indexOf(this.selectedItem),fallbackSelectedIndex=selectedIndex>=0?selectedIndex:this.items.findIndex(item=>item.value===this.value&&!item.disabled),tabbableIndex=fallbackSelectedIndex!==-1?fallbackSelectedIndex:this.items.findIndex(item=>!item.disabled);return html`
|
|
2
2
|
<div part="form-control">
|
|
3
3
|
<div id="segmented-label" part="form-control-label" ?hidden=${!hasLabel} ><slot name="label" @slotchange=${this.onFieldSlotChange}>${this.label}</slot></div
|
|
4
4
|
>
|
|
5
5
|
<div part="base" role="radiogroup" aria-label=${ariaLabel} aria-labelledby=${hostLabel===null&&hasLabelSlot?"segmented-label":nothing} aria-describedby=${describedBy??nothing} aria-disabled=${this.disabled?"true":nothing} @keydown=${this.onKeyDown} >
|
|
6
6
|
${repeat(this.items,item=>item.value,(item,index)=>html`<button type="button" part="segment" data-value=${item.value} data-index=${index} role="radio" aria-checked=${index===fallbackSelectedIndex?"true":"false"} aria-disabled=${item.disabled||this.disabled?"true":"false"} tabindex=${index===tabbableIndex?"0":"-1"} @click=${()=>this.select(item)} >
|
|
7
|
-
${
|
|
8
|
-
>`:nothing}<span part="segment-label">${item.label}</span>
|
|
7
|
+
${this.iconPlacement==="end"?nothing:this.renderSegmentIcon(item)}<span part="segment-label">${item.label}</span>${this.iconPlacement==="end"?this.renderSegmentIcon(item):nothing}
|
|
9
8
|
</button>`)}
|
|
10
9
|
</div>
|
|
11
10
|
<div id=${hintId} part="hint" ?hidden=${!hasHint} ><slot name="hint" @slotchange=${this.onFieldSlotChange}>${this.hint}</slot></div
|
|
12
11
|
>
|
|
13
12
|
</div>
|
|
14
|
-
`}}__decorate([property({attribute:!1})],LyraSegmented.prototype,"items",null),__decorate([property()],LyraSegmented.prototype,"value",null),__decorate([property()],LyraSegmented.prototype,"label",void 0),__decorate([property({attribute:"label-display",reflect:!0})],LyraSegmented.prototype,"labelDisplay",void 0),__decorate([property()],LyraSegmented.prototype,"hint",void 0),__decorate([state()],LyraSegmented.prototype,"hasNativeLabelAssignment",void 0),__decorate([state()],LyraSegmented.prototype,"hasNativeHintAssignment",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraSegmented.prototype,"disabled",void 0),__decorate([property({reflect:!0})],LyraSegmented.prototype,"size",void 0),__decorate([property({converter:SEGMENTED_LAYOUT,reflect:!0})],LyraSegmented.prototype,"layout",null),__decorate([state()],LyraSegmented.prototype,"selectedItem",void 0);export{LyraSegmented};
|
|
13
|
+
`}}__decorate([property({attribute:!1})],LyraSegmented.prototype,"items",null),__decorate([property()],LyraSegmented.prototype,"value",null),__decorate([property()],LyraSegmented.prototype,"label",void 0),__decorate([property({attribute:"label-display",reflect:!0})],LyraSegmented.prototype,"labelDisplay",void 0),__decorate([property()],LyraSegmented.prototype,"hint",void 0),__decorate([state()],LyraSegmented.prototype,"hasNativeLabelAssignment",void 0),__decorate([state()],LyraSegmented.prototype,"hasNativeHintAssignment",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraSegmented.prototype,"disabled",void 0),__decorate([property({reflect:!0})],LyraSegmented.prototype,"size",void 0),__decorate([property({converter:SEGMENTED_LAYOUT,reflect:!0})],LyraSegmented.prototype,"layout",null),__decorate([property({converter:SEGMENTED_ICON_PLACEMENT,attribute:"icon-placement",reflect:!0})],LyraSegmented.prototype,"iconPlacement",null),__decorate([property({type:Boolean,attribute:"full-width",reflect:!0})],LyraSegmented.prototype,"fullWidth",void 0),__decorate([state()],LyraSegmented.prototype,"selectedItem",void 0);export{LyraSegmented};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{forcedColorsPart}from"../../../internal/forced-colors.styles.js";import{activeFill,disabledControl,focusRingInsetOffset}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{visuallyHidden}from"../../../internal/a11y.js";import{formControlTextWrap}from"../../../internal/form-control.styles.js";import{formControlChrome}from"../../../internal/form-control/chrome.styles.js";const styles=css` :host{display:inline-flex;min-inline-size:0;max-inline-size:100%;--_lr-segmented-track-min-height:var(--lr-form-control-height);--_lr-segmented-segment-padding:var(--lr-form-control-padding-block) var(--lr-form-control-padding-inline);--_lr-segmented-font-size:var(--lr-form-control-font-size)}${formControlChrome} [part=form-control]{position:relative;display:flex;flex-direction:column;min-inline-size:0;max-inline-size:100%}[part=form-control-label],[part=hint]{${formControlTextWrap}}:host(:not([label-display=visible])) [part=form-control-label]{${visuallyHidden}}[part=base]{display:inline-flex;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;min-inline-size:0;min-block-size:var(--lr-segmented-track-height,var(--lr-segmented-track-min-height,var(--_lr-segmented-track-min-height)));block-size:var(--lr-segmented-track-height,auto);box-sizing:border-box;background:var(--lr-segmented-track-bg,transparent);border:var(--lr-border-width-thin) solid var(--lr-segmented-track-border-color,var(--lr-color-border));border-radius:var(--lr-segmented-track-radius,var(--lr-radius));padding:var(--lr-segmented-track-padding,var(--lr-size-0-125rem));gap:var(--lr-segmented-track-gap,var(--lr-size-0-125rem))}[part=segment]{min-inline-size:var(--lr-size-24px);min-block-size:var(--lr-size-24px);border:none;border-radius:var(--lr-segmented-segment-radius,calc(var(--lr-form-control-radius) * 0.7));background:transparent;color:var(--lr-color-text-quiet);font:inherit;font-size:var(--lr-segmented-font-size,var(--_lr-segmented-font-size));padding:var(--lr-segmented-segment-padding,var(--_lr-segmented-segment-padding));cursor:pointer;transition:background-color var(--lr-transition-fast),color var(--lr-transition-fast)}[part=segment-icon]{display:inline-flex;align-items:center;margin-inline-end:var(--lr-space-xs);block-size:var(--lr-size-1em);max-inline-size:var(--lr-size-2-5rem)}[part=segment][aria-disabled=true]{${disabledControl}}:where([part=segment]):hover:where(:not([aria-disabled=true]):not([aria-checked=true])){color:var(--lr-segmented-hover-color,var(--lr-color-text));background:var(--lr-segmented-hover-bg,transparent);box-shadow:var(--lr-segmented-hover-shadow,none)}:where([part=segment]):active:where(:not([aria-disabled=true]):not([aria-checked=true])){background:var(--lr-segmented-active-bg,${activeFill("transparent")});color:var(--lr-segmented-active-color,var(--lr-segmented-hover-color,var(--lr-color-text)))}[part=segment]:focus-visible{${focusRingInsetOffset}}[part=segment][aria-checked=true]{background:var(--lr-segmented-selected-bg,var(--lr-color-text));color:var(--lr-segmented-selected-color,var(--lr-color-surface));font-weight:var(--lr-segmented-selected-font-weight,var(--lr-font-weight-semibold));box-shadow:var(--lr-segmented-selected-shadow,var(--lr-shadow-xs))}:host([layout=grid]){display:flex}:host([layout=wrap]) [part=base],:host([layout=grid]) [part=base]{overflow:visible;block-size:auto;-webkit-mask-image:none;mask-image:none}:host([layout=wrap]) [part=base]{flex-wrap:wrap}:host([layout=grid]) [part=base]{display:grid;grid-template-columns:repeat(var(--lr-segmented-columns,3),minmax(0,1fr))}:host([layout=wrap]) [part=segment],:host([layout=grid]) [part=segment]{max-inline-size:100%;white-space:normal;overflow-wrap:anywhere}${forcedColorsPart('[part="segment"][aria-checked="true"]')} `;export{styles};
|
|
1
|
+
import{forcedColorsPart}from"../../../internal/forced-colors.styles.js";import{activeFill,disabledControl,focusRingInsetOffset}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{visuallyHidden}from"../../../internal/a11y.js";import{formControlTextWrap}from"../../../internal/form-control.styles.js";import{formControlChrome}from"../../../internal/form-control/chrome.styles.js";const styles=css` :host{display:inline-flex;min-inline-size:0;max-inline-size:100%;--_lr-segmented-track-min-height:var(--lr-form-control-height);--_lr-segmented-segment-padding:var(--lr-form-control-padding-block) var(--lr-form-control-padding-inline);--_lr-segmented-font-size:var(--lr-form-control-font-size)}${formControlChrome} [part=form-control]{position:relative;display:flex;flex-direction:column;min-inline-size:0;max-inline-size:100%}[part=form-control-label],[part=hint]{${formControlTextWrap}}:host(:not([label-display=visible])) [part=form-control-label]{${visuallyHidden}}[part=base]{display:inline-flex;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;min-inline-size:0;min-block-size:var(--lr-segmented-track-height,var(--lr-segmented-track-min-height,var(--_lr-segmented-track-min-height)));block-size:var(--lr-segmented-track-height,auto);box-sizing:border-box;background:var(--lr-segmented-track-bg,transparent);border:var(--lr-border-width-thin) solid var(--lr-segmented-track-border-color,var(--lr-color-border));border-radius:var(--lr-segmented-track-radius,var(--lr-radius));padding:var(--lr-segmented-track-padding,var(--lr-size-0-125rem));gap:var(--lr-segmented-track-gap,var(--lr-size-0-125rem))}[part=segment]{min-inline-size:var(--lr-segmented-segment-min-size,var(--lr-size-24px));min-block-size:var(--lr-segmented-segment-min-size,var(--lr-size-24px));border:none;border-radius:var(--lr-segmented-segment-radius,calc(var(--lr-form-control-radius) * 0.7));background:transparent;color:var(--lr-color-text-quiet);font:inherit;font-size:var(--lr-segmented-font-size,var(--_lr-segmented-font-size));padding:var(--lr-segmented-segment-padding,var(--_lr-segmented-segment-padding));cursor:pointer;transition:background-color var(--lr-transition-fast),color var(--lr-transition-fast)}[part=segment-icon]{display:inline-flex;align-items:center;margin-inline-end:var(--lr-space-xs);block-size:var(--lr-size-1em);max-inline-size:var(--lr-size-2-5rem)}:host([icon-placement=end]) [part=segment-icon]{margin-inline:var(--lr-space-xs) 0}:host([full-width]){display:flex}:host([full-width]) [part=form-control]{flex:1 1 auto}:host([full-width]) [part=segment]{flex:1 0 auto}[part=segment][aria-disabled=true]{${disabledControl}}:where([part=segment]):hover:where(:not([aria-disabled=true]):not([aria-checked=true])){color:var(--lr-segmented-hover-color,var(--lr-color-text));background:var(--lr-segmented-hover-bg,transparent);box-shadow:var(--lr-segmented-hover-shadow,none)}:where([part=segment]):active:where(:not([aria-disabled=true]):not([aria-checked=true])){background:var(--lr-segmented-active-bg,${activeFill("transparent")});color:var(--lr-segmented-active-color,var(--lr-segmented-hover-color,var(--lr-color-text)))}[part=segment]:focus-visible{${focusRingInsetOffset}}[part=segment][aria-checked=true]{background:var(--lr-segmented-selected-bg,var(--lr-color-text));color:var(--lr-segmented-selected-color,var(--lr-color-surface));font-weight:var(--lr-segmented-selected-font-weight,var(--lr-font-weight-semibold));box-shadow:var(--lr-segmented-selected-shadow,var(--lr-shadow-xs))}:host([layout=grid]){display:flex}:host([layout=wrap]) [part=base],:host([layout=grid]) [part=base]{overflow:visible;block-size:auto;-webkit-mask-image:none;mask-image:none}:host([layout=wrap]) [part=base]{flex-wrap:wrap}:host([layout=grid]) [part=base]{display:grid;grid-template-columns:repeat(var(--lr-segmented-columns,3),minmax(0,1fr))}:host([layout=wrap]) [part=segment],:host([layout=grid]) [part=segment]{max-inline-size:100%;white-space:normal;overflow-wrap:anywhere}${forcedColorsPart('[part="segment"][aria-checked="true"]')} `;export{styles};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraVariant}from'../../../internal/variants.js';
|
|
2
|
+
/** Attention animation drawn on a step's marker.*/
|
|
3
|
+
export type LyraStepAttention='none'|'pulse'|'bounce';
|
|
4
|
+
/**
|
|
5
|
+
* `<lr-step>` — one stage inside a child-driven `<lr-stepper>`: its position marker, label,
|
|
6
|
+
* optional description and completion status. Mirrors `wa-step`.
|
|
7
|
+
*
|
|
8
|
+
* The owning stepper numbers the step, marks the current one, locks the steps a `linear` stepper
|
|
9
|
+
* cannot reach yet and, when it is `clickable`, turns the marker and content into a real button.
|
|
10
|
+
* Outside a stepper the element still renders, as a plain list item.
|
|
11
|
+
*
|
|
12
|
+
* `name` identifies the step to the stepper's `active` property, `goTo()` and its events.
|
|
13
|
+
* `completed` shows a check mark in place of the number; `loading` shows a spinner and sets
|
|
14
|
+
* `aria-busy`; `disabled` makes the step unreachable. `variant` colors the marker (a cosmetic
|
|
15
|
+
* cue only: pair a failed or flagged step with an `icon` and a clear label). `attention`
|
|
16
|
+
* (`pulse` or `bounce`) animates the marker to draw the eye and stops under
|
|
17
|
+
* `prefers-reduced-motion: reduce`.
|
|
18
|
+
*
|
|
19
|
+
* `custom-states` names extra states of the author's own (for example `custom-states="error"` on a
|
|
20
|
+
* step whose server check failed); each one is published as a CSS custom state, so
|
|
21
|
+
* `lr-step:state(error)::part(marker)` styles it without a wrapper class. These names are a
|
|
22
|
+
* styling hook only: they change neither the status text nor the stepper's behavior, so pair a
|
|
23
|
+
* meaningful state with a visible label, `variant` or `icon`.
|
|
24
|
+
*
|
|
25
|
+
* Every state also reaches assistive technology as visually hidden status text (completed,
|
|
26
|
+
* loading, unavailable, locked, not started), localized through the standard string table, and
|
|
27
|
+
* the current step carries `aria-current="step"` on the element that takes focus.
|
|
28
|
+
*
|
|
29
|
+
* @customElement lr-step
|
|
30
|
+
* @slot - The step's label.
|
|
31
|
+
* @slot description - Optional text shown under the label.
|
|
32
|
+
* @slot icon - An element that replaces the step number, check mark or spinner.
|
|
33
|
+
* @csspart step - The outer wrapper.
|
|
34
|
+
* @csspart connector - The line joining this step to its neighbours. Each step draws the half
|
|
35
|
+
* leading in and the half leading out; both carry this part name.
|
|
36
|
+
* @csspart button - The `<button>` wrapping the marker and content, rendered only while the
|
|
37
|
+
* owning stepper is `clickable`; otherwise the same wrapper is a plain non-focusable element.
|
|
38
|
+
* @csspart marker - The round marker showing the number, check mark, spinner or `icon` slot.
|
|
39
|
+
* @csspart spinner - The spinner shown inside the marker while `loading`.
|
|
40
|
+
* @csspart content - The wrapper around the label, status text and description.
|
|
41
|
+
* @csspart label - The label.
|
|
42
|
+
* @csspart status - Visually hidden text telling assistive technology whether the step is
|
|
43
|
+
* completed, loading, unavailable, locked or not started.
|
|
44
|
+
* @csspart description - The description.
|
|
45
|
+
* @cssstate active - The owning stepper's current step.
|
|
46
|
+
* @cssstate completed - Mirrors `completed`.
|
|
47
|
+
* @cssstate loading - Mirrors `loading`.
|
|
48
|
+
* @cssstate disabled - Mirrors `disabled`.
|
|
49
|
+
* @cssstate locked - A `linear` stepper cannot reach this step yet.
|
|
50
|
+
* @cssstate clickable - The owning stepper is `clickable`, so the step is a button.
|
|
51
|
+
* @cssprop [--lr-step-pulse-color] - Color of the marker pulse drawn by `attention="pulse"`;
|
|
52
|
+
* defaults to the step's variant color.
|
|
53
|
+
* @cssprop [--pulse-color] - Alias of `--lr-step-pulse-color`; wins when both are set.
|
|
54
|
+
* @cssprop [--lr-stepper-marker-size=var(--lr-size-2rem)] - Diameter of the marker. Set on the
|
|
55
|
+
* stepper or an ancestor.
|
|
56
|
+
* @cssprop [--lr-stepper-connector-color=var(--lr-color-neutral-fill-normal)] - Color of the line
|
|
57
|
+
* after a step that is not completed.
|
|
58
|
+
* @cssprop [--lr-stepper-connector-active-color] - Color of the line after a completed step;
|
|
59
|
+
* unset, it follows the completed step's variant.
|
|
60
|
+
* @cssprop [--lr-stepper-connector-width=var(--lr-border-width-medium)] - Thickness of the line.
|
|
61
|
+
* @cssprop [--lr-stepper-connector-gap=var(--lr-size-0-35em)] - Gap between the marker edge and
|
|
62
|
+
* the line on both sides.
|
|
63
|
+
* @cssprop [--lr-stepper-step-gap=var(--lr-space-m)] - Block spacing between steps while the
|
|
64
|
+
* stepper is laid out vertically.
|
|
65
|
+
* @cssprop [--lr-stepper-hover-bg] - Background of a hovered, enabled clickable step.
|
|
66
|
+
* @cssprop [--lr-stepper-active-bg] - Background of a pressed, enabled clickable step.
|
|
67
|
+
* @status experimental
|
|
68
|
+
* @since 32.1.0
|
|
69
|
+
*/
|
|
70
|
+
export declare class LyraStep extends LyraElement{static styles:import("lit").CSSResultGroup[];private readonly slots;private readonly stepInternals;
|
|
71
|
+
/** Identifies the step. Matched against the stepper's `active` property and reported in its
|
|
72
|
+
* events. */
|
|
73
|
+
name:string;
|
|
74
|
+
/** Marks the step done: a check mark replaces the number.*/
|
|
75
|
+
completed:boolean;
|
|
76
|
+
/** Shows a spinner in place of the number, for example while an asynchronous transition runs.
|
|
77
|
+
* Sets `aria-busy` on the step. */
|
|
78
|
+
loading:boolean;
|
|
79
|
+
/** Makes the step unreachable: it cannot be clicked or targeted by `next()`/`goTo()`, and it
|
|
80
|
+
* renders as a disabled button while the stepper is `clickable`. */
|
|
81
|
+
disabled:boolean;
|
|
82
|
+
/** Semantic color of the marker. An upcoming `brand` step keeps a neutral outline so a default
|
|
83
|
+
* stepper reads quietly. */
|
|
84
|
+
variant:LyraVariant;
|
|
85
|
+
/** Animates the marker (`pulse` or `bounce`) to draw attention to it, for example the step the
|
|
86
|
+
* user should do next. Both stop under `prefers-reduced-motion: reduce`. */
|
|
87
|
+
attention:LyraStepAttention;
|
|
88
|
+
/** Space-separated names of author-defined states, each published as a CSS custom state
|
|
89
|
+
* (`custom-states="error retried"` matches `lr-step:state(error)` and `lr-step:state(retried)`).
|
|
90
|
+
* Names must be CSS identifiers; names the step publishes itself (`active`, `completed`,
|
|
91
|
+
* `loading`, `disabled`, `locked`, `clickable`) are ignored, as are duplicates, names over 64
|
|
92
|
+
* characters and any after the 32nd. A styling hook only: the status text and the stepper's
|
|
93
|
+
* behavior do not change. */
|
|
94
|
+
customStates:string;
|
|
95
|
+
/** Server rendering only: set it when a `description` is slotted so the server markup includes
|
|
96
|
+
* it before hydration. */
|
|
97
|
+
withDescription:boolean;
|
|
98
|
+
/** Draws the step as the stepper's current step. The owning stepper keeps it in sync with its
|
|
99
|
+
* own `active`; set it yourself only for server rendering. */
|
|
100
|
+
active:boolean;private publishedStates;connectedCallback():void;protected updated(changed:PropertyValues):void;
|
|
101
|
+
/** Focuses the step's button when the stepper is `clickable`.*/
|
|
102
|
+
focus(options?:FocusOptions):void;private statusText;private markerContent;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-step':LyraStep;}}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{checkIcon,spinnerIcon}from"../../../internal/icons.js";import{declaredDefaultConverter}from"../../../internal/converters.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{stepStyles}from"./step.styles.js";import{LYRA_DEFAULT_stepperStateCompleted,LYRA_DEFAULT_stepperStateDisabled,LYRA_DEFAULT_stepperStateLoading,LYRA_DEFAULT_stepperStateLocked,LYRA_DEFAULT_stepperStatePending}from"../../../internal/default-strings/layout.generated.js";const OWN_STATES=new Set(["active","completed","loading","disabled","locked","clickable"]),STATE_NAME=/^(?:--|-?[A-Za-z_\u00A0-\uFFFF])[\w\u00A0-\uFFFF-]*$/,MAX_CUSTOM_STATES=32,MAX_STATE_NAME_UNITS=64;function authorStateNames(value){if(typeof value!="string")return[];const names=[];for(const token of value.split(/\s+/)){if(names.length>=MAX_CUSTOM_STATES)break;!token||token.length>MAX_STATE_NAME_UNITS||OWN_STATES.has(token)||!STATE_NAME.test(token)||names.includes(token)||names.push(token)}return names}class LyraStep extends LyraElement{constructor(){super(...arguments),this.slots=new SlotPresenceController(this),this.stepInternals=attachInternalsSafely(this),this.name="",this.completed=!1,this.loading=!1,this.disabled=!1,this.variant="brand",this.attention="none",this.customStates="",this.withDescription=!1,this.active=!1,this.position=0,this.clickable=!1,this.locked=!1,this.vertical=!1,this.first=!1,this.last=!1,this.tabStop=!1,this.publishedStates=[]}static{this.defaultStrings={...super.defaultStrings,stepperStateCompleted:LYRA_DEFAULT_stepperStateCompleted,stepperStateDisabled:LYRA_DEFAULT_stepperStateDisabled,stepperStateLoading:LYRA_DEFAULT_stepperStateLoading,stepperStateLocked:LYRA_DEFAULT_stepperStateLocked,stepperStatePending:LYRA_DEFAULT_stepperStatePending}}static{this.styles=[LyraElement.styles,stepStyles]}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","listitem")}updated(changed){if(super.updated(changed),changed.has("loading")&&this.setAttribute("aria-busy",this.loading?"true":"false"),setCustomState(this.stepInternals,"active",this.active),setCustomState(this.stepInternals,"completed",this.completed),setCustomState(this.stepInternals,"loading",this.loading),setCustomState(this.stepInternals,"disabled",this.disabled),setCustomState(this.stepInternals,"locked",this.locked),setCustomState(this.stepInternals,"clickable",this.clickable),changed.has("customStates")){const next=authorStateNames(this.customStates);for(const name of this.publishedStates)next.includes(name)||setCustomState(this.stepInternals,name,!1);for(const name of next)setCustomState(this.stepInternals,name,!0);this.publishedStates=next}(changed.has("active")||changed.has("clickable"))&&(this.active&&!this.clickable?this.setAttribute("aria-current","step"):this.removeAttribute("aria-current"))}focus(options){const button=this.renderRoot?.querySelector('[part="button"]');button?button.focus(options):super.focus(options)}statusText(){return this.completed?this.localize("stepperStateCompleted"):this.loading?this.localize("stepperStateLoading"):this.disabled?this.localize("stepperStateDisabled"):this.locked?this.localize("stepperStateLocked"):this.active?"":this.localize("stepperStatePending")}markerContent(){return this.loading?html`<span part="spinner" class="spinner" aria-hidden="true">${spinnerIcon()}</span>`:this.completed?html`<span class="check" aria-hidden="true">${checkIcon()}</span>`:this.position>0?getNumberFormat(this.effectiveLocale).format(this.position):nothing}render(){const hasDescription=this.withDescription||this.slots.has("description"),body=html`
|
|
2
|
+
<span part="marker" class="marker" data-attention=${this.attention}>
|
|
3
|
+
<slot name="icon">${this.markerContent()}</slot>
|
|
4
|
+
</span>
|
|
5
|
+
<span part="content" class="content">
|
|
6
|
+
<span part="label" class="label"><slot></slot></span>
|
|
7
|
+
<span part="status" class="visually-hidden">${this.statusText()}</span>
|
|
8
|
+
<span part="description" class="description" ?hidden=${!hasDescription}>
|
|
9
|
+
<slot name="description"></slot>
|
|
10
|
+
</span>
|
|
11
|
+
</span>
|
|
12
|
+
`;return html`
|
|
13
|
+
<div part="step" class="step" ?data-active=${this.active} ?data-completed=${this.completed} ?data-locked=${this.locked} ?data-disabled=${this.disabled} ?data-vertical=${this.vertical} ?data-first=${this.first} ?data-last=${this.last} >
|
|
14
|
+
<span part="connector" class="connector connector-start" data-variant=${this.connectorStartVariant??nothing} ></span>
|
|
15
|
+
<span part="connector" class="connector connector-end"></span>
|
|
16
|
+
${this.clickable?html`<button part="button" class="body" type="button" tabindex=${this.tabStop?"0":"-1"} ?disabled=${this.disabled||this.locked} aria-current=${this.active?"step":nothing} >${body}</button>`:html`<div class="body">${body}</div>`}
|
|
17
|
+
</div>
|
|
18
|
+
`}}__decorate([property({reflect:!0})],LyraStep.prototype,"name",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraStep.prototype,"completed",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraStep.prototype,"loading",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraStep.prototype,"disabled",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("brand")})],LyraStep.prototype,"variant",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("none")})],LyraStep.prototype,"attention",void 0),__decorate([property({attribute:"custom-states"})],LyraStep.prototype,"customStates",void 0),__decorate([property({type:Boolean,attribute:"with-description"})],LyraStep.prototype,"withDescription",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraStep.prototype,"active",void 0),__decorate([state()],LyraStep.prototype,"position",void 0),__decorate([state()],LyraStep.prototype,"clickable",void 0),__decorate([state()],LyraStep.prototype,"locked",void 0),__decorate([state()],LyraStep.prototype,"vertical",void 0),__decorate([state()],LyraStep.prototype,"first",void 0),__decorate([state()],LyraStep.prototype,"last",void 0),__decorate([state()],LyraStep.prototype,"tabStop",void 0),__decorate([state()],LyraStep.prototype,"connectorStartVariant",void 0);export{LyraStep};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{css}from"lit";import{visuallyHidden}from"../../../internal/a11y.js";import{activeFill,disabledControl,focusRing}from"../../../internal/interactive-control.styles.js";const stepStyles=/* @__PURE__ */(()=>css` :host{display:block;flex:1 1 0;min-inline-size:0;--_pad:var(--lr-space-2xs);--_size:var(--marker-size, var(--lr-stepper-marker-size, var(--lr-size-2rem)));--_cw:var(--connector-width, var(--lr-stepper-connector-width, var(--lr-border-width-medium)));--_gap:var(--connector-gap, var(--lr-stepper-connector-gap, var(--lr-size-0-35em)));--_fill:var(--lr-color-brand);--_on:var(--lr-color-on-brand);--_line:var(--connector-color, var(--lr-stepper-connector-color, var(--lr-color-neutral-fill-normal)))}:host([variant=neutral]){--_fill:var(--lr-color-neutral);--_on:var(--lr-color-on-neutral)}:host([variant=success]){--_fill:var(--lr-color-success);--_on:var(--lr-color-on-success)}:host([variant=warning]){--_fill:var(--lr-color-warning);--_on:var(--lr-color-on-warning)}:host([variant=danger]){--_fill:var(--lr-color-danger);--_on:var(--lr-color-on-danger)}.visually-hidden{${visuallyHidden}}[hidden]{display:none!important}.step{position:relative}.body{display:flex;flex-direction:column;align-items:center;gap:var(--lr-space-xs);box-sizing:border-box;inline-size:100%;margin:0;padding:var(--_pad);border:none;border-radius:var(--lr-radius);background:transparent;color:var(--lr-color-text-quiet);font:inherit;text-align:center;transition:background-color var(--lr-transition-fast),color var(--lr-transition-fast)}button.body{cursor:pointer}button.body:focus-visible{${focusRing}}:where(button.body):hover:where(:not(:disabled)){background:var(--lr-stepper-hover-bg,var(--lr-color-brand-quiet));color:var(--lr-stepper-hover-color,var(--lr-color-text))}:where(button.body):active:where(:not(:disabled)){background:var(--lr-stepper-active-bg,${activeFill("var(--lr-color-brand-quiet)")});color:var(--lr-stepper-active-color,var(--lr-color-text))}button.body:disabled{${disabledControl}}[data-disabled]:not(button) .body{opacity:var(--lr-opacity-disabled)}.step[data-active] .body,.step[data-completed] .body{color:var(--lr-color-text)}.step[data-active] .label{font-weight:var(--lr-font-weight-semibold)}.marker{position:relative;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;box-sizing:border-box;inline-size:var(--_size);block-size:var(--_size);border-radius:var(--lr-radius-pill);border:var(--lr-border-width-medium) solid var(--_fill);background:transparent;color:var(--_fill);font-size:var(--lr-font-size-sm);font-variant-numeric:tabular-nums;--_pulse:var(--pulse-color, var(--lr-step-pulse-color, var(--_fill)))}:host([variant=brand]) .step:not([data-active]):not([data-completed]) .marker{border-color:var(--lr-color-neutral-fill-normal);color:var(--lr-color-text-quiet)}.step[data-active] .marker,.step[data-completed] .marker{background:var(--_fill);border-color:var(--_fill);color:var(--_on)}.check,.spinner{display:inline-flex}.spinner{animation:lr-step-spin var(--lr-duration-ambient) linear infinite}.content{display:flex;flex-direction:column;align-items:center;min-inline-size:0}.description{color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-sm)}.connector{position:absolute;box-sizing:border-box;background:var(--_line);pointer-events:none}.connector-end{background:var(--connector-color-active,var(--lr-stepper-connector-active-color,var(--_fill)))}.step:not([data-completed]) .connector-end{background:var(--_line)}.connector-start{background:var(--_line)}.connector-start[data-variant=neutral]{background:var(--connector-color-active,var(--lr-stepper-connector-active-color,var(--lr-color-neutral)))}.connector-start[data-variant=brand]{background:var(--connector-color-active,var(--lr-stepper-connector-active-color,var(--lr-color-brand)))}.connector-start[data-variant=success]{background:var(--connector-color-active,var(--lr-stepper-connector-active-color,var(--lr-color-success)))}.connector-start[data-variant=warning]{background:var(--connector-color-active,var(--lr-stepper-connector-active-color,var(--lr-color-warning)))}.connector-start[data-variant=danger]{background:var(--connector-color-active,var(--lr-stepper-connector-active-color,var(--lr-color-danger)))}.step[data-first] .connector-start,.step[data-last] .connector-end{display:none}.connector{block-size:var(--_cw);inset-block-start:calc(var(--_pad) + var(--_size) / 2 - var(--_cw) / 2)}.connector-start{inset-inline-start:0;inset-inline-end:calc(50% + var(--_size) / 2 + var(--_gap))}.connector-end{inset-inline-start:calc(50% + var(--_size) / 2 + var(--_gap));inset-inline-end:0}.step[data-vertical]{padding-block:var(--gap,var(--lr-stepper-step-gap,var(--lr-space-m))) 0}.step[data-vertical] .body{flex-direction:row;align-items:flex-start;text-align:start}.step[data-vertical] .content{align-items:flex-start;padding-block-start:calc((var(--_size) - 1lh) / 2)}.step[data-vertical] .connector{block-size:auto;inline-size:var(--_cw);inset-inline-start:calc(var(--_pad) + var(--_size) / 2 - var(--_cw) / 2);inset-inline-end:auto}.step[data-vertical] .connector-start{inset-block-start:0;inset-block-end:auto;block-size:calc(var(--gap,var(--lr-stepper-step-gap,var(--lr-space-m))) + var(--_pad) - var(--_gap))}.step[data-vertical] .connector-end{inset-block-start:calc(var(--gap,var(--lr-stepper-step-gap,var(--lr-space-m))) + var(--_pad) + var(--_size) + var(--_gap));inset-block-end:0}.step[data-vertical][data-first]{padding-block-start:0}.step[data-vertical][data-first] .connector-end{inset-block-start:calc(var(--_pad) + var(--_size) + var(--_gap))}@keyframes lr-step-spin{to{transform:rotate(360deg)}}@keyframes lr-step-pulse{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--_pulse) 55%,transparent)}100%{box-shadow:0 0 0 var(--lr-size-6px) transparent}}@keyframes lr-step-bounce{0%,100%{transform:translateY(0)}50%{transform:translateY(var(--lr-size-neg-4px))}}.marker[data-attention=pulse]{animation:lr-step-pulse var(--lr-duration-ambient) ease-out infinite}.marker[data-attention=bounce]{animation:lr-step-bounce var(--lr-duration-ambient) ease-in-out infinite}@media (prefers-reduced-motion:reduce){.marker[data-attention],.spinner{animation:none}}@media (forced-colors:active){.marker{border-color:CanvasText;forced-color-adjust:none;color:CanvasText;background:Canvas}.step[data-active] .marker,.step[data-completed] .marker{background:Highlight;color:HighlightText;border-color:Highlight}.connector{background:CanvasText}}`)();export{stepStyles};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type BreakpointBasis}from'../../../internal/orientation-breakpoint.js';import type{LyraOrientation}from'../../../internal/shared-unions.js';export type LyraStepState='pending'|'current'|'completed'|'error';export interface LyraStepperOrientationChangeDetail{orientation:LyraOrientation;}export interface LyraStepItem{
|
|
1
|
+
import type{LyraStep}from'./step.class.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type BreakpointBasis}from'../../../internal/orientation-breakpoint.js';import type{LyraOrientation}from'../../../internal/shared-unions.js';export type LyraStepState='pending'|'current'|'completed'|'error';export interface LyraStepperOrientationChangeDetail{orientation:LyraOrientation;}export interface LyraStepItem{
|
|
2
2
|
/** Stable business identity for this step. Duplicate IDs are valid occurrences and are
|
|
3
3
|
* disambiguated by their zero-based collection index. */
|
|
4
4
|
stepId:string;
|
|
@@ -18,13 +18,44 @@ title?:string;
|
|
|
18
18
|
* additionally to, never instead of, the state-driven index chip/checkmark -- the icon
|
|
19
19
|
* identifies the step's topic, the chip/checkmark identifies its state. It is inert and hidden
|
|
20
20
|
* from assistive technology, so it never supplies a second action or accessible name. */
|
|
21
|
-
icon?:unknown;}
|
|
21
|
+
icon?:unknown;}
|
|
22
|
+
/** Layout axis of a stepper. `auto` lays the steps in a row and stacks them when the stepper is too
|
|
23
|
+
* narrow to give each step room. */
|
|
24
|
+
export type LyraStepperOrientation=LyraOrientation|'auto';
|
|
25
|
+
/** Payload of `lr-before-step-change` and `lr-step-change` in child-driven mode.*/
|
|
26
|
+
export interface LyraStepChangeDetail{
|
|
27
|
+
/** `name` of the step becoming current.*/
|
|
28
|
+
name:string;
|
|
29
|
+
/** `name` of the step that was current, or `null` when none was.*/
|
|
30
|
+
previousName:string|null;
|
|
31
|
+
/** The step becoming current.*/
|
|
32
|
+
step:LyraStep;
|
|
33
|
+
/** The step that was current, or `null` when none was.*/
|
|
34
|
+
previousStep:LyraStep|null;}export interface LyraStepperEventMap{'lr-step-select':CustomEvent<{stepId:string;index:number;}>;'lr-before-step-change':CustomEvent<LyraStepChangeDetail>;'lr-step-change':CustomEvent<LyraStepChangeDetail>;'lr-stepper-orientation-change':CustomEvent<LyraStepperOrientationChangeDetail>;}
|
|
22
35
|
/**
|
|
23
36
|
* `<lr-stepper>` — ordered multi-step wizard/form navigation: label + index per step,
|
|
24
|
-
* current/completed/locked/error state, click-to-jump.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
37
|
+
* current/completed/locked/error state, click-to-jump. Mirrors `wa-stepper`, whose `wa-step`
|
|
38
|
+
* children are `<lr-step>`; the stepper has two authoring modes.
|
|
39
|
+
*
|
|
40
|
+
* Data-driven mode (the original contract): fully controlled, like `lr-table`'s `columns`/`rows` --
|
|
41
|
+
* it never mutates `steps` itself; a click or Enter/Space on a non-disabled step fires a
|
|
42
|
+
* non-cancelable `lr-step-select`, and the host decides whether/how `steps` changes in response.
|
|
43
|
+
*
|
|
44
|
+
* Child mode: with an empty `steps` array and `<lr-step>` children, the stepper owns the current
|
|
45
|
+
* step. `active` names it (the first step when unset or unmatched), `goTo(name)`, `next()` and
|
|
46
|
+
* `previous()` move it, and each move first emits a cancelable `lr-before-step-change` (a
|
|
47
|
+
* `preventDefault()` veto keeps the current step) and then `lr-step-change`, and announces the new
|
|
48
|
+
* position politely. `linear` stops a step being reached until every step before it is
|
|
49
|
+
* `completed`; later steps render locked. `clickable` makes each step a button (one roving tab stop,
|
|
50
|
+
* Left/Right swapped under RTL, Up/Down while stacked, Home/End) so a click or Enter/Space jumps to
|
|
51
|
+
* it; unset, only the methods and invokers move the step, and the stepper is a labelled group
|
|
52
|
+
* instead of a navigation landmark. Any element on the page, inside the stepper or not, with
|
|
53
|
+
* `data-stepper="next <id>"`, `"previous <id>"` or `"goto <id> <step-name>"` drives the stepper
|
|
54
|
+
* whose `id` it names when clicked. `label` names the group. The array mode is unchanged and wins
|
|
55
|
+
* while `steps` is non-empty.
|
|
56
|
+
*
|
|
57
|
+
* `orientation="auto"` lays the steps in a row and stacks them whenever the stepper's own measured
|
|
58
|
+
* width cannot give every step about 6em, so a phone-width container stacks without any breakpoint.
|
|
28
59
|
*
|
|
29
60
|
* An opt-in `orientationBreakpoint` (unset by default -- no behavior change) makes the effective
|
|
30
61
|
* layout/navigation axis respond to a measured inline size instead of only the authored
|
|
@@ -56,7 +87,16 @@ icon?:unknown;}export interface LyraStepperEventMap{'lr-step-select':CustomEvent
|
|
|
56
87
|
* `lr-table`'s `columns`/`rows` contract) and takes no default action of its own on selection
|
|
57
88
|
* (it never mutates `steps`), so there is no real veto point for `preventDefault()` to gate.
|
|
58
89
|
* @event lr-stepper-orientation-change - `detail: { orientation }`, fired when an enabled
|
|
59
|
-
* `orientationBreakpoint` changes the effective layout/navigation axis.
|
|
90
|
+
* `orientationBreakpoint`, or `orientation="auto"`, changes the effective layout/navigation axis.
|
|
91
|
+
* @event lr-before-step-change - Child mode. Cancelable; `detail: { name, previousName, step,
|
|
92
|
+
* previousStep }`, fired before `active` changes. `preventDefault()` keeps the current step.
|
|
93
|
+
* @event lr-step-change - Child mode. `detail` as `lr-before-step-change`; fired after `active`
|
|
94
|
+
* changed and the steps re-rendered.
|
|
95
|
+
* @slot - Child mode: one or more `<lr-step>` elements.
|
|
96
|
+
* @csspart stepper - Child mode: the outer wrapper, a `<nav>` landmark while `clickable`, otherwise
|
|
97
|
+
* a labelled `role="group"`.
|
|
98
|
+
* @csspart summary - Child mode: visually hidden "Step X of Y" text for assistive technology.
|
|
99
|
+
* @csspart steps - The list element that lays out the steps; the same node as `base`.
|
|
60
100
|
* @csspart base - The root wrapper, and the horizontally scrolling track. Takes `tabindex="0"`
|
|
61
101
|
* only while `readonly` and genuinely overflowing, so an otherwise keyboard-unreachable
|
|
62
102
|
* read-only strip can still be scrolled; style that state with `::part(base):focus-visible`.
|
|
@@ -69,6 +109,33 @@ icon?:unknown;}export interface LyraStepperEventMap{'lr-step-select':CustomEvent
|
|
|
69
109
|
* @csspart step-index - The numbered index chip, shown for `pending`/`current`/`error` steps.
|
|
70
110
|
* @csspart step-check - The completed-checkmark glyph, shown for `completed` steps instead of `step-index`.
|
|
71
111
|
* @csspart step-label - The step's label text.
|
|
112
|
+
* @cssprop [--lr-stepper-marker-size=var(--lr-size-2rem)] - Child mode: diameter of each step's marker.
|
|
113
|
+
* @cssprop [--lr-stepper-connector-color=var(--lr-color-neutral-fill-normal)] - Child mode: color of the
|
|
114
|
+
* line after a step that is not completed.
|
|
115
|
+
* @cssprop [--lr-stepper-connector-active-color] - Child mode: color of the line after a completed
|
|
116
|
+
* step; unset, it follows that step's variant.
|
|
117
|
+
* @cssprop [--lr-stepper-connector-width=var(--lr-border-width-medium)] - Child mode: line thickness.
|
|
118
|
+
* @cssprop [--lr-stepper-connector-gap=var(--lr-size-0-35em)] - Child mode: gap between a marker and
|
|
119
|
+
* the line on both sides.
|
|
120
|
+
* @cssprop [--lr-stepper-step-gap=var(--lr-space-m)] - Child mode: space between steps while stacked.
|
|
121
|
+
* @cssprop [--marker-size=var(--lr-stepper-marker-size,var(--lr-size-2rem))] - Child mode: alias of
|
|
122
|
+
* `--lr-stepper-marker-size`; wins when both are set.
|
|
123
|
+
* @cssprop [--connector-color=var(--lr-stepper-connector-color,var(--lr-color-neutral-fill-normal))] -
|
|
124
|
+
* Child mode: alias of `--lr-stepper-connector-color`; wins when both are set.
|
|
125
|
+
* @cssprop [--connector-color-active] - Child mode: alias of `--lr-stepper-connector-active-color`;
|
|
126
|
+
* wins when both are set.
|
|
127
|
+
* @cssprop [--connector-width=var(--lr-stepper-connector-width,var(--lr-border-width-medium))] - Child
|
|
128
|
+
* mode: alias of `--lr-stepper-connector-width`; wins when both are set.
|
|
129
|
+
* @cssprop [--connector-gap=var(--lr-stepper-connector-gap,var(--lr-size-0-35em))] - Child mode: alias
|
|
130
|
+
* of `--lr-stepper-connector-gap`; wins when both are set.
|
|
131
|
+
* @cssprop [--gap=var(--lr-stepper-step-gap,var(--lr-space-m))] - Child mode: alias of
|
|
132
|
+
* `--lr-stepper-step-gap`, the space between stacked steps; wins when both are set. In a row the
|
|
133
|
+
* connectors span the space between steps, which share the width evenly.
|
|
134
|
+
* @cssstate completed - Every step is completed (child mode: every `<lr-step>` is `completed`; data
|
|
135
|
+
* mode: every item's `state` is `completed`).
|
|
136
|
+
* @cssstate loading - Child mode: at least one `<lr-step>` is `loading`.
|
|
137
|
+
* @cssstate stacked - The steps are laid out vertically, by `orientation="vertical"`, an
|
|
138
|
+
* `orientationBreakpoint` or an `auto` stepper too narrow for a row.
|
|
72
139
|
* @cssprop [--lr-scroll-fade-size=2rem] - Width of each decorative horizontal overflow fade.
|
|
73
140
|
* Pointer-state hooks use inline `var()` fallbacks rather than a `:host` declaration, so they
|
|
74
141
|
* inherit from the stepper or any ancestor without retheming another state.
|
|
@@ -89,6 +156,10 @@ icon?:unknown;}export interface LyraStepperEventMap{'lr-step-select':CustomEvent
|
|
|
89
156
|
* @cssprop [--lr-stepper-error-color=var(--lr-color-danger)] - Text color of an `error` step.
|
|
90
157
|
* @cssprop [--lr-stepper-index-bg=var(--lr-color-neutral-fill-normal)] - Background of a step's
|
|
91
158
|
* `[part='step-index']` outside the current and error states.
|
|
159
|
+
* @cssprop [--lr-stepper-index-border=none] - Border shorthand of a step's index circle (for example
|
|
160
|
+
* `2px solid currentColor`); the circle keeps its size.
|
|
161
|
+
* @cssprop [--lr-stepper-current-index-border=var(--lr-stepper-index-border,none)] - Border of the `current` step's index.
|
|
162
|
+
* @cssprop [--lr-stepper-error-index-border=var(--lr-stepper-index-border,none)] - Border of an `error` step's index.
|
|
92
163
|
* @cssprop [--lr-stepper-index-color=var(--lr-color-neutral-on-normal)] - Text color of that index.
|
|
93
164
|
* @cssprop [--lr-stepper-error-index-bg=var(--lr-color-neutral-fill-normal)] - Background of an
|
|
94
165
|
* `error` step's index.
|
|
@@ -103,7 +174,7 @@ icon?:unknown;}export interface LyraStepperEventMap{'lr-step-select':CustomEvent
|
|
|
103
174
|
* @status stable
|
|
104
175
|
* @since 4.0.0
|
|
105
176
|
*/
|
|
106
|
-
export declare class LyraStepper extends LyraElement<LyraStepperEventMap>{static styles:import("lit").CSSResultGroup[];private omitted;private readonly stepsSnapshot;
|
|
177
|
+
export declare class LyraStepper extends LyraElement<LyraStepperEventMap>{protected static collectionSupport:import("../../../internal/lyra-element.js").LyraCollectionSupport;protected static readonly immutableEventDetails:readonly string[];protected static readonly identityEventDetailProperties:Readonly<{'lr-before-step-change':readonly string[];'lr-step-change':readonly string[];}>;static styles:import("lit").CSSResultGroup[];private omitted;private readonly stepsSnapshot;
|
|
107
178
|
/** Input positions beyond the 256-position limit on the latest assignment.*/
|
|
108
179
|
get omittedSteps():number;
|
|
109
180
|
/** Ordered step data. Never mutated by this component -- see the class doc's controlled-
|
|
@@ -112,10 +183,13 @@ get omittedSteps():number;
|
|
|
112
183
|
* locked. */
|
|
113
184
|
get steps():readonly LyraStepItem[];set steps(value:readonly LyraStepItem[]);
|
|
114
185
|
/** `'horizontal'` (the default) lays steps out in a row (Left/Right, RTL-aware, to navigate);
|
|
115
|
-
* `'vertical'` stacks them (Up/Down navigate instead, no RTL swap needed)
|
|
186
|
+
* `'vertical'` stacks them (Up/Down navigate instead, no RTL swap needed); `'auto'` lays them in
|
|
187
|
+
* a row and stacks them whenever the stepper's measured inline size cannot give each step about
|
|
188
|
+
* 6em (plus the gaps), so a narrow container or a phone stacks with no breakpoint to author.
|
|
189
|
+
* `'auto'` measures the stepper, so a server-rendered one starts as a row. The *authored* axis
|
|
116
190
|
* used at/above `orientationBreakpoint` (or always, when that's unset) -- see
|
|
117
191
|
* `effectiveOrientation` for the live axis actually in effect. */
|
|
118
|
-
orientation:
|
|
192
|
+
orientation:LyraStepperOrientation;
|
|
119
193
|
/** Opt-in inline-size breakpoint, measured on `[part="base"]`. Below it, `narrowOrientation`
|
|
120
194
|
* becomes effective instead of `orientation`. Unset (the default): no behavior change, the
|
|
121
195
|
* authored `orientation` always applies.
|
|
@@ -176,8 +250,27 @@ readonly:boolean;
|
|
|
176
250
|
* property. Unset, the list renders without an `aria-label` (the role carries no localized
|
|
177
251
|
* default name). */
|
|
178
252
|
accessibleLabel:string|null;
|
|
179
|
-
/** Accessible name when no aria-label is supplied
|
|
180
|
-
|
|
253
|
+
/** Accessible name when no aria-label is supplied. In child mode it names the stepper's group or
|
|
254
|
+
* navigation landmark (a localized "Steps" when unset). */
|
|
255
|
+
label?:string;
|
|
256
|
+
/** Child mode: the `name` of the current `<lr-step>`. Falls back to the first step when unset or
|
|
257
|
+
* when it matches no step. Changing it from script moves the step without the veto event;
|
|
258
|
+
* `goTo()`, `next()` and `previous()` ask first. */
|
|
259
|
+
active:string;
|
|
260
|
+
/** Child mode: steps must be completed in order. `next()`, `goTo()`, an invoker and a click
|
|
261
|
+
* cannot reach a step until every step before it is `completed`; later steps render locked. */
|
|
262
|
+
linear:boolean;
|
|
263
|
+
/** Child mode: each step becomes a button, so a click (or Enter/Space on a focused step) jumps to
|
|
264
|
+
* it. Unset, only the methods and `data-stepper` invokers move the step. */
|
|
265
|
+
clickable:boolean;private childSteps;private readonly stepperInternals;private childCount;private readonly announcements;private get childMode();constructor();private _effectiveOrientation;private readonly resizeFrame;private readonly resizeObserver;private readonlyFocusLost;private pendingStepFocus?;private baseEl?;private measuredInlineSize;private orientationBreakpoints;private scrollOverflow;private get observesContainer();
|
|
181
266
|
/** The live layout/navigation axis after applying `orientationBreakpoint` -- identical to
|
|
182
267
|
* `orientation` whenever that's unset. See the class doc. */
|
|
183
|
-
get effectiveOrientation():LyraOrientation;connectedCallback():void;private seedInlineSize;private orientationInlineSize;disconnectedCallback():void;adoptedCallback():void;protected firstUpdated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private syncScrollTabStop;private updateEffectiveOrientation;private armResizeObserver;private resetResizeObserver;private
|
|
268
|
+
get effectiveOrientation():LyraOrientation;connectedCallback():void;private invokerDocument?;private registerInvokers;private unregisterInvokers;private seedInlineSize;private orientationInlineSize;disconnectedCallback():void;adoptedCallback():void;protected firstUpdated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private syncScrollTabStop;private updateEffectiveOrientation;private autoStacks;private observedBase?;private armResizeObserver;private resetResizeObserver;private syncChildSteps;private syncCustomStates;private resolveActiveStep;private linearBoundary;private isReachable;private applyChildState;private activeIndex;
|
|
269
|
+
/** Child mode: requests a change to the named step. Emits a cancelable `lr-before-step-change`;
|
|
270
|
+
* unless vetoed, updates `active`, emits `lr-step-change` and announces the new position. Does
|
|
271
|
+
* nothing when the step does not exist, is `disabled`, or (while `linear`) cannot be reached yet. */
|
|
272
|
+
goTo(name:string):void;
|
|
273
|
+
/** Child mode: goes to the step after the current one, if any.*/
|
|
274
|
+
next():void;
|
|
275
|
+
/** Child mode: goes back to the step before the current one, if any.*/
|
|
276
|
+
previous():void;private ownStepOf;private readonly onChildClick;private readonly onChildKeyDown;private renderChildren;private selectStep;private focusStep;private onKeyDown;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-stepper':LyraStepper;}}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{finiteCount}from"../../../internal/numbers.js";import{declaredDefaultConverter}from"../../../internal/converters.js";import{checkIcon}from"../../../internal/icons.js";import{OwnedResizeObserver,readInlineSize}from"../../../internal/owned-observer.js";import{OwnedFrame}from"../../../internal/owned-timer.js";import{SnapshotProperty}from"../../../internal/collection-source-tracker.js";import{html,nothing}from"lit";import{property,query}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveAccessibleName}from"../../../internal/accessible-name.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{OrientationBreakpointController}from"../../../internal/orientation-breakpoint.js";import{isRepeatedActivationKey,shouldIgnoreNavigationKey,resolveListMove}from"../../../internal/list-navigation.js";import{observeScrollOverflow,SCROLL_OVERFLOW_ATTRIBUTE}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{styles}from"./stepper.styles.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{restoreComposedFocus}from"../../../internal/focus-repair.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{syncAriaDescribedByElements}from"../../../internal/aria-reflection.js";import{LYRA_DEFAULT_stepperStateCompleted,LYRA_DEFAULT_stepperStateError,LYRA_DEFAULT_stepperStateLocked,LYRA_DEFAULT_stepperStatePending}from"../../../internal/default-strings/layout.generated.js";const STEP_STATES=new Set(["pending","current","completed","error"]),MAX_STEPS=256;function snapshotSteps(value,reportOmitted){try{if(!Array.isArray(value))return Object.freeze([])}catch{return Object.freeze([])}const normalized=[];let length=0;try{const sourceLength=finiteCount(value.length);length=Math.min(sourceLength,MAX_STEPS),reportOmitted(sourceLength-length)}catch{return Object.freeze(normalized)}for(let index=0;index<length;index+=1)try{const candidate=value[index];if(!candidate||typeof candidate!="object")continue;const record=candidate,stepId=record.stepId,label=record.label,state=record.state,disabled=record.disabled,title=record.title,icon=record.icon;if(typeof stepId!="string"||stepId.length===0||stepId!==stepId.trim()||typeof label!="string"||label.trim()===""||typeof state!="string"||!STEP_STATES.has(state)||disabled!==void 0&&typeof disabled!="boolean"||title!==void 0&&typeof title!="string")continue;normalized.push(Object.freeze({stepId,label,state,...disabled!==void 0?{disabled}:{},...title!==void 0?{title}:{},...icon!==void 0?{icon}:{}}))}catch{}return Object.freeze(normalized)}class LyraStepper extends LyraElement{constructor(){super(...arguments),this.omitted=0,this.stepsSnapshot=new SnapshotProperty(Object.freeze([]),value=>(this.omitted=0,snapshotSteps(value,count=>{this.omitted=count}))),this.orientation="horizontal",this.orientationBreakpointBasis="container",this.narrowOrientation="vertical",this.wrapLabels=!1,this.readonly=!1,this.accessibleLabel=null,this._effectiveOrientation="horizontal",this.resizeFrame=new OwnedFrame(this),this.resizeObserver=new OwnedResizeObserver(this,entries=>{const width=readInlineSize(entries[0])??this.orientationInlineSize();this.resizeFrame.schedule(()=>{this.measuredInlineSize=width,this.updateEffectiveOrientation(width,!0)})}),this.readonlyFocusLost=!1,this.measuredInlineSize=Number.POSITIVE_INFINITY,this.orientationBreakpoints=new OrientationBreakpointController(this,()=>this.updateEffectiveOrientation(this.orientationInlineSize(),!0)),this.scrollOverflow=observeScrollOverflow(this,()=>this.baseEl,()=>this.syncScrollTabStop()),this.onKeyDown=e=>{if(this.readonly||e.defaultPrevented||shouldIgnoreNavigationKey(e))return;const navigable=this.steps.map((step,index)=>({step,index})).filter(({step})=>!step.disabled);if(navigable.length===0)return;const focused=shadowFocusTarget(this),focusedIndex=Number(focused?.dataset.index),currentIndex=navigable.findIndex(item=>item.index===focusedIndex);if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),isRepeatedActivationKey(e))return;if(currentIndex>=0){const target=navigable[currentIndex];this.selectStep(target.step,target.index)}return}const targetIndex=resolveListMove(e,{count:navigable.length,current:currentIndex,orientation:this.effectiveOrientation==="vertical"?"vertical":"horizontal",direction:this.effectiveDirection,wrap:!1,clamp:!0,backwardFromMissing:"first"});targetIndex!==null&&(e.preventDefault(),this.focusStep(navigable[targetIndex].index))}}static{this.defaultStrings={...super.defaultStrings,stepperStateCompleted:LYRA_DEFAULT_stepperStateCompleted,stepperStateError:LYRA_DEFAULT_stepperStateError,stepperStateLocked:LYRA_DEFAULT_stepperStateLocked,stepperStatePending:LYRA_DEFAULT_stepperStatePending}}static{this.styles=[LyraElement.styles,scrollOverflowFadeStyles,styles]}get omittedSteps(){return this.omitted}get steps(){return this.stepsSnapshot.read()}set steps(value){this.stepsSnapshot.assign(this,"steps",value)}get effectiveOrientation(){return this._effectiveOrientation}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.orientationBreakpoints.containerObservationEnabled&&this.seedInlineSize(),this.orientationBreakpoints.containerObservationEnabled&&this.armResizeObserver()}seedInlineSize(){const hostWidth=this.getBoundingClientRect().width;hostWidth>0&&(this.measuredInlineSize=hostWidth)}orientationInlineSize(){return this.orientationBreakpoints.containerObservationEnabled?this.baseEl?.clientWidth??this.measuredInlineSize:this.measuredInlineSize}disconnectedCallback(){super.disconnectedCallback(),this.resetResizeObserver()}adoptedCallback(){super.adoptedCallback(),this.resetResizeObserver()}firstUpdated(changed){super.firstUpdated(changed),this.orientationBreakpoints.containerObservationEnabled&&this.armResizeObserver()}willUpdate(changed){if(super.willUpdate(changed),changed.has("readonly")&&this.hasUpdated&&(this.readonlyFocusLost=shadowFocusTarget(this)?.getAttribute("part")==="step"),changed.has("steps")){const focusedStep=shadowFocusTarget(this);focusedStep?.getAttribute("part")==="step"&&(this.pendingStepFocus={stepId:focusedStep.dataset.stepId??"",index:Number(focusedStep.dataset.index)})}(changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.orientationBreakpoints.configure(this.orientationBreakpoint,this.orientationBreakpointBasis),!this.hasUpdated&&this.isConnected&&this.orientationBreakpoints.containerObservationEnabled&&this.seedInlineSize(),(changed.has("orientation")||changed.has("narrowOrientation")||changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.updateEffectiveOrientation(this.orientationInlineSize(),this.hasUpdated&&this.orientationBreakpointBasis==="viewport")}updated(changed){super.updated(changed);const base=this.renderRoot.querySelector('[part~="base"]')??void 0;if(syncAriaDescribedByElements(this,base,this.getAttribute("aria-describedby")),this.scrollOverflow.observeExtra(this.renderRoot.querySelectorAll('[part="step"]')),this.syncScrollTabStop(),this.readonlyFocusLost&&(this.readonlyFocusLost=!1,restoreComposedFocus(this,!0,this.renderRoot.querySelector('[part="base"]'))),this.pendingStepFocus!==void 0){const focusedOccurrence=this.pendingStepFocus;this.pendingStepFocus=void 0;const enabledIdentityMatches=[...this.renderRoot.querySelectorAll('[part="step"]')].filter(step=>step.dataset.stepId===focusedOccurrence.stepId&&step.getAttribute("aria-disabled")!=="true");(enabledIdentityMatches.find(step=>Number(step.dataset.index)===focusedOccurrence.index)??(enabledIdentityMatches.length===1?enabledIdentityMatches[0]:void 0)??this.renderRoot.querySelector('[part="step"][tabindex="0"]'))?.focus()}(changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&(this.orientationBreakpoints.containerObservationEnabled?this.armResizeObserver():this.resetResizeObserver())}syncScrollTabStop(){const base=this.baseEl;if(!base)return;const scrollable=this.effectiveOrientation==="horizontal"&&base.hasAttribute(SCROLL_OVERFLOW_ATTRIBUTE);this.readonly&&scrollable?base.setAttribute("tabindex","0"):this.readonly&&(this.readonlyFocusLost||shadowFocusTarget(this)===base)?base.tabIndex=-1:base.removeAttribute("tabindex")}updateEffectiveOrientation(width,emitOnChange){const next=this.orientationBreakpoints.isBelow(width)?this.narrowOrientation:this.orientation;this.orientationBreakpoints.active?this.setAttribute("data-effective-orientation",next):this.removeAttribute("data-effective-orientation"),next!==this._effectiveOrientation&&(this._effectiveOrientation=next,this.requestUpdate(),emitOnChange&&this.emit("lr-stepper-orientation-change",{orientation:next}))}armResizeObserver(){this.baseEl&&!this.resizeObserver.active&&this.resizeObserver.observe(this.baseEl)}resetResizeObserver(){this.resizeFrame.cancel(),this.resizeObserver.clear()}selectStep(step,index){this.readonly||step.disabled||this.emit("lr-step-select",{stepId:step.stepId,index})}focusStep(index){this.renderRoot.querySelector(`[part="step"][data-index="${index}"]`)?.focus()}render(){const currentIndex=this.steps.findIndex(step=>step.state==="current"),rovingIndex=this.readonly?-1:currentIndex>=0&&!this.steps[currentIndex].disabled?currentIndex:this.steps.findIndex(step=>!step.disabled),numberFormat=getNumberFormat(this.effectiveLocale),stateText=step=>{const parts=[];return step.state==="completed"?parts.push(this.localize("stepperStateCompleted")):step.state==="error"?parts.push(this.localize("stepperStateError")):step.state==="pending"&&parts.push(this.localize("stepperStatePending")),step.disabled&&!this.readonly&&parts.push(this.localize("stepperStateLocked")),parts.length===0?nothing:html`<span class="visually-hidden">${parts.length===1?parts[0]:getListFormat(this.effectiveLocale,{type:"unit"}).format(parts)}</span>`},stepGlyphs=(step,index)=>html`${step.icon!==void 0?html`<span part="step-icon" aria-hidden="true" inert >${step.icon}</span
|
|
1
|
+
import{__decorate}from"tslib";import{finiteCount}from"../../../internal/numbers.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{declaredDefaultConverter}from"../../../internal/converters.js";import{checkIcon}from"../../../internal/icons.js";import{HostChildrenObserver,OwnedResizeObserver,readInlineSize}from"../../../internal/owned-observer.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{tag}from"../../../internal/prefix.js";import{OwnedFrame}from"../../../internal/owned-timer.js";import{SnapshotProperty}from"../../../internal/collection-source-tracker.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveAccessibleName}from"../../../internal/accessible-name.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{OrientationBreakpointController}from"../../../internal/orientation-breakpoint.js";import{isRepeatedActivationKey,shouldIgnoreNavigationKey,resolveListMove}from"../../../internal/list-navigation.js";import{observeScrollOverflow,SCROLL_OVERFLOW_ATTRIBUTE}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{styles}from"./stepper.styles.js";import{getListFormat,getNumberFormat}from"../../../internal/intl-cache.js";import{restoreComposedFocus}from"../../../internal/focus-repair.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{syncAriaDescribedByElements}from"../../../internal/aria-reflection.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{LYRA_DEFAULT_stepperStateCompleted,LYRA_DEFAULT_stepperStateError,LYRA_DEFAULT_stepperStateLocked,LYRA_DEFAULT_stepperStatePending,LYRA_DEFAULT_stepperStepPosition,LYRA_DEFAULT_stepperSteps}from"../../../internal/default-strings/layout.generated.js";const STEP_STATES=new Set(["pending","current","completed","error"]),MAX_STEPS=256,invokerRecords=new WeakMap,INVOKER_COMMANDS=new Set(["next","previous","goto"]);function handleInvokerClick(event){const invoker=event.composedPath().find(node=>node instanceof Element&&node.hasAttribute("data-stepper"));if(!invoker)return;const[rawCommand,...rest]=(invoker.getAttribute("data-stepper")??"").trim().split(/\s+/),command=(rawCommand??"").toLowerCase();if(!INVOKER_COMMANDS.has(command))return;const root=invoker.getRootNode(),named=rest[0]?root.getElementById?.(rest[0])??null:null,byId=named?.localName===tag("stepper"),target=byId?named:invoker.closest(tag("stepper"));if(!target)return;const args=byId?rest.slice(1):rest;command==="next"?target.next():command==="previous"?target.previous():args.length>0&&target.goTo(args.join(" "))}function acquireInvokers(doc){const existing=invokerRecords.get(doc);if(existing){existing.count+=1;return}doc.addEventListener("click",handleInvokerClick),invokerRecords.set(doc,{count:1,handler:handleInvokerClick})}function releaseInvokers(doc){const record=invokerRecords.get(doc);record&&(record.count-=1,!(record.count>0)&&(doc.removeEventListener("click",record.handler),invokerRecords.delete(doc)))}function snapshotSteps(value,reportOmitted){try{if(!Array.isArray(value))return Object.freeze([])}catch{return Object.freeze([])}const normalized=[];let length=0;try{const sourceLength=finiteCount(value.length);length=Math.min(sourceLength,MAX_STEPS),reportOmitted(sourceLength-length)}catch{return Object.freeze(normalized)}for(let index=0;index<length;index+=1)try{const candidate=value[index];if(!candidate||typeof candidate!="object")continue;const record=candidate,stepId=record.stepId,label=record.label,state2=record.state,disabled=record.disabled,title=record.title,icon=record.icon;if(typeof stepId!="string"||stepId.length===0||stepId!==stepId.trim()||typeof label!="string"||label.trim()===""||typeof state2!="string"||!STEP_STATES.has(state2)||disabled!==void 0&&typeof disabled!="boolean"||title!==void 0&&typeof title!="string")continue;normalized.push(Object.freeze({stepId,label,state:state2,...disabled!==void 0?{disabled}:{},...title!==void 0?{title}:{},...icon!==void 0?{icon}:{}}))}catch{}return Object.freeze(normalized)}class LyraStepper extends LyraElement{static{this.defaultStrings={...super.defaultStrings,stepperStateCompleted:LYRA_DEFAULT_stepperStateCompleted,stepperStateError:LYRA_DEFAULT_stepperStateError,stepperStateLocked:LYRA_DEFAULT_stepperStateLocked,stepperStatePending:LYRA_DEFAULT_stepperStatePending,stepperStepPosition:LYRA_DEFAULT_stepperStepPosition,stepperSteps:LYRA_DEFAULT_stepperSteps}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-before-step-change","lr-step-change"])}static{this.identityEventDetailProperties=Object.freeze({"lr-before-step-change":Object.freeze(["step","previousStep"]),"lr-step-change":Object.freeze(["step","previousStep"])})}static{this.styles=[LyraElement.styles,scrollOverflowFadeStyles,styles]}get omittedSteps(){return this.omitted}get steps(){return this.stepsSnapshot.read()}set steps(value){this.stepsSnapshot.assign(this,"steps",value)}get childMode(){return this.childCount>0&&this.steps.length===0}constructor(){super(),this.omitted=0,this.stepsSnapshot=new SnapshotProperty(Object.freeze([]),value=>(this.omitted=0,snapshotSteps(value,count=>{this.omitted=count}))),this.orientation="horizontal",this.orientationBreakpointBasis="container",this.narrowOrientation="vertical",this.wrapLabels=!1,this.readonly=!1,this.accessibleLabel=null,this.active="",this.linear=!1,this.clickable=!1,this.childSteps=[],this.stepperInternals=attachInternalsSafely(this),this.childCount=0,this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this._effectiveOrientation="horizontal",this.resizeFrame=new OwnedFrame(this),this.resizeObserver=new OwnedResizeObserver(this,entries=>{const width=readInlineSize(entries[0])??this.orientationInlineSize();this.resizeFrame.schedule(()=>{this.measuredInlineSize=width,this.updateEffectiveOrientation(width,!0)})}),this.readonlyFocusLost=!1,this.measuredInlineSize=Number.POSITIVE_INFINITY,this.orientationBreakpoints=new OrientationBreakpointController(this,()=>this.updateEffectiveOrientation(this.orientationInlineSize(),!0)),this.scrollOverflow=observeScrollOverflow(this,()=>this.baseEl,()=>this.syncScrollTabStop()),this.activeIndex=0,this.onChildClick=event=>{if(!this.childMode||!this.clickable)return;const step=this.ownStepOf(event);step&&this.goTo(step.name)},this.onChildKeyDown=event=>{if(!this.childMode||!this.clickable||event.defaultPrevented||shouldIgnoreNavigationKey(event))return;const current=this.ownStepOf(event);if(!current)return;const navigable=this.childSteps.filter(step=>this.isReachable(step)),target=resolveListMove(event,{count:navigable.length,current:navigable.indexOf(current),orientation:this.effectiveOrientation==="vertical"?"vertical":"horizontal",direction:this.effectiveDirection,wrap:!1,clamp:!0,backwardFromMissing:"first"});target!==null&&(event.preventDefault(),navigable[target]?.focus())},this.onKeyDown=e=>{if(this.readonly||e.defaultPrevented||shouldIgnoreNavigationKey(e))return;const navigable=this.steps.map((step,index)=>({step,index})).filter(({step})=>!step.disabled);if(navigable.length===0)return;const focused=shadowFocusTarget(this),focusedIndex=Number(focused?.dataset.index),currentIndex=navigable.findIndex(item=>item.index===focusedIndex);if(e.key==="Enter"||e.key===" "){if(e.preventDefault(),isRepeatedActivationKey(e))return;if(currentIndex>=0){const target=navigable[currentIndex];this.selectStep(target.step,target.index)}return}const targetIndex=resolveListMove(e,{count:navigable.length,current:currentIndex,orientation:this.effectiveOrientation==="vertical"?"vertical":"horizontal",direction:this.effectiveDirection,wrap:!1,clamp:!0,backwardFromMissing:"first"});targetIndex!==null&&(e.preventDefault(),this.focusStep(navigable[targetIndex].index))},this.addEventListener("click",this.onChildClick),this.addEventListener("keydown",this.onChildKeyDown),new HostChildrenObserver(this,{subtree:!0,attributeFilter:["name","completed","loading","disabled","variant"],onChange:records=>{records.some(record=>{const target=record.target;return target===this||target.closest?.(tag("stepper"))===this})&&this.syncChildSteps()}})}get observesContainer(){return this.orientationBreakpoints.containerObservationEnabled||this.orientation==="auto"}get effectiveOrientation(){return this._effectiveOrientation}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.observesContainer&&this.seedInlineSize(),this.observesContainer&&this.armResizeObserver(),this.registerInvokers(),this.syncChildSteps()}registerInvokers(){const doc=this.ownerDocument;this.invokerDocument!==doc&&(this.unregisterInvokers(),this.invokerDocument=doc,acquireInvokers(doc))}unregisterInvokers(){this.invokerDocument&&releaseInvokers(this.invokerDocument),this.invokerDocument=void 0}seedInlineSize(){const hostWidth=this.getBoundingClientRect().width;hostWidth>0&&(this.measuredInlineSize=hostWidth)}orientationInlineSize(){return this.observesContainer?this.baseEl?.clientWidth??this.measuredInlineSize:this.measuredInlineSize}disconnectedCallback(){super.disconnectedCallback(),this.resetResizeObserver(),this.unregisterInvokers()}adoptedCallback(){super.adoptedCallback(),this.resetResizeObserver(),this.unregisterInvokers()}firstUpdated(changed){super.firstUpdated(changed),this.observesContainer&&this.armResizeObserver()}willUpdate(changed){if(super.willUpdate(changed),changed.has("readonly")&&this.hasUpdated&&(this.readonlyFocusLost=shadowFocusTarget(this)?.getAttribute("part")==="step"),(changed.has("active")||changed.has("linear")||changed.has("clickable")||changed.has("steps")||!this.hasUpdated)&&this.applyChildState(),changed.has("steps")){const focusedStep=shadowFocusTarget(this);focusedStep?.getAttribute("part")==="step"&&(this.pendingStepFocus={stepId:focusedStep.dataset.stepId??"",index:Number(focusedStep.dataset.index)})}(changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.orientationBreakpoints.configure(this.orientationBreakpoint,this.orientationBreakpointBasis),!this.hasUpdated&&this.isConnected&&this.observesContainer&&this.seedInlineSize(),(changed.has("orientation")||changed.has("steps")&&this.orientation==="auto"||changed.has("narrowOrientation")||changed.has("orientationBreakpoint")||changed.has("orientationBreakpointBasis"))&&this.updateEffectiveOrientation(this.orientationInlineSize(),this.hasUpdated&&this.orientationBreakpointBasis==="viewport")}updated(changed){super.updated(changed),this.syncCustomStates(),this.registerInvokers();const base=this.renderRoot.querySelector('[part~="base"]')??void 0;if(syncAriaDescribedByElements(this,base,this.getAttribute("aria-describedby")),this.scrollOverflow.observeExtra(this.renderRoot.querySelectorAll('[part="step"]')),this.syncScrollTabStop(),this.readonlyFocusLost&&(this.readonlyFocusLost=!1,restoreComposedFocus(this,!0,this.renderRoot.querySelector('[part~="base"]'))),this.pendingStepFocus!==void 0){const focusedOccurrence=this.pendingStepFocus;this.pendingStepFocus=void 0;const enabledIdentityMatches=[...this.renderRoot.querySelectorAll('[part="step"]')].filter(step=>step.dataset.stepId===focusedOccurrence.stepId&&step.getAttribute("aria-disabled")!=="true");(enabledIdentityMatches.find(step=>Number(step.dataset.index)===focusedOccurrence.index)??(enabledIdentityMatches.length===1?enabledIdentityMatches[0]:void 0)??this.renderRoot.querySelector('[part="step"][tabindex="0"]'))?.focus()}this.observesContainer?this.armResizeObserver():this.resetResizeObserver()}syncScrollTabStop(){const base=this.baseEl;if(!base)return;const scrollable=this.effectiveOrientation==="horizontal"&&base.hasAttribute(SCROLL_OVERFLOW_ATTRIBUTE);this.readonly&&scrollable?base.setAttribute("tabindex","0"):this.readonly&&(this.readonlyFocusLost||shadowFocusTarget(this)===base)?base.tabIndex=-1:base.removeAttribute("tabindex")}updateEffectiveOrientation(width,emitOnChange){const next=this.orientationBreakpoints.isBelow(width)?this.narrowOrientation:this.orientation==="auto"?this.autoStacks(width)?"vertical":"horizontal":this.orientation;if(this.orientationBreakpoints.active||this.orientation==="auto"?this.setAttribute("data-effective-orientation",next):this.removeAttribute("data-effective-orientation"),next!==this._effectiveOrientation){this._effectiveOrientation=next;for(const step of this.childSteps)step.vertical=next==="vertical";this.requestUpdate(),emitOnChange&&this.emit("lr-stepper-orientation-change",{orientation:next})}}autoStacks(width){if(!Number.isFinite(width)||width<=0)return!1;const count=this.childMode?this.childSteps.length:this.steps.length;if(count<2)return!1;const fontSize=Number.parseFloat(getComputedStyle(this).fontSize)||16,gap=this.baseEl&&Number.parseFloat(getComputedStyle(this.baseEl).columnGap)||0;return width<count*fontSize*6+(count-1)*gap}armResizeObserver(){const base=this.baseEl;base&&(this.observedBase===base&&this.resizeObserver.active||(this.resizeObserver.clear(),this.resizeObserver.observe(base),this.observedBase=base))}resetResizeObserver(){this.resizeFrame.cancel(),this.resizeObserver.clear(),this.observedBase=void 0}syncChildSteps(){const steps=Array.from(this.children).filter(child=>child.localName===tag("step")),countChanged=steps.length!==this.childSteps.length;this.childSteps=steps,this.childCount=steps.length,this.applyChildState(),this.syncCustomStates(),countChanged&&this.orientation==="auto"&&this.updateEffectiveOrientation(this.orientationInlineSize(),!0)}syncCustomStates(){const child=this.childMode,completed=child?this.childSteps.every(step=>step.completed):this.steps.length>0&&this.steps.every(step=>step.state==="completed");setCustomState(this.stepperInternals,"completed",completed),setCustomState(this.stepperInternals,"loading",child&&this.childSteps.some(step=>step.loading)),setCustomState(this.stepperInternals,"stacked",this.effectiveOrientation==="vertical")}resolveActiveStep(steps){return steps.find(step=>step.name===this.active)??steps[0]}linearBoundary(steps){const firstIncomplete=steps.findIndex(step=>!step.completed);return firstIncomplete===-1?steps.length-1:firstIncomplete}isReachable(step,steps=this.childSteps){return step.disabled?!1:this.linear?steps.indexOf(step)<=this.linearBoundary(steps):!0}applyChildState(){const steps=this.childSteps;if(steps.length===0||this.steps.length>0)return;const activeStep=this.resolveActiveStep(steps),boundary=this.linearBoundary(steps);this.activeIndex=activeStep?steps.indexOf(activeStep):0;const stop=activeStep&&this.isReachable(activeStep,steps)?activeStep:steps.find(step=>this.isReachable(step,steps)),vertical=this.effectiveOrientation==="vertical";steps.forEach((step,index)=>{step.position=index+1,step.active=step===activeStep,step.locked=this.linear&&index>boundary,step.clickable=this.clickable,step.vertical=vertical,step.first=index===0,step.last=index===steps.length-1,step.tabStop=step===stop;const previous=steps[index-1];step.connectorStartVariant=previous?.completed?previous.variant:void 0})}goTo(name){if(!this.childMode)return;const steps=this.childSteps,target=steps.find(step=>step.name===name);if(!target||!this.isReachable(target,steps))return;const previousStep=this.resolveActiveStep(steps)??null;if(target===previousStep)return;const detail={name:target.name,previousName:previousStep?.name??null,step:target,previousStep};this.emit("lr-before-step-change",detail,{cancelable:!0}).defaultPrevented||(this.active=target.name,this.updateComplete.then(()=>{this.emit("lr-step-change",detail);const format=getNumberFormat(this.effectiveLocale);this.announcements.announcePolite(this.localize("stepperStepPosition",void 0,{current:format.format(this.activeIndex+1),total:format.format(this.childSteps.length)}))}))}next(){const steps=this.childSteps,index=steps.findIndex(step=>step===this.resolveActiveStep(steps)),target=steps[index+1];index>=0&&target&&this.goTo(target.name)}previous(){const steps=this.childSteps,index=steps.findIndex(step=>step===this.resolveActiveStep(steps)),target=index>0?steps[index-1]:void 0;target&&this.goTo(target.name)}ownStepOf(event){const origin=event.target;if(!(origin instanceof Element))return;const step=origin.closest(tag("step"));return step&&step.parentNode===this?step:void 0}renderChildren(){const format=getNumberFormat(this.effectiveLocale),name=this.accessibleLabel||this.label||this.localize("stepperSteps"),body=html`
|
|
2
|
+
<span part="summary" class="visually-hidden" >${this.localize("stepperStepPosition",void 0,{current:format.format(this.activeIndex+1),total:format.format(this.childCount)})}</span
|
|
3
|
+
>
|
|
4
|
+
<div part="base steps" class="child-steps" role="list"><slot></slot></div>
|
|
5
|
+
`;return this.clickable?html`<nav part="stepper" aria-label=${name}>${body}</nav>`:html`<div part="stepper" role="group" aria-label=${name}>${body}</div>`}selectStep(step,index){this.readonly||step.disabled||this.emit("lr-step-select",{stepId:step.stepId,index})}focusStep(index){this.renderRoot.querySelector(`[part="step"][data-index="${index}"]`)?.focus()}render(){if(this.childMode)return this.renderChildren();const currentIndex=this.steps.findIndex(step=>step.state==="current"),rovingIndex=this.readonly?-1:currentIndex>=0&&!this.steps[currentIndex].disabled?currentIndex:this.steps.findIndex(step=>!step.disabled),numberFormat=getNumberFormat(this.effectiveLocale),stateText=step=>{const parts=[];return step.state==="completed"?parts.push(this.localize("stepperStateCompleted")):step.state==="error"?parts.push(this.localize("stepperStateError")):step.state==="pending"&&parts.push(this.localize("stepperStatePending")),step.disabled&&!this.readonly&&parts.push(this.localize("stepperStateLocked")),parts.length===0?nothing:html`<span class="visually-hidden">${parts.length===1?parts[0]:getListFormat(this.effectiveLocale,{type:"unit"}).format(parts)}</span>`},stepGlyphs=(step,index)=>html`${step.icon!==void 0?html`<span part="step-icon" aria-hidden="true" inert >${step.icon}</span
|
|
2
6
|
>`:nothing}
|
|
3
7
|
${step.state==="completed"?html`<span part="step-check">${checkIcon()}</span>`:html`<span part="step-index" >${numberFormat.format(index+1)}</span
|
|
4
8
|
>`}`;return html`
|
|
@@ -15,4 +19,4 @@ import{__decorate}from"tslib";import{finiteCount}from"../../../internal/numbers.
|
|
|
15
19
|
</button>`}
|
|
16
20
|
</div>`)}
|
|
17
21
|
</div>
|
|
18
|
-
`}}__decorate([property({attribute:!1})],LyraStepper.prototype,"steps",null),__decorate([property({reflect:!0,converter:declaredDefaultConverter("horizontal")})],LyraStepper.prototype,"orientation",void 0),__decorate([property({attribute:"orientation-breakpoint"})],LyraStepper.prototype,"orientationBreakpoint",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("container"),attribute:"orientation-breakpoint-basis"})],LyraStepper.prototype,"orientationBreakpointBasis",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("vertical"),attribute:"narrow-orientation"})],LyraStepper.prototype,"narrowOrientation",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"wrap-labels"})],LyraStepper.prototype,"wrapLabels",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraStepper.prototype,"readonly",void 0),__decorate([property({attribute:"aria-label"})],LyraStepper.prototype,"accessibleLabel",void 0),__decorate([property()],LyraStepper.prototype,"label",void 0),__decorate([query('[part
|
|
22
|
+
`}}__decorate([property({attribute:!1})],LyraStepper.prototype,"steps",null),__decorate([property({reflect:!0,converter:declaredDefaultConverter("horizontal")})],LyraStepper.prototype,"orientation",void 0),__decorate([property({attribute:"orientation-breakpoint"})],LyraStepper.prototype,"orientationBreakpoint",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("container"),attribute:"orientation-breakpoint-basis"})],LyraStepper.prototype,"orientationBreakpointBasis",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("vertical"),attribute:"narrow-orientation"})],LyraStepper.prototype,"narrowOrientation",void 0),__decorate([property({type:Boolean,reflect:!0,attribute:"wrap-labels"})],LyraStepper.prototype,"wrapLabels",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraStepper.prototype,"readonly",void 0),__decorate([property({attribute:"aria-label"})],LyraStepper.prototype,"accessibleLabel",void 0),__decorate([property()],LyraStepper.prototype,"label",void 0),__decorate([property({reflect:!0})],LyraStepper.prototype,"active",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraStepper.prototype,"linear",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraStepper.prototype,"clickable",void 0),__decorate([state()],LyraStepper.prototype,"childCount",void 0),__decorate([query('[part~="base"]')],LyraStepper.prototype,"baseEl",void 0),__decorate([state()],LyraStepper.prototype,"activeIndex",void 0);export{LyraStepper};
|