@iyulab/flex-table 0.10.1 → 0.10.2
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.
|
@@ -762,7 +762,7 @@ function it(t) {
|
|
|
762
762
|
}
|
|
763
763
|
return i;
|
|
764
764
|
}
|
|
765
|
-
function
|
|
765
|
+
function z(t, e) {
|
|
766
766
|
if (t === "") return null;
|
|
767
767
|
switch (e.type) {
|
|
768
768
|
case "number": {
|
|
@@ -775,7 +775,7 @@ function A(t, e) {
|
|
|
775
775
|
return t;
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
|
-
function
|
|
778
|
+
function A(t, e, i) {
|
|
779
779
|
switch (i) {
|
|
780
780
|
case "csv":
|
|
781
781
|
return U(t, e, ",");
|
|
@@ -837,10 +837,10 @@ var ht = Object.defineProperty, dt = Object.getOwnPropertyDescriptor, v = (t, e,
|
|
|
837
837
|
(n = t[r]) && (o = (s ? n(e, i, o) : n(o)) || o);
|
|
838
838
|
return s && o && ht(e, i, o), o;
|
|
839
839
|
};
|
|
840
|
-
const S = 120, E = 40, ut = 32,
|
|
840
|
+
const S = 120, E = 40, ut = 32, R = 5;
|
|
841
841
|
let _ = class extends T {
|
|
842
842
|
constructor() {
|
|
843
|
-
super(...arguments), this.columns = [], this.data = [], this.rowHeight = ut, this.showRowNumbers = !1, this.theme = void 0, this.maxRows = 0, this.editable = !0, this.showFilters = !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 j(), this._editing = new B(), this._rowSelection = new X(), this._undo = new tt(), this._filters = [], this._filteredIndices = [], this._sortedIndices = [], this._openFilterKey = null, this._rowSelectionVersion = 0, this._viewDirty = !0, this._resizing = null, this._resizeCleanup = null, this._columnWidths = /* @__PURE__ */ new Map(), this._invalidCells = /* @__PURE__ */ new Map(), this._textFilterState = /* @__PURE__ */ new Map(), this._numberFilterState = /* @__PURE__ */ new Map(), this._dateFilterState = /* @__PURE__ */ new Map();
|
|
843
|
+
super(...arguments), this.columns = [], this.data = [], this.rowHeight = ut, this.showRowNumbers = !1, this.theme = void 0, this.maxRows = 0, this.editable = !0, this.showFilters = !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 j(), this._editing = new B(), this._rowSelection = new X(), this._undo = new tt(), this._filters = [], this._filteredIndices = [], this._sortedIndices = [], this._openFilterKey = null, this._rowSelectionVersion = 0, this._viewDirty = !0, this._resizing = null, this._resizeCleanup = null, this._columnWidths = /* @__PURE__ */ new Map(), this._hostResizeObserver = null, this._invalidCells = /* @__PURE__ */ new Map(), this._textFilterState = /* @__PURE__ */ new Map(), this._numberFilterState = /* @__PURE__ */ new Map(), this._dateFilterState = /* @__PURE__ */ new Map();
|
|
844
844
|
}
|
|
845
845
|
set selectionMode(t) {
|
|
846
846
|
this._rowSelection.mode = t, this.requestUpdate();
|
|
@@ -1150,10 +1150,10 @@ let _ = class extends T {
|
|
|
1150
1150
|
const o = this.visibleColumns.slice(s.startCol, s.endCol + 1), r = [];
|
|
1151
1151
|
for (let n = s.startRow; n <= s.endRow; n++)
|
|
1152
1152
|
r.push(this.data[this._toDataIndex(n)]);
|
|
1153
|
-
return
|
|
1153
|
+
return A(r, o, t);
|
|
1154
1154
|
}
|
|
1155
1155
|
const i = this._sortedIndices.map((s) => this.data[s]);
|
|
1156
|
-
return
|
|
1156
|
+
return A(i, this.visibleColumns, t);
|
|
1157
1157
|
}
|
|
1158
1158
|
/**
|
|
1159
1159
|
* Export table data and trigger file download.
|
|
@@ -1191,14 +1191,14 @@ let _ = class extends T {
|
|
|
1191
1191
|
return this._visibleRowCount * this.rowHeight;
|
|
1192
1192
|
}
|
|
1193
1193
|
get visibleRange() {
|
|
1194
|
-
const t = Math.max(0, this._scrollTop - this.headerHeight), e = Math.max(0, Math.floor(t / this.rowHeight) -
|
|
1194
|
+
const t = Math.max(0, this._scrollTop - this.headerHeight), e = Math.max(0, Math.floor(t / this.rowHeight) - R), i = Math.ceil(this._viewportHeight / this.rowHeight), s = Math.min(this._visibleRowCount, Math.floor(t / this.rowHeight) + i + R);
|
|
1195
1195
|
return { start: e, end: s };
|
|
1196
1196
|
}
|
|
1197
1197
|
connectedCallback() {
|
|
1198
|
-
super.connectedCallback(), this._onScroll = this._onScroll.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onDocumentClick = this._onDocumentClick.bind(this), this._onContextMenu = this._onContextMenu.bind(this), this.addEventListener("scroll", this._onScroll, { passive: !0 }), this.addEventListener("keydown", this._onKeyDown), this.addEventListener("contextmenu", this._onContextMenu), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "grid");
|
|
1198
|
+
super.connectedCallback(), this._onScroll = this._onScroll.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onDocumentClick = this._onDocumentClick.bind(this), this._onContextMenu = this._onContextMenu.bind(this), this.addEventListener("scroll", this._onScroll, { passive: !0 }), this.addEventListener("keydown", this._onKeyDown), this.addEventListener("contextmenu", this._onContextMenu), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "grid"), typeof ResizeObserver < "u" && (this._hostResizeObserver = new ResizeObserver(() => this._measureViewport()), this._hostResizeObserver.observe(this));
|
|
1199
1199
|
}
|
|
1200
1200
|
disconnectedCallback() {
|
|
1201
|
-
super.disconnectedCallback(), this.removeEventListener("scroll", this._onScroll), this.removeEventListener("keydown", this._onKeyDown), this.removeEventListener("contextmenu", this._onContextMenu), document.removeEventListener("click", this._onDocumentClick), this._resizeCleanup && (this._resizeCleanup(), this._resizeCleanup = null);
|
|
1201
|
+
super.disconnectedCallback(), this.removeEventListener("scroll", this._onScroll), this.removeEventListener("keydown", this._onKeyDown), this.removeEventListener("contextmenu", this._onContextMenu), document.removeEventListener("click", this._onDocumentClick), this._resizeCleanup && (this._resizeCleanup(), this._resizeCleanup = null), this._hostResizeObserver && (this._hostResizeObserver.disconnect(), this._hostResizeObserver = null);
|
|
1202
1202
|
}
|
|
1203
1203
|
firstUpdated() {
|
|
1204
1204
|
this._measureViewport();
|
|
@@ -1222,20 +1222,20 @@ let _ = class extends T {
|
|
|
1222
1222
|
o = n;
|
|
1223
1223
|
break;
|
|
1224
1224
|
}
|
|
1225
|
-
o = Math.max(0, o -
|
|
1225
|
+
o = Math.max(0, o - R);
|
|
1226
1226
|
let r = t.length;
|
|
1227
1227
|
for (let n = o; n < e.length; n++)
|
|
1228
1228
|
if (e[n] > s) {
|
|
1229
1229
|
r = n;
|
|
1230
1230
|
break;
|
|
1231
1231
|
}
|
|
1232
|
-
return r = Math.min(t.length, r +
|
|
1232
|
+
return r = Math.min(t.length, r + R), { start: o, end: r };
|
|
1233
1233
|
}
|
|
1234
1234
|
willUpdate(t) {
|
|
1235
1235
|
(!(t.size <= 2 && !t.has("data") && !t.has("columns") && !t.has("_openFilterKey") && !t.has("_editingCell") && !t.has("_activeCell") && (t.has("_scrollTop") || t.has("_scrollLeft"))) || this._viewDirty) && (this._recomputeView(), this._viewDirty = !1), this._updateColOffsets(), this._selection.setDimensions(this._visibleRowCount, this.visibleColumns.length), this._rowSelection.setRowCount(this._visibleRowCount);
|
|
1236
1236
|
}
|
|
1237
1237
|
updated() {
|
|
1238
|
-
this.
|
|
1238
|
+
this._focusEditor(), this._adjustFilterDropdown(), this.setAttribute("aria-rowcount", String(this._visibleRowCount)), this.setAttribute("aria-colcount", String(this.visibleColumns.length));
|
|
1239
1239
|
}
|
|
1240
1240
|
/** Recompute filter → sort pipeline. */
|
|
1241
1241
|
_recomputeView() {
|
|
@@ -1340,7 +1340,7 @@ let _ = class extends T {
|
|
|
1340
1340
|
if (!this._editing.current) return;
|
|
1341
1341
|
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector(".ft-editor");
|
|
1342
1342
|
if (t) {
|
|
1343
|
-
const i = this.visibleColumns[this._editing.current.position.col], s =
|
|
1343
|
+
const i = this.visibleColumns[this._editing.current.position.col], s = z(t.value, i);
|
|
1344
1344
|
this._applyEdit(s);
|
|
1345
1345
|
} else
|
|
1346
1346
|
this._cancelEdit();
|
|
@@ -1546,7 +1546,7 @@ let _ = class extends T {
|
|
|
1546
1546
|
for (let l = 0; l < e[o].length; l++) {
|
|
1547
1547
|
const a = t.col + l;
|
|
1548
1548
|
if (a >= i.length) break;
|
|
1549
|
-
const d = i[a], f = this.data[n][d.key], h =
|
|
1549
|
+
const d = i[a], f = this.data[n][d.key], h = z(e[o][l], d);
|
|
1550
1550
|
this.data[n][d.key] = h, s.push({ row: n, col: a, key: d.key, oldValue: f, newValue: h });
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
@@ -1967,8 +1967,8 @@ let _ = class extends T {
|
|
|
1967
1967
|
`;
|
|
1968
1968
|
}
|
|
1969
1969
|
_renderCell(t, e, i, s) {
|
|
1970
|
-
var x,
|
|
1971
|
-
const o = ((x = this._activeCell) == null ? void 0 : x.row) === i && ((
|
|
1970
|
+
var x, $, D, F;
|
|
1971
|
+
const o = ((x = this._activeCell) == null ? void 0 : x.row) === i && (($ = this._activeCell) == null ? void 0 : $.col) === s, r = ((D = this._editingCell) == null ? void 0 : D.row) === i && ((F = this._editingCell) == null ? void 0 : F.col) === s, n = this._selection.isInRange(i, s), l = e.pinned === "left", a = e.pinned === "right", d = l || a, f = this._getColWidth(e), h = this.rowHeight, g = this._colLeftOffsets[s] ?? 0;
|
|
1972
1972
|
let p;
|
|
1973
1973
|
l ? p = `position: absolute; top: 0; left: ${this._scrollLeft + this._getPinnedLeft(s)}px; width: ${f}px; height: ${h}px; z-index: 2;` : a ? p = `position: absolute; top: 0; right: ${-this._scrollLeft + this._getPinnedRight(s)}px; width: ${f}px; height: ${h}px; z-index: 2;` : p = `left: ${g}px; width: ${f}px; height: ${h}px;`;
|
|
1974
1974
|
const c = !this._isCellEditable(e);
|
|
@@ -2132,6 +2132,6 @@ export {
|
|
|
2132
2132
|
_ as F,
|
|
2133
2133
|
X as R,
|
|
2134
2134
|
tt as U,
|
|
2135
|
-
|
|
2135
|
+
A as e,
|
|
2136
2136
|
H as r
|
|
2137
2137
|
};
|
package/dist/flex-table.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export declare class FlexTable extends LitElement {
|
|
|
48
48
|
private _resizing;
|
|
49
49
|
private _resizeCleanup;
|
|
50
50
|
private _columnWidths;
|
|
51
|
+
private _hostResizeObserver;
|
|
51
52
|
get visibleColumns(): ColumnDefinition[];
|
|
52
53
|
private get _prefixWidth();
|
|
53
54
|
/** Whether an undo operation is available. */
|
package/dist/flex-table.js
CHANGED
package/dist/odata/index.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { useState as r, useRef as
|
|
1
|
+
import { useState as r, useRef as z, useCallback as m, useEffect as K } from "react";
|
|
2
2
|
import Q from "odata-query";
|
|
3
|
-
function I(
|
|
4
|
-
const { pageSize: a = 20, defaultOrderBy:
|
|
5
|
-
|
|
6
|
-
}, []),
|
|
7
|
-
|
|
8
|
-
}, []),
|
|
9
|
-
var
|
|
10
|
-
const
|
|
11
|
-
|
|
3
|
+
function I(c, d = {}) {
|
|
4
|
+
const { pageSize: a = 20, defaultOrderBy: n, fixedFilter: l } = d, x = l ? JSON.stringify(l) : "", [O, S] = r([]), [B, b] = r(0), [E, C] = r(!1), [R, g] = r(null), [h, p] = r(0), [u, T] = r(() => n ? U(n) : []), [f, q] = r(""), [A, D] = r(0), k = z(null), F = m(() => {
|
|
5
|
+
D((e) => e + 1);
|
|
6
|
+
}, []), J = m((e) => {
|
|
7
|
+
q(e), p(0);
|
|
8
|
+
}, []), L = m((e) => {
|
|
9
|
+
var o;
|
|
10
|
+
const i = (o = e.detail) == null ? void 0 : o.criteria;
|
|
11
|
+
i && (T(i), p(0));
|
|
12
12
|
}, []);
|
|
13
|
-
return
|
|
13
|
+
return K(() => {
|
|
14
14
|
var w;
|
|
15
15
|
(w = k.current) == null || w.abort();
|
|
16
16
|
const e = new AbortController();
|
|
17
17
|
k.current = e, C(!0), g(null);
|
|
18
|
-
const
|
|
18
|
+
const i = u.length > 0 ? u.map((t) => `${t.key} ${t.direction}`).join(", ") : n, o = {
|
|
19
19
|
top: a,
|
|
20
20
|
skip: h * a,
|
|
21
21
|
count: !0
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
return fetch(
|
|
23
|
+
i && (o.orderBy = i), l && (o.filter = l), f && (o.search = f);
|
|
24
|
+
const N = Q(o), P = `${window.location.origin}${c}${N}`;
|
|
25
|
+
return fetch(P, { signal: e.signal }).then(async (t) => {
|
|
26
26
|
var $;
|
|
27
27
|
if (!t.ok) {
|
|
28
|
-
const
|
|
29
|
-
let
|
|
28
|
+
const v = await t.text().catch(() => "");
|
|
29
|
+
let y = `요청 실패 (${t.status})`;
|
|
30
30
|
try {
|
|
31
|
-
const s = JSON.parse(
|
|
32
|
-
|
|
31
|
+
const s = JSON.parse(v);
|
|
32
|
+
y = (($ = s == null ? void 0 : s.error) == null ? void 0 : $.message) ?? (s == null ? void 0 : s.message) ?? y;
|
|
33
33
|
} catch {
|
|
34
34
|
}
|
|
35
|
-
throw new Error(
|
|
35
|
+
throw new Error(y);
|
|
36
36
|
}
|
|
37
37
|
return t.json();
|
|
38
38
|
}).then((t) => {
|
|
@@ -42,27 +42,27 @@ function I(i, f = {}) {
|
|
|
42
42
|
}).finally(() => {
|
|
43
43
|
e.signal.aborted || C(!1);
|
|
44
44
|
}), () => e.abort();
|
|
45
|
-
}, [
|
|
46
|
-
data:
|
|
45
|
+
}, [c, h, a, u, f, x, n, A]), {
|
|
46
|
+
data: O,
|
|
47
47
|
totalCount: B,
|
|
48
48
|
loading: E,
|
|
49
|
-
error:
|
|
49
|
+
error: R,
|
|
50
50
|
page: h,
|
|
51
51
|
setPage: p,
|
|
52
|
-
sortCriteria:
|
|
53
|
-
onSortChange:
|
|
54
|
-
search:
|
|
55
|
-
setSearch:
|
|
56
|
-
refresh:
|
|
52
|
+
sortCriteria: u,
|
|
53
|
+
onSortChange: L,
|
|
54
|
+
search: f,
|
|
55
|
+
setSearch: J,
|
|
56
|
+
refresh: F
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function U(
|
|
60
|
-
return
|
|
61
|
-
var
|
|
62
|
-
const a =
|
|
59
|
+
function U(c) {
|
|
60
|
+
return c.split(",").map((d) => {
|
|
61
|
+
var n;
|
|
62
|
+
const a = d.trim().split(/\s+/);
|
|
63
63
|
return {
|
|
64
64
|
key: a[0],
|
|
65
|
-
direction: ((
|
|
65
|
+
direction: ((n = a[1]) == null ? void 0 : n.toLowerCase()) === "desc" ? "desc" : "asc"
|
|
66
66
|
};
|
|
67
67
|
});
|
|
68
68
|
}
|
package/dist/react.js
CHANGED