xph-crud 0.3.2 → 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.
@@ -2,86 +2,98 @@ import { ButtonProps } from 'antd';
2
2
 
3
3
  export interface IDialogProps {
4
4
  /**
5
- * @default 700
6
- * @description 弹窗的宽度
5
+ * 弹窗的宽度
6
+ * @defaultValue `700`
7
7
  */
8
8
  width?: number;
9
9
  /**
10
- * @default -
11
- * @description 弹窗的高度
10
+ * 弹窗的高度
11
+ * @defaultValue `-`
12
12
  */
13
13
  height?: number;
14
14
  /**
15
- * @default false
16
- * @description 是否显示遮罩
15
+ * 是否显示遮罩
16
+ * @defaultValue `false`
17
17
  */
18
18
  mask?: boolean;
19
19
  /**
20
- * @default -
21
- * @description 弹窗的标题
20
+ * 弹窗的标题
21
+ * @defaultValue `-`
22
22
  */
23
23
  title?: string;
24
24
  /**
25
- * @default -
26
- * @description 确定按钮属性
25
+ * 确定按钮属性
26
+ * @defaultValue `-`
27
27
  */
28
28
  okProps?: Omit<ButtonProps, "children" | "onClick">;
29
29
  /**
30
- * @default -
31
- * @description 取消按钮属性
30
+ * 取消按钮属性
31
+ * @defaultValue `-`
32
32
  */
33
33
  cancelProps?: Omit<ButtonProps, "children" | "onClick">;
34
34
  /**
35
- * @default "确定"
36
- * @description 确定按钮文字
35
+ * 确定按钮文字
36
+ * @defaultValue `"确定"`
37
37
  */
38
38
  okText?: string;
39
39
  /**
40
- * @default "取消"
41
- * @description 取消按钮文字
40
+ * 取消按钮文字
41
+ * @defaultValue `"取消"`
42
42
  */
43
43
  cancelText?: string;
44
44
  /**
45
- * @default -
46
- * @description 点击确定按钮触发该事件
45
+ * 点击确定按钮触发该事件
46
+ * @defaultValue `-`
47
47
  */
48
48
  onOk?: (args: any) => Promise<void>;
49
49
  /**
50
- * @default -
51
- * @description 点击取消按钮触发该事件
50
+ * 点击取消按钮触发该事件
51
+ * @defaultValue `-`
52
52
  */
53
53
  onCancel?: (args: any) => Promise<void>;
54
54
  /**
55
- * @default -
56
- * @description 底部按钮自定义渲染函数
55
+ * 底部按钮自定义渲染函数
56
+ * @defaultValue `-`
57
57
  */
58
58
  renderFooter?: ({ loading }: {
59
59
  loading: boolean;
60
60
  }) => React.ReactElement;
61
61
  /**
62
- * @default -
63
- * @description 顶部标题自定义渲染函数
62
+ * 顶部标题自定义渲染函数
63
+ * @defaultValue `-`
64
64
  */
65
65
  renderTitle?: () => React.ReactElement;
66
66
  /**
67
- * @default -
68
- * @description 打开的时候会触发该事件
67
+ * 打开的时候会触发该事件
68
+ * @defaultValue `-`
69
69
  */
70
70
  onOpen?: () => void;
71
71
  /**
72
- * @default -
73
- * @description 关闭的时候会触发该事件
72
+ * 关闭的时候会触发该事件
73
+ * @defaultValue `-`
74
74
  */
75
75
  onClose?: () => void;
76
76
  /**
77
- * @default () => document.body
78
- * @description 挂载弹窗的容器
77
+ * 挂载弹窗的容器
78
+ * @defaultValue `() => document.body`
79
79
  */
80
80
  getPopperContainer?: () => HTMLElement | null;
81
81
  }
82
82
  export interface IDialogActionType {
83
+ /**
84
+ * 打开
85
+ */
83
86
  open: () => Promise<void>;
87
+ /**
88
+ * 关闭
89
+ */
84
90
  close: () => void;
91
+ /**
92
+ * 设置loading
93
+ */
85
94
  setLoading: (loading: boolean) => void;
95
+ /**
96
+ * 获取弹窗状态
97
+ */
86
98
  getVisible: () => boolean;
87
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,3 +1,6 @@
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 通过属性为包含.的字符串的对象从值对象中获取值
@@ -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];
@@ -8,87 +8,85 @@ export interface IRegister {
8
8
  }
