@reportportal/ui-kit 0.0.1-alpha.133 → 0.0.1-alpha.135

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,485 +0,0 @@
1
- import { jsxs as w, jsx as r } from "react/jsx-runtime";
2
- import { useMemo as Z, useState as L, useCallback as C, useEffect as R, useRef as F } from "react";
3
- import { c as ke } from "./bind-06a7ff84.js";
4
- import { b as Y, a as q, S as ve } from "./chevronDownDropdown-66f5b1af.js";
5
- import { C as J } from "./checkbox-ed6cc375.js";
6
- const D = (l) => typeof l == "string", Ce = "_table_m8adn_1", ge = "_selectable_m8adn_56", we = "_expanded_m8adn_52", xe = "_label_m8adn_269", Ne = {
7
- table: Ce,
8
- "fixed-header": "_fixed-header_m8adn_8",
9
- "horizontally-scrollable-container": "_horizontally-scrollable-container_m8adn_14",
10
- "table-header": "_table-header_m8adn_19",
11
- "sticky-header": "_sticky-header_m8adn_25",
12
- "horizontally-scrollable": "_horizontally-scrollable_m8adn_14",
13
- "table-row": "_table-row_m8adn_47",
14
- "expanded-cell": "_expanded-cell_m8adn_52",
15
- selectable: ge,
16
- "row-content-wrapper": "_row-content-wrapper_m8adn_60",
17
- "table-row-content": "_table-row-content_m8adn_65",
18
- "expand-cell": "_expand-cell_m8adn_81",
19
- "size-small": "_size-small_m8adn_84",
20
- "size-large": "_size-large_m8adn_95",
21
- "table-body": "_table-body_m8adn_110",
22
- "scrollable-body": "_scrollable-body_m8adn_116",
23
- "table-header-cell": "_table-header-cell_m8adn_162",
24
- "table-cell": "_table-cell_m8adn_163",
25
- "action-menu-cell": "_action-menu-cell_m8adn_170",
26
- "checkbox-cell": "_checkbox-cell_m8adn_195",
27
- "expand-icon": "_expand-icon_m8adn_241",
28
- expanded: we,
29
- "primary-cell": "_primary-cell_m8adn_250",
30
- label: xe,
31
- "sortable-cell": "_sortable-cell_m8adn_280",
32
- "align-right": "_align-right_m8adn_283",
33
- "align-center": "_align-center_m8adn_289",
34
- "pinned-column": "_pinned-column_m8adn_292"
35
- }, I = "asc", x = 32, ee = 100, Ee = 48, Me = (l) => l.toLowerCase() === I, $e = (l) => l.map((a) => a.key), g = (l) => "primary" in l && l.primary === !0, Te = (l) => {
36
- var t;
37
- return `size-${((t = l.rowConfigs) == null ? void 0 : t.size) ?? "default"}`;
38
- }, Se = (l, a, t, s, o) => {
39
- let c = 0;
40
- s && (c += x), o && (c += x);
41
- for (let _ = 0; _ < l; _++) {
42
- const i = a[_];
43
- if (g(i)) {
44
- const n = t.current.get(i.key) || ee;
45
- c += n;
46
- } else {
47
- const n = i, d = D(n.width) ? parseInt(n.width, 10) || 0 : n.width;
48
- c += d;
49
- }
50
- }
51
- return c;
52
- }, A = (l, a, t, s, o, c, _) => {
53
- const i = {};
54
- if (!g(l)) {
55
- const n = l;
56
- i.textAlign = n.align;
57
- }
58
- if (a && t !== void 0) {
59
- const n = Se(
60
- t,
61
- s,
62
- o,
63
- c,
64
- _
65
- );
66
- i.left = `${n}px`;
67
- }
68
- return i;
69
- }, Q = (l, a, t, s, o, c = !1) => {
70
- const _ = [];
71
- t && _.push(`${x}px`), c && s && _.push(`${x}px`);
72
- const i = (n) => {
73
- if (g(n)) {
74
- const d = n, y = d.width ? D(d.width) ? d.width : `${d.width}px` : `${ee}px`;
75
- _.push(`minmax(${y}, 1fr)`);
76
- } else {
77
- const d = n, y = D(d.width) ? d.width : `${d.width}px`;
78
- _.push(y);
79
- }
80
- };
81
- return l.forEach(i), a.forEach(i), o && _.push(`${Ee}px`), _.join(" ");
82
- }, ze = ({
83
- primaryColumns: l,
84
- fixedColumns: a,
85
- pinnedColumnKeys: t
86
- }) => Z(() => {
87
- const s = [], o = [];
88
- return l.forEach((c) => {
89
- const _ = { ...c, primary: !0 };
90
- t.includes(c.key) ? s.push(_) : o.push(_);
91
- }), a.forEach((c) => {
92
- t.includes(c.key) ? s.push(c) : o.push(c);
93
- }), {
94
- pinnedColumns: s,
95
- scrollableColumns: o
96
- };
97
- }, [l, a, t]), Ae = () => {
98
- const [l, a] = L(null), [t, s] = L(null), o = C((n) => {
99
- a(n);
100
- }, []), c = C(() => {
101
- a(null);
102
- }, []), _ = C((n) => {
103
- s(n);
104
- }, []), i = C(() => {
105
- s(null);
106
- }, []);
107
- return {
108
- hoveredColumn: l,
109
- hoveredRow: t,
110
- handleColumnMouseEnter: o,
111
- handleColumnMouseLeave: c,
112
- handleRowMouseEnter: _,
113
- handleRowMouseLeave: i
114
- };
115
- }, Le = ({
116
- primaryColumns: l,
117
- fixedColumns: a,
118
- expandedRowIds: t,
119
- onToggleRowExpansion: s
120
- }) => {
121
- const [o, c] = L(/* @__PURE__ */ new Set());
122
- R(() => {
123
- const n = [
124
- ...l.map((y) => y.key),
125
- ...a.map((y) => y.key)
126
- ], d = /* @__PURE__ */ new Set();
127
- t.forEach((y) => {
128
- n.forEach((b) => {
129
- d.add(`${y}-${b}`);
130
- });
131
- }), c((y) => {
132
- if (y.size === d.size) {
133
- let b = !0;
134
- if (y.forEach((u) => {
135
- d.has(u) || (b = !1);
136
- }), b)
137
- return y;
138
- }
139
- return d;
140
- });
141
- }, [t, l, a]);
142
- const _ = C(
143
- (n) => {
144
- const d = new Set(o), y = t.includes(n), b = [
145
- ...l.map((u) => u.key),
146
- ...a.map((u) => u.key)
147
- ];
148
- y ? b.forEach((u) => {
149
- const v = `${n}-${u}`;
150
- d.delete(v);
151
- }) : b.forEach((u) => {
152
- const v = `${n}-${u}`;
153
- d.add(v);
154
- }), c(d), s(n);
155
- },
156
- [o, t, l, a, s]
157
- ), i = C(
158
- (n, d) => {
159
- const y = `${n}-${d}`;
160
- return o.has(y);
161
- },
162
- [o]
163
- );
164
- return {
165
- expandedCells: o,
166
- handleToggleRowExpansion: _,
167
- isCellExpanded: i
168
- };
169
- }, We = () => {
170
- const l = F(/* @__PURE__ */ new Map()), a = C(
171
- (t) => (s) => {
172
- if (!s)
173
- return;
174
- const o = s.getBoundingClientRect().width;
175
- o > 0 && l.current.set(t, o);
176
- },
177
- []
178
- );
179
- return {
180
- columnWidthsRef: l,
181
- setCellRef: a
182
- };
183
- }, h = ke.bind(Ne), V = ({ column: l }) => {
184
- const a = F(null), [t, s] = L(!1);
185
- return R(() => {
186
- if (a.current) {
187
- const o = a.current.offsetWidth, c = a.current.scrollWidth;
188
- s(c > o);
189
- }
190
- }, [l.header]), /* @__PURE__ */ r("span", { ref: a, title: t ? l.header : void 0, children: l.header });
191
- }, Be = ({
192
- data: l,
193
- primaryColumn: a,
194
- fixedColumns: t,
195
- renderRowActions: s,
196
- className: o = "",
197
- rowClassName: c = "",
198
- headerClassName: _ = "",
199
- selectable: i = !1,
200
- selectedRowIds: n = [],
201
- sortingDirection: d = I,
202
- sortingColumn: y,
203
- sortableColumns: b,
204
- isHeaderFixed: u = !1,
205
- isHorizontallyScrollable: v = !1,
206
- pinnedColumnKeys: le = [],
207
- isRowsExpandable: f = !1,
208
- expandedRowIds: N = [],
209
- onChangeSorting: ne = () => {
210
- },
211
- onToggleRowSelection: ae = () => {
212
- },
213
- onToggleAllRowsSelection: te = () => {
214
- },
215
- onToggleRowExpansion: se = () => {
216
- },
217
- onToggleAllRowsExpansion: re = () => {
218
- }
219
- }) => {
220
- const E = Z(
221
- () => Array.isArray(a) ? a : [a],
222
- [a]
223
- ), m = y ?? E[0], M = b ?? $e([...E, ...t]), { pinnedColumns: k, scrollableColumns: $ } = ze({
224
- primaryColumns: E,
225
- fixedColumns: t,
226
- pinnedColumnKeys: le
227
- }), {
228
- hoveredColumn: P,
229
- hoveredRow: ce,
230
- handleColumnMouseEnter: U,
231
- handleColumnMouseLeave: O,
232
- handleRowMouseEnter: oe,
233
- handleRowMouseLeave: ie
234
- } = Ae(), { columnWidthsRef: T, setCellRef: j } = We(), { handleToggleRowExpansion: de, isCellExpanded: B } = Le({
235
- primaryColumns: E,
236
- fixedColumns: t,
237
- expandedRowIds: N,
238
- onToggleRowExpansion: se
239
- }), H = (e) => {
240
- M.includes(e) && ne({ key: e, direction: d });
241
- }, he = (e) => {
242
- ae(e);
243
- }, _e = () => {
244
- te();
245
- }, ye = () => {
246
- re();
247
- }, G = (e) => M.includes(e) ? (m == null ? void 0 : m.key) === e ? Me(d) ? /* @__PURE__ */ r(q, {}) : /* @__PURE__ */ r(ve, {}) : /* @__PURE__ */ r(q, {}) : null, pe = l.every((e) => n.includes(e.id)), ue = l.some((e) => n.includes(e.id)), X = (n == null ? void 0 : n.length) > 0, fe = l.every((e) => N.includes(e.id)), be = Q(
248
- k,
249
- $,
250
- f,
251
- i,
252
- !!s,
253
- !1
254
- ), me = Q(
255
- k,
256
- $,
257
- f,
258
- i,
259
- !!s,
260
- !0
261
- );
262
- return /* @__PURE__ */ w(
263
- "div",
264
- {
265
- className: h(
266
- "table",
267
- {
268
- "fixed-header": u,
269
- "horizontally-scrollable-container": u && v
270
- },
271
- o
272
- ),
273
- children: [
274
- /* @__PURE__ */ w(
275
- "div",
276
- {
277
- className: h(
278
- "table-header",
279
- {
280
- "sticky-header": u,
281
- "horizontally-scrollable": v
282
- },
283
- _
284
- ),
285
- style: { gridTemplateColumns: me },
286
- children: [
287
- i && /* @__PURE__ */ r(
288
- "div",
289
- {
290
- className: h("table-header-cell", "checkbox-cell"),
291
- style: { left: f ? `${x}px` : "0" },
292
- children: X && /* @__PURE__ */ r(
293
- J,
294
- {
295
- value: pe,
296
- partiallyChecked: ue,
297
- onChange: _e,
298
- className: h("checkbox-cell")
299
- }
300
- )
301
- }
302
- ),
303
- f && /* @__PURE__ */ r("div", { className: h("table-header-cell", "expand-cell"), style: { left: "0" }, children: /* @__PURE__ */ r("button", { onClick: ye, "aria-label": "Toggle all rows expansion", children: /* @__PURE__ */ r("span", { className: h("expand-icon", { expanded: fe }), children: /* @__PURE__ */ r(Y, {}) }) }) }),
304
- k.map((e, S) => /* @__PURE__ */ r(
305
- "button",
306
- {
307
- className: h("table-header-cell", "pinned-column", {
308
- [`align-${e.align}`]: "align" in e,
309
- "primary-cell": g(e),
310
- "sortable-cell": M.includes(e.key)
311
- }),
312
- style: A(
313
- e,
314
- !0,
315
- S,
316
- k,
317
- T,
318
- f,
319
- i
320
- ),
321
- children: /* @__PURE__ */ w(
322
- "div",
323
- {
324
- className: h("label"),
325
- onClick: () => H(e.key),
326
- onMouseEnter: () => U(e.key),
327
- onMouseLeave: O,
328
- children: [
329
- /* @__PURE__ */ r(V, { column: e }),
330
- (P === e.key || (m == null ? void 0 : m.key) === e.key) && G(e.key)
331
- ]
332
- }
333
- )
334
- },
335
- e.key
336
- )),
337
- $.map((e) => /* @__PURE__ */ r(
338
- "button",
339
- {
340
- className: h("table-header-cell", {
341
- [`align-${e.align}`]: "align" in e,
342
- "primary-cell": g(e),
343
- "sortable-cell": M.includes(e.key)
344
- }),
345
- style: A(
346
- e,
347
- !1,
348
- void 0,
349
- k,
350
- T,
351
- f,
352
- i
353
- ),
354
- children: /* @__PURE__ */ w(
355
- "div",
356
- {
357
- className: h("label"),
358
- onClick: () => H(e.key),
359
- onMouseEnter: () => U(e.key),
360
- onMouseLeave: O,
361
- children: [
362
- /* @__PURE__ */ r(V, { column: e }),
363
- (P === e.key || (m == null ? void 0 : m.key) === e.key) && G(e.key)
364
- ]
365
- }
366
- )
367
- },
368
- e.key
369
- )),
370
- s && /* @__PURE__ */ r("div", { className: h("table-header-cell", "action-menu-cell") })
371
- ]
372
- }
373
- ),
374
- /* @__PURE__ */ r(
375
- "div",
376
- {
377
- className: h("table-body", {
378
- "scrollable-body": u,
379
- "horizontally-scrollable": v
380
- }),
381
- children: l.map((e, S) => /* @__PURE__ */ w(
382
- "div",
383
- {
384
- className: h("table-row", Te(e), c, {
385
- selectable: i
386
- }),
387
- onMouseEnter: () => oe(S),
388
- onMouseLeave: ie,
389
- children: [
390
- i && /* @__PURE__ */ r(
391
- "div",
392
- {
393
- className: h("table-cell", "checkbox-cell"),
394
- style: { left: f ? `${x}px` : "0" },
395
- children: (X || ce === S) && /* @__PURE__ */ r(
396
- J,
397
- {
398
- value: n.includes(e.id),
399
- onChange: () => he(e.id),
400
- className: h("checkbox-cell")
401
- }
402
- )
403
- }
404
- ),
405
- /* @__PURE__ */ r("div", { className: h("row-content-wrapper"), children: /* @__PURE__ */ w("div", { className: h("table-row-content"), style: { gridTemplateColumns: be }, children: [
406
- f && /* @__PURE__ */ r("div", { className: h("table-cell", "expand-cell"), style: { left: "0" }, children: /* @__PURE__ */ r(
407
- "button",
408
- {
409
- onClick: () => de(e.id),
410
- "aria-label": N.includes(e.id) ? "Collapse row" : "Expand row",
411
- "aria-expanded": N.includes(e.id),
412
- children: /* @__PURE__ */ r(
413
- "span",
414
- {
415
- className: h("expand-icon", {
416
- expanded: N.includes(e.id)
417
- }),
418
- children: /* @__PURE__ */ r(Y, {})
419
- }
420
- )
421
- }
422
- ) }),
423
- k.map((p, W) => {
424
- const z = B(e.id, p.key), K = g(p);
425
- return /* @__PURE__ */ r(
426
- "div",
427
- {
428
- ref: K ? j(p.key) : void 0,
429
- className: h("table-cell", "pinned-column", {
430
- "primary-cell": K,
431
- "expanded-cell": z
432
- }),
433
- style: A(
434
- p,
435
- !0,
436
- W,
437
- k,
438
- T,
439
- f,
440
- i
441
- ),
442
- children: e[p.key].component || e[p.key].content || e[p.key]
443
- },
444
- p.key
445
- );
446
- }),
447
- $.map((p) => {
448
- const W = B(e.id, p.key), z = g(p);
449
- return /* @__PURE__ */ r(
450
- "div",
451
- {
452
- ref: z ? j(p.key) : void 0,
453
- className: h("table-cell", {
454
- "primary-cell": z,
455
- "expanded-cell": W
456
- }),
457
- style: A(
458
- p,
459
- !1,
460
- void 0,
461
- k,
462
- T,
463
- f,
464
- i
465
- ),
466
- children: e[p.key].component || e[p.key].content || e[p.key]
467
- },
468
- p.key
469
- );
470
- }),
471
- s && /* @__PURE__ */ r("div", { className: h("table-cell", "action-menu-cell"), children: s(e.metaData) })
472
- ] }) })
473
- ]
474
- },
475
- e.id
476
- ))
477
- }
478
- )
479
- ]
480
- }
481
- );
482
- };
483
- export {
484
- Be as T
485
- };