@jswork/antd-components 1.0.161 → 1.0.162

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.161",
3
+ "version": "1.0.162",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.esm.js",
6
6
  "types": "dist/main.d.ts",
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @Author: aric.zheng 1290657123@qq.com
3
+ * @Date: 2025-10-29 10:54:41
4
+ * @LastEditors: aric.zheng 1290657123@qq.com
5
+ * @LastEditTime: 2025-10-29 11:05:07
6
+ */
7
+ import React from 'react';
8
+ import { AcSearch } from './search';
9
+ import { FC } from 'react';
10
+
11
+
12
+ declare global {
13
+ interface NxStatic {
14
+ $event: any;
15
+ $api: Record<string, any>;
16
+ }
17
+ }
18
+
19
+ export type AcTableExtraSearchProps = AcSearch & {
20
+ name: string,
21
+ queryKey?: 'keywords'
22
+ }
23
+
24
+ export const AcTableExtraSearch: FC<AcTableExtraSearchProps> = (props) => {
25
+ const { name, queryKey = 'keywords', ...rest } = props;
26
+ return (
27
+ <AcSearch
28
+ name={name}
29
+ onSearch={(e) => {
30
+ const q = e.target.value;
31
+ nx.$event.emit(`${name}:load`, { [queryKey]: q });
32
+ }}
33
+ {...rest}
34
+ />
35
+ );
36
+ };
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.zheng 1290657123@qq.com
5
- * @LastEditTime: 2025-10-29 10:45:59
5
+ * @LastEditTime: 2025-10-29 11:00:08
6
6
  *
7
7
  *
8
8
  * 路由风格: /{module}/{name} eg: /admin/staff-roles
@@ -140,7 +140,7 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
140
140
  static formSchema = CLASS_NAME;
141
141
  private harmonyEvents: ReactHarmonyEvents | null = null;
142
142
  static event: EventMittNamespace.EventMitt;
143
- static events = ['refetch', 'reset', 'add', 'edit', 'destroy', 'draft'];
143
+ static events = ['load', 'refetch', 'reset', 'add', 'edit', 'destroy', 'draft'];
144
144
  static defaultProps = {
145
145
  name: '@',
146
146
  lang: 'zh-CN',
@@ -250,6 +250,13 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
250
250
  };
251
251
 
252
252
  /* ----- public eventBus methods start ----- */
253
+ /**
254
+ * Load data from backend.
255
+ */
256
+ public load = async (payload: Record<string, any>) => {
257
+ const { page, size, ...rest } = payload;
258
+ await this.fetchData(page, size, rest);
259
+ };
253
260
  /**
254
261
  * Refresh data use current state.
255
262
  */
@@ -10,6 +10,7 @@ const useCommand = (inName?: string) => {
10
10
  const listen: ListenFn = (cmd, callback) => AcTable.event?.on(`${name}:${cmd}`, callback);
11
11
 
12
12
  // the command repository:
13
+ const load = () => execute('load');
13
14
  const refetch = () => execute('refetch');
14
15
  const reset = () => execute('reset');
15
16
  const add = () => execute('add');
@@ -20,6 +21,7 @@ const useCommand = (inName?: string) => {
20
21
  return {
21
22
  listen,
22
23
  execute,
24
+ load,
23
25
  refetch,
24
26
  reset,
25
27
  add,
package/src/main.ts CHANGED
@@ -80,6 +80,8 @@ import type { AcTableExtrasProps } from './lib/table-extras';
80
80
  import { initWidgets } from './lib/init-widgets';
81
81
  import { FormActions } from './lib/form-actions';
82
82
  import type { FormActionsProps } from './lib/form-actions';
83
+ import { AcTableExtraSearch } from './lib/table-extra-search';
84
+ import type { AcTableExtraSearchProps } from './lib/table-extra-search';
83
85
 
84
86
  export * from './lib/button';
85
87
 
@@ -171,6 +173,7 @@ export {
171
173
  AcUploadPictureCardFc,
172
174
  AcUploadFc,
173
175
  FormActions,
176
+ AcTableExtraSearch,
174
177
 
175
178
  // ---- commands ----
176
179
  useTableCommand,
@@ -209,6 +212,7 @@ export {
209
212
  AcUploadDraggerProps,
210
213
  AcUploadProps,
211
214
  FormActionsProps,
215
+ AcTableExtraSearchProps,
212
216
 
213
217
  // ---- widgets ----
214
218
  initWidgets,