flexitablesort 1.1.8 → 1.1.11
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/README.md +72 -72
- package/dist/Components/Draggable.d.ts +2 -1
- package/dist/Components/TableContainer/index.d.ts +3 -11
- package/dist/Components/TableContainer/useTable.d.ts +1 -87
- package/dist/Components/TableHeader.d.ts +1 -1
- package/dist/Components/index.d.ts +2 -0
- package/dist/Components/utils.d.ts +4 -3
- package/dist/hooks/types.d.ts +67 -17
- package/dist/hooks/useAutoScroll.d.ts +2 -6
- package/dist/hooks/useDragContextEvents.d.ts +3 -2
- package/dist/index.cjs.js +26 -6
- package/dist/index.es.js +435 -391
- package/package.json +89 -73
package/dist/index.es.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import e, { createContext as t, forwardRef as n, memo as r, useCallback as i, useContext as a, useEffect as o, useImperativeHandle as s,
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import e, { createContext as t, forwardRef as n, memo as r, useCallback as i, useContext as a, useEffect as o, useImperativeHandle as s, useLayoutEffect as c, useMemo as l, useReducer as u, useRef as d, useState as f } from "react";
|
|
2
|
+
import p from "styled-components";
|
|
3
|
+
import { createPortal as m, flushSync as h } from "react-dom";
|
|
4
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
5
|
+
import v from "classnames";
|
|
6
6
|
//#region src/Components/TableContainer/styles.tsx
|
|
7
|
-
var
|
|
7
|
+
var y = p.div`
|
|
8
8
|
height: 100%;
|
|
9
9
|
|
|
10
10
|
/* Structural elements: full reset */
|
|
11
|
-
&,
|
|
12
|
-
& .
|
|
11
|
+
&,
|
|
12
|
+
& .table,
|
|
13
|
+
& .header,
|
|
14
|
+
& .thead,
|
|
15
|
+
& .body,
|
|
16
|
+
& .ibody,
|
|
17
|
+
& .draggable,
|
|
18
|
+
& .tr {
|
|
13
19
|
box-sizing: border-box;
|
|
14
20
|
margin: 0;
|
|
15
21
|
padding: 0;
|
|
@@ -17,93 +23,109 @@ var g = d.div`
|
|
|
17
23
|
|
|
18
24
|
/* User-facing cells: only box-sizing reset — no padding/margin override
|
|
19
25
|
so className and styled-components can customize freely */
|
|
20
|
-
& .th,
|
|
26
|
+
& .th,
|
|
27
|
+
& .td {
|
|
21
28
|
box-sizing: border-box;
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
&.is-dragging,
|
|
31
|
+
&.is-dragging,
|
|
32
|
+
&.is-dragging * {
|
|
33
|
+
cursor: -webkit-grabbing !important;
|
|
34
|
+
cursor: grabbing !important;
|
|
25
35
|
user-select: none !important;
|
|
26
36
|
-webkit-user-select: none !important;
|
|
37
|
+
-webkit-touch-callout: none !important;
|
|
27
38
|
}
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
|
|
40
|
+
/* When a DragHandle exists, only the handle shows grab cursor */
|
|
41
|
+
&:not(.is-dragging) .draggable:has([data-drag-handle]) > div {
|
|
42
|
+
cursor: default !important;
|
|
43
|
+
}
|
|
44
|
+
&:not(.is-dragging) [data-drag-handle] {
|
|
45
|
+
cursor: -webkit-grab;
|
|
46
|
+
cursor: grab;
|
|
47
|
+
}
|
|
48
|
+
`, b = t(void 0), x = () => {
|
|
49
|
+
let e = a(b);
|
|
30
50
|
if (e === void 0) throw Error("useTable must be used within a TableProvider");
|
|
31
51
|
return e;
|
|
32
|
-
},
|
|
33
|
-
let t =
|
|
52
|
+
}, S = 30, C = (e) => {
|
|
53
|
+
let { headerRef: t, bodyRef: n } = e, r = d(null), a = d(!1), s = d(!1), c = d(0), l = d(null), u = d({
|
|
34
54
|
x: 0,
|
|
35
55
|
y: 0
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
}, []),
|
|
39
|
-
|
|
40
|
-
}, []),
|
|
41
|
-
let
|
|
42
|
-
if (!
|
|
43
|
-
let
|
|
44
|
-
if (
|
|
45
|
-
let e =
|
|
46
|
-
if (
|
|
47
|
-
let t = e.y <
|
|
56
|
+
}), f = d(null), p = i((e) => {
|
|
57
|
+
f.current = e;
|
|
58
|
+
}, []), m = i(() => {
|
|
59
|
+
s.current = !1, a.current = !1, l.current !== null && (cancelAnimationFrame(l.current), l.current = null);
|
|
60
|
+
}, []), h = i((e, t, n) => {
|
|
61
|
+
let i = n === "vertical", o = i ? s : a;
|
|
62
|
+
if (!o.current) return;
|
|
63
|
+
let d = f.current;
|
|
64
|
+
if (d) {
|
|
65
|
+
let e = u.current;
|
|
66
|
+
if (i) {
|
|
67
|
+
let t = e.y < d.top + S, n = e.y > d.bottom - S;
|
|
48
68
|
if (!t && !n) {
|
|
49
|
-
|
|
69
|
+
o.current = !1;
|
|
50
70
|
return;
|
|
51
71
|
}
|
|
52
72
|
} else {
|
|
53
|
-
let t = e.x <
|
|
73
|
+
let t = e.x < d.left + S, n = e.x > d.right - S;
|
|
54
74
|
if (!t && !n) {
|
|
55
|
-
|
|
75
|
+
o.current = !1;
|
|
56
76
|
return;
|
|
57
77
|
}
|
|
58
78
|
}
|
|
59
79
|
}
|
|
60
|
-
let p =
|
|
61
|
-
|
|
62
|
-
let m =
|
|
80
|
+
let p = i ? t.scrollHeight - t.clientHeight : t.scrollWidth - t.clientWidth;
|
|
81
|
+
i ? t.scrollTop += e : t.scrollLeft += e;
|
|
82
|
+
let m = i ? t.scrollTop : t.scrollLeft;
|
|
63
83
|
if (m >= p || m <= 0) {
|
|
64
|
-
|
|
84
|
+
o.current = !1;
|
|
65
85
|
return;
|
|
66
86
|
}
|
|
67
|
-
|
|
87
|
+
c.current += e / 1e3, l.current = requestAnimationFrame(() => r.current?.(e + c.current, t, n));
|
|
68
88
|
}, []);
|
|
69
|
-
return {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
return o(() => {
|
|
90
|
+
r.current = h;
|
|
91
|
+
}, [h]), {
|
|
92
|
+
startAutoScroll: i((e, t, n) => {
|
|
93
|
+
let r = n === "vertical" ? s : a;
|
|
94
|
+
r.current || (r.current = !0, c.current = 0, l.current = requestAnimationFrame(() => h(e, t, n)));
|
|
95
|
+
}, [h]),
|
|
96
|
+
stopAutoScroll: m,
|
|
97
|
+
setContainerRect: p,
|
|
98
|
+
isAutoScrollingVertical: s,
|
|
99
|
+
isAutoScrollingHorizontal: a,
|
|
100
|
+
pointerRef: u,
|
|
101
|
+
BodyScrollHandle: i((e) => {
|
|
102
|
+
t?.current && e.currentTarget && (t.current.scrollLeft = e.currentTarget.scrollLeft);
|
|
103
|
+
}, [t]),
|
|
104
|
+
HeaderScrollHandle: i((e) => {
|
|
105
|
+
n?.current && e.currentTarget && (n.current.scrollLeft = e.currentTarget.scrollLeft);
|
|
106
|
+
}, [n])
|
|
85
107
|
};
|
|
86
|
-
},
|
|
87
|
-
function
|
|
88
|
-
let a =
|
|
108
|
+
}, w = 300, T = 8;
|
|
109
|
+
function E(e, t, n, r) {
|
|
110
|
+
let a = d(null), o = d({
|
|
89
111
|
x: 0,
|
|
90
112
|
y: 0
|
|
91
|
-
}), s =
|
|
113
|
+
}), s = d(null), c = d(!1), l = d(null), u = i(() => {
|
|
92
114
|
a.current &&= (clearTimeout(a.current), null), s.current = null, l.current &&= (l.current(), null);
|
|
93
115
|
}, []);
|
|
94
116
|
return {
|
|
95
117
|
touchStart: i((i) => {
|
|
96
118
|
if (i.target === i.currentTarget) return;
|
|
97
|
-
let
|
|
98
|
-
for (;
|
|
99
|
-
if (
|
|
119
|
+
let d = i.target, f = !1;
|
|
120
|
+
for (; d && !(d.dataset?.contextid || d.dataset?.disabled === "true");) {
|
|
121
|
+
if (d.dataset?.id) {
|
|
100
122
|
f = !0;
|
|
101
123
|
break;
|
|
102
124
|
}
|
|
103
|
-
|
|
125
|
+
d = d.parentNode;
|
|
104
126
|
}
|
|
105
127
|
if (!f) return;
|
|
106
|
-
|
|
128
|
+
u(), c.current = !0, window.getSelection()?.removeAllRanges();
|
|
107
129
|
let p = i.touches[0];
|
|
108
130
|
o.current = {
|
|
109
131
|
x: p.clientX,
|
|
@@ -111,7 +133,9 @@ function C(e, t, n, r) {
|
|
|
111
133
|
}, s.current = i;
|
|
112
134
|
let m = e.tableRef?.current;
|
|
113
135
|
if (!m) return;
|
|
114
|
-
let h = !1, g = !1, _ = p.clientY, v = p.clientX, y = (
|
|
136
|
+
let h = !1, g = !1, _ = p.clientY, v = p.clientX, y = (e) => e.preventDefault();
|
|
137
|
+
document.addEventListener("selectstart", y);
|
|
138
|
+
let b = (t) => {
|
|
115
139
|
t.preventDefault();
|
|
116
140
|
let n = t.touches[0];
|
|
117
141
|
if (g) {
|
|
@@ -120,35 +144,35 @@ function C(e, t, n, r) {
|
|
|
120
144
|
} else if (h) r(n.clientX, n.clientY);
|
|
121
145
|
else {
|
|
122
146
|
let e = n.clientX - o.current.x, t = n.clientY - o.current.y;
|
|
123
|
-
(Math.abs(e) >
|
|
147
|
+
(Math.abs(e) > T || Math.abs(t) > T) && (a.current &&= (clearTimeout(a.current), null), s.current = null, g = !0, _ = n.clientY, v = n.clientX);
|
|
124
148
|
}
|
|
125
|
-
},
|
|
126
|
-
h ? (
|
|
149
|
+
}, x = () => {
|
|
150
|
+
h ? (S(), n()) : (u(), setTimeout(() => {
|
|
127
151
|
c.current = !1;
|
|
128
152
|
}, 400));
|
|
129
|
-
},
|
|
130
|
-
m.removeEventListener("touchmove",
|
|
153
|
+
}, S = () => {
|
|
154
|
+
m.removeEventListener("touchmove", b), m.removeEventListener("touchend", x), m.removeEventListener("touchcancel", x), document.removeEventListener("selectstart", y), l.current = null;
|
|
131
155
|
};
|
|
132
|
-
m.addEventListener("touchmove",
|
|
156
|
+
m.addEventListener("touchmove", b, { passive: !1 }), m.addEventListener("touchend", x, !1), m.addEventListener("touchcancel", x, !1), l.current = S, a.current = setTimeout(() => {
|
|
133
157
|
a.current = null, h = !0;
|
|
134
158
|
let e = s.current;
|
|
135
159
|
s.current = null, e && t(e, p.clientX, p.clientY);
|
|
136
|
-
},
|
|
160
|
+
}, w);
|
|
137
161
|
}, [
|
|
138
162
|
t,
|
|
139
163
|
n,
|
|
140
164
|
r,
|
|
141
|
-
|
|
165
|
+
u,
|
|
142
166
|
e.tableRef?.current,
|
|
143
167
|
e.bodyRef?.current
|
|
144
168
|
]),
|
|
145
|
-
cancelLongPress:
|
|
169
|
+
cancelLongPress: u,
|
|
146
170
|
isTouchActiveRef: c
|
|
147
171
|
};
|
|
148
172
|
}
|
|
149
173
|
//#endregion
|
|
150
174
|
//#region src/Components/utils.ts
|
|
151
|
-
var
|
|
175
|
+
var D = (e, t) => {
|
|
152
176
|
let n = e, r = 0, i = t.length - 1;
|
|
153
177
|
for (; r < i;) {
|
|
154
178
|
let e = Math.floor((r + i) / 2), a = t[e];
|
|
@@ -156,7 +180,7 @@ var w = (e, t) => {
|
|
|
156
180
|
n < a.itemTop ? i = e - 1 : r = e + 1;
|
|
157
181
|
}
|
|
158
182
|
return +t[r].index;
|
|
159
|
-
},
|
|
183
|
+
}, O = (e, t) => {
|
|
160
184
|
let n = e, r = 0, i = t.length - 1;
|
|
161
185
|
for (; r < i;) {
|
|
162
186
|
let e = Math.floor((r + i) / 2), a = t[e];
|
|
@@ -164,17 +188,20 @@ var w = (e, t) => {
|
|
|
164
188
|
n < a.itemLeft ? i = e - 1 : r = e + 1;
|
|
165
189
|
}
|
|
166
190
|
return +t[r].index;
|
|
167
|
-
},
|
|
168
|
-
let
|
|
191
|
+
}, k = (e, t, n) => {
|
|
192
|
+
let r = Number(e);
|
|
193
|
+
return t !== void 0 && r < t || n !== void 0 && r > n;
|
|
194
|
+
}, A = "transform 450ms cubic-bezier(0.2, 0, 0, 1)", j = 200, M = (e, t, n, r, a, s) => {
|
|
195
|
+
let { startAutoScroll: l, stopAutoScroll: u, setContainerRect: f, pointerRef: p } = C(e), m = d(null), g = d(null), _ = d(null), v = d({
|
|
169
196
|
x: 0,
|
|
170
197
|
y: 0
|
|
171
|
-
}),
|
|
198
|
+
}), y = d(null), b = d(null), x = d({
|
|
172
199
|
width: 0,
|
|
173
200
|
height: 0
|
|
174
|
-
}),
|
|
201
|
+
}), S = d({
|
|
175
202
|
x: 0,
|
|
176
203
|
y: 0
|
|
177
|
-
}),
|
|
204
|
+
}), w = d(!1), T = i(() => {
|
|
178
205
|
let t = e.bodyRef?.current;
|
|
179
206
|
if (!t) return null;
|
|
180
207
|
let n = t.scrollTop, r = t.getBoundingClientRect().top, i = t.querySelectorAll(".draggable[data-type=\"row\"]"), o = [];
|
|
@@ -191,7 +218,7 @@ var w = (e, t) => {
|
|
|
191
218
|
}
|
|
192
219
|
let { start: s, end: c } = a.rowDragRange;
|
|
193
220
|
return (s || c) && (o = o.filter((e) => (!s || +e.index >= s) && (!c || +e.index < c))), o;
|
|
194
|
-
}, [e.bodyRef, a.rowDragRange]),
|
|
221
|
+
}, [e.bodyRef, a.rowDragRange]), k = i(() => {
|
|
195
222
|
let t = e.headerRef?.current;
|
|
196
223
|
if (!t || !t.children[0]) return null;
|
|
197
224
|
let n = Array.from(t.children[0].children).map((e) => {
|
|
@@ -208,24 +235,24 @@ var w = (e, t) => {
|
|
|
208
235
|
let t = +e.index;
|
|
209
236
|
return (r === void 0 || t >= r) && (i === void 0 || t < i);
|
|
210
237
|
})), n;
|
|
211
|
-
}, [e.headerRef, a.columnDragRange]),
|
|
238
|
+
}, [e.headerRef, a.columnDragRange]), M = i((t, n, r, i) => {
|
|
212
239
|
let a = e.placeholderRef?.current;
|
|
213
240
|
if (!a || !t) {
|
|
214
241
|
a && (a.style.display = "none");
|
|
215
242
|
return;
|
|
216
243
|
}
|
|
217
|
-
let o =
|
|
244
|
+
let o = x.current, s = t.getBoundingClientRect(), c = e.tableRef?.current?.getBoundingClientRect(), l = (n ?? 0) < (r ?? 0);
|
|
218
245
|
a.style.display = "block", i === "row" ? (a.style.top = `${l ? s.top + s.height - o.height : s.top}px`, a.style.left = `${c?.left ?? s.left}px`, a.style.width = `${c?.width ?? s.width}px`, a.style.height = `${o.height}px`) : (a.style.top = `${c?.top ?? s.top}px`, a.style.left = `${l ? s.left + s.width - o.width : s.left}px`, a.style.width = `${o.width}px`, a.style.height = `${c?.height ?? s.height}px`);
|
|
219
|
-
}, [e.placeholderRef, e.tableRef]),
|
|
246
|
+
}, [e.placeholderRef, e.tableRef]), N = i((t, n, r) => {
|
|
220
247
|
if (t === null || n === null) return;
|
|
221
|
-
let i =
|
|
248
|
+
let i = x.current, a = null, o = (e, r, i, o) => {
|
|
222
249
|
if (!e) return;
|
|
223
250
|
let s = e.querySelectorAll(r);
|
|
224
251
|
for (let e = 0; e < s.length; e++) {
|
|
225
252
|
let r = s[e], c = +r.dataset.index, l = r.firstElementChild;
|
|
226
253
|
if (!l) continue;
|
|
227
254
|
let u = "";
|
|
228
|
-
c > t && c <= n ? u = `translate${i}(-${o}px)` : c < t && c >= n && (u = `translate${i}(${o}px)`), l.style.transform = u, l.style.transition = c === t ? "none" :
|
|
255
|
+
c > t && c <= n ? u = `translate${i}(-${o}px)` : c < t && c >= n && (u = `translate${i}(${o}px)`), l.style.transform = u, l.style.transition = c === t ? "none" : A, c === n ? (r.setAttribute("data-drop-target", "true"), a = r) : r.removeAttribute("data-drop-target");
|
|
229
256
|
}
|
|
230
257
|
};
|
|
231
258
|
if (r === "row") o(e.bodyRef?.current ?? null, ".draggable[data-type=\"row\"]", "Y", i.height);
|
|
@@ -236,16 +263,16 @@ var w = (e, t) => {
|
|
|
236
263
|
let e = r.querySelectorAll(".td[data-col-index]");
|
|
237
264
|
for (let r = 0; r < e.length; r++) {
|
|
238
265
|
let a = e[r], o = +a.dataset.colIndex, s = "";
|
|
239
|
-
o > t && o <= n ? s = `translateX(-${i.width}px)` : o < t && o >= n && (s = `translateX(${i.width}px)`), a.style.transform = s, a.style.transition =
|
|
266
|
+
o > t && o <= n ? s = `translateX(-${i.width}px)` : o < t && o >= n && (s = `translateX(${i.width}px)`), a.style.transform = s, a.style.transition = A;
|
|
240
267
|
}
|
|
241
268
|
}
|
|
242
269
|
}
|
|
243
|
-
|
|
270
|
+
M(a, t, n, r);
|
|
244
271
|
}, [
|
|
245
272
|
e.bodyRef,
|
|
246
273
|
e.headerRef,
|
|
247
|
-
|
|
248
|
-
]),
|
|
274
|
+
M
|
|
275
|
+
]), P = i(() => {
|
|
249
276
|
let t = e.placeholderRef?.current;
|
|
250
277
|
t && (t.style.display = "none");
|
|
251
278
|
for (let t of [e.bodyRef?.current, e.headerRef?.current]) {
|
|
@@ -254,19 +281,19 @@ var w = (e, t) => {
|
|
|
254
281
|
for (let t = 0; t < e.length; t++) {
|
|
255
282
|
e[t].removeAttribute("data-drop-target");
|
|
256
283
|
let n = e[t].firstElementChild;
|
|
257
|
-
n && (n.style.
|
|
284
|
+
n && (n.style.transition = "none", n.style.transform = "");
|
|
258
285
|
}
|
|
259
286
|
}
|
|
260
287
|
let n = e.bodyRef?.current;
|
|
261
288
|
if (n) {
|
|
262
289
|
let e = n.querySelectorAll(".td[data-col-index]");
|
|
263
|
-
for (let t = 0; t < e.length; t++) e[t].style.
|
|
290
|
+
for (let t = 0; t < e.length; t++) e[t].style.transition = "none", e[t].style.transform = "";
|
|
264
291
|
}
|
|
265
292
|
}, [
|
|
266
293
|
e.bodyRef,
|
|
267
294
|
e.headerRef,
|
|
268
295
|
e.placeholderRef
|
|
269
|
-
]),
|
|
296
|
+
]), F = (e) => {
|
|
270
297
|
let t = e, n = !1;
|
|
271
298
|
for (; t;) {
|
|
272
299
|
if (t.dataset?.dragHandle === "true" && (n = !0), t.dataset?.contextid || t.dataset?.disabled === "true") return null;
|
|
@@ -277,46 +304,46 @@ var w = (e, t) => {
|
|
|
277
304
|
t = t.parentNode;
|
|
278
305
|
}
|
|
279
306
|
return null;
|
|
280
|
-
},
|
|
281
|
-
let a =
|
|
307
|
+
}, I = i((t, r, i) => {
|
|
308
|
+
let a = F(t.target);
|
|
282
309
|
if (!a) return;
|
|
283
310
|
let { element: o, foundHandle: s } = a;
|
|
284
311
|
if (!s && o.querySelector("[data-drag-handle]")) return;
|
|
285
|
-
let c = o.dataset.id, l = +o.dataset.index, u = o.dataset.type,
|
|
286
|
-
|
|
312
|
+
let c = o.dataset.id, l = +o.dataset.index, u = o.dataset.type, d = t.type === "touchstart";
|
|
313
|
+
_.current = u ?? null, y.current = l, b.current = null, w.current = !1, d && o.dispatchEvent(new PointerEvent("pointerdown", {
|
|
287
314
|
bubbles: !0,
|
|
288
315
|
pointerType: "mouse"
|
|
289
316
|
}));
|
|
290
|
-
let
|
|
291
|
-
|
|
292
|
-
width:
|
|
293
|
-
height:
|
|
317
|
+
let h = u === "row" ? e.bodyRef?.current?.scrollLeft ?? 0 : 0, C = o.getBoundingClientRect();
|
|
318
|
+
x.current = {
|
|
319
|
+
width: C.width,
|
|
320
|
+
height: C.height
|
|
294
321
|
};
|
|
295
|
-
let
|
|
296
|
-
x: r -
|
|
297
|
-
y: i -
|
|
322
|
+
let E = {
|
|
323
|
+
x: r - C.left - h,
|
|
324
|
+
y: i - C.top
|
|
298
325
|
};
|
|
299
|
-
|
|
326
|
+
v.current = E, S.current = {
|
|
300
327
|
x: r,
|
|
301
328
|
y: i
|
|
302
|
-
},
|
|
329
|
+
}, p.current = {
|
|
303
330
|
x: r,
|
|
304
331
|
y: i
|
|
305
332
|
};
|
|
306
333
|
let D = {
|
|
307
|
-
x:
|
|
308
|
-
y:
|
|
334
|
+
x: C.left + h,
|
|
335
|
+
y: C.top
|
|
309
336
|
};
|
|
310
|
-
|
|
337
|
+
m.current = u === "row" ? T() : k();
|
|
311
338
|
let O = e.bodyRef?.current;
|
|
312
339
|
if (O) {
|
|
313
340
|
let e = O.getBoundingClientRect();
|
|
314
|
-
|
|
341
|
+
g.current = e, f(e);
|
|
315
342
|
}
|
|
316
|
-
let
|
|
317
|
-
|
|
318
|
-
let
|
|
319
|
-
|
|
343
|
+
let A = e.tableRef?.current;
|
|
344
|
+
A && (A.style.touchAction = "none");
|
|
345
|
+
let j = e.cloneRef?.current;
|
|
346
|
+
j && (j.style.transform = `translate(${D.x}px, ${D.y}px)`);
|
|
320
347
|
let M = e.tableRef?.current;
|
|
321
348
|
M && n({
|
|
322
349
|
type: "setTableDimensions",
|
|
@@ -328,17 +355,17 @@ var w = (e, t) => {
|
|
|
328
355
|
type: "dragStart",
|
|
329
356
|
value: {
|
|
330
357
|
rect: {
|
|
331
|
-
draggedItemHeight:
|
|
332
|
-
draggedItemWidth:
|
|
358
|
+
draggedItemHeight: C.height,
|
|
359
|
+
draggedItemWidth: C.width
|
|
333
360
|
},
|
|
334
361
|
dragged: {
|
|
335
|
-
initial:
|
|
362
|
+
initial: E,
|
|
336
363
|
translate: D,
|
|
337
|
-
draggedID: c,
|
|
364
|
+
draggedID: c ?? null,
|
|
338
365
|
isDragging: !0,
|
|
339
366
|
sourceIndex: l
|
|
340
367
|
},
|
|
341
|
-
dragType: u
|
|
368
|
+
dragType: u ?? null
|
|
342
369
|
}
|
|
343
370
|
});
|
|
344
371
|
let N = () => {
|
|
@@ -355,48 +382,65 @@ var w = (e, t) => {
|
|
|
355
382
|
}, [
|
|
356
383
|
n,
|
|
357
384
|
e,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
]),
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
})), h.current = null, _.current = null, v.current = null;
|
|
385
|
+
T,
|
|
386
|
+
k,
|
|
387
|
+
p,
|
|
388
|
+
f
|
|
389
|
+
]), L = i((t, r, i, a, o) => {
|
|
390
|
+
let c = e.cloneRef?.current;
|
|
391
|
+
c && (c.style.visibility = "hidden");
|
|
392
|
+
let l = e.tableRef?.current;
|
|
393
|
+
l && (l.style.touchAction = ""), h(() => {
|
|
394
|
+
s && t !== null && r !== null && (i === "row" || i === "column") && s({
|
|
395
|
+
sourceIndex: t,
|
|
396
|
+
targetIndex: r,
|
|
397
|
+
dragType: i
|
|
398
|
+
}), n({
|
|
399
|
+
type: "dragEnd",
|
|
400
|
+
value: {
|
|
401
|
+
targetIndex: r,
|
|
402
|
+
sourceIndex: t
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}), P();
|
|
406
|
+
let u = e.bodyRef?.current;
|
|
407
|
+
u && (u.scrollTop = a, u.scrollLeft = o, requestAnimationFrame(() => {
|
|
408
|
+
u.scrollTop = a, u.scrollLeft = o;
|
|
409
|
+
}));
|
|
384
410
|
}, [
|
|
385
411
|
n,
|
|
386
|
-
l,
|
|
387
412
|
e.bodyRef,
|
|
388
413
|
e.cloneRef,
|
|
389
414
|
e.tableRef,
|
|
390
|
-
|
|
415
|
+
P,
|
|
391
416
|
s
|
|
392
|
-
]),
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
417
|
+
]), R = i(() => {
|
|
418
|
+
if (w.current) return;
|
|
419
|
+
w.current = !0, V(), setTimeout(() => {
|
|
420
|
+
H.current = !1;
|
|
421
|
+
}, 400);
|
|
422
|
+
let t = b.current, n = y.current, r = _.current, i = e.bodyRef?.current, a = i?.scrollTop ?? 0, o = i?.scrollLeft ?? 0;
|
|
423
|
+
m.current = null, g.current = null, u(), _.current = null, y.current = null, b.current = null;
|
|
424
|
+
let s = e.cloneRef?.current, c = e.placeholderRef?.current;
|
|
425
|
+
if (s && c && c.style.display !== "none") {
|
|
426
|
+
let e = parseFloat(c.style.left) || 0, i = parseFloat(c.style.top) || 0;
|
|
427
|
+
s.style.transition = `transform ${j}ms cubic-bezier(0.2, 0, 0, 1)`, s.style.transform = `translate(${e}px, ${i}px)`, setTimeout(() => L(n, t, r, a, o), j);
|
|
428
|
+
} else L(n, t, r, a, o);
|
|
429
|
+
}, [
|
|
430
|
+
u,
|
|
431
|
+
e.bodyRef,
|
|
432
|
+
e.placeholderRef,
|
|
433
|
+
e.cloneRef,
|
|
434
|
+
L
|
|
435
|
+
]), z = d(() => {}), { touchStart: B, cancelLongPress: V, isTouchActiveRef: H } = E(e, I, R, (e, t) => z.current(e, t)), U = i((e) => {
|
|
436
|
+
e.target !== e.currentTarget && (H.current || I(e, e.clientX, e.clientY));
|
|
437
|
+
}, [I, H]), W = i((t, n) => {
|
|
438
|
+
if (w.current) return;
|
|
439
|
+
let i = v.current;
|
|
440
|
+
S.current = {
|
|
397
441
|
x: t,
|
|
398
442
|
y: n
|
|
399
|
-
},
|
|
443
|
+
}, p.current = {
|
|
400
444
|
x: t,
|
|
401
445
|
y: n
|
|
402
446
|
};
|
|
@@ -404,7 +448,7 @@ var w = (e, t) => {
|
|
|
404
448
|
if (a) {
|
|
405
449
|
a.style.transform = `translate(${t - i.x}px, ${n - i.y}px)`;
|
|
406
450
|
let r = e.bodyRef?.current;
|
|
407
|
-
if (r) if (
|
|
451
|
+
if (r) if (_.current === "row") a.scrollLeft = r.scrollLeft;
|
|
408
452
|
else {
|
|
409
453
|
let e = a.querySelector(".clone-body");
|
|
410
454
|
e && (e.scrollTop = r.scrollTop);
|
|
@@ -412,47 +456,56 @@ var w = (e, t) => {
|
|
|
412
456
|
}
|
|
413
457
|
let o = e.bodyRef?.current;
|
|
414
458
|
if (!o) return;
|
|
415
|
-
let s =
|
|
416
|
-
s || (s = o.getBoundingClientRect(),
|
|
417
|
-
let
|
|
418
|
-
d === "row" ? n < s.top + 30 ? (
|
|
419
|
-
let
|
|
420
|
-
d === "row" ? (
|
|
459
|
+
let s = g.current;
|
|
460
|
+
s || (s = o.getBoundingClientRect(), g.current = s);
|
|
461
|
+
let c = 0, d = _.current || r;
|
|
462
|
+
d === "row" ? n < s.top + 30 ? (l(-5, o, "vertical"), m.current = null) : n > s.bottom - 30 ? (l(5, o, "vertical"), m.current = null) : u() : t < s.left + 30 ? (l(-5, o, "horizontal"), m.current = null) : t > s.right - 30 ? (l(5, o, "horizontal"), m.current = null) : u();
|
|
463
|
+
let f;
|
|
464
|
+
d === "row" ? (f = T(), m.current = f, f && f.length > 0 && (c = D(n - s.top + o.scrollTop, f))) : (f = k(), m.current = f, f && f.length > 0 && (c = O(t, f))), c !== b.current && (b.current = c, requestAnimationFrame(() => N(y.current, c, d)));
|
|
421
465
|
}, [
|
|
422
466
|
r,
|
|
423
467
|
e.bodyRef,
|
|
424
468
|
e.cloneRef,
|
|
425
|
-
|
|
426
|
-
E,
|
|
427
|
-
c,
|
|
428
|
-
l,
|
|
469
|
+
T,
|
|
429
470
|
k,
|
|
430
|
-
|
|
471
|
+
l,
|
|
472
|
+
u,
|
|
473
|
+
N,
|
|
474
|
+
p
|
|
431
475
|
]);
|
|
432
|
-
|
|
433
|
-
let
|
|
434
|
-
|
|
476
|
+
z.current = W;
|
|
477
|
+
let G = i(() => {
|
|
478
|
+
V(), m.current = null, g.current = null;
|
|
435
479
|
let t = e.cloneRef?.current;
|
|
436
|
-
t && (t.style.
|
|
480
|
+
t && (t.style.visibility = "hidden");
|
|
437
481
|
let r = e.tableRef?.current;
|
|
438
|
-
r && (r.style.touchAction = ""),
|
|
482
|
+
r && (r.style.touchAction = ""), n({
|
|
439
483
|
type: "dragEnd",
|
|
440
484
|
value: {
|
|
441
485
|
targetIndex: null,
|
|
442
486
|
sourceIndex: null
|
|
443
487
|
}
|
|
444
|
-
}),
|
|
488
|
+
}), u(), _.current = null, y.current = null, b.current = null;
|
|
445
489
|
}, [
|
|
446
490
|
n,
|
|
447
|
-
|
|
491
|
+
u,
|
|
448
492
|
e.cloneRef,
|
|
449
493
|
e.tableRef,
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
494
|
+
V
|
|
495
|
+
]), K = i((e) => {
|
|
496
|
+
e.key === "Escape" && G();
|
|
497
|
+
}, [G]);
|
|
498
|
+
return c(() => {
|
|
499
|
+
if (!t.isDragging) {
|
|
500
|
+
P();
|
|
501
|
+
let t = e.cloneRef?.current;
|
|
502
|
+
t && (t.style.transition = "", t.style.transform = "translate(0px, 0px)", t.style.visibility = "", t.scrollLeft = 0);
|
|
503
|
+
}
|
|
504
|
+
}, [
|
|
505
|
+
t.isDragging,
|
|
506
|
+
P,
|
|
507
|
+
e.cloneRef
|
|
508
|
+
]), o(() => {
|
|
456
509
|
let t = e.bodyRef?.current;
|
|
457
510
|
return t && (t.style.touchAction = "none"), () => {
|
|
458
511
|
t && (t.style.touchAction = "");
|
|
@@ -460,23 +513,23 @@ var w = (e, t) => {
|
|
|
460
513
|
}, [e.bodyRef]), o(() => {
|
|
461
514
|
if (!t.isDragging) return;
|
|
462
515
|
let e = (e) => {
|
|
463
|
-
|
|
516
|
+
W(e.clientX, e.clientY);
|
|
464
517
|
}, n = () => {
|
|
465
|
-
|
|
518
|
+
R();
|
|
466
519
|
};
|
|
467
|
-
return window.addEventListener("pointermove", e), window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n), window.addEventListener("keydown",
|
|
468
|
-
window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n), window.removeEventListener("keydown",
|
|
520
|
+
return window.addEventListener("pointermove", e), window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n), window.addEventListener("keydown", K), () => {
|
|
521
|
+
window.removeEventListener("pointermove", e), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n), window.removeEventListener("keydown", K);
|
|
469
522
|
};
|
|
470
523
|
}, [
|
|
471
524
|
t.isDragging,
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
525
|
+
W,
|
|
526
|
+
R,
|
|
527
|
+
K
|
|
475
528
|
]), {
|
|
476
|
-
dragStart:
|
|
477
|
-
touchStart:
|
|
529
|
+
dragStart: U,
|
|
530
|
+
touchStart: B
|
|
478
531
|
};
|
|
479
|
-
},
|
|
532
|
+
}, N = {
|
|
480
533
|
columnDragRange: {
|
|
481
534
|
start: void 0,
|
|
482
535
|
end: void 0
|
|
@@ -487,7 +540,7 @@ var w = (e, t) => {
|
|
|
487
540
|
},
|
|
488
541
|
defaultSizing: 50
|
|
489
542
|
};
|
|
490
|
-
function
|
|
543
|
+
function P(e, t) {
|
|
491
544
|
switch (t.type) {
|
|
492
545
|
case "setClone": return {
|
|
493
546
|
...e,
|
|
@@ -504,47 +557,15 @@ function A(e, t) {
|
|
|
504
557
|
...e,
|
|
505
558
|
dragType: t.value
|
|
506
559
|
};
|
|
507
|
-
case "setRect": return {
|
|
508
|
-
...e,
|
|
509
|
-
rect: t.value
|
|
510
|
-
};
|
|
511
560
|
case "setTableDimensions": return {
|
|
512
561
|
...e,
|
|
513
562
|
tableDimensions: t.value
|
|
514
563
|
};
|
|
515
|
-
case "
|
|
516
|
-
...e,
|
|
517
|
-
refs: {
|
|
518
|
-
...e.refs,
|
|
519
|
-
tableRef: t.value
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
case "setBodyRef": return {
|
|
564
|
+
case "setRef": return {
|
|
523
565
|
...e,
|
|
524
566
|
refs: {
|
|
525
567
|
...e.refs,
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
};
|
|
529
|
-
case "setHeaderRef": return {
|
|
530
|
-
...e,
|
|
531
|
-
refs: {
|
|
532
|
-
...e.refs,
|
|
533
|
-
headerRef: t.value
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
case "setCloneRef": return {
|
|
537
|
-
...e,
|
|
538
|
-
refs: {
|
|
539
|
-
...e.refs,
|
|
540
|
-
cloneRef: t.value
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
case "setPlaceholderRef": return {
|
|
544
|
-
...e,
|
|
545
|
-
refs: {
|
|
546
|
-
...e.refs,
|
|
547
|
-
placeholderRef: t.value
|
|
568
|
+
[t.refName]: t.value
|
|
548
569
|
}
|
|
549
570
|
};
|
|
550
571
|
case "setBodyScrollBarWidth": return {
|
|
@@ -561,7 +582,10 @@ function A(e, t) {
|
|
|
561
582
|
};
|
|
562
583
|
case "setOptions": return {
|
|
563
584
|
...e,
|
|
564
|
-
options:
|
|
585
|
+
options: {
|
|
586
|
+
...e.options,
|
|
587
|
+
...t.value
|
|
588
|
+
}
|
|
565
589
|
};
|
|
566
590
|
case "dragStart": return {
|
|
567
591
|
...e,
|
|
@@ -595,10 +619,10 @@ function A(e, t) {
|
|
|
595
619
|
draggedItemHeight: 0
|
|
596
620
|
}
|
|
597
621
|
};
|
|
598
|
-
default: throw Error(
|
|
622
|
+
default: throw Error("Unhandled action");
|
|
599
623
|
}
|
|
600
624
|
}
|
|
601
|
-
var
|
|
625
|
+
var F = {
|
|
602
626
|
clone: null,
|
|
603
627
|
dragged: {
|
|
604
628
|
initial: {
|
|
@@ -624,65 +648,68 @@ var j = {
|
|
|
624
648
|
width: 0
|
|
625
649
|
},
|
|
626
650
|
refs: {
|
|
627
|
-
tableRef: null,
|
|
628
|
-
bodyRef: null,
|
|
629
|
-
headerRef: null,
|
|
630
|
-
cloneRef: null,
|
|
631
|
-
placeholderRef: null
|
|
651
|
+
tableRef: { current: null },
|
|
652
|
+
bodyRef: { current: null },
|
|
653
|
+
headerRef: { current: null },
|
|
654
|
+
cloneRef: { current: null },
|
|
655
|
+
placeholderRef: { current: null }
|
|
632
656
|
},
|
|
633
657
|
bodyScrollBarWidth: 0,
|
|
634
|
-
options:
|
|
658
|
+
options: N,
|
|
635
659
|
widths: [],
|
|
636
660
|
columnIds: []
|
|
637
|
-
},
|
|
661
|
+
}, I = {
|
|
638
662
|
position: "relative",
|
|
639
663
|
display: "flex",
|
|
640
664
|
flexFlow: "column"
|
|
641
|
-
},
|
|
665
|
+
}, L = {
|
|
642
666
|
position: "fixed",
|
|
643
667
|
pointerEvents: "none",
|
|
644
668
|
zIndex: 3,
|
|
645
669
|
top: 0,
|
|
646
670
|
left: 0,
|
|
647
671
|
display: "none"
|
|
648
|
-
},
|
|
649
|
-
let
|
|
650
|
-
s(
|
|
651
|
-
let [
|
|
652
|
-
state:
|
|
653
|
-
dispatch:
|
|
654
|
-
}), [
|
|
672
|
+
}, R = n(({ children: e, className: t, style: n, options: r, onDragEnd: i, renderPlaceholder: a }, c) => {
|
|
673
|
+
let f = d(null), p = d(null), m = d(null);
|
|
674
|
+
s(c, () => f.current, []);
|
|
675
|
+
let [h, v] = u(P, F), x = l(() => ({
|
|
676
|
+
state: h,
|
|
677
|
+
dispatch: v
|
|
678
|
+
}), [h]);
|
|
655
679
|
o(() => {
|
|
656
|
-
|
|
657
|
-
type: "
|
|
680
|
+
v({
|
|
681
|
+
type: "setRef",
|
|
682
|
+
refName: "tableRef",
|
|
683
|
+
value: f
|
|
684
|
+
}), v({
|
|
685
|
+
type: "setRef",
|
|
686
|
+
refName: "cloneRef",
|
|
687
|
+
value: p
|
|
688
|
+
}), v({
|
|
689
|
+
type: "setRef",
|
|
690
|
+
refName: "placeholderRef",
|
|
658
691
|
value: m
|
|
659
|
-
}), b({
|
|
660
|
-
type: "setCloneRef",
|
|
661
|
-
value: h
|
|
662
|
-
}), b({
|
|
663
|
-
type: "setPlaceholderRef",
|
|
664
|
-
value: v
|
|
665
692
|
});
|
|
666
|
-
}, [
|
|
693
|
+
}, [f]), o(() => {
|
|
667
694
|
let e = () => {
|
|
668
|
-
|
|
695
|
+
f.current && v({
|
|
669
696
|
type: "setTableDimensions",
|
|
670
697
|
value: {
|
|
671
|
-
height:
|
|
672
|
-
width:
|
|
698
|
+
height: f.current.offsetHeight,
|
|
699
|
+
width: f.current.offsetWidth
|
|
673
700
|
}
|
|
674
701
|
});
|
|
675
702
|
};
|
|
676
703
|
return e(), window.addEventListener("resize", e), () => {
|
|
677
704
|
window.removeEventListener("resize", e);
|
|
678
705
|
};
|
|
679
|
-
}, [
|
|
680
|
-
|
|
706
|
+
}, [f]), o(() => {
|
|
707
|
+
r && v({
|
|
681
708
|
type: "setOptions",
|
|
682
709
|
value: r
|
|
683
710
|
});
|
|
684
711
|
}, [r]);
|
|
685
|
-
let { dragStart: S, touchStart: C } =
|
|
712
|
+
let { dragStart: S, touchStart: C } = M(h.refs, h.dragged, v, h.dragType, h.options, i), w = l(() => ({
|
|
686
713
|
position: "fixed",
|
|
687
714
|
zIndex: "5",
|
|
688
715
|
pointerEvents: "none",
|
|
@@ -690,50 +717,53 @@ var j = {
|
|
|
690
717
|
left: 0,
|
|
691
718
|
display: "flex",
|
|
692
719
|
flexDirection: "column",
|
|
693
|
-
height:
|
|
694
|
-
width:
|
|
720
|
+
height: h.dragType === "row" ? h.rect.draggedItemHeight : `${h.tableDimensions.height}px`,
|
|
721
|
+
width: h.dragType === "column" ? `${h.rect.draggedItemWidth}px` : `${h.tableDimensions.width}px`,
|
|
695
722
|
overflow: "hidden",
|
|
696
|
-
boxShadow:
|
|
723
|
+
boxShadow: h.dragged.isDragging ? "0 0 10px 0 rgba(0, 0, 0, 0.1)" : "none"
|
|
697
724
|
}), [
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
725
|
+
h.dragType,
|
|
726
|
+
h.dragged.isDragging,
|
|
727
|
+
h.rect.draggedItemHeight,
|
|
728
|
+
h.rect.draggedItemWidth,
|
|
729
|
+
h.tableDimensions.height,
|
|
730
|
+
h.tableDimensions.width
|
|
704
731
|
]);
|
|
705
|
-
return /* @__PURE__ */
|
|
732
|
+
return /* @__PURE__ */ g(b.Provider, {
|
|
706
733
|
value: x,
|
|
707
|
-
children: /* @__PURE__ */
|
|
708
|
-
className:
|
|
734
|
+
children: /* @__PURE__ */ _(y, {
|
|
735
|
+
className: h.dragged.isDragging ? "is-dragging" : "",
|
|
709
736
|
children: [
|
|
710
|
-
/* @__PURE__ */
|
|
737
|
+
/* @__PURE__ */ g("div", {
|
|
711
738
|
id: "portalroot",
|
|
712
739
|
style: {
|
|
713
740
|
...w,
|
|
714
|
-
visibility:
|
|
741
|
+
visibility: h.dragged.isDragging ? "visible" : "hidden"
|
|
715
742
|
},
|
|
716
|
-
ref:
|
|
717
|
-
children: /* @__PURE__ */
|
|
743
|
+
ref: p,
|
|
744
|
+
children: /* @__PURE__ */ g("div", {
|
|
718
745
|
style: {
|
|
719
746
|
flexShrink: 0,
|
|
720
747
|
order: -1
|
|
721
748
|
},
|
|
722
|
-
children:
|
|
749
|
+
children: h.clone
|
|
723
750
|
})
|
|
724
751
|
}),
|
|
725
|
-
|
|
726
|
-
ref:
|
|
727
|
-
style:
|
|
728
|
-
children: a()
|
|
752
|
+
/* @__PURE__ */ g("div", {
|
|
753
|
+
ref: m,
|
|
754
|
+
style: L,
|
|
755
|
+
children: a ? a() : /* @__PURE__ */ g("div", { style: {
|
|
756
|
+
width: "100%",
|
|
757
|
+
height: "100%"
|
|
758
|
+
} })
|
|
729
759
|
}),
|
|
730
|
-
/* @__PURE__ */
|
|
760
|
+
/* @__PURE__ */ g("div", {
|
|
731
761
|
"data-contextid": "context",
|
|
732
|
-
ref:
|
|
762
|
+
ref: f,
|
|
733
763
|
onMouseDown: S,
|
|
734
764
|
onTouchStart: C,
|
|
735
765
|
style: {
|
|
736
|
-
...
|
|
766
|
+
...I,
|
|
737
767
|
...n
|
|
738
768
|
},
|
|
739
769
|
className: `table ${t ?? ""}`,
|
|
@@ -743,129 +773,142 @@ var j = {
|
|
|
743
773
|
})
|
|
744
774
|
});
|
|
745
775
|
});
|
|
746
|
-
|
|
776
|
+
R.displayName = "TableProvider";
|
|
747
777
|
//#endregion
|
|
748
778
|
//#region src/Components/TableHeader.tsx
|
|
749
|
-
var
|
|
750
|
-
let
|
|
779
|
+
var z = n(({ children: e, style: t, className: n }, r) => {
|
|
780
|
+
let a = d(null), s = r || a, { state: u, dispatch: f } = x(), p = i((e) => "current" in e ? e.current : null, []);
|
|
751
781
|
o(() => {
|
|
752
|
-
|
|
753
|
-
type: "
|
|
782
|
+
a.current && f({
|
|
783
|
+
type: "setRef",
|
|
784
|
+
refName: "headerRef",
|
|
754
785
|
value: a
|
|
755
786
|
});
|
|
756
|
-
}, [
|
|
757
|
-
let { HeaderScrollHandle:
|
|
787
|
+
}, [f]);
|
|
788
|
+
let { HeaderScrollHandle: m } = C(u.refs), h = {
|
|
758
789
|
display: "flex",
|
|
759
790
|
flex: "1 0 auto"
|
|
760
|
-
},
|
|
791
|
+
}, _ = l(() => ({
|
|
761
792
|
overflow: "hidden",
|
|
762
793
|
display: "flex",
|
|
763
|
-
paddingRight: `${
|
|
764
|
-
userSelect:
|
|
794
|
+
paddingRight: `${u.bodyScrollBarWidth}px`,
|
|
795
|
+
userSelect: u.dragged.isDragging ? "none" : "auto",
|
|
765
796
|
...t
|
|
766
797
|
}), [
|
|
767
|
-
|
|
768
|
-
|
|
798
|
+
u.bodyScrollBarWidth,
|
|
799
|
+
u.dragged.isDragging,
|
|
769
800
|
t
|
|
770
801
|
]);
|
|
771
|
-
return
|
|
772
|
-
|
|
802
|
+
return c(() => {
|
|
803
|
+
let e = p(s);
|
|
804
|
+
e && f({
|
|
773
805
|
type: "setWidths",
|
|
774
|
-
value: Array.from(
|
|
806
|
+
value: Array.from(e.querySelectorAll(".th")).map((e) => {
|
|
775
807
|
let t = e.getAttribute("data-width");
|
|
776
|
-
return t ? parseInt(t, 10) :
|
|
808
|
+
return t ? parseInt(t, 10) : 0;
|
|
777
809
|
})
|
|
778
810
|
});
|
|
779
811
|
}, [
|
|
780
812
|
e,
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
813
|
+
f,
|
|
814
|
+
p,
|
|
815
|
+
s
|
|
816
|
+
]), c(() => {
|
|
817
|
+
let e = p(s);
|
|
818
|
+
e && f({
|
|
785
819
|
type: "setColumnIds",
|
|
786
|
-
value: Array.from(
|
|
820
|
+
value: Array.from(e.querySelectorAll(".draggable")).map((e) => e.getAttribute("data-id") || "")
|
|
787
821
|
});
|
|
788
822
|
}, [
|
|
789
823
|
e,
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
824
|
+
f,
|
|
825
|
+
p,
|
|
826
|
+
s
|
|
827
|
+
]), /* @__PURE__ */ g("div", {
|
|
793
828
|
className: `header ${n ?? ""}`,
|
|
794
|
-
children: /* @__PURE__ */
|
|
829
|
+
children: /* @__PURE__ */ g("div", {
|
|
795
830
|
className: "thead",
|
|
796
|
-
style:
|
|
831
|
+
style: _,
|
|
797
832
|
"data-droppableid": "header",
|
|
798
|
-
onScroll:
|
|
799
|
-
ref:
|
|
800
|
-
children: /* @__PURE__ */
|
|
801
|
-
style:
|
|
833
|
+
onScroll: m,
|
|
834
|
+
ref: s,
|
|
835
|
+
children: /* @__PURE__ */ g("div", {
|
|
836
|
+
style: h,
|
|
802
837
|
className: "tr",
|
|
803
838
|
children: e
|
|
804
839
|
})
|
|
805
840
|
})
|
|
806
841
|
});
|
|
807
842
|
});
|
|
808
|
-
|
|
843
|
+
z.displayName = "TableHeader";
|
|
809
844
|
//#endregion
|
|
810
845
|
//#region src/Components/Draggable.tsx
|
|
811
|
-
var
|
|
812
|
-
let { state: s, dispatch:
|
|
846
|
+
var B = r(({ children: t, id: n, index: r, type: i, styles: a = {} }) => {
|
|
847
|
+
let { state: s, dispatch: c } = x(), u = l(() => String(n) === String(s.dragged.draggedID) && s.dragged.isDragging, [
|
|
813
848
|
n,
|
|
814
849
|
s.dragged.draggedID,
|
|
815
850
|
s.dragged.isDragging
|
|
816
|
-
]),
|
|
851
|
+
]), f = l(() => i === "row" ? k(r, s.options.rowDragRange.start, s.options.rowDragRange.end) : k(r, s.options.columnDragRange.start, s.options.columnDragRange.end), [
|
|
817
852
|
r,
|
|
818
853
|
s.options.columnDragRange.end,
|
|
819
854
|
s.options.columnDragRange.start,
|
|
820
855
|
s.options.rowDragRange.end,
|
|
821
856
|
s.options.rowDragRange.start,
|
|
822
857
|
i
|
|
823
|
-
]),
|
|
858
|
+
]), p = d(null), m = d(!1);
|
|
824
859
|
o(() => {
|
|
825
|
-
m.current
|
|
826
|
-
});
|
|
827
|
-
let
|
|
828
|
-
cursor:
|
|
829
|
-
zIndex:
|
|
830
|
-
opacity:
|
|
831
|
-
pointerEvents:
|
|
860
|
+
m.current = !!p.current?.querySelector("[data-drag-handle]");
|
|
861
|
+
}, [t]);
|
|
862
|
+
let h = l(() => ({
|
|
863
|
+
cursor: u ? "-webkit-grabbing" : f ? "auto" : "-webkit-grab",
|
|
864
|
+
zIndex: u ? 2 : 1,
|
|
865
|
+
opacity: u ? 0 : 1,
|
|
866
|
+
pointerEvents: u ? "none" : "auto",
|
|
832
867
|
display: "flex"
|
|
833
|
-
}), [
|
|
834
|
-
|
|
835
|
-
|
|
868
|
+
}), [f, u]);
|
|
869
|
+
o(() => {
|
|
870
|
+
p.current && p.current.querySelector("[data-drag-handle]") && (p.current.style.cursor = "auto");
|
|
871
|
+
}, [
|
|
872
|
+
t,
|
|
873
|
+
f,
|
|
874
|
+
u
|
|
875
|
+
]);
|
|
876
|
+
let _ = (n) => {
|
|
877
|
+
n.pointerType !== "touch" && (f || m.current && !n.target.closest("[data-drag-handle]") || requestAnimationFrame(() => {
|
|
878
|
+
c({
|
|
836
879
|
type: "setClone",
|
|
837
880
|
value: e.cloneElement(t)
|
|
838
881
|
});
|
|
839
882
|
}));
|
|
840
883
|
};
|
|
841
|
-
return /* @__PURE__ */
|
|
884
|
+
return /* @__PURE__ */ g("div", {
|
|
842
885
|
className: "draggable",
|
|
843
886
|
"data-id": n,
|
|
844
887
|
"data-index": r,
|
|
845
888
|
"data-type": i,
|
|
846
889
|
onPointerDown: _,
|
|
847
|
-
"data-disabled":
|
|
890
|
+
"data-disabled": f ? "true" : "false",
|
|
848
891
|
style: a,
|
|
849
|
-
children: /* @__PURE__ */
|
|
850
|
-
ref:
|
|
851
|
-
style:
|
|
892
|
+
children: /* @__PURE__ */ g("div", {
|
|
893
|
+
ref: p,
|
|
894
|
+
style: h,
|
|
852
895
|
children: t
|
|
853
896
|
})
|
|
854
897
|
});
|
|
855
898
|
});
|
|
856
|
-
|
|
899
|
+
B.displayName = "Draggable";
|
|
857
900
|
//#endregion
|
|
858
901
|
//#region src/Components/ColumnCell.tsx
|
|
859
|
-
var
|
|
860
|
-
let { state: a } =
|
|
902
|
+
var V = r(({ children: e, width: t, style: n, className: r, ...i }) => {
|
|
903
|
+
let { state: a } = x(), o = l(() => t ?? a.options.defaultSizing, [t, a.options.defaultSizing]), s = l(() => ({
|
|
861
904
|
width: `${o}px`,
|
|
862
905
|
flex: `${o} 0 auto`
|
|
863
906
|
}), [o]);
|
|
864
|
-
return /* @__PURE__ */
|
|
907
|
+
return /* @__PURE__ */ g(B, {
|
|
865
908
|
...i,
|
|
866
909
|
styles: s,
|
|
867
910
|
type: "column",
|
|
868
|
-
children: /* @__PURE__ */
|
|
911
|
+
children: /* @__PURE__ */ g("div", {
|
|
869
912
|
className: `th ${r ?? ""}`,
|
|
870
913
|
"data-width": t,
|
|
871
914
|
style: {
|
|
@@ -876,14 +919,18 @@ var L = r(({ children: e, width: t, style: n, className: r, ...i }) => {
|
|
|
876
919
|
})
|
|
877
920
|
});
|
|
878
921
|
});
|
|
879
|
-
|
|
922
|
+
V.displayName = "ColumnCell";
|
|
880
923
|
//#endregion
|
|
881
924
|
//#region src/Components/TableBody.tsx
|
|
882
|
-
var
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
925
|
+
var H = {
|
|
926
|
+
display: "flex",
|
|
927
|
+
overflow: "hidden",
|
|
928
|
+
flex: 1
|
|
929
|
+
}, U = n(({ children: t, style: n, className: r }, i) => {
|
|
930
|
+
let [a, u] = f(0), p = d(null);
|
|
931
|
+
s(i, () => p.current, []);
|
|
932
|
+
let { state: h, dispatch: v } = x(), y = l(() => {
|
|
933
|
+
if (h.dragged.sourceIndex === null) return null;
|
|
887
934
|
let n = (t) => {
|
|
888
935
|
let r = [];
|
|
889
936
|
return e.Children.forEach(t, (t) => {
|
|
@@ -891,124 +938,121 @@ var R = n(({ children: t, style: n, className: r }, i) => {
|
|
|
891
938
|
}), r;
|
|
892
939
|
};
|
|
893
940
|
return n(t).map((t) => {
|
|
894
|
-
let n = e.Children.toArray(t.props.children).filter((t) => e.isValidElement(t) && String(t.props.index) === String(
|
|
941
|
+
let n = e.Children.toArray(t.props.children).filter((t) => e.isValidElement(t) && String(t.props.index) === String(h.dragged.sourceIndex)).map((t) => e.cloneElement(t, {
|
|
942
|
+
key: t.props.index,
|
|
943
|
+
isClone: !0
|
|
944
|
+
}));
|
|
895
945
|
return e.cloneElement(t, {
|
|
946
|
+
key: t.props.id,
|
|
896
947
|
...t.props,
|
|
897
948
|
children: n
|
|
898
949
|
});
|
|
899
950
|
});
|
|
900
|
-
}, [t,
|
|
951
|
+
}, [t, h.dragged.sourceIndex]);
|
|
901
952
|
o(() => {
|
|
902
|
-
|
|
903
|
-
type: "
|
|
904
|
-
|
|
953
|
+
v({
|
|
954
|
+
type: "setRef",
|
|
955
|
+
refName: "bodyRef",
|
|
956
|
+
value: p
|
|
905
957
|
});
|
|
906
|
-
}, [
|
|
907
|
-
let { BodyScrollHandle:
|
|
958
|
+
}, [v, p]);
|
|
959
|
+
let { BodyScrollHandle: b } = C(h.refs), S = l(() => ({
|
|
908
960
|
overflowX: "auto",
|
|
909
961
|
overflowY: "auto",
|
|
910
962
|
flex: 1,
|
|
911
|
-
userSelect:
|
|
963
|
+
userSelect: h.dragged.isDragging ? "none" : "auto",
|
|
912
964
|
...n
|
|
913
|
-
}), [
|
|
914
|
-
o(() => {
|
|
915
|
-
if (
|
|
916
|
-
let e =
|
|
917
|
-
|
|
965
|
+
}), [h.dragged.isDragging, n]);
|
|
966
|
+
return o(() => {
|
|
967
|
+
if (p.current) {
|
|
968
|
+
let e = p.current.clientWidth;
|
|
969
|
+
v({
|
|
918
970
|
type: "setBodyScrollBarWidth",
|
|
919
|
-
value:
|
|
971
|
+
value: p.current.offsetWidth - e
|
|
920
972
|
});
|
|
921
973
|
}
|
|
922
|
-
}, [
|
|
923
|
-
|
|
924
|
-
|
|
974
|
+
}, [v, p]), c(() => {
|
|
975
|
+
p.current && u(p.current.scrollHeight);
|
|
976
|
+
}, [p, t]), /* @__PURE__ */ _(e.Fragment, { children: [h.dragType === "column" && h.refs.cloneRef?.current && m(/* @__PURE__ */ g("div", {
|
|
925
977
|
className: "body clone-body",
|
|
926
978
|
"data-droppableid": "body",
|
|
927
979
|
style: {
|
|
928
980
|
overflow: "hidden",
|
|
929
981
|
flex: 1
|
|
930
982
|
},
|
|
931
|
-
children: /* @__PURE__ */
|
|
983
|
+
children: /* @__PURE__ */ g("div", {
|
|
932
984
|
className: "rbody",
|
|
933
985
|
style: {
|
|
934
|
-
height:
|
|
986
|
+
height: a,
|
|
935
987
|
position: "relative"
|
|
936
988
|
},
|
|
937
|
-
children:
|
|
989
|
+
children: y && e.Children.toArray(y)
|
|
938
990
|
})
|
|
939
|
-
}),
|
|
991
|
+
}), h.refs.cloneRef.current), /* @__PURE__ */ g("div", {
|
|
940
992
|
className: `body ${r ?? ""}`,
|
|
941
|
-
style:
|
|
942
|
-
children: /* @__PURE__ */
|
|
993
|
+
style: H,
|
|
994
|
+
children: /* @__PURE__ */ g("div", {
|
|
943
995
|
className: "ibody",
|
|
944
|
-
style:
|
|
996
|
+
style: S,
|
|
945
997
|
"data-droppableid": "body",
|
|
946
|
-
onScroll:
|
|
947
|
-
ref:
|
|
998
|
+
onScroll: b,
|
|
999
|
+
ref: p,
|
|
948
1000
|
children: t
|
|
949
1001
|
})
|
|
950
1002
|
})] });
|
|
951
|
-
}),
|
|
952
|
-
display: "flex",
|
|
953
|
-
overflow: "hidden",
|
|
954
|
-
flex: 1
|
|
955
|
-
};
|
|
956
|
-
R.displayName = "TableBody";
|
|
957
|
-
//#endregion
|
|
958
|
-
//#region src/Components/BodyRow.tsx
|
|
959
|
-
var B = {
|
|
1003
|
+
}), W = {
|
|
960
1004
|
display: "flex",
|
|
961
1005
|
flex: "1 0 auto",
|
|
962
1006
|
minHeight: "24px"
|
|
963
|
-
},
|
|
964
|
-
let i =
|
|
965
|
-
...
|
|
1007
|
+
}, G = r(({ children: e, style: t, className: n, ...r }) => {
|
|
1008
|
+
let i = l(() => t ? {
|
|
1009
|
+
...W,
|
|
966
1010
|
...t
|
|
967
|
-
} :
|
|
968
|
-
return /* @__PURE__ */
|
|
1011
|
+
} : W, [t]), a = v("tr", n);
|
|
1012
|
+
return /* @__PURE__ */ g(B, {
|
|
969
1013
|
...r,
|
|
970
1014
|
type: "row",
|
|
971
|
-
children: /* @__PURE__ */
|
|
1015
|
+
children: /* @__PURE__ */ g("div", {
|
|
972
1016
|
className: a,
|
|
973
1017
|
style: i,
|
|
974
1018
|
children: e
|
|
975
1019
|
})
|
|
976
1020
|
});
|
|
977
1021
|
});
|
|
978
|
-
|
|
1022
|
+
G.displayName = "BodyRow";
|
|
979
1023
|
//#endregion
|
|
980
1024
|
//#region src/Components/RowCell.tsx
|
|
981
|
-
var
|
|
982
|
-
let { index: a } = i, { state: o } =
|
|
1025
|
+
var K = r(({ children: e, style: t, className: n, isClone: r, ...i }) => {
|
|
1026
|
+
let { index: a } = i, { state: o } = x(), s = l(() => o.columnIds[a] ?? "", [o.columnIds, a]), c = l(() => o.widths[a] ?? o.options.defaultSizing, [
|
|
983
1027
|
o.widths,
|
|
984
1028
|
a,
|
|
985
1029
|
o.options.defaultSizing
|
|
986
|
-
]), u =
|
|
1030
|
+
]), u = l(() => r ? !1 : s === o.dragged.draggedID, [
|
|
987
1031
|
r,
|
|
988
1032
|
s,
|
|
989
1033
|
o.dragged.draggedID
|
|
990
|
-
]), d =
|
|
1034
|
+
]), d = l(() => ({
|
|
991
1035
|
display: "inline-flex",
|
|
992
1036
|
opacity: u ? 0 : 1,
|
|
993
|
-
width: `${
|
|
994
|
-
flex: `${
|
|
1037
|
+
width: `${c}px`,
|
|
1038
|
+
flex: `${c} 0 auto`,
|
|
995
1039
|
...t
|
|
996
1040
|
}), [
|
|
997
1041
|
u,
|
|
998
|
-
|
|
1042
|
+
c,
|
|
999
1043
|
t
|
|
1000
1044
|
]);
|
|
1001
|
-
return /* @__PURE__ */
|
|
1045
|
+
return /* @__PURE__ */ g("div", {
|
|
1002
1046
|
className: `td ${n ?? ""}`,
|
|
1003
1047
|
style: d,
|
|
1004
1048
|
"data-col-index": a,
|
|
1005
1049
|
children: e
|
|
1006
1050
|
});
|
|
1007
1051
|
});
|
|
1008
|
-
|
|
1052
|
+
K.displayName = "RowCell";
|
|
1009
1053
|
//#endregion
|
|
1010
1054
|
//#region src/Components/DragHandle.tsx
|
|
1011
|
-
var
|
|
1055
|
+
var q = r(({ children: e, className: t, style: n }) => /* @__PURE__ */ g("div", {
|
|
1012
1056
|
"data-drag-handle": "true",
|
|
1013
1057
|
className: t,
|
|
1014
1058
|
style: {
|
|
@@ -1019,6 +1063,6 @@ var U = r(({ children: e, className: t, style: n }) => /* @__PURE__ */ f("div",
|
|
|
1019
1063
|
},
|
|
1020
1064
|
children: e
|
|
1021
1065
|
}));
|
|
1022
|
-
|
|
1066
|
+
q.displayName = "DragHandle";
|
|
1023
1067
|
//#endregion
|
|
1024
|
-
export {
|
|
1068
|
+
export { G as BodyRow, V as ColumnCell, q as DragHandle, K as RowCell, U as TableBody, R as TableContainer, z as TableHeader, x as useTable };
|