import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraLocaleDirection}from'../../../internal/localization.js';import type{LyraSize}from'../../../internal/variants.js';import{type FormOwnerValue}from'../../../internal/form-associated.js'; /** `true`-defaulting boolean attribute converter -- Lit's default presence-based `type: Boolean` * can never be set back to `false` from a plain-HTML attribute once a property's own default is * `true` (removing an attribute that was never present fires no `attributeChangedCallback`), so * `fromAttribute` checks the literal string instead. Duplicated locally rather than imported, * matching this exact converter's repeated per-component convention elsewhere in this library. * `showFlags` (the only property using this converter) doesn't set `reflect: true`, so there's * no `toAttribute` half -- Lit only calls it when reflecting. */ /** One offered locale row. `label` overrides the derived `localeNativeName(tag)` endonym when * given -- e.g. offering a locale before its strings are registered ("Français (bientôt)"). * `country` overrides the row's derived flag country when given -- e.g. showing Lebanon's flag * for an `'ar'` row instead of the library's default Saudi Arabia mapping. */ export interface LyraLocaleEntry{ /** BCP-47 locale tag, e.g. `'pt-BR'`. */ readonly tag:string; /** Overrides `localeNativeName(tag)` when given. */ readonly label?:string; /** ISO 3166-1 alpha-2 or alpha-3 country code (e.g. `'lb'` or `'lbn'`) overriding this row's `` derivation * -- when given, the row renders `` instead of the default * ``. Unset (the default) keeps today's tag-derived flag. Ignored * while `showFlags` is `false`. */ readonly country?:string;} /** `locales` accepts either a plain array of BCP-47 tags (endonym label derived automatically, * no per-row flag override available) or `{ tag, label, country }` rows for custom * labels/ordering/subsets/flag overrides. */ export type LyraLocaleCatalog=readonly string[]|readonly LyraLocaleEntry[]; /** Visible content of the locale picker's trigger; option labels are always retained. */ export type LyraLocaleTriggerDisplay='flag'|'label'|'flag-label'; /** Visible content of each option row's label column; the trigger is unaffected. */ export type LyraLocaleOptionDisplay='label'|'label-tag'; /** `lr-change`'s detail. `direction` is the picked locale's writing direction, resolved through * `getLyraLocaleDirection()` — the component never applies it (see the class doc), it just hands * the host the one fact it would otherwise need its own locale table to know. */ export interface LyraLocaleChangeDetail{value:string;previousValue:string;direction:LyraLocaleDirection;}export interface LyraLocalePickerEventMap{'lr-invalid':CustomEvent;'lr-change':CustomEvent;blur:FocusEvent;focus:FocusEvent;} /** * `` — a closed-list locale switcher over the library's own locale registry. * * With `locales` left unset (the default), the offered rows are exactly * `getRegisteredLyraLocales()` — every locale with strings registered via `registerLyraLocale()`, * plus `'en'` (always available through the library's built-in English fallback) — kept live via * `subscribeLyraLocaleRegistry()` so a locale registered after mount (e.g. a lazily-loaded * translation pack) appears without a manual refresh. Passing an explicit `locales` array * overrides the auto-discovered list entirely: a curated subset, a custom order, custom labels, * or a locale the host wants to offer before its strings are registered. * * `value` is the *committed* selection (form-submitted, drives `lr-change`) and starts `''`. * While unset, the trigger displays `effectiveLocale` (the same ancestor-`lang`/registry * resolution every other component already uses) as a live preview — but that preview is never a * commitment: `checkValidity()`/`required` are governed by the real `value`, which stays `''` * until the host sets it or the user actually picks a row. This mirrors a native `` matches neither `:valid` nor * `:invalid`. Without this guard a `` kept publishing * `valueMissing` and `:state(invalid)`, which is what painted every disabled picker with the * documented `lr-locale-picker:state(user-invalid)` error styling. This only writes the * library-owned intrinsic layer; `AnchoredValidityController` preserves a caller's custom error * while the localized required message changes. */ private updateValidity; /** A localized catalog can change without a named Lit property change, so compare both the * resolved locale and the current intrinsic message during each update. The comparison makes * the controller write only when a library-owned validation input actually changed. */ private refreshLocalizedIntrinsicValidity;private hasMissingRequiredValue; /** Lit reflects a changed property after rendering. This component's localizer resolves the * host attribute, so synchronize an explicit locale before either render-time or intrinsic * validation text asks it for the effective message locale. */ private syncLocaleAttributeForLocalization; /** Whether constraint validation is currently barred. Shares the library-wide predicate rather * than re-listing the conditions, so this control cannot implement three of them and miss the * fourth. This picker has no `readonly` of its own; the shared predicate simply never sees one. */ private isBarred; /** * Publishes the six validity custom states (`:state(required)`/`optional`, `valid`/`invalid`, * `user-valid`/`user-invalid`). Shared implementation in `internal/custom-states.ts`: this * component drives `ElementInternals` directly rather than through the `FormAssociated` mixin, * so it calls the helper itself instead of inheriting the call. `touched` is its own interaction * flag (set when the trigger blurs, or by interactive validation -- `reportValidity()` and a * submission attempt alike, via `installInteractionOnInvalid()`), which is what keeps the * `user-*` pair off a pristine control the way native `:user-invalid` does. A silent * `checkValidity()` alone never counts. */ private syncCustomStates;private markInteracted;formResetCallback():void;private restoreLiveValueFromDefault;formStateRestoreCallback(state:string|File|FormData|null,_mode?:'restore'|'autocomplete'):void;formDisabledCallback(disabled:boolean):void;checkValidity():boolean;reportValidity():boolean; /** * Sets or clears a consumer-supplied validation error — the standard channel for a server-side * rejection ("that locale is not enabled for your account") that no client-side constraint can * express. A non-empty `message` raises `customError` and becomes `validationMessage`, so the * control fails `checkValidity()`, blocks form submission, and matches `:state(invalid)`; `''` * clears it. * * Clearing restores the control's own computed validity rather than forcing it valid: a required * picker with nothing committed stays `valueMissing`. The custom error also survives every * intrinsic recomputation in between (each `value`/`required` change re-runs `updateValidity()`) * and a form reset, exactly like a native control — only another `setCustomValidity('')` clears * it. * * The message is caller-supplied content, so it is used verbatim and never localized here. */ setCustomValidity(message:string):void; /** `locales` normalized to `{ tag, label }[]`: every explicit catalog wins outright, including * an empty array; only `undefined` selects every locale * `getRegisteredLyraLocales()` currently reports. */ private get normalizedEntries(); /** The tag actually shown in the trigger: the committed `value` once set, else a live preview * of `effectiveLocale` -- never a committed selection, see the class doc's value/preview * split. * * The `||` here (and `hasMissingRequiredValue()`'s `!this._value`) is deliberately NOT the * truthiness bug ``/`` were corrected for. There, `''` was a legitimate * option value being misread as "no value". Here `''` cannot be a row: `snapshotLocaleCatalog()` * drops a zero-length `tag`, and a BCP-47 tag has at least a primary language subtag, so the * empty string is this control's one documented "nothing committed" sentinel -- the very state * the preview and the `valueMissing` constraint exist to express. Treating `''` as a candidate * value would break both. */ private get previewTag();private entryFor; /** A tag with no row falls back to its derived endonym rather than to a "not in catalog" badge, * unlike ``/``. The catalog here is live: with `locales` unset * it tracks `getRegisteredLyraLocales()`, so a value restored from a profile is routinely * legitimate-but-not-yet-listed for as long as its translation pack takes to register. Badging * it would flag a correct value as stale, which is the same false alarm `` * suppresses while an async `source` fetch is still in flight. */ private labelFor;private show;private hide;private dismissFromEscape;private onDocPointer;private bindDocumentPointer;private unbindDocumentPointer;private activatePopupOverlay;private deactivatePopupOverlay;private syncPopup;protected updated(changed:PropertyValues):void; /** Commits `tag`: sets `value`, closes the popup, then emits a cancelable `lr-change` -- * applying `setLyraLocale(tag)` itself only when the listener doesn't veto it. Unconditional * on every explicit pick (no reselect-guard), mirroring ``'s identical * `commitValue()` -- the closest sibling precedent for this event shape. */ private commit;private onTriggerClick;private onTriggerBlur;private onTriggerFocus;private onLabelSlotChange;private onHintSlotChange;private onErrorSlotChange; /** Standard listbox type-ahead: moves to the next row whose native name starts with the * accumulated buffer, cycling from just after the "current" row (the active row while open, * the preview tag while closed). While open this only moves `activeIndex` (a highlight, * matching Arrow-key nav); while closed it commits immediately, matching ``'s * identical closed-state type-ahead. */ private typeAhead; /** Discards an armed buffer reset. `cancel()`, never `dispose()`: a disconnect here may be a * re-parent, and a disposed controller would refuse every later keystroke's reset for good. */ private clearTypeAheadTimer; /** Updates active-descendant ownership and keeps the resulting row visible after render. */ private setActiveIndex;private queueActiveScroll;private onKeyDown;private onListboxMouseDown;private onListboxClick;private renderRows;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-locale-picker':LyraLocalePicker;}}