@unframed/cli 0.13.1 → 1.0.0-rc.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unframed/cli",
3
- "version": "0.13.1",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "Copy Unframed web components into your project, and own the code.",
5
5
  "license": "MIT",
6
6
  "author": "Patrizio Di Bartolomeo",
package/registry.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.13.1",
2
+ "version": "1.0.0-rc.1",
3
3
  "components": {
4
4
  "accordion": {
5
5
  "name": "accordion",
@@ -112,6 +112,23 @@
112
112
  "lit"
113
113
  ]
114
114
  },
115
+ "button-group": {
116
+ "name": "button-group",
117
+ "entry": "components/button-group/button-group.ts",
118
+ "tag": "uf-button-group",
119
+ "summary": "Joins related buttons into one bar.",
120
+ "files": [
121
+ "components/button-group/button-group.ts"
122
+ ],
123
+ "internal": [
124
+ "internal/define.ts",
125
+ "internal/shared.styles.ts"
126
+ ],
127
+ "dependencies": [],
128
+ "npm": [
129
+ "lit"
130
+ ]
131
+ },
115
132
  "calendar": {
116
133
  "name": "calendar",
117
134
  "entry": "components/calendar/calendar.ts",
@@ -834,8 +851,9 @@
834
851
  "components/avatar/avatar.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\n\nexport type AvatarSize = 'sm' | 'md' | 'lg' | 'xl';\nexport type AvatarShape = 'circle' | 'square';\n\n/** \"John Smith\" -> \"JS\", \"john\" -> \"J\". */\nfunction initialsOf(name: string): string {\n const words = name.trim().split(/\\s+/).filter(Boolean);\n const letters = words.length > 1 ? [words[0], words[words.length - 1]] : words;\n return letters.map((w) => [...w][0]?.toUpperCase() ?? '').join('');\n}\n\n/**\n * A picture of a person or an entity. Shows the image when it loads, the\n * initials of `name` when there's no image or it fails, and a generic icon\n * when there's neither.\n *\n * `name` is also the accessible name. When the name is already written next\n * to the avatar, set `decorative` so screen readers don't read it twice.\n *\n * @summary Shows a person's picture, initials or icon.\n * @tag uf-avatar\n *\n * @slot - Custom content instead of the initials or icon, e.g. an `<uf-icon>`.\n *\n * @csspart base - The avatar.\n * @csspart image - The `<img>`.\n * @csspart initials - The initials.\n * @csspart icon - The fallback icon.\n *\n * @cssprop --uf-avatar-size - Width and height. Overrides `size`.\n * @cssprop --uf-avatar-bg - Background behind initials and icon.\n * @cssprop --uf-avatar-color - Color of the initials and icon.\n * @cssprop --uf-avatar-radius - Corner radius. Overrides `shape`.\n */\nexport class UfAvatar extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n --_size: 2.5rem;\n --_radius: 50%;\n }\n\n :host([size='sm']) {\n --_size: 2rem;\n }\n :host([size='lg']) {\n --_size: 3rem;\n }\n :host([size='xl']) {\n --_size: 4rem;\n }\n :host([shape='square']) {\n --_radius: var(--uf-radius-md);\n }\n\n .base {\n position: relative;\n display: inline-grid;\n place-items: center;\n width: var(--uf-avatar-size, var(--_size));\n height: var(--uf-avatar-size, var(--_size));\n overflow: hidden;\n border-radius: var(--uf-avatar-radius, var(--_radius));\n background: var(--uf-avatar-bg, var(--uf-color-accent-tint));\n color: var(--uf-avatar-color, var(--uf-color-on-accent-tint));\n font-family: var(--uf-font-family-sans);\n /* Initials scale with the avatar. */\n font-size: calc(var(--uf-avatar-size, var(--_size)) * 0.4);\n font-weight: var(--uf-font-weight-semibold);\n line-height: 1;\n user-select: none;\n }\n\n .image {\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .icon {\n width: 60%;\n height: 60%;\n }\n\n ::slotted(*) {\n font-size: inherit;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n src: {},\n name: {},\n initials: {},\n size: { reflect: true },\n shape: { reflect: true },\n decorative: { type: Boolean },\n loading: {},\n };\n\n /** Image URL. */\n declare src: string | undefined;\n /** The person's or entity's name: the accessible name, and the source of the initials. */\n declare name: string | undefined;\n /** Initials to show instead of the ones taken from `name`. */\n declare initials: string | undefined;\n /** Size: `sm`, `md`, `lg` or `xl`. */\n declare size: AvatarSize;\n /** `circle` or `square` (rounded corners). */\n declare shape: AvatarShape;\n /** Hides the avatar from assistive tech, when the name is already shown next to it. */\n declare decorative: boolean;\n /** The image's `loading` attribute: `lazy` waits until it's near the viewport. */\n declare loading: 'eager' | 'lazy';\n\n /** The image failed to load: show the fallback. */\n #failed = false;\n\n constructor() {\n super();\n this.size = 'md';\n this.shape = 'circle';\n this.decorative = false;\n this.loading = 'eager';\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n // A new image gets a new chance to load.\n if (changed.has('src')) this.#failed = false;\n }\n\n override render() {\n const showImage = Boolean(this.src) && !this.#failed;\n const initials = this.initials ?? (this.name ? initialsOf(this.name) : '');\n const labelled = !this.decorative && Boolean(this.name);\n\n return html`<span\n class=\"base\"\n part=\"base\"\n role=${labelled ? 'img' : nothing}\n aria-label=${labelled ? this.name! : nothing}\n aria-hidden=${labelled ? nothing : 'true'}\n >\n ${showImage\n ? html`<img\n class=\"image\"\n part=\"image\"\n src=${this.src!}\n alt=\"\"\n loading=${this.loading}\n @error=${() => {\n this.#failed = true;\n this.requestUpdate();\n }}\n />`\n : html`<slot>\n ${initials\n ? html`<span part=\"initials\">${initials}</span>`\n : iconSvg(icons.user)}\n </slot>`}\n </span>`;\n }\n}\n\ndefineElement('uf-avatar', UfAvatar);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-avatar': UfAvatar;\n }\n}\n",
835
852
  "components/badge/badge.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\n\nexport type BadgeVariant = 'neutral' | 'accent' | 'info' | 'success' | 'warning' | 'danger';\nexport type BadgeAppearance = 'soft' | 'solid' | 'outline';\nexport type BadgeSize = 'sm' | 'md' | 'lg';\n\n/**\n * A short label for a status, a category or a count. It's plain text for\n * assistive tech: write text that makes sense out of context (\"3 unread\", not\n * just \"3\"), or describe it in the surrounding element's label.\n *\n * @summary Labels a status, a category or a count.\n * @tag uf-badge\n *\n * @slot - The badge text.\n * @slot prefix - An icon before the text.\n *\n * @csspart base - The badge.\n * @csspart dot - The status dot, when `dot` is set.\n *\n * @cssprop --uf-badge-bg - Background color.\n * @cssprop --uf-badge-color - Text color.\n * @cssprop --uf-badge-border-color - Border color.\n * @cssprop --uf-badge-radius - Corner radius. Use `999px` for a pill.\n */\nexport class UfBadge extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n --_bg: var(--uf-color-surface-hover);\n --_fg: var(--uf-color-text);\n --_border: transparent;\n }\n\n .base {\n display: inline-flex;\n align-items: center;\n gap: 0.375em;\n min-height: 1.5rem;\n padding: 0 var(--uf-space-2);\n border: 1px solid var(--uf-badge-border-color, var(--_border));\n border-radius: var(--uf-badge-radius, var(--uf-radius-sm));\n background: var(--uf-badge-bg, var(--_bg));\n color: var(--uf-badge-color, var(--_fg));\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-sm);\n font-weight: var(--uf-font-weight-medium);\n line-height: 1;\n white-space: nowrap;\n }\n\n :host([size='sm']) .base {\n min-height: 1.25rem;\n padding: 0 var(--uf-space-1);\n font-size: 0.75rem;\n }\n\n :host([size='lg']) .base {\n min-height: 1.75rem;\n padding: 0 var(--uf-space-3);\n font-size: var(--uf-font-size-md);\n }\n\n .dot {\n width: 0.5em;\n height: 0.5em;\n border-radius: 50%;\n background: currentColor;\n }\n\n ::slotted([slot='prefix']) {\n display: inline-flex;\n font-size: 1.1em;\n }\n\n /* Soft (default): a subtle background with strong text. */\n :host([variant='accent']) {\n --_bg: var(--uf-color-accent-tint);\n --_fg: var(--uf-color-on-accent-tint);\n }\n :host([variant='info']) {\n --_bg: var(--uf-color-info-subtle);\n --_fg: var(--uf-color-info);\n }\n :host([variant='success']) {\n --_bg: var(--uf-color-success-subtle);\n --_fg: var(--uf-color-success);\n }\n :host([variant='warning']) {\n --_bg: var(--uf-color-warning-subtle);\n --_fg: var(--uf-color-warning);\n }\n :host([variant='danger']) {\n --_bg: var(--uf-color-danger-subtle);\n --_fg: var(--uf-color-danger-text);\n }\n\n /* Solid: the bold colors of toasts. */\n :host([appearance='solid']) {\n --_bg: var(--uf-color-toast-neutral-bg);\n --_fg: var(--uf-color-toast-neutral-text);\n }\n :host([appearance='solid'][variant='accent']) {\n --_bg: var(--uf-color-accent);\n --_fg: var(--uf-color-on-accent);\n }\n :host([appearance='solid'][variant='info']) {\n --_bg: var(--uf-color-toast-info-bg);\n --_fg: var(--uf-color-toast-info-text);\n }\n :host([appearance='solid'][variant='success']) {\n --_bg: var(--uf-color-toast-success-bg);\n --_fg: var(--uf-color-toast-success-text);\n }\n :host([appearance='solid'][variant='warning']) {\n --_bg: var(--uf-color-toast-warning-bg);\n --_fg: var(--uf-color-toast-warning-text);\n }\n :host([appearance='solid'][variant='danger']) {\n --_bg: var(--uf-color-toast-danger-bg);\n --_fg: var(--uf-color-toast-danger-text);\n }\n\n /* Outline: no fill, the text color as border. */\n :host([appearance='outline']) {\n --_bg: transparent;\n --_border: currentColor;\n }\n :host([appearance='outline'][variant='neutral']) {\n --_border: var(--uf-color-border-strong);\n }\n :host([appearance='outline'][variant='accent']) {\n --_fg: var(--uf-color-accent-strong);\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true },\n appearance: { reflect: true },\n size: { reflect: true },\n dot: { type: Boolean, reflect: true },\n };\n\n /** Color, by meaning: `neutral`, `accent`, `info`, `success`, `warning` or `danger`. */\n declare variant: BadgeVariant;\n /** `soft` (tinted background), `solid` (bold background) or `outline` (border only). */\n declare appearance: BadgeAppearance;\n /** Size: `sm`, `md` or `lg`. */\n declare size: BadgeSize;\n /** Shows a status dot before the text. */\n declare dot: boolean;\n\n constructor() {\n super();\n this.variant = 'neutral';\n this.appearance = 'soft';\n this.size = 'md';\n this.dot = false;\n }\n\n override render() {\n return html`<span class=\"base\" part=\"base\">\n ${this.dot ? html`<span class=\"dot\" part=\"dot\" aria-hidden=\"true\"></span>` : null}\n <slot name=\"prefix\"></slot>\n <slot></slot>\n </span>`;\n }\n}\n\ndefineElement('uf-badge', UfBadge);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-badge': UfBadge;\n }\n}\n",
836
853
  "components/breadcrumbs/breadcrumbs.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.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\n/**\n * One step of a breadcrumb trail, inside `<uf-breadcrumbs>`. The last item is\n * the current page: plain text, announced as the current page.\n *\n * @summary A step in a breadcrumb trail.\n * @tag uf-breadcrumb-item\n *\n * @slot - The label.\n * @slot prefix - An icon before the label.\n * @slot separator - Set by `<uf-breadcrumbs>`; you don't need it yourself.\n *\n * @csspart link - The link, for items with `href`.\n * @csspart label - The current page's label, or an item without `href`.\n * @csspart separator - The separator after the item.\n */\nexport class UfBreadcrumbItem extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: inline-flex;\n align-items: center;\n min-width: 0;\n }\n\n .link,\n .label {\n display: inline-flex;\n align-items: center;\n gap: var(--uf-space-1);\n min-width: 0;\n border-radius: var(--uf-radius-sm);\n }\n\n .link {\n color: var(--uf-color-text-muted);\n text-decoration: none;\n }\n\n .link:hover {\n color: var(--uf-color-text);\n text-decoration: underline;\n }\n\n .link:focus-visible {\n ${focusRing}\n }\n\n .label {\n color: var(--uf-color-text);\n }\n\n :host([current]) .label {\n font-weight: var(--uf-font-weight-medium);\n }\n\n .separator {\n display: inline-flex;\n margin: 0 var(--uf-space-2);\n color: var(--uf-color-text-muted);\n }\n\n .separator .icon {\n width: 1em;\n height: 1em;\n }\n\n ::slotted([slot='prefix']) {\n display: inline-flex;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n href: {},\n target: {},\n current: { type: Boolean, reflect: true },\n };\n\n /** Link to this step. */\n declare href: string | undefined;\n /** Link target, used with `href`. */\n declare target: string | undefined;\n /** The current page. `<uf-breadcrumbs>` sets it on the last item. */\n declare current: boolean;\n\n constructor() {\n super();\n this.current = false;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.setAttribute('role', 'listitem');\n }\n\n override render() {\n const content = html`<slot name=\"prefix\"></slot><slot></slot>`;\n return html`\n ${this.href && !this.current\n ? html`<a class=\"link\" part=\"link\" href=${this.href} target=${ifDefined(this.target)}>${content}</a>`\n : html`<span class=\"label\" part=\"label\" aria-current=${ifDefined(this.current ? 'page' : undefined)}>${content}</span>`}\n ${this.current\n ? nothing\n : html`<span class=\"separator\" part=\"separator\" aria-hidden=\"true\"><slot name=\"separator\">${iconSvg(icons['chevron-right'])}</slot></span>`}\n `;\n }\n}\n\n/**\n * Shows where the current page sits in the site: a trail of links, from the\n * top level to here. It's a navigation landmark with a list inside, and the\n * last item is marked as the current page.\n *\n * @summary Shows the path to the current page.\n * @tag uf-breadcrumbs\n *\n * @slot - `<uf-breadcrumb-item>` elements.\n * @slot separator - A custom separator, e.g. `<span slot=\"separator\">/</span>`. Copied between the items.\n *\n * @csspart base - The `<nav>` element.\n * @csspart list - The list of items.\n */\nexport class UfBreadcrumbs extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: block;\n }\n\n .list {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n row-gap: var(--uf-space-1);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-sm);\n line-height: 1.5;\n }\n\n slot[name='separator'] {\n display: none;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n label: {},\n };\n\n /** Accessible name of the navigation. Defaults to \"Breadcrumb\", in the page's language. */\n declare label: string | undefined;\n\n readonly #translator = new Translator(this);\n\n get #items(): UfBreadcrumbItem[] {\n return [...this.children].filter((el): el is UfBreadcrumbItem => el.localName === 'uf-breadcrumb-item');\n }\n\n /** Marks the last item as current, and copies a custom separator into the others. */\n #sync = (): void => {\n const items = this.#items;\n const separator = this.querySelector<HTMLElement>(':scope > [slot=\"separator\"]');\n items.forEach((item, i) => {\n item.current = i === items.length - 1;\n item.querySelectorAll(':scope > [data-uf-separator]').forEach((copy) => copy.remove());\n if (separator && !item.current) {\n const copy = separator.cloneNode(true) as HTMLElement;\n copy.setAttribute('data-uf-separator', '');\n item.append(copy);\n }\n });\n };\n\n override render() {\n return html`\n <nav part=\"base\" aria-label=${this.label || this.#translator.t('breadcrumb')}>\n <div class=\"list\" part=\"list\" role=\"list\"><slot @slotchange=${this.#sync}></slot></div>\n </nav>\n <slot name=\"separator\" @slotchange=${this.#sync}></slot>\n `;\n }\n}\n\ndefineElement('uf-breadcrumb-item', UfBreadcrumbItem);\ndefineElement('uf-breadcrumbs', UfBreadcrumbs);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-breadcrumb-item': UfBreadcrumbItem;\n 'uf-breadcrumbs': UfBreadcrumbs;\n }\n}\n",
837
- "components/button/button.ts": "import { LitElement, 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 { buttonStyles } from './button.styles.js';\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'link';\nexport type ButtonSize = 'sm' | 'md' | 'lg';\nexport type ButtonType = 'button' | 'submit' | 'reset';\n\n/**\n * A button that works like a native `<button>`, inside or outside a form,\n * or renders as a link when `href` is set.\n *\n * @summary Triggers an action or navigates to a URL.\n * @tag uf-button\n *\n * @slot - The button's label.\n * @slot prefix - An icon or element before the label.\n * @slot suffix - An icon or element after the label.\n *\n * ARIA state set on the host (`aria-expanded`, `aria-haspopup`, `aria-pressed`,\n * `aria-current`, `aria-description`) is forwarded to the inner button, so\n * popovers, tooltips and toggle patterns work with it like with a native button.\n *\n * @csspart base - The inner `<button>` or `<a>`.\n * @csspart label - The wrapper around the default slot.\n * @csspart prefix - The prefix slot.\n * @csspart suffix - The suffix slot.\n * @csspart spinner - The loading spinner.\n *\n * @cssprop --uf-button-bg - Background color (all states unless overridden).\n * @cssprop --uf-button-bg-hover - Background color on hover.\n * @cssprop --uf-button-bg-active - Background color while pressed.\n * @cssprop --uf-button-color - Text color.\n * @cssprop --uf-button-border-color - Border color.\n * @cssprop --uf-button-radius - Corner radius.\n * @cssprop --uf-button-height - Height.\n * @cssprop --uf-button-padding - Horizontal padding.\n * @cssprop --uf-button-gap - Space between prefix, label and suffix.\n * @cssprop --uf-button-font-family - Font family.\n * @cssprop --uf-button-font-weight - Font weight.\n */\nexport class UfButton extends LitElement {\n static override styles = buttonStyles;\n static override shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n static formAssociated = true;\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true },\n size: { reflect: true },\n type: { reflect: true },\n disabled: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n label: {},\n href: {},\n target: {},\n rel: {},\n download: {},\n };\n\n /** Visual style. */\n declare variant: ButtonVariant;\n /** Size of the button. */\n declare size: ButtonSize;\n /** Behaviour inside a form. Defaults to `button` so it never submits by accident. */\n declare type: ButtonType;\n /** Disables the button. */\n declare disabled: boolean;\n /** Shows a spinner and ignores clicks, while keeping the button focusable. */\n declare loading: boolean;\n /** Accessible name, for icon-only buttons. */\n declare label: string | undefined;\n /** Renders the button as a link to this URL. */\n declare href: string | undefined;\n /** Link target, used with `href`. */\n declare target: string | undefined;\n /** Link rel, used with `href`. Defaults to `noreferrer noopener` when `target=\"_blank\"`. */\n declare rel: string | undefined;\n /** Download filename, used with `href`. */\n declare download: string | undefined;\n static #forwardedAria = ['aria-expanded', 'aria-haspopup', 'aria-pressed', 'aria-current', 'aria-description'];\n\n readonly #internals = this.attachInternals();\n /** True when the default slot has no text or elements: an icon-only button. */\n #iconOnly = false;\n readonly #ariaObserver = new MutationObserver(() => this.requestUpdate());\n /** Set when an ancestor `<fieldset disabled>` disables the button. */\n #formDisabled = false;\n\n constructor() {\n super();\n this.variant = 'primary';\n this.size = 'md';\n this.type = 'button';\n this.disabled = false;\n this.loading = false;\n // Registered first, so it runs before any listener a consumer adds.\n this.addEventListener('click', this.#handleClick);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#ariaObserver.observe(this, { attributes: true, attributeFilter: UfButton.#forwardedAria });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#ariaObserver.disconnect();\n }\n\n #aria(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n /**\n * Whether the default slot gets text or elements, read from the children so it's\n * known before rendering: checking the slot after a render would render twice.\n */\n #hasLabel(): boolean {\n return [...this.childNodes].some((node) => {\n if (node instanceof HTMLSlotElement && !node.slot) return node.assignedNodes({ flatten: true }).some((n) => n.nodeType === Node.ELEMENT_NODE || n.textContent?.trim());\n if (node.nodeType === Node.ELEMENT_NODE) return !(node as Element).slot;\n return node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim());\n });\n }\n\n override willUpdate(): void {\n this.#iconOnly = !this.#hasLabel();\n }\n\n #onLabelChange = (): void => {\n if (this.#iconOnly === this.#hasLabel()) this.requestUpdate();\n };\n\n /** The form this button belongs to, if any. */\n get form(): HTMLFormElement | null {\n return this.#internals.form;\n }\n\n /** @internal */\n formDisabledCallback(disabled: boolean): void {\n this.#formDisabled = disabled;\n this.requestUpdate();\n }\n\n get #isDisabled(): boolean {\n return this.disabled || this.#formDisabled;\n }\n\n #handleClick = (event: MouseEvent): void => {\n if (this.#isDisabled || this.loading) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n if (this.href) return;\n\n const form = this.#internals.form;\n if (this.type === 'submit') form?.requestSubmit();\n else if (this.type === 'reset') form?.reset();\n };\n\n override render() {\n const disabled = this.#isDisabled;\n const classes = classMap({ base: true, disabled, loading: this.loading, 'icon-only': this.#iconOnly });\n const content = html`\n <slot name=\"prefix\" part=\"prefix\"></slot>\n <span class=\"label\" part=\"label\"><slot @slotchange=${this.#onLabelChange}></slot></span>\n <slot name=\"suffix\" part=\"suffix\"></slot>\n ${this.loading ? html`<span class=\"spinner\" part=\"spinner\" aria-hidden=\"true\"></span>` : nothing}\n `;\n\n if (this.href) {\n const rel = this.rel ?? (this.target === '_blank' ? 'noreferrer noopener' : undefined);\n return html`<a\n part=\"base\"\n class=${classes}\n href=${ifDefined(disabled ? undefined : this.href)}\n target=${ifDefined(disabled ? undefined : this.target)}\n rel=${ifDefined(rel)}\n download=${ifDefined(this.download)}\n role=${ifDefined(disabled ? 'link' : undefined)}\n tabindex=${ifDefined(disabled ? '0' : undefined)}\n aria-disabled=${ifDefined(disabled ? 'true' : undefined)}\n aria-busy=${ifDefined(this.loading ? 'true' : undefined)}\n aria-label=${ifDefined(this.label)}\n aria-current=${ifDefined(this.#aria('aria-current'))}\n aria-description=${ifDefined(this.#aria('aria-description'))}\n >${content}</a\n >`;\n }\n\n return html`<button\n part=\"base\"\n class=${classes}\n type=\"button\"\n ?disabled=${disabled}\n aria-disabled=${ifDefined(this.loading ? 'true' : undefined)}\n aria-busy=${ifDefined(this.loading ? 'true' : undefined)}\n aria-label=${ifDefined(this.label)}\n aria-expanded=${ifDefined(this.#aria('aria-expanded'))}\n aria-haspopup=${ifDefined(this.#aria('aria-haspopup') as 'true' | undefined)}\n aria-pressed=${ifDefined(this.#aria('aria-pressed'))}\n aria-description=${ifDefined(this.#aria('aria-description'))}\n >\n ${content}\n </button>`;\n }\n}\n\ndefineElement('uf-button', UfButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-button': UfButton;\n }\n}\n",
838
- "components/button/button.styles.ts": "import { css } from 'lit';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\n\nexport const buttonStyles = [\n hostStyles,\n css`\n :host {\n display: inline-block;\n --_height: var(--uf-size-control-md);\n --_padding: var(--uf-space-4);\n --_font-size: var(--uf-font-size-md);\n --_bg: var(--uf-color-accent);\n --_bg-hover: var(--uf-color-accent-hover);\n --_bg-active: var(--uf-color-accent-active);\n --_fg: var(--uf-color-on-accent);\n --_border: transparent;\n }\n\n :host([size='sm']) {\n --_height: var(--uf-size-control-sm);\n --_padding: var(--uf-space-3);\n --_font-size: var(--uf-font-size-sm);\n }\n\n :host([size='lg']) {\n --_height: var(--uf-size-control-lg);\n --_padding: var(--uf-space-5);\n --_font-size: var(--uf-font-size-lg);\n }\n\n /* Grey at rest, so it never looks like a faded (disabled) primary; accent tint on hover, like outline and ghost. */\n :host([variant='secondary']) {\n --_bg: var(--uf-color-neutral-fill);\n --_bg-hover: var(--uf-color-accent-tint);\n --_bg-active: var(--uf-color-accent-tint-hover);\n --_fg: var(--uf-color-text);\n --_fg-hover: var(--uf-color-on-accent-tint);\n }\n\n :host([variant='outline']) {\n --_bg: transparent;\n --_bg-hover: var(--uf-color-accent-tint);\n --_bg-active: var(--uf-color-accent-tint-hover);\n --_fg: var(--uf-color-on-accent-tint);\n --_border: var(--uf-color-accent-strong);\n }\n\n :host([variant='ghost']) {\n --_bg: transparent;\n --_bg-hover: var(--uf-color-accent-tint);\n --_bg-active: var(--uf-color-accent-tint-hover);\n --_fg: var(--uf-color-text);\n --_fg-hover: var(--uf-color-on-accent-tint);\n }\n\n :host([variant='danger']) {\n --_bg: var(--uf-color-danger);\n --_bg-hover: var(--uf-color-danger-hover);\n --_bg-active: var(--uf-color-danger-hover);\n --_fg: var(--uf-color-on-danger);\n }\n\n /* Looks like a text link: no fill, no side padding (lines up with text), underline on hover.\n After the size rules, so its padding wins. */\n :host([variant='link']) {\n --_bg: transparent;\n --_bg-hover: transparent;\n --_bg-active: transparent;\n --_fg: var(--uf-color-accent-strong);\n --_padding: 0;\n }\n\n :host([variant='link']) .base:hover:not(.disabled),\n :host([variant='link']) .base:focus-visible {\n text-decoration: underline;\n text-underline-offset: 0.2em;\n }\n\n .base {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--uf-button-gap, var(--uf-space-2));\n width: 100%;\n height: var(--uf-button-height, var(--_height));\n padding: 0 var(--uf-button-padding, var(--_padding));\n border: 1px solid var(--uf-button-border-color, var(--_border));\n border-radius: var(--uf-button-radius, var(--uf-radius-control));\n background: var(--uf-button-bg, var(--_bg));\n color: var(--uf-button-color, var(--_fg));\n font-family: var(--uf-button-font-family, var(--uf-font-family-sans));\n font-size: var(--_font-size);\n font-weight: var(--uf-button-font-weight, var(--uf-font-weight-medium));\n line-height: 1;\n white-space: nowrap;\n text-decoration: none;\n cursor: pointer;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n transition:\n background-color var(--uf-duration-fast) ease,\n border-color var(--uf-duration-fast) ease,\n color var(--uf-duration-fast) ease;\n }\n\n /* Icon-only: no empty label (its gaps pushed the icon off-center), and square. */\n .base.icon-only {\n width: var(--uf-button-height, var(--_height));\n padding: 0;\n }\n\n .base.icon-only .label {\n display: none;\n }\n\n /* No hover or pressed look on a disabled (or loading) button: it can't be used. */\n .base:hover:not(.disabled, .loading) {\n background: var(--uf-button-bg-hover, var(--_bg-hover));\n color: var(--uf-button-color, var(--_fg-hover, var(--_fg)));\n }\n\n .base:active:not(.disabled, .loading) {\n background: var(--uf-button-bg-active, var(--_bg-active));\n }\n\n .base:focus-visible {\n ${focusRing}\n }\n\n .base.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .base.loading {\n cursor: progress;\n }\n\n /* opacity, not visibility, so the label stays in the accessibility tree. */\n .base.loading .label,\n .base.loading ::slotted(*) {\n opacity: 0;\n }\n\n ::slotted(svg) {\n width: 1em;\n height: 1em;\n flex: none;\n }\n\n .spinner {\n position: absolute;\n inset: 0;\n margin: auto;\n width: 1em;\n height: 1em;\n border: 2px solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n animation: spin 0.6s linear infinite;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .spinner {\n animation-duration: 1.5s;\n }\n }\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n `,\n];\n",
854
+ "components/button/button.ts": "import { LitElement, 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 { buttonStyles } from './button.styles.js';\n\nexport type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'link';\nexport type ButtonSize = 'sm' | 'md' | 'lg';\nexport type ButtonType = 'button' | 'submit' | 'reset';\n\n/**\n * A button that works like a native `<button>`, inside or outside a form,\n * or renders as a link when `href` is set.\n *\n * @summary Triggers an action or navigates to a URL.\n * @tag uf-button\n *\n * @slot - The button's label.\n * @slot prefix - An icon or element before the label.\n * @slot suffix - An icon or element after the label.\n *\n * ARIA state set on the host (`aria-expanded`, `aria-haspopup`, `aria-pressed`,\n * `aria-current`, `aria-description`) is forwarded to the inner button, so\n * popovers, tooltips and toggle patterns work with it like with a native button.\n *\n * @csspart base - The inner `<button>` or `<a>`.\n * @csspart label - The wrapper around the default slot.\n * @csspart prefix - The prefix slot.\n * @csspart suffix - The suffix slot.\n * @csspart spinner - The loading spinner.\n *\n * @cssprop --uf-button-bg - Background color (all states unless overridden).\n * @cssprop --uf-button-bg-hover - Background color on hover.\n * @cssprop --uf-button-bg-active - Background color while pressed.\n * @cssprop --uf-button-color - Text color.\n * @cssprop --uf-button-border-color - Border color.\n * @cssprop --uf-button-radius - Corner radius.\n * @cssprop --uf-button-height - Height.\n * @cssprop --uf-button-padding - Horizontal padding.\n * @cssprop --uf-button-gap - Space between prefix, label and suffix.\n * @cssprop --uf-button-font-family - Font family.\n * @cssprop --uf-button-font-weight - Font weight.\n */\nexport class UfButton extends LitElement {\n static override styles = buttonStyles;\n static override shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n static formAssociated = true;\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true },\n size: { reflect: true },\n type: { reflect: true },\n disabled: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n label: {},\n href: {},\n target: {},\n rel: {},\n download: {},\n };\n\n /** Visual style. */\n declare variant: ButtonVariant;\n /** Size of the button. */\n declare size: ButtonSize;\n /** Behaviour inside a form. Defaults to `button` so it never submits by accident. */\n declare type: ButtonType;\n /** Disables the button. */\n declare disabled: boolean;\n /** Shows a spinner and ignores clicks, while keeping the button focusable. */\n declare loading: boolean;\n /** Accessible name, for icon-only buttons. */\n declare label: string | undefined;\n /** Renders the button as a link to this URL. */\n declare href: string | undefined;\n /** Link target, used with `href`. */\n declare target: string | undefined;\n /** Link rel, used with `href`. Defaults to `noreferrer noopener` when `target=\"_blank\"`. */\n declare rel: string | undefined;\n /** Download filename, used with `href`. */\n declare download: string | undefined;\n static #forwardedAria = ['aria-expanded', 'aria-haspopup', 'aria-pressed', 'aria-current', 'aria-description'];\n\n readonly #internals = this.attachInternals();\n /** True when the default slot has no text or elements: an icon-only button. */\n #iconOnly = false;\n readonly #ariaObserver = new MutationObserver(() => this.requestUpdate());\n /** Set when an ancestor `<fieldset disabled>` disables the button. */\n #formDisabled = false;\n\n constructor() {\n super();\n this.variant = 'primary';\n this.size = 'md';\n this.type = 'button';\n this.disabled = false;\n this.loading = false;\n // Registered first, so it runs before any listener a consumer adds.\n this.addEventListener('click', this.#handleClick);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#ariaObserver.observe(this, { attributes: true, attributeFilter: UfButton.#forwardedAria });\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#ariaObserver.disconnect();\n }\n\n #aria(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n /**\n * Whether the default slot gets text or elements, read from the children so it's\n * known before rendering: checking the slot after a render would render twice.\n */\n #hasLabel(): boolean {\n return [...this.childNodes].some((node) => {\n if (node instanceof HTMLSlotElement && !node.slot) return node.assignedNodes({ flatten: true }).some((n) => n.nodeType === Node.ELEMENT_NODE || n.textContent?.trim());\n if (node.nodeType === Node.ELEMENT_NODE) return !(node as Element).slot;\n return node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim());\n });\n }\n\n override willUpdate(): void {\n this.#iconOnly = !this.#hasLabel();\n }\n\n #onLabelChange = (): void => {\n if (this.#iconOnly === this.#hasLabel()) this.requestUpdate();\n };\n\n /** The form this button belongs to, if any. */\n get form(): HTMLFormElement | null {\n return this.#internals.form;\n }\n\n /** @internal */\n formDisabledCallback(disabled: boolean): void {\n this.#formDisabled = disabled;\n // The browser also calls this when an update adds or removes the element's own\n // `disabled` attribute, after render. Lit drops a request made during an update,\n // so the control would stay disabled: ask again once the update is done.\n if (this.isUpdatePending) void this.updateComplete.then(() => this.requestUpdate());\n else this.requestUpdate();\n }\n\n get #isDisabled(): boolean {\n return this.disabled || this.#formDisabled;\n }\n\n #handleClick = (event: MouseEvent): void => {\n if (this.#isDisabled || this.loading) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n if (this.href) return;\n\n const form = this.#internals.form;\n if (this.type === 'submit') form?.requestSubmit();\n else if (this.type === 'reset') form?.reset();\n };\n\n override render() {\n const disabled = this.#isDisabled;\n const classes = classMap({ base: true, disabled, loading: this.loading, 'icon-only': this.#iconOnly });\n const content = html`\n <slot name=\"prefix\" part=\"prefix\"></slot>\n <span class=\"label\" part=\"label\"><slot @slotchange=${this.#onLabelChange}></slot></span>\n <slot name=\"suffix\" part=\"suffix\"></slot>\n ${this.loading ? html`<span class=\"spinner\" part=\"spinner\" aria-hidden=\"true\"></span>` : nothing}\n `;\n\n if (this.href) {\n const rel = this.rel ?? (this.target === '_blank' ? 'noreferrer noopener' : undefined);\n return html`<a\n part=\"base\"\n class=${classes}\n href=${ifDefined(disabled ? undefined : this.href)}\n target=${ifDefined(disabled ? undefined : this.target)}\n rel=${ifDefined(rel)}\n download=${ifDefined(this.download)}\n role=${ifDefined(disabled ? 'link' : undefined)}\n tabindex=${ifDefined(disabled ? '0' : undefined)}\n aria-disabled=${ifDefined(disabled ? 'true' : undefined)}\n aria-busy=${ifDefined(this.loading ? 'true' : undefined)}\n aria-label=${ifDefined(this.label)}\n aria-current=${ifDefined(this.#aria('aria-current'))}\n aria-description=${ifDefined(this.#aria('aria-description'))}\n >${content}</a\n >`;\n }\n\n return html`<button\n part=\"base\"\n class=${classes}\n type=\"button\"\n ?disabled=${disabled}\n aria-disabled=${ifDefined(this.loading ? 'true' : undefined)}\n aria-busy=${ifDefined(this.loading ? 'true' : undefined)}\n aria-label=${ifDefined(this.label)}\n aria-expanded=${ifDefined(this.#aria('aria-expanded'))}\n aria-haspopup=${ifDefined(this.#aria('aria-haspopup') as 'true' | undefined)}\n aria-pressed=${ifDefined(this.#aria('aria-pressed'))}\n aria-description=${ifDefined(this.#aria('aria-description'))}\n >\n ${content}\n </button>`;\n }\n}\n\ndefineElement('uf-button', UfButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-button': UfButton;\n }\n}\n",
855
+ "components/button/button.styles.ts": "import { css } from 'lit';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\n\nexport const buttonStyles = [\n hostStyles,\n css`\n :host {\n display: inline-block;\n --_height: var(--uf-size-control-md);\n --_padding: var(--uf-space-4);\n --_font-size: var(--uf-font-size-md);\n --_bg: var(--uf-color-accent);\n --_bg-hover: var(--uf-color-accent-hover);\n --_bg-active: var(--uf-color-accent-active);\n --_fg: var(--uf-color-on-accent);\n --_border: transparent;\n }\n\n :host([size='sm']) {\n --_height: var(--uf-size-control-sm);\n --_padding: var(--uf-space-3);\n --_font-size: var(--uf-font-size-sm);\n }\n\n :host([size='lg']) {\n --_height: var(--uf-size-control-lg);\n --_padding: var(--uf-space-5);\n --_font-size: var(--uf-font-size-lg);\n }\n\n /* Grey at rest, so it never looks like a faded (disabled) primary; accent tint on hover, like outline and ghost. */\n :host([variant='secondary']) {\n --_bg: var(--uf-color-neutral-fill);\n --_bg-hover: var(--uf-color-accent-tint);\n --_bg-active: var(--uf-color-accent-tint-hover);\n --_fg: var(--uf-color-text);\n --_fg-hover: var(--uf-color-on-accent-tint);\n }\n\n :host([variant='outline']) {\n --_bg: transparent;\n --_bg-hover: var(--uf-color-accent-tint);\n --_bg-active: var(--uf-color-accent-tint-hover);\n --_fg: var(--uf-color-on-accent-tint);\n --_border: var(--uf-color-accent-strong);\n }\n\n :host([variant='ghost']) {\n --_bg: transparent;\n --_bg-hover: var(--uf-color-accent-tint);\n --_bg-active: var(--uf-color-accent-tint-hover);\n --_fg: var(--uf-color-text);\n --_fg-hover: var(--uf-color-on-accent-tint);\n }\n\n :host([variant='danger']) {\n --_bg: var(--uf-color-danger);\n --_bg-hover: var(--uf-color-danger-hover);\n --_bg-active: var(--uf-color-danger-hover);\n --_fg: var(--uf-color-on-danger);\n }\n\n /* Looks like a text link: no fill, no side padding (lines up with text), underline on hover.\n After the size rules, so its padding wins. */\n :host([variant='link']) {\n --_bg: transparent;\n --_bg-hover: transparent;\n --_bg-active: transparent;\n --_fg: var(--uf-color-accent-strong);\n --_padding: 0;\n }\n\n :host([variant='link']) .base:hover:not(.disabled),\n :host([variant='link']) .base:focus-visible {\n text-decoration: underline;\n text-underline-offset: 0.2em;\n }\n\n .base {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--uf-button-gap, var(--uf-space-2));\n width: 100%;\n height: var(--uf-button-height, var(--_height));\n padding: 0 var(--uf-button-padding, var(--_padding));\n border: 1px solid var(--uf-button-border-color, var(--_border));\n /* In a <uf-button-group>: one border between neighbors, square inner corners. */\n border-width: var(--_uf-group-border-width, 1px);\n border-radius: var(--_uf-group-radius, var(--uf-button-radius, var(--uf-radius-control)));\n background: var(--uf-button-bg, var(--_bg));\n color: var(--uf-button-color, var(--_fg));\n font-family: var(--uf-button-font-family, var(--uf-font-family-sans));\n font-size: var(--_font-size);\n font-weight: var(--uf-button-font-weight, var(--uf-font-weight-medium));\n line-height: 1;\n white-space: nowrap;\n text-decoration: none;\n cursor: pointer;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n transition:\n background-color var(--uf-duration-fast) ease,\n border-color var(--uf-duration-fast) ease,\n color var(--uf-duration-fast) ease;\n }\n\n /* Icon-only: no empty label (its gaps pushed the icon off-center), and square. */\n /* In a <uf-button-group>: a line between buttons with no border to share, filled or ghost. */\n :host(:not([variant='outline'], [variant='link'])) .base {\n box-shadow: var(--_uf-group-divider, none);\n }\n\n .base.icon-only {\n width: var(--uf-button-height, var(--_height));\n padding: 0;\n }\n\n .base.icon-only .label {\n display: none;\n }\n\n /* No hover or pressed look on a disabled (or loading) button: it can't be used. */\n .base:hover:not(.disabled, .loading) {\n background: var(--uf-button-bg-hover, var(--_bg-hover));\n color: var(--uf-button-color, var(--_fg-hover, var(--_fg)));\n }\n\n .base:active:not(.disabled, .loading) {\n background: var(--uf-button-bg-active, var(--_bg-active));\n }\n\n .base:focus-visible {\n ${focusRing}\n }\n\n .base.disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n\n .base.loading {\n cursor: progress;\n }\n\n /* opacity, not visibility, so the label stays in the accessibility tree. */\n .base.loading .label,\n .base.loading ::slotted(*) {\n opacity: 0;\n }\n\n ::slotted(svg) {\n width: 1em;\n height: 1em;\n flex: none;\n }\n\n .spinner {\n position: absolute;\n inset: 0;\n margin: auto;\n width: 1em;\n height: 1em;\n border: 2px solid currentColor;\n border-right-color: transparent;\n border-radius: 50%;\n animation: spin 0.6s linear infinite;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .spinner {\n animation-duration: 1.5s;\n }\n }\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n `,\n];\n",
856
+ "components/button-group/button-group.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\n\nexport type ButtonGroupOrientation = 'horizontal' | 'vertical';\n\n/**\n * Related buttons joined into one bar, like \"Bold / Italic / Underline\" or\n * \"Save\" with a menu of other ways to save. For one choice among a few, use\n * `<uf-segmented-control>` instead.\n *\n * Neighbors share one border, and only the outer corners are rounded. Filled\n * and ghost buttons get a thin line between them. Buttons can be wrapped, in a\n * `<uf-tooltip>` or as the trigger of a `<uf-dropdown>`, and stay joined.\n *\n * It's a group for assistive tech: give it a `label` that says what the\n * buttons have in common.\n *\n * @summary Joins related buttons into one bar.\n * @tag uf-button-group\n *\n * @slot - `<uf-button>` elements, alone or wrapped in a tooltip or dropdown.\n */\nexport class UfButtonGroup extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n --_radius: var(--uf-button-radius, var(--uf-radius-control));\n --_divider: color-mix(in srgb, currentColor 30%, transparent);\n display: inline-flex;\n vertical-align: middle;\n }\n\n :host([orientation='vertical']) {\n flex-direction: column;\n }\n\n /*\n * The buttons read these private properties. Custom properties pass through\n * wrappers, so a button inside a tooltip or a dropdown gets them too.\n * A button on its own keeps its corners.\n */\n ::slotted(:not(:first-child):not(:last-child)) {\n --_uf-group-radius: 0;\n }\n\n ::slotted(:first-child:not(:last-child)) {\n --_uf-group-radius: var(--_radius) 0 0 var(--_radius);\n }\n\n ::slotted(:last-child:not(:first-child)) {\n --_uf-group-radius: 0 var(--_radius) var(--_radius) 0;\n }\n\n /* One border between neighbors, and a line between filled and ghost buttons. */\n ::slotted(:not(:first-child)) {\n --_uf-group-border-width: 1px 1px 1px 0;\n --_uf-group-divider: inset 1px 0 0 var(--_divider);\n }\n\n :host(:dir(rtl)) ::slotted(:first-child:not(:last-child)) {\n --_uf-group-radius: 0 var(--_radius) var(--_radius) 0;\n }\n\n :host(:dir(rtl)) ::slotted(:last-child:not(:first-child)) {\n --_uf-group-radius: var(--_radius) 0 0 var(--_radius);\n }\n\n :host(:dir(rtl)) ::slotted(:not(:first-child)) {\n --_uf-group-border-width: 1px 0 1px 1px;\n --_uf-group-divider: inset -1px 0 0 var(--_divider);\n }\n\n /* After the RTL rules: a vertical group is the same in both directions. */\n :host([orientation='vertical']) ::slotted(:first-child:not(:last-child)) {\n --_uf-group-radius: var(--_radius) var(--_radius) 0 0;\n }\n\n :host([orientation='vertical']) ::slotted(:last-child:not(:first-child)) {\n --_uf-group-radius: 0 0 var(--_radius) var(--_radius);\n }\n\n :host([orientation='vertical']) ::slotted(:not(:first-child)) {\n --_uf-group-border-width: 0 1px 1px;\n --_uf-group-divider: inset 0 1px 0 var(--_divider);\n }\n\n /* The focus ring above the neighbors, not under the next button. */\n ::slotted(:focus-within) {\n position: relative;\n z-index: 1;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n label: {},\n orientation: { reflect: true },\n };\n\n /** What the buttons have in common, for assistive tech. */\n declare label: string | undefined;\n /** Side by side, or stacked. */\n declare orientation: ButtonGroupOrientation;\n\n constructor() {\n super();\n this.orientation = 'horizontal';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.setAttribute('role', 'group');\n }\n\n override updated(): void {\n if (this.label) this.setAttribute('aria-label', this.label);\n else this.removeAttribute('aria-label');\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndefineElement('uf-button-group', UfButtonGroup);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-button-group': UfButtonGroup;\n }\n}\n",
839
857
  "components/calendar/calendar.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { addDays, addMonths, clamp, firstDayOfWeek, formatter, parseIso, startOfMonth, toIso, todayIso } from '../../internal/dates.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';\nimport { uniqueId } from '../../internal/slot.js';\n\n/**\n * A month grid to pick a date. Arrow keys move by day and week, Page Up and\n * Page Down by month (with Shift, by year), Home and End to the start and end\n * of the week, Enter or Space selects. Month and weekday names, and the first\n * day of the week, follow the nearest `lang` attribute.\n *\n * With `range`, it picks a start and an end date instead: the first pick sets\n * `start`, the second `end` (swapped if it's earlier), with the days between\n * highlighted as the pointer or keyboard moves.\n *\n * Use it inline, e.g. for a booking page. For a form field, use\n * `<uf-date-picker>` or `<uf-date-range-picker>`, which open one in a popup.\n *\n * @summary Shows a month to pick a date from.\n * @tag uf-calendar\n *\n * @event change - The user picked a date (read `value`), or, with `range`, completed a range (read `start` and `end`).\n *\n * @csspart base - The calendar.\n * @csspart header - The month title and the previous and next buttons.\n * @csspart title - The month and year.\n * @csspart nav-button - The previous and next month buttons.\n * @csspart grid - The `<table>` of days.\n * @csspart weekday - A weekday heading.\n * @csspart day - Every day.\n * @csspart selected - The selected day.\n * @csspart today - Today.\n * @csspart range-start - With `range`, the start date.\n * @csspart range-end - With `range`, the end date.\n * @csspart in-range - With `range`, a day between the start and the end.\n *\n * @cssprop --uf-calendar-day-size - Width and height of a day.\n */\nexport class UfCalendar extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: inline-block;\n --_day: var(--uf-calendar-day-size, 2.25rem);\n }\n\n .base {\n display: inline-flex;\n flex-direction: column;\n gap: 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-sm);\n }\n\n .header {\n display: flex;\n align-items: center;\n gap: var(--uf-space-1);\n }\n\n .title {\n flex: 1;\n margin: 0;\n font-size: var(--uf-font-size-md);\n font-weight: var(--uf-font-weight-semibold);\n text-align: center;\n text-transform: capitalize;\n }\n\n .nav {\n display: inline-grid;\n place-items: center;\n width: var(--_day);\n height: var(--_day);\n padding: 0;\n border: 0;\n border-radius: var(--uf-radius-control);\n background: transparent;\n color: var(--uf-color-text);\n cursor: pointer;\n }\n\n .nav:hover:not(:disabled) {\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n .nav:focus-visible {\n ${focusRing}\n }\n\n .nav:disabled {\n opacity: 0.35;\n cursor: not-allowed;\n }\n\n .nav svg {\n width: 1.125em;\n height: 1.125em;\n }\n\n table {\n border-collapse: collapse;\n }\n\n th {\n width: var(--_day);\n height: 1.75rem;\n padding: 0;\n color: var(--uf-color-text-muted);\n font-weight: var(--uf-font-weight-medium);\n font-size: 0.75rem;\n }\n\n td {\n width: var(--_day);\n height: var(--_day);\n padding: 0;\n border-radius: var(--uf-radius-control);\n text-align: center;\n font-variant-numeric: tabular-nums;\n cursor: pointer;\n user-select: none;\n }\n\n td:hover:not([aria-disabled='true']) {\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n td:focus-visible {\n ${focusRing}\n }\n\n td.outside {\n color: var(--uf-color-text-muted);\n }\n\n td.today {\n font-weight: var(--uf-font-weight-semibold);\n box-shadow: inset 0 0 0 1px var(--uf-color-accent-strong);\n }\n\n td[aria-selected='true'],\n td[aria-selected='true']:hover {\n background: var(--uf-color-accent);\n color: var(--uf-color-on-accent);\n font-weight: var(--uf-font-weight-semibold);\n }\n\n /* Range: the days between the ends tinted, the ends filled. */\n td.in-range,\n td.in-range:hover {\n border-radius: 0;\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n td.range-start,\n td.range-end,\n td.range-start:hover,\n td.range-end:hover {\n background: var(--uf-color-accent);\n color: var(--uf-color-on-accent);\n font-weight: var(--uf-font-weight-semibold);\n }\n\n td[aria-disabled='true'] {\n color: var(--uf-color-text-muted);\n text-decoration: line-through;\n opacity: 0.5;\n cursor: not-allowed;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: {},\n min: {},\n max: {},\n firstDayOfWeek: { type: Number, attribute: 'first-day-of-week' },\n isDateDisabled: { attribute: false },\n range: { type: Boolean, reflect: true },\n start: {},\n end: {},\n };\n\n /** The selected date, as `YYYY-MM-DD`, or an empty string. */\n declare value: string;\n /** The earliest date that can be picked, as `YYYY-MM-DD`. */\n declare min: string | undefined;\n /** The latest date that can be picked, as `YYYY-MM-DD`. */\n declare max: string | undefined;\n /** First day of the week: 0 Sunday … 6 Saturday. Defaults to the language's. */\n declare firstDayOfWeek: number | undefined;\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 /** Picks a range, from `start` to `end`, instead of one date. */\n declare range: boolean;\n /** With `range`, the first date of the range, as `YYYY-MM-DD`, or an empty string. */\n declare start: string;\n /** With `range`, the last date of the range, as `YYYY-MM-DD`, or an empty string. */\n declare end: string;\n\n readonly #translator = new Translator(this);\n readonly #id = uniqueId('uf-calendar');\n /** The day with keyboard focus; its month is the one shown. */\n #focused: Date = parseIso(todayIso())!;\n /** Focus the focused day after the next render (keyboard navigation). */\n #moveFocus = false;\n\n /** With `range`, the day under the pointer or keyboard while the end is being picked. */\n #preview: Date | null = null;\n\n constructor() {\n super();\n this.value = '';\n this.range = false;\n this.start = '';\n this.end = '';\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n // Show the selected date's month when the value changes from outside.\n if (changed.has('value') || changed.has('start') || changed.has('min') || changed.has('max')) {\n const selected = parseIso(this.range ? this.start : this.value);\n this.#focused = clamp(selected ?? this.#focused, parseIso(this.min), parseIso(this.max));\n }\n }\n\n override updated(): void {\n if (this.#moveFocus) {\n this.#moveFocus = false;\n this.#focusedCell()?.focus();\n }\n }\n\n /** Moves keyboard focus to the selected day, or today. */\n override focus(options?: FocusOptions): void {\n this.#focusedCell()?.focus(options);\n }\n\n #focusedCell(): HTMLElement | null {\n return this.renderRoot.querySelector<HTMLElement>(`td[data-date=\"${toIso(this.#focused)}\"]`);\n }\n\n #isDisabled(date: Date): boolean {\n const min = parseIso(this.min);\n const max = parseIso(this.max);\n return Boolean((min && date < min) || (max && date > max) || this.isDateDisabled?.(toIso(date)));\n }\n\n #moveTo(date: Date, focus: boolean): void {\n this.#focused = clamp(date, parseIso(this.min), parseIso(this.max));\n this.#moveFocus = focus;\n this.requestUpdate();\n }\n\n #select(date: Date): void {\n if (this.#isDisabled(date)) return;\n this.#focused = date;\n const iso = toIso(date);\n if (this.range) {\n this.#selectInRange(iso);\n return;\n }\n if (iso === this.value) return;\n this.value = iso;\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));\n }\n\n /** First pick: the start. Second pick: the end, swapped with the start if earlier. */\n #selectInRange(iso: string): void {\n if (!this.start || this.end) {\n this.start = iso;\n this.end = '';\n this.#preview = null;\n return;\n }\n [this.start, this.end] = iso < this.start ? [iso, this.start] : [this.start, iso];\n this.#preview = null;\n this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));\n }\n\n /** While the end is being picked, the day the range would end on. */\n #setPreview(date: Date | null): void {\n if (!this.range || !this.start || this.end) return;\n this.#preview = date;\n this.requestUpdate();\n }\n\n #onKeyDown = (event: KeyboardEvent): void => {\n const date = this.#focused;\n const weekStart = this.#weekStart;\n const offset = (date.getUTCDay() - weekStart + 7) % 7;\n const moves: Record<string, () => Date> = {\n ArrowLeft: () => addDays(date, getComputedStyle(this).direction === 'rtl' ? 1 : -1),\n ArrowRight: () => addDays(date, getComputedStyle(this).direction === 'rtl' ? -1 : 1),\n ArrowUp: () => addDays(date, -7),\n ArrowDown: () => addDays(date, 7),\n Home: () => addDays(date, -offset),\n End: () => addDays(date, 6 - offset),\n PageUp: () => addMonths(date, event.shiftKey ? -12 : -1),\n PageDown: () => addMonths(date, event.shiftKey ? 12 : 1),\n };\n if (moves[event.key]) {\n event.preventDefault();\n this.#moveTo(moves[event.key](), true);\n this.#setPreview(this.#focused);\n } else if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.#select(date);\n }\n };\n\n get #weekStart(): number {\n return this.firstDayOfWeek ?? firstDayOfWeek(this.#translator.lang);\n }\n\n override render() {\n const lang = this.#translator.lang;\n const weekStart = this.#weekStart;\n const month = startOfMonth(this.#focused);\n const first = addDays(month, -((month.getUTCDay() - weekStart + 7) % 7));\n // Always six weeks, so the calendar keeps its height from month to month.\n const days = Array.from({ length: 42 }, (_, i) => addDays(first, i));\n const weekdays = days.slice(0, 7);\n const min = parseIso(this.min);\n const max = parseIso(this.max);\n const today = todayIso();\n const titleId = `${this.#id}-title`;\n const long = formatter(lang, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });\n // The range shown: start to end, or start to the previewed day while the end is picked.\n let [from, to] = [this.start, this.end || (this.#preview ? toIso(this.#preview) : '')];\n if (from && to && to < from) [from, to] = [to, from];\n\n return html`<div class=\"base\" part=\"base\">\n <div class=\"header\" part=\"header\">\n <button\n class=\"nav\"\n part=\"nav-button\"\n type=\"button\"\n aria-label=${this.#translator.t('previousMonth')}\n ?disabled=${Boolean(min && addDays(month, -1) < min)}\n @click=${() => this.#moveTo(addMonths(this.#focused, -1), false)}\n >\n ${iconSvg(icons['chevron-left'])}\n </button>\n <h2 id=${titleId} class=\"title\" part=\"title\" aria-live=\"polite\">${formatter(lang, { month: 'long', year: 'numeric' }).format(month)}</h2>\n <button\n class=\"nav\"\n part=\"nav-button\"\n type=\"button\"\n aria-label=${this.#translator.t('nextMonth')}\n ?disabled=${Boolean(max && addMonths(month, 1) > max)}\n @click=${() => this.#moveTo(addMonths(this.#focused, 1), false)}\n >\n ${iconSvg(icons['chevron-right'])}\n </button>\n </div>\n <table role=\"grid\" part=\"grid\" aria-labelledby=${titleId} @keydown=${this.#onKeyDown}>\n <thead>\n <tr>\n ${weekdays.map(\n (day) =>\n html`<th scope=\"col\" part=\"weekday\" abbr=${formatter(lang, { weekday: 'long' }).format(day)}>\n ${formatter(lang, { weekday: 'narrow' }).format(day)}\n </th>`,\n )}\n </tr>\n </thead>\n <tbody>\n ${[0, 1, 2, 3, 4, 5].map(\n (week) => html`<tr>\n ${days.slice(week * 7, week * 7 + 7).map((day) => {\n const iso = toIso(day);\n const isStart = this.range && Boolean(from) && iso === from;\n const isEnd = this.range && Boolean(to) && iso === to;\n const between = this.range && Boolean(from && to) && iso > from && iso < to;\n const selected = this.range ? isStart || isEnd || (between && Boolean(this.end)) : iso === this.value;\n const isToday = iso === today;\n const outside = day.getUTCMonth() !== month.getUTCMonth();\n const disabled = this.#isDisabled(day);\n const parts = [\n 'day',\n selected && !this.range ? 'selected' : '',\n isToday ? 'today' : '',\n isStart ? 'range-start' : '',\n isEnd ? 'range-end' : '',\n between ? 'in-range' : '',\n ]\n .filter(Boolean)\n .join(' ');\n return html`<td\n part=${parts}\n class=${classMap({\n outside,\n today: isToday,\n 'range-start': isStart,\n 'range-end': isEnd,\n 'in-range': between,\n })}\n data-date=${iso}\n tabindex=${iso === toIso(this.#focused) ? 0 : -1}\n aria-label=${long.format(day)}\n aria-selected=${selected ? 'true' : 'false'}\n aria-disabled=${disabled ? 'true' : nothing}\n aria-current=${isToday ? 'date' : nothing}\n @click=${() => this.#select(day)}\n @pointerenter=${() => this.#setPreview(day)}\n @focus=${() => {\n // A day of another month is focused by the pointer, just before its click: moving\n // to its month now would re-render the grid, and the click would land on another day.\n if (!outside && toIso(this.#focused) !== iso) this.#moveTo(day, false);\n }}\n >\n ${day.getUTCDate()}\n </td>`;\n })}\n </tr>`,\n )}\n </tbody>\n </table>\n </div>`;\n }\n}\n\ndefineElement('uf-calendar', UfCalendar);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-calendar': UfCalendar;\n }\n}\n",
840
858
  "internal/dates.ts": "// Calendar dates as `YYYY-MM-DD` strings, like `<input type=\"date\">`. They're\n// handled as UTC midnights, so time zones and daylight saving never shift a day.\n\n/** A date as a UTC midnight, or null when the text isn't a real `YYYY-MM-DD` date. */\nexport function parseIso(text: string | null | undefined): Date | null {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(text ?? '');\n if (!match) return null;\n const [year, month, day] = match.slice(1).map(Number);\n const date = new Date(Date.UTC(year, month - 1, day));\n // Rejects 2026-02-30 and friends, which Date would roll over.\n return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day ? date : null;\n}\n\nexport function toIso(date: Date): string {\n return date.toISOString().slice(0, 10);\n}\n\n/** Today in the user's time zone, as `YYYY-MM-DD`. */\nexport function todayIso(): string {\n const now = new Date();\n return toIso(new Date(Date.UTC(now.getFullYear(), now.getMonth(), now.getDate())));\n}\n\nexport function addDays(date: Date, days: number): Date {\n return new Date(date.getTime() + days * 86_400_000);\n}\n\n/** The same day `months` later, or the month's last day when it's shorter (Jan 31 + 1 month = Feb 28). */\nexport function addMonths(date: Date, months: number): Date {\n const target = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + months, 1));\n const lastDay = new Date(Date.UTC(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)).getUTCDate();\n target.setUTCDate(Math.min(date.getUTCDate(), lastDay));\n return target;\n}\n\nexport function startOfMonth(date: Date): Date {\n return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), 1));\n}\n\n/** The date clamped between min and max (either may be null). */\nexport function clamp(date: Date, min: Date | null, max: Date | null): Date {\n if (min && date < min) return min;\n if (max && date > max) return max;\n return date;\n}\n\n/** First day of the week for a language: 0 Sunday … 6 Saturday. */\nexport function firstDayOfWeek(lang: string): number {\n try {\n const locale = new Intl.Locale(lang || 'en-US') as Intl.Locale & {\n getWeekInfo?: () => { firstDay: number };\n weekInfo?: { firstDay: number };\n };\n const info = locale.getWeekInfo?.() ?? locale.weekInfo;\n // Intl counts 1 Monday … 7 Sunday.\n if (info) return info.firstDay % 7;\n } catch {\n // An invalid language tag: fall through.\n }\n // Browsers without week info: Sunday in the US and Canada, Monday elsewhere.\n const region = (lang.split('-')[1] ?? (lang === 'en' || !lang ? 'US' : '')).toUpperCase();\n return ['US', 'CA', 'JP', 'BR', 'IL', 'IN'].includes(region) ? 0 : 1;\n}\n\nexport function formatter(lang: string, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat {\n try {\n return new Intl.DateTimeFormat(lang || undefined, { timeZone: 'UTC', ...options });\n } catch {\n return new Intl.DateTimeFormat(undefined, { timeZone: 'UTC', ...options });\n }\n}\n\n/** The short numeric format of a language, e.g. 14/10/2026 or 10/14/2026. */\nexport function formatShort(date: Date, lang: string): string {\n return formatter(lang, { day: '2-digit', month: '2-digit', year: 'numeric' }).format(date);\n}\n\n/** Order of day, month and year in the language's short format, and its separator. */\nexport function shortPattern(lang: string): { order: ('day' | 'month' | 'year')[]; separator: string } {\n const parts = formatter(lang, { day: '2-digit', month: '2-digit', year: 'numeric' }).formatToParts(new Date(Date.UTC(2026, 11, 31)));\n const order = parts.filter((p) => p.type === 'day' || p.type === 'month' || p.type === 'year').map((p) => p.type as 'day' | 'month' | 'year');\n const separator = parts.find((p) => p.type === 'literal')?.value.trim() || '/';\n return { order: order.length === 3 ? order : ['day', 'month', 'year'], separator };\n}\n\n/**\n * A typed date, in the language's order (14/10/2026, 10.14.26, 14-10-2026…) or\n * as `YYYY-MM-DD`. Any separator works. Two-digit years mean 20xx. Returns null\n * when it isn't a real date.\n */\nexport function parseTyped(text: string, lang: string): Date | null {\n const trimmed = text.trim();\n const iso = parseIso(trimmed);\n if (iso) return iso;\n const numbers = trimmed.split(/[^0-9]+/).filter(Boolean);\n if (numbers.length !== 3) return null;\n const { order } = shortPattern(lang);\n const value = Object.fromEntries(order.map((part, i) => [part, numbers[i]])) as Record<'day' | 'month' | 'year', string>;\n if (value.year.length !== 2 && value.year.length !== 4) return null;\n const year = value.year.length === 2 ? 2000 + Number(value.year) : Number(value.year);\n return parseIso(`${String(year).padStart(4, '0')}-${value.month.padStart(2, '0')}-${value.day.padStart(2, '0')}`);\n}\n",
841
859
  "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 CardAppearance = '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([appearance='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([appearance='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 appearance: { 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 appearance: CardAppearance;\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.appearance = '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",
@@ -843,7 +861,7 @@
843
861
  "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 /** Shown at the end of the label's row, e.g. a slider's value. Not part of the label's text. */\n labelEnd?: 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 <div class=\"field-label-row\" ?hidden=${!hasLabel && !parts.labelEnd}>\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.labelEnd ?? nothing}\n </div>\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-row {\n display: flex;\n justify-content: space-between;\n align-items: baseline;\n gap: var(--uf-space-2);\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",
844
862
  "internal/select-all.ts": "/**\n * How a `<uf-checkbox>` asks its `<uf-checkbox-group>` to update \"select all\"\n * when its `checked` changes from code. A symbol, so it isn't public API.\n */\nexport const syncSelectAll = Symbol('syncSelectAll');\n\nexport interface SelectAllHost extends HTMLElement {\n [syncSelectAll](): void;\n}\n",
845
863
  "internal/toggle-control.ts": "import type { PropertyDeclarations, PropertyValues } from 'lit';\nimport type { FieldSize } from './field.js';\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 size: { reflect: true },\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 /** Size of the control and its label: `sm`, `md` or `lg`. */\n declare size: FieldSize;\n\n constructor() {\n super();\n this.checked = false;\n this.defaultChecked = false;\n this.value = 'on';\n this.size = 'md';\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",
846
- "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 */\n/** Forms (or lone controls) that already focused their first invalid control in this submission. */\nconst focusedForInvalid = new WeakSet<HTMLElement>();\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, and by reportValidity().\n this.addEventListener('invalid', this.#onInvalid);\n }\n\n /**\n * Shows the error inline instead of the browser's bubble, which would repeat it.\n * Cancelling the event also stops the browser from focusing the field, so the\n * first invalid control of a submission is focused here instead.\n */\n #onInvalid = (event: Event): void => {\n if (this.#checking) return;\n event.preventDefault();\n this.markInteracted();\n const group = this.internals.form ?? this;\n if (focusedForInvalid.has(group)) return;\n focusedForInvalid.add(group);\n // A submission fires `invalid` on every invalid control in one task: only the first gets focus.\n // Cleared after the task, not in a microtask: those run between the events of a user's submit.\n setTimeout(() => focusedForInvalid.delete(group));\n this.focus();\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",
864
+ "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 */\n/** Forms (or lone controls) that already focused their first invalid control in this submission. */\nconst focusedForInvalid = new WeakSet<HTMLElement>();\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, and by reportValidity().\n this.addEventListener('invalid', this.#onInvalid);\n }\n\n /**\n * Shows the error inline instead of the browser's bubble, which would repeat it.\n * Cancelling the event also stops the browser from focusing the field, so the\n * first invalid control of a submission is focused here instead.\n */\n #onInvalid = (event: Event): void => {\n if (this.#checking) return;\n event.preventDefault();\n this.markInteracted();\n const group = this.internals.form ?? this;\n if (focusedForInvalid.has(group)) return;\n focusedForInvalid.add(group);\n // A submission fires `invalid` on every invalid control in one task: only the first gets focus.\n // Cleared after the task, not in a microtask: those run between the events of a user's submit.\n setTimeout(() => focusedForInvalid.delete(group));\n this.focus();\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 // The browser also calls this when an update adds or removes the element's own\n // `disabled` attribute, after render. Lit drops a request made during an update,\n // so the control would stay disabled: ask again once the update is done.\n if (this.isUpdatePending) void this.updateComplete.then(() => this.requestUpdate());\n else 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",
847
865
  "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 :host([size='sm']) {\n font-size: var(--uf-font-size-sm);\n }\n\n :host([size='lg']) {\n font-size: var(--uf-font-size-lg);\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 /* Grey instead of faded, like disabled fields. */\n .root.disabled {\n color: var(--uf-color-text-muted);\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",
848
866
  "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 { syncSelectAll } from '../../internal/select-all.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 this.#updateOptions((option) => wanted.has(option.value));\n }\n\n /** True while the group checks options itself, so they don't each update \"select all\" halfway. */\n #updatingOptions = false;\n\n #updateOptions(checked: (option: UfCheckbox) => boolean): void {\n this.#updatingOptions = true;\n try {\n for (const option of this.#options) option.checked = checked(option);\n } finally {\n this.#updatingOptions = false;\n }\n this[syncSelectAll]();\n }\n\n /** Updates \"select all\" to match the other checkboxes. The checkboxes call it when they change. @internal */\n [syncSelectAll](): void {\n const selectAll = this.#selectAll;\n if (!selectAll || this.#updatingOptions) 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 const checked = target.checked;\n // Disabled checkboxes keep their state, like any control the user can't change.\n this.#updateOptions((option) => (option.disabled ? option.checked : checked));\n } else {\n this[syncSelectAll]();\n }\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[syncSelectAll]();\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",
849
867
  "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 * @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 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'));\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'));\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",
@@ -853,10 +871,10 @@
853
871
  "components/date-range-picker/date-range-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\ntype End = 'start' | 'end';\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/** Splits an ISO 8601 interval, `YYYY-MM-DD/YYYY-MM-DD`, into its two valid dates (or empty strings). */\nfunction splitInterval(value: string | null | undefined): [string, string] {\n const [start = '', end = ''] = (value ?? '').split('/');\n return [parseIso(start) ? start : '', parseIso(end) ? end : ''];\n}\n\n/**\n * A date range field: type the start and end dates in the page language's\n * format, or pick both from a calendar. The value is an ISO 8601 interval,\n * `YYYY-MM-DD/YYYY-MM-DD`, the same in every language, and it submits with the\n * form; `start` and `end` hold the two dates.\n *\n * Alt + Down Arrow opens the calendar; Escape closes it.\n *\n * @summary Lets users type or pick a start and an end date.\n * @tag uf-date-range-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 range changed (a date was typed and committed, or both were picked).\n * @event change - The range changed (a date was typed and committed, or both were 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 inputs.\n * @csspart start-input - The start date input.\n * @csspart end-input - The end date input.\n * @csspart separator - The dash between the two inputs.\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 range is invalid and the user has interacted with the field.\n */\nexport class UfDateRangePicker extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n controlBoxStyles,\n css`\n .box {\n padding-inline-end: 0;\n }\n\n .native {\n width: 0;\n text-align: center;\n }\n\n .separator {\n flex: none;\n color: var(--uf-color-text-muted);\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 'start',\n 'end',\n 'min',\n 'max',\n 'isDateDisabled',\n ]);\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false, noAccessor: true },\n start: { attribute: false },\n end: { 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 first date of the range, as `YYYY-MM-DD`, or an empty string. */\n declare start: string;\n /** The last date of the range, as `YYYY-MM-DD`, or an empty string. */\n declare end: string;\n /** Initial range, restored on form reset. Set with the `value` attribute, as `YYYY-MM-DD/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 in both inputs 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 dates. */\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-range-picker');\n /** What the user typed in each input and hasn't committed yet; null shows the date, formatted. */\n #text: Record<End, string | null> = { start: null, end: null };\n /** The committed text of an input isn't a date. */\n #bad: Record<End, boolean> = { start: false, end: false };\n #cleanup?: () => void;\n #focusWasInside = false;\n #toggling = false;\n\n constructor() {\n super();\n this.start = '';\n this.end = '';\n this.defaultValue = '';\n this.size = 'md';\n this.readonly = false;\n this.open = false;\n }\n\n /** The range as an ISO 8601 interval, `YYYY-MM-DD/YYYY-MM-DD`, or an empty string until both dates are set. */\n get value(): string {\n return this.start && this.end ? `${this.start}/${this.end}` : '';\n }\n\n set value(value: string) {\n const old = this.value;\n [this.start, this.end] = splitInterval(value);\n this.requestUpdate('value', old);\n }\n\n #input(which: End): HTMLInputElement | null {\n return this.renderRoot.querySelector(`[data-end=\"${which}\"]`);\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 === splitInterval(changed.get('defaultValue')).filter(Boolean).join('/')) {\n [this.start, this.end] = splitInterval(this.defaultValue);\n }\n // Dates set from code replace what was typed.\n for (const which of ['start', 'end'] as const) {\n if (changed.has(which)) {\n this.#text[which] = null;\n this.#bad[which] = false;\n }\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 if (!popup || this.#toggling) return;\n if (this.open && !popup.matches(':popover-open')) {\n popup.showPopover();\n this.#startPositioning();\n } else if (!this.open && popup.matches(':popover-open')) {\n popup.hidePopover();\n }\n }\n\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 #onBeforeToggle = (event: ToggleEvent): void => {\n // Same as <uf-date-picker>: keeps `open` right at once, and positions the\n // popup before its first paint.\n this.#toggling = true;\n this.open = event.newState === 'open';\n if (event.newState === 'open') requestAnimationFrame(() => this.#startPositioning());\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 // Closed (or reopened) from code before the browser finished: catch up now.\n if ((event.newState === 'open') !== this.open) {\n this.#syncPopup();\n return;\n }\n if (event.newState === 'open') {\n this.#startPositioning();\n this.#calendar?.updateComplete.then(() => this.#calendar?.focus());\n this.dispatchEvent(new Event('uf-show'));\n } else {\n this.#cleanup?.();\n this.#cleanup = undefined;\n if (this.#focusWasInside) this.#input('start')?.focus();\n this.#focusWasInside = false;\n this.dispatchEvent(new Event('uf-hide'));\n }\n };\n\n protected syncFormState(): void {\n const startInput = this.#input('start');\n const endInput = this.#input('end');\n if (!startInput || !endInput) return;\n this.internals.setFormValue(this.value);\n const t = this.translator;\n const lang = t.lang;\n const start = parseIso(this.start);\n const end = parseIso(this.end);\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 const example = () => t.t('invalidDate', { example: formatShort(parseIso(todayIso())!, lang) });\n\n if (this.#bad.start || this.#bad.end) {\n this.setValidity({ badInput: true }, example(), this.#bad.start ? startInput : endInput);\n } else if (this.required && !start && !end) {\n this.setValidity({ valueMissing: true }, valueMissingMessage(), startInput);\n } else if (Boolean(start) !== Boolean(end)) {\n this.setValidity({ badInput: true }, t.t('rangeIncomplete'), start ? endInput : startInput);\n } else if (start && end && end < start) {\n this.setValidity({ badInput: true }, t.t('endBeforeStart'), endInput);\n } else if (start && min && start < min) {\n this.setValidity({ rangeUnderflow: true }, t.t('dateTooEarly', { date: long(min) }), startInput);\n } else if (end && max && end > max) {\n this.setValidity({ rangeOverflow: true }, t.t('dateTooLate', { date: long(max) }), endInput);\n } else if (start && this.isDateDisabled?.(this.start)) {\n this.setValidity({ badInput: true }, t.t('dateUnavailable'), startInput);\n } else if (end && this.isDateDisabled?.(this.end)) {\n this.setValidity({ badInput: true }, t.t('dateUnavailable'), endInput);\n } else {\n this.setValidity({}, '', startInput);\n }\n }\n\n protected resetValue(): void {\n [this.start, this.end] = splitInterval(this.defaultValue);\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n [this.start, this.end] = splitInterval(state);\n }\n\n /** Sets the dates from the user, and tells listeners when they changed. */\n #commit(start: string, end: string): void {\n const changed = start !== this.start || end !== this.end;\n this.start = start;\n this.end = end;\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 of one input into its date: a date, empty, or invalid. */\n #commitText(which: End): void {\n const typed = this.#text[which];\n if (typed === null) return;\n const text = typed.trim();\n const date = text ? parseTyped(text, this.translator.lang) : null;\n const iso = date ? toIso(date) : '';\n this.#commit(which === 'start' ? iso : this.start, which === 'end' ? iso : this.end);\n // Not a date: keep the text so the user can fix it, and report it.\n this.#text[which] = text && !date ? text : null;\n this.#bad[which] = Boolean(text && !date);\n this.syncFormState();\n this.requestUpdate();\n }\n\n #onInput = (which: End) => (event: Event) => {\n // The dates change when committed, not on every keystroke.\n event.stopPropagation();\n this.#text[which] = (event.target as HTMLInputElement).value;\n };\n\n #onKeyDown = (which: End) => (event: KeyboardEvent) => {\n if (event.key === 'Enter') this.#commitText(which);\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 const calendar = event.target as UfCalendar;\n this.#commit(calendar.start, calendar.end);\n this.hide();\n this.#input('end')?.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 #renderInput(which: End, ids: { hintId: string; errorId: string }, error: string, hasHintSlot: boolean) {\n const date = parseIso(this[which]);\n const text = this.#text[which] ?? (date ? formatShort(date, this.translator.lang) : '');\n const name = this.translator.t(which === 'start' ? 'startDate' : 'endDate');\n return html`<input\n id=${which === 'start' ? this.#id : `${this.#id}-end`}\n class=\"native\"\n part=${`${which}-input`}\n data-end=${which}\n type=\"text\"\n autocomplete=\"off\"\n .value=${live(text)}\n placeholder=${this.#placeholder()}\n aria-label=${this.label ? `${this.label}, ${name}` : name}\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(which)}\n @change=${() => this.#commitText(which)}\n @keydown=${this.#onKeyDown(which)}\n />`;\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\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 ${this.#renderInput('start', ids, error, hasHintSlot)}\n <span class=\"separator\" part=\"separator\" aria-hidden=\"true\">–</span>\n ${this.#renderInput('end', ids, error, hasHintSlot)}\n <button\n class=${classMap({ toggle: true, open: this.open })}\n part=\"toggle\"\n type=\"button\"\n aria-label=${this.translator.t('chooseDates')}\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('chooseDates')}\n @beforetoggle=${this.#onBeforeToggle}\n @toggle=${this.#onToggle}\n >\n <uf-calendar\n part=\"calendar\"\n range\n .start=${live(this.start)}\n .end=${live(this.end)}\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-range-picker', UfDateRangePicker);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-date-range-picker': UfDateRangePicker;\n }\n}\n",
854
872
  "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-control);\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'));\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'));\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'));\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",
855
873
  "components/divider/divider.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController } from '../../internal/slot.js';\n\nexport type DividerOrientation = 'horizontal' | 'vertical';\n\n/**\n * A line between groups of content, across or beside them. Assistive tech\n * announces it as a separator. With a label (\"or\"), the label is read as plain\n * text and the line around it is decorative.\n *\n * @summary Separates groups of content with a line.\n * @tag uf-divider\n *\n * @slot - An optional label in the middle of the line, like \"or\".\n *\n * @csspart base - The line, or the wrapper around a labelled one.\n * @csspart label - The label.\n *\n * @cssprop --uf-divider-color - Color of the line.\n * @cssprop --uf-divider-width - Thickness of the line.\n * @cssprop --uf-divider-spacing - Space before and after the line.\n */\nexport class UfDivider extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n --_color: var(--uf-divider-color, var(--uf-color-border));\n --_width: var(--uf-divider-width, 1px);\n --_spacing: var(--uf-divider-spacing, var(--uf-space-4));\n display: block;\n margin-block: var(--_spacing);\n }\n\n :host([orientation='vertical']) {\n display: inline-flex;\n align-self: stretch;\n min-height: 1em;\n margin-block: 0;\n margin-inline: var(--_spacing);\n vertical-align: middle;\n }\n\n .base {\n display: flex;\n align-items: center;\n gap: var(--uf-space-3);\n height: 100%;\n color: var(--uf-color-text-muted);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-sm);\n }\n\n :host([orientation='vertical']) .base {\n flex-direction: column;\n }\n\n .line {\n flex: 1;\n border-top: var(--_width) solid var(--_color);\n }\n\n :host([orientation='vertical']) .line {\n border-top: 0;\n border-inline-start: var(--_width) solid var(--_color);\n }\n\n .label {\n flex: none;\n }\n\n [hidden] {\n display: none !important;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n orientation: { reflect: true },\n };\n\n /** `horizontal` (across the content) or `vertical` (between items in a row). */\n declare orientation: DividerOrientation;\n\n constructor() {\n super();\n this.orientation = 'horizontal';\n // Re-renders when a label is added or removed.\n new HasSlotController(this, '');\n }\n\n override render() {\n // A separator's content isn't read, so a labelled divider is plain text between two decorative lines.\n const labelled = [...this.childNodes].some((n) => (n.nodeType === Node.ELEMENT_NODE ? !(n as Element).slot : n.textContent?.trim()));\n return labelled\n ? html`<div class=\"base\" part=\"base\">\n <span class=\"line\" aria-hidden=\"true\"></span>\n <span class=\"label\" part=\"label\"><slot></slot></span>\n <span class=\"line\" aria-hidden=\"true\"></span>\n </div>`\n : html`<div class=\"base\" part=\"base\" role=\"separator\" aria-orientation=${this.orientation}>\n <span class=\"line\"></span>\n <slot hidden></slot>\n </div>`;\n }\n}\n\ndefineElement('uf-divider', UfDivider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-divider': UfDivider;\n }\n}\n",
856
- "components/drawer/drawer.ts": "import { css, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { UfDialog } from '../dialog/dialog.js';\n\nexport type DrawerPlacement = 'start' | 'end' | 'top' | 'bottom';\n\n/**\n * A panel that slides in from an edge of the screen, for navigation, filters or\n * details. It is a modal dialog, so it behaves like `<uf-dialog>`: it traps\n * focus, makes the page inert, closes with Escape, and returns focus to the\n * opener. Any element inside with `data-dialog=\"close\"` closes it.\n *\n * @summary A panel that slides in from an edge of the screen.\n * @tag uf-drawer\n *\n * @slot - The drawer 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 drawer opened.\n * @event uf-hide - The drawer closed.\n * @event {CustomEvent<DialogRequestCloseDetail>} uf-request-close - The user tried to close the drawer. 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-drawer-size - Width of a side drawer, or height of a top or bottom one. Defaults to `24rem`.\n * @cssprop --uf-drawer-radius - Corner radius of the corners on the open side; the side against the screen edge stays square.\n * @cssprop --uf-dialog-bg - Background of the drawer.\n * @cssprop --uf-dialog-padding - Padding of header, body and footer.\n * @cssprop --uf-dialog-backdrop - Backdrop color.\n */\nexport class UfDrawer extends UfDialog {\n static override styles = [\n ...UfDialog.styles,\n css`\n dialog {\n --_size: min(var(--uf-drawer-size, 24rem), 100vw);\n --_radius: var(--uf-drawer-radius, var(--uf-radius-md));\n --_from: 100% 0;\n position: fixed;\n inset: 0 0 0 auto;\n width: var(--_size);\n max-width: 100vw;\n height: 100dvh;\n max-height: 100dvh;\n margin: 0;\n border-width: 0 0 0 1px;\n border-radius: var(--_radius) 0 0 var(--_radius);\n /* Even on every side: the dialog's shadow falls downward, too far below a top drawer and off screen for a bottom one. */\n box-shadow: var(--uf-shadow-drawer);\n }\n\n :host([placement='start']) dialog {\n --_from: -100% 0;\n inset: 0 auto 0 0;\n border-width: 0 1px 0 0;\n border-radius: 0 var(--_radius) var(--_radius) 0;\n }\n\n /* Right-to-left pages: start is on the right, end on the left. */\n :host(:dir(rtl)) dialog {\n --_from: -100% 0;\n inset: 0 auto 0 0;\n border-width: 0 1px 0 0;\n border-radius: 0 var(--_radius) var(--_radius) 0;\n }\n\n :host(:dir(rtl)[placement='start']) dialog {\n --_from: 100% 0;\n inset: 0 0 0 auto;\n border-width: 0 0 0 1px;\n border-radius: var(--_radius) 0 0 var(--_radius);\n }\n\n :host([placement='top']) dialog,\n :host([placement='bottom']) dialog {\n --_size: min(var(--uf-drawer-size, 24rem), 100dvh);\n width: 100vw;\n height: var(--_size);\n }\n\n :host([placement='top']) dialog {\n --_from: 0 -100%;\n inset: 0 0 auto 0;\n border-width: 0 0 1px 0;\n border-radius: 0 0 var(--_radius) var(--_radius);\n }\n\n :host([placement='bottom']) dialog {\n --_from: 0 100%;\n inset: auto 0 0 0;\n border-width: 1px 0 0 0;\n border-radius: var(--_radius) var(--_radius) 0 0;\n }\n\n dialog[open] {\n animation-name: uf-drawer-in;\n }\n\n dialog.closing {\n animation-name: uf-drawer-out;\n }\n\n @keyframes uf-drawer-in {\n from {\n translate: var(--_from);\n }\n }\n\n @keyframes uf-drawer-out {\n to {\n translate: var(--_from);\n }\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n placement: { reflect: true },\n };\n\n /** The edge it slides in from: `start` (left, in left-to-right pages), `end`, `top` or `bottom`. */\n declare placement: DrawerPlacement;\n\n constructor() {\n super();\n this.placement = 'end';\n }\n}\n\ndefineElement('uf-drawer', UfDrawer);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-drawer': UfDrawer;\n }\n}\n",
874
+ "components/drawer/drawer.ts": "import { css, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { UfDialog } from '../dialog/dialog.js';\n\nexport type DrawerPlacement = 'start' | 'end' | 'top' | 'bottom';\n\n/**\n * A panel that slides in from an edge of the screen, for navigation, filters or\n * details. It is a modal dialog, so it behaves like `<uf-dialog>`: it traps\n * focus, makes the page inert, closes with Escape, and returns focus to the\n * opener. Any element inside with `data-dialog=\"close\"` closes it.\n *\n * @summary A panel that slides in from an edge of the screen.\n * @tag uf-drawer\n *\n * @slot - The drawer 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 drawer opened.\n * @event uf-hide - The drawer closed.\n * @event {CustomEvent<DialogRequestCloseDetail>} uf-request-close - The user tried to close the drawer. 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-drawer-size - Width of a side drawer, or height of a top or bottom one. Defaults to `24rem`.\n * @cssprop --uf-drawer-gap - Space between the drawer and the screen's edges. `0` puts it against the edge. Defaults to `--uf-space-3`.\n * @cssprop --uf-drawer-radius - Corner radius.\n * @cssprop --uf-dialog-bg - Background of the drawer.\n * @cssprop --uf-dialog-padding - Padding of header, body and footer.\n * @cssprop --uf-dialog-backdrop - Backdrop color.\n */\nexport class UfDrawer extends UfDialog {\n static override styles = [\n ...UfDialog.styles,\n css`\n /*\n * A panel floating a gap away from the screen's edges, on top of the page.\n * With --uf-drawer-gap: 0 it sits against the edge, like a classic drawer.\n */\n dialog {\n --_gap: var(--uf-drawer-gap, var(--uf-space-3));\n --_size: min(var(--uf-drawer-size, 24rem), 100vw - 2 * var(--_gap));\n --_from: calc(100% + var(--_gap)) 0;\n position: fixed;\n inset: var(--_gap) var(--_gap) var(--_gap) auto;\n width: var(--_size);\n max-width: none;\n height: calc(100dvh - 2 * var(--_gap));\n max-height: none;\n margin: 0;\n border-radius: var(--uf-drawer-radius, var(--uf-radius-md));\n /* Even on every side: the dialog's shadow falls downward, too far below a top drawer and off screen for a bottom one. */\n box-shadow: var(--uf-shadow-drawer);\n }\n\n /* Right-to-left pages: start is on the right, end on the left. */\n :host([placement='start']) dialog,\n :host(:dir(rtl):not([placement='start'])) dialog {\n --_from: calc(-100% - var(--_gap)) 0;\n inset: var(--_gap) auto var(--_gap) var(--_gap);\n }\n\n :host(:dir(rtl)[placement='start']) dialog {\n --_from: calc(100% + var(--_gap)) 0;\n inset: var(--_gap) var(--_gap) var(--_gap) auto;\n }\n\n :host([placement='top']) dialog,\n :host([placement='bottom']) dialog {\n --_size: min(var(--uf-drawer-size, 24rem), 100dvh - 2 * var(--_gap));\n width: calc(100vw - 2 * var(--_gap));\n height: var(--_size);\n }\n\n :host([placement='top']) dialog {\n --_from: 0 calc(-100% - var(--_gap));\n inset: var(--_gap) var(--_gap) auto;\n }\n\n :host([placement='bottom']) dialog {\n --_from: 0 calc(100% + var(--_gap));\n inset: auto var(--_gap) var(--_gap);\n }\n\n dialog[open] {\n animation-name: uf-drawer-in;\n }\n\n dialog.closing {\n animation-name: uf-drawer-out;\n }\n\n @keyframes uf-drawer-in {\n from {\n translate: var(--_from);\n }\n }\n\n @keyframes uf-drawer-out {\n to {\n translate: var(--_from);\n }\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n placement: { reflect: true },\n };\n\n /** The edge it slides in from: `start` (left, in left-to-right pages), `end`, `top` or `bottom`. */\n declare placement: DrawerPlacement;\n\n constructor() {\n super();\n this.placement = 'end';\n }\n}\n\ndefineElement('uf-drawer', UfDrawer);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-drawer': UfDrawer;\n }\n}\n",
857
875
  "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",
858
876
  "components/empty-state/empty-state.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController } from '../../internal/slot.js';\nimport '../icon/icon.js';\n\n/**\n * What to show where content would be: an empty list, no search results, a\n * first visit. An icon, a heading, a short explanation and what to do next.\n *\n * The `heading` attribute is bold text. For a real heading in the page's\n * outline, put an `<h2>` or `<h3>` in the `heading` slot.\n *\n * @summary Fills an empty list or page with a message and what to do next.\n * @tag uf-empty-state\n *\n * @slot - The explanation.\n * @slot heading - The heading, when you need markup or a heading level. Overrides `heading`.\n * @slot icon - Replaces the icon.\n * @slot actions - Buttons or links, like \"Create a project\".\n *\n * @csspart base - The empty state.\n * @csspart icon - The icon.\n * @csspart heading - The heading.\n * @csspart description - The explanation.\n * @csspart actions - The wrapper around the actions.\n *\n * @cssprop --uf-empty-state-icon-size - Size of the icon.\n * @cssprop --uf-empty-state-icon-color - Color of the icon.\n * @cssprop --uf-empty-state-padding - Space around the content.\n */\nexport class UfEmptyState extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: block;\n }\n\n .base {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--uf-space-2);\n max-width: 28rem;\n margin-inline: auto;\n padding: var(--uf-empty-state-padding, var(--uf-space-6) var(--uf-space-4));\n color: var(--uf-color-text-muted);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n line-height: 1.5;\n text-align: center;\n }\n\n .icon {\n display: inline-flex;\n margin-bottom: var(--uf-space-2);\n color: var(--uf-empty-state-icon-color, var(--uf-color-accent));\n font-size: var(--uf-empty-state-icon-size, 2.5rem);\n }\n\n .icon uf-icon,\n ::slotted([slot='icon']) {\n --uf-icon-size: 1em;\n width: 1em;\n height: 1em;\n }\n\n .heading {\n color: var(--uf-color-text);\n font-size: var(--uf-font-size-lg);\n font-weight: var(--uf-font-weight-semibold);\n }\n\n /* A heading element in the slot: the same look, without its default margins. */\n ::slotted([slot='heading']) {\n margin: 0;\n font: inherit;\n }\n\n .actions {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: var(--uf-space-2);\n margin-top: var(--uf-space-3);\n }\n\n [hidden] {\n display: none !important;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n heading: {},\n icon: {},\n };\n\n /** Bold text above the explanation. */\n declare heading: string | undefined;\n /** A built-in or registered icon name. An empty string hides the icon. */\n declare icon: string;\n\n readonly #slots = new HasSlotController(this, 'heading', 'icon', 'actions');\n\n constructor() {\n super();\n this.icon = 'inbox';\n }\n\n override render() {\n const hasIcon = Boolean(this.icon) || this.#slots.has('icon');\n const hasHeading = Boolean(this.heading) || this.#slots.has('heading');\n return html`\n <div class=\"base\" part=\"base\">\n <span class=\"icon\" part=\"icon\" aria-hidden=\"true\" ?hidden=${!hasIcon}>\n <slot name=\"icon\">${this.icon ? html`<uf-icon name=${this.icon}></uf-icon>` : nothing}</slot>\n </span>\n <div class=\"heading\" part=\"heading\" ?hidden=${!hasHeading}><slot name=\"heading\">${this.heading ?? nothing}</slot></div>\n <div class=\"description\" part=\"description\"><slot></slot></div>\n <div class=\"actions\" part=\"actions\" ?hidden=${!this.#slots.has('actions')}><slot name=\"actions\"></slot></div>\n </div>\n `;\n }\n}\n\ndefineElement('uf-empty-state', UfEmptyState);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-empty-state': UfEmptyState;\n }\n}\n",
859
- "components/file-upload/file-upload.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, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\n/** Whether a file matches an `accept` list: extensions (`.pdf`), MIME types (`image/png`) or wildcards (`image/*`). */\nfunction accepts(file: File, accept: string | undefined): boolean {\n const tokens = (accept ?? '')\n .split(',')\n .map((token) => token.trim().toLowerCase())\n .filter(Boolean);\n if (!tokens.length) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return tokens.some((token) =>\n token.startsWith('.') ? name.endsWith(token) : token.endsWith('/*') ? type.startsWith(token.slice(0, -1)) : type === token,\n );\n}\n\n/** A size in the language's format, in bytes, kB, MB or GB. */\nfunction formatSize(bytes: number, lang: string): string {\n const units = ['byte', 'kilobyte', 'megabyte', 'gigabyte'] as const;\n let value = bytes;\n let unit = 0;\n while (value >= 1000 && unit < units.length - 1) {\n value /= 1000;\n unit += 1;\n }\n try {\n return new Intl.NumberFormat(lang || undefined, { style: 'unit', unit: units[unit], unitDisplay: 'short', maximumFractionDigits: unit ? 1 : 0 }).format(value);\n } catch {\n return `${Math.round(value * 10) / 10} ${['B', 'kB', 'MB', 'GB'][unit]}`;\n }\n}\n\n/**\n * Picks files to send with a form: from a button, or by dragging them onto the\n * drop zone. The chosen files are listed with their size and a remove button.\n * Files that don't match `accept` or are larger than `max-size` are refused,\n * with a message saying why. It submits like a native `<input type=\"file\">`.\n *\n * @summary Lets users choose files to upload.\n * @tag uf-file-upload\n *\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the label. Overrides `hint`.\n *\n * @event input - Fired when files are added or removed.\n * @event change - Fired when files are added or removed.\n *\n * @csspart field - The wrapper around label, drop zone, files, hint and error.\n * @csspart form-label - The label.\n * @csspart dropzone - The area files can be dropped on.\n * @csspart button - The button that opens the file picker.\n * @csspart files - The list of chosen files.\n * @csspart file - A chosen file.\n * @csspart remove-button - A file's remove button.\n * @csspart rejected - Why files were refused.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-file-upload-border-color - Border color of the drop zone.\n * @cssprop --uf-file-upload-bg - Background of the drop zone.\n * @cssprop --uf-file-upload-radius - Corner radius of the drop zone. Defaults to the theme's control radius.\n * @cssprop --uf-file-upload-active-color - Border and background tint while files are dragged over.\n *\n * @cssstate user-invalid - Required but empty, after the user interacted.\n */\nexport class UfFileUpload extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n css`\n .dropzone {\n --_active: var(--uf-file-upload-active-color, var(--uf-color-accent-strong));\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--uf-space-2);\n padding: var(--_padding, var(--uf-space-5) var(--uf-space-4));\n border: 1px solid var(--uf-file-upload-border-color, var(--uf-color-border-strong));\n /* Like the fields: square by default, following the theme's control radius. */\n border-radius: var(--uf-file-upload-radius, var(--uf-radius-control));\n background: var(--uf-file-upload-bg, transparent);\n color: var(--uf-color-text-muted);\n font-size: var(--_font-size, var(--uf-font-size-sm));\n text-align: center;\n transition:\n border-color var(--uf-duration-fast) ease,\n background-color var(--uf-duration-fast) ease;\n }\n\n :host([size='sm']) {\n --_padding: var(--uf-space-3) var(--uf-space-4);\n --_icon: 1.25rem;\n }\n\n :host([size='lg']) {\n --_padding: var(--uf-space-6) var(--uf-space-5);\n --_icon: 2.25rem;\n --_font-size: var(--uf-font-size-md);\n }\n\n .dropzone > .icon {\n width: var(--_icon, 1.75rem);\n height: var(--_icon, 1.75rem);\n color: var(--uf-color-text-muted);\n }\n\n /* Files dragged over it: an accent border, thicker like a focused field. */\n .dropzone.dragging {\n border-color: var(--_active);\n box-shadow: inset 0 0 0 1px var(--_active);\n background: color-mix(in srgb, var(--_active) 8%, transparent);\n }\n\n /* A 2px error outline, as on the fields. */\n .invalid .dropzone {\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, like disabled fields. */\n .dropzone.disabled {\n border-color: var(--uf-color-border);\n background: var(--uf-color-neutral-fill);\n }\n\n .browse {\n min-height: var(--uf-size-control-sm);\n padding: 0 var(--uf-space-3);\n border: 1px solid var(--uf-color-border-strong);\n border-radius: var(--uf-radius-control);\n background: var(--uf-color-surface);\n color: var(--uf-color-text);\n font: inherit;\n font-weight: var(--uf-font-weight-medium);\n cursor: pointer;\n }\n\n .browse:hover:not(:disabled) {\n border-color: var(--uf-color-accent-strong);\n color: var(--uf-color-accent-strong);\n }\n\n .browse:focus-visible {\n ${focusRing}\n }\n\n .browse:disabled {\n color: var(--uf-color-text-muted);\n cursor: not-allowed;\n }\n\n .native {\n position: absolute;\n width: 1px;\n height: 1px;\n opacity: 0;\n pointer-events: none;\n }\n\n .files {\n display: grid;\n gap: var(--uf-space-1);\n margin: var(--uf-space-2) 0 0;\n padding: 0;\n list-style: none;\n }\n\n .file {\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-1) 0 var(--uf-space-3);\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-radius-control);\n font-size: var(--uf-font-size-sm);\n color: var(--uf-color-text);\n }\n\n .file > .icon {\n flex: none;\n width: 1rem;\n height: 1rem;\n color: var(--uf-color-text-muted);\n }\n\n .name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .size {\n flex: none;\n color: var(--uf-color-text-muted);\n font-variant-numeric: tabular-nums;\n }\n\n .remove {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n padding: 0;\n border: 0;\n border-radius: var(--uf-radius-sm);\n background: transparent;\n color: var(--uf-color-text-muted);\n cursor: pointer;\n }\n\n .remove:hover:not(:disabled) {\n background: var(--uf-color-surface-hover);\n color: var(--uf-color-text);\n }\n\n .remove:focus-visible {\n ${focusRing}\n }\n\n .remove .icon {\n width: 1rem;\n height: 1rem;\n }\n\n .rejected {\n margin: var(--uf-space-1) 0 0;\n color: var(--uf-color-danger-text);\n font-size: var(--uf-font-size-sm);\n }\n\n .rejected:empty {\n display: none;\n }\n\n [hidden] {\n display: none !important;\n }\n `,\n ];\n\n protected static override formStateProperties: ReadonlySet<PropertyKey> = new Set([...FormControl.formStateProperties, 'files']);\n\n static override properties: PropertyDeclarations = {\n files: { attribute: false },\n label: {},\n hint: {},\n accept: {},\n multiple: { type: Boolean, reflect: true },\n maxSize: { type: Number, attribute: 'max-size' },\n size: { reflect: true },\n };\n\n /** The chosen files. Set it to `[]` to clear them. */\n declare files: File[];\n /** Visible label. */\n declare label: string | undefined;\n /** Help text, e.g. the accepted types and size. */\n declare hint: string | undefined;\n /** Accepted files, as in a native file input: extensions (`.pdf`), MIME types (`image/png`) or wildcards (`image/*`), comma-separated. */\n declare accept: string | undefined;\n /** Lets users choose more than one file. */\n declare multiple: boolean;\n /** Largest accepted file, in bytes, e.g. `5000000` for 5 MB. */\n declare maxSize: number | undefined;\n /** Size of the drop zone: `sm`, `md` or `lg`. */\n declare size: FieldSize;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-file-upload');\n #dragging = false;\n #rejected: string[] = [];\n\n constructor() {\n super();\n this.files = [];\n this.multiple = false;\n this.size = 'md';\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('.native');\n }\n\n get #button(): HTMLButtonElement | null {\n return this.renderRoot.querySelector('.browse');\n }\n\n /** Opens the file picker. */\n showPicker(): void {\n if (!this.isDisabled) this.#input?.click();\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('multiple') && !this.multiple && this.files.length > 1) this.files = this.files.slice(0, 1);\n }\n\n override updated(): void {\n this.syncFormState();\n }\n\n protected syncFormState(): void {\n if (!this.hasUpdated) return;\n if (this.files.length && this.name) {\n const data = new FormData();\n for (const file of this.files) data.append(this.name, file);\n this.internals.setFormValue(data);\n } else {\n this.internals.setFormValue(null);\n }\n const missing = this.required && !this.files.length;\n this.setValidity({ valueMissing: missing }, missing ? this.#missingMessage() : '', this.#button ?? undefined);\n }\n\n /** The browser's own \"Please select a file\" message, in the user's language. */\n #missingMessage(): string {\n const probe = document.createElement('input');\n probe.type = 'file';\n probe.required = true;\n return probe.validationMessage;\n }\n\n protected resetValue(): void {\n this.files = [];\n this.#rejected = [];\n }\n\n /** Adds files, refusing those that don't fit `accept` and `max-size`. */\n #add(list: FileList | File[]): void {\n const lang = this.translator.lang;\n const rejected: string[] = [];\n const added: File[] = [];\n for (const file of list) {\n if (!accepts(file, this.accept)) rejected.push(this.translator.t('fileTypeRejected', { name: file.name }));\n else if (this.maxSize && file.size > this.maxSize) rejected.push(this.translator.t('fileTooLarge', { name: file.name, size: formatSize(this.maxSize, lang) }));\n else added.push(file);\n }\n this.#rejected = rejected;\n if (added.length) {\n // A new pick replaces the file of a single upload; with `multiple`, files add up (same name and size: kept once).\n const kept = this.multiple ? this.files.filter((f) => !added.some((a) => a.name === f.name && a.size === f.size)) : [];\n this.files = this.multiple ? [...kept, ...added] : added.slice(0, 1);\n this.#changed();\n } else {\n this.requestUpdate();\n }\n }\n\n #remove(index: number): void {\n this.files = this.files.filter((_, i) => i !== index);\n this.#rejected = [];\n this.#changed();\n // Focus moves to the next file's remove button, or the picker button, so it isn't lost.\n void this.updateComplete.then(() => {\n const buttons = this.renderRoot.querySelectorAll<HTMLButtonElement>('.remove');\n (buttons[Math.min(index, buttons.length - 1)] ?? this.#button)?.focus();\n });\n }\n\n #changed(): void {\n this.markInteracted();\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n this.emitChange();\n }\n\n #onPick = (event: Event): void => {\n event.stopPropagation();\n const input = event.target as HTMLInputElement;\n if (input.files?.length) this.#add(input.files);\n // Cleared, so choosing the same file again still fires `change`.\n input.value = '';\n };\n\n #onDragOver = (event: DragEvent): void => {\n if (this.isDisabled || !event.dataTransfer?.types.includes('Files')) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n if (!this.#dragging) {\n this.#dragging = true;\n this.requestUpdate();\n }\n };\n\n #onDragLeave = (event: DragEvent): void => {\n if ((event.currentTarget as Element).contains(event.relatedTarget as Node)) return;\n this.#dragging = false;\n this.requestUpdate();\n };\n\n #onDrop = (event: DragEvent): void => {\n event.preventDefault();\n this.#dragging = false;\n if (this.isDisabled || !event.dataTransfer?.files.length) {\n this.requestUpdate();\n return;\n }\n const files = [...event.dataTransfer.files];\n this.#add(this.multiple ? files : files.slice(0, 1));\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 const lang = this.translator.lang;\n const choose = this.translator.t(this.multiple ? 'chooseFiles' : 'chooseFile');\n\n return renderField({\n ...ids,\n controlId: `${this.#id}-input`,\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\n class=${classMap({ dropzone: true, dragging: this.#dragging, disabled })}\n part=\"dropzone\"\n @dragover=${this.#onDragOver}\n @dragleave=${this.#onDragLeave}\n @drop=${this.#onDrop}\n >\n ${iconSvg(icons.upload)}\n <button\n class=\"browse\"\n part=\"button\"\n type=\"button\"\n ?disabled=${disabled}\n aria-label=${this.label ? `${choose}: ${this.label}` : choose}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @click=${() => this.showPicker()}\n >\n ${choose}\n </button>\n <span>${this.translator.t(this.multiple ? 'dropFiles' : 'dropFile')}</span>\n <input\n id=${`${this.#id}-input`}\n class=\"native\"\n type=\"file\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n accept=${ifDefined(this.accept)}\n ?multiple=${this.multiple}\n ?disabled=${disabled}\n @change=${this.#onPick}\n @input=${(event: Event) => event.stopPropagation()}\n />\n </div>\n <ul class=\"files\" part=\"files\" ?hidden=${!this.files.length}>\n ${this.files.map(\n (file, i) => html`<li class=\"file\" part=\"file\">\n ${iconSvg(icons.file)}\n <span class=\"name\" title=${file.name}>${file.name}</span>\n <span class=\"size\">${formatSize(file.size, lang)}</span>\n <button\n class=\"remove\"\n part=\"remove-button\"\n type=\"button\"\n ?disabled=${disabled}\n aria-label=${this.translator.t('removeFile', { name: file.name })}\n @click=${() => this.#remove(i)}\n >\n ${iconSvg(icons.x)}\n </button>\n </li>`,\n )}\n </ul>\n <div class=\"rejected\" part=\"rejected\" role=\"status\">${this.#rejected.length ? this.#rejected.join(' ') : nothing}</div>\n `,\n });\n }\n}\n\ndefineElement('uf-file-upload', UfFileUpload);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-file-upload': UfFileUpload;\n }\n}\n",
877
+ "components/file-upload/file-upload.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, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\n/** Whether a file matches an `accept` list: extensions (`.pdf`), MIME types (`image/png`) or wildcards (`image/*`). */\nfunction accepts(file: File, accept: string | undefined): boolean {\n const tokens = (accept ?? '')\n .split(',')\n .map((token) => token.trim().toLowerCase())\n .filter(Boolean);\n if (!tokens.length) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return tokens.some((token) =>\n token.startsWith('.') ? name.endsWith(token) : token.endsWith('/*') ? type.startsWith(token.slice(0, -1)) : type === token,\n );\n}\n\n/** A size in the language's format, in bytes, kB, MB or GB. */\nfunction formatSize(bytes: number, lang: string): string {\n const units = ['byte', 'kilobyte', 'megabyte', 'gigabyte'] as const;\n let value = bytes;\n let unit = 0;\n while (value >= 1000 && unit < units.length - 1) {\n value /= 1000;\n unit += 1;\n }\n try {\n return new Intl.NumberFormat(lang || undefined, { style: 'unit', unit: units[unit], unitDisplay: 'short', maximumFractionDigits: unit ? 1 : 0 }).format(value);\n } catch {\n return `${Math.round(value * 10) / 10} ${['B', 'kB', 'MB', 'GB'][unit]}`;\n }\n}\n\n/**\n * Picks files to send with a form: from a button, or by dragging them onto the\n * drop zone. The chosen files are listed with their size and a remove button.\n * Files that don't match `accept` or are larger than `max-size` are refused,\n * with a message saying why. It submits like a native `<input type=\"file\">`.\n *\n * @summary Lets users choose files to upload.\n * @tag uf-file-upload\n *\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the label. Overrides `hint`.\n *\n * @event input - Fired when files are added or removed.\n * @event change - Fired when files are added or removed.\n *\n * @csspart field - The wrapper around label, drop zone, files, hint and error.\n * @csspart form-label - The label.\n * @csspart dropzone - The area files can be dropped on.\n * @csspart button - The button that opens the file picker.\n * @csspart files - The list of chosen files.\n * @csspart file - A chosen file.\n * @csspart remove-button - A file's remove button.\n * @csspart rejected - Why files were refused.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-file-upload-border-color - Border color of the drop zone.\n * @cssprop --uf-file-upload-bg - Background of the drop zone.\n * @cssprop --uf-file-upload-radius - Corner radius of the drop zone. Defaults to the theme's control radius.\n * @cssprop --uf-file-upload-active-color - Border and background tint while files are dragged over.\n *\n * @cssstate user-invalid - Required but empty, after the user interacted.\n */\nexport class UfFileUpload extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n css`\n .dropzone {\n --_active: var(--uf-file-upload-active-color, var(--uf-color-accent-strong));\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: var(--uf-space-2);\n padding: var(--_padding, var(--uf-space-5) var(--uf-space-4));\n border: 1px solid var(--uf-file-upload-border-color, var(--uf-color-border-strong));\n /* Like the fields: the theme's control radius. */\n border-radius: var(--uf-file-upload-radius, var(--uf-radius-control));\n background: var(--uf-file-upload-bg, transparent);\n color: var(--uf-color-text-muted);\n font-size: var(--_font-size, var(--uf-font-size-sm));\n text-align: center;\n transition:\n border-color var(--uf-duration-fast) ease,\n background-color var(--uf-duration-fast) ease;\n }\n\n :host([size='sm']) {\n --_padding: var(--uf-space-3) var(--uf-space-4);\n --_icon: 1.25rem;\n }\n\n :host([size='lg']) {\n --_padding: var(--uf-space-6) var(--uf-space-5);\n --_icon: 2.25rem;\n --_font-size: var(--uf-font-size-md);\n }\n\n .dropzone > .icon {\n width: var(--_icon, 1.75rem);\n height: var(--_icon, 1.75rem);\n color: var(--uf-color-text-muted);\n }\n\n /* Files dragged over it: an accent border, thicker like a focused field. */\n .dropzone.dragging {\n border-color: var(--_active);\n box-shadow: inset 0 0 0 1px var(--_active);\n background: color-mix(in srgb, var(--_active) 8%, transparent);\n }\n\n /* A 2px error outline, as on the fields. */\n .invalid .dropzone {\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, like disabled fields. */\n .dropzone.disabled {\n border-color: var(--uf-color-border);\n background: var(--uf-color-neutral-fill);\n }\n\n .browse {\n min-height: var(--uf-size-control-sm);\n padding: 0 var(--uf-space-3);\n border: 1px solid var(--uf-color-border-strong);\n border-radius: var(--uf-radius-control);\n background: var(--uf-color-surface);\n color: var(--uf-color-text);\n font: inherit;\n font-weight: var(--uf-font-weight-medium);\n cursor: pointer;\n }\n\n .browse:hover:not(:disabled) {\n border-color: var(--uf-color-accent-strong);\n color: var(--uf-color-accent-strong);\n }\n\n .browse:focus-visible {\n ${focusRing}\n }\n\n .browse:disabled {\n color: var(--uf-color-text-muted);\n cursor: not-allowed;\n }\n\n .native {\n position: absolute;\n width: 1px;\n height: 1px;\n opacity: 0;\n pointer-events: none;\n }\n\n .files {\n display: grid;\n gap: var(--uf-space-1);\n margin: var(--uf-space-2) 0 0;\n padding: 0;\n list-style: none;\n }\n\n .file {\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-1) 0 var(--uf-space-3);\n border: 1px solid var(--uf-color-border);\n border-radius: var(--uf-radius-control);\n font-size: var(--uf-font-size-sm);\n color: var(--uf-color-text);\n }\n\n .file > .icon {\n flex: none;\n width: 1rem;\n height: 1rem;\n color: var(--uf-color-text-muted);\n }\n\n .name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n .size {\n flex: none;\n color: var(--uf-color-text-muted);\n font-variant-numeric: tabular-nums;\n }\n\n .remove {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n padding: 0;\n border: 0;\n border-radius: var(--uf-radius-sm);\n background: transparent;\n color: var(--uf-color-text-muted);\n cursor: pointer;\n }\n\n .remove:hover:not(:disabled) {\n background: var(--uf-color-surface-hover);\n color: var(--uf-color-text);\n }\n\n .remove:focus-visible {\n ${focusRing}\n }\n\n .remove .icon {\n width: 1rem;\n height: 1rem;\n }\n\n .rejected {\n margin: var(--uf-space-1) 0 0;\n color: var(--uf-color-danger-text);\n font-size: var(--uf-font-size-sm);\n }\n\n .rejected:empty {\n display: none;\n }\n\n [hidden] {\n display: none !important;\n }\n `,\n ];\n\n protected static override formStateProperties: ReadonlySet<PropertyKey> = new Set([...FormControl.formStateProperties, 'files']);\n\n static override properties: PropertyDeclarations = {\n files: { attribute: false },\n label: {},\n hint: {},\n accept: {},\n multiple: { type: Boolean, reflect: true },\n maxSize: { type: Number, attribute: 'max-size' },\n size: { reflect: true },\n };\n\n /** The chosen files. Set it to `[]` to clear them. */\n declare files: File[];\n /** Visible label. */\n declare label: string | undefined;\n /** Help text, e.g. the accepted types and size. */\n declare hint: string | undefined;\n /** Accepted files, as in a native file input: extensions (`.pdf`), MIME types (`image/png`) or wildcards (`image/*`), comma-separated. */\n declare accept: string | undefined;\n /** Lets users choose more than one file. */\n declare multiple: boolean;\n /** Largest accepted file, in bytes, e.g. `5000000` for 5 MB. */\n declare maxSize: number | undefined;\n /** Size of the drop zone: `sm`, `md` or `lg`. */\n declare size: FieldSize;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-file-upload');\n #dragging = false;\n #rejected: string[] = [];\n\n constructor() {\n super();\n this.files = [];\n this.multiple = false;\n this.size = 'md';\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('.native');\n }\n\n get #button(): HTMLButtonElement | null {\n return this.renderRoot.querySelector('.browse');\n }\n\n /** Opens the file picker. */\n showPicker(): void {\n if (!this.isDisabled) this.#input?.click();\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('multiple') && !this.multiple && this.files.length > 1) this.files = this.files.slice(0, 1);\n }\n\n override updated(): void {\n this.syncFormState();\n }\n\n protected syncFormState(): void {\n if (!this.hasUpdated) return;\n if (this.files.length && this.name) {\n const data = new FormData();\n for (const file of this.files) data.append(this.name, file);\n this.internals.setFormValue(data);\n } else {\n this.internals.setFormValue(null);\n }\n const missing = this.required && !this.files.length;\n this.setValidity({ valueMissing: missing }, missing ? this.#missingMessage() : '', this.#button ?? undefined);\n }\n\n /** The browser's own \"Please select a file\" message, in the user's language. */\n #missingMessage(): string {\n const probe = document.createElement('input');\n probe.type = 'file';\n probe.required = true;\n return probe.validationMessage;\n }\n\n protected resetValue(): void {\n this.files = [];\n this.#rejected = [];\n }\n\n /** Adds files, refusing those that don't fit `accept` and `max-size`. */\n #add(list: FileList | File[]): void {\n const lang = this.translator.lang;\n const rejected: string[] = [];\n const added: File[] = [];\n for (const file of list) {\n if (!accepts(file, this.accept)) rejected.push(this.translator.t('fileTypeRejected', { name: file.name }));\n else if (this.maxSize && file.size > this.maxSize) rejected.push(this.translator.t('fileTooLarge', { name: file.name, size: formatSize(this.maxSize, lang) }));\n else added.push(file);\n }\n this.#rejected = rejected;\n if (added.length) {\n // A new pick replaces the file of a single upload; with `multiple`, files add up (same name and size: kept once).\n const kept = this.multiple ? this.files.filter((f) => !added.some((a) => a.name === f.name && a.size === f.size)) : [];\n this.files = this.multiple ? [...kept, ...added] : added.slice(0, 1);\n this.#changed();\n } else {\n this.requestUpdate();\n }\n }\n\n #remove(index: number): void {\n this.files = this.files.filter((_, i) => i !== index);\n this.#rejected = [];\n this.#changed();\n // Focus moves to the next file's remove button, or the picker button, so it isn't lost.\n void this.updateComplete.then(() => {\n const buttons = this.renderRoot.querySelectorAll<HTMLButtonElement>('.remove');\n (buttons[Math.min(index, buttons.length - 1)] ?? this.#button)?.focus();\n });\n }\n\n #changed(): void {\n this.markInteracted();\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n this.emitChange();\n }\n\n #onPick = (event: Event): void => {\n event.stopPropagation();\n const input = event.target as HTMLInputElement;\n if (input.files?.length) this.#add(input.files);\n // Cleared, so choosing the same file again still fires `change`.\n input.value = '';\n };\n\n #onDragOver = (event: DragEvent): void => {\n if (this.isDisabled || !event.dataTransfer?.types.includes('Files')) return;\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n if (!this.#dragging) {\n this.#dragging = true;\n this.requestUpdate();\n }\n };\n\n #onDragLeave = (event: DragEvent): void => {\n if ((event.currentTarget as Element).contains(event.relatedTarget as Node)) return;\n this.#dragging = false;\n this.requestUpdate();\n };\n\n #onDrop = (event: DragEvent): void => {\n event.preventDefault();\n this.#dragging = false;\n if (this.isDisabled || !event.dataTransfer?.files.length) {\n this.requestUpdate();\n return;\n }\n const files = [...event.dataTransfer.files];\n this.#add(this.multiple ? files : files.slice(0, 1));\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 const lang = this.translator.lang;\n const choose = this.translator.t(this.multiple ? 'chooseFiles' : 'chooseFile');\n\n return renderField({\n ...ids,\n controlId: `${this.#id}-input`,\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\n class=${classMap({ dropzone: true, dragging: this.#dragging, disabled })}\n part=\"dropzone\"\n @dragover=${this.#onDragOver}\n @dragleave=${this.#onDragLeave}\n @drop=${this.#onDrop}\n >\n ${iconSvg(icons.upload)}\n <button\n class=\"browse\"\n part=\"button\"\n type=\"button\"\n ?disabled=${disabled}\n aria-label=${this.label ? `${choose}: ${this.label}` : choose}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @click=${() => this.showPicker()}\n >\n ${choose}\n </button>\n <span>${this.translator.t(this.multiple ? 'dropFiles' : 'dropFile')}</span>\n <input\n id=${`${this.#id}-input`}\n class=\"native\"\n type=\"file\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n accept=${ifDefined(this.accept)}\n ?multiple=${this.multiple}\n ?disabled=${disabled}\n @change=${this.#onPick}\n @input=${(event: Event) => event.stopPropagation()}\n />\n </div>\n <ul class=\"files\" part=\"files\" ?hidden=${!this.files.length}>\n ${this.files.map(\n (file, i) => html`<li class=\"file\" part=\"file\">\n ${iconSvg(icons.file)}\n <span class=\"name\" title=${file.name}>${file.name}</span>\n <span class=\"size\">${formatSize(file.size, lang)}</span>\n <button\n class=\"remove\"\n part=\"remove-button\"\n type=\"button\"\n ?disabled=${disabled}\n aria-label=${this.translator.t('removeFile', { name: file.name })}\n @click=${() => this.#remove(i)}\n >\n ${iconSvg(icons.x)}\n </button>\n </li>`,\n )}\n </ul>\n <div class=\"rejected\" part=\"rejected\" role=\"status\">${this.#rejected.length ? this.#rejected.join(' ') : nothing}</div>\n `,\n });\n }\n}\n\ndefineElement('uf-file-upload', UfFileUpload);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-file-upload': UfFileUpload;\n }\n}\n",
860
878
  "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",
861
879
  "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 { submitOnEnter } from '../../internal/implicit-submission.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 #onKeyDown = (event: KeyboardEvent): void => submitOnEnter(event, this.form);\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 @keydown=${this.#onKeyDown}\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",
862
880
  "internal/implicit-submission.ts": "const submitTypes = new Set(['submit', 'image']);\n\nfunction isSubmitButton(el: Element): boolean {\n if (el instanceof HTMLButtonElement) return el.type === 'submit';\n if (el instanceof HTMLInputElement) return submitTypes.has(el.type);\n // The property, not the attribute: frameworks may set only the property.\n return el.localName === 'uf-button' && (el as Element & { type?: string }).type === 'submit';\n}\n\n/** Fields where Enter submits, the ones that count for implicit submission. */\nconst textTypes = new Set(['text', 'search', 'url', 'tel', 'email', 'password', 'date', 'month', 'week', 'time', 'datetime-local', 'number']);\n\nfunction blocksImplicitSubmission(el: Element): boolean {\n if (el instanceof HTMLInputElement) return textTypes.has(el.type);\n return el.localName === 'uf-input' || el.localName === 'uf-number-input';\n}\n\n/**\n * Enter submits the form, like in a native input: through its default button (the\n * first submit button), unless that's disabled. Without one, only when the field\n * is the form's only text field.\n */\nexport function submitOnEnter(event: KeyboardEvent, form: HTMLFormElement | null): void {\n if (event.key !== 'Enter' || event.isComposing || event.defaultPrevented || !form) return;\n const fields = [...form.elements];\n const submitter = fields.find(isSubmitButton);\n if (submitter) {\n if ((submitter as Element & { disabled?: boolean }).disabled || submitter.matches(':disabled')) return;\n } else if (fields.filter(blocksImplicitSubmission).length > 1) {\n return;\n }\n event.preventDefault();\n // Native submit buttons go with the form data; ours submit no value.\n form.requestSubmit(submitter instanceof HTMLButtonElement || submitter instanceof HTMLInputElement ? submitter : undefined);\n}\n",
@@ -869,7 +887,7 @@
869
887
  "components/progress/progress.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { defineElement } from '../../internal/define.js';\nimport { Translator } from '../../internal/i18n.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\nexport type ProgressVariant = 'accent' | 'success' | 'warning' | 'danger';\nexport type ProgressSize = 'sm' | 'md' | 'lg';\n\n/**\n * A bar that shows how far a task has got. Without a `value` it's\n * indeterminate: an animated bar for work whose length isn't known, like a\n * native `<progress>`.\n *\n * @summary Shows how far a task has got.\n * @tag uf-progress\n *\n * @slot label - The label, when you need markup. Overrides `label`.\n *\n * @csspart base - The wrapper around label and bar.\n * @csspart label - The label.\n * @csspart value - The percentage, when `show-value` is set.\n * @csspart track - The bar's background.\n * @csspart indicator - The filled part of the bar.\n *\n * @cssprop --uf-progress-height - Height of the bar.\n * @cssprop --uf-progress-radius - Corner radius of the bar. Use `999px` for a pill.\n * @cssprop --uf-progress-track-color - Color of the bar's background.\n * @cssprop --uf-progress-indicator-color - Color of the filled part.\n */\nexport class UfProgress extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: block;\n --_height: var(--uf-progress-height, 0.5rem);\n --_color: var(--uf-color-accent);\n }\n\n :host([size='sm']) {\n --_height: var(--uf-progress-height, 0.25rem);\n }\n\n :host([size='lg']) {\n --_height: var(--uf-progress-height, 0.75rem);\n }\n\n :host([variant='success']) {\n --_color: var(--uf-color-success);\n }\n :host([variant='warning']) {\n --_color: var(--uf-color-warning);\n }\n :host([variant='danger']) {\n --_color: var(--uf-color-danger);\n }\n\n .base {\n display: flex;\n flex-direction: column;\n gap: var(--uf-space-1);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-sm);\n color: var(--uf-color-text);\n }\n\n .header {\n display: flex;\n justify-content: space-between;\n gap: var(--uf-space-2);\n }\n\n .label {\n font-weight: var(--uf-font-weight-medium);\n }\n\n .value {\n color: var(--uf-color-text-muted);\n font-variant-numeric: tabular-nums;\n }\n\n .track {\n position: relative;\n height: var(--_height);\n border-radius: var(--uf-progress-radius, var(--uf-radius-control));\n background: var(--uf-progress-track-color, var(--uf-color-surface-hover));\n overflow: hidden;\n }\n\n .indicator {\n height: 100%;\n border-radius: inherit;\n background: var(--uf-progress-indicator-color, var(--_color));\n transition: width var(--uf-duration-base) ease;\n }\n\n .indeterminate .indicator {\n position: absolute;\n width: 40%;\n animation: uf-progress-slide 1.5s ease-in-out infinite;\n }\n\n @keyframes uf-progress-slide {\n from {\n left: -40%;\n }\n to {\n left: 100%;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .indicator {\n transition: none;\n }\n .indeterminate .indicator {\n animation-duration: 4s;\n }\n }\n\n [hidden] {\n display: none !important;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: { type: Number },\n max: { type: Number },\n label: {},\n showValue: { type: Boolean, attribute: 'show-value' },\n variant: { reflect: true },\n size: { reflect: true },\n };\n\n /** Progress so far, from 0 to `max`. Leave it out for an indeterminate bar. */\n declare value: number | undefined;\n /** The value that means done. */\n declare max: number;\n /** Visible label, also the bar's accessible name. Without one, it's named \"Progress\". */\n declare label: string | undefined;\n /** Shows the percentage next to the label. */\n declare showValue: boolean;\n /** Color, by meaning: `accent`, `success`, `warning` or `danger`. */\n declare variant: ProgressVariant;\n /** Height of the bar: `sm`, `md` or `lg`. */\n declare size: ProgressSize;\n\n readonly #slots = new HasSlotController(this, 'label');\n readonly #id = uniqueId('uf-progress');\n readonly #translator = new Translator(this);\n\n constructor() {\n super();\n this.max = 100;\n this.showValue = false;\n this.variant = 'accent';\n this.size = 'md';\n }\n\n /** The value as a percentage, or undefined when indeterminate. */\n get #percent(): number | undefined {\n if (this.value == null || Number.isNaN(this.value)) return undefined;\n const max = this.max > 0 ? this.max : 100;\n return Math.round((Math.min(Math.max(this.value, 0), max) / max) * 100);\n }\n\n override render() {\n const percent = this.#percent;\n const indeterminate = percent === undefined;\n const hasLabel = Boolean(this.label) || this.#slots.has('label');\n const showValue = this.showValue && !indeterminate;\n const labelId = `${this.#id}-label`;\n return html`\n <div class=\"base\" part=\"base\">\n <div class=\"header\" ?hidden=${!hasLabel && !showValue}>\n <span id=${labelId} class=\"label\" part=\"label\" ?hidden=${!hasLabel}><slot name=\"label\">${this.label}</slot></span>\n ${showValue ? html`<span class=\"value\" part=\"value\" aria-hidden=\"true\">${percent}%</span>` : nothing}\n </div>\n <div\n class=\"track ${indeterminate ? 'indeterminate' : ''}\"\n part=\"track\"\n role=\"progressbar\"\n aria-labelledby=${ifDefined(hasLabel ? labelId : undefined)}\n aria-label=${ifDefined(hasLabel ? undefined : this.#translator.t('progress'))}\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n aria-valuenow=${ifDefined(percent)}\n >\n <div class=\"indicator\" part=\"indicator\" style=${indeterminate ? '' : `width: ${percent}%`}></div>\n </div>\n </div>\n `;\n }\n}\n\ndefineElement('uf-progress', UfProgress);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-progress': UfProgress;\n }\n}\n",
870
888
  "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-bg - 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, var(--_circle, 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 /* The group's size. */\n :host([data-group-size='sm']) {\n --_circle: 1rem;\n font-size: var(--uf-font-size-sm);\n }\n\n :host([data-group-size='lg']) {\n --_circle: 1.25rem;\n font-size: var(--uf-font-size-lg);\n }\n\n /* Grey instead of faded, like disabled fields. */\n :host([disabled]),\n :host([data-group-disabled]) {\n color: var(--uf-color-text-muted);\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-bg, var(--uf-color-accent-strong));\n }\n\n :host([disabled]) .control,\n :host([data-group-disabled]) .control {\n border-color: var(--uf-color-border);\n background: var(--uf-color-neutral-fill);\n }\n\n :host([disabled][checked]) .control,\n :host([data-group-disabled][checked]) .control {\n border-color: var(--uf-color-text-muted);\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",
871
889
  "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, 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';\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 size: { 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 /** Size of the radios and their labels: `sm`, `md` or `lg`. */\n declare size: FieldSize;\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.size = 'md';\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, size 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.setAttribute('data-group-size', this.size);\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",
872
- "components/segmented-control/segmented-control.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, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { flattenOptions, readItems, type OptionItem } from '../../internal/options.js';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\n/**\n * A row of buttons for one choice among a few, like \"List / Grid\" or \"Day /\n * Week / Month\". The choices are plain `<option>` children. One is always\n * selected: the `value` attribute, an option marked `selected`, or the first.\n *\n * It's a radio group for assistive tech: arrow keys move and select, Home and\n * End jump to the ends, and it submits its value with a form.\n *\n * @summary Picks one of a few options, side by side.\n * @tag uf-segmented-control\n *\n * @slot - `<option>` elements. `disabled` options can't be picked.\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the options. Overrides `hint`.\n *\n * @event input - The user picked another option.\n * @event change - The user picked another option.\n *\n * @csspart base - The element with `role=\"radiogroup\"`.\n * @csspart form-label - The label.\n * @csspart options - The row of buttons.\n * @csspart option - One button. The selected one also has the part `selected`.\n * @csspart selected - The selected button.\n * @csspart hint - The hint text.\n *\n * @cssprop --uf-segmented-control-bg - Background behind the buttons.\n * @cssprop --uf-segmented-control-selected-bg - Background of the selected button.\n * @cssprop --uf-segmented-control-selected-color - Text color of the selected button.\n * @cssprop --uf-segmented-control-radius - Corner radius of the row.\n */\nexport class UfSegmentedControl extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n css`\n :host {\n display: inline-block;\n }\n\n .options {\n --_height: var(--uf-size-control-md);\n display: inline-flex;\n gap: 2px;\n padding: 2px;\n border: 1px solid var(--uf-color-border-strong);\n border-radius: var(--uf-segmented-control-radius, var(--uf-radius-control));\n background: var(--uf-segmented-control-bg, var(--uf-color-surface));\n }\n\n :host([size='sm']) .options {\n --_height: var(--uf-size-control-sm);\n }\n\n :host([size='lg']) .options {\n --_height: var(--uf-size-control-lg);\n }\n\n .option {\n min-height: calc(var(--_height) - 6px);\n padding: 0 var(--uf-space-3);\n border: 0;\n border-radius: inherit;\n background: transparent;\n color: var(--uf-color-text-muted);\n font: inherit;\n font-size: var(--uf-font-size-md);\n font-weight: var(--uf-font-weight-medium);\n white-space: nowrap;\n cursor: pointer;\n transition:\n background-color var(--uf-duration-fast) ease,\n color var(--uf-duration-fast) ease;\n }\n\n :host([size='sm']) .option {\n padding: 0 var(--uf-space-2);\n font-size: var(--uf-font-size-sm);\n }\n\n :host([size='lg']) .option {\n padding: 0 var(--uf-space-4);\n font-size: var(--uf-font-size-lg);\n }\n\n .option:hover:not(:disabled):not(.selected) {\n background: var(--uf-color-surface-hover);\n color: var(--uf-color-text);\n }\n\n .option.selected {\n background: var(--uf-segmented-control-selected-bg, var(--uf-color-accent));\n color: var(--uf-segmented-control-selected-color, var(--uf-color-on-accent));\n }\n\n .option:focus-visible {\n ${focusRing}\n }\n\n .option:disabled {\n color: var(--uf-color-border-strong);\n cursor: not-allowed;\n }\n\n /* Grey, like disabled fields. */\n .disabled .options {\n border-color: var(--uf-color-border);\n background: var(--uf-color-neutral-fill);\n }\n\n .disabled .option.selected {\n background: var(--uf-color-border-strong);\n color: var(--uf-color-surface);\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n size: { reflect: true },\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, also the group's accessible name. */\n declare label: string | undefined;\n /** Help text below the options. */\n declare hint: string | undefined;\n /** Size of the buttons. */\n declare size: FieldSize;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-segmented-control');\n readonly #observer = new MutationObserver(() => this.#readOptions());\n #options: OptionItem[] = [];\n #optionsChanged = 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.#readOptions();\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 #readOptions(): void {\n this.#options = flattenOptions(readItems(this));\n this.#optionsChanged = true;\n this.requestUpdate();\n }\n\n /** The value a reset returns to: the `value` attribute, a `selected` option, or the first enabled one. */\n #initialValue(): string {\n if (this.defaultValue !== undefined && this.defaultValue !== null) return this.defaultValue;\n return (this.#options.find((o) => o.selected) ?? this.#options.find((o) => !o.disabled))?.value ?? '';\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (!changed.has('defaultValue') && !this.#optionsChanged) return;\n this.#optionsChanged = false;\n // Frameworks often connect the element before appending its options: wait for them.\n if (!this.#options.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 || changed.has('defaultValue')) {\n this.value = this.#initialValue();\n }\n }\n\n override updated(): void {\n this.syncFormState();\n }\n\n protected syncFormState(): void {\n this.internals.setFormValue(this.value);\n // One option is always selected: nothing to validate.\n this.setValidity({}, '');\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 get #buttons(): HTMLButtonElement[] {\n return [...this.renderRoot.querySelectorAll<HTMLButtonElement>('.option')];\n }\n\n /** Moves focus to the selected option. */\n override focus(options?: FocusOptions): void {\n this.#buttons.find((b) => b.tabIndex === 0)?.focus(options);\n }\n\n #select(option: OptionItem, focus = false): void {\n if (option.disabled || this.isDisabled) return;\n if (focus) this.updateComplete.then(() => this.focus());\n if (option.value === this.value) return;\n this.value = option.value;\n this.markInteracted();\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n this.emitChange();\n }\n\n #onKeyDown = (event: KeyboardEvent): void => {\n const enabled = this.#options.filter((o) => !o.disabled);\n const index = enabled.findIndex((o) => o.value === this.value);\n const rtl = getComputedStyle(this).direction === 'rtl';\n const next = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1, ArrowDown: 1, ArrowUp: -1 }[event.key];\n let target: OptionItem | undefined;\n if (next) target = enabled[(index + next + enabled.length) % enabled.length];\n else if (event.key === 'Home') target = enabled[0];\n else if (event.key === 'End') target = enabled[enabled.length - 1];\n if (!target) return;\n event.preventDefault();\n this.#select(target, true);\n };\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const labelId = `${this.#id}-label`;\n const hasHintSlot = this.#slots.has('hint');\n const hasLabel = Boolean(this.label) || this.#slots.has('label');\n const disabled = this.isDisabled;\n // The selected option takes Tab; with none (no options yet), the first enabled one.\n const focusable = this.#options.find((o) => o.value === this.value && !o.disabled) ?? this.#options.find((o) => !o.disabled);\n\n return html`\n <div\n class=${classMap({ field: true, disabled })}\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-disabled=${disabled ? 'true' : 'false'}\n >\n <div id=${labelId} class=\"field-label\" part=\"form-label\" ?hidden=${!hasLabel}>\n <slot name=\"label\">${this.label ?? nothing}</slot>\n </div>\n <div class=\"options\" part=\"options\" @keydown=${this.#onKeyDown}>\n ${this.#options.map((option) => {\n const selected = option.value === this.value;\n return html`<button\n class=${classMap({ option: true, selected })}\n part=${selected ? 'option selected' : 'option'}\n type=\"button\"\n role=\"radio\"\n aria-checked=${selected ? 'true' : 'false'}\n tabindex=${option === focusable ? 0 : -1}\n ?disabled=${disabled || option.disabled}\n @click=${() => this.#select(option)}\n >\n ${option.label}\n </button>`;\n })}\n </div>\n <div id=${ids.hintId} class=\"field-hint\" part=\"hint\" ?hidden=${!(this.hint || hasHintSlot)}>\n <slot name=\"hint\">${this.hint ?? nothing}</slot>\n </div>\n </div>\n `;\n }\n}\n\ndefineElement('uf-segmented-control', UfSegmentedControl);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-segmented-control': UfSegmentedControl;\n }\n}\n",
890
+ "components/segmented-control/segmented-control.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, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { flattenOptions, readItems, type OptionItem } from '../../internal/options.js';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\n/**\n * A row of buttons for one choice among a few, like \"List / Grid\" or \"Day /\n * Week / Month\". The choices are plain `<option>` children. One is always\n * selected: the `value` attribute, an option marked `selected`, or the first.\n *\n * It's a radio group for assistive tech: arrow keys move and select, Home and\n * End jump to the ends, and it submits its value with a form.\n *\n * @summary Picks one of a few options, side by side.\n * @tag uf-segmented-control\n *\n * @slot - `<option>` elements. `disabled` options can't be picked.\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the options. Overrides `hint`.\n *\n * @event input - The user picked another option.\n * @event change - The user picked another option.\n *\n * @csspart base - The element with `role=\"radiogroup\"`.\n * @csspart form-label - The label.\n * @csspart options - The row of buttons.\n * @csspart option - One button. The selected one also has the part `selected`.\n * @csspart selected - The selected button.\n * @csspart hint - The hint text.\n *\n * @cssprop --uf-segmented-control-bg - Background behind the buttons.\n * @cssprop --uf-segmented-control-selected-bg - Background of the selected button.\n * @cssprop --uf-segmented-control-selected-color - Text color of the selected button.\n * @cssprop --uf-segmented-control-radius - Corner radius of the row.\n */\nexport class UfSegmentedControl extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n css`\n :host {\n display: inline-block;\n }\n\n .options {\n --_height: var(--uf-size-control-md);\n display: inline-flex;\n gap: 2px;\n padding: 2px;\n border: 1px solid var(--uf-color-border-strong);\n border-radius: var(--uf-segmented-control-radius, var(--uf-radius-control));\n background: var(--uf-segmented-control-bg, var(--uf-color-surface));\n }\n\n :host([size='sm']) .options {\n --_height: var(--uf-size-control-sm);\n }\n\n :host([size='lg']) .options {\n --_height: var(--uf-size-control-lg);\n }\n\n /* Share any extra width when the row is stretched, as in a grid; no effect at its natural width. */\n .option {\n flex: 1 1 auto;\n min-height: calc(var(--_height) - 6px);\n padding: 0 var(--uf-space-3);\n border: 0;\n border-radius: inherit;\n background: transparent;\n color: var(--uf-color-text-muted);\n font: inherit;\n font-size: var(--uf-font-size-md);\n font-weight: var(--uf-font-weight-medium);\n white-space: nowrap;\n cursor: pointer;\n transition:\n background-color var(--uf-duration-fast) ease,\n color var(--uf-duration-fast) ease;\n }\n\n :host([size='sm']) .option {\n padding: 0 var(--uf-space-2);\n font-size: var(--uf-font-size-sm);\n }\n\n :host([size='lg']) .option {\n padding: 0 var(--uf-space-4);\n font-size: var(--uf-font-size-lg);\n }\n\n .option:hover:not(:disabled):not(.selected) {\n background: var(--uf-color-surface-hover);\n color: var(--uf-color-text);\n }\n\n .option.selected {\n background: var(--uf-segmented-control-selected-bg, var(--uf-color-accent));\n color: var(--uf-segmented-control-selected-color, var(--uf-color-on-accent));\n }\n\n .option:focus-visible {\n ${focusRing}\n }\n\n .option:disabled {\n color: var(--uf-color-border-strong);\n cursor: not-allowed;\n }\n\n /* Grey, like disabled fields. */\n .disabled .options {\n border-color: var(--uf-color-border);\n background: var(--uf-color-neutral-fill);\n }\n\n .disabled .option.selected {\n background: var(--uf-color-border-strong);\n color: var(--uf-color-surface);\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n size: { reflect: true },\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, also the group's accessible name. */\n declare label: string | undefined;\n /** Help text below the options. */\n declare hint: string | undefined;\n /** Size of the buttons. */\n declare size: FieldSize;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-segmented-control');\n readonly #observer = new MutationObserver(() => this.#readOptions());\n #options: OptionItem[] = [];\n #optionsChanged = 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.#readOptions();\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 #readOptions(): void {\n this.#options = flattenOptions(readItems(this));\n this.#optionsChanged = true;\n this.requestUpdate();\n }\n\n /** The value a reset returns to: the `value` attribute, a `selected` option, or the first enabled one. */\n #initialValue(): string {\n if (this.defaultValue !== undefined && this.defaultValue !== null) return this.defaultValue;\n return (this.#options.find((o) => o.selected) ?? this.#options.find((o) => !o.disabled))?.value ?? '';\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (!changed.has('defaultValue') && !this.#optionsChanged) return;\n this.#optionsChanged = false;\n // Frameworks often connect the element before appending its options: wait for them.\n if (!this.#options.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 || changed.has('defaultValue')) {\n this.value = this.#initialValue();\n }\n }\n\n override updated(): void {\n this.syncFormState();\n }\n\n protected syncFormState(): void {\n this.internals.setFormValue(this.value);\n // One option is always selected: nothing to validate.\n this.setValidity({}, '');\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 get #buttons(): HTMLButtonElement[] {\n return [...this.renderRoot.querySelectorAll<HTMLButtonElement>('.option')];\n }\n\n /** Moves focus to the selected option. */\n override focus(options?: FocusOptions): void {\n this.#buttons.find((b) => b.tabIndex === 0)?.focus(options);\n }\n\n #select(option: OptionItem, focus = false): void {\n if (option.disabled || this.isDisabled) return;\n if (focus) this.updateComplete.then(() => this.focus());\n if (option.value === this.value) return;\n this.value = option.value;\n this.markInteracted();\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n this.emitChange();\n }\n\n #onKeyDown = (event: KeyboardEvent): void => {\n const enabled = this.#options.filter((o) => !o.disabled);\n const index = enabled.findIndex((o) => o.value === this.value);\n const rtl = getComputedStyle(this).direction === 'rtl';\n const next = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1, ArrowDown: 1, ArrowUp: -1 }[event.key];\n let target: OptionItem | undefined;\n if (next) target = enabled[(index + next + enabled.length) % enabled.length];\n else if (event.key === 'Home') target = enabled[0];\n else if (event.key === 'End') target = enabled[enabled.length - 1];\n if (!target) return;\n event.preventDefault();\n this.#select(target, true);\n };\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const labelId = `${this.#id}-label`;\n const hasHintSlot = this.#slots.has('hint');\n const hasLabel = Boolean(this.label) || this.#slots.has('label');\n const disabled = this.isDisabled;\n // The selected option takes Tab; with none (no options yet), the first enabled one.\n const focusable = this.#options.find((o) => o.value === this.value && !o.disabled) ?? this.#options.find((o) => !o.disabled);\n\n return html`\n <div\n class=${classMap({ field: true, disabled })}\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-disabled=${disabled ? 'true' : 'false'}\n >\n <div id=${labelId} class=\"field-label\" part=\"form-label\" ?hidden=${!hasLabel}>\n <slot name=\"label\">${this.label ?? nothing}</slot>\n </div>\n <div class=\"options\" part=\"options\" @keydown=${this.#onKeyDown}>\n ${this.#options.map((option) => {\n const selected = option.value === this.value;\n return html`<button\n class=${classMap({ option: true, selected })}\n part=${selected ? 'option selected' : 'option'}\n type=\"button\"\n role=\"radio\"\n aria-checked=${selected ? 'true' : 'false'}\n tabindex=${option === focusable ? 0 : -1}\n ?disabled=${disabled || option.disabled}\n @click=${() => this.#select(option)}\n >\n ${option.label}\n </button>`;\n })}\n </div>\n <div id=${ids.hintId} class=\"field-hint\" part=\"hint\" ?hidden=${!(this.hint || hasHintSlot)}>\n <slot name=\"hint\">${this.hint ?? nothing}</slot>\n </div>\n </div>\n `;\n }\n}\n\ndefineElement('uf-segmented-control', UfSegmentedControl);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-segmented-control': UfSegmentedControl;\n }\n}\n",
873
891
  "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",
874
892
  "components/skeleton/skeleton.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\n\nexport type SkeletonShape = 'text' | 'rect' | 'circle';\n\n/**\n * A grey placeholder in the shape of content that's still loading: lines of\n * text, a block or a circle. It's decorative, hidden from assistive tech: mark\n * the region that's loading with `aria-busy=\"true\"`, and announce the result\n * when it arrives.\n *\n * Size it with `width` and `height` in CSS; `text` lines take the height of a\n * line of text, and `circle` stays round.\n *\n * @summary Holds the place of content while it loads.\n * @tag uf-skeleton\n *\n * @csspart base - The placeholder, or the wrapper around its lines.\n * @csspart line - One line of a `text` placeholder.\n *\n * @cssprop --uf-skeleton-color - Background of the placeholder.\n * @cssprop --uf-skeleton-highlight - Color of the shimmer that sweeps across it.\n * @cssprop --uf-skeleton-radius - Corner radius of `text` and `rect` placeholders.\n */\nexport class UfSkeleton extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n --_color: var(--uf-skeleton-color, var(--uf-color-surface-hover));\n /* Toward the text color: lighter in dark mode, darker in light, clearly visible in both. */\n --_highlight: var(--uf-skeleton-highlight, color-mix(in srgb, var(--_color), var(--uf-color-text) 8%));\n display: block;\n }\n\n :host([shape='rect']) {\n height: 6rem;\n }\n\n :host([shape='circle']) {\n display: inline-block;\n width: 2.5rem;\n height: 2.5rem;\n vertical-align: middle;\n }\n\n .base {\n display: grid;\n gap: 0.5em;\n height: 100%;\n }\n\n .block,\n .line {\n border-radius: var(--uf-skeleton-radius, var(--uf-radius-sm));\n /*\n * Three times as wide as the placeholder: the outer thirds are plain, so the\n * loop starts and ends on the plain color and the highlight sweeps through the middle.\n */\n background: linear-gradient(\n /* A slanted band, sweeping from left to right. */\n 110deg,\n var(--_color) 0%,\n var(--_color) 36%,\n var(--_highlight) 50%,\n var(--_color) 64%,\n var(--_color) 100%\n )\n 0 0 / 300% 100%;\n animation: uf-skeleton-shimmer 1.6s ease-in-out infinite;\n }\n\n /* A line of text: as tall as the text around it, a little less than the line height. */\n .line {\n height: 0.9em;\n margin-block: 0.25em;\n }\n\n /* The last of several lines is shorter, like the end of a paragraph. */\n .line.last {\n width: 60%;\n }\n\n :host([shape='circle']) .block {\n border-radius: 50%;\n }\n\n @keyframes uf-skeleton-shimmer {\n from {\n background-position: 100% 0;\n }\n to {\n background-position: 0 0;\n }\n }\n\n /* Still, for people who asked for less motion: the shape alone says \"loading\". */\n @media (prefers-reduced-motion: reduce) {\n .block,\n .line {\n animation: none;\n }\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n shape: { reflect: true },\n lines: { type: Number },\n };\n\n /** `text` (lines of text), `rect` (a block, like an image) or `circle` (like an avatar). */\n declare shape: SkeletonShape;\n /** Number of lines of a `text` placeholder. */\n declare lines: number;\n\n constructor() {\n super();\n this.shape = 'text';\n this.lines = 1;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // A real attribute, so it's hidden for every assistive tech and test tool.\n this.setAttribute('aria-hidden', 'true');\n }\n\n override render() {\n if (this.shape !== 'text') return html`<div class=\"base\" part=\"base\"><div class=\"block\"></div></div>`;\n const count = Math.max(1, Math.floor(this.lines) || 1);\n return html`<div class=\"base\" part=\"base\">\n ${Array.from(\n { length: count },\n (_, i) => html`<div class=${i === count - 1 && count > 1 ? 'line last' : 'line'} part=\"line\"></div>`,\n )}\n </div>`;\n }\n}\n\ndefineElement('uf-skeleton', UfSkeleton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-skeleton': UfSkeleton;\n }\n}\n",
875
893
  "components/slider/slider.ts": "import { css, html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\n/**\n * Picks a number in a range by dragging a handle, or with the arrow keys. Built\n * on the native range input, so keyboard, touch and screen readers work as\n * they do everywhere; it submits its value with the form.\n *\n * @summary Lets users pick a number in a range.\n * @tag uf-slider\n *\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the slider. Overrides `hint`.\n *\n * @event input - Fired while the handle moves.\n * @event change - Fired when the user lets go, or after a key press.\n *\n * @csspart field - The wrapper around label, slider, hint and error.\n * @csspart form-label - The label.\n * @csspart value - The current value, when `show-value` is set.\n * @csspart input - The native range `<input>`.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-slider-track-height - Height of the track.\n * @cssprop --uf-slider-track-color - Color of the track's empty part.\n * @cssprop --uf-slider-indicator-color - Color of the track up to the handle.\n * @cssprop --uf-slider-thumb-size - Diameter of the handle.\n */\nexport class UfSlider extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n css`\n :host {\n --_track: var(--uf-slider-track-height, var(--_track-size, 0.375rem));\n --_thumb: var(--uf-slider-thumb-size, var(--_thumb-size, 1.125rem));\n --_fill-color: var(--uf-slider-indicator-color, var(--uf-color-accent));\n --_track-color: var(--uf-slider-track-color, var(--uf-color-surface-hover));\n }\n\n :host([size='sm']) {\n --_track-size: 0.25rem;\n --_thumb-size: 1rem;\n }\n\n :host([size='lg']) {\n --_track-size: 0.5rem;\n --_thumb-size: 1.375rem;\n }\n\n .value {\n color: var(--uf-color-text-muted);\n font-size: var(--uf-font-size-md);\n font-variant-numeric: tabular-nums;\n }\n\n .native {\n width: 100%;\n height: var(--_thumb);\n margin: 0;\n background: transparent;\n cursor: pointer;\n appearance: none;\n }\n\n .native:focus-visible {\n outline: none;\n }\n\n .native::-webkit-slider-runnable-track {\n height: var(--_track);\n border-radius: var(--uf-radius-control);\n background: linear-gradient(to right, var(--_fill-color) var(--_fill), var(--_track-color) var(--_fill));\n }\n\n .native::-moz-range-track {\n height: var(--_track);\n border-radius: var(--uf-radius-control);\n background: linear-gradient(to right, var(--_fill-color) var(--_fill), var(--_track-color) var(--_fill));\n }\n\n .native::-webkit-slider-thumb {\n width: var(--_thumb);\n height: var(--_thumb);\n margin-top: calc((var(--_track) - var(--_thumb)) / 2);\n border: 2px solid var(--_fill-color);\n border-radius: 50%;\n background: var(--uf-color-surface);\n box-shadow: var(--uf-shadow-sm);\n appearance: none;\n }\n\n .native::-moz-range-thumb {\n width: var(--_thumb);\n height: var(--_thumb);\n border: 2px solid var(--_fill-color);\n border-radius: 50%;\n background: var(--uf-color-surface);\n box-shadow: var(--uf-shadow-sm);\n }\n\n .native:focus-visible::-webkit-slider-thumb {\n ${focusRing}\n }\n\n .native:focus-visible::-moz-range-thumb {\n ${focusRing}\n }\n\n /* Grey, like disabled fields. */\n .native:disabled {\n --_fill-color: var(--uf-color-text-muted);\n --_track-color: var(--uf-color-neutral-fill);\n cursor: not-allowed;\n }\n\n :host([disabled]) .field-label,\n :host([disabled]) .value {\n color: var(--uf-color-text-muted);\n }\n `,\n ];\n\n protected static override formStateProperties: ReadonlySet<PropertyKey> = new Set([\n ...FormControl.formStateProperties,\n 'min',\n 'max',\n 'step',\n ]);\n\n static override properties: PropertyDeclarations = {\n value: { type: Number, attribute: false },\n defaultValue: { type: Number, attribute: 'value' },\n min: { type: Number },\n max: { type: Number },\n step: { type: Number },\n label: {},\n hint: {},\n showValue: { type: Boolean, attribute: 'show-value' },\n size: { reflect: true },\n };\n\n /** Current value. */\n declare value: number;\n /** Initial value, restored on form reset. Set with the `value` attribute. Defaults to the middle of the range, like a native slider. */\n declare defaultValue: number | undefined;\n /** Lowest value. */\n declare min: number;\n /** Highest value. */\n declare max: number;\n /** Granularity: the value moves in steps of this size. */\n declare step: number;\n /** Visible label, also the slider's accessible name. */\n declare label: string | undefined;\n /** Help text below the slider. */\n declare hint: string | undefined;\n /** Shows the current value next to the label. */\n declare showValue: boolean;\n /** Size of the track and handle: `sm`, `md` or `lg`. */\n declare size: FieldSize;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-slider');\n\n constructor() {\n super();\n this.min = 0;\n this.max = 100;\n this.step = 1;\n this.showValue = false;\n this.size = 'md';\n // Not a number yet: the first update puts it in the middle of min and max.\n this.value = Number.NaN;\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n /** The value a native slider would hold: within min and max, on a step. */\n #normalize(value: number | undefined): number {\n const min = this.min;\n const max = Math.max(this.max, min);\n const fallback = min + (max - min) / 2;\n const v = value == null || Number.isNaN(value) ? fallback : value;\n const clamped = Math.min(Math.max(v, min), max);\n const step = this.step > 0 ? this.step : 1;\n const stepped = min + Math.round((clamped - min) / step) * step;\n // Avoid 0.30000000000000004 with decimal steps.\n return Number(Math.min(stepped, max).toFixed(10));\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n // Like a native input: the value follows the `value` attribute until it is changed.\n if (changed.has('defaultValue') && (!this.hasUpdated || this.value === this.#normalize(changed.get('defaultValue')))) {\n this.value = this.#normalize(this.defaultValue);\n }\n if (changed.has('value') || changed.has('min') || changed.has('max') || changed.has('step')) {\n const normalized = this.#normalize(this.value);\n if (normalized !== this.value) this.value = normalized;\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(String(this.value));\n this.setValidityFrom(input);\n }\n\n protected resetValue(): void {\n this.value = this.#normalize(this.defaultValue);\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = this.#normalize(state == null ? undefined : Number(state));\n }\n\n #onInput = (event: Event): void => {\n this.value = Number((event.target as HTMLInputElement).value);\n };\n\n #onChange = (): void => {\n this.markInteracted();\n this.emitChange();\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 range = this.max - this.min;\n const fill = range > 0 ? ((this.value - this.min) / range) * 100 : 0;\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: false,\n // The native slider announces its value already.\n labelEnd: this.showValue ? html`<span class=\"value\" part=\"value\" aria-hidden=\"true\">${this.value}</span>` : undefined,\n control: html`\n <input\n id=${this.#id}\n class=\"native\"\n part=\"input\"\n type=\"range\"\n style=\"--_fill: ${fill}%\"\n name=${ifDefined(this.name || undefined)}\n min=${this.min}\n max=${this.max}\n step=${this.step}\n .value=${live(String(this.value))}\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 `,\n });\n }\n}\n\ndefineElement('uf-slider', UfSlider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-slider': UfSlider;\n }\n}\n",
@@ -880,7 +898,7 @@
880
898
  "components/tabs/tab.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\n\n/**\n * A tab inside `<uf-tabs>`. Its `panel` names the `<uf-tab-panel>` it shows.\n *\n * @summary A tab in a tab list.\n * @tag uf-tab\n *\n * @slot - The tab label.\n *\n * @csspart base - The tab's inner wrapper.\n *\n * @cssstate active - The tab is selected.\n */\nexport class UfTab extends LitElement {\n static override styles = css`\n :host {\n position: relative;\n display: inline-flex;\n align-items: center;\n gap: var(--uf-space-2);\n padding: var(--uf-space-2) var(--uf-space-3);\n color: var(--uf-color-text-muted);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n font-weight: var(--uf-font-weight-medium);\n white-space: nowrap;\n cursor: pointer;\n user-select: none;\n outline: none;\n border-radius: var(--uf-radius-sm);\n transition: color var(--uf-duration-fast) ease;\n }\n\n :host(:hover:not([disabled])) {\n color: var(--uf-color-text);\n }\n\n :host([aria-selected='true']) {\n color: var(--uf-color-text);\n }\n\n :host::after {\n content: '';\n position: absolute;\n inset: auto 0 -1px 0;\n height: 2px;\n border-radius: 2px;\n background: var(--uf-tabs-indicator-color, var(--uf-color-accent-strong));\n scale: 0 1;\n transition: scale var(--uf-duration-base) ease;\n }\n\n :host([aria-selected='true'])::after {\n scale: 1 1;\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 }\n\n @media (prefers-reduced-motion: reduce) {\n :host::after {\n transition: none;\n }\n }\n `;\n\n static override properties: PropertyDeclarations = {\n panel: { reflect: true },\n disabled: { type: Boolean, reflect: true },\n };\n\n /** Name of the `<uf-tab-panel>` this tab shows. */\n declare panel: string;\n /** Disables the tab. */\n declare disabled: boolean;\n\n constructor() {\n super();\n this.panel = '';\n this.disabled = false;\n }\n\n override render() {\n return html`<slot part=\"base\"></slot>`;\n }\n}\n\n/**\n * The content shown when its tab is selected.\n *\n * @summary A panel of content inside `<uf-tabs>`.\n * @tag uf-tab-panel\n *\n * @slot - The panel content.\n *\n * @cssprop --uf-tab-panel-padding - Padding around the content.\n */\nexport class UfTabPanel extends LitElement {\n static override styles = css`\n :host {\n display: block;\n padding: var(--uf-tab-panel-padding, var(--uf-space-4) 0);\n outline: none;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host(:focus-visible) {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: var(--uf-focus-ring-offset);\n border-radius: var(--uf-radius-sm);\n }\n `;\n\n static override properties: PropertyDeclarations = {\n name: { reflect: true },\n };\n\n /** Name the matching tab refers to with `panel`. */\n declare name: string;\n\n constructor() {\n super();\n this.name = '';\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndefineElement('uf-tab', UfTab);\ndefineElement('uf-tab-panel', UfTabPanel);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-tab': UfTab;\n 'uf-tab-panel': UfTabPanel;\n }\n}\n",
881
899
  "components/textarea/textarea.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 { 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 TextareaResize = 'none' | 'vertical' | 'auto';\n\n/**\n * A multi-line text field with a built-in label, hint and validation message.\n *\n * @summary Lets users enter multiple lines of text.\n * @tag uf-textarea\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 - Fired on every keystroke.\n * @event change - Fired when the value is committed (blur).\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 textarea.\n * @csspart textarea - The native `<textarea>`.\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 UfTextarea extends FormControl {\n static override styles = [\n hostStyles,\n fieldStyles,\n controlBoxStyles,\n css`\n .box {\n align-items: stretch;\n padding-block: var(--uf-space-2);\n }\n\n .native {\n min-height: 3lh;\n line-height: 1.5;\n resize: vertical;\n }\n\n :host([resize='none']) .native {\n resize: none;\n }\n\n /* Grows with its content where supported (field-sizing), otherwise resizable. */\n :host([resize='auto']) .native {\n field-sizing: content;\n resize: none;\n }\n `,\n ];\n\n protected static override formStateProperties: ReadonlySet<PropertyKey> = new Set([\n ...FormControl.formStateProperties,\n 'readonly',\n 'minlength',\n 'maxlength',\n ]);\n\n static override properties: PropertyDeclarations = {\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n placeholder: {},\n rows: { type: Number },\n resize: { reflect: true },\n size: { reflect: true },\n readonly: { type: Boolean, reflect: true },\n autocomplete: {},\n minlength: { type: Number },\n maxlength: { type: Number },\n };\n\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 /** Visible number of lines. */\n declare rows: number;\n /** How the user can resize the field. `auto` grows with the content. */\n declare resize: TextareaResize;\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 /** 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-textarea');\n\n constructor() {\n super();\n this.value = '';\n this.defaultValue = '';\n this.rows = 4;\n this.resize = 'vertical';\n this.size = 'md';\n this.readonly = false;\n }\n\n get #textarea(): HTMLTextAreaElement | null {\n return this.renderRoot.querySelector('textarea');\n }\n\n /** Selects all text in the field. */\n select(): void {\n this.#textarea?.select();\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.syncFormState();\n }\n\n protected syncFormState(): void {\n const textarea = this.#textarea;\n if (!textarea) return;\n this.internals.setFormValue(this.value);\n this.setValidityFrom(textarea);\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 HTMLTextAreaElement).value;\n };\n\n #onChange = (): void => {\n this.markInteracted();\n this.emitChange();\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\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 <textarea\n id=${this.#id}\n class=\"native\"\n part=\"textarea\"\n name=${ifDefined(this.name || undefined)}\n .value=${live(this.value)}\n rows=${this.rows}\n placeholder=${ifDefined(this.placeholder)}\n autocomplete=${ifDefined(this.autocomplete)}\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 ></textarea>\n </div>\n `,\n });\n }\n}\n\ndefineElement('uf-textarea', UfTextarea);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-textarea': UfTextarea;\n }\n}\n",
882
900
  "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' | 'accent' | '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 accent: 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 .accent {\n --_bg: var(--uf-color-toast-accent-bg);\n --_border: var(--uf-color-toast-accent-border);\n --_text: var(--uf-color-toast-accent-text);\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-control);\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. Does nothing on the\n * server, when rendering with SSR.\n *\n * @example toast('Saved', { variant: 'success' })\n */\nexport function toast(message: string, options?: ToastOptions): ToastHandle {\n // On the server (SSR) there is no page to show it on: do nothing.\n if (typeof document === 'undefined') return { dismiss() {} };\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",
883
- "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 * @event uf-show - The tooltip opened.\n * @event uf-hide - The tooltip closed.\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 * @cssprop --uf-tooltip-radius - Corner radius. Square by default.\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-tooltip-radius, 0);\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 this.dispatchEvent(new Event('uf-show'));\n } else if (!this.open && body.matches(':popover-open')) {\n body.hidePopover();\n this.#cleanup?.();\n this.#cleanup = undefined;\n this.dispatchEvent(new Event('uf-hide'));\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"
901
+ "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 * @event uf-show - The tooltip opened.\n * @event uf-hide - The tooltip closed.\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 * @cssprop --uf-tooltip-radius - Corner radius. Defaults to `--uf-radius-sm`.\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-tooltip-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 this.dispatchEvent(new Event('uf-show'));\n } else if (!this.open && body.matches(':popover-open')) {\n body.hidePopover();\n this.#cleanup?.();\n this.#cleanup = undefined;\n this.dispatchEvent(new Event('uf-hide'));\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"
884
902
  },
