@ctlyst.id/internal-ui 3.4.2 → 3.4.4
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.js +34 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1419,40 +1419,57 @@ var useDataTable = ({
|
|
1419
1419
|
};
|
1420
1420
|
};
|
1421
1421
|
var DataTable = React5.forwardRef((props, ref) => {
|
1422
|
-
var _a, _b, _c, _d;
|
1422
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
1423
1423
|
const { isLoading, styles, headerSticky, onRowClick, container, columnPinning } = props;
|
1424
1424
|
const { table, toggleAllRowsSelected, generateColumn } = useDataTable(props);
|
1425
1425
|
const refTable = React5.useRef(null);
|
1426
1426
|
React5.useImperativeHandle(ref, () => ({
|
1427
1427
|
toggleAllRowsSelected
|
1428
1428
|
}));
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
(_a2 = refTable.current) == null ? void 0 : _a2.setAttribute("data-pin-left", "true");
|
1435
|
-
} else {
|
1436
|
-
(_b2 = refTable.current) == null ? void 0 : _b2.removeAttribute("data-pin-left");
|
1437
|
-
}
|
1438
|
-
if (element.scrollLeft < element.scrollWidth - (lastPinnedColumn + element.offsetWidth)) {
|
1439
|
-
(_c2 = refTable.current) == null ? void 0 : _c2.setAttribute("data-pin-right", "true");
|
1429
|
+
const tableResizeHandler = () => {
|
1430
|
+
var _a2, _b2, _c2, _d2, _e2;
|
1431
|
+
if (((_a2 = refTable.current) == null ? void 0 : _a2.offsetWidth) === ((_b2 = refTable.current) == null ? void 0 : _b2.scrollWidth)) {
|
1432
|
+
(_c2 = refTable.current) == null ? void 0 : _c2.removeAttribute("data-pin-right");
|
1433
|
+
(_d2 = refTable.current) == null ? void 0 : _d2.removeAttribute("data-pin-left");
|
1440
1434
|
} else {
|
1441
|
-
(
|
1435
|
+
(_e2 = refTable.current) == null ? void 0 : _e2.setAttribute("data-pin-right", "true");
|
1442
1436
|
}
|
1443
|
-
}
|
1437
|
+
};
|
1438
|
+
let lastPinnedColumn = 0;
|
1439
|
+
React5.useEffect(() => {
|
1440
|
+
var _a2;
|
1441
|
+
(_a2 = refTable.current) == null ? void 0 : _a2.addEventListener("scroll", (s) => {
|
1442
|
+
var _a3, _b2, _c2, _d2;
|
1443
|
+
const element = s.currentTarget;
|
1444
|
+
if (element.scrollLeft > 0) {
|
1445
|
+
(_a3 = refTable.current) == null ? void 0 : _a3.setAttribute("data-pin-left", "true");
|
1446
|
+
} else {
|
1447
|
+
(_b2 = refTable.current) == null ? void 0 : _b2.removeAttribute("data-pin-left");
|
1448
|
+
}
|
1449
|
+
if (element.scrollLeft < element.scrollWidth - (lastPinnedColumn + element.offsetWidth)) {
|
1450
|
+
(_c2 = refTable.current) == null ? void 0 : _c2.setAttribute("data-pin-right", "true");
|
1451
|
+
} else {
|
1452
|
+
(_d2 = refTable.current) == null ? void 0 : _d2.removeAttribute("data-pin-right");
|
1453
|
+
}
|
1454
|
+
});
|
1455
|
+
window.addEventListener("resize", tableResizeHandler);
|
1456
|
+
return () => {
|
1457
|
+
window.removeEventListener("resize", tableResizeHandler);
|
1458
|
+
};
|
1459
|
+
}, []);
|
1460
|
+
const hasScroll = ((_a = refTable == null ? void 0 : refTable.current) == null ? void 0 : _a.offsetWidth) && ((_b = refTable == null ? void 0 : refTable.current) == null ? void 0 : _b.scrollWidth) && ((_c = refTable == null ? void 0 : refTable.current) == null ? void 0 : _c.offsetWidth) < ((_d = refTable == null ? void 0 : refTable.current) == null ? void 0 : _d.scrollWidth);
|
1444
1461
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
1445
1462
|
import_react28.Box,
|
1446
1463
|
{
|
1447
1464
|
overflowX: "auto",
|
1448
1465
|
overflowY: "hidden",
|
1449
1466
|
position: "relative",
|
1450
|
-
pl: ((
|
1451
|
-
pr: ((
|
1467
|
+
pl: ((_e = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _e.length) ? 0 : 4,
|
1468
|
+
pr: ((_f = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _f.length) ? 0 : 4,
|
1452
1469
|
maxW: "100%",
|
1453
1470
|
w: "full",
|
1454
1471
|
ref: refTable,
|
1455
|
-
...((
|
1472
|
+
...((_g = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _g.length) && hasScroll ? { "data-pin-right": true } : {},
|
1456
1473
|
...container,
|
1457
1474
|
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react28.Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
|
1458
1475
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react28.Thead, { ...(styles == null ? void 0 : styles.tableHead, headerSticky ? { position: "sticky", top: 0, bg: "white", zIndex: 1 } : {}), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react28.Tr, { mx: "2", ...styles == null ? void 0 : styles.tableRow, children: headerGroup.headers.map((header, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|