@pretable/core 0.0.1 → 0.0.3

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 CHANGED
@@ -21,7 +21,7 @@ function autosizeColumns(input) {
21
21
  maxContentWidth = Math.max(maxContentWidth, headerWidth);
22
22
  }
23
23
  for (const row of input.rows) {
24
- const rawValue = column.getValue ? column.getValue(row) : row[column.id];
24
+ const rawValue = column.value ? column.value(row) : row[column.id];
25
25
  const text = String(rawValue ?? "");
26
26
  if (text.length === 0) {
27
27
  continue;
@@ -35,6 +35,197 @@ function autosizeColumns(input) {
35
35
  return { widths };
36
36
  }
37
37
 
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
+
38
229
  // ../grid-core/dist/derived-rows.js
39
230
  function createSourceRows(options) {
40
231
  return options.rows.map((row, index) => ({
@@ -56,22 +247,20 @@ function deriveVisibleRows(input) {
56
247
  function resolveFilters(columns, filters) {
57
248
  const columnMap = new Map(columns.map((c) => [c.id, c]));
58
249
  const resolved = [];
59
- for (const [columnId, rawNeedle] of Object.entries(filters)) {
60
- if (!rawNeedle) {
250
+ for (const [columnId, filter] of Object.entries(filters)) {
251
+ if (!filter || !isFilterActive(filter))
61
252
  continue;
62
- }
63
253
  const column = columnMap.get(columnId);
64
- if (!column) {
254
+ if (!column || column.filterable === false)
65
255
  continue;
66
- }
67
- resolved.push({ column, needle: rawNeedle.toLowerCase() });
256
+ resolved.push({ column, filter });
68
257
  }
69
258
  return resolved;
70
259
  }
71
260
  function matchesFilters(row, resolvedFilters) {
72
- for (const { column, needle } of resolvedFilters) {
73
- const haystack = String(readCellValue(row, column)).toLowerCase();
74
- if (!haystack.includes(needle)) {
261
+ for (const { column, filter } of resolvedFilters) {
262
+ const cell = readCellValue(row, column);
263
+ if (!evaluateFilter(cell, column.type ?? "text", filter.operator, filter.value)) {
75
264
  return false;
76
265
  }
77
266
  }
@@ -82,38 +271,45 @@ var collator = new Intl.Collator(void 0, {
82
271
  sensitivity: "base"
83
272
  });
84
273
  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) {
274
+ const keys = sort.map((entry) => {
275
+ const column = columns.find((c) => c.id === entry.columnId);
276
+ if (!column)
277
+ return null;
278
+ const rawKeys = rows.map((r) => readCellValue(r.row, column));
279
+ const allNumeric = rawKeys.every((v) => typeof v === "number");
280
+ const multiplier = entry.direction === "asc" ? 1 : -1;
281
+ return allNumeric ? { kind: "num", keys: rawKeys, multiplier } : {
282
+ kind: "str",
283
+ keys: rawKeys.map((v) => String(v ?? "")),
284
+ multiplier
285
+ };
286
+ }).filter((k) => k !== null);
287
+ if (keys.length === 0) {
90
288
  return [...rows];
91
289
  }
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
290
  const indexed = rows.map((_, i) => i);
106
291
  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;
292
+ for (const key of keys) {
293
+ const cmp = key.kind === "num" ? key.keys[a] - key.keys[b] : collator.compare(key.keys[a], key.keys[b]);
294
+ if (cmp !== 0) {
295
+ return cmp * key.multiplier;
296
+ }
297
+ }
298
+ return rows[a].sourceIndex - rows[b].sourceIndex;
109
299
  });
110
300
  return indexed.map((i) => rows[i]);
111
301
  }
112
302
  function readCellValue(row, column) {
113
- return column.getValue ? column.getValue(row) : row[column.id];
303
+ return column.value ? column.value(row) : row[column.id];
114
304
  }
115
305
 
116
306
  // ../grid-core/dist/create-grid-core.js
307
+ var ROW_SELECT_COLUMN_ID = "__pretable_row_select__";
308
+ function clampColumnWidth(width, column) {
309
+ const min = column.minWidthPx ?? 40;
310
+ const max = column.maxWidthPx ?? Infinity;
311
+ return Math.max(min, Math.min(max, width));
312
+ }
117
313
  function applyAutosize(options, autosizeOptions) {
118
314
  const result = autosizeColumns({
119
315
  columns: options.columns,
@@ -132,19 +328,40 @@ function applyAutosize(options, autosizeOptions) {
132
328
  });
133
329
  return { ...options, columns: nextColumns };
134
330
  }
331
+ function groupColumnsByPin(columns) {
332
+ const left = [];
333
+ const unpinned = [];
334
+ const right = [];
335
+ for (const column of columns) {
336
+ const region = column.pinned === "left" ? left : column.pinned === "right" ? right : unpinned;
337
+ if (column.id === ROW_SELECT_COLUMN_ID) {
338
+ region.unshift(column);
339
+ } else {
340
+ region.push(column);
341
+ }
342
+ }
343
+ return [...left, ...unpinned, ...right];
344
+ }
135
345
  function createGridCore(inputOptions) {
136
346
  const listeners = /* @__PURE__ */ new Set();
137
- let options = inputOptions.autosize ? applyAutosize(inputOptions, typeof inputOptions.autosize === "object" ? inputOptions.autosize : void 0) : inputOptions;
347
+ const groupedInput = {
348
+ ...inputOptions,
349
+ columns: groupColumnsByPin(inputOptions.columns)
350
+ };
351
+ let options = groupedInput.autosize ? applyAutosize(groupedInput, typeof groupedInput.autosize === "object" ? groupedInput.autosize : void 0) : groupedInput;
352
+ let originalColumns = groupColumnsByPin(inputOptions.columns).map((c) => ({ ...c }));
138
353
  let sourceRows = createSourceRows(options);
139
354
  const sourceRowIndex = new Map(sourceRows.map((entry) => [entry.id, entry]));
355
+ const pinnedWidthColumnIds = /* @__PURE__ */ new Set();
140
356
  let cachedSnapshot = null;
141
357
  let cachedVisibleRows = null;
142
358
  let cachedDerivedSort = null;
143
359
  let cachedDerivedFilters = null;
144
- let sort = { columnId: null, direction: null };
360
+ let sort = [];
145
361
  let filters = {};
146
- let selection = { rowIds: [], anchorRowId: null };
362
+ let selection = { ranges: [], anchor: null };
147
363
  let focus = { rowId: null, columnId: null };
364
+ let editing = null;
148
365
  let viewport = {
149
366
  scrollTop: 0,
150
367
  scrollLeft: 0,
@@ -163,22 +380,31 @@ function createGridCore(inputOptions) {
163
380
  },
164
381
  getSnapshot,
165
382
  setSort(columnId, direction) {
166
- if (sort.columnId === columnId && sort.direction === direction) {
383
+ const candidate = columnId && direction ? [{ columnId, direction }] : [];
384
+ const next = sanitizeSortEntries(candidate, options.columns);
385
+ if (sortsEqual(sort, next)) {
386
+ return;
387
+ }
388
+ sort = next;
389
+ emit();
390
+ },
391
+ replaceSort(entries) {
392
+ const next = sanitizeSortEntries(entries, options.columns);
393
+ if (sortsEqual(sort, next)) {
167
394
  return;
168
395
  }
169
- sort = { columnId, direction };
396
+ sort = next;
170
397
  emit();
171
398
  },
172
- setFilter(columnId, value) {
173
- const trimmed = value.trim();
174
- const currentValue = filters[columnId];
175
- if (trimmed) {
176
- if (currentValue === trimmed) {
399
+ setColumnFilter(columnId, filter) {
400
+ const current = filters[columnId];
401
+ if (filter && isFilterActive(filter)) {
402
+ if (current && columnFilterEqual(current, filter)) {
177
403
  return;
178
404
  }
179
- filters = { ...filters, [columnId]: trimmed };
405
+ filters = { ...filters, [columnId]: filter };
180
406
  } else {
181
- if (currentValue === void 0) {
407
+ if (current === void 0) {
182
408
  return;
183
409
  }
184
410
  const next = { ...filters };
@@ -196,10 +422,9 @@ function createGridCore(inputOptions) {
196
422
  },
197
423
  replaceFilters(nextFilters) {
198
424
  const normalized = {};
199
- for (const [columnId, value] of Object.entries(nextFilters)) {
200
- const trimmed = value.trim();
201
- if (trimmed) {
202
- normalized[columnId] = trimmed;
425
+ for (const [columnId, filter] of Object.entries(nextFilters)) {
426
+ if (filter && isFilterActive(filter)) {
427
+ normalized[columnId] = filter;
203
428
  }
204
429
  }
205
430
  if (filtersEqual(filters, normalized)) {
@@ -208,35 +433,270 @@ function createGridCore(inputOptions) {
208
433
  filters = normalized;
209
434
  emit();
210
435
  },
211
- selectRow(rowId) {
212
- const currentRowId = selection.rowIds[0] ?? null;
213
- if (currentRowId === rowId && selection.anchorRowId === rowId) {
436
+ distinctColumnValues(columnId) {
437
+ const column = options.columns.find((c) => c.id === columnId);
438
+ if (!column) {
439
+ return [];
440
+ }
441
+ const seen = /* @__PURE__ */ new Set();
442
+ for (const entry of sourceRows) {
443
+ const raw = column.value ? column.value(entry.row) : entry.row[columnId];
444
+ if (raw === null || raw === void 0) {
445
+ continue;
446
+ }
447
+ const s = String(raw);
448
+ if (s.trim() === "") {
449
+ continue;
450
+ }
451
+ seen.add(s);
452
+ }
453
+ return [...seen].sort((a, b) => a.localeCompare(b));
454
+ },
455
+ setSelection(next) {
456
+ if (selectionsEqual(selection, next)) {
214
457
  return;
215
458
  }
216
- selection = rowId ? { rowIds: [rowId], anchorRowId: rowId } : { rowIds: [], anchorRowId: null };
459
+ selection = {
460
+ ranges: next.ranges.map((r) => ({ ...r })),
461
+ anchor: next.anchor ? { ...next.anchor } : null
462
+ };
217
463
  emit();
218
464
  },
219
- setFocus(rowId, columnId) {
220
- if (focus.rowId === rowId && focus.columnId === columnId) {
465
+ selectAll() {
466
+ const snapshot = getSnapshot();
467
+ const firstRow = snapshot.visibleRows[0];
468
+ const lastRow = snapshot.visibleRows[snapshot.visibleRows.length - 1];
469
+ const firstColumn = options.columns[0];
470
+ const lastColumn = options.columns[options.columns.length - 1];
471
+ if (!firstRow || !lastRow || !firstColumn || !lastColumn) {
221
472
  return;
222
473
  }
223
- focus = { rowId, columnId };
474
+ const range = {
475
+ startRowId: firstRow.id,
476
+ endRowId: lastRow.id,
477
+ startColumnId: firstColumn.id,
478
+ endColumnId: lastColumn.id
479
+ };
480
+ const anchor = {
481
+ rowId: firstRow.id,
482
+ columnId: firstColumn.id
483
+ };
484
+ const next = { ranges: [range], anchor };
485
+ if (selectionsEqual(selection, next)) {
486
+ return;
487
+ }
488
+ selection = next;
224
489
  emit();
225
490
  },
226
- moveFocus(delta) {
491
+ clearSelection() {
492
+ const focusAddr = focus.rowId && focus.columnId ? { rowId: focus.rowId, columnId: focus.columnId } : null;
493
+ const next = focusAddr ? {
494
+ ranges: [
495
+ {
496
+ startRowId: focusAddr.rowId,
497
+ endRowId: focusAddr.rowId,
498
+ startColumnId: focusAddr.columnId,
499
+ endColumnId: focusAddr.columnId
500
+ }
501
+ ],
502
+ anchor: focusAddr
503
+ } : { ranges: [], anchor: null };
504
+ if (selectionsEqual(selection, next)) {
505
+ return;
506
+ }
507
+ selection = next;
508
+ emit();
509
+ },
510
+ addRange(range) {
511
+ selection = {
512
+ ranges: [...selection.ranges, { ...range }],
513
+ anchor: { rowId: range.startRowId, columnId: range.startColumnId }
514
+ };
515
+ emit();
516
+ },
517
+ extendRangeFromAnchor(addr) {
518
+ if (!selection.anchor) {
519
+ return;
520
+ }
521
+ const newActive = {
522
+ startRowId: selection.anchor.rowId,
523
+ endRowId: addr.rowId,
524
+ startColumnId: selection.anchor.columnId,
525
+ endColumnId: addr.columnId
526
+ };
527
+ const ranges = selection.ranges.length === 0 ? [newActive] : [...selection.ranges.slice(0, -1), newActive];
528
+ selection = { ranges, anchor: selection.anchor };
529
+ emit();
530
+ },
531
+ toggleRowSelection(rowId) {
532
+ const firstColumn = options.columns[0];
533
+ const lastColumn = options.columns[options.columns.length - 1];
534
+ if (!firstColumn || !lastColumn) {
535
+ return;
536
+ }
537
+ const fullRowRange = {
538
+ startRowId: rowId,
539
+ endRowId: rowId,
540
+ startColumnId: firstColumn.id,
541
+ endColumnId: lastColumn.id
542
+ };
543
+ const matchIndex = selection.ranges.findIndex((r) => isFullRowRange(r, rowId, firstColumn.id, lastColumn.id));
544
+ if (matchIndex >= 0) {
545
+ const ranges = selection.ranges.filter((_, i) => i !== matchIndex);
546
+ selection = { ranges, anchor: selection.anchor };
547
+ } else {
548
+ selection = {
549
+ ranges: [...selection.ranges, fullRowRange],
550
+ anchor: { rowId, columnId: firstColumn.id }
551
+ };
552
+ }
553
+ emit();
554
+ },
555
+ setSelectAllVisible(checked) {
556
+ const snapshot = getSnapshot();
557
+ const firstColumn = options.columns[0];
558
+ const lastColumn = options.columns[options.columns.length - 1];
559
+ if (!firstColumn || !lastColumn) {
560
+ return;
561
+ }
562
+ const visibleIds = new Set(snapshot.visibleRows.map((r) => r.id));
563
+ const nonRowRanges = selection.ranges.filter((r) => !isFullRowRange(r, r.startRowId, firstColumn.id, lastColumn.id) || !visibleIds.has(r.startRowId));
564
+ let next;
565
+ if (checked) {
566
+ const newRanges = snapshot.visibleRows.map((row) => ({
567
+ startRowId: row.id,
568
+ endRowId: row.id,
569
+ startColumnId: firstColumn.id,
570
+ endColumnId: lastColumn.id
571
+ }));
572
+ next = {
573
+ ranges: [...nonRowRanges, ...newRanges],
574
+ anchor: snapshot.visibleRows[0] ? { rowId: snapshot.visibleRows[0].id, columnId: firstColumn.id } : selection.anchor
575
+ };
576
+ } else {
577
+ next = { ranges: nonRowRanges, anchor: selection.anchor };
578
+ }
579
+ if (selectionsEqual(selection, next)) {
580
+ return;
581
+ }
582
+ selection = next;
583
+ emit();
584
+ },
585
+ setFocus(addr) {
586
+ const nextRowId = addr?.rowId ?? null;
587
+ const nextColumnId = addr?.columnId ?? null;
588
+ if (focus.rowId === nextRowId && focus.columnId === nextColumnId) {
589
+ return;
590
+ }
591
+ focus = { rowId: nextRowId, columnId: nextColumnId };
592
+ emit();
593
+ },
594
+ moveFocus(direction, moveOptions = {}) {
227
595
  const snapshot = getSnapshot();
228
- const currentIndex = snapshot.visibleRows.findIndex((row) => row.id === focus.rowId);
229
- if (snapshot.visibleRows.length === 0) {
230
- focus = { rowId: null, columnId: focus.columnId };
596
+ const visibleRows = snapshot.visibleRows;
597
+ const columnList = options.columns;
598
+ if (visibleRows.length === 0 || columnList.length === 0) {
599
+ focus = { rowId: null, columnId: null };
231
600
  emit();
232
601
  return;
233
602
  }
234
- const nextIndex = currentIndex === -1 ? delta >= 0 ? 0 : snapshot.visibleRows.length - 1 : clamp(currentIndex + delta, 0, snapshot.visibleRows.length - 1);
235
- const nextRow = snapshot.visibleRows[nextIndex];
236
- if (!nextRow) {
603
+ const currentRowIndex = focus.rowId ? visibleRows.findIndex((r) => r.id === focus.rowId) : -1;
604
+ const currentColumnIndex = focus.columnId ? columnList.findIndex((c) => c.id === focus.columnId) : -1;
605
+ const hasRowFocus = currentRowIndex !== -1;
606
+ const hasColumnFocus = currentColumnIndex !== -1;
607
+ const baseRowIndex = hasRowFocus ? currentRowIndex : 0;
608
+ const baseColumnIndex = hasColumnFocus ? currentColumnIndex : 0;
609
+ let nextRowIndex = baseRowIndex;
610
+ let nextColumnIndex = baseColumnIndex;
611
+ const pageStep = computePageStep(viewport, visibleRows);
612
+ switch (direction) {
613
+ case "up":
614
+ if (moveOptions.jumpToEdge) {
615
+ nextRowIndex = 0;
616
+ } else if (!hasRowFocus) {
617
+ nextRowIndex = visibleRows.length - 1;
618
+ } else if (moveOptions.byPage) {
619
+ nextRowIndex = clamp(baseRowIndex - pageStep, 0, visibleRows.length - 1);
620
+ } else {
621
+ nextRowIndex = clamp(baseRowIndex - 1, 0, visibleRows.length - 1);
622
+ }
623
+ break;
624
+ case "down":
625
+ if (moveOptions.jumpToEdge) {
626
+ nextRowIndex = visibleRows.length - 1;
627
+ } else if (!hasRowFocus) {
628
+ nextRowIndex = 0;
629
+ } else if (moveOptions.byPage) {
630
+ nextRowIndex = clamp(baseRowIndex + pageStep, 0, visibleRows.length - 1);
631
+ } else {
632
+ nextRowIndex = clamp(baseRowIndex + 1, 0, visibleRows.length - 1);
633
+ }
634
+ break;
635
+ case "left":
636
+ if (moveOptions.jumpToEdge) {
637
+ nextColumnIndex = 0;
638
+ } else if (!hasColumnFocus) {
639
+ nextColumnIndex = columnList.length - 1;
640
+ } else {
641
+ nextColumnIndex = clamp(baseColumnIndex - 1, 0, columnList.length - 1);
642
+ }
643
+ break;
644
+ case "right":
645
+ if (moveOptions.jumpToEdge) {
646
+ nextColumnIndex = columnList.length - 1;
647
+ } else if (!hasColumnFocus) {
648
+ nextColumnIndex = 0;
649
+ } else {
650
+ nextColumnIndex = clamp(baseColumnIndex + 1, 0, columnList.length - 1);
651
+ }
652
+ break;
653
+ }
654
+ const nextRow = visibleRows[nextRowIndex];
655
+ const nextColumn = columnList[nextColumnIndex];
656
+ if (!nextRow || !nextColumn) {
237
657
  return;
238
658
  }
239
- focus = { rowId: nextRow.id, columnId: focus.columnId };
659
+ const nextAddr = {
660
+ rowId: nextRow.id,
661
+ columnId: nextColumn.id
662
+ };
663
+ focus = nextAddr;
664
+ if (moveOptions.extend) {
665
+ if (!selection.anchor) {
666
+ selection = {
667
+ ranges: [
668
+ {
669
+ startRowId: nextAddr.rowId,
670
+ endRowId: nextAddr.rowId,
671
+ startColumnId: nextAddr.columnId,
672
+ endColumnId: nextAddr.columnId
673
+ }
674
+ ],
675
+ anchor: nextAddr
676
+ };
677
+ } else {
678
+ const newActive = {
679
+ startRowId: selection.anchor.rowId,
680
+ endRowId: nextAddr.rowId,
681
+ startColumnId: selection.anchor.columnId,
682
+ endColumnId: nextAddr.columnId
683
+ };
684
+ const ranges = selection.ranges.length === 0 ? [newActive] : [...selection.ranges.slice(0, -1), newActive];
685
+ selection = { ranges, anchor: selection.anchor };
686
+ }
687
+ } else {
688
+ selection = {
689
+ ranges: [
690
+ {
691
+ startRowId: nextAddr.rowId,
692
+ endRowId: nextAddr.rowId,
693
+ startColumnId: nextAddr.columnId,
694
+ endColumnId: nextAddr.columnId
695
+ }
696
+ ],
697
+ anchor: nextAddr
698
+ };
699
+ }
240
700
  emit();
241
701
  },
242
702
  setViewport(nextViewport) {
@@ -254,9 +714,222 @@ function createGridCore(inputOptions) {
254
714
  options = nextOptions;
255
715
  emit();
256
716
  },
717
+ setColumnWidth(columnId, width) {
718
+ if (columnId === ROW_SELECT_COLUMN_ID) {
719
+ return;
720
+ }
721
+ const idx = options.columns.findIndex((c) => c.id === columnId);
722
+ if (idx === -1) {
723
+ return;
724
+ }
725
+ const column = options.columns[idx];
726
+ const clamped = clampColumnWidth(width, column);
727
+ if (column.widthPx === clamped) {
728
+ return;
729
+ }
730
+ const nextColumns = options.columns.slice();
731
+ nextColumns[idx] = { ...column, widthPx: clamped };
732
+ options = { ...options, columns: nextColumns };
733
+ pinnedWidthColumnIds.add(columnId);
734
+ emit();
735
+ },
736
+ moveColumn(columnId, toIndex) {
737
+ if (columnId === ROW_SELECT_COLUMN_ID) {
738
+ return;
739
+ }
740
+ const fromIndex = options.columns.findIndex((c) => c.id === columnId);
741
+ if (fromIndex === -1) {
742
+ return;
743
+ }
744
+ const synthAtZero = options.columns[0]?.id === ROW_SELECT_COLUMN_ID;
745
+ const minIndex = synthAtZero ? 1 : 0;
746
+ const maxIndex = options.columns.length - 1;
747
+ const clampedTo = Math.max(minIndex, Math.min(maxIndex, toIndex));
748
+ if (fromIndex === clampedTo) {
749
+ return;
750
+ }
751
+ const nextColumns = options.columns.slice();
752
+ const [moved] = nextColumns.splice(fromIndex, 1);
753
+ if (!moved) {
754
+ return;
755
+ }
756
+ nextColumns.splice(clampedTo, 0, moved);
757
+ let leftBoundary = minIndex;
758
+ for (let i = minIndex; i < nextColumns.length; i += 1) {
759
+ if (i === clampedTo) {
760
+ continue;
761
+ }
762
+ if (nextColumns[i]?.pinned === "left") {
763
+ leftBoundary = i + 1;
764
+ } else {
765
+ break;
766
+ }
767
+ }
768
+ let rightBoundary = nextColumns.length;
769
+ for (let i = nextColumns.length - 1; i >= minIndex; i -= 1) {
770
+ if (i === clampedTo) {
771
+ continue;
772
+ }
773
+ if (nextColumns[i]?.pinned === "right") {
774
+ rightBoundary = i;
775
+ } else {
776
+ break;
777
+ }
778
+ }
779
+ const nextPinned = clampedTo < leftBoundary ? "left" : clampedTo >= rightBoundary ? "right" : void 0;
780
+ if (nextPinned !== moved.pinned) {
781
+ nextColumns[clampedTo] = { ...moved, pinned: nextPinned };
782
+ }
783
+ options = { ...options, columns: nextColumns };
784
+ emit();
785
+ },
786
+ setColumnOrder(ids) {
787
+ const byId = new Map(options.columns.map((c) => [c.id, c]));
788
+ const taken = /* @__PURE__ */ new Set();
789
+ const ordered = [];
790
+ for (const id of ids) {
791
+ if (id === ROW_SELECT_COLUMN_ID || taken.has(id)) {
792
+ continue;
793
+ }
794
+ const column = byId.get(id);
795
+ if (!column) {
796
+ continue;
797
+ }
798
+ taken.add(id);
799
+ ordered.push(column);
800
+ }
801
+ for (const column of options.columns) {
802
+ if (taken.has(column.id)) {
803
+ continue;
804
+ }
805
+ taken.add(column.id);
806
+ ordered.push(column);
807
+ }
808
+ const nextColumns = groupColumnsByPin(ordered);
809
+ let changed = nextColumns.length !== options.columns.length;
810
+ if (!changed) {
811
+ for (let i = 0; i < nextColumns.length; i += 1) {
812
+ if (nextColumns[i].id !== options.columns[i].id) {
813
+ changed = true;
814
+ break;
815
+ }
816
+ }
817
+ }
818
+ if (!changed) {
819
+ return;
820
+ }
821
+ options = { ...options, columns: nextColumns };
822
+ emit();
823
+ },
824
+ setColumnPinned(columnId, pinned) {
825
+ if (columnId === ROW_SELECT_COLUMN_ID) {
826
+ return;
827
+ }
828
+ const idx = options.columns.findIndex((c) => c.id === columnId);
829
+ if (idx === -1) {
830
+ return;
831
+ }
832
+ const column = options.columns[idx];
833
+ const nextPinnedValue = pinned === "left" || pinned === "right" ? pinned : void 0;
834
+ if (column.pinned === nextPinnedValue) {
835
+ return;
836
+ }
837
+ const nextColumns = options.columns.slice();
838
+ nextColumns.splice(idx, 1);
839
+ const synthAtZero = nextColumns[0]?.id === ROW_SELECT_COLUMN_ID;
840
+ const baseStart = synthAtZero ? 1 : 0;
841
+ let boundary = baseStart;
842
+ while (boundary < nextColumns.length && nextColumns[boundary]?.pinned === "left") {
843
+ boundary += 1;
844
+ }
845
+ let rightBoundary = nextColumns.length;
846
+ while (rightBoundary > boundary && nextColumns[rightBoundary - 1]?.pinned === "right") {
847
+ rightBoundary -= 1;
848
+ }
849
+ const staysAtRightBoundary = nextPinnedValue === "right" || nextPinnedValue === void 0 && column.pinned === "right";
850
+ const insertAt = staysAtRightBoundary ? rightBoundary : boundary;
851
+ const nextColumn = {
852
+ ...column,
853
+ pinned: nextPinnedValue
854
+ };
855
+ nextColumns.splice(insertAt, 0, nextColumn);
856
+ options = { ...options, columns: nextColumns };
857
+ emit();
858
+ },
859
+ autosizeColumn(columnId, autosizeOptions) {
860
+ if (columnId === ROW_SELECT_COLUMN_ID) {
861
+ return;
862
+ }
863
+ const idx = options.columns.findIndex((c) => c.id === columnId);
864
+ if (idx === -1) {
865
+ return;
866
+ }
867
+ const column = options.columns[idx];
868
+ const probeColumns = options.columns.slice();
869
+ probeColumns[idx] = { ...column, widthPx: void 0 };
870
+ const probedOptions = { ...options, columns: probeColumns };
871
+ const probed = applyAutosize(probedOptions, autosizeOptions);
872
+ const nextWidth = probed.columns[idx]?.widthPx;
873
+ if (nextWidth === void 0 || nextWidth === column.widthPx) {
874
+ return;
875
+ }
876
+ const clamped = clampColumnWidth(nextWidth, column);
877
+ const nextColumns = options.columns.slice();
878
+ nextColumns[idx] = { ...column, widthPx: clamped };
879
+ options = { ...options, columns: nextColumns };
880
+ emit();
881
+ },
882
+ resetColumnLayout() {
883
+ const restored = inputOptions.autosize ? applyAutosize({
884
+ ...inputOptions,
885
+ columns: originalColumns.map((c) => ({ ...c }))
886
+ }, typeof inputOptions.autosize === "object" ? inputOptions.autosize : void 0) : {
887
+ ...inputOptions,
888
+ columns: originalColumns.map((c) => ({ ...c }))
889
+ };
890
+ const current = options.columns;
891
+ const next = restored.columns;
892
+ if (current.length === next.length) {
893
+ let same = true;
894
+ for (let i = 0; i < current.length; i += 1) {
895
+ const c = current[i];
896
+ const n = next[i];
897
+ if (c.id !== n.id || c.widthPx !== n.widthPx || c.pinned !== n.pinned) {
898
+ same = false;
899
+ break;
900
+ }
901
+ }
902
+ if (same) {
903
+ return;
904
+ }
905
+ }
906
+ options = { ...options, columns: next };
907
+ emit();
908
+ },
909
+ mergeColumnsFromProps(nextColumns) {
910
+ const currentById = new Map(options.columns.map((c) => [c.id, c]));
911
+ const merged = nextColumns.map((newCol) => {
912
+ const existing = currentById.get(newCol.id);
913
+ if (existing) {
914
+ return {
915
+ ...newCol,
916
+ widthPx: existing.widthPx ?? newCol.widthPx,
917
+ pinned: existing.pinned ?? newCol.pinned
918
+ };
919
+ }
920
+ return { ...newCol };
921
+ });
922
+ const grouped = groupColumnsByPin(merged);
923
+ const changed = !sameColumnLayout(options.columns, grouped);
924
+ originalColumns = groupColumnsByPin(nextColumns).map((c) => ({ ...c }));
925
+ options = { ...options, columns: grouped };
926
+ if (changed) {
927
+ emit();
928
+ }
929
+ },
257
930
  applyTransaction(transaction) {
258
931
  if (!options.getRowId) {
259
- throw new Error("applyTransaction requires getRowId on GridCoreOptions");
932
+ throw new Error("applyTransaction requires getRowId on PretableGridOptions");
260
933
  }
261
934
  const getRowId = options.getRowId;
262
935
  if (transaction.remove) {
@@ -303,6 +976,108 @@ function createGridCore(inputOptions) {
303
976
  }
304
977
  cachedVisibleRows = null;
305
978
  emit();
979
+ },
980
+ setRows(nextRows) {
981
+ options = { ...options, rows: nextRows };
982
+ sourceRows = createSourceRows(options);
983
+ sourceRowIndex.clear();
984
+ for (const entry of sourceRows) {
985
+ sourceRowIndex.set(entry.id, entry);
986
+ }
987
+ const hasRow = (id) => id != null && sourceRowIndex.has(id);
988
+ const keptRanges = selection.ranges.filter((range) => hasRow(range.startRowId) && hasRow(range.endRowId));
989
+ const anchorValid = !selection.anchor || hasRow(selection.anchor.rowId);
990
+ if (keptRanges.length !== selection.ranges.length || !anchorValid) {
991
+ selection = {
992
+ ranges: keptRanges,
993
+ anchor: anchorValid ? selection.anchor : null
994
+ };
995
+ }
996
+ if (focus.rowId !== null && !hasRow(focus.rowId)) {
997
+ focus = { rowId: null, columnId: null };
998
+ }
999
+ if (editing && !hasRow(editing.rowId)) {
1000
+ editing = null;
1001
+ }
1002
+ if (options.autosize) {
1003
+ const measured = applyAutosize({ ...options, columns: originalColumns }, typeof options.autosize === "object" ? options.autosize : void 0);
1004
+ const measuredById = new Map(measured.columns.map((column) => [column.id, column.widthPx]));
1005
+ options = {
1006
+ ...options,
1007
+ // Keyed by id, not index — `moveColumn` can leave the live order out
1008
+ // of step with `originalColumns`, and the live set may carry the
1009
+ // synthetic row-select column that never appears in props.
1010
+ columns: options.columns.map((column) => {
1011
+ if (pinnedWidthColumnIds.has(column.id)) {
1012
+ return column;
1013
+ }
1014
+ const width = measuredById.get(column.id);
1015
+ if (width === void 0 || width === column.widthPx) {
1016
+ return column;
1017
+ }
1018
+ return { ...column, widthPx: width };
1019
+ })
1020
+ };
1021
+ }
1022
+ cachedVisibleRows = null;
1023
+ emit();
1024
+ },
1025
+ beginEdit(addr, opts) {
1026
+ editing = {
1027
+ rowId: addr.rowId,
1028
+ columnId: addr.columnId,
1029
+ draft: opts?.draft,
1030
+ status: opts?.status ?? "editing"
1031
+ };
1032
+ emit();
1033
+ },
1034
+ setEditDraft(value) {
1035
+ if (!editing)
1036
+ return;
1037
+ editing = { ...editing, draft: value };
1038
+ emit();
1039
+ },
1040
+ markEditing() {
1041
+ if (!editing || editing.status !== "checking")
1042
+ return;
1043
+ editing = { ...editing, status: "editing", error: void 0 };
1044
+ emit();
1045
+ },
1046
+ markEditValidating() {
1047
+ if (!editing)
1048
+ return;
1049
+ editing = { ...editing, status: "validating", error: void 0 };
1050
+ emit();
1051
+ },
1052
+ markEditSaving() {
1053
+ if (!editing)
1054
+ return;
1055
+ editing = { ...editing, status: "saving", error: void 0 };
1056
+ emit();
1057
+ },
1058
+ markEditInvalid(message) {
1059
+ if (!editing)
1060
+ return;
1061
+ editing = { ...editing, status: "editing", error: message };
1062
+ emit();
1063
+ },
1064
+ markEditError(message) {
1065
+ if (!editing)
1066
+ return;
1067
+ editing = { ...editing, status: "error", error: message };
1068
+ emit();
1069
+ },
1070
+ commitEditSucceeded() {
1071
+ if (!editing)
1072
+ return;
1073
+ editing = null;
1074
+ emit();
1075
+ },
1076
+ cancelEdit() {
1077
+ if (!editing)
1078
+ return;
1079
+ editing = null;
1080
+ emit();
306
1081
  }
307
1082
  };
308
1083
  return store;
@@ -321,11 +1096,11 @@ function createGridCore(inputOptions) {
321
1096
  cachedDerivedFilters = filters;
322
1097
  cachedSnapshot = {
323
1098
  viewport,
324
- sort,
1099
+ sort: sort.map((entry) => ({ ...entry })),
325
1100
  filters: { ...filters },
326
1101
  selection: {
327
- rowIds: [...selection.rowIds],
328
- anchorRowId: selection.anchorRowId
1102
+ ranges: selection.ranges.map((r) => ({ ...r })),
1103
+ anchor: selection.anchor ? { ...selection.anchor } : null
329
1104
  },
330
1105
  focus,
331
1106
  totalRowCount: sourceRows.length,
@@ -333,7 +1108,8 @@ function createGridCore(inputOptions) {
333
1108
  visibleRange: {
334
1109
  start: 0,
335
1110
  end: visibleRows.length
336
- }
1111
+ },
1112
+ editing: editing ? { ...editing } : null
337
1113
  };
338
1114
  return cachedSnapshot;
339
1115
  }
@@ -347,6 +1123,74 @@ function createGridCore(inputOptions) {
347
1123
  function clamp(value, min, max) {
348
1124
  return Math.max(min, Math.min(max, value));
349
1125
  }
1126
+ function sameColumnLayout(a, b) {
1127
+ if (a.length !== b.length) {
1128
+ return false;
1129
+ }
1130
+ return a.every((left, index) => {
1131
+ const right = b[index];
1132
+ 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;
1133
+ });
1134
+ }
1135
+ function computePageStep(viewport, visibleRows) {
1136
+ if (viewport.height <= 0 || visibleRows.length === 0) {
1137
+ return 1;
1138
+ }
1139
+ const estimatedRowsPerPage = Math.max(1, Math.floor(viewport.height * 0.8 / 32));
1140
+ return Math.min(estimatedRowsPerPage, visibleRows.length);
1141
+ }
1142
+ function isFullRowRange(range, rowId, firstColumnId, lastColumnId) {
1143
+ return range.startRowId === rowId && range.endRowId === rowId && range.startColumnId === firstColumnId && range.endColumnId === lastColumnId;
1144
+ }
1145
+ function selectionsEqual(a, b) {
1146
+ if (a.ranges.length !== b.ranges.length) {
1147
+ return false;
1148
+ }
1149
+ for (let i = 0; i < a.ranges.length; i += 1) {
1150
+ const ar = a.ranges[i];
1151
+ const br = b.ranges[i];
1152
+ if (ar.startRowId !== br.startRowId || ar.endRowId !== br.endRowId || ar.startColumnId !== br.startColumnId || ar.endColumnId !== br.endColumnId) {
1153
+ return false;
1154
+ }
1155
+ }
1156
+ if (a.anchor === null && b.anchor === null) {
1157
+ return true;
1158
+ }
1159
+ if (a.anchor === null || b.anchor === null) {
1160
+ return false;
1161
+ }
1162
+ return a.anchor.rowId === b.anchor.rowId && a.anchor.columnId === b.anchor.columnId;
1163
+ }
1164
+ function sanitizeSortEntries(entries, columns) {
1165
+ return entries.filter((entry) => {
1166
+ const column = columns.find((c) => c.id === entry.columnId);
1167
+ return column !== void 0 && column.sortable !== false;
1168
+ });
1169
+ }
1170
+ function sortsEqual(a, b) {
1171
+ if (a.length !== b.length) {
1172
+ return false;
1173
+ }
1174
+ for (let i = 0; i < a.length; i += 1) {
1175
+ const ae = a[i];
1176
+ const be = b[i];
1177
+ if (ae.columnId !== be.columnId || ae.direction !== be.direction) {
1178
+ return false;
1179
+ }
1180
+ }
1181
+ return true;
1182
+ }
1183
+ function columnFilterEqual(a, b) {
1184
+ if (a.operator !== b.operator) {
1185
+ return false;
1186
+ }
1187
+ const av = a.value;
1188
+ const bv = b.value;
1189
+ if (Array.isArray(av) && Array.isArray(bv)) {
1190
+ return av.length === bv.length && av.every((v, i) => v === bv[i]);
1191
+ }
1192
+ return av === bv;
1193
+ }
350
1194
  function filtersEqual(a, b) {
351
1195
  const aKeys = Object.keys(a);
352
1196
  const bKeys = Object.keys(b);
@@ -354,7 +1198,9 @@ function filtersEqual(a, b) {
354
1198
  return false;
355
1199
  }
356
1200
  for (const key of aKeys) {
357
- if (a[key] !== b[key]) {
1201
+ const av = a[key];
1202
+ const bv = b[key];
1203
+ if (!av || !bv || !columnFilterEqual(av, bv)) {
358
1204
  return false;
359
1205
  }
360
1206
  }
@@ -363,24 +1209,49 @@ function filtersEqual(a, b) {
363
1209
 
364
1210
  // src/create-grid.ts
365
1211
  function createGrid(options) {
366
- const gridCore = createGridCore(options);
1212
+ const engine = createGridCore(options);
367
1213
  return {
368
1214
  kind: "pretable-grid",
369
1215
  get options() {
370
- return gridCore.options;
371
- },
372
- subscribe: gridCore.subscribe,
373
- getSnapshot: gridCore.getSnapshot,
374
- setSort: gridCore.setSort,
375
- setFilter: gridCore.setFilter,
376
- clearFilters: gridCore.clearFilters,
377
- replaceFilters: gridCore.replaceFilters,
378
- selectRow: gridCore.selectRow,
379
- setFocus: gridCore.setFocus,
380
- moveFocus: gridCore.moveFocus,
381
- setViewport: gridCore.setViewport,
382
- autosizeColumns: gridCore.autosizeColumns,
383
- applyTransaction: gridCore.applyTransaction
1216
+ return engine.options;
1217
+ },
1218
+ subscribe: engine.subscribe,
1219
+ getSnapshot: engine.getSnapshot,
1220
+ setSort: engine.setSort,
1221
+ replaceSort: engine.replaceSort,
1222
+ setColumnFilter: engine.setColumnFilter,
1223
+ clearFilters: engine.clearFilters,
1224
+ replaceFilters: engine.replaceFilters,
1225
+ distinctColumnValues: engine.distinctColumnValues,
1226
+ setSelection: engine.setSelection,
1227
+ selectAll: engine.selectAll,
1228
+ clearSelection: engine.clearSelection,
1229
+ addRange: engine.addRange,
1230
+ extendRangeFromAnchor: engine.extendRangeFromAnchor,
1231
+ toggleRowSelection: engine.toggleRowSelection,
1232
+ setSelectAllVisible: engine.setSelectAllVisible,
1233
+ setFocus: engine.setFocus,
1234
+ moveFocus: engine.moveFocus,
1235
+ setViewport: engine.setViewport,
1236
+ autosizeColumns: engine.autosizeColumns,
1237
+ setColumnWidth: engine.setColumnWidth,
1238
+ moveColumn: engine.moveColumn,
1239
+ setColumnOrder: engine.setColumnOrder,
1240
+ setColumnPinned: engine.setColumnPinned,
1241
+ autosizeColumn: engine.autosizeColumn,
1242
+ resetColumnLayout: engine.resetColumnLayout,
1243
+ mergeColumnsFromProps: engine.mergeColumnsFromProps,
1244
+ applyTransaction: engine.applyTransaction,
1245
+ setRows: engine.setRows,
1246
+ beginEdit: engine.beginEdit,
1247
+ setEditDraft: engine.setEditDraft,
1248
+ markEditing: engine.markEditing,
1249
+ markEditValidating: engine.markEditValidating,
1250
+ markEditSaving: engine.markEditSaving,
1251
+ markEditInvalid: engine.markEditInvalid,
1252
+ markEditError: engine.markEditError,
1253
+ commitEditSucceeded: engine.commitEditSucceeded,
1254
+ cancelEdit: engine.cancelEdit
384
1255
  };
385
1256
  }
386
1257