@jswork/antd-components 1.0.143 → 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.143",
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",
@@ -2,13 +2,14 @@
2
2
  * @Author: aric 1290657123@qq.com
3
3
  * @Date: 2025-10-25 18:48:19
4
4
  * @LastEditors: aric 1290657123@qq.com
5
- * @LastEditTime: 2025-10-25 18:57:40
5
+ * @LastEditTime: 2025-10-25 21:51:46
6
6
  */
7
7
  import React, { RefObject } from 'react';
8
8
  import { Button, ButtonProps, Space, SpaceProps } from 'antd';
9
9
 
10
10
  export type FormActionsProps = SpaceProps & {
11
11
  lang?: string;
12
+ actions?: string[];
12
13
  okText?: string;
13
14
  cancelText?: string;
14
15
  onOk?: (e: React.MouseEvent<HTMLElement>) => void;
@@ -20,6 +21,7 @@ export type FormActionsProps = SpaceProps & {
20
21
 
21
22
  const defaultProps: FormActionsProps = {
22
23
  lang: 'zh-CN',
24
+ actions: ['ok', 'cancel'],
23
25
  };
24
26
 
25
27
  const locales = {
@@ -36,6 +38,7 @@ const locales = {
36
38
  export const FormActions = React.forwardRef((props: FormActionsProps, ref: RefObject<HTMLDivElement>) => {
37
39
  const {
38
40
  lang,
41
+ actions,
39
42
  okText,
40
43
  cancelText,
41
44
  onOk,
@@ -45,25 +48,31 @@ export const FormActions = React.forwardRef((props: FormActionsProps, ref: RefOb
45
48
  buttonProps,
46
49
  ...rest
47
50
  } = { ...defaultProps, ...props };
51
+
48
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
+ };
49
72
 
50
73
  return (
51
74
  <Space {...rest} ref={ref}>
52
- <Button
53
- htmlType="submit"
54
- type="primary"
55
- onClick={onOk}
56
- children={okText || t('ok')}
57
- {...buttonProps}
58
- {...okProps}
59
- />
60
- <Button
61
- htmlType="reset"
62
- onClick={onCancel}
63
- children={cancelText || t('cancel')}
64
- {...buttonProps}
65
- {...cancelProps}
66
- />
75
+ {actions!.map(key => items[key])}
67
76
  </Space>
68
77
  );
69
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',