react-glide-table 1.7.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -2
- package/dist/compound.cjs +453 -97
- package/dist/compound.d.cts +2 -2
- package/dist/compound.d.ts +2 -2
- package/dist/compound.js +438 -82
- package/dist/core.cjs +399 -12
- package/dist/core.d.cts +40 -4
- package/dist/core.d.ts +40 -4
- package/dist/core.js +391 -12
- package/dist/index.cjs +550 -164
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +522 -144
- package/dist/{types-Cs9MiZs1.d.cts → types-DJOlsDL8.d.cts} +73 -4
- package/dist/{types-Cs9MiZs1.d.ts → types-DJOlsDL8.d.ts} +73 -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,
|
|
@@ -187,6 +195,37 @@ function applyCellEdit(data, rows, rowIndex, colIndex, raw) {
|
|
|
187
195
|
return newData;
|
|
188
196
|
}
|
|
189
197
|
|
|
198
|
+
// src/components/ui/table/features/cell-render/commitCellValue.ts
|
|
199
|
+
function commitCellValue({
|
|
200
|
+
data,
|
|
201
|
+
rows,
|
|
202
|
+
rowId,
|
|
203
|
+
columnId,
|
|
204
|
+
value,
|
|
205
|
+
onCellChange,
|
|
206
|
+
onDataChange
|
|
207
|
+
}) {
|
|
208
|
+
if (!onCellChange && !onDataChange) return true;
|
|
209
|
+
if (onCellChange) {
|
|
210
|
+
onCellChange(rowId, columnId, value);
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
const row = rows.find((item) => item.id === rowId);
|
|
214
|
+
if (!row) return false;
|
|
215
|
+
const cell = row.getAllCells().find((item) => item.column.id === columnId) ?? row.getVisibleCells().find((item) => item.column.id === columnId);
|
|
216
|
+
if (!cell) return false;
|
|
217
|
+
const accessorKey = getColumnAccessorKey(cell.column.columnDef);
|
|
218
|
+
if (!accessorKey) return false;
|
|
219
|
+
const dataIndex = row.index;
|
|
220
|
+
if (dataIndex < 0 || dataIndex >= data.length) return false;
|
|
221
|
+
const next = data.map((item) => ({ ...item }));
|
|
222
|
+
const target = next[dataIndex];
|
|
223
|
+
if (!target) return false;
|
|
224
|
+
target[accessorKey] = value;
|
|
225
|
+
onDataChange?.(next);
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
|
|
190
229
|
// src/components/ui/table/features/cell-edit/useCellEdit.ts
|
|
191
230
|
function useCellEdit({
|
|
192
231
|
data,
|
|
@@ -222,21 +261,23 @@ function useCellEdit({
|
|
|
222
261
|
cancelEdit();
|
|
223
262
|
return true;
|
|
224
263
|
}
|
|
225
|
-
const value = raw ?? draftValueRef.current;
|
|
226
264
|
if (!isColumnEditable(cell.column.columnDef)) {
|
|
227
265
|
cancelEdit();
|
|
228
266
|
return true;
|
|
229
267
|
}
|
|
268
|
+
const value = raw ?? draftValueRef.current;
|
|
230
269
|
const parsed = parseCellEditValue(value, getColumnEditType(cell.column.columnDef));
|
|
231
270
|
if (!parsed.ok) return false;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
271
|
+
const committed = commitCellValue({
|
|
272
|
+
data,
|
|
273
|
+
rows,
|
|
274
|
+
rowId: row.id,
|
|
275
|
+
columnId: cell.column.id,
|
|
276
|
+
value: parsed.value,
|
|
277
|
+
onCellChange,
|
|
278
|
+
onDataChange
|
|
279
|
+
});
|
|
280
|
+
if (!committed) return false;
|
|
240
281
|
cancelEdit();
|
|
241
282
|
return true;
|
|
242
283
|
},
|
|
@@ -265,6 +306,218 @@ function useCellEdit({
|
|
|
265
306
|
};
|
|
266
307
|
}
|
|
267
308
|
|
|
309
|
+
// src/components/ui/table/features/cell-render/builtins.tsx
|
|
310
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
311
|
+
function asString(value) {
|
|
312
|
+
if (value == null) return "";
|
|
313
|
+
return String(value);
|
|
314
|
+
}
|
|
315
|
+
function asStringList(value) {
|
|
316
|
+
if (Array.isArray(value)) {
|
|
317
|
+
return value.map((item) => asString(item)).filter(Boolean);
|
|
318
|
+
}
|
|
319
|
+
if (value == null || value === "") return [];
|
|
320
|
+
return [asString(value)];
|
|
321
|
+
}
|
|
322
|
+
function asDrilldownItems(value) {
|
|
323
|
+
if (!Array.isArray(value)) return [];
|
|
324
|
+
return value.flatMap((item) => {
|
|
325
|
+
if (item == null) return [];
|
|
326
|
+
if (typeof item === "string") return [{ text: item }];
|
|
327
|
+
if (typeof item === "object") {
|
|
328
|
+
const record = item;
|
|
329
|
+
const text = asString(record.text ?? record.label ?? "");
|
|
330
|
+
if (!text) return [];
|
|
331
|
+
const img = record.img ?? record.image;
|
|
332
|
+
return [{ text, ...typeof img === "string" ? { img } : {} }];
|
|
333
|
+
}
|
|
334
|
+
return [{ text: asString(item) }];
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function escapeHtml(text) {
|
|
338
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
339
|
+
}
|
|
340
|
+
function simpleMarkdownToHtml(source) {
|
|
341
|
+
const escaped = escapeHtml(source);
|
|
342
|
+
return escaped.replace(/`([^`]+)`/g, "<code>$1</code>").replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/\*([^*]+)\*/g, "<em>$1</em>").replace(/\n/g, "<br />");
|
|
343
|
+
}
|
|
344
|
+
function TextCell({ value }) {
|
|
345
|
+
return asString(value);
|
|
346
|
+
}
|
|
347
|
+
function NumberCell({ value }) {
|
|
348
|
+
if (value == null || value === "") return null;
|
|
349
|
+
return asString(value);
|
|
350
|
+
}
|
|
351
|
+
function BooleanCell({ value, update, cellProps }) {
|
|
352
|
+
const checked = Boolean(value);
|
|
353
|
+
const readonly = Boolean(cellProps?.readonly);
|
|
354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
355
|
+
"input",
|
|
356
|
+
{
|
|
357
|
+
type: "checkbox",
|
|
358
|
+
className: "data-table-cell-boolean",
|
|
359
|
+
checked,
|
|
360
|
+
disabled: readonly,
|
|
361
|
+
"aria-checked": checked,
|
|
362
|
+
onChange: (event) => {
|
|
363
|
+
if (readonly) return;
|
|
364
|
+
update(event.target.checked);
|
|
365
|
+
},
|
|
366
|
+
onClick: (event) => {
|
|
367
|
+
event.stopPropagation();
|
|
368
|
+
},
|
|
369
|
+
onMouseDown: (event) => {
|
|
370
|
+
event.stopPropagation();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
function sanitizeUriHref(raw) {
|
|
376
|
+
const href = raw.trim();
|
|
377
|
+
if (!href) return null;
|
|
378
|
+
if (href.startsWith("/") || href.startsWith("#") || href.startsWith("?") || href.startsWith("./") || href.startsWith("../")) {
|
|
379
|
+
return href;
|
|
380
|
+
}
|
|
381
|
+
try {
|
|
382
|
+
const parsed = new URL(href);
|
|
383
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
384
|
+
if (protocol === "http:" || protocol === "https:" || protocol === "mailto:") {
|
|
385
|
+
return href;
|
|
386
|
+
}
|
|
387
|
+
return null;
|
|
388
|
+
} catch {
|
|
389
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return null;
|
|
390
|
+
return href;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function UriCell({ value }) {
|
|
394
|
+
const raw = asString(value);
|
|
395
|
+
if (!raw) return null;
|
|
396
|
+
const href = sanitizeUriHref(raw);
|
|
397
|
+
if (!href) {
|
|
398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-uri", children: raw });
|
|
399
|
+
}
|
|
400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
401
|
+
"a",
|
|
402
|
+
{
|
|
403
|
+
className: "data-table-cell-uri",
|
|
404
|
+
href,
|
|
405
|
+
target: "_blank",
|
|
406
|
+
rel: "noopener noreferrer",
|
|
407
|
+
onClick: (event) => event.stopPropagation(),
|
|
408
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
409
|
+
children: raw
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
function ImageCell({ value }) {
|
|
414
|
+
const urls = asStringList(value);
|
|
415
|
+
if (urls.length === 0) return null;
|
|
416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-image", children: urls.map((url, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
417
|
+
"img",
|
|
418
|
+
{
|
|
419
|
+
src: url,
|
|
420
|
+
alt: "",
|
|
421
|
+
className: "data-table-cell-image-item"
|
|
422
|
+
},
|
|
423
|
+
`${index}:${url}`
|
|
424
|
+
)) });
|
|
425
|
+
}
|
|
426
|
+
function BubbleCell({ value }) {
|
|
427
|
+
const items = asStringList(value);
|
|
428
|
+
if (items.length === 0) return null;
|
|
429
|
+
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}`)) });
|
|
430
|
+
}
|
|
431
|
+
function MarkdownCell({ value }) {
|
|
432
|
+
const source = asString(value);
|
|
433
|
+
if (!source) return null;
|
|
434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
435
|
+
"span",
|
|
436
|
+
{
|
|
437
|
+
className: "data-table-cell-markdown",
|
|
438
|
+
dangerouslySetInnerHTML: { __html: simpleMarkdownToHtml(source) }
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
function DrilldownCell({ value }) {
|
|
443
|
+
const items = asDrilldownItems(value);
|
|
444
|
+
if (items.length === 0) return null;
|
|
445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-drilldown", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
446
|
+
"span",
|
|
447
|
+
{
|
|
448
|
+
className: "data-table-cell-drilldown-item",
|
|
449
|
+
children: [
|
|
450
|
+
item.img ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
451
|
+
"img",
|
|
452
|
+
{
|
|
453
|
+
src: item.img,
|
|
454
|
+
alt: "",
|
|
455
|
+
className: "data-table-cell-drilldown-image"
|
|
456
|
+
}
|
|
457
|
+
) : null,
|
|
458
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-drilldown-text", children: item.text })
|
|
459
|
+
]
|
|
460
|
+
},
|
|
461
|
+
`${index}:${item.text}:${item.img ?? ""}`
|
|
462
|
+
)) });
|
|
463
|
+
}
|
|
464
|
+
function LoadingCell() {
|
|
465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-loading", "aria-busy": "true" });
|
|
466
|
+
}
|
|
467
|
+
function ProtectedCell() {
|
|
468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-protected", "aria-label": "protected", children: "****" });
|
|
469
|
+
}
|
|
470
|
+
function RowIdCell({ value }) {
|
|
471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "data-table-cell-row-id", children: asString(value) });
|
|
472
|
+
}
|
|
473
|
+
var BUILTIN_RENDER_MAP = {
|
|
474
|
+
text: TextCell,
|
|
475
|
+
number: NumberCell,
|
|
476
|
+
boolean: BooleanCell,
|
|
477
|
+
uri: UriCell,
|
|
478
|
+
image: ImageCell,
|
|
479
|
+
bubble: BubbleCell,
|
|
480
|
+
markdown: MarkdownCell,
|
|
481
|
+
drilldown: DrilldownCell,
|
|
482
|
+
loading: LoadingCell,
|
|
483
|
+
protected: ProtectedCell,
|
|
484
|
+
"row-id": RowIdCell
|
|
485
|
+
};
|
|
486
|
+
var BUILTIN_CELL_RENDERERS = Object.keys(BUILTIN_RENDER_MAP).map((kind) => ({
|
|
487
|
+
kind,
|
|
488
|
+
render: BUILTIN_RENDER_MAP[kind]
|
|
489
|
+
}));
|
|
490
|
+
|
|
491
|
+
// src/components/ui/table/features/cell-render/registry.ts
|
|
492
|
+
function createCellRendererRegistry(customRenderers = []) {
|
|
493
|
+
const registry = /* @__PURE__ */ new Map();
|
|
494
|
+
for (const renderer of BUILTIN_CELL_RENDERERS) {
|
|
495
|
+
registry.set(renderer.kind, renderer);
|
|
496
|
+
}
|
|
497
|
+
for (const renderer of customRenderers) {
|
|
498
|
+
registry.set(renderer.kind, renderer);
|
|
499
|
+
}
|
|
500
|
+
return registry;
|
|
501
|
+
}
|
|
502
|
+
function resolveCellRenderer(registry, kind, ctx) {
|
|
503
|
+
if (!kind) return void 0;
|
|
504
|
+
const renderer = registry.get(kind);
|
|
505
|
+
if (!renderer) return void 0;
|
|
506
|
+
if (renderer.isMatch && !renderer.isMatch(ctx)) {
|
|
507
|
+
return void 0;
|
|
508
|
+
}
|
|
509
|
+
return renderer;
|
|
510
|
+
}
|
|
511
|
+
function formatDefaultCellValue(value) {
|
|
512
|
+
if (value == null) return null;
|
|
513
|
+
if (typeof value === "string") return value;
|
|
514
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
515
|
+
return String(value);
|
|
516
|
+
}
|
|
517
|
+
if (typeof value === "bigint") return value.toString();
|
|
518
|
+
return String(value);
|
|
519
|
+
}
|
|
520
|
+
|
|
268
521
|
// src/components/ui/table/features/cell-selection/useCellSelection.ts
|
|
269
522
|
var import_react2 = require("react");
|
|
270
523
|
|
|
@@ -574,9 +827,34 @@ function hasCellSelectionEdges(style) {
|
|
|
574
827
|
}
|
|
575
828
|
|
|
576
829
|
// src/components/ui/table/features/cell-selection/copyData.ts
|
|
830
|
+
function formatPrimitive(value) {
|
|
831
|
+
if (value === null || value === void 0) return "";
|
|
832
|
+
if (typeof value === "string") return value;
|
|
833
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
834
|
+
return String(value);
|
|
835
|
+
}
|
|
836
|
+
return "";
|
|
837
|
+
}
|
|
838
|
+
function formatObjectValue(value) {
|
|
839
|
+
const text = value.text ?? value.label ?? value.name ?? value.title;
|
|
840
|
+
if (text != null && text !== "") {
|
|
841
|
+
return formatCellValue(text);
|
|
842
|
+
}
|
|
843
|
+
try {
|
|
844
|
+
return JSON.stringify(value);
|
|
845
|
+
} catch {
|
|
846
|
+
return "";
|
|
847
|
+
}
|
|
848
|
+
}
|
|
577
849
|
function formatCellValue(value) {
|
|
578
850
|
if (value === null || value === void 0) return "";
|
|
579
|
-
|
|
851
|
+
if (Array.isArray(value)) {
|
|
852
|
+
return value.map((item) => formatCellValue(item)).filter((item) => item.length > 0).join(", ");
|
|
853
|
+
}
|
|
854
|
+
if (typeof value === "object") {
|
|
855
|
+
return formatObjectValue(value);
|
|
856
|
+
}
|
|
857
|
+
return formatPrimitive(value);
|
|
580
858
|
}
|
|
581
859
|
function getNestedValue(row, path) {
|
|
582
860
|
if (!path.includes(".")) return row[path];
|
|
@@ -1200,10 +1478,40 @@ function getColumnFreezeStyle(offset, options) {
|
|
|
1200
1478
|
return {
|
|
1201
1479
|
position: "sticky",
|
|
1202
1480
|
...offset.side === "left" ? { left: offset.offset } : { right: offset.offset },
|
|
1203
|
-
zIndex: zBase + offset.stack
|
|
1204
|
-
...options?.isHeader ? { top: options.headerTop ?? 0 } : {}
|
|
1481
|
+
zIndex: zBase + offset.stack
|
|
1205
1482
|
};
|
|
1206
1483
|
}
|
|
1484
|
+
function resolveHeaderFreezeOffset(column, freezeOffsets) {
|
|
1485
|
+
const direct = freezeOffsets.get(column.id);
|
|
1486
|
+
if (direct) return direct;
|
|
1487
|
+
const leaves = typeof column.getLeafColumns === "function" ? column.getLeafColumns() : column.columns && column.columns.length > 0 ? flattenHeaderLeaves(column) : [];
|
|
1488
|
+
if (leaves.length === 0) return void 0;
|
|
1489
|
+
const leafOffsets = [];
|
|
1490
|
+
for (const leaf of leaves) {
|
|
1491
|
+
const offset2 = freezeOffsets.get(leaf.id);
|
|
1492
|
+
if (!offset2) return void 0;
|
|
1493
|
+
leafOffsets.push(offset2);
|
|
1494
|
+
}
|
|
1495
|
+
const side = leafOffsets[0]?.side;
|
|
1496
|
+
if (!side || leafOffsets.some((offset2) => offset2.side !== side)) {
|
|
1497
|
+
return void 0;
|
|
1498
|
+
}
|
|
1499
|
+
const offset = Math.min(...leafOffsets.map((item) => item.offset));
|
|
1500
|
+
const leftmost = leafOffsets[0];
|
|
1501
|
+
const rightmost = leafOffsets[leafOffsets.length - 1];
|
|
1502
|
+
return {
|
|
1503
|
+
side,
|
|
1504
|
+
offset,
|
|
1505
|
+
edgeLeft: leftmost.edgeLeft,
|
|
1506
|
+
edgeRight: rightmost.edgeRight,
|
|
1507
|
+
isEdge: leftmost.edgeLeft || rightmost.edgeRight,
|
|
1508
|
+
stack: Math.max(...leafOffsets.map((item) => item.stack))
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1511
|
+
function flattenHeaderLeaves(column) {
|
|
1512
|
+
if (!column.columns || column.columns.length === 0) return [column];
|
|
1513
|
+
return column.columns.flatMap((child) => flattenHeaderLeaves(child));
|
|
1514
|
+
}
|
|
1207
1515
|
|
|
1208
1516
|
// src/components/ui/table/features/inline-search/inlineSearch.ts
|
|
1209
1517
|
var INLINE_SEARCH_MAX_RESULTS = 1e3;
|
|
@@ -1947,6 +2255,7 @@ function useGlideTable(options) {
|
|
|
1947
2255
|
onDataChange,
|
|
1948
2256
|
onCellChange,
|
|
1949
2257
|
onBatchChange,
|
|
2258
|
+
cellRenderers,
|
|
1950
2259
|
preserveRowSelection = false,
|
|
1951
2260
|
toggleField,
|
|
1952
2261
|
childField,
|
|
@@ -2172,6 +2481,22 @@ function useGlideTable(options) {
|
|
|
2172
2481
|
commitEdit,
|
|
2173
2482
|
cancelEdit
|
|
2174
2483
|
} = useCellEdit({ data: tableData, rows, onDataChange, onCellChange });
|
|
2484
|
+
const cellRendererRegistry = (0, import_react5.useMemo)(
|
|
2485
|
+
() => createCellRendererRegistry(cellRenderers),
|
|
2486
|
+
[cellRenderers]
|
|
2487
|
+
);
|
|
2488
|
+
const commitRenderedCellValue = (0, import_react5.useCallback)(
|
|
2489
|
+
(rowId, columnId, value) => commitCellValue({
|
|
2490
|
+
data: tableData,
|
|
2491
|
+
rows,
|
|
2492
|
+
rowId,
|
|
2493
|
+
columnId,
|
|
2494
|
+
value,
|
|
2495
|
+
onCellChange,
|
|
2496
|
+
onDataChange
|
|
2497
|
+
}),
|
|
2498
|
+
[onCellChange, onDataChange, rows, tableData]
|
|
2499
|
+
);
|
|
2175
2500
|
const handleCellMouseDownWithCommit = (0, import_react5.useCallback)(
|
|
2176
2501
|
(rowIndex, colIndex, options2) => {
|
|
2177
2502
|
const isSameEditingCell = editingCell?.rowIndex === rowIndex && editingCell?.colIndex === colIndex;
|
|
@@ -2408,6 +2733,10 @@ function useGlideTable(options) {
|
|
|
2408
2733
|
onCommitEdit: commitEdit,
|
|
2409
2734
|
onCancelEdit: cancelEdit
|
|
2410
2735
|
},
|
|
2736
|
+
cellRender: {
|
|
2737
|
+
registry: cellRendererRegistry,
|
|
2738
|
+
commitValue: commitRenderedCellValue
|
|
2739
|
+
},
|
|
2411
2740
|
expand: {
|
|
2412
2741
|
enableExpand,
|
|
2413
2742
|
toggleField,
|
|
@@ -2454,6 +2783,8 @@ function useGlideTable(options) {
|
|
|
2454
2783
|
startEdit,
|
|
2455
2784
|
commitEdit,
|
|
2456
2785
|
cancelEdit,
|
|
2786
|
+
cellRendererRegistry,
|
|
2787
|
+
commitRenderedCellValue,
|
|
2457
2788
|
enableExpand,
|
|
2458
2789
|
toggleField,
|
|
2459
2790
|
expandedRows,
|
|
@@ -2518,6 +2849,60 @@ function useGlideTable(options) {
|
|
|
2518
2849
|
};
|
|
2519
2850
|
}
|
|
2520
2851
|
|
|
2852
|
+
// src/components/ui/table/features/cell-render/ResolvedTableCell.tsx
|
|
2853
|
+
var import_react7 = require("react");
|
|
2854
|
+
|
|
2855
|
+
// src/components/ui/table/DataTableContext.tsx
|
|
2856
|
+
var import_react6 = require("react");
|
|
2857
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2858
|
+
var DataTableContext = (0, import_react6.createContext)(null);
|
|
2859
|
+
function useDataTableRowContext() {
|
|
2860
|
+
const context = (0, import_react6.use)(DataTableContext);
|
|
2861
|
+
if (!context) {
|
|
2862
|
+
throw new Error("useDataTableRowContext must be used within a DataTableContextProvider");
|
|
2863
|
+
}
|
|
2864
|
+
return context;
|
|
2865
|
+
}
|
|
2866
|
+
function DataTableContextProvider({
|
|
2867
|
+
value,
|
|
2868
|
+
children
|
|
2869
|
+
}) {
|
|
2870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DataTableContext, { value, children });
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
// src/components/ui/table/features/cell-render/ResolvedTableCell.tsx
|
|
2874
|
+
function ResolvedTableCell({
|
|
2875
|
+
info
|
|
2876
|
+
}) {
|
|
2877
|
+
const { cellRender } = useDataTableRowContext();
|
|
2878
|
+
const { row, column, getValue } = info;
|
|
2879
|
+
const meta = column.columnDef.meta;
|
|
2880
|
+
const value = getValue();
|
|
2881
|
+
const columnId = column.id;
|
|
2882
|
+
const update = (0, import_react7.useCallback)(
|
|
2883
|
+
(next) => {
|
|
2884
|
+
cellRender.commitValue(row.id, columnId, next);
|
|
2885
|
+
},
|
|
2886
|
+
[cellRender, columnId, row.id]
|
|
2887
|
+
);
|
|
2888
|
+
const ctx = {
|
|
2889
|
+
value,
|
|
2890
|
+
row,
|
|
2891
|
+
index: row.index,
|
|
2892
|
+
columnId,
|
|
2893
|
+
cellProps: meta?.cellProps,
|
|
2894
|
+
update
|
|
2895
|
+
};
|
|
2896
|
+
if (meta?.cellRender) {
|
|
2897
|
+
return meta.cellRender(ctx);
|
|
2898
|
+
}
|
|
2899
|
+
const renderer = resolveCellRenderer(cellRender.registry, meta?.kind, ctx);
|
|
2900
|
+
if (renderer) {
|
|
2901
|
+
return renderer.render(ctx);
|
|
2902
|
+
}
|
|
2903
|
+
return formatDefaultCellValue(value);
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2521
2906
|
// src/components/ui/table/features/column-resize/columnResize.ts
|
|
2522
2907
|
function getColumnSizeStyle(size, options) {
|
|
2523
2908
|
const { force = false, lockMax = false } = options ?? {};
|
|
@@ -2533,34 +2918,16 @@ function getColumnSizeStyle(size, options) {
|
|
|
2533
2918
|
|
|
2534
2919
|
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
2535
2920
|
var import_react_table3 = require("@tanstack/react-table");
|
|
2536
|
-
var
|
|
2921
|
+
var import_react9 = require("react");
|
|
2537
2922
|
|
|
2538
2923
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
2539
2924
|
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
|
-
}
|
|
2925
|
+
var import_react8 = require("react");
|
|
2559
2926
|
|
|
2560
2927
|
// src/components/ui/table/components/icons.tsx
|
|
2561
|
-
var
|
|
2928
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2562
2929
|
function ChevronDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
2563
|
-
return /* @__PURE__ */ (0,
|
|
2930
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2564
2931
|
"svg",
|
|
2565
2932
|
{
|
|
2566
2933
|
className,
|
|
@@ -2573,12 +2940,12 @@ function ChevronDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2573
2940
|
strokeWidth: "2",
|
|
2574
2941
|
strokeLinecap: "round",
|
|
2575
2942
|
strokeLinejoin: "round",
|
|
2576
|
-
children: /* @__PURE__ */ (0,
|
|
2943
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m6 9 6 6 6-6" })
|
|
2577
2944
|
}
|
|
2578
2945
|
);
|
|
2579
2946
|
}
|
|
2580
2947
|
function ChevronUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
2581
|
-
return /* @__PURE__ */ (0,
|
|
2948
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2582
2949
|
"svg",
|
|
2583
2950
|
{
|
|
2584
2951
|
className,
|
|
@@ -2591,12 +2958,12 @@ function ChevronUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2591
2958
|
strokeWidth: "2",
|
|
2592
2959
|
strokeLinecap: "round",
|
|
2593
2960
|
strokeLinejoin: "round",
|
|
2594
|
-
children: /* @__PURE__ */ (0,
|
|
2961
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m18 15-6-6-6 6" })
|
|
2595
2962
|
}
|
|
2596
2963
|
);
|
|
2597
2964
|
}
|
|
2598
2965
|
function ChevronLeft({ className, "aria-hidden": ariaHidden = true }) {
|
|
2599
|
-
return /* @__PURE__ */ (0,
|
|
2966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2600
2967
|
"svg",
|
|
2601
2968
|
{
|
|
2602
2969
|
className,
|
|
@@ -2609,12 +2976,12 @@ function ChevronLeft({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2609
2976
|
strokeWidth: "2",
|
|
2610
2977
|
strokeLinecap: "round",
|
|
2611
2978
|
strokeLinejoin: "round",
|
|
2612
|
-
children: /* @__PURE__ */ (0,
|
|
2979
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m15 18-6-6 6-6" })
|
|
2613
2980
|
}
|
|
2614
2981
|
);
|
|
2615
2982
|
}
|
|
2616
2983
|
function ChevronRight({ className, "aria-hidden": ariaHidden = true }) {
|
|
2617
|
-
return /* @__PURE__ */ (0,
|
|
2984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2618
2985
|
"svg",
|
|
2619
2986
|
{
|
|
2620
2987
|
className,
|
|
@@ -2627,12 +2994,12 @@ function ChevronRight({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2627
2994
|
strokeWidth: "2",
|
|
2628
2995
|
strokeLinecap: "round",
|
|
2629
2996
|
strokeLinejoin: "round",
|
|
2630
|
-
children: /* @__PURE__ */ (0,
|
|
2997
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m9 18 6-6-6-6" })
|
|
2631
2998
|
}
|
|
2632
2999
|
);
|
|
2633
3000
|
}
|
|
2634
3001
|
function ArrowUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
2635
|
-
return /* @__PURE__ */ (0,
|
|
3002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2636
3003
|
"svg",
|
|
2637
3004
|
{
|
|
2638
3005
|
className,
|
|
@@ -2646,14 +3013,14 @@ function ArrowUp({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2646
3013
|
strokeLinecap: "round",
|
|
2647
3014
|
strokeLinejoin: "round",
|
|
2648
3015
|
children: [
|
|
2649
|
-
/* @__PURE__ */ (0,
|
|
2650
|
-
/* @__PURE__ */ (0,
|
|
3016
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m18 15-6-6-6 6" }),
|
|
3017
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 21V9" })
|
|
2651
3018
|
]
|
|
2652
3019
|
}
|
|
2653
3020
|
);
|
|
2654
3021
|
}
|
|
2655
3022
|
function ArrowDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
2656
|
-
return /* @__PURE__ */ (0,
|
|
3023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2657
3024
|
"svg",
|
|
2658
3025
|
{
|
|
2659
3026
|
className,
|
|
@@ -2667,14 +3034,14 @@ function ArrowDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2667
3034
|
strokeLinecap: "round",
|
|
2668
3035
|
strokeLinejoin: "round",
|
|
2669
3036
|
children: [
|
|
2670
|
-
/* @__PURE__ */ (0,
|
|
2671
|
-
/* @__PURE__ */ (0,
|
|
3037
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m6 9 6 6 6-6" }),
|
|
3038
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M12 3v12" })
|
|
2672
3039
|
]
|
|
2673
3040
|
}
|
|
2674
3041
|
);
|
|
2675
3042
|
}
|
|
2676
3043
|
function ArrowUpDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
2677
|
-
return /* @__PURE__ */ (0,
|
|
3044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2678
3045
|
"svg",
|
|
2679
3046
|
{
|
|
2680
3047
|
className,
|
|
@@ -2688,10 +3055,10 @@ function ArrowUpDown({ className, "aria-hidden": ariaHidden = true }) {
|
|
|
2688
3055
|
strokeLinecap: "round",
|
|
2689
3056
|
strokeLinejoin: "round",
|
|
2690
3057
|
children: [
|
|
2691
|
-
/* @__PURE__ */ (0,
|
|
2692
|
-
/* @__PURE__ */ (0,
|
|
2693
|
-
/* @__PURE__ */ (0,
|
|
2694
|
-
/* @__PURE__ */ (0,
|
|
3058
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m21 16-4 4-4-4" }),
|
|
3059
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M17 20V4" }),
|
|
3060
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "m3 8 4-4 4 4" }),
|
|
3061
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M7 4v16" })
|
|
2695
3062
|
]
|
|
2696
3063
|
}
|
|
2697
3064
|
);
|
|
@@ -2703,7 +3070,7 @@ function cn(...inputs) {
|
|
|
2703
3070
|
}
|
|
2704
3071
|
|
|
2705
3072
|
// src/components/ui/table/components/DataTable/DataTableRow.tsx
|
|
2706
|
-
var
|
|
3073
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2707
3074
|
function isInteractiveMouseTarget(target) {
|
|
2708
3075
|
if (!(target instanceof Element)) return false;
|
|
2709
3076
|
const interactiveSelector = [
|
|
@@ -2848,14 +3215,14 @@ function DataTableRow({
|
|
|
2848
3215
|
const expandKey = toggleField && rowData[toggleField] !== null && rowData[toggleField] !== void 0 ? String(rowData[toggleField]) : null;
|
|
2849
3216
|
const isExpanded = expandKey !== null && Boolean(expandedRows?.has(expandKey));
|
|
2850
3217
|
const rowLevel = typeof rowData.level === "number" ? rowData.level : 0;
|
|
2851
|
-
const editInputRef = (0,
|
|
3218
|
+
const editInputRef = (0, import_react8.useRef)(null);
|
|
2852
3219
|
const isRowEditing = editingCell?.rowIndex === rowIndex;
|
|
2853
|
-
(0,
|
|
3220
|
+
(0, import_react8.useEffect)(() => {
|
|
2854
3221
|
if (!isRowEditing) return;
|
|
2855
3222
|
editInputRef.current?.focus();
|
|
2856
3223
|
editInputRef.current?.select();
|
|
2857
3224
|
}, [isRowEditing, editingCell?.colIndex]);
|
|
2858
|
-
return /* @__PURE__ */ (0,
|
|
3225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2859
3226
|
"tr",
|
|
2860
3227
|
{
|
|
2861
3228
|
ref: measureElement,
|
|
@@ -2949,7 +3316,7 @@ function DataTableRow({
|
|
|
2949
3316
|
const searchMatchKey = buildSearchMatchKey(cellIndex, rowIndex);
|
|
2950
3317
|
const isSearchMatch = enableInlineSearch && searchMatchKeys.has(searchMatchKey);
|
|
2951
3318
|
const isSearchActive = isSearchMatch && activeMatch !== null && activeMatch[0] === cellIndex && activeMatch[1] === rowIndex;
|
|
2952
|
-
return /* @__PURE__ */ (0,
|
|
3319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2953
3320
|
"td",
|
|
2954
3321
|
{
|
|
2955
3322
|
"data-row-index": rowIndex,
|
|
@@ -3023,7 +3390,7 @@ function DataTableRow({
|
|
|
3023
3390
|
classNames?.cell
|
|
3024
3391
|
),
|
|
3025
3392
|
children: [
|
|
3026
|
-
isEditing ? /* @__PURE__ */ (0,
|
|
3393
|
+
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3027
3394
|
"input",
|
|
3028
3395
|
{
|
|
3029
3396
|
...editInputProps,
|
|
@@ -3066,8 +3433,8 @@ function DataTableRow({
|
|
|
3066
3433
|
onCommitEdit(event.currentTarget.value);
|
|
3067
3434
|
}
|
|
3068
3435
|
}
|
|
3069
|
-
) : isExpandCell && enableExpand ? /* @__PURE__ */ (0,
|
|
3070
|
-
/* @__PURE__ */ (0,
|
|
3436
|
+
) : isExpandCell && enableExpand ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cn("expand-cell", classNames?.expandCell), children: [
|
|
3437
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3071
3438
|
"div",
|
|
3072
3439
|
{
|
|
3073
3440
|
className: cn(
|
|
@@ -3075,7 +3442,7 @@ function DataTableRow({
|
|
|
3075
3442
|
classNames?.expandCellContent
|
|
3076
3443
|
),
|
|
3077
3444
|
children: [
|
|
3078
|
-
rowLevel > 0 && /* @__PURE__ */ (0,
|
|
3445
|
+
rowLevel > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3079
3446
|
"span",
|
|
3080
3447
|
{
|
|
3081
3448
|
className: cn(
|
|
@@ -3085,7 +3452,7 @@ function DataTableRow({
|
|
|
3085
3452
|
children: "\xB7"
|
|
3086
3453
|
}
|
|
3087
3454
|
),
|
|
3088
|
-
/* @__PURE__ */ (0,
|
|
3455
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3089
3456
|
"div",
|
|
3090
3457
|
{
|
|
3091
3458
|
className: cn(
|
|
@@ -3098,7 +3465,7 @@ function DataTableRow({
|
|
|
3098
3465
|
]
|
|
3099
3466
|
}
|
|
3100
3467
|
),
|
|
3101
|
-
canExpand && expandKey && /* @__PURE__ */ (0,
|
|
3468
|
+
canExpand && expandKey && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3102
3469
|
"button",
|
|
3103
3470
|
{
|
|
3104
3471
|
type: "button",
|
|
@@ -3112,7 +3479,7 @@ function DataTableRow({
|
|
|
3112
3479
|
onToggleExpand?.(expandKey);
|
|
3113
3480
|
},
|
|
3114
3481
|
onMouseDown: (event) => event.stopPropagation(),
|
|
3115
|
-
children: isExpanded ? /* @__PURE__ */ (0,
|
|
3482
|
+
children: isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3116
3483
|
ChevronUp,
|
|
3117
3484
|
{
|
|
3118
3485
|
className: cn(
|
|
@@ -3120,7 +3487,7 @@ function DataTableRow({
|
|
|
3120
3487
|
classNames?.expandToggleIcon
|
|
3121
3488
|
)
|
|
3122
3489
|
}
|
|
3123
|
-
) : /* @__PURE__ */ (0,
|
|
3490
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3124
3491
|
ChevronDown,
|
|
3125
3492
|
{
|
|
3126
3493
|
className: cn(
|
|
@@ -3132,7 +3499,7 @@ function DataTableRow({
|
|
|
3132
3499
|
}
|
|
3133
3500
|
)
|
|
3134
3501
|
] }) : (0, import_react_table2.flexRender)(cell.column.columnDef.cell, cell.getContext()),
|
|
3135
|
-
isBottomRightCell && /* @__PURE__ */ (0,
|
|
3502
|
+
isBottomRightCell && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3136
3503
|
"div",
|
|
3137
3504
|
{
|
|
3138
3505
|
role: "presentation",
|
|
@@ -3154,9 +3521,9 @@ function DataTableRow({
|
|
|
3154
3521
|
}
|
|
3155
3522
|
|
|
3156
3523
|
// src/components/ui/table/components/DataTable/DataTableSearch.tsx
|
|
3157
|
-
var
|
|
3524
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3158
3525
|
function SearchCloseIcon({ className }) {
|
|
3159
|
-
return /* @__PURE__ */ (0,
|
|
3526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3160
3527
|
"svg",
|
|
3161
3528
|
{
|
|
3162
3529
|
className,
|
|
@@ -3170,8 +3537,8 @@ function SearchCloseIcon({ className }) {
|
|
|
3170
3537
|
strokeLinecap: "round",
|
|
3171
3538
|
strokeLinejoin: "round",
|
|
3172
3539
|
children: [
|
|
3173
|
-
/* @__PURE__ */ (0,
|
|
3174
|
-
/* @__PURE__ */ (0,
|
|
3540
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M18 6 6 18" }),
|
|
3541
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "m6 6 12 12" })
|
|
3175
3542
|
]
|
|
3176
3543
|
}
|
|
3177
3544
|
);
|
|
@@ -3217,15 +3584,15 @@ function DataTableSearch({
|
|
|
3217
3584
|
onPrevious();
|
|
3218
3585
|
}
|
|
3219
3586
|
};
|
|
3220
|
-
return /* @__PURE__ */ (0,
|
|
3587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3221
3588
|
"div",
|
|
3222
3589
|
{
|
|
3223
3590
|
className: cn("data-table-search", classNames?.search),
|
|
3224
3591
|
role: "search",
|
|
3225
3592
|
onMouseDown: (event) => event.stopPropagation(),
|
|
3226
3593
|
children: [
|
|
3227
|
-
/* @__PURE__ */ (0,
|
|
3228
|
-
/* @__PURE__ */ (0,
|
|
3594
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "data-table-search-row", children: [
|
|
3595
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3229
3596
|
"input",
|
|
3230
3597
|
{
|
|
3231
3598
|
ref: searchInputRef,
|
|
@@ -3241,7 +3608,7 @@ function DataTableSearch({
|
|
|
3241
3608
|
onKeyDown: handleKeyDown
|
|
3242
3609
|
}
|
|
3243
3610
|
),
|
|
3244
|
-
/* @__PURE__ */ (0,
|
|
3611
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3245
3612
|
"button",
|
|
3246
3613
|
{
|
|
3247
3614
|
type: "button",
|
|
@@ -3251,10 +3618,10 @@ function DataTableSearch({
|
|
|
3251
3618
|
event.stopPropagation();
|
|
3252
3619
|
onPrevious();
|
|
3253
3620
|
},
|
|
3254
|
-
children: /* @__PURE__ */ (0,
|
|
3621
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronUp, { className: "data-table-search-icon" })
|
|
3255
3622
|
}
|
|
3256
3623
|
),
|
|
3257
|
-
/* @__PURE__ */ (0,
|
|
3624
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3258
3625
|
"button",
|
|
3259
3626
|
{
|
|
3260
3627
|
type: "button",
|
|
@@ -3264,10 +3631,10 @@ function DataTableSearch({
|
|
|
3264
3631
|
event.stopPropagation();
|
|
3265
3632
|
onNext();
|
|
3266
3633
|
},
|
|
3267
|
-
children: /* @__PURE__ */ (0,
|
|
3634
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChevronDown, { className: "data-table-search-icon" })
|
|
3268
3635
|
}
|
|
3269
3636
|
),
|
|
3270
|
-
canClose ? /* @__PURE__ */ (0,
|
|
3637
|
+
canClose ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3271
3638
|
"button",
|
|
3272
3639
|
{
|
|
3273
3640
|
type: "button",
|
|
@@ -3277,11 +3644,11 @@ function DataTableSearch({
|
|
|
3277
3644
|
event.stopPropagation();
|
|
3278
3645
|
onClose();
|
|
3279
3646
|
},
|
|
3280
|
-
children: /* @__PURE__ */ (0,
|
|
3647
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SearchCloseIcon, { className: "data-table-search-icon" })
|
|
3281
3648
|
}
|
|
3282
3649
|
) : null
|
|
3283
3650
|
] }),
|
|
3284
|
-
/* @__PURE__ */ (0,
|
|
3651
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3285
3652
|
"div",
|
|
3286
3653
|
{
|
|
3287
3654
|
className: cn("data-table-search-status", classNames?.searchStatus),
|
|
@@ -3289,7 +3656,7 @@ function DataTableSearch({
|
|
|
3289
3656
|
children: resultString
|
|
3290
3657
|
}
|
|
3291
3658
|
),
|
|
3292
|
-
searchStatus !== void 0 ? /* @__PURE__ */ (0,
|
|
3659
|
+
searchStatus !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3293
3660
|
"div",
|
|
3294
3661
|
{
|
|
3295
3662
|
className: cn(
|
|
@@ -3300,7 +3667,7 @@ function DataTableSearch({
|
|
|
3300
3667
|
"aria-valuemin": 0,
|
|
3301
3668
|
"aria-valuemax": 100,
|
|
3302
3669
|
"aria-valuenow": progress,
|
|
3303
|
-
children: /* @__PURE__ */ (0,
|
|
3670
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
3304
3671
|
"div",
|
|
3305
3672
|
{
|
|
3306
3673
|
className: "data-table-search-progress-bar",
|
|
@@ -3315,7 +3682,7 @@ function DataTableSearch({
|
|
|
3315
3682
|
}
|
|
3316
3683
|
|
|
3317
3684
|
// src/components/ui/table/components/DataTable/DataTableToolbar.tsx
|
|
3318
|
-
var
|
|
3685
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3319
3686
|
function DataTableToolbar({
|
|
3320
3687
|
filteredCount,
|
|
3321
3688
|
totalCount,
|
|
@@ -3333,20 +3700,20 @@ function DataTableToolbar({
|
|
|
3333
3700
|
const selectionContent = selectionLabel?.(selectedCount) ?? null;
|
|
3334
3701
|
const hasSelectionContent = selectionContent !== null && selectionContent !== false && selectionContent !== void 0 && typeof selectionContent !== "boolean";
|
|
3335
3702
|
if (!hasLeftContent && !hasToolbar && !hasSelectionContent) return null;
|
|
3336
|
-
return /* @__PURE__ */ (0,
|
|
3337
|
-
/* @__PURE__ */ (0,
|
|
3338
|
-
hasCount && /* @__PURE__ */ (0,
|
|
3339
|
-
/* @__PURE__ */ (0,
|
|
3340
|
-
/* @__PURE__ */ (0,
|
|
3703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn("DataTableToolbarJSX", classNames?.toolbar, className), children: [
|
|
3704
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn("toolbar-left", classNames?.toolbarLeft), children: [
|
|
3705
|
+
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: [
|
|
3706
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "toolbar-count-primary", children: displayFiltered }),
|
|
3707
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "toolbar-count-placeholder", children: [
|
|
3341
3708
|
" / ",
|
|
3342
3709
|
totalCount
|
|
3343
3710
|
] })
|
|
3344
|
-
] }) : /* @__PURE__ */ (0,
|
|
3711
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "toolbar-count-primary", children: displayFiltered ?? totalCount }) }),
|
|
3345
3712
|
summary
|
|
3346
3713
|
] }),
|
|
3347
|
-
/* @__PURE__ */ (0,
|
|
3348
|
-
hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ (0,
|
|
3349
|
-
hasToolbar && /* @__PURE__ */ (0,
|
|
3714
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn("toolbar-right", classNames?.toolbarRight), children: [
|
|
3715
|
+
hasSelectionContent && (typeof selectionContent === "string" || typeof selectionContent === "number" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: cn("toolbar-selection", classNames?.toolbarSelection), children: selectionContent }) : selectionContent),
|
|
3716
|
+
hasToolbar && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: cn("toolbar-actions", classNames?.toolbarActions), children: toolbar })
|
|
3350
3717
|
] })
|
|
3351
3718
|
] });
|
|
3352
3719
|
}
|
|
@@ -3384,20 +3751,20 @@ function getMergedHeaderGroups(headerGroups) {
|
|
|
3384
3751
|
}
|
|
3385
3752
|
|
|
3386
3753
|
// src/components/ui/table/components/DataTable/DataTable.tsx
|
|
3387
|
-
var
|
|
3754
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3388
3755
|
function DefaultScroll({
|
|
3389
3756
|
scrollRef,
|
|
3390
3757
|
children,
|
|
3391
3758
|
className
|
|
3392
3759
|
}) {
|
|
3393
|
-
return /* @__PURE__ */ (0,
|
|
3760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: scrollRef, className: cn("data-table-scroll", className), children });
|
|
3394
3761
|
}
|
|
3395
3762
|
function DefaultPending({
|
|
3396
3763
|
loadingText,
|
|
3397
3764
|
className,
|
|
3398
3765
|
classNames
|
|
3399
3766
|
}) {
|
|
3400
|
-
return /* @__PURE__ */ (0,
|
|
3767
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3401
3768
|
"div",
|
|
3402
3769
|
{
|
|
3403
3770
|
className: cn(
|
|
@@ -3407,7 +3774,7 @@ function DefaultPending({
|
|
|
3407
3774
|
classNames?.pending,
|
|
3408
3775
|
className
|
|
3409
3776
|
),
|
|
3410
|
-
children: /* @__PURE__ */ (0,
|
|
3777
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: cn("data-table-loading-text", classNames?.loadingText), children: loadingText })
|
|
3411
3778
|
}
|
|
3412
3779
|
);
|
|
3413
3780
|
}
|
|
@@ -3416,7 +3783,7 @@ function DefaultEmpty({
|
|
|
3416
3783
|
columnCount,
|
|
3417
3784
|
classNames
|
|
3418
3785
|
}) {
|
|
3419
|
-
return /* @__PURE__ */ (0,
|
|
3786
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3420
3787
|
"td",
|
|
3421
3788
|
{
|
|
3422
3789
|
colSpan: columnCount,
|
|
@@ -3469,12 +3836,12 @@ function DataTable({
|
|
|
3469
3836
|
const EmptySlot = slots?.Empty ?? DefaultEmpty;
|
|
3470
3837
|
const freezeOffsets = rowContextValue.columnFreeze.offsets;
|
|
3471
3838
|
const headerGroups = getMergedHeaderGroups(table.getHeaderGroups());
|
|
3472
|
-
const contextValue = (0,
|
|
3839
|
+
const contextValue = (0, import_react9.useMemo)(
|
|
3473
3840
|
() => ({ ...rowContextValue, classNames }),
|
|
3474
3841
|
[rowContextValue, classNames]
|
|
3475
3842
|
);
|
|
3476
3843
|
if (isPending) {
|
|
3477
|
-
return /* @__PURE__ */ (0,
|
|
3844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3478
3845
|
PendingSlot,
|
|
3479
3846
|
{
|
|
3480
3847
|
loadingText,
|
|
@@ -3483,7 +3850,7 @@ function DataTable({
|
|
|
3483
3850
|
}
|
|
3484
3851
|
);
|
|
3485
3852
|
}
|
|
3486
|
-
return /* @__PURE__ */ (0,
|
|
3853
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3487
3854
|
"div",
|
|
3488
3855
|
{
|
|
3489
3856
|
ref: rootRef,
|
|
@@ -3497,7 +3864,7 @@ function DataTable({
|
|
|
3497
3864
|
className
|
|
3498
3865
|
),
|
|
3499
3866
|
children: [
|
|
3500
|
-
/* @__PURE__ */ (0,
|
|
3867
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3501
3868
|
ToolbarSlot,
|
|
3502
3869
|
{
|
|
3503
3870
|
filteredCount: filteredCount ?? tableData.length,
|
|
@@ -3509,7 +3876,7 @@ function DataTable({
|
|
|
3509
3876
|
classNames
|
|
3510
3877
|
}
|
|
3511
3878
|
),
|
|
3512
|
-
enableInlineSearch ? /* @__PURE__ */ (0,
|
|
3879
|
+
enableInlineSearch ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3513
3880
|
DataTableSearch,
|
|
3514
3881
|
{
|
|
3515
3882
|
showSearch: inlineSearch.showSearch,
|
|
@@ -3531,14 +3898,14 @@ function DataTable({
|
|
|
3531
3898
|
onPrevious: inlineSearch.goToPrevious
|
|
3532
3899
|
}
|
|
3533
3900
|
) : null,
|
|
3534
|
-
/* @__PURE__ */ (0,
|
|
3901
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ScrollSlot, { scrollRef, className: classNames?.scroll, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3535
3902
|
"table",
|
|
3536
3903
|
{
|
|
3537
3904
|
className: cn("data-table", classNames?.table),
|
|
3538
3905
|
style: enableColumnResize ? { width: table.getTotalSize() } : void 0,
|
|
3539
3906
|
onDragStart: enableCellSelection ? (event) => event.preventDefault() : void 0,
|
|
3540
3907
|
children: [
|
|
3541
|
-
/* @__PURE__ */ (0,
|
|
3908
|
+
/* @__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
3909
|
"tr",
|
|
3543
3910
|
{
|
|
3544
3911
|
className: cn("data-table-head-row", classNames?.headRow),
|
|
@@ -3550,7 +3917,7 @@ function DataTable({
|
|
|
3550
3917
|
force: enableColumnResize,
|
|
3551
3918
|
lockMax: enableColumnResize
|
|
3552
3919
|
});
|
|
3553
|
-
const freezeOffset = enableColumnFreeze ?
|
|
3920
|
+
const freezeOffset = enableColumnFreeze ? resolveHeaderFreezeOffset(header.column, freezeOffsets) : void 0;
|
|
3554
3921
|
const freezeStyle = getColumnFreezeStyle(freezeOffset, {
|
|
3555
3922
|
isHeader: true,
|
|
3556
3923
|
headerTop: header.depth * DATA_TABLE_HEADER_ROW_HEIGHT
|
|
@@ -3559,7 +3926,7 @@ function DataTable({
|
|
|
3559
3926
|
...sizeStyle,
|
|
3560
3927
|
...freezeStyle
|
|
3561
3928
|
};
|
|
3562
|
-
return /* @__PURE__ */ (0,
|
|
3929
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3563
3930
|
"th",
|
|
3564
3931
|
{
|
|
3565
3932
|
colSpan: header.colSpan,
|
|
@@ -3576,8 +3943,11 @@ function DataTable({
|
|
|
3576
3943
|
headerClassName
|
|
3577
3944
|
),
|
|
3578
3945
|
children: [
|
|
3579
|
-
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
3580
|
-
|
|
3946
|
+
header.isPlaceholder ? null : (0, import_react_table3.flexRender)(
|
|
3947
|
+
header.column.columnDef.header,
|
|
3948
|
+
header.getContext()
|
|
3949
|
+
),
|
|
3950
|
+
canResize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3581
3951
|
"div",
|
|
3582
3952
|
{
|
|
3583
3953
|
role: "separator",
|
|
@@ -3603,20 +3973,20 @@ function DataTable({
|
|
|
3603
3973
|
},
|
|
3604
3974
|
headerGroup.id
|
|
3605
3975
|
)) }),
|
|
3606
|
-
/* @__PURE__ */ (0,
|
|
3976
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DataTableContextProvider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3607
3977
|
"tbody",
|
|
3608
3978
|
{
|
|
3609
3979
|
onMouseLeave: clearHover,
|
|
3610
3980
|
className: cn("data-table-body", classNames?.body),
|
|
3611
|
-
children: rows.length === 0 ? /* @__PURE__ */ (0,
|
|
3981
|
+
children: rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3612
3982
|
EmptySlot,
|
|
3613
3983
|
{
|
|
3614
3984
|
emptyText,
|
|
3615
3985
|
columnCount,
|
|
3616
3986
|
classNames
|
|
3617
3987
|
}
|
|
3618
|
-
) : shouldVirtualize ? /* @__PURE__ */ (0,
|
|
3619
|
-
paddingTop > 0 && /* @__PURE__ */ (0,
|
|
3988
|
+
) : shouldVirtualize ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
3989
|
+
paddingTop > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3620
3990
|
"tr",
|
|
3621
3991
|
{
|
|
3622
3992
|
"aria-hidden": true,
|
|
@@ -3624,7 +3994,7 @@ function DataTable({
|
|
|
3624
3994
|
"data-table-virtual-spacer",
|
|
3625
3995
|
classNames?.virtualSpacer
|
|
3626
3996
|
),
|
|
3627
|
-
children: /* @__PURE__ */ (0,
|
|
3997
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3628
3998
|
"td",
|
|
3629
3999
|
{
|
|
3630
4000
|
colSpan: columnCount,
|
|
@@ -3640,7 +4010,7 @@ function DataTable({
|
|
|
3640
4010
|
virtualRows.map((virtualRow) => {
|
|
3641
4011
|
const row = rows[virtualRow.index];
|
|
3642
4012
|
if (!row) return null;
|
|
3643
|
-
return /* @__PURE__ */ (0,
|
|
4013
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3644
4014
|
RowSlot,
|
|
3645
4015
|
{
|
|
3646
4016
|
row,
|
|
@@ -3651,7 +4021,7 @@ function DataTable({
|
|
|
3651
4021
|
row.id
|
|
3652
4022
|
);
|
|
3653
4023
|
}),
|
|
3654
|
-
paddingBottom > 0 && /* @__PURE__ */ (0,
|
|
4024
|
+
paddingBottom > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3655
4025
|
"tr",
|
|
3656
4026
|
{
|
|
3657
4027
|
"aria-hidden": true,
|
|
@@ -3659,7 +4029,7 @@ function DataTable({
|
|
|
3659
4029
|
"data-table-virtual-spacer",
|
|
3660
4030
|
classNames?.virtualSpacer
|
|
3661
4031
|
),
|
|
3662
|
-
children: /* @__PURE__ */ (0,
|
|
4032
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3663
4033
|
"td",
|
|
3664
4034
|
{
|
|
3665
4035
|
colSpan: columnCount,
|
|
@@ -3672,7 +4042,7 @@ function DataTable({
|
|
|
3672
4042
|
)
|
|
3673
4043
|
}
|
|
3674
4044
|
)
|
|
3675
|
-
] }) : rows.map((row) => /* @__PURE__ */ (0,
|
|
4045
|
+
] }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3676
4046
|
RowSlot,
|
|
3677
4047
|
{
|
|
3678
4048
|
row,
|
|
@@ -3691,10 +4061,10 @@ function DataTable({
|
|
|
3691
4061
|
}
|
|
3692
4062
|
|
|
3693
4063
|
// src/components/ui/table/components/Table/Table.tsx
|
|
3694
|
-
var
|
|
4064
|
+
var import_react12 = require("react");
|
|
3695
4065
|
|
|
3696
4066
|
// src/components/ui/table/components/Table/buildColumnDef.tsx
|
|
3697
|
-
var
|
|
4067
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3698
4068
|
function SortableHeader({
|
|
3699
4069
|
label,
|
|
3700
4070
|
field,
|
|
@@ -3703,15 +4073,18 @@ function SortableHeader({
|
|
|
3703
4073
|
}) {
|
|
3704
4074
|
const isActive = sort?.field === field;
|
|
3705
4075
|
const Icon = isActive ? sort.direction === "asc" ? ArrowUp : ArrowDown : ArrowUpDown;
|
|
3706
|
-
return /* @__PURE__ */ (0,
|
|
4076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
3707
4077
|
"button",
|
|
3708
4078
|
{
|
|
3709
4079
|
type: "button",
|
|
3710
|
-
className: cn(
|
|
4080
|
+
className: cn(
|
|
4081
|
+
"SortableHeaderJSX",
|
|
4082
|
+
isActive ? "is-active" : "is-inactive"
|
|
4083
|
+
),
|
|
3711
4084
|
onClick: () => onSort(field),
|
|
3712
4085
|
children: [
|
|
3713
|
-
/* @__PURE__ */ (0,
|
|
3714
|
-
/* @__PURE__ */ (0,
|
|
4086
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: label }),
|
|
4087
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { className: "sortable-header-icon" })
|
|
3715
4088
|
]
|
|
3716
4089
|
}
|
|
3717
4090
|
);
|
|
@@ -3733,6 +4106,8 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3733
4106
|
editable,
|
|
3734
4107
|
editType,
|
|
3735
4108
|
editInputProps,
|
|
4109
|
+
kind,
|
|
4110
|
+
cellProps,
|
|
3736
4111
|
className,
|
|
3737
4112
|
headerClassName,
|
|
3738
4113
|
render
|
|
@@ -3744,18 +4119,20 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3744
4119
|
...minWidth != null ? { minSize: minWidth } : {},
|
|
3745
4120
|
...maxWidth != null ? { maxSize: maxWidth } : {},
|
|
3746
4121
|
...resizable === false ? { enableResizing: false } : {},
|
|
3747
|
-
header: sortable ? () => /* @__PURE__ */ (0,
|
|
4122
|
+
header: sortable ? () => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4123
|
+
SortableHeader,
|
|
4124
|
+
{
|
|
4125
|
+
label: children,
|
|
4126
|
+
field,
|
|
4127
|
+
sort,
|
|
4128
|
+
onSort
|
|
4129
|
+
}
|
|
4130
|
+
) : (
|
|
3748
4131
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
3749
4132
|
() => children
|
|
3750
4133
|
),
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
cell: ({ row, getValue }) => render(
|
|
3754
|
-
getValue(),
|
|
3755
|
-
row,
|
|
3756
|
-
row.index
|
|
3757
|
-
)
|
|
3758
|
-
} : {},
|
|
4134
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4135
|
+
cell: (info) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ResolvedTableCell, { info }),
|
|
3759
4136
|
meta: {
|
|
3760
4137
|
align,
|
|
3761
4138
|
rowSpan,
|
|
@@ -3763,6 +4140,9 @@ function buildColumnDef(props, sort, onSort) {
|
|
|
3763
4140
|
editable,
|
|
3764
4141
|
editType,
|
|
3765
4142
|
editInputProps,
|
|
4143
|
+
kind,
|
|
4144
|
+
cellProps,
|
|
4145
|
+
cellRender: render,
|
|
3766
4146
|
frozen,
|
|
3767
4147
|
className,
|
|
3768
4148
|
headerClassName
|
|
@@ -3785,10 +4165,8 @@ function buildColumnDefsFromTree(nodes, sort, onSort) {
|
|
|
3785
4165
|
const { header, align, headerClassName } = node.props;
|
|
3786
4166
|
return {
|
|
3787
4167
|
id: resolveGroupId(node.props, index),
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
() => header
|
|
3791
|
-
),
|
|
4168
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
4169
|
+
header: () => header,
|
|
3792
4170
|
columns: childDefs,
|
|
3793
4171
|
enableResizing: false,
|
|
3794
4172
|
meta: {
|
|
@@ -3811,10 +4189,10 @@ function countLeafColumns(nodes) {
|
|
|
3811
4189
|
}
|
|
3812
4190
|
|
|
3813
4191
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
3814
|
-
var
|
|
4192
|
+
var import_react11 = require("react");
|
|
3815
4193
|
|
|
3816
4194
|
// src/components/ui/table/components/Table/tableChildTypes.ts
|
|
3817
|
-
var
|
|
4195
|
+
var import_react10 = require("react");
|
|
3818
4196
|
var TABLE_HEADER_DISPLAY_NAME = "Table.Header";
|
|
3819
4197
|
var TABLE_BODY_DISPLAY_NAME = "Table.Body";
|
|
3820
4198
|
var TABLE_COLUMN_DISPLAY_NAME = "Table.Column";
|
|
@@ -3827,19 +4205,19 @@ function getComponentDisplayName(type) {
|
|
|
3827
4205
|
return void 0;
|
|
3828
4206
|
}
|
|
3829
4207
|
function isTableHeaderElement(child) {
|
|
3830
|
-
return (0,
|
|
4208
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_HEADER_DISPLAY_NAME;
|
|
3831
4209
|
}
|
|
3832
4210
|
function isTableBodyElement(child) {
|
|
3833
|
-
return (0,
|
|
4211
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_BODY_DISPLAY_NAME;
|
|
3834
4212
|
}
|
|
3835
4213
|
function isTableColumnElement(child) {
|
|
3836
|
-
return (0,
|
|
4214
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_DISPLAY_NAME;
|
|
3837
4215
|
}
|
|
3838
4216
|
function isTableColumnGroupElement(child) {
|
|
3839
|
-
return (0,
|
|
4217
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_COLUMN_GROUP_DISPLAY_NAME;
|
|
3840
4218
|
}
|
|
3841
4219
|
function isTablePaginationElement(child) {
|
|
3842
|
-
return (0,
|
|
4220
|
+
return (0, import_react10.isValidElement)(child) && getComponentDisplayName(child.type) === TABLE_PAGINATION_DISPLAY_NAME;
|
|
3843
4221
|
}
|
|
3844
4222
|
|
|
3845
4223
|
// src/components/ui/table/components/Table/parseTableChildren.ts
|
|
@@ -3849,7 +4227,7 @@ function parseTableChildren(children) {
|
|
|
3849
4227
|
body: null,
|
|
3850
4228
|
pagination: null
|
|
3851
4229
|
};
|
|
3852
|
-
for (const child of
|
|
4230
|
+
for (const child of import_react11.Children.toArray(children)) {
|
|
3853
4231
|
if (isTableHeaderElement(child)) {
|
|
3854
4232
|
slots.header = child;
|
|
3855
4233
|
continue;
|
|
@@ -3866,7 +4244,7 @@ function parseTableChildren(children) {
|
|
|
3866
4244
|
}
|
|
3867
4245
|
function walkColumnTreeNodes(children) {
|
|
3868
4246
|
const result = [];
|
|
3869
|
-
for (const child of
|
|
4247
|
+
for (const child of import_react11.Children.toArray(children)) {
|
|
3870
4248
|
if (isTableColumnElement(child)) {
|
|
3871
4249
|
result.push({
|
|
3872
4250
|
type: "leaf",
|
|
@@ -3883,7 +4261,7 @@ function walkColumnTreeNodes(children) {
|
|
|
3883
4261
|
});
|
|
3884
4262
|
continue;
|
|
3885
4263
|
}
|
|
3886
|
-
if ((0,
|
|
4264
|
+
if ((0, import_react11.isValidElement)(child)) {
|
|
3887
4265
|
const nested = child.props.children;
|
|
3888
4266
|
if (nested != null) {
|
|
3889
4267
|
result.push(...walkColumnTreeNodes(nested));
|
|
@@ -3955,7 +4333,7 @@ function TableHeader(props) {
|
|
|
3955
4333
|
TableHeader.displayName = TABLE_HEADER_DISPLAY_NAME;
|
|
3956
4334
|
|
|
3957
4335
|
// src/components/ui/table/components/Table/TablePagination.tsx
|
|
3958
|
-
var
|
|
4336
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3959
4337
|
function TablePagination({
|
|
3960
4338
|
page,
|
|
3961
4339
|
pageSize = 10,
|
|
@@ -3967,8 +4345,8 @@ function TablePagination({
|
|
|
3967
4345
|
const safePage = Math.min(Math.max(1, page), totalPages);
|
|
3968
4346
|
const canGoPrev = safePage > 1;
|
|
3969
4347
|
const canGoNext = safePage < totalPages;
|
|
3970
|
-
return /* @__PURE__ */ (0,
|
|
3971
|
-
/* @__PURE__ */ (0,
|
|
4348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: cn("TablePaginationJSX", className), children: [
|
|
4349
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3972
4350
|
"button",
|
|
3973
4351
|
{
|
|
3974
4352
|
type: "button",
|
|
@@ -3976,15 +4354,15 @@ function TablePagination({
|
|
|
3976
4354
|
disabled: !canGoPrev,
|
|
3977
4355
|
onClick: () => onChange(safePage - 1),
|
|
3978
4356
|
"aria-label": "Previous page",
|
|
3979
|
-
children: /* @__PURE__ */ (0,
|
|
4357
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronLeft, { className: "pagination-button-icon" })
|
|
3980
4358
|
}
|
|
3981
4359
|
),
|
|
3982
|
-
/* @__PURE__ */ (0,
|
|
4360
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "pagination-label", children: [
|
|
3983
4361
|
safePage,
|
|
3984
4362
|
" / ",
|
|
3985
4363
|
totalPages
|
|
3986
4364
|
] }),
|
|
3987
|
-
/* @__PURE__ */ (0,
|
|
4365
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3988
4366
|
"button",
|
|
3989
4367
|
{
|
|
3990
4368
|
type: "button",
|
|
@@ -3992,7 +4370,7 @@ function TablePagination({
|
|
|
3992
4370
|
disabled: !canGoNext,
|
|
3993
4371
|
onClick: () => onChange(safePage + 1),
|
|
3994
4372
|
"aria-label": "Next page",
|
|
3995
|
-
children: /* @__PURE__ */ (0,
|
|
4373
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ChevronRight, { className: "pagination-button-icon" })
|
|
3996
4374
|
}
|
|
3997
4375
|
)
|
|
3998
4376
|
] });
|
|
@@ -4000,7 +4378,7 @@ function TablePagination({
|
|
|
4000
4378
|
TablePagination.displayName = TABLE_PAGINATION_DISPLAY_NAME;
|
|
4001
4379
|
|
|
4002
4380
|
// src/components/ui/table/components/Table/Table.tsx
|
|
4003
|
-
var
|
|
4381
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4004
4382
|
function TableRoot({
|
|
4005
4383
|
data,
|
|
4006
4384
|
children,
|
|
@@ -4009,12 +4387,12 @@ function TableRoot({
|
|
|
4009
4387
|
filteredCount,
|
|
4010
4388
|
...dataTableProps
|
|
4011
4389
|
}) {
|
|
4012
|
-
const { header, pagination: paginationElement } = (0,
|
|
4390
|
+
const { header, pagination: paginationElement } = (0, import_react12.useMemo)(
|
|
4013
4391
|
() => parseTableChildren(children),
|
|
4014
4392
|
[children]
|
|
4015
4393
|
);
|
|
4016
|
-
const [sort, setSort] = (0,
|
|
4017
|
-
const handleSort = (0,
|
|
4394
|
+
const [sort, setSort] = (0, import_react12.useState)(null);
|
|
4395
|
+
const handleSort = (0, import_react12.useCallback)((field) => {
|
|
4018
4396
|
setSort((previous) => {
|
|
4019
4397
|
if (previous?.field !== field) {
|
|
4020
4398
|
return { field, direction: "asc" };
|
|
@@ -4025,8 +4403,8 @@ function TableRoot({
|
|
|
4025
4403
|
return null;
|
|
4026
4404
|
});
|
|
4027
4405
|
}, []);
|
|
4028
|
-
const columnTree = (0,
|
|
4029
|
-
const columns = (0,
|
|
4406
|
+
const columnTree = (0, import_react12.useMemo)(() => extractColumnTree(header), [header]);
|
|
4407
|
+
const columns = (0, import_react12.useMemo)(
|
|
4030
4408
|
() => buildColumnDefsFromTree(columnTree, sort, handleSort),
|
|
4031
4409
|
[columnTree, sort, handleSort]
|
|
4032
4410
|
);
|
|
@@ -4034,7 +4412,7 @@ function TableRoot({
|
|
|
4034
4412
|
const pageSize = paginationProps?.pageSize ?? 10;
|
|
4035
4413
|
const page = paginationProps?.page ?? 1;
|
|
4036
4414
|
const resolvedTotalCount = paginationProps?.totalCount ?? totalCount ?? data.length;
|
|
4037
|
-
const tableData = (0,
|
|
4415
|
+
const tableData = (0, import_react12.useMemo)(() => {
|
|
4038
4416
|
const sortedData = sortTableData(data, sort);
|
|
4039
4417
|
if (!paginationProps) return sortedData;
|
|
4040
4418
|
return paginateTableData(sortedData, page, pageSize);
|
|
@@ -4042,8 +4420,8 @@ function TableRoot({
|
|
|
4042
4420
|
if (countLeafColumns(columnTree) === 0) {
|
|
4043
4421
|
console.warn("[Table] Declare at least one Table.Column inside Table.Header.");
|
|
4044
4422
|
}
|
|
4045
|
-
return /* @__PURE__ */ (0,
|
|
4046
|
-
/* @__PURE__ */ (0,
|
|
4423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "TableJSX", children: [
|
|
4424
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4047
4425
|
DataTable,
|
|
4048
4426
|
{
|
|
4049
4427
|
...dataTableProps,
|
|
@@ -4054,7 +4432,7 @@ function TableRoot({
|
|
|
4054
4432
|
className: cn(className, paginationProps && "DataTableJSX--with-pagination")
|
|
4055
4433
|
}
|
|
4056
4434
|
),
|
|
4057
|
-
paginationProps && /* @__PURE__ */ (0,
|
|
4435
|
+
paginationProps && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4058
4436
|
TablePagination,
|
|
4059
4437
|
{
|
|
4060
4438
|
page,
|
|
@@ -4079,7 +4457,7 @@ function createTable() {
|
|
|
4079
4457
|
ColumnGroup.displayName = TABLE_COLUMN_GROUP_DISPLAY_NAME;
|
|
4080
4458
|
return Object.assign(
|
|
4081
4459
|
function BoundTable(props) {
|
|
4082
|
-
return /* @__PURE__ */ (0,
|
|
4460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TableRoot, { ...props });
|
|
4083
4461
|
},
|
|
4084
4462
|
{
|
|
4085
4463
|
Header: TableHeader,
|
|
@@ -4099,6 +4477,7 @@ var Table = Object.assign(TableRoot, {
|
|
|
4099
4477
|
});
|
|
4100
4478
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4101
4479
|
0 && (module.exports = {
|
|
4480
|
+
BUILTIN_CELL_RENDERERS,
|
|
4102
4481
|
CELL_SELECTION_EDGES_CLASS,
|
|
4103
4482
|
DEFAULT_DATA_TABLE_LABELS,
|
|
4104
4483
|
DEFAULT_TREE_CHILDREN_FIELD,
|
|
@@ -4107,6 +4486,7 @@ var Table = Object.assign(TableRoot, {
|
|
|
4107
4486
|
DEFAULT_TREE_QTY_FIELD,
|
|
4108
4487
|
DataTable,
|
|
4109
4488
|
INLINE_SEARCH_MAX_RESULTS,
|
|
4489
|
+
ResolvedTableCell,
|
|
4110
4490
|
Table,
|
|
4111
4491
|
applyCellEdit,
|
|
4112
4492
|
applyFillData,
|
|
@@ -4126,10 +4506,14 @@ var Table = Object.assign(TableRoot, {
|
|
|
4126
4506
|
collectFillChanges,
|
|
4127
4507
|
collectRowSpanColumns,
|
|
4128
4508
|
collectSearchMatchesInRange,
|
|
4509
|
+
commitCellValue,
|
|
4510
|
+
createCellRendererRegistry,
|
|
4129
4511
|
createSearchRegex,
|
|
4130
4512
|
createTable,
|
|
4131
4513
|
escapeSearchRegex,
|
|
4132
4514
|
flattenSubtreeRows,
|
|
4515
|
+
formatCellValue,
|
|
4516
|
+
formatDefaultCellValue,
|
|
4133
4517
|
formatSearchResultLabel,
|
|
4134
4518
|
getCellEditDraftValue,
|
|
4135
4519
|
getCellSelectionEdgeStyle,
|
|
@@ -4151,8 +4535,10 @@ var Table = Object.assign(TableRoot, {
|
|
|
4151
4535
|
parseClipboardTSV,
|
|
4152
4536
|
parseClipboardTSVWithDepths,
|
|
4153
4537
|
previousSearchIndex,
|
|
4538
|
+
resolveCellRenderer,
|
|
4154
4539
|
resolveColumnFreezeSide,
|
|
4155
4540
|
resolveDataTableLabels,
|
|
4541
|
+
resolveHeaderFreezeOffset,
|
|
4156
4542
|
resolvePasteColumnIds,
|
|
4157
4543
|
resolveRowSelection,
|
|
4158
4544
|
resolveRowSpanAt,
|