@threadlabs/looma 0.1.28 → 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 (197) hide show
  1. package/dist/{chunk-G5AWV77V.js → chunk-JXSHRMYW.js} +32 -33
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/looma.cjs.js +1 -1
  4. package/dist/cjs/ui-chip_2.cjs.entry.js +190 -498
  5. package/dist/cjs/ui-combobox.cjs.entry.js +708 -0
  6. package/dist/cjs/ui-context-menu.cjs.entry.js +1 -1
  7. package/dist/cjs/ui-dialog.cjs.entry.js +1 -1
  8. package/dist/cjs/ui-disclosure.cjs.entry.js +1 -1
  9. package/dist/cjs/ui-editable.cjs.entry.js +3 -3
  10. package/dist/cjs/ui-floating-action-button.cjs.entry.js +1 -1
  11. package/dist/cjs/ui-form-field.cjs.entry.js +1 -1
  12. package/dist/cjs/ui-icon-button.cjs.entry.js +1 -1
  13. package/dist/cjs/ui-input.cjs.entry.js +1 -1
  14. package/dist/cjs/ui-menu-item.cjs.entry.js +1 -1
  15. package/dist/cjs/ui-menu.cjs.entry.js +1 -1
  16. package/dist/cjs/ui-popover.cjs.entry.js +1 -1
  17. package/dist/cjs/ui-radio-group.cjs.entry.js +1 -1
  18. package/dist/cjs/ui-radio.cjs.entry.js +1 -1
  19. package/dist/cjs/ui-search-result-row.cjs.entry.js +1 -1
  20. package/dist/cjs/ui-search-shell.cjs.entry.js +1 -1
  21. package/dist/cjs/ui-select.cjs.entry.js +1 -1
  22. package/dist/cjs/ui-switch.cjs.entry.js +2 -2
  23. package/dist/cjs/ui-tabs.cjs.entry.js +1 -1
  24. package/dist/cjs/ui-textarea.cjs.entry.js +1 -1
  25. package/dist/cjs/ui-toast-region.cjs.entry.js +1 -1
  26. package/dist/cjs/ui-top-bar.cjs.entry.js +1 -1
  27. package/dist/cjs/ui-tree-item.cjs.entry.js +2 -2
  28. package/dist/cjs/ui-tree.cjs.entry.js +1 -1
  29. package/dist/collection/collection-manifest.json +0 -1
  30. package/dist/collection/components/ui-combobox/ui-combobox.css +23 -0
  31. package/dist/collection/components/ui-combobox/ui-combobox.js +298 -21
  32. package/dist/collection/components/ui-context-menu/ui-context-menu.js +1 -1
  33. package/dist/collection/components/ui-dialog/ui-dialog.js +1 -1
  34. package/dist/collection/components/ui-disclosure/ui-disclosure.js +1 -1
  35. package/dist/collection/components/ui-editable/ui-editable.js +3 -3
  36. package/dist/collection/components/ui-floating-action-button/ui-floating-action-button.js +1 -1
  37. package/dist/collection/components/ui-form-field/ui-form-field.js +1 -1
  38. package/dist/collection/components/ui-icon-button/ui-icon-button.js +1 -1
  39. package/dist/collection/components/ui-input/ui-input.js +1 -1
  40. package/dist/collection/components/ui-menu/ui-menu.js +1 -1
  41. package/dist/collection/components/ui-menu-item/ui-menu-item.js +1 -1
  42. package/dist/collection/components/ui-popover/ui-popover.js +1 -1
  43. package/dist/collection/components/ui-radio/ui-radio.js +1 -1
  44. package/dist/collection/components/ui-radio-group/ui-radio-group.js +1 -1
  45. package/dist/collection/components/ui-search-result-row/ui-search-result-row.js +1 -1
  46. package/dist/collection/components/ui-search-shell/ui-search-shell.js +1 -1
  47. package/dist/collection/components/ui-select/ui-select.js +1 -1
  48. package/dist/collection/components/ui-switch/ui-switch.js +2 -2
  49. package/dist/collection/components/ui-tabs/ui-tabs.js +1 -1
  50. package/dist/collection/components/ui-textarea/ui-textarea.js +1 -1
  51. package/dist/collection/components/ui-toast-region/ui-toast-region.js +1 -1
  52. package/dist/collection/components/ui-tooltip/ui-tooltip.js +1 -1
  53. package/dist/collection/components/ui-top-bar/ui-top-bar.js +1 -1
  54. package/dist/collection/components/ui-tree/ui-tree.js +1 -1
  55. package/dist/collection/components/ui-tree-item/ui-tree-item.js +2 -2
  56. package/dist/components/index.d.ts +0 -2
  57. package/dist/components/index.js +1 -1
  58. package/dist/components/{p-B1macZOS.js → p-DWN2m6ta.js} +1 -1
  59. package/dist/components/p-DYiNETk6.js +1 -0
  60. package/dist/components/ui-combobox.js +1 -1
  61. package/dist/components/ui-context-menu.js +1 -1
  62. package/dist/components/ui-dialog.js +1 -1
  63. package/dist/components/ui-disclosure.js +1 -1
  64. package/dist/components/ui-editable.js +1 -1
  65. package/dist/components/ui-floating-action-button.js +1 -1
  66. package/dist/components/ui-form-field.js +1 -1
  67. package/dist/components/ui-icon-button.js +1 -1
  68. package/dist/components/ui-input.js +1 -1
  69. package/dist/components/ui-menu-item.js +1 -1
  70. package/dist/components/ui-menu.js +1 -1
  71. package/dist/components/ui-popover.js +1 -1
  72. package/dist/components/ui-radio-group.js +1 -1
  73. package/dist/components/ui-radio.js +1 -1
  74. package/dist/components/ui-search-result-row.js +1 -1
  75. package/dist/components/ui-search-shell.js +1 -1
  76. package/dist/components/ui-select.js +1 -1
  77. package/dist/components/ui-switch.js +1 -1
  78. package/dist/components/ui-tabs.js +1 -1
  79. package/dist/components/ui-textarea.js +1 -1
  80. package/dist/components/ui-toast-region.js +1 -1
  81. package/dist/components/ui-tooltip.js +1 -1
  82. package/dist/components/ui-top-bar.js +1 -1
  83. package/dist/components/ui-tree-item.js +1 -1
  84. package/dist/components/ui-tree.js +1 -1
  85. package/dist/esm/loader.js +1 -1
  86. package/dist/esm/looma.js +1 -1
  87. package/dist/esm/ui-chip_2.entry.js +192 -500
  88. package/dist/esm/ui-combobox.entry.js +706 -0
  89. package/dist/esm/ui-context-menu.entry.js +1 -1
  90. package/dist/esm/ui-dialog.entry.js +1 -1
  91. package/dist/esm/ui-disclosure.entry.js +1 -1
  92. package/dist/esm/ui-editable.entry.js +3 -3
  93. package/dist/esm/ui-floating-action-button.entry.js +1 -1
  94. package/dist/esm/ui-form-field.entry.js +1 -1
  95. package/dist/esm/ui-icon-button.entry.js +1 -1
  96. package/dist/esm/ui-input.entry.js +1 -1
  97. package/dist/esm/ui-menu-item.entry.js +1 -1
  98. package/dist/esm/ui-menu.entry.js +1 -1
  99. package/dist/esm/ui-popover.entry.js +1 -1
  100. package/dist/esm/ui-radio-group.entry.js +1 -1
  101. package/dist/esm/ui-radio.entry.js +1 -1
  102. package/dist/esm/ui-search-result-row.entry.js +1 -1
  103. package/dist/esm/ui-search-shell.entry.js +1 -1
  104. package/dist/esm/ui-select.entry.js +1 -1
  105. package/dist/esm/ui-switch.entry.js +2 -2
  106. package/dist/esm/ui-tabs.entry.js +1 -1
  107. package/dist/esm/ui-textarea.entry.js +1 -1
  108. package/dist/esm/ui-toast-region.entry.js +1 -1
  109. package/dist/esm/ui-top-bar.entry.js +1 -1
  110. package/dist/esm/ui-tree-item.entry.js +2 -2
  111. package/dist/esm/ui-tree.entry.js +1 -1
  112. package/dist/index.cjs +471 -514
  113. package/dist/index.js +2 -2
  114. package/dist/looma/looma.esm.js +1 -1
  115. package/dist/looma/{p-9a82c523.entry.js → p-1249a806.entry.js} +1 -1
  116. package/dist/looma/p-1c00670f.entry.js +1 -0
  117. package/dist/looma/p-22842f8c.entry.js +1 -0
  118. package/dist/looma/{p-1e1de77f.entry.js → p-2915d5c0.entry.js} +1 -1
  119. package/dist/looma/{p-88e61cab.entry.js → p-37ec2b4b.entry.js} +1 -1
  120. package/dist/looma/{p-2f3c1b57.entry.js → p-3b2961a6.entry.js} +1 -1
  121. package/dist/looma/{p-e07e6ac2.entry.js → p-3f60f4c8.entry.js} +1 -1
  122. package/dist/looma/{p-9551ebf6.entry.js → p-424d6719.entry.js} +1 -1
  123. package/dist/looma/{p-6cc3180b.entry.js → p-4caccfce.entry.js} +1 -1
  124. package/dist/looma/p-55e06e2e.entry.js +1 -0
  125. package/dist/looma/{p-3957f7ef.entry.js → p-56dac38a.entry.js} +1 -1
  126. package/dist/looma/p-5cbbf7a0.entry.js +1 -0
  127. package/dist/looma/{p-f431dc13.entry.js → p-6f20d470.entry.js} +1 -1
  128. package/dist/looma/{p-b68762f2.entry.js → p-7c0b5364.entry.js} +1 -1
  129. package/dist/looma/{p-e82f104c.entry.js → p-8bdd9495.entry.js} +1 -1
  130. package/dist/looma/{p-df696cca.entry.js → p-9cfbf722.entry.js} +1 -1
  131. package/dist/looma/{p-607c3056.entry.js → p-b6ede6bb.entry.js} +1 -1
  132. package/dist/looma/p-b6fb6ba3.entry.js +1 -0
  133. package/dist/looma/{p-da6e2d01.entry.js → p-b76e2111.entry.js} +1 -1
  134. package/dist/looma/{p-1a12eb5c.entry.js → p-d372b0db.entry.js} +1 -1
  135. package/dist/looma/p-d46317e0.entry.js +1 -0
  136. package/dist/looma/{p-20387ffa.entry.js → p-d4825822.entry.js} +1 -1
  137. package/dist/looma/{p-8a5e3fe1.entry.js → p-d5c3954f.entry.js} +1 -1
  138. package/dist/looma/{p-4f68f939.entry.js → p-e604e906.entry.js} +1 -1
  139. package/dist/looma/{p-e406656e.entry.js → p-f1f7c5cb.entry.js} +1 -1
  140. package/dist/types/components/ui-combobox/ui-combobox.d.ts +35 -4
  141. package/dist/types/components.d.ts +56 -153
  142. package/dist/{ui-affordance-scope.entry-X5526PRP.js → ui-affordance-scope.entry-VR7FLAWG.js} +1 -1
  143. package/dist/{ui-avatar-group.entry-U72MPB5K.js → ui-avatar-group.entry-L3UKOY3U.js} +1 -1
  144. package/dist/{ui-avatar.entry-OC4J3LTV.js → ui-avatar.entry-VM5OHEFQ.js} +1 -1
  145. package/dist/{ui-badge.entry-4MSUQRQV.js → ui-badge.entry-ZTM4OPUD.js} +1 -1
  146. package/dist/{ui-button.entry-22DESWN4.js → ui-button.entry-CIPUSV5B.js} +1 -1
  147. package/dist/{ui-callout.entry-LOGODDM5.js → ui-callout.entry-OBFCI2O7.js} +1 -1
  148. package/dist/{ui-checkbox.entry-XAGW3BW4.js → ui-checkbox.entry-XT6ET56H.js} +1 -1
  149. package/dist/{ui-tooltip.entry-AQ6UPBUP.js → ui-chip_2.entry-32SHCLV6.js} +18 -3
  150. package/dist/{ui-chip_2.entry-JCPHPXAG.js → ui-combobox.entry-ONBBPQ2C.js} +169 -30
  151. package/dist/{ui-context-menu.entry-24YOHF7L.js → ui-context-menu.entry-RXNUOK24.js} +2 -2
  152. package/dist/{ui-dialog.entry-XKNYDWOQ.js → ui-dialog.entry-IJXNUARC.js} +2 -2
  153. package/dist/{ui-disclosure.entry-2AWCGZ4C.js → ui-disclosure.entry-5QS7UDRH.js} +2 -2
  154. package/dist/{ui-editable.entry-HLEWO7BN.js → ui-editable.entry-D7LOQN2H.js} +3 -3
  155. package/dist/{ui-floating-action-button.entry-2NJDB4YN.js → ui-floating-action-button.entry-XQZCTZQT.js} +2 -2
  156. package/dist/{ui-form-field.entry-FJ5HYCTN.js → ui-form-field.entry-A654LJZE.js} +2 -2
  157. package/dist/{ui-icon-button.entry-YZHJQ5YR.js → ui-icon-button.entry-MJ7F7ZIH.js} +2 -2
  158. package/dist/{ui-input.entry-JMBLMNP6.js → ui-input.entry-B2XM7JQU.js} +2 -2
  159. package/dist/{ui-menu-item.entry-VBGXM66D.js → ui-menu-item.entry-JULYSFVW.js} +2 -2
  160. package/dist/{ui-menu.entry-I2N5H3YC.js → ui-menu.entry-ORRWW7HD.js} +2 -2
  161. package/dist/{ui-popover.entry-7JRSJM5S.js → ui-popover.entry-W67V4UPA.js} +2 -2
  162. package/dist/{ui-radio-group.entry-Q2XB7P3B.js → ui-radio-group.entry-KCFOR27M.js} +2 -2
  163. package/dist/{ui-radio.entry-NJO4NA4M.js → ui-radio.entry-I2P4V5E3.js} +2 -2
  164. package/dist/{ui-search-result-row.entry-RPMNDSRN.js → ui-search-result-row.entry-GHODLSLR.js} +2 -2
  165. package/dist/{ui-search-shell.entry-FMIMYD3B.js → ui-search-shell.entry-PDB5UN4B.js} +2 -2
  166. package/dist/{ui-select.entry-7NDBWNAU.js → ui-select.entry-D3CZHCKB.js} +2 -2
  167. package/dist/{ui-switch.entry-YUCPIZE4.js → ui-switch.entry-WUDRL4H5.js} +3 -3
  168. package/dist/{ui-tabs.entry-FXZWV665.js → ui-tabs.entry-MW64GKIJ.js} +2 -2
  169. package/dist/{ui-textarea.entry-HHLQR5GG.js → ui-textarea.entry-VHRBYY6G.js} +2 -2
  170. package/dist/{ui-toast-region.entry-PIIBHNYA.js → ui-toast-region.entry-ET75RWYP.js} +2 -2
  171. package/dist/{ui-top-bar.entry-S2L7ZM4U.js → ui-top-bar.entry-QIYA3LD3.js} +2 -2
  172. package/dist/{ui-tree-item.entry-UID7IJPA.js → ui-tree-item.entry-BDB7VEUS.js} +3 -3
  173. package/dist/{ui-tree.entry-UMD3DNG5.js → ui-tree.entry-GSC7BPRN.js} +2 -2
  174. package/package.json +1 -1
  175. package/vue/{chunk-2DDIBSFD.js → chunk-ROMBQS2L.js} +32 -89
  176. package/vue/editor/index.js +1 -1
  177. package/vue/index.d.ts +30 -107
  178. package/vue/index.js +1 -3
  179. package/dist/cjs/ui-multi-combobox.cjs.entry.js +0 -190
  180. package/dist/cjs/ui-tooltip.cjs.entry.js +0 -241
  181. package/dist/collection/components/ui-multi-combobox/ui-multi-combobox.css +0 -33
  182. package/dist/collection/components/ui-multi-combobox/ui-multi-combobox.js +0 -553
  183. package/dist/components/p-DiyiodGX.js +0 -1
  184. package/dist/components/p-d5fk1vBI.js +0 -1
  185. package/dist/components/ui-multi-combobox.d.ts +0 -11
  186. package/dist/components/ui-multi-combobox.js +0 -1
  187. package/dist/esm/ui-multi-combobox.entry.js +0 -188
  188. package/dist/esm/ui-tooltip.entry.js +0 -239
  189. package/dist/looma/p-071c139c.entry.js +0 -1
  190. package/dist/looma/p-311e54d4.entry.js +0 -1
  191. package/dist/looma/p-4a10a875.entry.js +0 -1
  192. package/dist/looma/p-4fc9917f.entry.js +0 -1
  193. package/dist/looma/p-63a9159f.entry.js +0 -1
  194. package/dist/looma/p-82de1112.entry.js +0 -1
  195. package/dist/looma/p-caa37be2.entry.js +0 -1
  196. package/dist/types/components/ui-multi-combobox/ui-multi-combobox.d.ts +0 -51
  197. package/dist/ui-multi-combobox.entry-MEX7MU7P.js +0 -196
