@aplus-frontend/ui 0.3.1 → 0.3.2
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/es/src/ap-form/ap-form.vue.d.ts +5 -6
- package/es/src/ap-form/ap-form.vue2.mjs +3 -3
- package/es/src/ap-form/drawer-form/index.vue.d.ts +4 -4
- package/es/src/ap-form/interface.d.ts +12 -3
- package/es/src/ap-form/modal-form/index.vue.d.ts +4 -4
- package/es/src/ap-form/search-form/index.vue.d.ts +5 -5
- package/lib/src/ap-form/ap-form.vue.d.ts +5 -6
- package/lib/src/ap-form/ap-form.vue2.js +1 -1
- package/lib/src/ap-form/drawer-form/index.vue.d.ts +4 -4
- package/lib/src/ap-form/interface.d.ts +12 -3
- package/lib/src/ap-form/modal-form/index.vue.d.ts +4 -4
- package/lib/src/ap-form/search-form/index.vue.d.ts +5 -5
- package/package.json +3 -3
|
@@ -288,14 +288,13 @@ declare function __VLS_template(): {
|
|
|
288
288
|
};
|
|
289
289
|
xxl: {
|
|
290
290
|
type: PropType<string | number | ColSize>;
|
|
291
|
-
default: string | number |
|
|
291
|
+
default: string | number | **
|
|
292
|
+
* 订阅事件
|
|
293
|
+
*/).ColSize;
|
|
292
294
|
};
|
|
293
295
|
prefixCls: StringConstructor;
|
|
294
296
|
flex: (StringConstructor | NumberConstructor)[];
|
|
295
|
-
}>> &
|
|
296
|
-
* 注册表单项
|
|
297
|
-
* @param field
|
|
298
|
-
*/).HTMLAttributes;
|
|
297
|
+
}>> & HTMLAttributes;
|
|
299
298
|
labelAlign: FormLabelAlign;
|
|
300
299
|
labelWrap: boolean;
|
|
301
300
|
wrapperCol: Partial< ExtractPropTypes<{
|
|
@@ -683,7 +682,7 @@ declare const __VLS_component: DefineComponent<ApFormProps, {
|
|
|
683
682
|
}> | undefined;
|
|
684
683
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
685
684
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
686
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
685
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
687
686
|
registerWatch: typeof registerWatch;
|
|
688
687
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
689
688
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -49,7 +49,7 @@ const ye = /* @__PURE__ */ $({
|
|
|
49
49
|
} else
|
|
50
50
|
n[e] = t;
|
|
51
51
|
let o = f(e) ? e[0] : e;
|
|
52
|
-
l && ((i = s.onValuesChange) == null || i.call(s, { [o]: n[o] }, n)), g();
|
|
52
|
+
l && ((i = s.onValuesChange) == null || i.call(s, { [o]: n[o] }, n, e)), g();
|
|
53
53
|
}
|
|
54
54
|
const a = M(), v = se(ne()), B = M(
|
|
55
55
|
s.syncToUrl ? _(s.syncToUrl, v, "get") : {}
|
|
@@ -112,8 +112,8 @@ const ye = /* @__PURE__ */ $({
|
|
|
112
112
|
(l = a.value) == null || l.scrollToField(e, t);
|
|
113
113
|
}, L = (e) => {
|
|
114
114
|
Object.assign(n, e), g();
|
|
115
|
-
}, P = (e, t) => {
|
|
116
|
-
y(e, t), g();
|
|
115
|
+
}, P = (e, t, l = !0) => {
|
|
116
|
+
y(e, t, l), g();
|
|
117
117
|
};
|
|
118
118
|
function T(e, t) {
|
|
119
119
|
return t || e(O(n)), F.push(e), () => {
|
|
@@ -110,7 +110,7 @@ declare function __VLS_template(): {
|
|
|
110
110
|
readonly hideRequiredMark?: boolean | undefined;
|
|
111
111
|
readonly validateOnRuleChange?: boolean | undefined;
|
|
112
112
|
readonly scrollToFirstError?: boolean | Options<any> | undefined;
|
|
113
|
-
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable) => void)) | undefined;
|
|
113
|
+
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable, fieldName: NamePath) => void)) | undefined;
|
|
114
114
|
readonly onFieldsChange?: ((changedFields: FieldData[], allFields: FieldData[]) => void) | undefined;
|
|
115
115
|
readonly onFinish?: ((values: any) => void) | undefined;
|
|
116
116
|
readonly onFinishFailed?: ((errorInfo: ValidateErrorEntity<any>) => void) | undefined;
|
|
@@ -147,7 +147,7 @@ declare function __VLS_template(): {
|
|
|
147
147
|
}> | undefined;
|
|
148
148
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
149
149
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
150
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
150
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
151
151
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
152
152
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
153
153
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -191,7 +191,7 @@ declare function __VLS_template(): {
|
|
|
191
191
|
hideRequiredMark: boolean;
|
|
192
192
|
validateOnRuleChange: boolean;
|
|
193
193
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
194
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "
|
|
194
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "setFieldsValue" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "getInternalInstance" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl")> & ShallowUnwrapRef<{
|
|
195
195
|
resetFields: () => Promise<void>;
|
|
196
196
|
clearValidate: (name?: NamePath | NamePath[]) => void;
|
|
197
197
|
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
|
|
@@ -205,7 +205,7 @@ declare function __VLS_template(): {
|
|
|
205
205
|
}> | undefined;
|
|
206
206
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
207
207
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
208
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
208
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
209
209
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
210
210
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
211
211
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -43,9 +43,10 @@ export type ApFormProps = Omit<FormProps, 'model'> & {
|
|
|
43
43
|
* 字段值更新时触发
|
|
44
44
|
* @param changedValues 更改的字段值
|
|
45
45
|
* @param allValues 更改后的字段值
|
|
46
|
+
* @param fieldName 触发change的表单项
|
|
46
47
|
* @returns
|
|
47
48
|
*/
|
|
48
|
-
onValuesChange?: (changedValues: Recordable, allValues: Recordable) => void;
|
|
49
|
+
onValuesChange?: (changedValues: Recordable, allValues: Recordable, fieldName: NamePath) => void;
|
|
49
50
|
/**
|
|
50
51
|
* 同步表单数据到url中
|
|
51
52
|
*/
|
|
@@ -58,7 +59,7 @@ export type ApFormProps = Omit<FormProps, 'model'> & {
|
|
|
58
59
|
export type WatchFunc = (values?: Recordable) => void;
|
|
59
60
|
export type ApFormExpose<ModelType = any> = {
|
|
60
61
|
setFieldsValue: (fields: Partial<ModelType>) => void;
|
|
61
|
-
setFieldValue: (name: NamePath, value: any) => void;
|
|
62
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
62
63
|
resetFields: () => Promise<void>;
|
|
63
64
|
clearValidate: (name?: NamePath) => void;
|
|
64
65
|
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
|
|
@@ -107,7 +108,15 @@ export type ApFormInternalInstance = {
|
|
|
107
108
|
* @returns
|
|
108
109
|
*/
|
|
109
110
|
registerField: (field: RegistedFieldType) => void;
|
|
110
|
-
|
|
111
|
+
/**
|
|
112
|
+
* 设置表单值
|
|
113
|
+
* @param name
|
|
114
|
+
* @param value
|
|
115
|
+
* @param triggerChange
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
119
|
+
};
|
|
111
120
|
export type ApFormItemExpose = FormItemExpose & {
|
|
112
121
|
/**
|
|
113
122
|
* 是否需要格式化(默认为false)
|
|
@@ -111,7 +111,7 @@ declare function __VLS_template(): {
|
|
|
111
111
|
readonly hideRequiredMark?: boolean | undefined;
|
|
112
112
|
readonly validateOnRuleChange?: boolean | undefined;
|
|
113
113
|
readonly scrollToFirstError?: boolean | Options<any> | undefined;
|
|
114
|
-
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable) => void)) | undefined;
|
|
114
|
+
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable, fieldName: NamePath) => void)) | undefined;
|
|
115
115
|
readonly onFieldsChange?: ((changedFields: FieldData[], allFields: FieldData[]) => void) | undefined;
|
|
116
116
|
readonly onFinish?: ((values: any) => void) | undefined;
|
|
117
117
|
readonly onFinishFailed?: ((errorInfo: ValidateErrorEntity<any>) => void) | undefined;
|
|
@@ -148,7 +148,7 @@ declare function __VLS_template(): {
|
|
|
148
148
|
}> | undefined;
|
|
149
149
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
150
150
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
151
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
151
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
152
152
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
153
153
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
154
154
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -192,7 +192,7 @@ declare function __VLS_template(): {
|
|
|
192
192
|
hideRequiredMark: boolean;
|
|
193
193
|
validateOnRuleChange: boolean;
|
|
194
194
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
195
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "
|
|
195
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "setFieldsValue" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "getInternalInstance" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl")> & ShallowUnwrapRef<{
|
|
196
196
|
resetFields: () => Promise<void>;
|
|
197
197
|
clearValidate: (name?: NamePath | NamePath[]) => void;
|
|
198
198
|
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
|
|
@@ -206,7 +206,7 @@ declare function __VLS_template(): {
|
|
|
206
206
|
}> | undefined;
|
|
207
207
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
208
208
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
209
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
209
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
210
210
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
211
211
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
212
212
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApFormExpose, ApFormSearchFormProps } from '../interface';
|
|
2
2
|
import { ComponentInternalInstance, ExtractPropTypes, PropType, HTMLAttributes, VNodeProps, AllowedComponentProps, ComponentCustomProps, Slot, ComponentPublicInstance, ComponentOptionsBase, ComponentOptionsMixin, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DebuggerEvent, nextTick, WatchOptions, WatchStopHandle, ShallowUnwrapRef, ComponentCustomProperties, DefineComponent, ComputedRef, PublicProps } from 'vue';
|
|
3
3
|
import { ButtonSize } from '@aplus-frontend/antdv/es/button';
|
|
4
|
-
import { ValidateMessages, FormLabelAlign, FieldData, ValidateErrorEntity,
|
|
4
|
+
import { ValidateMessages, FormLabelAlign, NamePath, FieldData, ValidateErrorEntity, ValidateOptions, InternalNamePath } from '@aplus-frontend/antdv/es/form/interface';
|
|
5
5
|
import { RequiredMark } from '@aplus-frontend/antdv/es/form/Form';
|
|
6
6
|
import { ColSize } from '@aplus-frontend/antdv/es/grid';
|
|
7
7
|
import { RuleObject } from '@aplus-frontend/antdv/es/form';
|
|
@@ -107,7 +107,7 @@ declare function __VLS_template(): {
|
|
|
107
107
|
readonly hideRequiredMark?: boolean | undefined;
|
|
108
108
|
readonly validateOnRuleChange?: boolean | undefined;
|
|
109
109
|
readonly scrollToFirstError?: boolean | Options<any> | undefined;
|
|
110
|
-
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable) => void)) | undefined;
|
|
110
|
+
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable, fieldName: NamePath) => void)) | undefined;
|
|
111
111
|
readonly onFieldsChange?: ((changedFields: FieldData[], allFields: FieldData[]) => void) | undefined;
|
|
112
112
|
readonly onFinish?: ((values: any) => void) | undefined;
|
|
113
113
|
readonly onFinishFailed?: ((errorInfo: ValidateErrorEntity<any>) => void) | undefined;
|
|
@@ -144,7 +144,7 @@ declare function __VLS_template(): {
|
|
|
144
144
|
}> | undefined;
|
|
145
145
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
146
146
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
147
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
147
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
148
148
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
149
149
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
150
150
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -188,7 +188,7 @@ declare function __VLS_template(): {
|
|
|
188
188
|
hideRequiredMark: boolean;
|
|
189
189
|
validateOnRuleChange: boolean;
|
|
190
190
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
191
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "
|
|
191
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "setFieldsValue" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "getInternalInstance" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl")> & ShallowUnwrapRef<{
|
|
192
192
|
resetFields: () => Promise<void>;
|
|
193
193
|
clearValidate: (name?: NamePath | NamePath[]) => void;
|
|
194
194
|
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
|
|
@@ -202,7 +202,7 @@ declare function __VLS_template(): {
|
|
|
202
202
|
}> | undefined;
|
|
203
203
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
204
204
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
205
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
205
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
206
206
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
207
207
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
208
208
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -288,14 +288,13 @@ declare function __VLS_template(): {
|
|
|
288
288
|
};
|
|
289
289
|
xxl: {
|
|
290
290
|
type: PropType<string | number | ColSize>;
|
|
291
|
-
default: string | number |
|
|
291
|
+
default: string | number | **
|
|
292
|
+
* 订阅事件
|
|
293
|
+
*/).ColSize;
|
|
292
294
|
};
|
|
293
295
|
prefixCls: StringConstructor;
|
|
294
296
|
flex: (StringConstructor | NumberConstructor)[];
|
|
295
|
-
}>> &
|
|
296
|
-
* 注册表单项
|
|
297
|
-
* @param field
|
|
298
|
-
*/).HTMLAttributes;
|
|
297
|
+
}>> & HTMLAttributes;
|
|
299
298
|
labelAlign: FormLabelAlign;
|
|
300
299
|
labelWrap: boolean;
|
|
301
300
|
wrapperCol: Partial< ExtractPropTypes<{
|
|
@@ -683,7 +682,7 @@ declare const __VLS_component: DefineComponent<ApFormProps, {
|
|
|
683
682
|
}> | undefined;
|
|
684
683
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
685
684
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
686
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
685
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
687
686
|
registerWatch: typeof registerWatch;
|
|
688
687
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
689
688
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),z=require("@aplus-frontend/antdv"),C=require("./context.js"),a=require("lodash-unified"),L=require("@vueuse/core"),$=require("./constant.js"),T=require("../utils/index.js"),k=require("./utils/set.js"),y=require("./utils/params.js"),K=l.defineComponent({__name:"ap-form",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{},initialValues:{},syncToUrl:{type:[Boolean,Function],default:!1},syncToUrlPriority:{type:Boolean}},setup(
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),z=require("@aplus-frontend/antdv"),C=require("./context.js"),a=require("lodash-unified"),L=require("@vueuse/core"),$=require("./constant.js"),T=require("../utils/index.js"),k=require("./utils/set.js"),y=require("./utils/params.js"),K=l.defineComponent({__name:"ap-form",props:{layout:{default:"horizontal"},labelCol:{},wrapperCol:{},colon:{type:Boolean,default:!0},labelAlign:{default:"right"},labelWrap:{type:Boolean},prefixCls:{},requiredMark:{},hideRequiredMark:{type:Boolean,default:!1},rules:{},validateMessages:{},validateOnRuleChange:{type:Boolean,default:!0},scrollToFirstError:{},onSubmit:{},name:{},validateTrigger:{default:"change"},size:{},disabled:{type:Boolean},onValuesChange:{},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{},initialValues:{},syncToUrl:{type:[Boolean,Function],default:!1},syncToUrlPriority:{type:Boolean}},setup(U,{expose:m}){const i=U;function V(e,t,r=!0){var o;if(a.isArray(e)){let n=u;for(let d=0;d<e.length-1;d++)e[d]in n||(n[e[d]]={}),n=n[e[d]];n[e[e.length-1]]=t}else u[e]=t;let s=a.isArray(e)?e[0]:e;r&&((o=i.onValuesChange)==null||o.call(i,{[s]:u[s]},u,e)),p()}const c=l.ref(),P=L.useUrlSearchParams(T.getRouteType()),_=l.ref(i.syncToUrl?y.genParams(i.syncToUrl,P,"get"):{});let v=a.cloneDeep(q()),F={};const u=l.reactive(q());let g=[];function q(){const e=i.initialValues||{};return i.syncToUrlPriority?{...e,...l.unref(_)}:{...l.unref(_),...e}}function M(e){var r;const t=h(e,F);i.syncToUrl&&y.setToParams(P,y.genParams(i.syncToUrl,t,"set")),(r=i.onFinish)==null||r.call(i,t)}const O=async()=>{var e;(e=c.value)==null||e.resetFields(),await l.nextTick(()=>{Object.keys(u).forEach(t=>delete u[t]),Object.assign(u,v),p(),i.syncToUrl&&y.setToParams(P,y.genParams(i.syncToUrl,h(v,F),"set"))})},B=e=>{var t;(t=c.value)==null||t.clearValidate(e)},I=(e,t)=>{var r;return(r=c.value)==null?void 0:r.validateFields(e,t)},j=async(e,t)=>{var s;const r=await((s=c.value)==null?void 0:s.validateFields(e,t));return h(r,F)},w=e=>{var t;return(t=c.value)==null?void 0:t.getFieldsValue(e)},x=e=>{var r;const t=(r=c.value)==null?void 0:r.getFieldsValue(e);return h(t,F)},E=(e,t)=>{var r;return(r=c.value)==null?void 0:r.validate(e,t)},S=(e,t={})=>{var r;(r=c.value)==null||r.scrollToField(e,t)},N=e=>{Object.assign(u,e),p()},A=(e,t,r=!0)=>{V(e,t,r),p()};function b(e,t){return t||e(l.toRaw(u)),g.push(e),()=>{g=g.filter(r=>r!==e)}}function R({initialValue:e,name:t,transform:r}){if(T.isDef(e)&&T.isDef(t))if(V(t,e,!1),a.isArray(t)){let s=v;for(let o=0;o<t.length-1;o++)T.isDef(s[t[o]])||(s[t[o]]={}),s=s[t[o]];s[t[t.length-1]]=e}else v[t]=e;r&&(F=k.default(F,[t].flat(1),r,!0))}function D(e){if(e!==$.INTERNAL_FORM_INSTANCE_MARK){console.warn("getInternalInstance should only used at internal");return}return{registerField:R,registerWatch:b}}function p(){if(g.length){const e=l.toRaw(u);g.forEach(t=>{t(e)})}}function h(e,t){if(e==null)return;let r=a.isArray(e)?[]:{};return Object.keys(e).forEach(s=>{const o=e[s],n=t==null?void 0:t[s],d=a.isFunction(n)?n:n==null?void 0:n.transformer,W=a.isFunction(n)?!0:n==null?void 0:n.flat;if(a.isFunction(d)){const f=d(o);W?a.isArray(f)&&a.isArray(r)?r=[...r,...f]:a.isPlainObject(f)&&a.isPlainObject(r)?r={...r,...f}:r[s]=f:r[s]=f}else if(a.isPlainObject(o)||a.isArray(o)){const f=h(o,n);r[s]=f}else r[s]=o}),r}return C.useProvideForm({model:l.computed(()=>u),updateModel:V,internalInstance:{registerWatch:b,registerField:R,setFieldValue:A}}),m({resetFields:O,clearValidate:B,validateFields:I,getFieldsValue:w,validate:E,scrollToField:S,setFieldsValue:N,setFieldValue:A,registerWatch:b,validateFieldsReturnTransformed:j,getFieldsValueTransformed:x,getInternalInstance:D}),(e,t)=>(l.openBlock(),l.createBlock(l.unref(z.Form),l.mergeProps({ref_key:"formRef",ref:c},l.unref(a.omit)(i,["initialValues","onValuesChange","onFinish"]),{model:u,onFinish:M}),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["model"]))}});exports.default=K;
|
|
@@ -110,7 +110,7 @@ declare function __VLS_template(): {
|
|
|
110
110
|
readonly hideRequiredMark?: boolean | undefined;
|
|
111
111
|
readonly validateOnRuleChange?: boolean | undefined;
|
|
112
112
|
readonly scrollToFirstError?: boolean | Options<any> | undefined;
|
|
113
|
-
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable) => void)) | undefined;
|
|
113
|
+
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable, fieldName: NamePath) => void)) | undefined;
|
|
114
114
|
readonly onFieldsChange?: ((changedFields: FieldData[], allFields: FieldData[]) => void) | undefined;
|
|
115
115
|
readonly onFinish?: ((values: any) => void) | undefined;
|
|
116
116
|
readonly onFinishFailed?: ((errorInfo: ValidateErrorEntity<any>) => void) | undefined;
|
|
@@ -147,7 +147,7 @@ declare function __VLS_template(): {
|
|
|
147
147
|
}> | undefined;
|
|
148
148
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
149
149
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
150
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
150
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
151
151
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
152
152
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
153
153
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -191,7 +191,7 @@ declare function __VLS_template(): {
|
|
|
191
191
|
hideRequiredMark: boolean;
|
|
192
192
|
validateOnRuleChange: boolean;
|
|
193
193
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
194
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "
|
|
194
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "setFieldsValue" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "getInternalInstance" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl")> & ShallowUnwrapRef<{
|
|
195
195
|
resetFields: () => Promise<void>;
|
|
196
196
|
clearValidate: (name?: NamePath | NamePath[]) => void;
|
|
197
197
|
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
|
|
@@ -205,7 +205,7 @@ declare function __VLS_template(): {
|
|
|
205
205
|
}> | undefined;
|
|
206
206
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
207
207
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
208
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
208
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
209
209
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
210
210
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
211
211
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -43,9 +43,10 @@ export type ApFormProps = Omit<FormProps, 'model'> & {
|
|
|
43
43
|
* 字段值更新时触发
|
|
44
44
|
* @param changedValues 更改的字段值
|
|
45
45
|
* @param allValues 更改后的字段值
|
|
46
|
+
* @param fieldName 触发change的表单项
|
|
46
47
|
* @returns
|
|
47
48
|
*/
|
|
48
|
-
onValuesChange?: (changedValues: Recordable, allValues: Recordable) => void;
|
|
49
|
+
onValuesChange?: (changedValues: Recordable, allValues: Recordable, fieldName: NamePath) => void;
|
|
49
50
|
/**
|
|
50
51
|
* 同步表单数据到url中
|
|
51
52
|
*/
|
|
@@ -58,7 +59,7 @@ export type ApFormProps = Omit<FormProps, 'model'> & {
|
|
|
58
59
|
export type WatchFunc = (values?: Recordable) => void;
|
|
59
60
|
export type ApFormExpose<ModelType = any> = {
|
|
60
61
|
setFieldsValue: (fields: Partial<ModelType>) => void;
|
|
61
|
-
setFieldValue: (name: NamePath, value: any) => void;
|
|
62
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
62
63
|
resetFields: () => Promise<void>;
|
|
63
64
|
clearValidate: (name?: NamePath) => void;
|
|
64
65
|
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<ModelType>> | undefined;
|
|
@@ -107,7 +108,15 @@ export type ApFormInternalInstance = {
|
|
|
107
108
|
* @returns
|
|
108
109
|
*/
|
|
109
110
|
registerField: (field: RegistedFieldType) => void;
|
|
110
|
-
|
|
111
|
+
/**
|
|
112
|
+
* 设置表单值
|
|
113
|
+
* @param name
|
|
114
|
+
* @param value
|
|
115
|
+
* @param triggerChange
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
119
|
+
};
|
|
111
120
|
export type ApFormItemExpose = FormItemExpose & {
|
|
112
121
|
/**
|
|
113
122
|
* 是否需要格式化(默认为false)
|
|
@@ -111,7 +111,7 @@ declare function __VLS_template(): {
|
|
|
111
111
|
readonly hideRequiredMark?: boolean | undefined;
|
|
112
112
|
readonly validateOnRuleChange?: boolean | undefined;
|
|
113
113
|
readonly scrollToFirstError?: boolean | Options<any> | undefined;
|
|
114
|
-
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable) => void)) | undefined;
|
|
114
|
+
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable, fieldName: NamePath) => void)) | undefined;
|
|
115
115
|
readonly onFieldsChange?: ((changedFields: FieldData[], allFields: FieldData[]) => void) | undefined;
|
|
116
116
|
readonly onFinish?: ((values: any) => void) | undefined;
|
|
117
117
|
readonly onFinishFailed?: ((errorInfo: ValidateErrorEntity<any>) => void) | undefined;
|
|
@@ -148,7 +148,7 @@ declare function __VLS_template(): {
|
|
|
148
148
|
}> | undefined;
|
|
149
149
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
150
150
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
151
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
151
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
152
152
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
153
153
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
154
154
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -192,7 +192,7 @@ declare function __VLS_template(): {
|
|
|
192
192
|
hideRequiredMark: boolean;
|
|
193
193
|
validateOnRuleChange: boolean;
|
|
194
194
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
195
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "
|
|
195
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "setFieldsValue" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "getInternalInstance" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl")> & ShallowUnwrapRef<{
|
|
196
196
|
resetFields: () => Promise<void>;
|
|
197
197
|
clearValidate: (name?: NamePath | NamePath[]) => void;
|
|
198
198
|
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
|
|
@@ -206,7 +206,7 @@ declare function __VLS_template(): {
|
|
|
206
206
|
}> | undefined;
|
|
207
207
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
208
208
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
209
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
209
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
210
210
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
211
211
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
212
212
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApFormExpose, ApFormSearchFormProps } from '../interface';
|
|
2
2
|
import { ComponentInternalInstance, ExtractPropTypes, PropType, HTMLAttributes, VNodeProps, AllowedComponentProps, ComponentCustomProps, Slot, ComponentPublicInstance, ComponentOptionsBase, ComponentOptionsMixin, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DebuggerEvent, nextTick, WatchOptions, WatchStopHandle, ShallowUnwrapRef, ComponentCustomProperties, DefineComponent, ComputedRef, PublicProps } from 'vue';
|
|
3
3
|
import { ButtonSize } from '@aplus-frontend/antdv/es/button';
|
|
4
|
-
import { ValidateMessages, FormLabelAlign, FieldData, ValidateErrorEntity,
|
|
4
|
+
import { ValidateMessages, FormLabelAlign, NamePath, FieldData, ValidateErrorEntity, ValidateOptions, InternalNamePath } from '@aplus-frontend/antdv/es/form/interface';
|
|
5
5
|
import { RequiredMark } from '@aplus-frontend/antdv/es/form/Form';
|
|
6
6
|
import { ColSize } from '@aplus-frontend/antdv/es/grid';
|
|
7
7
|
import { RuleObject } from '@aplus-frontend/antdv/es/form';
|
|
@@ -107,7 +107,7 @@ declare function __VLS_template(): {
|
|
|
107
107
|
readonly hideRequiredMark?: boolean | undefined;
|
|
108
108
|
readonly validateOnRuleChange?: boolean | undefined;
|
|
109
109
|
readonly scrollToFirstError?: boolean | Options<any> | undefined;
|
|
110
|
-
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable) => void)) | undefined;
|
|
110
|
+
readonly onValuesChange?: (((changedValues: any, values: any) => void) & ((changedValues: Recordable, allValues: Recordable, fieldName: NamePath) => void)) | undefined;
|
|
111
111
|
readonly onFieldsChange?: ((changedFields: FieldData[], allFields: FieldData[]) => void) | undefined;
|
|
112
112
|
readonly onFinish?: ((values: any) => void) | undefined;
|
|
113
113
|
readonly onFinishFailed?: ((errorInfo: ValidateErrorEntity<any>) => void) | undefined;
|
|
@@ -144,7 +144,7 @@ declare function __VLS_template(): {
|
|
|
144
144
|
}> | undefined;
|
|
145
145
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
146
146
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
147
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
147
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
148
148
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
149
149
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
150
150
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
@@ -188,7 +188,7 @@ declare function __VLS_template(): {
|
|
|
188
188
|
hideRequiredMark: boolean;
|
|
189
189
|
validateOnRuleChange: boolean;
|
|
190
190
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
191
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "
|
|
191
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "setFieldsValue" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed" | "getInternalInstance" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl")> & ShallowUnwrapRef<{
|
|
192
192
|
resetFields: () => Promise<void>;
|
|
193
193
|
clearValidate: (name?: NamePath | NamePath[]) => void;
|
|
194
194
|
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<{
|
|
@@ -202,7 +202,7 @@ declare function __VLS_template(): {
|
|
|
202
202
|
}> | undefined;
|
|
203
203
|
scrollToField: (name: NamePath, options?: {}) => void;
|
|
204
204
|
setFieldsValue: (values: Record<string, any>) => void;
|
|
205
|
-
setFieldValue: (name: NamePath, newValue: any) => void;
|
|
205
|
+
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
206
206
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
207
207
|
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
208
208
|
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aplus-frontend/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"sortablejs": "^1.15.2",
|
|
65
65
|
"vue-virtual-scroller": "2.0.0-beta.8",
|
|
66
66
|
"vuedraggable": "^4.1.0",
|
|
67
|
-
"@aplus-frontend/
|
|
68
|
-
"@aplus-frontend/
|
|
67
|
+
"@aplus-frontend/hooks": "1.0.7",
|
|
68
|
+
"@aplus-frontend/utils": "1.0.43"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@aplus-frontend/antdv": "^1.0.8",
|