@unframed/cli 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.11.0",
|
|
3
3
|
"components": {
|
|
4
4
|
"accordion": {
|
|
5
5
|
"name": "accordion",
|
|
@@ -20,6 +20,26 @@
|
|
|
20
20
|
"lit"
|
|
21
21
|
]
|
|
22
22
|
},
|
|
23
|
+
"alert": {
|
|
24
|
+
"name": "alert",
|
|
25
|
+
"entry": "components/alert/alert.ts",
|
|
26
|
+
"tag": "uf-alert",
|
|
27
|
+
"summary": "Shows a message in the page, by meaning: info, success, warning or danger.",
|
|
28
|
+
"files": [
|
|
29
|
+
"components/alert/alert.ts"
|
|
30
|
+
],
|
|
31
|
+
"internal": [
|
|
32
|
+
"internal/define.ts",
|
|
33
|
+
"internal/i18n.ts",
|
|
34
|
+
"internal/icons.ts",
|
|
35
|
+
"internal/shared.styles.ts",
|
|
36
|
+
"internal/slot.ts"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": [],
|
|
39
|
+
"npm": [
|
|
40
|
+
"lit"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
23
43
|
"avatar": {
|
|
24
44
|
"name": "avatar",
|
|
25
45
|
"entry": "components/avatar/avatar.ts",
|
|
@@ -682,15 +702,16 @@
|
|
|
682
702
|
"internal/define.ts": "/**\n * Registers a custom element unless the tag is already taken, so loading the\n * library twice (e.g. two micro-frontends) doesn't throw.\n */\nexport function defineElement(tagName: string, ctor: CustomElementConstructor): void {\n if (!customElements.get(tagName)) customElements.define(tagName, ctor);\n}\n",
|
|
683
703
|
"internal/icons.ts": "import { svg, type SVGTemplateResult } from 'lit';\n\n/** Built-in 24×24 stroke icons, drawn with currentColor. */\nexport const icons = {\n check: svg`<path d=\"M5 12.5l4.5 4.5L19 7.5\" />`,\n minus: svg`<path d=\"M6 12h12\" />`,\n x: svg`<path d=\"M6 6l12 12M18 6L6 18\" />`,\n 'chevron-down': svg`<path d=\"M6 9l6 6 6-6\" />`,\n 'chevron-up': svg`<path d=\"M6 15l6-6 6 6\" />`,\n 'chevron-left': svg`<path d=\"M15 6l-6 6 6 6\" />`,\n 'chevron-right': svg`<path d=\"M9 6l6 6-6 6\" />`,\n plus: svg`<path d=\"M12 5v14M5 12h14\" />`,\n search: svg`<circle cx=\"11\" cy=\"11\" r=\"7\" /><path d=\"M20 20l-4-4\" />`,\n info: svg`<circle cx=\"12\" cy=\"12\" r=\"9\" /><path d=\"M12 11v5M12 8h.01\" />`,\n 'check-circle': svg`<circle cx=\"12\" cy=\"12\" r=\"9\" /><path d=\"M8 12.5l2.5 2.5L16 9.5\" />`,\n 'alert-triangle': svg`<path d=\"M12 4L2.5 20h19L12 4z\" /><path d=\"M12 10v4M12 17h.01\" />`,\n 'alert-circle': svg`<circle cx=\"12\" cy=\"12\" r=\"9\" /><path d=\"M12 7.5v5M12 16h.01\" />`,\n sun: svg`<circle cx=\"12\" cy=\"12\" r=\"4\" /><path d=\"M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4\" />`,\n calendar: svg`<rect x=\"3.5\" y=\"5\" width=\"17\" height=\"15.5\" rx=\"2\" /><path d=\"M3.5 10h17M8 3v4M16 3v4\" />`,\n user: svg`<circle cx=\"12\" cy=\"8\" r=\"4\" /><path d=\"M4 21a8 8 0 0 1 16 0\" />`,\n moon: svg`<path d=\"M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z\" />`,\n upload: svg`<path d=\"M12 15V4M7.5 8.5L12 4l4.5 4.5\" /><path d=\"M4 15v3.5A1.5 1.5 0 0 0 5.5 20h13a1.5 1.5 0 0 0 1.5-1.5V15\" />`,\n file: svg`<path d=\"M13.5 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5z\" /><path d=\"M13.5 3v5.5H19\" />`,\n} satisfies Record<string, SVGTemplateResult>;\n\nexport type BuiltInIconName = keyof typeof icons;\n\n/** Wraps an icon's paths in an `<svg>` element. */\nexport function iconSvg(paths: SVGTemplateResult, part = 'icon') {\n return svg`<svg part=${part} class=\"icon\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\"\n stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">${paths}</svg>`;\n}\n",
|
|
684
704
|
"internal/shared.styles.ts": "import { css } from 'lit';\n\n/** Base styles every component includes. */\nexport const hostStyles = css`\n :host {\n box-sizing: border-box;\n }\n\n :host *,\n :host *::before,\n :host *::after {\n box-sizing: inherit;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n`;\n\n/** Shared keyboard focus ring, driven by the focus tokens. */\nexport const focusRing = css`\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: var(--uf-focus-ring-offset);\n`;\n",
|
|
705
|
+
"components/alert/alert.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } 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 } from '../../internal/slot.js';\n\nexport type AlertVariant = 'neutral' | 'accent' | 'info' | 'success' | 'warning' | 'danger';\n\nconst variantIcons = {\n neutral: icons.info,\n accent: icons.info,\n info: icons.info,\n success: icons['check-circle'],\n warning: icons['alert-triangle'],\n danger: icons['alert-circle'],\n} as const;\n\n/**\n * A message in the page, like \"Your trial ends in 3 days\" or \"We couldn't save\n * your changes\". Unlike a toast it stays where it is until it's dismissed.\n *\n * `warning` and `danger` alerts are announced right away (`role=\"alert\"`), the\n * others politely (`role=\"status\"`). Assistive tech announces an alert when it's\n * added to the page or shown, not when the page loads with it.\n *\n * @summary Shows a message in the page, by meaning: info, success, warning or danger.\n * @tag uf-alert\n *\n * @slot - The message.\n * @slot heading - The heading, when you need markup. Overrides `heading`.\n * @slot icon - Replaces the variant's icon.\n * @slot actions - Buttons or links below the message.\n *\n * @event uf-show - The alert was shown with `show()`.\n * @event uf-hide - The alert was hidden, with the close button or `hide()`.\n *\n * @csspart base - The alert.\n * @csspart icon - The icon.\n * @csspart content - The wrapper around the heading, message and actions.\n * @csspart heading - The heading.\n * @csspart message - The message.\n * @csspart actions - The wrapper around the actions.\n * @csspart close-button - The close button, when `closable` is set.\n *\n * @cssprop --uf-alert-bg - Background color.\n * @cssprop --uf-alert-border-color - Border color.\n * @cssprop --uf-alert-color - Text color.\n * @cssprop --uf-alert-icon-color - Icon color.\n * @cssprop --uf-alert-radius - Corner radius.\n * @cssprop --uf-alert-padding - Space inside the alert.\n */\nexport class UfAlert extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: block;\n --_bg: var(--uf-color-surface-hover);\n --_border: var(--uf-color-border);\n --_icon: var(--uf-color-text-muted);\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([variant='accent']) {\n --_bg: var(--uf-color-accent-subtle);\n --_icon: var(--uf-color-accent-strong);\n }\n :host([variant='info']) {\n --_bg: var(--uf-color-info-subtle);\n --_icon: var(--uf-color-info);\n }\n :host([variant='success']) {\n --_bg: var(--uf-color-success-subtle);\n --_icon: var(--uf-color-success);\n }\n :host([variant='warning']) {\n --_bg: var(--uf-color-warning-subtle);\n --_icon: var(--uf-color-warning);\n }\n :host([variant='danger']) {\n --_bg: var(--uf-color-danger-subtle);\n --_icon: var(--uf-color-danger-text);\n }\n /* A border in the variant's color, faint enough to keep the text the focus. */\n :host(:not([variant='neutral'])) {\n --_border: color-mix(in srgb, var(--_icon) 35%, transparent);\n }\n\n .base {\n display: flex;\n align-items: flex-start;\n gap: var(--uf-space-3);\n padding: var(--uf-alert-padding, var(--uf-space-3) var(--uf-space-4));\n border: 1px solid var(--uf-alert-border-color, var(--_border));\n border-radius: var(--uf-alert-radius, var(--uf-radius-md));\n background: var(--uf-alert-bg, var(--_bg));\n color: var(--uf-alert-color, var(--uf-color-text));\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n line-height: 1.5;\n }\n\n .icon-slot {\n display: inline-flex;\n flex: none;\n /* Centers the icon on the first line of text. */\n margin-top: calc((1.5em - 1.125rem) / 2);\n color: var(--uf-alert-icon-color, var(--_icon));\n }\n\n .icon-slot .icon,\n ::slotted([slot='icon']) {\n width: 1.125rem;\n height: 1.125rem;\n }\n\n .content {\n flex: 1;\n min-width: 0;\n }\n\n .heading {\n display: block;\n font-weight: var(--uf-font-weight-semibold);\n }\n\n .actions {\n display: flex;\n flex-wrap: wrap;\n gap: var(--uf-space-2);\n margin-top: var(--uf-space-3);\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 /* Lines up with the first line of text, without making the alert taller. */\n margin: calc((1.5em - 1.75rem) / 2) calc(var(--uf-space-1) * -1) 0 0;\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 .close:hover {\n background: color-mix(in srgb, currentColor 14%, transparent);\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: 1rem;\n height: 1rem;\n }\n\n [hidden] {\n display: none !important;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true },\n heading: {},\n closable: { type: Boolean, reflect: true },\n withoutIcon: { type: Boolean, reflect: true, attribute: 'without-icon' },\n };\n\n /** Color, icon and urgency, by meaning: `neutral`, `accent`, `info`, `success`, `warning` or `danger`. */\n declare variant: AlertVariant;\n /** Bold first line. */\n declare heading: string | undefined;\n /** Shows a close button that hides the alert. */\n declare closable: boolean;\n /** Hides the icon. */\n declare withoutIcon: boolean;\n\n readonly #slots = new HasSlotController(this, 'heading', 'actions');\n readonly #translator = new Translator(this);\n\n constructor() {\n super();\n this.variant = 'info';\n this.closable = false;\n this.withoutIcon = false;\n }\n\n /** Shows the alert again after it was hidden. */\n show(): void {\n if (!this.hidden) return;\n this.hidden = false;\n this.dispatchEvent(new Event('uf-show'));\n }\n\n /** Hides the alert, like its close button. */\n hide(): void {\n if (this.hidden) return;\n this.hidden = true;\n this.dispatchEvent(new Event('uf-hide'));\n }\n\n override render() {\n const hasHeading = Boolean(this.heading) || this.#slots.has('heading');\n const urgent = this.variant === 'warning' || this.variant === 'danger';\n return html`\n <div class=\"base\" part=\"base\" role=${urgent ? 'alert' : 'status'}>\n <span class=\"icon-slot\" part=\"icon\" ?hidden=${this.withoutIcon}>\n <slot name=\"icon\">${iconSvg(variantIcons[this.variant] ?? icons.info, '')}</slot>\n </span>\n <div class=\"content\" part=\"content\">\n <strong class=\"heading\" part=\"heading\" ?hidden=${!hasHeading}><slot name=\"heading\">${this.heading ?? nothing}</slot></strong>\n <div class=\"message\" part=\"message\"><slot></slot></div>\n <div class=\"actions\" part=\"actions\" ?hidden=${!this.#slots.has('actions')}><slot name=\"actions\"></slot></div>\n </div>\n ${this.closable\n ? html`<button class=\"close\" part=\"close-button\" type=\"button\" aria-label=${this.#translator.t('close')} @click=${() => this.hide()}>\n ${iconSvg(icons.x, '')}\n </button>`\n : nothing}\n </div>\n `;\n }\n}\n\ndefineElement('uf-alert', UfAlert);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-alert': UfAlert;\n }\n}\n",
|
|
706
|
+
"internal/i18n.ts": "import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\n/** Every built-in text, by key. `{page}` is replaced with the page number. */\nexport interface Translations {\n /** Dialog and alert: the close button's accessible name. */\n close: string;\n /** Toast: the dismiss button's accessible name. */\n dismiss: string;\n /** Toaster: the notification region's accessible name, unless `label` is set. */\n notifications: string;\n /** Combobox: the arrow button's accessible name. */\n showOptions: string;\n /** Combobox: shown when the search matches nothing. */\n noResults: string;\n /** Combobox: error when required and empty. */\n selectItem: string;\n /** Combobox: announced while typing when one option matches. */\n oneResult: string;\n /** Combobox: announced while typing; `{count}` is the number of matches. */\n results: `${string}{count}${string}`;\n /** Radio group: error when required and empty. */\n selectOption: string;\n /** Pagination: the navigation's accessible name, unless `label` is set. */\n pagination: string;\n /** Pagination: the previous button's accessible name. */\n previousPage: string;\n /** Pagination: the next button's accessible name. */\n nextPage: string;\n /** Pagination: a page button's accessible name. Must contain `{page}`. */\n page: `${string}{page}${string}`;\n /** Table: shown when there are no rows, unless the `empty` slot is used. */\n noData: string;\n /** Form controls: error for an invalid value that has no message of its own. */\n invalidValue: string;\n /** Date picker: the calendar button's accessible name. */\n chooseDate: string;\n /** Calendar: the previous month button's accessible name. */\n previousMonth: string;\n /** Calendar: the next month button's accessible name. */\n nextMonth: string;\n /** Date picker: error for text that isn't a date; `{example}` is a date in the expected format. */\n invalidDate: `${string}{example}${string}`;\n /** Date picker: error for a date before `min`; `{date}` is the minimum. */\n dateTooEarly: `${string}{date}${string}`;\n /** Date picker: error for a date after `max`; `{date}` is the maximum. */\n dateTooLate: `${string}{date}${string}`;\n /** Date picker: error for a date that `isDateDisabled` rules out. */\n dateUnavailable: string;\n /** Date picker: placeholder letters for day, month and year, in the language's date order. */\n dayPlaceholder: string;\n monthPlaceholder: string;\n yearPlaceholder: string;\n /** Progress: the bar's accessible name, unless `label` is set. */\n progress: string;\n /** Spinner: its accessible name, unless `label` is set. */\n loading: string;\n /** Breadcrumbs: the navigation's accessible name, unless `label` is set. */\n breadcrumb: string;\n /** File upload: the button, with `multiple`. */\n chooseFiles: string;\n /** File upload: the button, for one file. */\n chooseFile: string;\n /** File upload: next to the button, with `multiple`. */\n dropFiles: string;\n /** File upload: next to the button, for one file. */\n dropFile: string;\n /** File upload: a file's remove button. Must contain `{name}`. */\n removeFile: `${string}{name}${string}`;\n /** File upload: a file over `max-size`. Must contain `{name}`, then `{size}`. */\n fileTooLarge: `${string}{name}${string}{size}${string}`;\n /** File upload: a file `accept` rules out. Must contain `{name}`. */\n fileTypeRejected: `${string}{name}${string}`;\n /** Date range picker: the calendar button's accessible name, and the popup's without a `label`. */\n chooseDates: string;\n /** Date range picker: the start input's accessible name, after the label. */\n startDate: string;\n /** Date range picker: the end input's accessible name, after the label. */\n endDate: string;\n /** Date range picker: error when only one of the two dates is set. */\n rangeIncomplete: string;\n /** Date range picker: error when the end date is before the start date. */\n endBeforeStart: string;\n}\n\nconst english: Translations = {\n close: 'Close',\n dismiss: 'Dismiss',\n notifications: 'Notifications',\n showOptions: 'Show options',\n noResults: 'No results',\n selectItem: 'Please select an item in the list.',\n oneResult: '1 result',\n results: '{count} results',\n selectOption: 'Please select one of these options.',\n pagination: 'Pagination',\n previousPage: 'Previous page',\n nextPage: 'Next page',\n page: 'Page {page}',\n noData: 'No data',\n invalidValue: 'Invalid value',\n chooseDate: 'Choose date',\n previousMonth: 'Previous month',\n nextMonth: 'Next month',\n invalidDate: 'Enter a date like {example}.',\n dateTooEarly: 'Choose {date} or later.',\n dateTooLate: 'Choose {date} or earlier.',\n dateUnavailable: 'This date is not available.',\n dayPlaceholder: 'dd',\n monthPlaceholder: 'mm',\n yearPlaceholder: 'yyyy',\n progress: 'Progress',\n loading: 'Loading',\n breadcrumb: 'Breadcrumb',\n chooseFiles: 'Choose files',\n chooseFile: 'Choose a file',\n dropFiles: 'or drag them here',\n dropFile: 'or drag it here',\n removeFile: 'Remove {name}',\n fileTooLarge: '{name} is larger than {size}.',\n fileTypeRejected: \"{name} isn't an accepted file type.\",\n chooseDates: 'Choose dates',\n startDate: 'Start date',\n endDate: 'End date',\n rangeIncomplete: 'Enter both a start and an end date.',\n endBeforeStart: \"The end date can't be before the start date.\",\n};\n\n/** Registered translations by lowercase language code; '' applies to every language. */\nconst registered = new Map<string, Partial<Translations>>();\nconst hosts = new Set<ReactiveControllerHost>();\nlet langObserver: MutationObserver | undefined;\n\nconst refreshAll = () => hosts.forEach((host) => host.requestUpdate());\n\n/**\n * Replaces the built-in English text of every component. Pass only the keys\n * you want to change; the rest stay in English. Components already on the page\n * update at once.\n *\n * With a language code, the strings apply where the nearest `lang` attribute\n * matches it (`'pt'` also covers `pt-BR`), so a page can switch language by\n * changing `<html lang>`, or mix languages by section. Without one, they apply\n * everywhere no registered language matches.\n *\n * @example setTranslations({ close: 'Chiudi', page: 'Pagina {page}' }, 'it')\n */\nexport function setTranslations(translations: Partial<Translations>, lang = ''): void {\n const key = lang.toLowerCase();\n registered.set(key, { ...registered.get(key), ...translations });\n refreshAll();\n}\n\n/** Forgets every registered translation. For tests. */\nexport function resetTranslations(): void {\n registered.clear();\n refreshAll();\n}\n\n/** The `lang` that applies to an element: the nearest one, across shadow roots. */\nfunction langOf(element: Element): string {\n let node: Element | null = element;\n while (node) {\n const lang = node.closest('[lang]')?.getAttribute('lang');\n if (lang) return lang.toLowerCase();\n const root = node.getRootNode();\n node = root instanceof ShadowRoot ? root.host : null;\n }\n return '';\n}\n\n/** The text for a key: the element's language, then its base language, then the default, then English. */\nfunction lookup(element: Element, key: keyof Translations): string {\n const lang = langOf(element);\n const candidates = lang ? [lang, lang.split('-')[0], ''] : [''];\n for (const candidate of candidates) {\n const value = registered.get(candidate)?.[key];\n if (value) return value;\n }\n return english[key];\n}\n\n/**\n * Gives a component its built-in text, and re-renders it when translations or\n * the page's `lang` change.\n */\nexport class Translator implements ReactiveController {\n readonly #host: ReactiveControllerHost & HTMLElement;\n\n constructor(host: ReactiveControllerHost & HTMLElement) {\n this.#host = host;\n host.addController(this);\n }\n\n /** The translated text, with `{name}` placeholders filled in. */\n t(key: keyof Translations, values: Record<string, string | number> = {}): string {\n return lookup(this.#host, key).replace(/\\{(\\w+)\\}/g, (match, name: string) => (name in values ? String(values[name]) : match));\n }\n\n hostConnected(): void {\n hosts.add(this.#host);\n if (!langObserver && typeof MutationObserver !== 'undefined') {\n // One observer for the whole document: a `lang` change anywhere re-renders the components.\n langObserver = new MutationObserver(refreshAll);\n langObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['lang'], subtree: true });\n }\n }\n\n /** The language that applies to the component, from the nearest `lang` attribute ('' when none). */\n get lang(): string {\n return langOf(this.#host);\n }\n\n hostDisconnected(): void {\n hosts.delete(this.#host);\n }\n}\n",
|
|
707
|
+
"internal/slot.ts": "import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\n/** Re-renders the host when the content of the given named slots changes. */\nexport class HasSlotController implements ReactiveController {\n readonly #host: ReactiveControllerHost & HTMLElement;\n readonly #names: string[];\n\n constructor(host: ReactiveControllerHost & HTMLElement, ...names: string[]) {\n this.#host = host;\n this.#names = names;\n host.addController(this);\n }\n\n /** True when a direct child is assigned to the named slot. */\n has(name: string): boolean {\n return [...this.#host.children].some((child) => child.getAttribute('slot') === name);\n }\n\n hostConnected(): void {\n this.#host.shadowRoot?.addEventListener('slotchange', this.#onSlotChange);\n }\n\n hostDisconnected(): void {\n this.#host.shadowRoot?.removeEventListener('slotchange', this.#onSlotChange);\n }\n\n #onSlotChange = (event: Event): void => {\n const slot = event.target as HTMLSlotElement;\n if (this.#names.includes(slot.name)) this.#host.requestUpdate();\n };\n}\n\nlet counter = 0;\n\n/** A document-unique id, for ARIA references within one tree. */\nexport function uniqueId(prefix = 'uf'): string {\n counter += 1;\n return `${prefix}-${counter}`;\n}\n",
|
|
685
708
|
"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",
|
|
686
709
|
"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",
|
|
687
710
|
"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",
|
|
688
|
-
"
|
|
689
|
-
"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 // slotchange doesn't fire for a slot that starts empty, so check after the first render too.\n override firstUpdated(): void {\n this.#onLabelChange();\n }\n\n #onLabelChange = (): void => {\n const slot = this.renderRoot.querySelector<HTMLSlotElement>('.label slot');\n const nodes = slot?.assignedNodes({ flatten: true }) ?? [];\n const iconOnly = !nodes.some((n) => n.nodeType === Node.ELEMENT_NODE || n.textContent?.trim());\n if (iconOnly !== this.#iconOnly) {\n this.#iconOnly = iconOnly;\n this.requestUpdate();\n }\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",
|
|
711
|
+
"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",
|
|
690
712
|
"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",
|
|
691
713
|
"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 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: day.getUTCMonth() !== month.getUTCMonth(),\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 if (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",
|
|
692
714
|
"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",
|
|
693
|
-
"internal/slot.ts": "import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\n/** Re-renders the host when the content of the given named slots changes. */\nexport class HasSlotController implements ReactiveController {\n readonly #host: ReactiveControllerHost & HTMLElement;\n readonly #names: string[];\n\n constructor(host: ReactiveControllerHost & HTMLElement, ...names: string[]) {\n this.#host = host;\n this.#names = names;\n host.addController(this);\n }\n\n /** True when a direct child is assigned to the named slot. */\n has(name: string): boolean {\n return [...this.#host.children].some((child) => child.getAttribute('slot') === name);\n }\n\n hostConnected(): void {\n this.#host.shadowRoot?.addEventListener('slotchange', this.#onSlotChange);\n }\n\n hostDisconnected(): void {\n this.#host.shadowRoot?.removeEventListener('slotchange', this.#onSlotChange);\n }\n\n #onSlotChange = (event: Event): void => {\n const slot = event.target as HTMLSlotElement;\n if (this.#names.includes(slot.name)) this.#host.requestUpdate();\n };\n}\n\nlet counter = 0;\n\n/** A document-unique id, for ARIA references within one tree. */\nexport function uniqueId(prefix = 'uf'): string {\n counter += 1;\n return `${prefix}-${counter}`;\n}\n",
|
|
694
715
|
"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",
|
|
695
716
|
"components/checkbox/checkbox.ts": "import { css, html, type PropertyDeclarations } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { describedBy } from '../../internal/field.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { syncSelectAll, type SelectAllHost } from '../../internal/select-all.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\nimport { ToggleControl } from '../../internal/toggle-control.js';\nimport { toggleStyles } from '../../internal/toggle.styles.js';\n\n/**\n * A checkbox with its label as content.\n *\n * @summary Lets users turn an option on or off, or pick several options.\n * @tag uf-checkbox\n *\n * @slot - The label.\n * @slot hint - Help text below the label. Overrides `hint`.\n *\n * @event input - Fired when the checked state changes.\n * @event change - Fired when the checked state changes.\n *\n * @csspart base - The `<label>` wrapping control and label.\n * @csspart control - The box.\n * @csspart checkmark - The check or dash icon.\n * @csspart label - The label text.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-checkbox-size - Size of the box.\n * @cssprop --uf-checkbox-radius - Corner radius of the box.\n * @cssprop --uf-checkbox-checked-bg - Background when checked.\n * @cssprop --uf-checkbox-indeterminate-bg - Background when indeterminate. Defaults to the checked background.\n *\n * @cssstate checked - The checkbox is checked.\n * @cssstate indeterminate - The checkbox shows a dash (\"some selected\").\n * @cssstate user-invalid - Required but unchecked, after the user interacted.\n */\nexport class UfCheckbox extends ToggleControl {\n static override styles = [\n hostStyles,\n toggleStyles,\n css`\n :host {\n --_box: 1.125rem;\n --_control-width: var(--uf-checkbox-size, var(--_box));\n --_control-height: var(--uf-checkbox-size, var(--_box));\n }\n\n :host([size='sm']) {\n --_box: 1rem;\n }\n\n :host([size='lg']) {\n --_box: 1.25rem;\n }\n\n .native {\n width: var(--_control-width);\n height: var(--_control-height);\n border: 1px solid var(--uf-color-border-strong);\n border-radius: var(--uf-checkbox-radius, var(--uf-radius-control));\n background: var(--uf-color-surface);\n }\n\n .native:hover:not(:disabled) {\n border-color: var(--uf-color-text-muted);\n }\n\n .native:checked,\n .native:indeterminate {\n border-color: transparent;\n background: var(--uf-checkbox-checked-bg, var(--uf-color-accent));\n }\n\n .native:indeterminate {\n background: var(--uf-checkbox-indeterminate-bg, var(--uf-checkbox-checked-bg, var(--uf-color-accent)));\n }\n\n .disabled .native {\n border-color: var(--uf-color-border);\n background: var(--uf-color-neutral-fill);\n }\n\n .disabled .native:checked,\n .disabled .native:indeterminate {\n border-color: transparent;\n background: var(--uf-color-text-muted);\n }\n\n .disabled .icon {\n color: var(--uf-color-surface);\n }\n\n .invalid .native {\n border-color: var(--uf-color-danger-text);\n box-shadow: inset 0 0 0 1px var(--uf-color-danger-text);\n }\n\n .icon {\n position: absolute;\n inset: 0;\n margin: auto;\n width: 80%;\n height: 80%;\n color: var(--uf-color-on-accent);\n stroke-width: 3;\n pointer-events: none;\n opacity: 0;\n }\n\n .native:checked + .icon,\n .native:indeterminate + .icon {\n opacity: 1;\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n indeterminate: { type: Boolean, reflect: true },\n selectAll: { type: Boolean, reflect: true, attribute: 'select-all' },\n hint: {},\n };\n\n /** Shows a dash instead of a check, for \"some selected\". Cleared when the user clicks. */\n declare indeterminate: boolean;\n /**\n * Inside `<uf-checkbox-group>`: checks or unchecks every other checkbox in the\n * group, and shows checked, unchecked or indeterminate to match them.\n */\n declare selectAll: boolean;\n /** Help text below the label. */\n declare hint: string | undefined;\n\n readonly #slots = new HasSlotController(this, 'hint');\n readonly #id = uniqueId('uf-checkbox');\n\n constructor() {\n super();\n this.indeterminate = false;\n this.selectAll = false;\n }\n\n /** The `checked` state the group last heard about. */\n #reportedChecked?: boolean;\n\n override updated(): void {\n super.updated();\n this.internals.states?.[this.indeterminate ? 'add' : 'delete']('indeterminate');\n // Checking a box from code updates \"select all\" too, like a click does.\n if (!this.selectAll && this.checked !== this.#reportedChecked) {\n this.#reportedChecked = this.checked;\n this.closest<SelectAllHost>('uf-checkbox-group')?.[syncSelectAll]?.();\n }\n }\n\n #onChange = (event: Event): void => {\n this.indeterminate = false;\n this.onNativeChange(event);\n };\n\n override render() {\n const ids = { hintId: `${this.#id}-hint`, errorId: `${this.#id}-error` };\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n const disabled = this.isDisabled;\n\n return html`\n <label class=${classMap({ root: true, disabled, invalid: Boolean(error) })} part=\"base\">\n <span class=\"control\" part=\"control\">\n <input\n class=\"native\"\n type=\"checkbox\"\n name=${ifDefined(this.name || undefined)}\n .value=${this.value}\n .checked=${live(this.checked)}\n .indeterminate=${live(this.indeterminate)}\n ?required=${this.required}\n ?disabled=${disabled}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @change=${this.#onChange}\n />\n ${iconSvg(this.indeterminate ? icons.minus : icons.check, 'checkmark')}\n </span>\n <span class=\"label\" part=\"label\"><slot></slot></span>\n </label>\n <div id=${ids.hintId} class=\"hint\" part=\"hint\" ?hidden=${!this.hint && !hasHintSlot}>\n <slot name=\"hint\">${this.hint}</slot>\n </div>\n <div id=${ids.errorId} class=\"error\" part=\"error\" ?hidden=${!error}>${error}</div>\n `;\n }\n}\n\ndefineElement('uf-checkbox', UfCheckbox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-checkbox': UfCheckbox;\n }\n}\n",
|
|
696
717
|
"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",
|
|
@@ -709,7 +730,7 @@
|
|
|
709
730
|
"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",
|
|
710
731
|
"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",
|
|
711
732
|
"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",
|
|
712
|
-
"components/input/input.ts": "import { html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { controlBoxStyles, describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\nexport type { FieldSize };\n\nexport type InputType = 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'number' | 'date' | 'time';\n\n/**\n * A single-line text field with a built-in label, hint and validation message.\n *\n * @summary Lets users enter a single line of text.\n * @tag uf-input\n *\n * @slot label - The label, when you need markup. Overrides `label`.\n * @slot hint - Help text below the field. Overrides `hint`.\n * @slot prefix - An icon or text before the input.\n * @slot suffix - An icon or text after the input.\n *\n * @event input - Fired on every keystroke.\n * @event change - Fired when the value is committed (blur or Enter).\n *\n * @csspart field - The wrapper around label, control, hint and error.\n * @csspart form-label - The label.\n * @csspart box - The bordered box around the input.\n * @csspart input - The native `<input>`.\n * @csspart hint - The hint text.\n * @csspart error - The validation message.\n *\n * @cssprop --uf-field-bg - Background of the box.\n * @cssprop --uf-field-border-color - Border color of the box.\n * @cssprop --uf-field-radius - Corner radius of the box.\n *\n * @cssstate user-invalid - The value is invalid and the user has interacted with the field.\n */\nexport class UfInput extends FormControl {\n static override styles = [hostStyles, fieldStyles, controlBoxStyles];\n\n protected static override formStateProperties: ReadonlySet<PropertyKey> = new Set([\n ...FormControl.formStateProperties,\n 'type',\n 'readonly',\n 'pattern',\n 'min',\n 'max',\n 'step',\n 'minlength',\n 'maxlength',\n ]);\n\n static override properties: PropertyDeclarations = {\n type: { reflect: true },\n value: { attribute: false },\n defaultValue: { attribute: 'value' },\n label: {},\n hint: {},\n placeholder: {},\n size: { reflect: true },\n readonly: { type: Boolean, reflect: true },\n autocomplete: {},\n inputmode: {},\n pattern: {},\n min: {},\n max: {},\n step: {},\n minlength: { type: Number },\n maxlength: { type: Number },\n };\n\n /** Input type. */\n declare type: InputType;\n /** Current value. */\n declare value: string;\n /** Initial value, restored on form reset. Set with the `value` attribute. */\n declare defaultValue: string;\n /** Visible label. */\n declare label: string | undefined;\n /** Help text below the field. */\n declare hint: string | undefined;\n /** Placeholder text. */\n declare placeholder: string | undefined;\n /** Size of the field. */\n declare size: FieldSize;\n /** Makes the field read-only. */\n declare readonly: boolean;\n /** Native `autocomplete` hint. */\n declare autocomplete: AutoFill | undefined;\n /** Native `inputmode` hint for virtual keyboards. */\n declare inputmode: string | undefined;\n /** Regex the value must match. */\n declare pattern: string | undefined;\n /** Minimum value, for number and date types. */\n declare min: string | undefined;\n /** Maximum value, for number and date types. */\n declare max: string | undefined;\n /** Step, for number and date types. */\n declare step: string | undefined;\n /** Minimum length. */\n declare minlength: number | undefined;\n /** Maximum length. */\n declare maxlength: number | undefined;\n\n readonly #slots = new HasSlotController(this, 'label', 'hint');\n readonly #id = uniqueId('uf-input');\n\n constructor() {\n super();\n this.type = 'text';\n this.value = '';\n this.defaultValue = '';\n this.size = 'md';\n this.readonly = false;\n }\n\n get #input(): HTMLInputElement | null {\n return this.renderRoot.querySelector('input');\n }\n\n /** Selects all text in the field. */\n select(): void {\n this.#input?.select();\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n // Like a native input: the value follows the `value` attribute until it is edited.\n if (changed.has('defaultValue') && this.value === (changed.get('defaultValue') ?? '')) {\n this.value = this.defaultValue ?? '';\n }\n }\n\n override updated(): void {\n this.syncFormState();\n }\n\n protected syncFormState(): void {\n const input = this.#input;\n if (!input) return;\n this.internals.setFormValue(this.value);\n this.setValidityFrom(input);\n }\n\n protected resetValue(): void {\n this.value = this.defaultValue ?? '';\n }\n\n /** @internal */\n formStateRestoreCallback(state: string | null): void {\n this.value = state ?? '';\n }\n\n #onInput = (event: Event): void => {\n this.value = (event.target as HTMLInputElement).value;\n };\n\n #onChange = (): void => {\n this.markInteracted();\n this.emitChange();\n };\n\n override render() {\n const ids = {\n hintId: `${this.#id}-hint`,\n errorId: `${this.#id}-error`,\n };\n const error = this.showInvalid ? this.validationMessage : '';\n const hasHintSlot = this.#slots.has('hint');\n\n return renderField({\n ...ids,\n controlId: this.#id,\n label: this.label,\n hasLabelSlot: this.#slots.has('label'),\n hint: this.hint,\n hasHintSlot,\n error,\n required: this.required,\n control: html`\n <div class=${classMap({ box: true, disabled: this.isDisabled })} part=\"box\">\n <slot name=\"prefix\"></slot>\n <input\n id=${this.#id}\n class=\"native\"\n part=\"input\"\n type=${this.type}\n name=${ifDefined(this.name || undefined)}\n .value=${live(this.value)}\n placeholder=${ifDefined(this.placeholder)}\n autocomplete=${ifDefined(this.autocomplete)}\n inputmode=${ifDefined(this.inputmode)}\n pattern=${ifDefined(this.pattern)}\n min=${ifDefined(this.min)}\n max=${ifDefined(this.max)}\n step=${ifDefined(this.step)}\n minlength=${ifDefined(this.minlength)}\n maxlength=${ifDefined(this.maxlength)}\n ?required=${this.required}\n ?readonly=${this.readonly}\n ?disabled=${this.isDisabled}\n aria-invalid=${error ? 'true' : 'false'}\n aria-describedby=${ifDefined(describedBy({ ...ids, hint: this.hint, hasHintSlot, error }))}\n @input=${this.#onInput}\n @change=${this.#onChange}\n />\n <slot name=\"suffix\"></slot>\n </div>\n `,\n });\n }\n}\n\ndefineElement('uf-input', UfInput);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-input': UfInput;\n }\n}\n",
|
|
733
|
+
"components/input/input.ts": "import { html, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { defineElement } from '../../internal/define.js';\nimport { controlBoxStyles, describedBy, fieldStyles, renderField, type FieldSize } from '../../internal/field.js';\nimport { FormControl } from '../../internal/form-control.js';\nimport { hostStyles } from '../../internal/shared.styles.js';\nimport { HasSlotController, uniqueId } from '../../internal/slot.js';\n\nexport type { FieldSize };\n\nexport type InputType = 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'number' | 'date' | 'time';\n\nconst 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';\n}\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 /**\n * Enter submits the form, like a native input: through its default button (the\n * first submit button), unless that's disabled. Without one, only when this is\n * the form's only text field.\n */\n #onKeyDown = (event: KeyboardEvent): void => {\n const form = this.form;\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\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",
|
|
713
734
|
"components/menu/menu.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport './menu-item.js';\nimport type { UfMenuItem } from './menu-item.js';\n\nexport { UfMenuItem } from './menu-item.js';\n\nexport interface MenuSelectDetail {\n item: UfMenuItem;\n value: string;\n}\n\n/**\n * A list of actions with full keyboard support: arrow keys, Home and End,\n * and typing a letter jumps to the next item starting with it. Use `<hr>`\n * between items for a separator. Usually placed inside `<uf-dropdown>`.\n *\n * @summary A list of actions or options.\n * @tag uf-menu\n *\n * @slot - `<uf-menu-item>` elements and `<hr>` separators.\n *\n * @event {CustomEvent<MenuSelectDetail>} uf-select - An item was chosen. Cancel it to keep a dropdown open.\n */\nexport class UfMenu extends LitElement {\n static override styles = css`\n :host {\n display: block;\n min-width: 10rem;\n outline: none;\n }\n\n ::slotted(hr) {\n height: 1px;\n margin: var(--uf-space-1) 0;\n border: 0;\n background: var(--uf-color-border);\n }\n `;\n\n static override properties: PropertyDeclarations = {\n label: {},\n };\n\n /** Accessible name of the menu. */\n declare label: string | undefined;\n\n #typeahead = '';\n #typeaheadTimer = 0;\n\n constructor() {\n super();\n this.addEventListener('click', this.#onClick);\n this.addEventListener('keydown', this.#onKeyDown);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.setAttribute('role', 'menu');\n }\n\n override updated(): void {\n if (this.label) this.setAttribute('aria-label', this.label);\n else this.removeAttribute('aria-label');\n this.#alignItems();\n }\n\n /** Reserves the check column on every item when any item is a checkbox. */\n #alignItems(): void {\n const items = [...this.querySelectorAll('uf-menu-item')].filter((i) => i.closest('uf-menu') === this);\n const hasCheckbox = items.some((i) => i.type === 'checkbox');\n for (const item of items) item.toggleAttribute('data-check-space', hasCheckbox);\n }\n\n /** Enabled items that belong to this menu (not to a nested one). */\n get items(): UfMenuItem[] {\n return [...this.querySelectorAll<UfMenuItem>('uf-menu-item')].filter(\n (item) => item.closest('uf-menu') === this && !item.disabled,\n );\n }\n\n /** Focuses the first enabled item. */\n focusFirst(): void {\n this.#focusItem(this.items[0]);\n }\n\n /** Focuses the last enabled item. */\n focusLast(): void {\n const items = this.items;\n this.#focusItem(items[items.length - 1]);\n }\n\n #focusItem(item: UfMenuItem | undefined): void {\n if (!item) return;\n for (const other of this.items) other.tabIndex = other === item ? 0 : -1;\n item.focus();\n }\n\n #activate(item: UfMenuItem): void {\n if (item.disabled) return;\n if (item.type === 'checkbox') item.checked = !item.checked;\n this.dispatchEvent(\n new CustomEvent<MenuSelectDetail>('uf-select', {\n bubbles: true,\n composed: true,\n cancelable: true,\n detail: { item, value: item.value },\n }),\n );\n }\n\n #onClick = (event: MouseEvent): void => {\n const item = (event.target as Element).closest('uf-menu-item');\n if (item && item.closest('uf-menu') === this) this.#activate(item);\n };\n\n #onKeyDown = (event: KeyboardEvent): void => {\n const items = this.items;\n const current = (event.target as Element).closest('uf-menu-item');\n const index = current ? items.indexOf(current) : -1;\n\n switch (event.key) {\n case 'ArrowDown':\n this.#focusItem(items[(index + 1) % items.length]);\n break;\n case 'ArrowUp':\n this.#focusItem(items[(index - 1 + items.length) % items.length]);\n break;\n case 'Home':\n this.#focusItem(items[0]);\n break;\n case 'End':\n this.#focusItem(items[items.length - 1]);\n break;\n case 'Enter':\n case ' ':\n if (current) this.#activate(current);\n break;\n default:\n if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {\n this.#onTypeahead(event.key, items, index);\n break;\n }\n return;\n }\n event.preventDefault();\n };\n\n /** Jumps to the next item whose label starts with the typed characters. */\n #onTypeahead(key: string, items: UfMenuItem[], index: number): void {\n clearTimeout(this.#typeaheadTimer);\n this.#typeaheadTimer = window.setTimeout(() => (this.#typeahead = ''), 500);\n this.#typeahead += key.toLowerCase();\n // Repeating one letter cycles through the items that start with it.\n const search = /^(.)\\1*$/.test(this.#typeahead) ? this.#typeahead[0] : this.#typeahead;\n const ordered = [...items.slice(index + 1), ...items.slice(0, index + 1)];\n const match = ordered.find((item) => item.textContent?.trim().toLowerCase().startsWith(search));\n this.#focusItem(match);\n }\n\n override render() {\n return html`<slot @slotchange=${() => this.#alignItems()}></slot>`;\n }\n}\n\ndefineElement('uf-menu', UfMenu);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-menu': UfMenu;\n }\n}\n",
|
|
714
735
|
"components/menu/menu-item.ts": "import { LitElement, css, html, nothing, type PropertyDeclarations } from 'lit';\nimport { defineElement } from '../../internal/define.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\n\n/**\n * An action inside `<uf-menu>`. With `type=\"checkbox\"` it toggles on and off.\n *\n * @summary An item in a menu.\n * @tag uf-menu-item\n *\n * @slot - The label.\n * @slot prefix - An icon before the label.\n * @slot suffix - Trailing content, e.g. a keyboard shortcut.\n *\n * @csspart checkmark - The check shown for checked checkbox items.\n * @csspart label - The label wrapper.\n *\n * @cssstate checked - A checkbox item that is on.\n */\nexport class UfMenuItem extends LitElement {\n static override styles = css`\n :host {\n display: flex;\n align-items: center;\n gap: var(--uf-space-2);\n min-height: var(--uf-size-control-sm);\n padding: 0 var(--uf-space-3) 0 var(--uf-space-2);\n color: var(--uf-color-text);\n font-family: var(--uf-font-family-sans);\n font-size: var(--uf-font-size-md);\n line-height: 1.3;\n white-space: nowrap;\n cursor: pointer;\n user-select: none;\n outline: none;\n }\n\n :host(:hover),\n :host(:focus) {\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n :host(:focus-visible) {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: calc(var(--uf-focus-ring-width) * -1);\n }\n\n :host([disabled]) {\n opacity: 0.5;\n cursor: not-allowed;\n background: none;\n color: var(--uf-color-text);\n }\n\n .check {\n display: inline-flex;\n width: 1rem;\n flex: none;\n }\n\n /* In menus with checkbox items, every label lines up after the check column. */\n :host([data-check-space]:not([type='checkbox'])) {\n padding-inline-start: calc(var(--uf-space-2) * 2 + 1rem);\n }\n\n .icon {\n width: 1rem;\n height: 1rem;\n }\n\n .label {\n flex: 1;\n }\n\n ::slotted([slot='suffix']) {\n margin-inline-start: var(--uf-space-4);\n color: var(--uf-color-text-muted);\n font-size: var(--uf-font-size-sm);\n }\n\n ::slotted(svg),\n ::slotted(uf-icon) {\n width: 1rem;\n height: 1rem;\n }\n `;\n\n static override properties: PropertyDeclarations = {\n value: { reflect: true },\n type: { reflect: true },\n checked: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n };\n\n /** Identifies the item in the menu's `uf-select` event. */\n declare value: string;\n /** `checkbox` items toggle `checked` when selected. */\n declare type: 'normal' | 'checkbox';\n /** Whether a checkbox item is on. */\n declare checked: boolean;\n /** Disables the item. */\n declare disabled: boolean;\n\n readonly #internals = this.attachInternals();\n\n constructor() {\n super();\n this.value = '';\n this.type = 'normal';\n this.checked = false;\n this.disabled = false;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute('tabindex')) this.tabIndex = -1;\n }\n\n override updated(): void {\n // Real attributes, so every accessibility tool and test library sees them.\n const checkbox = this.type === 'checkbox';\n this.setAttribute('role', checkbox ? 'menuitemcheckbox' : 'menuitem');\n this.setAttribute('aria-disabled', String(this.disabled));\n if (checkbox) this.setAttribute('aria-checked', String(this.checked));\n else this.removeAttribute('aria-checked');\n this.#internals.states?.[checkbox && this.checked ? 'add' : 'delete']('checked');\n }\n\n override render() {\n return html`\n ${this.type === 'checkbox'\n ? html`<span class=\"check\">${this.checked ? iconSvg(icons.check, 'checkmark') : nothing}</span>`\n : nothing}\n <slot name=\"prefix\"></slot>\n <span class=\"label\" part=\"label\"><slot></slot></span>\n <slot name=\"suffix\"></slot>\n `;\n }\n}\n\ndefineElement('uf-menu-item', UfMenuItem);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-menu-item': UfMenuItem;\n }\n}\n",
|
|
715
736
|
"components/pagination/pagination.ts": "import { LitElement, css, html, type PropertyDeclarations } from 'lit';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { defineElement } from '../../internal/define.js';\nimport { Translator } from '../../internal/i18n.js';\nimport { iconSvg, icons } from '../../internal/icons.js';\nimport { focusRing, hostStyles } from '../../internal/shared.styles.js';\n\nexport type PaginationSize = 'sm' | 'md' | 'lg';\n\nexport interface PageChangeDetail {\n /** The new page, from 1. */\n page: number;\n}\n\ntype Item = number | 'start-ellipsis' | 'end-ellipsis';\n\n/**\n * The page buttons to show: the first and last pages, the current page with\n * `siblings` pages on each side, and an ellipsis for the gaps. The number of\n * items stays the same from page to page, so the buttons don't jump around.\n */\nfunction pageItems(page: number, pages: number, siblings: number): Item[] {\n // Enough room to show everything: first, last, current, siblings and two ellipses.\n if (pages <= 2 * siblings + 5) return Array.from({ length: pages }, (_, i) => i + 1);\n const start = Math.max(2, Math.min(page - siblings, pages - 2 * siblings - 2));\n const end = Math.min(pages - 1, Math.max(page + siblings, 2 * siblings + 3));\n const items: Item[] = [1];\n if (start > 2) items.push('start-ellipsis');\n for (let p = start; p <= end; p++) items.push(p);\n if (end < pages - 1) items.push('end-ellipsis');\n items.push(pages);\n return items;\n}\n\n/**\n * Navigation between the pages of a list or table. Set `pages` and `page`; the\n * user changes `page`, and `uf-page-change` tells you which page to show.\n *\n * It's a navigation landmark: when a page has more than one, give each a\n * different `label`.\n *\n * @summary Moves between the pages of a long list.\n * @tag uf-pagination\n *\n * @event {CustomEvent<PageChangeDetail>} uf-page-change - The user chose another page.\n *\n * @csspart base - The `<nav>`.\n * @csspart list - The list of buttons.\n * @csspart button - Every button: pages, previous and next.\n * @csspart current - The current page's button.\n * @csspart previous - The previous button.\n * @csspart next - The next button.\n * @csspart ellipsis - The \"…\" between pages.\n *\n * @cssprop --uf-pagination-gap - Space between the buttons.\n */\nexport class UfPagination extends LitElement {\n static override styles = [\n hostStyles,\n css`\n :host {\n display: block;\n --_size: var(--uf-size-control-md);\n }\n\n :host([size='sm']) {\n --_size: var(--uf-size-control-sm);\n }\n\n :host([size='lg']) {\n --_size: var(--uf-size-control-lg);\n --_font-size: var(--uf-font-size-md);\n }\n\n .list {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--uf-pagination-gap, var(--uf-space-1));\n margin: 0;\n padding: 0;\n list-style: none;\n font-family: var(--uf-font-family-sans);\n font-size: var(--_font-size, var(--uf-font-size-sm));\n }\n\n .button {\n display: inline-grid;\n place-items: center;\n min-width: var(--_size);\n height: var(--_size);\n padding: 0 var(--uf-space-2);\n border: 1px solid transparent;\n border-radius: var(--uf-radius-control);\n background: transparent;\n color: var(--uf-color-text);\n font: inherit;\n font-variant-numeric: tabular-nums;\n cursor: pointer;\n transition: background-color var(--uf-duration-fast) ease;\n }\n\n .button:hover:not(:disabled) {\n background: var(--uf-color-accent-tint);\n color: var(--uf-color-on-accent-tint);\n }\n\n .button:focus-visible {\n ${focusRing}\n }\n\n .button:disabled {\n color: var(--uf-color-text-muted);\n cursor: not-allowed;\n opacity: 0.5;\n }\n\n .current,\n .current:hover:not(:disabled) {\n background: var(--uf-color-accent);\n color: var(--uf-color-on-accent);\n font-weight: var(--uf-font-weight-semibold);\n }\n\n .arrow svg {\n width: 1.125em;\n height: 1.125em;\n }\n\n .ellipsis {\n display: inline-grid;\n place-items: center;\n min-width: var(--_size);\n color: var(--uf-color-text-muted);\n }\n `,\n ];\n\n static override properties: PropertyDeclarations = {\n page: { type: Number, reflect: true },\n pages: { type: Number },\n siblings: { type: Number },\n label: {},\n size: { reflect: true },\n };\n\n /** The current page, from 1. */\n declare page: number;\n /** How many pages there are. */\n declare pages: number;\n /** How many pages to show on each side of the current one. */\n declare siblings: number;\n /** Accessible name of the navigation, e.g. \"Search results pages\". Defaults to \"Pagination\", or its translation. */\n declare label: string | undefined;\n /** Size: `sm`, `md` or `lg`. */\n declare size: PaginationSize;\n\n readonly #translator = new Translator(this);\n\n constructor() {\n super();\n this.page = 1;\n this.pages = 1;\n this.siblings = 1;\n this.size = 'md';\n }\n\n /** The current page, kept between 1 and `pages`. */\n get #current(): number {\n return Math.min(Math.max(1, Math.round(this.page) || 1), Math.max(1, this.pages));\n }\n\n #go(page: number): void {\n if (page === this.#current || page < 1 || page > this.pages) return;\n this.page = page;\n this.dispatchEvent(new CustomEvent<PageChangeDetail>('uf-page-change', { bubbles: true, composed: true, detail: { page } }));\n }\n\n override render() {\n const current = this.#current;\n const pages = Math.max(1, Math.floor(this.pages) || 1);\n const items = pageItems(current, pages, Math.max(0, Math.floor(this.siblings)));\n\n return html`<nav part=\"base\" aria-label=${this.label ?? this.#translator.t('pagination')}>\n <ul class=\"list\" part=\"list\">\n <li>\n <button\n class=\"button arrow\"\n part=\"button previous\"\n type=\"button\"\n aria-label=${this.#translator.t('previousPage')}\n ?disabled=${current <= 1}\n @click=${() => this.#go(this.#current - 1)}\n >\n ${iconSvg(icons['chevron-left'])}\n </button>\n </li>\n ${repeat(\n items,\n (item) => item,\n (item) =>\n typeof item === 'number'\n ? html`<li>\n <button\n class=${classMap({ button: true, current: item === current })}\n part=${item === current ? 'button current' : 'button'}\n type=\"button\"\n aria-label=${this.#translator.t('page', { page: item })}\n aria-current=${item === current ? 'page' : 'false'}\n @click=${() => this.#go(item)}\n >\n ${item}\n </button>\n </li>`\n : html`<li class=\"ellipsis\" part=\"ellipsis\" aria-hidden=\"true\">…</li>`,\n )}\n <li>\n <button\n class=\"button arrow\"\n part=\"button next\"\n type=\"button\"\n aria-label=${this.#translator.t('nextPage')}\n ?disabled=${current >= pages}\n @click=${() => this.#go(this.#current + 1)}\n >\n ${iconSvg(icons['chevron-right'])}\n </button>\n </li>\n </ul>\n </nav>`;\n }\n}\n\ndefineElement('uf-pagination', UfPagination);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uf-pagination': UfPagination;\n }\n}\n",
|
|
@@ -728,5 +749,5 @@
|
|
|
728
749
|
"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-sm);\n background: transparent;\n color: inherit;\n opacity: 0.8;\n cursor: pointer;\n }\n\n .close:hover {\n background: color-mix(in srgb, currentColor 16%, transparent);\n opacity: 1;\n }\n\n .close:focus-visible {\n outline: var(--uf-focus-ring-width) solid var(--uf-color-focus-ring);\n outline-offset: 0;\n }\n\n .close .icon {\n width: 1rem;\n height: 1rem;\n margin: 0;\n color: inherit;\n }\n\n @keyframes enter {\n from {\n opacity: 0;\n translate: 0 0.5rem;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .toast {\n animation: none;\n }\n .toast.leaving {\n transition: none;\n }\n }\n `;\n\n static override properties: PropertyDeclarations = {\n placement: { reflect: true },\n label: {},\n };\n\n /** Corner or edge of the viewport where toasts appear. */\n declare placement: ToasterPlacement;\n /** Accessible name of the notification region. Defaults to \"Notifications\", or its translation. */\n declare label: string | undefined;\n\n #items: ToastItem[] = [];\n readonly #translator = new Translator(this);\n readonly #timers = new Map<number, Timer>();\n\n constructor() {\n super();\n this.placement = 'bottom-end';\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // The host itself is a manual popover, so toasts render in the top layer.\n this.popover = 'manual';\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n for (const timer of this.#timers.values()) clearTimeout(timer.handle);\n this.#timers.clear();\n }\n\n /** Shows a toast in this region. Prefer the `toast()` function. */\n add(message: string, options: ToastOptions = {}): ToastHandle {\n const item: ToastItem = {\n id: nextId++,\n message,\n title: options.title,\n variant: options.variant ?? 'neutral',\n duration: options.duration ?? 5000,\n closable: options.closable ?? true,\n leaving: false,\n };\n this.#items = [...this.#items, item];\n const overflow = this.#items.filter((i) => !i.leaving).length - MAX_TOASTS;\n if (overflow > 0) this.#items.filter((i) => !i.leaving).slice(0, overflow).forEach((i) => this.dismiss(i.id));\n\n this.#bringToFront();\n if (item.duration > 0) this.#startTimer(item.id, item.duration);\n this.requestUpdate();\n return { dismiss: () => this.dismiss(item.id) };\n }\n\n /** Hides a toast by id. */\n dismiss(id: number): void {\n const item = this.#items.find((i) => i.id === id);\n if (!item || item.leaving) return;\n clearTimeout(this.#timers.get(id)?.handle);\n this.#timers.delete(id);\n item.leaving = true;\n this.requestUpdate();\n\n const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;\n setTimeout(() => {\n this.#items = this.#items.filter((i) => i.id !== id);\n if (!this.#items.length && this.matches(':popover-open')) this.hidePopover();\n this.requestUpdate();\n }, reduced ? 0 : EXIT_MS);\n }\n\n /** Re-shows the popover, so toasts appear above a dialog opened after the last one. */\n #bringToFront(): void {\n if (this.matches(':popover-open')) this.hidePopover();\n this.showPopover();\n }\n\n #startTimer(id: number, ms: number): void {\n this.#timers.set(id, { handle: window.setTimeout(() => this.dismiss(id), ms), started: Date.now(), remaining: ms });\n }\n\n #pause(id: number): void {\n const timer = this.#timers.get(id);\n if (!timer) return;\n clearTimeout(timer.handle);\n timer.remaining -= Date.now() - timer.started;\n }\n\n #resume(id: number): void {\n const timer = this.#timers.get(id);\n if (timer) this.#startTimer(id, Math.max(timer.remaining, 1000));\n }\n\n #renderToast(item: ToastItem) {\n const icon = variantIcons[item.variant];\n return html`\n <li\n class=${classMap({ toast: true, [item.variant]: true, leaving: item.leaving })}\n part=\"toast\"\n role=${item.variant === 'danger' ? 'alert' : nothing}\n @pointerenter=${() => this.#pause(item.id)}\n @pointerleave=${() => this.#resume(item.id)}\n @focusin=${() => this.#pause(item.id)}\n @focusout=${() => this.#resume(item.id)}\n >\n ${icon ? iconSvg(icon) : nothing}\n <div class=\"content\">\n ${item.title ? html`<strong class=\"title\" part=\"title\">${item.title}</strong>` : nothing}\n <div class=\"message\" part=\"message\">${item.message}</div>\n </div>\n ${item.closable\n ? html`<button class=\"close\" part=\"close-button\" type=\"button\" aria-label=${this.#translator.t('dismiss')} @click=${() => this.dismiss(item.id)}>\n ${iconSvg(icons.x)}\n </button>`\n : nothing}\n </li>\n `;\n }\n\n override render() {\n return html`\n <section aria-label=${this.label ?? this.#translator.t('notifications')}>\n <ol part=\"region\" aria-live=\"polite\" aria-relevant=\"additions\">\n ${repeat(this.#items, (item) => item.id, (item) => this.#renderToast(item))}\n </ol>\n </section>\n `;\n }\n}\n\ndefineElement('uf-toaster', UfToaster);\n\n/**\n * Shows a toast. Creates a `<uf-toaster>` on first use. 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",
|
|
729
750
|
"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"
|
|
730
751
|
},
|
|
731
|
-
"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-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-drawer, uf-dropdown, uf-file-upload, uf-icon, uf-input, uf-menu, uf-menu-item, uf-pagination, uf-popover, uf-progress, uf-radio, uf-radio-group, uf-select, 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):not(:defined) > :where(option, optgroup),\nuf-accordion-item:not(:defined):not([open]) > :not([slot]) {\n display: none;\n}\n"
|
|
752
|
+
"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-drawer, uf-dropdown, uf-file-upload, uf-icon, uf-input, uf-menu, uf-menu-item, uf-pagination, uf-popover, uf-progress, uf-radio, uf-radio-group, uf-select, 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):not(:defined) > :where(option, optgroup),\nuf-accordion-item:not(:defined):not([open]) > :not([slot]) {\n display: none;\n}\n"
|
|
732
753
|
}
|
package/skill/unframed/SKILL.md
CHANGED
|
@@ -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.
|
|
8
|
+
Unframed 0.11.0: 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
|
|
|
@@ -35,6 +35,7 @@ Unframed 0.10.0: accessible UI components as standard custom elements (Lit). Eve
|
|
|
35
35
|
| Component | Tags | Import |
|
|
36
36
|
|---|---|---|
|
|
37
37
|
| Accordion: A stack of sections that expand and collapse. | `<uf-accordion>` `<uf-accordion-item>` | `@unframed/core/accordion` |
|
|
38
|
+
| Alert: Shows a message in the page, by meaning: info, success, warning or danger. | `<uf-alert>` | `@unframed/core/alert` |
|
|
38
39
|
| Avatar: Shows a person's picture, initials or icon. | `<uf-avatar>` | `@unframed/core/avatar` |
|
|
39
40
|
| Badge: Labels a status, a category or a count. | `<uf-badge>` | `@unframed/core/badge` |
|
|
40
41
|
| Breadcrumbs: Shows the path to the current page. | `<uf-breadcrumbs>` `<uf-breadcrumb-item>` | `@unframed/core/breadcrumbs` |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Unframed 0.
|
|
1
|
+
# Unframed 0.11.0 components
|
|
2
2
|
|
|
3
3
|
## Accordion
|
|
4
4
|
|
|
@@ -94,6 +94,119 @@ Add `multiple` to let several items stay open.
|
|
|
94
94
|
|---|---|
|
|
95
95
|
| `--uf-accordion-padding` | Horizontal padding of header and content. |
|
|
96
96
|
|
|
97
|
+
## Alert
|
|
98
|
+
|
|
99
|
+
A message in the page, like "Your trial ends in 3 days" or "We couldn't save
|
|
100
|
+
your changes". Unlike a toast it stays where it is until it's dismissed.
|
|
101
|
+
|
|
102
|
+
`warning` and `danger` alerts are announced right away (`role="alert"`), the
|
|
103
|
+
others politely (`role="status"`). Assistive tech announces an alert when it's
|
|
104
|
+
added to the page or shown, not when the page loads with it.
|
|
105
|
+
|
|
106
|
+
Tags: `<uf-alert>`. Import: `import '@unframed/core/alert';` (or `npx @unframed/cli add alert` to copy the source).
|
|
107
|
+
|
|
108
|
+
### Variants
|
|
109
|
+
|
|
110
|
+
Six colors by meaning, each with its icon. `info` is the default.
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<uf-alert>A new version is available.</uf-alert>
|
|
114
|
+
<uf-alert variant="success">Your changes were published.</uf-alert>
|
|
115
|
+
<uf-alert variant="warning">Your trial ends in 3 days.</uf-alert>
|
|
116
|
+
<uf-alert variant="danger">We couldn't charge your card.</uf-alert>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
- `warning` and `danger` alerts are announced right away, the others politely. Assistive tech announces an alert when it appears, so add it to the page (or `show()` it) when the message happens.
|
|
120
|
+
|
|
121
|
+
### Heading and actions
|
|
122
|
+
|
|
123
|
+
```html
|
|
124
|
+
<uf-alert variant="warning" heading="Your trial ends in 3 days">
|
|
125
|
+
Choose a plan to keep your projects and invoices.
|
|
126
|
+
<uf-button slot="actions" size="sm">Choose a plan</uf-button>
|
|
127
|
+
<uf-button slot="actions" size="sm" variant="ghost">Remind me later</uf-button>
|
|
128
|
+
</uf-alert>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Closable
|
|
132
|
+
|
|
133
|
+
`closable` adds a close button that hides the alert and emits `uf-hide`. `show()` brings it back.
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
<uf-alert variant="success" closable>Your changes were saved.</uf-alert>
|
|
137
|
+
|
|
138
|
+
<script>
|
|
139
|
+
document.querySelector('uf-alert').addEventListener('uf-hide', () => console.log('closed'));
|
|
140
|
+
</script>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Without an icon, or with your own
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<uf-alert variant="neutral" without-icon>Maintenance on Sunday from 02:00 to 04:00 UTC.</uf-alert>
|
|
147
|
+
<uf-alert variant="accent">
|
|
148
|
+
<uf-icon slot="icon" name="user"></uf-icon>
|
|
149
|
+
John Smith shared a project with you.
|
|
150
|
+
</uf-alert>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### `<uf-alert>` API
|
|
154
|
+
|
|
155
|
+
#### Attributes and properties
|
|
156
|
+
|
|
157
|
+
| Attribute | Property | Type | Default | Description |
|
|
158
|
+
|---|---|---|---|---|
|
|
159
|
+
| `variant` | | `AlertVariant` | `'info'` | Color, icon and urgency, by meaning: `neutral`, `accent`, `info`, `success`, `warning` or `danger`. |
|
|
160
|
+
| `heading` | | `string \| undefined` | | Bold first line. |
|
|
161
|
+
| `closable` | | `boolean` | `false` | Shows a close button that hides the alert. |
|
|
162
|
+
| `without-icon` | `withoutIcon` | `boolean` | `false` | Hides the icon. |
|
|
163
|
+
|
|
164
|
+
#### Methods
|
|
165
|
+
|
|
166
|
+
| Method | Description |
|
|
167
|
+
|---|---|
|
|
168
|
+
| `show()` | Shows the alert again after it was hidden. |
|
|
169
|
+
| `hide()` | Hides the alert, like its close button. |
|
|
170
|
+
|
|
171
|
+
#### Events
|
|
172
|
+
|
|
173
|
+
| Event | Type | Description |
|
|
174
|
+
|---|---|---|
|
|
175
|
+
| `uf-show` | `Event` | The alert was shown with `show()`. |
|
|
176
|
+
| `uf-hide` | `Event` | The alert was hidden, with the close button or `hide()`. |
|
|
177
|
+
|
|
178
|
+
#### Slots
|
|
179
|
+
|
|
180
|
+
| Slot | Description |
|
|
181
|
+
|---|---|
|
|
182
|
+
| (default) | The message. |
|
|
183
|
+
| `heading` | The heading, when you need markup. Overrides `heading`. |
|
|
184
|
+
| `icon` | Replaces the variant's icon. |
|
|
185
|
+
| `actions` | Buttons or links below the message. |
|
|
186
|
+
|
|
187
|
+
#### CSS parts
|
|
188
|
+
|
|
189
|
+
| Part | Description |
|
|
190
|
+
|---|---|
|
|
191
|
+
| `base` | The alert. |
|
|
192
|
+
| `icon` | The icon. |
|
|
193
|
+
| `content` | The wrapper around the heading, message and actions. |
|
|
194
|
+
| `heading` | The heading. |
|
|
195
|
+
| `message` | The message. |
|
|
196
|
+
| `actions` | The wrapper around the actions. |
|
|
197
|
+
| `close-button` | The close button, when `closable` is set. |
|
|
198
|
+
|
|
199
|
+
#### CSS custom properties
|
|
200
|
+
|
|
201
|
+
| Property | Description |
|
|
202
|
+
|---|---|
|
|
203
|
+
| `--uf-alert-bg` | Background color. |
|
|
204
|
+
| `--uf-alert-border-color` | Border color. |
|
|
205
|
+
| `--uf-alert-color` | Text color. |
|
|
206
|
+
| `--uf-alert-icon-color` | Icon color. |
|
|
207
|
+
| `--uf-alert-radius` | Corner radius. |
|
|
208
|
+
| `--uf-alert-padding` | Space inside the alert. |
|
|
209
|
+
|
|
97
210
|
## Avatar
|
|
98
211
|
|
|
99
212
|
A picture of a person or an entity. Shows the image when it loads, the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Using Unframed 0.
|
|
1
|
+
# Using Unframed 0.11.0 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.
|
|
72
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@unframed/core@0.
|
|
71
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unframed/tokens@0.11/dist/tokens.css" />
|
|
72
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@unframed/core@0.11/+esm"></script>
|
|
73
73
|
</head>
|
|
74
74
|
<body>
|
|
75
75
|
<uf-button variant="primary">It works</uf-button>
|