xph-crud 0.3.1 → 0.3.3

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.
Files changed (68) hide show
  1. package/dist/index.js +6 -0
  2. package/dist/index.umd.cjs +8 -8
  3. package/dist/types/common/index.d.ts +1 -1
  4. package/dist/types/common/src/{componnets → components}/actions/types/actionItem.d.ts +59 -18
  5. package/dist/types/common/src/components/actions/types/actions.d.ts +30 -0
  6. package/dist/types/common/src/{componnets → components}/auth/types/index.d.ts +9 -0
  7. package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogContentMaxHeight.d.ts +1 -1
  8. package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogFooter.d.ts +1 -1
  9. package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogPosition.d.ts +1 -1
  10. package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogSize.d.ts +1 -1
  11. package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogZoom.d.ts +1 -1
  12. package/dist/types/common/src/{componnets → components}/dialog/hooks/useDragDialog.d.ts +1 -1
  13. package/dist/types/common/src/{componnets → components}/dialog/hooks/useResizeDialog.d.ts +1 -1
  14. package/dist/types/common/src/components/dialog/types/dialog.d.ts +99 -0
  15. package/dist/types/common/src/{componnets → components}/index.d.ts +3 -0
  16. package/dist/types/common/src/hooks/useAsyncState.d.ts +2 -2
  17. package/dist/types/common/src/hooks/useExtendCompProps.d.ts +1 -1
  18. package/dist/types/common/src/types/extendComponent.d.ts +3 -1
  19. package/dist/types/common/src/utils/getValueByPath.d.ts +7 -4
  20. package/dist/types/common/src/utils/uuid.d.ts +3 -0
  21. package/dist/types/form/index.d.ts +1 -0
  22. package/dist/types/form/src/helper.d.ts +1 -1
  23. package/dist/types/form/src/hooks/useApiComonentCache.d.ts +6 -9
  24. package/dist/types/form/src/hooks/useForm.d.ts +1 -1
  25. package/dist/types/form/src/types/form.d.ts +81 -19
  26. package/dist/types/form/src/types/formItem.d.ts +102 -23
  27. package/dist/types/table/index.d.ts +3 -2
  28. package/dist/types/table/src/components/crudFormDialog/index.d.ts +2 -2
  29. package/dist/types/table/src/components/table/components/cellFunc/types/cellFunc.d.ts +32 -17
  30. package/dist/types/table/src/types/apiTable.d.ts +52 -21
  31. package/dist/types/table/src/types/column.d.ts +6 -2
  32. package/dist/types/table/src/types/crudFormDialog.d.ts +21 -8
  33. package/dist/types/table/src/types/searchForm.d.ts +6 -1
  34. package/dist/types/table/src/types/table.d.ts +22 -18
  35. package/package.json +1 -1
  36. package/dist/types/common/src/componnets/actions/types/actions.d.ts +0 -18
  37. package/dist/types/common/src/componnets/dialog/types/dialog.d.ts +0 -32
  38. /package/dist/types/common/src/{componnets → components}/actions/actions.d.ts +0 -0
  39. /package/dist/types/common/src/{componnets → components}/actions/components/button.d.ts +0 -0
  40. /package/dist/types/common/src/{componnets → components}/actions/components/dropdown.d.ts +0 -0
  41. /package/dist/types/common/src/{componnets → components}/actions/components/index.d.ts +0 -0
  42. /package/dist/types/common/src/{componnets → components}/actions/components/more.d.ts +0 -0
  43. /package/dist/types/common/src/{componnets → components}/actions/hooks/index.d.ts +0 -0
  44. /package/dist/types/common/src/{componnets → components}/actions/hooks/useActionItems.d.ts +0 -0
  45. /package/dist/types/common/src/{componnets → components}/actions/hooks/useActionsProps.d.ts +0 -0
  46. /package/dist/types/common/src/{componnets → components}/actions/hooks/useExtendActions.d.ts +0 -0
  47. /package/dist/types/common/src/{componnets → components}/actions/hooks/useRenderContent.d.ts +0 -0
  48. /package/dist/types/common/src/{componnets → components}/actions/types/index.d.ts +0 -0
  49. /package/dist/types/common/src/{componnets → components}/auth/auth.d.ts +0 -0
  50. /package/dist/types/common/src/{componnets → components}/auth/hooks/index.d.ts +0 -0
  51. /package/dist/types/common/src/{componnets → components}/auth/hooks/useAuthProps.d.ts +0 -0
  52. /package/dist/types/common/src/{componnets → components}/auth/hooks/useExtendAuth.d.ts +0 -0
  53. /package/dist/types/common/src/{componnets → components}/dialog/components/headerBtns/index.d.ts +0 -0
  54. /package/dist/types/common/src/{componnets → components}/dialog/components/minimizeDialog/index.d.ts +0 -0
  55. /package/dist/types/common/src/{componnets → components}/dialog/dialog.d.ts +0 -0
  56. /package/dist/types/common/src/{componnets → components}/dialog/hooks/index.d.ts +0 -0
  57. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogActions.d.ts +0 -0
  58. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogChangeRecord.d.ts +0 -0
  59. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useDialogProps.d.ts +0 -0
  60. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useExtendDialog.d.ts +0 -0
  61. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useMinResizeRecord.d.ts +0 -0
  62. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useMinimizeDialog.d.ts +0 -0
  63. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useOnContainerSizeChange.d.ts +0 -0
  64. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useOnPropsSizeChange.d.ts +0 -0
  65. /package/dist/types/common/src/{componnets → components}/dialog/hooks/usePopperContainerSize.d.ts +0 -0
  66. /package/dist/types/common/src/{componnets → components}/dialog/hooks/useTopShowDialog.d.ts +0 -0
  67. /package/dist/types/common/src/{componnets → components}/dialog/types/index.d.ts +0 -0
  68. /package/dist/types/common/src/{componnets → components}/portal/portal.d.ts +0 -0