@@ -1,6 +1,8 @@
1
1
  import { r as registerInstance, h, H as Host, c as createEvent, g as getElement } from './index-8BGiMGQ0.js';
2
+ import { o as openOverlay, c as closeOverlay } from './manager-C-0syqXZ.js';
3
+ import { d as dispatchDetail } from './events-JwSoedEO.js';
4
+ import { i as isControlled, c as controlledOrDefault } from './controlled-state-BnGhGgTH.js';
2
5
  import { a as createAnchoredSurface } from './positioning-Drmwg-C1.js';
3
- import { c as closeOverlay, o as openOverlay } from './manager-C-0syqXZ.js';
4
6
 
5
7
  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%)}`;
6
8
 
@@ -18,546 +20,236 @@ const UIChip = class {
18
20
  };
19
21
  UIChip.style = uiChipCss();
20
22
 
21
- /** Formatting is additive: every original character must survive in order.
22
- * Normalization belongs to submitted output, never the visible editing buffer. */
23
- function formatEditingValue(raw, selection, format) {
24
- const unchanged = { display: raw, selection };
25
- if (!format)
26
- return unchanged;
27
- let result;
28
- try {
29
- result = format(raw, selection);
30
- }
31
- catch {
32
- return unchanged;
33
- }
34
- if (!result)
35
- return unchanged;
36
- const characters = Array.from(raw);
37
- let cursor = 0;
38
- for (const character of result.display)
39
- if (character === characters[cursor])
40
- cursor += 1;
41
- if (!Number.isInteger(result.selection.start) || !Number.isInteger(result.selection.end) || cursor !== characters.length || result.selection.start < 0 || result.selection.end < result.selection.start
42
- || result.selection.end > result.display.length)
43
- return unchanged;
44
- return result;
45
- }
46
- async function validateField(request, config) {
47
- let output = request.raw;
48
- let issues = [];
49
- const check = () => request.signal.throwIfAborted();
50
- try {
51
- check();
52
- if (config.parse)
53
- output = await config.parse(request.raw, request);
54
- check();
55
- if (config.schema) {
56
- const result = await config.schema['~standard'].validate(output);
57
- check();
58
- if (result.issues)
59
- issues = result.issues;
60
- else if ('value' in result)
61
- output = result.value;
62
- }
63
- if (!issues.some(issue => issue.severity !== 'warning')) {
64
- if (config.normalize)
65
- output = await config.normalize(output, request);
66
- check();
67
- if (config.validator) {
68
- const result = await config.validator(output, request);
69
- check();
70
- issues = [...issues, ...(result.issues ?? [])];
71
- if ('output' in result)
72
- output = result.output;
73
- }
74
- }
75
- }
76
- catch (error) {
77
- check();
78
- issues = [{ message: error instanceof Error ? error.message : 'Unable to validate this value.' }];
79
- }
80
- issues = [...issues, ...(config.issues ?? [])];
81
- return { output: issues.some(issue => issue.severity !== 'warning') ? undefined : output, issues };
82
- }
83
-
84
- 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}}`;
23
+ 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}}`;
85
24
 
86
- const UICombobox = class {
25
+ const UITooltip = class {
87
26
  constructor(hostRef) {
88
27
  registerInstance(this, hostRef);
89
- this.queryChange = createEvent(this, "query-change");
90
- this.valueChange = createEvent(this, "value-change");
91
- this.freeEntry = createEvent(this, "free-entry");
92
- this.createEntry = createEvent(this, "create-entry");
93
- this.dependencyInvalidate = createEvent(this, "dependency-invalidate");
94
- this.validationChange = createEvent(this, "validation-change");
95
- this.optionsChange = createEvent(this, "options-change");
28
+ this.opened = createEvent(this, "open");
29
+ this.closed = createEvent(this, "close");
96
30
  }
97
31
  get host() { return getElement(this); }
98
- /** Accessible visible label, associated with the native text input. */
99
- label = '';
100
- placeholder = '';
101
- name = '';
102
- /** Controlled canonical value. Undefined selects uncontrolled mode; null means no selection. */
103
- value;
104
- defaultValue;
105
- /** Controlled raw editing text; independent of canonical selection. */
106
- query;
107
- defaultQuery = '';
108
- /** Immutable configuration; replace the object/context when dependencies change. */
109
- config = {};
110
- disabled = false;
111
- readOnly = false;
112
- required = false;
113
- size = 'md';
114
- /** Keep the native label accessible while allowing compact composed controls. */
115
- labelVisibility = 'visible';
116
- disclosure = false;
117
- clearable = false;
118
- /** Optional description shown by the connected question-mark button. */
119
- help = '';
120
- queryChange;
121
- valueChange;
122
- freeEntry;
123
- createEntry;
124
- dependencyInvalidate;
125
- validationChange;
126
- /** Supplies the current result rows for framework-owned rich slots. */
127
- optionsChange;
128
- raw = '';
129
- display = '';
130
- selected = null;
131
- expanded = false;
132
- rows = [];
133
- active = -1;
134
- loading = false;
135
- helpOpen = false;
136
- lookupError = '';
137
- validation = { status: 'pristine', touched: false, dirty: false, issues: [] };
138
- input;
139
- popup;
140
- field;
141
- surface;
142
- lookup;
143
- validationRun;
144
- lookupTimer;
145
- composing = false;
146
- initialRaw = '';
147
- overlayId = `ui-combobox-${Math.random().toString(36).slice(2)}`;
148
- alive = false;
149
- fullSet = false;
150
- knownOptions = new Map();
151
- awaitingLabel = null;
152
- proposedChange;
153
- formattedRaw;
154
- formattedWith;
155
- componentWillLoad() {
156
- this.selected = this.value !== undefined ? this.value : this.defaultValue ?? null;
157
- this.raw = this.query ?? this.defaultQuery;
158
- if (this.query === undefined && !this.raw && this.selected !== null) {
159
- this.raw = this.config.options?.find(row => row.value === this.selected)?.label ?? this.selected;
32
+ for = '';
33
+ /** Controlled open state. Omit it to use defaultOpen and local interaction state. */
34
+ open;
35
+ defaultOpen = false;
36
+ placement = 'top-start';
37
+ /** Pointer hover intent delay in milliseconds. Keyboard focus is immediate. */
38
+ showDelay = 500;
39
+ /** Pointer leave grace period in milliseconds. */
40
+ hideDelay = 100;
41
+ /** Click or tap pins the description; activate again to dismiss. */
42
+ toggleOnClick = false;
43
+ pinned = false;
44
+ focused = false;
45
+ opened;
46
+ closed;
47
+ internalOpen = false;
48
+ overlayId = `ui-tooltip-${Math.random().toString(36).slice(2, 11)}`;
49
+ trigger = null;
50
+ surface = null;
51
+ showTimer = null;
52
+ hideTimer = null;
53
+ syncFromProp() {
54
+ this.clearTimers();
55
+ if (isControlled(this.open))
56
+ this.internalOpen = this.open;
57
+ }
58
+ resetSurface() {
59
+ this.syncTrigger();
60
+ this.setupSurface();
61
+ this.syncOverlay();
62
+ }
63
+ syncOverlay() {
64
+ if (this.internalOpen) {
65
+ this.surface?.show();
66
+ openOverlay({
67
+ id: this.overlayId,
68
+ modal: false,
69
+ element: this.host,
70
+ relatedElements: this.trigger ? [this.trigger] : undefined,
71
+ dismissible: true,
72
+ requestClose: (reason, trigger) => this.handleRequestClose(reason, trigger),
73
+ });
74
+ }
75
+ else {
76
+ this.surface?.hide();
77
+ closeOverlay(this.overlayId);
160
78
  }
161
- if (this.query === undefined && this.selected !== null && this.raw === this.selected)
162
- this.awaitingLabel = this.selected;
163
- this.display = this.raw;
164
- this.initialRaw = this.raw;
165
- this.applyServerIssues();
166
79
  }
167
- connectedCallback() { this.alive = true; this.setupSurface(); }
168
- componentDidLoad() { this.setupSurface(); }
80
+ componentDidLoad() {
81
+ if (!this.host.id)
82
+ this.host.id = this.overlayId;
83
+ this.internalOpen = controlledOrDefault(this.open, this.defaultOpen);
84
+ this.syncTrigger();
85
+ this.setupSurface();
86
+ this.host.addEventListener('pointerenter', this.onSurfaceEnter);
87
+ this.host.addEventListener('pointerleave', this.onTriggerLeave);
88
+ this.syncOverlay();
89
+ }
169
90
  componentDidUpdate() {
170
- if (this.input && !this.composing && this.input.value !== this.display)
171
- this.input.value = this.display;
172
- if (this.expanded)
173
- this.surface?.refresh();
91
+ this.syncTrigger();
174
92
  }
175
93
  disconnectedCallback() {
176
- this.alive = false;
177
- this.close();
178
- this.validationRun?.abort();
94
+ this.clearTimers();
95
+ this.detachTriggerListeners();
179
96
  this.surface?.destroy();
180
- this.surface = undefined;
97
+ this.surface = null;
98
+ this.host.removeEventListener('pointerenter', this.onSurfaceEnter);
99
+ this.host.removeEventListener('pointerleave', this.onTriggerLeave);
100
+ closeOverlay(this.overlayId);
101
+ }
102
+ syncTrigger() {
103
+ const next = this.for
104
+ ? this.host.getRootNode().getElementById(this.for)
105
+ : this.host.previousElementSibling;
106
+ if (next === this.trigger)
107
+ return;
108
+ this.detachTriggerListeners();
109
+ this.trigger = next;
110
+ this.attachTriggerListeners();
111
+ this.surface?.setAnchor(next);
181
112
  }
182
113
  setupSurface() {
183
- if (!this.surface && this.popup && this.field)
184
- this.surface = createAnchoredSurface(this.popup, { anchor: this.field, placement: 'bottom-start' });
114
+ this.surface?.destroy();
115
+ this.surface = createAnchoredSurface(this.host, {
116
+ anchor: this.trigger,
117
+ placement: this.placement,
118
+ });
185
119
  }
186
- syncValue() {
187
- if (this.value === undefined)
120
+ attachTriggerListeners() {
121
+ this.detachTriggerListeners();
122
+ if (!this.trigger)
188
123
  return;
189
- this.selected = this.value;
190
- if (this.query === undefined) {
191
- const proposal = this.proposedChange;
192
- const option = this.config.options?.find(row => row.value === this.selected)
193
- ?? (this.selected === null ? undefined : this.knownOptions.get(this.selected));
194
- const nextRaw = proposal?.value === this.selected ? proposal.query : option?.label ?? this.selected ?? '';
195
- if (proposal?.value !== this.selected || nextRaw !== this.raw) {
196
- this.raw = nextRaw;
197
- this.display = this.raw;
198
- this.formattedRaw = undefined;
199
- }
200
- this.awaitingLabel = !option && this.selected !== null ? this.selected : null;
201
- }
202
- this.resetValidation();
203
- }
204
- syncQuery() {
205
- if (this.query === undefined || this.query === this.raw)
124
+ const ids = new Set((this.trigger.getAttribute('aria-describedby') || '').split(/\s+/).filter(Boolean));
125
+ ids.add(this.host.id);
126
+ this.trigger.setAttribute('aria-describedby', [...ids].join(' '));
127
+ this.trigger.addEventListener('click', this.onTriggerClick);
128
+ this.trigger.addEventListener('keydown', this.onTriggerKeydown);
129
+ this.trigger.addEventListener('pointerenter', this.onTriggerEnter);
130
+ this.trigger.addEventListener('pointerleave', this.onTriggerLeave);
131
+ this.trigger.addEventListener('focusin', this.onTriggerFocusIn);
132
+ this.trigger.addEventListener('focusout', this.onTriggerFocusOut);
133
+ }
134
+ detachTriggerListeners() {
135
+ if (!this.trigger)
206
136
  return;
207
- // Only a selection proposal's query echo retains an uncontrolled identity.
208
- // Other owner text replacements are edits, just like native input.
209
- if (this.value === undefined && this.proposedChange?.query !== this.query)
210
- this.selected = null;
211
- this.awaitingLabel = null;
212
- this.formattedRaw = undefined;
213
- this.raw = this.query;
214
- this.display = this.raw;
215
- this.resetValidation();
216
- if (this.expanded)
217
- this.search('input');
218
- }
219
- syncDisabled() {
220
- if (this.disabled || this.readOnly) {
221
- this.close();
222
- this.resetValidation();
223
- }
224
- }
225
- syncConfig(next, previous) {
226
- this.validationRun?.abort();
227
- if (next.provider !== previous?.provider || next.context !== previous?.context)
228
- this.knownOptions.clear();
229
- if (next.context !== previous?.context) {
230
- this.close();
231
- const policy = next.invalidation ?? 'retain-query';
232
- const value = policy === 'retain' ? this.selected : null;
233
- const query = policy === 'clear' ? '' : this.raw;
234
- this.commit(value, query, null, 'invalidation', 'programmatic');
235
- this.validation = { status: 'pristine', touched: false, dirty: this.raw !== this.initialRaw, issues: [] };
236
- }
237
- this.applyServerIssues();
238
- if (this.expanded)
239
- this.search('context');
240
- }
241
- applyServerIssues() {
242
- const issues = this.config.issues ?? [];
243
- if (issues.length)
244
- this.setValidation({ issues }, this.validation.touched);
137
+ const ids = (this.trigger.getAttribute('aria-describedby') || '').split(/\s+/).filter(id => id && id !== this.host.id);
138
+ if (ids.length)
139
+ this.trigger.setAttribute('aria-describedby', ids.join(' '));
245
140
  else
246
- this.resetValidation();
247
- }
248
- resetValidation() {
249
- this.validationRun?.abort();
250
- this.validation = { status: 'pristine', touched: this.validation.touched, dirty: this.raw !== this.initialRaw, issues: [] };
251
- this.validationChange?.emit(this.validation);
252
- }
253
- cancelLookup() {
254
- clearTimeout(this.lookupTimer);
255
- this.lookup?.abort();
256
- this.lookup = undefined;
257
- this.loading = false;
258
- }
259
- close() {
260
- this.expanded = false;
261
- this.active = -1;
262
- this.cancelLookup();
263
- this.surface?.hide();
264
- closeOverlay(this.overlayId);
265
- }
266
- open(reason = 'input') {
267
- if (this.disabled || this.readOnly)
141
+ this.trigger.removeAttribute('aria-describedby');
142
+ this.trigger.removeEventListener('click', this.onTriggerClick);
143
+ this.trigger.removeEventListener('keydown', this.onTriggerKeydown);
144
+ this.trigger.removeEventListener('pointerenter', this.onTriggerEnter);
145
+ this.trigger.removeEventListener('pointerleave', this.onTriggerLeave);
146
+ this.trigger.removeEventListener('focusin', this.onTriggerFocusIn);
147
+ this.trigger.removeEventListener('focusout', this.onTriggerFocusOut);
148
+ }
149
+ clearShowTimer() {
150
+ if (this.showTimer === null)
268
151
  return;
269
- this.expanded = true;
270
- if (this.popup && this.field)
271
- this.popup.style.minWidth = `${this.field.getBoundingClientRect().width}px`;
272
- this.surface?.show();
273
- openOverlay({ id: this.overlayId, element: this.popup, relatedElements: [this.host], modal: false,
274
- requestClose: () => this.close() });
275
- this.search(reason);
152
+ clearTimeout(this.showTimer);
153
+ this.showTimer = null;
276
154
  }
277
- search(reason) {
278
- this.cancelLookup();
279
- this.fullSet = reason === 'disclosure';
280
- this.active = -1;
281
- this.lookupError = '';
282
- const config = this.config;
283
- const query = this.fullSet ? '' : this.raw;
284
- const controller = new AbortController();
285
- this.lookup = controller;
286
- const apply = (options) => {
287
- if (controller.signal.aborted || !this.alive)
288
- return;
289
- for (const option of options)
290
- this.knownOptions.set(option.value, option);
291
- const selectedOption = this.selected === null ? undefined : this.knownOptions.get(this.selected);
292
- if (this.query === undefined && this.awaitingLabel === this.selected && selectedOption) {
293
- this.raw = selectedOption.label;
294
- this.display = this.raw;
295
- this.awaitingLabel = null;
296
- this.formattedRaw = undefined;
297
- this.resetValidation();
298
- }
299
- const ids = new Set();
300
- this.rows = options.filter(option => {
301
- if (ids.has(option.id))
302
- return false;
303
- ids.add(option.id);
304
- return this.fullSet || (config.filter ? config.filter(option, query, config.context)
305
- : config.provider ? true : option.label.toLocaleLowerCase().includes(query.toLocaleLowerCase()));
306
- });
307
- const groups = new Map();
308
- for (const row of this.rows) {
309
- const group = row.group ?? '';
310
- if (!groups.has(group))
311
- groups.set(group, []);
312
- groups.get(group).push(row);
313
- }
314
- this.rows = [...groups.values()].flat();
315
- this.loading = false;
316
- this.optionsChange.emit(this.rows);
317
- };
318
- if (!config.provider) {
319
- apply(config.options ?? []);
155
+ clearHideTimer() {
156
+ if (this.hideTimer === null)
320
157
  return;
321
- }
322
- this.rows = [];
323
- this.loading = true;
324
- this.lookupTimer = setTimeout(async () => {
325
- try {
326
- apply(await config.provider({ query, context: config.context, signal: controller.signal, reason }));
327
- }
328
- catch (error) {
329
- if (controller.signal.aborted || !this.alive)
330
- return;
331
- this.loading = false;
332
- this.lookupError = error instanceof Error ? error.message : 'Unable to load suggestions.';
333
- }
334
- }, reason === 'disclosure' ? 0 : Math.max(0, config.debounce ?? 200));
158
+ clearTimeout(this.hideTimer);
159
+ this.hideTimer = null;
335
160
  }
336
- get canCreate() {
337
- const candidates = this.config.options ? [...this.config.options, ...this.rows] : this.rows;
338
- return Boolean(this.config.allowCreate && this.raw.trim() && !this.loading && !this.lookupError
339
- && !candidates.some(row => row.label.toLocaleLowerCase() === this.raw.toLocaleLowerCase()));
161
+ clearTimers() {
162
+ this.clearShowTimer();
163
+ this.clearHideTimer();
340
164
  }
341
- format(timing) {
342
- if ((this.config.formatOn ?? 'blur') !== timing || !this.input)
165
+ setInteractionOpen(nextOpen, trigger) {
166
+ if (this.internalOpen === nextOpen)
343
167
  return;
344
- // Selection is now in display coordinates; do not map it as raw a second time.
345
- if (this.formattedRaw === this.raw && this.formattedWith === this.config.format)
346
- return;
347
- const result = formatEditingValue(this.raw, {
348
- start: this.input.selectionStart ?? this.raw.length, end: this.input.selectionEnd ?? this.raw.length,
349
- direction: this.input.selectionDirection ?? 'none',
350
- }, this.config.format);
351
- this.formattedRaw = this.raw;
352
- this.formattedWith = this.config.format;
353
- this.display = result.display;
354
- if (this.input.value !== result.display) {
355
- this.input.value = result.display;
356
- this.input.setSelectionRange(result.selection.start, result.selection.end, result.selection.direction);
357
- }
358
- }
359
- onInput = (event) => {
360
- // Composition updates remain entirely native until compositionend.
361
- if (this.composing || event.isComposing)
362
- return;
363
- this.awaitingLabel = null;
364
- this.formattedRaw = undefined;
365
- this.raw = this.input.value;
366
- this.display = this.raw;
367
- this.resetValidation();
368
- this.format('input');
369
- this.queryChange.emit({ query: this.raw, display: this.display, trigger: 'keyboard' });
370
- if (this.selected !== null)
371
- this.commit(null, this.raw, null, 'clear', 'keyboard');
372
- this.open();
373
- if (this.config.validateOn === 'input')
374
- void this.validate();
375
- queueMicrotask(() => {
376
- if (this.query !== undefined && this.query !== this.raw)
377
- this.syncQuery();
378
- });
379
- };
380
- commit(value, query, option, kind, trigger) {
381
- this.awaitingLabel = null;
382
- const queryChanged = query !== this.raw;
383
- if (this.value === undefined)
384
- this.selected = value;
385
- if (this.query === undefined && queryChanged) {
386
- this.raw = query;
387
- this.display = query;
388
- this.formattedRaw = undefined;
389
- }
390
- this.resetValidation();
391
- const detail = { value, query, option, kind, trigger };
392
- const proposal = { value, query };
393
- this.proposedChange = proposal;
394
- this.valueChange.emit(detail);
395
- if (queryChanged)
396
- this.queryChange.emit({ query, display: query, trigger });
397
- if (kind === 'create')
398
- this.createEntry.emit(detail);
399
- if (kind === 'free-entry')
400
- this.freeEntry.emit(detail);
401
- if (kind === 'invalidation')
402
- this.dependencyInvalidate.emit(detail);
403
- // Settle after all owner notifications (including Vue's queued update).
404
- // A retained prop does not fire a Stencil watcher, so rejection must be
405
- // reconciled explicitly while the proposal still identifies an edit echo.
406
- queueMicrotask(() => {
407
- if (this.proposedChange !== proposal)
408
- return;
409
- if (this.value !== undefined && this.value !== proposal.value)
410
- this.syncValue();
411
- if (this.query !== undefined && this.query !== proposal.query) {
412
- if (this.value === undefined) {
413
- this.selected = null;
414
- this.resetValidation();
415
- }
416
- this.syncQuery();
417
- }
418
- this.proposedChange = undefined;
168
+ if (!isControlled(this.open))
169
+ this.internalOpen = nextOpen;
170
+ dispatchDetail(this.host, nextOpen ? 'open' : 'close', {
171
+ open: nextOpen,
172
+ reason: 'action',
173
+ trigger,
419
174
  });
420
175
  }
421
- choose(index, trigger) {
422
- const option = this.rows[index];
423
- if (option?.disabled)
424
- return;
425
- if (option)
426
- this.commit(option.value, option.label, option, 'selection', trigger);
427
- else if (this.canCreate && index === this.rows.length)
428
- this.commit(null, this.raw, null, 'create', trigger);
429
- else
176
+ onSurfaceEnter = () => this.clearHideTimer();
177
+ onTriggerClick = (event) => {
178
+ if (!this.toggleOnClick)
430
179
  return;
431
- this.close();
432
- this.input?.focus();
433
- if (this.config.validateOn !== 'submit')
434
- queueMicrotask(() => void this.validate());
435
- }
436
- move(key) {
437
- const indices = this.rows.flatMap((row, index) => row.disabled ? [] : [index]);
438
- if (this.canCreate)
439
- indices.push(this.rows.length);
440
- if (!indices.length)
441
- return;
442
- const current = indices.indexOf(this.active);
443
- const next = key === 'Home' ? 0 : key === 'End' ? indices.length - 1
444
- : key === 'ArrowDown' ? Math.min(current + 1, indices.length - 1)
445
- : current < 0 ? indices.length - 1 : Math.max(0, current - 1);
446
- this.active = indices[next];
447
- requestAnimationFrame(() => this.host.shadowRoot?.getElementById(`option-${this.active}`)?.scrollIntoView({ block: 'nearest' }));
448
- }
449
- onKeydown = (event) => {
450
- if (this.composing || event.isComposing || this.disabled || this.readOnly)
451
- return;
452
- if (event.key === 'Escape' && this.expanded) {
453
- event.preventDefault();
454
- event.stopPropagation();
455
- this.close();
180
+ this.clearTimers();
181
+ this.pinned = !this.pinned;
182
+ this.setInteractionOpen(this.pinned, event.detail === 0 ? 'keyboard' : 'pointer');
183
+ };
184
+ onTriggerKeydown = (event) => {
185
+ if (event.key === 'Escape')
186
+ this.clearTimers();
187
+ };
188
+ onTriggerEnter = (event) => {
189
+ if (event.pointerType === 'touch')
456
190
  return;
457
- }
458
- if (event.key === 'Tab') {
459
- this.close();
191
+ this.clearHideTimer();
192
+ if (this.internalOpen || this.showTimer !== null)
460
193
  return;
461
- }
462
- if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
194
+ this.showTimer = setTimeout(() => {
195
+ this.showTimer = null;
196
+ this.setInteractionOpen(true, 'pointer');
197
+ }, Math.max(0, this.showDelay));
198
+ };
199
+ onTriggerLeave = () => {
200
+ this.clearShowTimer();
201
+ if (this.focused || this.pinned || !this.internalOpen || this.hideTimer !== null)
463
202
  return;
464
- if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
465
- event.preventDefault();
466
- if (!this.expanded)
467
- this.open('disclosure');
468
- this.move(event.key);
469
- }
470
- else if ((event.key === 'Home' || event.key === 'End') && this.expanded && this.active >= 0) {
471
- event.preventDefault();
472
- this.move(event.key);
473
- }
474
- else if (event.key === 'Enter' && this.expanded) {
475
- if (this.active >= 0) {
476
- event.preventDefault();
477
- this.choose(this.active, 'keyboard');
478
- }
479
- else if (this.config.allowFreeText) {
480
- event.preventDefault();
481
- this.commit(null, this.raw, null, 'free-entry', 'keyboard');
482
- this.close();
483
- }
484
- }
203
+ this.hideTimer = setTimeout(() => {
204
+ this.hideTimer = null;
205
+ this.setInteractionOpen(false, 'pointer');
206
+ }, Math.max(0, this.hideDelay));
207
+ };
208
+ onTriggerFocusIn = () => {
209
+ this.focused = true;
210
+ this.clearTimers();
211
+ this.setInteractionOpen(true, 'keyboard');
485
212
  };
486
- onFocusOut = (event) => {
487
- if (event.relatedTarget instanceof Node && this.host.shadowRoot?.contains(event.relatedTarget))
213
+ onTriggerFocusOut = (e) => {
214
+ const related = e.relatedTarget;
215
+ if (related && this.host.contains(related))
488
216
  return;
489
- this.close();
490
- this.format('blur');
491
- this.validation = { ...this.validation, touched: true };
492
- if (this.config.allowFreeText && this.selected === null)
493
- this.commit(null, this.raw, null, 'free-entry', 'keyboard');
494
- if ((this.config.validateOn ?? 'blur') === 'blur')
495
- void this.validate();
217
+ this.focused = false;
218
+ this.pinned = false;
219
+ this.clearTimers();
220
+ this.setInteractionOpen(false, 'keyboard');
496
221
  };
497
- setValidation(result, touched = this.validation.touched) {
498
- const blocking = result.issues.some(issue => issue.severity !== 'warning');
499
- this.validation = { status: blocking ? 'error' : result.issues.length ? 'warning' : 'valid',
500
- touched, dirty: this.raw !== this.initialRaw, ...result };
501
- this.validationChange?.emit(this.validation);
502
- }
503
- /** Validate for submission. Caller submits only non-pending, non-error output. */
504
- async validate() {
505
- this.validationRun?.abort();
506
- const run = new AbortController();
507
- this.validationRun = run;
508
- this.validation = { ...this.validation, status: 'pending', output: undefined };
509
- this.validationChange.emit(this.validation);
510
- try {
511
- const result = await validateField({ raw: this.raw, value: this.selected, context: this.config.context, signal: run.signal }, this.config);
512
- if (this.required && !this.raw.trim())
513
- result.issues = [...result.issues, { message: 'A value is required.' }];
514
- else if (this.raw && this.selected === null && !this.config.allowFreeText && !this.config.allowCreate)
515
- result.issues = [...result.issues, { message: 'Choose a suggestion.' }];
516
- if (result.issues.some(issue => issue.severity !== 'warning'))
517
- result.output = undefined;
518
- if (!run.signal.aborted && this.alive)
519
- this.setValidation(result);
222
+ handleRequestClose(reason, trigger) {
223
+ if (reason === 'escape' || (reason === 'light-dismiss' && this.toggleOnClick)) {
224
+ this.pinned = false;
225
+ this.clearTimers();
226
+ if (!isControlled(this.open))
227
+ this.internalOpen = false;
228
+ dispatchDetail(this.host, 'close', {
229
+ open: false,
230
+ reason,
231
+ trigger: trigger,
232
+ });
520
233
  }
521
- catch { /* Aborted work never becomes current field state. */ }
522
- return this.validation;
523
234
  }
524
- /** Focus the native editing input from a composed control. */
525
- async focusInput() { this.input?.focus(); }
526
235
  render() {
527
- const description = [this.helpOpen ? 'help-text' : '', this.validation.issues.length ? 'validation' : ''].filter(Boolean).join(' ') || undefined;
528
- const status = this.loading ? 'Loading suggestions…' : this.lookupError || (this.expanded ? `${this.rows.length} suggestions available.` : '');
529
- const groups = [...new Set(this.rows.map(row => row.group ?? ''))];
530
- return h(Host, { key: '1f00d9a83729d9c2147ced7e5006b928d1b5e51d', "data-size": this.size, "data-validation": this.validation.status, onFocusout: this.onFocusOut }, h("label", { key: '10353b147cc68ef1d67be0988849af1527fcf9ba', htmlFor: "input", part: "label", class: this.labelVisibility === 'sr-only' ? 'sr-only' : undefined }, this.label, this.required ? ' *' : ''), h("div", { key: '74bb53137d9343add37c22f3ac503eccf41807a9', class: "field", part: "field", ref: element => this.field = element, onClick: event => {
531
- if (!event.composedPath().some(node => node instanceof HTMLButtonElement))
532
- this.input?.focus();
533
- } }, h("slot", { key: '24c26916365013faa4a78bd4fe0d01f6c129c703', name: "start" }), 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 && 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 && h("button", { key: '6aeb62dc2935eb95670caa1d2028c0931dc362b2', id: "help", type: "button", part: "affordance", "aria-label": `Help for ${this.label}`, disabled: this.disabled }, h("span", { key: '9317be0fbb0c1bbb91061be69f38037a97a4c36b', "aria-hidden": "true" }, "?")), this.disclosure && 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: () => {
534
- if (this.expanded)
535
- this.close();
536
- else
537
- this.open('disclosure');
538
- this.input?.focus();
539
- } }, h("span", { key: '0188b2d0e8cc7b7ff4d1a2175a0ff0b47d9c7d98', "aria-hidden": "true" }, "\u2304"))), this.help && h("ui-tooltip", { key: 'e09fd35274c3e1fa6e408850d72f7a07c2bb4baf', id: "help-text", for: "help", toggleOnClick: true, onOpen: () => this.helpOpen = true, onClose: () => this.helpOpen = false }, this.help), h("div", { key: 'ddf83a5944dd03fc7eb580b81fcf291e06c03601', class: "popup", part: "popup", hidden: !this.expanded, ref: element => this.popup = element }, h("div", { key: '1d73de1dabb6eaa95af12f2af88dac74e3f163ea', id: "listbox", role: "listbox", "aria-label": `${this.label} suggestions`, "aria-busy": String(this.loading) }, groups.map(group => h("div", { role: group ? 'group' : 'presentation', "aria-label": group || undefined }, group && h("div", { class: "group", part: "group" }, group), this.rows.map((row, index) => (row.group ?? '') !== group ? null : h("div", { id: `option-${index}`, role: "option", "aria-selected": String(this.selected === row.value), "aria-disabled": String(Boolean(row.disabled)), "data-active": this.active === index ? '' : undefined, part: "option", class: "option", onPointerDown: event => event.preventDefault(), onClick: () => this.choose(index, 'pointer') }, h("slot", { name: `option-${row.id}` }, h("span", { class: "primary", part: "option-primary" }, row.label), row.description && h("span", { class: "secondary", part: "option-secondary" }, row.description)))))), this.canCreate && h("div", { key: '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') }, h("slot", { key: '53a6706fc2c26097948b08cf0a7ee6040e37fe57', name: "create" }, "Create \u201C", this.raw, "\u201D"))), this.loading ? h("div", { class: "message" }, h("slot", { name: "loading" }, "Loading suggestions\u2026"))
540
- : this.lookupError ? h("div", { class: "message" }, h("slot", { name: "error" }, this.lookupError))
541
- : !this.rows.length && !this.canCreate ? h("div", { class: "message" }, h("slot", { name: "empty" }, "No suggestions.")) : null, h("slot", { key: '7997a0233a3c1a560b820c846645405ec4ceec1d', name: "footer" })), h("div", { key: '9143eb79141f5f3660a63f7a2471d1eecd8e9332', id: "validation", class: "message", part: "validation", hidden: !this.validation.issues.length }, this.validation.issues.map(issue => h("div", null, issue.message))), 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(' ')));
236
+ return (h(Host, { key: 'fd4d81febd147b846aca66e94f25d56f14b171dc', role: "tooltip", hidden: !this.internalOpen, "data-open": this.internalOpen ? '' : undefined }, h("div", { key: 'd31ac8c0e087becd7e60459f2cd894a9b15e95fa', class: "tooltip__surface" }, h("slot", { key: '06e7aac9b6992a9cf0f92c9d356b97d18fb2da8b' }))));
542
237
  }
543
238
  static get watchers() { return {
544
- "value": [{
545
- "syncValue": 0
546
- }],
547
- "query": [{
548
- "syncQuery": 0
239
+ "open": [{
240
+ "syncFromProp": 0
549
241
  }],
550
- "disabled": [{
551
- "syncDisabled": 0
242
+ "for": [{
243
+ "resetSurface": 0
552
244
  }],
553
- "readOnly": [{
554
- "syncDisabled": 0
245
+ "placement": [{
246
+ "resetSurface": 0
555
247
  }],
556
- "config": [{
557
- "syncConfig": 0
248
+ "internalOpen": [{
249
+ "syncOverlay": 0
558
250
  }]
559
251
  }; }
560
252
  };
561
- UICombobox.style = uiComboboxCss();
253
+ UITooltip.style = uiTooltipCss();
562
254
 
563
- export { UIChip as ui_chip, UICombobox as ui_combobox };
255
+ export { UIChip as ui_chip, UITooltip as ui_tooltip };