@reportportal/ui-kit 0.0.1-alpha.148 → 0.0.1-alpha.149
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/dist/common/hooks/useSortable.d.ts +1 -1
- package/dist/common/types/sortableTypes.d.ts +16 -1
- package/dist/common.js +11 -0
- package/dist/components/sortable/helpers.d.ts +7 -0
- package/dist/components/sortable/sortableItem/sortableItem.d.ts +1 -1
- package/dist/components/table/types.d.ts +1 -0
- package/dist/index.js +147 -146
- package/dist/sortable.js +177 -123
- package/dist/style.css +1 -1
- package/dist/{table-f1461100.js → table-82d5455c.js} +96 -94
- package/dist/table.js +2 -1
- package/package.json +4 -3
package/dist/sortable.js
CHANGED
|
@@ -1,160 +1,214 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { useEffect as
|
|
4
|
-
import { useDrag as
|
|
5
|
-
import { getEmptyImage as
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { jsx as R } from "react/jsx-runtime";
|
|
2
|
+
import { c as N } from "./bind-06a7ff84.js";
|
|
3
|
+
import { useRef as w, useState as F, useEffect as k, useCallback as x } from "react";
|
|
4
|
+
import { useDrag as $, useDrop as H, useDragLayer as Y } from "react-dnd";
|
|
5
|
+
import { getEmptyImage as z } from "react-dnd-html5-backend";
|
|
6
|
+
import { DROP_POSITIONS as g, DROP_DETECTION_MODE as E } from "./common.js";
|
|
7
|
+
import { createPortal as V } from "react-dom";
|
|
8
|
+
const I = "SORTABLE_ITEM", X = (e) => {
|
|
9
|
+
if (!e)
|
|
10
|
+
return {
|
|
11
|
+
display: "none"
|
|
12
|
+
};
|
|
13
|
+
const { x: t, y: r } = e, l = `translate(${t}px, ${r}px)`;
|
|
14
|
+
return {
|
|
15
|
+
transform: l,
|
|
16
|
+
WebkitTransform: l
|
|
17
|
+
};
|
|
18
|
+
}, U = ({
|
|
19
|
+
fromIndex: e,
|
|
20
|
+
targetIndex: t,
|
|
21
|
+
isTopZone: r
|
|
22
|
+
}) => r ? e < t ? t - 1 : t : e > t ? t + 1 : t, W = (e, t) => {
|
|
23
|
+
const r = e / t;
|
|
24
|
+
return r < 0.05 || r > 0.95 ? null : r < 0.5 ? g.TOP : g.BOTTOM;
|
|
25
|
+
}, q = ({
|
|
8
26
|
id: e,
|
|
9
|
-
index:
|
|
10
|
-
type:
|
|
11
|
-
isDisabled:
|
|
12
|
-
|
|
13
|
-
|
|
27
|
+
index: t,
|
|
28
|
+
type: r = I,
|
|
29
|
+
isDisabled: l = !1,
|
|
30
|
+
isLast: p = !1,
|
|
31
|
+
onDrop: a,
|
|
32
|
+
hideDefaultPreview: d = !1,
|
|
33
|
+
dropDetectionMode: m = E.INDEX_BASED
|
|
14
34
|
}) => {
|
|
15
|
-
const [{ isDragging:
|
|
35
|
+
const i = m === E.HOVER, c = w(null), n = w(null), [u, o] = F(null), [{ isDragging: O }, P, _] = $(
|
|
16
36
|
() => ({
|
|
17
|
-
type:
|
|
18
|
-
item: { id: e, index:
|
|
19
|
-
collect: (
|
|
20
|
-
isDragging:
|
|
37
|
+
type: r,
|
|
38
|
+
item: { id: e, index: t, type: r },
|
|
39
|
+
collect: (s) => ({
|
|
40
|
+
isDragging: s.isDragging()
|
|
21
41
|
}),
|
|
22
|
-
canDrag: () => !
|
|
42
|
+
canDrag: () => !l
|
|
23
43
|
}),
|
|
24
|
-
[e,
|
|
44
|
+
[e, t, r, l]
|
|
25
45
|
);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, [
|
|
29
|
-
const [{ isOver:
|
|
46
|
+
k(() => {
|
|
47
|
+
d && _(z(), { captureDraggingState: !0 });
|
|
48
|
+
}, [d, _]);
|
|
49
|
+
const [{ isOver: b, draggedItemIndex: T }, B] = H(
|
|
30
50
|
() => ({
|
|
31
|
-
accept:
|
|
32
|
-
collect: (
|
|
33
|
-
const
|
|
51
|
+
accept: r,
|
|
52
|
+
collect: (s) => {
|
|
53
|
+
const f = s.getItem(), D = (f == null ? void 0 : f.id) !== e ? s.isOver() : !1;
|
|
34
54
|
return {
|
|
35
|
-
isOver:
|
|
36
|
-
draggedItemIndex:
|
|
55
|
+
isOver: D,
|
|
56
|
+
draggedItemIndex: D ? (f == null ? void 0 : f.index) ?? null : null
|
|
37
57
|
};
|
|
38
58
|
},
|
|
39
|
-
|
|
40
|
-
|
|
59
|
+
hover: (s, f) => {
|
|
60
|
+
if (!i)
|
|
61
|
+
return;
|
|
62
|
+
if (s.id === e) {
|
|
63
|
+
o(null);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const v = c.current;
|
|
67
|
+
if (!v) {
|
|
68
|
+
o(null);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const D = v.getBoundingClientRect(), A = D.bottom - D.top, h = f.getClientOffset();
|
|
72
|
+
if (!h) {
|
|
73
|
+
o(null);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const Z = h.y - D.top, C = W(Z, A);
|
|
77
|
+
C === null ? (o(null), n.current = null) : C === g.TOP ? (o(g.TOP), n.current = g.TOP) : (o(g.BOTTOM), n.current = g.BOTTOM);
|
|
78
|
+
},
|
|
79
|
+
drop: (s) => {
|
|
80
|
+
if (!(s.id === e || !a))
|
|
81
|
+
if (i) {
|
|
82
|
+
const f = n.current;
|
|
83
|
+
if (!f)
|
|
84
|
+
return;
|
|
85
|
+
const v = f === g.TOP, D = U({
|
|
86
|
+
fromIndex: s.index,
|
|
87
|
+
targetIndex: t,
|
|
88
|
+
isTopZone: v
|
|
89
|
+
});
|
|
90
|
+
a(s.index, D);
|
|
91
|
+
} else
|
|
92
|
+
a(s.index, t);
|
|
41
93
|
}
|
|
42
94
|
}),
|
|
43
|
-
[e, r,
|
|
44
|
-
),
|
|
95
|
+
[e, t, r, a, p, i]
|
|
96
|
+
), S = x(
|
|
97
|
+
(s) => (c.current = s, B(s)),
|
|
98
|
+
[B]
|
|
99
|
+
);
|
|
100
|
+
k(() => {
|
|
101
|
+
b || o(null);
|
|
102
|
+
}, [b]);
|
|
103
|
+
const L = i ? u : (() => T === null ? null : T > t ? g.TOP : g.BOTTOM)();
|
|
45
104
|
return {
|
|
46
|
-
isDragging:
|
|
47
|
-
isOver:
|
|
48
|
-
draggedItemIndex:
|
|
49
|
-
dropPosition:
|
|
50
|
-
dragRef:
|
|
51
|
-
dropRef:
|
|
52
|
-
previewRef:
|
|
105
|
+
isDragging: O,
|
|
106
|
+
isOver: b,
|
|
107
|
+
draggedItemIndex: T,
|
|
108
|
+
dropPosition: L,
|
|
109
|
+
dragRef: P,
|
|
110
|
+
dropRef: S,
|
|
111
|
+
previewRef: _
|
|
53
112
|
};
|
|
54
|
-
},
|
|
55
|
-
"sortable-item": "_sortable-
|
|
56
|
-
"sortable-item--drop-target-top": "_sortable-item--drop-target-
|
|
57
|
-
"sortable-item--drop-target-bottom": "_sortable-item--drop-target-
|
|
58
|
-
"drag-handle": "_drag-
|
|
59
|
-
"drag-handle--disabled": "_drag-handle--
|
|
60
|
-
},
|
|
113
|
+
}, G = {
|
|
114
|
+
"sortable-item": "_sortable-item_l234k_1",
|
|
115
|
+
"sortable-item--drop-target-top": "_sortable-item--drop-target-top_l234k_7",
|
|
116
|
+
"sortable-item--drop-target-bottom": "_sortable-item--drop-target-bottom_l234k_20",
|
|
117
|
+
"drag-handle": "_drag-handle_l234k_34",
|
|
118
|
+
"drag-handle--disabled": "_drag-handle--disabled_l234k_41"
|
|
119
|
+
}, J = N.bind(G), K = ({
|
|
61
120
|
id: e,
|
|
62
|
-
index:
|
|
63
|
-
type:
|
|
64
|
-
isDisabled:
|
|
65
|
-
className:
|
|
66
|
-
draggingClassName:
|
|
121
|
+
index: t,
|
|
122
|
+
type: r = I,
|
|
123
|
+
isDisabled: l = !1,
|
|
124
|
+
className: p,
|
|
125
|
+
draggingClassName: a,
|
|
67
126
|
dropTargetClassName: d,
|
|
68
|
-
onDrop:
|
|
69
|
-
hideDefaultPreview:
|
|
70
|
-
|
|
127
|
+
onDrop: m,
|
|
128
|
+
hideDefaultPreview: i = !1,
|
|
129
|
+
dropDetectionMode: c = E.INDEX_BASED,
|
|
130
|
+
isLast: n = !1,
|
|
131
|
+
children: u
|
|
71
132
|
}) => {
|
|
72
|
-
const { isDragging:
|
|
133
|
+
const { isDragging: o, dropPosition: O, dragRef: P, dropRef: _, previewRef: b } = q({
|
|
73
134
|
id: e,
|
|
74
|
-
index:
|
|
75
|
-
type:
|
|
76
|
-
isDisabled:
|
|
77
|
-
onDrop:
|
|
78
|
-
hideDefaultPreview:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"sortable-item--
|
|
83
|
-
|
|
84
|
-
|
|
135
|
+
index: t,
|
|
136
|
+
type: r,
|
|
137
|
+
isDisabled: l,
|
|
138
|
+
onDrop: m,
|
|
139
|
+
hideDefaultPreview: i,
|
|
140
|
+
dropDetectionMode: c,
|
|
141
|
+
isLast: n
|
|
142
|
+
}), T = typeof u == "function", B = J("sortable-item", p, {
|
|
143
|
+
"sortable-item--dragging": o,
|
|
144
|
+
"sortable-item--drop-target-top": O === g.TOP,
|
|
145
|
+
"sortable-item--drop-target-bottom": O === g.BOTTOM,
|
|
146
|
+
[a || ""]: o && a,
|
|
147
|
+
[d || ""]: O && d
|
|
85
148
|
});
|
|
86
|
-
return /* @__PURE__ */
|
|
87
|
-
_(
|
|
88
|
-
}, className:
|
|
89
|
-
isDragging:
|
|
90
|
-
isOver:
|
|
91
|
-
dragRef:
|
|
92
|
-
}) :
|
|
93
|
-
},
|
|
149
|
+
return /* @__PURE__ */ R("div", { ref: (y) => {
|
|
150
|
+
_(y), i || b(y), T || P(y);
|
|
151
|
+
}, className: B, children: T ? u({
|
|
152
|
+
isDragging: o,
|
|
153
|
+
isOver: O !== null,
|
|
154
|
+
dragRef: P
|
|
155
|
+
}) : u });
|
|
156
|
+
}, ie = ({
|
|
94
157
|
items: e,
|
|
95
|
-
type:
|
|
96
|
-
isDisabled:
|
|
97
|
-
className:
|
|
98
|
-
itemClassName:
|
|
99
|
-
onReorder:
|
|
158
|
+
type: t = I,
|
|
159
|
+
isDisabled: r = !1,
|
|
160
|
+
className: l,
|
|
161
|
+
itemClassName: p,
|
|
162
|
+
onReorder: a,
|
|
100
163
|
renderItem: d,
|
|
101
|
-
keyExtractor:
|
|
164
|
+
keyExtractor: m = (i) => i.id
|
|
102
165
|
}) => {
|
|
103
|
-
const
|
|
104
|
-
(
|
|
105
|
-
const
|
|
106
|
-
|
|
166
|
+
const i = x(
|
|
167
|
+
(c, n) => {
|
|
168
|
+
const u = [...e], [o] = u.splice(c, 1);
|
|
169
|
+
u.splice(n, 0, o), a(u);
|
|
107
170
|
},
|
|
108
|
-
[e,
|
|
171
|
+
[e, a]
|
|
109
172
|
);
|
|
110
|
-
return /* @__PURE__ */
|
|
111
|
-
|
|
173
|
+
return /* @__PURE__ */ R("div", { className: l, children: e.map((c, n) => /* @__PURE__ */ R(
|
|
174
|
+
K,
|
|
112
175
|
{
|
|
113
|
-
id:
|
|
114
|
-
index:
|
|
115
|
-
type:
|
|
116
|
-
isDisabled:
|
|
117
|
-
className:
|
|
118
|
-
onDrop:
|
|
119
|
-
|
|
176
|
+
id: m(c),
|
|
177
|
+
index: n,
|
|
178
|
+
type: t,
|
|
179
|
+
isDisabled: r,
|
|
180
|
+
className: p,
|
|
181
|
+
onDrop: i,
|
|
182
|
+
isLast: n === e.length - 1,
|
|
183
|
+
children: ({ dragRef: u, isDragging: o }) => d(c, n, u, o)
|
|
120
184
|
},
|
|
121
|
-
|
|
185
|
+
m(c)
|
|
122
186
|
)) });
|
|
123
|
-
},
|
|
124
|
-
if (!e)
|
|
125
|
-
return {
|
|
126
|
-
display: "none"
|
|
127
|
-
};
|
|
128
|
-
const { x: r, y: s } = e, i = `translate(${r}px, ${s}px)`;
|
|
129
|
-
return {
|
|
130
|
-
transform: i,
|
|
131
|
-
WebkitTransform: i
|
|
132
|
-
};
|
|
133
|
-
}, A = {
|
|
187
|
+
}, Q = {
|
|
134
188
|
"drag-layer": "_drag-layer_1izcx_1",
|
|
135
189
|
"drag-preview": "_drag-preview_1izcx_11"
|
|
136
|
-
},
|
|
190
|
+
}, M = N.bind(Q), le = ({
|
|
137
191
|
type: e,
|
|
138
|
-
renderPreview:
|
|
139
|
-
className:
|
|
140
|
-
previewClassName:
|
|
141
|
-
portalTarget:
|
|
192
|
+
renderPreview: t,
|
|
193
|
+
className: r,
|
|
194
|
+
previewClassName: l,
|
|
195
|
+
portalTarget: p = document.body
|
|
142
196
|
}) => {
|
|
143
|
-
const { itemType:
|
|
144
|
-
(
|
|
145
|
-
item:
|
|
146
|
-
itemType:
|
|
147
|
-
clientOffset:
|
|
148
|
-
isDragging:
|
|
197
|
+
const { itemType: a, isDragging: d, item: m, clientOffset: i } = Y(
|
|
198
|
+
(n) => ({
|
|
199
|
+
item: n.getItem(),
|
|
200
|
+
itemType: n.getItemType(),
|
|
201
|
+
clientOffset: n.getClientOffset(),
|
|
202
|
+
isDragging: n.isDragging()
|
|
149
203
|
})
|
|
150
204
|
);
|
|
151
|
-
if (!d ||
|
|
205
|
+
if (!d || a !== e || !m || !p)
|
|
152
206
|
return null;
|
|
153
|
-
const
|
|
154
|
-
return
|
|
207
|
+
const c = /* @__PURE__ */ R("div", { className: M("drag-layer", r), children: /* @__PURE__ */ R("div", { className: M("drag-preview", l), style: X(i), children: t(m) }) });
|
|
208
|
+
return V(c, p);
|
|
155
209
|
};
|
|
156
210
|
export {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
211
|
+
le as DragLayer,
|
|
212
|
+
K as SortableItem,
|
|
213
|
+
ie as SortableList
|
|
160
214
|
};
|