@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
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-BHG9Rpil.js');
4
- var positioning = require('./positioning-i0WrCAdF.js');
5
4
  var manager = require('./manager-Ce25WRtl.js');
5
+ var events = require('./events-TcQIzpNv.js');
6
+ var controlledState = require('./controlled-state-BFya8rAX.js');
7
+ var positioning = require('./positioning-D5q9DM-0.js');
6
8
 
7
9
  const uiChipCss = () => `:host{--ui-chip-surface:var(--ui-surface-subtle);--ui-chip-text:var(--ui-text-secondary);--ui-chip-border:var(--ui-border-default);--ui-chip-font-size:var(--ui-font-size-xs);--ui-chip-font-weight:var(--ui-font-normal);--ui-chip-line-height:var(--ui-line-height-tight);--ui-chip-padding-block:var(--ui-space-0-5);--ui-chip-padding-inline:var(--ui-space-2);--ui-chip-notch:var(--ui-space-1);display:inline-flex;min-width:0;max-width:100%}:host([data-size='sm']){--ui-chip-font-size:var(--ui-font-size-sm)}.chip__surface{display:inline-flex;align-items:center;box-sizing:border-box;min-width:0;max-width:100%;padding:var(--ui-chip-padding-block) var(--ui-chip-padding-inline);border:1px solid var(--ui-chip-border);background:var(--ui-chip-surface);color:var(--ui-chip-text) !important;font-family:var(--ui-font-family-sans) !important;font-size:var(--ui-chip-font-size) !important;font-weight:var(--ui-chip-font-weight) !important;line-height:var(--ui-chip-line-height) !important}.chip__label{min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}:host([data-appearance='pill']) .chip__surface{border-radius:var(--ui-radius-round)}:host([data-appearance='tag']) .chip__surface{border:0;padding-inline-end:calc(var(--ui-chip-padding-inline) + var(--ui-chip-notch));clip-path:polygon(0 0, calc(100% - var(--ui-chip-notch)) 0, 100% 50%, calc(100% - var(--ui-chip-notch)) 100%, 0 100%)}`;
8
10
 
@@ -20,547 +22,237 @@ const UIChip = class {
20
22
  };
21
23
  UIChip.style = uiChipCss();
22
24
 
