@freegridjs/core 1.9.3 → 1.9.5
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/dist/cdn/freegrid.css +542 -541
- package/dist/cdn/freegrid.esm.js +18 -18
- package/dist/cdn/freegrid.min.js +22 -22
- package/dist/index.d.ts +3 -3
- package/dist/index.js +251 -22
- package/dist/locales/de.d.ts +1 -1
- package/dist/locales/en.d.ts +1 -1
- package/dist/locales/es.d.ts +1 -1
- package/dist/locales/fr.d.ts +1 -1
- package/dist/locales/id.d.ts +1 -1
- package/dist/locales/it.d.ts +1 -1
- package/dist/locales/ja.d.ts +1 -1
- package/dist/locales/ko.d.ts +1 -1
- package/dist/locales/pt-BR.d.ts +1 -1
- package/dist/locales/ru.d.ts +1 -1
- package/dist/locales/th.d.ts +1 -1
- package/dist/locales/vi.d.ts +1 -1
- package/dist/locales/zh-CN.d.ts +1 -1
- package/dist/locales/zh-TW.d.ts +1 -1
- package/dist/styles.css +542 -541
- package/dist/{types-DloQYCt_.d.ts → types-CIOv3MoN.d.ts} +34 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { G as GridOptions, a as GridApi, E as ExportOptions, R as Row, D as Datasource, b as RowTransaction, L as LocalePack } from './types-
|
|
2
|
-
export { A as AdvancedFilter, c as AdvancedFilterCondition, d as Aggregator, e as AssistantAction, f as AssistantColumn, g as AssistantOptions, h as AssistantRequest, i as AssistantResult, C as CellEvent, j as CellParams, k as CellStyle, l as ChartHandle, m as ChartOptions, n as ColumnDef, o as ColumnState, p as ColumnType, q as CombinedFilterModel, r as ConditionalFormat, s as ConditionalFormatType, t as ConditionalOp, u as ContextMenuItem, v as ContextMenuParams, w as CustomEditor, x as DateFilterModel, y as DateOp, z as EditorParams, B as EditorSpec, F as FilterModel, H as FilterOp, I as FilterType, J as GridEvents, K as GridRange, M as InvalidCell, N as JsonExportOptions, O as KeyAction, P as
|
|
1
|
+
import { G as GridOptions, a as GridApi, E as ExportOptions, R as Row, D as Datasource, b as RowTransaction, L as LocalePack } from './types-CIOv3MoN.js';
|
|
2
|
+
export { A as AdvancedFilter, c as AdvancedFilterCondition, d as Aggregator, e as AssistantAction, f as AssistantColumn, g as AssistantOptions, h as AssistantRequest, i as AssistantResult, C as CellEvent, j as CellParams, k as CellStyle, l as ChartHandle, m as ChartOptions, n as ColumnDef, o as ColumnState, p as ColumnType, q as CombinedFilterModel, r as ConditionalFormat, s as ConditionalFormatType, t as ConditionalOp, u as ContextMenuItem, v as ContextMenuParams, w as CustomEditor, x as DateFilterModel, y as DateOp, z as EditorParams, B as EditorSpec, F as FilterModel, H as FilterOp, I as FilterType, J as GridEvents, K as GridRange, M as InvalidCell, N as JsonExportOptions, O as KeyAction, P as MergeSelectionGroup, Q as Messages, S as NumberFilterModel, T as NumberOp, U as PdfOptions, V as PivotConfig, W as PrintOptions, X as Region, Y as RowDragOptions, Z as RowDropParams, _ as RowDropPosition, $ as SavedGridState, a0 as SavedStatePart, a1 as ScrollPosition, a2 as SelectOption, a3 as ServerParams, a4 as SetFilterModel, a5 as SortDir, a6 as SortItem, a7 as SpanParams, a8 as SummaryCell, a9 as SummaryOptions, aa as SummaryRowDef, ab as TextFilterModel, ac as TextOp, ad as TransactionResult, ae as XlsxCell, af as XlsxSheet, ag as readXlsx, ah as writeXlsx } from './types-CIOv3MoN.js';
|
|
3
3
|
export { default as en } from './locales/en.js';
|
|
4
4
|
|
|
5
5
|
declare function createGrid(host: HTMLElement, options: GridOptions): GridApi;
|
|
6
6
|
|
|
7
7
|
/** FreeGrid version (kept in sync with releases.json by scripts/release.mjs). */
|
|
8
|
-
declare const version = "1.9.
|
|
8
|
+
declare const version = "1.9.5";
|
|
9
9
|
|
|
10
10
|
interface LicenseInfo {
|
|
11
11
|
/** Licensed domains; each also covers every subdomain below it (`*.example.com` means the same as `example.com`). */
|
package/dist/index.js
CHANGED
|
@@ -596,9 +596,31 @@ var ColumnModel = class {
|
|
|
596
596
|
relayout() {
|
|
597
597
|
const visible = this.leafNodes().filter((n) => !n.hide && this.shownByGroups(n));
|
|
598
598
|
const fixed = visible.reduce((s, n) => s + (n.flex ? 0 : n.width), 0);
|
|
599
|
-
const
|
|
600
|
-
|
|
601
|
-
|
|
599
|
+
const flexWidth = /* @__PURE__ */ new Map();
|
|
600
|
+
let pending = visible.filter((n) => n.flex);
|
|
601
|
+
let free = Math.max(0, this.containerWidth - fixed);
|
|
602
|
+
while (pending.length) {
|
|
603
|
+
const totalFlex = pending.reduce((s, n) => s + n.flex, 0);
|
|
604
|
+
const share = (n) => Math.floor(free * n.flex / totalFlex);
|
|
605
|
+
const excess = pending.reduce((s, n) => s + clampWidth(n.def, share(n)) - share(n), 0);
|
|
606
|
+
const clamped = pending.filter((n) => {
|
|
607
|
+
const d = clampWidth(n.def, share(n)) - share(n);
|
|
608
|
+
return excess > 0 ? d > 0 : excess < 0 ? d < 0 : false;
|
|
609
|
+
});
|
|
610
|
+
if (!clamped.length) {
|
|
611
|
+
for (const n of pending) flexWidth.set(n, clampWidth(n.def, share(n)));
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
let used = 0;
|
|
615
|
+
for (const n of clamped) {
|
|
616
|
+
const w = clampWidth(n.def, share(n));
|
|
617
|
+
flexWidth.set(n, w);
|
|
618
|
+
used += w;
|
|
619
|
+
}
|
|
620
|
+
free = Math.max(0, free - used);
|
|
621
|
+
pending = pending.filter((n) => !clamped.includes(n));
|
|
622
|
+
}
|
|
623
|
+
const widthOf = (n) => flexWidth.get(n) ?? n.width;
|
|
602
624
|
const next = { left: [], center: [], right: [] };
|
|
603
625
|
this.leafById = /* @__PURE__ */ new Map();
|
|
604
626
|
let index = 0;
|
|
@@ -1882,21 +1904,26 @@ function computeSpans(rows, def) {
|
|
|
1882
1904
|
}
|
|
1883
1905
|
return { start, end };
|
|
1884
1906
|
}
|
|
1907
|
+
function nestedSpans(list, n) {
|
|
1908
|
+
const start = new Int32Array(n);
|
|
1909
|
+
const end = new Int32Array(n);
|
|
1910
|
+
let s = 0;
|
|
1911
|
+
for (let i = 1; i <= n; i++) {
|
|
1912
|
+
if (i < n && !list.some((sp) => sp.start[i] === i)) continue;
|
|
1913
|
+
for (let k = s; k < i; k++) {
|
|
1914
|
+
start[k] = s;
|
|
1915
|
+
end[k] = i - 1;
|
|
1916
|
+
}
|
|
1917
|
+
s = i;
|
|
1918
|
+
}
|
|
1919
|
+
return { start, end };
|
|
1920
|
+
}
|
|
1885
1921
|
function mergeBlocks(rows, defs) {
|
|
1886
1922
|
const n = rows.length;
|
|
1887
1923
|
const block = new Int32Array(n);
|
|
1888
1924
|
if (!n || !defs.length) return block;
|
|
1889
|
-
const
|
|
1890
|
-
let
|
|
1891
|
-
for (let i = 1; i < n; i++) {
|
|
1892
|
-
for (let k = 0; k < starts.length; k++) {
|
|
1893
|
-
if (starts[k][i] === i) {
|
|
1894
|
-
b++;
|
|
1895
|
-
break;
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
block[i] = b;
|
|
1899
|
-
}
|
|
1925
|
+
const { start } = nestedSpans(defs.map((def) => computeSpans(rows, def)), n);
|
|
1926
|
+
for (let i = 1; i < n; i++) block[i] = block[i - 1] + (start[i] === i ? 1 : 0);
|
|
1900
1927
|
return block;
|
|
1901
1928
|
}
|
|
1902
1929
|
|
|
@@ -2464,6 +2491,7 @@ var Renderer = class {
|
|
|
2464
2491
|
const { selected, focus } = store.state;
|
|
2465
2492
|
const allBounds = this.grid.allRangeBounds();
|
|
2466
2493
|
const spans = this.grid.mergeSpans();
|
|
2494
|
+
const blocks = spans.has(SELECT_COL_ID);
|
|
2467
2495
|
const { geo } = this;
|
|
2468
2496
|
const top = Math.max(0, geo.top - this.topOffset);
|
|
2469
2497
|
const range = this.grid.options.autoHeight && !rowModel.server ? { first: 0, last: count - 1 } : this.offsets ? rowRangeByOffsets(this.offsets, top, geo.ch, count, ROW_OVERSCAN) : rowRange(top, geo.ch, this.opts.rowHeight, count, ROW_OVERSCAN);
|
|
@@ -2492,8 +2520,9 @@ var Renderer = class {
|
|
|
2492
2520
|
const hits = allBounds.filter((b) => i >= b.r1 && i <= b.r2);
|
|
2493
2521
|
const inRange = hits.map((b) => `${b.c1}-${b.c2}`).join(",");
|
|
2494
2522
|
const merge2 = this.mergeState(spans, cols, i, range.first);
|
|
2523
|
+
const block = blocks && !node.kind ? this.grid.blockSelection(i) ?? "" : "";
|
|
2495
2524
|
const pos = node.kind === "detail" ? `${geo.left}:${geo.cw}` : "";
|
|
2496
|
-
const base = `${node.id}|${this.version}.${this.rowVersions.get(node.id) ?? 0}|${isSel ? 1 : 0}${node.kind === "group" ? `:${this.grid.selectionVersion}` : ""}|${focusCol}|${inRange}|${merge2}|${pos}`;
|
|
2525
|
+
const base = `${node.id}|${this.version}.${this.rowVersions.get(node.id) ?? 0}|${isSel ? 1 : 0}${node.kind === "group" ? `:${this.grid.selectionVersion}` : ""}${block}|${focusCol}|${inRange}|${merge2}|${pos}`;
|
|
2497
2526
|
const key = `${colKey}|${base}`;
|
|
2498
2527
|
let row = map.get(i);
|
|
2499
2528
|
if (!row) {
|
|
@@ -2690,7 +2719,15 @@ var Renderer = class {
|
|
|
2690
2719
|
cell.className = `${cls} fg-cell-select`;
|
|
2691
2720
|
const box = el("input", "fg-checkbox", { type: "checkbox", tabindex: "-1", "aria-label": locale.selectRow });
|
|
2692
2721
|
box.checked = selected;
|
|
2693
|
-
|
|
2722
|
+
const block = i >= 0 && !node.kind ? this.grid.blockSelection(i) : null;
|
|
2723
|
+
if (block) {
|
|
2724
|
+
box.checked = block === "all";
|
|
2725
|
+
box.indeterminate = block === "some";
|
|
2726
|
+
if (block === "off") {
|
|
2727
|
+
box.disabled = true;
|
|
2728
|
+
cell.classList.add("fg-cell-select-locked");
|
|
2729
|
+
}
|
|
2730
|
+
} else if (i >= 0 && !node.kind && !this.grid.rowSelectable(node.data)) {
|
|
2694
2731
|
box.disabled = true;
|
|
2695
2732
|
cell.classList.add("fg-cell-select-locked");
|
|
2696
2733
|
}
|
|
@@ -7742,7 +7779,7 @@ var PAID_FEATURES = {
|
|
|
7742
7779
|
};
|
|
7743
7780
|
|
|
7744
7781
|
// src/version.ts
|
|
7745
|
-
var version = "1.9.
|
|
7782
|
+
var version = "1.9.5";
|
|
7746
7783
|
|
|
7747
7784
|
// src/license.ts
|
|
7748
7785
|
var PUBLIC_KEY = { kty: "EC", crv: "P-256", x: "sUTKkglZmk-HMKPNub8p7AeLBKesHCU8irIkw9rJlbE", y: "j0U_aKRDR7iApY9UpaD3hUemhBLZJwDv9-QiT_hUyw8" };
|
|
@@ -8290,6 +8327,8 @@ var RowModel = class {
|
|
|
8290
8327
|
this.full = [];
|
|
8291
8328
|
this.last = {};
|
|
8292
8329
|
this.nodes = [];
|
|
8330
|
+
/** Ids given to the current rows (repeats of a getRowId value made unique). */
|
|
8331
|
+
this.assignedIds = /* @__PURE__ */ new WeakMap();
|
|
8293
8332
|
this.filtered = [];
|
|
8294
8333
|
this.sorted = [];
|
|
8295
8334
|
this.display = [];
|
|
@@ -8308,7 +8347,23 @@ var RowModel = class {
|
|
|
8308
8347
|
const displayChanged = sortChanged || d?.version !== this.last.displayVersion || d?.groupBy !== this.last.display?.groupBy;
|
|
8309
8348
|
if (dataChanged) {
|
|
8310
8349
|
const getId = this.deps.getRowId;
|
|
8311
|
-
|
|
8350
|
+
if (getId) {
|
|
8351
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
8352
|
+
let dup = null;
|
|
8353
|
+
this.assignedIds = /* @__PURE__ */ new WeakMap();
|
|
8354
|
+
this.nodes = input.data.map((data, i) => {
|
|
8355
|
+
const raw = String(getId(data));
|
|
8356
|
+
let id = raw;
|
|
8357
|
+
if (seen2.has(id)) {
|
|
8358
|
+
dup ?? (dup = raw);
|
|
8359
|
+
for (let k = 2; seen2.has(id); k++) id = `${raw}#${k}`;
|
|
8360
|
+
}
|
|
8361
|
+
seen2.add(id);
|
|
8362
|
+
this.assignedIds.set(data, id);
|
|
8363
|
+
return { id, data, sourceIndex: i };
|
|
8364
|
+
});
|
|
8365
|
+
if (dup !== null) warn(`getRowId returned "${dup}" for more than one row; inside the grid the repeats are told apart as "${dup}#2" and so on, and updates by id reach the first of them. Return a unique id per row.`);
|
|
8366
|
+
} else this.nodes = input.data.map((data, i) => ({ id: autoId(data), data, sourceIndex: i }));
|
|
8312
8367
|
}
|
|
8313
8368
|
if (filterChanged) {
|
|
8314
8369
|
this.filtered = this.filter(input);
|
|
@@ -8361,7 +8416,8 @@ var RowModel = class {
|
|
|
8361
8416
|
}
|
|
8362
8417
|
/** Id of a row object as currently assigned. */
|
|
8363
8418
|
idOf(row) {
|
|
8364
|
-
|
|
8419
|
+
if (!this.deps.getRowId) return autoId(row);
|
|
8420
|
+
return this.assignedIds.get(row) ?? String(this.deps.getRowId(row));
|
|
8365
8421
|
}
|
|
8366
8422
|
indexOfId(id) {
|
|
8367
8423
|
if (!this.indexById) this.indexById = new Map(this.display.map((n, i) => [n.id, i]));
|
|
@@ -10040,6 +10096,11 @@ var Grid = class {
|
|
|
10040
10096
|
// ── merge, aggregates, fill, pinned rows ────────────────────
|
|
10041
10097
|
/** `sortWithinMerges` is on. */
|
|
10042
10098
|
this.sortWithin = false;
|
|
10099
|
+
// ── mergeSelection: one checkbox per merged block ───────────
|
|
10100
|
+
/** 'rows' or the merge level whose blocks get one checkbox each. */
|
|
10101
|
+
this.mergeSel = "rows";
|
|
10102
|
+
this.selBlockCache = null;
|
|
10103
|
+
this.blockStateCache = null;
|
|
10043
10104
|
/** Count / sum / min / max over the selected range (numbers only for the math). */
|
|
10044
10105
|
this.aggMemo = null;
|
|
10045
10106
|
/** Bumped on every selection change (group row checkboxes depend on their rows). */
|
|
@@ -10090,6 +10151,7 @@ var Grid = class {
|
|
|
10090
10151
|
sortBlocks: (sort) => this.sortBlocks(sort)
|
|
10091
10152
|
});
|
|
10092
10153
|
this.sortWithin = !!options.sortWithinMerges;
|
|
10154
|
+
this.mergeSel = this.validMergeSelection(options.mergeSelection);
|
|
10093
10155
|
if (this.sortWithin && this.rowModel.server) warn("sortWithinMerges is ignored with a datasource: the server sorts the rows");
|
|
10094
10156
|
if (options.groupBy?.length && this.allow(this.rowModel.server ? "serverGroups" : "grouping")) this.groupBy = this.validGroupBy(options.groupBy);
|
|
10095
10157
|
if (Array.isArray(options.conditionalFormats) && options.conditionalFormats.length && this.allow("conditional")) this.cfRules = options.conditionalFormats.filter((r) => r && typeof r === "object" && Array.isArray(r.columns)).map((r) => ({ ...r, columns: [...r.columns] }));
|
|
@@ -11357,16 +11419,173 @@ var Grid = class {
|
|
|
11357
11419
|
if (!this.allow("merge")) return NO_SPANS;
|
|
11358
11420
|
const rows = this.rowModel.rows();
|
|
11359
11421
|
const ver = this.editVersion * 1e6 + this.columns.displayed().length;
|
|
11360
|
-
|
|
11422
|
+
const sel = this.columns.getColumn(SELECT_COL_ID) ? this.selectionBlocks() : null;
|
|
11423
|
+
if (this.spanCache && this.spanCache.rows === rows && this.spanCache.ver === ver && this.spanCache.sel === sel) return this.spanCache.spans;
|
|
11361
11424
|
const spans = /* @__PURE__ */ new Map();
|
|
11362
11425
|
const merged = this.columns.displayed().filter((c) => c.def.merge || c.def.rowSpan);
|
|
11363
11426
|
if (merged.length && !rows.some((n) => n.kind)) {
|
|
11364
11427
|
const data = rows.map((n) => n.data);
|
|
11365
11428
|
for (const c of merged) spans.set(c.id, computeSpans(data, c.def));
|
|
11429
|
+
if (sel) {
|
|
11430
|
+
const n = rows.length, start = new Int32Array(n), end = new Int32Array(n);
|
|
11431
|
+
for (let i = 0; i < n; i++) {
|
|
11432
|
+
const g = sel.index.get(rows[i].id) ?? -1;
|
|
11433
|
+
start[i] = g < 0 ? i : Math.max(0, i - (g - sel.spans.start[g]));
|
|
11434
|
+
end[i] = g < 0 ? i : Math.min(n - 1, i + (sel.spans.end[g] - g));
|
|
11435
|
+
}
|
|
11436
|
+
spans.set(SELECT_COL_ID, { start, end });
|
|
11437
|
+
}
|
|
11366
11438
|
}
|
|
11367
|
-
this.spanCache = { rows, ver, spans };
|
|
11439
|
+
this.spanCache = { rows, ver, sel, spans };
|
|
11368
11440
|
return spans;
|
|
11369
11441
|
}
|
|
11442
|
+
validMergeSelection(v) {
|
|
11443
|
+
if (v === void 0 || v === null || v === "rows") return "rows";
|
|
11444
|
+
if (typeof v === "number" && Number.isInteger(v) && v >= 1) return v;
|
|
11445
|
+
warn("mergeSelection must be 'rows' or a whole number from 1; one checkbox per row is used");
|
|
11446
|
+
return "rows";
|
|
11447
|
+
}
|
|
11448
|
+
setMergeSelection(level) {
|
|
11449
|
+
const next = this.validMergeSelection(level);
|
|
11450
|
+
if (next === this.mergeSel) return;
|
|
11451
|
+
this.mergeSel = next;
|
|
11452
|
+
this.renderer.invalidate({ rows: true });
|
|
11453
|
+
}
|
|
11454
|
+
getMergeSelection() {
|
|
11455
|
+
return this.mergeSel;
|
|
11456
|
+
}
|
|
11457
|
+
/** The displayed merge columns that make the levels of `mergeSelection`, left to right. */
|
|
11458
|
+
mergeLevelColumns() {
|
|
11459
|
+
return this.columns.displayed().filter((c) => c.def.merge && !c.def.rowSpan && !isSystemCol(c.id));
|
|
11460
|
+
}
|
|
11461
|
+
/** Merge level whose blocks are checked together; 0 = one checkbox per row. */
|
|
11462
|
+
mergeSelectionLevel() {
|
|
11463
|
+
if (this.mergeSel === "rows") return 0;
|
|
11464
|
+
if (!this.options.rowSelection) {
|
|
11465
|
+
warn("mergeSelection needs rowSelection 'multiple' or 'single'");
|
|
11466
|
+
return 0;
|
|
11467
|
+
}
|
|
11468
|
+
if (!this.paid) return 0;
|
|
11469
|
+
if (this.rowModel.server || this.pivotCfg || this.options.treeData || this.groupBy.length) {
|
|
11470
|
+
warn("mergeSelection is ignored while rows are grouped, pivoted, shown as a tree or loaded from a datasource: one checkbox per row");
|
|
11471
|
+
return 0;
|
|
11472
|
+
}
|
|
11473
|
+
const m = this.mergeLevelColumns().length;
|
|
11474
|
+
if (!m) return 0;
|
|
11475
|
+
if (this.mergeSel > m) {
|
|
11476
|
+
warn(`mergeSelection: level ${this.mergeSel} asked for, but only ${m} merge column${m > 1 ? "s are" : " is"} shown; level ${m} is used`);
|
|
11477
|
+
return m;
|
|
11478
|
+
}
|
|
11479
|
+
return this.mergeSel;
|
|
11480
|
+
}
|
|
11481
|
+
/** Blocks of the selection level over every filtered, sorted row (not only the page); null for one checkbox per row. */
|
|
11482
|
+
selectionBlocks() {
|
|
11483
|
+
const level = this.mergeSelectionLevel();
|
|
11484
|
+
if (!level) return null;
|
|
11485
|
+
const rows = this.rowModel.dataRows(), disp = this.rowModel.rows();
|
|
11486
|
+
const cols = this.mergeLevelColumns().slice(0, level);
|
|
11487
|
+
const key = `${level}|${this.editVersion}|${cols.map((c2) => c2.id).join("")}`;
|
|
11488
|
+
const c = this.selBlockCache;
|
|
11489
|
+
if (c && c.rows === rows && c.disp === disp && c.key === key) return c.blocks;
|
|
11490
|
+
let blocks = null;
|
|
11491
|
+
if (!disp.some((n) => n.kind)) {
|
|
11492
|
+
const data = rows.map((n) => n.data);
|
|
11493
|
+
blocks = {
|
|
11494
|
+
level,
|
|
11495
|
+
cols,
|
|
11496
|
+
spans: nestedSpans(cols.map((col) => computeSpans(data, col.def)), rows.length),
|
|
11497
|
+
index: new Map(rows.map((n, i) => [n.id, i]))
|
|
11498
|
+
};
|
|
11499
|
+
}
|
|
11500
|
+
this.selBlockCache = { rows, disp, key, blocks };
|
|
11501
|
+
return blocks;
|
|
11502
|
+
}
|
|
11503
|
+
/** Checkbox of the block holding display row i: all, some or none of its selectable rows selected, or 'off' (none selectable). Null without block checkboxes. */
|
|
11504
|
+
blockSelection(i) {
|
|
11505
|
+
const sb = this.selectionBlocks();
|
|
11506
|
+
const node = sb && this.rowModel.getRow(i);
|
|
11507
|
+
const g = node ? sb.index.get(node.id) : void 0;
|
|
11508
|
+
if (!sb || g === void 0) return null;
|
|
11509
|
+
const sel = this.store.state.selected;
|
|
11510
|
+
let c = this.blockStateCache;
|
|
11511
|
+
if (!c || c.sel !== sel || c.blocks !== sb || c.ver !== this.editVersion) c = this.blockStateCache = { sel, blocks: sb, ver: this.editVersion, map: /* @__PURE__ */ new Map() };
|
|
11512
|
+
const a = sb.spans.start[g];
|
|
11513
|
+
let state = c.map.get(a);
|
|
11514
|
+
if (state === void 0) {
|
|
11515
|
+
const rows = this.rowModel.dataRows();
|
|
11516
|
+
let able = 0, on = 0;
|
|
11517
|
+
for (let k = a; k <= sb.spans.end[a]; k++) {
|
|
11518
|
+
if (!this.rowSelectable(rows[k].data)) continue;
|
|
11519
|
+
able++;
|
|
11520
|
+
if (sel.has(rows[k].id)) on++;
|
|
11521
|
+
}
|
|
11522
|
+
state = !able ? "off" : on === 0 ? "none" : on === able ? "all" : "some";
|
|
11523
|
+
c.map.set(a, state);
|
|
11524
|
+
}
|
|
11525
|
+
return state;
|
|
11526
|
+
}
|
|
11527
|
+
/** Selectable row ids from position a to b (inclusive) of the filtered rows. */
|
|
11528
|
+
blockIds(a, b) {
|
|
11529
|
+
const rows = this.rowModel.dataRows(), out = [];
|
|
11530
|
+
for (let k = a; k <= b; k++) if (this.rowSelectable(rows[k].data)) out.push(rows[k].id);
|
|
11531
|
+
return out;
|
|
11532
|
+
}
|
|
11533
|
+
/** selectFromClick with block checkboxes: the clicked row's whole block (Shift: every block from the anchor's). */
|
|
11534
|
+
selectBlockFromClick(sb, index, toggle, range) {
|
|
11535
|
+
const mode = this.options.rowSelection;
|
|
11536
|
+
const g = sb.index.get(this.rowModel.getRow(index).id);
|
|
11537
|
+
if (g === void 0) return;
|
|
11538
|
+
const { start, end } = sb.spans;
|
|
11539
|
+
const a = start[g], b = end[g];
|
|
11540
|
+
const ids = this.blockIds(a, b);
|
|
11541
|
+
if (!ids.length) return;
|
|
11542
|
+
const cur = this.store.state.selected;
|
|
11543
|
+
const anchorId = this.rowModel.dataRows()[a].id;
|
|
11544
|
+
if (mode === "single") {
|
|
11545
|
+
const all2 = ids.every((id) => cur.has(id));
|
|
11546
|
+
this.setSelected(toggle && all2 ? /* @__PURE__ */ new Set() : new Set(ids), anchorId);
|
|
11547
|
+
return;
|
|
11548
|
+
}
|
|
11549
|
+
const ag = this.store.state.anchorId == null ? void 0 : sb.index.get(this.store.state.anchorId);
|
|
11550
|
+
if (range && ag !== void 0) {
|
|
11551
|
+
const next = toggle ? new Set(cur) : /* @__PURE__ */ new Set();
|
|
11552
|
+
for (const id of this.blockIds(Math.min(start[ag], a), Math.max(end[ag], b))) next.add(id);
|
|
11553
|
+
this.setSelected(next);
|
|
11554
|
+
return;
|
|
11555
|
+
}
|
|
11556
|
+
if (toggle) {
|
|
11557
|
+
const next = new Set(cur);
|
|
11558
|
+
const all2 = ids.every((id) => next.has(id));
|
|
11559
|
+
for (const id of ids) all2 ? next.delete(id) : next.add(id);
|
|
11560
|
+
this.setSelected(next, anchorId);
|
|
11561
|
+
return;
|
|
11562
|
+
}
|
|
11563
|
+
this.setSelected(new Set(ids), anchorId);
|
|
11564
|
+
}
|
|
11565
|
+
/**
|
|
11566
|
+
* getSelectedGroups: blocks holding selected rows, in display order, with their merge values and selected rows.
|
|
11567
|
+
* allRows: every row of those blocks that passes the filters, selected or not (getSelectedGroupsAllRows).
|
|
11568
|
+
*/
|
|
11569
|
+
selectedGroups(allRows = false) {
|
|
11570
|
+
const sb = this.selectionBlocks();
|
|
11571
|
+
const sel = this.store.state.selected;
|
|
11572
|
+
if (!sb || !sel.size) return [];
|
|
11573
|
+
const rows = this.rowModel.dataRows(), out = [];
|
|
11574
|
+
for (let a = 0; a < rows.length; a = sb.spans.end[a] + 1) {
|
|
11575
|
+
const picked = [];
|
|
11576
|
+
let any = false;
|
|
11577
|
+
for (let k = a; k <= sb.spans.end[a]; k++) {
|
|
11578
|
+
const on = sel.has(rows[k].id);
|
|
11579
|
+
any || (any = on);
|
|
11580
|
+
if (on || allRows) picked.push(rows[k].data);
|
|
11581
|
+
}
|
|
11582
|
+
if (!any) continue;
|
|
11583
|
+
const values = {};
|
|
11584
|
+
for (const c of sb.cols) values[c.def.field ?? c.id] = getCellValue(c.def, rows[a].data);
|
|
11585
|
+
out.push({ level: sb.level, values, rows: picked });
|
|
11586
|
+
}
|
|
11587
|
+
return out;
|
|
11588
|
+
}
|
|
11370
11589
|
rangeAggregates() {
|
|
11371
11590
|
const all2 = this.allRangeBounds();
|
|
11372
11591
|
if (!all2.length || !this.paid) return null;
|
|
@@ -11802,7 +12021,13 @@ var Grid = class {
|
|
|
11802
12021
|
const mode = this.options.rowSelection;
|
|
11803
12022
|
if (!mode || index < 0 || index >= this.rowModel.getRowCount()) return;
|
|
11804
12023
|
const target = this.rowModel.getRow(index);
|
|
11805
|
-
if (target.kind
|
|
12024
|
+
if (target.kind) return;
|
|
12025
|
+
const blocks = this.selectionBlocks();
|
|
12026
|
+
if (blocks) {
|
|
12027
|
+
this.selectBlockFromClick(blocks, index, toggle, range);
|
|
12028
|
+
return;
|
|
12029
|
+
}
|
|
12030
|
+
if (!this.rowSelectable(target.data)) return;
|
|
11806
12031
|
const r = nextSelection({
|
|
11807
12032
|
selected: this.store.state.selected,
|
|
11808
12033
|
anchorIndex: this.anchorIndex(),
|
|
@@ -11992,6 +12217,10 @@ var Grid = class {
|
|
|
11992
12217
|
getDensity: guard(() => this.density),
|
|
11993
12218
|
setSortWithinMerges: guard((on) => this.setSortWithinMerges(on)),
|
|
11994
12219
|
getSortWithinMerges: guard(() => this.sortWithin),
|
|
12220
|
+
setMergeSelection: guard((level) => this.setMergeSelection(level)),
|
|
12221
|
+
getMergeSelection: guard(() => this.getMergeSelection()),
|
|
12222
|
+
getSelectedGroups: guard(() => this.selectedGroups()),
|
|
12223
|
+
getSelectedGroupsAllRows: guard(() => this.selectedGroups(true)),
|
|
11995
12224
|
showOverlay: guard((kind) => {
|
|
11996
12225
|
this.forcedOverlay = kind === "loading" || kind === "noRows" ? kind : null;
|
|
11997
12226
|
this.renderer.invalidate();
|
package/dist/locales/de.d.ts
CHANGED
package/dist/locales/en.d.ts
CHANGED
package/dist/locales/es.d.ts
CHANGED
package/dist/locales/fr.d.ts
CHANGED
package/dist/locales/id.d.ts
CHANGED
package/dist/locales/it.d.ts
CHANGED
package/dist/locales/ja.d.ts
CHANGED
package/dist/locales/ko.d.ts
CHANGED
package/dist/locales/pt-BR.d.ts
CHANGED
package/dist/locales/ru.d.ts
CHANGED
package/dist/locales/th.d.ts
CHANGED
package/dist/locales/vi.d.ts
CHANGED
package/dist/locales/zh-CN.d.ts
CHANGED
package/dist/locales/zh-TW.d.ts
CHANGED