@motifx-community/ui 0.1.0-beta.10 → 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.
- package/CHANGELOG.md +59 -0
- package/dist/components/combobox/ComboBox.d.ts +5 -0
- package/dist/components/combobox/combo-box-props.d.ts +6 -0
- package/dist/components/datagrid/DataGrid.d.ts +4 -1
- package/dist/components/datagrid/grid-lookup.d.ts +8 -0
- package/dist/components/datagrid/model/FilterModel.d.ts +5 -0
- package/dist/components/datagrid/model/LookupTexts.d.ts +2 -0
- package/dist/components/datagrid/model/LookupValues.d.ts +4 -0
- package/dist/components/datagrid/view/ActionWidths.d.ts +13 -3
- package/dist/components/datagrid/view/GridRow.d.ts +1 -1
- package/dist/components/dropdown/DropDown.d.ts +5 -0
- package/dist/components/dropdown/drop-down-props.d.ts +6 -0
- package/dist/components/filterbuilder/filter-builder-lookup.d.ts +3 -0
- package/dist/components/listbox/ListBox.d.ts +5 -0
- package/dist/components/listbox/list-box-props.d.ts +6 -0
- package/dist/components/listbox/select-all-state.d.ts +1 -1
- package/dist/components/ribbonmenu/RibbonKeyHints.d.ts +1 -0
- package/dist/components/tagbox/TagBox.d.ts +5 -0
- package/dist/components/tagbox/tag-box-props.d.ts +6 -0
- package/dist/components/toolbar/Toolbar.d.ts +10 -2
- package/dist/core/measure/after-frame.d.ts +7 -0
- package/dist/core/measure/drawn.d.ts +7 -0
- package/dist/core/measure/index.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +571 -139
- package/dist/index.js.map +1 -1
- package/dist/parts/data/DataItems.d.ts +24 -0
- package/dist/parts/data/KeyedItems.d.ts +31 -5
- package/dist/parts/data/normalize-key.d.ts +7 -0
- package/dist/styles.css +32 -0
- package/docs/accordion.md +1 -1
- package/docs/actionsheet.md +1 -1
- package/docs/appbar.md +1 -1
- package/docs/appmenu-api.md +1 -1
- package/docs/appmenu-programmatic.md +1 -1
- package/docs/appmenu-search.md +1 -1
- package/docs/appmenu.md +1 -1
- package/docs/avatar.md +1 -1
- package/docs/badge.md +1 -1
- package/docs/bar-gauge-angles.md +1 -1
- package/docs/bar-gauge-data.md +1 -1
- package/docs/bar-gauge-labels.md +1 -1
- package/docs/bar-gauge.md +1 -1
- package/docs/barcode.md +1 -1
- package/docs/bottomnavigation.md +1 -1
- package/docs/bottomsheet.md +1 -1
- package/docs/breadcrumb.md +1 -1
- package/docs/button.md +2 -2
- package/docs/buttongroup.md +1 -1
- package/docs/buttons.md +3 -5
- package/docs/calendar.md +1 -1
- package/docs/card.md +1 -1
- package/docs/chart-bars.md +1 -1
- package/docs/chart-candles.md +1 -1
- package/docs/chart-funnel.md +1 -1
- package/docs/chart-heatmap.md +1 -1
- package/docs/chart-lines.md +1 -1
- package/docs/chart-live.md +1 -1
- package/docs/chart-pie.md +1 -1
- package/docs/chart-radar.md +1 -1
- package/docs/chart-ranges.md +1 -1
- package/docs/chart-references.md +1 -1
- package/docs/chart-scatter.md +1 -1
- package/docs/chart-waterfall.md +1 -1
- package/docs/chart-zoom.md +1 -1
- package/docs/chart.md +1 -1
- package/docs/checkbox.md +1 -1
- package/docs/chip.md +1 -1
- package/docs/choice.md +1 -1
- package/docs/colorbox.md +1 -1
- package/docs/combobox.md +1 -1
- package/docs/commands.md +126 -0
- package/docs/control.md +1 -1
- package/docs/data.md +1 -1
- package/docs/datagrid-api.md +3 -3
- package/docs/datagrid-bands.md +1 -1
- package/docs/datagrid-drag-select.md +1 -1
- package/docs/datagrid-drag.md +1 -1
- package/docs/datagrid-editing.md +107 -1
- package/docs/datagrid-filtering.md +11 -3
- package/docs/datagrid-forms.md +1 -1
- package/docs/datagrid-grouping.md +1 -1
- package/docs/datagrid-layout.md +2 -2
- package/docs/datagrid-lookups.md +1 -1
- package/docs/datagrid-master-detail.md +1 -1
- package/docs/datagrid-scrolling.md +1 -1
- package/docs/datagrid-selection.md +1 -1
- package/docs/datagrid.md +1 -1
- package/docs/datebox.md +1 -1
- package/docs/daterangebox.md +1 -1
- package/docs/display.md +1 -1
- package/docs/draggable.md +1 -1
- package/docs/drawer.md +1 -1
- package/docs/dropdown.md +1 -1
- package/docs/editors.md +3 -1
- package/docs/feedback.md +1 -1
- package/docs/fileuploader.md +1 -1
- package/docs/filterbuilder.md +1 -1
- package/docs/formlayout.md +1 -1
- package/docs/foundations.md +1 -1
- package/docs/gallery.md +1 -1
- package/docs/gauge-base.md +1 -1
- package/docs/gauge-circular.md +1 -1
- package/docs/gauge-dashboards.md +1 -1
- package/docs/gauge-linear.md +1 -1
- package/docs/gauge-markers.md +1 -1
- package/docs/gauge-marks.md +1 -1
- package/docs/gauge-ranges.md +1 -1
- package/docs/gauge-scales.md +1 -1
- package/docs/gauge.md +1 -1
- package/docs/home.md +2 -2
- package/docs/keyboard.md +5 -3
- package/docs/language.md +2 -2
- package/docs/layout.md +1 -1
- package/docs/listbox.md +1 -1
- package/docs/loadpanel.md +2 -2
- package/docs/lookup.md +1 -1
- package/docs/menus-api.md +142 -0
- package/docs/menus-context.md +126 -0
- package/docs/menus-customization.md +138 -0
- package/docs/menus-merging.md +208 -0
- package/docs/menus-programmatic.md +74 -0
- package/docs/menus.md +22 -179
- package/docs/multiview.md +1 -1
- package/docs/navigation.md +7 -2
- package/docs/numberbox.md +3 -3
- package/docs/otpinput.md +1 -1
- package/docs/pagination.md +1 -1
- package/docs/popover.md +1 -1
- package/docs/progress.md +3 -3
- package/docs/qrcode.md +1 -1
- package/docs/radiogroup.md +1 -1
- package/docs/rating.md +1 -1
- package/docs/resizable.md +1 -1
- package/docs/ribbonmenu-api.md +1 -1
- package/docs/ribbonmenu-commands.md +1 -1
- package/docs/ribbonmenu-customization.md +1 -1
- package/docs/ribbonmenu-display.md +1 -1
- package/docs/ribbonmenu-layouts.md +1 -1
- package/docs/ribbonmenu-programmatic.md +1 -1
- package/docs/ribbonmenu.md +1 -1
- package/docs/scheduler-agenda.md +1 -1
- package/docs/scheduler-big-data.md +1 -1
- package/docs/scheduler-editing.md +1 -1
- package/docs/scheduler-form.md +1 -1
- package/docs/scheduler-icalendar.md +1 -1
- package/docs/scheduler-mobile.md +1 -1
- package/docs/scheduler-recurrence.md +1 -1
- package/docs/scheduler-resources.md +1 -1
- package/docs/scheduler-timeline.md +1 -1
- package/docs/scheduler.md +1 -1
- package/docs/scrollview.md +1 -1
- package/docs/shortcuteditor.md +248 -0
- package/docs/showcase-home.md +1 -1
- package/docs/showcase.md +1 -1
- package/docs/signature.md +1 -1
- package/docs/skeleton.md +1 -1
- package/docs/slider.md +3 -3
- package/docs/sortable.md +1 -1
- package/docs/sparkline.md +1 -1
- package/docs/speeddial.md +1 -1
- package/docs/splitter.md +1 -1
- package/docs/stepper.md +1 -1
- package/docs/switch.md +1 -1
- package/docs/tabdocs-dock.md +1 -1
- package/docs/tabdocs-drag.md +1 -1
- package/docs/tabdocs-menus.md +1 -1
- package/docs/tabdocs-mobile.md +1 -1
- package/docs/tabdocs-tabs.md +1 -1
- package/docs/tabdocs-windows.md +1 -1
- package/docs/tabdocs-workspace.md +1 -1
- package/docs/tabdocs.md +1 -1
- package/docs/tabs.md +1 -1
- package/docs/tagbox.md +1 -1
- package/docs/textarea.md +1 -1
- package/docs/textbox.md +1 -1
- package/docs/tileview.md +1 -1
- package/docs/timeline.md +1 -1
- package/docs/toast.md +1 -1
- package/docs/tokens.md +13 -1
- package/docs/toolbar.md +1 -1
- package/docs/tooltip.md +1 -1
- package/docs/treeview.md +1 -1
- package/docs/validationsummary.md +1 -1
- package/docs/window.md +1 -1
- package/docs/wizard.md +1 -1
- package/llms-full.txt +3774 -2692
- package/llms.txt +16 -6
- 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))
|
|
279
|
-
|
|
280
|
-
|
|
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
|
|
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 =
|
|
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
|
|
315
|
-
var FRAME_TIME
|
|
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
|
|
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
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
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
|
-
|
|
798
|
-
} catch {
|
|
799
|
-
|
|
848
|
+
untracked(then);
|
|
849
|
+
} catch (error) {
|
|
850
|
+
errorHandler.report(error instanceof Error ? error : new Error(String(error)));
|
|
800
851
|
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
/**
|
|
12479
|
-
|
|
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
|
|
12488
|
-
if (!
|
|
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
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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(
|
|
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(
|
|
12745
|
-
|
|
12746
|
-
|
|
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
|
-
} :
|
|
12881
|
+
} : {
|
|
12752
12882
|
state: "missing",
|
|
12753
12883
|
failed: true
|
|
12754
12884
|
});
|
|
12885
|
+
settled.push(ks);
|
|
12886
|
+
}
|
|
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);
|
|
12755
12902
|
}
|
|
12756
|
-
|
|
12903
|
+
return keys.some(([, key]) => {
|
|
12904
|
+
const k = looseKey(key);
|
|
12905
|
+
return k !== null && loose.has(k);
|
|
12906
|
+
});
|
|
12757
12907
|
}
|
|
12758
|
-
|
|
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.
|
|
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 =
|
|
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
|
|
12801
|
-
|
|
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 =
|
|
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((
|
|
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
|
|
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 =
|
|
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
|
|
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 &&
|
|
14231
|
+
if (item !== void 0 && holds(item)) return i;
|
|
14010
14232
|
}
|
|
14011
14233
|
return -1;
|
|
14012
14234
|
}
|
|
14013
|
-
return this.visibleItems().findIndex(
|
|
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 =
|
|
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.
|
|
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);
|
|
@@ -24593,6 +24815,7 @@ var Toolbar = class extends Control {
|
|
|
24593
24815
|
}
|
|
24594
24816
|
);
|
|
24595
24817
|
_defineProperty(this, "fitKnown", (bar) => {
|
|
24818
|
+
this.parts.stopRefit = null;
|
|
24596
24819
|
if (bar) this.fit(bar);
|
|
24597
24820
|
else this.layout();
|
|
24598
24821
|
});
|
|
@@ -24626,6 +24849,8 @@ var Toolbar = class extends Control {
|
|
|
24626
24849
|
const gap = length(vertical ? "row-gap" : "column-gap");
|
|
24627
24850
|
this.parts.gap = gap;
|
|
24628
24851
|
this.parts.room = room;
|
|
24852
|
+
const needed = [...sizes.values()].reduce((sum, size) => sum + size, 0) + gap * Math.max(0, sizes.size - 1);
|
|
24853
|
+
this.parts.stretched = room > needed + 1;
|
|
24629
24854
|
return {
|
|
24630
24855
|
kids,
|
|
24631
24856
|
room,
|
|
@@ -24640,6 +24865,9 @@ var Toolbar = class extends Control {
|
|
|
24640
24865
|
/** Moves into the "more" menu what does not fit (and what always goes there). */
|
|
24641
24866
|
"fit",
|
|
24642
24867
|
(bar) => {
|
|
24868
|
+
this.parts.measuring = false;
|
|
24869
|
+
this.parts.stopFirst = null;
|
|
24870
|
+
if (bar.shown) this.parts.first = false;
|
|
24643
24871
|
this.parts.laidOut = bar.length;
|
|
24644
24872
|
if (!this.menuMode()) return;
|
|
24645
24873
|
untracked(() => {
|
|
@@ -24647,6 +24875,7 @@ var Toolbar = class extends Control {
|
|
|
24647
24875
|
for (const kid of bar.kids) if (!out.includes(kid)) mark(kid.part, "data-overflowed", false);
|
|
24648
24876
|
this.parts.out = new Set(out.map((kid) => kid.part));
|
|
24649
24877
|
this.showOverflow(out);
|
|
24878
|
+
this.keepRoom(bar, out);
|
|
24650
24879
|
});
|
|
24651
24880
|
}
|
|
24652
24881
|
);
|
|
@@ -24761,6 +24990,7 @@ var Toolbar = class extends Control {
|
|
|
24761
24990
|
overflowed: /* @__PURE__ */ new Set(),
|
|
24762
24991
|
more: null,
|
|
24763
24992
|
stopMoreLabel: null,
|
|
24993
|
+
reserve: null,
|
|
24764
24994
|
restyleQueued: false,
|
|
24765
24995
|
laying: [],
|
|
24766
24996
|
laidOut: -1,
|
|
@@ -24769,6 +24999,11 @@ var Toolbar = class extends Control {
|
|
|
24769
24999
|
sizes: /* @__PURE__ */ new Map(),
|
|
24770
25000
|
watched: /* @__PURE__ */ new Map(),
|
|
24771
25001
|
out: /* @__PURE__ */ new Set(),
|
|
25002
|
+
stretched: false,
|
|
25003
|
+
measuring: false,
|
|
25004
|
+
stopRefit: null,
|
|
25005
|
+
first: true,
|
|
25006
|
+
stopFirst: null,
|
|
24772
25007
|
moreLength: null,
|
|
24773
25008
|
itemClick: new Emitter()
|
|
24774
25009
|
};
|
|
@@ -24900,7 +25135,7 @@ var Toolbar = class extends Control {
|
|
|
24900
25135
|
/** The parts in the bar in order, without the "more" button. For a list or a condition, the parts it holds. */
|
|
24901
25136
|
barContent(from = this, found = []) {
|
|
24902
25137
|
for (const part of from.controls.items) {
|
|
24903
|
-
if (part === this.parts.more) continue;
|
|
25138
|
+
if (part === this.parts.more || part === this.parts.reserve) continue;
|
|
24904
25139
|
if (isElement(part.element)) found.push(part);
|
|
24905
25140
|
else this.barContent(part, found);
|
|
24906
25141
|
}
|
|
@@ -24921,7 +25156,7 @@ var Toolbar = class extends Control {
|
|
|
24921
25156
|
}
|
|
24922
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. */
|
|
24923
25158
|
childChanged(control) {
|
|
24924
|
-
if (control === this.parts.more) return;
|
|
25159
|
+
if (control === this.parts.more || control === this.parts.reserve) return;
|
|
24925
25160
|
this.queueRestyle();
|
|
24926
25161
|
this.layout();
|
|
24927
25162
|
}
|
|
@@ -24978,16 +25213,29 @@ var Toolbar = class extends Control {
|
|
|
24978
25213
|
parts.out.clear();
|
|
24979
25214
|
for (const kid of parts.laying) mark(kid.part, "data-overflowed", false);
|
|
24980
25215
|
if (parts.more) mark(parts.more, "data-idle", true);
|
|
24981
|
-
if (
|
|
24982
|
-
|
|
25216
|
+
if (parts.reserve) mark(parts.reserve, "data-idle", true);
|
|
25217
|
+
parts.stopRefit?.();
|
|
25218
|
+
parts.stopRefit = null;
|
|
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);
|
|
24983
25229
|
});
|
|
24984
25230
|
}
|
|
24985
25231
|
/**
|
|
24986
|
-
* Fits the parts into the room again from their sizes as last laid out, which the size observers keep
|
|
24987
|
-
*
|
|
25232
|
+
* Fits the parts into the room again from their sizes as last laid out, which the size observers keep, when only the
|
|
25233
|
+
* room of a stretched bar changed: nothing is laid out to read. Without them yet, it puts every part back and reads.
|
|
24988
25234
|
*/
|
|
24989
25235
|
refit() {
|
|
24990
|
-
|
|
25236
|
+
const parts = this.parts;
|
|
25237
|
+
if (!this.menuMode() || parts.measuring) return;
|
|
25238
|
+
parts.stopRefit = measure(this, this.readKnown, this.fitKnown);
|
|
24991
25239
|
}
|
|
24992
25240
|
/** Each part of the bar tells its size as the browser lays it out; a part that leaves the bar stops. */
|
|
24993
25241
|
watchKids(kids) {
|
|
@@ -25013,11 +25261,39 @@ var Toolbar = class extends Control {
|
|
|
25013
25261
|
const known = parts.sizes.get(part);
|
|
25014
25262
|
if (known !== void 0 && Math.abs(known - along) < .5) return;
|
|
25015
25263
|
parts.sizes.set(part, along);
|
|
25016
|
-
if (known !== void 0) this.
|
|
25264
|
+
if (known !== void 0) this.layout();
|
|
25017
25265
|
}
|
|
25018
25266
|
menuMode() {
|
|
25019
25267
|
return (this.peekProperty("overflow") ?? "menu") === "menu";
|
|
25020
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
|
+
}
|
|
25021
25297
|
showOverflow(out) {
|
|
25022
25298
|
const parts = this.parts;
|
|
25023
25299
|
const focused = rememberFocus();
|
|
@@ -25124,7 +25400,9 @@ var Toolbar = class extends Control {
|
|
|
25124
25400
|
this.motif.setDisposable(onLayout(this, "size", (size) => {
|
|
25125
25401
|
const vertical = this.peekProperty("orientation") === "vertical";
|
|
25126
25402
|
parts.room = vertical ? size.height : size.width;
|
|
25127
|
-
if (Math.abs(parts.room - parts.laidOut)
|
|
25403
|
+
if (Math.abs(parts.room - parts.laidOut) < .5) return;
|
|
25404
|
+
if (parts.stretched) this.refit();
|
|
25405
|
+
else this.layout();
|
|
25128
25406
|
}, { box: "content" }));
|
|
25129
25407
|
}
|
|
25130
25408
|
onKeyDown(e) {
|
|
@@ -31332,6 +31610,7 @@ var OWN$45 = [
|
|
|
31332
31610
|
var FUNCTIONS$6 = [
|
|
31333
31611
|
"textField",
|
|
31334
31612
|
"valueField",
|
|
31613
|
+
"normalizeKey",
|
|
31335
31614
|
"iconField",
|
|
31336
31615
|
"groupField",
|
|
31337
31616
|
"enabledField",
|
|
@@ -31366,6 +31645,10 @@ var ComboBox = class extends Field {
|
|
|
31366
31645
|
this.observeProperty("clearButton", () => this.renderClear());
|
|
31367
31646
|
this.observeProperty("dataSource", () => this.renderSource());
|
|
31368
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
|
+
});
|
|
31369
31652
|
this.observeProperty("searchMode", (mode) => parts.items.searchMode = mode === "startswith" ? "startswith" : "contains");
|
|
31370
31653
|
parts.items.textOf = (item) => this.itemText(item);
|
|
31371
31654
|
parts.items.onChanged(() => this.itemsChanged());
|
|
@@ -31408,6 +31691,12 @@ var ComboBox = class extends Field {
|
|
|
31408
31691
|
set valueField(value) {
|
|
31409
31692
|
this.assignProperty("valueField", functionValue(value));
|
|
31410
31693
|
}
|
|
31694
|
+
get normalizeKey() {
|
|
31695
|
+
return this.getProperty("normalizeKey");
|
|
31696
|
+
}
|
|
31697
|
+
set normalizeKey(value) {
|
|
31698
|
+
this.assignProperty("normalizeKey", functionValue(value));
|
|
31699
|
+
}
|
|
31411
31700
|
get iconField() {
|
|
31412
31701
|
return this.getProperty("iconField");
|
|
31413
31702
|
}
|
|
@@ -31580,7 +31869,7 @@ var ComboBox = class extends Field {
|
|
|
31580
31869
|
return;
|
|
31581
31870
|
}
|
|
31582
31871
|
const lookup = ++parts.lookup;
|
|
31583
|
-
this.showText(parts.chosen !== void 0 && this.
|
|
31872
|
+
this.showText(parts.chosen !== void 0 && this.holderOf(value)(parts.chosen) ? this.itemText(parts.chosen) : "");
|
|
31584
31873
|
parts.items.find(value, (item) => this.itemValue(item)).then((item) => {
|
|
31585
31874
|
if (lookup !== parts.lookup || this.isDisposed) return;
|
|
31586
31875
|
parts.chosen = item;
|
|
@@ -31594,6 +31883,10 @@ var ComboBox = class extends Field {
|
|
|
31594
31883
|
itemText(item) {
|
|
31595
31884
|
return String(readItemField(item, this.peekProperty("textField"), "text") ?? "");
|
|
31596
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
|
+
}
|
|
31597
31890
|
itemValue(item) {
|
|
31598
31891
|
const field = this.peekProperty("valueField");
|
|
31599
31892
|
if (field !== void 0) return readItemField(item, field, "value");
|
|
@@ -31772,11 +32065,14 @@ var ComboBox = class extends Field {
|
|
|
31772
32065
|
if (!list) return;
|
|
31773
32066
|
const value = this.peekValue();
|
|
31774
32067
|
let index = -1;
|
|
31775
|
-
if (!parts.editing && value !== null)
|
|
31776
|
-
const
|
|
31777
|
-
|
|
31778
|
-
|
|
31779
|
-
|
|
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
|
+
}
|
|
31780
32076
|
}
|
|
31781
32077
|
}
|
|
31782
32078
|
if (index >= 0) list.setActive(index);
|
|
@@ -31814,7 +32110,7 @@ var ComboBox = class extends Field {
|
|
|
31814
32110
|
const list = new OptionList();
|
|
31815
32111
|
list.textOf = (item) => this.itemText(item);
|
|
31816
32112
|
list.enabledOf = (item) => this.canChoose(item);
|
|
31817
|
-
list.isSelected = (item) => this.
|
|
32113
|
+
list.isSelected = (item) => this.holderOf(this.peekValue())(item);
|
|
31818
32114
|
list.emptyText = () => parts.items.loading ? uiLocale.strings.loading : uiLocale.strings.noItems;
|
|
31819
32115
|
list.onChosen((e) => {
|
|
31820
32116
|
this.choose(e.item, this.itemValue(e.item), e.event);
|
|
@@ -34066,11 +34362,11 @@ var ListRows = class {
|
|
|
34066
34362
|
//#endregion
|
|
34067
34363
|
//#region src/components/listbox/select-all-state.ts
|
|
34068
34364
|
/** Whether the items the list shows are all chosen (`true`), none of them (`false`) or some (`'mixed'`). */
|
|
34069
|
-
function selectAllState(items, chosen,
|
|
34365
|
+
function selectAllState(items, chosen, isChosen, enabledOf) {
|
|
34070
34366
|
if (!chosen.size) return false;
|
|
34071
34367
|
const rows = items.loaded.filter(enabledOf);
|
|
34072
34368
|
let hits = 0;
|
|
34073
|
-
for (const row of rows) if (
|
|
34369
|
+
for (const row of rows) if (isChosen(row)) hits++;
|
|
34074
34370
|
if (!hits) return items.dataSource && !items.searchText ? "mixed" : false;
|
|
34075
34371
|
return hits === rows.length && (!items.dataSource || chosen.size >= items.count) ? true : "mixed";
|
|
34076
34372
|
}
|
|
@@ -34155,6 +34451,7 @@ var OWN$40 = [
|
|
|
34155
34451
|
var FUNCTIONS$5 = [
|
|
34156
34452
|
"textField",
|
|
34157
34453
|
"valueField",
|
|
34454
|
+
"normalizeKey",
|
|
34158
34455
|
"iconField",
|
|
34159
34456
|
"groupField",
|
|
34160
34457
|
"enabledField",
|
|
@@ -34216,7 +34513,13 @@ var TagBox = class extends Field {
|
|
|
34216
34513
|
this.observeProperty("matchWidth", (on) => {
|
|
34217
34514
|
if (parts.popup) parts.popup.matchWidth = on !== false;
|
|
34218
34515
|
});
|
|
34219
|
-
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;
|
|
34220
34523
|
parts.known.clear();
|
|
34221
34524
|
this.renderValue(this.peekValue());
|
|
34222
34525
|
});
|
|
@@ -34271,6 +34574,12 @@ var TagBox = class extends Field {
|
|
|
34271
34574
|
set valueField(value) {
|
|
34272
34575
|
this.assignProperty("valueField", functionValue(value));
|
|
34273
34576
|
}
|
|
34577
|
+
get normalizeKey() {
|
|
34578
|
+
return this.getProperty("normalizeKey");
|
|
34579
|
+
}
|
|
34580
|
+
set normalizeKey(value) {
|
|
34581
|
+
this.assignProperty("normalizeKey", functionValue(value));
|
|
34582
|
+
}
|
|
34274
34583
|
get iconField() {
|
|
34275
34584
|
return this.getProperty("iconField");
|
|
34276
34585
|
}
|
|
@@ -34520,6 +34829,11 @@ var TagBox = class extends Field {
|
|
|
34520
34829
|
itemText(item) {
|
|
34521
34830
|
return String(readItemField(item, this.peekProperty("textField"), "text") ?? "");
|
|
34522
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
|
+
}
|
|
34523
34837
|
itemValue(item) {
|
|
34524
34838
|
const field = this.peekProperty("valueField");
|
|
34525
34839
|
if (field !== void 0) return readItemField(item, field, "value");
|
|
@@ -34581,7 +34895,7 @@ var TagBox = class extends Field {
|
|
|
34581
34895
|
}
|
|
34582
34896
|
allState() {
|
|
34583
34897
|
const parts = this.tagParts;
|
|
34584
|
-
return selectAllState(parts.items, parts.chosen, (item) => this.
|
|
34898
|
+
return selectAllState(parts.items, parts.chosen, (item) => this.isChosen(item), (item) => this.canChoose(item));
|
|
34585
34899
|
}
|
|
34586
34900
|
renderSource() {
|
|
34587
34901
|
const parts = this.tagParts;
|
|
@@ -34714,9 +35028,9 @@ var TagBox = class extends Field {
|
|
|
34714
35028
|
list.enabledOf = (row) => {
|
|
34715
35029
|
if (row === selectAllRow) return true;
|
|
34716
35030
|
const item = row;
|
|
34717
|
-
return this.canChoose(item) && (!this.atLimit() ||
|
|
35031
|
+
return this.canChoose(item) && (!this.atLimit() || this.isChosen(item));
|
|
34718
35032
|
};
|
|
34719
|
-
list.isSelected = (row) => row === selectAllRow ? this.allState() === true :
|
|
35033
|
+
list.isSelected = (row) => row === selectAllRow ? this.allState() === true : this.isChosen(row);
|
|
34720
35034
|
list.emptyText = () => parts.items.loading ? uiLocale.strings.loading : uiLocale.strings.noItems;
|
|
34721
35035
|
list.onChosen((e) => this.chosen(e));
|
|
34722
35036
|
popup.controls.add(list);
|
|
@@ -34759,7 +35073,7 @@ var TagBox = class extends Field {
|
|
|
34759
35073
|
parts.sourceCount = -1;
|
|
34760
35074
|
list.groupOf = group === void 0 ? null : (row) => row === selectAllRow ? void 0 : readItemField(row, group, "group") ?? void 0;
|
|
34761
35075
|
let shown = parts.items.loaded;
|
|
34762
|
-
if (this.peekProperty("hideSelected")) shown = shown.filter((item) => !
|
|
35076
|
+
if (this.peekProperty("hideSelected")) shown = shown.filter((item) => !this.isChosen(item));
|
|
34763
35077
|
list.setItems(withAll && shown.length ? [selectAllRow, ...shown] : shown);
|
|
34764
35078
|
}
|
|
34765
35079
|
this.pointAt();
|
|
@@ -34847,7 +35161,8 @@ var TagBox = class extends Field {
|
|
|
34847
35161
|
if (!this.canChange() || !this.canChoose(item)) return;
|
|
34848
35162
|
const value = this.itemValue(item);
|
|
34849
35163
|
const values = this.values();
|
|
34850
|
-
|
|
35164
|
+
const held = parts.items.heldIn(parts.chosen, value);
|
|
35165
|
+
if (held) this.commit(values.filter((v) => !Object.is(v, held.value)), event);
|
|
34851
35166
|
else {
|
|
34852
35167
|
if (this.atLimit()) return;
|
|
34853
35168
|
parts.known.remember(item);
|
|
@@ -34875,7 +35190,7 @@ var TagBox = class extends Field {
|
|
|
34875
35190
|
const make = this.peekProperty("customValue");
|
|
34876
35191
|
const value = make ? make(text) : text;
|
|
34877
35192
|
if (value === null || value === void 0 || this.atLimit()) return false;
|
|
34878
|
-
if (!this.tagParts.
|
|
35193
|
+
if (!this.tagParts.items.heldIn(this.tagParts.chosen, value)) this.commit([...this.values(), value], event);
|
|
34879
35194
|
this.chosenDone();
|
|
34880
35195
|
return true;
|
|
34881
35196
|
}
|
|
@@ -34888,7 +35203,7 @@ var TagBox = class extends Field {
|
|
|
34888
35203
|
const current = this.values();
|
|
34889
35204
|
const chosen = new Set(current);
|
|
34890
35205
|
const set = new Set(shown);
|
|
34891
|
-
let next = on ? [...current, ...shown.filter((v) => !
|
|
35206
|
+
let next = on ? [...current, ...shown.filter((v) => !parts.items.heldIn(chosen, v))] : current.filter((v) => !parts.items.heldIn(set, v));
|
|
34892
35207
|
const max = this.peekProperty("maxSelected") ?? 0;
|
|
34893
35208
|
if (max > 0 && next.length > max) next = next.slice(0, Math.max(max, current.length));
|
|
34894
35209
|
this.commit(next, event);
|
|
@@ -36135,6 +36450,7 @@ var CellEditor = class {
|
|
|
36135
36450
|
clearButton: lookup.allowClearing ?? false,
|
|
36136
36451
|
searchEnabled: true
|
|
36137
36452
|
};
|
|
36453
|
+
if (lookup.normalizeKey) options.normalizeKey = lookup.normalizeKey;
|
|
36138
36454
|
if (Array.isArray(source)) {
|
|
36139
36455
|
const test = search.filter ? data.createRowFilter(search.filter, { locale: search.locale }) : null;
|
|
36140
36456
|
options.items = test ? source.filter((item) => item !== null && typeof item === "object" && test(item)) : source;
|
|
@@ -40294,6 +40610,15 @@ var FilterModel = class {
|
|
|
40294
40610
|
"conditionOf",
|
|
40295
40611
|
() => null
|
|
40296
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
|
+
);
|
|
40297
40622
|
_defineProperty(
|
|
40298
40623
|
this,
|
|
40299
40624
|
/** Whether the filter row and the header filters are part of the filter value (`filterSyncEnabled`); the grid gives it. */
|
|
@@ -40678,7 +41003,11 @@ var FilterModel = class {
|
|
|
40678
41003
|
if (!this.columns.can(field, "filterRow")) return null;
|
|
40679
41004
|
const col = this.columns.get(field);
|
|
40680
41005
|
if (col.type === "boolean") return typeof f.value === "boolean" ? data.where(field, "=", f.value) : null;
|
|
40681
|
-
if (col.lookup)
|
|
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
|
+
}
|
|
40682
41011
|
const op = this.operator(field);
|
|
40683
41012
|
if (op === "isblank" || op === "isnotblank") return data.where(field, op);
|
|
40684
41013
|
if (op === "between") {
|
|
@@ -40703,7 +41032,7 @@ var FilterModel = class {
|
|
|
40703
41032
|
const condition = empty$2(v) ? null : own?.(v);
|
|
40704
41033
|
if (empty$2(v)) blank = true;
|
|
40705
41034
|
else if (condition) parts.push(condition);
|
|
40706
|
-
else plain.push(v);
|
|
41035
|
+
else plain.push(...this.keysOf(field, v));
|
|
40707
41036
|
}
|
|
40708
41037
|
const any = data.or(plain.length ? data.where(field, "in", plain) : null, ...parts, blank ? data.where(field, "isblank") : null);
|
|
40709
41038
|
return any && f.filterType === "exclude" ? data.not(any) : any;
|
|
@@ -40794,8 +41123,21 @@ function searchOf(filter) {
|
|
|
40794
41123
|
var LookupValues = class {
|
|
40795
41124
|
constructor(model) {
|
|
40796
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
|
+
);
|
|
40797
41132
|
this.model = model;
|
|
40798
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
|
+
}
|
|
40799
41141
|
/** The filter of the other columns (and the source's own), which a synced list honors. */
|
|
40800
41142
|
otherFilter(field) {
|
|
40801
41143
|
return data.and(this.model.baseFilter, this.model.filters.expression(void 0, field));
|
|
@@ -40877,9 +41219,25 @@ var LookupValues = class {
|
|
|
40877
41219
|
}
|
|
40878
41220
|
}
|
|
40879
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);
|
|
40880
41238
|
const lower = search.trim().toLocaleLowerCase(model.formatter.locale);
|
|
40881
41239
|
const collator = model.formatter.collator;
|
|
40882
|
-
const all = [...
|
|
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));
|
|
40883
41241
|
return {
|
|
40884
41242
|
values: all.slice(skip, skip + take),
|
|
40885
41243
|
total: all.length
|
|
@@ -43597,7 +43955,7 @@ var LookupTexts = class {
|
|
|
43597
43955
|
if (!lookup) return null;
|
|
43598
43956
|
const source = readField(lookup, "dataSource");
|
|
43599
43957
|
if (!source) return null;
|
|
43600
|
-
const items = KeyedItems.of(source, lookup.valueField);
|
|
43958
|
+
const items = KeyedItems.of(source, lookup.valueField, lookup.normalizeKey);
|
|
43601
43959
|
if (lookup.resolve) items.resolve = lookup.resolve;
|
|
43602
43960
|
if (lookup.batchSize) items.batchSize = lookup.batchSize;
|
|
43603
43961
|
if (lookup.parallelRequests) items.parallelRequests = lookup.parallelRequests;
|
|
@@ -43608,6 +43966,10 @@ var LookupTexts = class {
|
|
|
43608
43966
|
})));
|
|
43609
43967
|
return items;
|
|
43610
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
|
+
}
|
|
43611
43973
|
/** The text of an item: `textField`, else its `text`, else its value. */
|
|
43612
43974
|
textOf(col, item) {
|
|
43613
43975
|
const field = col.lookup?.textField;
|
|
@@ -43639,7 +44001,7 @@ var LookupTexts = class {
|
|
|
43639
44001
|
state: "none"
|
|
43640
44002
|
};
|
|
43641
44003
|
if (Array.isArray(value) && !(col.textFrom && !edited)) return this.listText(col, value, ask);
|
|
43642
|
-
const chosen = this.chosen.get(col.field)?.get(
|
|
44004
|
+
const chosen = this.chosen.get(col.field)?.get(this.keyOf(col, value));
|
|
43643
44005
|
if (chosen !== void 0) return {
|
|
43644
44006
|
text: chosen,
|
|
43645
44007
|
state: "found"
|
|
@@ -43661,7 +44023,7 @@ var LookupTexts = class {
|
|
|
43661
44023
|
state: "none"
|
|
43662
44024
|
};
|
|
43663
44025
|
if (Array.isArray(value)) return this.listText(col, value, ask);
|
|
43664
|
-
const chosen = this.chosen.get(col.field)?.get(
|
|
44026
|
+
const chosen = this.chosen.get(col.field)?.get(this.keyOf(col, value));
|
|
43665
44027
|
if (chosen !== void 0) return {
|
|
43666
44028
|
text: chosen,
|
|
43667
44029
|
state: "found"
|
|
@@ -43722,7 +44084,7 @@ var LookupTexts = class {
|
|
|
43722
44084
|
textOfKey(col, value) {
|
|
43723
44085
|
if (data.isEmpty(value)) return "";
|
|
43724
44086
|
if (Array.isArray(value)) return joinItems(listValues(value).map((v) => this.textOfKey(col, v)), this.locale());
|
|
43725
|
-
const chosen = this.chosen.get(col.field)?.get(
|
|
44087
|
+
const chosen = this.chosen.get(col.field)?.get(this.keyOf(col, value));
|
|
43726
44088
|
if (chosen !== void 0) return chosen;
|
|
43727
44089
|
const known = this.items(col)?.get(value);
|
|
43728
44090
|
return known?.state === "found" ? known.text ?? this.textOf(col, known.item) : String(value);
|
|
@@ -43739,13 +44101,13 @@ var LookupTexts = class {
|
|
|
43739
44101
|
const text = typeof itemOrText === "string" ? itemOrText : this.textOf(col, itemOrText);
|
|
43740
44102
|
let byKey = this.chosen.get(col.field);
|
|
43741
44103
|
if (!byKey) this.chosen.set(col.field, byKey = /* @__PURE__ */ new Map());
|
|
43742
|
-
byKey.set(
|
|
44104
|
+
byKey.set(this.keyOf(col, value), text);
|
|
43743
44105
|
this.items(col)?.remember(value, itemOrText);
|
|
43744
44106
|
}
|
|
43745
44107
|
/** Whether the source said it does not have the key (a failed request does not count). */
|
|
43746
44108
|
isMissing(col, value) {
|
|
43747
44109
|
if (Array.isArray(value)) return listValues(value).some((v) => this.isMissing(col, v));
|
|
43748
|
-
if (data.isEmpty(value) || this.chosen.get(col.field)?.has(
|
|
44110
|
+
if (data.isEmpty(value) || this.chosen.get(col.field)?.has(this.keyOf(col, value))) return false;
|
|
43749
44111
|
const known = this.items(col)?.get(value);
|
|
43750
44112
|
return known?.state === "missing" && !known.failed;
|
|
43751
44113
|
}
|
|
@@ -43830,7 +44192,7 @@ var LookupTexts = class {
|
|
|
43830
44192
|
return (row) => {
|
|
43831
44193
|
const value = cellValue(col, row);
|
|
43832
44194
|
if (data.isEmpty(value)) return null;
|
|
43833
|
-
const chosen = this.chosen.get(col.field)?.get(
|
|
44195
|
+
const chosen = this.chosen.get(col.field)?.get(this.keyOf(col, value));
|
|
43834
44196
|
if (chosen !== void 0) return chosen;
|
|
43835
44197
|
const known = this.items(col)?.get(value);
|
|
43836
44198
|
return known?.state === "found" ? known.text ?? this.textOf(col, known.item) : null;
|
|
@@ -44801,6 +45163,7 @@ var GridModel = class {
|
|
|
44801
45163
|
};
|
|
44802
45164
|
this.values = new FilterValues(this);
|
|
44803
45165
|
this.filters.conditionOf = (field) => this.values.conditionOf(field);
|
|
45166
|
+
this.filters.keysOf = (field, value) => this.values.lookups.keysOf(field, value);
|
|
44804
45167
|
const filterValue = stored ? this.reviveExpression(stored.filterValue ?? null) : read(props.filterValue);
|
|
44805
45168
|
if (filterValue) {
|
|
44806
45169
|
untracked(() => this.filters.filterValue());
|
|
@@ -48238,13 +48601,16 @@ var NO_FRAME = Object.freeze({
|
|
|
48238
48601
|
/**
|
|
48239
48602
|
* Widths of action buttons, measured once per action (its id, text and look) in a hidden cell and
|
|
48240
48603
|
* kept, so fitting a row's buttons only adds numbers: scrolling triggers no layout. An action not
|
|
48241
|
-
* measured yet counts 0 and is measured
|
|
48242
|
-
*
|
|
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.
|
|
48243
48608
|
*/
|
|
48244
48609
|
var ActionWidths = class {
|
|
48245
|
-
constructor(host, measured = () => {}) {
|
|
48610
|
+
constructor(host, measured = () => {}, waiting = () => {}) {
|
|
48246
48611
|
_defineProperty(this, "host", void 0);
|
|
48247
48612
|
_defineProperty(this, "measured", void 0);
|
|
48613
|
+
_defineProperty(this, "waiting", void 0);
|
|
48248
48614
|
_defineProperty(this, "widths", /* @__PURE__ */ new Map());
|
|
48249
48615
|
_defineProperty(this, "frameSize", null);
|
|
48250
48616
|
_defineProperty(this, "box", null);
|
|
@@ -48260,6 +48626,12 @@ var ActionWidths = class {
|
|
|
48260
48626
|
"moreProbe",
|
|
48261
48627
|
null
|
|
48262
48628
|
);
|
|
48629
|
+
_defineProperty(
|
|
48630
|
+
this,
|
|
48631
|
+
/** Takes back the read that waits for the page to be drawn. */
|
|
48632
|
+
"pending",
|
|
48633
|
+
null
|
|
48634
|
+
);
|
|
48263
48635
|
_defineProperty(this, "read", () => {
|
|
48264
48636
|
const box = this.box;
|
|
48265
48637
|
const more = this.moreProbe;
|
|
@@ -48283,6 +48655,10 @@ var ActionWidths = class {
|
|
|
48283
48655
|
};
|
|
48284
48656
|
});
|
|
48285
48657
|
_defineProperty(this, "write", (seen) => {
|
|
48658
|
+
if (this.pending) {
|
|
48659
|
+
this.pending = null;
|
|
48660
|
+
this.waiting(false);
|
|
48661
|
+
}
|
|
48286
48662
|
let kept = false;
|
|
48287
48663
|
for (const { key, button, width } of seen.buttons) {
|
|
48288
48664
|
if (this.probes.get(key) === button) this.probes.delete(key);
|
|
@@ -48304,6 +48680,7 @@ var ActionWidths = class {
|
|
|
48304
48680
|
});
|
|
48305
48681
|
this.host = host;
|
|
48306
48682
|
this.measured = measured;
|
|
48683
|
+
this.waiting = waiting;
|
|
48307
48684
|
}
|
|
48308
48685
|
/** Measure again (the density changed). */
|
|
48309
48686
|
clear() {
|
|
@@ -48322,7 +48699,7 @@ var ActionWidths = class {
|
|
|
48322
48699
|
box.controls.add(button);
|
|
48323
48700
|
this.probes.set(key, button);
|
|
48324
48701
|
}
|
|
48325
|
-
|
|
48702
|
+
this.ask(box);
|
|
48326
48703
|
return 0;
|
|
48327
48704
|
}
|
|
48328
48705
|
/** The cell's padding (both sides), the gap between buttons and the width of the "more" button; zeros until measured. */
|
|
@@ -48336,9 +48713,19 @@ var ActionWidths = class {
|
|
|
48336
48713
|
box.controls.add(more);
|
|
48337
48714
|
this.moreProbe = more;
|
|
48338
48715
|
}
|
|
48339
|
-
|
|
48716
|
+
this.ask(box);
|
|
48340
48717
|
return NO_FRAME;
|
|
48341
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
|
+
}
|
|
48342
48729
|
cell() {
|
|
48343
48730
|
const host = this.host();
|
|
48344
48731
|
if (!host) return null;
|
|
@@ -52360,7 +52747,10 @@ var GridRow = class {
|
|
|
52360
52747
|
for (const [field, text] of this.texts) {
|
|
52361
52748
|
const col = model.columns.get(field);
|
|
52362
52749
|
if (!col.lookup || model.lookups.items(col) !== items) continue;
|
|
52363
|
-
if (wanted
|
|
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
|
+
}
|
|
52364
52754
|
this.drawLookup(this.cellParts.get(field), text, col);
|
|
52365
52755
|
}
|
|
52366
52756
|
}
|
|
@@ -55553,6 +55943,7 @@ var OWN$36 = [
|
|
|
55553
55943
|
var FUNCTIONS$3 = [
|
|
55554
55944
|
"textField",
|
|
55555
55945
|
"valueField",
|
|
55946
|
+
"normalizeKey",
|
|
55556
55947
|
"iconField",
|
|
55557
55948
|
"groupField",
|
|
55558
55949
|
"enabledField",
|
|
@@ -55595,7 +55986,13 @@ var ListBox = class extends Field {
|
|
|
55595
55986
|
this.observeProperty("searchEnabled", () => this.renderSearch());
|
|
55596
55987
|
this.observeProperty("height", (height) => this.renderHeight(height));
|
|
55597
55988
|
this.observeProperty("selectionMode", (mode) => put(this, "data-selection-mode", mode ?? "single"));
|
|
55598
|
-
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;
|
|
55599
55996
|
parts.known.clear();
|
|
55600
55997
|
this.renderValue(this.peekValue());
|
|
55601
55998
|
});
|
|
@@ -55639,6 +56036,12 @@ var ListBox = class extends Field {
|
|
|
55639
56036
|
set valueField(value) {
|
|
55640
56037
|
this.assignProperty("valueField", functionValue(value));
|
|
55641
56038
|
}
|
|
56039
|
+
get normalizeKey() {
|
|
56040
|
+
return this.getProperty("normalizeKey");
|
|
56041
|
+
}
|
|
56042
|
+
set normalizeKey(value) {
|
|
56043
|
+
this.assignProperty("normalizeKey", functionValue(value));
|
|
56044
|
+
}
|
|
55642
56045
|
get iconField() {
|
|
55643
56046
|
return this.getProperty("iconField");
|
|
55644
56047
|
}
|
|
@@ -55793,6 +56196,11 @@ var ListBox = class extends Field {
|
|
|
55793
56196
|
itemText(item) {
|
|
55794
56197
|
return String(readItemField(item, this.peekProperty("textField"), "text") ?? "");
|
|
55795
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
|
+
}
|
|
55796
56204
|
itemValue(item) {
|
|
55797
56205
|
const field = this.peekProperty("valueField");
|
|
55798
56206
|
if (field !== void 0) return readItemField(item, field, "value");
|
|
@@ -55823,7 +56231,7 @@ var ListBox = class extends Field {
|
|
|
55823
56231
|
setUpList(list) {
|
|
55824
56232
|
list.textOf = (row) => row === selectAllRow ? "" : this.itemText(row);
|
|
55825
56233
|
list.enabledOf = (row) => row === selectAllRow || this.canChoose(row);
|
|
55826
|
-
list.isSelected = (row) => row === selectAllRow ? this.allState() === true : this.
|
|
56234
|
+
list.isSelected = (row) => row === selectAllRow ? this.allState() === true : this.isChosen(row);
|
|
55827
56235
|
list.emptyText = () => this.peekProperty("noItemsText") || (this.listParts.items.loading ? uiLocale.strings.loading : uiLocale.strings.noItems);
|
|
55828
56236
|
}
|
|
55829
56237
|
/** Gives the list a drawing for the template now, made anew only when the template changes. */
|
|
@@ -55857,7 +56265,7 @@ var ListBox = class extends Field {
|
|
|
55857
56265
|
}
|
|
55858
56266
|
allState() {
|
|
55859
56267
|
const parts = this.listParts;
|
|
55860
|
-
return selectAllState(parts.items, parts.chosen, (item) => this.
|
|
56268
|
+
return selectAllState(parts.items, parts.chosen, (item) => this.isChosen(item), (item) => this.canChoose(item));
|
|
55861
56269
|
}
|
|
55862
56270
|
renderSource() {
|
|
55863
56271
|
const parts = this.listParts;
|
|
@@ -56005,7 +56413,7 @@ var ListBox = class extends Field {
|
|
|
56005
56413
|
let index = -1;
|
|
56006
56414
|
if (parts.chosen.size) for (let i = 0; i < list.count && index < 0; i++) {
|
|
56007
56415
|
const row = list.itemOf(i);
|
|
56008
|
-
if (row !== void 0 && row !== selectAllRow &&
|
|
56416
|
+
if (row !== void 0 && row !== selectAllRow && this.isChosen(row)) index = i;
|
|
56009
56417
|
}
|
|
56010
56418
|
if (index >= 0) list.setActive(index);
|
|
56011
56419
|
else list.move("first");
|
|
@@ -56090,8 +56498,9 @@ var ListBox = class extends Field {
|
|
|
56090
56498
|
}
|
|
56091
56499
|
const values = this.valuesOf(this.peekValue());
|
|
56092
56500
|
let next;
|
|
56501
|
+
const held = parts.items.heldIn(parts.chosen, value);
|
|
56093
56502
|
if (how === "only") next = [value];
|
|
56094
|
-
else if (
|
|
56503
|
+
else if (held) next = how === "toggle" ? values.filter((v) => !Object.is(v, held.value)) : values;
|
|
56095
56504
|
else next = [...values, value];
|
|
56096
56505
|
this.commit(next, event);
|
|
56097
56506
|
}
|
|
@@ -56106,7 +56515,7 @@ var ListBox = class extends Field {
|
|
|
56106
56515
|
const row = parts.list.itemOf(i);
|
|
56107
56516
|
if (row === void 0 || row === selectAllRow || !this.canChoose(row)) continue;
|
|
56108
56517
|
const value = this.itemValue(row);
|
|
56109
|
-
if (!next.some((v) =>
|
|
56518
|
+
if (!next.some((v) => parts.items.sameItem(v, value))) next.push(value);
|
|
56110
56519
|
}
|
|
56111
56520
|
this.commit(next, event);
|
|
56112
56521
|
}
|
|
@@ -56120,7 +56529,7 @@ var ListBox = class extends Field {
|
|
|
56120
56529
|
const current = this.valuesOf(this.peekValue());
|
|
56121
56530
|
const chosen = new Set(current);
|
|
56122
56531
|
const set = new Set(shown);
|
|
56123
|
-
const next = on ? [...current, ...shown.filter((v) => !
|
|
56532
|
+
const next = on ? [...current, ...shown.filter((v) => !parts.items.heldIn(chosen, v))] : current.filter((v) => !parts.items.heldIn(set, v));
|
|
56124
56533
|
this.commit(next, event);
|
|
56125
56534
|
}
|
|
56126
56535
|
};
|
|
@@ -56830,7 +57239,7 @@ var FilterBuilderModel = class {
|
|
|
56830
57239
|
const source = givenField(lookup, "dataSource");
|
|
56831
57240
|
if (!source) return String(v);
|
|
56832
57241
|
this.state.texts;
|
|
56833
|
-
const items = KeyedItems.of(source, givenValue(lookup, "valueField"));
|
|
57242
|
+
const items = KeyedItems.of(source, givenValue(lookup, "valueField"), lookup.normalizeKey);
|
|
56834
57243
|
const known = items.get(v);
|
|
56835
57244
|
if (!known) {
|
|
56836
57245
|
items.request([v]).then(() => untracked(() => this.state.texts++));
|
|
@@ -57918,7 +58327,8 @@ var FilterBuilder = class extends Control {
|
|
|
57918
58327
|
const from = Array.isArray(source) ? { items: source } : { dataSource: source };
|
|
57919
58328
|
const fields = {
|
|
57920
58329
|
valueField: lookup.valueField,
|
|
57921
|
-
textField: lookup.textField
|
|
58330
|
+
textField: lookup.textField,
|
|
58331
|
+
normalizeKey: lookup.normalizeKey
|
|
57922
58332
|
};
|
|
57923
58333
|
if (many) return new TagBox({
|
|
57924
58334
|
...from,
|
|
@@ -58111,6 +58521,7 @@ function builderFields(model, customOperations = []) {
|
|
|
58111
58521
|
const lookup = col.lookup ? {
|
|
58112
58522
|
dataSource: col.lookup.dataSource,
|
|
58113
58523
|
valueField: col.lookup.valueField,
|
|
58524
|
+
normalizeKey: col.lookup.normalizeKey,
|
|
58114
58525
|
textField: col.lookup.textField
|
|
58115
58526
|
} : options ? {
|
|
58116
58527
|
dataSource: options,
|
|
@@ -58872,7 +59283,7 @@ var DataGrid = class extends Control {
|
|
|
58872
59283
|
this.bands = new BandRows(_model, host, this.header);
|
|
58873
59284
|
this.motif.setDisposable(() => this.bands.dispose());
|
|
58874
59285
|
this.filterRow = new FilterRow(_model);
|
|
58875
|
-
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));
|
|
58876
59287
|
onLayout(this, "look", () => {
|
|
58877
59288
|
this.widths.clear();
|
|
58878
59289
|
this.measureSizes();
|
|
@@ -61296,11 +61707,13 @@ var DataGrid = class extends Control {
|
|
|
61296
61707
|
model.showsFilterRow()
|
|
61297
61708
|
];
|
|
61298
61709
|
}, () => {
|
|
61710
|
+
const held = this.tabbable && !this.tabbable.isDisposed && holdsFocus(this.tabbable) ? this.tabbable : null;
|
|
61299
61711
|
const visible = model.columns.visible();
|
|
61300
61712
|
this.findColumns(visible);
|
|
61301
61713
|
this.arrangeColumns(visible, model.showsFilterRow());
|
|
61302
61714
|
model.keepActiveFieldVisible();
|
|
61303
|
-
this.
|
|
61715
|
+
if (held && this.activePart() !== held) this.focusActive(false);
|
|
61716
|
+
else this.syncTabStop();
|
|
61304
61717
|
});
|
|
61305
61718
|
this.whenChanged(() => {
|
|
61306
61719
|
const visible = model.columns.visible();
|
|
@@ -61791,13 +62204,16 @@ var DataGrid = class extends Control {
|
|
|
61791
62204
|
actionButtons(view) {
|
|
61792
62205
|
return view.actions?.buttonParts() ?? [];
|
|
61793
62206
|
}
|
|
61794
|
-
/**
|
|
61795
|
-
|
|
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) {
|
|
61796
62212
|
const active = this.keptColumn();
|
|
61797
62213
|
if (active && !this.model.columnWindow.has(active)) this.updateColumns();
|
|
61798
62214
|
const part = this.activePart();
|
|
61799
62215
|
if (!part) return;
|
|
61800
|
-
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");
|
|
61801
62217
|
put(part, "tabindex", this.tabStop ? "0" : "-1");
|
|
61802
62218
|
this.tabbable = part;
|
|
61803
62219
|
}
|
|
@@ -61868,10 +62284,12 @@ var DataGrid = class extends Control {
|
|
|
61868
62284
|
if (reveal && activeRow >= 0) this.body.reveal(activeRow);
|
|
61869
62285
|
const cols = this.model.columns;
|
|
61870
62286
|
if (reveal) this.revealColumn(cols.isBand(activeField) ? cols.leavesIn(activeField, cols.visible())[0] ?? activeField : activeField);
|
|
61871
|
-
this.
|
|
62287
|
+
const was = this.tabbable;
|
|
62288
|
+
this.syncTabStop(false);
|
|
61872
62289
|
const part = this.activePart();
|
|
61873
62290
|
if (!part) return;
|
|
61874
62291
|
focusOn(part, { preventScroll: true });
|
|
62292
|
+
if (was && was !== part && !was.isDisposed) put(was, "tabindex", "-1");
|
|
61875
62293
|
if (this.model.settings.get("tooltips")) this.tip.focus(part);
|
|
61876
62294
|
}
|
|
61877
62295
|
/** The column the active cell is in (a band's first one), drawn even while it is out of view. */
|
|
@@ -91481,8 +91899,8 @@ var AppointmentEditor = class {
|
|
|
91481
91899
|
columns: settings.columns ?? (phone ? 1 : 2),
|
|
91482
91900
|
minColumnWidth: settings.minColumnWidth ?? "",
|
|
91483
91901
|
labelMode: settings.labelMode,
|
|
91484
|
-
onFieldChanged: () => this.formChanged(layout),
|
|
91485
91902
|
ref: (c) => layout = c,
|
|
91903
|
+
onFieldChanged: () => this.formChanged(layout),
|
|
91486
91904
|
runover: {},
|
|
91487
91905
|
childs: []
|
|
91488
91906
|
});
|
|
@@ -91667,16 +92085,16 @@ var AppointmentEditor = class {
|
|
|
91667
92085
|
colSpan: "all",
|
|
91668
92086
|
visible: () => editing.allowRecurrence && !exception,
|
|
91669
92087
|
template: () => motifComponent(RecurrenceEditor, {
|
|
92088
|
+
ref: (r) => this.recurrence = {
|
|
92089
|
+
editor: r,
|
|
92090
|
+
data
|
|
92091
|
+
},
|
|
91670
92092
|
class: "mx-scheduler__recurrence",
|
|
91671
92093
|
start: () => data.start instanceof Date ? data.start : null,
|
|
91672
92094
|
allDay: () => !!data.allDay,
|
|
91673
92095
|
timeZone: () => data.startTimeZone ? String(data.startTimeZone) : model.zone.name || null,
|
|
91674
92096
|
locale: () => this.host.locale(),
|
|
91675
92097
|
firstDayOfWeek: () => this.host.firstDayOfWeek(),
|
|
91676
|
-
ref: (r) => this.recurrence = {
|
|
91677
|
-
editor: r,
|
|
91678
|
-
data
|
|
91679
|
-
},
|
|
91680
92098
|
runover: { initializeComponent: (sender) => {
|
|
91681
92099
|
sender.bindings.model(() => data.recurrenceRule, (_value) => {
|
|
91682
92100
|
const _owner = data;
|
|
@@ -106588,7 +107006,7 @@ var RibbonKeyHints = class {
|
|
|
106588
107006
|
});
|
|
106589
107007
|
return true;
|
|
106590
107008
|
}
|
|
106591
|
-
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"));
|
|
106592
107010
|
else if (this.level === level) this.stop();
|
|
106593
107011
|
return true;
|
|
106594
107012
|
}
|
|
@@ -108115,7 +108533,8 @@ var RibbonMenu = class RibbonMenu extends Control {
|
|
|
108115
108533
|
part: host,
|
|
108116
108534
|
keys: parsed.key ?? "",
|
|
108117
108535
|
text: parsed.text,
|
|
108118
|
-
press: () => this.pressTab(look)
|
|
108536
|
+
press: () => this.pressTab(look),
|
|
108537
|
+
tab: true
|
|
108119
108538
|
});
|
|
108120
108539
|
});
|
|
108121
108540
|
let n = 1;
|
|
@@ -108175,10 +108594,13 @@ var RibbonMenu = class RibbonMenu extends Control {
|
|
|
108175
108594
|
});
|
|
108176
108595
|
} else if (m.type === "content") {
|
|
108177
108596
|
const content = m.control;
|
|
108178
|
-
if (hasFocusableIn(content))
|
|
108597
|
+
if (!hasFocusableIn(content)) return;
|
|
108598
|
+
const label = parseAccessKey(contentName(content));
|
|
108599
|
+
const named = text.text || String(fieldOf(command, "hint", this) ?? "");
|
|
108600
|
+
hints.push({
|
|
108179
108601
|
part: content,
|
|
108180
|
-
keys,
|
|
108181
|
-
text:
|
|
108602
|
+
keys: keys || (named ? "" : label.key ?? ""),
|
|
108603
|
+
text: named || label.text,
|
|
108182
108604
|
press: () => focusFirstIn(content)
|
|
108183
108605
|
});
|
|
108184
108606
|
} else if (m.made) for (const inner of m.made.values()) add(inner);
|
|
@@ -108664,6 +109086,16 @@ function partStops(part, stops) {
|
|
|
108664
109086
|
if (canTakeFocus(part)) stops.push(part);
|
|
108665
109087
|
for (const child of part.controls.items) partStops(child, stops);
|
|
108666
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
|
+
}
|
|
108667
109099
|
function buttonHint(button, keys, text) {
|
|
108668
109100
|
const face = button.faceComponent;
|
|
108669
109101
|
const press = () => {
|