react-glide-table 1.7.0 → 2.0.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 +87 -6
- package/dist/compound.cjs +474 -98
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +459 -83
- package/dist/core.cjs +416 -12
- package/dist/core.d.cts +58 -4
- package/dist/core.d.ts +58 -4
- package/dist/core.js +407 -12
- package/dist/index.cjs +574 -166
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +545 -146
- package/dist/{types-Cs9MiZs1.d.cts → types-bgEceyRV.d.cts} +82 -4
- package/dist/{types-Cs9MiZs1.d.ts → types-bgEceyRV.d.ts} +82 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
BUILTIN_CELL_RENDERERS: () => BUILTIN_CELL_RENDERERS,
|
|
23
24
|
CELL_SELECTION_EDGES_CLASS: () => CELL_SELECTION_EDGES_CLASS,
|
|
24
25
|
DEFAULT_DATA_TABLE_LABELS: () => DEFAULT_DATA_TABLE_LABELS,
|
|
25
26
|
DEFAULT_TREE_CHILDREN_FIELD: () => DEFAULT_TREE_CHILDREN_FIELD,
|
|
@@ -28,6 +29,7 @@ __export(src_exports, {
|
|
|
28
29
|
DEFAULT_TREE_QTY_FIELD: () => DEFAULT_TREE_QTY_FIELD,
|
|
29
30
|
DataTable: () => DataTable,
|
|
30
31
|
INLINE_SEARCH_MAX_RESULTS: () => INLINE_SEARCH_MAX_RESULTS,
|
|
32
|
+
ResolvedTableCell: () => ResolvedTableCell,
|
|
31
33
|
Table: () => Table,
|
|
32
34
|
applyCellEdit: () => applyCellEdit,
|
|
33
35
|
applyFillData: () => applyFillData,
|
|
@@ -47,10 +49,14 @@ __export(src_exports, {
|
|
|
47
49
|
collectFillChanges: () => collectFillChanges,
|
|
48
50
|
collectRowSpanColumns: () => collectRowSpanColumns,
|
|
49
51
|
collectSearchMatchesInRange: () => collectSearchMatchesInRange,
|
|
52
|
+
commitCellValue: () => commitCellValue,
|
|
53
|
+
createCellRendererRegistry: () => createCellRendererRegistry,
|
|
50
54
|
createSearchRegex: () => createSearchRegex,
|
|
51
55
|
createTable: () => createTable,
|
|
52
56
|
escapeSearchRegex: () => escapeSearchRegex,
|
|
53
57
|
flattenSubtreeRows: () => flattenSubtreeRows,
|
|
58
|
+
formatCellValue: () => formatCellValue,
|
|
59
|
+
formatDefaultCellValue: () => formatDefaultCellValue,
|
|
54
60
|
formatSearchResultLabel: () => formatSearchResultLabel,
|
|
55
61
|
getCellEditDraftValue: () => getCellEditDraftValue,
|
|
56
62
|
getCellSelectionEdgeStyle: () => getCellSelectionEdgeStyle,
|
|
@@ -72,8 +78,10 @@ __export(src_exports, {
|
|
|
72
78
|
parseClipboardTSV: () => parseClipboardTSV,
|
|
73
79
|
parseClipboardTSVWithDepths: () => parseClipboardTSVWithDepths,
|
|
74
80
|
previousSearchIndex: () => previousSearchIndex,
|
|
81
|
+
resolveCellRenderer: () => resolveCellRenderer,
|
|
75
82
|
resolveColumnFreezeSide: () => resolveColumnFreezeSide,
|
|
76
83
|
resolveDataTableLabels: () => resolveDataTableLabels,
|
|
84
|
+
resolveHeaderFreezeOffset: () => resolveHeaderFreezeOffset,
|
|
77
85
|
resolvePasteColumnIds: () => resolvePasteColumnIds,
|
|
78
86
|
resolveRowSelection: () => resolveRowSelection,
|
|
79
87
|
resolveRowSpanAt: () => resolveRowSpanAt,
|
|
@@ -86,6 +94,7 @@ __export(src_exports, {
|
|
|
86
94
|
useConvertTreeData: () => useConvertTreeData,
|
|
87
95
|
useGlideTable: () => useGlideTable,
|
|
88
96
|
useInlineSearch: () => useInlineSearch,
|
|
97
|
+
withCellUpdate: () => withCellUpdate,
|
|
89
98
|
writeSelectionToClipboard: () => writeSelectionToClipboard
|
|
90
99
|
});
|
|
91
100
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -187,6 +196,37 @@ function applyCellEdit(data, rows, rowIndex, colIndex, raw) {
|
|
|
187
196
|
return newData;
|
|
188
197
|
}
|
|
189
198
|
|
|
199
|
+
// src/components/ui/table/features/cell-render/commitCellValue.ts
|
|
200
|
+
function commitCellValue({
|
|
201
|
+
data,
|
|
202
|
+
rows,
|
|
203
|
+
rowId,
|
|
204
|
+
columnId,
|
|
205
|
+
value,
|
|
206
|
+
onCellChange,
|
|
207
|
+
onDataChange
|
|
208
|
+
}) {
|
|
209
|
+
if (!onCellChange && !onDataChange) return true;
|
|
210
|
+
if (onCellChange) {
|
|
211
|
+
onCellChange(rowId, columnId, value);
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
const row = rows.find((item) => item.id === rowId);
|
|
215
|
+
if (!row) return false;
|
|
216
|
+
const cell = row.getAllCells().find((item) => item.column.id === columnId) ?? row.getVisibleCells().find((item) => item.column.id === columnId);
|
|
217
|
+
if (!cell) return false;
|
|
218
|
+
const accessorKey = getColumnAccessorKey(cell.column.columnDef);
|
|
219
|
+
if (!accessorKey) return false;
|
|
220
|
+
const dataIndex = row.index;
|
|
221
|
+
if (dataIndex < 0 || dataIndex >= data.length) return false;
|
|
222
|
+
const next = data.map((item) => ({ ...item }));
|
|
223
|
+
const target = next[dataIndex];
|
|
224
|
+
if (!target) return false;
|
|
225
|
+
target[accessorKey] = value;
|
|
226
|
+
onDataChange?.(next);
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
|
|
190
230
|
// src/components/ui/table/features/cell-edit/useCellEdit.ts
|
|
191
231
|
function useCellEdit({
|
|
192
232
|
data,
|
|
@@ -222,21 +262,23 @@ function useCellEdit({
|
|
|
222
262
|
cancelEdit();
|
|
223
263
|
return true;
|
|
224
264
|
}
|
|
225
|
-
const value = raw ?? draftValueRef.current;
|
|
226
265
|
if (!isColumnEditable(cell.column.columnDef)) {
|
|
227
266
|
cancelEdit();
|
|
228
267
|
return true;
|
|
229
268
|
}
|
|
269
|
+
const value = raw ?? draftValueRef.current;
|
|
230
270
|
const parsed = parseCellEditValue(value, getColumnEditType(cell.column.columnDef));
|
|
231
271
|
if (!parsed.ok) return false;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
272
|
+
const committed = commitCellValue({
|
|
273
|
+
data,
|
|
274
|
+
rows,
|
|
275
|
+
rowId: row.id,
|
|
276
|
+
columnId: cell.column.id,
|
|
277
|
+
value: parsed.value,
|
|
278
|
+
onCellChange,
|
|
279
|
+
onDataChange
|
|
280
|
+
});
|
|
281
|
+
if (!committed) return false;
|
|
240
282
|
cancelEdit();
|
|
241
283
|
return true;
|
|
242
284
|
},
|
|
@@ -265,6 +307,228 @@ function useCellEdit({
|
|
|
265
307
|
};
|
|
266
308
|
}
|
|
267
309
|
|
|
310
|
+
// src/components/ui/table/features/cell-render/builtins.tsx
|
|
311
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
312
|
+
function asString(value) {
|
|
313
|
+
if (value == null) return "";
|
|
314
|
+
return String(value);
|
|
315
|
+
}
|
|
316
|
+
function asStringList(value) {
|
|
317
|
+
if (Array.isArray(value)) {
|
|
318
|
+
return value.map((item) => asString(item)).filter(Boolean);
|
|
319
|
+
}
|
|
320
|
+
if (value == null || value === "") return [];
|
|
321
|
+
return [asString(value)];
|
|
322
|
+
}
|
|
323
|
+
function asDrilldownItems(value) {
|
|
324
|
+
if (!Array.isArray(value)) return [];
|
|
325
|
+
return value.flatMap((item) => {
|
|
326
|
+
if (item == null) return [];
|
|
327
|
+
if (typeof item === "string") return [{ text: item }];
|
|
328
|
+
if (typeof item === "object") {
|
|
329
|
+
const record = item;
|
|
330
|
+
const text = asString(record.text ?? record.label ?? "");
|
|
331
|
+
if (!text) return [];
|
|
332
|
+
const img = record.img ?? record.image;
|
|
333
|
+
return [{ text, ...typeof img === "string" ? { img } : {} }];
|
|
334
|
+
}
|
|
335
|
+
return [{ text: asString(item) }];
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function escapeHtml(text) {
|
|
339
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
340
|
+
}
|
|
341
|
+
function simpleMarkdownToHtml(source) {
|
|
342
|
+
const escaped = escapeHtml(source);
|
|
343
|
+
return escaped.replace(/`([^`]+)`/g, "<code>$1</code>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*]+)\*/g, "<em>$1</em>").replace(/\n/g, "<br />");
|
|
344
|
+
}
|
|
345
|
+
function TextCell({ value }) {
|
|
346
|
+
return asString(value);
|
|
347
|
+
}
|
|
348
|
+
function NumberCell({ value }) {
|
|
349
|
+
if (value == null || value === "") return null;
|
|
350
|
+
return asString(value);
|
|
351
|
+
}
|
|
352
|
+
function BooleanCell({ value, update, cellProps }) {
|
|
353
|
+
const checked = Boolean(value);
|
|
354
|
+
const readonly = Boolean(cellProps?.readonly);
|
|
355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
356
|
+
"input",
|
|
357
|
+
{
|
|
358
|
+
type: "checkbox",
|
|
359
|
+
className: "data-table-cell-boolean",
|
|
360
|
+
checked,
|
|
361
|
+
disabled: readonly,
|
|
362
|
+
"aria-checked": checked,
|
|
363
|
+
onChange: (event) => {
|
|
364
|
+
if (readonly) return;
|
|
365
|
+
update(event.target.checked);
|
|
366
|
+
},
|
|
367
|
+
onClick: (event) => {
|
|
368
|
+
event.stopPropagation();
|
|
369
|
+
},
|
|
370
|
+
onMouseDown: (event) => {
|
|
371
|
+
event.stopPropagation();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
function sanitizeUriHref(raw) {
|
|
377
|
+
const href = raw.trim();
|
|
378
|
+
if (!href) return null;
|
|
379
|
+
if (href.startsWith("/") || href.startsWith("#") || href.startsWith("?") || href.startsWith("./") || href.startsWith("../")) {
|
|
380
|
+
return href;
|
|
381
|
+
}
|
|
382
|
+
try {
|
|
383
|
+
const parsed = new URL(href);
|
|
384
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
385
|
+
if (protocol === "http:" || protocol === "https:" || protocol === "mailto:") {
|
|
386
|
+
return href;
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
389
|
+
} catch {
|
|
390
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return null;
|
|
391
|
+
return href;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function UriCell({ value }) {
|
|
395
|
+
const raw = asString(value);
|
|
396
|
+
if (!raw) return null;
|
|
397
|
+
const href = sanitizeUriHref(raw);
|
|
398
|
+
if (!href) {
|
|
399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-uri", children: raw });
|
|
400
|
+
}
|
|
401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
402
|
+
"a",
|
|
403
|
+
{
|
|
404
|
+
className: "data-table-cell-uri",
|
|
405
|
+
href,
|
|
406
|
+
target: "_blank",
|
|
407
|
+
rel: "noopener noreferrer",
|
|
408
|
+
onClick: (event) => event.stopPropagation(),
|
|
409
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
410
|
+
children: raw
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
function ImageCell({ value }) {
|
|
415
|
+
const urls = asStringList(value);
|
|
416
|
+
if (urls.length === 0) return null;
|
|
417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-image", children: urls.map((url, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
418
|
+
"img",
|
|
419
|
+
{
|
|
420
|
+
src: url,
|
|
421
|
+
alt: "",
|
|
422
|
+
className: "data-table-cell-image-item"
|
|
423
|
+
},
|
|
424
|
+
`${index}:${url}`
|
|
425
|
+
)) });
|
|
426
|
+
}
|
|
427
|
+
function BubbleCell({ value }) {
|
|
428
|
+
const items = asStringList(value);
|
|
429
|
+
if (items.length === 0) return null;
|
|
430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-bubble", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-bubble-item", children: item }, `${index}:${item}`)) });
|
|
431
|
+
}
|
|
432
|
+
function MarkdownCell({ value }) {
|
|
433
|
+
const source = asString(value);
|
|
434
|
+
if (!source) return null;
|
|
435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
436
|
+
"span",
|
|
437
|
+
{
|
|
438
|
+
className: "data-table-cell-markdown",
|
|
439
|
+
dangerouslySetInnerHTML: { __html: simpleMarkdownToHtml(source) }
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
function DrilldownCell({ value }) {
|
|
444
|
+
const items = asDrilldownItems(value);
|
|
445
|
+
if (items.length === 0) return null;
|
|
446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-drilldown", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
447
|
+
"span",
|
|
448
|
+
{
|
|
449
|
+
className: "data-table-cell-drilldown-item",
|
|
450
|
+
children: [
|
|
451
|
+
item.img ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
452
|
+
"img",
|
|
453
|
+
{
|
|
454
|
+
src: item.img,
|
|
455
|
+
alt: "",
|
|
456
|
+
className: "data-table-cell-drilldown-image"
|
|
457
|
+
}
|
|
458
|
+
) : null,
|
|
459
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-drilldown-text", children: item.text })
|
|
460
|
+
]
|
|
461
|
+
},
|
|
462
|
+
`${index}:${item.text}:${item.img ?? ""}`
|
|
463
|
+
)) });
|
|
464
|
+
}
|
|
465
|
+
function LoadingCell() {
|
|
466
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-loading", "aria-busy": "true" });
|
|
467
|
+
}
|
|
468
|
+
function ProtectedCell() {
|
|
469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-protected", "aria-label": "protected", children: "****" });
|
|
470
|
+
}
|
|
471
|
+
function RowIdCell({ value }) {
|
|
472
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-row-id", children: asString(value) });
|
|
473
|
+
}
|
|
474
|
+
var BUILTIN_RENDER_MAP = {
|
|
475
|
+
text: TextCell,
|
|
476
|
+
number: NumberCell,
|
|
477
|
+
boolean: BooleanCell,
|
|
478
|
+
uri: UriCell,
|
|
479
|
+
image: ImageCell,
|
|
480
|
+
bubble: BubbleCell,
|
|
481
|
+
markdown: MarkdownCell,
|
|
482
|
+
drilldown: DrilldownCell,
|
|
483
|
+
loading: LoadingCell,
|
|
484
|
+
protected: ProtectedCell,
|
|
485
|
+
"row-id": RowIdCell
|
|
486
|
+
};
|
|
487
|
+
var BUILTIN_CELL_RENDERERS = Object.keys(BUILTIN_RENDER_MAP).map((kind) => ({
|
|
488
|
+
kind,
|
|
489
|
+
render: BUILTIN_RENDER_MAP[kind]
|
|
490
|
+
}));
|
|
491
|
+
|
|
492
|
+
// src/components/ui/table/features/cell-render/registry.ts
|
|
493
|
+
function createCellRendererRegistry(customRenderers = []) {
|
|
494
|
+
const registry = /* @__PURE__ */ new Map();
|
|
495
|
+
for (const renderer of BUILTIN_CELL_RENDERERS) {
|
|
496
|
+
registry.set(renderer.kind, renderer);
|
|
497
|
+
}
|
|
498
|
+
for (const renderer of customRenderers) {
|
|
499
|
+
registry.set(renderer.kind, renderer);
|
|
500
|
+
}
|
|
501
|
+
return registry;
|
|
502
|
+
}
|
|
503
|
+
function resolveCellRenderer(registry, kind, ctx) {
|
|
504
|
+
if (!kind) return void 0;
|
|
505
|
+
const renderer = registry.get(kind);
|
|
506
|
+
if (!renderer) return void 0;
|
|
507
|
+
if (renderer.isMatch && !renderer.isMatch(ctx)) {
|
|
508
|
+
return void 0;
|
|
509
|
+
}
|
|
510
|
+
return renderer;
|
|
511
|
+
}
|
|
512
|
+
function formatDefaultCellValue(value) {
|
|
513
|
+
if (value == null) return null;
|
|
514
|
+
if (typeof value === "string") return value;
|
|
515
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
516
|
+
return String(value);
|
|
517
|
+
}
|
|
518
|
+
if (typeof value === "bigint") return value.toString();
|
|
519
|
+
return String(value);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// src/components/ui/table/features/cell-render/withCellUpdate.ts
|
|
523
|
+
function withCellUpdate(context, commitValue) {
|
|
524
|
+
return {
|
|
525
|
+
...context,
|
|
526
|
+
update: (next) => {
|
|
527
|
+
commitValue(context.row.id, context.column.id, next);
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
268
532
|
// src/components/ui/table/features/cell-selection/useCellSelection.ts
|
|
269
533
|
var import_react2 = require("react");
|
|
270
534
|
|
|
@@ -574,9 +838,34 @@ function hasCellSelectionEdges(style) {
|
|
|
574
838
|
}
|
|
575
839
|
|
|
576
840
|
// src/components/ui/table/features/cell-selection/copyData.ts
|
|
841
|
+
function formatPrimitive(value) {
|
|
842
|
+
if (value === null || value === void 0) return "";
|
|
843
|
+
if (typeof value === "string") return value;
|
|
844
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
845
|
+
return String(value);
|
|
846
|
+
}
|
|
847
|
+
return "";
|
|
848
|
+
}
|
|
849
|
+
function formatObjectValue(value) {
|
|
850
|
+
const text = value.text ?? value.label ?? value.name ?? value.title;
|
|
851
|
+
if (text != null && text !== "") {
|
|
852
|
+
return formatCellValue(text);
|
|
853
|
+
}
|
|
854
|
+
try {
|
|
855
|
+
return JSON.stringify(value);
|
|
856
|
+
} catch {
|
|
857
|
+
return "";
|
|
858
|
+
}
|
|
859
|
+
}
|
|
577
860
|
function formatCellValue(value) {
|
|
578
861
|
if (value === null || value === void 0) return "";
|
|
579
|
-
|
|
862
|
+
if (Array.isArray(value)) {
|
|
863
|
+
return value.map((item) => formatCellValue(item)).filter((item) => item.length > 0).join(", ");
|
|
864
|
+
}
|
|
865
|
+
if (typeof value === "object") {
|
|
866
|
+
return formatObjectValue(value);
|
|
867
|
+
}
|
|
868
|
+
return formatPrimitive(value);
|
|
580
869
|
}
|
|
581
870
|
function getNestedValue(row, path) {
|
|
582
871
|
if (!path.includes(".")) return row[path];
|
|
@@ -1200,10 +1489,40 @@ function getColumnFreezeStyle(offset, options) {
|
|
|
1200
1489
|
return {
|
|
1201
1490
|
position: "sticky",
|
|
1202
1491
|
...offset.side === "left" ? { left: offset.offset } : { right: offset.offset },
|
|
1203
|
-
zIndex: zBase + offset.stack
|
|
1204
|
-
|
|
1492
|
+
zIndex: zBase + offset.stack
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
function resolveHeaderFreezeOffset(column, freezeOffsets) {
|
|
1496
|
+
const direct = freezeOffsets.get(column.id);
|
|
1497
|
+
if (direct) return direct;
|
|
1498
|
+
const leaves = typeof column.getLeafColumns === "function" ? column.getLeafColumns() : column.columns && column.columns.length > 0 ? flattenHeaderLeaves(column) : [];
|
|
1499
|
+
if (leaves.length === 0) return void 0;
|
|
1500
|
+
const leafOffsets = [];
|
|
1501
|
+
for (const leaf of leaves) {
|
|
1502
|
+
const offset2 = freezeOffsets.get(leaf.id);
|
|
1503
|
+
if (!offset2) return void 0;
|
|
1504
|
+
leafOffsets.push(offset2);
|
|
1505
|
+
}
|
|
1506
|
+
const side = leafOffsets[0]?.side;
|
|
1507
|
+
if (!side || leafOffsets.some((offset2) => offset2.side !== side)) {
|
|
1508
|
+
return void 0;
|
|
1509
|
+
}
|
|
1510
|
+
const offset = Math.min(...leafOffsets.map((item) => item.offset));
|
|
1511
|
+
const leftmost = leafOffsets[0];
|
|
1512
|
+
const rightmost = leafOffsets[leafOffsets.length - 1];
|
|
1513
|
+
return {
|
|
1514
|
+
side,
|
|
1515
|
+
offset,
|
|
1516
|
+
edgeLeft: leftmost.edgeLeft,
|
|
1517
|
+
edgeRight: rightmost.edgeRight,
|
|
1518
|
+
isEdge: leftmost.edgeLeft || rightmost.edgeRight,
|
|
1519
|
+
stack: Math.max(...leafOffsets.map((item) => item.stack))
|
|
1205
1520
|
};
|
|
1206
1521
|
}
|
|
1522
|
+
function flattenHeaderLeaves(column) {
|
|
1523
|
+
if (!column.columns || column.columns.length === 0) return [column];
|
|
1524
|
+
return column.columns.flatMap((child) => flattenHeaderLeaves(child));
|
|
1525
|
+
}
|
|
1207
1526
|
|
|
1208
1527
|
// src/components/ui/table/features/inline-search/inlineSearch.ts
|
|
1209
1528
|
var INLINE_SEARCH_MAX_RESULTS = 1e3;
|
|
@@ -1947,6 +2266,7 @@ function useGlideTable(options) {
|
|
|
1947
2266
|
onDataChange,
|
|
1948
2267
|
onCellChange,
|
|
1949
2268
|
onBatchChange,
|
|
2269
|
+
cellRenderers,
|
|
1950
2270
|
preserveRowSelection = false,
|
|
1951
2271
|
toggleField,
|
|
1952
2272
|
childField,
|
|
@@ -2172,6 +2492,26 @@ function useGlideTable(options) {
|
|
|
2172
2492
|
commitEdit,
|
|
2173
2493
|
cancelEdit
|
|
2174
2494
|
} = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
|
|
2495
|
+
const cellRendererRegistry = (0, import_react5.useMemo)(
|
|
2496
|
+
() => createCellRendererRegistry(cellRenderers),
|
|
2497
|
+
[cellRenderers]
|
|
2498
|
+
);
|
|
2499
|
+
const commitRenderedCellValue = (0, import_react5.useCallback)(
|
|
2500
|
+
(rowId, columnId, value) => commitCellValue({
|
|
2501
|
+
data: tableData,
|
|
2502
|
+
rows,
|
|
2503
|
+
rowId,
|
|
2504
|
+
columnId,
|
|
2505
|
+
value,
|
|
2506
|
+
onCellChange,
|
|
2507
|
+
onDataChange
|
|
2508
|
+
}),
|
|
2509
|
+
[onCellChange, onDataChange, rows, tableData]
|
|
2510
|
+
);
|
|
2511
|
+
const getCellContext = (0, import_react5.useCallback)(
|
|
2512
|
+
(cell) => withCellUpdate(cell.getContext(), commitRenderedCellValue),
|
|
2513
|
+
[commitRenderedCellValue]
|
|
2514
|
+
);
|
|
2175
2515
|
const handleCellMouseDownWithCommit = (0, import_react5.useCallback)(
|
|
2176
2516
|
(rowIndex, colIndex, options2) => {
|
|
2177
2517
|
const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
|
|
@@ -2408,6 +2748,10 @@ function useGlideTable(options) {
|
|
|
2408
2748
|
onCommitEdit: commitEdit,
|
|
2409
2749
|
onCancelEdit: cancelEdit
|
|
2410
2750
|
},
|
|
2751
|
+
cellRender: {
|
|
2752
|
+
registry: cellRendererRegistry,
|
|
2753
|
+
commitValue: commitRenderedCellValue
|
|
2754
|
+
},
|
|
2411
2755
|
expand: {
|
|
2412
2756
|
enableExpand,
|
|
2413
2757
|
toggleField,
|
|
@@ -2454,6 +2798,8 @@ function useGlideTable(options) {
|
|
|
2454
2798
|
startEdit,
|
|
2455
2799
|
commitEdit,
|
|
2456
2800
|
cancelEdit,
|
|
2801
|
+
cellRendererRegistry,
|
|
2802
|
+
commitRenderedCellValue,
|
|
2457
2803
|
enableExpand,
|
|
2458
2804
|
toggleField,
|
|
2459
2805
|
expandedRows,
|
|
@@ -2498,6 +2844,7 @@ function useGlideTable(options) {
|
|
|
2498
2844
|
paddingTop,
|
|
2499
2845
|
paddingBottom,
|
|
2500
2846
|
rowContextValue,
|
|
2847
|
+
getCellContext,
|
|
2501
2848
|
handleToggleSelect,
|
|
2502
2849
|
clearHover,
|
|
2503
2850
|
copySelection: stableCopySelection,
|
|
@@ -2518,6 +2865,60 @@ function useGlideTable(options) {
|
|
|
2518
2865
|
};
|
|
2519
2866
|
}
|
|
2520
2867
|
|
|
2868
|
+
// src/components/ui/table/features/cell-render/ResolvedTableCell.tsx
|
|
2869
|
+
var import_react7 = require("react");
|
|
2870
|
+
|
|
2871
|
+
// src/components/ui/table/DataTableContext.tsx
|
|
2872
|
+
var import_react6 = require("react");
|
|
2873
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2874
|
+
var DataTableContext = (0, import_react6.createContext)(null);
|
|
2875
|
+
function useDataTableRowContext() {
|
|
2876
|
+
const context = (0, import_react6.use)(DataTableContext);
|
|
2877
|
+
if (!context) {
|
|
2878
|
+
throw new Error("useDataTableRowContext must be used within a DataTableContextProvider");
|
|
2879
|
+
}
|
|
2880
|
+
return context;
|
|
2881
|
+
}
|
|
2882
|
+
function DataTableContextProvider({
|
|
2883
|
+
value,
|
|
2884
|
+
children
|
|
2885
|
+
}) {
|
|
2886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DataTableContext, { value, children });
|
|
2887
|
+
}
|
|
2888
|
+
|
|
2889
|
+
// src/components/ui/table/features/cell-render/ResolvedTableCell.tsx
|
|
2890
|
+
function ResolvedTableCell({
|
|
2891
|
+
info
|
|
2892
|
+
}) {
|
|
2893
|
+
const { cellRender } = useDataTableRowContext();
|
|
2894
|
+
const { row, column, getValue } = info;
|
|
2895
|
+
const meta = column.columnDef.meta;
|
|
2896
|
+
const value = getValue();
|
|
2897
|
+
const columnId = column.id;
|
|
2898
|
+
const update = (0, import_react7.useCallback)(
|
|
2899
|
+
(next) => {
|
|
2900
|
+
cellRender.commitValue(row.id, columnId, next);
|
|
2901
|
+
},
|
|
2902
|
+
[cellRender, columnId, row.id]
|
|
2903
|
+
);
|
|
2904
|
+
const ctx = {
|
|
2905
|
+
value,
|
|
2906
|
+
row,
|
|
2907
|
+
index: row.index,
|
|
2908
|
+
columnId,
|
|
2909
|
+
cellProps: meta?.cellProps,
|
|
2910
|
+
update
|
|
2911
|
+
};
|
|
2912
|
+
if (meta?.cellRender) {
|
|
2913
|
+
return meta.cellRender(ctx);
|
|
2914
|
+
}
|
|
2915
|
+
const renderer = resolveCellRenderer(cellRender.registry, meta?.kind, ctx);
|
|
2916
|
+
if (renderer) {
|
|
2917
|
+
return renderer.render(ctx);
|
|
2918
|
+
}
|
|
2919
|
+
return formatDefaultCellValue(value);
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2521
2922
|
// src/components/ui/table/features/column-resize/columnResize.ts
|
|
2522
2923
|
function getColumnSizeStyle(size, options) {
|
|
2523
2924
|
const { force = false, lockMax = false } = options ?? {};
|
|
@@ -2533,34 +2934,16 @@ function getColumnSizeStyle(size, options) {
|
|
|
2533
2934
|
|
|
2534
2935
|
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
2535
2936
|
var import_react_table3 = require("@tanstack/react-table");
|
|
2536
|
-
var
|
|
2937
|
+
var import_react9 = require("react");
|
|
2537
2938
|
|
|
2538
2939
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
2539
2940
|
var import_react_table2 = require("@tanstack/react-table");
|
|
2540
|
-
var
|
|
2541
|
-
|
|
2542
|
-
// src/components/ui/table/DataTableContext.tsx
|
|
2543
|
-
var import_react6 = require("react");
|
|
2544
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2545
|
-
var DataTableContext = (0, import_react6.createContext)(null);
|
|
2546
|
-
function useDataTableRowContext() {
|
|
2547
|
-
const context = (0, import_react6.use)(DataTableContext);
|
|
2548
|
-
if (!context) {
|
|
2549
|
-
throw new Error("useDataTableRowContext must be used within a DataTableContextProvider");
|
|
2550
|
-
}
|
|
2551
|
-
return context;
|
|
2552
|
-
}
|
|
2553
|
-
function DataTableContextProvider({
|
|
2554
|
-
value,
|
|
2555
|
-
children
|
|
2556
|
-
}) {
|
|
2557
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataTableContext, { value, children });
|
|
2558
|
-
}
|
|
2941
|
+
var import_react8 = require("react");
|
|
2559
2942
|
|
|
2560
2943
|
// src/components/ui/table/components/icons.tsx
|
|
2561
|
-
var
|
|
2944
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2562
2945
|
function ChevronDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
2563
|
-
return /* @__PURE__ */ (0,
|
|
2946
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2564
2947
|
"svg",
|
|
2565
2948
|
{
|
|
2566
2949
|
className,
|
|
@@ -2573,12 +2956,12 @@ function ChevronDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2573
2956
|
strokeWidth: "2",
|
|
2574
2957
|
strokeLinecap: "round",
|
|
2575
2958
|
strokeLinejoin: "round",
|
|
2576
|
-
children: /* @__PURE__ */ (0,
|
|
2959
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m6 9 6 6 6-6" })
|
|
2577
2960
|
}
|
|
2578
2961
|
);
|
|
2579
2962
|
}
|
|
2580
2963
|
function ChevronUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
2581
|
-
return /* @__PURE__ */ (0,
|
|
2964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2582
2965
|
"svg",
|
|
2583
2966
|
{
|
|
2584
2967
|
className,
|
|
@@ -2591,12 +2974,12 @@ function ChevronUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2591
2974
|
strokeWidth: "2",
|
|
2592
2975
|
strokeLinecap: "round",
|
|
2593
2976
|
strokeLinejoin: "round",
|
|
2594
|
-
children: /* @__PURE__ */ (0,
|
|
2977
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m18 15-6-6-6 6" })
|
|
2595
2978
|
}
|
|
2596
2979
|
);
|
|
2597
2980
|
}
|
|
2598
2981
|
function ChevronLeft({ className, "aria-hidden": ariaHidden = true }) {
|
|
2599
|
-
return /* @__PURE__ */ (0,
|
|
2982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2600
2983
|
"svg",
|
|
2601
2984
|
{
|
|
2602
2985
|
className,
|
|
@@ -2609,12 +2992,12 @@ function ChevronLeft({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2609
2992
|
strokeWidth: "2",
|
|
2610
2993
|
strokeLinecap: "round",
|
|
2611
2994
|
strokeLinejoin: "round",
|
|
2612
|
-
children: /* @__PURE__ */ (0,
|
|
2995
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m15 18-6-6 6-6" })
|
|
2613
2996
|
}
|
|
2614
2997
|
);
|
|
2615
2998
|
}
|
|
2616
2999
|
function ChevronRight({ className, "aria-hidden": ariaHidden = true }) {
|
|
2617
|
-
return /* @__PURE__ */ (0,
|
|
3000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2618
3001
|
"svg",
|
|
2619
3002
|
{
|
|
2620
3003
|
className,
|
|
@@ -2627,12 +3010,12 @@ function ChevronRight({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2627
3010
|
strokeWidth: "2",
|
|
2628
3011
|
strokeLinecap: "round",
|
|
2629
3012
|
strokeLinejoin: "round",
|
|
2630
|
-
children: /* @__PURE__ */ (0,
|
|
3013
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m9 18 6-6-6-6" })
|
|
2631
3014
|
}
|
|
2632
3015
|
);
|
|
2633
3016
|
}
|
|
2634
3017
|
function ArrowUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
2635
|
-
return /* @__PURE__ */ (0,
|
|
3018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2636
3019
|
"svg",
|
|
2637
3020
|
{
|
|
2638
3021
|
className,
|
|
@@ -2646,14 +3029,14 @@ function ArrowUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2646
3029
|
strokeLinecap: "round",
|
|
2647
3030
|
strokeLinejoin: "round",
|
|
2648
3031
|
children: [
|
|
2649
|
-
/* @__PURE__ */ (0,
|
|
2650
|
-
/* @__PURE__ */ (0,
|
|
3032
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m18 15-6-6-6 6" }),
|
|
3033
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 21V9" })
|
|
2651
3034
|
]
|
|
2652
3035
|
}
|
|
2653
3036
|
);
|
|
2654
3037
|
}
|
|
2655
3038
|
function ArrowDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
2656
|
-
return /* @__PURE__ */ (0,
|
|
3039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2657
3040
|
"svg",
|
|
2658
3041
|
{
|
|
2659
3042
|
className,
|
|
@@ -2667,14 +3050,14 @@ function ArrowDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2667
3050
|
strokeLinecap: "round",
|
|
2668
3051
|
strokeLinejoin: "round",
|
|
2669
3052
|
children: [
|
|
2670
|
-
/* @__PURE__ */ (0,
|
|
2671
|
-
/* @__PURE__ */ (0,
|
|
3053
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m6 9 6 6 6-6" }),
|
|
3054
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 3v12" })
|
|
2672
3055
|
]
|
|
2673
3056
|
}
|
|
2674
3057
|
);
|
|
2675
3058
|
}
|
|
2676
3059
|
function ArrowUpDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
2677
|
-
return /* @__PURE__ */ (0,
|
|
3060
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2678
3061
|
"svg",
|
|
2679
3062
|
{
|
|
2680
3063
|
className,
|
|
@@ -2688,10 +3071,10 @@ function ArrowUpDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2688
3071
|
strokeLinecap: "round",
|
|
2689
3072
|
strokeLinejoin: "round",
|
|
2690
3073
|
children: [
|
|
2691
|
-
/* @__PURE__ */ (0,
|
|
2692
|
-
/* @__PURE__ */ (0,
|
|
2693
|
-
/* @__PURE__ */ (0,
|
|
2694
|
-
/* @__PURE__ */ (0,
|
|
3074
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m21 16-4 4-4-4" }),
|
|
3075
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M17 20V4" }),
|
|
3076
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m3 8 4-4 4 4" }),
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M7 4v16" })
|
|
2695
3078
|
]
|
|
2696
3079
|
}
|
|
2697
3080
|
);
|
|
@@ -2703,7 +3086,7 @@ function cn(...inputs) {
|
|
|
2703
3086
|
}
|
|
2704
3087
|
|
|
2705
3088
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
2706
|
-
var
|
|
3089
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2707
3090
|
function isInteractiveMouseTarget(target) {
|
|
2708
3091
|
if (!(target instanceof Element)) return false;
|
|
2709
3092
|
const interactiveSelector = [
|
|
@@ -2743,6 +3126,7 @@ function DataTableRow({
|
|
|
2743
3126
|
selection,
|
|
2744
3127
|
cellSelection,
|
|
2745
3128
|
cellEdit,
|
|
3129
|
+
cellRender,
|
|
2746
3130
|
expand,
|
|
2747
3131
|
columnResize,
|
|
2748
3132
|
columnFreeze,
|
|
@@ -2780,6 +3164,10 @@ function DataTableRow({
|
|
|
2780
3164
|
onCommitEdit,
|
|
2781
3165
|
onCancelEdit
|
|
2782
3166
|
} = cellEdit;
|
|
3167
|
+
const renderCell = (tableCell) => (0, import_react_table2.flexRender)(
|
|
3168
|
+
tableCell.column.columnDef.cell,
|
|
3169
|
+
withCellUpdate(tableCell.getContext(), cellRender.commitValue)
|
|
3170
|
+
);
|
|
2783
3171
|
const {
|
|
2784
3172
|
enableExpand,
|
|
2785
3173
|
toggleField,
|
|
@@ -2848,14 +3236,14 @@ function DataTableRow({
|
|
|
2848
3236
|
const expandKey = toggleField && rowData[toggleField] !== null && rowData[toggleField] !== void 0 ? String(rowData[toggleField]) : null;
|
|
2849
3237
|
const isExpanded = expandKey !== null && Boolean(expandedRows?.has(expandKey));
|
|
2850
3238
|
const rowLevel = typeof rowData.level === "number" ? rowData.level : 0;
|
|
2851
|
-
const editInputRef = (0,
|
|
3239
|
+
const editInputRef = (0, import_react8.useRef)(null);
|
|
2852
3240
|
const isRowEditing = editingCell?.rowIndex === rowIndex;
|
|
2853
|
-
(0,
|
|
3241
|
+
(0, import_react8.useEffect)(() => {
|
|
2854
3242
|
if (!isRowEditing) return;
|
|
2855
3243
|
editInputRef.current?.focus();
|
|
2856
3244
|
editInputRef.current?.select();
|
|
2857
3245
|
}, [isRowEditing, editingCell?.colIndex]);
|
|
2858
|
-
return /* @__PURE__ */ (0,
|
|
3246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2859
3247
|
"tr",
|
|
2860
3248
|
{
|
|
2861
3249
|
ref: measureElement,
|
|
@@ -2949,7 +3337,7 @@ function DataTableRow({
|
|
|
2949
3337
|
const searchMatchKey = buildSearchMatchKey(cellIndex, rowIndex);
|
|
2950
3338
|
const isSearchMatch = enableInlineSearch && searchMatchKeys.has(searchMatchKey);
|
|
2951
3339
|
const isSearchActive = isSearchMatch && activeMatch !== null && activeMatch[0] === cellIndex && activeMatch[1] === rowIndex;
|
|
2952
|
-
return /* @__PURE__ */ (0,
|
|
3340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2953
3341
|
"td",
|
|
2954
3342
|
{
|
|
2955
3343
|
"data-row-index": rowIndex,
|
|
@@ -3023,7 +3411,7 @@ function DataTableRow({
|
|
|
3023
3411
|
classNames?.cell
|
|
3024
3412
|
),
|
|
3025
3413
|
children: [
|
|
3026
|
-
isEditing ? /* @__PURE__ */ (0,
|
|
3414
|
+
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3027
3415
|
"input",
|
|
3028
3416
|
{
|
|
3029
3417
|
...editInputProps,
|
|
@@ -3066,8 +3454,8 @@ function DataTableRow({
|
|
|
3066
3454
|
onCommitEdit(event.currentTarget.value);
|
|
3067
3455
|
}
|
|
3068
3456
|
}
|
|
3069
|
-
) : isExpandCell && enableExpand ? /* @__PURE__ */ (0,
|
|
3070
|
-
/* @__PURE__ */ (0,
|
|
3457
|
+
) : isExpandCell && enableExpand ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("expand-cell", classNames?.expandCell), children: [
|
|
3458
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3071
3459
|
"div",
|
|
3072
3460
|
{
|
|
3073
3461
|
className: cn(
|
|
@@ -3075,7 +3463,7 @@ function DataTableRow({
|
|
|
3075
3463
|
classNames?.expandCellContent
|
|
3076
3464
|
),
|
|
3077
3465
|
children: [
|
|
3078
|
-
rowLevel > 0 && /* @__PURE__ */ (0,
|
|
3466
|
+
rowLevel > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3079
3467
|
"span",
|
|
3080
3468
|
{
|
|
3081
3469
|
className: cn(
|
|
@@ -3085,20 +3473,20 @@ function DataTableRow({
|
|
|
3085
3473
|
children: "\xB7"
|
|
3086
3474
|
}
|
|
3087
3475
|
),
|
|
3088
|
-
/* @__PURE__ */ (0,
|
|
3476
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3089
3477
|
"div",
|
|
3090
3478
|
{
|
|
3091
3479
|
className: cn(
|
|
3092
3480
|
"expand-cell-value",
|
|
3093
3481
|
classNames?.expandCellValue
|
|
3094
3482
|
),
|
|
3095
|
-
children: (
|
|
3483
|
+
children: renderCell(cell)
|
|
3096
3484
|
}
|
|
3097
3485
|
)
|
|
3098
3486
|
]
|
|
3099
3487
|
}
|
|
3100
3488
|
),
|
|
3101
|
-
canExpand && expandKey && /* @__PURE__ */ (0,
|
|
3489
|
+
canExpand && expandKey && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3102
3490
|
"button",
|
|
3103
3491
|
{
|
|
3104
3492
|
type: "button",
|
|
@@ -3112,7 +3500,7 @@ function DataTableRow({
|
|
|
3112
3500
|
onToggleExpand?.(expandKey);
|
|
3113
3501
|
},
|
|
3114
3502
|
onMouseDown: (event) => event.stopPropagation(),
|
|
3115
|
-
children: isExpanded ? /* @__PURE__ */ (0,
|
|
3503
|
+
children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3116
3504
|
ChevronUp,
|
|
3117
3505
|
{
|
|
3118
3506
|
className: cn(
|
|
@@ -3120,7 +3508,7 @@ function DataTableRow({
|
|
|
3120
3508
|
classNames?.expandToggleIcon
|
|
3121
3509
|
)
|
|
3122
3510
|
}
|
|
3123
|
-
) : /* @__PURE__ */ (0,
|
|
3511
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3124
3512
|
ChevronDown,
|
|
3125
3513
|
{
|
|
3126
3514
|
className: cn(
|
|
@@ -3131,8 +3519,8 @@ function DataTableRow({
|
|
|
3131
3519
|
)
|
|
3132
3520
|
}
|
|
3133
3521
|
)
|
|
3134
|
-
] }) : (
|
|
3135
|
-
isBottomRightCell && /* @__PURE__ */ (0,
|
|
3522
|
+
] }) : renderCell(cell),
|
|
3523
|
+
isBottomRightCell && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3136
3524
|
"div",
|
|
3137
3525
|
{
|
|
3138
3526
|
role: "presentation",
|
|
@@ -3154,9 +3542,9 @@ function DataTableRow({
|
|
|
3154
3542
|
}
|
|
3155
3543
|
|
|
3156
3544
|
// src/components/ui/table/components/DataTable/DataTableSearch.tsx
|
|
3157
|
-
var
|
|
3545
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3158
3546
|
function SearchCloseIcon({ className }) {
|
|
3159
|
-
return /* @__PURE__ */ (0,
|
|
3547
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3160
3548
|
"svg",
|
|
3161
3549
|
{
|
|
3162
3550
|
className,
|
|
@@ -3170,8 +3558,8 @@ function SearchCloseIcon({ className }) {
|
|
|
3170
3558
|
strokeLinecap: "round",
|
|
3171
3559
|
strokeLinejoin: "round",
|
|
3172
3560
|
children: [
|
|
3173
|
-
/* @__PURE__ */ (0,
|
|
3174
|
-
/* @__PURE__ */ (0,
|
|
3561
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M18 6 6 18" }),
|
|
3562
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "m6 6 12 12" })
|
|
3175
3563
|
]
|
|
3176
3564
|
}
|
|
3177
3565
|
);
|
|
@@ -3217,15 +3605,15 @@ function DataTableSearch({
|
|
|
3217
3605
|
onPrevious();
|
|
3218
3606
|
}
|
|
3219
3607
|
};
|
|
3220
|
-
return /* @__PURE__ */ (0,
|
|
3608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3221
3609
|
"div",
|
|
3222
3610
|
{
|
|
3223
3611
|
className: cn("data-table-search", classNames?.search),
|
|
3224
3612
|
role: "search",
|
|
3225
3613
|
onMouseDown: (event) => event.stopPropagation(),
|
|
3226
3614
|
children: [
|
|
3227
|
-
/* @__PURE__ */ (0,
|
|
3228
|
-
/* @__PURE__ */ (0,
|
|
3615
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "data-table-search-row", children: [
|
|
3616
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3229
3617
|
"input",
|
|
3230
3618
|
{
|
|
3231
3619
|
ref: searchInputRef,
|
|
@@ -3241,7 +3629,7 @@ function DataTableSearch({
|
|
|
3241
3629
|
onKeyDown: handleKeyDown
|
|
3242
3630
|
}
|
|
3243
3631
|
),
|
|
3244
|
-
/* @__PURE__ */ (0,
|
|
3632
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3245
3633
|
"button",
|
|
3246
3634
|
{
|
|
3247
3635
|
type: "button",
|
|
@@ -3251,10 +3639,10 @@ function DataTableSearch({
|
|
|
3251
3639
|
event.stopPropagation();
|
|
3252
3640
|
onPrevious();
|
|
3253
3641
|
},
|
|
3254
|
-
children: /* @__PURE__ */ (0,
|
|
3642
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronUp, { className: "data-table-search-icon" })
|
|
3255
3643
|
}
|
|
3256
3644
|
),
|
|
3257
|
-
/* @__PURE__ */ (0,
|
|
3645
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3258
3646
|
"button",
|
|
3259
3647
|
{
|
|
3260
3648
|
type: "button",
|
|
@@ -3264,10 +3652,10 @@ function DataTableSearch({
|
|
|
3264
3652
|
event.stopPropagation();
|
|
3265
3653
|
onNext();
|
|
3266
3654
|
},
|
|
3267
|
-
children: /* @__PURE__ */ (0,
|
|
3655
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronDown, { className: "data-table-search-icon" })
|
|
3268
3656
|
}
|
|
3269
3657
|
),
|
|
3270
|
-
canClose ? /* @__PURE__ */ (0,
|
|
3658
|
+
canClose ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3271
3659
|
"button",
|
|
3272
3660
|
{
|
|
3273
3661
|
type: "button",
|
|
@@ -3277,11 +3665,11 @@ function DataTableSearch({
|
|
|
3277
3665
|
event.stopPropagation();
|
|
3278
3666
|
onClose();
|
|
3279
3667
|
},
|
|
3280
|
-
children: /* @__PURE__ */ (0,
|
|
3668
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SearchCloseIcon, { className: "data-table-search-icon" })
|
|
3281
3669
|
}
|
|
3282
3670
|
) : null
|
|
3283
3671
|
] }),
|
|
3284
|
-
/* @__PURE__ */ (0,
|
|
3672
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3285
3673
|
"div",
|
|
3286
3674
|
{
|
|
3287
3675
|
className: cn("data-table-search-status", classNames?.searchStatus),
|
|
@@ -3289,7 +3677,7 @@ function DataTableSearch({
|
|
|
3289
3677
|
children: resultString
|
|
3290
3678
|
}
|
|
3291
3679
|
),
|
|
3292
|
-
searchStatus !== void 0 ? /* @__PURE__ */ (0,
|
|
3680
|
+
searchStatus !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3293
3681
|
"div",
|
|
3294
3682
|
{
|
|
3295
3683
|
className: cn(
|
|
@@ -3300,7 +3688,7 @@ function DataTableSearch({
|
|
|
3300
3688
|
"aria-valuemin": 0,
|
|
3301
3689
|
"aria-valuemax": 100,
|
|
3302
3690
|
"aria-valuenow": progress,
|
|
3303
|
-
children: /* @__PURE__ */ (0,
|
|
3691
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3304
3692
|
"div",
|
|
3305
3693
|
{
|
|
3306
3694
|
className: "data-table-search-progress-bar",
|
|
@@ -3315,7 +3703,7 @@ function DataTableSearch({
|
|
|
3315
3703
|
}
|
|
3316
3704
|
|
|
3317
3705
|
// src/components/ui/table/components/DataTable/DataTableToolbar.tsx
|
|
3318
|
-
var
|
|
3706
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3319
3707
|
function DataTableToolbar({
|
|
3320
3708
|
filteredCount,
|
|
3321
3709
|
totalCount,
|
|
@@ -3333,20 +3721,20 @@ function DataTableToolbar({
|
|
|
3333
3721
|
const selectionContent = selectionLabel?.(selectedCount) ?? null;
|
|
3334
3722
|
const hasSelectionContent = selectionContent !== null && selectionContent !== false && selectionContent !== void 0 && typeof selectionContent !== "boolean";
|
|
3335
3723
|
if (!hasLeftContent && !hasToolbar && !hasSelectionContent) return null;
|
|
3336
|
-
return /* @__PURE__ */ (0,
|
|
3337
|
-
/* @__PURE__ */ (0,
|
|
3338
|
-
hasCount && /* @__PURE__ */ (0,
|
|
3339
|
-
/* @__PURE__ */ (0,
|
|
3340
|
-
/* @__PURE__ */ (0,
|
|
3724
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn("DataTableToolbarJSX", classNames?.toolbar, className), children: [
|
|
3725
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn("toolbar-left", classNames?.toolbarLeft), children: [
|
|
3726
|
+
hasCount && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: cn("toolbar-count", classNames?.toolbarCount), children: displayFiltered !== void 0 && totalCount !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
3727
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "toolbar-count-primary", children: displayFiltered }),
|
|
3728
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "toolbar-count-placeholder", children: [
|
|
3341
3729
|
" / ",
|
|
3342
3730
|
totalCount
|
|
3343
3731
|
] })
|
|
3344
|
-
] }) : /* @__PURE__ */ (0,
|
|
3732
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "toolbar-count-primary", children: displayFiltered ?? totalCount }) }),
|
|
3345
3733
|
summary
|
|
3346
3734
|
] }),
|
|
3347
|
-
/* @__PURE__ */ (0,
|
|
3348
|
-
hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ (0,
|
|
3349
|
-
hasToolbar && /* @__PURE__ */ (0,
|
|
3735
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn("toolbar-right", classNames?.toolbarRight), children: [
|
|
3736
|
+
hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: cn("toolbar-selection", classNames?.toolbarSelection), children: selectionContent }) : selectionContent),
|
|
3737
|
+
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: cn("toolbar-actions", classNames?.toolbarActions), children: toolbar })
|
|
3350
3738
|
] })
|
|
3351
3739
|
] });
|
|
3352
3740
|
}
|
|
@@ -3384,20 +3772,20 @@ function getMergedHeaderGroups(headerGroups) {
|
|
|
3384
3772
|
}
|
|
3385
3773
|
|
|
3386
3774
|
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
3387
|
-
var
|
|
3775
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3388
3776
|
function DefaultScroll({
|
|
3389
3777
|
scrollRef,
|
|
3390
3778
|
children,
|
|
3391
3779
|
className
|
|
3392
3780
|
}) {
|
|
3393
|
-
return /* @__PURE__ */ (0,
|
|
3781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
|
|
3394
3782
|
}
|
|
3395
3783
|
function DefaultPending({
|
|
3396
3784
|
loadingText,
|
|
3397
3785
|
className,
|
|
3398
3786
|
classNames
|
|
3399
3787
|
}) {
|
|
3400
|
-
return /* @__PURE__ */ (0,
|
|
3788
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3401
3789
|
"div",
|
|
3402
3790
|
{
|
|
3403
3791
|
className: cn(
|
|
@@ -3407,7 +3795,7 @@ function DefaultPending({
|
|
|
3407
3795
|
classNames?.pending,
|
|
3408
3796
|
className
|
|
3409
3797
|
),
|
|
3410
|
-
children: /* @__PURE__ */ (0,
|
|
3798
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
|
|
3411
3799
|
}
|
|
3412
3800
|
);
|
|
3413
3801
|
}
|
|
@@ -3416,7 +3804,7 @@ function DefaultEmpty({
|
|
|
3416
3804
|
columnCount,
|
|
3417
3805
|
classNames
|
|
3418
3806
|
}) {
|
|
3419
|
-
return /* @__PURE__ */ (0,
|
|
3807
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3420
3808
|
"td",
|
|
3421
3809
|
{
|
|
3422
3810
|
colSpan: columnCount,
|
|
@@ -3469,12 +3857,12 @@ function DataTable({
|
|
|
3469
3857
|
const EmptySlot = slots?.Empty ?? DefaultEmpty;
|
|
3470
3858
|
const freezeOffsets = rowContextValue.columnFreeze.offsets;
|
|
3471
3859
|
const headerGroups = getMergedHeaderGroups(table.getHeaderGroups());
|
|
3472
|
-
const contextValue = (0,
|
|
3860
|
+
const contextValue = (0, import_react9.useMemo)(
|
|
3473
3861
|
() => ({ ...rowContextValue, classNames }),
|
|
3474
3862
|
[rowContextValue, classNames]
|
|
3475
3863
|
);
|
|
3476
3864
|
if (isPending) {
|
|
3477
|
-
return /* @__PURE__ */ (0,
|
|
3865
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3478
3866
|
PendingSlot,
|
|
3479
3867
|
{
|
|
3480
3868
|
loadingText,
|
|
@@ -3483,7 +3871,7 @@ function DataTable({
|
|
|
3483
3871
|
}
|
|
3484
3872
|
);
|
|
3485
3873
|
}
|
|
3486
|
-
return /* @__PURE__ */ (0,
|
|
3874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3487
3875
|
"div",
|
|
3488
3876
|
{
|
|
3489
3877
|
ref: rootRef,
|
|
@@ -3497,7 +3885,7 @@ function DataTable({
|
|
|
3497
3885
|
className
|
|
3498
3886
|
),
|
|
3499
3887
|
children: [
|
|
3500
|
-
/* @__PURE__ */ (0,
|
|
3888
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3501
3889
|
ToolbarSlot,
|
|
3502
3890
|
{
|
|
3503
3891
|
filteredCount: filteredCount ?? tableData.length,
|
|
@@ -3509,7 +3897,7 @@ function DataTable({
|
|
|
3509
3897
|
classNames
|
|
3510
3898
|
}
|
|
3511
3899
|
),
|
|
3512
|
-
enableInlineSearch ? /* @__PURE__ */ (0,
|
|
3900
|
+
enableInlineSearch ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3513
3901
|
DataTableSearch,
|
|
3514
3902
|
{
|
|
3515
3903
|
showSearch: inlineSearch.showSearch,
|
|
@@ -3531,14 +3919,14 @@ function DataTable({
|
|
|
3531
3919
|
onPrevious: inlineSearch.goToPrevious
|
|
3532
3920
|
}
|
|
3533
3921
|
) : null,
|
|
3534
|
-
/* @__PURE__ */ (0,
|
|
3922
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3535
3923
|
"table",
|
|
3536
3924
|
{
|
|
3537
3925
|
className: cn("data-table", classNames?.table),
|
|
3538
3926
|
style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
|
|
3539
3927
|
onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
|
|
3540
3928
|
children: [
|
|
3541
|
-
/* @__PURE__ */ (0,
|
|
3929
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("thead", { className: cn("data-table-head", classNames?.head), children: headerGroups.map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3542
3930
|
"tr",
|
|
3543
3931
|
{
|
|
3544
3932
|
className: cn("data-table-head-row", classNames?.headRow),
|
|
@@ -3550,7 +3938,7 @@ function DataTable({
|
|
|
3550
3938
|
force: enableColumnResize,
|
|
3551
3939
|
lockMax: enableColumnResize
|
|
3552
3940
|
});
|
|
3553
|
-
const freezeOffset = enableColumnFreeze ?
|
|
3941
|
+
const freezeOffset = enableColumnFreeze ? resolveHeaderFreezeOffset(header.column, freezeOffsets) : void 0;
|
|
3554
3942
|
const freezeStyle = getColumnFreezeStyle(freezeOffset, {
|
|
3555
3943
|
isHeader: true,
|
|
3556
3944
|
headerTop: header.depth * DATA_TABLE_HEADER_ROW_HEIGHT
|
|
@@ -3559,7 +3947,7 @@ function DataTable({
|
|
|
3559
3947
|
...sizeStyle,
|
|
3560
3948
|
...freezeStyle
|
|
3561
3949
|
};
|
|
3562
|
-
return /* @__PURE__ */ (0,
|
|
3950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3563
3951
|
"th",
|
|
3564
3952
|
{
|
|
3565
3953
|
colSpan: header.colSpan,
|
|
@@ -3576,8 +3964,11 @@ function DataTable({
|
|
|
3576
3964
|
headerClassName
|
|
3577
3965
|
),
|
|
3578
3966
|
children: [
|
|
3579
|
-
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
3580
|
-
|
|
3967
|
+
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
3968
|
+
header.column.columnDef.header,
|
|
3969
|
+
header.getContext()
|
|
3970
|
+
),
|
|
3971
|
+
canResize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3581
3972
|
"div",
|
|
3582
3973
|
{
|
|
3583
3974
|
role: "separator",
|
|
@@ -3603,20 +3994,20 @@ function DataTable({
|
|
|
3603
3994
|
},
|
|
3604
3995
|
headerGroup.id
|
|
3605
3996
|
)) }),
|
|
3606
|
-
/* @__PURE__ */ (0,
|
|
3997
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3607
3998
|
"tbody",
|
|
3608
3999
|
{
|
|
3609
4000
|
onMouseLeave: clearHover,
|
|
3610
4001
|
className: cn("data-table-body", classNames?.body),
|
|
3611
|
-
children: rows.length === 0 ? /* @__PURE__ */ (0,
|
|
4002
|
+
children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3612
4003
|
EmptySlot,
|
|
3613
4004
|
{
|
|
3614
4005
|
emptyText,
|
|
3615
4006
|
columnCount,
|
|
3616
4007
|
classNames
|
|
3617
4008
|
}
|
|
3618
|
-
) : shouldVirtualize ? /* @__PURE__ */ (0,
|
|
3619
|
-
paddingTop > 0 && /* @__PURE__ */ (0,
|
|
4009
|
+
) : shouldVirtualize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
4010
|
+
paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3620
4011
|
"tr",
|
|
3621
4012
|
{
|
|
3622
4013
|
"aria-hidden": true,
|
|
@@ -3624,7 +4015,7 @@ function DataTable({
|
|
|
3624
4015
|
"data-table-virtual-spacer",
|
|
3625
4016
|
classNames?.virtualSpacer
|
|
3626
4017
|
),
|
|
3627
|
-
children: /* @__PURE__ */ (0,
|
|
4018
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3628
4019
|
"td",
|
|
3629
4020
|
{
|
|
3630
4021
|
colSpan: columnCount,
|
|
@@ -3640,7 +4031,7 @@ function DataTable({
|
|
|
3640
4031
|
virtualRows.map((virtualRow) => {
|
|
3641
4032
|
const row = rows[virtualRow.index];
|
|
3642
4033
|
if (!row) return null;
|
|
3643
|
-
return /* @__PURE__ */ (0,
|
|
4034
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3644
4035
|
RowSlot,
|
|
3645
4036
|
{
|
|
3646
4037
|
row,
|
|
@@ -3651,7 +4042,7 @@ function DataTable({
|
|
|
3651
4042
|
row.id
|
|
3652
4043
|
);
|
|
3653
4044
|
}),
|
|
3654
|
-
paddingBottom > 0 && /* @__PURE__ */ (0,
|
|
4045
|
+
paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3655
4046
|
"tr",
|
|
3656
4047
|
{
|
|
3657
4048
|
"aria-hidden": true,
|
|
@@ -3659,7 +4050,7 @@ function DataTable({
|
|
|
3659
4050
|
"data-table-virtual-spacer",
|
|
3660
4051
|
classNames?.virtualSpacer
|
|
3661
4052
|
),
|
|
3662
|
-
children: /* @__PURE__ */ (0,
|
|
4053
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3663
4054
|
"td",
|
|
3664
4055
|
{
|
|
3665
4056
|
colSpan: columnCount,
|
|
@@ -3672,7 +4063,7 @@ function DataTable({
|
|
|
3672
4063
|
)
|
|
3673
4064
|
}
|
|
3674
4065
|
)
|
|
3675
|
-
] }) : rows.map((row) => /* @__PURE__ */ (0,
|
|
4066
|
+
] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3676
4067
|
RowSlot,
|
|
3677
4068
|
{
|
|
3678
4069
|
row,
|
|
@@ -3691,10 +4082,10 @@ function DataTable({
|
|
|
3691
4082
|
}
|
|
3692
4083
|
|
|
3693
4084
|
// src/components/ui/table/components/Table/Table.tsx
|
|
3694
|
-
var
|
|
4085
|
+
var import_react12 = require("react");
|
|
3695
4086
|
|
|
3696
4087
|
// src/components/ui/table/components/Table/buildColumnDef.tsx
|
|
3697
|
-
var
|
|
4088
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3698
4089
|
function SortableHeader({
|
|
3699
4090
|
label,
|
|
3700
4091
|
field,
|
|
@@ -3703,15 +4094,18 @@ function SortableHeader({
|
|
|
3703
4094
|
}) {
|
|
3704
4095
|
const isActive = sort?.field === field;
|
|
3705
4096
|
const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
|
|
3706
|
-
return /* @__PURE__ */ (0,
|
|
4097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3707
4098
|
"button",
|
|
3708
4099
|
{
|
|
3709
4100
|
type: "button",
|
|
3710
|
-
className: cn(
|
|
4101
|
+
className: cn(
|
|
4102
|
+
"SortableHeaderJSX",
|
|
4103
|
+
isActive ? "is-active" : "is-inactive"
|
|
4104
|
+
),
|
|
3711
4105
|
onClick: () => onSort(field),
|
|
3712
4106
|
children: [
|
|
3713
|
-
/* @__PURE__ */ (0,
|
|
3714
|
-
/* @__PURE__ */ (0,
|
|
4107
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: label }),
|
|
4108
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { className: "sortable-header-icon" })
|
|
3715
4109
|
]
|
|
3716
4110
|
}
|
|
3717
4111
|
);
|
|
@@ -3733,6 +4127,8 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3733
4127
|
editable,
|
|
3734
4128
|
editType,
|
|
3735
4129
|
editInputProps,
|
|
4130
|
+
kind,
|
|
4131
|
+
cellProps,
|
|
3736
4132
|
className,
|
|
3737
4133
|
headerClassName,
|
|
3738
4134
|
render
|
|
@@ -3744,18 +4140,20 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3744
4140
|
...minWidth != null ? { minSize: minWidth } : {},
|
|
3745
4141
|
...maxWidth != null ? { maxSize: maxWidth } : {},
|
|
3746
4142
|
...resizable === false ? { enableResizing: false } : {},
|
|
3747
|
-
header: sortable ? () => /* @__PURE__ */ (0,
|
|
4143
|
+
header: sortable ? () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4144
|
+
SortableHeader,
|
|
4145
|
+
{
|
|
4146
|
+
label: children,
|
|
4147
|
+
field,
|
|
4148
|
+
sort,
|
|
4149
|
+
onSort
|
|
4150
|
+
}
|
|
4151
|
+
) : (
|
|
3748
4152
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
3749
4153
|
() => children
|
|
3750
4154
|
),
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
cell: ({ row, getValue }) => render(
|
|
3754
|
-
getValue(),
|
|
3755
|
-
row,
|
|
3756
|
-
row.index
|
|
3757
|
-
)
|
|
3758
|
-
} : {},
|
|
4155
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4156
|
+
cell: (info) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ResolvedTableCell, { info }),
|
|
3759
4157
|
meta: {
|
|
3760
4158
|
align,
|
|
3761
4159
|
rowSpan,
|
|
@@ -3763,6 +4161,9 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3763
4161
|
editable,
|
|
3764
4162
|
editType,
|
|
3765
4163
|
editInputProps,
|
|
4164
|
+
kind,
|
|
4165
|
+
cellProps,
|
|
4166
|
+
cellRender: render,
|
|
3766
4167
|
frozen,
|
|
3767
4168
|
className,
|
|
3768
4169
|
headerClassName
|
|
@@ -3785,10 +4186,8 @@ function buildColumnDefsFromTree(nodes, sort, onSort) {
|
|
|
3785
4186
|
const { header, align, headerClassName } = node.props;
|
|
3786
4187
|
return {
|
|
3787
4188
|
id: resolveGroupId(node.props, index),
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
() => header
|
|
3791
|
-
),
|
|
4189
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4190
|
+
header: () => header,
|
|
3792
4191
|
columns: childDefs,
|
|
3793
4192
|
enableResizing: false,
|
|
3794
4193
|
meta: {
|
|
@@ -3811,10 +4210,10 @@ function countLeafColumns(nodes) {
|
|
|
3811
4210
|
}
|
|
3812
4211
|
|
|
3813
4212
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
3814
|
-
var
|
|
4213
|
+
var import_react11 = require("react");
|
|
3815
4214
|
|
|
3816
4215
|
// src/components/ui/table/components/Table/tableChildTypes.ts
|
|
3817
|
-
var
|
|
4216
|
+
var import_react10 = require("react");
|
|
3818
4217
|
var TABLE_HEADER_DISPLAY_NAME = "Table.Header";
|
|
3819
4218
|
var TABLE_BODY_DISPLAY_NAME = "Table.Body";
|
|
3820
4219
|
var TABLE_COLUMN_DISPLAY_NAME = "Table.Column";
|
|
@@ -3827,19 +4226,19 @@ function getComponentDisplayName(type) {
|
|
|
3827
4226
|
return void 0;
|
|
3828
4227
|
}
|
|
3829
4228
|
function isTableHeaderElement(child) {
|
|
3830
|
-
return (0,
|
|
4229
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
|
|
3831
4230
|
}
|
|
3832
4231
|
function isTableBodyElement(child) {
|
|
3833
|
-
return (0,
|
|
4232
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
|
|
3834
4233
|
}
|
|
3835
4234
|
function isTableColumnElement(child) {
|
|
3836
|
-
return (0,
|
|
4235
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
|
|
3837
4236
|
}
|
|
3838
4237
|
function isTableColumnGroupElement(child) {
|
|
3839
|
-
return (0,
|
|
4238
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_GROUP_DISPLAY_NAME;
|
|
3840
4239
|
}
|
|
3841
4240
|
function isTablePaginationElement(child) {
|
|
3842
|
-
return (0,
|
|
4241
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
|
|
3843
4242
|
}
|
|
3844
4243
|
|
|
3845
4244
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
@@ -3849,7 +4248,7 @@ function parseTableChildren(children) {
|
|
|
3849
4248
|
body: null,
|
|
3850
4249
|
pagination: null
|
|
3851
4250
|
};
|
|
3852
|
-
for (const child of
|
|
4251
|
+
for (const child of import_react11.Children.toArray(children)) {
|
|
3853
4252
|
if (isTableHeaderElement(child)) {
|
|
3854
4253
|
slots.header = child;
|
|
3855
4254
|
continue;
|
|
@@ -3866,7 +4265,7 @@ function parseTableChildren(children) {
|
|
|
3866
4265
|
}
|
|
3867
4266
|
function walkColumnTreeNodes(children) {
|
|
3868
4267
|
const result = [];
|
|
3869
|
-
for (const child of
|
|
4268
|
+
for (const child of import_react11.Children.toArray(children)) {
|
|
3870
4269
|
if (isTableColumnElement(child)) {
|
|
3871
4270
|
result.push({
|
|
3872
4271
|
type: "leaf",
|
|
@@ -3883,7 +4282,7 @@ function walkColumnTreeNodes(children) {
|
|
|
3883
4282
|
});
|
|
3884
4283
|
continue;
|
|
3885
4284
|
}
|
|
3886
|
-
if ((0,
|
|
4285
|
+
if ((0, import_react11.isValidElement)(child)) {
|
|
3887
4286
|
const nested = child.props.children;
|
|
3888
4287
|
if (nested != null) {
|
|
3889
4288
|
result.push(...walkColumnTreeNodes(nested));
|
|
@@ -3955,7 +4354,7 @@ function TableHeader(props) {
|
|
|
3955
4354
|
TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
|
|
3956
4355
|
|
|
3957
4356
|
// src/components/ui/table/components/Table/TablePagination.tsx
|
|
3958
|
-
var
|
|
4357
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3959
4358
|
function TablePagination({
|
|
3960
4359
|
page,
|
|
3961
4360
|
pageSize = 10,
|
|
@@ -3967,8 +4366,8 @@ function TablePagination({
|
|
|
3967
4366
|
const safePage = Math.min(Math.max(1, page), totalPages);
|
|
3968
4367
|
const canGoPrev = safePage > 1;
|
|
3969
4368
|
const canGoNext = safePage < totalPages;
|
|
3970
|
-
return /* @__PURE__ */ (0,
|
|
3971
|
-
/* @__PURE__ */ (0,
|
|
4369
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: cn("TablePaginationJSX", className), children: [
|
|
4370
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3972
4371
|
"button",
|
|
3973
4372
|
{
|
|
3974
4373
|
type: "button",
|
|
@@ -3976,15 +4375,15 @@ function TablePagination({
|
|
|
3976
4375
|
disabled: !canGoPrev,
|
|
3977
4376
|
onClick: () => onChange(safePage - 1),
|
|
3978
4377
|
"aria-label": "Previous page",
|
|
3979
|
-
children: /* @__PURE__ */ (0,
|
|
4378
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronLeft, { className: "pagination-button-icon" })
|
|
3980
4379
|
}
|
|
3981
4380
|
),
|
|
3982
|
-
/* @__PURE__ */ (0,
|
|
4381
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "pagination-label", children: [
|
|
3983
4382
|
safePage,
|
|
3984
4383
|
" / ",
|
|
3985
4384
|
totalPages
|
|
3986
4385
|
] }),
|
|
3987
|
-
/* @__PURE__ */ (0,
|
|
4386
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3988
4387
|
"button",
|
|
3989
4388
|
{
|
|
3990
4389
|
type: "button",
|
|
@@ -3992,7 +4391,7 @@ function TablePagination({
|
|
|
3992
4391
|
disabled: !canGoNext,
|
|
3993
4392
|
onClick: () => onChange(safePage + 1),
|
|
3994
4393
|
"aria-label": "Next page",
|
|
3995
|
-
children: /* @__PURE__ */ (0,
|
|
4394
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronRight, { className: "pagination-button-icon" })
|
|
3996
4395
|
}
|
|
3997
4396
|
)
|
|
3998
4397
|
] });
|
|
@@ -4000,7 +4399,7 @@ function TablePagination({
|
|
|
4000
4399
|
TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
|
|
4001
4400
|
|
|
4002
4401
|
// src/components/ui/table/components/Table/Table.tsx
|
|
4003
|
-
var
|
|
4402
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4004
4403
|
function TableRoot({
|
|
4005
4404
|
data,
|
|
4006
4405
|
children,
|
|
@@ -4009,12 +4408,12 @@ function TableRoot({
|
|
|
4009
4408
|
filteredCount,
|
|
4010
4409
|
...dataTableProps
|
|
4011
4410
|
}) {
|
|
4012
|
-
const { header, pagination: paginationElement } = (0,
|
|
4411
|
+
const { header, pagination: paginationElement } = (0, import_react12.useMemo)(
|
|
4013
4412
|
() => parseTableChildren(children),
|
|
4014
4413
|
[children]
|
|
4015
4414
|
);
|
|
4016
|
-
const [sort, setSort] = (0,
|
|
4017
|
-
const handleSort = (0,
|
|
4415
|
+
const [sort, setSort] = (0, import_react12.useState)(null);
|
|
4416
|
+
const handleSort = (0, import_react12.useCallback)((field) => {
|
|
4018
4417
|
setSort((previous) => {
|
|
4019
4418
|
if (previous?.field !== field) {
|
|
4020
4419
|
return { field, direction: "asc" };
|
|
@@ -4025,8 +4424,8 @@ function TableRoot({
|
|
|
4025
4424
|
return null;
|
|
4026
4425
|
});
|
|
4027
4426
|
}, []);
|
|
4028
|
-
const columnTree = (0,
|
|
4029
|
-
const columns = (0,
|
|
4427
|
+
const columnTree = (0, import_react12.useMemo)(() => extractColumnTree(header), [header]);
|
|
4428
|
+
const columns = (0, import_react12.useMemo)(
|
|
4030
4429
|
() => buildColumnDefsFromTree(columnTree, sort, handleSort),
|
|
4031
4430
|
[columnTree, sort, handleSort]
|
|
4032
4431
|
);
|
|
@@ -4034,7 +4433,7 @@ function TableRoot({
|
|
|
4034
4433
|
const pageSize = paginationProps?.pageSize ?? 10;
|
|
4035
4434
|
const page = paginationProps?.page ?? 1;
|
|
4036
4435
|
const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
|
|
4037
|
-
const tableData = (0,
|
|
4436
|
+
const tableData = (0, import_react12.useMemo)(() => {
|
|
4038
4437
|
const sortedData = sortTableData(data, sort);
|
|
4039
4438
|
if (!paginationProps) return sortedData;
|
|
4040
4439
|
return paginateTableData(sortedData, page, pageSize);
|
|
@@ -4042,8 +4441,8 @@ function TableRoot({
|
|
|
4042
4441
|
if (countLeafColumns(columnTree) === 0) {
|
|
4043
4442
|
console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
|
|
4044
4443
|
}
|
|
4045
|
-
return /* @__PURE__ */ (0,
|
|
4046
|
-
/* @__PURE__ */ (0,
|
|
4444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "TableJSX", children: [
|
|
4445
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4047
4446
|
DataTable,
|
|
4048
4447
|
{
|
|
4049
4448
|
...dataTableProps,
|
|
@@ -4054,7 +4453,7 @@ function TableRoot({
|
|
|
4054
4453
|
className: cn(className, paginationProps && "DataTableJSX--with-pagination")
|
|
4055
4454
|
}
|
|
4056
4455
|
),
|
|
4057
|
-
paginationProps && /* @__PURE__ */ (0,
|
|
4456
|
+
paginationProps && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4058
4457
|
TablePagination,
|
|
4059
4458
|
{
|
|
4060
4459
|
page,
|
|
@@ -4079,7 +4478,7 @@ function createTable() {
|
|
|
4079
4478
|
ColumnGroup.displayName = TABLE_COLUMN_GROUP_DISPLAY_NAME;
|
|
4080
4479
|
return Object.assign(
|
|
4081
4480
|
function BoundTable(props) {
|
|
4082
|
-
return /* @__PURE__ */ (0,
|
|
4481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TableRoot, { ...props });
|
|
4083
4482
|
},
|
|
4084
4483
|
{
|
|
4085
4484
|
Header: TableHeader,
|
|
@@ -4099,6 +4498,7 @@ var Table = Object.assign(TableRoot, {
|
|
|
4099
4498
|
});
|
|
4100
4499
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4101
4500
|
0 && (module.exports = {
|
|
4501
|
+
BUILTIN_CELL_RENDERERS,
|
|
4102
4502
|
CELL_SELECTION_EDGES_CLASS,
|
|
4103
4503
|
DEFAULT_DATA_TABLE_LABELS,
|
|
4104
4504
|
DEFAULT_TREE_CHILDREN_FIELD,
|
|
@@ -4107,6 +4507,7 @@ var Table = Object.assign(TableRoot, {
|
|
|
4107
4507
|
DEFAULT_TREE_QTY_FIELD,
|
|
4108
4508
|
DataTable,
|
|
4109
4509
|
INLINE_SEARCH_MAX_RESULTS,
|
|
4510
|
+
ResolvedTableCell,
|
|
4110
4511
|
Table,
|
|
4111
4512
|
applyCellEdit,
|
|
4112
4513
|
applyFillData,
|
|
@@ -4126,10 +4527,14 @@ var Table = Object.assign(TableRoot, {
|
|
|
4126
4527
|
collectFillChanges,
|
|
4127
4528
|
collectRowSpanColumns,
|
|
4128
4529
|
collectSearchMatchesInRange,
|
|
4530
|
+
commitCellValue,
|
|
4531
|
+
createCellRendererRegistry,
|
|
4129
4532
|
createSearchRegex,
|
|
4130
4533
|
createTable,
|
|
4131
4534
|
escapeSearchRegex,
|
|
4132
4535
|
flattenSubtreeRows,
|
|
4536
|
+
formatCellValue,
|
|
4537
|
+
formatDefaultCellValue,
|
|
4133
4538
|
formatSearchResultLabel,
|
|
4134
4539
|
getCellEditDraftValue,
|
|
4135
4540
|
getCellSelectionEdgeStyle,
|
|
@@ -4151,8 +4556,10 @@ var Table = Object.assign(TableRoot, {
|
|
|
4151
4556
|
parseClipboardTSV,
|
|
4152
4557
|
parseClipboardTSVWithDepths,
|
|
4153
4558
|
previousSearchIndex,
|
|
4559
|
+
resolveCellRenderer,
|
|
4154
4560
|
resolveColumnFreezeSide,
|
|
4155
4561
|
resolveDataTableLabels,
|
|
4562
|
+
resolveHeaderFreezeOffset,
|
|
4156
4563
|
resolvePasteColumnIds,
|
|
4157
4564
|
resolveRowSelection,
|
|
4158
4565
|
resolveRowSpanAt,
|
|
@@ -4165,5 +4572,6 @@ var Table = Object.assign(TableRoot, {
|
|
|
4165
4572
|
useConvertTreeData,
|
|
4166
4573
|
useGlideTable,
|
|
4167
4574
|
useInlineSearch,
|
|
4575
|
+
withCellUpdate,
|
|
4168
4576
|
writeSelectionToClipboard
|
|
4169
4577
|
});
|