885
- "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-accent-bg: var(--uf-palette-accent-600);\n --uf-color-toast-accent-border: var(--uf-palette-accent-600);\n --uf-color-toast-accent-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 --uf-shadow-drawer: 0 0 40px rgb(0 0 0 / 0.16), 0 0 12px rgb(0 0 0 / 0.08);\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-accent-bg: var(--uf-palette-accent-600);\n --uf-color-toast-accent-border: var(--uf-palette-accent-600);\n --uf-color-toast-accent-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 --uf-shadow-drawer: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 30%, transparent), 0 0 48px -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-accent-bg: var(--uf-palette-accent-600);\n --uf-color-toast-accent-border: var(--uf-palette-accent-600);\n --uf-color-toast-accent-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 --uf-shadow-drawer: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 30%, transparent), 0 0 48px -8px color-mix(in srgb, var(--uf-palette-accent-600) 55%, transparent);\n }\n}\n\n/* Before the components load: no flash of raw content on server-rendered pages. */\n:where(uf-accordion, uf-accordion-item, uf-alert, uf-avatar, uf-badge, uf-breadcrumb-item, uf-breadcrumbs, uf-button, uf-calendar, uf-card, uf-checkbox, uf-checkbox-group, uf-combobox, uf-date-picker, uf-date-range-picker, uf-dialog, uf-divider, uf-drawer, uf-dropdown, uf-empty-state, uf-file-upload, uf-icon, uf-input, uf-menu, uf-menu-item, uf-multi-select, uf-number-input, uf-pagination, uf-popover, uf-progress, uf-radio, uf-radio-group, uf-segmented-control, uf-select, uf-skeleton, uf-slider, uf-spinner, uf-switch, uf-tab, uf-tab-panel, uf-table, uf-tabs, uf-textarea, uf-toaster, uf-tooltip):not(:defined) {\n visibility: hidden;\n}\n\n:where(uf-dialog, uf-drawer, uf-toaster, uf-tab-panel):not(:defined),\n:where(uf-dropdown, uf-popover):not(:defined) > :not([slot]),\n:where(uf-select, uf-combobox, uf-multi-select, uf-segmented-control):not(:defined) > :where(option, optgroup),\nuf-accordion-item:not(:defined):not([open]) > :not([slot]) {\n display: none;\n}\n"
903
+ "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: 2px;\n --uf-radius-md: 2px;\n --uf-radius-lg: 2px;\n --uf-radius-full: 9999px;\n --uf-radius-control: 2px;\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-accent-bg: var(--uf-palette-accent-600);\n --uf-color-toast-accent-border: var(--uf-palette-accent-600);\n --uf-color-toast-accent-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: 0 12px 32px rgb(0 0 0 / 0.12), 0 2px 8px rgb(0 0 0 / 0.06);\n --uf-shadow-drawer: 0 0 32px rgb(0 0 0 / 0.10), 0 0 8px rgb(0 0 0 / 0.05);\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-accent-bg: var(--uf-palette-accent-600);\n --uf-color-toast-accent-border: var(--uf-palette-accent-600);\n --uf-color-toast-accent-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) 20%, transparent), 0 8px 24px -8px color-mix(in srgb, var(--uf-palette-accent-600) 30%, transparent);\n --uf-shadow-overlay: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 18%, transparent), 0 6px 16px -6px color-mix(in srgb, var(--uf-palette-accent-600) 28%, transparent);\n --uf-shadow-modal: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 20%, transparent), 0 16px 40px -12px color-mix(in srgb, var(--uf-palette-accent-600) 32%, transparent);\n --uf-shadow-drawer: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 20%, transparent), 0 0 32px -8px color-mix(in srgb, var(--uf-palette-accent-600) 30%, 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-accent-bg: var(--uf-palette-accent-600);\n --uf-color-toast-accent-border: var(--uf-palette-accent-600);\n --uf-color-toast-accent-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) 20%, transparent), 0 8px 24px -8px color-mix(in srgb, var(--uf-palette-accent-600) 30%, transparent);\n --uf-shadow-overlay: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 18%, transparent), 0 6px 16px -6px color-mix(in srgb, var(--uf-palette-accent-600) 28%, transparent);\n --uf-shadow-modal: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 20%, transparent), 0 16px 40px -12px color-mix(in srgb, var(--uf-palette-accent-600) 32%, transparent);\n --uf-shadow-drawer: 0 0 0 1px color-mix(in srgb, var(--uf-palette-accent-400) 20%, transparent), 0 0 32px -8px color-mix(in srgb, var(--uf-palette-accent-600) 30%, transparent);\n }\n}\n\n/* Before the components load: no flash of raw content on server-rendered pages. */\n:where(uf-accordion, uf-accordion-item, uf-alert, uf-avatar, uf-badge, uf-breadcrumb-item, uf-breadcrumbs, uf-button, uf-button-group, uf-calendar, uf-card, uf-checkbox, uf-checkbox-group, uf-combobox, uf-date-picker, uf-date-range-picker, uf-dialog, uf-divider, uf-drawer, uf-dropdown, uf-empty-state, uf-file-upload, uf-icon, uf-input, uf-menu, uf-menu-item, uf-multi-select, uf-number-input, uf-pagination, uf-popover, uf-progress, uf-radio, uf-radio-group, uf-segmented-control, uf-select, uf-skeleton, uf-slider, uf-spinner, uf-switch, uf-tab, uf-tab-panel, uf-table, uf-tabs, uf-textarea, uf-toaster, uf-tooltip):not(:defined) {\n visibility: hidden;\n}\n\n:where(uf-dialog, uf-drawer, uf-toaster, uf-tab-panel):not(:defined),\n:where(uf-dropdown, uf-popover):not(:defined) > :not([slot]),\n:where(uf-select, uf-combobox, uf-multi-select, uf-segmented-control):not(:defined) > :where(option, optgroup),\nuf-accordion-item:not(:defined):not([open]) > :not([slot]) {\n display: none;\n}\n"
886
904
  }
