@galaxy-io/dls 1.2.0 → 1.2.1
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,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;
|
|
@@ -11,6 +11,13 @@ 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",
|
|
@@ -297,7 +313,7 @@ var ExpandedOverlayLayer = /*#__PURE__*/ styled("div")({
|
|
|
297
313
|
var _exp39 = () => ({ $top }) => `${$top}px`;
|
|
298
314
|
var _exp40 = () => ({ $left }) => `${$left}px`;
|
|
299
315
|
var _exp41 = () => ({ $width }) => `${$width}px`;
|
|
300
|
-
var _exp43 = () => ({ theme }) => theme
|
|
316
|
+
var _exp43 = () => ({ $variant, theme }) => getVariantBackgroundColor(theme, $variant);
|
|
301
317
|
var _exp44 = () => ({ $isLastRow, theme }) => $isLastRow ? "none" : `0.5px solid ${theme.color.border.primary}`;
|
|
302
318
|
var ExpandedOverlay = withTheme(/*#__PURE__*/ styled("div")({
|
|
303
319
|
name: "ExpandedOverlay",
|
|
@@ -311,7 +327,7 @@ var ExpandedOverlay = withTheme(/*#__PURE__*/ styled("div")({
|
|
|
311
327
|
"e1birhg7-4": [_exp44()]
|
|
312
328
|
}
|
|
313
329
|
}));
|
|
314
|
-
var _exp45 = () => ({ theme }) => theme
|
|
330
|
+
var _exp45 = () => ({ $variant, theme }) => getVariantBackgroundColor(theme, $variant);
|
|
315
331
|
var _exp46 = () => ({ theme }) => theme.color.border.primary;
|
|
316
332
|
var ExpandedGutter = withTheme(/*#__PURE__*/ styled("div")({
|
|
317
333
|
name: "ExpandedGutter",
|
|
@@ -335,7 +351,7 @@ var ExpandedContent = /*#__PURE__*/ styled("div")({
|
|
|
335
351
|
propsAsIs: false
|
|
336
352
|
});
|
|
337
353
|
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;
|
|
354
|
+
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;
|
|
339
355
|
const outerContainerRef = useRef(null);
|
|
340
356
|
const scrollContainerRef = useRef(null);
|
|
341
357
|
const expandedOverlayRef = useRef(null);
|
|
@@ -601,6 +617,7 @@ function InfiniteTable(props) {
|
|
|
601
617
|
const renderLoadingRows = () => {
|
|
602
618
|
return Array.from({ length: loadingRowCount }).map((_, rowIndex) => /* @__PURE__ */ jsx(LoadingRowWrapper, {
|
|
603
619
|
$density: density,
|
|
620
|
+
$variant: variant,
|
|
604
621
|
children: resolvedColumns.map((col) => /* @__PURE__ */ jsx(TableDataCell, {
|
|
605
622
|
$width: col.size,
|
|
606
623
|
$minWidth: col.minSize,
|
|
@@ -609,6 +626,7 @@ function InfiniteTable(props) {
|
|
|
609
626
|
$pinnedOffset: pinnedOffsets.get(col.id),
|
|
610
627
|
$align: col.align,
|
|
611
628
|
$density: density,
|
|
629
|
+
$variant: variant,
|
|
612
630
|
children: col.cellLoading ? col.cellLoading() : null
|
|
613
631
|
}, col.id))
|
|
614
632
|
}, `loading-${rowIndex}`));
|
|
@@ -638,6 +656,7 @@ function InfiniteTable(props) {
|
|
|
638
656
|
$align: columnMeta?.align,
|
|
639
657
|
$isSortable: canSort,
|
|
640
658
|
$density: density,
|
|
659
|
+
$variant: variant,
|
|
641
660
|
$isExpandCell: header.column.id === EXPAND_COLUMN_ID,
|
|
642
661
|
onClick: canSort ? header.column.getToggleSortingHandler() : void 0,
|
|
643
662
|
children: /* @__PURE__ */ jsxs(HeaderContentWrapper, { children: [flexRender(header.column.columnDef.header, header.getContext()), canSort && /* @__PURE__ */ jsx(SortIconWrapper, { children: header.column.getIsSorted() === "asc" ? /* @__PURE__ */ jsx(Icon, {
|
|
@@ -669,6 +688,7 @@ function InfiniteTable(props) {
|
|
|
669
688
|
$isClickable: !!onRowClick,
|
|
670
689
|
$isSelected: isSelected,
|
|
671
690
|
$density: density,
|
|
691
|
+
$variant: variant,
|
|
672
692
|
$isExpanded: isExpanded,
|
|
673
693
|
$isLastRow: noLastRowBorder && isLastRow && !isExpanded,
|
|
674
694
|
onClick: onRowClick ? (e) => onRowClick(row, e) : void 0,
|
|
@@ -683,6 +703,7 @@ function InfiniteTable(props) {
|
|
|
683
703
|
$pinnedOffset: pinnedOffsets.get(cell.column.id),
|
|
684
704
|
$align: columnMeta?.align,
|
|
685
705
|
$density: density,
|
|
706
|
+
$variant: variant,
|
|
686
707
|
$isExpandCell: cell.column.id === EXPAND_COLUMN_ID,
|
|
687
708
|
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
688
709
|
}, cell.id);
|
|
@@ -699,13 +720,14 @@ function InfiniteTable(props) {
|
|
|
699
720
|
$left: expandedOverlayLayout?.left ?? 0,
|
|
700
721
|
$top: expandedOverlayLayout?.top ?? 0,
|
|
701
722
|
$width: expandedOverlayLayout?.width ?? scrollContainerRef.current?.clientWidth ?? 0,
|
|
723
|
+
$variant: variant,
|
|
702
724
|
onWheel: handleExpandedOverlayWheel,
|
|
703
725
|
style: { visibility: expandedOverlayLayout ? "visible" : "hidden" },
|
|
704
|
-
children: [/* @__PURE__ */ jsx(ExpandedGutter, {}), /* @__PURE__ */ jsx(ExpandedBody, { children: /* @__PURE__ */ jsx(ExpandedContent, { children: onRowExpand(expandedRow) }) })]
|
|
726
|
+
children: [/* @__PURE__ */ jsx(ExpandedGutter, { $variant: variant }), /* @__PURE__ */ jsx(ExpandedBody, { children: /* @__PURE__ */ jsx(ExpandedContent, { children: onRowExpand(expandedRow) }) })]
|
|
705
727
|
}) }),
|
|
706
728
|
isEmpty && contentWhenEmpty && /* @__PURE__ */ jsx(EmptyContentWrapper, { children: contentWhenEmpty })
|
|
707
729
|
]
|
|
708
730
|
});
|
|
709
731
|
}
|
|
710
732
|
//#endregion
|
|
711
|
-
export { ColumnAlign, ColumnPin, TableDensity, InfiniteTable as default, estimateColumnWidth };
|
|
733
|
+
export { ColumnAlign, ColumnPin, TableDensity, TableVariant, InfiniteTable as default, estimateColumnWidth };
|