@hw-component/table 1.9.29 → 1.9.31

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,33 +132,36 @@ 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() {
136
+ var newKeys = _toConsumableArray(keys);
137
+ var newRowData = _toConsumableArray(rowData);
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() {
137
144
  var newKeys = _toConsumableArray(keys);
138
145
  var newRowData = _toConsumableArray(rowData);
139
- if (checked) {
140
- newKeys.push(key);
141
- newRowData.push(data);
142
- console.log(newKeys, newRowData, "newKeys,newRowData");
143
- rowOnChange(newKeys, newRowData);
144
- onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
145
- return;
146
- }
147
146
  var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
148
- console.log(keyIndex, "keyIndex");
149
147
  _spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
150
148
  _spliceInstanceProperty(newRowData).call(newRowData, keyIndex, 1);
151
- console.log(newKeys, newRowData, "newKeys,newRowData");
152
149
  rowOnChange(newKeys, newRowData);
153
150
  onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
154
151
  };
152
+ var check = function check(e) {
153
+ var checked = e.target.checked;
154
+ if (checked) {
155
+ add();
156
+ return;
157
+ }
158
+ cancel();
159
+ };
155
160
  var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
156
161
  _ref6$disabled = _ref6.disabled,
157
162
  disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
158
163
  var checked = _indexOfInstanceProperty(keys).call(keys, key) !== -1;
159
- useEffect(function () {
160
- console.log("检测一次");
161
- }, []);
164
+ console.log(keys, rowData, "keys,rowData");
162
165
  return jsx(Checkbox, {
163
166
  checked: checked,
164
167
  onChange: check,
@@ -133,33 +133,36 @@ 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() {
137
+ var newKeys = _toConsumableArray(keys);
138
+ var newRowData = _toConsumableArray(rowData);
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() {
138
145
  var newKeys = _toConsumableArray(keys);
139
146
  var newRowData = _toConsumableArray(rowData);
140
- if (checked) {
141
- newKeys.push(key);
142
- newRowData.push(data);
143
- console.log(newKeys, newRowData, "newKeys,newRowData");
144
- rowOnChange(newKeys, newRowData);
145
- onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
146
- return;
147
- }
148
147
  var keyIndex = _indexOfInstanceProperty(newKeys).call(newKeys, key);
149
- console.log(keyIndex, "keyIndex");
150
148
  _spliceInstanceProperty(newKeys).call(newKeys, keyIndex, 1);
151
149
  _spliceInstanceProperty(newRowData).call(newRowData, keyIndex, 1);
152
- console.log(newKeys, newRowData, "newKeys,newRowData");
153
150
  rowOnChange(newKeys, newRowData);
154
151
  onChange === null || onChange === void 0 || onChange(newKeys, newRowData);
155
152
  };
153
+ var check = function check(e) {
154
+ var checked = e.target.checked;
155
+ if (checked) {
156
+ add();
157
+ return;
158
+ }
159
+ cancel();
160
+ };
156
161
  var _ref6 = (getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(data)) || {},
157
162
  _ref6$disabled = _ref6.disabled,
158
163
  disabled = _ref6$disabled === void 0 ? false : _ref6$disabled;
159
164
  var checked = _indexOfInstanceProperty(keys).call(keys, key) !== -1;
160
- React.useEffect(function () {
161
- console.log("检测一次");
162
- }, []);
165
+ console.log(keys, rowData, "keys,rowData");
163
166
  return jsxRuntime.jsx(antd.Checkbox, {
164
167
  checked: checked,
165
168
  onChange: check,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/table",
3
- "version": "1.9.29",
3
+ "version": "1.9.31",
4
4
  "description": "基于antd二次开发table组件",
5
5
  "keywords": [
6
6
  "table"
@@ -119,34 +119,34 @@ 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
- console.log(newKeys,newRowData,"newKeys,newRowData")
130
- rowOnChange(newKeys, newRowData);
131
- onChange?.(newKeys, newRowData);
132
- return;
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];
132
+ const newRowData=[...rowData];
134
133
  const keyIndex = newKeys.indexOf(key);
135
- console.log(keyIndex,"keyIndex")
136
134
  newKeys.splice(keyIndex, 1);
137
- newRowData.splice(keyIndex, 1);
138
- console.log(newKeys,newRowData,"newKeys,newRowData")
135
+ newRowData.splice(keyIndex,1);
139
136
  rowOnChange(newKeys, newRowData);
140
137
  onChange?.(newKeys, newRowData);
138
+ }
139
+ const check = (e) => {
140
+ const checked = e.target.checked;
141
+ if (checked) {
142
+ add();
143
+ return;
144
+ }
145
+ cancel()
141
146
  };
142
147
  const { disabled = false } = getCheckboxProps?.(data) || {};
143
148
  const checked=keys.indexOf(key) !== -1;
144
- useEffect(() => {
145
- if (checked){
146
-
147
- }
148
- console.log("检测一次")
149
- }, []);
149
+ console.log(keys,rowData,"keys,rowData");
150
150
  return (
151
151
  <Checkbox
152
152
  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
  }}