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