react-glide-table 1.1.0 → 1.1.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/README.md +75 -15
- package/dist/compound.cjs +2085 -0
- package/dist/compound.d.cts +63 -0
- package/dist/compound.d.ts +63 -0
- package/dist/compound.js +2067 -0
- package/dist/core.cjs +1198 -0
- package/dist/core.d.cts +255 -0
- package/dist/core.d.ts +255 -0
- package/dist/core.js +1154 -0
- package/dist/index.cjs +948 -3
- package/dist/index.d.cts +5 -414
- package/dist/index.d.ts +5 -414
- package/dist/index.js +942 -0
- package/dist/types-ByOoRY8x.d.cts +177 -0
- package/dist/types-ByOoRY8x.d.ts +177 -0
- package/package.json +12 -1
|
@@ -0,0 +1,2085 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/compound/index.ts
|
|
21
|
+
var compound_exports = {};
|
|
22
|
+
__export(compound_exports, {
|
|
23
|
+
DataTable: () => DataTable,
|
|
24
|
+
Table: () => Table,
|
|
25
|
+
createTable: () => createTable
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(compound_exports);
|
|
28
|
+
|
|
29
|
+
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
30
|
+
var import_react_table3 = require("@tanstack/react-table");
|
|
31
|
+
|
|
32
|
+
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
33
|
+
var import_react_table = require("@tanstack/react-table");
|
|
34
|
+
var import_react3 = require("react");
|
|
35
|
+
|
|
36
|
+
// src/components/ui/table/constants.ts
|
|
37
|
+
var CELL_ALIGN_CLASS = {
|
|
38
|
+
left: "cell-align-left",
|
|
39
|
+
center: "cell-align-center",
|
|
40
|
+
right: "cell-align-right"
|
|
41
|
+
};
|
|
42
|
+
var ROW_HOVER_CLASS = "row-hoverable";
|
|
43
|
+
var ROW_HOVERED_BG_CLASS = "row-hovered";
|
|
44
|
+
var CELL_SELECTION_FILL_CLASS = "cell-selection-fill";
|
|
45
|
+
var DATA_TABLE_ROW_HEIGHT = 44;
|
|
46
|
+
var DATA_TABLE_VIRTUAL_OVERSCAN = 8;
|
|
47
|
+
|
|
48
|
+
// src/components/ui/table/DataTableContext.tsx
|
|
49
|
+
var import_react = require("react");
|
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
+
var DataTableContext = (0, import_react.createContext)(null);
|
|
52
|
+
function useDataTableRowContext() {
|
|
53
|
+
const context = (0, import_react.use)(DataTableContext);
|
|
54
|
+
if (!context) {
|
|
55
|
+
throw new Error("useDataTableRowContext must be used within a DataTableContextProvider");
|
|
56
|
+
}
|
|
57
|
+
return context;
|
|
58
|
+
}
|
|
59
|
+
function DataTableContextProvider({
|
|
60
|
+
value,
|
|
61
|
+
children
|
|
62
|
+
}) {
|
|
63
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataTableContext, { value, children });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/components/ui/table/features/cell-edit/cellEdit.ts
|
|
67
|
+
function getColumnAccessorKey(columnDef) {
|
|
68
|
+
if (columnDef.accessorKey !== void 0 && columnDef.accessorKey !== null) {
|
|
69
|
+
return String(columnDef.accessorKey);
|
|
70
|
+
}
|
|
71
|
+
return columnDef.id;
|
|
72
|
+
}
|
|
73
|
+
function isColumnEditable(columnDef) {
|
|
74
|
+
return Boolean(columnDef.meta?.editable);
|
|
75
|
+
}
|
|
76
|
+
function getColumnEditType(columnDef) {
|
|
77
|
+
return columnDef.meta?.editType ?? "text";
|
|
78
|
+
}
|
|
79
|
+
function parseCellEditValue(raw, editType) {
|
|
80
|
+
if (editType === "text") {
|
|
81
|
+
return { ok: true, value: raw };
|
|
82
|
+
}
|
|
83
|
+
const trimmed = raw.trim();
|
|
84
|
+
if (trimmed === "") {
|
|
85
|
+
return { ok: true, value: null };
|
|
86
|
+
}
|
|
87
|
+
const parsed = Number(trimmed);
|
|
88
|
+
if (Number.isNaN(parsed)) {
|
|
89
|
+
return { ok: false };
|
|
90
|
+
}
|
|
91
|
+
return { ok: true, value: parsed };
|
|
92
|
+
}
|
|
93
|
+
function getCellEditDraftValue(value) {
|
|
94
|
+
if (value === null || value === void 0) return "";
|
|
95
|
+
return String(value);
|
|
96
|
+
}
|
|
97
|
+
function applyCellEdit(data, rows, rowIndex, colIndex, raw) {
|
|
98
|
+
const cell = rows[rowIndex]?.getVisibleCells()[colIndex];
|
|
99
|
+
if (!cell) return null;
|
|
100
|
+
const columnDef = cell.column.columnDef;
|
|
101
|
+
if (!isColumnEditable(columnDef)) return null;
|
|
102
|
+
const accessorKey = getColumnAccessorKey(columnDef);
|
|
103
|
+
if (!accessorKey) return null;
|
|
104
|
+
const parsed = parseCellEditValue(raw, getColumnEditType(columnDef));
|
|
105
|
+
if (!parsed.ok) return null;
|
|
106
|
+
const newData = data.map((row) => ({ ...row }));
|
|
107
|
+
if (!newData[rowIndex]) return null;
|
|
108
|
+
newData[rowIndex][accessorKey] = parsed.value;
|
|
109
|
+
return newData;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/components/ui/table/features/cell-selection/cellSelection.ts
|
|
113
|
+
var INITIAL_DRAG_STATE = {
|
|
114
|
+
isSelecting: false,
|
|
115
|
+
isFillDragging: false,
|
|
116
|
+
start: null,
|
|
117
|
+
end: null,
|
|
118
|
+
fillAnchor: null,
|
|
119
|
+
fillEnd: null
|
|
120
|
+
};
|
|
121
|
+
function getCellSelectionBounds(start, end) {
|
|
122
|
+
if (!start || !end) return null;
|
|
123
|
+
return {
|
|
124
|
+
startRow: Math.min(start.row, end.row),
|
|
125
|
+
endRow: Math.max(start.row, end.row),
|
|
126
|
+
startCol: Math.min(start.col, end.col),
|
|
127
|
+
endCol: Math.max(start.col, end.col)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function getRowIndexInMergedCell(clientY, cellElement, rowIndex, rowSpan) {
|
|
131
|
+
if (rowSpan <= 1) return rowIndex;
|
|
132
|
+
const rect = cellElement.getBoundingClientRect();
|
|
133
|
+
const relativeY = clientY - rect.top;
|
|
134
|
+
const rowHeight = rect.height / rowSpan;
|
|
135
|
+
const offset = Math.min(
|
|
136
|
+
Math.max(Math.floor(relativeY / rowHeight), 0),
|
|
137
|
+
rowSpan - 1
|
|
138
|
+
);
|
|
139
|
+
return rowIndex + offset;
|
|
140
|
+
}
|
|
141
|
+
function isCellInSelection(rowIndex, colIndex, bounds, rowSpan = 1) {
|
|
142
|
+
if (!bounds) return false;
|
|
143
|
+
const cellEndRow = rowIndex + rowSpan - 1;
|
|
144
|
+
return cellEndRow >= bounds.startRow && rowIndex <= bounds.endRow && colIndex >= bounds.startCol && colIndex <= bounds.endCol;
|
|
145
|
+
}
|
|
146
|
+
function getActiveSelectionBounds(dragState, selectionBounds) {
|
|
147
|
+
if (dragState.isFillDragging && dragState.fillAnchor && dragState.fillEnd) {
|
|
148
|
+
return getCellSelectionBounds(dragState.fillAnchor, dragState.fillEnd);
|
|
149
|
+
}
|
|
150
|
+
return selectionBounds;
|
|
151
|
+
}
|
|
152
|
+
var SELECTION_EDGE_WIDTH_PX = 2;
|
|
153
|
+
var SELECTION_EDGE_COLOR = "var(--color-brand-primary)";
|
|
154
|
+
var CELL_SELECTION_EDGES_CLASS = "cell-selection-edges";
|
|
155
|
+
function getMergedCellStepEdges(rowIndex, colIndex, bounds, rowSpan, isVisuallySelectedAt) {
|
|
156
|
+
const cellEndRow = rowIndex + rowSpan - 1;
|
|
157
|
+
const span = cellEndRow - rowIndex + 1;
|
|
158
|
+
if (span <= 1) return [];
|
|
159
|
+
const edges = [];
|
|
160
|
+
const isNeighborSelected = (row, neighborCol) => {
|
|
161
|
+
if (isVisuallySelectedAt) {
|
|
162
|
+
return isVisuallySelectedAt(row, neighborCol);
|
|
163
|
+
}
|
|
164
|
+
return row >= bounds.startRow && row <= bounds.endRow && neighborCol >= bounds.startCol && neighborCol <= bounds.endCol;
|
|
165
|
+
};
|
|
166
|
+
const pushUnselectedRuns = (side, neighborCol, fromRow, toRowExclusive) => {
|
|
167
|
+
let runStart = null;
|
|
168
|
+
for (let row = fromRow; row < toRowExclusive; row++) {
|
|
169
|
+
if (!isNeighborSelected(row, neighborCol)) {
|
|
170
|
+
if (runStart === null) runStart = row;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (runStart !== null) {
|
|
174
|
+
edges.push({
|
|
175
|
+
side,
|
|
176
|
+
offsetRatio: (runStart - rowIndex) / span,
|
|
177
|
+
heightRatio: (row - runStart) / span
|
|
178
|
+
});
|
|
179
|
+
runStart = null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (runStart !== null) {
|
|
183
|
+
edges.push({
|
|
184
|
+
side,
|
|
185
|
+
offsetRatio: (runStart - rowIndex) / span,
|
|
186
|
+
heightRatio: (toRowExclusive - runStart) / span
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const collectSide = (side, neighborCol) => {
|
|
191
|
+
if (bounds.startRow > rowIndex) {
|
|
192
|
+
pushUnselectedRuns(
|
|
193
|
+
side,
|
|
194
|
+
neighborCol,
|
|
195
|
+
rowIndex,
|
|
196
|
+
Math.min(bounds.startRow, cellEndRow + 1)
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
if (bounds.endRow < cellEndRow) {
|
|
200
|
+
pushUnselectedRuns(
|
|
201
|
+
side,
|
|
202
|
+
neighborCol,
|
|
203
|
+
Math.max(bounds.endRow + 1, rowIndex),
|
|
204
|
+
cellEndRow + 1
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
if (colIndex < bounds.endCol) {
|
|
209
|
+
collectSide("right", colIndex + 1);
|
|
210
|
+
}
|
|
211
|
+
if (colIndex > bounds.startCol) {
|
|
212
|
+
collectSide("left", colIndex - 1);
|
|
213
|
+
}
|
|
214
|
+
return edges;
|
|
215
|
+
}
|
|
216
|
+
function buildPartialVerticalGradient(edge) {
|
|
217
|
+
const startPct = edge.offsetRatio * 100;
|
|
218
|
+
const endPct = (edge.offsetRatio + edge.heightRatio) * 100;
|
|
219
|
+
const overlapPx = SELECTION_EDGE_WIDTH_PX + 1;
|
|
220
|
+
const isTopProtrusion = edge.offsetRatio === 0 && edge.heightRatio < 1;
|
|
221
|
+
const isBottomProtrusion = edge.offsetRatio > 0;
|
|
222
|
+
const startStop = isBottomProtrusion ? `calc(${startPct}% - ${overlapPx}px)` : `${startPct}%`;
|
|
223
|
+
const endStop = isTopProtrusion ? `calc(${endPct}% + ${overlapPx}px)` : `${endPct}%`;
|
|
224
|
+
const xPos = edge.side === "left" ? "0" : "100%";
|
|
225
|
+
const layers = [
|
|
226
|
+
{
|
|
227
|
+
image: `linear-gradient(to bottom, transparent 0%, transparent ${startStop}, ${SELECTION_EDGE_COLOR} ${startStop}, ${SELECTION_EDGE_COLOR} ${endStop}, transparent ${endStop}, transparent 100%)`,
|
|
228
|
+
size: `${SELECTION_EDGE_WIDTH_PX}px 100%`,
|
|
229
|
+
position: `${xPos} 0`
|
|
230
|
+
}
|
|
231
|
+
];
|
|
232
|
+
if (isTopProtrusion || isBottomProtrusion) {
|
|
233
|
+
const capTop = isTopProtrusion ? `calc(${endPct}% - ${SELECTION_EDGE_WIDTH_PX}px)` : `calc(${startPct}% - ${SELECTION_EDGE_WIDTH_PX}px)`;
|
|
234
|
+
layers.push({
|
|
235
|
+
image: `linear-gradient(${SELECTION_EDGE_COLOR}, ${SELECTION_EDGE_COLOR})`,
|
|
236
|
+
size: `${SELECTION_EDGE_WIDTH_PX}px ${SELECTION_EDGE_WIDTH_PX}px`,
|
|
237
|
+
position: `${xPos} ${capTop}`
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return layers;
|
|
241
|
+
}
|
|
242
|
+
function getCellSelectionEdgeStyle(rowIndex, colIndex, bounds, rowSpan = 1, isVisuallySelectedAt) {
|
|
243
|
+
if (!isCellInSelection(rowIndex, colIndex, bounds, rowSpan) || !bounds)
|
|
244
|
+
return void 0;
|
|
245
|
+
const cellEndRow = rowIndex + rowSpan - 1;
|
|
246
|
+
const isTopEdge = bounds.startRow >= rowIndex && bounds.startRow <= cellEndRow;
|
|
247
|
+
const isBottomEdge = bounds.endRow >= rowIndex && bounds.endRow <= cellEndRow;
|
|
248
|
+
const isLeftEdge = colIndex === bounds.startCol;
|
|
249
|
+
const isRightEdge = colIndex === bounds.endCol;
|
|
250
|
+
const selectionContinuesBelow = cellEndRow < bounds.endRow;
|
|
251
|
+
const shadows = [];
|
|
252
|
+
if (isTopEdge) {
|
|
253
|
+
shadows.push(
|
|
254
|
+
`inset 0 ${SELECTION_EDGE_WIDTH_PX}px 0 0 ${SELECTION_EDGE_COLOR}`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
if (isBottomEdge) {
|
|
258
|
+
shadows.push(
|
|
259
|
+
`inset 0 -${SELECTION_EDGE_WIDTH_PX}px 0 0 ${SELECTION_EDGE_COLOR}`
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
if (isLeftEdge) {
|
|
263
|
+
shadows.push(
|
|
264
|
+
`inset ${SELECTION_EDGE_WIDTH_PX}px 0 0 0 ${SELECTION_EDGE_COLOR}`
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
if (isRightEdge) {
|
|
268
|
+
shadows.push(
|
|
269
|
+
`inset -${SELECTION_EDGE_WIDTH_PX}px 0 0 0 ${SELECTION_EDGE_COLOR}`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
const stepEdges = getMergedCellStepEdges(
|
|
273
|
+
rowIndex,
|
|
274
|
+
colIndex,
|
|
275
|
+
bounds,
|
|
276
|
+
rowSpan,
|
|
277
|
+
isVisuallySelectedAt
|
|
278
|
+
);
|
|
279
|
+
const gradients = [];
|
|
280
|
+
const sizes = [];
|
|
281
|
+
const positions = [];
|
|
282
|
+
for (const edge of stepEdges) {
|
|
283
|
+
for (const partial of buildPartialVerticalGradient(edge)) {
|
|
284
|
+
gradients.push(partial.image);
|
|
285
|
+
sizes.push(partial.size);
|
|
286
|
+
positions.push(partial.position);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (shadows.length === 0 && gradients.length === 0 && !selectionContinuesBelow) {
|
|
290
|
+
return void 0;
|
|
291
|
+
}
|
|
292
|
+
const style = {};
|
|
293
|
+
if (shadows.length > 0) {
|
|
294
|
+
style["--selection-edge-shadows"] = shadows.join(", ");
|
|
295
|
+
}
|
|
296
|
+
if (gradients.length > 0) {
|
|
297
|
+
style["--selection-edge-gradients"] = gradients.join(", ");
|
|
298
|
+
style["--selection-edge-sizes"] = sizes.join(", ");
|
|
299
|
+
style["--selection-edge-positions"] = positions.join(", ");
|
|
300
|
+
}
|
|
301
|
+
if (selectionContinuesBelow) {
|
|
302
|
+
style.borderBottomColor = "var(--color-brand-surface)";
|
|
303
|
+
}
|
|
304
|
+
return style;
|
|
305
|
+
}
|
|
306
|
+
function hasCellSelectionEdges(style) {
|
|
307
|
+
return Boolean(
|
|
308
|
+
style?.["--selection-edge-shadows"] || style?.["--selection-edge-gradients"]
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/components/ui/table/features/row-expand/row-expand.ts
|
|
313
|
+
var import_react2 = require("react");
|
|
314
|
+
|
|
315
|
+
// src/core/treeDefaults.ts
|
|
316
|
+
var DEFAULT_TREE_ID_FIELD = "id";
|
|
317
|
+
var DEFAULT_TREE_PARENT_ID_FIELD = "parentId";
|
|
318
|
+
var DEFAULT_TREE_CHILDREN_FIELD = "children";
|
|
319
|
+
var DEFAULT_TREE_QTY_FIELD = "qty";
|
|
320
|
+
|
|
321
|
+
// src/components/ui/table/features/row-expand/row-expand.ts
|
|
322
|
+
function getFieldValue(row, key) {
|
|
323
|
+
return row[key];
|
|
324
|
+
}
|
|
325
|
+
function canExpandRow(row) {
|
|
326
|
+
const children = row.children;
|
|
327
|
+
const level = row.level;
|
|
328
|
+
return Array.isArray(children) && children.length > 0 && (level === 0 || level === void 0);
|
|
329
|
+
}
|
|
330
|
+
function toggleExpandedRowId(rowId, previous) {
|
|
331
|
+
const next = new Set(previous);
|
|
332
|
+
if (next.has(rowId)) {
|
|
333
|
+
next.delete(rowId);
|
|
334
|
+
} else {
|
|
335
|
+
next.add(rowId);
|
|
336
|
+
}
|
|
337
|
+
return next;
|
|
338
|
+
}
|
|
339
|
+
var useConvertTreeData = ({
|
|
340
|
+
data,
|
|
341
|
+
enabled = true,
|
|
342
|
+
toggleField = DEFAULT_TREE_ID_FIELD,
|
|
343
|
+
childField = DEFAULT_TREE_PARENT_ID_FIELD,
|
|
344
|
+
flattenField = DEFAULT_TREE_CHILDREN_FIELD,
|
|
345
|
+
qtyField = DEFAULT_TREE_QTY_FIELD,
|
|
346
|
+
preventExpand = false,
|
|
347
|
+
startIndex = 1,
|
|
348
|
+
expandedRows,
|
|
349
|
+
onExpandedRowsChange
|
|
350
|
+
}) => {
|
|
351
|
+
const onExpandedRowsChangeRef = (0, import_react2.useRef)(onExpandedRowsChange);
|
|
352
|
+
const hasInitializedRef = (0, import_react2.useRef)(false);
|
|
353
|
+
(0, import_react2.useEffect)(() => {
|
|
354
|
+
onExpandedRowsChangeRef.current = onExpandedRowsChange;
|
|
355
|
+
}, [onExpandedRowsChange]);
|
|
356
|
+
(0, import_react2.useEffect)(() => {
|
|
357
|
+
if (!data || data.length === 0) {
|
|
358
|
+
hasInitializedRef.current = false;
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (!enabled || hasInitializedRef.current) return;
|
|
362
|
+
const ids = data.map((item) => getFieldValue(item, toggleField)).filter((value) => typeof value === "string" && value.length > 0);
|
|
363
|
+
onExpandedRowsChangeRef.current?.(new Set(ids));
|
|
364
|
+
hasInitializedRef.current = true;
|
|
365
|
+
}, [enabled, data, toggleField]);
|
|
366
|
+
const processedData = (0, import_react2.useMemo)(() => {
|
|
367
|
+
if (!enabled || !data || data.length === 0) return [];
|
|
368
|
+
const flattenedData = [];
|
|
369
|
+
const flattenItems = (items) => {
|
|
370
|
+
items.forEach((item) => {
|
|
371
|
+
const newItem = { ...item };
|
|
372
|
+
const nested = newItem[flattenField];
|
|
373
|
+
if (Array.isArray(nested)) {
|
|
374
|
+
const children = nested.map(
|
|
375
|
+
(child) => typeof child === "object" && child !== null ? { ...child } : child
|
|
376
|
+
);
|
|
377
|
+
delete newItem[flattenField];
|
|
378
|
+
flattenedData.push(newItem);
|
|
379
|
+
children.forEach((child) => {
|
|
380
|
+
if (typeof child === "object" && child !== null) {
|
|
381
|
+
;
|
|
382
|
+
child[childField] = newItem[toggleField];
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
flattenItems(children);
|
|
386
|
+
} else {
|
|
387
|
+
flattenedData.push(newItem);
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
flattenItems(data);
|
|
392
|
+
const dataWithLevels = flattenedData.map((item) => ({
|
|
393
|
+
...item,
|
|
394
|
+
level: 0,
|
|
395
|
+
children: [],
|
|
396
|
+
processed: false
|
|
397
|
+
}));
|
|
398
|
+
const itemMap = /* @__PURE__ */ new Map();
|
|
399
|
+
dataWithLevels.forEach((item) => {
|
|
400
|
+
const key = getFieldValue(item, toggleField);
|
|
401
|
+
if (typeof key !== "string" || !key) return;
|
|
402
|
+
if (!itemMap.has(key)) {
|
|
403
|
+
itemMap.set(key, []);
|
|
404
|
+
}
|
|
405
|
+
itemMap.get(key)?.push(item);
|
|
406
|
+
});
|
|
407
|
+
const rootItems = [];
|
|
408
|
+
dataWithLevels.forEach((item) => {
|
|
409
|
+
if (!getFieldValue(item, childField)) {
|
|
410
|
+
rootItems.push(item);
|
|
411
|
+
item.processed = true;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
dataWithLevels.forEach((item) => {
|
|
415
|
+
const parentKey = getFieldValue(item, childField);
|
|
416
|
+
if (!parentKey || item.processed) return;
|
|
417
|
+
const parentItems = dataWithLevels.filter(
|
|
418
|
+
(parent) => getFieldValue(parent, toggleField) === parentKey && !getFieldValue(parent, childField)
|
|
419
|
+
);
|
|
420
|
+
if (parentItems.length > 0) {
|
|
421
|
+
const parent = parentItems[0];
|
|
422
|
+
item.level = parent.level + 1;
|
|
423
|
+
parent.children.push(item);
|
|
424
|
+
item.processed = true;
|
|
425
|
+
} else {
|
|
426
|
+
const otherParents = itemMap.get(String(parentKey)) || [];
|
|
427
|
+
if (otherParents.length > 0) {
|
|
428
|
+
const parent = otherParents[0];
|
|
429
|
+
item.level = parent.level + 1;
|
|
430
|
+
parent.children.push(item);
|
|
431
|
+
item.processed = true;
|
|
432
|
+
} else {
|
|
433
|
+
rootItems.push(item);
|
|
434
|
+
item.processed = true;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
return rootItems;
|
|
439
|
+
}, [enabled, data, toggleField, childField, flattenField]);
|
|
440
|
+
const flattenTree = (0, import_react2.useMemo)(() => {
|
|
441
|
+
if (!enabled) return [];
|
|
442
|
+
const flatten = (nodes, result = [], level = 0) => {
|
|
443
|
+
nodes.forEach((node, index) => {
|
|
444
|
+
const currentIndex = level === 0 ? `${index + startIndex}` : `${level}-${index + 1}`;
|
|
445
|
+
const toggleValue = getFieldValue(node, toggleField);
|
|
446
|
+
const uniqueId = `${index}-${String(toggleValue ?? "")}`;
|
|
447
|
+
result.push({
|
|
448
|
+
...node,
|
|
449
|
+
treeNo: currentIndex,
|
|
450
|
+
uniqueId,
|
|
451
|
+
processed: true
|
|
452
|
+
});
|
|
453
|
+
const shouldExpandChildren = node.children.length > 0 && (preventExpand || typeof toggleValue === "string" && expandedRows?.has(toggleValue));
|
|
454
|
+
if (shouldExpandChildren) {
|
|
455
|
+
flatten(node.children, result, index + startIndex);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
return result;
|
|
459
|
+
};
|
|
460
|
+
const flattenedData = flatten(processedData, [], 0);
|
|
461
|
+
flattenedData.forEach((item) => {
|
|
462
|
+
if (getFieldValue(item, childField)) {
|
|
463
|
+
const parentItem = flattenedData.find(
|
|
464
|
+
(parent) => getFieldValue(parent, toggleField) === getFieldValue(item, childField)
|
|
465
|
+
);
|
|
466
|
+
const parentAmount = parentItem ? Number(getFieldValue(parentItem, qtyField) ?? 1) : 1;
|
|
467
|
+
item.parentCount = parentAmount || 1;
|
|
468
|
+
} else {
|
|
469
|
+
item.parentCount = 1;
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
return flattenedData;
|
|
473
|
+
}, [
|
|
474
|
+
enabled,
|
|
475
|
+
processedData,
|
|
476
|
+
startIndex,
|
|
477
|
+
toggleField,
|
|
478
|
+
childField,
|
|
479
|
+
qtyField,
|
|
480
|
+
preventExpand,
|
|
481
|
+
expandedRows
|
|
482
|
+
]);
|
|
483
|
+
const sortedData = (0, import_react2.useMemo)(() => {
|
|
484
|
+
if (!enabled) {
|
|
485
|
+
return data ?? [];
|
|
486
|
+
}
|
|
487
|
+
return [...flattenTree].sort((a, b) => {
|
|
488
|
+
const aParts = String(a.treeNo ?? "").split("-").map(Number);
|
|
489
|
+
const bParts = String(b.treeNo ?? "").split("-").map(Number);
|
|
490
|
+
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
|
491
|
+
const aVal = aParts[i] || 0;
|
|
492
|
+
const bVal = bParts[i] || 0;
|
|
493
|
+
if (aVal !== bVal) {
|
|
494
|
+
return aVal - bVal;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return 0;
|
|
498
|
+
});
|
|
499
|
+
}, [enabled, data, flattenTree]);
|
|
500
|
+
return sortedData;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
// src/components/ui/table/features/row-span/rowSpan.ts
|
|
504
|
+
function getRowFieldValue(row, key) {
|
|
505
|
+
return row[key];
|
|
506
|
+
}
|
|
507
|
+
function computeRowSpans(data, rowSpanKey) {
|
|
508
|
+
if (data.length === 0) return [];
|
|
509
|
+
const result = [];
|
|
510
|
+
for (let index = 0; index < data.length; index++) {
|
|
511
|
+
const currentValue = getRowFieldValue(data[index], rowSpanKey);
|
|
512
|
+
const previousValue = index > 0 ? getRowFieldValue(data[index - 1], rowSpanKey) : void 0;
|
|
513
|
+
if (index > 0 && currentValue === previousValue) {
|
|
514
|
+
result.push({ rowSpan: 0, isFirstInGroup: false });
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
let span = 1;
|
|
518
|
+
for (let nextIndex = index + 1; nextIndex < data.length; nextIndex++) {
|
|
519
|
+
if (getRowFieldValue(data[nextIndex], rowSpanKey) === currentValue) {
|
|
520
|
+
span++;
|
|
521
|
+
} else {
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
result.push({ rowSpan: span, isFirstInGroup: true });
|
|
526
|
+
}
|
|
527
|
+
return result;
|
|
528
|
+
}
|
|
529
|
+
function resolveRowSpanAt(rowSpans, rowIndex) {
|
|
530
|
+
if (!rowSpans?.[rowIndex]) {
|
|
531
|
+
return { startRow: rowIndex, rowSpan: 1 };
|
|
532
|
+
}
|
|
533
|
+
const current = rowSpans[rowIndex];
|
|
534
|
+
if (current.rowSpan > 0) {
|
|
535
|
+
return { startRow: rowIndex, rowSpan: current.rowSpan };
|
|
536
|
+
}
|
|
537
|
+
for (let row = rowIndex - 1; row >= 0; row--) {
|
|
538
|
+
const info = rowSpans[row];
|
|
539
|
+
if (info && info.rowSpan > 0) {
|
|
540
|
+
return { startRow: row, rowSpan: info.rowSpan };
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
return { startRow: rowIndex, rowSpan: 1 };
|
|
544
|
+
}
|
|
545
|
+
function buildColumnRowSpanMap(data, columnKeys) {
|
|
546
|
+
const map = /* @__PURE__ */ new Map();
|
|
547
|
+
for (const { columnId, rowSpanKey } of columnKeys) {
|
|
548
|
+
map.set(columnId, computeRowSpans(data, rowSpanKey));
|
|
549
|
+
}
|
|
550
|
+
return map;
|
|
551
|
+
}
|
|
552
|
+
function collectRowSpanColumns(columns) {
|
|
553
|
+
const result = [];
|
|
554
|
+
const visit = (defs) => {
|
|
555
|
+
for (const columnDef of defs) {
|
|
556
|
+
if ("columns" in columnDef && columnDef.columns?.length) {
|
|
557
|
+
visit(columnDef.columns);
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
const columnId = columnDef.id ?? ("accessorKey" in columnDef && columnDef.accessorKey ? String(columnDef.accessorKey) : void 0);
|
|
561
|
+
if (!columnId || !columnDef.meta?.rowSpan) continue;
|
|
562
|
+
result.push({
|
|
563
|
+
columnId,
|
|
564
|
+
rowSpanKey: columnDef.meta.rowSpanKey ?? columnId
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
visit(columns);
|
|
569
|
+
return result;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/components/ui/table/components/icons.tsx
|
|
573
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
574
|
+
function ChevronDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
576
|
+
"svg",
|
|
577
|
+
{
|
|
578
|
+
className,
|
|
579
|
+
"aria-hidden": ariaHidden,
|
|
580
|
+
width: "16",
|
|
581
|
+
height: "16",
|
|
582
|
+
viewBox: "0 0 24 24",
|
|
583
|
+
fill: "none",
|
|
584
|
+
stroke: "currentColor",
|
|
585
|
+
strokeWidth: "2",
|
|
586
|
+
strokeLinecap: "round",
|
|
587
|
+
strokeLinejoin: "round",
|
|
588
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m6 9 6 6 6-6" })
|
|
589
|
+
}
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
function ChevronUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
594
|
+
"svg",
|
|
595
|
+
{
|
|
596
|
+
className,
|
|
597
|
+
"aria-hidden": ariaHidden,
|
|
598
|
+
width: "16",
|
|
599
|
+
height: "16",
|
|
600
|
+
viewBox: "0 0 24 24",
|
|
601
|
+
fill: "none",
|
|
602
|
+
stroke: "currentColor",
|
|
603
|
+
strokeWidth: "2",
|
|
604
|
+
strokeLinecap: "round",
|
|
605
|
+
strokeLinejoin: "round",
|
|
606
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m18 15-6-6-6 6" })
|
|
607
|
+
}
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
function ChevronLeft({ className, "aria-hidden": ariaHidden = true }) {
|
|
611
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
612
|
+
"svg",
|
|
613
|
+
{
|
|
614
|
+
className,
|
|
615
|
+
"aria-hidden": ariaHidden,
|
|
616
|
+
width: "16",
|
|
617
|
+
height: "16",
|
|
618
|
+
viewBox: "0 0 24 24",
|
|
619
|
+
fill: "none",
|
|
620
|
+
stroke: "currentColor",
|
|
621
|
+
strokeWidth: "2",
|
|
622
|
+
strokeLinecap: "round",
|
|
623
|
+
strokeLinejoin: "round",
|
|
624
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m15 18-6-6 6-6" })
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
function ChevronRight({ className, "aria-hidden": ariaHidden = true }) {
|
|
629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
630
|
+
"svg",
|
|
631
|
+
{
|
|
632
|
+
className,
|
|
633
|
+
"aria-hidden": ariaHidden,
|
|
634
|
+
width: "16",
|
|
635
|
+
height: "16",
|
|
636
|
+
viewBox: "0 0 24 24",
|
|
637
|
+
fill: "none",
|
|
638
|
+
stroke: "currentColor",
|
|
639
|
+
strokeWidth: "2",
|
|
640
|
+
strokeLinecap: "round",
|
|
641
|
+
strokeLinejoin: "round",
|
|
642
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m9 18 6-6-6-6" })
|
|
643
|
+
}
|
|
644
|
+
);
|
|
645
|
+
}
|
|
646
|
+
function ArrowUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
647
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
648
|
+
"svg",
|
|
649
|
+
{
|
|
650
|
+
className,
|
|
651
|
+
"aria-hidden": ariaHidden,
|
|
652
|
+
width: "14",
|
|
653
|
+
height: "14",
|
|
654
|
+
viewBox: "0 0 24 24",
|
|
655
|
+
fill: "none",
|
|
656
|
+
stroke: "currentColor",
|
|
657
|
+
strokeWidth: "2",
|
|
658
|
+
strokeLinecap: "round",
|
|
659
|
+
strokeLinejoin: "round",
|
|
660
|
+
children: [
|
|
661
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m18 15-6-6-6 6" }),
|
|
662
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 21V9" })
|
|
663
|
+
]
|
|
664
|
+
}
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
function ArrowDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
669
|
+
"svg",
|
|
670
|
+
{
|
|
671
|
+
className,
|
|
672
|
+
"aria-hidden": ariaHidden,
|
|
673
|
+
width: "14",
|
|
674
|
+
height: "14",
|
|
675
|
+
viewBox: "0 0 24 24",
|
|
676
|
+
fill: "none",
|
|
677
|
+
stroke: "currentColor",
|
|
678
|
+
strokeWidth: "2",
|
|
679
|
+
strokeLinecap: "round",
|
|
680
|
+
strokeLinejoin: "round",
|
|
681
|
+
children: [
|
|
682
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m6 9 6 6 6-6" }),
|
|
683
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 3v12" })
|
|
684
|
+
]
|
|
685
|
+
}
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
function ArrowUpDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
690
|
+
"svg",
|
|
691
|
+
{
|
|
692
|
+
className,
|
|
693
|
+
"aria-hidden": ariaHidden,
|
|
694
|
+
width: "14",
|
|
695
|
+
height: "14",
|
|
696
|
+
viewBox: "0 0 24 24",
|
|
697
|
+
fill: "none",
|
|
698
|
+
stroke: "currentColor",
|
|
699
|
+
strokeWidth: "2",
|
|
700
|
+
strokeLinecap: "round",
|
|
701
|
+
strokeLinejoin: "round",
|
|
702
|
+
children: [
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m21 16-4 4-4-4" }),
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M17 20V4" }),
|
|
705
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m3 8 4-4 4 4" }),
|
|
706
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M7 4v16" })
|
|
707
|
+
]
|
|
708
|
+
}
|
|
709
|
+
);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// src/lib/cn.ts
|
|
713
|
+
function cn(...inputs) {
|
|
714
|
+
return inputs.filter(Boolean).join(" ");
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
718
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
719
|
+
function resolveExpandCellIndex(cells, toggleField) {
|
|
720
|
+
if (!toggleField) return 0;
|
|
721
|
+
const matchedIndex = cells.findIndex(
|
|
722
|
+
(cell) => cell.column.id === toggleField
|
|
723
|
+
);
|
|
724
|
+
if (matchedIndex >= 0) return matchedIndex;
|
|
725
|
+
const noColumnIndex = cells.findIndex(
|
|
726
|
+
(cell) => cell.column.id === "no" || cell.column.id === "treeNo"
|
|
727
|
+
);
|
|
728
|
+
if (noColumnIndex >= 0 && noColumnIndex + 1 < cells.length) {
|
|
729
|
+
return noColumnIndex + 1;
|
|
730
|
+
}
|
|
731
|
+
return 0;
|
|
732
|
+
}
|
|
733
|
+
function DataTableRow({
|
|
734
|
+
row,
|
|
735
|
+
onToggleSelect,
|
|
736
|
+
virtualIndex,
|
|
737
|
+
measureElement
|
|
738
|
+
}) {
|
|
739
|
+
const { rowSpan, selection, cellSelection, cellEdit, expand } = useDataTableRowContext();
|
|
740
|
+
const {
|
|
741
|
+
enableRowSpan,
|
|
742
|
+
primaryRowSpanKey,
|
|
743
|
+
columnRowSpanMap,
|
|
744
|
+
hoveredRowIndex,
|
|
745
|
+
hoveredGroupKey,
|
|
746
|
+
selectedGroupKeys,
|
|
747
|
+
onRowHover
|
|
748
|
+
} = rowSpan;
|
|
749
|
+
const { rowSelectionMode, selectOnRowClick, onRowClick, getRowClassName } = selection;
|
|
750
|
+
const {
|
|
751
|
+
enableCellSelection,
|
|
752
|
+
activeSelectionBounds,
|
|
753
|
+
dragState,
|
|
754
|
+
onCellMouseDown,
|
|
755
|
+
onCellMouseEnter,
|
|
756
|
+
onFillHandleMouseDown
|
|
757
|
+
} = cellSelection;
|
|
758
|
+
const {
|
|
759
|
+
editingCell,
|
|
760
|
+
draftValue,
|
|
761
|
+
onDraftValueChange,
|
|
762
|
+
onStartEdit,
|
|
763
|
+
onCommitEdit,
|
|
764
|
+
onCancelEdit
|
|
765
|
+
} = cellEdit;
|
|
766
|
+
const {
|
|
767
|
+
enableExpand,
|
|
768
|
+
toggleField,
|
|
769
|
+
expandedRows,
|
|
770
|
+
preventExpand,
|
|
771
|
+
onToggleExpand,
|
|
772
|
+
expandRowLabel,
|
|
773
|
+
collapseRowLabel
|
|
774
|
+
} = expand;
|
|
775
|
+
const rowIndex = row.index;
|
|
776
|
+
const rowData = row.original;
|
|
777
|
+
const isRowHovered = hoveredRowIndex === rowIndex;
|
|
778
|
+
const isRowSelected = row.getIsSelected();
|
|
779
|
+
const rowGroupKey = primaryRowSpanKey !== void 0 && rowData[primaryRowSpanKey] !== null && rowData[primaryRowSpanKey] !== void 0 ? String(rowData[primaryRowSpanKey]) : null;
|
|
780
|
+
const isGroupHovered = enableRowSpan && hoveredGroupKey !== null && rowGroupKey === hoveredGroupKey;
|
|
781
|
+
const isGroupSelected = enableRowSpan && rowGroupKey !== null && selectedGroupKeys.has(rowGroupKey);
|
|
782
|
+
const visibleCells = row.getVisibleCells();
|
|
783
|
+
const columnIdsByIndex = visibleCells.map((cell) => cell.column.id);
|
|
784
|
+
const isVisuallySelectedAt = activeSelectionBounds ? (targetRow, targetCol) => {
|
|
785
|
+
if (targetCol < activeSelectionBounds.startCol || targetCol > activeSelectionBounds.endCol) {
|
|
786
|
+
return false;
|
|
787
|
+
}
|
|
788
|
+
const columnId = columnIdsByIndex[targetCol];
|
|
789
|
+
const { startRow, rowSpan: span } = resolveRowSpanAt(
|
|
790
|
+
columnId ? columnRowSpanMap.get(columnId) : void 0,
|
|
791
|
+
targetRow
|
|
792
|
+
);
|
|
793
|
+
return isCellInSelection(
|
|
794
|
+
startRow,
|
|
795
|
+
targetCol,
|
|
796
|
+
activeSelectionBounds,
|
|
797
|
+
span
|
|
798
|
+
);
|
|
799
|
+
} : void 0;
|
|
800
|
+
const expandCellIndex = enableExpand ? resolveExpandCellIndex(visibleCells, toggleField) : -1;
|
|
801
|
+
const canExpand = enableExpand && !preventExpand && canExpandRow(rowData);
|
|
802
|
+
const expandKey = toggleField && rowData[toggleField] !== null && rowData[toggleField] !== void 0 ? String(rowData[toggleField]) : null;
|
|
803
|
+
const isExpanded = expandKey !== null && Boolean(expandedRows?.has(expandKey));
|
|
804
|
+
const rowLevel = typeof rowData.level === "number" ? rowData.level : 0;
|
|
805
|
+
const editInputRef = (0, import_react3.useRef)(null);
|
|
806
|
+
const isRowEditing = editingCell?.rowIndex === rowIndex;
|
|
807
|
+
(0, import_react3.useEffect)(() => {
|
|
808
|
+
if (!isRowEditing) return;
|
|
809
|
+
editInputRef.current?.focus();
|
|
810
|
+
editInputRef.current?.select();
|
|
811
|
+
}, [isRowEditing, editingCell?.colIndex]);
|
|
812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
813
|
+
"tr",
|
|
814
|
+
{
|
|
815
|
+
ref: measureElement,
|
|
816
|
+
"data-index": virtualIndex,
|
|
817
|
+
className: cn(
|
|
818
|
+
"DataTableRowJSX",
|
|
819
|
+
!enableRowSpan && ROW_HOVER_CLASS,
|
|
820
|
+
enableRowSpan && isRowHovered && !isRowSelected && ROW_HOVERED_BG_CLASS,
|
|
821
|
+
isRowSelected && "is-selected",
|
|
822
|
+
enableExpand && canExpand && "is-expandable",
|
|
823
|
+
getRowClassName?.(rowData, rowIndex)
|
|
824
|
+
),
|
|
825
|
+
onMouseEnter: () => onRowHover(rowIndex, rowData),
|
|
826
|
+
onClick: () => {
|
|
827
|
+
if (isRowEditing) return;
|
|
828
|
+
onRowClick?.(rowData, rowIndex);
|
|
829
|
+
if (rowSelectionMode !== "none" && selectOnRowClick) {
|
|
830
|
+
onToggleSelect();
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
children: visibleCells.map((cell, cellIndex) => {
|
|
834
|
+
const columnId = cell.column.id;
|
|
835
|
+
const meta = cell.column.columnDef.meta;
|
|
836
|
+
const align = meta?.align ?? "center";
|
|
837
|
+
const cellClassName = meta?.className;
|
|
838
|
+
const isRowSpanColumn = Boolean(enableRowSpan && meta?.rowSpan);
|
|
839
|
+
const isExpandCell = cellIndex === expandCellIndex;
|
|
840
|
+
const editable = isColumnEditable(cell.column.columnDef);
|
|
841
|
+
const editType = getColumnEditType(cell.column.columnDef);
|
|
842
|
+
let rowSpanInfo;
|
|
843
|
+
if (isRowSpanColumn) {
|
|
844
|
+
rowSpanInfo = columnRowSpanMap.get(columnId)?.[rowIndex];
|
|
845
|
+
if (rowSpanInfo && rowSpanInfo.rowSpan === 0) {
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
const isEditing = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === cellIndex;
|
|
850
|
+
const showCellHover = isRowSpanColumn ? isGroupHovered : isRowHovered;
|
|
851
|
+
const showCellSelected = isRowSpanColumn ? isGroupSelected : isRowSelected;
|
|
852
|
+
const cellRowSpan = rowSpanInfo?.rowSpan ?? 1;
|
|
853
|
+
const isMerged = cellRowSpan > 1;
|
|
854
|
+
const showMergedRightEdge = isMerged && (cellIndex === visibleCells.length - 1 || resolveRowSpanAt(
|
|
855
|
+
columnRowSpanMap.get(columnIdsByIndex[cellIndex + 1]),
|
|
856
|
+
rowIndex
|
|
857
|
+
).rowSpan <= 1);
|
|
858
|
+
const isCellDragSelected = isCellInSelection(
|
|
859
|
+
rowIndex,
|
|
860
|
+
cellIndex,
|
|
861
|
+
activeSelectionBounds,
|
|
862
|
+
cellRowSpan
|
|
863
|
+
);
|
|
864
|
+
const isBottomRightCell = !isEditing && activeSelectionBounds && !dragState.isSelecting && activeSelectionBounds.endRow >= rowIndex && activeSelectionBounds.endRow <= rowIndex + cellRowSpan - 1 && cellIndex === activeSelectionBounds.endCol;
|
|
865
|
+
const selectionEdgeStyle = getCellSelectionEdgeStyle(
|
|
866
|
+
rowIndex,
|
|
867
|
+
cellIndex,
|
|
868
|
+
activeSelectionBounds,
|
|
869
|
+
cellRowSpan,
|
|
870
|
+
isVisuallySelectedAt
|
|
871
|
+
);
|
|
872
|
+
const resolveCellRowIndex = (clientY, element) => getRowIndexInMergedCell(clientY, element, rowIndex, cellRowSpan);
|
|
873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
874
|
+
"td",
|
|
875
|
+
{
|
|
876
|
+
rowSpan: rowSpanInfo && rowSpanInfo.rowSpan > 1 ? rowSpanInfo.rowSpan : void 0,
|
|
877
|
+
onMouseDown: (event) => {
|
|
878
|
+
if (isEditing) {
|
|
879
|
+
event.stopPropagation();
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
if (!enableCellSelection) return;
|
|
883
|
+
event.preventDefault();
|
|
884
|
+
onCellMouseDown(
|
|
885
|
+
resolveCellRowIndex(event.clientY, event.currentTarget),
|
|
886
|
+
cellIndex
|
|
887
|
+
);
|
|
888
|
+
},
|
|
889
|
+
onMouseEnter: (event) => {
|
|
890
|
+
if (!enableCellSelection) return;
|
|
891
|
+
onCellMouseEnter(
|
|
892
|
+
resolveCellRowIndex(event.clientY, event.currentTarget),
|
|
893
|
+
cellIndex
|
|
894
|
+
);
|
|
895
|
+
},
|
|
896
|
+
onMouseMove: (event) => {
|
|
897
|
+
if (!enableCellSelection) return;
|
|
898
|
+
if (!dragState.isSelecting && !dragState.isFillDragging) return;
|
|
899
|
+
onCellMouseEnter(
|
|
900
|
+
resolveCellRowIndex(event.clientY, event.currentTarget),
|
|
901
|
+
cellIndex
|
|
902
|
+
);
|
|
903
|
+
},
|
|
904
|
+
onDoubleClick: (event) => {
|
|
905
|
+
if (!editable) return;
|
|
906
|
+
event.preventDefault();
|
|
907
|
+
event.stopPropagation();
|
|
908
|
+
onStartEdit(rowIndex, cellIndex);
|
|
909
|
+
},
|
|
910
|
+
style: selectionEdgeStyle,
|
|
911
|
+
className: cn(
|
|
912
|
+
"data-table-cell",
|
|
913
|
+
CELL_ALIGN_CLASS[align],
|
|
914
|
+
cellClassName,
|
|
915
|
+
isMerged && cellIndex > 0 && "is-merged",
|
|
916
|
+
showMergedRightEdge && "is-merged-edge-right",
|
|
917
|
+
enableRowSpan && showCellSelected && "is-group-selected",
|
|
918
|
+
enableRowSpan && showCellHover && !showCellSelected && "is-group-hovered",
|
|
919
|
+
isCellDragSelected && CELL_SELECTION_FILL_CLASS,
|
|
920
|
+
hasCellSelectionEdges(selectionEdgeStyle) && CELL_SELECTION_EDGES_CLASS,
|
|
921
|
+
editable && "is-editable"
|
|
922
|
+
),
|
|
923
|
+
children: [
|
|
924
|
+
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
925
|
+
"input",
|
|
926
|
+
{
|
|
927
|
+
ref: editInputRef,
|
|
928
|
+
type: editType === "number" ? "number" : "text",
|
|
929
|
+
defaultValue: draftValue,
|
|
930
|
+
className: cn("cell-edit-input", CELL_ALIGN_CLASS[align]),
|
|
931
|
+
onChange: (event) => onDraftValueChange(event.target.value),
|
|
932
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
933
|
+
onClick: (event) => event.stopPropagation(),
|
|
934
|
+
onKeyDown: (event) => {
|
|
935
|
+
if (event.key === "Enter") {
|
|
936
|
+
event.preventDefault();
|
|
937
|
+
onCommitEdit(event.currentTarget.value);
|
|
938
|
+
}
|
|
939
|
+
if (event.key === "Escape") {
|
|
940
|
+
event.preventDefault();
|
|
941
|
+
onCancelEdit();
|
|
942
|
+
}
|
|
943
|
+
},
|
|
944
|
+
onBlur: (event) => {
|
|
945
|
+
onCommitEdit(event.currentTarget.value);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
) : isExpandCell && enableExpand ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "expand-cell", children: [
|
|
949
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "expand-cell-content", children: [
|
|
950
|
+
rowLevel > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "expand-cell-indent", children: "\xB7" }),
|
|
951
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "expand-cell-value", children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) })
|
|
952
|
+
] }),
|
|
953
|
+
canExpand && expandKey && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
954
|
+
"button",
|
|
955
|
+
{
|
|
956
|
+
type: "button",
|
|
957
|
+
"aria-label": isExpanded ? collapseRowLabel : expandRowLabel,
|
|
958
|
+
className: "expand-toggle-button",
|
|
959
|
+
onClick: (event) => {
|
|
960
|
+
event.stopPropagation();
|
|
961
|
+
onToggleExpand?.(expandKey);
|
|
962
|
+
},
|
|
963
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
964
|
+
children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronUp, { className: "expand-toggle-icon" }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChevronDown, { className: "expand-toggle-icon" })
|
|
965
|
+
}
|
|
966
|
+
)
|
|
967
|
+
] }) : (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()),
|
|
968
|
+
isBottomRightCell && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
969
|
+
"div",
|
|
970
|
+
{
|
|
971
|
+
role: "presentation",
|
|
972
|
+
className: "fill-handle",
|
|
973
|
+
onMouseDown: (event) => {
|
|
974
|
+
event.stopPropagation();
|
|
975
|
+
event.preventDefault();
|
|
976
|
+
onFillHandleMouseDown(rowIndex, cellIndex);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
)
|
|
980
|
+
]
|
|
981
|
+
},
|
|
982
|
+
cell.id
|
|
983
|
+
);
|
|
984
|
+
})
|
|
985
|
+
}
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// src/components/ui/table/components/DataTable/DataTableToolbar.tsx
|
|
990
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
991
|
+
function DataTableToolbar({
|
|
992
|
+
filteredCount,
|
|
993
|
+
totalCount,
|
|
994
|
+
summary,
|
|
995
|
+
selectedCount,
|
|
996
|
+
selectionLabel,
|
|
997
|
+
toolbar,
|
|
998
|
+
className
|
|
999
|
+
}) {
|
|
1000
|
+
const displayFiltered = filteredCount ?? totalCount;
|
|
1001
|
+
const hasCount = displayFiltered !== void 0 || totalCount !== void 0;
|
|
1002
|
+
const hasLeftContent = hasCount || Boolean(summary);
|
|
1003
|
+
const hasToolbar = Boolean(toolbar);
|
|
1004
|
+
const selectionContent = selectionLabel?.(selectedCount) ?? null;
|
|
1005
|
+
const hasSelectionContent = selectionContent !== null && selectionContent !== false && selectionContent !== void 0 && typeof selectionContent !== "boolean";
|
|
1006
|
+
if (!hasLeftContent && !hasToolbar && !hasSelectionContent) return null;
|
|
1007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("DataTableToolbarJSX", className), children: [
|
|
1008
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "toolbar-left", children: [
|
|
1009
|
+
hasCount && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "toolbar-count", children: displayFiltered !== void 0 && totalCount !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1010
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "toolbar-count-primary", children: displayFiltered }),
|
|
1011
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "toolbar-count-placeholder", children: [
|
|
1012
|
+
" / ",
|
|
1013
|
+
totalCount
|
|
1014
|
+
] })
|
|
1015
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "toolbar-count-primary", children: displayFiltered ?? totalCount }) }),
|
|
1016
|
+
summary
|
|
1017
|
+
] }),
|
|
1018
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "toolbar-right", children: [
|
|
1019
|
+
hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "toolbar-selection", children: selectionContent }) : selectionContent),
|
|
1020
|
+
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "toolbar-actions", children: toolbar })
|
|
1021
|
+
] })
|
|
1022
|
+
] });
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// src/core/useGlideTable.ts
|
|
1026
|
+
var import_react_table2 = require("@tanstack/react-table");
|
|
1027
|
+
var import_react_virtual = require("@tanstack/react-virtual");
|
|
1028
|
+
var import_react6 = require("react");
|
|
1029
|
+
|
|
1030
|
+
// src/components/ui/table/features/cell-edit/useCellEdit.ts
|
|
1031
|
+
var import_react4 = require("react");
|
|
1032
|
+
function useCellEdit({
|
|
1033
|
+
data,
|
|
1034
|
+
rows,
|
|
1035
|
+
onDataChange,
|
|
1036
|
+
onCellChange
|
|
1037
|
+
}) {
|
|
1038
|
+
const [editingCell, setEditingCell] = (0, import_react4.useState)(null);
|
|
1039
|
+
const [draftValue, setDraftValue] = (0, import_react4.useState)("");
|
|
1040
|
+
const draftValueRef = (0, import_react4.useRef)(draftValue);
|
|
1041
|
+
const editingCellRef = (0, import_react4.useRef)(editingCell);
|
|
1042
|
+
(0, import_react4.useEffect)(() => {
|
|
1043
|
+
draftValueRef.current = draftValue;
|
|
1044
|
+
}, [draftValue]);
|
|
1045
|
+
(0, import_react4.useEffect)(() => {
|
|
1046
|
+
editingCellRef.current = editingCell;
|
|
1047
|
+
}, [editingCell]);
|
|
1048
|
+
const cancelEdit = (0, import_react4.useCallback)(() => {
|
|
1049
|
+
setEditingCell(null);
|
|
1050
|
+
setDraftValue("");
|
|
1051
|
+
}, []);
|
|
1052
|
+
const commitEdit = (0, import_react4.useCallback)(
|
|
1053
|
+
(raw) => {
|
|
1054
|
+
const current = editingCellRef.current;
|
|
1055
|
+
if (!current) return true;
|
|
1056
|
+
if (!onCellChange && !onDataChange) {
|
|
1057
|
+
cancelEdit();
|
|
1058
|
+
return true;
|
|
1059
|
+
}
|
|
1060
|
+
const row = rows[current.rowIndex];
|
|
1061
|
+
const cell = row?.getVisibleCells()[current.colIndex];
|
|
1062
|
+
if (!row || !cell) {
|
|
1063
|
+
cancelEdit();
|
|
1064
|
+
return true;
|
|
1065
|
+
}
|
|
1066
|
+
const value = raw ?? draftValueRef.current;
|
|
1067
|
+
if (!isColumnEditable(cell.column.columnDef)) {
|
|
1068
|
+
cancelEdit();
|
|
1069
|
+
return true;
|
|
1070
|
+
}
|
|
1071
|
+
const parsed = parseCellEditValue(value, getColumnEditType(cell.column.columnDef));
|
|
1072
|
+
if (!parsed.ok) return false;
|
|
1073
|
+
if (onCellChange) {
|
|
1074
|
+
onCellChange(row.id, cell.column.id, parsed.value);
|
|
1075
|
+
cancelEdit();
|
|
1076
|
+
return true;
|
|
1077
|
+
}
|
|
1078
|
+
const next = applyCellEdit(data, rows, current.rowIndex, current.colIndex, value);
|
|
1079
|
+
if (!next) return false;
|
|
1080
|
+
onDataChange?.(next);
|
|
1081
|
+
cancelEdit();
|
|
1082
|
+
return true;
|
|
1083
|
+
},
|
|
1084
|
+
[cancelEdit, data, onCellChange, onDataChange, rows]
|
|
1085
|
+
);
|
|
1086
|
+
const startEdit = (0, import_react4.useCallback)(
|
|
1087
|
+
(rowIndex, colIndex) => {
|
|
1088
|
+
const cell = rows[rowIndex]?.getVisibleCells()[colIndex];
|
|
1089
|
+
if (!cell || !isColumnEditable(cell.column.columnDef)) return;
|
|
1090
|
+
const current = editingCellRef.current;
|
|
1091
|
+
if (current && (current.rowIndex !== rowIndex || current.colIndex !== colIndex) && !commitEdit()) {
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
setEditingCell({ rowIndex, colIndex });
|
|
1095
|
+
setDraftValue(getCellEditDraftValue(cell.getValue()));
|
|
1096
|
+
},
|
|
1097
|
+
[commitEdit, rows]
|
|
1098
|
+
);
|
|
1099
|
+
return {
|
|
1100
|
+
editingCell,
|
|
1101
|
+
draftValue,
|
|
1102
|
+
setDraftValue,
|
|
1103
|
+
startEdit,
|
|
1104
|
+
commitEdit,
|
|
1105
|
+
cancelEdit
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// src/components/ui/table/features/cell-selection/useCellSelection.ts
|
|
1110
|
+
var import_react5 = require("react");
|
|
1111
|
+
|
|
1112
|
+
// src/components/ui/table/features/cell-selection/fillData.ts
|
|
1113
|
+
function getColumnAccessorKey2(columnDef) {
|
|
1114
|
+
if ("accessorKey" in columnDef && columnDef.accessorKey) {
|
|
1115
|
+
return String(columnDef.accessorKey);
|
|
1116
|
+
}
|
|
1117
|
+
return columnDef.id;
|
|
1118
|
+
}
|
|
1119
|
+
function collectFillTargets(rows, sourceBounds, fillBounds) {
|
|
1120
|
+
const targets = [];
|
|
1121
|
+
const sourceHeight = sourceBounds.endRow - sourceBounds.startRow + 1;
|
|
1122
|
+
const sourceWidth = sourceBounds.endCol - sourceBounds.startCol + 1;
|
|
1123
|
+
for (let rowIndex = fillBounds.startRow; rowIndex <= fillBounds.endRow; rowIndex += 1) {
|
|
1124
|
+
for (let colIndex = fillBounds.startCol; colIndex <= fillBounds.endCol; colIndex += 1) {
|
|
1125
|
+
if (isCellInSelection(rowIndex, colIndex, sourceBounds)) continue;
|
|
1126
|
+
const offsetRow = rowIndex - sourceBounds.startRow;
|
|
1127
|
+
const offsetCol = colIndex - sourceBounds.startCol;
|
|
1128
|
+
const sourceRowIndex = sourceBounds.startRow + (offsetRow % sourceHeight + sourceHeight) % sourceHeight;
|
|
1129
|
+
const sourceColIndex = sourceBounds.startCol + (offsetCol % sourceWidth + sourceWidth) % sourceWidth;
|
|
1130
|
+
const targetRow = rows[rowIndex];
|
|
1131
|
+
const targetCell = targetRow?.getVisibleCells()[colIndex];
|
|
1132
|
+
const sourceCell = rows[sourceRowIndex]?.getVisibleCells()[sourceColIndex];
|
|
1133
|
+
if (!targetRow || !targetCell || !sourceCell) continue;
|
|
1134
|
+
const accessorKey = getColumnAccessorKey2(
|
|
1135
|
+
targetCell.column.columnDef
|
|
1136
|
+
);
|
|
1137
|
+
if (!accessorKey) continue;
|
|
1138
|
+
targets.push({
|
|
1139
|
+
rowIndex,
|
|
1140
|
+
accessorKey,
|
|
1141
|
+
columnId: targetCell.column.id,
|
|
1142
|
+
value: sourceCell.getValue(),
|
|
1143
|
+
rowId: targetRow.id
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
return targets;
|
|
1148
|
+
}
|
|
1149
|
+
function collectFillChanges(rows, sourceBounds, fillBounds) {
|
|
1150
|
+
return collectFillTargets(rows, sourceBounds, fillBounds).map(
|
|
1151
|
+
({ rowId, columnId, value }) => ({ rowId, columnId, value })
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
function applyFillData(data, rows, sourceBounds, fillBounds) {
|
|
1155
|
+
const newData = data.map((row) => ({ ...row }));
|
|
1156
|
+
const targets = collectFillTargets(rows, sourceBounds, fillBounds);
|
|
1157
|
+
for (const target of targets) {
|
|
1158
|
+
if (!newData[target.rowIndex]) continue;
|
|
1159
|
+
newData[target.rowIndex][target.accessorKey] = target.value;
|
|
1160
|
+
}
|
|
1161
|
+
return newData;
|
|
1162
|
+
}
|
|
1163
|
+
function hasFillExtension(sourceBounds, fillBounds) {
|
|
1164
|
+
if (!sourceBounds) return false;
|
|
1165
|
+
return fillBounds.startRow < sourceBounds.startRow || fillBounds.endRow > sourceBounds.endRow || fillBounds.startCol < sourceBounds.startCol || fillBounds.endCol > sourceBounds.endCol;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
// src/components/ui/table/features/cell-selection/useCellSelection.ts
|
|
1169
|
+
function useCellSelection({
|
|
1170
|
+
data,
|
|
1171
|
+
rows,
|
|
1172
|
+
enabled = true,
|
|
1173
|
+
onDataChange,
|
|
1174
|
+
onBatchChange
|
|
1175
|
+
}) {
|
|
1176
|
+
const [dragState, setDragState] = (0, import_react5.useState)(INITIAL_DRAG_STATE);
|
|
1177
|
+
const cellSelectionBounds = getCellSelectionBounds(dragState.start, dragState.end);
|
|
1178
|
+
const activeSelectionBounds = enabled ? getActiveSelectionBounds(dragState, cellSelectionBounds) : null;
|
|
1179
|
+
const handleCellMouseDown = (0, import_react5.useCallback)(
|
|
1180
|
+
(rowIndex, colIndex) => {
|
|
1181
|
+
if (!enabled) return;
|
|
1182
|
+
setDragState({
|
|
1183
|
+
isSelecting: true,
|
|
1184
|
+
isFillDragging: false,
|
|
1185
|
+
start: { row: rowIndex, col: colIndex },
|
|
1186
|
+
end: { row: rowIndex, col: colIndex },
|
|
1187
|
+
fillAnchor: null,
|
|
1188
|
+
fillEnd: null
|
|
1189
|
+
});
|
|
1190
|
+
},
|
|
1191
|
+
[enabled]
|
|
1192
|
+
);
|
|
1193
|
+
const handleCellMouseEnter = (0, import_react5.useCallback)(
|
|
1194
|
+
(rowIndex, colIndex) => {
|
|
1195
|
+
if (!enabled) return;
|
|
1196
|
+
setDragState((prev) => {
|
|
1197
|
+
if (prev.isSelecting) {
|
|
1198
|
+
return { ...prev, end: { row: rowIndex, col: colIndex } };
|
|
1199
|
+
}
|
|
1200
|
+
if (prev.isFillDragging) {
|
|
1201
|
+
return { ...prev, fillEnd: { row: rowIndex, col: colIndex } };
|
|
1202
|
+
}
|
|
1203
|
+
return prev;
|
|
1204
|
+
});
|
|
1205
|
+
},
|
|
1206
|
+
[enabled]
|
|
1207
|
+
);
|
|
1208
|
+
const handleFillHandleMouseDown = (0, import_react5.useCallback)(
|
|
1209
|
+
(rowIndex, colIndex) => {
|
|
1210
|
+
if (!enabled) return;
|
|
1211
|
+
setDragState((prev) => {
|
|
1212
|
+
const bounds = getCellSelectionBounds(prev.start, prev.end);
|
|
1213
|
+
if (!bounds) return prev;
|
|
1214
|
+
return {
|
|
1215
|
+
...prev,
|
|
1216
|
+
isSelecting: false,
|
|
1217
|
+
isFillDragging: true,
|
|
1218
|
+
fillAnchor: { row: bounds.startRow, col: bounds.startCol },
|
|
1219
|
+
fillEnd: { row: rowIndex, col: colIndex }
|
|
1220
|
+
};
|
|
1221
|
+
});
|
|
1222
|
+
},
|
|
1223
|
+
[enabled]
|
|
1224
|
+
);
|
|
1225
|
+
(0, import_react5.useEffect)(() => {
|
|
1226
|
+
if (!enabled) {
|
|
1227
|
+
setDragState(INITIAL_DRAG_STATE);
|
|
1228
|
+
}
|
|
1229
|
+
}, [enabled]);
|
|
1230
|
+
(0, import_react5.useEffect)(() => {
|
|
1231
|
+
if (!enabled) return;
|
|
1232
|
+
const handleKeyDown = (e) => {
|
|
1233
|
+
if ((e.ctrlKey || e.metaKey) && e.key === "c" && activeSelectionBounds) {
|
|
1234
|
+
const { startRow, endRow, startCol, endCol } = activeSelectionBounds;
|
|
1235
|
+
const selectedData = rows.slice(startRow, endRow + 1).map((row) => {
|
|
1236
|
+
const cells = row.getVisibleCells();
|
|
1237
|
+
return cells.slice(startCol, endCol + 1).map((cell) => cell.getValue()).join(" ");
|
|
1238
|
+
}).join("\n");
|
|
1239
|
+
navigator.clipboard.writeText(selectedData);
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1243
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1244
|
+
}, [activeSelectionBounds, enabled, rows]);
|
|
1245
|
+
(0, import_react5.useEffect)(() => {
|
|
1246
|
+
if (!enabled) return;
|
|
1247
|
+
const handleMouseUp = () => {
|
|
1248
|
+
setDragState((prev) => {
|
|
1249
|
+
if (prev.isFillDragging && prev.fillAnchor && prev.fillEnd) {
|
|
1250
|
+
const sourceBounds = getCellSelectionBounds(prev.start, prev.end);
|
|
1251
|
+
const newBounds = getCellSelectionBounds(prev.fillAnchor, prev.fillEnd);
|
|
1252
|
+
if (newBounds) {
|
|
1253
|
+
if (hasFillExtension(sourceBounds, newBounds) && sourceBounds) {
|
|
1254
|
+
if (onBatchChange) {
|
|
1255
|
+
const changes = collectFillChanges(rows, sourceBounds, newBounds);
|
|
1256
|
+
if (changes.length > 0) {
|
|
1257
|
+
onBatchChange(changes);
|
|
1258
|
+
}
|
|
1259
|
+
} else if (onDataChange) {
|
|
1260
|
+
onDataChange(applyFillData(data, rows, sourceBounds, newBounds));
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
return {
|
|
1264
|
+
isSelecting: false,
|
|
1265
|
+
isFillDragging: false,
|
|
1266
|
+
start: { row: newBounds.startRow, col: newBounds.startCol },
|
|
1267
|
+
end: { row: newBounds.endRow, col: newBounds.endCol },
|
|
1268
|
+
fillAnchor: null,
|
|
1269
|
+
fillEnd: null
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
if (prev.isSelecting) {
|
|
1274
|
+
return { ...prev, isSelecting: false };
|
|
1275
|
+
}
|
|
1276
|
+
if (prev.isFillDragging) {
|
|
1277
|
+
return { ...prev, isFillDragging: false, fillAnchor: null, fillEnd: null };
|
|
1278
|
+
}
|
|
1279
|
+
return prev;
|
|
1280
|
+
});
|
|
1281
|
+
};
|
|
1282
|
+
window.addEventListener("mouseup", handleMouseUp);
|
|
1283
|
+
return () => window.removeEventListener("mouseup", handleMouseUp);
|
|
1284
|
+
}, [data, enabled, onBatchChange, onDataChange, rows]);
|
|
1285
|
+
return {
|
|
1286
|
+
dragState: enabled ? dragState : INITIAL_DRAG_STATE,
|
|
1287
|
+
activeSelectionBounds,
|
|
1288
|
+
handleCellMouseDown,
|
|
1289
|
+
handleCellMouseEnter,
|
|
1290
|
+
handleFillHandleMouseDown
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// src/components/ui/table/features/row-selection/rowSelection.ts
|
|
1295
|
+
function resolveRowSelection(mode, controlledSelection, internalSelection) {
|
|
1296
|
+
if (mode === "none") return {};
|
|
1297
|
+
return controlledSelection ?? internalSelection;
|
|
1298
|
+
}
|
|
1299
|
+
function normalizeSingleSelection(next) {
|
|
1300
|
+
const selectedIds = Object.keys(next).filter((id) => next[id]);
|
|
1301
|
+
if (selectedIds.length <= 1) return next;
|
|
1302
|
+
return { [selectedIds[selectedIds.length - 1]]: true };
|
|
1303
|
+
}
|
|
1304
|
+
function applySelectionUpdater(mode, updater, previous) {
|
|
1305
|
+
const next = typeof updater === "function" ? updater(previous) : updater;
|
|
1306
|
+
return mode === "single" ? normalizeSingleSelection(next) : next;
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
// src/core/labels.ts
|
|
1310
|
+
var DEFAULT_DATA_TABLE_LABELS = {
|
|
1311
|
+
empty: "No data",
|
|
1312
|
+
loading: "Loading...",
|
|
1313
|
+
selection: (selectedCount) => selectedCount > 0 ? `\u2713 ${selectedCount} selected` : null,
|
|
1314
|
+
expandRow: "Expand row",
|
|
1315
|
+
collapseRow: "Collapse row"
|
|
1316
|
+
};
|
|
1317
|
+
function resolveDataTableLabels(partial) {
|
|
1318
|
+
return {
|
|
1319
|
+
...DEFAULT_DATA_TABLE_LABELS,
|
|
1320
|
+
...partial
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// src/core/useGlideTable.ts
|
|
1325
|
+
function useGlideTable(options) {
|
|
1326
|
+
const {
|
|
1327
|
+
data,
|
|
1328
|
+
columns,
|
|
1329
|
+
rowSelectionMode = "none",
|
|
1330
|
+
rowSelection: controlledRowSelection,
|
|
1331
|
+
onRowSelectionChange,
|
|
1332
|
+
selectionLabel,
|
|
1333
|
+
emptyText,
|
|
1334
|
+
loadingText,
|
|
1335
|
+
labels: labelsProp,
|
|
1336
|
+
enableRowSpan = false,
|
|
1337
|
+
getRowId,
|
|
1338
|
+
onRowClick,
|
|
1339
|
+
getRowClassName,
|
|
1340
|
+
getRowCanSelect,
|
|
1341
|
+
selectOnRowClick = true,
|
|
1342
|
+
enableCellSelection = true,
|
|
1343
|
+
onDataChange,
|
|
1344
|
+
onCellChange,
|
|
1345
|
+
onBatchChange,
|
|
1346
|
+
preserveRowSelection = false,
|
|
1347
|
+
toggleField,
|
|
1348
|
+
childField,
|
|
1349
|
+
flattenField,
|
|
1350
|
+
qtyField,
|
|
1351
|
+
expandedRows: controlledExpandedRows,
|
|
1352
|
+
onExpandedRowsChange,
|
|
1353
|
+
preventExpand = false,
|
|
1354
|
+
enableVirtualization = true,
|
|
1355
|
+
estimateRowHeight = DATA_TABLE_ROW_HEIGHT,
|
|
1356
|
+
virtualOverscan = DATA_TABLE_VIRTUAL_OVERSCAN
|
|
1357
|
+
} = options;
|
|
1358
|
+
const labels = (0, import_react6.useMemo)(() => {
|
|
1359
|
+
const resolved = resolveDataTableLabels(labelsProp);
|
|
1360
|
+
return {
|
|
1361
|
+
...resolved,
|
|
1362
|
+
empty: labelsProp?.empty ?? emptyText ?? resolved.empty,
|
|
1363
|
+
loading: labelsProp?.loading ?? loadingText ?? resolved.loading,
|
|
1364
|
+
selection: labelsProp?.selection ?? selectionLabel ?? resolved.selection
|
|
1365
|
+
};
|
|
1366
|
+
}, [labelsProp, emptyText, loadingText, selectionLabel]);
|
|
1367
|
+
const enableExpand = Boolean(toggleField);
|
|
1368
|
+
const [internalRowSelection, setInternalRowSelection] = (0, import_react6.useState)({});
|
|
1369
|
+
const [internalExpandedRows, setInternalExpandedRows] = (0, import_react6.useState)(
|
|
1370
|
+
() => /* @__PURE__ */ new Set()
|
|
1371
|
+
);
|
|
1372
|
+
const [hoveredRowIndex, setHoveredRowIndex] = (0, import_react6.useState)(null);
|
|
1373
|
+
const [hoveredGroupKey, setHoveredGroupKey] = (0, import_react6.useState)(null);
|
|
1374
|
+
const scrollRef = (0, import_react6.useRef)(null);
|
|
1375
|
+
const shouldVirtualize = enableVirtualization && !enableRowSpan;
|
|
1376
|
+
(0, import_react6.useEffect)(() => {
|
|
1377
|
+
if (enableVirtualization && enableRowSpan) {
|
|
1378
|
+
console.warn(
|
|
1379
|
+
"[useGlideTable] enableRowSpan is on; virtualization is disabled to preserve cell merges."
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
}, [enableVirtualization, enableRowSpan]);
|
|
1383
|
+
const rowSelection = resolveRowSelection(
|
|
1384
|
+
rowSelectionMode,
|
|
1385
|
+
controlledRowSelection,
|
|
1386
|
+
internalRowSelection
|
|
1387
|
+
);
|
|
1388
|
+
const expandedRows = controlledExpandedRows ?? internalExpandedRows;
|
|
1389
|
+
const handleExpandedRowsChange = (0, import_react6.useCallback)(
|
|
1390
|
+
(next) => {
|
|
1391
|
+
if (onExpandedRowsChange) {
|
|
1392
|
+
onExpandedRowsChange(next);
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
setInternalExpandedRows(next);
|
|
1396
|
+
},
|
|
1397
|
+
[onExpandedRowsChange]
|
|
1398
|
+
);
|
|
1399
|
+
const tableData = useConvertTreeData({
|
|
1400
|
+
data,
|
|
1401
|
+
enabled: enableExpand,
|
|
1402
|
+
toggleField,
|
|
1403
|
+
childField,
|
|
1404
|
+
flattenField,
|
|
1405
|
+
qtyField,
|
|
1406
|
+
expandedRows,
|
|
1407
|
+
onExpandedRowsChange: enableExpand ? handleExpandedRowsChange : void 0,
|
|
1408
|
+
preventExpand
|
|
1409
|
+
});
|
|
1410
|
+
const table = (0, import_react_table2.useReactTable)({
|
|
1411
|
+
data: tableData,
|
|
1412
|
+
columns,
|
|
1413
|
+
state: {
|
|
1414
|
+
rowSelection: rowSelectionMode === "none" ? {} : rowSelection
|
|
1415
|
+
},
|
|
1416
|
+
enableRowSelection: rowSelectionMode === "none" ? false : getRowCanSelect ? (row) => getRowCanSelect(row.original, row.index) : true,
|
|
1417
|
+
enableMultiRowSelection: rowSelectionMode === "multi",
|
|
1418
|
+
onRowSelectionChange: (updater) => {
|
|
1419
|
+
if (onRowSelectionChange) {
|
|
1420
|
+
onRowSelectionChange(
|
|
1421
|
+
(previous) => applySelectionUpdater(rowSelectionMode, updater, previous)
|
|
1422
|
+
);
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
setInternalRowSelection(
|
|
1426
|
+
(previous) => applySelectionUpdater(rowSelectionMode, updater, previous)
|
|
1427
|
+
);
|
|
1428
|
+
},
|
|
1429
|
+
getCoreRowModel: (0, import_react_table2.getCoreRowModel)(),
|
|
1430
|
+
getRowId: getRowId ? (originalRow, index) => getRowId(originalRow, index) : (_originalRow, index) => String(index)
|
|
1431
|
+
});
|
|
1432
|
+
const rowSpanColumnKeys = (0, import_react6.useMemo)(() => {
|
|
1433
|
+
if (!enableRowSpan) return [];
|
|
1434
|
+
return collectRowSpanColumns(columns);
|
|
1435
|
+
}, [enableRowSpan, columns]);
|
|
1436
|
+
const primaryRowSpanKey = rowSpanColumnKeys[0]?.rowSpanKey;
|
|
1437
|
+
const columnRowSpanMap = (0, import_react6.useMemo)(
|
|
1438
|
+
() => buildColumnRowSpanMap(tableData, rowSpanColumnKeys),
|
|
1439
|
+
[tableData, rowSpanColumnKeys]
|
|
1440
|
+
);
|
|
1441
|
+
const selectedRows = table.getSelectedRowModel().rows;
|
|
1442
|
+
const selectedCount = selectedRows.length;
|
|
1443
|
+
const rows = table.getRowModel().rows;
|
|
1444
|
+
const columnCount = table.getAllLeafColumns().length || 1;
|
|
1445
|
+
const rowVirtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
1446
|
+
count: shouldVirtualize ? rows.length : 0,
|
|
1447
|
+
getScrollElement: () => scrollRef.current,
|
|
1448
|
+
estimateSize: () => estimateRowHeight,
|
|
1449
|
+
overscan: virtualOverscan
|
|
1450
|
+
});
|
|
1451
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
1452
|
+
const totalSize = rowVirtualizer.getTotalSize();
|
|
1453
|
+
const paddingTop = virtualRows.length > 0 ? virtualRows[0]?.start ?? 0 : 0;
|
|
1454
|
+
const paddingBottom = virtualRows.length > 0 ? totalSize - (virtualRows[virtualRows.length - 1]?.end ?? 0) : 0;
|
|
1455
|
+
const selectedGroupKeys = (0, import_react6.useMemo)(() => {
|
|
1456
|
+
if (!enableRowSpan || !primaryRowSpanKey) return /* @__PURE__ */ new Set();
|
|
1457
|
+
const keys = /* @__PURE__ */ new Set();
|
|
1458
|
+
for (const selectedRow of selectedRows) {
|
|
1459
|
+
const value = selectedRow.original[primaryRowSpanKey];
|
|
1460
|
+
if (value !== null && value !== void 0) keys.add(String(value));
|
|
1461
|
+
}
|
|
1462
|
+
return keys;
|
|
1463
|
+
}, [enableRowSpan, primaryRowSpanKey, selectedRows]);
|
|
1464
|
+
const {
|
|
1465
|
+
dragState,
|
|
1466
|
+
activeSelectionBounds,
|
|
1467
|
+
handleCellMouseDown,
|
|
1468
|
+
handleCellMouseEnter,
|
|
1469
|
+
handleFillHandleMouseDown
|
|
1470
|
+
} = useCellSelection({
|
|
1471
|
+
data: tableData,
|
|
1472
|
+
rows,
|
|
1473
|
+
enabled: enableCellSelection,
|
|
1474
|
+
onDataChange,
|
|
1475
|
+
onBatchChange
|
|
1476
|
+
});
|
|
1477
|
+
const {
|
|
1478
|
+
editingCell,
|
|
1479
|
+
draftValue,
|
|
1480
|
+
setDraftValue,
|
|
1481
|
+
startEdit,
|
|
1482
|
+
commitEdit,
|
|
1483
|
+
cancelEdit
|
|
1484
|
+
} = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
|
|
1485
|
+
const handleCellMouseDownWithCommit = (0, import_react6.useCallback)(
|
|
1486
|
+
(rowIndex, colIndex) => {
|
|
1487
|
+
const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
|
|
1488
|
+
if (editingCell && !isSameEditingCell && !commitEdit()) {
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1491
|
+
handleCellMouseDown(rowIndex, colIndex);
|
|
1492
|
+
},
|
|
1493
|
+
[commitEdit, editingCell, handleCellMouseDown]
|
|
1494
|
+
);
|
|
1495
|
+
const clearHover = (0, import_react6.useCallback)(() => {
|
|
1496
|
+
setHoveredRowIndex(null);
|
|
1497
|
+
setHoveredGroupKey(null);
|
|
1498
|
+
}, []);
|
|
1499
|
+
const handleRowHover = (0, import_react6.useCallback)(
|
|
1500
|
+
(rowIndex, rowData) => {
|
|
1501
|
+
setHoveredRowIndex(rowIndex);
|
|
1502
|
+
if (!primaryRowSpanKey) {
|
|
1503
|
+
setHoveredGroupKey(null);
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
const groupValue = rowData[primaryRowSpanKey];
|
|
1507
|
+
setHoveredGroupKey(
|
|
1508
|
+
groupValue === null || groupValue === void 0 ? null : String(groupValue)
|
|
1509
|
+
);
|
|
1510
|
+
},
|
|
1511
|
+
[primaryRowSpanKey]
|
|
1512
|
+
);
|
|
1513
|
+
const handleToggleSelect = (0, import_react6.useCallback)(
|
|
1514
|
+
(row) => {
|
|
1515
|
+
if (!row.getCanSelect()) return;
|
|
1516
|
+
if (preserveRowSelection && row.getIsSelected()) {
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
row.toggleSelected();
|
|
1520
|
+
},
|
|
1521
|
+
[preserveRowSelection]
|
|
1522
|
+
);
|
|
1523
|
+
const handleToggleExpand = (0, import_react6.useCallback)(
|
|
1524
|
+
(rowKey) => {
|
|
1525
|
+
if (preventExpand) return;
|
|
1526
|
+
handleExpandedRowsChange(toggleExpandedRowId(rowKey, expandedRows));
|
|
1527
|
+
},
|
|
1528
|
+
[preventExpand, handleExpandedRowsChange, expandedRows]
|
|
1529
|
+
);
|
|
1530
|
+
const rowContextValue = (0, import_react6.useMemo)(() => {
|
|
1531
|
+
return {
|
|
1532
|
+
rowSpan: {
|
|
1533
|
+
enableRowSpan,
|
|
1534
|
+
primaryRowSpanKey,
|
|
1535
|
+
columnRowSpanMap,
|
|
1536
|
+
hoveredRowIndex,
|
|
1537
|
+
hoveredGroupKey,
|
|
1538
|
+
selectedGroupKeys,
|
|
1539
|
+
onRowHover: handleRowHover
|
|
1540
|
+
},
|
|
1541
|
+
selection: {
|
|
1542
|
+
rowSelectionMode,
|
|
1543
|
+
selectOnRowClick,
|
|
1544
|
+
onRowClick,
|
|
1545
|
+
getRowClassName
|
|
1546
|
+
},
|
|
1547
|
+
cellSelection: {
|
|
1548
|
+
enableCellSelection,
|
|
1549
|
+
activeSelectionBounds,
|
|
1550
|
+
dragState,
|
|
1551
|
+
onCellMouseDown: handleCellMouseDownWithCommit,
|
|
1552
|
+
onCellMouseEnter: handleCellMouseEnter,
|
|
1553
|
+
onFillHandleMouseDown: handleFillHandleMouseDown
|
|
1554
|
+
},
|
|
1555
|
+
cellEdit: {
|
|
1556
|
+
editingCell,
|
|
1557
|
+
draftValue,
|
|
1558
|
+
onDraftValueChange: setDraftValue,
|
|
1559
|
+
onStartEdit: startEdit,
|
|
1560
|
+
onCommitEdit: commitEdit,
|
|
1561
|
+
onCancelEdit: cancelEdit
|
|
1562
|
+
},
|
|
1563
|
+
expand: {
|
|
1564
|
+
enableExpand,
|
|
1565
|
+
toggleField,
|
|
1566
|
+
expandedRows,
|
|
1567
|
+
preventExpand,
|
|
1568
|
+
onToggleExpand: handleToggleExpand,
|
|
1569
|
+
expandRowLabel: labels.expandRow,
|
|
1570
|
+
collapseRowLabel: labels.collapseRow
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
}, [
|
|
1574
|
+
enableRowSpan,
|
|
1575
|
+
primaryRowSpanKey,
|
|
1576
|
+
columnRowSpanMap,
|
|
1577
|
+
hoveredRowIndex,
|
|
1578
|
+
hoveredGroupKey,
|
|
1579
|
+
selectedGroupKeys,
|
|
1580
|
+
handleRowHover,
|
|
1581
|
+
rowSelectionMode,
|
|
1582
|
+
selectOnRowClick,
|
|
1583
|
+
onRowClick,
|
|
1584
|
+
getRowClassName,
|
|
1585
|
+
enableCellSelection,
|
|
1586
|
+
activeSelectionBounds,
|
|
1587
|
+
dragState,
|
|
1588
|
+
handleCellMouseDownWithCommit,
|
|
1589
|
+
handleCellMouseEnter,
|
|
1590
|
+
handleFillHandleMouseDown,
|
|
1591
|
+
editingCell,
|
|
1592
|
+
draftValue,
|
|
1593
|
+
setDraftValue,
|
|
1594
|
+
startEdit,
|
|
1595
|
+
commitEdit,
|
|
1596
|
+
cancelEdit,
|
|
1597
|
+
enableExpand,
|
|
1598
|
+
toggleField,
|
|
1599
|
+
expandedRows,
|
|
1600
|
+
preventExpand,
|
|
1601
|
+
handleToggleExpand,
|
|
1602
|
+
labels.expandRow,
|
|
1603
|
+
labels.collapseRow
|
|
1604
|
+
]);
|
|
1605
|
+
return {
|
|
1606
|
+
table,
|
|
1607
|
+
tableData,
|
|
1608
|
+
rows,
|
|
1609
|
+
columnCount,
|
|
1610
|
+
selectedCount,
|
|
1611
|
+
labels,
|
|
1612
|
+
emptyText: labels.empty,
|
|
1613
|
+
loadingText: labels.loading,
|
|
1614
|
+
selectionLabel: labels.selection,
|
|
1615
|
+
enableCellSelection,
|
|
1616
|
+
shouldVirtualize,
|
|
1617
|
+
scrollRef,
|
|
1618
|
+
rowVirtualizer,
|
|
1619
|
+
virtualRows,
|
|
1620
|
+
paddingTop,
|
|
1621
|
+
paddingBottom,
|
|
1622
|
+
rowContextValue,
|
|
1623
|
+
handleToggleSelect,
|
|
1624
|
+
clearHover
|
|
1625
|
+
};
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
1629
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1630
|
+
function DefaultPending({
|
|
1631
|
+
loadingText,
|
|
1632
|
+
className
|
|
1633
|
+
}) {
|
|
1634
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: cn("DataTableJSX", "DataTableJSX--pending", className), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "data-table-loading-text", children: loadingText }) });
|
|
1635
|
+
}
|
|
1636
|
+
function DefaultEmpty({
|
|
1637
|
+
emptyText,
|
|
1638
|
+
columnCount
|
|
1639
|
+
}) {
|
|
1640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { colSpan: columnCount, className: "data-table-empty-cell", children: emptyText }) });
|
|
1641
|
+
}
|
|
1642
|
+
function DataTable({
|
|
1643
|
+
isPending = false,
|
|
1644
|
+
summary,
|
|
1645
|
+
toolbar,
|
|
1646
|
+
filteredCount,
|
|
1647
|
+
totalCount,
|
|
1648
|
+
className,
|
|
1649
|
+
slots,
|
|
1650
|
+
...glideOptions
|
|
1651
|
+
}) {
|
|
1652
|
+
const {
|
|
1653
|
+
table,
|
|
1654
|
+
tableData,
|
|
1655
|
+
rows,
|
|
1656
|
+
columnCount,
|
|
1657
|
+
selectedCount,
|
|
1658
|
+
emptyText,
|
|
1659
|
+
loadingText,
|
|
1660
|
+
selectionLabel,
|
|
1661
|
+
enableCellSelection,
|
|
1662
|
+
shouldVirtualize,
|
|
1663
|
+
scrollRef,
|
|
1664
|
+
rowVirtualizer,
|
|
1665
|
+
virtualRows,
|
|
1666
|
+
paddingTop,
|
|
1667
|
+
paddingBottom,
|
|
1668
|
+
rowContextValue,
|
|
1669
|
+
handleToggleSelect,
|
|
1670
|
+
clearHover
|
|
1671
|
+
} = useGlideTable(glideOptions);
|
|
1672
|
+
const ToolbarSlot = slots?.Toolbar ?? DataTableToolbar;
|
|
1673
|
+
const RowSlot = slots?.Row ?? DataTableRow;
|
|
1674
|
+
const PendingSlot = slots?.Pending ?? DefaultPending;
|
|
1675
|
+
const EmptySlot = slots?.Empty ?? DefaultEmpty;
|
|
1676
|
+
if (isPending) {
|
|
1677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PendingSlot, { loadingText, className });
|
|
1678
|
+
}
|
|
1679
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1680
|
+
"div",
|
|
1681
|
+
{
|
|
1682
|
+
className: cn(
|
|
1683
|
+
"DataTableJSX",
|
|
1684
|
+
!enableCellSelection && "DataTableJSX--no-cell-selection",
|
|
1685
|
+
className
|
|
1686
|
+
),
|
|
1687
|
+
children: [
|
|
1688
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1689
|
+
ToolbarSlot,
|
|
1690
|
+
{
|
|
1691
|
+
filteredCount: filteredCount ?? tableData.length,
|
|
1692
|
+
totalCount,
|
|
1693
|
+
summary,
|
|
1694
|
+
selectedCount,
|
|
1695
|
+
selectionLabel,
|
|
1696
|
+
toolbar
|
|
1697
|
+
}
|
|
1698
|
+
),
|
|
1699
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: scrollRef, className: "data-table-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1700
|
+
"table",
|
|
1701
|
+
{
|
|
1702
|
+
className: "data-table",
|
|
1703
|
+
onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
|
|
1704
|
+
children: [
|
|
1705
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: "data-table-head", children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { className: "data-table-head-row", children: headerGroup.headers.map((header) => {
|
|
1706
|
+
const align = header.column.columnDef.meta?.align ?? "center";
|
|
1707
|
+
const headerClassName = header.column.columnDef.meta?.headerClassName;
|
|
1708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1709
|
+
"th",
|
|
1710
|
+
{
|
|
1711
|
+
style: { width: header.getSize() !== 150 ? header.getSize() : void 0 },
|
|
1712
|
+
className: cn(
|
|
1713
|
+
"data-table-head-cell",
|
|
1714
|
+
CELL_ALIGN_CLASS[align],
|
|
1715
|
+
headerClassName
|
|
1716
|
+
),
|
|
1717
|
+
children: header.isPlaceholder ? null : (0, import_react_table3.flexRender)(header.column.columnDef.header, header.getContext())
|
|
1718
|
+
},
|
|
1719
|
+
header.id
|
|
1720
|
+
);
|
|
1721
|
+
}) }, headerGroup.id)) }),
|
|
1722
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DataTableContextProvider, { value: rowContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { onMouseLeave: clearHover, className: "data-table-body", children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EmptySlot, { emptyText, columnCount }) : shouldVirtualize ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1723
|
+
paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { "aria-hidden": true, className: "data-table-virtual-spacer", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1724
|
+
"td",
|
|
1725
|
+
{
|
|
1726
|
+
colSpan: columnCount,
|
|
1727
|
+
style: { height: paddingTop },
|
|
1728
|
+
className: "data-table-virtual-spacer-cell"
|
|
1729
|
+
}
|
|
1730
|
+
) }),
|
|
1731
|
+
virtualRows.map((virtualRow) => {
|
|
1732
|
+
const row = rows[virtualRow.index];
|
|
1733
|
+
if (!row) return null;
|
|
1734
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1735
|
+
RowSlot,
|
|
1736
|
+
{
|
|
1737
|
+
row,
|
|
1738
|
+
virtualIndex: virtualRow.index,
|
|
1739
|
+
measureElement: rowVirtualizer.measureElement,
|
|
1740
|
+
onToggleSelect: () => handleToggleSelect(row)
|
|
1741
|
+
},
|
|
1742
|
+
row.id
|
|
1743
|
+
);
|
|
1744
|
+
}),
|
|
1745
|
+
paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { "aria-hidden": true, className: "data-table-virtual-spacer", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1746
|
+
"td",
|
|
1747
|
+
{
|
|
1748
|
+
colSpan: columnCount,
|
|
1749
|
+
style: { height: paddingBottom },
|
|
1750
|
+
className: "data-table-virtual-spacer-cell"
|
|
1751
|
+
}
|
|
1752
|
+
) })
|
|
1753
|
+
] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1754
|
+
RowSlot,
|
|
1755
|
+
{
|
|
1756
|
+
row,
|
|
1757
|
+
onToggleSelect: () => handleToggleSelect(row)
|
|
1758
|
+
},
|
|
1759
|
+
row.id
|
|
1760
|
+
)) }) })
|
|
1761
|
+
]
|
|
1762
|
+
}
|
|
1763
|
+
) })
|
|
1764
|
+
]
|
|
1765
|
+
}
|
|
1766
|
+
);
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
// src/components/ui/table/components/Table/Table.tsx
|
|
1770
|
+
var import_react9 = require("react");
|
|
1771
|
+
|
|
1772
|
+
// src/components/ui/table/components/Table/buildColumnDef.tsx
|
|
1773
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1774
|
+
function SortableHeader({
|
|
1775
|
+
label,
|
|
1776
|
+
field,
|
|
1777
|
+
sort,
|
|
1778
|
+
onSort
|
|
1779
|
+
}) {
|
|
1780
|
+
const isActive = sort?.field === field;
|
|
1781
|
+
const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
|
|
1782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1783
|
+
"button",
|
|
1784
|
+
{
|
|
1785
|
+
type: "button",
|
|
1786
|
+
className: cn("SortableHeaderJSX", isActive ? "is-active" : "is-inactive"),
|
|
1787
|
+
onClick: () => onSort(field),
|
|
1788
|
+
children: [
|
|
1789
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: label }),
|
|
1790
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { className: "sortable-header-icon" })
|
|
1791
|
+
]
|
|
1792
|
+
}
|
|
1793
|
+
);
|
|
1794
|
+
}
|
|
1795
|
+
function buildColumnDef(props, sort, onSort) {
|
|
1796
|
+
const {
|
|
1797
|
+
field,
|
|
1798
|
+
virtual = false,
|
|
1799
|
+
children,
|
|
1800
|
+
sortable = false,
|
|
1801
|
+
width,
|
|
1802
|
+
align,
|
|
1803
|
+
rowSpan,
|
|
1804
|
+
rowSpanKey,
|
|
1805
|
+
editable,
|
|
1806
|
+
editType,
|
|
1807
|
+
className,
|
|
1808
|
+
headerClassName,
|
|
1809
|
+
render
|
|
1810
|
+
} = props;
|
|
1811
|
+
return {
|
|
1812
|
+
id: field,
|
|
1813
|
+
...!virtual ? { accessorKey: field } : {},
|
|
1814
|
+
size: width ?? 150,
|
|
1815
|
+
header: sortable ? () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SortableHeader, { label: children, field, sort, onSort }) : (
|
|
1816
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1817
|
+
() => children
|
|
1818
|
+
),
|
|
1819
|
+
...render ? {
|
|
1820
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1821
|
+
cell: ({ row, getValue }) => render(
|
|
1822
|
+
getValue(),
|
|
1823
|
+
row,
|
|
1824
|
+
row.index
|
|
1825
|
+
)
|
|
1826
|
+
} : {},
|
|
1827
|
+
meta: {
|
|
1828
|
+
align,
|
|
1829
|
+
rowSpan,
|
|
1830
|
+
rowSpanKey,
|
|
1831
|
+
editable,
|
|
1832
|
+
editType,
|
|
1833
|
+
className,
|
|
1834
|
+
headerClassName
|
|
1835
|
+
}
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
1840
|
+
var import_react8 = require("react");
|
|
1841
|
+
|
|
1842
|
+
// src/components/ui/table/components/Table/tableChildTypes.ts
|
|
1843
|
+
var import_react7 = require("react");
|
|
1844
|
+
var TABLE_HEADER_DISPLAY_NAME = "Table.Header";
|
|
1845
|
+
var TABLE_BODY_DISPLAY_NAME = "Table.Body";
|
|
1846
|
+
var TABLE_COLUMN_DISPLAY_NAME = "Table.Column";
|
|
1847
|
+
var TABLE_PAGINATION_DISPLAY_NAME = "Table.Pagination";
|
|
1848
|
+
function getComponentDisplayName(type) {
|
|
1849
|
+
if (typeof type === "function" || typeof type === "object" && type !== null) {
|
|
1850
|
+
return type.displayName;
|
|
1851
|
+
}
|
|
1852
|
+
return void 0;
|
|
1853
|
+
}
|
|
1854
|
+
function isTableHeaderElement(child) {
|
|
1855
|
+
return (0, import_react7.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
|
|
1856
|
+
}
|
|
1857
|
+
function isTableBodyElement(child) {
|
|
1858
|
+
return (0, import_react7.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
|
|
1859
|
+
}
|
|
1860
|
+
function isTableColumnElement(child) {
|
|
1861
|
+
return (0, import_react7.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
|
|
1862
|
+
}
|
|
1863
|
+
function isTablePaginationElement(child) {
|
|
1864
|
+
return (0, import_react7.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
1868
|
+
function parseTableChildren(children) {
|
|
1869
|
+
const slots = {
|
|
1870
|
+
header: null,
|
|
1871
|
+
body: null,
|
|
1872
|
+
pagination: null
|
|
1873
|
+
};
|
|
1874
|
+
for (const child of import_react8.Children.toArray(children)) {
|
|
1875
|
+
if (isTableHeaderElement(child)) {
|
|
1876
|
+
slots.header = child;
|
|
1877
|
+
continue;
|
|
1878
|
+
}
|
|
1879
|
+
if (isTableBodyElement(child)) {
|
|
1880
|
+
slots.body = child;
|
|
1881
|
+
continue;
|
|
1882
|
+
}
|
|
1883
|
+
if (isTablePaginationElement(child)) {
|
|
1884
|
+
slots.pagination = child;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
return slots;
|
|
1888
|
+
}
|
|
1889
|
+
function extractColumnElements(header) {
|
|
1890
|
+
if (!header) return [];
|
|
1891
|
+
const { children } = header.props;
|
|
1892
|
+
return import_react8.Children.toArray(children).filter(isTableColumnElement);
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
// src/components/ui/table/components/Table/TableBody.tsx
|
|
1896
|
+
function TableBody() {
|
|
1897
|
+
return null;
|
|
1898
|
+
}
|
|
1899
|
+
TableBody.displayName = TABLE_BODY_DISPLAY_NAME;
|
|
1900
|
+
|
|
1901
|
+
// src/components/ui/table/components/Table/TableColumn.tsx
|
|
1902
|
+
function TableColumn(props) {
|
|
1903
|
+
void props;
|
|
1904
|
+
return null;
|
|
1905
|
+
}
|
|
1906
|
+
TableColumn.displayName = TABLE_COLUMN_DISPLAY_NAME;
|
|
1907
|
+
|
|
1908
|
+
// src/components/ui/table/components/Table/tableDataPipeline.ts
|
|
1909
|
+
function sortTableData(data, sort) {
|
|
1910
|
+
if (!sort) return data;
|
|
1911
|
+
const { field, direction } = sort;
|
|
1912
|
+
const multiplier = direction === "asc" ? 1 : -1;
|
|
1913
|
+
return [...data].sort((left, right) => {
|
|
1914
|
+
const leftValue = left[field];
|
|
1915
|
+
const rightValue = right[field];
|
|
1916
|
+
if ((leftValue === null || leftValue === void 0) && (rightValue === null || rightValue === void 0)) {
|
|
1917
|
+
return 0;
|
|
1918
|
+
}
|
|
1919
|
+
if (leftValue === null || leftValue === void 0) return 1;
|
|
1920
|
+
if (rightValue === null || rightValue === void 0) return -1;
|
|
1921
|
+
if (typeof leftValue === "number" && typeof rightValue === "number") {
|
|
1922
|
+
return (leftValue - rightValue) * multiplier;
|
|
1923
|
+
}
|
|
1924
|
+
return String(leftValue).localeCompare(String(rightValue), "ko") * multiplier;
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
function paginateTableData(data, page, pageSize) {
|
|
1928
|
+
const safePage = Math.max(1, page);
|
|
1929
|
+
const start = (safePage - 1) * pageSize;
|
|
1930
|
+
return data.slice(start, start + pageSize);
|
|
1931
|
+
}
|
|
1932
|
+
function getTotalPages(totalCount, pageSize) {
|
|
1933
|
+
if (pageSize <= 0) return 1;
|
|
1934
|
+
return Math.max(1, Math.ceil(totalCount / pageSize));
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
// src/components/ui/table/components/Table/TableHeader.tsx
|
|
1938
|
+
function TableHeader(props) {
|
|
1939
|
+
void props;
|
|
1940
|
+
return null;
|
|
1941
|
+
}
|
|
1942
|
+
TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
|
|
1943
|
+
|
|
1944
|
+
// src/components/ui/table/components/Table/TablePagination.tsx
|
|
1945
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1946
|
+
function TablePagination({
|
|
1947
|
+
page,
|
|
1948
|
+
pageSize = 10,
|
|
1949
|
+
totalCount = 0,
|
|
1950
|
+
onChange,
|
|
1951
|
+
className
|
|
1952
|
+
}) {
|
|
1953
|
+
const totalPages = getTotalPages(totalCount, pageSize);
|
|
1954
|
+
const safePage = Math.min(Math.max(1, page), totalPages);
|
|
1955
|
+
const canGoPrev = safePage > 1;
|
|
1956
|
+
const canGoNext = safePage < totalPages;
|
|
1957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: cn("TablePaginationJSX", className), children: [
|
|
1958
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1959
|
+
"button",
|
|
1960
|
+
{
|
|
1961
|
+
type: "button",
|
|
1962
|
+
className: "pagination-button",
|
|
1963
|
+
disabled: !canGoPrev,
|
|
1964
|
+
onClick: () => onChange(safePage - 1),
|
|
1965
|
+
"aria-label": "Previous page",
|
|
1966
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronLeft, { className: "pagination-button-icon" })
|
|
1967
|
+
}
|
|
1968
|
+
),
|
|
1969
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "pagination-label", children: [
|
|
1970
|
+
safePage,
|
|
1971
|
+
" / ",
|
|
1972
|
+
totalPages
|
|
1973
|
+
] }),
|
|
1974
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1975
|
+
"button",
|
|
1976
|
+
{
|
|
1977
|
+
type: "button",
|
|
1978
|
+
className: "pagination-button",
|
|
1979
|
+
disabled: !canGoNext,
|
|
1980
|
+
onClick: () => onChange(safePage + 1),
|
|
1981
|
+
"aria-label": "Next page",
|
|
1982
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChevronRight, { className: "pagination-button-icon" })
|
|
1983
|
+
}
|
|
1984
|
+
)
|
|
1985
|
+
] });
|
|
1986
|
+
}
|
|
1987
|
+
TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
|
|
1988
|
+
|
|
1989
|
+
// src/components/ui/table/components/Table/Table.tsx
|
|
1990
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1991
|
+
function TableRoot({
|
|
1992
|
+
data,
|
|
1993
|
+
children,
|
|
1994
|
+
className,
|
|
1995
|
+
totalCount,
|
|
1996
|
+
filteredCount,
|
|
1997
|
+
...dataTableProps
|
|
1998
|
+
}) {
|
|
1999
|
+
const { header, pagination: paginationElement } = (0, import_react9.useMemo)(
|
|
2000
|
+
() => parseTableChildren(children),
|
|
2001
|
+
[children]
|
|
2002
|
+
);
|
|
2003
|
+
const [sort, setSort] = (0, import_react9.useState)(null);
|
|
2004
|
+
const handleSort = (0, import_react9.useCallback)((field) => {
|
|
2005
|
+
setSort((previous) => {
|
|
2006
|
+
if (previous?.field !== field) {
|
|
2007
|
+
return { field, direction: "asc" };
|
|
2008
|
+
}
|
|
2009
|
+
if (previous.direction === "asc") {
|
|
2010
|
+
return { field, direction: "desc" };
|
|
2011
|
+
}
|
|
2012
|
+
return null;
|
|
2013
|
+
});
|
|
2014
|
+
}, []);
|
|
2015
|
+
const columns = (0, import_react9.useMemo)(() => {
|
|
2016
|
+
return extractColumnElements(header).map(
|
|
2017
|
+
(columnElement) => buildColumnDef(columnElement.props, sort, handleSort)
|
|
2018
|
+
);
|
|
2019
|
+
}, [header, sort, handleSort]);
|
|
2020
|
+
const paginationProps = paginationElement?.props;
|
|
2021
|
+
const pageSize = paginationProps?.pageSize ?? 10;
|
|
2022
|
+
const page = paginationProps?.page ?? 1;
|
|
2023
|
+
const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
|
|
2024
|
+
const tableData = (0, import_react9.useMemo)(() => {
|
|
2025
|
+
const sortedData = sortTableData(data, sort);
|
|
2026
|
+
if (!paginationProps) return sortedData;
|
|
2027
|
+
return paginateTableData(sortedData, page, pageSize);
|
|
2028
|
+
}, [data, sort, paginationProps, page, pageSize]);
|
|
2029
|
+
if (columns.length === 0) {
|
|
2030
|
+
console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
|
|
2031
|
+
}
|
|
2032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "TableJSX", children: [
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2034
|
+
DataTable,
|
|
2035
|
+
{
|
|
2036
|
+
...dataTableProps,
|
|
2037
|
+
data: tableData,
|
|
2038
|
+
columns,
|
|
2039
|
+
totalCount: paginationProps ? resolvedTotalCount : totalCount,
|
|
2040
|
+
filteredCount: filteredCount ?? data.length,
|
|
2041
|
+
className: cn(className, paginationProps && "DataTableJSX--with-pagination")
|
|
2042
|
+
}
|
|
2043
|
+
),
|
|
2044
|
+
paginationProps && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2045
|
+
TablePagination,
|
|
2046
|
+
{
|
|
2047
|
+
page,
|
|
2048
|
+
pageSize,
|
|
2049
|
+
totalCount: resolvedTotalCount,
|
|
2050
|
+
onChange: paginationProps.onChange,
|
|
2051
|
+
className: paginationProps.className
|
|
2052
|
+
}
|
|
2053
|
+
)
|
|
2054
|
+
] });
|
|
2055
|
+
}
|
|
2056
|
+
function createTable() {
|
|
2057
|
+
function Column(props) {
|
|
2058
|
+
void props;
|
|
2059
|
+
return null;
|
|
2060
|
+
}
|
|
2061
|
+
Column.displayName = TABLE_COLUMN_DISPLAY_NAME;
|
|
2062
|
+
return Object.assign(
|
|
2063
|
+
function BoundTable(props) {
|
|
2064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TableRoot, { ...props });
|
|
2065
|
+
},
|
|
2066
|
+
{
|
|
2067
|
+
Header: TableHeader,
|
|
2068
|
+
Column,
|
|
2069
|
+
Body: TableBody,
|
|
2070
|
+
Pagination: TablePagination
|
|
2071
|
+
}
|
|
2072
|
+
);
|
|
2073
|
+
}
|
|
2074
|
+
var Table = Object.assign(TableRoot, {
|
|
2075
|
+
Header: TableHeader,
|
|
2076
|
+
Column: TableColumn,
|
|
2077
|
+
Body: TableBody,
|
|
2078
|
+
Pagination: TablePagination
|
|
2079
|
+
});
|
|
2080
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2081
|
+
0 && (module.exports = {
|
|
2082
|
+
DataTable,
|
|
2083
|
+
Table,
|
|
2084
|
+
createTable
|
|
2085
|
+
});
|