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