@pretable/core 0.0.2 → 0.0.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/index.cjs +985 -113
- package/dist/index.d.cts +200 -13
- package/dist/index.d.ts +200 -13
- package/dist/index.mjs +985 -113
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -33,7 +33,277 @@ function autosizeColumns(input) {
|
|
|
33
33
|
return { widths };
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
// ../grid-core/dist/
|
|
36
|
+
// ../grid-core/dist/evaluate-filter.js
|
|
37
|
+
var NO_OPERAND = /* @__PURE__ */ new Set([
|
|
38
|
+
"isEmpty",
|
|
39
|
+
"isNotEmpty"
|
|
40
|
+
]);
|
|
41
|
+
function isFilterActive(filter) {
|
|
42
|
+
const { operator, value } = filter;
|
|
43
|
+
if (NO_OPERAND.has(operator))
|
|
44
|
+
return true;
|
|
45
|
+
if (value === null || value === void 0)
|
|
46
|
+
return false;
|
|
47
|
+
if (typeof value === "string")
|
|
48
|
+
return value.trim() !== "";
|
|
49
|
+
if (Array.isArray(value))
|
|
50
|
+
return value.length > 0;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
function isEmptyCell(cell) {
|
|
54
|
+
if (cell === null || cell === void 0)
|
|
55
|
+
return true;
|
|
56
|
+
if (typeof cell === "number")
|
|
57
|
+
return Number.isNaN(cell);
|
|
58
|
+
return String(cell).trim() === "";
|
|
59
|
+
}
|
|
60
|
+
function toBooleanCell(value) {
|
|
61
|
+
if (typeof value === "boolean")
|
|
62
|
+
return value;
|
|
63
|
+
if (value === "true" || value === 1 || value === "1")
|
|
64
|
+
return true;
|
|
65
|
+
if (value === "false" || value === 0 || value === "0")
|
|
66
|
+
return false;
|
|
67
|
+
return Boolean(value);
|
|
68
|
+
}
|
|
69
|
+
var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
70
|
+
var ISO_DATETIME_RE = /^(\d{4}-\d{2}-\d{2})[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?$/i;
|
|
71
|
+
var MAX_ISO_YEAR = 9999;
|
|
72
|
+
var GREGORIAN_400Y_MS = 146097 * 864e5;
|
|
73
|
+
function utcMs(year, month, day) {
|
|
74
|
+
return year >= 0 && year < 100 ? Date.UTC(year + 400, month, day) - GREGORIAN_400Y_MS : Date.UTC(year, month, day);
|
|
75
|
+
}
|
|
76
|
+
function utcDayOf(ms) {
|
|
77
|
+
const d = new Date(ms);
|
|
78
|
+
if (Number.isNaN(d.getTime()))
|
|
79
|
+
return Number.NaN;
|
|
80
|
+
const year = d.getUTCFullYear();
|
|
81
|
+
if (year < 0 || year > MAX_ISO_YEAR)
|
|
82
|
+
return Number.NaN;
|
|
83
|
+
d.setUTCHours(0, 0, 0, 0);
|
|
84
|
+
return d.getTime();
|
|
85
|
+
}
|
|
86
|
+
function isoDayMs(iso) {
|
|
87
|
+
if (!ISO_DATE_RE.test(iso))
|
|
88
|
+
return Number.NaN;
|
|
89
|
+
const [y, m, d] = iso.split("-").map(Number);
|
|
90
|
+
const ms = utcMs(y, m - 1, d);
|
|
91
|
+
const back = new Date(ms);
|
|
92
|
+
return back.getUTCFullYear() === y && back.getUTCMonth() === m - 1 && back.getUTCDate() === d ? ms : Number.NaN;
|
|
93
|
+
}
|
|
94
|
+
function toDayMs(input) {
|
|
95
|
+
if (input instanceof Date)
|
|
96
|
+
return utcDayOf(input.getTime());
|
|
97
|
+
if (typeof input === "number")
|
|
98
|
+
return utcDayOf(input);
|
|
99
|
+
if (typeof input !== "string")
|
|
100
|
+
return Number.NaN;
|
|
101
|
+
const trimmed = input.trim();
|
|
102
|
+
const dateOnly = isoDayMs(trimmed);
|
|
103
|
+
if (!Number.isNaN(dateOnly))
|
|
104
|
+
return dateOnly;
|
|
105
|
+
const parts = ISO_DATETIME_RE.exec(trimmed);
|
|
106
|
+
if (!parts)
|
|
107
|
+
return Number.NaN;
|
|
108
|
+
const day = isoDayMs(parts[1]);
|
|
109
|
+
if (Number.isNaN(day))
|
|
110
|
+
return Number.NaN;
|
|
111
|
+
return parts[2] ? utcDayOf(Date.parse(trimmed.replace(" ", "T"))) : day;
|
|
112
|
+
}
|
|
113
|
+
function evaluateFilter(cell, type, operator, value) {
|
|
114
|
+
if (operator === "isEmpty")
|
|
115
|
+
return isEmptyCell(cell);
|
|
116
|
+
if (operator === "isNotEmpty")
|
|
117
|
+
return !isEmptyCell(cell);
|
|
118
|
+
switch (type) {
|
|
119
|
+
case "number": {
|
|
120
|
+
const n = typeof cell === "number" ? cell : Number(cell);
|
|
121
|
+
if (Number.isNaN(n))
|
|
122
|
+
return false;
|
|
123
|
+
switch (operator) {
|
|
124
|
+
case "equals":
|
|
125
|
+
return n === Number(value);
|
|
126
|
+
case "notEquals":
|
|
127
|
+
return n !== Number(value);
|
|
128
|
+
case "gt":
|
|
129
|
+
return n > Number(value);
|
|
130
|
+
case "gte":
|
|
131
|
+
return n >= Number(value);
|
|
132
|
+
case "lt":
|
|
133
|
+
return n < Number(value);
|
|
134
|
+
case "lte":
|
|
135
|
+
return n <= Number(value);
|
|
136
|
+
case "between": {
|
|
137
|
+
if (!Array.isArray(value))
|
|
138
|
+
return false;
|
|
139
|
+
const a = Number(value[0]);
|
|
140
|
+
const b = Number(value[1]);
|
|
141
|
+
const lo = Math.min(a, b);
|
|
142
|
+
const hi = Math.max(a, b);
|
|
143
|
+
return n >= lo && n <= hi;
|
|
144
|
+
}
|
|
145
|
+
default:
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
case "date": {
|
|
150
|
+
const c = toDayMs(cell);
|
|
151
|
+
if (Number.isNaN(c))
|
|
152
|
+
return false;
|
|
153
|
+
switch (operator) {
|
|
154
|
+
case "on":
|
|
155
|
+
return c === toDayMs(value);
|
|
156
|
+
case "before":
|
|
157
|
+
return c < toDayMs(value);
|
|
158
|
+
case "after":
|
|
159
|
+
return c > toDayMs(value);
|
|
160
|
+
case "dateBetween": {
|
|
161
|
+
if (!Array.isArray(value))
|
|
162
|
+
return false;
|
|
163
|
+
const a = toDayMs(value[0]);
|
|
164
|
+
const b = toDayMs(value[1]);
|
|
165
|
+
if (Number.isNaN(a) || Number.isNaN(b))
|
|
166
|
+
return false;
|
|
167
|
+
const lo = Math.min(a, b);
|
|
168
|
+
const hi = Math.max(a, b);
|
|
169
|
+
return c >= lo && c <= hi;
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
case "boolean": {
|
|
176
|
+
const c = String(toBooleanCell(cell));
|
|
177
|
+
const set = Array.isArray(value) ? value.map(String) : [];
|
|
178
|
+
if (set.length === 0)
|
|
179
|
+
return true;
|
|
180
|
+
switch (operator) {
|
|
181
|
+
case "isAnyOf":
|
|
182
|
+
return set.includes(c);
|
|
183
|
+
case "isNoneOf":
|
|
184
|
+
return !set.includes(c);
|
|
185
|
+
default:
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
case "enum": {
|
|
190
|
+
const c = String(cell);
|
|
191
|
+
const set = Array.isArray(value) ? value.map(String) : [];
|
|
192
|
+
if (set.length === 0)
|
|
193
|
+
return true;
|
|
194
|
+
switch (operator) {
|
|
195
|
+
case "isAnyOf":
|
|
196
|
+
return set.includes(c);
|
|
197
|
+
case "isNoneOf":
|
|
198
|
+
return !set.includes(c);
|
|
199
|
+
default:
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
case "text":
|
|
204
|
+
default: {
|
|
205
|
+
const hay = String(cell ?? "").toLowerCase();
|
|
206
|
+
const needle = String(value ?? "").toLowerCase();
|
|
207
|
+
switch (operator) {
|
|
208
|
+
case "contains":
|
|
209
|
+
return hay.includes(needle);
|
|
210
|
+
case "notContains":
|
|
211
|
+
return !hay.includes(needle);
|
|
212
|
+
case "equals":
|
|
213
|
+
return hay === needle;
|
|
214
|
+
case "notEquals":
|
|
215
|
+
return hay !== needle;
|
|
216
|
+
case "startsWith":
|
|
217
|
+
return hay.startsWith(needle);
|
|
218
|
+
case "endsWith":
|
|
219
|
+
return hay.endsWith(needle);
|
|
220
|
+
default:
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ../grid-core/dist/aggregators.js
|
|
228
|
+
function isAggregatableNumber(value) {
|
|
229
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
230
|
+
}
|
|
231
|
+
var sum = {
|
|
232
|
+
init: () => ({ sum: 0, count: 0 }),
|
|
233
|
+
accumulate(acc, value) {
|
|
234
|
+
if (!isAggregatableNumber(value))
|
|
235
|
+
return acc;
|
|
236
|
+
acc.sum += value;
|
|
237
|
+
acc.count += 1;
|
|
238
|
+
return acc;
|
|
239
|
+
},
|
|
240
|
+
merge: (a, b) => ({ sum: a.sum + b.sum, count: a.count + b.count }),
|
|
241
|
+
finalize: (acc) => acc.count === 0 ? null : acc.sum
|
|
242
|
+
};
|
|
243
|
+
var avg = {
|
|
244
|
+
init: () => ({ sum: 0, count: 0 }),
|
|
245
|
+
accumulate: sum.accumulate,
|
|
246
|
+
merge: sum.merge,
|
|
247
|
+
finalize: (acc) => acc.count === 0 ? null : acc.sum / acc.count
|
|
248
|
+
};
|
|
249
|
+
var min = {
|
|
250
|
+
init: () => ({ value: null }),
|
|
251
|
+
accumulate(acc, value) {
|
|
252
|
+
if (!isAggregatableNumber(value))
|
|
253
|
+
return acc;
|
|
254
|
+
if (acc.value === null || value < acc.value)
|
|
255
|
+
acc.value = value;
|
|
256
|
+
return acc;
|
|
257
|
+
},
|
|
258
|
+
merge: (a, b) => ({
|
|
259
|
+
value: a.value === null ? b.value : b.value === null ? a.value : Math.min(a.value, b.value)
|
|
260
|
+
}),
|
|
261
|
+
finalize: (acc) => acc.value
|
|
262
|
+
};
|
|
263
|
+
var max = {
|
|
264
|
+
init: () => ({ value: null }),
|
|
265
|
+
accumulate(acc, value) {
|
|
266
|
+
if (!isAggregatableNumber(value))
|
|
267
|
+
return acc;
|
|
268
|
+
if (acc.value === null || value > acc.value)
|
|
269
|
+
acc.value = value;
|
|
270
|
+
return acc;
|
|
271
|
+
},
|
|
272
|
+
merge: (a, b) => ({
|
|
273
|
+
value: a.value === null ? b.value : b.value === null ? a.value : Math.max(a.value, b.value)
|
|
274
|
+
}),
|
|
275
|
+
finalize: (acc) => acc.value
|
|
276
|
+
};
|
|
277
|
+
var count = {
|
|
278
|
+
init: () => ({ count: 0 }),
|
|
279
|
+
accumulate(acc) {
|
|
280
|
+
acc.count += 1;
|
|
281
|
+
return acc;
|
|
282
|
+
},
|
|
283
|
+
merge: (a, b) => ({ count: a.count + b.count }),
|
|
284
|
+
// `0` is arguably count's identity, unlike sum/min/max where "no numeric
|
|
285
|
+
// values seen" has no honest number. We still return `null`, for consistency
|
|
286
|
+
// with the other built-ins and because it is unreachable for a real group —
|
|
287
|
+
// a group only exists because at least one row landed in it.
|
|
288
|
+
finalize: (acc) => acc.count === 0 ? null : acc.count
|
|
289
|
+
};
|
|
290
|
+
var builtinAggregators = {
|
|
291
|
+
sum,
|
|
292
|
+
avg,
|
|
293
|
+
min,
|
|
294
|
+
max,
|
|
295
|
+
count
|
|
296
|
+
};
|
|
297
|
+
function resolveAggregator(spec) {
|
|
298
|
+
if (spec === void 0 || spec === null)
|
|
299
|
+
return null;
|
|
300
|
+
if (typeof spec === "string") {
|
|
301
|
+
return builtinAggregators[spec] ?? null;
|
|
302
|
+
}
|
|
303
|
+
return spec;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// ../grid-core/dist/row-utils.js
|
|
37
307
|
function createSourceRows(options) {
|
|
38
308
|
return options.rows.map((row, index) => ({
|
|
39
309
|
id: options.getRowId?.(row, index) ?? String(index),
|
|
@@ -41,82 +311,314 @@ function createSourceRows(options) {
|
|
|
41
311
|
sourceIndex: index
|
|
42
312
|
}));
|
|
43
313
|
}
|
|
314
|
+
var collator = new Intl.Collator(void 0, {
|
|
315
|
+
numeric: true,
|
|
316
|
+
sensitivity: "base"
|
|
317
|
+
});
|
|
318
|
+
function sortRows(rows, columns, sort) {
|
|
319
|
+
const keys = sort.map((entry) => {
|
|
320
|
+
const column = columns.find((c) => c.id === entry.columnId);
|
|
321
|
+
if (!column)
|
|
322
|
+
return null;
|
|
323
|
+
const rawKeys = rows.map((r) => readCellValue(r.row, column));
|
|
324
|
+
const allNumeric = rawKeys.every((v) => typeof v === "number");
|
|
325
|
+
const multiplier = entry.direction === "asc" ? 1 : -1;
|
|
326
|
+
return allNumeric ? { kind: "num", keys: rawKeys, multiplier } : {
|
|
327
|
+
kind: "str",
|
|
328
|
+
keys: rawKeys.map((v) => String(v ?? "")),
|
|
329
|
+
multiplier
|
|
330
|
+
};
|
|
331
|
+
}).filter((k) => k !== null);
|
|
332
|
+
if (keys.length === 0) {
|
|
333
|
+
return [...rows];
|
|
334
|
+
}
|
|
335
|
+
const indexed = rows.map((_, i) => i);
|
|
336
|
+
indexed.sort((a, b) => {
|
|
337
|
+
for (const key of keys) {
|
|
338
|
+
const cmp = key.kind === "num" ? key.keys[a] - key.keys[b] : collator.compare(key.keys[a], key.keys[b]);
|
|
339
|
+
if (cmp !== 0) {
|
|
340
|
+
return cmp * key.multiplier;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return rows[a].sourceIndex - rows[b].sourceIndex;
|
|
344
|
+
});
|
|
345
|
+
return indexed.map((i) => rows[i]);
|
|
346
|
+
}
|
|
347
|
+
function readCellValue(row, column) {
|
|
348
|
+
return column.value ? column.value(row) : row[column.id];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// ../grid-core/dist/group-id.js
|
|
352
|
+
var GROUP_ID_PREFIX = "__group__:";
|
|
353
|
+
var LEVEL_SEPARATOR = "/";
|
|
354
|
+
var KEY_SEPARATOR = "=";
|
|
355
|
+
function escapeGroupKey(raw) {
|
|
356
|
+
return raw.replace(/%/g, "%25").replace(/\//g, "%2F").replace(/=/g, "%3D");
|
|
357
|
+
}
|
|
358
|
+
function stringifyGroupValue(value) {
|
|
359
|
+
if (value === null || value === void 0)
|
|
360
|
+
return "~";
|
|
361
|
+
switch (typeof value) {
|
|
362
|
+
case "string":
|
|
363
|
+
return `s:${value}`;
|
|
364
|
+
case "number":
|
|
365
|
+
return `n:${value}`;
|
|
366
|
+
case "boolean":
|
|
367
|
+
return `b:${value}`;
|
|
368
|
+
case "bigint":
|
|
369
|
+
return `i:${value}`;
|
|
370
|
+
default:
|
|
371
|
+
return `o:${safeToString(value)}`;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function safeToString(value) {
|
|
375
|
+
try {
|
|
376
|
+
return String(value);
|
|
377
|
+
} catch {
|
|
378
|
+
return "[unstringifiable]";
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function makeGroupId(path) {
|
|
382
|
+
let id = GROUP_ID_PREFIX;
|
|
383
|
+
for (let i = 0; i < path.length; i += 1) {
|
|
384
|
+
if (i > 0)
|
|
385
|
+
id += LEVEL_SEPARATOR;
|
|
386
|
+
id += escapeGroupKey(path[i].columnId);
|
|
387
|
+
id += KEY_SEPARATOR;
|
|
388
|
+
id += escapeGroupKey(stringifyGroupValue(path[i].value));
|
|
389
|
+
}
|
|
390
|
+
return id;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// ../grid-core/dist/group-rows.js
|
|
394
|
+
function buildGroupedRows(args) {
|
|
395
|
+
const { rows, allRows, columns, rowGroups, sort } = args;
|
|
396
|
+
const sorted = sortRows(rows, columns, sort);
|
|
397
|
+
const levels = resolveLevels(columns, rowGroups);
|
|
398
|
+
if (levels.length === 0) {
|
|
399
|
+
return sorted.map(({ id, row, sourceIndex }) => ({
|
|
400
|
+
kind: "data",
|
|
401
|
+
id,
|
|
402
|
+
row,
|
|
403
|
+
sourceIndex,
|
|
404
|
+
depth: 0
|
|
405
|
+
}));
|
|
406
|
+
}
|
|
407
|
+
const roots = buildTree(sorted, levels);
|
|
408
|
+
const aggregateColumns = resolveAggregateColumns(columns);
|
|
409
|
+
if (aggregateColumns.length > 0) {
|
|
410
|
+
accumulate(allRows ? sortRows(allRows, columns, sort) : sorted, levels, roots, aggregateColumns);
|
|
411
|
+
}
|
|
412
|
+
const out = [];
|
|
413
|
+
flatten(roots, 0, levels, aggregateColumns, args, out);
|
|
414
|
+
return out;
|
|
415
|
+
}
|
|
416
|
+
function resolveLevels(columns, rowGroups) {
|
|
417
|
+
if (rowGroups.length === 0)
|
|
418
|
+
return [];
|
|
419
|
+
const byId = new Map(columns.map((column) => [column.id, column]));
|
|
420
|
+
const levels = [];
|
|
421
|
+
for (const columnId of rowGroups) {
|
|
422
|
+
const column = byId.get(columnId);
|
|
423
|
+
if (column)
|
|
424
|
+
levels.push(column);
|
|
425
|
+
}
|
|
426
|
+
return levels;
|
|
427
|
+
}
|
|
428
|
+
function resolveAggregateColumns(columns) {
|
|
429
|
+
const resolved = [];
|
|
430
|
+
for (const column of columns) {
|
|
431
|
+
const aggregator = resolveAggregator(column.aggregate);
|
|
432
|
+
if (aggregator)
|
|
433
|
+
resolved.push({ column, aggregator });
|
|
434
|
+
}
|
|
435
|
+
return resolved;
|
|
436
|
+
}
|
|
437
|
+
function buildTree(sorted, levels) {
|
|
438
|
+
const roots = /* @__PURE__ */ new Map();
|
|
439
|
+
const lastLevel = levels.length - 1;
|
|
440
|
+
const path = [];
|
|
441
|
+
for (const entry of sorted) {
|
|
442
|
+
let siblings = roots;
|
|
443
|
+
let node;
|
|
444
|
+
path.length = 0;
|
|
445
|
+
for (let depth = 0; depth <= lastLevel; depth += 1) {
|
|
446
|
+
const column = levels[depth];
|
|
447
|
+
const value = readCellValue(entry.row, column);
|
|
448
|
+
const key = stringifyGroupValue(value);
|
|
449
|
+
path.push({ columnId: column.id, value });
|
|
450
|
+
node = siblings.get(key);
|
|
451
|
+
if (!node) {
|
|
452
|
+
const isLeafLevel = depth === lastLevel;
|
|
453
|
+
node = {
|
|
454
|
+
id: makeGroupId(path),
|
|
455
|
+
depth,
|
|
456
|
+
columnId: column.id,
|
|
457
|
+
value,
|
|
458
|
+
childCount: 0,
|
|
459
|
+
children: isLeafLevel ? null : /* @__PURE__ */ new Map(),
|
|
460
|
+
rows: isLeafLevel ? [] : null,
|
|
461
|
+
accumulators: /* @__PURE__ */ new Map()
|
|
462
|
+
};
|
|
463
|
+
siblings.set(key, node);
|
|
464
|
+
}
|
|
465
|
+
node.childCount += 1;
|
|
466
|
+
if (node.children)
|
|
467
|
+
siblings = node.children;
|
|
468
|
+
}
|
|
469
|
+
node?.rows?.push(entry);
|
|
470
|
+
}
|
|
471
|
+
return roots;
|
|
472
|
+
}
|
|
473
|
+
function accumulate(source, levels, roots, aggregateColumns) {
|
|
474
|
+
for (const entry of source) {
|
|
475
|
+
const values = aggregateColumns.map(({ column }) => readCellValue(entry.row, column));
|
|
476
|
+
let siblings = roots;
|
|
477
|
+
for (let depth = 0; depth < levels.length && siblings; depth += 1) {
|
|
478
|
+
const key = stringifyGroupValue(readCellValue(entry.row, levels[depth]));
|
|
479
|
+
const node = siblings.get(key);
|
|
480
|
+
if (!node)
|
|
481
|
+
break;
|
|
482
|
+
for (let i = 0; i < aggregateColumns.length; i += 1) {
|
|
483
|
+
const { column, aggregator } = aggregateColumns[i];
|
|
484
|
+
const previous = node.accumulators.get(column.id);
|
|
485
|
+
const acc = previous === void 0 ? aggregator.init() : previous;
|
|
486
|
+
node.accumulators.set(column.id, aggregator.accumulate(acc, values[i], entry.row));
|
|
487
|
+
}
|
|
488
|
+
siblings = node.children;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
function flatten(siblings, depth, levels, aggregateColumns, args, out) {
|
|
493
|
+
const nodes = [...siblings.values()];
|
|
494
|
+
sortSiblings(nodes, levels[depth], args.sort);
|
|
495
|
+
for (const node of nodes) {
|
|
496
|
+
out.push({
|
|
497
|
+
kind: "group",
|
|
498
|
+
id: node.id,
|
|
499
|
+
depth: node.depth,
|
|
500
|
+
columnId: node.columnId,
|
|
501
|
+
value: node.value,
|
|
502
|
+
childCount: node.childCount,
|
|
503
|
+
aggregates: finalizeAggregates(node, aggregateColumns)
|
|
504
|
+
});
|
|
505
|
+
if (!isExpanded(node.id, args))
|
|
506
|
+
continue;
|
|
507
|
+
if (node.children) {
|
|
508
|
+
flatten(node.children, depth + 1, levels, aggregateColumns, args, out);
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
for (const entry of node.rows ?? []) {
|
|
512
|
+
out.push({
|
|
513
|
+
kind: "data",
|
|
514
|
+
id: entry.id,
|
|
515
|
+
row: entry.row,
|
|
516
|
+
sourceIndex: entry.sourceIndex,
|
|
517
|
+
depth: depth + 1
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function finalizeAggregates(node, aggregateColumns) {
|
|
523
|
+
const aggregates = {};
|
|
524
|
+
for (const { column, aggregator } of aggregateColumns) {
|
|
525
|
+
const acc = node.accumulators.get(column.id);
|
|
526
|
+
aggregates[column.id] = aggregator.finalize(acc === void 0 ? aggregator.init() : acc);
|
|
527
|
+
}
|
|
528
|
+
return aggregates;
|
|
529
|
+
}
|
|
530
|
+
function isExpanded(id, args) {
|
|
531
|
+
return args.groupExpansionOverrides.has(id) ? !args.defaultExpanded : args.defaultExpanded;
|
|
532
|
+
}
|
|
533
|
+
function sortSiblings(nodes, column, sort) {
|
|
534
|
+
if (nodes.length < 2)
|
|
535
|
+
return;
|
|
536
|
+
const entry = column ? sort.find((candidate) => candidate.columnId === column.id) : void 0;
|
|
537
|
+
const multiplier = entry?.direction === "desc" ? -1 : 1;
|
|
538
|
+
const allNumeric = nodes.every((node) => typeof node.value === "number");
|
|
539
|
+
nodes.sort((a, b) => {
|
|
540
|
+
const cmp = allNumeric ? a.value - b.value : collator.compare(String(a.value ?? ""), String(b.value ?? ""));
|
|
541
|
+
return cmp * multiplier;
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// ../grid-core/dist/derived-rows.js
|
|
546
|
+
var NO_OVERRIDES = /* @__PURE__ */ new Set();
|
|
44
547
|
function deriveVisibleRows(input) {
|
|
45
548
|
const resolvedFilters = resolveFilters(input.columns, input.filters);
|
|
46
549
|
const filtered = input.rows.filter((entry) => matchesFilters(entry.row, resolvedFilters));
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
550
|
+
return buildGroupedRows({
|
|
551
|
+
rows: filtered,
|
|
552
|
+
// Only worth carrying the pre-filter set when it can actually differ.
|
|
553
|
+
// Equal lengths mean the filter removed nothing, so `filtered` is a copy of
|
|
554
|
+
// `input.rows` in the same order and the two sort identically —
|
|
555
|
+
// `buildGroupedRows` sorts whichever it folds over, so skipping here does
|
|
556
|
+
// not change the fold order.
|
|
557
|
+
allRows: input.aggregateFilteredRows && filtered.length !== input.rows.length ? input.rows : void 0,
|
|
558
|
+
columns: input.columns,
|
|
559
|
+
rowGroups: input.rowGroups ?? [],
|
|
560
|
+
sort: input.sort,
|
|
561
|
+
groupExpansionOverrides: input.groupExpansionOverrides ?? NO_OVERRIDES,
|
|
562
|
+
defaultExpanded: input.groupsDefaultExpanded ?? true
|
|
563
|
+
});
|
|
53
564
|
}
|
|
54
565
|
function resolveFilters(columns, filters) {
|
|
55
566
|
const columnMap = new Map(columns.map((c) => [c.id, c]));
|
|
56
567
|
const resolved = [];
|
|
57
|
-
for (const [columnId,
|
|
58
|
-
if (!
|
|
568
|
+
for (const [columnId, filter] of Object.entries(filters)) {
|
|
569
|
+
if (!filter || !isFilterActive(filter))
|
|
59
570
|
continue;
|
|
60
|
-
}
|
|
61
571
|
const column = columnMap.get(columnId);
|
|
62
|
-
if (!column)
|
|
572
|
+
if (!column || column.filterable === false)
|
|
63
573
|
continue;
|
|
64
|
-
}
|
|
65
|
-
resolved.push({ column, needle: rawNeedle.toLowerCase() });
|
|
574
|
+
resolved.push({ column, filter });
|
|
66
575
|
}
|
|
67
576
|
return resolved;
|
|
68
577
|
}
|
|
69
578
|
function matchesFilters(row, resolvedFilters) {
|
|
70
|
-
for (const { column,
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
579
|
+
for (const { column, filter } of resolvedFilters) {
|
|
580
|
+
const cell = readCellValue(row, column);
|
|
581
|
+
if (!evaluateFilter(cell, column.type ?? "text", filter.operator, filter.value)) {
|
|
73
582
|
return false;
|
|
74
583
|
}
|
|
75
584
|
}
|
|
76
585
|
return true;
|
|
77
586
|
}
|
|
78
|
-
var collator = new Intl.Collator(void 0, {
|
|
79
|
-
numeric: true,
|
|
80
|
-
sensitivity: "base"
|
|
81
|
-
});
|
|
82
|
-
function sortRows(rows, columns, sort) {
|
|
83
|
-
if (!sort.columnId || !sort.direction) {
|
|
84
|
-
return [...rows];
|
|
85
|
-
}
|
|
86
|
-
const column = columns.find((candidate) => candidate.id === sort.columnId);
|
|
87
|
-
if (!column) {
|
|
88
|
-
return [...rows];
|
|
89
|
-
}
|
|
90
|
-
const multiplier = sort.direction === "asc" ? 1 : -1;
|
|
91
|
-
const rawKeys = rows.map((entry) => readCellValue(entry.row, column));
|
|
92
|
-
const allNumeric = rawKeys.every((v) => typeof v === "number");
|
|
93
|
-
if (allNumeric) {
|
|
94
|
-
const numKeys = rawKeys;
|
|
95
|
-
const indexed2 = rows.map((_, i) => i);
|
|
96
|
-
indexed2.sort((a, b) => {
|
|
97
|
-
const diff = numKeys[a] - numKeys[b];
|
|
98
|
-
return diff !== 0 ? diff * multiplier : rows[a].sourceIndex - rows[b].sourceIndex;
|
|
99
|
-
});
|
|
100
|
-
return indexed2.map((i) => rows[i]);
|
|
101
|
-
}
|
|
102
|
-
const strKeys = rawKeys.map((v) => String(v ?? ""));
|
|
103
|
-
const indexed = rows.map((_, i) => i);
|
|
104
|
-
indexed.sort((a, b) => {
|
|
105
|
-
const comparison = collator.compare(strKeys[a], strKeys[b]);
|
|
106
|
-
return comparison !== 0 ? comparison * multiplier : rows[a].sourceIndex - rows[b].sourceIndex;
|
|
107
|
-
});
|
|
108
|
-
return indexed.map((i) => rows[i]);
|
|
109
|
-
}
|
|
110
|
-
function readCellValue(row, column) {
|
|
111
|
-
return column.value ? column.value(row) : row[column.id];
|
|
112
|
-
}
|
|
113
587
|
|
|
114
588
|
// ../grid-core/dist/create-grid-core.js
|
|
115
589
|
var ROW_SELECT_COLUMN_ID = "__pretable_row_select__";
|
|
590
|
+
function isDataRow(entry) {
|
|
591
|
+
return entry.kind === "data";
|
|
592
|
+
}
|
|
593
|
+
function scanDataRows(rows, rowId) {
|
|
594
|
+
let count2 = 0;
|
|
595
|
+
let index = -1;
|
|
596
|
+
for (const entry of rows) {
|
|
597
|
+
if (!isDataRow(entry))
|
|
598
|
+
continue;
|
|
599
|
+
if (rowId !== null && entry.id === rowId)
|
|
600
|
+
index = count2;
|
|
601
|
+
count2 += 1;
|
|
602
|
+
}
|
|
603
|
+
return { count: count2, index };
|
|
604
|
+
}
|
|
605
|
+
function dataRowAt(rows, ordinal) {
|
|
606
|
+
if (ordinal < 0)
|
|
607
|
+
return void 0;
|
|
608
|
+
let seen = 0;
|
|
609
|
+
for (const entry of rows) {
|
|
610
|
+
if (!isDataRow(entry))
|
|
611
|
+
continue;
|
|
612
|
+
if (seen === ordinal)
|
|
613
|
+
return entry;
|
|
614
|
+
seen += 1;
|
|
615
|
+
}
|
|
616
|
+
return void 0;
|
|
617
|
+
}
|
|
116
618
|
function clampColumnWidth(width, column) {
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
return Math.max(
|
|
619
|
+
const min2 = column.minWidthPx ?? 40;
|
|
620
|
+
const max2 = column.maxWidthPx ?? Infinity;
|
|
621
|
+
return Math.max(min2, Math.min(max2, width));
|
|
120
622
|
}
|
|
121
623
|
function applyAutosize(options, autosizeOptions) {
|
|
122
624
|
const result = autosizeColumns({
|
|
@@ -136,20 +638,48 @@ function applyAutosize(options, autosizeOptions) {
|
|
|
136
638
|
});
|
|
137
639
|
return { ...options, columns: nextColumns };
|
|
138
640
|
}
|
|
641
|
+
function groupColumnsByPin(columns) {
|
|
642
|
+
const left = [];
|
|
643
|
+
const unpinned = [];
|
|
644
|
+
const right = [];
|
|
645
|
+
for (const column of columns) {
|
|
646
|
+
const region = column.pinned === "left" ? left : column.pinned === "right" ? right : unpinned;
|
|
647
|
+
if (column.id === ROW_SELECT_COLUMN_ID) {
|
|
648
|
+
region.unshift(column);
|
|
649
|
+
} else {
|
|
650
|
+
region.push(column);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return [...left, ...unpinned, ...right];
|
|
654
|
+
}
|
|
139
655
|
function createGridCore(inputOptions) {
|
|
140
656
|
const listeners = /* @__PURE__ */ new Set();
|
|
141
|
-
|
|
142
|
-
|
|
657
|
+
const groupedInput = {
|
|
658
|
+
...inputOptions,
|
|
659
|
+
columns: groupColumnsByPin(inputOptions.columns)
|
|
660
|
+
};
|
|
661
|
+
let options = groupedInput.autosize ? applyAutosize(groupedInput, typeof groupedInput.autosize === "object" ? groupedInput.autosize : void 0) : groupedInput;
|
|
662
|
+
let originalColumns = groupColumnsByPin(inputOptions.columns).map((c) => ({ ...c }));
|
|
143
663
|
let sourceRows = createSourceRows(options);
|
|
144
664
|
const sourceRowIndex = new Map(sourceRows.map((entry) => [entry.id, entry]));
|
|
665
|
+
const pinnedWidthColumnIds = /* @__PURE__ */ new Set();
|
|
145
666
|
let cachedSnapshot = null;
|
|
146
667
|
let cachedVisibleRows = null;
|
|
147
668
|
let cachedDerivedSort = null;
|
|
148
669
|
let cachedDerivedFilters = null;
|
|
149
|
-
let
|
|
670
|
+
let cachedDerivedRowGroups = null;
|
|
671
|
+
let cachedDerivedOverrides = null;
|
|
672
|
+
let cachedDerivedDefaultExpanded = null;
|
|
673
|
+
let cachedDerivedAggregateFiltered = null;
|
|
674
|
+
let sort = [];
|
|
150
675
|
let filters = {};
|
|
676
|
+
let rowGroups = sanitizeRowGroups(options.columns.filter((column) => column.rowGroup === true).map((c) => c.id), options.columns);
|
|
677
|
+
let groupExpansionOverrides = /* @__PURE__ */ new Set();
|
|
678
|
+
let groupsDefaultExpanded = options.groupsDefaultExpanded ?? true;
|
|
679
|
+
let previousAggregates = /* @__PURE__ */ new Map();
|
|
151
680
|
let selection = { ranges: [], anchor: null };
|
|
152
681
|
let focus = { rowId: null, columnId: null };
|
|
682
|
+
let editing = null;
|
|
153
683
|
let viewport = {
|
|
154
684
|
scrollTop: 0,
|
|
155
685
|
scrollLeft: 0,
|
|
@@ -168,22 +698,31 @@ function createGridCore(inputOptions) {
|
|
|
168
698
|
},
|
|
169
699
|
getSnapshot,
|
|
170
700
|
setSort(columnId, direction) {
|
|
171
|
-
|
|
701
|
+
const candidate = columnId && direction ? [{ columnId, direction }] : [];
|
|
702
|
+
const next = sanitizeSortEntries(candidate, options.columns);
|
|
703
|
+
if (sortsEqual(sort, next)) {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
sort = next;
|
|
707
|
+
emit();
|
|
708
|
+
},
|
|
709
|
+
replaceSort(entries) {
|
|
710
|
+
const next = sanitizeSortEntries(entries, options.columns);
|
|
711
|
+
if (sortsEqual(sort, next)) {
|
|
172
712
|
return;
|
|
173
713
|
}
|
|
174
|
-
sort =
|
|
714
|
+
sort = next;
|
|
175
715
|
emit();
|
|
176
716
|
},
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (currentValue === trimmed) {
|
|
717
|
+
setColumnFilter(columnId, filter) {
|
|
718
|
+
const current = filters[columnId];
|
|
719
|
+
if (filter && isFilterActive(filter)) {
|
|
720
|
+
if (current && columnFilterEqual(current, filter)) {
|
|
182
721
|
return;
|
|
183
722
|
}
|
|
184
|
-
filters = { ...filters, [columnId]:
|
|
723
|
+
filters = { ...filters, [columnId]: filter };
|
|
185
724
|
} else {
|
|
186
|
-
if (
|
|
725
|
+
if (current === void 0) {
|
|
187
726
|
return;
|
|
188
727
|
}
|
|
189
728
|
const next = { ...filters };
|
|
@@ -201,10 +740,9 @@ function createGridCore(inputOptions) {
|
|
|
201
740
|
},
|
|
202
741
|
replaceFilters(nextFilters) {
|
|
203
742
|
const normalized = {};
|
|
204
|
-
for (const [columnId,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
normalized[columnId] = trimmed;
|
|
743
|
+
for (const [columnId, filter] of Object.entries(nextFilters)) {
|
|
744
|
+
if (filter && isFilterActive(filter)) {
|
|
745
|
+
normalized[columnId] = filter;
|
|
208
746
|
}
|
|
209
747
|
}
|
|
210
748
|
if (filtersEqual(filters, normalized)) {
|
|
@@ -213,6 +751,25 @@ function createGridCore(inputOptions) {
|
|
|
213
751
|
filters = normalized;
|
|
214
752
|
emit();
|
|
215
753
|
},
|
|
754
|
+
distinctColumnValues(columnId) {
|
|
755
|
+
const column = options.columns.find((c) => c.id === columnId);
|
|
756
|
+
if (!column) {
|
|
757
|
+
return [];
|
|
758
|
+
}
|
|
759
|
+
const seen = /* @__PURE__ */ new Set();
|
|
760
|
+
for (const entry of sourceRows) {
|
|
761
|
+
const raw = column.value ? column.value(entry.row) : entry.row[columnId];
|
|
762
|
+
if (raw === null || raw === void 0) {
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
const s = String(raw);
|
|
766
|
+
if (s.trim() === "") {
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
seen.add(s);
|
|
770
|
+
}
|
|
771
|
+
return [...seen].sort((a, b) => a.localeCompare(b));
|
|
772
|
+
},
|
|
216
773
|
setSelection(next) {
|
|
217
774
|
if (selectionsEqual(selection, next)) {
|
|
218
775
|
return;
|
|
@@ -224,9 +781,9 @@ function createGridCore(inputOptions) {
|
|
|
224
781
|
emit();
|
|
225
782
|
},
|
|
226
783
|
selectAll() {
|
|
227
|
-
const
|
|
228
|
-
const firstRow =
|
|
229
|
-
const lastRow =
|
|
784
|
+
const dataRows = getSnapshot().visibleRows.filter(isDataRow);
|
|
785
|
+
const firstRow = dataRows[0];
|
|
786
|
+
const lastRow = dataRows[dataRows.length - 1];
|
|
230
787
|
const firstColumn = options.columns[0];
|
|
231
788
|
const lastColumn = options.columns[options.columns.length - 1];
|
|
232
789
|
if (!firstRow || !lastRow || !firstColumn || !lastColumn) {
|
|
@@ -314,17 +871,17 @@ function createGridCore(inputOptions) {
|
|
|
314
871
|
emit();
|
|
315
872
|
},
|
|
316
873
|
setSelectAllVisible(checked) {
|
|
317
|
-
const
|
|
874
|
+
const dataRows = getSnapshot().visibleRows.filter(isDataRow);
|
|
318
875
|
const firstColumn = options.columns[0];
|
|
319
876
|
const lastColumn = options.columns[options.columns.length - 1];
|
|
320
877
|
if (!firstColumn || !lastColumn) {
|
|
321
878
|
return;
|
|
322
879
|
}
|
|
323
|
-
const visibleIds = new Set(
|
|
880
|
+
const visibleIds = new Set(dataRows.map((r) => r.id));
|
|
324
881
|
const nonRowRanges = selection.ranges.filter((r) => !isFullRowRange(r, r.startRowId, firstColumn.id, lastColumn.id) || !visibleIds.has(r.startRowId));
|
|
325
882
|
let next;
|
|
326
883
|
if (checked) {
|
|
327
|
-
const newRanges =
|
|
884
|
+
const newRanges = dataRows.map((row) => ({
|
|
328
885
|
startRowId: row.id,
|
|
329
886
|
endRowId: row.id,
|
|
330
887
|
startColumnId: firstColumn.id,
|
|
@@ -332,7 +889,7 @@ function createGridCore(inputOptions) {
|
|
|
332
889
|
}));
|
|
333
890
|
next = {
|
|
334
891
|
ranges: [...nonRowRanges, ...newRanges],
|
|
335
|
-
anchor:
|
|
892
|
+
anchor: dataRows[0] ? { rowId: dataRows[0].id, columnId: firstColumn.id } : selection.anchor
|
|
336
893
|
};
|
|
337
894
|
} else {
|
|
338
895
|
next = { ranges: nonRowRanges, anchor: selection.anchor };
|
|
@@ -354,14 +911,13 @@ function createGridCore(inputOptions) {
|
|
|
354
911
|
},
|
|
355
912
|
moveFocus(direction, moveOptions = {}) {
|
|
356
913
|
const snapshot = getSnapshot();
|
|
357
|
-
const
|
|
914
|
+
const { count: dataRowCount, index: currentRowIndex } = scanDataRows(snapshot.visibleRows, focus.rowId);
|
|
358
915
|
const columnList = options.columns;
|
|
359
|
-
if (
|
|
916
|
+
if (dataRowCount === 0 || columnList.length === 0) {
|
|
360
917
|
focus = { rowId: null, columnId: null };
|
|
361
918
|
emit();
|
|
362
919
|
return;
|
|
363
920
|
}
|
|
364
|
-
const currentRowIndex = focus.rowId ? visibleRows.findIndex((r) => r.id === focus.rowId) : -1;
|
|
365
921
|
const currentColumnIndex = focus.columnId ? columnList.findIndex((c) => c.id === focus.columnId) : -1;
|
|
366
922
|
const hasRowFocus = currentRowIndex !== -1;
|
|
367
923
|
const hasColumnFocus = currentColumnIndex !== -1;
|
|
@@ -369,28 +925,28 @@ function createGridCore(inputOptions) {
|
|
|
369
925
|
const baseColumnIndex = hasColumnFocus ? currentColumnIndex : 0;
|
|
370
926
|
let nextRowIndex = baseRowIndex;
|
|
371
927
|
let nextColumnIndex = baseColumnIndex;
|
|
372
|
-
const pageStep = computePageStep(viewport,
|
|
928
|
+
const pageStep = computePageStep(viewport, dataRowCount);
|
|
373
929
|
switch (direction) {
|
|
374
930
|
case "up":
|
|
375
931
|
if (moveOptions.jumpToEdge) {
|
|
376
932
|
nextRowIndex = 0;
|
|
377
933
|
} else if (!hasRowFocus) {
|
|
378
|
-
nextRowIndex =
|
|
934
|
+
nextRowIndex = dataRowCount - 1;
|
|
379
935
|
} else if (moveOptions.byPage) {
|
|
380
|
-
nextRowIndex = clamp(baseRowIndex - pageStep, 0,
|
|
936
|
+
nextRowIndex = clamp(baseRowIndex - pageStep, 0, dataRowCount - 1);
|
|
381
937
|
} else {
|
|
382
|
-
nextRowIndex = clamp(baseRowIndex - 1, 0,
|
|
938
|
+
nextRowIndex = clamp(baseRowIndex - 1, 0, dataRowCount - 1);
|
|
383
939
|
}
|
|
384
940
|
break;
|
|
385
941
|
case "down":
|
|
386
942
|
if (moveOptions.jumpToEdge) {
|
|
387
|
-
nextRowIndex =
|
|
943
|
+
nextRowIndex = dataRowCount - 1;
|
|
388
944
|
} else if (!hasRowFocus) {
|
|
389
945
|
nextRowIndex = 0;
|
|
390
946
|
} else if (moveOptions.byPage) {
|
|
391
|
-
nextRowIndex = clamp(baseRowIndex + pageStep, 0,
|
|
947
|
+
nextRowIndex = clamp(baseRowIndex + pageStep, 0, dataRowCount - 1);
|
|
392
948
|
} else {
|
|
393
|
-
nextRowIndex = clamp(baseRowIndex + 1, 0,
|
|
949
|
+
nextRowIndex = clamp(baseRowIndex + 1, 0, dataRowCount - 1);
|
|
394
950
|
}
|
|
395
951
|
break;
|
|
396
952
|
case "left":
|
|
@@ -412,7 +968,7 @@ function createGridCore(inputOptions) {
|
|
|
412
968
|
}
|
|
413
969
|
break;
|
|
414
970
|
}
|
|
415
|
-
const nextRow = visibleRows
|
|
971
|
+
const nextRow = dataRowAt(snapshot.visibleRows, nextRowIndex);
|
|
416
972
|
const nextColumn = columnList[nextColumnIndex];
|
|
417
973
|
if (!nextRow || !nextColumn) {
|
|
418
974
|
return;
|
|
@@ -491,6 +1047,7 @@ function createGridCore(inputOptions) {
|
|
|
491
1047
|
const nextColumns = options.columns.slice();
|
|
492
1048
|
nextColumns[idx] = { ...column, widthPx: clamped };
|
|
493
1049
|
options = { ...options, columns: nextColumns };
|
|
1050
|
+
pinnedWidthColumnIds.add(columnId);
|
|
494
1051
|
emit();
|
|
495
1052
|
},
|
|
496
1053
|
moveColumn(columnId, toIndex) {
|
|
@@ -514,26 +1071,73 @@ function createGridCore(inputOptions) {
|
|
|
514
1071
|
return;
|
|
515
1072
|
}
|
|
516
1073
|
nextColumns.splice(clampedTo, 0, moved);
|
|
517
|
-
let
|
|
518
|
-
for (let i =
|
|
1074
|
+
let leftBoundary = minIndex;
|
|
1075
|
+
for (let i = minIndex; i < nextColumns.length; i += 1) {
|
|
519
1076
|
if (i === clampedTo) {
|
|
520
1077
|
continue;
|
|
521
1078
|
}
|
|
522
1079
|
if (nextColumns[i]?.pinned === "left") {
|
|
523
|
-
|
|
1080
|
+
leftBoundary = i + 1;
|
|
524
1081
|
} else {
|
|
525
1082
|
break;
|
|
526
1083
|
}
|
|
527
1084
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
1085
|
+
let rightBoundary = nextColumns.length;
|
|
1086
|
+
for (let i = nextColumns.length - 1; i >= minIndex; i -= 1) {
|
|
1087
|
+
if (i === clampedTo) {
|
|
1088
|
+
continue;
|
|
1089
|
+
}
|
|
1090
|
+
if (nextColumns[i]?.pinned === "right") {
|
|
1091
|
+
rightBoundary = i;
|
|
1092
|
+
} else {
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
const nextPinned = clampedTo < leftBoundary ? "left" : clampedTo >= rightBoundary ? "right" : void 0;
|
|
1097
|
+
if (nextPinned !== moved.pinned) {
|
|
532
1098
|
nextColumns[clampedTo] = { ...moved, pinned: nextPinned };
|
|
533
1099
|
}
|
|
534
1100
|
options = { ...options, columns: nextColumns };
|
|
535
1101
|
emit();
|
|
536
1102
|
},
|
|
1103
|
+
setColumnOrder(ids) {
|
|
1104
|
+
const byId = new Map(options.columns.map((c) => [c.id, c]));
|
|
1105
|
+
const taken = /* @__PURE__ */ new Set();
|
|
1106
|
+
const ordered = [];
|
|
1107
|
+
for (const id of ids) {
|
|
1108
|
+
if (id === ROW_SELECT_COLUMN_ID || taken.has(id)) {
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
const column = byId.get(id);
|
|
1112
|
+
if (!column) {
|
|
1113
|
+
continue;
|
|
1114
|
+
}
|
|
1115
|
+
taken.add(id);
|
|
1116
|
+
ordered.push(column);
|
|
1117
|
+
}
|
|
1118
|
+
for (const column of options.columns) {
|
|
1119
|
+
if (taken.has(column.id)) {
|
|
1120
|
+
continue;
|
|
1121
|
+
}
|
|
1122
|
+
taken.add(column.id);
|
|
1123
|
+
ordered.push(column);
|
|
1124
|
+
}
|
|
1125
|
+
const nextColumns = groupColumnsByPin(ordered);
|
|
1126
|
+
let changed = nextColumns.length !== options.columns.length;
|
|
1127
|
+
if (!changed) {
|
|
1128
|
+
for (let i = 0; i < nextColumns.length; i += 1) {
|
|
1129
|
+
if (nextColumns[i].id !== options.columns[i].id) {
|
|
1130
|
+
changed = true;
|
|
1131
|
+
break;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
if (!changed) {
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1138
|
+
options = { ...options, columns: nextColumns };
|
|
1139
|
+
emit();
|
|
1140
|
+
},
|
|
537
1141
|
setColumnPinned(columnId, pinned) {
|
|
538
1142
|
if (columnId === ROW_SELECT_COLUMN_ID) {
|
|
539
1143
|
return;
|
|
@@ -543,7 +1147,7 @@ function createGridCore(inputOptions) {
|
|
|
543
1147
|
return;
|
|
544
1148
|
}
|
|
545
1149
|
const column = options.columns[idx];
|
|
546
|
-
const nextPinnedValue = pinned === "left"
|
|
1150
|
+
const nextPinnedValue = pinned === "left" || pinned === "right" ? pinned : void 0;
|
|
547
1151
|
if (column.pinned === nextPinnedValue) {
|
|
548
1152
|
return;
|
|
549
1153
|
}
|
|
@@ -555,7 +1159,12 @@ function createGridCore(inputOptions) {
|
|
|
555
1159
|
while (boundary < nextColumns.length && nextColumns[boundary]?.pinned === "left") {
|
|
556
1160
|
boundary += 1;
|
|
557
1161
|
}
|
|
558
|
-
|
|
1162
|
+
let rightBoundary = nextColumns.length;
|
|
1163
|
+
while (rightBoundary > boundary && nextColumns[rightBoundary - 1]?.pinned === "right") {
|
|
1164
|
+
rightBoundary -= 1;
|
|
1165
|
+
}
|
|
1166
|
+
const staysAtRightBoundary = nextPinnedValue === "right" || nextPinnedValue === void 0 && column.pinned === "right";
|
|
1167
|
+
const insertAt = staysAtRightBoundary ? rightBoundary : boundary;
|
|
559
1168
|
const nextColumn = {
|
|
560
1169
|
...column,
|
|
561
1170
|
pinned: nextPinnedValue
|
|
@@ -627,9 +1236,13 @@ function createGridCore(inputOptions) {
|
|
|
627
1236
|
}
|
|
628
1237
|
return { ...newCol };
|
|
629
1238
|
});
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
1239
|
+
const grouped = groupColumnsByPin(merged);
|
|
1240
|
+
const changed = !sameColumnLayout(options.columns, grouped);
|
|
1241
|
+
originalColumns = groupColumnsByPin(nextColumns).map((c) => ({ ...c }));
|
|
1242
|
+
options = { ...options, columns: grouped };
|
|
1243
|
+
if (changed) {
|
|
1244
|
+
emit();
|
|
1245
|
+
}
|
|
633
1246
|
},
|
|
634
1247
|
applyTransaction(transaction) {
|
|
635
1248
|
if (!options.getRowId) {
|
|
@@ -680,25 +1293,199 @@ function createGridCore(inputOptions) {
|
|
|
680
1293
|
}
|
|
681
1294
|
cachedVisibleRows = null;
|
|
682
1295
|
emit();
|
|
1296
|
+
},
|
|
1297
|
+
setRows(nextRows) {
|
|
1298
|
+
options = { ...options, rows: nextRows };
|
|
1299
|
+
sourceRows = createSourceRows(options);
|
|
1300
|
+
sourceRowIndex.clear();
|
|
1301
|
+
for (const entry of sourceRows) {
|
|
1302
|
+
sourceRowIndex.set(entry.id, entry);
|
|
1303
|
+
}
|
|
1304
|
+
const hasRow = (id) => id != null && sourceRowIndex.has(id);
|
|
1305
|
+
const keptRanges = selection.ranges.filter((range) => hasRow(range.startRowId) && hasRow(range.endRowId));
|
|
1306
|
+
const anchorValid = !selection.anchor || hasRow(selection.anchor.rowId);
|
|
1307
|
+
if (keptRanges.length !== selection.ranges.length || !anchorValid) {
|
|
1308
|
+
selection = {
|
|
1309
|
+
ranges: keptRanges,
|
|
1310
|
+
anchor: anchorValid ? selection.anchor : null
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
if (focus.rowId !== null && !hasRow(focus.rowId)) {
|
|
1314
|
+
focus = { rowId: null, columnId: null };
|
|
1315
|
+
}
|
|
1316
|
+
if (editing && !hasRow(editing.rowId)) {
|
|
1317
|
+
editing = null;
|
|
1318
|
+
}
|
|
1319
|
+
if (options.autosize) {
|
|
1320
|
+
const measured = applyAutosize({ ...options, columns: originalColumns }, typeof options.autosize === "object" ? options.autosize : void 0);
|
|
1321
|
+
const measuredById = new Map(measured.columns.map((column) => [column.id, column.widthPx]));
|
|
1322
|
+
options = {
|
|
1323
|
+
...options,
|
|
1324
|
+
// Keyed by id, not index — `moveColumn` can leave the live order out
|
|
1325
|
+
// of step with `originalColumns`, and the live set may carry the
|
|
1326
|
+
// synthetic row-select column that never appears in props.
|
|
1327
|
+
columns: options.columns.map((column) => {
|
|
1328
|
+
if (pinnedWidthColumnIds.has(column.id)) {
|
|
1329
|
+
return column;
|
|
1330
|
+
}
|
|
1331
|
+
const width = measuredById.get(column.id);
|
|
1332
|
+
if (width === void 0 || width === column.widthPx) {
|
|
1333
|
+
return column;
|
|
1334
|
+
}
|
|
1335
|
+
return { ...column, widthPx: width };
|
|
1336
|
+
})
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
cachedVisibleRows = null;
|
|
1340
|
+
emit();
|
|
1341
|
+
},
|
|
1342
|
+
setRowGroups(columnIds) {
|
|
1343
|
+
const next = sanitizeRowGroups(columnIds, options.columns);
|
|
1344
|
+
if (stringListsEqual(rowGroups, next)) {
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
rowGroups = next;
|
|
1348
|
+
groupExpansionOverrides = /* @__PURE__ */ new Set();
|
|
1349
|
+
emit();
|
|
1350
|
+
},
|
|
1351
|
+
toggleGroup(groupId) {
|
|
1352
|
+
store.setGroupExpanded(groupId, !isGroupExpanded(groupId));
|
|
1353
|
+
},
|
|
1354
|
+
setGroupExpanded(groupId, expanded) {
|
|
1355
|
+
if (isGroupExpanded(groupId) === expanded) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
const next = new Set(groupExpansionOverrides);
|
|
1359
|
+
if (expanded === groupsDefaultExpanded) {
|
|
1360
|
+
next.delete(groupId);
|
|
1361
|
+
} else {
|
|
1362
|
+
next.add(groupId);
|
|
1363
|
+
}
|
|
1364
|
+
groupExpansionOverrides = next;
|
|
1365
|
+
emit();
|
|
1366
|
+
},
|
|
1367
|
+
expandAll() {
|
|
1368
|
+
setExpansionDefault(true);
|
|
1369
|
+
},
|
|
1370
|
+
collapseAll() {
|
|
1371
|
+
setExpansionDefault(false);
|
|
1372
|
+
},
|
|
1373
|
+
beginEdit(addr, opts) {
|
|
1374
|
+
editing = {
|
|
1375
|
+
rowId: addr.rowId,
|
|
1376
|
+
columnId: addr.columnId,
|
|
1377
|
+
draft: opts?.draft,
|
|
1378
|
+
status: opts?.status ?? "editing"
|
|
1379
|
+
};
|
|
1380
|
+
emit();
|
|
1381
|
+
},
|
|
1382
|
+
setEditDraft(value) {
|
|
1383
|
+
if (!editing)
|
|
1384
|
+
return;
|
|
1385
|
+
editing = { ...editing, draft: value };
|
|
1386
|
+
emit();
|
|
1387
|
+
},
|
|
1388
|
+
markEditing() {
|
|
1389
|
+
if (!editing || editing.status !== "checking")
|
|
1390
|
+
return;
|
|
1391
|
+
editing = { ...editing, status: "editing", error: void 0 };
|
|
1392
|
+
emit();
|
|
1393
|
+
},
|
|
1394
|
+
markEditValidating() {
|
|
1395
|
+
if (!editing)
|
|
1396
|
+
return;
|
|
1397
|
+
editing = { ...editing, status: "validating", error: void 0 };
|
|
1398
|
+
emit();
|
|
1399
|
+
},
|
|
1400
|
+
markEditSaving() {
|
|
1401
|
+
if (!editing)
|
|
1402
|
+
return;
|
|
1403
|
+
editing = { ...editing, status: "saving", error: void 0 };
|
|
1404
|
+
emit();
|
|
1405
|
+
},
|
|
1406
|
+
markEditInvalid(message) {
|
|
1407
|
+
if (!editing)
|
|
1408
|
+
return;
|
|
1409
|
+
editing = { ...editing, status: "editing", error: message };
|
|
1410
|
+
emit();
|
|
1411
|
+
},
|
|
1412
|
+
markEditError(message) {
|
|
1413
|
+
if (!editing)
|
|
1414
|
+
return;
|
|
1415
|
+
editing = { ...editing, status: "error", error: message };
|
|
1416
|
+
emit();
|
|
1417
|
+
},
|
|
1418
|
+
commitEditSucceeded() {
|
|
1419
|
+
if (!editing)
|
|
1420
|
+
return;
|
|
1421
|
+
editing = null;
|
|
1422
|
+
emit();
|
|
1423
|
+
},
|
|
1424
|
+
cancelEdit() {
|
|
1425
|
+
if (!editing)
|
|
1426
|
+
return;
|
|
1427
|
+
editing = null;
|
|
1428
|
+
emit();
|
|
683
1429
|
}
|
|
684
1430
|
};
|
|
685
1431
|
return store;
|
|
1432
|
+
function isGroupExpanded(groupId) {
|
|
1433
|
+
return groupExpansionOverrides.has(groupId) ? !groupsDefaultExpanded : groupsDefaultExpanded;
|
|
1434
|
+
}
|
|
1435
|
+
function setExpansionDefault(expanded) {
|
|
1436
|
+
if (groupsDefaultExpanded === expanded && groupExpansionOverrides.size === 0) {
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
groupsDefaultExpanded = expanded;
|
|
1440
|
+
groupExpansionOverrides = /* @__PURE__ */ new Set();
|
|
1441
|
+
emit();
|
|
1442
|
+
}
|
|
1443
|
+
function preserveAggregateIdentity(rows) {
|
|
1444
|
+
const next = /* @__PURE__ */ new Map();
|
|
1445
|
+
let result = rows;
|
|
1446
|
+
for (let i = 0; i < rows.length; i += 1) {
|
|
1447
|
+
const entry = rows[i];
|
|
1448
|
+
if (entry.kind !== "group")
|
|
1449
|
+
continue;
|
|
1450
|
+
const previous = previousAggregates.get(entry.id);
|
|
1451
|
+
if (previous && recordsEqual(previous, entry.aggregates)) {
|
|
1452
|
+
if (result === rows)
|
|
1453
|
+
result = rows.slice();
|
|
1454
|
+
result[i] = { ...entry, aggregates: previous };
|
|
1455
|
+
next.set(entry.id, previous);
|
|
1456
|
+
} else {
|
|
1457
|
+
next.set(entry.id, entry.aggregates);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
previousAggregates = next;
|
|
1461
|
+
return result;
|
|
1462
|
+
}
|
|
686
1463
|
function getSnapshot() {
|
|
687
1464
|
if (cachedSnapshot) {
|
|
688
1465
|
return cachedSnapshot;
|
|
689
1466
|
}
|
|
690
|
-
const
|
|
1467
|
+
const aggregateFilteredRows = options.aggregateFilteredRows ?? false;
|
|
1468
|
+
const derivedIsFresh = cachedVisibleRows !== null && cachedDerivedSort === sort && cachedDerivedFilters === filters && cachedDerivedRowGroups === rowGroups && cachedDerivedOverrides === groupExpansionOverrides && cachedDerivedDefaultExpanded === groupsDefaultExpanded && cachedDerivedAggregateFiltered === aggregateFilteredRows;
|
|
1469
|
+
const visibleRows = derivedIsFresh ? cachedVisibleRows : preserveAggregateIdentity(deriveVisibleRows({
|
|
691
1470
|
columns: options.columns,
|
|
692
1471
|
filters,
|
|
693
1472
|
rows: sourceRows,
|
|
694
|
-
sort
|
|
695
|
-
|
|
1473
|
+
sort,
|
|
1474
|
+
rowGroups,
|
|
1475
|
+
groupExpansionOverrides,
|
|
1476
|
+
groupsDefaultExpanded,
|
|
1477
|
+
aggregateFilteredRows
|
|
1478
|
+
}));
|
|
696
1479
|
cachedVisibleRows = visibleRows;
|
|
697
1480
|
cachedDerivedSort = sort;
|
|
698
1481
|
cachedDerivedFilters = filters;
|
|
1482
|
+
cachedDerivedRowGroups = rowGroups;
|
|
1483
|
+
cachedDerivedOverrides = groupExpansionOverrides;
|
|
1484
|
+
cachedDerivedDefaultExpanded = groupsDefaultExpanded;
|
|
1485
|
+
cachedDerivedAggregateFiltered = aggregateFilteredRows;
|
|
699
1486
|
cachedSnapshot = {
|
|
700
1487
|
viewport,
|
|
701
|
-
sort,
|
|
1488
|
+
sort: sort.map((entry) => ({ ...entry })),
|
|
702
1489
|
filters: { ...filters },
|
|
703
1490
|
selection: {
|
|
704
1491
|
ranges: selection.ranges.map((r) => ({ ...r })),
|
|
@@ -710,7 +1497,11 @@ function createGridCore(inputOptions) {
|
|
|
710
1497
|
visibleRange: {
|
|
711
1498
|
start: 0,
|
|
712
1499
|
end: visibleRows.length
|
|
713
|
-
}
|
|
1500
|
+
},
|
|
1501
|
+
editing: editing ? { ...editing } : null,
|
|
1502
|
+
rowGroups: [...rowGroups],
|
|
1503
|
+
groupExpansionOverrides: new Set(groupExpansionOverrides),
|
|
1504
|
+
groupsDefaultExpanded
|
|
714
1505
|
};
|
|
715
1506
|
return cachedSnapshot;
|
|
716
1507
|
}
|
|
@@ -721,15 +1512,24 @@ function createGridCore(inputOptions) {
|
|
|
721
1512
|
}
|
|
722
1513
|
}
|
|
723
1514
|
}
|
|
724
|
-
function clamp(value,
|
|
725
|
-
return Math.max(
|
|
1515
|
+
function clamp(value, min2, max2) {
|
|
1516
|
+
return Math.max(min2, Math.min(max2, value));
|
|
726
1517
|
}
|
|
727
|
-
function
|
|
728
|
-
if (
|
|
1518
|
+
function sameColumnLayout(a, b) {
|
|
1519
|
+
if (a.length !== b.length) {
|
|
1520
|
+
return false;
|
|
1521
|
+
}
|
|
1522
|
+
return a.every((left, index) => {
|
|
1523
|
+
const right = b[index];
|
|
1524
|
+
return left.id === right.id && left.header === right.header && left.widthPx === right.widthPx && left.minWidthPx === right.minWidthPx && left.maxWidthPx === right.maxWidthPx && left.pinned === right.pinned && left.sortable === right.sortable && left.filterable === right.filterable && left.resizable === right.resizable && left.reorderable === right.reorderable && left.wrap === right.wrap;
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
function computePageStep(viewport, dataRowCount) {
|
|
1528
|
+
if (viewport.height <= 0 || dataRowCount === 0) {
|
|
729
1529
|
return 1;
|
|
730
1530
|
}
|
|
731
1531
|
const estimatedRowsPerPage = Math.max(1, Math.floor(viewport.height * 0.8 / 32));
|
|
732
|
-
return Math.min(estimatedRowsPerPage,
|
|
1532
|
+
return Math.min(estimatedRowsPerPage, dataRowCount);
|
|
733
1533
|
}
|
|
734
1534
|
function isFullRowRange(range, rowId, firstColumnId, lastColumnId) {
|
|
735
1535
|
return range.startRowId === rowId && range.endRowId === rowId && range.startColumnId === firstColumnId && range.endColumnId === lastColumnId;
|
|
@@ -753,6 +1553,58 @@ function selectionsEqual(a, b) {
|
|
|
753
1553
|
}
|
|
754
1554
|
return a.anchor.rowId === b.anchor.rowId && a.anchor.columnId === b.anchor.columnId;
|
|
755
1555
|
}
|
|
1556
|
+
function sanitizeSortEntries(entries, columns) {
|
|
1557
|
+
return entries.filter((entry) => {
|
|
1558
|
+
const column = columns.find((c) => c.id === entry.columnId);
|
|
1559
|
+
return column !== void 0 && column.sortable !== false;
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
function sanitizeRowGroups(columnIds, columns) {
|
|
1563
|
+
const known = new Set(columns.map((column) => column.id));
|
|
1564
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1565
|
+
const next = [];
|
|
1566
|
+
for (const columnId of columnIds) {
|
|
1567
|
+
if (!known.has(columnId) || seen.has(columnId))
|
|
1568
|
+
continue;
|
|
1569
|
+
seen.add(columnId);
|
|
1570
|
+
next.push(columnId);
|
|
1571
|
+
}
|
|
1572
|
+
return next;
|
|
1573
|
+
}
|
|
1574
|
+
function stringListsEqual(a, b) {
|
|
1575
|
+
return a.length === b.length && a.every((value, i) => value === b[i]);
|
|
1576
|
+
}
|
|
1577
|
+
function recordsEqual(a, b) {
|
|
1578
|
+
const aKeys = Object.keys(a);
|
|
1579
|
+
if (aKeys.length !== Object.keys(b).length) {
|
|
1580
|
+
return false;
|
|
1581
|
+
}
|
|
1582
|
+
return aKeys.every((key) => Object.prototype.hasOwnProperty.call(b, key) && Object.is(a[key], b[key]));
|
|
1583
|
+
}
|
|
1584
|
+
function sortsEqual(a, b) {
|
|
1585
|
+
if (a.length !== b.length) {
|
|
1586
|
+
return false;
|
|
1587
|
+
}
|
|
1588
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
1589
|
+
const ae = a[i];
|
|
1590
|
+
const be = b[i];
|
|
1591
|
+
if (ae.columnId !== be.columnId || ae.direction !== be.direction) {
|
|
1592
|
+
return false;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
return true;
|
|
1596
|
+
}
|
|
1597
|
+
function columnFilterEqual(a, b) {
|
|
1598
|
+
if (a.operator !== b.operator) {
|
|
1599
|
+
return false;
|
|
1600
|
+
}
|
|
1601
|
+
const av = a.value;
|
|
1602
|
+
const bv = b.value;
|
|
1603
|
+
if (Array.isArray(av) && Array.isArray(bv)) {
|
|
1604
|
+
return av.length === bv.length && av.every((v, i) => v === bv[i]);
|
|
1605
|
+
}
|
|
1606
|
+
return av === bv;
|
|
1607
|
+
}
|
|
756
1608
|
function filtersEqual(a, b) {
|
|
757
1609
|
const aKeys = Object.keys(a);
|
|
758
1610
|
const bKeys = Object.keys(b);
|
|
@@ -760,7 +1612,9 @@ function filtersEqual(a, b) {
|
|
|
760
1612
|
return false;
|
|
761
1613
|
}
|
|
762
1614
|
for (const key of aKeys) {
|
|
763
|
-
|
|
1615
|
+
const av = a[key];
|
|
1616
|
+
const bv = b[key];
|
|
1617
|
+
if (!av || !bv || !columnFilterEqual(av, bv)) {
|
|
764
1618
|
return false;
|
|
765
1619
|
}
|
|
766
1620
|
}
|
|
@@ -778,9 +1632,11 @@ function createGrid(options) {
|
|
|
778
1632
|
subscribe: engine.subscribe,
|
|
779
1633
|
getSnapshot: engine.getSnapshot,
|
|
780
1634
|
setSort: engine.setSort,
|
|
781
|
-
|
|
1635
|
+
replaceSort: engine.replaceSort,
|
|
1636
|
+
setColumnFilter: engine.setColumnFilter,
|
|
782
1637
|
clearFilters: engine.clearFilters,
|
|
783
1638
|
replaceFilters: engine.replaceFilters,
|
|
1639
|
+
distinctColumnValues: engine.distinctColumnValues,
|
|
784
1640
|
setSelection: engine.setSelection,
|
|
785
1641
|
selectAll: engine.selectAll,
|
|
786
1642
|
clearSelection: engine.clearSelection,
|
|
@@ -790,15 +1646,31 @@ function createGrid(options) {
|
|
|
790
1646
|
setSelectAllVisible: engine.setSelectAllVisible,
|
|
791
1647
|
setFocus: engine.setFocus,
|
|
792
1648
|
moveFocus: engine.moveFocus,
|
|
1649
|
+
setRowGroups: engine.setRowGroups,
|
|
1650
|
+
toggleGroup: engine.toggleGroup,
|
|
1651
|
+
setGroupExpanded: engine.setGroupExpanded,
|
|
1652
|
+
expandAll: engine.expandAll,
|
|
1653
|
+
collapseAll: engine.collapseAll,
|
|
793
1654
|
setViewport: engine.setViewport,
|
|
794
1655
|
autosizeColumns: engine.autosizeColumns,
|
|
795
1656
|
setColumnWidth: engine.setColumnWidth,
|
|
796
1657
|
moveColumn: engine.moveColumn,
|
|
1658
|
+
setColumnOrder: engine.setColumnOrder,
|
|
797
1659
|
setColumnPinned: engine.setColumnPinned,
|
|
798
1660
|
autosizeColumn: engine.autosizeColumn,
|
|
799
1661
|
resetColumnLayout: engine.resetColumnLayout,
|
|
800
1662
|
mergeColumnsFromProps: engine.mergeColumnsFromProps,
|
|
801
|
-
applyTransaction: engine.applyTransaction
|
|
1663
|
+
applyTransaction: engine.applyTransaction,
|
|
1664
|
+
setRows: engine.setRows,
|
|
1665
|
+
beginEdit: engine.beginEdit,
|
|
1666
|
+
setEditDraft: engine.setEditDraft,
|
|
1667
|
+
markEditing: engine.markEditing,
|
|
1668
|
+
markEditValidating: engine.markEditValidating,
|
|
1669
|
+
markEditSaving: engine.markEditSaving,
|
|
1670
|
+
markEditInvalid: engine.markEditInvalid,
|
|
1671
|
+
markEditError: engine.markEditError,
|
|
1672
|
+
commitEditSucceeded: engine.commitEditSucceeded,
|
|
1673
|
+
cancelEdit: engine.cancelEdit
|
|
802
1674
|
};
|
|
803
1675
|
}
|
|
804
1676
|
|