@@ -5,7 +5,7 @@ description: Builds UI with Unframed web components (@unframed/core, @unframed/r
5
5
 
6
6
  # Unframed UI
7
7
 
8
- Unframed 0.13.1: accessible UI components as standard custom elements (Lit). Every tag starts with `uf-`. They work in plain HTML and every framework; React, Vue and Angular have wrapper packages for typed props, events and form bindings.
8
+ Unframed 1.0.0-rc.1: accessible UI components as standard custom elements (Lit). Every tag starts with `uf-`. They work in plain HTML and every framework; React, Vue and Angular have wrapper packages for typed props, events and form bindings.
9
9
 
10
10
  ## Before writing code
11
11
 
@@ -40,6 +40,7 @@ Unframed 0.13.1: accessible UI components as standard custom elements (Lit). Eve
40
40
  | Badge: Labels a status, a category or a count. | `<uf-badge>` | `@unframed/core/badge` |
41
41
  | Breadcrumbs: Shows the path to the current page. | `<uf-breadcrumbs>` `<uf-breadcrumb-item>` | `@unframed/core/breadcrumbs` |
42
42
  | Button: Triggers an action or navigates to a URL. | `<uf-button>` | `@unframed/core/button` |
43
+ | Button group: Joins related buttons into one bar. | `<uf-button-group>` | `@unframed/core/button-group` |
43
44
  | Card: Groups related content and actions. | `<uf-card>` | `@unframed/core/card` |
44
45
  | Checkbox: Lets users turn an option on or off, or pick several options. | `<uf-checkbox>` `<uf-checkbox-group>` | `@unframed/core/checkbox` `@unframed/core/checkbox-group` |
45
46
  | Combobox: Lets users search a list and pick one option. | `<uf-combobox>` | `@unframed/core/combobox` |
@@ -1,4 +1,4 @@
1
- # Unframed 0.13.1 components
1
+ # Unframed 1.0.0-rc.1 components
2
2
 
3
3
  ## Accordion
4
4
 
@@ -519,6 +519,84 @@ Icon-only buttons need a `label` for screen readers.
519
519
  | `--uf-button-font-family` | Font family. |
520
520
  | `--uf-button-font-weight` | Font weight. |
521
521
 
522
+ ## Button group
523
+
524
+ Related buttons joined into one bar, like "Bold / Italic / Underline" or
525
+ "Save" with a menu of other ways to save. For one choice among a few, use
526
+ `<uf-segmented-control>` instead.
527
+
528
+ Neighbors share one border, and only the outer corners are rounded. Filled
529
+ and ghost buttons get a thin line between them. Buttons can be wrapped, in a
530
+ `<uf-tooltip>` or as the trigger of a `<uf-dropdown>`, and stay joined.
531
+
532
+ It's a group for assistive tech: give it a `label` that says what the
533
+ buttons have in common.
534
+
535
+ Tags: `<uf-button-group>`. Import: `import '@unframed/core/button-group';` (or `npx @unframed/cli add button-group` to copy the source).
536
+
537
+ ### Basic
538
+
539
+ Related actions in one bar: neighbors share a border, and only the outer corners follow the theme radius. The `label` says what they have in common.
540
+
541
+ ```html
542
+ <uf-button-group label="Clipboard">
543
+ <uf-button variant="outline">Cut</uf-button>
544
+ <uf-button variant="outline">Copy</uf-button>
545
+ <uf-button variant="outline">Paste</uf-button>
546
+ </uf-button-group>
547
+
548
+ <uf-button-group label="Pages">
549
+ <uf-button variant="secondary" label="Previous page"><uf-icon slot="prefix" name="chevron-left"></uf-icon></uf-button>
550
+ <uf-button variant="secondary" label="Next page"><uf-icon slot="prefix" name="chevron-right"></uf-icon></uf-button>
551
+ </uf-button-group>
552
+ ```
553
+
554
+ - To pick one of a few options, like "Day / Week / Month", use a segmented control: it keeps one selected and works as a radio group.
555
+
556
+ ### Split button
557
+
558
+ A main action with a menu of other ways to do it. Buttons stay joined inside a dropdown or a tooltip, and filled or ghost buttons get a thin line between them.
559
+
560
+ ```html
561
+ <uf-button-group label="Save">
562
+ <uf-button>Save</uf-button>
563
+ <uf-dropdown placement="bottom-end">
564
+ <uf-button slot="trigger" label="More ways to save"><uf-icon slot="prefix" name="chevron-down"></uf-icon></uf-button>
565
+ <uf-menu label="Save">
566
+ <uf-menu-item value="draft">Save as draft</uf-menu-item>
567
+ <uf-menu-item value="template">Save as template</uf-menu-item>
568
+ </uf-menu>
569
+ </uf-dropdown>
570
+ </uf-button-group>
571
+ ```
572
+
573
+ ### Vertical
574
+
575
+ `orientation="vertical"` stacks the buttons, as wide as the widest.
576
+
577
+ ```html
578
+ <uf-button-group label="Align" orientation="vertical">
579
+ <uf-button variant="outline">Top</uf-button>
580
+ <uf-button variant="outline">Middle</uf-button>
581
+ <uf-button variant="outline">Bottom</uf-button>
582
+ </uf-button-group>
583
+ ```
584
+
585
+ ### `<uf-button-group>` API
586
+
587
+ #### Attributes and properties
588
+
589
+ | Attribute | Property | Type | Default | Description |
590
+ |---|---|---|---|---|
591
+ | `label` | | `string \| undefined` | | What the buttons have in common, for assistive tech. |
592
+ | `orientation` | | `ButtonGroupOrientation` | `'horizontal'` | Side by side, or stacked. |
593
+
594
+ #### Slots
595
+
596
+ | Slot | Description |
597
+ |---|---|
598
+ | (default) | `<uf-button>` elements, alone or wrapped in a tooltip or dropdown. |
599
+
522
600
  ## Card
523
601
 
524
602
  A container that groups related content: an optional image, a header, the
@@ -1356,15 +1434,25 @@ Tags: `<uf-drawer>`. Import: `import '@unframed/core/drawer';` (or `npx @unframe
1356
1434
 
1357
1435
  ### Filters
1358
1436
 
1359
- A modal panel from the end edge. Escape, the close button and any element with `data-dialog="close"` close it.
1437
+ A modal panel from the end edge, floating a little away from the screen edges. Escape, the close button and any element with `data-dialog="close"` close it.
1360
1438
 
1361
1439
  ```html
1362
1440
  <uf-button variant="outline" onclick="this.nextElementSibling.show()">Filters</uf-button>
1363
1441
  <uf-drawer label="Filters" light-dismiss>
1364
1442
  <uf-checkbox-group label="Status">
1365
- <uf-checkbox value="open">Open</uf-checkbox>
1443
+ <uf-checkbox value="open" checked>Open</uf-checkbox>
1444
+ <uf-checkbox value="review">In review</uf-checkbox>
1366
1445
  <uf-checkbox value="closed">Closed</uf-checkbox>
1367
1446
  </uf-checkbox-group>
1447
+ <uf-radio-group label="Priority" value="any">
1448
+ <uf-radio value="any">Any</uf-radio>
1449
+ <uf-radio value="high">High</uf-radio>
1450
+ <uf-radio value="low">Low</uf-radio>
1451
+ </uf-radio-group>
1452
+ <uf-select label="Assignee">
1453
+ <option value="anyone">Anyone</option>
1454
+ <option value="john">John Smith</option>
1455
+ </uf-select>
1368
1456
  <uf-button slot="footer" variant="ghost" data-dialog="close">Cancel</uf-button>
1369
1457
  <uf-button slot="footer" data-dialog="close">Apply</uf-button>
1370
1458
  </uf-drawer>
@@ -1372,14 +1460,35 @@ A modal panel from the end edge. Escape, the close button and any element with `
1372
1460
 
1373
1461
  - It is a modal dialog: focus stays inside, the page behind is inert and does not scroll, and focus returns to the button on close.
1374
1462
 
1463
+ ### Navigation menu
1464
+
1465
+ A site menu from the start edge, for small screens. The links are plain HTML in a `<nav>`, styled by your app.
1466
+
1467
+ ```html
1468
+ <uf-button variant="outline" onclick="this.nextElementSibling.show()">Menu</uf-button>
1469
+ <uf-drawer label="Menu" placement="start" light-dismiss style="--uf-drawer-size: 18rem">
1470
+ <nav aria-label="Main">
1471
+ <ul>
1472
+ <li><a href="/inbox" aria-current="page"><uf-icon name="inbox"></uf-icon>Inbox</a></li>
1473
+ <li><a href="/calendar"><uf-icon name="calendar"></uf-icon>Calendar</a></li>
1474
+ <li><a href="/documents"><uf-icon name="file"></uf-icon>Documents</a></li>
1475
+ <li><a href="/team"><uf-icon name="user"></uf-icon>Team</a></li>
1476
+ </ul>
1477
+ </nav>
1478
+ <div slot="footer"><uf-avatar name="John Smith" size="sm"></uf-avatar>John Smith</div>
1479
+ </uf-drawer>
1480
+ ```
1481
+
1482
+ - Mark the current page with `aria-current="page"`: screen readers announce it, and it is a handy hook for its style.
1483
+
1375
1484
  ### Placement
1376
1485
 
1377
- `start`, `end` (the default), `top` or `bottom`. Start and end follow the page direction. `--uf-drawer-size` sets the width, or the height for top and bottom.
1486
+ `start`, `end` (the default), `top` or `bottom`. Start and end follow the page direction. `--uf-drawer-size` sets the width, or the height for top and bottom, and `--uf-drawer-gap` the space around it: `0` puts it against the edge.
1378
1487
 
1379
1488
  ```html
1380
1489
  <uf-drawer label="Menu" placement="start">…</uf-drawer>
1381
1490
  <uf-drawer label="Cart" placement="end" style="--uf-drawer-size: 28rem">…</uf-drawer>
1382
- <uf-drawer label="Cookies" placement="bottom">…</uf-drawer>
1491
+ <uf-drawer label="Cookies" placement="bottom" style="--uf-drawer-gap: 0">…</uf-drawer>
1383
1492
  ```
1384
1493
 
1385
1494
  ### `<uf-drawer>` API
@@ -1435,7 +1544,8 @@ A modal panel from the end edge. Escape, the close button and any element with `
1435
1544
  | Property | Description |
1436
1545
  |---|---|
1437
1546
  | `--uf-drawer-size` | Width of a side drawer, or height of a top or bottom one. Defaults to `24rem`. |
1438
- | `--uf-drawer-radius` | Corner radius of the corners on the open side; the side against the screen edge stays square. |
1547
+ | `--uf-drawer-gap` | Space between the drawer and the screen's edges. `0` puts it against the edge. Defaults to `--uf-space-3`. |
1548
+ | `--uf-drawer-radius` | Corner radius. |
1439
1549
  | `--uf-dialog-bg` | Background of the drawer. |
1440
1550
  | `--uf-dialog-padding` | Padding of header, body and footer. |
1441
1551
  | `--uf-dialog-backdrop` | Backdrop color. |
@@ -3340,4 +3450,4 @@ Tags: `<uf-tooltip>`. Import: `import '@unframed/core/tooltip';` (or `npx @unfra
3340
3450
  | `--uf-tooltip-bg` | Background color. |
3341
3451
  | `--uf-tooltip-color` | Text color. |
3342
3452
  | `--uf-tooltip-max-width` | Maximum width. |
3343
- | `--uf-tooltip-radius` | Corner radius. Square by default. |
3453
+ | `--uf-tooltip-radius` | Corner radius. Defaults to `--uf-radius-sm`. |
@@ -1,4 +1,4 @@
1
- # Using Unframed 0.13.1 in each framework
1
+ # Using Unframed 1.0.0-rc.1 in each framework
2
2
 
3
3
  ## HTML & JavaScript
4
4
 
@@ -68,8 +68,8 @@ dialog.addEventListener('uf-hide', () => toast('Welcome aboard!', { variant: 'su
68
68
  <!doctype html>
69
69
  <html lang="en">
70
70
  <head>
71
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unframed/tokens@0.13/dist/tokens.css" />
72
- <script type="module" src="https://cdn.jsdelivr.net/npm/@unframed/core@0.13/+esm"></script>
71
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unframed/tokens@1.0.0-rc.1/dist/tokens.css" />
72
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@unframed/core@1.0.0-rc.1/+esm"></script>
73
73
  </head>
74
74
  <body>
75
75
  <uf-button variant="primary">It works</uf-button>