@ctlyst.id/internal-ui 3.3.15 → 3.3.16

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1287,26 +1287,32 @@ var getCommonPinningStyles = (column) => {
1287
1287
  ...isLastLeftPinnedColumn ? {
1288
1288
  padding: "16px 8px 16px 8px",
1289
1289
  "&:after": {
1290
+ transition: "all 0.3s",
1290
1291
  content: "''",
1291
1292
  position: "absolute",
1292
1293
  width: "30px",
1293
1294
  right: "0px",
1294
1295
  bottom: "-1px",
1295
1296
  top: 0,
1296
- transform: "translateX(100%)",
1297
+ transform: "translateX(100%)"
1298
+ },
1299
+ "[pin-left=true] &:after": {
1297
1300
  boxShadow: "inset 14px 0px 20px -10px #00000010"
1298
1301
  }
1299
1302
  } : {},
1300
1303
  ...isFirstRightPinnedColumn ? {
1301
1304
  padding: "16px 8px 16px 8px",
1302
1305
  "&:after": {
1306
+ transition: "all 0.3s",
1303
1307
  content: "''",
1304
1308
  position: "absolute",
1305
1309
  width: "30px",
1306
1310
  left: "0%",
1307
1311
  top: 0,
1308
1312
  bottom: "-1px",
1309
- transform: "translateX(-100%)",
1313
+ transform: "translateX(-100%)"
1314
+ },
1315
+ "[pin-right=true] &:after": {
1310
1316
  boxShadow: "inset -14px 0px 20px -10px #00000010"
1311
1317
  }
1312
1318
  } : {}
@@ -1406,22 +1412,39 @@ var useDataTable = ({
1406
1412
  };
1407
1413
  };
1408
1414
  var DataTable = React5.forwardRef((props, ref) => {
1409
- var _a, _b;
1415
+ var _a, _b, _c;
1410
1416
  const { isLoading, styles, headerSticky, onRowClick, container, columnPinning } = props;
1411
1417
  const { table, toggleAllRowsSelected, generateColumn } = useDataTable(props);
1418
+ const refTable = React5.useRef(null);
1412
1419
  React5.useImperativeHandle(ref, () => ({
1413
1420
  toggleAllRowsSelected
1414
1421
  }));
1422
+ let lastPinnedColumn = 0;
1423
+ (_a = refTable.current) == null ? void 0 : _a.addEventListener("scroll", (s) => {
1424
+ var _a2, _b2, _c2, _d;
1425
+ const element = s.currentTarget;
1426
+ if (element.scrollLeft > 0) {
1427
+ (_a2 = refTable.current) == null ? void 0 : _a2.setAttribute("pin-left", "true");
1428
+ } else {
1429
+ (_b2 = refTable.current) == null ? void 0 : _b2.removeAttribute("pin-left");
1430
+ }
1431
+ if (element.scrollLeft < element.scrollWidth - (lastPinnedColumn + element.offsetWidth)) {
1432
+ (_c2 = refTable.current) == null ? void 0 : _c2.setAttribute("pin-right", "true");
1433
+ } else {
1434
+ (_d = refTable.current) == null ? void 0 : _d.removeAttribute("pin-right");
1435
+ }
1436
+ });
1415
1437
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1416
1438
  import_react28.Box,
1417
1439
  {
1418
1440
  overflowX: "auto",
1419
1441
  overflowY: "hidden",
1420
1442
  position: "relative",
1421
- pl: ((_a = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _a.length) ? 0 : 4,
1422
- pr: ((_b = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _b.length) ? 0 : 4,
1443
+ pl: ((_b = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _b.length) ? 0 : 4,
1444
+ pr: ((_c = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _c.length) ? 0 : 4,
1423
1445
  maxW: "100%",
1424
1446
  w: "full",
1447
+ ref: refTable,
1425
1448
  ...container,
1426
1449
  children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react28.Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
1427
1450
  /* @__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)(
@@ -1451,7 +1474,10 @@ var DataTable = React5.forwardRef((props, ref) => {
1451
1474
  maxH: "50px",
1452
1475
  ...(styles == null ? void 0 : styles.tableHead, headerSticky ? { position: "sticky", top: 0, bg: "white", zIndex: 1 } : {}),
1453
1476
  children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react28.Tr, { bg: (0, import_react28.useColorModeValue)("initial", "ebony-clay.700"), ...styles == null ? void 0 : styles.tableRow, children: headerGroup.headers.map((header, index) => {
1454
- var _a2;
1477
+ var _a2, _b2;
1478
+ if (!!((_a2 = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _a2.length) && header.column.getIsFirstColumn("right")) {
1479
+ lastPinnedColumn = header.column.getAfter("right");
1480
+ }
1455
1481
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1456
1482
  import_react28.Th,
1457
1483
  {
@@ -1478,10 +1504,10 @@ var DataTable = React5.forwardRef((props, ref) => {
1478
1504
  cursor: header.column.getCanSort() ? "pointer" : "default",
1479
1505
  "data-test-id": `CT_Container_SortingIcon_${header.id}`,
1480
1506
  onClick: header.column.getToggleSortingHandler(),
1481
- children: (_a2 = header.column.getCanSort() && {
1507
+ children: (_b2 = header.column.getCanSort() && {
1482
1508
  asc: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_icons2.ChevronUpIcon, { h: 4, w: 4, color: "neutral.500" }),
1483
1509
  desc: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_icons2.ChevronDownIcon, { h: 4, w: 4, color: "neutral.500" })
1484
- }[header.column.getIsSorted()]) != null ? _a2 : /* @__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" }) })
1510
+ }[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" }) })
1485
1511
  }
1486
1512
  )
1487
1513
  ]