trotl-table 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +91 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +91 -13
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -9586,6 +9586,42 @@ const Modal = ({
|
|
|
9586
9586
|
}, confirmLabel))));
|
|
9587
9587
|
};
|
|
9588
9588
|
|
|
9589
|
+
// src/components/DotsLoading.jsx
|
|
9590
|
+
const style = `
|
|
9591
|
+
.dots-spinner {
|
|
9592
|
+
display: flex;
|
|
9593
|
+
justify-content: center;
|
|
9594
|
+
align-items: center;
|
|
9595
|
+
gap: 6px;
|
|
9596
|
+
height: 24px;
|
|
9597
|
+
}
|
|
9598
|
+
.dots-spinner div {
|
|
9599
|
+
width: 6px;
|
|
9600
|
+
height: 6px;
|
|
9601
|
+
border-radius: 50%;
|
|
9602
|
+
background-color: #2980B9;
|
|
9603
|
+
animation: dotPulse 1s infinite ease-in-out;
|
|
9604
|
+
}
|
|
9605
|
+
.dots-spinner div:nth-child(1) { animation-delay: 0s; }
|
|
9606
|
+
.dots-spinner div:nth-child(2) { animation-delay: 0.2s; }
|
|
9607
|
+
.dots-spinner div:nth-child(3) { animation-delay: 0.4s; }
|
|
9608
|
+
.dots-spinner div:nth-child(4) { animation-delay: 0.6s; }
|
|
9609
|
+
|
|
9610
|
+
@keyframes dotPulse {
|
|
9611
|
+
0%, 100% {
|
|
9612
|
+
transform: scale(1);
|
|
9613
|
+
opacity: 0.6;
|
|
9614
|
+
}
|
|
9615
|
+
50% {
|
|
9616
|
+
transform: scale(1.5);
|
|
9617
|
+
opacity: 1;
|
|
9618
|
+
}
|
|
9619
|
+
}
|
|
9620
|
+
`;
|
|
9621
|
+
const DotsLoading = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, style), /*#__PURE__*/React.createElement("div", {
|
|
9622
|
+
className: "dots-spinner"
|
|
9623
|
+
}, /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null), /*#__PURE__*/React.createElement("div", null)));
|
|
9624
|
+
|
|
9589
9625
|
const ITEM_TYPE = "ROW";
|
|
9590
9626
|
|
|
9591
9627
|
// Normalize data into grouped format
|
|
@@ -9772,6 +9808,8 @@ function TableInner({
|
|
|
9772
9808
|
const [localData, setLocalData] = React.useState(data);
|
|
9773
9809
|
React.useEffect(() => setLocalData(data), [data]);
|
|
9774
9810
|
const listRef = React.useRef(null);
|
|
9811
|
+
const headerRef = React.useRef(null);
|
|
9812
|
+
const [headerPadRight, setHeaderPadRight] = React.useState(0);
|
|
9775
9813
|
const normalizedGroups = React.useMemo(() => {
|
|
9776
9814
|
return normalizeData(isGrouped ? localData : [], isGrouped ? [] : localData);
|
|
9777
9815
|
}, [localData, isGrouped]);
|
|
@@ -9891,6 +9929,50 @@ function TableInner({
|
|
|
9891
9929
|
setTableDataFlat(flattened);
|
|
9892
9930
|
}, [flattened]);
|
|
9893
9931
|
|
|
9932
|
+
// Detect vertical scrollbar on react-virtualized grid and adjust header padding
|
|
9933
|
+
React.useEffect(() => {
|
|
9934
|
+
const el = listRef.current;
|
|
9935
|
+
if (!el) return;
|
|
9936
|
+
|
|
9937
|
+
// Try to find the actual scrollable grid element created by react-virtualized
|
|
9938
|
+
const grid = el.querySelector('.ReactVirtualized__Grid');
|
|
9939
|
+
const check = () => {
|
|
9940
|
+
if (!grid) {
|
|
9941
|
+
setHeaderPadRight(0);
|
|
9942
|
+
return;
|
|
9943
|
+
}
|
|
9944
|
+
const hasVerticalScroll = grid.scrollHeight > grid.clientHeight;
|
|
9945
|
+
// Compute scrollbar width if present
|
|
9946
|
+
const sbWidth = hasVerticalScroll ? grid.offsetWidth - grid.clientWidth : 0;
|
|
9947
|
+
// Fallback: typical scrollbar width ~17px on Windows
|
|
9948
|
+
const pad = hasVerticalScroll ? sbWidth > 0 ? sbWidth : 17 : 0;
|
|
9949
|
+
setHeaderPadRight(pad);
|
|
9950
|
+
};
|
|
9951
|
+
|
|
9952
|
+
// Initial check after next frame to allow grid mount
|
|
9953
|
+
const raf = requestAnimationFrame(check);
|
|
9954
|
+
|
|
9955
|
+
// Observe size changes
|
|
9956
|
+
const ro = new ResizeObserver(check);
|
|
9957
|
+
if (grid) ro.observe(grid);
|
|
9958
|
+
|
|
9959
|
+
// Observe content mutations (rows update)
|
|
9960
|
+
const mo = new MutationObserver(check);
|
|
9961
|
+
if (grid) mo.observe(grid, {
|
|
9962
|
+
childList: true,
|
|
9963
|
+
subtree: true
|
|
9964
|
+
});
|
|
9965
|
+
return () => {
|
|
9966
|
+
cancelAnimationFrame(raf);
|
|
9967
|
+
try {
|
|
9968
|
+
ro.disconnect();
|
|
9969
|
+
} catch {/* noop */}
|
|
9970
|
+
try {
|
|
9971
|
+
mo.disconnect();
|
|
9972
|
+
} catch {/* noop */}
|
|
9973
|
+
};
|
|
9974
|
+
}, [listRef, tableDataFlat.length]);
|
|
9975
|
+
|
|
9894
9976
|
// useEffect(() => setTableDataFlat(flattened), [flattened]);
|
|
9895
9977
|
React.useEffect(() => selectedRowsCallback(selectedRows), [selectedRows, selectedRowsCallback]);
|
|
9896
9978
|
|
|
@@ -10178,10 +10260,10 @@ function TableInner({
|
|
|
10178
10260
|
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10179
10261
|
className: "table-cell key-cell"
|
|
10180
10262
|
}, visualIndex), allColumns.map((col, i) => {
|
|
10181
|
-
let cellStyle = col.
|
|
10263
|
+
let cellStyle = col.style ? {
|
|
10182
10264
|
...col.style
|
|
10183
10265
|
} : undefined;
|
|
10184
|
-
if (col.
|
|
10266
|
+
if (col.style && col.style.width) {
|
|
10185
10267
|
cellStyle = cellStyle || {};
|
|
10186
10268
|
cellStyle.minWidth = col.style.width;
|
|
10187
10269
|
cellStyle.maxWidth = col.style.width;
|
|
@@ -10277,11 +10359,13 @@ function TableInner({
|
|
|
10277
10359
|
} : undefined
|
|
10278
10360
|
}, /*#__PURE__*/React.createElement("div", {
|
|
10279
10361
|
className: "table-header",
|
|
10362
|
+
ref: headerRef,
|
|
10280
10363
|
style: {
|
|
10281
10364
|
position: "sticky",
|
|
10282
10365
|
top: 0,
|
|
10283
10366
|
zIndex: 10,
|
|
10284
|
-
background: "#fff"
|
|
10367
|
+
background: "#fff",
|
|
10368
|
+
paddingRight: headerPadRight || undefined
|
|
10285
10369
|
}
|
|
10286
10370
|
}, /*#__PURE__*/React.createElement("div", {
|
|
10287
10371
|
className: "table-row header-row"
|
|
@@ -10301,17 +10385,13 @@ function TableInner({
|
|
|
10301
10385
|
})), showKey && /*#__PURE__*/React.createElement("div", {
|
|
10302
10386
|
className: "table-cell key-cell"
|
|
10303
10387
|
}, "#"), allColumns.map((col, i) => {
|
|
10304
|
-
|
|
10305
|
-
let cellStyle = col.isCustom && col.style ? {
|
|
10388
|
+
let cellStyle = col.style ? {
|
|
10306
10389
|
...col.style,
|
|
10307
|
-
cursor: undefined
|
|
10308
|
-
display: 'flex',
|
|
10309
|
-
alignItems: 'center',
|
|
10310
|
-
justifyContent: col.style.textAlign === 'center' ? 'center' : col.style.textAlign === 'right' ? 'flex-end' : 'flex-start'
|
|
10390
|
+
cursor: col.isCustom ? undefined : "pointer"
|
|
10311
10391
|
} : {
|
|
10312
10392
|
cursor: col.isCustom ? undefined : "pointer"
|
|
10313
10393
|
};
|
|
10314
|
-
if (col.
|
|
10394
|
+
if (col.style && col.style.width) {
|
|
10315
10395
|
cellStyle.minWidth = col.style.width;
|
|
10316
10396
|
cellStyle.maxWidth = col.style.width;
|
|
10317
10397
|
cellStyle.width = col.style.width;
|
|
@@ -10327,9 +10407,7 @@ function TableInner({
|
|
|
10327
10407
|
}, "Action"))), /*#__PURE__*/React.createElement("div", {
|
|
10328
10408
|
className: "main-table",
|
|
10329
10409
|
ref: listRef
|
|
10330
|
-
}, tableDataFlat.length === 0 ? /*#__PURE__*/React.createElement(
|
|
10331
|
-
className: "table-empty"
|
|
10332
|
-
}, "No items") : /*#__PURE__*/React.createElement(AutoSizer, null, ({
|
|
10410
|
+
}, tableDataFlat.length === 0 ? /*#__PURE__*/React.createElement(DotsLoading, null) : /*#__PURE__*/React.createElement(AutoSizer, null, ({
|
|
10333
10411
|
height,
|
|
10334
10412
|
width
|
|
10335
10413
|
}) => /*#__PURE__*/React.createElement(List, {
|