@ctlyst.id/internal-ui 3.4.3 → 3.4.5
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +31 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1280,6 +1280,7 @@ var getCommonPinningStyles = (column) => {
|
|
1280
1280
|
const isFirstLeftPinnedColumn = isPinned === "left" && column.getIsFirstColumn("left");
|
1281
1281
|
const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
|
1282
1282
|
const isFirstRightPinnedColumn = isPinned === "right" && column.getIsFirstColumn("right");
|
1283
|
+
const isLastRightPinnedColumn = isPinned === "right" && column.getIsLastColumn("right");
|
1283
1284
|
return {
|
1284
1285
|
left: isPinned === "left" ? `${column.getStart("left")}px` : void 0,
|
1285
1286
|
right: isPinned === "right" ? `${column.getAfter("right")}px` : void 0,
|
@@ -1289,6 +1290,9 @@ var getCommonPinningStyles = (column) => {
|
|
1289
1290
|
...isFirstLeftPinnedColumn ? {
|
1290
1291
|
pl: "16px"
|
1291
1292
|
} : { pl: "8px" },
|
1293
|
+
...isLastRightPinnedColumn ? {
|
1294
|
+
pr: "16px"
|
1295
|
+
} : { pr: "8px" },
|
1292
1296
|
...isLastLeftPinnedColumn ? {
|
1293
1297
|
py: "16px",
|
1294
1298
|
pr: "8px",
|
@@ -1308,7 +1312,7 @@ var getCommonPinningStyles = (column) => {
|
|
1308
1312
|
} : {},
|
1309
1313
|
...isFirstRightPinnedColumn ? {
|
1310
1314
|
py: "16px",
|
1311
|
-
|
1315
|
+
pl: "8px",
|
1312
1316
|
"&:after": {
|
1313
1317
|
transition: "all 0.3s",
|
1314
1318
|
content: "''",
|
@@ -1419,18 +1423,27 @@ var useDataTable = ({
|
|
1419
1423
|
};
|
1420
1424
|
};
|
1421
1425
|
var DataTable = React5.forwardRef((props, ref) => {
|
1422
|
-
var _a, _b;
|
1426
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
1423
1427
|
const { isLoading, styles, headerSticky, onRowClick, container, columnPinning } = props;
|
1424
1428
|
const { table, toggleAllRowsSelected, generateColumn } = useDataTable(props);
|
1425
1429
|
const refTable = React5.useRef(null);
|
1426
1430
|
React5.useImperativeHandle(ref, () => ({
|
1427
1431
|
toggleAllRowsSelected
|
1428
1432
|
}));
|
1433
|
+
const tableResizeHandler = () => {
|
1434
|
+
var _a2, _b2, _c2, _d2, _e2;
|
1435
|
+
if (((_a2 = refTable.current) == null ? void 0 : _a2.offsetWidth) === ((_b2 = refTable.current) == null ? void 0 : _b2.scrollWidth)) {
|
1436
|
+
(_c2 = refTable.current) == null ? void 0 : _c2.removeAttribute("data-pin-right");
|
1437
|
+
(_d2 = refTable.current) == null ? void 0 : _d2.removeAttribute("data-pin-left");
|
1438
|
+
} else {
|
1439
|
+
(_e2 = refTable.current) == null ? void 0 : _e2.setAttribute("data-pin-right", "true");
|
1440
|
+
}
|
1441
|
+
};
|
1429
1442
|
let lastPinnedColumn = 0;
|
1430
1443
|
React5.useEffect(() => {
|
1431
1444
|
var _a2;
|
1432
1445
|
(_a2 = refTable.current) == null ? void 0 : _a2.addEventListener("scroll", (s) => {
|
1433
|
-
var _a3, _b2,
|
1446
|
+
var _a3, _b2, _c2, _d2;
|
1434
1447
|
const element = s.currentTarget;
|
1435
1448
|
if (element.scrollLeft > 0) {
|
1436
1449
|
(_a3 = refTable.current) == null ? void 0 : _a3.setAttribute("data-pin-left", "true");
|
@@ -1438,32 +1451,29 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1438
1451
|
(_b2 = refTable.current) == null ? void 0 : _b2.removeAttribute("data-pin-left");
|
1439
1452
|
}
|
1440
1453
|
if (element.scrollLeft < element.scrollWidth - (lastPinnedColumn + element.offsetWidth)) {
|
1441
|
-
(
|
1454
|
+
(_c2 = refTable.current) == null ? void 0 : _c2.setAttribute("data-pin-right", "true");
|
1442
1455
|
} else {
|
1443
|
-
(
|
1444
|
-
}
|
1445
|
-
});
|
1446
|
-
window.addEventListener("resize", (ev) => {
|
1447
|
-
var _a3, _b2, _c, _d, _e;
|
1448
|
-
if (((_a3 = refTable.current) == null ? void 0 : _a3.offsetWidth) === ((_b2 = refTable.current) == null ? void 0 : _b2.scrollWidth)) {
|
1449
|
-
(_c = refTable.current) == null ? void 0 : _c.removeAttribute("data-pin-right");
|
1450
|
-
(_d = refTable.current) == null ? void 0 : _d.removeAttribute("data-pin-left");
|
1451
|
-
} else {
|
1452
|
-
(_e = refTable.current) == null ? void 0 : _e.setAttribute("data-pin-right", "true");
|
1456
|
+
(_d2 = refTable.current) == null ? void 0 : _d2.removeAttribute("data-pin-right");
|
1453
1457
|
}
|
1454
1458
|
});
|
1459
|
+
window.addEventListener("resize", tableResizeHandler);
|
1460
|
+
return () => {
|
1461
|
+
window.removeEventListener("resize", tableResizeHandler);
|
1462
|
+
};
|
1455
1463
|
}, []);
|
1464
|
+
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);
|
1456
1465
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
1457
1466
|
import_react28.Box,
|
1458
1467
|
{
|
1459
1468
|
overflowX: "auto",
|
1460
1469
|
overflowY: "hidden",
|
1461
1470
|
position: "relative",
|
1462
|
-
pl: ((
|
1463
|
-
pr: ((
|
1471
|
+
pl: ((_e = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _e.length) ? 0 : 4,
|
1472
|
+
pr: ((_f = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _f.length) ? 0 : 4,
|
1464
1473
|
maxW: "100%",
|
1465
1474
|
w: "full",
|
1466
1475
|
ref: refTable,
|
1476
|
+
...((_g = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _g.length) && hasScroll ? { "data-pin-right": true } : {},
|
1467
1477
|
...container,
|
1468
1478
|
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react28.Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
|
1469
1479
|
/* @__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)(
|
@@ -1516,17 +1526,17 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1516
1526
|
gap: 2,
|
1517
1527
|
children: [
|
1518
1528
|
(0, import_react_table.flexRender)(header.column.columnDef.header, header.getContext()),
|
1519
|
-
|
1529
|
+
(_b2 = header.column.getCanSort() && {
|
1530
|
+
asc: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_icons2.ChevronUpIcon, { h: 4, w: 4, color: "neutral.500" }),
|
1531
|
+
desc: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_icons2.ChevronDownIcon, { h: 4, w: 4, color: "neutral.500" })
|
1532
|
+
}[header.column.getIsSorted()]) != null ? _b2 : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
1520
1533
|
import_react28.Box,
|
1521
1534
|
{
|
1522
1535
|
as: "span",
|
1523
1536
|
cursor: header.column.getCanSort() ? "pointer" : "default",
|
1524
1537
|
"data-test-id": `CT_Container_SortingIcon_${header.id}`,
|
1525
1538
|
onClick: header.column.getToggleSortingHandler(),
|
1526
|
-
children: (
|
1527
|
-
asc: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_icons2.ChevronUpIcon, { h: 4, w: 4, color: "neutral.500" }),
|
1528
|
-
desc: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_icons2.ChevronDownIcon, { h: 4, w: 4, color: "neutral.500" })
|
1529
|
-
}[header.column.getIsSorted()]) != null ? _b2 : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react28.Box, { display: "flex", justifyContent: "center", alignItems: "center", boxSize: 4, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_icons2.UpDownIcon, { color: "neutral.500" }) })
|
1539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react28.Box, { display: "flex", justifyContent: "center", alignItems: "center", boxSize: 4, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_icons2.UpDownIcon, { color: "neutral.500" }) })
|
1530
1540
|
}
|
1531
1541
|
)
|
1532
1542
|
]
|