@jswork/antd-components 1.0.142 → 1.0.143

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.143",
4
4
  "main": "dist/main.cjs.js",
5
5
  "module": "dist/main.esm.js",
6
6
  "types": "dist/main.d.ts",
@@ -0,0 +1,69 @@
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 18:57:40
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
+ okText?: string;
13
+ cancelText?: string;
14
+ onOk?: (e: React.MouseEvent<HTMLElement>) => void;
15
+ onCancel?: (e: React.MouseEvent<HTMLElement>) => void;
16
+ okProps?: ButtonProps;
17
+ cancelProps?: ButtonProps;
18
+ buttonProps?: ButtonProps;
19
+ }
20
+
21
+ const defaultProps: FormActionsProps = {
22
+ lang: 'zh-CN',
23
+ };
24
+
25
+ const locales = {
26
+ 'zh-CN': {
27
+ ok: '确认',
28
+ cancel: '取消',
29
+ },
30
+ 'en-US': {
31
+ ok: 'OK',
32
+ cancel: 'Cancel',
33
+ },
34
+ };
35
+
36
+ export const FormActions = React.forwardRef((props: FormActionsProps, ref: RefObject<HTMLDivElement>) => {
37
+ const {
38
+ lang,
39
+ okText,
40
+ cancelText,
41
+ onOk,
42
+ onCancel,
43
+ okProps,
44
+ cancelProps,
45
+ buttonProps,
46
+ ...rest
47
+ } = { ...defaultProps, ...props };
48
+ const t = (key: string) => locales[lang!][key];
49
+
50
+ return (
51
+ <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
+ />
67
+ </Space>
68
+ );
69
+ });
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,