@f-ewald/components 1.39.0 → 1.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/README.md +48 -0
  2. package/custom-elements.json +1179 -100
  3. package/dist/address-autocomplete.js +2 -2
  4. package/dist/address-autocomplete.js.map +1 -1
  5. package/dist/app-shell.js +4 -4
  6. package/dist/app-shell.js.map +1 -1
  7. package/dist/app-sidebar.js +2 -2
  8. package/dist/app-sidebar.js.map +1 -1
  9. package/dist/audio-player.js +1 -1
  10. package/dist/audio-player.js.map +1 -1
  11. package/dist/autocomplete-input.js +2 -2
  12. package/dist/autocomplete-input.js.map +1 -1
  13. package/dist/breadcrumb-nav.d.ts +87 -0
  14. package/dist/breadcrumb-nav.d.ts.map +1 -0
  15. package/dist/breadcrumb-nav.js +281 -0
  16. package/dist/breadcrumb-nav.js.map +1 -0
  17. package/dist/button-group.js +2 -2
  18. package/dist/button-group.js.map +1 -1
  19. package/dist/calendar-day.js +3 -3
  20. package/dist/calendar-day.js.map +1 -1
  21. package/dist/calendar-month.d.ts.map +1 -1
  22. package/dist/calendar-month.js +4 -1
  23. package/dist/calendar-month.js.map +1 -1
  24. package/dist/calendar-week.js +4 -4
  25. package/dist/calendar-week.js.map +1 -1
  26. package/dist/chat-message.js +1 -1
  27. package/dist/chat-message.js.map +1 -1
  28. package/dist/comment-composer.js +1 -1
  29. package/dist/comment-composer.js.map +1 -1
  30. package/dist/confirm-dialog.d.ts.map +1 -1
  31. package/dist/confirm-dialog.js +5 -2
  32. package/dist/confirm-dialog.js.map +1 -1
  33. package/dist/content-divider.js +1 -1
  34. package/dist/content-divider.js.map +1 -1
  35. package/dist/cron-schedule.d.ts.map +1 -1
  36. package/dist/cron-schedule.js +6 -5
  37. package/dist/cron-schedule.js.map +1 -1
  38. package/dist/data-table.d.ts.map +1 -1
  39. package/dist/data-table.js +3 -2
  40. package/dist/data-table.js.map +1 -1
  41. package/dist/dropdown-button.d.ts.map +1 -1
  42. package/dist/dropdown-button.js +4 -2
  43. package/dist/dropdown-button.js.map +1 -1
  44. package/dist/editable-text.js +1 -1
  45. package/dist/editable-text.js.map +1 -1
  46. package/dist/empty-state.d.ts +58 -0
  47. package/dist/empty-state.d.ts.map +1 -0
  48. package/dist/empty-state.js +203 -0
  49. package/dist/empty-state.js.map +1 -0
  50. package/dist/form-field.js +1 -1
  51. package/dist/form-field.js.map +1 -1
  52. package/dist/form-select.js +3 -3
  53. package/dist/form-select.js.map +1 -1
  54. package/dist/frame-box.js +1 -1
  55. package/dist/frame-box.js.map +1 -1
  56. package/dist/fullscreen-button.js +1 -1
  57. package/dist/fullscreen-button.js.map +1 -1
  58. package/dist/icons.d.ts +2 -0
  59. package/dist/icons.d.ts.map +1 -1
  60. package/dist/icons.js +2 -0
  61. package/dist/icons.js.map +1 -1
  62. package/dist/index.d.ts +6 -1
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +6 -1
  65. package/dist/index.js.map +1 -1
  66. package/dist/kanban-card.js +1 -1
  67. package/dist/kanban-card.js.map +1 -1
  68. package/dist/kanban-column.js +3 -3
  69. package/dist/kanban-column.js.map +1 -1
  70. package/dist/kbd-hint.d.ts.map +1 -1
  71. package/dist/kbd-hint.js +2 -1
  72. package/dist/kbd-hint.js.map +1 -1
  73. package/dist/link-card.js +1 -1
  74. package/dist/link-card.js.map +1 -1
  75. package/dist/markdown-view.js +3 -3
  76. package/dist/markdown-view.js.map +1 -1
  77. package/dist/modal-dialog.js +1 -1
  78. package/dist/modal-dialog.js.map +1 -1
  79. package/dist/multi-select.js +5 -5
  80. package/dist/multi-select.js.map +1 -1
  81. package/dist/pagination-nav.d.ts.map +1 -1
  82. package/dist/pagination-nav.js +5 -1
  83. package/dist/pagination-nav.js.map +1 -1
  84. package/dist/photo-gallery.js +1 -1
  85. package/dist/photo-gallery.js.map +1 -1
  86. package/dist/popover-panel.d.ts.map +1 -1
  87. package/dist/popover-panel.js +4 -2
  88. package/dist/popover-panel.js.map +1 -1
  89. package/dist/progress-bar.d.ts.map +1 -1
  90. package/dist/progress-bar.js +1 -0
  91. package/dist/progress-bar.js.map +1 -1
  92. package/dist/radio-cards.js +1 -1
  93. package/dist/radio-cards.js.map +1 -1
  94. package/dist/radio-pills.js +1 -1
  95. package/dist/radio-pills.js.map +1 -1
  96. package/dist/reveal-button.js +1 -1
  97. package/dist/reveal-button.js.map +1 -1
  98. package/dist/scroll-to-bottom.js +1 -1
  99. package/dist/scroll-to-bottom.js.map +1 -1
  100. package/dist/scroll-to-top.js +1 -1
  101. package/dist/scroll-to-top.js.map +1 -1
  102. package/dist/skip-link.d.ts +38 -0
  103. package/dist/skip-link.d.ts.map +1 -0
  104. package/dist/skip-link.js +184 -0
  105. package/dist/skip-link.js.map +1 -0
  106. package/dist/slide-panel.js +1 -1
  107. package/dist/slide-panel.js.map +1 -1
  108. package/dist/spec-list.d.ts +58 -0
  109. package/dist/spec-list.d.ts.map +1 -0
  110. package/dist/spec-list.js +226 -0
  111. package/dist/spec-list.js.map +1 -0
  112. package/dist/stat-meter.d.ts.map +1 -1
  113. package/dist/stat-meter.js +1 -0
  114. package/dist/stat-meter.js.map +1 -1
  115. package/dist/tab-bar.js +1 -1
  116. package/dist/tab-bar.js.map +1 -1
  117. package/dist/text-area.js +1 -1
  118. package/dist/text-area.js.map +1 -1
  119. package/dist/tile-grid.js +1 -1
  120. package/dist/tile-grid.js.map +1 -1
  121. package/dist/tokens.css +42 -1
  122. package/dist/tokens.d.ts +50 -0
  123. package/dist/tokens.d.ts.map +1 -1
  124. package/dist/tokens.js +136 -0
  125. package/dist/tokens.js.map +1 -1
  126. package/dist/tree-view.js +2 -2
  127. package/dist/tree-view.js.map +1 -1
  128. package/dist/ui-admonition.js +1 -1
  129. package/dist/ui-admonition.js.map +1 -1
  130. package/dist/ui-button.js +1 -1
  131. package/dist/ui-button.js.map +1 -1
  132. package/dist/video-player.js +1 -1
  133. package/dist/video-player.js.map +1 -1
  134. package/dist/vote-control.d.ts +40 -0
  135. package/dist/vote-control.d.ts.map +1 -0
  136. package/dist/vote-control.js +318 -0
  137. package/dist/vote-control.js.map +1 -0
  138. package/docs/address-autocomplete.md +1 -0
  139. package/docs/app-shell.md +1 -0
  140. package/docs/app-sidebar.md +1 -0
  141. package/docs/audio-player.md +1 -0
  142. package/docs/autocomplete-input.md +1 -0
  143. package/docs/breadcrumb-nav.md +70 -0
  144. package/docs/button-group.md +1 -0
  145. package/docs/calendar-day.md +1 -0
  146. package/docs/calendar-month.md +1 -0
  147. package/docs/calendar-week.md +1 -0
  148. package/docs/chat-message.md +1 -0
  149. package/docs/comment-composer.md +1 -0
  150. package/docs/confirm-dialog.md +1 -0
  151. package/docs/content-divider.md +1 -0
  152. package/docs/cron-schedule.md +2 -0
  153. package/docs/data-table.md +2 -0
  154. package/docs/design-language.md +57 -5
  155. package/docs/dropdown-button.md +1 -0
  156. package/docs/editable-text.md +1 -0
  157. package/docs/empty-state.md +60 -0
  158. package/docs/form-field.md +1 -0
  159. package/docs/form-select.md +1 -0
  160. package/docs/frame-box.md +1 -0
  161. package/docs/fullscreen-button.md +1 -0
  162. package/docs/icons.md +1 -0
  163. package/docs/kanban-card.md +1 -0
  164. package/docs/kanban-column.md +1 -0
  165. package/docs/kbd-hint.md +1 -0
  166. package/docs/link-card.md +1 -0
  167. package/docs/markdown-view.md +1 -0
  168. package/docs/modal-dialog.md +1 -0
  169. package/docs/multi-select.md +1 -0
  170. package/docs/pagination-nav.md +2 -0
  171. package/docs/photo-gallery.md +1 -0
  172. package/docs/popover-panel.md +1 -0
  173. package/docs/progress-bar.md +1 -0
  174. package/docs/radio-cards.md +1 -0
  175. package/docs/radio-pills.md +1 -0
  176. package/docs/reveal-button.md +1 -0
  177. package/docs/scroll-to-bottom.md +1 -0
  178. package/docs/scroll-to-top.md +1 -0
  179. package/docs/skip-link.md +61 -0
  180. package/docs/slide-panel.md +1 -0
  181. package/docs/spec-list.md +79 -0
  182. package/docs/stat-meter.md +1 -0
  183. package/docs/tab-bar.md +1 -0
  184. package/docs/text-area.md +1 -0
  185. package/docs/tile-grid.md +1 -0
  186. package/docs/tree-view.md +1 -0
  187. package/docs/ui-admonition.md +1 -0
  188. package/docs/ui-button.md +1 -0
  189. package/docs/video-player.md +1 -0
  190. package/docs/vote-control.md +73 -0
  191. package/llms.txt +212 -49
  192. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-input.js","sourceRoot":"","sources":["../src/autocomplete-input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAuB,MAAM,KAAK,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,gBAAgB,GAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,IAAI,aAAa,GAAG,CAAC,CAAC;AAQtB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAqNL,mFAAmF;QACvE,UAAK,GAAG,EAAE,CAAC;QACvB,sDAAsD;QAC1C,gBAAW,GAAG,EAAE,CAAC;QAC7B,8DAA8D;QACjC,aAAQ,GAAG,KAAK,CAAC;QAC9C,0DAA0D;QACd,aAAQ,GAAG,KAAK,CAAC;QAC7D,oEAAoE;QACxB,cAAS,GAAG,KAAK,CAAC;QAC9D,uEAAuE;QAC3D,aAAQ,GAAG,EAAE,CAAC;QAC1B,wEAAwE;QAChC,eAAU,GAAG,GAAG,CAAC;QACzD,uEAAuE;QAC3C,aAAQ,GAAG,GAAG,CAAC;QAC3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EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAAkB;AAEjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oDAAmB;AAElD;IAAX,QAAQ,EAAE;mDAAe;AAEc;IAAvC,QAAQ,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;qDAAkB;AAE7B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAgB;AAEU;IAApD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;oDAAe;AAMnC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;kDAA6C;AAE3D;IAAhB,KAAK,EAAE;uDAAiD;AACxC;IAAhB,KAAK,EAAE;gDAAuB;AACd;IAAhB,KAAK,EAAE;uDAA2B;AAClB;IAAhB,KAAK,EAAE;wDAA+B;AACtB;IAAhB,KAAK,EAAE;2DAAgE;AAEhD;IAAvB,KAAK,CAAC,OAAO,CAAC;iDAAmC;AApPvC,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CA8jB7B","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n formFieldControl,\n type FormFieldControlConfig,\n} from \"./utils/form-field-control.js\";\nimport { submitWithDefaultButton } from \"./utils/form.js\";\n\nlet instanceCount = 0;\n\n/** A single autocomplete candidate: an opaque `key` plus its display `value`. */\nexport interface AutocompleteOption {\n key: string;\n value: string;\n}\n\n/**\n * Generic form-associated text input with a suggestion dropdown, for any\n * \"type to filter a list of `{key, value}` options\" use case. Works as a\n * drop-in replacement for a plain `<input>` inside a `<form>`: set `name` on\n * the element itself and consumers keep reading\n * `new FormData(form).get(name)` and calling `form.reset()` unchanged — the\n * submitted value is the picked option's `value`, while `key` is available\n * via the `option-select` event and the `selectedOption` getter for cases\n * that need the underlying id rather than the display text.\n *\n * Supports two suggestion sources:\n * - **API**: set `endpoint` to a URL that, given a `?<query-param>=<text>`\n * query string, responds with a JSON array of `{key, value}` objects.\n * Requests are debounced as the user types.\n * - **Local array**: set `options` to a fixed `AutocompleteOption[]` and the\n * component filters it client-side instead of making any network\n * request. Useful for small/fixed lists, offline use, or tests. Takes\n * priority over `endpoint` whenever it's non-null.\n *\n * Set `clearable` to show an in-field clear action whenever a value is\n * present.\n *\n * @element autocomplete-input\n * @fires option-select - An option was picked; detail: AutocompleteOption.\n * @fires input - Native-compatible input event fired while editing or clearing.\n */\n@customElement(\"autocomplete-input\")\nexport class AutocompleteInput extends LitElement {\n static formAssociated = true;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n position: relative;\n }\n .field-shell {\n position: relative;\n }\n input {\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface, #ffffff);\n padding: 0.5rem 0.75rem;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n width: 100%;\n height: 2rem;\n box-sizing: border-box;\n }\n .field-shell.clearable input {\n padding-right: 2rem;\n }\n .clear-button {\n position: absolute;\n top: 0;\n right: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 2rem;\n height: 2rem;\n /* Insets the hover/focus background by the input's 1px border so it\n stays fully inside the field instead of painting over the border. */\n padding: 1px;\n background-clip: content-box;\n border: 0;\n border-radius: var(--ui-radius-sm, 0.25rem);\n color: var(--ui-text-muted, #64748b);\n background-color: transparent;\n cursor: pointer;\n line-height: 0;\n }\n .clear-button:hover {\n color: var(--ui-text, #0f172a);\n background-color: var(--ui-surface-muted, #f8fafc);\n }\n .clear-button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .floating-label {\n position: absolute;\n top: 50%;\n left: 0.75rem;\n right: 0.75rem;\n z-index: 1;\n display: flex;\n align-items: baseline;\n gap: 0.25rem;\n overflow: hidden;\n transform: translateY(-50%);\n color: var(--ui-text-muted, #64748b);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n text-overflow: ellipsis;\n cursor: text;\n transition:\n top 150ms ease,\n transform 150ms ease,\n font-size 150ms ease;\n }\n .field-shell.clearable .floating-label {\n right: 2rem;\n }\n .field-shell.floating input {\n height: 3rem;\n padding-top: 1.25rem;\n padding-bottom: 0.25rem;\n }\n .field-shell.floating .clear-button {\n top: 0.5rem;\n }\n .field-shell.floating.has-value .floating-label,\n .field-shell.floating:focus-within .floating-label {\n top: 0.25rem;\n transform: none;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .field-shell.floating:not(.has-value):not(:focus-within) input::placeholder {\n opacity: 0;\n }\n .field-shell.disabled .floating-label {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .required-mark {\n flex: 0 0 auto;\n color: var(--ui-danger, #dc2626);\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n input:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n input:focus-visible {\n outline: none;\n border-color: var(--ui-primary, #4f46e5);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .suggestions {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 10;\n max-height: 40vh;\n overflow-y: auto;\n margin: 0.25rem 0 0;\n padding: 0.25rem 0;\n list-style: none;\n background: var(--ui-surface, #ffffff);\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n .suggestion {\n padding: 0.5rem 0.75rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n cursor: pointer;\n }\n .suggestion.active,\n .suggestion:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .no-suggestions {\n padding: 0.5rem 0.75rem;\n color: var(--ui-text-muted, #64748b);\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-style: italic;\n }\n @media (forced-colors: active) {\n input:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n input:disabled {\n color: GrayText;\n opacity: 1;\n }\n .clear-button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: -2px;\n box-shadow: none;\n }\n .field-shell.disabled .floating-label {\n color: GrayText;\n opacity: 1;\n }\n .suggestion.active,\n .suggestion:hover {\n color: HighlightText;\n background: Highlight;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .floating-label {\n transition: none;\n }\n }\n `,\n ];\n\n /** Current input value; also the form-associated value submitted with the form. */\n @property() value = \"\";\n /** Placeholder text shown when the input is empty. */\n @property() placeholder = \"\";\n /** Marks the input as required for native form validation. */\n @property({ type: Boolean }) required = false;\n /** Disables the input and closes its suggestion popup. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n /** Shows an in-field clear action while the control has a value. */\n @property({ type: Boolean, reflect: true }) clearable = false;\n /** API endpoint queried in API mode. Ignored when `options` is set. */\n @property() endpoint = \"\";\n /** Query string parameter name the current input text is sent under. */\n @property({ attribute: \"query-param\" }) queryParam = \"q\";\n /** Debounce delay (ms) before firing a request/filter after typing. */\n @property({ type: Number }) debounce = 300;\n /** Minimum query length before suggestions are shown. */\n @property({ type: Number, attribute: \"min-length\" }) minLength = 3;\n /**\n * Fixed candidate list to filter locally instead of fetching from\n * `endpoint`. When set (non-null), no network request is ever made —\n * this takes priority over the API mode.\n */\n @property({ attribute: false }) options: AutocompleteOption[] | null = null;\n\n @state() private _suggestions: AutocompleteOption[] = [];\n @state() private _open = false;\n @state() private _activeIndex = -1;\n @state() private _formDisabled = false;\n @state() private _formFieldConfig: FormFieldControlConfig | null = null;\n\n @query(\"input\") private _input?: HTMLInputElement;\n\n #internals = this.attachInternals();\n #lastPicked: AutocompleteOption | null = null;\n #debounceTimer: ReturnType<typeof setTimeout> | null = null;\n #abortController: AbortController | null = null;\n #isComposing = false;\n #compositionJustEnded = false;\n #compositionEndTimer: ReturnType<typeof setTimeout> | null = null;\n readonly #inputId = `autocomplete-input-field-${++instanceCount}`;\n readonly #listboxId = `autocomplete-input-listbox-${instanceCount}`;\n\n /** Whether the host or an ancestor fieldset currently disables the control. */\n get #isDisabled(): boolean {\n return this.disabled || this._formDisabled;\n }\n\n /** Last-picked option, or null once the input diverges from it. */\n get selectedOption(): AutocompleteOption | null {\n if (this.#lastPicked && this.#lastPicked.value === this.value) return this.#lastPicked;\n return null;\n }\n\n /**\n * Applies or clears label configuration supplied by a wrapping `form-field`.\n * @private\n */\n [formFieldControl](config: FormFieldControlConfig | null): void {\n this._formFieldConfig = config;\n }\n\n protected override willUpdate(changed: PropertyValues) {\n if (changed.has(\"disabled\") && this.#isDisabled) {\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n this._open = false;\n this._activeIndex = -1;\n }\n }\n\n protected override updated(changed: PropertyValues) {\n if (changed.has(\"value\")) this.#internals.setFormValue(this.value);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n }\n\n /** Resets to empty on `form.reset()`, per the form-associated custom element contract. */\n formResetCallback() {\n this.value = \"\";\n this._suggestions = [];\n this._open = false;\n this.#lastPicked = null;\n }\n\n /** Mirrors ancestor fieldset disabled state onto the native input. */\n formDisabledCallback(disabled: boolean) {\n this._formDisabled = disabled;\n if (!disabled) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n this._open = false;\n this._activeIndex = -1;\n }\n\n private onInput(e: InputEvent) {\n if (this.#isDisabled) return;\n this.value = (e.target as HTMLInputElement).value;\n this.#lastPicked = null;\n this.#scheduleFetch(this.value);\n }\n\n #scheduleFetch(query: string) {\n if (this.#isDisabled) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n if (query.trim().length < this.minLength) {\n this._suggestions = [];\n this._open = false;\n this._activeIndex = -1;\n return;\n }\n if (this.options) {\n // Local mode: filtering is synchronous and cheap, but keep the same\n // debounce as the API mode so the UX doesn't shift between sources.\n this.#debounceTimer = setTimeout(() => this.#filterLocalOptions(query), this.debounce);\n return;\n }\n this.#debounceTimer = setTimeout(() => void this.#fetchOptions(query), this.debounce);\n }\n\n /** Filters the locally-supplied `options` list for `query`, case-insensitively. */\n #filterLocalOptions(query: string) {\n const needle = query.trim().toLowerCase();\n this._suggestions = (this.options ?? [])\n .filter((o) => o.value.toLowerCase().includes(needle))\n .slice(0, 5);\n this._activeIndex = -1;\n this._open = !this.#isDisabled;\n }\n\n /** Fetches options for `query` from `endpoint`, cancelling any request still in flight. */\n async #fetchOptions(query: string) {\n this.#abortController?.abort();\n const controller = new AbortController();\n this.#abortController = controller;\n try {\n const res = await fetch(this.#buildUrl(query), { signal: controller.signal });\n if (!res.ok) throw new Error(`autocomplete request failed: ${res.status}`);\n if (this.#isDisabled) return;\n this._suggestions = ((await res.json()) as AutocompleteOption[]).slice(0, 5);\n this._activeIndex = -1;\n this._open = true;\n } catch {\n // Aborted (superseded by newer keystroke) or a network failure while\n // typing — fail silently and just close the list.\n if (!controller.signal.aborted) {\n this._suggestions = [];\n this._open = false;\n }\n }\n }\n\n #buildUrl(query: string): string {\n const params = new URLSearchParams({ [this.queryParam]: query });\n return `${this.endpoint}?${params.toString()}`;\n }\n\n private onKeydown(e: KeyboardEvent) {\n if (this.#isDisabled) return;\n if (e.isComposing || e.keyCode === 229 || this.#isComposing || this.#compositionJustEnded) {\n return;\n }\n if (e.key === \"ArrowDown\") this.#moveActive(1, e);\n else if (e.key === \"ArrowUp\") this.#moveActive(-1, e);\n else if (e.key === \"Enter\") this.#handleEnter(e);\n else if (e.key === \"Escape\") this.#handleEscape(e);\n }\n\n #moveActive(delta: number, e: KeyboardEvent) {\n if (!this._open || this._suggestions.length === 0) return;\n e.preventDefault();\n const n = this._suggestions.length;\n this._activeIndex = (this._activeIndex + delta + n) % n;\n }\n\n #handleEnter(e: KeyboardEvent) {\n const pick = this._suggestions[this._activeIndex] ?? this._suggestions[0];\n if (this._open && pick) {\n e.preventDefault();\n this.#selectOption(pick);\n return;\n }\n if (this.#internals.form) {\n const form = this.#internals.form;\n window.setTimeout(() => {\n if (!e.defaultPrevented && form.isConnected) submitWithDefaultButton(form);\n });\n }\n }\n\n #handleEscape(e: KeyboardEvent) {\n if (!this._open) return;\n e.preventDefault();\n this._open = false;\n }\n\n private onBlur() {\n this._open = false;\n }\n\n private onCompositionStart(): void {\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = null;\n this.#compositionJustEnded = false;\n this.#isComposing = true;\n }\n\n private onCompositionEnd(): void {\n this.#isComposing = false;\n this.#compositionJustEnded = true;\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = setTimeout(() => {\n this.#compositionJustEnded = false;\n this.#compositionEndTimer = null;\n });\n }\n\n /** Clears composition state when the control can no longer receive keys. */\n #resetComposition(): void {\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = null;\n this.#isComposing = false;\n this.#compositionJustEnded = false;\n }\n\n #selectOption(o: AutocompleteOption) {\n this.value = o.value;\n this.#lastPicked = o;\n this._open = false;\n this._suggestions = [];\n this.dispatchEvent(new CustomEvent<AutocompleteOption>(\"option-select\", { detail: o, bubbles: true, composed: true }));\n }\n\n /** Clears the field and all pending autocomplete state, then restores input focus. */\n #clear(): void {\n if (this.#isDisabled || !this.value) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#debounceTimer = null;\n this.#abortController?.abort();\n this.#abortController = null;\n this.#resetComposition();\n this.value = \"\";\n this.#lastPicked = null;\n this._suggestions = [];\n this._activeIndex = -1;\n this._open = false;\n this.#internals.setFormValue(\"\");\n this.dispatchEvent(\n new InputEvent(\"input\", {\n bubbles: true,\n composed: true,\n inputType: \"deleteContentBackward\",\n }),\n );\n this._input?.focus({ preventScroll: true });\n }\n\n /** Selects on mousedown (not click) so it wins over the input's blur, which closes the list. */\n #onSuggestionMousedown(e: MouseEvent, o: AutocompleteOption) {\n e.preventDefault();\n this.#selectOption(o);\n }\n\n private renderSuggestions() {\n if (!this._open || this.#isDisabled) return nothing;\n return html`\n <ul id=${this.#listboxId} class=\"suggestions\" role=\"listbox\" aria-label=\"Suggestions\">\n ${this._suggestions.map(\n (o, i) => html`\n <li\n id=${`${this.#listboxId}-option-${i}`}\n role=\"option\"\n aria-selected=${i === this._activeIndex}\n class=\"suggestion ${i === this._activeIndex ? \"active\" : \"\"}\"\n @mousedown=${(e: MouseEvent) => this.#onSuggestionMousedown(e, o)}\n >\n ${o.value}\n </li>\n `,\n )}\n ${this._suggestions.length === 0\n ? html`<li class=\"no-suggestions\" role=\"presentation\">\n <span role=\"status\">No suggestions found</span>\n </li>`\n : nothing}\n </ul>\n `;\n }\n\n override render() {\n const activeDescendant =\n this._open && !this.#isDisabled && this._activeIndex >= 0\n ? `${this.#listboxId}-option-${this._activeIndex}`\n : nothing;\n const expanded = this._open && !this.#isDisabled;\n const floating =\n Boolean(this._formFieldConfig?.floating) && Boolean(this._formFieldConfig?.label);\n const showClear = this.clearable && Boolean(this.value) && !this.#isDisabled;\n return html`\n <div\n class=\"field-shell ${this.clearable ? \"clearable\" : \"\"} ${floating\n ? \"floating\"\n : \"\"} ${this.value ? \"has-value\" : \"\"} ${this.#isDisabled ? \"disabled\" : \"\"}\"\n >\n ${floating\n ? html`\n <label class=\"floating-label\" for=${this.#inputId}>\n <span>${this._formFieldConfig!.label}</span>\n ${this._formFieldConfig!.required\n ? html`\n <span class=\"required-mark\" aria-hidden=\"true\">*</span>\n <span class=\"sr-only\"> (required)</span>\n `\n : nothing}\n </label>\n `\n : nothing}\n <input\n id=${this.#inputId}\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded=${expanded}\n aria-controls=${this.#listboxId}\n aria-activedescendant=${activeDescendant}\n .value=${this.value}\n placeholder=${this.placeholder}\n ?required=${this.required}\n ?disabled=${this.#isDisabled}\n autocomplete=\"off\"\n @input=${this.onInput}\n @compositionstart=${this.onCompositionStart}\n @compositionend=${this.onCompositionEnd}\n @keydown=${this.onKeydown}\n @blur=${this.onBlur}\n />\n ${showClear\n ? html`\n <button\n type=\"button\"\n class=\"clear-button\"\n aria-label=\"Clear input\"\n title=\"Clear input\"\n @mousedown=${(event: MouseEvent) => event.preventDefault()}\n @click=${() => this.#clear()}\n >\n ${iconX(18)}\n </button>\n `\n : nothing}\n ${this.renderSuggestions()}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"autocomplete-input\": AutocompleteInput;\n }\n}\n"]}
