@jswork/antd-components 1.0.192 → 1.0.194

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.192",
3
+ "version": "1.0.194",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.esm.js",
6
6
  "types": "dist/main.d.ts",
@@ -2,7 +2,7 @@
2
2
  * @Author: aric 1290657123@qq.com
3
3
  * @Date: 2025-10-25 10:45:13
4
4
  * @LastEditors: aric 1290657123@qq.com
5
- * @LastEditTime: 2025-10-25 18:41:04
5
+ * @LastEditTime: 2025-10-29 17:49:27
6
6
  */
7
7
  import NiceForm from '@ebay/nice-form-react';
8
8
  import { AcCheckableTagFc } from './checkable-tag';
@@ -67,7 +67,7 @@ export const widgets = {
67
67
  'ac:upload': AcUploadFc,
68
68
  };
69
69
 
70
- export const initWidgets = (names?: string[]) => {
70
+ export const initWidgets = (names?: string[], externalWidgets?: any) => {
71
71
  const keys = names?.length ? names : Object.keys(widgets);
72
72
  keys.forEach((key) => {
73
73
  const widget = widgets[key];
@@ -77,4 +77,11 @@ export const initWidgets = (names?: string[]) => {
77
77
  console.warn(`[defineWidgets] widget ${key} not found!`);
78
78
  }
79
79
  });
80
+
81
+ if (externalWidgets) {
82
+ Object.keys(externalWidgets).forEach((key) => {
83
+ const widget = externalWidgets[key];
84
+ NiceForm.defineWidget(key, widget);
85
+ });
86
+ }
80
87
  };
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @Author: aric.zheng 1290657123@qq.com
3
3
  * @Date: 2025-10-29 10:54:41
4
- * @LastEditors: aric.zheng 1290657123@qq.com
5
- * @LastEditTime: 2025-10-29 15:50:45
4
+ * @LastEditors: aric 1290657123@qq.com
5
+ * @LastEditTime: 2025-10-29 16:39:12
6
6
  */
7
7
  import React, { FC, useEffect } from 'react';
8
- import { AcSearch, AcSearchProps } from './search';
9
- import { readSearchString } from '@jswork/url-sync-flat';
8
+ import { readSearchString, writeSearchString } from '@jswork/url-sync-flat';
10
9
  import nx from '@jswork/next';
11
-
10
+ import { Input } from 'antd';
11
+ import { SearchProps } from 'antd/es/input';
12
12
 
13
13
  declare global {
14
14
  interface NxStatic {
@@ -17,7 +17,7 @@ declare global {
17
17
  }
18
18
  }
19
19
 
20
- export type AcTableExtraSearchProps = AcSearchProps & {
20
+ export type AcTableExtraSearchProps = SearchProps & {
21
21
  name: string;
22
22
  lang?: string;
23
23
  queryKey?: string;
@@ -39,38 +39,43 @@ const defaultProps = {
39
39
  routerType: 'hash' as const,
40
40
  };
41
41
 
42
+ const EMPTY_STR = '';
43
+
42
44
  export const AcTableExtraSearch: FC<AcTableExtraSearchProps> = (props) => {
43
45
  const { name, lang, queryKey, routerType, ...rest } = { ...defaultProps, ...props };
44
46
  const t = (key: string) => locales[lang!][key];
45
- const [value, setValue] = React.useState('');
46
47
  const searchParams = readSearchString(routerType);
47
48
  const defaultQuery = searchParams.get(queryKey) || '';
49
+ const [value, setValue] = React.useState(defaultQuery);
48
50
  const defaultParams = Object.fromEntries(searchParams.entries());
49
51
  const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {
50
52
  const q = e.target.value;
51
53
  setValue(q);
52
54
  };
53
55
 
56
+ const handleSearch = (q: string) => {
57
+ setValue(q);
58
+ nx.$event?.emit?.(`${name}:load`, { page: 1, ...defaultParams, [queryKey]: q });
59
+ };
60
+
54
61
  useEffect(() => {
55
62
  const res = nx.$event.on(`${name}:reset`, () => {
56
- setValue('');
63
+ setValue(EMPTY_STR);
64
+ searchParams.delete(queryKey);
65
+ writeSearchString(routerType, searchParams, true);
57
66
  });
58
67
  return res.destroy;
59
68
  }, []);
60
69
 
61
70
  return (
62
- <AcSearch
71
+ <Input.Search
63
72
  size="small"
64
73
  enterButton
65
74
  allowClear
66
- defaultValue={defaultQuery}
67
75
  value={value}
68
76
  placeholder={t('placeholder')}
69
77
  onChange={handleSearchChange}
70
- onSearch={(e) => {
71
- const q = e.target.value;
72
- nx.$event?.emit?.(`${name}:load`, { page: 1, ...defaultParams, [queryKey]: q });
73
- }}
78
+ onSearch={handleSearch}
74
79
  {...rest}
75
80
  />
76
81
  );