@bmsuisse/datagrid 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +21 -1
- package/dist/index.js +194 -89
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -653,11 +653,24 @@ function toDate(value) {
|
|
|
653
653
|
}
|
|
654
654
|
return null;
|
|
655
655
|
}
|
|
656
|
+
var SWISS_CURRENCY_MARKER = /^(?:chf|s?fr\.?)\s+|\s+(?:chf|s?fr\.?)$/gi;
|
|
657
|
+
var SWISS_THOUSANDS_SEPARATOR = /(\d)['’](\d{3})/;
|
|
658
|
+
function stripSwissNumberFormatting(raw) {
|
|
659
|
+
const withoutCurrency = raw.replace(SWISS_CURRENCY_MARKER, "");
|
|
660
|
+
let stripped = withoutCurrency;
|
|
661
|
+
while (SWISS_THOUSANDS_SEPARATOR.test(stripped)) {
|
|
662
|
+
stripped = stripped.replace(SWISS_THOUSANDS_SEPARATOR, "$1$2");
|
|
663
|
+
}
|
|
664
|
+
return stripped;
|
|
665
|
+
}
|
|
656
666
|
function toNumber(value) {
|
|
657
667
|
if (typeof value === "number") return Number.isNaN(value) ? null : value;
|
|
658
668
|
if (typeof value === "string" && value.trim() !== "") {
|
|
659
|
-
const
|
|
660
|
-
|
|
669
|
+
const trimmed = value.trim();
|
|
670
|
+
const parsed = Number(trimmed);
|
|
671
|
+
if (!Number.isNaN(parsed)) return parsed;
|
|
672
|
+
const swiss = Number(stripSwissNumberFormatting(trimmed));
|
|
673
|
+
return Number.isNaN(swiss) ? null : swiss;
|
|
661
674
|
}
|
|
662
675
|
return null;
|
|
663
676
|
}
|
|
@@ -2169,6 +2182,8 @@ function useCellEditingState(cellEditing, getRowId) {
|
|
|
2169
2182
|
return override.value;
|
|
2170
2183
|
}
|
|
2171
2184
|
const ctx = cellEditing ? {
|
|
2185
|
+
alwaysEdit: cellEditing.alwaysEdit ?? false,
|
|
2186
|
+
disabled: cellEditing.disabled ?? false,
|
|
2172
2187
|
editingCell,
|
|
2173
2188
|
initialText,
|
|
2174
2189
|
hasDraft,
|
|
@@ -2182,6 +2197,7 @@ function useCellEditingState(cellEditing, getRowId) {
|
|
|
2182
2197
|
onCommitEdit,
|
|
2183
2198
|
onCommitValue,
|
|
2184
2199
|
onSetError,
|
|
2200
|
+
applyChange: (change) => applyChanges([change]),
|
|
2185
2201
|
consumeJustCommitted
|
|
2186
2202
|
} : void 0;
|
|
2187
2203
|
const ctxRef = useRef8(void 0);
|
|
@@ -2341,7 +2357,12 @@ function matchEnumOption(options, raw) {
|
|
|
2341
2357
|
const lowered = trimmed.toLowerCase();
|
|
2342
2358
|
return options.find((option) => option.label.toLowerCase() === lowered)?.value;
|
|
2343
2359
|
}
|
|
2360
|
+
var EXCEL_ERROR_STRINGS = /* @__PURE__ */ new Set(["#N/A", "#DIV/0!", "#REF!", "#VALUE!", "#NAME?", "#NULL!", "#NUM!", "#SPILL!", "#CALC!"]);
|
|
2361
|
+
function isExcelErrorString(raw) {
|
|
2362
|
+
return EXCEL_ERROR_STRINGS.has(raw.trim());
|
|
2363
|
+
}
|
|
2344
2364
|
function coerceValueForColumn(column, raw) {
|
|
2365
|
+
if (column.type !== "string" && isExcelErrorString(raw)) return void 0;
|
|
2345
2366
|
switch (column.type) {
|
|
2346
2367
|
case "string":
|
|
2347
2368
|
return { value: raw };
|
|
@@ -2400,7 +2421,8 @@ function rangeToTsv(range, rows, rowIds, columns, columnIds, getRowId) {
|
|
|
2400
2421
|
return lines.join("\n");
|
|
2401
2422
|
}
|
|
2402
2423
|
function parseTsv(text) {
|
|
2403
|
-
const
|
|
2424
|
+
const withoutBom = text.startsWith("\uFEFF") ? text.slice(1) : text;
|
|
2425
|
+
const normalized = withoutBom.replace(/\r\n/g, "\n");
|
|
2404
2426
|
const rows = [];
|
|
2405
2427
|
let row = [];
|
|
2406
2428
|
let field = "";
|
|
@@ -2770,12 +2792,69 @@ import { BarsArrowDownIcon, BarsArrowUpIcon, FunnelIcon as FunnelIcon7 } from "@
|
|
|
2770
2792
|
import { columnResizingFeature, columnSizingFeature, flexRender, tableFeatures, useTable } from "@tanstack/react-table";
|
|
2771
2793
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
2772
2794
|
import { ChevronRight, Loader2 } from "lucide-react";
|
|
2773
|
-
import { Fragment as Fragment3, useEffect as useEffect9, useMemo as useMemo8, useRef as useRef11, useState as
|
|
2795
|
+
import { Fragment as Fragment3, useEffect as useEffect9, useMemo as useMemo8, useRef as useRef11, useState as useState14 } from "react";
|
|
2796
|
+
|
|
2797
|
+
// src/cell-editing/renderAlwaysEditCell.tsx
|
|
2798
|
+
import { useState as useState10 } from "react";
|
|
2799
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
2800
|
+
function AlwaysEditCell(props) {
|
|
2801
|
+
const { column, row, rawValue, ctx } = props;
|
|
2802
|
+
const rowId = ctx.getRowId(row);
|
|
2803
|
+
const resolvedValue = ctx.resolveValue(rowId, column.id, rawValue);
|
|
2804
|
+
const [draft, setDraft] = useState10(void 0);
|
|
2805
|
+
if (!isEditable(column, row)) {
|
|
2806
|
+
return /* @__PURE__ */ jsx32("span", { "data-testid": `cell-${rowId}-${column.id}`, className: "block w-full", children: column.cell ? column.cell(resolvedValue, row) : defaultFormat(column, resolvedValue) });
|
|
2807
|
+
}
|
|
2808
|
+
const isAtomic = isAtomicEditorType(column.type);
|
|
2809
|
+
const error = ctx.getError(rowId, column.id);
|
|
2810
|
+
const draftIsFresh = draft !== void 0 && resolvedValue === draft.baseline;
|
|
2811
|
+
const currentValue = draftIsFresh ? draft.value : resolvedValue;
|
|
2812
|
+
function validate(candidate) {
|
|
2813
|
+
return column.validateEdit?.(candidate, row);
|
|
2814
|
+
}
|
|
2815
|
+
function commit(value) {
|
|
2816
|
+
ctx.applyChange({ rowId, row, columnId: column.id, previousValue: resolvedValue, value });
|
|
2817
|
+
setDraft(void 0);
|
|
2818
|
+
}
|
|
2819
|
+
const onChange = (next) => {
|
|
2820
|
+
const message = validate(next);
|
|
2821
|
+
ctx.onSetError(rowId, column.id, message);
|
|
2822
|
+
if (isAtomic && !message) {
|
|
2823
|
+
commit(next);
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
setDraft({ value: next, baseline: resolvedValue });
|
|
2827
|
+
};
|
|
2828
|
+
function handleKeyDown(event) {
|
|
2829
|
+
if (event.key === "Escape") {
|
|
2830
|
+
event.stopPropagation();
|
|
2831
|
+
ctx.onSetError(rowId, column.id, void 0);
|
|
2832
|
+
setDraft(void 0);
|
|
2833
|
+
return;
|
|
2834
|
+
}
|
|
2835
|
+
const isMultilineNewline = column.type === "string" && column.multiline && event.key === "Enter" && event.shiftKey;
|
|
2836
|
+
if (isMultilineNewline) return;
|
|
2837
|
+
if (isAtomic || event.key !== "Enter" && event.key !== "Tab") return;
|
|
2838
|
+
if (!draftIsFresh) return;
|
|
2839
|
+
const message = validate(draft.value);
|
|
2840
|
+
if (message) {
|
|
2841
|
+
event.stopPropagation();
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2844
|
+
commit(draft.value);
|
|
2845
|
+
}
|
|
2846
|
+
function handleBlur() {
|
|
2847
|
+
if (isAtomic || !draftIsFresh) return;
|
|
2848
|
+
if (validate(draft.value)) setDraft(void 0);
|
|
2849
|
+
else commit(draft.value);
|
|
2850
|
+
}
|
|
2851
|
+
return /* @__PURE__ */ jsx32("fieldset", { disabled: ctx.disabled, onKeyDown: handleKeyDown, onBlur: handleBlur, className: "contents", children: column.renderEditCell ? column.renderEditCell(currentValue, row, onChange, error, false) : renderDefaultEditWidget(column, rowId, currentValue, onChange, error, false) });
|
|
2852
|
+
}
|
|
2774
2853
|
|
|
2775
2854
|
// src/hooks/useGroupExpansion.ts
|
|
2776
|
-
import { useCallback as useCallback3, useState as
|
|
2855
|
+
import { useCallback as useCallback3, useState as useState11 } from "react";
|
|
2777
2856
|
function useGroupExpansion(defaultGroupsExpanded, controlledExpandedGroups, onExpandedGroupsChange) {
|
|
2778
|
-
const [internalExpandedGroups, setInternalExpandedGroups] =
|
|
2857
|
+
const [internalExpandedGroups, setInternalExpandedGroups] = useState11({});
|
|
2779
2858
|
const expandedGroups = controlledExpandedGroups ?? internalExpandedGroups;
|
|
2780
2859
|
const updateExpandedGroups = useCallback3(
|
|
2781
2860
|
(next) => {
|
|
@@ -2798,10 +2877,10 @@ function useGroupExpansion(defaultGroupsExpanded, controlledExpandedGroups, onEx
|
|
|
2798
2877
|
}
|
|
2799
2878
|
|
|
2800
2879
|
// src/hooks/useStickyGroupHeaderTop.ts
|
|
2801
|
-
import { useLayoutEffect as useLayoutEffect3, useRef as useRef9, useState as
|
|
2880
|
+
import { useLayoutEffect as useLayoutEffect3, useRef as useRef9, useState as useState12 } from "react";
|
|
2802
2881
|
function useStickyGroupHeaderTop(enabled) {
|
|
2803
2882
|
const theadRef = useRef9(null);
|
|
2804
|
-
const [groupHeaderTop, setGroupHeaderTop] =
|
|
2883
|
+
const [groupHeaderTop, setGroupHeaderTop] = useState12(0);
|
|
2805
2884
|
useLayoutEffect3(() => {
|
|
2806
2885
|
if (!enabled) return;
|
|
2807
2886
|
const theadEl = theadRef.current;
|
|
@@ -2865,7 +2944,7 @@ function processClientData(data, state) {
|
|
|
2865
2944
|
}
|
|
2866
2945
|
|
|
2867
2946
|
// src/grid/useGridState.ts
|
|
2868
|
-
import { useCallback as useCallback4, useEffect as useEffect8, useMemo as useMemo7, useState as
|
|
2947
|
+
import { useCallback as useCallback4, useEffect as useEffect8, useMemo as useMemo7, useState as useState13 } from "react";
|
|
2869
2948
|
|
|
2870
2949
|
// src/hooks/useDebouncedCallback.ts
|
|
2871
2950
|
import { useEffect as useEffect7, useMemo as useMemo6, useRef as useRef10 } from "react";
|
|
@@ -2903,7 +2982,7 @@ function nextSortDir(current, descFirst) {
|
|
|
2903
2982
|
return void 0;
|
|
2904
2983
|
}
|
|
2905
2984
|
function useGridState(dataSource, initialState, externalState) {
|
|
2906
|
-
const [state, setState] =
|
|
2985
|
+
const [state, setState] = useState13(
|
|
2907
2986
|
() => externalState ?? { ...DEFAULT_STATE, ...initialState }
|
|
2908
2987
|
);
|
|
2909
2988
|
const notifyRaw = useCallback4(
|
|
@@ -2992,12 +3071,16 @@ function useGridState(dataSource, initialState, externalState) {
|
|
|
2992
3071
|
}
|
|
2993
3072
|
|
|
2994
3073
|
// src/grid/DataGrid.tsx
|
|
2995
|
-
import { Fragment as Fragment4, jsx as
|
|
3074
|
+
import { Fragment as Fragment4, jsx as jsx33, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2996
3075
|
var gridTableFeatures = tableFeatures({ columnSizingFeature, columnResizingFeature });
|
|
2997
3076
|
var DEFAULT_COLUMN_SIZE = 150;
|
|
2998
3077
|
var DETAIL_COLUMN_WIDTH = 44;
|
|
2999
3078
|
var ROW_ACTIONS_COLUMN_WIDTH = 44;
|
|
3000
3079
|
var EMPTY_ID_ARRAY = [];
|
|
3080
|
+
function isNativeTextFieldTarget(event) {
|
|
3081
|
+
const tag = event.target?.tagName;
|
|
3082
|
+
return tag === "INPUT" || tag === "TEXTAREA";
|
|
3083
|
+
}
|
|
3001
3084
|
var STRUCTURAL_ZEBRA_BG_CLASS = "bg-[color-mix(in_srgb,var(--color-foreground)_5%,var(--color-background))]";
|
|
3002
3085
|
function pinnedOffsets(visibleColumns, side, getSize, leadingOffset) {
|
|
3003
3086
|
const offsets = /* @__PURE__ */ new Map();
|
|
@@ -3030,7 +3113,11 @@ function toTanstackColumns(columns, editingCtxRef, cellEditingCtxRef) {
|
|
|
3030
3113
|
header: column.header,
|
|
3031
3114
|
size: column.width,
|
|
3032
3115
|
accessorFn: (row) => getColumnValue(column, row),
|
|
3033
|
-
cell: (info) =>
|
|
3116
|
+
cell: (info) => {
|
|
3117
|
+
const cellEditingCtx = cellEditingCtxRef.current;
|
|
3118
|
+
if (!cellEditingCtx) return renderEditableCell(column, info.row.original, info.getValue(), editingCtxRef.current);
|
|
3119
|
+
return cellEditingCtx.alwaysEdit ? /* @__PURE__ */ jsx33(AlwaysEditCell, { column, row: info.row.original, rawValue: info.getValue(), ctx: cellEditingCtx }) : renderCellModeCell(column, info.row.original, info.getValue(), cellEditingCtx);
|
|
3120
|
+
}
|
|
3034
3121
|
}));
|
|
3035
3122
|
}
|
|
3036
3123
|
function DataGrid({
|
|
@@ -3071,19 +3158,19 @@ function DataGrid({
|
|
|
3071
3158
|
initialState,
|
|
3072
3159
|
gridState
|
|
3073
3160
|
);
|
|
3074
|
-
const [internalSelectedIds, setInternalSelectedIds] =
|
|
3161
|
+
const [internalSelectedIds, setInternalSelectedIds] = useState14(/* @__PURE__ */ new Set());
|
|
3075
3162
|
const selectedIds = controlledSelectedIds ?? internalSelectedIds;
|
|
3076
3163
|
function updateSelectedIds(next) {
|
|
3077
3164
|
setInternalSelectedIds(next);
|
|
3078
3165
|
onSelectedIdsChange?.(next);
|
|
3079
3166
|
}
|
|
3080
|
-
const [internalColumnSizing, setInternalColumnSizing] =
|
|
3167
|
+
const [internalColumnSizing, setInternalColumnSizing] = useState14({});
|
|
3081
3168
|
const columnSizing = controlledColumnSizing ?? internalColumnSizing;
|
|
3082
3169
|
function updateColumnSizing(next) {
|
|
3083
3170
|
setInternalColumnSizing(next);
|
|
3084
3171
|
onColumnSizingChange?.(next);
|
|
3085
3172
|
}
|
|
3086
|
-
const [expandedIds, setExpandedIds] =
|
|
3173
|
+
const [expandedIds, setExpandedIds] = useState14(/* @__PURE__ */ new Set());
|
|
3087
3174
|
function toggleRowExpanded(id) {
|
|
3088
3175
|
setExpandedIds((prev) => {
|
|
3089
3176
|
const next = new Set(prev);
|
|
@@ -3316,6 +3403,16 @@ function DataGrid({
|
|
|
3316
3403
|
if (index !== void 0) virtualizer.scrollToIndex(index);
|
|
3317
3404
|
}
|
|
3318
3405
|
});
|
|
3406
|
+
const clickCellRef = useRef11(null);
|
|
3407
|
+
const dragMovedRef = useRef11(false);
|
|
3408
|
+
function beginEditFromClick(cell) {
|
|
3409
|
+
if (!cellEditingCtx) return;
|
|
3410
|
+
if (cellEditingCtx.editingCell?.rowId === cell.rowId && cellEditingCtx.editingCell.columnId === cell.columnId) return;
|
|
3411
|
+
const column = columnById.get(cell.columnId);
|
|
3412
|
+
const row = findRowById(cell.rowId);
|
|
3413
|
+
if (!column || row === void 0 || !isEditable(column, row)) return;
|
|
3414
|
+
cellEditingCtx.onBeginEdit(cell);
|
|
3415
|
+
}
|
|
3319
3416
|
const pendingDragCellRef = useRef11(null);
|
|
3320
3417
|
const dragRafRef = useRef11(null);
|
|
3321
3418
|
useEffect9(() => {
|
|
@@ -3325,6 +3422,8 @@ function DataGrid({
|
|
|
3325
3422
|
const rowId = cellEl?.dataset.cellRow;
|
|
3326
3423
|
const columnId = cellEl?.dataset.cellCol;
|
|
3327
3424
|
if (rowId === void 0 || columnId === void 0) return;
|
|
3425
|
+
const anchor = clickCellRef.current;
|
|
3426
|
+
if (anchor && (rowId !== anchor.rowId || columnId !== anchor.columnId)) dragMovedRef.current = true;
|
|
3328
3427
|
pendingDragCellRef.current = { rowId, columnId };
|
|
3329
3428
|
if (dragRafRef.current !== null) return;
|
|
3330
3429
|
dragRafRef.current = requestAnimationFrame(() => {
|
|
@@ -3334,6 +3433,9 @@ function DataGrid({
|
|
|
3334
3433
|
}
|
|
3335
3434
|
function handleMouseUp() {
|
|
3336
3435
|
cellSelection.endDrag();
|
|
3436
|
+
const clickCell = clickCellRef.current;
|
|
3437
|
+
clickCellRef.current = null;
|
|
3438
|
+
if (clickCell && !clickCell.extend && !clickCell.wasEditing && !dragMovedRef.current) beginEditFromClick(clickCell);
|
|
3337
3439
|
}
|
|
3338
3440
|
window.addEventListener("mousemove", handleMouseMove);
|
|
3339
3441
|
window.addEventListener("mouseup", handleMouseUp);
|
|
@@ -3399,6 +3501,11 @@ function DataGrid({
|
|
|
3399
3501
|
const columnId = cellEl?.dataset.cellCol;
|
|
3400
3502
|
if (rowId === void 0 || columnId === void 0) return;
|
|
3401
3503
|
cellSelection.startSelection({ rowId, columnId }, { extend: event.shiftKey });
|
|
3504
|
+
if (cellEditingCtx?.alwaysEdit) return;
|
|
3505
|
+
const wasEditing = cellEditingCtx?.editingCell?.rowId === rowId && cellEditingCtx.editingCell.columnId === columnId;
|
|
3506
|
+
clickCellRef.current = { rowId, columnId, extend: event.shiftKey, wasEditing };
|
|
3507
|
+
dragMovedRef.current = false;
|
|
3508
|
+
if (wasEditing) return;
|
|
3402
3509
|
scrollRef.current?.focus();
|
|
3403
3510
|
}
|
|
3404
3511
|
const CELL_NAV_KEYS = {
|
|
@@ -3417,6 +3524,7 @@ function DataGrid({
|
|
|
3417
3524
|
}
|
|
3418
3525
|
function handleCellKeyDown(event) {
|
|
3419
3526
|
if (!hasCellEditing || !cellEditingCtx) return;
|
|
3527
|
+
if (cellEditingCtx.alwaysEdit) return;
|
|
3420
3528
|
if (cellEditingCtx.editingCell && !cellEditingCtx.consumeJustCommitted()) return;
|
|
3421
3529
|
const direction = CELL_NAV_KEYS[event.key];
|
|
3422
3530
|
if (direction) {
|
|
@@ -3445,18 +3553,15 @@ function DataGrid({
|
|
|
3445
3553
|
);
|
|
3446
3554
|
}
|
|
3447
3555
|
function handleCellDoubleClick(event) {
|
|
3448
|
-
if (!hasCellEditing || !cellEditingCtx) return;
|
|
3556
|
+
if (!hasCellEditing || !cellEditingCtx || cellEditingCtx.alwaysEdit) return;
|
|
3449
3557
|
const cellEl = event.target.closest("[data-cell-row]");
|
|
3450
3558
|
const rowId = cellEl?.dataset.cellRow;
|
|
3451
3559
|
const columnId = cellEl?.dataset.cellCol;
|
|
3452
3560
|
if (rowId === void 0 || columnId === void 0) return;
|
|
3453
|
-
|
|
3454
|
-
const row = findRowById(rowId);
|
|
3455
|
-
if (!column || row === void 0 || !isEditable(column, row)) return;
|
|
3456
|
-
cellEditingCtx.onBeginEdit({ rowId, columnId });
|
|
3561
|
+
beginEditFromClick({ rowId, columnId });
|
|
3457
3562
|
}
|
|
3458
3563
|
function handleCopy(event) {
|
|
3459
|
-
if (!hasCellEditing || !cellSelection.selection || cellEditingCtx?.editingCell) return;
|
|
3564
|
+
if (!hasCellEditing || !cellSelection.selection || cellEditingCtx?.editingCell || isNativeTextFieldTarget(event)) return;
|
|
3460
3565
|
event.preventDefault();
|
|
3461
3566
|
const text = rangeToTsv(cellSelection.selection, rows, cellEditingRowIds, visibleColumns, cellEditingColumnIds, getRowId);
|
|
3462
3567
|
event.clipboardData.setData("text/plain", text);
|
|
@@ -3473,7 +3578,7 @@ function DataGrid({
|
|
|
3473
3578
|
return { rowId, row: rowData, columnId, previousValue: getColumnValue(column, rowData), value: coerced.value };
|
|
3474
3579
|
}
|
|
3475
3580
|
function handlePaste(event) {
|
|
3476
|
-
if (!hasCellEditing || !cellSelection.selection || cellEditingCtx?.editingCell) return;
|
|
3581
|
+
if (!hasCellEditing || !cellSelection.selection || cellEditingCtx?.editingCell || isNativeTextFieldTarget(event)) return;
|
|
3477
3582
|
const text = event.clipboardData.getData("text/plain");
|
|
3478
3583
|
event.preventDefault();
|
|
3479
3584
|
const normalized = normalizeRange(cellSelection.selection, cellEditingRowIndex, buildIndexMap(cellEditingColumnIds));
|
|
@@ -3512,12 +3617,12 @@ function DataGrid({
|
|
|
3512
3617
|
"data-testid": rowTestId,
|
|
3513
3618
|
className: rowProps?.className ? cn("divide-x divide-border", rowProps.className, isOddRow && "bg-foreground/5") : `divide-x divide-border${isOddRow ? " bg-foreground/5" : ""}`,
|
|
3514
3619
|
children: [
|
|
3515
|
-
showDetailColumn && /* @__PURE__ */
|
|
3620
|
+
showDetailColumn && /* @__PURE__ */ jsx33(
|
|
3516
3621
|
"td",
|
|
3517
3622
|
{
|
|
3518
3623
|
className: isOddRow ? detailCellProps.classNameOdd : detailCellProps.className,
|
|
3519
3624
|
style: detailCellProps.style,
|
|
3520
|
-
children: /* @__PURE__ */
|
|
3625
|
+
children: /* @__PURE__ */ jsx33(
|
|
3521
3626
|
Button,
|
|
3522
3627
|
{
|
|
3523
3628
|
type: "button",
|
|
@@ -3529,7 +3634,7 @@ function DataGrid({
|
|
|
3529
3634
|
stopRowClick(event);
|
|
3530
3635
|
toggleRowExpanded(row.id);
|
|
3531
3636
|
},
|
|
3532
|
-
children: /* @__PURE__ */
|
|
3637
|
+
children: /* @__PURE__ */ jsx33(
|
|
3533
3638
|
ChevronRight,
|
|
3534
3639
|
{
|
|
3535
3640
|
className: `h-4 w-4 transition-transform${isExpanded ? " rotate-90" : ""}`,
|
|
@@ -3540,12 +3645,12 @@ function DataGrid({
|
|
|
3540
3645
|
)
|
|
3541
3646
|
}
|
|
3542
3647
|
),
|
|
3543
|
-
showSelectionColumn && /* @__PURE__ */
|
|
3648
|
+
showSelectionColumn && /* @__PURE__ */ jsx33(
|
|
3544
3649
|
"td",
|
|
3545
3650
|
{
|
|
3546
3651
|
className: isOddRow ? selectionCellProps.classNameOdd : selectionCellProps.className,
|
|
3547
3652
|
style: selectionCellProps.style,
|
|
3548
|
-
children: /* @__PURE__ */
|
|
3653
|
+
children: /* @__PURE__ */ jsx33(
|
|
3549
3654
|
"input",
|
|
3550
3655
|
{
|
|
3551
3656
|
type: "checkbox",
|
|
@@ -3559,7 +3664,7 @@ function DataGrid({
|
|
|
3559
3664
|
),
|
|
3560
3665
|
row.getAllCells().map((cell) => {
|
|
3561
3666
|
const cellProps = bodyCellPropsByColumn.get(cell.column.id);
|
|
3562
|
-
return /* @__PURE__ */
|
|
3667
|
+
return /* @__PURE__ */ jsx33(
|
|
3563
3668
|
"td",
|
|
3564
3669
|
{
|
|
3565
3670
|
style: cellProps?.style,
|
|
@@ -3571,23 +3676,23 @@ function DataGrid({
|
|
|
3571
3676
|
cell.id
|
|
3572
3677
|
);
|
|
3573
3678
|
}),
|
|
3574
|
-
showRowActionsColumn && rowActions && /* @__PURE__ */
|
|
3679
|
+
showRowActionsColumn && rowActions && /* @__PURE__ */ jsx33(
|
|
3575
3680
|
"td",
|
|
3576
3681
|
{
|
|
3577
3682
|
className: isOddRow ? rowActionsCellProps.classNameOdd : rowActionsCellProps.className,
|
|
3578
3683
|
style: rowActionsCellProps.style,
|
|
3579
|
-
children: /* @__PURE__ */
|
|
3684
|
+
children: /* @__PURE__ */ jsx33(ActionsMenu, { items: rowActions, ctx: { row: row.original }, triggerLabel: `Row actions for ${row.id}` })
|
|
3580
3685
|
}
|
|
3581
3686
|
)
|
|
3582
3687
|
]
|
|
3583
3688
|
}
|
|
3584
3689
|
),
|
|
3585
|
-
showDetailColumn && isExpanded && renderDetail && /* @__PURE__ */
|
|
3690
|
+
showDetailColumn && isExpanded && renderDetail && /* @__PURE__ */ jsx33("tr", { "data-testid": `${rowTestId}-detail`, children: /* @__PURE__ */ jsx33("td", { colSpan: totalColumnCount, className: "border-b border-border p-2", children: renderDetail(row.original) }) })
|
|
3586
3691
|
] }, row.id);
|
|
3587
3692
|
}
|
|
3588
3693
|
function renderGroupHeaderTbody(key, rows2, measureRef, dataIndex) {
|
|
3589
3694
|
const expanded = isGroupExpanded(key);
|
|
3590
|
-
return /* @__PURE__ */
|
|
3695
|
+
return /* @__PURE__ */ jsx33("tbody", { ref: measureRef, "data-index": dataIndex, children: /* @__PURE__ */ jsx33("tr", { "data-testid": `group-header-${key}`, children: /* @__PURE__ */ jsx33(
|
|
3591
3696
|
"td",
|
|
3592
3697
|
{
|
|
3593
3698
|
colSpan: totalColumnCount,
|
|
@@ -3601,7 +3706,7 @@ function DataGrid({
|
|
|
3601
3706
|
onClick: () => toggleGroupExpanded(key),
|
|
3602
3707
|
"aria-expanded": expanded,
|
|
3603
3708
|
children: [
|
|
3604
|
-
/* @__PURE__ */
|
|
3709
|
+
/* @__PURE__ */ jsx33(
|
|
3605
3710
|
ChevronRight,
|
|
3606
3711
|
{
|
|
3607
3712
|
className: `h-4 w-4 shrink-0 transition-transform${expanded ? " rotate-90" : ""}`,
|
|
@@ -3641,7 +3746,7 @@ function DataGrid({
|
|
|
3641
3746
|
// `overflow-x-auto` div scrolling horizontally) fighting over which one
|
|
3642
3747
|
// a sticky header/pinned column is actually stuck relative to.
|
|
3643
3748
|
/* @__PURE__ */ jsxs20("div", { className: "flex h-full min-h-0 flex-col gap-2", "data-testid": "datagrid", children: [
|
|
3644
|
-
editing && pendingEdits.size > 0 && /* @__PURE__ */
|
|
3749
|
+
editing && pendingEdits.size > 0 && /* @__PURE__ */ jsx33(
|
|
3645
3750
|
EditingBar,
|
|
3646
3751
|
{
|
|
3647
3752
|
editing,
|
|
@@ -3656,15 +3761,15 @@ function DataGrid({
|
|
|
3656
3761
|
selectedRows.length,
|
|
3657
3762
|
" selected"
|
|
3658
3763
|
] }),
|
|
3659
|
-
/* @__PURE__ */
|
|
3764
|
+
/* @__PURE__ */ jsx33(ActionsMenu, { items: headerActions, ctx: { selectedRows }, triggerLabel: "Bulk actions" })
|
|
3660
3765
|
] }),
|
|
3661
3766
|
/* @__PURE__ */ jsxs20("div", { className: "relative min-h-0 flex-1", children: [
|
|
3662
|
-
loading && /* @__PURE__ */
|
|
3767
|
+
loading && /* @__PURE__ */ jsx33(
|
|
3663
3768
|
"div",
|
|
3664
3769
|
{
|
|
3665
3770
|
"data-testid": "datagrid-loading-overlay",
|
|
3666
3771
|
className: "absolute inset-0 z-30 flex items-center justify-center bg-background/60",
|
|
3667
|
-
children: /* @__PURE__ */
|
|
3772
|
+
children: /* @__PURE__ */ jsx33(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground", "aria-hidden": true })
|
|
3668
3773
|
}
|
|
3669
3774
|
),
|
|
3670
3775
|
/* @__PURE__ */ jsxs20(
|
|
@@ -3703,8 +3808,8 @@ function DataGrid({
|
|
|
3703
3808
|
onClick: (event) => toggleSort(column.id, enableMultiSort && event.shiftKey, column.sortDescFirst === true),
|
|
3704
3809
|
children: [
|
|
3705
3810
|
headerContent,
|
|
3706
|
-
sortEntry?.dir === "asc" && /* @__PURE__ */
|
|
3707
|
-
sortEntry?.dir === "desc" && /* @__PURE__ */
|
|
3811
|
+
sortEntry?.dir === "asc" && /* @__PURE__ */ jsx33(BarsArrowUpIcon, { className: "h-3 w-3", "aria-hidden": true }),
|
|
3812
|
+
sortEntry?.dir === "desc" && /* @__PURE__ */ jsx33(BarsArrowDownIcon, { className: "h-3 w-3", "aria-hidden": true })
|
|
3708
3813
|
]
|
|
3709
3814
|
}
|
|
3710
3815
|
) : (
|
|
@@ -3713,10 +3818,10 @@ function DataGrid({
|
|
|
3713
3818
|
// silently breaking any interactive content a column's own `renderHeader`
|
|
3714
3819
|
// embeds directly (bare filter inputs, "select/reject all" buttons) —
|
|
3715
3820
|
// clicks never reach them at all, even though nothing looks wrong visually.
|
|
3716
|
-
/* @__PURE__ */
|
|
3821
|
+
/* @__PURE__ */ jsx33("div", { className: "flex items-center gap-1 px-1", children: headerContent })
|
|
3717
3822
|
),
|
|
3718
3823
|
filterable && /* @__PURE__ */ jsxs20(Popover, { children: [
|
|
3719
|
-
/* @__PURE__ */
|
|
3824
|
+
/* @__PURE__ */ jsx33(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx33(Button, { variant: "ghost", size: "icon", "aria-label": `Filter ${column.header}`, children: /* @__PURE__ */ jsx33(
|
|
3720
3825
|
FunnelIcon7,
|
|
3721
3826
|
{
|
|
3722
3827
|
className: cn(
|
|
@@ -3726,10 +3831,10 @@ function DataGrid({
|
|
|
3726
3831
|
"aria-hidden": true
|
|
3727
3832
|
}
|
|
3728
3833
|
) }) }),
|
|
3729
|
-
/* @__PURE__ */
|
|
3834
|
+
/* @__PURE__ */ jsx33(PopoverContent, { children: renderFilterWidget(column) })
|
|
3730
3835
|
] })
|
|
3731
3836
|
] }),
|
|
3732
|
-
enableColumnResizing && /* @__PURE__ */
|
|
3837
|
+
enableColumnResizing && /* @__PURE__ */ jsx33(
|
|
3733
3838
|
"div",
|
|
3734
3839
|
{
|
|
3735
3840
|
"data-testid": `resize-handle-${column.id}`,
|
|
@@ -3742,7 +3847,7 @@ function DataGrid({
|
|
|
3742
3847
|
}
|
|
3743
3848
|
return /* @__PURE__ */ jsxs20(Fragment3, { children: [
|
|
3744
3849
|
hasHeaderGroups && /* @__PURE__ */ jsxs20("tr", { "data-testid": "header-group-row", className: "divide-x divide-border", children: [
|
|
3745
|
-
showDetailColumn && /* @__PURE__ */
|
|
3850
|
+
showDetailColumn && /* @__PURE__ */ jsx33(
|
|
3746
3851
|
"th",
|
|
3747
3852
|
{
|
|
3748
3853
|
rowSpan: 2,
|
|
@@ -3751,13 +3856,13 @@ function DataGrid({
|
|
|
3751
3856
|
"aria-hidden": true
|
|
3752
3857
|
}
|
|
3753
3858
|
),
|
|
3754
|
-
showSelectionColumn && /* @__PURE__ */
|
|
3859
|
+
showSelectionColumn && /* @__PURE__ */ jsx33(
|
|
3755
3860
|
"th",
|
|
3756
3861
|
{
|
|
3757
3862
|
rowSpan: 2,
|
|
3758
3863
|
className: selectionHeaderCellProps.className,
|
|
3759
3864
|
style: selectionHeaderCellProps.style,
|
|
3760
|
-
children: /* @__PURE__ */
|
|
3865
|
+
children: /* @__PURE__ */ jsx33(
|
|
3761
3866
|
"input",
|
|
3762
3867
|
{
|
|
3763
3868
|
type: "checkbox",
|
|
@@ -3769,7 +3874,7 @@ function DataGrid({
|
|
|
3769
3874
|
}
|
|
3770
3875
|
),
|
|
3771
3876
|
headerRuns.map(
|
|
3772
|
-
(run) => run.kind === "single" ? renderLeafHeaderCell(run.column, 2) : /* @__PURE__ */
|
|
3877
|
+
(run) => run.kind === "single" ? renderLeafHeaderCell(run.column, 2) : /* @__PURE__ */ jsx33(
|
|
3773
3878
|
"th",
|
|
3774
3879
|
{
|
|
3775
3880
|
colSpan: run.columns.length,
|
|
@@ -3779,7 +3884,7 @@ function DataGrid({
|
|
|
3779
3884
|
`group-${run.label}-${run.columns[0].id}`
|
|
3780
3885
|
)
|
|
3781
3886
|
),
|
|
3782
|
-
showRowActionsColumn && /* @__PURE__ */
|
|
3887
|
+
showRowActionsColumn && /* @__PURE__ */ jsx33(
|
|
3783
3888
|
"th",
|
|
3784
3889
|
{
|
|
3785
3890
|
rowSpan: 2,
|
|
@@ -3790,7 +3895,7 @@ function DataGrid({
|
|
|
3790
3895
|
)
|
|
3791
3896
|
] }, `${headerGroup.id}-groups`),
|
|
3792
3897
|
/* @__PURE__ */ jsxs20("tr", { className: "divide-x divide-border", children: [
|
|
3793
|
-
!hasHeaderGroups && showDetailColumn && /* @__PURE__ */
|
|
3898
|
+
!hasHeaderGroups && showDetailColumn && /* @__PURE__ */ jsx33(
|
|
3794
3899
|
"th",
|
|
3795
3900
|
{
|
|
3796
3901
|
className: detailHeaderCellProps.className,
|
|
@@ -3798,12 +3903,12 @@ function DataGrid({
|
|
|
3798
3903
|
"aria-hidden": true
|
|
3799
3904
|
}
|
|
3800
3905
|
),
|
|
3801
|
-
!hasHeaderGroups && showSelectionColumn && /* @__PURE__ */
|
|
3906
|
+
!hasHeaderGroups && showSelectionColumn && /* @__PURE__ */ jsx33(
|
|
3802
3907
|
"th",
|
|
3803
3908
|
{
|
|
3804
3909
|
className: selectionHeaderCellProps.className,
|
|
3805
3910
|
style: selectionHeaderCellProps.style,
|
|
3806
|
-
children: /* @__PURE__ */
|
|
3911
|
+
children: /* @__PURE__ */ jsx33(
|
|
3807
3912
|
"input",
|
|
3808
3913
|
{
|
|
3809
3914
|
type: "checkbox",
|
|
@@ -3819,7 +3924,7 @@ function DataGrid({
|
|
|
3819
3924
|
if (!column || hasHeaderGroups && !column.headerGroup) return null;
|
|
3820
3925
|
return renderLeafHeaderCell(column);
|
|
3821
3926
|
}),
|
|
3822
|
-
!hasHeaderGroups && showRowActionsColumn && /* @__PURE__ */
|
|
3927
|
+
!hasHeaderGroups && showRowActionsColumn && /* @__PURE__ */ jsx33(
|
|
3823
3928
|
"th",
|
|
3824
3929
|
{
|
|
3825
3930
|
className: rowActionsHeaderCellProps.className,
|
|
@@ -3831,8 +3936,8 @@ function DataGrid({
|
|
|
3831
3936
|
] }, headerGroup.id);
|
|
3832
3937
|
}),
|
|
3833
3938
|
hasFilterRow && /* @__PURE__ */ jsxs20("tr", { "data-testid": "filter-row", className: "divide-x divide-border", children: [
|
|
3834
|
-
showDetailColumn && /* @__PURE__ */
|
|
3835
|
-
showSelectionColumn && /* @__PURE__ */
|
|
3939
|
+
showDetailColumn && /* @__PURE__ */ jsx33("th", { className: detailHeaderCellProps.className, style: detailHeaderCellProps.style }),
|
|
3940
|
+
showSelectionColumn && /* @__PURE__ */ jsx33(
|
|
3836
3941
|
"th",
|
|
3837
3942
|
{
|
|
3838
3943
|
className: selectionHeaderCellProps.className,
|
|
@@ -3841,9 +3946,9 @@ function DataGrid({
|
|
|
3841
3946
|
),
|
|
3842
3947
|
visibleColumns.map((column) => {
|
|
3843
3948
|
const cellProps = filterHeaderCellPropsByColumn.get(column.id);
|
|
3844
|
-
return /* @__PURE__ */
|
|
3949
|
+
return /* @__PURE__ */ jsx33("th", { style: cellProps?.style, className: cellProps?.className, children: isFilterable(column) && column.filterDisplay === "row" ? renderFilterWidget(column) : null }, column.id);
|
|
3845
3950
|
}),
|
|
3846
|
-
showRowActionsColumn && /* @__PURE__ */
|
|
3951
|
+
showRowActionsColumn && /* @__PURE__ */ jsx33(
|
|
3847
3952
|
"th",
|
|
3848
3953
|
{
|
|
3849
3954
|
className: rowActionsHeaderCellProps.className,
|
|
@@ -3852,8 +3957,8 @@ function DataGrid({
|
|
|
3852
3957
|
)
|
|
3853
3958
|
] })
|
|
3854
3959
|
] }),
|
|
3855
|
-
rows.length === 0 ? /* @__PURE__ */
|
|
3856
|
-
paddingTop > 0 && /* @__PURE__ */
|
|
3960
|
+
rows.length === 0 ? /* @__PURE__ */ jsx33("tbody", { children: /* @__PURE__ */ jsx33("tr", { children: /* @__PURE__ */ jsx33("td", { colSpan: totalColumnCount, className: "p-4 text-center text-muted-foreground", children: loading ? "Loading..." : "No results." }) }) }) : shouldVirtualize ? /* @__PURE__ */ jsxs20(Fragment4, { children: [
|
|
3961
|
+
paddingTop > 0 && /* @__PURE__ */ jsx33("tbody", { children: /* @__PURE__ */ jsx33("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx33("td", { colSpan: totalColumnCount, style: { padding: 0, border: "none", height: paddingTop } }) }) }),
|
|
3857
3962
|
virtualItems.map(
|
|
3858
3963
|
(virtualItem) => renderFlatItem(
|
|
3859
3964
|
flatItems[virtualItem.index],
|
|
@@ -3861,10 +3966,10 @@ function DataGrid({
|
|
|
3861
3966
|
(el) => virtualizer.measureElement(el)
|
|
3862
3967
|
)
|
|
3863
3968
|
),
|
|
3864
|
-
paddingBottom > 0 && /* @__PURE__ */
|
|
3969
|
+
paddingBottom > 0 && /* @__PURE__ */ jsx33("tbody", { children: /* @__PURE__ */ jsx33("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx33("td", { colSpan: totalColumnCount, style: { padding: 0, border: "none", height: paddingBottom } }) }) })
|
|
3865
3970
|
] }) : groupedBuckets ? groupedBuckets.map((bucket) => renderGroupedBucket(bucket)) : tableRows.map((row) => renderRow(row))
|
|
3866
3971
|
] }),
|
|
3867
|
-
hasCellEditing && /* @__PURE__ */
|
|
3972
|
+
hasCellEditing && /* @__PURE__ */ jsx33(
|
|
3868
3973
|
SelectionOverlay,
|
|
3869
3974
|
{
|
|
3870
3975
|
containerRef: scrollRef,
|
|
@@ -3890,7 +3995,7 @@ function DataGrid({
|
|
|
3890
3995
|
")"
|
|
3891
3996
|
] }),
|
|
3892
3997
|
/* @__PURE__ */ jsxs20("div", { className: "flex gap-2", children: [
|
|
3893
|
-
/* @__PURE__ */
|
|
3998
|
+
/* @__PURE__ */ jsx33(
|
|
3894
3999
|
Button,
|
|
3895
4000
|
{
|
|
3896
4001
|
variant: "outline",
|
|
@@ -3900,7 +4005,7 @@ function DataGrid({
|
|
|
3900
4005
|
children: "Previous"
|
|
3901
4006
|
}
|
|
3902
4007
|
),
|
|
3903
|
-
/* @__PURE__ */
|
|
4008
|
+
/* @__PURE__ */ jsx33(
|
|
3904
4009
|
Button,
|
|
3905
4010
|
{
|
|
3906
4011
|
variant: "outline",
|
|
@@ -3964,7 +4069,7 @@ function computeSelectionStates(roots, accessors, childrenOverride, selectedIds)
|
|
|
3964
4069
|
}
|
|
3965
4070
|
|
|
3966
4071
|
// src/tree/useTreeState.ts
|
|
3967
|
-
import { useCallback as useCallback5, useMemo as useMemo9, useState as
|
|
4072
|
+
import { useCallback as useCallback5, useMemo as useMemo9, useState as useState15 } from "react";
|
|
3968
4073
|
function useTreeState({
|
|
3969
4074
|
data,
|
|
3970
4075
|
getRowId,
|
|
@@ -3976,7 +4081,7 @@ function useTreeState({
|
|
|
3976
4081
|
childrenMap: controlledChildrenMap,
|
|
3977
4082
|
onChildrenMapChange
|
|
3978
4083
|
}) {
|
|
3979
|
-
const [internalExpanded, setInternalExpanded] =
|
|
4084
|
+
const [internalExpanded, setInternalExpanded] = useState15({});
|
|
3980
4085
|
const expanded = controlledExpanded ?? internalExpanded;
|
|
3981
4086
|
const setExpanded = useCallback5(
|
|
3982
4087
|
(updater) => {
|
|
@@ -3988,7 +4093,7 @@ function useTreeState({
|
|
|
3988
4093
|
},
|
|
3989
4094
|
[controlledExpanded, onExpandedChange]
|
|
3990
4095
|
);
|
|
3991
|
-
const [internalChildrenMap, setInternalChildrenMap] =
|
|
4096
|
+
const [internalChildrenMap, setInternalChildrenMap] = useState15(/* @__PURE__ */ new Map());
|
|
3992
4097
|
const childrenMap = controlledChildrenMap ?? internalChildrenMap;
|
|
3993
4098
|
const setChildrenMap = useCallback5(
|
|
3994
4099
|
(updater) => {
|
|
@@ -4000,8 +4105,8 @@ function useTreeState({
|
|
|
4000
4105
|
},
|
|
4001
4106
|
[controlledChildrenMap, onChildrenMapChange]
|
|
4002
4107
|
);
|
|
4003
|
-
const [loadingIds, setLoadingIds] =
|
|
4004
|
-
const [errorIds, setErrorIds] =
|
|
4108
|
+
const [loadingIds, setLoadingIds] = useState15(/* @__PURE__ */ new Set());
|
|
4109
|
+
const [errorIds, setErrorIds] = useState15(/* @__PURE__ */ new Map());
|
|
4005
4110
|
const resolveHasChildren = useMemo9(
|
|
4006
4111
|
() => hasChildren ?? ((row) => (getChildren(row)?.length ?? 0) > 0),
|
|
4007
4112
|
[hasChildren, getChildren]
|
|
@@ -4081,7 +4186,7 @@ function useTreeState({
|
|
|
4081
4186
|
}
|
|
4082
4187
|
|
|
4083
4188
|
// src/tree/TreeDataGrid.tsx
|
|
4084
|
-
import { Fragment as Fragment6, jsx as
|
|
4189
|
+
import { Fragment as Fragment6, jsx as jsx34, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4085
4190
|
var EMPTY_SELECTED_IDS = /* @__PURE__ */ new Set();
|
|
4086
4191
|
var UNCHECKED_STATE = { checked: false, indeterminate: false };
|
|
4087
4192
|
function renderCell(column, row, editingCtx) {
|
|
@@ -4098,7 +4203,7 @@ function TreeCell({
|
|
|
4098
4203
|
editingCtx
|
|
4099
4204
|
}) {
|
|
4100
4205
|
return /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-1", style: { paddingLeft: flatRow.depth * indentSize }, children: [
|
|
4101
|
-
flatRow.hasChildren ? /* @__PURE__ */
|
|
4206
|
+
flatRow.hasChildren ? /* @__PURE__ */ jsx34(
|
|
4102
4207
|
"button",
|
|
4103
4208
|
{
|
|
4104
4209
|
type: "button",
|
|
@@ -4110,14 +4215,14 @@ function TreeCell({
|
|
|
4110
4215
|
"aria-label": flatRow.isExpanded ? "Collapse" : "Expand",
|
|
4111
4216
|
"aria-expanded": flatRow.isExpanded,
|
|
4112
4217
|
className: "flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground hover:text-foreground disabled:opacity-50",
|
|
4113
|
-
children: isLoading ? /* @__PURE__ */
|
|
4218
|
+
children: isLoading ? /* @__PURE__ */ jsx34(Loader22, { className: "h-3.5 w-3.5 animate-spin", "aria-hidden": "true" }) : flatRow.isExpanded ? /* @__PURE__ */ jsx34(ChevronDown2, { className: "h-3.5 w-3.5", "aria-hidden": "true" }) : /* @__PURE__ */ jsx34(ChevronRight2, { className: "h-3.5 w-3.5", "aria-hidden": "true" })
|
|
4114
4219
|
}
|
|
4115
|
-
) : /* @__PURE__ */
|
|
4116
|
-
/* @__PURE__ */
|
|
4220
|
+
) : /* @__PURE__ */ jsx34("span", { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }),
|
|
4221
|
+
/* @__PURE__ */ jsx34("span", { className: "min-w-0 flex-1 truncate", children: renderCell(column, flatRow.row, editingCtx) }),
|
|
4117
4222
|
flatRow.isExpanded && error ? /* @__PURE__ */ jsxs21("span", { className: "ml-1 flex shrink-0 items-center gap-1 text-xs text-destructive", children: [
|
|
4118
|
-
/* @__PURE__ */
|
|
4223
|
+
/* @__PURE__ */ jsx34(AlertCircle, { className: "h-3 w-3", "aria-hidden": "true" }),
|
|
4119
4224
|
"Failed to load.",
|
|
4120
|
-
/* @__PURE__ */
|
|
4225
|
+
/* @__PURE__ */ jsx34("button", { type: "button", className: "underline underline-offset-2", onClick: onRetry, children: "Retry" })
|
|
4121
4226
|
] }) : null
|
|
4122
4227
|
] });
|
|
4123
4228
|
}
|
|
@@ -4272,9 +4377,9 @@ function TreeDataGrid({
|
|
|
4272
4377
|
isOddRow && "bg-foreground/5"
|
|
4273
4378
|
) : `border-b border-border divide-x divide-border${isOddRow ? " bg-foreground/5" : ""}`,
|
|
4274
4379
|
children: [
|
|
4275
|
-
showSelectionColumn && /* @__PURE__ */
|
|
4380
|
+
showSelectionColumn && /* @__PURE__ */ jsx34("td", { className: "p-1", style: { width: SELECTION_COLUMN_WIDTH }, children: (() => {
|
|
4276
4381
|
const state = resolveSelectionState(flatRow.row, flatRow.id);
|
|
4277
|
-
return /* @__PURE__ */
|
|
4382
|
+
return /* @__PURE__ */ jsx34(
|
|
4278
4383
|
Checkbox,
|
|
4279
4384
|
{
|
|
4280
4385
|
"aria-label": `Select row ${flatRow.id}`,
|
|
@@ -4285,7 +4390,7 @@ function TreeDataGrid({
|
|
|
4285
4390
|
}
|
|
4286
4391
|
);
|
|
4287
4392
|
})() }),
|
|
4288
|
-
visibleColumns.map((column) => /* @__PURE__ */
|
|
4393
|
+
visibleColumns.map((column) => /* @__PURE__ */ jsx34("td", { className: bodyTdClassByColumn.get(column.id), children: column.id === treeColId ? /* @__PURE__ */ jsx34(
|
|
4289
4394
|
TreeCell,
|
|
4290
4395
|
{
|
|
4291
4396
|
flatRow,
|
|
@@ -4298,7 +4403,7 @@ function TreeDataGrid({
|
|
|
4298
4403
|
editingCtx: editingState.ctx
|
|
4299
4404
|
}
|
|
4300
4405
|
) : renderCell(column, flatRow.row, editingState.ctx) }, column.id)),
|
|
4301
|
-
showRowActionsColumn && rowActions && /* @__PURE__ */
|
|
4406
|
+
showRowActionsColumn && rowActions && /* @__PURE__ */ jsx34("td", { className: "p-2", children: /* @__PURE__ */ jsx34(
|
|
4302
4407
|
ActionsMenu,
|
|
4303
4408
|
{
|
|
4304
4409
|
items: rowActions,
|
|
@@ -4315,7 +4420,7 @@ function TreeDataGrid({
|
|
|
4315
4420
|
const paddingTop = virtualItems.length > 0 ? virtualItems[0].start : 0;
|
|
4316
4421
|
const paddingBottom = virtualItems.length > 0 ? virtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end : 0;
|
|
4317
4422
|
return /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-2", "data-testid": "tree-datagrid", children: [
|
|
4318
|
-
editing && editingState.pendingEdits.size > 0 && /* @__PURE__ */
|
|
4423
|
+
editing && editingState.pendingEdits.size > 0 && /* @__PURE__ */ jsx34(
|
|
4319
4424
|
EditingBar,
|
|
4320
4425
|
{
|
|
4321
4426
|
editing,
|
|
@@ -4326,15 +4431,15 @@ function TreeDataGrid({
|
|
|
4326
4431
|
testIdPrefix: "tree-datagrid"
|
|
4327
4432
|
}
|
|
4328
4433
|
),
|
|
4329
|
-
/* @__PURE__ */
|
|
4434
|
+
/* @__PURE__ */ jsx34(
|
|
4330
4435
|
"div",
|
|
4331
4436
|
{
|
|
4332
4437
|
ref: scrollRef,
|
|
4333
4438
|
className: shouldVirtualize ? "overflow-y-auto" : void 0,
|
|
4334
4439
|
style: shouldVirtualize ? { maxHeight: maxBodyHeight } : void 0,
|
|
4335
4440
|
children: /* @__PURE__ */ jsxs21("table", { className: "w-full border-collapse text-sm", children: [
|
|
4336
|
-
/* @__PURE__ */
|
|
4337
|
-
showSelectionColumn && /* @__PURE__ */
|
|
4441
|
+
/* @__PURE__ */ jsx34("thead", { ref: theadRef, children: /* @__PURE__ */ jsxs21("tr", { className: "divide-x divide-border", children: [
|
|
4442
|
+
showSelectionColumn && /* @__PURE__ */ jsx34("th", { className: "border-b border-border p-1", style: { width: SELECTION_COLUMN_WIDTH }, children: /* @__PURE__ */ jsx34(
|
|
4338
4443
|
Checkbox,
|
|
4339
4444
|
{
|
|
4340
4445
|
"aria-label": "Select all visible rows",
|
|
@@ -4342,7 +4447,7 @@ function TreeDataGrid({
|
|
|
4342
4447
|
onCheckedChange: toggleAllVisibleSelected
|
|
4343
4448
|
}
|
|
4344
4449
|
) }),
|
|
4345
|
-
visibleColumns.map((column) => /* @__PURE__ */
|
|
4450
|
+
visibleColumns.map((column) => /* @__PURE__ */ jsx34(
|
|
4346
4451
|
"th",
|
|
4347
4452
|
{
|
|
4348
4453
|
style: column.width ? { width: column.width } : void 0,
|
|
@@ -4351,12 +4456,12 @@ function TreeDataGrid({
|
|
|
4351
4456
|
},
|
|
4352
4457
|
column.id
|
|
4353
4458
|
)),
|
|
4354
|
-
showRowActionsColumn && /* @__PURE__ */
|
|
4459
|
+
showRowActionsColumn && /* @__PURE__ */ jsx34("th", { className: "border-b border-border p-2", "aria-label": "Row actions" })
|
|
4355
4460
|
] }) }),
|
|
4356
|
-
/* @__PURE__ */
|
|
4461
|
+
/* @__PURE__ */ jsx34("tbody", { children: data.length === 0 ? /* @__PURE__ */ jsx34("tr", { children: /* @__PURE__ */ jsx34("td", { colSpan: totalColumnCount, className: "p-4 text-center text-muted-foreground", children: "No results." }) }) : groupedBuckets ? groupedBuckets.map((bucket) => {
|
|
4357
4462
|
const groupExpanded = isGroupExpanded(bucket.key);
|
|
4358
4463
|
return /* @__PURE__ */ jsxs21(Fragment5, { children: [
|
|
4359
|
-
/* @__PURE__ */
|
|
4464
|
+
/* @__PURE__ */ jsx34("tr", { "data-testid": `group-header-${bucket.key}`, children: /* @__PURE__ */ jsx34(
|
|
4360
4465
|
"td",
|
|
4361
4466
|
{
|
|
4362
4467
|
colSpan: totalColumnCount,
|
|
@@ -4373,7 +4478,7 @@ function TreeDataGrid({
|
|
|
4373
4478
|
onClick: () => toggleGroupExpanded(bucket.key),
|
|
4374
4479
|
"aria-expanded": groupExpanded,
|
|
4375
4480
|
children: [
|
|
4376
|
-
/* @__PURE__ */
|
|
4481
|
+
/* @__PURE__ */ jsx34(
|
|
4377
4482
|
ChevronRight2,
|
|
4378
4483
|
{
|
|
4379
4484
|
className: `h-4 w-4 shrink-0 transition-transform${groupExpanded ? " rotate-90" : ""}`,
|
|
@@ -4392,11 +4497,11 @@ function TreeDataGrid({
|
|
|
4392
4497
|
})()
|
|
4393
4498
|
] }, `group-${bucket.key}`);
|
|
4394
4499
|
}) : shouldVirtualize ? /* @__PURE__ */ jsxs21(Fragment6, { children: [
|
|
4395
|
-
paddingTop > 0 && /* @__PURE__ */
|
|
4500
|
+
paddingTop > 0 && /* @__PURE__ */ jsx34("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx34("td", { colSpan: totalColumnCount, style: { padding: 0, border: "none", height: paddingTop } }) }),
|
|
4396
4501
|
virtualItems.map(
|
|
4397
4502
|
(virtualItem) => renderRow(flatRows[virtualItem.index], virtualItem.index, (el) => virtualizer.measureElement(el))
|
|
4398
4503
|
),
|
|
4399
|
-
paddingBottom > 0 && /* @__PURE__ */
|
|
4504
|
+
paddingBottom > 0 && /* @__PURE__ */ jsx34("tr", { "aria-hidden": "true", children: /* @__PURE__ */ jsx34(
|
|
4400
4505
|
"td",
|
|
4401
4506
|
{
|
|
4402
4507
|
colSpan: totalColumnCount,
|