@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
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{AnchoredDisclosureController}from"../../../internal/anchored-disclosure-controller.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isAccessibilitySubtreeExcluded,isAccessibilityVisibilityHidden,nextId}from"../../../internal/a11y.js";import{resolveAccessibleTrigger}from"../../../internal/accessible-trigger.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{isActionableElement}from"../../../internal/focus-navigation.js";import{imageMapImageFor}from"../../../internal/dom-guards.js";import{deferredPlaceReady as place,syncTopLayerRelease,topLayerPlacement,waitForDeferredPlacement}from"../../../internal/anchored-overlay-runtime.js";import{virtualAnchorFromRect}from"../../../internal/positioner-geometry.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{composedParentElement,deepActiveElementIn}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{parseCssTimeToken}from"../../../internal/css-motion-time.js";import{finiteDuration,finiteNumber}from"../../../internal/numbers.js";import{declaredDefaultConverter,literalSetConverter,omittedEmptyStringConverter,blankNumberConverter}from"../../../internal/converters.js";import{PositioningStrategyState,positioningStrategyConverter,resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{activateNonmodalOverlay,composedContains}from"../../../internal/nonmodal-overlay-manager.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{subscribeInheritedAttributes}from"../../../internal/inherited-attribute-hub.js";import{accessibleTextRecordsMatter,bindAccessibleTextObserver,labelReferenceRecordsMatter,composedAccessibilityTextResult}from"../../../internal/accessibility-visibility.js";import{applyOverlayArrow}from"./overlay-arrow.js";import{normalizeVirtualRect,OverlayAnchorIdentity,OverlayDelayTimer,resolveOverlayAnchor,resolveOverlayAccessibleTrigger,resolveOverlayInteractionTrigger}from"../../../internal/overlay-shared.js";import{tooltipStyles}from"./overlay.styles.js";import{LYRA_DEFAULT_popover}from"../../../internal/default-strings/overlays.generated.js";const DEFAULT_SHOW_DELAY=150,DEFAULT_HIDE_DELAY=0,DEFAULT_DISTANCE=8,MAX_SHADOW_CONTENT_SCAN_FRAMES=4;function safelyComposedContains(container,candidate){try{return candidate?.nodeType===1&&composedContains(container,candidate)}catch{return!1}}const TOOLTIP_LABEL_MODE=literalSetConverter(["description","label","none"],"description"),BLANK_TEXT=/^[ \t\n\f\r]*$/;function isBlankText(node){return node.nodeType===Node.TEXT_NODE&&BLANK_TEXT.test(node.textContent??"")}class LyraTooltip extends LyraElement{constructor(){super(...arguments),this._open=!1,this.trigger="hover focus",this._labelMode="description",this.manual=!1,this.showDelay=150,this.hideDelay=0,this.placement="top",this.distance=8,this.skidding=0,this._for="",this.anchor=null,this.disabled=!1,this.strategy=new PositioningStrategyState(this),this.topLayer=!1,this.withoutArrow=!1,this.arrowPlacement="anchor",this.arrowPadding=0,this.content="",this.accessibleLabel="",this.namedTriggerMode=!0,this.interactiveContent=!1,this.blankContentAssignment=!1,this.resolvedSide="top",this.anchorPositioned=!1,this.popupHidden=!0,this.directionChanged=!1,this.anchorIdentity=new OverlayAnchorIdentity,this.placementPending=!1,this.delayTimer=new OverlayDelayTimer,this.restoreFocusOnClose=!1,this.suppressTriggerFocusOpen=!1,this.openedByPointer=!1,this.tooltipId=nextId("tooltip"),this.descriptionId=nextId("tooltip-description"),this.focusDescribesTrigger=!1,this.triggerSyncGeneration=0,this.contentSlotListeners=new Set,this.shadowContentScanAttempts=0,this.disclosure=new AnchoredDisclosureController({host:this,isOpen:()=>this._open,setOpen:value=>this.applyOpenState(value),emit:name=>name==="lr-show"||name==="lr-hide"?this.emit(name,null,{cancelable:!0}).defaultPrevented:this.emit(name).defaultPrevented,popup:()=>this.renderRoot.querySelector('[part~="popup"]'),readyToShow:async isCurrent=>{const positioned=await waitForDeferredPlacement(()=>this.cleanup);return isCurrent()&&positioned&&this.anchorPositioned&&!this.placementPending},animate:(showing,popup)=>animateRegistered(this,popup,`tooltip.${showing?"show":"hide"}`,this.effectiveDirection,{keyframes:showing?[{opacity:0},{opacity:1}]:[{opacity:1},{opacity:0}],durationProperties:["--lr-transition-fast","--lr-duration-fast"],easingProperties:["--lr-easing-standard"]}),afterHide:()=>{this.popupHidden=!0}}),this.onTriggerSlotChange=event=>{this.syncNamedTriggerMode();const slot=event.target;this.slottedTriggerElement=slot.assignedElements({flatten:!0})[0],this.syncInteractionTrigger()},this.onEnter=event=>{if(!this.disabled){if(event.type==="focusin"){if(this.updateInteractiveContent(),this.opensOn("focus")&&(this.focusDescribesTrigger=!0),this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot),this.syncTriggerA11y(),this.suppressTriggerFocusOpen||!this.opensOn("focus")||!isKeyboardFocusEvent(event))return}else{if(this.syncTriggerA11y(),!this.opensOn("hover"))return;this.openedByPointer=!0}this.requestTransition(!0)}},this.onLeave=event=>{if(event.type==="focusout"?!this.opensOn("focus"):!this.opensOn("hover"))return;const next=event.relatedTarget;next!==null&&next.nodeType===1&&this.triggerElement&&composedContains(this.triggerElement,next)||(event.type==="focusout"&&(this.focusDescribesTrigger=!1,this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot),this.syncTriggerA11y()),!(this.interactiveContent&&(this.isPopupTarget(next)||this.retainsPopupInteraction(event)))&&this.requestTransition(!1))},this.onTriggerClick=()=>{this.disabled||this.opensOn("click")&&(this.syncTriggerA11y(),this._open?this.hide():this.show())},this.onPopupEnter=()=>{!this.interactiveContent||this.isManual||(this.cancelPendingTransition(),this.show())},this.onPopupLeave=event=>{if(!this.interactiveContent||this.isManual||this.retainsPopupInteraction(event))return;const next=event.relatedTarget;next!==null&&next.nodeType===1&&(this.triggerElement&&composedContains(this.triggerElement,next)||this.isPopupTarget(next))||this.requestTransition(!1)},this.onContentSlotChange=event=>{event.target?.localName==="slot"&&this.updateInteractiveContent()}}static{this.defaultStrings={...super.defaultStrings,popover:LYRA_DEFAULT_popover}}static{this.styles=[LyraElement.styles,tooltipStyles]}get open(){return this._open}set open(next){const normalized=!!next;if(normalized||this.cancelPendingTransition(),normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.hide()}}get labelMode(){return this._labelMode}set labelMode(next){this._labelMode=TOOLTIP_LABEL_MODE.normalize(next)}get for(){return this._for}set for(next){this._for=next??""}get positioningStrategy(){return this.strategy.value}set positioningStrategy(next){this.strategy.set(next)}get hoist(){return this.strategy.hoist}set hoist(next){this.strategy.setHoist(next)}get rendersArrow(){return!this.withoutArrow}get activeContentSlot(){const selector=this.namedTriggerMode?'[part~="body"] slot:not([name])':'[part~="body"] slot[name="content"]';return(this.renderRoot??this.shadowRoot)?.querySelector(selector)??null}syncNamedTriggerMode(schedule=!0){const children=Array.from(this.children),hasNamedTrigger=children.some(child=>child.getAttribute("slot")==="trigger"),hasShoelaceContent=(this.content??"").length>0||children.some(child=>child.getAttribute("slot")==="content"),next=hasNamedTrigger||!hasShoelaceContent;if(next===this.namedTriggerMode)return;const old=this.namedTriggerMode;this.namedTriggerMode=next,schedule&&this.hasUpdated&&this.requestUpdate("namedTriggerMode",old)}get triggerKeywords(){return new Set(String(this.trigger??"").trim().split(/\s+/).filter(Boolean))}get isManual(){const keywords=this.triggerKeywords;return this.manual||keywords.size===0||keywords.has("manual")}opensOn(keyword){return!this.isManual&&this.triggerKeywords.has(keyword)}willUpdate(changed){super.willUpdate(changed);const direction=this.effectiveDirection;this.directionChanged=direction!==this.positioningDirection,this.positioningDirection=direction,this.syncNamedTriggerMode(!1),(changed.has("manual")||changed.has("trigger"))&&this.isManual&&this.cancelPendingTransition(),(changed.has("manual")||changed.has("trigger"))&&this.focusDescribesTrigger&&!this.opensOn("focus")&&(this.focusDescribesTrigger=!1,this.syncTriggerA11y()),changed.has("disabled")&&this.disabled&&(this.cancelPendingTransition(),this.focusDescribesTrigger&&(this.focusDescribesTrigger=!1,this.syncTriggerA11y()),this._open&&(this.hasUpdated?this.hide():this.applyOpenState(!1))),this.anchorIdentity.lostAnchorProperty(changed,this.anchor)&&this.open&&!this.resolveAnchor()&&this.forceClose(),changed.has("showDelay")&&this.delayTimer.pendingDirection==="show"&&this.requestTransition(!0),changed.has("hideDelay")&&this.delayTimer.pendingDirection==="hide"&&this.requestTransition(!1),changed.has("for")&&this.syncInteractionTrigger(),changed.has("open")&&!this.open&&(this.anchorPositioned=!1),changed.has("open")&&this.open&&(this.popupHidden=!1),changed.has("open")&&this.open&&this.hasUpdated&&this.isConnected&&this.updateInteractiveContent(),changed.has("labelMode")&&this.hasUpdated&&this.isConnected&&(this.contentNeeded?this.updateInteractiveContent():this.observeStructureOnly()),(changed.has("anchor")||changed.has("for"))&&(this.anchorPositioned=!1)}updated(changed){if(super.updated(changed),(changed.has("for")||changed.has("anchor")||changed.has("open"))&&this.syncAnchorIdentityObservation(),this.directionChanged||changed.has("open")||changed.has("placement")||changed.has("distance")||changed.has("skidding")||changed.has("for")||changed.has("anchor")||changed.has("positioningStrategy")||changed.has("topLayer")||changed.has("arrow")||changed.has("withoutArrow")||changed.has("arrowPlacement")||changed.has("arrowPadding")||changed.has("interactiveContent")){if(this.cleanup?.(),this.cleanup=void 0,this.open&&this.isConnected&&this.position(),changed.has("open"))if(this.open)this.updateInteractiveContent(),this.isConnected&&this.requiresOverlayManager&&this.activateTooltipOverlay();else{this.positionedAnchor=void 0;const restoreFocus=this.restoreFocusOnClose;this.suppressTriggerFocusOpen=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.suppressTriggerFocusOpen=!1}this.overlayHandle=void 0,this.restoreFocusOnClose=!1,this.virtualAnchor=void 0,this.returnFocusTo=void 0,this.syncInteractionTrigger(),this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot)}else changed.has("interactiveContent")&&this.open&&this.isConnected&&this.activateTooltipOverlay();this.syncTriggerA11y()}changed.has("labelMode")&&this.syncTriggerA11y(),(changed.has("content")||changed.has("accessibleLabel"))&&this.updateDescriptionProxy()}connectedCallback(){super.connectedCallback();const triggerSyncGeneration=++this.triggerSyncGeneration,triggerSyncDocument=this.ownerDocument;this.syncAnchorIdentityObservation(),this.ensureDescriptionProxy(),this.contentObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;this.contentObserver=MutationObserverCtor?new MutationObserverCtor((records,observer)=>{if(!this.contentNeeded){this.syncNamedTriggerMode();return}accessibleTextRecordsMatter(observer,records)&&(this.syncNamedTriggerMode(),this.updateInteractiveContent())}):void 0,this.updateInteractiveContent(),this.syncInteractionTrigger(),this.updateComplete.then(()=>{if(triggerSyncGeneration!==this.triggerSyncGeneration||!this.isConnected||this.ownerDocument!==triggerSyncDocument)return;const slot=this.renderRoot.querySelector('[part="trigger"] > slot');this.slottedTriggerElement=slot?.assignedElements({flatten:!0})[0],this.syncInteractionTrigger()}),this.hasUpdated&&this.open&&(this.popupHidden=!1,this.position(),this.requiresOverlayManager&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.activateTooltipOverlay()))}disconnectedCallback(){this.triggerSyncGeneration++,this.anchorIdentity.stop(),this.cancelPendingTransition(),this.cleanup?.(),this.cleanup=void 0,this.overlayHandle?.suspend(),this.triggerElement&&this.unbindTrigger(this.triggerElement),this.releaseTriggerA11y(),this.focusDescribesTrigger=!1,this.triggerElement=void 0,this.contentObserver?.disconnect(),this.contentObserver=void 0,this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.clearContentSlotListeners(),this.cancelShadowContentScan(),this.disclosure.reset(),this.popupHidden=!0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.triggerSyncGeneration++,this.anchorIdentity.stop(),this.cancelPendingTransition(),this.cancelShadowContentScan(),this.contentObserver?.disconnect(),this.contentObserver=void 0,this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.clearContentSlotListeners(),this.releaseTriggerA11y()}syncAnchorIdentityObservation(){this.anchorIdentity.stop();const directAnchor=this.open?this.anchor??void 0:void 0;this.anchorIdentity.observe(this,directAnchor,this.for,()=>this.anchor,directAnchorRemoved=>{if((this.resolveInteractionTrigger()!==this.triggerElement||this.open||this.focusDescribesTrigger)&&this.syncInteractionTrigger(),!this.open)return;const nextAnchor=this.resolveAnchor();if(directAnchorRemoved&&!nextAnchor){this.forceClose();return}nextAnchor!==this.positionedAnchor&&this.position()})}resolveInteractionTrigger(){return resolveOverlayInteractionTrigger(this,this.virtualAnchor,this.slottedTriggerElement,this.for)}syncInteractionTrigger(){const next=this.resolveInteractionTrigger();this.adoptTrigger(next)}activateTooltipOverlay(){if(!this.isConnected)return;const restoreFocusTarget=this.virtualAnchor?this.returnFocusTo??null:this.accessibleTrigger;if(this.overlayHandle?.isActive()){this.overlayHandle.updateRestoreFocusTo(restoreFocusTarget);return}this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part~="popup"]'),onEscape:()=>{this.hide({restoreFocus:this.shouldRestoreFocusAfterEscape()})},restoreFocusTo:restoreFocusTarget}),this.overlayHandle.focusAutofocus()}shouldRestoreFocusAfterEscape(){if(this.virtualAnchor)return this.returnFocusTo!==void 0;const active=deepActiveElementIn(this.ownerDocument);return safelyComposedContains(this,active)}get requiresOverlayManager(){return this.open}showAt(rect,options){const normalizedRect=normalizeVirtualRect(rect);if(!normalizedRect)return;const previousAnchor=this.virtualAnchor,previousReturnFocusTo=this.returnFocusTo;if(this.virtualAnchor=virtualAnchorFromRect(normalizedRect),this.returnFocusTo=options?.returnFocusTo,this.syncInteractionTrigger(),this.open){this.activateTooltipOverlay(),this.position();return}this.show(),!this.open&&(this.virtualAnchor=previousAnchor,this.returnFocusTo=previousReturnFocusTo,this.syncInteractionTrigger())}show(){return this.cancelPendingTransition(),this.disabled?Promise.resolve():this.disclosure.show()}hide(options){return this.cancelPendingTransition(),this.disclosure.hide(()=>{options?.restoreFocus&&(this.restoreFocusOnClose=!0)})}forceClose(){return this.cancelPendingTransition(),this.disclosure.forceClose()}applyOpenState(next){const old=this._open;this._open=next,next||(this.cancelShadowContentScan(),this.placementPending=!1),next||(this.openedByPointer=!1),this.requestUpdate("open",old)}resolveAnchor(){return resolveOverlayAnchor(this,{virtualAnchor:this.virtualAnchor,anchor:this.anchor,for:this.for,trigger:this.triggerElement})}position(){this.cleanup?.(),this.cleanup=void 0;const popup=this.renderRoot.querySelector('[part~="popup"]'),arrowElement=this.renderRoot.querySelector('[part~="arrow"]'),anchor=this.resolveAnchor();if(!this.open||!anchor||!popup){this.positionedAnchor=void 0,this.anchorPositioned=!1,this.placementPending=!1;return}if(anchor!==this.positionedAnchor&&(this.anchorPositioned=!1),this.open&&anchor&&popup){const arrowPadding=Math.max(0,finiteNumber(this.arrowPadding,0));this.placementPending=!0,this.placedTopLayer=syncTopLayerRelease(popup,this.placedTopLayer,this.topLayer);const operation=place(anchor,popup,{placement:rtlAwarePlacement(this.placement,this),...topLayerPlacement(this.topLayer,resolveEffectivePositioningStrategy(this,this.strategy.authored,"absolute")),offset:finiteNumber(this.distance,DEFAULT_DISTANCE),skidding:finiteNumber(this.skidding,0),arrow:this.rendersArrow&&arrowElement?arrowElement:void 0,arrowPadding,onPlaced:({placement,arrow})=>{this.placementPending=!1,this.positionedAnchor=anchor,this.anchorPositioned=!0;const side=applyOverlayArrow(arrowElement,{placement,coords:arrow,enabled:this.rendersArrow,arrowPlacement:this.arrowPlacement,arrowPadding,rtl:this.effectiveDirection==="rtl",sizeProperty:"--arrow-size",fallbackSizeProperty:"--lr-tooltip-arrow-size"});side!==this.resolvedSide&&(this.resolvedSide=side)}});this.cleanup=operation,operation.ready.then(positioned=>{!positioned&&this.cleanup===operation&&this.open&&(this.restoreFocusOnClose=safelyComposedContains(this,deepActiveElementIn(this.ownerDocument)),this.forceClose())})}}syncTriggerA11y(){const trigger=this.triggerElement??null,proxy=this.descriptionProxy,contribution={labels:proxy&&this.labelMode==="label"?[proxy]:[],descriptions:proxy&&this.labelMode==="description"&&(this.open||this.focusDescribesTrigger)?[proxy]:[]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution);const accessibleTrigger=this.accessibleTrigger;this.observeTriggerTarget(contribution.labels.length||contribution.descriptions.length?trigger:null,accessibleTrigger);const distinctAccessibleTrigger=accessibleTrigger!==trigger?accessibleTrigger:null;this.accessibleTriggerAria?this.accessibleTriggerAria.update(distinctAccessibleTrigger,contribution):this.accessibleTriggerAria=acquireAriaOwnership(distinctAccessibleTrigger,contribution),this.overlayHandle?.isActive()&&!this.virtualAnchor&&this.overlayHandle.updateRestoreFocusTo(accessibleTrigger)}observeTriggerTarget(trigger,control){if(this.triggerTargetObserver?.disconnect(),!trigger||!this.isConnected){this.triggerTargetUpgrades?.disconnect();return}this.triggerTargetUpgrades??=new CustomElementUpgradeObserver(()=>this.syncTriggerA11y()),this.triggerTargetUpgrades.observeElement(trigger);const Observer=this.ownerDocument.defaultView?.MutationObserver;if(!Observer)return;this.triggerTargetObserver??=new Observer(()=>this.syncTriggerA11y());const options={childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-disabled","aria-hidden","class","disabled","hidden","href","inert","name","role","slot","style","tabindex","type"]};this.triggerTargetObserver.observe(trigger,options);for(let node=control;node&&(node.shadowRoot&&this.triggerTargetObserver.observe(node.shadowRoot,options),node!==trigger);node=composedParentElement(node));}get accessibleTrigger(){return this.triggerElement?this.labelMode==="label"?resolveOverlayAccessibleTrigger(this.triggerElement):resolveAccessibleTrigger(this.triggerElement):null}releaseTriggerA11y(){this.triggerTargetObserver?.disconnect(),this.triggerTargetObserver=void 0,this.triggerTargetUpgrades?.disconnect(),this.triggerTargetUpgrades=void 0,this.accessibleTriggerAria?.release(),this.accessibleTriggerAria=void 0,this.triggerAria?.release(),this.triggerAria=void 0}requestTransition(next){if(this.cancelPendingTransition(),this.disabled)return;const delay=this.interactionDelay(next);if(delay<=0){next?this.show():this.hide();return}const view=this.ownerDocument.defaultView;view&&this.delayTimer.schedule(view,delay,next?"show":"hide",()=>{next?this.show():this.hide()})}interactionDelay(showing){const value=showing?this.showDelay:this.hideDelay,fallback=showing?DEFAULT_SHOW_DELAY:DEFAULT_HIDE_DELAY,attribute=showing?"show-delay":"hide-delay";if(this.hasAttribute(attribute)||value!==fallback)return finiteDuration(value,fallback);const property2=showing?"--show-delay":"--hide-delay",raw=this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue(property2).trim()??"",token=parseCssTimeToken(raw);return token&&!token.rest?finiteDuration(token.ms,fallback):fallback}cancelPendingTransition(){this.delayTimer.cancel()}bindTrigger(trigger){trigger.addEventListener("mouseenter",this.onEnter),trigger.addEventListener("mouseleave",this.onLeave),trigger.addEventListener("focusin",this.onEnter),trigger.addEventListener("focusout",this.onLeave),trigger.addEventListener("click",this.onTriggerClick)}unbindTrigger(trigger){trigger.removeEventListener("mouseenter",this.onEnter),trigger.removeEventListener("mouseleave",this.onLeave),trigger.removeEventListener("focusin",this.onEnter),trigger.removeEventListener("focusout",this.onLeave),trigger.removeEventListener("click",this.onTriggerClick),this.focusDescribesTrigger=!1}isTriggerHeld(trigger){try{if(trigger.matches(":hover"))return!0}catch{}const active=deepActiveElementIn(trigger.ownerDocument);return safelyComposedContains(trigger,active)}adoptTrigger(next){if(next===this.triggerElement){this.syncTriggerA11y();return}const hadTrigger=this.triggerElement!==void 0;if(this.cancelPendingTransition(),this.triggerElement&&this.unbindTrigger(this.triggerElement),this.triggerElement=next,!this.triggerElement){this.syncTriggerA11y(),hadTrigger&&this.open&&!this.resolveAnchor()&&this.forceClose();return}this.bindTrigger(this.triggerElement),this.syncTriggerA11y(),hadTrigger&&this._open&&this.openedByPointer&&!this.isTriggerHeld(this.triggerElement)&&this.forceClose(),this.open&&this.position(),this.open&&this.interactiveContent&&this.activateTooltipOverlay()}retainsPopupInteraction(event){return event.type==="mouseleave"?this.isPopupTarget(deepActiveElementIn(this.ownerDocument)):this.opensOn("hover")&&(this.triggerElement?.matches(":hover")===!0||this.renderRoot.querySelector('[part~="popup"]:hover')!==null)}isPopupTarget(target){if(target===null||target.nodeType!==1)return!1;const element=target,slot=this.activeContentSlot;return this.renderRoot.querySelector('[part~="popup"]')?.contains(element)===!0||slot?.assignedElements({flatten:!0}).some(root=>composedContains(root,element))===!0}clearContentSlotListeners(){for(const slot of this.contentSlotListeners)slot.removeEventListener("slotchange",this.onContentSlotChange);this.contentSlotListeners.clear()}syncContentSlotListeners(slots){const activeSlot=this.activeContentSlot;for(const slot of this.contentSlotListeners)slots.has(slot)&&slot!==activeSlot||(slot.removeEventListener("slotchange",this.onContentSlotChange),this.contentSlotListeners.delete(slot));for(const slot of slots)slot===activeSlot||this.contentSlotListeners.has(slot)||(slot.addEventListener("slotchange",this.onContentSlotChange),this.contentSlotListeners.add(slot))}inspectContent(){const snapshot={actionable:!1,assigned:!1,blank:!1,awaitingShadowRoot:!1,labelReferenceRoots:new Set,labelReferenceIds:new Set,referencedElements:new Set,text:"",externalRoots:new Set,shadowRoots:new Set,forwardingSlots:new Set,composedAncestors:new Set},activeSlot=this.activeContentSlot;if(!activeSlot)return snapshot;const renderRoot=this.renderRoot??this.shadowRoot,assignedNodes=activeSlot.assignedNodes();if(snapshot.assigned=assignedNodes.some(node=>!isBlankText(node)),snapshot.blank=assignedNodes.length>0&&!snapshot.assigned,!snapshot.assigned)return snapshot;const popup=renderRoot?.querySelector('[part~="popup"]'),bypassClosedVisibility=popup?.hasAttribute("data-hidden")===!0||this.placementPending,previousVisibility=popup?.style.getPropertyValue("visibility")??"",previousVisibilityPriority=popup?.style.getPropertyPriority("visibility")??"",previousHidden=popup?.hidden??!1;if(popup&&bypassClosedVisibility){const hostVisibility=this.ownerDocument.defaultView?.getComputedStyle(this).visibility??"visible";popup.style.setProperty("visibility",hostVisibility),popup.hidden=!1}try{const visitedContentElements=new Set,elementStates=new Map,accessibilityText=composedAccessibilityTextResult(activeSlot,{shouldPruneNode:node=>{if(node.getRootNode()!==renderRoot&&!this.contains(node)&&snapshot.externalRoots.add(node),node.nodeType!==1)return!1;const element=node;return visitedContentElements.add(element),element.localName==="slot"&&snapshot.forwardingSlots.add(element),element.shadowRoot?snapshot.shadowRoots.add(element.shadowRoot):element.localName.includes("-")&&(snapshot.awaitingShadowRoot=!0),!1},onElementState:(element,state2)=>elementStates.set(element,state2)});for(const element of elementStates.keys())!visitedContentElements.has(element)&&element!==this&&snapshot.composedAncestors.add(element);for(const element of visitedContentElements){const imageMapElement=element.localName==="map"||element.localName==="area";if(imageMapElement){const image=imageMapImageFor(element);image&&snapshot.externalRoots.add(image)}if(!isActionableElement(element))continue;const state2=imageMapElement?void 0:elementStates.get(element);if(state2?.subtreeExcluded??isAccessibilitySubtreeExcluded(element))continue;(state2?.visibilityHidden??isAccessibilityVisibilityHidden(element))||(snapshot.actionable=!0)}snapshot.text=accessibilityText.text.replace(/\s+/g," ").trim();for(const root of accessibilityText.labelReferenceRoots)snapshot.labelReferenceRoots.add(root);for(const id of accessibilityText.labelReferenceIds)snapshot.labelReferenceIds.add(id);for(const reference of accessibilityText.referencedElements)snapshot.referencedElements.add(reference),snapshot.externalRoots.add(reference)}finally{popup&&bypassClosedVisibility&&(previousVisibility?popup.style.setProperty("visibility",previousVisibility,previousVisibilityPriority):popup.style.removeProperty("visibility"),popup.hidden=previousHidden)}return snapshot}observeContentNode(node){if(this.contentObserver){if(node.nodeType===3){this.contentObserver.observe(node,{characterData:!0});return}node.nodeType!==1&&node.nodeType!==11||this.contentObserver.observe(node,{attributes:!0,attributeFilter:["aria-hidden","aria-label","aria-labelledby","alt","class","contenteditable","hidden","href","inert","name","open","role","slot","style","tabindex","usemap"],childList:!0,characterData:!0,subtree:!0})}}get contentNeeded(){return this.open||this.focusDescribesTrigger||this.labelMode==="label"}observeStructureOnly(){this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.cancelShadowContentScan();const observer=this.contentObserver;observer&&(observer.disconnect(),observer.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}bindContentObservation(snapshot){if(!this.contentNeeded){this.observeStructureOnly();return}if(this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.isConnected&&snapshot.labelReferenceRoots.size>0){const Observer=this.ownerDocument.defaultView?.MutationObserver,cleanups=[...snapshot.labelReferenceRoots].map(root=>subscribeInheritedAttributes(root,Observer,{attributes:["id"],childList:!0,changed:records=>{labelReferenceRecordsMatter(records,snapshot.labelReferenceIds,snapshot.referencedElements)&&this.updateInteractiveContent()}}));this.stopLabelReferenceIdentityObservation=()=>{for(const cleanup of cleanups)cleanup?.()}}if(!this.contentObserver)return;const pendingRecords=this.contentObserver.takeRecords(),pendingMatter=pendingRecords.length>0&&accessibleTextRecordsMatter(this.contentObserver,pendingRecords),observer=this.contentObserver;if(!snapshot.assigned&&!snapshot.blank){observer.disconnect(),observer.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0});return}bindAccessibleTextObserver(observer,this),pendingMatter&&queueMicrotask(()=>{this.isConnected&&this.contentObserver===observer&&this.updateInteractiveContent()}),this.observeContentNode(this);for(const root of snapshot.externalRoots)this.observeContentNode(root);for(const root of snapshot.shadowRoots)this.observeContentNode(root)}updateInteractiveContent(fromShadowContentScan=!1){fromShadowContentScan||(this.shadowContentScanAttempts=0);const snapshot=this.inspectContent();this.contentSnapshot=snapshot,this.interactiveContent=snapshot.actionable,this.blankContentAssignment=snapshot.blank,this.syncContentSlotListeners(snapshot.forwardingSlots),this.bindContentObservation(snapshot),this.scheduleShadowContentScan(snapshot.awaitingShadowRoot),this.updateDescriptionProxy()}scheduleShadowContentScan(awaitingShadowRoot){if(this.cancelShadowContentScan(!1),!awaitingShadowRoot||!this.open||!this.isConnected||this.shadowContentScanAttempts>=MAX_SHADOW_CONTENT_SCAN_FRAMES)return;const view=this.ownerDocument.defaultView;view&&(this.shadowContentScanView=view,this.shadowContentScanFrame=view.requestAnimationFrame(()=>{this.shadowContentScanFrame=void 0,this.shadowContentScanView=void 0,this.shadowContentScanAttempts++,this.updateInteractiveContent(!0)}))}cancelShadowContentScan(resetAttempts=!0){this.shadowContentScanFrame!==void 0&&this.shadowContentScanView?.cancelAnimationFrame(this.shadowContentScanFrame),this.shadowContentScanFrame=void 0,this.shadowContentScanView=void 0,resetAttempts&&(this.shadowContentScanAttempts=0)}ensureDescriptionProxy(){this.descriptionProxy||(this.descriptionProxy=this.ownerDocument.createElement("span"),this.descriptionProxy.id=this.descriptionId,this.descriptionProxy.slot="__lr-tooltip-description",this.descriptionProxy.hidden=!0,this.descriptionProxy.dataset.lyraTooltipDescription=""),this.updateDescriptionProxy()}updateDescriptionProxy(){if(!this.descriptionProxy)return;this.descriptionProxy.parentNode!==this&&this.append(this.descriptionProxy);const hostLabel=this.getAttribute("aria-label"),visibleContent=this.contentSnapshot?.text??"",hasAssignment=this.contentSnapshot?.assigned??!1,description=hostLabel!==null?hostLabel.trim():(this.accessibleLabel||visibleContent||(hasAssignment?"":this.content??"")).trim();this.descriptionProxy.textContent!==description&&(this.descriptionProxy.textContent=description)}render(){const hostLabel=this.getAttribute("aria-label"),propertyLabel=this.accessibleLabel??"",hasExplicitLabel=hostLabel!==null||propertyLabel.length>0,label=hostLabel!==null?hostLabel:propertyLabel,popupLabel=this.interactiveContent?hasExplicitLabel?label:this.localize("popover"):hasExplicitLabel?label:nothing;return html`
|
|
1
|
+
import{__decorate}from"tslib";import{AnchoredDisclosureController}from"../../../internal/anchored-disclosure-controller.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{isAccessibilitySubtreeExcluded,isAccessibilityVisibilityHidden,nextId}from"../../../internal/a11y.js";import{resolveAccessibleTrigger}from"../../../internal/accessible-trigger.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{isActionableElement}from"../../../internal/focus-navigation.js";import{imageMapImageFor}from"../../../internal/dom-guards.js";import{deferredPlaceReady as place,syncTopLayerRelease,topLayerPlacement,waitForDeferredPlacement}from"../../../internal/anchored-overlay-runtime.js";import{virtualAnchorFromRect}from"../../../internal/positioner-geometry.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{composedParentElement,deepActiveElementIn}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{parseCssTimeToken}from"../../../internal/css-motion-time.js";import{finiteDuration,finiteNumber}from"../../../internal/numbers.js";import{declaredDefaultConverter,literalSetConverter,omittedEmptyStringConverter,blankNumberConverter}from"../../../internal/converters.js";import{PositioningStrategyState,positioningStrategyConverter,resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{activateNonmodalOverlay,composedContains}from"../../../internal/nonmodal-overlay-manager.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{subscribeInheritedAttributes}from"../../../internal/inherited-attribute-hub.js";import{accessibleTextRecordsMatter,bindAccessibleTextObserver,labelReferenceRecordsMatter,composedAccessibilityTextResult}from"../../../internal/accessibility-visibility.js";import{applyOverlayArrow}from"./overlay-arrow.js";import{normalizeVirtualRect,OverlayAnchorIdentity,OverlayDelayTimer,resolveOverlayAnchor,resolveOverlayAccessibleTrigger,resolveOverlayInteractionTrigger}from"../../../internal/overlay-shared.js";import{tooltipStyles}from"./overlay.styles.js";import{LYRA_DEFAULT_popover}from"../../../internal/default-strings/overlays.generated.js";const DEFAULT_SHOW_DELAY=150,DEFAULT_HIDE_DELAY=0,DEFAULT_DISTANCE=8,MAX_SHADOW_CONTENT_SCAN_FRAMES=4;function safelyComposedContains(container,candidate){try{return candidate?.nodeType===1&&composedContains(container,candidate)}catch{return!1}}const TOOLTIP_LABEL_MODE=literalSetConverter(["description","label","none"],"description"),BLANK_TEXT=/^[ \t\n\f\r]*$/;function isBlankText(node){return node.nodeType===Node.TEXT_NODE&&BLANK_TEXT.test(node.textContent??"")}class LyraTooltip extends LyraElement{constructor(){super(...arguments),this._open=!1,this.trigger="hover focus",this._labelMode="description",this.manual=!1,this.showDelay=150,this.hideDelay=0,this.placement="top",this.distance=8,this.skidding=0,this._for="",this.anchor=null,this.disabled=!1,this.strategy=new PositioningStrategyState(this),this.topLayer=!1,this.withoutArrow=!1,this.arrowPlacement="anchor",this.arrowPadding=0,this.fullWidthTrigger=!1,this.content="",this.accessibleLabel="",this.namedTriggerMode=!0,this.interactiveContent=!1,this.blankContentAssignment=!1,this.resolvedSide="top",this.anchorPositioned=!1,this.popupHidden=!0,this.directionChanged=!1,this.anchorIdentity=new OverlayAnchorIdentity,this.placementPending=!1,this.delayTimer=new OverlayDelayTimer,this.restoreFocusOnClose=!1,this.suppressTriggerFocusOpen=!1,this.openedByPointer=!1,this.tooltipId=nextId("tooltip"),this.descriptionId=nextId("tooltip-description"),this.focusDescribesTrigger=!1,this.triggerSyncGeneration=0,this.contentSlotListeners=new Set,this.shadowContentScanAttempts=0,this.disclosure=new AnchoredDisclosureController({host:this,isOpen:()=>this._open,setOpen:value=>this.applyOpenState(value),emit:name=>name==="lr-show"||name==="lr-hide"?this.emit(name,null,{cancelable:!0}).defaultPrevented:this.emit(name).defaultPrevented,popup:()=>this.renderRoot.querySelector('[part~="popup"]'),readyToShow:async isCurrent=>{const positioned=await waitForDeferredPlacement(()=>this.cleanup);return isCurrent()&&positioned&&this.anchorPositioned&&!this.placementPending},animate:(showing,popup)=>animateRegistered(this,popup,`tooltip.${showing?"show":"hide"}`,this.effectiveDirection,{keyframes:showing?[{opacity:0},{opacity:1}]:[{opacity:1},{opacity:0}],durationProperties:["--lr-transition-fast","--lr-duration-fast"],easingProperties:["--lr-easing-standard"]}),afterHide:()=>{this.popupHidden=!0}}),this.onTriggerSlotChange=event=>{this.syncNamedTriggerMode();const slot=event.target;this.slottedTriggerElement=slot.assignedElements({flatten:!0})[0],this.syncInteractionTrigger()},this.onEnter=event=>{if(!this.disabled){if(event.type==="focusin"){if(this.updateInteractiveContent(),this.opensOn("focus")&&(this.focusDescribesTrigger=!0),this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot),this.syncTriggerA11y(),this.suppressTriggerFocusOpen||!this.opensOn("focus")||!isKeyboardFocusEvent(event))return}else{if(this.syncTriggerA11y(),!this.opensOn("hover"))return;this.openedByPointer=!0}this.requestTransition(!0)}},this.onLeave=event=>{if(event.type==="focusout"?!this.opensOn("focus"):!this.opensOn("hover"))return;const next=event.relatedTarget;next!==null&&next.nodeType===1&&this.triggerElement&&composedContains(this.triggerElement,next)||(event.type==="focusout"&&(this.focusDescribesTrigger=!1,this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot),this.syncTriggerA11y()),!(this.interactiveContent&&(this.isPopupTarget(next)||this.retainsPopupInteraction(event)))&&this.requestTransition(!1))},this.onTriggerClick=()=>{this.disabled||this.opensOn("click")&&(this.syncTriggerA11y(),this._open?this.hide():this.show())},this.onPopupEnter=()=>{!this.interactiveContent||this.isManual||(this.cancelPendingTransition(),this.show())},this.onPopupLeave=event=>{if(!this.interactiveContent||this.isManual||this.retainsPopupInteraction(event))return;const next=event.relatedTarget;next!==null&&next.nodeType===1&&(this.triggerElement&&composedContains(this.triggerElement,next)||this.isPopupTarget(next))||this.requestTransition(!1)},this.onContentSlotChange=event=>{event.target?.localName==="slot"&&this.updateInteractiveContent()}}static{this.defaultStrings={...super.defaultStrings,popover:LYRA_DEFAULT_popover}}static{this.styles=[LyraElement.styles,tooltipStyles]}get open(){return this._open}set open(next){const normalized=!!next;if(normalized||this.cancelPendingTransition(),normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.hide()}}get labelMode(){return this._labelMode}set labelMode(next){this._labelMode=TOOLTIP_LABEL_MODE.normalize(next)}get for(){return this._for}set for(next){this._for=next??""}get positioningStrategy(){return this.strategy.value}set positioningStrategy(next){this.strategy.set(next)}get hoist(){return this.strategy.hoist}set hoist(next){this.strategy.setHoist(next)}get rendersArrow(){return!this.withoutArrow}get activeContentSlot(){const selector=this.namedTriggerMode?'[part~="body"] slot:not([name])':'[part~="body"] slot[name="content"]';return(this.renderRoot??this.shadowRoot)?.querySelector(selector)??null}syncNamedTriggerMode(schedule=!0){const children=Array.from(this.children),hasNamedTrigger=children.some(child=>child.getAttribute("slot")==="trigger"),hasShoelaceContent=(this.content??"").length>0||children.some(child=>child.getAttribute("slot")==="content"),next=hasNamedTrigger||!hasShoelaceContent;if(next===this.namedTriggerMode)return;const old=this.namedTriggerMode;this.namedTriggerMode=next,schedule&&this.hasUpdated&&this.requestUpdate("namedTriggerMode",old)}get triggerKeywords(){return new Set(String(this.trigger??"").trim().split(/\s+/).filter(Boolean))}get isManual(){const keywords=this.triggerKeywords;return this.manual||keywords.size===0||keywords.has("manual")}opensOn(keyword){return!this.isManual&&this.triggerKeywords.has(keyword)}willUpdate(changed){super.willUpdate(changed);const direction=this.effectiveDirection;this.directionChanged=direction!==this.positioningDirection,this.positioningDirection=direction,this.syncNamedTriggerMode(!1),(changed.has("manual")||changed.has("trigger"))&&this.isManual&&this.cancelPendingTransition(),(changed.has("manual")||changed.has("trigger"))&&this.focusDescribesTrigger&&!this.opensOn("focus")&&(this.focusDescribesTrigger=!1,this.syncTriggerA11y()),changed.has("disabled")&&this.disabled&&(this.cancelPendingTransition(),this.focusDescribesTrigger&&(this.focusDescribesTrigger=!1,this.syncTriggerA11y()),this._open&&(this.hasUpdated?this.hide():this.applyOpenState(!1))),this.anchorIdentity.lostAnchorProperty(changed,this.anchor)&&this.open&&!this.resolveAnchor()&&this.forceClose(),changed.has("showDelay")&&this.delayTimer.pendingDirection==="show"&&this.requestTransition(!0),changed.has("hideDelay")&&this.delayTimer.pendingDirection==="hide"&&this.requestTransition(!1),changed.has("for")&&this.syncInteractionTrigger(),changed.has("open")&&!this.open&&(this.anchorPositioned=!1),changed.has("open")&&this.open&&(this.popupHidden=!1),changed.has("open")&&this.open&&this.hasUpdated&&this.isConnected&&this.updateInteractiveContent(),changed.has("labelMode")&&this.hasUpdated&&this.isConnected&&(this.contentNeeded?this.updateInteractiveContent():this.observeStructureOnly()),(changed.has("anchor")||changed.has("for"))&&(this.anchorPositioned=!1)}updated(changed){if(super.updated(changed),(changed.has("for")||changed.has("anchor")||changed.has("open"))&&this.syncAnchorIdentityObservation(),this.directionChanged||changed.has("open")||changed.has("placement")||changed.has("distance")||changed.has("skidding")||changed.has("for")||changed.has("anchor")||changed.has("positioningStrategy")||changed.has("topLayer")||changed.has("arrow")||changed.has("withoutArrow")||changed.has("arrowPlacement")||changed.has("arrowPadding")||changed.has("interactiveContent")){if(this.cleanup?.(),this.cleanup=void 0,this.open&&this.isConnected&&this.position(),changed.has("open"))if(this.open)changed.get("open")===void 0?this.updateComplete.then(()=>{this.open&&this.isConnected&&this.updateInteractiveContent()}):this.updateInteractiveContent(),this.isConnected&&this.requiresOverlayManager&&this.activateTooltipOverlay();else{this.positionedAnchor=void 0;const restoreFocus=this.restoreFocusOnClose;this.suppressTriggerFocusOpen=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.suppressTriggerFocusOpen=!1}this.overlayHandle=void 0,this.restoreFocusOnClose=!1,this.virtualAnchor=void 0,this.returnFocusTo=void 0,this.syncInteractionTrigger(),this.contentSnapshot&&this.bindContentObservation(this.contentSnapshot)}else changed.has("interactiveContent")&&this.open&&this.isConnected&&this.activateTooltipOverlay();this.syncTriggerA11y()}changed.has("labelMode")&&this.syncTriggerA11y(),(changed.has("content")||changed.has("accessibleLabel"))&&this.updateDescriptionProxy()}connectedCallback(){super.connectedCallback();const triggerSyncGeneration=++this.triggerSyncGeneration,triggerSyncDocument=this.ownerDocument;this.syncAnchorIdentityObservation(),this.ensureDescriptionProxy(),this.contentObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;this.contentObserver=MutationObserverCtor?new MutationObserverCtor((records,observer)=>{if(!this.contentNeeded){this.syncNamedTriggerMode();return}accessibleTextRecordsMatter(observer,records)&&(this.syncNamedTriggerMode(),this.updateInteractiveContent())}):void 0,this.updateInteractiveContent(),this.syncInteractionTrigger(),this.updateComplete.then(()=>{if(triggerSyncGeneration!==this.triggerSyncGeneration||!this.isConnected||this.ownerDocument!==triggerSyncDocument)return;const slot=this.renderRoot.querySelector('[part="trigger"] > slot');this.slottedTriggerElement=slot?.assignedElements({flatten:!0})[0],this.syncInteractionTrigger()}),this.hasUpdated&&this.open&&(this.popupHidden=!1,this.position(),this.requiresOverlayManager&&(this.overlayHandle?.isActive()?this.overlayHandle.resume():this.activateTooltipOverlay()))}disconnectedCallback(){this.triggerSyncGeneration++,this.anchorIdentity.stop(),this.cancelPendingTransition(),this.cleanup?.(),this.cleanup=void 0,this.overlayHandle?.suspend(),this.triggerElement&&this.unbindTrigger(this.triggerElement),this.releaseTriggerA11y(),this.focusDescribesTrigger=!1,this.triggerElement=void 0,this.contentObserver?.disconnect(),this.contentObserver=void 0,this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.clearContentSlotListeners(),this.cancelShadowContentScan(),this.disclosure.reset(),this.popupHidden=!0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.triggerSyncGeneration++,this.anchorIdentity.stop(),this.cancelPendingTransition(),this.cancelShadowContentScan(),this.contentObserver?.disconnect(),this.contentObserver=void 0,this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.clearContentSlotListeners(),this.releaseTriggerA11y()}syncAnchorIdentityObservation(){this.anchorIdentity.stop();const directAnchor=this.open?this.anchor??void 0:void 0;this.anchorIdentity.observe(this,directAnchor,this.for,()=>this.anchor,directAnchorRemoved=>{if((this.resolveInteractionTrigger()!==this.triggerElement||this.open||this.focusDescribesTrigger)&&this.syncInteractionTrigger(),!this.open)return;const nextAnchor=this.resolveAnchor();if(directAnchorRemoved&&!nextAnchor){this.forceClose();return}nextAnchor!==this.positionedAnchor&&this.position()})}resolveInteractionTrigger(){return resolveOverlayInteractionTrigger(this,this.virtualAnchor,this.slottedTriggerElement,this.for)}syncInteractionTrigger(){const next=this.resolveInteractionTrigger();this.adoptTrigger(next)}activateTooltipOverlay(){if(!this.isConnected)return;const restoreFocusTarget=this.virtualAnchor?this.returnFocusTo??null:this.accessibleTrigger;if(this.overlayHandle?.isActive()){this.overlayHandle.updateRestoreFocusTo(restoreFocusTarget);return}this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part~="popup"]'),onEscape:()=>{this.hide({restoreFocus:this.shouldRestoreFocusAfterEscape()})},restoreFocusTo:restoreFocusTarget}),this.overlayHandle.focusAutofocus()}shouldRestoreFocusAfterEscape(){if(this.virtualAnchor)return this.returnFocusTo!==void 0;const active=deepActiveElementIn(this.ownerDocument);return safelyComposedContains(this,active)}get requiresOverlayManager(){return this.open}showAt(rect,options){const normalizedRect=normalizeVirtualRect(rect);if(!normalizedRect)return;const previousAnchor=this.virtualAnchor,previousReturnFocusTo=this.returnFocusTo;if(this.virtualAnchor=virtualAnchorFromRect(normalizedRect),this.returnFocusTo=options?.returnFocusTo,this.syncInteractionTrigger(),this.open){this.activateTooltipOverlay(),this.position();return}this.show(),!this.open&&(this.virtualAnchor=previousAnchor,this.returnFocusTo=previousReturnFocusTo,this.syncInteractionTrigger())}show(){return this.cancelPendingTransition(),this.disabled?Promise.resolve():this.disclosure.show()}hide(options){return this.cancelPendingTransition(),this.disclosure.hide(()=>{options?.restoreFocus&&(this.restoreFocusOnClose=!0)})}forceClose(){return this.cancelPendingTransition(),this.disclosure.forceClose()}applyOpenState(next){const old=this._open;this._open=next,next||(this.cancelShadowContentScan(),this.placementPending=!1),next||(this.openedByPointer=!1),this.requestUpdate("open",old)}resolveAnchor(){return resolveOverlayAnchor(this,{virtualAnchor:this.virtualAnchor,anchor:this.anchor,for:this.for,trigger:this.triggerElement})}position(){this.cleanup?.(),this.cleanup=void 0;const popup=this.renderRoot.querySelector('[part~="popup"]'),arrowElement=this.renderRoot.querySelector('[part~="arrow"]'),anchor=this.resolveAnchor();if(!this.open||!anchor||!popup){this.positionedAnchor=void 0,this.anchorPositioned=!1,this.placementPending=!1;return}if(anchor!==this.positionedAnchor&&(this.anchorPositioned=!1),this.open&&anchor&&popup){const arrowPadding=Math.max(0,finiteNumber(this.arrowPadding,0));this.placementPending=!0,this.placedTopLayer=syncTopLayerRelease(popup,this.placedTopLayer,this.topLayer);const operation=place(anchor,popup,{placement:rtlAwarePlacement(this.placement,this),...topLayerPlacement(this.topLayer,resolveEffectivePositioningStrategy(this,this.strategy.authored,"absolute")),offset:finiteNumber(this.distance,DEFAULT_DISTANCE),skidding:finiteNumber(this.skidding,0),arrow:this.rendersArrow&&arrowElement?arrowElement:void 0,arrowPadding,onPlaced:({placement,arrow})=>{this.placementPending=!1,this.positionedAnchor=anchor,this.anchorPositioned=!0;const side=applyOverlayArrow(arrowElement,{placement,coords:arrow,enabled:this.rendersArrow,arrowPlacement:this.arrowPlacement,arrowPadding,rtl:this.effectiveDirection==="rtl",sizeProperty:"--arrow-size",fallbackSizeProperty:"--lr-tooltip-arrow-size"});side!==this.resolvedSide&&(this.resolvedSide=side)}});this.cleanup=operation,operation.ready.then(positioned=>{!positioned&&this.cleanup===operation&&this.open&&(this.restoreFocusOnClose=safelyComposedContains(this,deepActiveElementIn(this.ownerDocument)),this.forceClose())})}}syncTriggerA11y(){const trigger=this.triggerElement??null,proxy=this.descriptionProxy,contribution={labels:proxy&&this.labelMode==="label"?[proxy]:[],descriptions:proxy&&this.labelMode==="description"&&(this.open||this.focusDescribesTrigger)?[proxy]:[]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution);const accessibleTrigger=this.accessibleTrigger;this.observeTriggerTarget(contribution.labels.length||contribution.descriptions.length?trigger:null,accessibleTrigger);const distinctAccessibleTrigger=accessibleTrigger!==trigger?accessibleTrigger:null;this.accessibleTriggerAria?this.accessibleTriggerAria.update(distinctAccessibleTrigger,contribution):this.accessibleTriggerAria=acquireAriaOwnership(distinctAccessibleTrigger,contribution),this.overlayHandle?.isActive()&&!this.virtualAnchor&&this.overlayHandle.updateRestoreFocusTo(accessibleTrigger)}observeTriggerTarget(trigger,control){if(this.triggerTargetObserver?.disconnect(),!trigger||!this.isConnected){this.triggerTargetUpgrades?.disconnect();return}this.triggerTargetUpgrades??=new CustomElementUpgradeObserver(()=>this.syncTriggerA11y()),this.triggerTargetUpgrades.observeElement(trigger);const Observer=this.ownerDocument.defaultView?.MutationObserver;if(!Observer)return;this.triggerTargetObserver??=new Observer(()=>this.syncTriggerA11y());const options={childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-disabled","aria-hidden","class","disabled","hidden","href","inert","name","role","slot","style","tabindex","type"]};this.triggerTargetObserver.observe(trigger,options);for(let node=control;node&&(node.shadowRoot&&this.triggerTargetObserver.observe(node.shadowRoot,options),node!==trigger);node=composedParentElement(node));}get accessibleTrigger(){return this.triggerElement?this.labelMode==="label"?resolveOverlayAccessibleTrigger(this.triggerElement):resolveAccessibleTrigger(this.triggerElement):null}releaseTriggerA11y(){this.triggerTargetObserver?.disconnect(),this.triggerTargetObserver=void 0,this.triggerTargetUpgrades?.disconnect(),this.triggerTargetUpgrades=void 0,this.accessibleTriggerAria?.release(),this.accessibleTriggerAria=void 0,this.triggerAria?.release(),this.triggerAria=void 0}requestTransition(next){if(this.cancelPendingTransition(),this.disabled)return;const delay=this.interactionDelay(next);if(delay<=0){next?this.show():this.hide();return}const view=this.ownerDocument.defaultView;view&&this.delayTimer.schedule(view,delay,next?"show":"hide",()=>{next?this.show():this.hide()})}interactionDelay(showing){const value=showing?this.showDelay:this.hideDelay,fallback=showing?DEFAULT_SHOW_DELAY:DEFAULT_HIDE_DELAY,attribute=showing?"show-delay":"hide-delay";if(this.hasAttribute(attribute)||value!==fallback)return finiteDuration(value,fallback);const property2=showing?"--show-delay":"--hide-delay",raw=this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue(property2).trim()??"",token=parseCssTimeToken(raw);return token&&!token.rest?finiteDuration(token.ms,fallback):fallback}cancelPendingTransition(){this.delayTimer.cancel()}bindTrigger(trigger){trigger.addEventListener("mouseenter",this.onEnter),trigger.addEventListener("mouseleave",this.onLeave),trigger.addEventListener("focusin",this.onEnter),trigger.addEventListener("focusout",this.onLeave),trigger.addEventListener("click",this.onTriggerClick)}unbindTrigger(trigger){trigger.removeEventListener("mouseenter",this.onEnter),trigger.removeEventListener("mouseleave",this.onLeave),trigger.removeEventListener("focusin",this.onEnter),trigger.removeEventListener("focusout",this.onLeave),trigger.removeEventListener("click",this.onTriggerClick),this.focusDescribesTrigger=!1}isTriggerHeld(trigger){try{if(trigger.matches(":hover"))return!0}catch{}const active=deepActiveElementIn(trigger.ownerDocument);return safelyComposedContains(trigger,active)}adoptTrigger(next){if(next===this.triggerElement){this.syncTriggerA11y();return}const hadTrigger=this.triggerElement!==void 0;if(this.cancelPendingTransition(),this.triggerElement&&this.unbindTrigger(this.triggerElement),this.triggerElement=next,!this.triggerElement){this.syncTriggerA11y(),hadTrigger&&this.open&&!this.resolveAnchor()&&this.forceClose();return}this.bindTrigger(this.triggerElement),this.syncTriggerA11y(),hadTrigger&&this._open&&this.openedByPointer&&!this.isTriggerHeld(this.triggerElement)&&this.forceClose(),this.open&&this.position(),this.open&&this.interactiveContent&&this.activateTooltipOverlay()}retainsPopupInteraction(event){return event.type==="mouseleave"?this.isPopupTarget(deepActiveElementIn(this.ownerDocument)):this.opensOn("hover")&&(this.triggerElement?.matches(":hover")===!0||this.renderRoot.querySelector('[part~="popup"]:hover')!==null)}isPopupTarget(target){if(target===null||target.nodeType!==1)return!1;const element=target,slot=this.activeContentSlot;return this.renderRoot.querySelector('[part~="popup"]')?.contains(element)===!0||slot?.assignedElements({flatten:!0}).some(root=>composedContains(root,element))===!0}clearContentSlotListeners(){for(const slot of this.contentSlotListeners)slot.removeEventListener("slotchange",this.onContentSlotChange);this.contentSlotListeners.clear()}syncContentSlotListeners(slots){const activeSlot=this.activeContentSlot;for(const slot of this.contentSlotListeners)slots.has(slot)&&slot!==activeSlot||(slot.removeEventListener("slotchange",this.onContentSlotChange),this.contentSlotListeners.delete(slot));for(const slot of slots)slot===activeSlot||this.contentSlotListeners.has(slot)||(slot.addEventListener("slotchange",this.onContentSlotChange),this.contentSlotListeners.add(slot))}inspectContent(){const snapshot={actionable:!1,assigned:!1,blank:!1,awaitingShadowRoot:!1,labelReferenceRoots:new Set,labelReferenceIds:new Set,referencedElements:new Set,text:"",externalRoots:new Set,shadowRoots:new Set,forwardingSlots:new Set,composedAncestors:new Set},activeSlot=this.activeContentSlot;if(!activeSlot)return snapshot;const renderRoot=this.renderRoot??this.shadowRoot,assignedNodes=activeSlot.assignedNodes();if(snapshot.assigned=assignedNodes.some(node=>!isBlankText(node)),snapshot.blank=assignedNodes.length>0&&!snapshot.assigned,!snapshot.assigned)return snapshot;const popup=renderRoot?.querySelector('[part~="popup"]'),bypassClosedVisibility=popup?.hasAttribute("data-hidden")===!0||this.placementPending,previousVisibility=popup?.style.getPropertyValue("visibility")??"",previousVisibilityPriority=popup?.style.getPropertyPriority("visibility")??"",previousHidden=popup?.hidden??!1;if(popup&&bypassClosedVisibility){const hostVisibility=this.ownerDocument.defaultView?.getComputedStyle(this).visibility??"visible";popup.style.setProperty("visibility",hostVisibility),popup.hidden=!1}try{const visitedContentElements=new Set,elementStates=new Map,accessibilityText=composedAccessibilityTextResult(activeSlot,{shouldPruneNode:node=>{if(node.getRootNode()!==renderRoot&&!this.contains(node)&&snapshot.externalRoots.add(node),node.nodeType!==1)return!1;const element=node;return visitedContentElements.add(element),element.localName==="slot"&&snapshot.forwardingSlots.add(element),element.shadowRoot?snapshot.shadowRoots.add(element.shadowRoot):element.localName.includes("-")&&(snapshot.awaitingShadowRoot=!0),!1},onElementState:(element,state2)=>elementStates.set(element,state2)});for(const element of elementStates.keys())!visitedContentElements.has(element)&&element!==this&&snapshot.composedAncestors.add(element);for(const element of visitedContentElements){const imageMapElement=element.localName==="map"||element.localName==="area";if(imageMapElement){const image=imageMapImageFor(element);image&&snapshot.externalRoots.add(image)}if(!isActionableElement(element))continue;const state2=imageMapElement?void 0:elementStates.get(element);if(state2?.subtreeExcluded??isAccessibilitySubtreeExcluded(element))continue;(state2?.visibilityHidden??isAccessibilityVisibilityHidden(element))||(snapshot.actionable=!0)}snapshot.text=accessibilityText.text.replace(/\s+/g," ").trim();for(const root of accessibilityText.labelReferenceRoots)snapshot.labelReferenceRoots.add(root);for(const id of accessibilityText.labelReferenceIds)snapshot.labelReferenceIds.add(id);for(const reference of accessibilityText.referencedElements)snapshot.referencedElements.add(reference),snapshot.externalRoots.add(reference)}finally{popup&&bypassClosedVisibility&&(previousVisibility?popup.style.setProperty("visibility",previousVisibility,previousVisibilityPriority):popup.style.removeProperty("visibility"),popup.hidden=previousHidden)}return snapshot}observeContentNode(node){if(this.contentObserver){if(node.nodeType===3){this.contentObserver.observe(node,{characterData:!0});return}node.nodeType!==1&&node.nodeType!==11||this.contentObserver.observe(node,{attributes:!0,attributeFilter:["aria-hidden","aria-label","aria-labelledby","alt","class","contenteditable","hidden","href","inert","name","open","role","slot","style","tabindex","usemap"],childList:!0,characterData:!0,subtree:!0})}}get contentNeeded(){return this.open||this.focusDescribesTrigger||this.labelMode==="label"}observeStructureOnly(){this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.cancelShadowContentScan();const observer=this.contentObserver;observer&&(observer.disconnect(),observer.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}bindContentObservation(snapshot){if(!this.contentNeeded){this.observeStructureOnly();return}if(this.stopLabelReferenceIdentityObservation?.(),this.stopLabelReferenceIdentityObservation=void 0,this.isConnected&&snapshot.labelReferenceRoots.size>0){const Observer=this.ownerDocument.defaultView?.MutationObserver,cleanups=[...snapshot.labelReferenceRoots].map(root=>subscribeInheritedAttributes(root,Observer,{attributes:["id"],childList:!0,changed:records=>{labelReferenceRecordsMatter(records,snapshot.labelReferenceIds,snapshot.referencedElements)&&this.updateInteractiveContent()}}));this.stopLabelReferenceIdentityObservation=()=>{for(const cleanup of cleanups)cleanup?.()}}if(!this.contentObserver)return;const pendingRecords=this.contentObserver.takeRecords(),pendingMatter=pendingRecords.length>0&&accessibleTextRecordsMatter(this.contentObserver,pendingRecords),observer=this.contentObserver;if(!snapshot.assigned&&!snapshot.blank){observer.disconnect(),observer.observe(this,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0});return}bindAccessibleTextObserver(observer,this),pendingMatter&&queueMicrotask(()=>{this.isConnected&&this.contentObserver===observer&&this.updateInteractiveContent()}),this.observeContentNode(this);for(const root of snapshot.externalRoots)this.observeContentNode(root);for(const root of snapshot.shadowRoots)this.observeContentNode(root)}updateInteractiveContent(fromShadowContentScan=!1){fromShadowContentScan||(this.shadowContentScanAttempts=0);const snapshot=this.inspectContent();this.contentSnapshot=snapshot,this.interactiveContent=snapshot.actionable,this.blankContentAssignment=snapshot.blank,this.syncContentSlotListeners(snapshot.forwardingSlots),this.bindContentObservation(snapshot),this.scheduleShadowContentScan(snapshot.awaitingShadowRoot),this.updateDescriptionProxy()}scheduleShadowContentScan(awaitingShadowRoot){if(this.cancelShadowContentScan(!1),!awaitingShadowRoot||!this.open||!this.isConnected||this.shadowContentScanAttempts>=MAX_SHADOW_CONTENT_SCAN_FRAMES)return;const view=this.ownerDocument.defaultView;view&&(this.shadowContentScanView=view,this.shadowContentScanFrame=view.requestAnimationFrame(()=>{this.shadowContentScanFrame=void 0,this.shadowContentScanView=void 0,this.shadowContentScanAttempts++,this.updateInteractiveContent(!0)}))}cancelShadowContentScan(resetAttempts=!0){this.shadowContentScanFrame!==void 0&&this.shadowContentScanView?.cancelAnimationFrame(this.shadowContentScanFrame),this.shadowContentScanFrame=void 0,this.shadowContentScanView=void 0,resetAttempts&&(this.shadowContentScanAttempts=0)}ensureDescriptionProxy(){this.descriptionProxy||(this.descriptionProxy=this.ownerDocument.createElement("span"),this.descriptionProxy.id=this.descriptionId,this.descriptionProxy.slot="__lr-tooltip-description",this.descriptionProxy.hidden=!0,this.descriptionProxy.dataset.lyraTooltipDescription=""),this.updateDescriptionProxy()}updateDescriptionProxy(){if(!this.descriptionProxy)return;this.descriptionProxy.parentNode!==this&&this.append(this.descriptionProxy);const hostLabel=this.getAttribute("aria-label"),visibleContent=this.contentSnapshot?.text??"",hasAssignment=this.contentSnapshot?.assigned??!1,description=hostLabel!==null?hostLabel.trim():(this.accessibleLabel||visibleContent||(hasAssignment?"":this.content??"")).trim();this.descriptionProxy.textContent!==description&&(this.descriptionProxy.textContent=description)}render(){const hostLabel=this.getAttribute("aria-label"),propertyLabel=this.accessibleLabel??"",hasExplicitLabel=hostLabel!==null||propertyLabel.length>0,label=hostLabel!==null?hostLabel:propertyLabel,popupLabel=this.interactiveContent?hasExplicitLabel?label:this.localize("popover"):hasExplicitLabel?label:nothing;return html`
|
|
2
2
|
<span part="trigger">
|
|
3
3
|
${this.namedTriggerMode?html`<slot name="trigger" @slotchange=${this.onTriggerSlotChange}></slot>`:html`<slot @slotchange=${this.onTriggerSlotChange}></slot>`}
|
|
4
4
|
</span>
|
|
5
5
|
<slot name="__lr-tooltip-description" hidden></slot>
|
|
6
|
-
<div id=${this.tooltipId} part="popup base tooltip base__popup" role=${this.interactiveContent?"dialog":"tooltip"} aria-label=${popupLabel} ?hidden=${this.popupHidden} ?data-hidden=${!this.open||!this.anchorPositioned} ?data-has-arrow=${this.rendersArrow} @mouseenter=${this.onPopupEnter} @mouseleave=${this.onPopupLeave} @focusin=${this.onPopupEnter} @focusout=${this.onPopupLeave}>
|
|
6
|
+
<div id=${this.tooltipId} part="popup base tooltip base__popup tooltip__popup" role=${this.interactiveContent?"dialog":"tooltip"} aria-label=${popupLabel} ?hidden=${this.popupHidden} ?data-hidden=${!this.open||!this.anchorPositioned} ?data-has-arrow=${this.rendersArrow} @mouseenter=${this.onPopupEnter} @mouseleave=${this.onPopupLeave} @focusin=${this.onPopupEnter} @focusout=${this.onPopupLeave}>
|
|
7
7
|
<span part="body">
|
|
8
8
|
${this.namedTriggerMode?html`<slot @slotchange=${this.onContentSlotChange}>${this.content}</slot>`:html`<slot name="content" @slotchange=${this.onContentSlotChange}>${this.content}</slot>`}${this.blankContentAssignment?this.content:nothing}
|
|
9
9
|
</span>
|
|
10
|
-
${this.rendersArrow?html`<span part="arrow base__arrow arrow-${this.resolvedSide}"></span>`:nothing}
|
|
10
|
+
${this.rendersArrow?html`<span part="arrow base__arrow tooltip__arrow arrow-${this.resolvedSide}"></span>`:nothing}
|
|
11
11
|
</div>
|
|
12
|
-
`}}__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"open",null),__decorate([property({converter:declaredDefaultConverter("hover focus")})],LyraTooltip.prototype,"trigger",void 0),__decorate([property({attribute:"label-mode",converter:TOOLTIP_LABEL_MODE})],LyraTooltip.prototype,"labelMode",null),__decorate([property({type:Boolean})],LyraTooltip.prototype,"manual",void 0),__decorate([property({converter:blankNumberConverter(150),attribute:"show-delay"})],LyraTooltip.prototype,"showDelay",void 0),__decorate([property({converter:blankNumberConverter(0),attribute:"hide-delay"})],LyraTooltip.prototype,"hideDelay",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("top")})],LyraTooltip.prototype,"placement",void 0),__decorate([property({converter:blankNumberConverter(8)})],LyraTooltip.prototype,"distance",void 0),__decorate([property({converter:blankNumberConverter(0)})],LyraTooltip.prototype,"skidding",void 0),__decorate([property({reflect:!0,converter:omittedEmptyStringConverter})],LyraTooltip.prototype,"for",null),__decorate([property({attribute:!1})],LyraTooltip.prototype,"anchor",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"disabled",void 0),__decorate([property({attribute:"positioning-strategy",reflect:!0,converter:positioningStrategyConverter})],LyraTooltip.prototype,"positioningStrategy",null),__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"hoist",null),__decorate([property({type:Boolean,attribute:"top-layer",reflect:!0})],LyraTooltip.prototype,"topLayer",void 0),__decorate([property({type:Boolean,attribute:"without-arrow",reflect:!0})],LyraTooltip.prototype,"withoutArrow",void 0),__decorate([property({attribute:"arrow-placement"})],LyraTooltip.prototype,"arrowPlacement",void 0),__decorate([property({converter:blankNumberConverter(0),attribute:"arrow-padding"})],LyraTooltip.prototype,"arrowPadding",void 0),__decorate([property()],LyraTooltip.prototype,"content",void 0),__decorate([property({attribute:"aria-label"})],LyraTooltip.prototype,"accessibleLabel",void 0),__decorate([state()],LyraTooltip.prototype,"interactiveContent",void 0),__decorate([state()],LyraTooltip.prototype,"blankContentAssignment",void 0),__decorate([state()],LyraTooltip.prototype,"resolvedSide",void 0),__decorate([state()],LyraTooltip.prototype,"anchorPositioned",void 0),__decorate([state()],LyraTooltip.prototype,"popupHidden",void 0);export{LyraTooltip};
|
|
12
|
+
`}}__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"open",null),__decorate([property({converter:declaredDefaultConverter("hover focus")})],LyraTooltip.prototype,"trigger",void 0),__decorate([property({attribute:"label-mode",converter:TOOLTIP_LABEL_MODE})],LyraTooltip.prototype,"labelMode",null),__decorate([property({type:Boolean})],LyraTooltip.prototype,"manual",void 0),__decorate([property({converter:blankNumberConverter(150),attribute:"show-delay"})],LyraTooltip.prototype,"showDelay",void 0),__decorate([property({converter:blankNumberConverter(0),attribute:"hide-delay"})],LyraTooltip.prototype,"hideDelay",void 0),__decorate([property({reflect:!0,converter:declaredDefaultConverter("top")})],LyraTooltip.prototype,"placement",void 0),__decorate([property({converter:blankNumberConverter(8)})],LyraTooltip.prototype,"distance",void 0),__decorate([property({converter:blankNumberConverter(0)})],LyraTooltip.prototype,"skidding",void 0),__decorate([property({reflect:!0,converter:omittedEmptyStringConverter})],LyraTooltip.prototype,"for",null),__decorate([property({attribute:!1})],LyraTooltip.prototype,"anchor",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"disabled",void 0),__decorate([property({attribute:"positioning-strategy",reflect:!0,converter:positioningStrategyConverter})],LyraTooltip.prototype,"positioningStrategy",null),__decorate([property({type:Boolean,reflect:!0})],LyraTooltip.prototype,"hoist",null),__decorate([property({type:Boolean,attribute:"top-layer",reflect:!0})],LyraTooltip.prototype,"topLayer",void 0),__decorate([property({type:Boolean,attribute:"without-arrow",reflect:!0})],LyraTooltip.prototype,"withoutArrow",void 0),__decorate([property({attribute:"arrow-placement"})],LyraTooltip.prototype,"arrowPlacement",void 0),__decorate([property({converter:blankNumberConverter(0),attribute:"arrow-padding"})],LyraTooltip.prototype,"arrowPadding",void 0),__decorate([property({type:Boolean,attribute:"full-width-trigger",reflect:!0})],LyraTooltip.prototype,"fullWidthTrigger",void 0),__decorate([property()],LyraTooltip.prototype,"content",void 0),__decorate([property({attribute:"aria-label"})],LyraTooltip.prototype,"accessibleLabel",void 0),__decorate([state()],LyraTooltip.prototype,"interactiveContent",void 0),__decorate([state()],LyraTooltip.prototype,"blankContentAssignment",void 0),__decorate([state()],LyraTooltip.prototype,"resolvedSide",void 0),__decorate([state()],LyraTooltip.prototype,"anchorPositioned",void 0),__decorate([state()],LyraTooltip.prototype,"popupHidden",void 0);export{LyraTooltip};
|
|
@@ -39,6 +39,7 @@ export type LyraToastSize=LyraSize;export interface LyraToastItemEventMap{'lr-sh
|
|
|
39
39
|
* @csspart close-icon__svg - The close glyph's SVG element.
|
|
40
40
|
* @csspart progress-ring - The auto-dismiss progress ring around the close glyph.
|
|
41
41
|
* @csspart progress-ring__base - The progress ring's SVG element.
|
|
42
|
+
* @csspart progress-ring__progress-ring - Upstream name on the same SVG as `progress-ring__base`.
|
|
42
43
|
* @csspart progress-ring__indicator - The elapsed-time indicator circle.
|
|
43
44
|
* @csspart progress-ring__label - The ring's centered close-glyph container.
|
|
44
45
|
* @csspart progress-ring__track - The progress ring's background circle.
|
|
@@ -58,7 +59,7 @@ export type LyraToastSize=LyraSize;export interface LyraToastItemEventMap{'lr-sh
|
|
|
58
59
|
* follows `size` across the shared six-step ladder; an inherited or direct public value wins.
|
|
59
60
|
* @cssprop [--lr-toast-item-gap=var(--lr-space-s)] - Gap between the item icon, message, and close
|
|
60
61
|
* button. Unlike `--lr-toast-gap`, this does not affect spacing between stacked items.
|
|
61
|
-
* @cssprop [--lr-toast-item-radius=var(--lr-radius)] - Corner radius of the item surface and its
|
|
62
|
+
* @cssprop [--lr-toast-item-radius=var(--lr-radius-container)] - Corner radius of the item surface and its
|
|
62
63
|
* accent bar's inline-start corners.
|
|
63
64
|
* Pointer-state hooks are inline fallbacks, so they inherit from the item or an ancestor without
|
|
64
65
|
* recoloring the item surface or the stack.
|
|
@@ -78,7 +79,7 @@ export type LyraToastSize=LyraSize;export interface LyraToastItemEventMap{'lr-sh
|
|
|
78
79
|
* @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge of the item.
|
|
79
80
|
* @cssprop [--lr-overlay-shadow-modal=var(--lr-shadow-l)] - Shared modal elevation of the item; its
|
|
80
81
|
* default is the lower modal step, below lr-dialog's.
|
|
81
|
-
* @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, behind
|
|
82
|
+
* @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius, behind
|
|
82
83
|
* `--lr-toast-item-radius`.
|
|
83
84
|
* @cssprop --lr-icon-button-bg - Resting background of the icon-only action buttons.
|
|
84
85
|
* @cssprop --lr-icon-button-active-bg - Pressed background of the icon-only action buttons.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import{__decorate}from"tslib";import{OwnedFrame}from"../../../internal/owned-timer.js";import{waitForTransitionSettle}from"../../../internal/css-motion-time.js";import{html}from"lit";import{property,state}from"lit/decorators.js";import{keyed}from"lit/directives/keyed.js";import{composedParentElement}from"../../../internal/a11y.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{composedAccessibilityTextResult}from"../../../internal/accessibility-visibility.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{LyraElement}from"../../../internal/lyra-element.js";import{closeIcon}from"../../../internal/icons.js";import{getSegmenter}from"../../../internal/intl-cache.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{finiteDuration}from"../../../internal/numbers.js";import{composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{applyComposedFocusRepair,captureComposedFocusRepair,isActionableElement}from"../../../internal/focus-navigation.js";import{tag}from"../../../internal/prefix.js";import{normalizeSize}from"../../../internal/variants.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./toast-item.styles.js";import{TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE,toastRegionControllerFor}from"./toast-region-protocol.js";import{blankNumberConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_closeWithContext,LYRA_DEFAULT_closeWithTruncatedContext,LYRA_DEFAULT_toastContentIncomplete}from"../../../internal/default-strings/overlays.generated.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings/shared.generated.js";const CLOSE_LABEL_GRAPHEME_LIMIT=40;function isAssertiveVariant(variant){return variant==="danger"||variant==="warning"}function truncateGraphemes(value,limit,locale){if(typeof Intl.Segmenter!="function")return{snippet:value,truncated:!1};let graphemes;try{graphemes=[...getSegmenter(locale,{granularity:"grapheme"}).segment(value)].map(({segment})=>segment)}catch(error){if(!(error instanceof RangeError))throw error;graphemes=[...getSegmenter(void 0,{granularity:"grapheme"}).segment(value)].map(({segment})=>segment)}return graphemes.length>limit?{snippet:graphemes.slice(0,limit).join(""),truncated:!0}:{snippet:value,truncated:!1}}class LyraToastItem extends LyraElement{constructor(){super(...arguments),this.duration=5e3,this.size="m",this.variant="neutral",this.withIcon=!1,this.elapsedMs=0,this.startedAt=0,this.timerStarted=!1,this.showFrame=new OwnedFrame(this),this.showGeneration=0,this.showCompletionGeneration=0,this.showCompletionRunning=!1,this.showAccepted=!1,this.afterShowEmitted=!1,this.admitted=!1,this.requestingRegionAdmission=!1,this.hovering=!1,this.focused=!1,this.messageUpgrades=new CustomElementUpgradeObserver(()=>{this.isConnected&&(this.bindMessageObserverTargets(),this.recomputeMessageText())}),this.announcements=new AnnouncementSinkController(this,{eager:["polite","assertive"]}),this.lastAnnouncedMessage="",this.onMessageSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||(this.bindMessageObserverTargets(),this.recomputeMessageText())},this.hideCompletionRunning=!1,this.hideGeneration=0,this.afterHideEmitted=!1,this.messageText="",this.messageTextTruncated=!1,this.hiding=!1,this.progressRun=0,this.surfaceMounted=!1,this.interactionReady=!1,this.resumeTimer=()=>{if(this.timer!==void 0&&(this.timerOwner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0),!this.isConnected||!this.admitted||this.hiding||!this.hasAttribute("data-visible")||this.hovering||this.focused||this.ownerDocument.hidden)return;const duration=this.safeDuration;if(!isFinite(duration)||duration<=0)return;const remaining=duration-this.elapsedMs;if(remaining<=0){this.requestHide("timeout");return}const view=this.ownerDocument.defaultView;if(!view)return;this.startedAt=view.performance.now(),this.timerOwner=view;const timer=view.setTimeout(()=>{this.timer!==timer||this.timerOwner!==view||(this.timer=void 0,this.timerOwner=void 0,this.requestHide("timeout"))},remaining);this.timer=timer},this.onVisibilityChange=()=>{this.pauseTimer(),this.resumeTimer()},this.pauseTimer=()=>{if(this.timer!==void 0){const owner=this.timerOwner;owner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0,owner&&(this.elapsedMs+=owner.performance.now()-this.startedAt)}},this.onPointerEnter=()=>{this.hovering=!0,this.pauseTimer()},this.onPointerLeave=()=>{this.hovering=!1,!this.focused&&!this.hiding&&this.resumeTimer()},this.onFocusIn=event=>{const previous=event.relatedTarget;previous?.nodeType===1&&!composedContains(this,previous)&&previous.isConnected&&(this.focusReturnTarget=previous);const activeElement=deepActiveElement(this.ownerDocument);this.pendingFocusRepair=activeElement&&typeof activeElement.focus=="function"?captureComposedFocusRepair(this,activeElement)??void 0:void 0,this.focused=!0,this.pauseTimer()},this.onFocusOut=event=>{if(event.relatedTarget===null&&this.hasAttribute("data-visible")){const parent=this.parentElement,clearIfStillOwned=()=>{this.isConnected&&this.parentElement===parent&&(this.pendingFocusRepair=void 0)},view=this.ownerDocument.defaultView;view?view.queueMicrotask(clearIfStillOwned):queueMicrotask(clearIfStillOwned)}else event.relatedTarget?.nodeType===1&&!composedContains(this,event.relatedTarget)&&(this.pendingFocusRepair=void 0);this.focused=!1,!this.hovering&&!this.hiding&&this.resumeTimer()}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close,closeWithContext:LYRA_DEFAULT_closeWithContext,closeWithTruncatedContext:LYRA_DEFAULT_closeWithTruncatedContext,toastContentIncomplete:LYRA_DEFAULT_toastContentIncomplete}}static{this.styles=[LyraElement.styles,variants,styles]}get toastItemElement(){return this.renderRoot?.querySelector('[part="toast-item"]')??null}get effectiveSize(){const value=this.size;return["2xs","xs","s","m","l","xl","small","medium","large"].includes(value)?normalizeSize(value):"m"}get safeDuration(){return this.duration===1/0?1/0:finiteDuration(this.duration,5e3,0)}willUpdate(changed){super.willUpdate(changed),this.setAttribute("data-effective-size",this.effectiveSize),changed.has("duration")&&this.timerStarted&&this.admitted&&this.hasAttribute("data-visible")&&!this.hovering&&!this.focused&&(this.pauseTimer(),this.resumeTimer())}updated(changed){if(super.updated(changed),this.hasAttribute("data-visible")){const previousVariant=changed.get("variant");changed.has("variant")&&isAssertiveVariant(this.variant)!==isAssertiveVariant(previousVariant??"neutral")?this.announceMessage(!0):(changed.has("messageText")||changed.has("messageTextTruncated"))&&this.announceMessage()}this.shadowRoot?.querySelector('[part~="close-icon"] svg')?.setAttribute("part","close-icon__svg")}firstUpdated(changed){super.firstUpdated(changed),this.requestRegionAdmission(),this.admitted&&this.scheduleShow()}connectedCallback(){super.connectedCallback();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;if(this.messageObserver=MutationObserverCtor?new MutationObserverCtor(()=>{this.bindMessageObserverTargets(),this.recomputeMessageText()}):void 0,this.addEventListener("slotchange",this.onMessageSlotChange),this.ownerDocument.addEventListener("visibilitychange",this.onVisibilityChange),this.bindMessageObserverTargets(),this.hasUpdated?this.recomputeMessageText():this.seedFirstRenderState(()=>this.recomputeMessageText()),this.requestRegionAdmission(),!!this.hasUpdated){if(this.hiding){this.completeHide();return}!this.hasAttribute("data-visible")&&this.admitted?this.scheduleShow():this.admitted&&this.timerStarted&&!this.hovering&&!this.focused&&(this.completeShow(),this.resumeTimer())}}requestRegionAdmission(){const controller=toastRegionControllerFor(this);if(controller){this.requestingRegionAdmission=!0;try{controller[TOAST_REGION_ENQUEUE](this)}finally{this.requestingRegionAdmission=!1}return}const parent=this.parentElement;if(parent?.localName===tag("toast")){this.regionOwner=void 0,this.admitted=!1,this.setAttribute("data-toast-queued",""),this.cancelPendingShow(),this.pauseTimer(),this.setSurfaceAvailability(!1);const releaseUnavailableOwner=()=>{this.parentElement===parent&&!toastRegionControllerFor(this)&&this.remove()},view=this.ownerDocument.defaultView,registry=view?.customElements;registry?.get(this.localName)&&!registry.get(parent.localName)?registry.whenDefined(parent.localName).then(releaseUnavailableOwner):view?view.queueMicrotask(releaseUnavailableOwner):queueMicrotask(releaseUnavailableOwner);return}this.regionOwner=void 0,this.admitted=!0,this.removeAttribute("data-toast-queued"),this.hasAttribute("data-visible")&&(this.setSurfaceAvailability(!0),this.pendingFocusRepair&&(applyComposedFocusRepair(this.pendingFocusRepair),this.pendingFocusRepair=void 0))}[TOAST_REGION_SET_ACTIVE](owner,active){if(this.parentElement===owner){if(this.regionOwner=owner,this.admitted=active,this.toggleAttribute("data-toast-queued",!active),!active){const focusTarget=this.adjacentToastOrReturnTarget(),activeElement=deepActiveElement(this.ownerDocument),repair=this.pendingFocusRepair??(activeElement&&typeof activeElement.focus=="function"?captureComposedFocusRepair(this,focusTarget):null);this.cancelPendingShow(),this.pauseTimer(),this.setSurfaceAvailability(!1),repair&&applyComposedFocusRepair(repair,focusTarget),this.pendingFocusRepair=void 0;return}if(this.hasAttribute("data-visible")&&!this.hiding){this.setSurfaceAvailability(!0),this.pendingFocusRepair&&(applyComposedFocusRepair(this.pendingFocusRepair),this.pendingFocusRepair=void 0),!this.requestingRegionAdmission&&this.timerStarted&&!this.hovering&&!this.focused&&this.resumeTimer(),this.completeShow();return}this.isConnected&&this.hasUpdated&&!this.hiding&&!this.hasAttribute("data-visible")&&this.scheduleShow()}}[TOAST_REGION_EVICT](owner,_reason){this.regionOwner===owner&&(this.regionOwner=void 0,this.admitted=!1,this.cancelPendingShow(),this.showAccepted=!1,this.pauseTimer(),this.setSurfaceAvailability(!1),this.parentElement===owner&&this.remove())}setSurfaceAvailability(available){this.surfaceMounted=available,this.interactionReady=available;const surface=this.shadowRoot?.querySelector('[part="toast-item"]');surface&&(surface.hidden=!available,surface.inert=!available)}cancelPendingShow(){this.showGeneration+=1,this.showAccepted&&!this.afterShowEmitted&&(this.showCompletionGeneration+=1),this.showFrame.cancel(),this.cancelShowAnimation?.(),this.cancelShowAnimation=void 0}scheduleShow(){if(this.showFrame.pending||this.hiding||!this.admitted)return;const generation=++this.showGeneration;this.showFrame.schedule(()=>{this.prepareShow(generation)})}async prepareShow(generation){if(await this.updateComplete,generation!==this.showGeneration||!this.isConnected||!this.admitted||this.hiding)return;if(this.emit("lr-show",null,{cancelable:!0}).defaultPrevented){if(generation!==this.showGeneration)return;const owner=this.regionOwner;owner?owner[TOAST_REGION_REJECT](this):this.remove();return}if(generation!==this.showGeneration||!this.isConnected||!this.admitted||this.hiding)return;this.surfaceMounted=!0;const surface=this.shadowRoot?.querySelector('[part="toast-item"]');surface&&(surface.hidden=!1,surface.offsetWidth),this.setAttribute("data-visible",""),this.bindMessageObserverTargets(),this.recomputeMessageText(),this.interactionReady=!0,surface&&(surface.inert=!1),this.announceMessage(!0),this.showAccepted=!0,this.afterShowEmitted=!1,this.showCompletionGeneration+=1,this.completeShow(),this.startTimer()}async completeShow(){if(this.showCompletionRunning||!this.showAccepted||this.afterShowEmitted||this.hiding||!this.admitted||!this.hasAttribute("data-visible"))return;this.showCompletionRunning=!0;const generation=this.showCompletionGeneration;if(await this.waitForVisualCompletion("show"),this.showCompletionRunning=!1,generation!==this.showCompletionGeneration||!this.isConnected||!this.admitted||this.hiding||!this.hasAttribute("data-visible")){this.isConnected&&this.admitted&&!this.hiding&&this.completeShow();return}this.afterShowEmitted||!this.showAccepted||(this.afterShowEmitted=!0,this.showAccepted=!1,this.emit("lr-after-show"))}disconnectedCallback(){const activeElement=deepActiveElement(this.ownerDocument);!this.pendingFocusRepair&&!this.hiding&&this.hasAttribute("data-visible")&&activeElement&&typeof activeElement.focus=="function"&&(this.pendingFocusRepair=captureComposedFocusRepair(this,activeElement)??void 0),super.disconnectedCallback(),this.removeEventListener("slotchange",this.onMessageSlotChange),this.ownerDocument.removeEventListener("visibilitychange",this.onVisibilityChange),this.messageObserver?.disconnect(),this.messageObserver=void 0,this.messageUpgrades.disconnect(),this.hiding&&!this.afterHideEmitted&&this.hideGeneration++,this.cancelPendingShow(),this.cancelHideAnimation?.(),this.cancelHideAnimation=void 0,this.pauseTimer(),this.hovering=!1,this.focused=!1,!this.hasAttribute("data-visible")&&!this.hiding&&(this.surfaceMounted=!1,this.interactionReady=!1)}startTimer(){this.timerStarted=!0,this.elapsedMs=0,this.resumeTimer()}clearTimer(){this.timer!==void 0&&this.timerOwner?.clearTimeout(this.timer),this.timer=void 0,this.timerOwner=void 0}waitForVisualCompletion(kind){(kind==="show"?this.cancelShowAnimation:this.cancelHideAnimation)?.();const surface=this.shadowRoot?.querySelector('[part="toast-item"]'),watch=waitForTransitionSettle(surface??null,this,{reducedMotion:prefersReducedMotion(this),includeAnimation:!0});if(!watch.pending)return watch.finished;const cancelKey=kind==="show"?"cancelShowAnimation":"cancelHideAnimation",cancel=()=>watch.cancel();return this[cancelKey]=cancel,watch.finished.then(()=>{this[cancelKey]===cancel&&(this[cancelKey]=void 0)})}observeMessageNode(node){if(this.messageObserver){if(node.nodeType===3){this.messageObserver.observe(node,{characterData:!0});return}node.nodeType!==1&&node.nodeType!==11||this.messageObserver.observe(node,{attributes:!0,attributeFilter:["alt","aria-hidden","aria-label","aria-labelledby","class","contenteditable","hidden","href","inert","id","role","slot","style","tabindex"],childList:!0,characterData:!0,subtree:!0})}}bindMessageObserverTargets(){if(this.messageObserver){if(this.messageObserver.disconnect(),this.observeMessageNode(this),this.hasAttribute("data-visible")){let ancestor=composedParentElement(this);for(;ancestor;)this.messageObserver.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","class","hidden","inert","style"]}),ancestor=composedParentElement(ancestor)}for(const slot of this.querySelectorAll("slot"))for(const assigned of slot.assignedNodes({flatten:!0}))this.observeMessageNode(assigned)}}observeLabelReferenceRoot(root){this.messageObserver?.observe(root,{attributes:!0,attributeFilter:["id"],childList:!0,subtree:!0})}recomputeMessageText(){const slot=this.renderRoot?.querySelector("slot:not([name])"),lightDomNodes=this.childNodes,messageNodes=slot?slot.assignedNodes({flatten:!0}):Array.from(lightDomNodes??[]).filter(node=>node.nodeType!==1||!node.getAttribute("slot")),result=composedAccessibilityTextResult(messageNodes,{requireRendered:!1,shouldPrune:element=>{const slotName=element.getAttribute("slot");return slotName!==null&&slotName!==""||isActionableElement(element)?!0:(this.messageUpgrades.observeElement(element),element.hasAttribute("tabindex")&&element.getAttribute("tabindex")!=="-1")},skipRootAncestorValidation:!0});this.messageText=result.text.trim().replace(/\s+/g," "),this.messageTextTruncated=result.truncated;for(const root of result.labelReferenceRoots)this.observeLabelReferenceRoot(root);for(const reference of result.referencedElements)this.observeMessageNode(reference);for(const root of result.traversedShadowRoots)this.observeMessageNode(root)}announceMessage(force=!1){const message=this.messageText,announcement=this.messageTextTruncated?message?`${message}…`:this.localize("toastContentIncomplete"):message;!force&&announcement===this.lastAnnouncedMessage||(this.lastAnnouncedMessage=announcement,this.announcements.announce(announcement,isAssertiveVariant(this.variant)?"assertive":"polite"))}get closeLabel(){const text=this.messageText;if(!text&&this.messageTextTruncated)return this.localize("closeWithContext",void 0,{snippet:this.localize("toastContentIncomplete")});if(!text)return this.localize("close");const{snippet,truncated}=truncateGraphemes(text,CLOSE_LABEL_GRAPHEME_LIMIT,this.effectiveLocale);return this.messageTextTruncated||truncated?this.localize("closeWithTruncatedContext",void 0,{snippet}):this.localize("closeWithContext",void 0,{snippet})}async hide(){await this.requestHide("programmatic")}requestHide(reason){if(this.hideRequest)return this.hideRequest;if(this.hiding)return Promise.resolve();let resolve,reject;const completion=new Promise((resolveCompletion,rejectCompletion)=>{resolve=resolveCompletion,reject=rejectCompletion});return this.hideRequest=completion,this.emit("lr-hide",null,{cancelable:!0}).defaultPrevented||this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented?(reason==="timeout"&&(this.elapsedMs=0,this.startedAt=0,this.progressRun+=1,this.isConnected&&!this.hovering&&!this.focused&&this.resumeTimer()),this.hideRequest===completion&&(this.hideRequest=void 0),resolve(),completion):(this.hiding=!0,this.showAccepted=!1,this.showCompletionGeneration+=1,this.shadowRoot?.querySelector('[part="close-button"]')?.setAttribute("aria-disabled","true"),this.cancelShowAnimation?.(),this.cancelShowAnimation=void 0,this.clearTimer(),this.removeAttribute("data-visible"),this.bindMessageObserverTargets(),this.setAttribute("data-hiding",""),this.emit("lr-close",{reason}),this.completeHide().then(()=>{this.hideRequest===completion&&(this.hideRequest=void 0),resolve()},reason2=>{this.hideRequest===completion&&(this.hideRequest=void 0),reject(reason2)}),completion)}async completeHide(){if(this.hideCompletionRunning||this.afterHideEmitted)return;this.hideCompletionRunning=!0;const generation=this.hideGeneration;if(await this.waitForVisualCompletion("hide"),this.hideCompletionRunning=!1,generation!==this.hideGeneration||!this.isConnected){this.isConnected&&await this.completeHide();return}this.afterHideEmitted||(this.repairFocusBeforeRemoval(),this.afterHideEmitted=!0,this.emit("lr-after-hide"),this.remove())}repairFocusBeforeRemoval(){const active=deepActiveElement(this.ownerDocument);composedContains(this,active)&&this.focusAdjacentToastOrReturn()}adjacentToastOrReturnTarget(){const findAdjacent=direction=>{let element=this[direction];for(;element;){if(element.localName===tag("toast-item")){const item=element,surface=item.shadowRoot?.querySelector('[part="toast-item"]');if(!item.hasAttribute("data-hiding")&&!item.hasAttribute("data-toast-queued")&&item.hasAttribute("data-visible")&&item.isConnected&&surface&&!surface.hidden&&!surface.inert)return item.shadowRoot?.querySelector('[part="close-button"]')??null}element=element[direction]}return null};return findAdjacent("nextElementSibling")??findAdjacent("previousElementSibling")??(this.focusReturnTarget?.isConnected&&!composedContains(this,this.focusReturnTarget)?this.focusReturnTarget:null)}focusAdjacentToastOrReturn(){this.adjacentToastOrReturnTarget()?.focus()}renderCloseControl(){const close=html`<span part="close-icon">${closeIcon()}</span>`,duration=this.safeDuration;return!Number.isFinite(duration)||duration<=0?close:html`
|
|
2
2
|
<span part="progress-ring" aria-hidden="true">
|
|
3
3
|
${keyed(this.progressRun,html`
|
|
4
|
-
<svg part="progress-ring__base" viewBox="0 0 20 20" focusable="false" >
|
|
4
|
+
<svg part="progress-ring__base progress-ring__progress-ring" viewBox="0 0 20 20" focusable="false" >
|
|
5
5
|
<circle part="progress-ring__track" cx="10" cy="10" r="8" pathLength="1" ></circle>
|
|
6
6
|
<circle part="progress-ring__indicator" cx="10" cy="10" r="8" pathLength="1" style=${`animation-duration: ${duration}ms; animation-delay: -${Math.min(this.elapsedMs,duration)}ms`} ></circle>
|
|
7
7
|
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{iconAction,iconActionHover,iconActionActive}from"../../../internal/icon-action.styles.js";import{activeFill,disabledControl,focusRing,iconHitTarget}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{glassSurface}from"../../../internal/glass-surface.styles.js";import{overlaySurfaceFill}from"../../../internal/overlay-surface.styles.js";const styles=css` :host{display:block;--_lr-toast-accent-width:var(--accent-width, var(--lr-size-4px));--_lr-toast-show-duration:var( --show-duration, var(--lr-transition-base, 180ms ease-out) );--_lr-toast-hide-duration:var( --hide-duration, var(--lr-transition-base, 180ms ease-out) );--_lr-toast-padding:var(--padding, var(--lr-space-m));--_lr-toast-font-size:var(--lr-font-size-m);--_lr-toast-accent-color:var(--lr-color-border)}:host([variant]:not([variant=neutral])){--_lr-toast-accent-color:var(--lr-color-fill-loud)}:host([data-effective-size="2xs"]){--_lr-toast-padding:var(--padding, var(--lr-space-2xs));--_lr-toast-font-size:var(--lr-font-size-2xs)}:host([data-effective-size=xs]){--_lr-toast-padding:var(--padding, var(--lr-space-xs));--_lr-toast-font-size:var(--lr-font-size-xs)}:host([data-effective-size=s]){--_lr-toast-padding:var(--padding, var(--lr-space-s));--_lr-toast-font-size:var(--lr-font-size-md-sm)}:host([data-effective-size=m]){--_lr-toast-padding:var(--padding, var(--lr-space-m));--_lr-toast-font-size:var(--lr-font-size-m)}:host([data-effective-size=l]){--_lr-toast-padding:var(--padding, var(--lr-space-l));--_lr-toast-font-size:var(--lr-font-size-lg)}:host([data-effective-size=xl]){--_lr-toast-padding:var(--padding, calc(var(--lr-space-l) * 1.5));--_lr-toast-font-size:var(--lr-font-size-xl)}[part=toast-item]{position:relative;display:flex;align-items:start;gap:var(--lr-toast-item-gap,var(--lr-space-s));inline-size:100%;padding:var(--lr-toast-padding,var(--_lr-toast-padding));padding-inline-start:calc(var(--lr-toast-padding,var(--_lr-toast-padding)) + var(--lr-toast-accent-width,var(--_lr-toast-accent-width)));font-size:var(--lr-toast-font-size,var(--_lr-toast-font-size));${overlaySurfaceFill} color:var(--lr-color-text);border-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius)));box-shadow:var(--lr-overlay-shadow-modal,var(--lr-shadow-l));opacity:0;transform:translateY(var(--lr-size-neg-8px));transition:opacity var(--lr-toast-show-duration,var(--_lr-toast-show-duration)),transform var(--lr-toast-show-duration,var(--_lr-toast-show-duration))}[part=toast-item][hidden]{display:none}:host([data-hiding]) [part=toast-item]{transition:opacity var(--lr-toast-hide-duration,var(--_lr-toast-hide-duration)),transform var(--lr-toast-hide-duration,var(--_lr-toast-hide-duration))}:host([data-visible]) [part=toast-item]{opacity:1;transform:none}@media (prefers-reduced-motion:reduce){[part=toast-item]{transition-duration:0.01ms!important}}[part=accent]{position:absolute;inset-block:0;inset-inline-start:0;inline-size:var(--lr-toast-accent-width,var(--_lr-toast-accent-width));background:var(--lr-toast-accent-color,var(--_lr-toast-accent-color));border-start-start-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius)));border-end-start-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius)))}[part=icon]{display:inline-flex;flex:0 1 auto;min-inline-size:0;max-inline-size:var(--lr-icon-button-size);overflow:hidden;color:var(--lr-toast-accent-color,var(--_lr-toast-accent-color))}[part=icon] ::slotted(*){max-inline-size:100%}[part=content]{flex:1 1 auto;min-inline-size:0;overflow-wrap:anywhere;unicode-bidi:plaintext}::slotted(button){display:inline-block;margin-inline:var(--lr-space-s)!important;padding:0;border:none;background:none;font:inherit;font-weight:var(--lr-font-weight-bold);color:var(--lr-color-on-quiet);text-decoration:underline;cursor:pointer}::slotted(button:hover){color:var(--lr-color-text)}::slotted(button:focus-visible){${focusRing}}::slotted([hidden]:not([hidden="until-found" i])){display:none}[part=close-button]{${iconAction} --_lr-icon-button-color-default:var(--lr-color-text-quiet);--_lr-icon-button-color-hover-default:var(--lr-toast-close-button-hover-color, var(--lr-color-text));--_lr-icon-button-color-active-default:var(--lr-toast-close-button-active-color, var(--lr-color-text));--_lr-icon-button-background-hover-default:var(--lr-toast-close-button-hover-bg, transparent);--_lr-icon-button-background-active-default:var(--lr-toast-close-button-active-bg, ${activeFill("transparent")});position:relative;display:inline-grid;place-items:center;flex:0 0 auto;margin-inline-start:auto;font-size:var(--lr-size-1em);line-height:var(--lr-line-height-none);padding:var(--lr-space-xs);${iconHitTarget}}[part=progress-ring]{position:relative;display:inline-grid;place-items:center;inline-size:var(--lr-size-24px);block-size:var(--lr-size-24px);pointer-events:none}[part
|
|
1
|
+
import{iconAction,iconActionHover,iconActionActive}from"../../../internal/icon-action.styles.js";import{activeFill,disabledControl,focusRing,iconHitTarget}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{glassSurface}from"../../../internal/glass-surface.styles.js";import{overlaySurfaceFill}from"../../../internal/overlay-surface.styles.js";const styles=css` :host{display:block;--_lr-toast-accent-width:var(--accent-width, var(--lr-size-4px));--_lr-toast-show-duration:var( --show-duration, var(--lr-transition-base, 180ms ease-out) );--_lr-toast-hide-duration:var( --hide-duration, var(--lr-transition-base, 180ms ease-out) );--_lr-toast-padding:var(--padding, var(--lr-space-m));--_lr-toast-font-size:var(--lr-font-size-m);--_lr-toast-accent-color:var(--lr-color-border)}:host([variant]:not([variant=neutral])){--_lr-toast-accent-color:var(--lr-color-fill-loud)}:host([data-effective-size="2xs"]){--_lr-toast-padding:var(--padding, var(--lr-space-2xs));--_lr-toast-font-size:var(--lr-font-size-2xs)}:host([data-effective-size=xs]){--_lr-toast-padding:var(--padding, var(--lr-space-xs));--_lr-toast-font-size:var(--lr-font-size-xs)}:host([data-effective-size=s]){--_lr-toast-padding:var(--padding, var(--lr-space-s));--_lr-toast-font-size:var(--lr-font-size-md-sm)}:host([data-effective-size=m]){--_lr-toast-padding:var(--padding, var(--lr-space-m));--_lr-toast-font-size:var(--lr-font-size-m)}:host([data-effective-size=l]){--_lr-toast-padding:var(--padding, var(--lr-space-l));--_lr-toast-font-size:var(--lr-font-size-lg)}:host([data-effective-size=xl]){--_lr-toast-padding:var(--padding, calc(var(--lr-space-l) * 1.5));--_lr-toast-font-size:var(--lr-font-size-xl)}[part=toast-item]{position:relative;display:flex;align-items:start;gap:var(--lr-toast-item-gap,var(--lr-space-s));inline-size:100%;padding:var(--lr-toast-padding,var(--_lr-toast-padding));padding-inline-start:calc(var(--lr-toast-padding,var(--_lr-toast-padding)) + var(--lr-toast-accent-width,var(--_lr-toast-accent-width)));font-size:var(--lr-toast-font-size,var(--_lr-toast-font-size));${overlaySurfaceFill} color:var(--lr-color-text);border-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius-container)));box-shadow:var(--lr-overlay-shadow-modal,var(--lr-shadow-l));opacity:0;transform:translateY(var(--lr-size-neg-8px));transition:opacity var(--lr-toast-show-duration,var(--_lr-toast-show-duration)),transform var(--lr-toast-show-duration,var(--_lr-toast-show-duration))}[part=toast-item][hidden]{display:none}:host([data-hiding]) [part=toast-item]{transition:opacity var(--lr-toast-hide-duration,var(--_lr-toast-hide-duration)),transform var(--lr-toast-hide-duration,var(--_lr-toast-hide-duration))}:host([data-visible]) [part=toast-item]{opacity:1;transform:none}@media (prefers-reduced-motion:reduce){[part=toast-item]{transition-duration:0.01ms!important}}[part=accent]{position:absolute;inset-block:0;inset-inline-start:0;inline-size:var(--lr-toast-accent-width,var(--_lr-toast-accent-width));background:var(--lr-toast-accent-color,var(--_lr-toast-accent-color));border-start-start-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius-container)));border-end-start-radius:var(--lr-toast-item-radius,var(--lr-overlay-radius,var(--lr-radius-container)))}[part=icon]{display:inline-flex;flex:0 1 auto;min-inline-size:0;max-inline-size:var(--lr-icon-button-size);overflow:hidden;color:var(--lr-toast-accent-color,var(--_lr-toast-accent-color))}[part=icon] ::slotted(*){max-inline-size:100%}[part=content]{flex:1 1 auto;min-inline-size:0;overflow-wrap:anywhere;unicode-bidi:plaintext}::slotted(button){display:inline-block;margin-inline:var(--lr-space-s)!important;padding:0;border:none;background:none;font:inherit;font-weight:var(--lr-font-weight-bold);color:var(--lr-color-on-quiet);text-decoration:underline;cursor:pointer}::slotted(button:hover){color:var(--lr-color-text)}::slotted(button:focus-visible){${focusRing}}::slotted([hidden]:not([hidden="until-found" i])){display:none}[part=close-button]{${iconAction} --_lr-icon-button-color-default:var(--lr-color-text-quiet);--_lr-icon-button-color-hover-default:var(--lr-toast-close-button-hover-color, var(--lr-color-text));--_lr-icon-button-color-active-default:var(--lr-toast-close-button-active-color, var(--lr-color-text));--_lr-icon-button-background-hover-default:var(--lr-toast-close-button-hover-bg, transparent);--_lr-icon-button-background-active-default:var(--lr-toast-close-button-active-bg, ${activeFill("transparent")});position:relative;display:inline-grid;place-items:center;flex:0 0 auto;margin-inline-start:auto;font-size:var(--lr-size-1em);line-height:var(--lr-line-height-none);padding:var(--lr-space-xs);${iconHitTarget}}[part=progress-ring]{position:relative;display:inline-grid;place-items:center;inline-size:var(--lr-size-24px);block-size:var(--lr-size-24px);pointer-events:none}[part~=progress-ring__base]{position:absolute;inset:0;inline-size:100%;block-size:100%;overflow:visible;fill:none;transform:rotate(-90deg)}[part=progress-ring__track],[part=progress-ring__indicator]{fill:none;stroke-width:var(--lr-border-width-medium)}[part=progress-ring__track]{stroke:var(--lr-color-border)}[part=progress-ring__indicator]{stroke:var(--lr-toast-accent-color,var(--_lr-toast-accent-color));stroke-linecap:round;stroke-dasharray:1;stroke-dashoffset:0;animation-timing-function:linear;animation-fill-mode:forwards}:host([data-visible]) [part=progress-ring__indicator]{animation-name:var(--_lr-motion-animation,lr-toast-progress)}:host(:hover) [part=progress-ring__indicator],:host(:focus-within) [part=progress-ring__indicator]{animation-play-state:paused}[part=progress-ring__label],[part=close-icon]{display:inline-flex;align-items:center;justify-content:center}[part=close-icon__svg]{display:block}[part=close-button]:where(:hover):where(:not([aria-disabled=true])){${iconActionHover}}[part=close-button]:where(:active):where(:not([aria-disabled=true])){${iconActionActive}}[part=close-button][aria-disabled=true]{${disabledControl}}[part=close-button]:focus-visible{${focusRing}}@keyframes lr-toast-progress{to{stroke-dashoffset:1}}@media (prefers-reduced-motion:reduce){[part=progress-ring__indicator]{animation:none!important;stroke-dashoffset:1}}${glassSurface('[part="toast-item"]',css`var(--lr-overlay-surface, var(--lr-color-surface-container-high))`)} `;export{styles};
|
|
@@ -28,6 +28,12 @@ count:number;}export interface LyraToastEventMap{'lr-toast-overflow':CustomEvent
|
|
|
28
28
|
* @csspart stack - The fl-column container holding the items.
|
|
29
29
|
* @cssprop --gap - Mapped alias for `--lr-toast-gap`.
|
|
30
30
|
* @cssprop --width - Mapped alias for `--lr-toast-width`.
|
|
31
|
+
* @cssprop [--lr-toast-inset-block=var(--lr-space-l)] - Distance between the region and the
|
|
32
|
+
* viewport's top and bottom edges. Each placement is its own region element, so
|
|
33
|
+
* `lr-toast[placement^='bottom']` scopes it to one region. The device safe-area insets still win
|
|
34
|
+
* wherever they are larger.
|
|
35
|
+
* @cssprop [--lr-toast-inset-inline=var(--lr-space-l)] - Distance between the region and the
|
|
36
|
+
* viewport's inline-start and inline-end edges, scoped per region the same way.
|
|
31
37
|
* @cssprop [--lr-toast-gap=var(--lr-space-s)] - Gap between stacked items.
|
|
32
38
|
* @cssprop [--lr-toast-width=var(--lr-size-28rem)] - Inline size of the stack, capped by the
|
|
33
39
|
* usable logical safe-area rectangle.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{declaredDefaultConverter}from"../../../internal/converters.js";import{html,render}from"lit";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{property}from"lit/decorators.js";import{setCustomState}from"../../../internal/custom-states.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{css as lyraStaticStyleCss}from"lit";const styles=lyraStaticStyleCss`:host{z-index:var(--lr-layer-toast);--_lr-toast-gap:var(--gap,var(--lr-space-s));--_lr-toast-width:var(--width,var(--lr-size-28rem));pointer-events:none;display:grid;position:fixed;inset-block-start:max(var(--lr-space-l),var(--lr-safe-area-top));inset-block-end:max(var(--lr-space-l),var(--lr-safe-area-bottom));inset-inline-start:max(var(--lr-space-l),var(--lr-safe-area-inline-start));inset-inline-end:max(var(--lr-space-l),var(--lr-safe-area-inline-end))}:host([popover]){color:inherit;background:0 0;border:0;block-size:auto;inline-size:auto;margin:0;padding:0;overflow:visible}:host::backdrop{pointer-events:none;background:0 0}[part=stack]{gap:var(--lr-toast-gap,var(--_lr-toast-gap));inline-size:min(var(--lr-toast-width,var(--_lr-toast-width)),100%);overscroll-behavior:contain;flex-direction:column;min-block-size:0;max-block-size:100%;max-inline-size:100%;display:flex;overflow:hidden auto}::slotted(*){pointer-events:auto}::slotted([data-toast-queued]){pointer-events:none;display:none!important}:host(:is([placement^=top],:not([placement]))) [part=stack]{align-self:start}:host([placement^=bottom]) [part=stack]{flex-direction:column-reverse;align-self:end}:host([placement$=start]) [part=stack]{justify-self:start}:host([placement$=center]) [part=stack]{justify-self:center}:host(:is([placement$=end],:not([placement]))) [part=stack]{justify-self:end}`;import{isToastRegionEntry,TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE}from"./toast-region-protocol.js";import{LYRA_DEFAULT_toastOverflow}from"../../../internal/default-strings/overlays.generated.js";const MAX_VISIBLE_TOASTS=3,MAX_QUEUED_TOASTS=20;class LyraToast extends LyraElement{constructor(){super(...arguments),this.placement="top-end",this.toastInternals=attachInternalsSafely(this),this.managedEntries=new Set,this.activeEntries=[],this.queuedEntries=[],this.admissionsInProgress=new Set,this.connectionGeneration=0,this.overflowSink=new AnnouncementSinkController(this,{eager:["polite"]}),this.pendingOverflowCount=0,this.overflowNotificationScheduled=!1,this.syncVisibleState=()=>{const hasToast=this.isConnected&&Array.from(this.children).some(child=>isToastRegionEntry(child));setCustomState(this.toastInternals,"visible",hasToast)},this.reconcileEntries=()=>{const children=Array.from(this.children);this.pruneAbsentEntries(),this.promoteQueuedEntries();for(const child of children){if(!isToastRegionEntry(child)){child.localName===tag("toast-item")&&this.ownerDocument.defaultView?.customElements.get(child.localName)&&child.remove();continue}this.managedEntries.has(child)?this.reassertEntry(child):this.admitEntry(child)}this.promoteQueuedEntries(),this.syncVisibleState()}}static{this.defaultStrings={...super.defaultStrings,toastOverflow:LYRA_DEFAULT_toastOverflow}}static{this.styles=[LyraElement.styles,styles]}get stack(){return this.renderRoot?.querySelector('[part="stack"]')??null}connectedCallback(){super.connectedCallback(),this.connectionGeneration+=1;const MutationObserverConstructor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverConstructor&&(this.childObserver=new MutationObserverConstructor(this.reconcileEntries),this.childObserver.observe(this,{childList:!0})),this.reconcileEntries(),this.syncVisibleState()}disconnectedCallback(){const connectionGeneration=++this.connectionGeneration;this.childObserver?.disconnect(),this.childObserver=void 0,this.pendingOverflowCount=0,this.overflowNotificationScheduled=!1,setCustomState(this.toastInternals,"visible",!1);const releaseAfterLastingDisconnect=()=>{if(!(connectionGeneration!==this.connectionGeneration||this.isConnected)){for(const entry of[...this.managedEntries])this.forgetEntry(entry),entry[TOAST_REGION_EVICT](this.regionController,"rejected"),entry.parentElement===this&&entry.remove();this.activeEntries.length=0,this.queuedEntries.length=0,this.managedEntries.clear(),this.admissionsInProgress.clear()}},view=this.ownerDocument.defaultView;view?view.queueMicrotask(releaseAfterLastingDisconnect):queueMicrotask(releaseAfterLastingDisconnect),super.disconnectedCallback()}get regionController(){return this}[TOAST_REGION_ENQUEUE](entry){if(isToastRegionEntry(entry)){if(this.pruneAbsentEntries(),this.promoteQueuedEntries(),entry.parentElement!==this){this.admissionsInProgress.add(entry);try{this.appendChild(entry)}finally{this.admissionsInProgress.delete(entry)}}else if(this.admissionsInProgress.has(entry))return;entry.parentElement===this&&(this.managedEntries.has(entry)?this.reassertEntry(entry):this.admitEntry(entry),this.syncVisibleState())}}[TOAST_REGION_REJECT](entry){isToastRegionEntry(entry)&&this.managedEntries.has(entry)&&(this.forgetEntry(entry),entry[TOAST_REGION_EVICT](this.regionController,"rejected"),this.promoteQueuedEntries(),this.syncVisibleState())}admitEntry(entry){if(entry.parentElement===this){if(this.managedEntries.add(entry),this.activeEntries.length<MAX_VISIBLE_TOASTS){this.activeEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0);return}if(this.queuedEntries.length>=MAX_QUEUED_TOASTS){const evicted=this.queuedEntries.shift();evicted&&(this.managedEntries.delete(evicted),evicted[TOAST_REGION_EVICT](this.regionController,"overflow"),this.recordOverflow())}this.queuedEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!1)}}reassertEntry(entry){if(entry.parentElement===this){if(this.activeEntries.includes(entry)){entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0);return}if(this.queuedEntries.includes(entry)){entry[TOAST_REGION_SET_ACTIVE](this.regionController,!1);return}this.managedEntries.delete(entry),this.admitEntry(entry)}}pruneAbsentEntries(){for(const entry of[...this.managedEntries])entry.parentElement!==this&&this.forgetEntry(entry)}forgetEntry(entry){this.managedEntries.delete(entry);const activeIndex=this.activeEntries.indexOf(entry);activeIndex>=0&&this.activeEntries.splice(activeIndex,1);const queuedIndex=this.queuedEntries.indexOf(entry);queuedIndex>=0&&this.queuedEntries.splice(queuedIndex,1)}promoteQueuedEntries(){for(;this.activeEntries.length<MAX_VISIBLE_TOASTS&&this.queuedEntries.length>0;){const entry=this.queuedEntries.shift();!entry||!this.managedEntries.has(entry)||entry.parentElement!==this||(this.activeEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0))}}recordOverflow(){if(this.pendingOverflowCount+=1,this.overflowNotificationScheduled)return;this.overflowNotificationScheduled=!0;const notify=()=>{this.overflowNotificationScheduled=!1;const count=this.pendingOverflowCount;this.pendingOverflowCount=0,!(count<=0)&&(this.emit("lr-toast-overflow",{count}),this.isConnected&&this.overflowSink.announcePolite(this.localize("toastOverflow",void 0,{count:this.formatLocaleNumber(count)})))},view=this.ownerDocument.defaultView;view?view.requestAnimationFrame(()=>view.requestAnimationFrame(notify)):queueMicrotask(notify)}async create(messageOrOptions,legacyOptions={}){if(!this.isConnected)throw new TypeError("A toast region must be connected before create().");const options=typeof messageOrOptions=="string"?{...legacyOptions,message:messageOrOptions}:messageOrOptions;if(options.ownerDocument&&options.ownerDocument!==this.ownerDocument)throw new TypeError("Toast ownerDocument must match the region owner document.");if(options.placement&&options.placement!==this.placement)throw new TypeError("Toast placement must match the region placement.");const itemTag=tag("toast-item");if(!this.ownerDocument.defaultView?.customElements?.get(itemTag))throw new TypeError(`${itemTag} is not registered in the toast owner document.`);const item=this.ownerDocument.createElement(itemTag);if(typeof item.hide!="function"||!("updateComplete"in item))throw new TypeError(`${itemTag} does not expose the Lyra toast-item contract.`);if(options.variant!==void 0&&(item.variant=options.variant),options.duration!==void 0&&(item.duration=options.duration),options.size!==void 0&&(item.size=options.size),options.withIcon!==void 0&&(item.withIcon=options.withIcon),item.textContent=options.message,options.icon!==void 0){item.withIcon=!0;const iconHost=this.ownerDocument.createElement("span");iconHost.slot="icon",iconHost.setAttribute("aria-hidden","true");const content=typeof options.icon=="function"?options.icon(this.ownerDocument):options.icon;if(typeof content=="string")iconHost.textContent=content;else if(content&&typeof content=="object"&&"nodeType"in content){const node=content;iconHost.append(node.ownerDocument===this.ownerDocument?node:this.ownerDocument.importNode(node,!0))}else render(content,iconHost);item.append(iconHost)}if(options.action){const action=this.ownerDocument.createElement("button");action.type="button",action.textContent=options.action.label,action.addEventListener("click",()=>options.action?.onClick(item)),item.append(action)}if(!isToastRegionEntry(item))throw new TypeError(`${itemTag} does not expose the bounded toast-region protocol.`);return this[TOAST_REGION_ENQUEUE](item),this.syncVisibleState(),await item.updateComplete,item}render(){return html`<div part="stack">
|
|
1
|
+
import{__decorate}from"tslib";import{declaredDefaultConverter}from"../../../internal/converters.js";import{html,render}from"lit";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{property}from"lit/decorators.js";import{setCustomState}from"../../../internal/custom-states.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{css as lyraStaticStyleCss}from"lit";const styles=lyraStaticStyleCss`:host{z-index:var(--lr-layer-toast);--_lr-toast-gap:var(--gap,var(--lr-space-s));--_lr-toast-width:var(--width,var(--lr-size-28rem));pointer-events:none;display:grid;position:fixed;inset-block-start:max(var(--lr-toast-inset-block,var(--lr-space-l)),var(--lr-safe-area-top));inset-block-end:max(var(--lr-toast-inset-block,var(--lr-space-l)),var(--lr-safe-area-bottom));inset-inline-start:max(var(--lr-toast-inset-inline,var(--lr-space-l)),var(--lr-safe-area-inline-start));inset-inline-end:max(var(--lr-toast-inset-inline,var(--lr-space-l)),var(--lr-safe-area-inline-end))}:host([popover]){color:inherit;background:0 0;border:0;block-size:auto;inline-size:auto;margin:0;padding:0;overflow:visible}:host::backdrop{pointer-events:none;background:0 0}[part=stack]{gap:var(--lr-toast-gap,var(--_lr-toast-gap));inline-size:min(var(--lr-toast-width,var(--_lr-toast-width)),100%);overscroll-behavior:contain;flex-direction:column;min-block-size:0;max-block-size:100%;max-inline-size:100%;display:flex;overflow:hidden auto}::slotted(*){pointer-events:auto}::slotted([data-toast-queued]){pointer-events:none;display:none!important}:host(:is([placement^=top],:not([placement]))) [part=stack]{align-self:start}:host([placement^=bottom]) [part=stack]{flex-direction:column-reverse;align-self:end}:host([placement$=start]) [part=stack]{justify-self:start}:host([placement$=center]) [part=stack]{justify-self:center}:host(:is([placement$=end],:not([placement]))) [part=stack]{justify-self:end}`;import{isToastRegionEntry,TOAST_REGION_ENQUEUE,TOAST_REGION_EVICT,TOAST_REGION_REJECT,TOAST_REGION_SET_ACTIVE}from"./toast-region-protocol.js";import{LYRA_DEFAULT_toastOverflow}from"../../../internal/default-strings/overlays.generated.js";const MAX_VISIBLE_TOASTS=3,MAX_QUEUED_TOASTS=20;class LyraToast extends LyraElement{constructor(){super(...arguments),this.placement="top-end",this.toastInternals=attachInternalsSafely(this),this.managedEntries=new Set,this.activeEntries=[],this.queuedEntries=[],this.admissionsInProgress=new Set,this.connectionGeneration=0,this.overflowSink=new AnnouncementSinkController(this,{eager:["polite"]}),this.pendingOverflowCount=0,this.overflowNotificationScheduled=!1,this.syncVisibleState=()=>{const hasToast=this.isConnected&&Array.from(this.children).some(child=>isToastRegionEntry(child));setCustomState(this.toastInternals,"visible",hasToast)},this.reconcileEntries=()=>{const children=Array.from(this.children);this.pruneAbsentEntries(),this.promoteQueuedEntries();for(const child of children){if(!isToastRegionEntry(child)){child.localName===tag("toast-item")&&this.ownerDocument.defaultView?.customElements.get(child.localName)&&child.remove();continue}this.managedEntries.has(child)?this.reassertEntry(child):this.admitEntry(child)}this.promoteQueuedEntries(),this.syncVisibleState()}}static{this.defaultStrings={...super.defaultStrings,toastOverflow:LYRA_DEFAULT_toastOverflow}}static{this.styles=[LyraElement.styles,styles]}get stack(){return this.renderRoot?.querySelector('[part="stack"]')??null}connectedCallback(){super.connectedCallback(),this.connectionGeneration+=1;const MutationObserverConstructor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverConstructor&&(this.childObserver=new MutationObserverConstructor(this.reconcileEntries),this.childObserver.observe(this,{childList:!0})),this.reconcileEntries(),this.syncVisibleState()}disconnectedCallback(){const connectionGeneration=++this.connectionGeneration;this.childObserver?.disconnect(),this.childObserver=void 0,this.pendingOverflowCount=0,this.overflowNotificationScheduled=!1,setCustomState(this.toastInternals,"visible",!1);const releaseAfterLastingDisconnect=()=>{if(!(connectionGeneration!==this.connectionGeneration||this.isConnected)){for(const entry of[...this.managedEntries])this.forgetEntry(entry),entry[TOAST_REGION_EVICT](this.regionController,"rejected"),entry.parentElement===this&&entry.remove();this.activeEntries.length=0,this.queuedEntries.length=0,this.managedEntries.clear(),this.admissionsInProgress.clear()}},view=this.ownerDocument.defaultView;view?view.queueMicrotask(releaseAfterLastingDisconnect):queueMicrotask(releaseAfterLastingDisconnect),super.disconnectedCallback()}get regionController(){return this}[TOAST_REGION_ENQUEUE](entry){if(isToastRegionEntry(entry)){if(this.pruneAbsentEntries(),this.promoteQueuedEntries(),entry.parentElement!==this){this.admissionsInProgress.add(entry);try{this.appendChild(entry)}finally{this.admissionsInProgress.delete(entry)}}else if(this.admissionsInProgress.has(entry))return;entry.parentElement===this&&(this.managedEntries.has(entry)?this.reassertEntry(entry):this.admitEntry(entry),this.syncVisibleState())}}[TOAST_REGION_REJECT](entry){isToastRegionEntry(entry)&&this.managedEntries.has(entry)&&(this.forgetEntry(entry),entry[TOAST_REGION_EVICT](this.regionController,"rejected"),this.promoteQueuedEntries(),this.syncVisibleState())}admitEntry(entry){if(entry.parentElement===this){if(this.managedEntries.add(entry),this.activeEntries.length<MAX_VISIBLE_TOASTS){this.activeEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0);return}if(this.queuedEntries.length>=MAX_QUEUED_TOASTS){const evicted=this.queuedEntries.shift();evicted&&(this.managedEntries.delete(evicted),evicted[TOAST_REGION_EVICT](this.regionController,"overflow"),this.recordOverflow())}this.queuedEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!1)}}reassertEntry(entry){if(entry.parentElement===this){if(this.activeEntries.includes(entry)){entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0);return}if(this.queuedEntries.includes(entry)){entry[TOAST_REGION_SET_ACTIVE](this.regionController,!1);return}this.managedEntries.delete(entry),this.admitEntry(entry)}}pruneAbsentEntries(){for(const entry of[...this.managedEntries])entry.parentElement!==this&&this.forgetEntry(entry)}forgetEntry(entry){this.managedEntries.delete(entry);const activeIndex=this.activeEntries.indexOf(entry);activeIndex>=0&&this.activeEntries.splice(activeIndex,1);const queuedIndex=this.queuedEntries.indexOf(entry);queuedIndex>=0&&this.queuedEntries.splice(queuedIndex,1)}promoteQueuedEntries(){for(;this.activeEntries.length<MAX_VISIBLE_TOASTS&&this.queuedEntries.length>0;){const entry=this.queuedEntries.shift();!entry||!this.managedEntries.has(entry)||entry.parentElement!==this||(this.activeEntries.push(entry),entry[TOAST_REGION_SET_ACTIVE](this.regionController,!0))}}recordOverflow(){if(this.pendingOverflowCount+=1,this.overflowNotificationScheduled)return;this.overflowNotificationScheduled=!0;const notify=()=>{this.overflowNotificationScheduled=!1;const count=this.pendingOverflowCount;this.pendingOverflowCount=0,!(count<=0)&&(this.emit("lr-toast-overflow",{count}),this.isConnected&&this.overflowSink.announcePolite(this.localize("toastOverflow",void 0,{count:this.formatLocaleNumber(count)})))},view=this.ownerDocument.defaultView;view?view.requestAnimationFrame(()=>view.requestAnimationFrame(notify)):queueMicrotask(notify)}async create(messageOrOptions,legacyOptions={}){if(!this.isConnected)throw new TypeError("A toast region must be connected before create().");const options=typeof messageOrOptions=="string"?{...legacyOptions,message:messageOrOptions}:messageOrOptions;if(options.ownerDocument&&options.ownerDocument!==this.ownerDocument)throw new TypeError("Toast ownerDocument must match the region owner document.");if(options.placement&&options.placement!==this.placement)throw new TypeError("Toast placement must match the region placement.");const itemTag=tag("toast-item");if(!this.ownerDocument.defaultView?.customElements?.get(itemTag))throw new TypeError(`${itemTag} is not registered in the toast owner document.`);const item=this.ownerDocument.createElement(itemTag);if(typeof item.hide!="function"||!("updateComplete"in item))throw new TypeError(`${itemTag} does not expose the Lyra toast-item contract.`);if(options.variant!==void 0&&(item.variant=options.variant),options.duration!==void 0&&(item.duration=options.duration),options.size!==void 0&&(item.size=options.size),options.withIcon!==void 0&&(item.withIcon=options.withIcon),item.textContent=options.message,options.icon!==void 0){item.withIcon=!0;const iconHost=this.ownerDocument.createElement("span");iconHost.slot="icon",iconHost.setAttribute("aria-hidden","true");const content=typeof options.icon=="function"?options.icon(this.ownerDocument):options.icon;if(typeof content=="string")iconHost.textContent=content;else if(content&&typeof content=="object"&&"nodeType"in content){const node=content;iconHost.append(node.ownerDocument===this.ownerDocument?node:this.ownerDocument.importNode(node,!0))}else render(content,iconHost);item.append(iconHost)}if(options.action){const action=this.ownerDocument.createElement("button");action.type="button",action.textContent=options.action.label,action.addEventListener("click",()=>options.action?.onClick(item)),item.append(action)}if(!isToastRegionEntry(item))throw new TypeError(`${itemTag} does not expose the bounded toast-region protocol.`);return this[TOAST_REGION_ENQUEUE](item),this.syncVisibleState(),await item.updateComplete,item}render(){return html`<div part="stack">
|
|
2
2
|
<slot @slotchange=${this.syncVisibleState}></slot>
|
|
3
3
|
</div>`}}__decorate([property({reflect:!0,converter:declaredDefaultConverter("top-end")})],LyraToast.prototype,"placement",void 0);export{LyraToast};
|
|
@@ -73,7 +73,7 @@ import{type TemplateResult}from'lit';import{LyraElement}from'../../../internal/l
|
|
|
73
73
|
* on the anchored source-preview popover.
|
|
74
74
|
* @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge
|
|
75
75
|
* colour, on the anchored source-preview popover.
|
|
76
|
-
* @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on the
|
|
76
|
+
* @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius, on the
|
|
77
77
|
* anchored source-preview popover.
|
|
78
78
|
* @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored surface.
|
|
79
79
|
* @cssprop --lr-positioning-strategy - Cascading `absolute`/`fixed` override for the preview
|
|
@@ -30,7 +30,7 @@ import{type TemplateResult}from'lit';import{LyraElement}from'../../../internal/l
|
|
|
30
30
|
* on the anchored detail popover.
|
|
31
31
|
* @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge
|
|
32
32
|
* colour, on the anchored detail popover.
|
|
33
|
-
* @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on the
|
|
33
|
+
* @cssprop [--lr-overlay-radius=var(--lr-radius-container)] - Shared floating-surface corner radius, on the
|
|
34
34
|
* anchored detail popover.
|
|
35
35
|
* @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored surface.
|
|
36
36
|
* @cssprop --lr-positioning-strategy - Cascading `absolute`/`fixed` override for the preview
|
|
@@ -64,6 +64,8 @@ export type LyraCopyButtonTooltipPlacement='top'|'right'|'bottom'|'left';export
|
|
|
64
64
|
* @csspart feedback - Visually hidden, `aria-hidden` mirror of the outcome text. The announcement
|
|
65
65
|
* uses the shared light-DOM polite region because live regions inside shadow roots are not reliable;
|
|
66
66
|
* style the composed tooltip through its `tooltip__*` parts.
|
|
67
|
+
* @csspart copy-button - Web Awesome-named outer wrapper: the nested tooltip element that
|
|
68
|
+
* contains the trigger.
|
|
67
69
|
* @csspart tooltip__base - The nested tooltip's base wrapper.
|
|
68
70
|
* @csspart tooltip__base__popup - The nested tooltip's popup wrapper.
|
|
69
71
|
* @csspart tooltip__base__arrow - The nested tooltip's arrow.
|
|
@@ -106,7 +108,8 @@ accessibleLabel:string|null;
|
|
|
106
108
|
disabled:boolean;private _size?;
|
|
107
109
|
/** Optional shared density tier for the built-in trigger. Unset preserves its original geometry.*/
|
|
108
110
|
get size():LyraSize|undefined;set size(next:LyraSize|undefined);
|
|
109
|
-
/** How long, in milliseconds, the copied confirmation or failure state remains visible
|
|
111
|
+
/** How long, in milliseconds, the copied confirmation or failure state remains visible.
|
|
112
|
+
* Defaults to `1000`. A non-finite value falls back to `1000`; a negative one clamps to `0`. */
|
|
110
113
|
feedbackDuration:number;private status;private readonly sink;private hasCustomTrigger;private triggerCollected;private lastObservedTrigger;private buttonEl?;private defaultSlot?;private readonly internals;private readonly toolbarAction;constructor();private copyTimer?;private copyGeneration;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private hostRelationshipLeases;private syncHostRelationships;private releaseHostRelationships;protected firstUpdated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private cancelFeedbackTimer;private resetFeedback;private setStatus;private customTrigger;private activeTrigger;private composedTriggerAction;private createToolbarAction;
|
|
111
114
|
/** The stable logical copy action exposed to an enclosing composite toolbar. Its optional
|
|
112
115
|
* release method restores an untouched authored trigger tabindex when the parent leaves. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{tag}from"../../../internal/prefix.js";import{copyOutcome,reportCopyOutcome}from"../../../internal/record-copy-feedback.js";import{normalizeLabel}from"../../../internal/accessible-name.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{checkIcon,copyIcon,errorCircleIcon}from"../../../internal/icons.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{finiteDuration}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{optionalSizeConverter,writeOptionalSize}from"../../../internal/variants.js";import{sizes}from"../../../internal/sizes.styles.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{styles}from"./copy-button.styles.js";import{COPY_FEEDBACK_MS}from"../../../internal/copy-feedback.js";import{leaseTabIndex}from"../../../internal/tab-index-lease.js";import{blankNumberConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_FEEDBACK_DURATION=COPY_FEEDBACK_MS;function isElementValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return candidate.nodeType===1&&typeof candidate.getAttribute=="function"}function isHtmlElementValue(value){if(!isElementValue(value))return!1;const candidate=value;return candidate.namespaceURI==="http://www.w3.org/1999/xhtml"&&typeof candidate.focus=="function"&&typeof candidate.blur=="function"&&typeof candidate.click=="function"}class CopySourceError extends Error{constructor(message){super(message),this.name="CopySourceError"}}class LyraCopyButton extends LyraElement{static{this.defaultStrings={...super.defaultStrings,copied:LYRA_DEFAULT_copied,copy:LYRA_DEFAULT_copy,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.styles=[LyraElement.styles,sizes,styles]}get size(){return this._size}set size(next){writeOptionalSize(this,this._size,next,value=>{this._size=value})}constructor(){super(),this.value="",this.from="",this.tooltip="full",this.tooltipPlacement="top",this.hoist=!1,this.accessibleLabel=null,this.disabled=!1,this.feedbackDuration=DEFAULT_FEEDBACK_DURATION,this.status="rest",this.sink=new AnnouncementSinkController(this,{eager:["polite"]}),this.hasCustomTrigger=!1,this.triggerCollected=!1,this.internals=attachInternalsSafely(this),this.toolbarAction=this.createToolbarAction(),this.copyGeneration=0,this.hostRelationshipLeases=[],this.onClick=()=>{this.copy()},this.onDefaultSlotChange=event=>{this.onDefaultSlotChangeFromSlot(event.currentTarget)},this.onCustomTriggerClick=()=>{this.hasCustomTrigger&&this.copy()},this.stopInternalTooltipEvent=event=>{event.stopPropagation()},this.internals.role="group"}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&(changed.has("value")||changed.has("from"))&&this.resetFeedback()}updated(changed){super.updated(changed),(changed.has("disabled")||changed.has("hasCustomTrigger"))&&this.emit("lr-toolbar-actions-change"),this.syncHostRelationships()}syncHostRelationships(){const iconButton=this.renderRoot.querySelector(tag("icon-button"));if(!iconButton){this.releaseHostRelationships();return}iconButton.updateComplete.then(()=>{if(!iconButton.isConnected||iconButton.getRootNode()!==this.renderRoot)return;const target=iconButton.control;if(this.hostRelationshipLeases.length===0)this.hostRelationshipLeases=[acquireNativeControlDescription(this,target,()=>""),acquireResolvedAriaRelationship(this,target,"aria-labelledby")];else for(const lease of this.hostRelationshipLeases)lease.update(target)})}releaseHostRelationships(){for(const lease of this.hostRelationshipLeases)lease.release();this.hostRelationshipLeases=[]}firstUpdated(changed){super.firstUpdated(changed);const slot=this.defaultSlot;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>this.onDefaultSlotChangeFromSlot(s))})}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","group")}disconnectedCallback(){this.toolbarAction.releaseTabIndex?.(),this.releaseHostRelationships(),super.disconnectedCallback(),this.resetFeedback()}adoptedCallback(){this.toolbarAction.releaseTabIndex?.(),super.adoptedCallback(),this.sink.adopted(),this.resetFeedback()}cancelFeedbackTimer(){const timer=this.copyTimer;this.copyTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}resetFeedback(){this.copyGeneration+=1,this.cancelFeedbackTimer(),this.setStatus("rest")}setStatus(status){this.status=status,setCustomState(this.internals,"success",status==="success"),setCustomState(this.internals,"error",status==="error")}customTrigger(){return this.defaultSlot?.assignedElements({flatten:!0}).find(isHtmlElementValue)}activeTrigger(){return this.hasCustomTrigger?this.customTrigger():this.buttonEl}composedTriggerAction(){if(this.hasCustomTrigger)return;const[action]=this.buttonEl?.getToolbarActions()??[];return action}createToolbarAction(){const host=this,lease=leaseTabIndex();let delegated;const releaseDelegated=()=>{const previous=delegated;delegated=void 0,previous?.releaseTabIndex?.()},releaseTabIndex=()=>{releaseDelegated(),lease.release()};return{id:"copy",get disabled(){const trigger=host.activeTrigger();return!trigger||host.disabled||trigger.disabled===!0},focus(options){host.activeTrigger()?.focus(options)},setTabIndex(tabIndex){const composed=host.composedTriggerAction();if(composed){delegated!==composed&&(releaseTabIndex(),delegated=composed),composed.setTabIndex(tabIndex);return}releaseDelegated(),lease.set(host.activeTrigger()??void 0,tabIndex)},releaseTabIndex,matchesEventPath(path){const trigger=host.activeTrigger();return trigger!=null&&path.includes(trigger)}}}getToolbarActions(){return[this.toolbarAction]}focus(options){this.deferFocusUntilRendered(options)||this.activeTrigger()?.focus(options)}blur(){this.activeTrigger()?.blur()}click(){this.activeTrigger()?.click()}sourceById(id){const root=this.getRootNode();if((root.nodeType===9||root.nodeType===11)&&typeof root.getElementById=="function"){const source=root.getElementById(id);if(isElementValue(source))return source}const documentSource=this.ownerDocument.getElementById(id);return isElementValue(documentSource)?documentSource:null}resolveCopyText(){if(!this.from){if(!this.value)throw new CopySourceError("The copy value is empty.");return this.value}const expression=this.from.trim(),attributeMatch=/^(.*?)\[([^\]]+)\]$/.exec(expression),propertyMatch=attributeMatch?null:/^(.*?)\.([^.]*)$/.exec(expression),id=(attributeMatch?.[1]??propertyMatch?.[1]??expression).trim(),splitSource=id?this.sourceById(id):null,wholeIdSource=!splitSource&&(attributeMatch||propertyMatch)?this.sourceById(expression):null,source=splitSource??wholeIdSource;if(!source)throw new CopySourceError(`The copy source "${id}" was not found.`);let resolved;if(wholeIdSource)resolved=source.textContent;else if(attributeMatch){const attribute=attributeMatch[2].trim();resolved=attribute?source.getAttribute(attribute):null}else if(propertyMatch){const propertyName=propertyMatch[2].trim();resolved=propertyName?source[propertyName]:void 0}else resolved=source.textContent;const text=resolved==null?"":String(resolved);if(!text)throw new CopySourceError(`The copy source "${expression}" resolved to an empty value.`);return text}showStatus(status){const owner=this.ownerDocument.defaultView;if(!this.isConnected||!owner)return;this.setStatus(status),this.sink.announcePolite(this.statusLabel(status)),this.cancelFeedbackTimer();const duration=finiteDuration(this.feedbackDuration,DEFAULT_FEEDBACK_DURATION,0),generation=this.copyGeneration;let handle=0;handle=owner.setTimeout(()=>{const timer=this.copyTimer;timer?.owner!==owner||timer.handle!==handle||timer.generation!==generation||generation!==this.copyGeneration||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.copyTimer=void 0,this.setStatus("rest"))},duration),this.copyTimer={owner,handle,generation}}reportCopy(outcome,generation,owner){reportCopyOutcome({announce:ok=>this.showStatus(ok?"success":"error"),emit:(name,detail)=>this.emit(name,detail??null)},outcome,()=>this.isCurrentCopy(generation,owner))}async copy(){if(this.disabled)return;const generation=++this.copyGeneration,owner=this.isConnected?this.ownerDocument.defaultView:null;let text="";try{text=this.resolveCopyText()}catch(error){this.reportCopy(copyOutcome("failure",{text,error}),generation);return}if(!owner)return;const outcome=await writeClipboardText(owner,text);this.reportCopy(outcome,generation,owner)}isCurrentCopy(generation,owner){return this.isConnected&&generation===this.copyGeneration&&(owner===void 0||this.ownerDocument.defaultView===owner)}onDefaultSlotChangeFromSlot(slot){const trigger=slot.assignedElements({flatten:!0}).find(isHtmlElementValue);if(this.triggerCollected&&trigger===this.lastObservedTrigger)return;this.triggerCollected=!0,this.lastObservedTrigger=trigger;const hasCustomTrigger=trigger!==void 0;if(hasCustomTrigger!==this.hasCustomTrigger){this.hasCustomTrigger=hasCustomTrigger;return}this.emit("lr-toolbar-actions-change")}statusLabel(status){const label=status==="success"?this.successLabel:status==="error"?this.errorLabel:this.copyLabel;return label===""?"":normalizeLabel(label)??this.localize(status==="success"?"copied":status==="error"?"copyFailed":"copy")}renderIcon(){return this.status==="error"?html`<span part="error-icon" aria-hidden="true"><slot name="error-icon">${errorCircleIcon()}</slot></span>`:this.status==="success"?html`<span part="success-icon" aria-hidden="true"><slot name="success-icon">${checkIcon()}</slot></span>`:html`<span part="copy-icon" aria-hidden="true"><slot name="copy-icon">${copyIcon()}</slot></span>`}render(){const statusLabel=this.statusLabel(this.status),feedback=this.status==="rest"?"":statusLabel,part=this.status==="success"?"base button base-success":this.status==="error"?"base button base-error":"base button",tooltipDisabled=this.tooltip==="none"||statusLabel.trim()==="",tooltipOpen=!tooltipDisabled&&this.status!=="rest",buttonLabel=this.accessibleLabel?.trim()?this.accessibleLabel:statusLabel;return html`
|
|
2
|
-
<lr-tooltip .trigger=${this.tooltip==="full"?"hover focus":"manual"} .placement=${this.tooltipPlacement} .hoist=${this.hoist} .disabled=${tooltipDisabled} .open=${tooltipOpen} @lr-show=${this.stopInternalTooltipEvent} @lr-after-show=${this.stopInternalTooltipEvent} @lr-hide=${this.stopInternalTooltipEvent} @lr-after-hide=${this.stopInternalTooltipEvent} exportparts="base:tooltip__base, base__popup:tooltip__base__popup, base__arrow:tooltip__base__arrow, body:tooltip__body" >
|
|
1
|
+
import{__decorate}from"tslib";import{tag}from"../../../internal/prefix.js";import{copyOutcome,reportCopyOutcome}from"../../../internal/record-copy-feedback.js";import{normalizeLabel}from"../../../internal/accessible-name.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{checkIcon,copyIcon,errorCircleIcon}from"../../../internal/icons.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{finiteDuration}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{optionalSizeConverter,writeOptionalSize}from"../../../internal/variants.js";import{sizes}from"../../../internal/sizes.styles.js";import{writeClipboardText}from"../../../internal/clipboard.js";import{styles}from"./copy-button.styles.js";import{leaseTabIndex}from"../../../internal/tab-index-lease.js";import{blankNumberConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_FEEDBACK_DURATION=1e3;function isElementValue(value){if(value===null||typeof value!="object")return!1;const candidate=value;return candidate.nodeType===1&&typeof candidate.getAttribute=="function"}function isHtmlElementValue(value){if(!isElementValue(value))return!1;const candidate=value;return candidate.namespaceURI==="http://www.w3.org/1999/xhtml"&&typeof candidate.focus=="function"&&typeof candidate.blur=="function"&&typeof candidate.click=="function"}class CopySourceError extends Error{constructor(message){super(message),this.name="CopySourceError"}}class LyraCopyButton extends LyraElement{static{this.defaultStrings={...super.defaultStrings,copied:LYRA_DEFAULT_copied,copy:LYRA_DEFAULT_copy,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.styles=[LyraElement.styles,sizes,styles]}get size(){return this._size}set size(next){writeOptionalSize(this,this._size,next,value=>{this._size=value})}constructor(){super(),this.value="",this.from="",this.tooltip="full",this.tooltipPlacement="top",this.hoist=!1,this.accessibleLabel=null,this.disabled=!1,this.feedbackDuration=DEFAULT_FEEDBACK_DURATION,this.status="rest",this.sink=new AnnouncementSinkController(this,{eager:["polite"]}),this.hasCustomTrigger=!1,this.triggerCollected=!1,this.internals=attachInternalsSafely(this),this.toolbarAction=this.createToolbarAction(),this.copyGeneration=0,this.hostRelationshipLeases=[],this.onClick=()=>{this.copy()},this.onDefaultSlotChange=event=>{this.onDefaultSlotChangeFromSlot(event.currentTarget)},this.onCustomTriggerClick=()=>{this.hasCustomTrigger&&this.copy()},this.stopInternalTooltipEvent=event=>{event.stopPropagation()},this.internals.role="group"}willUpdate(changed){super.willUpdate(changed),this.hasUpdated&&(changed.has("value")||changed.has("from"))&&this.resetFeedback()}updated(changed){super.updated(changed),(changed.has("disabled")||changed.has("hasCustomTrigger"))&&this.emit("lr-toolbar-actions-change"),this.syncHostRelationships()}syncHostRelationships(){const iconButton=this.renderRoot.querySelector(tag("icon-button"));if(!iconButton){this.releaseHostRelationships();return}iconButton.updateComplete.then(()=>{if(!iconButton.isConnected||iconButton.getRootNode()!==this.renderRoot)return;const target=iconButton.control;if(this.hostRelationshipLeases.length===0)this.hostRelationshipLeases=[acquireNativeControlDescription(this,target,()=>""),acquireResolvedAriaRelationship(this,target,"aria-labelledby")];else for(const lease of this.hostRelationshipLeases)lease.update(target)})}releaseHostRelationships(){for(const lease of this.hostRelationshipLeases)lease.release();this.hostRelationshipLeases=[]}firstUpdated(changed){super.firstUpdated(changed);const slot=this.defaultSlot;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>this.onDefaultSlotChangeFromSlot(s))})}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","group"),this.getAttribute("hydrate-internals-role")===this.getAttribute("role")&&this.removeAttribute("hydrate-internals-role")}disconnectedCallback(){this.toolbarAction.releaseTabIndex?.(),this.releaseHostRelationships(),super.disconnectedCallback(),this.resetFeedback()}adoptedCallback(){this.toolbarAction.releaseTabIndex?.(),super.adoptedCallback(),this.sink.adopted(),this.resetFeedback()}cancelFeedbackTimer(){const timer=this.copyTimer;this.copyTimer=void 0,timer&&timer.owner.clearTimeout(timer.handle)}resetFeedback(){this.copyGeneration+=1,this.cancelFeedbackTimer(),this.setStatus("rest")}setStatus(status){this.status=status,setCustomState(this.internals,"success",status==="success"),setCustomState(this.internals,"error",status==="error")}customTrigger(){return this.defaultSlot?.assignedElements({flatten:!0}).find(isHtmlElementValue)}activeTrigger(){return this.hasCustomTrigger?this.customTrigger():this.buttonEl}composedTriggerAction(){if(this.hasCustomTrigger)return;const[action]=this.buttonEl?.getToolbarActions()??[];return action}createToolbarAction(){const host=this,lease=leaseTabIndex();let delegated;const releaseDelegated=()=>{const previous=delegated;delegated=void 0,previous?.releaseTabIndex?.()},releaseTabIndex=()=>{releaseDelegated(),lease.release()};return{id:"copy",get disabled(){const trigger=host.activeTrigger();return!trigger||host.disabled||trigger.disabled===!0},focus(options){host.activeTrigger()?.focus(options)},setTabIndex(tabIndex){const composed=host.composedTriggerAction();if(composed){delegated!==composed&&(releaseTabIndex(),delegated=composed),composed.setTabIndex(tabIndex);return}releaseDelegated(),lease.set(host.activeTrigger()??void 0,tabIndex)},releaseTabIndex,matchesEventPath(path){const trigger=host.activeTrigger();return trigger!=null&&path.includes(trigger)}}}getToolbarActions(){return[this.toolbarAction]}focus(options){this.deferFocusUntilRendered(options)||this.activeTrigger()?.focus(options)}blur(){this.activeTrigger()?.blur()}click(){this.activeTrigger()?.click()}sourceById(id){const root=this.getRootNode();if((root.nodeType===9||root.nodeType===11)&&typeof root.getElementById=="function"){const source=root.getElementById(id);if(isElementValue(source))return source}const documentSource=this.ownerDocument.getElementById(id);return isElementValue(documentSource)?documentSource:null}resolveCopyText(){if(!this.from){if(!this.value)throw new CopySourceError("The copy value is empty.");return this.value}const expression=this.from.trim(),attributeMatch=/^(.*?)\[([^\]]+)\]$/.exec(expression),propertyMatch=attributeMatch?null:/^(.*?)\.([^.]*)$/.exec(expression),id=(attributeMatch?.[1]??propertyMatch?.[1]??expression).trim(),splitSource=id?this.sourceById(id):null,wholeIdSource=!splitSource&&(attributeMatch||propertyMatch)?this.sourceById(expression):null,source=splitSource??wholeIdSource;if(!source)throw new CopySourceError(`The copy source "${id}" was not found.`);let resolved;if(wholeIdSource)resolved=source.textContent;else if(attributeMatch){const attribute=attributeMatch[2].trim();resolved=attribute?source.getAttribute(attribute):null}else if(propertyMatch){const propertyName=propertyMatch[2].trim();resolved=propertyName?source[propertyName]:void 0}else resolved=source.textContent;const text=resolved==null?"":String(resolved);if(!text)throw new CopySourceError(`The copy source "${expression}" resolved to an empty value.`);return text}showStatus(status){const owner=this.ownerDocument.defaultView;if(!this.isConnected||!owner)return;this.setStatus(status),this.sink.announcePolite(this.statusLabel(status)),this.cancelFeedbackTimer();const duration=finiteDuration(this.feedbackDuration,DEFAULT_FEEDBACK_DURATION,0),generation=this.copyGeneration;let handle=0;handle=owner.setTimeout(()=>{const timer=this.copyTimer;timer?.owner!==owner||timer.handle!==handle||timer.generation!==generation||generation!==this.copyGeneration||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.copyTimer=void 0,this.setStatus("rest"))},duration),this.copyTimer={owner,handle,generation}}reportCopy(outcome,generation,owner){reportCopyOutcome({announce:ok=>this.showStatus(ok?"success":"error"),emit:(name,detail)=>this.emit(name,detail??null)},outcome,()=>this.isCurrentCopy(generation,owner))}async copy(){if(this.disabled)return;const generation=++this.copyGeneration,owner=this.isConnected?this.ownerDocument.defaultView:null;let text="";try{text=this.resolveCopyText()}catch(error){this.reportCopy(copyOutcome("failure",{text,error}),generation);return}if(!owner)return;const outcome=await writeClipboardText(owner,text);this.reportCopy(outcome,generation,owner)}isCurrentCopy(generation,owner){return this.isConnected&&generation===this.copyGeneration&&(owner===void 0||this.ownerDocument.defaultView===owner)}onDefaultSlotChangeFromSlot(slot){const trigger=slot.assignedElements({flatten:!0}).find(isHtmlElementValue);if(this.triggerCollected&&trigger===this.lastObservedTrigger)return;this.triggerCollected=!0,this.lastObservedTrigger=trigger;const hasCustomTrigger=trigger!==void 0;if(hasCustomTrigger!==this.hasCustomTrigger){this.hasCustomTrigger=hasCustomTrigger;return}this.emit("lr-toolbar-actions-change")}statusLabel(status){const label=status==="success"?this.successLabel:status==="error"?this.errorLabel:this.copyLabel;return label===""?"":normalizeLabel(label)??this.localize(status==="success"?"copied":status==="error"?"copyFailed":"copy")}renderIcon(){return this.status==="error"?html`<span part="error-icon" aria-hidden="true"><slot name="error-icon">${errorCircleIcon()}</slot></span>`:this.status==="success"?html`<span part="success-icon" aria-hidden="true"><slot name="success-icon">${checkIcon()}</slot></span>`:html`<span part="copy-icon" aria-hidden="true"><slot name="copy-icon">${copyIcon()}</slot></span>`}render(){const statusLabel=this.statusLabel(this.status),feedback=this.status==="rest"?"":statusLabel,part=this.status==="success"?"base button base-success":this.status==="error"?"base button base-error":"base button",tooltipDisabled=this.tooltip==="none"||statusLabel.trim()==="",tooltipOpen=!tooltipDisabled&&this.status!=="rest",buttonLabel=this.accessibleLabel?.trim()?this.accessibleLabel:statusLabel;return html`
|
|
2
|
+
<lr-tooltip part="copy-button" .trigger=${this.tooltip==="full"?"hover focus":"manual"} .placement=${this.tooltipPlacement} .hoist=${this.hoist} .disabled=${tooltipDisabled} .open=${tooltipOpen} @lr-show=${this.stopInternalTooltipEvent} @lr-after-show=${this.stopInternalTooltipEvent} @lr-hide=${this.stopInternalTooltipEvent} @lr-after-hide=${this.stopInternalTooltipEvent} exportparts="base:tooltip__base, base__popup:tooltip__base__popup, base__arrow:tooltip__base__arrow, body:tooltip__body" >
|
|
3
3
|
${this.hasCustomTrigger?nothing:html`
|
|
4
4
|
<lr-icon-button slot="trigger" part=${part} exportparts="button:base-control" ?disabled=${this.disabled} aria-label=${buttonLabel} @click=${this.onClick} >
|
|
5
5
|
${this.renderIcon()}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Calendar-aware time splitting for `<lr-counter>`. Pure functions; no DOM.*/
|
|
2
|
+
export type LyraCounterUnit='years'|'months'|'days'|'hours'|'minutes'|'seconds';
|
|
3
|
+
/** Every unit, largest to smallest.*/
|
|
4
|
+
export declare const COUNTER_UNITS:readonly LyraCounterUnit[];
|
|
5
|
+
/** Fixed-length units in milliseconds; months and years vary and have no entry.*/
|
|
6
|
+
export declare const COUNTER_UNIT_MS:Readonly<Partial<Record<LyraCounterUnit,number>>>;export type LyraCounterValues=Partial<Record<LyraCounterUnit,number>>;
|
|
7
|
+
/** Adds calendar months in local time, clamping to the last day of a shorter month.*/
|
|
8
|
+
export declare function addCalendarMonths(date:Date,months:number):Date;
|
|
9
|
+
/**
|
|
10
|
+
* Splits the span between two instants into `largest`..`smallest` units. Time above `largest` rolls
|
|
11
|
+
* into it; time below `smallest` is dropped. Years and months follow the local calendar and step from
|
|
12
|
+
* the fixed end (`from` when counting up, `to` when `countdown`); days and smaller are exact elapsed
|
|
13
|
+
* time, so a day is always 24 real hours. A negative span counts as zero.
|
|
14
|
+
*/
|
|
15
|
+
export declare function splitDuration(from:Date,to:Date,largest:LyraCounterUnit,smallest:LyraCounterUnit,countdown?:boolean):LyraCounterValues;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const COUNTER_UNITS=["years","months","days","hours","minutes","seconds"],COUNTER_UNIT_MS={days:864e5,hours:36e5,minutes:6e4,seconds:1e3};function addCalendarMonths(date,months){const result=new Date(date.getTime());result.setFullYear(date.getFullYear(),date.getMonth()+months,1);const lastDay=new Date(result.getTime());return lastDay.setMonth(lastDay.getMonth()+1,0),result.setDate(Math.min(date.getDate(),lastDay.getDate())),result}function splitDuration(from,to,largest,smallest,countdown=!1){const shown=COUNTER_UNITS.slice(COUNTER_UNITS.indexOf(largest),COUNTER_UNITS.indexOf(smallest)+1),result={},end=to.getTime()<from.getTime()?from:to;let rest=end.getTime()-from.getTime();if(largest==="years"||largest==="months"){let months=(end.getFullYear()-from.getFullYear())*12+end.getMonth()-from.getMonth();const restAfter=count=>countdown?addCalendarMonths(end,-count).getTime()-from.getTime():end.getTime()-addCalendarMonths(from,count).getTime();restAfter(months)<0&&months--,rest=restAfter(months),countdown&&(smallest==="months"||smallest==="years")&&(rest>0&&months++,smallest==="years"&&(months=Math.ceil(months/12)*12)),largest==="years"&&(result.years=Math.floor(months/12),months%=12),shown.includes("months")&&(result.months=months)}for(const unit of["days","hours","minutes","seconds"]){if(!shown.includes(unit))continue;const length=COUNTER_UNIT_MS[unit];result[unit]=Math.floor(rest/length),rest%=length}return result}export{COUNTER_UNITS,COUNTER_UNIT_MS,addCalendarMonths,splitDuration};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraCounterUnit}from'./counter-time.js';export type{LyraCounterUnit}from'./counter-time.js';
|
|
2
|
+
/** The label style of a counter's units.*/
|
|
3
|
+
export type LyraCounterFormat='long'|'short'|'narrow';
|
|
4
|
+
/** The direction a counter runs.*/
|
|
5
|
+
export type LyraCounterDirection='down'|'up';export interface LyraCounterEventMap{'lr-finish':CustomEvent<null>;}
|
|
6
|
+
/** A source for `date`: a `Date`, epoch milliseconds, or a date string (ISO 8601 is the safe form).*/
|
|
7
|
+
export type LyraCounterDateSource=Date|string|number;
|
|
8
|
+
/**
|
|
9
|
+
* `<lr-counter>` — counts down to a date (or for a duration) or up from one, ticking through years,
|
|
10
|
+
* months, days, hours, minutes and seconds with locale-aware unit labels. Use it for launch and sale
|
|
11
|
+
* countdowns and for how long something has been running.
|
|
12
|
+
*
|
|
13
|
+
* The host is not a live region: the counter is a `role="timer"` whose visually hidden phrase is
|
|
14
|
+
* refreshed every tick but never announced, so assistive technology reads the current time on demand
|
|
15
|
+
* instead of once a second. Set `label` to name it. It renders zeros during SSR and starts counting
|
|
16
|
+
* once it connects on the client, because the server cannot know the viewer's clock.
|
|
17
|
+
*
|
|
18
|
+
* @customElement lr-counter
|
|
19
|
+
* @slot years - A custom label for years.
|
|
20
|
+
* @slot months - A custom label for months.
|
|
21
|
+
* @slot days - A custom label for days.
|
|
22
|
+
* @slot hours - A custom label for hours.
|
|
23
|
+
* @slot minutes - A custom label for minutes.
|
|
24
|
+
* @slot seconds - A custom label for seconds.
|
|
25
|
+
* @slot finished - Content shown in place of the units when a countdown is at zero, including one whose date already passed.
|
|
26
|
+
* @csspart base - The timer container that holds the units.
|
|
27
|
+
* @csspart unit - The container that wraps one unit's value and label.
|
|
28
|
+
* @csspart value - One unit's value.
|
|
29
|
+
* @csspart label - One unit's label.
|
|
30
|
+
* @csspart delimiter - The text shown between units.
|
|
31
|
+
* @csspart finished - The container around the `finished` slot.
|
|
32
|
+
* @cssprop [--lr-counter-gap=0.5em] - The space between units.
|
|
33
|
+
* @cssstate finished - Applied while a countdown is at zero, including one whose date already passed.
|
|
34
|
+
* @event lr-finish - A running countdown reached zero. Not emitted when the date had already passed.
|
|
35
|
+
* @status experimental
|
|
36
|
+
* @since 32.1.0
|
|
37
|
+
*/
|
|
38
|
+
export declare class LyraCounter extends LyraElement<LyraCounterEventMap>{static styles:import("lit").CSSResultGroup[];
|
|
39
|
+
/**
|
|
40
|
+
* The date to count down to, or up from: a `Date`, epoch milliseconds, or a string. Prefer ISO 8601
|
|
41
|
+
* strings so time zones resolve identically everywhere. When omitted, the counter counts down from
|
|
42
|
+
* `duration`, or up from the moment it starts.
|
|
43
|
+
*/
|
|
44
|
+
date?:LyraCounterDateSource;
|
|
45
|
+
/**
|
|
46
|
+
* Milliseconds to count down from, starting when the counter connects. Changing it restarts the
|
|
47
|
+
* countdown. Ignored when `date` is set or `direction` is `up`.
|
|
48
|
+
*/
|
|
49
|
+
duration?:number;
|
|
50
|
+
/** Counts `down` to the date (the default) or `up` from it.*/
|
|
51
|
+
direction:LyraCounterDirection;
|
|
52
|
+
/** An accessible name for the timer.*/
|
|
53
|
+
label:string;
|
|
54
|
+
/** The largest unit to show; larger time rolls up into it. An invalid pair falls back to days through seconds.*/
|
|
55
|
+
largestUnit:LyraCounterUnit;
|
|
56
|
+
/** The smallest unit to show; smaller time is dropped. An invalid pair falls back to days through seconds.*/
|
|
57
|
+
smallestUnit:LyraCounterUnit;
|
|
58
|
+
/** The unit label style: `long` (the default), `short` or `narrow`.*/
|
|
59
|
+
format:LyraCounterFormat;
|
|
60
|
+
/** Hides the unit labels and keeps every unit so the digits hold their place, like a clock.*/
|
|
61
|
+
withoutLabels:boolean;
|
|
62
|
+
/** Text shown between units, such as `:`.*/
|
|
63
|
+
delimiter:string;
|
|
64
|
+
/** Pauses the counter; clearing it continues from the time shown.*/
|
|
65
|
+
paused:boolean;
|
|
66
|
+
/** Formats each unit's value. Receives the value and its unit; assistive technology still reads the raw value. Property only.*/
|
|
67
|
+
valueFormatter?:(value:number,unit:LyraCounterUnit)=>string;private values;private finished;private hasFinishedContent;private readonly internals;private timer;private startedAt;private pausedAt;private shift;private counting;private generation;connectedCallback():void;disconnectedCallback():void;protected willUpdate(changed:PropertyValues<this>):void;private stopTimer;private get units();private tick;private unitLabel;private unitValue;private onFinishedSlotChange;protected render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-counter':LyraCounter;}}
|