@threadlabs/looma 0.1.27 → 0.2.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.
Files changed (214) hide show
  1. package/dist/{chunk-RLELJVBL.js → chunk-JXSHRMYW.js} +32 -33
  2. package/dist/{chunk-YHXJC5M5.js → chunk-M7FPK6GN.js} +17 -12
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/looma.cjs.js +1 -1
  5. package/dist/cjs/{positioning-i0WrCAdF.js → positioning-D5q9DM-0.js} +19 -12
  6. package/dist/cjs/ui-affordance-scope.cjs.entry.js +1 -1
  7. package/dist/cjs/ui-chip_2.cjs.entry.js +190 -498
  8. package/dist/cjs/ui-combobox.cjs.entry.js +708 -0
  9. package/dist/cjs/ui-context-menu.cjs.entry.js +2 -2
  10. package/dist/cjs/ui-dialog.cjs.entry.js +2 -2
  11. package/dist/cjs/ui-disclosure.cjs.entry.js +1 -1
  12. package/dist/cjs/ui-editable.cjs.entry.js +3 -3
  13. package/dist/cjs/ui-floating-action-button.cjs.entry.js +1 -1
  14. package/dist/cjs/ui-form-field.cjs.entry.js +1 -1
  15. package/dist/cjs/ui-icon-button.cjs.entry.js +1 -1
  16. package/dist/cjs/ui-input.cjs.entry.js +1 -1
  17. package/dist/cjs/ui-menu-item.cjs.entry.js +1 -1
  18. package/dist/cjs/ui-menu.cjs.entry.js +3 -3
  19. package/dist/cjs/ui-popover.cjs.entry.js +3 -3
  20. package/dist/cjs/ui-radio-group.cjs.entry.js +1 -1
  21. package/dist/cjs/ui-radio.cjs.entry.js +1 -1
  22. package/dist/cjs/ui-search-result-row.cjs.entry.js +1 -1
  23. package/dist/cjs/ui-search-shell.cjs.entry.js +1 -1
  24. package/dist/cjs/ui-select.cjs.entry.js +1 -1
  25. package/dist/cjs/ui-switch.cjs.entry.js +2 -2
  26. package/dist/cjs/ui-tabs.cjs.entry.js +1 -1
  27. package/dist/cjs/ui-textarea.cjs.entry.js +1 -1
  28. package/dist/cjs/ui-toast-region.cjs.entry.js +2 -2
  29. package/dist/cjs/ui-top-bar.cjs.entry.js +1 -1
  30. package/dist/cjs/ui-tree-item.cjs.entry.js +2 -2
  31. package/dist/cjs/ui-tree.cjs.entry.js +1 -1
  32. package/dist/collection/collection-manifest.json +0 -1
  33. package/dist/collection/components/ui-combobox/ui-combobox.css +23 -0
  34. package/dist/collection/components/ui-combobox/ui-combobox.js +298 -21
  35. package/dist/collection/components/ui-context-menu/ui-context-menu.js +1 -1
  36. package/dist/collection/components/ui-dialog/ui-dialog.css +1 -0
  37. package/dist/collection/components/ui-dialog/ui-dialog.js +1 -1
  38. package/dist/collection/components/ui-disclosure/ui-disclosure.js +1 -1
  39. package/dist/collection/components/ui-editable/ui-editable.js +3 -3
  40. package/dist/collection/components/ui-floating-action-button/ui-floating-action-button.js +1 -1
  41. package/dist/collection/components/ui-form-field/ui-form-field.js +1 -1
  42. package/dist/collection/components/ui-icon-button/ui-icon-button.js +1 -1
  43. package/dist/collection/components/ui-input/ui-input.js +1 -1
  44. package/dist/collection/components/ui-menu/ui-menu.css +7 -2
  45. package/dist/collection/components/ui-menu/ui-menu.js +1 -1
  46. package/dist/collection/components/ui-menu-item/ui-menu-item.js +1 -1
  47. package/dist/collection/components/ui-popover/ui-popover.css +6 -2
  48. package/dist/collection/components/ui-popover/ui-popover.js +1 -1
  49. package/dist/collection/components/ui-radio/ui-radio.js +1 -1
  50. package/dist/collection/components/ui-radio-group/ui-radio-group.js +1 -1
  51. package/dist/collection/components/ui-search-result-row/ui-search-result-row.js +1 -1
  52. package/dist/collection/components/ui-search-shell/ui-search-shell.js +1 -1
  53. package/dist/collection/components/ui-select/ui-select.js +1 -1
  54. package/dist/collection/components/ui-switch/ui-switch.js +2 -2
  55. package/dist/collection/components/ui-tabs/ui-tabs.js +1 -1
  56. package/dist/collection/components/ui-textarea/ui-textarea.js +1 -1
  57. package/dist/collection/components/ui-toast-region/ui-toast-region.js +1 -1
  58. package/dist/collection/components/ui-tooltip/ui-tooltip.js +1 -1
  59. package/dist/collection/components/ui-top-bar/ui-top-bar.js +1 -1
  60. package/dist/collection/components/ui-tree/ui-tree.js +1 -1
  61. package/dist/collection/components/ui-tree-item/ui-tree-item.js +2 -2
  62. package/dist/collection/overlay/positioning.js +21 -14
  63. package/dist/components/index.d.ts +0 -2
  64. package/dist/components/index.js +1 -1
  65. package/dist/components/{p-DZRtXH6j.js → p-DWN2m6ta.js} +1 -1
  66. package/dist/components/p-DYiNETk6.js +1 -0
  67. package/dist/components/p-Drw41pSY.js +1 -0
  68. package/dist/components/ui-affordance-scope.js +1 -1
  69. package/dist/components/ui-combobox.js +1 -1
  70. package/dist/components/ui-context-menu.js +1 -1
  71. package/dist/components/ui-dialog.js +1 -1
  72. package/dist/components/ui-disclosure.js +1 -1
  73. package/dist/components/ui-editable.js +1 -1
  74. package/dist/components/ui-floating-action-button.js +1 -1
  75. package/dist/components/ui-form-field.js +1 -1
  76. package/dist/components/ui-icon-button.js +1 -1
  77. package/dist/components/ui-input.js +1 -1
  78. package/dist/components/ui-menu-item.js +1 -1
  79. package/dist/components/ui-menu.js +1 -1
  80. package/dist/components/ui-popover.js +1 -1
  81. package/dist/components/ui-radio-group.js +1 -1
  82. package/dist/components/ui-radio.js +1 -1
  83. package/dist/components/ui-search-result-row.js +1 -1
  84. package/dist/components/ui-search-shell.js +1 -1
  85. package/dist/components/ui-select.js +1 -1
  86. package/dist/components/ui-switch.js +1 -1
  87. package/dist/components/ui-tabs.js +1 -1
  88. package/dist/components/ui-textarea.js +1 -1
  89. package/dist/components/ui-toast-region.js +1 -1
  90. package/dist/components/ui-tooltip.js +1 -1
  91. package/dist/components/ui-top-bar.js +1 -1
  92. package/dist/components/ui-tree-item.js +1 -1
  93. package/dist/components/ui-tree.js +1 -1
  94. package/dist/esm/loader.js +1 -1
  95. package/dist/esm/looma.js +1 -1
  96. package/dist/esm/{positioning-Bu0dmLBE.js → positioning-Drmwg-C1.js} +19 -12
  97. package/dist/esm/ui-affordance-scope.entry.js +1 -1
  98. package/dist/esm/ui-chip_2.entry.js +193 -501
  99. package/dist/esm/ui-combobox.entry.js +706 -0
  100. package/dist/esm/ui-context-menu.entry.js +2 -2
  101. package/dist/esm/ui-dialog.entry.js +2 -2
  102. package/dist/esm/ui-disclosure.entry.js +1 -1
  103. package/dist/esm/ui-editable.entry.js +3 -3
  104. package/dist/esm/ui-floating-action-button.entry.js +1 -1
  105. package/dist/esm/ui-form-field.entry.js +1 -1
  106. package/dist/esm/ui-icon-button.entry.js +1 -1
  107. package/dist/esm/ui-input.entry.js +1 -1
  108. package/dist/esm/ui-menu-item.entry.js +1 -1
  109. package/dist/esm/ui-menu.entry.js +3 -3
  110. package/dist/esm/ui-popover.entry.js +3 -3
  111. package/dist/esm/ui-radio-group.entry.js +1 -1
  112. package/dist/esm/ui-radio.entry.js +1 -1
  113. package/dist/esm/ui-search-result-row.entry.js +1 -1
  114. package/dist/esm/ui-search-shell.entry.js +1 -1
  115. package/dist/esm/ui-select.entry.js +1 -1
  116. package/dist/esm/ui-switch.entry.js +2 -2
  117. package/dist/esm/ui-tabs.entry.js +1 -1
  118. package/dist/esm/ui-textarea.entry.js +1 -1
  119. package/dist/esm/ui-toast-region.entry.js +2 -2
  120. package/dist/esm/ui-top-bar.entry.js +1 -1
  121. package/dist/esm/ui-tree-item.entry.js +2 -2
  122. package/dist/esm/ui-tree.entry.js +1 -1
  123. package/dist/index.cjs +525 -550
  124. package/dist/index.js +27 -14
  125. package/dist/looma/looma.esm.js +1 -1
  126. package/dist/looma/{p-9a82c523.entry.js → p-1249a806.entry.js} +1 -1
  127. package/dist/looma/p-1c00670f.entry.js +1 -0
  128. package/dist/looma/p-22842f8c.entry.js +1 -0
  129. package/dist/looma/{p-1e1de77f.entry.js → p-2915d5c0.entry.js} +1 -1
  130. package/dist/looma/{p-72338f53.entry.js → p-32c85198.entry.js} +1 -1
  131. package/dist/looma/{p-b75aff63.entry.js → p-37ec2b4b.entry.js} +1 -1
  132. package/dist/looma/{p-2f3c1b57.entry.js → p-3b2961a6.entry.js} +1 -1
  133. package/dist/looma/{p-e07e6ac2.entry.js → p-3f60f4c8.entry.js} +1 -1
  134. package/dist/looma/{p-9551ebf6.entry.js → p-424d6719.entry.js} +1 -1
  135. package/dist/looma/{p-6cc3180b.entry.js → p-4caccfce.entry.js} +1 -1
  136. package/dist/looma/p-55e06e2e.entry.js +1 -0
  137. package/dist/looma/{p-a939c00f.entry.js → p-56dac38a.entry.js} +1 -1
  138. package/dist/looma/p-5cbbf7a0.entry.js +1 -0
  139. package/dist/looma/{p-f431dc13.entry.js → p-6f20d470.entry.js} +1 -1
  140. package/dist/looma/{p-b68762f2.entry.js → p-7c0b5364.entry.js} +1 -1
  141. package/dist/looma/{p-e82f104c.entry.js → p-8bdd9495.entry.js} +1 -1
  142. package/dist/looma/{p-df696cca.entry.js → p-9cfbf722.entry.js} +1 -1
  143. package/dist/looma/p-Drmwg-C1.js +1 -0
  144. package/dist/looma/{p-607c3056.entry.js → p-b6ede6bb.entry.js} +1 -1
  145. package/dist/looma/p-b6fb6ba3.entry.js +1 -0
  146. package/dist/looma/{p-da6e2d01.entry.js → p-b76e2111.entry.js} +1 -1
  147. package/dist/looma/{p-1a12eb5c.entry.js → p-d372b0db.entry.js} +1 -1
  148. package/dist/looma/p-d46317e0.entry.js +1 -0
  149. package/dist/looma/{p-20387ffa.entry.js → p-d4825822.entry.js} +1 -1
  150. package/dist/looma/{p-8a5e3fe1.entry.js → p-d5c3954f.entry.js} +1 -1
  151. package/dist/looma/p-e604e906.entry.js +1 -0
  152. package/dist/looma/{p-e406656e.entry.js → p-f1f7c5cb.entry.js} +1 -1
  153. package/dist/types/components/ui-combobox/ui-combobox.d.ts +35 -4
  154. package/dist/types/components.d.ts +56 -153
  155. package/dist/{ui-affordance-scope.entry-7H6GIQEK.js → ui-affordance-scope.entry-VR7FLAWG.js} +2 -2
  156. package/dist/{ui-avatar-group.entry-QB25IUWA.js → ui-avatar-group.entry-L3UKOY3U.js} +1 -1
  157. package/dist/{ui-avatar.entry-L377CWPR.js → ui-avatar.entry-VM5OHEFQ.js} +1 -1
  158. package/dist/{ui-badge.entry-QHC3KI5S.js → ui-badge.entry-ZTM4OPUD.js} +1 -1
  159. package/dist/{ui-button.entry-MZGTPU22.js → ui-button.entry-CIPUSV5B.js} +1 -1
  160. package/dist/{ui-callout.entry-2D4LO74K.js → ui-callout.entry-OBFCI2O7.js} +1 -1
  161. package/dist/{ui-checkbox.entry-B2O5DREC.js → ui-checkbox.entry-XT6ET56H.js} +1 -1
  162. package/dist/{ui-tooltip.entry-VG4AWEBD.js → ui-chip_2.entry-32SHCLV6.js} +19 -4
  163. package/dist/{ui-chip_2.entry-OOSON72O.js → ui-combobox.entry-ONBBPQ2C.js} +170 -31
  164. package/dist/{ui-context-menu.entry-UY76G7HM.js → ui-context-menu.entry-RXNUOK24.js} +3 -3
  165. package/dist/{ui-dialog.entry-345V7IJ3.js → ui-dialog.entry-IJXNUARC.js} +3 -3
  166. package/dist/{ui-disclosure.entry-RUU7VNDN.js → ui-disclosure.entry-5QS7UDRH.js} +2 -2
  167. package/dist/{ui-editable.entry-WWFFHOMP.js → ui-editable.entry-D7LOQN2H.js} +3 -3
  168. package/dist/{ui-floating-action-button.entry-Y2TLDJO4.js → ui-floating-action-button.entry-XQZCTZQT.js} +2 -2
  169. package/dist/{ui-form-field.entry-C63GZMQR.js → ui-form-field.entry-A654LJZE.js} +2 -2
  170. package/dist/{ui-icon-button.entry-35MJYYEI.js → ui-icon-button.entry-MJ7F7ZIH.js} +2 -2
  171. package/dist/{ui-input.entry-3FAXEH5M.js → ui-input.entry-B2XM7JQU.js} +2 -2
  172. package/dist/{ui-menu-item.entry-3J42XLCJ.js → ui-menu-item.entry-JULYSFVW.js} +2 -2
  173. package/dist/{ui-menu.entry-YDABO3OO.js → ui-menu.entry-ORRWW7HD.js} +4 -4
  174. package/dist/{ui-popover.entry-YP7R6FQO.js → ui-popover.entry-W67V4UPA.js} +4 -4
  175. package/dist/{ui-radio-group.entry-TYXAN7G5.js → ui-radio-group.entry-KCFOR27M.js} +2 -2
  176. package/dist/{ui-radio.entry-JW7HX3LW.js → ui-radio.entry-I2P4V5E3.js} +2 -2
  177. package/dist/{ui-search-result-row.entry-MKQYGNFO.js → ui-search-result-row.entry-GHODLSLR.js} +2 -2
  178. package/dist/{ui-search-shell.entry-KHIQTT4J.js → ui-search-shell.entry-PDB5UN4B.js} +2 -2
  179. package/dist/{ui-select.entry-R235Y3IL.js → ui-select.entry-D3CZHCKB.js} +2 -2
  180. package/dist/{ui-switch.entry-BJ6FIEPB.js → ui-switch.entry-WUDRL4H5.js} +3 -3
  181. package/dist/{ui-tabs.entry-ZBP3FLR2.js → ui-tabs.entry-MW64GKIJ.js} +2 -2
  182. package/dist/{ui-textarea.entry-2YW7TCEU.js → ui-textarea.entry-VHRBYY6G.js} +2 -2
  183. package/dist/{ui-toast-region.entry-ZSCMMIKQ.js → ui-toast-region.entry-ET75RWYP.js} +3 -3
  184. package/dist/{ui-top-bar.entry-CZW3MLC6.js → ui-top-bar.entry-QIYA3LD3.js} +2 -2
  185. package/dist/{ui-tree-item.entry-CU2SWAOK.js → ui-tree-item.entry-BDB7VEUS.js} +3 -3
  186. package/dist/{ui-tree.entry-M6KXK7GJ.js → ui-tree.entry-GSC7BPRN.js} +2 -2
  187. package/package.json +1 -1
  188. package/styles.css +6 -4
  189. package/vue/{chunk-2DDIBSFD.js → chunk-ROMBQS2L.js} +32 -89
  190. package/vue/editor/index.js +1 -1
  191. package/vue/index.d.ts +30 -107
  192. package/vue/index.js +1 -3
  193. package/dist/cjs/ui-multi-combobox.cjs.entry.js +0 -190
  194. package/dist/cjs/ui-tooltip.cjs.entry.js +0 -241
  195. package/dist/collection/components/ui-multi-combobox/ui-multi-combobox.css +0 -33
  196. package/dist/collection/components/ui-multi-combobox/ui-multi-combobox.js +0 -553
  197. package/dist/components/p-BKzrrab4.js +0 -1
  198. package/dist/components/p-D0wBI-9r.js +0 -1
  199. package/dist/components/p-DOulVJT7.js +0 -1
  200. package/dist/components/ui-multi-combobox.d.ts +0 -11
  201. package/dist/components/ui-multi-combobox.js +0 -1
  202. package/dist/esm/ui-multi-combobox.entry.js +0 -188
  203. package/dist/esm/ui-tooltip.entry.js +0 -239
  204. package/dist/looma/p-071c139c.entry.js +0 -1
  205. package/dist/looma/p-0fd60103.entry.js +0 -1
  206. package/dist/looma/p-4fc9917f.entry.js +0 -1
  207. package/dist/looma/p-66c6b6dd.entry.js +0 -1
  208. package/dist/looma/p-77dcfa6f.entry.js +0 -1
  209. package/dist/looma/p-85a6716e.entry.js +0 -1
  210. package/dist/looma/p-8f102407.entry.js +0 -1
  211. package/dist/looma/p-Bu0dmLBE.js +0 -1
  212. package/dist/looma/p-caa37be2.entry.js +0 -1
  213. package/dist/types/components/ui-multi-combobox/ui-multi-combobox.d.ts +0 -51
  214. package/dist/ui-multi-combobox.entry-XXLS4V3I.js +0 -196
