@unframed/cli 0.5.0 → 0.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/registry.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.0",
2
+ "version": "0.6.0",
3
3
  "components": {
4
4
  "accordion": {
5
5
  "name": "accordion",
@@ -543,23 +543,23 @@
543
543
  "internal/slot.ts": "import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\n/** Re-renders the host when the content of the given named slots changes. */\nexport class HasSlotController implements ReactiveController {\n readonly #host: ReactiveControllerHost & HTMLElement;\n readonly #names: string[];\n\n constructor(host: ReactiveControllerHost & HTMLElement, ...names: string[]) {\n this.#host = host;\n this.#names = names;\n host.addController(this);\n }\n\n /** True when a direct child is assigned to the named slot. */\n has(name: string): boolean {\n return [...this.#host.children].some((child) => child.getAttribute('slot') === name);\n }\n\n hostConnected(): void {\n this.#host.shadowRoot?.addEventListener('slotchange', this.#onSlotChange);\n }\n\n hostDisconnected(): void {\n this.#host.shadowRoot?.removeEventListener('slotchange', this.#onSlotChange);\n }\n\n #onSlotChange = (event: Event): void => {\n const slot = event.target as HTMLSlotElement;\n if (this.#names.includes(slot.name)) this.#host.requestUpdate();\n };\n}\n\nlet counter = 0;\n\n/** A document-unique id, for ARIA references within one tree. */\nexport function uniqueId(prefix = 'uf'): string {\n counter += 1;\n return `${prefix}-${counter}`;\n}\n",
544
544
  "components/card/card.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { defineElement } from '../../internal/define.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController } from '../../internal/slot.js';\n\nexport type CardVariant = 'outline' | 'elevated' | 'filled';\nexport type CardOrientation = 'vertical' | 'horizontal';\n\n/**\n * A container that groups related content: an optional image, a header, the\n * content and actions. Empty sections take no space.\n *\n * A card is a plain container for assistive tech. To make a whole card a link,\n * put a link in the header and let it cover the card with CSS, so the card's\n * buttons stay usable.\n *\n * @summary Groups related content and actions.\n * @tag uf-card\n *\n * @slot - The main content.\n * @slot media - An image or video, edge to edge at the top (or the start, when horizontal).\n * @slot header - The title area, e.g. a heading and a subtitle.\n * @slot footer - Actions or details at the bottom.\n *\n * @csspart base - The card.\n * @csspart media - The media wrapper.\n * @csspart header - The header wrapper.\n * @csspart body - The main content wrapper.\n * @csspart footer - The footer wrapper.\n *\n * @cssprop --uf-card-padding - Padding of header, body and footer.\n * @cssprop --uf-card-bg - Background color.\n * @cssprop --uf-card-border-color - Border color.\n * @cssprop --uf-card-radius - Corner radius.\n * @cssprop --uf-card-shadow - Shadow of an elevated card. Defaults to a soft shadow in light mode and an accent glow in dark mode.\n * @cssprop --uf-card-media-width - Width of the media in a horizontal card. Defaults to 40%.\n */\nexport class UfCard extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: block;\n --_padding: var(--uf-card-padding, var(--uf-space-5));\n }\n\n .base {\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n border: 1px solid var(--uf-card-border-color, var(--uf-color-border));\n border-radius: var(--uf-card-radius, var(--uf-radius-md));\n background: var(--uf-card-bg, var(--uf-color-surface-raised));\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n }\n\n /* A shadow in light mode, an accent glow in dark mode (--uf-shadow-raised). */\n :host([variant='elevated']) .base {\n border-color: var(--uf-card-border-color, transparent);\n box-shadow: var(--uf-card-shadow, var(--uf-shadow-raised));\n }\n\n :host([variant='filled']) .base {\n border-color: var(--uf-card-border-color, transparent);\n background: var(--uf-card-bg, var(--uf-color-surface-hover));\n }\n\n .content {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-width: 0;\n }\n\n .media ::slotted(*) {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .header,\n .body,\n .footer {\n padding: var(--_padding);\n }\n\n .header {\n padding-bottom: 0;\n }\n\n .body {\n flex: 1;\n }\n\n .footer {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--uf-space-2);\n padding-top: 0;\n }\n\n /* A body after a header only needs half the gap. */\n .has-header .body {\n padding-top: var(--uf-space-3);\n }\n\n /* Without a body, the header and footer keep their own padding. */\n .no-body .header {\n padding-bottom: var(--_padding);\n }\n .no-body.has-header .footer {\n padding-top: 0;\n }\n\n .empty {\n display: none;\n }\n\n :host([orientation='horizontal']) .base {\n flex-direction: row;\n }\n\n :host([orientation='horizontal']) .media {\n flex: 0 0 var(--uf-card-media-width, 40%);\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true },\n orientation: { reflect: true },\n };\n\n /** `outline` (a border), `elevated` (a shadow, or an accent glow in dark mode) or `filled` (a tinted background). */\n declare variant: CardVariant;\n /** `vertical`, or `horizontal` to put the media beside the content. */\n declare orientation: CardOrientation;\n\n readonly #slots = new HasSlotController(this, 'media', 'header', 'footer', '');\n\n constructor() {\n super();\n this.variant = 'outline';\n this.orientation = 'vertical';\n }\n\n /** True when the default slot has elements or non-blank text. */\n #hasBody(): boolean {\n return [...this.childNodes].some(\n (node) =>\n (node.nodeType === Node.ELEMENT_NODE && !(node as Element).hasAttribute('slot')) ||\n (node.nodeType === Node.TEXT_NODE && node.textContent!.trim() !== ''),\n );\n }\n\n override render() {\n const has = { media: this.#slots.has('media'), header: this.#slots.has('header'), footer: this.#slots.has('footer') };\n const body = this.#hasBody();\n return html`<div class=${classMap({ base: true, 'has-header': has.header, 'no-body': !body })} part=\"base\">\n <div class=${classMap({ media: true, empty: !has.media })} part=\"media\"><slot name=\"media\"></slot></div>\n <div class=\"content\">\n <div class=${classMap({ header: true, empty: !has.header })} part=\"header\"><slot name=\"header\"></slot></div>\n <div class=${classMap({ body: true, empty: !body })} part=\"body\"><slot></slot></div>\n <div class=${classMap({ footer: true, empty: !has.footer })} part=\"footer\"><slot name=\"footer\"></slot></div>\n </div>\n </div>`;\n }\n}\n\ndefineElement('uf-card', UfCard);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-card': UfCard;\n }\n}\n",
545
545
  "components/checkbox/checkbox.ts": "import { css, html, type PropertyDeclarations } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { describedBy } from '../../internal/field.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\nimport { ToggleControl } from '../../internal/toggle-control.js';\nimport { toggleStyles } from '../../internal/toggle.styles.js';\n\n/**\n * A checkbox with its label as content.\n *\n * @summary Lets users turn an option on or off, or pick several options.\n * @tag uf-checkbox\n *\n * @slot - The label.\n * @slot hint - Help text below the label. Overrides `hint`.\n *\n * @event input - Fired when the checked state changes.\n * @event change - Fired when the checked state changes.\n *\n * @csspart base - The `<label>` wrapping control and label.\n * @csspart control - The box.\n * @csspart checkmark - The check or dash icon.\n * @csspart label - The label text.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-checkbox-size - Size of the box.\n * @cssprop --uf-checkbox-radius - Corner radius of the box.\n * @cssprop --uf-checkbox-checked-bg - Background when checked.\n * @cssprop --uf-checkbox-indeterminate-bg - Background when indeterminate. Defaults to the checked background.\n *\n * @cssstate checked - The checkbox is checked.\n * @cssstate indeterminate - The checkbox shows a dash (\"some selected\").\n * @cssstate user-invalid - Required but unchecked, after the user interacted.\n */\nexport class UfCheckbox extends ToggleControl {\n static override styles = [\n hostStyles,\n toggleStyles,\n css`\n :host {\n --_control-width: var(--uf-checkbox-size, 1.125rem);\n --_control-height: var(--uf-checkbox-size, 1.125rem);\n }\n\n .native {\n width: var(--_control-width);\n height: var(--_control-height);\n border: 1px solid var(--uf-color-border-strong);\n border-radius: var(--uf-checkbox-radius, var(--uf-radius-control));\n background: var(--uf-color-surface);\n }\n\n .native:hover:not(:disabled) {\n border-color: var(--uf-color-text-muted);\n }\n\n .native:checked,\n .native:indeterminate {\n border-color: transparent;\n background: var(--uf-checkbox-checked-bg, var(--uf-color-accent));\n }\n\n .native:indeterminate {\n background: var(--uf-checkbox-indeterminate-bg, var(--uf-checkbox-checked-bg, var(--uf-color-accent)));\n }\n\n .invalid .native {\n border-color: var(--uf-color-danger-text);\n box-shadow: inset 0 0 0 1px var(--uf-color-danger-text);\n }\n\n .icon {\n position: absolute;\n inset: 0;\n margin: auto;\n width: 80%;\n height: 80%;\n color: var(--uf-color-on-accent);\n stroke-width: 3;\n pointer-events: none;\n opacity: 0;\n }\n\n .native:checked + .icon,\n .native:indeterminate + .icon {\n opacity: 1;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n indeterminate: { type: Boolean, reflect: true },\n selectAll: { type: Boolean, reflect: true, attribute: 'select-all' },\n hint: {},\n };\n\n /** Shows a dash instead of a check, for \"some selected\". Cleared when the user clicks. */\n declare indeterminate: boolean;\n /**\n * Inside `<uf-checkbox-group>`: checks or unchecks every other checkbox in the\n * group, and shows checked, unchecked or indeterminate to match them.\n */\n declare selectAll: boolean;\n /** Help text below the label. */\n declare hint: string | undefined;\n\n readonly #slots = new HasSlotController(this, 'hint');\n readonly #id = uniqueId('uf-checkbox');\n\n constructor() {\n super();\n this.indeterminate = false;\n this.selectAll = false;\n }\n\n override updated(): void {\n super.updated();\n this.internals.states?.[this.indeterminate ? 'add' : 'delete']('indeterminate');\n }\n\n #onChange = (event: Event): void => {\n this.indeterminate = false;\n this.onNativeChange(event);\n };\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n const disabled = this.isDisabled;\n\n return html`\n <label class=${classMap({ root: true, disabled, invalid: Boolean(error) })} part=\"base\">\n <span class=\"control\" part=\"control\">\n <input\n class=\"native\"\n type=\"checkbox\"\n name=${ifDefined(this.name || undefined)}\n .value=${this.value}\n .checked=${live(this.checked)}\n .indeterminate=${live(this.indeterminate)}\n ?required=${this.required}\n ?disabled=${disabled}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @change=${this.#onChange}\n />\n ${iconSvg(this.indeterminate ? icons.minus : icons.check, 'checkmark')}\n </span>\n <span class=\"label\" part=\"label\"><slot></slot></span>\n </label>\n <div id=${ids.hintId} class=\"hint\" part=\"hint\" ?hidden=${!this.hint && !hasHintSlot}>\n <slot name=\"hint\">${this.hint}</slot>\n </div>\n <div id=${ids.errorId} class=\"error\" part=\"error\" ?hidden=${!error}>${error}</div>\n `;\n }\n}\n\ndefineElement('uf-checkbox', UfCheckbox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-checkbox': UfCheckbox;\n }\n}\n",
546
- "internal/field.ts": "import { css, html, nothing, type TemplateResult } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\n\n/** Size of a form field. */\nexport type FieldSize = 'sm' | 'md' | 'lg';\n\nexport interface FieldParts {\n /** Id of the native control the label points at. */\n controlId: string;\n hintId: string;\n errorId: string;\n label?: string;\n hasLabelSlot: boolean;\n hint?: string;\n hasHintSlot: boolean;\n /** Visible error, shown once the user interacted with an invalid field. */\n error: string;\n required: boolean;\n control: TemplateResult;\n}\n\n/** ids for `aria-describedby` on the native control. */\nexport function describedBy(parts: Pick<FieldParts, 'hintId' | 'errorId' | 'hint' | 'hasHintSlot' | 'error'>): string | undefined {\n const ids = [];\n if (parts.hint || parts.hasHintSlot) ids.push(parts.hintId);\n if (parts.error) ids.push(parts.errorId);\n return ids.length ? ids.join(' ') : undefined;\n}\n\n/**\n * Label, control, hint and error laid out as one field. The label lives inside\n * the shadow root because an outside `<label for>` can't reach the native control.\n */\nexport function renderField(parts: FieldParts): TemplateResult {\n const hasLabel = Boolean(parts.label) || parts.hasLabelSlot;\n const hasHint = Boolean(parts.hint) || parts.hasHintSlot;\n return html`\n <div class=${classMap({ field: true, invalid: Boolean(parts.error) })} part=\"field\">\n <label for=${parts.controlId} class=\"field-label\" part=\"form-label\" ?hidden=${!hasLabel}>\n <slot name=\"label\">${parts.label}</slot>\n ${parts.required ? html`<span class=\"required\" aria-hidden=\"true\">*</span>` : nothing}\n </label>\n ${parts.control}\n <div id=${parts.hintId} class=\"field-hint\" part=\"hint\" ?hidden=${!hasHint}>\n <slot name=\"hint\">${parts.hint}</slot>\n </div>\n <div id=${parts.errorId} class=\"field-error\" part=\"error\" ?hidden=${!parts.error}>${parts.error}</div>\n </div>\n `;\n}\n\nexport const fieldStyles = css`\n :host {\n display: block;\n }\n\n .field {\n display: flex;\n flex-direction: column;\n gap: var(--uf-space-1);\n font-family: var(--uf-font-family-sans);\n }\n\n .field-label {\n font-size: var(--uf-font-size-md);\n font-weight: var(--uf-font-weight-medium);\n color: var(--uf-color-text);\n }\n\n .required {\n margin-inline-start: 0.125em;\n color: var(--uf-color-danger-text);\n }\n\n .field-hint,\n .field-error {\n font-size: var(--uf-font-size-sm);\n line-height: 1.4;\n }\n\n .field-hint {\n color: var(--uf-color-text-muted);\n }\n\n .field-error {\n color: var(--uf-color-danger-text);\n }\n\n [hidden] {\n display: none !important;\n }\n`;\n\n/** The bordered box shared by input, textarea and select. */\nexport const controlBoxStyles = css`\n .box {\n --_height: var(--uf-size-control-md);\n --_padding: var(--uf-space-3);\n --_font-size: var(--uf-font-size-md);\n display: flex;\n align-items: center;\n gap: var(--uf-space-2);\n min-height: var(--_height);\n padding: 0 var(--_padding);\n border: 1px solid var(--uf-field-border-color, var(--uf-color-border-strong));\n border-radius: var(--uf-field-radius, var(--uf-radius-control));\n background: var(--uf-field-bg, var(--uf-color-surface));\n color: var(--uf-color-text);\n font-size: var(--_font-size);\n transition:\n border-color var(--uf-duration-fast) ease,\n box-shadow var(--uf-duration-fast) ease;\n }\n\n :host([size='sm']) .box {\n --_height: var(--uf-size-control-sm);\n --_padding: var(--uf-space-2);\n --_font-size: var(--uf-font-size-sm);\n }\n\n :host([size='lg']) .box {\n --_height: var(--uf-size-control-lg);\n --_padding: var(--uf-space-4);\n --_font-size: var(--uf-font-size-lg);\n }\n\n .box:hover:not(.disabled) {\n border-color: var(--uf-color-text-muted);\n }\n\n .box:focus-within {\n border-color: var(--uf-color-focus-ring);\n box-shadow: 0 0 0 1px var(--uf-color-focus-ring);\n }\n\n /* A 2px error outline: the border plus an inset shadow, so the box keeps its size. */\n .invalid .box,\n .invalid .box:hover,\n .invalid .box:focus-within {\n border-color: var(--uf-color-danger-text);\n box-shadow: inset 0 0 0 1px var(--uf-color-danger-text);\n }\n\n .box.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .native {\n flex: 1;\n min-width: 0;\n height: 100%;\n padding: 0;\n border: 0;\n outline: none;\n background: transparent;\n color: inherit;\n font: inherit;\n }\n\n .native::placeholder {\n color: var(--uf-color-text-muted);\n opacity: 1;\n }\n\n .native:disabled {\n cursor: not-allowed;\n }\n\n ::slotted([slot='prefix']),\n ::slotted([slot='suffix']) {\n display: inline-flex;\n flex: none;\n color: var(--uf-color-text-muted);\n }\n\n ::slotted(svg) {\n width: 1em;\n height: 1em;\n }\n`;\n",
546
+ "internal/field.ts": "import { css, html, nothing, type TemplateResult } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\n\n/** Size of a form field. */\nexport type FieldSize = 'sm' | 'md' | 'lg';\n\nexport interface FieldParts {\n /** Id of the native control the label points at. */\n controlId: string;\n hintId: string;\n errorId: string;\n label?: string;\n hasLabelSlot: boolean;\n hint?: string;\n hasHintSlot: boolean;\n /** Visible error, shown once the user interacted with an invalid field. */\n error: string;\n required: boolean;\n control: TemplateResult;\n}\n\n/** ids for `aria-describedby` on the native control. */\nexport function describedBy(parts: Pick<FieldParts, 'hintId' | 'errorId' | 'hint' | 'hasHintSlot' | 'error'>): string | undefined {\n const ids = [];\n if (parts.hint || parts.hasHintSlot) ids.push(parts.hintId);\n if (parts.error) ids.push(parts.errorId);\n return ids.length ? ids.join(' ') : undefined;\n}\n\n/**\n * Label, control, hint and error laid out as one field. The label lives inside\n * the shadow root because an outside `<label for>` can't reach the native control.\n */\nexport function renderField(parts: FieldParts): TemplateResult {\n const hasLabel = Boolean(parts.label) || parts.hasLabelSlot;\n const hasHint = Boolean(parts.hint) || parts.hasHintSlot;\n return html`\n <div class=${classMap({ field: true, invalid: Boolean(parts.error) })} part=\"field\">\n <label for=${parts.controlId} class=\"field-label\" part=\"form-label\" ?hidden=${!hasLabel}>\n <slot name=\"label\">${parts.label}</slot>\n ${parts.required ? html`<span class=\"required\" aria-hidden=\"true\">*</span>` : nothing}\n </label>\n ${parts.control}\n <div id=${parts.hintId} class=\"field-hint\" part=\"hint\" ?hidden=${!hasHint}>\n <slot name=\"hint\">${parts.hint}</slot>\n </div>\n <div id=${parts.errorId} class=\"field-error\" part=\"error\" ?hidden=${!parts.error}>${parts.error}</div>\n </div>\n `;\n}\n\nexport const fieldStyles = css`\n :host {\n display: block;\n }\n\n .field {\n display: flex;\n flex-direction: column;\n gap: var(--uf-space-1);\n font-family: var(--uf-font-family-sans);\n }\n\n .field-label {\n font-size: var(--uf-font-size-md);\n font-weight: var(--uf-font-weight-medium);\n color: var(--uf-color-text);\n }\n\n .required {\n margin-inline-start: 0.125em;\n color: var(--uf-color-danger-text);\n }\n\n .field-hint,\n .field-error {\n font-size: var(--uf-font-size-sm);\n line-height: 1.4;\n }\n\n .field-hint {\n color: var(--uf-color-text-muted);\n }\n\n .field-error {\n color: var(--uf-color-danger-text);\n }\n\n [hidden] {\n display: none !important;\n }\n`;\n\n/** The bordered box shared by input, textarea and select. */\nexport const controlBoxStyles = css`\n .box {\n --_height: var(--uf-size-control-md);\n --_padding: var(--uf-space-3);\n --_font-size: var(--uf-font-size-md);\n display: flex;\n align-items: center;\n gap: var(--uf-space-2);\n min-height: var(--_height);\n padding: 0 var(--_padding);\n border: 1px solid var(--uf-field-border-color, var(--uf-color-border-strong));\n border-radius: var(--uf-field-radius, var(--uf-radius-control));\n background: var(--uf-field-bg, var(--uf-color-surface));\n color: var(--uf-color-text);\n font-size: var(--_font-size);\n transition:\n border-color var(--uf-duration-fast) ease,\n box-shadow var(--uf-duration-fast) ease;\n }\n\n :host([size='sm']) .box {\n --_height: var(--uf-size-control-sm);\n --_padding: var(--uf-space-2);\n --_font-size: var(--uf-font-size-sm);\n }\n\n :host([size='lg']) .box {\n --_height: var(--uf-size-control-lg);\n --_padding: var(--uf-space-4);\n --_font-size: var(--uf-font-size-lg);\n }\n\n .box:hover:not(.disabled) {\n border-color: var(--uf-color-text-muted);\n }\n\n .box:focus-within {\n border-color: var(--uf-color-focus-ring);\n box-shadow: 0 0 0 1px var(--uf-color-focus-ring);\n }\n\n /* A 2px error outline: the border plus an inset shadow, so the box keeps its size. */\n .invalid .box,\n .invalid .box:hover,\n .invalid .box:focus-within {\n border-color: var(--uf-color-danger-text);\n box-shadow: inset 0 0 0 1px var(--uf-color-danger-text);\n }\n\n /* Grey instead of faded: a faded field still looks like one you can type in. */\n .box.disabled {\n border-color: var(--uf-color-border);\n background: var(--uf-color-neutral-fill);\n color: var(--uf-color-text-muted);\n cursor: not-allowed;\n }\n\n .native {\n flex: 1;\n min-width: 0;\n height: 100%;\n padding: 0;\n border: 0;\n outline: none;\n background: transparent;\n color: inherit;\n font: inherit;\n }\n\n .native::placeholder {\n color: var(--uf-color-text-muted);\n opacity: 1;\n }\n\n .native:disabled {\n cursor: not-allowed;\n }\n\n ::slotted([slot='prefix']),\n ::slotted([slot='suffix']) {\n display: inline-flex;\n flex: none;\n color: var(--uf-color-text-muted);\n }\n\n ::slotted(svg) {\n width: 1em;\n height: 1em;\n }\n`;\n",
547
547
  "internal/toggle-control.ts": "import type { PropertyDeclarations, PropertyValues } from 'lit';\nimport { FormControl } from './form-control.js';\n\n/**\n * Shared logic for checkbox-like controls: `checked` state, the `checked`\n * attribute as the reset default, and submitting `value` only when checked.\n */\nexport abstract class ToggleControl extends FormControl {\n static override properties: PropertyDeclarations = {\n checked: { type: Boolean, attribute: false },\n defaultChecked: { type: Boolean, attribute: 'checked' },\n value: {},\n };\n\n /** Whether the control is on. */\n declare checked: boolean;\n /** Initial state, restored on form reset. Set with the `checked` attribute. */\n declare defaultChecked: boolean;\n /** Value submitted with the form when checked. */\n declare value: string;\n\n constructor() {\n super();\n this.checked = false;\n this.defaultChecked = false;\n this.value = 'on';\n }\n\n protected get nativeInput(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n /** Toggles the control, as if the user clicked it. */\n toggle(): void {\n this.nativeInput?.click();\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('defaultChecked') && this.checked === Boolean(changed.get('defaultChecked'))) {\n this.checked = this.defaultChecked;\n }\n }\n\n override updated(): void {\n this.syncFormState();\n }\n\n protected syncFormState(): void {\n const input = this.nativeInput;\n if (!input) return;\n this.internals.setFormValue(this.checked ? this.value : null, String(this.checked));\n this.internals.states?.[this.checked ? 'add' : 'delete']('checked');\n this.setValidityFrom(input);\n }\n\n protected resetValue(): void {\n this.checked = this.defaultChecked;\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.checked = state === 'true';\n }\n\n protected onNativeChange = (event: Event): void => {\n this.checked = (event.target as HTMLInputElement).checked;\n this.markInteracted();\n this.emitChange();\n };\n}\n",
548
548
  "internal/form-control.ts": "import { LitElement, type PropertyDeclarations } from 'lit';\nimport { Translator } from './i18n.js';\n\n/**\n * Base class for form-associated controls. Handles everything a native control\n * gets for free: form value, validity, reset, state restore, `<fieldset disabled>`,\n * and the `user-invalid` custom state (only set after the user interacted or\n * tried to submit, so pristine fields aren't shown as errors).\n *\n * Subclasses implement `syncFormState()` and call it whenever their value changes.\n */\nexport abstract class FormControl extends LitElement {\n static formAssociated = true;\n static override shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static override properties: PropertyDeclarations = {\n name: { reflect: true },\n disabled: { type: Boolean, reflect: true },\n required: { type: Boolean, reflect: true },\n };\n\n /** Name submitted with the form. */\n declare name: string;\n /** Disables the control. */\n declare disabled: boolean;\n /** Makes the control required for form submission. */\n declare required: boolean;\n\n protected readonly internals = this.attachInternals();\n /** Built-in text, e.g. validation messages, in the page's language. */\n protected readonly translator = new Translator(this);\n #formDisabled = false;\n #interacted = false;\n #customError = '';\n /** True while checkValidity() runs, so its `invalid` event isn't taken for a submit attempt. */\n #checking = false;\n\n constructor() {\n super();\n this.name = '';\n this.disabled = false;\n this.required = false;\n // Fired by the form when submission is blocked by this control.\n this.addEventListener('invalid', () => {\n if (!this.#checking) this.markInteracted();\n });\n }\n\n /** True while an update runs, so changes made during it don't start a nested one. */\n #updating = false;\n\n /**\n * Properties that change the submitted value or the validity. Subclasses add\n * their own constraints (`pattern`, `min`...).\n */\n protected static formStateProperties: ReadonlySet<PropertyKey> = new Set([\n 'value',\n 'checked',\n 'defaultValue',\n 'defaultChecked',\n 'required',\n 'name',\n ]);\n\n /**\n * Form value and validity come from the rendered control, but the form reads\n * them synchronously: `input.value = 'x'; form.requestSubmit()` must see the\n * new value. So changing one of `formStateProperties` on a rendered control\n * updates it at once, instead of in the next microtask. Other properties keep\n * Lit's batched updates.\n */\n override requestUpdate(...args: Parameters<LitElement['requestUpdate']>): void {\n super.requestUpdate(...args);\n const [name] = args;\n const formState = (this.constructor as typeof FormControl).formStateProperties;\n if (name !== undefined && formState.has(name) && this.hasUpdated && !this.#updating && this.isUpdatePending) {\n this.performUpdate();\n }\n }\n\n protected override performUpdate(): void {\n this.#updating = true;\n try {\n super.performUpdate();\n } finally {\n this.#updating = false;\n }\n }\n\n /** The form this control belongs to, if any. */\n get form(): HTMLFormElement | null {\n return this.internals.form;\n }\n\n /** The control's validity state, like a native input's. */\n get validity(): ValidityState {\n return this.internals.validity;\n }\n\n /** The error message shown when the value is invalid. */\n get validationMessage(): string {\n return this.internals.validationMessage;\n }\n\n /** Whether the control takes part in form validation. */\n get willValidate(): boolean {\n return this.internals.willValidate;\n }\n\n /** Returns whether the value is valid, without showing an error. */\n checkValidity(): boolean {\n this.#checking = true;\n try {\n return this.internals.checkValidity();\n } finally {\n this.#checking = false;\n }\n }\n\n /** Returns whether the value is valid, and shows the error if not. */\n reportValidity(): boolean {\n this.markInteracted();\n return this.internals.reportValidity();\n }\n\n /** Sets a custom error message. Pass an empty string to clear it. */\n setCustomValidity(message: string): void {\n this.#customError = message;\n this.syncFormState();\n }\n\n /** True when the control is disabled directly or through a disabled fieldset. */\n protected get isDisabled(): boolean {\n return this.disabled || this.#formDisabled;\n }\n\n /** True when the control is invalid and the user has interacted with it. */\n protected get showInvalid(): boolean {\n return this.#interacted && !this.internals.validity.valid;\n }\n\n protected get customError(): string {\n return this.#customError;\n }\n\n /** Call after user input or blur, so validation errors may be shown. */\n protected markInteracted(): void {\n if (this.#interacted) return;\n this.#interacted = true;\n this.#updateStates();\n }\n\n /**\n * Sets validity from flags. A custom error set through `setCustomValidity`\n * takes precedence. `anchor` is the element the browser points its bubble at.\n */\n protected setValidity(flags: ValidityStateFlags, message: string, anchor?: HTMLElement): void {\n if (this.#customError) {\n this.internals.setValidity({ ...flags, customError: true }, this.#customError, anchor);\n } else if (Object.values(flags).some(Boolean)) {\n this.internals.setValidity(flags, message || this.translator.t('invalidValue'), anchor);\n } else {\n this.internals.setValidity({});\n }\n this.#updateStates();\n }\n\n /** Copies a native control's validity onto the host. */\n protected setValidityFrom(control: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement): void {\n control.setCustomValidity(this.#customError);\n const v = control.validity;\n this.setValidity(\n {\n valueMissing: v.valueMissing,\n typeMismatch: v.typeMismatch,\n patternMismatch: v.patternMismatch,\n tooLong: v.tooLong,\n tooShort: v.tooShort,\n rangeUnderflow: v.rangeUnderflow,\n rangeOverflow: v.rangeOverflow,\n stepMismatch: v.stepMismatch,\n badInput: v.badInput,\n },\n control.validationMessage,\n control,\n );\n }\n\n #shownInvalid = false;\n\n #updateStates(): void {\n const invalid = this.showInvalid;\n // Only re-render on a real change: syncFormState() runs from updated().\n if (invalid === this.#shownInvalid) return;\n this.#shownInvalid = invalid;\n this.internals.states?.[invalid ? 'add' : 'delete']('user-invalid');\n this.requestUpdate();\n }\n\n /** Updates the submitted value and validity. */\n protected abstract syncFormState(): void;\n\n /** Restores the initial value, called on form reset. */\n protected abstract resetValue(): void;\n\n /** @internal */\n formDisabledCallback(disabled: boolean): void {\n this.#formDisabled = disabled;\n this.requestUpdate();\n }\n\n /** @internal */\n formResetCallback(): void {\n this.resetValue();\n this.#interacted = false;\n this.syncFormState();\n }\n\n /** Dispatches a bubbling `change` event, which native `change` events don't cross shadow roots. */\n protected emitChange(): void {\n this.dispatchEvent(new Event('change', { bubbles: true }));\n }\n}\n",
549
549
  "internal/toggle.styles.ts": "import { css } from 'lit';\n\n/** Layout shared by checkbox, switch and radio: control, label, hint and error. */\nexport const toggleStyles = css`\n :host {\n display: block;\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n color: var(--uf-color-text);\n }\n\n .root {\n display: inline-flex;\n align-items: flex-start;\n gap: var(--uf-space-2);\n cursor: pointer;\n line-height: 1.4;\n }\n\n .root.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .control {\n position: relative;\n display: inline-flex;\n flex: none;\n /* Vertically centers the control on the first line of the label. */\n margin-top: calc((1.4em - var(--_control-height)) / 2);\n }\n\n .native {\n appearance: none;\n margin: 0;\n cursor: inherit;\n transition:\n background-color var(--uf-duration-fast) ease,\n border-color var(--uf-duration-fast) ease;\n }\n\n .native:focus-visible {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: var(--uf-focus-ring-offset);\n }\n\n .hint,\n .error {\n margin: var(--uf-space-1) 0 0 calc(var(--_control-width) + var(--uf-space-2));\n font-size: var(--uf-font-size-sm);\n line-height: 1.4;\n }\n\n .hint {\n color: var(--uf-color-text-muted);\n }\n\n .error {\n color: var(--uf-color-danger-text);\n }\n\n [hidden] {\n display: none !important;\n }\n`;\n",
550
550
  "components/checkbox-group/checkbox-group.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { defineElement } from '../../internal/define.js';\nimport { fieldStyles } from '../../internal/field.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\nimport '../checkbox/checkbox.js';\nimport type { UfCheckbox } from '../checkbox/checkbox.js';\n\n/**\n * Groups related `<uf-checkbox>`es under one label. Mark one checkbox with\n * `select-all` to get the \"select all\" pattern: it checks or unchecks the\n * others, and turns indeterminate when only some are checked.\n *\n * Each checkbox still submits its own `name` and `value` with a form;\n * `value` on the group lists the checked values, for frameworks.\n *\n * @summary Groups checkboxes, with an optional \"select all\".\n * @tag uf-checkbox-group\n *\n * @slot - `<uf-checkbox>` elements.\n * @slot label - The group label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the checkboxes. Overrides `hint`.\n *\n * @event change - A checkbox in the group changed (including through \"select all\").\n *\n * @csspart base - The element with `role=\"group\"`.\n * @csspart form-label - The group label.\n * @csspart options - The wrapper around the checkboxes.\n * @csspart hint - The hint text.\n *\n * @cssprop --uf-checkbox-group-indent - Indent of the checkboxes under a \"select all\".\n */\nexport class UfCheckboxGroup extends LitElement {\n static override styles = [\n hostStyles,\n fieldStyles,\n css`\n .options {\n display: flex;\n flex-direction: column;\n gap: var(--uf-space-2);\n margin-top: var(--uf-space-1);\n }\n\n :host([orientation='horizontal']) .options {\n flex-direction: row;\n flex-wrap: wrap;\n gap: var(--uf-space-2) var(--uf-space-5);\n }\n\n /* The checkboxes controlled by \"select all\" sit indented under it. */\n .has-select-all ::slotted(uf-checkbox:not([select-all])) {\n margin-inline-start: var(--uf-checkbox-group-indent, calc(1.125rem + var(--uf-space-2)));\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n label: {},\n hint: {},\n orientation: { reflect: true },\n };\n\n /** Visible group label. */\n declare label: string | undefined;\n /** Help text below the checkboxes. */\n declare hint: string | undefined;\n /** Lays the checkboxes out in a column or a row. */\n declare orientation: 'vertical' | 'horizontal';\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-checkbox-group');\n\n constructor() {\n super();\n this.orientation = 'vertical';\n // Runs before listeners added later (e.g. a framework's), so they see the synced state.\n this.addEventListener('change', this.#onChange);\n }\n\n get #selectAll(): UfCheckbox | null {\n return this.querySelector<UfCheckbox>('uf-checkbox[select-all]');\n }\n\n /** The checkboxes in the group, other than \"select all\". */\n get #options(): UfCheckbox[] {\n return [...this.querySelectorAll<UfCheckbox>('uf-checkbox')].filter((c) => !c.selectAll);\n }\n\n /** The values of the checked checkboxes (other than \"select all\"). */\n get value(): string[] {\n return this.#options.filter((c) => c.checked).map((c) => c.value);\n }\n\n set value(values: string[]) {\n const wanted = new Set(values ?? []);\n for (const option of this.#options) option.checked = wanted.has(option.value);\n this.sync();\n }\n\n /**\n * Updates \"select all\" to match the other checkboxes. Called automatically on\n * user changes; call it after changing `checked` on a checkbox from code.\n */\n sync(): void {\n const selectAll = this.#selectAll;\n if (!selectAll) return;\n const options = this.#options;\n const checked = options.filter((c) => c.checked).length;\n selectAll.checked = checked > 0 && checked === options.length;\n selectAll.indeterminate = checked > 0 && checked < options.length;\n }\n\n #onChange = (event: Event): void => {\n const target = event.target as UfCheckbox;\n if (target.localName !== 'uf-checkbox' || !this.contains(target)) return;\n if (target.selectAll) {\n // Disabled checkboxes keep their state, like any control the user can't change.\n for (const option of this.#options) if (!option.disabled) option.checked = target.checked;\n }\n this.sync();\n };\n\n override render() {\n const labelId = `${this.#id}-label`;\n const hintId = `${this.#id}-hint`;\n const hasLabel = Boolean(this.label) || this.#slots.has('label');\n const hasHint = Boolean(this.hint) || this.#slots.has('hint');\n\n return html`\n <div\n class=${classMap({ field: true, 'has-select-all': Boolean(this.#selectAll) })}\n part=\"base\"\n role=\"group\"\n aria-labelledby=${ifDefined(hasLabel ? labelId : undefined)}\n aria-describedby=${ifDefined(hasHint ? hintId : undefined)}\n >\n <div id=${labelId} class=\"field-label\" part=\"form-label\" ?hidden=${!hasLabel}>\n <slot name=\"label\">${this.label}</slot>\n </div>\n <div class=\"options\" part=\"options\">\n <slot\n @slotchange=${() => {\n this.sync();\n this.requestUpdate();\n }}\n ></slot>\n </div>\n <div id=${hintId} class=\"field-hint\" part=\"hint\" ?hidden=${!hasHint}>\n <slot name=\"hint\">${this.hint ?? nothing}</slot>\n </div>\n </div>\n `;\n }\n}\n\ndefineElement('uf-checkbox-group', UfCheckboxGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-checkbox-group': UfCheckboxGroup;\n }\n}\n",
551
- "components/combobox/combobox.ts": "import { css, html, nothing, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { controlBoxStyles, describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { flattenOptions, observeOptions, readItems, type Item, type OptionItem } from '../../internal/options.js';\nimport { autoUpdate, positionFloating } from '../../internal/position.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\n/** A visible option, with its group and its index among visible options. */\ninterface Row {\n option: OptionItem;\n group?: string;\n index: number;\n}\n\n/**\n * A text field with a filterable list of options, following the WAI-ARIA\n * combobox pattern. Typing filters the list; arrow keys move through it and\n * Enter picks an option. Only listed values can be chosen. Write options as\n * plain `<option>` and `<optgroup>` children, like `<uf-select>`.\n *\n * @summary Lets users search a list and pick one option.\n * @tag uf-combobox\n *\n * @slot - `<option>` and `<optgroup>` elements. They are read, not rendered.\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the field. Overrides `hint`.\n * @slot prefix - An icon before the input.\n *\n * @event input - Fired as the user types in the field (the search text, not the value).\n * @event change - Fired when the selected value changes.\n * @event uf-show - The list opened.\n * @event uf-hide - The list closed.\n *\n * @csspart field - The wrapper around label, control, hint and error.\n * @csspart form-label - The label.\n * @csspart box - The bordered box.\n * @csspart input - The native `<input>`.\n * @csspart toggle - The button that opens the list.\n * @csspart listbox - The floating list.\n * @csspart option - Each option.\n * @csspart group-label - Each group heading.\n * @csspart empty - The \"no results\" message.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-combobox-max-height - Maximum height of the list before it scrolls.\n *\n * @cssstate user-invalid - The value is invalid and the user has interacted with the field.\n */\nexport class UfCombobox extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n controlBoxStyles,\n css`\n .box {\n padding-inline-end: 0;\n }\n\n .toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n align-self: stretch;\n width: calc(var(--_height) - 2px);\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--uf-color-text-muted);\n cursor: pointer;\n }\n\n .toggle:disabled {\n cursor: not-allowed;\n }\n\n .toggle .icon {\n width: 1em;\n height: 1em;\n transition: rotate var(--uf-duration-fast) ease;\n }\n\n .toggle.open .icon {\n rotate: 180deg;\n }\n\n .listbox {\n position: fixed;\n inset: auto;\n margin: 0;\n max-height: var(--uf-combobox-max-height, 16rem);\n padding: var(--uf-space-1) 0;\n overflow: auto;\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-radius-control);\n background: var(--uf-color-surface-overlay);\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n box-shadow: var(--uf-shadow-md);\n }\n\n .option {\n display: flex;\n align-items: center;\n gap: var(--uf-space-2);\n min-height: var(--uf-size-control-sm);\n padding: 0 var(--uf-space-3) 0 var(--uf-space-2);\n cursor: pointer;\n user-select: none;\n }\n\n .option .check {\n display: inline-flex;\n width: 1rem;\n flex: none;\n }\n\n .option .icon {\n width: 1rem;\n height: 1rem;\n }\n\n .option.active {\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n .option[aria-selected='true'] {\n font-weight: var(--uf-font-weight-medium);\n }\n\n .option[aria-disabled='true'] {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .group-label {\n padding: var(--uf-space-2) var(--uf-space-3) var(--uf-space-1);\n color: var(--uf-color-text-muted);\n font-size: var(--uf-font-size-sm);\n font-weight: var(--uf-font-weight-semibold);\n }\n\n .empty {\n padding: var(--uf-space-2) var(--uf-space-3);\n color: var(--uf-color-text-muted);\n }\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n placeholder: {},\n size: { reflect: true },\n open: { type: Boolean, reflect: true },\n };\n\n /** The selected option's value, or an empty string. */\n declare value: string;\n /** Initially selected value, restored on form reset. Set with the `value` attribute. */\n declare defaultValue: string | undefined;\n /** Visible label. */\n declare label: string | undefined;\n /** Help text below the field. */\n declare hint: string | undefined;\n /** Placeholder text in the field. */\n declare placeholder: string | undefined;\n /** Size of the field. */\n declare size: FieldSize;\n /** Whether the list is showing. */\n declare open: boolean;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-combobox');\n #observer?: MutationObserver;\n #items: Item[] = [];\n #itemsChanged = false;\n #hasInitialized = false;\n /** Text the user typed; null while the field shows the selected option's label. */\n #query: string | null = null;\n /** Index of the highlighted row among visible options, or -1. */\n #active = -1;\n #cleanup?: () => void;\n\n constructor() {\n super();\n this.value = '';\n this.size = 'md';\n this.open = false;\n this.addEventListener('focusout', this.#onFocusOut);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#readItems();\n this.#observer = observeOptions(this, () => this.#readItems());\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#observer?.disconnect();\n this.#cleanup?.();\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n get #listbox(): HTMLElement | null {\n return this.renderRoot.querySelector('.listbox');\n }\n\n get #options(): OptionItem[] {\n return flattenOptions(this.#items);\n }\n\n get #selected(): OptionItem | undefined {\n return this.#options.find((o) => o.value === this.value);\n }\n\n /** Options matching the current search, in order, with their group. */\n get #rows(): Row[] {\n const query = this.#query?.trim().toLowerCase() ?? '';\n const rows: Row[] = [];\n const add = (option: OptionItem, group?: string) => {\n if (!query || option.label.toLowerCase().includes(query)) rows.push({ option, group, index: rows.length });\n };\n for (const item of this.#items) {\n if (item.kind === 'group') item.options.forEach((o) => add(o, item.label));\n else add(item);\n }\n return rows;\n }\n\n #readItems(): void {\n this.#items = readItems(this);\n this.#itemsChanged = true;\n this.requestUpdate();\n }\n\n #initialValue(): string {\n if (this.defaultValue !== undefined && this.defaultValue !== null) return this.defaultValue;\n return this.#options.find((o) => o.selected)?.value ?? '';\n }\n\n /** Opens the list. */\n show(): void {\n if (!this.isDisabled) this.open = true;\n }\n\n /** Closes the list. */\n hide(): void {\n this.open = false;\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('defaultValue') || this.#itemsChanged) {\n this.#itemsChanged = false;\n // Frameworks often connect the element before appending its options: wait for them.\n if (this.#items.length && !this.#hasInitialized) {\n // A value set before the options were read (e.g. by a framework) wins if it exists.\n if (!(this.value && this.#selected)) this.value = this.#initialValue();\n this.#hasInitialized = true;\n } else if (this.#items.length && this.value && !this.#selected) {\n this.value = this.#initialValue();\n }\n }\n if (changed.has('open') && !this.open) {\n this.#query = null;\n this.#active = -1;\n }\n }\n\n override updated(changed: PropertyValues<this>): void {\n this.syncFormState();\n if (changed.has('open')) this.#syncPopup();\n this.renderRoot.querySelector('.option.active')?.scrollIntoView({ block: 'nearest' });\n }\n\n #syncPopup(): void {\n const listbox = this.#listbox;\n const box = this.renderRoot.querySelector<HTMLElement>('.box');\n if (!listbox || !box) return;\n if (this.open && !listbox.matches(':popover-open')) {\n listbox.showPopover();\n this.#cleanup = autoUpdate(box, listbox, () => {\n listbox.style.minWidth = `${box.offsetWidth}px`;\n positionFloating(box, listbox, 'bottom-start', 4);\n });\n this.dispatchEvent(new Event('uf-show', { bubbles: true, composed: true }));\n } else if (!this.open && listbox.matches(':popover-open')) {\n listbox.hidePopover();\n this.#cleanup?.();\n this.#cleanup = undefined;\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n }\n }\n\n protected syncFormState(): void {\n const input = this.#input;\n if (!input) return;\n this.internals.setFormValue(this.value);\n this.setValidity({ valueMissing: this.required && !this.value }, this.translator.t('selectItem'), input);\n }\n\n protected resetValue(): void {\n this.value = this.#initialValue();\n this.#query = null;\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = state ?? '';\n }\n\n #select(option: OptionItem): void {\n if (option.disabled) return;\n const changed = option.value !== this.value;\n this.value = option.value;\n this.#query = null;\n this.hide();\n this.markInteracted();\n if (changed) this.emitChange();\n }\n\n /** Highlights the next or previous enabled row, wrapping around. */\n #move(step: 1 | -1, rows: Row[]): void {\n const enabled = rows.filter((r) => !r.option.disabled);\n if (!enabled.length) return;\n const position = enabled.findIndex((r) => r.index === this.#active);\n const next = position === -1 ? (step === 1 ? 0 : enabled.length - 1) : (position + step + enabled.length) % enabled.length;\n this.#active = enabled[next].index;\n this.requestUpdate();\n }\n\n /** On opening, highlight the selected option, or the first one. */\n #openWithActive(rows: Row[], fromEnd = false): void {\n const selected = rows.find((r) => r.option.value === this.value && !r.option.disabled);\n const enabled = rows.filter((r) => !r.option.disabled);\n this.#active = selected?.index ?? (fromEnd ? enabled[enabled.length - 1] : enabled[0])?.index ?? -1;\n this.show();\n }\n\n #onInput = (event: Event): void => {\n this.#query = (event.target as HTMLInputElement).value;\n // Highlight the first match, so Enter picks it.\n this.#active = this.#rows.find((r) => !r.option.disabled)?.index ?? -1;\n this.show();\n this.requestUpdate();\n };\n\n #onKeyDown = (event: KeyboardEvent): void => {\n const rows = this.#rows;\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n if (!this.open || event.altKey) this.#openWithActive(rows);\n else this.#move(1, rows);\n break;\n case 'ArrowUp':\n event.preventDefault();\n if (!this.open) this.#openWithActive(rows, true);\n else this.#move(-1, rows);\n break;\n case 'Enter': {\n const row = rows.find((r) => r.index === this.#active);\n if (this.open && row) {\n event.preventDefault();\n this.#select(row.option);\n }\n break;\n }\n case 'Escape':\n if (this.open) {\n event.preventDefault();\n this.hide();\n }\n break;\n }\n };\n\n /** Leaving the field: accept an exact match, clear on empty text, otherwise revert. */\n #commitText(): void {\n if (this.#query === null) return;\n const text = this.#query.trim().toLowerCase();\n if (!text) {\n if (this.value) {\n this.value = '';\n this.markInteracted();\n this.emitChange();\n }\n } else {\n const match = this.#options.find((o) => !o.disabled && o.label.toLowerCase() === text);\n if (match) this.#select(match);\n }\n this.#query = null;\n this.requestUpdate();\n }\n\n #onFocusOut = (event: FocusEvent): void => {\n const next = event.relatedTarget as Node | null;\n if (next && (this.contains(next) || this.renderRoot.contains(next))) return;\n this.#commitText();\n this.markInteracted();\n this.hide();\n };\n\n #onToggleClick = (): void => {\n if (this.open) this.hide();\n else this.#openWithActive(this.#rows);\n this.#input?.focus();\n };\n\n #renderOption(row: Row) {\n const { option } = row;\n const selected = option.value === this.value;\n return html`\n <div\n id=${`${this.#id}-option-${row.index}`}\n class=${classMap({ option: true, active: row.index === this.#active })}\n part=\"option\"\n role=\"option\"\n aria-selected=${selected ? 'true' : 'false'}\n aria-disabled=${option.disabled ? 'true' : 'false'}\n @pointerdown=${(e: Event) => e.preventDefault()}\n @click=${() => this.#select(option)}\n @pointermove=${() => {\n if (!option.disabled && this.#active !== row.index) {\n this.#active = row.index;\n this.requestUpdate();\n }\n }}\n >\n <span class=\"check\">${selected ? iconSvg(icons.check) : nothing}</span>\n ${option.label}\n </div>\n `;\n }\n\n #renderRows(rows: Row[]) {\n const out = [];\n let group: string | undefined;\n for (const row of rows) {\n if (row.group !== group) {\n group = row.group;\n if (group) out.push(html`<div class=\"group-label\" part=\"group-label\" role=\"presentation\">${group}</div>`);\n }\n out.push(this.#renderOption(row));\n }\n return out;\n }\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const listboxId = `${this.#id}-listbox`;\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n const rows = this.#rows;\n const activeId = this.open && this.#active >= 0 ? `${this.#id}-option-${this.#active}` : undefined;\n const text = this.#query ?? this.#selected?.label ?? '';\n\n return renderField({\n ...ids,\n controlId: this.#id,\n label: this.label,\n hasLabelSlot: this.#slots.has('label'),\n hint: this.hint,\n hasHintSlot,\n error,\n required: this.required,\n control: html`\n <div class=${classMap({ box: true, disabled: this.isDisabled })} part=\"box\">\n <slot name=\"prefix\"></slot>\n <input\n id=${this.#id}\n class=\"native\"\n part=\"input\"\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n .value=${live(text)}\n placeholder=${ifDefined(this.placeholder)}\n ?disabled=${this.isDisabled}\n aria-expanded=${this.open ? 'true' : 'false'}\n aria-controls=${listboxId}\n aria-autocomplete=\"list\"\n aria-activedescendant=${ifDefined(activeId)}\n aria-required=${this.required ? 'true' : 'false'}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @input=${this.#onInput}\n @keydown=${this.#onKeyDown}\n @click=${() => !this.open && this.#openWithActive(this.#rows)}\n />\n <button\n class=${classMap({ toggle: true, open: this.open })}\n part=\"toggle\"\n type=\"button\"\n tabindex=\"-1\"\n aria-label=${this.translator.t('showOptions')}\n ?disabled=${this.isDisabled}\n @pointerdown=${(e: Event) => e.preventDefault()}\n @click=${this.#onToggleClick}\n >\n ${iconSvg(icons['chevron-down'])}\n </button>\n </div>\n <div id=${listboxId} class=\"listbox\" part=\"listbox\" popover=\"manual\" role=\"listbox\" aria-label=${ifDefined(this.label)}>\n ${rows.length ? this.#renderRows(rows) : html`<div class=\"empty\" part=\"empty\" role=\"option\" aria-disabled=\"true\" aria-selected=\"false\">${this.translator.t('noResults')}</div>`}\n </div>\n <div class=\"sr-only\" role=\"status\">\n ${this.open && this.#query !== null\n ? rows.length === 1\n ? this.translator.t('oneResult')\n : this.translator.t('results', { count: rows.length })\n : ''}\n </div>\n `,\n });\n }\n}\n\ndefineElement('uf-combobox', UfCombobox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-combobox': UfCombobox;\n }\n}\n",
551
+ "components/combobox/combobox.ts": "import { css, html, nothing, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { controlBoxStyles, describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { flattenOptions, observeOptions, readItems, type Item, type OptionItem } from '../../internal/options.js';\nimport { autoUpdate, positionFloating } from '../../internal/position.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\n/** A visible option, with its group and its index among visible options. */\ninterface Row {\n option: OptionItem;\n group?: string;\n index: number;\n}\n\n/**\n * A text field with a filterable list of options, following the WAI-ARIA\n * combobox pattern. Typing filters the list; arrow keys move through it and\n * Enter picks an option. Only listed values can be chosen. Write options as\n * plain `<option>` and `<optgroup>` children, like `<uf-select>`.\n *\n * @summary Lets users search a list and pick one option.\n * @tag uf-combobox\n *\n * @slot - `<option>` and `<optgroup>` elements. They are read, not rendered.\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the field. Overrides `hint`.\n * @slot prefix - An icon before the input.\n *\n * @event input - Fired as the user types in the field (the search text, not the value).\n * @event change - Fired when the selected value changes.\n * @event uf-show - The list opened.\n * @event uf-hide - The list closed.\n *\n * @csspart field - The wrapper around label, control, hint and error.\n * @csspart form-label - The label.\n * @csspart box - The bordered box.\n * @csspart input - The native `<input>`.\n * @csspart toggle - The button that opens the list.\n * @csspart listbox - The floating list.\n * @csspart option - Each option.\n * @csspart group-label - Each group heading.\n * @csspart empty - The \"no results\" message.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-combobox-max-height - Maximum height of the list before it scrolls.\n *\n * @cssstate user-invalid - The value is invalid and the user has interacted with the field.\n */\nexport class UfCombobox extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n controlBoxStyles,\n css`\n .box {\n padding-inline-end: 0;\n }\n\n .toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n align-self: stretch;\n width: calc(var(--_height) - 2px);\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--uf-color-text-muted);\n cursor: pointer;\n }\n\n .toggle:disabled {\n cursor: not-allowed;\n }\n\n .toggle .icon {\n width: 1em;\n height: 1em;\n transition: rotate var(--uf-duration-fast) ease;\n }\n\n .toggle.open .icon {\n rotate: 180deg;\n }\n\n .listbox {\n position: fixed;\n inset: auto;\n margin: 0;\n max-height: var(--uf-combobox-max-height, 16rem);\n padding: var(--uf-space-1) 0;\n overflow: auto;\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-radius-control);\n background: var(--uf-color-surface-overlay);\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n box-shadow: var(--uf-shadow-overlay);\n }\n\n .option {\n display: flex;\n align-items: center;\n gap: var(--uf-space-2);\n min-height: var(--uf-size-control-sm);\n padding: 0 var(--uf-space-3) 0 var(--uf-space-2);\n cursor: pointer;\n user-select: none;\n }\n\n .option .check {\n display: inline-flex;\n width: 1rem;\n flex: none;\n }\n\n .option .icon {\n width: 1rem;\n height: 1rem;\n }\n\n .option.active {\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n .option[aria-selected='true'] {\n font-weight: var(--uf-font-weight-medium);\n }\n\n .option[aria-disabled='true'] {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .group-label {\n padding: var(--uf-space-2) var(--uf-space-3) var(--uf-space-1);\n color: var(--uf-color-text-muted);\n font-size: var(--uf-font-size-sm);\n font-weight: var(--uf-font-weight-semibold);\n }\n\n .empty {\n padding: var(--uf-space-2) var(--uf-space-3);\n color: var(--uf-color-text-muted);\n }\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n placeholder: {},\n size: { reflect: true },\n open: { type: Boolean, reflect: true },\n };\n\n /** The selected option's value, or an empty string. */\n declare value: string;\n /** Initially selected value, restored on form reset. Set with the `value` attribute. */\n declare defaultValue: string | undefined;\n /** Visible label. */\n declare label: string | undefined;\n /** Help text below the field. */\n declare hint: string | undefined;\n /** Placeholder text in the field. */\n declare placeholder: string | undefined;\n /** Size of the field. */\n declare size: FieldSize;\n /** Whether the list is showing. */\n declare open: boolean;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-combobox');\n #observer?: MutationObserver;\n #items: Item[] = [];\n #itemsChanged = false;\n #hasInitialized = false;\n /** Text the user typed; null while the field shows the selected option's label. */\n #query: string | null = null;\n /** Index of the highlighted row among visible options, or -1. */\n #active = -1;\n #cleanup?: () => void;\n\n constructor() {\n super();\n this.value = '';\n this.size = 'md';\n this.open = false;\n this.addEventListener('focusout', this.#onFocusOut);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#readItems();\n this.#observer = observeOptions(this, () => this.#readItems());\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#observer?.disconnect();\n this.#cleanup?.();\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n get #listbox(): HTMLElement | null {\n return this.renderRoot.querySelector('.listbox');\n }\n\n get #options(): OptionItem[] {\n return flattenOptions(this.#items);\n }\n\n get #selected(): OptionItem | undefined {\n return this.#options.find((o) => o.value === this.value);\n }\n\n /** Options matching the current search, in order, with their group. */\n get #rows(): Row[] {\n const query = this.#query?.trim().toLowerCase() ?? '';\n const rows: Row[] = [];\n const add = (option: OptionItem, group?: string) => {\n if (!query || option.label.toLowerCase().includes(query)) rows.push({ option, group, index: rows.length });\n };\n for (const item of this.#items) {\n if (item.kind === 'group') item.options.forEach((o) => add(o, item.label));\n else add(item);\n }\n return rows;\n }\n\n #readItems(): void {\n this.#items = readItems(this);\n this.#itemsChanged = true;\n this.requestUpdate();\n }\n\n #initialValue(): string {\n if (this.defaultValue !== undefined && this.defaultValue !== null) return this.defaultValue;\n return this.#options.find((o) => o.selected)?.value ?? '';\n }\n\n /** Opens the list. */\n show(): void {\n if (!this.isDisabled) this.open = true;\n }\n\n /** Closes the list. */\n hide(): void {\n this.open = false;\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('defaultValue') || this.#itemsChanged) {\n this.#itemsChanged = false;\n // Frameworks often connect the element before appending its options: wait for them.\n if (this.#items.length && !this.#hasInitialized) {\n // A value set before the options were read (e.g. by a framework) wins if it exists.\n if (!(this.value && this.#selected)) this.value = this.#initialValue();\n this.#hasInitialized = true;\n } else if (this.#items.length && this.value && !this.#selected) {\n this.value = this.#initialValue();\n }\n }\n if (changed.has('open') && !this.open) {\n this.#query = null;\n this.#active = -1;\n }\n }\n\n override updated(changed: PropertyValues<this>): void {\n this.syncFormState();\n if (changed.has('open')) this.#syncPopup();\n this.renderRoot.querySelector('.option.active')?.scrollIntoView({ block: 'nearest' });\n }\n\n #syncPopup(): void {\n const listbox = this.#listbox;\n const box = this.renderRoot.querySelector<HTMLElement>('.box');\n if (!listbox || !box) return;\n if (this.open && !listbox.matches(':popover-open')) {\n listbox.showPopover();\n this.#cleanup = autoUpdate(box, listbox, () => {\n listbox.style.minWidth = `${box.offsetWidth}px`;\n positionFloating(box, listbox, 'bottom-start', 4);\n });\n this.dispatchEvent(new Event('uf-show', { bubbles: true, composed: true }));\n } else if (!this.open && listbox.matches(':popover-open')) {\n listbox.hidePopover();\n this.#cleanup?.();\n this.#cleanup = undefined;\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n }\n }\n\n protected syncFormState(): void {\n const input = this.#input;\n if (!input) return;\n this.internals.setFormValue(this.value);\n this.setValidity({ valueMissing: this.required && !this.value }, this.translator.t('selectItem'), input);\n }\n\n protected resetValue(): void {\n this.value = this.#initialValue();\n this.#query = null;\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = state ?? '';\n }\n\n #select(option: OptionItem): void {\n if (option.disabled) return;\n const changed = option.value !== this.value;\n this.value = option.value;\n this.#query = null;\n this.hide();\n this.markInteracted();\n if (changed) this.emitChange();\n }\n\n /** Highlights the next or previous enabled row, wrapping around. */\n #move(step: 1 | -1, rows: Row[]): void {\n const enabled = rows.filter((r) => !r.option.disabled);\n if (!enabled.length) return;\n const position = enabled.findIndex((r) => r.index === this.#active);\n const next = position === -1 ? (step === 1 ? 0 : enabled.length - 1) : (position + step + enabled.length) % enabled.length;\n this.#active = enabled[next].index;\n this.requestUpdate();\n }\n\n /** On opening, highlight the selected option, or the first one. */\n #openWithActive(rows: Row[], fromEnd = false): void {\n const selected = rows.find((r) => r.option.value === this.value && !r.option.disabled);\n const enabled = rows.filter((r) => !r.option.disabled);\n this.#active = selected?.index ?? (fromEnd ? enabled[enabled.length - 1] : enabled[0])?.index ?? -1;\n this.show();\n }\n\n #onInput = (event: Event): void => {\n this.#query = (event.target as HTMLInputElement).value;\n // Highlight the first match, so Enter picks it.\n this.#active = this.#rows.find((r) => !r.option.disabled)?.index ?? -1;\n this.show();\n this.requestUpdate();\n };\n\n #onKeyDown = (event: KeyboardEvent): void => {\n const rows = this.#rows;\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n if (!this.open || event.altKey) this.#openWithActive(rows);\n else this.#move(1, rows);\n break;\n case 'ArrowUp':\n event.preventDefault();\n if (!this.open) this.#openWithActive(rows, true);\n else this.#move(-1, rows);\n break;\n case 'Enter': {\n const row = rows.find((r) => r.index === this.#active);\n if (this.open && row) {\n event.preventDefault();\n this.#select(row.option);\n }\n break;\n }\n case 'Escape':\n if (this.open) {\n event.preventDefault();\n this.hide();\n }\n break;\n }\n };\n\n /** Leaving the field: accept an exact match, clear on empty text, otherwise revert. */\n #commitText(): void {\n if (this.#query === null) return;\n const text = this.#query.trim().toLowerCase();\n if (!text) {\n if (this.value) {\n this.value = '';\n this.markInteracted();\n this.emitChange();\n }\n } else {\n const match = this.#options.find((o) => !o.disabled && o.label.toLowerCase() === text);\n if (match) this.#select(match);\n }\n this.#query = null;\n this.requestUpdate();\n }\n\n #onFocusOut = (event: FocusEvent): void => {\n const next = event.relatedTarget as Node | null;\n if (next && (this.contains(next) || this.renderRoot.contains(next))) return;\n this.#commitText();\n this.markInteracted();\n this.hide();\n };\n\n #onToggleClick = (): void => {\n if (this.open) this.hide();\n else this.#openWithActive(this.#rows);\n this.#input?.focus();\n };\n\n #renderOption(row: Row) {\n const { option } = row;\n const selected = option.value === this.value;\n return html`\n <div\n id=${`${this.#id}-option-${row.index}`}\n class=${classMap({ option: true, active: row.index === this.#active })}\n part=\"option\"\n role=\"option\"\n aria-selected=${selected ? 'true' : 'false'}\n aria-disabled=${option.disabled ? 'true' : 'false'}\n @pointerdown=${(e: Event) => e.preventDefault()}\n @click=${() => this.#select(option)}\n @pointermove=${() => {\n if (!option.disabled && this.#active !== row.index) {\n this.#active = row.index;\n this.requestUpdate();\n }\n }}\n >\n <span class=\"check\">${selected ? iconSvg(icons.check) : nothing}</span>\n ${option.label}\n </div>\n `;\n }\n\n #renderRows(rows: Row[]) {\n const out = [];\n let group: string | undefined;\n for (const row of rows) {\n if (row.group !== group) {\n group = row.group;\n if (group) out.push(html`<div class=\"group-label\" part=\"group-label\" role=\"presentation\">${group}</div>`);\n }\n out.push(this.#renderOption(row));\n }\n return out;\n }\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const listboxId = `${this.#id}-listbox`;\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n const rows = this.#rows;\n const activeId = this.open && this.#active >= 0 ? `${this.#id}-option-${this.#active}` : undefined;\n const text = this.#query ?? this.#selected?.label ?? '';\n\n return renderField({\n ...ids,\n controlId: this.#id,\n label: this.label,\n hasLabelSlot: this.#slots.has('label'),\n hint: this.hint,\n hasHintSlot,\n error,\n required: this.required,\n control: html`\n <div class=${classMap({ box: true, disabled: this.isDisabled })} part=\"box\">\n <slot name=\"prefix\"></slot>\n <input\n id=${this.#id}\n class=\"native\"\n part=\"input\"\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n .value=${live(text)}\n placeholder=${ifDefined(this.placeholder)}\n ?disabled=${this.isDisabled}\n aria-expanded=${this.open ? 'true' : 'false'}\n aria-controls=${listboxId}\n aria-autocomplete=\"list\"\n aria-activedescendant=${ifDefined(activeId)}\n aria-required=${this.required ? 'true' : 'false'}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @input=${this.#onInput}\n @keydown=${this.#onKeyDown}\n @click=${() => !this.open && this.#openWithActive(this.#rows)}\n />\n <button\n class=${classMap({ toggle: true, open: this.open })}\n part=\"toggle\"\n type=\"button\"\n tabindex=\"-1\"\n aria-label=${this.translator.t('showOptions')}\n ?disabled=${this.isDisabled}\n @pointerdown=${(e: Event) => e.preventDefault()}\n @click=${this.#onToggleClick}\n >\n ${iconSvg(icons['chevron-down'])}\n </button>\n </div>\n <div id=${listboxId} class=\"listbox\" part=\"listbox\" popover=\"manual\" role=\"listbox\" aria-label=${ifDefined(this.label)}>\n ${rows.length ? this.#renderRows(rows) : html`<div class=\"empty\" part=\"empty\" role=\"option\" aria-disabled=\"true\" aria-selected=\"false\">${this.translator.t('noResults')}</div>`}\n </div>\n <div class=\"sr-only\" role=\"status\">\n ${this.open && this.#query !== null\n ? rows.length === 1\n ? this.translator.t('oneResult')\n : this.translator.t('results', { count: rows.length })\n : ''}\n </div>\n `,\n });\n }\n}\n\ndefineElement('uf-combobox', UfCombobox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-combobox': UfCombobox;\n }\n}\n",
552
552
  "internal/options.ts": "/** An `<option>` read from a component's light DOM. */\nexport interface OptionItem {\n kind: 'option';\n value: string;\n label: string;\n disabled: boolean;\n selected: boolean;\n}\n\n/** An `<optgroup>` and its options. */\nexport interface GroupItem {\n kind: 'group';\n label: string;\n disabled: boolean;\n options: OptionItem[];\n}\n\nexport type Item = OptionItem | GroupItem;\n\nfunction readOption(option: HTMLOptionElement, groupDisabled = false): OptionItem {\n return {\n kind: 'option',\n value: option.value,\n label: option.label || option.textContent?.trim() || '',\n disabled: option.disabled || groupDisabled,\n selected: option.hasAttribute('selected'),\n };\n}\n\n/** Reads the `<option>` and `<optgroup>` children of a host element. */\nexport function readItems(host: Element): Item[] {\n return [...host.children].flatMap((child): Item[] => {\n if (child instanceof HTMLOptionElement) return [readOption(child)];\n if (child instanceof HTMLOptGroupElement) {\n return [\n {\n kind: 'group',\n label: child.label,\n disabled: child.disabled,\n options: [...child.querySelectorAll('option')].map((o) => readOption(o, child.disabled)),\n },\n ];\n }\n return [];\n });\n}\n\n/** All options, with groups flattened. */\nexport function flattenOptions(items: Item[]): OptionItem[] {\n return items.flatMap((item) => (item.kind === 'group' ? item.options : [item]));\n}\n\n/** Calls `onChange` whenever the host's options are added, removed or edited. */\nexport function observeOptions(host: Element, onChange: () => void): MutationObserver {\n const observer = new MutationObserver(onChange);\n observer.observe(host, { childList: true, subtree: true, attributes: true, characterData: true });\n return observer;\n}\n",
553
553
  "internal/position.ts": "export type Placement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'right';\n\nconst VIEWPORT_PADDING = 8;\nconst opposite = { top: 'bottom', bottom: 'top', left: 'right', right: 'left' } as const;\n\n/**\n * Positions a `position: fixed` element (usually in the top layer) next to an\n * anchor. Flips to the opposite side when it doesn't fit, then clamps to the\n * viewport. Returns the side it ended up on.\n */\nexport function positionFloating(\n anchor: Element,\n floating: HTMLElement,\n placement: Placement,\n offset = 8,\n): Placement {\n const a = anchor.getBoundingClientRect();\n const f = floating.getBoundingClientRect();\n const vw = document.documentElement.clientWidth;\n const vh = document.documentElement.clientHeight;\n\n let [side, align] = placement.split('-') as [keyof typeof opposite, 'start' | 'end' | undefined];\n\n const fits = (s: keyof typeof opposite) => {\n if (s === 'top') return a.top - offset - f.height >= VIEWPORT_PADDING;\n if (s === 'bottom') return a.bottom + offset + f.height <= vh - VIEWPORT_PADDING;\n if (s === 'left') return a.left - offset - f.width >= VIEWPORT_PADDING;\n return a.right + offset + f.width <= vw - VIEWPORT_PADDING;\n };\n if (!fits(side) && fits(opposite[side])) side = opposite[side];\n\n let x: number;\n let y: number;\n if (side === 'top' || side === 'bottom') {\n y = side === 'top' ? a.top - offset - f.height : a.bottom + offset;\n x = align === 'start' ? a.left : align === 'end' ? a.right - f.width : a.left + a.width / 2 - f.width / 2;\n } else {\n x = side === 'left' ? a.left - offset - f.width : a.right + offset;\n y = a.top + a.height / 2 - f.height / 2;\n }\n\n x = Math.min(Math.max(x, VIEWPORT_PADDING), vw - f.width - VIEWPORT_PADDING);\n y = Math.min(Math.max(y, VIEWPORT_PADDING), vh - f.height - VIEWPORT_PADDING);\n\n floating.style.left = `${Math.round(x)}px`;\n floating.style.top = `${Math.round(y)}px`;\n return (align ? `${side}-${align}` : side) as Placement;\n}\n\n/** Re-runs `update` on scroll, resize and size changes. Returns a cleanup function. */\nexport function autoUpdate(anchor: Element, floating: HTMLElement, update: () => void): () => void {\n let frame = 0;\n const schedule = () => {\n cancelAnimationFrame(frame);\n frame = requestAnimationFrame(update);\n };\n const observer = new ResizeObserver(schedule);\n observer.observe(anchor);\n observer.observe(floating);\n window.addEventListener('scroll', schedule, { capture: true, passive: true });\n window.addEventListener('resize', schedule, { passive: true });\n update();\n return () => {\n cancelAnimationFrame(frame);\n observer.disconnect();\n window.removeEventListener('scroll', schedule, { capture: true });\n window.removeEventListener('resize', schedule);\n };\n}\n\n",
554
- "components/date-picker/date-picker.ts": "import { css, html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { formatShort, formatter, parseIso, parseTyped, shortPattern, toIso, todayIso } from '../../internal/dates.js';\nimport { defineElement } from '../../internal/define.js';\nimport { controlBoxStyles, describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { autoUpdate, positionFloating } from '../../internal/position.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\nimport '../calendar/calendar.js';\nimport type { UfCalendar } from '../calendar/calendar.js';\n\n/** A browser-translated \"Please fill out this field.\", from a native input that never joins the page. */\nlet requiredMessage: string | undefined;\nfunction valueMissingMessage(): string {\n if (requiredMessage === undefined) {\n const probe = document.createElement('input');\n probe.required = true;\n requiredMessage = probe.validationMessage;\n }\n return requiredMessage;\n}\n\n/**\n * A date field: type a date in the page language's format, or pick one from a\n * calendar. The value is always `YYYY-MM-DD`, like `<input type=\"date\">`, so\n * it's the same in every language and submits with the form.\n *\n * Alt + Down Arrow opens the calendar; Escape closes it.\n *\n * @summary Lets users type or pick a date.\n * @tag uf-date-picker\n *\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the field. Overrides `hint`.\n *\n * @event input - The value changed (a date was typed and committed, or picked).\n * @event change - The value changed (a date was typed and committed, or picked).\n * @event uf-show - The calendar opened.\n * @event uf-hide - The calendar closed.\n *\n * @csspart field - The wrapper around label, control, hint and error.\n * @csspart form-label - The label.\n * @csspart box - The bordered box around the input.\n * @csspart input - The text input.\n * @csspart toggle - The calendar button.\n * @csspart popup - The floating panel around the calendar.\n * @csspart calendar - The `<uf-calendar>`.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-field-bg - Background of the box.\n * @cssprop --uf-field-border-color - Border color of the box.\n * @cssprop --uf-field-radius - Corner radius of the box.\n *\n * @cssstate user-invalid - The value is invalid and the user has interacted with the field.\n */\nexport class UfDatePicker extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n controlBoxStyles,\n css`\n .box {\n padding-inline-end: 0;\n }\n\n .toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n align-self: stretch;\n width: calc(var(--_height) - 2px);\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--uf-color-text-muted);\n cursor: pointer;\n }\n\n .toggle:hover:not(:disabled),\n .toggle.open {\n color: var(--uf-color-accent-strong);\n }\n\n .toggle:focus-visible {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: -2px;\n }\n\n .toggle:disabled {\n cursor: not-allowed;\n }\n\n .toggle .icon {\n width: 1.125em;\n height: 1.125em;\n }\n\n .popup {\n position: fixed;\n inset: auto;\n margin: 0;\n padding: var(--uf-space-3);\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-radius-md);\n background: var(--uf-color-surface-overlay);\n color: var(--uf-color-text);\n box-shadow: var(--uf-shadow-md);\n }\n `,\n ];\n\n protected static override formStateProperties: ReadonlySet<PropertyKey> = new Set([\n ...FormControl.formStateProperties,\n 'min',\n 'max',\n 'isDateDisabled',\n ]);\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n placeholder: {},\n size: { reflect: true },\n min: {},\n max: {},\n readonly: { type: Boolean, reflect: true },\n open: { type: Boolean, reflect: true },\n isDateDisabled: { attribute: false },\n };\n\n /** The date, as `YYYY-MM-DD`, or an empty string. */\n declare value: string;\n /** Initial date, restored on form reset. Set with the `value` attribute, as `YYYY-MM-DD`. */\n declare defaultValue: string;\n /** The field's label, also its accessible name. */\n declare label: string | undefined;\n /** Help text below the field. */\n declare hint: string | undefined;\n /** Shown when empty. Defaults to the date format, e.g. dd/mm/yyyy. */\n declare placeholder: string | undefined;\n /** Size: `sm`, `md` or `lg`. */\n declare size: FieldSize;\n /** The earliest allowed date, as `YYYY-MM-DD`. */\n declare min: string | undefined;\n /** The latest allowed date, as `YYYY-MM-DD`. */\n declare max: string | undefined;\n /** Lets the user select the text but not change the date. */\n declare readonly: boolean;\n /** Whether the calendar is open. */\n declare open: boolean;\n /** Rules out dates, e.g. weekends: called with each date as `YYYY-MM-DD`, returns true to disable it. */\n declare isDateDisabled: ((date: string) => boolean) | undefined;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-date-picker');\n /** What the user typed and hasn't committed yet; null shows the value, formatted. */\n #text: string | null = null;\n /** The committed text isn't a date. */\n #badInput = false;\n #cleanup?: () => void;\n /** Focus was in the calendar when it closed: give it back to the input. */\n #focusWasInside = false;\n /** Between beforetoggle and toggle. */\n #toggling = false;\n\n constructor() {\n super();\n this.value = '';\n this.defaultValue = '';\n this.size = 'md';\n this.readonly = false;\n this.open = false;\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n get #popup(): HTMLElement | null {\n return this.renderRoot.querySelector('.popup');\n }\n\n get #calendar(): UfCalendar | null {\n return this.renderRoot.querySelector('uf-calendar');\n }\n\n /** Opens the calendar. */\n show(): void {\n if (!this.isDisabled && !this.readonly) this.open = true;\n }\n\n /** Closes the calendar. */\n hide(): void {\n this.open = false;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#cleanup?.();\n this.#cleanup = undefined;\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('defaultValue') && this.value === (changed.get('defaultValue') ?? '')) {\n this.value = parseIso(this.defaultValue) ? this.defaultValue : '';\n }\n // A value set from code replaces what was typed.\n if (changed.has('value')) {\n this.#text = null;\n this.#badInput = false;\n }\n }\n\n override updated(changed: PropertyValues<this>): void {\n this.syncFormState();\n if (changed.has('open')) this.#syncPopup();\n }\n\n #syncPopup(): void {\n const popup = this.#popup;\n // The browser is opening or closing it already (button, Escape, click outside).\n if (!popup || this.#toggling) return;\n if (this.open && !popup.matches(':popover-open')) {\n popup.showPopover();\n // Positioned in the same task, so it never paints at its default spot.\n this.#startPositioning();\n } else if (!this.open && popup.matches(':popover-open')) {\n popup.hidePopover();\n }\n }\n\n /** Places the popup under the field, and keeps it there on scroll and resize. */\n #startPositioning(): void {\n const popup = this.#popup;\n const box = this.renderRoot.querySelector<HTMLElement>('.box');\n if (!popup || !box || !popup.matches(':popover-open')) return;\n this.#cleanup ??= autoUpdate(box, popup, () => positionFloating(box, popup, 'bottom-start', 4));\n }\n\n /**\n * The popup opened or closed, however it happened: the button (linked with\n * popovertarget, so a click while open closes it instead of reopening),\n * Escape, a click outside, or \\`open\\`.\n */\n #onBeforeToggle = (event: ToggleEvent): void => {\n // Synchronous, so \\`open\\` is right as soon as the popup opens or closes.\n // Lit may render before the browser finishes: #toggling keeps #syncPopup\n // from calling showPopover/hidePopover in the middle, which would cancel\n // the toggle event.\n this.#toggling = true;\n this.open = event.newState === 'open';\n // Opened by the button: the browser shows it after this event, and the\n // toggle event comes a task later, after a paint. An animation frame runs\n // after it's shown and before that paint, so position it there.\n if (event.newState === 'open') requestAnimationFrame(() => this.#startPositioning());\n // Before it hides: afterwards the browser has already moved focus away.\n if (event.newState === 'closed') this.#focusWasInside = Boolean(this.shadowRoot?.activeElement?.closest('.popup'));\n };\n\n #onToggle = (event: ToggleEvent): void => {\n this.#toggling = false;\n if (event.newState === 'open') {\n this.#startPositioning();\n this.#calendar?.updateComplete.then(() => this.#calendar?.focus());\n this.dispatchEvent(new Event('uf-show', { bubbles: true, composed: true }));\n } else {\n this.#cleanup?.();\n this.#cleanup = undefined;\n if (this.#focusWasInside) this.#input?.focus();\n this.#focusWasInside = false;\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n }\n };\n\n protected syncFormState(): void {\n const input = this.#input;\n if (!input) return;\n this.internals.setFormValue(this.value);\n const t = this.translator;\n const lang = t.lang;\n const date = parseIso(this.value);\n const min = parseIso(this.min);\n const max = parseIso(this.max);\n const long = (d: Date) => formatter(lang, { day: 'numeric', month: 'long', year: 'numeric' }).format(d);\n\n if (this.#badInput) {\n this.setValidity({ badInput: true }, t.t('invalidDate', { example: formatShort(parseIso(todayIso())!, lang) }), input);\n } else if (this.required && !date) {\n this.setValidity({ valueMissing: true }, valueMissingMessage(), input);\n } else if (date && min && date < min) {\n this.setValidity({ rangeUnderflow: true }, t.t('dateTooEarly', { date: long(min) }), input);\n } else if (date && max && date > max) {\n this.setValidity({ rangeOverflow: true }, t.t('dateTooLate', { date: long(max) }), input);\n } else if (date && this.isDateDisabled?.(this.value)) {\n this.setValidity({ badInput: true }, t.t('dateUnavailable'), input);\n } else {\n this.setValidity({}, '', input);\n }\n }\n\n protected resetValue(): void {\n this.value = parseIso(this.defaultValue) ? this.defaultValue : '';\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = parseIso(state) ? state! : '';\n }\n\n /** Sets the value from the user, and tells listeners when it changed. */\n #commit(value: string): void {\n const changed = value !== this.value;\n this.value = value;\n this.markInteracted();\n if (changed) {\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n this.emitChange();\n }\n }\n\n /** Turns the typed text into the value: a date, empty, or invalid. */\n #commitText(): void {\n if (this.#text === null) return;\n const text = this.#text.trim();\n const date = text ? parseTyped(text, this.translator.lang) : null;\n if (!text || date) {\n this.#commit(date ? toIso(date) : '');\n this.#text = null;\n this.#badInput = false;\n } else {\n // Not a date: keep the text so the user can fix it, and report it.\n this.#commit('');\n this.#text = text;\n this.#badInput = true;\n }\n this.syncFormState();\n this.requestUpdate();\n }\n\n #onInput = (event: Event): void => {\n // The value changes when the date is committed, not on every keystroke.\n event.stopPropagation();\n this.#text = (event.target as HTMLInputElement).value;\n };\n\n #onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Enter') this.#commitText();\n else if (event.key === 'ArrowDown' && event.altKey) {\n event.preventDefault();\n this.show();\n }\n };\n\n #onCalendarChange = (event: Event): void => {\n event.stopPropagation();\n this.#commit((event.target as UfCalendar).value);\n this.hide();\n this.#input?.focus();\n };\n\n #placeholder(): string {\n if (this.placeholder !== undefined) return this.placeholder;\n const { order, separator } = shortPattern(this.translator.lang);\n const letters = { day: this.translator.t('dayPlaceholder'), month: this.translator.t('monthPlaceholder'), year: this.translator.t('yearPlaceholder') };\n return order.map((part) => letters[part]).join(separator);\n }\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const popupId = `${this.#id}-popup`;\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n const date = parseIso(this.value);\n const text = this.#text ?? (date ? formatShort(date, this.translator.lang) : '');\n\n return renderField({\n ...ids,\n controlId: this.#id,\n label: this.label,\n hasLabelSlot: this.#slots.has('label'),\n hint: this.hint,\n hasHintSlot,\n error,\n required: this.required,\n control: html`\n <div class=${classMap({ box: true, disabled: this.isDisabled })} part=\"box\">\n <input\n id=${this.#id}\n class=\"native\"\n part=\"input\"\n type=\"text\"\n autocomplete=\"off\"\n .value=${live(text)}\n placeholder=${this.#placeholder()}\n ?readonly=${this.readonly}\n ?disabled=${this.isDisabled}\n aria-required=${this.required ? 'true' : 'false'}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @input=${this.#onInput}\n @change=${() => this.#commitText()}\n @keydown=${this.#onKeyDown}\n />\n <button\n class=${classMap({ toggle: true, open: this.open })}\n part=\"toggle\"\n type=\"button\"\n aria-label=${this.translator.t('chooseDate')}\n aria-haspopup=\"dialog\"\n aria-expanded=${this.open ? 'true' : 'false'}\n popovertarget=${popupId}\n ?disabled=${this.isDisabled || this.readonly}\n >\n ${iconSvg(icons.calendar)}\n </button>\n </div>\n <div\n id=${popupId}\n class=\"popup\"\n part=\"popup\"\n popover=\"auto\"\n role=\"dialog\"\n aria-label=${this.label ?? this.translator.t('chooseDate')}\n @beforetoggle=${this.#onBeforeToggle}\n @toggle=${this.#onToggle}\n >\n <uf-calendar\n part=\"calendar\"\n .value=${this.value}\n .min=${this.min}\n .max=${this.max}\n .isDateDisabled=${this.isDateDisabled}\n @change=${this.#onCalendarChange}\n ></uf-calendar>\n </div>\n `,\n });\n }\n}\n\ndefineElement('uf-date-picker', UfDatePicker);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-date-picker': UfDatePicker;\n }\n}\n",
555
- "components/dialog/dialog.ts": "import { LitElement, css, html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { Translator } from '../../internal/i18n.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\nexport type DialogCloseSource = 'close-button' | 'escape' | 'backdrop' | 'trigger' | 'method';\n\nexport interface DialogRequestCloseDetail {\n source: DialogCloseSource;\n}\n\nlet scrollLocks = 0;\nlet savedStyles: { overflow: string; paddingRight: string } | undefined;\n\n/**\n * Locks page scroll while any dialog is open. Hiding overflow removes a classic\n * (non-overlay) scrollbar, so the page is padded by its width to avoid a shift.\n * (`scrollbar-gutter: stable` isn't honoured on the root once overflow is hidden.)\n * The width is exposed as `--uf-scrollbar-width` for fixed elements to compensate.\n */\nfunction lockScroll(lock: boolean): void {\n const html = document.documentElement;\n const wasLocked = scrollLocks > 0;\n scrollLocks = Math.max(0, scrollLocks + (lock ? 1 : -1));\n\n if (scrollLocks > 0 && !wasLocked) {\n const scrollbarWidth = window.innerWidth - html.clientWidth;\n savedStyles = { overflow: html.style.overflow, paddingRight: html.style.paddingRight };\n if (scrollbarWidth > 0) {\n const padding = parseFloat(getComputedStyle(html).paddingRight) || 0;\n html.style.paddingRight = `${padding + scrollbarWidth}px`;\n html.style.setProperty('--uf-scrollbar-width', `${scrollbarWidth}px`);\n }\n html.style.overflow = 'hidden';\n } else if (scrollLocks === 0 && wasLocked && savedStyles) {\n html.style.overflow = savedStyles.overflow;\n html.style.paddingRight = savedStyles.paddingRight;\n html.style.removeProperty('--uf-scrollbar-width');\n savedStyles = undefined;\n }\n}\n\n/**\n * A modal dialog built on the native `<dialog>`: it renders in the top layer,\n * traps focus, makes the page inert, and returns focus to the opener on close.\n * Any element inside with `data-dialog=\"close\"` closes it.\n *\n * @summary Shows content in a modal window on top of the page.\n * @tag uf-dialog\n *\n * @slot - The dialog content.\n * @slot label - The title, when you need markup. Overrides `label`.\n * @slot header-actions - Extra buttons next to the close button.\n * @slot footer - Actions at the bottom, usually buttons.\n *\n * @event uf-show - The dialog opened.\n * @event uf-hide - The dialog closed.\n * @event {CustomEvent<DialogRequestCloseDetail>} uf-request-close - The user tried to close the dialog. Call `preventDefault()` to keep it open.\n *\n * @csspart dialog - The native `<dialog>`.\n * @csspart header - The header with title and close button.\n * @csspart title - The title.\n * @csspart close-button - The close button.\n * @csspart body - The content area.\n * @csspart footer - The footer.\n *\n * @cssprop --uf-dialog-bg - Background of the dialog.\n * @cssprop --uf-dialog-width - Width of the dialog. Defaults to `32rem`.\n * @cssprop --uf-dialog-padding - Padding of header, body and footer.\n * @cssprop --uf-dialog-radius - Corner radius.\n * @cssprop --uf-dialog-backdrop - Backdrop color.\n */\nexport class UfDialog extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n --_padding: var(--uf-dialog-padding, var(--uf-space-5));\n display: contents;\n }\n\n dialog {\n flex-direction: column;\n width: min(var(--uf-dialog-width, 32rem), calc(100vw - 2rem));\n max-height: calc(100dvh - 2rem);\n padding: 0;\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-dialog-radius, var(--uf-radius-lg));\n background: var(--uf-dialog-bg, var(--uf-color-surface-overlay));\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n box-shadow: var(--uf-shadow-lg);\n overflow: hidden;\n }\n\n dialog[open] {\n display: flex;\n }\n\n dialog::backdrop {\n background: var(--uf-dialog-backdrop, color-mix(in srgb, var(--uf-color-backdrop) 50%, transparent));\n }\n\n /*\n * Keyframe animations rather than transitions on display/overlay: the\n * component keeps the dialog open (modal, in the top layer) until the exit\n * animation ends, so it behaves the same in every browser.\n */\n dialog[open] {\n animation: uf-dialog-in var(--uf-duration-base) ease;\n }\n\n dialog[open]::backdrop {\n animation: uf-fade-in var(--uf-duration-base) ease;\n }\n\n dialog.closing {\n animation: uf-dialog-out var(--uf-duration-base) ease forwards;\n }\n\n dialog.closing::backdrop {\n animation: uf-fade-out var(--uf-duration-base) ease forwards;\n }\n\n @keyframes uf-dialog-in {\n from {\n opacity: 0;\n translate: 0 0.5rem;\n }\n }\n\n @keyframes uf-dialog-out {\n to {\n opacity: 0;\n translate: 0 0.5rem;\n }\n }\n\n @keyframes uf-fade-in {\n from {\n opacity: 0;\n }\n }\n\n @keyframes uf-fade-out {\n to {\n opacity: 0;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n dialog[open],\n dialog[open]::backdrop,\n dialog.closing,\n dialog.closing::backdrop {\n animation: none;\n }\n }\n\n .header {\n display: flex;\n align-items: center;\n gap: var(--uf-space-2);\n padding: var(--_padding) var(--_padding) 0;\n }\n\n .title {\n flex: 1;\n margin: 0;\n font-size: var(--uf-font-size-lg);\n font-weight: var(--uf-font-weight-semibold);\n line-height: 1.3;\n }\n\n .close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--uf-size-control-sm);\n height: var(--uf-size-control-sm);\n margin: calc(var(--uf-space-1) * -1) calc(var(--uf-space-2) * -1) calc(var(--uf-space-1) * -1) 0;\n padding: 0;\n border: 0;\n border-radius: var(--uf-radius-md);\n background: transparent;\n color: var(--uf-color-text-muted);\n cursor: pointer;\n }\n\n .close:hover {\n background: var(--uf-color-surface-hover);\n color: var(--uf-color-text);\n }\n\n .close:focus-visible {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: 0;\n }\n\n .close .icon {\n width: 1.125rem;\n height: 1.125rem;\n }\n\n .body {\n flex: 1;\n padding: var(--_padding);\n overflow: auto;\n line-height: 1.5;\n }\n\n .footer {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: var(--uf-space-2);\n padding: var(--uf-space-2) var(--_padding) var(--_padding);\n }\n\n [hidden] {\n display: none !important;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n open: { type: Boolean, reflect: true },\n label: {},\n lightDismiss: { type: Boolean, attribute: 'light-dismiss' },\n withoutHeader: { type: Boolean, attribute: 'without-header' },\n };\n\n /** Whether the dialog is open. */\n declare open: boolean;\n /** Title of the dialog, also its accessible name. */\n declare label: string | undefined;\n /** Closes the dialog when the backdrop is clicked. */\n declare lightDismiss: boolean;\n /** Hides the header. Set `label` anyway, so the dialog keeps an accessible name. */\n declare withoutHeader: boolean;\n\n readonly #slots = new HasSlotController(this, 'footer', 'label');\n readonly #id = uniqueId('uf-dialog');\n readonly #translator = new Translator(this);\n\n constructor() {\n super();\n this.open = false;\n this.lightDismiss = false;\n this.withoutHeader = false;\n this.addEventListener('click', this.#onHostClick);\n }\n\n get #dialog(): HTMLDialogElement | null {\n return this.renderRoot.querySelector('dialog');\n }\n\n /** Opens the dialog. */\n show(): void {\n this.open = true;\n }\n\n /** Closes the dialog, without firing `uf-request-close`. */\n hide(): void {\n this.open = false;\n }\n\n /** Asks to close, as a user action would. Listeners can cancel it. */\n requestClose(source: DialogCloseSource = 'trigger'): void {\n const event = new CustomEvent<DialogRequestCloseDetail>('uf-request-close', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: { source },\n });\n if (this.dispatchEvent(event)) this.open = false;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#dialog?.close();\n this.#setScrollLock(false);\n }\n\n /** Each dialog holds at most one scroll lock, however it was closed. */\n #setScrollLock(lock: boolean): void {\n if (lock === this.#scrollLocked) return;\n this.#scrollLocked = lock;\n lockScroll(lock);\n }\n\n #scrollLocked = false;\n\n override updated(changed: PropertyValues<this>): void {\n if (!changed.has('open')) return;\n const dialog = this.#dialog;\n if (!dialog) return;\n\n if (this.open) {\n // Reopened during the exit animation: just cancel the exit.\n if (dialog.classList.contains('closing')) {\n dialog.classList.remove('closing');\n return;\n }\n if (dialog.open) return;\n dialog.showModal();\n this.#setScrollLock(true);\n this.dispatchEvent(new Event('uf-show', { bubbles: true, composed: true }));\n } else if (dialog.open) {\n void this.#animateClose(dialog);\n }\n }\n\n /** Plays the exit animation while the dialog is still modal, then closes it. */\n async #animateClose(dialog: HTMLDialogElement): Promise<void> {\n dialog.classList.add('closing');\n const animations = document.hidden ? [] : dialog.getAnimations({ subtree: true });\n // Animations pause in background tabs; never let that keep the dialog open.\n const longest = Math.max(0, ...animations.map((a) => Number(a.effect?.getComputedTiming().endTime) || 0));\n await Promise.race([\n Promise.allSettled(animations.map((a) => a.finished)),\n new Promise((resolve) => setTimeout(resolve, longest + 50)),\n ]);\n if (this.open || !dialog.classList.contains('closing')) return;\n dialog.classList.remove('closing');\n dialog.close();\n this.#setScrollLock(false);\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n }\n\n #onCancel = (event: Event): void => {\n event.preventDefault();\n this.requestClose('escape');\n };\n\n /** Closed by something other than this component, e.g. `<form method=\"dialog\">`. */\n #onClose = (): void => {\n this.#setScrollLock(false);\n if (!this.open) return;\n this.open = false;\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n };\n\n #onDialogClick = (event: MouseEvent): void => {\n // The dialog has no padding, so a click whose target is the dialog itself hit the backdrop.\n if (this.lightDismiss && event.target === this.#dialog) this.requestClose('backdrop');\n };\n\n #onHostClick = (event: MouseEvent): void => {\n const closer = event.composedPath().find((el) => el instanceof Element && el.getAttribute('data-dialog') === 'close');\n if (closer && this.open) this.requestClose('trigger');\n };\n\n override render() {\n const titleId = `${this.#id}-title`;\n return html`\n <dialog\n part=\"dialog\"\n aria-labelledby=${titleId}\n @cancel=${this.#onCancel}\n @close=${this.#onClose}\n @click=${this.#onDialogClick}\n >\n <header class=\"header\" part=\"header\" ?hidden=${this.withoutHeader}>\n <h2 id=${titleId} class=\"title\" part=\"title\"><slot name=\"label\">${this.label}</slot></h2>\n <slot name=\"header-actions\"></slot>\n <button class=\"close\" part=\"close-button\" type=\"button\" aria-label=${this.#translator.t('close')} @click=${() => this.requestClose('close-button')}>\n ${iconSvg(icons.x)}\n </button>\n </header>\n <div class=\"body\" part=\"body\"><slot></slot></div>\n <footer class=\"footer\" part=\"footer\" ?hidden=${!this.#slots.has('footer')}>\n <slot name=\"footer\"></slot>\n </footer>\n </dialog>\n `;\n }\n}\n\ndefineElement('uf-dialog', UfDialog);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-dialog': UfDialog;\n }\n}\n",
554
+ "components/date-picker/date-picker.ts": "import { css, html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { formatShort, formatter, parseIso, parseTyped, shortPattern, toIso, todayIso } from '../../internal/dates.js';\nimport { defineElement } from '../../internal/define.js';\nimport { controlBoxStyles, describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { autoUpdate, positionFloating } from '../../internal/position.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\nimport '../calendar/calendar.js';\nimport type { UfCalendar } from '../calendar/calendar.js';\n\n/** A browser-translated \"Please fill out this field.\", from a native input that never joins the page. */\nlet requiredMessage: string | undefined;\nfunction valueMissingMessage(): string {\n if (requiredMessage === undefined) {\n const probe = document.createElement('input');\n probe.required = true;\n requiredMessage = probe.validationMessage;\n }\n return requiredMessage;\n}\n\n/**\n * A date field: type a date in the page language's format, or pick one from a\n * calendar. The value is always `YYYY-MM-DD`, like `<input type=\"date\">`, so\n * it's the same in every language and submits with the form.\n *\n * Alt + Down Arrow opens the calendar; Escape closes it.\n *\n * @summary Lets users type or pick a date.\n * @tag uf-date-picker\n *\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the field. Overrides `hint`.\n *\n * @event input - The value changed (a date was typed and committed, or picked).\n * @event change - The value changed (a date was typed and committed, or picked).\n * @event uf-show - The calendar opened.\n * @event uf-hide - The calendar closed.\n *\n * @csspart field - The wrapper around label, control, hint and error.\n * @csspart form-label - The label.\n * @csspart box - The bordered box around the input.\n * @csspart input - The text input.\n * @csspart toggle - The calendar button.\n * @csspart popup - The floating panel around the calendar.\n * @csspart calendar - The `<uf-calendar>`.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-field-bg - Background of the box.\n * @cssprop --uf-field-border-color - Border color of the box.\n * @cssprop --uf-field-radius - Corner radius of the box.\n *\n * @cssstate user-invalid - The value is invalid and the user has interacted with the field.\n */\nexport class UfDatePicker extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n controlBoxStyles,\n css`\n .box {\n padding-inline-end: 0;\n }\n\n .toggle {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n align-self: stretch;\n width: calc(var(--_height) - 2px);\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--uf-color-text-muted);\n cursor: pointer;\n }\n\n .toggle:hover:not(:disabled),\n .toggle.open {\n color: var(--uf-color-accent-strong);\n }\n\n .toggle:focus-visible {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: -2px;\n }\n\n .toggle:disabled {\n cursor: not-allowed;\n }\n\n .toggle .icon {\n width: 1.125em;\n height: 1.125em;\n }\n\n .popup {\n position: fixed;\n inset: auto;\n margin: 0;\n padding: var(--uf-space-3);\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-radius-md);\n background: var(--uf-color-surface-overlay);\n color: var(--uf-color-text);\n box-shadow: var(--uf-shadow-overlay);\n }\n `,\n ];\n\n protected static override formStateProperties: ReadonlySet<PropertyKey> = new Set([\n ...FormControl.formStateProperties,\n 'min',\n 'max',\n 'isDateDisabled',\n ]);\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n placeholder: {},\n size: { reflect: true },\n min: {},\n max: {},\n readonly: { type: Boolean, reflect: true },\n open: { type: Boolean, reflect: true },\n isDateDisabled: { attribute: false },\n };\n\n /** The date, as `YYYY-MM-DD`, or an empty string. */\n declare value: string;\n /** Initial date, restored on form reset. Set with the `value` attribute, as `YYYY-MM-DD`. */\n declare defaultValue: string;\n /** The field's label, also its accessible name. */\n declare label: string | undefined;\n /** Help text below the field. */\n declare hint: string | undefined;\n /** Shown when empty. Defaults to the date format, e.g. dd/mm/yyyy. */\n declare placeholder: string | undefined;\n /** Size: `sm`, `md` or `lg`. */\n declare size: FieldSize;\n /** The earliest allowed date, as `YYYY-MM-DD`. */\n declare min: string | undefined;\n /** The latest allowed date, as `YYYY-MM-DD`. */\n declare max: string | undefined;\n /** Lets the user select the text but not change the date. */\n declare readonly: boolean;\n /** Whether the calendar is open. */\n declare open: boolean;\n /** Rules out dates, e.g. weekends: called with each date as `YYYY-MM-DD`, returns true to disable it. */\n declare isDateDisabled: ((date: string) => boolean) | undefined;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-date-picker');\n /** What the user typed and hasn't committed yet; null shows the value, formatted. */\n #text: string | null = null;\n /** The committed text isn't a date. */\n #badInput = false;\n #cleanup?: () => void;\n /** Focus was in the calendar when it closed: give it back to the input. */\n #focusWasInside = false;\n /** Between beforetoggle and toggle. */\n #toggling = false;\n\n constructor() {\n super();\n this.value = '';\n this.defaultValue = '';\n this.size = 'md';\n this.readonly = false;\n this.open = false;\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n get #popup(): HTMLElement | null {\n return this.renderRoot.querySelector('.popup');\n }\n\n get #calendar(): UfCalendar | null {\n return this.renderRoot.querySelector('uf-calendar');\n }\n\n /** Opens the calendar. */\n show(): void {\n if (!this.isDisabled && !this.readonly) this.open = true;\n }\n\n /** Closes the calendar. */\n hide(): void {\n this.open = false;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#cleanup?.();\n this.#cleanup = undefined;\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('defaultValue') && this.value === (changed.get('defaultValue') ?? '')) {\n this.value = parseIso(this.defaultValue) ? this.defaultValue : '';\n }\n // A value set from code replaces what was typed.\n if (changed.has('value')) {\n this.#text = null;\n this.#badInput = false;\n }\n }\n\n override updated(changed: PropertyValues<this>): void {\n this.syncFormState();\n if (changed.has('open')) this.#syncPopup();\n }\n\n #syncPopup(): void {\n const popup = this.#popup;\n // The browser is opening or closing it already (button, Escape, click outside).\n if (!popup || this.#toggling) return;\n if (this.open && !popup.matches(':popover-open')) {\n popup.showPopover();\n // Positioned in the same task, so it never paints at its default spot.\n this.#startPositioning();\n } else if (!this.open && popup.matches(':popover-open')) {\n popup.hidePopover();\n }\n }\n\n /** Places the popup under the field, and keeps it there on scroll and resize. */\n #startPositioning(): void {\n const popup = this.#popup;\n const box = this.renderRoot.querySelector<HTMLElement>('.box');\n if (!popup || !box || !popup.matches(':popover-open')) return;\n this.#cleanup ??= autoUpdate(box, popup, () => positionFloating(box, popup, 'bottom-start', 4));\n }\n\n /**\n * The popup opened or closed, however it happened: the button (linked with\n * popovertarget, so a click while open closes it instead of reopening),\n * Escape, a click outside, or \\`open\\`.\n */\n #onBeforeToggle = (event: ToggleEvent): void => {\n // Synchronous, so \\`open\\` is right as soon as the popup opens or closes.\n // Lit may render before the browser finishes: #toggling keeps #syncPopup\n // from calling showPopover/hidePopover in the middle, which would cancel\n // the toggle event.\n this.#toggling = true;\n this.open = event.newState === 'open';\n // Opened by the button: the browser shows it after this event, and the\n // toggle event comes a task later, after a paint. An animation frame runs\n // after it's shown and before that paint, so position it there.\n if (event.newState === 'open') requestAnimationFrame(() => this.#startPositioning());\n // Before it hides: afterwards the browser has already moved focus away.\n if (event.newState === 'closed') this.#focusWasInside = Boolean(this.shadowRoot?.activeElement?.closest('.popup'));\n };\n\n #onToggle = (event: ToggleEvent): void => {\n this.#toggling = false;\n if (event.newState === 'open') {\n this.#startPositioning();\n this.#calendar?.updateComplete.then(() => this.#calendar?.focus());\n this.dispatchEvent(new Event('uf-show', { bubbles: true, composed: true }));\n } else {\n this.#cleanup?.();\n this.#cleanup = undefined;\n if (this.#focusWasInside) this.#input?.focus();\n this.#focusWasInside = false;\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n }\n };\n\n protected syncFormState(): void {\n const input = this.#input;\n if (!input) return;\n this.internals.setFormValue(this.value);\n const t = this.translator;\n const lang = t.lang;\n const date = parseIso(this.value);\n const min = parseIso(this.min);\n const max = parseIso(this.max);\n const long = (d: Date) => formatter(lang, { day: 'numeric', month: 'long', year: 'numeric' }).format(d);\n\n if (this.#badInput) {\n this.setValidity({ badInput: true }, t.t('invalidDate', { example: formatShort(parseIso(todayIso())!, lang) }), input);\n } else if (this.required && !date) {\n this.setValidity({ valueMissing: true }, valueMissingMessage(), input);\n } else if (date && min && date < min) {\n this.setValidity({ rangeUnderflow: true }, t.t('dateTooEarly', { date: long(min) }), input);\n } else if (date && max && date > max) {\n this.setValidity({ rangeOverflow: true }, t.t('dateTooLate', { date: long(max) }), input);\n } else if (date && this.isDateDisabled?.(this.value)) {\n this.setValidity({ badInput: true }, t.t('dateUnavailable'), input);\n } else {\n this.setValidity({}, '', input);\n }\n }\n\n protected resetValue(): void {\n this.value = parseIso(this.defaultValue) ? this.defaultValue : '';\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = parseIso(state) ? state! : '';\n }\n\n /** Sets the value from the user, and tells listeners when it changed. */\n #commit(value: string): void {\n const changed = value !== this.value;\n this.value = value;\n this.markInteracted();\n if (changed) {\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n this.emitChange();\n }\n }\n\n /** Turns the typed text into the value: a date, empty, or invalid. */\n #commitText(): void {\n if (this.#text === null) return;\n const text = this.#text.trim();\n const date = text ? parseTyped(text, this.translator.lang) : null;\n if (!text || date) {\n this.#commit(date ? toIso(date) : '');\n this.#text = null;\n this.#badInput = false;\n } else {\n // Not a date: keep the text so the user can fix it, and report it.\n this.#commit('');\n this.#text = text;\n this.#badInput = true;\n }\n this.syncFormState();\n this.requestUpdate();\n }\n\n #onInput = (event: Event): void => {\n // The value changes when the date is committed, not on every keystroke.\n event.stopPropagation();\n this.#text = (event.target as HTMLInputElement).value;\n };\n\n #onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Enter') this.#commitText();\n else if (event.key === 'ArrowDown' && event.altKey) {\n event.preventDefault();\n this.show();\n }\n };\n\n #onCalendarChange = (event: Event): void => {\n event.stopPropagation();\n this.#commit((event.target as UfCalendar).value);\n this.hide();\n this.#input?.focus();\n };\n\n #placeholder(): string {\n if (this.placeholder !== undefined) return this.placeholder;\n const { order, separator } = shortPattern(this.translator.lang);\n const letters = { day: this.translator.t('dayPlaceholder'), month: this.translator.t('monthPlaceholder'), year: this.translator.t('yearPlaceholder') };\n return order.map((part) => letters[part]).join(separator);\n }\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const popupId = `${this.#id}-popup`;\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n const date = parseIso(this.value);\n const text = this.#text ?? (date ? formatShort(date, this.translator.lang) : '');\n\n return renderField({\n ...ids,\n controlId: this.#id,\n label: this.label,\n hasLabelSlot: this.#slots.has('label'),\n hint: this.hint,\n hasHintSlot,\n error,\n required: this.required,\n control: html`\n <div class=${classMap({ box: true, disabled: this.isDisabled })} part=\"box\">\n <input\n id=${this.#id}\n class=\"native\"\n part=\"input\"\n type=\"text\"\n autocomplete=\"off\"\n .value=${live(text)}\n placeholder=${this.#placeholder()}\n ?readonly=${this.readonly}\n ?disabled=${this.isDisabled}\n aria-required=${this.required ? 'true' : 'false'}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @input=${this.#onInput}\n @change=${() => this.#commitText()}\n @keydown=${this.#onKeyDown}\n />\n <button\n class=${classMap({ toggle: true, open: this.open })}\n part=\"toggle\"\n type=\"button\"\n aria-label=${this.translator.t('chooseDate')}\n aria-haspopup=\"dialog\"\n aria-expanded=${this.open ? 'true' : 'false'}\n popovertarget=${popupId}\n ?disabled=${this.isDisabled || this.readonly}\n >\n ${iconSvg(icons.calendar)}\n </button>\n </div>\n <div\n id=${popupId}\n class=\"popup\"\n part=\"popup\"\n popover=\"auto\"\n role=\"dialog\"\n aria-label=${this.label ?? this.translator.t('chooseDate')}\n @beforetoggle=${this.#onBeforeToggle}\n @toggle=${this.#onToggle}\n >\n <uf-calendar\n part=\"calendar\"\n .value=${this.value}\n .min=${this.min}\n .max=${this.max}\n .isDateDisabled=${this.isDateDisabled}\n @change=${this.#onCalendarChange}\n ></uf-calendar>\n </div>\n `,\n });\n }\n}\n\ndefineElement('uf-date-picker', UfDatePicker);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-date-picker': UfDatePicker;\n }\n}\n",
555
+ "components/dialog/dialog.ts": "import { LitElement, css, html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { Translator } from '../../internal/i18n.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\nexport type DialogCloseSource = 'close-button' | 'escape' | 'backdrop' | 'trigger' | 'method';\n\nexport interface DialogRequestCloseDetail {\n source: DialogCloseSource;\n}\n\nlet scrollLocks = 0;\nlet savedStyles: { overflow: string; paddingRight: string } | undefined;\n\n/**\n * Locks page scroll while any dialog is open. Hiding overflow removes a classic\n * (non-overlay) scrollbar, so the page is padded by its width to avoid a shift.\n * (`scrollbar-gutter: stable` isn't honoured on the root once overflow is hidden.)\n * The width is exposed as `--uf-scrollbar-width` for fixed elements to compensate.\n */\nfunction lockScroll(lock: boolean): void {\n const html = document.documentElement;\n const wasLocked = scrollLocks > 0;\n scrollLocks = Math.max(0, scrollLocks + (lock ? 1 : -1));\n\n if (scrollLocks > 0 && !wasLocked) {\n const scrollbarWidth = window.innerWidth - html.clientWidth;\n savedStyles = { overflow: html.style.overflow, paddingRight: html.style.paddingRight };\n if (scrollbarWidth > 0) {\n const padding = parseFloat(getComputedStyle(html).paddingRight) || 0;\n html.style.paddingRight = `${padding + scrollbarWidth}px`;\n html.style.setProperty('--uf-scrollbar-width', `${scrollbarWidth}px`);\n }\n html.style.overflow = 'hidden';\n } else if (scrollLocks === 0 && wasLocked && savedStyles) {\n html.style.overflow = savedStyles.overflow;\n html.style.paddingRight = savedStyles.paddingRight;\n html.style.removeProperty('--uf-scrollbar-width');\n savedStyles = undefined;\n }\n}\n\n/**\n * A modal dialog built on the native `<dialog>`: it renders in the top layer,\n * traps focus, makes the page inert, and returns focus to the opener on close.\n * Any element inside with `data-dialog=\"close\"` closes it.\n *\n * @summary Shows content in a modal window on top of the page.\n * @tag uf-dialog\n *\n * @slot - The dialog content.\n * @slot label - The title, when you need markup. Overrides `label`.\n * @slot header-actions - Extra buttons next to the close button.\n * @slot footer - Actions at the bottom, usually buttons.\n *\n * @event uf-show - The dialog opened.\n * @event uf-hide - The dialog closed.\n * @event {CustomEvent<DialogRequestCloseDetail>} uf-request-close - The user tried to close the dialog. Call `preventDefault()` to keep it open.\n *\n * @csspart dialog - The native `<dialog>`.\n * @csspart header - The header with title and close button.\n * @csspart title - The title.\n * @csspart close-button - The close button.\n * @csspart body - The content area.\n * @csspart footer - The footer.\n *\n * @cssprop --uf-dialog-bg - Background of the dialog.\n * @cssprop --uf-dialog-width - Width of the dialog. Defaults to `32rem`.\n * @cssprop --uf-dialog-padding - Padding of header, body and footer.\n * @cssprop --uf-dialog-radius - Corner radius.\n * @cssprop --uf-dialog-backdrop - Backdrop color.\n */\nexport class UfDialog extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n --_padding: var(--uf-dialog-padding, var(--uf-space-5));\n display: contents;\n }\n\n dialog {\n flex-direction: column;\n width: min(var(--uf-dialog-width, 32rem), calc(100vw - 2rem));\n max-height: calc(100dvh - 2rem);\n padding: 0;\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-dialog-radius, var(--uf-radius-lg));\n background: var(--uf-dialog-bg, var(--uf-color-surface-overlay));\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n box-shadow: var(--uf-shadow-modal);\n overflow: hidden;\n }\n\n dialog[open] {\n display: flex;\n }\n\n dialog::backdrop {\n background: var(--uf-dialog-backdrop, color-mix(in srgb, var(--uf-color-backdrop) 50%, transparent));\n }\n\n /*\n * Keyframe animations rather than transitions on display/overlay: the\n * component keeps the dialog open (modal, in the top layer) until the exit\n * animation ends, so it behaves the same in every browser.\n */\n dialog[open] {\n animation: uf-dialog-in var(--uf-duration-base) ease;\n }\n\n dialog[open]::backdrop {\n animation: uf-fade-in var(--uf-duration-base) ease;\n }\n\n dialog.closing {\n animation: uf-dialog-out var(--uf-duration-base) ease forwards;\n }\n\n dialog.closing::backdrop {\n animation: uf-fade-out var(--uf-duration-base) ease forwards;\n }\n\n @keyframes uf-dialog-in {\n from {\n opacity: 0;\n translate: 0 0.5rem;\n }\n }\n\n @keyframes uf-dialog-out {\n to {\n opacity: 0;\n translate: 0 0.5rem;\n }\n }\n\n @keyframes uf-fade-in {\n from {\n opacity: 0;\n }\n }\n\n @keyframes uf-fade-out {\n to {\n opacity: 0;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n dialog[open],\n dialog[open]::backdrop,\n dialog.closing,\n dialog.closing::backdrop {\n animation: none;\n }\n }\n\n .header {\n display: flex;\n align-items: center;\n gap: var(--uf-space-2);\n padding: var(--_padding) var(--_padding) 0;\n }\n\n .title {\n flex: 1;\n margin: 0;\n font-size: var(--uf-font-size-lg);\n font-weight: var(--uf-font-weight-semibold);\n line-height: 1.3;\n }\n\n .close {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--uf-size-control-sm);\n height: var(--uf-size-control-sm);\n margin: calc(var(--uf-space-1) * -1) calc(var(--uf-space-2) * -1) calc(var(--uf-space-1) * -1) 0;\n padding: 0;\n border: 0;\n border-radius: var(--uf-radius-md);\n background: transparent;\n color: var(--uf-color-text-muted);\n cursor: pointer;\n }\n\n .close:hover {\n background: var(--uf-color-surface-hover);\n color: var(--uf-color-text);\n }\n\n .close:focus-visible {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: 0;\n }\n\n .close .icon {\n width: 1.125rem;\n height: 1.125rem;\n }\n\n .body {\n flex: 1;\n padding: var(--_padding);\n overflow: auto;\n line-height: 1.5;\n }\n\n .footer {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n gap: var(--uf-space-2);\n padding: var(--uf-space-2) var(--_padding) var(--_padding);\n }\n\n [hidden] {\n display: none !important;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n open: { type: Boolean, reflect: true },\n label: {},\n lightDismiss: { type: Boolean, attribute: 'light-dismiss' },\n withoutHeader: { type: Boolean, attribute: 'without-header' },\n };\n\n /** Whether the dialog is open. */\n declare open: boolean;\n /** Title of the dialog, also its accessible name. */\n declare label: string | undefined;\n /** Closes the dialog when the backdrop is clicked. */\n declare lightDismiss: boolean;\n /** Hides the header. Set `label` anyway, so the dialog keeps an accessible name. */\n declare withoutHeader: boolean;\n\n readonly #slots = new HasSlotController(this, 'footer', 'label');\n readonly #id = uniqueId('uf-dialog');\n readonly #translator = new Translator(this);\n\n constructor() {\n super();\n this.open = false;\n this.lightDismiss = false;\n this.withoutHeader = false;\n this.addEventListener('click', this.#onHostClick);\n }\n\n get #dialog(): HTMLDialogElement | null {\n return this.renderRoot.querySelector('dialog');\n }\n\n /** Opens the dialog. */\n show(): void {\n this.open = true;\n }\n\n /** Closes the dialog, without firing `uf-request-close`. */\n hide(): void {\n this.open = false;\n }\n\n /** Asks to close, as a user action would. Listeners can cancel it. */\n requestClose(source: DialogCloseSource = 'trigger'): void {\n const event = new CustomEvent<DialogRequestCloseDetail>('uf-request-close', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: { source },\n });\n if (this.dispatchEvent(event)) this.open = false;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#dialog?.close();\n this.#setScrollLock(false);\n }\n\n /** Each dialog holds at most one scroll lock, however it was closed. */\n #setScrollLock(lock: boolean): void {\n if (lock === this.#scrollLocked) return;\n this.#scrollLocked = lock;\n lockScroll(lock);\n }\n\n #scrollLocked = false;\n\n override updated(changed: PropertyValues<this>): void {\n if (!changed.has('open')) return;\n const dialog = this.#dialog;\n if (!dialog) return;\n\n if (this.open) {\n // Reopened during the exit animation: just cancel the exit.\n if (dialog.classList.contains('closing')) {\n dialog.classList.remove('closing');\n return;\n }\n if (dialog.open) return;\n dialog.showModal();\n this.#setScrollLock(true);\n this.dispatchEvent(new Event('uf-show', { bubbles: true, composed: true }));\n } else if (dialog.open) {\n void this.#animateClose(dialog);\n }\n }\n\n /** Plays the exit animation while the dialog is still modal, then closes it. */\n async #animateClose(dialog: HTMLDialogElement): Promise<void> {\n dialog.classList.add('closing');\n const animations = document.hidden ? [] : dialog.getAnimations({ subtree: true });\n // Animations pause in background tabs; never let that keep the dialog open.\n const longest = Math.max(0, ...animations.map((a) => Number(a.effect?.getComputedTiming().endTime) || 0));\n await Promise.race([\n Promise.allSettled(animations.map((a) => a.finished)),\n new Promise((resolve) => setTimeout(resolve, longest + 50)),\n ]);\n if (this.open || !dialog.classList.contains('closing')) return;\n dialog.classList.remove('closing');\n dialog.close();\n this.#setScrollLock(false);\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n }\n\n #onCancel = (event: Event): void => {\n event.preventDefault();\n this.requestClose('escape');\n };\n\n /** Closed by something other than this component, e.g. `<form method=\"dialog\">`. */\n #onClose = (): void => {\n this.#setScrollLock(false);\n if (!this.open) return;\n this.open = false;\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n };\n\n #onDialogClick = (event: MouseEvent): void => {\n // The dialog has no padding, so a click whose target is the dialog itself hit the backdrop.\n if (this.lightDismiss && event.target === this.#dialog) this.requestClose('backdrop');\n };\n\n #onHostClick = (event: MouseEvent): void => {\n const closer = event.composedPath().find((el) => el instanceof Element && el.getAttribute('data-dialog') === 'close');\n if (closer && this.open) this.requestClose('trigger');\n };\n\n override render() {\n const titleId = `${this.#id}-title`;\n return html`\n <dialog\n part=\"dialog\"\n aria-labelledby=${titleId}\n @cancel=${this.#onCancel}\n @close=${this.#onClose}\n @click=${this.#onDialogClick}\n >\n <header class=\"header\" part=\"header\" ?hidden=${this.withoutHeader}>\n <h2 id=${titleId} class=\"title\" part=\"title\"><slot name=\"label\">${this.label}</slot></h2>\n <slot name=\"header-actions\"></slot>\n <button class=\"close\" part=\"close-button\" type=\"button\" aria-label=${this.#translator.t('close')} @click=${() => this.requestClose('close-button')}>\n ${iconSvg(icons.x)}\n </button>\n </header>\n <div class=\"body\" part=\"body\"><slot></slot></div>\n <footer class=\"footer\" part=\"footer\" ?hidden=${!this.#slots.has('footer')}>\n <slot name=\"footer\"></slot>\n </footer>\n </dialog>\n `;\n }\n}\n\ndefineElement('uf-dialog', UfDialog);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-dialog': UfDialog;\n }\n}\n",
556
556
  "components/dropdown/dropdown.ts": "import { css } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { UfPopover } from '../popover/popover.js';\nimport '../menu/menu.js';\nimport type { MenuSelectDetail, UfMenu } from '../menu/menu.js';\n\nexport { UfMenu, UfMenuItem } from '../menu/menu.js';\nexport type { MenuSelectDetail } from '../menu/menu.js';\n\n/**\n * A button that opens a `<uf-menu>`, following the WAI-ARIA menu button\n * pattern: Enter, Space or Down open it on the first item, Up on the last;\n * choosing an item or pressing Escape closes it and returns focus to the button.\n *\n * @summary Opens a menu of actions from a button.\n * @tag uf-dropdown\n *\n * @slot trigger - The button that opens the menu.\n * @slot - A `<uf-menu>`.\n *\n * @event {CustomEvent<MenuSelectDetail>} uf-select - An item was chosen (bubbles up from the menu).\n * @event uf-show - The menu opened.\n * @event uf-hide - The menu closed.\n *\n * @csspart panel - The floating panel around the menu.\n */\nexport class UfDropdown extends UfPopover {\n static override styles = [\n UfPopover.styles,\n css`\n .panel {\n --uf-popover-padding: var(--uf-space-1) 0;\n }\n `,\n ];\n\n #focusLastOnOpen = false;\n\n constructor() {\n super();\n this.addEventListener('uf-select', this.#onSelect as EventListener);\n this.addEventListener('keydown', this.#onKeyDown);\n }\n\n protected override get popupKind(): 'menu' {\n return 'menu';\n }\n\n get #menu(): UfMenu | null {\n return this.querySelector('uf-menu');\n }\n\n protected override afterShow(): void {\n const menu = this.#menu;\n if (this.#focusLastOnOpen) menu?.focusLast();\n else menu?.focusFirst();\n this.#focusLastOnOpen = false;\n }\n\n protected override onTriggerKeyDown(event: KeyboardEvent): void {\n if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;\n event.preventDefault();\n this.#focusLastOnOpen = event.key === 'ArrowUp';\n if (this.open) this.afterShow();\n else this.show();\n }\n\n #onSelect = (event: CustomEvent<MenuSelectDetail>): void => {\n // Checkbox items stay open so several can be toggled; cancel the event to keep any item open.\n if (event.defaultPrevented || event.detail.item.type === 'checkbox') return;\n this.hide();\n this.trigger?.focus();\n };\n\n #onKeyDown = (event: KeyboardEvent): void => {\n // Tab leaves the menu: close it and let focus move on.\n if (event.key === 'Tab' && this.open && this.focusInPanel) this.hide();\n };\n}\n\ndefineElement('uf-dropdown', UfDropdown);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-dropdown': UfDropdown;\n }\n}\n",
557
557
  "components/icon/icon.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js';\nimport { defineElement } from '../../internal/define.js';\nimport { iconSvg, icons, type BuiltInIconName } from '../../internal/icons.js';\n\nconst registry = new Map<string, string>();\nconst instances = new Set<UfIcon>();\n\n/**\n * Registers custom icons by name, as SVG markup. The markup is trusted and\n * inserted as-is, so only register icons from your own code, never user input.\n *\n * @example registerIcons({ heart: '<svg viewBox=\"0 0 24 24\">…</svg>' })\n */\nexport function registerIcons(svgs: Record<string, string>): void {\n for (const [name, markup] of Object.entries(svgs)) registry.set(name, markup);\n for (const icon of instances) icon.requestUpdate();\n}\n\n/**\n * An icon from the built-in set, or one added with `registerIcons()`.\n * Icons are decorative unless you give them a `label`.\n *\n * @summary Shows a small symbol.\n * @tag uf-icon\n *\n * @csspart svg - The `<svg>` element.\n *\n * @cssprop --uf-icon-size - Width and height. Defaults to `1em`, so it follows the font size.\n * @cssprop --uf-icon-stroke-width - Stroke width of built-in icons.\n */\nexport class UfIcon extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n width: var(--uf-icon-size, 1em);\n height: var(--uf-icon-size, 1em);\n flex: none;\n vertical-align: -0.125em;\n }\n\n svg {\n width: 100%;\n height: 100%;\n stroke-width: var(--uf-icon-stroke-width, 2);\n }\n `;\n\n static override properties: PropertyDeclarations = {\n name: { reflect: true },\n label: {},\n };\n\n /** Icon name: a built-in icon or one added with `registerIcons()`. */\n declare name: BuiltInIconName | (string & {});\n /** Accessible label. Without it the icon is hidden from assistive tech. */\n declare label: string | undefined;\n\n constructor() {\n super();\n this.name = '';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n instances.add(this);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n instances.delete(this);\n }\n\n override updated(): void {\n if (this.label) {\n this.setAttribute('role', 'img');\n this.setAttribute('aria-label', this.label);\n this.removeAttribute('aria-hidden');\n } else {\n this.removeAttribute('role');\n this.removeAttribute('aria-label');\n this.setAttribute('aria-hidden', 'true');\n }\n }\n\n override render() {\n const custom = registry.get(this.name);\n if (custom) return html`${unsafeSVG(custom)}`;\n const builtIn = icons[this.name as BuiltInIconName];\n return builtIn ? iconSvg(builtIn, 'svg') : nothing;\n }\n}\n\ndefineElement('uf-icon', UfIcon);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-icon': UfIcon;\n }\n}\n",
558
558
  "components/input/input.ts": "import { html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { controlBoxStyles, describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\nexport type { FieldSize };\n\nexport type InputType = 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'number' | 'date' | 'time';\n\n/**\n * A single-line text field with a built-in label, hint and validation message.\n *\n * @summary Lets users enter a single line of text.\n * @tag uf-input\n *\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the field. Overrides `hint`.\n * @slot prefix - An icon or text before the input.\n * @slot suffix - An icon or text after the input.\n *\n * @event input - Fired on every keystroke.\n * @event change - Fired when the value is committed (blur or Enter).\n *\n * @csspart field - The wrapper around label, control, hint and error.\n * @csspart form-label - The label.\n * @csspart box - The bordered box around the input.\n * @csspart input - The native `<input>`.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-field-bg - Background of the box.\n * @cssprop --uf-field-border-color - Border color of the box.\n * @cssprop --uf-field-radius - Corner radius of the box.\n *\n * @cssstate user-invalid - The value is invalid and the user has interacted with the field.\n */\nexport class UfInput extends FormControl {\n static override styles = [hostStyles, fieldStyles, controlBoxStyles];\n\n protected static override formStateProperties: ReadonlySet<PropertyKey> = new Set([\n ...FormControl.formStateProperties,\n 'type',\n 'readonly',\n 'pattern',\n 'min',\n 'max',\n 'step',\n 'minlength',\n 'maxlength',\n ]);\n\n static override properties: PropertyDeclarations = {\n type: { reflect: true },\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n placeholder: {},\n size: { reflect: true },\n readonly: { type: Boolean, reflect: true },\n autocomplete: {},\n inputmode: {},\n pattern: {},\n min: {},\n max: {},\n step: {},\n minlength: { type: Number },\n maxlength: { type: Number },\n };\n\n /** Input type. */\n declare type: InputType;\n /** Current value. */\n declare value: string;\n /** Initial value, restored on form reset. Set with the `value` attribute. */\n declare defaultValue: string;\n /** Visible label. */\n declare label: string | undefined;\n /** Help text below the field. */\n declare hint: string | undefined;\n /** Placeholder text. */\n declare placeholder: string | undefined;\n /** Size of the field. */\n declare size: FieldSize;\n /** Makes the field read-only. */\n declare readonly: boolean;\n /** Native `autocomplete` hint. */\n declare autocomplete: AutoFill | undefined;\n /** Native `inputmode` hint for virtual keyboards. */\n declare inputmode: string | undefined;\n /** Regex the value must match. */\n declare pattern: string | undefined;\n /** Minimum value, for number and date types. */\n declare min: string | undefined;\n /** Maximum value, for number and date types. */\n declare max: string | undefined;\n /** Step, for number and date types. */\n declare step: string | undefined;\n /** Minimum length. */\n declare minlength: number | undefined;\n /** Maximum length. */\n declare maxlength: number | undefined;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-input');\n\n constructor() {\n super();\n this.type = 'text';\n this.value = '';\n this.defaultValue = '';\n this.size = 'md';\n this.readonly = false;\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n /** Selects all text in the field. */\n select(): void {\n this.#input?.select();\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n // Like a native input: the value follows the `value` attribute until it is edited.\n if (changed.has('defaultValue') && this.value === (changed.get('defaultValue') ?? '')) {\n this.value = this.defaultValue ?? '';\n }\n }\n\n override updated(): void {\n this.syncFormState();\n }\n\n protected syncFormState(): void {\n const input = this.#input;\n if (!input) return;\n this.internals.setFormValue(this.value);\n this.setValidityFrom(input);\n }\n\n protected resetValue(): void {\n this.value = this.defaultValue ?? '';\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = state ?? '';\n }\n\n #onInput = (event: Event): void => {\n this.value = (event.target as HTMLInputElement).value;\n };\n\n #onChange = (): void => {\n this.markInteracted();\n this.emitChange();\n };\n\n override render() {\n const ids = {\n hintId: `${this.#id}-hint`,\n errorId: `${this.#id}-error`,\n };\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n\n return renderField({\n ...ids,\n controlId: this.#id,\n label: this.label,\n hasLabelSlot: this.#slots.has('label'),\n hint: this.hint,\n hasHintSlot,\n error,\n required: this.required,\n control: html`\n <div class=${classMap({ box: true, disabled: this.isDisabled })} part=\"box\">\n <slot name=\"prefix\"></slot>\n <input\n id=${this.#id}\n class=\"native\"\n part=\"input\"\n type=${this.type}\n name=${ifDefined(this.name || undefined)}\n .value=${live(this.value)}\n placeholder=${ifDefined(this.placeholder)}\n autocomplete=${ifDefined(this.autocomplete)}\n inputmode=${ifDefined(this.inputmode)}\n pattern=${ifDefined(this.pattern)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n ?required=${this.required}\n ?readonly=${this.readonly}\n ?disabled=${this.isDisabled}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @input=${this.#onInput}\n @change=${this.#onChange}\n />\n <slot name=\"suffix\"></slot>\n </div>\n `,\n });\n }\n}\n\ndefineElement('uf-input', UfInput);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-input': UfInput;\n }\n}\n",
559
559
  "components/menu/menu.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport './menu-item.js';\nimport type { UfMenuItem } from './menu-item.js';\n\nexport { UfMenuItem } from './menu-item.js';\n\nexport interface MenuSelectDetail {\n item: UfMenuItem;\n value: string;\n}\n\n/**\n * A list of actions with full keyboard support: arrow keys, Home and End,\n * and typing a letter jumps to the next item starting with it. Use `<hr>`\n * between items for a separator. Usually placed inside `<uf-dropdown>`.\n *\n * @summary A list of actions or options.\n * @tag uf-menu\n *\n * @slot - `<uf-menu-item>` elements and `<hr>` separators.\n *\n * @event {CustomEvent<MenuSelectDetail>} uf-select - An item was chosen. Cancel it to keep a dropdown open.\n */\nexport class UfMenu extends LitElement {\n static override styles = css`\n :host {\n display: block;\n min-width: 10rem;\n outline: none;\n }\n\n ::slotted(hr) {\n height: 1px;\n margin: var(--uf-space-1) 0;\n border: 0;\n background: var(--uf-color-border);\n }\n `;\n\n static override properties: PropertyDeclarations = {\n label: {},\n };\n\n /** Accessible name of the menu. */\n declare label: string | undefined;\n\n #typeahead = '';\n #typeaheadTimer = 0;\n\n constructor() {\n super();\n this.addEventListener('click', this.#onClick);\n this.addEventListener('keydown', this.#onKeyDown);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.setAttribute('role', 'menu');\n }\n\n override updated(): void {\n if (this.label) this.setAttribute('aria-label', this.label);\n else this.removeAttribute('aria-label');\n this.#alignItems();\n }\n\n /** Reserves the check column on every item when any item is a checkbox. */\n #alignItems(): void {\n const items = [...this.querySelectorAll('uf-menu-item')].filter((i) => i.closest('uf-menu') === this);\n const hasCheckbox = items.some((i) => i.type === 'checkbox');\n for (const item of items) item.toggleAttribute('data-check-space', hasCheckbox);\n }\n\n /** Enabled items that belong to this menu (not to a nested one). */\n get items(): UfMenuItem[] {\n return [...this.querySelectorAll<UfMenuItem>('uf-menu-item')].filter(\n (item) => item.closest('uf-menu') === this && !item.disabled,\n );\n }\n\n /** Focuses the first enabled item. */\n focusFirst(): void {\n this.#focusItem(this.items[0]);\n }\n\n /** Focuses the last enabled item. */\n focusLast(): void {\n const items = this.items;\n this.#focusItem(items[items.length - 1]);\n }\n\n #focusItem(item: UfMenuItem | undefined): void {\n if (!item) return;\n for (const other of this.items) other.tabIndex = other === item ? 0 : -1;\n item.focus();\n }\n\n #activate(item: UfMenuItem): void {\n if (item.disabled) return;\n if (item.type === 'checkbox') item.checked = !item.checked;\n this.dispatchEvent(\n new CustomEvent<MenuSelectDetail>('uf-select', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: { item, value: item.value },\n }),\n );\n }\n\n #onClick = (event: MouseEvent): void => {\n const item = (event.target as Element).closest('uf-menu-item');\n if (item && item.closest('uf-menu') === this) this.#activate(item);\n };\n\n #onKeyDown = (event: KeyboardEvent): void => {\n const items = this.items;\n const current = (event.target as Element).closest('uf-menu-item');\n const index = current ? items.indexOf(current) : -1;\n\n switch (event.key) {\n case 'ArrowDown':\n this.#focusItem(items[(index + 1) % items.length]);\n break;\n case 'ArrowUp':\n this.#focusItem(items[(index - 1 + items.length) % items.length]);\n break;\n case 'Home':\n this.#focusItem(items[0]);\n break;\n case 'End':\n this.#focusItem(items[items.length - 1]);\n break;\n case 'Enter':\n case ' ':\n if (current) this.#activate(current);\n break;\n default:\n if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n this.#onTypeahead(event.key, items, index);\n break;\n }\n return;\n }\n event.preventDefault();\n };\n\n /** Jumps to the next item whose label starts with the typed characters. */\n #onTypeahead(key: string, items: UfMenuItem[], index: number): void {\n clearTimeout(this.#typeaheadTimer);\n this.#typeaheadTimer = window.setTimeout(() => (this.#typeahead = ''), 500);\n this.#typeahead += key.toLowerCase();\n // Repeating one letter cycles through the items that start with it.\n const search = /^(.)\\1*$/.test(this.#typeahead) ? this.#typeahead[0] : this.#typeahead;\n const ordered = [...items.slice(index + 1), ...items.slice(0, index + 1)];\n const match = ordered.find((item) => item.textContent?.trim().toLowerCase().startsWith(search));\n this.#focusItem(match);\n }\n\n override render() {\n return html`<slot @slotchange=${() => this.#alignItems()}></slot>`;\n }\n}\n\ndefineElement('uf-menu', UfMenu);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-menu': UfMenu;\n }\n}\n",
560
560
  "components/menu/menu-item.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\n\n/**\n * An action inside `<uf-menu>`. With `type=\"checkbox\"` it toggles on and off.\n *\n * @summary An item in a menu.\n * @tag uf-menu-item\n *\n * @slot - The label.\n * @slot prefix - An icon before the label.\n * @slot suffix - Trailing content, e.g. a keyboard shortcut.\n *\n * @csspart checkmark - The check shown for checked checkbox items.\n * @csspart label - The label wrapper.\n *\n * @cssstate checked - A checkbox item that is on.\n */\nexport class UfMenuItem extends LitElement {\n static override styles = css`\n :host {\n display: flex;\n align-items: center;\n gap: var(--uf-space-2);\n min-height: var(--uf-size-control-sm);\n padding: 0 var(--uf-space-3) 0 var(--uf-space-2);\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n line-height: 1.3;\n white-space: nowrap;\n cursor: pointer;\n user-select: none;\n outline: none;\n }\n\n :host(:hover),\n :host(:focus) {\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n :host(:focus-visible) {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: calc(var(--uf-focus-ring-width) * -1);\n }\n\n :host([disabled]) {\n opacity: 0.5;\n cursor: not-allowed;\n background: none;\n color: var(--uf-color-text);\n }\n\n .check {\n display: inline-flex;\n width: 1rem;\n flex: none;\n }\n\n /* In menus with checkbox items, every label lines up after the check column. */\n :host([data-check-space]:not([type='checkbox'])) {\n padding-inline-start: calc(var(--uf-space-2) * 2 + 1rem);\n }\n\n .icon {\n width: 1rem;\n height: 1rem;\n }\n\n .label {\n flex: 1;\n }\n\n ::slotted([slot='suffix']) {\n margin-inline-start: var(--uf-space-4);\n color: var(--uf-color-text-muted);\n font-size: var(--uf-font-size-sm);\n }\n\n ::slotted(svg),\n ::slotted(uf-icon) {\n width: 1rem;\n height: 1rem;\n }\n `;\n\n static override properties: PropertyDeclarations = {\n value: { reflect: true },\n type: { reflect: true },\n checked: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n };\n\n /** Identifies the item in the menu's `uf-select` event. */\n declare value: string;\n /** `checkbox` items toggle `checked` when selected. */\n declare type: 'normal' | 'checkbox';\n /** Whether a checkbox item is on. */\n declare checked: boolean;\n /** Disables the item. */\n declare disabled: boolean;\n\n readonly #internals = this.attachInternals();\n\n constructor() {\n super();\n this.value = '';\n this.type = 'normal';\n this.checked = false;\n this.disabled = false;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute('tabindex')) this.tabIndex = -1;\n }\n\n override updated(): void {\n // Real attributes, so every accessibility tool and test library sees them.\n const checkbox = this.type === 'checkbox';\n this.setAttribute('role', checkbox ? 'menuitemcheckbox' : 'menuitem');\n this.setAttribute('aria-disabled', String(this.disabled));\n if (checkbox) this.setAttribute('aria-checked', String(this.checked));\n else this.removeAttribute('aria-checked');\n this.#internals.states?.[checkbox && this.checked ? 'add' : 'delete']('checked');\n }\n\n override render() {\n return html`\n ${this.type === 'checkbox'\n ? html`<span class=\"check\">${this.checked ? iconSvg(icons.check, 'checkmark') : nothing}</span>`\n : nothing}\n <slot name=\"prefix\"></slot>\n <span class=\"label\" part=\"label\"><slot></slot></span>\n <slot name=\"suffix\"></slot>\n `;\n }\n}\n\ndefineElement('uf-menu-item', UfMenuItem);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-menu-item': UfMenuItem;\n }\n}\n",
561
561
  "components/pagination/pagination.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { defineElement } from '../../internal/define.js';\nimport { Translator } from '../../internal/i18n.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\n\nexport type PaginationSize = 'sm' | 'md';\n\nexport interface PageChangeDetail {\n /** The new page, from 1. */\n page: number;\n}\n\ntype Item = number | 'start-ellipsis' | 'end-ellipsis';\n\n/**\n * The page buttons to show: the first and last pages, the current page with\n * `siblings` pages on each side, and an ellipsis for the gaps. The number of\n * items stays the same from page to page, so the buttons don't jump around.\n */\nfunction pageItems(page: number, pages: number, siblings: number): Item[] {\n // Enough room to show everything: first, last, current, siblings and two ellipses.\n if (pages <= 2 * siblings + 5) return Array.from({ length: pages }, (_, i) => i + 1);\n const start = Math.max(2, Math.min(page - siblings, pages - 2 * siblings - 2));\n const end = Math.min(pages - 1, Math.max(page + siblings, 2 * siblings + 3));\n const items: Item[] = [1];\n if (start > 2) items.push('start-ellipsis');\n for (let p = start; p <= end; p++) items.push(p);\n if (end < pages - 1) items.push('end-ellipsis');\n items.push(pages);\n return items;\n}\n\n/**\n * Navigation between the pages of a list or table. Set `pages` and `page`; the\n * user changes `page`, and `uf-page-change` tells you which page to show.\n *\n * It's a navigation landmark: when a page has more than one, give each a\n * different `label`.\n *\n * @summary Moves between the pages of a long list.\n * @tag uf-pagination\n *\n * @event {CustomEvent<PageChangeDetail>} uf-page-change - The user chose another page.\n *\n * @csspart base - The `<nav>`.\n * @csspart list - The list of buttons.\n * @csspart button - Every button: pages, previous and next.\n * @csspart current - The current page's button.\n * @csspart previous - The previous button.\n * @csspart next - The next button.\n * @csspart ellipsis - The \"…\" between pages.\n *\n * @cssprop --uf-pagination-gap - Space between the buttons.\n */\nexport class UfPagination extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: block;\n --_size: var(--uf-size-control-md);\n }\n\n :host([size='sm']) {\n --_size: var(--uf-size-control-sm);\n }\n\n .list {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--uf-pagination-gap, var(--uf-space-1));\n margin: 0;\n padding: 0;\n list-style: none;\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-sm);\n }\n\n .button {\n display: inline-grid;\n place-items: center;\n min-width: var(--_size);\n height: var(--_size);\n padding: 0 var(--uf-space-2);\n border: 1px solid transparent;\n border-radius: var(--uf-radius-control);\n background: transparent;\n color: var(--uf-color-text);\n font: inherit;\n font-variant-numeric: tabular-nums;\n cursor: pointer;\n transition: background-color var(--uf-duration-fast) ease;\n }\n\n .button:hover:not(:disabled) {\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n .button:focus-visible {\n ${focusRing}\n }\n\n .button:disabled {\n color: var(--uf-color-text-muted);\n cursor: not-allowed;\n opacity: 0.5;\n }\n\n .current,\n .current:hover:not(:disabled) {\n background: var(--uf-color-accent);\n color: var(--uf-color-on-accent);\n font-weight: var(--uf-font-weight-semibold);\n }\n\n .arrow svg {\n width: 1.125em;\n height: 1.125em;\n }\n\n .ellipsis {\n display: inline-grid;\n place-items: center;\n min-width: var(--_size);\n color: var(--uf-color-text-muted);\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n page: { type: Number, reflect: true },\n pages: { type: Number },\n siblings: { type: Number },\n label: {},\n size: { reflect: true },\n };\n\n /** The current page, from 1. */\n declare page: number;\n /** How many pages there are. */\n declare pages: number;\n /** How many pages to show on each side of the current one. */\n declare siblings: number;\n /** Accessible name of the navigation, e.g. \"Search results pages\". Defaults to \"Pagination\", or its translation. */\n declare label: string | undefined;\n /** Size: `sm` or `md`. */\n declare size: PaginationSize;\n\n readonly #translator = new Translator(this);\n\n constructor() {\n super();\n this.page = 1;\n this.pages = 1;\n this.siblings = 1;\n this.size = 'md';\n }\n\n /** The current page, kept between 1 and `pages`. */\n get #current(): number {\n return Math.min(Math.max(1, Math.round(this.page) || 1), Math.max(1, this.pages));\n }\n\n #go(page: number): void {\n if (page === this.#current || page < 1 || page > this.pages) return;\n this.page = page;\n this.dispatchEvent(new CustomEvent<PageChangeDetail>('uf-page-change', { bubbles: true, composed: true, detail: { page } }));\n }\n\n override render() {\n const current = this.#current;\n const pages = Math.max(1, Math.floor(this.pages) || 1);\n const items = pageItems(current, pages, Math.max(0, Math.floor(this.siblings)));\n\n return html`<nav part=\"base\" aria-label=${this.label ?? this.#translator.t('pagination')}>\n <ul class=\"list\" part=\"list\">\n <li>\n <button\n class=\"button arrow\"\n part=\"button previous\"\n type=\"button\"\n aria-label=${this.#translator.t('previousPage')}\n ?disabled=${current <= 1}\n @click=${() => this.#go(this.#current - 1)}\n >\n ${iconSvg(icons['chevron-left'])}\n </button>\n </li>\n ${repeat(\n items,\n (item) => item,\n (item) =>\n typeof item === 'number'\n ? html`<li>\n <button\n class=${classMap({ button: true, current: item === current })}\n part=${item === current ? 'button current' : 'button'}\n type=\"button\"\n aria-label=${this.#translator.t('page', { page: item })}\n aria-current=${item === current ? 'page' : 'false'}\n @click=${() => this.#go(item)}\n >\n ${item}\n </button>\n </li>`\n : html`<li class=\"ellipsis\" part=\"ellipsis\" aria-hidden=\"true\">…</li>`,\n )}\n <li>\n <button\n class=\"button arrow\"\n part=\"button next\"\n type=\"button\"\n aria-label=${this.#translator.t('nextPage')}\n ?disabled=${current >= pages}\n @click=${() => this.#go(this.#current + 1)}\n >\n ${iconSvg(icons['chevron-right'])}\n </button>\n </li>\n </ul>\n </nav>`;\n }\n}\n\ndefineElement('uf-pagination', UfPagination);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-pagination': UfPagination;\n }\n}\n",
562
- "components/popover/popover.ts": "import { LitElement, css, html, type CSSResultGroup, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { defineElement } from '../../internal/define.js';\nimport { autoUpdate, positionFloating, type Placement } from '../../internal/position.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\n\n/**\n * A panel anchored to a trigger, built on the Popover API: it renders in the\n * top layer and closes on Escape or a click outside. Use it for menus of\n * actions, filters or small forms; use a dialog for anything that blocks the page.\n *\n * @summary Shows floating content next to a trigger.\n * @tag uf-popover\n *\n * @slot trigger - The element that toggles the popover, usually a button.\n * @slot - The popover content.\n *\n * @event uf-show - The popover opened.\n * @event uf-hide - The popover closed.\n *\n * @csspart panel - The floating panel.\n *\n * @cssprop --uf-popover-padding - Padding of the panel.\n * @cssprop --uf-popover-width - Width of the panel. Defaults to its content.\n */\nexport class UfPopover extends LitElement {\n static override styles: CSSResultGroup = [\n hostStyles,\n css`\n :host {\n display: inline-block;\n }\n\n .panel {\n position: fixed;\n inset: auto;\n margin: 0;\n width: var(--uf-popover-width, max-content);\n max-width: calc(100vw - 1rem);\n padding: var(--uf-popover-padding, var(--uf-space-3));\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-radius-md);\n background: var(--uf-color-surface-overlay);\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n box-shadow: var(--uf-shadow-md);\n opacity: 0;\n transition:\n opacity var(--uf-duration-fast) ease,\n overlay var(--uf-duration-fast) allow-discrete,\n display var(--uf-duration-fast) allow-discrete;\n }\n\n .panel:popover-open {\n opacity: 1;\n }\n\n @starting-style {\n .panel:popover-open {\n opacity: 0;\n }\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n open: { type: Boolean, reflect: true },\n placement: { reflect: true },\n distance: { type: Number },\n label: {},\n };\n\n /** Whether the popover is open. */\n declare open: boolean;\n /** Preferred side. Flips when there is no room. */\n declare placement: Placement;\n /** Gap between trigger and panel, in pixels. */\n declare distance: number;\n /** Accessible name of the panel. Defaults to the trigger's text. */\n declare label: string | undefined;\n\n #cleanup?: () => void;\n #openAtPointerDown: boolean | undefined;\n #restoreFocus = false;\n\n constructor() {\n super();\n this.open = false;\n this.placement = 'bottom-start';\n this.distance = 6;\n }\n\n protected get panel(): HTMLElement | null {\n return this.renderRoot.querySelector('.panel');\n }\n\n protected get trigger(): HTMLElement | undefined {\n const slot = this.renderRoot.querySelector<HTMLSlotElement>('slot[name=\"trigger\"]');\n return slot?.assignedElements()[0] as HTMLElement | undefined;\n }\n\n /** What the panel is, for `aria-haspopup` and the panel's role. Subclasses override it. */\n protected get popupKind(): 'dialog' | 'menu' {\n return 'dialog';\n }\n\n /** Called after the panel opened. */\n protected afterShow(): void {}\n\n /** Keys pressed on the trigger. */\n protected onTriggerKeyDown(_event: KeyboardEvent): void {}\n\n /** True when focus is in the panel's content (light-DOM children other than the trigger). */\n protected get focusInPanel(): boolean {\n const active = document.activeElement;\n return Boolean(active && this.contains(active) && !this.trigger?.contains(active));\n }\n\n /** Opens the popover. */\n show(): void {\n this.open = true;\n }\n\n /** Closes the popover. */\n hide(): void {\n this.open = false;\n }\n\n /** Opens the popover if closed, closes it if open. */\n toggle(): void {\n this.open = !this.open;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#cleanup?.();\n }\n\n override updated(changed: PropertyValues<this>): void {\n const panel = this.panel;\n const trigger = this.trigger;\n trigger?.setAttribute('aria-haspopup', this.popupKind);\n trigger?.setAttribute('aria-expanded', String(this.open));\n if (!changed.has('open') || !panel) return;\n\n if (this.open && !panel.matches(':popover-open')) {\n panel.showPopover();\n if (trigger) this.#cleanup = autoUpdate(trigger, panel, () => positionFloating(trigger, panel, this.placement, this.distance));\n this.dispatchEvent(new Event('uf-show', { bubbles: true, composed: true }));\n this.afterShow();\n } else if (!this.open && panel.matches(':popover-open')) {\n panel.hidePopover();\n }\n }\n\n #onBeforeToggle = (event: ToggleEvent): void => {\n // Checked before the panel hides, while focus is still inside it.\n if (event.newState === 'closed') this.#restoreFocus = this.focusInPanel;\n };\n\n /** Keeps `open` in sync when the browser closes the popover (Escape, outside click). */\n #onToggle = (event: ToggleEvent): void => {\n if (event.newState === 'closed') {\n this.#cleanup?.();\n this.#cleanup = undefined;\n this.open = false;\n // Focus would otherwise fall back to <body>.\n if (this.#restoreFocus) this.trigger?.focus();\n this.#restoreFocus = false;\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n }\n };\n\n // A click on the trigger while open first light-dismisses the popover on\n // pointerdown; remembering the state lets the click close it instead of reopening.\n #onTriggerPointerDown = (): void => {\n this.#openAtPointerDown = this.open;\n };\n\n #onTriggerClick = (): void => {\n const wasOpen = this.#openAtPointerDown ?? this.open;\n this.#openAtPointerDown = undefined;\n this.open = !wasOpen;\n };\n\n override render() {\n return html`\n <slot\n name=\"trigger\"\n @pointerdown=${this.#onTriggerPointerDown}\n @click=${this.#onTriggerClick}\n @keydown=${(event: KeyboardEvent) => this.onTriggerKeyDown(event)}\n @slotchange=${() => this.requestUpdate()}\n ></slot>\n <div\n class=\"panel\"\n part=\"panel\"\n popover=\"auto\"\n role=${ifDefined(this.popupKind === 'dialog' ? 'dialog' : undefined)}\n aria-label=${ifDefined(this.popupKind === 'dialog' ? (this.label ?? (this.trigger?.textContent?.trim() || undefined)) : undefined)}\n @beforetoggle=${this.#onBeforeToggle}\n @toggle=${this.#onToggle}\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\ndefineElement('uf-popover', UfPopover);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-popover': UfPopover;\n }\n}\n",
562
+ "components/popover/popover.ts": "import { LitElement, css, html, type CSSResultGroup, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { defineElement } from '../../internal/define.js';\nimport { autoUpdate, positionFloating, type Placement } from '../../internal/position.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\n\n/**\n * A panel anchored to a trigger, built on the Popover API: it renders in the\n * top layer and closes on Escape or a click outside. Use it for menus of\n * actions, filters or small forms; use a dialog for anything that blocks the page.\n *\n * @summary Shows floating content next to a trigger.\n * @tag uf-popover\n *\n * @slot trigger - The element that toggles the popover, usually a button.\n * @slot - The popover content.\n *\n * @event uf-show - The popover opened.\n * @event uf-hide - The popover closed.\n *\n * @csspart panel - The floating panel.\n *\n * @cssprop --uf-popover-padding - Padding of the panel.\n * @cssprop --uf-popover-width - Width of the panel. Defaults to its content.\n */\nexport class UfPopover extends LitElement {\n static override styles: CSSResultGroup = [\n hostStyles,\n css`\n :host {\n display: inline-block;\n }\n\n .panel {\n position: fixed;\n inset: auto;\n margin: 0;\n width: var(--uf-popover-width, max-content);\n max-width: calc(100vw - 1rem);\n padding: var(--uf-popover-padding, var(--uf-space-3));\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-radius-md);\n background: var(--uf-color-surface-overlay);\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n box-shadow: var(--uf-shadow-overlay);\n opacity: 0;\n transition:\n opacity var(--uf-duration-fast) ease,\n overlay var(--uf-duration-fast) allow-discrete,\n display var(--uf-duration-fast) allow-discrete;\n }\n\n .panel:popover-open {\n opacity: 1;\n }\n\n @starting-style {\n .panel:popover-open {\n opacity: 0;\n }\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n open: { type: Boolean, reflect: true },\n placement: { reflect: true },\n distance: { type: Number },\n label: {},\n };\n\n /** Whether the popover is open. */\n declare open: boolean;\n /** Preferred side. Flips when there is no room. */\n declare placement: Placement;\n /** Gap between trigger and panel, in pixels. */\n declare distance: number;\n /** Accessible name of the panel. Defaults to the trigger's text. */\n declare label: string | undefined;\n\n #cleanup?: () => void;\n #openAtPointerDown: boolean | undefined;\n #restoreFocus = false;\n\n constructor() {\n super();\n this.open = false;\n this.placement = 'bottom-start';\n this.distance = 6;\n }\n\n protected get panel(): HTMLElement | null {\n return this.renderRoot.querySelector('.panel');\n }\n\n protected get trigger(): HTMLElement | undefined {\n const slot = this.renderRoot.querySelector<HTMLSlotElement>('slot[name=\"trigger\"]');\n return slot?.assignedElements()[0] as HTMLElement | undefined;\n }\n\n /** What the panel is, for `aria-haspopup` and the panel's role. Subclasses override it. */\n protected get popupKind(): 'dialog' | 'menu' {\n return 'dialog';\n }\n\n /** Called after the panel opened. */\n protected afterShow(): void {}\n\n /** Keys pressed on the trigger. */\n protected onTriggerKeyDown(_event: KeyboardEvent): void {}\n\n /** True when focus is in the panel's content (light-DOM children other than the trigger). */\n protected get focusInPanel(): boolean {\n const active = document.activeElement;\n return Boolean(active && this.contains(active) && !this.trigger?.contains(active));\n }\n\n /** Opens the popover. */\n show(): void {\n this.open = true;\n }\n\n /** Closes the popover. */\n hide(): void {\n this.open = false;\n }\n\n /** Opens the popover if closed, closes it if open. */\n toggle(): void {\n this.open = !this.open;\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#cleanup?.();\n }\n\n override updated(changed: PropertyValues<this>): void {\n const panel = this.panel;\n const trigger = this.trigger;\n trigger?.setAttribute('aria-haspopup', this.popupKind);\n trigger?.setAttribute('aria-expanded', String(this.open));\n if (!changed.has('open') || !panel) return;\n\n if (this.open && !panel.matches(':popover-open')) {\n panel.showPopover();\n if (trigger) this.#cleanup = autoUpdate(trigger, panel, () => positionFloating(trigger, panel, this.placement, this.distance));\n this.dispatchEvent(new Event('uf-show', { bubbles: true, composed: true }));\n this.afterShow();\n } else if (!this.open && panel.matches(':popover-open')) {\n panel.hidePopover();\n }\n }\n\n #onBeforeToggle = (event: ToggleEvent): void => {\n // Checked before the panel hides, while focus is still inside it.\n if (event.newState === 'closed') this.#restoreFocus = this.focusInPanel;\n };\n\n /** Keeps `open` in sync when the browser closes the popover (Escape, outside click). */\n #onToggle = (event: ToggleEvent): void => {\n if (event.newState === 'closed') {\n this.#cleanup?.();\n this.#cleanup = undefined;\n this.open = false;\n // Focus would otherwise fall back to <body>.\n if (this.#restoreFocus) this.trigger?.focus();\n this.#restoreFocus = false;\n this.dispatchEvent(new Event('uf-hide', { bubbles: true, composed: true }));\n }\n };\n\n // A click on the trigger while open first light-dismisses the popover on\n // pointerdown; remembering the state lets the click close it instead of reopening.\n #onTriggerPointerDown = (): void => {\n this.#openAtPointerDown = this.open;\n };\n\n #onTriggerClick = (): void => {\n const wasOpen = this.#openAtPointerDown ?? this.open;\n this.#openAtPointerDown = undefined;\n this.open = !wasOpen;\n };\n\n override render() {\n return html`\n <slot\n name=\"trigger\"\n @pointerdown=${this.#onTriggerPointerDown}\n @click=${this.#onTriggerClick}\n @keydown=${(event: KeyboardEvent) => this.onTriggerKeyDown(event)}\n @slotchange=${() => this.requestUpdate()}\n ></slot>\n <div\n class=\"panel\"\n part=\"panel\"\n popover=\"auto\"\n role=${ifDefined(this.popupKind === 'dialog' ? 'dialog' : undefined)}\n aria-label=${ifDefined(this.popupKind === 'dialog' ? (this.label ?? (this.trigger?.textContent?.trim() || undefined)) : undefined)}\n @beforetoggle=${this.#onBeforeToggle}\n @toggle=${this.#onToggle}\n >\n <slot></slot>\n </div>\n `;\n }\n}\n\ndefineElement('uf-popover', UfPopover);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-popover': UfPopover;\n }\n}\n",
563
563
  "components/radio/radio.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\n\n/**\n * One option inside `<uf-radio-group>`. The group manages checked state,\n * focus and keyboard navigation.\n *\n * @summary An option in a radio group.\n * @tag uf-radio\n *\n * @slot - The label.\n *\n * @csspart control - The circle.\n * @csspart label - The label text.\n *\n * @cssprop --uf-radio-size - Size of the circle.\n * @cssprop --uf-radio-checked-color - Color of the circle when checked.\n *\n * @cssstate checked - The radio is selected.\n */\nexport class UfRadio extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n --_size: var(--uf-radio-size, 1.125rem);\n display: flex;\n align-items: flex-start;\n gap: var(--uf-space-2);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n line-height: 1.4;\n color: var(--uf-color-text);\n cursor: pointer;\n outline: none;\n }\n\n :host([disabled]),\n :host([data-group-disabled]) {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .control {\n position: relative;\n flex: none;\n width: var(--_size);\n height: var(--_size);\n margin-top: calc((1.4em - var(--_size)) / 2);\n border: 1px solid var(--uf-color-border-strong);\n border-radius: 50%;\n background: var(--uf-color-surface);\n transition: border-color var(--uf-duration-fast) ease;\n }\n\n :host(:hover:not([disabled], [data-group-disabled])) .control {\n border-color: var(--uf-color-text-muted);\n }\n\n :host([checked]) .control {\n border: calc(var(--_size) * 0.3) solid var(--uf-radio-checked-color, var(--uf-color-accent-strong));\n }\n\n :host([data-invalid]) .control {\n border-color: var(--uf-color-danger-text);\n box-shadow: inset 0 0 0 1px var(--uf-color-danger-text);\n }\n\n :host(:focus-visible) .control {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: var(--uf-focus-ring-offset);\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: { reflect: true },\n checked: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n };\n\n /** Value the group takes when this radio is selected. */\n declare value: string;\n /** Whether this radio is selected. Set by the group. */\n declare checked: boolean;\n /** Disables this option. */\n declare disabled: boolean;\n\n readonly #internals = this.attachInternals();\n\n constructor() {\n super();\n this.value = '';\n this.checked = false;\n this.disabled = false;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Real attributes rather than ElementInternals ARIA, so axe, Testing Library\n // and older assistive tech all see them.\n this.setAttribute('role', 'radio');\n }\n\n override updated(): void {\n const groupDisabled = this.hasAttribute('data-group-disabled');\n this.setAttribute('aria-checked', String(this.checked));\n this.setAttribute('aria-disabled', String(this.disabled || groupDisabled));\n this.#internals.states?.[this.checked ? 'add' : 'delete']('checked');\n }\n\n override render() {\n return html`\n <span class=\"control\" part=\"control\"></span>\n <span class=\"label\" part=\"label\"><slot></slot></span>\n `;\n }\n}\n\ndefineElement('uf-radio', UfRadio);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-radio': UfRadio;\n }\n}\n",
564
564
  "components/radio-group/radio-group.ts": "import { css, html, nothing, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { defineElement } from '../../internal/define.js';\nimport { describedBy, fieldStyles } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\nimport '../radio/radio.js';\nimport type { UfRadio } from '../radio/radio.js';\n\n/**\n * A group of `<uf-radio>` options with one selected value. Arrow keys move\n * the selection, and only the selected option is in the tab order.\n *\n * @summary Lets users pick exactly one option from a list.\n * @tag uf-radio-group\n *\n * @slot - `<uf-radio>` elements.\n * @slot label - The group label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the options. Overrides `hint`.\n *\n * @event input - Fired when the selection changes.\n * @event change - Fired when the selection changes.\n *\n * @csspart base - The element with `role=\"radiogroup\"`.\n * @csspart form-label - The group label.\n * @csspart options - The wrapper around the radios.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssstate user-invalid - Required with nothing selected, after the user interacted.\n */\nexport class UfRadioGroup extends FormControl {\n static override shadowRootOptions = { ...FormControl.shadowRootOptions, delegatesFocus: false };\n\n static override styles = [\n hostStyles,\n fieldStyles,\n css`\n .options {\n display: flex;\n flex-direction: column;\n gap: var(--uf-space-2);\n margin-top: var(--uf-space-1);\n }\n\n :host([orientation='horizontal']) .options {\n flex-direction: row;\n flex-wrap: wrap;\n gap: var(--uf-space-2) var(--uf-space-5);\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n orientation: { reflect: true },\n };\n\n /** The selected radio's value, or an empty string. */\n declare value: string;\n /** Initially selected value, restored on form reset. Set with the `value` attribute. */\n declare defaultValue: string;\n /** Visible group label. */\n declare label: string | undefined;\n /** Help text below the options. */\n declare hint: string | undefined;\n /** Lays the options out in a column or a row. */\n declare orientation: 'vertical' | 'horizontal';\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-radio-group');\n\n constructor() {\n super();\n this.value = '';\n this.defaultValue = '';\n this.orientation = 'vertical';\n this.addEventListener('click', this.#onClick);\n this.addEventListener('keydown', this.#onKeyDown);\n }\n\n get #radios(): UfRadio[] {\n return [...this.querySelectorAll('uf-radio')];\n }\n\n #isEnabled(radio: UfRadio): boolean {\n return !radio.disabled && !this.isDisabled;\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('defaultValue') && this.value === (changed.get('defaultValue') ?? '')) {\n this.value = this.defaultValue ?? '';\n }\n }\n\n override updated(): void {\n this.#syncRadios();\n this.syncFormState();\n }\n\n /** Reflects the group's value, disabled state and roving tabindex onto the radios. */\n #syncRadios(): void {\n const radios = this.#radios;\n const enabled = radios.filter((r) => this.#isEnabled(r));\n const focusable = enabled.find((r) => r.value === this.value) ?? enabled[0];\n const invalid = this.showInvalid;\n for (const radio of radios) {\n radio.checked = radio.value === this.value;\n radio.tabIndex = radio === focusable ? 0 : -1;\n radio.toggleAttribute('data-group-disabled', this.isDisabled);\n radio.toggleAttribute('data-invalid', invalid);\n radio.requestUpdate();\n }\n }\n\n protected syncFormState(): void {\n this.internals.setFormValue(this.value || null);\n this.setValidity(\n { valueMissing: this.required && !this.value },\n this.translator.t('selectOption'),\n this.#radios[0],\n );\n }\n\n protected resetValue(): void {\n this.value = this.defaultValue ?? '';\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = state ?? '';\n }\n\n #select(radio: UfRadio): void {\n radio.focus();\n if (radio.value === this.value) return;\n this.value = radio.value;\n this.markInteracted();\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n this.emitChange();\n }\n\n #onClick = (event: MouseEvent): void => {\n const radio = (event.target as Element).closest('uf-radio');\n if (radio && this.contains(radio) && this.#isEnabled(radio)) this.#select(radio);\n };\n\n #onKeyDown = (event: KeyboardEvent): void => {\n const radios = this.#radios.filter((r) => this.#isEnabled(r));\n const current = (event.target as Element).closest('uf-radio');\n if (!current || !radios.length) return;\n\n const index = radios.indexOf(current);\n const step = { ArrowDown: 1, ArrowRight: 1, ArrowUp: -1, ArrowLeft: -1 }[event.key];\n if (step) {\n event.preventDefault();\n this.#select(radios[(index + step + radios.length) % radios.length]);\n } else if (event.key === ' ') {\n event.preventDefault();\n this.#select(current);\n }\n };\n\n /** Moves focus to the selected radio, or the first enabled one. */\n override focus(options?: FocusOptions): void {\n this.#radios.find((r) => r.tabIndex === 0)?.focus(options);\n }\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const labelId = `${this.#id}-label`;\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n const hasLabel = Boolean(this.label) || this.#slots.has('label');\n\n return html`\n <div\n class=${classMap({ field: true, invalid: Boolean(error) })}\n part=\"base\"\n role=\"radiogroup\"\n aria-labelledby=${ifDefined(hasLabel ? labelId : undefined)}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n aria-required=${this.required ? 'true' : 'false'}\n aria-invalid=${error ? 'true' : 'false'}\n aria-disabled=${this.isDisabled ? 'true' : 'false'}\n >\n <div id=${labelId} class=\"field-label\" part=\"form-label\" ?hidden=${!hasLabel}>\n <slot name=\"label\">${this.label}</slot>\n ${this.required ? html`<span class=\"required\" aria-hidden=\"true\">*</span>` : nothing}\n </div>\n <div class=\"options\" part=\"options\">\n <slot @slotchange=${() => this.#syncRadios()}></slot>\n </div>\n <div id=${ids.hintId} class=\"field-hint\" part=\"hint\" ?hidden=${!this.hint && !hasHintSlot}>\n <slot name=\"hint\">${this.hint}</slot>\n </div>\n <div id=${ids.errorId} class=\"field-error\" part=\"error\" ?hidden=${!error}>${error}</div>\n </div>\n `;\n }\n}\n\ndefineElement('uf-radio-group', UfRadioGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-radio-group': UfRadioGroup;\n }\n}\n",
565
565
  "components/select/select.ts": "import { css, html, nothing, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { controlBoxStyles, describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\nimport { flattenOptions, readItems, type Item, type OptionItem } from '../../internal/options.js';\n\n/**\n * A dropdown built on the native `<select>`, so it gets the platform's\n * keyboard support, screen reader support and mobile pickers for free.\n * Write options as plain `<option>` and `<optgroup>` children.\n *\n * @summary Lets users pick one option from a dropdown list.\n * @tag uf-select\n *\n * @slot - `<option>` and `<optgroup>` elements. They are mirrored into the native select.\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the field. Overrides `hint`.\n * @slot prefix - An icon before the selected value.\n *\n * @event input - Fired when the selection changes.\n * @event change - Fired when the selection changes.\n *\n * @csspart field - The wrapper around label, control, hint and error.\n * @csspart form-label - The label.\n * @csspart box - The bordered box.\n * @csspart select - The native `<select>`.\n * @csspart chevron - The dropdown arrow.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-field-bg - Background of the box.\n * @cssprop --uf-field-border-color - Border color of the box.\n * @cssprop --uf-field-radius - Corner radius of the box.\n *\n * @cssstate user-invalid - The value is invalid and the user has interacted with the field.\n */\nexport class UfSelect extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n controlBoxStyles,\n css`\n .box {\n position: relative;\n padding-inline-end: 0;\n }\n\n .native {\n appearance: none;\n min-height: calc(var(--_height) - 2px);\n padding-inline-end: calc(var(--_padding) + 1.25em);\n cursor: pointer;\n }\n\n .native:invalid,\n .native.placeholder {\n color: var(--uf-color-text-muted);\n }\n\n .native option {\n color: var(--uf-color-text);\n background: var(--uf-color-surface-overlay);\n }\n\n .icon {\n position: absolute;\n inset-inline-end: var(--_padding);\n width: 1em;\n height: 1em;\n color: var(--uf-color-text-muted);\n pointer-events: none;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n placeholder: {},\n size: { reflect: true },\n autocomplete: {},\n };\n\n /** The selected option's value. */\n declare value: string;\n /** Initially selected value, restored on form reset. Set with the `value` attribute. */\n declare defaultValue: string | undefined;\n /** Visible label. */\n declare label: string | undefined;\n /** Help text below the field. */\n declare hint: string | undefined;\n /** Text shown while nothing is selected. */\n declare placeholder: string | undefined;\n /** Size of the field. */\n declare size: FieldSize;\n /** Native `autocomplete` hint. */\n declare autocomplete: AutoFill | undefined;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-select');\n readonly #observer = new MutationObserver(() => this.#readItems());\n #items: Item[] = [];\n #itemsChanged = false;\n #hasInitialized = false;\n\n constructor() {\n super();\n this.value = '';\n this.size = 'md';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#readItems();\n this.#observer.observe(this, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#observer.disconnect();\n }\n\n get #select(): HTMLSelectElement | null {\n return this.renderRoot.querySelector('select');\n }\n\n get #options(): OptionItem[] {\n return flattenOptions(this.#items);\n }\n\n /** Mirrors the light-DOM options into the native select. */\n #readItems(): void {\n this.#items = readItems(this);\n this.#itemsChanged = true;\n this.requestUpdate();\n }\n\n /** The value a reset returns to: the `value` attribute, a `selected` option, or the native default. */\n #initialValue(): string {\n if (this.defaultValue !== undefined && this.defaultValue !== null) return this.defaultValue;\n const options = this.#options;\n const selected = options.find((o) => o.selected);\n if (selected) return selected.value;\n if (this.placeholder) return '';\n return options.find((o) => !o.disabled)?.value ?? '';\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n const defaultChanged = changed.has('defaultValue') || changed.has('placeholder') || this.#itemsChanged;\n if (!defaultChanged) return;\n this.#itemsChanged = false;\n // Frameworks often connect the element before appending its options: wait for them.\n if (!this.#items.length) return;\n const valid = this.#options.some((o) => o.value === this.value);\n if (!this.#hasInitialized) {\n // A value set before the options were read (e.g. by a framework) wins if it exists.\n if (!(this.value && valid)) this.value = this.#initialValue();\n this.#hasInitialized = true;\n } else if (!valid) {\n this.value = this.#initialValue();\n }\n }\n\n override updated(): void {\n this.syncFormState();\n }\n\n protected syncFormState(): void {\n const select = this.#select;\n if (!select) return;\n this.internals.setFormValue(this.value);\n this.setValidityFrom(select);\n }\n\n protected resetValue(): void {\n this.value = this.#initialValue();\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = state ?? '';\n }\n\n #onChange = (event: Event): void => {\n this.value = (event.target as HTMLSelectElement).value;\n this.markInteracted();\n this.emitChange();\n };\n\n #renderOption(option: OptionItem) {\n return html`<option value=${option.value} ?disabled=${option.disabled} ?selected=${option.value === this.value}>\n ${option.label}\n </option>`;\n }\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n const showingPlaceholder = Boolean(this.placeholder) && !this.value;\n\n return renderField({\n ...ids,\n controlId: this.#id,\n label: this.label,\n hasLabelSlot: this.#slots.has('label'),\n hint: this.hint,\n hasHintSlot,\n error,\n required: this.required,\n control: html`\n <div class=${classMap({ box: true, disabled: this.isDisabled })} part=\"box\">\n <slot name=\"prefix\"></slot>\n <select\n id=${this.#id}\n class=${classMap({ native: true, placeholder: showingPlaceholder })}\n part=\"select\"\n name=${ifDefined(this.name || undefined)}\n autocomplete=${ifDefined(this.autocomplete)}\n .value=${live(this.value)}\n ?required=${this.required}\n ?disabled=${this.isDisabled}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @change=${this.#onChange}\n >\n ${this.placeholder\n ? html`<option value=\"\" disabled hidden ?selected=${!this.value}>${this.placeholder}</option>`\n : nothing}\n ${this.#items.map((item) =>\n item.kind === 'group'\n ? html`<optgroup label=${item.label} ?disabled=${item.disabled}>\n ${item.options.map((o) => this.#renderOption(o))}\n </optgroup>`\n : this.#renderOption(item),\n )}\n </select>\n ${iconSvg(icons['chevron-down'], 'chevron')}\n </div>\n `,\n });\n }\n}\n\ndefineElement('uf-select', UfSelect);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-select': UfSelect;\n }\n}\n",
@@ -571,5 +571,5 @@
571
571
  "components/toast/toast.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { defineElement } from '../../internal/define.js';\nimport { Translator } from '../../internal/i18n.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\n\nexport type ToastVariant = 'neutral' | 'info' | 'success' | 'warning' | 'danger';\nexport type ToasterPlacement = 'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end';\n\nexport interface ToastOptions {\n /** Bold first line. */\n title?: string;\n /** Color and icon. `danger` toasts are announced assertively. */\n variant?: ToastVariant;\n /** Milliseconds before it hides. `0` keeps it until dismissed. Defaults to 5000. */\n duration?: number;\n /** Shows a dismiss button. Defaults to true. */\n closable?: boolean;\n}\n\nexport interface ToastHandle {\n /** Hides the toast now. */\n dismiss(): void;\n}\n\ninterface ToastItem extends Required<Omit<ToastOptions, 'title'>> {\n id: number;\n title?: string;\n message: string;\n leaving: boolean;\n}\n\ninterface Timer {\n handle: number;\n started: number;\n remaining: number;\n}\n\nconst variantIcons = {\n neutral: null,\n info: icons.info,\n success: icons['check-circle'],\n warning: icons['alert-triangle'],\n danger: icons['alert-circle'],\n} as const;\n\nconst MAX_TOASTS = 5;\nconst EXIT_MS = 200;\nlet nextId = 1;\n\n/**\n * The region that shows toasts. You rarely need to add it yourself: `toast()`\n * creates one on first use. Add it to choose a placement, or to hold\n * toasts in a specific place in the DOM.\n *\n * @summary Shows short, temporary notifications.\n * @tag uf-toaster\n *\n * @csspart region - The list holding the toasts.\n * @csspart toast - Each toast.\n * @csspart title - A toast's title.\n * @csspart message - A toast's message.\n * @csspart close-button - A toast's dismiss button.\n *\n * @cssprop --uf-toast-width - Width of each toast.\n * @cssprop --uf-toaster-offset - Distance from the viewport edges.\n */\nexport class UfToaster extends LitElement {\n static override styles = css`\n :host {\n --_offset: var(--uf-toaster-offset, var(--uf-space-4));\n position: fixed;\n inset: auto;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n overflow: visible;\n width: min(var(--uf-toast-width, 22rem), calc(100vw - 2 * var(--_offset)));\n font-family: var(--uf-font-family-sans);\n }\n\n :host([placement^='top']) {\n top: var(--_offset);\n }\n :host([placement^='bottom']) {\n bottom: var(--_offset);\n }\n :host([placement$='start']) {\n left: var(--_offset);\n }\n :host([placement$='end']) {\n right: var(--_offset);\n }\n :host([placement$='center']) {\n left: 50%;\n translate: -50% 0;\n }\n\n ol {\n display: flex;\n flex-direction: column;\n gap: var(--uf-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n :host([placement^='bottom']) ol {\n flex-direction: column-reverse;\n }\n\n .toast {\n --_bg: var(--uf-color-toast-neutral-bg);\n --_border: var(--uf-color-toast-neutral-border);\n --_text: var(--uf-color-toast-neutral-text);\n display: flex;\n align-items: flex-start;\n gap: var(--uf-space-3);\n padding: var(--uf-space-3) var(--uf-space-3) var(--uf-space-3) var(--uf-space-4);\n border: 1px solid var(--_border);\n border-radius: var(--uf-radius-md);\n background: var(--_bg);\n color: var(--_text);\n font-size: var(--uf-font-size-md);\n line-height: 1.45;\n box-shadow: var(--uf-shadow-md);\n animation: enter var(--uf-duration-base) ease;\n }\n\n .toast.leaving {\n opacity: 0;\n translate: 0 0.25rem;\n transition:\n opacity ${EXIT_MS}ms ease,\n translate ${EXIT_MS}ms ease;\n }\n\n .info {\n --_bg: var(--uf-color-toast-info-bg);\n --_border: var(--uf-color-toast-info-border);\n --_text: var(--uf-color-toast-info-text);\n }\n .success {\n --_bg: var(--uf-color-toast-success-bg);\n --_border: var(--uf-color-toast-success-border);\n --_text: var(--uf-color-toast-success-text);\n }\n .warning {\n --_bg: var(--uf-color-toast-warning-bg);\n --_border: var(--uf-color-toast-warning-border);\n --_text: var(--uf-color-toast-warning-text);\n }\n .danger {\n --_bg: var(--uf-color-toast-danger-bg);\n --_border: var(--uf-color-toast-danger-border);\n --_text: var(--uf-color-toast-danger-text);\n }\n\n .icon {\n flex: none;\n width: 1.125rem;\n height: 1.125rem;\n margin-top: 0.1em;\n color: currentColor;\n }\n\n .content {\n flex: 1;\n min-width: 0;\n padding-block: 0.0625rem;\n }\n\n .title {\n display: block;\n font-weight: var(--uf-font-weight-semibold);\n }\n\n .title + .message {\n margin-top: 0.125rem;\n }\n\n\n .close {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n margin: -0.125rem -0.25rem 0 0;\n padding: 0;\n border: 0;\n border-radius: var(--uf-radius-sm);\n background: transparent;\n color: inherit;\n opacity: 0.8;\n cursor: pointer;\n }\n\n .close:hover {\n background: color-mix(in srgb, currentColor 16%, transparent);\n opacity: 1;\n }\n\n .close:focus-visible {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: 0;\n }\n\n .close .icon {\n width: 1rem;\n height: 1rem;\n margin: 0;\n color: inherit;\n }\n\n @keyframes enter {\n from {\n opacity: 0;\n translate: 0 0.5rem;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .toast {\n animation: none;\n }\n .toast.leaving {\n transition: none;\n }\n }\n `;\n\n static override properties: PropertyDeclarations = {\n placement: { reflect: true },\n label: {},\n };\n\n /** Corner or edge of the viewport where toasts appear. */\n declare placement: ToasterPlacement;\n /** Accessible name of the notification region. Defaults to \"Notifications\", or its translation. */\n declare label: string | undefined;\n\n #items: ToastItem[] = [];\n readonly #translator = new Translator(this);\n readonly #timers = new Map<number, Timer>();\n\n constructor() {\n super();\n this.placement = 'bottom-end';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // The host itself is a manual popover, so toasts render in the top layer.\n this.popover = 'manual';\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n for (const timer of this.#timers.values()) clearTimeout(timer.handle);\n this.#timers.clear();\n }\n\n /** Shows a toast in this region. Prefer the `toast()` function. */\n add(message: string, options: ToastOptions = {}): ToastHandle {\n const item: ToastItem = {\n id: nextId++,\n message,\n title: options.title,\n variant: options.variant ?? 'neutral',\n duration: options.duration ?? 5000,\n closable: options.closable ?? true,\n leaving: false,\n };\n this.#items = [...this.#items, item];\n const overflow = this.#items.filter((i) => !i.leaving).length - MAX_TOASTS;\n if (overflow > 0) this.#items.filter((i) => !i.leaving).slice(0, overflow).forEach((i) => this.dismiss(i.id));\n\n this.#bringToFront();\n if (item.duration > 0) this.#startTimer(item.id, item.duration);\n this.requestUpdate();\n return { dismiss: () => this.dismiss(item.id) };\n }\n\n /** Hides a toast by id. */\n dismiss(id: number): void {\n const item = this.#items.find((i) => i.id === id);\n if (!item || item.leaving) return;\n clearTimeout(this.#timers.get(id)?.handle);\n this.#timers.delete(id);\n item.leaving = true;\n this.requestUpdate();\n\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n setTimeout(() => {\n this.#items = this.#items.filter((i) => i.id !== id);\n if (!this.#items.length && this.matches(':popover-open')) this.hidePopover();\n this.requestUpdate();\n }, reduced ? 0 : EXIT_MS);\n }\n\n /** Re-shows the popover, so toasts appear above a dialog opened after the last one. */\n #bringToFront(): void {\n if (this.matches(':popover-open')) this.hidePopover();\n this.showPopover();\n }\n\n #startTimer(id: number, ms: number): void {\n this.#timers.set(id, { handle: window.setTimeout(() => this.dismiss(id), ms), started: Date.now(), remaining: ms });\n }\n\n #pause(id: number): void {\n const timer = this.#timers.get(id);\n if (!timer) return;\n clearTimeout(timer.handle);\n timer.remaining -= Date.now() - timer.started;\n }\n\n #resume(id: number): void {\n const timer = this.#timers.get(id);\n if (timer) this.#startTimer(id, Math.max(timer.remaining, 1000));\n }\n\n #renderToast(item: ToastItem) {\n const icon = variantIcons[item.variant];\n return html`\n <li\n class=${classMap({ toast: true, [item.variant]: true, leaving: item.leaving })}\n part=\"toast\"\n role=${item.variant === 'danger' ? 'alert' : nothing}\n @pointerenter=${() => this.#pause(item.id)}\n @pointerleave=${() => this.#resume(item.id)}\n @focusin=${() => this.#pause(item.id)}\n @focusout=${() => this.#resume(item.id)}\n >\n ${icon ? iconSvg(icon) : nothing}\n <div class=\"content\">\n ${item.title ? html`<strong class=\"title\" part=\"title\">${item.title}</strong>` : nothing}\n <div class=\"message\" part=\"message\">${item.message}</div>\n </div>\n ${item.closable\n ? html`<button class=\"close\" part=\"close-button\" type=\"button\" aria-label=${this.#translator.t('dismiss')} @click=${() => this.dismiss(item.id)}>\n ${iconSvg(icons.x)}\n </button>`\n : nothing}\n </li>\n `;\n }\n\n override render() {\n return html`\n <section aria-label=${this.label ?? this.#translator.t('notifications')}>\n <ol part=\"region\" aria-live=\"polite\" aria-relevant=\"additions\">\n ${repeat(this.#items, (item) => item.id, (item) => this.#renderToast(item))}\n </ol>\n </section>\n `;\n }\n}\n\ndefineElement('uf-toaster', UfToaster);\n\n/**\n * Shows a toast. Creates a `<uf-toaster>` on first use.\n *\n * @example toast('Saved', { variant: 'success' })\n */\nexport function toast(message: string, options?: ToastOptions): ToastHandle {\n let toaster = document.querySelector('uf-toaster');\n if (toaster) return toaster.add(message, options);\n\n // A live region must exist before content is added to it, or screen readers\n // may skip the first message. Create it now and add the toast a moment later.\n toaster = document.body.appendChild(document.createElement('uf-toaster'));\n let handle: ToastHandle | undefined;\n let dismissed = false;\n setTimeout(() => {\n if (!dismissed) handle = toaster.add(message, options);\n }, 100);\n return {\n dismiss() {\n dismissed = true;\n handle?.dismiss();\n },\n };\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-toaster': UfToaster;\n }\n}\n",
572
572
  "components/tooltip/tooltip.ts": "import { LitElement, css, html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { autoUpdate, positionFloating, type Placement } from '../../internal/position.js';\n\n/**\n * A short label that appears on hover and keyboard focus. Wrap the element it\n * describes. The text is also set as the trigger's `aria-description` (unless it\n * repeats the trigger's own label), so screen reader users get it too. Don't put\n * interactive content in a tooltip.\n *\n * @summary Shows a short hint for the element it wraps.\n * @tag uf-tooltip\n *\n * @slot - The element the tooltip describes.\n *\n * @csspart body - The tooltip bubble.\n *\n * @cssprop --uf-tooltip-bg - Background color.\n * @cssprop --uf-tooltip-color - Text color.\n * @cssprop --uf-tooltip-max-width - Maximum width.\n */\nexport class UfTooltip extends LitElement {\n static override styles = css`\n :host {\n display: contents;\n }\n\n .body {\n position: fixed;\n inset: auto;\n margin: 0;\n max-width: var(--uf-tooltip-max-width, 18rem);\n padding: var(--uf-space-1) var(--uf-space-2);\n border: 0;\n border-radius: var(--uf-radius-sm);\n background: var(--uf-tooltip-bg, var(--uf-color-text));\n color: var(--uf-tooltip-color, var(--uf-color-surface));\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-sm);\n line-height: 1.4;\n overflow: visible;\n opacity: 0;\n transition:\n opacity var(--uf-duration-fast) ease,\n overlay var(--uf-duration-fast) allow-discrete,\n display var(--uf-duration-fast) allow-discrete;\n }\n\n .body:popover-open {\n opacity: 1;\n }\n\n @starting-style {\n .body:popover-open {\n opacity: 0;\n }\n }\n `;\n\n static override properties: PropertyDeclarations = {\n content: {},\n placement: { reflect: true },\n disabled: { type: Boolean, reflect: true },\n delay: { type: Number },\n open: { type: Boolean, reflect: true },\n };\n\n /** The tooltip text. */\n declare content: string;\n /** Preferred side. Flips when there is no room. */\n declare placement: Placement;\n /** Turns the tooltip off. */\n declare disabled: boolean;\n /** Milliseconds to wait on hover before showing. Focus shows it immediately. */\n declare delay: number;\n /** Whether the tooltip is showing. */\n declare open: boolean;\n\n #timer = 0;\n #cleanup?: () => void;\n\n constructor() {\n super();\n this.content = '';\n this.placement = 'top';\n this.disabled = false;\n this.delay = 300;\n this.open = false;\n this.addEventListener('pointerenter', this.#onPointerEnter);\n this.addEventListener('pointerleave', this.#onLeave);\n this.addEventListener('focusin', this.#onFocusIn);\n this.addEventListener('focusout', this.#onLeave);\n }\n\n get #body(): HTMLElement | null {\n return this.renderRoot.querySelector('.body');\n }\n\n get #trigger(): HTMLElement | undefined {\n const slot = this.renderRoot.querySelector<HTMLSlotElement>('slot');\n return slot?.assignedElements()[0] as HTMLElement | undefined;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n document.addEventListener('keydown', this.#onKeyDown);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n document.removeEventListener('keydown', this.#onKeyDown);\n clearTimeout(this.#timer);\n this.#cleanup?.();\n }\n\n /** Shows the tooltip, unless it's disabled. */\n show(): void {\n if (!this.disabled) this.open = true;\n }\n\n /** Hides the tooltip. */\n hide(): void {\n clearTimeout(this.#timer);\n this.open = false;\n }\n\n override updated(changed: PropertyValues<this>): void {\n const trigger = this.#trigger;\n if (trigger && changed.has('content')) {\n // Skip when the tooltip repeats the trigger's name (icon buttons), or it's read twice.\n const name = trigger.getAttribute('aria-label') ?? (trigger as HTMLElement & { label?: string }).label;\n if (this.content && this.content !== name) trigger.setAttribute('aria-description', this.content);\n else trigger.removeAttribute('aria-description');\n }\n const body = this.#body;\n if (!changed.has('open') || !body) return;\n\n if (this.open && trigger && !body.matches(':popover-open')) {\n body.showPopover();\n this.#cleanup = autoUpdate(trigger, body, () => positionFloating(trigger, body, this.placement, 6));\n } else if (!this.open && body.matches(':popover-open')) {\n body.hidePopover();\n this.#cleanup?.();\n this.#cleanup = undefined;\n }\n }\n\n #onPointerEnter = (): void => {\n clearTimeout(this.#timer);\n this.#timer = window.setTimeout(() => this.show(), this.delay);\n };\n\n #onFocusIn = (): void => this.show();\n\n #onLeave = (): void => this.hide();\n\n #onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && this.open) this.hide();\n };\n\n override render() {\n return html`\n <slot @slotchange=${() => this.requestUpdate('content')}></slot>\n <div class=\"body\" part=\"body\" popover=\"manual\" role=\"tooltip\">${this.content}</div>\n `;\n }\n}\n\ndefineElement('uf-tooltip', UfTooltip);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-tooltip': UfTooltip;\n }\n}\n"
573
573
  },
574
- "tokens": "/* @unframed/tokens — generated by scripts/build.mjs, do not edit. */\n:root {\n --uf-palette-neutral-0: #ffffff;\n --uf-palette-neutral-50: #f7f6f9;\n --uf-palette-neutral-100: #efedf2;\n --uf-palette-neutral-200: #e1dfe6;\n --uf-palette-neutral-300: #c9c6d1;\n --uf-palette-neutral-400: #a29eae;\n --uf-palette-neutral-500: #7c778a;\n --uf-palette-neutral-600: #5d586b;\n --uf-palette-neutral-700: #464155;\n --uf-palette-neutral-750: #373442;\n --uf-palette-neutral-800: #302d38;\n --uf-palette-neutral-825: #28262e;\n --uf-palette-neutral-850: #212026;\n --uf-palette-neutral-900: #19191c;\n --uf-palette-neutral-925: #111312;\n --uf-palette-neutral-950: #0a0b08;\n --uf-palette-accent-50: #f3eefb;\n --uf-palette-accent-100: #e5dbf6;\n --uf-palette-accent-200: #cbb7ee;\n --uf-palette-accent-300: #ad8fe3;\n --uf-palette-accent-400: #9067d6;\n --uf-palette-accent-500: #7b47cc;\n --uf-palette-accent-600: #6930c3;\n --uf-palette-accent-700: #5726a3;\n --uf-palette-accent-800: #461f83;\n --uf-palette-accent-900: #361865;\n --uf-palette-accent-950: #1f0e3b;\n --uf-palette-danger-50: #fcedf0;\n --uf-palette-danger-100: #f8d3db;\n --uf-palette-danger-200: #f0a8b8;\n --uf-palette-danger-300: #e57d93;\n --uf-palette-danger-400: #d4566f;\n --uf-palette-danger-500: #b13650;\n --uf-palette-danger-600: #7c162e;\n --uf-palette-danger-700: #661126;\n --uf-palette-danger-800: #510d1e;\n --uf-palette-danger-900: #3d0a17;\n --uf-palette-danger-950: #24050d;\n --uf-palette-success-50: #f0fdf4;\n --uf-palette-success-100: #dcfce7;\n --uf-palette-success-400: #4ade80;\n --uf-palette-success-500: #22c55e;\n --uf-palette-success-600: #16a34a;\n --uf-palette-success-700: #15803d;\n --uf-palette-success-800: #166534;\n --uf-palette-success-950: #052e16;\n --uf-palette-warning-50: #fffbeb;\n --uf-palette-warning-100: #fef3c7;\n --uf-palette-warning-400: #fbbf24;\n --uf-palette-warning-500: #f59e0b;\n --uf-palette-warning-600: #d97706;\n --uf-palette-warning-700: #b45309;\n --uf-palette-warning-800: #92400e;\n --uf-palette-warning-950: #451a03;\n --uf-palette-info-50: #eef2fc;\n --uf-palette-info-100: #dbe3f8;\n --uf-palette-info-300: #93a8e6;\n --uf-palette-info-400: #6f88db;\n --uf-palette-info-600: #4763c9;\n --uf-palette-info-700: #3a51a8;\n --uf-palette-info-950: #121a36;\n --uf-palette-signal-blue: #4763c9;\n --uf-palette-signal-green: #1f7a66;\n --uf-palette-signal-orange: #f2a65a;\n --uf-palette-signal-orange-ink: #1b1407;\n --uf-font-family-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;\n --uf-font-family-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;\n --uf-font-size-sm: 0.8125rem;\n --uf-font-size-md: 0.875rem;\n --uf-font-size-lg: 1rem;\n --uf-font-weight-regular: 400;\n --uf-font-weight-medium: 500;\n --uf-font-weight-semibold: 600;\n --uf-radius-sm: 4px;\n --uf-radius-md: 8px;\n --uf-radius-lg: 12px;\n --uf-radius-full: 9999px;\n --uf-radius-control: 0px;\n --uf-space-1: 0.25rem;\n --uf-space-2: 0.5rem;\n --uf-space-3: 0.75rem;\n --uf-space-4: 1rem;\n --uf-space-5: 1.25rem;\n --uf-space-6: 1.5rem;\n --uf-size-control-sm: 2rem;\n --uf-size-control-md: 2.5rem;\n --uf-size-control-lg: 3rem;\n --uf-focus-ring-width: 2px;\n --uf-focus-ring-offset: 2px;\n --uf-duration-fast: 120ms;\n --uf-duration-base: 200ms;\n --uf-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);\n --uf-shadow-md: 0 4px 12px rgb(0 0 0 / 0.10), 0 1px 3px rgb(0 0 0 / 0.08);\n --uf-shadow-lg: 0 16px 40px rgb(0 0 0 / 0.18), 0 4px 12px rgb(0 0 0 / 0.10);\n}\n\n:root,\n[data-uf-theme='light'] {\n color-scheme: light;\n --uf-color-surface: var(--uf-palette-neutral-0);\n --uf-color-surface-raised: var(--uf-palette-neutral-50);\n --uf-color-surface-overlay: var(--uf-palette-neutral-0);\n --uf-color-surface-hover: var(--uf-palette-neutral-100);\n --uf-color-surface-active: var(--uf-palette-neutral-200);\n --uf-color-text: var(--uf-palette-neutral-925);\n --uf-color-text-muted: var(--uf-palette-neutral-600);\n --uf-color-border: var(--uf-palette-neutral-200);\n --uf-color-border-strong: var(--uf-palette-neutral-500);\n --uf-color-accent: var(--uf-palette-accent-600);\n --uf-color-accent-hover: var(--uf-palette-accent-700);\n --uf-color-accent-active: var(--uf-palette-accent-800);\n --uf-color-accent-strong: var(--uf-palette-accent-600);\n --uf-color-accent-subtle: var(--uf-palette-accent-50);\n --uf-color-on-accent: var(--uf-palette-neutral-0);\n --uf-color-accent-tint: var(--uf-palette-accent-100);\n --uf-color-accent-tint-hover: var(--uf-palette-accent-200);\n --uf-color-accent-tint-active: var(--uf-palette-accent-300);\n --uf-color-on-accent-tint: var(--uf-palette-accent-900);\n --uf-color-neutral-fill: var(--uf-palette-neutral-100);\n --uf-color-danger: var(--uf-palette-danger-600);\n --uf-color-danger-hover: var(--uf-palette-danger-700);\n --uf-color-danger-subtle: var(--uf-palette-danger-50);\n --uf-color-danger-text: var(--uf-palette-danger-600);\n --uf-color-on-danger: var(--uf-palette-neutral-0);\n --uf-color-success: var(--uf-palette-success-700);\n --uf-color-success-subtle: var(--uf-palette-success-50);\n --uf-color-warning: var(--uf-palette-warning-700);\n --uf-color-warning-subtle: var(--uf-palette-warning-50);\n --uf-color-info: var(--uf-palette-info-700);\n --uf-color-info-subtle: var(--uf-palette-info-50);\n --uf-color-focus-ring: var(--uf-palette-accent-600);\n --uf-color-backdrop: var(--uf-palette-neutral-950);\n --uf-color-toast-neutral-bg: var(--uf-palette-neutral-800);\n --uf-color-toast-neutral-border: var(--uf-palette-neutral-800);\n --uf-color-toast-neutral-text: var(--uf-palette-neutral-0);\n --uf-color-toast-info-bg: var(--uf-palette-signal-blue);\n --uf-color-toast-info-border: var(--uf-palette-signal-blue);\n --uf-color-toast-info-text: var(--uf-palette-neutral-0);\n --uf-color-toast-success-bg: var(--uf-palette-signal-green);\n --uf-color-toast-success-border: var(--uf-palette-signal-green);\n --uf-color-toast-success-text: var(--uf-palette-neutral-0);\n --uf-color-toast-warning-bg: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-border: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-text: var(--uf-palette-signal-orange-ink);\n --uf-color-toast-danger-bg: var(--uf-palette-danger-600);\n --uf-color-toast-danger-border: var(--uf-palette-danger-600);\n --uf-color-toast-danger-text: var(--uf-palette-neutral-0);\n --uf-shadow-raised: var(--uf-shadow-md);\n}\n\n[data-uf-theme='dark'] {\n color-scheme: dark;\n --uf-color-surface: var(--uf-palette-neutral-950);\n --uf-color-surface-raised: var(--uf-palette-neutral-925);\n --uf-color-surface-overlay: var(--uf-palette-neutral-900);\n --uf-color-surface-hover: var(--uf-palette-neutral-850);\n --uf-color-surface-active: var(--uf-palette-neutral-825);\n --uf-color-text: var(--uf-palette-neutral-50);\n --uf-color-text-muted: var(--uf-palette-neutral-400);\n --uf-color-border: var(--uf-palette-neutral-825);\n --uf-color-border-strong: var(--uf-palette-neutral-500);\n --uf-color-accent: var(--uf-palette-accent-600);\n --uf-color-accent-hover: var(--uf-palette-accent-500);\n --uf-color-accent-active: var(--uf-palette-accent-700);\n --uf-color-accent-strong: var(--uf-palette-accent-300);\n --uf-color-accent-subtle: var(--uf-palette-accent-950);\n --uf-color-on-accent: var(--uf-palette-neutral-0);\n --uf-color-accent-tint: var(--uf-palette-accent-800);\n --uf-color-accent-tint-hover: var(--uf-palette-accent-700);\n --uf-color-accent-tint-active: var(--uf-palette-accent-900);\n --uf-color-on-accent-tint: var(--uf-palette-accent-200);\n --uf-color-neutral-fill: var(--uf-palette-neutral-800);\n --uf-color-danger: var(--uf-palette-danger-600);\n --uf-color-danger-hover: var(--uf-palette-danger-500);\n --uf-color-danger-subtle: var(--uf-palette-danger-950);\n --uf-color-danger-text: var(--uf-palette-danger-300);\n --uf-color-on-danger: var(--uf-palette-neutral-0);\n --uf-color-success: var(--uf-palette-success-400);\n --uf-color-success-subtle: var(--uf-palette-success-950);\n --uf-color-warning: var(--uf-palette-warning-400);\n --uf-color-warning-subtle: var(--uf-palette-warning-950);\n --uf-color-info: var(--uf-palette-info-300);\n --uf-color-info-subtle: var(--uf-palette-info-950);\n --uf-color-focus-ring: var(--uf-palette-accent-400);\n --uf-color-backdrop: var(--uf-palette-neutral-950);\n --uf-color-toast-neutral-bg: var(--uf-palette-neutral-750);\n --uf-color-toast-neutral-border: var(--uf-palette-neutral-700);\n --uf-color-toast-neutral-text: var(--uf-palette-neutral-0);\n --uf-color-toast-info-bg: var(--uf-palette-signal-blue);\n --uf-color-toast-info-border: var(--uf-palette-signal-blue);\n --uf-color-toast-info-text: var(--uf-palette-neutral-0);\n --uf-color-toast-success-bg: var(--uf-palette-signal-green);\n --uf-color-toast-success-border: var(--uf-palette-signal-green);\n --uf-color-toast-success-text: var(--uf-palette-neutral-0);\n --uf-color-toast-warning-bg: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-border: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-text: var(--uf-palette-signal-orange-ink);\n --uf-color-toast-danger-bg: var(--uf-palette-danger-600);\n --uf-color-toast-danger-border: var(--uf-palette-danger-600);\n --uf-color-toast-danger-text: var(--uf-palette-neutral-0);\n --uf-shadow-raised: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 30%, transparent), 0 12px 32px -8px color-mix(in srgb, var(--uf-palette-accent-600) 55%, transparent);\n}\n\n@media (prefers-color-scheme: dark) {\n :root:not([data-uf-theme='light']) {\n color-scheme: dark;\n --uf-color-surface: var(--uf-palette-neutral-950);\n --uf-color-surface-raised: var(--uf-palette-neutral-925);\n --uf-color-surface-overlay: var(--uf-palette-neutral-900);\n --uf-color-surface-hover: var(--uf-palette-neutral-850);\n --uf-color-surface-active: var(--uf-palette-neutral-825);\n --uf-color-text: var(--uf-palette-neutral-50);\n --uf-color-text-muted: var(--uf-palette-neutral-400);\n --uf-color-border: var(--uf-palette-neutral-825);\n --uf-color-border-strong: var(--uf-palette-neutral-500);\n --uf-color-accent: var(--uf-palette-accent-600);\n --uf-color-accent-hover: var(--uf-palette-accent-500);\n --uf-color-accent-active: var(--uf-palette-accent-700);\n --uf-color-accent-strong: var(--uf-palette-accent-300);\n --uf-color-accent-subtle: var(--uf-palette-accent-950);\n --uf-color-on-accent: var(--uf-palette-neutral-0);\n --uf-color-accent-tint: var(--uf-palette-accent-800);\n --uf-color-accent-tint-hover: var(--uf-palette-accent-700);\n --uf-color-accent-tint-active: var(--uf-palette-accent-900);\n --uf-color-on-accent-tint: var(--uf-palette-accent-200);\n --uf-color-neutral-fill: var(--uf-palette-neutral-800);\n --uf-color-danger: var(--uf-palette-danger-600);\n --uf-color-danger-hover: var(--uf-palette-danger-500);\n --uf-color-danger-subtle: var(--uf-palette-danger-950);\n --uf-color-danger-text: var(--uf-palette-danger-300);\n --uf-color-on-danger: var(--uf-palette-neutral-0);\n --uf-color-success: var(--uf-palette-success-400);\n --uf-color-success-subtle: var(--uf-palette-success-950);\n --uf-color-warning: var(--uf-palette-warning-400);\n --uf-color-warning-subtle: var(--uf-palette-warning-950);\n --uf-color-info: var(--uf-palette-info-300);\n --uf-color-info-subtle: var(--uf-palette-info-950);\n --uf-color-focus-ring: var(--uf-palette-accent-400);\n --uf-color-backdrop: var(--uf-palette-neutral-950);\n --uf-color-toast-neutral-bg: var(--uf-palette-neutral-750);\n --uf-color-toast-neutral-border: var(--uf-palette-neutral-700);\n --uf-color-toast-neutral-text: var(--uf-palette-neutral-0);\n --uf-color-toast-info-bg: var(--uf-palette-signal-blue);\n --uf-color-toast-info-border: var(--uf-palette-signal-blue);\n --uf-color-toast-info-text: var(--uf-palette-neutral-0);\n --uf-color-toast-success-bg: var(--uf-palette-signal-green);\n --uf-color-toast-success-border: var(--uf-palette-signal-green);\n --uf-color-toast-success-text: var(--uf-palette-neutral-0);\n --uf-color-toast-warning-bg: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-border: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-text: var(--uf-palette-signal-orange-ink);\n --uf-color-toast-danger-bg: var(--uf-palette-danger-600);\n --uf-color-toast-danger-border: var(--uf-palette-danger-600);\n --uf-color-toast-danger-text: var(--uf-palette-neutral-0);\n --uf-shadow-raised: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 30%, transparent), 0 12px 32px -8px color-mix(in srgb, var(--uf-palette-accent-600) 55%, transparent);\n }\n}\n"
574
+ "tokens": "/* @unframed/tokens — generated by scripts/build.mjs, do not edit. */\n:root {\n --uf-palette-neutral-0: #ffffff;\n --uf-palette-neutral-50: #f7f6f9;\n --uf-palette-neutral-100: #efedf2;\n --uf-palette-neutral-200: #e1dfe6;\n --uf-palette-neutral-300: #c9c6d1;\n --uf-palette-neutral-400: #a29eae;\n --uf-palette-neutral-500: #7c778a;\n --uf-palette-neutral-600: #5d586b;\n --uf-palette-neutral-700: #464155;\n --uf-palette-neutral-750: #373442;\n --uf-palette-neutral-800: #302d38;\n --uf-palette-neutral-825: #28262e;\n --uf-palette-neutral-850: #212026;\n --uf-palette-neutral-900: #19191c;\n --uf-palette-neutral-925: #111312;\n --uf-palette-neutral-950: #0a0b08;\n --uf-palette-accent-50: #f3eefb;\n --uf-palette-accent-100: #e5dbf6;\n --uf-palette-accent-200: #cbb7ee;\n --uf-palette-accent-300: #ad8fe3;\n --uf-palette-accent-400: #9067d6;\n --uf-palette-accent-500: #7b47cc;\n --uf-palette-accent-600: #6930c3;\n --uf-palette-accent-700: #5726a3;\n --uf-palette-accent-800: #461f83;\n --uf-palette-accent-900: #361865;\n --uf-palette-accent-950: #1f0e3b;\n --uf-palette-danger-50: #fcedf0;\n --uf-palette-danger-100: #f8d3db;\n --uf-palette-danger-200: #f0a8b8;\n --uf-palette-danger-300: #e57d93;\n --uf-palette-danger-400: #d4566f;\n --uf-palette-danger-500: #b13650;\n --uf-palette-danger-600: #7c162e;\n --uf-palette-danger-700: #661126;\n --uf-palette-danger-800: #510d1e;\n --uf-palette-danger-900: #3d0a17;\n --uf-palette-danger-950: #24050d;\n --uf-palette-success-50: #f0fdf4;\n --uf-palette-success-100: #dcfce7;\n --uf-palette-success-400: #4ade80;\n --uf-palette-success-500: #22c55e;\n --uf-palette-success-600: #16a34a;\n --uf-palette-success-700: #15803d;\n --uf-palette-success-800: #166534;\n --uf-palette-success-950: #052e16;\n --uf-palette-warning-50: #fffbeb;\n --uf-palette-warning-100: #fef3c7;\n --uf-palette-warning-400: #fbbf24;\n --uf-palette-warning-500: #f59e0b;\n --uf-palette-warning-600: #d97706;\n --uf-palette-warning-700: #b45309;\n --uf-palette-warning-800: #92400e;\n --uf-palette-warning-950: #451a03;\n --uf-palette-info-50: #eef2fc;\n --uf-palette-info-100: #dbe3f8;\n --uf-palette-info-300: #93a8e6;\n --uf-palette-info-400: #6f88db;\n --uf-palette-info-600: #4763c9;\n --uf-palette-info-700: #3a51a8;\n --uf-palette-info-950: #121a36;\n --uf-palette-signal-blue: #4763c9;\n --uf-palette-signal-green: #1f7a66;\n --uf-palette-signal-orange: #f2a65a;\n --uf-palette-signal-orange-ink: #1b1407;\n --uf-font-family-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;\n --uf-font-family-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;\n --uf-font-size-sm: 0.8125rem;\n --uf-font-size-md: 0.875rem;\n --uf-font-size-lg: 1rem;\n --uf-font-weight-regular: 400;\n --uf-font-weight-medium: 500;\n --uf-font-weight-semibold: 600;\n --uf-radius-sm: 4px;\n --uf-radius-md: 8px;\n --uf-radius-lg: 12px;\n --uf-radius-full: 9999px;\n --uf-radius-control: 0px;\n --uf-space-1: 0.25rem;\n --uf-space-2: 0.5rem;\n --uf-space-3: 0.75rem;\n --uf-space-4: 1rem;\n --uf-space-5: 1.25rem;\n --uf-space-6: 1.5rem;\n --uf-size-control-sm: 2rem;\n --uf-size-control-md: 2.5rem;\n --uf-size-control-lg: 3rem;\n --uf-focus-ring-width: 2px;\n --uf-focus-ring-offset: 2px;\n --uf-duration-fast: 120ms;\n --uf-duration-base: 200ms;\n --uf-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.06);\n --uf-shadow-md: 0 4px 12px rgb(0 0 0 / 0.10), 0 1px 3px rgb(0 0 0 / 0.08);\n --uf-shadow-lg: 0 16px 40px rgb(0 0 0 / 0.18), 0 4px 12px rgb(0 0 0 / 0.10);\n}\n\n:root,\n[data-uf-theme='light'] {\n color-scheme: light;\n --uf-color-surface: var(--uf-palette-neutral-0);\n --uf-color-surface-raised: var(--uf-palette-neutral-50);\n --uf-color-surface-overlay: var(--uf-palette-neutral-0);\n --uf-color-surface-hover: var(--uf-palette-neutral-100);\n --uf-color-surface-active: var(--uf-palette-neutral-200);\n --uf-color-text: var(--uf-palette-neutral-925);\n --uf-color-text-muted: var(--uf-palette-neutral-600);\n --uf-color-border: var(--uf-palette-neutral-200);\n --uf-color-border-strong: var(--uf-palette-neutral-500);\n --uf-color-accent: var(--uf-palette-accent-600);\n --uf-color-accent-hover: var(--uf-palette-accent-700);\n --uf-color-accent-active: var(--uf-palette-accent-800);\n --uf-color-accent-strong: var(--uf-palette-accent-600);\n --uf-color-accent-subtle: var(--uf-palette-accent-50);\n --uf-color-on-accent: var(--uf-palette-neutral-0);\n --uf-color-accent-tint: var(--uf-palette-accent-100);\n --uf-color-accent-tint-hover: var(--uf-palette-accent-200);\n --uf-color-accent-tint-active: var(--uf-palette-accent-300);\n --uf-color-on-accent-tint: var(--uf-palette-accent-900);\n --uf-color-neutral-fill: var(--uf-palette-neutral-100);\n --uf-color-danger: var(--uf-palette-danger-500);\n --uf-color-danger-hover: var(--uf-palette-danger-600);\n --uf-color-danger-subtle: var(--uf-palette-danger-50);\n --uf-color-danger-text: var(--uf-palette-danger-500);\n --uf-color-on-danger: var(--uf-palette-neutral-0);\n --uf-color-success: var(--uf-palette-success-700);\n --uf-color-success-subtle: var(--uf-palette-success-50);\n --uf-color-warning: var(--uf-palette-warning-700);\n --uf-color-warning-subtle: var(--uf-palette-warning-50);\n --uf-color-info: var(--uf-palette-info-700);\n --uf-color-info-subtle: var(--uf-palette-info-50);\n --uf-color-focus-ring: var(--uf-palette-accent-600);\n --uf-color-backdrop: var(--uf-palette-neutral-950);\n --uf-color-toast-neutral-bg: var(--uf-palette-neutral-800);\n --uf-color-toast-neutral-border: var(--uf-palette-neutral-800);\n --uf-color-toast-neutral-text: var(--uf-palette-neutral-0);\n --uf-color-toast-info-bg: var(--uf-palette-signal-blue);\n --uf-color-toast-info-border: var(--uf-palette-signal-blue);\n --uf-color-toast-info-text: var(--uf-palette-neutral-0);\n --uf-color-toast-success-bg: var(--uf-palette-signal-green);\n --uf-color-toast-success-border: var(--uf-palette-signal-green);\n --uf-color-toast-success-text: var(--uf-palette-neutral-0);\n --uf-color-toast-warning-bg: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-border: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-text: var(--uf-palette-signal-orange-ink);\n --uf-color-toast-danger-bg: var(--uf-palette-danger-500);\n --uf-color-toast-danger-border: var(--uf-palette-danger-500);\n --uf-color-toast-danger-text: var(--uf-palette-neutral-0);\n --uf-shadow-raised: var(--uf-shadow-md);\n --uf-shadow-overlay: var(--uf-shadow-md);\n --uf-shadow-modal: var(--uf-shadow-lg);\n}\n\n[data-uf-theme='dark'] {\n color-scheme: dark;\n --uf-color-surface: var(--uf-palette-neutral-950);\n --uf-color-surface-raised: var(--uf-palette-neutral-925);\n --uf-color-surface-overlay: var(--uf-palette-neutral-900);\n --uf-color-surface-hover: var(--uf-palette-neutral-850);\n --uf-color-surface-active: var(--uf-palette-neutral-825);\n --uf-color-text: var(--uf-palette-neutral-50);\n --uf-color-text-muted: var(--uf-palette-neutral-400);\n --uf-color-border: var(--uf-palette-neutral-825);\n --uf-color-border-strong: var(--uf-palette-neutral-500);\n --uf-color-accent: var(--uf-palette-accent-600);\n --uf-color-accent-hover: var(--uf-palette-accent-500);\n --uf-color-accent-active: var(--uf-palette-accent-700);\n --uf-color-accent-strong: var(--uf-palette-accent-300);\n --uf-color-accent-subtle: var(--uf-palette-accent-950);\n --uf-color-on-accent: var(--uf-palette-neutral-0);\n --uf-color-accent-tint: var(--uf-palette-accent-800);\n --uf-color-accent-tint-hover: var(--uf-palette-accent-700);\n --uf-color-accent-tint-active: var(--uf-palette-accent-900);\n --uf-color-on-accent-tint: var(--uf-palette-accent-200);\n --uf-color-neutral-fill: var(--uf-palette-neutral-800);\n --uf-color-danger: var(--uf-palette-danger-600);\n --uf-color-danger-hover: var(--uf-palette-danger-500);\n --uf-color-danger-subtle: var(--uf-palette-danger-950);\n --uf-color-danger-text: var(--uf-palette-danger-300);\n --uf-color-on-danger: var(--uf-palette-neutral-0);\n --uf-color-success: var(--uf-palette-success-400);\n --uf-color-success-subtle: var(--uf-palette-success-950);\n --uf-color-warning: var(--uf-palette-warning-400);\n --uf-color-warning-subtle: var(--uf-palette-warning-950);\n --uf-color-info: var(--uf-palette-info-300);\n --uf-color-info-subtle: var(--uf-palette-info-950);\n --uf-color-focus-ring: var(--uf-palette-accent-400);\n --uf-color-backdrop: var(--uf-palette-neutral-950);\n --uf-color-toast-neutral-bg: var(--uf-palette-neutral-750);\n --uf-color-toast-neutral-border: var(--uf-palette-neutral-700);\n --uf-color-toast-neutral-text: var(--uf-palette-neutral-0);\n --uf-color-toast-info-bg: var(--uf-palette-signal-blue);\n --uf-color-toast-info-border: var(--uf-palette-signal-blue);\n --uf-color-toast-info-text: var(--uf-palette-neutral-0);\n --uf-color-toast-success-bg: var(--uf-palette-signal-green);\n --uf-color-toast-success-border: var(--uf-palette-signal-green);\n --uf-color-toast-success-text: var(--uf-palette-neutral-0);\n --uf-color-toast-warning-bg: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-border: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-text: var(--uf-palette-signal-orange-ink);\n --uf-color-toast-danger-bg: var(--uf-palette-danger-600);\n --uf-color-toast-danger-border: var(--uf-palette-danger-600);\n --uf-color-toast-danger-text: var(--uf-palette-neutral-0);\n --uf-shadow-raised: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 30%, transparent), 0 12px 32px -8px color-mix(in srgb, var(--uf-palette-accent-600) 55%, transparent);\n --uf-shadow-overlay: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 25%, transparent), 0 8px 24px -6px color-mix(in srgb, var(--uf-palette-accent-600) 50%, transparent);\n --uf-shadow-modal: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 30%, transparent), 0 24px 64px -12px color-mix(in srgb, var(--uf-palette-accent-600) 60%, transparent);\n}\n\n@media (prefers-color-scheme: dark) {\n :root:not([data-uf-theme='light']) {\n color-scheme: dark;\n --uf-color-surface: var(--uf-palette-neutral-950);\n --uf-color-surface-raised: var(--uf-palette-neutral-925);\n --uf-color-surface-overlay: var(--uf-palette-neutral-900);\n --uf-color-surface-hover: var(--uf-palette-neutral-850);\n --uf-color-surface-active: var(--uf-palette-neutral-825);\n --uf-color-text: var(--uf-palette-neutral-50);\n --uf-color-text-muted: var(--uf-palette-neutral-400);\n --uf-color-border: var(--uf-palette-neutral-825);\n --uf-color-border-strong: var(--uf-palette-neutral-500);\n --uf-color-accent: var(--uf-palette-accent-600);\n --uf-color-accent-hover: var(--uf-palette-accent-500);\n --uf-color-accent-active: var(--uf-palette-accent-700);\n --uf-color-accent-strong: var(--uf-palette-accent-300);\n --uf-color-accent-subtle: var(--uf-palette-accent-950);\n --uf-color-on-accent: var(--uf-palette-neutral-0);\n --uf-color-accent-tint: var(--uf-palette-accent-800);\n --uf-color-accent-tint-hover: var(--uf-palette-accent-700);\n --uf-color-accent-tint-active: var(--uf-palette-accent-900);\n --uf-color-on-accent-tint: var(--uf-palette-accent-200);\n --uf-color-neutral-fill: var(--uf-palette-neutral-800);\n --uf-color-danger: var(--uf-palette-danger-600);\n --uf-color-danger-hover: var(--uf-palette-danger-500);\n --uf-color-danger-subtle: var(--uf-palette-danger-950);\n --uf-color-danger-text: var(--uf-palette-danger-300);\n --uf-color-on-danger: var(--uf-palette-neutral-0);\n --uf-color-success: var(--uf-palette-success-400);\n --uf-color-success-subtle: var(--uf-palette-success-950);\n --uf-color-warning: var(--uf-palette-warning-400);\n --uf-color-warning-subtle: var(--uf-palette-warning-950);\n --uf-color-info: var(--uf-palette-info-300);\n --uf-color-info-subtle: var(--uf-palette-info-950);\n --uf-color-focus-ring: var(--uf-palette-accent-400);\n --uf-color-backdrop: var(--uf-palette-neutral-950);\n --uf-color-toast-neutral-bg: var(--uf-palette-neutral-750);\n --uf-color-toast-neutral-border: var(--uf-palette-neutral-700);\n --uf-color-toast-neutral-text: var(--uf-palette-neutral-0);\n --uf-color-toast-info-bg: var(--uf-palette-signal-blue);\n --uf-color-toast-info-border: var(--uf-palette-signal-blue);\n --uf-color-toast-info-text: var(--uf-palette-neutral-0);\n --uf-color-toast-success-bg: var(--uf-palette-signal-green);\n --uf-color-toast-success-border: var(--uf-palette-signal-green);\n --uf-color-toast-success-text: var(--uf-palette-neutral-0);\n --uf-color-toast-warning-bg: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-border: var(--uf-palette-signal-orange);\n --uf-color-toast-warning-text: var(--uf-palette-signal-orange-ink);\n --uf-color-toast-danger-bg: var(--uf-palette-danger-600);\n --uf-color-toast-danger-border: var(--uf-palette-danger-600);\n --uf-color-toast-danger-text: var(--uf-palette-neutral-0);\n --uf-shadow-raised: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 30%, transparent), 0 12px 32px -8px color-mix(in srgb, var(--uf-palette-accent-600) 55%, transparent);\n --uf-shadow-overlay: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 25%, transparent), 0 8px 24px -6px color-mix(in srgb, var(--uf-palette-accent-600) 50%, transparent);\n --uf-shadow-modal: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 30%, transparent), 0 24px 64px -12px color-mix(in srgb, var(--uf-palette-accent-600) 60%, transparent);\n }\n}\n"
575
575
  }