9
9
  export interface IFormProps<T extends TXphExtendComponentPropsMap = {}> {
10
10
  /**
11
- * @default []
12
- * @description 表单项配置集合
11
+ * 表单项配置集合
12
+ * @defaultValue `[]`
13
13
  */
14
14
  items: TFormItemProps<T>[];
15
15
  /**
16
- * @default "horizontal"
17
- * @description 表单布局方式,排除了antd的inline,因为可以使用colProps实现inline布局
16
+ * 表单布局方式,排除了antd的inline,因为可以使用colProps实现inline布局
17
+ * @defaultValue `"horizontal"`
18
18
  */
19
19
  layout?: "horizontal" | "vertical";
20
20
  /**
21
- * @default false
22
- * @description 表示是否显示 label 后面的冒号 (只有在属性 layout 为 horizontal 时有效)
21
+ * 表示是否显示 label 后面的冒号 (只有在属性 layout 为 horizontal 时有效)
22
+ * @defaultValue `false`
23
23
  */
24
24
  colon?: boolean;
25
25
  /**
26
- * @default -
27
- * @description 设置表单组件禁用,仅对 antd 组件有效
26
+ * 设置表单组件禁用,仅对 antd 组件有效
27
+ * @defaultValue `-`
28
28
  */
29
29
  disabled?: boolean;
30
30
  /**
31
- * @default -
32
- * @description 表单项组件布局方式(wrapperCol的span与labelCol的span形成24栅格布局)
31
+ * 表单项组件布局方式(wrapperCol的span与labelCol的span形成24栅格布局)
32
+ * @defaultValue `-`
33
33
  */
34
34
  wrapperCol?: ColProps;
35
35
  /**
36
- * @default true
37
- * @description label 标签的文本换行方式
36
+ * label 标签的文本换行方式
37
+ * @defaultValue `true`
38
38
  */
39
39
  labelWrap?: boolean;
40
40
  /**
41
- * @default -
42
- * @description label 标签的文本对齐方式
41
+ * label 标签的文本对齐方式
42
+ * @defaultValue `-`
43
43
  */
44
44
  labelAlign?: "left" | "right";
45
45
  /**
46
- * @default -
47
- * @description 表单项label标签布局方式(wrapperCol的span与labelCol的span形成24栅格布局)
46
+ * 表单项label标签布局方式(wrapperCol的span与labelCol的span形成24栅格布局)
47
+ * @defaultValue `-`
48
48
  */
49
49
  labelCol?: ColProps;
50
50
  /**
51
- * @default -
52
- * @description 表单项的栅格配置
51
+ * 表单项的栅格配置
52
+ * @defaultValue `-`
53
53
  */
54
54
  colProps?: ColProps;
55
55
  /**
56
- * @default -
57
- * @description 提交失败自动滚动到第一个错误字段
56
+ * 提交失败自动滚动到第一个错误字段
57
+ * @defaultValue `-`
58
58
  */
59
59
  scrollToFirstError?: boolean;
60
60
  /**
61
- * @default -
62
- * @description 设置字段组件的尺寸(仅限 antd 组件)
61
+ * 设置字段组件的尺寸(仅限 antd 组件)
62
+ * @defaultValue `-`
63
63
  */
64
64
  size?: "large" | "middle" | "small";
65
65
  /**
66
- * @default -
67
- * @description 是否可折叠,默认超过5个折叠
66
+ * 是否可折叠,默认超过5个折叠
67
+ * @defaultValue `-`
68
68
  */
69
69
  collapsible?: boolean;
70
70
  /**
71
- * @default 5
72
- * @description 超过多少进行折叠,collapsible为true才生效
71
+ * 超过多少进行折叠,collapsible为true才生效
72
+ * @defaultValue `5`
73
73
  */
74
74
  collapseNum?: number;
75
75
  /**
76
- * @default -
77
- * @description 渲染操作组,用于渲染表单项的操作,这是一个预留项,是否需要操作组由业务自己决定(会跟折叠同行显示)
76
+ * 渲染操作组,用于渲染表单项的操作,这是一个预留项,是否需要操作组由业务自己决定(会跟折叠同行显示)
77
+ * @defaultValue `-`
78
78
  */
79
79
  renderActions?: () => React.ReactElement;
80
80
  /**
81
- * @default (date: any, format: string) => { return date?.format?.(format || "YYYY-MM-DD HH:mm:ss") ?? date; }
82
- * @description 时间返回统一处理函数
81
+ * 时间返回统一处理函数
82
+ * @defaultValue `(date: any, format: string) => { return date?.format?.(format \|\| "YYYY-MM-DD HH:mm:ss") ?? date }`
83
83
  */
84
84
  transformDateFunc?: (date: any, format: string) => string;
85
85
  /**
86
- * @default -
87
- * @description 用于将表单内时间区域的应设成 2 个字段,见下方案例
86
+ * 用于将表单内时间区域的应设成 2 个字段
87
+ * @defaultValue `-`
88
88
  * @example
89
- *
90
- * // 场景:如果表单内有时间区间组件,获取到的值是一个数组,但是往往我们传递到后台需要是 2 个字段
91
- *
89
+ * 场景:如果表单内有时间区间组件,获取到的值是一个数组,但是往往我们传递到后台需要是 2 个字段
92
90
  * fieldMapToTime: [
93
91
  * // data为时间组件在表单内的字段,startTime,endTime为转化后的开始时间与结束时间
94
92
  * // 'YYYY-MM-DD'为时间格式,参考moment
@@ -122,15 +120,30 @@ export interface IFormProps<T extends TXphExtendComponentPropsMap = {}> {
122
120
  */
123
121
  fieldMapToTime?: [string, [string, string], (string | [string, string])?][];
124
122
  /**
125
- * @default -
126
- * @description 注册事件(useForm使用,form组件会在挂载后调用)
123
+ * 注册事件(useForm使用,form组件会在挂载后调用)
124
+ * @defaultValue `-`
127
125
  */
128
126
  register?: IRegister;
129
127
  }
