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