@reportportal/ui-kit 0.0.1-alpha.97 → 0.0.1-alpha.99

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.
@@ -1,63 +1,69 @@
1
- import { jsxs as S, jsx as e } from "react/jsx-runtime";
2
- import { useState as h, useRef as y, useEffect as l } from "react";
3
- import { c as v } from "./bind-06a7ff84.js";
4
- import { S as b } from "./close-4d480ef7.js";
5
- import { S as g, b as w, a as E } from "./success-8fd8bd2c.js";
6
- var a = /* @__PURE__ */ ((s) => (s.INFO = "info", s.SUCCESS = "success", s.ERROR = "error", s))(a || {});
7
- const O = "_error_1py1m_11", I = "_success_1py1m_14", T = "_info_1py1m_17", x = "_title_1py1m_32", D = {
8
- "system-alert": "_system-alert_1py1m_1",
9
- error: O,
10
- success: I,
11
- info: T,
12
- "icon-wrapper": "_icon-wrapper_1py1m_20",
13
- "content-wrapper": "_content-wrapper_1py1m_26",
14
- title: x,
15
- "close-button": "_close-button_1py1m_45"
16
- }, t = v.bind(D), U = 7e3, j = 4e3, L = ({
17
- title: s,
1
+ import { jsxs as g, jsx as e } from "react/jsx-runtime";
2
+ import { useState as h, useRef as v, useEffect as _ } from "react";
3
+ import { c as E } from "./bind-06a7ff84.js";
4
+ import { S as I } from "./close-4d480ef7.js";
5
+ import { S as p, b as S, a as O } from "./success-8fd8bd2c.js";
6
+ var o = /* @__PURE__ */ ((t) => (t.INFO = "info", t.SUCCESS = "success", t.WARNING = "warning", t.ERROR = "error", t))(o || {}), f = /* @__PURE__ */ ((t) => (t.WHITE = "white", t.BLACK = "black", t))(f || {});
7
+ const k = "_error_jbf1d_14", x = "_success_jbf1d_17", D = "_info_jbf1d_20", H = "_warning_jbf1d_23", T = "_title_jbf1d_38", U = {
8
+ "system-alert": "_system-alert_jbf1d_1",
9
+ "system-alert--black": "_system-alert--black_jbf1d_11",
10
+ error: k,
11
+ success: x,
12
+ info: D,
13
+ warning: H,
14
+ "icon-wrapper": "_icon-wrapper_jbf1d_26",
15
+ "content-wrapper": "_content-wrapper_jbf1d_32",
16
+ title: T,
17
+ "title--white": "_title--white_jbf1d_50",
18
+ "title--black": "_title--black_jbf1d_53",
19
+ "close-button": "_close-button_jbf1d_56"
20
+ }, s = E.bind(U), F = 7e3, W = 4e3, G = ({
21
+ title: t,
18
22
  onClose: c,
19
- icon: m = null,
20
- type: o = a.INFO,
21
- duration: u = j,
22
- className: _,
23
- dataAutomationId: p
23
+ icon: u = null,
24
+ type: n = o.INFO,
25
+ typographyColor: i = f.WHITE,
26
+ duration: d = W,
27
+ className: m,
28
+ dataAutomationId: b
24
29
  }) => {
25
- const i = o === a.ERROR ? U : u, [f, d] = h(""), r = y(null);
26
- l(() => {
27
- const { offsetHeight: n, scrollHeight: N } = r == null ? void 0 : r.current;
28
- n < N && d(s);
29
- }, [s]), l(() => {
30
- const n = setTimeout(() => {
30
+ const l = n === o.ERROR ? F : d, [j, w] = h(""), r = v(null);
31
+ _(() => {
32
+ const { offsetHeight: a, scrollHeight: N } = r == null ? void 0 : r.current;
33
+ a < N && w(t);
34
+ }, [t]), _(() => {
35
+ const a = setTimeout(() => {
31
36
  c();
32
- }, i);
33
- return () => clearTimeout(n);
34
- }, [i, c]);
37
+ }, l);
38
+ return () => clearTimeout(a);
39
+ }, [l, c]);
35
40
  const R = () => {
36
- switch (o) {
41
+ switch (n) {
37
42
  case "info":
38
- return /* @__PURE__ */ e(E, {});
43
+ return /* @__PURE__ */ e(O, {});
39
44
  case "success":
40
- return /* @__PURE__ */ e(w, {});
45
+ return /* @__PURE__ */ e(S, {});
46
+ case "warning":
41
47
  case "error":
42
- return /* @__PURE__ */ e(g, {});
48
+ return /* @__PURE__ */ e(p, {});
43
49
  default:
44
- return m;
50
+ return u;
45
51
  }
46
52
  };
47
- return /* @__PURE__ */ S(
53
+ return /* @__PURE__ */ g(
48
54
  "div",
49
55
  {
50
- className: t("system-alert", o, _),
51
- title: f,
52
- "data-automation-id": p,
56
+ className: s("system-alert", n, m, `system-alert--${i}`),
57
+ title: j,
58
+ "data-automation-id": b,
53
59
  children: [
54
- /* @__PURE__ */ e("div", { className: t("icon-wrapper"), children: R() }),
55
- /* @__PURE__ */ e("div", { className: t("content-wrapper"), children: /* @__PURE__ */ e("h2", { ref: r, className: t("title"), children: s }) }),
56
- /* @__PURE__ */ e("button", { className: t("close-button"), onClick: c, "aria-label": "close system alert", children: /* @__PURE__ */ e(b, {}) })
60
+ /* @__PURE__ */ e("div", { className: s("icon-wrapper"), children: R() }),
61
+ /* @__PURE__ */ e("div", { className: s("content-wrapper"), children: /* @__PURE__ */ e("h2", { ref: r, className: s("title", `title--${i}`), children: t }) }),
62
+ /* @__PURE__ */ e("button", { className: s("close-button"), onClick: c, "aria-label": "close system alert", children: /* @__PURE__ */ e(I, {}) })
57
63
  ]
58
64
  }
59
65
  );
60
66
  };
61
67
  export {
62
- L as SystemAlert
68
+ G as SystemAlert
63
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/ui-kit",
3
- "version": "0.0.1-alpha.97",
3
+ "version": "0.0.1-alpha.99",
4
4
  "description": "The UI-kit library for ReportPortal Design System.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,282 +0,0 @@
1
- import { jsxs as u, jsx as d, Fragment as U } from "react/jsx-runtime";
2
- import { forwardRef as _e, useState as q, useRef as he } from "react";
3
- import { c as J } from "./bind-06a7ff84.js";
4
- import { useFloating as fe, offset as ue, flip as ge } from "@floating-ui/react-dom";
5
- import { useSelect as P } from "downshift";
6
- import { Scrollbars as pe } from "rc-scrollbars";
7
- import { u as me } from "./useOnClickOutside-c332f7d3.js";
8
- import { K as p } from "./keyCodes-f63c0e11.js";
9
- import { B as ye } from "./baseIconButton-251479f7.js";
10
- import { S as be } from "./dropdown-0260bb66.js";
11
- import { FieldLabel as Ce } from "./fieldLabel.js";
12
- import { C as Oe } from "./checkbox-ed6cc375.js";
13
- const ke = "_disabled_1etj7_12", Ne = "_hidden_1etj7_16", De = "_hover_1etj7_22", Ee = "_selected_1etj7_34", we = {
14
- "dropdown-option": "_dropdown-option_1etj7_1",
15
- disabled: ke,
16
- hidden: Ne,
17
- hover: De,
18
- selected: Ee,
19
- "multi-select": "_multi-select_1etj7_34",
20
- "single-option": "_single-option_1etj7_39",
21
- "sub-option": "_sub-option_1etj7_46"
22
- }, z = J.bind(we), G = _e(
23
- (n, t) => {
24
- const {
25
- option: { value: r, disabled: i, hidden: v, label: m, title: c, groupRef: a },
26
- selected: b,
27
- onChange: y,
28
- render: C,
29
- highlightHovered: O,
30
- onMouseEnter: K,
31
- multiSelect: h,
32
- isPartiallyChecked: k = !1
33
- } = n, A = (N) => {
34
- (N.target instanceof HTMLDivElement || N.target instanceof HTMLInputElement) && (y == null || y(r));
35
- };
36
- return /* @__PURE__ */ u(
37
- "div",
38
- {
39
- className: z("dropdown-option", {
40
- selected: b,
41
- disabled: i,
42
- hidden: v,
43
- hover: O,
44
- "multi-select": h
45
- }),
46
- title: c,
47
- onClick: A,
48
- ref: t,
49
- onMouseEnter: K,
50
- children: [
51
- h && /* @__PURE__ */ d(Oe, { value: !!b, partiallyChecked: k }),
52
- /* @__PURE__ */ d("div", { className: z("single-option", { "sub-option": !!a }), children: C ? C(n) : m })
53
- ]
54
- }
55
- );
56
- }
57
- ), ve = [
58
- p.ENTER_KEY_CODE,
59
- p.SPACE_KEY_CODE,
60
- p.ARROW_DOWN_KEY_CODE
61
- ], Ke = [p.ESCAPE_KEY_CODE, p.TAB_KEY_CODE];
62
- var g = /* @__PURE__ */ ((n) => (n.ON_KEY_DOWN = "onKeyDown", n.ON_CLICK = "onClick", n))(g || {});
63
- const Ae = (n, t) => {
64
- const r = Array.isArray(t) ? t : [t];
65
- return n.findIndex(({ value: i }) => r.includes(i));
66
- }, xe = (n, t) => (n % t + t) % t, Y = (n, t = 0, r = 1) => {
67
- if (!n[t].disabled)
68
- return t;
69
- const i = n.length;
70
- return Y(
71
- n,
72
- xe(t + r, i),
73
- r
74
- );
75
- }, Ie = (n, t) => Y(n, t), Pe = (n, t) => Y(n, t, -1), Ye = "_container_5enku_1", je = "_icon_5enku_7", Re = "_arrow_5enku_13", Te = "_dropdown_5enku_19", He = "_disabled_5enku_36", Me = "_value_5enku_43", We = "_error_5enku_46", Le = "_touched_5enku_46", Se = "_opened_5enku_50", Ve = "_placeholder_5enku_83", $e = "_ghost_5enku_118", Ue = "_divider_5enku_139", qe = {
76
- container: Ye,
77
- icon: je,
78
- arrow: Re,
79
- dropdown: Te,
80
- "transparent-background": "_transparent-background_5enku_33",
81
- disabled: He,
82
- value: Me,
83
- error: We,
84
- touched: Le,
85
- opened: Se,
86
- placeholder: Ve,
87
- "mobile-disabled": "_mobile-disabled_5enku_87",
88
- "select-list": "_select-list_5enku_92",
89
- "limited-width": "_limited-width_5enku_109",
90
- "options-container": "_options-container_5enku_113",
91
- ghost: $e,
92
- divider: Ue
93
- }, o = J.bind(qe), dt = ({
94
- multiSelect: n = !1,
95
- value: t = n ? [] : "",
96
- options: r = [],
97
- disabled: i = !1,
98
- error: v,
99
- onChange: m,
100
- onFocus: c,
101
- onBlur: a,
102
- mobileDisabled: b,
103
- title: y,
104
- touched: C = !1,
105
- icon: O,
106
- variant: K,
107
- placeholder: h = "",
108
- label: k = "",
109
- renderOption: A,
110
- transparentBackground: N = !1,
111
- className: Q,
112
- toggleButtonClassName: X,
113
- isListWidthLimited: Z = !1,
114
- optionAll: j = { value: "all", label: "All" },
115
- isOptionAllVisible: R = !1,
116
- onSelectAll: F = () => {
117
- },
118
- formatDisplayedValue: T,
119
- notScrollable: B = !1,
120
- footer: H
121
- }) => {
122
- const [_, f] = q(!1), M = he(null), [ee, D] = q(null), x = n && Array.isArray(t) ? r.filter((e) => t.includes(e.value)) : null, { refs: W, floatingStyles: te } = fe({
123
- placement: "bottom-start",
124
- middleware: [
125
- ue(5),
126
- ge({
127
- fallbackPlacements: ["bottom-start", "top-start", "bottom", "top"]
128
- })
129
- ]
130
- }), ne = () => {
131
- if (R && Array.isArray(t)) {
132
- const e = r.map((s) => s.value);
133
- m(t.length === r.length ? [] : e), F();
134
- }
135
- };
136
- me(M, () => {
137
- _ && (f(!1), a == null || a());
138
- });
139
- const L = (e) => {
140
- if (!e.disabled) {
141
- if (n) {
142
- const s = Array.isArray(t) ? [...t] : [], l = s.indexOf(e.value);
143
- l === -1 ? s.push(e.value) : s.splice(l, 1), m(s);
144
- } else
145
- m(e.value);
146
- f((s) => n || !s);
147
- }
148
- }, re = () => r.find(({ value: e }) => e === t), S = Ae(r, t), {
149
- getToggleButtonProps: se,
150
- getLabelProps: ae,
151
- getMenuProps: de,
152
- getItemProps: le,
153
- setHighlightedIndex: E,
154
- highlightedIndex: V,
155
- selectedItem: w
156
- } = P({
157
- items: r,
158
- itemToString: (e) => (e != null && e.label ? String(e.label) : h) || "",
159
- selectedItem: re(),
160
- isOpen: _,
161
- circularNavigation: !0,
162
- defaultHighlightedIndex: S,
163
- onHighlightedIndexChange: (e) => {
164
- switch (e.type) {
165
- case P.stateChangeTypes.MenuKeyDownArrowUp:
166
- return D(g.ON_KEY_DOWN), E(Pe(r, e.highlightedIndex)), e;
167
- case P.stateChangeTypes.MenuKeyDownArrowDown:
168
- return D(g.ON_KEY_DOWN), E(Ie(r, e.highlightedIndex)), e;
169
- default:
170
- return e;
171
- }
172
- }
173
- }), ie = () => {
174
- i || (f((e) => !e), _ ? a == null || a() : c == null || c(), D(g.ON_CLICK));
175
- }, I = (() => {
176
- if (n && Array.isArray(t) && r.length === t.length)
177
- return j.label;
178
- const e = r.reduce((s, l) => ((Array.isArray(t) && t.includes(l.value) || l.value === t) && s.push(l.label), s), []);
179
- if (e.length > 0)
180
- return e.join(", ");
181
- if (!t && t !== !1 && t !== 0 || Array.isArray(t) && !t.length)
182
- return h;
183
- })(), oe = (e) => {
184
- const { keyCode: s } = e;
185
- ve.includes(s) && !_ && (e.preventDefault(), E(S), f(!0), c == null || c(), D(g.ON_KEY_DOWN));
186
- }, ce = (e) => {
187
- const { keyCode: s } = e;
188
- if (s === p.ENTER_KEY_CODE) {
189
- const l = r[V];
190
- L(l), n || (f(!1), a == null || a());
191
- return;
192
- }
193
- Ke.includes(s) && (e.stopPropagation(), f(!1), a == null || a());
194
- }, $ = () => /* @__PURE__ */ u("div", { className: o("options-container"), children: [
195
- n && R && Array.isArray(t) && /* @__PURE__ */ u(U, { children: [
196
- /* @__PURE__ */ d(
197
- G,
198
- {
199
- option: j,
200
- selected: t.length === r.length,
201
- onChange: ne,
202
- multiSelect: n,
203
- isPartiallyChecked: !!t.length
204
- }
205
- ),
206
- /* @__PURE__ */ d("div", { className: o("divider") }),
207
- " "
208
- ] }),
209
- r.map((e, s) => /* @__PURE__ */ d(
210
- G,
211
- {
212
- ...le({
213
- item: e,
214
- index: s
215
- }),
216
- multiSelect: n,
217
- selected: n ? x == null ? void 0 : x.some((l) => l.value === e.value) : e.value === ((w == null ? void 0 : w.value) ?? w),
218
- option: { title: e.label, ...e },
219
- highlightHovered: V === s && ee !== g.ON_CLICK,
220
- render: A,
221
- onChange: e.disabled ? null : () => L(e),
222
- onMouseEnter: () => E(s)
223
- },
224
- e.value
225
- )),
226
- H && /* @__PURE__ */ u(U, { children: [
227
- /* @__PURE__ */ d("div", { className: o("divider") }),
228
- H
229
- ] })
230
- ] });
231
- return /* @__PURE__ */ u("div", { ref: M, className: o("container", Q), title: y, children: [
232
- k && /* @__PURE__ */ d(Ce, { ...ae(), children: k }),
233
- /* @__PURE__ */ u(
234
- "button",
235
- {
236
- disabled: i,
237
- ...se({
238
- className: o("dropdown", K, X, {
239
- "transparent-background": N,
240
- opened: _,
241
- disabled: i,
242
- error: v,
243
- touched: C,
244
- "mobile-disabled": b
245
- }),
246
- onClick: ie,
247
- onKeyDown: oe,
248
- ref: W.setReference
249
- }),
250
- type: "button",
251
- children: [
252
- O && /* @__PURE__ */ d("span", { className: o("icon"), children: O }),
253
- /* @__PURE__ */ d(
254
- "span",
255
- {
256
- className: o("value", {
257
- placeholder: I === h
258
- }),
259
- children: T ? T(I) : I
260
- }
261
- ),
262
- /* @__PURE__ */ d(ye, { className: o("arrow"), tabIndex: -1, children: /* @__PURE__ */ d(be, {}) })
263
- ]
264
- }
265
- ),
266
- _ && /* @__PURE__ */ d(
267
- "div",
268
- {
269
- style: te,
270
- className: o("select-list", { opened: _, "limited-width": Z }),
271
- ...de({
272
- onKeyDown: ce,
273
- ref: W.setFloating
274
- }),
275
- children: B ? $() : /* @__PURE__ */ d(pe, { autoHeight: !0, autoHeightMax: 216, hideTracksWhenNotNeeded: !0, children: $() })
276
- }
277
- )
278
- ] });
279
- };
280
- export {
281
- dt as D
282
- };