@threadlabs/looma 0.2.0 → 0.2.2

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 (76) hide show
  1. package/dist/{chunk-JXSHRMYW.js → chunk-CSULYHMX.js} +32 -32
  2. package/dist/{chunk-M7FPK6GN.js → chunk-D5WRORG6.js} +21 -1
  3. package/dist/cjs/{positioning-D5q9DM-0.js → positioning-CCR6ifPj.js} +35 -0
  4. package/dist/cjs/ui-affordance-scope.cjs.entry.js +1 -1
  5. package/dist/cjs/ui-chip_2.cjs.entry.js +1 -1
  6. package/dist/cjs/ui-combobox.cjs.entry.js +1 -1
  7. package/dist/cjs/ui-context-menu.cjs.entry.js +1 -1
  8. package/dist/cjs/ui-menu.cjs.entry.js +1 -1
  9. package/dist/cjs/ui-popover.cjs.entry.js +1 -1
  10. package/dist/cjs/ui-toast-region.cjs.entry.js +1 -1
  11. package/dist/collection/overlay/positioning.js +35 -0
  12. package/dist/components/{p-DYiNETk6.js → p-6SWSrfmW.js} +1 -1
  13. package/dist/components/p-B_DaIVEY.js +1 -0
  14. package/dist/components/{p-DWN2m6ta.js → p-BzaB_bXo.js} +1 -1
  15. package/dist/components/ui-affordance-scope.js +1 -1
  16. package/dist/components/ui-combobox.js +1 -1
  17. package/dist/components/ui-context-menu.js +1 -1
  18. package/dist/components/ui-menu.js +1 -1
  19. package/dist/components/ui-popover.js +1 -1
  20. package/dist/components/ui-toast-region.js +1 -1
  21. package/dist/components/ui-tooltip.js +1 -1
  22. package/dist/esm/{positioning-Drmwg-C1.js → positioning-ZOr-2PSe.js} +35 -0
  23. package/dist/esm/ui-affordance-scope.entry.js +1 -1
  24. package/dist/esm/ui-chip_2.entry.js +1 -1
  25. package/dist/esm/ui-combobox.entry.js +1 -1
  26. package/dist/esm/ui-context-menu.entry.js +1 -1
  27. package/dist/esm/ui-menu.entry.js +1 -1
  28. package/dist/esm/ui-popover.entry.js +1 -1
  29. package/dist/esm/ui-toast-region.entry.js +1 -1
  30. package/dist/index.cjs +48 -10
  31. package/dist/index.js +19 -1
  32. package/dist/looma/looma.esm.js +1 -1
  33. package/dist/looma/{p-55e06e2e.entry.js → p-0b5b8d9e.entry.js} +1 -1
  34. package/dist/looma/{p-32c85198.entry.js → p-16e0669d.entry.js} +1 -1
  35. package/dist/looma/{p-37ec2b4b.entry.js → p-6d8b99ee.entry.js} +1 -1
  36. package/dist/looma/{p-b6fb6ba3.entry.js → p-99116a72.entry.js} +1 -1
  37. package/dist/looma/{p-5cbbf7a0.entry.js → p-9ff2fa19.entry.js} +1 -1
  38. package/dist/looma/p-ZOr-2PSe.js +1 -0
  39. package/dist/looma/{p-d46317e0.entry.js → p-a2dd4c6c.entry.js} +1 -1
  40. package/dist/looma/p-ca2a54fd.entry.js +1 -0
  41. package/dist/{ui-affordance-scope.entry-VR7FLAWG.js → ui-affordance-scope.entry-UHAPBKUL.js} +2 -2
  42. package/dist/{ui-avatar-group.entry-L3UKOY3U.js → ui-avatar-group.entry-5CW7NZXC.js} +1 -1
  43. package/dist/{ui-avatar.entry-VM5OHEFQ.js → ui-avatar.entry-6HZBNQ4Y.js} +1 -1
  44. package/dist/{ui-badge.entry-ZTM4OPUD.js → ui-badge.entry-SNSI6RIY.js} +1 -1
  45. package/dist/{ui-button.entry-CIPUSV5B.js → ui-button.entry-Z3T6L2OC.js} +1 -1
  46. package/dist/{ui-callout.entry-OBFCI2O7.js → ui-callout.entry-DLUGC27N.js} +1 -1
  47. package/dist/{ui-checkbox.entry-XT6ET56H.js → ui-checkbox.entry-3V3KTI2D.js} +1 -1
  48. package/dist/{ui-chip_2.entry-32SHCLV6.js → ui-chip_2.entry-YKN25ITS.js} +2 -2
  49. package/dist/{ui-combobox.entry-ONBBPQ2C.js → ui-combobox.entry-ZQ6MXY7Z.js} +2 -2
  50. package/dist/{ui-context-menu.entry-RXNUOK24.js → ui-context-menu.entry-RAWB3GNP.js} +2 -2
  51. package/dist/{ui-dialog.entry-IJXNUARC.js → ui-dialog.entry-ZRXQ2XCL.js} +1 -1
  52. package/dist/{ui-disclosure.entry-5QS7UDRH.js → ui-disclosure.entry-U3465YX7.js} +1 -1
  53. package/dist/{ui-editable.entry-D7LOQN2H.js → ui-editable.entry-6L3DIEER.js} +1 -1
  54. package/dist/{ui-floating-action-button.entry-XQZCTZQT.js → ui-floating-action-button.entry-HOWHDYGL.js} +1 -1
  55. package/dist/{ui-form-field.entry-A654LJZE.js → ui-form-field.entry-QCVAXSX7.js} +1 -1
  56. package/dist/{ui-icon-button.entry-MJ7F7ZIH.js → ui-icon-button.entry-FSK5NRAO.js} +1 -1
  57. package/dist/{ui-input.entry-B2XM7JQU.js → ui-input.entry-55UHQLHX.js} +1 -1
  58. package/dist/{ui-menu-item.entry-JULYSFVW.js → ui-menu-item.entry-OXGX4CVF.js} +1 -1
  59. package/dist/{ui-menu.entry-ORRWW7HD.js → ui-menu.entry-YBQ66B7X.js} +2 -2
  60. package/dist/{ui-popover.entry-W67V4UPA.js → ui-popover.entry-AG2T2URX.js} +2 -2
  61. package/dist/{ui-radio-group.entry-KCFOR27M.js → ui-radio-group.entry-E3NXQNYV.js} +1 -1
  62. package/dist/{ui-radio.entry-I2P4V5E3.js → ui-radio.entry-UWC5EALS.js} +1 -1
  63. package/dist/{ui-search-result-row.entry-GHODLSLR.js → ui-search-result-row.entry-CS5I2JJX.js} +1 -1
  64. package/dist/{ui-search-shell.entry-PDB5UN4B.js → ui-search-shell.entry-MTB5GDP3.js} +1 -1
  65. package/dist/{ui-select.entry-D3CZHCKB.js → ui-select.entry-BFFNMJNZ.js} +1 -1
  66. package/dist/{ui-switch.entry-WUDRL4H5.js → ui-switch.entry-7JXIFCZY.js} +1 -1
  67. package/dist/{ui-tabs.entry-MW64GKIJ.js → ui-tabs.entry-R4GNA3P2.js} +1 -1
  68. package/dist/{ui-textarea.entry-VHRBYY6G.js → ui-textarea.entry-HIWZP5GO.js} +1 -1
  69. package/dist/{ui-toast-region.entry-ET75RWYP.js → ui-toast-region.entry-B25TKUAZ.js} +2 -2
  70. package/dist/{ui-top-bar.entry-QIYA3LD3.js → ui-top-bar.entry-RHPW4WN3.js} +1 -1
  71. package/dist/{ui-tree-item.entry-BDB7VEUS.js → ui-tree-item.entry-EAAWU24M.js} +1 -1
  72. package/dist/{ui-tree.entry-GSC7BPRN.js → ui-tree.entry-PISIJRSP.js} +1 -1
  73. package/package.json +1 -1
  74. package/dist/components/p-Drw41pSY.js +0 -1
  75. package/dist/looma/p-56dac38a.entry.js +0 -1
  76. package/dist/looma/p-Drmwg-C1.js +0 -1
