@f-ewald/components 1.23.1 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/custom-elements.json +1882 -595
- package/dist/address-autocomplete.d.ts.map +1 -1
- package/dist/address-autocomplete.js +7 -3
- package/dist/address-autocomplete.js.map +1 -1
- package/dist/audio-player.d.ts +53 -0
- package/dist/audio-player.d.ts.map +1 -0
- package/dist/audio-player.js +267 -0
- package/dist/audio-player.js.map +1 -0
- package/dist/autocomplete-input.d.ts.map +1 -1
- package/dist/autocomplete-input.js +7 -3
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/button-group.d.ts +12 -1
- package/dist/button-group.d.ts.map +1 -1
- package/dist/button-group.js +35 -3
- package/dist/button-group.js.map +1 -1
- package/dist/comment-composer.d.ts +54 -0
- package/dist/comment-composer.d.ts.map +1 -0
- package/dist/comment-composer.js +244 -0
- package/dist/comment-composer.js.map +1 -0
- package/dist/confirm-dialog.d.ts +4 -1
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +47 -9
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/dropdown-button.d.ts +4 -1
- package/dist/dropdown-button.d.ts.map +1 -1
- package/dist/dropdown-button.js +29 -3
- package/dist/dropdown-button.js.map +1 -1
- package/dist/icons.d.ts +12 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +12 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/page-header.d.ts +8 -3
- package/dist/page-header.d.ts.map +1 -1
- package/dist/page-header.js +33 -12
- package/dist/page-header.js.map +1 -1
- package/dist/pagination-nav.d.ts +7 -0
- package/dist/pagination-nav.d.ts.map +1 -1
- package/dist/pagination-nav.js +19 -4
- package/dist/pagination-nav.js.map +1 -1
- package/dist/radio-cards.d.ts +6 -0
- package/dist/radio-cards.d.ts.map +1 -1
- package/dist/radio-cards.js +13 -3
- package/dist/radio-cards.js.map +1 -1
- package/dist/radio-pills.d.ts +6 -0
- package/dist/radio-pills.d.ts.map +1 -1
- package/dist/radio-pills.js +13 -3
- package/dist/radio-pills.js.map +1 -1
- package/dist/range-slider.d.ts.map +1 -1
- package/dist/range-slider.js +11 -7
- package/dist/range-slider.js.map +1 -1
- package/dist/reveal-button.d.ts +5 -1
- package/dist/reveal-button.d.ts.map +1 -1
- package/dist/reveal-button.js +26 -4
- package/dist/reveal-button.js.map +1 -1
- package/dist/tokens.css +38 -1
- package/dist/tokens.d.ts +16 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +93 -0
- package/dist/tokens.js.map +1 -1
- package/dist/ui-button.d.ts +18 -0
- package/dist/ui-button.d.ts.map +1 -1
- package/dist/ui-button.js +50 -7
- package/dist/ui-button.js.map +1 -1
- package/dist/utils/duration.d.ts +8 -0
- package/dist/utils/duration.d.ts.map +1 -1
- package/dist/utils/duration.js +18 -0
- package/dist/utils/duration.js.map +1 -1
- package/dist/utils/transport-controls.d.ts +11 -0
- package/dist/utils/transport-controls.d.ts.map +1 -0
- package/dist/utils/transport-controls.js +113 -0
- package/dist/utils/transport-controls.js.map +1 -0
- package/dist/video-player.d.ts +60 -0
- package/dist/video-player.d.ts.map +1 -0
- package/dist/video-player.js +324 -0
- package/dist/video-player.js.map +1 -0
- package/docs/audio-player.md +60 -0
- package/docs/button-group.md +18 -1
- package/docs/comment-composer.md +68 -0
- package/docs/confirm-dialog.md +19 -1
- package/docs/dropdown-button.md +10 -1
- package/docs/icons.md +6 -0
- package/docs/page-header.md +11 -4
- package/docs/pagination-nav.md +14 -0
- package/docs/radio-cards.md +9 -0
- package/docs/radio-pills.md +9 -0
- package/docs/range-slider.md +3 -0
- package/docs/reveal-button.md +11 -1
- package/docs/ui-button.md +34 -0
- package/docs/video-player.md +59 -0
- package/llms.txt +165 -23
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-autocomplete.d.ts","sourceRoot":"","sources":["../src/address-autocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAI1E,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,mCAAmC;AACnC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAOD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,mBAAoB,SAAQ,UAAU;;IACjD,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"address-autocomplete.d.ts","sourceRoot":"","sources":["../src/address-autocomplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAI1E,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,mCAAmC;AACnC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAOD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBACa,mBAAoB,SAAQ,UAAU;;IACjD,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAgB,MAAM,4BAgNpB;IAEF,mFAAmF;IACvE,KAAK,SAAM;IACvB,sDAAsD;IAC1C,WAAW,SAAM;IAC7B,8DAA8D;IACjC,QAAQ,UAAS;IAC9C,0DAA0D;IACd,QAAQ,UAAS;IAC7D,oEAAoE;IACxB,SAAS,UAAS;IAC9D,6DAA6D;IACjD,KAAK,SAAa;IAC9B,+EAA+E;IACnE,QAAQ,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
125
125
|
justify-content: center;
|
|
126
|
+
box-sizing: border-box;
|
|
126
127
|
width: 2rem;
|
|
127
128
|
height: 2rem;
|
|
128
|
-
|
|
129
|
+
/* Insets the hover/focus background by the input's 1px border so it
|
|
130
|
+
stays fully inside the field instead of painting over the border. */
|
|
131
|
+
padding: 1px;
|
|
132
|
+
background-clip: content-box;
|
|
129
133
|
border: 0;
|
|
130
134
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
131
135
|
color: var(--ui-text-muted, #64748b);
|
|
132
|
-
background: transparent;
|
|
136
|
+
background-color: transparent;
|
|
133
137
|
cursor: pointer;
|
|
134
138
|
line-height: 0;
|
|
135
139
|
}
|
|
136
140
|
.clear-button:hover {
|
|
137
141
|
color: var(--ui-text, #0f172a);
|
|
138
|
-
background: var(--ui-surface-muted, #f8fafc);
|
|
142
|
+
background-color: var(--ui-surface-muted, #f8fafc);
|
|
139
143
|
}
|
|
140
144
|
.clear-button:focus-visible {
|
|
141
145
|
outline: none;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-autocomplete.js","sourceRoot":"","sources":["../src/address-autocomplete.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,gBAAgB,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,IAAI,aAAa,GAAG,CAAC,CAAC;AActB;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,UAAU;I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gB;AAEC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAgB;AAEU;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;sDAAe;AAMnC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;wDAAgD;AAE9D;IAAhB,KAAK,EAAE;yDAAgD;AACvC;IAAhB,KAAK,EAAE;kDAAuB;AACd;IAAhB,KAAK,EAAE;yDAA2B;AAClB;IAAhB,KAAK,EAAE;0DAA+B;AACtB;IAAhB,KAAK,EAAE;6DAAgE;AAEhD;IAAvB,KAAK,CAAC,OAAO,CAAC;mDAAmC;AAtPvC,mBAAmB;IAD/B,aAAa,CAAC,sBAAsB,CAAC;GACzB,mBAAmB,CAykB/B;;AAED,oGAAoG;AACpG,SAAS,aAAa,CAAC,QAAgC;IACrD,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC;QAC3C,IAAI,CAAC,OAAO;YAAE,SAAS;QACvB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC1C,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n formFieldControl,\n type FormFieldControlConfig,\n} from \"./utils/form-field-control.js\";\nimport { submitWithDefaultButton } from \"./utils/form.js\";\n\nlet instanceCount = 0;\n\n/** A picked address suggestion. */\nexport interface AddressSuggestion {\n address: string;\n lat: number;\n lng: number;\n}\n\ninterface MapboxGeocodeFeature {\n properties?: { full_address?: string };\n geometry: { coordinates: [number, number] };\n}\n\n/**\n * Form-associated text input with a suggestion dropdown. Works as a\n * drop-in replacement for a plain `<input name=\"address\">`: consumers keep\n * reading `new FormData(form).get(\"address\")` and calling `form.reset()`\n * unchanged.\n *\n * Supports two suggestion sources:\n * - **API** (default): fetches from `endpoint`, a Mapbox Geocoding v6-shaped\n * forward-geocode URL, debounced as the user types.\n * - **Local array**: set `suggestions` to a fixed `AddressSuggestion[]` and\n * the component filters it client-side instead of making any network\n * request. Useful for small/fixed address lists, offline use, or tests.\n * Takes priority over `endpoint` whenever it's non-null.\n *\n * Set `clearable` to show an in-field clear action whenever a value is\n * present.\n *\n * @element address-autocomplete\n * @fires address-select - A suggestion was picked; detail: AddressSuggestion.\n * @fires input - Native-compatible input event fired while editing or clearing.\n */\n@customElement(\"address-autocomplete\")\nexport class AddressAutocomplete extends LitElement {\n static formAssociated = true;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n position: relative;\n }\n .field-shell {\n position: relative;\n }\n input {\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface, #ffffff);\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n width: 100%;\n height: 2rem;\n box-sizing: border-box;\n }\n .field-shell.clearable input {\n padding-right: 2rem;\n }\n .clear-button {\n position: absolute;\n top: 0;\n right: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n border: 0;\n border-radius: var(--ui-radius-sm, 0.25rem);\n color: var(--ui-text-muted, #64748b);\n background: transparent;\n cursor: pointer;\n line-height: 0;\n }\n .clear-button:hover {\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface-muted, #f8fafc);\n }\n .clear-button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .floating-label {\n position: absolute;\n top: 50%;\n left: 0.75rem;\n right: 0.75rem;\n z-index: 1;\n display: flex;\n align-items: baseline;\n gap: 0.25rem;\n overflow: hidden;\n transform: translateY(-50%);\n color: var(--ui-text-muted, #64748b);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n text-overflow: ellipsis;\n cursor: text;\n transition:\n top 150ms ease,\n transform 150ms ease,\n font-size 150ms ease;\n }\n .field-shell.clearable .floating-label {\n right: 2rem;\n }\n .field-shell.floating input {\n height: 3rem;\n padding-top: 1.25rem;\n padding-bottom: 0.25rem;\n }\n .field-shell.floating .clear-button {\n top: 0.5rem;\n }\n .field-shell.floating.has-value .floating-label,\n .field-shell.floating:focus-within .floating-label {\n top: 0.25rem;\n transform: none;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .field-shell.floating:not(.has-value):not(:focus-within) input::placeholder {\n opacity: 0;\n }\n .field-shell.disabled .floating-label {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .required-mark {\n flex: 0 0 auto;\n color: var(--ui-danger, #dc2626);\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n input:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n input:focus-visible {\n outline: none;\n border-color: var(--ui-primary, #4f46e5);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .suggestions {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 10;\n max-height: 40vh;\n overflow-y: auto;\n margin: 0.25rem 0 0;\n padding: 0.25rem 0;\n list-style: none;\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n .suggestion {\n padding: 0.5rem 0.75rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n cursor: pointer;\n }\n .suggestion.active,\n .suggestion:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .no-suggestions {\n padding: 0.5rem 0.75rem;\n color: var(--ui-text-muted, #64748b);\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-style: italic;\n }\n @media (forced-colors: active) {\n input:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n input:disabled {\n color: GrayText;\n opacity: 1;\n }\n .clear-button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: -2px;\n box-shadow: none;\n }\n .field-shell.disabled .floating-label {\n color: GrayText;\n opacity: 1;\n }\n .suggestion.active,\n .suggestion:hover {\n color: HighlightText;\n background: Highlight;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .floating-label {\n transition: none;\n }\n }\n `,\n ];\n\n /** Current input value; also the form-associated value submitted with the form. */\n @property() value = \"\";\n /** Placeholder text shown when the input is empty. */\n @property() placeholder = \"\";\n /** Marks the input as required for native form validation. */\n @property({ type: Boolean }) required = false;\n /** Disables the input and closes its suggestion popup. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n /** Shows an in-field clear action while the control has a value. */\n @property({ type: Boolean, reflect: true }) clearable = false;\n /** Mapbox `types` param, e.g. \"address\" or \"address,poi\". */\n @property() types = \"address\";\n /** Geocoding endpoint URL. Defaults to the Mapbox Geocoding v6 forward URL. */\n @property() endpoint: string = \"https://api.mapbox.com/search/geocode/v6/forward\";\n /** Mapbox access token. Required for requests to succeed. */\n @property({ attribute: \"access-token\" }) accessToken = \"\";\n /** Optional bounding box bias, comma-separated `west,south,east,north`. */\n @property() bbox = \"\";\n /** Optional proximity bias, comma-separated `lng,lat`. */\n @property() proximity = \"\";\n /** Debounce delay (ms) before firing a geocode request after typing. */\n @property({ type: Number }) debounce = 300;\n /** Minimum query length before suggestions are fetched. */\n @property({ type: Number, attribute: \"min-length\" }) minLength = 3;\n /**\n * Fixed candidate list to filter locally instead of fetching from\n * `endpoint`. When set (non-null), no network request is ever made —\n * this takes priority over the API mode.\n */\n @property({ attribute: false }) suggestions: AddressSuggestion[] | null = null;\n\n @state() private _suggestions: AddressSuggestion[] = [];\n @state() private _open = false;\n @state() private _activeIndex = -1;\n @state() private _formDisabled = false;\n @state() private _formFieldConfig: FormFieldControlConfig | null = null;\n\n @query(\"input\") private _input?: HTMLInputElement;\n\n #internals = this.attachInternals();\n #lastPicked: AddressSuggestion | null = null;\n #debounceTimer: ReturnType<typeof setTimeout> | null = null;\n #abortController: AbortController | null = null;\n #isComposing = false;\n #compositionJustEnded = false;\n #compositionEndTimer: ReturnType<typeof setTimeout> | null = null;\n readonly #inputId = `address-autocomplete-field-${++instanceCount}`;\n readonly #listboxId = `address-autocomplete-listbox-${instanceCount}`;\n\n /** Whether the host or an ancestor fieldset currently disables the control. */\n get #isDisabled(): boolean {\n return this.disabled || this._formDisabled;\n }\n\n /** Last-picked suggestion, or null once the input diverges from it. */\n get selectedSuggestion(): AddressSuggestion | null {\n if (this.#lastPicked && this.#lastPicked.address === this.value) return this.#lastPicked;\n return null;\n }\n\n /**\n * Applies or clears label configuration supplied by a wrapping `form-field`.\n * @private\n */\n [formFieldControl](config: FormFieldControlConfig | null): void {\n this._formFieldConfig = config;\n }\n\n protected override willUpdate(changed: PropertyValues) {\n if (changed.has(\"disabled\") && this.#isDisabled) {\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n this._open = false;\n this._activeIndex = -1;\n }\n }\n\n protected override updated(changed: PropertyValues) {\n if (changed.has(\"value\")) this.#internals.setFormValue(this.value);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n }\n\n /** Resets to empty on `form.reset()`, per the form-associated custom element contract. */\n formResetCallback() {\n this.value = \"\";\n this._suggestions = [];\n this._open = false;\n this.#lastPicked = null;\n }\n\n /** Mirrors ancestor fieldset disabled state onto the native input. */\n formDisabledCallback(disabled: boolean) {\n this._formDisabled = disabled;\n if (!disabled) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n this._open = false;\n this._activeIndex = -1;\n }\n\n private onInput(e: InputEvent) {\n if (this.#isDisabled) return;\n this.value = (e.target as HTMLInputElement).value;\n this.#lastPicked = null;\n this.#scheduleFetch(this.value);\n }\n\n #scheduleFetch(query: string) {\n if (this.#isDisabled) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n if (query.trim().length < this.minLength) {\n this._suggestions = [];\n this._open = false;\n this._activeIndex = -1;\n return;\n }\n if (this.suggestions) {\n // Local mode: filtering is synchronous and cheap, but keep the same\n // debounce as the API mode so the UX doesn't shift between sources.\n this.#debounceTimer = setTimeout(() => this.#filterLocalSuggestions(query), this.debounce);\n return;\n }\n this.#debounceTimer = setTimeout(() => void this.#fetchSuggestions(query), this.debounce);\n }\n\n /** Filters the locally-supplied `suggestions` list for `query`, case-insensitively. */\n #filterLocalSuggestions(query: string) {\n const needle = query.trim().toLowerCase();\n this._suggestions = (this.suggestions ?? [])\n .filter((s) => s.address.toLowerCase().includes(needle))\n .slice(0, 5);\n this._activeIndex = -1;\n this._open = !this.#isDisabled;\n }\n\n /** Fetches suggestions for `query`, cancelling any request still in flight. */\n async #fetchSuggestions(query: string) {\n this.#abortController?.abort();\n const controller = new AbortController();\n this.#abortController = controller;\n try {\n const res = await fetch(this.#buildUrl(query), { signal: controller.signal });\n if (!res.ok) throw new Error(`geocode request failed: ${res.status}`);\n const body = (await res.json()) as { features?: MapboxGeocodeFeature[] };\n if (this.#isDisabled) return;\n this._suggestions = parseFeatures(body.features ?? []);\n this._activeIndex = -1;\n this._open = true;\n } catch {\n // Aborted (superseded by newer keystroke) or a network failure while\n // typing — fail silently and just close the list.\n if (!controller.signal.aborted) {\n this._suggestions = [];\n this._open = false;\n }\n }\n }\n\n #buildUrl(query: string): string {\n const params = new URLSearchParams({\n q: query,\n access_token: this.accessToken,\n autocomplete: \"true\",\n limit: \"5\",\n types: this.types,\n });\n if (this.bbox) params.set(\"bbox\", this.bbox);\n if (this.proximity) params.set(\"proximity\", this.proximity);\n return `${this.endpoint}?${params.toString()}`;\n }\n\n private onKeydown(e: KeyboardEvent) {\n if (this.#isDisabled) return;\n if (e.isComposing || e.keyCode === 229 || this.#isComposing || this.#compositionJustEnded) {\n return;\n }\n if (e.key === \"ArrowDown\") this.#moveActive(1, e);\n else if (e.key === \"ArrowUp\") this.#moveActive(-1, e);\n else if (e.key === \"Enter\") this.#handleEnter(e);\n else if (e.key === \"Escape\") this.#handleEscape(e);\n }\n\n #moveActive(delta: number, e: KeyboardEvent) {\n if (!this._open || this._suggestions.length === 0) return;\n e.preventDefault();\n const n = this._suggestions.length;\n this._activeIndex = (this._activeIndex + delta + n) % n;\n }\n\n #handleEnter(e: KeyboardEvent) {\n const pick = this._suggestions[this._activeIndex] ?? this._suggestions[0];\n if (this._open && pick) {\n e.preventDefault();\n this.#selectSuggestion(pick);\n return;\n }\n if (this.#internals.form) {\n const form = this.#internals.form;\n window.setTimeout(() => {\n if (!e.defaultPrevented && form.isConnected) submitWithDefaultButton(form);\n });\n }\n }\n\n #handleEscape(e: KeyboardEvent) {\n if (!this._open) return;\n e.preventDefault();\n this._open = false;\n }\n\n private onBlur() {\n this._open = false;\n }\n\n private onCompositionStart(): void {\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = null;\n this.#compositionJustEnded = false;\n this.#isComposing = true;\n }\n\n private onCompositionEnd(): void {\n this.#isComposing = false;\n this.#compositionJustEnded = true;\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = setTimeout(() => {\n this.#compositionJustEnded = false;\n this.#compositionEndTimer = null;\n });\n }\n\n /** Clears composition state when the control can no longer receive keys. */\n #resetComposition(): void {\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = null;\n this.#isComposing = false;\n this.#compositionJustEnded = false;\n }\n\n #selectSuggestion(s: AddressSuggestion) {\n this.value = s.address;\n this.#lastPicked = s;\n this._open = false;\n this._suggestions = [];\n this.dispatchEvent(new CustomEvent<AddressSuggestion>(\"address-select\", { detail: s, bubbles: true, composed: true }));\n }\n\n /** Clears the field and all pending autocomplete state, then restores input focus. */\n #clear(): void {\n if (this.#isDisabled || !this.value) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#debounceTimer = null;\n this.#abortController?.abort();\n this.#abortController = null;\n this.#resetComposition();\n this.value = \"\";\n this.#lastPicked = null;\n this._suggestions = [];\n this._activeIndex = -1;\n this._open = false;\n this.#internals.setFormValue(\"\");\n this.dispatchEvent(\n new InputEvent(\"input\", {\n bubbles: true,\n composed: true,\n inputType: \"deleteContentBackward\",\n }),\n );\n this._input?.focus({ preventScroll: true });\n }\n\n /** Selects on mousedown (not click) so it wins over the input's blur, which closes the list. */\n #onSuggestionMousedown(e: MouseEvent, s: AddressSuggestion) {\n e.preventDefault();\n this.#selectSuggestion(s);\n }\n\n private renderSuggestions() {\n if (!this._open || this.#isDisabled) return nothing;\n return html`\n <ul id=${this.#listboxId} class=\"suggestions\" role=\"listbox\" aria-label=\"Address suggestions\">\n ${this._suggestions.map(\n (s, i) => html`\n <li\n id=${`${this.#listboxId}-option-${i}`}\n role=\"option\"\n aria-selected=${i === this._activeIndex}\n class=\"suggestion ${i === this._activeIndex ? \"active\" : \"\"}\"\n @mousedown=${(e: MouseEvent) => this.#onSuggestionMousedown(e, s)}\n >\n ${s.address}\n </li>\n `,\n )}\n ${this._suggestions.length === 0\n ? html`<li class=\"no-suggestions\" role=\"presentation\">\n <span role=\"status\">No suggestions found</span>\n </li>`\n : nothing}\n </ul>\n `;\n }\n\n override render() {\n const activeDescendant =\n this._open && !this.#isDisabled && this._activeIndex >= 0\n ? `${this.#listboxId}-option-${this._activeIndex}`\n : nothing;\n const expanded = this._open && !this.#isDisabled;\n const floating =\n Boolean(this._formFieldConfig?.floating) && Boolean(this._formFieldConfig?.label);\n const showClear = this.clearable && Boolean(this.value) && !this.#isDisabled;\n return html`\n <div\n class=\"field-shell ${this.clearable ? \"clearable\" : \"\"} ${floating\n ? \"floating\"\n : \"\"} ${this.value ? \"has-value\" : \"\"} ${this.#isDisabled ? \"disabled\" : \"\"}\"\n >\n ${floating\n ? html`\n <label class=\"floating-label\" for=${this.#inputId}>\n <span>${this._formFieldConfig!.label}</span>\n ${this._formFieldConfig!.required\n ? html`\n <span class=\"required-mark\" aria-hidden=\"true\">*</span>\n <span class=\"sr-only\"> (required)</span>\n `\n : nothing}\n </label>\n `\n : nothing}\n <input\n id=${this.#inputId}\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded=${expanded}\n aria-controls=${this.#listboxId}\n aria-activedescendant=${activeDescendant}\n .value=${this.value}\n placeholder=${this.placeholder}\n ?required=${this.required}\n ?disabled=${this.#isDisabled}\n autocomplete=\"off\"\n @input=${this.onInput}\n @compositionstart=${this.onCompositionStart}\n @compositionend=${this.onCompositionEnd}\n @keydown=${this.onKeydown}\n @blur=${this.onBlur}\n />\n ${showClear\n ? html`\n <button\n type=\"button\"\n class=\"clear-button\"\n aria-label=\"Clear address\"\n title=\"Clear address\"\n @mousedown=${(event: MouseEvent) => event.preventDefault()}\n @click=${() => this.#clear()}\n >\n ${iconX(18)}\n </button>\n `\n : nothing}\n ${this.renderSuggestions()}\n </div>\n `;\n }\n}\n\n/** Maps Mapbox v6 forward-geocode features to suggestions, skipping ones without a full_address. */\nfunction parseFeatures(features: MapboxGeocodeFeature[]): AddressSuggestion[] {\n const suggestions: AddressSuggestion[] = [];\n for (const f of features) {\n const address = f.properties?.full_address;\n if (!address) continue;\n const [lng, lat] = f.geometry.coordinates;\n suggestions.push({ address, lng, lat });\n }\n return suggestions;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"address-autocomplete\": AddressAutocomplete;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"address-autocomplete.js","sourceRoot":"","sources":["../src/address-autocomplete.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,gBAAgB,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,IAAI,aAAa,GAAG,CAAC,CAAC;AActB;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,UAAU;IAA5C;;QAqNL,mFAAmF;QACvE,UAAK,GAAG,EAAE,CAAC;QACvB,sDAAsD;QAC1C,gBAAW,GAAG,EAAE,CAAC;QAC7B,8DAA8D;QACjC,aAAQ,GAAG,KAAK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,EAAE,YAAY,EAAE,CAAC;sDAAe;AAMnC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;wDAAgD;AAE9D;IAAhB,KAAK,EAAE;yDAAgD;AACvC;IAAhB,KAAK,EAAE;kDAAuB;AACd;IAAhB,KAAK,EAAE;yDAA2B;AAClB;IAAhB,KAAK,EAAE;0DAA+B;AACtB;IAAhB,KAAK,EAAE;6DAAgE;AAEhD;IAAvB,KAAK,CAAC,OAAO,CAAC;mDAAmC;AA1PvC,mBAAmB;IAD/B,aAAa,CAAC,sBAAsB,CAAC;GACzB,mBAAmB,CA6kB/B;;AAED,oGAAoG;AACpG,SAAS,aAAa,CAAC,QAAgC;IACrD,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,CAAC,CAAC,UAAU,EAAE,YAAY,CAAC;QAC3C,IAAI,CAAC,OAAO;YAAE,SAAS;QACvB,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC1C,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n formFieldControl,\n type FormFieldControlConfig,\n} from \"./utils/form-field-control.js\";\nimport { submitWithDefaultButton } from \"./utils/form.js\";\n\nlet instanceCount = 0;\n\n/** A picked address suggestion. */\nexport interface AddressSuggestion {\n address: string;\n lat: number;\n lng: number;\n}\n\ninterface MapboxGeocodeFeature {\n properties?: { full_address?: string };\n geometry: { coordinates: [number, number] };\n}\n\n/**\n * Form-associated text input with a suggestion dropdown. Works as a\n * drop-in replacement for a plain `<input name=\"address\">`: consumers keep\n * reading `new FormData(form).get(\"address\")` and calling `form.reset()`\n * unchanged.\n *\n * Supports two suggestion sources:\n * - **API** (default): fetches from `endpoint`, a Mapbox Geocoding v6-shaped\n * forward-geocode URL, debounced as the user types.\n * - **Local array**: set `suggestions` to a fixed `AddressSuggestion[]` and\n * the component filters it client-side instead of making any network\n * request. Useful for small/fixed address lists, offline use, or tests.\n * Takes priority over `endpoint` whenever it's non-null.\n *\n * Set `clearable` to show an in-field clear action whenever a value is\n * present.\n *\n * @element address-autocomplete\n * @fires address-select - A suggestion was picked; detail: AddressSuggestion.\n * @fires input - Native-compatible input event fired while editing or clearing.\n */\n@customElement(\"address-autocomplete\")\nexport class AddressAutocomplete extends LitElement {\n static formAssociated = true;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n position: relative;\n }\n .field-shell {\n position: relative;\n }\n input {\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface, #ffffff);\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n width: 100%;\n height: 2rem;\n box-sizing: border-box;\n }\n .field-shell.clearable input {\n padding-right: 2rem;\n }\n .clear-button {\n position: absolute;\n top: 0;\n right: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 2rem;\n height: 2rem;\n /* Insets the hover/focus background by the input's 1px border so it\n stays fully inside the field instead of painting over the border. */\n padding: 1px;\n background-clip: content-box;\n border: 0;\n border-radius: var(--ui-radius-sm, 0.25rem);\n color: var(--ui-text-muted, #64748b);\n background-color: transparent;\n cursor: pointer;\n line-height: 0;\n }\n .clear-button:hover {\n color: var(--ui-text, #0f172a);\n background-color: var(--ui-surface-muted, #f8fafc);\n }\n .clear-button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .floating-label {\n position: absolute;\n top: 50%;\n left: 0.75rem;\n right: 0.75rem;\n z-index: 1;\n display: flex;\n align-items: baseline;\n gap: 0.25rem;\n overflow: hidden;\n transform: translateY(-50%);\n color: var(--ui-text-muted, #64748b);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n text-overflow: ellipsis;\n cursor: text;\n transition:\n top 150ms ease,\n transform 150ms ease,\n font-size 150ms ease;\n }\n .field-shell.clearable .floating-label {\n right: 2rem;\n }\n .field-shell.floating input {\n height: 3rem;\n padding-top: 1.25rem;\n padding-bottom: 0.25rem;\n }\n .field-shell.floating .clear-button {\n top: 0.5rem;\n }\n .field-shell.floating.has-value .floating-label,\n .field-shell.floating:focus-within .floating-label {\n top: 0.25rem;\n transform: none;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .field-shell.floating:not(.has-value):not(:focus-within) input::placeholder {\n opacity: 0;\n }\n .field-shell.disabled .floating-label {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .required-mark {\n flex: 0 0 auto;\n color: var(--ui-danger, #dc2626);\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n input:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n input:focus-visible {\n outline: none;\n border-color: var(--ui-primary, #4f46e5);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .suggestions {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 10;\n max-height: 40vh;\n overflow-y: auto;\n margin: 0.25rem 0 0;\n padding: 0.25rem 0;\n list-style: none;\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n .suggestion {\n padding: 0.5rem 0.75rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n cursor: pointer;\n }\n .suggestion.active,\n .suggestion:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .no-suggestions {\n padding: 0.5rem 0.75rem;\n color: var(--ui-text-muted, #64748b);\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-style: italic;\n }\n @media (forced-colors: active) {\n input:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n input:disabled {\n color: GrayText;\n opacity: 1;\n }\n .clear-button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: -2px;\n box-shadow: none;\n }\n .field-shell.disabled .floating-label {\n color: GrayText;\n opacity: 1;\n }\n .suggestion.active,\n .suggestion:hover {\n color: HighlightText;\n background: Highlight;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .floating-label {\n transition: none;\n }\n }\n `,\n ];\n\n /** Current input value; also the form-associated value submitted with the form. */\n @property() value = \"\";\n /** Placeholder text shown when the input is empty. */\n @property() placeholder = \"\";\n /** Marks the input as required for native form validation. */\n @property({ type: Boolean }) required = false;\n /** Disables the input and closes its suggestion popup. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n /** Shows an in-field clear action while the control has a value. */\n @property({ type: Boolean, reflect: true }) clearable = false;\n /** Mapbox `types` param, e.g. \"address\" or \"address,poi\". */\n @property() types = \"address\";\n /** Geocoding endpoint URL. Defaults to the Mapbox Geocoding v6 forward URL. */\n @property() endpoint: string = \"https://api.mapbox.com/search/geocode/v6/forward\";\n /** Mapbox access token. Required for requests to succeed. */\n @property({ attribute: \"access-token\" }) accessToken = \"\";\n /** Optional bounding box bias, comma-separated `west,south,east,north`. */\n @property() bbox = \"\";\n /** Optional proximity bias, comma-separated `lng,lat`. */\n @property() proximity = \"\";\n /** Debounce delay (ms) before firing a geocode request after typing. */\n @property({ type: Number }) debounce = 300;\n /** Minimum query length before suggestions are fetched. */\n @property({ type: Number, attribute: \"min-length\" }) minLength = 3;\n /**\n * Fixed candidate list to filter locally instead of fetching from\n * `endpoint`. When set (non-null), no network request is ever made —\n * this takes priority over the API mode.\n */\n @property({ attribute: false }) suggestions: AddressSuggestion[] | null = null;\n\n @state() private _suggestions: AddressSuggestion[] = [];\n @state() private _open = false;\n @state() private _activeIndex = -1;\n @state() private _formDisabled = false;\n @state() private _formFieldConfig: FormFieldControlConfig | null = null;\n\n @query(\"input\") private _input?: HTMLInputElement;\n\n #internals = this.attachInternals();\n #lastPicked: AddressSuggestion | null = null;\n #debounceTimer: ReturnType<typeof setTimeout> | null = null;\n #abortController: AbortController | null = null;\n #isComposing = false;\n #compositionJustEnded = false;\n #compositionEndTimer: ReturnType<typeof setTimeout> | null = null;\n readonly #inputId = `address-autocomplete-field-${++instanceCount}`;\n readonly #listboxId = `address-autocomplete-listbox-${instanceCount}`;\n\n /** Whether the host or an ancestor fieldset currently disables the control. */\n get #isDisabled(): boolean {\n return this.disabled || this._formDisabled;\n }\n\n /** Last-picked suggestion, or null once the input diverges from it. */\n get selectedSuggestion(): AddressSuggestion | null {\n if (this.#lastPicked && this.#lastPicked.address === this.value) return this.#lastPicked;\n return null;\n }\n\n /**\n * Applies or clears label configuration supplied by a wrapping `form-field`.\n * @private\n */\n [formFieldControl](config: FormFieldControlConfig | null): void {\n this._formFieldConfig = config;\n }\n\n protected override willUpdate(changed: PropertyValues) {\n if (changed.has(\"disabled\") && this.#isDisabled) {\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n this._open = false;\n this._activeIndex = -1;\n }\n }\n\n protected override updated(changed: PropertyValues) {\n if (changed.has(\"value\")) this.#internals.setFormValue(this.value);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n }\n\n /** Resets to empty on `form.reset()`, per the form-associated custom element contract. */\n formResetCallback() {\n this.value = \"\";\n this._suggestions = [];\n this._open = false;\n this.#lastPicked = null;\n }\n\n /** Mirrors ancestor fieldset disabled state onto the native input. */\n formDisabledCallback(disabled: boolean) {\n this._formDisabled = disabled;\n if (!disabled) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n this._open = false;\n this._activeIndex = -1;\n }\n\n private onInput(e: InputEvent) {\n if (this.#isDisabled) return;\n this.value = (e.target as HTMLInputElement).value;\n this.#lastPicked = null;\n this.#scheduleFetch(this.value);\n }\n\n #scheduleFetch(query: string) {\n if (this.#isDisabled) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n if (query.trim().length < this.minLength) {\n this._suggestions = [];\n this._open = false;\n this._activeIndex = -1;\n return;\n }\n if (this.suggestions) {\n // Local mode: filtering is synchronous and cheap, but keep the same\n // debounce as the API mode so the UX doesn't shift between sources.\n this.#debounceTimer = setTimeout(() => this.#filterLocalSuggestions(query), this.debounce);\n return;\n }\n this.#debounceTimer = setTimeout(() => void this.#fetchSuggestions(query), this.debounce);\n }\n\n /** Filters the locally-supplied `suggestions` list for `query`, case-insensitively. */\n #filterLocalSuggestions(query: string) {\n const needle = query.trim().toLowerCase();\n this._suggestions = (this.suggestions ?? [])\n .filter((s) => s.address.toLowerCase().includes(needle))\n .slice(0, 5);\n this._activeIndex = -1;\n this._open = !this.#isDisabled;\n }\n\n /** Fetches suggestions for `query`, cancelling any request still in flight. */\n async #fetchSuggestions(query: string) {\n this.#abortController?.abort();\n const controller = new AbortController();\n this.#abortController = controller;\n try {\n const res = await fetch(this.#buildUrl(query), { signal: controller.signal });\n if (!res.ok) throw new Error(`geocode request failed: ${res.status}`);\n const body = (await res.json()) as { features?: MapboxGeocodeFeature[] };\n if (this.#isDisabled) return;\n this._suggestions = parseFeatures(body.features ?? []);\n this._activeIndex = -1;\n this._open = true;\n } catch {\n // Aborted (superseded by newer keystroke) or a network failure while\n // typing — fail silently and just close the list.\n if (!controller.signal.aborted) {\n this._suggestions = [];\n this._open = false;\n }\n }\n }\n\n #buildUrl(query: string): string {\n const params = new URLSearchParams({\n q: query,\n access_token: this.accessToken,\n autocomplete: \"true\",\n limit: \"5\",\n types: this.types,\n });\n if (this.bbox) params.set(\"bbox\", this.bbox);\n if (this.proximity) params.set(\"proximity\", this.proximity);\n return `${this.endpoint}?${params.toString()}`;\n }\n\n private onKeydown(e: KeyboardEvent) {\n if (this.#isDisabled) return;\n if (e.isComposing || e.keyCode === 229 || this.#isComposing || this.#compositionJustEnded) {\n return;\n }\n if (e.key === \"ArrowDown\") this.#moveActive(1, e);\n else if (e.key === \"ArrowUp\") this.#moveActive(-1, e);\n else if (e.key === \"Enter\") this.#handleEnter(e);\n else if (e.key === \"Escape\") this.#handleEscape(e);\n }\n\n #moveActive(delta: number, e: KeyboardEvent) {\n if (!this._open || this._suggestions.length === 0) return;\n e.preventDefault();\n const n = this._suggestions.length;\n this._activeIndex = (this._activeIndex + delta + n) % n;\n }\n\n #handleEnter(e: KeyboardEvent) {\n const pick = this._suggestions[this._activeIndex] ?? this._suggestions[0];\n if (this._open && pick) {\n e.preventDefault();\n this.#selectSuggestion(pick);\n return;\n }\n if (this.#internals.form) {\n const form = this.#internals.form;\n window.setTimeout(() => {\n if (!e.defaultPrevented && form.isConnected) submitWithDefaultButton(form);\n });\n }\n }\n\n #handleEscape(e: KeyboardEvent) {\n if (!this._open) return;\n e.preventDefault();\n this._open = false;\n }\n\n private onBlur() {\n this._open = false;\n }\n\n private onCompositionStart(): void {\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = null;\n this.#compositionJustEnded = false;\n this.#isComposing = true;\n }\n\n private onCompositionEnd(): void {\n this.#isComposing = false;\n this.#compositionJustEnded = true;\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = setTimeout(() => {\n this.#compositionJustEnded = false;\n this.#compositionEndTimer = null;\n });\n }\n\n /** Clears composition state when the control can no longer receive keys. */\n #resetComposition(): void {\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = null;\n this.#isComposing = false;\n this.#compositionJustEnded = false;\n }\n\n #selectSuggestion(s: AddressSuggestion) {\n this.value = s.address;\n this.#lastPicked = s;\n this._open = false;\n this._suggestions = [];\n this.dispatchEvent(new CustomEvent<AddressSuggestion>(\"address-select\", { detail: s, bubbles: true, composed: true }));\n }\n\n /** Clears the field and all pending autocomplete state, then restores input focus. */\n #clear(): void {\n if (this.#isDisabled || !this.value) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#debounceTimer = null;\n this.#abortController?.abort();\n this.#abortController = null;\n this.#resetComposition();\n this.value = \"\";\n this.#lastPicked = null;\n this._suggestions = [];\n this._activeIndex = -1;\n this._open = false;\n this.#internals.setFormValue(\"\");\n this.dispatchEvent(\n new InputEvent(\"input\", {\n bubbles: true,\n composed: true,\n inputType: \"deleteContentBackward\",\n }),\n );\n this._input?.focus({ preventScroll: true });\n }\n\n /** Selects on mousedown (not click) so it wins over the input's blur, which closes the list. */\n #onSuggestionMousedown(e: MouseEvent, s: AddressSuggestion) {\n e.preventDefault();\n this.#selectSuggestion(s);\n }\n\n private renderSuggestions() {\n if (!this._open || this.#isDisabled) return nothing;\n return html`\n <ul id=${this.#listboxId} class=\"suggestions\" role=\"listbox\" aria-label=\"Address suggestions\">\n ${this._suggestions.map(\n (s, i) => html`\n <li\n id=${`${this.#listboxId}-option-${i}`}\n role=\"option\"\n aria-selected=${i === this._activeIndex}\n class=\"suggestion ${i === this._activeIndex ? \"active\" : \"\"}\"\n @mousedown=${(e: MouseEvent) => this.#onSuggestionMousedown(e, s)}\n >\n ${s.address}\n </li>\n `,\n )}\n ${this._suggestions.length === 0\n ? html`<li class=\"no-suggestions\" role=\"presentation\">\n <span role=\"status\">No suggestions found</span>\n </li>`\n : nothing}\n </ul>\n `;\n }\n\n override render() {\n const activeDescendant =\n this._open && !this.#isDisabled && this._activeIndex >= 0\n ? `${this.#listboxId}-option-${this._activeIndex}`\n : nothing;\n const expanded = this._open && !this.#isDisabled;\n const floating =\n Boolean(this._formFieldConfig?.floating) && Boolean(this._formFieldConfig?.label);\n const showClear = this.clearable && Boolean(this.value) && !this.#isDisabled;\n return html`\n <div\n class=\"field-shell ${this.clearable ? \"clearable\" : \"\"} ${floating\n ? \"floating\"\n : \"\"} ${this.value ? \"has-value\" : \"\"} ${this.#isDisabled ? \"disabled\" : \"\"}\"\n >\n ${floating\n ? html`\n <label class=\"floating-label\" for=${this.#inputId}>\n <span>${this._formFieldConfig!.label}</span>\n ${this._formFieldConfig!.required\n ? html`\n <span class=\"required-mark\" aria-hidden=\"true\">*</span>\n <span class=\"sr-only\"> (required)</span>\n `\n : nothing}\n </label>\n `\n : nothing}\n <input\n id=${this.#inputId}\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded=${expanded}\n aria-controls=${this.#listboxId}\n aria-activedescendant=${activeDescendant}\n .value=${this.value}\n placeholder=${this.placeholder}\n ?required=${this.required}\n ?disabled=${this.#isDisabled}\n autocomplete=\"off\"\n @input=${this.onInput}\n @compositionstart=${this.onCompositionStart}\n @compositionend=${this.onCompositionEnd}\n @keydown=${this.onKeydown}\n @blur=${this.onBlur}\n />\n ${showClear\n ? html`\n <button\n type=\"button\"\n class=\"clear-button\"\n aria-label=\"Clear address\"\n title=\"Clear address\"\n @mousedown=${(event: MouseEvent) => event.preventDefault()}\n @click=${() => this.#clear()}\n >\n ${iconX(18)}\n </button>\n `\n : nothing}\n ${this.renderSuggestions()}\n </div>\n `;\n }\n}\n\n/** Maps Mapbox v6 forward-geocode features to suggestions, skipping ones without a full_address. */\nfunction parseFeatures(features: MapboxGeocodeFeature[]): AddressSuggestion[] {\n const suggestions: AddressSuggestion[] = [];\n for (const f of features) {\n const address = f.properties?.full_address;\n if (!address) continue;\n const [lng, lat] = f.geometry.coordinates;\n suggestions.push({ address, lng, lat });\n }\n return suggestions;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"address-autocomplete\": AddressAutocomplete;\n }\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import "./icon-button.js";
|
|
3
|
+
/**
|
|
4
|
+
* Compact audio player wrapping a native `<audio>` element (kept off-screen
|
|
5
|
+
* for its decoding/playback engine and free `timeupdate`/`loadedmetadata`
|
|
6
|
+
* events) behind a tokenized transport bar: a play/pause `icon-button`,
|
|
7
|
+
* elapsed/total time, a seekable progress bar, and a mute toggle + volume
|
|
8
|
+
* slider. The seek/volume sliders are native `<input type="range">`
|
|
9
|
+
* elements (see `utils/transport-controls.ts`) for free keyboard and
|
|
10
|
+
* pointer support, per this package's "native semantics before custom ARIA"
|
|
11
|
+
* rule.
|
|
12
|
+
*
|
|
13
|
+
* @element audio-player
|
|
14
|
+
* @fires play - The audio started playing.
|
|
15
|
+
* @fires pause - The audio was paused.
|
|
16
|
+
* @fires ended - Playback reached the end.
|
|
17
|
+
*/
|
|
18
|
+
export declare class AudioPlayer extends LitElement {
|
|
19
|
+
static styles: import("lit").CSSResult[];
|
|
20
|
+
/** URL of the audio file to play. */
|
|
21
|
+
src: string;
|
|
22
|
+
/** Accessible name for the player, e.g. a track/episode title. */
|
|
23
|
+
label: string;
|
|
24
|
+
/** Loops playback once it reaches the end. */
|
|
25
|
+
loop: boolean;
|
|
26
|
+
/** Native `<audio preload>` hint. */
|
|
27
|
+
preload: "none" | "metadata" | "auto";
|
|
28
|
+
private _playing;
|
|
29
|
+
private _currentTime;
|
|
30
|
+
private _duration;
|
|
31
|
+
private _volume;
|
|
32
|
+
private _muted;
|
|
33
|
+
private _errored;
|
|
34
|
+
private _audio?;
|
|
35
|
+
private _togglePlay;
|
|
36
|
+
private _toggleMute;
|
|
37
|
+
private _onSeekInput;
|
|
38
|
+
private _onVolumeInput;
|
|
39
|
+
private _onLoadedMetadata;
|
|
40
|
+
private _onTimeUpdate;
|
|
41
|
+
private _onPlay;
|
|
42
|
+
private _onPause;
|
|
43
|
+
private _onEnded;
|
|
44
|
+
private _onVolumeChange;
|
|
45
|
+
private _onError;
|
|
46
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
47
|
+
}
|
|
48
|
+
declare global {
|
|
49
|
+
interface HTMLElementTagNameMap {
|
|
50
|
+
"audio-player": AudioPlayer;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=audio-player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-player.d.ts","sourceRoot":"","sources":["../src/audio-player.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAM5C,OAAO,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,qBACa,WAAY,SAAQ,UAAU;IACzC,OAAgB,MAAM,4BA6DpB;IAEF,qCAAqC;IACzB,GAAG,SAAM;IACrB,kEAAkE;IACtD,KAAK,SAAkB;IACnC,8CAA8C;IACjB,IAAI,UAAS;IAC1C,qCAAqC;IACzB,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAc;IAEtD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,SAAS,CAAO;IACxB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;IAElB,OAAO,CAAC,MAAM,CAAC,CAAmB;IAElD,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,iBAAiB;IAKzB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,QAAQ;IAIP,MAAM,yCAwDd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,WAAW,CAAC;KAC7B;CACF"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html } from "lit";
|
|
8
|
+
import { customElement, property, query, state } from "lit/decorators.js";
|
|
9
|
+
import { tokens } from "./tokens.js";
|
|
10
|
+
import { transportRangeStyles } from "./utils/transport-controls.js";
|
|
11
|
+
import { formatClockDuration } from "./utils/duration.js";
|
|
12
|
+
import { iconPause, iconPlay, iconSpeakerWave, iconSpeakerXMark } from "./icons.js";
|
|
13
|
+
import "./icon-button.js";
|
|
14
|
+
/**
|
|
15
|
+
* Compact audio player wrapping a native `<audio>` element (kept off-screen
|
|
16
|
+
* for its decoding/playback engine and free `timeupdate`/`loadedmetadata`
|
|
17
|
+
* events) behind a tokenized transport bar: a play/pause `icon-button`,
|
|
18
|
+
* elapsed/total time, a seekable progress bar, and a mute toggle + volume
|
|
19
|
+
* slider. The seek/volume sliders are native `<input type="range">`
|
|
20
|
+
* elements (see `utils/transport-controls.ts`) for free keyboard and
|
|
21
|
+
* pointer support, per this package's "native semantics before custom ARIA"
|
|
22
|
+
* rule.
|
|
23
|
+
*
|
|
24
|
+
* @element audio-player
|
|
25
|
+
* @fires play - The audio started playing.
|
|
26
|
+
* @fires pause - The audio was paused.
|
|
27
|
+
* @fires ended - Playback reached the end.
|
|
28
|
+
*/
|
|
29
|
+
let AudioPlayer = class AudioPlayer extends LitElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
/** URL of the audio file to play. */
|
|
33
|
+
this.src = "";
|
|
34
|
+
/** Accessible name for the player, e.g. a track/episode title. */
|
|
35
|
+
this.label = "Audio player";
|
|
36
|
+
/** Loops playback once it reaches the end. */
|
|
37
|
+
this.loop = false;
|
|
38
|
+
/** Native `<audio preload>` hint. */
|
|
39
|
+
this.preload = "metadata";
|
|
40
|
+
this._playing = false;
|
|
41
|
+
this._currentTime = 0;
|
|
42
|
+
this._duration = NaN;
|
|
43
|
+
this._volume = 1;
|
|
44
|
+
this._muted = false;
|
|
45
|
+
this._errored = false;
|
|
46
|
+
}
|
|
47
|
+
static { this.styles = [
|
|
48
|
+
tokens,
|
|
49
|
+
transportRangeStyles,
|
|
50
|
+
css `
|
|
51
|
+
:host {
|
|
52
|
+
display: block;
|
|
53
|
+
}
|
|
54
|
+
.player {
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 0.5rem;
|
|
58
|
+
padding: 0.5rem 0.75rem;
|
|
59
|
+
border: 1px solid var(--ui-border, #e2e8f0);
|
|
60
|
+
border-radius: var(--ui-radius, 0.5rem);
|
|
61
|
+
background: var(--ui-surface, #ffffff);
|
|
62
|
+
font-family: var(
|
|
63
|
+
--ui-font,
|
|
64
|
+
ui-sans-serif,
|
|
65
|
+
system-ui,
|
|
66
|
+
sans-serif,
|
|
67
|
+
"Apple Color Emoji",
|
|
68
|
+
"Segoe UI Emoji",
|
|
69
|
+
"Segoe UI Symbol",
|
|
70
|
+
"Noto Color Emoji"
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
.time {
|
|
74
|
+
flex: 0 0 auto;
|
|
75
|
+
min-width: 2.5rem;
|
|
76
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
77
|
+
color: var(--ui-text-muted, #64748b);
|
|
78
|
+
font-variant-numeric: tabular-nums;
|
|
79
|
+
text-align: center;
|
|
80
|
+
}
|
|
81
|
+
.seek {
|
|
82
|
+
/* Sets its own width (100%) and flex-basis: 0 (not auto) so it
|
|
83
|
+
fills the row's remaining space via flex-grow — an auto basis
|
|
84
|
+
would otherwise derive its hypothetical size from that same
|
|
85
|
+
width:100%, resolved against an indefinite container, and
|
|
86
|
+
collapse the track to 0. */
|
|
87
|
+
flex: 1 1 0%;
|
|
88
|
+
min-width: 0;
|
|
89
|
+
width: 100%;
|
|
90
|
+
}
|
|
91
|
+
.volume {
|
|
92
|
+
flex: 0 0 auto;
|
|
93
|
+
width: 4rem;
|
|
94
|
+
}
|
|
95
|
+
.error {
|
|
96
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
97
|
+
color: var(--ui-danger, #dc2626);
|
|
98
|
+
}
|
|
99
|
+
audio {
|
|
100
|
+
display: none;
|
|
101
|
+
}
|
|
102
|
+
@media (forced-colors: active) {
|
|
103
|
+
.player {
|
|
104
|
+
border-color: CanvasText;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`,
|
|
108
|
+
]; }
|
|
109
|
+
_togglePlay() {
|
|
110
|
+
const audio = this._audio;
|
|
111
|
+
if (!audio)
|
|
112
|
+
return;
|
|
113
|
+
if (audio.paused)
|
|
114
|
+
audio.play();
|
|
115
|
+
else
|
|
116
|
+
audio.pause();
|
|
117
|
+
}
|
|
118
|
+
_toggleMute() {
|
|
119
|
+
const audio = this._audio;
|
|
120
|
+
if (!audio)
|
|
121
|
+
return;
|
|
122
|
+
audio.muted = !audio.muted;
|
|
123
|
+
}
|
|
124
|
+
_onSeekInput(e) {
|
|
125
|
+
const audio = this._audio;
|
|
126
|
+
if (!audio)
|
|
127
|
+
return;
|
|
128
|
+
const value = Number(e.target.value);
|
|
129
|
+
audio.currentTime = value;
|
|
130
|
+
this._currentTime = value;
|
|
131
|
+
}
|
|
132
|
+
_onVolumeInput(e) {
|
|
133
|
+
const audio = this._audio;
|
|
134
|
+
if (!audio)
|
|
135
|
+
return;
|
|
136
|
+
const value = Number(e.target.value);
|
|
137
|
+
audio.volume = value;
|
|
138
|
+
// Adjusting the slider while muted is treated as an implicit unmute, so
|
|
139
|
+
// dragging it back up audibly takes effect instead of appearing frozen.
|
|
140
|
+
if (audio.muted && value > 0)
|
|
141
|
+
audio.muted = false;
|
|
142
|
+
}
|
|
143
|
+
_onLoadedMetadata() {
|
|
144
|
+
this._duration = this._audio?.duration ?? NaN;
|
|
145
|
+
this._errored = false;
|
|
146
|
+
}
|
|
147
|
+
_onTimeUpdate() {
|
|
148
|
+
this._currentTime = this._audio?.currentTime ?? 0;
|
|
149
|
+
}
|
|
150
|
+
_onPlay() {
|
|
151
|
+
this._playing = true;
|
|
152
|
+
this.dispatchEvent(new CustomEvent("play", { bubbles: true, composed: true }));
|
|
153
|
+
}
|
|
154
|
+
_onPause() {
|
|
155
|
+
this._playing = false;
|
|
156
|
+
this.dispatchEvent(new CustomEvent("pause", { bubbles: true, composed: true }));
|
|
157
|
+
}
|
|
158
|
+
_onEnded() {
|
|
159
|
+
this._playing = false;
|
|
160
|
+
this.dispatchEvent(new CustomEvent("ended", { bubbles: true, composed: true }));
|
|
161
|
+
}
|
|
162
|
+
_onVolumeChange() {
|
|
163
|
+
const audio = this._audio;
|
|
164
|
+
if (!audio)
|
|
165
|
+
return;
|
|
166
|
+
this._volume = audio.volume;
|
|
167
|
+
this._muted = audio.muted;
|
|
168
|
+
}
|
|
169
|
+
_onError() {
|
|
170
|
+
this._errored = true;
|
|
171
|
+
}
|
|
172
|
+
render() {
|
|
173
|
+
const duration = this._duration;
|
|
174
|
+
const seekMax = Number.isFinite(duration) && duration > 0 ? duration : 0;
|
|
175
|
+
return html `
|
|
176
|
+
<div class="player" role="group" aria-label=${this.label}>
|
|
177
|
+
<audio
|
|
178
|
+
.src=${this.src}
|
|
179
|
+
?loop=${this.loop}
|
|
180
|
+
preload=${this.preload}
|
|
181
|
+
@loadedmetadata=${this._onLoadedMetadata}
|
|
182
|
+
@timeupdate=${this._onTimeUpdate}
|
|
183
|
+
@play=${this._onPlay}
|
|
184
|
+
@pause=${this._onPause}
|
|
185
|
+
@ended=${this._onEnded}
|
|
186
|
+
@volumechange=${this._onVolumeChange}
|
|
187
|
+
@error=${this._onError}
|
|
188
|
+
></audio>
|
|
189
|
+
${this._errored
|
|
190
|
+
? html `<span class="error">Unable to load audio</span>`
|
|
191
|
+
: html `
|
|
192
|
+
<icon-button
|
|
193
|
+
.icon=${this._playing ? iconPause(18) : iconPlay(18)}
|
|
194
|
+
label=${this._playing ? "Pause" : "Play"}
|
|
195
|
+
@click=${this._togglePlay}
|
|
196
|
+
></icon-button>
|
|
197
|
+
<span class="time">${formatClockDuration(this._currentTime)}</span>
|
|
198
|
+
<input
|
|
199
|
+
class="seek"
|
|
200
|
+
type="range"
|
|
201
|
+
min="0"
|
|
202
|
+
max=${seekMax}
|
|
203
|
+
step="0.1"
|
|
204
|
+
.value=${String(this._currentTime)}
|
|
205
|
+
aria-label="Seek"
|
|
206
|
+
aria-valuetext=${formatClockDuration(this._currentTime)}
|
|
207
|
+
@input=${this._onSeekInput}
|
|
208
|
+
/>
|
|
209
|
+
<span class="time">${formatClockDuration(duration)}</span>
|
|
210
|
+
<icon-button
|
|
211
|
+
.icon=${this._muted || this._volume === 0 ? iconSpeakerXMark(18) : iconSpeakerWave(18)}
|
|
212
|
+
label=${this._muted ? "Unmute" : "Mute"}
|
|
213
|
+
@click=${this._toggleMute}
|
|
214
|
+
></icon-button>
|
|
215
|
+
<input
|
|
216
|
+
class="volume"
|
|
217
|
+
type="range"
|
|
218
|
+
min="0"
|
|
219
|
+
max="1"
|
|
220
|
+
step="0.05"
|
|
221
|
+
.value=${String(this._muted ? 0 : this._volume)}
|
|
222
|
+
aria-label="Volume"
|
|
223
|
+
@input=${this._onVolumeInput}
|
|
224
|
+
/>
|
|
225
|
+
`}
|
|
226
|
+
</div>
|
|
227
|
+
`;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
__decorate([
|
|
231
|
+
property()
|
|
232
|
+
], AudioPlayer.prototype, "src", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
property()
|
|
235
|
+
], AudioPlayer.prototype, "label", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
property({ type: Boolean })
|
|
238
|
+
], AudioPlayer.prototype, "loop", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
property()
|
|
241
|
+
], AudioPlayer.prototype, "preload", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
state()
|
|
244
|
+
], AudioPlayer.prototype, "_playing", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
state()
|
|
247
|
+
], AudioPlayer.prototype, "_currentTime", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
state()
|
|
250
|
+
], AudioPlayer.prototype, "_duration", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
state()
|
|
253
|
+
], AudioPlayer.prototype, "_volume", void 0);
|
|
254
|
+
__decorate([
|
|
255
|
+
state()
|
|
256
|
+
], AudioPlayer.prototype, "_muted", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
state()
|
|
259
|
+
], AudioPlayer.prototype, "_errored", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
query("audio")
|
|
262
|
+
], AudioPlayer.prototype, "_audio", void 0);
|
|
263
|
+
AudioPlayer = __decorate([
|
|
264
|
+
customElement("audio-player")
|
|
265
|
+
], AudioPlayer);
|
|
266
|
+
export { AudioPlayer };
|
|
267
|
+
//# sourceMappingURL=audio-player.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audio-player.js","sourceRoot":"","sources":["../src/audio-player.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAgEL,qCAAqC;QACzB,QAAG,GAAG,EAAE,CAAC;QACrB,kEAAkE;QACtD,UAAK,GAAG,cAAc,CAAC;QACnC,8CAA8C;QACjB,SAAI,GAAG,KAAK,CAAC;QAC1C,qCAAqC;QACzB,YAAO,GAAiC,UAAU,CAAC;QAE9C,aAAQ,GAAG,KAAK,CAAC;QACjB,iBAAY,GAAG,CAAC,CAAC;QACjB,cAAS,GAAG,GAAG,CAAC;QAChB,YAAO,GAAG,CAAC,CAAC;QACZ,WAAM,GAAG,KAAK,CAAC;QACf,aAAQ,GAAG,KAAK,CAAC;IA+HpC,CAAC;aA5MiB,WAAM,GAAG;QACvB,MAAM;QACN,oBAAoB;QACpB,GAAG,CAA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AC;;yBAEtC,IAAI,CAAC,cAAc;;aAE/B;;KAER,CAAC;IACJ,CAAC;CACF,CAAA;AA5Ia;IAAX,QAAQ,EAAE;wCAAU;AAET;IAAX,QAAQ,EAAE;0CAAwB;AAEN;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;yCAAc;AAE9B;IAAX,QAAQ,EAAE;4CAAoD;AAE9C;IAAhB,KAAK,EAAE;6CAA0B;AACjB;IAAhB,KAAK,EAAE;iDAA0B;AACjB;IAAhB,KAAK,EAAE;8CAAyB;AAChB;IAAhB,KAAK,EAAE;4CAAqB;AACZ;IAAhB,KAAK,EAAE;2CAAwB;AACf;IAAhB,KAAK,EAAE;6CAA0B;AAEV;IAAvB,KAAK,CAAC,OAAO,CAAC;2CAAmC;AAhFvC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA6MvB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport { transportRangeStyles } from \"./utils/transport-controls.js\";\nimport { formatClockDuration } from \"./utils/duration.js\";\nimport { iconPause, iconPlay, iconSpeakerWave, iconSpeakerXMark } from \"./icons.js\";\nimport \"./icon-button.js\";\n\n/**\n * Compact audio player wrapping a native `<audio>` element (kept off-screen\n * for its decoding/playback engine and free `timeupdate`/`loadedmetadata`\n * events) behind a tokenized transport bar: a play/pause `icon-button`,\n * elapsed/total time, a seekable progress bar, and a mute toggle + volume\n * slider. The seek/volume sliders are native `<input type=\"range\">`\n * elements (see `utils/transport-controls.ts`) for free keyboard and\n * pointer support, per this package's \"native semantics before custom ARIA\"\n * rule.\n *\n * @element audio-player\n * @fires play - The audio started playing.\n * @fires pause - The audio was paused.\n * @fires ended - Playback reached the end.\n */\n@customElement(\"audio-player\")\nexport class AudioPlayer extends LitElement {\n static override styles = [\n tokens,\n transportRangeStyles,\n css`\n :host {\n display: block;\n }\n .player {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius, 0.5rem);\n background: var(--ui-surface, #ffffff);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n }\n .time {\n flex: 0 0 auto;\n min-width: 2.5rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n color: var(--ui-text-muted, #64748b);\n font-variant-numeric: tabular-nums;\n text-align: center;\n }\n .seek {\n /* Sets its own width (100%) and flex-basis: 0 (not auto) so it\n fills the row's remaining space via flex-grow — an auto basis\n would otherwise derive its hypothetical size from that same\n width:100%, resolved against an indefinite container, and\n collapse the track to 0. */\n flex: 1 1 0%;\n min-width: 0;\n width: 100%;\n }\n .volume {\n flex: 0 0 auto;\n width: 4rem;\n }\n .error {\n font-size: var(--ui-font-size-sm, 0.75rem);\n color: var(--ui-danger, #dc2626);\n }\n audio {\n display: none;\n }\n @media (forced-colors: active) {\n .player {\n border-color: CanvasText;\n }\n }\n `,\n ];\n\n /** URL of the audio file to play. */\n @property() src = \"\";\n /** Accessible name for the player, e.g. a track/episode title. */\n @property() label = \"Audio player\";\n /** Loops playback once it reaches the end. */\n @property({ type: Boolean }) loop = false;\n /** Native `<audio preload>` hint. */\n @property() preload: \"none\" | \"metadata\" | \"auto\" = \"metadata\";\n\n @state() private _playing = false;\n @state() private _currentTime = 0;\n @state() private _duration = NaN;\n @state() private _volume = 1;\n @state() private _muted = false;\n @state() private _errored = false;\n\n @query(\"audio\") private _audio?: HTMLAudioElement;\n\n private _togglePlay(): void {\n const audio = this._audio;\n if (!audio) return;\n if (audio.paused) audio.play();\n else audio.pause();\n }\n\n private _toggleMute(): void {\n const audio = this._audio;\n if (!audio) return;\n audio.muted = !audio.muted;\n }\n\n private _onSeekInput(e: Event): void {\n const audio = this._audio;\n if (!audio) return;\n const value = Number((e.target as HTMLInputElement).value);\n audio.currentTime = value;\n this._currentTime = value;\n }\n\n private _onVolumeInput(e: Event): void {\n const audio = this._audio;\n if (!audio) return;\n const value = Number((e.target as HTMLInputElement).value);\n audio.volume = value;\n // Adjusting the slider while muted is treated as an implicit unmute, so\n // dragging it back up audibly takes effect instead of appearing frozen.\n if (audio.muted && value > 0) audio.muted = false;\n }\n\n private _onLoadedMetadata(): void {\n this._duration = this._audio?.duration ?? NaN;\n this._errored = false;\n }\n\n private _onTimeUpdate(): void {\n this._currentTime = this._audio?.currentTime ?? 0;\n }\n\n private _onPlay(): void {\n this._playing = true;\n this.dispatchEvent(new CustomEvent(\"play\", { bubbles: true, composed: true }));\n }\n\n private _onPause(): void {\n this._playing = false;\n this.dispatchEvent(new CustomEvent(\"pause\", { bubbles: true, composed: true }));\n }\n\n private _onEnded(): void {\n this._playing = false;\n this.dispatchEvent(new CustomEvent(\"ended\", { bubbles: true, composed: true }));\n }\n\n private _onVolumeChange(): void {\n const audio = this._audio;\n if (!audio) return;\n this._volume = audio.volume;\n this._muted = audio.muted;\n }\n\n private _onError(): void {\n this._errored = true;\n }\n\n override render() {\n const duration = this._duration;\n const seekMax = Number.isFinite(duration) && duration > 0 ? duration : 0;\n return html`\n <div class=\"player\" role=\"group\" aria-label=${this.label}>\n <audio\n .src=${this.src}\n ?loop=${this.loop}\n preload=${this.preload}\n @loadedmetadata=${this._onLoadedMetadata}\n @timeupdate=${this._onTimeUpdate}\n @play=${this._onPlay}\n @pause=${this._onPause}\n @ended=${this._onEnded}\n @volumechange=${this._onVolumeChange}\n @error=${this._onError}\n ></audio>\n ${this._errored\n ? html`<span class=\"error\">Unable to load audio</span>`\n : html`\n <icon-button\n .icon=${this._playing ? iconPause(18) : iconPlay(18)}\n label=${this._playing ? \"Pause\" : \"Play\"}\n @click=${this._togglePlay}\n ></icon-button>\n <span class=\"time\">${formatClockDuration(this._currentTime)}</span>\n <input\n class=\"seek\"\n type=\"range\"\n min=\"0\"\n max=${seekMax}\n step=\"0.1\"\n .value=${String(this._currentTime)}\n aria-label=\"Seek\"\n aria-valuetext=${formatClockDuration(this._currentTime)}\n @input=${this._onSeekInput}\n />\n <span class=\"time\">${formatClockDuration(duration)}</span>\n <icon-button\n .icon=${this._muted || this._volume === 0 ? iconSpeakerXMark(18) : iconSpeakerWave(18)}\n label=${this._muted ? \"Unmute\" : \"Mute\"}\n @click=${this._toggleMute}\n ></icon-button>\n <input\n class=\"volume\"\n type=\"range\"\n min=\"0\"\n max=\"1\"\n step=\"0.05\"\n .value=${String(this._muted ? 0 : this._volume)}\n aria-label=\"Volume\"\n @input=${this._onVolumeInput}\n />\n `}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"audio-player\": AudioPlayer;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-input.d.ts","sourceRoot":"","sources":["../src/autocomplete-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAI1E,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBACa,iBAAkB,SAAQ,UAAU;;IAC/C,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"autocomplete-input.d.ts","sourceRoot":"","sources":["../src/autocomplete-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAI1E,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC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C,SAAS;IAuCjB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,gBAAgB;IAwDxB,OAAO,CAAC,iBAAiB;IA0BhB,MAAM,yCAgEd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,iBAAiB,CAAC;KACzC;CACF"}
|
|
@@ -122,19 +122,23 @@ let AutocompleteInput = class AutocompleteInput extends LitElement {
|
|
|
122
122
|
display: inline-flex;
|
|
123
123
|
align-items: center;
|
|
124
124
|
justify-content: center;
|
|
125
|
+
box-sizing: border-box;
|
|
125
126
|
width: 2rem;
|
|
126
127
|
height: 2rem;
|
|
127
|
-
|
|
128
|
+
/* Insets the hover/focus background by the input's 1px border so it
|
|
129
|
+
stays fully inside the field instead of painting over the border. */
|
|
130
|
+
padding: 1px;
|
|
131
|
+
background-clip: content-box;
|
|
128
132
|
border: 0;
|
|
129
133
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
130
134
|
color: var(--ui-text-muted, #64748b);
|
|
131
|
-
background: transparent;
|
|
135
|
+
background-color: transparent;
|
|
132
136
|
cursor: pointer;
|
|
133
137
|
line-height: 0;
|
|
134
138
|
}
|
|
135
139
|
.clear-button:hover {
|
|
136
140
|
color: var(--ui-text, #0f172a);
|
|
137
|
-
background: var(--ui-surface-muted, #f8fafc);
|
|
141
|
+
background-color: var(--ui-surface-muted, #f8fafc);
|
|
138
142
|
}
|
|
139
143
|
.clear-button:focus-visible {
|
|
140
144
|
outline: none;
|