@ctlyst.id/internal-ui 3.4.2 → 3.4.3
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 +29 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -1077,7 +1077,7 @@ var useDataTable = ({
|
|
1077
1077
|
};
|
1078
1078
|
};
|
1079
1079
|
var DataTable = React5.forwardRef((props, ref) => {
|
1080
|
-
var _a, _b
|
1080
|
+
var _a, _b;
|
1081
1081
|
const { isLoading, styles, headerSticky, onRowClick, container, columnPinning } = props;
|
1082
1082
|
const { table, toggleAllRowsSelected, generateColumn } = useDataTable(props);
|
1083
1083
|
const refTable = React5.useRef(null);
|
@@ -1085,32 +1085,43 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1085
1085
|
toggleAllRowsSelected
|
1086
1086
|
}));
|
1087
1087
|
let lastPinnedColumn = 0;
|
1088
|
-
|
1089
|
-
var _a2
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1088
|
+
React5.useEffect(() => {
|
1089
|
+
var _a2;
|
1090
|
+
(_a2 = refTable.current) == null ? void 0 : _a2.addEventListener("scroll", (s) => {
|
1091
|
+
var _a3, _b2, _c, _d;
|
1092
|
+
const element = s.currentTarget;
|
1093
|
+
if (element.scrollLeft > 0) {
|
1094
|
+
(_a3 = refTable.current) == null ? void 0 : _a3.setAttribute("data-pin-left", "true");
|
1095
|
+
} else {
|
1096
|
+
(_b2 = refTable.current) == null ? void 0 : _b2.removeAttribute("data-pin-left");
|
1097
|
+
}
|
1098
|
+
if (element.scrollLeft < element.scrollWidth - (lastPinnedColumn + element.offsetWidth)) {
|
1099
|
+
(_c = refTable.current) == null ? void 0 : _c.setAttribute("data-pin-right", "true");
|
1100
|
+
} else {
|
1101
|
+
(_d = refTable.current) == null ? void 0 : _d.removeAttribute("data-pin-right");
|
1102
|
+
}
|
1103
|
+
});
|
1104
|
+
window.addEventListener("resize", (ev) => {
|
1105
|
+
var _a3, _b2, _c, _d, _e;
|
1106
|
+
if (((_a3 = refTable.current) == null ? void 0 : _a3.offsetWidth) === ((_b2 = refTable.current) == null ? void 0 : _b2.scrollWidth)) {
|
1107
|
+
(_c = refTable.current) == null ? void 0 : _c.removeAttribute("data-pin-right");
|
1108
|
+
(_d = refTable.current) == null ? void 0 : _d.removeAttribute("data-pin-left");
|
1109
|
+
} else {
|
1110
|
+
(_e = refTable.current) == null ? void 0 : _e.setAttribute("data-pin-right", "true");
|
1111
|
+
}
|
1112
|
+
});
|
1113
|
+
}, []);
|
1102
1114
|
return /* @__PURE__ */ jsx24(
|
1103
1115
|
Box11,
|
1104
1116
|
{
|
1105
1117
|
overflowX: "auto",
|
1106
1118
|
overflowY: "hidden",
|
1107
1119
|
position: "relative",
|
1108
|
-
pl: ((
|
1109
|
-
pr: ((
|
1120
|
+
pl: ((_a = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _a.length) ? 0 : 4,
|
1121
|
+
pr: ((_b = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _b.length) ? 0 : 4,
|
1110
1122
|
maxW: "100%",
|
1111
1123
|
w: "full",
|
1112
1124
|
ref: refTable,
|
1113
|
-
...((_d = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _d.length) ? { "data-pin-right": true } : {},
|
1114
1125
|
...container,
|
1115
1126
|
children: isLoading ? /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
|
1116
1127
|
/* @__PURE__ */ jsx24(Thead, { ...(styles == null ? void 0 : styles.tableHead, headerSticky ? { position: "sticky", top: 0, bg: "white", zIndex: 1 } : {}), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx24(Tr, { mx: "2", ...styles == null ? void 0 : styles.tableRow, children: headerGroup.headers.map((header, index) => /* @__PURE__ */ jsx24(
|