@dmsi/wedgekit-react 0.0.207 → 0.0.209
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/{chunk-WNQ53SVY.js → chunk-E6Y7ZHQX.js} +45 -1
- package/dist/{chunk-WXHRJSDG.js → chunk-ERW3AMED.js} +1 -1
- package/dist/{chunk-2JRZCC2K.js → chunk-JITZWSPR.js} +3 -3
- package/dist/{chunk-WE55TGZZ.js → chunk-NIHZMIOL.js} +1 -1
- package/dist/{chunk-RXPS5GVE.js → chunk-Q3TNALWH.js} +17 -26
- package/dist/{chunk-M3433XEJ.js → chunk-T3F37S6Z.js} +15 -1
- package/dist/{chunk-2B5T4NCT.js → chunk-UKSJPFN2.js} +2 -2
- package/dist/components/DataGridCell.cjs +814 -824
- package/dist/components/DataGridCell.js +7 -6
- package/dist/components/DateInput.cjs +23 -23
- package/dist/components/DateInput.js +4 -4
- package/dist/components/DateRangeInput.cjs +23 -23
- package/dist/components/DateRangeInput.js +4 -4
- package/dist/components/Menu.cjs +38 -35
- package/dist/components/Menu.js +6 -4
- package/dist/components/MenuOption.cjs +7 -4
- package/dist/components/MenuOption.js +5 -2
- package/dist/components/Modal.cjs +15 -12
- package/dist/components/Modal.js +5 -3
- package/dist/components/NestedMenu.cjs +9 -6
- package/dist/components/NestedMenu.js +5 -2
- package/dist/components/PDFViewer.cjs +22 -19
- package/dist/components/PDFViewer.js +5 -3
- package/dist/components/ProjectBar.cjs +3 -0
- package/dist/components/ProjectBar.js +4 -1
- package/dist/components/Time.js +2 -1
- package/dist/components/index.cjs +963 -905
- package/dist/components/index.js +70 -45
- package/dist/components/useMenuSystem.cjs +22 -19
- package/dist/components/useMenuSystem.js +5 -2
- package/dist/hooks/index.cjs +66 -2
- package/dist/hooks/index.js +8 -3
- package/dist/utils/index.cjs +25 -0
- package/dist/utils/index.js +3 -1
- package/package.json +1 -1
- package/src/components/DataGrid/TableBody/TableBodyRow.tsx +0 -4
- package/src/components/DataGrid/TableBody/index.tsx +14 -3
- package/src/components/DataGrid/index.tsx +58 -35
- package/src/components/DataGridCell.tsx +11 -17
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useTableLayout.ts +68 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/mergeObjectArrays.ts +18 -0
- package/src/utils.ts +1 -0
- /package/dist/{chunk-6LN6QT6M.js → chunk-VXWSAIB5.js} +0 -0
package/dist/components/index.js
CHANGED
|
@@ -12,18 +12,20 @@ import {
|
|
|
12
12
|
DataGridCell,
|
|
13
13
|
DragAlongCell,
|
|
14
14
|
DraggableCellHeader
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-Q3TNALWH.js";
|
|
16
16
|
import {
|
|
17
17
|
Menu
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
18
|
+
} from "../chunk-JITZWSPR.js";
|
|
19
|
+
import "../chunk-NIHZMIOL.js";
|
|
20
20
|
import {
|
|
21
21
|
MenuOption
|
|
22
|
-
} from "../chunk-
|
|
22
|
+
} from "../chunk-ERW3AMED.js";
|
|
23
23
|
import {
|
|
24
|
-
useInfiniteScroll
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
useInfiniteScroll,
|
|
25
|
+
useTableLayout
|
|
26
|
+
} from "../chunk-E6Y7ZHQX.js";
|
|
27
|
+
import "../chunk-VXWSAIB5.js";
|
|
28
|
+
import "../chunk-T3F37S6Z.js";
|
|
27
29
|
import {
|
|
28
30
|
Search
|
|
29
31
|
} from "../chunk-2WRRRPEB.js";
|
|
@@ -65,7 +67,7 @@ import {
|
|
|
65
67
|
} from "../chunk-BBZEL7EG.js";
|
|
66
68
|
|
|
67
69
|
// src/components/DataGrid/index.tsx
|
|
68
|
-
import React3, { useCallback, useId, useState as useState3 } from "react";
|
|
70
|
+
import React3, { useCallback, useEffect, useId, useState as useState3 } from "react";
|
|
69
71
|
import {
|
|
70
72
|
flexRender as flexRender3,
|
|
71
73
|
getCoreRowModel,
|
|
@@ -170,7 +172,7 @@ function TableBodyRow({
|
|
|
170
172
|
/* @__PURE__ */ jsx2("td", { style: { display: "flex", width: virtualPaddingLeft } })
|
|
171
173
|
) : null,
|
|
172
174
|
columns.map((column) => {
|
|
173
|
-
var _a2
|
|
175
|
+
var _a2;
|
|
174
176
|
const cell = locked ? column : visibleCells[column.index];
|
|
175
177
|
if (!cell) {
|
|
176
178
|
return;
|
|
@@ -185,7 +187,6 @@ function TableBodyRow({
|
|
|
185
187
|
className: clsx2({
|
|
186
188
|
"justify-end": typeof cellValue === "number"
|
|
187
189
|
}),
|
|
188
|
-
width: (_c = (_b = cell.column.columnDef.meta) == null ? void 0 : _b.headerWidth) != null ? _c : `${cell.column.getSize()}px`,
|
|
189
190
|
children: /* @__PURE__ */ jsx2(
|
|
190
191
|
Tooltip,
|
|
191
192
|
{
|
|
@@ -371,7 +372,15 @@ function TableBody({
|
|
|
371
372
|
transform: `translateY(${virtualRows[virtualRows.length - 1].start + 40}px)`
|
|
372
373
|
},
|
|
373
374
|
className: "odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal",
|
|
374
|
-
children: table.getAllLeafColumns().map((column) => /* @__PURE__ */ jsx4(
|
|
375
|
+
children: table.getAllLeafColumns().map((column) => /* @__PURE__ */ jsx4(
|
|
376
|
+
LoadingCell,
|
|
377
|
+
{
|
|
378
|
+
id,
|
|
379
|
+
testid,
|
|
380
|
+
column: column.columnDef
|
|
381
|
+
},
|
|
382
|
+
column.id
|
|
383
|
+
))
|
|
375
384
|
}
|
|
376
385
|
)
|
|
377
386
|
]
|
|
@@ -659,12 +668,29 @@ function DataGrid({
|
|
|
659
668
|
useMenuDefaultMinWidth
|
|
660
669
|
}) {
|
|
661
670
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
662
|
-
const [columnOrder, setColumnOrder] = useState3(
|
|
663
|
-
() => columns.map((c) => c.id)
|
|
664
|
-
);
|
|
665
671
|
const [localSorting, setLocalSorting] = useState3([]);
|
|
666
672
|
const [localColumnFilters, setLocalColumnFilters] = useState3([]);
|
|
667
673
|
const [localRowSelection, setLocalRowSelection] = useState3({});
|
|
674
|
+
const {
|
|
675
|
+
columns: tableColumns,
|
|
676
|
+
setColumns: setTableColumns,
|
|
677
|
+
layoutSignal
|
|
678
|
+
} = useTableLayout(columns, id != null ? id : testid);
|
|
679
|
+
const [columnOrder, setColumnOrder] = useState3(
|
|
680
|
+
tableColumns.map((c) => c.id)
|
|
681
|
+
);
|
|
682
|
+
const [columnVisibility, setColumnVisibility] = useState3(
|
|
683
|
+
Object.fromEntries(
|
|
684
|
+
tableColumns.filter((column) => !!column.id).map((column) => {
|
|
685
|
+
var _a2, _b2;
|
|
686
|
+
return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
|
|
687
|
+
})
|
|
688
|
+
)
|
|
689
|
+
);
|
|
690
|
+
useEffect(() => {
|
|
691
|
+
setColumnOrder(tableColumns.map((c) => c.id));
|
|
692
|
+
resetColumnVisibility();
|
|
693
|
+
}, [layoutSignal]);
|
|
668
694
|
const sortingState = pagination ? externalSorting != null ? externalSorting : localSorting : localSorting;
|
|
669
695
|
const setSortingState = pagination ? (updaterOrValue) => {
|
|
670
696
|
const value = typeof updaterOrValue === "function" ? updaterOrValue(
|
|
@@ -684,36 +710,32 @@ function DataGrid({
|
|
|
684
710
|
} : setLocalRowSelection;
|
|
685
711
|
const dndId = useId();
|
|
686
712
|
const containerRef = React3.useRef(null);
|
|
687
|
-
const [columnVisibility, setColumnVisibility] = useState3(() => {
|
|
688
|
-
const initialVisibility = {};
|
|
689
|
-
columns.forEach((column) => {
|
|
690
|
-
var _a2, _b2;
|
|
691
|
-
if (column.id) {
|
|
692
|
-
initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
|
|
693
|
-
}
|
|
694
|
-
});
|
|
695
|
-
return initialVisibility;
|
|
696
|
-
});
|
|
697
713
|
const toggleColumnVisibility = useCallback(
|
|
698
714
|
(columnId, isVisible) => {
|
|
699
|
-
|
|
715
|
+
setTableColumns((prev) => {
|
|
716
|
+
const persistedIndex = prev.findIndex((col) => col.id === columnId);
|
|
717
|
+
if (persistedIndex !== -1) {
|
|
718
|
+
prev[persistedIndex].meta = __spreadProps(__spreadValues({}, prev[persistedIndex].meta), {
|
|
719
|
+
visible: isVisible
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
return [...prev];
|
|
723
|
+
}, true);
|
|
700
724
|
},
|
|
701
|
-
[
|
|
725
|
+
[setTableColumns]
|
|
702
726
|
);
|
|
703
727
|
const resetColumnVisibility = useCallback(() => {
|
|
704
|
-
setColumnVisibility(
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
});
|
|
714
|
-
}, [columns]);
|
|
728
|
+
setColumnVisibility(
|
|
729
|
+
Object.fromEntries(
|
|
730
|
+
tableColumns.filter((column) => !!column.id).map((column) => {
|
|
731
|
+
var _a2, _b2;
|
|
732
|
+
return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
|
|
733
|
+
})
|
|
734
|
+
)
|
|
735
|
+
);
|
|
736
|
+
}, [tableColumns]);
|
|
715
737
|
const table = useReactTable({
|
|
716
|
-
columns,
|
|
738
|
+
columns: tableColumns,
|
|
717
739
|
data,
|
|
718
740
|
getCoreRowModel: getCoreRowModel(),
|
|
719
741
|
getSortedRowModel: getSortedRowModel(),
|
|
@@ -797,7 +819,12 @@ function DataGrid({
|
|
|
797
819
|
setColumnOrder((prev) => {
|
|
798
820
|
const oldIndex = prev.indexOf(active.id);
|
|
799
821
|
const newIndex = prev.indexOf(over.id);
|
|
800
|
-
|
|
822
|
+
const newOrder = arrayMove(prev, oldIndex, newIndex);
|
|
823
|
+
setTableColumns((prev2) => {
|
|
824
|
+
const res = newOrder.map((id2) => prev2.find((col) => col.id === id2)).filter(Boolean);
|
|
825
|
+
return res;
|
|
826
|
+
});
|
|
827
|
+
return newOrder;
|
|
801
828
|
});
|
|
802
829
|
}
|
|
803
830
|
};
|
|
@@ -883,23 +910,21 @@ function DataGrid({
|
|
|
883
910
|
)
|
|
884
911
|
) : null,
|
|
885
912
|
virtualColumns.map((virtualColumn) => {
|
|
886
|
-
var _a2, _b2, _c2
|
|
913
|
+
var _a2, _b2, _c2;
|
|
887
914
|
const header = headerGroup.headers[virtualColumn.index];
|
|
888
915
|
if (!header) {
|
|
889
916
|
return;
|
|
890
917
|
}
|
|
891
918
|
if (typeof header.column.columnDef.header === "string") {
|
|
892
|
-
const
|
|
893
|
-
const cellValue = (_b2 = table.getRowModel().rows[0]) == null ? void 0 : _b2.getValue(header.column.id);
|
|
919
|
+
const cellValue = (_a2 = table.getRowModel().rows[0]) == null ? void 0 : _a2.getValue(header.column.id);
|
|
894
920
|
return /* @__PURE__ */ jsxs5(
|
|
895
921
|
DraggableCellHeader,
|
|
896
922
|
{
|
|
897
923
|
id: id ? `${id}-header-${header.id}` : void 0,
|
|
898
924
|
testid: testid ? `${testid}-header-${header.id}` : void 0,
|
|
899
925
|
header,
|
|
900
|
-
locked: (
|
|
926
|
+
locked: (_b2 = header.column.columnDef.meta) == null ? void 0 : _b2.locked,
|
|
901
927
|
center: centerHeader,
|
|
902
|
-
width: customHeaderWidth,
|
|
903
928
|
className: clsx5(
|
|
904
929
|
header.column.getCanSort() ? "cursor-pointer" : "cursor-grab",
|
|
905
930
|
"group",
|
|
@@ -940,7 +965,7 @@ function DataGrid({
|
|
|
940
965
|
header.id
|
|
941
966
|
);
|
|
942
967
|
}
|
|
943
|
-
return /* @__PURE__ */ jsx8(React3.Fragment, { children: ((
|
|
968
|
+
return /* @__PURE__ */ jsx8(React3.Fragment, { children: ((_c2 = header.column.columnDef.meta) == null ? void 0 : _c2.checkbox) ? /* @__PURE__ */ jsx8(
|
|
944
969
|
DataGridCell,
|
|
945
970
|
{
|
|
946
971
|
id: id ? `${id}-header-${header.id}` : void 0,
|
|
@@ -39,7 +39,7 @@ __export(useMenuSystem_exports, {
|
|
|
39
39
|
useSubMenuSystem: () => useSubMenuSystem
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(useMenuSystem_exports);
|
|
42
|
-
var
|
|
42
|
+
var import_react5 = require("react");
|
|
43
43
|
|
|
44
44
|
// src/hooks/useKeydown.ts
|
|
45
45
|
var import_react = require("react");
|
|
@@ -62,23 +62,26 @@ var useMatchesMedia = (query) => {
|
|
|
62
62
|
};
|
|
63
63
|
var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
|
|
64
64
|
|
|
65
|
+
// src/hooks/useTableLayout.ts
|
|
66
|
+
var import_react4 = require("react");
|
|
67
|
+
|
|
65
68
|
// src/components/useMenuSystem.tsx
|
|
66
69
|
function useSubMenuSystem(mobilePositionTo) {
|
|
67
|
-
const [activeMenus, setActiveMenus] = (0,
|
|
70
|
+
const [activeMenus, setActiveMenus] = (0, import_react5.useState)(
|
|
68
71
|
{}
|
|
69
72
|
);
|
|
70
|
-
const [activeMenu, setActiveMenu] = (0,
|
|
71
|
-
const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0,
|
|
73
|
+
const [activeMenu, setActiveMenu] = (0, import_react5.useState)("");
|
|
74
|
+
const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0, import_react5.useState)(
|
|
72
75
|
null
|
|
73
76
|
);
|
|
74
|
-
const menuRootRef = (0,
|
|
75
|
-
const subMenuRefs = (0,
|
|
76
|
-
const hoverTimeoutRef = (0,
|
|
77
|
-
const closeTimeoutRef = (0,
|
|
78
|
-
const mouseStopTimeoutRef = (0,
|
|
79
|
-
const isMouseMovingRef = (0,
|
|
80
|
-
const pendingOpenActionRef = (0,
|
|
81
|
-
const pendingCloseActionRef = (0,
|
|
77
|
+
const menuRootRef = (0, import_react5.useRef)(null);
|
|
78
|
+
const subMenuRefs = (0, import_react5.useRef)({});
|
|
79
|
+
const hoverTimeoutRef = (0, import_react5.useRef)(null);
|
|
80
|
+
const closeTimeoutRef = (0, import_react5.useRef)(null);
|
|
81
|
+
const mouseStopTimeoutRef = (0, import_react5.useRef)(null);
|
|
82
|
+
const isMouseMovingRef = (0, import_react5.useRef)(false);
|
|
83
|
+
const pendingOpenActionRef = (0, import_react5.useRef)(null);
|
|
84
|
+
const pendingCloseActionRef = (0, import_react5.useRef)(null);
|
|
82
85
|
const isMobile = useMatchesMobile();
|
|
83
86
|
const toggleMenu = (menuId, level) => {
|
|
84
87
|
if (closeTimeoutRef.current) {
|
|
@@ -118,7 +121,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
118
121
|
return newActiveMenus;
|
|
119
122
|
});
|
|
120
123
|
};
|
|
121
|
-
const executePendingActions = (0,
|
|
124
|
+
const executePendingActions = (0, import_react5.useCallback)(() => {
|
|
122
125
|
if (pendingCloseActionRef.current) {
|
|
123
126
|
pendingCloseActionRef.current();
|
|
124
127
|
pendingCloseActionRef.current = null;
|
|
@@ -207,7 +210,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
207
210
|
const isMenuActive = (menuId, level) => {
|
|
208
211
|
return activeMenus[level] === menuId;
|
|
209
212
|
};
|
|
210
|
-
(0,
|
|
213
|
+
(0, import_react5.useEffect)(() => {
|
|
211
214
|
const handleClickOutside = (event) => {
|
|
212
215
|
var _a;
|
|
213
216
|
if (Object.keys(activeMenus).length === 0) return;
|
|
@@ -226,7 +229,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
226
229
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
227
230
|
};
|
|
228
231
|
}, [activeMenus]);
|
|
229
|
-
(0,
|
|
232
|
+
(0, import_react5.useEffect)(() => {
|
|
230
233
|
return () => {
|
|
231
234
|
if (hoverTimeoutRef.current) {
|
|
232
235
|
clearTimeout(hoverTimeoutRef.current);
|
|
@@ -304,13 +307,13 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
304
307
|
};
|
|
305
308
|
}
|
|
306
309
|
function useMenuPosition(elementRef, position = "bottom", options) {
|
|
307
|
-
const [menuPosition, setMenuPosition] = (0,
|
|
310
|
+
const [menuPosition, setMenuPosition] = (0, import_react5.useState)({
|
|
308
311
|
top: 0,
|
|
309
312
|
left: 0,
|
|
310
313
|
minWidth: 0
|
|
311
314
|
});
|
|
312
315
|
const isMobile = options == null ? void 0 : options.isMobile;
|
|
313
|
-
const updatePosition = (0,
|
|
316
|
+
const updatePosition = (0, import_react5.useCallback)(() => {
|
|
314
317
|
var _a, _b, _c;
|
|
315
318
|
if (!(elementRef == null ? void 0 : elementRef.current)) return;
|
|
316
319
|
const triggerRect = elementRef.current.getBoundingClientRect();
|
|
@@ -358,7 +361,7 @@ function useMenuPosition(elementRef, position = "bottom", options) {
|
|
|
358
361
|
minWidth: triggerRect.width
|
|
359
362
|
});
|
|
360
363
|
}, [elementRef, position, options == null ? void 0 : options.menuRef, options == null ? void 0 : options.topOffset, isMobile]);
|
|
361
|
-
(0,
|
|
364
|
+
(0, import_react5.useEffect)(() => {
|
|
362
365
|
if (!(options == null ? void 0 : options.isOpen) || !(options == null ? void 0 : options.setIsOpen)) return;
|
|
363
366
|
const handleClickOutside = (event) => {
|
|
364
367
|
var _a, _b, _c, _d, _e;
|
|
@@ -384,7 +387,7 @@ function useMenuPosition(elementRef, position = "bottom", options) {
|
|
|
384
387
|
options == null ? void 0 : options.menuRef,
|
|
385
388
|
options == null ? void 0 : options.additionalRefs
|
|
386
389
|
]);
|
|
387
|
-
(0,
|
|
390
|
+
(0, import_react5.useEffect)(() => {
|
|
388
391
|
updatePosition();
|
|
389
392
|
const resizeObserver = new ResizeObserver(updatePosition);
|
|
390
393
|
if (elementRef == null ? void 0 : elementRef.current) {
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useMenuPosition,
|
|
4
4
|
useSubMenuSystem
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-NIHZMIOL.js";
|
|
6
|
+
import "../chunk-E6Y7ZHQX.js";
|
|
7
|
+
import "../chunk-VXWSAIB5.js";
|
|
8
|
+
import "../chunk-T3F37S6Z.js";
|
|
9
|
+
import "../chunk-5UH6QUFB.js";
|
|
7
10
|
import "../chunk-BBZEL7EG.js";
|
|
8
11
|
export {
|
|
9
12
|
useMenuPosition,
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -2,7 +2,21 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
6
20
|
var __export = (target, all) => {
|
|
7
21
|
for (var name in all)
|
|
8
22
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -23,7 +37,8 @@ __export(hooks_exports, {
|
|
|
23
37
|
useInfiniteScroll: () => useInfiniteScroll,
|
|
24
38
|
useKeydown: () => useKeydown,
|
|
25
39
|
useMatchesMedia: () => useMatchesMedia,
|
|
26
|
-
useMatchesMobile: () => useMatchesMobile
|
|
40
|
+
useMatchesMobile: () => useMatchesMobile,
|
|
41
|
+
useTableLayout: () => useTableLayout
|
|
27
42
|
});
|
|
28
43
|
module.exports = __toCommonJS(hooks_exports);
|
|
29
44
|
|
|
@@ -99,10 +114,59 @@ var useMatchesMedia = (query) => {
|
|
|
99
114
|
return matches;
|
|
100
115
|
};
|
|
101
116
|
var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
|
|
117
|
+
|
|
118
|
+
// src/utils/mergeObjectArrays.ts
|
|
119
|
+
function mergeObjectArrays(arr1, arr2) {
|
|
120
|
+
const maxLength = Math.max(arr1.length, arr2.length);
|
|
121
|
+
return Array.from(
|
|
122
|
+
{ length: maxLength },
|
|
123
|
+
(_, i) => __spreadValues(__spreadValues({}, arr1[i] || {}), arr2[i] || {})
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/hooks/useTableLayout.ts
|
|
128
|
+
var import_react4 = require("react");
|
|
129
|
+
function useTableLayout(initialColumns, key) {
|
|
130
|
+
const [columns, setColumns] = (0, import_react4.useState)(initialColumns);
|
|
131
|
+
const [isReady, setIsReady] = (0, import_react4.useState)(false);
|
|
132
|
+
const [layoutSignal, setLayoutSignal] = (0, import_react4.useState)(0);
|
|
133
|
+
(0, import_react4.useEffect)(() => {
|
|
134
|
+
if (!key) return setIsReady(true);
|
|
135
|
+
const savedLayout = localStorage.getItem(`${key}-tableLayout`);
|
|
136
|
+
if (savedLayout) {
|
|
137
|
+
setColumns(
|
|
138
|
+
mergeObjectArrays(
|
|
139
|
+
initialColumns,
|
|
140
|
+
JSON.parse(savedLayout)
|
|
141
|
+
)
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (!savedLayout) handleSaveLayout(initialColumns, true);
|
|
145
|
+
setLayoutSignal((prev) => prev + 1);
|
|
146
|
+
setIsReady(true);
|
|
147
|
+
}, []);
|
|
148
|
+
const handleSaveLayout = (0, import_react4.useCallback)(
|
|
149
|
+
(setter, _internal) => {
|
|
150
|
+
if (!isReady && !_internal) return null;
|
|
151
|
+
const newColumns = typeof setter === "function" ? setter(columns) : setter;
|
|
152
|
+
if (JSON.stringify(newColumns) === JSON.stringify(columns) && !_internal)
|
|
153
|
+
return null;
|
|
154
|
+
if (key) {
|
|
155
|
+
localStorage.setItem(`${key}-tableLayout`, JSON.stringify(newColumns));
|
|
156
|
+
}
|
|
157
|
+
setColumns(newColumns);
|
|
158
|
+
setLayoutSignal((prev) => prev + 1);
|
|
159
|
+
return newColumns;
|
|
160
|
+
},
|
|
161
|
+
[columns, isReady, key]
|
|
162
|
+
);
|
|
163
|
+
return { columns, setColumns: handleSaveLayout, layoutSignal, isReady };
|
|
164
|
+
}
|
|
102
165
|
// Annotate the CommonJS export names for ESM import in node:
|
|
103
166
|
0 && (module.exports = {
|
|
104
167
|
useInfiniteScroll,
|
|
105
168
|
useKeydown,
|
|
106
169
|
useMatchesMedia,
|
|
107
|
-
useMatchesMobile
|
|
170
|
+
useMatchesMobile,
|
|
171
|
+
useTableLayout
|
|
108
172
|
});
|
package/dist/hooks/index.js
CHANGED
|
@@ -2,12 +2,17 @@ import {
|
|
|
2
2
|
useInfiniteScroll,
|
|
3
3
|
useKeydown,
|
|
4
4
|
useMatchesMedia,
|
|
5
|
-
useMatchesMobile
|
|
6
|
-
|
|
5
|
+
useMatchesMobile,
|
|
6
|
+
useTableLayout
|
|
7
|
+
} from "../chunk-E6Y7ZHQX.js";
|
|
8
|
+
import "../chunk-VXWSAIB5.js";
|
|
9
|
+
import "../chunk-T3F37S6Z.js";
|
|
10
|
+
import "../chunk-5UH6QUFB.js";
|
|
7
11
|
import "../chunk-BBZEL7EG.js";
|
|
8
12
|
export {
|
|
9
13
|
useInfiniteScroll,
|
|
10
14
|
useKeydown,
|
|
11
15
|
useMatchesMedia,
|
|
12
|
-
useMatchesMobile
|
|
16
|
+
useMatchesMobile,
|
|
17
|
+
useTableLayout
|
|
13
18
|
};
|
package/dist/utils/index.cjs
CHANGED
|
@@ -2,7 +2,21 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
6
20
|
var __export = (target, all) => {
|
|
7
21
|
for (var name in all)
|
|
8
22
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,6 +48,7 @@ __export(utils_exports, {
|
|
|
34
48
|
isValidDate: () => isValidDate,
|
|
35
49
|
isValidDateRange: () => isValidDateRange,
|
|
36
50
|
isValidDateRangeOrder: () => isValidDateRangeOrder,
|
|
51
|
+
mergeObjectArrays: () => mergeObjectArrays,
|
|
37
52
|
parseDateParts: () => parseDateParts,
|
|
38
53
|
parseInputDate: () => parseInputDate
|
|
39
54
|
});
|
|
@@ -197,6 +212,15 @@ function isValidDateRangeOrder(fromDate, toDate) {
|
|
|
197
212
|
const to = new Date(toDate);
|
|
198
213
|
return to >= from;
|
|
199
214
|
}
|
|
215
|
+
|
|
216
|
+
// src/utils/mergeObjectArrays.ts
|
|
217
|
+
function mergeObjectArrays(arr1, arr2) {
|
|
218
|
+
const maxLength = Math.max(arr1.length, arr2.length);
|
|
219
|
+
return Array.from(
|
|
220
|
+
{ length: maxLength },
|
|
221
|
+
(_, i) => __spreadValues(__spreadValues({}, arr1[i] || {}), arr2[i] || {})
|
|
222
|
+
);
|
|
223
|
+
}
|
|
200
224
|
// Annotate the CommonJS export names for ESM import in node:
|
|
201
225
|
0 && (module.exports = {
|
|
202
226
|
calculateCursorPosition,
|
|
@@ -213,6 +237,7 @@ function isValidDateRangeOrder(fromDate, toDate) {
|
|
|
213
237
|
isValidDate,
|
|
214
238
|
isValidDateRange,
|
|
215
239
|
isValidDateRangeOrder,
|
|
240
|
+
mergeObjectArrays,
|
|
216
241
|
parseDateParts,
|
|
217
242
|
parseInputDate
|
|
218
243
|
});
|
package/dist/utils/index.js
CHANGED
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
isValidDate,
|
|
11
11
|
isValidDateRange,
|
|
12
12
|
isValidDateRangeOrder,
|
|
13
|
+
mergeObjectArrays,
|
|
13
14
|
parseDateParts,
|
|
14
15
|
parseInputDate
|
|
15
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-T3F37S6Z.js";
|
|
16
17
|
import {
|
|
17
18
|
formatCurrencyDisplay,
|
|
18
19
|
formatDecimalValue,
|
|
@@ -34,6 +35,7 @@ export {
|
|
|
34
35
|
isValidDate,
|
|
35
36
|
isValidDateRange,
|
|
36
37
|
isValidDateRangeOrder,
|
|
38
|
+
mergeObjectArrays,
|
|
37
39
|
parseDateParts,
|
|
38
40
|
parseInputDate
|
|
39
41
|
};
|
package/package.json
CHANGED
|
@@ -107,10 +107,6 @@ export function TableBodyRow<T>({
|
|
|
107
107
|
className={clsx({
|
|
108
108
|
"justify-end": typeof cellValue === "number",
|
|
109
109
|
})}
|
|
110
|
-
width={
|
|
111
|
-
(cell.column.columnDef.meta?.headerWidth as string | undefined) ??
|
|
112
|
-
`${cell.column.getSize()}px`
|
|
113
|
-
}
|
|
114
110
|
>
|
|
115
111
|
<Tooltip
|
|
116
112
|
id={id ? `${id}-tooltip-${cell.id}` : undefined}
|
|
@@ -89,7 +89,9 @@ export function TableBody<T>({
|
|
|
89
89
|
x.headers.map((header) => (
|
|
90
90
|
<CellElement
|
|
91
91
|
id={id ? `${id}-filter-cell-${header.id}` : undefined}
|
|
92
|
-
testid={
|
|
92
|
+
testid={
|
|
93
|
+
testid ? `${testid}-filter-cell-${header.id}` : undefined
|
|
94
|
+
}
|
|
93
95
|
noPadding
|
|
94
96
|
key={header.id}
|
|
95
97
|
cell={header}
|
|
@@ -105,7 +107,11 @@ export function TableBody<T>({
|
|
|
105
107
|
}) ?? (
|
|
106
108
|
<Search
|
|
107
109
|
id={id ? `${id}-filter-search-${header.id}` : undefined}
|
|
108
|
-
testid={
|
|
110
|
+
testid={
|
|
111
|
+
testid
|
|
112
|
+
? `${testid}-filter-search-${header.id}`
|
|
113
|
+
: undefined
|
|
114
|
+
}
|
|
109
115
|
removeRoundness
|
|
110
116
|
onChange={(e) =>
|
|
111
117
|
header.column.setFilterValue(e.target.value)
|
|
@@ -156,7 +162,12 @@ export function TableBody<T>({
|
|
|
156
162
|
className="odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal"
|
|
157
163
|
>
|
|
158
164
|
{table.getAllLeafColumns().map((column) => (
|
|
159
|
-
<LoadingCell
|
|
165
|
+
<LoadingCell
|
|
166
|
+
id={id}
|
|
167
|
+
testid={testid}
|
|
168
|
+
key={column.id}
|
|
169
|
+
column={column.columnDef}
|
|
170
|
+
/>
|
|
160
171
|
))}
|
|
161
172
|
</tr>
|
|
162
173
|
)}
|