@jswork/antd-components 1.0.142 → 1.0.144

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.142",
3
+ "version": "1.0.144",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.esm.js",
6
6
  "types": "dist/main.d.ts",
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @Author: aric 1290657123@qq.com
3
+ * @Date: 2025-10-25 18:48:19
4
+ * @LastEditors: aric 1290657123@qq.com
5
+ * @LastEditTime: 2025-10-25 21:51:46
6
+ */
7
+ import React, { RefObject } from 'react';
8
+ import { Button, ButtonProps, Space, SpaceProps } from 'antd';
9
+
10
+ export type FormActionsProps = SpaceProps & {
11
+ lang?: string;
12
+ actions?: string[];
13
+ okText?: string;
14
+ cancelText?: string;
15
+ onOk?: (e: React.MouseEvent<HTMLElement>) => void;
16
+ onCancel?: (e: React.MouseEvent<HTMLElement>) => void;
17
+ okProps?: ButtonProps;
18
+ cancelProps?: ButtonProps;
19
+ buttonProps?: ButtonProps;
20
+ }
21
+
22
+ const defaultProps: FormActionsProps = {
23
+ lang: 'zh-CN',
24
+ actions: ['ok', 'cancel'],
25
+ };
26
+
27
+ const locales = {
28
+ 'zh-CN': {
29
+ ok: '确认',
30
+ cancel: '取消',
31
+ },
32
+ 'en-US': {
33
+ ok: 'OK',
34
+ cancel: 'Cancel',
35
+ },
36
+ };
37
+
38
+ export const FormActions = React.forwardRef((props: FormActionsProps, ref: RefObject<HTMLDivElement>) => {
39
+ const {
40
+ lang,
41
+ actions,
42
+ okText,
43
+ cancelText,
44
+ onOk,
45
+ onCancel,
46
+ okProps,
47
+ cancelProps,
48
+ buttonProps,
49
+ ...rest
50
+ } = { ...defaultProps, ...props };
51
+
52
+ const t = (key: string) => locales[lang!][key];
53
+ const items = {
54
+ ok: <Button
55
+ key="ok"
56
+ htmlType="submit"
57
+ type="primary"
58
+ onClick={onOk}
59
+ children={okText || t('ok')}
60
+ {...buttonProps}
61
+ {...okProps}
62
+ />,
63
+ cancel: <Button
64
+ key="cancel"
65
+ htmlType="reset"
66
+ onClick={onCancel}
67
+ children={cancelText || t('cancel')}
68
+ {...buttonProps}
69
+ {...cancelProps}
70
+ />,
71
+ };
72
+
73
+ return (
74
+ <Space {...rest} ref={ref}>
75
+ {actions!.map(key => items[key])}
76
+ </Space>
77
+ );
78
+ });
@@ -17,11 +17,11 @@ export class AcSwitch extends React.Component<AcSwitchProps> {
17
17
  static displayName = CLASS_NAME;
18
18
  static formSchema = CLASS_NAME;
19
19
  static defaultProps = {
20
- onChange: noop
20
+ onChange: noop,
21
21
  };
22
22
 
23
23
  state = {
24
- value: Boolean(this.props.value)
24
+ value: Boolean(this.props.value),
25
25
  };
26
26
 
27
27
  shouldComponentUpdate(nextProps: Readonly<AcSwitchProps>): boolean {
@@ -51,7 +51,7 @@ export class AcSwitch extends React.Component<AcSwitchProps> {
51
51
  }
52
52
  }
53
53
 
54
- export const AcSwitchFc = (props: AcSwitchProps) => {
55
- return <AcSwitch {...props} />;
56
- };
54
+ export const AcSwitchFc = React.forwardRef<AcSwitch, AcSwitchProps>((props, ref) => {
55
+ return <AcSwitch {...props} ref={ref} />;
56
+ });
57
57
 
package/src/lib/table.tsx CHANGED
@@ -2,7 +2,11 @@
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 09:01:26
5
+ * @LastEditTime: 2025-10-25 20:06:56
6
+ *
7
+ *
8
+ * 路由风格: /{module}/{name} eg: /admin/staff-roles
9
+ * API资源风格: {module}_{name}_index eg: admin_staff-roles_index
6
10
  */
7
11
  import type { EventMittNamespace } from '@jswork/event-mitt';
8
12
  import { ReactHarmonyEvents } from '@jswork/harmony-events';
@@ -97,7 +101,6 @@ export class AcTable extends React.Component<AcTableProps, AcTableState> {
97
101
  private harmonyEvents: ReactHarmonyEvents | null = null;
98
102
  static event: EventMittNamespace.EventMitt;
99
103
  static events = ['refetch', 'reset', 'add', 'edit', 'destroy'];
100
-
101
104
  static defaultProps = {
102
105
  name: '@',
103
106
  module: 'admin',
package/src/main.ts CHANGED
@@ -78,6 +78,8 @@ import type { AcTableLinksProps } from './lib/table-links';
78
78
  import { AcTableExtras } from './lib/table-extras';
79
79
  import type { AcTableExtrasProps } from './lib/table-extras';
80
80
  import { initWidgets } from './lib/init-widgets';
81
+ import { FormActions } from './lib/form-actions';
82
+ import type { FormActionsProps } from './lib/form-actions';
81
83
 
82
84
  export * from './lib/button';
83
85
 
@@ -168,6 +170,7 @@ export {
168
170
  AcUploadPictureFc,
169
171
  AcUploadPictureCardFc,
170
172
  AcUploadFc,
173
+ FormActions,
171
174
 
172
175
  // ---- commands ----
173
176
  useTableCommand,
@@ -205,6 +208,7 @@ export {
205
208
  AcTreeSelectProps,
206
209
  AcUploadDraggerProps,
207
210
  AcUploadProps,
211
+ FormActionsProps,
208
212
 
209
213
  // ---- widgets ----
210
214
  initWidgets,