@hw-component/table 1.9.28 → 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,30 +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
|
-
|
|
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);
|
|
146
145
|
var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
|
|
147
146
|
_spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
|
|
148
|
-
|
|
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
|
+
});
|
|
149
152
|
rowOnChange(newKeys, newRowData);
|
|
150
153
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
151
154
|
};
|
|
155
|
+
var check = function check(e) {
|
|
156
|
+
var checked = e.target.checked;
|
|
157
|
+
if (checked) {
|
|
158
|
+
add();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
cancel();
|
|
162
|
+
};
|
|
152
163
|
var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
|
|
153
164
|
_ref6$disabled = _ref6.disabled,
|
|
154
165
|
disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
|
|
155
166
|
var checked = _indexOfInstanceProperty(keys).call(keys, key) !== -1;
|
|
156
|
-
useEffect(function () {
|
|
157
|
-
console.log("检测一次");
|
|
158
|
-
}, []);
|
|
159
167
|
return jsx(Checkbox, {
|
|
160
168
|
checked: checked,
|
|
161
169
|
onChange: check,
|
|
@@ -133,30 +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
|
-
|
|
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);
|
|
147
146
|
var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
|
|
148
147
|
_spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
|
|
149
|
-
|
|
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
|
+
});
|
|
150
153
|
rowOnChange(newKeys, newRowData);
|
|
151
154
|
onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
|
|
152
155
|
};
|
|
156
|
+
var check = function check(e) {
|
|
157
|
+
var checked = e.target.checked;
|
|
158
|
+
if (checked) {
|
|
159
|
+
add();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
cancel();
|
|
163
|
+
};
|
|
153
164
|
var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
|
|
154
165
|
_ref6$disabled = _ref6.disabled,
|
|
155
166
|
disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
|
|
156
167
|
var checked = _indexOfInstanceProperty(keys).call(keys, key) !== -1;
|
|
157
|
-
React.useEffect(function () {
|
|
158
|
-
console.log("检测一次");
|
|
159
|
-
}, []);
|
|
160
168
|
return jsxRuntime.jsx(antd.Checkbox, {
|
|
161
169
|
checked: checked,
|
|
162
170
|
onChange: check,
|
package/package.json
CHANGED
|
@@ -119,31 +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
|
-
|
|
125
|
+
newKeys.push(key);
|
|
126
|
+
newRowData.push(data);
|
|
127
|
+
rowOnChange(newKeys, newRowData);
|
|
128
|
+
onChange?.(newKeys, newRowData);
|
|
129
|
+
}
|
|
130
|
+
const cancel=()=>{
|
|
131
|
+
const newKeys = [...keys];
|
|
133
132
|
const keyIndex = newKeys.indexOf(key);
|
|
134
133
|
newKeys.splice(keyIndex, 1);
|
|
135
|
-
newRowData
|
|
134
|
+
const newRowData = rowData?.filter((item)=>{
|
|
135
|
+
const rowId=item[key];
|
|
136
|
+
const index=newKeys.indexOf(rowId);
|
|
137
|
+
return index!==-1;
|
|
138
|
+
});
|
|
136
139
|
rowOnChange(newKeys, newRowData);
|
|
137
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()
|
|
138
149
|
};
|
|
139
150
|
const { disabled = false } = getCheckboxProps?.(data) || {};
|
|
140
151
|
const checked=keys.indexOf(key) !== -1;
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
if (checked){
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
console.log("检测一次")
|
|
146
|
-
}, []);
|
|
147
152
|
return (
|
|
148
153
|
<Checkbox
|
|
149
154
|
checked={checked}
|