@dmsi/wedgekit-react 0.0.207 → 0.0.208
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-RXPS5GVE.js → chunk-EFX3RPW4.js} +3 -3
- 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-M3433XEJ.js → chunk-T3F37S6Z.js} +15 -1
- package/dist/{chunk-2B5T4NCT.js → chunk-UKSJPFN2.js} +2 -2
- package/dist/components/DataGridCell.cjs +68 -65
- 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 +190 -124
- package/dist/components/index.js +56 -36
- 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/index.tsx +57 -31
- 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
|
@@ -134,7 +134,7 @@ var CSS = /* @__PURE__ */ Object.freeze({
|
|
|
134
134
|
|
|
135
135
|
// src/components/DataGridCell.tsx
|
|
136
136
|
var import_clsx8 = __toESM(require("clsx"), 1);
|
|
137
|
-
var
|
|
137
|
+
var import_react11 = require("react");
|
|
138
138
|
|
|
139
139
|
// src/classNames.ts
|
|
140
140
|
var import_clsx = __toESM(require("clsx"), 1);
|
|
@@ -883,11 +883,11 @@ Search.displayName = "Search";
|
|
|
883
883
|
|
|
884
884
|
// src/components/Menu.tsx
|
|
885
885
|
var import_clsx5 = __toESM(require("clsx"), 1);
|
|
886
|
-
var
|
|
886
|
+
var import_react9 = require("react");
|
|
887
887
|
var import_react_dom = require("react-dom");
|
|
888
888
|
|
|
889
889
|
// src/components/useMenuSystem.tsx
|
|
890
|
-
var
|
|
890
|
+
var import_react8 = require("react");
|
|
891
891
|
|
|
892
892
|
// src/hooks/useKeydown.ts
|
|
893
893
|
var import_react4 = require("react");
|
|
@@ -936,23 +936,94 @@ var useMatchesMedia = (query) => {
|
|
|
936
936
|
};
|
|
937
937
|
var useMatchesMobile = () => useMatchesMedia("(width < 48rem)");
|
|
938
938
|
|
|
939
|
+
// src/utils/mergeObjectArrays.ts
|
|
940
|
+
function mergeObjectArrays(arr1, arr2) {
|
|
941
|
+
const maxLength = Math.max(arr1.length, arr2.length);
|
|
942
|
+
return Array.from(
|
|
943
|
+
{ length: maxLength },
|
|
944
|
+
(_, i) => __spreadValues(__spreadValues({}, arr1[i] || {}), arr2[i] || {})
|
|
945
|
+
);
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// src/utils.ts
|
|
949
|
+
function findDocumentRoot(element) {
|
|
950
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
951
|
+
throw new Error(
|
|
952
|
+
"findDocumentRoot can only be used in a browser environment."
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
if (!element || !(element instanceof Node)) {
|
|
956
|
+
return window.document.body;
|
|
957
|
+
}
|
|
958
|
+
let currentElement = element;
|
|
959
|
+
while (currentElement && currentElement.parentNode) {
|
|
960
|
+
if (currentElement.parentNode === document) {
|
|
961
|
+
return document.body;
|
|
962
|
+
} else if (currentElement.parentNode instanceof DocumentFragment) {
|
|
963
|
+
return currentElement.parentNode;
|
|
964
|
+
} else {
|
|
965
|
+
currentElement = currentElement.parentNode;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
return window.document.body;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// src/hooks/useTableLayout.ts
|
|
972
|
+
var import_react7 = require("react");
|
|
973
|
+
function useTableLayout(initialColumns, key) {
|
|
974
|
+
const [columns, setColumns] = (0, import_react7.useState)(initialColumns);
|
|
975
|
+
const [isReady, setIsReady] = (0, import_react7.useState)(false);
|
|
976
|
+
const [layoutSignal, setLayoutSignal] = (0, import_react7.useState)(0);
|
|
977
|
+
(0, import_react7.useEffect)(() => {
|
|
978
|
+
if (!key) return setIsReady(true);
|
|
979
|
+
const savedLayout = localStorage.getItem(`${key}-tableLayout`);
|
|
980
|
+
if (savedLayout) {
|
|
981
|
+
setColumns(
|
|
982
|
+
mergeObjectArrays(
|
|
983
|
+
initialColumns,
|
|
984
|
+
JSON.parse(savedLayout)
|
|
985
|
+
)
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
if (!savedLayout) handleSaveLayout(initialColumns, true);
|
|
989
|
+
setLayoutSignal((prev) => prev + 1);
|
|
990
|
+
setIsReady(true);
|
|
991
|
+
}, []);
|
|
992
|
+
const handleSaveLayout = (0, import_react7.useCallback)(
|
|
993
|
+
(setter, _internal) => {
|
|
994
|
+
if (!isReady && !_internal) return null;
|
|
995
|
+
const newColumns = typeof setter === "function" ? setter(columns) : setter;
|
|
996
|
+
if (JSON.stringify(newColumns) === JSON.stringify(columns) && !_internal)
|
|
997
|
+
return null;
|
|
998
|
+
if (key) {
|
|
999
|
+
localStorage.setItem(`${key}-tableLayout`, JSON.stringify(newColumns));
|
|
1000
|
+
}
|
|
1001
|
+
setColumns(newColumns);
|
|
1002
|
+
setLayoutSignal((prev) => prev + 1);
|
|
1003
|
+
return newColumns;
|
|
1004
|
+
},
|
|
1005
|
+
[columns, isReady, key]
|
|
1006
|
+
);
|
|
1007
|
+
return { columns, setColumns: handleSaveLayout, layoutSignal, isReady };
|
|
1008
|
+
}
|
|
1009
|
+
|
|
939
1010
|
// src/components/useMenuSystem.tsx
|
|
940
1011
|
function useSubMenuSystem(mobilePositionTo) {
|
|
941
|
-
const [activeMenus, setActiveMenus] = (0,
|
|
1012
|
+
const [activeMenus, setActiveMenus] = (0, import_react8.useState)(
|
|
942
1013
|
{}
|
|
943
1014
|
);
|
|
944
|
-
const [activeMenu, setActiveMenu] = (0,
|
|
945
|
-
const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0,
|
|
1015
|
+
const [activeMenu, setActiveMenu] = (0, import_react8.useState)("");
|
|
1016
|
+
const [currentSubMenuLevel, setCurrentSubMenuLevel] = (0, import_react8.useState)(
|
|
946
1017
|
null
|
|
947
1018
|
);
|
|
948
|
-
const menuRootRef = (0,
|
|
949
|
-
const subMenuRefs = (0,
|
|
950
|
-
const hoverTimeoutRef = (0,
|
|
951
|
-
const closeTimeoutRef = (0,
|
|
952
|
-
const mouseStopTimeoutRef = (0,
|
|
953
|
-
const isMouseMovingRef = (0,
|
|
954
|
-
const pendingOpenActionRef = (0,
|
|
955
|
-
const pendingCloseActionRef = (0,
|
|
1019
|
+
const menuRootRef = (0, import_react8.useRef)(null);
|
|
1020
|
+
const subMenuRefs = (0, import_react8.useRef)({});
|
|
1021
|
+
const hoverTimeoutRef = (0, import_react8.useRef)(null);
|
|
1022
|
+
const closeTimeoutRef = (0, import_react8.useRef)(null);
|
|
1023
|
+
const mouseStopTimeoutRef = (0, import_react8.useRef)(null);
|
|
1024
|
+
const isMouseMovingRef = (0, import_react8.useRef)(false);
|
|
1025
|
+
const pendingOpenActionRef = (0, import_react8.useRef)(null);
|
|
1026
|
+
const pendingCloseActionRef = (0, import_react8.useRef)(null);
|
|
956
1027
|
const isMobile = useMatchesMobile();
|
|
957
1028
|
const toggleMenu = (menuId, level) => {
|
|
958
1029
|
if (closeTimeoutRef.current) {
|
|
@@ -992,7 +1063,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
992
1063
|
return newActiveMenus;
|
|
993
1064
|
});
|
|
994
1065
|
};
|
|
995
|
-
const executePendingActions = (0,
|
|
1066
|
+
const executePendingActions = (0, import_react8.useCallback)(() => {
|
|
996
1067
|
if (pendingCloseActionRef.current) {
|
|
997
1068
|
pendingCloseActionRef.current();
|
|
998
1069
|
pendingCloseActionRef.current = null;
|
|
@@ -1081,7 +1152,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
1081
1152
|
const isMenuActive = (menuId, level) => {
|
|
1082
1153
|
return activeMenus[level] === menuId;
|
|
1083
1154
|
};
|
|
1084
|
-
(0,
|
|
1155
|
+
(0, import_react8.useEffect)(() => {
|
|
1085
1156
|
const handleClickOutside = (event) => {
|
|
1086
1157
|
var _a;
|
|
1087
1158
|
if (Object.keys(activeMenus).length === 0) return;
|
|
@@ -1100,7 +1171,7 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
1100
1171
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1101
1172
|
};
|
|
1102
1173
|
}, [activeMenus]);
|
|
1103
|
-
(0,
|
|
1174
|
+
(0, import_react8.useEffect)(() => {
|
|
1104
1175
|
return () => {
|
|
1105
1176
|
if (hoverTimeoutRef.current) {
|
|
1106
1177
|
clearTimeout(hoverTimeoutRef.current);
|
|
@@ -1178,13 +1249,13 @@ function useSubMenuSystem(mobilePositionTo) {
|
|
|
1178
1249
|
};
|
|
1179
1250
|
}
|
|
1180
1251
|
function useMenuPosition(elementRef, position = "bottom", options) {
|
|
1181
|
-
const [menuPosition, setMenuPosition] = (0,
|
|
1252
|
+
const [menuPosition, setMenuPosition] = (0, import_react8.useState)({
|
|
1182
1253
|
top: 0,
|
|
1183
1254
|
left: 0,
|
|
1184
1255
|
minWidth: 0
|
|
1185
1256
|
});
|
|
1186
1257
|
const isMobile = options == null ? void 0 : options.isMobile;
|
|
1187
|
-
const updatePosition = (0,
|
|
1258
|
+
const updatePosition = (0, import_react8.useCallback)(() => {
|
|
1188
1259
|
var _a, _b, _c;
|
|
1189
1260
|
if (!(elementRef == null ? void 0 : elementRef.current)) return;
|
|
1190
1261
|
const triggerRect = elementRef.current.getBoundingClientRect();
|
|
@@ -1232,7 +1303,7 @@ function useMenuPosition(elementRef, position = "bottom", options) {
|
|
|
1232
1303
|
minWidth: triggerRect.width
|
|
1233
1304
|
});
|
|
1234
1305
|
}, [elementRef, position, options == null ? void 0 : options.menuRef, options == null ? void 0 : options.topOffset, isMobile]);
|
|
1235
|
-
(0,
|
|
1306
|
+
(0, import_react8.useEffect)(() => {
|
|
1236
1307
|
if (!(options == null ? void 0 : options.isOpen) || !(options == null ? void 0 : options.setIsOpen)) return;
|
|
1237
1308
|
const handleClickOutside = (event) => {
|
|
1238
1309
|
var _a, _b, _c, _d, _e;
|
|
@@ -1258,7 +1329,7 @@ function useMenuPosition(elementRef, position = "bottom", options) {
|
|
|
1258
1329
|
options == null ? void 0 : options.menuRef,
|
|
1259
1330
|
options == null ? void 0 : options.additionalRefs
|
|
1260
1331
|
]);
|
|
1261
|
-
(0,
|
|
1332
|
+
(0, import_react8.useEffect)(() => {
|
|
1262
1333
|
updatePosition();
|
|
1263
1334
|
const resizeObserver = new ResizeObserver(updatePosition);
|
|
1264
1335
|
if (elementRef == null ? void 0 : elementRef.current) {
|
|
@@ -1275,29 +1346,6 @@ function useMenuPosition(elementRef, position = "bottom", options) {
|
|
|
1275
1346
|
return { menuPosition, updatePosition };
|
|
1276
1347
|
}
|
|
1277
1348
|
|
|
1278
|
-
// src/utils.ts
|
|
1279
|
-
function findDocumentRoot(element) {
|
|
1280
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1281
|
-
throw new Error(
|
|
1282
|
-
"findDocumentRoot can only be used in a browser environment."
|
|
1283
|
-
);
|
|
1284
|
-
}
|
|
1285
|
-
if (!element || !(element instanceof Node)) {
|
|
1286
|
-
return window.document.body;
|
|
1287
|
-
}
|
|
1288
|
-
let currentElement = element;
|
|
1289
|
-
while (currentElement && currentElement.parentNode) {
|
|
1290
|
-
if (currentElement.parentNode === document) {
|
|
1291
|
-
return document.body;
|
|
1292
|
-
} else if (currentElement.parentNode instanceof DocumentFragment) {
|
|
1293
|
-
return currentElement.parentNode;
|
|
1294
|
-
} else {
|
|
1295
|
-
currentElement = currentElement.parentNode;
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
return window.document.body;
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
1349
|
// src/components/Menu.tsx
|
|
1302
1350
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1303
1351
|
var Menu = (_a) => {
|
|
@@ -1340,9 +1388,9 @@ var Menu = (_a) => {
|
|
|
1340
1388
|
"menuName",
|
|
1341
1389
|
"calculateMinMaxHeight"
|
|
1342
1390
|
]);
|
|
1343
|
-
const internalRef = (0,
|
|
1391
|
+
const internalRef = (0, import_react9.useRef)(null);
|
|
1344
1392
|
const actualRef = ref || internalRef;
|
|
1345
|
-
const [maxHeight, setMaxHeight] = (0,
|
|
1393
|
+
const [maxHeight, setMaxHeight] = (0, import_react9.useState)("180px");
|
|
1346
1394
|
const isMobile = useMatchesMobile();
|
|
1347
1395
|
const { menuPosition, updatePosition } = useMenuPosition(
|
|
1348
1396
|
isMobile && mobilePositionTo ? mobilePositionTo : positionTo,
|
|
@@ -1355,7 +1403,7 @@ var Menu = (_a) => {
|
|
|
1355
1403
|
isMobile: !!(isMobile && mobilePositionTo)
|
|
1356
1404
|
}
|
|
1357
1405
|
);
|
|
1358
|
-
(0,
|
|
1406
|
+
(0, import_react9.useEffect)(() => {
|
|
1359
1407
|
if (calculateMinMaxHeight) {
|
|
1360
1408
|
return;
|
|
1361
1409
|
}
|
|
@@ -1379,7 +1427,7 @@ var Menu = (_a) => {
|
|
|
1379
1427
|
cancelAnimationFrame(raf);
|
|
1380
1428
|
};
|
|
1381
1429
|
}, [actualRef.current, customMaxHeight, calculateMinMaxHeight]);
|
|
1382
|
-
(0,
|
|
1430
|
+
(0, import_react9.useEffect)(() => {
|
|
1383
1431
|
if (!calculateMinMaxHeight) {
|
|
1384
1432
|
return;
|
|
1385
1433
|
}
|
|
@@ -1390,14 +1438,14 @@ var Menu = (_a) => {
|
|
|
1390
1438
|
setMaxHeight(`${calculatedMaxHeight}px`);
|
|
1391
1439
|
}
|
|
1392
1440
|
}, [actualRef.current, positionTo == null ? void 0 : positionTo.current, calculateMinMaxHeight]);
|
|
1393
|
-
(0,
|
|
1441
|
+
(0, import_react9.useEffect)(() => {
|
|
1394
1442
|
if (!show) {
|
|
1395
1443
|
return;
|
|
1396
1444
|
}
|
|
1397
1445
|
initializeMenuFocus();
|
|
1398
1446
|
updatePosition();
|
|
1399
1447
|
}, [show, updatePosition]);
|
|
1400
|
-
(0,
|
|
1448
|
+
(0, import_react9.useEffect)(() => {
|
|
1401
1449
|
if (!show || !setShow) {
|
|
1402
1450
|
return;
|
|
1403
1451
|
}
|
|
@@ -1552,7 +1600,7 @@ Menu.displayName = "Menu";
|
|
|
1552
1600
|
|
|
1553
1601
|
// src/components/MenuOption.tsx
|
|
1554
1602
|
var import_clsx7 = __toESM(require("clsx"), 1);
|
|
1555
|
-
var
|
|
1603
|
+
var import_react10 = require("react");
|
|
1556
1604
|
|
|
1557
1605
|
// src/components/Paragraph.tsx
|
|
1558
1606
|
var import_clsx6 = __toESM(require("clsx"), 1);
|
|
@@ -1635,10 +1683,10 @@ var MenuOption = ({
|
|
|
1635
1683
|
menuValue,
|
|
1636
1684
|
onMouseMove
|
|
1637
1685
|
}) => {
|
|
1638
|
-
const uniqueId = (0,
|
|
1639
|
-
const internalRef = (0,
|
|
1686
|
+
const uniqueId = (0, import_react10.useId)();
|
|
1687
|
+
const internalRef = (0, import_react10.useRef)(null);
|
|
1640
1688
|
const actualRef = ref || internalRef;
|
|
1641
|
-
const menuId = (0,
|
|
1689
|
+
const menuId = (0, import_react10.useRef)(`menu-${uniqueId}`);
|
|
1642
1690
|
const isMobile = useMatchesMobile();
|
|
1643
1691
|
const handleMouseEnter = () => {
|
|
1644
1692
|
if (subMenu && onSubMenuHover && !disabled) {
|
|
@@ -1789,7 +1837,7 @@ function highlightMatch(text, searchValue) {
|
|
|
1789
1837
|
|
|
1790
1838
|
// src/components/DataGridCell.tsx
|
|
1791
1839
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1792
|
-
var DataGridCell = (0,
|
|
1840
|
+
var DataGridCell = (0, import_react11.memo)(
|
|
1793
1841
|
(_a) => {
|
|
1794
1842
|
var _b = _a, {
|
|
1795
1843
|
id,
|
|
@@ -1827,10 +1875,10 @@ var DataGridCell = (0, import_react10.memo)(
|
|
|
1827
1875
|
"testid"
|
|
1828
1876
|
]);
|
|
1829
1877
|
const Element = type === "header" ? "th" : "td";
|
|
1830
|
-
const timerRef = (0,
|
|
1831
|
-
const [isGrabbing, setIsGrabbing] = (0,
|
|
1832
|
-
const [isPointerPressed, setIsPointerPressed] = (0,
|
|
1833
|
-
(0,
|
|
1878
|
+
const timerRef = (0, import_react11.useRef)(null);
|
|
1879
|
+
const [isGrabbing, setIsGrabbing] = (0, import_react11.useState)(false);
|
|
1880
|
+
const [isPointerPressed, setIsPointerPressed] = (0, import_react11.useState)(false);
|
|
1881
|
+
(0, import_react11.useEffect)(() => {
|
|
1834
1882
|
return () => {
|
|
1835
1883
|
if (timerRef.current) {
|
|
1836
1884
|
clearTimeout(timerRef.current);
|
|
@@ -1939,12 +1987,12 @@ function DataCellHeader(_a) {
|
|
|
1939
1987
|
"useMenuDefaultMinWidth"
|
|
1940
1988
|
]);
|
|
1941
1989
|
var _a2, _b2, _c;
|
|
1942
|
-
const [showMenu, setShowMenu] = (0,
|
|
1943
|
-
const [filter, setFilter] = (0,
|
|
1990
|
+
const [showMenu, setShowMenu] = (0, import_react11.useState)(false);
|
|
1991
|
+
const [filter, setFilter] = (0, import_react11.useState)(
|
|
1944
1992
|
(_a2 = header.column.getFilterValue()) != null ? _a2 : ""
|
|
1945
1993
|
);
|
|
1946
|
-
const ref = (0,
|
|
1947
|
-
const predeterminedPinned = (0,
|
|
1994
|
+
const ref = (0, import_react11.useRef)(null);
|
|
1995
|
+
const predeterminedPinned = (0, import_react11.useRef)(false);
|
|
1948
1996
|
const {
|
|
1949
1997
|
menuRootRef,
|
|
1950
1998
|
isMenuActive,
|
|
@@ -1952,7 +2000,7 @@ function DataCellHeader(_a) {
|
|
|
1952
2000
|
listeners: subMenuListeners,
|
|
1953
2001
|
mobileHide
|
|
1954
2002
|
} = useSubMenuSystem(node ? node : ref);
|
|
1955
|
-
(0,
|
|
2003
|
+
(0, import_react11.useEffect)(() => {
|
|
1956
2004
|
var _a3;
|
|
1957
2005
|
const columnPinning = (_a3 = header.getContext().table.options.initialState) == null ? void 0 : _a3.columnPinning;
|
|
1958
2006
|
const left = (columnPinning == null ? void 0 : columnPinning.left) ? columnPinning.left : [];
|
|
@@ -1961,7 +2009,7 @@ function DataCellHeader(_a) {
|
|
|
1961
2009
|
header.column.id
|
|
1962
2010
|
);
|
|
1963
2011
|
}, []);
|
|
1964
|
-
(0,
|
|
2012
|
+
(0, import_react11.useEffect)(() => {
|
|
1965
2013
|
const handler = setTimeout(() => {
|
|
1966
2014
|
header.column.setFilterValue(filter);
|
|
1967
2015
|
}, 500);
|
|
@@ -2235,7 +2283,7 @@ function DragAlongCell(_a) {
|
|
|
2235
2283
|
DragAlongCell.displayName = "DragAlongCell";
|
|
2236
2284
|
|
|
2237
2285
|
// src/components/DataGrid/index.tsx
|
|
2238
|
-
var
|
|
2286
|
+
var import_react16 = __toESM(require("react"), 1);
|
|
2239
2287
|
var import_react_table3 = require("@tanstack/react-table");
|
|
2240
2288
|
var import_core = require("@dnd-kit/core");
|
|
2241
2289
|
var import_sortable2 = require("@dnd-kit/sortable");
|
|
@@ -2263,7 +2311,7 @@ function getSortIcon(sort, nextSort = false) {
|
|
|
2263
2311
|
}
|
|
2264
2312
|
|
|
2265
2313
|
// src/components/DataGrid/PinnedColumns.tsx
|
|
2266
|
-
var
|
|
2314
|
+
var import_react15 = __toESM(require("react"), 1);
|
|
2267
2315
|
|
|
2268
2316
|
// src/components/DataGrid/TableBody/index.tsx
|
|
2269
2317
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
@@ -2272,7 +2320,7 @@ var import_clsx11 = __toESM(require("clsx"), 1);
|
|
|
2272
2320
|
// src/components/DataGrid/TableBody/TableBodyRow.tsx
|
|
2273
2321
|
var import_clsx10 = __toESM(require("clsx"), 1);
|
|
2274
2322
|
var import_react_table = require("@tanstack/react-table");
|
|
2275
|
-
var
|
|
2323
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
2276
2324
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2277
2325
|
function TableBodyRow({
|
|
2278
2326
|
id,
|
|
@@ -2328,7 +2376,7 @@ function TableBodyRow({
|
|
|
2328
2376
|
return;
|
|
2329
2377
|
}
|
|
2330
2378
|
const cellValue = cell.getValue();
|
|
2331
|
-
return ((_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.useCustomRenderer) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2379
|
+
return ((_a2 = cell.column.columnDef.meta) == null ? void 0 : _a2.useCustomRenderer) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react12.default.Fragment, { children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()) }, cell.id) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2332
2380
|
CellElement,
|
|
2333
2381
|
{
|
|
2334
2382
|
id: id ? `${id}-row-${row.id}-cell-${cell.id}` : void 0,
|
|
@@ -2532,10 +2580,10 @@ function TableBody({
|
|
|
2532
2580
|
}
|
|
2533
2581
|
|
|
2534
2582
|
// src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx
|
|
2535
|
-
var
|
|
2583
|
+
var import_react14 = require("react");
|
|
2536
2584
|
|
|
2537
2585
|
// src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx
|
|
2538
|
-
var
|
|
2586
|
+
var import_react13 = require("react");
|
|
2539
2587
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2540
2588
|
function ColumnSelectorMenuOption({
|
|
2541
2589
|
id,
|
|
@@ -2543,7 +2591,7 @@ function ColumnSelectorMenuOption({
|
|
|
2543
2591
|
column,
|
|
2544
2592
|
toggleColumnVisibility
|
|
2545
2593
|
}) {
|
|
2546
|
-
const [isVisible, setIsVisible] = (0,
|
|
2594
|
+
const [isVisible, setIsVisible] = (0, import_react13.useState)(column.getIsVisible());
|
|
2547
2595
|
const label = typeof column.columnDef.header === "string" ? column.columnDef.header : null;
|
|
2548
2596
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MenuOption, { id, testid, selected: isVisible, defaultChecked: isVisible, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2549
2597
|
Checkbox,
|
|
@@ -2569,8 +2617,8 @@ function ColumnSelectorHeaderCell({
|
|
|
2569
2617
|
toggleColumnVisibility,
|
|
2570
2618
|
resetColumnVisibility
|
|
2571
2619
|
}) {
|
|
2572
|
-
const ref = (0,
|
|
2573
|
-
const [show, setShow] = (0,
|
|
2620
|
+
const ref = (0, import_react14.useRef)(null);
|
|
2621
|
+
const [show, setShow] = (0, import_react14.useState)(false);
|
|
2574
2622
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
2575
2623
|
DataGridCell,
|
|
2576
2624
|
{
|
|
@@ -2733,7 +2781,7 @@ function PinnedColumns(_a) {
|
|
|
2733
2781
|
header.id
|
|
2734
2782
|
);
|
|
2735
2783
|
}
|
|
2736
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
2784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react15.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)(
|
|
2737
2785
|
Checkbox,
|
|
2738
2786
|
{
|
|
2739
2787
|
checked: allSelectedAcrossPages,
|
|
@@ -2811,12 +2859,29 @@ function DataGrid({
|
|
|
2811
2859
|
useMenuDefaultMinWidth
|
|
2812
2860
|
}) {
|
|
2813
2861
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2814
|
-
const [
|
|
2815
|
-
|
|
2862
|
+
const [localSorting, setLocalSorting] = (0, import_react16.useState)([]);
|
|
2863
|
+
const [localColumnFilters, setLocalColumnFilters] = (0, import_react16.useState)([]);
|
|
2864
|
+
const [localRowSelection, setLocalRowSelection] = (0, import_react16.useState)({});
|
|
2865
|
+
const {
|
|
2866
|
+
columns: tableColumns,
|
|
2867
|
+
setColumns: setTableColumns,
|
|
2868
|
+
layoutSignal
|
|
2869
|
+
} = useTableLayout(columns, id != null ? id : testid);
|
|
2870
|
+
const [columnOrder, setColumnOrder] = (0, import_react16.useState)(
|
|
2871
|
+
tableColumns.map((c) => c.id)
|
|
2872
|
+
);
|
|
2873
|
+
const [columnVisibility, setColumnVisibility] = (0, import_react16.useState)(
|
|
2874
|
+
Object.fromEntries(
|
|
2875
|
+
tableColumns.filter((column) => !!column.id).map((column) => {
|
|
2876
|
+
var _a2, _b2;
|
|
2877
|
+
return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
|
|
2878
|
+
})
|
|
2879
|
+
)
|
|
2816
2880
|
);
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2881
|
+
(0, import_react16.useEffect)(() => {
|
|
2882
|
+
setColumnOrder(tableColumns.map((c) => c.id));
|
|
2883
|
+
resetColumnVisibility();
|
|
2884
|
+
}, [layoutSignal]);
|
|
2820
2885
|
const sortingState = pagination ? externalSorting != null ? externalSorting : localSorting : localSorting;
|
|
2821
2886
|
const setSortingState = pagination ? (updaterOrValue) => {
|
|
2822
2887
|
const value = typeof updaterOrValue === "function" ? updaterOrValue(
|
|
@@ -2834,38 +2899,34 @@ function DataGrid({
|
|
|
2834
2899
|
const value = typeof updaterOrValue === "function" ? updaterOrValue(externalRowSelection != null ? externalRowSelection : {}) : updaterOrValue;
|
|
2835
2900
|
(onRowSelectionChange != null ? onRowSelectionChange : setLocalRowSelection)(value);
|
|
2836
2901
|
} : setLocalRowSelection;
|
|
2837
|
-
const dndId = (0,
|
|
2838
|
-
const containerRef =
|
|
2839
|
-
const
|
|
2840
|
-
const initialVisibility = {};
|
|
2841
|
-
columns.forEach((column) => {
|
|
2842
|
-
var _a2, _b2;
|
|
2843
|
-
if (column.id) {
|
|
2844
|
-
initialVisibility[column.id] = (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true;
|
|
2845
|
-
}
|
|
2846
|
-
});
|
|
2847
|
-
return initialVisibility;
|
|
2848
|
-
});
|
|
2849
|
-
const toggleColumnVisibility = (0, import_react15.useCallback)(
|
|
2902
|
+
const dndId = (0, import_react16.useId)();
|
|
2903
|
+
const containerRef = import_react16.default.useRef(null);
|
|
2904
|
+
const toggleColumnVisibility = (0, import_react16.useCallback)(
|
|
2850
2905
|
(columnId, isVisible) => {
|
|
2851
|
-
|
|
2906
|
+
setTableColumns((prev) => {
|
|
2907
|
+
const persistedIndex = prev.findIndex((col) => col.id === columnId);
|
|
2908
|
+
if (persistedIndex !== -1) {
|
|
2909
|
+
prev[persistedIndex].meta = __spreadProps(__spreadValues({}, prev[persistedIndex].meta), {
|
|
2910
|
+
visible: isVisible
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2913
|
+
return [...prev];
|
|
2914
|
+
}, true);
|
|
2852
2915
|
},
|
|
2853
|
-
[
|
|
2916
|
+
[setTableColumns]
|
|
2854
2917
|
);
|
|
2855
|
-
const resetColumnVisibility = (0,
|
|
2856
|
-
setColumnVisibility(
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
});
|
|
2866
|
-
}, [columns]);
|
|
2918
|
+
const resetColumnVisibility = (0, import_react16.useCallback)(() => {
|
|
2919
|
+
setColumnVisibility(
|
|
2920
|
+
Object.fromEntries(
|
|
2921
|
+
tableColumns.filter((column) => !!column.id).map((column) => {
|
|
2922
|
+
var _a2, _b2;
|
|
2923
|
+
return [column.id, (_b2 = (_a2 = column.meta) == null ? void 0 : _a2.visible) != null ? _b2 : true];
|
|
2924
|
+
})
|
|
2925
|
+
)
|
|
2926
|
+
);
|
|
2927
|
+
}, [tableColumns]);
|
|
2867
2928
|
const table = (0, import_react_table3.useReactTable)({
|
|
2868
|
-
columns,
|
|
2929
|
+
columns: tableColumns,
|
|
2869
2930
|
data,
|
|
2870
2931
|
getCoreRowModel: (0, import_react_table3.getCoreRowModel)(),
|
|
2871
2932
|
getSortedRowModel: (0, import_react_table3.getSortedRowModel)(),
|
|
@@ -2949,7 +3010,12 @@ function DataGrid({
|
|
|
2949
3010
|
setColumnOrder((prev) => {
|
|
2950
3011
|
const oldIndex = prev.indexOf(active.id);
|
|
2951
3012
|
const newIndex = prev.indexOf(over.id);
|
|
2952
|
-
|
|
3013
|
+
const newOrder = (0, import_sortable2.arrayMove)(prev, oldIndex, newIndex);
|
|
3014
|
+
setTableColumns((prev2) => {
|
|
3015
|
+
const res = newOrder.map((id2) => prev2.find((col) => col.id === id2)).filter(Boolean);
|
|
3016
|
+
return res;
|
|
3017
|
+
});
|
|
3018
|
+
return newOrder;
|
|
2953
3019
|
});
|
|
2954
3020
|
}
|
|
2955
3021
|
};
|
|
@@ -3092,7 +3158,7 @@ function DataGrid({
|
|
|
3092
3158
|
header.id
|
|
3093
3159
|
);
|
|
3094
3160
|
}
|
|
3095
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react16.default.Fragment, { children: ((_d2 = header.column.columnDef.meta) == null ? void 0 : _d2.checkbox) ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3096
3162
|
DataGridCell,
|
|
3097
3163
|
{
|
|
3098
3164
|
id: id ? `${id}-header-${header.id}` : void 0,
|
|
@@ -3296,7 +3362,7 @@ function adaptTableStateSetter(setter) {
|
|
|
3296
3362
|
}
|
|
3297
3363
|
|
|
3298
3364
|
// src/components/Select.tsx
|
|
3299
|
-
var
|
|
3365
|
+
var import_react17 = require("react");
|
|
3300
3366
|
var import_clsx14 = __toESM(require("clsx"), 1);
|
|
3301
3367
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3302
3368
|
var Select = (_a) => {
|
|
@@ -3329,11 +3395,11 @@ var Select = (_a) => {
|
|
|
3329
3395
|
"displayValue",
|
|
3330
3396
|
"value"
|
|
3331
3397
|
]);
|
|
3332
|
-
const inputRef = (0,
|
|
3333
|
-
const inputContainerRef = (0,
|
|
3334
|
-
const preventFocusOnInitialRender = (0,
|
|
3335
|
-
const [show, setShow] = (0,
|
|
3336
|
-
(0,
|
|
3398
|
+
const inputRef = (0, import_react17.useRef)(null);
|
|
3399
|
+
const inputContainerRef = (0, import_react17.useRef)(null);
|
|
3400
|
+
const preventFocusOnInitialRender = (0, import_react17.useRef)(true);
|
|
3401
|
+
const [show, setShow] = (0, import_react17.useState)(false);
|
|
3402
|
+
(0, import_react17.useEffect)(() => {
|
|
3337
3403
|
var _a2;
|
|
3338
3404
|
if (preventFocusOnInitialRender.current) {
|
|
3339
3405
|
preventFocusOnInitialRender.current = false;
|
|
@@ -3712,7 +3778,7 @@ Button.displayName = "Button";
|
|
|
3712
3778
|
|
|
3713
3779
|
// src/components/Tooltip.tsx
|
|
3714
3780
|
var import_clsx18 = __toESM(require("clsx"), 1);
|
|
3715
|
-
var
|
|
3781
|
+
var import_react18 = require("react");
|
|
3716
3782
|
var import_react_dom2 = require("react-dom");
|
|
3717
3783
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3718
3784
|
var Tooltip = ({
|
|
@@ -3725,11 +3791,11 @@ var Tooltip = ({
|
|
|
3725
3791
|
offset = 8,
|
|
3726
3792
|
keepHidden = false
|
|
3727
3793
|
}) => {
|
|
3728
|
-
const ref = (0,
|
|
3729
|
-
const tooltipRef = (0,
|
|
3730
|
-
const [tooltipPosition, setTooltipPosition] = (0,
|
|
3731
|
-
const [isVisible, setIsVisible] = (0,
|
|
3732
|
-
const [removeOpacity, setRemoveOpacity] = (0,
|
|
3794
|
+
const ref = (0, import_react18.useRef)(null);
|
|
3795
|
+
const tooltipRef = (0, import_react18.useRef)(null);
|
|
3796
|
+
const [tooltipPosition, setTooltipPosition] = (0, import_react18.useState)({ top: 0, left: 0 });
|
|
3797
|
+
const [isVisible, setIsVisible] = (0, import_react18.useState)(false);
|
|
3798
|
+
const [removeOpacity, setRemoveOpacity] = (0, import_react18.useState)(false);
|
|
3733
3799
|
const updatePosition = () => {
|
|
3734
3800
|
if (!ref.current || !tooltipRef.current) return;
|
|
3735
3801
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -3768,14 +3834,14 @@ var Tooltip = ({
|
|
|
3768
3834
|
setIsVisible(false);
|
|
3769
3835
|
setRemoveOpacity(false);
|
|
3770
3836
|
};
|
|
3771
|
-
(0,
|
|
3837
|
+
(0, import_react18.useEffect)(() => {
|
|
3772
3838
|
if (isVisible && tooltipRef.current) {
|
|
3773
3839
|
requestAnimationFrame(() => {
|
|
3774
3840
|
updatePosition();
|
|
3775
3841
|
});
|
|
3776
3842
|
}
|
|
3777
3843
|
}, [isVisible]);
|
|
3778
|
-
(0,
|
|
3844
|
+
(0, import_react18.useEffect)(() => {
|
|
3779
3845
|
if (isVisible) {
|
|
3780
3846
|
window.addEventListener("resize", updatePosition);
|
|
3781
3847
|
return () => window.removeEventListener("resize", updatePosition);
|