@iyulab/flex-table 0.16.1 → 0.17.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.
|
@@ -1416,11 +1416,18 @@ var Y = {
|
|
|
1416
1416
|
lte: "≤"
|
|
1417
1417
|
}, X = 120, Z = 40, xe = 32, Q = 5, $ = class extends e {
|
|
1418
1418
|
constructor(...e) {
|
|
1419
|
-
super(...e), this.columns = [], this.
|
|
1419
|
+
super(...e), this.columns = [], this._data = [], this._inUndoRedo = !1, this.clearUndoOnDataChange = !1, this.rowHeight = xe, this.showRowNumbers = !1, this.theme = void 0, this.maxRows = 0, this.editable = !0, this.showFilters = !1, this.showContextMenu = !1, this.frozenRows = 0, this.importEnabled = !1, this.selectable = !1, this.dataMode = "client", this.footerData = null, this._scrollTop = 0, this._scrollLeft = 0, this._viewportHeight = 0, this._viewportWidth = 0, this._colLeftOffsets = [], this._totalRowWidth = 0, this._activeCell = null, this._editingCell = null, this._sortCriteria = [], this._selection = new y(), this._editing = new b(), this._rowSelection = new x(), this._undo = new D(), this._filters = [], this._filteredIndices = [], this._sortedIndices = [], this._openFilterKey = null, this._rowSelectionVersion = 0, this._autocompleteState = null, this._headerMenu = null, this._bodyContextMenu = null, this._viewDirty = !0, this._isDragging = !1, this._wasDrag = !1, this._resizing = null, this._resizeCleanup = null, this._colDrag = null, this._colDragIndicatorLeft = null, this._fillDrag = null, this._rowDrag = null, this._rowDragIndicatorY = null, this._findState = null, this._columnWidths = /* @__PURE__ */ new Map(), this._hostResizeObserver = null, this._comments = /* @__PURE__ */ new Map(), this._isDragOver = !1, this._invalidCells = /* @__PURE__ */ new Map(), this._textFilterState = /* @__PURE__ */ new Map(), this._numberFilterState = /* @__PURE__ */ new Map(), this._dateFilterState = /* @__PURE__ */ new Map(), this._emptyFilterState = /* @__PURE__ */ new Map();
|
|
1420
1420
|
}
|
|
1421
1421
|
static {
|
|
1422
1422
|
this.styles = s;
|
|
1423
1423
|
}
|
|
1424
|
+
get data() {
|
|
1425
|
+
return this._data;
|
|
1426
|
+
}
|
|
1427
|
+
set data(e) {
|
|
1428
|
+
let t = this._data;
|
|
1429
|
+
this._data = e, this.clearUndoOnDataChange && !this._inUndoRedo && this._undo.clear(), this.requestUpdate("data", t);
|
|
1430
|
+
}
|
|
1424
1431
|
set selectionMode(e) {
|
|
1425
1432
|
this._rowSelection.mode = e, this.requestUpdate();
|
|
1426
1433
|
}
|
|
@@ -1501,6 +1508,15 @@ var Y = {
|
|
|
1501
1508
|
refreshData() {
|
|
1502
1509
|
this.requestUpdate("data");
|
|
1503
1510
|
}
|
|
1511
|
+
undo() {
|
|
1512
|
+
this._inUndoRedo = !0, this._undo.undo(), this._inUndoRedo = !1, this.requestUpdate(), this._dispatchUndoStateEvent();
|
|
1513
|
+
}
|
|
1514
|
+
redo() {
|
|
1515
|
+
this._inUndoRedo = !0, this._undo.redo(), this._inUndoRedo = !1, this.requestUpdate(), this._dispatchUndoStateEvent();
|
|
1516
|
+
}
|
|
1517
|
+
clearUndoHistory() {
|
|
1518
|
+
this._undo.clear(), this._dispatchUndoStateEvent();
|
|
1519
|
+
}
|
|
1504
1520
|
_dispatchUndoStateEvent() {
|
|
1505
1521
|
this.dispatchEvent(new CustomEvent("undo-state-change", {
|
|
1506
1522
|
detail: {
|
|
@@ -1601,10 +1617,32 @@ var Y = {
|
|
|
1601
1617
|
})), this._dispatchUndoStateEvent();
|
|
1602
1618
|
}
|
|
1603
1619
|
hideColumn(e) {
|
|
1604
|
-
this.
|
|
1620
|
+
let t = this.columns.findIndex((t) => t.key === e);
|
|
1621
|
+
if (t === -1) return;
|
|
1622
|
+
let n = this.columns[t].hidden ?? !1;
|
|
1623
|
+
this._setColumnHidden(e, !0), this._undo.push({
|
|
1624
|
+
label: "column-visibility",
|
|
1625
|
+
undo: () => {
|
|
1626
|
+
this._setColumnHidden(e, n);
|
|
1627
|
+
},
|
|
1628
|
+
redo: () => {
|
|
1629
|
+
this._setColumnHidden(e, !0);
|
|
1630
|
+
}
|
|
1631
|
+
});
|
|
1605
1632
|
}
|
|
1606
1633
|
showColumn(e) {
|
|
1607
|
-
this.
|
|
1634
|
+
let t = this.columns.findIndex((t) => t.key === e);
|
|
1635
|
+
if (t === -1) return;
|
|
1636
|
+
let n = this.columns[t].hidden ?? !1;
|
|
1637
|
+
this._setColumnHidden(e, !1), this._undo.push({
|
|
1638
|
+
label: "column-visibility",
|
|
1639
|
+
undo: () => {
|
|
1640
|
+
this._setColumnHidden(e, n);
|
|
1641
|
+
},
|
|
1642
|
+
redo: () => {
|
|
1643
|
+
this._setColumnHidden(e, !1);
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1608
1646
|
}
|
|
1609
1647
|
_setColumnHidden(e, t) {
|
|
1610
1648
|
let n = this.columns.findIndex((t) => t.key === e);
|
|
@@ -1733,6 +1771,18 @@ var Y = {
|
|
|
1733
1771
|
G(this.exportToString(e), t ?? `export${le(e)}`, ce(e));
|
|
1734
1772
|
}
|
|
1735
1773
|
setComment(e, t, n) {
|
|
1774
|
+
let r = this.getComment(e, t);
|
|
1775
|
+
this._applyComment(e, t, n), this._undo.push({
|
|
1776
|
+
label: "comment",
|
|
1777
|
+
undo: () => {
|
|
1778
|
+
this._applyComment(e, t, r);
|
|
1779
|
+
},
|
|
1780
|
+
redo: () => {
|
|
1781
|
+
this._applyComment(e, t, n);
|
|
1782
|
+
}
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
_applyComment(e, t, n) {
|
|
1736
1786
|
if (n) this._comments.has(e) || this._comments.set(e, /* @__PURE__ */ new Map()), this._comments.get(e).set(t, n);
|
|
1737
1787
|
else {
|
|
1738
1788
|
let n = this._comments.get(e);
|
|
@@ -1761,7 +1811,16 @@ var Y = {
|
|
|
1761
1811
|
return e;
|
|
1762
1812
|
}
|
|
1763
1813
|
clearComments() {
|
|
1764
|
-
this._comments.
|
|
1814
|
+
let e = new Map([...this._comments].map(([e, t]) => [e, new Map(t)]));
|
|
1815
|
+
this._comments.clear(), this.requestUpdate(), this._undo.push({
|
|
1816
|
+
label: "clear-comments",
|
|
1817
|
+
undo: () => {
|
|
1818
|
+
this._comments = e, this.requestUpdate();
|
|
1819
|
+
},
|
|
1820
|
+
redo: () => {
|
|
1821
|
+
this._comments.clear(), this.requestUpdate();
|
|
1822
|
+
}
|
|
1823
|
+
});
|
|
1765
1824
|
}
|
|
1766
1825
|
async importFromFile(e) {
|
|
1767
1826
|
let t = e.name.toLowerCase();
|
|
@@ -1782,8 +1841,16 @@ var Y = {
|
|
|
1782
1841
|
let o = this.columns.find((e) => e.key === a);
|
|
1783
1842
|
r[a] = o ? k(n[i] ?? "", o) : n[i] ?? null;
|
|
1784
1843
|
}), r;
|
|
1785
|
-
});
|
|
1786
|
-
this.data = n, this.
|
|
1844
|
+
}), r = [...this.data];
|
|
1845
|
+
this.data = n, this._undo.push({
|
|
1846
|
+
label: "import",
|
|
1847
|
+
undo: () => {
|
|
1848
|
+
this.data = r, this.requestUpdate();
|
|
1849
|
+
},
|
|
1850
|
+
redo: () => {
|
|
1851
|
+
this.data = n, this.requestUpdate();
|
|
1852
|
+
}
|
|
1853
|
+
}), this.dispatchEvent(new CustomEvent("data-import", {
|
|
1787
1854
|
detail: { count: n.length },
|
|
1788
1855
|
bubbles: !0,
|
|
1789
1856
|
composed: !0
|
|
@@ -1799,8 +1866,16 @@ var Y = {
|
|
|
1799
1866
|
let o = this.columns.find((e) => e.key === a);
|
|
1800
1867
|
r[a] = o ? k(e[i] ?? "", o) : e[i] ?? null;
|
|
1801
1868
|
}), r;
|
|
1802
|
-
});
|
|
1803
|
-
this.data = r, this.
|
|
1869
|
+
}), i = [...this.data];
|
|
1870
|
+
this.data = r, this._undo.push({
|
|
1871
|
+
label: "import",
|
|
1872
|
+
undo: () => {
|
|
1873
|
+
this.data = i, this.requestUpdate();
|
|
1874
|
+
},
|
|
1875
|
+
redo: () => {
|
|
1876
|
+
this.data = r, this.requestUpdate();
|
|
1877
|
+
}
|
|
1878
|
+
}), this.dispatchEvent(new CustomEvent("data-import", {
|
|
1804
1879
|
detail: { count: r.length },
|
|
1805
1880
|
bubbles: !0,
|
|
1806
1881
|
composed: !0
|
|
@@ -2234,8 +2309,8 @@ var Y = {
|
|
|
2234
2309
|
_handleCtrlKey(e) {
|
|
2235
2310
|
if (!(e.ctrlKey || e.metaKey) || e.altKey) return !1;
|
|
2236
2311
|
switch (e.key.toLowerCase()) {
|
|
2237
|
-
case "z": return e.preventDefault(), e.shiftKey ? this.
|
|
2238
|
-
case "y": return e.preventDefault(), this.
|
|
2312
|
+
case "z": return e.preventDefault(), e.shiftKey ? this.redo() : this.undo(), !0;
|
|
2313
|
+
case "y": return e.preventDefault(), this.redo(), !0;
|
|
2239
2314
|
case "c": return e.preventDefault(), this._handleCopy(!1), !0;
|
|
2240
2315
|
case "x": return e.preventDefault(), this._handleCopy(this.editable), !0;
|
|
2241
2316
|
case "v": return e.preventDefault(), this.editable && this._handlePaste(), !0;
|
|
@@ -3717,7 +3792,10 @@ var Y = {
|
|
|
3717
3792
|
J([a({ type: Array })], $.prototype, "columns", void 0), J([a({
|
|
3718
3793
|
type: Array,
|
|
3719
3794
|
hasChanged: () => !0
|
|
3720
|
-
})], $.prototype, "data",
|
|
3795
|
+
})], $.prototype, "data", null), J([a({
|
|
3796
|
+
type: Boolean,
|
|
3797
|
+
attribute: "clear-undo-on-data-change"
|
|
3798
|
+
})], $.prototype, "clearUndoOnDataChange", void 0), J([a({
|
|
3721
3799
|
type: Number,
|
|
3722
3800
|
attribute: "row-height"
|
|
3723
3801
|
})], $.prototype, "rowHeight", void 0), J([a({
|
package/dist/flex-table.d.ts
CHANGED
|
@@ -8,7 +8,21 @@ import type { TemplateResult } from 'lit';
|
|
|
8
8
|
export declare class FlexTable extends LitElement {
|
|
9
9
|
static styles: import("lit").CSSResult;
|
|
10
10
|
columns: ColumnDefinition[];
|
|
11
|
-
|
|
11
|
+
private _data;
|
|
12
|
+
private _inUndoRedo;
|
|
13
|
+
/**
|
|
14
|
+
* The table data. When `clear-undo-on-data-change` is enabled, replacing this
|
|
15
|
+
* property externally (`table.data = newData`) will clear the undo/redo history.
|
|
16
|
+
* Internal undo/redo operations are exempt from this clearing.
|
|
17
|
+
* To manually clear history before data replacement, call `clearUndoHistory()`.
|
|
18
|
+
*/
|
|
19
|
+
get data(): DataRow[];
|
|
20
|
+
set data(value: DataRow[]);
|
|
21
|
+
/**
|
|
22
|
+
* When true, replacing `data` externally automatically clears the undo/redo history.
|
|
23
|
+
* Default: false. Internal undo/redo operations are never affected.
|
|
24
|
+
*/
|
|
25
|
+
clearUndoOnDataChange: boolean;
|
|
12
26
|
rowHeight: number;
|
|
13
27
|
showRowNumbers: boolean;
|
|
14
28
|
theme: 'light' | 'dark' | undefined;
|
|
@@ -111,6 +125,12 @@ export declare class FlexTable extends LitElement {
|
|
|
111
125
|
* Useful when `data` array contents are mutated in-place without reassignment.
|
|
112
126
|
*/
|
|
113
127
|
refreshData(): void;
|
|
128
|
+
/** Undo the most recent action. */
|
|
129
|
+
undo(): void;
|
|
130
|
+
/** Redo the most recently undone action. */
|
|
131
|
+
redo(): void;
|
|
132
|
+
/** Clear all undo/redo history. */
|
|
133
|
+
clearUndoHistory(): void;
|
|
114
134
|
private _dispatchUndoStateEvent;
|
|
115
135
|
private _dispatchFilterEvent;
|
|
116
136
|
/**
|
|
@@ -172,6 +192,7 @@ export declare class FlexTable extends LitElement {
|
|
|
172
192
|
* Pass an empty string or null to remove the comment.
|
|
173
193
|
*/
|
|
174
194
|
setComment(dataIndex: number, colKey: string, text: string | null): void;
|
|
195
|
+
private _applyComment;
|
|
175
196
|
/**
|
|
176
197
|
* Get the comment for a cell (by data index and column key). Returns null if none.
|
|
177
198
|
*/
|
package/dist/flex-table.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, r, t as i } from "./flex-table-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./flex-table-Dwdo2HpR.js";
|
|
2
2
|
export { i as FlexTable, t as RowSelectionState, r as UndoStack, n as exportData, e as renderCell };
|
package/dist/react.js
CHANGED