@ctlyst.id/internal-ui 3.3.9 → 3.3.10

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -1065,155 +1065,169 @@ var useDataTable = ({
1065
1065
  };
1066
1066
  };
1067
1067
  var DataTable = React5.forwardRef((props, ref) => {
1068
- const { isLoading, styles, headerSticky, onRowClick, container } = props;
1068
+ var _a, _b;
1069
+ const { isLoading, styles, headerSticky, onRowClick, container, columnPinning } = props;
1069
1070
  const { table, toggleAllRowsSelected, generateColumn } = useDataTable(props);
1070
1071
  React5.useImperativeHandle(ref, () => ({
1071
1072
  toggleAllRowsSelected
1072
1073
  }));
1073
- return /* @__PURE__ */ jsx24(Box11, { overflowX: "auto", position: "relative", px: 4, maxW: "100%", w: "full", ...container, children: isLoading ? /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
1074
- /* @__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(
1075
- Th,
1076
- {
1077
- colSpan: header.colSpan,
1078
- width: `${header.getSize() + (index === 0 || index === headerGroup.headers.length - 1 ? 16 : 0)}px`,
1079
- ...styles == null ? void 0 : styles.tableColumnHeader,
1080
- children: /* @__PURE__ */ jsx24(
1081
- Flex2,
1074
+ return /* @__PURE__ */ jsx24(
1075
+ Box11,
1076
+ {
1077
+ overflowX: "auto",
1078
+ overflowY: "hidden",
1079
+ position: "relative",
1080
+ pl: ((_a = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _a.length) ? 0 : 4,
1081
+ pr: ((_b = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _b.length) ? 0 : 4,
1082
+ maxW: "100%",
1083
+ w: "full",
1084
+ ...container,
1085
+ children: isLoading ? /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
1086
+ /* @__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(
1087
+ Th,
1082
1088
  {
1083
- "data-test-id": "CT_component_data-table_loader",
1084
- textTransform: "capitalize",
1085
- align: "center",
1086
- gap: 2,
1087
- children: flexRender(header.column.columnDef.header, header.getContext())
1089
+ colSpan: header.colSpan,
1090
+ width: `${header.getSize() + (index === 0 || index === headerGroup.headers.length - 1 ? 16 : 0)}px`,
1091
+ ...styles == null ? void 0 : styles.tableColumnHeader,
1092
+ children: /* @__PURE__ */ jsx24(
1093
+ Flex2,
1094
+ {
1095
+ "data-test-id": "CT_component_data-table_loader",
1096
+ textTransform: "capitalize",
1097
+ align: "center",
1098
+ gap: 2,
1099
+ children: flexRender(header.column.columnDef.header, header.getContext())
1100
+ }
1101
+ )
1102
+ },
1103
+ header.id
1104
+ )) }, headerGroup.id)) }),
1105
+ /* @__PURE__ */ jsx24(Tbody, { children: [...Array(5)].map((num) => /* @__PURE__ */ jsx24(Tr, { mx: "2", children: [...Array(generateColumn().length)].map((i) => /* @__PURE__ */ jsx24(Td, { width: 210, children: /* @__PURE__ */ jsx24(Skeleton2, { startColor: "neutral.100", endColor: "neutral.200", h: "20px", w: "70%" }, i) }, i)) }, num)) })
1106
+ ] }) : /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, children: [
1107
+ /* @__PURE__ */ jsx24(
1108
+ Thead,
1109
+ {
1110
+ maxH: "50px",
1111
+ ...(styles == null ? void 0 : styles.tableHead, headerSticky ? { position: "sticky", top: 0, bg: "white", zIndex: 1 } : {}),
1112
+ children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx24(Tr, { bg: useColorModeValue("initial", "ebony-clay.700"), ...styles == null ? void 0 : styles.tableRow, children: headerGroup.headers.map((header, index) => {
1113
+ var _a2;
1114
+ return /* @__PURE__ */ jsx24(
1115
+ Th,
1116
+ {
1117
+ colSpan: header.colSpan,
1118
+ sx: getCommonPinningStyles(header.column),
1119
+ width: `${header.getSize() + (index === 0 || index === headerGroup.headers.length - 1 ? 16 : 0)}px`,
1120
+ ...styles == null ? void 0 : styles.tableColumnHeader,
1121
+ children: /* @__PURE__ */ jsxs8(
1122
+ Flex2,
1123
+ {
1124
+ backgroundColor: "white",
1125
+ height: "100%",
1126
+ "data-test-id": `CT_Container_TableHeader_${header.id}`,
1127
+ textTransform: "capitalize",
1128
+ userSelect: "none",
1129
+ align: "center",
1130
+ gap: 2,
1131
+ children: [
1132
+ flexRender(header.column.columnDef.header, header.getContext()),
1133
+ /* @__PURE__ */ jsx24(
1134
+ Box11,
1135
+ {
1136
+ as: "span",
1137
+ cursor: header.column.getCanSort() ? "pointer" : "default",
1138
+ "data-test-id": `CT_Container_SortingIcon_${header.id}`,
1139
+ onClick: header.column.getToggleSortingHandler(),
1140
+ children: (_a2 = header.column.getCanSort() && {
1141
+ asc: /* @__PURE__ */ jsx24(ChevronUpIcon, { h: 4, w: 4, color: "neutral.500" }),
1142
+ desc: /* @__PURE__ */ jsx24(ChevronDownIcon, { h: 4, w: 4, color: "neutral.500" })
1143
+ }[header.column.getIsSorted()]) != null ? _a2 : /* @__PURE__ */ jsx24(Box11, { display: "flex", justifyContent: "center", alignItems: "center", boxSize: 4, children: /* @__PURE__ */ jsx24(UpDownIcon, { color: "neutral.500" }) })
1144
+ }
1145
+ )
1146
+ ]
1147
+ }
1148
+ )
1149
+ },
1150
+ header.id
1151
+ );
1152
+ }) }, headerGroup.id))
1088
1153
  }
1089
- )
1090
- },
1091
- header.id
1092
- )) }, headerGroup.id)) }),
1093
- /* @__PURE__ */ jsx24(Tbody, { children: [...Array(5)].map((num) => /* @__PURE__ */ jsx24(Tr, { mx: "2", children: [...Array(generateColumn().length)].map((i) => /* @__PURE__ */ jsx24(Td, { width: 210, children: /* @__PURE__ */ jsx24(Skeleton2, { startColor: "neutral.100", endColor: "neutral.200", h: "20px", w: "70%" }, i) }, i)) }, num)) })
1094
- ] }) : /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, children: [
1095
- /* @__PURE__ */ jsx24(
1096
- Thead,
1097
- {
1098
- maxH: "50px",
1099
- ...(styles == null ? void 0 : styles.tableHead, headerSticky ? { position: "sticky", top: 0, bg: "white", zIndex: 1 } : {}),
1100
- children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx24(Tr, { bg: useColorModeValue("initial", "ebony-clay.700"), ...styles == null ? void 0 : styles.tableRow, children: headerGroup.headers.map((header, index) => {
1101
- var _a;
1154
+ ),
1155
+ /* @__PURE__ */ jsx24(Tbody, { ...styles == null ? void 0 : styles.tableBody, children: table.getRowModel().rows.map((row) => {
1102
1156
  return /* @__PURE__ */ jsx24(
1103
- Th,
1157
+ Tr,
1104
1158
  {
1105
- colSpan: header.colSpan,
1106
- sx: getCommonPinningStyles(header.column),
1107
- width: `${header.getSize() + (index === 0 || index === headerGroup.headers.length - 1 ? 16 : 0)}px`,
1108
- ...styles == null ? void 0 : styles.tableColumnHeader,
1109
- children: /* @__PURE__ */ jsxs8(
1110
- Flex2,
1111
- {
1112
- backgroundColor: "white",
1113
- height: "100%",
1114
- "data-test-id": `CT_Container_TableHeader_${header.id}`,
1115
- textTransform: "capitalize",
1116
- userSelect: "none",
1117
- align: "center",
1118
- gap: 2,
1119
- children: [
1120
- flexRender(header.column.columnDef.header, header.getContext()),
1121
- /* @__PURE__ */ jsx24(
1122
- Box11,
1123
- {
1124
- as: "span",
1125
- cursor: header.column.getCanSort() ? "pointer" : "default",
1126
- "data-test-id": `CT_Container_SortingIcon_${header.id}`,
1127
- onClick: header.column.getToggleSortingHandler(),
1128
- children: (_a = header.column.getCanSort() && {
1129
- asc: /* @__PURE__ */ jsx24(ChevronUpIcon, { h: 4, w: 4, color: "neutral.500" }),
1130
- desc: /* @__PURE__ */ jsx24(ChevronDownIcon, { h: 4, w: 4, color: "neutral.500" })
1131
- }[header.column.getIsSorted()]) != null ? _a : /* @__PURE__ */ jsx24(Box11, { display: "flex", justifyContent: "center", alignItems: "center", boxSize: 4, children: /* @__PURE__ */ jsx24(UpDownIcon, { color: "neutral.500" }) })
1132
- }
1133
- )
1134
- ]
1135
- }
1136
- )
1137
- },
1138
- header.id
1139
- );
1140
- }) }, headerGroup.id))
1141
- }
1142
- ),
1143
- /* @__PURE__ */ jsx24(Tbody, { ...styles == null ? void 0 : styles.tableBody, children: table.getRowModel().rows.map((row) => {
1144
- return /* @__PURE__ */ jsx24(
1145
- Tr,
1146
- {
1147
- "data-test-id": "-RU0hNYGRzeVM3HQ4cXHl",
1148
- tabindex: "0",
1149
- ...styles == null ? void 0 : styles.tableRow,
1150
- css: css`
1159
+ "data-test-id": "-RU0hNYGRzeVM3HQ4cXHl",
1160
+ tabindex: "0",
1161
+ ...styles == null ? void 0 : styles.tableRow,
1162
+ css: css`
1151
1163
  &:last-child {
1152
1164
  td {
1153
1165
  border-bottom: none;
1154
1166
  }
1155
1167
  }
1156
1168
  `,
1157
- onMouseDown: (e) => {
1158
- var _a;
1159
- (_a = e.currentTarget) == null ? void 0 : _a.setAttribute("data-active", "true");
1160
- },
1161
- onMouseUp: (e) => {
1162
- var _a;
1163
- (_a = e.currentTarget) == null ? void 0 : _a.removeAttribute("data-active");
1164
- },
1165
- onClick: () => {
1166
- if (onRowClick) {
1167
- onRowClick(row.original);
1168
- }
1169
- },
1170
- children: row.getVisibleCells().map((cell) => {
1171
- const meta = cell.column.columnDef.meta;
1172
- const isDisabled = isCellDisabled(row.original, cell.column.id);
1173
- return /* @__PURE__ */ jsx24(
1174
- Td,
1175
- {
1176
- "data-test-id": `CT_Component_TableCell_${cell.id}`,
1177
- fontSize: "text.sm",
1178
- sx: getCommonPinningStyles(cell.column),
1179
- ...styles == null ? void 0 : styles.tableCell,
1180
- children: /* @__PURE__ */ jsx24(
1181
- Flex2,
1169
+ onMouseDown: (e) => {
1170
+ var _a2;
1171
+ (_a2 = e.currentTarget) == null ? void 0 : _a2.setAttribute("data-active", "true");
1172
+ },
1173
+ onMouseUp: (e) => {
1174
+ var _a2;
1175
+ (_a2 = e.currentTarget) == null ? void 0 : _a2.removeAttribute("data-active");
1176
+ },
1177
+ onClick: () => {
1178
+ if (onRowClick) {
1179
+ onRowClick(row.original);
1180
+ }
1181
+ },
1182
+ children: row.getVisibleCells().map((cell) => {
1183
+ const meta = cell.column.columnDef.meta;
1184
+ const isDisabled = isCellDisabled(row.original, cell.column.id);
1185
+ return /* @__PURE__ */ jsx24(
1186
+ Td,
1182
1187
  {
1183
- height: "100%",
1184
- width: "100%",
1185
- align: "center",
1186
- opacity: isDisabled ? 0.5 : 1,
1187
- sx: { ...meta && meta.columnStyles ? meta.columnStyles : {} },
1188
+ "data-test-id": `CT_Component_TableCell_${cell.id}`,
1189
+ fontSize: "text.sm",
1190
+ sx: getCommonPinningStyles(cell.column),
1191
+ ...styles == null ? void 0 : styles.tableCell,
1188
1192
  children: /* @__PURE__ */ jsx24(
1189
1193
  Flex2,
1190
1194
  {
1191
- tabIndex: 0,
1192
- cursor: "auto",
1193
- "data-test-id": `CT_Component_TableCell_Content-${cell.id}`,
1194
- onMouseUp: (e) => e.stopPropagation(),
1195
- onMouseDown: (e) => e.stopPropagation(),
1196
- onClick: (e) => {
1197
- e.stopPropagation();
1198
- },
1199
- noOfLines: 2,
1200
- sx: {
1201
- display: "-webkit-inline-box"
1202
- },
1203
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
1195
+ height: "100%",
1196
+ width: "100%",
1197
+ align: "center",
1198
+ opacity: isDisabled ? 0.5 : 1,
1199
+ sx: { ...meta && meta.columnStyles ? meta.columnStyles : {} },
1200
+ children: /* @__PURE__ */ jsx24(
1201
+ Flex2,
1202
+ {
1203
+ tabIndex: 0,
1204
+ cursor: "auto",
1205
+ "data-test-id": `CT_Component_TableCell_Content-${cell.id}`,
1206
+ onMouseUp: (e) => e.stopPropagation(),
1207
+ onMouseDown: (e) => e.stopPropagation(),
1208
+ onClick: (e) => {
1209
+ e.stopPropagation();
1210
+ },
1211
+ noOfLines: 2,
1212
+ sx: {
1213
+ display: "-webkit-inline-box"
1214
+ },
1215
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
1216
+ }
1217
+ )
1204
1218
  }
1205
1219
  )
1206
- }
1207
- )
1208
- },
1209
- cell.id
1210
- );
1211
- })
1212
- },
1213
- row.id
1214
- );
1215
- }) })
1216
- ] }) });
1220
+ },
1221
+ cell.id
1222
+ );
1223
+ })
1224
+ },
1225
+ row.id
1226
+ );
1227
+ }) })
1228
+ ] })
1229
+ }
1230
+ );
1217
1231
  });
1218
1232
  var data_table_default = DataTable;
1219
1233