@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, useEffect } from 'react';
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 check = function check(e) {
136
- var checked = e.target.checked;
135
+ var add = function add() {
137
136
  var newKeys = _toConsumableArray(keys);
138
137
  var newRowData = _toConsumableArray(rowData);
139
- if (checked) {
140
- newKeys.push(key);
141
- newRowData.push(data);
142
- rowOnChange(newKeys, newRowData);
143
- onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
144
- return;
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
- _spliceInstanceProperty(newRowData).call(newRowData, keyIndex, 1);
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 check = function check(e) {
137
- var checked = e.target.checked;
136
+ var add = function add() {
138
137
  var newKeys = _toConsumableArray(keys);
139
138
  var newRowData = _toConsumableArray(rowData);
140
- if (checked) {
141
- newKeys.push(key);
142
- newRowData.push(data);
143
- rowOnChange(newKeys, newRowData);
144
- onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
145
- return;
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
- _spliceInstanceProperty(newRowData).call(newRowData, keyIndex, 1);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "1.9.28",
3
+ "version": "1.9.30",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -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 check = (e) => {
123
- const checked = e.target.checked;
122
+ const add=()=>{
124
123
  const newKeys = [...keys];
125
124
  const newRowData = [...rowData];
126
- if (checked) {
127
- newKeys.push(key);
128
- newRowData.push(data);
129
- rowOnChange(newKeys, newRowData);
130
- onChange?.(newKeys, newRowData);
131
- return;
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.splice(keyIndex, 1);
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}
@@ -181,7 +181,9 @@ export default () => {
181
181
  console.log(params, "lllll");
182
182
  },
183
183
  }}
184
- rowSelection={false}
184
+ rowSelection={{
185
+ allPageCheck:false
186
+ }}
185
187
  affixProps={{
186
188
  target: () => document.querySelector(".body"),
187
189
  }}