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