@@ -0,0 +1,30 @@
1
+ import { TActionItemProps } from './actionItem';
2
+ import { ButtonProps } from 'antd/lib/button';
3
+ import { TXphExtendComponentPropsMap } from '../../../types';
4
+
5
+ export interface IActionsProps<T extends TXphExtendComponentPropsMap = {}> {
6
+ /**
7
+ * 类型
8
+ */
9
+ type?: ButtonProps["type"];
10
+ /**
11
+ * 操作项
12
+ */
13
+ items?: TActionItemProps<T>[];
14
+ /**
15
+ * 禁用(items中的componentProps的disabled优先级最高)
16
+ */
17
+ disabled?: boolean;
18
+ /**
19
+ * 自定义内容(items的优先级高于render)
20
+ */
21
+ render?: React.ReactElement;
22
+ /**
23
+ * 超过多少个item自动省略,默认是10(其余全部放在一个dropdown中)
24
+ */
25
+ max?: number;
26
+ /**
27
+ * 是否需要从扩展中继承属性(可能有些特殊情况,不需要使用扩展中的属性)
28
+ */
29
+ inherit?: boolean;
30
+ }
@@ -1,6 +1,15 @@
1
1
  /// <reference types="react" />
2
2
  export interface IAuthProps {
3
+ /**
4
+ * 鉴权内容
5
+ */
3
6
  children: React.ReactElement;
7
+ /**
8
+ * 鉴权函数
9
+ */
4
10
  auth?: (key: string) => boolean;
11
+ /**
12
+ * 鉴权标识
13
+ */
5
14
  authCode: string | Array<string>;
6
15
  }
@@ -1,4 +1,4 @@
1
- import { IContainerSizeTarget } from '../hooks';
1
+ import { IContainerSizeTarget } from '.';
2
2
 