@@ -0,0 +1,706 @@
1
+ import { r as registerInstance, c as createEvent, g as getElement, h, H as Host } from './index-8BGiMGQ0.js';
2
+ import { a as createAnchoredSurface } from './positioning-Drmwg-C1.js';
3
+ import { c as closeOverlay, o as openOverlay } from './manager-C-0syqXZ.js';
4
+
5
+ /** Formatting is additive: every original character must survive in order.
6
+ * Normalization belongs to submitted output, never the visible editing buffer. */
7
+ function formatEditingValue(raw, selection, format) {
8
+ const unchanged = { display: raw, selection };
9
+ if (!format)
10
+ return unchanged;
11
+ let result;
12
+ try {
13
+ result = format(raw, selection);
14
+ }
15
+ catch {
16
+ return unchanged;
17
+ }
18
+ if (!result)
19
+ return unchanged;
20
+ const characters = Array.from(raw);
21
+ let cursor = 0;
22
+ for (const character of result.display)
23
+ if (character === characters[cursor])
24
+ cursor += 1;
25
+ if (!Number.isInteger(result.selection.start) || !Number.isInteger(result.selection.end) || cursor !== characters.length || result.selection.start < 0 || result.selection.end < result.selection.start
26
+ || result.selection.end > result.display.length)
27
+ return unchanged;
28
+ return result;
29
+ }
30
+ async function validateField(request, config) {
31
+ let output = request.raw;
32
+ let issues = [];
33
+ const check = () => request.signal.throwIfAborted();
34
+ try {
35
+ check();
36
+ if (config.parse)
37
+ output = await config.parse(request.raw, request);
38
+ check();
39
+ if (config.schema) {
40
+ const result = await config.schema['~standard'].validate(output);
41
+ check();
42
+ if (result.issues)
43
+ issues = result.issues;
44
+ else if ('value' in result)
45
+ output = result.value;
46
+ }
47
+ if (!issues.some(issue => issue.severity !== 'warning')) {
48
+ if (config.normalize)
49
+ output = await config.normalize(output, request);
50
+ check();
51
+ if (config.validator) {
52
+ const result = await config.validator(output, request);
53
+ check();
54
+ issues = [...issues, ...(result.issues ?? [])];
55
+ if ('output' in result)
56
+ output = result.output;
57
+ }
58
+ }
59
+ }
60
+ catch (error) {
61
+ check();
62
+ issues = [{ message: error instanceof Error ? error.message : 'Unable to validate this value.' }];
63
+ }
64
+ issues = [...issues, ...(config.issues ?? [])];
65
+ return { output: issues.some(issue => issue.severity !== 'warning') ? undefined : output, issues };
66
+ }
67
+
68
+ const uiComboboxCss = () => `:host{display:grid;gap:var(--ui-space-1);min-inline-size:0;color:var(--ui-text-primary);font:inherit}label{color:var(--ui-field-label-color, var(--ui-text-primary));font-size:var(--ui-field-label-size, 0.875rem);font-weight:var(--ui-field-label-weight, 500)}.field{display:flex;min-inline-size:0;border:1px solid var(--ui-control-border, var(--ui-border-default));border-radius:var(--ui-radius-2);background:var(--ui-control-surface, var(--ui-surface-default))}.field:focus-within{border-color:var(--ui-control-focus, var(--ui-focus-ring));outline:2px solid var(--ui-control-focus, var(--ui-focus-ring));outline-offset:1px}input{appearance:none;width:100%;min-inline-size:0;min-block-size:var(--ui-control-min-block-size, 2.75rem);box-sizing:border-box;border:0;border-radius:inherit;background:transparent;color:inherit;font:inherit;line-height:var(--ui-line-height-md);padding:var(--ui-space-2) var(--ui-space-3);margin:0;outline:none}:host([data-size='sm']) input{min-block-size:var(--ui-field-compact-size, 2rem);padding:var(--ui-space-1) var(--ui-space-2)}button{appearance:none;border:0;border-radius:var(--ui-radius-2);background:transparent;color:var(--ui-field-affordance-color, var(--ui-text-secondary));font:inherit;font-weight:var(--ui-field-affordance-weight, 400);min-inline-size:2rem;padding:var(--ui-space-1);cursor:pointer}button:hover:enabled{background:var(--ui-surface-muted);color:var(--ui-text-primary)}button:focus-visible{outline:2px solid var(--ui-focus-ring);outline-offset:-3px}input:disabled,button:disabled{color:var(--ui-text-muted);cursor:not-allowed}.field:has(input:disabled){background:var(--ui-control-surface-disabled, var(--ui-surface-muted))}:host([data-validation='error']) .field{border-color:var(--ui-danger-solid, var(--ui-accent-active))}.popup{box-sizing:border-box;min-inline-size:12rem;max-inline-size:calc(100vw - 1rem);max-block-size:var(--ui-combobox-max-block-size, 18rem);overflow:auto;margin:0;padding:var(--ui-space-1);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-2);background:var(--ui-surface-elevated);color:var(--ui-text-primary);box-shadow:var(--ui-shadow-md)}[hidden]{display:none !important}.option{padding:var(--ui-space-2) var(--ui-space-3);border-radius:var(--ui-radius-1);cursor:pointer;overflow-wrap:anywhere}.option:hover,.option[data-active]{background:var(--ui-surface-muted);outline:1px solid var(--ui-focus-ring);outline-offset:-1px}.option[aria-disabled='true']{color:var(--ui-text-muted);cursor:not-allowed}.primary{display:block;color:var(--ui-option-primary-color, var(--ui-text-primary));font-weight:var(--ui-option-primary-weight, 500)}.secondary{display:block;color:var(--ui-option-secondary-color, var(--ui-text-secondary));font-weight:var(--ui-option-secondary-weight, 400);font-size:var(--ui-font-size-sm)}.message,.group{color:var(--ui-field-message-color, var(--ui-text-secondary));font-weight:var(--ui-field-message-weight, 400);font-size:var(--ui-font-size-sm);line-height:var(--ui-line-height-md);overflow-wrap:anywhere}.group,.popup .message{padding:var(--ui-space-2) var(--ui-space-3)}.sr-only{position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@media (pointer: coarse){button{min-inline-size:2.75rem;min-block-size:2.75rem}}@media (forced-colors: active){.field,.popup{border-color:CanvasText}.option[data-active]{outline-color:Highlight}}:host([multiple]) .field{flex-wrap:wrap;align-items:center;gap:var(--ui-space-1);min-block-size:var(--ui-multi-combobox-min-block-size, 2.5rem);padding:var(--ui-space-1)}:host([multiple]) input{flex:1 0 var(--ui-multi-combobox-input-min-inline-size, 5rem);width:auto;min-block-size:1.75rem;padding:var(--ui-space-0-5) var(--ui-space-1)}.items{display:contents}.item{appearance:none;display:inline-flex;min-inline-size:0;max-inline-size:min(100%, var(--ui-multi-combobox-item-max-inline-size, 12rem));overflow:hidden;padding:0;border:0;border-radius:var(--ui-radius-1);background:transparent;color:inherit;font:inherit;cursor:default}.item>slot{display:block;min-inline-size:0;max-inline-size:100%;overflow:hidden}.item>slot::slotted(*){min-inline-size:0;max-inline-size:100%}.item:focus-visible{outline:2px solid var(--ui-focus-ring);outline-offset:1px}.item:disabled{opacity:.6}`;
69
+
70
+ const UICombobox = class {
71
+ constructor(hostRef) {
72
+ registerInstance(this, hostRef);
73
+ this.queryChange = createEvent(this, "query-change");
74
+ this.valueChange = createEvent(this, "value-change");
75
+ this.freeEntry = createEvent(this, "free-entry");
76
+ this.createEntry = createEvent(this, "create-entry");
77
+ this.dependencyInvalidate = createEvent(this, "dependency-invalidate");
78
+ this.validationChange = createEvent(this, "validation-change");
79
+ this.optionsChange = createEvent(this, "options-change");
80
+ this.addItem = createEvent(this, "add-item");
81
+ this.removeItem = createEvent(this, "remove-item");
82
+ this.createItem = createEvent(this, "create-item");
83
+ }
84
+ get host() { return getElement(this); }
85
+ /** Accessible visible label, associated with the native text input. */
86
+ label = '';
87
+ placeholder = '';
88
+ name = '';
89
+ /**
90
+ * Controlled canonical value. Undefined selects uncontrolled mode; null means no selection.
91
+ * With `multiple`, this is the controlled list of selected items instead.
92
+ */
93
+ value;
94
+ defaultValue;
95
+ /** Render selected values as removable chips before the cursor. `value` becomes the item list. */
96
+ multiple = false;
97
+ /** Characters that commit the current query and leave the input ready for the next item (multiple only). */
98
+ tokenSeparators = [];
99
+ /** Controlled raw editing text; independent of canonical selection. */
100
+ query;
101
+ defaultQuery = '';
102
+ /** Immutable configuration; replace the object/context when dependencies change. */
103
+ config = {};
104
+ disabled = false;
105
+ readOnly = false;
106
+ required = false;
107
+ size = 'md';
108
+ /** Keep the native label accessible while allowing compact composed controls. */
109
+ labelVisibility = 'visible';
110
+ disclosure = false;
111
+ clearable = false;
112
+ /** Optional description shown by the connected question-mark button. */
113
+ help = '';
114
+ queryChange;
115
+ /** Single mode: the ComboboxChange. Multiple mode: the full current item list on any change. */
116
+ valueChange;
117
+ freeEntry;
118
+ createEntry;
119
+ dependencyInvalidate;
120
+ validationChange;
121
+ /** Supplies the current result rows for framework-owned rich slots. */
122
+ optionsChange;
123
+ /** Multiple mode: a suggestion or exact-match token was committed as a new item. */
124
+ addItem;
125
+ /** Multiple mode: a selected item was removed via chip keyboard controls. */
126
+ removeItem;
127
+ /** Multiple mode: an unmatched query was submitted for creation. */
128
+ createItem;
129
+ raw = '';
130
+ display = '';
131
+ selected = null;
132
+ expanded = false;
133
+ rows = [];
134
+ active = -1;
135
+ loading = false;
136
+ helpOpen = false;
137
+ lookupError = '';
138
+ validation = { status: 'pristine', touched: false, dirty: false, issues: [] };
139
+ input;
140
+ popup;
141
+ field;
142
+ surface;
143
+ lookup;
144
+ validationRun;
145
+ lookupTimer;
146
+ composing = false;
147
+ initialRaw = '';
148
+ overlayId = `ui-combobox-${Math.random().toString(36).slice(2)}`;
149
+ alive = false;
150
+ fullSet = false;
151
+ knownOptions = new Map();
152
+ awaitingLabel = null;
153
+ proposedChange;
154
+ formattedRaw;
155
+ formattedWith;
156
+ /** Multiple mode: the controlled selected items (from `value`). Empty otherwise. */
157
+ get items() {
158
+ return this.multiple && Array.isArray(this.value) ? this.value : [];
159
+ }
160
+ get selectedValues() { return new Set(this.items.map(item => item.value)); }
161
+ componentWillLoad() {
162
+ if (this.multiple) {
163
+ this.selected = null;
164
+ this.raw = this.query ?? this.defaultQuery;
165
+ this.display = this.raw;
166
+ this.initialRaw = this.raw;
167
+ this.applyServerIssues();
168
+ return;
169
+ }
170
+ this.selected = (this.value !== undefined ? this.value : this.defaultValue ?? null);
171
+ this.raw = this.query ?? this.defaultQuery;
172
+ if (this.query === undefined && !this.raw && this.selected !== null) {
173
+ this.raw = this.config.options?.find(row => row.value === this.selected)?.label ?? this.selected;
174
+ }
175
+ if (this.query === undefined && this.selected !== null && this.raw === this.selected)
176
+ this.awaitingLabel = this.selected;
177
+ this.display = this.raw;
178
+ this.initialRaw = this.raw;
179
+ this.applyServerIssues();
180
+ }
181
+ connectedCallback() { this.alive = true; this.setupSurface(); }
182
+ componentDidLoad() { this.setupSurface(); }
183
+ componentDidUpdate() {
184
+ if (this.input && !this.composing && this.input.value !== this.display)
185
+ this.input.value = this.display;
186
+ if (this.expanded)
187
+ this.surface?.refresh();
188
+ }
189
+ disconnectedCallback() {
190
+ this.alive = false;
191
+ this.close();
192
+ this.validationRun?.abort();
193
+ this.surface?.destroy();
194
+ this.surface = undefined;
195
+ }
196
+ setupSurface() {
197
+ if (!this.surface && this.popup && this.field)
198
+ this.surface = createAnchoredSurface(this.popup, { anchor: this.field, placement: 'bottom-start' });
199
+ }
200
+ syncValue() {
201
+ // Multiple mode: `value` is the item list; Stencil re-renders chips on reference change.
202
+ if (this.multiple || this.value === undefined)
203
+ return;
204
+ this.selected = this.value;
205
+ if (this.query === undefined) {
206
+ const proposal = this.proposedChange;
207
+ const option = this.config.options?.find(row => row.value === this.selected)
208
+ ?? (this.selected === null ? undefined : this.knownOptions.get(this.selected));
209
+ const nextRaw = proposal?.value === this.selected ? proposal.query : option?.label ?? this.selected ?? '';
210
+ if (proposal?.value !== this.selected || nextRaw !== this.raw) {
211
+ this.raw = nextRaw;
212
+ this.display = this.raw;
213
+ this.formattedRaw = undefined;
214
+ }
215
+ this.awaitingLabel = !option && this.selected !== null ? this.selected : null;
216
+ }
217
+ this.resetValidation();
218
+ }
219
+ syncQuery() {
220
+ if (this.query === undefined || this.query === this.raw)
221
+ return;
222
+ // Only a selection proposal's query echo retains an uncontrolled identity.
223
+ // Other owner text replacements are edits, just like native input.
224
+ if (this.value === undefined && this.proposedChange?.query !== this.query)
225
+ this.selected = null;
226
+ this.awaitingLabel = null;
227
+ this.formattedRaw = undefined;
228
+ this.raw = this.query;
229
+ this.display = this.raw;
230
+ this.resetValidation();
231
+ if (this.expanded)
232
+ this.search('input');
233
+ }
234
+ syncDisabled() {
235
+ if (this.disabled || this.readOnly) {
236
+ this.close();
237
+ this.resetValidation();
238
+ }
239
+ }
240
+ syncConfig(next, previous) {
241
+ this.validationRun?.abort();
242
+ if (next.provider !== previous?.provider || next.context !== previous?.context)
243
+ this.knownOptions.clear();
244
+ if (next.context !== previous?.context) {
245
+ this.close();
246
+ const policy = next.invalidation ?? 'retain-query';
247
+ if (this.multiple) {
248
+ if (policy === 'clear')
249
+ this.setMultiQuery('', 'programmatic');
250
+ }
251
+ else {
252
+ const value = policy === 'retain' ? this.selected : null;
253
+ const query = policy === 'clear' ? '' : this.raw;
254
+ this.commit(value, query, null, 'invalidation', 'programmatic');
255
+ }
256
+ this.validation = { status: 'pristine', touched: false, dirty: this.raw !== this.initialRaw, issues: [] };
257
+ }
258
+ this.applyServerIssues();
259
+ if (this.expanded)
260
+ this.search('context');
261
+ }
262
+ applyServerIssues() {
263
+ const issues = this.config.issues ?? [];
264
+ if (issues.length)
265
+ this.setValidation({ issues }, this.validation.touched);
266
+ else
267
+ this.resetValidation();
268
+ }
269
+ resetValidation() {
270
+ this.validationRun?.abort();
271
+ this.validation = { status: 'pristine', touched: this.validation.touched, dirty: this.raw !== this.initialRaw, issues: [] };
272
+ this.validationChange?.emit(this.validation);
273
+ }
274
+ cancelLookup() {
275
+ clearTimeout(this.lookupTimer);
276
+ this.lookup?.abort();
277
+ this.lookup = undefined;
278
+ this.loading = false;
279
+ }
280
+ close() {
281
+ this.expanded = false;
282
+ this.active = -1;
283
+ this.cancelLookup();
284
+ this.surface?.hide();
285
+ closeOverlay(this.overlayId);
286
+ }
287
+ open(reason = 'input') {
288
+ if (this.disabled || this.readOnly)
289
+ return;
290
+ this.expanded = true;
291
+ if (this.popup && this.field)
292
+ this.popup.style.minWidth = `${this.field.getBoundingClientRect().width}px`;
293
+ this.surface?.show();
294
+ openOverlay({ id: this.overlayId, element: this.popup, relatedElements: [this.host], modal: false,
295
+ requestClose: () => this.close() });
296
+ this.search(reason);
297
+ }
298
+ search(reason) {
299
+ this.cancelLookup();
300
+ this.fullSet = reason === 'disclosure';
301
+ this.active = -1;
302
+ this.lookupError = '';
303
+ const config = this.config;
304
+ const query = this.fullSet ? '' : this.raw;
305
+ const controller = new AbortController();
306
+ this.lookup = controller;
307
+ const apply = (options) => {
308
+ if (controller.signal.aborted || !this.alive)
309
+ return;
310
+ for (const option of options)
311
+ this.knownOptions.set(option.value, option);
312
+ const selectedOption = this.selected === null ? undefined : this.knownOptions.get(this.selected);
313
+ if (this.query === undefined && this.awaitingLabel === this.selected && selectedOption) {
314
+ this.raw = selectedOption.label;
315
+ this.display = this.raw;
316
+ this.awaitingLabel = null;
317
+ this.formattedRaw = undefined;
318
+ this.resetValidation();
319
+ }
320
+ const ids = new Set();
321
+ const selected = this.multiple ? this.selectedValues : undefined;
322
+ this.rows = options.filter(option => {
323
+ if (ids.has(option.id))
324
+ return false;
325
+ ids.add(option.id);
326
+ if (this.fullSet)
327
+ return true;
328
+ // Multiple mode always hides already-selected items and, absent an owner
329
+ // filter, falls back to a client label match (there is no unfiltered pass-through).
330
+ if (selected)
331
+ return !selected.has(option.value)
332
+ && (config.filter ? config.filter(option, query, config.context)
333
+ : option.label.toLocaleLowerCase().includes(query.toLocaleLowerCase()));
334
+ return config.filter ? config.filter(option, query, config.context)
335
+ : config.provider ? true : option.label.toLocaleLowerCase().includes(query.toLocaleLowerCase());
336
+ });
337
+ const groups = new Map();
338
+ for (const row of this.rows) {
339
+ const group = row.group ?? '';
340
+ if (!groups.has(group))
341
+ groups.set(group, []);
342
+ groups.get(group).push(row);
343
+ }
344
+ this.rows = [...groups.values()].flat();
345
+ this.loading = false;
346
+ this.optionsChange.emit(this.rows);
347
+ };
348
+ if (!config.provider) {
349
+ apply(config.options ?? []);
350
+ return;
351
+ }
352
+ this.rows = [];
353
+ this.loading = true;
354
+ this.lookupTimer = setTimeout(async () => {
355
+ try {
356
+ apply(await config.provider({ query, context: config.context, signal: controller.signal, reason }));
357
+ }
358
+ catch (error) {
359
+ if (controller.signal.aborted || !this.alive)
360
+ return;
361
+ this.loading = false;
362
+ this.lookupError = error instanceof Error ? error.message : 'Unable to load suggestions.';
363
+ }
364
+ }, reason === 'disclosure' ? 0 : Math.max(0, config.debounce ?? 200));
365
+ }
366
+ get canCreate() {
367
+ const candidates = this.config.options ? [...this.config.options, ...this.rows] : this.rows;
368
+ return Boolean(this.config.allowCreate && this.raw.trim() && !this.loading && !this.lookupError
369
+ && !candidates.some(row => row.label.toLocaleLowerCase() === this.raw.toLocaleLowerCase()));
370
+ }
371
+ format(timing) {
372
+ if ((this.config.formatOn ?? 'blur') !== timing || !this.input)
373
+ return;
374
+ // Selection is now in display coordinates; do not map it as raw a second time.
375
+ if (this.formattedRaw === this.raw && this.formattedWith === this.config.format)
376
+ return;
377
+ const result = formatEditingValue(this.raw, {
378
+ start: this.input.selectionStart ?? this.raw.length, end: this.input.selectionEnd ?? this.raw.length,
379
+ direction: this.input.selectionDirection ?? 'none',
380
+ }, this.config.format);
381
+ this.formattedRaw = this.raw;
382
+ this.formattedWith = this.config.format;
383
+ this.display = result.display;
384
+ if (this.input.value !== result.display) {
385
+ this.input.value = result.display;
386
+ this.input.setSelectionRange(result.selection.start, result.selection.end, result.selection.direction);
387
+ }
388
+ }
389
+ onInput = (event) => {
390
+ // Composition updates remain entirely native until compositionend.
391
+ if (this.composing || event.isComposing)
392
+ return;
393
+ this.awaitingLabel = null;
394
+ this.formattedRaw = undefined;
395
+ this.raw = this.input.value;
396
+ this.display = this.raw;
397
+ this.resetValidation();
398
+ this.format('input');
399
+ this.queryChange.emit({ query: this.raw, display: this.display, trigger: 'keyboard' });
400
+ if (this.selected !== null)
401
+ this.commit(null, this.raw, null, 'clear', 'keyboard');
402
+ this.open();
403
+ if (this.config.validateOn === 'input')
404
+ void this.validate();
405
+ queueMicrotask(() => {
406
+ if (this.query !== undefined && this.query !== this.raw)
407
+ this.syncQuery();
408
+ });
409
+ };
410
+ commit(value, query, option, kind, trigger) {
411
+ this.awaitingLabel = null;
412
+ const queryChanged = query !== this.raw;
413
+ if (this.value === undefined)
414
+ this.selected = value;
415
+ if (this.query === undefined && queryChanged) {
416
+ this.raw = query;
417
+ this.display = query;
418
+ this.formattedRaw = undefined;
419
+ }
420
+ this.resetValidation();
421
+ const detail = { value, query, option, kind, trigger };
422
+ const proposal = { value, query };
423
+ this.proposedChange = proposal;
424
+ this.valueChange.emit(detail);
425
+ if (queryChanged)
426
+ this.queryChange.emit({ query, display: query, trigger });
427
+ if (kind === 'create')
428
+ this.createEntry.emit(detail);
429
+ if (kind === 'free-entry')
430
+ this.freeEntry.emit(detail);
431
+ if (kind === 'invalidation')
432
+ this.dependencyInvalidate.emit(detail);
433
+ // Settle after all owner notifications (including Vue's queued update).
434
+ // A retained prop does not fire a Stencil watcher, so rejection must be
435
+ // reconciled explicitly while the proposal still identifies an edit echo.
436
+ queueMicrotask(() => {
437
+ if (this.proposedChange !== proposal)
438
+ return;
439
+ if (this.value !== undefined && this.value !== proposal.value)
440
+ this.syncValue();
441
+ if (this.query !== undefined && this.query !== proposal.query) {
442
+ if (this.value === undefined) {
443
+ this.selected = null;
444
+ this.resetValidation();
445
+ }
446
+ this.syncQuery();
447
+ }
448
+ this.proposedChange = undefined;
449
+ });
450
+ }
451
+ choose(index, trigger) {
452
+ const option = this.rows[index];
453
+ if (option?.disabled)
454
+ return;
455
+ if (this.multiple) {
456
+ if (option)
457
+ this.addSelectedItem(option, trigger);
458
+ else if (this.canCreate && index === this.rows.length)
459
+ this.createSelectedItem(this.raw.trim(), trigger);
460
+ else
461
+ return;
462
+ this.setMultiQuery('', trigger);
463
+ this.close();
464
+ this.input?.focus();
465
+ return;
466
+ }
467
+ if (option)
468
+ this.commit(option.value, option.label, option, 'selection', trigger);
469
+ else if (this.canCreate && index === this.rows.length)
470
+ this.commit(null, this.raw, null, 'create', trigger);
471
+ else
472
+ return;
473
+ this.close();
474
+ this.input?.focus();
475
+ if (this.config.validateOn !== 'submit')
476
+ queueMicrotask(() => void this.validate());
477
+ }
478
+ // --- Multiple-mode helpers ---------------------------------------------
479
+ emitItems(items) { this.valueChange.emit(items); }
480
+ setMultiQuery(query, trigger) {
481
+ if (this.query === undefined) {
482
+ this.raw = query;
483
+ this.display = query;
484
+ this.formattedRaw = undefined;
485
+ }
486
+ if (this.input)
487
+ this.input.value = query;
488
+ this.queryChange.emit({ query, display: query, trigger });
489
+ }
490
+ addSelectedItem(option, trigger) {
491
+ this.addItem.emit({ item: option, index: this.items.length, trigger });
492
+ this.emitItems([...this.items, option]);
493
+ }
494
+ createSelectedItem(query, trigger) {
495
+ if (!query)
496
+ return;
497
+ this.createItem.emit({ query, trigger });
498
+ }
499
+ commitQuery(trigger) {
500
+ const query = this.raw.trim();
501
+ if (!query)
502
+ return;
503
+ const normalized = query.toLocaleLowerCase();
504
+ const option = this.rows.find(row => row.label.trim().toLocaleLowerCase() === normalized);
505
+ if (option) {
506
+ this.setMultiQuery('', trigger);
507
+ this.addSelectedItem(option, trigger);
508
+ }
509
+ else if (this.config.allowCreate) {
510
+ this.setMultiQuery('', trigger);
511
+ this.createSelectedItem(query, trigger);
512
+ }
513
+ }
514
+ removeItemAt(index, trigger) {
515
+ const item = this.items[index];
516
+ if (!item || item.disabled || this.disabled || this.readOnly)
517
+ return;
518
+ this.removeItem.emit({ item, index, trigger });
519
+ this.emitItems(this.items.filter((_, position) => position !== index));
520
+ requestAnimationFrame(() => {
521
+ const buttons = this.host.shadowRoot?.querySelectorAll('[part="item"]') ?? [];
522
+ const next = buttons[Math.min(index, buttons.length - 1)] ?? buttons[index - 1];
523
+ if (next && next.dataset.value !== item.value)
524
+ next.focus();
525
+ else
526
+ void this.focusInput();
527
+ });
528
+ }
529
+ focusItem(index) {
530
+ this.host.shadowRoot?.querySelectorAll('[part="item"]')[index]?.focus();
531
+ }
532
+ onItemKeyDown = (event, index) => {
533
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
534
+ return;
535
+ if (event.key === 'ArrowLeft') {
536
+ event.preventDefault();
537
+ event.stopPropagation();
538
+ this.focusItem(Math.max(0, index - 1));
539
+ }
540
+ else if (event.key === 'ArrowRight') {
541
+ event.preventDefault();
542
+ event.stopPropagation();
543
+ if (index === this.items.length - 1)
544
+ void this.focusInput();
545
+ else
546
+ this.focusItem(index + 1);
547
+ }
548
+ else if (event.key === 'Backspace' || event.key === 'Delete') {
549
+ event.preventDefault();
550
+ event.stopPropagation();
551
+ this.removeItemAt(index, 'keyboard');
552
+ }
553
+ };
554
+ handleMultipleKeydown(event) {
555
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
556
+ return false;
557
+ if (this.tokenSeparators.includes(event.key)) {
558
+ event.preventDefault();
559
+ event.stopPropagation();
560
+ this.commitQuery('keyboard');
561
+ return true;
562
+ }
563
+ if (this.raw || (this.input?.selectionStart ?? 0) > 0)
564
+ return false;
565
+ if (event.key === 'ArrowLeft' && this.items.length) {
566
+ event.preventDefault();
567
+ this.focusItem(this.items.length - 1);
568
+ return true;
569
+ }
570
+ if (event.key === 'Backspace' && this.items.length) {
571
+ event.preventDefault();
572
+ this.removeItemAt(this.items.length - 1, 'keyboard');
573
+ return true;
574
+ }
575
+ return false;
576
+ }
577
+ move(key) {
578
+ const indices = this.rows.flatMap((row, index) => row.disabled ? [] : [index]);
579
+ if (this.canCreate)
580
+ indices.push(this.rows.length);
581
+ if (!indices.length)
582
+ return;
583
+ const current = indices.indexOf(this.active);
584
+ const next = key === 'Home' ? 0 : key === 'End' ? indices.length - 1
585
+ : key === 'ArrowDown' ? Math.min(current + 1, indices.length - 1)
586
+ : current < 0 ? indices.length - 1 : Math.max(0, current - 1);
587
+ this.active = indices[next];
588
+ requestAnimationFrame(() => this.host.shadowRoot?.getElementById(`option-${this.active}`)?.scrollIntoView({ block: 'nearest' }));
589
+ }
590
+ onKeydown = (event) => {
591
+ if (this.composing || event.isComposing || this.disabled || this.readOnly)
592
+ return;
593
+ if (this.multiple && this.handleMultipleKeydown(event))
594
+ return;
595
+ if (event.key === 'Escape' && this.expanded) {
596
+ event.preventDefault();
597
+ event.stopPropagation();
598
+ this.close();
599
+ return;
600
+ }
601
+ if (event.key === 'Tab') {
602
+ this.close();
603
+ return;
604
+ }
605
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
606
+ return;
607
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
608
+ event.preventDefault();
609
+ if (!this.expanded)
610
+ this.open('disclosure');
611
+ this.move(event.key);
612
+ }
613
+ else if ((event.key === 'Home' || event.key === 'End') && this.expanded && this.active >= 0) {
614
+ event.preventDefault();
615
+ this.move(event.key);
616
+ }
617
+ else if (event.key === 'Enter' && this.expanded) {
618
+ if (this.active >= 0) {
619
+ event.preventDefault();
620
+ this.choose(this.active, 'keyboard');
621
+ }
622
+ else if (this.config.allowFreeText) {
623
+ event.preventDefault();
624
+ this.commit(null, this.raw, null, 'free-entry', 'keyboard');
625
+ this.close();
626
+ }
627
+ }
628
+ };
629
+ onFocusOut = (event) => {
630
+ if (event.relatedTarget instanceof Node && this.host.shadowRoot?.contains(event.relatedTarget))
631
+ return;
632
+ this.close();
633
+ this.format('blur');
634
+ this.validation = { ...this.validation, touched: true };
635
+ if (!this.multiple && this.config.allowFreeText && this.selected === null)
636
+ this.commit(null, this.raw, null, 'free-entry', 'keyboard');
637
+ if ((this.config.validateOn ?? 'blur') === 'blur')
638
+ void this.validate();
639
+ };
640
+ setValidation(result, touched = this.validation.touched) {
641
+ const blocking = result.issues.some(issue => issue.severity !== 'warning');
642
+ this.validation = { status: blocking ? 'error' : result.issues.length ? 'warning' : 'valid',
643
+ touched, dirty: this.raw !== this.initialRaw, ...result };
644
+ this.validationChange?.emit(this.validation);
645
+ }
646
+ /** Validate for submission. Caller submits only non-pending, non-error output. */
647
+ async validate() {
648
+ this.validationRun?.abort();
649
+ const run = new AbortController();
650
+ this.validationRun = run;
651
+ this.validation = { ...this.validation, status: 'pending', output: undefined };
652
+ this.validationChange.emit(this.validation);
653
+ try {
654
+ const result = await validateField({ raw: this.raw, value: this.selected, context: this.config.context, signal: run.signal }, this.config);
655
+ if (this.required && !this.raw.trim())
656
+ result.issues = [...result.issues, { message: 'A value is required.' }];
657
+ else if (this.raw && this.selected === null && !this.config.allowFreeText && !this.config.allowCreate)
658
+ result.issues = [...result.issues, { message: 'Choose a suggestion.' }];
659
+ if (result.issues.some(issue => issue.severity !== 'warning'))
660
+ result.output = undefined;
661
+ if (!run.signal.aborted && this.alive)
662
+ this.setValidation(result);
663
+ }
664
+ catch { /* Aborted work never becomes current field state. */ }
665
+ return this.validation;
666
+ }
667
+ /** Focus the native editing input from a composed control. */
668
+ async focusInput() { this.input?.focus(); }
669
+ render() {
670
+ const description = [this.helpOpen ? 'help-text' : '', this.validation.issues.length ? 'validation' : ''].filter(Boolean).join(' ') || undefined;
671
+ const status = this.loading ? 'Loading suggestions…' : this.lookupError || (this.expanded ? `${this.rows.length} suggestions available.` : '');
672
+ const groups = [...new Set(this.rows.map(row => row.group ?? ''))];
673
+ return h(Host, { key: 'fc4c0192d3be88d8c0199ae1bcca44232bd22351', "data-size": this.size, "data-validation": this.validation.status, onFocusout: this.onFocusOut }, h("label", { key: 'bdd0d244c6ef448978fa77aac3a2d3b71d713553', htmlFor: "input", part: "label", class: this.labelVisibility === 'sr-only' ? 'sr-only' : undefined }, this.label, this.required ? ' *' : ''), h("div", { key: 'afb3972aab52171a3b25ede863c31059e56f5d91', class: "field", part: "field", ref: element => this.field = element, onClick: event => {
674
+ if (!event.composedPath().some(node => node instanceof HTMLButtonElement))
675
+ this.input?.focus();
676
+ } }, h("slot", { key: '65e4e201d6c11cd2638e392e1298662de7ba4d57', name: "start" }), this.multiple && h("div", { key: 'b80b5b85fa0540139b9756fcc494aef9df245c15', class: "items", role: "group", "aria-label": `Selected ${this.label}` }, this.items.map((item, index) => h("button", { type: "button", part: "item", class: "item", "data-value": item.value, tabIndex: -1, disabled: this.disabled || this.readOnly || item.disabled, "aria-label": `${item.label}, press Delete or Backspace to remove`, onKeyDown: event => this.onItemKeyDown(event, index) }, h("slot", { name: `item-${item.id}` }, h("ui-chip", { appearance: "pill" }, item.label))))), h("input", { key: '64f76055ae412cc87119270eec10c69000a72563', id: "input", ref: element => this.input = element, role: "combobox", "aria-autocomplete": "list", "aria-expanded": String(this.expanded), "aria-controls": "listbox", "aria-activedescendant": this.expanded && this.active >= 0 ? `option-${this.active}` : undefined, "aria-describedby": description, "aria-invalid": String(this.validation.status === 'error'), "aria-busy": String(this.validation.status === 'pending'), value: this.display, placeholder: this.placeholder, name: this.name || undefined, disabled: this.disabled, readOnly: this.readOnly, required: this.required, autoComplete: "off", part: "input", onInput: this.onInput, onKeyDown: this.onKeydown, onCompositionstart: () => this.composing = true, onCompositionend: () => { this.composing = false; this.onInput(new InputEvent('input')); } }), this.clearable && h("button", { key: 'eac4c18dadcea92065af4ecd871d925ef1248d47', type: "button", part: "affordance", "aria-label": `Clear ${this.label}`, disabled: this.disabled || this.readOnly, onClick: () => { this.commit(null, '', null, 'clear', 'pointer'); this.close(); this.input?.focus(); } }, "\u00D7"), this.help && h("button", { key: '9a559d49a495ead3dbf159f170c594e0aaa0d0d0', id: "help", type: "button", part: "affordance", "aria-label": `Help for ${this.label}`, disabled: this.disabled }, h("span", { key: '73940e568b976f85399d5baa5e247a4a606d0039', "aria-hidden": "true" }, "?")), this.disclosure && h("button", { key: '30dd6746ffb121888a4c4fb6df54720906badf78', type: "button", part: "affordance", "aria-label": `Suggestions for ${this.label}`, "aria-controls": "listbox", "aria-expanded": String(this.expanded), disabled: this.disabled || this.readOnly, onClick: () => {
677
+ if (this.expanded)
678
+ this.close();
679
+ else
680
+ this.open('disclosure');
681
+ this.input?.focus();
682
+ } }, h("span", { key: '7d3b10a765ee0a6c40d7b0b49e98c676a5837944', "aria-hidden": "true" }, "\u2304"))), this.help && h("ui-tooltip", { key: 'efff00f45dc281b727789eb2aa84ff772bb5c925', id: "help-text", for: "help", toggleOnClick: true, onOpen: () => this.helpOpen = true, onClose: () => this.helpOpen = false }, this.help), h("div", { key: '770bc12b873026b571bd3ae2a80416e8af52b8d4', class: "popup", part: "popup", hidden: !this.expanded, ref: element => this.popup = element }, h("div", { key: 'ed48c8dd8b672a577d567ca5e795b8a53fde2761', id: "listbox", role: "listbox", "aria-label": `${this.label} suggestions`, "aria-busy": String(this.loading) }, groups.map(group => h("div", { role: group ? 'group' : 'presentation', "aria-label": group || undefined }, group && h("div", { class: "group", part: "group" }, group), this.rows.map((row, index) => (row.group ?? '') !== group ? null : h("div", { id: `option-${index}`, role: "option", "aria-selected": String(this.selected === row.value), "aria-disabled": String(Boolean(row.disabled)), "data-active": this.active === index ? '' : undefined, part: "option", class: "option", onPointerDown: event => event.preventDefault(), onClick: () => this.choose(index, 'pointer') }, h("slot", { name: `option-${row.id}` }, h("span", { class: "primary", part: "option-primary" }, row.label), row.description && h("span", { class: "secondary", part: "option-secondary" }, row.description)))))), this.canCreate && h("div", { key: '43215f449bbccde407ef818cee473f69870f6f8c', id: `option-${this.rows.length}`, role: "option", "aria-selected": "false", class: "option", part: "option", "data-active": this.active === this.rows.length ? '' : undefined, onPointerDown: event => event.preventDefault(), onClick: () => this.choose(this.rows.length, 'pointer') }, h("slot", { key: '3ff70ff3ab8e24afc369a26e8474e7d1220ed6eb', name: "create" }, "Create \u201C", this.raw, "\u201D"))), this.loading ? h("div", { class: "message" }, h("slot", { name: "loading" }, "Loading suggestions\u2026"))
683
+ : this.lookupError ? h("div", { class: "message" }, h("slot", { name: "error" }, this.lookupError))
684
+ : !this.rows.length && !this.canCreate ? h("div", { class: "message" }, h("slot", { name: "empty" }, "No suggestions.")) : null, h("slot", { key: '8b1fbd4f5c372393d294d8c218ae1785e6b0334f', name: "footer" })), h("div", { key: '18e68687f04e35535edee363683523ce6bbb0291', id: "validation", class: "message", part: "validation", hidden: !this.validation.issues.length }, this.validation.issues.map(issue => h("div", null, issue.message))), h("div", { key: 'e4a7db06abcfaf08b8ac592107531a13ef3a5897', class: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true" }, status, " ", this.validation.status === 'pending' ? 'Checking value…' : this.validation.issues.map(issue => issue.message).join(' ')));
685
+ }
686
+ static get watchers() { return {
687
+ "value": [{
688
+ "syncValue": 0
689
+ }],
690
+ "query": [{
691
+ "syncQuery": 0
692
+ }],
693
+ "disabled": [{
694
+ "syncDisabled": 0
695
+ }],
696
+ "readOnly": [{
697
+ "syncDisabled": 0
698
+ }],
699
+ "config": [{
700
+ "syncConfig": 0
701
+ }]
702
+ }; }
703
+ };
704
+ UICombobox.style = uiComboboxCss();
705
+
706
+ export { UICombobox as ui_combobox };