@f-ewald/components 1.38.0 → 1.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/custom-elements.json +1052 -131
- package/dist/address-autocomplete.js +2 -2
- package/dist/address-autocomplete.js.map +1 -1
- package/dist/app-shell.js +4 -4
- package/dist/app-shell.js.map +1 -1
- package/dist/app-sidebar.js +2 -2
- package/dist/app-sidebar.js.map +1 -1
- package/dist/audio-player.js +1 -1
- package/dist/audio-player.js.map +1 -1
- package/dist/autocomplete-input.js +2 -2
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/breadcrumb-nav.d.ts +69 -0
- package/dist/breadcrumb-nav.d.ts.map +1 -0
- package/dist/breadcrumb-nav.js +235 -0
- package/dist/breadcrumb-nav.js.map +1 -0
- package/dist/button-group.js +2 -2
- package/dist/button-group.js.map +1 -1
- package/dist/calendar-day.js +3 -3
- package/dist/calendar-day.js.map +1 -1
- package/dist/calendar-month.d.ts.map +1 -1
- package/dist/calendar-month.js +4 -1
- package/dist/calendar-month.js.map +1 -1
- package/dist/calendar-week.js +4 -4
- package/dist/calendar-week.js.map +1 -1
- package/dist/chat-message.js +1 -1
- package/dist/chat-message.js.map +1 -1
- package/dist/comment-composer.js +1 -1
- package/dist/comment-composer.js.map +1 -1
- package/dist/confirm-dialog.d.ts.map +1 -1
- package/dist/confirm-dialog.js +5 -2
- package/dist/confirm-dialog.js.map +1 -1
- package/dist/content-divider.js +1 -1
- package/dist/content-divider.js.map +1 -1
- package/dist/cron-schedule.d.ts.map +1 -1
- package/dist/cron-schedule.js +6 -5
- package/dist/cron-schedule.js.map +1 -1
- package/dist/data-table.d.ts.map +1 -1
- package/dist/data-table.js +3 -2
- package/dist/data-table.js.map +1 -1
- package/dist/dropdown-button.d.ts.map +1 -1
- package/dist/dropdown-button.js +4 -2
- package/dist/dropdown-button.js.map +1 -1
- package/dist/editable-text.js +1 -1
- package/dist/editable-text.js.map +1 -1
- package/dist/empty-state.d.ts +42 -0
- package/dist/empty-state.d.ts.map +1 -0
- package/dist/empty-state.js +172 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/form-field.js +1 -1
- package/dist/form-field.js.map +1 -1
- package/dist/form-select.js +3 -3
- package/dist/form-select.js.map +1 -1
- package/dist/frame-box.js +1 -1
- package/dist/frame-box.js.map +1 -1
- package/dist/fullscreen-button.js +1 -1
- package/dist/fullscreen-button.js.map +1 -1
- package/dist/icons.d.ts +2 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +2 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/kanban-card.js +1 -1
- package/dist/kanban-card.js.map +1 -1
- package/dist/kanban-column.js +3 -3
- package/dist/kanban-column.js.map +1 -1
- package/dist/kbd-hint.d.ts.map +1 -1
- package/dist/kbd-hint.js +2 -1
- package/dist/kbd-hint.js.map +1 -1
- package/dist/link-card.js +1 -1
- package/dist/link-card.js.map +1 -1
- package/dist/markdown-view.js +3 -3
- package/dist/markdown-view.js.map +1 -1
- package/dist/modal-dialog.js +1 -1
- package/dist/modal-dialog.js.map +1 -1
- package/dist/multi-select.js +5 -5
- package/dist/multi-select.js.map +1 -1
- package/dist/pagination-nav.d.ts.map +1 -1
- package/dist/pagination-nav.js +5 -1
- package/dist/pagination-nav.js.map +1 -1
- package/dist/photo-gallery.js +1 -1
- package/dist/photo-gallery.js.map +1 -1
- package/dist/popover-panel.d.ts.map +1 -1
- package/dist/popover-panel.js +4 -2
- package/dist/popover-panel.js.map +1 -1
- package/dist/progress-bar.d.ts.map +1 -1
- package/dist/progress-bar.js +1 -0
- package/dist/progress-bar.js.map +1 -1
- package/dist/radio-cards.js +1 -1
- package/dist/radio-cards.js.map +1 -1
- package/dist/radio-pills.js +1 -1
- package/dist/radio-pills.js.map +1 -1
- package/dist/reveal-button.js +1 -1
- package/dist/reveal-button.js.map +1 -1
- package/dist/scroll-to-bottom.js +1 -1
- package/dist/scroll-to-bottom.js.map +1 -1
- package/dist/scroll-to-top.js +1 -1
- package/dist/scroll-to-top.js.map +1 -1
- package/dist/skip-link.d.ts +30 -0
- package/dist/skip-link.d.ts.map +1 -0
- package/dist/skip-link.js +136 -0
- package/dist/skip-link.js.map +1 -0
- package/dist/slide-panel.js +1 -1
- package/dist/slide-panel.js.map +1 -1
- package/dist/spec-list.d.ts +49 -0
- package/dist/spec-list.d.ts.map +1 -0
- package/dist/spec-list.js +168 -0
- package/dist/spec-list.js.map +1 -0
- package/dist/stat-meter.d.ts.map +1 -1
- package/dist/stat-meter.js +1 -0
- package/dist/stat-meter.js.map +1 -1
- package/dist/tab-bar.js +1 -1
- package/dist/tab-bar.js.map +1 -1
- package/dist/text-area.js +1 -1
- package/dist/text-area.js.map +1 -1
- package/dist/tile-grid.js +1 -1
- package/dist/tile-grid.js.map +1 -1
- package/dist/tokens.css +42 -1
- package/dist/tokens.d.ts +50 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +132 -0
- package/dist/tokens.js.map +1 -1
- package/dist/tree-view.js +2 -2
- package/dist/tree-view.js.map +1 -1
- package/dist/ui-admonition.js +1 -1
- package/dist/ui-admonition.js.map +1 -1
- package/dist/ui-button.js +1 -1
- package/dist/ui-button.js.map +1 -1
- package/dist/ui-checkbox.d.ts +10 -1
- package/dist/ui-checkbox.d.ts.map +1 -1
- package/dist/ui-checkbox.js +11 -2
- package/dist/ui-checkbox.js.map +1 -1
- package/dist/video-player.js +1 -1
- package/dist/video-player.js.map +1 -1
- package/dist/vote-control.d.ts +40 -0
- package/dist/vote-control.d.ts.map +1 -0
- package/dist/vote-control.js +311 -0
- package/dist/vote-control.js.map +1 -0
- package/docs/address-autocomplete.md +1 -0
- package/docs/app-shell.md +1 -0
- package/docs/app-sidebar.md +1 -0
- package/docs/audio-player.md +1 -0
- package/docs/autocomplete-input.md +1 -0
- package/docs/breadcrumb-nav.md +70 -0
- package/docs/button-group.md +1 -0
- package/docs/calendar-day.md +1 -0
- package/docs/calendar-month.md +1 -0
- package/docs/calendar-week.md +1 -0
- package/docs/chat-message.md +1 -0
- package/docs/comment-composer.md +1 -0
- package/docs/confirm-dialog.md +1 -0
- package/docs/content-divider.md +1 -0
- package/docs/cron-schedule.md +2 -0
- package/docs/data-table.md +2 -0
- package/docs/design-language.md +57 -5
- package/docs/dropdown-button.md +1 -0
- package/docs/editable-text.md +1 -0
- package/docs/empty-state.md +55 -0
- package/docs/form-field.md +1 -0
- package/docs/form-select.md +1 -0
- package/docs/frame-box.md +1 -0
- package/docs/fullscreen-button.md +1 -0
- package/docs/icons.md +1 -0
- package/docs/kanban-card.md +1 -0
- package/docs/kanban-column.md +1 -0
- package/docs/kbd-hint.md +1 -0
- package/docs/link-card.md +1 -0
- package/docs/markdown-view.md +1 -0
- package/docs/modal-dialog.md +1 -0
- package/docs/multi-select.md +1 -0
- package/docs/pagination-nav.md +2 -0
- package/docs/photo-gallery.md +1 -0
- package/docs/popover-panel.md +1 -0
- package/docs/progress-bar.md +1 -0
- package/docs/radio-cards.md +1 -0
- package/docs/radio-pills.md +1 -0
- package/docs/reveal-button.md +1 -0
- package/docs/scroll-to-bottom.md +1 -0
- package/docs/scroll-to-top.md +1 -0
- package/docs/skip-link.md +54 -0
- package/docs/slide-panel.md +1 -0
- package/docs/spec-list.md +71 -0
- package/docs/stat-meter.md +1 -0
- package/docs/tab-bar.md +1 -0
- package/docs/text-area.md +1 -0
- package/docs/tile-grid.md +1 -0
- package/docs/tree-view.md +1 -0
- package/docs/ui-admonition.md +1 -0
- package/docs/ui-button.md +1 -0
- package/docs/ui-checkbox.md +13 -2
- package/docs/video-player.md +1 -0
- package/docs/vote-control.md +73 -0
- package/llms.txt +210 -49
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown-button.js","sourceRoot":"","sources":["../src/dropdown-button.ts"],"names":[],"mappings":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B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAAoC;AAEtC;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAA0B;AAEV;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAkB;AAE5C;IAAhB,KAAK,EAAE;6CAAuB;AACd;IAAhB,KAAK,EAAE;oDAA2B;AApMxB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAiU1B","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues, type TemplateResult } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronRight } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nlet instanceCount = 0;\n\n/** A single menu action. */\nexport interface DropdownOption {\n value: string;\n label: string;\n /** Optional leading icon rendered ahead of the label in the menu item. */\n icon?: TemplateResult | null;\n /** Renders the item in the danger color, for a destructive action (e.g. Delete). */\n danger?: boolean;\n}\n\n/** How the trigger presents itself: label only, icon only, or icon + label. */\nexport type DropdownButtonVariant = \"text\" | \"icon\" | \"text-icon\";\n\n/**\n * A button that opens an anchored menu of actions — essentially `form-select`\n * minus \"current value\" semantics: a menu, not a select. Use for a set of\n * mutually exclusive next-step actions (e.g. a failed task's Retry / Close /\n * Backlog, or a table row's overflow actions).\n *\n * Three trigger presentations share one base: `text` (the default — a\n * primary-filled button with a label and a rotating chevron), `text-icon`\n * (the same, with `icon` ahead of the label), and `icon` (a borderless,\n * square, low-emphasis icon target in the style of `icon-button` — the\n * classic \"three-dot\"/overflow menu, where `label` becomes the accessible\n * name rather than visible text). Set `size=\"sm\"` for a compact trigger one\n * step below the default, matching `ui-button`'s `sm` size. Set `circular`\n * on the `icon` variant when the trigger wraps an inherently circular\n * element (e.g. an avatar) so the hover/focus highlight matches its shape\n * instead of the default rounded-square icon-button footprint.\n *\n * @element dropdown-button\n * @fires select - Fired with `{ value: string }` when a menu item is picked.\n */\n@customElement(\"dropdown-button\")\nexport class DropdownButton extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n position: relative;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n /* Shared trigger base — layout, type, shape, and interaction states every\n variant has in common. Variant blocks below only add fill/padding. */\n button.trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n height: 2rem;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n border: 1px solid transparent;\n border-radius: var(--ui-radius-sm, 0.25rem);\n cursor: pointer;\n }\n button.trigger:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n button.trigger:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n /* text + text-icon: the primary-filled trigger. Written as :not([variant=\"icon\"])\n rather than two positive selectors so the default presentation is correct\n even before the reflected attribute lands. */\n :host(:not([variant=\"icon\"])) button.trigger {\n color: var(--ui-on-accent, #ffffff);\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border-color: var(--ui-button-border, transparent);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n padding: 0.5rem 1rem;\n }\n :host(:not([variant=\"icon\"])) button.trigger:hover:not(:disabled) {\n background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));\n }\n :host(:not([variant=\"icon\"])) button.trigger:active:not(:disabled) {\n background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));\n box-shadow: none;\n }\n :host(:not([variant=\"icon\"])) button.trigger:focus-visible:not(:active) {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n /* icon: borderless low-emphasis square target, matching icon-button. */\n :host([variant=\"icon\"]) button.trigger {\n width: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n background: none;\n }\n :host([variant=\"icon\"]) button.trigger:hover:not(:disabled) {\n background: var(--ui-surface-muted, #f8fafc);\n color: var(--ui-text, #0f172a);\n }\n /* circular: for an icon-variant trigger wrapping a round element (e.g.\n an avatar) — overrides the default rounded-square footprint so the\n hover/focus highlight matches the wrapped element's own shape. */\n :host([variant=\"icon\"][circular]) button.trigger {\n border-radius: var(--ui-radius-circle, 50%);\n }\n :host([size=\"sm\"]) button.trigger {\n height: 1.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n :host(:not([variant=\"icon\"])[size=\"sm\"]) button.trigger {\n padding: 0.25rem 0.5rem;\n }\n :host([variant=\"icon\"][size=\"sm\"]) button.trigger {\n width: 1.5rem;\n }\n .icon {\n display: flex;\n line-height: 0;\n }\n .chevron {\n display: flex;\n transform: rotate(90deg);\n transition: transform 150ms ease;\n }\n :host([open]) .chevron {\n transform: rotate(-90deg);\n }\n ul.options {\n position: absolute;\n top: 100%;\n right: 0;\n z-index: 10;\n min-width: 100%;\n max-height: 40vh;\n overflow-y: auto;\n margin: 0.25rem 0 0;\n padding: 0.25rem 0;\n list-style: none;\n white-space: nowrap;\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n li {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem 0.75rem;\n cursor: pointer;\n color: var(--ui-text, #0f172a);\n }\n li .icon {\n color: var(--ui-text-muted, #64748b);\n }\n li.danger .icon {\n color: var(--ui-danger, #dc2626);\n }\n li.danger {\n color: var(--ui-danger, #dc2626);\n }\n li.active,\n li:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n li.danger.active,\n li.danger:hover {\n color: var(--ui-danger-hover, #b91c1c);\n }\n @media (prefers-reduced-motion: reduce) {\n .chevron {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n button.trigger:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n button.trigger:disabled {\n color: GrayText;\n opacity: 1;\n }\n li.active,\n li:hover,\n li.danger.active,\n li.danger:hover {\n color: HighlightText;\n background: Highlight;\n }\n }\n `,\n ];\n\n /** The trigger button's label. In the `icon` variant it is the accessible name instead of visible text. */\n @property() label = \"\";\n /** The menu's actions. */\n @property({ attribute: false }) options: DropdownOption[] = [];\n /** Disables the trigger, preventing the menu from opening. */\n @property({ type: Boolean }) disabled = false;\n /** Trigger presentation: label only, icon only, or icon + label. */\n @property({ reflect: true }) variant: DropdownButtonVariant = \"text\";\n /** Icon template rendered by the `icon` and `text-icon` variants. */\n @property({ attribute: false }) icon: TemplateResult | null = null;\n /** Size — `sm` reduces the trigger's height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n /** `icon` variant only: renders the trigger's highlight as a circle instead of a rounded square, to match a wrapped circular element (e.g. an avatar). */\n @property({ type: Boolean, reflect: true }) circular = false;\n\n @state() private _open = false;\n @state() private _activeIndex = -1;\n readonly #menuId = `dropdown-button-menu-${++instanceCount}`;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener(\"mousedown\", this.#onWindowMousedown, true);\n this._open = false;\n this._activeIndex = -1;\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"disabled\") && this.disabled) {\n this._open = false;\n this._activeIndex = -1;\n }\n if (!changed.has(\"_open\")) return;\n this.toggleAttribute(\"open\", this._open);\n if (this._open) {\n window.addEventListener(\"mousedown\", this.#onWindowMousedown, true);\n } else {\n window.removeEventListener(\"mousedown\", this.#onWindowMousedown, true);\n }\n }\n\n #onWindowMousedown = (e: MouseEvent): void => {\n if (!e.composedPath().includes(this)) this._open = false;\n };\n\n #toggle(): void {\n if (this.disabled) return;\n this._open = !this._open;\n if (this._open) this._activeIndex = 0;\n }\n\n #select(option: DropdownOption): void {\n if (this.disabled) return;\n this._open = false;\n this.dispatchEvent(new CustomEvent(\"select\", { detail: { value: option.value } }));\n }\n\n #onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\" || e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (!this._open) {\n this.#toggle();\n return;\n }\n if (e.key === \"ArrowDown\") this.#moveActive(1);\n else if (e.key === \"ArrowUp\") this.#moveActive(-1);\n else this.#confirmActive();\n } else if (e.key === \"Escape\" && this._open) {\n e.preventDefault();\n this._open = false;\n }\n }\n\n #moveActive(delta: number): void {\n if (this.options.length === 0) return;\n const n = this.options.length;\n this._activeIndex = (this._activeIndex + delta + n) % n;\n }\n\n #confirmActive(): void {\n const option = this.options[this._activeIndex];\n if (option) this.#select(option);\n }\n\n private renderMenu() {\n if (!this._open) return nothing;\n return html`\n <ul id=${this.#menuId} class=\"options\" role=\"menu\" aria-label=${this.label}>\n ${this.options.map(\n (o, i) => html`\n <li\n id=${`${this.#menuId}-item-${i}`}\n role=\"menuitem\"\n class=${[i === this._activeIndex ? \"active\" : \"\", o.danger ? \"danger\" : \"\"]\n .filter(Boolean)\n .join(\" \")}\n @mousedown=${(e: MouseEvent) => {\n if (e.button !== 0) return;\n e.preventDefault();\n this.#select(o);\n }}\n >\n ${o.icon ? html`<span class=\"icon\" aria-hidden=\"true\">${o.icon}</span>` : nothing}\n ${o.label}\n </li>\n `,\n )}\n </ul>\n `;\n }\n\n override render() {\n const activeDescendant =\n this._open && this._activeIndex >= 0\n ? `${this.#menuId}-item-${this._activeIndex}`\n : nothing;\n const iconOnly = this.variant === \"icon\";\n return html`\n <button\n type=\"button\"\n class=\"trigger\"\n aria-haspopup=\"menu\"\n aria-expanded=${this._open}\n aria-controls=${this.#menuId}\n aria-activedescendant=${activeDescendant}\n aria-label=${iconOnly && this.label ? this.label : nothing}\n title=${iconOnly && this.label ? this.label : nothing}\n ?disabled=${this.disabled}\n @click=${() => this.#toggle()}\n @keydown=${(e: KeyboardEvent) => this.#onTriggerKeydown(e)}\n >\n ${this.variant !== \"text\" && this.icon\n ? html`<span class=\"icon\" aria-hidden=\"true\">${this.icon}</span>`\n : nothing}\n ${iconOnly ? nothing : html`<span>${this.label}</span>`}\n ${iconOnly\n ? nothing\n : html`<span class=\"chevron\" aria-hidden=\"true\">${iconChevronRight(14)}</span>`}\n </button>\n ${this.renderMenu()}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dropdown-button\": DropdownButton;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dropdown-button.js","sourceRoot":"","sources":["../src/dropdown-button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,IAAI,aAAa,GAAG,CAAC,CAAC;AAetB;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAsLL,2GAA2G;QAC/F,UAAK,GAAG,EAAE,CAAC;QACvB,0BAA0B;QACM,YAAO,GAAqB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AAE;mBAClB,CAAC,CAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;;UAExD,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI;YACpC,CAAC,CAAC,IAAI,CAAA,yCAAyC,IAAI,CAAC,IAAI,SAAS;YACjE,CAAC,CAAC,OAAO;UACT,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,SAAS,IAAI,CAAC,KAAK,SAAS;UACrD,QAAQ;YACR,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,IAAI,CAAA,4CAA4C,gBAAgB,CAAC,EAAE,CAAC,SAAS;;QAEjF,IAAI,CAAC,UAAU,EAAE;KACpB,CAAC;IACJ,CAAC;CACF,CAAA;AA5Ia;IAAX,QAAQ,EAAE;6CAAY;AAES;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;+CAAgC;AAElC;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAAyC;AAErC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAAoC;AAEtC;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CAA0B;AAEV;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAkB;AAE5C;IAAhB,KAAK,EAAE;6CAAuB;AACd;IAAhB,KAAK,EAAE;oDAA2B;AAtMxB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAmU1B","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues, type TemplateResult } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { iconChevronRight } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\nlet instanceCount = 0;\n\n/** A single menu action. */\nexport interface DropdownOption {\n value: string;\n label: string;\n /** Optional leading icon rendered ahead of the label in the menu item. */\n icon?: TemplateResult | null;\n /** Renders the item in the danger color, for a destructive action (e.g. Delete). */\n danger?: boolean;\n}\n\n/** How the trigger presents itself: label only, icon only, or icon + label. */\nexport type DropdownButtonVariant = \"text\" | \"icon\" | \"text-icon\";\n\n/**\n * A button that opens an anchored menu of actions — essentially `form-select`\n * minus \"current value\" semantics: a menu, not a select. Use for a set of\n * mutually exclusive next-step actions (e.g. a failed task's Retry / Close /\n * Backlog, or a table row's overflow actions).\n *\n * Three trigger presentations share one base: `text` (the default — a\n * primary-filled button with a label and a rotating chevron), `text-icon`\n * (the same, with `icon` ahead of the label), and `icon` (a borderless,\n * square, low-emphasis icon target in the style of `icon-button` — the\n * classic \"three-dot\"/overflow menu, where `label` becomes the accessible\n * name rather than visible text). Set `size=\"sm\"` for a compact trigger one\n * step below the default, matching `ui-button`'s `sm` size. Set `circular`\n * on the `icon` variant when the trigger wraps an inherently circular\n * element (e.g. an avatar) so the hover/focus highlight matches its shape\n * instead of the default rounded-square icon-button footprint.\n *\n * @element dropdown-button\n * @fires select - Fired with `{ value: string }` when a menu item is picked.\n */\n@customElement(\"dropdown-button\")\nexport class DropdownButton extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n position: relative;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n /* Shared trigger base — layout, type, shape, and interaction states every\n variant has in common. Variant blocks below only add fill/padding. */\n button.trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n height: 2rem;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n border: var(--ui-border-width, 1px) solid transparent;\n border-radius: var(--ui-radius-sm, 0.25rem);\n /* The border is themeable, so it has to stay inside the 2rem target. */\n box-sizing: border-box;\n cursor: pointer;\n }\n button.trigger:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n button.trigger:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n /* text + text-icon: the primary-filled trigger. Written as :not([variant=\"icon\"])\n rather than two positive selectors so the default presentation is correct\n even before the reflected attribute lands. */\n :host(:not([variant=\"icon\"])) button.trigger {\n color: var(--ui-on-accent, #ffffff);\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n border-color: var(--ui-button-border, transparent);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n text-shadow: var(--ui-button-text-shadow, none);\n padding: 0.5rem 1rem;\n }\n :host(:not([variant=\"icon\"])) button.trigger:hover:not(:disabled) {\n background: var(--ui-button-background-hover, var(--ui-primary-hover, #4338ca));\n }\n :host(:not([variant=\"icon\"])) button.trigger:active:not(:disabled) {\n background: var(--ui-button-background-active, var(--ui-button-background, var(--ui-primary, #4f46e5)));\n box-shadow: none;\n }\n :host(:not([variant=\"icon\"])) button.trigger:focus-visible:not(:active) {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n /* icon: borderless low-emphasis square target, matching icon-button. */\n :host([variant=\"icon\"]) button.trigger {\n width: 2rem;\n padding: 0;\n color: var(--ui-text-muted, #64748b);\n background: none;\n }\n :host([variant=\"icon\"]) button.trigger:hover:not(:disabled) {\n background: var(--ui-surface-muted, #f8fafc);\n color: var(--ui-text, #0f172a);\n }\n /* circular: for an icon-variant trigger wrapping a round element (e.g.\n an avatar) — overrides the default rounded-square footprint so the\n hover/focus highlight matches the wrapped element's own shape. */\n :host([variant=\"icon\"][circular]) button.trigger {\n border-radius: var(--ui-radius-circle, 50%);\n }\n :host([size=\"sm\"]) button.trigger {\n height: 1.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n :host(:not([variant=\"icon\"])[size=\"sm\"]) button.trigger {\n padding: 0.25rem 0.5rem;\n }\n :host([variant=\"icon\"][size=\"sm\"]) button.trigger {\n width: 1.5rem;\n }\n .icon {\n display: flex;\n line-height: 0;\n }\n .chevron {\n display: flex;\n transform: rotate(90deg);\n transition: transform 150ms ease;\n }\n :host([open]) .chevron {\n transform: rotate(-90deg);\n }\n ul.options {\n position: absolute;\n top: 100%;\n right: 0;\n z-index: 10;\n min-width: 100%;\n max-height: 40vh;\n overflow-y: auto;\n margin: 0.25rem 0 0;\n padding: 0.25rem 0;\n list-style: none;\n white-space: nowrap;\n background: var(--ui-surface, #ffffff);\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n li {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem 0.75rem;\n cursor: pointer;\n color: var(--ui-text, #0f172a);\n }\n li .icon {\n color: var(--ui-text-muted, #64748b);\n }\n li.danger .icon {\n color: var(--ui-danger, #dc2626);\n }\n li.danger {\n color: var(--ui-danger, #dc2626);\n }\n li.active,\n li:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n li.danger.active,\n li.danger:hover {\n color: var(--ui-danger-hover, #b91c1c);\n }\n @media (prefers-reduced-motion: reduce) {\n .chevron {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n button.trigger:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n button.trigger:disabled {\n color: GrayText;\n opacity: 1;\n }\n li.active,\n li:hover,\n li.danger.active,\n li.danger:hover {\n color: HighlightText;\n background: Highlight;\n }\n }\n `,\n ];\n\n /** The trigger button's label. In the `icon` variant it is the accessible name instead of visible text. */\n @property() label = \"\";\n /** The menu's actions. */\n @property({ attribute: false }) options: DropdownOption[] = [];\n /** Disables the trigger, preventing the menu from opening. */\n @property({ type: Boolean }) disabled = false;\n /** Trigger presentation: label only, icon only, or icon + label. */\n @property({ reflect: true }) variant: DropdownButtonVariant = \"text\";\n /** Icon template rendered by the `icon` and `text-icon` variants. */\n @property({ attribute: false }) icon: TemplateResult | null = null;\n /** Size — `sm` reduces the trigger's height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n /** `icon` variant only: renders the trigger's highlight as a circle instead of a rounded square, to match a wrapped circular element (e.g. an avatar). */\n @property({ type: Boolean, reflect: true }) circular = false;\n\n @state() private _open = false;\n @state() private _activeIndex = -1;\n readonly #menuId = `dropdown-button-menu-${++instanceCount}`;\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener(\"mousedown\", this.#onWindowMousedown, true);\n this._open = false;\n this._activeIndex = -1;\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has(\"disabled\") && this.disabled) {\n this._open = false;\n this._activeIndex = -1;\n }\n if (!changed.has(\"_open\")) return;\n this.toggleAttribute(\"open\", this._open);\n if (this._open) {\n window.addEventListener(\"mousedown\", this.#onWindowMousedown, true);\n } else {\n window.removeEventListener(\"mousedown\", this.#onWindowMousedown, true);\n }\n }\n\n #onWindowMousedown = (e: MouseEvent): void => {\n if (!e.composedPath().includes(this)) this._open = false;\n };\n\n #toggle(): void {\n if (this.disabled) return;\n this._open = !this._open;\n if (this._open) this._activeIndex = 0;\n }\n\n #select(option: DropdownOption): void {\n if (this.disabled) return;\n this._open = false;\n this.dispatchEvent(new CustomEvent(\"select\", { detail: { value: option.value } }));\n }\n\n #onTriggerKeydown(e: KeyboardEvent): void {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\" || e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n if (!this._open) {\n this.#toggle();\n return;\n }\n if (e.key === \"ArrowDown\") this.#moveActive(1);\n else if (e.key === \"ArrowUp\") this.#moveActive(-1);\n else this.#confirmActive();\n } else if (e.key === \"Escape\" && this._open) {\n e.preventDefault();\n this._open = false;\n }\n }\n\n #moveActive(delta: number): void {\n if (this.options.length === 0) return;\n const n = this.options.length;\n this._activeIndex = (this._activeIndex + delta + n) % n;\n }\n\n #confirmActive(): void {\n const option = this.options[this._activeIndex];\n if (option) this.#select(option);\n }\n\n private renderMenu() {\n if (!this._open) return nothing;\n return html`\n <ul id=${this.#menuId} class=\"options\" role=\"menu\" aria-label=${this.label}>\n ${this.options.map(\n (o, i) => html`\n <li\n id=${`${this.#menuId}-item-${i}`}\n role=\"menuitem\"\n class=${[i === this._activeIndex ? \"active\" : \"\", o.danger ? \"danger\" : \"\"]\n .filter(Boolean)\n .join(\" \")}\n @mousedown=${(e: MouseEvent) => {\n if (e.button !== 0) return;\n e.preventDefault();\n this.#select(o);\n }}\n >\n ${o.icon ? html`<span class=\"icon\" aria-hidden=\"true\">${o.icon}</span>` : nothing}\n ${o.label}\n </li>\n `,\n )}\n </ul>\n `;\n }\n\n override render() {\n const activeDescendant =\n this._open && this._activeIndex >= 0\n ? `${this.#menuId}-item-${this._activeIndex}`\n : nothing;\n const iconOnly = this.variant === \"icon\";\n return html`\n <button\n type=\"button\"\n class=\"trigger\"\n aria-haspopup=\"menu\"\n aria-expanded=${this._open}\n aria-controls=${this.#menuId}\n aria-activedescendant=${activeDescendant}\n aria-label=${iconOnly && this.label ? this.label : nothing}\n title=${iconOnly && this.label ? this.label : nothing}\n ?disabled=${this.disabled}\n @click=${() => this.#toggle()}\n @keydown=${(e: KeyboardEvent) => this.#onTriggerKeydown(e)}\n >\n ${this.variant !== \"text\" && this.icon\n ? html`<span class=\"icon\" aria-hidden=\"true\">${this.icon}</span>`\n : nothing}\n ${iconOnly ? nothing : html`<span>${this.label}</span>`}\n ${iconOnly\n ? nothing\n : html`<span class=\"chevron\" aria-hidden=\"true\">${iconChevronRight(14)}</span>`}\n </button>\n ${this.renderMenu()}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dropdown-button\": DropdownButton;\n }\n}\n"]}
|
package/dist/editable-text.js
CHANGED
|
@@ -88,7 +88,7 @@ let EditableText = class EditableText extends LitElement {
|
|
|
88
88
|
font: inherit;
|
|
89
89
|
color: inherit;
|
|
90
90
|
background: var(--ui-surface, #ffffff);
|
|
91
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
91
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
92
92
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
93
93
|
padding: 0.25rem;
|
|
94
94
|
margin: -0.25rem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable-text.js","sourceRoot":"","sources":["../src/editable-text.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAwFL,oBAAoB;QACR,UAAK,GAAG,EAAE,CAAC;QACvB,yEAAyE;QAC5C,cAAS,GAAG,KAAK,CAAC;QAC/C,0FAA0F;QAC9E,gBAAW,GAAG,EAAE,CAAC;QAC7B,mCAAmC;QACN,aAAQ,GAAG,KAAK,CAAC;QAC9C,kDAAkD;QACtC,UAAK,GAAG,E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AAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAAmB;AAEnC;IAAX,QAAQ,EAAE;iDAAkB;AAEA;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAAkB;AAElC;IAAX,QAAQ,EAAE;2CAAY;AAEN;IAAhB,KAAK,EAAE;8CAA0B;AACjB;IAAhB,KAAK,EAAE;4CAAqB;AAEK;IAAjC,KAAK,CAAC,iBAAiB,CAAC;4CAAyD;AAtGvE,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAkNxB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Jira/GitHub-style click-to-edit text: a display span that turns into an\n * `<input>` (or auto-growing `<textarea>` when `multiline`) on click. The\n * input/textarea inherits the host's font, so a title wrapped in an `<h1>`\n * edits at title size.\n *\n * @element editable-text\n * @fires change - Fired with `{ value: string }` when the committed value differs from the previous one.\n */\n@customElement(\"editable-text\")\nexport class EditableText extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: inherit;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .display {\n display: block;\n width: 100%;\n box-sizing: border-box;\n border: 0;\n color: inherit;\n background: transparent;\n font: inherit;\n line-height: inherit;\n text-align: inherit;\n cursor: text;\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.25rem;\n margin: -0.25rem;\n }\n .display.multiline {\n /* Inactive multiline text is flush; the active textarea keeps its editor inset. */\n white-space: pre-wrap;\n padding: 0;\n margin: 0;\n }\n .display:hover:not(:disabled) {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .display.empty {\n color: var(--ui-text-muted, #64748b);\n }\n .display:disabled {\n cursor: inherit;\n opacity: 0.6;\n }\n .display:disabled:hover {\n background: none;\n }\n .display:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n input,\n textarea {\n display: block;\n width: 100%;\n box-sizing: border-box;\n font: inherit;\n color: inherit;\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.25rem;\n margin: -0.25rem;\n outline: none;\n }\n input:focus-visible,\n textarea:focus-visible {\n border-color: var(--ui-primary, #4f46e5);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n textarea {\n resize: none;\n overflow: hidden;\n }\n @media (forced-colors: active) {\n .display:focus-visible,\n input:focus-visible,\n textarea:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .display:disabled {\n color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Current text. */\n @property() value = \"\";\n /** `false` renders an `<input>`, `true` an auto-growing `<textarea>`. */\n @property({ type: Boolean }) multiline = false;\n /** Muted placeholder text shown when `value` is empty, and as the input's placeholder. */\n @property() placeholder = \"\";\n /** Disables entering edit mode. */\n @property({ type: Boolean }) readonly = false;\n /** `aria-label` applied to the input/textarea. */\n @property() label = \"\";\n\n @state() private _editing = false;\n @state() private _draft = \"\";\n\n @query(\"input, textarea\") private _field?: HTMLInputElement | HTMLTextAreaElement;\n\n /** Enters edit mode, seeding the draft from the current value. */\n private _startEdit() {\n if (this.readonly) return;\n this._draft = this.value;\n this._editing = true;\n }\n\n /** Commits the draft (reverting an empty single-line commit) and exits edit mode.\n *\n * Guarded on `_editing`: removing the focused input/textarea from the DOM\n * (which happens as soon as `_editing` flips to false) makes the browser\n * fire a native `blur` on it, re-invoking this handler a second time after\n * a cancel already ran — the guard makes that second call a no-op instead\n * of re-committing the stale draft.\n */\n private _commit() {\n if (!this._editing) return;\n const next = this._draft;\n this._editing = false;\n if (!this.multiline && next.trim() === \"\") return;\n if (next === this.value) return;\n this.value = next;\n this.dispatchEvent(new CustomEvent(\"change\", { detail: { value: next } }));\n }\n\n /** Discards the draft and exits edit mode without committing. */\n private _cancel() {\n this._editing = false;\n }\n\n private _onInput(e: Event) {\n this._draft = (e.target as HTMLInputElement | HTMLTextAreaElement).value;\n if (this.multiline) this._resize();\n }\n\n private _onSingleLineKeydown(e: KeyboardEvent) {\n if (e.key === \"Enter\") {\n e.preventDefault();\n this._commit();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n this._cancel();\n }\n }\n\n private _onMultilineKeydown(e: KeyboardEvent) {\n if (e.key === \"Escape\") {\n e.preventDefault();\n this._cancel();\n } else if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n this._commit();\n }\n }\n\n /** Grows the textarea's height to fit its content. */\n private _resize() {\n const field = this._field;\n if (!field) return;\n field.style.height = \"auto\";\n field.style.height = `${field.scrollHeight}px`;\n }\n\n protected override updated(changed: Map<string, unknown>) {\n if (changed.has(\"_editing\") && this._editing) {\n const field = this._field;\n if (!field) return;\n field.focus();\n const end = field.value.length;\n field.setSelectionRange(end, end);\n if (this.multiline) this._resize();\n }\n }\n\n override render() {\n if (this._editing) {\n return this.multiline\n ? html`<textarea\n rows=\"3\"\n .value=${this._draft}\n placeholder=${this.placeholder}\n aria-label=${this.label || nothing}\n @input=${this._onInput}\n @keydown=${this._onMultilineKeydown}\n @blur=${this._commit}\n ></textarea>`\n : html`<input\n type=\"text\"\n .value=${this._draft}\n placeholder=${this.placeholder}\n aria-label=${this.label || nothing}\n @input=${this._onInput}\n @keydown=${this._onSingleLineKeydown}\n @blur=${this._commit}\n />`;\n }\n\n const isEmpty = this.value.trim() === \"\";\n const classes = `display ${this.multiline ? \"multiline\" : \"\"} ${isEmpty ? \"empty\" : \"\"} ${this.readonly ? \"readonly\" : \"\"}`;\n return html`<button\n type=\"button\"\n class=${classes}\n ?disabled=${this.readonly}\n @click=${this._startEdit}\n >${isEmpty ? this.placeholder : this.value}</button>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n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5B,IAAI,CAAC,OAAO;aACnB,CAAC;QACV,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,WAAW,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC5H,OAAO,IAAI,CAAA;;cAED,OAAO;kBACH,IAAI,CAAC,QAAQ;eAChB,IAAI,CAAC,UAAU;OACvB,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC;IACxD,CAAC;CACF,CAAA;AAzHa;IAAX,QAAQ,EAAE;2CAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CAAmB;AAEnC;IAAX,QAAQ,EAAE;iDAAkB;AAEA;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAAkB;AAElC;IAAX,QAAQ,EAAE;2CAAY;AAEN;IAAhB,KAAK,EAAE;8CAA0B;AACjB;IAAhB,KAAK,EAAE;4CAAqB;AAEK;IAAjC,KAAK,CAAC,iBAAiB,CAAC;4CAAyD;AAtGvE,YAAY;IADxB,aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CAkNxB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * Jira/GitHub-style click-to-edit text: a display span that turns into an\n * `<input>` (or auto-growing `<textarea>` when `multiline`) on click. The\n * input/textarea inherits the host's font, so a title wrapped in an `<h1>`\n * edits at title size.\n *\n * @element editable-text\n * @fires change - Fired with `{ value: string }` when the committed value differs from the previous one.\n */\n@customElement(\"editable-text\")\nexport class EditableText extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: inherit;\n font-size: inherit;\n font-weight: inherit;\n line-height: inherit;\n }\n .display {\n display: block;\n width: 100%;\n box-sizing: border-box;\n border: 0;\n color: inherit;\n background: transparent;\n font: inherit;\n line-height: inherit;\n text-align: inherit;\n cursor: text;\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.25rem;\n margin: -0.25rem;\n }\n .display.multiline {\n /* Inactive multiline text is flush; the active textarea keeps its editor inset. */\n white-space: pre-wrap;\n padding: 0;\n margin: 0;\n }\n .display:hover:not(:disabled) {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .display.empty {\n color: var(--ui-text-muted, #64748b);\n }\n .display:disabled {\n cursor: inherit;\n opacity: 0.6;\n }\n .display:disabled:hover {\n background: none;\n }\n .display:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n input,\n textarea {\n display: block;\n width: 100%;\n box-sizing: border-box;\n font: inherit;\n color: inherit;\n background: var(--ui-surface, #ffffff);\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.25rem;\n margin: -0.25rem;\n outline: none;\n }\n input:focus-visible,\n textarea:focus-visible {\n border-color: var(--ui-primary, #4f46e5);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n textarea {\n resize: none;\n overflow: hidden;\n }\n @media (forced-colors: active) {\n .display:focus-visible,\n input:focus-visible,\n textarea:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .display:disabled {\n color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Current text. */\n @property() value = \"\";\n /** `false` renders an `<input>`, `true` an auto-growing `<textarea>`. */\n @property({ type: Boolean }) multiline = false;\n /** Muted placeholder text shown when `value` is empty, and as the input's placeholder. */\n @property() placeholder = \"\";\n /** Disables entering edit mode. */\n @property({ type: Boolean }) readonly = false;\n /** `aria-label` applied to the input/textarea. */\n @property() label = \"\";\n\n @state() private _editing = false;\n @state() private _draft = \"\";\n\n @query(\"input, textarea\") private _field?: HTMLInputElement | HTMLTextAreaElement;\n\n /** Enters edit mode, seeding the draft from the current value. */\n private _startEdit() {\n if (this.readonly) return;\n this._draft = this.value;\n this._editing = true;\n }\n\n /** Commits the draft (reverting an empty single-line commit) and exits edit mode.\n *\n * Guarded on `_editing`: removing the focused input/textarea from the DOM\n * (which happens as soon as `_editing` flips to false) makes the browser\n * fire a native `blur` on it, re-invoking this handler a second time after\n * a cancel already ran — the guard makes that second call a no-op instead\n * of re-committing the stale draft.\n */\n private _commit() {\n if (!this._editing) return;\n const next = this._draft;\n this._editing = false;\n if (!this.multiline && next.trim() === \"\") return;\n if (next === this.value) return;\n this.value = next;\n this.dispatchEvent(new CustomEvent(\"change\", { detail: { value: next } }));\n }\n\n /** Discards the draft and exits edit mode without committing. */\n private _cancel() {\n this._editing = false;\n }\n\n private _onInput(e: Event) {\n this._draft = (e.target as HTMLInputElement | HTMLTextAreaElement).value;\n if (this.multiline) this._resize();\n }\n\n private _onSingleLineKeydown(e: KeyboardEvent) {\n if (e.key === \"Enter\") {\n e.preventDefault();\n this._commit();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n this._cancel();\n }\n }\n\n private _onMultilineKeydown(e: KeyboardEvent) {\n if (e.key === \"Escape\") {\n e.preventDefault();\n this._cancel();\n } else if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n this._commit();\n }\n }\n\n /** Grows the textarea's height to fit its content. */\n private _resize() {\n const field = this._field;\n if (!field) return;\n field.style.height = \"auto\";\n field.style.height = `${field.scrollHeight}px`;\n }\n\n protected override updated(changed: Map<string, unknown>) {\n if (changed.has(\"_editing\") && this._editing) {\n const field = this._field;\n if (!field) return;\n field.focus();\n const end = field.value.length;\n field.setSelectionRange(end, end);\n if (this.multiline) this._resize();\n }\n }\n\n override render() {\n if (this._editing) {\n return this.multiline\n ? html`<textarea\n rows=\"3\"\n .value=${this._draft}\n placeholder=${this.placeholder}\n aria-label=${this.label || nothing}\n @input=${this._onInput}\n @keydown=${this._onMultilineKeydown}\n @blur=${this._commit}\n ></textarea>`\n : html`<input\n type=\"text\"\n .value=${this._draft}\n placeholder=${this.placeholder}\n aria-label=${this.label || nothing}\n @input=${this._onInput}\n @keydown=${this._onSingleLineKeydown}\n @blur=${this._commit}\n />`;\n }\n\n const isEmpty = this.value.trim() === \"\";\n const classes = `display ${this.multiline ? \"multiline\" : \"\"} ${isEmpty ? \"empty\" : \"\"} ${this.readonly ? \"readonly\" : \"\"}`;\n return html`<button\n type=\"button\"\n class=${classes}\n ?disabled=${this.readonly}\n @click=${this._startEdit}\n >${isEmpty ? this.placeholder : this.value}</button>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"editable-text\": EditableText;\n }\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
/**
|
|
3
|
+
* A centered placeholder for an empty list, an empty panel, or a zero-result
|
|
4
|
+
* search: an optional leading glyph, a heading, a supporting line (or richer
|
|
5
|
+
* slotted body), and an optional call-to-action row. Purely presentational —
|
|
6
|
+
* it carries no interactive state of its own and no ARIA `role`; it is a
|
|
7
|
+
* region of content, not a live status. Every optional part collapses
|
|
8
|
+
* completely when absent, reserving no layout space.
|
|
9
|
+
*
|
|
10
|
+
* @element empty-state
|
|
11
|
+
* @slot icon - Optional leading glyph. The consumer supplies it (e.g. an inline SVG icon).
|
|
12
|
+
* @slot - Optional rich body content, an alternative to `description`.
|
|
13
|
+
* @slot actions - Optional call to action, e.g. a `ui-button`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class EmptyState extends LitElement {
|
|
16
|
+
/** The primary line. */
|
|
17
|
+
heading: string;
|
|
18
|
+
/** The supporting line under the heading. Omitted entirely when empty. */
|
|
19
|
+
description: string;
|
|
20
|
+
/** `sm` for a small panel/sidebar, `md` (default) for a full page region. `md` matches the pre-`size` look exactly. */
|
|
21
|
+
size: "sm" | "md";
|
|
22
|
+
/** Whether the icon slot currently has assigned content. */
|
|
23
|
+
private _hasIcon;
|
|
24
|
+
/** Whether the default (body) slot currently has assigned content. */
|
|
25
|
+
private _hasBody;
|
|
26
|
+
/** Whether the actions slot currently has assigned content. */
|
|
27
|
+
private _hasActions;
|
|
28
|
+
static styles: import("lit").CSSResult[];
|
|
29
|
+
/** Tracks whether the icon slot has content so its row can collapse when empty. */
|
|
30
|
+
private _onIconSlotChange;
|
|
31
|
+
/** Tracks whether the default body slot has content so its row can collapse when empty. */
|
|
32
|
+
private _onBodySlotChange;
|
|
33
|
+
/** Tracks whether the actions slot has content so its row can collapse when empty. */
|
|
34
|
+
private _onActionsSlotChange;
|
|
35
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
36
|
+
}
|
|
37
|
+
declare global {
|
|
38
|
+
interface HTMLElementTagNameMap {
|
|
39
|
+
"empty-state": EmptyState;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=empty-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-state.d.ts","sourceRoot":"","sources":["../src/empty-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAIrD;;;;;;;;;;;;GAYG;AACH,qBACa,UAAW,SAAQ,UAAU;IACxC,wBAAwB;IACZ,OAAO,SAAM;IAEzB,0EAA0E;IAC9D,WAAW,SAAM;IAE7B,uHAAuH;IAC1F,IAAI,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEtD,4DAA4D;IACnD,OAAO,CAAC,QAAQ,CAAS;IAElC,sEAAsE;IAC7D,OAAO,CAAC,QAAQ,CAAS;IAElC,+DAA+D;IACtD,OAAO,CAAC,WAAW,CAAS;IAErC,OAAgB,MAAM,4BA6EpB;IAEF,mFAAmF;IACnF,OAAO,CAAC,iBAAiB;IAKzB,2FAA2F;IAC3F,OAAO,CAAC,iBAAiB;IAKzB,sFAAsF;IACtF,OAAO,CAAC,oBAAoB;IAKnB,MAAM,yCAgBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, css, html, nothing } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
|
+
import { tokens } from "./tokens.js";
|
|
10
|
+
/**
|
|
11
|
+
* A centered placeholder for an empty list, an empty panel, or a zero-result
|
|
12
|
+
* search: an optional leading glyph, a heading, a supporting line (or richer
|
|
13
|
+
* slotted body), and an optional call-to-action row. Purely presentational —
|
|
14
|
+
* it carries no interactive state of its own and no ARIA `role`; it is a
|
|
15
|
+
* region of content, not a live status. Every optional part collapses
|
|
16
|
+
* completely when absent, reserving no layout space.
|
|
17
|
+
*
|
|
18
|
+
* @element empty-state
|
|
19
|
+
* @slot icon - Optional leading glyph. The consumer supplies it (e.g. an inline SVG icon).
|
|
20
|
+
* @slot - Optional rich body content, an alternative to `description`.
|
|
21
|
+
* @slot actions - Optional call to action, e.g. a `ui-button`.
|
|
22
|
+
*/
|
|
23
|
+
let EmptyState = class EmptyState extends LitElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
/** The primary line. */
|
|
27
|
+
this.heading = "";
|
|
28
|
+
/** The supporting line under the heading. Omitted entirely when empty. */
|
|
29
|
+
this.description = "";
|
|
30
|
+
/** `sm` for a small panel/sidebar, `md` (default) for a full page region. `md` matches the pre-`size` look exactly. */
|
|
31
|
+
this.size = "md";
|
|
32
|
+
/** Whether the icon slot currently has assigned content. */
|
|
33
|
+
this._hasIcon = false;
|
|
34
|
+
/** Whether the default (body) slot currently has assigned content. */
|
|
35
|
+
this._hasBody = false;
|
|
36
|
+
/** Whether the actions slot currently has assigned content. */
|
|
37
|
+
this._hasActions = false;
|
|
38
|
+
}
|
|
39
|
+
static { this.styles = [
|
|
40
|
+
tokens,
|
|
41
|
+
css `
|
|
42
|
+
:host {
|
|
43
|
+
display: block;
|
|
44
|
+
font-family: var(
|
|
45
|
+
--ui-font,
|
|
46
|
+
ui-sans-serif,
|
|
47
|
+
system-ui,
|
|
48
|
+
sans-serif,
|
|
49
|
+
"Apple Color Emoji",
|
|
50
|
+
"Segoe UI Emoji",
|
|
51
|
+
"Segoe UI Symbol",
|
|
52
|
+
"Noto Color Emoji"
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
.state {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
align-items: center;
|
|
59
|
+
text-align: center;
|
|
60
|
+
padding: 2rem 1rem;
|
|
61
|
+
}
|
|
62
|
+
:host([size="sm"]) .state {
|
|
63
|
+
padding: 1rem 0.75rem;
|
|
64
|
+
}
|
|
65
|
+
.icon {
|
|
66
|
+
display: inline-flex;
|
|
67
|
+
margin-bottom: 0.75rem;
|
|
68
|
+
color: var(--ui-text-muted, #64748b);
|
|
69
|
+
}
|
|
70
|
+
:host([size="sm"]) .icon {
|
|
71
|
+
margin-bottom: 0.5rem;
|
|
72
|
+
}
|
|
73
|
+
.heading {
|
|
74
|
+
margin: 0;
|
|
75
|
+
font-size: var(--ui-font-size-lg, 1rem);
|
|
76
|
+
font-weight: var(--ui-font-weight-semibold, 600);
|
|
77
|
+
line-height: var(--ui-line-height-tight, 1.25);
|
|
78
|
+
color: var(--ui-text, #0f172a);
|
|
79
|
+
}
|
|
80
|
+
:host([size="sm"]) .heading {
|
|
81
|
+
font-size: var(--ui-font-size, 0.875rem);
|
|
82
|
+
}
|
|
83
|
+
.description {
|
|
84
|
+
margin: 0.5rem 0 0;
|
|
85
|
+
max-width: 32rem;
|
|
86
|
+
font-size: var(--ui-font-size, 0.875rem);
|
|
87
|
+
font-weight: var(--ui-font-weight-regular, 400);
|
|
88
|
+
line-height: var(--ui-line-height-normal, 1.5);
|
|
89
|
+
color: var(--ui-text-muted, #64748b);
|
|
90
|
+
}
|
|
91
|
+
:host([size="sm"]) .description {
|
|
92
|
+
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
93
|
+
}
|
|
94
|
+
.body {
|
|
95
|
+
margin-top: 0.5rem;
|
|
96
|
+
color: var(--ui-text-muted, #64748b);
|
|
97
|
+
}
|
|
98
|
+
.body.empty {
|
|
99
|
+
display: none;
|
|
100
|
+
}
|
|
101
|
+
.actions {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-wrap: wrap;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
gap: 0.5rem;
|
|
107
|
+
margin-top: 1rem;
|
|
108
|
+
}
|
|
109
|
+
.actions.empty {
|
|
110
|
+
display: none;
|
|
111
|
+
}
|
|
112
|
+
.icon.empty {
|
|
113
|
+
display: none;
|
|
114
|
+
}
|
|
115
|
+
`,
|
|
116
|
+
]; }
|
|
117
|
+
/** Tracks whether the icon slot has content so its row can collapse when empty. */
|
|
118
|
+
_onIconSlotChange(event) {
|
|
119
|
+
const slot = event.target;
|
|
120
|
+
this._hasIcon = slot.assignedNodes({ flatten: true }).length > 0;
|
|
121
|
+
}
|
|
122
|
+
/** Tracks whether the default body slot has content so its row can collapse when empty. */
|
|
123
|
+
_onBodySlotChange(event) {
|
|
124
|
+
const slot = event.target;
|
|
125
|
+
this._hasBody = slot.assignedNodes({ flatten: true }).length > 0;
|
|
126
|
+
}
|
|
127
|
+
/** Tracks whether the actions slot has content so its row can collapse when empty. */
|
|
128
|
+
_onActionsSlotChange(event) {
|
|
129
|
+
const slot = event.target;
|
|
130
|
+
this._hasActions = slot.assignedNodes({ flatten: true }).length > 0;
|
|
131
|
+
}
|
|
132
|
+
render() {
|
|
133
|
+
return html `
|
|
134
|
+
<div class="state">
|
|
135
|
+
<span class="icon ${this._hasIcon ? "" : "empty"}">
|
|
136
|
+
<slot name="icon" @slotchange=${this._onIconSlotChange}></slot>
|
|
137
|
+
</span>
|
|
138
|
+
${this.heading ? html `<h2 class="heading">${this.heading}</h2>` : nothing}
|
|
139
|
+
${this.description ? html `<p class="description">${this.description}</p>` : nothing}
|
|
140
|
+
<div class="body ${this._hasBody ? "" : "empty"}">
|
|
141
|
+
<slot @slotchange=${this._onBodySlotChange}></slot>
|
|
142
|
+
</div>
|
|
143
|
+
<div class="actions ${this._hasActions ? "" : "empty"}">
|
|
144
|
+
<slot name="actions" @slotchange=${this._onActionsSlotChange}></slot>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
__decorate([
|
|
151
|
+
property()
|
|
152
|
+
], EmptyState.prototype, "heading", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
property()
|
|
155
|
+
], EmptyState.prototype, "description", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
property({ reflect: true })
|
|
158
|
+
], EmptyState.prototype, "size", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
state()
|
|
161
|
+
], EmptyState.prototype, "_hasIcon", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
state()
|
|
164
|
+
], EmptyState.prototype, "_hasBody", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
state()
|
|
167
|
+
], EmptyState.prototype, "_hasActions", void 0);
|
|
168
|
+
EmptyState = __decorate([
|
|
169
|
+
customElement("empty-state")
|
|
170
|
+
], EmptyState);
|
|
171
|
+
export { EmptyState };
|
|
172
|
+
//# sourceMappingURL=empty-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-state.js","sourceRoot":"","sources":["../src/empty-state.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;GAYG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QACL,wBAAwB;QACZ,YAAO,GAAG,EAAE,CAAC;QAEzB,0EAA0E;QAC9D,gBAAW,GAAG,EAAE,CAAC;QAE7B,uHAAuH;QAC1F,SAAI,GAAgB,IAAI,CAAC;QAEtD,4DAA4D;QAC3C,aAAQ,GAAG,KAAK,CAAC;QAElC,sEAAsE;QACrD,aAAQ,GAAG,KAAK,CAAC;QAElC,+DAA+D;QAC9C,gBAAW,GAAG,KAAK,CAAC;IAoHvC,CAAC;aAlHiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0EF;KACF,AA7EqB,CA6EpB;IAEF,mFAAmF;IAC3E,iBAAiB,CAAC,KAAY;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAyB,CAAC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aA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AC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAA0B;AAGrC;IAAhB,KAAK,EAAE;4CAA0B;AAGjB;IAAhB,KAAK,EAAE;4CAA0B;AAGjB;IAAhB,KAAK,EAAE;+CAA6B;AAjB1B,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAqItB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * A centered placeholder for an empty list, an empty panel, or a zero-result\n * search: an optional leading glyph, a heading, a supporting line (or richer\n * slotted body), and an optional call-to-action row. Purely presentational —\n * it carries no interactive state of its own and no ARIA `role`; it is a\n * region of content, not a live status. Every optional part collapses\n * completely when absent, reserving no layout space.\n *\n * @element empty-state\n * @slot icon - Optional leading glyph. The consumer supplies it (e.g. an inline SVG icon).\n * @slot - Optional rich body content, an alternative to `description`.\n * @slot actions - Optional call to action, e.g. a `ui-button`.\n */\n@customElement(\"empty-state\")\nexport class EmptyState extends LitElement {\n /** The primary line. */\n @property() heading = \"\";\n\n /** The supporting line under the heading. Omitted entirely when empty. */\n @property() description = \"\";\n\n /** `sm` for a small panel/sidebar, `md` (default) for a full page region. `md` matches the pre-`size` look exactly. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n /** Whether the icon slot currently has assigned content. */\n @state() private _hasIcon = false;\n\n /** Whether the default (body) slot currently has assigned content. */\n @state() private _hasBody = false;\n\n /** Whether the actions slot currently has assigned content. */\n @state() private _hasActions = false;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n }\n .state {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n padding: 2rem 1rem;\n }\n :host([size=\"sm\"]) .state {\n padding: 1rem 0.75rem;\n }\n .icon {\n display: inline-flex;\n margin-bottom: 0.75rem;\n color: var(--ui-text-muted, #64748b);\n }\n :host([size=\"sm\"]) .icon {\n margin-bottom: 0.5rem;\n }\n .heading {\n margin: 0;\n font-size: var(--ui-font-size-lg, 1rem);\n font-weight: var(--ui-font-weight-semibold, 600);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n }\n :host([size=\"sm\"]) .heading {\n font-size: var(--ui-font-size, 0.875rem);\n }\n .description {\n margin: 0.5rem 0 0;\n max-width: 32rem;\n font-size: var(--ui-font-size, 0.875rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text-muted, #64748b);\n }\n :host([size=\"sm\"]) .description {\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n .body {\n margin-top: 0.5rem;\n color: var(--ui-text-muted, #64748b);\n }\n .body.empty {\n display: none;\n }\n .actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: center;\n gap: 0.5rem;\n margin-top: 1rem;\n }\n .actions.empty {\n display: none;\n }\n .icon.empty {\n display: none;\n }\n `,\n ];\n\n /** Tracks whether the icon slot has content so its row can collapse when empty. */\n private _onIconSlotChange(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n this._hasIcon = slot.assignedNodes({ flatten: true }).length > 0;\n }\n\n /** Tracks whether the default body slot has content so its row can collapse when empty. */\n private _onBodySlotChange(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n this._hasBody = slot.assignedNodes({ flatten: true }).length > 0;\n }\n\n /** Tracks whether the actions slot has content so its row can collapse when empty. */\n private _onActionsSlotChange(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n this._hasActions = slot.assignedNodes({ flatten: true }).length > 0;\n }\n\n override render() {\n return html`\n <div class=\"state\">\n <span class=\"icon ${this._hasIcon ? \"\" : \"empty\"}\">\n <slot name=\"icon\" @slotchange=${this._onIconSlotChange}></slot>\n </span>\n ${this.heading ? html`<h2 class=\"heading\">${this.heading}</h2>` : nothing}\n ${this.description ? html`<p class=\"description\">${this.description}</p>` : nothing}\n <div class=\"body ${this._hasBody ? \"\" : \"empty\"}\">\n <slot @slotchange=${this._onBodySlotChange}></slot>\n </div>\n <div class=\"actions ${this._hasActions ? \"\" : \"empty\"}\">\n <slot name=\"actions\" @slotchange=${this._onActionsSlotChange}></slot>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"empty-state\": EmptyState;\n }\n}\n"]}
|
package/dist/form-field.js
CHANGED
|
@@ -227,7 +227,7 @@ let FormField = class FormField extends LitElement {
|
|
|
227
227
|
margin: 0;
|
|
228
228
|
/* See the !important note on the floating-native rule above. */
|
|
229
229
|
padding: 0.5rem 0.75rem !important;
|
|
230
|
-
border: 1px solid var(--ui-border, #e2e8f0) !important;
|
|
230
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0) !important;
|
|
231
231
|
border-radius: var(--ui-radius-sm, 0.25rem) !important;
|
|
232
232
|
color: var(--ui-text, #0f172a) !important;
|
|
233
233
|
background: var(--ui-surface, #ffffff) !important;
|
package/dist/form-field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-field.js","sourceRoot":"","sources":["../src/form-field.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EACL,aAAa,EACb,QAAQ,EACR,qBAAqB,EACrB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GAEzB,MAAM,+BAA+B,CAAC;AAEvC,IAAI,aAAa,GAAG,CAAC,CAAC;AACtB,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,MAAM;IACN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CAAC,CAAC,CAAC,OAAO;iBAC9G,OAAO;cACV;YACJ,CAAC,CAAC,OAAO;;KAEd,CAAC;IACJ,CAAC;CACF,CAAA;AA9Qa;IAAX,QAAQ,EAAE;wCAAY;AAEX;IAAX,QAAQ,EAAE;uCAAW;AAEV;IAAX,QAAQ,EAAE;wCAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAkB;AAG9C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;gDAClD;AAGL;IADhB,qBAAqB,EAAE;oDAC2B;AAElC;IAAhB,KAAK,EAAE;gDAA6D;AACpD;IAAhB,KAAK,EAAE;kDAAiC;AAxQ9B,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAugBrB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport {\n customElement,\n property,\n queryAssignedElements,\n state,\n} from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n formFieldControl,\n supportsFormFieldControl,\n type FormFieldControl,\n} from \"./utils/form-field-control.js\";\n\nlet instanceCount = 0;\nconst NATIVE_TEXT_INPUT_TYPES = new Set([\n \"date\",\n \"datetime-local\",\n \"email\",\n \"month\",\n \"number\",\n \"password\",\n \"search\",\n \"tel\",\n \"text\",\n \"time\",\n \"url\",\n \"week\",\n]);\n\n/**\n * Per-field wrapper for a form control: label, slotted control, and an\n * optional hint or error message, in one consistent unit repeated across a\n * form. Purely presentational — composes whatever control is slotted\n * (`form-select`, `multi-select`, `autocomplete-input`, `ui-checkbox`, etc.)\n * without intercepting its events or value.\n *\n * Set `floating-label` for supported text controls (`input`, `textarea`,\n * `autocomplete-input`, `address-autocomplete`, and `text-area`). The label\n * then rests inside an empty field and moves to a smaller top-left position\n * while focused or non-empty. Other controls keep the external label.\n *\n * The label wraps the default slot for a best-effort visual/click\n * association only: every existing value-entry control encapsulates its\n * real `<input>` inside its own shadow DOM, so there is no light-DOM `id` a\n * `for` attribute could target from outside, and this component cannot set\n * `aria-describedby`/`aria-invalid` on an arbitrary slotted control's\n * shadow-encapsulated input for the same reason. The error message uses\n * `role=\"alert\"` as the practical accessibility mitigation instead of true\n * `aria-describedby` association.\n *\n * @element form-field\n * @slot - The wrapped form control.\n */\n@customElement(\"form-field\")\nexport class FormField extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .field {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n .control-label {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n .label-text {\n display: flex;\n align-items: baseline;\n gap: 0.25rem;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n }\n .control-label.floating-native {\n position: relative;\n display: block;\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: var(--ui-surface, #ffffff);\n box-shadow: inset 0 0 0 1px var(--ui-border, #e2e8f0);\n }\n .control-label.floating-native:focus-within {\n box-shadow:\n inset 0 0 0 1px var(--ui-primary, #4f46e5),\n var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .control-label.floating-native .label-text {\n position: absolute;\n top: 50%;\n left: 0.75rem;\n right: 0.75rem;\n z-index: 1;\n overflow: hidden;\n transform: translateY(-50%);\n color: var(--ui-text-muted, #64748b);\n font-weight: var(--ui-font-weight-regular, 400);\n white-space: nowrap;\n text-overflow: ellipsis;\n cursor: text;\n transition:\n top 150ms ease,\n transform 150ms ease,\n font-size 150ms ease;\n }\n .control-label.floating-native.multiline .label-text {\n top: 0.25rem;\n transform: none;\n }\n .control-label.floating-native.has-value .label-text,\n .control-label.floating-native:focus-within .label-text {\n top: 0.25rem;\n transform: none;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .control-label.floating-native ::slotted(input),\n .control-label.floating-native ::slotted(textarea) {\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-height: 3rem;\n margin: 0;\n /*\n * !important below survives a host page's own global element reset\n * (e.g. Tailwind v4's layered preflight): a slotted control is real\n * light-DOM content, so the host page's own rules for \"input\"/\n * \"textarea\" compete directly against ::slotted() here, and in\n * practice win over it at equal-or-lower specificity despite living\n * in a CSS layer, since ::slotted() rules cross a shadow boundary.\n */\n padding: 1.25rem 0.75rem 0.25rem !important;\n border: 0 !important;\n border-radius: var(--ui-radius-sm, 0.25rem) !important;\n color: var(--ui-text, #0f172a) !important;\n background: transparent !important;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n ) !important;\n font-size: var(--ui-font-size, 0.875rem) !important;\n line-height: var(--ui-line-height-tight, 1.25) !important;\n }\n .control-label.floating-native ::slotted(input) {\n height: 3rem;\n }\n .control-label.floating-native ::slotted(textarea) {\n padding-bottom: 0.5rem !important;\n resize: vertical;\n }\n .control-label.floating-native.multiline ::slotted(textarea) {\n padding-top: 1.5rem !important;\n }\n .control-label.floating-native ::slotted(input:focus-visible),\n .control-label.floating-native ::slotted(textarea:focus-visible) {\n outline: none;\n }\n .control-label.floating-native ::slotted(input:disabled),\n .control-label.floating-native ::slotted(textarea:disabled) {\n cursor: not-allowed;\n opacity: 0.6 !important;\n }\n .control-label.floating-native:has(:disabled) .label-text {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .control-label.floating-native ::slotted(input:-webkit-autofill) {\n animation: form-field-autofill 0.001s;\n }\n .control-label:not(.floating-native) ::slotted(input),\n .control-label:not(.floating-native) ::slotted(textarea) {\n display: block;\n box-sizing: border-box;\n width: 100%;\n margin: 0;\n /* See the !important note on the floating-native rule above. */\n padding: 0.5rem 0.75rem !important;\n border: 1px solid var(--ui-border, #e2e8f0) !important;\n border-radius: var(--ui-radius-sm, 0.25rem) !important;\n color: var(--ui-text, #0f172a) !important;\n background: var(--ui-surface, #ffffff) !important;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n ) !important;\n font-size: var(--ui-font-size, 0.875rem) !important;\n line-height: var(--ui-line-height-normal, 1.5) !important;\n }\n .control-label:not(.floating-native) ::slotted(input) {\n height: 2rem;\n }\n .control-label:not(.floating-native) ::slotted(textarea) {\n resize: vertical;\n }\n .control-label:not(.floating-native) ::slotted(input:focus-visible),\n .control-label:not(.floating-native) ::slotted(textarea:focus-visible) {\n outline: none;\n border-color: var(--ui-primary, #4f46e5) !important;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .control-label:not(.floating-native) ::slotted(input:disabled),\n .control-label:not(.floating-native) ::slotted(textarea:disabled) {\n cursor: not-allowed;\n opacity: 0.6 !important;\n }\n .required-mark {\n color: var(--ui-danger, #dc2626);\n }\n .message {\n font-size: var(--ui-font-size-xs, 0.6875rem);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text-muted, #64748b);\n }\n .message.error {\n color: var(--ui-danger, #dc2626);\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n @media (prefers-reduced-motion: reduce) {\n .control-label.floating-native .label-text {\n transition: none;\n }\n }\n @keyframes form-field-autofill {\n from {\n opacity: 1;\n }\n to {\n opacity: 1;\n }\n }\n @media (forced-colors: active) {\n .control-label.floating-native {\n border: 1px solid CanvasText;\n box-shadow: none;\n }\n .control-label.floating-native:focus-within {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .control-label.floating-native ::slotted(input:disabled),\n .control-label.floating-native ::slotted(textarea:disabled),\n .control-label.floating-native:has(:disabled) .label-text {\n color: GrayText !important;\n opacity: 1 !important;\n }\n .control-label:not(.floating-native) ::slotted(input),\n .control-label:not(.floating-native) ::slotted(textarea) {\n border-color: CanvasText !important;\n }\n .control-label:not(.floating-native) ::slotted(input:focus-visible),\n .control-label:not(.floating-native) ::slotted(textarea:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .control-label:not(.floating-native) ::slotted(input:disabled),\n .control-label:not(.floating-native) ::slotted(textarea:disabled) {\n color: GrayText !important;\n opacity: 1 !important;\n }\n }\n `,\n ];\n\n /** Field label text. */\n @property() label = \"\";\n /** Optional helper text shown below the control when there's no `error`. */\n @property() hint = \"\";\n /** Optional error text; replaces the `hint` display when non-empty. */\n @property() error = \"\";\n /** Shows a required indicator next to the label. */\n @property({ type: Boolean }) required = false;\n /** Moves labels inside supported text controls until they receive focus or content. */\n @property({ type: Boolean, reflect: true, attribute: \"floating-label\" })\n floatingLabel = false;\n\n @queryAssignedElements()\n private readonly _assignedElements!: HTMLElement[];\n\n @state() private _floatingKind: \"delegated\" | \"native\" | null = null;\n @state() private _nativeHasValue = false;\n\n readonly #messageId = `form-field-message-${++instanceCount}`;\n #configuredControls = new Set<FormFieldControl>();\n #resetForm: HTMLFormElement | null = null;\n #placeholderControl: HTMLInputElement | HTMLTextAreaElement | null = null;\n #placeholder = \"\";\n #accessibleNameControl: HTMLInputElement | HTMLTextAreaElement | null = null;\n #accessibleName: string | null = null;\n #nativeEventControl: HTMLInputElement | HTMLTextAreaElement | null = null;\n #nativeFocused = false;\n readonly #onNativeValueChange = () => this._onControlValueChange();\n readonly #onNativeFocus = () => this._onControlFocusIn();\n readonly #onNativeBlur = () => this._onControlFocusOut();\n readonly #onNativeAnimation = (event: Event) => {\n if (event instanceof AnimationEvent) this._onNativeAnimationStart(event);\n };\n readonly #onFormReset = () => {\n window.setTimeout(() => {\n this.#updateNativeValue();\n this.#syncNativePlaceholder();\n });\n };\n\n /** Synchronizes label configuration after the component first renders. */\n protected override firstUpdated(): void {\n this.#syncControls();\n }\n\n /** Resynchronizes delegated controls when public label configuration changes. */\n protected override updated(changed: PropertyValues<this>): void {\n if (\n changed.has(\"label\") ||\n changed.has(\"required\") ||\n changed.has(\"floatingLabel\")\n ) {\n this.#syncControls();\n }\n }\n\n /** Removes delegated configuration and form listeners when disconnected. */\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n for (const control of this.#configuredControls) control[formFieldControl](null);\n this.#configuredControls.clear();\n this.#bindNativePlaceholder(null);\n this.#bindNativeAccessibleName(null);\n this.#bindNativeEvents(null);\n this.#bindResetForm(null);\n }\n\n /** Handles assigned-control changes and updates the floating-label strategy. */\n private _onSlotChange(): void {\n this.#syncControls();\n }\n\n /** Tracks native input/textarea content after user edits. */\n private _onControlValueChange(): void {\n if (this._floatingKind !== \"native\") return;\n this.#updateNativeValue();\n this.#syncNativePlaceholder();\n }\n\n /** Reveals the native placeholder once focus floats the label. */\n private _onControlFocusIn(): void {\n if (this._floatingKind !== \"native\") return;\n this.#nativeFocused = true;\n this.#syncNativePlaceholder();\n }\n\n /** Hides the native placeholder again when an empty field loses focus. */\n private _onControlFocusOut(): void {\n if (this._floatingKind !== \"native\") return;\n this.#nativeFocused = false;\n this.#syncNativePlaceholder();\n }\n\n /** Focuses a native control when its shadow-rendered floating label is clicked. */\n private _onControlLabelClick(event: MouseEvent): void {\n if (this._floatingKind !== \"native\") return;\n const control = this.#nativeControl();\n if (!control || event.composedPath().includes(control)) return;\n control.focus();\n }\n\n /** Synchronizes native value state when WebKit applies autofill without input events. */\n private _onNativeAnimationStart(event: AnimationEvent): void {\n if (\n this._floatingKind !== \"native\" ||\n event.animationName !== \"form-field-autofill\"\n ) {\n return;\n }\n this.#updateNativeValue();\n this.#syncNativePlaceholder();\n }\n\n /** Finds the sole assigned native text control, if present. */\n #nativeControl(): HTMLInputElement | HTMLTextAreaElement | null {\n if (this._assignedElements?.length !== 1) return null;\n const [element] = this._assignedElements;\n if (element instanceof HTMLTextAreaElement) return element;\n if (!(element instanceof HTMLInputElement)) return null;\n return NATIVE_TEXT_INPUT_TYPES.has(element.type) ? element : null;\n }\n\n /** Pushes current label configuration into a supported slotted control. */\n #syncControls(): void {\n const assigned = this._assignedElements ?? [];\n const delegated =\n this.floatingLabel &&\n Boolean(this.label) &&\n assigned.length === 1 &&\n supportsFormFieldControl(assigned[0])\n ? assigned[0]\n : null;\n const native =\n this.floatingLabel && Boolean(this.label) && !delegated\n ? this.#nativeControl()\n : null;\n const nextConfigured = new Set<FormFieldControl>();\n\n if (delegated) {\n delegated[formFieldControl]({\n label: this.label,\n required: this.required,\n floating: true,\n });\n nextConfigured.add(delegated);\n }\n for (const control of this.#configuredControls) {\n if (!nextConfigured.has(control)) control[formFieldControl](null);\n }\n this.#configuredControls = nextConfigured;\n\n this._floatingKind = delegated ? \"delegated\" : native ? \"native\" : null;\n this.#updateNativeValue();\n this.#bindNativePlaceholder(native);\n this.#bindNativeAccessibleName(native);\n this.#bindNativeEvents(native);\n this.#bindResetForm(native?.form ?? null);\n }\n\n /** Updates whether a native control currently contains a value. */\n #updateNativeValue(): void {\n this._nativeHasValue = Boolean(this.#nativeControl()?.value);\n }\n\n /** Preserves the consumer placeholder while floating mode temporarily hides it. */\n #bindNativePlaceholder(\n control: HTMLInputElement | HTMLTextAreaElement | null,\n ): void {\n if (control === this.#placeholderControl) {\n this.#syncNativePlaceholder();\n return;\n }\n if (this.#placeholderControl) this.#placeholderControl.placeholder = this.#placeholder;\n this.#placeholderControl = control;\n this.#placeholder = control?.placeholder ?? \"\";\n this.#nativeFocused = control === document.activeElement;\n this.#syncNativePlaceholder();\n }\n\n /** Applies the correct placeholder for the native label's focus/value state. */\n #syncNativePlaceholder(): void {\n if (!this.#placeholderControl) return;\n this.#placeholderControl.placeholder =\n this.#nativeFocused || this._nativeHasValue ? this.#placeholder : \"\";\n }\n\n /** Applies a shadow-boundary-safe accessible name and restores any prior value. */\n #bindNativeAccessibleName(\n control: HTMLInputElement | HTMLTextAreaElement | null,\n ): void {\n if (control !== this.#accessibleNameControl) {\n if (this.#accessibleNameControl) {\n if (this.#accessibleName == null) {\n this.#accessibleNameControl.removeAttribute(\"aria-label\");\n } else {\n this.#accessibleNameControl.setAttribute(\"aria-label\", this.#accessibleName);\n }\n }\n this.#accessibleNameControl = control;\n this.#accessibleName = control?.getAttribute(\"aria-label\") ?? null;\n }\n if (!control) return;\n control.setAttribute(\n \"aria-label\",\n this.required ? `${this.label} (required)` : this.label,\n );\n }\n\n /** Moves native field listeners directly between assigned controls. */\n #bindNativeEvents(control: HTMLInputElement | HTMLTextAreaElement | null): void {\n if (control === this.#nativeEventControl) return;\n this.#nativeEventControl?.removeEventListener(\"input\", this.#onNativeValueChange);\n this.#nativeEventControl?.removeEventListener(\"change\", this.#onNativeValueChange);\n this.#nativeEventControl?.removeEventListener(\"focus\", this.#onNativeFocus);\n this.#nativeEventControl?.removeEventListener(\"blur\", this.#onNativeBlur);\n this.#nativeEventControl?.removeEventListener(\n \"animationstart\",\n this.#onNativeAnimation,\n );\n this.#nativeEventControl = control;\n this.#nativeEventControl?.addEventListener(\"input\", this.#onNativeValueChange);\n this.#nativeEventControl?.addEventListener(\"change\", this.#onNativeValueChange);\n this.#nativeEventControl?.addEventListener(\"focus\", this.#onNativeFocus);\n this.#nativeEventControl?.addEventListener(\"blur\", this.#onNativeBlur);\n this.#nativeEventControl?.addEventListener(\n \"animationstart\",\n this.#onNativeAnimation,\n );\n }\n\n /** Moves the reset listener to the native control's current owner form. */\n #bindResetForm(form: HTMLFormElement | null): void {\n if (form === this.#resetForm) return;\n this.#resetForm?.removeEventListener(\"reset\", this.#onFormReset);\n this.#resetForm = form;\n this.#resetForm?.addEventListener(\"reset\", this.#onFormReset);\n }\n\n override render() {\n const message = this.error || this.hint;\n const delegatedFloating = this._floatingKind === \"delegated\";\n const nativeFloating = this._floatingKind === \"native\";\n const nativeMultiline =\n nativeFloating && this.#nativeControl() instanceof HTMLTextAreaElement;\n return html`\n <div class=\"field\">\n <label\n class=\"control-label ${nativeFloating ? \"floating-native\" : \"\"} ${nativeMultiline\n ? \"multiline\"\n : \"\"} ${this._nativeHasValue ? \"has-value\" : \"\"}\"\n @click=${this._onControlLabelClick}\n >\n ${this.label && !delegatedFloating\n ? html`<span class=\"label-text\">\n <span>${this.label}</span>\n ${this.required\n ? html`<span class=\"required-mark\" aria-hidden=\"true\">*</span\n ><span class=\"sr-only\"> (required)</span>`\n : nothing}\n </span>`\n : nothing}\n <slot @slotchange=${this._onSlotChange}></slot>\n </label>\n ${message\n ? html`<span id=${this.#messageId} class=\"message ${this.error ? \"error\" : \"\"}\" role=${this.error ? \"alert\" : nothing}\n >${message}</span\n >`\n : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"form-field\": FormField;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"form-field.js","sourceRoot":"","sources":["../src/form-field.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EACL,aAAa,EACb,QAAQ,EACR,qBAAqB,EACrB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GAEzB,MAAM,+BAA+B,CAAC;AAEvC,IAAI,aAAa,GAAG,CAAC,CAAC;AACtB,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,MAAM;IACN,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,KAAK;IACL,MA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,CAAC;CACF,CAAA;AA9Qa;IAAX,QAAQ,EAAE;wCAAY;AAEX;IAAX,QAAQ,EAAE;uCAAW;AAEV;IAAX,QAAQ,EAAE;wCAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CAAkB;AAG9C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;gDAClD;AAGL;IADhB,qBAAqB,EAAE;oDAC2B;AAElC;IAAhB,KAAK,EAAE;gDAA6D;AACpD;IAAhB,KAAK,EAAE;kDAAiC;AAxQ9B,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CAugBrB","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport {\n customElement,\n property,\n queryAssignedElements,\n state,\n} from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n formFieldControl,\n supportsFormFieldControl,\n type FormFieldControl,\n} from \"./utils/form-field-control.js\";\n\nlet instanceCount = 0;\nconst NATIVE_TEXT_INPUT_TYPES = new Set([\n \"date\",\n \"datetime-local\",\n \"email\",\n \"month\",\n \"number\",\n \"password\",\n \"search\",\n \"tel\",\n \"text\",\n \"time\",\n \"url\",\n \"week\",\n]);\n\n/**\n * Per-field wrapper for a form control: label, slotted control, and an\n * optional hint or error message, in one consistent unit repeated across a\n * form. Purely presentational — composes whatever control is slotted\n * (`form-select`, `multi-select`, `autocomplete-input`, `ui-checkbox`, etc.)\n * without intercepting its events or value.\n *\n * Set `floating-label` for supported text controls (`input`, `textarea`,\n * `autocomplete-input`, `address-autocomplete`, and `text-area`). The label\n * then rests inside an empty field and moves to a smaller top-left position\n * while focused or non-empty. Other controls keep the external label.\n *\n * The label wraps the default slot for a best-effort visual/click\n * association only: every existing value-entry control encapsulates its\n * real `<input>` inside its own shadow DOM, so there is no light-DOM `id` a\n * `for` attribute could target from outside, and this component cannot set\n * `aria-describedby`/`aria-invalid` on an arbitrary slotted control's\n * shadow-encapsulated input for the same reason. The error message uses\n * `role=\"alert\"` as the practical accessibility mitigation instead of true\n * `aria-describedby` association.\n *\n * @element form-field\n * @slot - The wrapped form control.\n */\n@customElement(\"form-field\")\nexport class FormField extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .field {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n .control-label {\n display: flex;\n flex-direction: column;\n gap: 0.25rem;\n }\n .label-text {\n display: flex;\n align-items: baseline;\n gap: 0.25rem;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n }\n .control-label.floating-native {\n position: relative;\n display: block;\n border-radius: var(--ui-radius-sm, 0.25rem);\n background: var(--ui-surface, #ffffff);\n box-shadow: inset 0 0 0 1px var(--ui-border, #e2e8f0);\n }\n .control-label.floating-native:focus-within {\n box-shadow:\n inset 0 0 0 1px var(--ui-primary, #4f46e5),\n var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .control-label.floating-native .label-text {\n position: absolute;\n top: 50%;\n left: 0.75rem;\n right: 0.75rem;\n z-index: 1;\n overflow: hidden;\n transform: translateY(-50%);\n color: var(--ui-text-muted, #64748b);\n font-weight: var(--ui-font-weight-regular, 400);\n white-space: nowrap;\n text-overflow: ellipsis;\n cursor: text;\n transition:\n top 150ms ease,\n transform 150ms ease,\n font-size 150ms ease;\n }\n .control-label.floating-native.multiline .label-text {\n top: 0.25rem;\n transform: none;\n }\n .control-label.floating-native.has-value .label-text,\n .control-label.floating-native:focus-within .label-text {\n top: 0.25rem;\n transform: none;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .control-label.floating-native ::slotted(input),\n .control-label.floating-native ::slotted(textarea) {\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-height: 3rem;\n margin: 0;\n /*\n * !important below survives a host page's own global element reset\n * (e.g. Tailwind v4's layered preflight): a slotted control is real\n * light-DOM content, so the host page's own rules for \"input\"/\n * \"textarea\" compete directly against ::slotted() here, and in\n * practice win over it at equal-or-lower specificity despite living\n * in a CSS layer, since ::slotted() rules cross a shadow boundary.\n */\n padding: 1.25rem 0.75rem 0.25rem !important;\n border: 0 !important;\n border-radius: var(--ui-radius-sm, 0.25rem) !important;\n color: var(--ui-text, #0f172a) !important;\n background: transparent !important;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n ) !important;\n font-size: var(--ui-font-size, 0.875rem) !important;\n line-height: var(--ui-line-height-tight, 1.25) !important;\n }\n .control-label.floating-native ::slotted(input) {\n height: 3rem;\n }\n .control-label.floating-native ::slotted(textarea) {\n padding-bottom: 0.5rem !important;\n resize: vertical;\n }\n .control-label.floating-native.multiline ::slotted(textarea) {\n padding-top: 1.5rem !important;\n }\n .control-label.floating-native ::slotted(input:focus-visible),\n .control-label.floating-native ::slotted(textarea:focus-visible) {\n outline: none;\n }\n .control-label.floating-native ::slotted(input:disabled),\n .control-label.floating-native ::slotted(textarea:disabled) {\n cursor: not-allowed;\n opacity: 0.6 !important;\n }\n .control-label.floating-native:has(:disabled) .label-text {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .control-label.floating-native ::slotted(input:-webkit-autofill) {\n animation: form-field-autofill 0.001s;\n }\n .control-label:not(.floating-native) ::slotted(input),\n .control-label:not(.floating-native) ::slotted(textarea) {\n display: block;\n box-sizing: border-box;\n width: 100%;\n margin: 0;\n /* See the !important note on the floating-native rule above. */\n padding: 0.5rem 0.75rem !important;\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0) !important;\n border-radius: var(--ui-radius-sm, 0.25rem) !important;\n color: var(--ui-text, #0f172a) !important;\n background: var(--ui-surface, #ffffff) !important;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n ) !important;\n font-size: var(--ui-font-size, 0.875rem) !important;\n line-height: var(--ui-line-height-normal, 1.5) !important;\n }\n .control-label:not(.floating-native) ::slotted(input) {\n height: 2rem;\n }\n .control-label:not(.floating-native) ::slotted(textarea) {\n resize: vertical;\n }\n .control-label:not(.floating-native) ::slotted(input:focus-visible),\n .control-label:not(.floating-native) ::slotted(textarea:focus-visible) {\n outline: none;\n border-color: var(--ui-primary, #4f46e5) !important;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .control-label:not(.floating-native) ::slotted(input:disabled),\n .control-label:not(.floating-native) ::slotted(textarea:disabled) {\n cursor: not-allowed;\n opacity: 0.6 !important;\n }\n .required-mark {\n color: var(--ui-danger, #dc2626);\n }\n .message {\n font-size: var(--ui-font-size-xs, 0.6875rem);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text-muted, #64748b);\n }\n .message.error {\n color: var(--ui-danger, #dc2626);\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n @media (prefers-reduced-motion: reduce) {\n .control-label.floating-native .label-text {\n transition: none;\n }\n }\n @keyframes form-field-autofill {\n from {\n opacity: 1;\n }\n to {\n opacity: 1;\n }\n }\n @media (forced-colors: active) {\n .control-label.floating-native {\n border: 1px solid CanvasText;\n box-shadow: none;\n }\n .control-label.floating-native:focus-within {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .control-label.floating-native ::slotted(input:disabled),\n .control-label.floating-native ::slotted(textarea:disabled),\n .control-label.floating-native:has(:disabled) .label-text {\n color: GrayText !important;\n opacity: 1 !important;\n }\n .control-label:not(.floating-native) ::slotted(input),\n .control-label:not(.floating-native) ::slotted(textarea) {\n border-color: CanvasText !important;\n }\n .control-label:not(.floating-native) ::slotted(input:focus-visible),\n .control-label:not(.floating-native) ::slotted(textarea:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .control-label:not(.floating-native) ::slotted(input:disabled),\n .control-label:not(.floating-native) ::slotted(textarea:disabled) {\n color: GrayText !important;\n opacity: 1 !important;\n }\n }\n `,\n ];\n\n /** Field label text. */\n @property() label = \"\";\n /** Optional helper text shown below the control when there's no `error`. */\n @property() hint = \"\";\n /** Optional error text; replaces the `hint` display when non-empty. */\n @property() error = \"\";\n /** Shows a required indicator next to the label. */\n @property({ type: Boolean }) required = false;\n /** Moves labels inside supported text controls until they receive focus or content. */\n @property({ type: Boolean, reflect: true, attribute: \"floating-label\" })\n floatingLabel = false;\n\n @queryAssignedElements()\n private readonly _assignedElements!: HTMLElement[];\n\n @state() private _floatingKind: \"delegated\" | \"native\" | null = null;\n @state() private _nativeHasValue = false;\n\n readonly #messageId = `form-field-message-${++instanceCount}`;\n #configuredControls = new Set<FormFieldControl>();\n #resetForm: HTMLFormElement | null = null;\n #placeholderControl: HTMLInputElement | HTMLTextAreaElement | null = null;\n #placeholder = \"\";\n #accessibleNameControl: HTMLInputElement | HTMLTextAreaElement | null = null;\n #accessibleName: string | null = null;\n #nativeEventControl: HTMLInputElement | HTMLTextAreaElement | null = null;\n #nativeFocused = false;\n readonly #onNativeValueChange = () => this._onControlValueChange();\n readonly #onNativeFocus = () => this._onControlFocusIn();\n readonly #onNativeBlur = () => this._onControlFocusOut();\n readonly #onNativeAnimation = (event: Event) => {\n if (event instanceof AnimationEvent) this._onNativeAnimationStart(event);\n };\n readonly #onFormReset = () => {\n window.setTimeout(() => {\n this.#updateNativeValue();\n this.#syncNativePlaceholder();\n });\n };\n\n /** Synchronizes label configuration after the component first renders. */\n protected override firstUpdated(): void {\n this.#syncControls();\n }\n\n /** Resynchronizes delegated controls when public label configuration changes. */\n protected override updated(changed: PropertyValues<this>): void {\n if (\n changed.has(\"label\") ||\n changed.has(\"required\") ||\n changed.has(\"floatingLabel\")\n ) {\n this.#syncControls();\n }\n }\n\n /** Removes delegated configuration and form listeners when disconnected. */\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n for (const control of this.#configuredControls) control[formFieldControl](null);\n this.#configuredControls.clear();\n this.#bindNativePlaceholder(null);\n this.#bindNativeAccessibleName(null);\n this.#bindNativeEvents(null);\n this.#bindResetForm(null);\n }\n\n /** Handles assigned-control changes and updates the floating-label strategy. */\n private _onSlotChange(): void {\n this.#syncControls();\n }\n\n /** Tracks native input/textarea content after user edits. */\n private _onControlValueChange(): void {\n if (this._floatingKind !== \"native\") return;\n this.#updateNativeValue();\n this.#syncNativePlaceholder();\n }\n\n /** Reveals the native placeholder once focus floats the label. */\n private _onControlFocusIn(): void {\n if (this._floatingKind !== \"native\") return;\n this.#nativeFocused = true;\n this.#syncNativePlaceholder();\n }\n\n /** Hides the native placeholder again when an empty field loses focus. */\n private _onControlFocusOut(): void {\n if (this._floatingKind !== \"native\") return;\n this.#nativeFocused = false;\n this.#syncNativePlaceholder();\n }\n\n /** Focuses a native control when its shadow-rendered floating label is clicked. */\n private _onControlLabelClick(event: MouseEvent): void {\n if (this._floatingKind !== \"native\") return;\n const control = this.#nativeControl();\n if (!control || event.composedPath().includes(control)) return;\n control.focus();\n }\n\n /** Synchronizes native value state when WebKit applies autofill without input events. */\n private _onNativeAnimationStart(event: AnimationEvent): void {\n if (\n this._floatingKind !== \"native\" ||\n event.animationName !== \"form-field-autofill\"\n ) {\n return;\n }\n this.#updateNativeValue();\n this.#syncNativePlaceholder();\n }\n\n /** Finds the sole assigned native text control, if present. */\n #nativeControl(): HTMLInputElement | HTMLTextAreaElement | null {\n if (this._assignedElements?.length !== 1) return null;\n const [element] = this._assignedElements;\n if (element instanceof HTMLTextAreaElement) return element;\n if (!(element instanceof HTMLInputElement)) return null;\n return NATIVE_TEXT_INPUT_TYPES.has(element.type) ? element : null;\n }\n\n /** Pushes current label configuration into a supported slotted control. */\n #syncControls(): void {\n const assigned = this._assignedElements ?? [];\n const delegated =\n this.floatingLabel &&\n Boolean(this.label) &&\n assigned.length === 1 &&\n supportsFormFieldControl(assigned[0])\n ? assigned[0]\n : null;\n const native =\n this.floatingLabel && Boolean(this.label) && !delegated\n ? this.#nativeControl()\n : null;\n const nextConfigured = new Set<FormFieldControl>();\n\n if (delegated) {\n delegated[formFieldControl]({\n label: this.label,\n required: this.required,\n floating: true,\n });\n nextConfigured.add(delegated);\n }\n for (const control of this.#configuredControls) {\n if (!nextConfigured.has(control)) control[formFieldControl](null);\n }\n this.#configuredControls = nextConfigured;\n\n this._floatingKind = delegated ? \"delegated\" : native ? \"native\" : null;\n this.#updateNativeValue();\n this.#bindNativePlaceholder(native);\n this.#bindNativeAccessibleName(native);\n this.#bindNativeEvents(native);\n this.#bindResetForm(native?.form ?? null);\n }\n\n /** Updates whether a native control currently contains a value. */\n #updateNativeValue(): void {\n this._nativeHasValue = Boolean(this.#nativeControl()?.value);\n }\n\n /** Preserves the consumer placeholder while floating mode temporarily hides it. */\n #bindNativePlaceholder(\n control: HTMLInputElement | HTMLTextAreaElement | null,\n ): void {\n if (control === this.#placeholderControl) {\n this.#syncNativePlaceholder();\n return;\n }\n if (this.#placeholderControl) this.#placeholderControl.placeholder = this.#placeholder;\n this.#placeholderControl = control;\n this.#placeholder = control?.placeholder ?? \"\";\n this.#nativeFocused = control === document.activeElement;\n this.#syncNativePlaceholder();\n }\n\n /** Applies the correct placeholder for the native label's focus/value state. */\n #syncNativePlaceholder(): void {\n if (!this.#placeholderControl) return;\n this.#placeholderControl.placeholder =\n this.#nativeFocused || this._nativeHasValue ? this.#placeholder : \"\";\n }\n\n /** Applies a shadow-boundary-safe accessible name and restores any prior value. */\n #bindNativeAccessibleName(\n control: HTMLInputElement | HTMLTextAreaElement | null,\n ): void {\n if (control !== this.#accessibleNameControl) {\n if (this.#accessibleNameControl) {\n if (this.#accessibleName == null) {\n this.#accessibleNameControl.removeAttribute(\"aria-label\");\n } else {\n this.#accessibleNameControl.setAttribute(\"aria-label\", this.#accessibleName);\n }\n }\n this.#accessibleNameControl = control;\n this.#accessibleName = control?.getAttribute(\"aria-label\") ?? null;\n }\n if (!control) return;\n control.setAttribute(\n \"aria-label\",\n this.required ? `${this.label} (required)` : this.label,\n );\n }\n\n /** Moves native field listeners directly between assigned controls. */\n #bindNativeEvents(control: HTMLInputElement | HTMLTextAreaElement | null): void {\n if (control === this.#nativeEventControl) return;\n this.#nativeEventControl?.removeEventListener(\"input\", this.#onNativeValueChange);\n this.#nativeEventControl?.removeEventListener(\"change\", this.#onNativeValueChange);\n this.#nativeEventControl?.removeEventListener(\"focus\", this.#onNativeFocus);\n this.#nativeEventControl?.removeEventListener(\"blur\", this.#onNativeBlur);\n this.#nativeEventControl?.removeEventListener(\n \"animationstart\",\n this.#onNativeAnimation,\n );\n this.#nativeEventControl = control;\n this.#nativeEventControl?.addEventListener(\"input\", this.#onNativeValueChange);\n this.#nativeEventControl?.addEventListener(\"change\", this.#onNativeValueChange);\n this.#nativeEventControl?.addEventListener(\"focus\", this.#onNativeFocus);\n this.#nativeEventControl?.addEventListener(\"blur\", this.#onNativeBlur);\n this.#nativeEventControl?.addEventListener(\n \"animationstart\",\n this.#onNativeAnimation,\n );\n }\n\n /** Moves the reset listener to the native control's current owner form. */\n #bindResetForm(form: HTMLFormElement | null): void {\n if (form === this.#resetForm) return;\n this.#resetForm?.removeEventListener(\"reset\", this.#onFormReset);\n this.#resetForm = form;\n this.#resetForm?.addEventListener(\"reset\", this.#onFormReset);\n }\n\n override render() {\n const message = this.error || this.hint;\n const delegatedFloating = this._floatingKind === \"delegated\";\n const nativeFloating = this._floatingKind === \"native\";\n const nativeMultiline =\n nativeFloating && this.#nativeControl() instanceof HTMLTextAreaElement;\n return html`\n <div class=\"field\">\n <label\n class=\"control-label ${nativeFloating ? \"floating-native\" : \"\"} ${nativeMultiline\n ? \"multiline\"\n : \"\"} ${this._nativeHasValue ? \"has-value\" : \"\"}\"\n @click=${this._onControlLabelClick}\n >\n ${this.label && !delegatedFloating\n ? html`<span class=\"label-text\">\n <span>${this.label}</span>\n ${this.required\n ? html`<span class=\"required-mark\" aria-hidden=\"true\">*</span\n ><span class=\"sr-only\"> (required)</span>`\n : nothing}\n </span>`\n : nothing}\n <slot @slotchange=${this._onSlotChange}></slot>\n </label>\n ${message\n ? html`<span id=${this.#messageId} class=\"message ${this.error ? \"error\" : \"\"}\" role=${this.error ? \"alert\" : nothing}\n >${message}</span\n >`\n : nothing}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"form-field\": FormField;\n }\n}\n"]}
|
package/dist/form-select.js
CHANGED
|
@@ -106,7 +106,7 @@ let FormSelect = class FormSelect extends LitElement {
|
|
|
106
106
|
line-height: var(--ui-line-height-tight, 1.25);
|
|
107
107
|
color: var(--ui-text, #0f172a);
|
|
108
108
|
background: var(--ui-surface, #ffffff);
|
|
109
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
109
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
110
110
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
111
111
|
padding: 0.5rem 0.75rem;
|
|
112
112
|
cursor: pointer;
|
|
@@ -133,7 +133,7 @@ let FormSelect = class FormSelect extends LitElement {
|
|
|
133
133
|
box-sizing: border-box;
|
|
134
134
|
color: var(--ui-text, #0f172a);
|
|
135
135
|
background: var(--ui-surface, #ffffff);
|
|
136
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
136
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
137
137
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
138
138
|
cursor: text;
|
|
139
139
|
}
|
|
@@ -203,7 +203,7 @@ let FormSelect = class FormSelect extends LitElement {
|
|
|
203
203
|
white-space: nowrap;
|
|
204
204
|
color: var(--ui-text, #0f172a);
|
|
205
205
|
background: var(--ui-surface, #ffffff);
|
|
206
|
-
border: 1px solid var(--ui-border, #e2e8f0);
|
|
206
|
+
border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
|
|
207
207
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
208
208
|
box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));
|
|
209
209
|
}
|