@motifx-community/ui 0.1.0-beta.11 → 0.1.0-beta.12

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 (189) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/components/combobox/ComboBox.d.ts +5 -0
  3. package/dist/components/combobox/combo-box-props.d.ts +6 -0
  4. package/dist/components/datagrid/DataGrid.d.ts +4 -1
  5. package/dist/components/datagrid/grid-lookup.d.ts +8 -0
  6. package/dist/components/datagrid/model/FilterModel.d.ts +5 -0
  7. package/dist/components/datagrid/model/LookupTexts.d.ts +2 -0
  8. package/dist/components/datagrid/model/LookupValues.d.ts +4 -0
  9. package/dist/components/datagrid/view/ActionWidths.d.ts +13 -3
  10. package/dist/components/datagrid/view/GridRow.d.ts +1 -1
  11. package/dist/components/dropdown/DropDown.d.ts +5 -0
  12. package/dist/components/dropdown/drop-down-props.d.ts +6 -0
  13. package/dist/components/filterbuilder/filter-builder-lookup.d.ts +3 -0
  14. package/dist/components/listbox/ListBox.d.ts +5 -0
  15. package/dist/components/listbox/list-box-props.d.ts +6 -0
  16. package/dist/components/listbox/select-all-state.d.ts +1 -1
  17. package/dist/components/ribbonmenu/RibbonKeyHints.d.ts +1 -0
  18. package/dist/components/tagbox/TagBox.d.ts +5 -0
  19. package/dist/components/tagbox/tag-box-props.d.ts +6 -0
  20. package/dist/components/toolbar/Toolbar.d.ts +8 -0
  21. package/dist/core/measure/after-frame.d.ts +7 -0
  22. package/dist/core/measure/drawn.d.ts +7 -0
  23. package/dist/core/measure/index.d.ts +1 -1
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +553 -136
  26. package/dist/index.js.map +1 -1
  27. package/dist/parts/data/DataItems.d.ts +24 -0
  28. package/dist/parts/data/KeyedItems.d.ts +31 -5
  29. package/dist/parts/data/normalize-key.d.ts +7 -0
  30. package/dist/styles.css +32 -0
  31. package/docs/accordion.md +1 -1
  32. package/docs/actionsheet.md +1 -1
  33. package/docs/appbar.md +1 -1
  34. package/docs/appmenu-api.md +1 -1
  35. package/docs/appmenu-programmatic.md +1 -1
  36. package/docs/appmenu-search.md +1 -1
  37. package/docs/appmenu.md +1 -1
  38. package/docs/avatar.md +1 -1
  39. package/docs/badge.md +1 -1
  40. package/docs/bar-gauge-angles.md +1 -1
  41. package/docs/bar-gauge-data.md +1 -1
  42. package/docs/bar-gauge-labels.md +1 -1
  43. package/docs/bar-gauge.md +1 -1
  44. package/docs/barcode.md +1 -1
  45. package/docs/bottomnavigation.md +1 -1
  46. package/docs/bottomsheet.md +1 -1
  47. package/docs/breadcrumb.md +1 -1
  48. package/docs/button.md +1 -1
  49. package/docs/buttongroup.md +1 -1
  50. package/docs/buttons.md +1 -1
  51. package/docs/calendar.md +1 -1
  52. package/docs/card.md +1 -1
  53. package/docs/chart-bars.md +1 -1
  54. package/docs/chart-candles.md +1 -1
  55. package/docs/chart-funnel.md +1 -1
  56. package/docs/chart-heatmap.md +1 -1
  57. package/docs/chart-lines.md +1 -1
  58. package/docs/chart-live.md +1 -1
  59. package/docs/chart-pie.md +1 -1
  60. package/docs/chart-radar.md +1 -1
  61. package/docs/chart-ranges.md +1 -1
  62. package/docs/chart-references.md +1 -1
  63. package/docs/chart-scatter.md +1 -1
  64. package/docs/chart-waterfall.md +1 -1
  65. package/docs/chart-zoom.md +1 -1
  66. package/docs/chart.md +1 -1
  67. package/docs/checkbox.md +1 -1
  68. package/docs/chip.md +1 -1
  69. package/docs/choice.md +1 -1
  70. package/docs/colorbox.md +1 -1
  71. package/docs/combobox.md +1 -1
  72. package/docs/commands.md +1 -1
  73. package/docs/control.md +1 -1
  74. package/docs/data.md +1 -1
  75. package/docs/datagrid-api.md +1 -1
  76. package/docs/datagrid-bands.md +1 -1
  77. package/docs/datagrid-drag-select.md +1 -1
  78. package/docs/datagrid-drag.md +1 -1
  79. package/docs/datagrid-editing.md +1 -1
  80. package/docs/datagrid-filtering.md +1 -1
  81. package/docs/datagrid-forms.md +1 -1
  82. package/docs/datagrid-grouping.md +1 -1
  83. package/docs/datagrid-layout.md +1 -1
  84. package/docs/datagrid-lookups.md +1 -1
  85. package/docs/datagrid-master-detail.md +1 -1
  86. package/docs/datagrid-scrolling.md +1 -1
  87. package/docs/datagrid-selection.md +1 -1
  88. package/docs/datagrid.md +1 -1
  89. package/docs/datebox.md +1 -1
  90. package/docs/daterangebox.md +1 -1
  91. package/docs/display.md +1 -1
  92. package/docs/draggable.md +1 -1
  93. package/docs/drawer.md +1 -1
  94. package/docs/dropdown.md +1 -1
  95. package/docs/editors.md +1 -1
  96. package/docs/feedback.md +1 -1
  97. package/docs/fileuploader.md +1 -1
  98. package/docs/filterbuilder.md +1 -1
  99. package/docs/formlayout.md +1 -1
  100. package/docs/foundations.md +1 -1
  101. package/docs/gallery.md +1 -1
  102. package/docs/gauge-base.md +1 -1
  103. package/docs/gauge-circular.md +1 -1
  104. package/docs/gauge-dashboards.md +1 -1
  105. package/docs/gauge-linear.md +1 -1
  106. package/docs/gauge-markers.md +1 -1
  107. package/docs/gauge-marks.md +1 -1
  108. package/docs/gauge-ranges.md +1 -1
  109. package/docs/gauge-scales.md +1 -1
  110. package/docs/gauge.md +1 -1
  111. package/docs/home.md +1 -1
  112. package/docs/keyboard.md +1 -1
  113. package/docs/language.md +1 -1
  114. package/docs/layout.md +1 -1
  115. package/docs/listbox.md +1 -1
  116. package/docs/loadpanel.md +1 -1
  117. package/docs/lookup.md +1 -1
  118. package/docs/menus-api.md +1 -1
  119. package/docs/menus-context.md +1 -1
  120. package/docs/menus-customization.md +1 -1
  121. package/docs/menus-merging.md +1 -1
  122. package/docs/menus-programmatic.md +1 -1
  123. package/docs/menus.md +1 -1
  124. package/docs/multiview.md +1 -1
  125. package/docs/navigation.md +1 -1
  126. package/docs/numberbox.md +1 -1
  127. package/docs/otpinput.md +1 -1
  128. package/docs/pagination.md +1 -1
  129. package/docs/popover.md +1 -1
  130. package/docs/progress.md +1 -1
  131. package/docs/qrcode.md +1 -1
  132. package/docs/radiogroup.md +1 -1
  133. package/docs/rating.md +1 -1
  134. package/docs/resizable.md +1 -1
  135. package/docs/ribbonmenu-api.md +1 -1
  136. package/docs/ribbonmenu-commands.md +1 -1
  137. package/docs/ribbonmenu-customization.md +1 -1
  138. package/docs/ribbonmenu-display.md +1 -1
  139. package/docs/ribbonmenu-layouts.md +1 -1
  140. package/docs/ribbonmenu-programmatic.md +1 -1
  141. package/docs/ribbonmenu.md +1 -1
  142. package/docs/scheduler-agenda.md +1 -1
  143. package/docs/scheduler-big-data.md +1 -1
  144. package/docs/scheduler-editing.md +1 -1
  145. package/docs/scheduler-form.md +1 -1
  146. package/docs/scheduler-icalendar.md +1 -1
  147. package/docs/scheduler-mobile.md +1 -1
  148. package/docs/scheduler-recurrence.md +1 -1
  149. package/docs/scheduler-resources.md +1 -1
  150. package/docs/scheduler-timeline.md +1 -1
  151. package/docs/scheduler.md +1 -1
  152. package/docs/scrollview.md +1 -1
  153. package/docs/shortcuteditor.md +1 -1
  154. package/docs/showcase-home.md +1 -1
  155. package/docs/showcase.md +1 -1
  156. package/docs/signature.md +1 -1
  157. package/docs/skeleton.md +1 -1
  158. package/docs/slider.md +1 -1
  159. package/docs/sortable.md +1 -1
  160. package/docs/sparkline.md +1 -1
  161. package/docs/speeddial.md +1 -1
  162. package/docs/splitter.md +1 -1
  163. package/docs/stepper.md +1 -1
  164. package/docs/switch.md +1 -1
  165. package/docs/tabdocs-dock.md +1 -1
  166. package/docs/tabdocs-drag.md +1 -1
  167. package/docs/tabdocs-menus.md +1 -1
  168. package/docs/tabdocs-mobile.md +1 -1
  169. package/docs/tabdocs-tabs.md +1 -1
  170. package/docs/tabdocs-windows.md +1 -1
  171. package/docs/tabdocs-workspace.md +1 -1
  172. package/docs/tabdocs.md +1 -1
  173. package/docs/tabs.md +1 -1
  174. package/docs/tagbox.md +1 -1
  175. package/docs/textarea.md +1 -1
  176. package/docs/textbox.md +1 -1
  177. package/docs/tileview.md +1 -1
  178. package/docs/timeline.md +1 -1
  179. package/docs/toast.md +1 -1
  180. package/docs/tokens.md +1 -1
  181. package/docs/toolbar.md +1 -1
  182. package/docs/tooltip.md +1 -1
  183. package/docs/treeview.md +1 -1
  184. package/docs/validationsummary.md +1 -1
  185. package/docs/window.md +1 -1
  186. package/docs/wizard.md +1 -1
  187. package/llms-full.txt +157 -157
  188. package/llms.txt +1 -1
  189. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -227,6 +227,42 @@ function forgetReads() {
227
227
  roundReads.pages.clear();
228
228
  }
229
229
  //#endregion
230
+ //#region src/core/measure/after-frame.ts
231
+ /** A window that draws no frames (in the background) still runs it this much later. */
232
+ var LONGEST_WAIT$1 = 200;
233
+ var FRAME_TIME$1 = 16;
234
+ /**
235
+ * Runs `then` in a task after the next frame of `view`: the frame's own work (style, layout, paint) is done by then, so
236
+ * reading or moving focus there lays nothing out. A window that draws no frames runs it on a timer. Returns what takes
237
+ * it back.
238
+ */
239
+ function afterFrame(view, then) {
240
+ let done = false;
241
+ let frame = 0;
242
+ let after;
243
+ const run = () => {
244
+ if (done) return;
245
+ stop();
246
+ then();
247
+ };
248
+ try {
249
+ if (!view.closed && typeof view.requestAnimationFrame === "function") frame = view.requestAnimationFrame(() => after = setTimeout(run, 0));
250
+ } catch {
251
+ frame = 0;
252
+ }
253
+ const timer = setTimeout(run, frame ? LONGEST_WAIT$1 : FRAME_TIME$1);
254
+ function stop() {
255
+ done = true;
256
+ clearTimeout(timer);
257
+ clearTimeout(after);
258
+ if (!frame) return;
259
+ try {
260
+ view.cancelAnimationFrame(frame);
261
+ } catch {}
262
+ }
263
+ return stop;
264
+ }
265
+ //#endregion
230
266
  //#region src/core/measure/pending-scrolls.ts
