@ctlyst.id/internal-ui 3.4.3 → 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 +21 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1077,18 +1077,27 @@ var useDataTable = ({
|
|
|
1077
1077
|
};
|
|
1078
1078
|
};
|
|
1079
1079
|
var DataTable = React5.forwardRef((props, ref) => {
|
|
1080
|
-
var _a, _b;
|
|
1080
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
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);
|
|
1084
1084
|
React5.useImperativeHandle(ref, () => ({
|
|
1085
1085
|
toggleAllRowsSelected
|
|
1086
1086
|
}));
|
|
1087
|
+
const tableResizeHandler = () => {
|
|
1088
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
1089
|
+
if (((_a2 = refTable.current) == null ? void 0 : _a2.offsetWidth) === ((_b2 = refTable.current) == null ? void 0 : _b2.scrollWidth)) {
|
|
1090
|
+
(_c2 = refTable.current) == null ? void 0 : _c2.removeAttribute("data-pin-right");
|
|
1091
|
+
(_d2 = refTable.current) == null ? void 0 : _d2.removeAttribute("data-pin-left");
|
|
1092
|
+
} else {
|
|
1093
|
+
(_e2 = refTable.current) == null ? void 0 : _e2.setAttribute("data-pin-right", "true");
|
|
1094
|
+
}
|
|
1095
|
+
};
|
|
1087
1096
|
let lastPinnedColumn = 0;
|
|
1088
1097
|
React5.useEffect(() => {
|
|
1089
1098
|
var _a2;
|
|
1090
1099
|
(_a2 = refTable.current) == null ? void 0 : _a2.addEventListener("scroll", (s) => {
|
|
1091
|
-
var _a3, _b2,
|
|
1100
|
+
var _a3, _b2, _c2, _d2;
|
|
1092
1101
|
const element = s.currentTarget;
|
|
1093
1102
|
if (element.scrollLeft > 0) {
|
|
1094
1103
|
(_a3 = refTable.current) == null ? void 0 : _a3.setAttribute("data-pin-left", "true");
|
|
@@ -1096,32 +1105,29 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
|
1096
1105
|
(_b2 = refTable.current) == null ? void 0 : _b2.removeAttribute("data-pin-left");
|
|
1097
1106
|
}
|
|
1098
1107
|
if (element.scrollLeft < element.scrollWidth - (lastPinnedColumn + element.offsetWidth)) {
|
|
1099
|
-
(
|
|
1108
|
+
(_c2 = refTable.current) == null ? void 0 : _c2.setAttribute("data-pin-right", "true");
|
|
1100
1109
|
} else {
|
|
1101
|
-
(
|
|
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");
|
|
1110
|
+
(_d2 = refTable.current) == null ? void 0 : _d2.removeAttribute("data-pin-right");
|
|
1111
1111
|
}
|
|
1112
1112
|
});
|
|
1113
|
+
window.addEventListener("resize", tableResizeHandler);
|
|
1114
|
+
return () => {
|
|
1115
|
+
window.removeEventListener("resize", tableResizeHandler);
|
|
1116
|
+
};
|
|
1113
1117
|
}, []);
|
|
1118
|
+
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);
|
|
1114
1119
|
return /* @__PURE__ */ jsx24(
|
|
1115
1120
|
Box11,
|
|
1116
1121
|
{
|
|
1117
1122
|
overflowX: "auto",
|
|
1118
1123
|
overflowY: "hidden",
|
|
1119
1124
|
position: "relative",
|
|
1120
|
-
pl: ((
|
|
1121
|
-
pr: ((
|
|
1125
|
+
pl: ((_e = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _e.length) ? 0 : 4,
|
|
1126
|
+
pr: ((_f = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _f.length) ? 0 : 4,
|
|
1122
1127
|
maxW: "100%",
|
|
1123
1128
|
w: "full",
|
|
1124
1129
|
ref: refTable,
|
|
1130
|
+
...((_g = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _g.length) && hasScroll ? { "data-pin-right": true } : {},
|
|
1125
1131
|
...container,
|
|
1126
1132
|
children: isLoading ? /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
|
|
1127
1133
|
/* @__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(
|