@dmsi/wedgekit-react 0.0.179 → 0.0.181
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/components/index.cjs +162 -148
- package/dist/components/index.js +156 -142
- package/package.json +1 -1
- package/src/components/DataGrid/PinnedColumns.tsx +130 -112
- package/src/components/DataGrid/index.tsx +4 -13
|
@@ -2206,7 +2206,7 @@ function getSortIcon(sort, nextSort = false) {
|
|
|
2206
2206
|
}
|
|
2207
2207
|
|
|
2208
2208
|
// src/components/DataGrid/PinnedColumns.tsx
|
|
2209
|
-
var
|
|
2209
|
+
var import_react14 = __toESM(require("react"), 1);
|
|
2210
2210
|
|
|
2211
2211
|
// src/components/DataGrid/TableBody/index.tsx
|
|
2212
2212
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
@@ -2474,139 +2474,21 @@ function TableBody({
|
|
|
2474
2474
|
);
|
|
2475
2475
|
}
|
|
2476
2476
|
|
|
2477
|
-
// src/components/DataGrid/PinnedColumns.tsx
|
|
2478
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2479
|
-
function PinnedColumns(_a) {
|
|
2480
|
-
var _b = _a, {
|
|
2481
|
-
pinDirection = "left",
|
|
2482
|
-
table,
|
|
2483
|
-
centerHeader,
|
|
2484
|
-
allSelectedAcrossPages,
|
|
2485
|
-
someSelectedAcrossPages,
|
|
2486
|
-
toggleSelectAllAcrossPages,
|
|
2487
|
-
testid
|
|
2488
|
-
} = _b, props = __objRest(_b, [
|
|
2489
|
-
"pinDirection",
|
|
2490
|
-
"table",
|
|
2491
|
-
"centerHeader",
|
|
2492
|
-
"allSelectedAcrossPages",
|
|
2493
|
-
"someSelectedAcrossPages",
|
|
2494
|
-
"toggleSelectAllAcrossPages",
|
|
2495
|
-
"testid"
|
|
2496
|
-
]);
|
|
2497
|
-
var _a2;
|
|
2498
|
-
const headerGroups = pinDirection === "left" ? table.getLeftHeaderGroups() : table.getRightHeaderGroups();
|
|
2499
|
-
const pinnedTestId = testid ? `${pinDirection}-pinned-${testid}` : void 0;
|
|
2500
|
-
return ((_a2 = headerGroups[0]) == null ? void 0 : _a2.headers.length) > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2501
|
-
"table",
|
|
2502
|
-
{
|
|
2503
|
-
className: (0, import_clsx12.default)(
|
|
2504
|
-
"flex flex-col min-h-min sticky z-20",
|
|
2505
|
-
pinDirection === "left" ? "left-0" : "right-0"
|
|
2506
|
-
),
|
|
2507
|
-
"data-testid": pinnedTestId,
|
|
2508
|
-
children: [
|
|
2509
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("thead", { className: "sticky top-0 z-20 grid", children: headerGroups.map((headerGroup) => {
|
|
2510
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2511
|
-
"tr",
|
|
2512
|
-
{
|
|
2513
|
-
"data-testid": pinnedTestId ? `${pinnedTestId}-header-row-${headerGroup.id}` : void 0,
|
|
2514
|
-
className: "flex w-full",
|
|
2515
|
-
children: headerGroup.headers.map((header) => {
|
|
2516
|
-
var _a3, _b2, _c, _d;
|
|
2517
|
-
if (!header) {
|
|
2518
|
-
return;
|
|
2519
|
-
}
|
|
2520
|
-
if (typeof header.column.columnDef.header === "string") {
|
|
2521
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2522
|
-
DataCellHeader,
|
|
2523
|
-
{
|
|
2524
|
-
locked: true,
|
|
2525
|
-
testid: pinnedTestId ? `${pinnedTestId}-header-${header.id}` : void 0,
|
|
2526
|
-
header,
|
|
2527
|
-
center: centerHeader,
|
|
2528
|
-
width: (_b2 = (_a3 = header.column.columnDef.meta) == null ? void 0 : _a3.headerWidth) != null ? _b2 : `${header.column.getSize()}px`,
|
|
2529
|
-
className: (0, import_clsx12.default)(
|
|
2530
|
-
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
2531
|
-
"group"
|
|
2532
|
-
),
|
|
2533
|
-
children: [
|
|
2534
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Subheader, { tall: true, children: header.column.columnDef.header }),
|
|
2535
|
-
getSortIcon(header.column.getIsSorted()),
|
|
2536
|
-
!header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
|
|
2537
|
-
header.column.getNextSortingOrder(),
|
|
2538
|
-
true
|
|
2539
|
-
),
|
|
2540
|
-
header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
|
|
2541
|
-
!((_c = header.column.columnDef.meta) == null ? void 0 : _c.locked) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2542
|
-
"div",
|
|
2543
|
-
{
|
|
2544
|
-
onDoubleClick: (e) => {
|
|
2545
|
-
e.stopPropagation();
|
|
2546
|
-
header.column.resetSize();
|
|
2547
|
-
},
|
|
2548
|
-
onMouseDown: (e) => {
|
|
2549
|
-
e.stopPropagation();
|
|
2550
|
-
header.getResizeHandler()(e);
|
|
2551
|
-
},
|
|
2552
|
-
onTouchStart: (e) => {
|
|
2553
|
-
e.stopPropagation();
|
|
2554
|
-
header.getResizeHandler()(e);
|
|
2555
|
-
},
|
|
2556
|
-
className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
2557
|
-
}
|
|
2558
|
-
)
|
|
2559
|
-
]
|
|
2560
|
-
},
|
|
2561
|
-
header.id
|
|
2562
|
-
);
|
|
2563
|
-
}
|
|
2564
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react12.default.Fragment, { children: ((_d = header.column.columnDef.meta) == null ? void 0 : _d.checkbox) ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DataGridCell, { type: "header", component: "checkbox", locked: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2565
|
-
Checkbox,
|
|
2566
|
-
{
|
|
2567
|
-
checked: allSelectedAcrossPages,
|
|
2568
|
-
indeterminate: someSelectedAcrossPages,
|
|
2569
|
-
onChange: toggleSelectAllAcrossPages
|
|
2570
|
-
}
|
|
2571
|
-
) }) : (0, import_react_table2.flexRender)(
|
|
2572
|
-
header.column.columnDef.header,
|
|
2573
|
-
header.getContext()
|
|
2574
|
-
) }, header.id);
|
|
2575
|
-
})
|
|
2576
|
-
},
|
|
2577
|
-
headerGroup.id
|
|
2578
|
-
);
|
|
2579
|
-
}) }),
|
|
2580
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2581
|
-
TableBody,
|
|
2582
|
-
__spreadProps(__spreadValues({
|
|
2583
|
-
testid: pinnedTestId
|
|
2584
|
-
}, props), {
|
|
2585
|
-
table,
|
|
2586
|
-
locked: true,
|
|
2587
|
-
pinDirection
|
|
2588
|
-
})
|
|
2589
|
-
)
|
|
2590
|
-
]
|
|
2591
|
-
}
|
|
2592
|
-
);
|
|
2593
|
-
}
|
|
2594
|
-
|
|
2595
2477
|
// src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx
|
|
2596
|
-
var
|
|
2478
|
+
var import_react13 = require("react");
|
|
2597
2479
|
|
|
2598
2480
|
// src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx
|
|
2599
|
-
var
|
|
2600
|
-
var
|
|
2481
|
+
var import_react12 = require("react");
|
|
2482
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2601
2483
|
function ColumnSelectorMenuOption({
|
|
2602
2484
|
id,
|
|
2603
2485
|
testid,
|
|
2604
2486
|
column,
|
|
2605
2487
|
toggleColumnVisibility
|
|
2606
2488
|
}) {
|
|
2607
|
-
const [isVisible, setIsVisible] = (0,
|
|
2489
|
+
const [isVisible, setIsVisible] = (0, import_react12.useState)(column.getIsVisible());
|
|
2608
2490
|
const label = typeof column.columnDef.header === "string" ? column.columnDef.header : null;
|
|
2609
|
-
return /* @__PURE__ */ (0,
|
|
2491
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MenuOption, { id, testid, selected: isVisible, defaultChecked: isVisible, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2610
2492
|
Checkbox,
|
|
2611
2493
|
{
|
|
2612
2494
|
id: id ? `${id}-checkbox` : void 0,
|
|
@@ -2622,7 +2504,7 @@ function ColumnSelectorMenuOption({
|
|
|
2622
2504
|
}
|
|
2623
2505
|
|
|
2624
2506
|
// src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx
|
|
2625
|
-
var
|
|
2507
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2626
2508
|
function ColumnSelectorHeaderCell({
|
|
2627
2509
|
id,
|
|
2628
2510
|
testid,
|
|
@@ -2630,9 +2512,9 @@ function ColumnSelectorHeaderCell({
|
|
|
2630
2512
|
toggleColumnVisibility,
|
|
2631
2513
|
resetColumnVisibility
|
|
2632
2514
|
}) {
|
|
2633
|
-
const ref = (0,
|
|
2634
|
-
const [show, setShow] = (0,
|
|
2635
|
-
return /* @__PURE__ */ (0,
|
|
2515
|
+
const ref = (0, import_react13.useRef)(null);
|
|
2516
|
+
const [show, setShow] = (0, import_react13.useState)(false);
|
|
2517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2636
2518
|
DataGridCell,
|
|
2637
2519
|
{
|
|
2638
2520
|
id,
|
|
@@ -2642,7 +2524,7 @@ function ColumnSelectorHeaderCell({
|
|
|
2642
2524
|
color: "text-secondary-normal",
|
|
2643
2525
|
ref,
|
|
2644
2526
|
children: [
|
|
2645
|
-
/* @__PURE__ */ (0,
|
|
2527
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2646
2528
|
Button,
|
|
2647
2529
|
{
|
|
2648
2530
|
id: id ? `${id}-button` : void 0,
|
|
@@ -2650,10 +2532,10 @@ function ColumnSelectorHeaderCell({
|
|
|
2650
2532
|
onClick: () => setShow((prev) => !prev),
|
|
2651
2533
|
variant: "navigation",
|
|
2652
2534
|
iconOnly: true,
|
|
2653
|
-
leftIcon: /* @__PURE__ */ (0,
|
|
2535
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Icon, { name: "tune" })
|
|
2654
2536
|
}
|
|
2655
2537
|
),
|
|
2656
|
-
/* @__PURE__ */ (0,
|
|
2538
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2657
2539
|
Menu,
|
|
2658
2540
|
{
|
|
2659
2541
|
id: id ? `${id}-menu` : void 0,
|
|
@@ -2664,7 +2546,7 @@ function ColumnSelectorHeaderCell({
|
|
|
2664
2546
|
setShow,
|
|
2665
2547
|
calculateMinMaxHeight: true,
|
|
2666
2548
|
children: [
|
|
2667
|
-
/* @__PURE__ */ (0,
|
|
2549
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2668
2550
|
Button,
|
|
2669
2551
|
{
|
|
2670
2552
|
id: id ? `${id}-reset-button` : void 0,
|
|
@@ -2680,7 +2562,7 @@ function ColumnSelectorHeaderCell({
|
|
|
2680
2562
|
table.getAllColumns().filter((x) => {
|
|
2681
2563
|
var _a;
|
|
2682
2564
|
return (_a = x.columnDef.meta) == null ? void 0 : _a.inVisibilityMenu;
|
|
2683
|
-
}).map((column) => /* @__PURE__ */ (0,
|
|
2565
|
+
}).map((column) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
2684
2566
|
ColumnSelectorMenuOption,
|
|
2685
2567
|
{
|
|
2686
2568
|
id: id ? `${id}-option-${column.id}` : void 0,
|
|
@@ -2698,6 +2580,146 @@ function ColumnSelectorHeaderCell({
|
|
|
2698
2580
|
);
|
|
2699
2581
|
}
|
|
2700
2582
|
|
|
2583
|
+
// src/components/DataGrid/PinnedColumns.tsx
|
|
2584
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2585
|
+
function PinnedColumns(_a) {
|
|
2586
|
+
var _b = _a, {
|
|
2587
|
+
id,
|
|
2588
|
+
pinDirection = "left",
|
|
2589
|
+
table,
|
|
2590
|
+
centerHeader,
|
|
2591
|
+
allSelectedAcrossPages,
|
|
2592
|
+
someSelectedAcrossPages,
|
|
2593
|
+
toggleSelectAllAcrossPages,
|
|
2594
|
+
testid,
|
|
2595
|
+
enableColumnSelector,
|
|
2596
|
+
toggleColumnVisibility,
|
|
2597
|
+
resetColumnVisibility
|
|
2598
|
+
} = _b, props = __objRest(_b, [
|
|
2599
|
+
"id",
|
|
2600
|
+
"pinDirection",
|
|
2601
|
+
"table",
|
|
2602
|
+
"centerHeader",
|
|
2603
|
+
"allSelectedAcrossPages",
|
|
2604
|
+
"someSelectedAcrossPages",
|
|
2605
|
+
"toggleSelectAllAcrossPages",
|
|
2606
|
+
"testid",
|
|
2607
|
+
"enableColumnSelector",
|
|
2608
|
+
"toggleColumnVisibility",
|
|
2609
|
+
"resetColumnVisibility"
|
|
2610
|
+
]);
|
|
2611
|
+
var _a2;
|
|
2612
|
+
const headerGroups = pinDirection === "left" ? table.getLeftHeaderGroups() : table.getRightHeaderGroups();
|
|
2613
|
+
const pinnedTestId = testid ? `${pinDirection}-pinned-${testid}` : void 0;
|
|
2614
|
+
const hasAnyHeaders = ((_a2 = headerGroups[0]) == null ? void 0 : _a2.headers.length) > 0;
|
|
2615
|
+
if (!hasAnyHeaders && !enableColumnSelector) return;
|
|
2616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2617
|
+
"table",
|
|
2618
|
+
{
|
|
2619
|
+
className: (0, import_clsx12.default)(
|
|
2620
|
+
"flex flex-col min-h-min sticky z-20",
|
|
2621
|
+
pinDirection === "left" ? "left-0" : "right-0"
|
|
2622
|
+
),
|
|
2623
|
+
"data-testid": pinnedTestId,
|
|
2624
|
+
children: [
|
|
2625
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("thead", { className: "sticky top-0 z-20 grid", children: headerGroups.map((headerGroup) => {
|
|
2626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2627
|
+
"tr",
|
|
2628
|
+
{
|
|
2629
|
+
"data-testid": pinnedTestId ? `${pinnedTestId}-header-row-${headerGroup.id}` : void 0,
|
|
2630
|
+
className: "flex w-full",
|
|
2631
|
+
children: [
|
|
2632
|
+
headerGroup.headers.map((header) => {
|
|
2633
|
+
var _a3, _b2, _c;
|
|
2634
|
+
if (!header) {
|
|
2635
|
+
return;
|
|
2636
|
+
}
|
|
2637
|
+
if (typeof header.column.columnDef.header === "string") {
|
|
2638
|
+
const customHeaderWidth = (_a3 = header.column.columnDef.meta) == null ? void 0 : _a3.headerWidth;
|
|
2639
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
2640
|
+
DataCellHeader,
|
|
2641
|
+
{
|
|
2642
|
+
locked: true,
|
|
2643
|
+
testid: pinnedTestId ? `${pinnedTestId}-header-${header.id}` : void 0,
|
|
2644
|
+
header,
|
|
2645
|
+
center: centerHeader,
|
|
2646
|
+
width: customHeaderWidth,
|
|
2647
|
+
className: (0, import_clsx12.default)(
|
|
2648
|
+
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
2649
|
+
"group"
|
|
2650
|
+
),
|
|
2651
|
+
children: [
|
|
2652
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Subheader, { tall: true, children: header.column.columnDef.header }),
|
|
2653
|
+
getSortIcon(header.column.getIsSorted()),
|
|
2654
|
+
!header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(header.column.getNextSortingOrder(), true),
|
|
2655
|
+
header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
|
|
2656
|
+
!((_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2657
|
+
"div",
|
|
2658
|
+
{
|
|
2659
|
+
onDoubleClick: (e) => {
|
|
2660
|
+
e.stopPropagation();
|
|
2661
|
+
header.column.resetSize();
|
|
2662
|
+
},
|
|
2663
|
+
onMouseDown: (e) => {
|
|
2664
|
+
e.stopPropagation();
|
|
2665
|
+
header.getResizeHandler()(e);
|
|
2666
|
+
},
|
|
2667
|
+
onTouchStart: (e) => {
|
|
2668
|
+
e.stopPropagation();
|
|
2669
|
+
header.getResizeHandler()(e);
|
|
2670
|
+
},
|
|
2671
|
+
className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
2672
|
+
}
|
|
2673
|
+
)
|
|
2674
|
+
]
|
|
2675
|
+
},
|
|
2676
|
+
header.id
|
|
2677
|
+
);
|
|
2678
|
+
}
|
|
2679
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react14.default.Fragment, { children: ((_c = header.column.columnDef.meta) == null ? void 0 : _c.checkbox) ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DataGridCell, { type: "header", component: "checkbox", locked: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2680
|
+
Checkbox,
|
|
2681
|
+
{
|
|
2682
|
+
checked: allSelectedAcrossPages,
|
|
2683
|
+
indeterminate: someSelectedAcrossPages,
|
|
2684
|
+
onChange: toggleSelectAllAcrossPages
|
|
2685
|
+
}
|
|
2686
|
+
) }) : (0, import_react_table2.flexRender)(
|
|
2687
|
+
header.column.columnDef.header,
|
|
2688
|
+
header.getContext()
|
|
2689
|
+
) }, header.id);
|
|
2690
|
+
}),
|
|
2691
|
+
enableColumnSelector && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2692
|
+
ColumnSelectorHeaderCell,
|
|
2693
|
+
{
|
|
2694
|
+
id: id ? `${id}-column-selector` : void 0,
|
|
2695
|
+
testid: testid ? `${testid}-column-selector` : void 0,
|
|
2696
|
+
table,
|
|
2697
|
+
toggleColumnVisibility: toggleColumnVisibility != null ? toggleColumnVisibility : () => {
|
|
2698
|
+
},
|
|
2699
|
+
resetColumnVisibility: resetColumnVisibility != null ? resetColumnVisibility : () => {
|
|
2700
|
+
}
|
|
2701
|
+
}
|
|
2702
|
+
)
|
|
2703
|
+
]
|
|
2704
|
+
},
|
|
2705
|
+
headerGroup.id
|
|
2706
|
+
);
|
|
2707
|
+
}) }),
|
|
2708
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2709
|
+
TableBody,
|
|
2710
|
+
__spreadProps(__spreadValues({
|
|
2711
|
+
testid: pinnedTestId
|
|
2712
|
+
}, props), {
|
|
2713
|
+
table,
|
|
2714
|
+
locked: true,
|
|
2715
|
+
pinDirection
|
|
2716
|
+
})
|
|
2717
|
+
)
|
|
2718
|
+
]
|
|
2719
|
+
}
|
|
2720
|
+
);
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2701
2723
|
// src/components/DataGrid/index.tsx
|
|
2702
2724
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2703
2725
|
var PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 30, 35];
|
|
@@ -2933,8 +2955,7 @@ function DataGrid({
|
|
|
2933
2955
|
pagination,
|
|
2934
2956
|
isLoadingMore,
|
|
2935
2957
|
hasMore,
|
|
2936
|
-
showFilterRow
|
|
2937
|
-
enableColumnSelector
|
|
2958
|
+
showFilterRow
|
|
2938
2959
|
}
|
|
2939
2960
|
),
|
|
2940
2961
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("table", { className: "flex-1 flex flex-col min-h-min", children: [
|
|
@@ -3043,17 +3064,7 @@ function DataGrid({
|
|
|
3043
3064
|
style: { display: "flex", width: virtualPaddingRight }
|
|
3044
3065
|
}
|
|
3045
3066
|
)
|
|
3046
|
-
) : null
|
|
3047
|
-
enableColumnSelector && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3048
|
-
ColumnSelectorHeaderCell,
|
|
3049
|
-
{
|
|
3050
|
-
id: id ? `${id}-column-selector` : void 0,
|
|
3051
|
-
testid: testid ? `${testid}-column-selector` : void 0,
|
|
3052
|
-
table,
|
|
3053
|
-
toggleColumnVisibility,
|
|
3054
|
-
resetColumnVisibility
|
|
3055
|
-
}
|
|
3056
|
-
)
|
|
3067
|
+
) : null
|
|
3057
3068
|
]
|
|
3058
3069
|
},
|
|
3059
3070
|
headerGroup.id
|
|
@@ -3079,6 +3090,10 @@ function DataGrid({
|
|
|
3079
3090
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3080
3091
|
PinnedColumns,
|
|
3081
3092
|
{
|
|
3093
|
+
id,
|
|
3094
|
+
enableColumnSelector,
|
|
3095
|
+
toggleColumnVisibility,
|
|
3096
|
+
resetColumnVisibility,
|
|
3082
3097
|
testid,
|
|
3083
3098
|
pinDirection: "right",
|
|
3084
3099
|
table,
|
|
@@ -3086,8 +3101,7 @@ function DataGrid({
|
|
|
3086
3101
|
pagination,
|
|
3087
3102
|
isLoadingMore,
|
|
3088
3103
|
hasMore,
|
|
3089
|
-
showFilterRow
|
|
3090
|
-
enableColumnSelector
|
|
3104
|
+
showFilterRow
|
|
3091
3105
|
}
|
|
3092
3106
|
)
|
|
3093
3107
|
]
|
package/dist/components/index.js
CHANGED
|
@@ -379,130 +379,12 @@ function TableBody({
|
|
|
379
379
|
);
|
|
380
380
|
}
|
|
381
381
|
|
|
382
|
-
// src/components/DataGrid/PinnedColumns.tsx
|
|
383
|
-
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
384
|
-
function PinnedColumns(_a) {
|
|
385
|
-
var _b = _a, {
|
|
386
|
-
pinDirection = "left",
|
|
387
|
-
table,
|
|
388
|
-
centerHeader,
|
|
389
|
-
allSelectedAcrossPages,
|
|
390
|
-
someSelectedAcrossPages,
|
|
391
|
-
toggleSelectAllAcrossPages,
|
|
392
|
-
testid
|
|
393
|
-
} = _b, props = __objRest(_b, [
|
|
394
|
-
"pinDirection",
|
|
395
|
-
"table",
|
|
396
|
-
"centerHeader",
|
|
397
|
-
"allSelectedAcrossPages",
|
|
398
|
-
"someSelectedAcrossPages",
|
|
399
|
-
"toggleSelectAllAcrossPages",
|
|
400
|
-
"testid"
|
|
401
|
-
]);
|
|
402
|
-
var _a2;
|
|
403
|
-
const headerGroups = pinDirection === "left" ? table.getLeftHeaderGroups() : table.getRightHeaderGroups();
|
|
404
|
-
const pinnedTestId = testid ? `${pinDirection}-pinned-${testid}` : void 0;
|
|
405
|
-
return ((_a2 = headerGroups[0]) == null ? void 0 : _a2.headers.length) > 0 && /* @__PURE__ */ jsxs3(
|
|
406
|
-
"table",
|
|
407
|
-
{
|
|
408
|
-
className: clsx4(
|
|
409
|
-
"flex flex-col min-h-min sticky z-20",
|
|
410
|
-
pinDirection === "left" ? "left-0" : "right-0"
|
|
411
|
-
),
|
|
412
|
-
"data-testid": pinnedTestId,
|
|
413
|
-
children: [
|
|
414
|
-
/* @__PURE__ */ jsx5("thead", { className: "sticky top-0 z-20 grid", children: headerGroups.map((headerGroup) => {
|
|
415
|
-
return /* @__PURE__ */ jsx5(
|
|
416
|
-
"tr",
|
|
417
|
-
{
|
|
418
|
-
"data-testid": pinnedTestId ? `${pinnedTestId}-header-row-${headerGroup.id}` : void 0,
|
|
419
|
-
className: "flex w-full",
|
|
420
|
-
children: headerGroup.headers.map((header) => {
|
|
421
|
-
var _a3, _b2, _c, _d;
|
|
422
|
-
if (!header) {
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
if (typeof header.column.columnDef.header === "string") {
|
|
426
|
-
return /* @__PURE__ */ jsxs3(
|
|
427
|
-
DataCellHeader,
|
|
428
|
-
{
|
|
429
|
-
locked: true,
|
|
430
|
-
testid: pinnedTestId ? `${pinnedTestId}-header-${header.id}` : void 0,
|
|
431
|
-
header,
|
|
432
|
-
center: centerHeader,
|
|
433
|
-
width: (_b2 = (_a3 = header.column.columnDef.meta) == null ? void 0 : _a3.headerWidth) != null ? _b2 : `${header.column.getSize()}px`,
|
|
434
|
-
className: clsx4(
|
|
435
|
-
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
436
|
-
"group"
|
|
437
|
-
),
|
|
438
|
-
children: [
|
|
439
|
-
/* @__PURE__ */ jsx5(Subheader, { tall: true, children: header.column.columnDef.header }),
|
|
440
|
-
getSortIcon(header.column.getIsSorted()),
|
|
441
|
-
!header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(
|
|
442
|
-
header.column.getNextSortingOrder(),
|
|
443
|
-
true
|
|
444
|
-
),
|
|
445
|
-
header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ jsx5(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
|
|
446
|
-
!((_c = header.column.columnDef.meta) == null ? void 0 : _c.locked) && /* @__PURE__ */ jsx5(
|
|
447
|
-
"div",
|
|
448
|
-
{
|
|
449
|
-
onDoubleClick: (e) => {
|
|
450
|
-
e.stopPropagation();
|
|
451
|
-
header.column.resetSize();
|
|
452
|
-
},
|
|
453
|
-
onMouseDown: (e) => {
|
|
454
|
-
e.stopPropagation();
|
|
455
|
-
header.getResizeHandler()(e);
|
|
456
|
-
},
|
|
457
|
-
onTouchStart: (e) => {
|
|
458
|
-
e.stopPropagation();
|
|
459
|
-
header.getResizeHandler()(e);
|
|
460
|
-
},
|
|
461
|
-
className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
462
|
-
}
|
|
463
|
-
)
|
|
464
|
-
]
|
|
465
|
-
},
|
|
466
|
-
header.id
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
return /* @__PURE__ */ jsx5(React2.Fragment, { children: ((_d = header.column.columnDef.meta) == null ? void 0 : _d.checkbox) ? /* @__PURE__ */ jsx5(DataGridCell, { type: "header", component: "checkbox", locked: true, children: /* @__PURE__ */ jsx5(
|
|
470
|
-
Checkbox,
|
|
471
|
-
{
|
|
472
|
-
checked: allSelectedAcrossPages,
|
|
473
|
-
indeterminate: someSelectedAcrossPages,
|
|
474
|
-
onChange: toggleSelectAllAcrossPages
|
|
475
|
-
}
|
|
476
|
-
) }) : flexRender2(
|
|
477
|
-
header.column.columnDef.header,
|
|
478
|
-
header.getContext()
|
|
479
|
-
) }, header.id);
|
|
480
|
-
})
|
|
481
|
-
},
|
|
482
|
-
headerGroup.id
|
|
483
|
-
);
|
|
484
|
-
}) }),
|
|
485
|
-
/* @__PURE__ */ jsx5(
|
|
486
|
-
TableBody,
|
|
487
|
-
__spreadProps(__spreadValues({
|
|
488
|
-
testid: pinnedTestId
|
|
489
|
-
}, props), {
|
|
490
|
-
table,
|
|
491
|
-
locked: true,
|
|
492
|
-
pinDirection
|
|
493
|
-
})
|
|
494
|
-
)
|
|
495
|
-
]
|
|
496
|
-
}
|
|
497
|
-
);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
382
|
// src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx
|
|
501
383
|
import { useRef, useState as useState2 } from "react";
|
|
502
384
|
|
|
503
385
|
// src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx
|
|
504
386
|
import { useState } from "react";
|
|
505
|
-
import { jsx as
|
|
387
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
506
388
|
function ColumnSelectorMenuOption({
|
|
507
389
|
id,
|
|
508
390
|
testid,
|
|
@@ -511,7 +393,7 @@ function ColumnSelectorMenuOption({
|
|
|
511
393
|
}) {
|
|
512
394
|
const [isVisible, setIsVisible] = useState(column.getIsVisible());
|
|
513
395
|
const label = typeof column.columnDef.header === "string" ? column.columnDef.header : null;
|
|
514
|
-
return /* @__PURE__ */
|
|
396
|
+
return /* @__PURE__ */ jsx5(MenuOption, { id, testid, selected: isVisible, defaultChecked: isVisible, children: /* @__PURE__ */ jsx5(
|
|
515
397
|
Checkbox,
|
|
516
398
|
{
|
|
517
399
|
id: id ? `${id}-checkbox` : void 0,
|
|
@@ -527,7 +409,7 @@ function ColumnSelectorMenuOption({
|
|
|
527
409
|
}
|
|
528
410
|
|
|
529
411
|
// src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx
|
|
530
|
-
import { jsx as
|
|
412
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
531
413
|
function ColumnSelectorHeaderCell({
|
|
532
414
|
id,
|
|
533
415
|
testid,
|
|
@@ -537,7 +419,7 @@ function ColumnSelectorHeaderCell({
|
|
|
537
419
|
}) {
|
|
538
420
|
const ref = useRef(null);
|
|
539
421
|
const [show, setShow] = useState2(false);
|
|
540
|
-
return /* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ jsxs3(
|
|
541
423
|
DataGridCell,
|
|
542
424
|
{
|
|
543
425
|
id,
|
|
@@ -547,7 +429,7 @@ function ColumnSelectorHeaderCell({
|
|
|
547
429
|
color: "text-secondary-normal",
|
|
548
430
|
ref,
|
|
549
431
|
children: [
|
|
550
|
-
/* @__PURE__ */
|
|
432
|
+
/* @__PURE__ */ jsx6(
|
|
551
433
|
Button,
|
|
552
434
|
{
|
|
553
435
|
id: id ? `${id}-button` : void 0,
|
|
@@ -555,10 +437,10 @@ function ColumnSelectorHeaderCell({
|
|
|
555
437
|
onClick: () => setShow((prev) => !prev),
|
|
556
438
|
variant: "navigation",
|
|
557
439
|
iconOnly: true,
|
|
558
|
-
leftIcon: /* @__PURE__ */
|
|
440
|
+
leftIcon: /* @__PURE__ */ jsx6(Icon, { name: "tune" })
|
|
559
441
|
}
|
|
560
442
|
),
|
|
561
|
-
/* @__PURE__ */
|
|
443
|
+
/* @__PURE__ */ jsxs3(
|
|
562
444
|
Menu,
|
|
563
445
|
{
|
|
564
446
|
id: id ? `${id}-menu` : void 0,
|
|
@@ -569,7 +451,7 @@ function ColumnSelectorHeaderCell({
|
|
|
569
451
|
setShow,
|
|
570
452
|
calculateMinMaxHeight: true,
|
|
571
453
|
children: [
|
|
572
|
-
/* @__PURE__ */
|
|
454
|
+
/* @__PURE__ */ jsx6(
|
|
573
455
|
Button,
|
|
574
456
|
{
|
|
575
457
|
id: id ? `${id}-reset-button` : void 0,
|
|
@@ -585,7 +467,7 @@ function ColumnSelectorHeaderCell({
|
|
|
585
467
|
table.getAllColumns().filter((x) => {
|
|
586
468
|
var _a;
|
|
587
469
|
return (_a = x.columnDef.meta) == null ? void 0 : _a.inVisibilityMenu;
|
|
588
|
-
}).map((column) => /* @__PURE__ */
|
|
470
|
+
}).map((column) => /* @__PURE__ */ jsx6(
|
|
589
471
|
ColumnSelectorMenuOption,
|
|
590
472
|
{
|
|
591
473
|
id: id ? `${id}-option-${column.id}` : void 0,
|
|
@@ -603,6 +485,146 @@ function ColumnSelectorHeaderCell({
|
|
|
603
485
|
);
|
|
604
486
|
}
|
|
605
487
|
|
|
488
|
+
// src/components/DataGrid/PinnedColumns.tsx
|
|
489
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
490
|
+
function PinnedColumns(_a) {
|
|
491
|
+
var _b = _a, {
|
|
492
|
+
id,
|
|
493
|
+
pinDirection = "left",
|
|
494
|
+
table,
|
|
495
|
+
centerHeader,
|
|
496
|
+
allSelectedAcrossPages,
|
|
497
|
+
someSelectedAcrossPages,
|
|
498
|
+
toggleSelectAllAcrossPages,
|
|
499
|
+
testid,
|
|
500
|
+
enableColumnSelector,
|
|
501
|
+
toggleColumnVisibility,
|
|
502
|
+
resetColumnVisibility
|
|
503
|
+
} = _b, props = __objRest(_b, [
|
|
504
|
+
"id",
|
|
505
|
+
"pinDirection",
|
|
506
|
+
"table",
|
|
507
|
+
"centerHeader",
|
|
508
|
+
"allSelectedAcrossPages",
|
|
509
|
+
"someSelectedAcrossPages",
|
|
510
|
+
"toggleSelectAllAcrossPages",
|
|
511
|
+
"testid",
|
|
512
|
+
"enableColumnSelector",
|
|
513
|
+
"toggleColumnVisibility",
|
|
514
|
+
"resetColumnVisibility"
|
|
515
|
+
]);
|
|
516
|
+
var _a2;
|
|
517
|
+
const headerGroups = pinDirection === "left" ? table.getLeftHeaderGroups() : table.getRightHeaderGroups();
|
|
518
|
+
const pinnedTestId = testid ? `${pinDirection}-pinned-${testid}` : void 0;
|
|
519
|
+
const hasAnyHeaders = ((_a2 = headerGroups[0]) == null ? void 0 : _a2.headers.length) > 0;
|
|
520
|
+
if (!hasAnyHeaders && !enableColumnSelector) return;
|
|
521
|
+
return /* @__PURE__ */ jsxs4(
|
|
522
|
+
"table",
|
|
523
|
+
{
|
|
524
|
+
className: clsx4(
|
|
525
|
+
"flex flex-col min-h-min sticky z-20",
|
|
526
|
+
pinDirection === "left" ? "left-0" : "right-0"
|
|
527
|
+
),
|
|
528
|
+
"data-testid": pinnedTestId,
|
|
529
|
+
children: [
|
|
530
|
+
/* @__PURE__ */ jsx7("thead", { className: "sticky top-0 z-20 grid", children: headerGroups.map((headerGroup) => {
|
|
531
|
+
return /* @__PURE__ */ jsxs4(
|
|
532
|
+
"tr",
|
|
533
|
+
{
|
|
534
|
+
"data-testid": pinnedTestId ? `${pinnedTestId}-header-row-${headerGroup.id}` : void 0,
|
|
535
|
+
className: "flex w-full",
|
|
536
|
+
children: [
|
|
537
|
+
headerGroup.headers.map((header) => {
|
|
538
|
+
var _a3, _b2, _c;
|
|
539
|
+
if (!header) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
if (typeof header.column.columnDef.header === "string") {
|
|
543
|
+
const customHeaderWidth = (_a3 = header.column.columnDef.meta) == null ? void 0 : _a3.headerWidth;
|
|
544
|
+
return /* @__PURE__ */ jsxs4(
|
|
545
|
+
DataCellHeader,
|
|
546
|
+
{
|
|
547
|
+
locked: true,
|
|
548
|
+
testid: pinnedTestId ? `${pinnedTestId}-header-${header.id}` : void 0,
|
|
549
|
+
header,
|
|
550
|
+
center: centerHeader,
|
|
551
|
+
width: customHeaderWidth,
|
|
552
|
+
className: clsx4(
|
|
553
|
+
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
554
|
+
"group"
|
|
555
|
+
),
|
|
556
|
+
children: [
|
|
557
|
+
/* @__PURE__ */ jsx7(Subheader, { tall: true, children: header.column.columnDef.header }),
|
|
558
|
+
getSortIcon(header.column.getIsSorted()),
|
|
559
|
+
!header.column.getIsSorted() && header.column.getCanSort() && getSortIcon(header.column.getNextSortingOrder(), true),
|
|
560
|
+
header.column.getSortIndex() !== -1 && table.getState().sorting.length > 1 && /* @__PURE__ */ jsx7(Subheader, { tall: true, children: header.column.getSortIndex() + 1 }),
|
|
561
|
+
!((_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked) && /* @__PURE__ */ jsx7(
|
|
562
|
+
"div",
|
|
563
|
+
{
|
|
564
|
+
onDoubleClick: (e) => {
|
|
565
|
+
e.stopPropagation();
|
|
566
|
+
header.column.resetSize();
|
|
567
|
+
},
|
|
568
|
+
onMouseDown: (e) => {
|
|
569
|
+
e.stopPropagation();
|
|
570
|
+
header.getResizeHandler()(e);
|
|
571
|
+
},
|
|
572
|
+
onTouchStart: (e) => {
|
|
573
|
+
e.stopPropagation();
|
|
574
|
+
header.getResizeHandler()(e);
|
|
575
|
+
},
|
|
576
|
+
className: "absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
577
|
+
}
|
|
578
|
+
)
|
|
579
|
+
]
|
|
580
|
+
},
|
|
581
|
+
header.id
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
return /* @__PURE__ */ jsx7(React2.Fragment, { children: ((_c = header.column.columnDef.meta) == null ? void 0 : _c.checkbox) ? /* @__PURE__ */ jsx7(DataGridCell, { type: "header", component: "checkbox", locked: true, children: /* @__PURE__ */ jsx7(
|
|
585
|
+
Checkbox,
|
|
586
|
+
{
|
|
587
|
+
checked: allSelectedAcrossPages,
|
|
588
|
+
indeterminate: someSelectedAcrossPages,
|
|
589
|
+
onChange: toggleSelectAllAcrossPages
|
|
590
|
+
}
|
|
591
|
+
) }) : flexRender2(
|
|
592
|
+
header.column.columnDef.header,
|
|
593
|
+
header.getContext()
|
|
594
|
+
) }, header.id);
|
|
595
|
+
}),
|
|
596
|
+
enableColumnSelector && /* @__PURE__ */ jsx7(
|
|
597
|
+
ColumnSelectorHeaderCell,
|
|
598
|
+
{
|
|
599
|
+
id: id ? `${id}-column-selector` : void 0,
|
|
600
|
+
testid: testid ? `${testid}-column-selector` : void 0,
|
|
601
|
+
table,
|
|
602
|
+
toggleColumnVisibility: toggleColumnVisibility != null ? toggleColumnVisibility : () => {
|
|
603
|
+
},
|
|
604
|
+
resetColumnVisibility: resetColumnVisibility != null ? resetColumnVisibility : () => {
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
)
|
|
608
|
+
]
|
|
609
|
+
},
|
|
610
|
+
headerGroup.id
|
|
611
|
+
);
|
|
612
|
+
}) }),
|
|
613
|
+
/* @__PURE__ */ jsx7(
|
|
614
|
+
TableBody,
|
|
615
|
+
__spreadProps(__spreadValues({
|
|
616
|
+
testid: pinnedTestId
|
|
617
|
+
}, props), {
|
|
618
|
+
table,
|
|
619
|
+
locked: true,
|
|
620
|
+
pinDirection
|
|
621
|
+
})
|
|
622
|
+
)
|
|
623
|
+
]
|
|
624
|
+
}
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
|
|
606
628
|
// src/components/DataGrid/index.tsx
|
|
607
629
|
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
608
630
|
var PAGE_SIZE_OPTIONS = [5, 10, 15, 20, 25, 30, 35];
|
|
@@ -838,8 +860,7 @@ function DataGrid({
|
|
|
838
860
|
pagination,
|
|
839
861
|
isLoadingMore,
|
|
840
862
|
hasMore,
|
|
841
|
-
showFilterRow
|
|
842
|
-
enableColumnSelector
|
|
863
|
+
showFilterRow
|
|
843
864
|
}
|
|
844
865
|
),
|
|
845
866
|
/* @__PURE__ */ jsxs5("table", { className: "flex-1 flex flex-col min-h-min", children: [
|
|
@@ -948,17 +969,7 @@ function DataGrid({
|
|
|
948
969
|
style: { display: "flex", width: virtualPaddingRight }
|
|
949
970
|
}
|
|
950
971
|
)
|
|
951
|
-
) : null
|
|
952
|
-
enableColumnSelector && /* @__PURE__ */ jsx8(
|
|
953
|
-
ColumnSelectorHeaderCell,
|
|
954
|
-
{
|
|
955
|
-
id: id ? `${id}-column-selector` : void 0,
|
|
956
|
-
testid: testid ? `${testid}-column-selector` : void 0,
|
|
957
|
-
table,
|
|
958
|
-
toggleColumnVisibility,
|
|
959
|
-
resetColumnVisibility
|
|
960
|
-
}
|
|
961
|
-
)
|
|
972
|
+
) : null
|
|
962
973
|
]
|
|
963
974
|
},
|
|
964
975
|
headerGroup.id
|
|
@@ -984,6 +995,10 @@ function DataGrid({
|
|
|
984
995
|
/* @__PURE__ */ jsx8(
|
|
985
996
|
PinnedColumns,
|
|
986
997
|
{
|
|
998
|
+
id,
|
|
999
|
+
enableColumnSelector,
|
|
1000
|
+
toggleColumnVisibility,
|
|
1001
|
+
resetColumnVisibility,
|
|
987
1002
|
testid,
|
|
988
1003
|
pinDirection: "right",
|
|
989
1004
|
table,
|
|
@@ -991,8 +1006,7 @@ function DataGrid({
|
|
|
991
1006
|
pagination,
|
|
992
1007
|
isLoadingMore,
|
|
993
1008
|
hasMore,
|
|
994
|
-
showFilterRow
|
|
995
|
-
enableColumnSelector
|
|
1009
|
+
showFilterRow
|
|
996
1010
|
}
|
|
997
1011
|
)
|
|
998
1012
|
]
|
package/package.json
CHANGED
|
@@ -5,7 +5,13 @@ import clsx from "clsx";
|
|
|
5
5
|
import { getSortIcon } from "./utils";
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { TableBody } from "./TableBody";
|
|
8
|
+
import { ColumnSelectorHeaderCell } from "./ColumnSelectorHeaderCell";
|
|
8
9
|
interface PinnedColumnsProps<TData extends RowData> {
|
|
10
|
+
id?: string;
|
|
11
|
+
|
|
12
|
+
toggleColumnVisibility?: (columnId: string, isVisible: boolean) => void;
|
|
13
|
+
resetColumnVisibility?: () => void;
|
|
14
|
+
|
|
9
15
|
pinDirection: "left" | "right";
|
|
10
16
|
table: Table<TData>;
|
|
11
17
|
tableContainerRef: React.RefObject<HTMLDivElement | null>;
|
|
@@ -22,6 +28,7 @@ interface PinnedColumnsProps<TData extends RowData> {
|
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
export function PinnedColumns<TData>({
|
|
31
|
+
id,
|
|
25
32
|
pinDirection = "left",
|
|
26
33
|
table,
|
|
27
34
|
centerHeader,
|
|
@@ -29,6 +36,9 @@ export function PinnedColumns<TData>({
|
|
|
29
36
|
someSelectedAcrossPages,
|
|
30
37
|
toggleSelectAllAcrossPages,
|
|
31
38
|
testid,
|
|
39
|
+
enableColumnSelector,
|
|
40
|
+
toggleColumnVisibility,
|
|
41
|
+
resetColumnVisibility,
|
|
32
42
|
...props
|
|
33
43
|
}: PinnedColumnsProps<TData>) {
|
|
34
44
|
const headerGroups =
|
|
@@ -38,128 +48,136 @@ export function PinnedColumns<TData>({
|
|
|
38
48
|
|
|
39
49
|
const pinnedTestId = testid ? `${pinDirection}-pinned-${testid}` : undefined;
|
|
40
50
|
|
|
51
|
+
const hasAnyHeaders = headerGroups[0]?.headers.length > 0;
|
|
52
|
+
|
|
53
|
+
if (!hasAnyHeaders && !enableColumnSelector) return;
|
|
54
|
+
|
|
41
55
|
return (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
pinnedTestId
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
<table
|
|
57
|
+
className={clsx(
|
|
58
|
+
"flex flex-col min-h-min sticky z-20",
|
|
59
|
+
pinDirection === "left" ? "left-0" : "right-0",
|
|
60
|
+
)}
|
|
61
|
+
data-testid={pinnedTestId}
|
|
62
|
+
>
|
|
63
|
+
<thead className="sticky top-0 z-20 grid">
|
|
64
|
+
{headerGroups.map((headerGroup) => {
|
|
65
|
+
return (
|
|
66
|
+
<tr
|
|
67
|
+
key={headerGroup.id}
|
|
68
|
+
data-testid={
|
|
69
|
+
pinnedTestId
|
|
70
|
+
? `${pinnedTestId}-header-row-${headerGroup.id}`
|
|
71
|
+
: undefined
|
|
72
|
+
}
|
|
73
|
+
className="flex w-full"
|
|
74
|
+
>
|
|
75
|
+
{headerGroup.headers.map((header) => {
|
|
76
|
+
if (!header) {
|
|
77
|
+
return;
|
|
59
78
|
}
|
|
60
|
-
className="flex w-full"
|
|
61
|
-
>
|
|
62
|
-
{headerGroup.headers.map((header) => {
|
|
63
|
-
if (!header) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
locked
|
|
71
|
-
key={header.id}
|
|
72
|
-
testid={
|
|
73
|
-
pinnedTestId
|
|
74
|
-
? `${pinnedTestId}-header-${header.id}`
|
|
75
|
-
: undefined
|
|
76
|
-
}
|
|
77
|
-
header={header}
|
|
78
|
-
center={centerHeader}
|
|
79
|
-
width={
|
|
80
|
-
(header.column.columnDef.meta?.headerWidth as
|
|
81
|
-
| string
|
|
82
|
-
| undefined) ?? `${header.column.getSize()}px`
|
|
83
|
-
}
|
|
84
|
-
className={clsx(
|
|
85
|
-
header.column.getCanSort()
|
|
86
|
-
? "cursor-pointer"
|
|
87
|
-
: "cursor-grab",
|
|
88
|
-
"group",
|
|
89
|
-
)}
|
|
90
|
-
>
|
|
91
|
-
<Subheader tall>
|
|
92
|
-
{header.column.columnDef.header}
|
|
93
|
-
</Subheader>
|
|
80
|
+
if (typeof header.column.columnDef.header === "string") {
|
|
81
|
+
const customHeaderWidth =
|
|
82
|
+
header.column.columnDef.meta?.headerWidth;
|
|
94
83
|
|
|
95
|
-
|
|
84
|
+
return (
|
|
85
|
+
<DataCellHeader
|
|
86
|
+
locked
|
|
87
|
+
key={header.id}
|
|
88
|
+
testid={
|
|
89
|
+
pinnedTestId
|
|
90
|
+
? `${pinnedTestId}-header-${header.id}`
|
|
91
|
+
: undefined
|
|
92
|
+
}
|
|
93
|
+
header={header}
|
|
94
|
+
center={centerHeader}
|
|
95
|
+
width={customHeaderWidth}
|
|
96
|
+
className={clsx(
|
|
97
|
+
header.column.getCanSort()
|
|
98
|
+
? "cursor-pointer"
|
|
99
|
+
: "cursor-grab",
|
|
100
|
+
"group",
|
|
101
|
+
)}
|
|
102
|
+
>
|
|
103
|
+
<Subheader tall>
|
|
104
|
+
{header.column.columnDef.header}
|
|
105
|
+
</Subheader>
|
|
96
106
|
|
|
97
|
-
|
|
98
|
-
header.column.getCanSort() &&
|
|
99
|
-
getSortIcon(
|
|
100
|
-
header.column.getNextSortingOrder(),
|
|
101
|
-
true,
|
|
102
|
-
)}
|
|
107
|
+
{getSortIcon(header.column.getIsSorted())}
|
|
103
108
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
{header.column.getSortIndex() + 1}
|
|
108
|
-
</Subheader>
|
|
109
|
-
)}
|
|
109
|
+
{!header.column.getIsSorted() &&
|
|
110
|
+
header.column.getCanSort() &&
|
|
111
|
+
getSortIcon(header.column.getNextSortingOrder(), true)}
|
|
110
112
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}}
|
|
117
|
-
onMouseDown={(e) => {
|
|
118
|
-
e.stopPropagation();
|
|
119
|
-
header.getResizeHandler()(e);
|
|
120
|
-
}}
|
|
121
|
-
onTouchStart={(e) => {
|
|
122
|
-
e.stopPropagation();
|
|
123
|
-
header.getResizeHandler()(e);
|
|
124
|
-
}}
|
|
125
|
-
className="absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
126
|
-
/>
|
|
113
|
+
{header.column.getSortIndex() !== -1 &&
|
|
114
|
+
table.getState().sorting.length > 1 && (
|
|
115
|
+
<Subheader tall>
|
|
116
|
+
{header.column.getSortIndex() + 1}
|
|
117
|
+
</Subheader>
|
|
127
118
|
)}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
)
|
|
119
|
+
|
|
120
|
+
{!header.column.columnDef.meta?.locked && (
|
|
121
|
+
<div
|
|
122
|
+
onDoubleClick={(e) => {
|
|
123
|
+
e.stopPropagation();
|
|
124
|
+
header.column.resetSize();
|
|
125
|
+
}}
|
|
126
|
+
onMouseDown={(e) => {
|
|
127
|
+
e.stopPropagation();
|
|
128
|
+
header.getResizeHandler()(e);
|
|
129
|
+
}}
|
|
130
|
+
onTouchStart={(e) => {
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
header.getResizeHandler()(e);
|
|
133
|
+
}}
|
|
134
|
+
className="absolute right-0 inset-y-0 w-px bg-black cursor-col-resize"
|
|
135
|
+
/>
|
|
146
136
|
)}
|
|
147
|
-
</
|
|
137
|
+
</DataCellHeader>
|
|
148
138
|
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
139
|
+
}
|
|
140
|
+
return (
|
|
141
|
+
<React.Fragment key={header.id}>
|
|
142
|
+
{header.column.columnDef.meta?.checkbox ? (
|
|
143
|
+
<DataGridCell type="header" component="checkbox" locked>
|
|
144
|
+
<Checkbox
|
|
145
|
+
checked={allSelectedAcrossPages}
|
|
146
|
+
indeterminate={someSelectedAcrossPages}
|
|
147
|
+
onChange={toggleSelectAllAcrossPages}
|
|
148
|
+
/>
|
|
149
|
+
</DataGridCell>
|
|
150
|
+
) : (
|
|
151
|
+
flexRender(
|
|
152
|
+
header.column.columnDef.header,
|
|
153
|
+
header.getContext(),
|
|
154
|
+
)
|
|
155
|
+
)}
|
|
156
|
+
</React.Fragment>
|
|
157
|
+
);
|
|
158
|
+
})}
|
|
159
|
+
|
|
160
|
+
{enableColumnSelector && (
|
|
161
|
+
<ColumnSelectorHeaderCell
|
|
162
|
+
id={id ? `${id}-column-selector` : undefined}
|
|
163
|
+
testid={testid ? `${testid}-column-selector` : undefined}
|
|
164
|
+
table={table}
|
|
165
|
+
toggleColumnVisibility={toggleColumnVisibility ?? (() => {})}
|
|
166
|
+
resetColumnVisibility={resetColumnVisibility ?? (() => {})}
|
|
167
|
+
/>
|
|
168
|
+
)}
|
|
169
|
+
</tr>
|
|
170
|
+
);
|
|
171
|
+
})}
|
|
172
|
+
</thead>
|
|
154
173
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
)
|
|
174
|
+
<TableBody
|
|
175
|
+
testid={pinnedTestId}
|
|
176
|
+
{...props}
|
|
177
|
+
table={table}
|
|
178
|
+
locked={true}
|
|
179
|
+
pinDirection={pinDirection}
|
|
180
|
+
/>
|
|
181
|
+
</table>
|
|
164
182
|
);
|
|
165
183
|
}
|
|
@@ -349,7 +349,6 @@ export function DataGrid<T extends Record<string, unknown>>({
|
|
|
349
349
|
isLoadingMore={isLoadingMore}
|
|
350
350
|
hasMore={hasMore}
|
|
351
351
|
showFilterRow={showFilterRow}
|
|
352
|
-
enableColumnSelector={enableColumnSelector}
|
|
353
352
|
/>
|
|
354
353
|
|
|
355
354
|
<table className="flex-1 flex flex-col min-h-min">
|
|
@@ -497,17 +496,6 @@ export function DataGrid<T extends Record<string, unknown>>({
|
|
|
497
496
|
style={{ display: "flex", width: virtualPaddingRight }}
|
|
498
497
|
/>
|
|
499
498
|
) : null}
|
|
500
|
-
{enableColumnSelector && (
|
|
501
|
-
<ColumnSelectorHeaderCell
|
|
502
|
-
id={id ? `${id}-column-selector` : undefined}
|
|
503
|
-
testid={
|
|
504
|
-
testid ? `${testid}-column-selector` : undefined
|
|
505
|
-
}
|
|
506
|
-
table={table}
|
|
507
|
-
toggleColumnVisibility={toggleColumnVisibility}
|
|
508
|
-
resetColumnVisibility={resetColumnVisibility}
|
|
509
|
-
/>
|
|
510
|
-
)}
|
|
511
499
|
</tr>
|
|
512
500
|
))}
|
|
513
501
|
</thead>
|
|
@@ -529,6 +517,10 @@ export function DataGrid<T extends Record<string, unknown>>({
|
|
|
529
517
|
</table>
|
|
530
518
|
|
|
531
519
|
<PinnedColumns
|
|
520
|
+
id={id}
|
|
521
|
+
enableColumnSelector={enableColumnSelector}
|
|
522
|
+
toggleColumnVisibility={toggleColumnVisibility}
|
|
523
|
+
resetColumnVisibility={resetColumnVisibility}
|
|
532
524
|
testid={testid}
|
|
533
525
|
pinDirection="right"
|
|
534
526
|
table={table}
|
|
@@ -537,7 +529,6 @@ export function DataGrid<T extends Record<string, unknown>>({
|
|
|
537
529
|
isLoadingMore={isLoadingMore}
|
|
538
530
|
hasMore={hasMore}
|
|
539
531
|
showFilterRow={showFilterRow}
|
|
540
|
-
enableColumnSelector={enableColumnSelector}
|
|
541
532
|
/>
|
|
542
533
|
</div>
|
|
543
534
|
|