23
- /** Formatting is additive: every original character must survive in order.
24
- * Normalization belongs to submitted output, never the visible editing buffer. */
25
- function formatEditingValue(raw, selection, format) {
26
- const unchanged = { display: raw, selection };
27
- if (!format)
28
- return unchanged;
29
- let result;
30
- try {
31
- result = format(raw, selection);
32
- }
33
- catch {
34
- return unchanged;
35
- }
36
- if (!result)
37
- return unchanged;
38
- const characters = Array.from(raw);
39
- let cursor = 0;
40
- for (const character of result.display)
41
- if (character === characters[cursor])
42
- cursor += 1;
43
- if (!Number.isInteger(result.selection.start) || !Number.isInteger(result.selection.end) || cursor !== characters.length || result.selection.start < 0 || result.selection.end < result.selection.start
44
- || result.selection.end > result.display.length)
45
- return unchanged;
46
- return result;
47
- }
48
- async function validateField(request, config) {
49
- let output = request.raw;
50
- let issues = [];
51
- const check = () => request.signal.throwIfAborted();
52
- try {
53
- check();
54
- if (config.parse)
55
- output = await config.parse(request.raw, request);
56
- check();
57
- if (config.schema) {
58
- const result = await config.schema['~standard'].validate(output);
59
- check();
60
- if (result.issues)
61
- issues = result.issues;
62
- else if ('value' in result)
63
- output = result.value;
64
- }
65
- if (!issues.some(issue => issue.severity !== 'warning')) {
66
- if (config.normalize)
67
- output = await config.normalize(output, request);
68
- check();
69
- if (config.validator) {
70
- const result = await config.validator(output, request);
71
- check();
72
- issues = [...issues, ...(result.issues ?? [])];
73
- if ('output' in result)
74
- output = result.output;
75
- }
76
- }
77
- }
78
- catch (error) {
79
- check();
80
- issues = [{ message: error instanceof Error ? error.message : 'Unable to validate this value.' }];
81
- }
82
- issues = [...issues, ...(config.issues ?? [])];
83
- return { output: issues.some(issue => issue.severity !== 'warning') ? undefined : output, issues };
84
- }
85
-
86
- 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}}`;
25
+ const uiTooltipCss = () => `:host{position:fixed;inset:auto;margin:0;display:inline-block;box-sizing:border-box;padding:0;border:0;border-radius:0;background:transparent;opacity:0;transform:translateY(4px);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease), transform var(--ui-motion-fast) var(--ui-motion-ease), display var(--ui-motion-fast) allow-discrete, overlay var(--ui-motion-fast) allow-discrete}.tooltip__surface{box-sizing:border-box;border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-2);background:var(--ui-surface-elevated);color:var(--ui-text-primary);padding:var(--ui-space-2) var(--ui-space-3);font-size:var(--ui-font-size-sm);box-shadow:var(--ui-shadow-md)}:host(:popover-open){opacity:1;transform:translateY(0)}@starting-style{:host(:popover-open){opacity:0;transform:translateY(4px)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host{transition:none}}`;
87
26
 
88
- const UICombobox = class {
27
+ const UITooltip = class {
89
28
  constructor(hostRef) {
90
29
  index.registerInstance(this, hostRef);
91
- this.queryChange = index.createEvent(this, "query-change");
92
- this.valueChange = index.createEvent(this, "value-change");
93
- this.freeEntry = index.createEvent(this, "free-entry");
94
- this.createEntry = index.createEvent(this, "create-entry");
95
- this.dependencyInvalidate = index.createEvent(this, "dependency-invalidate");
96
- this.validationChange = index.createEvent(this, "validation-change");
97
- this.optionsChange = index.createEvent(this, "options-change");
30
+ this.opened = index.createEvent(this, "open");
31
+ this.closed = index.createEvent(this, "close");
98
32
  }
99
33
  get host() { return index.getElement(this); }
100
- /** Accessible visible label, associated with the native text input. */
101
- label = '';
102
- placeholder = '';
103
- name = '';
104
- /** Controlled canonical value. Undefined selects uncontrolled mode; null means no selection. */
105
- value;
106
- defaultValue;
107
- /** Controlled raw editing text; independent of canonical selection. */
108
- query;
109
- defaultQuery = '';
110
- /** Immutable configuration; replace the object/context when dependencies change. */
111
- config = {};
112
- disabled = false;
113
- readOnly = false;
114
- required = false;
115
- size = 'md';
116
- /** Keep the native label accessible while allowing compact composed controls. */
117
- labelVisibility = 'visible';
118
- disclosure = false;
119
- clearable = false;
120
- /** Optional description shown by the connected question-mark button. */
121
- help = '';
122
- queryChange;
123
- valueChange;
124
- freeEntry;
125
- createEntry;
126
- dependencyInvalidate;
127
- validationChange;
128
- /** Supplies the current result rows for framework-owned rich slots. */
129
- optionsChange;
130
- raw = '';
131
- display = '';
132
- selected = null;
133
- expanded = false;
134
- rows = [];
135
- active = -1;
136
- loading = false;
137
- helpOpen = false;
138
- lookupError = '';
139
- validation = { status: 'pristine', touched: false, dirty: false, issues: [] };
140
- input;
141
- popup;
142
- field;
143
- surface;
144
- lookup;
145
- validationRun;
146
- lookupTimer;
147
- composing = false;
148
- initialRaw = '';
149
- overlayId = `ui-combobox-${Math.random().toString(36).slice(2)}`;
150
- alive = false;
151
- fullSet = false;
152
- knownOptions = new Map();
153
- awaitingLabel = null;
154
- proposedChange;
155
- formattedRaw;
156
- formattedWith;
157
- componentWillLoad() {
158
- this.selected = this.value !== undefined ? this.value : this.defaultValue ?? null;
159
- this.raw = this.query ?? this.defaultQuery;
160
- if (this.query === undefined && !this.raw && this.selected !== null) {
161
- this.raw = this.config.options?.find(row => row.value === this.selected)?.label ?? this.selected;
34
+ for = '';
35
+ /** Controlled open state. Omit it to use defaultOpen and local interaction state. */
36
+ open;
37
+ defaultOpen = false;
38
+ placement = 'top-start';
39
+ /** Pointer hover intent delay in milliseconds. Keyboard focus is immediate. */
40
+ showDelay = 500;
41
+ /** Pointer leave grace period in milliseconds. */
42
+ hideDelay = 100;
43
+ /** Click or tap pins the description; activate again to dismiss. */
44
+ toggleOnClick = false;
45
+ pinned = false;
46
+ focused = false;
47
+ opened;
48
+ closed;
49
+ internalOpen = false;
50
+ overlayId = `ui-tooltip-${Math.random().toString(36).slice(2, 11)}`;
51
+ trigger = null;
52
+ surface = null;
53
+ showTimer = null;
54
+ hideTimer = null;
55
+ syncFromProp() {
56
+ this.clearTimers();
57
+ if (controlledState.isControlled(this.open))
58
+ this.internalOpen = this.open;
59
+ }
60
+ resetSurface() {
61
+ this.syncTrigger();
62
+ this.setupSurface();
63
+ this.syncOverlay();
64
+ }
65
+ syncOverlay() {
66
+ if (this.internalOpen) {
67
+ this.surface?.show();
68
+ manager.openOverlay({
69
+ id: this.overlayId,
70
+ modal: false,
71
+ element: this.host,
72
+ relatedElements: this.trigger ? [this.trigger] : undefined,
73
+ dismissible: true,
74
+ requestClose: (reason, trigger) => this.handleRequestClose(reason, trigger),
75
+ });
76
+ }
77
+ else {
78
+ this.surface?.hide();
79
+ manager.closeOverlay(this.overlayId);
162
80
  }
163
- if (this.query === undefined && this.selected !== null && this.raw === this.selected)
164
- this.awaitingLabel = this.selected;
165
- this.display = this.raw;
166
- this.initialRaw = this.raw;
167
- this.applyServerIssues();
168
81
  }
169
- connectedCallback() { this.alive = true; this.setupSurface(); }
170
- componentDidLoad() { this.setupSurface(); }
82
+ componentDidLoad() {
83
+ if (!this.host.id)
84
+ this.host.id = this.overlayId;
85
+ this.internalOpen = controlledState.controlledOrDefault(this.open, this.defaultOpen);
86
+ this.syncTrigger();
87
+ this.setupSurface();
88
+ this.host.addEventListener('pointerenter', this.onSurfaceEnter);
89
+ this.host.addEventListener('pointerleave', this.onTriggerLeave);
90
+ this.syncOverlay();
91
+ }
171
92
  componentDidUpdate() {
172
- if (this.input && !this.composing && this.input.value !== this.display)
173
- this.input.value = this.display;
174
- if (this.expanded)
175
- this.surface?.refresh();
93
+ this.syncTrigger();
176
94
  }
177
95
  disconnectedCallback() {
178
- this.alive = false;
179
- this.close();
180
- this.validationRun?.abort();
96
+ this.clearTimers();
97
+ this.detachTriggerListeners();
181
98
  this.surface?.destroy();
182
- this.surface = undefined;
99
+ this.surface = null;
100
+ this.host.removeEventListener('pointerenter', this.onSurfaceEnter);
101
+ this.host.removeEventListener('pointerleave', this.onTriggerLeave);
102
+ manager.closeOverlay(this.overlayId);
103
+ }
104
+ syncTrigger() {
105
+ const next = this.for
106
+ ? this.host.getRootNode().getElementById(this.for)
107
+ : this.host.previousElementSibling;
108
+ if (next === this.trigger)
109
+ return;
110
+ this.detachTriggerListeners();
111
+ this.trigger = next;
112
+ this.attachTriggerListeners();
113
+ this.surface?.setAnchor(next);
183
114
  }
184
115
  setupSurface() {
185
- if (!this.surface && this.popup && this.field)
186
- this.surface = positioning.createAnchoredSurface(this.popup, { anchor: this.field, placement: 'bottom-start' });
116
+ this.surface?.destroy();
117
+ this.surface = positioning.createAnchoredSurface(this.host, {
118
+ anchor: this.trigger,
119
+ placement: this.placement,
120
+ });
187
121
  }
188
- syncValue() {
189
- if (this.value === undefined)
122
+ attachTriggerListeners() {
123
+ this.detachTriggerListeners();
124
+ if (!this.trigger)
190
125
  return;
191
- this.selected = this.value;
192
- if (this.query === undefined) {
193
- const proposal = this.proposedChange;
194
- const option = this.config.options?.find(row => row.value === this.selected)
195
- ?? (this.selected === null ? undefined : this.knownOptions.get(this.selected));
196
- const nextRaw = proposal?.value === this.selected ? proposal.query : option?.label ?? this.selected ?? '';
197
- if (proposal?.value !== this.selected || nextRaw !== this.raw) {
198
- this.raw = nextRaw;
199
- this.display = this.raw;
200
- this.formattedRaw = undefined;
201
- }
202
- this.awaitingLabel = !option && this.selected !== null ? this.selected : null;
203
- }
204
- this.resetValidation();
126
+ const ids = new Set((this.trigger.getAttribute('aria-describedby') || '').split(/\s+/).filter(Boolean));
127
+ ids.add(this.host.id);
128
+ this.trigger.setAttribute('aria-describedby', [...ids].join(' '));
129
+ this.trigger.addEventListener('click', this.onTriggerClick);
130
+ this.trigger.addEventListener('keydown', this.onTriggerKeydown);
131
+ this.trigger.addEventListener('pointerenter', this.onTriggerEnter);
132
+ this.trigger.addEventListener('pointerleave', this.onTriggerLeave);
133
+ this.trigger.addEventListener('focusin', this.onTriggerFocusIn);
134
+ this.trigger.addEventListener('focusout', this.onTriggerFocusOut);
205
135
  }
206
- syncQuery() {
207
- if (this.query === undefined || this.query === this.raw)
136
+ detachTriggerListeners() {
137
+ if (!this.trigger)
208
138
  return;
209
- // Only a selection proposal's query echo retains an uncontrolled identity.
210
- // Other owner text replacements are edits, just like native input.
211
- if (this.value === undefined && this.proposedChange?.query !== this.query)
212
- this.selected = null;
213
- this.awaitingLabel = null;
214
- this.formattedRaw = undefined;
215
- this.raw = this.query;
216
- this.display = this.raw;
217
- this.resetValidation();
218
- if (this.expanded)
219
- this.search('input');
220
- }
221
- syncDisabled() {
222
- if (this.disabled || this.readOnly) {
223
- this.close();
224
- this.resetValidation();
225
- }
226
- }
227
- syncConfig(next, previous) {
228
- this.validationRun?.abort();
229
- if (next.provider !== previous?.provider || next.context !== previous?.context)
230
- this.knownOptions.clear();
231
- if (next.context !== previous?.context) {
232
- this.close();
233
- const policy = next.invalidation ?? 'retain-query';
234
- const value = policy === 'retain' ? this.selected : null;
235
- const query = policy === 'clear' ? '' : this.raw;
236
- this.commit(value, query, null, 'invalidation', 'programmatic');
237
- this.validation = { status: 'pristine', touched: false, dirty: this.raw !== this.initialRaw, issues: [] };
238
- }
239
- this.applyServerIssues();
240
- if (this.expanded)
241
- this.search('context');
242
- }
243
- applyServerIssues() {
244
- const issues = this.config.issues ?? [];
245
- if (issues.length)
246
- this.setValidation({ issues }, this.validation.touched);
139
+ const ids = (this.trigger.getAttribute('aria-describedby') || '').split(/\s+/).filter(id => id && id !== this.host.id);
140
+ if (ids.length)
141
+ this.trigger.setAttribute('aria-describedby', ids.join(' '));
247
142
  else
248
- this.resetValidation();
249
- }
250
- resetValidation() {
251
- this.validationRun?.abort();
252
- this.validation = { status: 'pristine', touched: this.validation.touched, dirty: this.raw !== this.initialRaw, issues: [] };
253
- this.validationChange?.emit(this.validation);
254
- }
255
- cancelLookup() {
256
- clearTimeout(this.lookupTimer);
257
- this.lookup?.abort();
258
- this.lookup = undefined;
259
- this.loading = false;
260
- }
261
- close() {
262
- this.expanded = false;
263
- this.active = -1;
264
- this.cancelLookup();
265
- this.surface?.hide();
266
- manager.closeOverlay(this.overlayId);
143
+ this.trigger.removeAttribute('aria-describedby');
144
+ this.trigger.removeEventListener('click', this.onTriggerClick);
145
+ this.trigger.removeEventListener('keydown', this.onTriggerKeydown);
146
+ this.trigger.removeEventListener('pointerenter', this.onTriggerEnter);
147
+ this.trigger.removeEventListener('pointerleave', this.onTriggerLeave);
148
+ this.trigger.removeEventListener('focusin', this.onTriggerFocusIn);
149
+ this.trigger.removeEventListener('focusout', this.onTriggerFocusOut);
267
150
  }
268
- open(reason = 'input') {
269
- if (this.disabled || this.readOnly)
151
+ clearShowTimer() {
152
+ if (this.showTimer === null)
270
153
  return;
271
- this.expanded = true;
272
- if (this.popup && this.field)
273
- this.popup.style.minWidth = `${this.field.getBoundingClientRect().width}px`;
274
- this.surface?.show();
275
- manager.openOverlay({ id: this.overlayId, element: this.popup, relatedElements: [this.host], modal: false,
276
- requestClose: () => this.close() });
277
- this.search(reason);
154
+ clearTimeout(this.showTimer);
155
+ this.showTimer = null;
278
156
  }
279
- search(reason) {
280
- this.cancelLookup();
281
- this.fullSet = reason === 'disclosure';
282
- this.active = -1;
283
- this.lookupError = '';
284
- const config = this.config;
285
- const query = this.fullSet ? '' : this.raw;
286
- const controller = new AbortController();
287
- this.lookup = controller;
288
- const apply = (options) => {
289
- if (controller.signal.aborted || !this.alive)
290
- return;
291
- for (const option of options)
292
- this.knownOptions.set(option.value, option);
293
- const selectedOption = this.selected === null ? undefined : this.knownOptions.get(this.selected);
294
- if (this.query === undefined && this.awaitingLabel === this.selected && selectedOption) {
295
- this.raw = selectedOption.label;
296
- this.display = this.raw;
297
- this.awaitingLabel = null;
298
- this.formattedRaw = undefined;
299
- this.resetValidation();
300
- }
301
- const ids = new Set();
302
- this.rows = options.filter(option => {
303
- if (ids.has(option.id))
304
- return false;
305
- ids.add(option.id);
306
- return this.fullSet || (config.filter ? config.filter(option, query, config.context)
307
- : config.provider ? true : option.label.toLocaleLowerCase().includes(query.toLocaleLowerCase()));
308
- });
309
- const groups = new Map();
310
- for (const row of this.rows) {
311
- const group = row.group ?? '';
312
- if (!groups.has(group))
313
- groups.set(group, []);
314
- groups.get(group).push(row);
315
- }
316
- this.rows = [...groups.values()].flat();
317
- this.loading = false;
318
- this.optionsChange.emit(this.rows);
319
- };
320
- if (!config.provider) {
321
- apply(config.options ?? []);
157
+ clearHideTimer() {
158
+ if (this.hideTimer === null)
322
159
  return;
323
- }
324
- this.rows = [];
325
- this.loading = true;
326
- this.lookupTimer = setTimeout(async () => {
327
- try {
328
- apply(await config.provider({ query, context: config.context, signal: controller.signal, reason }));
329
- }
330
- catch (error) {
331
- if (controller.signal.aborted || !this.alive)
332
- return;
333
- this.loading = false;
334
- this.lookupError = error instanceof Error ? error.message : 'Unable to load suggestions.';
335
- }
336
- }, reason === 'disclosure' ? 0 : Math.max(0, config.debounce ?? 200));
160
+ clearTimeout(this.hideTimer);
161
+ this.hideTimer = null;
337
162
  }
338
- get canCreate() {
339
- const candidates = this.config.options ? [...this.config.options, ...this.rows] : this.rows;
340
- return Boolean(this.config.allowCreate && this.raw.trim() && !this.loading && !this.lookupError
341
- && !candidates.some(row => row.label.toLocaleLowerCase() === this.raw.toLocaleLowerCase()));
163
+ clearTimers() {
164
+ this.clearShowTimer();
165
+ this.clearHideTimer();
342
166
  }
343
- format(timing) {
344
- if ((this.config.formatOn ?? 'blur') !== timing || !this.input)
167
+ setInteractionOpen(nextOpen, trigger) {
168
+ if (this.internalOpen === nextOpen)
345
169
  return;
346
- // Selection is now in display coordinates; do not map it as raw a second time.
347
- if (this.formattedRaw === this.raw && this.formattedWith === this.config.format)
348
- return;
349
- const result = formatEditingValue(this.raw, {
350
- start: this.input.selectionStart ?? this.raw.length, end: this.input.selectionEnd ?? this.raw.length,
351
- direction: this.input.selectionDirection ?? 'none',
352
- }, this.config.format);
353
- this.formattedRaw = this.raw;
354
- this.formattedWith = this.config.format;
355
- this.display = result.display;
356
- if (this.input.value !== result.display) {
357
- this.input.value = result.display;
358
- this.input.setSelectionRange(result.selection.start, result.selection.end, result.selection.direction);
359
- }
360
- }
361
- onInput = (event) => {
362
- // Composition updates remain entirely native until compositionend.
363
- if (this.composing || event.isComposing)
364
- return;
365
- this.awaitingLabel = null;
366
- this.formattedRaw = undefined;
367
- this.raw = this.input.value;
368
- this.display = this.raw;
369
- this.resetValidation();
370
- this.format('input');
371
- this.queryChange.emit({ query: this.raw, display: this.display, trigger: 'keyboard' });
372
- if (this.selected !== null)
373
- this.commit(null, this.raw, null, 'clear', 'keyboard');
374
- this.open();
375
- if (this.config.validateOn === 'input')
376
- void this.validate();
377
- queueMicrotask(() => {
378
- if (this.query !== undefined && this.query !== this.raw)
379
- this.syncQuery();
380
- });
381
- };
382
- commit(value, query, option, kind, trigger) {
383
- this.awaitingLabel = null;
384
- const queryChanged = query !== this.raw;
385
- if (this.value === undefined)
386
- this.selected = value;
387
- if (this.query === undefined && queryChanged) {
388
- this.raw = query;
389
- this.display = query;
390
- this.formattedRaw = undefined;
391
- }
392
- this.resetValidation();
393
- const detail = { value, query, option, kind, trigger };
394
- const proposal = { value, query };
395
- this.proposedChange = proposal;
396
- this.valueChange.emit(detail);
397
- if (queryChanged)
398
- this.queryChange.emit({ query, display: query, trigger });
399
- if (kind === 'create')
400
- this.createEntry.emit(detail);
401
- if (kind === 'free-entry')
402
- this.freeEntry.emit(detail);
403
- if (kind === 'invalidation')
404
- this.dependencyInvalidate.emit(detail);
405
- // Settle after all owner notifications (including Vue's queued update).
406
- // A retained prop does not fire a Stencil watcher, so rejection must be
407
- // reconciled explicitly while the proposal still identifies an edit echo.
408
- queueMicrotask(() => {
409
- if (this.proposedChange !== proposal)
410
- return;
411
- if (this.value !== undefined && this.value !== proposal.value)
412
- this.syncValue();
413
- if (this.query !== undefined && this.query !== proposal.query) {
414
- if (this.value === undefined) {
415
- this.selected = null;
416
- this.resetValidation();
417
- }
418
- this.syncQuery();
419
- }
420
- this.proposedChange = undefined;
170
+ if (!controlledState.isControlled(this.open))
171
+ this.internalOpen = nextOpen;
172
+ events.dispatchDetail(this.host, nextOpen ? 'open' : 'close', {
173
+ open: nextOpen,
174
+ reason: 'action',
175
+ trigger,
421
176
  });
422
177
  }
423
- choose(index, trigger) {
424
- const option = this.rows[index];
425
- if (option?.disabled)
426
- return;
427
- if (option)
428
- this.commit(option.value, option.label, option, 'selection', trigger);
429
- else if (this.canCreate && index === this.rows.length)
430
- this.commit(null, this.raw, null, 'create', trigger);
431
- else
178
+ onSurfaceEnter = () => this.clearHideTimer();
179
+ onTriggerClick = (event) => {
180
+ if (!this.toggleOnClick)
432
181
  return;
433
- this.close();
434
- this.input?.focus();
435
- if (this.config.validateOn !== 'submit')
436
- queueMicrotask(() => void this.validate());
437
- }
438
- move(key) {
439
- const indices = this.rows.flatMap((row, index) => row.disabled ? [] : [index]);
440
- if (this.canCreate)
441
- indices.push(this.rows.length);
442
- if (!indices.length)
443
- return;
444
- const current = indices.indexOf(this.active);
445
- const next = key === 'Home' ? 0 : key === 'End' ? indices.length - 1
446
- : key === 'ArrowDown' ? Math.min(current + 1, indices.length - 1)
447
- : current < 0 ? indices.length - 1 : Math.max(0, current - 1);
448
- this.active = indices[next];
449
- requestAnimationFrame(() => this.host.shadowRoot?.getElementById(`option-${this.active}`)?.scrollIntoView({ block: 'nearest' }));
450
- }
451
- onKeydown = (event) => {
452
- if (this.composing || event.isComposing || this.disabled || this.readOnly)
453
- return;
454
- if (event.key === 'Escape' && this.expanded) {
455
- event.preventDefault();
456
- event.stopPropagation();
457
- this.close();
182
+ this.clearTimers();
183
+ this.pinned = !this.pinned;
184
+ this.setInteractionOpen(this.pinned, event.detail === 0 ? 'keyboard' : 'pointer');
185
+ };
186
+ onTriggerKeydown = (event) => {
187
+ if (event.key === 'Escape')
188
+ this.clearTimers();
189
+ };
190
+ onTriggerEnter = (event) => {
191
+ if (event.pointerType === 'touch')
458
192
  return;
459
- }
460
- if (event.key === 'Tab') {
461
- this.close();
193
+ this.clearHideTimer();
194
+ if (this.internalOpen || this.showTimer !== null)
462
195
  return;
463
- }
464
- if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
196
+ this.showTimer = setTimeout(() => {
197
+ this.showTimer = null;
198
+ this.setInteractionOpen(true, 'pointer');
199
+ }, Math.max(0, this.showDelay));
200
+ };
201
+ onTriggerLeave = () => {
202
+ this.clearShowTimer();
203
+ if (this.focused || this.pinned || !this.internalOpen || this.hideTimer !== null)
465
204
  return;
466
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
467
- event.preventDefault();
468
- if (!this.expanded)
469
- this.open('disclosure');
470
- this.move(event.key);
471
- }
472
- else if ((event.key === 'Home' || event.key === 'End') && this.expanded && this.active >= 0) {
473
- event.preventDefault();
474
- this.move(event.key);
475
- }
476
- else if (event.key === 'Enter' && this.expanded) {
477
- if (this.active >= 0) {
478
- event.preventDefault();
479
- this.choose(this.active, 'keyboard');
480
- }
481
- else if (this.config.allowFreeText) {
482
- event.preventDefault();
483
- this.commit(null, this.raw, null, 'free-entry', 'keyboard');
484
- this.close();
485
- }
486
- }
205
+ this.hideTimer = setTimeout(() => {
206
+ this.hideTimer = null;
207
+ this.setInteractionOpen(false, 'pointer');
208
+ }, Math.max(0, this.hideDelay));
209
+ };
210
+ onTriggerFocusIn = () => {
211
+ this.focused = true;
212
+ this.clearTimers();
213
+ this.setInteractionOpen(true, 'keyboard');
487
214
  };
488
- onFocusOut = (event) => {
489
- if (event.relatedTarget instanceof Node && this.host.shadowRoot?.contains(event.relatedTarget))
215
+ onTriggerFocusOut = (e) => {
216
+ const related = e.relatedTarget;
217
+ if (related && this.host.contains(related))
490
218
  return;
491
- this.close();
492
- this.format('blur');
493
- this.validation = { ...this.validation, touched: true };
494
- if (this.config.allowFreeText && this.selected === null)
495
- this.commit(null, this.raw, null, 'free-entry', 'keyboard');
496
- if ((this.config.validateOn ?? 'blur') === 'blur')
497
- void this.validate();
219
+ this.focused = false;
220
+ this.pinned = false;
221
+ this.clearTimers();
222
+ this.setInteractionOpen(false, 'keyboard');
498
223
  };
499
- setValidation(result, touched = this.validation.touched) {
500
- const blocking = result.issues.some(issue => issue.severity !== 'warning');
501
- this.validation = { status: blocking ? 'error' : result.issues.length ? 'warning' : 'valid',
502
- touched, dirty: this.raw !== this.initialRaw, ...result };
503
- this.validationChange?.emit(this.validation);
504
- }
505
- /** Validate for submission. Caller submits only non-pending, non-error output. */
506
- async validate() {
507
- this.validationRun?.abort();
508
- const run = new AbortController();
509
- this.validationRun = run;
510
- this.validation = { ...this.validation, status: 'pending', output: undefined };
511
- this.validationChange.emit(this.validation);
512
- try {
513
- const result = await validateField({ raw: this.raw, value: this.selected, context: this.config.context, signal: run.signal }, this.config);
514
- if (this.required && !this.raw.trim())
515
- result.issues = [...result.issues, { message: 'A value is required.' }];
516
- else if (this.raw && this.selected === null && !this.config.allowFreeText && !this.config.allowCreate)
517
- result.issues = [...result.issues, { message: 'Choose a suggestion.' }];
518
- if (result.issues.some(issue => issue.severity !== 'warning'))
519
- result.output = undefined;
520
- if (!run.signal.aborted && this.alive)
521
- this.setValidation(result);
224
+ handleRequestClose(reason, trigger) {
225
+ if (reason === 'escape' || (reason === 'light-dismiss' && this.toggleOnClick)) {
226
+ this.pinned = false;
227
+ this.clearTimers();
228
+ if (!controlledState.isControlled(this.open))
229
+ this.internalOpen = false;
230
+ events.dispatchDetail(this.host, 'close', {
231
+ open: false,
232
+ reason,
233
+ trigger: trigger,
234
+ });
522
235
  }
523
- catch { /* Aborted work never becomes current field state. */ }
524
- return this.validation;
525
236
  }
526
- /** Focus the native editing input from a composed control. */
527
- async focusInput() { this.input?.focus(); }
528
237
  render() {
529
- const description = [this.helpOpen ? 'help-text' : '', this.validation.issues.length ? 'validation' : ''].filter(Boolean).join(' ') || undefined;
530
- const status = this.loading ? 'Loading suggestions…' : this.lookupError || (this.expanded ? `${this.rows.length} suggestions available.` : '');
531
- const groups = [...new Set(this.rows.map(row => row.group ?? ''))];
532
- return index.h(index.Host, { key: '1f00d9a83729d9c2147ced7e5006b928d1b5e51d', "data-size": this.size, "data-validation": this.validation.status, onFocusout: this.onFocusOut }, index.h("label", { key: '10353b147cc68ef1d67be0988849af1527fcf9ba', htmlFor: "input", part: "label", class: this.labelVisibility === 'sr-only' ? 'sr-only' : undefined }, this.label, this.required ? ' *' : ''), index.h("div", { key: '74bb53137d9343add37c22f3ac503eccf41807a9', class: "field", part: "field", ref: element => this.field = element, onClick: event => {
533
- if (!event.composedPath().some(node => node instanceof HTMLButtonElement))
534
- this.input?.focus();
535
- } }, index.h("slot", { key: '24c26916365013faa4a78bd4fe0d01f6c129c703', name: "start" }), index.h("input", { key: '835d19e66ec4a24c1a83f43bbc256fa2a9e3332f', 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: '326c1e24d3c417c3a72acd8234a53937b388ba79', 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: '6aeb62dc2935eb95670caa1d2028c0931dc362b2', id: "help", type: "button", part: "affordance", "aria-label": `Help for ${this.label}`, disabled: this.disabled }, index.h("span", { key: '9317be0fbb0c1bbb91061be69f38037a97a4c36b', "aria-hidden": "true" }, "?")), this.disclosure && index.h("button", { key: '1cd2a0ea92df1144ff2297fcf64df7b3d0f4713a', type: "button", part: "affordance", "aria-label": `Suggestions for ${this.label}`, "aria-controls": "listbox", "aria-expanded": String(this.expanded), disabled: this.disabled || this.readOnly, onClick: () => {
536
- if (this.expanded)
537
- this.close();
538
- else
539
- this.open('disclosure');
540
- this.input?.focus();
541
- } }, index.h("span", { key: '0188b2d0e8cc7b7ff4d1a2175a0ff0b47d9c7d98', "aria-hidden": "true" }, "\u2304"))), this.help && index.h("ui-tooltip", { key: 'e09fd35274c3e1fa6e408850d72f7a07c2bb4baf', id: "help-text", for: "help", toggleOnClick: true, onOpen: () => this.helpOpen = true, onClose: () => this.helpOpen = false }, this.help), index.h("div", { key: 'ddf83a5944dd03fc7eb580b81fcf291e06c03601', class: "popup", part: "popup", hidden: !this.expanded, ref: element => this.popup = element }, index.h("div", { key: '1d73de1dabb6eaa95af12f2af88dac74e3f163ea', 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: 'a0aaafa2f4ff79efa954ed780f3a7bd81d4b2ecd', 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: '53a6706fc2c26097948b08cf0a7ee6040e37fe57', name: "create" }, "Create \u201C", this.raw, "\u201D"))), this.loading ? index.h("div", { class: "message" }, index.h("slot", { name: "loading" }, "Loading suggestions\u2026"))
542
- : this.lookupError ? index.h("div", { class: "message" }, index.h("slot", { name: "error" }, this.lookupError))
543
- : !this.rows.length && !this.canCreate ? index.h("div", { class: "message" }, index.h("slot", { name: "empty" }, "No suggestions.")) : null, index.h("slot", { key: '7997a0233a3c1a560b820c846645405ec4ceec1d', name: "footer" })), index.h("div", { key: '9143eb79141f5f3660a63f7a2471d1eecd8e9332', 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: '21f310613b058f528f8c4df329864fd8a2a94b55', 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(' ')));
238
+ return (index.h(index.Host, { key: 'fd4d81febd147b846aca66e94f25d56f14b171dc', role: "tooltip", hidden: !this.internalOpen, "data-open": this.internalOpen ? '' : undefined }, index.h("div", { key: 'd31ac8c0e087becd7e60459f2cd894a9b15e95fa', class: "tooltip__surface" }, index.h("slot", { key: '06e7aac9b6992a9cf0f92c9d356b97d18fb2da8b' }))));
544
239
  }
545
240
  static get watchers() { return {
546
- "value": [{
547
- "syncValue": 0
548
- }],
549
- "query": [{
550
- "syncQuery": 0
241
+ "open": [{
242
+ "syncFromProp": 0
551
243
  }],
552
- "disabled": [{
553
- "syncDisabled": 0
244
+ "for": [{
245
+ "resetSurface": 0
554
246
  }],
555
- "readOnly": [{
556
- "syncDisabled": 0
247
+ "placement": [{
248
+ "resetSurface": 0
557
249
  }],
558
- "config": [{
559
- "syncConfig": 0
250
+ "internalOpen": [{
251
+ "syncOverlay": 0
560
252
  }]
561
253
  }; }
562
254
  };
563
- UICombobox.style = uiComboboxCss();
255
+ UITooltip.style = uiTooltipCss();
564
256
 
565
257
  exports.ui_chip = UIChip;
566
- exports.ui_combobox = UICombobox;
258
+ exports.ui_tooltip = UITooltip;