130
128
  export interface IFormActionType {
129
+ /**
130
+ * 获取表单值
131
+ */
131
132
  getFieldsValue: (...values: any[]) => Recordable<any>;
133
+ /**
134
+ * 设置表单值
135
+ */
132
136
  setFieldsValue: (values: Recordable<any>) => void;
137
+ /**
138
+ * 重置表单值
139
+ */
133
140
  resetFields: () => Promise<void>;
141
+ /**
142
+ * 表单校验
143
+ */
134
144
  validator: (nameList?: NamePath[]) => Promise<any>;
145
+ /**
146
+ * 滚动到指定字段
147
+ */
135
148
  scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>;
136
149
  }
@@ -9,73 +9,73 @@ export type Recordable<T> = Record<string, T>;
9
9
  export type TFunction<T> = T | ((args: Recordable<any>) => T);
10
10
  export interface IBaseFormItemProps {
11
11
  /**
12
- * @default -
13
- * @description 字段名
12
+ * 字段名
13
+ * @defaultValue `-`
14
14
  */
15
15
  name: string;
16
16
  /**
17
- * @default -
18
- * @description 标签名
17
+ * 标签名
18
+ * @defaultValue `-`
19
19
  */
20
20
  label: string;
21
21
  /**
22
- * @default -
23
- * @description 子节点的值的属性,如 Switch、Checkbox 的是 checked
22
+ * 子节点的值的属性,如 Switch、Checkbox 的是 checked
23
+ * @defaultValue `-`
24
24
  */
25
25
  valuePropName?: string;
26
26
  /**
27
- * @default -
28
- * @description 是否显示(相当于display:none)
27
+ * 是否显示(相当于display:none)
28
+ * @defaultValue `-`
29
29
  */
30
30
  show?: TFunction<boolean>;
31
31
  /**
32
- * @default -
33
- * @description 是否显示(会新增或删除节点)
32
+ * 是否显示(会新增或删除节点)
33
+ * @defaultValue `-`
34
34
  */
35
35
  ifShow?: TFunction<boolean>;
36
36
  /**
37
- * @default -
38
- * @description 是否必填
37
+ * 是否必填
38
+ * @defaultValue `-`
39
39
  */
40
40
  required?: TFunction<boolean>;
41
41
  /**
42
- * @default -
43
- * @description 是否禁用(当和 Form 同时设置时,以 Item 为准)
42
+ * 是否禁用(当和 Form 同时设置时,以 Item 为准)
43
+ * @defaultValue `-`
44
44
  */
45
45
  disabled?: TFunction<boolean>;
46
46
  /**
47
- * @default -
48
- * @description 组件属性
47
+ * 组件属性
48
+ * @defaultValue `-`
49
49
  */
50
50
  componentProps?: TFunction<Recordable<any>>;
51
51
  /**
52
- * @default -
53
- * @description 校验规则
52
+ * 校验规则
53
+ * @defaultValue `-`
54
54
  */
55
55
  rules?: Rule[];
56
56
  /**
57
- * @default -
58
- * @description 表单项组件的布局方式(当和 Form 同时设置时,以 Item 为准)
57
+ * 表单项组件的布局方式(当和 Form 同时设置时,以 Item 为准)
58
+ * @defaultValue `-`
59
59
  */
60
60
  wrapperCol?: ColProps;
61
61
  /**
62
- * @default -
63
- * @description 表单项label标签布局方式(当和 Form 同时设置时,以 Item 为准)
62
+ * 表单项label标签布局方式(当和 Form 同时设置时,以 Item 为准)
63
+ * @defaultValue `-`
64
64
  */
65
65
  labelCol?: ColProps;
66
66
  /**
67
- * @default -
68
- * @description 表单项的栅格配置(当和 Form 同时设置时,以 Item 为准)
67
+ * 表单项的栅格配置(当和 Form 同时设置时,以 Item 为准)
68
+ * @defaultValue `-`
69
69
  */
70
70
  colProps?: ColProps;
71
71
  /**
72
- * @default -
73
- * @description 是否强制换一行显示该表单项(强制换行后续会跟随换行表单项)
72
+ * 是否强制换一行显示该表单项(强制换行后续会跟随换行表单项)
73
+ * @defaultValue `-`
74
74
  */
75
75
  forceRow?: boolean;
76
76
  /**
77
- * @default -
78
- * @description 默认值
77
+ * 默认值
78
+ * @defaultValue `-`
79
79
  */
80
80
  initialValue?: any;
81
81
  }
