@reportportal/ui-kit 0.0.1-alpha.237 → 0.0.1-alpha.238

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/sortable.js CHANGED
@@ -1,330 +1,51 @@
1
- import { jsx as T, jsxs as Y } from "react/jsx-runtime";
2
- import { c as V } from "./bind-06a7ff84.js";
3
- import { isFunction as z } from "es-toolkit";
4
- import { useCallback as F, createContext as ie, useContext as se, useState as Z, useRef as M } from "react";
5
- import { u as ae, D as U, g as ne, a as pe } from "./useTreeSortable-bc631689.js";
6
- import { useDragLayer as le } from "react-dnd";
1
+ import { S as D } from "./treeSortableItem-301dbd92.js";
2
+ import { D as N, a as O, T as P } from "./treeSortableItem-301dbd92.js";
3
+ import { jsx as i } from "react/jsx-runtime";
4
+ import { useCallback as S } from "react";
5
+ import { D as T } from "./useTreeSortable-bc631689.js";
6
+ import "./bind-06a7ff84.js";
7
+ import "es-toolkit";
8
+ import "react-dnd";
7
9
  import "react-dnd-html5-backend";
8
- import { DROP_DETECTION_MODE as J, SORTABLE_ORIENTATION as K, DROP_POSITIONS as B, DROP_ACTIONS as f, TREE_DROP_POSITIONS as E } from "./common.js";
9
- import { createPortal as ee } from "react-dom";
10
- import { u as de } from "./useOnClickOutside-8f7d68a1.js";
11
- const ce = {
12
- "sortable-item": "_sortable-item_1l4xp_16",
13
- "sortable-item--horizontal": "_sortable-item--horizontal_1l4xp_22",
14
- "sortable-item--drop-target-top": "_sortable-item--drop-target-top_1l4xp_25",
15
- "sortable-item--drop-target-bottom": "_sortable-item--drop-target-bottom_1l4xp_38",
16
- "sortable-item--hover-mode": "_sortable-item--hover-mode_1l4xp_51",
17
- "sortable-item--drop-target-left": "_sortable-item--drop-target-left_1l4xp_67",
18
- "sortable-item--drop-target-right": "_sortable-item--drop-target-right_1l4xp_77",
19
- "drag-handle": "_drag-handle_1l4xp_88",
20
- "drag-handle--disabled": "_drag-handle--disabled_1l4xp_95"
21
- }, me = V.bind(ce), _e = ({
22
- id: n,
23
- index: b,
24
- type: v = U,
25
- isDisabled: I = !1,
26
- className: i,
27
- draggingClassName: p,
28
- dropTargetClassName: o,
29
- onDrop: l,
30
- hideDefaultPreview: s = !1,
31
- dropDetectionMode: e = J.INDEX_BASED,
32
- orientation: r = K.VERTICAL,
33
- isLast: c = !1,
34
- children: m
35
- }) => {
36
- const { isDragging: R, dropPosition: _, dragRef: P, dropRef: S, previewRef: A } = ae({
37
- id: n,
38
- index: b,
39
- type: v,
40
- isDisabled: I,
41
- onDrop: l,
42
- hideDefaultPreview: s,
43
- dropDetectionMode: e,
44
- orientation: r,
45
- isLast: c
46
- }), h = z(m), t = e === J.HOVER, O = r === K.HORIZONTAL, g = me("sortable-item", i, {
47
- "sortable-item--horizontal": O,
48
- "sortable-item--dragging": R,
49
- "sortable-item--hover-mode": t,
50
- "sortable-item--drop-target-top": _ === B.TOP,
51
- "sortable-item--drop-target-bottom": _ === B.BOTTOM,
52
- "sortable-item--drop-target-left": _ === B.LEFT,
53
- "sortable-item--drop-target-right": _ === B.RIGHT,
54
- [p || ""]: R && p,
55
- [o || ""]: _ && o
56
- });
57
- return /* @__PURE__ */ T("div", { ref: (a) => {
58
- S(a), s || A(a), h || P(a);
59
- }, className: g, children: h ? m({
60
- isDragging: R,
61
- isOver: _ !== null,
62
- dragRef: P
63
- }) : m });
64
- }, Le = ({
65
- items: n,
66
- type: b = U,
67
- isDisabled: v = !1,
68
- className: I,
69
- itemClassName: i,
10
+ import "./common.js";
11
+ import "react-dom";
12
+ import "./useOnClickOutside-8f7d68a1.js";
13
+ const j = ({
14
+ items: a,
15
+ type: l = T,
16
+ isDisabled: c = !1,
17
+ className: n,
18
+ itemClassName: d,
70
19
  onReorder: p,
71
- renderItem: o,
72
- keyExtractor: l = (s) => s.id
20
+ renderItem: f,
21
+ keyExtractor: s = (e) => e.id
73
22
  }) => {
74
- const s = F(
75
- (e, r) => {
76
- const c = [...n], [m] = c.splice(e, 1);
77
- c.splice(r, 0, m), p(c);
23
+ const e = S(
24
+ (r, o) => {
25
+ const t = [...a], [m] = t.splice(r, 1);
26
+ t.splice(o, 0, m), p(t);
78
27
  },
79
- [n, p]
28
+ [a, p]
80
29
  );
81
- return /* @__PURE__ */ T("div", { className: I, children: n.map((e, r) => /* @__PURE__ */ T(
82
- _e,
30
+ return /* @__PURE__ */ i("div", { className: n, children: a.map((r, o) => /* @__PURE__ */ i(
31
+ D,
83
32
  {
84
- id: l(e),
85
- index: r,
86
- type: b,
87
- isDisabled: v,
88
- className: i,
89
- onDrop: s,
90
- isLast: r === n.length - 1,
91
- children: ({ dragRef: c, isDragging: m }) => o(e, r, c, m)
33
+ id: s(r),
34
+ index: o,
35
+ type: l,
36
+ isDisabled: c,
37
+ className: d,
38
+ onDrop: e,
39
+ isLast: o === a.length - 1,
40
+ children: ({ dragRef: t, isDragging: m }) => f(r, o, t, m)
92
41
  },
93
- l(e)
42
+ s(r)
94
43
  )) });
95
- }, fe = {
96
- "drag-layer": "_drag-layer_1izcx_1",
97
- "drag-preview": "_drag-preview_1izcx_11"
98
- }, Q = V.bind(fe), ye = ({
99
- type: n,
100
- renderPreview: b,
101
- className: v,
102
- previewClassName: I,
103
- portalTarget: i = document.body
104
- }) => {
105
- const { itemType: p, isDragging: o, item: l, clientOffset: s } = le(
106
- (r) => ({
107
- item: r.getItem(),
108
- itemType: r.getItemType(),
109
- clientOffset: r.getClientOffset(),
110
- isDragging: r.isDragging()
111
- })
112
- );
113
- if (!o || p !== n || !l || !i)
114
- return null;
115
- const e = /* @__PURE__ */ T("div", { className: Q("drag-layer", v), children: /* @__PURE__ */ T("div", { className: Q("drag-preview", I), style: ne(s), children: b(l) }) });
116
- return ee(e, i);
117
- }, te = ie(null), be = () => se(te), ge = {
118
- "drop-confirmation-popover": "_drop-confirmation-popover_ie1p0_16",
119
- "drop-confirmation-popover--before": "_drop-confirmation-popover--before_ie1p0_31",
120
- "drop-confirmation-popover--after": "_drop-confirmation-popover--after_ie1p0_35",
121
- "drop-confirmation-popover--inside": "_drop-confirmation-popover--inside_ie1p0_40",
122
- "drop-confirmation-popover__button": "_drop-confirmation-popover__button_ie1p0_68",
123
- "drop-confirmation-popover__divider": "_drop-confirmation-popover__divider_ie1p0_84"
124
- }, D = V.bind(ge), W = 2, ue = {
125
- [f.MOVE]: "Move",
126
- [f.DUPLICATE]: "Duplicate",
127
- [f.CANCEL]: "Cancel"
128
- }, De = ({
129
- children: n,
130
- showDropConfirmation: b = !1,
131
- confirmationLabels: v,
132
- portalTarget: I,
133
- onMove: i,
134
- onDuplicate: p,
135
- onMoveExternal: o,
136
- onDuplicateExternal: l,
137
- onCancel: s
138
- }) => {
139
- const [e, r] = Z(null), [c, m] = Z(
140
- null
141
- ), R = M(null), _ = { ...ue, ...v }, P = F(() => {
142
- r(null), m(null);
143
- }, []), S = F(
144
- (O, g, u, a) => {
145
- if (!b) {
146
- const L = O.isExternal ? o : i;
147
- L == null || L(O, g, u);
148
- return;
149
- }
150
- const d = a.getBoundingClientRect(), w = d.left + d.width / 2;
151
- let C;
152
- u === E.BEFORE ? C = d.top + W : u === E.AFTER ? C = d.top + d.height + W : C = d.top, m({
153
- top: C,
154
- left: w
155
- }), r({ draggedItem: O, targetId: g, position: u });
156
- },
157
- [b, i, o]
158
- ), A = F(
159
- (O) => {
160
- if (!e) {
161
- P();
162
- return;
163
- }
164
- const { draggedItem: g, targetId: u, position: a } = e, d = g.isExternal === !0;
165
- switch (O) {
166
- case f.MOVE:
167
- d ? o == null || o(g, u, a) : i == null || i(g, u, a);
168
- break;
169
- case f.DUPLICATE:
170
- d ? l == null || l(g, u, a) : p == null || p(g, u, a);
171
- break;
172
- case f.CANCEL:
173
- s == null || s();
174
- break;
175
- }
176
- P();
177
- },
178
- [
179
- e,
180
- i,
181
- p,
182
- o,
183
- l,
184
- s,
185
- P
186
- ]
187
- );
188
- de(
189
- R,
190
- e && b ? () => A(f.CANCEL) : void 0
191
- );
192
- const h = {
193
- showDropConfirmation: b,
194
- pendingDraggedItemId: (e == null ? void 0 : e.draggedItem.id) ?? null,
195
- pendingTargetId: (e == null ? void 0 : e.targetId) ?? null,
196
- pendingDropPosition: (e == null ? void 0 : e.position) ?? null,
197
- requestDrop: S
198
- }, t = I ?? (typeof document < "u" ? document.body : null);
199
- return /* @__PURE__ */ Y(te.Provider, { value: h, children: [
200
- n,
201
- e && c && t && ee(
202
- /* @__PURE__ */ Y(
203
- "div",
204
- {
205
- ref: R,
206
- className: D("drop-confirmation-popover", {
207
- "drop-confirmation-popover--before": e.position === E.BEFORE,
208
- "drop-confirmation-popover--after": e.position === E.AFTER,
209
- "drop-confirmation-popover--inside": e.position === E.INSIDE
210
- }),
211
- style: {
212
- top: c.top,
213
- left: c.left
214
- },
215
- children: [
216
- /* @__PURE__ */ T(
217
- "button",
218
- {
219
- type: "button",
220
- className: D("drop-confirmation-popover__button"),
221
- onClick: () => A(f.MOVE),
222
- children: _[f.MOVE]
223
- }
224
- ),
225
- /* @__PURE__ */ T(
226
- "button",
227
- {
228
- type: "button",
229
- className: D("drop-confirmation-popover__button"),
230
- onClick: () => A(f.DUPLICATE),
231
- children: _[f.DUPLICATE]
232
- }
233
- ),
234
- /* @__PURE__ */ T("div", { className: D("drop-confirmation-popover__divider") }),
235
- /* @__PURE__ */ T(
236
- "button",
237
- {
238
- type: "button",
239
- className: D("drop-confirmation-popover__button"),
240
- onClick: () => A(f.CANCEL),
241
- children: _[f.CANCEL]
242
- }
243
- )
244
- ]
245
- }
246
- ),
247
- t
248
- )
249
- ] });
250
- }, Oe = {
251
- "tree-sortable-item": "_tree-sortable-item_xdaea_16",
252
- "tree-sortable-item--dragging": "_tree-sortable-item--dragging_xdaea_20",
253
- "tree-sortable-item--pending": "_tree-sortable-item--pending_xdaea_23",
254
- "tree-sortable-item--drop-before": "_tree-sortable-item--drop-before_xdaea_29",
255
- "tree-sortable-item--drop-after": "_tree-sortable-item--drop-after_xdaea_40",
256
- "tree-sortable-item--drop-inside": "_tree-sortable-item--drop-inside_xdaea_51"
257
- }, Ee = V.bind(Oe), Fe = ({
258
- id: n,
259
- index: b,
260
- parentId: v,
261
- type: I = U,
262
- isDisabled: i = !1,
263
- acceptDrop: p = !0,
264
- isLast: o = !1,
265
- canDropOn: l,
266
- acceptExternalDrop: s = !1,
267
- externalDropType: e,
268
- className: r,
269
- style: c,
270
- draggingClassName: m,
271
- dropBeforeClassName: R,
272
- dropInsideClassName: _,
273
- dropAfterClassName: P,
274
- onDrop: S,
275
- hideDefaultPreview: A = !1,
276
- children: h
277
- }) => {
278
- const t = be(), O = M(null), g = F(
279
- (N, q, G) => {
280
- t != null && t.showDropConfirmation && O.current ? t.requestDrop(N, q, G, O.current) : S == null || S(N, q, G);
281
- },
282
- [t, S]
283
- ), { isDragging: u, isOver: a, dropPosition: d, dragRef: w, dropRef: C, previewRef: L } = pe({
284
- id: n,
285
- index: b,
286
- parentId: v,
287
- type: I,
288
- isDisabled: i,
289
- acceptDrop: p,
290
- isLast: o,
291
- canDropOn: l,
292
- acceptExternalDrop: s,
293
- externalDropType: e,
294
- onDrop: g,
295
- hideDefaultPreview: A
296
- }), $ = (t == null ? void 0 : t.pendingDraggedItemId) === n, k = u || $, y = (t == null ? void 0 : t.pendingTargetId) === n, x = t == null ? void 0 : t.pendingDropPosition, H = a && d === E.BEFORE || y && x === E.BEFORE, X = a && d === E.INSIDE || y && x === E.INSIDE, j = o && (a && d === E.AFTER || y && x === E.AFTER), re = z(h) ? h({
297
- isDragging: k,
298
- isOver: a || y,
299
- dropPosition: y ? x ?? null : d,
300
- dragRef: w
301
- }) : h, oe = Ee("tree-sortable-item", r, {
302
- "tree-sortable-item--dragging": k,
303
- "tree-sortable-item--pending": $,
304
- "tree-sortable-item--drop-before": H,
305
- "tree-sortable-item--drop-inside": X,
306
- "tree-sortable-item--drop-after": j,
307
- [m || ""]: k && m,
308
- [R || ""]: H && R,
309
- [_ || ""]: X && _,
310
- [P || ""]: j && P
311
- });
312
- return /* @__PURE__ */ T(
313
- "div",
314
- {
315
- ref: (N) => {
316
- O.current = N, C(N), z(h) || (w(N), L(N));
317
- },
318
- className: oe,
319
- style: c,
320
- children: re
321
- }
322
- );
323
44
  };
324
45
  export {
325
- ye as DragLayer,
326
- _e as SortableItem,
327
- Le as SortableList,
328
- De as TreeSortableContainer,
329
- Fe as TreeSortableItem
46
+ N as DragLayer,
47
+ D as SortableItem,
48
+ j as SortableList,
49
+ O as TreeSortableContainer,
50
+ P as TreeSortableItem
330
51
  };