@hw-component/table 1.9.29 → 1.9.30
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.
|
@@ -8,7 +8,7 @@ import _spliceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/insta
|
|
|
8
8
|
import { jsx } from 'react/jsx-runtime';
|
|
9
9
|
import { useHTableContext } from '../context.js';
|
|
10
10
|
import { Dropdown, Checkbox, Menu } from 'antd';
|
|
11
|
-
import { useMemo
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
12
|
|
|
13
13
|
var RowSelectionTitle = function RowSelectionTitle(_ref) {
|
|
14
14
|
var _ref$allPageCheck = _ref.allPageCheck,
|
|
@@ -132,33 +132,38 @@ var RowSelectionBox = function RowSelectionBox(_ref5) {
|
|
|
132
132
|
_selectedRowData$keys = _keysInstanceProperty(selectedRowData),
|
|
133
133
|
keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys;
|
|
134
134
|
var key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
135
|
-
var
|
|
136
|
-
var checked = e.target.checked;
|
|
135
|
+
var add = function add() {
|
|
137
136
|
var newKeys = _toConsumableArray(keys);
|
|
138
137
|
var newRowData = _toConsumableArray(rowData);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
138
|
+
newKeys.push(key);
|
|
139
|
+
newRowData.push(data);
|
|
140
|
+
rowOnChange(newKeys, newRowData);
|
|
141
|
+
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
142
|
+
};
|
|
143
|
+
var cancel = function cancel() {
|
|
144
|
+
var newKeys = _toConsumableArray(keys);
|
|
147
145
|
var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
|
|
148
|
-
console.log(keyIndex, "keyIndex");
|
|
149
146
|
_spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
var newRowData = rowData === null || rowData === void 0 ? void 0 : _filterInstanceProperty(rowData).call(rowData, function (item) {
|
|
148
|
+
var rowId = item[key];
|
|
149
|
+
var index = _indexOfInstanceProperty(newKeys).call(newKeys, rowId);
|
|
150
|
+
return index !== -1;
|
|
151
|
+
});
|
|
152
152
|
rowOnChange(newKeys, newRowData);
|
|
153
153
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
154
154
|
};
|
|
155
|
+
var check = function check(e) {
|
|
156
|
+
var checked = e.target.checked;
|
|
157
|
+
if (checked) {
|
|
158
|
+
add();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
cancel();
|
|
162
|
+
};
|
|
155
163
|
var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
|
|
156
164
|
_ref6$disabled = _ref6.disabled,
|
|
157
165
|
disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
|
|
158
166
|
var checked = _indexOfInstanceProperty(keys).call(keys, key) !== -1;
|
|
159
|
-
useEffect(function () {
|
|
160
|
-
console.log("检测一次");
|
|
161
|
-
}, []);
|
|
162
167
|
return jsx(Checkbox, {
|
|
163
168
|
checked: checked,
|
|
164
169
|
onChange: check,
|
|
@@ -133,33 +133,38 @@ var RowSelectionBox = function RowSelectionBox(_ref5) {
|
|
|
133
133
|
_selectedRowData$keys = _keysInstanceProperty(selectedRowData),
|
|
134
134
|
keys = _selectedRowData$keys === void 0 ? [] : _selectedRowData$keys;
|
|
135
135
|
var key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
136
|
-
var
|
|
137
|
-
var checked = e.target.checked;
|
|
136
|
+
var add = function add() {
|
|
138
137
|
var newKeys = _toConsumableArray(keys);
|
|
139
138
|
var newRowData = _toConsumableArray(rowData);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
139
|
+
newKeys.push(key);
|
|
140
|
+
newRowData.push(data);
|
|
141
|
+
rowOnChange(newKeys, newRowData);
|
|
142
|
+
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
143
|
+
};
|
|
144
|
+
var cancel = function cancel() {
|
|
145
|
+
var newKeys = _toConsumableArray(keys);
|
|
148
146
|
var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
|
|
149
|
-
console.log(keyIndex, "keyIndex");
|
|
150
147
|
_spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
var newRowData = rowData === null || rowData === void 0 ? void 0 : _filterInstanceProperty(rowData).call(rowData, function (item) {
|
|
149
|
+
var rowId = item[key];
|
|
150
|
+
var index = _indexOfInstanceProperty(newKeys).call(newKeys, rowId);
|
|
151
|
+
return index !== -1;
|
|
152
|
+
});
|
|
153
153
|
rowOnChange(newKeys, newRowData);
|
|
154
154
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
155
155
|
};
|
|
156
|
+
var check = function check(e) {
|
|
157
|
+
var checked = e.target.checked;
|
|
158
|
+
if (checked) {
|
|
159
|
+
add();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
cancel();
|
|
163
|
+
};
|
|
156
164
|
var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
|
|
157
165
|
_ref6$disabled = _ref6.disabled,
|
|
158
166
|
disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
|
|
159
167
|
var checked = _indexOfInstanceProperty(keys).call(keys, key) !== -1;
|
|
160
|
-
React.useEffect(function () {
|
|
161
|
-
console.log("检测一次");
|
|
162
|
-
}, []);
|
|
163
168
|
return jsxRuntime.jsx(antd.Checkbox, {
|
|
164
169
|
checked: checked,
|
|
165
170
|
onChange: check,
|
package/package.json
CHANGED
|
@@ -119,34 +119,36 @@ export const RowSelectionBox = ({
|
|
|
119
119
|
const { selectedRowData, rowOnChange, rowKey = "id" } = useHTableContext();
|
|
120
120
|
const { rowData = [], keys = [] } = selectedRowData;
|
|
121
121
|
const key = typeof rowKey === "function" ? rowKey(data, index) : data[rowKey];
|
|
122
|
-
const
|
|
123
|
-
const checked = e.target.checked;
|
|
122
|
+
const add=()=>{
|
|
124
123
|
const newKeys = [...keys];
|
|
125
124
|
const newRowData = [...rowData];
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
125
|
+
newKeys.push(key);
|
|
126
|
+
newRowData.push(data);
|
|
127
|
+
rowOnChange(newKeys, newRowData);
|
|
128
|
+
onChange?.(newKeys, newRowData);
|
|
129
|
+
}
|
|
130
|
+
const cancel=()=>{
|
|
131
|
+
const newKeys = [...keys];
|
|
134
132
|
const keyIndex = newKeys.indexOf(key);
|
|
135
|
-
console.log(keyIndex,"keyIndex")
|
|
136
133
|
newKeys.splice(keyIndex, 1);
|
|
137
|
-
newRowData
|
|
138
|
-
|
|
134
|
+
const newRowData = rowData?.filter((item)=>{
|
|
135
|
+
const rowId=item[key];
|
|
136
|
+
const index=newKeys.indexOf(rowId);
|
|
137
|
+
return index!==-1;
|
|
138
|
+
});
|
|
139
139
|
rowOnChange(newKeys, newRowData);
|
|
140
140
|
onChange?.(newKeys, newRowData);
|
|
141
|
+
}
|
|
142
|
+
const check = (e) => {
|
|
143
|
+
const checked = e.target.checked;
|
|
144
|
+
if (checked) {
|
|
145
|
+
add();
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
cancel()
|
|
141
149
|
};
|
|
142
150
|
const { disabled = false } = getCheckboxProps?.(data) || {};
|
|
143
151
|
const checked=keys.indexOf(key) !== -1;
|
|
144
|
-
useEffect(() => {
|
|
145
|
-
if (checked){
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
console.log("检测一次")
|
|
149
|
-
}, []);
|
|
150
152
|
return (
|
|
151
153
|
<Checkbox
|
|
152
154
|
checked={checked}
|