@ctlyst.id/internal-ui 3.4.2 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1419,7 +1419,7 @@ var useDataTable = ({
1419
1419
  };
1420
1420
  };
1421
1421
  var DataTable = React5.forwardRef((props, ref) => {
1422
- var _a, _b, _c, _d;
1422
+ var _a, _b;
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);
@@ -1427,32 +1427,43 @@ var DataTable = React5.forwardRef((props, ref) => {
1427
1427
  toggleAllRowsSelected
1428
1428
  }));
1429
1429
  let lastPinnedColumn = 0;
1430
- (_a = refTable.current) == null ? void 0 : _a.addEventListener("scroll", (s) => {
1431
- var _a2, _b2, _c2, _d2;
1432
- const element = s.currentTarget;
1433
- if (element.scrollLeft > 0) {
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");
1440
- } else {
1441
- (_d2 = refTable.current) == null ? void 0 : _d2.removeAttribute("data-pin-right");
1442
- }
1443
- });
1430
+ React5.useEffect(() => {
1431
+ var _a2;
1432
+ (_a2 = refTable.current) == null ? void 0 : _a2.addEventListener("scroll", (s) => {
1433
+ var _a3, _b2, _c, _d;
1434
+ const element = s.currentTarget;
1435
+ if (element.scrollLeft > 0) {
1436
+ (_a3 = refTable.current) == null ? void 0 : _a3.setAttribute("data-pin-left", "true");
1437
+ } else {
1438
+ (_b2 = refTable.current) == null ? void 0 : _b2.removeAttribute("data-pin-left");
1439
+ }
1440
+ if (element.scrollLeft < element.scrollWidth - (lastPinnedColumn + element.offsetWidth)) {
1441
+ (_c = refTable.current) == null ? void 0 : _c.setAttribute("data-pin-right", "true");
1442
+ } else {
1443
+ (_d = refTable.current) == null ? void 0 : _d.removeAttribute("data-pin-right");
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");
1453
+ }
1454
+ });
1455
+ }, []);
1444
1456
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1445
1457
  import_react28.Box,
1446
1458
  {
1447
1459
  overflowX: "auto",
1448
1460
  overflowY: "hidden",
1449
1461
  position: "relative",
1450
- pl: ((_b = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _b.length) ? 0 : 4,
1451
- pr: ((_c = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _c.length) ? 0 : 4,
1462
+ pl: ((_a = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _a.length) ? 0 : 4,
1463
+ pr: ((_b = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _b.length) ? 0 : 4,
1452
1464
  maxW: "100%",
1453
1465
  w: "full",
1454
1466
  ref: refTable,
1455
- ...((_d = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _d.length) ? { "data-pin-right": true } : {},
1456
1467
  ...container,
1457
1468
  children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react28.Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
1458
1469
  /* @__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)(