zy-react-library 1.3.18 → 1.3.19

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.
@@ -21,7 +21,7 @@ export interface FormBuilderProps<Values = any> extends Omit<FormProps, "form" |
21
21
  /** 栅格间距,默认 24 */
22
22
  gutter?: Gutter | [Gutter, Gutter];
23
23
  /** 占据栅格列数,默认 12 */
24
- span?: number | string;
24
+ span?: number;
25
25
  /** 自动生成必填规则,默认 true */
26
26
  useAutoGenerateRequired?: boolean;
27
27
  /** 是否显示操作按钮区域,默认 true */
@@ -104,7 +104,7 @@ export interface FormOptionBase<
104
104
  /** 表单项标签 */
105
105
  label?: ReactNode;
106
106
  /** 占据栅格列数,默认 12 */
107
- span?: WhenTrue<IsOnlyForLabel, number | string>;
107
+ span?: WhenTrue<IsOnlyForLabel, number>;
108
108
  /** 是否必填,默认 true,支持函数动态计算 */
109
109
  required?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, boolean | ((formValues: AllValues) => boolean)>;
110
110
  /** 验证规则 */
@@ -209,33 +209,46 @@ export type FormOptionCustomRender<
209
209
  formListUniqueProps?: never;
210
210
  };
211
211
 
212
+ /**
213
+ * 根据 render 类型映射生成表单项联合类型
214
+ */
215
+ export type FormOptionByRenderUnion<
216
+ Values = any,
217
+ AllValues = Values,
218
+ IsOnlyForLabel extends boolean = false,
219
+ IsCustomizeRender extends boolean = false,
220
+ Name = NamePath<Values>,
221
+ Dependencies = NamePath<Values>,
222
+ > = { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, IsOnlyForLabel, IsCustomizeRender, Name, Dependencies> }[keyof FORM_ITEM_RENDER_TYPE_MAP];
223
+
224
+ /**
225
+ * 表单配置项联合类型组合
226
+ */
227
+ export type FormOptionGroup<
228
+ Values = any,
229
+ AllValues = Values,
230
+ Name = NamePath<Values>,
231
+ Dependencies = NamePath<Values>,
232
+ >
233
+ = | FormOptionDefault<Values, AllValues, false, false, Name, Dependencies>
234
+ | FormOptionDefault<Values, AllValues, false, true, Name, Dependencies>
235
+ | FormOptionDefault<Values, AllValues, true, false, Name, Dependencies>
236
+ | FormOptionByRenderUnion<Values, AllValues, false, false, Name, Dependencies>
237
+ | FormOptionByRenderUnion<Values, AllValues, false, true, Name, Dependencies>
238
+ | FormOptionByRenderUnion<Values, AllValues, true, false, Name, Dependencies>
239
+ | FormOptionCustomRender<Values, AllValues, false, false, Name, Dependencies>
240
+ | FormOptionCustomRender<Values, AllValues, false, true, Name, Dependencies>
241
+ | FormOptionCustomRender<Values, AllValues, true, false, Name, Dependencies>;
242
+
212
243
  /**
213
244
  * 普通表单配置项
214
245
  */