1
+ {"version":3,"file":"autocomplete-input.js","sourceRoot":"","sources":["../src/autocomplete-input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,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E,YAAY,EAAE,CAAC;oDAAe;AAMnC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;kDAA6C;AAE3D;IAAhB,KAAK,EAAE;uDAAiD;AACxC;IAAhB,KAAK,EAAE;gDAAuB;AACd;IAAhB,KAAK,EAAE;uDAA2B;AAClB;IAAhB,KAAK,EAAE;wDAA+B;AACtB;IAAhB,KAAK,EAAE;2DAAgE;AAEhD;IAAvB,KAAK,CAAC,OAAO,CAAC;iDAAmC;AApPvC,iBAAiB;IAD7B,aAAa,CAAC,oBAAoB,CAAC;GACvB,iBAAiB,CA8jB7B","sourcesContent":["import { LitElement, css, html, nothing, type PropertyValues } from \"lit\";\nimport { customElement, property, query, state } from \"lit/decorators.js\";\nimport { iconX } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\nimport {\n formFieldControl,\n type FormFieldControlConfig,\n} from \"./utils/form-field-control.js\";\nimport { submitWithDefaultButton } from \"./utils/form.js\";\n\nlet instanceCount = 0;\n\n/** A single autocomplete candidate: an opaque `key` plus its display `value`. */\nexport interface AutocompleteOption {\n key: string;\n value: string;\n}\n\n/**\n * Generic form-associated text input with a suggestion dropdown, for any\n * \"type to filter a list of `{key, value}` options\" use case. Works as a\n * drop-in replacement for a plain `<input>` inside a `<form>`: set `name` on\n * the element itself and consumers keep reading\n * `new FormData(form).get(name)` and calling `form.reset()` unchanged — the\n * submitted value is the picked option's `value`, while `key` is available\n * via the `option-select` event and the `selectedOption` getter for cases\n * that need the underlying id rather than the display text.\n *\n * Supports two suggestion sources:\n * - **API**: set `endpoint` to a URL that, given a `?<query-param>=<text>`\n * query string, responds with a JSON array of `{key, value}` objects.\n * Requests are debounced as the user types.\n * - **Local array**: set `options` to a fixed `AutocompleteOption[]` and the\n * component filters it client-side instead of making any network\n * request. Useful for small/fixed lists, offline use, or tests. Takes\n * priority over `endpoint` whenever it's non-null.\n *\n * Set `clearable` to show an in-field clear action whenever a value is\n * present.\n *\n * @element autocomplete-input\n * @fires option-select - An option was picked; detail: AutocompleteOption.\n * @fires input - Native-compatible input event fired while editing or clearing.\n */\n@customElement(\"autocomplete-input\")\nexport class AutocompleteInput extends LitElement {\n static formAssociated = true;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n position: relative;\n }\n .field-shell {\n position: relative;\n }\n input {\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-tight, 1.25);\n color: var(--ui-text, #0f172a);\n background: var(--ui-surface, #ffffff);\n padding: 0.5rem 0.75rem;\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n width: 100%;\n height: 2rem;\n box-sizing: border-box;\n }\n .field-shell.clearable input {\n padding-right: 2rem;\n }\n .clear-button {\n position: absolute;\n top: 0;\n right: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 2rem;\n height: 2rem;\n /* Insets the hover/focus background by the input's 1px border so it\n stays fully inside the field instead of painting over the border. */\n padding: 1px;\n background-clip: content-box;\n border: 0;\n border-radius: var(--ui-radius-sm, 0.25rem);\n color: var(--ui-text-muted, #64748b);\n background-color: transparent;\n cursor: pointer;\n line-height: 0;\n }\n .clear-button:hover {\n color: var(--ui-text, #0f172a);\n background-color: var(--ui-surface-muted, #f8fafc);\n }\n .clear-button:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .floating-label {\n position: absolute;\n top: 50%;\n left: 0.75rem;\n right: 0.75rem;\n z-index: 1;\n display: flex;\n align-items: baseline;\n gap: 0.25rem;\n overflow: hidden;\n transform: translateY(-50%);\n color: var(--ui-text-muted, #64748b);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n white-space: nowrap;\n text-overflow: ellipsis;\n cursor: text;\n transition:\n top 150ms ease,\n transform 150ms ease,\n font-size 150ms ease;\n }\n .field-shell.clearable .floating-label {\n right: 2rem;\n }\n .field-shell.floating input {\n height: 3rem;\n padding-top: 1.25rem;\n padding-bottom: 0.25rem;\n }\n .field-shell.floating .clear-button {\n top: 0.5rem;\n }\n .field-shell.floating.has-value .floating-label,\n .field-shell.floating:focus-within .floating-label {\n top: 0.25rem;\n transform: none;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n .field-shell.floating:not(.has-value):not(:focus-within) input::placeholder {\n opacity: 0;\n }\n .field-shell.disabled .floating-label {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .required-mark {\n flex: 0 0 auto;\n color: var(--ui-danger, #dc2626);\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n input:disabled {\n cursor: not-allowed;\n opacity: 0.6;\n }\n input:focus-visible {\n outline: none;\n border-color: var(--ui-primary, #4f46e5);\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .suggestions {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n z-index: 10;\n max-height: 40vh;\n overflow-y: auto;\n margin: 0.25rem 0 0;\n padding: 0.25rem 0;\n list-style: none;\n background: var(--ui-surface, #ffffff);\n border: 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 .suggestion {\n padding: 0.5rem 0.75rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n cursor: pointer;\n }\n .suggestion.active,\n .suggestion:hover {\n background: var(--ui-surface-muted, #f8fafc);\n }\n .no-suggestions {\n padding: 0.5rem 0.75rem;\n color: var(--ui-text-muted, #64748b);\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-style: italic;\n }\n @media (forced-colors: active) {\n input:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n input:disabled {\n color: GrayText;\n opacity: 1;\n }\n .clear-button:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: -2px;\n box-shadow: none;\n }\n .field-shell.disabled .floating-label {\n color: GrayText;\n opacity: 1;\n }\n .suggestion.active,\n .suggestion:hover {\n color: HighlightText;\n background: Highlight;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n .floating-label {\n transition: none;\n }\n }\n `,\n ];\n\n /** Current input value; also the form-associated value submitted with the form. */\n @property() value = \"\";\n /** Placeholder text shown when the input is empty. */\n @property() placeholder = \"\";\n /** Marks the input as required for native form validation. */\n @property({ type: Boolean }) required = false;\n /** Disables the input and closes its suggestion popup. */\n @property({ type: Boolean, reflect: true }) disabled = false;\n /** Shows an in-field clear action while the control has a value. */\n @property({ type: Boolean, reflect: true }) clearable = false;\n /** API endpoint queried in API mode. Ignored when `options` is set. */\n @property() endpoint = \"\";\n /** Query string parameter name the current input text is sent under. */\n @property({ attribute: \"query-param\" }) queryParam = \"q\";\n /** Debounce delay (ms) before firing a request/filter after typing. */\n @property({ type: Number }) debounce = 300;\n /** Minimum query length before suggestions are shown. */\n @property({ type: Number, attribute: \"min-length\" }) minLength = 3;\n /**\n * Fixed candidate list to filter locally instead of fetching from\n * `endpoint`. When set (non-null), no network request is ever made —\n * this takes priority over the API mode.\n */\n @property({ attribute: false }) options: AutocompleteOption[] | null = null;\n\n @state() private _suggestions: AutocompleteOption[] = [];\n @state() private _open = false;\n @state() private _activeIndex = -1;\n @state() private _formDisabled = false;\n @state() private _formFieldConfig: FormFieldControlConfig | null = null;\n\n @query(\"input\") private _input?: HTMLInputElement;\n\n #internals = this.attachInternals();\n #lastPicked: AutocompleteOption | null = null;\n #debounceTimer: ReturnType<typeof setTimeout> | null = null;\n #abortController: AbortController | null = null;\n #isComposing = false;\n #compositionJustEnded = false;\n #compositionEndTimer: ReturnType<typeof setTimeout> | null = null;\n readonly #inputId = `autocomplete-input-field-${++instanceCount}`;\n readonly #listboxId = `autocomplete-input-listbox-${instanceCount}`;\n\n /** Whether the host or an ancestor fieldset currently disables the control. */\n get #isDisabled(): boolean {\n return this.disabled || this._formDisabled;\n }\n\n /** Last-picked option, or null once the input diverges from it. */\n get selectedOption(): AutocompleteOption | null {\n if (this.#lastPicked && this.#lastPicked.value === this.value) return this.#lastPicked;\n return null;\n }\n\n /**\n * Applies or clears label configuration supplied by a wrapping `form-field`.\n * @private\n */\n [formFieldControl](config: FormFieldControlConfig | null): void {\n this._formFieldConfig = config;\n }\n\n protected override willUpdate(changed: PropertyValues) {\n if (changed.has(\"disabled\") && this.#isDisabled) {\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n this._open = false;\n this._activeIndex = -1;\n }\n }\n\n protected override updated(changed: PropertyValues) {\n if (changed.has(\"value\")) this.#internals.setFormValue(this.value);\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n }\n\n /** Resets to empty on `form.reset()`, per the form-associated custom element contract. */\n formResetCallback() {\n this.value = \"\";\n this._suggestions = [];\n this._open = false;\n this.#lastPicked = null;\n }\n\n /** Mirrors ancestor fieldset disabled state onto the native input. */\n formDisabledCallback(disabled: boolean) {\n this._formDisabled = disabled;\n if (!disabled) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#resetComposition();\n this.#abortController?.abort();\n this._open = false;\n this._activeIndex = -1;\n }\n\n private onInput(e: InputEvent) {\n if (this.#isDisabled) return;\n this.value = (e.target as HTMLInputElement).value;\n this.#lastPicked = null;\n this.#scheduleFetch(this.value);\n }\n\n #scheduleFetch(query: string) {\n if (this.#isDisabled) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n if (query.trim().length < this.minLength) {\n this._suggestions = [];\n this._open = false;\n this._activeIndex = -1;\n return;\n }\n if (this.options) {\n // Local mode: filtering is synchronous and cheap, but keep the same\n // debounce as the API mode so the UX doesn't shift between sources.\n this.#debounceTimer = setTimeout(() => this.#filterLocalOptions(query), this.debounce);\n return;\n }\n this.#debounceTimer = setTimeout(() => void this.#fetchOptions(query), this.debounce);\n }\n\n /** Filters the locally-supplied `options` list for `query`, case-insensitively. */\n #filterLocalOptions(query: string) {\n const needle = query.trim().toLowerCase();\n this._suggestions = (this.options ?? [])\n .filter((o) => o.value.toLowerCase().includes(needle))\n .slice(0, 5);\n this._activeIndex = -1;\n this._open = !this.#isDisabled;\n }\n\n /** Fetches options for `query` from `endpoint`, cancelling any request still in flight. */\n async #fetchOptions(query: string) {\n this.#abortController?.abort();\n const controller = new AbortController();\n this.#abortController = controller;\n try {\n const res = await fetch(this.#buildUrl(query), { signal: controller.signal });\n if (!res.ok) throw new Error(`autocomplete request failed: ${res.status}`);\n if (this.#isDisabled) return;\n this._suggestions = ((await res.json()) as AutocompleteOption[]).slice(0, 5);\n this._activeIndex = -1;\n this._open = true;\n } catch {\n // Aborted (superseded by newer keystroke) or a network failure while\n // typing — fail silently and just close the list.\n if (!controller.signal.aborted) {\n this._suggestions = [];\n this._open = false;\n }\n }\n }\n\n #buildUrl(query: string): string {\n const params = new URLSearchParams({ [this.queryParam]: query });\n return `${this.endpoint}?${params.toString()}`;\n }\n\n private onKeydown(e: KeyboardEvent) {\n if (this.#isDisabled) return;\n if (e.isComposing || e.keyCode === 229 || this.#isComposing || this.#compositionJustEnded) {\n return;\n }\n if (e.key === \"ArrowDown\") this.#moveActive(1, e);\n else if (e.key === \"ArrowUp\") this.#moveActive(-1, e);\n else if (e.key === \"Enter\") this.#handleEnter(e);\n else if (e.key === \"Escape\") this.#handleEscape(e);\n }\n\n #moveActive(delta: number, e: KeyboardEvent) {\n if (!this._open || this._suggestions.length === 0) return;\n e.preventDefault();\n const n = this._suggestions.length;\n this._activeIndex = (this._activeIndex + delta + n) % n;\n }\n\n #handleEnter(e: KeyboardEvent) {\n const pick = this._suggestions[this._activeIndex] ?? this._suggestions[0];\n if (this._open && pick) {\n e.preventDefault();\n this.#selectOption(pick);\n return;\n }\n if (this.#internals.form) {\n const form = this.#internals.form;\n window.setTimeout(() => {\n if (!e.defaultPrevented && form.isConnected) submitWithDefaultButton(form);\n });\n }\n }\n\n #handleEscape(e: KeyboardEvent) {\n if (!this._open) return;\n e.preventDefault();\n this._open = false;\n }\n\n private onBlur() {\n this._open = false;\n }\n\n private onCompositionStart(): void {\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = null;\n this.#compositionJustEnded = false;\n this.#isComposing = true;\n }\n\n private onCompositionEnd(): void {\n this.#isComposing = false;\n this.#compositionJustEnded = true;\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = setTimeout(() => {\n this.#compositionJustEnded = false;\n this.#compositionEndTimer = null;\n });\n }\n\n /** Clears composition state when the control can no longer receive keys. */\n #resetComposition(): void {\n if (this.#compositionEndTimer) clearTimeout(this.#compositionEndTimer);\n this.#compositionEndTimer = null;\n this.#isComposing = false;\n this.#compositionJustEnded = false;\n }\n\n #selectOption(o: AutocompleteOption) {\n this.value = o.value;\n this.#lastPicked = o;\n this._open = false;\n this._suggestions = [];\n this.dispatchEvent(new CustomEvent<AutocompleteOption>(\"option-select\", { detail: o, bubbles: true, composed: true }));\n }\n\n /** Clears the field and all pending autocomplete state, then restores input focus. */\n #clear(): void {\n if (this.#isDisabled || !this.value) return;\n if (this.#debounceTimer) clearTimeout(this.#debounceTimer);\n this.#debounceTimer = null;\n this.#abortController?.abort();\n this.#abortController = null;\n this.#resetComposition();\n this.value = \"\";\n this.#lastPicked = null;\n this._suggestions = [];\n this._activeIndex = -1;\n this._open = false;\n this.#internals.setFormValue(\"\");\n this.dispatchEvent(\n new InputEvent(\"input\", {\n bubbles: true,\n composed: true,\n inputType: \"deleteContentBackward\",\n }),\n );\n this._input?.focus({ preventScroll: true });\n }\n\n /** Selects on mousedown (not click) so it wins over the input's blur, which closes the list. */\n #onSuggestionMousedown(e: MouseEvent, o: AutocompleteOption) {\n e.preventDefault();\n this.#selectOption(o);\n }\n\n private renderSuggestions() {\n if (!this._open || this.#isDisabled) return nothing;\n return html`\n <ul id=${this.#listboxId} class=\"suggestions\" role=\"listbox\" aria-label=\"Suggestions\">\n ${this._suggestions.map(\n (o, i) => html`\n <li\n id=${`${this.#listboxId}-option-${i}`}\n role=\"option\"\n aria-selected=${i === this._activeIndex}\n class=\"suggestion ${i === this._activeIndex ? \"active\" : \"\"}\"\n @mousedown=${(e: MouseEvent) => this.#onSuggestionMousedown(e, o)}\n >\n ${o.value}\n </li>\n `,\n )}\n ${this._suggestions.length === 0\n ? html`<li class=\"no-suggestions\" role=\"presentation\">\n <span role=\"status\">No suggestions found</span>\n </li>`\n : nothing}\n </ul>\n `;\n }\n\n override render() {\n const activeDescendant =\n this._open && !this.#isDisabled && this._activeIndex >= 0\n ? `${this.#listboxId}-option-${this._activeIndex}`\n : nothing;\n const expanded = this._open && !this.#isDisabled;\n const floating =\n Boolean(this._formFieldConfig?.floating) && Boolean(this._formFieldConfig?.label);\n const showClear = this.clearable && Boolean(this.value) && !this.#isDisabled;\n return html`\n <div\n class=\"field-shell ${this.clearable ? \"clearable\" : \"\"} ${floating\n ? \"floating\"\n : \"\"} ${this.value ? \"has-value\" : \"\"} ${this.#isDisabled ? \"disabled\" : \"\"}\"\n >\n ${floating\n ? html`\n <label class=\"floating-label\" for=${this.#inputId}>\n <span>${this._formFieldConfig!.label}</span>\n ${this._formFieldConfig!.required\n ? html`\n <span class=\"required-mark\" aria-hidden=\"true\">*</span>\n <span class=\"sr-only\"> (required)</span>\n `\n : nothing}\n </label>\n `\n : nothing}\n <input\n id=${this.#inputId}\n type=\"text\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded=${expanded}\n aria-controls=${this.#listboxId}\n aria-activedescendant=${activeDescendant}\n .value=${this.value}\n placeholder=${this.placeholder}\n ?required=${this.required}\n ?disabled=${this.#isDisabled}\n autocomplete=\"off\"\n @input=${this.onInput}\n @compositionstart=${this.onCompositionStart}\n @compositionend=${this.onCompositionEnd}\n @keydown=${this.onKeydown}\n @blur=${this.onBlur}\n />\n ${showClear\n ? html`\n <button\n type=\"button\"\n class=\"clear-button\"\n aria-label=\"Clear input\"\n title=\"Clear input\"\n @mousedown=${(event: MouseEvent) => event.preventDefault()}\n @click=${() => this.#clear()}\n >\n ${iconX(18)}\n </button>\n `\n : nothing}\n ${this.renderSuggestions()}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"autocomplete-input\": AutocompleteInput;\n }\n}\n"]}
@@ -0,0 +1,87 @@
1
+ import { LitElement, nothing, type TemplateResult } from "lit";
2
+ /** A single crumb in the trail. */
3
+ export interface BreadcrumbItem {
4
+ /** Visible text for the crumb. */
5
+ label: string;
6
+ /**
7
+ * Destination the crumb links to. Omit for a non-interactive crumb rendered
8
+ * as plain text. Ignored on the last item, which is always the current page.
9
+ */
10
+ href?: string;
11
+ }
12
+ /** Detail for the `breadcrumb-navigate` event. */
13
+ export interface BreadcrumbNavigateDetail {
14
+ /** The activated crumb. */
15
+ item: BreadcrumbItem;
16
+ /** Its index within `items`. */
17
+ index: number;
18
+ }
19
+ /**
20
+ * A breadcrumb trail: a `<nav aria-label="Breadcrumb">` wrapping an ordered
21
+ * list, with chevron separators and the current page rendered as plain,
22
+ * non-interactive text. Designed to drop into `page-header`'s `breadcrumb`
23
+ * slot, but usable on its own anywhere a trail is needed.
24
+ *
25
+ * The last `items` entry is always treated as the current page: it renders as
26
+ * text with `aria-current="page"` even if it carries an `href`. Middle entries
27
+ * without an `href` render as plain text too; only middle entries with an
28
+ * `href` are real anchors.
29
+ *
30
+ * When `max-visible` is greater than zero and the trail is longer than that,
31
+ * the middle collapses behind an overflow button that always keeps the first
32
+ * and current crumbs visible; activating it toggles `expanded` to reveal the
33
+ * hidden crumbs in place.
34
+ *
35
+ * @element breadcrumb-nav
36
+ * @fires breadcrumb-navigate - A crumb link was activated; `detail` is
37
+ * `{ item: BreadcrumbItem; index: number }`. This is an additional
38
+ * notification hook only — the anchor's native navigation is never
39
+ * prevented, so crumbs stay real, middle-clickable, right-clickable links.
40
+ */
41
+ export declare class BreadcrumbNav extends LitElement {
42
+ /**
43
+ * The crumbs, root first. The last entry is the current page and is rendered
44
+ * as non-interactive text with `aria-current="page"`.
45
+ */
46
+ items: BreadcrumbItem[];
47
+ /**
48
+ * When greater than zero and the trail has more items than this, collapse the
49
+ * middle of the trail behind an overflow button (the first and current crumbs
50
+ * always stay visible). `0` (the default) never collapses.
51
+ *
52
+ * A collapsed trail always occupies three positions — first crumb, overflow
53
+ * button, current page — so values below `3` are raised to `3`. Collapsing a
54
+ * shorter trail would spend a button to hide one crumb, or none at all.
55
+ */
56
+ maxVisible: number;
57
+ /** Whether a collapsed trail is currently expanded to show its hidden crumbs. */
58
+ expanded: boolean;
59
+ static styles: import("lit").CSSResult[];
60
+ /** Toggles a collapsed trail between collapsed and expanded. */
61
+ private _toggle;
62
+ /** The crumbs, defended against a non-array value assigned at runtime by a JS or HTML consumer. */
63
+ private _crumbs;
64
+ /**
65
+ * How many crumbs may show before the middle collapses, or `0` for never.
66
+ * Floored at 3, since a collapsed trail always renders first + overflow +
67
+ * current.
68
+ */
69
+ private _limit;
70
+ /** Whether the trail is long enough for the overflow button to earn its place. */
71
+ private _collapsible;
72
+ willUpdate(): void;
73
+ updated(): void;
74
+ /** Whether the overflow button held focus when the current update began. */
75
+ private _overflowHadFocus;
76
+ /** Dispatches `breadcrumb-navigate` without preventing native navigation. */
77
+ private _onNavigate;
78
+ private _crumbNode;
79
+ private _overflowNode;
80
+ render(): typeof nothing | TemplateResult<1>;
81
+ }
82
+ declare global {
83
+ interface HTMLElementTagNameMap {
84
+ "breadcrumb-nav": BreadcrumbNav;
85
+ }
86
+ }
87
+ //# sourceMappingURL=breadcrumb-nav.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breadcrumb-nav.d.ts","sourceRoot":"","sources":["../src/breadcrumb-nav.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAK1E,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,kDAAkD;AAClD,MAAM,WAAW,wBAAwB;IACvC,2BAA2B;IAC3B,IAAI,EAAE,cAAc,CAAC;IACrB,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBACa,aAAc,SAAQ,UAAU;IAC3C;;;OAGG;IACwB,KAAK,EAAE,cAAc,EAAE,CAAM;IAExD;;;;;;;;OAQG;IACmD,UAAU,SAAK;IAErE,iFAAiF;IACrC,QAAQ,UAAS;IAE7D,OAAgB,MAAM,4BAgGpB;IAEF,gEAAgE;IAChE,OAAO,CAAC,OAAO;IAIf,mGAAmG;IACnG,OAAO,CAAC,OAAO;IAIf;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAKd,kFAAkF;IAClF,OAAO,CAAC,YAAY;IAKX,UAAU,IAAI,IAAI,CAO1B;IAEQ,OAAO,IAAI,IAAI,CAQvB;IAED,4EAA4E;IAC5E,OAAO,CAAC,iBAAiB,CAAS;IAElC,6EAA6E;IAC7E,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,aAAa;IAcZ,MAAM,uCAsCd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
@@ -0,0 +1,281 @@
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 } from "lit/decorators.js";
9
+ import { iconChevronRight, iconEllipsisHorizontal } from "./icons.js";
10
+ import { tokens } from "./tokens.js";
11
+ /**
12
+ * A breadcrumb trail: a `<nav aria-label="Breadcrumb">` wrapping an ordered
13
+ * list, with chevron separators and the current page rendered as plain,
14
+ * non-interactive text. Designed to drop into `page-header`'s `breadcrumb`
15
+ * slot, but usable on its own anywhere a trail is needed.
16
+ *
17
+ * The last `items` entry is always treated as the current page: it renders as
18
+ * text with `aria-current="page"` even if it carries an `href`. Middle entries
19
+ * without an `href` render as plain text too; only middle entries with an
20
+ * `href` are real anchors.
21
+ *
22
+ * When `max-visible` is greater than zero and the trail is longer than that,
23
+ * the middle collapses behind an overflow button that always keeps the first
24
+ * and current crumbs visible; activating it toggles `expanded` to reveal the
25
+ * hidden crumbs in place.
26
+ *
27
+ * @element breadcrumb-nav
28
+ * @fires breadcrumb-navigate - A crumb link was activated; `detail` is
29
+ * `{ item: BreadcrumbItem; index: number }`. This is an additional
30
+ * notification hook only — the anchor's native navigation is never
31
+ * prevented, so crumbs stay real, middle-clickable, right-clickable links.
32
+ */
33
+ let BreadcrumbNav = class BreadcrumbNav extends LitElement {
34
+ constructor() {
35
+ super(...arguments);
36
+ /**
37
+ * The crumbs, root first. The last entry is the current page and is rendered
38
+ * as non-interactive text with `aria-current="page"`.
39
+ */
40
+ this.items = [];
41
+ /**
42
+ * When greater than zero and the trail has more items than this, collapse the
43
+ * middle of the trail behind an overflow button (the first and current crumbs
44
+ * always stay visible). `0` (the default) never collapses.
45
+ *
46
+ * A collapsed trail always occupies three positions — first crumb, overflow
47
+ * button, current page — so values below `3` are raised to `3`. Collapsing a
48
+ * shorter trail would spend a button to hide one crumb, or none at all.
49
+ */
50
+ this.maxVisible = 0;
51
+ /** Whether a collapsed trail is currently expanded to show its hidden crumbs. */
52
+ this.expanded = false;
53
+ /** Whether the overflow button held focus when the current update began. */
54
+ this._overflowHadFocus = false;
55
+ }
56
+ static { this.styles = [
57
+ tokens,
58
+ css `
59
+ :host {
60
+ display: block;
61
+ font-family: var(
62
+ --ui-font,
63
+ ui-sans-serif,
64
+ system-ui,
65
+ sans-serif,
66
+ "Apple Color Emoji",
67
+ "Segoe UI Emoji",
68
+ "Segoe UI Symbol",
69
+ "Noto Color Emoji"
70
+ );
71
+ }
72
+ .trail {
73
+ display: flex;
74
+ flex-wrap: wrap;
75
+ align-items: center;
76
+ gap: 0.25rem;
77
+ margin: 0;
78
+ padding: 0;
79
+ list-style: none;
80
+ font-size: var(--ui-font-size-sm, 0.75rem);
81
+ font-weight: var(--ui-font-weight-regular, 400);
82
+ line-height: var(--ui-line-height-tight, 1.25);
83
+ }
84
+ .crumb-item {
85
+ display: inline-flex;
86
+ align-items: center;
87
+ gap: 0.25rem;
88
+ }
89
+ .sep {
90
+ display: inline-flex;
91
+ line-height: var(--ui-line-height-glyph, 1);
92
+ color: var(--ui-text-muted, #64748b);
93
+ }
94
+ .crumb {
95
+ color: var(--ui-text-muted, #64748b);
96
+ text-decoration: none;
97
+ border-radius: var(--ui-radius-sm, 0.25rem);
98
+ transition: color 150ms ease;
99
+ }
100
+ .crumb:hover,
101
+ .crumb:focus-visible {
102
+ color: var(--ui-text, #0f172a);
103
+ }
104
+ .crumb:focus-visible {
105
+ outline: none;
106
+ box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
107
+ }
108
+ .static {
109
+ color: var(--ui-text-muted, #64748b);
110
+ }
111
+ .current {
112
+ color: var(--ui-text, #0f172a);
113
+ font-weight: var(--ui-font-weight-medium, 500);
114
+ }
115
+ .overflow {
116
+ display: inline-flex;
117
+ align-items: center;
118
+ justify-content: center;
119
+ width: 2rem;
120
+ height: 2rem;
121
+ padding: 0;
122
+ appearance: none;
123
+ background: none;
124
+ border: none;
125
+ border-radius: var(--ui-radius-sm, 0.25rem);
126
+ color: var(--ui-text-muted, #64748b);
127
+ cursor: pointer;
128
+ transition: color 150ms ease;
129
+ }
130
+ .overflow:hover {
131
+ color: var(--ui-text, #0f172a);
132
+ }
133
+ .overflow:focus-visible {
134
+ outline: none;
135
+ box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));
136
+ }
137
+ @media (prefers-reduced-motion: reduce) {
138
+ .crumb,
139
+ .overflow {
140
+ transition: none;
141
+ }
142
+ }
143
+ @media (forced-colors: active) {
144
+ .crumb:focus-visible,
145
+ .overflow:focus-visible {
146
+ outline: 2px solid CanvasText;
147
+ outline-offset: 2px;
148
+ box-shadow: none;
149
+ }
150
+ }
151
+ `,
152
+ ]; }
153
+ /** Toggles a collapsed trail between collapsed and expanded. */
154
+ _toggle() {
155
+ this.expanded = !this.expanded;
156
+ }
157
+ /** The crumbs, defended against a non-array value assigned at runtime by a JS or HTML consumer. */
158
+ _crumbs() {
159
+ return Array.isArray(this.items) ? this.items : [];
160
+ }
161
+ /**
162
+ * How many crumbs may show before the middle collapses, or `0` for never.
163
+ * Floored at 3, since a collapsed trail always renders first + overflow +
164
+ * current.
165
+ */
166
+ _limit() {
167
+ const limit = Math.trunc(this.maxVisible);
168
+ return limit > 0 ? Math.max(3, limit) : 0;
169
+ }
170
+ /** Whether the trail is long enough for the overflow button to earn its place. */
171
+ _collapsible() {
172
+ const limit = this._limit();
173
+ return limit > 0 && this._crumbs().length > limit;
174
+ }
175
+ willUpdate() {
176
+ const root = this.renderRoot;
177
+ this._overflowHadFocus = root?.activeElement?.classList.contains("overflow") ?? false;
178
+ // A trail that stops being collapsible (its items shrank, or max-visible
179
+ // grew) must not keep a reflected expanded attribute describing a
180
+ // disclosure that no longer exists.
181
+ if (this.expanded && !this._collapsible())
182
+ this.expanded = false;
183
+ }
184
+ updated() {
185
+ // The overflow button is the only focusable node that can vanish mid-update.
186
+ // Without this, replacing items while it holds focus drops focus to
187
+ // document.body and strands a keyboard user at the top of the page.
188
+ if (!this._overflowHadFocus)
189
+ return;
190
+ this._overflowHadFocus = false;
191
+ if (this.renderRoot.querySelector(".overflow"))
192
+ return;
193
+ this.renderRoot.querySelector("nav")?.focus();
194
+ }
195
+ /** Dispatches `breadcrumb-navigate` without preventing native navigation. */
196
+ _onNavigate(item, index) {
197
+ this.dispatchEvent(new CustomEvent("breadcrumb-navigate", {
198
+ detail: { item, index },
199
+ bubbles: true,
200
+ composed: true,
201
+ }));
202
+ }
203
+ _crumbNode(item, index, lastIndex) {
204
+ if (index === lastIndex) {
205
+ return html `<span class="current" aria-current="page">${item.label}</span>`;
206
+ }
207
+ if (item.href) {
208
+ return html `<a
209
+ class="crumb"
210
+ href=${item.href}
211
+ @click=${() => this._onNavigate(item, index)}
212
+ >${item.label}</a
213
+ >`;
214
+ }
215
+ return html `<span class="static">${item.label}</span>`;
216
+ }
217
+ _overflowNode(hiddenCount) {
218
+ const label = this.expanded ? "Hide breadcrumbs" : `Show ${hiddenCount} hidden breadcrumbs`;
219
+ return html `<button
220
+ type="button"
221
+ class="overflow"
222
+ aria-expanded=${this.expanded ? "true" : "false"}
223
+ aria-controls="trail"
224
+ aria-label=${label}
225
+ @click=${this._toggle}
226
+ >
227
+ ${iconEllipsisHorizontal(18)}
228
+ </button>`;
229
+ }
230
+ render() {
231
+ const items = this._crumbs();
232
+ // An empty trail renders nothing at all rather than an empty landmark: a
233
+ // named but contentless nav is pure noise in the accessibility tree.
234
+ if (items.length === 0)
235
+ return nothing;
236
+ const lastIndex = items.length - 1;
237
+ const collapsible = this._collapsible();
238
+ const nodes = [];
239
+ if (collapsible) {
240
+ nodes.push(this._crumbNode(items[0], 0, lastIndex));
241
+ nodes.push(this._overflowNode(items.length - 2));
242
+ if (this.expanded) {
243
+ for (let i = 1; i < lastIndex; i++) {
244
+ nodes.push(this._crumbNode(items[i], i, lastIndex));
245
+ }
246
+ }
247
+ nodes.push(this._crumbNode(items[lastIndex], lastIndex, lastIndex));
248
+ }
249
+ else {
250
+ items.forEach((item, i) => nodes.push(this._crumbNode(item, i, lastIndex)));
251
+ }
252
+ return html `
253
+ <nav aria-label="Breadcrumb" tabindex="-1">
254
+ <ol class="trail" id="trail">
255
+ ${nodes.map((node, i) => html `
256
+ <li class="crumb-item">
257
+ ${i > 0
258
+ ? html `<span class="sep" aria-hidden="true">${iconChevronRight(14)}</span>`
259
+ : nothing}
260
+ ${node}
261
+ </li>
262
+ `)}
263
+ </ol>
264
+ </nav>
265
+ `;
266
+ }
267
+ };
268
+ __decorate([
269
+ property({ type: Array })
270
+ ], BreadcrumbNav.prototype, "items", void 0);
271
+ __decorate([
272
+ property({ type: Number, attribute: "max-visible" })
273
+ ], BreadcrumbNav.prototype, "maxVisible", void 0);
274
+ __decorate([
275
+ property({ type: Boolean, reflect: true })
276
+ ], BreadcrumbNav.prototype, "expanded", void 0);
277
+ BreadcrumbNav = __decorate([
278
+ customElement("breadcrumb-nav")
279
+ ], BreadcrumbNav);
280
+ export { BreadcrumbNav };
281
+ //# sourceMappingURL=breadcrumb-nav.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breadcrumb-nav.js","sourceRoot":"","sources":["../src/breadcrumb-nav.ts"],"names":[],"mappings":";;;;;;AAAA,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PzB","sourcesContent":["import { LitElement, css, html, nothing, type TemplateResult } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { iconChevronRight, iconEllipsisHorizontal } from \"./icons.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** A single crumb in the trail. */\nexport interface BreadcrumbItem {\n /** Visible text for the crumb. */\n label: string;\n /**\n * Destination the crumb links to. Omit for a non-interactive crumb rendered\n * as plain text. Ignored on the last item, which is always the current page.\n */\n href?: string;\n}\n\n/** Detail for the `breadcrumb-navigate` event. */\nexport interface BreadcrumbNavigateDetail {\n /** The activated crumb. */\n item: BreadcrumbItem;\n /** Its index within `items`. */\n index: number;\n}\n\n/**\n * A breadcrumb trail: a `<nav aria-label=\"Breadcrumb\">` wrapping an ordered\n * list, with chevron separators and the current page rendered as plain,\n * non-interactive text. Designed to drop into `page-header`'s `breadcrumb`\n * slot, but usable on its own anywhere a trail is needed.\n *\n * The last `items` entry is always treated as the current page: it renders as\n * text with `aria-current=\"page\"` even if it carries an `href`. Middle entries\n * without an `href` render as plain text too; only middle entries with an\n * `href` are real anchors.\n *\n * When `max-visible` is greater than zero and the trail is longer than that,\n * the middle collapses behind an overflow button that always keeps the first\n * and current crumbs visible; activating it toggles `expanded` to reveal the\n * hidden crumbs in place.\n *\n * @element breadcrumb-nav\n * @fires breadcrumb-navigate - A crumb link was activated; `detail` is\n * `{ item: BreadcrumbItem; index: number }`. This is an additional\n * notification hook only — the anchor's native navigation is never\n * prevented, so crumbs stay real, middle-clickable, right-clickable links.\n */\n@customElement(\"breadcrumb-nav\")\nexport class BreadcrumbNav extends LitElement {\n /**\n * The crumbs, root first. The last entry is the current page and is rendered\n * as non-interactive text with `aria-current=\"page\"`.\n */\n @property({ type: Array }) items: BreadcrumbItem[] = [];\n\n /**\n * When greater than zero and the trail has more items than this, collapse the\n * middle of the trail behind an overflow button (the first and current crumbs\n * always stay visible). `0` (the default) never collapses.\n *\n * A collapsed trail always occupies three positions — first crumb, overflow\n * button, current page — so values below `3` are raised to `3`. Collapsing a\n * shorter trail would spend a button to hide one crumb, or none at all.\n */\n @property({ type: Number, attribute: \"max-visible\" }) maxVisible = 0;\n\n /** Whether a collapsed trail is currently expanded to show its hidden crumbs. */\n @property({ type: Boolean, reflect: true }) expanded = 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 .trail {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 0.25rem;\n margin: 0;\n padding: 0;\n list-style: none;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-regular, 400);\n line-height: var(--ui-line-height-tight, 1.25);\n }\n .crumb-item {\n display: inline-flex;\n align-items: center;\n gap: 0.25rem;\n }\n .sep {\n display: inline-flex;\n line-height: var(--ui-line-height-glyph, 1);\n color: var(--ui-text-muted, #64748b);\n }\n .crumb {\n color: var(--ui-text-muted, #64748b);\n text-decoration: none;\n border-radius: var(--ui-radius-sm, 0.25rem);\n transition: color 150ms ease;\n }\n .crumb:hover,\n .crumb:focus-visible {\n color: var(--ui-text, #0f172a);\n }\n .crumb:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .static {\n color: var(--ui-text-muted, #64748b);\n }\n .current {\n color: var(--ui-text, #0f172a);\n font-weight: var(--ui-font-weight-medium, 500);\n }\n .overflow {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 2rem;\n height: 2rem;\n padding: 0;\n appearance: none;\n background: none;\n border: none;\n border-radius: var(--ui-radius-sm, 0.25rem);\n color: var(--ui-text-muted, #64748b);\n cursor: pointer;\n transition: color 150ms ease;\n }\n .overflow:hover {\n color: var(--ui-text, #0f172a);\n }\n .overflow:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (prefers-reduced-motion: reduce) {\n .crumb,\n .overflow {\n transition: none;\n }\n }\n @media (forced-colors: active) {\n .crumb:focus-visible,\n .overflow:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** Toggles a collapsed trail between collapsed and expanded. */\n private _toggle(): void {\n this.expanded = !this.expanded;\n }\n\n /** The crumbs, defended against a non-array value assigned at runtime by a JS or HTML consumer. */\n private _crumbs(): BreadcrumbItem[] {\n return Array.isArray(this.items) ? this.items : [];\n }\n\n /**\n * How many crumbs may show before the middle collapses, or `0` for never.\n * Floored at 3, since a collapsed trail always renders first + overflow +\n * current.\n */\n private _limit(): number {\n const limit = Math.trunc(this.maxVisible);\n return limit > 0 ? Math.max(3, limit) : 0;\n }\n\n /** Whether the trail is long enough for the overflow button to earn its place. */\n private _collapsible(): boolean {\n const limit = this._limit();\n return limit > 0 && this._crumbs().length > limit;\n }\n\n override willUpdate(): void {\n const root = this.renderRoot as ShadowRoot | null;\n this._overflowHadFocus = root?.activeElement?.classList.contains(\"overflow\") ?? false;\n // A trail that stops being collapsible (its items shrank, or max-visible\n // grew) must not keep a reflected expanded attribute describing a\n // disclosure that no longer exists.\n if (this.expanded && !this._collapsible()) this.expanded = false;\n }\n\n override updated(): void {\n // The overflow button is the only focusable node that can vanish mid-update.\n // Without this, replacing items while it holds focus drops focus to\n // document.body and strands a keyboard user at the top of the page.\n if (!this._overflowHadFocus) return;\n this._overflowHadFocus = false;\n if (this.renderRoot.querySelector(\".overflow\")) return;\n this.renderRoot.querySelector<HTMLElement>(\"nav\")?.focus();\n }\n\n /** Whether the overflow button held focus when the current update began. */\n private _overflowHadFocus = false;\n\n /** Dispatches `breadcrumb-navigate` without preventing native navigation. */\n private _onNavigate(item: BreadcrumbItem, index: number): void {\n this.dispatchEvent(\n new CustomEvent<BreadcrumbNavigateDetail>(\"breadcrumb-navigate\", {\n detail: { item, index },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _crumbNode(item: BreadcrumbItem, index: number, lastIndex: number): TemplateResult {\n if (index === lastIndex) {\n return html`<span class=\"current\" aria-current=\"page\">${item.label}</span>`;\n }\n if (item.href) {\n return html`<a\n class=\"crumb\"\n href=${item.href}\n @click=${() => this._onNavigate(item, index)}\n >${item.label}</a\n >`;\n }\n return html`<span class=\"static\">${item.label}</span>`;\n }\n\n private _overflowNode(hiddenCount: number): TemplateResult {\n const label = this.expanded ? \"Hide breadcrumbs\" : `Show ${hiddenCount} hidden breadcrumbs`;\n return html`<button\n type=\"button\"\n class=\"overflow\"\n aria-expanded=${this.expanded ? \"true\" : \"false\"}\n aria-controls=\"trail\"\n aria-label=${label}\n @click=${this._toggle}\n >\n ${iconEllipsisHorizontal(18)}\n </button>`;\n }\n\n override render() {\n const items = this._crumbs();\n // An empty trail renders nothing at all rather than an empty landmark: a\n // named but contentless nav is pure noise in the accessibility tree.\n if (items.length === 0) return nothing;\n const lastIndex = items.length - 1;\n const collapsible = this._collapsible();\n\n const nodes: TemplateResult[] = [];\n if (collapsible) {\n nodes.push(this._crumbNode(items[0], 0, lastIndex));\n nodes.push(this._overflowNode(items.length - 2));\n if (this.expanded) {\n for (let i = 1; i < lastIndex; i++) {\n nodes.push(this._crumbNode(items[i], i, lastIndex));\n }\n }\n nodes.push(this._crumbNode(items[lastIndex], lastIndex, lastIndex));\n } else {\n items.forEach((item, i) => nodes.push(this._crumbNode(item, i, lastIndex)));\n }\n\n return html`\n <nav aria-label=\"Breadcrumb\" tabindex=\"-1\">\n <ol class=\"trail\" id=\"trail\">\n ${nodes.map(\n (node, i) => html`\n <li class=\"crumb-item\">\n ${i > 0\n ? html`<span class=\"sep\" aria-hidden=\"true\">${iconChevronRight(14)}</span>`\n : nothing}\n ${node}\n </li>\n `,\n )}\n </ol>\n </nav>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"breadcrumb-nav\": BreadcrumbNav;\n }\n}\n"]}
@@ -53,7 +53,7 @@ let ButtonGroup = class ButtonGroup extends LitElement {
53
53
  }
