@galaxy-io/dls 1.2.0 → 1.2.2
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.
- package/dist/styles.css +6 -7
- package/dist/table/InfiniteTable.d.ts +7 -0
- package/dist/table/InfiniteTable.js +148 -209
- package/package.json +1 -1
package/dist/styles.css
CHANGED
|
@@ -159,13 +159,12 @@
|
|
|
159
159
|
.s1we9pi1{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}
|
|
160
160
|
.ezfy353{position:absolute;top:0;left:0;right:0;bottom:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;pointer-events:none;}.ezfy353>*{pointer-events:auto;}
|
|
161
161
|
.l1pcw3m6{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;height:var(--l1pcw3m6-0);}.l1pcw3m6>td{border-bottom:0.5px solid var(--l1pcw3m6-1);background-color:var(--l1pcw3m6-2);}
|
|
162
|
-
.eo1carc{display:block;width:100%;
|
|
163
|
-
.e8l9d05{display:block;width:100%;
|
|
164
|
-
.e12m9dma{position:
|
|
165
|
-
.e1birhg7{
|
|
166
|
-
.e2tyxoq{
|
|
167
|
-
.ew9y6zt{
|
|
168
|
-
.e2jf90d{width:100%;box-sizing:border-box;overscroll-behavior:auto;}
|
|
162
|
+
.eo1carc{display:block;width:100%;min-width:var(--eo1carc-0);}
|
|
163
|
+
.e8l9d05{display:block;width:100%;padding:0;box-sizing:border-box;background-color:var(--e8l9d05-0);border-bottom:var(--e8l9d05-1);}
|
|
164
|
+
.e12m9dma{position:-webkit-sticky;position:sticky;left:0;width:var(--e12m9dma-0);display:-ms-grid;display:grid;-ms-grid-columns:44px minmax(0, 1fr);grid-template-columns:44px minmax(0, 1fr);box-sizing:border-box;}
|
|
165
|
+
.e1birhg7{background-color:var(--e1birhg7-0);border-right:0.5px solid var(--e1birhg7-1);min-width:44px;}
|
|
166
|
+
.e2tyxoq{min-width:0;width:100%;border-top:0.5px solid var(--e2tyxoq-0);}
|
|
167
|
+
.ew9y6zt{width:100%;box-sizing:border-box;overscroll-behavior:auto;}
|
|
169
168
|
.c1bx58xl{position:var(--c1bx58xl-0);z-index:var(--c1bx58xl-1);left:var(--c1bx58xl-2);right:var(--c1bx58xl-3);-webkit-flex:var(--c1bx58xl-4);-ms-flex:var(--c1bx58xl-4);flex:var(--c1bx58xl-4);padding:0 12px;height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:var(--c1bx58xl-5);-ms-flex-pack:var(--c1bx58xl-5);-webkit-justify-content:var(--c1bx58xl-5);justify-content:var(--c1bx58xl-5);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:var(--c1bx58xl-6);background-color:var(--c1bx58xl-7);border-right:var(--c1bx58xl-8);border-left:var(--c1bx58xl-9);}.c1bx58xl:hover{background-color:var(--c1bx58xl-10);}
|
|
170
169
|
.sgqglvy{width:6px;height:6px;border-radius:50%;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;margin-right:6px;background-color:var(--sgqglvy-0);}
|
|
171
170
|
.ejxsxoj{position:absolute;inset:0;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:0 4px;z-index:1;background-color:var(--ejxsxoj-0);border:1.5px solid var(--ejxsxoj-1);border-radius:2px;}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React, { type ReactNode } from "react";
|
|
2
2
|
import { type OnChangeFn as TanstackOnChangeFn, type Row as TanstackRow, type RowSelectionState as TanstackRowSelectionState, type SortingState as TanstackSortingState, type Table as TanstackTable } from "@tanstack/react-table";
|
|
3
|
+
export declare enum TableVariant {
|
|
4
|
+
BASE = "BASE",
|
|
5
|
+
PRIMARY = "PRIMARY",
|
|
6
|
+
SECONDARY = "SECONDARY",
|
|
7
|
+
TERTIARY = "TERTIARY"
|
|
8
|
+
}
|
|
3
9
|
export declare enum TableDensity {
|
|
4
10
|
SMALL = "SMALL",
|
|
5
11
|
MEDIUM = "MEDIUM",
|
|
@@ -53,6 +59,7 @@ export interface InfiniteTableProps<TData> {
|
|
|
53
59
|
fillWidth?: boolean;
|
|
54
60
|
fillHeight?: boolean;
|
|
55
61
|
density?: TableDensity;
|
|
62
|
+
variant?: TableVariant;
|
|
56
63
|
hasNextPage?: boolean;
|
|
57
64
|
isFetchingNextPage?: boolean;
|
|
58
65
|
fetchNextPage?: () => void;
|
|
@@ -6,11 +6,18 @@ import Button, { ButtonSize, ButtonVariant } from "../buttons/Button.js";
|
|
|
6
6
|
/* empty css */
|
|
7
7
|
import { styled } from "@linaria/react";
|
|
8
8
|
import { match } from "ts-pattern";
|
|
9
|
-
import React, {
|
|
9
|
+
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { CaretDownIcon, CaretRightIcon, CaretUpDownIcon, SortAscendingIcon, SortDescendingIcon } from "@phosphor-icons/react";
|
|
12
12
|
import { flexRender, getCoreRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
|
|
13
13
|
//#region src/table/InfiniteTable.tsx
|
|
14
|
+
var TableVariant = /* @__PURE__ */ function(TableVariant) {
|
|
15
|
+
TableVariant["BASE"] = "BASE";
|
|
16
|
+
TableVariant["PRIMARY"] = "PRIMARY";
|
|
17
|
+
TableVariant["SECONDARY"] = "SECONDARY";
|
|
18
|
+
TableVariant["TERTIARY"] = "TERTIARY";
|
|
19
|
+
return TableVariant;
|
|
20
|
+
}({});
|
|
14
21
|
var TableDensity = /* @__PURE__ */ function(TableDensity) {
|
|
15
22
|
TableDensity["SMALL"] = "SMALL";
|
|
16
23
|
TableDensity["MEDIUM"] = "MEDIUM";
|
|
@@ -46,6 +53,15 @@ var TABLE_DENSITY_TO_BUTTON_SIZE_MAP = {
|
|
|
46
53
|
["MEDIUM"]: ButtonSize.SMALL,
|
|
47
54
|
["LARGE"]: ButtonSize.MEDIUM
|
|
48
55
|
};
|
|
56
|
+
function getVariantBackgroundColor(theme, variant) {
|
|
57
|
+
return match(variant).with("BASE", () => theme.color.background.base).with("PRIMARY", () => theme.color.background.primary).with("SECONDARY", () => theme.color.background.secondary).with("TERTIARY", () => theme.color.background.tertiary).with(void 0, () => theme.color.background.primary).exhaustive();
|
|
58
|
+
}
|
|
59
|
+
function getVariantHoverBackgroundColor(theme, variant) {
|
|
60
|
+
return match(variant).with("BASE", () => theme.color.background.tertiary).with("PRIMARY", () => theme.color.background.tertiary).with("SECONDARY", () => theme.color.background.tertiary).with("TERTIARY", () => theme.color.background.secondary).with(void 0, () => theme.color.background.tertiary).exhaustive();
|
|
61
|
+
}
|
|
62
|
+
function getVariantSelectedBackgroundColor(theme, variant) {
|
|
63
|
+
return match(variant).with("BASE", () => theme.color.background.secondary).with("PRIMARY", () => theme.color.background.secondary).with("SECONDARY", () => theme.color.background.primary).with("TERTIARY", () => theme.color.background.primary).with(void 0, () => theme.color.background.secondary).exhaustive();
|
|
64
|
+
}
|
|
49
65
|
var _exp = () => ({ $width, $fillWidth }) => {
|
|
50
66
|
if ($fillWidth) return "100%";
|
|
51
67
|
if ($width) return getCssSizeValue($width);
|
|
@@ -89,15 +105,15 @@ var TableBody = /*#__PURE__*/ styled("tbody")({
|
|
|
89
105
|
});
|
|
90
106
|
var _exp4 = () => ({ $isClickable }) => $isClickable ? "pointer" : "default";
|
|
91
107
|
var _exp5 = () => ({ $density }) => match($density).with("SMALL", () => "32px").with("MEDIUM", () => "48px").with("LARGE", () => "56px").with(void 0, () => "48px").exhaustive();
|
|
92
|
-
var _exp6 = () => ({ $isSelected, theme }) => $isSelected ? theme
|
|
108
|
+
var _exp6 = () => ({ $isSelected, $variant, theme }) => $isSelected ? getVariantSelectedBackgroundColor(theme, $variant) : getVariantBackgroundColor(theme, $variant);
|
|
93
109
|
var _exp7 = () => ({ $isExpanded, $isLastRow, theme }) => {
|
|
94
110
|
if ($isExpanded || $isLastRow) return "none";
|
|
95
111
|
return `0.5px solid ${theme.color.border.primary}`;
|
|
96
112
|
};
|
|
97
|
-
var _exp8 = () => ({ $isClickable, $isSelected, theme }) => {
|
|
98
|
-
if ($isSelected) return theme
|
|
99
|
-
if ($isClickable) return theme
|
|
100
|
-
return theme
|
|
113
|
+
var _exp8 = () => ({ $isClickable, $isSelected, $variant, theme }) => {
|
|
114
|
+
if ($isSelected) return getVariantSelectedBackgroundColor(theme, $variant);
|
|
115
|
+
if ($isClickable) return getVariantHoverBackgroundColor(theme, $variant);
|
|
116
|
+
return getVariantBackgroundColor(theme, $variant);
|
|
101
117
|
};
|
|
102
118
|
var TableRow = withTheme(/*#__PURE__*/ styled("tr")({
|
|
103
119
|
name: "TableRow",
|
|
@@ -134,7 +150,7 @@ var _exp10 = () => ({ $maxWidth }) => {
|
|
|
134
150
|
};
|
|
135
151
|
var _exp11 = () => ({ $align }) => match($align).with("LEFT", () => "left").with("CENTER", () => "center").with("RIGHT", () => "right").with(void 0, () => "left").exhaustive();
|
|
136
152
|
var _exp12 = () => ({ theme }) => theme.color.border.primary;
|
|
137
|
-
var _exp13 = () => ({ theme }) => theme
|
|
153
|
+
var _exp13 = () => ({ $variant, theme }) => getVariantBackgroundColor(theme, $variant);
|
|
138
154
|
var _exp14 = () => ({ $align }) => match($align).with("LEFT", () => "flex-start").with("CENTER", () => "center").with("RIGHT", () => "flex-end").with(void 0, () => "flex-start").exhaustive();
|
|
139
155
|
var _exp15 = () => ({ $isSortable }) => {
|
|
140
156
|
if ($isSortable) return "pointer";
|
|
@@ -200,8 +216,8 @@ var _exp25 = () => ({ $maxWidth }) => {
|
|
|
200
216
|
};
|
|
201
217
|
var _exp26 = () => ({ $align }) => match($align).with("LEFT", () => "left").with("CENTER", () => "center").with("RIGHT", () => "right").with(void 0, () => "left").exhaustive();
|
|
202
218
|
var _exp27 = () => ({ $align }) => match($align).with("LEFT", () => "flex-start").with("CENTER", () => "center").with("RIGHT", () => "flex-end").with(void 0, () => "flex-start").exhaustive();
|
|
203
|
-
var _exp28 = () => ({ $pin, theme }) => {
|
|
204
|
-
if ($pin) return theme
|
|
219
|
+
var _exp28 = () => ({ $pin, $variant, theme }) => {
|
|
220
|
+
if ($pin) return getVariantBackgroundColor(theme, $variant);
|
|
205
221
|
return "transparent";
|
|
206
222
|
};
|
|
207
223
|
var _exp29 = () => ({ $pin }) => {
|
|
@@ -266,7 +282,7 @@ var EmptyContentWrapper = /*#__PURE__*/ styled("div")({
|
|
|
266
282
|
});
|
|
267
283
|
var _exp35 = () => ({ $density }) => match($density).with("SMALL", () => "32px").with("MEDIUM", () => "48px").with("LARGE", () => "56px").with(void 0, () => "48px").exhaustive();
|
|
268
284
|
var _exp36 = () => ({ theme }) => theme.color.border.primary;
|
|
269
|
-
var _exp37 = () => ({ theme }) => theme
|
|
285
|
+
var _exp37 = () => ({ $variant, theme }) => getVariantBackgroundColor(theme, $variant);
|
|
270
286
|
var LoadingRowWrapper = withTheme(/*#__PURE__*/ styled("tr")({
|
|
271
287
|
name: "LoadingRowWrapper",
|
|
272
288
|
class: "l1pcw3m6",
|
|
@@ -277,72 +293,59 @@ var LoadingRowWrapper = withTheme(/*#__PURE__*/ styled("tr")({
|
|
|
277
293
|
"l1pcw3m6-2": [_exp37()]
|
|
278
294
|
}
|
|
279
295
|
}));
|
|
280
|
-
var _exp38 = () => ({ $
|
|
281
|
-
var
|
|
282
|
-
name: "
|
|
296
|
+
var _exp38 = () => ({ $minWidth }) => `${$minWidth}px`;
|
|
297
|
+
var ExpandedRow = /*#__PURE__*/ styled("tr")({
|
|
298
|
+
name: "ExpandedRow",
|
|
283
299
|
class: "eo1carc",
|
|
284
300
|
propsAsIs: false,
|
|
285
301
|
vars: { "eo1carc-0": [_exp38()] }
|
|
286
302
|
});
|
|
287
|
-
var
|
|
288
|
-
|
|
303
|
+
var _exp39 = () => ({ $variant, theme }) => getVariantBackgroundColor(theme, $variant);
|
|
304
|
+
var _exp40 = () => ({ $isLastRow, theme }) => $isLastRow ? "none" : `0.5px solid ${theme.color.border.primary}`;
|
|
305
|
+
var ExpandedRowCell = withTheme(/*#__PURE__*/ styled("td")({
|
|
306
|
+
name: "ExpandedRowCell",
|
|
289
307
|
class: "e8l9d05",
|
|
290
|
-
propsAsIs: false
|
|
291
|
-
}));
|
|
292
|
-
var ExpandedOverlayLayer = /*#__PURE__*/ styled("div")({
|
|
293
|
-
name: "ExpandedOverlayLayer",
|
|
294
|
-
class: "e12m9dma",
|
|
295
|
-
propsAsIs: false
|
|
296
|
-
});
|
|
297
|
-
var _exp39 = () => ({ $top }) => `${$top}px`;
|
|
298
|
-
var _exp40 = () => ({ $left }) => `${$left}px`;
|
|
299
|
-
var _exp41 = () => ({ $width }) => `${$width}px`;
|
|
300
|
-
var _exp43 = () => ({ theme }) => theme.color.background.primary;
|
|
301
|
-
var _exp44 = () => ({ $isLastRow, theme }) => $isLastRow ? "none" : `0.5px solid ${theme.color.border.primary}`;
|
|
302
|
-
var ExpandedOverlay = withTheme(/*#__PURE__*/ styled("div")({
|
|
303
|
-
name: "ExpandedOverlay",
|
|
304
|
-
class: "e1birhg7",
|
|
305
308
|
propsAsIs: false,
|
|
306
309
|
vars: {
|
|
307
|
-
"
|
|
308
|
-
"
|
|
309
|
-
"e1birhg7-2": [_exp41()],
|
|
310
|
-
"e1birhg7-3": [_exp43()],
|
|
311
|
-
"e1birhg7-4": [_exp44()]
|
|
310
|
+
"e8l9d05-0": [_exp39()],
|
|
311
|
+
"e8l9d05-1": [_exp40()]
|
|
312
312
|
}
|
|
313
313
|
}));
|
|
314
|
-
var
|
|
315
|
-
var
|
|
314
|
+
var _exp41 = () => ({ $width }) => $width !== void 0 ? `${$width}px` : "100%";
|
|
315
|
+
var ExpandedViewport = /*#__PURE__*/ styled("div")({
|
|
316
|
+
name: "ExpandedViewport",
|
|
317
|
+
class: "e12m9dma",
|
|
318
|
+
propsAsIs: false,
|
|
319
|
+
vars: { "e12m9dma-0": [_exp41()] }
|
|
320
|
+
});
|
|
321
|
+
var _exp43 = () => ({ $variant, theme }) => getVariantBackgroundColor(theme, $variant);
|
|
322
|
+
var _exp44 = () => ({ theme }) => theme.color.border.primary;
|
|
316
323
|
var ExpandedGutter = withTheme(/*#__PURE__*/ styled("div")({
|
|
317
324
|
name: "ExpandedGutter",
|
|
318
|
-
class: "
|
|
325
|
+
class: "e1birhg7",
|
|
319
326
|
propsAsIs: false,
|
|
320
327
|
vars: {
|
|
321
|
-
"
|
|
322
|
-
"
|
|
328
|
+
"e1birhg7-0": [_exp43()],
|
|
329
|
+
"e1birhg7-1": [_exp44()]
|
|
323
330
|
}
|
|
324
331
|
}));
|
|
325
|
-
var
|
|
332
|
+
var _exp46 = () => ({ theme }) => theme.color.border.primary;
|
|
326
333
|
var ExpandedBody = withTheme(/*#__PURE__*/ styled("div")({
|
|
327
334
|
name: "ExpandedBody",
|
|
328
|
-
class: "
|
|
335
|
+
class: "e2tyxoq",
|
|
329
336
|
propsAsIs: false,
|
|
330
|
-
vars: { "
|
|
337
|
+
vars: { "e2tyxoq-0": [_exp46()] }
|
|
331
338
|
}));
|
|
332
339
|
var ExpandedContent = /*#__PURE__*/ styled("div")({
|
|
333
340
|
name: "ExpandedContent",
|
|
334
|
-
class: "
|
|
341
|
+
class: "ew9y6zt",
|
|
335
342
|
propsAsIs: false
|
|
336
343
|
});
|
|
337
344
|
function InfiniteTable(props) {
|
|
338
|
-
const { columns, data, getRowId, height, width, fillWidth, fillHeight, density = "MEDIUM", hasNextPage, isFetchingNextPage, fetchNextPage, enableRowSelection, enableMultiRowSelection, rowSelection, onRowSelectionChange, enableSorting = false, enableMultiSort = false, sorting, onSortingChange, manualSorting = false, isLoading = false, isError = false, loadingRowCount = 5, contentWhenEmpty, contentWhenError, noHeader = false, noLastRowBorder = false, noLastRowPadding = false, onRowClick, onRowDoubleClick, onRowExpand, onTableReady } = props;
|
|
339
|
-
const outerContainerRef = useRef(null);
|
|
345
|
+
const { columns, data, getRowId, height, width, fillWidth, fillHeight, density = "MEDIUM", variant = "PRIMARY", hasNextPage, isFetchingNextPage, fetchNextPage, enableRowSelection, enableMultiRowSelection, rowSelection, onRowSelectionChange, enableSorting = false, enableMultiSort = false, sorting, onSortingChange, manualSorting = false, isLoading = false, isError = false, loadingRowCount = 5, contentWhenEmpty, contentWhenError, noHeader = false, noLastRowBorder = false, noLastRowPadding = false, onRowClick, onRowDoubleClick, onRowExpand, onTableReady } = props;
|
|
340
346
|
const scrollContainerRef = useRef(null);
|
|
341
|
-
const expandedOverlayRef = useRef(null);
|
|
342
|
-
const queueWheelScrollRef = useRef(null);
|
|
343
|
-
const syncExpandedOverlayLayoutRafRef = useRef(null);
|
|
344
347
|
const [expandedRowId, setExpandedRowId] = useState(null);
|
|
345
|
-
const [
|
|
348
|
+
const [scrollContainerClientWidth, setScrollContainerClientWidth] = useState(null);
|
|
346
349
|
const resolvedColumns = useMemo(() => {
|
|
347
350
|
if (!onRowExpand) return columns;
|
|
348
351
|
return [{
|
|
@@ -394,6 +397,7 @@ function InfiniteTable(props) {
|
|
|
394
397
|
});
|
|
395
398
|
return offsets;
|
|
396
399
|
}, [resolvedColumns]);
|
|
400
|
+
const totalColumnMinWidth = useMemo(() => resolvedColumns.reduce((sum, col) => sum + (col.size ?? col.minSize ?? 0), 0), [resolvedColumns]);
|
|
397
401
|
const table = useReactTable({
|
|
398
402
|
data,
|
|
399
403
|
columns: useMemo(() => resolvedColumns.map((col) => ({
|
|
@@ -457,8 +461,6 @@ function InfiniteTable(props) {
|
|
|
457
461
|
onTableReady?.(table);
|
|
458
462
|
}, [table, onTableReady]);
|
|
459
463
|
const { rows } = table.getRowModel();
|
|
460
|
-
const expandedRow = expandedRowId ? rows.find((row) => row.id === expandedRowId) : void 0;
|
|
461
|
-
const isExpandedRowLast = expandedRow ? rows[rows.length - 1]?.id === expandedRow.id : false;
|
|
462
464
|
useEffect(() => {
|
|
463
465
|
if (!onRowExpand && expandedRowId !== null) setExpandedRowId(null);
|
|
464
466
|
}, [expandedRowId, onRowExpand]);
|
|
@@ -466,74 +468,21 @@ function InfiniteTable(props) {
|
|
|
466
468
|
if (expandedRowId === null) return;
|
|
467
469
|
if (!rows.some((row) => row.id === expandedRowId)) setExpandedRowId(null);
|
|
468
470
|
}, [expandedRowId, rows]);
|
|
469
|
-
const syncExpandedOverlayLayout = useCallback(() => {
|
|
470
|
-
if (!expandedRow || !onRowExpand) {
|
|
471
|
-
setExpandedOverlayLayout(null);
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
const outerContainer = outerContainerRef.current;
|
|
475
|
-
const scrollContainer = scrollContainerRef.current;
|
|
476
|
-
const overlayElement = expandedOverlayRef.current;
|
|
477
|
-
if (!outerContainer || !scrollContainer || !overlayElement) return;
|
|
478
|
-
const expandedRowAnchor = scrollContainer.querySelector("[data-gx-expanded-row-anchor=\"true\"]");
|
|
479
|
-
if (!expandedRowAnchor) return;
|
|
480
|
-
const outerRect = outerContainer.getBoundingClientRect();
|
|
481
|
-
const scrollRect = scrollContainer.getBoundingClientRect();
|
|
482
|
-
const rowRect = expandedRowAnchor.getBoundingClientRect();
|
|
483
|
-
const overlayRect = overlayElement.getBoundingClientRect();
|
|
484
|
-
const nextLayout = {
|
|
485
|
-
top: rowRect.bottom - outerRect.top,
|
|
486
|
-
left: scrollRect.left - outerRect.left,
|
|
487
|
-
width: scrollContainer.clientWidth,
|
|
488
|
-
height: overlayRect.height
|
|
489
|
-
};
|
|
490
|
-
setExpandedOverlayLayout((currentLayout) => {
|
|
491
|
-
if (currentLayout && currentLayout.top === nextLayout.top && currentLayout.left === nextLayout.left && currentLayout.width === nextLayout.width && currentLayout.height === nextLayout.height) return currentLayout;
|
|
492
|
-
return nextLayout;
|
|
493
|
-
});
|
|
494
|
-
}, [expandedRow, onRowExpand]);
|
|
495
|
-
const scheduleSyncExpandedOverlayLayout = useCallback(() => {
|
|
496
|
-
if (syncExpandedOverlayLayoutRafRef.current !== null) return;
|
|
497
|
-
syncExpandedOverlayLayoutRafRef.current = requestAnimationFrame(() => {
|
|
498
|
-
syncExpandedOverlayLayoutRafRef.current = null;
|
|
499
|
-
syncExpandedOverlayLayout();
|
|
500
|
-
});
|
|
501
|
-
}, [syncExpandedOverlayLayout]);
|
|
502
471
|
useLayoutEffect(() => {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
syncExpandedOverlayLayoutRafRef.current = null;
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
}, [syncExpandedOverlayLayout]);
|
|
511
|
-
useEffect(() => {
|
|
512
|
-
if (!expandedRow || !onRowExpand) return;
|
|
513
|
-
const scrollContainer = scrollContainerRef.current;
|
|
514
|
-
const overlayElement = expandedOverlayRef.current;
|
|
515
|
-
if (!scrollContainer || !overlayElement) return;
|
|
516
|
-
scrollContainer.addEventListener("scroll", scheduleSyncExpandedOverlayLayout, { passive: true });
|
|
517
|
-
window.addEventListener("resize", scheduleSyncExpandedOverlayLayout);
|
|
518
|
-
if (typeof ResizeObserver === "undefined") return () => {
|
|
519
|
-
scrollContainer.removeEventListener("scroll", scheduleSyncExpandedOverlayLayout);
|
|
520
|
-
window.removeEventListener("resize", scheduleSyncExpandedOverlayLayout);
|
|
521
|
-
};
|
|
522
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
523
|
-
scheduleSyncExpandedOverlayLayout();
|
|
524
|
-
});
|
|
525
|
-
resizeObserver.observe(scrollContainer);
|
|
526
|
-
resizeObserver.observe(overlayElement);
|
|
527
|
-
return () => {
|
|
528
|
-
scrollContainer.removeEventListener("scroll", scheduleSyncExpandedOverlayLayout);
|
|
529
|
-
window.removeEventListener("resize", scheduleSyncExpandedOverlayLayout);
|
|
530
|
-
resizeObserver.disconnect();
|
|
472
|
+
const container = scrollContainerRef.current;
|
|
473
|
+
if (!container) return;
|
|
474
|
+
const measure = () => {
|
|
475
|
+
setScrollContainerClientWidth((currentWidth) => currentWidth === container.clientWidth ? currentWidth : container.clientWidth);
|
|
531
476
|
};
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
477
|
+
measure();
|
|
478
|
+
if (typeof ResizeObserver === "undefined") {
|
|
479
|
+
window.addEventListener("resize", measure);
|
|
480
|
+
return () => window.removeEventListener("resize", measure);
|
|
481
|
+
}
|
|
482
|
+
const resizeObserver = new ResizeObserver(measure);
|
|
483
|
+
resizeObserver.observe(container);
|
|
484
|
+
return () => resizeObserver.disconnect();
|
|
485
|
+
}, []);
|
|
537
486
|
useEffect(() => {
|
|
538
487
|
const container = scrollContainerRef.current;
|
|
539
488
|
if (!container || !fetchNextPage) return;
|
|
@@ -581,26 +530,19 @@ function InfiniteTable(props) {
|
|
|
581
530
|
}
|
|
582
531
|
return false;
|
|
583
532
|
};
|
|
584
|
-
queueWheelScrollRef.current = queueWheelScroll;
|
|
585
533
|
const onWheel = (e) => {
|
|
586
534
|
queueWheelScroll(e.deltaX, e.deltaY);
|
|
587
535
|
};
|
|
588
536
|
container.addEventListener("wheel", onWheel, { passive: true });
|
|
589
537
|
return () => {
|
|
590
|
-
queueWheelScrollRef.current = null;
|
|
591
538
|
container.removeEventListener("wheel", onWheel);
|
|
592
539
|
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
593
540
|
};
|
|
594
541
|
}, [isFetchingNextPage]);
|
|
595
|
-
const handleExpandedOverlayWheel = useCallback((event) => {
|
|
596
|
-
if (queueWheelScrollRef.current?.(event.deltaX, event.deltaY) ?? false) {
|
|
597
|
-
event.preventDefault();
|
|
598
|
-
event.stopPropagation();
|
|
599
|
-
}
|
|
600
|
-
}, []);
|
|
601
542
|
const renderLoadingRows = () => {
|
|
602
543
|
return Array.from({ length: loadingRowCount }).map((_, rowIndex) => /* @__PURE__ */ jsx(LoadingRowWrapper, {
|
|
603
544
|
$density: density,
|
|
545
|
+
$variant: variant,
|
|
604
546
|
children: resolvedColumns.map((col) => /* @__PURE__ */ jsx(TableDataCell, {
|
|
605
547
|
$width: col.size,
|
|
606
548
|
$minWidth: col.minSize,
|
|
@@ -609,6 +551,7 @@ function InfiniteTable(props) {
|
|
|
609
551
|
$pinnedOffset: pinnedOffsets.get(col.id),
|
|
610
552
|
$align: col.align,
|
|
611
553
|
$density: density,
|
|
554
|
+
$variant: variant,
|
|
612
555
|
children: col.cellLoading ? col.cellLoading() : null
|
|
613
556
|
}, col.id))
|
|
614
557
|
}, `loading-${rowIndex}`));
|
|
@@ -617,95 +560,91 @@ function InfiniteTable(props) {
|
|
|
617
560
|
const showLoading = isLoading && data.length === 0;
|
|
618
561
|
const showError = isError && data.length === 0;
|
|
619
562
|
return /* @__PURE__ */ jsxs(TableOuterContainer, {
|
|
620
|
-
ref: outerContainerRef,
|
|
621
563
|
$width: width,
|
|
622
564
|
$height: height,
|
|
623
565
|
$fillWidth: fillWidth,
|
|
624
566
|
$fillHeight: fillHeight,
|
|
625
|
-
children: [
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
567
|
+
children: [/* @__PURE__ */ jsx(TableScrollContainer, {
|
|
568
|
+
ref: scrollContainerRef,
|
|
569
|
+
$noLastRowPadding: noLastRowPadding,
|
|
570
|
+
children: /* @__PURE__ */ jsxs(StyledTable, { children: [!noHeader && /* @__PURE__ */ jsx(TableHead, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableHeaderRow, { children: headerGroup.headers.map((header) => {
|
|
571
|
+
const columnMeta = header.column.columnDef.meta;
|
|
572
|
+
const canSort = header.column.getCanSort();
|
|
573
|
+
return /* @__PURE__ */ jsx(TableHeaderCell, {
|
|
574
|
+
$width: header.column.columnDef.size,
|
|
575
|
+
$minWidth: header.column.columnDef.minSize,
|
|
576
|
+
$maxWidth: header.column.columnDef.maxSize,
|
|
577
|
+
$pin: columnMeta?.pin,
|
|
578
|
+
$pinnedOffset: pinnedOffsets.get(header.column.id),
|
|
579
|
+
$align: columnMeta?.align,
|
|
580
|
+
$isSortable: canSort,
|
|
581
|
+
$density: density,
|
|
582
|
+
$variant: variant,
|
|
583
|
+
$isExpandCell: header.column.id === EXPAND_COLUMN_ID,
|
|
584
|
+
onClick: canSort ? header.column.getToggleSortingHandler() : void 0,
|
|
585
|
+
children: /* @__PURE__ */ jsxs(HeaderContentWrapper, { children: [flexRender(header.column.columnDef.header, header.getContext()), canSort && /* @__PURE__ */ jsx(SortIconWrapper, { children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(Icon, {
|
|
586
|
+
component: SortAscendingIcon,
|
|
587
|
+
size: 12,
|
|
588
|
+
variant: IconVariant.TERTIARY
|
|
589
|
+
}) : header.column.getIsSorted() === "desc" ? /* @__PURE__ */ jsx(Icon, {
|
|
590
|
+
component: SortDescendingIcon,
|
|
591
|
+
size: 12,
|
|
592
|
+
variant: IconVariant.TERTIARY
|
|
593
|
+
}) : /* @__PURE__ */ jsx(Icon, {
|
|
594
|
+
component: CaretUpDownIcon,
|
|
595
|
+
size: 12,
|
|
596
|
+
variant: IconVariant.TERTIARY
|
|
597
|
+
}) })] })
|
|
598
|
+
}, header.id);
|
|
599
|
+
}) }, headerGroup.id)) }), /* @__PURE__ */ jsxs(TableBody, { children: [showLoading ? renderLoadingRows() : showError ? /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", {
|
|
600
|
+
colSpan: resolvedColumns.length,
|
|
601
|
+
children: typeof contentWhenError === "function" ? contentWhenError() : contentWhenError ?? /* @__PURE__ */ jsx(Text, {
|
|
602
|
+
variant: TextVariant.ERROR,
|
|
603
|
+
children: "Error loading data"
|
|
604
|
+
})
|
|
605
|
+
}) }) : rows.map((row, index) => {
|
|
606
|
+
const isSelected = row.getIsSelected();
|
|
607
|
+
const isExpanded = onRowExpand !== void 0 && row.id === expandedRowId;
|
|
608
|
+
const isLastRow = index === rows.length - 1;
|
|
609
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(TableRow, {
|
|
610
|
+
$isClickable: !!onRowClick,
|
|
611
|
+
$isSelected: isSelected,
|
|
612
|
+
$density: density,
|
|
613
|
+
$variant: variant,
|
|
614
|
+
$isExpanded: isExpanded,
|
|
615
|
+
$isLastRow: noLastRowBorder && isLastRow && !isExpanded,
|
|
616
|
+
onClick: onRowClick ? (e) => onRowClick(row, e) : void 0,
|
|
617
|
+
onDoubleClick: onRowDoubleClick ? (e) => onRowDoubleClick(row, e) : void 0,
|
|
618
|
+
children: row.getVisibleCells().map((cell) => {
|
|
619
|
+
const columnMeta = cell.column.columnDef.meta;
|
|
620
|
+
return /* @__PURE__ */ jsx(TableDataCell, {
|
|
621
|
+
$width: cell.column.columnDef.size,
|
|
622
|
+
$minWidth: cell.column.columnDef.minSize,
|
|
623
|
+
$maxWidth: cell.column.columnDef.maxSize,
|
|
624
|
+
$pin: columnMeta?.pin,
|
|
625
|
+
$pinnedOffset: pinnedOffsets.get(cell.column.id),
|
|
626
|
+
$align: columnMeta?.align,
|
|
627
|
+
$density: density,
|
|
628
|
+
$variant: variant,
|
|
629
|
+
$isExpandCell: cell.column.id === EXPAND_COLUMN_ID,
|
|
630
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
631
|
+
}, cell.id);
|
|
662
632
|
})
|
|
663
|
-
})
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
$isExpanded: isExpanded,
|
|
673
|
-
$isLastRow: noLastRowBorder && isLastRow && !isExpanded,
|
|
674
|
-
onClick: onRowClick ? (e) => onRowClick(row, e) : void 0,
|
|
675
|
-
onDoubleClick: onRowDoubleClick ? (e) => onRowDoubleClick(row, e) : void 0,
|
|
676
|
-
children: row.getVisibleCells().map((cell) => {
|
|
677
|
-
const columnMeta = cell.column.columnDef.meta;
|
|
678
|
-
return /* @__PURE__ */ jsx(TableDataCell, {
|
|
679
|
-
$width: cell.column.columnDef.size,
|
|
680
|
-
$minWidth: cell.column.columnDef.minSize,
|
|
681
|
-
$maxWidth: cell.column.columnDef.maxSize,
|
|
682
|
-
$pin: columnMeta?.pin,
|
|
683
|
-
$pinnedOffset: pinnedOffsets.get(cell.column.id),
|
|
684
|
-
$align: columnMeta?.align,
|
|
685
|
-
$density: density,
|
|
686
|
-
$isExpandCell: cell.column.id === EXPAND_COLUMN_ID,
|
|
687
|
-
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
688
|
-
}, cell.id);
|
|
633
|
+
}), isExpanded && onRowExpand && /* @__PURE__ */ jsx(ExpandedRow, {
|
|
634
|
+
$minWidth: totalColumnMinWidth,
|
|
635
|
+
children: /* @__PURE__ */ jsx(ExpandedRowCell, {
|
|
636
|
+
colSpan: resolvedColumns.length,
|
|
637
|
+
$variant: variant,
|
|
638
|
+
$isLastRow: noLastRowBorder && isLastRow,
|
|
639
|
+
children: /* @__PURE__ */ jsxs(ExpandedViewport, {
|
|
640
|
+
$width: scrollContainerClientWidth ?? void 0,
|
|
641
|
+
children: [/* @__PURE__ */ jsx(ExpandedGutter, { $variant: variant }), /* @__PURE__ */ jsx(ExpandedBody, { children: /* @__PURE__ */ jsx(ExpandedContent, { children: onRowExpand(row) }) })]
|
|
689
642
|
})
|
|
690
|
-
})
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
}), isFetchingNextPage && renderLoadingRows()] })] })
|
|
695
|
-
}),
|
|
696
|
-
expandedRow && onRowExpand && /* @__PURE__ */ jsx(ExpandedOverlayLayer, { children: /* @__PURE__ */ jsxs(ExpandedOverlay, {
|
|
697
|
-
ref: expandedOverlayRef,
|
|
698
|
-
$isLastRow: noLastRowBorder && isExpandedRowLast,
|
|
699
|
-
$left: expandedOverlayLayout?.left ?? 0,
|
|
700
|
-
$top: expandedOverlayLayout?.top ?? 0,
|
|
701
|
-
$width: expandedOverlayLayout?.width ?? scrollContainerRef.current?.clientWidth ?? 0,
|
|
702
|
-
onWheel: handleExpandedOverlayWheel,
|
|
703
|
-
style: { visibility: expandedOverlayLayout ? "visible" : "hidden" },
|
|
704
|
-
children: [/* @__PURE__ */ jsx(ExpandedGutter, {}), /* @__PURE__ */ jsx(ExpandedBody, { children: /* @__PURE__ */ jsx(ExpandedContent, { children: onRowExpand(expandedRow) }) })]
|
|
705
|
-
}) }),
|
|
706
|
-
isEmpty && contentWhenEmpty && /* @__PURE__ */ jsx(EmptyContentWrapper, { children: contentWhenEmpty })
|
|
707
|
-
]
|
|
643
|
+
})
|
|
644
|
+
})] }, row.id);
|
|
645
|
+
}), isFetchingNextPage && renderLoadingRows()] })] })
|
|
646
|
+
}), isEmpty && contentWhenEmpty && /* @__PURE__ */ jsx(EmptyContentWrapper, { children: contentWhenEmpty })]
|
|
708
647
|
});
|
|
709
648
|
}
|
|
710
649
|
//#endregion
|
|
711
|
-
export { ColumnAlign, ColumnPin, TableDensity, InfiniteTable as default, estimateColumnWidth };
|
|
650
|
+
export { ColumnAlign, ColumnPin, TableDensity, TableVariant, InfiniteTable as default, estimateColumnWidth };
|