@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
|
|
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
|
|
14
|
-
import { S as
|
|
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
|
-
},
|
|
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: (
|
|
46
|
+
ineligibleInfoMessage: (i) => /* @__PURE__ */ s(y, { children: [
|
|
47
47
|
"You have ",
|
|
48
|
-
/* @__PURE__ */ n("b", { children:
|
|
48
|
+
/* @__PURE__ */ n("b", { children: i }),
|
|
49
49
|
" ineligible items"
|
|
50
50
|
] }),
|
|
51
|
-
cancelButton: (
|
|
52
|
-
proceedButton: (
|
|
53
|
-
},
|
|
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:
|
|
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
|
|
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 (!
|
|
68
|
+
if (!l)
|
|
69
69
|
return { eligibleItems: [], ineligibleItems: [] };
|
|
70
|
-
const e = ((g =
|
|
71
|
-
return { eligibleItems:
|
|
72
|
-
}, [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
]),
|
|
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,
|
|
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
|
-
[
|
|
86
|
-
),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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 &&
|
|
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,
|
|
110
|
+
}, [o, c]), X(S, o ? c : void 0), i.length === 0)
|
|
108
111
|
return null;
|
|
109
|
-
const
|
|
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: () =>
|
|
114
|
-
variant:
|
|
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:
|
|
120
|
-
|
|
122
|
+
return /* @__PURE__ */ n("div", { className: t("item"), children: e.tooltipContent ? /* @__PURE__ */ n(
|
|
123
|
+
te,
|
|
121
124
|
{
|
|
122
|
-
wrapperClassName:
|
|
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:
|
|
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:
|
|
138
|
-
/* @__PURE__ */ s("div", { className:
|
|
139
|
-
/* @__PURE__ */ s("div", { className:
|
|
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:
|
|
146
|
+
onClick: Y,
|
|
144
147
|
"aria-label": o ? "Collapse panel" : "Expand panel",
|
|
145
148
|
"aria-expanded": o,
|
|
146
|
-
children: /* @__PURE__ */ n("span", { className:
|
|
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:
|
|
155
|
+
selectedCount: i.length,
|
|
153
156
|
onClearSelection: O,
|
|
154
157
|
captions: {
|
|
155
|
-
selected:
|
|
156
|
-
buttonCaption:
|
|
158
|
+
selected: r.selected,
|
|
159
|
+
buttonCaption: r.clearSelection
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
)
|
|
160
163
|
] }),
|
|
161
|
-
/* @__PURE__ */ s("div", { className:
|
|
162
|
-
(T || x) && /* @__PURE__ */ s("div", { className:
|
|
163
|
-
/* @__PURE__ */ n("i", { className:
|
|
164
|
-
/* @__PURE__ */ n("div", { className:
|
|
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:
|
|
167
|
-
/* @__PURE__ */ n(B, { variant: "ghost", onClick:
|
|
168
|
-
$ && /* @__PURE__ */ n(B, { variant: "primary", onClick:
|
|
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: () =>
|
|
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:
|
|
182
|
-
/* @__PURE__ */ n("div", { className:
|
|
183
|
-
|
|
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:
|
|
187
|
-
active: I ===
|
|
189
|
+
className: t("tab", {
|
|
190
|
+
active: I === u.INELIGIBLE || m === 0
|
|
188
191
|
}),
|
|
189
|
-
onClick: () =>
|
|
192
|
+
onClick: () => C(u.INELIGIBLE),
|
|
190
193
|
children: [
|
|
191
|
-
|
|
192
|
-
/* @__PURE__ */ n("span", { className:
|
|
194
|
+
r.ineligibleTab,
|
|
195
|
+
/* @__PURE__ */ n("span", { className: t("tab-count"), children: p })
|
|
193
196
|
]
|
|
194
197
|
}
|
|
195
198
|
),
|
|
196
|
-
|
|
199
|
+
m > 0 && /* @__PURE__ */ s(
|
|
197
200
|
"button",
|
|
198
201
|
{
|
|
199
|
-
className:
|
|
200
|
-
active: I ===
|
|
202
|
+
className: t("tab", {
|
|
203
|
+
active: I === u.ELIGIBLE || p === 0
|
|
201
204
|
}),
|
|
202
|
-
onClick: () =>
|
|
205
|
+
onClick: () => C(u.ELIGIBLE),
|
|
203
206
|
children: [
|
|
204
|
-
|
|
205
|
-
/* @__PURE__ */ n("span", { className:
|
|
207
|
+
r.eligibleTab,
|
|
208
|
+
/* @__PURE__ */ n("span", { className: t("tab-count"), children: m })
|
|
206
209
|
]
|
|
207
210
|
}
|
|
208
211
|
)
|
|
209
|
-
] }) :
|
|
210
|
-
/* @__PURE__ */ n("div", { className:
|
|
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;
|