231
267
  /** Scrolls written through a component that core has not made yet (it calls the method a microtask later). */
232
268
  var pending$2 = /* @__PURE__ */ new WeakMap();
@@ -265,6 +301,9 @@ function pendingScroll(component) {
265
301
  //#region src/core/measure/scroll-memory.ts
266
302
  var known$1 = /* @__PURE__ */ new WeakMap();
267
303
  var heard = /* @__PURE__ */ new WeakSet();
304
+ /** Elements scrolled and not read yet, and the ones of each window that wait for its next frame. */
305
+ var unread = /* @__PURE__ */ new WeakSet();
306
+ var waiting$2 = /* @__PURE__ */ new WeakMap();
268
307
  var AT_START = {
269
308
  start: 0,
270
309
  top: 0
@@ -275,9 +314,18 @@ function rememberScrolls(view) {
275
314
  heard.add(view);
276
315
  onDocument(view.document, "scroll", (e) => {
277
316
  const el = e.target;
278
- if (isElement(el)) known$1.set(el, {
279
- start: Math.abs(el.scrollLeft),
280
- top: el.scrollTop
317
+ if (!isElement(el)) return;
318
+ unread.add(el);
319
+ let scrolled = waiting$2.get(view);
320
+ if (scrolled) {
321
+ scrolled.add(el);
322
+ return;
323
+ }
324
+ scrolled = /* @__PURE__ */ new Set([el]);
325
+ waiting$2.set(view, scrolled);
326
+ afterFrame(view, () => {
327
+ waiting$2.delete(view);
328
+ for (const one of scrolled) if (unread.has(one)) readScroll(one);
281
329
  });
282
330
  }, {
283
331
  capture: true,
@@ -286,7 +334,9 @@ function rememberScrolls(view) {
286
334
  }
287
335
  /** Notes how far `el` is scrolled, as the layer read it or wrote it. */
288
336
  function noteScroll(el, place, by = false) {
289
- const was = known$1.get(el) ?? AT_START;
337
+ const whole = !by && place.start !== void 0 && place.top !== void 0;
338
+ if (whole) unread.delete(el);
339
+ const was = whole ? AT_START : scrollOf$2(el);
290
340
  const start = place.start === void 0 ? was.start : Math.max(0, (by ? was.start : 0) + place.start);
291
341
  const top = place.top === void 0 ? was.top : Math.max(0, (by ? was.top : 0) + place.top);
292
342
  known$1.set(el, {
@@ -298,7 +348,7 @@ function noteScroll(el, place, by = false) {
298
348
  function knownScrollOf(component) {
299
349
  const el = elementOf$2(component);
300
350
  if (!el) return AT_START;
301
- const seen = known$1.get(el) ?? AT_START;
351
+ const seen = scrollOf$2(el);
302
352
  const pending = pendingScroll(component);
303
353
  if (!pending) return seen;
304
354
  return {
@@ -306,13 +356,25 @@ function knownScrollOf(component) {
306
356
  top: Math.max(0, (pending.top ?? seen.top) + pending.byTop)
307
357
  };
308
358
  }
359
+ /** How far `el` is scrolled as told; one scrolled and not read yet is read now. */
360
+ function scrollOf$2(el) {
361
+ if (unread.has(el)) readScroll(el);
362
+ return known$1.get(el) ?? AT_START;
363
+ }
364
+ function readScroll(el) {
365
+ unread.delete(el);
366
+ if (el.isConnected) known$1.set(el, {
367
+ start: Math.abs(el.scrollLeft),
368
+ top: el.scrollTop
369
+ });
370
+ }
309
371
  //#endregion
310
372
  //#region src/core/measure/rounds.ts
311
373
  var MOST_ROUNDS = 8;
312
374
  var MOST_TRIES = 16;
313
375
  /** A window that draws no frames (in the background, being closed) still runs its work this much later. */
314
- var LONGEST_WAIT$1 = 200;
315
- var FRAME_TIME$1 = 16;
376
+ var LONGEST_WAIT = 200;
377
+ var FRAME_TIME = 16;
316
378
  var SKIPPED = Symbol("skipped");
317
379
  var frames = /* @__PURE__ */ new WeakMap();
318
380
  /** Jobs not run yet, by owner and read: the same read and write asked for again run once. */
@@ -469,7 +531,7 @@ function ask(frame) {
469
531
  } catch {
470
532
  id = 0;
471
533
  }
472
- const timer = setTimeout(go, id ? LONGEST_WAIT$1 : FRAME_TIME$1);
534
+ const timer = setTimeout(go, id ? LONGEST_WAIT : FRAME_TIME);
473
535
  frame.waiting = () => {
474
536
  clearTimeout(timer);
475
537
  if (!id) return;
@@ -769,9 +831,6 @@ function everyFrame(owner, read, write) {
769
831
  }
770
832
  //#endregion
771
833
  //#region src/core/measure/drawn.ts
772
- /** A window that draws no frames (in the background) still runs it this much later. */
773
- var LONGEST_WAIT = 200;
774
- var FRAME_TIME = 16;
775
834
  /**
776
835
  * Runs `then` once the window of `owner` has drawn its next frame: what was written by then is laid out and on the
777
836
  * screen, so moving focus or reading costs no layout there. A window that draws no frames runs it on a timer. Nothing
@@ -780,35 +839,56 @@ var FRAME_TIME = 16;
780
839
  function afterDrawn(owner, then) {
781
840
  const view = viewOf(owner);
782
841
  if (!view) return () => {};
783
- let done = false;
784
- let frame = 0;
785
- let after;
786
- const run = () => {
787
- if (done) return;
788
- stop();
789
- if (owner.isDisposed) return;
790
- try {
791
- untracked(then);
792
- } catch (error) {
793
- errorHandler.report(error instanceof Error ? error : new Error(String(error)));
794
- }
795
- };
842
+ return afterFrame(view, () => {
843
+ if (!owner.isDisposed) runSafely(then);
844
+ });
845
+ }
846
+ function runSafely(then) {
796
847
  try {
797
- if (!view.closed && typeof view.requestAnimationFrame === "function") frame = view.requestAnimationFrame(() => after = setTimeout(run, 0));
798
- } catch {
799
- frame = 0;
848
+ untracked(then);
849
+ } catch (error) {
850
+ errorHandler.report(error instanceof Error ? error : new Error(String(error)));
800
851
  }
801
- const timer = setTimeout(run, frame ? LONGEST_WAIT : FRAME_TIME);
802
- function stop() {
803
- done = true;
804
- clearTimeout(timer);
805
- clearTimeout(after);
806
- if (!frame) return;
807
- try {
808
- view.cancelAnimationFrame(frame);
809
- } catch {}
852
+ }
853
+ /** What waits for the next frame of each window: every measure asked until then runs in one run there. */
854
+ var waitingIn = /* @__PURE__ */ new WeakMap();
855
+ /**
856
+ * Reads once the window of `owner` has drawn its next frame, in one run with every other measure asked for that frame:
857
+ * the page is laid out by then and the reads come before the writes, so nothing is laid out to read. What `write`
858
+ * writes shows a frame later. For a first measure that can wait a frame (a part that clips what does not fit until
859
+ * then). Returns what takes it back.
860
+ */
861
+ function measureAfterDrawn(owner, read, write) {
862
+ const view = viewOf(owner);
863
+ if (!view) return () => {};
864
+ const waiting = {
865
+ owner,
866
+ ask: () => measure(owner, read, write),
867
+ asked: null
868
+ };
869
+ let batch = waitingIn.get(view);
870
+ if (!batch) {
871
+ const all = /* @__PURE__ */ new Set();
872
+ batch = {
873
+ all,
874
+ stop: afterFrame(view, () => {
875
+ waitingIn.delete(view);
876
+ const live = [...all].filter((one) => !one.owner.isDisposed);
877
+ if (!live.length) return;
878
+ for (const one of live) runSafely(() => one.asked = one.ask());
879
+ runSafely(() => measureNow(live[0].owner));
880
+ })
881
+ };
882
+ waitingIn.set(view, batch);
810
883
  }
811
- return stop;
884
+ const { all, stop } = batch;
885
+ all.add(waiting);
886
+ return () => {
887
+ waiting.asked?.();
888
+ if (!all.delete(waiting) || all.size || waitingIn.get(view)?.all !== all) return;
889
+ stop();
890
+ waitingIn.delete(view);
891
+ };
812
892
  }
813
893
  //#endregion
814
894
  //#region src/core/component-tree.ts
@@ -12446,6 +12526,7 @@ function isEmptyKey(key) {
12446
12526
  }
12447
12527
  //#endregion
12448
12528
  //#region src/parts/data/KeyedItems.ts
12529
+ /** The caches of a source, by value field and by the `normalizeKey` given (`null`: none). */
12449
12530
  var registry = /* @__PURE__ */ new WeakMap();
12450
12531
  var watched = /* @__PURE__ */ new WeakSet();
12451
12532
  /** The same text for equal keys: `1` and `'1'` are one key, equal dates are one key. */
@@ -12456,14 +12537,32 @@ function keyString(key) {
12456
12537
  }
12457
12538
  var sameText = (a, b, locale) => foldText(a.trim(), locale) === foldText(b.trim(), locale);
12458
12539
  /**
12540
+ * A key as databases commonly compare keys when they disregard what this cache does not: trailing spaces (a `char(n)`
12541
+ * column), case, accents, the width of a character, or how a number is written (`'007'` and `7`). `null` for a key
12542
+ * that is not a text or a number. It never decides a match: it only tells the cache to ask the source again.
12543
+ */
12544
+ function looseKey(key) {
12545
+ if (typeof key === "number" || typeof key === "bigint") return String(key);
12546
+ if (typeof key !== "string") return null;
12547
+ const text = key.normalize("NFKD").replace(/\p{M}+/gu, "").trim().toLowerCase().replace(/ı/g, "i");
12548
+ return /^[+-]?\d+(\.\d+)?$/.test(text) ? String(Number(text)) : text;
12549
+ }
12550
+ /**
12459
12551
  * Items by key, from a data source of the data layer (any adapter) or an array: what a grid cell, a
12460
12552
  * drop-down's field or a filter list needs to turn a key into its item. Keys are requested when they
12461
12553
  * are needed and only once. Keys requested at the same moment go out together, in one request
12462
12554
  * per `batchSize` keys (`valueField in [...]`), or in one request per key for a service that only returns
12463
- * one item by key (`resolve: 'byKey'`). There is one cache per source and value field, shared by
12464
- * every grid, column and list that uses it (`KeyedItems.of`). Requests go through the source's
12555
+ * one item by key (`resolve: 'byKey'`). There is one cache per source, value field and `normalizeKey`,
12556
+ * shared by every grid, column and list that uses it (`KeyedItems.of`). Requests go through the source's
12465
12557
  * adapter, so the source's own query (filter, page, search) never changes.
12466
12558
  *
12559
+ * Which item a key stands for is the source's decision: a source may compare keys its own way (a
12560
+ * database that disregards trailing spaces, case or accents, or reads `'007'` as `7`). The items of a
12561
+ * batch are matched to the keys asked for; when keys are left over while the source returned items no
12562
+ * key matched here, or items that differ from a key only in such a way, those keys are asked for one
12563
+ * by one, and what the source returns for a key is that key's item. `normalizeKey` tells the cache the
12564
+ * rule itself: keys equal once normalized are one key, also in an array, where no source decides.
12565
+ *
12467
12566
  * @example
12468
12567
  * const customers = KeyedItems.of(customerSource, 'id');
12469
12568
  * customers.onResolved(() => redraw());
@@ -12475,8 +12574,11 @@ var KeyedItems = class KeyedItems {
12475
12574
  static keyString(key) {
12476
12575
  return keyString(key);
12477
12576
  }
12478
- /** The shared cache of a source and value field. Every data source over the same adapter shares it. */
12479
- static of(source, valueField) {
12577
+ /**
12578
+ * The shared cache of a source, value field and `normalizeKey`. Every data source over the same adapter shares it; give
12579
+ * the same `normalizeKey` function wherever the source is used, so they share one cache.
12580
+ */
12581
+ static of(source, valueField, normalizeKey) {
12480
12582
  const owner = Array.isArray(source) ? source : source.adapter;
12481
12583
  if (!Array.isArray(source) && valueField !== void 0) {
12482
12584
  const fields = owner.keys.fields;
@@ -12484,14 +12586,17 @@ var KeyedItems = class KeyedItems {
12484
12586
  }
12485
12587
  let byField = registry.get(owner);
12486
12588
  if (!byField) registry.set(owner, byField = /* @__PURE__ */ new Map());
12487
- let items = byField.get(valueField ?? "");
12488
- if (!items) byField.set(valueField ?? "", items = new KeyedItems(source, valueField));
12589
+ let byRule = byField.get(valueField ?? "");
12590
+ if (!byRule) byField.set(valueField ?? "", byRule = /* @__PURE__ */ new Map());
12591
+ let items = byRule.get(normalizeKey ?? null);
12592
+ if (!items) byRule.set(normalizeKey ?? null, items = new KeyedItems(source, valueField, normalizeKey ?? void 0));
12489
12593
  if (!Array.isArray(source)) items.watch(source);
12490
12594
  return items;
12491
12595
  }
12492
- constructor(source, valueField) {
12596
+ constructor(source, valueField, normalizeKey) {
12493
12597
  _defineProperty(this, "source", void 0);
12494
12598
  _defineProperty(this, "valueField", void 0);
12599
+ _defineProperty(this, "normalizeKey", void 0);
12495
12600
  _defineProperty(
12496
12601
  this,
12497
12602
  /**
@@ -12535,6 +12640,7 @@ var KeyedItems = class KeyedItems {
12535
12640
  );
12536
12641
  this.source = source;
12537
12642
  this.valueField = valueField;
12643
+ this.normalizeKey = normalizeKey;
12538
12644
  const adapter = this.adapter;
12539
12645
  this.resolve = adapter && !adapter.capabilities.filter ? "byKey" : "batch";
12540
12646
  adapter?.onChanged((e) => this.changed(e.changes));
@@ -12549,12 +12655,24 @@ var KeyedItems = class KeyedItems {
12549
12655
  if (this.inMemory) return item !== null && typeof item === "object" && "value" in item ? item.value : item;
12550
12656
  return this.adapter.keyOf(item);
12551
12657
  }
12658
+ /** The string the cache keeps a key under: equal for keys it counts as one (`normalizeKey`). */
12659
+ keyStringOf(key) {
12660
+ return keyString(this.normalizeKey ? this.normalizeKey(key) : key);
12661
+ }
12552
12662
  sameKey(a, b) {
12553
- return keyString(a) === keyString(b);
12663
+ return this.keyStringOf(a) === this.keyStringOf(b);
12664
+ }
12665
+ /**
12666
+ * The item a key stands for, as a string: equal for keys the source matched to the same item (`'A'` and `'A '`
12667
+ * where it disregards trailing spaces). A key not found yet stands for itself.
12668
+ */
12669
+ itemKeyOf(key) {
12670
+ const item = this.get(key)?.item;
12671
+ return item === void 0 ? this.keyStringOf(key) : this.keyStringOf(this.valueOf(item));
12554
12672
  }
12555
12673
  /** What is known of a key now, or `undefined` if it was never requested (an array knows every key). */
12556
12674
  get(key) {
12557
- const ks = keyString(key);
12675
+ const ks = this.keyStringOf(key);
12558
12676
  const known = this.entries.get(ks);
12559
12677
  if (known || !this.inMemory) return known;
12560
12678
  const item = this.fromArray(ks);
@@ -12569,7 +12687,7 @@ var KeyedItems = class KeyedItems {
12569
12687
  const waits = /* @__PURE__ */ new Set();
12570
12688
  for (const key of keys) {
12571
12689
  if (isEmptyKey(key)) continue;
12572
- const ks = keyString(key);
12690
+ const ks = this.keyStringOf(key);
12573
12691
  const known = this.entries.get(ks);
12574
12692
  if (known && known.state !== "loading") continue;
12575
12693
  const wait = this.waiting.get(ks);
@@ -12589,7 +12707,7 @@ var KeyedItems = class KeyedItems {
12589
12707
  retry(keys) {
12590
12708
  const list = [...keys];
12591
12709
  for (const key of list) {
12592
- const ks = keyString(key);
12710
+ const ks = this.keyStringOf(key);
12593
12711
  if (this.entries.get(ks)?.failed) this.entries.delete(ks);
12594
12712
  }
12595
12713
  return this.request(list);
@@ -12597,7 +12715,7 @@ var KeyedItems = class KeyedItems {
12597
12715
  /** Stores what an editor selected for a key, its item or its text, which appears immediately without a request. */
12598
12716
  remember(key, itemOrText) {
12599
12717
  if (key === null || key === void 0) return;
12600
- const ks = keyString(key);
12718
+ const ks = this.keyStringOf(key);
12601
12719
  this.entries.set(ks, typeof itemOrText === "string" ? {
12602
12720
  state: "found",
12603
12721
  text: itemOrText
@@ -12615,7 +12733,7 @@ var KeyedItems = class KeyedItems {
12615
12733
  const out = [];
12616
12734
  for (const item of pool) {
12617
12735
  if (!sameText(search.textOf(item), text, locale)) continue;
12618
- const ks = keyString(this.valueOf(item));
12736
+ const ks = this.keyStringOf(this.valueOf(item));
12619
12737
  if (seen.has(ks)) continue;
12620
12738
  seen.add(ks);
12621
12739
  out.push(item);
@@ -12699,7 +12817,7 @@ var KeyedItems = class KeyedItems {
12699
12817
  const rows = this.source;
12700
12818
  if (!this.index || !this.index.has(ks) && rows.length !== this.indexedLength) {
12701
12819
  this.index = /* @__PURE__ */ new Map();
12702
- for (const item of rows) this.index.set(keyString(this.valueOf(item)), item);
12820
+ for (const item of rows) this.index.set(this.keyStringOf(this.valueOf(item)), item);
12703
12821
  this.indexedLength = rows.length;
12704
12822
  }
12705
12823
  return this.index.get(ks);
@@ -12726,6 +12844,10 @@ var KeyedItems = class KeyedItems {
12726
12844
  jobs.push(() => this.loadMany(field, part, generation));
12727
12845
  }
12728
12846
  }
12847
+ await this.inTurns(jobs);
12848
+ }
12849
+ /** Runs the jobs `parallelRequests` at a time. */
12850
+ async inTurns(jobs) {
12729
12851
  let next = 0;
12730
12852
  const worker = async () => {
12731
12853
  while (next < jobs.length) await jobs[next++]();
@@ -12741,24 +12863,56 @@ var KeyedItems = class KeyedItems {
12741
12863
  }
12742
12864
  if (generation !== this.generation) return;
12743
12865
  const found = /* @__PURE__ */ new Map();
12744
- for (const row of rows ?? []) found.set(keyString(this.valueOf(row)), row);
12745
- for (const [ks] of part) {
12746
- this.waiting.delete(ks);
12866
+ for (const row of rows ?? []) found.set(this.keyStringOf(this.valueOf(row)), row);
12867
+ const matched = /* @__PURE__ */ new Set();
12868
+ const left = [];
12869
+ const settled = [];
12870
+ for (const [ks, key] of part) {
12747
12871
  const item = found.get(ks);
12872
+ if (item !== void 0) matched.add(item);
12873
+ if (item === void 0 && rows) {
12874
+ left.push([ks, key]);
12875
+ continue;
12876
+ }
12877
+ this.waiting.delete(ks);
12748
12878
  this.entries.set(ks, item !== void 0 ? {
12749
12879
  state: "found",
12750
12880
  item
12751
- } : rows ? { state: "missing" } : {
12881
+ } : {
12752
12882
  state: "missing",
12753
12883
  failed: true
12754
12884
  });
12885
+ settled.push(ks);
12755
12886
  }
12756
- this.resolvedEmitter.fire(part.map(([ks]) => ks));
12887
+ const own = rows !== null && left.length > 0 && (rows.some((row) => !matched.has(row)) || this.looselyIn(left, rows));
12888
+ for (const [ks] of own ? [] : left) {
12889
+ this.waiting.delete(ks);
12890
+ this.entries.set(ks, { state: "missing" });
12891
+ settled.push(ks);
12892
+ }
12893
+ if (settled.length) this.resolvedEmitter.fire(settled);
12894
+ if (own) await this.inTurns(left.map(([ks, key]) => () => this.loadOne(ks, key, generation, field)));
12895
+ }
12896
+ /** Whether an item differs from one of `keys` only in what databases often disregard (`looseKey`). */
12897
+ looselyIn(keys, rows) {
12898
+ const loose = /* @__PURE__ */ new Set();
12899
+ for (const row of rows) {
12900
+ const key = looseKey(this.valueOf(row));
12901
+ if (key !== null) loose.add(key);
12902
+ }
12903
+ return keys.some(([, key]) => {
12904
+ const k = looseKey(key);
12905
+ return k !== null && loose.has(k);
12906
+ });
12757
12907
  }
12758
- async loadOne(ks, key, generation) {
12908
+ /** One key asked for alone: by the adapter's key, or by `field` when the value is not the key. What comes is that key's. */
12909
+ async loadOne(ks, key, generation, field) {
12759
12910
  let entry;
12760
12911
  try {
12761
- const item = await this.adapter.byKey(key);
12912
+ const item = field && this.valueField ? (await this.adapter.load({
12913
+ filter: data.where(field, "=", key),
12914
+ take: 1
12915
+ })).rows[0] : await this.adapter.byKey(key);
12762
12916
  entry = item === void 0 ? { state: "missing" } : {
12763
12917
  state: "found",
12764
12918
  item
@@ -12780,7 +12934,7 @@ var KeyedItems = class KeyedItems {
12780
12934
  for (const item of items) {
12781
12935
  const value = this.valueOf(item);
12782
12936
  if (value === null || value === void 0) continue;
12783
- const ks = keyString(value);
12937
+ const ks = this.keyStringOf(value);
12784
12938
  if (this.entries.get(ks)?.state === "found") continue;
12785
12939
  this.entries.set(ks, {
12786
12940
  state: "found",
@@ -12796,11 +12950,10 @@ var KeyedItems = class KeyedItems {
12796
12950
  if (this.entries.size) this.clear();
12797
12951
  return;
12798
12952
  }
12953
+ const changed = new Set(changes.map((change) => this.keyStringOf(change.key)));
12799
12954
  const keys = [];
12800
- for (const change of changes) {
12801
- const ks = keyString(change.key);
12802
- if (this.entries.delete(ks)) keys.push(ks);
12803
- }
12955
+ for (const [ks, entry] of this.entries) if (changed.has(ks) || entry.item !== void 0 && changed.has(this.keyStringOf(this.valueOf(entry.item)))) keys.push(ks);
12956
+ for (const ks of keys) this.entries.delete(ks);
12804
12957
  if (keys.length) this.resolvedEmitter.fire(keys);
12805
12958
  }
12806
12959
  batchFieldOfKey() {
@@ -12835,6 +12988,15 @@ var DataItems = class {
12835
12988
  "valueField",
12836
12989
  void 0
12837
12990
  );
12991
+ _defineProperty(
12992
+ this,
12993
+ /**
12994
+ * Values equal once normalized are one value (`KeyedItems.normalizeKey`): the rule of keys a source compares its own
12995
+ * way, for items in memory and to spare the source the requests that find it out.
12996
+ */
12997
+ "normalizeKey",
12998
+ void 0
12999
+ );
12838
13000
  _defineProperty(this, "searchMode", "contains");
12839
13001
  _defineProperty(this, "onChanged", this.changedEmitter.event);
12840
13002
  }
@@ -12916,25 +13078,73 @@ var DataItems = class {
12916
13078
  const near = this.findLoaded(value, valueOf, same);
12917
13079
  if (near !== void 0 || !this.source) return near;
12918
13080
  if (isEmptyKey(value)) return void 0;
12919
- const known = KeyedItems.of(this.source, this.valueField);
13081
+ const known = this.keyed(this.source);
12920
13082
  await known.request([value]);
12921
13083
  return known.get(value)?.item;
12922
13084
  }
12923
13085
  findLoaded(value, valueOf, same = Object.is) {
12924
- return (this.source ? this.loaded : this.array).find((item) => same(valueOf(item), value));
13086
+ return (this.source ? this.loaded : this.array).find(this.matcher(value, valueOf, same));
13087
+ }
13088
+ /**
13089
+ * Whether `item` is the item of `value`: its value is the same, the same once normalized (`normalizeKey`), or the
13090
+ * data source matched `value` to it (a key it compares its own way, such as `'A '` for `'A'`).
13091
+ */
13092
+ holds(item, value, valueOf, same = Object.is) {
13093
+ return this.matcher(value, valueOf, same)(item);
13094
+ }
13095
+ /** The test of `holds` for one value, with what is known of it read once: for many items. */
13096
+ matcher(value, valueOf, same = Object.is) {
13097
+ if (isEmptyKey(value)) return (item) => same(valueOf(item), value);
13098
+ const normalized = this.normalizeKey ? this.keyStringOf(value) : null;
13099
+ const matched = this.known(value)?.item;
13100
+ const matchedKey = matched === void 0 ? null : this.keyStringOf(valueOf(matched));
13101
+ return (item) => {
13102
+ const own = valueOf(item);
13103
+ if (same(own, value)) return true;
13104
+ if (normalized === null && matchedKey === null) return false;
13105
+ const key = this.keyStringOf(own);
13106
+ return key === normalized || key === matchedKey;
13107
+ };
13108
+ }
13109
+ /**
13110
+ * Whether two values stand for the same item: they are the same, the same once normalized (`normalizeKey`), or the
13111
+ * data source matched them to one item (`'A '` and `'A'` where it disregards trailing spaces).
13112
+ */
13113
+ sameItem(a, b) {
13114
+ if (Object.is(a, b)) return true;
13115
+ if (isEmptyKey(a) || isEmptyKey(b)) return false;
13116
+ if (this.normalizeKey && this.keyStringOf(a) === this.keyStringOf(b)) return true;
13117
+ if (!this.source) return false;
13118
+ const cache = this.keyed(this.source);
13119
+ if (cache.get(a)?.item === void 0 && cache.get(b)?.item === void 0) return false;
13120
+ return cache.itemKeyOf(a) === cache.itemKeyOf(b);
13121
+ }
13122
+ /** Of `values` (the chosen ones), the one that stands for the same item as `value` (`sameItem`); `null` when none does. */
13123
+ heldIn(values, value) {
13124
+ if (values.has(value)) return { value };
13125
+ if (!values.size || !this.normalizeKey && !this.source) return null;
13126
+ for (const held of values) if (this.sameItem(held, value)) return { value: held };
13127
+ return null;
12925
13128
  }
12926
13129
  /** What is known of the item `find` requested from the data source: loading, found, or not in the source. */
12927
13130
  known(value) {
12928
13131
  if (!this.source || isEmptyKey(value)) return void 0;
12929
- return KeyedItems.of(this.source, this.valueField).get(value);
13132
+ return this.keyed(this.source).get(value);
12930
13133
  }
12931
13134
  /** Requests the item of `value` from the data source again after its request failed. */
12932
13135
  async retry(value) {
12933
13136
  if (!this.source || isEmptyKey(value)) return void 0;
12934
- const known = KeyedItems.of(this.source, this.valueField);
13137
+ const known = this.keyed(this.source);
12935
13138
  await known.retry([value]);
12936
13139
  return known.get(value)?.item;
12937
13140
  }
13141
+ /** The cache of the data source, shared by every list and grid that reads it with the same value field and rule. */
13142
+ keyed(source) {
13143
+ return KeyedItems.of(source, this.valueField, this.normalizeKey);
13144
+ }
13145
+ keyStringOf(value) {
13146
+ return KeyedItems.keyString(this.normalizeKey ? this.normalizeKey(value) : value);
13147
+ }
12938
13148
  reload() {
12939
13149
  return this.source ? this.source.reload() : Promise.resolve();
12940
13150
  }
@@ -13704,6 +13914,7 @@ var OWN$82 = [
13704
13914
  var FUNCTIONS$7 = [
13705
13915
  "textField",
13706
13916
  "valueField",
13917
+ "normalizeKey",
13707
13918
  "iconField",
13708
13919
  "groupField",
13709
13920
  "enabledField",
@@ -13743,6 +13954,7 @@ var DropDown = class extends Field {
13743
13954
  const stopField = follow$1(this, "field", () => {
13744
13955
  this.getProperty("textField");
13745
13956
  this.getProperty("valueField");
13957
+ parts.source.normalizeKey = this.getProperty("normalizeKey") ?? void 0;
13746
13958
  return {
13747
13959
  tick: `${this.getProperty("chosenTick") ?? 0}|${this.getProperty("refreshed") ?? 0}`,
13748
13960
  items: this.items,
@@ -13785,6 +13997,12 @@ var DropDown = class extends Field {
13785
13997
  set valueField(value) {
13786
13998
  this.assignProperty("valueField", functionValue(value));
13787
13999
  }
14000
+ get normalizeKey() {
14001
+ return this.getProperty("normalizeKey");
14002
+ }
14003
+ set normalizeKey(value) {
14004
+ this.assignProperty("normalizeKey", functionValue(value));
14005
+ }
13788
14006
  get iconField() {
13789
14007
  return this.getProperty("iconField");
13790
14008
  }
@@ -14000,22 +14218,26 @@ var DropDown = class extends Field {
14000
14218
  if (field !== void 0) return readItemField(item, field, "value");
14001
14219
  return itemOwnValue(item);
14002
14220
  }
14221
+ /** The test for the item of `value`: the same value, the same once normalized, or the one the data source matched to it. */
14222
+ holderOf(value) {
14223
+ return this.dropParts.source.matcher(value, (item) => this.itemValue(item), (a, b) => this.sameValue(a, b));
14224
+ }
14003
14225
  indexOfValue() {
14004
- const value = this.peekValue();
14226
+ const holds = this.holderOf(this.peekValue());
14005
14227
  const list = this.dropParts.list;
14006
14228
  if (this.dropParts.source.dataSource && list) {
14007
14229
  for (let i = 0; i < list.count; i++) {
14008
14230
  const item = list.itemOf(i);
14009
- if (item !== void 0 && this.sameValue(this.itemValue(item), value)) return i;
14231
+ if (item !== void 0 && holds(item)) return i;
14010
14232
  }
14011
14233
  return -1;
14012
14234
  }
14013
- return this.visibleItems().findIndex((item) => this.sameValue(this.itemValue(item), value));
14235
+ return this.visibleItems().findIndex(holds);
14014
14236
  }
14015
14237
  /** The item of `value`: among the items in memory, or the one known from a data source (asked by key when needed). */
14016
14238
  itemOfValue(items, value) {
14017
14239
  const parts = this.dropParts;
14018
- const same = (item) => this.sameValue(this.itemValue(item), value);
14240
+ const same = this.holderOf(value);
14019
14241
  if (!parts.source.dataSource) return givenList(items).find(same);
14020
14242
  if (isEmptyKey(value)) return void 0;
14021
14243
  if (parts.chosen !== void 0 && same(parts.chosen)) return parts.chosen;
@@ -14223,7 +14445,7 @@ var DropDown = class extends Field {
14223
14445
  const list = new OptionList();
14224
14446
  list.textOf = (item) => this.itemText(item);
14225
14447
  list.enabledOf = (item) => readItemField(item, this.peekProperty("enabledField"), "enabled") !== false;
14226
- list.isSelected = (item) => this.sameValue(this.itemValue(item), this.peekValue());
14448
+ list.isSelected = (item) => this.holderOf(this.peekValue())(item);
14227
14449
  list.emptyText = () => parts.source.loading ? uiLocale.strings.loading : uiLocale.strings.noItems;
14228
14450
  list.onChosen((e) => this.choose(e.item, e.event));
14229
14451
  popup.controls.add(list);
@@ -24644,6 +24866,8 @@ var Toolbar = class extends Control {
24644
24866
  "fit",
24645
24867
  (bar) => {
24646
24868
  this.parts.measuring = false;
24869
+ this.parts.stopFirst = null;
24870
+ if (bar.shown) this.parts.first = false;
24647
24871
  this.parts.laidOut = bar.length;
24648
24872
  if (!this.menuMode()) return;
24649
24873
  untracked(() => {
@@ -24651,6 +24875,7 @@ var Toolbar = class extends Control {
24651
24875
  for (const kid of bar.kids) if (!out.includes(kid)) mark(kid.part, "data-overflowed", false);
24652
24876
  this.parts.out = new Set(out.map((kid) => kid.part));
24653
24877
  this.showOverflow(out);
24878
+ this.keepRoom(bar, out);
24654
24879
  });
24655
24880
  }
24656
24881
  );
@@ -24765,6 +24990,7 @@ var Toolbar = class extends Control {
24765
24990
  overflowed: /* @__PURE__ */ new Set(),
24766
24991
  more: null,
24767
24992
  stopMoreLabel: null,
24993
+ reserve: null,
24768
24994
  restyleQueued: false,
24769
24995
  laying: [],
24770
24996
  laidOut: -1,
@@ -24776,6 +25002,8 @@ var Toolbar = class extends Control {
24776
25002
  stretched: false,
24777
25003
  measuring: false,
24778
25004
  stopRefit: null,
25005
+ first: true,
25006
+ stopFirst: null,
24779
25007
  moreLength: null,
24780
25008
  itemClick: new Emitter()
24781
25009
  };
@@ -24907,7 +25135,7 @@ var Toolbar = class extends Control {
24907
25135
  /** The parts in the bar in order, without the "more" button. For a list or a condition, the parts it holds. */
24908
25136
  barContent(from = this, found = []) {
24909
25137
  for (const part of from.controls.items) {
24910
- if (part === this.parts.more) continue;
25138
+ if (part === this.parts.more || part === this.parts.reserve) continue;
24911
25139
  if (isElement(part.element)) found.push(part);
24912
25140
  else this.barContent(part, found);
24913
25141
  }
@@ -24928,7 +25156,7 @@ var Toolbar = class extends Control {
24928
25156
  }
24929
25157
  /** A control added to the bar or taken away: the arrows and the room follow. The "more" button is no part of the bar. */
24930
25158
  childChanged(control) {
24931
- if (control === this.parts.more) return;
25159
+ if (control === this.parts.more || control === this.parts.reserve) return;
24932
25160
  this.queueRestyle();
24933
25161
  this.layout();
24934
25162
  }
@@ -24985,12 +25213,19 @@ var Toolbar = class extends Control {
24985
25213
  parts.out.clear();
24986
25214
  for (const kid of parts.laying) mark(kid.part, "data-overflowed", false);
24987
25215
  if (parts.more) mark(parts.more, "data-idle", true);
25216
+ if (parts.reserve) mark(parts.reserve, "data-idle", true);
24988
25217
  parts.stopRefit?.();
24989
25218
  parts.stopRefit = null;
24990
- if (this.menuMode()) {
24991
- parts.measuring = true;
24992
- measure(this, this.readBar, this.fit);
24993
- } else this.showOverflow([]);
25219
+ parts.stopFirst?.();
25220
+ parts.stopFirst = null;
25221
+ if (!this.menuMode()) {
25222
+ parts.measuring = false;
25223
+ this.showOverflow([]);
25224
+ return;
25225
+ }
25226
+ parts.measuring = true;
25227
+ if (parts.first && canMeasure(this)) parts.stopFirst = measureAfterDrawn(this, this.readBar, this.fit);
25228
+ else measure(this, this.readBar, this.fit);
24994
25229
  });
24995
25230
  }
24996
25231
  /**
@@ -25031,6 +25266,34 @@ var Toolbar = class extends Control {
25031
25266
  menuMode() {
25032
25267
  return (this.peekProperty("overflow") ?? "menu") === "menu";
25033
25268
  }
25269
+ /**
25270
+ * Keeps the room of the parts put in the "more" menu in the bar's own size, so it still asks what holds it for the
25271
+ * room of every part: a hidden part as long as they are, which takes no room on the bar (it grows by a millionth of
25272
+ * the room to spare). A bar sized by its parts then grows when what holds it does, and its size notice puts them
25273
+ * back; without it, the bar would stay as small as the parts left on it.
25274
+ */
25275
+ keepRoom({ kids, gap, sizes }, out) {
25276
+ const parts = this.parts;
25277
+ const shown = kids.filter((kid) => sizes.has(kid));
25278
+ const always = new Set(shown.filter((kid) => kid.movable && kid.overflow === "always"));
25279
+ const length = (list, more) => list.reduce((sum, kid) => sum + sizes.get(kid), 0) + gap * Math.max(0, list.length - 1) + (more ? (list.length ? gap : 0) + (parts.moreLength ?? 0) : 0);
25280
+ const missing = length(shown.filter((kid) => !always.has(kid)), always.size > 0) - length(shown.filter((kid) => !out.includes(kid)), out.some((kid) => !kid.separator));
25281
+ if (missing < .5) {
25282
+ if (parts.reserve) mark(parts.reserve, "data-idle", true);
25283
+ return;
25284
+ }
25285
+ const reserve = parts.reserve ?? this.makeReserve();
25286
+ css(reserve, "--_reserve", `${missing}px`);
25287
+ css(reserve, "--_reserve-gap", `${gap}px`);
25288
+ mark(reserve, "data-idle", false);
25289
+ }
25290
+ makeReserve() {
25291
+ const reserve = loose("span", "mx-toolbar__reserve");
25292
+ put(reserve, "aria-hidden", "true");
25293
+ this.parts.reserve = reserve;
25294
+ this.controls.add(reserve);
25295
+ return reserve;
25296
+ }
25034
25297
  showOverflow(out) {
25035
25298
  const parts = this.parts;
25036
25299
  const focused = rememberFocus();
@@ -31347,6 +31610,7 @@ var OWN$45 = [
31347
31610
  var FUNCTIONS$6 = [
31348
31611
  "textField",
31349
31612
  "valueField",
31613
+ "normalizeKey",
31350
31614
  "iconField",
31351
31615
  "groupField",
31352
31616
  "enabledField",
@@ -31381,6 +31645,10 @@ var ComboBox = class extends Field {
31381
31645
  this.observeProperty("clearButton", () => this.renderClear());
31382
31646
  this.observeProperty("dataSource", () => this.renderSource());
31383
31647
  this.observeProperty("valueField", (field) => parts.items.valueField = typeof field === "string" ? field : void 0);
31648
+ this.observeProperty("normalizeKey", (rule) => {
31649
+ parts.items.normalizeKey = rule ?? void 0;
31650
+ this.renderValue(this.peekValue());
31651
+ });
31384
31652
  this.observeProperty("searchMode", (mode) => parts.items.searchMode = mode === "startswith" ? "startswith" : "contains");
31385
31653
  parts.items.textOf = (item) => this.itemText(item);
31386
31654
  parts.items.onChanged(() => this.itemsChanged());
@@ -31423,6 +31691,12 @@ var ComboBox = class extends Field {
31423
31691
  set valueField(value) {
31424
31692
  this.assignProperty("valueField", functionValue(value));
31425
31693
  }
31694
+ get normalizeKey() {
31695
+ return this.getProperty("normalizeKey");
31696
+ }
31697
+ set normalizeKey(value) {
31698
+ this.assignProperty("normalizeKey", functionValue(value));
31699
+ }
31426
31700
  get iconField() {
31427
31701
  return this.getProperty("iconField");
31428
31702
  }
@@ -31595,7 +31869,7 @@ var ComboBox = class extends Field {
31595
31869
  return;
31596
31870
  }
31597
31871
  const lookup = ++parts.lookup;
31598
- this.showText(parts.chosen !== void 0 && this.sameValue(this.itemValue(parts.chosen), value) ? this.itemText(parts.chosen) : "");
31872
+ this.showText(parts.chosen !== void 0 && this.holderOf(value)(parts.chosen) ? this.itemText(parts.chosen) : "");
31599
31873
  parts.items.find(value, (item) => this.itemValue(item)).then((item) => {
31600
31874
  if (lookup !== parts.lookup || this.isDisposed) return;
31601
31875
  parts.chosen = item;
@@ -31609,6 +31883,10 @@ var ComboBox = class extends Field {
31609
31883
  itemText(item) {
31610
31884
  return String(readItemField(item, this.peekProperty("textField"), "text") ?? "");
31611
31885
  }
31886
+ /** The test for the item of `value`: the same value, the same once normalized, or the one the data source matched to it. */
31887
+ holderOf(value) {
31888
+ return this.comboParts.items.matcher(value, (item) => this.itemValue(item), (a, b) => this.sameValue(a, b));
31889
+ }
31612
31890
  itemValue(item) {
31613
31891
  const field = this.peekProperty("valueField");
31614
31892
  if (field !== void 0) return readItemField(item, field, "value");
@@ -31787,11 +32065,14 @@ var ComboBox = class extends Field {
31787
32065
  if (!list) return;
31788
32066
  const value = this.peekValue();
31789
32067
  let index = -1;
31790
- if (!parts.editing && value !== null) for (let i = 0; i < list.count; i++) {
31791
- const item = list.itemOf(i);
31792
- if (item !== void 0 && this.sameValue(this.itemValue(item), value)) {
31793
- index = i;
31794
- break;
32068
+ if (!parts.editing && value !== null) {
32069
+ const holds = this.holderOf(value);
32070
+ for (let i = 0; i < list.count; i++) {
32071
+ const item = list.itemOf(i);
32072
+ if (item !== void 0 && holds(item)) {
32073
+ index = i;
32074
+ break;
32075
+ }
31795
32076
  }
31796
32077
  }
31797
32078
  if (index >= 0) list.setActive(index);
@@ -31829,7 +32110,7 @@ var ComboBox = class extends Field {
31829
32110
  const list = new OptionList();
31830
32111
  list.textOf = (item) => this.itemText(item);
31831
32112
  list.enabledOf = (item) => this.canChoose(item);
31832
- list.isSelected = (item) => this.sameValue(this.itemValue(item), this.peekValue());
32113
+ list.isSelected = (item) => this.holderOf(this.peekValue())(item);
31833
32114
  list.emptyText = () => parts.items.loading ? uiLocale.strings.loading : uiLocale.strings.noItems;
31834
32115
  list.onChosen((e) => {
31835
32116
  this.choose(e.item, this.itemValue(e.item), e.event);
@@ -34081,11 +34362,11 @@ var ListRows = class {
34081
34362
  //#endregion
34082
34363
  //#region src/components/listbox/select-all-state.ts
34083
34364
  /** Whether the items the list shows are all chosen (`true`), none of them (`false`) or some (`'mixed'`). */
34084
- function selectAllState(items, chosen, valueOf, enabledOf) {
34365
+ function selectAllState(items, chosen, isChosen, enabledOf) {
34085
34366
  if (!chosen.size) return false;
34086
34367
  const rows = items.loaded.filter(enabledOf);
34087
34368
  let hits = 0;
34088
- for (const row of rows) if (chosen.has(valueOf(row))) hits++;
34369
+ for (const row of rows) if (isChosen(row)) hits++;
34089
34370
  if (!hits) return items.dataSource && !items.searchText ? "mixed" : false;
34090
34371
  return hits === rows.length && (!items.dataSource || chosen.size >= items.count) ? true : "mixed";
34091
34372
  }
@@ -34170,6 +34451,7 @@ var OWN$40 = [
34170
34451
  var FUNCTIONS$5 = [
34171
34452
  "textField",
34172
34453
  "valueField",
34454
+ "normalizeKey",
34173
34455
  "iconField",
34174
34456
  "groupField",
34175
34457
  "enabledField",
@@ -34231,7 +34513,13 @@ var TagBox = class extends Field {
34231
34513
  this.observeProperty("matchWidth", (on) => {
34232
34514
  if (parts.popup) parts.popup.matchWidth = on !== false;
34233
34515
  });
34234
- this.observeProperty("valueField", () => {
34516
+ this.observeProperty("valueField", (field) => {
34517
+ parts.items.valueField = typeof field === "string" ? field : void 0;
34518
+ parts.known.clear();
34519
+ this.renderValue(this.peekValue());
34520
+ });
34521
+ this.observeProperty("normalizeKey", (rule) => {
34522
+ parts.items.normalizeKey = rule ?? void 0;
34235
34523
  parts.known.clear();
34236
34524
  this.renderValue(this.peekValue());
34237
34525
  });
@@ -34286,6 +34574,12 @@ var TagBox = class extends Field {
34286
34574
  set valueField(value) {
34287
34575
  this.assignProperty("valueField", functionValue(value));
34288
34576
  }
34577
+ get normalizeKey() {
34578
+ return this.getProperty("normalizeKey");
34579
+ }
34580
+ set normalizeKey(value) {
34581
+ this.assignProperty("normalizeKey", functionValue(value));
34582
+ }
34289
34583
  get iconField() {
34290
34584
  return this.getProperty("iconField");
34291
34585
  }
@@ -34535,6 +34829,11 @@ var TagBox = class extends Field {
34535
34829
  itemText(item) {
34536
34830
  return String(readItemField(item, this.peekProperty("textField"), "text") ?? "");
34537
34831
  }
34832
+ /** Whether `item` is chosen: its value is, or a chosen value stands for it (`DataItems.sameItem`). */
34833
+ isChosen(item) {
34834
+ const parts = this.tagParts;
34835
+ return parts.items.heldIn(parts.chosen, this.itemValue(item)) !== null;
34836
+ }
34538
34837
  itemValue(item) {
34539
34838
  const field = this.peekProperty("valueField");
34540
34839
  if (field !== void 0) return readItemField(item, field, "value");
@@ -34596,7 +34895,7 @@ var TagBox = class extends Field {
34596
34895
  }
34597
34896
  allState() {
34598
34897
  const parts = this.tagParts;
34599
- return selectAllState(parts.items, parts.chosen, (item) => this.itemValue(item), (item) => this.canChoose(item));
34898
+ return selectAllState(parts.items, parts.chosen, (item) => this.isChosen(item), (item) => this.canChoose(item));
34600
34899
  }
34601
34900
  renderSource() {
34602
34901
  const parts = this.tagParts;
@@ -34729,9 +35028,9 @@ var TagBox = class extends Field {
34729
35028
  list.enabledOf = (row) => {
34730
35029
  if (row === selectAllRow) return true;
34731
35030
  const item = row;
34732
- return this.canChoose(item) && (!this.atLimit() || parts.chosen.has(this.itemValue(item)));
35031
+ return this.canChoose(item) && (!this.atLimit() || this.isChosen(item));
34733
35032
  };
34734
- list.isSelected = (row) => row === selectAllRow ? this.allState() === true : parts.chosen.has(this.itemValue(row));
35033
+ list.isSelected = (row) => row === selectAllRow ? this.allState() === true : this.isChosen(row);
34735
35034
  list.emptyText = () => parts.items.loading ? uiLocale.strings.loading : uiLocale.strings.noItems;
34736
35035
  list.onChosen((e) => this.chosen(e));
34737
35036
  popup.controls.add(list);
@@ -34774,7 +35073,7 @@ var TagBox = class extends Field {
34774
35073
  parts.sourceCount = -1;
34775
35074
  list.groupOf = group === void 0 ? null : (row) => row === selectAllRow ? void 0 : readItemField(row, group, "group") ?? void 0;
34776
35075
  let shown = parts.items.loaded;
34777
- if (this.peekProperty("hideSelected")) shown = shown.filter((item) => !parts.chosen.has(this.itemValue(item)));
35076
+ if (this.peekProperty("hideSelected")) shown = shown.filter((item) => !this.isChosen(item));
34778
35077
  list.setItems(withAll && shown.length ? [selectAllRow, ...shown] : shown);
34779
35078
  }
34780
35079
  this.pointAt();
@@ -34862,7 +35161,8 @@ var TagBox = class extends Field {
34862
35161
  if (!this.canChange() || !this.canChoose(item)) return;
34863
35162
  const value = this.itemValue(item);
34864
35163
  const values = this.values();
34865
- if (parts.chosen.has(value)) this.commit(values.filter((v) => !Object.is(v, value)), event);
35164
+ const held = parts.items.heldIn(parts.chosen, value);
35165
+ if (held) this.commit(values.filter((v) => !Object.is(v, held.value)), event);
34866
35166
  else {
34867
35167
  if (this.atLimit()) return;
34868
35168
  parts.known.remember(item);
@@ -34890,7 +35190,7 @@ var TagBox = class extends Field {
34890
35190
  const make = this.peekProperty("customValue");
34891
35191
  const value = make ? make(text) : text;
34892
35192
  if (value === null || value === void 0 || this.atLimit()) return false;
34893
- if (!this.tagParts.chosen.has(value)) this.commit([...this.values(), value], event);
35193
+ if (!this.tagParts.items.heldIn(this.tagParts.chosen, value)) this.commit([...this.values(), value], event);
34894
35194
  this.chosenDone();
34895
35195
  return true;
34896
35196
  }
@@ -34903,7 +35203,7 @@ var TagBox = class extends Field {
34903
35203
  const current = this.values();
34904
35204
  const chosen = new Set(current);
34905
35205
  const set = new Set(shown);
34906
- let next = on ? [...current, ...shown.filter((v) => !chosen.has(v))] : current.filter((v) => !set.has(v));
35206
+ let next = on ? [...current, ...shown.filter((v) => !parts.items.heldIn(chosen, v))] : current.filter((v) => !parts.items.heldIn(set, v));
34907
35207
  const max = this.peekProperty("maxSelected") ?? 0;
34908
35208
  if (max > 0 && next.length > max) next = next.slice(0, Math.max(max, current.length));
34909
35209
  this.commit(next, event);
@@ -36150,6 +36450,7 @@ var CellEditor = class {
36150
36450
  clearButton: lookup.allowClearing ?? false,
36151
36451
  searchEnabled: true
36152
36452
  };
36453
+ if (lookup.normalizeKey) options.normalizeKey = lookup.normalizeKey;
36153
36454
  if (Array.isArray(source)) {
36154
36455
  const test = search.filter ? data.createRowFilter(search.filter, { locale: search.locale }) : null;
36155
36456
  options.items = test ? source.filter((item) => item !== null && typeof item === "object" && test(item)) : source;
@@ -40309,6 +40610,15 @@ var FilterModel = class {
40309
40610
  "conditionOf",
40310
40611
  () => null
40311
40612
  );
40613
+ _defineProperty(
40614
+ this,
40615
+ /**
40616
+ * The keys a lookup column's chosen key stands with: the keys its list showed as one item (the source matched them to
40617
+ * it); a key alone otherwise. The grid gives it.
40618
+ */
40619
+ "keysOf",
40620
+ (_field, value) => [value]
40621
+ );
40312
40622
  _defineProperty(
40313
40623
  this,
40314
40624
  /** Whether the filter row and the header filters are part of the filter value (`filterSyncEnabled`); the grid gives it. */
@@ -40693,7 +41003,11 @@ var FilterModel = class {
40693
41003
  if (!this.columns.can(field, "filterRow")) return null;
40694
41004
  const col = this.columns.get(field);
40695
41005
  if (col.type === "boolean") return typeof f.value === "boolean" ? data.where(field, "=", f.value) : null;
40696
- if (col.lookup) return empty$2(f.value) ? null : data.where(field, "=", f.value);
41006
+ if (col.lookup) {
41007
+ if (empty$2(f.value)) return null;
41008
+ const keys = this.keysOf(field, f.value);
41009
+ return keys.length > 1 ? data.where(field, "in", [...keys]) : data.where(field, "=", f.value);
41010
+ }
40697
41011
  const op = this.operator(field);
40698
41012
  if (op === "isblank" || op === "isnotblank") return data.where(field, op);
40699
41013
  if (op === "between") {
@@ -40718,7 +41032,7 @@ var FilterModel = class {
40718
41032
  const condition = empty$2(v) ? null : own?.(v);
40719
41033
  if (empty$2(v)) blank = true;
40720
41034
  else if (condition) parts.push(condition);
40721
- else plain.push(v);
41035
+ else plain.push(...this.keysOf(field, v));
40722
41036
  }
40723
41037
  const any = data.or(plain.length ? data.where(field, "in", plain) : null, ...parts, blank ? data.where(field, "isblank") : null);
40724
41038
  return any && f.filterType === "exclude" ? data.not(any) : any;
@@ -40809,8 +41123,21 @@ function searchOf(filter) {
40809
41123
  var LookupValues = class {
40810
41124
  constructor(model) {
40811
41125
  _defineProperty(this, "model", void 0);
41126
+ _defineProperty(
41127
+ this,
41128
+ /** By column, the keys each entry of its last list stands for, when the source matched more than one key to its item. */
41129
+ "merged",
41130
+ /* @__PURE__ */ new Map()
41131
+ );
40812
41132
  this.model = model;
40813
41133
  }
41134
+ /** The keys `value` stands with in the column's list (see `FilterModel.keysOf`): itself alone, unless its entry holds several. */
41135
+ keysOf(field, value) {
41136
+ const byKey = this.merged.get(field);
41137
+ if (!byKey?.size) return [value];
41138
+ const items = this.model.lookups.items(this.model.columns.get(field));
41139
+ return byKey.get(items ? items.keyStringOf(value) : String(value)) ?? [value];
41140
+ }
40814
41141
  /** The filter of the other columns (and the source's own), which a synced list honors. */
40815
41142
  otherFilter(field) {
40816
41143
  return data.and(this.model.baseFilter, this.model.filters.expression(void 0, field));
@@ -40892,9 +41219,25 @@ var LookupValues = class {
40892
41219
  }
40893
41220
  }
40894
41221
  await items?.request([...counts.values()].map((b) => b.value));
41222
+ const byItem = /* @__PURE__ */ new Map();
41223
+ for (const b of counts.values()) {
41224
+ const id = b.value === null ? "" : items ? `i${items.itemKeyOf(b.value)}` : `v${typeof b.value}:${String(b.value)}`;
41225
+ const one = byItem.get(id);
41226
+ if (one) {
41227
+ one.count += b.count;
41228
+ one.keys.push(b.value);
41229
+ } else byItem.set(id, {
41230
+ value: b.value,
41231
+ count: b.count,
41232
+ keys: [b.value]
41233
+ });
41234
+ }
41235
+ const merged = /* @__PURE__ */ new Map();
41236
+ for (const one of byItem.values()) if (one.keys.length > 1 && items) merged.set(items.keyStringOf(one.value), one.keys);
41237
+ this.merged.set(field, merged);
40895
41238
  const lower = search.trim().toLocaleLowerCase(model.formatter.locale);
40896
41239
  const collator = model.formatter.collator;
40897
- const all = [...counts.values()].filter((b) => !lookups.isMissing(col, b.value)).map((b) => entry(b.value, b.count)).filter((e) => !lower || e.value !== null && e.text.toLocaleLowerCase(model.formatter.locale).includes(lower)).sort((a, b) => a.value === null ? -1 : b.value === null ? 1 : collator.compare(a.text, b.text));
41240
+ const all = [...byItem.values()].filter((b) => !lookups.isMissing(col, b.value)).map((b) => entry(b.value, b.count)).filter((e) => !lower || e.value !== null && e.text.toLocaleLowerCase(model.formatter.locale).includes(lower)).sort((a, b) => a.value === null ? -1 : b.value === null ? 1 : collator.compare(a.text, b.text));
40898
41241
  return {
40899
41242
  values: all.slice(skip, skip + take),
40900
41243
  total: all.length
@@ -43612,7 +43955,7 @@ var LookupTexts = class {
43612
43955
  if (!lookup) return null;
43613
43956
  const source = readField(lookup, "dataSource");
43614
43957
  if (!source) return null;
43615
- const items = KeyedItems.of(source, lookup.valueField);
43958
+ const items = KeyedItems.of(source, lookup.valueField, lookup.normalizeKey);
43616
43959
  if (lookup.resolve) items.resolve = lookup.resolve;
43617
43960
  if (lookup.batchSize) items.batchSize = lookup.batchSize;
43618
43961
  if (lookup.parallelRequests) items.parallelRequests = lookup.parallelRequests;
@@ -43623,6 +43966,10 @@ var LookupTexts = class {
43623
43966
  })));
43624
43967
  return items;
43625
43968
  }
43969
+ /** The string a key of the column is kept under: by its cache (`normalizeKey`), else as it is. */
43970
+ keyOf(col, value) {
43971
+ return this.items(col)?.keyStringOf(value) ?? KeyedItems.keyString(value);
43972
+ }
43626
43973
  /** The text of an item: `textField`, else its `text`, else its value. */
43627
43974
  textOf(col, item) {
43628
43975
  const field = col.lookup?.textField;
@@ -43654,7 +44001,7 @@ var LookupTexts = class {
43654
44001
  state: "none"
43655
44002
  };
43656
44003
  if (Array.isArray(value) && !(col.textFrom && !edited)) return this.listText(col, value, ask);
43657
- const chosen = this.chosen.get(col.field)?.get(KeyedItems.keyString(value));
44004
+ const chosen = this.chosen.get(col.field)?.get(this.keyOf(col, value));
43658
44005
  if (chosen !== void 0) return {
43659
44006
  text: chosen,
43660
44007
  state: "found"
@@ -43676,7 +44023,7 @@ var LookupTexts = class {
43676
44023
  state: "none"
43677
44024
  };
43678
44025
  if (Array.isArray(value)) return this.listText(col, value, ask);
43679
- const chosen = this.chosen.get(col.field)?.get(KeyedItems.keyString(value));
44026
+ const chosen = this.chosen.get(col.field)?.get(this.keyOf(col, value));
43680
44027
  if (chosen !== void 0) return {
43681
44028
  text: chosen,
43682
44029
  state: "found"
@@ -43737,7 +44084,7 @@ var LookupTexts = class {
43737
44084
  textOfKey(col, value) {
43738
44085
  if (data.isEmpty(value)) return "";
43739
44086
  if (Array.isArray(value)) return joinItems(listValues(value).map((v) => this.textOfKey(col, v)), this.locale());
43740
- const chosen = this.chosen.get(col.field)?.get(KeyedItems.keyString(value));
44087
+ const chosen = this.chosen.get(col.field)?.get(this.keyOf(col, value));
43741
44088
  if (chosen !== void 0) return chosen;
43742
44089
  const known = this.items(col)?.get(value);
43743
44090
  return known?.state === "found" ? known.text ?? this.textOf(col, known.item) : String(value);
@@ -43754,13 +44101,13 @@ var LookupTexts = class {
43754
44101
  const text = typeof itemOrText === "string" ? itemOrText : this.textOf(col, itemOrText);
43755
44102
  let byKey = this.chosen.get(col.field);
43756
44103
  if (!byKey) this.chosen.set(col.field, byKey = /* @__PURE__ */ new Map());
43757
- byKey.set(KeyedItems.keyString(value), text);
44104
+ byKey.set(this.keyOf(col, value), text);
43758
44105
  this.items(col)?.remember(value, itemOrText);
43759
44106
  }
43760
44107
  /** Whether the source said it does not have the key (a failed request does not count). */
43761
44108
  isMissing(col, value) {
43762
44109
  if (Array.isArray(value)) return listValues(value).some((v) => this.isMissing(col, v));
43763
- if (data.isEmpty(value) || this.chosen.get(col.field)?.has(KeyedItems.keyString(value))) return false;
44110
+ if (data.isEmpty(value) || this.chosen.get(col.field)?.has(this.keyOf(col, value))) return false;
43764
44111
  const known = this.items(col)?.get(value);
43765
44112
  return known?.state === "missing" && !known.failed;
43766
44113
  }
@@ -43845,7 +44192,7 @@ var LookupTexts = class {
43845
44192
  return (row) => {
43846
44193
  const value = cellValue(col, row);
43847
44194
  if (data.isEmpty(value)) return null;
43848
- const chosen = this.chosen.get(col.field)?.get(KeyedItems.keyString(value));
44195
+ const chosen = this.chosen.get(col.field)?.get(this.keyOf(col, value));
43849
44196
  if (chosen !== void 0) return chosen;
43850
44197
  const known = this.items(col)?.get(value);
43851
44198
  return known?.state === "found" ? known.text ?? this.textOf(col, known.item) : null;
@@ -44816,6 +45163,7 @@ var GridModel = class {
44816
45163
  };
44817
45164
  this.values = new FilterValues(this);
44818
45165
  this.filters.conditionOf = (field) => this.values.conditionOf(field);
45166
+ this.filters.keysOf = (field, value) => this.values.lookups.keysOf(field, value);
44819
45167
  const filterValue = stored ? this.reviveExpression(stored.filterValue ?? null) : read(props.filterValue);
44820
45168
  if (filterValue) {
44821
45169
  untracked(() => this.filters.filterValue());
@@ -48253,13 +48601,16 @@ var NO_FRAME = Object.freeze({
48253
48601
  /**
48254
48602
  * Widths of action buttons, measured once per action (its id, text and look) in a hidden cell and
48255
48603
  * kept, so fitting a row's buttons only adds numbers: scrolling triggers no layout. An action not
48256
- * measured yet counts 0 and is measured with the window's next reads; `measured` then asks the rows
48257
- * to fit their buttons again. A width of 0 (the grid is not shown yet) is not kept.
48604
+ * measured yet counts 0 and is measured once the page is drawn, with everything asked in that frame:
48605
+ * read then, it lays nothing out. `waiting` tells while it waits (the rows keep their buttons out of
48606
+ * sight meanwhile) and `measured` then asks the rows to fit their buttons again. A width of 0 (the
48607
+ * grid is not shown yet) is not kept.
48258
48608
  */
48259
48609
  var ActionWidths = class {
48260
- constructor(host, measured = () => {}) {
48610
+ constructor(host, measured = () => {}, waiting = () => {}) {
48261
48611
  _defineProperty(this, "host", void 0);
48262
48612
  _defineProperty(this, "measured", void 0);
48613
+ _defineProperty(this, "waiting", void 0);
48263
48614
  _defineProperty(this, "widths", /* @__PURE__ */ new Map());
48264
48615
  _defineProperty(this, "frameSize", null);
48265
48616
  _defineProperty(this, "box", null);
@@ -48275,6 +48626,12 @@ var ActionWidths = class {
48275
48626
  "moreProbe",
48276
48627
  null
48277
48628
  );
48629
+ _defineProperty(
48630
+ this,
48631
+ /** Takes back the read that waits for the page to be drawn. */
48632
+ "pending",
48633
+ null
48634
+ );
48278
48635
  _defineProperty(this, "read", () => {
48279
48636
  const box = this.box;
48280
48637
  const more = this.moreProbe;
@@ -48298,6 +48655,10 @@ var ActionWidths = class {
48298
48655
  };
48299
48656
  });
48300
48657
  _defineProperty(this, "write", (seen) => {
48658
+ if (this.pending) {
48659
+ this.pending = null;
48660
+ this.waiting(false);
48661
+ }
48301
48662
  let kept = false;
48302
48663
  for (const { key, button, width } of seen.buttons) {
48303
48664
  if (this.probes.get(key) === button) this.probes.delete(key);
@@ -48319,6 +48680,7 @@ var ActionWidths = class {
48319
48680
  });
48320
48681
  this.host = host;
48321
48682
  this.measured = measured;
48683
+ this.waiting = waiting;
48322
48684
  }
48323
48685
  /** Measure again (the density changed). */
48324
48686
  clear() {
@@ -48337,7 +48699,7 @@ var ActionWidths = class {
48337
48699
  box.controls.add(button);
48338
48700
  this.probes.set(key, button);
48339
48701
  }
48340
- measure(box, this.read, this.write);
48702
+ this.ask(box);
48341
48703
  return 0;
48342
48704
  }
48343
48705
  /** The cell's padding (both sides), the gap between buttons and the width of the "more" button; zeros until measured. */
@@ -48351,9 +48713,19 @@ var ActionWidths = class {
48351
48713
  box.controls.add(more);
48352
48714
  this.moreProbe = more;
48353
48715
  }
48354
- measure(box, this.read, this.write);
48716
+ this.ask(box);
48355
48717
  return NO_FRAME;
48356
48718
  }
48719
+ /** One read for everything asked before the page is drawn; a window that lays nothing out (a test document) reads with its next round. */
48720
+ ask(box) {
48721
+ if (!canMeasure(box)) {
48722
+ measure(box, this.read, this.write);
48723
+ return;
48724
+ }
48725
+ if (this.pending) return;
48726
+ this.pending = measureAfterDrawn(box, this.read, this.write);
48727
+ this.waiting(true);
48728
+ }
48357
48729
  cell() {
48358
48730
  const host = this.host();
48359
48731
  if (!host) return null;
@@ -52375,7 +52747,10 @@ var GridRow = class {
52375
52747
  for (const [field, text] of this.texts) {
52376
52748
  const col = model.columns.get(field);
52377
52749
  if (!col.lookup || model.lookups.items(col) !== items) continue;
52378
- if (wanted && !wanted.has(KeyedItems.keyString(model.value(this.rowId, this.row, col)))) continue;
52750
+ if (wanted) {
52751
+ const value = model.value(this.rowId, this.row, col);
52752
+ if (!(Array.isArray(value) ? value : [value]).some((key) => wanted.has(items.keyStringOf(key)))) continue;
52753
+ }
52379
52754
  this.drawLookup(this.cellParts.get(field), text, col);
52380
52755
  }
52381
52756
  }
@@ -55568,6 +55943,7 @@ var OWN$36 = [
55568
55943
  var FUNCTIONS$3 = [
55569
55944
  "textField",
55570
55945
  "valueField",
55946
+ "normalizeKey",
55571
55947
  "iconField",
55572
55948
  "groupField",
55573
55949
  "enabledField",
@@ -55610,7 +55986,13 @@ var ListBox = class extends Field {
55610
55986
  this.observeProperty("searchEnabled", () => this.renderSearch());
55611
55987
  this.observeProperty("height", (height) => this.renderHeight(height));
55612
55988
  this.observeProperty("selectionMode", (mode) => put(this, "data-selection-mode", mode ?? "single"));
55613
- this.observeProperty("valueField", () => {
55989
+ this.observeProperty("valueField", (field) => {
55990
+ parts.items.valueField = typeof field === "string" ? field : void 0;
55991
+ parts.known.clear();
55992
+ this.renderValue(this.peekValue());
55993
+ });
55994
+ this.observeProperty("normalizeKey", (rule) => {
55995
+ parts.items.normalizeKey = rule ?? void 0;
55614
55996
  parts.known.clear();
55615
55997
  this.renderValue(this.peekValue());
55616
55998
  });
@@ -55654,6 +56036,12 @@ var ListBox = class extends Field {
55654
56036
  set valueField(value) {
55655
56037
  this.assignProperty("valueField", functionValue(value));
55656
56038
  }
56039
+ get normalizeKey() {
56040
+ return this.getProperty("normalizeKey");
56041
+ }
56042
+ set normalizeKey(value) {
56043
+ this.assignProperty("normalizeKey", functionValue(value));
56044
+ }
55657
56045
  get iconField() {
55658
56046
  return this.getProperty("iconField");
55659
56047
  }
@@ -55808,6 +56196,11 @@ var ListBox = class extends Field {
55808
56196
  itemText(item) {
55809
56197
  return String(readItemField(item, this.peekProperty("textField"), "text") ?? "");
55810
56198
  }
56199
+ /** Whether `item` is chosen: its value is, or a chosen value stands for it (`DataItems.sameItem`). */
56200
+ isChosen(item) {
56201
+ const parts = this.listParts;
56202
+ return parts.items.heldIn(parts.chosen, this.itemValue(item)) !== null;
56203
+ }
55811
56204
  itemValue(item) {
55812
56205
  const field = this.peekProperty("valueField");
55813
56206
  if (field !== void 0) return readItemField(item, field, "value");
@@ -55838,7 +56231,7 @@ var ListBox = class extends Field {
55838
56231
  setUpList(list) {
55839
56232
  list.textOf = (row) => row === selectAllRow ? "" : this.itemText(row);
55840
56233
  list.enabledOf = (row) => row === selectAllRow || this.canChoose(row);
55841
- list.isSelected = (row) => row === selectAllRow ? this.allState() === true : this.listParts.chosen.has(this.itemValue(row));
56234
+ list.isSelected = (row) => row === selectAllRow ? this.allState() === true : this.isChosen(row);
55842
56235
  list.emptyText = () => this.peekProperty("noItemsText") || (this.listParts.items.loading ? uiLocale.strings.loading : uiLocale.strings.noItems);
55843
56236
  }
55844
56237
  /** Gives the list a drawing for the template now, made anew only when the template changes. */
@@ -55872,7 +56265,7 @@ var ListBox = class extends Field {
55872
56265
  }
55873
56266
  allState() {
55874
56267
  const parts = this.listParts;
55875
- return selectAllState(parts.items, parts.chosen, (item) => this.itemValue(item), (item) => this.canChoose(item));
56268
+ return selectAllState(parts.items, parts.chosen, (item) => this.isChosen(item), (item) => this.canChoose(item));
55876
56269
  }
55877
56270
  renderSource() {
55878
56271
  const parts = this.listParts;
@@ -56020,7 +56413,7 @@ var ListBox = class extends Field {
56020
56413
  let index = -1;
56021
56414
  if (parts.chosen.size) for (let i = 0; i < list.count && index < 0; i++) {
56022
56415
  const row = list.itemOf(i);
56023
- if (row !== void 0 && row !== selectAllRow && parts.chosen.has(this.itemValue(row))) index = i;
56416
+ if (row !== void 0 && row !== selectAllRow && this.isChosen(row)) index = i;
56024
56417
  }
56025
56418
  if (index >= 0) list.setActive(index);
56026
56419
  else list.move("first");
@@ -56105,8 +56498,9 @@ var ListBox = class extends Field {
56105
56498
  }
56106
56499
  const values = this.valuesOf(this.peekValue());
56107
56500
  let next;
56501
+ const held = parts.items.heldIn(parts.chosen, value);
56108
56502
  if (how === "only") next = [value];
56109
- else if (parts.chosen.has(value)) next = how === "toggle" ? values.filter((v) => !Object.is(v, value)) : values;
56503
+ else if (held) next = how === "toggle" ? values.filter((v) => !Object.is(v, held.value)) : values;
56110
56504
  else next = [...values, value];
56111
56505
  this.commit(next, event);
56112
56506
  }
@@ -56121,7 +56515,7 @@ var ListBox = class extends Field {
56121
56515
  const row = parts.list.itemOf(i);
56122
56516
  if (row === void 0 || row === selectAllRow || !this.canChoose(row)) continue;
56123
56517
  const value = this.itemValue(row);
56124
- if (!next.some((v) => Object.is(v, value))) next.push(value);
56518
+ if (!next.some((v) => parts.items.sameItem(v, value))) next.push(value);
56125
56519
  }
56126
56520
  this.commit(next, event);
56127
56521
  }
@@ -56135,7 +56529,7 @@ var ListBox = class extends Field {
56135
56529
  const current = this.valuesOf(this.peekValue());
56136
56530
  const chosen = new Set(current);
56137
56531
  const set = new Set(shown);
56138
- const next = on ? [...current, ...shown.filter((v) => !chosen.has(v))] : current.filter((v) => !set.has(v));
56532
+ const next = on ? [...current, ...shown.filter((v) => !parts.items.heldIn(chosen, v))] : current.filter((v) => !parts.items.heldIn(set, v));
56139
56533
  this.commit(next, event);
56140
56534
  }
56141
56535
  };
@@ -56845,7 +57239,7 @@ var FilterBuilderModel = class {
56845
57239
  const source = givenField(lookup, "dataSource");
56846
57240
  if (!source) return String(v);
56847
57241
  this.state.texts;
56848
- const items = KeyedItems.of(source, givenValue(lookup, "valueField"));
57242
+ const items = KeyedItems.of(source, givenValue(lookup, "valueField"), lookup.normalizeKey);
56849
57243
  const known = items.get(v);
56850
57244
  if (!known) {
56851
57245
  items.request([v]).then(() => untracked(() => this.state.texts++));
@@ -57933,7 +58327,8 @@ var FilterBuilder = class extends Control {
57933
58327
  const from = Array.isArray(source) ? { items: source } : { dataSource: source };
57934
58328
  const fields = {
57935
58329
  valueField: lookup.valueField,
57936
- textField: lookup.textField
58330
+ textField: lookup.textField,
58331
+ normalizeKey: lookup.normalizeKey
57937
58332
  };
57938
58333
  if (many) return new TagBox({
57939
58334
  ...from,
@@ -58126,6 +58521,7 @@ function builderFields(model, customOperations = []) {
58126
58521
  const lookup = col.lookup ? {
58127
58522
  dataSource: col.lookup.dataSource,
58128
58523
  valueField: col.lookup.valueField,
58524
+ normalizeKey: col.lookup.normalizeKey,
58129
58525
  textField: col.lookup.textField
58130
58526
  } : options ? {
58131
58527
  dataSource: options,
@@ -58887,7 +59283,7 @@ var DataGrid = class extends Control {
58887
59283
  this.bands = new BandRows(_model, host, this.header);
58888
59284
  this.motif.setDisposable(() => this.bands.dispose());
58889
59285
  this.filterRow = new FilterRow(_model);
58890
- this.widths = new ActionWidths(() => this.measurePart, () => _model.notices.tell("actions"));
59286
+ this.widths = new ActionWidths(() => this.measurePart, () => _model.notices.tell("actions"), (on) => mark(this, "data-measuring-actions", on));
58891
59287
  onLayout(this, "look", () => {
58892
59288
  this.widths.clear();
58893
59289
  this.measureSizes();
@@ -61311,11 +61707,13 @@ var DataGrid = class extends Control {
61311
61707
  model.showsFilterRow()
61312
61708
  ];
61313
61709
  }, () => {
61710
+ const held = this.tabbable && !this.tabbable.isDisposed && holdsFocus(this.tabbable) ? this.tabbable : null;
61314
61711
  const visible = model.columns.visible();
61315
61712
  this.findColumns(visible);
61316
61713
  this.arrangeColumns(visible, model.showsFilterRow());
61317
61714
  model.keepActiveFieldVisible();
61318
- this.syncTabStop();
61715
+ if (held && this.activePart() !== held) this.focusActive(false);
61716
+ else this.syncTabStop();
61319
61717
  });
61320
61718
  this.whenChanged(() => {
61321
61719
  const visible = model.columns.visible();
@@ -61806,13 +62204,16 @@ var DataGrid = class extends Control {
61806
62204
  actionButtons(view) {
61807
62205
  return view.actions?.buttonParts() ?? [];
61808
62206
  }
61809
- /** Exactly one cell is in the tab order: the active one. */
61810
- syncTabStop() {
62207
+ /**
62208
+ * Exactly one cell is in the tab order: the active one. `leave: false` keeps the one it was in the tab order, for the
62209
+ * caller to take it out once focus has left it (`focusActive`).
62210
+ */
62211
+ syncTabStop(leave = true) {
61811
62212
  const active = this.keptColumn();
61812
62213
  if (active && !this.model.columnWindow.has(active)) this.updateColumns();
61813
62214
  const part = this.activePart();
61814
62215
  if (!part) return;
61815
- if (this.tabbable && this.tabbable !== part && !this.tabbable.isDisposed) put(this.tabbable, "tabindex", "-1");
62216
+ if (leave && this.tabbable && this.tabbable !== part && !this.tabbable.isDisposed) put(this.tabbable, "tabindex", "-1");
61816
62217
  put(part, "tabindex", this.tabStop ? "0" : "-1");
61817
62218
  this.tabbable = part;
61818
62219
  }
@@ -61883,10 +62284,12 @@ var DataGrid = class extends Control {
61883
62284
  if (reveal && activeRow >= 0) this.body.reveal(activeRow);
61884
62285
  const cols = this.model.columns;
61885
62286
  if (reveal) this.revealColumn(cols.isBand(activeField) ? cols.leavesIn(activeField, cols.visible())[0] ?? activeField : activeField);
61886
- this.syncTabStop();
62287
+ const was = this.tabbable;
62288
+ this.syncTabStop(false);
61887
62289
  const part = this.activePart();
61888
62290
  if (!part) return;
61889
62291
  focusOn(part, { preventScroll: true });
62292
+ if (was && was !== part && !was.isDisposed) put(was, "tabindex", "-1");
61890
62293
  if (this.model.settings.get("tooltips")) this.tip.focus(part);
61891
62294
  }
61892
62295
  /** The column the active cell is in (a band's first one), drawn even while it is out of view. */
@@ -91496,8 +91899,8 @@ var AppointmentEditor = class {
91496
91899
  columns: settings.columns ?? (phone ? 1 : 2),
91497
91900
  minColumnWidth: settings.minColumnWidth ?? "",
91498
91901
  labelMode: settings.labelMode,
91499
- onFieldChanged: () => this.formChanged(layout),
91500
91902
  ref: (c) => layout = c,
91903
+ onFieldChanged: () => this.formChanged(layout),
91501
91904
  runover: {},
91502
91905
  childs: []
91503
91906
  });
@@ -91682,16 +92085,16 @@ var AppointmentEditor = class {
91682
92085
  colSpan: "all",
91683
92086
  visible: () => editing.allowRecurrence && !exception,
91684
92087
  template: () => motifComponent(RecurrenceEditor, {
92088
+ ref: (r) => this.recurrence = {
92089
+ editor: r,
92090
+ data
92091
+ },
91685
92092
  class: "mx-scheduler__recurrence",
91686
92093
  start: () => data.start instanceof Date ? data.start : null,
91687
92094
  allDay: () => !!data.allDay,
91688
92095
  timeZone: () => data.startTimeZone ? String(data.startTimeZone) : model.zone.name || null,
91689
92096
  locale: () => this.host.locale(),
91690
92097
  firstDayOfWeek: () => this.host.firstDayOfWeek(),
91691
- ref: (r) => this.recurrence = {
91692
- editor: r,
91693
- data
91694
- },
91695
92098
  runover: { initializeComponent: (sender) => {
91696
92099
  sender.bindings.model(() => data.recurrenceRule, (_value) => {
91697
92100
  const _owner = data;
@@ -106603,7 +107006,7 @@ var RibbonKeyHints = class {
106603
107006
  });
106604
107007
  return true;
106605
107008
  }
106606
- if (level === "tabs" && this.level === "tabs") whenMeasured(this.owner).then(() => untouched() && this.start("commands"));
107009
+ if (exact.hint.tab && level === "tabs" && this.level === "tabs") whenMeasured(this.owner).then(() => untouched() && this.start("commands"));
106607
107010
  else if (this.level === level) this.stop();
106608
107011
  return true;
106609
107012
  }
@@ -108130,7 +108533,8 @@ var RibbonMenu = class RibbonMenu extends Control {
108130
108533
  part: host,
108131
108534
  keys: parsed.key ?? "",
108132
108535
  text: parsed.text,
108133
- press: () => this.pressTab(look)
108536
+ press: () => this.pressTab(look),
108537
+ tab: true
108134
108538
  });
108135
108539
  });
108136
108540
  let n = 1;
@@ -108190,10 +108594,13 @@ var RibbonMenu = class RibbonMenu extends Control {
108190
108594
  });
108191
108595
  } else if (m.type === "content") {
108192
108596
  const content = m.control;
108193
- if (hasFocusableIn(content)) hints.push({
108597
+ if (!hasFocusableIn(content)) return;
108598
+ const label = parseAccessKey(contentName(content));
108599
+ const named = text.text || String(fieldOf(command, "hint", this) ?? "");
108600
+ hints.push({
108194
108601
  part: content,
108195
- keys,
108196
- text: text.text || String(fieldOf(command, "hint", this) ?? ""),
108602
+ keys: keys || (named ? "" : label.key ?? ""),
108603
+ text: named || label.text,
108197
108604
  press: () => focusFirstIn(content)
108198
108605
  });
108199
108606
  } else if (m.made) for (const inner of m.made.values()) add(inner);
@@ -108679,6 +109086,16 @@ function partStops(part, stops) {
108679
109086
  if (canTakeFocus(part)) stops.push(part);
108680
109087
  for (const child of part.controls.items) partStops(child, stops);
108681
109088
  }
109089
+ function contentName(part) {
109090
+ if (part instanceof Field) return part.label;
109091
+ const own = part.attr.get("aria-label");
109092
+ if (typeof own === "string" && own) return own;
109093
+ for (const child of part.controls.items) {
109094
+ const name = contentName(child);
109095
+ if (name) return name;
109096
+ }
109097
+ return "";
109098
+ }
108682
109099
  function buttonHint(button, keys, text) {
108683
109100
  const face = button.faceComponent;
108684
109101
  const press = () => {