@reportportal/ui-kit 0.0.1-alpha.166 → 0.0.1-alpha.168

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/bulkPanel.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as n, jsxs as s, Fragment as y } from "react/jsx-runtime";
2
- import { useState as k, useRef as q, useMemo as P, useCallback as b, useEffect as z } from "react";
2
+ import { useState as k, useRef as U, useMemo as P, useCallback as _, useEffect as z } from "react";
3
3
  import { createPortal as H } from "react-dom";
4
4
  import { c as J } from "./bind-06a7ff84.js";
5
5
  import { Scrollbars as Q } from "rc-scrollbars";
@@ -10,8 +10,8 @@ import { K as Z } from "./keyCodes-f63c0e11.js";
10
10
  import { S as ee } from "./selection-9124d029.js";
11
11
  import { Chip as ne } from "./chip.js";
12
12
  import { B } from "./button-97d9e587.js";
13
- import { Tooltip as le } from "./tooltip.js";
14
- import { S as te } from "./chevronDownDropdown-0260bb66.js";
13
+ import { Tooltip as te } from "./tooltip.js";
14
+ import { S as le } from "./chevronDownDropdown-0260bb66.js";
15
15
  import { S as ie } from "./warning-537ead32.js";
16
16
  import "./close-4d480ef7.js";
17
17
  import "@floating-ui/react";
@@ -37,24 +37,24 @@ const ae = "_expanded_ue1t9_6", se = "_header_ue1t9_32", oe = "_tabs_ue1t9_119",
37
37
  "items-list": "_items-list_ue1t9_167",
38
38
  item: de,
39
39
  "tooltip-wrapper": "_tooltip-wrapper_ue1t9_179"
