@aceshooting/lyra-ui 25.4.0 → 25.6.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 +36 -0
- package/README.md +15 -3
- package/custom-elements.json +1 -1
- package/dist/all.d.ts +1 -1
- package/dist/all.js +1 -1
- package/dist/cli/migration-contract.json +1 -1
- package/dist/components/forms/button/button.class.d.ts +13 -3
- package/dist/components/forms/button/button.class.js +2 -2
- package/dist/components/forms/catalog-picker-base.d.ts +48 -0
- package/dist/components/forms/catalog-picker-base.js +29 -0
- package/dist/components/forms/catalog-picker-base.styles.d.ts +1 -0
- package/dist/components/forms/catalog-picker-base.styles.js +1 -0
- package/dist/components/forms/combobox/combobox.class.d.ts +4 -1
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/forms/country-picker/country-picker.class.d.ts +40 -0
- package/dist/components/forms/country-picker/country-picker.class.js +1 -0
- package/dist/components/forms/country-picker/country-picker.d.ts +1 -0
- package/dist/components/forms/country-picker/country-picker.js +1 -0
- package/dist/components/forms/country-picker/country-picker.styles.d.ts +1 -0
- package/dist/components/forms/country-picker/country-picker.styles.js +1 -0
- package/dist/components/forms/currency-picker/currency-catalog.d.ts +19 -0
- package/dist/components/forms/currency-picker/currency-catalog.js +1 -0
- package/dist/components/forms/currency-picker/currency-picker.class.d.ts +95 -0
- package/dist/components/forms/currency-picker/currency-picker.class.js +30 -0
- package/dist/components/forms/currency-picker/currency-picker.d.ts +1 -0
- package/dist/components/forms/currency-picker/currency-picker.js +1 -0
- package/dist/components/forms/currency-picker/currency-picker.styles.d.ts +1 -0
- package/dist/components/forms/currency-picker/currency-picker.styles.js +1 -0
- package/dist/components/forms/currency-picker/currency-presentation.d.ts +3 -0
- package/dist/components/forms/currency-picker/currency-presentation.js +1 -0
- package/dist/components/forms/currency-picker/currency-types.d.ts +3 -0
- package/dist/components/forms/index.d.ts +1 -1
- package/dist/components/forms/index.js +1 -1
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +37 -11
- package/dist/components/forms/locale-picker/locale-picker.class.js +43 -8
- package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
- package/dist/components/forms/select/select.class.d.ts +9 -2
- package/dist/components/forms/select/select.class.js +2 -2
- package/dist/components/forms/select/select.styles.js +1 -1
- package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +40 -0
- package/dist/components/forms/time-zone-picker/time-zone-picker.class.js +1 -0
- package/dist/components/forms/time-zone-picker/time-zone-picker.d.ts +1 -0
- package/dist/components/forms/time-zone-picker/time-zone-picker.js +1 -0
- package/dist/components/forms/time-zone-picker/time-zone-picker.styles.d.ts +1 -0
- package/dist/components/forms/time-zone-picker/time-zone-picker.styles.js +1 -0
- package/dist/components/forms/unit-picker/unit-picker.class.d.ts +38 -0
- package/dist/components/forms/unit-picker/unit-picker.class.js +1 -0
- package/dist/components/forms/unit-picker/unit-picker.d.ts +1 -0
- package/dist/components/forms/unit-picker/unit-picker.js +1 -0
- package/dist/components/forms/unit-picker/unit-picker.styles.d.ts +1 -0
- package/dist/components/forms/unit-picker/unit-picker.styles.js +1 -0
- package/dist/components/lr-country-picker.js +1 -0
- package/dist/components/lr-currency-picker.js +1 -0
- package/dist/components/lr-time-zone-picker.js +1 -0
- package/dist/components/lr-unit-picker.js +1 -0
- package/dist/components/overlays/overlay/popover.class.d.ts +6 -5
- package/dist/components/overlays/overlay/popover.class.js +1 -1
- package/dist/countries.d.ts +7 -0
- package/dist/countries.js +1 -0
- package/dist/currency.d.ts +39 -0
- package/dist/currency.js +1 -0
- package/dist/custom-elements-jsx.d.ts +1 -1
- package/dist/events.d.ts +28 -24
- package/dist/framework-types.d.ts +2 -2
- 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/default-strings.generated.d.ts +1 -1
- package/dist/internal/default-strings.generated.js +1 -1
- package/dist/internal/form-associated.d.ts +3 -1
- package/dist/internal/form-associated.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/root-registration-allowlist.d.ts +1 -1
- package/dist/internal/root-registration-allowlist.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/selection-catalog.d.ts +4 -0
- package/dist/internal/selection-catalog.js +1 -0
- 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 +4 -4
- package/dist/ssr.js +1 -1
- package/dist/svelte.d.ts +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/time-zones.d.ts +8 -0
- package/dist/time-zones.js +1 -0
- package/dist/translations/am/forms.js +1 -1
- package/dist/translations/ar/forms.js +1 -1
- package/dist/translations/bho/forms.js +1 -1
- package/dist/translations/bn/forms.js +1 -1
- package/dist/translations/cs/forms.js +1 -1
- package/dist/translations/da/forms.js +1 -1
- package/dist/translations/de/forms.js +1 -1
- package/dist/translations/el/forms.js +1 -1
- package/dist/translations/es/forms.js +1 -1
- package/dist/translations/fa/forms.js +1 -1
- package/dist/translations/fa-AF/forms.js +1 -1
- package/dist/translations/fi/forms.js +1 -1
- package/dist/translations/fr/forms.js +1 -1
- package/dist/translations/gu/forms.js +1 -1
- package/dist/translations/ha/forms.js +1 -1
- package/dist/translations/he/forms.js +1 -1
- package/dist/translations/hi/forms.js +1 -1
- package/dist/translations/hr/forms.js +1 -1
- package/dist/translations/hu/forms.js +1 -1
- package/dist/translations/id/forms.js +1 -1
- package/dist/translations/ig/forms.js +1 -1
- package/dist/translations/it/forms.js +1 -1
- package/dist/translations/ja/forms.js +1 -1
- package/dist/translations/jv/forms.js +1 -1
- package/dist/translations/kk/forms.js +1 -1
- package/dist/translations/kn/forms.js +1 -1
- package/dist/translations/ko/forms.js +1 -1
- package/dist/translations/ln/forms.js +1 -1
- package/dist/translations/ml/forms.js +1 -1
- package/dist/translations/mr/forms.js +1 -1
- package/dist/translations/ms/forms.js +1 -1
- package/dist/translations/my/forms.js +1 -1
- package/dist/translations/nb/forms.js +1 -1
- package/dist/translations/ne/forms.js +1 -1
- package/dist/translations/nl/forms.js +1 -1
- package/dist/translations/nn/forms.js +1 -1
- package/dist/translations/om/forms.js +1 -1
- package/dist/translations/or/forms.js +1 -1
- package/dist/translations/pa/forms.js +1 -1
- package/dist/translations/pcm/forms.js +1 -1
- package/dist/translations/pl/forms.js +1 -1
- package/dist/translations/pnb/forms.js +1 -1
- package/dist/translations/ps/forms.js +1 -1
- package/dist/translations/pt-BR/forms.js +1 -1
- package/dist/translations/pt-PT/forms.js +1 -1
- package/dist/translations/ro/forms.js +1 -1
- package/dist/translations/ru/forms.js +1 -1
- package/dist/translations/sd/forms.js +1 -1
- package/dist/translations/sl/forms.js +1 -1
- package/dist/translations/su/forms.js +1 -1
- package/dist/translations/sv/forms.js +1 -1
- package/dist/translations/sw/forms.js +1 -1
- package/dist/translations/ta/forms.js +1 -1
- package/dist/translations/te/forms.js +1 -1
- package/dist/translations/th/forms.js +1 -1
- package/dist/translations/tl/forms.js +1 -1
- package/dist/translations/tr/forms.js +1 -1
- package/dist/translations/uk/forms.js +1 -1
- package/dist/translations/ur/forms.js +1 -1
- package/dist/translations/uz/forms.js +1 -1
- package/dist/translations/vi/forms.js +1 -1
- package/dist/translations/yo/forms.js +1 -1
- package/dist/translations/zh-CN/forms.js +1 -1
- package/dist/translations/zh-TW/forms.js +1 -1
- package/dist/translations/zu/forms.js +1 -1
- package/dist/units.d.ts +5 -0
- package/dist/units.js +1 -0
- package/dist/vue.d.ts +1 -1
- package/llms/components/lr-button.md +9 -0
- package/llms/components/lr-combobox.md +5 -0
- package/llms/components/lr-country-picker.md +92 -0
- package/llms/components/lr-currency-picker.md +101 -0
- package/llms/components/lr-locale-picker.md +18 -4
- package/llms/components/lr-popover.md +10 -4
- package/llms/components/lr-select.md +29 -0
- package/llms/components/lr-time-zone-picker.md +56 -0
- package/llms/components/lr-unit-picker.md +54 -0
- package/llms/index.md +6 -2
- package/llms/shared/events-and-types.md +16 -0
- package/llms/shared/imports-and-registration.md +1 -1
- package/llms/shared/testing-and-utilities.md +4 -1
- package/llms/shared.md +21 -2
- package/llms.txt +1 -1
- package/locales.json +138 -138
- package/package.json +55 -3
- package/registrations.json +1 -1
- package/vscode-html-data.json +1 -1
- package/web-types.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";import{glassSurface}from"../../../internal/glass-surface.styles.js";import{glassScrollLayerStyles}from"../../../internal/glass-scroll-layer.styles.js";import{glassIndependentRootStyles}from"../../../internal/glass-independent-root.styles.js";import{formControlFocusHalo,formControlRequiredMarker}from"../../../internal/form-control.styles.js";import{overlaySurface,overlaySurfaceControlEdge}from"../../../internal/overlay-surface.styles.js";const styles=css` :host { display: block; --_lr-select-trigger-padding: var(--lr-form-control-padding-block) var(--lr-form-control-padding-inline); --_lr-select-trigger-min-height: var(--lr-form-control-height); --_lr-select-font-size: var(--lr-form-control-font-size); --_lr-select-expand-size: min( var(--lr-size-1-75rem), max(0px, calc(var(--lr-form-control-height) - 2 * var(--lr-form-control-padding-block) - 2 * var(--lr-border-width-thin))) ); --_lr-select-gap: var(--lr-space-xs); --_lr-select-radius: var(--lr-form-control-radius); --_lr-select-tag-padding: var(--lr-space-2xs) var(--lr-space-xs); --_lr-select-tag-font-size: var(--lr-font-size-sm); --_lr-form-control-focus-shadow: var(--lr-form-control-focus-shadow, none); } :host([size="2xs"]), :host([size="xs"]) { --_lr-select-expand-size: var(--lr-size-1rem); } :host([size="s"]), :host([size="small"]) { --_lr-select-expand-size: var(--lr-size-1-25rem); } [part="form-control-label"] { display: block; margin-block-end: var(--lr-space-xs); font-size: var(--lr-font-size-md-sm); font-weight: var(--lr-font-weight-semibold); } [part="form-control-label"][hidden] { display: none; } ${formControlRequiredMarker} :host([pill]) { --_lr-select-radius: var(--lr-radius-pill); } :host([filled]) [part="trigger"] { background: var(--lr-select-trigger-fill, var(--lr-color-surface-raised)); border-color: var(--lr-select-trigger-border-color, transparent); } .control { position: relative; display: grid; } .control > [part="trigger"], .control > [part="tags"] { grid-area: 1 / 1; } [part="trigger"] { display: flex; align-items: center; justify-content: space-between; gap: var(--lr-select-gap, var(--_lr-select-gap)); inline-size: 100%; min-inline-size: 0; min-block-size: var( --lr-select-trigger-height, var(--lr-select-trigger-min-height, var(--_lr-select-trigger-min-height)) ); box-sizing: border-box; block-size: var(--lr-select-trigger-height, auto); padding: var( --lr-select-trigger-padding, var(--_lr-select-trigger-padding) ); border: var(--lr-border-width-thin) solid var(--lr-select-trigger-border-color, var(--lr-color-border)); border-radius: var(--lr-select-radius, var(--_lr-select-radius)); background: var(--lr-select-trigger-fill, var(--lr-color-surface)); color: inherit; font: inherit; font-size: var(--lr-select-font-size, var(--_lr-select-font-size)); text-align: start; cursor: pointer; } [part="trigger"]:focus-visible { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } [part="trigger"]:focus { ${formControlFocusHalo} } :where([part="trigger"]):hover:where(:not(:disabled)) { background: var(--lr-select-trigger-hover-bg, var(--lr-color-brand-quiet)); border-color: var( --lr-select-trigger-hover-border-color, var(--lr-select-trigger-border-color, var(--lr-color-border)) ); } :where([part="trigger"]):active:where(:not(:disabled)) { background: var( --lr-select-trigger-active-bg, color-mix( in oklab, var(--lr-select-trigger-hover-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); } :host([appearance="filled"]) [part="trigger"] { background: var(--lr-select-trigger-fill, var(--lr-color-surface-raised)); border-color: var(--lr-select-trigger-border-color, transparent); } :host([appearance="filled-outlined"]) [part="trigger"] { background: var(--lr-select-trigger-fill, var(--lr-color-surface-raised)); } :host([appearance="plain"]) [part="trigger"] { background: var(--lr-select-trigger-fill, transparent); border-color: var(--lr-select-trigger-border-color, transparent); } :host([appearance="accent"]) [part="trigger"] { background: var(--lr-select-trigger-fill, var(--lr-color-brand)); border-color: var(--lr-select-trigger-border-color, transparent); color: var(--lr-color-on-brand); } :host([appearance="accent"]) [part="trigger"] .trigger-label[data-placeholder], :host([appearance="accent"]) [part="trigger"] [part="expand-icon"], :host([appearance="accent"]) [part="trigger"] [part="start"], :host([appearance="accent"]) [part="trigger"] [part="end"] { color: inherit; } :host([appearance="accent"]) [part~="tag"] { background: color-mix(in srgb, currentColor 20%, transparent); } :host([appearance="filled"]) :where([part="trigger"]):hover:where(:not(:disabled)), :host([appearance="filled-outlined"]) :where([part="trigger"]):hover:where(:not(:disabled)), :host([filled]) :where([part="trigger"]):hover:where(:not(:disabled)), :host([appearance="plain"]) :where([part="trigger"]):hover:where(:not(:disabled)) { background: var(--lr-select-trigger-hover-bg, var(--lr-color-brand-quiet)); border-color: var( --lr-select-trigger-hover-border-color, var(--lr-select-trigger-border-color, transparent) ); } :host([appearance="filled-outlined"]) :where([part="trigger"]):hover:where(:not(:disabled)) { border-color: var( --lr-select-trigger-hover-border-color, var(--lr-select-trigger-border-color, var(--lr-color-border)) ); } :host([appearance="filled"]) :where([part="trigger"]):active:where(:not(:disabled)), :host([appearance="filled-outlined"]) :where([part="trigger"]):active:where(:not(:disabled)), :host([filled]) :where([part="trigger"]):active:where(:not(:disabled)), :host([appearance="plain"]) :where([part="trigger"]):active:where(:not(:disabled)) { background: var( --lr-select-trigger-active-bg, color-mix( in oklab, var(--lr-select-trigger-hover-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); } :host([appearance="accent"]) :where([part="trigger"]):hover:where(:not(:disabled)) { background: var( --lr-select-trigger-hover-bg, color-mix( in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-hover) ) ); border-color: var( --lr-select-trigger-hover-border-color, var(--lr-select-trigger-border-color, transparent) ); } :host([appearance="accent"]) :where([part="trigger"]):active:where(:not(:disabled)) { background: var( --lr-select-trigger-active-bg, color-mix( in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); } :host([open]) [part="trigger"] { border-color: var(--lr-select-open-border-color, var(--lr-color-brand)); ${formControlFocusHalo} } :host(:disabled) [part="trigger"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="start"], [part="end"] { flex: 0 0 auto; display: inline-flex; align-items: center; color: var(--lr-color-text-quiet); pointer-events: none; } [part="start"][hidden], [part="end"][hidden] { display: none; } .trigger-label { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .trigger-label[data-placeholder] { color: var(--lr-color-text-quiet); } [part="tags"] { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center; gap: var(--lr-space-2xs); min-inline-size: 0; } .control > [part="tags"] { z-index: var(--lr-layer-content); align-self: center; margin-inline-start: var(--lr-form-control-padding-inline); margin-inline-end: calc( var(--lr-select-expand-size, var(--_lr-select-expand-size)) + var(--lr-form-control-padding-inline) ); padding-block: var(--lr-form-control-padding-block); pointer-events: none; } [part~="tag"] { display: inline-flex; align-items: center; box-sizing: border-box; max-inline-size: min(100%, var(--tag-max-size, var(--lr-size-12rem))); padding: var(--lr-select-tag-padding, var(--_lr-select-tag-padding)); border-radius: var(--lr-radius-xs); background: var(--lr-color-surface-raised); font-size: var(--lr-select-tag-font-size, var(--_lr-select-tag-font-size)); line-height: var(--lr-line-height-none); pointer-events: auto; } [part="tag-label"] { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } [part~="tag-overflow"] { color: var(--lr-color-text-quiet); white-space: nowrap; } [part~="tag__remove-button"] { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; min-inline-size: var(--lr-icon-button-size); min-block-size: var(--lr-icon-button-size); margin-block: calc(var(--lr-space-2xs) * -1); margin-inline-end: calc(var(--lr-space-xs) * -1); padding: var(--lr-space-2xs); border: none; border-radius: var(--lr-radius-xs); background: transparent; color: var(--lr-color-text-quiet); font: inherit; cursor: pointer; } [part~="tag__remove-button"]:hover { color: var(--lr-color-text); background: var(--lr-select-tag-remove-hover-bg, var(--lr-color-brand-quiet)); } [part~="tag__remove-button"]:active { background: color-mix( in oklab, var(--lr-select-tag-remove-hover-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part~="tag__remove-button"]:focus-visible { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } [part~="tag__remove-button"]:disabled { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="clear-button"] { position: absolute; z-index: var(--lr-layer-content); inset-inline-end: 0; inset-block-start: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-inline-size: var(--lr-icon-button-size); min-block-size: var(--lr-icon-button-size); padding: var(--lr-space-2xs); border: none; border-radius: var(--lr-select-radius, var(--_lr-select-radius)); background: none; color: var(--lr-color-text-quiet); font: inherit; line-height: var(--lr-line-height-none); cursor: pointer; } .control[data-clearable] [part="trigger"] { padding-inline-end: var(--lr-icon-button-size); } [part="clear-button"]:hover { color: var(--lr-color-text); } [part="clear-button"]:active { color: var(--lr-color-text); background: color-mix( in oklab, var(--lr-color-surface), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part="clear-button"]:focus-visible { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } [part="clear-button"]:disabled { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="expand-icon"] { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; color: var(--lr-color-text-quiet); min-inline-size: min( var(--lr-icon-button-size), var(--lr-select-expand-size, var(--_lr-select-expand-size)) ); min-block-size: min( var(--lr-icon-button-size), var(--lr-select-expand-size, var(--_lr-select-expand-size)) ); line-height: var(--lr-line-height-none); } [part="expand-icon"] svg { transform: rotate(90deg); } [part="listbox"][hidden] { display: none; } [part="listbox"] { position: absolute; z-index: var(--lr-overlay-stack-index, var(--lr-layer-dropdown)); box-sizing: border-box; max-block-size: var(--lr-size-18rem); overflow-y: auto; overflow-x: hidden; inline-size: max-content; padding: var(--lr-space-xs); ${overlaySurface} ${overlaySurfaceControlEdge} box-shadow: var(--lr-overlay-shadow-anchored, var(--lr-shadow-m)); visibility: hidden; opacity: 0; transform: translateY(var(--lr-size-neg-0-25rem)); transition: opacity var(--hide-duration, var(--lr-transition-fast)), transform var(--hide-duration, var(--lr-transition-fast)), visibility var(--hide-duration, var(--lr-transition-fast)); } :host(:not([sync="width"]):not([sync="both"])) [part="listbox"] { min-inline-size: var(--lr-size-12rem); max-inline-size: min( var(--lr-popover-viewport-clamp), var(--lr-size-28rem) ); } :host([sync="width"]) [part="listbox"], :host([sync="both"]) [part="listbox"] { max-inline-size: var(--lr-positioner-available-inline-size, 100vw); } :host([hoist]) [part="listbox"] { position: fixed; } :host([open]) [part="listbox"][data-positioned] { visibility: visible; opacity: 1; transform: translateY(0); transition: opacity var(--show-duration, var(--lr-transition-fast)), transform var(--show-duration, var(--lr-transition-fast)), visibility var(--show-duration, var(--lr-transition-fast)); } :host(:disabled) [part="listbox"] { visibility: hidden; opacity: 0; pointer-events: none; transition: none; } @media (prefers-reduced-motion: reduce) { [part="listbox"] { transition: none !important; } } [part="option"] { display: flex; flex-direction: row; align-items: center; gap: var(--lr-space-xs); inline-size: 100%; padding: var(--lr-space-xs) var(--lr-space-s); border: var(--lr-border-width-thin) solid transparent; border-radius: var(--lr-radius); background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; } [part="option"][aria-selected="true"] { background: var(--lr-select-option-selected-bg, transparent); border-color: var( --lr-select-option-selected-border, var(--lr-color-brand) ); color: var(--lr-select-option-selected-color, var(--lr-color-brand)); font-weight: var( --lr-select-option-selected-font-weight, var(--lr-font-weight-semibold) ); } [part="option"]:where(:not([aria-disabled="true"])):hover, [part="option"][data-active] { background: var(--lr-select-option-active-bg, var(--lr-color-brand-quiet)); } [part="option"]:where(:not([aria-disabled="true"])):active { background: color-mix( in oklab, var(--lr-select-option-active-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part="option"][aria-disabled="true"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="option-dot"] { inline-size: var(--lr-size-0-5rem); block-size: var(--lr-size-0-5rem); border-radius: 50%; flex: 0 0 auto; } [part="option-start"], [part="option-end"] { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; max-inline-size: 40%; overflow: hidden; } [part="option-start"] > *, [part="option-end"] > * { min-inline-size: 0; max-inline-size: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } [part="option-label"] { display: flex; flex-direction: column; min-inline-size: 0; } [part="option-sub"] { font-size: var(--lr-font-size-xs); color: var(--lr-color-text-quiet); } .trigger-label[data-unknown-value], [part~="tag"][data-unknown-value] [part="tag__content"] { font-style: italic; } [part~="tag"][data-unknown-value] { border: var(--lr-border-width-thin) var(--lr-select-unknown-value-border-style, dashed) var(--lr-select-unknown-value-border-color, var(--lr-color-border)); } [part~="option"][data-unknown-value] [part="option-label"] { font-style: italic; } [part~="option"][data-unknown-value] { border: var(--lr-border-width-thin) var(--lr-select-unknown-value-border-style, dashed) var(--lr-select-unknown-value-border-color, var(--lr-color-border)); } [part="option-badge"] { flex: 0 0 auto; margin-inline-start: auto; padding: 0 var(--lr-space-xs); border-radius: var(--lr-radius-pill); background: var(--lr-select-option-badge-bg, var(--lr-color-brand-quiet)); color: var(--lr-color-text); font-size: var(--lr-font-size-xs); font-style: normal; } [part="unknown-value"] { margin-inline-start: var(--lr-space-2xs); font-size: var(--lr-size-0-6875rem); font-style: normal; font-weight: var(--lr-font-weight-normal); color: var(--lr-color-text-quiet); } [part="form-control"], [part="form-control-label"], [part~="hint"], [part="error"] { min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; } [part="option"] { box-sizing: border-box; min-inline-size: 0; max-inline-size: 100%; } [part="option-label"] { max-inline-size: 100%; overflow-wrap: anywhere; } [part="option-sub"], .group-label { overflow-wrap: anywhere; } .group-label { padding: var(--lr-space-xs) var(--lr-space-s) 0; font-size: var(--lr-size-0-6875rem); font-weight: var(--lr-font-weight-bold); text-transform: uppercase; letter-spacing: var(--lr-size-0-04em); color: var(--lr-color-text-quiet); } [part~="hint"] { margin-block-start: var(--lr-space-xs); font-size: var(--lr-font-size-sm); color: var(--lr-color-text-quiet); } [part~="hint"][hidden] { display: none; } [part="error"] { margin-block-start: var(--lr-space-xs); font-size: var(--lr-font-size-sm); color: var(--lr-color-danger); } [part="error"][hidden] { display: none; } ${glassScrollLayerStyles} ${glassIndependentRootStyles} ${glassSurface('[part="listbox"]',css`var(--lr-overlay-surface, var(--_lr-overlay-surface, var(--lr-color-surface-container-high)))`,void 0,!0)} `;export{styles};
|
|
1
|
+
import{css}from"lit";import{glassSurface}from"../../../internal/glass-surface.styles.js";import{glassScrollLayerStyles}from"../../../internal/glass-scroll-layer.styles.js";import{glassIndependentRootStyles}from"../../../internal/glass-independent-root.styles.js";import{formControlFocusHalo,formControlRequiredMarker}from"../../../internal/form-control.styles.js";import{overlaySurface,overlaySurfaceControlEdge}from"../../../internal/overlay-surface.styles.js";const styles=css` :host { display: block; --_lr-select-trigger-padding: var(--lr-form-control-padding-block) var(--lr-form-control-padding-inline); --_lr-select-trigger-min-height: var(--lr-form-control-height); --_lr-select-font-size: var(--lr-form-control-font-size); --_lr-select-expand-size: min( var(--lr-size-1-75rem), max(0px, calc(var(--lr-form-control-height) - 2 * var(--lr-form-control-padding-block) - 2 * var(--lr-border-width-thin))) ); --_lr-select-gap: var(--lr-space-xs); --_lr-select-radius: var(--lr-form-control-radius); --_lr-select-tag-padding: var(--lr-space-2xs) var(--lr-space-xs); --_lr-select-tag-font-size: var(--lr-font-size-sm); --_lr-form-control-focus-shadow: var(--lr-form-control-focus-shadow, none); } :host([size="2xs"]), :host([size="xs"]) { --_lr-select-expand-size: var(--lr-size-1rem); } :host([size="s"]), :host([size="small"]) { --_lr-select-expand-size: var(--lr-size-1-25rem); } [part="form-control-label"] { display: block; margin-block-end: var(--lr-space-xs); font-size: var(--lr-font-size-md-sm); font-weight: var(--lr-font-weight-semibold); } [part="form-control-label"][hidden] { display: none; } ${formControlRequiredMarker} :host([pill]) { --_lr-select-radius: var(--lr-radius-pill); } :host([filled]) [part="trigger"] { background: var(--lr-select-trigger-fill, var(--lr-color-surface-raised)); border-color: var(--lr-select-trigger-border-color, transparent); } .control { position: relative; display: grid; } .control > [part="trigger"], .control > [part="tags"] { grid-area: 1 / 1; } [part="trigger"] { display: flex; align-items: center; justify-content: space-between; gap: var(--lr-select-gap, var(--_lr-select-gap)); inline-size: 100%; min-inline-size: 0; min-block-size: var( --lr-select-trigger-height, var(--lr-select-trigger-min-height, var(--_lr-select-trigger-min-height)) ); box-sizing: border-box; block-size: var(--lr-select-trigger-height, auto); padding: var( --lr-select-trigger-padding, var(--_lr-select-trigger-padding) ); border: var(--lr-border-width-thin) solid var(--lr-select-trigger-border-color, var(--lr-color-border)); border-radius: var(--lr-select-radius, var(--_lr-select-radius)); background: var(--lr-select-trigger-fill, var(--lr-color-surface)); color: inherit; font: inherit; font-size: var(--lr-select-font-size, var(--_lr-select-font-size)); text-align: start; cursor: pointer; } [part="trigger"]:focus-visible { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } [part="trigger"]:focus { ${formControlFocusHalo} } :where([part="trigger"]):hover:where(:not(:disabled)) { background: var(--lr-select-trigger-hover-bg, var(--lr-color-brand-quiet)); border-color: var( --lr-select-trigger-hover-border-color, var(--lr-select-trigger-border-color, var(--lr-color-border)) ); } :where([part="trigger"]):active:where(:not(:disabled)) { background: var( --lr-select-trigger-active-bg, color-mix( in oklab, var(--lr-select-trigger-hover-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); } :host([appearance="filled"]) [part="trigger"] { background: var(--lr-select-trigger-fill, var(--lr-color-surface-raised)); border-color: var(--lr-select-trigger-border-color, transparent); } :host([appearance="filled-outlined"]) [part="trigger"] { background: var(--lr-select-trigger-fill, var(--lr-color-surface-raised)); } :host([appearance="plain"]) [part="trigger"] { background: var(--lr-select-trigger-fill, transparent); border-color: var(--lr-select-trigger-border-color, transparent); } :host([appearance="accent"]) [part="trigger"] { background: var(--lr-select-trigger-fill, var(--lr-color-brand)); border-color: var(--lr-select-trigger-border-color, transparent); color: var(--lr-color-on-brand); } :host([appearance="accent"]) [part="trigger"] .trigger-label[data-placeholder], :host([appearance="accent"]) [part="trigger"] [part="expand-icon"], :host([appearance="accent"]) [part="trigger"] [part="start"], :host([appearance="accent"]) [part="trigger"] [part="end"] { color: inherit; } :host([appearance="accent"]) [part~="tag"] { background: color-mix(in srgb, currentColor 20%, transparent); } :host([appearance="filled"]) :where([part="trigger"]):hover:where(:not(:disabled)), :host([appearance="filled-outlined"]) :where([part="trigger"]):hover:where(:not(:disabled)), :host([filled]) :where([part="trigger"]):hover:where(:not(:disabled)), :host([appearance="plain"]) :where([part="trigger"]):hover:where(:not(:disabled)) { background: var(--lr-select-trigger-hover-bg, var(--lr-color-brand-quiet)); border-color: var( --lr-select-trigger-hover-border-color, var(--lr-select-trigger-border-color, transparent) ); } :host([appearance="filled-outlined"]) :where([part="trigger"]):hover:where(:not(:disabled)) { border-color: var( --lr-select-trigger-hover-border-color, var(--lr-select-trigger-border-color, var(--lr-color-border)) ); } :host([appearance="filled"]) :where([part="trigger"]):active:where(:not(:disabled)), :host([appearance="filled-outlined"]) :where([part="trigger"]):active:where(:not(:disabled)), :host([filled]) :where([part="trigger"]):active:where(:not(:disabled)), :host([appearance="plain"]) :where([part="trigger"]):active:where(:not(:disabled)) { background: var( --lr-select-trigger-active-bg, color-mix( in oklab, var(--lr-select-trigger-hover-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); } :host([appearance="accent"]) :where([part="trigger"]):hover:where(:not(:disabled)) { background: var( --lr-select-trigger-hover-bg, color-mix( in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-hover) ) ); border-color: var( --lr-select-trigger-hover-border-color, var(--lr-select-trigger-border-color, transparent) ); } :host([appearance="accent"]) :where([part="trigger"]):active:where(:not(:disabled)) { background: var( --lr-select-trigger-active-bg, color-mix( in oklab, var(--lr-color-brand), var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); } :host([open]) [part="trigger"] { border-color: var(--lr-select-open-border-color, var(--lr-color-brand)); ${formControlFocusHalo} } :host(:disabled) [part="trigger"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="start"], [part="end"] { flex: 0 0 auto; display: inline-flex; align-items: center; color: var(--lr-color-text-quiet); pointer-events: none; } [part="start"][hidden], [part="end"][hidden] { display: none; } .trigger-label { flex: 1 1 auto; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .trigger-label[data-placeholder] { color: var(--lr-color-text-quiet); } [part="tags"] { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: center; gap: var(--lr-space-2xs); min-inline-size: 0; } .control > [part="tags"] { z-index: var(--lr-layer-content); align-self: center; margin-inline-start: var(--lr-form-control-padding-inline); margin-inline-end: calc( var(--lr-select-expand-size, var(--_lr-select-expand-size)) + var(--lr-form-control-padding-inline) ); padding-block: var(--lr-form-control-padding-block); pointer-events: none; } [part~="tag"] { display: inline-flex; align-items: center; box-sizing: border-box; max-inline-size: min(100%, var(--tag-max-size, var(--lr-size-12rem))); padding: var(--lr-select-tag-padding, var(--_lr-select-tag-padding)); border-radius: var(--lr-radius-xs); background: var(--lr-color-surface-raised); font-size: var(--lr-select-tag-font-size, var(--_lr-select-tag-font-size)); line-height: var(--lr-line-height-none); pointer-events: auto; } [part="tag-label"] { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } [part~="tag-overflow"] { color: var(--lr-color-text-quiet); white-space: nowrap; } [part~="tag__remove-button"] { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; min-inline-size: var(--lr-icon-button-size); min-block-size: var(--lr-icon-button-size); margin-block: calc(var(--lr-space-2xs) * -1); margin-inline-end: calc(var(--lr-space-xs) * -1); padding: var(--lr-space-2xs); border: none; border-radius: var(--lr-radius-xs); background: transparent; color: var(--lr-color-text-quiet); font: inherit; cursor: pointer; } [part~="tag__remove-button"]:hover { color: var(--lr-color-text); background: var(--lr-select-tag-remove-hover-bg, var(--lr-color-brand-quiet)); } [part~="tag__remove-button"]:active { background: color-mix( in oklab, var(--lr-select-tag-remove-hover-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part~="tag__remove-button"]:focus-visible { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } [part~="tag__remove-button"]:disabled { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="clear-button"] { position: absolute; z-index: var(--lr-layer-content); inset-inline-end: 0; inset-block-start: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-inline-size: var(--lr-icon-button-size); min-block-size: var(--lr-icon-button-size); padding: var(--lr-space-2xs); border: none; border-radius: var(--lr-select-radius, var(--_lr-select-radius)); background: none; color: var(--lr-color-text-quiet); font: inherit; line-height: var(--lr-line-height-none); cursor: pointer; } .control[data-clearable] [part="trigger"] { padding-inline-end: var(--lr-icon-button-size); } [part="clear-button"]:hover { color: var(--lr-color-text); } [part="clear-button"]:active { color: var(--lr-color-text); background: color-mix( in oklab, var(--lr-color-surface), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part="clear-button"]:focus-visible { outline: var(--lr-focus-ring-width) solid var(--lr-focus-ring-color); outline-offset: var(--lr-focus-ring-offset); } [part="clear-button"]:disabled { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="expand-icon"] { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; color: var(--lr-color-text-quiet); min-inline-size: min( var(--lr-icon-button-size), var(--lr-select-expand-size, var(--_lr-select-expand-size)) ); min-block-size: min( var(--lr-icon-button-size), var(--lr-select-expand-size, var(--_lr-select-expand-size)) ); line-height: var(--lr-line-height-none); } [part="expand-icon"] svg { transform: rotate(90deg); } [part="listbox"][hidden] { display: none; } [part="listbox"] { position: absolute; z-index: var(--lr-overlay-stack-index, var(--lr-layer-dropdown)); box-sizing: border-box; max-block-size: min( var(--lr-size-18rem), var(--lr-positioner-available-block-size, var(--lr-size-18rem)) ); overflow-y: auto; overflow-x: hidden; inline-size: max-content; padding: var(--lr-space-xs); ${overlaySurface} ${overlaySurfaceControlEdge} box-shadow: var(--lr-overlay-shadow-anchored, var(--lr-shadow-m)); visibility: hidden; opacity: 0; transform: translateY(var(--lr-size-neg-0-25rem)); transition: opacity var(--hide-duration, var(--lr-transition-fast)), transform var(--hide-duration, var(--lr-transition-fast)), visibility var(--hide-duration, var(--lr-transition-fast)); } :host(:not([sync="width"]):not([sync="both"])) [part="listbox"] { min-inline-size: min( var(--lr-size-12rem), var(--lr-positioner-available-inline-size, var(--lr-size-12rem)) ); max-inline-size: min( var(--lr-popover-viewport-clamp), var(--lr-size-28rem) ); } :host([sync="width"]) [part="listbox"], :host([sync="both"]) [part="listbox"] { max-inline-size: var(--lr-positioner-available-inline-size, 100vw); } :host([hoist]) [part="listbox"] { position: fixed; } :host([open]) [part="listbox"][data-positioned] { visibility: visible; opacity: 1; transform: translateY(0); transition: opacity var(--show-duration, var(--lr-transition-fast)), transform var(--show-duration, var(--lr-transition-fast)), visibility var(--show-duration, var(--lr-transition-fast)); } :host(:disabled) [part="listbox"] { visibility: hidden; opacity: 0; pointer-events: none; transition: none; } @media (prefers-reduced-motion: reduce) { [part="listbox"] { transition: none !important; } } [part="option"] { display: flex; flex-direction: row; align-items: center; gap: var(--lr-space-xs); inline-size: 100%; padding: var(--lr-space-xs) var(--lr-space-s); border: var(--lr-border-width-thin) solid transparent; border-radius: var(--lr-radius); background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; } [part="option"][aria-selected="true"] { background: var(--lr-select-option-selected-bg, transparent); border-color: var( --lr-select-option-selected-border, var(--lr-color-brand) ); color: var(--lr-select-option-selected-color, var(--lr-color-brand)); font-weight: var( --lr-select-option-selected-font-weight, var(--lr-font-weight-semibold) ); } [part="option"]:where(:not([aria-disabled="true"])):hover, [part="option"][data-active] { background: var(--lr-select-option-active-bg, var(--lr-color-brand-quiet)); } [part="option"]:where(:not([aria-disabled="true"])):active { background: color-mix( in oklab, var(--lr-select-option-active-bg, var(--lr-color-brand-quiet)), var(--lr-color-mix-partner) var(--lr-color-mix-active) ); } [part="option"][aria-disabled="true"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } [part="option-dot"] { inline-size: var(--lr-size-0-5rem); block-size: var(--lr-size-0-5rem); border-radius: 50%; flex: 0 0 auto; } [part="option-start"], [part="option-end"] { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; max-inline-size: 40%; overflow: hidden; } [part="option-start"] > *, [part="option-end"] > * { min-inline-size: 0; max-inline-size: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } [part="option-label"] { display: flex; flex-direction: column; min-inline-size: 0; } [part="option-sub"] { font-size: var(--lr-font-size-xs); color: var(--lr-color-text-quiet); } .trigger-label[data-unknown-value], [part~="tag"][data-unknown-value] [part="tag__content"] { font-style: italic; } [part~="tag"][data-unknown-value] { border: var(--lr-border-width-thin) var(--lr-select-unknown-value-border-style, dashed) var(--lr-select-unknown-value-border-color, var(--lr-color-border)); } [part~="option"][data-unknown-value] [part="option-label"] { font-style: italic; } [part~="option"][data-unknown-value] { border: var(--lr-border-width-thin) var(--lr-select-unknown-value-border-style, dashed) var(--lr-select-unknown-value-border-color, var(--lr-color-border)); } [part="option-badge"] { flex: 0 0 auto; margin-inline-start: auto; padding: 0 var(--lr-space-xs); border-radius: var(--lr-radius-pill); background: var(--lr-select-option-badge-bg, var(--lr-color-brand-quiet)); color: var(--lr-color-text); font-size: var(--lr-font-size-xs); font-style: normal; } [part="unknown-value"] { margin-inline-start: var(--lr-space-2xs); font-size: var(--lr-size-0-6875rem); font-style: normal; font-weight: var(--lr-font-weight-normal); color: var(--lr-color-text-quiet); } [part="form-control"], [part="form-control-label"], [part~="hint"], [part="error"] { min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; } [part="option"] { box-sizing: border-box; min-inline-size: 0; max-inline-size: 100%; } [part="option-label"] { max-inline-size: 100%; overflow-wrap: anywhere; } [part="option-sub"], .group-label { overflow-wrap: anywhere; } .group-label { padding: var(--lr-space-xs) var(--lr-space-s) 0; font-size: var(--lr-size-0-6875rem); font-weight: var(--lr-font-weight-bold); text-transform: uppercase; letter-spacing: var(--lr-size-0-04em); color: var(--lr-color-text-quiet); } [part~="hint"] { margin-block-start: var(--lr-space-xs); font-size: var(--lr-font-size-sm); color: var(--lr-color-text-quiet); } [part~="hint"][hidden] { display: none; } [part="error"] { margin-block-start: var(--lr-space-xs); font-size: var(--lr-font-size-sm); color: var(--lr-color-danger); } [part="error"][hidden] { display: none; } ${glassScrollLayerStyles} ${glassIndependentRootStyles} ${glassSurface('[part="listbox"]',css`var(--lr-overlay-surface, var(--_lr-overlay-surface, var(--lr-color-surface-container-high)))`,void 0,!0)} `;export{styles};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import{type SelectionCatalogRow}from'../../../internal/selection-catalog.js';import{type LyraTimeZoneCatalog,type LyraTimeZoneEntry}from'../../../time-zones.js';import{LyraCatalogPickerBase,type LyraCatalogPickerChangeDetail,type LyraCatalogPickerEventMap}from'../catalog-picker-base.js';export type{LyraTimeZoneCatalog,LyraTimeZoneEntry}from'../../../time-zones.js';export type LyraTimeZoneChangeDetail=LyraCatalogPickerChangeDetail;export interface LyraTimeZonePickerEventMap extends LyraCatalogPickerEventMap{}
|
|
2
|
+
/**
|
|
3
|
+
* `<lr-time-zone-picker>` — a form-associated time-zone identifier selector.
|
|
4
|
+
* Defaults to UTC and the runtime's supported IANA identifiers without choosing a zone.
|
|
5
|
+
* Default labels retain the identifier, replacing underscores with spaces for readability.
|
|
6
|
+
* Supply an explicit catalog to keep server and client inventories identical.
|
|
7
|
+
* Opt-in searchable filters identifiers and labels without changing the committed form value.
|
|
8
|
+
* Catalogs preserve caller order and contiguous groups. Identifiers are trimmed, case-sensitive
|
|
9
|
+
* and never canonicalized. Unavailable or disabled values remain visible and invalid.
|
|
10
|
+
* Programmatic changes and reset emit no selection events. Selection does not change the
|
|
11
|
+
* application's time zone or calculate offsets, clocks or daylight-saving transitions.
|
|
12
|
+
*
|
|
13
|
+
* @customElement lr-time-zone-picker
|
|
14
|
+
* @slot label - Custom field label.
|
|
15
|
+
* @slot hint - Custom field guidance.
|
|
16
|
+
* @slot error - Custom validation guidance.
|
|
17
|
+
* @csspart form-control - The field wrapper.
|
|
18
|
+
* @csspart form-control-label - The field label.
|
|
19
|
+
* @csspart select-trigger - The visible trigger or filter frame.
|
|
20
|
+
* @csspart select-display-input - The committed name or optional filter input.
|
|
21
|
+
* @csspart select-listbox - The offered time zones.
|
|
22
|
+
* @csspart select-option - A time-zone option.
|
|
23
|
+
* @csspart select-option-sub - The time-zone identifier.
|
|
24
|
+
* @csspart select-group-label - A caller-provided group heading.
|
|
25
|
+
* @csspart select-clear-button - The optional clear action.
|
|
26
|
+
* @csspart hint - Field guidance.
|
|
27
|
+
* @csspart error - Validation guidance.
|
|
28
|
+
* @event {Event} input - User selection changed the committed value and form state.
|
|
29
|
+
* @event lr-input - User selection changed the committed value.
|
|
30
|
+
* @event {Event} change - Fired once after a user selection or clear.
|
|
31
|
+
* @event lr-change - User selection changed the committed value.
|
|
32
|
+
* @event lr-invalid - Native invalid alias. Cancelable: preventDefault suppresses validation UI.
|
|
33
|
+
* @event {FocusEvent} focus - Re-dispatched from the visible control, bubbling and composed.
|
|
34
|
+
* @event {FocusEvent} blur - Re-dispatched from the visible control, bubbling and composed.
|
|
35
|
+
* @status experimental
|
|
36
|
+
* @since 25.5.0
|
|
37
|
+
*/
|
|
38
|
+
export declare class LyraTimeZonePicker extends LyraCatalogPickerBase{static styles:import("lit").CSSResultGroup[];private readonly defaultEntries;private _timeZones?;
|
|
39
|
+
/** Clone-owned ordered catalog, capped at 1024 rows. Undefined/null restores runtime defaults; [] stays empty. */
|
|
40
|
+
get timeZones():LyraTimeZoneCatalog|undefined;set timeZones(value:LyraTimeZoneCatalog|null|undefined);protected get entries():readonly LyraTimeZoneEntry[];protected get pickerLabel():string;protected resolveRows():readonly SelectionCatalogRow[];}declare global{interface HTMLElementTagNameMap{'lr-time-zone-picker':LyraTimeZonePicker;}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__decorate}from"tslib";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{normalizeSelectionValue,snapshotSelectionCatalog}from"../../../internal/selection-catalog.js";import{getTimeZoneCodes}from"../../../time-zones.js";import{LyraCatalogPickerBase}from"../catalog-picker-base.js";import{styles}from"./time-zone-picker.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_restore,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_tableLoadFailed,LYRA_DEFAULT_timeZonePickerLabel}from"../../../internal/default-strings.generated.js";class LyraTimeZonePicker extends LyraCatalogPickerBase{constructor(){super(...arguments),this.defaultEntries=Object.freeze(getTimeZoneCodes().map(code=>Object.freeze({code})))}static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,notInCatalog:LYRA_DEFAULT_notInCatalog,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,restore:LYRA_DEFAULT_restore,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,tableLoadFailed:LYRA_DEFAULT_tableLoadFailed,timeZonePickerLabel:LYRA_DEFAULT_timeZonePickerLabel}}static{this.styles=[LyraElement.styles,styles]}get timeZones(){return this._timeZones}set timeZones(value){const previous=this._timeZones;this._timeZones=snapshotSelectionCatalog(value,normalizeSelectionValue),this.updateValidity(),this.requestUpdate("timeZones",previous)}get entries(){return this._timeZones??this.defaultEntries}get pickerLabel(){return this.localize("timeZonePickerLabel")}resolveRows(){return Object.freeze(this.entries.map(entry=>{const readableName=entry.code.replace(/_/g," "),label=entry.label??readableName;return Object.freeze({...entry,label,searchText:[entry.code,readableName,label].join(" ")})}))}}__decorate([property({attribute:!1})],LyraTimeZonePicker.prototype,"timeZones",null);export{LyraTimeZonePicker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from'./time-zone-picker.class.js';import'../select/select.js';import'../combobox/combobox.js';import'../combobox/option.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./time-zone-picker.class.js";import{LyraTimeZonePicker}from"./time-zone-picker.class.js";import{defineElement}from"../../../internal/prefix.js";import"../select/select.js";import"../combobox/combobox.js";import"../combobox/option.js";defineElement("time-zone-picker",LyraTimeZonePicker);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{styles}from'../catalog-picker-base.styles.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{styles}from"../catalog-picker-base.styles.js";export{styles};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import{type SelectionCatalogRow}from'../../../internal/selection-catalog.js';import{type LyraUnitCatalog,type LyraUnitEntry}from'../../../units.js';import{LyraCatalogPickerBase,type LyraCatalogPickerChangeDetail,type LyraCatalogPickerEventMap}from'../catalog-picker-base.js';export type{LyraUnitCatalog,LyraUnitEntry}from'../../../units.js';export type LyraUnitChangeDetail=LyraCatalogPickerChangeDetail;export interface LyraUnitPickerEventMap extends LyraCatalogPickerEventMap{}
|
|
2
|
+
/**
|
|
3
|
+
* `<lr-unit-picker>` — a form-associated measurement-unit identifier selector.
|
|
4
|
+
* Defaults to the standard ECMA-402 simple measurement units with localized names and symbols.
|
|
5
|
+
* Caller catalogs may include custom or compound identifiers with explicit display text.
|
|
6
|
+
* Opt-in searchable filters identifiers, names and symbols without changing the committed value.
|
|
7
|
+
* Catalogs preserve caller order and contiguous groups. Identifiers are trimmed and retain case.
|
|
8
|
+
* Unavailable or disabled values remain visible and invalid. Programmatic changes, locale
|
|
9
|
+
* changes and reset emit no selection events. Selection does not convert or edit measurements.
|
|
10
|
+
*
|
|
11
|
+
* @customElement lr-unit-picker
|
|
12
|
+
* @slot label - Custom field label.
|
|
13
|
+
* @slot hint - Custom field guidance.
|
|
14
|
+
* @slot error - Custom validation guidance.
|
|
15
|
+
* @csspart form-control - The field wrapper.
|
|
16
|
+
* @csspart form-control-label - The field label.
|
|
17
|
+
* @csspart select-trigger - The visible trigger or filter frame.
|
|
18
|
+
* @csspart select-display-input - The committed name or optional filter input.
|
|
19
|
+
* @csspart select-listbox - The offered measurement units.
|
|
20
|
+
* @csspart select-option - A measurement-unit option.
|
|
21
|
+
* @csspart select-option-sub - The unit identifier and symbol.
|
|
22
|
+
* @csspart select-group-label - A caller-provided group heading.
|
|
23
|
+
* @csspart select-clear-button - The optional clear action.
|
|
24
|
+
* @csspart hint - Field guidance.
|
|
25
|
+
* @csspart error - Validation guidance.
|
|
26
|
+
* @event {Event} input - User selection changed the committed value and form state.
|
|
27
|
+
* @event lr-input - User selection changed the committed value.
|
|
28
|
+
* @event {Event} change - Fired once after a user selection or clear.
|
|
29
|
+
* @event lr-change - User selection changed the committed value.
|
|
30
|
+
* @event lr-invalid - Native invalid alias. Cancelable: preventDefault suppresses validation UI.
|
|
31
|
+
* @event {FocusEvent} focus - Re-dispatched from the visible control, bubbling and composed.
|
|
32
|
+
* @event {FocusEvent} blur - Re-dispatched from the visible control, bubbling and composed.
|
|
33
|
+
* @status experimental
|
|
34
|
+
* @since 25.5.0
|
|
35
|
+
*/
|
|
36
|
+
export declare class LyraUnitPicker extends LyraCatalogPickerBase{static styles:import("lit").CSSResultGroup[];private _units?;
|
|
37
|
+
/** Clone-owned ordered catalog, capped at 1024 rows. Undefined/null restores standard defaults; [] stays empty. */
|
|
38
|
+
get units():LyraUnitCatalog|undefined;set units(value:LyraUnitCatalog|null|undefined);protected get entries():readonly LyraUnitEntry[];protected get pickerLabel():string;protected resolveRows():readonly SelectionCatalogRow[];}declare global{interface HTMLElementTagNameMap{'lr-unit-picker':LyraUnitPicker;}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__decorate}from"tslib";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{normalizeSelectionValue,snapshotSelectionCatalog}from"../../../internal/selection-catalog.js";import{UNIT_CODES,resolveUnitNames}from"../../../units.js";import{LyraCatalogPickerBase}from"../catalog-picker-base.js";import{styles}from"./unit-picker.styles.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_restore,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_tableLoadFailed,LYRA_DEFAULT_unitPickerLabel}from"../../../internal/default-strings.generated.js";const defaultEntries=Object.freeze(UNIT_CODES.map(code=>Object.freeze({code})));class LyraUnitPicker extends LyraCatalogPickerBase{static{this.defaultStrings={...super.defaultStrings,collapse:LYRA_DEFAULT_collapse,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,notInCatalog:LYRA_DEFAULT_notInCatalog,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,restore:LYRA_DEFAULT_restore,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,tableLoadFailed:LYRA_DEFAULT_tableLoadFailed,unitPickerLabel:LYRA_DEFAULT_unitPickerLabel}}static{this.styles=[LyraElement.styles,styles]}get units(){return this._units}set units(value){const previous=this._units;this._units=snapshotSelectionCatalog(value,normalizeSelectionValue),this.updateValidity(),this.requestUpdate("units",previous)}get entries(){return this._units??defaultEntries}get pickerLabel(){return this.localize("unitPickerLabel")}resolveRows(){return resolveUnitNames(this.entries,this.effectiveLocale)}}__decorate([property({attribute:!1})],LyraUnitPicker.prototype,"units",null);export{LyraUnitPicker};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from'./unit-picker.class.js';import'../select/select.js';import'../combobox/combobox.js';import'../combobox/option.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./unit-picker.class.js";import{LyraUnitPicker}from"./unit-picker.class.js";import{defineElement}from"../../../internal/prefix.js";import"../select/select.js";import"../combobox/combobox.js";import"../combobox/option.js";defineElement("unit-picker",LyraUnitPicker);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{styles}from'../catalog-picker-base.styles.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{styles}from"../catalog-picker-base.styles.js";export{styles};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./forms/country-picker/country-picker.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./forms/currency-picker/currency-picker.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./forms/time-zone-picker/time-zone-picker.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"./forms/unit-picker/unit-picker.js";
|
|
@@ -50,9 +50,10 @@ export interface LyraPopoverEventMap{'lr-show':CustomEvent<null>;'lr-after-show'
|
|
|
50
50
|
* pointer travelling from the trigger to the popup never leaves both at once.
|
|
51
51
|
*
|
|
52
52
|
* Interaction/ARIA ownership is resolved separately from positioning. A slotted trigger wins and
|
|
53
|
-
* receives the click listener
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* receives the click listener; without one, a live HTML element resolved by `for` owns interaction.
|
|
54
|
+
* Only its semantic composed focus target receives `aria-haspopup`, `aria-expanded`, and
|
|
55
|
+
* `aria-controls`, and becomes the focus-return target. Generic wrapper hosts receive no generated
|
|
56
|
+
* trigger ARIA. Native controls and authored roles supporting expansion retain their own state. A
|
|
56
57
|
* direct `.anchor` is positioning-only. `showAt()`'s virtual anchor wins positioning and
|
|
57
58
|
* deliberately has no DOM interaction/ARIA owner while active.
|
|
58
59
|
* The component supplies the real shadow popup to the shared relationship controller. Current
|
|
@@ -290,7 +291,7 @@ private popupHidden;
|
|
|
290
291
|
* queues disconnect then connect on this element; a nested DOM operation inside the disconnect
|
|
291
292
|
* teardown (releasing a slotted menu, trigger attributes) can make the engine run the queued
|
|
292
293
|
* connect *before* that teardown finishes, which would then undo the reconnect. */
|
|
293
|
-
private disconnecting;private reconnectedWhileDisconnecting;private positionedAnchor?;private positioningDirection?;private directionChanged;private observedDirectAnchor?;private observedDirectAnchorWasConnected;private stopAnchorIdentityObservation?;private
|
|
294
|
+
private disconnecting;private reconnectedWhileDisconnecting;private positionedAnchor?;private positioningDirection?;private directionChanged;private observedDirectAnchor?;private observedDirectAnchorWasConnected;private stopAnchorIdentityObservation?;private accessibleTriggerAria?;private accessibleTriggerObserver?;private readonly triggerUpgrades;
|
|
294
295
|
/** The virtual anchor set by `showAt()`, taking priority over `trigger` for positioning while
|
|
295
296
|
* set. Cleared whenever the popover closes, so a later `open = true` with no fresh `showAt()`
|
|
296
297
|
* call reverts to plain trigger-based behavior. */
|
|
@@ -393,7 +394,7 @@ showAt(rect:OverlayVirtualRect,options?:{returnFocusTo?:HTMLElement;interactionB
|
|
|
393
394
|
/** Resolves what the popup is positioned against: an explicit virtual anchor first, then the
|
|
394
395
|
* direct `anchor`, then the `for` idref, then the slotted trigger. Shared with `<lr-tooltip>`,
|
|
395
396
|
* which resolves the identical chain. */
|
|
396
|
-
private resolveAnchor;protected positionPopup():void;private invalidatePositioning;private resolveCurrentPositioning;private startPositioning;private syncTriggerA11y;private get accessibleTrigger();private releaseTriggerA11y;private onTriggerSlotChange;
|
|
397
|
+
private resolveAnchor;protected positionPopup():void;private invalidatePositioning;private resolveCurrentPositioning;private startPositioning;private syncTriggerA11y;private get accessibleTrigger();private observeAccessibleTrigger;private releaseTriggerA11y;private onTriggerSlotChange;
|
|
397
398
|
/**
|
|
398
399
|
* Reads the named `trigger` slot's currently assigned element and applies it -- wired as the
|
|
399
400
|
* `slotchange` handler for later mutations and called from `firstUpdated()` for initial
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel,nextId,resolveAccessibleTrigger}from"../../../internal/a11y.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{tag}from"../../../internal/prefix.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{loadAnchoredOverlayRuntime}from"../../../internal/anchored-overlay-runtime.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{finiteDuration,finiteNumber}from"../../../internal/numbers.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{literalSetConverter,omittedEmptyStringConverter,optionalLiteralSetConverter}from"../../../internal/converters.js";import{activateNonmodalOverlay,composedContains}from"../../../internal/nonmodal-overlay-manager.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{applyOverlayArrow}from"./overlay-arrow.js";import{normalizeVirtualRect,observeOverlayAnchorIdentity,OverlayTransitionGate,resolveOverlayAnchor}from"./overlay-shared.js";import{styles}from"./overlay.styles.js";import{glassPopoverStyles}from"./popover-glass.styles.js";import{LYRA_DEFAULT_menuLabel,LYRA_DEFAULT_popover}from"../../../internal/default-strings.generated.js";const DEFAULT_DISTANCE=8;let popoverConnectionSequence=0;const POPUP_ROLE=literalSetConverter(["dialog","menu","none"],"dialog"),POPOVER_TRIGGER_KEYWORDS=["click","hover","focus","manual"];function normalizeTriggerList(next){const keywords=[];for(const token of String(next??"").trim().toLowerCase().split(/\s+/)){const keyword=POPOVER_TRIGGER_KEYWORDS.find(candidate=>candidate===token);keyword&&!keywords.includes(keyword)&&keywords.push(keyword)}return keywords.length>0?keywords.join(" "):"click"}const DEFAULT_TRIGGER_DELAY=0,POSITIONING_STRATEGY=optionalLiteralSetConverter(["absolute","fixed"]);class LyraPopover extends LyraElement{static{this.defaultStrings={...super.defaultStrings,menuLabel:LYRA_DEFAULT_menuLabel,popover:LYRA_DEFAULT_popover}}constructor(){super(),this._open=!1,this.placement="top",this.topLayer=!1,this.distance=8,this.skidding=0,this._for="",this.anchor=null,this.interactionBoundary=null,this.withoutArrow=!1,this.arrowPlacement="anchor",this.arrowPadding=0,this._trigger="click",this.showDelay=0,this.hideDelay=0,this.hoverBridge=!1,this.accessibleLabel="",this._popupRole="dialog",this._disabled=!1,this.openedByInteraction=!1,this.pinned=!1,this.suppressTriggerFocusOpen=!1,this.resolvedSide="bottom",this.anchorPositioned=!1,this.popupHidden=!0,this.disconnecting=!1,this.reconnectedWhileDisconnecting=!1,this.directionChanged=!1,this.observedDirectAnchorWasConnected=!1,this.positioningGeneration=0,this.positioningReady=Promise.resolve(!1),this.generatedHostId=nextId("popover"),this.popupId=nextId("popover-popup"),this.hostIdObserverGeneration=0,this.transitionToken=0,this.transitionGate=new OverlayTransitionGate,this.connectionSequence=0,this.popoverInternals=attachInternalsSafely(this),this.onExternalTriggerKeyDown=event=>{this.onTriggerKeyDown(event)},this.onTriggerSlotChange=event=>{this.collectTriggerFromSlot(event.target)},this.onTriggerClick=()=>{if(!this.virtualAnchor&&(this.syncTriggerA11y(),!this.isManualTrigger)){if(this.cancelPendingTransition(),this.opensOn("click")&&!this.opensOn("hover")&&!this.opensOn("focus")){this.open?this.hide():this.show();return}if(this.open&&this.pinned){this.hide();return}this.open||(this.openedByInteraction=!1,this.show()),this.pinned=this.open}},this.onTriggerPointerEnter=()=>{this.opensOn("hover")&&this.requestDelayedTransition(!0)},this.onTriggerPointerLeave=event=>{this.opensOn("hover")&&this.requestInteractionClose(event.relatedTarget)},this.onPopupPointerEnter=()=>{!this.opensOn("hover")||!this.open||this.cancelPendingTransition()},this.onPopupPointerLeave=event=>{this.opensOn("hover")&&this.requestInteractionClose(event.relatedTarget)},this.onSurfaceFocusIn=event=>{!this.opensOn("focus")||this.suppressTriggerFocusOpen||(!this.open||this.triggerElement!=null&&event.composedPath().includes(this.triggerElement))&&!isKeyboardFocusEvent(event)||this.requestDelayedTransition(!0)},this.onSurfaceFocusOut=event=>{this.opensOn("focus")&&this.requestInteractionClose(event.relatedTarget)},this.onPopupClick=event=>{if(event.defaultPrevented)return;const path=event.composedPath(),hostIndex=path.indexOf(this);if(hostIndex<0)return;const closeAction=path.slice(0,hostIndex).find(target=>target.nodeType===1&&target.getAttribute("data-popover")==="close");if(!closeAction)return;event.stopPropagation();const state2=closeAction;state2.effectiveDisabled===!0||state2.disabled===!0||closeAction.hasAttribute("disabled")||closeAction.getAttribute("aria-disabled")?.trim().toLowerCase()==="true"||closeAction.hasAttribute("inert")||closeAction.closest("[inert]")||this.hide()},this.onDocumentPointer=event=>{this.overlayHandle?.isTopmost()&&(this.isInsideLightDismissBoundary(event.composedPath())||this.hide())},new GlassScrollLayer(this,'[part~="popup"]')}static{this.styles=[LyraElement.styles,styles,glassPopoverStyles]}get open(){return this._open}set open(next){const normalized=!!next&&this.canOpen;if(normalized!==this._open){if(!this.hasUpdated){this.setOpen(normalized),this.isConnected&&this.connectionSequence>0&&this.updateBrowserDerivedState(()=>this.reconcileInitialPopoverPeers());return}normalized?this.show():this.hide()}}get positioningStrategy(){return this._positioningStrategy??this.defaultPositioningStrategy}set positioningStrategy(next){const normalized=POSITIONING_STRATEGY.normalize(next)??this.defaultPositioningStrategy,old=this.positioningStrategy;this._positioningStrategy=normalized,normalized!==old&&(this.requestUpdate("positioningStrategy",old),this.onPositioningStrategyChanged(old,normalized))}onPositioningStrategyChanged(_previous,_next){}get for(){return this._for}set for(next){this._for=next??""}get trigger(){return this._trigger}set trigger(next){const normalized=normalizeTriggerList(next);if(normalized===this._trigger)return;const old=this._trigger;this._trigger=normalized,this.requestUpdate("trigger",old)}get triggerKeywords(){return new Set(this._trigger.split(" "))}get isManualTrigger(){return this.triggerKeywords.has("manual")}opensOn(keyword){return!this.isManualTrigger&&this.triggerKeywords.has(keyword)}get popupRole(){return this._popupRole}set popupRole(next){const normalized=POPUP_ROLE.normalize(next);if(normalized===this._popupRole)return;const old=this._popupRole;this._popupRole=normalized,this.requestUpdate("popupRole",old)}get disabled(){return this._disabled}set disabled(next){const normalized=!!next;if(normalized===this._disabled)return;const old=this._disabled;this._disabled=normalized,this.requestUpdate("disabled",old),normalized&&this.open&&(this.hasUpdated?this.hide():this.open=!1)}get defaultDistance(){return DEFAULT_DISTANCE}get defaultPositioningStrategy(){return"fixed"}get resolvedPositioningStrategy(){return resolveEffectivePositioningStrategy(this,this._positioningStrategy,this.defaultPositioningStrategy)}get positioningSync(){}get animationNamespace(){return"popover"}animationDurationProperties(showing){return[showing?"--show-duration":"--hide-duration","--lr-duration-fast"]}get popupPartNames(){return["popup","dialog","popup__popup"].join(" ")}get contentPartNames(){return["content","body"].join(" ")}get triggerPopupRole(){return this.popupRole}get popupSurfaceRole(){return this.popupRole==="none"?void 0:this.popupRole}get effectivePopupLabel(){return hostAriaLabel(this)??(this.accessibleLabel||this.localize(this.triggerPopupRole==="menu"?"menuLabel":"popover"))}get rendersArrow(){return!this.withoutArrow}get arrowPartNames(){return"arrow popup__arrow"}get rendersHoverBridge(){return this.hoverBridge&&this.opensOn("hover")&&this.open}get canOpen(){return!this.disabled}renderPopupContent(){return html`<slot></slot>`}onTriggerKeyDown(_event){}isInsideLightDismissBoundary(path){const boundary=this.virtualAnchor?this.virtualInteractionBoundary:this.interactionBoundary;return path.includes(this)||this.triggerElement!=null&&path.includes(this.triggerElement)||boundary!=null&&boundary.isConnected&&boundary.ownerDocument===this.ownerDocument&&path.includes(boundary)}onPopupPositioned(){this.openedByInteraction||this.overlayHandle?.focusAutofocus()}willUpdate(changed){super.willUpdate(changed);const direction=this.effectiveDirection;this.directionChanged=direction!==this.positioningDirection,this.positioningDirection=direction,changed.has("anchor")&&changed.get("anchor")===this.observedDirectAnchor&&this.observedDirectAnchorWasConnected&&this.anchor?.isConnected!==!0&&this.open&&!this.resolveAnchor()&&this.forceClose({focusTrigger:!1}),changed.has("open")&&!this.open&&(this.anchorPositioned=!1),changed.has("open")&&this.open&&(this.popupHidden=!1),(changed.has("anchor")||changed.has("for"))&&(this.anchorPositioned=!1)}updated(changed){if(super.updated(changed),changed.has("trigger")&&(this.cancelPendingTransition(),!this.opensOn("hover")&&!this.opensOn("focus")&&(this.pinned=!1)),changed.has("showDelay")&&this.pendingDirection==="show"&&this.requestDelayedTransition(!0,!0),changed.has("hideDelay")&&this.pendingDirection==="hide"&&this.requestDelayedTransition(!1,!0),(changed.has("for")||changed.has("anchor")||changed.has("open"))&&this.syncAnchorIdentityObservation(),changed.has("for")&&this.syncInteractionTrigger(),this.directionChanged||changed.has("open")||changed.has("placement")||changed.has("positioningStrategy")||changed.has("topLayer")||changed.has("hoverBridge")||changed.has("trigger")||changed.has("distance")||changed.has("skidding")||changed.has("for")||changed.has("anchor")||changed.has("arrow")||changed.has("withoutArrow")||changed.has("arrowPlacement")||changed.has("arrowPadding")||changed.has("popupRole")){if(this.open&&this.isConnected?this.positionPopup():changed.has("open")&&this.invalidatePositioning(),changed.has("open"))if(this.open)this.isConnected&&(this.startLightDismiss(),this.activatePopoverOverlay());else{this.pinned=!1,this.openedByInteraction=!1,this.cancelPendingTransition(),this.positionedAnchor=void 0,this.stopLightDismiss(),this.suppressTriggerFocusOpen=!0;try{this.overlayHandle?.deactivate()}finally{this.suppressTriggerFocusOpen=!1}this.overlayHandle=void 0,this.virtualAnchor=void 0,this.returnFocusTo=void 0,this.virtualInteractionBoundary=void 0,this.syncInteractionTrigger()}this.isConnected&&this.syncTriggerA11y()}}firstUpdated(changed){super.firstUpdated(changed);const slot=this.triggerSlotElement;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>this.collectTriggerFromSlot(s))})}connectedCallback(){if(this.disconnecting){this.reconnectedWhileDisconnecting=!0;return}if(super.connectedCallback(),this.connectionSequence=++popoverConnectionSequence,this.addEventListener("focusin",this.onSurfaceFocusIn),this.addEventListener("focusout",this.onSurfaceFocusOut),this.updateBrowserDerivedState(()=>this.reconcileInitialPopoverPeers()),this.syncAnchorIdentityObservation(),this.id||(this.id=this.generatedHostId),this.observeHostId(),this.syncInteractionTrigger(),this.hasUpdated&&this.open){const wasPreviouslyActivated=this.overlayHandle?.isActive()===!0;this.startLightDismiss(),wasPreviouslyActivated?this.overlayHandle.resume():this.activatePopoverOverlay(),this.popupHidden=!1,this.positionPopup()}}disconnectedCallback(){this.disconnecting=!0;try{this.teardownOnDisconnect(),super.disconnectedCallback()}finally{this.disconnecting=!1}this.reconnectedWhileDisconnecting&&(this.reconnectedWhileDisconnecting=!1,this.isConnected&&this.connectedCallback())}teardownOnDisconnect(){this.stopAnchorIdentityObservation?.(),this.stopAnchorIdentityObservation=void 0,this.invalidatePositioning(),this.stopLightDismiss(),this.resetHostIdObserver(),this.overlayHandle?.suspend(),this.triggerElement?.removeEventListener("click",this.onTriggerClick),this.triggerElement?.removeEventListener("keydown",this.onExternalTriggerKeyDown),this.triggerElement&&this.unbindTriggerInteractions(this.triggerElement),this.releaseTriggerA11y(),this.triggerElement=void 0,this.removeEventListener("focusin",this.onSurfaceFocusIn),this.removeEventListener("focusout",this.onSurfaceFocusOut),this.cancelPendingTransition(),this.virtualInteractionBoundary=void 0,this.pinned=!1,this.openedByInteraction=!1,this.transitionToken++,this.cancelTransitionAnimation(),this.removeAttribute("data-closing"),this.popupHidden=!0}adoptedCallback(){super.adoptedCallback(),this.stopAnchorIdentityObservation?.(),this.stopAnchorIdentityObservation=void 0,this.resetHostIdObserver(),this.releaseTriggerA11y()}syncAnchorIdentityObservation(){this.stopAnchorIdentityObservation?.(),this.stopAnchorIdentityObservation=void 0;const directAnchor=this.open?this.anchor??void 0:void 0;if(this.observedDirectAnchor=directAnchor,this.observedDirectAnchorWasConnected=directAnchor?.isConnected===!0,!this.isConnected||!this.for&&!directAnchor)return;const onIdentityChange=()=>{const directAnchorRemoved=this.anchor===this.observedDirectAnchor&&this.observedDirectAnchorWasConnected&&this.observedDirectAnchor?.isConnected===!1;if(this.observedDirectAnchorWasConnected=this.observedDirectAnchor?.isConnected===!0,this.syncInteractionTrigger(),!this.open)return;const nextAnchor=this.resolveAnchor();if(directAnchorRemoved&&!nextAnchor){this.forceClose({focusTrigger:!1});return}nextAnchor!==this.positionedAnchor&&this.positionPopup()},observedRoots=new Set([this]);directAnchor&&directAnchor.getRootNode()!==this.getRootNode()&&observedRoots.add(directAnchor.isConnected?directAnchor:directAnchor.ownerDocument);const cleanups=[...observedRoots].map(root=>observeOverlayAnchorIdentity(root,onIdentityChange));this.stopAnchorIdentityObservation=()=>{for(const cleanup of cleanups)cleanup()}}resolveForTrigger(){if(!this.for)return;const target=this.getRootNode().getElementById?.(this.for)??null,HTMLElementCtor=target?.ownerDocument.defaultView?.HTMLElement;return target&&HTMLElementCtor&&target instanceof HTMLElementCtor?target:void 0}syncInteractionTrigger(){const next=this.virtualAnchor?void 0:this.slottedTrigger??this.resolveForTrigger();if(next===this.triggerElement){this.syncTriggerA11y();return}if(this.triggerElement?.removeEventListener("click",this.onTriggerClick),this.triggerElement?.removeEventListener("keydown",this.onExternalTriggerKeyDown),this.triggerElement&&this.unbindTriggerInteractions(this.triggerElement),this.triggerElement=next,this.triggerElement&&this.triggerElement!==this.slottedTrigger&&(this.triggerElement.addEventListener("click",this.onTriggerClick),this.triggerElement.addEventListener("keydown",this.onExternalTriggerKeyDown)),this.triggerElement&&this.bindTriggerInteractions(this.triggerElement),this.syncTriggerA11y(),this.open){if(!this.resolveAnchor()){this.forceClose({focusTrigger:!1});return}this.updatePopoverRestoreFocusTarget(),this.positionPopup()}}activatePopoverOverlay(){!this.isConnected||this.overlayHandle?.isActive()||(this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part~="popup"]'),onEscape:()=>{this.hide()},restoreFocusTo:this.virtualAnchor?this.returnFocusTo??null:this.accessibleTrigger}))}updatePopoverRestoreFocusTarget(){const target=this.virtualAnchor?this.returnFocusTo??null:this.accessibleTrigger;if(this.overlayHandle?.isActive()){this.overlayHandle.updateRestoreFocusTo(target);return}this.activatePopoverOverlay()}showAt(rect,options){const normalizedRect=normalizeVirtualRect(rect);if(!normalizedRect)return;const previousAnchor=this.virtualAnchor,previousReturnFocusTo=this.returnFocusTo,previousInteractionBoundary=this.virtualInteractionBoundary,bounds=new DOMRect(normalizedRect.x,normalizedRect.y,normalizedRect.width,normalizedRect.height);if(this.virtualAnchor={getBoundingClientRect:()=>bounds,contextElement:normalizedRect.contextElement},this.returnFocusTo=options?.returnFocusTo,this.virtualInteractionBoundary=options?.interactionBoundary,this.syncInteractionTrigger(),this.open){this.updatePopoverRestoreFocusTarget(),this.positionPopup();return}this.show(),!this.open&&(this.virtualAnchor=previousAnchor,this.returnFocusTo=previousReturnFocusTo,this.virtualInteractionBoundary=previousInteractionBoundary,this.syncInteractionTrigger())}resolveAnchor(){return resolveOverlayAnchor(this,{virtualAnchor:this.virtualAnchor,anchor:this.anchor,for:this.for,trigger:this.triggerElement})}positionPopup(){this.invalidatePositioning();const popup=this.renderRoot.querySelector('[part~="popup"]'),arrowElement=this.renderRoot.querySelector('[part~="arrow"]'),bridgeElement=this.renderRoot.querySelector('[part~="hover-bridge"]'),anchor=this.resolveAnchor();if(!this.open||!anchor||!popup){this.positionedAnchor=void 0,this.anchorPositioned=!1;return}anchor!==this.positionedAnchor&&(this.anchorPositioned=!1);const generation=this.positioningGeneration;this.positioningReady=new Promise(resolve=>{this.resolvePositioningReady=resolve}),this.startPositioning(generation,anchor,popup,arrowElement,bridgeElement)}invalidatePositioning(){this.positioningGeneration++,this.cleanup?.(),this.cleanup=void 0,this.resolvePositioningReady?.(!1),this.resolvePositioningReady=void 0}resolveCurrentPositioning(positioned){const resolve=this.resolvePositioningReady;this.resolvePositioningReady=void 0,resolve?.(positioned)}async startPositioning(generation,anchor,popup,arrowElement,bridgeElement){try{const{place,releaseTopLayer}=await loadAnchoredOverlayRuntime();if(generation!==this.positioningGeneration||!this.open||!this.isConnected||this.resolveAnchor()!==anchor||this.renderRoot.querySelector('[part~="popup"]')!==popup)return;this.placedTopLayer&&!this.topLayer&&releaseTopLayer?.(popup),this.placedTopLayer=this.topLayer;const cleanup=place(anchor,popup,{placement:rtlAwarePlacement(this.placement,this),strategy:this.topLayer?"fixed":this.resolvedPositioningStrategy,topLayer:this.topLayer,offset:finiteNumber(this.distance,this.defaultDistance),skidding:finiteNumber(this.skidding,0),sync:this.positioningSync,arrow:this.rendersArrow&&arrowElement?arrowElement:void 0,arrowPadding:Math.max(0,finiteNumber(this.arrowPadding,0)),hoverBridge:this.rendersHoverBridge&&bridgeElement?bridgeElement:void 0,onPlaced:({placement,arrow})=>{if(generation!==this.positioningGeneration)return;const becamePositioned=!this.anchorPositioned||this.positionedAnchor!==anchor;this.positionedAnchor=anchor,this.anchorPositioned=!0;const side=applyOverlayArrow(arrowElement,{placement,coords:arrow,enabled:this.rendersArrow,arrowPlacement:this.arrowPlacement,arrowPadding:Math.max(0,finiteNumber(this.arrowPadding,0)),rtl:this.effectiveDirection==="rtl",sizeProperty:"--arrow-size",fallbackSizeProperty:"--lr-overlay-arrow-size"});side!==this.resolvedSide&&(this.resolvedSide=side),this.updateComplete.then(()=>{generation!==this.positioningGeneration||!this.open||this.resolveAnchor()!==anchor||(this.resolveCurrentPositioning(!0),becamePositioned&&this.onPopupPositioned())})}});generation!==this.positioningGeneration?cleanup():this.cleanup=cleanup}catch{if(generation!==this.positioningGeneration)return;this.resolveCurrentPositioning(!1),this.forceClose({focusTrigger:!1})}}syncTriggerA11y(){const trigger=this.triggerElement??null,popup=this.renderRoot?.querySelector('[part~="popup"]')??null,contribution={attributes:{"aria-haspopup":this.triggerPopupRole==="none"?null:this.triggerPopupRole,"aria-expanded":this.open?"true":"false"},controls:popup?[popup]:[]};this.triggerAria?this.triggerAria.update(trigger,contribution):this.triggerAria=acquireAriaOwnership(trigger,contribution);const accessibleTrigger=this.accessibleTrigger,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)}get accessibleTrigger(){return this.triggerElement?resolveAccessibleTrigger(this.triggerElement):null}releaseTriggerA11y(){this.accessibleTriggerAria?.release(),this.accessibleTriggerAria=void 0,this.triggerAria?.release(),this.triggerAria=void 0}collectTriggerFromSlot(slot){const next=slot.assignedElements({flatten:!0})[0];next!==this.slottedTrigger&&(this.slottedTrigger=next,this.syncInteractionTrigger())}requestInteractionClose(next){this.pinned||this.isWithinPopoverSurface(next)||this.hasFocusWithinSurface()||this.requestDelayedTransition(!1)}isWithinPopoverSurface(target){if(target===null||target.nodeType!==1)return!1;const element=target;if(composedContains(this,element))return!0;const popup=this.renderRoot?.querySelector('[part~="popup"]')??null;return popup&&composedContains(popup,element)?!0:this.triggerElement!=null&&composedContains(this.triggerElement,element)}hasFocusWithinSurface(){const active=deepActiveElementIn(this.ownerDocument);return active===null||this.triggerElement&&composedContains(this.triggerElement,active)?!1:this.isWithinPopoverSurface(active)}requestDelayedTransition(next,deferImmediate=!1){if(this.cancelPendingTransition(),next&&!this.canOpen)return;const commit=()=>{next?(this.openedByInteraction=!0,this.show()):this.hide()},delay=Math.max(0,finiteDuration(next?this.showDelay:this.hideDelay,DEFAULT_TRIGGER_DELAY)),view=this.ownerDocument.defaultView;if(!view||delay<=0&&!deferImmediate){commit();return}this.pendingDirection=next?"show":"hide",this.delayTimerView=view;const timer=view.setTimeout(()=>{this.delayTimerView!==view||this.delayTimer!==timer||(this.delayTimer=void 0,this.delayTimerView=void 0,this.pendingDirection=void 0,commit())},delay);this.delayTimer=timer}cancelPendingTransition(){this.delayTimer!==void 0&&this.delayTimerView?.clearTimeout(this.delayTimer),this.delayTimer=void 0,this.delayTimerView=void 0,this.pendingDirection=void 0}triggerNeedsOwnFocusListeners(trigger){return!composedContains(this,trigger)}bindTriggerInteractions(trigger){trigger.addEventListener("mouseenter",this.onTriggerPointerEnter),trigger.addEventListener("mouseleave",this.onTriggerPointerLeave),this.triggerNeedsOwnFocusListeners(trigger)&&(trigger.addEventListener("focusin",this.onSurfaceFocusIn),trigger.addEventListener("focusout",this.onSurfaceFocusOut))}unbindTriggerInteractions(trigger){trigger.removeEventListener("mouseenter",this.onTriggerPointerEnter),trigger.removeEventListener("mouseleave",this.onTriggerPointerLeave),trigger.removeEventListener("focusin",this.onSurfaceFocusIn),trigger.removeEventListener("focusout",this.onSurfaceFocusOut)}startLightDismiss(){const nextDocument=this.ownerDocument;this.lightDismissDocument!==nextDocument&&(this.stopLightDismiss(),nextDocument.addEventListener("pointerdown",this.onDocumentPointer),this.lightDismissDocument=nextDocument)}stopLightDismiss(){this.lightDismissDocument?.removeEventListener("pointerdown",this.onDocumentPointer),this.lightDismissDocument=void 0}observeHostId(){const ownerDocument=this.ownerDocument;if(this.hostIdObserver&&this.hostIdObserverDocument===ownerDocument)return;this.resetHostIdObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor||!this.isConnected)return;const generation=this.hostIdObserverGeneration,observer=new MutationObserverCtor(()=>{this.hostIdObserver!==observer||this.hostIdObserverDocument!==ownerDocument||this.hostIdObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||(this.id||(this.id=this.generatedHostId),this.syncTriggerA11y())});this.hostIdObserver=observer,this.hostIdObserverDocument=ownerDocument,observer.observe(this,{attributes:!0,attributeFilter:["id"]})}resetHostIdObserver(){this.hostIdObserverGeneration+=1,this.hostIdObserver?.disconnect(),this.hostIdObserver=void 0,this.hostIdObserverDocument=void 0}setOpen(next){if(this._open===next)return;const old=this._open;this._open=next,setCustomState(this.popoverInternals,"open",next),this.requestUpdate("open",old)}syncOpenAttribute(){this.toggleAttribute("open",this._open)}show(){return this._open||!this.canOpen?Promise.resolve():this.transitionGate.request(!0,()=>{if(this.emitCancelableLifecycle("lr-show").defaultPrevented){this.syncOpenAttribute();return}if(!this.closePopoverPeers()){this.syncOpenAttribute();return}return this.cancelTransitionAnimation(),this.removeAttribute("data-closing"),this.setOpen(!0),this.settleTransition("lr-after-show")})}hide(options){return this._open?this.transitionGate.request(!1,()=>{if(this.emitCancelableLifecycle("lr-hide").defaultPrevented){this.syncOpenAttribute();return}return this.forceClose(options)}):Promise.resolve()}closePopoverPeers(){if(this.virtualAnchor||this.localName!==tag("popover"))return!0;const root=this.getRootNode();for(const peer of root.querySelectorAll(tag("popover")))if(!(peer===this||!peer.open||peer.virtualAnchor)&&(peer.hide({focusTrigger:!1}),peer.open))return!1;return!0}reconcileInitialPopoverPeers(){if(!this.isConnected||!this._open||this.virtualAnchor||this.localName!==tag("popover"))return;const peers=[...this.getRootNode().querySelectorAll(tag("popover"))].filter(peer=>peer.isConnected&&peer._open&&!peer.virtualAnchor&&peer.connectionSequence>0);if(peers.reduce((latest,peer)=>!latest||peer.connectionSequence>latest.connectionSequence?peer:latest,void 0)!==this){this.closeForInitialPeerReconciliation();return}for(const peer of peers)peer!==this&&peer.closeForInitialPeerReconciliation()}closeForInitialPeerReconciliation(){this._open&&(this.transitionToken++,this.cancelTransitionAnimation(),this.removeAttribute("data-closing"),this.invalidatePositioning(),this.stopLightDismiss(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.positionedAnchor=void 0,this.anchorPositioned=!1,this.returnFocusTo=void 0,this.setOpen(!1),this.syncOpenAttribute())}forceClose(options){return this._open?(options?.focusTrigger===!1&&(this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0),this.cancelTransitionAnimation(),this.isConnected&&this.setAttribute("data-closing",""),this.setOpen(!1),this.settleTransition("lr-after-hide")):Promise.resolve()}cancelTransitionAnimation(){this.transitionAnimation?.cancel(),this.transitionAnimation=void 0}emitCancelableLifecycle(name){return this.emit(name,null,{cancelable:!0})}emitSettledLifecycle(name){return this.emit(name)}async settleTransition(event){const token=++this.transitionToken;if(await this.updateComplete,this.transitionToken===token){if(event==="lr-after-show"){for(;this.open&&!this.anchorPositioned;){const readiness=this.positioningReady,positioned=await readiness;if(this.transitionToken!==token)return;if(positioned)break;if(readiness===this.positioningReady)return}if(await this.updateComplete,this.transitionToken!==token)return}if(this.isConnected){const popup=this.renderRoot.querySelector('[part~="popup"]'),showing=event==="lr-after-show",offset="translateY(var(--lr-size-neg-0-25rem))",animation=popup?animateRegistered(this,popup,`${this.animationNamespace}.${showing?"show":"hide"}`,this.effectiveDirection,{keyframes:showing?[{opacity:0,transform:offset},{opacity:1,transform:"translateY(0)"}]:[{opacity:1,transform:"translateY(0)"},{opacity:0,transform:offset}],durationProperties:this.animationDurationProperties(showing),easingProperties:["--lr-easing-standard"]}):void 0;if(this.transitionAnimation=animation,await animation?.finished.catch(()=>{}),this.transitionToken!==token)return;this.cancelTransitionAnimation()}event==="lr-after-hide"&&(this.removeAttribute("data-closing"),this.popupHidden=!0,await this.updateComplete,this.transitionToken!==token)||this.emitSettledLifecycle(event)}}render(){const popupRole=this.popupSurfaceRole;return html`
|
|
1
|
+
import{__decorate}from"tslib";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{hostAriaLabel,nextId,resolveAccessibleTrigger}from"../../../internal/a11y.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{collectComposedFocusTargets}from"../../../internal/focus-navigation.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{acquireAriaOwnership}from"../../../internal/aria-ownership.js";import{tag}from"../../../internal/prefix.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{loadAnchoredOverlayRuntime}from"../../../internal/anchored-overlay-runtime.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{finiteDuration,finiteNumber}from"../../../internal/numbers.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{literalSetConverter,omittedEmptyStringConverter,optionalLiteralSetConverter}from"../../../internal/converters.js";import{activateNonmodalOverlay,composedContains}from"../../../internal/nonmodal-overlay-manager.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{applyOverlayArrow}from"./overlay-arrow.js";import{normalizeVirtualRect,observeOverlayAnchorIdentity,OverlayTransitionGate,resolveOverlayAnchor}from"./overlay-shared.js";import{styles}from"./overlay.styles.js";import{glassPopoverStyles}from"./popover-glass.styles.js";import{LYRA_DEFAULT_menuLabel,LYRA_DEFAULT_popover}from"../../../internal/default-strings.generated.js";const DEFAULT_DISTANCE=8,EXPANDABLE_TRIGGER_ROLES=new Set(["application","button","checkbox","combobox","gridcell","link","listbox","menuitem","row","rowheader","tab","treeitem","columnheader","menuitemcheckbox","menuitemradio","switch"]);function supportsTriggerExpansion(element){const role=element.getAttribute("role")?.trim().split(/\s+/)[0];return role?EXPANDABLE_TRIGGER_ROLES.has(role):element.matches("button, a[href], select, summary")?!0:element.localName==="input"&&["button","submit","reset","image","checkbox"].includes(element.type)}let popoverConnectionSequence=0;const POPUP_ROLE=literalSetConverter(["dialog","menu","none"],"dialog"),POPOVER_TRIGGER_KEYWORDS=["click","hover","focus","manual"];function normalizeTriggerList(next){const keywords=[];for(const token of String(next??"").trim().toLowerCase().split(/\s+/)){const keyword=POPOVER_TRIGGER_KEYWORDS.find(candidate=>candidate===token);keyword&&!keywords.includes(keyword)&&keywords.push(keyword)}return keywords.length>0?keywords.join(" "):"click"}const DEFAULT_TRIGGER_DELAY=0,POSITIONING_STRATEGY=optionalLiteralSetConverter(["absolute","fixed"]);class LyraPopover extends LyraElement{static{this.defaultStrings={...super.defaultStrings,menuLabel:LYRA_DEFAULT_menuLabel,popover:LYRA_DEFAULT_popover}}constructor(){super(),this._open=!1,this.placement="top",this.topLayer=!1,this.distance=8,this.skidding=0,this._for="",this.anchor=null,this.interactionBoundary=null,this.withoutArrow=!1,this.arrowPlacement="anchor",this.arrowPadding=0,this._trigger="click",this.showDelay=0,this.hideDelay=0,this.hoverBridge=!1,this.accessibleLabel="",this._popupRole="dialog",this._disabled=!1,this.openedByInteraction=!1,this.pinned=!1,this.suppressTriggerFocusOpen=!1,this.resolvedSide="bottom",this.anchorPositioned=!1,this.popupHidden=!0,this.disconnecting=!1,this.reconnectedWhileDisconnecting=!1,this.directionChanged=!1,this.observedDirectAnchorWasConnected=!1,this.triggerUpgrades=new CustomElementUpgradeObserver(()=>{this.isConnected&&this.syncTriggerA11y()}),this.positioningGeneration=0,this.positioningReady=Promise.resolve(!1),this.generatedHostId=nextId("popover"),this.popupId=nextId("popover-popup"),this.hostIdObserverGeneration=0,this.transitionToken=0,this.transitionGate=new OverlayTransitionGate,this.connectionSequence=0,this.popoverInternals=attachInternalsSafely(this),this.onExternalTriggerKeyDown=event=>{this.onTriggerKeyDown(event)},this.onTriggerSlotChange=event=>{this.collectTriggerFromSlot(event.target)},this.onTriggerClick=()=>{if(!this.virtualAnchor&&(this.syncTriggerA11y(),!this.isManualTrigger)){if(this.cancelPendingTransition(),this.opensOn("click")&&!this.opensOn("hover")&&!this.opensOn("focus")){this.open?this.hide():this.show();return}if(this.open&&this.pinned){this.hide();return}this.open||(this.openedByInteraction=!1,this.show()),this.pinned=this.open}},this.onTriggerPointerEnter=()=>{this.opensOn("hover")&&this.requestDelayedTransition(!0)},this.onTriggerPointerLeave=event=>{this.opensOn("hover")&&this.requestInteractionClose(event.relatedTarget)},this.onPopupPointerEnter=()=>{!this.opensOn("hover")||!this.open||this.cancelPendingTransition()},this.onPopupPointerLeave=event=>{this.opensOn("hover")&&this.requestInteractionClose(event.relatedTarget)},this.onSurfaceFocusIn=event=>{!this.opensOn("focus")||this.suppressTriggerFocusOpen||(!this.open||this.triggerElement!=null&&event.composedPath().includes(this.triggerElement))&&!isKeyboardFocusEvent(event)||this.requestDelayedTransition(!0)},this.onSurfaceFocusOut=event=>{this.opensOn("focus")&&this.requestInteractionClose(event.relatedTarget)},this.onPopupClick=event=>{if(event.defaultPrevented)return;const path=event.composedPath(),hostIndex=path.indexOf(this);if(hostIndex<0)return;const closeAction=path.slice(0,hostIndex).find(target=>target.nodeType===1&&target.getAttribute("data-popover")==="close");if(!closeAction)return;event.stopPropagation();const state2=closeAction;state2.effectiveDisabled===!0||state2.disabled===!0||closeAction.hasAttribute("disabled")||closeAction.getAttribute("aria-disabled")?.trim().toLowerCase()==="true"||closeAction.hasAttribute("inert")||closeAction.closest("[inert]")||this.hide()},this.onDocumentPointer=event=>{this.overlayHandle?.isTopmost()&&(this.isInsideLightDismissBoundary(event.composedPath())||this.hide())},new GlassScrollLayer(this,'[part~="popup"]')}static{this.styles=[LyraElement.styles,styles,glassPopoverStyles]}get open(){return this._open}set open(next){const normalized=!!next&&this.canOpen;if(normalized!==this._open){if(!this.hasUpdated){this.setOpen(normalized),this.isConnected&&this.connectionSequence>0&&this.updateBrowserDerivedState(()=>this.reconcileInitialPopoverPeers());return}normalized?this.show():this.hide()}}get positioningStrategy(){return this._positioningStrategy??this.defaultPositioningStrategy}set positioningStrategy(next){const normalized=POSITIONING_STRATEGY.normalize(next)??this.defaultPositioningStrategy,old=this.positioningStrategy;this._positioningStrategy=normalized,normalized!==old&&(this.requestUpdate("positioningStrategy",old),this.onPositioningStrategyChanged(old,normalized))}onPositioningStrategyChanged(_previous,_next){}get for(){return this._for}set for(next){this._for=next??""}get trigger(){return this._trigger}set trigger(next){const normalized=normalizeTriggerList(next);if(normalized===this._trigger)return;const old=this._trigger;this._trigger=normalized,this.requestUpdate("trigger",old)}get triggerKeywords(){return new Set(this._trigger.split(" "))}get isManualTrigger(){return this.triggerKeywords.has("manual")}opensOn(keyword){return!this.isManualTrigger&&this.triggerKeywords.has(keyword)}get popupRole(){return this._popupRole}set popupRole(next){const normalized=POPUP_ROLE.normalize(next);if(normalized===this._popupRole)return;const old=this._popupRole;this._popupRole=normalized,this.requestUpdate("popupRole",old)}get disabled(){return this._disabled}set disabled(next){const normalized=!!next;if(normalized===this._disabled)return;const old=this._disabled;this._disabled=normalized,this.requestUpdate("disabled",old),normalized&&this.open&&(this.hasUpdated?this.hide():this.open=!1)}get defaultDistance(){return DEFAULT_DISTANCE}get defaultPositioningStrategy(){return"fixed"}get resolvedPositioningStrategy(){return resolveEffectivePositioningStrategy(this,this._positioningStrategy,this.defaultPositioningStrategy)}get positioningSync(){}get animationNamespace(){return"popover"}animationDurationProperties(showing){return[showing?"--show-duration":"--hide-duration","--lr-duration-fast"]}get popupPartNames(){return["popup","dialog","popup__popup"].join(" ")}get contentPartNames(){return["content","body"].join(" ")}get triggerPopupRole(){return this.popupRole}get popupSurfaceRole(){return this.popupRole==="none"?void 0:this.popupRole}get effectivePopupLabel(){return hostAriaLabel(this)??(this.accessibleLabel||this.localize(this.triggerPopupRole==="menu"?"menuLabel":"popover"))}get rendersArrow(){return!this.withoutArrow}get arrowPartNames(){return"arrow popup__arrow"}get rendersHoverBridge(){return this.hoverBridge&&this.opensOn("hover")&&this.open}get canOpen(){return!this.disabled}renderPopupContent(){return html`<slot></slot>`}onTriggerKeyDown(_event){}isInsideLightDismissBoundary(path){const boundary=this.virtualAnchor?this.virtualInteractionBoundary:this.interactionBoundary;return path.includes(this)||this.triggerElement!=null&&path.includes(this.triggerElement)||boundary!=null&&boundary.isConnected&&boundary.ownerDocument===this.ownerDocument&&path.includes(boundary)}onPopupPositioned(){this.openedByInteraction||this.overlayHandle?.focusAutofocus()}willUpdate(changed){super.willUpdate(changed);const direction=this.effectiveDirection;this.directionChanged=direction!==this.positioningDirection,this.positioningDirection=direction,changed.has("anchor")&&changed.get("anchor")===this.observedDirectAnchor&&this.observedDirectAnchorWasConnected&&this.anchor?.isConnected!==!0&&this.open&&!this.resolveAnchor()&&this.forceClose({focusTrigger:!1}),changed.has("open")&&!this.open&&(this.anchorPositioned=!1),changed.has("open")&&this.open&&(this.popupHidden=!1),(changed.has("anchor")||changed.has("for"))&&(this.anchorPositioned=!1)}updated(changed){if(super.updated(changed),changed.has("trigger")&&(this.cancelPendingTransition(),!this.opensOn("hover")&&!this.opensOn("focus")&&(this.pinned=!1)),changed.has("showDelay")&&this.pendingDirection==="show"&&this.requestDelayedTransition(!0,!0),changed.has("hideDelay")&&this.pendingDirection==="hide"&&this.requestDelayedTransition(!1,!0),(changed.has("for")||changed.has("anchor")||changed.has("open"))&&this.syncAnchorIdentityObservation(),changed.has("for")&&this.syncInteractionTrigger(),this.directionChanged||changed.has("open")||changed.has("placement")||changed.has("positioningStrategy")||changed.has("topLayer")||changed.has("hoverBridge")||changed.has("trigger")||changed.has("distance")||changed.has("skidding")||changed.has("for")||changed.has("anchor")||changed.has("arrow")||changed.has("withoutArrow")||changed.has("arrowPlacement")||changed.has("arrowPadding")||changed.has("popupRole")){if(this.open&&this.isConnected?this.positionPopup():changed.has("open")&&this.invalidatePositioning(),changed.has("open"))if(this.open)this.isConnected&&(this.startLightDismiss(),this.activatePopoverOverlay());else{this.pinned=!1,this.openedByInteraction=!1,this.cancelPendingTransition(),this.positionedAnchor=void 0,this.stopLightDismiss(),this.suppressTriggerFocusOpen=!0;try{this.overlayHandle?.deactivate()}finally{this.suppressTriggerFocusOpen=!1}this.overlayHandle=void 0,this.virtualAnchor=void 0,this.returnFocusTo=void 0,this.virtualInteractionBoundary=void 0,this.syncInteractionTrigger()}this.isConnected&&this.syncTriggerA11y()}}firstUpdated(changed){super.firstUpdated(changed);const slot=this.triggerSlotElement;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>this.collectTriggerFromSlot(s))})}connectedCallback(){if(this.disconnecting){this.reconnectedWhileDisconnecting=!0;return}if(super.connectedCallback(),this.connectionSequence=++popoverConnectionSequence,this.addEventListener("focusin",this.onSurfaceFocusIn),this.addEventListener("focusout",this.onSurfaceFocusOut),this.updateBrowserDerivedState(()=>this.reconcileInitialPopoverPeers()),this.syncAnchorIdentityObservation(),this.id||(this.id=this.generatedHostId),this.observeHostId(),this.syncInteractionTrigger(),this.hasUpdated&&this.open){const wasPreviouslyActivated=this.overlayHandle?.isActive()===!0;this.startLightDismiss(),wasPreviouslyActivated?this.overlayHandle.resume():this.activatePopoverOverlay(),this.popupHidden=!1,this.positionPopup()}}disconnectedCallback(){this.disconnecting=!0;try{this.teardownOnDisconnect(),super.disconnectedCallback()}finally{this.disconnecting=!1}this.reconnectedWhileDisconnecting&&(this.reconnectedWhileDisconnecting=!1,this.isConnected&&this.connectedCallback())}teardownOnDisconnect(){this.stopAnchorIdentityObservation?.(),this.stopAnchorIdentityObservation=void 0,this.invalidatePositioning(),this.stopLightDismiss(),this.resetHostIdObserver(),this.overlayHandle?.suspend(),this.triggerElement?.removeEventListener("click",this.onTriggerClick),this.triggerElement?.removeEventListener("keydown",this.onExternalTriggerKeyDown),this.triggerElement&&this.unbindTriggerInteractions(this.triggerElement),this.releaseTriggerA11y(),this.triggerElement=void 0,this.removeEventListener("focusin",this.onSurfaceFocusIn),this.removeEventListener("focusout",this.onSurfaceFocusOut),this.cancelPendingTransition(),this.virtualInteractionBoundary=void 0,this.pinned=!1,this.openedByInteraction=!1,this.transitionToken++,this.cancelTransitionAnimation(),this.removeAttribute("data-closing"),this.popupHidden=!0}adoptedCallback(){super.adoptedCallback(),this.stopAnchorIdentityObservation?.(),this.stopAnchorIdentityObservation=void 0,this.resetHostIdObserver(),this.releaseTriggerA11y()}syncAnchorIdentityObservation(){this.stopAnchorIdentityObservation?.(),this.stopAnchorIdentityObservation=void 0;const directAnchor=this.open?this.anchor??void 0:void 0;if(this.observedDirectAnchor=directAnchor,this.observedDirectAnchorWasConnected=directAnchor?.isConnected===!0,!this.isConnected||!this.for&&!directAnchor)return;const onIdentityChange=()=>{const directAnchorRemoved=this.anchor===this.observedDirectAnchor&&this.observedDirectAnchorWasConnected&&this.observedDirectAnchor?.isConnected===!1;if(this.observedDirectAnchorWasConnected=this.observedDirectAnchor?.isConnected===!0,this.syncInteractionTrigger(),!this.open)return;const nextAnchor=this.resolveAnchor();if(directAnchorRemoved&&!nextAnchor){this.forceClose({focusTrigger:!1});return}nextAnchor!==this.positionedAnchor&&this.positionPopup()},observedRoots=new Set([this]);directAnchor&&directAnchor.getRootNode()!==this.getRootNode()&&observedRoots.add(directAnchor.isConnected?directAnchor:directAnchor.ownerDocument);const cleanups=[...observedRoots].map(root=>observeOverlayAnchorIdentity(root,onIdentityChange));this.stopAnchorIdentityObservation=()=>{for(const cleanup of cleanups)cleanup()}}resolveForTrigger(){if(!this.for)return;const target=this.getRootNode().getElementById?.(this.for)??null,HTMLElementCtor=target?.ownerDocument.defaultView?.HTMLElement;return target&&HTMLElementCtor&&target instanceof HTMLElementCtor?target:void 0}syncInteractionTrigger(){const next=this.virtualAnchor?void 0:this.slottedTrigger??this.resolveForTrigger();if(next===this.triggerElement){this.syncTriggerA11y();return}if(this.triggerElement?.removeEventListener("click",this.onTriggerClick),this.triggerElement?.removeEventListener("keydown",this.onExternalTriggerKeyDown),this.triggerElement&&this.unbindTriggerInteractions(this.triggerElement),this.triggerElement=next,this.triggerUpgrades.disconnect(),this.triggerElement&&this.triggerElement!==this.slottedTrigger&&(this.triggerElement.addEventListener("click",this.onTriggerClick),this.triggerElement.addEventListener("keydown",this.onExternalTriggerKeyDown)),this.triggerElement&&this.bindTriggerInteractions(this.triggerElement),this.syncTriggerA11y(),this.open){if(!this.resolveAnchor()){this.forceClose({focusTrigger:!1});return}this.updatePopoverRestoreFocusTarget(),this.positionPopup()}}activatePopoverOverlay(){!this.isConnected||this.overlayHandle?.isActive()||(this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part~="popup"]'),onEscape:()=>{this.hide()},restoreFocusTo:this.virtualAnchor?this.returnFocusTo??null:this.accessibleTrigger}))}updatePopoverRestoreFocusTarget(){const target=this.virtualAnchor?this.returnFocusTo??null:this.accessibleTrigger;if(this.overlayHandle?.isActive()){this.overlayHandle.updateRestoreFocusTo(target);return}this.activatePopoverOverlay()}showAt(rect,options){const normalizedRect=normalizeVirtualRect(rect);if(!normalizedRect)return;const previousAnchor=this.virtualAnchor,previousReturnFocusTo=this.returnFocusTo,previousInteractionBoundary=this.virtualInteractionBoundary,bounds=new DOMRect(normalizedRect.x,normalizedRect.y,normalizedRect.width,normalizedRect.height);if(this.virtualAnchor={getBoundingClientRect:()=>bounds,contextElement:normalizedRect.contextElement},this.returnFocusTo=options?.returnFocusTo,this.virtualInteractionBoundary=options?.interactionBoundary,this.syncInteractionTrigger(),this.open){this.updatePopoverRestoreFocusTarget(),this.positionPopup();return}this.show(),!this.open&&(this.virtualAnchor=previousAnchor,this.returnFocusTo=previousReturnFocusTo,this.virtualInteractionBoundary=previousInteractionBoundary,this.syncInteractionTrigger())}resolveAnchor(){return resolveOverlayAnchor(this,{virtualAnchor:this.virtualAnchor,anchor:this.anchor,for:this.for,trigger:this.triggerElement})}positionPopup(){this.invalidatePositioning();const popup=this.renderRoot.querySelector('[part~="popup"]'),arrowElement=this.renderRoot.querySelector('[part~="arrow"]'),bridgeElement=this.renderRoot.querySelector('[part~="hover-bridge"]'),anchor=this.resolveAnchor();if(!this.open||!anchor||!popup){this.positionedAnchor=void 0,this.anchorPositioned=!1;return}anchor!==this.positionedAnchor&&(this.anchorPositioned=!1);const generation=this.positioningGeneration;this.positioningReady=new Promise(resolve=>{this.resolvePositioningReady=resolve}),this.startPositioning(generation,anchor,popup,arrowElement,bridgeElement)}invalidatePositioning(){this.positioningGeneration++,this.cleanup?.(),this.cleanup=void 0,this.resolvePositioningReady?.(!1),this.resolvePositioningReady=void 0}resolveCurrentPositioning(positioned){const resolve=this.resolvePositioningReady;this.resolvePositioningReady=void 0,resolve?.(positioned)}async startPositioning(generation,anchor,popup,arrowElement,bridgeElement){try{const{place,releaseTopLayer}=await loadAnchoredOverlayRuntime();if(generation!==this.positioningGeneration||!this.open||!this.isConnected||this.resolveAnchor()!==anchor||this.renderRoot.querySelector('[part~="popup"]')!==popup)return;this.placedTopLayer&&!this.topLayer&&releaseTopLayer?.(popup),this.placedTopLayer=this.topLayer;const cleanup=place(anchor,popup,{placement:rtlAwarePlacement(this.placement,this),strategy:this.topLayer?"fixed":this.resolvedPositioningStrategy,topLayer:this.topLayer,offset:finiteNumber(this.distance,this.defaultDistance),skidding:finiteNumber(this.skidding,0),sync:this.positioningSync,arrow:this.rendersArrow&&arrowElement?arrowElement:void 0,arrowPadding:Math.max(0,finiteNumber(this.arrowPadding,0)),hoverBridge:this.rendersHoverBridge&&bridgeElement?bridgeElement:void 0,onPlaced:({placement,arrow})=>{if(generation!==this.positioningGeneration)return;const becamePositioned=!this.anchorPositioned||this.positionedAnchor!==anchor;this.positionedAnchor=anchor,this.anchorPositioned=!0;const side=applyOverlayArrow(arrowElement,{placement,coords:arrow,enabled:this.rendersArrow,arrowPlacement:this.arrowPlacement,arrowPadding:Math.max(0,finiteNumber(this.arrowPadding,0)),rtl:this.effectiveDirection==="rtl",sizeProperty:"--arrow-size",fallbackSizeProperty:"--lr-overlay-arrow-size"});side!==this.resolvedSide&&(this.resolvedSide=side),this.updateComplete.then(()=>{generation!==this.positioningGeneration||!this.open||this.resolveAnchor()!==anchor||(this.resolveCurrentPositioning(!0),becamePositioned&&this.onPopupPositioned())})}});generation!==this.positioningGeneration?cleanup():this.cleanup=cleanup}catch{if(generation!==this.positioningGeneration)return;this.resolveCurrentPositioning(!1),this.forceClose({focusTrigger:!1})}}syncTriggerA11y(){const popup=this.renderRoot?.querySelector('[part~="popup"]')??null,contribution={attributes:{"aria-haspopup":this.triggerPopupRole==="none"?null:this.triggerPopupRole,"aria-expanded":this.open?"true":"false"},controls:popup?[popup]:[]},accessibleTrigger=this.accessibleTrigger;this.observeAccessibleTrigger(accessibleTrigger);const semanticTrigger=accessibleTrigger&&supportsTriggerExpansion(accessibleTrigger)?accessibleTrigger:null;this.accessibleTriggerAria?this.accessibleTriggerAria.update(semanticTrigger,contribution):this.accessibleTriggerAria=acquireAriaOwnership(semanticTrigger,contribution),this.overlayHandle?.isActive()&&!this.virtualAnchor&&this.overlayHandle.updateRestoreFocusTo(accessibleTrigger)}get accessibleTrigger(){const trigger=this.triggerElement;if(!trigger)return null;const resolved=resolveAccessibleTrigger(trigger);return resolved===trigger&&!trigger.hasAttribute("role")&&!trigger.matches("button, a[href], input, select, textarea, summary")?collectComposedFocusTargets(trigger,{includeRoot:!1,mode:"programmatic"}).elements[0]??trigger:resolved}observeAccessibleTrigger(target){this.accessibleTriggerObserver?.disconnect();const trigger=this.triggerElement;if(!trigger||!this.isConnected)return;const view=this.ownerDocument.defaultView;if(view?.MutationObserver){this.accessibleTriggerObserver??=new view.MutationObserver(()=>{this.isConnected&&this.syncTriggerA11y()});const roots=new Set([trigger]);trigger.shadowRoot&&roots.add(trigger.shadowRoot);let current=target;for(;current&¤t!==trigger;){const root=current.getRootNode();if(root.nodeType!==11||!("host"in root))break;roots.add(root),current=root.host}for(const root of roots)this.accessibleTriggerObserver.observe(root,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","tabindex","disabled","href","type"]})}this.triggerUpgrades.observeElement(trigger)}releaseTriggerA11y(){this.accessibleTriggerObserver?.disconnect(),this.accessibleTriggerObserver=void 0,this.triggerUpgrades.disconnect(),this.accessibleTriggerAria?.release(),this.accessibleTriggerAria=void 0}collectTriggerFromSlot(slot){const next=slot.assignedElements({flatten:!0})[0];next!==this.slottedTrigger&&(this.slottedTrigger=next,this.syncInteractionTrigger())}requestInteractionClose(next){this.pinned||this.isWithinPopoverSurface(next)||this.hasFocusWithinSurface()||this.requestDelayedTransition(!1)}isWithinPopoverSurface(target){if(target===null||target.nodeType!==1)return!1;const element=target;if(composedContains(this,element))return!0;const popup=this.renderRoot?.querySelector('[part~="popup"]')??null;return popup&&composedContains(popup,element)?!0:this.triggerElement!=null&&composedContains(this.triggerElement,element)}hasFocusWithinSurface(){const active=deepActiveElementIn(this.ownerDocument);return active===null||this.triggerElement&&composedContains(this.triggerElement,active)?!1:this.isWithinPopoverSurface(active)}requestDelayedTransition(next,deferImmediate=!1){if(this.cancelPendingTransition(),next&&!this.canOpen)return;const commit=()=>{next?(this.openedByInteraction=!0,this.show()):this.hide()},delay=Math.max(0,finiteDuration(next?this.showDelay:this.hideDelay,DEFAULT_TRIGGER_DELAY)),view=this.ownerDocument.defaultView;if(!view||delay<=0&&!deferImmediate){commit();return}this.pendingDirection=next?"show":"hide",this.delayTimerView=view;const timer=view.setTimeout(()=>{this.delayTimerView!==view||this.delayTimer!==timer||(this.delayTimer=void 0,this.delayTimerView=void 0,this.pendingDirection=void 0,commit())},delay);this.delayTimer=timer}cancelPendingTransition(){this.delayTimer!==void 0&&this.delayTimerView?.clearTimeout(this.delayTimer),this.delayTimer=void 0,this.delayTimerView=void 0,this.pendingDirection=void 0}triggerNeedsOwnFocusListeners(trigger){return!composedContains(this,trigger)}bindTriggerInteractions(trigger){trigger.addEventListener("mouseenter",this.onTriggerPointerEnter),trigger.addEventListener("mouseleave",this.onTriggerPointerLeave),this.triggerNeedsOwnFocusListeners(trigger)&&(trigger.addEventListener("focusin",this.onSurfaceFocusIn),trigger.addEventListener("focusout",this.onSurfaceFocusOut))}unbindTriggerInteractions(trigger){trigger.removeEventListener("mouseenter",this.onTriggerPointerEnter),trigger.removeEventListener("mouseleave",this.onTriggerPointerLeave),trigger.removeEventListener("focusin",this.onSurfaceFocusIn),trigger.removeEventListener("focusout",this.onSurfaceFocusOut)}startLightDismiss(){const nextDocument=this.ownerDocument;this.lightDismissDocument!==nextDocument&&(this.stopLightDismiss(),nextDocument.addEventListener("pointerdown",this.onDocumentPointer),this.lightDismissDocument=nextDocument)}stopLightDismiss(){this.lightDismissDocument?.removeEventListener("pointerdown",this.onDocumentPointer),this.lightDismissDocument=void 0}observeHostId(){const ownerDocument=this.ownerDocument;if(this.hostIdObserver&&this.hostIdObserverDocument===ownerDocument)return;this.resetHostIdObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor||!this.isConnected)return;const generation=this.hostIdObserverGeneration,observer=new MutationObserverCtor(()=>{this.hostIdObserver!==observer||this.hostIdObserverDocument!==ownerDocument||this.hostIdObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||(this.id||(this.id=this.generatedHostId),this.syncTriggerA11y())});this.hostIdObserver=observer,this.hostIdObserverDocument=ownerDocument,observer.observe(this,{attributes:!0,attributeFilter:["id"]})}resetHostIdObserver(){this.hostIdObserverGeneration+=1,this.hostIdObserver?.disconnect(),this.hostIdObserver=void 0,this.hostIdObserverDocument=void 0}setOpen(next){if(this._open===next)return;const old=this._open;this._open=next,setCustomState(this.popoverInternals,"open",next),this.requestUpdate("open",old)}syncOpenAttribute(){this.toggleAttribute("open",this._open)}show(){return this._open||!this.canOpen?Promise.resolve():this.transitionGate.request(!0,()=>{if(this.emitCancelableLifecycle("lr-show").defaultPrevented){this.syncOpenAttribute();return}if(!this.closePopoverPeers()){this.syncOpenAttribute();return}return this.cancelTransitionAnimation(),this.removeAttribute("data-closing"),this.setOpen(!0),this.settleTransition("lr-after-show")})}hide(options){return this._open?this.transitionGate.request(!1,()=>{if(this.emitCancelableLifecycle("lr-hide").defaultPrevented){this.syncOpenAttribute();return}return this.forceClose(options)}):Promise.resolve()}closePopoverPeers(){if(this.virtualAnchor||this.localName!==tag("popover"))return!0;const root=this.getRootNode();for(const peer of root.querySelectorAll(tag("popover")))if(!(peer===this||!peer.open||peer.virtualAnchor)&&(peer.hide({focusTrigger:!1}),peer.open))return!1;return!0}reconcileInitialPopoverPeers(){if(!this.isConnected||!this._open||this.virtualAnchor||this.localName!==tag("popover"))return;const peers=[...this.getRootNode().querySelectorAll(tag("popover"))].filter(peer=>peer.isConnected&&peer._open&&!peer.virtualAnchor&&peer.connectionSequence>0);if(peers.reduce((latest,peer)=>!latest||peer.connectionSequence>latest.connectionSequence?peer:latest,void 0)!==this){this.closeForInitialPeerReconciliation();return}for(const peer of peers)peer!==this&&peer.closeForInitialPeerReconciliation()}closeForInitialPeerReconciliation(){this._open&&(this.transitionToken++,this.cancelTransitionAnimation(),this.removeAttribute("data-closing"),this.invalidatePositioning(),this.stopLightDismiss(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.positionedAnchor=void 0,this.anchorPositioned=!1,this.returnFocusTo=void 0,this.setOpen(!1),this.syncOpenAttribute())}forceClose(options){return this._open?(options?.focusTrigger===!1&&(this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0),this.cancelTransitionAnimation(),this.isConnected&&this.setAttribute("data-closing",""),this.setOpen(!1),this.settleTransition("lr-after-hide")):Promise.resolve()}cancelTransitionAnimation(){this.transitionAnimation?.cancel(),this.transitionAnimation=void 0}emitCancelableLifecycle(name){return this.emit(name,null,{cancelable:!0})}emitSettledLifecycle(name){return this.emit(name)}async settleTransition(event){const token=++this.transitionToken;if(await this.updateComplete,this.transitionToken===token){if(event==="lr-after-show"){for(;this.open&&!this.anchorPositioned;){const readiness=this.positioningReady,positioned=await readiness;if(this.transitionToken!==token)return;if(positioned)break;if(readiness===this.positioningReady)return}if(await this.updateComplete,this.transitionToken!==token)return}if(this.isConnected){const popup=this.renderRoot.querySelector('[part~="popup"]'),showing=event==="lr-after-show",offset="translateY(var(--lr-size-neg-0-25rem))",animation=popup?animateRegistered(this,popup,`${this.animationNamespace}.${showing?"show":"hide"}`,this.effectiveDirection,{keyframes:showing?[{opacity:0,transform:offset},{opacity:1,transform:"translateY(0)"}]:[{opacity:1,transform:"translateY(0)"},{opacity:0,transform:offset}],durationProperties:this.animationDurationProperties(showing),easingProperties:["--lr-easing-standard"]}):void 0;if(this.transitionAnimation=animation,await animation?.finished.catch(()=>{}),this.transitionToken!==token)return;this.cancelTransitionAnimation()}event==="lr-after-hide"&&(this.removeAttribute("data-closing"),this.popupHidden=!0,await this.updateComplete,this.transitionToken!==token)||this.emitSettledLifecycle(event)}}render(){const popupRole=this.popupSurfaceRole;return html`
|
|
2
2
|
<span part="trigger" @click=${this.onTriggerClick} @keydown=${this.onTriggerKeyDown}>
|
|
3
3
|
<slot name="trigger" @slotchange=${this.onTriggerSlotChange}></slot>
|
|
4
4
|
</span>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{type SelectionCatalogRow}from'./internal/selection-catalog.js';declare const countryCodes:readonly['AD','AE','AF','AG','AI','AL','AM','AO','AQ','AR','AS','AT','AU','AW','AX','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BJ','BL','BM','BN','BO','BQ','BR','BS','BT','BV','BW','BY','BZ','CA','CC','CD','CF','CG','CH','CI','CK','CL','CM','CN','CO','CR','CU','CV','CW','CX','CY','CZ','DE','DJ','DK','DM','DO','DZ','EC','EE','EG','EH','ER','ES','ET','FI','FJ','FK','FM','FO','FR','GA','GB','GD','GE','GF','GG','GH','GI','GL','GM','GN','GP','GQ','GR','GS','GT','GU','GW','GY','HK','HM','HN','HR','HT','HU','ID','IE','IL','IM','IN','IO','IQ','IR','IS','IT','JE','JM','JO','JP','KE','KG','KH','KI','KM','KN','KP','KR','KW','KY','KZ','LA','LB','LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','ME','MF','MG','MH','MK','ML','MM','MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MX','MY','MZ','NA','NC','NE','NF','NG','NI','NL','NO','NP','NR','NU','NZ','OM','PA','PE','PF','PG','PH','PK','PL','PM','PN','PR','PS','PT','PW','PY','QA','RE','RO','RS','RU','RW','SA','SB','SC','SD','SE','SG','SH','SI','SJ','SK','SL','SM','SN','SO','SR','SS','ST','SV','SX','SY','SZ','TC','TD','TF','TG','TH','TJ','TK','TL','TM','TN','TO','TR','TT','TV','TW','TZ','UA','UG','UM','US','UY','UZ','VA','VC','VE','VG','VI','VN','VU','WF','WS','YE','YT','ZA','ZM','ZW'];
|
|
2
|
+
/** A country or territory code in the library's pinned ISO catalog. */
|
|
3
|
+
export type LyraCountryCode=typeof countryCodes[number];
|
|
4
|
+
/** Frozen ISO alpha-2 catalog; display names are resolved separately for the chosen locale. */
|
|
5
|
+
export declare const COUNTRY_CODES:readonly LyraCountryCode[];export interface LyraCountryEntry{readonly code:string;readonly label?:string;readonly group?:string;readonly disabled?:boolean;}export type LyraCountryCatalog=readonly string[]|readonly LyraCountryEntry[];
|
|
6
|
+
/** Display-only localization; explicit caller names and ordering remain authoritative. */
|
|
7
|
+
export declare function resolveCountryNames(countries:LyraCountryCatalog,locale:string):readonly SelectionCatalogRow[];export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getDisplayNames}from"./internal/intl-cache.js";import{snapshotSelectionCatalog}from"./internal/selection-catalog.js";const countryCodes=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","ZA","ZM","ZW"],COUNTRY_CODES=Object.freeze(countryCodes);function resolveCountryNames(countries,locale){const entries=snapshotSelectionCatalog(countries,code=>code.trim().toUpperCase(),code=>/^[A-Z]{2}$/.test(code))??[];return Object.freeze(entries.map(entry=>{let name=entry.code;try{name=getDisplayNames(locale,{type:"region",fallback:"code"}).of(entry.code)??entry.code}catch{}const label=entry.label??name;return Object.freeze({...entry,label,searchText:[entry.code,name,label].join(" ")})}))}export{COUNTRY_CODES,resolveCountryNames};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type{LyraCurrencyCatalog,LyraCurrencyDisplayEntry}from'./components/forms/currency-picker/currency-types.js';export{CURRENCY_CODES}from'./components/forms/currency-picker/currency-catalog.js';export type{LyraCurrencyCode}from'./components/forms/currency-picker/currency-catalog.js';export type{LyraCurrencyCatalog,LyraCurrencyDisplayEntry,LyraCurrencyEntry,}from'./components/forms/currency-picker/currency-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Return immutable localized display data for the full ISO catalog, or a caller-ordered subset.
|
|
4
|
+
* The full catalog includes XTS and XXX; the picker's omitted catalog excludes those sentinels.
|
|
5
|
+
* Custom three-letter codes are supported. An explicit empty catalog remains empty.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getCurrencyCatalog(locale:string,currencies?:LyraCurrencyCatalog):readonly LyraCurrencyDisplayEntry[];
|
|
8
|
+
/** Quotes are units of each currency per one unit of base; absent quotes remain unavailable. */
|
|
9
|
+
export interface LyraCurrencyRateSnapshot{readonly base:string;
|
|
10
|
+
/** Provider as-of metadata, or null when unknown; never the helper's fetch time. */
|
|
11
|
+
readonly date:string|null;readonly rates:Readonly<Partial<Record<string,number>>>;}
|
|
12
|
+
/** Cancellation for a single independent load; providers own transport, authentication and cache. */
|
|
13
|
+
export interface LyraCurrencyRateLoadOptions{readonly signal?:AbortSignal;}
|
|
14
|
+
/** A caller-supplied provider mapping its response to the canonical snapshot shape. */
|
|
15
|
+
export type LyraCurrencyRateLoader=(context:{readonly signal:AbortSignal;})=>Promise<unknown>;
|
|
16
|
+
/** Static data or an explicit provider; the library does not select an exchange-rate service. */
|
|
17
|
+
export type LyraCurrencyRateSource=LyraCurrencyRateSnapshot|LyraCurrencyRateLoader;
|
|
18
|
+
/**
|
|
19
|
+
* Validate, clone and freeze a partial rate table with at most 512 currencies, including base.
|
|
20
|
+
* Accept only plain or null-prototype own-data records, positive finite numeric quotes and
|
|
21
|
+
* an explicit null or nonblank date of at most 128 UTF-16 code units. Reject duplicate normalized
|
|
22
|
+
* codes and conflicting base quotes; add only the exact base identity of 1 when absent.
|
|
23
|
+
* Throws TypeError for malformed data or RangeError for an oversized table.
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeCurrencyRates(input:unknown):LyraCurrencyRateSnapshot;
|
|
26
|
+
/**
|
|
27
|
+
* Convert finite signed amounts using the snapshot's common base without rounding.
|
|
28
|
+
* Require both quotes even for zero or same-currency requests. Throw RangeError for missing
|
|
29
|
+
* quotes or results outside finite nonzero numeric range, and TypeError for malformed input.
|
|
30
|
+
* Applications retain responsibility for monetary rounding and historical-rate policy.
|
|
31
|
+
*/
|
|
32
|
+
export declare function convertCurrency(amount:number,from:string,to:string,snapshot:LyraCurrencyRateSnapshot):number;
|
|
33
|
+
/**
|
|
34
|
+
* Normalize static data or invoke an explicit loader once with a cancellation signal.
|
|
35
|
+
* Cancellation rejects promptly with the signal's reason, including when a provider ignores it;
|
|
36
|
+
* late results are observed but discarded. Preserve provider errors and release abort listeners
|
|
37
|
+
* on every outcome. Each call is independent; applications own latest-request assignment guards.
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadCurrencyRates(source:LyraCurrencyRateSource,options?:LyraCurrencyRateLoadOptions):Promise<LyraCurrencyRateSnapshot>;
|
package/dist/currency.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{CURRENCY_CODES,normalizeCurrencyCatalog,normalizeCurrencyValue}from"./components/forms/currency-picker/currency-catalog.js";import{resolveCurrencyPresentation}from"./components/forms/currency-picker/currency-presentation.js";import{getOwnDataDescriptor}from"./internal/data-descriptors.js";import{CURRENCY_CODES as CURRENCY_CODES2}from"./components/forms/currency-picker/currency-catalog.js";function getCurrencyCatalog(locale,currencies){const entries=normalizeCurrencyCatalog(currencies??CURRENCY_CODES)??[],rows=resolveCurrencyPresentation(entries,locale).map(entry=>Object.freeze({code:entry.code,label:entry.label,symbol:entry.symbol,narrowSymbol:entry.narrowSymbol,disabled:entry.disabled,...entry.group===void 0?{}:{group:entry.group}}));return Object.freeze(rows)}function requireRecord(value){if(value===null||typeof value!="object")throw new TypeError("Expected a currency data record.");let prototype;try{if(Array.isArray(value))throw new TypeError("Currency data records cannot be arrays.");prototype=Object.getPrototypeOf(value)}catch{throw new TypeError("Cannot inspect the currency data record.")}if(prototype!==null&&prototype!==Object.prototype)throw new TypeError("Expected a plain currency data record.");return value}function requireOwnValue(record,key){const descriptor=getOwnDataDescriptor(record,key);if(typeof descriptor=="symbol")throw new TypeError("Currency data requires own data fields.");return descriptor.value}function requireCode(value){const code=normalizeCurrencyValue(value);if(!/^[A-Z]{3}$/.test(code))throw new TypeError("Currency codes must contain three ASCII letters.");return code}function normalizeCurrencyRates(input){const record=requireRecord(input),base=requireCode(requireOwnValue(record,"base")),date=requireOwnValue(record,"date");if(date!==null&&(typeof date!="string"||date.length>128||!date.trim()))throw new TypeError("Currency rate dates must be null or bounded nonblank provider metadata.");const sourceRates=requireRecord(requireOwnValue(record,"rates"));let keys;try{keys=Reflect.ownKeys(sourceRates)}catch{throw new TypeError("Cannot inspect the currency rate keys.")}if(keys.length>512)throw new RangeError("Currency rate tables are limited to 512 codes.");const rates=Object.create(null),seen=new Set;for(const key of keys){const code=requireCode(key);if(seen.has(code))throw new TypeError("Currency rate codes must be unique after normalization.");const rate=requireOwnValue(sourceRates,key);if(typeof rate!="number"||!Number.isFinite(rate)||rate<=0)throw new TypeError("Currency rates must be positive finite numbers.");if(code===base&&rate!==1)throw new TypeError("The base currency rate must equal 1.");seen.add(code),rates[code]=rate}if(!seen.has(base)){if(seen.size===512)throw new RangeError("Currency rate tables are limited to 512 codes including base.");rates[base]=1}return Object.freeze({base,date,rates:Object.freeze(rates)})}function convertCurrency(amount,from,to,snapshot){if(typeof amount!="number"||!Number.isFinite(amount))throw new TypeError("Currency amounts must be finite numbers.");const fromCode=requireCode(from),toCode=requireCode(to),normalized=normalizeCurrencyRates(snapshot),fromRate=normalized.rates[fromCode],toRate=normalized.rates[toCode];if(fromRate===void 0||toRate===void 0)throw new RangeError("A requested currency quote is unavailable.");if(fromCode===toCode||amount===0)return amount;const ratio=toRate/fromRate,normalRatio=Number.isFinite(ratio)&&ratio>=2**-1022;let result=normalRatio?amount*ratio:amount/fromRate*toRate;if((!Number.isFinite(result)||result===0)&&(result=normalRatio?amount/fromRate*toRate:amount*ratio),!Number.isFinite(result)||result===0)throw new RangeError("The converted amount is outside the numeric range.");return result}function loadCurrencyRates(source,options={}){const signal=options.signal??new AbortController().signal;return signal.aborted?Promise.reject(signal.reason):new Promise((resolve,reject)=>{let settled=!1;const cleanup=()=>signal.removeEventListener("abort",onAbort),fail=reason=>{settled||(settled=!0,cleanup(),reject(reason))},onAbort=()=>fail(signal.reason),accept=input=>{if(!settled){if(signal.aborted){onAbort();return}try{const normalized=normalizeCurrencyRates(input);if(signal.aborted){onAbort();return}settled=!0,cleanup(),resolve(normalized)}catch(error){fail(signal.aborted?signal.reason:error)}}};if(signal.addEventListener("abort",onAbort,{once:!0}),signal.aborted){onAbort();return}if(typeof source!="function"){accept(source);return}try{Promise.resolve(source({signal})).then(accept,error=>fail(signal.aborted?signal.reason:error))}catch(error){fail(signal.aborted?signal.reason:error)}})}export{CURRENCY_CODES2 as CURRENCY_CODES,convertCurrency,getCurrencyCatalog,loadCurrencyRates,normalizeCurrencyRates};
|