@reportportal/ui-kit 0.0.1-alpha.164 → 0.0.1-alpha.166
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 +198 -71
- package/dist/components/bulkPanel/bulkPanel.d.ts +1 -1
- package/dist/components/bulkPanel/index.d.ts +1 -1
- package/dist/components/bulkPanel/types.d.ts +36 -7
- package/dist/icons.js +51 -50
- package/dist/index.js +46 -45
- package/dist/style.css +1 -1
- package/dist/{table-5fc80c4b.js → table-03bd209d.js} +285 -285
- package/dist/table.js +1 -1
- package/dist/warning-537ead32.js +5 -0
- package/package.json +1 -1
package/dist/bulkPanel.js
CHANGED
|
@@ -1,92 +1,219 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { c as
|
|
5
|
-
import { Scrollbars as
|
|
6
|
-
import { u as
|
|
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";
|
|
3
|
+
import { createPortal as H } from "react-dom";
|
|
4
|
+
import { c as J } from "./bind-06a7ff84.js";
|
|
5
|
+
import { Scrollbars as Q } from "rc-scrollbars";
|
|
6
|
+
import { u as X } from "./useOnClickOutside-8f7d68a1.js";
|
|
7
7
|
import "react-dnd";
|
|
8
8
|
import "react-dnd-html5-backend";
|
|
9
|
-
import { K as
|
|
10
|
-
import { S as
|
|
11
|
-
import { Chip as
|
|
12
|
-
import {
|
|
9
|
+
import { K as Z } from "./keyCodes-f63c0e11.js";
|
|
10
|
+
import { S as ee } from "./selection-9124d029.js";
|
|
11
|
+
import { Chip as ne } from "./chip.js";
|
|
12
|
+
import { B } from "./button-97d9e587.js";
|
|
13
|
+
import { Tooltip as le } from "./tooltip.js";
|
|
14
|
+
import { S as te } from "./chevronDownDropdown-0260bb66.js";
|
|
15
|
+
import { S as ie } from "./warning-537ead32.js";
|
|
13
16
|
import "./close-4d480ef7.js";
|
|
14
|
-
import "
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
17
|
+
import "@floating-ui/react";
|
|
18
|
+
import "./floatingUi-41f8c7b5.js";
|
|
19
|
+
const ae = "_expanded_ue1t9_6", se = "_header_ue1t9_32", oe = "_tabs_ue1t9_119", ce = "_tab_ue1t9_119", re = "_active_ue1t9_146", de = "_item_ue1t9_99", me = {
|
|
20
|
+
"bulk-panel": "_bulk-panel_ue1t9_1",
|
|
21
|
+
expanded: ae,
|
|
22
|
+
"panel-content": "_panel-content_ue1t9_16",
|
|
23
|
+
header: se,
|
|
24
|
+
"header-actions": "_header-actions_ue1t9_43",
|
|
25
|
+
"warning-icon": "_warning-icon_ue1t9_49",
|
|
26
|
+
"info-message-container": "_info-message-container_ue1t9_58",
|
|
27
|
+
"buttons-container": "_buttons-container_ue1t9_66",
|
|
28
|
+
"selection-info": "_selection-info_ue1t9_72",
|
|
29
|
+
"expand-icon": "_expand-icon_ue1t9_87",
|
|
30
|
+
"items-section": "_items-section_ue1t9_99",
|
|
31
|
+
"items-header": "_items-header_ue1t9_110",
|
|
32
|
+
tabs: oe,
|
|
33
|
+
tab: ce,
|
|
34
|
+
"tab-count": "_tab-count_ue1t9_142",
|
|
35
|
+
active: re,
|
|
36
|
+
"items-scroll": "_items-scroll_ue1t9_162",
|
|
37
|
+
"items-list": "_items-list_ue1t9_167",
|
|
38
|
+
item: de,
|
|
39
|
+
"tooltip-wrapper": "_tooltip-wrapper_ue1t9_179"
|
|
40
|
+
}, l = J.bind(me), pe = {
|
|
27
41
|
selected: "selected",
|
|
28
42
|
clearSelection: "Clear selection",
|
|
29
|
-
selectedItems: "Selected items"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
selectedItems: "Selected items",
|
|
44
|
+
eligibleTab: "Eligible Items",
|
|
45
|
+
ineligibleTab: "Ineligible Items",
|
|
46
|
+
ineligibleInfoMessage: (t) => /* @__PURE__ */ s(y, { children: [
|
|
47
|
+
"You have ",
|
|
48
|
+
/* @__PURE__ */ n("b", { children: t }),
|
|
49
|
+
" ineligible items"
|
|
50
|
+
] }),
|
|
51
|
+
cancelButton: (t) => `Cancel "${t}"`,
|
|
52
|
+
proceedButton: (t) => `Proceed with ${t} Eligible Items`
|
|
53
|
+
}, p = {
|
|
54
|
+
ELIGIBLE: "eligible",
|
|
55
|
+
INELIGIBLE: "ineligible"
|
|
56
|
+
}, Ge = ({
|
|
57
|
+
items: t,
|
|
58
|
+
actions: D = [],
|
|
59
|
+
captions: K,
|
|
60
|
+
infoMessage: x,
|
|
61
|
+
className: M,
|
|
62
|
+
portalRoot: f,
|
|
63
|
+
onRemoveItem: w,
|
|
64
|
+
onClearSelection: O
|
|
37
65
|
}) => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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(() => {
|
|
67
|
+
var g;
|
|
68
|
+
if (!i)
|
|
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,
|
|
76
|
+
h,
|
|
77
|
+
I,
|
|
78
|
+
m,
|
|
79
|
+
d
|
|
80
|
+
]), j = b(
|
|
81
|
+
(e) => {
|
|
82
|
+
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));
|
|
84
|
+
},
|
|
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(
|
|
95
|
+
(e) => {
|
|
96
|
+
w(e);
|
|
97
|
+
},
|
|
98
|
+
[w]
|
|
99
|
+
);
|
|
100
|
+
if (z(() => {
|
|
101
|
+
if (!o)
|
|
45
102
|
return;
|
|
46
|
-
const
|
|
47
|
-
|
|
103
|
+
const e = (a) => {
|
|
104
|
+
a.keyCode === Z.ESCAPE_KEY_CODE && E();
|
|
48
105
|
};
|
|
49
|
-
return document.addEventListener("keydown",
|
|
50
|
-
}, [
|
|
106
|
+
return document.addEventListener("keydown", e, !1), () => document.removeEventListener("keydown", e, !1);
|
|
107
|
+
}, [o, E]), X(S, o ? E : void 0), t.length === 0)
|
|
51
108
|
return null;
|
|
52
|
-
const
|
|
109
|
+
const R = (e) => h.some((a) => a.id === e.id), U = (e) => {
|
|
110
|
+
const a = /* @__PURE__ */ n(
|
|
111
|
+
ne,
|
|
112
|
+
{
|
|
113
|
+
onRemove: () => Y(e.id),
|
|
114
|
+
variant: R(e) && r ? "error" : "default",
|
|
115
|
+
children: e.label ?? e.name
|
|
116
|
+
},
|
|
117
|
+
e.id
|
|
118
|
+
);
|
|
119
|
+
return /* @__PURE__ */ n("div", { className: l("item"), children: e.tooltipContent ? /* @__PURE__ */ n(
|
|
120
|
+
le,
|
|
121
|
+
{
|
|
122
|
+
wrapperClassName: l("tooltip-wrapper"),
|
|
123
|
+
content: e.tooltipContent,
|
|
124
|
+
placement: "top",
|
|
125
|
+
width: 270,
|
|
126
|
+
portalRoot: f,
|
|
127
|
+
children: a
|
|
128
|
+
},
|
|
129
|
+
e.id
|
|
130
|
+
) : a }, e.id);
|
|
131
|
+
}, G = /* @__PURE__ */ n(
|
|
53
132
|
"div",
|
|
54
133
|
{
|
|
55
|
-
className: l("bulk-panel", { expanded:
|
|
134
|
+
className: l("bulk-panel", { expanded: o }, M),
|
|
56
135
|
role: "region",
|
|
57
136
|
"aria-label": "Bulk actions panel",
|
|
58
|
-
children: /* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
/* @__PURE__ */ n(
|
|
141
|
+
"button",
|
|
142
|
+
{
|
|
143
|
+
onClick: W,
|
|
144
|
+
"aria-label": o ? "Collapse panel" : "Expand panel",
|
|
145
|
+
"aria-expanded": o,
|
|
146
|
+
children: /* @__PURE__ */ n("span", { className: l("expand-icon", { expanded: o }), children: /* @__PURE__ */ n(te, {}) })
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ n(
|
|
150
|
+
ee,
|
|
151
|
+
{
|
|
152
|
+
selectedCount: t.length,
|
|
153
|
+
onClearSelection: O,
|
|
154
|
+
captions: {
|
|
155
|
+
selected: c.selected,
|
|
156
|
+
buttonCaption: c.clearSelection
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
] }),
|
|
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 })
|
|
165
|
+
] }),
|
|
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
|
+
] }) : D.map((e, a) => /* @__PURE__ */ n(
|
|
170
|
+
B,
|
|
171
|
+
{
|
|
172
|
+
variant: e.variant,
|
|
173
|
+
onClick: () => j(e),
|
|
174
|
+
disabled: e.disabled,
|
|
175
|
+
children: e.label
|
|
176
|
+
},
|
|
177
|
+
`${e.label}-${a}`
|
|
178
|
+
)) })
|
|
179
|
+
] })
|
|
180
|
+
] }),
|
|
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
|
+
"button",
|
|
185
|
+
{
|
|
186
|
+
className: l("tab", {
|
|
187
|
+
active: I === p.INELIGIBLE || d === 0
|
|
188
|
+
}),
|
|
189
|
+
onClick: () => v(p.INELIGIBLE),
|
|
190
|
+
children: [
|
|
191
|
+
c.ineligibleTab,
|
|
192
|
+
/* @__PURE__ */ n("span", { className: l("tab-count"), children: m })
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
d > 0 && /* @__PURE__ */ s(
|
|
197
|
+
"button",
|
|
198
|
+
{
|
|
199
|
+
className: l("tab", {
|
|
200
|
+
active: I === p.ELIGIBLE || m === 0
|
|
201
|
+
}),
|
|
202
|
+
onClick: () => v(p.ELIGIBLE),
|
|
203
|
+
children: [
|
|
204
|
+
c.eligibleTab,
|
|
205
|
+
/* @__PURE__ */ n("span", { className: l("tab-count"), children: d })
|
|
206
|
+
]
|
|
77
207
|
}
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
/* @__PURE__ */ i("div", { className: l("items-section"), children: [
|
|
82
|
-
/* @__PURE__ */ e("div", { className: l("items-header"), children: t.selectedItems }),
|
|
83
|
-
/* @__PURE__ */ e("div", { className: l("items-scroll"), children: /* @__PURE__ */ e(E, { hideTracksWhenNotNeeded: !0, children: /* @__PURE__ */ e("div", { className: l("items-list"), children: o.map((s) => /* @__PURE__ */ e(D, { onRemove: () => _(s.id), children: s.label }, s.id)) }) }) })
|
|
208
|
+
)
|
|
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)) }) }) })
|
|
84
211
|
] })
|
|
85
212
|
] })
|
|
86
213
|
}
|
|
87
214
|
);
|
|
88
|
-
return
|
|
215
|
+
return o && f ? H(G, f) : G;
|
|
89
216
|
};
|
|
90
217
|
export {
|
|
91
|
-
|
|
218
|
+
Ge as BulkPanel
|
|
92
219
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BulkPanelProps } from './types';
|
|
2
2
|
|
|
3
|
-
export declare const BulkPanel: ({ items,
|
|
3
|
+
export declare const BulkPanel: ({ items, actions, captions: captionsProp, infoMessage, className, portalRoot, onRemoveItem, onClearSelection, }: BulkPanelProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { BulkPanel } from './bulkPanel';
|
|
2
|
-
export type { BulkPanelProps, BulkPanelItem } from './types';
|
|
2
|
+
export type { BulkPanelProps, BulkPanelItem, BulkPanelAction, BulkPanelCaptions } from './types';
|
|
@@ -1,16 +1,45 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ButtonProps } from '../button';
|
|
3
|
+
|
|
1
4
|
export interface BulkPanelItem {
|
|
2
5
|
id: string | number;
|
|
6
|
+
label?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
tooltipContent?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export interface BulkPanelAction {
|
|
3
11
|
label: string;
|
|
12
|
+
variant?: ButtonProps['variant'];
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
onClick?: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Called to validate items. May be called multiple times if items change.
|
|
17
|
+
* Should return INELIGIBLE items array.
|
|
18
|
+
* If not provided or returns empty array - all items are eligible and onProceed is called immediately.
|
|
19
|
+
*/
|
|
20
|
+
onValidate?: (items: BulkPanelItem[]) => BulkPanelItem[];
|
|
21
|
+
/**
|
|
22
|
+
* @param direct - true if all items were eligible and proceed was called directly, false if called via Proceed button
|
|
23
|
+
*/
|
|
24
|
+
onProceed: (eligibleItems: BulkPanelItem[], direct?: boolean) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface BulkPanelCaptions {
|
|
27
|
+
selected?: string;
|
|
28
|
+
clearSelection?: string;
|
|
29
|
+
selectedItems?: string;
|
|
30
|
+
eligibleTab?: string;
|
|
31
|
+
ineligibleTab?: string;
|
|
32
|
+
ineligibleInfoMessage?: (ineligibleCount: number) => ReactNode | string;
|
|
33
|
+
cancelButton?: (actionLabel: string) => ReactNode | string;
|
|
34
|
+
proceedButton?: (eligibleCount: number) => ReactNode | string;
|
|
4
35
|
}
|
|
5
36
|
export interface BulkPanelProps {
|
|
6
|
-
className?: string;
|
|
7
37
|
items: BulkPanelItem[];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
38
|
+
actions?: BulkPanelAction[];
|
|
39
|
+
captions?: BulkPanelCaptions;
|
|
40
|
+
infoMessage?: ReactNode;
|
|
41
|
+
className?: string;
|
|
42
|
+
portalRoot?: Element;
|
|
13
43
|
onRemoveItem: (id: string | number) => void;
|
|
14
44
|
onClearSelection: () => void;
|
|
15
|
-
portalRoot?: Element;
|
|
16
45
|
}
|