@reportportal/ui-kit 0.0.1-alpha.139 → 0.0.1-alpha.140

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