3
3
  declare const useDialogContentMaxHeight: ({ visible, containerSizeTarget, dialogHeight, dialogRef, dialogHeaderRef, dialogFooterRef, }: {
4
4
  visible: boolean;
@@ -1,5 +1,5 @@
1
1
  import { IDialogProps } from '../types';
2
- import { IXphActionsProps } from '../../';
2
+ import { IXphActionsProps } from '../..';
3
3
 
4
4
  export default function useDialogFooter(props: IDialogProps, loading: boolean): {
5
5
  footerActions: IXphActionsProps<{}>;
@@ -1,4 +1,4 @@
1
- import { IDialogChangeRecord } from '../hooks';
1
+ import { IDialogChangeRecord } from '.';
2
2
 
3
3
  declare const useDialogPosition: ({ initLeft, initTop, setDialogChangeRecord, }: {
4
4
  initLeft: React.MutableRefObject<number>;
@@ -1,4 +1,4 @@
1
- import { IDialogChangeRecord } from '../hooks';
1
+ import { IDialogChangeRecord } from '.';
2
2
 
3
3
  declare const useDialogInitSize: ({ initWidth, initHeight, setDialogChangeRecord, }: {
4
4
  initWidth: React.MutableRefObject<string | number>;
@@ -1,4 +1,4 @@
1
- import { IDialogChangeRecord, IContainerSizeTarget } from '../hooks';
1
+ import { IDialogChangeRecord, IContainerSizeTarget } from '.';
2
2
 
3
3
  declare const useDialogZoom: ({ containerSizeTarget, dialogChangeRecord, close, setDialogSize, setDialogPosition, }: {
4
4
  containerSizeTarget: React.MutableRefObject<IContainerSizeTarget>;
@@ -1,4 +1,4 @@
1
- import { IContainerSizeTarget } from '../hooks';
1
+ import { IContainerSizeTarget } from '.';
2
2
 
3
3
  declare const useDragDialog: ({ containerSizeTarget, dialogHeaderRef, dialogRef, setDialogPosition, }: {
4
4
  containerSizeTarget: React.MutableRefObject<IContainerSizeTarget>;
@@ -1,5 +1,5 @@
1
1
  import { MouseEvent } from 'react';
2
- import { IContainerSizeTarget } from '../hooks';
2
+ import { IContainerSizeTarget } from '.';
3
3
 
4
4
  declare const useResizeDialog: ({ containerSizeTarget, dialogRef, minResizeRecord, setDialogSize, setDialogPosition, setMinResizeRecord, }: {
5
5
  containerSizeTarget: React.MutableRefObject<IContainerSizeTarget>;
@@ -0,0 +1,99 @@
1
+ import { ButtonProps } from 'antd';
2
+
3
+ export interface IDialogProps {
4
+ /**
5
+ * 弹窗的宽度
6
+ * @defaultValue `700`
7
+ */
8
+ width?: number;
9
+ /**
10
+ * 弹窗的高度
11
+ * @defaultValue `-`
12
+ */
13
+ height?: number;
14
+ /**
15
+ * 是否显示遮罩
16
+ * @defaultValue `false`
17
+ */
18
+ mask?: boolean;
19
+ /**
20
+ * 弹窗的标题
21
+ * @defaultValue `-`
22
+ */
23
+ title?: string;
24
+ /**
25
+ * 确定按钮属性
26
+ * @defaultValue `-`
27
+ */
28
+ okProps?: Omit<ButtonProps, "children" | "onClick">;
29
+ /**
30
+ * 取消按钮属性
31
+ * @defaultValue `-`
32
+ */
33
+ cancelProps?: Omit<ButtonProps, "children" | "onClick">;
34
+ /**
35
+ * 确定按钮文字
36
+ * @defaultValue `"确定"`
37
+ */
38
+ okText?: string;
39
+ /**
40
+ * 取消按钮文字
41
+ * @defaultValue `"取消"`
42
+ */
43
+ cancelText?: string;
44
+ /**
45
+ * 点击确定按钮触发该事件
46
+ * @defaultValue `-`
47
+ */
48
+ onOk?: (args: any) => Promise<void>;
49
+ /**
50
+ * 点击取消按钮触发该事件
51
+ * @defaultValue `-`
52
+ */
53
+ onCancel?: (args: any) => Promise<void>;
54
+ /**
55
+ * 底部按钮自定义渲染函数
56
+ * @defaultValue `-`
57
+ */
58
+ renderFooter?: ({ loading }: {
59
+ loading: boolean;
60
+ }) => React.ReactElement;
61
+ /**
62
+ * 顶部标题自定义渲染函数
63
+ * @defaultValue `-`
64
+ */
65
+ renderTitle?: () => React.ReactElement;
66
+ /**
67
+ * 打开的时候会触发该事件
68
+ * @defaultValue `-`
69
+ */
70
+ onOpen?: () => void;
71
+ /**
72
+ * 关闭的时候会触发该事件
73
+ * @defaultValue `-`
74
+ */
75
+ onClose?: () => void;
76
+ /**
77
+ * 挂载弹窗的容器
78
+ * @defaultValue `() => document.body`
79
+ */
80
+ getPopperContainer?: () => HTMLElement | null;
81
+ }
82
+ export interface IDialogActionType {
83
+ /**
84
+ * 打开
85
+ */
86
+ open: () => Promise<void>;
87
+ /**
88
+ * 关闭
89
+ */
90
+ close: () => void;
91
+ /**
92
+ * 设置loading
93
+ */
94
+ setLoading: (loading: boolean) => void;
95
+ /**
96
+ * 获取弹窗状态
97
+ */
98
+ getVisible: () => boolean;
99
+ }
@@ -6,4 +6,7 @@ import { default as XphPortal } from './portal/portal';
6
6
  import { default as XphAuth } from './auth/auth';
7
7
  import { IAuthProps as IXphAuthProps } from './auth/types';
8
8
 
9
+ export * from './actions/types';
10
+ export * from './auth/types';
11
+ export * from './dialog/types';
9
12
  export { XphActions, TXphActionItemProps, IXphActionsProps, XphDialog, IXphDialogProps, IXphDialogActionType, XphPortal, XphAuth, IXphAuthProps, };
@@ -1,6 +1,6 @@
1
1
  /**
2
- * 自定义 Hook 用于异步更新状态
3
- * @param initialState 初始状态
2
+ * @description 自定义 Hook 用于异步更新状态
3
+ * @param initialState - 初始状态
4
4
  * @returns [state, setAsyncState] state 是当前状态,setAsyncState 是更新状态的函数
5
5
  */
6
6
  export declare const useAsyncState: <T>(initialState: T) => [T, (newState: T) => Promise<void>];
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
- import { IXphActionsProps } from '../componnets';
2
+ import { IXphActionsProps } from '../components';
3
3
  import { IXphFormProps } from '../../../form';
4
4
  import { TXphTableProps } from '../../../table';
5
5
  import { IXphDialogProps, IXphAuthProps } from '../..';
@@ -1,2 +1,4 @@
1
- /** 扩展组件的props映射(共用) */
1
+ /**
2
+ * @description 扩展组件的props映射(共用)
3
+ */
2
4
  export type TExtendComponentPropsMap = Record<string, any>;
@@ -1,9 +1,12 @@
1
+ /**
2
+ * @description Helper function to get value by path
3
+ */
1
4
  export declare const getValueByPath: (obj: Record<string, any>, path: string) => any;
2
5
  /**
3
6
  * @description 通过属性为包含.的字符串的对象从值对象中获取值
4
- * @param fields = { current: 'data.current', pageSize: 'data.pageSize' }
5
- * @param values = { data: { current: 1, pageSize: 10 } }
6
- * @returns = { current: 1, pageSize: 10 }
7
- *
7
+ * @example
8
+ * fields { current: 'data.current', pageSize: 'data.pageSize' }
9
+ * values { data: { current: 1, pageSize: 10 } }
10
+ * return { current: 1, pageSize: 10 }
8
11
  */
9
12
  export declare const getValuesByPathObj: (fields: Record<string, string>, values: Record<string, any>) => Record<string, any>;
@@ -1 +1,4 @@
1
+ /**
2
+ * @description 生成随机数
3
+ */
1
4
  export declare function buildUUID(): string;
@@ -2,4 +2,5 @@ import { default as XphForm } from './src/form';
2
2
  import { IFormProps as IXphFormProps, IFormActionType as IXphFormActionType, TFormItemProps as TXphFormItemProps } from './src/types';
3
3
  import { useForm as useXphForm } from './src/hooks';
4
4
 
5
+ export * from './src/types';
5
6
  export { XphForm, IXphFormProps, TXphFormItemProps, IXphFormActionType, useXphForm, };
@@ -2,7 +2,7 @@ import { RuleObject } from 'antd/es/form';
2
2
  import { TComponentPropsMap, TFormItemProps } from './types';
3
3
 
4
4
  /**
5
- * @description: 生成placeholder
5
+ * @description 生成placeholder
6
6
  */
7
7
  export declare function createPlaceholderMessage(component: keyof TComponentPropsMap): "" | "请输入" | "请选择";
8
8
  export declare function setComponentRuleType(rule: RuleObject, component: keyof TComponentPropsMap, valueFormat: string): void;
@@ -1,15 +1,12 @@
1
1
  /**
2
- * 该钩子解决的问题:
2
+ * @description 该钩子解决的问题:
3
3
  * 1、使用了Form.useWatch的FormItem,至少都会触发两次组件更新,导致api首次请求的情况不一致
4
4
  * 2、每次value的更新,都会导致组件的重新渲染,导致api每次都会请求(处理成当params不一致才重新请求)
5
- */
6
- /**
7
- *
8
- * @param api 请求的api
9
- * @param apiCallback 请求之后的回调
10
- * @param immediate 首次是否立即执行apiCallback
11
- * @param params 请求的参数
12
- * @param isUseWatch 是否使用了Form.useWatch
5
+ * @param api - 请求的api
6
+ * @param apiCallback - 请求之后的回调
7
+ * @param immediate - 首次是否立即执行apiCallback
8
+ * @param params - 请求的参数
9
+ * @param isUseWatch - 是否使用了Form.useWatch
13
10
  */
14
11
  interface IUseComonentCacheProps {
15
12
  api?: (...args: any[]) => Promise<any>;
@@ -13,7 +13,7 @@ export declare const useFormModel: (formProps: IFormProps, itemProps: TFormItemP
13
13
  /**
14
14
  *
15
15
  * @description 用于注册form的方法
16
- * @description form组件会先于parent组件挂载,挂载完后调用register方法,将methods注册到useForm中给parent使用
16
+ * form组件会先于parent组件挂载,挂载完后调用register方法,将methods注册到useForm中给parent使用
17
17
  *
18
18
  */
19
19
  declare const useForm: () => [IRegister, IFormActionType];
@@ -7,42 +7,86 @@ export interface IRegister {
7
7
  (methods: IFormActionType): void;
8
8
  }
9
9
  export interface IFormProps<T extends TXphExtendComponentPropsMap = {}> {
10
- items: TFormItemProps<T>[] /** 表单项配置集合 */;
11
10
  /**
12
- * @description 表单布局方式(默认horizontal)
13
- * @description 排除了antd的inline,因为可以使用colProps实现inline布局
11
+ * 表单项配置集合
12
+ * @defaultValue `[]`
13
+ */
14
+ items: TFormItemProps<T>[];
15
+ /**
16
+ * 表单布局方式,排除了antd的inline,因为可以使用colProps实现inline布局
17
+ * @defaultValue `"horizontal"`
14
18
  */
15
19
  layout?: "horizontal" | "vertical";
16
- /** 表示是否显示 label 后面的冒号 (只有在属性 layout 为 horizontal 时有效) */
20
+ /**
21
+ * 表示是否显示 label 后面的冒号 (只有在属性 layout 为 horizontal 时有效)
22
+ * @defaultValue `false`
23
+ */
17
24
  colon?: boolean;
18
- /** 设置表单组件禁用,仅对 antd 组件有效 */
25
+ /**
26
+ * 设置表单组件禁用,仅对 antd 组件有效
27
+ * @defaultValue `-`
28
+ */
19
29
  disabled?: boolean;
20
- /** 表单项组件布局方式(wrapperCol的span与labelCol的span形成24栅格布局) */
30
+ /**
31
+ * 表单项组件布局方式(wrapperCol的span与labelCol的span形成24栅格布局)
32
+ * @defaultValue `-`
33
+ */
21
34
  wrapperCol?: ColProps;
22
- /** label 标签的文本换行方式 */
35
+ /**
36
+ * label 标签的文本换行方式
37
+ * @defaultValue `true`
38
+ */
23
39
  labelWrap?: boolean;
24
- /** label 标签的文本对齐方式 */
40
+ /**
41
+ * label 标签的文本对齐方式
42
+ * @defaultValue `-`
43
+ */
25
44
  labelAlign?: "left" | "right";
26
- /** 表单项label标签布局方式(wrapperCol的span与labelCol的span形成24栅格布局) */
45
+ /**
46
+ * 表单项label标签布局方式(wrapperCol的span与labelCol的span形成24栅格布局)
47
+ * @defaultValue `-`
48
+ */
27
49
  labelCol?: ColProps;
28
- /** 表单项的栅格配置 */
50
+ /**
51
+ * 表单项的栅格配置
52
+ * @defaultValue `-`
53
+ */
29
54
  colProps?: ColProps;
30
- /** 提交失败自动滚动到第一个错误字段 */
55
+ /**
56
+ * 提交失败自动滚动到第一个错误字段
57
+ * @defaultValue `-`
58
+ */
31
59
  scrollToFirstError?: boolean;
32
- /** 设置字段组件的尺寸(仅限 antd 组件) */
60
+ /**
61
+ * 设置字段组件的尺寸(仅限 antd 组件)
62
+ * @defaultValue `-`
63
+ */
33
64
  size?: "large" | "middle" | "small";
34
- /** 是否可折叠,默认超过5个折叠 */
65
+ /**
66
+ * 是否可折叠,默认超过5个折叠
67
+ * @defaultValue `-`
68
+ */
35
69
  collapsible?: boolean;
36
- /** 超过多少进行折叠,collapsible为true才生效 */
70
+ /**
71
+ * 超过多少进行折叠,collapsible为true才生效
72
+ * @defaultValue `5`
73
+ */
37
74
  collapseNum?: number;
38
- /** 渲染操作组,用于渲染表单项的操作,这是一个预留项,是否需要操作组由业务自己决定(会跟折叠同行显示) */
75
+ /**
76
+ * 渲染操作组,用于渲染表单项的操作,这是一个预留项,是否需要操作组由业务自己决定(会跟折叠同行显示)
77
+ * @defaultValue `-`
78
+ */
39
79
  renderActions?: () => React.ReactElement;
40
- /** 时间返回统一处理函数 */
80
+ /**
81
+ * 时间返回统一处理函数
82
+ * @defaultValue `(date: any, format: string) => { return date?.format?.(format \|\| "YYYY-MM-DD HH:mm:ss") ?? date }`
83
+ */
41
84
  transformDateFunc?: (date: any, format: string) => string;
42
85
  /**
43
- * @description 用于将表单内时间区域的应设成 2 个字段,见下方说明
44
- * @description 如果表单内有时间区间组件,获取到的值是一个数组,但是往往我们传递到后台需要是 2 个字段
86
+ * 用于将表单内时间区域的应设成 2 个字段
87
+ * @defaultValue `-`
45
88
  * @example
89
+ * 场景:如果表单内有时间区间组件,获取到的值是一个数组,但是往往我们传递到后台需要是 2 个字段
46
90
  * fieldMapToTime: [
47
91
  * // data为时间组件在表单内的字段,startTime,endTime为转化后的开始时间与结束时间
48
92
  * // 'YYYY-MM-DD'为时间格式,参考moment
@@ -75,13 +119,31 @@ export interface IFormProps<T extends TXphExtendComponentPropsMap = {}> {
75
119
  * }
76
120
  */
77
121
  fieldMapToTime?: [string, [string, string], (string | [string, string])?][];
78
- /** 注册事件(useForm使用,form组件会在挂载后调用) */
122
+ /**
123
+ * 注册事件(useForm使用,form组件会在挂载后调用)
124
+ * @defaultValue `-`
125
+ */
79
126
  register?: IRegister;
80
127
  }
81
128
  export interface IFormActionType {
129
+ /**
130
+ * 获取表单值
131
+ */
82
132
  getFieldsValue: (...values: any[]) => Recordable<any>;
133
+ /**
134
+ * 设置表单值
135
+ */
83
136
  setFieldsValue: (values: Recordable<any>) => void;
137
+ /**
138
+ * 重置表单值
139
+ */
84
140
  resetFields: () => Promise<void>;
141
+ /**
142
+ * 表单校验
143
+ */
85
144
  validator: (nameList?: NamePath[]) => Promise<any>;
145
+ /**
146
+ * 滚动到指定字段
147
+ */
86
148
  scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>;
87
149
  }
@@ -5,45 +5,124 @@ import { ColProps } from 'antd';
5
5
  import { IFormActionType } from './form';
6
6
  import { TXphExtendComponentPropsMap } from '../../../common';
7
7
 
8
- /**
9
- * 字符串类型对象
10
- */
11
8
  export type Recordable<T> = Record<string, T>;
12
9
  export type TFunction<T> = T | ((args: Recordable<any>) => T);
13
10
  export interface IBaseFormItemProps {
14
- name: string /** 字段名 */;
15
- label: string /** 标签名 */;
16
- valuePropName?: string /** 子节点的值的属性,如 Switch、Checkbox 的是 checked */;
17
- show?: TFunction<boolean> /** 是否显示(相当于display:none) */;
18
- ifShow?: TFunction<boolean> /** 是否显示(会新增或删除节点) */;
19
- required?: TFunction<boolean> /** 是否必填 */;
20
- disabled?: TFunction<boolean> /** 是否禁用(当和 Form 同时设置时,以 Item 为准) */;
21
- componentProps?: TFunction<Recordable<any>> /** 组件属性 */;
22
- rules?: Rule[] /** 校验规则 */;
23
- wrapperCol?: ColProps /** 表单项组件的布局方式(当和 Form 同时设置时,以 Item 为准) */;
24
- labelCol?: ColProps /** 表单项label标签布局方式(当和 Form 同时设置时,以 Item 为准) */;
25
- colProps?: ColProps /** 表单项的栅格配置(当和 Form 同时设置时,以 Item 为准) */;
26
- forceRow?: boolean /** 是否强制换一行显示该表单项(强制换行后续会跟随换行表单项) */;
27
- initialValue?: any /** 默认值 */;
11
+ /**
12
+ * 字段名
13
+ * @defaultValue `-`
14
+ */
15
+ name: string;
16
+ /**
17
+ * 标签名
18
+ * @defaultValue `-`
19
+ */
20
+ label: string;
21
+ /**
22
+ * 子节点的值的属性,如 Switch、Checkbox 的是 checked
23
+ * @defaultValue `-`
24
+ */
25
+ valuePropName?: string;
26
+ /**
27
+ * 是否显示(相当于display:none)
28
+ * @defaultValue `-`
29
+ */
30
+ show?: TFunction<boolean>;
31
+ /**
32
+ * 是否显示(会新增或删除节点)
33
+ * @defaultValue `-`
34
+ */
35
+ ifShow?: TFunction<boolean>;
36
+ /**
37
+ * 是否必填
38
+ * @defaultValue `-`
39
+ */
40
+ required?: TFunction<boolean>;
41
+ /**
42
+ * 是否禁用(当和 Form 同时设置时,以 Item 为准)
43
+ * @defaultValue `-`
44
+ */
45
+ disabled?: TFunction<boolean>;
46
+ /**
47
+ * 组件属性
48
+ * @defaultValue `-`
49
+ */
50
+ componentProps?: TFunction<Recordable<any>>;
51
+ /**
52
+ * 校验规则
53
+ * @defaultValue `-`
54
+ */
55
+ rules?: Rule[];
56
+ /**
57
+ * 表单项组件的布局方式(当和 Form 同时设置时,以 Item 为准)
58
+ * @defaultValue `-`
59
+ */
60
+ wrapperCol?: ColProps;
61
+ /**
62
+ * 表单项label标签布局方式(当和 Form 同时设置时,以 Item 为准)
63
+ * @defaultValue `-`
64
+ */
65
+ labelCol?: ColProps;
66
+ /**
67
+ * 表单项的栅格配置(当和 Form 同时设置时,以 Item 为准)
68
+ * @defaultValue `-`
69
+ */
70
+ colProps?: ColProps;
71
+ /**
72
+ * 是否强制换一行显示该表单项(强制换行后续会跟随换行表单项)
73
+ * @defaultValue `-`
74
+ */
75
+ forceRow?: boolean;
76
+ /**
77
+ * 默认值
78
+ * @defaultValue `-`
79
+ */
80
+ initialValue?: any;
28
81
  }
29
- /** 自定义渲染函数的props */
82
+ /**
83
+ * @description 自定义渲染函数的props
84
+ */
30
85
  export interface IFRenderProps {
86
+ /**
87
+ * 当前项name
88
+ */
31
89
  name: string;
90
+ /**
91
+ * 当前项状态
92
+ */
32
93
  disabled: boolean;
94
+ /**
95
+ * 组件属性
96
+ */
33
97
  componentProps: Recordable<any>;
98
+ /**
99
+ * 表单值
100
+ */
34
101
  model: any;
102
+ /**
103
+ * 表单方法实例
104
+ */
35
105
  methods: IFormActionType;
36
106
  }
37
- /** render props */
38
107
  /**
39
- * @description: 自定义渲染组件,若根节点为antd组件,就会和form组件进行双向绑定,model也是响应式的;若根节点为非antd组件,就不会和form组件进行双向绑定,需根据实际业务手动处理表单项的值
108
+ * @description render props(自定义渲染函数,若根节点为antd组件,就会和form组件进行双向绑定,model也是响应式的;若根节点为非antd组件,就不会和form组件进行双向绑定,需根据实际业务手动处理表单项的值)
40
109
  */
41
110
  export interface IRenderFormItemProps extends IBaseFormItemProps {
42
- render: (props: IFRenderProps) => React.ReactNode /** 自定义渲染组件 */;
111
+ /**
112
+ * 自定义渲染函数
113
+ * @defaultValue `-`
114
+ */
115
+ render: (props: IFRenderProps) => React.ReactNode;
43
116
  }
44
- /** component props */
117
+ /**
118
+ * @description component props
119
+ */
45
120
  export interface IComponentFormItemProps<T extends TXphExtendComponentPropsMap = {}> extends IBaseFormItemProps {
46
- component: keyof TComponentPropsMap<T> /** 映射组件 */;
121
+ /**
122
+ * 映射组件
123
+ * @defaultValue `-`
124
+ */
125
+ component: keyof TComponentPropsMap<T>;
47
126
  }
48
127
  type Without<T, K> = {
49
128
  [P in Exclude<keyof T, K>]?: never;
@@ -1,5 +1,6 @@
1
1
  import { default as XphTable } from './src/table';
2
2
  import { default as XphCrudFormDialog } from './src/components/crudFormDialog';
3
- import { TTableProps as TXphTableProps, TTableActionType as TXphTableActionType, TDataSourceItem as TXphDataSourceItem, TColumnProps as TXphColumnProps, TApiTableProps as TXphApiTableProps, TSearchFormProps as TXphSearchFormProps, IMainProps as IXphMainProps, TCrudFormDialogProps as TXphCrudFormDialogProps } from './src/types';
3
+ import { TTableProps as TXphTableProps, TTableActionType as TXphTableActionType, TDataSourceItem as TXphDataSourceItem, TColumnProps as TXphColumnProps, TApiTableProps as TXphApiTableProps, TSearchFormProps as TXphSearchFormProps, IMainProps as IXphMainProps, TCrudFormDialogProps as TXphCrudFormDialogProps, ICrudFormDialogActionType as IXphCrudFormDialogActionType } from './src/types';
4
4
 
5
- export { XphTable, TXphTableProps, TXphTableActionType, TXphDataSourceItem, TXphColumnProps, TXphApiTableProps, TXphSearchFormProps, IXphMainProps, XphCrudFormDialog, TXphCrudFormDialogProps, };
5
+ export * from './src/types';
6
+ export { XphTable, TXphTableProps, TXphTableActionType, TXphDataSourceItem, TXphColumnProps, TXphApiTableProps, TXphSearchFormProps, IXphMainProps, XphCrudFormDialog, TXphCrudFormDialogProps, IXphCrudFormDialogActionType, };
@@ -5,11 +5,11 @@ import { TXphExtendComponentPropsMap } from '../../../../common';
5
5
  declare const CrudFormDialog: (props: TCrudFormDialogProps, ref: ForwardedRef<ICrudFormDialogActionType>) => import("react/jsx-runtime").JSX.Element;
6
6
  declare const ForwardedCrudFormDialog: <T extends TXphExtendComponentPropsMap = {}>(props: Omit<import('../../../../common').IXphDialogProps, "onOk" | "onCancel"> & {
7
7
  formProps: import('../../../../form').IXphFormProps<T>;
8
- onOk?: (({ values, data }: {
8
+ onOk?: ((event: {
9
9
  values: any;
10
10
  data: any;
11
11
  }) => Promise<any>) | undefined;
12
- onCancel?: (({ values, data }: {
12
+ onCancel?: ((event: {
13
13
  values: any;
14
14
  data: any;
15
15
  }) => Promise<any>) | undefined;