40
- }, l = J.bind(me), pe = {
40
+ }, t = J.bind(me), pe = {
41
41
  selected: "selected",
42
42
  clearSelection: "Clear selection",
43
43
  selectedItems: "Selected items",
44
44
  eligibleTab: "Eligible Items",
45
45
  ineligibleTab: "Ineligible Items",
46
- ineligibleInfoMessage: (t) => /* @__PURE__ */ s(y, { children: [
46
+ ineligibleInfoMessage: (i) => /* @__PURE__ */ s(y, { children: [
47
47
  "You have ",
48
- /* @__PURE__ */ n("b", { children: t }),
48
+ /* @__PURE__ */ n("b", { children: i }),
49
49
  " ineligible items"
50
50
  ] }),
51
- cancelButton: (t) => `Cancel "${t}"`,
52
- proceedButton: (t) => `Proceed with ${t} Eligible Items`
53
- }, p = {
51
+ cancelButton: (i) => `Cancel "${i}"`,
52
+ proceedButton: (i) => `Proceed with ${i} Eligible Items`
53
+ }, u = {
54
54
  ELIGIBLE: "eligible",
55
55
  INELIGIBLE: "ineligible"
56
56
  }, Ge = ({
57
- items: t,
57
+ items: i,
58
58
  actions: D = [],
59
59
  captions: K,
60
60
  infoMessage: x,
@@ -63,35 +63,38 @@ const ae = "_expanded_ue1t9_6", se = "_header_ue1t9_32", oe = "_tabs_ue1t9_119",
63
63
  onRemoveItem: w,
64
64
  onClearSelection: O
65
65
  }) => {
66
- const c = { ...pe, ...K }, [o, _] = k(!1), [I, v] = k(p.INELIGIBLE), [i, C] = k(null), S = q(null), r = i !== null, { eligibleItems: u, ineligibleItems: h } = P(() => {
66
+ const r = { ...pe, ...K }, [o, v] = k(!1), [I, C] = k(u.INELIGIBLE), [l, E] = k(null), S = U(null), d = l !== null, { eligibleItems: b, ineligibleItems: h } = P(() => {
67
67
  var g;
68
- if (!i)
68
+ if (!l)
69
69
  return { eligibleItems: [], ineligibleItems: [] };
70
- const e = ((g = i.onValidate) == null ? void 0 : g.call(i, t)) ?? [], a = new Set(e.map((L) => L.id));
71
- return { eligibleItems: t.filter((L) => !a.has(L.id)), ineligibleItems: e };
72
- }, [t, i]), d = u.length, m = h.length, $ = r && d > 0, T = r && m > 0 ? c.ineligibleInfoMessage(m) : null, V = P(() => r ? m === 0 ? u : d === 0 ? h : I === p.ELIGIBLE ? u : h : t, [
73
- r,
74
- t,
75
- u,
70
+ const e = ((g = l.onValidate) == null ? void 0 : g.call(l, i)) ?? [], a = new Set(e.map((L) => L.id));
71
+ return { eligibleItems: i.filter((L) => !a.has(L.id)), ineligibleItems: e };
72
+ }, [i, l]), m = b.length, p = h.length, $ = d && m > 0, T = d && p > 0 ? r.ineligibleInfoMessage(p) : null, F = P(() => d ? p === 0 ? b : m === 0 ? h : I === u.ELIGIBLE ? b : h : i, [
73
+ d,
74
+ i,
75
+ b,
76
76
  h,
77
77
  I,
78
- m,
79
- d
80
- ]), j = b(
78
+ p,
79
+ m
80
+ ]), c = _(() => {
81
+ requestAnimationFrame(() => {
82
+ v(!1);
83
+ });
84
+ }, []), V = _(
81
85
  (e) => {
82
86
  var N, g;
83
- (N = e.onClick) == null || N.call(e), (((g = e.onValidate) == null ? void 0 : g.call(e, t)) ?? []).length === 0 ? e.onProceed(t, !0) : (C(e), v(p.INELIGIBLE), _(!0));
87
+ (N = e.onClick) == null || N.call(e), (((g = e.onValidate) == null ? void 0 : g.call(e, i)) ?? []).length === 0 ? (e.onProceed(i, !0), c()) : (E(e), C(u.INELIGIBLE), v(!0));
84
88
  },
85
- [t]
86
- ), A = b(() => {
87
- C(null), _(!1);
88
- }, []), F = b(() => {
89
- i == null || i.onProceed(u), C(null), _(!1);
90
- }, [i, u]), E = b(() => {
91
- _(!1);
92
- }, []), W = b(() => {
93
- _((e) => !e);
94
- }, []), Y = b(
89
+ [i, c]
90
+ ), j = _(() => {
91
+ const e = l == null ? void 0 : l.onCancel;
92
+ E(null), c(), e == null || e();
93
+ }, [l, c]), W = _(() => {
94
+ l == null || l.onProceed(b), E(null), c();
95
+ }, [l, b, c]), Y = _(() => {
96
+ v((e) => !e);
97
+ }, []), q = _(
95
98
  (e) => {
96
99
  w(e);
97
100
  },
@@ -101,25 +104,25 @@ const ae = "_expanded_ue1t9_6", se = "_header_ue1t9_32", oe = "_tabs_ue1t9_119",
101
104
  if (!o)
102
105
  return;
103
106
  const e = (a) => {
104
- a.keyCode === Z.ESCAPE_KEY_CODE && E();
107
+ a.keyCode === Z.ESCAPE_KEY_CODE && c();
105
108
  };
106
109
  return document.addEventListener("keydown", e, !1), () => document.removeEventListener("keydown", e, !1);
107
- }, [o, E]), X(S, o ? E : void 0), t.length === 0)
110
+ }, [o, c]), X(S, o ? c : void 0), i.length === 0)
108
111
  return null;
