@iyulab/flex-table 0.48.6 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +11 -1
- package/dist/events.d.ts +199 -0
- package/dist/{flex-table-CoqeYojZ.js → flex-table-BsxF9Q3O.js} +182 -322
- package/dist/flex-table.d.ts +19 -0
- package/dist/flex-table.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/react.d.ts +32 -31
- package/dist/react.js +1 -1
- package/package.json +2 -1
- package/skills/iyulab-flex-table/references/api.md +2 -0
- package/dist/array/use-array-source.hooks.test.d.ts +0 -1
- package/dist/array/use-array-source.test.d.ts +0 -1
- package/dist/clipboard/clipboard.test.d.ts +0 -1
- package/dist/core/filtering.test.d.ts +0 -1
- package/dist/core/selection.test.d.ts +0 -1
- package/dist/core/sorting.test.d.ts +0 -1
- package/dist/core/undo.test.d.ts +0 -1
- package/dist/export/export.test.d.ts +0 -1
- package/dist/export/xlsx-deflate.test.d.ts +0 -1
- package/dist/export/xlsx-reader.test.d.ts +0 -1
- package/dist/flex-table.test.d.ts +0 -1
- package/dist/odata/index.test.d.ts +0 -1
- package/dist/odata/use-odata-source.hooks.test.d.ts +0 -1
- package/dist/odata/use-odata-source.test.d.ts +0 -1
- package/dist/react-events.test.d.ts +0 -1
- package/dist/renderers/format.test.d.ts +0 -1
- package/dist/styles/density-tokens.test.d.ts +0 -1
- package/dist/styles/token-derivation.test.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.49.0] - 2026-10-06
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Typed events.** `FlexTableEventMap` (exported, with `CellChange`) maps each of the 31 event names to
|
|
8
|
+
its `CustomEvent<detail>`, and `FlexTable` overloads `addEventListener`/`removeEventListener` with it:
|
|
9
|
+
`table.addEventListener('sort-change', (e) => e.detail.criteria)` type-checks without a cast. Before,
|
|
10
|
+
a TypeScript listener got a plain `Event`. The names stay off the global event map on purpose — several
|
|
11
|
+
are generic (`sort-change`, `selection-change`) and would collide with other libraries.
|
|
12
|
+
- The element dispatches every event through one helper keyed on the map, so a detail that drifts from
|
|
13
|
+
the documented shape no longer compiles.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **React `on*` props carry the detail types** (they were `CustomEvent<any>`). A handler that declared a
|
|
18
|
+
detail shape the event never had now fails to type-check — that is the point; handlers typed as plain
|
|
19
|
+
`CustomEvent` keep working.
|
|
20
|
+
|
|
21
|
+
### Documentation
|
|
22
|
+
|
|
23
|
+
- The README's event tables list the seven events they were missing (`row-reorder`, `data-import`,
|
|
24
|
+
`fill-handle-apply`, `find-replace`, `comment-change`, `column-visibility-change`,
|
|
25
|
+
`header-context-menu`).
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- The package no longer ships empty `.d.ts` files for its own tests.
|
|
30
|
+
|
|
3
31
|
## [0.48.6] - 2026-10-06
|
|
4
32
|
|
|
5
33
|
### Fixed
|
package/README.md
CHANGED
|
@@ -282,7 +282,10 @@ Default is `false`, matching `clear-undo-on-data-change`.
|
|
|
282
282
|
|
|
283
283
|
## Events
|
|
284
284
|
|
|
285
|
-
All events use `CustomEvent` with `bubbles: true, composed: true`.
|
|
285
|
+
All events use `CustomEvent` with `bubbles: true, composed: true`. They are typed: `FlexTableEventMap` maps
|
|
286
|
+
each name to its `CustomEvent<detail>`, and `addEventListener` on a `FlexTable` (for example from
|
|
287
|
+
`document.querySelector('flex-table')`) uses it — `table.addEventListener('sort-change', (e) => e.detail.criteria)`
|
|
288
|
+
type-checks without a cast. The React wrapper's `on*` props carry the same types.
|
|
286
289
|
|
|
287
290
|
### Cell Events
|
|
288
291
|
|
|
@@ -302,6 +305,11 @@ All events use `CustomEvent` with `bubbles: true, composed: true`.
|
|
|
302
305
|
| `row-delete` | `{ indices, rows }` | Rows deleted |
|
|
303
306
|
| `row-activate` | `{ row, index, col, key }` | Enter pressed on a non-editable cell — the grid's own contract for "activate this row" (e.g. navigate to a detail view), guaranteed even though the internal Enter handler prevents the keystroke from reliably reaching a listener the host attaches to the same element |
|
|
304
307
|
| `batch-update` | `{ changes: [{ row, key, oldValue, newValue }] }` | Batch update applied |
|
|
308
|
+
| `row-reorder` | `{ from, to }` | Row dragged to a new place (data indices) |
|
|
309
|
+
| `data-import` | `{ count }` | Rows imported from a file |
|
|
310
|
+
| `fill-handle-apply` | `{ sourceRange, targetRange, cells }` | Fill handle wrote `cells` (`{ dataRow, key, oldValue, newValue }`) |
|
|
311
|
+
| `find-replace` | `{ type, cells }` | Replace (`type: 'replace'`) or replace-all from the find panel; `cells` are `{ row, col, oldValue, newValue }` with `col` the column key |
|
|
312
|
+
| `comment-change` | `{ dataIndex, colKey, text }` | Cell comment set, changed or removed (`text: null`) |
|
|
305
313
|
|
|
306
314
|
### Column Events
|
|
307
315
|
|
|
@@ -312,6 +320,8 @@ All events use `CustomEvent` with `bubbles: true, composed: true`.
|
|
|
312
320
|
| `column-reorder` | `{ key, oldIndex, newIndex }` | Column moved |
|
|
313
321
|
| `column-resize` | `{ key, width, colIndex }` | Column resized (drag, auto-fit, or keyboard) |
|
|
314
322
|
| `column-select` | `{ colIndex, key, rowCount }` | Entire column selected |
|
|
323
|
+
| `column-visibility-change` | `{ key, hidden }` | Column hidden or shown |
|
|
324
|
+
| `header-context-menu` | `{ key, label, x, y }` | Right-click on a column header |
|
|
315
325
|
|
|
316
326
|
### Sort & Filter Events
|
|
317
327
|
|
package/dist/events.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { CellPosition, CellRange } from './core/selection.js';
|
|
2
|
+
import type { SortCriteria } from './core/sorting.js';
|
|
3
|
+
import type { ColumnDefinition, DataRow } from './models/types.js';
|
|
4
|
+
/** One cell a bulk operation wrote: data row index, column key, value before and after. */
|
|
5
|
+
export interface CellChange {
|
|
6
|
+
row: number;
|
|
7
|
+
key: string;
|
|
8
|
+
oldValue: unknown;
|
|
9
|
+
newValue: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Every event `<flex-table>` dispatches, by name. All bubble and are composed.
|
|
13
|
+
*
|
|
14
|
+
* This map is the single source: the element dispatches through a typed helper keyed on it, so a
|
|
15
|
+
* detail that drifts from what is written here fails to compile. Listeners get the same types —
|
|
16
|
+
* `table.addEventListener('sort-change', (e) => e.detail.criteria)` — and so does the React
|
|
17
|
+
* wrapper's `onSortChange`. The names are element-scoped (not on the global event map) because
|
|
18
|
+
* several are generic (`sort-change`, `selection-change`) and other libraries use them too.
|
|
19
|
+
*/
|
|
20
|
+
export interface FlexTableEventMap {
|
|
21
|
+
/** Row selection changed (`selectable`). Indices are data indices. */
|
|
22
|
+
'selection-change': CustomEvent<{
|
|
23
|
+
selectedIndices: number[];
|
|
24
|
+
selectedRows: DataRow[];
|
|
25
|
+
}>;
|
|
26
|
+
/** After any undoable change, undo or redo. */
|
|
27
|
+
'undo-state-change': CustomEvent<{
|
|
28
|
+
canUndo: boolean;
|
|
29
|
+
canRedo: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
/** The set of column filters changed. `filteredCount` is the rows left visible. */
|
|
32
|
+
'filter-change': CustomEvent<{
|
|
33
|
+
keys: string[];
|
|
34
|
+
filteredCount: number;
|
|
35
|
+
}>;
|
|
36
|
+
/** A column filter predicate threw for a row; the row is kept. */
|
|
37
|
+
'filter-error': CustomEvent<{
|
|
38
|
+
error: unknown;
|
|
39
|
+
row: DataRow;
|
|
40
|
+
filterKey: string;
|
|
41
|
+
}>;
|
|
42
|
+
'column-add': CustomEvent<{
|
|
43
|
+
column: ColumnDefinition;
|
|
44
|
+
index: number;
|
|
45
|
+
}>;
|
|
46
|
+
'column-delete': CustomEvent<{
|
|
47
|
+
column: ColumnDefinition;
|
|
48
|
+
key: string;
|
|
49
|
+
index: number;
|
|
50
|
+
}>;
|
|
51
|
+
'column-reorder': CustomEvent<{
|
|
52
|
+
key: string;
|
|
53
|
+
oldIndex: number;
|
|
54
|
+
newIndex: number;
|
|
55
|
+
}>;
|
|
56
|
+
'column-visibility-change': CustomEvent<{
|
|
57
|
+
key: string;
|
|
58
|
+
hidden: boolean;
|
|
59
|
+
}>;
|
|
60
|
+
/** A column was resized — during the drag and once more when it ends. `colIndex` is the visible index. */
|
|
61
|
+
'column-resize': CustomEvent<{
|
|
62
|
+
key: string;
|
|
63
|
+
width: number;
|
|
64
|
+
colIndex: number;
|
|
65
|
+
}>;
|
|
66
|
+
/** A whole column was selected. `colIndex` is the visible index. */
|
|
67
|
+
'column-select': CustomEvent<{
|
|
68
|
+
colIndex: number;
|
|
69
|
+
key: string | undefined;
|
|
70
|
+
rowCount: number;
|
|
71
|
+
}>;
|
|
72
|
+
'row-add': CustomEvent<{
|
|
73
|
+
row: DataRow;
|
|
74
|
+
index: number;
|
|
75
|
+
}>;
|
|
76
|
+
'row-delete': CustomEvent<{
|
|
77
|
+
indices: number[];
|
|
78
|
+
rows: DataRow[];
|
|
79
|
+
}>;
|
|
80
|
+
/** A row was dragged to a new place. Both are data indices. */
|
|
81
|
+
'row-reorder': CustomEvent<{
|
|
82
|
+
from: number;
|
|
83
|
+
to: number;
|
|
84
|
+
}>;
|
|
85
|
+
/** Enter on a non-editable cell — "activate this row". `index` is the data index, `col` the visible column index. */
|
|
86
|
+
'row-activate': CustomEvent<{
|
|
87
|
+
row: DataRow;
|
|
88
|
+
index: number;
|
|
89
|
+
col: number;
|
|
90
|
+
key: string | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
/** `batchUpdate()` applied its changes. */
|
|
93
|
+
'batch-update': CustomEvent<{
|
|
94
|
+
changes: CellChange[];
|
|
95
|
+
}>;
|
|
96
|
+
/** The active cell moved; `null` when there is none. */
|
|
97
|
+
'cell-select': CustomEvent<CellPosition | null>;
|
|
98
|
+
/** `row` is the data index, `col` the visible column index. */
|
|
99
|
+
'cell-edit-start': CustomEvent<{
|
|
100
|
+
row: number;
|
|
101
|
+
col: number;
|
|
102
|
+
key: string;
|
|
103
|
+
value: unknown;
|
|
104
|
+
}>;
|
|
105
|
+
'cell-edit-commit': CustomEvent<{
|
|
106
|
+
row: number;
|
|
107
|
+
col: number;
|
|
108
|
+
key: string;
|
|
109
|
+
oldValue: unknown;
|
|
110
|
+
newValue: unknown;
|
|
111
|
+
}>;
|
|
112
|
+
/** `row` and `col` are visible positions. */
|
|
113
|
+
'cell-edit-cancel': CustomEvent<{
|
|
114
|
+
row: number;
|
|
115
|
+
col: number;
|
|
116
|
+
}>;
|
|
117
|
+
/** An edit was rejected (type, `required` or `validator`); the value was not written. */
|
|
118
|
+
'validation-error': CustomEvent<{
|
|
119
|
+
row: number;
|
|
120
|
+
col: number;
|
|
121
|
+
key: string;
|
|
122
|
+
value: unknown;
|
|
123
|
+
error: string;
|
|
124
|
+
}>;
|
|
125
|
+
'comment-change': CustomEvent<{
|
|
126
|
+
dataIndex: number;
|
|
127
|
+
colKey: string;
|
|
128
|
+
text: string | null;
|
|
129
|
+
}>;
|
|
130
|
+
/** Rows were imported from a file; `count` is how many. */
|
|
131
|
+
'data-import': CustomEvent<{
|
|
132
|
+
count: number;
|
|
133
|
+
}>;
|
|
134
|
+
'sort-change': CustomEvent<{
|
|
135
|
+
criteria: SortCriteria[];
|
|
136
|
+
}>;
|
|
137
|
+
/**
|
|
138
|
+
* Right-click on a body cell. Cancelable: `preventDefault()` keeps the built-in menu closed so you
|
|
139
|
+
* can show your own. `row` is the data index, `col` the visible column index.
|
|
140
|
+
*/
|
|
141
|
+
'context-menu': CustomEvent<{
|
|
142
|
+
x: number;
|
|
143
|
+
y: number;
|
|
144
|
+
row: number;
|
|
145
|
+
col: number;
|
|
146
|
+
key: string;
|
|
147
|
+
value: unknown;
|
|
148
|
+
rowData: DataRow | undefined;
|
|
149
|
+
}>;
|
|
150
|
+
'header-context-menu': CustomEvent<{
|
|
151
|
+
key: string;
|
|
152
|
+
label: string;
|
|
153
|
+
x: number;
|
|
154
|
+
y: number;
|
|
155
|
+
}>;
|
|
156
|
+
/** Text reached the clipboard (`range` is in visible positions). */
|
|
157
|
+
'clipboard-copy': CustomEvent<{
|
|
158
|
+
range: CellRange;
|
|
159
|
+
text: string;
|
|
160
|
+
}>;
|
|
161
|
+
/** Like `clipboard-copy`, and the range was cleared afterwards. */
|
|
162
|
+
'clipboard-cut': CustomEvent<{
|
|
163
|
+
range: CellRange;
|
|
164
|
+
text: string;
|
|
165
|
+
}>;
|
|
166
|
+
/** A paste was applied. `addedRows` counts rows appended to fit it. */
|
|
167
|
+
'clipboard-paste': CustomEvent<{
|
|
168
|
+
changes: Array<CellChange & {
|
|
169
|
+
col: number;
|
|
170
|
+
}>;
|
|
171
|
+
addedRows: number;
|
|
172
|
+
}>;
|
|
173
|
+
/** The clipboard refused a copy or paste (permission, focus, no secure context). */
|
|
174
|
+
'clipboard-error': CustomEvent<{
|
|
175
|
+
action: 'copy' | 'paste';
|
|
176
|
+
error: unknown;
|
|
177
|
+
}>;
|
|
178
|
+
/** The fill handle wrote `cells` (data row index and key). */
|
|
179
|
+
'fill-handle-apply': CustomEvent<{
|
|
180
|
+
sourceRange: CellRange;
|
|
181
|
+
targetRange: CellRange;
|
|
182
|
+
cells: Array<{
|
|
183
|
+
dataRow: number;
|
|
184
|
+
key: string;
|
|
185
|
+
oldValue: unknown;
|
|
186
|
+
newValue: unknown;
|
|
187
|
+
}>;
|
|
188
|
+
}>;
|
|
189
|
+
/** Replace or replace-all from the find panel. `row` is the data index, `col` the column key. */
|
|
190
|
+
'find-replace': CustomEvent<{
|
|
191
|
+
type: 'replace' | 'replace-all';
|
|
192
|
+
cells: Array<{
|
|
193
|
+
row: number;
|
|
194
|
+
col: string;
|
|
195
|
+
oldValue: unknown;
|
|
196
|
+
newValue: unknown;
|
|
197
|
+
}>;
|
|
198
|
+
}>;
|
|
199
|
+
}
|
|
@@ -1973,14 +1973,10 @@ var K = {
|
|
|
1973
1973
|
}
|
|
1974
1974
|
_dispatchRowSelectionEvent() {
|
|
1975
1975
|
let { selectedIndices: e, selectedRows: t } = this.getSelectedRows();
|
|
1976
|
-
this.
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
},
|
|
1981
|
-
bubbles: !0,
|
|
1982
|
-
composed: !0
|
|
1983
|
-
}));
|
|
1976
|
+
this._emit("selection-change", {
|
|
1977
|
+
selectedIndices: e,
|
|
1978
|
+
selectedRows: t
|
|
1979
|
+
});
|
|
1984
1980
|
}
|
|
1985
1981
|
setFilter(e, t) {
|
|
1986
1982
|
this._filters = this._filters.filter((t) => t.key !== e), this._filters.push({
|
|
@@ -2010,25 +2006,26 @@ var K = {
|
|
|
2010
2006
|
clearUndoHistory() {
|
|
2011
2007
|
this._undo.clear(), this._dispatchUndoStateEvent();
|
|
2012
2008
|
}
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
detail:
|
|
2016
|
-
canUndo: this.canUndo,
|
|
2017
|
-
canRedo: this.canRedo
|
|
2018
|
-
},
|
|
2009
|
+
_emit(e, t, n) {
|
|
2010
|
+
let r = new CustomEvent(e, {
|
|
2011
|
+
detail: t,
|
|
2019
2012
|
bubbles: !0,
|
|
2020
|
-
composed: !0
|
|
2021
|
-
|
|
2013
|
+
composed: !0,
|
|
2014
|
+
...n
|
|
2015
|
+
});
|
|
2016
|
+
return this.dispatchEvent(r), r;
|
|
2017
|
+
}
|
|
2018
|
+
_dispatchUndoStateEvent() {
|
|
2019
|
+
this._emit("undo-state-change", {
|
|
2020
|
+
canUndo: this.canUndo,
|
|
2021
|
+
canRedo: this.canRedo
|
|
2022
|
+
});
|
|
2022
2023
|
}
|
|
2023
2024
|
_dispatchFilterEvent() {
|
|
2024
|
-
this.
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
},
|
|
2029
|
-
bubbles: !0,
|
|
2030
|
-
composed: !0
|
|
2031
|
-
}));
|
|
2025
|
+
this._emit("filter-change", {
|
|
2026
|
+
keys: this.filterKeys,
|
|
2027
|
+
filteredCount: this.filteredRowCount
|
|
2028
|
+
});
|
|
2032
2029
|
}
|
|
2033
2030
|
addColumn(e, t) {
|
|
2034
2031
|
let n = t ?? this.columns.length;
|
|
@@ -2048,14 +2045,10 @@ var K = {
|
|
|
2048
2045
|
...this.columns.slice(n)
|
|
2049
2046
|
], this.requestUpdate();
|
|
2050
2047
|
}
|
|
2051
|
-
}), this.requestUpdate(), this.
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
},
|
|
2056
|
-
bubbles: !0,
|
|
2057
|
-
composed: !0
|
|
2058
|
-
})), this._dispatchUndoStateEvent(), e;
|
|
2048
|
+
}), this.requestUpdate(), this._emit("column-add", {
|
|
2049
|
+
column: e,
|
|
2050
|
+
index: n
|
|
2051
|
+
}), this._dispatchUndoStateEvent(), e;
|
|
2059
2052
|
}
|
|
2060
2053
|
deleteColumn(e) {
|
|
2061
2054
|
let t = this.columns.findIndex((t) => t.key === e);
|
|
@@ -2073,15 +2066,11 @@ var K = {
|
|
|
2073
2066
|
redo: () => {
|
|
2074
2067
|
this._filters = this._filters.filter((t) => t.key !== e), this._sortCriteria = this._sortCriteria.filter((t) => t.key !== e), this._columnWidths.delete(e), this.columns = this.columns.filter((t) => t.key !== e), this.requestUpdate();
|
|
2075
2068
|
}
|
|
2076
|
-
}), this._activeCell && this._activeCell.col >= this.visibleColumns.length && (this._selection.clear(), this._activeCell = null), this.requestUpdate(), this.
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
},
|
|
2082
|
-
bubbles: !0,
|
|
2083
|
-
composed: !0
|
|
2084
|
-
})), this._dispatchUndoStateEvent();
|
|
2069
|
+
}), this._activeCell && this._activeCell.col >= this.visibleColumns.length && (this._selection.clear(), this._activeCell = null), this.requestUpdate(), this._emit("column-delete", {
|
|
2070
|
+
column: n,
|
|
2071
|
+
key: e,
|
|
2072
|
+
index: t
|
|
2073
|
+
}), this._dispatchUndoStateEvent();
|
|
2085
2074
|
}
|
|
2086
2075
|
moveColumn(e, t) {
|
|
2087
2076
|
let n = this.columns.findIndex((t) => t.key === e);
|
|
@@ -2099,15 +2088,11 @@ var K = {
|
|
|
2099
2088
|
let e = [...this.columns];
|
|
2100
2089
|
e.splice(n, 1), e.splice(r, 0, i), this.columns = e, this.requestUpdate();
|
|
2101
2090
|
}
|
|
2102
|
-
}), this.requestUpdate(), this.
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
},
|
|
2108
|
-
bubbles: !0,
|
|
2109
|
-
composed: !0
|
|
2110
|
-
})), this._dispatchUndoStateEvent();
|
|
2091
|
+
}), this.requestUpdate(), this._emit("column-reorder", {
|
|
2092
|
+
key: e,
|
|
2093
|
+
oldIndex: n,
|
|
2094
|
+
newIndex: r
|
|
2095
|
+
}), this._dispatchUndoStateEvent();
|
|
2111
2096
|
}
|
|
2112
2097
|
hideColumn(e) {
|
|
2113
2098
|
let t = this.columns.findIndex((t) => t.key === e);
|
|
@@ -2142,14 +2127,10 @@ var K = {
|
|
|
2142
2127
|
n !== -1 && (this.columns = this.columns.map((e, r) => r === n ? {
|
|
2143
2128
|
...e,
|
|
2144
2129
|
hidden: t
|
|
2145
|
-
} : e), this.
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
},
|
|
2150
|
-
bubbles: !0,
|
|
2151
|
-
composed: !0
|
|
2152
|
-
})));
|
|
2130
|
+
} : e), this._emit("column-visibility-change", {
|
|
2131
|
+
key: e,
|
|
2132
|
+
hidden: t
|
|
2133
|
+
}));
|
|
2153
2134
|
}
|
|
2154
2135
|
getHiddenColumns() {
|
|
2155
2136
|
return this.columns.filter((e) => e.hidden);
|
|
@@ -2165,14 +2146,10 @@ var K = {
|
|
|
2165
2146
|
redo: () => {
|
|
2166
2147
|
this.data.splice(r, 0, n), this.requestUpdate();
|
|
2167
2148
|
}
|
|
2168
|
-
}), this.requestUpdate(), this.
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
},
|
|
2173
|
-
bubbles: !0,
|
|
2174
|
-
composed: !0
|
|
2175
|
-
})), this._dispatchUndoStateEvent(), n;
|
|
2149
|
+
}), this.requestUpdate(), this._emit("row-add", {
|
|
2150
|
+
row: n,
|
|
2151
|
+
index: r
|
|
2152
|
+
}), this._dispatchUndoStateEvent(), n;
|
|
2176
2153
|
}
|
|
2177
2154
|
deleteRows(e) {
|
|
2178
2155
|
let t = e ?? this._getSelectedDataRows();
|
|
@@ -2198,14 +2175,10 @@ var K = {
|
|
|
2198
2175
|
let e = this._toDataIndex(this._activeCell.row);
|
|
2199
2176
|
t.includes(e) && (this._selection.clear(), this._activeCell = null);
|
|
2200
2177
|
}
|
|
2201
|
-
this.requestUpdate(), this.
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
},
|
|
2206
|
-
bubbles: !0,
|
|
2207
|
-
composed: !0
|
|
2208
|
-
})), this._dispatchUndoStateEvent();
|
|
2178
|
+
this.requestUpdate(), this._emit("row-delete", {
|
|
2179
|
+
indices: r.map((e) => e.index),
|
|
2180
|
+
rows: r.map((e) => e.row)
|
|
2181
|
+
}), this._dispatchUndoStateEvent();
|
|
2209
2182
|
}
|
|
2210
2183
|
}
|
|
2211
2184
|
updateRows(e) {
|
|
@@ -2231,11 +2204,7 @@ var K = {
|
|
|
2231
2204
|
for (let e of t) this.data[e.row][e.key] = e.newValue;
|
|
2232
2205
|
this.requestUpdate();
|
|
2233
2206
|
}
|
|
2234
|
-
}), this.requestUpdate(), this.
|
|
2235
|
-
detail: { changes: t },
|
|
2236
|
-
bubbles: !0,
|
|
2237
|
-
composed: !0
|
|
2238
|
-
})), this._dispatchUndoStateEvent());
|
|
2207
|
+
}), this.requestUpdate(), this._emit("batch-update", { changes: t }), this._dispatchUndoStateEvent());
|
|
2239
2208
|
}
|
|
2240
2209
|
_createEmptyRow() {
|
|
2241
2210
|
let e = {};
|
|
@@ -2298,15 +2267,11 @@ var K = {
|
|
|
2298
2267
|
let n = this._comments.get(e);
|
|
2299
2268
|
n && (n.delete(t), n.size === 0 && this._comments.delete(e));
|
|
2300
2269
|
}
|
|
2301
|
-
this.
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
},
|
|
2307
|
-
bubbles: !0,
|
|
2308
|
-
composed: !0
|
|
2309
|
-
})), this.requestUpdate();
|
|
2270
|
+
this._emit("comment-change", {
|
|
2271
|
+
dataIndex: e,
|
|
2272
|
+
colKey: t,
|
|
2273
|
+
text: n ?? null
|
|
2274
|
+
}), this.requestUpdate();
|
|
2310
2275
|
}
|
|
2311
2276
|
getComment(e, t) {
|
|
2312
2277
|
return this._comments.get(e)?.get(t) ?? null;
|
|
@@ -2360,11 +2325,7 @@ var K = {
|
|
|
2360
2325
|
redo: () => {
|
|
2361
2326
|
this.data = n, this.requestUpdate();
|
|
2362
2327
|
}
|
|
2363
|
-
}), this.
|
|
2364
|
-
detail: { count: n.length },
|
|
2365
|
-
bubbles: !0,
|
|
2366
|
-
composed: !0
|
|
2367
|
-
}));
|
|
2328
|
+
}), this._emit("data-import", { count: n.length });
|
|
2368
2329
|
}
|
|
2369
2330
|
_applyImportedRows(e) {
|
|
2370
2331
|
if (e.length === 0) return;
|
|
@@ -2385,11 +2346,7 @@ var K = {
|
|
|
2385
2346
|
redo: () => {
|
|
2386
2347
|
this.data = r, this.requestUpdate();
|
|
2387
2348
|
}
|
|
2388
|
-
}), this.
|
|
2389
|
-
detail: { count: r.length },
|
|
2390
|
-
bubbles: !0,
|
|
2391
|
-
composed: !0
|
|
2392
|
-
}));
|
|
2349
|
+
}), this._emit("data-import", { count: r.length });
|
|
2393
2350
|
}
|
|
2394
2351
|
_buildHeaderColumnMap(e) {
|
|
2395
2352
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -2528,15 +2485,11 @@ var K = {
|
|
|
2528
2485
|
return;
|
|
2529
2486
|
}
|
|
2530
2487
|
if (this._filteredIndices = ce(this.data, this._filters, (e, t, n) => {
|
|
2531
|
-
this.
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
},
|
|
2537
|
-
bubbles: !0,
|
|
2538
|
-
composed: !0
|
|
2539
|
-
}));
|
|
2488
|
+
this._emit("filter-error", {
|
|
2489
|
+
error: e,
|
|
2490
|
+
row: t,
|
|
2491
|
+
filterKey: n.key
|
|
2492
|
+
});
|
|
2540
2493
|
}), this._filters.length === 0 && this._sortCriteria.length === 0) this._sortedIndices = Array.from({ length: this.data.length }, (e, t) => t);
|
|
2541
2494
|
else if (this._sortCriteria.length === 0) this._sortedIndices = [...this._filteredIndices];
|
|
2542
2495
|
else {
|
|
@@ -2584,21 +2537,16 @@ var K = {
|
|
|
2584
2537
|
if (r < 0 || a < 0) return;
|
|
2585
2538
|
let o = this._toDataIndex(a), s = this.visibleColumns[r];
|
|
2586
2539
|
if (!s) return;
|
|
2587
|
-
let c =
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
bubbles: !0,
|
|
2598
|
-
composed: !0,
|
|
2599
|
-
cancelable: !0
|
|
2600
|
-
});
|
|
2601
|
-
this.dispatchEvent(c), this._cancelCommentPopup(), this.showContextMenu && !c.defaultPrevented && (this._bodyContextMenu = {
|
|
2540
|
+
let c = this._emit("context-menu", {
|
|
2541
|
+
x: e.clientX,
|
|
2542
|
+
y: e.clientY,
|
|
2543
|
+
row: o,
|
|
2544
|
+
col: r,
|
|
2545
|
+
key: s.key,
|
|
2546
|
+
value: this.data[o]?.[s.key],
|
|
2547
|
+
rowData: this.data[o]
|
|
2548
|
+
}, { cancelable: !0 });
|
|
2549
|
+
this._cancelCommentPopup(), this.showContextMenu && !c.defaultPrevented && (this._bodyContextMenu = {
|
|
2602
2550
|
rowIndex: a,
|
|
2603
2551
|
colIndex: r,
|
|
2604
2552
|
dataIndex: o,
|
|
@@ -2651,16 +2599,12 @@ var K = {
|
|
|
2651
2599
|
_fireRowActivate(e) {
|
|
2652
2600
|
if (!this._activeCell) return;
|
|
2653
2601
|
let t = this._toDataIndex(this._activeCell.row), n = this.data[t];
|
|
2654
|
-
n && this.
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
},
|
|
2661
|
-
bubbles: !0,
|
|
2662
|
-
composed: !0
|
|
2663
|
-
}));
|
|
2602
|
+
n && this._emit("row-activate", {
|
|
2603
|
+
row: n,
|
|
2604
|
+
index: t,
|
|
2605
|
+
col: this._activeCell.col,
|
|
2606
|
+
key: e?.key
|
|
2607
|
+
});
|
|
2664
2608
|
}
|
|
2665
2609
|
_startEdit() {
|
|
2666
2610
|
if (!this._activeCell) return;
|
|
@@ -2672,16 +2616,12 @@ var K = {
|
|
|
2672
2616
|
return;
|
|
2673
2617
|
}
|
|
2674
2618
|
let t = this._toDataIndex(this._activeCell.row), n = this.data[t];
|
|
2675
|
-
this._editing.start(this._activeCell, n[e.key]), this._editingCell = { ...this._activeCell }, this.
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
},
|
|
2682
|
-
bubbles: !0,
|
|
2683
|
-
composed: !0
|
|
2684
|
-
}));
|
|
2619
|
+
this._editing.start(this._activeCell, n[e.key]), this._editingCell = { ...this._activeCell }, this._emit("cell-edit-start", {
|
|
2620
|
+
row: t,
|
|
2621
|
+
col: this._activeCell.col,
|
|
2622
|
+
key: e.key,
|
|
2623
|
+
value: n[e.key]
|
|
2624
|
+
});
|
|
2685
2625
|
}
|
|
2686
2626
|
_commitEdit() {
|
|
2687
2627
|
if (!this._editing.current) return;
|
|
@@ -2722,48 +2662,36 @@ var K = {
|
|
|
2722
2662
|
let { row: n, col: r } = t.position, i = this._toDataIndex(n), a = this.visibleColumns[r], o = t.originalValue;
|
|
2723
2663
|
if (a.autocomplete === "strict" && e != null && e !== "" && !this._getAutocompleteCandidates(a, "").includes(String(e))) {
|
|
2724
2664
|
let t = k("notInList");
|
|
2725
|
-
this._markCellInvalid(n, r, t), this.
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
},
|
|
2733
|
-
bubbles: !0,
|
|
2734
|
-
composed: !0
|
|
2735
|
-
}));
|
|
2665
|
+
this._markCellInvalid(n, r, t), this._emit("validation-error", {
|
|
2666
|
+
row: i,
|
|
2667
|
+
col: r,
|
|
2668
|
+
key: a.key,
|
|
2669
|
+
value: e,
|
|
2670
|
+
error: t
|
|
2671
|
+
});
|
|
2736
2672
|
return;
|
|
2737
2673
|
}
|
|
2738
2674
|
if (a.type === "number" && typeof e == "string" || a.type === "date" && typeof e == "string" && f(e) === null || a.type === "datetime" && typeof e == "string" && p(e) === null) {
|
|
2739
2675
|
let t = k(a.type === "number" ? "notANumber" : a.type === "date" ? "notADate" : "notADateTime");
|
|
2740
|
-
this._markCellInvalid(n, r, t), this.
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
},
|
|
2748
|
-
bubbles: !0,
|
|
2749
|
-
composed: !0
|
|
2750
|
-
}));
|
|
2676
|
+
this._markCellInvalid(n, r, t), this._emit("validation-error", {
|
|
2677
|
+
row: i,
|
|
2678
|
+
col: r,
|
|
2679
|
+
key: a.key,
|
|
2680
|
+
value: e,
|
|
2681
|
+
error: t
|
|
2682
|
+
});
|
|
2751
2683
|
return;
|
|
2752
2684
|
}
|
|
2753
2685
|
if (a.validator) {
|
|
2754
2686
|
let t = a.validator(e, this.data[i], a);
|
|
2755
2687
|
if (t) {
|
|
2756
|
-
this._markCellInvalid(n, r, t), this.
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
},
|
|
2764
|
-
bubbles: !0,
|
|
2765
|
-
composed: !0
|
|
2766
|
-
}));
|
|
2688
|
+
this._markCellInvalid(n, r, t), this._emit("validation-error", {
|
|
2689
|
+
row: i,
|
|
2690
|
+
col: r,
|
|
2691
|
+
key: a.key,
|
|
2692
|
+
value: e,
|
|
2693
|
+
error: t
|
|
2694
|
+
});
|
|
2767
2695
|
return;
|
|
2768
2696
|
}
|
|
2769
2697
|
}
|
|
@@ -2775,29 +2703,21 @@ var K = {
|
|
|
2775
2703
|
redo: () => {
|
|
2776
2704
|
this.data[i][a.key] = e, this.requestUpdate();
|
|
2777
2705
|
}
|
|
2778
|
-
}), this.requestUpdate(), this.
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
},
|
|
2786
|
-
bubbles: !0,
|
|
2787
|
-
composed: !0
|
|
2788
|
-
})), this._dispatchUndoStateEvent();
|
|
2706
|
+
}), this.requestUpdate(), this._emit("cell-edit-commit", {
|
|
2707
|
+
row: i,
|
|
2708
|
+
col: r,
|
|
2709
|
+
key: a.key,
|
|
2710
|
+
oldValue: o,
|
|
2711
|
+
newValue: e
|
|
2712
|
+
}), this._dispatchUndoStateEvent();
|
|
2789
2713
|
}
|
|
2790
2714
|
_cancelEdit() {
|
|
2791
2715
|
this._autocompleteState = null;
|
|
2792
2716
|
let e = this._editing.cancel();
|
|
2793
|
-
this._editingCell = null, e && this.
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
},
|
|
2798
|
-
bubbles: !0,
|
|
2799
|
-
composed: !0
|
|
2800
|
-
}));
|
|
2717
|
+
this._editingCell = null, e && this._emit("cell-edit-cancel", {
|
|
2718
|
+
row: e.position.row,
|
|
2719
|
+
col: e.position.col
|
|
2720
|
+
});
|
|
2801
2721
|
}
|
|
2802
2722
|
_onEditorKeyDown(e) {
|
|
2803
2723
|
if (_(e)) return;
|
|
@@ -2942,15 +2862,11 @@ var K = {
|
|
|
2942
2862
|
let n = this.visibleColumns.findIndex((t) => t.key === e), r = this.visibleColumns[n];
|
|
2943
2863
|
if (!r) return;
|
|
2944
2864
|
let i = this._columnWidths.get(r.key) ?? r.width ?? q, a = r.minWidth ?? J, o = Math.max(a, i + t);
|
|
2945
|
-
this._columnWidths.set(r.key, o), this.requestUpdate(), this.
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
},
|
|
2951
|
-
bubbles: !0,
|
|
2952
|
-
composed: !0
|
|
2953
|
-
}));
|
|
2865
|
+
this._columnWidths.set(r.key, o), this.requestUpdate(), this._emit("column-resize", {
|
|
2866
|
+
key: r.key,
|
|
2867
|
+
width: o,
|
|
2868
|
+
colIndex: n
|
|
2869
|
+
});
|
|
2954
2870
|
}
|
|
2955
2871
|
_handleNavigation(e) {
|
|
2956
2872
|
switch (e.key) {
|
|
@@ -2987,24 +2903,16 @@ var K = {
|
|
|
2987
2903
|
}
|
|
2988
2904
|
}
|
|
2989
2905
|
_clipboardError(e, t) {
|
|
2990
|
-
this.
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
},
|
|
2995
|
-
bubbles: !0,
|
|
2996
|
-
composed: !0
|
|
2997
|
-
}));
|
|
2906
|
+
this._emit("clipboard-error", {
|
|
2907
|
+
action: e,
|
|
2908
|
+
error: t
|
|
2909
|
+
});
|
|
2998
2910
|
}
|
|
2999
2911
|
_afterCopy(e, t, n) {
|
|
3000
|
-
n && this._clearRange(e), this.
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
},
|
|
3005
|
-
bubbles: !0,
|
|
3006
|
-
composed: !0
|
|
3007
|
-
}));
|
|
2912
|
+
n && this._clearRange(e), this._emit(n ? "clipboard-cut" : "clipboard-copy", {
|
|
2913
|
+
range: e,
|
|
2914
|
+
text: t
|
|
2915
|
+
});
|
|
3008
2916
|
}
|
|
3009
2917
|
_pasteText(e) {
|
|
3010
2918
|
if (!this._activeCell) return;
|
|
@@ -3026,14 +2934,10 @@ var K = {
|
|
|
3026
2934
|
}
|
|
3027
2935
|
}), this._dispatchUndoStateEvent();
|
|
3028
2936
|
}
|
|
3029
|
-
this.requestUpdate(), this.
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
},
|
|
3034
|
-
bubbles: !0,
|
|
3035
|
-
composed: !0
|
|
3036
|
-
}));
|
|
2937
|
+
this.requestUpdate(), this._emit("clipboard-paste", {
|
|
2938
|
+
changes: r,
|
|
2939
|
+
addedRows: n.length
|
|
2940
|
+
});
|
|
3037
2941
|
}
|
|
3038
2942
|
_selectPastedRange(e, t) {
|
|
3039
2943
|
let n = Math.max(...t.map((e) => e.length)), r = Math.min(e.row + t.length, this._visibleRowCount) - 1, i = Math.min(e.col + n, this.visibleColumns.length) - 1;
|
|
@@ -3203,11 +3107,7 @@ var K = {
|
|
|
3203
3107
|
i < this.scrollLeft ? this.scrollLeft = i : a > this.scrollLeft + this.clientWidth && (this.scrollLeft = a - this.clientWidth);
|
|
3204
3108
|
}
|
|
3205
3109
|
_dispatchSelectionEvent() {
|
|
3206
|
-
this.
|
|
3207
|
-
detail: this._activeCell ? { ...this._activeCell } : null,
|
|
3208
|
-
bubbles: !0,
|
|
3209
|
-
composed: !0
|
|
3210
|
-
}));
|
|
3110
|
+
this._emit("cell-select", this._activeCell ? { ...this._activeCell } : null);
|
|
3211
3111
|
}
|
|
3212
3112
|
_onHeaderClick(t, n) {
|
|
3213
3113
|
if (this._wasHeaderDrag) {
|
|
@@ -3219,26 +3119,18 @@ var K = {
|
|
|
3219
3119
|
this._selectColumn(r);
|
|
3220
3120
|
return;
|
|
3221
3121
|
}
|
|
3222
|
-
n.sortable !== !1 && (this._sortCriteria = e(this._sortCriteria, n.key, t.shiftKey), this.dataMode !== "server" && this._recomputeView(), this.requestUpdate(), this.
|
|
3223
|
-
detail: { criteria: [...this._sortCriteria] },
|
|
3224
|
-
bubbles: !0,
|
|
3225
|
-
composed: !0
|
|
3226
|
-
})));
|
|
3122
|
+
n.sortable !== !1 && (this._sortCriteria = e(this._sortCriteria, n.key, t.shiftKey), this.dataMode !== "server" && this._recomputeView(), this.requestUpdate(), this._emit("sort-change", { criteria: [...this._sortCriteria] }));
|
|
3227
3123
|
}
|
|
3228
3124
|
_selectColumn(e) {
|
|
3229
3125
|
let t = this._visibleRowCount;
|
|
3230
3126
|
t === 0 || e < 0 || (this._selection.setActive(0, e), this._selection.setActiveWithRange(t - 1, e), this._activeCell = {
|
|
3231
3127
|
row: 0,
|
|
3232
3128
|
col: e
|
|
3233
|
-
}, this.requestUpdate(), this.
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
},
|
|
3239
|
-
bubbles: !0,
|
|
3240
|
-
composed: !0
|
|
3241
|
-
})));
|
|
3129
|
+
}, this.requestUpdate(), this._emit("column-select", {
|
|
3130
|
+
colIndex: e,
|
|
3131
|
+
key: this.visibleColumns[e]?.key,
|
|
3132
|
+
rowCount: t
|
|
3133
|
+
}));
|
|
3242
3134
|
}
|
|
3243
3135
|
selectColumn(e) {
|
|
3244
3136
|
this._selectColumn(e);
|
|
@@ -3325,16 +3217,12 @@ var K = {
|
|
|
3325
3217
|
x: e.clientX,
|
|
3326
3218
|
y: e.clientY,
|
|
3327
3219
|
hiddenNeighbors: this._hiddenNeighbors(t)
|
|
3328
|
-
}, this.
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
},
|
|
3335
|
-
bubbles: !0,
|
|
3336
|
-
composed: !0
|
|
3337
|
-
})), requestAnimationFrame(() => {
|
|
3220
|
+
}, this._emit("header-context-menu", {
|
|
3221
|
+
key: t.key,
|
|
3222
|
+
label: t.label,
|
|
3223
|
+
x: e.clientX,
|
|
3224
|
+
y: e.clientY
|
|
3225
|
+
}), requestAnimationFrame(() => {
|
|
3338
3226
|
document.addEventListener("click", this._onDocumentClick, { once: !0 });
|
|
3339
3227
|
});
|
|
3340
3228
|
}
|
|
@@ -3519,11 +3407,7 @@ var K = {
|
|
|
3519
3407
|
n && n.sortable !== !1 && (this._sortCriteria = [{
|
|
3520
3408
|
key: e,
|
|
3521
3409
|
direction: t
|
|
3522
|
-
}], this.dataMode !== "server" && this._recomputeView(), this.requestUpdate(), this.
|
|
3523
|
-
detail: { criteria: [...this._sortCriteria] },
|
|
3524
|
-
bubbles: !0,
|
|
3525
|
-
composed: !0
|
|
3526
|
-
})));
|
|
3410
|
+
}], this.dataMode !== "server" && this._recomputeView(), this.requestUpdate(), this._emit("sort-change", { criteria: [...this._sortCriteria] }));
|
|
3527
3411
|
}
|
|
3528
3412
|
_keepMenuInView(e) {
|
|
3529
3413
|
let t = this.shadowRoot?.querySelector(e);
|
|
@@ -3837,15 +3721,11 @@ var K = {
|
|
|
3837
3721
|
let r = this.shadowRoot?.querySelectorAll(`.ft-cell[data-col-index="${t}"]`), i = 0, a = this.shadowRoot?.querySelector(`.ft-header-cell[data-col-index="${t}"]`);
|
|
3838
3722
|
if (a && (i = Math.max(i, a.scrollWidth)), r) for (let e of r) i = Math.max(i, e.scrollWidth);
|
|
3839
3723
|
let o = n.minWidth ?? J, s = Math.max(o, i + 8);
|
|
3840
|
-
this._columnWidths.set(n.key, s), this.requestUpdate(), this.
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
},
|
|
3846
|
-
bubbles: !0,
|
|
3847
|
-
composed: !0
|
|
3848
|
-
}));
|
|
3724
|
+
this._columnWidths.set(n.key, s), this.requestUpdate(), this._emit("column-resize", {
|
|
3725
|
+
key: n.key,
|
|
3726
|
+
width: s,
|
|
3727
|
+
colIndex: t
|
|
3728
|
+
});
|
|
3849
3729
|
}
|
|
3850
3730
|
_onResizeStart(e, t) {
|
|
3851
3731
|
e.preventDefault(), e.stopPropagation();
|
|
@@ -3864,15 +3744,11 @@ var K = {
|
|
|
3864
3744
|
}, o = () => {
|
|
3865
3745
|
if (a(), this._resizing) {
|
|
3866
3746
|
let e = this._columnWidths.get(n.key) ?? q;
|
|
3867
|
-
this.
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
},
|
|
3873
|
-
bubbles: !0,
|
|
3874
|
-
composed: !0
|
|
3875
|
-
})), this._resizing = null;
|
|
3747
|
+
this._emit("column-resize", {
|
|
3748
|
+
key: n.key,
|
|
3749
|
+
width: e,
|
|
3750
|
+
colIndex: t
|
|
3751
|
+
}), this._resizing = null;
|
|
3876
3752
|
}
|
|
3877
3753
|
};
|
|
3878
3754
|
document.addEventListener("mousemove", i), document.addEventListener("mouseup", o), this._resizeCleanup = a;
|
|
@@ -4001,15 +3877,11 @@ var K = {
|
|
|
4001
3877
|
for (let e of r) this.data[e.dataRow][e.key] = e.newValue;
|
|
4002
3878
|
this.requestUpdate();
|
|
4003
3879
|
}
|
|
4004
|
-
}), this._dispatchUndoStateEvent(), this.
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
},
|
|
4010
|
-
bubbles: !0,
|
|
4011
|
-
composed: !0
|
|
4012
|
-
}))), this.requestUpdate();
|
|
3880
|
+
}), this._dispatchUndoStateEvent(), this._emit("fill-handle-apply", {
|
|
3881
|
+
sourceRange: e,
|
|
3882
|
+
targetRange: t,
|
|
3883
|
+
cells: r
|
|
3884
|
+
})), this.requestUpdate();
|
|
4013
3885
|
}
|
|
4014
3886
|
_detectNumericSeries(e) {
|
|
4015
3887
|
if (e.length < 2) return null;
|
|
@@ -4101,14 +3973,10 @@ var K = {
|
|
|
4101
3973
|
redo: () => {
|
|
4102
3974
|
this.data = [...a], this.requestUpdate();
|
|
4103
3975
|
}
|
|
4104
|
-
}), this._dispatchUndoStateEvent(), this.
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
},
|
|
4109
|
-
bubbles: !0,
|
|
4110
|
-
composed: !0
|
|
4111
|
-
}));
|
|
3976
|
+
}), this._dispatchUndoStateEvent(), this._emit("row-reorder", {
|
|
3977
|
+
from: n,
|
|
3978
|
+
to: r
|
|
3979
|
+
});
|
|
4112
3980
|
}
|
|
4113
3981
|
_toggleFindPanel(e) {
|
|
4114
3982
|
if (this._findState?.mode === e) {
|
|
@@ -4191,19 +4059,15 @@ var K = {
|
|
|
4191
4059
|
for (let e of r) this.data[e.dataRow][e.key] = e.newValue;
|
|
4192
4060
|
this.requestUpdate();
|
|
4193
4061
|
}
|
|
4194
|
-
}), this._dispatchUndoStateEvent(), this.
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
},
|
|
4204
|
-
bubbles: !0,
|
|
4205
|
-
composed: !0
|
|
4206
|
-
}))), this._findState.results = [], this._findState.currentIndex = 0, this.requestUpdate();
|
|
4062
|
+
}), this._dispatchUndoStateEvent(), this._emit("find-replace", {
|
|
4063
|
+
type: "replace-all",
|
|
4064
|
+
cells: r.map((e) => ({
|
|
4065
|
+
row: e.dataRow,
|
|
4066
|
+
col: e.key,
|
|
4067
|
+
oldValue: e.oldValue,
|
|
4068
|
+
newValue: e.newValue
|
|
4069
|
+
}))
|
|
4070
|
+
})), this._findState.results = [], this._findState.currentIndex = 0, this.requestUpdate();
|
|
4207
4071
|
}
|
|
4208
4072
|
_replaceOne() {
|
|
4209
4073
|
if (!this._findState || this._findState.results.length === 0) return;
|
|
@@ -4216,19 +4080,15 @@ var K = {
|
|
|
4216
4080
|
redo: () => {
|
|
4217
4081
|
this.data[a][o] = n, this.requestUpdate();
|
|
4218
4082
|
}
|
|
4219
|
-
}), this._dispatchUndoStateEvent(), this.
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
},
|
|
4229
|
-
bubbles: !0,
|
|
4230
|
-
composed: !0
|
|
4231
|
-
})), this._findSearch(), this._findGoTo(Math.min(e, this._findState.results.length - 1));
|
|
4083
|
+
}), this._dispatchUndoStateEvent(), this._emit("find-replace", {
|
|
4084
|
+
type: "replace",
|
|
4085
|
+
cells: [{
|
|
4086
|
+
row: a,
|
|
4087
|
+
col: o,
|
|
4088
|
+
oldValue: s,
|
|
4089
|
+
newValue: n
|
|
4090
|
+
}]
|
|
4091
|
+
}), this._findSearch(), this._findGoTo(Math.min(e, this._findState.results.length - 1));
|
|
4232
4092
|
}
|
|
4233
4093
|
_renderFindPanel() {
|
|
4234
4094
|
if (!this._findState) return "";
|
package/dist/flex-table.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { CellPosition, CellRange } from './core/selection.js';
|
|
|
5
5
|
import type { SortCriteria } from './core/sorting.js';
|
|
6
6
|
import type { FilterPredicate } from './core/filtering.js';
|
|
7
7
|
import type { ColumnDefinition, DataRow, SelectionMode, DataMode } from './models/types.js';
|
|
8
|
+
import type { FlexTableEventMap } from './events.js';
|
|
8
9
|
import type { TemplateResult } from 'lit';
|
|
9
10
|
export declare class FlexTable extends LitElement {
|
|
10
11
|
static styles: import("lit").CSSResult;
|
|
@@ -210,6 +211,11 @@ export declare class FlexTable extends LitElement {
|
|
|
210
211
|
redo(): void;
|
|
211
212
|
/** Clear all undo/redo history. */
|
|
212
213
|
clearUndoHistory(): void;
|
|
214
|
+
/**
|
|
215
|
+
* Dispatches one of {@link FlexTableEventMap}'s events — bubbling and composed. Every event goes
|
|
216
|
+
* through here, so a detail that drifts from the map fails to compile.
|
|
217
|
+
*/
|
|
218
|
+
private _emit;
|
|
213
219
|
private _dispatchUndoStateEvent;
|
|
214
220
|
private _dispatchFilterEvent;
|
|
215
221
|
/**
|
|
@@ -561,6 +567,19 @@ export declare class FlexTable extends LitElement {
|
|
|
561
567
|
private _renderCell;
|
|
562
568
|
private _renderEditor;
|
|
563
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
* Typed listeners for {@link FlexTableEventMap} — the DOM's own pattern (`HTMLMediaElement` with
|
|
572
|
+
* `HTMLMediaElementEventMap`). Element-scoped on purpose: several names are generic and would
|
|
573
|
+
* collide on the global event map.
|
|
574
|
+
*/
|
|
575
|
+
export interface FlexTable {
|
|
576
|
+
addEventListener<K extends keyof FlexTableEventMap>(type: K, listener: (this: FlexTable, ev: FlexTableEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
577
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: FlexTable, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
|
|
578
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
579
|
+
removeEventListener<K extends keyof FlexTableEventMap>(type: K, listener: (this: FlexTable, ev: FlexTableEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
580
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: FlexTable, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
|
|
581
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
582
|
+
}
|
|
564
583
|
declare global {
|
|
565
584
|
interface HTMLElementTagNameMap {
|
|
566
585
|
'flex-table': FlexTable;
|
package/dist/flex-table.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./flex-table-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./flex-table-BsxF9Q3O.js";
|
|
2
2
|
export { o as FlexTable, e as RowSelectionState, t as UndoStack, n as effectiveAlign, i as exportData, r as flexTableLocale, a as renderCell };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { FlexTable } from './flex-table.js';
|
|
|
2
2
|
export type { ColumnDefinition, ColumnType, ColumnAlign, DataRow, CellRenderer, CellEditor, CellValidator, SelectionMode, DataMode, CellStyle, ConditionalRule } from './models/types.js';
|
|
3
3
|
export { effectiveAlign } from './models/types.js';
|
|
4
4
|
export type { CellPosition, CellRange } from './core/selection.js';
|
|
5
|
+
export type { FlexTableEventMap, CellChange } from './events.js';
|
|
5
6
|
export type { SortCriteria, SortDirection } from './core/sorting.js';
|
|
6
7
|
export type { ColumnFilter, FilterPredicate, FilterErrorCallback } from './core/filtering.js';
|
|
7
8
|
export { RowSelectionState } from './core/row-selection.js';
|
package/dist/react.d.ts
CHANGED
|
@@ -2,38 +2,39 @@ import React from 'react';
|
|
|
2
2
|
import { type EventName } from '@lit/react';
|
|
3
3
|
import { FlexTable } from './flex-table.js';
|
|
4
4
|
import type { ColumnDefinition, DataRow } from './models/types.js';
|
|
5
|
+
import type { FlexTableEventMap } from './events.js';
|
|
5
6
|
declare const FlexTableReactBase: import("@lit/react").ReactWebComponent<FlexTable, {
|
|
6
|
-
onCellSelect: EventName<
|
|
7
|
-
onCellEditCommit: EventName<
|
|
8
|
-
onCellEditCancel: EventName<
|
|
9
|
-
onCellEditStart: EventName<
|
|
10
|
-
onSortChange: EventName<
|
|
11
|
-
onFilterChange: EventName<
|
|
12
|
-
onRowAdd: EventName<
|
|
13
|
-
onRowDelete: EventName<
|
|
14
|
-
onRowActivate: EventName<
|
|
15
|
-
onColumnResize: EventName<
|
|
16
|
-
onColumnSelect: EventName<
|
|
17
|
-
onColumnAdd: EventName<
|
|
18
|
-
onColumnDelete: EventName<
|
|
19
|
-
onColumnReorder: EventName<
|
|
20
|
-
onSelectionChange: EventName<
|
|
21
|
-
onClipboardCopy: EventName<
|
|
22
|
-
onClipboardCut: EventName<
|
|
23
|
-
onClipboardPaste: EventName<
|
|
24
|
-
onClipboardError: EventName<
|
|
25
|
-
onUndoStateChange: EventName<
|
|
26
|
-
onValidationError: EventName<
|
|
27
|
-
onBatchUpdate: EventName<
|
|
28
|
-
onContextMenu: EventName<
|
|
29
|
-
onFilterError: EventName<
|
|
30
|
-
onRowReorder: EventName<
|
|
31
|
-
onColumnVisibilityChange: EventName<
|
|
32
|
-
onCommentChange: EventName<
|
|
33
|
-
onDataImport: EventName<
|
|
34
|
-
onFillHandleApply: EventName<
|
|
35
|
-
onFindReplace: EventName<
|
|
36
|
-
onHeaderContextMenu: EventName<
|
|
7
|
+
onCellSelect: EventName<FlexTableEventMap["cell-select"]>;
|
|
8
|
+
onCellEditCommit: EventName<FlexTableEventMap["cell-edit-commit"]>;
|
|
9
|
+
onCellEditCancel: EventName<FlexTableEventMap["cell-edit-cancel"]>;
|
|
10
|
+
onCellEditStart: EventName<FlexTableEventMap["cell-edit-start"]>;
|
|
11
|
+
onSortChange: EventName<FlexTableEventMap["sort-change"]>;
|
|
12
|
+
onFilterChange: EventName<FlexTableEventMap["filter-change"]>;
|
|
13
|
+
onRowAdd: EventName<FlexTableEventMap["row-add"]>;
|
|
14
|
+
onRowDelete: EventName<FlexTableEventMap["row-delete"]>;
|
|
15
|
+
onRowActivate: EventName<FlexTableEventMap["row-activate"]>;
|
|
16
|
+
onColumnResize: EventName<FlexTableEventMap["column-resize"]>;
|
|
17
|
+
onColumnSelect: EventName<FlexTableEventMap["column-select"]>;
|
|
18
|
+
onColumnAdd: EventName<FlexTableEventMap["column-add"]>;
|
|
19
|
+
onColumnDelete: EventName<FlexTableEventMap["column-delete"]>;
|
|
20
|
+
onColumnReorder: EventName<FlexTableEventMap["column-reorder"]>;
|
|
21
|
+
onSelectionChange: EventName<FlexTableEventMap["selection-change"]>;
|
|
22
|
+
onClipboardCopy: EventName<FlexTableEventMap["clipboard-copy"]>;
|
|
23
|
+
onClipboardCut: EventName<FlexTableEventMap["clipboard-cut"]>;
|
|
24
|
+
onClipboardPaste: EventName<FlexTableEventMap["clipboard-paste"]>;
|
|
25
|
+
onClipboardError: EventName<FlexTableEventMap["clipboard-error"]>;
|
|
26
|
+
onUndoStateChange: EventName<FlexTableEventMap["undo-state-change"]>;
|
|
27
|
+
onValidationError: EventName<FlexTableEventMap["validation-error"]>;
|
|
28
|
+
onBatchUpdate: EventName<FlexTableEventMap["batch-update"]>;
|
|
29
|
+
onContextMenu: EventName<FlexTableEventMap["context-menu"]>;
|
|
30
|
+
onFilterError: EventName<FlexTableEventMap["filter-error"]>;
|
|
31
|
+
onRowReorder: EventName<FlexTableEventMap["row-reorder"]>;
|
|
32
|
+
onColumnVisibilityChange: EventName<FlexTableEventMap["column-visibility-change"]>;
|
|
33
|
+
onCommentChange: EventName<FlexTableEventMap["comment-change"]>;
|
|
34
|
+
onDataImport: EventName<FlexTableEventMap["data-import"]>;
|
|
35
|
+
onFillHandleApply: EventName<FlexTableEventMap["fill-handle-apply"]>;
|
|
36
|
+
onFindReplace: EventName<FlexTableEventMap["find-replace"]>;
|
|
37
|
+
onHeaderContextMenu: EventName<FlexTableEventMap["header-context-menu"]>;
|
|
37
38
|
}>;
|
|
38
39
|
type BaseProps = React.ComponentProps<typeof FlexTableReactBase>;
|
|
39
40
|
/**
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./flex-table-
|
|
1
|
+
import { t as e } from "./flex-table-BsxF9Q3O.js";
|
|
2
2
|
import { i as t, t as n } from "./query-Dw4iO0ir.js";
|
|
3
3
|
import { t as r } from "./view-DiLr-TdY.js";
|
|
4
4
|
import i, { useCallback as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iyulab/flex-table",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "A minimalist, input-centric data grid web component",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/flex-table.js",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|
|
36
|
+
"!dist/**/*.test.d.ts",
|
|
36
37
|
"skills",
|
|
37
38
|
"package.json",
|
|
38
39
|
"README.md",
|
|
@@ -134,6 +134,8 @@ Enter/Escape and blur-to-commit behavior.
|
|
|
134
134
|
## Events
|
|
135
135
|
|
|
136
136
|
All are `CustomEvent`s with `bubbles: true, composed: true`. `row`/`index` are data indices.
|
|
137
|
+
Typed by `FlexTableEventMap` (exported): `table.addEventListener('sort-change', (e) => e.detail.criteria)` needs no
|
|
138
|
+
cast, and the React `on*` props carry the same types.
|
|
137
139
|
|
|
138
140
|
| Event | `detail` |
|
|
139
141
|
|---|---|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/core/undo.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './flex-table.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '../flex-table';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|