@reportportal/ui-kit 0.0.1-alpha.147 → 0.0.1-alpha.149

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,588 +0,0 @@
1
- import { jsx as o, jsxs as z } from "react/jsx-runtime";
2
- import { useMemo as se, useState as m, useCallback as w, useEffect as re, useRef as oe, forwardRef as Pe } from "react";
3
- import { Resizable as De } from "react-resizable";
4
- import { c as ce } from "./bind-06a7ff84.js";
5
- import { c as We, b as ee, a as le, S as Oe } from "./resizeColumn-d4107941.js";
6
- import { C as te } from "./checkbox-ed6cc375.js";
7
- import { Tooltip as Ue } from "./tooltip.js";
8
- const j = (l) => typeof l == "string", je = "_table_1244e_1", He = "_resizable_1244e_46", Be = "_selectable_1244e_63", Ge = "_expanded_1244e_59", Xe = "_label_1244e_303", Ye = {
9
- table: je,
10
- "fixed-header": "_fixed-header_1244e_8",
11
- "horizontally-scrollable-container": "_horizontally-scrollable-container_1244e_14",
12
- "table-header": "_table-header_1244e_19",
13
- "sticky-header": "_sticky-header_1244e_26",
14
- "horizontally-scrollable": "_horizontally-scrollable_1244e_14",
15
- resizable: He,
16
- "resizable-column": "_resizable-column_1244e_46",
17
- "table-row": "_table-row_1244e_54",
18
- "expanded-cell": "_expanded-cell_1244e_59",
19
- selectable: Be,
20
- "row-content-wrapper": "_row-content-wrapper_1244e_67",
21
- "table-row-content": "_table-row-content_1244e_75",
22
- "expand-cell": "_expand-cell_1244e_89",
23
- "size-small": "_size-small_1244e_92",
24
- "size-large": "_size-large_1244e_103",
25
- "table-body": "_table-body_1244e_115",
26
- "scrollable-body": "_scrollable-body_1244e_121",
27
- "table-header-cell": "_table-header-cell_1244e_181",
28
- "table-cell": "_table-cell_1244e_182",
29
- "action-menu-cell": "_action-menu-cell_1244e_188",
30
- "checkbox-cell": "_checkbox-cell_1244e_213",
31
- "expand-all-tooltip-wrapper": "_expand-all-tooltip-wrapper_1244e_255",
32
- "expand-all-tooltip-content": "_expand-all-tooltip-content_1244e_264",
33
- "expand-icon": "_expand-icon_1244e_273",
34
- expanded: Ge,
35
- "primary-cell": "_primary-cell_1244e_282",
36
- label: Xe,
37
- "sortable-cell": "_sortable-cell_1244e_317",
38
- "align-right": "_align-right_1244e_320",
39
- "align-center": "_align-center_1244e_326",
40
- "pinned-column": "_pinned-column_1244e_329"
41
- }, ie = "asc", S = 32, de = 100, qe = 48, Je = (l) => l.toLowerCase() === ie, Qe = (l) => l.map((n) => n.key), N = (l) => "primary" in l && l.primary === !0, Ve = (l) => {
42
- var r;
43
- return `size-${((r = l.rowConfigs) == null ? void 0 : r.size) ?? "default"}`;
44
- }, Ze = (l, n, r, c, i) => {
45
- let s = 0;
46
- c && (s += S), i && (s += S);
47
- for (let _ = 0; _ < l; _++) {
48
- const p = n[_];
49
- if (N(p)) {
50
- const t = r.current.get(p.key) || de;
51
- s += t;
52
- } else {
53
- const t = p, d = j(t.width) ? parseInt(t.width, 10) || 0 : t.width;
54
- s += d;
55
- }
56
- }
57
- return s;
58
- }, D = (l, n, r, c, i, s, _) => {
59
- const p = {};
60
- if (!N(l)) {
61
- const t = l;
62
- p.textAlign = t.align;
63
- }
64
- if (n && r !== void 0) {
65
- const t = Ze(
66
- r,
67
- c,
68
- i,
69
- s,
70
- _
71
- );
72
- p.left = `${t}px`;
73
- }
74
- return p;
75
- }, ne = (l, n, r, c, i, s = !1, _) => {
76
- const p = [];
77
- r && p.push(`${S}px`), s && c && p.push(`${S}px`);
78
- const t = (d) => {
79
- if ((_ == null ? void 0 : _[d.key]) !== void 0) {
80
- p.push(`${_[d.key]}px`);
81
- return;
82
- }
83
- if (N(d)) {
84
- const a = d, f = a.width ? j(a.width) ? a.width : `${a.width}px` : `${de}px`;
85
- p.push(`minmax(${f}, 1fr)`);
86
- } else {
87
- const a = d, f = j(a.width) ? a.width : `${a.width}px`;
88
- p.push(f);
89
- }
90
- };
91
- return l.forEach(t), n.forEach(t), i && p.push(`${qe}px`), p.join(" ");
92
- }, Ke = ({
93
- primaryColumns: l,
94
- fixedColumns: n,
95
- pinnedColumnKeys: r
96
- }) => se(() => {
97
- const c = [], i = [];
98
- return l.forEach((s) => {
99
- const _ = { ...s, primary: !0 };
100
- r.includes(s.key) ? c.push(_) : i.push(_);
101
- }), n.forEach((s) => {
102
- r.includes(s.key) ? c.push(s) : i.push(s);
103
- }), {
104
- pinnedColumns: c,
105
- scrollableColumns: i
106
- };
107
- }, [l, n, r]), Fe = () => {
108
- const [l, n] = m(null), [r, c] = m(null), i = w((t) => {
109
- n(t);
110
- }, []), s = w(() => {
111
- n(null);
112
- }, []), _ = w((t) => {
113
- c(t);
114
- }, []), p = w(() => {
115
- c(null);
116
- }, []);
117
- return {
118
- hoveredColumn: l,
119
- hoveredRow: r,
120
- handleColumnMouseEnter: i,
121
- handleColumnMouseLeave: s,
122
- handleRowMouseEnter: _,
123
- handleRowMouseLeave: p
124
- };
125
- }, Re = ({
126
- primaryColumns: l,
127
- fixedColumns: n,
128
- expandedRowIds: r,
129
- onToggleRowExpansion: c
130
- }) => {
131
- const [i, s] = m(/* @__PURE__ */ new Set());
132
- re(() => {
133
- const t = [
134
- ...l.map((a) => a.key),
135
- ...n.map((a) => a.key)
136
- ], d = /* @__PURE__ */ new Set();
137
- r.forEach((a) => {
138
- t.forEach((f) => {
139
- d.add(`${a}-${f}`);
140
- });
141
- }), s((a) => {
142
- if (a.size === d.size) {
143
- let f = !0;
144
- if (a.forEach((b) => {
145
- d.has(b) || (f = !1);
146
- }), f)
147
- return a;
148
- }
149
- return d;
150
- });
151
- }, [r, l, n]);
152
- const _ = w(
153
- (t) => {
154
- const d = new Set(i), a = r.includes(t), f = [
155
- ...l.map((b) => b.key),
156
- ...n.map((b) => b.key)
157
- ];
158
- a ? f.forEach((b) => {
159
- const u = `${t}-${b}`;
160
- d.delete(u);
161
- }) : f.forEach((b) => {
162
- const u = `${t}-${b}`;
163
- d.add(u);
164
- }), s(d), c(t);
165
- },
166
- [i, r, l, n, c]
167
- ), p = w(
168
- (t, d) => {
169
- const a = `${t}-${d}`;
170
- return i.has(a);
171
- },
172
- [i]
173
- );
174
- return {
175
- expandedCells: i,
176
- handleToggleRowExpansion: _,
177
- isCellExpanded: p
178
- };
179
- }, Ie = () => {
180
- const l = oe(/* @__PURE__ */ new Map()), n = w(
181
- (r) => (c) => {
182
- if (!c)
183
- return;
184
- const i = c.getBoundingClientRect().width;
185
- i > 0 && l.current.set(r, i);
186
- },
187
- []
188
- );
189
- return {
190
- columnWidthsRef: l,
191
- setCellRef: n
192
- };
193
- }, el = ({
194
- enabled: l = !1,
195
- minWidth: n = 50,
196
- maxWidth: r = 500,
197
- columnWidthsRef: c,
198
- onColumnResize: i
199
- }) => {
200
- const [s, _] = m({}), p = w(() => {
201
- if (!l || Object.keys(s).length > 0 || !c)
202
- return;
203
- const a = {};
204
- c.current.forEach((f, b) => {
205
- a[b] = f;
206
- }), _(a);
207
- }, [l, s, c]), t = w(
208
- (a) => (f, { size: b }) => {
209
- if (!l)
210
- return;
211
- const u = Math.min(r, Math.max(n, b.width));
212
- _((E) => ({ ...E, [a]: u }));
213
- },
214
- [l, n, r]
215
- ), d = w(
216
- (a) => () => {
217
- !l || !s[a] || i == null || i(a, s[a]);
218
- },
219
- [l, s, i]
220
- );
221
- return {
222
- columnWidths: s,
223
- handleResize: t,
224
- handleResizeStop: d,
225
- handleResizeStart: p
226
- };
227
- }, ll = {
228
- "resize-handle": "_resize-handle_15uk3_1"
229
- }, tl = ce.bind(ll), nl = Pe(
230
- (l, n) => /* @__PURE__ */ o("div", { ref: n, className: tl("resize-handle"), ...l, children: /* @__PURE__ */ o(We, {}) })
231
- ), h = ce.bind(Ye), ae = ({ column: l }) => {
232
- const n = oe(null), [r, c] = m(!1);
233
- return re(() => {
234
- if (n.current) {
235
- const i = n.current.offsetWidth, s = n.current.scrollWidth;
236
- c(s > i);
237
- }
238
- }, [l.header]), /* @__PURE__ */ o("span", { ref: n, title: r ? l.header : void 0, children: l.header });
239
- }, hl = ({
240
- data: l,
241
- primaryColumn: n,
242
- fixedColumns: r,
243
- renderRowActions: c,
244
- className: i = "",
245
- rowClassName: s = "",
246
- headerClassName: _ = "",
247
- bodyClassName: p = "",
248
- selectable: t = !1,
249
- selectedRowIds: d = [],
250
- sortingDirection: a = ie,
251
- sortingColumn: f,
252
- sortableColumns: b,
253
- isHeaderFixed: u = !1,
254
- isHorizontallyScrollable: E = !1,
255
- pinnedColumnKeys: he = [],
256
- isRowsExpandable: k = !1,
257
- expandedRowIds: $ = [],
258
- isAllExpandedByDefault: H,
259
- expandAllTooltip: B,
260
- isResizable: v = !1,
261
- minColumnWidth: W = 50,
262
- maxColumnWidth: G = 500,
263
- onChangeSorting: pe = () => {
264
- },
265
- onToggleRowSelection: _e = () => {
266
- },
267
- onToggleAllRowsSelection: ye = () => {
268
- },
269
- onToggleRowExpansion: fe = () => {
270
- },
271
- onToggleAllRowsExpansion: be = () => {
272
- },
273
- onColumnResize: ue = () => {
274
- }
275
- }) => {
276
- const T = se(
277
- () => Array.isArray(n) ? n : [n],
278
- [n]
279
- ), x = f ?? T[0], A = b ?? Qe([...T, ...r]), { pinnedColumns: g, scrollableColumns: L } = Ke({
280
- primaryColumns: T,
281
- fixedColumns: r,
282
- pinnedColumnKeys: he
283
- }), {
284
- hoveredColumn: X,
285
- hoveredRow: ke,
286
- handleColumnMouseEnter: Y,
287
- handleColumnMouseLeave: q,
288
- handleRowMouseEnter: ve,
289
- handleRowMouseLeave: we
290
- } = Fe(), { columnWidthsRef: M, setCellRef: J } = Ie(), { handleToggleRowExpansion: xe, isCellExpanded: Q } = Re({
291
- primaryColumns: T,
292
- fixedColumns: r,
293
- expandedRowIds: $,
294
- onToggleRowExpansion: fe
295
- }), { columnWidths: O, handleResize: Ce, handleResizeStop: ge, handleResizeStart: Ne } = el({
296
- enabled: v,
297
- minWidth: W,
298
- maxWidth: G,
299
- columnWidthsRef: M,
300
- onColumnResize: ue
301
- }), V = (e, C) => /* @__PURE__ */ o(
302
- De,
303
- {
304
- width: O[e.key] ?? (typeof e.width == "number" ? e.width : W),
305
- height: 0,
306
- axis: "x",
307
- handle: /* @__PURE__ */ o(nl, {}),
308
- onResizeStart: Ne,
309
- onResize: Ce(e.key),
310
- onResizeStop: ge(e.key),
311
- minConstraints: [W, 0],
312
- maxConstraints: [G, 0],
313
- className: h("resizable-column"),
314
- children: C
315
- },
316
- e.key
317
- ), Z = (e) => {
318
- A.includes(e) && pe({ key: e, direction: a });
319
- }, ze = (e) => {
320
- _e(e);
321
- }, Se = () => {
322
- ye();
323
- }, Ee = () => {
324
- be();
325
- }, K = (e) => A.includes(e) ? (x == null ? void 0 : x.key) === e ? Je(a) ? /* @__PURE__ */ o(le, {}) : /* @__PURE__ */ o(Oe, {}) : /* @__PURE__ */ o(le, {}) : null, $e = l.every((e) => d.includes(e.id)), Me = l.some((e) => d.includes(e.id)), F = (d == null ? void 0 : d.length) > 0, me = l.every((e) => $.includes(e.id)), Te = H !== void 0 ? H : me, Ae = ne(
326
- g,
327
- L,
328
- k,
329
- t,
330
- !!c,
331
- !1,
332
- v ? O : void 0
333
- ), Le = ne(
334
- g,
335
- L,
336
- k,
337
- t,
338
- !!c,
339
- !0,
340
- v ? O : void 0
341
- ), R = /* @__PURE__ */ o("button", { onClick: Ee, "aria-label": "Toggle all rows expansion", children: /* @__PURE__ */ o("span", { className: h("expand-icon", { expanded: Te }), children: /* @__PURE__ */ o(ee, {}) }) });
342
- return /* @__PURE__ */ z(
343
- "div",
344
- {
345
- className: h(
346
- "table",
347
- {
348
- "fixed-header": u,
349
- "horizontally-scrollable-container": u && (E || v)
350
- },
351
- i
352
- ),
353
- children: [
354
- /* @__PURE__ */ z(
355
- "div",
356
- {
357
- className: h(
358
- "table-header",
359
- {
360
- "sticky-header": u,
361
- "horizontally-scrollable": E,
362
- resizable: v
363
- },
364
- _
365
- ),
366
- style: { gridTemplateColumns: Le },
367
- children: [
368
- t && /* @__PURE__ */ o(
369
- "div",
370
- {
371
- className: h("table-header-cell", "checkbox-cell"),
372
- style: { left: k ? `${S}px` : "0" },
373
- children: F && /* @__PURE__ */ o(
374
- te,
375
- {
376
- value: $e,
377
- partiallyChecked: Me,
378
- onChange: Se,
379
- className: h("checkbox-cell")
380
- }
381
- )
382
- }
383
- ),
384
- k && /* @__PURE__ */ o("div", { className: h("table-header-cell", "expand-cell"), style: { left: "0" }, children: B ? /* @__PURE__ */ o(
385
- Ue,
386
- {
387
- content: B,
388
- placement: "top",
389
- wrapperClassName: h("expand-all-tooltip-wrapper"),
390
- contentClassName: h("expand-all-tooltip-content"),
391
- children: R
392
- }
393
- ) : R }),
394
- g.map((e, C) => {
395
- const y = /* @__PURE__ */ o(
396
- "button",
397
- {
398
- className: h("table-header-cell", "pinned-column", {
399
- [`align-${e.align}`]: "align" in e,
400
- "primary-cell": N(e),
401
- "sortable-cell": A.includes(e.key),
402
- resizable: v
403
- }),
404
- style: D(
405
- e,
406
- !0,
407
- C,
408
- g,
409
- M,
410
- k,
411
- t
412
- ),
413
- children: /* @__PURE__ */ z(
414
- "div",
415
- {
416
- className: h("label"),
417
- onClick: () => Z(e.key),
418
- onMouseEnter: () => Y(e.key),
419
- onMouseLeave: q,
420
- children: [
421
- /* @__PURE__ */ o(ae, { column: e }),
422
- (X === e.key || (x == null ? void 0 : x.key) === e.key) && K(e.key)
423
- ]
424
- }
425
- )
426
- },
427
- e.key
428
- );
429
- return v ? V(e, y) : y;
430
- }),
431
- L.map((e) => {
432
- const C = /* @__PURE__ */ o(
433
- "button",
434
- {
435
- className: h("table-header-cell", {
436
- [`align-${e.align}`]: "align" in e,
437
- "primary-cell": N(e),
438
- "sortable-cell": A.includes(e.key),
439
- resizable: v
440
- }),
441
- style: D(
442
- e,
443
- !1,
444
- void 0,
445
- g,
446
- M,
447
- k,
448
- t
449
- ),
450
- children: /* @__PURE__ */ z(
451
- "div",
452
- {
453
- className: h("label"),
454
- onClick: () => Z(e.key),
455
- onMouseEnter: () => Y(e.key),
456
- onMouseLeave: q,
457
- children: [
458
- /* @__PURE__ */ o(ae, { column: e }),
459
- (X === e.key || (x == null ? void 0 : x.key) === e.key) && K(e.key)
460
- ]
461
- }
462
- )
463
- },
464
- e.key
465
- );
466
- return v ? V(e, C) : C;
467
- }),
468
- c && /* @__PURE__ */ o("div", { className: h("table-header-cell", "action-menu-cell") })
469
- ]
470
- }
471
- ),
472
- /* @__PURE__ */ o(
473
- "div",
474
- {
475
- className: h(
476
- "table-body",
477
- {
478
- "scrollable-body": u,
479
- "horizontally-scrollable": E,
480
- resizable: v
481
- },
482
- p
483
- ),
484
- children: l.map((e, C) => /* @__PURE__ */ z(
485
- "div",
486
- {
487
- className: h("table-row", Ve(e), s, {
488
- selectable: t
489
- }),
490
- onMouseEnter: () => ve(C),
491
- onMouseLeave: we,
492
- children: [
493
- t && /* @__PURE__ */ o(
494
- "div",
495
- {
496
- className: h("table-cell", "checkbox-cell"),
497
- style: { left: k ? `${S}px` : "0" },
498
- children: (F || ke === C) && /* @__PURE__ */ o(
499
- te,
500
- {
501
- value: d.includes(e.id),
502
- onChange: () => ze(e.id),
503
- className: h("checkbox-cell")
504
- }
505
- )
506
- }
507
- ),
508
- /* @__PURE__ */ o("div", { className: h("row-content-wrapper"), children: /* @__PURE__ */ z("div", { className: h("table-row-content"), style: { gridTemplateColumns: Ae }, children: [
509
- k && /* @__PURE__ */ o("div", { className: h("table-cell", "expand-cell"), style: { left: "0" }, children: /* @__PURE__ */ o(
510
- "button",
511
- {
512
- onClick: () => xe(e.id),
513
- "aria-label": $.includes(e.id) ? "Collapse row" : "Expand row",
514
- "aria-expanded": $.includes(e.id),
515
- children: /* @__PURE__ */ o(
516
- "span",
517
- {
518
- className: h("expand-icon", {
519
- expanded: $.includes(e.id)
520
- }),
521
- children: /* @__PURE__ */ o(ee, {})
522
- }
523
- )
524
- }
525
- ) }),
526
- g.map((y, U) => {
527
- const P = Q(e.id, y.key), I = N(y);
528
- return /* @__PURE__ */ o(
529
- "div",
530
- {
531
- ref: I ? J(y.key) : void 0,
532
- className: h("table-cell", "pinned-column", {
533
- "primary-cell": I,
534
- "expanded-cell": P
535
- }),
536
- style: D(
537
- y,
538
- !0,
539
- U,
540
- g,
541
- M,
542
- k,
543
- t
544
- ),
545
- children: e[y.key].component || e[y.key].content || e[y.key]
546
- },
547
- y.key
548
- );
549
- }),
550
- L.map((y) => {
551
- const U = Q(e.id, y.key), P = N(y);
552
- return /* @__PURE__ */ o(
553
- "div",
554
- {
555
- ref: P ? J(y.key) : void 0,
556
- className: h("table-cell", {
557
- "primary-cell": P,
558
- "expanded-cell": U
559
- }),
560
- style: D(
561
- y,
562
- !1,
563
- void 0,
564
- g,
565
- M,
566
- k,
567
- t
568
- ),
569
- children: e[y.key].component || e[y.key].content || e[y.key]
570
- },
571
- y.key
572
- );
573
- }),
574
- c && /* @__PURE__ */ o("div", { className: h("table-cell", "action-menu-cell"), children: c(e.metaData) })
575
- ] }) })
576
- ]
577
- },
578
- e.id
579
- ))
580
- }
581
- )
582
- ]
583
- }
584
- );
585
- };
586
- export {
587
- hl as T
588
- };