@reportportal/ui-kit 0.0.1-alpha.162 → 0.0.1-alpha.163

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,1073 +0,0 @@
1
- import { jsx as h, jsxs as q, Fragment as Nt } from "react/jsx-runtime";
2
- import { useMemo as de, useState as S, useCallback as z, useEffect as B, useRef as W, useLayoutEffect as et, forwardRef as zt } from "react";
3
- import { Resizable as At } from "react-resizable";
4
- import { c as we } from "./bind-06a7ff84.js";
5
- import { b as $t, a as Ye, S as Mt } from "./resizeColumn-46b5b30f.js";
6
- import { S as Je } from "./chevronDownDropdown-0260bb66.js";
7
- import { C as ie } from "./checkbox-493fdc63.js";
8
- import { Tooltip as Wt } from "./tooltip.js";
9
- import { createPortal as Ht } from "react-dom";
10
- import { i as Pt } from "./isEmpty-ccacb5ff.js";
11
- const tt = (t) => typeof t == "string", Bt = "_table_1rtld_1", St = "_resizable_1rtld_67", Gt = "_selectable_1rtld_84", Ft = "_expanded_1rtld_80", qt = "_label_1rtld_353", Ut = {
12
- table: Bt,
13
- "fixed-header": "_fixed-header_1rtld_10",
14
- "external-scroll-container": "_external-scroll-container_1rtld_14",
15
- "horizontally-scrollable-container": "_horizontally-scrollable-container_1rtld_21",
16
- "table-header": "_table-header_1rtld_26",
17
- "sticky-header": "_sticky-header_1rtld_34",
18
- "pinned-header": "_pinned-header_1rtld_44",
19
- "horizontally-scrollable": "_horizontally-scrollable_1rtld_21",
20
- resizable: St,
21
- "resizable-column": "_resizable-column_1rtld_67",
22
- "table-row": "_table-row_1rtld_75",
23
- "expanded-cell": "_expanded-cell_1rtld_80",
24
- selectable: Gt,
25
- "row-content-wrapper": "_row-content-wrapper_1rtld_88",
26
- "pinned-column": "_pinned-column_1rtld_96",
27
- "has-scroll": "_has-scroll_1rtld_96",
28
- "table-row-content": "_table-row-content_1rtld_99",
29
- "expand-cell": "_expand-cell_1rtld_116",
30
- "left-border-accent": "_left-border-accent_1rtld_119",
31
- "size-small": "_size-small_1rtld_129",
32
- "size-large": "_size-large_1rtld_140",
33
- "table-body": "_table-body_1rtld_152",
34
- "scrollable-body": "_scrollable-body_1rtld_158",
35
- "table-header-cell": "_table-header-cell_1rtld_222",
36
- "table-cell": "_table-cell_1rtld_223",
37
- "action-menu-cell": "_action-menu-cell_1rtld_229",
38
- "checkbox-cell": "_checkbox-cell_1rtld_257",
39
- "expand-all-tooltip-wrapper": "_expand-all-tooltip-wrapper_1rtld_302",
40
- "expand-all-tooltip-content": "_expand-all-tooltip-content_1rtld_311",
41
- "expand-icon": "_expand-icon_1rtld_320",
42
- expanded: Ft,
43
- "primary-cell": "_primary-cell_1rtld_329",
44
- label: qt,
45
- "sortable-cell": "_sortable-cell_1rtld_367",
46
- "align-right": "_align-right_1rtld_370",
47
- "align-center": "_align-center_1rtld_376",
48
- "table-wrapper": "_table-wrapper_1rtld_430",
49
- "checkbox-column": "_checkbox-column_1rtld_442",
50
- "checkbox-header": "_checkbox-header_1rtld_454",
51
- "checkbox-body": "_checkbox-body_1rtld_478",
52
- "checkbox-row": "_checkbox-row_1rtld_485"
53
- }, nt = "asc", C = 32, rt = 100, Dt = 48, me = 48, Xt = (t) => t.toLowerCase() === nt, jt = (t) => t.map((c) => c.key), V = (t) => "primary" in t && t.primary === !0, Qe = (t) => {
54
- var o;
55
- return `size-${((o = t.rowConfigs) == null ? void 0 : o.size) ?? "default"}`;
56
- }, ye = (t) => tt(t) ? t : `${t}px`, It = (t, c, o, l, p, _ = !1) => {
57
- let d = 0;
58
- l && (d += C), p && !_ && (d += C);
59
- for (let b = 0; b < t; b++) {
60
- const i = c[b];
61
- if (V(i)) {
62
- const r = o.current.get(i.key) || rt;
63
- d += r;
64
- } else {
65
- const r = i, a = tt(r.width) ? parseInt(r.width, 10) || 0 : r.width;
66
- d += a;
67
- }
68
- }
69
- return d;
70
- }, ae = (t, c, o, l, p, _, d, b = !1) => {
71
- const i = {};
72
- if (!V(t)) {
73
- const r = t;
74
- i.textAlign = r.align;
75
- }
76
- if (c && o !== void 0) {
77
- const r = It(
78
- o,
79
- l,
80
- p,
81
- _,
82
- d,
83
- b
84
- );
85
- i.left = `${r}px`;
86
- }
87
- return i;
88
- }, Ze = (t, c, o, l, p, _ = !1, d, b = !1, i = !1) => {
89
- const r = [];
90
- o && r.push(`${C}px`), _ && l && !i && r.push(`${C}px`);
91
- const a = (v) => {
92
- if ((d == null ? void 0 : d[v.key]) !== void 0) {
93
- r.push(`${d[v.key]}px`);
94
- return;
95
- }
96
- if (V(v)) {
97
- const f = v;
98
- if (b && f.width) {
99
- r.push(ye(f.width));
100
- return;
101
- }
102
- const y = f.width ? ye(f.width) : `${rt}px`;
103
- r.push(`minmax(${y}, 1fr)`);
104
- } else {
105
- const y = ye(v.width);
106
- r.push(y);
107
- }
108
- };
109
- return t.forEach(a), c.forEach(a), p && r.push(`${Dt}px`), r.join(" ");
110
- }, Rt = ({
111
- primaryColumns: t,
112
- fixedColumns: c,
113
- pinnedColumnKeys: o
114
- }) => de(() => {
115
- const l = [], p = [];
116
- return t.forEach((_) => {
117
- const d = { ..._, primary: !0 };
118
- o.includes(_.key) ? l.push(d) : p.push(d);
119
- }), c.forEach((_) => {
120
- o.includes(_.key) ? l.push(_) : p.push(_);
121
- }), {
122
- pinnedColumns: l,
123
- scrollableColumns: p
124
- };
125
- }, [t, c, o]), Vt = () => {
126
- const [t, c] = S(null), [o, l] = S(null), p = z((i) => {
127
- c(i);
128
- }, []), _ = z(() => {
129
- c(null);
130
- }, []), d = z((i) => {
131
- l(i);
132
- }, []), b = z(() => {
133
- l(null);
134
- }, []);
135
- return {
136
- hoveredColumn: t,
137
- hoveredRow: o,
138
- handleColumnMouseEnter: p,
139
- handleColumnMouseLeave: _,
140
- handleRowMouseEnter: d,
141
- handleRowMouseLeave: b
142
- };
143
- }, Ct = ({
144
- primaryColumns: t,
145
- fixedColumns: c,
146
- expandedRowIds: o,
147
- onToggleRowExpansion: l
148
- }) => {
149
- const [p, _] = S(/* @__PURE__ */ new Set());
150
- B(() => {
151
- const i = [
152
- ...t.map((a) => a.key),
153
- ...c.map((a) => a.key)
154
- ], r = /* @__PURE__ */ new Set();
155
- o.forEach((a) => {
156
- i.forEach((v) => {
157
- r.add(`${a}-${v}`);
158
- });
159
- }), _((a) => {
160
- if (a.size === r.size) {
161
- let v = !0;
162
- if (a.forEach((f) => {
163
- r.has(f) || (v = !1);
164
- }), v)
165
- return a;
166
- }
167
- return r;
168
- });
169
- }, [o, t, c]);
170
- const d = z(
171
- (i) => {
172
- const r = new Set(p), a = o.includes(i), v = [
173
- ...t.map((f) => f.key),
174
- ...c.map((f) => f.key)
175
- ];
176
- a ? v.forEach((f) => {
177
- const y = `${i}-${f}`;
178
- r.delete(y);
179
- }) : v.forEach((f) => {
180
- const y = `${i}-${f}`;
181
- r.add(y);
182
- }), _(r), l(i);
183
- },
184
- [p, o, t, c, l]
185
- ), b = z(
186
- (i, r) => {
187
- const a = `${i}-${r}`;
188
- return p.has(a);
189
- },
190
- [p]
191
- );
192
- return {
193
- expandedCells: p,
194
- handleToggleRowExpansion: d,
195
- isCellExpanded: b
196
- };
197
- }, Yt = () => {
198
- const t = W(/* @__PURE__ */ new Map()), c = z(
199
- (o) => (l) => {
200
- if (!l)
201
- return;
202
- const p = l.getBoundingClientRect().width;
203
- p > 0 && t.current.set(o, p);
204
- },
205
- []
206
- );
207
- return {
208
- columnWidthsRef: t,
209
- setCellRef: c
210
- };
211
- }, Jt = ({
212
- enabled: t = !1,
213
- minWidth: c = 50,
214
- maxWidth: o = 500,
215
- columns: l = [],
216
- columnWidthsRef: p,
217
- onColumnResize: _
218
- }) => {
219
- const [d, b] = S({}), i = z(
220
- (f) => {
221
- const y = l.find((T) => T.key === f);
222
- return {
223
- minWidth: (y == null ? void 0 : y.minWidth) ?? c,
224
- maxWidth: (y == null ? void 0 : y.maxWidth) ?? o
225
- };
226
- },
227
- [l, c, o]
228
- ), r = z(() => {
229
- if (!t || Object.keys(d).length > 0 || !p)
230
- return;
231
- const f = {};
232
- p.current.forEach((y, T) => {
233
- f[T] = y;
234
- }), b(f);
235
- }, [t, d, p]), a = z(
236
- (f) => (y, { size: T }) => {
237
- if (!t)
238
- return;
239
- const { minWidth: E, maxWidth: H } = i(f), x = Math.min(H, Math.max(E, T.width));
240
- b((A) => ({ ...A, [f]: x }));
241
- },
242
- [t, i]
243
- ), v = z(
244
- (f) => () => {
245
- !t || !d[f] || _ == null || _(f, d[f]);
246
- },
247
- [t, d, _]
248
- );
249
- return {
250
- columnWidths: d,
251
- handleResize: a,
252
- handleResizeStop: v,
253
- handleResizeStart: r
254
- };
255
- }, Qt = (t, c, o, l, p, _, d, b) => de(() => {
256
- if (!t)
257
- return {
258
- visible: !1,
259
- position: { top: 0, left: 0 },
260
- size: { width: 0, height: 0 }
261
- };
262
- if (!(p + t.clientWidth < d))
263
- return {
264
- visible: !1,
265
- position: { top: 0, left: 0 },
266
- size: { width: 0, height: 0 }
267
- };
268
- const r = t.getBoundingClientRect(), a = (c == null ? void 0 : c.offsetHeight) || 0, v = o == null ? void 0 : o.getBoundingClientRect(), f = Math.min(
269
- r.bottom,
270
- (v == null ? void 0 : v.bottom) || Number.MAX_SAFE_INTEGER
271
- );
272
- let y;
273
- l && o && v ? y = v.top - r.top + a : y = a;
274
- const T = r.top + y, H = t.scrollWidth > t.clientWidth ? t.offsetHeight - t.clientHeight : 0, x = f - T - H, U = t.scrollHeight > t.clientHeight ? t.offsetWidth - t.clientWidth : 0, j = r.right - me - U;
275
- return {
276
- visible: !0,
277
- position: {
278
- top: T,
279
- left: j
280
- },
281
- size: {
282
- width: me,
283
- height: x
284
- }
285
- };
286
- }, [
287
- t,
288
- c,
289
- o,
290
- l,
291
- p,
292
- _,
293
- d,
294
- b
295
- ]), Zt = (t, c, o, l, p, _, d, b) => de(() => {
296
- if (!t)
297
- return {
298
- visible: !1,
299
- position: { top: 0, left: 0 },
300
- size: { width: 0, height: 0 }
301
- };
302
- if (!(c > 0))
303
- return {
304
- visible: !1,
305
- position: { top: 0, left: 0 },
306
- size: { width: 0, height: 0 }
307
- };
308
- const r = t.querySelector('[data-row-index="0"]');
309
- if (!r)
310
- return {
311
- visible: !1,
312
- position: { top: 0, left: 0 },
313
- size: { width: 0, height: 0 }
314
- };
315
- const a = Array.from(r.querySelectorAll("[data-pinned-index]"));
316
- if (a.length === 0)
317
- return {
318
- visible: !1,
319
- position: { top: 0, left: 0 },
320
- size: { width: 0, height: 0 }
321
- };
322
- const v = Math.max(
323
- ...a.map(
324
- (J) => parseInt(J.getAttribute("data-pinned-index") || "-1", 10)
325
- )
326
- );
327
- if (v < 0)
328
- return {
329
- visible: !1,
330
- position: { top: 0, left: 0 },
331
- size: { width: 0, height: 0 }
332
- };
333
- const f = a.find(
334
- (J) => parseInt(J.getAttribute("data-pinned-index") || "-1", 10) === v
335
- );
336
- if (!f)
337
- return {
338
- visible: !1,
339
- position: { top: 0, left: 0 },
340
- size: { width: 0, height: 0 }
341
- };
342
- const y = f.getBoundingClientRect(), T = t.getBoundingClientRect(), E = (o == null ? void 0 : o.offsetHeight) || 0, H = l == null ? void 0 : l.getBoundingClientRect(), x = y.right, A = Math.min(
343
- T.bottom,
344
- (H == null ? void 0 : H.bottom) || Number.MAX_SAFE_INTEGER
345
- );
346
- let U;
347
- p && l && H ? U = H.top - T.top + E : U = E;
348
- const j = T.top + U, Y = t.scrollWidth > t.clientWidth ? t.offsetHeight - t.clientHeight : 0, ee = A - j - Y;
349
- return {
350
- visible: !0,
351
- position: {
352
- top: j,
353
- left: x
354
- },
355
- size: {
356
- width: me,
357
- height: ee
358
- }
359
- };
360
- }, [
361
- t,
362
- c,
363
- o,
364
- l,
365
- p,
366
- _,
367
- d,
368
- b
369
- ]), Kt = ({ enabled: t, rowCount: c }) => {
370
- const o = W(/* @__PURE__ */ new Map()), l = W(/* @__PURE__ */ new Map()), p = z(
371
- (i) => (r) => {
372
- r ? o.current.set(i, r) : o.current.delete(i);
373
- },
374
- []
375
- ), _ = z(
376
- (i) => (r) => {
377
- r ? l.current.set(i, r) : l.current.delete(i);
378
- },
379
- []
380
- ), d = z((i, r) => {
381
- const a = `${i.offsetHeight}px`;
382
- r.style.height !== a && (r.style.height = a);
383
- }, []), b = z(() => {
384
- o.current.forEach((i, r) => {
385
- const a = l.current.get(r);
386
- a && d(i, a);
387
- });
388
- }, [d]);
389
- return B(() => {
390
- if (!t)
391
- return;
392
- const i = new ResizeObserver((r) => {
393
- requestAnimationFrame(() => {
394
- r.forEach((a) => {
395
- const v = a.target, f = parseInt(v.dataset.rowIndex || "-1", 10), y = l.current.get(f);
396
- y && f >= 0 && d(v, y);
397
- });
398
- });
399
- });
400
- return o.current.forEach((r) => i.observe(r)), () => i.disconnect();
401
- }, [t, c, d]), et(() => {
402
- t && b();
403
- }, [t, c, b]), { setTableRowRef: p, setCheckboxRowRef: _, syncAllHeights: b };
404
- }, Ot = {
405
- "resize-handle": "_resize-handle_15uk3_1"
406
- }, en = we.bind(Ot), tn = zt(
407
- (t, c) => /* @__PURE__ */ h("div", { ref: c, className: en("resize-handle"), ...t, children: /* @__PURE__ */ h($t, {}) })
408
- ), nn = {
409
- "gradient-overlay": "_gradient-overlay_hx7m8_1",
410
- "direction-right": "_direction-right_hx7m8_5",
411
- "direction-left": "_direction-left_hx7m8_13"
412
- }, rn = we.bind(nn), Ke = ({
413
- portalContainer: t,
414
- visible: c,
415
- position: o,
416
- size: l,
417
- direction: p,
418
- className: _,
419
- dataTestId: d
420
- }) => {
421
- if (!c || !t)
422
- return null;
423
- const b = {
424
- position: "fixed",
425
- top: `${o.top}px`,
426
- width: `${l.width}px`,
427
- height: `${l.height}px`
428
- };
429
- return o.left !== void 0 && (b.left = `${o.left}px`), o.right !== void 0 && (b.right = `${o.right}px`), Ht(
430
- /* @__PURE__ */ h(
431
- "div",
432
- {
433
- className: rn("gradient-overlay", `direction-${p}`, _),
434
- style: b,
435
- "data-gradient-type": d
436
- }
437
- ),
438
- t
439
- );
440
- }, u = we.bind(Ut), Oe = ({ column: t }) => {
441
- const c = W(null), [o, l] = S(!1);
442
- return B(() => {
443
- if (c.current) {
444
- const p = c.current.offsetWidth, _ = c.current.scrollWidth;
445
- l(_ > p);
446
- }
447
- }, [t.header]), /* @__PURE__ */ h("span", { ref: c, title: o ? t.header : void 0, children: t.header });
448
- }, gn = ({
449
- data: t,
450
- primaryColumn: c,
451
- fixedColumns: o,
452
- renderRowActions: l,
453
- className: p = "",
454
- wrapperClassName: _ = "",
455
- rowClassName: d = "",
456
- headerClassName: b = "",
457
- bodyClassName: i = "",
458
- selectable: r = !1,
459
- selectedRowIds: a = [],
460
- sortingDirection: v = nt,
461
- sortingColumn: f,
462
- sortableColumns: y,
463
- isHeaderFixed: T = !1,
464
- isHorizontallyScrollable: E = !1,
465
- pinnedColumnKeys: H = [],
466
- isRowsExpandable: x = !1,
467
- expandedRowIds: A = [],
468
- isAllExpandedByDefault: U,
469
- expandAllTooltip: j,
470
- isResizable: M = !1,
471
- minColumnWidth: Y = 50,
472
- maxColumnWidth: ee = 500,
473
- isSelectAllCheckboxAlwaysVisible: J = !1,
474
- isCheckboxOutside: N = !1,
475
- onChangeSorting: st = () => {
476
- },
477
- onToggleRowSelection: ot = () => {
478
- },
479
- onToggleAllRowsSelection: ct = () => {
480
- },
481
- onToggleRowExpansion: lt = () => {
482
- },
483
- onToggleAllRowsExpansion: it = () => {
484
- },
485
- onColumnResize: at = () => {
486
- },
487
- externalScrollContainerRef: m,
488
- portalContainer: ke = typeof document < "u" ? document.body : null,
489
- rightGradientClassName: dt,
490
- pinnedGradientClassName: ht
491
- }) => {
492
- const te = de(
493
- () => Array.isArray(c) ? c : [c],
494
- [c]
495
- ), G = f ?? te[0], ne = y ?? jt([...te, ...o]), { pinnedColumns: F, scrollableColumns: Q } = Rt({
496
- primaryColumns: te,
497
- fixedColumns: o,
498
- pinnedColumnKeys: H
499
- }), {
500
- hoveredColumn: Ee,
501
- hoveredRow: Te,
502
- handleColumnMouseEnter: Le,
503
- handleColumnMouseLeave: xe,
504
- handleRowMouseEnter: Ne,
505
- handleRowMouseLeave: ze
506
- } = Vt(), { columnWidthsRef: Z, setCellRef: Ae } = Yt(), { handleToggleRowExpansion: pt, isCellExpanded: $e } = Ct({
507
- primaryColumns: te,
508
- fixedColumns: o,
509
- expandedRowIds: A,
510
- onToggleRowExpansion: lt
511
- }), { columnWidths: re, handleResize: ft, handleResizeStop: ut, handleResizeStart: _t } = Jt({
512
- enabled: M,
513
- minWidth: Y,
514
- maxWidth: ee,
515
- columns: [...F, ...Q],
516
- columnWidthsRef: Z,
517
- onColumnResize: at
518
- }), { setTableRowRef: gt, setCheckboxRowRef: vt } = Kt({
519
- enabled: r && N,
520
- rowCount: t.length
521
- }), Me = (e, s) => {
522
- const n = e.minWidth ?? Y, g = e.maxWidth ?? ee;
523
- return /* @__PURE__ */ h(
524
- At,
525
- {
526
- width: re[e.key] ?? (typeof e.width == "number" ? e.width : Y),
527
- height: 0,
528
- axis: "x",
529
- handle: /* @__PURE__ */ h(tn, {}),
530
- onResizeStart: _t,
531
- onResize: ft(e.key),
532
- onResizeStop: ut(e.key),
533
- minConstraints: [n, 0],
534
- maxConstraints: [g, 0],
535
- className: u("resizable-column"),
536
- children: s
537
- },
538
- e.key
539
- );
540
- }, L = W(null), D = W(null), bt = W(null), K = W(null), he = W(null), [I, yt] = S(!1), se = z((e) => {
541
- const s = D.current;
542
- if (s && s.contains(e))
543
- return;
544
- const n = e.parentElement;
545
- if (!n)
546
- return;
547
- const g = window.getComputedStyle(n), w = parseFloat(g.paddingTop) || 0, k = parseFloat(g.paddingBottom) || 0, P = e.offsetHeight + w + k;
548
- e.style.setProperty("--expand-cell-top", `${w}px`), e.style.setProperty("--expand-cell-height", `${P}px`);
549
- }, []), [We, pe] = S(0), [He, fe] = S(0), [Pe, ue] = S(0), [Be, Se] = S(0), oe = W(!1), _e = W(/* @__PURE__ */ new Set()), O = W(null), ge = Qt(
550
- L.current,
551
- D.current,
552
- (m == null ? void 0 : m.current) instanceof HTMLElement ? m.current : null,
553
- I,
554
- We,
555
- He,
556
- Pe,
557
- Be
558
- ), ve = Zt(
559
- L.current,
560
- We,
561
- D.current,
562
- (m == null ? void 0 : m.current) instanceof HTMLElement ? m.current : null,
563
- I,
564
- He,
565
- Pe,
566
- Be
567
- ), Ge = (e) => {
568
- ne.includes(e) && st({ key: e, direction: v });
569
- }, Fe = (e) => {
570
- ot(e);
571
- }, qe = () => {
572
- ct();
573
- }, mt = () => {
574
- it();
575
- }, Ue = (e) => ne.includes(e) ? (G == null ? void 0 : G.key) === e ? Xt(v) ? /* @__PURE__ */ h(Ye, {}) : /* @__PURE__ */ h(Mt, {}) : /* @__PURE__ */ h(Ye, {}) : null, De = t.every((e) => a.includes(e.id)), Xe = t.some((e) => a.includes(e.id)), be = (a == null ? void 0 : a.length) > 0, wt = !Pt(t), je = J && wt || be, kt = t.every((e) => A.includes(e.id)), Et = U !== void 0 ? U : kt, Tt = Ze(
576
- F,
577
- Q,
578
- x,
579
- r,
580
- !!l,
581
- !1,
582
- M ? re : void 0,
583
- M,
584
- N
585
- ), Lt = Ze(
586
- F,
587
- Q,
588
- x,
589
- r,
590
- !!l,
591
- !0,
592
- M ? re : void 0,
593
- M,
594
- N
595
- ), Ie = /* @__PURE__ */ h("button", { onClick: mt, "aria-label": "Toggle all rows expansion", children: /* @__PURE__ */ h("span", { className: u("expand-icon", { expanded: Et }), children: /* @__PURE__ */ h(Je, {}) }) });
596
- B(() => {
597
- if (!(m != null && m.current) || !L.current || !D.current)
598
- return;
599
- const e = m.current, s = L.current, n = D.current, g = he.current, w = () => {
600
- const $ = s.getBoundingClientRect(), P = e.getBoundingClientRect(), R = n.offsetHeight, X = $.top - P.top, ce = $.bottom - P.top, Ve = e.scrollTop > 0 && X <= 0 && ce > R;
601
- if (yt(Ve), Ve) {
602
- const le = $.left, Ce = P.top;
603
- n.classList.add(u("pinned-header")), E && (n.style.overflow = "hidden", n.style.overflowX = "hidden"), n.style.left = `${le}px`, n.style.top = `${Ce}px`, n.style.width = `${$.width}px`, g && N && (g.style.top = `${Ce}px`);
604
- } else {
605
- const le = s.scrollLeft;
606
- oe.current = !0, n.classList.remove(u("pinned-header")), E && (n.scrollLeft = 0), n.style.left = "", n.style.top = "", n.style.width = "", E && (n.style.overflow = "", n.style.overflowX = ""), g && N && (g.style.top = "", g.classList.remove(u("pinned-header"))), E && le > 0 ? requestAnimationFrame(() => {
607
- s.scrollLeft = le, setTimeout(() => {
608
- oe.current = !1;
609
- }, 0);
610
- }) : oe.current = !1;
611
- }
612
- }, k = requestAnimationFrame(() => {
613
- w();
614
- });
615
- return e.addEventListener("scroll", w), window.addEventListener("resize", w), () => {
616
- cancelAnimationFrame(k), e.removeEventListener("scroll", w), window.removeEventListener("resize", w);
617
- };
618
- }, [m, E, N]), B(() => {
619
- if (!(m != null && m.current) || !L.current || !D.current || !I)
620
- return;
621
- const e = m.current, s = L.current, n = D.current, g = he.current, w = () => {
622
- const X = s.getBoundingClientRect(), ce = e.getBoundingClientRect();
623
- n.style.left = `${X.left}px`, n.style.top = `${ce.top}px`, n.style.width = `${X.width}px`, g && N && (g.style.top = `${ce.top}px`);
624
- }, k = (X) => {
625
- oe.current || (X === n ? s.scrollLeft = n.scrollLeft : n.scrollLeft = s.scrollLeft, O.current && O.current());
626
- }, $ = () => {
627
- k(s), w();
628
- }, P = () => {
629
- k(n);
630
- }, R = () => {
631
- w();
632
- };
633
- return s.addEventListener("scroll", $), E && n.addEventListener("scroll", P), e.addEventListener("scroll", R), window.addEventListener("resize", w), k(s), w(), () => {
634
- s.removeEventListener("scroll", $), E && n.removeEventListener("scroll", P), e.removeEventListener("scroll", R), window.removeEventListener("resize", w);
635
- };
636
- }, [I, m, E, N]), B(() => {
637
- if (!L.current || !E)
638
- return;
639
- const e = L.current, s = m == null ? void 0 : m.current;
640
- pe(e.scrollLeft), fe((s == null ? void 0 : s.scrollTop) || e.scrollTop || 0), ue(e.scrollWidth);
641
- const n = () => {
642
- e && (pe(e.scrollLeft), fe((s == null ? void 0 : s.scrollTop) || e.scrollTop || 0), ue(e.scrollWidth));
643
- };
644
- let g = null;
645
- const w = () => {
646
- g === null && (g = requestAnimationFrame(() => {
647
- n(), g = null;
648
- }));
649
- }, k = () => {
650
- w();
651
- }, $ = () => {
652
- w();
653
- };
654
- e.addEventListener("scroll", k, { passive: !0 }), s && s.addEventListener("scroll", $, {
655
- passive: !0
656
- });
657
- const P = () => {
658
- n(), Se((X) => X + 1);
659
- };
660
- window.addEventListener("resize", P), O.current = n, n();
661
- const R = new ResizeObserver(() => {
662
- n();
663
- });
664
- return e && R.observe(e), () => {
665
- e.removeEventListener("scroll", k), s && s.removeEventListener("scroll", $), window.removeEventListener("resize", P), R.disconnect(), g !== null && (cancelAnimationFrame(g), g = null);
666
- };
667
- }, [E, m, I, A]), B(() => {
668
- if (!L.current || !E)
669
- return;
670
- const e = L.current, s = m == null ? void 0 : m.current;
671
- requestAnimationFrame(() => {
672
- e && (pe(e.scrollLeft), fe((s == null ? void 0 : s.scrollTop) || e.scrollTop || 0), ue(e.scrollWidth), O.current && O.current());
673
- });
674
- }, [re, E, m]), B(() => {
675
- if (!L.current)
676
- return;
677
- const e = L.current, s = () => {
678
- Array.from(e.querySelectorAll('[data-base-left="0"]')).forEach(se);
679
- };
680
- requestAnimationFrame(() => {
681
- s();
682
- });
683
- }, [x, t, se]), B(() => {
684
- if (!L.current)
685
- return;
686
- const e = L.current, s = new Set(A), n = _e.current, g = /* @__PURE__ */ new Set();
687
- if (A.forEach((k) => {
688
- n.has(k) || g.add(k);
689
- }), n.forEach((k) => {
690
- s.has(k) || g.add(k);
691
- }), g.size === 0) {
692
- _e.current = s;
693
- return;
694
- }
695
- const w = setTimeout(() => {
696
- g.forEach((k) => {
697
- const $ = e.querySelector(
698
- `[data-base-left="0"][data-row-id="${k}"]`
699
- );
700
- $ && se($);
701
- }), Se((k) => k + 1);
702
- }, 0);
703
- return _e.current = s, () => clearTimeout(w);
704
- }, [x, A, se]), B(() => {
705
- if (!K.current || !L.current || !N)
706
- return;
707
- const e = K.current, s = L.current, n = () => {
708
- requestAnimationFrame(() => {
709
- e.scrollTop = s.scrollTop;
710
- });
711
- };
712
- return s.addEventListener("scroll", n), () => {
713
- s.removeEventListener("scroll", n);
714
- };
715
- }, [t, N]), et(() => {
716
- if (!L.current || !K.current)
717
- return;
718
- const e = L.current, s = K.current, n = () => {
719
- const w = `${e.clientHeight}px`;
720
- s.style.height !== w && (s.style.height = w);
721
- };
722
- n();
723
- const g = new ResizeObserver(() => {
724
- requestAnimationFrame(n);
725
- });
726
- return g.observe(e), () => g.disconnect();
727
- }, []);
728
- const xt = () => /* @__PURE__ */ q("div", { className: u("checkbox-column"), ref: K, children: [
729
- /* @__PURE__ */ h(
730
- "div",
731
- {
732
- ref: he,
733
- className: u(
734
- "table-header",
735
- "checkbox-header",
736
- { "pinned-header": I },
737
- b
738
- ),
739
- children: je && /* @__PURE__ */ h(
740
- ie,
741
- {
742
- value: De,
743
- partiallyChecked: Xe,
744
- onChange: qe,
745
- className: u("checkbox-cell")
746
- }
747
- )
748
- }
749
- ),
750
- /* @__PURE__ */ h("div", { className: u("checkbox-body", i), children: t.map((e, s) => /* @__PURE__ */ h(
751
- "div",
752
- {
753
- ref: vt(s),
754
- className: u("checkbox-row", "table-row", Qe(e), d),
755
- onMouseEnter: () => Ne(s),
756
- onMouseLeave: ze,
757
- children: (be || Te === s) && /* @__PURE__ */ h(
758
- ie,
759
- {
760
- value: a.includes(e.id),
761
- onChange: () => Fe(e.id),
762
- className: u("checkbox-cell")
763
- }
764
- )
765
- },
766
- e.id
767
- )) })
768
- ] }), Re = () => /* @__PURE__ */ q(
769
- "div",
770
- {
771
- ref: L,
772
- className: u(
773
- "table",
774
- {
775
- "fixed-header": T,
776
- "horizontally-scrollable-container": T && (E || M),
777
- "external-scroll-container": T && !!m
778
- },
779
- p
780
- ),
781
- children: [
782
- /* @__PURE__ */ q(
783
- "div",
784
- {
785
- ref: D,
786
- className: u(
787
- "table-header",
788
- {
789
- "sticky-header": T && !I,
790
- "horizontally-scrollable": E,
791
- resizable: M
792
- },
793
- b
794
- ),
795
- style: { gridTemplateColumns: Lt },
796
- children: [
797
- r && !N && /* @__PURE__ */ h(
798
- "div",
799
- {
800
- className: u("table-header-cell", "checkbox-cell"),
801
- "data-base-left": x ? C : 0,
802
- children: je && /* @__PURE__ */ h(
803
- ie,
804
- {
805
- value: De,
806
- partiallyChecked: Xe,
807
- onChange: qe,
808
- className: u("checkbox-cell")
809
- }
810
- )
811
- }
812
- ),
813
- x && /* @__PURE__ */ h(
814
- "div",
815
- {
816
- className: u("table-header-cell", "expand-cell", "left-border-accent"),
817
- "data-base-left": "0",
818
- children: j ? /* @__PURE__ */ h(
819
- Wt,
820
- {
821
- content: j,
822
- placement: "top",
823
- wrapperClassName: u("expand-all-tooltip-wrapper"),
824
- contentClassName: u("expand-all-tooltip-content"),
825
- children: Ie
826
- }
827
- ) : Ie
828
- }
829
- ),
830
- F.map((e, s) => {
831
- const n = /* @__PURE__ */ h(
832
- "button",
833
- {
834
- "data-column-key": e.key,
835
- "data-pinned-index": s,
836
- className: u("table-header-cell", "pinned-column", {
837
- [`align-${e.align}`]: "align" in e,
838
- "primary-cell": V(e),
839
- "sortable-cell": ne.includes(e.key),
840
- resizable: M
841
- }),
842
- style: ae(
843
- e,
844
- !0,
845
- s,
846
- F,
847
- Z,
848
- x,
849
- r,
850
- N
851
- ),
852
- children: /* @__PURE__ */ q(
853
- "div",
854
- {
855
- className: u("label"),
856
- onClick: () => Ge(e.key),
857
- onMouseEnter: () => Le(e.key),
858
- onMouseLeave: xe,
859
- children: [
860
- /* @__PURE__ */ h(Oe, { column: e }),
861
- (Ee === e.key || (G == null ? void 0 : G.key) === e.key) && Ue(e.key)
862
- ]
863
- }
864
- )
865
- },
866
- e.key
867
- );
868
- return M ? Me(e, n) : n;
869
- }),
870
- Q.map((e) => {
871
- const s = /* @__PURE__ */ h(
872
- "button",
873
- {
874
- className: u("table-header-cell", {
875
- [`align-${e.align}`]: "align" in e,
876
- "primary-cell": V(e),
877
- "sortable-cell": ne.includes(e.key),
878
- resizable: M
879
- }),
880
- style: ae(
881
- e,
882
- !1,
883
- void 0,
884
- F,
885
- Z,
886
- x,
887
- r,
888
- N
889
- ),
890
- children: /* @__PURE__ */ q(
891
- "div",
892
- {
893
- className: u("label"),
894
- onClick: () => Ge(e.key),
895
- onMouseEnter: () => Le(e.key),
896
- onMouseLeave: xe,
897
- children: [
898
- /* @__PURE__ */ h(Oe, { column: e }),
899
- (Ee === e.key || (G == null ? void 0 : G.key) === e.key) && Ue(e.key)
900
- ]
901
- }
902
- )
903
- },
904
- e.key
905
- );
906
- return M ? Me(e, s) : s;
907
- }),
908
- l && /* @__PURE__ */ h("div", { className: u("table-header-cell", "action-menu-cell") })
909
- ]
910
- }
911
- ),
912
- /* @__PURE__ */ h(
913
- "div",
914
- {
915
- ref: bt,
916
- className: u(
917
- "table-body",
918
- {
919
- "scrollable-body": T,
920
- "horizontally-scrollable": E,
921
- resizable: M
922
- },
923
- i
924
- ),
925
- children: t.map((e, s) => /* @__PURE__ */ q(
926
- "div",
927
- {
928
- "data-row-index": s,
929
- ref: gt(s),
930
- className: u("table-row", Qe(e), d, {
931
- selectable: r && !N
932
- }),
933
- onMouseEnter: () => Ne(s),
934
- onMouseLeave: ze,
935
- children: [
936
- r && !N && /* @__PURE__ */ h(
937
- "div",
938
- {
939
- className: u("table-cell", "checkbox-cell"),
940
- "data-base-left": x ? C : 0,
941
- children: (be || Te === s) && /* @__PURE__ */ h(
942
- ie,
943
- {
944
- value: a.includes(e.id),
945
- onChange: () => Fe(e.id),
946
- className: u("checkbox-cell")
947
- }
948
- )
949
- }
950
- ),
951
- /* @__PURE__ */ h("div", { className: u("row-content-wrapper"), children: /* @__PURE__ */ q("div", { className: u("table-row-content"), style: { gridTemplateColumns: Tt }, children: [
952
- x && /* @__PURE__ */ h(
953
- "div",
954
- {
955
- className: u("table-cell", "expand-cell", "left-border-accent"),
956
- "data-base-left": "0",
957
- "data-row-id": e.id,
958
- children: /* @__PURE__ */ h(
959
- "button",
960
- {
961
- onClick: () => pt(e.id),
962
- "aria-label": A.includes(e.id) ? "Collapse row" : "Expand row",
963
- "aria-expanded": A.includes(e.id),
964
- children: /* @__PURE__ */ h(
965
- "span",
966
- {
967
- className: u("expand-icon", {
968
- expanded: A.includes(e.id)
969
- }),
970
- children: /* @__PURE__ */ h(Je, {})
971
- }
972
- )
973
- }
974
- )
975
- }
976
- ),
977
- F.map((n, g) => {
978
- const w = $e(e.id, n.key), k = V(n);
979
- return /* @__PURE__ */ h(
980
- "div",
981
- {
982
- "data-column-key": n.key,
983
- "data-pinned-index": g,
984
- ref: k ? Ae(n.key) : void 0,
985
- className: u("table-cell", "pinned-column", {
986
- "primary-cell": k,
987
- "expanded-cell": w
988
- }),
989
- style: ae(
990
- n,
991
- !0,
992
- g,
993
- F,
994
- Z,
995
- x,
996
- r,
997
- N
998
- ),
999
- children: e[n.key].component || e[n.key].content || e[n.key]
1000
- },
1001
- n.key
1002
- );
1003
- }),
1004
- Q.map((n) => {
1005
- const g = $e(e.id, n.key), w = V(n);
1006
- return /* @__PURE__ */ h(
1007
- "div",
1008
- {
1009
- ref: w ? Ae(n.key) : void 0,
1010
- className: u("table-cell", {
1011
- "primary-cell": w,
1012
- "expanded-cell": g
1013
- }),
1014
- style: ae(
1015
- n,
1016
- !1,
1017
- void 0,
1018
- F,
1019
- Z,
1020
- x,
1021
- r,
1022
- N
1023
- ),
1024
- children: e[n.key].component || e[n.key].content || e[n.key]
1025
- },
1026
- n.key
1027
- );
1028
- }),
1029
- l && /* @__PURE__ */ h("div", { className: u("table-cell", "action-menu-cell"), children: l(e.metaData) })
1030
- ] }) })
1031
- ]
1032
- },
1033
- e.id
1034
- ))
1035
- }
1036
- ),
1037
- E && /* @__PURE__ */ q(Nt, { children: [
1038
- /* @__PURE__ */ h(
1039
- Ke,
1040
- {
1041
- portalContainer: ke,
1042
- visible: ge.visible,
1043
- position: ge.position,
1044
- size: ge.size,
1045
- direction: "right",
1046
- className: dt,
1047
- dataTestId: "right-gradient"
1048
- }
1049
- ),
1050
- /* @__PURE__ */ h(
1051
- Ke,
1052
- {
1053
- portalContainer: ke,
1054
- visible: ve.visible,
1055
- position: ve.position,
1056
- size: ve.size,
1057
- direction: "left",
1058
- className: ht,
1059
- dataTestId: "pinned-gradient"
1060
- }
1061
- )
1062
- ] })
1063
- ]
1064
- }
1065
- );
1066
- return N ? /* @__PURE__ */ q("div", { className: u("table-wrapper", { "fixed-header": T }, _), children: [
1067
- xt(),
1068
- Re()
1069
- ] }) : Re();
1070
- };
1071
- export {
1072
- gn as T
1073
- };