@ctlyst.id/internal-ui 5.0.3 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +15 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -1079,6 +1079,7 @@ var useDataTable = ({
|
|
1079
1079
|
const [isFirstLoad, setIsFirstLoad] = React5.useState(true);
|
1080
1080
|
const [sorting, setSorting] = React5.useState(sortingState != null ? sortingState : []);
|
1081
1081
|
const dataColumns = React5.useMemo(() => columns, [columns]);
|
1082
|
+
const action = React5.useRef("");
|
1082
1083
|
const checkboxColumn = React5.useMemo(
|
1083
1084
|
() => [
|
1084
1085
|
{
|
@@ -1090,11 +1091,12 @@ var useDataTable = ({
|
|
1090
1091
|
"data-test-id": "select-header-data-table",
|
1091
1092
|
...{
|
1092
1093
|
isDisabled: table2.getPaginationRowModel().rows.filter((row) => !(disabledRow == null ? void 0 : disabledRow(row.original))).length === 0,
|
1093
|
-
isChecked: table2.
|
1094
|
-
isIndeterminate: table2.
|
1094
|
+
isChecked: table2.getIsAllPageRowsSelected(),
|
1095
|
+
isIndeterminate: table2.getIsSomePageRowsSelected(),
|
1095
1096
|
onChange: () => {
|
1097
|
+
action.current = "selectAll";
|
1096
1098
|
if (table2.getIsAllRowsSelected()) {
|
1097
|
-
table2.
|
1099
|
+
table2.toggleAllRowsSelected();
|
1098
1100
|
} else if (disabledRow) {
|
1099
1101
|
const prevSelected = table2.getFilteredSelectedRowModel().rows.length;
|
1100
1102
|
const rows = table2.getPaginationRowModel().rows.filter((row) => !disabledRow(row.original));
|
@@ -1104,7 +1106,7 @@ var useDataTable = ({
|
|
1104
1106
|
table2.setRowSelection(Object.fromEntries(rows.map((row) => [row.id, true])));
|
1105
1107
|
}
|
1106
1108
|
} else {
|
1107
|
-
table2.
|
1109
|
+
table2.toggleAllRowsSelected();
|
1108
1110
|
}
|
1109
1111
|
}
|
1110
1112
|
}
|
@@ -1122,7 +1124,7 @@ var useDataTable = ({
|
|
1122
1124
|
) })
|
1123
1125
|
}
|
1124
1126
|
],
|
1125
|
-
[]
|
1127
|
+
[dataSource]
|
1126
1128
|
);
|
1127
1129
|
const generateColumn = () => {
|
1128
1130
|
if (withSelectedRow) {
|
@@ -1152,15 +1154,16 @@ var useDataTable = ({
|
|
1152
1154
|
});
|
1153
1155
|
const { getSelectedRowModel, toggleAllRowsSelected } = table;
|
1154
1156
|
const { flatRows } = getSelectedRowModel();
|
1155
|
-
React5.useEffect(() => {
|
1156
|
-
table.setRowSelection(selectedRow != null ? selectedRow : {});
|
1157
|
-
}, [selectedRow]);
|
1158
1157
|
React5.useEffect(() => {
|
1159
1158
|
const rowData = flatRows.map((row) => row.original);
|
1160
1159
|
if (onSelectedRow) {
|
1161
|
-
onSelectedRow(rowData);
|
1160
|
+
onSelectedRow(rowData, action.current);
|
1162
1161
|
}
|
1163
1162
|
}, [flatRows]);
|
1163
|
+
React5.useEffect(() => {
|
1164
|
+
action.current = "newData";
|
1165
|
+
table.setRowSelection(selectedRow != null ? selectedRow : {});
|
1166
|
+
}, [selectedRow]);
|
1164
1167
|
React5.useEffect(() => {
|
1165
1168
|
if (onSort && !isFirstLoad) {
|
1166
1169
|
onSort(sorting);
|
@@ -1171,6 +1174,7 @@ var useDataTable = ({
|
|
1171
1174
|
}, []);
|
1172
1175
|
return {
|
1173
1176
|
table,
|
1177
|
+
action,
|
1174
1178
|
toggleAllRowsSelected,
|
1175
1179
|
generateColumn
|
1176
1180
|
};
|
@@ -1191,7 +1195,7 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1191
1195
|
cellLineClamp = 2
|
1192
1196
|
} = props;
|
1193
1197
|
const { clickOrDragged, getDragOrClickProps } = useDragOrClick();
|
1194
|
-
const { table, toggleAllRowsSelected, generateColumn } = useDataTable(props);
|
1198
|
+
const { table, action, toggleAllRowsSelected, generateColumn } = useDataTable(props);
|
1195
1199
|
const refTable = React5.useRef(null);
|
1196
1200
|
React5.useImperativeHandle(ref, () => ({
|
1197
1201
|
toggleAllRowsSelected
|
@@ -1352,6 +1356,7 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1352
1356
|
(_a2 = e.currentTarget) == null ? void 0 : _a2.removeAttribute("data-active");
|
1353
1357
|
},
|
1354
1358
|
onClick: () => {
|
1359
|
+
action.current = "selectRow";
|
1355
1360
|
if (withSelectedRow) row.toggleSelected();
|
1356
1361
|
if (onRowClick) {
|
1357
1362
|
if (isDisabledRow) return;
|