@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.
@@ -0,0 +1,298 @@
1
+ import { jsx as P, jsxs as G } from "react/jsx-runtime";
2
+ import { c as k } from "./bind-06a7ff84.js";
3
+ import { isFunction as z } from "es-toolkit";
4
+ import { createContext as ie, useContext as se, useState as Y, useRef as W, useCallback as B } from "react";
5
+ import { u as ae, D as M, g as ne, a as pe } from "./useTreeSortable-bc631689.js";
6
+ import { useDragLayer as le } from "react-dnd";
7
+ import "react-dnd-html5-backend";
8
+ import { DROP_DETECTION_MODE as Z, SORTABLE_ORIENTATION as J, DROP_POSITIONS as w, DROP_ACTIONS as n, TREE_DROP_POSITIONS as b } from "./common.js";
9
+ import { createPortal as ee } from "react-dom";
10
+ import { u as de } from "./useOnClickOutside-8f7d68a1.js";
11
+ const me = {
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
+ }, ce = k.bind(me), Ce = ({
22
+ id: u,
23
+ index: g,
24
+ type: S = M,
25
+ isDisabled: h = !1,
26
+ className: s,
27
+ draggingClassName: m,
28
+ dropTargetClassName: o,
29
+ onDrop: c,
30
+ hideDefaultPreview: _ = !1,
31
+ dropDetectionMode: e = Z.INDEX_BASED,
32
+ orientation: p = J.VERTICAL,
33
+ isLast: A = !1,
34
+ children: O
35
+ }) => {
36
+ const { isDragging: E, dropPosition: a, dragRef: T, dropRef: R, previewRef: I } = ae({
37
+ id: u,
38
+ index: g,
39
+ type: S,
40
+ isDisabled: h,
41
+ onDrop: c,
42
+ hideDefaultPreview: _,
43
+ dropDetectionMode: e,
44
+ orientation: p,
45
+ isLast: A
46
+ }), v = z(O), t = e === Z.HOVER, f = p === J.HORIZONTAL, l = ce("sortable-item", s, {
47
+ "sortable-item--horizontal": f,
48
+ "sortable-item--dragging": E,
49
+ "sortable-item--hover-mode": t,
50
+ "sortable-item--drop-target-top": a === w.TOP,
51
+ "sortable-item--drop-target-bottom": a === w.BOTTOM,
52
+ "sortable-item--drop-target-left": a === w.LEFT,
53
+ "sortable-item--drop-target-right": a === w.RIGHT,
54
+ [m || ""]: E && m,
55
+ [o || ""]: a && o
56
+ });
57
+ return /* @__PURE__ */ P("div", { ref: (r) => {
58
+ R(r), _ || I(r), v || T(r);
59
+ }, className: l, children: v ? O({
60
+ isDragging: E,
61
+ isOver: a !== null,
62
+ dragRef: T
63
+ }) : O });
64
+ }, _e = {
65
+ "drag-layer": "_drag-layer_1izcx_1",
66
+ "drag-preview": "_drag-preview_1izcx_11"
67
+ }, K = k.bind(_e), Ne = ({
68
+ type: u,
69
+ renderPreview: g,
70
+ className: S,
71
+ previewClassName: h,
72
+ portalTarget: s = document.body
73
+ }) => {
74
+ const { itemType: m, isDragging: o, item: c, clientOffset: _ } = le(
75
+ (p) => ({
76
+ item: p.getItem(),
77
+ itemType: p.getItemType(),
78
+ clientOffset: p.getClientOffset(),
79
+ isDragging: p.isDragging()
80
+ })
81
+ );
82
+ if (!o || m !== u || !c || !s)
83
+ return null;
84
+ const e = /* @__PURE__ */ P("div", { className: K("drag-layer", S), children: /* @__PURE__ */ P("div", { className: K("drag-preview", h), style: ne(_), children: g(c) }) });
85
+ return ee(e, s);
86
+ }, te = ie(null), fe = () => se(te), be = {
87
+ "drop-confirmation-popover": "_drop-confirmation-popover_ie1p0_16",
88
+ "drop-confirmation-popover--before": "_drop-confirmation-popover--before_ie1p0_31",
89
+ "drop-confirmation-popover--after": "_drop-confirmation-popover--after_ie1p0_35",
90
+ "drop-confirmation-popover--inside": "_drop-confirmation-popover--inside_ie1p0_40",
91
+ "drop-confirmation-popover__button": "_drop-confirmation-popover__button_ie1p0_68",
92
+ "drop-confirmation-popover__divider": "_drop-confirmation-popover__divider_ie1p0_84"
93
+ }, L = k.bind(be), Q = 2, ge = {
94
+ [n.MOVE]: "Move",
95
+ [n.DUPLICATE]: "Duplicate",
96
+ [n.CANCEL]: "Cancel"
97
+ }, De = ({
98
+ children: u,
99
+ showDropConfirmation: g = !1,
100
+ confirmationLabels: S,
101
+ portalTarget: h,
102
+ onMove: s,
103
+ onDuplicate: m,
104
+ onMoveExternal: o,
105
+ onDuplicateExternal: c,
106
+ onCancel: _
107
+ }) => {
108
+ const [e, p] = Y(null), [A, O] = Y(
109
+ null
110
+ ), E = W(null), a = { ...ge, ...S }, T = B(() => {
111
+ p(null), O(null);
112
+ }, []), R = B(
113
+ (f, l, d, r) => {
114
+ if (!g) {
115
+ const N = f.isExternal ? o : s;
116
+ N == null || N(f, l, d);
117
+ return;
118
+ }
119
+ const i = r.getBoundingClientRect(), F = i.left + i.width / 2;
120
+ let C;
121
+ d === b.BEFORE ? C = i.top + Q : d === b.AFTER ? C = i.top + i.height + Q : C = i.top, O({
122
+ top: C,
123
+ left: F
124
+ }), p({ draggedItem: f, targetId: l, position: d });
125
+ },
126
+ [g, s, o]
127
+ ), I = B(
128
+ (f) => {
129
+ if (!e) {
130
+ T();
131
+ return;
132
+ }
133
+ const { draggedItem: l, targetId: d, position: r } = e, i = l.isExternal === !0;
134
+ switch (f) {
135
+ case n.MOVE:
136
+ i ? o == null || o(l, d, r) : s == null || s(l, d, r);
137
+ break;
138
+ case n.DUPLICATE:
139
+ i ? c == null || c(l, d, r) : m == null || m(l, d, r);
140
+ break;
141
+ case n.CANCEL:
142
+ _ == null || _();
143
+ break;
144
+ }
145
+ T();
146
+ },
147
+ [
148
+ e,
149
+ s,
150
+ m,
151
+ o,
152
+ c,
153
+ _,
154
+ T
155
+ ]
156
+ );
157
+ de(
158
+ E,
159
+ e && g ? () => I(n.CANCEL) : void 0
160
+ );
161
+ const v = {
162
+ showDropConfirmation: g,
163
+ pendingDraggedItemId: (e == null ? void 0 : e.draggedItem.id) ?? null,
164
+ pendingTargetId: (e == null ? void 0 : e.targetId) ?? null,
165
+ pendingDropPosition: (e == null ? void 0 : e.position) ?? null,
166
+ requestDrop: R
167
+ }, t = h ?? (typeof document < "u" ? document.body : null);
168
+ return /* @__PURE__ */ G(te.Provider, { value: v, children: [
169
+ u,
170
+ e && A && t && ee(
171
+ /* @__PURE__ */ G(
172
+ "div",
173
+ {
174
+ ref: E,
175
+ className: L("drop-confirmation-popover", {
176
+ "drop-confirmation-popover--before": e.position === b.BEFORE,
177
+ "drop-confirmation-popover--after": e.position === b.AFTER,
178
+ "drop-confirmation-popover--inside": e.position === b.INSIDE
179
+ }),
180
+ style: {
181
+ top: A.top,
182
+ left: A.left
183
+ },
184
+ children: [
185
+ /* @__PURE__ */ P(
186
+ "button",
187
+ {
188
+ type: "button",
189
+ className: L("drop-confirmation-popover__button"),
190
+ onClick: () => I(n.MOVE),
191
+ children: a[n.MOVE]
192
+ }
193
+ ),
194
+ /* @__PURE__ */ P(
195
+ "button",
196
+ {
197
+ type: "button",
198
+ className: L("drop-confirmation-popover__button"),
199
+ onClick: () => I(n.DUPLICATE),
200
+ children: a[n.DUPLICATE]
201
+ }
202
+ ),
203
+ /* @__PURE__ */ P("div", { className: L("drop-confirmation-popover__divider") }),
204
+ /* @__PURE__ */ P(
205
+ "button",
206
+ {
207
+ type: "button",
208
+ className: L("drop-confirmation-popover__button"),
209
+ onClick: () => I(n.CANCEL),
210
+ children: a[n.CANCEL]
211
+ }
212
+ )
213
+ ]
214
+ }
215
+ ),
216
+ t
217
+ )
218
+ ] });
219
+ }, ue = {
220
+ "tree-sortable-item": "_tree-sortable-item_xdaea_16",
221
+ "tree-sortable-item--dragging": "_tree-sortable-item--dragging_xdaea_20",
222
+ "tree-sortable-item--pending": "_tree-sortable-item--pending_xdaea_23",
223
+ "tree-sortable-item--drop-before": "_tree-sortable-item--drop-before_xdaea_29",
224
+ "tree-sortable-item--drop-after": "_tree-sortable-item--drop-after_xdaea_40",
225
+ "tree-sortable-item--drop-inside": "_tree-sortable-item--drop-inside_xdaea_51"
226
+ }, Oe = k.bind(ue), Le = ({
227
+ id: u,
228
+ index: g,
229
+ parentId: S,
230
+ type: h = M,
231
+ isDisabled: s = !1,
232
+ acceptDrop: m = !0,
233
+ isLast: o = !1,
234
+ canDropOn: c,
235
+ acceptExternalDrop: _ = !1,
236
+ externalDropType: e,
237
+ className: p,
238
+ style: A,
239
+ draggingClassName: O,
240
+ dropBeforeClassName: E,
241
+ dropInsideClassName: a,
242
+ dropAfterClassName: T,
243
+ onDrop: R,
244
+ hideDefaultPreview: I = !1,
245
+ children: v
246
+ }) => {
247
+ const t = fe(), f = W(null), l = B(
248
+ (y, j, q) => {
249
+ t != null && t.showDropConfirmation && f.current ? t.requestDrop(y, j, q, f.current) : R == null || R(y, j, q);
250
+ },
251
+ [t, R]
252
+ ), { isDragging: d, isOver: r, dropPosition: i, dragRef: F, dropRef: C, previewRef: N } = pe({
253
+ id: u,
254
+ index: g,
255
+ parentId: S,
256
+ type: h,
257
+ isDisabled: s,
258
+ acceptDrop: m,
259
+ isLast: o,
260
+ canDropOn: c,
261
+ acceptExternalDrop: _,
262
+ externalDropType: e,
263
+ onDrop: l,
264
+ hideDefaultPreview: I
265
+ }), U = (t == null ? void 0 : t.pendingDraggedItemId) === u, V = d || U, D = (t == null ? void 0 : t.pendingTargetId) === u, x = t == null ? void 0 : t.pendingDropPosition, $ = r && i === b.BEFORE || D && x === b.BEFORE, H = r && i === b.INSIDE || D && x === b.INSIDE, X = o && (r && i === b.AFTER || D && x === b.AFTER), re = z(v) ? v({
266
+ isDragging: V,
267
+ isOver: r || D,
268
+ dropPosition: D ? x ?? null : i,
269
+ dragRef: F
270
+ }) : v, oe = Oe("tree-sortable-item", p, {
271
+ "tree-sortable-item--dragging": V,
272
+ "tree-sortable-item--pending": U,
273
+ "tree-sortable-item--drop-before": $,
274
+ "tree-sortable-item--drop-inside": H,
275
+ "tree-sortable-item--drop-after": X,
276
+ [O || ""]: V && O,
277
+ [E || ""]: $ && E,
278
+ [a || ""]: H && a,
279
+ [T || ""]: X && T
280
+ });
281
+ return /* @__PURE__ */ P(
282
+ "div",
283
+ {
284
+ ref: (y) => {
285
+ f.current = y, C(y), z(v) || (F(y), N(y));
286
+ },
287
+ className: oe,
288
+ style: A,
289
+ children: re
290
+ }
291
+ );
292
+ };
293
+ export {
294
+ Ne as D,
295
+ Ce as S,
296
+ Le as T,
297
+ De as a
298
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/ui-kit",
3
- "version": "0.0.1-alpha.237",
3
+ "version": "0.0.1-alpha.238",
4
4
  "description": "The UI-kit library for ReportPortal Design System.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,5 +0,0 @@
1
- import * as e from "react";
2
- const t = (l) => /* @__PURE__ */ e.createElement("svg", { width: 8, height: 13, viewBox: "0 0 8 13", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...l }, /* @__PURE__ */ e.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M6.54134 12.2173C6.69755 12.3735 6.95081 12.3735 7.10702 12.2173L7.24844 12.0759C7.40465 11.9197 7.40465 11.6664 7.24844 11.5102L1.90539 6.16715L7.24844 0.824097C7.40465 0.667887 7.40465 0.41462 7.24844 0.258411L7.10702 0.116989C6.95081 -0.0392199 6.69755 -0.0392199 6.54134 0.116989L0.998591 5.65973L0.999562 5.6607L0.767094 5.89317C0.610884 6.04938 0.610884 6.30265 0.767093 6.45886L1.48425 7.17602L1.49215 7.16813L6.54134 12.2173Z", fill: "#C1C7D0" }));
3
- export {
4
- t as S
5
- };
@@ -1,6 +0,0 @@
1
- const E = "Enter", t = "Tab", T = "data-autocomplete-portal-menu";
2
- export {
3
- T as A,
4
- E,
5
- t as T
6
- };
@@ -1,229 +0,0 @@
1
- import { jsxs as x, Fragment as z, jsx as a } from "react/jsx-runtime";
2
- import { useMemo as v, forwardRef as J, useRef as K } from "react";
3
- import I from "react-datepicker/dist/es/index.js";
4
- import { c as Y } from "./bind-06a7ff84.js";
5
- import { F as Q } from "./fieldText-1749da7a.js";
6
- import { D as L } from "./dropdown-d2a05471.js";
7
- import { S as B } from "./calendarArrow-44c7e60e.js";
8
- import { registerLocale as X } from "react-datepicker";
9
- function Z(e) {
10
- return e == null;
11
- }
12
- const Ae = (e, t) => {
13
- X(e, t);
14
- }, ee = (e, t, r = 20) => {
15
- const d = new Array(r).fill(void 0).map((f, u) => e - u), D = e - r + 1;
16
- return t > e ? [t, ...d] : t < D ? [...d, t] : d;
17
- }, te = "_header_1s3dn_1", ne = "_disabled_1s3dn_25", oe = "_dropdown_1s3dn_8", ae = {
18
- header: te,
19
- "dropdowns-wrapper": "_dropdowns-wrapper_1s3dn_8",
20
- "button-prev": "_button-prev_1s3dn_13",
21
- "button-next": "_button-next_1s3dn_14",
22
- disabled: ne,
23
- dropdown: oe,
24
- "month-dropdown": "_month-dropdown_1s3dn_44",
25
- "toggle-button": "_toggle-button_1s3dn_47"
26
- }, l = Y.bind(ae), re = ({
27
- date: e = /* @__PURE__ */ new Date(),
28
- changeYear: t = () => {
29
- },
30
- changeMonth: r = () => {
31
- },
32
- decreaseMonth: d = () => {
33
- },
34
- increaseMonth: D = () => {
35
- },
36
- prevMonthButtonDisabled: f = !1,
37
- nextMonthButtonDisabled: u = !1,
38
- headerNodes: w = null,
39
- customClassName: y = "",
40
- yearsOptions: N = [],
41
- locale: k
42
- }) => {
43
- const p = e.getFullYear(), S = e.getMonth(), C = v(() => {
44
- const n = Array(12).keys(), m = new Intl.DateTimeFormat(k, {
45
- month: "long"
46
- }), g = (s) => m.format(new Date(p, s));
47
- return Array.from(n, g).reduce((s, P, c) => s.concat({
48
- value: c,
49
- label: P
50
- }), []);
51
- }, [k, p]), A = v(() => {
52
- const n = (/* @__PURE__ */ new Date()).getFullYear();
53
- return (N.length > 0 ? N : ee(n, p)).reduce(
54
- (g, _) => g.concat({ value: _, label: `${_}` }),
55
- []
56
- );
57
- }, [N, p]), F = (n) => {
58
- r(n);
59
- }, o = (n) => {
60
- t(n);
61
- };
62
- return /* @__PURE__ */ x(z, { children: [
63
- w && /* @__PURE__ */ a("div", { className: l(y), children: w }),
64
- /* @__PURE__ */ x("div", { className: l("header"), children: [
65
- /* @__PURE__ */ a(
66
- "button",
67
- {
68
- type: "button",
69
- "aria-label": "Previous Months",
70
- disabled: f,
71
- onClick: (n) => {
72
- n.stopPropagation(), d();
73
- },
74
- className: l("button-prev", { disabled: f }),
75
- children: /* @__PURE__ */ a(B, {})
76
- }
77
- ),
78
- /* @__PURE__ */ x("div", { className: l("dropdowns-wrapper"), children: [
79
- /* @__PURE__ */ a(
80
- L,
81
- {
82
- options: C,
83
- value: S,
84
- onChange: F,
85
- transparentBackground: !0,
86
- className: l("dropdown", "month-dropdown"),
87
- toggleButtonClassName: l("toggle-button")
88
- }
89
- ),
90
- /* @__PURE__ */ a(
91
- L,
92
- {
93
- options: A,
94
- value: p,
95
- onChange: o,
96
- transparentBackground: !0,
97
- className: l("dropdown"),
98
- toggleButtonClassName: l("toggle-button")
99
- }
100
- )
101
- ] }),
102
- /* @__PURE__ */ a(
103
- "button",
104
- {
105
- type: "button",
106
- "aria-label": "Next Months",
107
- disabled: u,
108
- onClick: (n) => {
109
- n.stopPropagation(), D();
110
- },
111
- className: l("button-next", { disabled: u }),
112
- children: /* @__PURE__ */ a(B, {})
113
- }
114
- )
115
- ] })
116
- ] });
117
- }, se = "_calendar_1511k_5", ce = "_date_1511k_104", de = "_disabled_1511k_150", le = "_popper_1511k_159", ie = "_input_1511k_163", pe = {
118
- calendar: se,
119
- "current-date": "_current-date_1511k_103",
120
- date: ce,
121
- "end-date": "_end-date_1511k_121",
122
- "selected-range": "_selected-range_1511k_131",
123
- disabled: de,
124
- popper: le,
125
- input: ie,
126
- "input-range": "_input-range_1511k_174"
127
- }, b = Y.bind(pe), ue = "en", me = "MM-dd-yyyy", ge = " to ", O = (e) => Z(e) ? void 0 : e, _e = J(
128
- ({ selectsRange: e, value: t, ...r }, d) => /* @__PURE__ */ a(
129
- Q,
130
- {
131
- ...r,
132
- className: b("input", e ? "input-range" : ""),
133
- defaultWidth: !1,
134
- value: e ? (t == null ? void 0 : t.replace(" - ", ge)) ?? "" : t,
135
- ref: d,
136
- readOnly: !0
137
- }
138
- )
139
- ), Fe = (e) => {
140
- const {
141
- onChange: t = () => {
142
- },
143
- disabled: r = !1,
144
- onBlur: d = () => {
145
- },
146
- onFocus: D = () => {
147
- },
148
- headerNodes: f = null,
149
- customClassName: u = "",
150
- customTimeInput: w = void 0,
151
- shouldCloseOnSelect: y = !0,
152
- popperClassName: N = "",
153
- calendarClassName: k = "",
154
- popperPlacement: p = "bottom-start",
155
- fixedHeight: S = !0,
156
- language: C = ue,
157
- yearsOptions: A = [],
158
- dateFormat: F = me,
159
- value: o = null
160
- } = e, { minDate: n, maxDate: m } = e, g = O(n), _ = O(m), s = "selectsRange" in e && e.selectsRange === !0, P = K(null), c = s ? (o == null ? void 0 : o[0]) ?? void 0 : void 0, i = s ? (o == null ? void 0 : o[1]) ?? void 0 : void 0, $ = c == null ? void 0 : c.toDateString(), H = i == null ? void 0 : i.toDateString(), M = i && c && i > c, U = s ? "Select date range" : "Select date", j = e.placeholder ?? U, R = {
161
- customInput: /* @__PURE__ */ a(_e, { ref: P, selectsRange: s }),
162
- placeholderText: j,
163
- disabled: r,
164
- shouldCloseOnSelect: y,
165
- fixedHeight: S,
166
- locale: C,
167
- showPopperArrow: !1,
168
- dayClassName: (h) => {
169
- if (!s) {
170
- const W = o == null ? void 0 : o.toDateString(), q = h.toDateString();
171
- return b("date", {
172
- "current-date": q === W,
173
- disabled: r
174
- });
175
- }
176
- const T = h.toDateString(), G = T === $, E = M && T === H, V = c && i && h > c && h < i;
177
- return b("date", {
178
- "current-date": G,
179
- "selected-range": V && !E,
180
- "end-date": E && M,
181
- disabled: r
182
- });
183
- },
184
- calendarClassName: b(k, "calendar"),
185
- renderCustomHeader: (h) => /* @__PURE__ */ a(
186
- re,
187
- {
188
- ...h,
189
- headerNodes: f,
190
- customClassName: u,
191
- yearsOptions: A,
192
- locale: C
193
- }
194
- ),
195
- onBlur: d,
196
- onFocus: D,
197
- customTimeInput: w,
198
- showTimeInput: !!w,
199
- popperClassName: b(N, "popper"),
200
- dateFormat: F,
201
- className: b("datepicker"),
202
- popperPlacement: p
203
- };
204
- return s ? /* @__PURE__ */ a(
205
- I,
206
- {
207
- ...R,
208
- selectsRange: !0,
209
- startDate: c,
210
- endDate: i,
211
- onChange: t,
212
- minDate: g,
213
- maxDate: _
214
- }
215
- ) : /* @__PURE__ */ a(
216
- I,
217
- {
218
- ...R,
219
- selected: o,
220
- onChange: t,
221
- minDate: g,
222
- maxDate: _
223
- }
224
- );
225
- };
226
- export {
227
- Fe as D,
228
- Ae as r
229
- };