@@ -84,23 +84,23 @@ export interface IBaseFormItemProps {
84
84
  */
85
85
  export interface IFRenderProps {
86
86
  /**
87
- * @description 当前项name
87
+ * 当前项name
88
88
  */
89
89
  name: string;
90
90
  /**
91
- * @description 当前项状态
91
+ * 当前项状态
92
92
  */
93
93
  disabled: boolean;
94
94
  /**
95
- * @description 组件属性
95
+ * 组件属性
96
96
  */
97
97
  componentProps: Recordable<any>;
98
98
  /**
99
- * @description 表单值
99
+ * 表单值
100
100
  */
101
101
  model: any;
102
102
  /**
103
- * @description 表单方法实例
103
+ * 表单方法实例
104
104
  */
105
105
  methods: IFormActionType;
106
106
  }
@@ -109,7 +109,8 @@ export interface IFRenderProps {
109
109
  */
110
110
  export interface IRenderFormItemProps extends IBaseFormItemProps {
111
111
  /**
112
- * @description 自定义渲染函数
112
+ * 自定义渲染函数
113
+ * @defaultValue `-`
113
114
  */
114
115
  render: (props: IFRenderProps) => React.ReactNode;
115
116
  }
@@ -118,7 +119,8 @@ export interface IRenderFormItemProps extends IBaseFormItemProps {
118
119
  */
119
120
  export interface IComponentFormItemProps<T extends TXphExtendComponentPropsMap = {}> extends IBaseFormItemProps {
120
121
  /**
121
- * @description 映射组件
122
+ * 映射组件
123
+ * @defaultValue `-`
122
124
  */
123
125
  component: keyof TComponentPropsMap<T>;
124
126
  }
@@ -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, };
@@ -7,18 +7,18 @@ import { IComponentColumnProps, TDataSourceItem } from '../../../../../types';
7
7
  export type TCellComponentPropsMap<CellFuncExtendPropsMap extends TXphExtendComponentPropsMap = {}, ActionsExtendPropsMap extends TXphExtendComponentPropsMap = {}> = {
8
8
  link: {
9
9
  /**
10
- * @description 超链接,点击超链接跳转
10
+ * 超链接,点击超链接跳转
11
11
  */
12
12
  url?: string;
13
13
  /**
14
- * @description 点击事件(优先级最高)
14
+ * 点击事件(优先级最高)
15
15
  */
16
16
  onClick?: () => void;
17
17
  };
18
18
  actions: IXphActionsProps<ActionsExtendPropsMap>;
19
19
  tag: {
20
20
  /**
21
- * @description 标签的枚举
21
+ * 标签的枚举
22
22
  */
23
23
  enums: Array<{
24
24
  label: string;
@@ -69,8 +69,17 @@ export interface ICurCellFuncProps<J extends TXphExtendComponentPropsMap = {}, K
69
69
  * 注意:因为多个自定义组件可能都有mainClick,所以也需要保证其他组件的正常调用(即:传递给子组件Comp的时候,需要把父组件传递过来的mainClick给手动执行一下)
70
70
  */
71
71
  export interface IMainProps {
72
+ /**
73
+ * 点击事件
74
+ */
72
75
  mainClick?: () => void;
76
+ /**
77
+ * 内容样式
78
+ */
73
79
  mainStyle?: React.CSSProperties;
80
+ /**
81
+ * 内容
82
+ */
74
83
  mainHandleText?: () => any;
75
84
  }
76
85
  export {};