215
- export type FormOption<Values = any, AllValues = Values>
216
- = | FormOptionDefault<Values, AllValues, false, false>
217
- | FormOptionDefault<Values, AllValues, false, true>
218
- | FormOptionDefault<Values, AllValues, true, false>
219
- | { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, false, false> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
220
- | { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, false, true> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
221
- | { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, true, false> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
222
- | FormOptionCustomRender<Values, AllValues, false, false>
223
- | FormOptionCustomRender<Values, AllValues, false, true>
224
- | FormOptionCustomRender<Values, AllValues, true, false>;
246
+ export type FormOption<Values = any, AllValues = Values> = FormOptionGroup<Values, AllValues>;
225
247
 
226
248
  /**
227
249
  * Form.List 子项表单配置项
228
250
  */
229
- export type FormListOption<Values = any, AllValues = Values>
230
- = | FormOptionDefault<Values, AllValues, false, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
231
- | FormOptionDefault<Values, AllValues, false, true, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
232
- | FormOptionDefault<Values, AllValues, true, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
233
- | { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, false, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
234
- | { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, false, true, FormListOptionName<Values>, FormListOptionDependencies<AllValues>> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
235
- | { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, true, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
236
- | FormOptionCustomRender<Values, AllValues, false, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
237
- | FormOptionCustomRender<Values, AllValues, false, true, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
238
- | FormOptionCustomRender<Values, AllValues, true, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>;
251
+ export type FormListOption<Values = any, AllValues = Values> = FormOptionGroup<Values, AllValues, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>;
239
252
 
240
253
  /**
241
254
  * FormItemsRenderer 组件属性
@@ -250,7 +263,7 @@ export interface FormItemsRendererProps<Values = any> {
250
263
  /** 自动生成必填规则,默认 true */
251
264
  useAutoGenerateRequired?: boolean;
252
265
  /** 初始值,用于在表单未初始化时提供默认值 */
253
- initialValues?: Values;
266
+ initialValues?: DeepPartial<Values>;
254
267
  /** 栅格间距,继承自 FormBuilder */
255
268
  gutter?: Gutter | [Gutter, Gutter];
256
269
  /** label 栅格配置,继承自 FormBuilder */
@@ -1,5 +1,5 @@
1
1
  import type { CheckboxProps } from "antd/es/checkbox";
2
- import type { DatePickerProps } from "antd/es/date-picker";
2
+ import type { DatePickerProps, MonthPickerProps, RangePickerProps, WeekPickerProps } from "antd/es/date-picker";
3
3
  import type { DividerProps } from "antd/es/divider";
4
4
  import type { FormListProps } from "antd/es/form";
5
5
  import type { InputProps, TextAreaProps } from "antd/es/input";
@@ -57,12 +57,12 @@ export interface FORM_ITEM_RENDER_TYPE_MAP {
57
57
  radio: RadioProps;
58
58
  checkbox: CheckboxProps;
59
59
  date: DatePickerProps;
60
- dateMonth: DatePickerProps;
60
+ dateMonth: MonthPickerProps;
61
61
  dateYear: DatePickerProps;
62
- dateWeek: DatePickerProps;
63
- dateRange: DatePickerProps;
62
+ dateWeek: WeekPickerProps;
63
+ dateRange: RangePickerProps;
64
64
  datetime: DatePickerProps;
65
- datetimeRange: DatePickerProps;
65
+ datetimeRange: RangePickerProps;
66
66
  divider: DividerProps;
67
67
  formList: FormListProps;
68
68
  }
@@ -1 +1 @@
1
- const e={INPUT:"input",TEXTAREA:"textarea",INPUT_NUMBER:"inputNumber",NUMBER:"number",INTEGER:"number",SELECT:"select",RADIO:"radio",CHECKBOX:"checkbox",DATE:"date",DATE_MONTH:"dateMonth",DATE_YEAR:"dateYear",DATE_WEEK:"dateWeek",DATE_RANGE:"dateRange",DATETIME:"datetime",DATETIME_RANGE:"datetimeRange",DIVIDER:"divider",FORM_LIST:"formList"};export{e as FORM_ITEM_RENDER_ENUM};
1
+ const e={INPUT:"input",TEXTAREA:"textarea",INPUT_NUMBER:"inputNumber",NUMBER:"number",INTEGER:"integer",SELECT:"select",RADIO:"radio",CHECKBOX:"checkbox",DATE:"date",DATE_MONTH:"dateMonth",DATE_YEAR:"dateYear",DATE_WEEK:"dateWeek",DATE_RANGE:"dateRange",DATETIME:"datetime",DATETIME_RANGE:"datetimeRange",DIVIDER:"divider",FORM_LIST:"formList"};export{e as FORM_ITEM_RENDER_ENUM};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "zy-react-library",
3
3
  "private": false,
4
- "version": "1.3.18",
4
+ "version": "1.3.19",
5
5
  "type": "module",
6
6
  "description": "",
7
7
  "author": "LiuJiaNan",