@reportportal/ui-kit 0.0.1-alpha.126 → 0.0.1-alpha.128

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/ui-kit",
3
- "version": "0.0.1-alpha.126",
3
+ "version": "0.0.1-alpha.128",
4
4
  "description": "The UI-kit library for ReportPortal Design System.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,448 +0,0 @@
1
- import { jsxs as D, jsx as l, Fragment as Ee } from "react/jsx-runtime";
2
- import { forwardRef as Ze, useState as oe, useRef as P, useMemo as y, useCallback as x, useLayoutEffect as er, useEffect as Oe } from "react";
3
- import { c as be } from "./bind-06a7ff84.js";
4
- import { useFloating as rr, offset as tr, flip as nr } from "@floating-ui/react-dom";
5
- import { useSelect as le } from "downshift";
6
- import { Scrollbars as sr } from "rc-scrollbars";
7
- import { u as ar } from "./useOnClickOutside-c332f7d3.js";
8
- import { K as w } from "./keyCodes-f63c0e11.js";
9
- import { B as or } from "./baseIconButton-251479f7.js";
10
- import { S as lr } from "./clear-53660571.js";
11
- import { S as cr } from "./dropdown-0260bb66.js";
12
- import { Tooltip as dr } from "./tooltip.js";
13
- import { FieldLabel as ir } from "./fieldLabel.js";
14
- import { C as ur } from "./checkbox-ed6cc375.js";
15
- const hr = "_disabled_14s7v_12", fr = "_hidden_14s7v_16", _r = "_hover_14s7v_22", pr = "_selected_14s7v_38", gr = {
16
- "dropdown-option": "_dropdown-option_14s7v_1",
17
- disabled: hr,
18
- hidden: fr,
19
- hover: _r,
20
- "depth-1": "_depth-1_14s7v_32",
21
- selected: pr,
22
- "multi-select": "_multi-select_14s7v_38",
23
- "single-option": "_single-option_14s7v_43",
24
- "sub-option": "_sub-option_14s7v_50"
25
- }, ve = be.bind(gr), Ne = Ze(
26
- (t, r) => {
27
- const {
28
- option: { value: a, disabled: s, hidden: d, label: f, title: m, groupRef: p },
29
- selected: R,
30
- onChange: K,
31
- render: V,
32
- highlightHovered: L,
33
- onMouseEnter: J,
34
- multiSelect: C,
35
- isPartiallyChecked: H = !1,
36
- depth: Y = 0,
37
- hasChildren: Q = !1
38
- } = t, Z = (M) => {
39
- (M.target instanceof HTMLDivElement || M.target instanceof HTMLInputElement) && (K == null || K(a));
40
- };
41
- return /* @__PURE__ */ D(
42
- "div",
43
- {
44
- className: ve("dropdown-option", {
45
- selected: R,
46
- disabled: s,
47
- hidden: d,
48
- hover: L,
49
- "multi-select": C,
50
- "has-children": Q,
51
- [`depth-${Y}`]: Y > 0
52
- }),
53
- title: m,
54
- onClick: Z,
55
- ref: r,
56
- onMouseEnter: J,
57
- children: [
58
- C && /* @__PURE__ */ l(ur, { value: !!R, partiallyChecked: H }),
59
- /* @__PURE__ */ l(
60
- "div",
61
- {
62
- className: ve("single-option", {
63
- "sub-option": !!p
64
- }),
65
- children: V ? V(t) : f
66
- }
67
- )
68
- ]
69
- }
70
- );
71
- }
72
- ), wr = [
73
- w.ENTER_KEY_CODE,
74
- w.SPACE_KEY_CODE,
75
- w.ARROW_DOWN_KEY_CODE
76
- ], mr = [w.ESCAPE_KEY_CODE, w.TAB_KEY_CODE];
77
- var A = /* @__PURE__ */ ((t) => (t.ON_KEY_DOWN = "onKeyDown", t.ON_CLICK = "onClick", t))(A || {});
78
- const yr = 216, Cr = (t, r) => {
79
- const a = Array.isArray(r) ? r : [r];
80
- return t.findIndex(({ value: s }) => a.includes(s));
81
- }, Er = (t, r) => (t % r + r) % r, ce = (t, r = 0, a = 1) => {
82
- var d;
83
- if (t.length === 0)
84
- return 0;
85
- if (!((d = t[r]) != null && d.disabled))
86
- return r;
87
- const s = t.length;
88
- return ce(
89
- t,
90
- Er(r + a, s),
91
- a
92
- );
93
- }, Or = (t, r) => ce(t, r), vr = (t, r) => ce(t, r, -1), De = (t, r = 0, a) => !t || t.length === 0 ? [] : t.reduce((s, d) => {
94
- var f;
95
- return d && (s.push({ option: d, depth: r, parent: a }), (f = d.children) != null && f.length && s.push(...De(d.children, r + 1, d))), s;
96
- }, []), Ae = (t) => !t || t.length === 0 ? [] : t.reduce((r, a) => {
97
- var s;
98
- return a && ((s = a.children) != null && s.length ? r.push(...Ae(a.children)) : r.push(a)), r;
99
- }, []), Ke = (t) => {
100
- var r;
101
- return t ? (r = t.children) != null && r.length ? t.children.reduce((a, s) => (s && a.push(...Ke(s)), a), []) : [t.value] : [];
102
- }, Nr = "_container_owe49_1", br = "_icon_owe49_7", Dr = "_arrow_owe49_13", Ar = "_dropdown_owe49_27", Kr = "_disabled_owe49_44", Ir = "_value_owe49_51", Tr = "_error_owe49_54", kr = "_touched_owe49_54", Pr = "_opened_owe49_58", xr = "_placeholder_owe49_93", Rr = "_ghost_owe49_139", Vr = "_divider_owe49_160", Lr = {
103
- container: Nr,
104
- icon: br,
105
- arrow: Dr,
106
- "clear-button": "_clear-button_owe49_19",
107
- dropdown: Ar,
108
- "transparent-background": "_transparent-background_owe49_41",
109
- disabled: Kr,
110
- value: Ir,
111
- error: Tr,
112
- touched: kr,
113
- opened: Pr,
114
- placeholder: xr,
115
- "mobile-disabled": "_mobile-disabled_owe49_97",
116
- "value-wrapper": "_value-wrapper_owe49_102",
117
- "value-tooltip": "_value-tooltip_owe49_108",
118
- "select-list": "_select-list_owe49_113",
119
- "limited-width": "_limited-width_owe49_130",
120
- "options-container": "_options-container_owe49_134",
121
- ghost: Rr,
122
- divider: Vr
123
- }, i = be.bind(Lr), Zr = ({
124
- multiSelect: t = !1,
125
- value: r = t ? [] : "",
126
- options: a = [],
127
- disabled: s = !1,
128
- error: d,
129
- onChange: f,
130
- onFocus: m,
131
- onBlur: p,
132
- mobileDisabled: R,
133
- title: K,
134
- touched: V = !1,
135
- icon: L,
136
- variant: J,
137
- placeholder: C = "",
138
- label: H = "",
139
- renderOption: Y,
140
- transparentBackground: Q = !1,
141
- className: Z,
142
- toggleButtonClassName: M,
143
- selectListClassName: Ie,
144
- isListWidthLimited: Te = !1,
145
- optionAll: ee = { value: "all", label: "All" },
146
- isOptionAllVisible: de = !1,
147
- onSelectAll: ke = () => {
148
- },
149
- formatDisplayedValue: ie,
150
- notScrollable: I = !1,
151
- footer: W,
152
- includeGroupValue: ue = !1,
153
- clearable: Pe = !1,
154
- onClear: he = () => {
155
- },
156
- clearButtonAriaLabel: xe = "Clear selection",
157
- tooltipPortalRoot: Re,
158
- tooltipZIndex: Ve
159
- }) => {
160
- const [u, S] = oe(!1), fe = P(null), T = P(null), re = P(0), te = P(null), [Le, _e] = oe(!1), [He, z] = oe(null), E = P(null), k = y(() => De(a), [a]), _ = y(
161
- () => k.map(({ option: e }) => e),
162
- [k]
163
- ), $ = y(() => k.filter(({ option: e }) => {
164
- var n;
165
- return (n = e.children) == null ? void 0 : n.length;
166
- }).map(({ option: e }) => e), [k]), pe = y(() => Ae(a), [a]), g = y(
167
- () => pe.map(({ value: e }) => e),
168
- [pe]
169
- ), j = y(() => {
170
- const e = /* @__PURE__ */ new Map();
171
- return $.forEach((n) => {
172
- e.set(n.value, Ke(n));
173
- }), e;
174
- }, [$]), q = x(
175
- (e) => ($.forEach((n) => {
176
- const o = j.get(n.value) ?? [], c = o.length > 0 && o.every((h) => e.has(h));
177
- ue && c ? e.add(n.value) : e.delete(n.value);
178
- }), e),
179
- [$, ue, j]
180
- ), O = y(() => !t || !Array.isArray(r) ? /* @__PURE__ */ new Set() : q(new Set(r)), [t, r, q]), ge = t ? Array.isArray(r) && r.length > 0 : r || r === !1 || r === 0, Ye = Pe && ge && !s, Me = x((e) => {
181
- re.current = e.scrollTop;
182
- }, []);
183
- er(() => {
184
- u && !I && T.current && !(t && E.current !== null) && T.current.scrollTop(re.current);
185
- }, [u, I, r, t]);
186
- const { refs: B, floatingStyles: We } = rr({
187
- placement: "bottom-start",
188
- middleware: [
189
- tr(5),
190
- nr({
191
- fallbackPlacements: ["bottom-start", "top-start", "bottom", "top"]
192
- })
193
- ]
194
- }), Se = () => {
195
- if (!de)
196
- return;
197
- const e = Array.isArray(r) ? r : [], n = new Set(e), o = g.some((h) => !n.has(h));
198
- g.forEach((h) => {
199
- o ? n.add(h) : n.delete(h);
200
- });
201
- const c = q(n);
202
- f(Array.from(c)), ke();
203
- }, N = x(() => {
204
- S(!1), p == null || p();
205
- }, [p]), ne = x(() => {
206
- if (s)
207
- return;
208
- f(t ? [] : ""), he(), N(), requestAnimationFrame(() => {
209
- const n = B.reference.current;
210
- n && n instanceof HTMLElement && n.focus();
211
- });
212
- }, [s, t, f, he, N, B]), ze = x(
213
- (e) => {
214
- e.preventDefault(), e.stopPropagation(), ne();
215
- },
216
- [ne]
217
- );
218
- ar(fe, () => {
219
- u && N();
220
- });
221
- const we = (e) => {
222
- var n;
223
- if (!e.disabled) {
224
- if (t) {
225
- const o = Array.isArray(r) ? r : [], c = new Set(o);
226
- if ((n = e.children) != null && n.length) {
227
- const F = j.get(e.value) ?? [], G = F.some((v) => !c.has(v));
228
- F.forEach((v) => {
229
- G ? c.add(v) : c.delete(v);
230
- });
231
- } else
232
- c.has(e.value) ? c.delete(e.value) : c.add(e.value);
233
- const h = q(c);
234
- f(Array.from(h));
235
- } else
236
- f(e.value);
237
- S((o) => t || !o);
238
- }
239
- }, $e = () => _.find(({ value: e }) => e === r), me = Cr(_, r), {
240
- getToggleButtonProps: je,
241
- getLabelProps: qe,
242
- getMenuProps: Be,
243
- getItemProps: Ue,
244
- setHighlightedIndex: b,
245
- highlightedIndex: se,
246
- selectedItem: U
247
- } = le({
248
- items: _,
249
- itemToString: (e) => (e != null && e.label ? String(e.label) : C) || "",
250
- selectedItem: $e(),
251
- isOpen: u,
252
- circularNavigation: !0,
253
- defaultHighlightedIndex: me,
254
- onHighlightedIndexChange: (e) => {
255
- switch (e.type) {
256
- case le.stateChangeTypes.MenuKeyDownArrowUp:
257
- return z(A.ON_KEY_DOWN), b(vr(_, e.highlightedIndex)), e;
258
- case le.stateChangeTypes.MenuKeyDownArrowDown:
259
- return z(A.ON_KEY_DOWN), b(Or(_, e.highlightedIndex)), e;
260
- default:
261
- return e;
262
- }
263
- }
264
- });
265
- Oe(() => {
266
- t && u && E.current !== null && E.current >= 0 && E.current < _.length && (b(E.current), E.current = null, requestAnimationFrame(() => {
267
- T.current && !I && T.current.scrollTop(re.current);
268
- }));
269
- }, [t, u, r, _.length, b, I]);
270
- const Xe = () => {
271
- s || (S((e) => !e), u ? p == null || p() : m == null || m(), z(A.ON_CLICK));
272
- }, X = y(() => {
273
- if (t && Array.isArray(r) && g.length > 0 && g.every((n) => O.has(n)))
274
- return ee.label;
275
- const e = _.reduce((n, o) => ((Array.isArray(r) && r.includes(o.value) || o.value === r) && n.push(o.label), n), []);
276
- if (e.length > 0)
277
- return e.join(", ");
278
- if (!r && r !== !1 && r !== 0 || Array.isArray(r) && !r.length)
279
- return C;
280
- }, [
281
- t,
282
- r,
283
- g,
284
- O,
285
- ee.label,
286
- _,
287
- C
288
- ]);
289
- Oe(() => {
290
- if (te.current) {
291
- const { offsetWidth: e, scrollWidth: n } = te.current;
292
- _e(n > e);
293
- } else
294
- _e(!1);
295
- }, [X]);
296
- const Fe = (e) => {
297
- const { keyCode: n } = e;
298
- wr.includes(n) && e.target === e.currentTarget && (e.preventDefault(), e.stopPropagation(), !u && (b(me), S(!0), m == null || m(), z(A.ON_KEY_DOWN)));
299
- }, Ge = (e) => {
300
- const { keyCode: n } = e;
301
- if (n === w.ENTER_KEY_CODE || n === w.SPACE_KEY_CODE) {
302
- const o = _[se];
303
- if (!o)
304
- return;
305
- t && (E.current = se), we(o), t || N();
306
- return;
307
- }
308
- mr.includes(n) && (e.stopPropagation(), N());
309
- }, ye = () => /* @__PURE__ */ D("div", { className: i("options-container"), children: [
310
- t && de && /* @__PURE__ */ D(Ee, { children: [
311
- /* @__PURE__ */ l(
312
- Ne,
313
- {
314
- option: ee,
315
- selected: Array.isArray(r) && g.length > 0 && g.every((e) => O.has(e)),
316
- onChange: Se,
317
- multiSelect: t,
318
- isPartiallyChecked: g.some((e) => O.has(e)) && !g.every((e) => O.has(e))
319
- }
320
- ),
321
- /* @__PURE__ */ l("div", { className: i("divider") }),
322
- " "
323
- ] }),
324
- k.map(({ option: e, depth: n }, o) => {
325
- var G, v;
326
- const c = j.get(e.value) ?? [e.value], h = t && c.every((ae) => O.has(ae)), F = t && ((G = e.children) == null ? void 0 : G.length) && c.some((ae) => O.has(ae)) && !h;
327
- return /* @__PURE__ */ l(
328
- Ne,
329
- {
330
- ...Ue({
331
- item: e,
332
- index: o
333
- }),
334
- multiSelect: t,
335
- selected: t ? h : e.value === ((U == null ? void 0 : U.value) ?? U),
336
- option: { title: e.label, ...e },
337
- highlightHovered: se === o && He !== A.ON_CLICK,
338
- render: Y,
339
- onChange: e.disabled ? null : () => we(e),
340
- onMouseEnter: () => b(o),
341
- depth: n,
342
- hasChildren: !!((v = e.children) != null && v.length),
343
- isPartiallyChecked: F
344
- },
345
- e.value
346
- );
347
- }),
348
- W && /* @__PURE__ */ D(Ee, { children: [
349
- /* @__PURE__ */ l("div", { className: i("divider") }),
350
- typeof W == "function" ? W(N) : W
351
- ] })
352
- ] }), Je = () => {
353
- const e = ie ? ie(X) : X, n = /* @__PURE__ */ l(
354
- "span",
355
- {
356
- ref: te,
357
- className: i("value", {
358
- placeholder: X === C
359
- }),
360
- children: e
361
- }
362
- );
363
- return ge && !!e && Le ? /* @__PURE__ */ l(
364
- dr,
365
- {
366
- content: e,
367
- placement: "top",
368
- wrapperClassName: i("value-tooltip"),
369
- portalRoot: Re,
370
- zIndex: Ve,
371
- children: n
372
- }
373
- ) : n;
374
- }, Qe = je({
375
- className: i("dropdown", J, M, {
376
- "transparent-background": Q,
377
- opened: u,
378
- disabled: s,
379
- error: d,
380
- touched: V,
381
- "mobile-disabled": R
382
- }),
383
- onClick: Xe,
384
- onKeyDown: Fe,
385
- ref: B.setReference
386
- }), { type: Yr, ...Ce } = Qe;
387
- return /* @__PURE__ */ D("div", { ref: fe, className: i("container", Z), title: K, children: [
388
- H && /* @__PURE__ */ l(ir, { ...qe(), children: H }),
389
- /* @__PURE__ */ D(
390
- "div",
391
- {
392
- ...Ce,
393
- role: "button",
394
- "aria-disabled": s,
395
- tabIndex: s ? -1 : Ce.tabIndex ?? 0,
396
- children: [
397
- L && /* @__PURE__ */ l("span", { className: i("icon"), children: L }),
398
- /* @__PURE__ */ l("div", { className: i("value-wrapper"), children: Je() }),
399
- Ye && /* @__PURE__ */ l(
400
- or,
401
- {
402
- className: i("clear-button"),
403
- onClick: ze,
404
- onKeyDown: (e) => {
405
- const { keyCode: n } = e;
406
- (n === w.ENTER_KEY_CODE || n === w.SPACE_KEY_CODE) && (e.preventDefault(), e.stopPropagation(), ne());
407
- },
408
- "aria-label": xe,
409
- children: /* @__PURE__ */ l(lr, {})
410
- }
411
- ),
412
- /* @__PURE__ */ l("span", { className: i("arrow"), "aria-hidden": "true", children: /* @__PURE__ */ l(cr, {}) })
413
- ]
414
- }
415
- ),
416
- u && /* @__PURE__ */ l(
417
- "div",
418
- {
419
- style: We,
420
- className: i(
421
- "select-list",
422
- { opened: u, "limited-width": Te },
423
- Ie
424
- ),
425
- ...Be({
426
- onKeyDown: Ge,
427
- ref: B.setFloating
428
- }),
429
- children: I ? ye() : /* @__PURE__ */ l(
430
- sr,
431
- {
432
- autoHeight: !0,
433
- autoHeightMax: yr,
434
- hideTracksWhenNotNeeded: !0,
435
- ref: (e) => {
436
- T.current = e;
437
- },
438
- onScrollFrame: Me,
439
- children: ye()
440
- }
441
- )
442
- }
443
- )
444
- ] });
445
- };
446
- export {
447
- Zr as D
448
- };
@@ -1,16 +0,0 @@
1
- import { useEffect as i } from "react";
2
- function u(t, n) {
3
- i(() => {
4
- if (!n)
5
- return;
6
- const e = (o) => {
7
- t && t.current && !t.current.contains(o.target) && n(o);
8
- };
9
- return document.addEventListener("pointerdown", e), () => {
10
- document.removeEventListener("pointerdown", e);
11
- };
12
- }, [t, n]);
13
- }
14
- export {
15
- u
16
- };