54
54
  .group {
55
55
  display: flex;
56
- border: 1px solid var(--ui-border, #e2e8f0);
56
+ border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
57
57
  border-radius: var(--ui-radius-sm, 0.25rem);
58
58
  overflow: hidden;
59
59
  }
@@ -67,7 +67,7 @@ let ButtonGroup = class ButtonGroup extends LitElement {
67
67
  height: 2rem;
68
68
  box-sizing: border-box;
69
69
  padding: 0.5rem 0.75rem;
70
- border-left: 1px solid var(--ui-border, #e2e8f0);
70
+ border-left: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
71
71
  cursor: pointer;
72
72
  font-family: var(
73
73
  --ui-font,
@@ -1 +1 @@
1
- {"version":3,"file":"button-group.js","sourceRoot":"","sources":["../src/button-group.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAiIL,2CAA2C;QACX,YAAO,GAAwB,EAAE,CAAC;QAClE,gCAAgC;QACpB,UAAK,GAAG,EAAE,CAAC;QACvB,gDAAgD;QACnB,aAAQ,GAAG,KAAK,CAAC;QAC9C,oFAAoF;QAChB,aAAQ,GAAG,KAAK,CAAC;QACrF,uFAAuF;QAC1D,SAAI,GAAgB,IAAI,CAAC;QAE7C,UAAK,GAAG,gBAAgB,EAAE,aAAa,EAAE,CAAC;IAmCrD,CAAC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ACJ,CAAC;CACF,CAAA;AA7CiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAAmC;AAEtD;IAAX,QAAQ,EAAE;0CAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAEsB;IAAnE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;6CAAkB;AAExD;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAA0B;AA1I3C,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA+KvB","sourcesContent":["import type { TemplateResult } from \"lit\";\nimport { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport interface ButtonGroupOption {\n value: string;\n label: string;\n /** Optional pre-rendered icon template displayed before the label. */\n icon?: TemplateResult;\n}\n\nlet instanceCount = 0;\n\n/**\n * Single-select segmented control — a strip of buttons joined into one\n * shared-border shape, for a small, persistent set of mutually exclusive\n * choices (a view switcher, a theme picker) where the *currently selected*\n * option should read as visually \"pressed,\" not just checked. For many\n * short, individually pill-shaped choices, use `radio-pills` instead. Wraps\n * native radio inputs for keyboard/a11y and fires `change` rather than\n * relying on form submission. Set `size=\"sm\"` for a compact strip one step\n * below the default, matching `ui-button`'s `sm` size.\n *\n * The checked segment reads `--ui-button-background`/`-hover`/`-active`,\n * same as `ui-button`'s `primary` variant. Unchecked segments are treated as\n * `ui-button`'s `secondary` variant: they read the shared\n * `--ui-button-secondary-background`/`-active` (rest/pressed) so a gradient\n * theme applies consistently, but use the shared `--ui-button-secondary-surface-muted`\n * (also used by `pagination-nav`) for hover, since — unlike `secondary` — an\n * unchecked segment already paints `--ui-surface-muted` on hover by default.\n *\n * @element button-group\n * @fires change - A segment was selected; detail: { value }.\n */\n@customElement(\"button-group\")\nexport class ButtonGroup extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n }\n .group {\n display: flex;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n overflow: hidden;\n }\n .segment {\n position: relative;\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0.5rem 0.75rem;\n border-left: 1px solid var(--ui-border, #e2e8f0);\n cursor: pointer;\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 white-space: nowrap;\n background: var(--ui-button-secondary-background, none);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .segment:first-child {\n border-left: none;\n border-top-left-radius: var(--ui-radius-sm, 0.25rem);\n border-bottom-left-radius: var(--ui-radius-sm, 0.25rem);\n }\n .segment:last-child {\n border-top-right-radius: var(--ui-radius-sm, 0.25rem);\n border-bottom-right-radius: var(--ui-radius-sm, 0.25rem);\n }\n .segment:has(input:checked) {\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n color: var(--ui-on-accent, #ffffff);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .segment:not(:has(input:checked)):hover {\n background: var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n }\n .segment:not(:has(input:checked)):active {\n background: var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none));\n box-shadow: none;\n }\n .segment input {\n /* Fills the whole segment (not visually-hidden-offscreen) so a real\n click anywhere in the segment — including a test driver clicking\n the input by its accessible role — lands on the input itself,\n not just via native <label> click delegation. */\n position: absolute;\n inset: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n /* Clipped by the group's own overflow:hidden unless promoted above its\n neighbors — the focus ring needs a stacking context of its own. */\n .segment:has(input:focus-visible) {\n z-index: 1;\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .segment:has(input: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 .segment:has(input:disabled) {\n cursor: not-allowed;\n opacity: 0.6;\n }\n :host([icon-only]) .segment {\n padding: 0.5rem;\n }\n :host([size=\"sm\"]) .segment {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n :host([icon-only][size=\"sm\"]) .segment {\n padding: 0.25rem;\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n @media (forced-colors: active) {\n .segment:has(input:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .segment:has(input:checked) {\n background: Highlight;\n color: HighlightText;\n }\n .segment:has(input:disabled) {\n color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Options to render, one segment each. */\n @property({ attribute: false }) options: ButtonGroupOption[] = [];\n /** Currently selected value. */\n @property() value = \"\";\n /** Disables every native radio in the group. */\n @property({ type: Boolean }) disabled = false;\n /** Hides labels visually (icons only) while keeping them as the accessible name. */\n @property({ type: Boolean, reflect: true, attribute: \"icon-only\" }) iconOnly = false;\n /** Size — `sm` reduces segment height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n readonly #name = `button-group-${++instanceCount}`;\n\n private _onChange(value: string) {\n if (this.disabled) return;\n this.value = value;\n this.dispatchEvent(\n new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }),\n );\n }\n\n override render() {\n return html`\n <div class=\"group\">\n ${repeat(\n this.options,\n (opt) => opt.value,\n (opt) => html`\n <label class=\"segment\">\n <input\n type=\"radio\"\n name=${this.#name}\n ?checked=${this.value === opt.value}\n ?disabled=${this.disabled}\n aria-label=${this.iconOnly ? opt.label : nothing}\n title=${this.iconOnly ? opt.label : nothing}\n @change=${() => this._onChange(opt.value)}\n />\n ${opt.icon ?? nothing}\n <span class=${this.iconOnly ? \"sr-only\" : \"\"}>${opt.label}</span>\n </label>\n `,\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"button-group\": ButtonGroup;\n }\n}\n"]}
1
+ {"version":3,"file":"button-group.js","sourceRoot":"","sources":["../src/button-group.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASrC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAiIL,2CAA2C;QACX,YAAO,GAAwB,EAAE,CAAC;QAClE,gCAAgC;QACpB,UAAK,GAAG,EAAE,CAAC;QACvB,gDAAgD;QACnB,aAAQ,GAAG,KAAK,CAAC;QAC9C,oFAAoF;QAChB,aAAQ,GAAG,KAAK,CAAC;QACrF,uFAAuF;QAC1D,SAAI,GAAgB,IAAI,CAAC;QAE7C,UAAK,GAAG,gBAAgB,EAAE,aAAa,EAAE,CAAC;IAmCrD,C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C;IACJ,CAAC;CACF,CAAA;AA7CiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4CAAmC;AAEtD;IAAX,QAAQ,EAAE;0CAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAEsB;IAAnE,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;6CAAkB;AAExD;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAA0B;AA1I3C,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA+KvB","sourcesContent":["import type { TemplateResult } from \"lit\";\nimport { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport interface ButtonGroupOption {\n value: string;\n label: string;\n /** Optional pre-rendered icon template displayed before the label. */\n icon?: TemplateResult;\n}\n\nlet instanceCount = 0;\n\n/**\n * Single-select segmented control — a strip of buttons joined into one\n * shared-border shape, for a small, persistent set of mutually exclusive\n * choices (a view switcher, a theme picker) where the *currently selected*\n * option should read as visually \"pressed,\" not just checked. For many\n * short, individually pill-shaped choices, use `radio-pills` instead. Wraps\n * native radio inputs for keyboard/a11y and fires `change` rather than\n * relying on form submission. Set `size=\"sm\"` for a compact strip one step\n * below the default, matching `ui-button`'s `sm` size.\n *\n * The checked segment reads `--ui-button-background`/`-hover`/`-active`,\n * same as `ui-button`'s `primary` variant. Unchecked segments are treated as\n * `ui-button`'s `secondary` variant: they read the shared\n * `--ui-button-secondary-background`/`-active` (rest/pressed) so a gradient\n * theme applies consistently, but use the shared `--ui-button-secondary-surface-muted`\n * (also used by `pagination-nav`) for hover, since — unlike `secondary` — an\n * unchecked segment already paints `--ui-surface-muted` on hover by default.\n *\n * @element button-group\n * @fires change - A segment was selected; detail: { value }.\n */\n@customElement(\"button-group\")\nexport class ButtonGroup extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: inline-block;\n }\n .group {\n display: flex;\n border: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n overflow: hidden;\n }\n .segment {\n position: relative;\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n justify-content: center;\n gap: 0.25rem;\n height: 2rem;\n box-sizing: border-box;\n padding: 0.5rem 0.75rem;\n border-left: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n cursor: pointer;\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 white-space: nowrap;\n background: var(--ui-button-secondary-background, none);\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .segment:first-child {\n border-left: none;\n border-top-left-radius: var(--ui-radius-sm, 0.25rem);\n border-bottom-left-radius: var(--ui-radius-sm, 0.25rem);\n }\n .segment:last-child {\n border-top-right-radius: var(--ui-radius-sm, 0.25rem);\n border-bottom-right-radius: var(--ui-radius-sm, 0.25rem);\n }\n .segment:has(input:checked) {\n background: var(--ui-button-background, var(--ui-primary, #4f46e5));\n color: var(--ui-on-accent, #ffffff);\n text-shadow: var(--ui-button-text-shadow, none);\n }\n .segment:not(:has(input:checked)):hover {\n background: var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n }\n .segment:not(:has(input:checked)):active {\n background: var(--ui-button-secondary-background-active, var(--ui-button-secondary-background, none));\n box-shadow: none;\n }\n .segment input {\n /* Fills the whole segment (not visually-hidden-offscreen) so a real\n click anywhere in the segment — including a test driver clicking\n the input by its accessible role — lands on the input itself,\n not just via native <label> click delegation. */\n position: absolute;\n inset: 0;\n margin: 0;\n opacity: 0;\n cursor: pointer;\n }\n /* Clipped by the group's own overflow:hidden unless promoted above its\n neighbors — the focus ring needs a stacking context of its own. */\n .segment:has(input:focus-visible) {\n z-index: 1;\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .segment:has(input: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 .segment:has(input:disabled) {\n cursor: not-allowed;\n opacity: 0.6;\n }\n :host([icon-only]) .segment {\n padding: 0.5rem;\n }\n :host([size=\"sm\"]) .segment {\n height: 1.5rem;\n padding: 0.25rem 0.5rem;\n font-size: var(--ui-font-size-xs, 0.6875rem);\n }\n :host([icon-only][size=\"sm\"]) .segment {\n padding: 0.25rem;\n }\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n @media (forced-colors: active) {\n .segment:has(input:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .segment:has(input:checked) {\n background: Highlight;\n color: HighlightText;\n }\n .segment:has(input:disabled) {\n color: GrayText;\n opacity: 1;\n }\n }\n `,\n ];\n\n /** Options to render, one segment each. */\n @property({ attribute: false }) options: ButtonGroupOption[] = [];\n /** Currently selected value. */\n @property() value = \"\";\n /** Disables every native radio in the group. */\n @property({ type: Boolean }) disabled = false;\n /** Hides labels visually (icons only) while keeping them as the accessible name. */\n @property({ type: Boolean, reflect: true, attribute: \"icon-only\" }) iconOnly = false;\n /** Size — `sm` reduces segment height/padding/font-size one step below the default. */\n @property({ reflect: true }) size: \"sm\" | \"md\" = \"md\";\n\n readonly #name = `button-group-${++instanceCount}`;\n\n private _onChange(value: string) {\n if (this.disabled) return;\n this.value = value;\n this.dispatchEvent(\n new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }),\n );\n }\n\n override render() {\n return html`\n <div class=\"group\">\n ${repeat(\n this.options,\n (opt) => opt.value,\n (opt) => html`\n <label class=\"segment\">\n <input\n type=\"radio\"\n name=${this.#name}\n ?checked=${this.value === opt.value}\n ?disabled=${this.disabled}\n aria-label=${this.iconOnly ? opt.label : nothing}\n title=${this.iconOnly ? opt.label : nothing}\n @change=${() => this._onChange(opt.value)}\n />\n ${opt.icon ?? nothing}\n <span class=${this.iconOnly ? \"sr-only\" : \"\"}>${opt.label}</span>\n </label>\n `,\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"button-group\": ButtonGroup;\n }\n}\n"]}