@jswork/antd-components 1.0.146 → 1.0.148

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jswork/antd-components",
3
- "version": "1.0.146",
3
+ "version": "1.0.148",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.esm.js",
6
6
  "types": "dist/main.d.ts",
package/src/lib/table.tsx CHANGED
@@ -2,7 +2,7 @@
2
2
  * @Author: aric 1290657123@qq.com
3
3
  * @Date: 2025-10-03 07:11:26
4
4
  * @LastEditors: aric 1290657123@qq.com
5
- * @LastEditTime: 2025-10-25 23:50:34
5
+ * @LastEditTime: 2025-10-26 08:56:31
6
6
  *
7
7
  *
8
8
  * 路由风格: /{module}/{name} eg: /admin/staff-roles
@@ -100,7 +100,7 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
100
100
  static formSchema = CLASS_NAME;
101
101
  private harmonyEvents: ReactHarmonyEvents | null = null;
102
102
  static event: EventMittNamespace.EventMitt;
103
- static events = ['refetch', 'reset', 'add', 'edit', 'destroy', 'optimisticUpdate'];
103
+ static events = ['refetch', 'reset', 'add', 'edit', 'destroy', 'draft'];
104
104
  static defaultProps = {
105
105
  name: '@',
106
106
  module: 'admin',
@@ -202,14 +202,15 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
202
202
  );
203
203
  };
204
204
 
205
- public optimisticUpdate = async (inId: any, inData: Record<string, any>) => {
205
+ public draft = async (payload: Record<string, any>) => {
206
206
  const { rowKey } = this.props;
207
+ const id = payload[rowKey as string];
207
208
  const dataSource = this.state.dataSource!.slice();
208
- const index = dataSource.findIndex((item) => item[rowKey as string] === inId);
209
+ const index = dataSource.findIndex((item) => item[rowKey as string] === id);
209
210
  if (index !== -1) {
210
211
  dataSource[index] = {
211
212
  ...dataSource[index],
212
- ...inData,
213
+ ...payload,
213
214
  };
214
215
  this.setState({ dataSource });
215
216
  }
@@ -1,7 +1,8 @@
1
1
  import { AcTable } from './table';
2
2
 
3
- type ExecuteFn = (command: string, ...args: any[]) => void;
3
+ type ExecuteFn = (command: string, data?: any) => void;
4
4
  type ListenFn = (command: string, callback: any) => void;
5
+ type Payload = Record<string, any>;
5
6
 
6
7
  const useCommand = (inName?: string) => {
7
8
  const name = inName || '@';
@@ -14,7 +15,7 @@ const useCommand = (inName?: string) => {
14
15
  const add = () => execute('add');
15
16
  const edit = () => execute('edit');
16
17
  const destroy = () => execute('destroy');
17
- const optimisticUpdate = (inId: any, inData: Record<string, any>) => execute('optimisticUpdate', inId, inData);
18
+ const draft = (payload: Payload) => execute('draft', payload);
18
19
 
19
20
  return {
20
21
  listen,
@@ -24,7 +25,7 @@ const useCommand = (inName?: string) => {
24
25
  add,
25
26
  edit,
26
27
  destroy,
27
- optimisticUpdate,
28
+ draft,
28
29
  };
29
30
  };
30
31