109
- const R = (e) => h.some((a) => a.id === e.id), U = (e) => {
112
+ const A = (e) => h.some((a) => a.id === e.id), R = (e) => {
110
113
  const a = /* @__PURE__ */ n(
111
114
  ne,
112
115
  {
113
- onRemove: () => Y(e.id),
114
- variant: R(e) && r ? "error" : "default",
116
+ onRemove: () => q(e.id),
117
+ variant: A(e) && d ? "error" : "default",
115
118
  children: e.label ?? e.name
116
119
  },
117
120
  e.id
118
121
  );
119
- return /* @__PURE__ */ n("div", { className: l("item"), children: e.tooltipContent ? /* @__PURE__ */ n(
120
- le,
122
+ return /* @__PURE__ */ n("div", { className: t("item"), children: e.tooltipContent ? /* @__PURE__ */ n(
123
+ te,
121
124
  {
122
- wrapperClassName: l("tooltip-wrapper"),
125
+ wrapperClassName: t("tooltip-wrapper"),
123
126
  content: e.tooltipContent,
124
127
  placement: "top",
125
128
  width: 270,
@@ -131,46 +134,46 @@ const ae = "_expanded_ue1t9_6", se = "_header_ue1t9_32", oe = "_tabs_ue1t9_119",
131
134
  }, G = /* @__PURE__ */ n(
132
135
  "div",
133
136
  {
134
- className: l("bulk-panel", { expanded: o }, M),
137
+ className: t("bulk-panel", { expanded: o }, M),
135
138
  role: "region",
136
139
  "aria-label": "Bulk actions panel",
137
- children: /* @__PURE__ */ s("div", { className: l("panel-content", { expanded: o }), ref: S, children: [
138
- /* @__PURE__ */ s("div", { className: l("header"), children: [
139
- /* @__PURE__ */ s("div", { className: l("selection-info"), children: [
140
+ children: /* @__PURE__ */ s("div", { className: t("panel-content", { expanded: o }), ref: S, children: [
141
+ /* @__PURE__ */ s("div", { className: t("header"), children: [
142
+ /* @__PURE__ */ s("div", { className: t("selection-info"), children: [
140
143
  /* @__PURE__ */ n(
141
144
  "button",
142
145
  {
143
- onClick: W,
146
+ onClick: Y,
144
147
  "aria-label": o ? "Collapse panel" : "Expand panel",
145
148
  "aria-expanded": o,
146
- children: /* @__PURE__ */ n("span", { className: l("expand-icon", { expanded: o }), children: /* @__PURE__ */ n(te, {}) })
149
+ children: /* @__PURE__ */ n("span", { className: t("expand-icon", { expanded: o }), children: /* @__PURE__ */ n(le, {}) })
147
150
  }
148
151
  ),
149
152
  /* @__PURE__ */ n(
150
153
  ee,
151
154
  {
152
- selectedCount: t.length,
155
+ selectedCount: i.length,
153
156
  onClearSelection: O,
154
157
  captions: {
155
- selected: c.selected,
156
- buttonCaption: c.clearSelection
158
+ selected: r.selected,
159
+ buttonCaption: r.clearSelection
157
160
  }
158
161
  }
159
162
  )
160
163
  ] }),
161
- /* @__PURE__ */ s("div", { className: l("header-actions"), children: [
162
- (T || x) && /* @__PURE__ */ s("div", { className: l("info-message-container"), children: [
163
- /* @__PURE__ */ n("i", { className: l("warning-icon"), children: /* @__PURE__ */ n(ie, {}) }),
164
- /* @__PURE__ */ n("div", { className: l("info-message"), children: T || x })
164
+ /* @__PURE__ */ s("div", { className: t("header-actions"), children: [
165
+ (T || x) && /* @__PURE__ */ s("div", { className: t("info-message-container"), children: [
166
+ /* @__PURE__ */ n("i", { className: t("warning-icon"), children: /* @__PURE__ */ n(ie, {}) }),
167
+ /* @__PURE__ */ n("div", { className: t("info-message"), children: T || x })
165
168
  ] }),
166
- /* @__PURE__ */ n("div", { className: l("buttons-container"), children: r ? /* @__PURE__ */ s(y, { children: [
167
- /* @__PURE__ */ n(B, { variant: "ghost", onClick: A, children: c.cancelButton((i == null ? void 0 : i.label) ?? "") }),
168
- $ && /* @__PURE__ */ n(B, { variant: "primary", onClick: F, children: c.proceedButton(d) })
169
+ /* @__PURE__ */ n("div", { className: t("buttons-container"), children: d ? /* @__PURE__ */ s(y, { children: [
170
+ /* @__PURE__ */ n(B, { variant: "ghost", onClick: j, children: r.cancelButton((l == null ? void 0 : l.label) ?? "") }),
171
+ $ && /* @__PURE__ */ n(B, { variant: "primary", onClick: W, children: r.proceedButton(m) })
169
172
  ] }) : D.map((e, a) => /* @__PURE__ */ n(
170
173
  B,
171
174
  {
172
175
  variant: e.variant,
173
- onClick: () => j(e),
176
+ onClick: () => V(e),
174
177
  disabled: e.disabled,
175
178
  children: e.label
176
179
  },
@@ -178,36 +181,36 @@ const ae = "_expanded_ue1t9_6", se = "_header_ue1t9_32", oe = "_tabs_ue1t9_119",
178
181
  )) })
179
182
  ] })
180
183
  ] }),
181
- /* @__PURE__ */ s("div", { className: l("items-section"), children: [
182
- /* @__PURE__ */ n("div", { className: l("items-header"), children: r ? /* @__PURE__ */ s("div", { className: l("tabs"), children: [
183
- m > 0 && /* @__PURE__ */ s(
184
+ /* @__PURE__ */ s("div", { className: t("items-section"), children: [
185
+ /* @__PURE__ */ n("div", { className: t("items-header"), children: d ? /* @__PURE__ */ s("div", { className: t("tabs"), children: [
186
+ p > 0 && /* @__PURE__ */ s(
184
187
  "button",
185
188
  {
186
- className: l("tab", {
187
- active: I === p.INELIGIBLE || d === 0
189
+ className: t("tab", {
190
+ active: I === u.INELIGIBLE || m === 0
188
191
  }),
189
- onClick: () => v(p.INELIGIBLE),
192
+ onClick: () => C(u.INELIGIBLE),
190
193
  children: [
191
- c.ineligibleTab,
192
- /* @__PURE__ */ n("span", { className: l("tab-count"), children: m })
194
+ r.ineligibleTab,
195
+ /* @__PURE__ */ n("span", { className: t("tab-count"), children: p })
193
196
  ]
194
197
  }
195
198
  ),
196
- d > 0 && /* @__PURE__ */ s(
199
+ m > 0 && /* @__PURE__ */ s(
197
200
  "button",
198
201
  {
199
- className: l("tab", {
200
- active: I === p.ELIGIBLE || m === 0
202
+ className: t("tab", {
203
+ active: I === u.ELIGIBLE || p === 0
201
204
  }),
202
- onClick: () => v(p.ELIGIBLE),
205
+ onClick: () => C(u.ELIGIBLE),
203
206
  children: [
204
- c.eligibleTab,
205
- /* @__PURE__ */ n("span", { className: l("tab-count"), children: d })
207
+ r.eligibleTab,
208
+ /* @__PURE__ */ n("span", { className: t("tab-count"), children: m })
206
209
  ]
207
210
  }
208
211
  )
209
- ] }) : c.selectedItems }),
210
- /* @__PURE__ */ n("div", { className: l("items-scroll"), children: /* @__PURE__ */ n(Q, { hideTracksWhenNotNeeded: !0, children: /* @__PURE__ */ n("div", { className: l("items-list"), children: V.map((e) => U(e)) }) }) })
212
+ ] }) : r.selectedItems }),
213
+ /* @__PURE__ */ n("div", { className: t("items-scroll"), children: /* @__PURE__ */ n(Q, { hideTracksWhenNotNeeded: !0, children: /* @__PURE__ */ n("div", { className: t("items-list"), children: F.map((e) => R(e)) }) }) })
211
214
  ] })
212
215
  ] })
213
216
  }
@@ -22,6 +22,7 @@ export interface BulkPanelAction {
22
22
  * @param direct - true if all items were eligible and proceed was called directly, false if called via Proceed button
23
23
  */
24
24
  onProceed: (eligibleItems: BulkPanelItem[], direct?: boolean) => void;
25
+ onCancel?: () => void;
25
26
  }
26
27
  export interface BulkPanelCaptions {
27
28
  selected?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/ui-kit",
3
- "version": "0.0.1-alpha.166",
3
+ "version": "0.0.1-alpha.168",
4
4
  "description": "The UI-kit library for ReportPortal Design System.",
5
5
  "type": "module",
6
6
  "scripts": {