@@ -6,38 +6,38 @@ var __glob = (map) => (path) => {
6
6
 
7
7
  // import("./**/*.entry.js") in dist/esm/index-8BGiMGQ0.js
8
8
  var globImport_entry_js = __glob({
9
- "./ui-affordance-scope.entry.js": () => import("./ui-affordance-scope.entry-VR7FLAWG.js"),
10
- "./ui-avatar-group.entry.js": () => import("./ui-avatar-group.entry-L3UKOY3U.js"),
11
- "./ui-avatar.entry.js": () => import("./ui-avatar.entry-VM5OHEFQ.js"),
12
- "./ui-badge.entry.js": () => import("./ui-badge.entry-ZTM4OPUD.js"),
13
- "./ui-button.entry.js": () => import("./ui-button.entry-CIPUSV5B.js"),
14
- "./ui-callout.entry.js": () => import("./ui-callout.entry-OBFCI2O7.js"),
15
- "./ui-checkbox.entry.js": () => import("./ui-checkbox.entry-XT6ET56H.js"),
16
- "./ui-chip_2.entry.js": () => import("./ui-chip_2.entry-32SHCLV6.js"),
17
- "./ui-combobox.entry.js": () => import("./ui-combobox.entry-ONBBPQ2C.js"),
18
- "./ui-context-menu.entry.js": () => import("./ui-context-menu.entry-RXNUOK24.js"),
19
- "./ui-dialog.entry.js": () => import("./ui-dialog.entry-IJXNUARC.js"),
20
- "./ui-disclosure.entry.js": () => import("./ui-disclosure.entry-5QS7UDRH.js"),
21
- "./ui-editable.entry.js": () => import("./ui-editable.entry-D7LOQN2H.js"),
22
- "./ui-floating-action-button.entry.js": () => import("./ui-floating-action-button.entry-XQZCTZQT.js"),
23
- "./ui-form-field.entry.js": () => import("./ui-form-field.entry-A654LJZE.js"),
24
- "./ui-icon-button.entry.js": () => import("./ui-icon-button.entry-MJ7F7ZIH.js"),
25
- "./ui-input.entry.js": () => import("./ui-input.entry-B2XM7JQU.js"),
26
- "./ui-menu-item.entry.js": () => import("./ui-menu-item.entry-JULYSFVW.js"),
27
- "./ui-menu.entry.js": () => import("./ui-menu.entry-ORRWW7HD.js"),
28
- "./ui-popover.entry.js": () => import("./ui-popover.entry-W67V4UPA.js"),
29
- "./ui-radio-group.entry.js": () => import("./ui-radio-group.entry-KCFOR27M.js"),
30
- "./ui-radio.entry.js": () => import("./ui-radio.entry-I2P4V5E3.js"),
31
- "./ui-search-result-row.entry.js": () => import("./ui-search-result-row.entry-GHODLSLR.js"),
32
- "./ui-search-shell.entry.js": () => import("./ui-search-shell.entry-PDB5UN4B.js"),
33
- "./ui-select.entry.js": () => import("./ui-select.entry-D3CZHCKB.js"),
34
- "./ui-switch.entry.js": () => import("./ui-switch.entry-WUDRL4H5.js"),
35
- "./ui-tabs.entry.js": () => import("./ui-tabs.entry-MW64GKIJ.js"),
36
- "./ui-textarea.entry.js": () => import("./ui-textarea.entry-VHRBYY6G.js"),
37
- "./ui-toast-region.entry.js": () => import("./ui-toast-region.entry-ET75RWYP.js"),
38
- "./ui-top-bar.entry.js": () => import("./ui-top-bar.entry-QIYA3LD3.js"),
39
- "./ui-tree-item.entry.js": () => import("./ui-tree-item.entry-BDB7VEUS.js"),
40
- "./ui-tree.entry.js": () => import("./ui-tree.entry-GSC7BPRN.js")
9
+ "./ui-affordance-scope.entry.js": () => import("./ui-affordance-scope.entry-UHAPBKUL.js"),
10
+ "./ui-avatar-group.entry.js": () => import("./ui-avatar-group.entry-5CW7NZXC.js"),
11
+ "./ui-avatar.entry.js": () => import("./ui-avatar.entry-6HZBNQ4Y.js"),
12
+ "./ui-badge.entry.js": () => import("./ui-badge.entry-SNSI6RIY.js"),
13
+ "./ui-button.entry.js": () => import("./ui-button.entry-Z3T6L2OC.js"),
14
+ "./ui-callout.entry.js": () => import("./ui-callout.entry-DLUGC27N.js"),
15
+ "./ui-checkbox.entry.js": () => import("./ui-checkbox.entry-3V3KTI2D.js"),
16
+ "./ui-chip_2.entry.js": () => import("./ui-chip_2.entry-YKN25ITS.js"),
17
+ "./ui-combobox.entry.js": () => import("./ui-combobox.entry-ZQ6MXY7Z.js"),
18
+ "./ui-context-menu.entry.js": () => import("./ui-context-menu.entry-RAWB3GNP.js"),
19
+ "./ui-dialog.entry.js": () => import("./ui-dialog.entry-ZRXQ2XCL.js"),
20
+ "./ui-disclosure.entry.js": () => import("./ui-disclosure.entry-U3465YX7.js"),
21
+ "./ui-editable.entry.js": () => import("./ui-editable.entry-6L3DIEER.js"),
22
+ "./ui-floating-action-button.entry.js": () => import("./ui-floating-action-button.entry-HOWHDYGL.js"),
23
+ "./ui-form-field.entry.js": () => import("./ui-form-field.entry-QCVAXSX7.js"),
24
+ "./ui-icon-button.entry.js": () => import("./ui-icon-button.entry-FSK5NRAO.js"),
25
+ "./ui-input.entry.js": () => import("./ui-input.entry-55UHQLHX.js"),
26
+ "./ui-menu-item.entry.js": () => import("./ui-menu-item.entry-OXGX4CVF.js"),
27
+ "./ui-menu.entry.js": () => import("./ui-menu.entry-YBQ66B7X.js"),
28
+ "./ui-popover.entry.js": () => import("./ui-popover.entry-AG2T2URX.js"),
29
+ "./ui-radio-group.entry.js": () => import("./ui-radio-group.entry-E3NXQNYV.js"),
30
+ "./ui-radio.entry.js": () => import("./ui-radio.entry-UWC5EALS.js"),
31
+ "./ui-search-result-row.entry.js": () => import("./ui-search-result-row.entry-CS5I2JJX.js"),
32
+ "./ui-search-shell.entry.js": () => import("./ui-search-shell.entry-MTB5GDP3.js"),
33
+ "./ui-select.entry.js": () => import("./ui-select.entry-BFFNMJNZ.js"),
34
+ "./ui-switch.entry.js": () => import("./ui-switch.entry-7JXIFCZY.js"),
35
+ "./ui-tabs.entry.js": () => import("./ui-tabs.entry-R4GNA3P2.js"),
36
+ "./ui-textarea.entry.js": () => import("./ui-textarea.entry-HIWZP5GO.js"),
37
+ "./ui-toast-region.entry.js": () => import("./ui-toast-region.entry-B25TKUAZ.js"),
38
+ "./ui-top-bar.entry.js": () => import("./ui-top-bar.entry-RHPW4WN3.js"),
39
+ "./ui-tree-item.entry.js": () => import("./ui-tree-item.entry-EAAWU24M.js"),
40
+ "./ui-tree.entry.js": () => import("./ui-tree.entry-PISIJRSP.js")
41
41
  });
42
42
 
43
43
  // dist/esm/index-8BGiMGQ0.js
@@ -1,4 +1,4 @@
1
- // dist/esm/positioning-Drmwg-C1.js
1
+ // dist/esm/positioning-ZOr-2PSe.js
2
2
  var DEFAULT_AFFORDANCE_NEAR_RADIUS = 16;
3
3
  var anchorSequence = 0;
4
4
  var anchorBindings = /* @__PURE__ */ new WeakMap();
@@ -106,6 +106,18 @@ function createAnchoredSurface(surface, options = {}) {
106
106
  let open = false;
107
107
  let frame = null;
108
108
  let listenerAbort = null;
109
+ let sizeObserver = null;
110
+ const ResizeObserverImpl = owner.ResizeObserver;
111
+ const observeSurfaceSize = () => {
112
+ if (sizeObserver || typeof ResizeObserverImpl !== "function")
113
+ return;
114
+ sizeObserver = new ResizeObserverImpl(() => schedule());
115
+ sizeObserver.observe(surface);
116
+ };
117
+ const stopObservingSurfaceSize = () => {
118
+ sizeObserver?.disconnect();
119
+ sizeObserver = null;
120
+ };
109
121
  surface.setAttribute("popover", "manual");
110
122
  surface.dataset.uiPositioning = nativeAnchor ? "anchor" : "fallback";
111
123
  surface.style.position = "fixed";
@@ -150,6 +162,8 @@ function createAnchoredSurface(surface, options = {}) {
150
162
  positionNative();
151
163
  const viewport = getVisualViewportRect(owner);
152
164
  surfaceRect = surface.getBoundingClientRect();
165
+ if (surfaceRect.width === 0 || surfaceRect.height === 0)
166
+ return;
153
167
  const shift = clampRectToViewport(surfaceRect, viewport, viewportGap);
154
168
  if (shift.x === 0 && shift.y === 0)
155
169
  return;
@@ -191,6 +205,8 @@ function createAnchoredSurface(surface, options = {}) {
191
205
  syncFallbackListeners();
192
206
  showInTopLayer(surface);
193
207
  position();
208
+ schedule();
209
+ observeSurfaceSize();
194
210
  },
195
211
  showAtPoint(nextPoint) {
196
212
  point = nextPoint;
@@ -198,11 +214,14 @@ function createAnchoredSurface(surface, options = {}) {
198
214
  syncFallbackListeners();
199
215
  showInTopLayer(surface);
200
216
  position();
217
+ schedule();
218
+ observeSurfaceSize();
201
219
  },
202
220
  hide() {
203
221
  open = false;
204
222
  point = null;
205
223
  syncFallbackListeners();
224
+ stopObservingSurfaceSize();
206
225
  if (frame !== null)
207
226
  owner.cancelAnimationFrame(frame);
208
227
  frame = null;
@@ -213,6 +232,7 @@ function createAnchoredSurface(surface, options = {}) {
213
232
  open = false;
214
233
  listenerAbort?.abort();
215
234
  listenerAbort = null;
235
+ stopObservingSurfaceSize();
216
236
  if (frame !== null)
217
237
  owner.cancelAnimationFrame(frame);
218
238
  frame = null;
@@ -133,6 +133,22 @@ function createAnchoredSurface(surface, options = {}) {
133
133
  let open = false;
134
134
  let frame = null;
135
135
  let listenerAbort = null;
136
+ let sizeObserver = null;
137
+ // The surface can enter the top layer before its content has laid out (a
138
+ // menu's items, a tooltip's text), so its measured size is briefly zero or
139
+ // stale and the viewport clamp would run against the wrong geometry. Re-run
140
+ // positioning whenever the surface's own size settles.
141
+ const ResizeObserverImpl = owner.ResizeObserver;
142
+ const observeSurfaceSize = () => {
143
+ if (sizeObserver || typeof ResizeObserverImpl !== "function")
144
+ return;
145
+ sizeObserver = new ResizeObserverImpl(() => schedule());
146
+ sizeObserver.observe(surface);
147
+ };
148
+ const stopObservingSurfaceSize = () => {
149
+ sizeObserver?.disconnect();
150
+ sizeObserver = null;
151
+ };
136
152
  surface.setAttribute("popover", "manual");
137
153
  surface.dataset.uiPositioning = nativeAnchor ? "anchor" : "fallback";
138
154
  surface.style.position = "fixed";
@@ -176,6 +192,15 @@ function createAnchoredSurface(surface, options = {}) {
176
192
  positionNative();
177
193
  const viewport = getVisualViewportRect(owner);
178
194
  surfaceRect = surface.getBoundingClientRect();
195
+ // The surface can be measured before it paints (its first frames in the
196
+ // top layer, or while slow content/fonts settle), reporting a zero size.
197
+ // The pixel fallback below would then place it at `anchor - 0`, i.e. off
198
+ // the anchored edge, and leave it stranded there. Trust native anchor
199
+ // placement — which does not depend on our measurement — until the
200
+ // surface has real geometry; the scheduled re-run and ResizeObserver
201
+ // re-position once it does.
202
+ if (surfaceRect.width === 0 || surfaceRect.height === 0)
203
+ return;
179
204
  const shift = clampRectToViewport(surfaceRect, viewport, viewportGap);
180
205
  if (shift.x === 0 && shift.y === 0)
181
206
  return;
@@ -219,6 +244,12 @@ function createAnchoredSurface(surface, options = {}) {
219
244
  syncFallbackListeners();
220
245
  showInTopLayer(surface);
221
246
  position();
247
+ // The surface has just entered the top layer and may not be laid out yet,
248
+ // so the first position() can measure a zero/stale size and skip the
249
+ // viewport clamp. Re-position on the next frame, and keep re-positioning
250
+ // while the surface's own size settles as its content renders.
251
+ schedule();
252
+ observeSurfaceSize();
222
253
  },
223
254
  showAtPoint(nextPoint) {
224
255
  point = nextPoint;
@@ -226,11 +257,14 @@ function createAnchoredSurface(surface, options = {}) {
226
257
  syncFallbackListeners();
227
258
  showInTopLayer(surface);
228
259
  position();
260
+ schedule();
261
+ observeSurfaceSize();
229
262
  },
230
263
  hide() {
231
264
  open = false;
232
265
  point = null;
233
266
  syncFallbackListeners();
267
+ stopObservingSurfaceSize();
234
268
  if (frame !== null)
235
269
  owner.cancelAnimationFrame(frame);
236
270
  frame = null;
@@ -241,6 +275,7 @@ function createAnchoredSurface(surface, options = {}) {
241
275
  open = false;
242
276
  listenerAbort?.abort();
243
277
  listenerAbort = null;
278
+ stopObservingSurfaceSize();
244
279
  if (frame !== null)
245
280
  owner.cancelAnimationFrame(frame);
246
281
  frame = null;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-BHG9Rpil.js');
4
- var positioning = require('./positioning-D5q9DM-0.js');
4
+ var positioning = require('./positioning-CCR6ifPj.js');
5
5
 
6
6
  const uiAffordanceScopeCss = () => `:host{display:contents;--ui-affordance-scope-engaged:0}:host([data-ui-interaction='engaged']){--ui-affordance-scope-engaged:1}`;
7
7
 
@@ -4,7 +4,7 @@ var index = require('./index-BHG9Rpil.js');
4
4
  var manager = require('./manager-Ce25WRtl.js');
5
5
  var events = require('./events-TcQIzpNv.js');
6
6
  var controlledState = require('./controlled-state-BFya8rAX.js');
7
- var positioning = require('./positioning-D5q9DM-0.js');
7
+ var positioning = require('./positioning-CCR6ifPj.js');
8
8
 
9
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%)}`;
10
10
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./index-BHG9Rpil.js');
4
- var positioning = require('./positioning-D5q9DM-0.js');
4
+ var positioning = require('./positioning-CCR6ifPj.js');
5
5
  var manager = require('./manager-Ce25WRtl.js');
6
6
 
7
7
  /** Formatting is additive: every original character must survive in order.
@@ -3,7 +3,7 @@
3
3
  var index = require('./index-BHG9Rpil.js');
4
4
  var manager = require('./manager-Ce25WRtl.js');
5
5
  var events = require('./events-TcQIzpNv.js');
6
- var positioning = require('./positioning-D5q9DM-0.js');
6
+ var positioning = require('./positioning-CCR6ifPj.js');
7
7
 
8
8
  const uiContextMenuCss = () => `:host{display:contents}:host([data-focus-trigger='pointer']) ::slotted(ui-menu-item:focus){outline:none}.menu{position:fixed;inset:auto;margin:0;z-index:var(--ui-z-overlay, 1000);min-width:12rem;opacity:0;transform:translateY(-4px) scale(0.99);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}.menu:popover-open{opacity:1;transform:translateY(0) scale(1)}@starting-style{.menu:popover-open{opacity:0;transform:translateY(-4px) scale(0.99)}}.menu[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){.menu{transition:none}}`;
9
9
 
@@ -4,7 +4,7 @@ var index = require('./index-BHG9Rpil.js');
4
4
  var events = require('./events-TcQIzpNv.js');
5
5
  var manager = require('./manager-Ce25WRtl.js');
6
6
  var controlledState = require('./controlled-state-BFya8rAX.js');
7
- var positioning = require('./positioning-D5q9DM-0.js');
7
+ var positioning = require('./positioning-CCR6ifPj.js');
8
8
 
9
9
  const uiMenuCss = () => `:host{--ui-menu-viewport-gap:var(--ui-space-2, 0.5rem);display:flex;flex-direction:column;box-sizing:border-box;inline-size:max-content;min-inline-size:min(12rem, calc(100vw - (var(--ui-menu-viewport-gap) * 2)));max-inline-size:calc(100vw - (var(--ui-menu-viewport-gap) * 2));padding:0;border:0;border-radius:0;background:transparent;box-shadow:none;overflow:visible}.menu__surface{display:flex;flex-direction:column;box-sizing:border-box;max-inline-size:inherit;padding:var(--ui-space-1);background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);box-shadow:var(--ui-shadow-lg);max-block-size:inherit;overflow:auto}:host(:not([data-open])){display:none}:host([popover]){position:fixed;inset:auto;margin:0;overflow:visible;max-block-size:calc(100dvh - (var(--ui-menu-viewport-gap) * 2));opacity:0;transform:translateY(-4px) scale(0.99);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}:host([popover]:popover-open){opacity:1;transform:translateY(0) scale(1)}@starting-style{:host([popover]:popover-open){opacity:0;transform:translateY(-4px) scale(0.99)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host([popover]){transition:none}}::slotted(ui-menu-item){display:block;width:100%}`;
10
10
 
@@ -4,7 +4,7 @@ var index = require('./index-BHG9Rpil.js');
4
4
  var manager = require('./manager-Ce25WRtl.js');
5
5
  var events = require('./events-TcQIzpNv.js');
6
6
  var controlledState = require('./controlled-state-BFya8rAX.js');
7
- var positioning = require('./positioning-D5q9DM-0.js');
7
+ var positioning = require('./positioning-CCR6ifPj.js');
8
8
 
9
9
  const uiPopoverCss = () => `:host{--ui-popover-viewport-gap:var(--ui-space-2, 0.5rem);box-sizing:border-box;max-inline-size:min( 20rem, calc(100vw - (var(--ui-popover-viewport-gap) * 2)) );max-block-size:calc(100dvh - (var(--ui-popover-viewport-gap) * 2));overflow:visible;padding:0;border:0;border-radius:0;background:transparent;box-shadow:none}.popover__surface{box-sizing:border-box;max-inline-size:inherit;max-block-size:inherit;overflow:auto;padding:var(--ui-space-3);background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);box-shadow:var(--ui-shadow-lg)}:host(:not([data-open])){display:none}:host([popover]){position:fixed;inset:auto;margin:0;opacity:0;transform:translateY(-4px) scale(0.99);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}:host([popover]:popover-open){opacity:1;transform:translateY(0) scale(1)}@starting-style{:host([popover]:popover-open){opacity:0;transform:translateY(-4px) scale(0.99)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host([popover]){transition:none}}`;
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  var index = require('./index-BHG9Rpil.js');
4
4
  var events = require('./events-TcQIzpNv.js');
5
- var positioning = require('./positioning-D5q9DM-0.js');
5
+ var positioning = require('./positioning-CCR6ifPj.js');
6
6
 
7
7
  const uiToastRegionCss = () => `:host{position:fixed;top:calc(var(--ui-space-4) + env(safe-area-inset-top));left:50%;transform:translateX(-50%);z-index:9999;display:grid;gap:var(--ui-space-2);inline-size:min(24rem, calc(100vw - (var(--ui-space-4) * 2)));max-inline-size:100%;pointer-events:none}:host([popover]){right:auto;bottom:auto;margin:0}:host>*{pointer-events:auto}::slotted([data-ui-toast]){display:grid;grid-template-columns:1fr auto;gap:var(--ui-space-2);align-items:start;border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);padding:var(--ui-space-3) var(--ui-space-4);background:var(--ui-surface-elevated);color:var(--ui-text-primary);box-shadow:var(--ui-shadow-lg);animation:ui-toast-enter 0.25s var(--ui-motion-ease) forwards}@keyframes ui-toast-enter{from{opacity:0;transform:translateY(-0.5rem)}to{opacity:1;transform:translateY(0)}}::slotted([data-ui-toast][aria-hidden='true']){display:none}::slotted([data-ui-toast-dismiss]){border:0;background:transparent;color:var(--ui-text-secondary);cursor:pointer;font:inherit}`;
8
8
 
@@ -133,6 +133,22 @@ export function createAnchoredSurface(surface, options = {}) {
133
133
  let open = false;
134
134
  let frame = null;
135
135
  let listenerAbort = null;
136
+ let sizeObserver = null;
137
+ // The surface can enter the top layer before its content has laid out (a
138
+ // menu's items, a tooltip's text), so its measured size is briefly zero or
139
+ // stale and the viewport clamp would run against the wrong geometry. Re-run
140
+ // positioning whenever the surface's own size settles.
141
+ const ResizeObserverImpl = owner.ResizeObserver;
142
+ const observeSurfaceSize = () => {
143
+ if (sizeObserver || typeof ResizeObserverImpl !== "function")
144
+ return;
145
+ sizeObserver = new ResizeObserverImpl(() => schedule());
146
+ sizeObserver.observe(surface);
147
+ };
148
+ const stopObservingSurfaceSize = () => {
149
+ sizeObserver?.disconnect();
150
+ sizeObserver = null;
151
+ };
136
152
  surface.setAttribute("popover", "manual");
137
153
  surface.dataset.uiPositioning = nativeAnchor ? "anchor" : "fallback";
138
154
  surface.style.position = "fixed";
@@ -179,6 +195,15 @@ export function createAnchoredSurface(surface, options = {}) {
179
195
  positionNative();
180
196
  const viewport = getVisualViewportRect(owner);
181
197
  surfaceRect = surface.getBoundingClientRect();
198
+ // The surface can be measured before it paints (its first frames in the
199
+ // top layer, or while slow content/fonts settle), reporting a zero size.
200
+ // The pixel fallback below would then place it at `anchor - 0`, i.e. off
201
+ // the anchored edge, and leave it stranded there. Trust native anchor
202
+ // placement — which does not depend on our measurement — until the
203
+ // surface has real geometry; the scheduled re-run and ResizeObserver
204
+ // re-position once it does.
205
+ if (surfaceRect.width === 0 || surfaceRect.height === 0)
206
+ return;
182
207
  const shift = clampRectToViewport(surfaceRect, viewport, viewportGap);
183
208
  if (shift.x === 0 && shift.y === 0)
184
209
  return;
@@ -222,6 +247,12 @@ export function createAnchoredSurface(surface, options = {}) {
222
247
  syncFallbackListeners();
223
248
  showInTopLayer(surface);
224
249
  position();
250
+ // The surface has just entered the top layer and may not be laid out yet,
251
+ // so the first position() can measure a zero/stale size and skip the
252
+ // viewport clamp. Re-position on the next frame, and keep re-positioning
253
+ // while the surface's own size settles as its content renders.
254
+ schedule();
255
+ observeSurfaceSize();
225
256
  },
226
257
  showAtPoint(nextPoint) {
227
258
  point = nextPoint;
@@ -229,11 +260,14 @@ export function createAnchoredSurface(surface, options = {}) {
229
260
  syncFallbackListeners();
230
261
  showInTopLayer(surface);
231
262
  position();
263
+ schedule();
264
+ observeSurfaceSize();
232
265
  },
233
266
  hide() {
234
267
  open = false;
235
268
  point = null;
236
269
  syncFallbackListeners();
270
+ stopObservingSurfaceSize();
237
271
  if (frame !== null)
238
272
  owner.cancelAnimationFrame(frame);
239
273
  frame = null;
@@ -244,6 +278,7 @@ export function createAnchoredSurface(surface, options = {}) {
244
278
  open = false;
245
279
  listenerAbort?.abort();
246
280
  listenerAbort = null;
281
+ stopObservingSurfaceSize();
247
282
  if (frame !== null)
248
283
  owner.cancelAnimationFrame(frame);
249
284
  frame = null;
@@ -1 +1 @@
1
- import{p as e,H as t,h as i,c as s,t as r}from"./p-Bh_1GxOD.js";import{d as a,e as o}from"./p-JwSoedEO.js";import{o as n,c,r as l}from"./p-C-0syqXZ.js";import{i as u,c as h}from"./p-BnGhGgTH.js";import{c as p}from"./p-Drw41pSY.js";const d=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow()}get host(){return this}open;defaultOpen=!1;for;placement="bottom-start";internalOpen=!1;overlayId=`ui-menu-${Math.random().toString(36).slice(2,11)}`;anchor=null;surface=null;syncFromProp(){u(this.open)&&(this.internalOpen=this.open)}resetSurface(){this.setupSurface(),this.syncSurface()}syncSurface(){this.syncAnchorState(),this.surface&&(this.internalOpen?(this.surface.show(),n({id:this.overlayId,modal:!1,element:this.host,relatedElements:this.anchor?[this.anchor]:void 0,dismissible:!0,requestClose:(e,t)=>this.closeMenu(e,t)})):(this.surface.hide(),c(this.overlayId)))}componentDidLoad(){this.internalOpen=h(this.open,this.defaultOpen),this.host.addEventListener("click",this.onItemClick),this.host.addEventListener("keydown",this.onKeydown),this.setupSurface(),this.syncSurface()}disconnectedCallback(){this.host.removeEventListener("click",this.onItemClick),this.host.removeEventListener("keydown",this.onKeydown),this.surface?.destroy(),this.surface=null,c(this.overlayId)}setupSurface(){this.surface?.destroy(),this.surface=null,this.anchor=this.for?this.host.ownerDocument.getElementById(this.for):null,this.anchor&&(this.surface=p(this.host,{anchor:this.anchor,placement:this.placement}))}syncAnchorState(){this.anchor&&(this.anchor.setAttribute("aria-haspopup","menu"),this.anchor.setAttribute("aria-expanded",this.internalOpen?"true":"false"))}closeMenu(e,t){this.internalOpen&&(u(this.open)||(this.internalOpen=!1),a(this.host,"close",{open:!1,reason:e,trigger:t}),"escape"===e&&this.anchor?.focus())}getItems(){return Array.from(this.host.querySelectorAll("ui-menu-item"))}isItemDisabled(e){return"true"===e.getAttribute("aria-disabled")||e.hasAttribute("disabled")||"true"===e.getAttribute("disabled")||!0===e.disabled}onItemClick=e=>{const t=e.target.closest?.("ui-menu-item");if(!t||t.getRootNode()!==this.host.getRootNode())return;if(this.isItemDisabled(t))return;const i=t.getAttribute("value")??t.getAttribute("data-value")??"";a(this.host,"select",{value:i,trigger:o(e)}),a(this.host,"close",{open:!1,reason:"action",trigger:o(e)}),u(this.open)||(this.internalOpen=!1)};onKeydown=e=>{if("Escape"===e.key)return e.preventDefault(),void l("escape","keyboard");const i=this.getItems().filter((e=>!this.isItemDisabled(e)));if(0===i.length)return;const s=e.target.closest?.("ui-menu-item"),r=s&&s instanceof t?i.indexOf(s):-1;if("Enter"!==e.key&&" "!==e.key)"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),i["ArrowDown"===e.key?r<0?0:Math.min(r+1,i.length-1):r<=0?i.length-1:r-1].focus());else if(e.preventDefault(),s&&r>=0){const e=s.getAttribute("value")??s.getAttribute("data-value")??"";a(this.host,"select",{value:e,trigger:"keyboard"}),a(this.host,"close",{open:!1,reason:"action",trigger:"keyboard"}),u(this.open)||(this.internalOpen=!1)}};render(){return i(s,{key:"5b64cc53ca56ea04a63013c8cb61231c9b1045cc",role:"menu","aria-orientation":"vertical","data-open":this.internalOpen?"":void 0},i("div",{key:"6410a56cc5efcffd0673c9abdf8f8aa45295c516",class:"menu__surface"},i("slot",{key:"7e7f9d3b19bbf3024d61ecf44cd8b103748ef966"})))}static get watchers(){return{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncSurface:0}]}}static get style(){return":host{--ui-menu-viewport-gap:var(--ui-space-2, 0.5rem);display:flex;flex-direction:column;box-sizing:border-box;inline-size:max-content;min-inline-size:min(12rem, calc(100vw - (var(--ui-menu-viewport-gap) * 2)));max-inline-size:calc(100vw - (var(--ui-menu-viewport-gap) * 2));padding:0;border:0;border-radius:0;background:transparent;box-shadow:none;overflow:visible}.menu__surface{display:flex;flex-direction:column;box-sizing:border-box;max-inline-size:inherit;padding:var(--ui-space-1);background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);box-shadow:var(--ui-shadow-lg);max-block-size:inherit;overflow:auto}:host(:not([data-open])){display:none}:host([popover]){position:fixed;inset:auto;margin:0;overflow:visible;max-block-size:calc(100dvh - (var(--ui-menu-viewport-gap) * 2));opacity:0;transform:translateY(-4px) scale(0.99);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}:host([popover]:popover-open){opacity:1;transform:translateY(0) scale(1)}@starting-style{:host([popover]:popover-open){opacity:0;transform:translateY(-4px) scale(0.99)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host([popover]){transition:none}}::slotted(ui-menu-item){display:block;width:100%}"}},[769,"ui-menu",{open:[4],defaultOpen:[4,"default-open"],for:[1],placement:[1],internalOpen:[32]},void 0,{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncSurface:0}]}]);function m(){"undefined"!=typeof customElements&&["ui-menu"].forEach((e=>{"ui-menu"===e&&(customElements.get(r(e))||customElements.define(r(e),d))}))}export{d as U,m as d}
1
+ import{p as e,H as t,h as i,c as s,t as a}from"./p-Bh_1GxOD.js";import{d as r,e as o}from"./p-JwSoedEO.js";import{o as n,c,r as l}from"./p-C-0syqXZ.js";import{i as u,c as h}from"./p-BnGhGgTH.js";import{c as p}from"./p-B_DaIVEY.js";const d=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow()}get host(){return this}open;defaultOpen=!1;for;placement="bottom-start";internalOpen=!1;overlayId=`ui-menu-${Math.random().toString(36).slice(2,11)}`;anchor=null;surface=null;syncFromProp(){u(this.open)&&(this.internalOpen=this.open)}resetSurface(){this.setupSurface(),this.syncSurface()}syncSurface(){this.syncAnchorState(),this.surface&&(this.internalOpen?(this.surface.show(),n({id:this.overlayId,modal:!1,element:this.host,relatedElements:this.anchor?[this.anchor]:void 0,dismissible:!0,requestClose:(e,t)=>this.closeMenu(e,t)})):(this.surface.hide(),c(this.overlayId)))}componentDidLoad(){this.internalOpen=h(this.open,this.defaultOpen),this.host.addEventListener("click",this.onItemClick),this.host.addEventListener("keydown",this.onKeydown),this.setupSurface(),this.syncSurface()}disconnectedCallback(){this.host.removeEventListener("click",this.onItemClick),this.host.removeEventListener("keydown",this.onKeydown),this.surface?.destroy(),this.surface=null,c(this.overlayId)}setupSurface(){this.surface?.destroy(),this.surface=null,this.anchor=this.for?this.host.ownerDocument.getElementById(this.for):null,this.anchor&&(this.surface=p(this.host,{anchor:this.anchor,placement:this.placement}))}syncAnchorState(){this.anchor&&(this.anchor.setAttribute("aria-haspopup","menu"),this.anchor.setAttribute("aria-expanded",this.internalOpen?"true":"false"))}closeMenu(e,t){this.internalOpen&&(u(this.open)||(this.internalOpen=!1),r(this.host,"close",{open:!1,reason:e,trigger:t}),"escape"===e&&this.anchor?.focus())}getItems(){return Array.from(this.host.querySelectorAll("ui-menu-item"))}isItemDisabled(e){return"true"===e.getAttribute("aria-disabled")||e.hasAttribute("disabled")||"true"===e.getAttribute("disabled")||!0===e.disabled}onItemClick=e=>{const t=e.target.closest?.("ui-menu-item");if(!t||t.getRootNode()!==this.host.getRootNode())return;if(this.isItemDisabled(t))return;const i=t.getAttribute("value")??t.getAttribute("data-value")??"";r(this.host,"select",{value:i,trigger:o(e)}),r(this.host,"close",{open:!1,reason:"action",trigger:o(e)}),u(this.open)||(this.internalOpen=!1)};onKeydown=e=>{if("Escape"===e.key)return e.preventDefault(),void l("escape","keyboard");const i=this.getItems().filter((e=>!this.isItemDisabled(e)));if(0===i.length)return;const s=e.target.closest?.("ui-menu-item"),a=s&&s instanceof t?i.indexOf(s):-1;if("Enter"!==e.key&&" "!==e.key)"ArrowDown"!==e.key&&"ArrowUp"!==e.key||(e.preventDefault(),i["ArrowDown"===e.key?a<0?0:Math.min(a+1,i.length-1):a<=0?i.length-1:a-1].focus());else if(e.preventDefault(),s&&a>=0){const e=s.getAttribute("value")??s.getAttribute("data-value")??"";r(this.host,"select",{value:e,trigger:"keyboard"}),r(this.host,"close",{open:!1,reason:"action",trigger:"keyboard"}),u(this.open)||(this.internalOpen=!1)}};render(){return i(s,{key:"5b64cc53ca56ea04a63013c8cb61231c9b1045cc",role:"menu","aria-orientation":"vertical","data-open":this.internalOpen?"":void 0},i("div",{key:"6410a56cc5efcffd0673c9abdf8f8aa45295c516",class:"menu__surface"},i("slot",{key:"7e7f9d3b19bbf3024d61ecf44cd8b103748ef966"})))}static get watchers(){return{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncSurface:0}]}}static get style(){return":host{--ui-menu-viewport-gap:var(--ui-space-2, 0.5rem);display:flex;flex-direction:column;box-sizing:border-box;inline-size:max-content;min-inline-size:min(12rem, calc(100vw - (var(--ui-menu-viewport-gap) * 2)));max-inline-size:calc(100vw - (var(--ui-menu-viewport-gap) * 2));padding:0;border:0;border-radius:0;background:transparent;box-shadow:none;overflow:visible}.menu__surface{display:flex;flex-direction:column;box-sizing:border-box;max-inline-size:inherit;padding:var(--ui-space-1);background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);box-shadow:var(--ui-shadow-lg);max-block-size:inherit;overflow:auto}:host(:not([data-open])){display:none}:host([popover]){position:fixed;inset:auto;margin:0;overflow:visible;max-block-size:calc(100dvh - (var(--ui-menu-viewport-gap) * 2));opacity:0;transform:translateY(-4px) scale(0.99);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}:host([popover]:popover-open){opacity:1;transform:translateY(0) scale(1)}@starting-style{:host([popover]:popover-open){opacity:0;transform:translateY(-4px) scale(0.99)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host([popover]){transition:none}}::slotted(ui-menu-item){display:block;width:100%}"}},[769,"ui-menu",{open:[4],defaultOpen:[4,"default-open"],for:[1],placement:[1],internalOpen:[32]},void 0,{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncSurface:0}]}]);function m(){"undefined"!=typeof customElements&&["ui-menu"].forEach((e=>{"ui-menu"===e&&(customElements.get(a(e))||customElements.define(a(e),d))}))}export{d as U,m as d}
@@ -0,0 +1 @@
1
+ const t=16;let n=0;const o=new WeakMap;function a(t){try{return t.matches(":popover-open")}catch{return!t.hidden}}function i(t){if(t.setAttribute("popover","manual"),t.hidden=!1,"function"==typeof t.showPopover&&!a(t))try{t.showPopover()}catch{}}function e(t){if("function"==typeof t.hidePopover&&a(t))try{t.hidePopover()}catch{}t.hidden=!0}function r(t){return t.setAttribute("popover","manual"),t.dataset.uiPositioning="viewport",{show(){i(t)},hide(){e(t)},destroy(){e(t)}}}function l(t,n,o,a,i,e=t.getBoundingClientRect()){const r=c(t.ownerDocument.defaultView??window),l=o.startsWith("top"),u=o.endsWith("end"),h=r.bottom-n.bottom-i,f=n.top-r.top-i,p=(l?!(f<e.height+a&&h>f):h<e.height+a&&f>h)?n.top-e.height-a:n.bottom+a,d=u?n.right-e.width:n.left,m=s({left:d,top:p,width:e.width,height:e.height},r,i);t.style.left=`${Math.round(d+m.x)}px`,t.style.top=`${Math.round(p+m.y)}px`,t.style.right="auto",t.style.bottom="auto"}function u(t,a={}){const r=t.ownerDocument.defaultView??window,u=a.placement??"bottom-start",h=Math.max(0,a.gap??4),f=Math.max(0,a.viewportGap??8),p=function(t){const n=t.CSS;return"function"==typeof n?.supports&&n.supports("anchor-name: --ui-anchor-test")&&n.supports("position-anchor: --ui-anchor-test")&&n.supports("top: anchor(bottom)")}(r),d="--ui-anchor-"+ ++n;let m=a.anchor??null,y=null,g=!1,w=null,v=null,b=null;const M=r.ResizeObserver,x=()=>{b||"function"!=typeof M||(b=new M((()=>$())),b.observe(t))},A=()=>{b?.disconnect(),b=null};t.setAttribute("popover","manual"),t.dataset.uiPositioning=p?"anchor":"fallback",t.style.position="fixed",t.style.margin="0";const k=n=>{m&&function(t,n){const a=o.get(t);if(a)if(a.names.delete(n),a.names.size){const n=[a.original,...a.names].filter(Boolean);t.style.setProperty("anchor-name",n.join(", "))}else a.original?t.style.setProperty("anchor-name",a.original):t.style.removeProperty("anchor-name"),o.delete(t)}(m,d),m=n,m?(function(t,n){const a=o.get(t)??{original:t.style.getPropertyValue("anchor-name"),names:new Set};a.names.add(n),o.set(t,a);const i=[a.original,...a.names].filter(Boolean);t.style.setProperty("anchor-name",i.join(", "))}(m,d),t.style.setProperty("position-anchor",d)):t.style.removeProperty("position-anchor")},z=()=>{if(w=null,!g)return;if(y)return void l(t,{left:y.x,right:y.x,top:y.y,bottom:y.y},"bottom-start",h,f);if(!m)return;let n;if(p){(()=>{const n=u.startsWith("bottom"),o=u.endsWith("end");t.style.top=n?`calc(anchor(bottom) + ${h}px)`:"auto",t.style.bottom=n?"auto":`calc(anchor(top) + ${h}px)`,t.style.left=o?"auto":"anchor(left)",t.style.right=o?"anchor(right)":"auto",t.style.setProperty("position-try-fallbacks","flip-block, flip-inline")})();const o=c(r);if(n=t.getBoundingClientRect(),0===n.width||0===n.height)return;const a=s(n,o,f);if(0===a.x&&0===a.y)return}l(t,m.getBoundingClientRect(),u,h,f,n)},$=()=>{g&&null===w&&(w=r.requestAnimationFrame(z))},B=()=>{if(!g||null===y&&null===m)return v?.abort(),void(v=null);if(v)return;v=new AbortController;const t=v.signal;r.addEventListener("resize",$,{passive:!0,signal:t}),r.addEventListener("scroll",$,{passive:!0,capture:!0,signal:t}),r.visualViewport?.addEventListener("resize",$,{passive:!0,signal:t}),r.visualViewport?.addEventListener("scroll",$,{passive:!0,signal:t})};return k(m),{setAnchor(t){y=null,k(t),B(),$()},show(){y=null,g=!0,B(),i(t),z(),$(),x()},showAtPoint(n){y=n,g=!0,B(),i(t),z(),$(),x()},hide(){g=!1,y=null,B(),A(),null!==w&&r.cancelAnimationFrame(w),w=null,e(t)},refresh:$,destroy(){g=!1,v?.abort(),v=null,A(),null!==w&&r.cancelAnimationFrame(w),w=null,e(t),k(null)}}}function c(t=window){const n=t.visualViewport,o=n?.offsetLeft??0,a=n?.offsetTop??0,i=n?.width??t.innerWidth,e=n?.height??t.innerHeight;return{left:o,top:a,right:o+i,bottom:a+e,width:i,height:e}}function s(t,n=c(),o=0){const a=Math.max(0,n.width-2*o),i=Math.max(0,n.height-2*o),e=t.width>a?n.left+o:Math.min(Math.max(t.left,n.left+o),n.right-o-t.width),r=t.height>i?n.top+o:Math.min(Math.max(t.top,n.top+o),n.bottom-o-t.height);return{x:e-t.left,y:r-t.top}}function h(t,n){const o=Math.max(n.left-t.x,0,t.x-n.right),a=Math.max(n.top-t.y,0,t.y-n.bottom);return Math.hypot(o,a)}function f(t,n={}){const o=t.ownerDocument.defaultView??window,a=n.pointerTarget??t,i=n.anchorSelector??"[data-ui-affordance]",e=n.nearRadius??16,r=Number.isFinite(e)?Math.max(0,e):16,l=new AbortController;let u=[],c=null,s=null,f=!1;const p=()=>{for(const{element:t}of u)t.hasAttribute("data-ui-proximity")&&t.removeAttribute("data-ui-proximity");t.hasAttribute("data-ui-interaction")&&t.removeAttribute("data-ui-interaction")},d=()=>{u=Array.from(t.querySelectorAll(i)).filter((t=>!t.hasAttribute("disabled")&&"true"!==t.getAttribute("aria-disabled"))).map((t=>({element:t,rect:t.getBoundingClientRect()}))),f=!1},m=()=>{if(c=null,f&&d(),!s)return void p();let n=!1;for(const t of u){const o=h(s,t.rect)<=r;o&&"near"!==t.element.getAttribute("data-ui-proximity")?t.element.setAttribute("data-ui-proximity","near"):!o&&t.element.hasAttribute("data-ui-proximity")&&t.element.removeAttribute("data-ui-proximity"),n||=o}n&&"engaged"!==t.getAttribute("data-ui-interaction")?t.setAttribute("data-ui-interaction","engaged"):!n&&t.hasAttribute("data-ui-interaction")&&t.removeAttribute("data-ui-interaction")},y=()=>{null===c&&(c=o.requestAnimationFrame(m))},g=()=>{f=!0,y()};return a.addEventListener("pointermove",(t=>{s="touch"===t.pointerType?null:{x:t.clientX,y:t.clientY},y()}),{passive:!0,signal:l.signal}),o.addEventListener("resize",g,{passive:!0,signal:l.signal}),o.addEventListener("scroll",g,{passive:!0,capture:!0,signal:l.signal}),o.visualViewport?.addEventListener("resize",g,{passive:!0,signal:l.signal}),o.visualViewport?.addEventListener("scroll",g,{passive:!0,signal:l.signal}),d(),{refresh:g,destroy(){l.abort(),null!==c&&o.cancelAnimationFrame(c),c=null,s=null,p(),u=[]}}}export{t as D,f as a,r as b,u as c}
@@ -1 +1 @@
1
- import{p as t,H as i,d as s,h as e,c as o,t as r}from"./p-Bh_1GxOD.js";import{o as h,c as n}from"./p-C-0syqXZ.js";import{d as a}from"./p-JwSoedEO.js";import{i as l,c}from"./p-BnGhGgTH.js";import{c as d}from"./p-Drw41pSY.js";const p=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.opened=s(this,"open"),this.closed=s(this,"close")}get host(){return this}for="";open;defaultOpen=!1;placement="top-start";showDelay=500;hideDelay=100;toggleOnClick=!1;pinned=!1;focused=!1;opened;closed;internalOpen=!1;overlayId=`ui-tooltip-${Math.random().toString(36).slice(2,11)}`;trigger=null;surface=null;showTimer=null;hideTimer=null;syncFromProp(){this.clearTimers(),l(this.open)&&(this.internalOpen=this.open)}resetSurface(){this.syncTrigger(),this.setupSurface(),this.syncOverlay()}syncOverlay(){this.internalOpen?(this.surface?.show(),h({id:this.overlayId,modal:!1,element:this.host,relatedElements:this.trigger?[this.trigger]:void 0,dismissible:!0,requestClose:(t,i)=>this.handleRequestClose(t,i)})):(this.surface?.hide(),n(this.overlayId))}componentDidLoad(){this.host.id||(this.host.id=this.overlayId),this.internalOpen=c(this.open,this.defaultOpen),this.syncTrigger(),this.setupSurface(),this.host.addEventListener("pointerenter",this.onSurfaceEnter),this.host.addEventListener("pointerleave",this.onTriggerLeave),this.syncOverlay()}componentDidUpdate(){this.syncTrigger()}disconnectedCallback(){this.clearTimers(),this.detachTriggerListeners(),this.surface?.destroy(),this.surface=null,this.host.removeEventListener("pointerenter",this.onSurfaceEnter),this.host.removeEventListener("pointerleave",this.onTriggerLeave),n(this.overlayId)}syncTrigger(){const t=this.for?this.host.getRootNode().getElementById(this.for):this.host.previousElementSibling;t!==this.trigger&&(this.detachTriggerListeners(),this.trigger=t,this.attachTriggerListeners(),this.surface?.setAnchor(t))}setupSurface(){this.surface?.destroy(),this.surface=d(this.host,{anchor:this.trigger,placement:this.placement})}attachTriggerListeners(){if(this.detachTriggerListeners(),!this.trigger)return;const t=new Set((this.trigger.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));t.add(this.host.id),this.trigger.setAttribute("aria-describedby",[...t].join(" ")),this.trigger.addEventListener("click",this.onTriggerClick),this.trigger.addEventListener("keydown",this.onTriggerKeydown),this.trigger.addEventListener("pointerenter",this.onTriggerEnter),this.trigger.addEventListener("pointerleave",this.onTriggerLeave),this.trigger.addEventListener("focusin",this.onTriggerFocusIn),this.trigger.addEventListener("focusout",this.onTriggerFocusOut)}detachTriggerListeners(){if(!this.trigger)return;const t=(this.trigger.getAttribute("aria-describedby")||"").split(/\s+/).filter((t=>t&&t!==this.host.id));t.length?this.trigger.setAttribute("aria-describedby",t.join(" ")):this.trigger.removeAttribute("aria-describedby"),this.trigger.removeEventListener("click",this.onTriggerClick),this.trigger.removeEventListener("keydown",this.onTriggerKeydown),this.trigger.removeEventListener("pointerenter",this.onTriggerEnter),this.trigger.removeEventListener("pointerleave",this.onTriggerLeave),this.trigger.removeEventListener("focusin",this.onTriggerFocusIn),this.trigger.removeEventListener("focusout",this.onTriggerFocusOut)}clearShowTimer(){null!==this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null)}clearHideTimer(){null!==this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)}clearTimers(){this.clearShowTimer(),this.clearHideTimer()}setInteractionOpen(t,i){this.internalOpen!==t&&(l(this.open)||(this.internalOpen=t),a(this.host,t?"open":"close",{open:t,reason:"action",trigger:i}))}onSurfaceEnter=()=>this.clearHideTimer();onTriggerClick=t=>{this.toggleOnClick&&(this.clearTimers(),this.pinned=!this.pinned,this.setInteractionOpen(this.pinned,0===t.detail?"keyboard":"pointer"))};onTriggerKeydown=t=>{"Escape"===t.key&&this.clearTimers()};onTriggerEnter=t=>{"touch"!==t.pointerType&&(this.clearHideTimer(),this.internalOpen||null!==this.showTimer||(this.showTimer=setTimeout((()=>{this.showTimer=null,this.setInteractionOpen(!0,"pointer")}),Math.max(0,this.showDelay))))};onTriggerLeave=()=>{this.clearShowTimer(),this.focused||this.pinned||!this.internalOpen||null!==this.hideTimer||(this.hideTimer=setTimeout((()=>{this.hideTimer=null,this.setInteractionOpen(!1,"pointer")}),Math.max(0,this.hideDelay)))};onTriggerFocusIn=()=>{this.focused=!0,this.clearTimers(),this.setInteractionOpen(!0,"keyboard")};onTriggerFocusOut=t=>{const i=t.relatedTarget;i&&this.host.contains(i)||(this.focused=!1,this.pinned=!1,this.clearTimers(),this.setInteractionOpen(!1,"keyboard"))};handleRequestClose(t,i){("escape"===t||"light-dismiss"===t&&this.toggleOnClick)&&(this.pinned=!1,this.clearTimers(),l(this.open)||(this.internalOpen=!1),a(this.host,"close",{open:!1,reason:t,trigger:i}))}render(){return e(o,{key:"fd4d81febd147b846aca66e94f25d56f14b171dc",role:"tooltip",hidden:!this.internalOpen,"data-open":this.internalOpen?"":void 0},e("div",{key:"d31ac8c0e087becd7e60459f2cd894a9b15e95fa",class:"tooltip__surface"},e("slot",{key:"06e7aac9b6992a9cf0f92c9d356b97d18fb2da8b"})))}static get watchers(){return{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncOverlay:0}]}}static get style(){return":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}}"}},[769,"ui-tooltip",{for:[1],open:[4],defaultOpen:[4,"default-open"],placement:[1],showDelay:[2,"show-delay"],hideDelay:[2,"hide-delay"],toggleOnClick:[4,"toggle-on-click"],internalOpen:[32]},void 0,{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncOverlay:0}]}]);function u(){"undefined"!=typeof customElements&&["ui-tooltip"].forEach((t=>{"ui-tooltip"===t&&(customElements.get(r(t))||customElements.define(r(t),p))}))}export{p as U,u as d}
1
+ import{p as t,H as i,d as s,h as e,c as o,t as r}from"./p-Bh_1GxOD.js";import{o as h,c as a}from"./p-C-0syqXZ.js";import{d as n}from"./p-JwSoedEO.js";import{i as l,c}from"./p-BnGhGgTH.js";import{c as d}from"./p-B_DaIVEY.js";const p=t(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.opened=s(this,"open"),this.closed=s(this,"close")}get host(){return this}for="";open;defaultOpen=!1;placement="top-start";showDelay=500;hideDelay=100;toggleOnClick=!1;pinned=!1;focused=!1;opened;closed;internalOpen=!1;overlayId=`ui-tooltip-${Math.random().toString(36).slice(2,11)}`;trigger=null;surface=null;showTimer=null;hideTimer=null;syncFromProp(){this.clearTimers(),l(this.open)&&(this.internalOpen=this.open)}resetSurface(){this.syncTrigger(),this.setupSurface(),this.syncOverlay()}syncOverlay(){this.internalOpen?(this.surface?.show(),h({id:this.overlayId,modal:!1,element:this.host,relatedElements:this.trigger?[this.trigger]:void 0,dismissible:!0,requestClose:(t,i)=>this.handleRequestClose(t,i)})):(this.surface?.hide(),a(this.overlayId))}componentDidLoad(){this.host.id||(this.host.id=this.overlayId),this.internalOpen=c(this.open,this.defaultOpen),this.syncTrigger(),this.setupSurface(),this.host.addEventListener("pointerenter",this.onSurfaceEnter),this.host.addEventListener("pointerleave",this.onTriggerLeave),this.syncOverlay()}componentDidUpdate(){this.syncTrigger()}disconnectedCallback(){this.clearTimers(),this.detachTriggerListeners(),this.surface?.destroy(),this.surface=null,this.host.removeEventListener("pointerenter",this.onSurfaceEnter),this.host.removeEventListener("pointerleave",this.onTriggerLeave),a(this.overlayId)}syncTrigger(){const t=this.for?this.host.getRootNode().getElementById(this.for):this.host.previousElementSibling;t!==this.trigger&&(this.detachTriggerListeners(),this.trigger=t,this.attachTriggerListeners(),this.surface?.setAnchor(t))}setupSurface(){this.surface?.destroy(),this.surface=d(this.host,{anchor:this.trigger,placement:this.placement})}attachTriggerListeners(){if(this.detachTriggerListeners(),!this.trigger)return;const t=new Set((this.trigger.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));t.add(this.host.id),this.trigger.setAttribute("aria-describedby",[...t].join(" ")),this.trigger.addEventListener("click",this.onTriggerClick),this.trigger.addEventListener("keydown",this.onTriggerKeydown),this.trigger.addEventListener("pointerenter",this.onTriggerEnter),this.trigger.addEventListener("pointerleave",this.onTriggerLeave),this.trigger.addEventListener("focusin",this.onTriggerFocusIn),this.trigger.addEventListener("focusout",this.onTriggerFocusOut)}detachTriggerListeners(){if(!this.trigger)return;const t=(this.trigger.getAttribute("aria-describedby")||"").split(/\s+/).filter((t=>t&&t!==this.host.id));t.length?this.trigger.setAttribute("aria-describedby",t.join(" ")):this.trigger.removeAttribute("aria-describedby"),this.trigger.removeEventListener("click",this.onTriggerClick),this.trigger.removeEventListener("keydown",this.onTriggerKeydown),this.trigger.removeEventListener("pointerenter",this.onTriggerEnter),this.trigger.removeEventListener("pointerleave",this.onTriggerLeave),this.trigger.removeEventListener("focusin",this.onTriggerFocusIn),this.trigger.removeEventListener("focusout",this.onTriggerFocusOut)}clearShowTimer(){null!==this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null)}clearHideTimer(){null!==this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)}clearTimers(){this.clearShowTimer(),this.clearHideTimer()}setInteractionOpen(t,i){this.internalOpen!==t&&(l(this.open)||(this.internalOpen=t),n(this.host,t?"open":"close",{open:t,reason:"action",trigger:i}))}onSurfaceEnter=()=>this.clearHideTimer();onTriggerClick=t=>{this.toggleOnClick&&(this.clearTimers(),this.pinned=!this.pinned,this.setInteractionOpen(this.pinned,0===t.detail?"keyboard":"pointer"))};onTriggerKeydown=t=>{"Escape"===t.key&&this.clearTimers()};onTriggerEnter=t=>{"touch"!==t.pointerType&&(this.clearHideTimer(),this.internalOpen||null!==this.showTimer||(this.showTimer=setTimeout((()=>{this.showTimer=null,this.setInteractionOpen(!0,"pointer")}),Math.max(0,this.showDelay))))};onTriggerLeave=()=>{this.clearShowTimer(),this.focused||this.pinned||!this.internalOpen||null!==this.hideTimer||(this.hideTimer=setTimeout((()=>{this.hideTimer=null,this.setInteractionOpen(!1,"pointer")}),Math.max(0,this.hideDelay)))};onTriggerFocusIn=()=>{this.focused=!0,this.clearTimers(),this.setInteractionOpen(!0,"keyboard")};onTriggerFocusOut=t=>{const i=t.relatedTarget;i&&this.host.contains(i)||(this.focused=!1,this.pinned=!1,this.clearTimers(),this.setInteractionOpen(!1,"keyboard"))};handleRequestClose(t,i){("escape"===t||"light-dismiss"===t&&this.toggleOnClick)&&(this.pinned=!1,this.clearTimers(),l(this.open)||(this.internalOpen=!1),n(this.host,"close",{open:!1,reason:t,trigger:i}))}render(){return e(o,{key:"fd4d81febd147b846aca66e94f25d56f14b171dc",role:"tooltip",hidden:!this.internalOpen,"data-open":this.internalOpen?"":void 0},e("div",{key:"d31ac8c0e087becd7e60459f2cd894a9b15e95fa",class:"tooltip__surface"},e("slot",{key:"06e7aac9b6992a9cf0f92c9d356b97d18fb2da8b"})))}static get watchers(){return{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncOverlay:0}]}}static get style(){return":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}}"}},[769,"ui-tooltip",{for:[1],open:[4],defaultOpen:[4,"default-open"],placement:[1],showDelay:[2,"show-delay"],hideDelay:[2,"hide-delay"],toggleOnClick:[4,"toggle-on-click"],internalOpen:[32]},void 0,{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncOverlay:0}]}]);function u(){"undefined"!=typeof customElements&&["ui-tooltip"].forEach((t=>{"ui-tooltip"===t&&(customElements.get(r(t))||customElements.define(r(t),p))}))}export{p as U,u as d}
@@ -1 +1 @@
1
- import{p as e,t,H as a,h as n,c as o}from"./p-Bh_1GxOD.js";import{D as s,a as r}from"./p-Drw41pSY.js";const i=e(class extends a{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow()}get host(){return this}nearRadius=s;coordinator=null;componentDidLoad(){this.connectCoordinator()}disconnectedCallback(){this.coordinator?.destroy(),this.coordinator=null}connectCoordinator(){this.coordinator?.destroy(),this.coordinator=r(this.host,{nearRadius:this.nearRadius})}onSlotChange=()=>{this.coordinator?.refresh()};render(){return n(o,{key:"f500fa48554ed6224efd2dbe9632880bf0a15a19"},n("slot",{key:"37c5c5b7925b260ff8f9edd411ee6c90a12a4909",onSlotchange:this.onSlotChange}))}static get watchers(){return{nearRadius:[{connectCoordinator:0}]}}static get style(){return":host{display:contents;--ui-affordance-scope-engaged:0}:host([data-ui-interaction='engaged']){--ui-affordance-scope-engaged:1}"}},[769,"ui-affordance-scope",{nearRadius:[514,"near-radius"]},void 0,{nearRadius:[{connectCoordinator:0}]}]),c=i,d=function(){"undefined"!=typeof customElements&&["ui-affordance-scope"].forEach((e=>{"ui-affordance-scope"===e&&(customElements.get(t(e))||customElements.define(t(e),i))}))};export{c as UiAffordanceScope,d as defineCustomElement}
1
+ import{p as e,t,H as a,h as n,c as o}from"./p-Bh_1GxOD.js";import{D as s,a as i}from"./p-B_DaIVEY.js";const r=e(class extends a{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow()}get host(){return this}nearRadius=s;coordinator=null;componentDidLoad(){this.connectCoordinator()}disconnectedCallback(){this.coordinator?.destroy(),this.coordinator=null}connectCoordinator(){this.coordinator?.destroy(),this.coordinator=i(this.host,{nearRadius:this.nearRadius})}onSlotChange=()=>{this.coordinator?.refresh()};render(){return n(o,{key:"f500fa48554ed6224efd2dbe9632880bf0a15a19"},n("slot",{key:"37c5c5b7925b260ff8f9edd411ee6c90a12a4909",onSlotchange:this.onSlotChange}))}static get watchers(){return{nearRadius:[{connectCoordinator:0}]}}static get style(){return":host{display:contents;--ui-affordance-scope-engaged:0}:host([data-ui-interaction='engaged']){--ui-affordance-scope-engaged:1}"}},[769,"ui-affordance-scope",{nearRadius:[514,"near-radius"]},void 0,{nearRadius:[{connectCoordinator:0}]}]),c=r,d=function(){"undefined"!=typeof customElements&&["ui-affordance-scope"].forEach((e=>{"ui-affordance-scope"===e&&(customElements.get(t(e))||customElements.define(t(e),r))}))};export{c as UiAffordanceScope,d as defineCustomElement}
@@ -1 +1 @@
1
- import{p as i,H as t,d as s,h as e,c as a,t as o}from"./p-Bh_1GxOD.js";import{c as r}from"./p-Drw41pSY.js";import{c as h,o as n}from"./p-C-0syqXZ.js";import{d as l}from"./p-Vc4ExHFc.js";import{d}from"./p-DWN2m6ta.js";const u=i(class extends t{constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.queryChange=s(this,"query-change"),this.valueChange=s(this,"value-change"),this.freeEntry=s(this,"free-entry"),this.createEntry=s(this,"create-entry"),this.dependencyInvalidate=s(this,"dependency-invalidate"),this.validationChange=s(this,"validation-change"),this.optionsChange=s(this,"options-change"),this.addItem=s(this,"add-item"),this.removeItem=s(this,"remove-item"),this.createItem=s(this,"create-item")}get host(){return this}label="";placeholder="";name="";value;defaultValue;multiple=!1;tokenSeparators=[];query;defaultQuery="";config={};disabled=!1;readOnly=!1;required=!1;size="md";labelVisibility="visible";disclosure=!1;clearable=!1;help="";queryChange;valueChange;freeEntry;createEntry;dependencyInvalidate;validationChange;optionsChange;addItem;removeItem;createItem;raw="";display="";selected=null;expanded=!1;rows=[];active=-1;loading=!1;helpOpen=!1;lookupError="";validation={status:"pristine",touched:!1,dirty:!1,issues:[]};input;popup;field;surface;lookup;validationRun;lookupTimer;composing=!1;initialRaw="";overlayId="ui-combobox-"+Math.random().toString(36).slice(2);alive=!1;fullSet=!1;knownOptions=new Map;awaitingLabel=null;proposedChange;formattedRaw;formattedWith;get items(){return this.multiple&&Array.isArray(this.value)?this.value:[]}get selectedValues(){return new Set(this.items.map((i=>i.value)))}componentWillLoad(){if(this.multiple)return this.selected=null,this.raw=this.query??this.defaultQuery,this.display=this.raw,this.initialRaw=this.raw,void this.applyServerIssues();this.selected=void 0!==this.value?this.value:this.defaultValue??null,this.raw=this.query??this.defaultQuery,void 0!==this.query||this.raw||null===this.selected||(this.raw=this.config.options?.find((i=>i.value===this.selected))?.label??this.selected),void 0===this.query&&null!==this.selected&&this.raw===this.selected&&(this.awaitingLabel=this.selected),this.display=this.raw,this.initialRaw=this.raw,this.applyServerIssues()}connectedCallback(){this.alive=!0,this.setupSurface()}componentDidLoad(){this.setupSurface()}componentDidUpdate(){this.input&&!this.composing&&this.input.value!==this.display&&(this.input.value=this.display),this.expanded&&this.surface?.refresh()}disconnectedCallback(){this.alive=!1,this.close(),this.validationRun?.abort(),this.surface?.destroy(),this.surface=void 0}setupSurface(){!this.surface&&this.popup&&this.field&&(this.surface=r(this.popup,{anchor:this.field,placement:"bottom-start"}))}syncValue(){if(!this.multiple&&void 0!==this.value){if(this.selected=this.value,void 0===this.query){const i=this.proposedChange,t=this.config.options?.find((i=>i.value===this.selected))??(null===this.selected?void 0:this.knownOptions.get(this.selected)),s=i?.value===this.selected?i.query:t?.label??this.selected??"";i?.value===this.selected&&s===this.raw||(this.raw=s,this.display=this.raw,this.formattedRaw=void 0),this.awaitingLabel=t||null===this.selected?null:this.selected}this.resetValidation()}}syncQuery(){void 0!==this.query&&this.query!==this.raw&&(void 0===this.value&&this.proposedChange?.query!==this.query&&(this.selected=null),this.awaitingLabel=null,this.formattedRaw=void 0,this.raw=this.query,this.display=this.raw,this.resetValidation(),this.expanded&&this.search("input"))}syncDisabled(){(this.disabled||this.readOnly)&&(this.close(),this.resetValidation())}syncConfig(i,t){if(this.validationRun?.abort(),i.provider===t?.provider&&i.context===t?.context||this.knownOptions.clear(),i.context!==t?.context){this.close();const t=i.invalidation??"retain-query";this.multiple?"clear"===t&&this.setMultiQuery("","programmatic"):this.commit("retain"===t?this.selected:null,"clear"===t?"":this.raw,null,"invalidation","programmatic"),this.validation={status:"pristine",touched:!1,dirty:this.raw!==this.initialRaw,issues:[]}}this.applyServerIssues(),this.expanded&&this.search("context")}applyServerIssues(){const i=this.config.issues??[];i.length?this.setValidation({issues:i},this.validation.touched):this.resetValidation()}resetValidation(){this.validationRun?.abort(),this.validation={status:"pristine",touched:this.validation.touched,dirty:this.raw!==this.initialRaw,issues:[]},this.validationChange?.emit(this.validation)}cancelLookup(){clearTimeout(this.lookupTimer),this.lookup?.abort(),this.lookup=void 0,this.loading=!1}close(){this.expanded=!1,this.active=-1,this.cancelLookup(),this.surface?.hide(),h(this.overlayId)}open(i="input"){this.disabled||this.readOnly||(this.expanded=!0,this.popup&&this.field&&(this.popup.style.minWidth=this.field.getBoundingClientRect().width+"px"),this.surface?.show(),n({id:this.overlayId,element:this.popup,relatedElements:[this.host],modal:!1,requestClose:()=>this.close()}),this.search(i))}search(i){this.cancelLookup(),this.fullSet="disclosure"===i,this.active=-1,this.lookupError="";const t=this.config,s=this.fullSet?"":this.raw,e=new AbortController;this.lookup=e;const a=i=>{if(e.signal.aborted||!this.alive)return;for(const t of i)this.knownOptions.set(t.value,t);const a=null===this.selected?void 0:this.knownOptions.get(this.selected);void 0===this.query&&this.awaitingLabel===this.selected&&a&&(this.raw=a.label,this.display=this.raw,this.awaitingLabel=null,this.formattedRaw=void 0,this.resetValidation());const o=new Set,r=this.multiple?this.selectedValues:void 0;this.rows=i.filter((i=>!o.has(i.id)&&(o.add(i.id),!!this.fullSet||(r?!r.has(i.value)&&(t.filter?t.filter(i,s,t.context):i.label.toLocaleLowerCase().includes(s.toLocaleLowerCase())):t.filter?t.filter(i,s,t.context):!!t.provider||i.label.toLocaleLowerCase().includes(s.toLocaleLowerCase())))));const h=new Map;for(const i of this.rows){const t=i.group??"";h.has(t)||h.set(t,[]),h.get(t).push(i)}this.rows=[...h.values()].flat(),this.loading=!1,this.optionsChange.emit(this.rows)};t.provider?(this.rows=[],this.loading=!0,this.lookupTimer=setTimeout((async()=>{try{a(await t.provider({query:s,context:t.context,signal:e.signal,reason:i}))}catch(i){if(e.signal.aborted||!this.alive)return;this.loading=!1,this.lookupError=i instanceof Error?i.message:"Unable to load suggestions."}}),"disclosure"===i?0:Math.max(0,t.debounce??200))):a(t.options??[])}get canCreate(){const i=this.config.options?[...this.config.options,...this.rows]:this.rows;return!(!this.config.allowCreate||!this.raw.trim()||this.loading||this.lookupError||i.some((i=>i.label.toLocaleLowerCase()===this.raw.toLocaleLowerCase())))}format(i){if((this.config.formatOn??"blur")!==i||!this.input)return;if(this.formattedRaw===this.raw&&this.formattedWith===this.config.format)return;const t=function(i,t,s){const e={display:i,selection:t};if(!s)return e;let a;try{a=s(i,t)}catch{return e}if(!a)return e;const o=Array.from(i);let r=0;for(const i of a.display)i===o[r]&&(r+=1);return!Number.isInteger(a.selection.start)||!Number.isInteger(a.selection.end)||r!==o.length||a.selection.start<0||a.selection.end<a.selection.start||a.selection.end>a.display.length?e:a}(this.raw,{start:this.input.selectionStart??this.raw.length,end:this.input.selectionEnd??this.raw.length,direction:this.input.selectionDirection??"none"},this.config.format);this.formattedRaw=this.raw,this.formattedWith=this.config.format,this.display=t.display,this.input.value!==t.display&&(this.input.value=t.display,this.input.setSelectionRange(t.selection.start,t.selection.end,t.selection.direction))}onInput=i=>{this.composing||i.isComposing||(this.awaitingLabel=null,this.formattedRaw=void 0,this.raw=this.input.value,this.display=this.raw,this.resetValidation(),this.format("input"),this.queryChange.emit({query:this.raw,display:this.display,trigger:"keyboard"}),null!==this.selected&&this.commit(null,this.raw,null,"clear","keyboard"),this.open(),"input"===this.config.validateOn&&this.validate(),queueMicrotask((()=>{void 0!==this.query&&this.query!==this.raw&&this.syncQuery()})))};commit(i,t,s,e,a){this.awaitingLabel=null;const o=t!==this.raw;void 0===this.value&&(this.selected=i),void 0===this.query&&o&&(this.raw=t,this.display=t,this.formattedRaw=void 0),this.resetValidation();const r={value:i,query:t,option:s,kind:e,trigger:a},h={value:i,query:t};this.proposedChange=h,this.valueChange.emit(r),o&&this.queryChange.emit({query:t,display:t,trigger:a}),"create"===e&&this.createEntry.emit(r),"free-entry"===e&&this.freeEntry.emit(r),"invalidation"===e&&this.dependencyInvalidate.emit(r),queueMicrotask((()=>{this.proposedChange===h&&(void 0!==this.value&&this.value!==h.value&&this.syncValue(),void 0!==this.query&&this.query!==h.query&&(void 0===this.value&&(this.selected=null,this.resetValidation()),this.syncQuery()),this.proposedChange=void 0)}))}choose(i,t){const s=this.rows[i];if(!s?.disabled){if(this.multiple){if(s)this.addSelectedItem(s,t);else{if(!this.canCreate||i!==this.rows.length)return;this.createSelectedItem(this.raw.trim(),t)}return this.setMultiQuery("",t),this.close(),void this.input?.focus()}if(s)this.commit(s.value,s.label,s,"selection",t);else{if(!this.canCreate||i!==this.rows.length)return;this.commit(null,this.raw,null,"create",t)}this.close(),this.input?.focus(),"submit"!==this.config.validateOn&&queueMicrotask((()=>{this.validate()}))}}emitItems(i){this.valueChange.emit(i)}setMultiQuery(i,t){void 0===this.query&&(this.raw=i,this.display=i,this.formattedRaw=void 0),this.input&&(this.input.value=i),this.queryChange.emit({query:i,display:i,trigger:t})}addSelectedItem(i,t){this.addItem.emit({item:i,index:this.items.length,trigger:t}),this.emitItems([...this.items,i])}createSelectedItem(i,t){i&&this.createItem.emit({query:i,trigger:t})}commitQuery(i){const t=this.raw.trim();if(!t)return;const s=t.toLocaleLowerCase(),e=this.rows.find((i=>i.label.trim().toLocaleLowerCase()===s));e?(this.setMultiQuery("",i),this.addSelectedItem(e,i)):this.config.allowCreate&&(this.setMultiQuery("",i),this.createSelectedItem(t,i))}removeItemAt(i,t){const s=this.items[i];!s||s.disabled||this.disabled||this.readOnly||(this.removeItem.emit({item:s,index:i,trigger:t}),this.emitItems(this.items.filter(((t,s)=>s!==i))),requestAnimationFrame((()=>{const t=this.host.shadowRoot?.querySelectorAll('[part="item"]')??[],e=t[Math.min(i,t.length-1)]??t[i-1];e&&e.dataset.value!==s.value?e.focus():this.focusInput()})))}focusItem(i){this.host.shadowRoot?.querySelectorAll('[part="item"]')[i]?.focus()}onItemKeyDown=(i,t)=>{i.altKey||i.ctrlKey||i.metaKey||i.shiftKey||("ArrowLeft"===i.key?(i.preventDefault(),i.stopPropagation(),this.focusItem(Math.max(0,t-1))):"ArrowRight"===i.key?(i.preventDefault(),i.stopPropagation(),t===this.items.length-1?this.focusInput():this.focusItem(t+1)):"Backspace"!==i.key&&"Delete"!==i.key||(i.preventDefault(),i.stopPropagation(),this.removeItemAt(t,"keyboard")))};handleMultipleKeydown(i){return!(i.altKey||i.ctrlKey||i.metaKey||i.shiftKey||(this.tokenSeparators.includes(i.key)?(i.preventDefault(),i.stopPropagation(),this.commitQuery("keyboard"),0):this.raw||(this.input?.selectionStart??0)>0||("ArrowLeft"===i.key&&this.items.length?(i.preventDefault(),this.focusItem(this.items.length-1),0):"Backspace"!==i.key||!this.items.length||(i.preventDefault(),this.removeItemAt(this.items.length-1,"keyboard"),0))))}move(i){const t=this.rows.flatMap(((i,t)=>i.disabled?[]:[t]));if(this.canCreate&&t.push(this.rows.length),!t.length)return;const s=t.indexOf(this.active);this.active=t["Home"===i?0:"End"===i?t.length-1:"ArrowDown"===i?Math.min(s+1,t.length-1):s<0?t.length-1:Math.max(0,s-1)],requestAnimationFrame((()=>this.host.shadowRoot?.getElementById("option-"+this.active)?.scrollIntoView({block:"nearest"})))}onKeydown=i=>{if(!(this.composing||i.isComposing||this.disabled||this.readOnly||this.multiple&&this.handleMultipleKeydown(i)))return"Escape"===i.key&&this.expanded?(i.preventDefault(),i.stopPropagation(),void this.close()):void("Tab"!==i.key?i.altKey||i.ctrlKey||i.metaKey||i.shiftKey||("ArrowDown"===i.key||"ArrowUp"===i.key?(i.preventDefault(),this.expanded||this.open("disclosure"),this.move(i.key)):("Home"===i.key||"End"===i.key)&&this.expanded&&this.active>=0?(i.preventDefault(),this.move(i.key)):"Enter"===i.key&&this.expanded&&(this.active>=0?(i.preventDefault(),this.choose(this.active,"keyboard")):this.config.allowFreeText&&(i.preventDefault(),this.commit(null,this.raw,null,"free-entry","keyboard"),this.close()))):this.close())};onFocusOut=i=>{i.relatedTarget instanceof Node&&this.host.shadowRoot?.contains(i.relatedTarget)||(this.close(),this.format("blur"),this.validation={...this.validation,touched:!0},!this.multiple&&this.config.allowFreeText&&null===this.selected&&this.commit(null,this.raw,null,"free-entry","keyboard"),"blur"===(this.config.validateOn??"blur")&&this.validate())};setValidation(i,t=this.validation.touched){const s=i.issues.some((i=>"warning"!==i.severity));this.validation={status:s?"error":i.issues.length?"warning":"valid",touched:t,dirty:this.raw!==this.initialRaw,...i},this.validationChange?.emit(this.validation)}async validate(){this.validationRun?.abort();const i=new AbortController;this.validationRun=i,this.validation={...this.validation,status:"pending",output:void 0},this.validationChange.emit(this.validation);try{const t=await async function(i,t){let s=i.raw,e=[];const a=()=>i.signal.throwIfAborted();try{if(a(),t.parse&&(s=await t.parse(i.raw,i)),a(),t.schema){const i=await t.schema["~standard"].validate(s);a(),i.issues?e=i.issues:"value"in i&&(s=i.value)}if(!e.some((i=>"warning"!==i.severity))&&(t.normalize&&(s=await t.normalize(s,i)),a(),t.validator)){const o=await t.validator(s,i);a(),e=[...e,...o.issues??[]],"output"in o&&(s=o.output)}}catch(i){a(),e=[{message:i instanceof Error?i.message:"Unable to validate this value."}]}return e=[...e,...t.issues??[]],{output:e.some((i=>"warning"!==i.severity))?void 0:s,issues:e}}({raw:this.raw,value:this.selected,context:this.config.context,signal:i.signal},this.config);this.required&&!this.raw.trim()?t.issues=[...t.issues,{message:"A value is required."}]:!this.raw||null!==this.selected||this.config.allowFreeText||this.config.allowCreate||(t.issues=[...t.issues,{message:"Choose a suggestion."}]),t.issues.some((i=>"warning"!==i.severity))&&(t.output=void 0),!i.signal.aborted&&this.alive&&this.setValidation(t)}catch{}return this.validation}async focusInput(){this.input?.focus()}render(){const i=[this.helpOpen?"help-text":"",this.validation.issues.length?"validation":""].filter(Boolean).join(" ")||void 0,t=this.loading?"Loading suggestions…":this.lookupError||(this.expanded?this.rows.length+" suggestions available.":""),s=[...new Set(this.rows.map((i=>i.group??"")))];return e(a,{key:"fc4c0192d3be88d8c0199ae1bcca44232bd22351","data-size":this.size,"data-validation":this.validation.status,onFocusout:this.onFocusOut},e("label",{key:"bdd0d244c6ef448978fa77aac3a2d3b71d713553",htmlFor:"input",part:"label",class:"sr-only"===this.labelVisibility?"sr-only":void 0},this.label,this.required?" *":""),e("div",{key:"afb3972aab52171a3b25ede863c31059e56f5d91",class:"field",part:"field",ref:i=>this.field=i,onClick:i=>{i.composedPath().some((i=>i instanceof HTMLButtonElement))||this.input?.focus()}},e("slot",{key:"65e4e201d6c11cd2638e392e1298662de7ba4d57",name:"start"}),this.multiple&&e("div",{key:"b80b5b85fa0540139b9756fcc494aef9df245c15",class:"items",role:"group","aria-label":"Selected "+this.label},this.items.map(((i,t)=>e("button",{type:"button",part:"item",class:"item","data-value":i.value,tabIndex:-1,disabled:this.disabled||this.readOnly||i.disabled,"aria-label":i.label+", press Delete or Backspace to remove",onKeyDown:i=>this.onItemKeyDown(i,t)},e("slot",{name:"item-"+i.id},e("ui-chip",{appearance:"pill"},i.label)))))),e("input",{key:"64f76055ae412cc87119270eec10c69000a72563",id:"input",ref:i=>this.input=i,role:"combobox","aria-autocomplete":"list","aria-expanded":this.expanded+"","aria-controls":"listbox","aria-activedescendant":this.expanded&&this.active>=0?"option-"+this.active:void 0,"aria-describedby":i,"aria-invalid":("error"===this.validation.status)+"","aria-busy":("pending"===this.validation.status)+"",value:this.display,placeholder:this.placeholder,name:this.name||void 0,disabled:this.disabled,readOnly:this.readOnly,required:this.required,autoComplete:"off",part:"input",onInput:this.onInput,onKeyDown:this.onKeydown,onCompositionstart:()=>this.composing=!0,onCompositionend:()=>{this.composing=!1,this.onInput(new InputEvent("input"))}}),this.clearable&&e("button",{key:"eac4c18dadcea92065af4ecd871d925ef1248d47",type:"button",part:"affordance","aria-label":"Clear "+this.label,disabled:this.disabled||this.readOnly,onClick:()=>{this.commit(null,"",null,"clear","pointer"),this.close(),this.input?.focus()}},"×"),this.help&&e("button",{key:"9a559d49a495ead3dbf159f170c594e0aaa0d0d0",id:"help",type:"button",part:"affordance","aria-label":"Help for "+this.label,disabled:this.disabled},e("span",{key:"73940e568b976f85399d5baa5e247a4a606d0039","aria-hidden":"true"},"?")),this.disclosure&&e("button",{key:"30dd6746ffb121888a4c4fb6df54720906badf78",type:"button",part:"affordance","aria-label":"Suggestions for "+this.label,"aria-controls":"listbox","aria-expanded":this.expanded+"",disabled:this.disabled||this.readOnly,onClick:()=>{this.expanded?this.close():this.open("disclosure"),this.input?.focus()}},e("span",{key:"7d3b10a765ee0a6c40d7b0b49e98c676a5837944","aria-hidden":"true"},"⌄"))),this.help&&e("ui-tooltip",{key:"efff00f45dc281b727789eb2aa84ff772bb5c925",id:"help-text",for:"help",toggleOnClick:!0,onOpen:()=>this.helpOpen=!0,onClose:()=>this.helpOpen=!1},this.help),e("div",{key:"770bc12b873026b571bd3ae2a80416e8af52b8d4",class:"popup",part:"popup",hidden:!this.expanded,ref:i=>this.popup=i},e("div",{key:"ed48c8dd8b672a577d567ca5e795b8a53fde2761",id:"listbox",role:"listbox","aria-label":this.label+" suggestions","aria-busy":this.loading+""},s.map((i=>e("div",{role:i?"group":"presentation","aria-label":i||void 0},i&&e("div",{class:"group",part:"group"},i),this.rows.map(((t,s)=>(t.group??"")!==i?null:e("div",{id:"option-"+s,role:"option","aria-selected":(this.selected===t.value)+"","aria-disabled":!!t.disabled+"","data-active":this.active===s?"":void 0,part:"option",class:"option",onPointerDown:i=>i.preventDefault(),onClick:()=>this.choose(s,"pointer")},e("slot",{name:"option-"+t.id},e("span",{class:"primary",part:"option-primary"},t.label),t.description&&e("span",{class:"secondary",part:"option-secondary"},t.description)))))))),this.canCreate&&e("div",{key:"43215f449bbccde407ef818cee473f69870f6f8c",id:"option-"+this.rows.length,role:"option","aria-selected":"false",class:"option",part:"option","data-active":this.active===this.rows.length?"":void 0,onPointerDown:i=>i.preventDefault(),onClick:()=>this.choose(this.rows.length,"pointer")},e("slot",{key:"3ff70ff3ab8e24afc369a26e8474e7d1220ed6eb",name:"create"},"Create “",this.raw,"”"))),this.loading?e("div",{class:"message"},e("slot",{name:"loading"},"Loading suggestions…")):this.lookupError?e("div",{class:"message"},e("slot",{name:"error"},this.lookupError)):this.rows.length||this.canCreate?null:e("div",{class:"message"},e("slot",{name:"empty"},"No suggestions.")),e("slot",{key:"8b1fbd4f5c372393d294d8c218ae1785e6b0334f",name:"footer"})),e("div",{key:"18e68687f04e35535edee363683523ce6bbb0291",id:"validation",class:"message",part:"validation",hidden:!this.validation.issues.length},this.validation.issues.map((i=>e("div",null,i.message)))),e("div",{key:"e4a7db06abcfaf08b8ac592107531a13ef3a5897",class:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true"},t," ","pending"===this.validation.status?"Checking value…":this.validation.issues.map((i=>i.message)).join(" ")))}static get watchers(){return{value:[{syncValue:0}],query:[{syncQuery:0}],disabled:[{syncDisabled:0}],readOnly:[{syncDisabled:0}],config:[{syncConfig:0}]}}static get style(){return":host{display:grid;gap:var(--ui-space-1);min-inline-size:0;color:var(--ui-text-primary);font:inherit}label{color:var(--ui-field-label-color, var(--ui-text-primary));font-size:var(--ui-field-label-size, 0.875rem);font-weight:var(--ui-field-label-weight, 500)}.field{display:flex;min-inline-size:0;border:1px solid var(--ui-control-border, var(--ui-border-default));border-radius:var(--ui-radius-2);background:var(--ui-control-surface, var(--ui-surface-default))}.field:focus-within{border-color:var(--ui-control-focus, var(--ui-focus-ring));outline:2px solid var(--ui-control-focus, var(--ui-focus-ring));outline-offset:1px}input{appearance:none;width:100%;min-inline-size:0;min-block-size:var(--ui-control-min-block-size, 2.75rem);box-sizing:border-box;border:0;border-radius:inherit;background:transparent;color:inherit;font:inherit;line-height:var(--ui-line-height-md);padding:var(--ui-space-2) var(--ui-space-3);margin:0;outline:none}:host([data-size='sm']) input{min-block-size:var(--ui-field-compact-size, 2rem);padding:var(--ui-space-1) var(--ui-space-2)}button{appearance:none;border:0;border-radius:var(--ui-radius-2);background:transparent;color:var(--ui-field-affordance-color, var(--ui-text-secondary));font:inherit;font-weight:var(--ui-field-affordance-weight, 400);min-inline-size:2rem;padding:var(--ui-space-1);cursor:pointer}button:hover:enabled{background:var(--ui-surface-muted);color:var(--ui-text-primary)}button:focus-visible{outline:2px solid var(--ui-focus-ring);outline-offset:-3px}input:disabled,button:disabled{color:var(--ui-text-muted);cursor:not-allowed}.field:has(input:disabled){background:var(--ui-control-surface-disabled, var(--ui-surface-muted))}:host([data-validation='error']) .field{border-color:var(--ui-danger-solid, var(--ui-accent-active))}.popup{box-sizing:border-box;min-inline-size:12rem;max-inline-size:calc(100vw - 1rem);max-block-size:var(--ui-combobox-max-block-size, 18rem);overflow:auto;margin:0;padding:var(--ui-space-1);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-2);background:var(--ui-surface-elevated);color:var(--ui-text-primary);box-shadow:var(--ui-shadow-md)}[hidden]{display:none !important}.option{padding:var(--ui-space-2) var(--ui-space-3);border-radius:var(--ui-radius-1);cursor:pointer;overflow-wrap:anywhere}.option:hover,.option[data-active]{background:var(--ui-surface-muted);outline:1px solid var(--ui-focus-ring);outline-offset:-1px}.option[aria-disabled='true']{color:var(--ui-text-muted);cursor:not-allowed}.primary{display:block;color:var(--ui-option-primary-color, var(--ui-text-primary));font-weight:var(--ui-option-primary-weight, 500)}.secondary{display:block;color:var(--ui-option-secondary-color, var(--ui-text-secondary));font-weight:var(--ui-option-secondary-weight, 400);font-size:var(--ui-font-size-sm)}.message,.group{color:var(--ui-field-message-color, var(--ui-text-secondary));font-weight:var(--ui-field-message-weight, 400);font-size:var(--ui-font-size-sm);line-height:var(--ui-line-height-md);overflow-wrap:anywhere}.group,.popup .message{padding:var(--ui-space-2) var(--ui-space-3)}.sr-only{position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@media (pointer: coarse){button{min-inline-size:2.75rem;min-block-size:2.75rem}}@media (forced-colors: active){.field,.popup{border-color:CanvasText}.option[data-active]{outline-color:Highlight}}:host([multiple]) .field{flex-wrap:wrap;align-items:center;gap:var(--ui-space-1);min-block-size:var(--ui-multi-combobox-min-block-size, 2.5rem);padding:var(--ui-space-1)}:host([multiple]) input{flex:1 0 var(--ui-multi-combobox-input-min-inline-size, 5rem);width:auto;min-block-size:1.75rem;padding:var(--ui-space-0-5) var(--ui-space-1)}.items{display:contents}.item{appearance:none;display:inline-flex;min-inline-size:0;max-inline-size:min(100%, var(--ui-multi-combobox-item-max-inline-size, 12rem));overflow:hidden;padding:0;border:0;border-radius:var(--ui-radius-1);background:transparent;color:inherit;font:inherit;cursor:default}.item>slot{display:block;min-inline-size:0;max-inline-size:100%;overflow:hidden}.item>slot::slotted(*){min-inline-size:0;max-inline-size:100%}.item:focus-visible{outline:2px solid var(--ui-focus-ring);outline-offset:1px}.item:disabled{opacity:.6}"}},[769,"ui-combobox",{label:[1],placeholder:[1],name:[1],value:[1],defaultValue:[1,"default-value"],multiple:[516],tokenSeparators:[16],query:[1],defaultQuery:[1,"default-query"],config:[16],disabled:[4],readOnly:[4,"readonly"],required:[4],size:[1],labelVisibility:[1,"label-visibility"],disclosure:[4],clearable:[4],help:[1],raw:[32],display:[32],selected:[32],expanded:[32],rows:[32],active:[32],loading:[32],helpOpen:[32],lookupError:[32],validation:[32],validate:[64],focusInput:[64]},void 0,{value:[{syncValue:0}],query:[{syncQuery:0}],disabled:[{syncDisabled:0}],readOnly:[{syncDisabled:0}],config:[{syncConfig:0}]}]),c=u,p=function(){"undefined"!=typeof customElements&&["ui-combobox","ui-chip","ui-tooltip"].forEach((i=>{switch(i){case"ui-combobox":customElements.get(o(i))||customElements.define(o(i),u);break;case"ui-chip":customElements.get(o(i))||l();break;case"ui-tooltip":customElements.get(o(i))||d()}}))};export{c as UiCombobox,p as defineCustomElement}
1
+ import{p as i,H as t,d as s,h as e,c as a,t as o}from"./p-Bh_1GxOD.js";import{c as r}from"./p-B_DaIVEY.js";import{c as h,o as n}from"./p-C-0syqXZ.js";import{d as l}from"./p-Vc4ExHFc.js";import{d}from"./p-BzaB_bXo.js";const u=i(class extends t{constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.queryChange=s(this,"query-change"),this.valueChange=s(this,"value-change"),this.freeEntry=s(this,"free-entry"),this.createEntry=s(this,"create-entry"),this.dependencyInvalidate=s(this,"dependency-invalidate"),this.validationChange=s(this,"validation-change"),this.optionsChange=s(this,"options-change"),this.addItem=s(this,"add-item"),this.removeItem=s(this,"remove-item"),this.createItem=s(this,"create-item")}get host(){return this}label="";placeholder="";name="";value;defaultValue;multiple=!1;tokenSeparators=[];query;defaultQuery="";config={};disabled=!1;readOnly=!1;required=!1;size="md";labelVisibility="visible";disclosure=!1;clearable=!1;help="";queryChange;valueChange;freeEntry;createEntry;dependencyInvalidate;validationChange;optionsChange;addItem;removeItem;createItem;raw="";display="";selected=null;expanded=!1;rows=[];active=-1;loading=!1;helpOpen=!1;lookupError="";validation={status:"pristine",touched:!1,dirty:!1,issues:[]};input;popup;field;surface;lookup;validationRun;lookupTimer;composing=!1;initialRaw="";overlayId="ui-combobox-"+Math.random().toString(36).slice(2);alive=!1;fullSet=!1;knownOptions=new Map;awaitingLabel=null;proposedChange;formattedRaw;formattedWith;get items(){return this.multiple&&Array.isArray(this.value)?this.value:[]}get selectedValues(){return new Set(this.items.map((i=>i.value)))}componentWillLoad(){if(this.multiple)return this.selected=null,this.raw=this.query??this.defaultQuery,this.display=this.raw,this.initialRaw=this.raw,void this.applyServerIssues();this.selected=void 0!==this.value?this.value:this.defaultValue??null,this.raw=this.query??this.defaultQuery,void 0!==this.query||this.raw||null===this.selected||(this.raw=this.config.options?.find((i=>i.value===this.selected))?.label??this.selected),void 0===this.query&&null!==this.selected&&this.raw===this.selected&&(this.awaitingLabel=this.selected),this.display=this.raw,this.initialRaw=this.raw,this.applyServerIssues()}connectedCallback(){this.alive=!0,this.setupSurface()}componentDidLoad(){this.setupSurface()}componentDidUpdate(){this.input&&!this.composing&&this.input.value!==this.display&&(this.input.value=this.display),this.expanded&&this.surface?.refresh()}disconnectedCallback(){this.alive=!1,this.close(),this.validationRun?.abort(),this.surface?.destroy(),this.surface=void 0}setupSurface(){!this.surface&&this.popup&&this.field&&(this.surface=r(this.popup,{anchor:this.field,placement:"bottom-start"}))}syncValue(){if(!this.multiple&&void 0!==this.value){if(this.selected=this.value,void 0===this.query){const i=this.proposedChange,t=this.config.options?.find((i=>i.value===this.selected))??(null===this.selected?void 0:this.knownOptions.get(this.selected)),s=i?.value===this.selected?i.query:t?.label??this.selected??"";i?.value===this.selected&&s===this.raw||(this.raw=s,this.display=this.raw,this.formattedRaw=void 0),this.awaitingLabel=t||null===this.selected?null:this.selected}this.resetValidation()}}syncQuery(){void 0!==this.query&&this.query!==this.raw&&(void 0===this.value&&this.proposedChange?.query!==this.query&&(this.selected=null),this.awaitingLabel=null,this.formattedRaw=void 0,this.raw=this.query,this.display=this.raw,this.resetValidation(),this.expanded&&this.search("input"))}syncDisabled(){(this.disabled||this.readOnly)&&(this.close(),this.resetValidation())}syncConfig(i,t){if(this.validationRun?.abort(),i.provider===t?.provider&&i.context===t?.context||this.knownOptions.clear(),i.context!==t?.context){this.close();const t=i.invalidation??"retain-query";this.multiple?"clear"===t&&this.setMultiQuery("","programmatic"):this.commit("retain"===t?this.selected:null,"clear"===t?"":this.raw,null,"invalidation","programmatic"),this.validation={status:"pristine",touched:!1,dirty:this.raw!==this.initialRaw,issues:[]}}this.applyServerIssues(),this.expanded&&this.search("context")}applyServerIssues(){const i=this.config.issues??[];i.length?this.setValidation({issues:i},this.validation.touched):this.resetValidation()}resetValidation(){this.validationRun?.abort(),this.validation={status:"pristine",touched:this.validation.touched,dirty:this.raw!==this.initialRaw,issues:[]},this.validationChange?.emit(this.validation)}cancelLookup(){clearTimeout(this.lookupTimer),this.lookup?.abort(),this.lookup=void 0,this.loading=!1}close(){this.expanded=!1,this.active=-1,this.cancelLookup(),this.surface?.hide(),h(this.overlayId)}open(i="input"){this.disabled||this.readOnly||(this.expanded=!0,this.popup&&this.field&&(this.popup.style.minWidth=this.field.getBoundingClientRect().width+"px"),this.surface?.show(),n({id:this.overlayId,element:this.popup,relatedElements:[this.host],modal:!1,requestClose:()=>this.close()}),this.search(i))}search(i){this.cancelLookup(),this.fullSet="disclosure"===i,this.active=-1,this.lookupError="";const t=this.config,s=this.fullSet?"":this.raw,e=new AbortController;this.lookup=e;const a=i=>{if(e.signal.aborted||!this.alive)return;for(const t of i)this.knownOptions.set(t.value,t);const a=null===this.selected?void 0:this.knownOptions.get(this.selected);void 0===this.query&&this.awaitingLabel===this.selected&&a&&(this.raw=a.label,this.display=this.raw,this.awaitingLabel=null,this.formattedRaw=void 0,this.resetValidation());const o=new Set,r=this.multiple?this.selectedValues:void 0;this.rows=i.filter((i=>!o.has(i.id)&&(o.add(i.id),!!this.fullSet||(r?!r.has(i.value)&&(t.filter?t.filter(i,s,t.context):i.label.toLocaleLowerCase().includes(s.toLocaleLowerCase())):t.filter?t.filter(i,s,t.context):!!t.provider||i.label.toLocaleLowerCase().includes(s.toLocaleLowerCase())))));const h=new Map;for(const i of this.rows){const t=i.group??"";h.has(t)||h.set(t,[]),h.get(t).push(i)}this.rows=[...h.values()].flat(),this.loading=!1,this.optionsChange.emit(this.rows)};t.provider?(this.rows=[],this.loading=!0,this.lookupTimer=setTimeout((async()=>{try{a(await t.provider({query:s,context:t.context,signal:e.signal,reason:i}))}catch(i){if(e.signal.aborted||!this.alive)return;this.loading=!1,this.lookupError=i instanceof Error?i.message:"Unable to load suggestions."}}),"disclosure"===i?0:Math.max(0,t.debounce??200))):a(t.options??[])}get canCreate(){const i=this.config.options?[...this.config.options,...this.rows]:this.rows;return!(!this.config.allowCreate||!this.raw.trim()||this.loading||this.lookupError||i.some((i=>i.label.toLocaleLowerCase()===this.raw.toLocaleLowerCase())))}format(i){if((this.config.formatOn??"blur")!==i||!this.input)return;if(this.formattedRaw===this.raw&&this.formattedWith===this.config.format)return;const t=function(i,t,s){const e={display:i,selection:t};if(!s)return e;let a;try{a=s(i,t)}catch{return e}if(!a)return e;const o=Array.from(i);let r=0;for(const i of a.display)i===o[r]&&(r+=1);return!Number.isInteger(a.selection.start)||!Number.isInteger(a.selection.end)||r!==o.length||a.selection.start<0||a.selection.end<a.selection.start||a.selection.end>a.display.length?e:a}(this.raw,{start:this.input.selectionStart??this.raw.length,end:this.input.selectionEnd??this.raw.length,direction:this.input.selectionDirection??"none"},this.config.format);this.formattedRaw=this.raw,this.formattedWith=this.config.format,this.display=t.display,this.input.value!==t.display&&(this.input.value=t.display,this.input.setSelectionRange(t.selection.start,t.selection.end,t.selection.direction))}onInput=i=>{this.composing||i.isComposing||(this.awaitingLabel=null,this.formattedRaw=void 0,this.raw=this.input.value,this.display=this.raw,this.resetValidation(),this.format("input"),this.queryChange.emit({query:this.raw,display:this.display,trigger:"keyboard"}),null!==this.selected&&this.commit(null,this.raw,null,"clear","keyboard"),this.open(),"input"===this.config.validateOn&&this.validate(),queueMicrotask((()=>{void 0!==this.query&&this.query!==this.raw&&this.syncQuery()})))};commit(i,t,s,e,a){this.awaitingLabel=null;const o=t!==this.raw;void 0===this.value&&(this.selected=i),void 0===this.query&&o&&(this.raw=t,this.display=t,this.formattedRaw=void 0),this.resetValidation();const r={value:i,query:t,option:s,kind:e,trigger:a},h={value:i,query:t};this.proposedChange=h,this.valueChange.emit(r),o&&this.queryChange.emit({query:t,display:t,trigger:a}),"create"===e&&this.createEntry.emit(r),"free-entry"===e&&this.freeEntry.emit(r),"invalidation"===e&&this.dependencyInvalidate.emit(r),queueMicrotask((()=>{this.proposedChange===h&&(void 0!==this.value&&this.value!==h.value&&this.syncValue(),void 0!==this.query&&this.query!==h.query&&(void 0===this.value&&(this.selected=null,this.resetValidation()),this.syncQuery()),this.proposedChange=void 0)}))}choose(i,t){const s=this.rows[i];if(!s?.disabled){if(this.multiple){if(s)this.addSelectedItem(s,t);else{if(!this.canCreate||i!==this.rows.length)return;this.createSelectedItem(this.raw.trim(),t)}return this.setMultiQuery("",t),this.close(),void this.input?.focus()}if(s)this.commit(s.value,s.label,s,"selection",t);else{if(!this.canCreate||i!==this.rows.length)return;this.commit(null,this.raw,null,"create",t)}this.close(),this.input?.focus(),"submit"!==this.config.validateOn&&queueMicrotask((()=>{this.validate()}))}}emitItems(i){this.valueChange.emit(i)}setMultiQuery(i,t){void 0===this.query&&(this.raw=i,this.display=i,this.formattedRaw=void 0),this.input&&(this.input.value=i),this.queryChange.emit({query:i,display:i,trigger:t})}addSelectedItem(i,t){this.addItem.emit({item:i,index:this.items.length,trigger:t}),this.emitItems([...this.items,i])}createSelectedItem(i,t){i&&this.createItem.emit({query:i,trigger:t})}commitQuery(i){const t=this.raw.trim();if(!t)return;const s=t.toLocaleLowerCase(),e=this.rows.find((i=>i.label.trim().toLocaleLowerCase()===s));e?(this.setMultiQuery("",i),this.addSelectedItem(e,i)):this.config.allowCreate&&(this.setMultiQuery("",i),this.createSelectedItem(t,i))}removeItemAt(i,t){const s=this.items[i];!s||s.disabled||this.disabled||this.readOnly||(this.removeItem.emit({item:s,index:i,trigger:t}),this.emitItems(this.items.filter(((t,s)=>s!==i))),requestAnimationFrame((()=>{const t=this.host.shadowRoot?.querySelectorAll('[part="item"]')??[],e=t[Math.min(i,t.length-1)]??t[i-1];e&&e.dataset.value!==s.value?e.focus():this.focusInput()})))}focusItem(i){this.host.shadowRoot?.querySelectorAll('[part="item"]')[i]?.focus()}onItemKeyDown=(i,t)=>{i.altKey||i.ctrlKey||i.metaKey||i.shiftKey||("ArrowLeft"===i.key?(i.preventDefault(),i.stopPropagation(),this.focusItem(Math.max(0,t-1))):"ArrowRight"===i.key?(i.preventDefault(),i.stopPropagation(),t===this.items.length-1?this.focusInput():this.focusItem(t+1)):"Backspace"!==i.key&&"Delete"!==i.key||(i.preventDefault(),i.stopPropagation(),this.removeItemAt(t,"keyboard")))};handleMultipleKeydown(i){return!(i.altKey||i.ctrlKey||i.metaKey||i.shiftKey||(this.tokenSeparators.includes(i.key)?(i.preventDefault(),i.stopPropagation(),this.commitQuery("keyboard"),0):this.raw||(this.input?.selectionStart??0)>0||("ArrowLeft"===i.key&&this.items.length?(i.preventDefault(),this.focusItem(this.items.length-1),0):"Backspace"!==i.key||!this.items.length||(i.preventDefault(),this.removeItemAt(this.items.length-1,"keyboard"),0))))}move(i){const t=this.rows.flatMap(((i,t)=>i.disabled?[]:[t]));if(this.canCreate&&t.push(this.rows.length),!t.length)return;const s=t.indexOf(this.active);this.active=t["Home"===i?0:"End"===i?t.length-1:"ArrowDown"===i?Math.min(s+1,t.length-1):s<0?t.length-1:Math.max(0,s-1)],requestAnimationFrame((()=>this.host.shadowRoot?.getElementById("option-"+this.active)?.scrollIntoView({block:"nearest"})))}onKeydown=i=>{if(!(this.composing||i.isComposing||this.disabled||this.readOnly||this.multiple&&this.handleMultipleKeydown(i)))return"Escape"===i.key&&this.expanded?(i.preventDefault(),i.stopPropagation(),void this.close()):void("Tab"!==i.key?i.altKey||i.ctrlKey||i.metaKey||i.shiftKey||("ArrowDown"===i.key||"ArrowUp"===i.key?(i.preventDefault(),this.expanded||this.open("disclosure"),this.move(i.key)):("Home"===i.key||"End"===i.key)&&this.expanded&&this.active>=0?(i.preventDefault(),this.move(i.key)):"Enter"===i.key&&this.expanded&&(this.active>=0?(i.preventDefault(),this.choose(this.active,"keyboard")):this.config.allowFreeText&&(i.preventDefault(),this.commit(null,this.raw,null,"free-entry","keyboard"),this.close()))):this.close())};onFocusOut=i=>{i.relatedTarget instanceof Node&&this.host.shadowRoot?.contains(i.relatedTarget)||(this.close(),this.format("blur"),this.validation={...this.validation,touched:!0},!this.multiple&&this.config.allowFreeText&&null===this.selected&&this.commit(null,this.raw,null,"free-entry","keyboard"),"blur"===(this.config.validateOn??"blur")&&this.validate())};setValidation(i,t=this.validation.touched){const s=i.issues.some((i=>"warning"!==i.severity));this.validation={status:s?"error":i.issues.length?"warning":"valid",touched:t,dirty:this.raw!==this.initialRaw,...i},this.validationChange?.emit(this.validation)}async validate(){this.validationRun?.abort();const i=new AbortController;this.validationRun=i,this.validation={...this.validation,status:"pending",output:void 0},this.validationChange.emit(this.validation);try{const t=await async function(i,t){let s=i.raw,e=[];const a=()=>i.signal.throwIfAborted();try{if(a(),t.parse&&(s=await t.parse(i.raw,i)),a(),t.schema){const i=await t.schema["~standard"].validate(s);a(),i.issues?e=i.issues:"value"in i&&(s=i.value)}if(!e.some((i=>"warning"!==i.severity))&&(t.normalize&&(s=await t.normalize(s,i)),a(),t.validator)){const o=await t.validator(s,i);a(),e=[...e,...o.issues??[]],"output"in o&&(s=o.output)}}catch(i){a(),e=[{message:i instanceof Error?i.message:"Unable to validate this value."}]}return e=[...e,...t.issues??[]],{output:e.some((i=>"warning"!==i.severity))?void 0:s,issues:e}}({raw:this.raw,value:this.selected,context:this.config.context,signal:i.signal},this.config);this.required&&!this.raw.trim()?t.issues=[...t.issues,{message:"A value is required."}]:!this.raw||null!==this.selected||this.config.allowFreeText||this.config.allowCreate||(t.issues=[...t.issues,{message:"Choose a suggestion."}]),t.issues.some((i=>"warning"!==i.severity))&&(t.output=void 0),!i.signal.aborted&&this.alive&&this.setValidation(t)}catch{}return this.validation}async focusInput(){this.input?.focus()}render(){const i=[this.helpOpen?"help-text":"",this.validation.issues.length?"validation":""].filter(Boolean).join(" ")||void 0,t=this.loading?"Loading suggestions…":this.lookupError||(this.expanded?this.rows.length+" suggestions available.":""),s=[...new Set(this.rows.map((i=>i.group??"")))];return e(a,{key:"fc4c0192d3be88d8c0199ae1bcca44232bd22351","data-size":this.size,"data-validation":this.validation.status,onFocusout:this.onFocusOut},e("label",{key:"bdd0d244c6ef448978fa77aac3a2d3b71d713553",htmlFor:"input",part:"label",class:"sr-only"===this.labelVisibility?"sr-only":void 0},this.label,this.required?" *":""),e("div",{key:"afb3972aab52171a3b25ede863c31059e56f5d91",class:"field",part:"field",ref:i=>this.field=i,onClick:i=>{i.composedPath().some((i=>i instanceof HTMLButtonElement))||this.input?.focus()}},e("slot",{key:"65e4e201d6c11cd2638e392e1298662de7ba4d57",name:"start"}),this.multiple&&e("div",{key:"b80b5b85fa0540139b9756fcc494aef9df245c15",class:"items",role:"group","aria-label":"Selected "+this.label},this.items.map(((i,t)=>e("button",{type:"button",part:"item",class:"item","data-value":i.value,tabIndex:-1,disabled:this.disabled||this.readOnly||i.disabled,"aria-label":i.label+", press Delete or Backspace to remove",onKeyDown:i=>this.onItemKeyDown(i,t)},e("slot",{name:"item-"+i.id},e("ui-chip",{appearance:"pill"},i.label)))))),e("input",{key:"64f76055ae412cc87119270eec10c69000a72563",id:"input",ref:i=>this.input=i,role:"combobox","aria-autocomplete":"list","aria-expanded":this.expanded+"","aria-controls":"listbox","aria-activedescendant":this.expanded&&this.active>=0?"option-"+this.active:void 0,"aria-describedby":i,"aria-invalid":("error"===this.validation.status)+"","aria-busy":("pending"===this.validation.status)+"",value:this.display,placeholder:this.placeholder,name:this.name||void 0,disabled:this.disabled,readOnly:this.readOnly,required:this.required,autoComplete:"off",part:"input",onInput:this.onInput,onKeyDown:this.onKeydown,onCompositionstart:()=>this.composing=!0,onCompositionend:()=>{this.composing=!1,this.onInput(new InputEvent("input"))}}),this.clearable&&e("button",{key:"eac4c18dadcea92065af4ecd871d925ef1248d47",type:"button",part:"affordance","aria-label":"Clear "+this.label,disabled:this.disabled||this.readOnly,onClick:()=>{this.commit(null,"",null,"clear","pointer"),this.close(),this.input?.focus()}},"×"),this.help&&e("button",{key:"9a559d49a495ead3dbf159f170c594e0aaa0d0d0",id:"help",type:"button",part:"affordance","aria-label":"Help for "+this.label,disabled:this.disabled},e("span",{key:"73940e568b976f85399d5baa5e247a4a606d0039","aria-hidden":"true"},"?")),this.disclosure&&e("button",{key:"30dd6746ffb121888a4c4fb6df54720906badf78",type:"button",part:"affordance","aria-label":"Suggestions for "+this.label,"aria-controls":"listbox","aria-expanded":this.expanded+"",disabled:this.disabled||this.readOnly,onClick:()=>{this.expanded?this.close():this.open("disclosure"),this.input?.focus()}},e("span",{key:"7d3b10a765ee0a6c40d7b0b49e98c676a5837944","aria-hidden":"true"},"⌄"))),this.help&&e("ui-tooltip",{key:"efff00f45dc281b727789eb2aa84ff772bb5c925",id:"help-text",for:"help",toggleOnClick:!0,onOpen:()=>this.helpOpen=!0,onClose:()=>this.helpOpen=!1},this.help),e("div",{key:"770bc12b873026b571bd3ae2a80416e8af52b8d4",class:"popup",part:"popup",hidden:!this.expanded,ref:i=>this.popup=i},e("div",{key:"ed48c8dd8b672a577d567ca5e795b8a53fde2761",id:"listbox",role:"listbox","aria-label":this.label+" suggestions","aria-busy":this.loading+""},s.map((i=>e("div",{role:i?"group":"presentation","aria-label":i||void 0},i&&e("div",{class:"group",part:"group"},i),this.rows.map(((t,s)=>(t.group??"")!==i?null:e("div",{id:"option-"+s,role:"option","aria-selected":(this.selected===t.value)+"","aria-disabled":!!t.disabled+"","data-active":this.active===s?"":void 0,part:"option",class:"option",onPointerDown:i=>i.preventDefault(),onClick:()=>this.choose(s,"pointer")},e("slot",{name:"option-"+t.id},e("span",{class:"primary",part:"option-primary"},t.label),t.description&&e("span",{class:"secondary",part:"option-secondary"},t.description)))))))),this.canCreate&&e("div",{key:"43215f449bbccde407ef818cee473f69870f6f8c",id:"option-"+this.rows.length,role:"option","aria-selected":"false",class:"option",part:"option","data-active":this.active===this.rows.length?"":void 0,onPointerDown:i=>i.preventDefault(),onClick:()=>this.choose(this.rows.length,"pointer")},e("slot",{key:"3ff70ff3ab8e24afc369a26e8474e7d1220ed6eb",name:"create"},"Create “",this.raw,"”"))),this.loading?e("div",{class:"message"},e("slot",{name:"loading"},"Loading suggestions…")):this.lookupError?e("div",{class:"message"},e("slot",{name:"error"},this.lookupError)):this.rows.length||this.canCreate?null:e("div",{class:"message"},e("slot",{name:"empty"},"No suggestions.")),e("slot",{key:"8b1fbd4f5c372393d294d8c218ae1785e6b0334f",name:"footer"})),e("div",{key:"18e68687f04e35535edee363683523ce6bbb0291",id:"validation",class:"message",part:"validation",hidden:!this.validation.issues.length},this.validation.issues.map((i=>e("div",null,i.message)))),e("div",{key:"e4a7db06abcfaf08b8ac592107531a13ef3a5897",class:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true"},t," ","pending"===this.validation.status?"Checking value…":this.validation.issues.map((i=>i.message)).join(" ")))}static get watchers(){return{value:[{syncValue:0}],query:[{syncQuery:0}],disabled:[{syncDisabled:0}],readOnly:[{syncDisabled:0}],config:[{syncConfig:0}]}}static get style(){return":host{display:grid;gap:var(--ui-space-1);min-inline-size:0;color:var(--ui-text-primary);font:inherit}label{color:var(--ui-field-label-color, var(--ui-text-primary));font-size:var(--ui-field-label-size, 0.875rem);font-weight:var(--ui-field-label-weight, 500)}.field{display:flex;min-inline-size:0;border:1px solid var(--ui-control-border, var(--ui-border-default));border-radius:var(--ui-radius-2);background:var(--ui-control-surface, var(--ui-surface-default))}.field:focus-within{border-color:var(--ui-control-focus, var(--ui-focus-ring));outline:2px solid var(--ui-control-focus, var(--ui-focus-ring));outline-offset:1px}input{appearance:none;width:100%;min-inline-size:0;min-block-size:var(--ui-control-min-block-size, 2.75rem);box-sizing:border-box;border:0;border-radius:inherit;background:transparent;color:inherit;font:inherit;line-height:var(--ui-line-height-md);padding:var(--ui-space-2) var(--ui-space-3);margin:0;outline:none}:host([data-size='sm']) input{min-block-size:var(--ui-field-compact-size, 2rem);padding:var(--ui-space-1) var(--ui-space-2)}button{appearance:none;border:0;border-radius:var(--ui-radius-2);background:transparent;color:var(--ui-field-affordance-color, var(--ui-text-secondary));font:inherit;font-weight:var(--ui-field-affordance-weight, 400);min-inline-size:2rem;padding:var(--ui-space-1);cursor:pointer}button:hover:enabled{background:var(--ui-surface-muted);color:var(--ui-text-primary)}button:focus-visible{outline:2px solid var(--ui-focus-ring);outline-offset:-3px}input:disabled,button:disabled{color:var(--ui-text-muted);cursor:not-allowed}.field:has(input:disabled){background:var(--ui-control-surface-disabled, var(--ui-surface-muted))}:host([data-validation='error']) .field{border-color:var(--ui-danger-solid, var(--ui-accent-active))}.popup{box-sizing:border-box;min-inline-size:12rem;max-inline-size:calc(100vw - 1rem);max-block-size:var(--ui-combobox-max-block-size, 18rem);overflow:auto;margin:0;padding:var(--ui-space-1);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-2);background:var(--ui-surface-elevated);color:var(--ui-text-primary);box-shadow:var(--ui-shadow-md)}[hidden]{display:none !important}.option{padding:var(--ui-space-2) var(--ui-space-3);border-radius:var(--ui-radius-1);cursor:pointer;overflow-wrap:anywhere}.option:hover,.option[data-active]{background:var(--ui-surface-muted);outline:1px solid var(--ui-focus-ring);outline-offset:-1px}.option[aria-disabled='true']{color:var(--ui-text-muted);cursor:not-allowed}.primary{display:block;color:var(--ui-option-primary-color, var(--ui-text-primary));font-weight:var(--ui-option-primary-weight, 500)}.secondary{display:block;color:var(--ui-option-secondary-color, var(--ui-text-secondary));font-weight:var(--ui-option-secondary-weight, 400);font-size:var(--ui-font-size-sm)}.message,.group{color:var(--ui-field-message-color, var(--ui-text-secondary));font-weight:var(--ui-field-message-weight, 400);font-size:var(--ui-font-size-sm);line-height:var(--ui-line-height-md);overflow-wrap:anywhere}.group,.popup .message{padding:var(--ui-space-2) var(--ui-space-3)}.sr-only{position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}@media (pointer: coarse){button{min-inline-size:2.75rem;min-block-size:2.75rem}}@media (forced-colors: active){.field,.popup{border-color:CanvasText}.option[data-active]{outline-color:Highlight}}:host([multiple]) .field{flex-wrap:wrap;align-items:center;gap:var(--ui-space-1);min-block-size:var(--ui-multi-combobox-min-block-size, 2.5rem);padding:var(--ui-space-1)}:host([multiple]) input{flex:1 0 var(--ui-multi-combobox-input-min-inline-size, 5rem);width:auto;min-block-size:1.75rem;padding:var(--ui-space-0-5) var(--ui-space-1)}.items{display:contents}.item{appearance:none;display:inline-flex;min-inline-size:0;max-inline-size:min(100%, var(--ui-multi-combobox-item-max-inline-size, 12rem));overflow:hidden;padding:0;border:0;border-radius:var(--ui-radius-1);background:transparent;color:inherit;font:inherit;cursor:default}.item>slot{display:block;min-inline-size:0;max-inline-size:100%;overflow:hidden}.item>slot::slotted(*){min-inline-size:0;max-inline-size:100%}.item:focus-visible{outline:2px solid var(--ui-focus-ring);outline-offset:1px}.item:disabled{opacity:.6}"}},[769,"ui-combobox",{label:[1],placeholder:[1],name:[1],value:[1],defaultValue:[1,"default-value"],multiple:[516],tokenSeparators:[16],query:[1],defaultQuery:[1,"default-query"],config:[16],disabled:[4],readOnly:[4,"readonly"],required:[4],size:[1],labelVisibility:[1,"label-visibility"],disclosure:[4],clearable:[4],help:[1],raw:[32],display:[32],selected:[32],expanded:[32],rows:[32],active:[32],loading:[32],helpOpen:[32],lookupError:[32],validation:[32],validate:[64],focusInput:[64]},void 0,{value:[{syncValue:0}],query:[{syncQuery:0}],disabled:[{syncDisabled:0}],readOnly:[{syncDisabled:0}],config:[{syncConfig:0}]}]),c=u,p=function(){"undefined"!=typeof customElements&&["ui-combobox","ui-chip","ui-tooltip"].forEach((i=>{switch(i){case"ui-combobox":customElements.get(o(i))||customElements.define(o(i),u);break;case"ui-chip":customElements.get(o(i))||l();break;case"ui-tooltip":customElements.get(o(i))||d()}}))};export{c as UiCombobox,p as defineCustomElement}