@ctlyst.id/internal-ui 3.1.6 → 3.1.7

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -945,6 +945,12 @@ import { flexRender, getCoreRowModel, getSortedRowModel, useReactTable } from "@
945
945
  import * as React5 from "react";
946
946
  import { useRef } from "react";
947
947
  import { jsx as jsx24, jsxs as jsxs8 } from "react/jsx-runtime";
948
+ var isCellDisabled = (row, cellId) => {
949
+ if (row.disabled) {
950
+ return row.disabled[cellId];
951
+ }
952
+ return false;
953
+ };
948
954
  var getCommonPinningStyles = (column) => {
949
955
  const isPinned = column.getIsPinned();
950
956
  const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
@@ -1076,148 +1082,145 @@ var useDataTable = ({
1076
1082
  generateColumn
1077
1083
  };
1078
1084
  };
1079
- var DataTable = React5.forwardRef(
1080
- (props, ref) => {
1081
- const { isLoading, styles, headerSticky, onRowClick, container } = props;
1082
- const { table, toggleAllRowsSelected, generateColumn } = useDataTable(props);
1083
- React5.useImperativeHandle(ref, () => ({
1084
- toggleAllRowsSelected
1085
- }));
1086
- return /* @__PURE__ */ jsx24(Box11, { overflowX: "auto", position: "relative", maxW: "100%", w: "full", ...container, children: isLoading ? /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
1087
- /* @__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(
1088
- Th,
1089
- {
1090
- colSpan: header.colSpan,
1091
- width: `${header.getSize() + (index === 0 || index === headerGroup.headers.length - 1 ? 16 : 0)}px`,
1092
- ...styles == null ? void 0 : styles.tableColumnHeader,
1093
- children: /* @__PURE__ */ jsx24(
1094
- Flex2,
1085
+ var DataTable = React5.forwardRef((props, ref) => {
1086
+ const { isLoading, styles, headerSticky, onRowClick, container } = props;
1087
+ const { table, toggleAllRowsSelected, generateColumn } = useDataTable(props);
1088
+ React5.useImperativeHandle(ref, () => ({
1089
+ toggleAllRowsSelected
1090
+ }));
1091
+ return /* @__PURE__ */ jsx24(Box11, { overflowX: "auto", position: "relative", maxW: "100%", w: "full", ...container, children: isLoading ? /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
1092
+ /* @__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(
1093
+ Th,
1094
+ {
1095
+ colSpan: header.colSpan,
1096
+ width: `${header.getSize() + (index === 0 || index === headerGroup.headers.length - 1 ? 16 : 0)}px`,
1097
+ ...styles == null ? void 0 : styles.tableColumnHeader,
1098
+ children: /* @__PURE__ */ jsx24(
1099
+ Flex2,
1100
+ {
1101
+ "data-test-id": "CT_component_data-table_loader",
1102
+ textTransform: "capitalize",
1103
+ align: "center",
1104
+ gap: 2,
1105
+ children: flexRender(header.column.columnDef.header, header.getContext())
1106
+ }
1107
+ )
1108
+ },
1109
+ header.id
1110
+ )) }, headerGroup.id)) }),
1111
+ /* @__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)) })
1112
+ ] }) : /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, children: [
1113
+ /* @__PURE__ */ jsx24(
1114
+ Thead,
1115
+ {
1116
+ maxH: "50px",
1117
+ ...(styles == null ? void 0 : styles.tableHead, headerSticky ? { position: "sticky", top: 0, bg: "white", zIndex: 1 } : {}),
1118
+ 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) => {
1119
+ var _a;
1120
+ return /* @__PURE__ */ jsx24(
1121
+ Th,
1095
1122
  {
1096
- "data-test-id": "CT_component_data-table_loader",
1097
- textTransform: "capitalize",
1098
- align: "center",
1099
- gap: 2,
1100
- children: flexRender(header.column.columnDef.header, header.getContext())
1101
- }
1102
- )
1103
- },
1104
- header.id
1105
- )) }, headerGroup.id)) }),
1106
- /* @__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)) })
1107
- ] }) : /* @__PURE__ */ jsxs8(Table, { ...styles == null ? void 0 : styles.table, children: [
1108
- /* @__PURE__ */ jsx24(
1109
- Thead,
1123
+ colSpan: header.colSpan,
1124
+ sx: getCommonPinningStyles(header.column),
1125
+ width: `${header.getSize() + (index === 0 || index === headerGroup.headers.length - 1 ? 16 : 0)}px`,
1126
+ ...styles == null ? void 0 : styles.tableColumnHeader,
1127
+ children: /* @__PURE__ */ jsxs8(
1128
+ Flex2,
1129
+ {
1130
+ backgroundColor: "white",
1131
+ height: "100%",
1132
+ "data-test-id": `CT_Container_TableHeader_${header.id}`,
1133
+ textTransform: "capitalize",
1134
+ userSelect: "none",
1135
+ align: "center",
1136
+ gap: 2,
1137
+ children: [
1138
+ /* @__PURE__ */ jsx24(Text4, { children: flexRender(header.column.columnDef.header, header.getContext()) }),
1139
+ /* @__PURE__ */ jsx24(
1140
+ Box11,
1141
+ {
1142
+ as: "span",
1143
+ cursor: header.column.getCanSort() ? "pointer" : "default",
1144
+ "data-test-id": `CT_Container_SortingIcon_${header.id}`,
1145
+ onClick: header.column.getToggleSortingHandler(),
1146
+ children: (_a = header.column.getCanSort() && {
1147
+ asc: /* @__PURE__ */ jsx24(ChevronUpIcon, { h: 4, w: 4, color: "neutral.500" }),
1148
+ desc: /* @__PURE__ */ jsx24(ChevronDownIcon, { h: 4, w: 4, color: "neutral.500" })
1149
+ }[header.column.getIsSorted()]) != null ? _a : /* @__PURE__ */ jsx24(Box11, { display: "flex", justifyContent: "center", alignItems: "center", boxSize: 4, children: /* @__PURE__ */ jsx24(UpDownIcon, { color: "neutral.500" }) })
1150
+ }
1151
+ )
1152
+ ]
1153
+ }
1154
+ )
1155
+ },
1156
+ header.id
1157
+ );
1158
+ }) }, headerGroup.id))
1159
+ }
1160
+ ),
1161
+ /* @__PURE__ */ jsx24(Tbody, { ...styles == null ? void 0 : styles.tableBody, children: table.getRowModel().rows.map((row) => {
1162
+ const trRef = useRef();
1163
+ return /* @__PURE__ */ jsx24(
1164
+ Tr,
1110
1165
  {
1111
- maxH: "50px",
1112
- ...(styles == null ? void 0 : styles.tableHead, headerSticky ? { position: "sticky", top: 0, bg: "white", zIndex: 1 } : {}),
1113
- 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) => {
1166
+ "data-test-id": "-RU0hNYGRzeVM3HQ4cXHl",
1167
+ tabindex: "0",
1168
+ ref: trRef,
1169
+ ...styles == null ? void 0 : styles.tableRow,
1170
+ css: css`
1171
+ &:last-child {
1172
+ td {
1173
+ border-bottom: none;
1174
+ }
1175
+ }
1176
+ `,
1177
+ onMouseDown: () => {
1114
1178
  var _a;
1179
+ (_a = trRef.current) == null ? void 0 : _a.setAttribute("data-active", "true");
1180
+ },
1181
+ onMouseUp: () => {
1182
+ var _a;
1183
+ (_a = trRef.current) == null ? void 0 : _a.removeAttribute("data-active");
1184
+ },
1185
+ onClick: () => {
1186
+ if (onRowClick) {
1187
+ onRowClick(row.original);
1188
+ }
1189
+ },
1190
+ children: row.getVisibleCells().map((cell) => {
1191
+ const isDisabled = isCellDisabled(row.original, cell.column.id);
1115
1192
  return /* @__PURE__ */ jsx24(
1116
- Th,
1193
+ Td,
1117
1194
  {
1118
- colSpan: header.colSpan,
1119
- sx: getCommonPinningStyles(header.column),
1120
- width: `${header.getSize() + (index === 0 || index === headerGroup.headers.length - 1 ? 16 : 0)}px`,
1121
- ...styles == null ? void 0 : styles.tableColumnHeader,
1122
- children: /* @__PURE__ */ jsxs8(
1195
+ "data-test-id": `CT_Component_TableCell_${cell.id}`,
1196
+ fontSize: "text.sm",
1197
+ sx: getCommonPinningStyles(cell.column),
1198
+ ...styles == null ? void 0 : styles.tableCell,
1199
+ children: /* @__PURE__ */ jsx24(Flex2, { height: "100%", align: "center", opacity: isDisabled ? 0.5 : 1, children: /* @__PURE__ */ jsx24(
1123
1200
  Flex2,
1124
1201
  {
1125
- backgroundColor: "white",
1126
- height: "100%",
1127
- "data-test-id": `CT_Container_TableHeader_${header.id}`,
1128
- textTransform: "capitalize",
1129
- userSelect: "none",
1130
- align: "center",
1131
- gap: 2,
1132
- children: [
1133
- /* @__PURE__ */ jsx24(Text4, { children: flexRender(header.column.columnDef.header, header.getContext()) }),
1134
- /* @__PURE__ */ jsx24(
1135
- Box11,
1136
- {
1137
- as: "span",
1138
- cursor: header.column.getCanSort() ? "pointer" : "default",
1139
- "data-test-id": `CT_Container_SortingIcon_${header.id}`,
1140
- onClick: header.column.getToggleSortingHandler(),
1141
- children: (_a = header.column.getCanSort() && {
1142
- asc: /* @__PURE__ */ jsx24(ChevronUpIcon, { h: 4, w: 4, color: "neutral.500" }),
1143
- desc: /* @__PURE__ */ jsx24(ChevronDownIcon, { h: 4, w: 4, color: "neutral.500" })
1144
- }[header.column.getIsSorted()]) != null ? _a : /* @__PURE__ */ jsx24(Box11, { display: "flex", justifyContent: "center", alignItems: "center", boxSize: 4, children: /* @__PURE__ */ jsx24(UpDownIcon, { color: "neutral.500" }) })
1145
- }
1146
- )
1147
- ]
1202
+ tabIndex: 0,
1203
+ display: "inline-flex",
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
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
1148
1212
  }
1149
- )
1213
+ ) })
1150
1214
  },
1151
- header.id
1215
+ cell.id
1152
1216
  );
1153
- }) }, headerGroup.id))
1154
- }
1155
- ),
1156
- /* @__PURE__ */ jsx24(Tbody, { ...styles == null ? void 0 : styles.tableBody, children: table.getRowModel().rows.map((row) => {
1157
- const trRef = useRef();
1158
- return /* @__PURE__ */ jsx24(
1159
- Tr,
1160
- {
1161
- "data-test-id": "-RU0hNYGRzeVM3HQ4cXHl",
1162
- tabindex: "0",
1163
- ref: trRef,
1164
- ...styles == null ? void 0 : styles.tableRow,
1165
- css: css`
1166
- &:last-child {
1167
- td {
1168
- border-bottom: none;
1169
- }
1170
- }
1171
- `,
1172
- onMouseDown: () => {
1173
- var _a;
1174
- (_a = trRef.current) == null ? void 0 : _a.setAttribute("data-active", "true");
1175
- },
1176
- onMouseUp: () => {
1177
- var _a;
1178
- (_a = trRef.current) == null ? void 0 : _a.removeAttribute("data-active");
1179
- },
1180
- onClick: () => {
1181
- if (onRowClick) {
1182
- onRowClick(row.original);
1183
- }
1184
- },
1185
- children: row.getVisibleCells().map((cell) => {
1186
- var _a, _b;
1187
- const isDisabled = (_b = (_a = cell.row.original) == null ? void 0 : _a.disabled) == null ? void 0 : _b[cell.column.id];
1188
- return /* @__PURE__ */ jsx24(
1189
- Td,
1190
- {
1191
- "data-test-id": `CT_Component_TableCell_${cell.id}`,
1192
- fontSize: "text.sm",
1193
- sx: getCommonPinningStyles(cell.column),
1194
- ...styles == null ? void 0 : styles.tableCell,
1195
- children: /* @__PURE__ */ jsx24(Flex2, { height: "100%", align: "center", opacity: isDisabled ? 0.5 : 1, children: /* @__PURE__ */ jsx24(
1196
- Flex2,
1197
- {
1198
- tabIndex: 0,
1199
- display: "inline-flex",
1200
- cursor: "auto",
1201
- "data-test-id": `CT_Component_TableCell_Content-${cell.id}`,
1202
- onMouseUp: (e) => e.stopPropagation(),
1203
- onMouseDown: (e) => e.stopPropagation(),
1204
- onClick: (e) => {
1205
- e.stopPropagation();
1206
- },
1207
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
1208
- }
1209
- ) })
1210
- },
1211
- cell.id
1212
- );
1213
- })
1214
- },
1215
- row.id
1216
- );
1217
- }) })
1218
- ] }) });
1219
- }
1220
- );
1217
+ })
1218
+ },
1219
+ row.id
1220
+ );
1221
+ }) })
1222
+ ] }) });
1223
+ });
1221
1224
  var data_table_default = DataTable;
1222
1225
 
1223
1226
  // src/components/datepicker/components/datepicker.tsx
@@ -7095,7 +7098,10 @@ export {
7095
7098
  forwardRef12 as forwardRef,
7096
7099
  getSelectAllCheckboxState,
7097
7100
  getTheme,
7101
+ isCellDisabled,
7102
+ selectStyles,
7098
7103
  theme4 as theme,
7104
+ themeSelect,
7099
7105
  useAccordion,
7100
7106
  useAccordionContext,
7101
7107
  useAccordionItem,