@dmsi/wedgekit-react 0.0.82 → 0.0.84
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/{chunk-6R2HCLEL.js → chunk-37TJJQL3.js} +2 -2
- package/dist/{chunk-B6PDZCU7.js → chunk-5GUW4DUY.js} +1 -1
- package/dist/{chunk-ATOEGP3V.js → chunk-CKSDMI2Q.js} +14 -7
- package/dist/{chunk-2DCVAATK.js → chunk-MQWWNAO3.js} +4 -4
- package/dist/{chunk-FOC6LTSX.js → chunk-UPBBOZM3.js} +1 -1
- package/dist/{chunk-SWA5WVQO.js → chunk-WNQ53SVY.js} +30 -0
- package/dist/components/DataGridCell.cjs +53 -43
- package/dist/components/DataGridCell.js +5 -5
- package/dist/components/Menu.cjs +17 -14
- package/dist/components/Menu.js +3 -3
- package/dist/components/MenuOption.cjs +10 -7
- package/dist/components/MenuOption.js +2 -2
- package/dist/components/Modal.cjs +18 -15
- package/dist/components/Modal.js +3 -3
- package/dist/components/NestedMenu.cjs +12 -9
- package/dist/components/NestedMenu.js +2 -2
- package/dist/components/PDFViewer.cjs +21 -18
- package/dist/components/PDFViewer.js +3 -3
- package/dist/components/ProjectBar.cjs +6 -3
- package/dist/components/ProjectBar.js +1 -1
- package/dist/components/TopBar.cjs +1 -1
- package/dist/components/TopBar.js +1 -1
- package/dist/components/{DataGrid.cjs → index.cjs} +1424 -1335
- package/dist/components/{DataGrid.js → index.js} +948 -883
- package/dist/components/useMenuSystem.cjs +20 -17
- package/dist/components/useMenuSystem.js +2 -2
- package/dist/hooks/index.cjs +34 -3
- package/dist/hooks/index.js +3 -1
- package/package.json +6 -1
- package/src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx +32 -0
- package/src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx +66 -0
- package/src/components/DataGrid/PinnedColumns.tsx +145 -0
- package/src/components/DataGrid/TableBody/LoadingCell.tsx +40 -0
- package/src/components/DataGrid/TableBody/TableBodyRow.tsx +129 -0
- package/src/components/DataGrid/TableBody/index.tsx +159 -0
- package/src/components/{DataGrid.tsx → DataGrid/index.tsx} +42 -678
- package/src/components/DataGrid/types.ts +86 -0
- package/src/components/DataGrid/utils.tsx +15 -0
- package/src/components/DataGridCell.tsx +37 -21
- package/src/components/TopBar.tsx +1 -1
- package/src/components/index.ts +20 -0
- package/src/hooks/index.ts +1 -0
- package/dist/chunk-AWQSSKCK.js +0 -32
- package/dist/components/useInfiniteScroll.cjs +0 -57
- package/dist/components/useInfiniteScroll.js +0 -8
- /package/src/{components → hooks}/useInfiniteScroll.tsx +0 -0
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
useInfiniteScroll
|
|
4
|
-
} from "../chunk-AWQSSKCK.js";
|
|
5
1
|
import {
|
|
6
2
|
Tooltip
|
|
7
3
|
} from "../chunk-QZGUMB7T.js";
|
|
@@ -16,15 +12,17 @@ import {
|
|
|
16
12
|
DataGridCell,
|
|
17
13
|
DragAlongCell,
|
|
18
14
|
DraggableCellHeader
|
|
19
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-CKSDMI2Q.js";
|
|
20
16
|
import {
|
|
21
17
|
Menu
|
|
22
|
-
} from "../chunk-
|
|
23
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-37TJJQL3.js";
|
|
19
|
+
import "../chunk-5GUW4DUY.js";
|
|
24
20
|
import {
|
|
25
21
|
MenuOption
|
|
26
|
-
} from "../chunk-
|
|
27
|
-
import
|
|
22
|
+
} from "../chunk-UPBBOZM3.js";
|
|
23
|
+
import {
|
|
24
|
+
useInfiniteScroll
|
|
25
|
+
} from "../chunk-WNQ53SVY.js";
|
|
28
26
|
import {
|
|
29
27
|
Search
|
|
30
28
|
} from "../chunk-LP6AZST2.js";
|
|
@@ -58,18 +56,15 @@ import {
|
|
|
58
56
|
__spreadValues
|
|
59
57
|
} from "../chunk-ORMEWXMH.js";
|
|
60
58
|
|
|
61
|
-
// src/components/DataGrid.tsx
|
|
62
|
-
import
|
|
59
|
+
// src/components/DataGrid/index.tsx
|
|
60
|
+
import React3, { useCallback, useId, useState as useState3 } from "react";
|
|
63
61
|
import {
|
|
64
|
-
flexRender,
|
|
62
|
+
flexRender as flexRender3,
|
|
65
63
|
getCoreRowModel,
|
|
66
64
|
getFilteredRowModel,
|
|
67
65
|
getSortedRowModel,
|
|
68
66
|
useReactTable
|
|
69
67
|
} from "@tanstack/react-table";
|
|
70
|
-
import {
|
|
71
|
-
useVirtualizer
|
|
72
|
-
} from "@tanstack/react-virtual";
|
|
73
68
|
import {
|
|
74
69
|
closestCenter,
|
|
75
70
|
DndContext,
|
|
@@ -85,914 +80,984 @@ import {
|
|
|
85
80
|
SortableContext
|
|
86
81
|
} from "@dnd-kit/sortable";
|
|
87
82
|
import { restrictToHorizontalAxis } from "@dnd-kit/modifiers";
|
|
83
|
+
import { useVirtualizer as useVirtualizer2 } from "@tanstack/react-virtual";
|
|
84
|
+
import clsx5 from "clsx";
|
|
85
|
+
|
|
86
|
+
// src/components/DataGrid/PinnedColumns.tsx
|
|
87
|
+
import { flexRender as flexRender2 } from "@tanstack/react-table";
|
|
88
|
+
import clsx4 from "clsx";
|
|
89
|
+
|
|
90
|
+
// src/components/DataGrid/utils.tsx
|
|
88
91
|
import clsx from "clsx";
|
|
89
|
-
import { jsx
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
97
|
-
|
|
92
|
+
import { jsx } from "react/jsx-runtime";
|
|
93
|
+
function getSortIcon(sort, nextSort = false) {
|
|
94
|
+
const iconClassName = clsx(
|
|
95
|
+
"text-icon-on-action-primary-normal",
|
|
96
|
+
nextSort && "hidden group-hover:block"
|
|
97
|
+
);
|
|
98
|
+
if (sort === "asc")
|
|
99
|
+
return /* @__PURE__ */ jsx(Icon, { size: 16, className: iconClassName, name: "arrow_upward" });
|
|
100
|
+
if (sort === "desc")
|
|
101
|
+
return /* @__PURE__ */ jsx(Icon, { size: 16, className: iconClassName, name: "arrow_downward" });
|
|
102
|
+
return null;
|
|
98
103
|
}
|
|
99
|
-
|
|
104
|
+
|
|
105
|
+
// src/components/DataGrid/PinnedColumns.tsx
|
|
106
|
+
import React2 from "react";
|
|
107
|
+
|
|
108
|
+
// src/components/DataGrid/TableBody/index.tsx
|
|
109
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
110
|
+
import clsx3 from "clsx";
|
|
111
|
+
|
|
112
|
+
// src/components/DataGrid/TableBody/TableBodyRow.tsx
|
|
113
|
+
import clsx2 from "clsx";
|
|
114
|
+
import { flexRender } from "@tanstack/react-table";
|
|
115
|
+
import React from "react";
|
|
116
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
117
|
+
function TableBodyRow({
|
|
100
118
|
id,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
showFilterRow
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
columnFilters: externalColumnFilters,
|
|
112
|
-
onColumnFiltersChange,
|
|
113
|
-
rowSelection: externalRowSelection,
|
|
114
|
-
onRowSelectionChange,
|
|
115
|
-
filteredSortedData,
|
|
116
|
-
totalRowCount,
|
|
117
|
-
hideStatusBar,
|
|
118
|
-
centerHeader,
|
|
119
|
-
enableColumnSelector,
|
|
120
|
-
predeterminedLeftPins = [],
|
|
121
|
-
predeterminedRightPins = []
|
|
119
|
+
columnVirtualizer,
|
|
120
|
+
row,
|
|
121
|
+
// rowVirtualizer,
|
|
122
|
+
virtualPaddingLeft,
|
|
123
|
+
virtualPaddingRight,
|
|
124
|
+
virtualRow,
|
|
125
|
+
showFilterRow,
|
|
126
|
+
enableColumnSelector = false,
|
|
127
|
+
locked,
|
|
128
|
+
pinDirection
|
|
122
129
|
}) {
|
|
123
|
-
var _a
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
130
|
+
var _a;
|
|
131
|
+
let visibleCells;
|
|
132
|
+
if (locked) {
|
|
133
|
+
visibleCells = pinDirection === "left" ? row.getLeftVisibleCells() : row.getRightVisibleCells();
|
|
134
|
+
} else {
|
|
135
|
+
visibleCells = row.getCenterVisibleCells();
|
|
136
|
+
}
|
|
137
|
+
const virtualColumns = (_a = columnVirtualizer == null ? void 0 : columnVirtualizer.getVirtualItems()) != null ? _a : [];
|
|
138
|
+
const columns = locked ? visibleCells : virtualColumns;
|
|
139
|
+
const isError = typeof row.original === "object" && row.original !== null && "rowState" in row.original && row.original.rowState === "error";
|
|
140
|
+
const CellElement = locked ? DataGridCell : DragAlongCell;
|
|
141
|
+
return /* @__PURE__ */ jsxs(
|
|
142
|
+
"tr",
|
|
143
|
+
{
|
|
144
|
+
className: clsx2(
|
|
145
|
+
"transition-colors hover:bg-background-action-secondary-hover",
|
|
146
|
+
row.getIsSelected() && "!bg-background-action-secondary-hover",
|
|
147
|
+
isError && "!bg-background-action-critical-secondary-hover",
|
|
148
|
+
showFilterRow ? "even:bg-background-grouped-primary-normal odd:bg-background-grouped-secondary-normal" : "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal"
|
|
149
|
+
),
|
|
150
|
+
style: {
|
|
151
|
+
display: "flex",
|
|
152
|
+
position: "absolute",
|
|
153
|
+
transform: `translateY(${showFilterRow ? virtualRow.start + 40 : virtualRow.start}px)`,
|
|
154
|
+
width: "100%"
|
|
155
|
+
},
|
|
156
|
+
children: [
|
|
157
|
+
!locked && virtualPaddingLeft ? (
|
|
158
|
+
// fake empty column to the left for virtualization scroll padding
|
|
159
|
+
/* @__PURE__ */ jsx2("td", { style: { display: "flex", width: virtualPaddingLeft } })
|
|
160
|
+
) : null,
|
|
161
|
+
columns.map((column) => {
|
|
162
|
+
var _a2, _b;
|
|
163
|
+
const cell = locked ? column : visibleCells[column.index];
|
|
164
|
+
if (!cell) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const cellValue = cell.getValue();
|
|
168
|
+
return ((_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.useCustomRenderer) ? /* @__PURE__ */ jsx2(React.Fragment, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ jsx2(
|
|
169
|
+
CellElement,
|
|
170
|
+
{
|
|
171
|
+
id: id ? `${id}-cell-${cell.id}` : void 0,
|
|
172
|
+
cell,
|
|
173
|
+
className: clsx2({
|
|
174
|
+
"justify-end": typeof cellValue === "number"
|
|
175
|
+
}),
|
|
176
|
+
width: (_b = cell.column.columnDef.meta) == null ? void 0 : _b.headerWidth,
|
|
177
|
+
children: /* @__PURE__ */ jsx2(
|
|
178
|
+
Tooltip,
|
|
179
|
+
{
|
|
180
|
+
id: id ? `${id}-tooltip-${cell.id}` : void 0,
|
|
181
|
+
showOnTruncation: true,
|
|
182
|
+
message: cellValue,
|
|
183
|
+
position: "bottom",
|
|
184
|
+
children: /* @__PURE__ */ jsx2(Paragraph, { addOverflow: true, tall: true, children: cellValue })
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
},
|
|
188
|
+
cell.id
|
|
189
|
+
);
|
|
190
|
+
}),
|
|
191
|
+
!locked && virtualPaddingRight ? (
|
|
192
|
+
// fake empty column to the right for virtualization scroll padding
|
|
193
|
+
/* @__PURE__ */ jsx2("td", { style: { display: "flex", width: virtualPaddingRight } })
|
|
194
|
+
) : null,
|
|
195
|
+
enableColumnSelector && !locked && /* @__PURE__ */ jsx2("td", { className: "p-2", style: { width: "48.8px" } })
|
|
196
|
+
]
|
|
162
197
|
},
|
|
163
|
-
|
|
198
|
+
row.id
|
|
164
199
|
);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
rowSelection,
|
|
193
|
-
columnVisibility
|
|
194
|
-
},
|
|
195
|
-
initialState: {
|
|
196
|
-
columnPinning: {
|
|
197
|
-
left: predeterminedLeftPins,
|
|
198
|
-
right: predeterminedRightPins
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
enableColumnPinning: (predeterminedLeftPins == null ? void 0 : predeterminedLeftPins.length) > 0 || predeterminedRightPins.length > 0,
|
|
202
|
-
onColumnOrderChange: setColumnOrder,
|
|
203
|
-
onSortingChange: adaptTableStateSetter(setSortingState),
|
|
204
|
-
onColumnFiltersChange: adaptTableStateSetter(setColumnFilterState),
|
|
205
|
-
onRowSelectionChange: adaptTableStateSetter(setRowSelection),
|
|
206
|
-
filterFns: {
|
|
207
|
-
startsWith: (row, columnId, filterValue) => {
|
|
208
|
-
const cellValue = row == null ? void 0 : row.getValue(columnId);
|
|
209
|
-
if (!cellValue || !filterValue) {
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
212
|
-
return String(cellValue).toLowerCase().startsWith(String(filterValue).toLowerCase());
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/components/DataGrid/TableBody/LoadingCell.tsx
|
|
203
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
204
|
+
function LoadingCell({
|
|
205
|
+
id,
|
|
206
|
+
column
|
|
207
|
+
}) {
|
|
208
|
+
const key = `loading-${column.id}`;
|
|
209
|
+
if (column.cell === "checkbox") {
|
|
210
|
+
return /* @__PURE__ */ jsx3(DataGridCell, { id: id ? `${id}-${key}` : void 0, children: /* @__PURE__ */ jsx3(Checkbox, { id: id ? `${id}-${key}-checkbox` : void 0, disabled: true }) }, key);
|
|
211
|
+
}
|
|
212
|
+
if (column.cell === "input") {
|
|
213
|
+
return /* @__PURE__ */ jsx3(
|
|
214
|
+
DataGridCell,
|
|
215
|
+
{
|
|
216
|
+
id: id ? `${id}-${key}` : void 0,
|
|
217
|
+
component: "input",
|
|
218
|
+
children: /* @__PURE__ */ jsx3(
|
|
219
|
+
Input,
|
|
220
|
+
{
|
|
221
|
+
id: id ? `${id}-${key}-input` : void 0,
|
|
222
|
+
align: "left",
|
|
223
|
+
disabled: true,
|
|
224
|
+
wrapperClassName: "!rounded-none !border-0"
|
|
225
|
+
}
|
|
226
|
+
)
|
|
213
227
|
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
key
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return /* @__PURE__ */ jsx3(DataGridCell, { id: id ? `${id}-${key}` : void 0, children: /* @__PURE__ */ jsx3("div", { className: "bg-linear-270 to-neutral-300/[24%] from-neutral-300/[12%] rounded-xs w-full max-w-25 h-6" }) }, key);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// src/components/DataGrid/TableBody/index.tsx
|
|
235
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
236
|
+
function TableBody({
|
|
237
|
+
id,
|
|
238
|
+
columnVirtualizer,
|
|
239
|
+
table,
|
|
240
|
+
tableContainerRef,
|
|
241
|
+
virtualPaddingLeft,
|
|
242
|
+
virtualPaddingRight,
|
|
243
|
+
pagination,
|
|
244
|
+
isLoadingMore,
|
|
245
|
+
hasMore,
|
|
246
|
+
showFilterRow,
|
|
247
|
+
enableColumnSelector = false,
|
|
248
|
+
locked,
|
|
249
|
+
pinDirection
|
|
250
|
+
}) {
|
|
251
|
+
const { rows } = table.getRowModel();
|
|
252
|
+
const rowVirtualizer = useVirtualizer({
|
|
253
|
+
count: rows.length,
|
|
254
|
+
estimateSize: () => 40,
|
|
255
|
+
getScrollElement: () => tableContainerRef.current,
|
|
256
|
+
overscan: 8
|
|
222
257
|
});
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
setRowSelection((prev) => {
|
|
233
|
-
const isSelecting = !allSelectedAcrossPages;
|
|
234
|
-
if (isSelecting) {
|
|
235
|
-
const newSelection = {};
|
|
236
|
-
for (const rowId of allRowIds) {
|
|
237
|
-
newSelection[rowId] = true;
|
|
238
|
-
}
|
|
239
|
-
return __spreadValues(__spreadValues({}, prev), newSelection);
|
|
240
|
-
} else {
|
|
241
|
-
const updatedSelection = __spreadValues({}, prev);
|
|
242
|
-
for (const rowId of allRowIds) {
|
|
243
|
-
delete updatedSelection[rowId];
|
|
244
|
-
}
|
|
245
|
-
return updatedSelection;
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
|
-
useInfiniteScroll({
|
|
250
|
-
containerRef,
|
|
251
|
-
onLoadMore: onLoadMore != null ? onLoadMore : () => {
|
|
252
|
-
},
|
|
253
|
-
isLoading: isLoadingMore,
|
|
254
|
-
enabled: !pagination
|
|
255
|
-
});
|
|
256
|
-
const handleDragEnd = (event) => {
|
|
257
|
-
const { active, over } = event;
|
|
258
|
-
if (active && over && active.id !== over.id) {
|
|
259
|
-
setColumnOrder((prev) => {
|
|
260
|
-
const oldIndex = prev.indexOf(active.id);
|
|
261
|
-
const newIndex = prev.indexOf(over.id);
|
|
262
|
-
return arrayMove(prev, oldIndex, newIndex);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
const sensors = useSensors(
|
|
267
|
-
useSensor(MouseSensor),
|
|
268
|
-
useSensor(TouchSensor),
|
|
269
|
-
useSensor(KeyboardSensor)
|
|
270
|
-
);
|
|
271
|
-
const visibleColumns = table.getVisibleLeafColumns();
|
|
272
|
-
const columnVirtualizer = useVirtualizer({
|
|
273
|
-
count: visibleColumns.length,
|
|
274
|
-
estimateSize: (index) => visibleColumns[index].getSize(),
|
|
275
|
-
//estimate width of each column for accurate scrollbar dragging
|
|
276
|
-
getScrollElement: () => containerRef.current,
|
|
277
|
-
horizontal: true,
|
|
278
|
-
overscan: 3
|
|
279
|
-
//how many columns to render on each side off screen each way
|
|
280
|
-
});
|
|
281
|
-
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
282
|
-
let virtualPaddingLeft;
|
|
283
|
-
let virtualPaddingRight;
|
|
284
|
-
if (columnVirtualizer && (virtualColumns == null ? void 0 : virtualColumns.length)) {
|
|
285
|
-
virtualPaddingLeft = (_c = (_b = virtualColumns[0]) == null ? void 0 : _b.start) != null ? _c : 0;
|
|
286
|
-
virtualPaddingRight = columnVirtualizer.getTotalSize() - ((_e = (_d = virtualColumns[virtualColumns.length - 1]) == null ? void 0 : _d.end) != null ? _e : 0);
|
|
258
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
259
|
+
const CellElement = locked ? DataGridCell : DragAlongCell;
|
|
260
|
+
let headerGroups;
|
|
261
|
+
if (pinDirection === "left") {
|
|
262
|
+
headerGroups = table.getLeftHeaderGroups();
|
|
263
|
+
} else if (pinDirection === "right") {
|
|
264
|
+
headerGroups = table.getRightHeaderGroups();
|
|
265
|
+
} else {
|
|
266
|
+
headerGroups = table.getCenterHeaderGroups();
|
|
287
267
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
DndContext,
|
|
268
|
+
return /* @__PURE__ */ jsxs2(
|
|
269
|
+
"tbody",
|
|
291
270
|
{
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
271
|
+
className: clsx3(locked ? "shadow-16" : ""),
|
|
272
|
+
style: {
|
|
273
|
+
display: "grid",
|
|
274
|
+
height: `${showFilterRow ? rowVirtualizer.getTotalSize() + 40 : rowVirtualizer.getTotalSize()}px`,
|
|
275
|
+
// tells scrollbar how big the table is
|
|
276
|
+
position: "relative"
|
|
277
|
+
// needed for absolute positioning of rows
|
|
278
|
+
},
|
|
279
|
+
children: [
|
|
280
|
+
showFilterRow && /* @__PURE__ */ jsx4(
|
|
281
|
+
"tr",
|
|
282
|
+
{
|
|
283
|
+
style: {
|
|
284
|
+
display: "flex",
|
|
285
|
+
position: "sticky",
|
|
286
|
+
top: "40px",
|
|
287
|
+
width: "100%",
|
|
288
|
+
height: "40px",
|
|
289
|
+
zIndex: 10
|
|
290
|
+
},
|
|
291
|
+
className: "even:bg-background-grouped-primary-normal odd:bg-background-grouped-secondary-normal",
|
|
292
|
+
children: headerGroups.flatMap(
|
|
293
|
+
(x) => x.headers.map((header) => {
|
|
294
|
+
var _a, _b, _c, _d, _e;
|
|
295
|
+
return /* @__PURE__ */ jsx4(
|
|
296
|
+
CellElement,
|
|
297
|
+
{
|
|
298
|
+
id: id ? `${id}-filter-cell-${header.id}` : void 0,
|
|
299
|
+
noPadding: true,
|
|
300
|
+
cell: header,
|
|
301
|
+
width: ((_a = header.column.columnDef.meta) == null ? void 0 : _a.headerWidth) || (locked ? `${header.column.getSize()}px` : ""),
|
|
302
|
+
children: header.column.getCanFilter() && ((_e = (_c = (_b = header.column.columnDef.meta) == null ? void 0 : _b.filterRowCell) == null ? void 0 : _c.call(_b, {
|
|
303
|
+
header,
|
|
304
|
+
table
|
|
305
|
+
})) != null ? _e : /* @__PURE__ */ jsx4(
|
|
306
|
+
Search,
|
|
307
|
+
{
|
|
308
|
+
id: id ? `${id}-filter-search-${header.id}` : void 0,
|
|
309
|
+
removeRoundness: true,
|
|
310
|
+
onChange: (e) => header.column.setFilterValue(e.target.value),
|
|
311
|
+
value: (_d = header.column.getFilterValue()) != null ? _d : "",
|
|
312
|
+
placeholder: "",
|
|
313
|
+
removeSearchIcon: true
|
|
314
|
+
}
|
|
315
|
+
))
|
|
316
|
+
},
|
|
317
|
+
header.id
|
|
318
|
+
);
|
|
319
|
+
})
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
),
|
|
323
|
+
virtualRows.map((virtualRow) => {
|
|
324
|
+
const row = rows[virtualRow.index];
|
|
325
|
+
return /* @__PURE__ */ jsx4(
|
|
326
|
+
TableBodyRow,
|
|
304
327
|
{
|
|
305
328
|
id,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
329
|
+
columnVirtualizer,
|
|
330
|
+
row,
|
|
331
|
+
rowVirtualizer,
|
|
332
|
+
virtualPaddingLeft,
|
|
333
|
+
virtualPaddingRight,
|
|
334
|
+
virtualRow,
|
|
335
|
+
showFilterRow,
|
|
336
|
+
enableColumnSelector,
|
|
337
|
+
locked,
|
|
338
|
+
pinDirection
|
|
339
|
+
},
|
|
340
|
+
row.id
|
|
341
|
+
);
|
|
342
|
+
}),
|
|
343
|
+
!pagination && isLoadingMore && hasMore && /* @__PURE__ */ jsx4(
|
|
344
|
+
"tr",
|
|
345
|
+
{
|
|
346
|
+
style: {
|
|
347
|
+
display: "flex",
|
|
348
|
+
position: "absolute",
|
|
349
|
+
width: "100%",
|
|
350
|
+
transform: `translateY(${virtualRows[virtualRows.length - 1].start + 40}px)`
|
|
351
|
+
},
|
|
352
|
+
className: "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal",
|
|
353
|
+
children: table.getAllLeafColumns().map((column) => /* @__PURE__ */ jsx4(LoadingCell, { id, column: column.columnDef }, column.id))
|
|
354
|
+
}
|
|
355
|
+
)
|
|
356
|
+
]
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/components/DataGrid/PinnedColumns.tsx
|
|
362
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
363
|
+
function PinnedColumns(_a) {
|
|
364
|
+
var _b = _a, {
|
|
365
|
+
pinDirection = "left",
|
|
366
|
+
table,
|
|
367
|
+
centerHeader,
|
|
368
|
+
allSelectedAcrossPages,
|
|
369
|
+
someSelectedAcrossPages,
|
|
370
|
+
toggleSelectAllAcrossPages
|
|
371
|
+
} = _b, props = __objRest(_b, [
|
|
372
|
+
"pinDirection",
|
|
373
|
+
"table",
|
|
374
|
+
"centerHeader",
|
|
375
|
+
"allSelectedAcrossPages",
|
|
376
|
+
"someSelectedAcrossPages",
|
|
377
|
+
"toggleSelectAllAcrossPages"
|
|
378
|
+
]);
|
|
379
|
+
var _a2;
|
|
380
|
+
const headerGroups = pinDirection === "left" ? table.getLeftHeaderGroups() : table.getRightHeaderGroups();
|
|
381
|
+
return ((_a2 = headerGroups[0]) == null ? void 0 : _a2.headers.length) > 0 && /* @__PURE__ */ jsxs3(
|
|
382
|
+
"table",
|
|
383
|
+
{
|
|
384
|
+
className: clsx4(
|
|
385
|
+
"flex flex-col min-h-min sticky z-20 bg-background-grouped-primary-normal",
|
|
386
|
+
pinDirection === "left" ? "left-0" : "right-0"
|
|
387
|
+
),
|
|
388
|
+
children: [
|
|
389
|
+
/* @__PURE__ */ jsx5("thead", { className: "sticky top-0 z-20 grid", children: headerGroups.map((headerGroup) => {
|
|
390
|
+
return /* @__PURE__ */ jsx5("tr", { className: "flex w-full", children: headerGroup.headers.map((header) => {
|
|
391
|
+
var _a3, _b2, _c;
|
|
392
|
+
if (!header) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
if (typeof header.column.columnDef.header === "string") {
|
|
396
|
+
const customHeaderWidth = (_a3 = header.column.columnDef.meta) == null ? void 0 : _a3.headerWidth;
|
|
397
|
+
return /* @__PURE__ */ jsxs3(
|
|
398
|
+
DataCellHeader,
|
|
399
|
+
{
|
|
400
|
+
locked: true,
|
|
401
|
+
header,
|
|
402
|
+
center: centerHeader,
|
|
403
|
+
width: customHeaderWidth,
|
|
404
|
+
className: clsx4(
|
|
405
|
+
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
406
|
+
"group"
|
|
407
|
+
),
|
|
408
|
+
children: [
|
|
409
|
+
/* @__PURE__ */ jsx5(Subheader, { tall: true, children: header.column.columnDef.header }),
|
|
410
|
+
getSortIcon(header.column.getIsSorted()),
|
|
411
|
+
!header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
|
|
412
|
+
header.column.getNextSortingOrder(),
|
|
413
|
+
true
|
|
314
414
|
),
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
{
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
)
|
|
340
|
-
) : null,
|
|
341
|
-
virtualColumns.map((virtualColumn) => {
|
|
342
|
-
var _a2, _b2, _c2, _d2;
|
|
343
|
-
const header = headerGroup.headers[virtualColumn.index];
|
|
344
|
-
if (!header) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (typeof header.column.columnDef.header === "string") {
|
|
348
|
-
const customHeaderWidth = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth;
|
|
349
|
-
return /* @__PURE__ */ jsxs(
|
|
350
|
-
DraggableCellHeader,
|
|
351
|
-
{
|
|
352
|
-
id: id ? `${id}-header-${header.id}` : void 0,
|
|
353
|
-
header,
|
|
354
|
-
locked: (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked,
|
|
355
|
-
center: centerHeader,
|
|
356
|
-
width: customHeaderWidth,
|
|
357
|
-
className: clsx(
|
|
358
|
-
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
359
|
-
"group"
|
|
360
|
-
),
|
|
361
|
-
children: [
|
|
362
|
-
/* @__PURE__ */ jsx(Subheader, { tall: true, children: header.column.columnDef.header }),
|
|
363
|
-
getSortIcon(header.column.getIsSorted()),
|
|
364
|
-
!header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
|
|
365
|
-
header.column.getNextSortingOrder(),
|
|
366
|
-
true
|
|
367
|
-
),
|
|
368
|
-
header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ jsx(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
|
|
369
|
-
/* @__PURE__ */ jsx(
|
|
370
|
-
"div",
|
|
371
|
-
{
|
|
372
|
-
onDoubleClick: (e) => {
|
|
373
|
-
e.stopPropagation();
|
|
374
|
-
header.column.resetSize();
|
|
375
|
-
},
|
|
376
|
-
onMouseDown: (e) => {
|
|
377
|
-
e.stopPropagation();
|
|
378
|
-
header.getResizeHandler()(e);
|
|
379
|
-
},
|
|
380
|
-
onTouchStart: (e) => {
|
|
381
|
-
e.stopPropagation();
|
|
382
|
-
header.getResizeHandler()(e);
|
|
383
|
-
},
|
|
384
|
-
className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
385
|
-
}
|
|
386
|
-
)
|
|
387
|
-
]
|
|
388
|
-
},
|
|
389
|
-
header.id
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
return /* @__PURE__ */ jsx(React.Fragment, { children: ((_c2 = header.column.columnDef.meta) == null ? void 0 : _c2.checkbox) ? /* @__PURE__ */ jsx(
|
|
393
|
-
DataGridCell,
|
|
394
|
-
{
|
|
395
|
-
id: id ? `${id}-header-${header.id}` : void 0,
|
|
396
|
-
type: "header",
|
|
397
|
-
component: "checkbox",
|
|
398
|
-
locked: (_d2 = header.column.columnDef.meta) == null ? void 0 : _d2.locked,
|
|
399
|
-
children: /* @__PURE__ */ jsx(
|
|
400
|
-
Checkbox,
|
|
401
|
-
{
|
|
402
|
-
id: id ? `${id}-select-all-checkbox` : void 0,
|
|
403
|
-
checked: allSelectedAcrossPages,
|
|
404
|
-
indeterminate: someSelectedAcrossPages,
|
|
405
|
-
onChange: toggleSelectAllAcrossPages
|
|
406
|
-
}
|
|
407
|
-
)
|
|
408
|
-
}
|
|
409
|
-
) : flexRender(
|
|
410
|
-
header.column.columnDef.header,
|
|
411
|
-
header.getContext()
|
|
412
|
-
) }, header.id);
|
|
413
|
-
}),
|
|
414
|
-
virtualPaddingRight ? (
|
|
415
|
-
//fake empty column to the right for virtualization scroll padding
|
|
416
|
-
/* @__PURE__ */ jsx(
|
|
417
|
-
"th",
|
|
418
|
-
{
|
|
419
|
-
style: { display: "flex", width: virtualPaddingRight }
|
|
420
|
-
}
|
|
421
|
-
)
|
|
422
|
-
) : null,
|
|
423
|
-
enableColumnSelector && /* @__PURE__ */ jsx(
|
|
424
|
-
ColumnSelectorHeaderCell,
|
|
425
|
-
{
|
|
426
|
-
id: id ? `${id}-column-selector` : void 0,
|
|
427
|
-
table,
|
|
428
|
-
toggleColumnVisibility,
|
|
429
|
-
resetColumnVisibility
|
|
430
|
-
}
|
|
431
|
-
)
|
|
432
|
-
] }, headerGroup.id)) }),
|
|
433
|
-
/* @__PURE__ */ jsx(
|
|
434
|
-
TableBody,
|
|
435
|
-
{
|
|
436
|
-
id,
|
|
437
|
-
columnVirtualizer,
|
|
438
|
-
table,
|
|
439
|
-
tableContainerRef: containerRef,
|
|
440
|
-
virtualPaddingLeft,
|
|
441
|
-
virtualPaddingRight,
|
|
442
|
-
pagination,
|
|
443
|
-
isLoadingMore,
|
|
444
|
-
hasMore,
|
|
445
|
-
showFilterRow,
|
|
446
|
-
enableColumnSelector
|
|
447
|
-
}
|
|
448
|
-
)
|
|
449
|
-
] }),
|
|
450
|
-
/* @__PURE__ */ jsx(
|
|
451
|
-
PinnedColumns,
|
|
452
|
-
{
|
|
453
|
-
pinDirection: "right",
|
|
454
|
-
table,
|
|
455
|
-
tableContainerRef: containerRef,
|
|
456
|
-
pagination,
|
|
457
|
-
isLoadingMore,
|
|
458
|
-
hasMore,
|
|
459
|
-
showFilterRow,
|
|
460
|
-
enableColumnSelector
|
|
461
|
-
}
|
|
462
|
-
)
|
|
463
|
-
]
|
|
464
|
-
}
|
|
465
|
-
),
|
|
466
|
-
empty && /* @__PURE__ */ jsxs(
|
|
467
|
-
"div",
|
|
468
|
-
{
|
|
469
|
-
className: clsx(
|
|
470
|
-
NO_RESULTS_HEIGHT,
|
|
471
|
-
"flex flex-col items-center justify-center",
|
|
472
|
-
componentGap,
|
|
473
|
-
componentPadding
|
|
474
|
-
),
|
|
475
|
-
children: [
|
|
476
|
-
/* @__PURE__ */ jsx(Subheader, { color: "text-secondary-normal", children: "No Results" }),
|
|
477
|
-
/* @__PURE__ */ jsx(Paragraph, { color: "text-secondary-normal", children: "To view results, enter or update your search criteria." })
|
|
478
|
-
]
|
|
479
|
-
}
|
|
480
|
-
),
|
|
481
|
-
!hideStatusBar && /* @__PURE__ */ jsxs("div", { className: "p-2 pt-[7px] border-t border-border-primary-normal h-full min-h-[34px]", children: [
|
|
482
|
-
pagination && /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
|
|
483
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 w-min", children: [
|
|
484
|
-
/* @__PURE__ */ jsx(
|
|
485
|
-
Select,
|
|
486
|
-
{
|
|
487
|
-
id: id ? `${id}-pagesize-select` : void 0,
|
|
488
|
-
wrapperClassName: "!w-20",
|
|
489
|
-
value: pagination.pageSize.toString(),
|
|
490
|
-
onChange: (e) => {
|
|
491
|
-
var _a2;
|
|
492
|
-
return (_a2 = pagination.onPageSizeChange) == null ? void 0 : _a2.call(pagination, Number(e.target.value));
|
|
493
|
-
},
|
|
494
|
-
renderMenu: (props) => /* @__PURE__ */ jsx(
|
|
495
|
-
Menu,
|
|
496
|
-
__spreadProps(__spreadValues({}, props), {
|
|
497
|
-
id: id ? `${id}-pagesize-menu` : void 0,
|
|
498
|
-
children: PAGE_SIZE_OPTIONS.map((option) => /* @__PURE__ */ jsx(
|
|
499
|
-
MenuOption,
|
|
500
|
-
{
|
|
501
|
-
id: id ? `${id}-pagesize-option-${option}` : void 0,
|
|
502
|
-
selected: pagination.pageSize === option,
|
|
503
|
-
onClick: () => {
|
|
504
|
-
var _a2;
|
|
505
|
-
return (_a2 = pagination.onPageSizeChange) == null ? void 0 : _a2.call(pagination, option);
|
|
506
|
-
},
|
|
507
|
-
children: option
|
|
508
|
-
},
|
|
509
|
-
option
|
|
510
|
-
))
|
|
511
|
-
})
|
|
512
|
-
)
|
|
513
|
-
}
|
|
514
|
-
),
|
|
515
|
-
/* @__PURE__ */ jsx(Label, { children: "Per Page" })
|
|
516
|
-
] }),
|
|
517
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
518
|
-
/* @__PURE__ */ jsx(
|
|
519
|
-
Button,
|
|
520
|
-
{
|
|
521
|
-
id: id ? `${id}-prev-page-button` : void 0,
|
|
522
|
-
iconOnly: true,
|
|
523
|
-
leftIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_left" }),
|
|
524
|
-
onClick: () => pagination.onPageChange(pagination.pageIndex - 1),
|
|
525
|
-
variant: "tertiary",
|
|
526
|
-
disabled: pagination.pageIndex === 0
|
|
527
|
-
}
|
|
528
|
-
),
|
|
529
|
-
/* @__PURE__ */ jsxs(Paragraph, { children: [
|
|
530
|
-
pagination.pageIndex * pagination.pageSize + 1,
|
|
531
|
-
" -",
|
|
532
|
-
" ",
|
|
533
|
-
Math.min(
|
|
534
|
-
(pagination.pageIndex + 1) * pagination.pageSize,
|
|
535
|
-
pagination.total
|
|
536
|
-
),
|
|
537
|
-
" ",
|
|
538
|
-
"of ",
|
|
539
|
-
pagination.total
|
|
540
|
-
] }),
|
|
541
|
-
/* @__PURE__ */ jsx(
|
|
542
|
-
Button,
|
|
543
|
-
{
|
|
544
|
-
id: id ? `${id}-next-page-button` : void 0,
|
|
545
|
-
iconOnly: true,
|
|
546
|
-
leftIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_right" }),
|
|
547
|
-
onClick: () => pagination.onPageChange(pagination.pageIndex + 1),
|
|
548
|
-
variant: "tertiary",
|
|
549
|
-
disabled: (pagination.pageIndex + 1) * pagination.pageSize >= pagination.total
|
|
550
|
-
}
|
|
551
|
-
)
|
|
552
|
-
] })
|
|
553
|
-
] }),
|
|
554
|
-
status && /* @__PURE__ */ jsx(Paragraph, { children: status })
|
|
555
|
-
] })
|
|
556
|
-
]
|
|
415
|
+
header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ jsx5(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
|
|
416
|
+
!((_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked) && /* @__PURE__ */ jsx5(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
onDoubleClick: (e) => {
|
|
420
|
+
e.stopPropagation();
|
|
421
|
+
header.column.resetSize();
|
|
422
|
+
},
|
|
423
|
+
onMouseDown: (e) => {
|
|
424
|
+
e.stopPropagation();
|
|
425
|
+
header.getResizeHandler()(e);
|
|
426
|
+
},
|
|
427
|
+
onTouchStart: (e) => {
|
|
428
|
+
e.stopPropagation();
|
|
429
|
+
header.getResizeHandler()(e);
|
|
430
|
+
},
|
|
431
|
+
className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
432
|
+
}
|
|
433
|
+
)
|
|
434
|
+
]
|
|
435
|
+
},
|
|
436
|
+
header.id
|
|
437
|
+
);
|
|
557
438
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
439
|
+
return /* @__PURE__ */ jsx5(React2.Fragment, { children: ((_c = header.column.columnDef.meta) == null ? void 0 : _c.checkbox) ? /* @__PURE__ */ jsx5(DataGridCell, { type: "header", component: "checkbox", locked: true, children: /* @__PURE__ */ jsx5(
|
|
440
|
+
Checkbox,
|
|
441
|
+
{
|
|
442
|
+
checked: allSelectedAcrossPages,
|
|
443
|
+
indeterminate: someSelectedAcrossPages,
|
|
444
|
+
onChange: toggleSelectAllAcrossPages
|
|
445
|
+
}
|
|
446
|
+
) }) : flexRender2(
|
|
447
|
+
header.column.columnDef.header,
|
|
448
|
+
header.getContext()
|
|
449
|
+
) }, header.id);
|
|
450
|
+
}) }, headerGroup.id);
|
|
451
|
+
}) }),
|
|
452
|
+
/* @__PURE__ */ jsx5(
|
|
453
|
+
TableBody,
|
|
454
|
+
__spreadProps(__spreadValues({}, props), {
|
|
455
|
+
table,
|
|
456
|
+
locked: true,
|
|
457
|
+
pinDirection
|
|
458
|
+
})
|
|
459
|
+
)
|
|
460
|
+
]
|
|
561
461
|
}
|
|
562
462
|
);
|
|
563
463
|
}
|
|
564
|
-
|
|
565
|
-
|
|
464
|
+
|
|
465
|
+
// src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx
|
|
466
|
+
import { useRef, useState as useState2 } from "react";
|
|
467
|
+
|
|
468
|
+
// src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx
|
|
469
|
+
import { useState } from "react";
|
|
470
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
471
|
+
function ColumnSelectorMenuOption({
|
|
566
472
|
id,
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
tableContainerRef,
|
|
570
|
-
virtualPaddingLeft,
|
|
571
|
-
virtualPaddingRight,
|
|
572
|
-
pagination,
|
|
573
|
-
isLoadingMore,
|
|
574
|
-
hasMore,
|
|
575
|
-
showFilterRow,
|
|
576
|
-
enableColumnSelector = false,
|
|
577
|
-
locked,
|
|
578
|
-
pinDirection
|
|
473
|
+
column,
|
|
474
|
+
toggleColumnVisibility
|
|
579
475
|
}) {
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
getScrollElement: () => tableContainerRef.current,
|
|
585
|
-
overscan: 8
|
|
586
|
-
});
|
|
587
|
-
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
588
|
-
const CellElement = locked ? DataGridCell : DragAlongCell;
|
|
589
|
-
let headerGroups;
|
|
590
|
-
if (pinDirection === "left") {
|
|
591
|
-
headerGroups = table.getLeftHeaderGroups();
|
|
592
|
-
} else if (pinDirection === "right") {
|
|
593
|
-
headerGroups = table.getRightHeaderGroups();
|
|
594
|
-
} else {
|
|
595
|
-
headerGroups = table.getCenterHeaderGroups();
|
|
596
|
-
}
|
|
597
|
-
return /* @__PURE__ */ jsxs(
|
|
598
|
-
"tbody",
|
|
476
|
+
const [isVisible, setIsVisible] = useState(column.getIsVisible());
|
|
477
|
+
const label = typeof column.columnDef.header === "string" ? column.columnDef.header : null;
|
|
478
|
+
return /* @__PURE__ */ jsx6(MenuOption, { id, selected: isVisible, defaultChecked: isVisible, children: /* @__PURE__ */ jsx6(
|
|
479
|
+
Checkbox,
|
|
599
480
|
{
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
removeRoundness: true,
|
|
639
|
-
onChange: (e) => header.column.setFilterValue(e.target.value),
|
|
640
|
-
value: (_d = header.column.getFilterValue()) != null ? _d : "",
|
|
641
|
-
placeholder: "",
|
|
642
|
-
removeSearchIcon: true
|
|
643
|
-
}
|
|
644
|
-
))
|
|
645
|
-
},
|
|
646
|
-
header.id
|
|
647
|
-
);
|
|
648
|
-
})
|
|
649
|
-
)
|
|
481
|
+
id: id ? `${id}-checkbox` : void 0,
|
|
482
|
+
label: label != null ? label : "Unknown",
|
|
483
|
+
checked: isVisible,
|
|
484
|
+
onChange: (e) => {
|
|
485
|
+
setIsVisible(e.target.checked);
|
|
486
|
+
toggleColumnVisibility(column.id, e.target.checked);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
) });
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx
|
|
493
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
494
|
+
function ColumnSelectorHeaderCell({
|
|
495
|
+
id,
|
|
496
|
+
table,
|
|
497
|
+
toggleColumnVisibility,
|
|
498
|
+
resetColumnVisibility
|
|
499
|
+
}) {
|
|
500
|
+
const ref = useRef(null);
|
|
501
|
+
const [show, setShow] = useState2(false);
|
|
502
|
+
return /* @__PURE__ */ jsxs4(
|
|
503
|
+
DataGridCell,
|
|
504
|
+
{
|
|
505
|
+
id,
|
|
506
|
+
width: "48",
|
|
507
|
+
type: "header",
|
|
508
|
+
color: "text-secondary-normal",
|
|
509
|
+
ref,
|
|
510
|
+
children: [
|
|
511
|
+
/* @__PURE__ */ jsx7(
|
|
512
|
+
Button,
|
|
513
|
+
{
|
|
514
|
+
id: id ? `${id}-button` : void 0,
|
|
515
|
+
onClick: () => setShow((prev) => !prev),
|
|
516
|
+
variant: "navigation",
|
|
517
|
+
iconOnly: true,
|
|
518
|
+
leftIcon: /* @__PURE__ */ jsx7(Icon, { name: "tune" })
|
|
650
519
|
}
|
|
651
520
|
),
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
return /* @__PURE__ */ jsx(
|
|
655
|
-
TableBodyRow,
|
|
656
|
-
{
|
|
657
|
-
id,
|
|
658
|
-
columnVirtualizer,
|
|
659
|
-
row,
|
|
660
|
-
rowVirtualizer,
|
|
661
|
-
virtualPaddingLeft,
|
|
662
|
-
virtualPaddingRight,
|
|
663
|
-
virtualRow,
|
|
664
|
-
showFilterRow,
|
|
665
|
-
enableColumnSelector,
|
|
666
|
-
locked,
|
|
667
|
-
pinDirection
|
|
668
|
-
},
|
|
669
|
-
row.id
|
|
670
|
-
);
|
|
671
|
-
}),
|
|
672
|
-
!pagination && isLoadingMore && hasMore && /* @__PURE__ */ jsx(
|
|
673
|
-
"tr",
|
|
521
|
+
/* @__PURE__ */ jsxs4(
|
|
522
|
+
Menu,
|
|
674
523
|
{
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
524
|
+
id: id ? `${id}-menu` : void 0,
|
|
525
|
+
positionTo: ref,
|
|
526
|
+
position: "bottom-right",
|
|
527
|
+
show,
|
|
528
|
+
setShow,
|
|
529
|
+
children: [
|
|
530
|
+
/* @__PURE__ */ jsx7(
|
|
531
|
+
Button,
|
|
532
|
+
{
|
|
533
|
+
id: id ? `${id}-reset-button` : void 0,
|
|
534
|
+
variant: "tertiary",
|
|
535
|
+
onClick: () => {
|
|
536
|
+
resetColumnVisibility();
|
|
537
|
+
setShow(false);
|
|
538
|
+
},
|
|
539
|
+
children: "Reset to default"
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
table.getAllColumns().filter((x) => {
|
|
543
|
+
var _a;
|
|
544
|
+
return (_a = x.columnDef.meta) == null ? void 0 : _a.inVisibilityMenu;
|
|
545
|
+
}).map((column) => /* @__PURE__ */ jsx7(
|
|
546
|
+
ColumnSelectorMenuOption,
|
|
547
|
+
{
|
|
548
|
+
id: id ? `${id}-option-${column.id}` : void 0,
|
|
549
|
+
column,
|
|
550
|
+
toggleColumnVisibility
|
|
551
|
+
},
|
|
552
|
+
column.id
|
|
553
|
+
))
|
|
554
|
+
]
|
|
683
555
|
}
|
|
684
556
|
)
|
|
685
557
|
]
|
|
686
558
|
}
|
|
687
559
|
);
|
|
688
560
|
}
|
|
689
|
-
|
|
561
|
+
|
|
562
|
+
// src/components/DataGrid/index.tsx
|
|
563
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
564
|
+
var PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 30, 35];
|
|
565
|
+
var NO_RESULTS_HEIGHT = "h-[120px]";
|
|
566
|
+
function DataGrid({
|
|
690
567
|
id,
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
showFilterRow,
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
568
|
+
data,
|
|
569
|
+
columns,
|
|
570
|
+
status,
|
|
571
|
+
isLoadingMore = false,
|
|
572
|
+
onLoadMore,
|
|
573
|
+
pagination,
|
|
574
|
+
showFilterRow = false,
|
|
575
|
+
hasMore = false,
|
|
576
|
+
sorting: externalSorting,
|
|
577
|
+
onSortingChange,
|
|
578
|
+
columnFilters: externalColumnFilters,
|
|
579
|
+
onColumnFiltersChange,
|
|
580
|
+
rowSelection: externalRowSelection,
|
|
581
|
+
onRowSelectionChange,
|
|
582
|
+
filteredSortedData,
|
|
583
|
+
totalRowCount,
|
|
584
|
+
hideStatusBar,
|
|
585
|
+
centerHeader,
|
|
586
|
+
enableColumnSelector,
|
|
587
|
+
predeterminedLeftPins = [],
|
|
588
|
+
predeterminedRightPins = [],
|
|
589
|
+
useMenuDefaultMinWidth
|
|
701
590
|
}) {
|
|
702
|
-
var _a;
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
}
|
|
709
|
-
const
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
{
|
|
742
|
-
id: id ? `${id}-cell-${cell.id}` : void 0,
|
|
743
|
-
cell,
|
|
744
|
-
children: /* @__PURE__ */ jsx(
|
|
745
|
-
Tooltip,
|
|
746
|
-
{
|
|
747
|
-
id: id ? `${id}-tooltip-${cell.id}` : void 0,
|
|
748
|
-
showOnTruncation: true,
|
|
749
|
-
message: cell.getValue(),
|
|
750
|
-
position: "bottom",
|
|
751
|
-
children: /* @__PURE__ */ jsx(Paragraph, { addOverflow: true, tall: true, children: cell.getValue() })
|
|
752
|
-
}
|
|
753
|
-
)
|
|
754
|
-
},
|
|
755
|
-
cell.id
|
|
756
|
-
);
|
|
757
|
-
}),
|
|
758
|
-
!locked && virtualPaddingRight ? (
|
|
759
|
-
// fake empty column to the right for virtualization scroll padding
|
|
760
|
-
/* @__PURE__ */ jsx("td", { style: { display: "flex", width: virtualPaddingRight } })
|
|
761
|
-
) : null,
|
|
762
|
-
enableColumnSelector && !locked && /* @__PURE__ */ jsx("td", { className: "p-2", style: { width: "48.8px" } })
|
|
763
|
-
]
|
|
591
|
+
var _a, _b, _c, _d, _e;
|
|
592
|
+
const [columnOrder, setColumnOrder] = useState3(
|
|
593
|
+
() => columns.map((c) => c.id)
|
|
594
|
+
);
|
|
595
|
+
const [localSorting, setLocalSorting] = useState3([]);
|
|
596
|
+
const [localColumnFilters, setLocalColumnFilters] = useState3([]);
|
|
597
|
+
const [localRowSelection, setLocalRowSelection] = useState3({});
|
|
598
|
+
const sortingState = pagination ? externalSorting != null ? externalSorting : localSorting : localSorting;
|
|
599
|
+
const setSortingState = pagination ? (updaterOrValue) => {
|
|
600
|
+
const value = typeof updaterOrValue === "function" ? updaterOrValue(
|
|
601
|
+
externalSorting != null ? externalSorting : []
|
|
602
|
+
) : updaterOrValue;
|
|
603
|
+
(onSortingChange != null ? onSortingChange : setLocalSorting)(value);
|
|
604
|
+
} : setLocalSorting;
|
|
605
|
+
const columnFilterState = pagination ? externalColumnFilters != null ? externalColumnFilters : localColumnFilters : localColumnFilters;
|
|
606
|
+
const setColumnFilterState = pagination ? (updaterOrValue) => {
|
|
607
|
+
const value = typeof updaterOrValue === "function" ? updaterOrValue(externalColumnFilters != null ? externalColumnFilters : []) : updaterOrValue;
|
|
608
|
+
(onColumnFiltersChange != null ? onColumnFiltersChange : setLocalColumnFilters)(value);
|
|
609
|
+
} : setLocalColumnFilters;
|
|
610
|
+
const rowSelection = pagination ? externalRowSelection != null ? externalRowSelection : localRowSelection : localRowSelection;
|
|
611
|
+
const setRowSelection = pagination ? (updaterOrValue) => {
|
|
612
|
+
const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
|
|
613
|
+
(onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
|
|
614
|
+
} : setLocalRowSelection;
|
|
615
|
+
const dndId = useId();
|
|
616
|
+
const containerRef = React3.useRef(null);
|
|
617
|
+
const [columnVisibility, setColumnVisibility] = useState3(() => {
|
|
618
|
+
const initialVisibility = {};
|
|
619
|
+
columns.forEach((column) => {
|
|
620
|
+
var _a2, _b2;
|
|
621
|
+
if (column.id) {
|
|
622
|
+
initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
return initialVisibility;
|
|
626
|
+
});
|
|
627
|
+
const toggleColumnVisibility = useCallback(
|
|
628
|
+
(columnId, isVisible) => {
|
|
629
|
+
setColumnVisibility((prev) => __spreadProps(__spreadValues({}, prev), { [columnId]: isVisible }));
|
|
764
630
|
},
|
|
765
|
-
|
|
631
|
+
[setColumnVisibility]
|
|
766
632
|
);
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
633
|
+
const resetColumnVisibility = useCallback(() => {
|
|
634
|
+
setColumnVisibility(() => {
|
|
635
|
+
const initialVisibility = {};
|
|
636
|
+
columns.forEach((column) => {
|
|
637
|
+
var _a2, _b2;
|
|
638
|
+
if (column.id) {
|
|
639
|
+
initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
return initialVisibility;
|
|
643
|
+
});
|
|
644
|
+
}, [columns]);
|
|
645
|
+
const table = useReactTable({
|
|
646
|
+
columns,
|
|
647
|
+
data,
|
|
648
|
+
getCoreRowModel: getCoreRowModel(),
|
|
649
|
+
getSortedRowModel: getSortedRowModel(),
|
|
650
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
651
|
+
columnResizeMode: "onChange",
|
|
652
|
+
getRowId: (row, index) => {
|
|
653
|
+
var _a2;
|
|
654
|
+
return String((_a2 = row.id) != null ? _a2 : index + 1);
|
|
655
|
+
},
|
|
656
|
+
state: {
|
|
657
|
+
columnOrder,
|
|
658
|
+
sorting: sortingState,
|
|
659
|
+
columnFilters: columnFilterState,
|
|
660
|
+
rowSelection,
|
|
661
|
+
columnVisibility
|
|
662
|
+
},
|
|
663
|
+
initialState: {
|
|
664
|
+
columnPinning: {
|
|
665
|
+
left: predeterminedLeftPins,
|
|
666
|
+
right: predeterminedRightPins
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
enableColumnPinning: (predeterminedLeftPins == null ? void 0 : predeterminedLeftPins.length) > 0 || predeterminedRightPins.length > 0,
|
|
670
|
+
onColumnOrderChange: setColumnOrder,
|
|
671
|
+
onSortingChange: adaptTableStateSetter(setSortingState),
|
|
672
|
+
onColumnFiltersChange: adaptTableStateSetter(setColumnFilterState),
|
|
673
|
+
onRowSelectionChange: adaptTableStateSetter(setRowSelection),
|
|
674
|
+
filterFns: {
|
|
675
|
+
startsWith: (row, columnId, filterValue) => {
|
|
676
|
+
const cellValue = row == null ? void 0 : row.getValue(columnId);
|
|
677
|
+
if (!cellValue || !filterValue) {
|
|
678
|
+
return true;
|
|
679
|
+
}
|
|
680
|
+
return String(cellValue).toLowerCase().startsWith(String(filterValue).toLowerCase());
|
|
681
|
+
},
|
|
682
|
+
endsWith: (row, columnId, filterValue) => {
|
|
683
|
+
const cellValue = row == null ? void 0 : row.getValue(columnId);
|
|
684
|
+
if (!cellValue || !filterValue) {
|
|
685
|
+
return true;
|
|
686
|
+
}
|
|
687
|
+
return String(cellValue).toLowerCase().endsWith(String(filterValue).toLowerCase());
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
const allRowIds = pagination ? (_a = filteredSortedData == null ? void 0 : filteredSortedData.map((row) => String(row.id))) != null ? _a : [] : Array.from(
|
|
692
|
+
{ length: totalRowCount != null ? totalRowCount : data.length },
|
|
693
|
+
(_, i) => String(i + 1)
|
|
694
|
+
);
|
|
695
|
+
const allSelectedAcrossPages = allRowIds.every(
|
|
696
|
+
(rowId) => rowSelection[rowId]
|
|
697
|
+
);
|
|
698
|
+
const someSelectedAcrossPages = !allSelectedAcrossPages && allRowIds.some((rowId) => rowSelection[rowId]);
|
|
699
|
+
const toggleSelectAllAcrossPages = () => {
|
|
700
|
+
setRowSelection((prev) => {
|
|
701
|
+
const isSelecting = !allSelectedAcrossPages;
|
|
702
|
+
if (isSelecting) {
|
|
703
|
+
const newSelection = {};
|
|
704
|
+
for (const rowId of allRowIds) {
|
|
705
|
+
newSelection[rowId] = true;
|
|
706
|
+
}
|
|
707
|
+
return __spreadValues(__spreadValues({}, prev), newSelection);
|
|
708
|
+
} else {
|
|
709
|
+
const updatedSelection = __spreadValues({}, prev);
|
|
710
|
+
for (const rowId of allRowIds) {
|
|
711
|
+
delete updatedSelection[rowId];
|
|
712
|
+
}
|
|
713
|
+
return updatedSelection;
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
};
|
|
717
|
+
useInfiniteScroll({
|
|
718
|
+
containerRef,
|
|
719
|
+
onLoadMore: onLoadMore != null ? onLoadMore : () => {
|
|
720
|
+
},
|
|
721
|
+
isLoading: isLoadingMore,
|
|
722
|
+
enabled: !pagination
|
|
723
|
+
});
|
|
724
|
+
const handleDragEnd = (event) => {
|
|
725
|
+
const { active, over } = event;
|
|
726
|
+
if (active && over && active.id !== over.id) {
|
|
727
|
+
setColumnOrder((prev) => {
|
|
728
|
+
const oldIndex = prev.indexOf(active.id);
|
|
729
|
+
const newIndex = prev.indexOf(over.id);
|
|
730
|
+
return arrayMove(prev, oldIndex, newIndex);
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
const sensors = useSensors(
|
|
735
|
+
useSensor(MouseSensor),
|
|
736
|
+
useSensor(TouchSensor),
|
|
737
|
+
useSensor(KeyboardSensor)
|
|
738
|
+
);
|
|
739
|
+
const visibleColumns = table.getVisibleLeafColumns();
|
|
740
|
+
const columnVirtualizer = useVirtualizer2({
|
|
741
|
+
count: visibleColumns.length,
|
|
742
|
+
estimateSize: (index) => visibleColumns[index].getSize(),
|
|
743
|
+
//estimate width of each column for accurate scrollbar dragging
|
|
744
|
+
getScrollElement: () => containerRef.current,
|
|
745
|
+
horizontal: true,
|
|
746
|
+
overscan: 3
|
|
747
|
+
//how many columns to render on each side off screen each way
|
|
748
|
+
});
|
|
749
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
|
750
|
+
let virtualPaddingLeft;
|
|
751
|
+
let virtualPaddingRight;
|
|
752
|
+
if (columnVirtualizer && (virtualColumns == null ? void 0 : virtualColumns.length)) {
|
|
753
|
+
virtualPaddingLeft = (_c = (_b = virtualColumns[0]) == null ? void 0 : _b.start) != null ? _c : 0;
|
|
754
|
+
virtualPaddingRight = columnVirtualizer.getTotalSize() - ((_e = (_d = virtualColumns[virtualColumns.length - 1]) == null ? void 0 : _d.end) != null ? _e : 0);
|
|
755
|
+
}
|
|
756
|
+
const empty = table.getRowModel().rows.length === 0;
|
|
757
|
+
return /* @__PURE__ */ jsx8(
|
|
758
|
+
DndContext,
|
|
788
759
|
{
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
760
|
+
id: dndId,
|
|
761
|
+
collisionDetection: closestCenter,
|
|
762
|
+
modifiers: [restrictToHorizontalAxis],
|
|
763
|
+
onDragEnd: handleDragEnd,
|
|
764
|
+
sensors,
|
|
765
|
+
children: /* @__PURE__ */ jsx8(
|
|
766
|
+
SortableContext,
|
|
767
|
+
{
|
|
768
|
+
items: columnOrder,
|
|
769
|
+
strategy: horizontalListSortingStrategy,
|
|
770
|
+
children: /* @__PURE__ */ jsxs5(
|
|
771
|
+
"div",
|
|
772
|
+
{
|
|
773
|
+
id,
|
|
774
|
+
className: "flex flex-col flex-1 h-full w-full rounded border border-border-primary-normal overflow-hidden text-text-primary-normal",
|
|
775
|
+
children: [
|
|
776
|
+
/* @__PURE__ */ jsxs5(
|
|
777
|
+
"div",
|
|
778
|
+
{
|
|
779
|
+
className: clsx5(
|
|
780
|
+
"flex overflow-auto scrollbar-thin relative contain-paint will-change-transform",
|
|
781
|
+
empty ? "overflow-y-hidden" : "h-full"
|
|
782
|
+
),
|
|
783
|
+
ref: containerRef,
|
|
784
|
+
children: [
|
|
785
|
+
/* @__PURE__ */ jsx8(
|
|
786
|
+
PinnedColumns,
|
|
787
|
+
{
|
|
788
|
+
pinDirection: "left",
|
|
789
|
+
table,
|
|
790
|
+
tableContainerRef: containerRef,
|
|
791
|
+
pagination,
|
|
792
|
+
isLoadingMore,
|
|
793
|
+
hasMore,
|
|
794
|
+
showFilterRow,
|
|
795
|
+
enableColumnSelector
|
|
796
|
+
}
|
|
797
|
+
),
|
|
798
|
+
/* @__PURE__ */ jsxs5("table", { className: "flex-1 flex flex-col min-h-min", children: [
|
|
799
|
+
/* @__PURE__ */ jsx8("thead", { className: "sticky top-0 z-10 grid", children: table.getCenterHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsxs5("tr", { className: "flex w-full", children: [
|
|
800
|
+
virtualPaddingLeft ? (
|
|
801
|
+
// fake empty column to the left for virtualization scroll padding
|
|
802
|
+
/* @__PURE__ */ jsx8(
|
|
803
|
+
"th",
|
|
804
|
+
{
|
|
805
|
+
style: { display: "flex", width: virtualPaddingLeft }
|
|
806
|
+
}
|
|
807
|
+
)
|
|
808
|
+
) : null,
|
|
809
|
+
virtualColumns.map((virtualColumn) => {
|
|
810
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
811
|
+
const header = headerGroup.headers[virtualColumn.index];
|
|
812
|
+
if (!header) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
if (typeof header.column.columnDef.header === "string") {
|
|
816
|
+
const customHeaderWidth = (_a2 = header.column.columnDef.meta) == null ? void 0 : _a2.headerWidth;
|
|
817
|
+
const cellValue = (_b2 = table.getRowModel().rows[0]) == null ? void 0 : _b2.getValue(header.column.id);
|
|
818
|
+
return /* @__PURE__ */ jsxs5(
|
|
819
|
+
DraggableCellHeader,
|
|
820
|
+
{
|
|
821
|
+
id: id ? `${id}-header-${header.id}` : void 0,
|
|
822
|
+
header,
|
|
823
|
+
locked: (_c2 = header.column.columnDef.meta) == null ? void 0 : _c2.locked,
|
|
824
|
+
center: centerHeader,
|
|
825
|
+
width: customHeaderWidth,
|
|
826
|
+
className: clsx5(
|
|
827
|
+
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
828
|
+
"group",
|
|
829
|
+
{
|
|
830
|
+
"justify-end": typeof cellValue === "number"
|
|
831
|
+
}
|
|
832
|
+
),
|
|
833
|
+
useMenuDefaultMinWidth,
|
|
834
|
+
children: [
|
|
835
|
+
/* @__PURE__ */ jsx8(Subheader, { tall: true, children: header.column.columnDef.header }),
|
|
836
|
+
getSortIcon(header.column.getIsSorted()),
|
|
837
|
+
!header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
|
|
838
|
+
header.column.getNextSortingOrder(),
|
|
839
|
+
true
|
|
840
|
+
),
|
|
841
|
+
header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ jsx8(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
|
|
842
|
+
/* @__PURE__ */ jsx8(
|
|
843
|
+
"div",
|
|
844
|
+
{
|
|
845
|
+
onDoubleClick: (e) => {
|
|
846
|
+
e.stopPropagation();
|
|
847
|
+
header.column.resetSize();
|
|
848
|
+
},
|
|
849
|
+
onMouseDown: (e) => {
|
|
850
|
+
e.stopPropagation();
|
|
851
|
+
header.getResizeHandler()(e);
|
|
852
|
+
},
|
|
853
|
+
onTouchStart: (e) => {
|
|
854
|
+
e.stopPropagation();
|
|
855
|
+
header.getResizeHandler()(e);
|
|
856
|
+
},
|
|
857
|
+
className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
858
|
+
}
|
|
859
|
+
)
|
|
860
|
+
]
|
|
861
|
+
},
|
|
862
|
+
header.id
|
|
863
|
+
);
|
|
864
|
+
}
|
|
865
|
+
return /* @__PURE__ */ jsx8(React3.Fragment, { children: ((_d2 = header.column.columnDef.meta) == null ? void 0 : _d2.checkbox) ? /* @__PURE__ */ jsx8(
|
|
866
|
+
DataGridCell,
|
|
867
|
+
{
|
|
868
|
+
id: id ? `${id}-header-${header.id}` : void 0,
|
|
869
|
+
type: "header",
|
|
870
|
+
component: "checkbox",
|
|
871
|
+
locked: (_e2 = header.column.columnDef.meta) == null ? void 0 : _e2.locked,
|
|
872
|
+
children: /* @__PURE__ */ jsx8(
|
|
873
|
+
Checkbox,
|
|
874
|
+
{
|
|
875
|
+
id: id ? `${id}-select-all-checkbox` : void 0,
|
|
876
|
+
checked: allSelectedAcrossPages,
|
|
877
|
+
indeterminate: someSelectedAcrossPages,
|
|
878
|
+
onChange: toggleSelectAllAcrossPages
|
|
879
|
+
}
|
|
880
|
+
)
|
|
881
|
+
}
|
|
882
|
+
) : flexRender3(
|
|
883
|
+
header.column.columnDef.header,
|
|
884
|
+
header.getContext()
|
|
885
|
+
) }, header.id);
|
|
886
|
+
}),
|
|
887
|
+
virtualPaddingRight ? (
|
|
888
|
+
//fake empty column to the right for virtualization scroll padding
|
|
889
|
+
/* @__PURE__ */ jsx8(
|
|
890
|
+
"th",
|
|
891
|
+
{
|
|
892
|
+
style: { display: "flex", width: virtualPaddingRight }
|
|
893
|
+
}
|
|
894
|
+
)
|
|
895
|
+
) : null,
|
|
896
|
+
enableColumnSelector && /* @__PURE__ */ jsx8(
|
|
897
|
+
ColumnSelectorHeaderCell,
|
|
898
|
+
{
|
|
899
|
+
id: id ? `${id}-column-selector` : void 0,
|
|
900
|
+
table,
|
|
901
|
+
toggleColumnVisibility,
|
|
902
|
+
resetColumnVisibility
|
|
903
|
+
}
|
|
904
|
+
)
|
|
905
|
+
] }, headerGroup.id)) }),
|
|
906
|
+
/* @__PURE__ */ jsx8(
|
|
907
|
+
TableBody,
|
|
908
|
+
{
|
|
909
|
+
id,
|
|
910
|
+
columnVirtualizer,
|
|
911
|
+
table,
|
|
912
|
+
tableContainerRef: containerRef,
|
|
913
|
+
virtualPaddingLeft,
|
|
914
|
+
virtualPaddingRight,
|
|
915
|
+
pagination,
|
|
916
|
+
isLoadingMore,
|
|
917
|
+
hasMore,
|
|
918
|
+
showFilterRow,
|
|
919
|
+
enableColumnSelector
|
|
920
|
+
}
|
|
921
|
+
)
|
|
922
|
+
] }),
|
|
923
|
+
/* @__PURE__ */ jsx8(
|
|
924
|
+
PinnedColumns,
|
|
925
|
+
{
|
|
926
|
+
pinDirection: "right",
|
|
927
|
+
table,
|
|
928
|
+
tableContainerRef: containerRef,
|
|
929
|
+
pagination,
|
|
930
|
+
isLoadingMore,
|
|
931
|
+
hasMore,
|
|
932
|
+
showFilterRow,
|
|
933
|
+
enableColumnSelector
|
|
934
|
+
}
|
|
935
|
+
)
|
|
936
|
+
]
|
|
937
|
+
}
|
|
938
|
+
),
|
|
939
|
+
empty && /* @__PURE__ */ jsxs5(
|
|
940
|
+
"div",
|
|
941
|
+
{
|
|
942
|
+
className: clsx5(
|
|
943
|
+
NO_RESULTS_HEIGHT,
|
|
944
|
+
"flex flex-col items-center justify-center",
|
|
945
|
+
componentGap,
|
|
946
|
+
componentPadding
|
|
819
947
|
),
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
"
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
948
|
+
children: [
|
|
949
|
+
/* @__PURE__ */ jsx8(Subheader, { color: "text-secondary-normal", children: "No Results" }),
|
|
950
|
+
/* @__PURE__ */ jsx8(Paragraph, { color: "text-secondary-normal", children: "To view results, enter or update your search criteria." })
|
|
951
|
+
]
|
|
952
|
+
}
|
|
953
|
+
),
|
|
954
|
+
!hideStatusBar && /* @__PURE__ */ jsxs5("div", { className: "p-2 pt-[7px] border-t border-border-primary-normal h-full min-h-[34px]", children: [
|
|
955
|
+
pagination && /* @__PURE__ */ jsxs5("div", { className: "flex justify-between items-center", children: [
|
|
956
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1 w-min", children: [
|
|
957
|
+
/* @__PURE__ */ jsx8(
|
|
958
|
+
Select,
|
|
959
|
+
{
|
|
960
|
+
id: id ? `${id}-pagesize-select` : void 0,
|
|
961
|
+
wrapperClassName: "!w-20",
|
|
962
|
+
value: pagination.pageSize.toString(),
|
|
963
|
+
onChange: (e) => {
|
|
964
|
+
var _a2;
|
|
965
|
+
return (_a2 = pagination.onPageSizeChange) == null ? void 0 : _a2.call(pagination, Number(e.target.value));
|
|
966
|
+
},
|
|
967
|
+
renderMenu: (props) => /* @__PURE__ */ jsx8(
|
|
968
|
+
Menu,
|
|
969
|
+
__spreadProps(__spreadValues({}, props), {
|
|
970
|
+
id: id ? `${id}-pagesize-menu` : void 0,
|
|
971
|
+
children: PAGE_SIZE_OPTIONS.map((option) => /* @__PURE__ */ jsx8(
|
|
972
|
+
MenuOption,
|
|
973
|
+
{
|
|
974
|
+
id: id ? `${id}-pagesize-option-${option}` : void 0,
|
|
975
|
+
selected: pagination.pageSize === option,
|
|
976
|
+
onClick: () => {
|
|
977
|
+
var _a2;
|
|
978
|
+
return (_a2 = pagination.onPageSizeChange) == null ? void 0 : _a2.call(pagination, option);
|
|
979
|
+
},
|
|
980
|
+
children: option
|
|
981
|
+
},
|
|
982
|
+
option
|
|
983
|
+
))
|
|
984
|
+
})
|
|
985
|
+
)
|
|
986
|
+
}
|
|
987
|
+
),
|
|
988
|
+
/* @__PURE__ */ jsx8(Label, { children: "Per Page" })
|
|
989
|
+
] }),
|
|
990
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
|
|
991
|
+
/* @__PURE__ */ jsx8(
|
|
992
|
+
Button,
|
|
993
|
+
{
|
|
994
|
+
id: id ? `${id}-prev-page-button` : void 0,
|
|
995
|
+
iconOnly: true,
|
|
996
|
+
leftIcon: /* @__PURE__ */ jsx8(Icon, { name: "chevron_left" }),
|
|
997
|
+
onClick: () => pagination.onPageChange(pagination.pageIndex - 1),
|
|
998
|
+
variant: "tertiary",
|
|
999
|
+
disabled: pagination.pageIndex === 0
|
|
1000
|
+
}
|
|
1001
|
+
),
|
|
1002
|
+
/* @__PURE__ */ jsxs5(Paragraph, { children: [
|
|
1003
|
+
pagination.pageIndex * pagination.pageSize + 1,
|
|
1004
|
+
" -",
|
|
1005
|
+
" ",
|
|
1006
|
+
Math.min(
|
|
1007
|
+
(pagination.pageIndex + 1) * pagination.pageSize,
|
|
1008
|
+
pagination.total
|
|
1009
|
+
),
|
|
1010
|
+
" ",
|
|
1011
|
+
"of ",
|
|
1012
|
+
pagination.total
|
|
1013
|
+
] }),
|
|
1014
|
+
/* @__PURE__ */ jsx8(
|
|
1015
|
+
Button,
|
|
1016
|
+
{
|
|
1017
|
+
id: id ? `${id}-next-page-button` : void 0,
|
|
1018
|
+
iconOnly: true,
|
|
1019
|
+
leftIcon: /* @__PURE__ */ jsx8(Icon, { name: "chevron_right" }),
|
|
1020
|
+
onClick: () => pagination.onPageChange(pagination.pageIndex + 1),
|
|
1021
|
+
variant: "tertiary",
|
|
1022
|
+
disabled: (pagination.pageIndex + 1) * pagination.pageSize >= pagination.total
|
|
1023
|
+
}
|
|
1024
|
+
)
|
|
1025
|
+
] })
|
|
1026
|
+
] }),
|
|
1027
|
+
status && /* @__PURE__ */ jsx8(Paragraph, { children: status })
|
|
1028
|
+
] })
|
|
1029
|
+
]
|
|
843
1030
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
checked: allSelectedAcrossPages,
|
|
848
|
-
indeterminate: someSelectedAcrossPages,
|
|
849
|
-
onChange: toggleSelectAllAcrossPages
|
|
850
|
-
}
|
|
851
|
-
) }) : flexRender(
|
|
852
|
-
header.column.columnDef.header,
|
|
853
|
-
header.getContext()
|
|
854
|
-
) }, header.id);
|
|
855
|
-
}) }, headerGroup.id);
|
|
856
|
-
}) }),
|
|
857
|
-
/* @__PURE__ */ jsx(
|
|
858
|
-
TableBody,
|
|
859
|
-
__spreadProps(__spreadValues({}, props), {
|
|
860
|
-
table,
|
|
861
|
-
locked: true,
|
|
862
|
-
pinDirection
|
|
863
|
-
})
|
|
864
|
-
)
|
|
865
|
-
]
|
|
1031
|
+
)
|
|
1032
|
+
}
|
|
1033
|
+
)
|
|
866
1034
|
}
|
|
867
1035
|
);
|
|
868
1036
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
if (column.cell === "checkbox") {
|
|
875
|
-
return /* @__PURE__ */ jsx(DataGridCell, { id: id ? `${id}-${key}` : void 0, children: /* @__PURE__ */ jsx(Checkbox, { id: id ? `${id}-${key}-checkbox` : void 0, disabled: true }) }, key);
|
|
876
|
-
}
|
|
877
|
-
if (column.cell === "input") {
|
|
878
|
-
return /* @__PURE__ */ jsx(
|
|
879
|
-
DataGridCell,
|
|
880
|
-
{
|
|
881
|
-
id: id ? `${id}-${key}` : void 0,
|
|
882
|
-
component: "input",
|
|
883
|
-
children: /* @__PURE__ */ jsx(
|
|
884
|
-
Input,
|
|
885
|
-
{
|
|
886
|
-
id: id ? `${id}-${key}-input` : void 0,
|
|
887
|
-
align: "left",
|
|
888
|
-
disabled: true,
|
|
889
|
-
wrapperClassName: "!rounded-none !border-0"
|
|
890
|
-
}
|
|
891
|
-
)
|
|
892
|
-
},
|
|
893
|
-
key
|
|
1037
|
+
DataGrid.displayName = "DataGrid";
|
|
1038
|
+
function adaptTableStateSetter(setter) {
|
|
1039
|
+
return (valueOrFn) => {
|
|
1040
|
+
setter(
|
|
1041
|
+
(prev) => typeof valueOrFn === "function" ? valueOrFn(prev) : valueOrFn
|
|
894
1042
|
);
|
|
895
|
-
}
|
|
896
|
-
return /* @__PURE__ */ jsx(DataGridCell, { id: id ? `${id}-${key}` : void 0, children: /* @__PURE__ */ jsx("div", { className: "bg-linear-270 to-neutral-300/[24%] from-neutral-300/[12%] rounded-xs w-full max-w-25 h-6" }) }, key);
|
|
897
|
-
};
|
|
898
|
-
function ColumnSelectorHeaderCell({
|
|
899
|
-
id,
|
|
900
|
-
table,
|
|
901
|
-
toggleColumnVisibility,
|
|
902
|
-
resetColumnVisibility
|
|
903
|
-
}) {
|
|
904
|
-
const ref = useRef(null);
|
|
905
|
-
const [show, setShow] = useState(false);
|
|
906
|
-
return /* @__PURE__ */ jsxs(
|
|
907
|
-
DataGridCell,
|
|
908
|
-
{
|
|
909
|
-
id,
|
|
910
|
-
width: "48",
|
|
911
|
-
type: "header",
|
|
912
|
-
color: "text-secondary-normal",
|
|
913
|
-
ref,
|
|
914
|
-
children: [
|
|
915
|
-
/* @__PURE__ */ jsx(
|
|
916
|
-
Button,
|
|
917
|
-
{
|
|
918
|
-
id: id ? `${id}-button` : void 0,
|
|
919
|
-
onClick: () => setShow((prev) => !prev),
|
|
920
|
-
variant: "navigation",
|
|
921
|
-
iconOnly: true,
|
|
922
|
-
leftIcon: /* @__PURE__ */ jsx(Icon, { name: "tune" })
|
|
923
|
-
}
|
|
924
|
-
),
|
|
925
|
-
/* @__PURE__ */ jsxs(
|
|
926
|
-
Menu,
|
|
927
|
-
{
|
|
928
|
-
id: id ? `${id}-menu` : void 0,
|
|
929
|
-
positionTo: ref,
|
|
930
|
-
position: "bottom-right",
|
|
931
|
-
show,
|
|
932
|
-
setShow,
|
|
933
|
-
children: [
|
|
934
|
-
/* @__PURE__ */ jsx(
|
|
935
|
-
Button,
|
|
936
|
-
{
|
|
937
|
-
id: id ? `${id}-reset-button` : void 0,
|
|
938
|
-
variant: "tertiary",
|
|
939
|
-
onClick: () => {
|
|
940
|
-
resetColumnVisibility();
|
|
941
|
-
setShow(false);
|
|
942
|
-
},
|
|
943
|
-
children: "Reset to default"
|
|
944
|
-
}
|
|
945
|
-
),
|
|
946
|
-
table.getAllColumns().filter((x) => {
|
|
947
|
-
var _a;
|
|
948
|
-
return (_a = x.columnDef.meta) == null ? void 0 : _a.inVisibilityMenu;
|
|
949
|
-
}).map((column) => /* @__PURE__ */ jsx(
|
|
950
|
-
ColumnSelectorMenuOption,
|
|
951
|
-
{
|
|
952
|
-
id: id ? `${id}-option-${column.id}` : void 0,
|
|
953
|
-
column,
|
|
954
|
-
toggleColumnVisibility
|
|
955
|
-
},
|
|
956
|
-
column.id
|
|
957
|
-
))
|
|
958
|
-
]
|
|
959
|
-
}
|
|
960
|
-
)
|
|
961
|
-
]
|
|
962
|
-
}
|
|
963
|
-
);
|
|
964
|
-
}
|
|
965
|
-
function ColumnSelectorMenuOption({
|
|
966
|
-
id,
|
|
967
|
-
column,
|
|
968
|
-
toggleColumnVisibility
|
|
969
|
-
}) {
|
|
970
|
-
const [isVisible, setIsVisible] = useState(column.getIsVisible());
|
|
971
|
-
const label = typeof column.columnDef.header === "string" ? column.columnDef.header : null;
|
|
972
|
-
return /* @__PURE__ */ jsx(MenuOption, { id, selected: isVisible, defaultChecked: isVisible, children: /* @__PURE__ */ jsx(
|
|
973
|
-
Checkbox,
|
|
974
|
-
{
|
|
975
|
-
id: id ? `${id}-checkbox` : void 0,
|
|
976
|
-
label: label != null ? label : "Unknown",
|
|
977
|
-
checked: isVisible,
|
|
978
|
-
onChange: (e) => {
|
|
979
|
-
setIsVisible(e.target.checked);
|
|
980
|
-
toggleColumnVisibility(column.id, e.target.checked);
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
) });
|
|
984
|
-
}
|
|
985
|
-
function getSortIcon(sort, nextSort = false) {
|
|
986
|
-
const iconClassName = clsx(
|
|
987
|
-
"text-icon-on-action-primary-normal",
|
|
988
|
-
nextSort && "hidden group-hover:block"
|
|
989
|
-
);
|
|
990
|
-
if (sort === "asc")
|
|
991
|
-
return /* @__PURE__ */ jsx(Icon, { size: 16, className: iconClassName, name: "arrow_upward" });
|
|
992
|
-
if (sort === "desc")
|
|
993
|
-
return /* @__PURE__ */ jsx(Icon, { size: 16, className: iconClassName, name: "arrow_downward" });
|
|
994
|
-
return null;
|
|
1043
|
+
};
|
|
995
1044
|
}
|
|
996
1045
|
export {
|
|
997
|
-
|
|
1046
|
+
Button,
|
|
1047
|
+
Checkbox,
|
|
1048
|
+
DataCellHeader,
|
|
1049
|
+
DataGrid,
|
|
1050
|
+
DataGridCell,
|
|
1051
|
+
DragAlongCell,
|
|
1052
|
+
DraggableCellHeader,
|
|
1053
|
+
Icon,
|
|
1054
|
+
Input,
|
|
1055
|
+
Label,
|
|
1056
|
+
Menu,
|
|
1057
|
+
MenuOption,
|
|
1058
|
+
Paragraph,
|
|
1059
|
+
Search,
|
|
1060
|
+
Select,
|
|
1061
|
+
Subheader,
|
|
1062
|
+
Tooltip
|
|
998
1063
|
};
|