@aplus-frontend/ui 0.3.10 → 0.3.12
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/index.mjs +231 -227
- package/es/src/ap-form/ap-form.vue.d.ts +13 -34
- package/es/src/ap-form/ap-form.vue2.mjs +143 -120
- package/es/src/ap-form/drawer-form/index.vue.d.ts +22 -40
- package/es/src/ap-form/drawer-form/index.vue.mjs +3 -3
- package/es/src/ap-form/index.d.ts +3 -1
- package/es/src/ap-form/index.mjs +26 -22
- package/es/src/ap-form/interface.d.ts +3 -1
- package/es/src/ap-form/modal-form/index.vue.d.ts +23 -41
- package/es/src/ap-form/modal-form/index.vue.mjs +64 -58
- package/es/src/ap-form/provider/context.d.ts +3 -0
- package/es/src/ap-form/provider/context.mjs +17 -0
- package/es/src/ap-form/provider/index.vue.d.ts +19 -0
- package/es/src/ap-form/provider/index.vue.mjs +39 -0
- package/es/src/ap-form/provider/index.vue2.mjs +4 -0
- package/es/src/ap-form/provider/interface.d.ts +22 -0
- package/es/src/ap-form/search-form/index.vue.d.ts +22 -40
- package/es/src/business/ap-select-layout/select-layout.vue2.mjs +33 -29
- package/es/src/business/ap-table-modal/interface.d.ts +2 -0
- package/es/src/business/ap-table-modal/table-modal.vue2.mjs +50 -48
- package/es/src/config-provider/config-provider-props.d.ts +0 -2
- package/es/src/config-provider/config-provider-props.mjs +2 -4
- package/es/src/config-provider/config-provider.d.ts +0 -6
- package/es/src/config-provider/config-provider.mjs +26 -25
- package/es/src/config-provider/constants.d.ts +2 -0
- package/es/src/config-provider/constants.mjs +3 -1
- package/es/src/config-provider/hooks/use-global-config.d.ts +0 -2
- package/es/src/config-provider/index.d.ts +0 -12
- package/es/src/config-provider/index.mjs +17 -15
- package/es/src/index.mjs +210 -206
- package/es/src/utils/slot.mjs +6 -8
- package/lib/index.js +1 -1
- package/lib/src/ap-form/ap-form.vue.d.ts +13 -34
- package/lib/src/ap-form/ap-form.vue2.js +1 -1
- package/lib/src/ap-form/drawer-form/index.vue.d.ts +22 -40
- package/lib/src/ap-form/drawer-form/index.vue.js +1 -1
- package/lib/src/ap-form/index.d.ts +3 -1
- package/lib/src/ap-form/index.js +1 -1
- package/lib/src/ap-form/interface.d.ts +3 -1
- package/lib/src/ap-form/modal-form/index.vue.d.ts +23 -41
- package/lib/src/ap-form/modal-form/index.vue.js +1 -1
- package/lib/src/ap-form/provider/context.d.ts +3 -0
- package/lib/src/ap-form/provider/context.js +1 -0
- package/lib/src/ap-form/provider/index.vue.d.ts +19 -0
- package/lib/src/ap-form/provider/index.vue.js +1 -0
- package/lib/src/ap-form/provider/index.vue2.js +1 -0
- package/lib/src/ap-form/provider/interface.d.ts +22 -0
- package/lib/src/ap-form/search-form/index.vue.d.ts +22 -40
- package/lib/src/business/ap-select-layout/select-layout.vue2.js +1 -1
- package/lib/src/business/ap-table-modal/interface.d.ts +2 -0
- package/lib/src/business/ap-table-modal/table-modal.vue2.js +1 -1
- package/lib/src/config-provider/config-provider-props.d.ts +0 -2
- package/lib/src/config-provider/config-provider-props.js +1 -1
- package/lib/src/config-provider/config-provider.d.ts +0 -6
- package/lib/src/config-provider/config-provider.js +1 -1
- package/lib/src/config-provider/constants.d.ts +2 -0
- package/lib/src/config-provider/constants.js +1 -1
- package/lib/src/config-provider/hooks/use-global-config.d.ts +0 -2
- package/lib/src/config-provider/index.d.ts +0 -12
- package/lib/src/config-provider/index.js +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/utils/slot.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApFormProps,
|
|
1
|
+
import { ApFormProps, WatchFunc, ApFormInternalInstance } from './interface';
|
|
2
2
|
import { InternalNamePath, NamePath, ValidateOptions, FormLabelAlign, ValidateMessages, FieldData, ValidateErrorEntity } from '@aplus-frontend/antdv/es/form/interface';
|
|
3
3
|
import { Recordable } from '../type';
|
|
4
4
|
import { CreateComponentPublicInstanceWithMixins, ExtractPropTypes, PropType, HTMLAttributes, ComponentOptionsMixin, PublicProps, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DefineComponent } from 'vue';
|
|
@@ -9,19 +9,6 @@ import { RuleObject } from '@aplus-frontend/antdv/es/form';
|
|
|
9
9
|
import { Options } from '../../node_modules/scroll-into-view-if-needed';
|
|
10
10
|
import { SizeType } from '@aplus-frontend/antdv/es/button';
|
|
11
11
|
import { VueNode } from '@aplus-frontend/antdv/es/_util/type';
|
|
12
|
-
/**
|
|
13
|
-
* 订阅事件
|
|
14
|
-
*/
|
|
15
|
-
declare function registerWatch(callback: WatchFunc, inner: boolean): () => void;
|
|
16
|
-
/**
|
|
17
|
-
* 注册表单项
|
|
18
|
-
* @param field
|
|
19
|
-
*/
|
|
20
|
-
declare function registerField({ initialValue, name, transform }: RegistedFieldType): void;
|
|
21
|
-
declare function getInternalInstance(mark: string): {
|
|
22
|
-
registerField: typeof registerField;
|
|
23
|
-
registerWatch: typeof registerWatch;
|
|
24
|
-
} | undefined;
|
|
25
12
|
declare function __VLS_template(): {
|
|
26
13
|
attrs: Partial<{}>;
|
|
27
14
|
slots: {
|
|
@@ -288,9 +275,7 @@ declare function __VLS_template(): {
|
|
|
288
275
|
};
|
|
289
276
|
xxl: {
|
|
290
277
|
type: PropType<string | number | ColSize>;
|
|
291
|
-
default: string | number |
|
|
292
|
-
* 订阅事件
|
|
293
|
-
*/).ColSize;
|
|
278
|
+
default: string | number | ColSize;
|
|
294
279
|
};
|
|
295
280
|
prefixCls: StringConstructor;
|
|
296
281
|
flex: (StringConstructor | NumberConstructor)[];
|
|
@@ -669,24 +654,18 @@ declare function __VLS_template(): {
|
|
|
669
654
|
};
|
|
670
655
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
671
656
|
declare const __VLS_component: DefineComponent<ApFormProps, {
|
|
657
|
+
setFieldsValue: (fields: Partial<any>) => void;
|
|
658
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
672
659
|
resetFields: () => Promise<void>;
|
|
673
|
-
clearValidate: (name?: NamePath
|
|
674
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
}> | undefined;
|
|
683
|
-
scrollToField: (name: NamePath, options?: {}) => void;
|
|
684
|
-
setFieldsValue: (values: Record<string, any>) => void;
|
|
685
|
-
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
686
|
-
registerWatch: typeof registerWatch;
|
|
687
|
-
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
688
|
-
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
689
|
-
getInternalInstance: typeof getInternalInstance;
|
|
660
|
+
clearValidate: (name?: NamePath) => void;
|
|
661
|
+
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
662
|
+
getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
663
|
+
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
664
|
+
scrollToField: (name: NamePath, options?: any) => void;
|
|
665
|
+
getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
|
|
666
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
667
|
+
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
668
|
+
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
690
669
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ApFormProps> & Readonly<{}>, {
|
|
691
670
|
layout: string;
|
|
692
671
|
colon: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue"),L=require("@aplus-frontend/antdv"),k=require("./context.js"),o=require("lodash-unified"),K=require("@vueuse/core"),G=require("./constant.js"),y=require("../utils/index.js"),H=require("./utils/set.js"),T=require("./utils/params.js"),J=require("./provider/context.js"),Q=i.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},onFieldsChange:{},onFinish:{},onFinishFailed:{},onValidate:{},initialValues:{},onValuesChange:{},syncToUrl:{type:[Boolean,Function],default:!1},syncToUrlPriority:{type:Boolean}},setup(M,{expose:R}){function O(e,t){return o.isArray(t)?t.reduce((r,l)=>r==null?void 0:r[l],e):e==null?void 0:e[t]}const n=M;function P(e,t,r=!0){var a;if(o.isArray(e)){let s=u;for(let f=0;f<e.length-1;f++)e[f]in s||(s[e[f]]={}),s=s[e[f]];s[e[e.length-1]]=t}else u[e]=t;let l=o.isArray(e)?e[0]:e;if(r){const s={[l]:u[l]};p.triggerFormChange(n.name,s),(a=n.onValuesChange)==null||a.call(n,s,u,e)}V()}const c=i.ref(),m=K.useUrlSearchParams(y.getRouteType()),p=J.useInjectFormProvider(),b=i.ref(n.syncToUrl?T.genParams(n.syncToUrl,m,"get"):{});let v=o.cloneDeep(U()),F={};const u=i.reactive(U());let g=[];function U(){const e=n.initialValues||{};return n.syncToUrlPriority?{...e,...i.unref(b)}:{...i.unref(b),...e}}function j(e){var r;const t=h(e,F);p.triggerFormFinish(n.name,e),n.syncToUrl&&T.setToParams(m,T.genParams(n.syncToUrl,t,"set")),(r=n.onFinish)==null||r.call(n,t)}const B=async()=>{var e;(e=c.value)==null||e.resetFields(),await i.nextTick(()=>{Object.keys(u).forEach(t=>delete u[t]),Object.assign(u,v),V(),n.syncToUrl&&T.setToParams(m,T.genParams(n.syncToUrl,h(v,F),"set"))})},w=e=>{var t;(t=c.value)==null||t.clearValidate(e)},x=(e,t)=>{var r;return(r=c.value)==null?void 0:r.validateFields(e,t)},E=async(e,t)=>{var l;const r=await((l=c.value)==null?void 0:l.validateFields(e,t));return h(r,F)},S=e=>{var t;return(t=c.value)==null?void 0:t.getFieldsValue(e)},C=e=>{var r;const t=(r=c.value)==null?void 0:r.getFieldsValue(e);return h(t,F)},D=(e,t)=>{var r;return(r=c.value)==null?void 0:r.validate(e,t)},N=(e,t={})=>{var r;(r=c.value)==null||r.scrollToField(e,t)},W=e=>{Object.assign(u,e),V()},q=(e,t,r=!0)=>{P(e,t,r),V()};function A(e,t){return t||e(i.toRaw(u)),g.push(e),()=>{g=g.filter(r=>r!==e)}}function _({initialValue:e,name:t,transform:r}){if(y.isDef(e)&&y.isDef(t)){const l=O(i.unref(b),t);if(!y.isDef(l)||!n.syncToUrlPriority)if(P(t,e,!1),o.isArray(t)){let a=v;for(let s=0;s<t.length-1;s++)y.isDef(a[t[s]])||(a[t[s]]={}),a=a[t[s]];a[t[t.length-1]]=e}else v[t]=e}r&&(F=H.default(F,[t].flat(1),r,!0))}function $(e){if(e!==G.INTERNAL_FORM_INSTANCE_MARK){console.warn("getInternalInstance should only used at internal");return}return{registerField:_,registerWatch:A,setFieldValue:q}}function V(){if(g.length){const e=i.toRaw(u);g.forEach(t=>{t(e)})}}function h(e,t){if(e==null)return;let r=o.isArray(e)?[]:{};return Object.keys(e).forEach(l=>{const a=e[l],s=t==null?void 0:t[l],f=o.isFunction(s)?s:s==null?void 0:s.transformer,z=o.isFunction(s)?!0:s==null?void 0:s.flat;if(o.isFunction(f)){const d=f(a);z?o.isArray(d)&&o.isArray(r)?r=[...r,...d]:o.isPlainObject(d)&&o.isPlainObject(r)?r={...r,...d}:r[l]=d:r[l]=d}else if(o.isPlainObject(a)||o.isArray(a)){const d=h(a,s);r[l]=d}else r[l]=a}),r}const I={resetFields:B,clearValidate:w,validateFields:x,getFieldsValue:S,validate:D,scrollToField:N,setFieldsValue:W,setFieldValue:q,registerWatch:A,validateFieldsReturnTransformed:E,getFieldsValueTransformed:C,getInternalInstance:$};return i.watch(()=>n.name,e=>{e&&(p.registerForm(e,I),i.onWatcherCleanup(()=>{p.unregisterForm(n.name)}))},{immediate:!0}),k.useProvideForm({model:i.computed(()=>u),updateModel:P,internalInstance:{registerWatch:A,registerField:_,setFieldValue:q}}),R(I),(e,t)=>(i.openBlock(),i.createBlock(i.unref(L.Form),i.mergeProps({ref_key:"formRef",ref:c},i.unref(o.omit)(n,["initialValues","onValuesChange","onFinish"]),{model:u,onFinish:j}),{default:i.withCtx(()=>[i.renderSlot(e.$slots,"default")]),_:3},16,["model"]))}});exports.default=Q;
|
|
@@ -7,7 +7,7 @@ import { ColSize } from '@aplus-frontend/antdv/es/grid';
|
|
|
7
7
|
import { RuleObject } from '@aplus-frontend/antdv/es/form';
|
|
8
8
|
import { Options } from '../../../node_modules/scroll-into-view-if-needed';
|
|
9
9
|
import { Recordable } from '../../type';
|
|
10
|
-
import { ApFormProps,
|
|
10
|
+
import { ApFormProps, ApFormInternalInstance, WatchFunc, ApFormSubmitterConfig } from '..';
|
|
11
11
|
import { OnCleanup } from '@vue/reactivity';
|
|
12
12
|
import { VueTypeValidableDef, VueTypeDef } from '../../../node_modules/vue-types';
|
|
13
13
|
import { PushState } from '@aplus-frontend/antdv/es/drawer';
|
|
@@ -134,27 +134,18 @@ declare function __VLS_template(): {
|
|
|
134
134
|
$emit: (event: string, ...args: any[]) => void;
|
|
135
135
|
$el: any;
|
|
136
136
|
$options: ComponentOptionsBase<Readonly< ApFormProps> & Readonly<{}>, {
|
|
137
|
+
setFieldsValue: (fields: Partial<any>) => void;
|
|
138
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
137
139
|
resetFields: () => Promise<void>;
|
|
138
|
-
clearValidate: (name?: NamePath
|
|
139
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
[key: string]: any;
|
|
147
|
-
}> | undefined;
|
|
148
|
-
scrollToField: (name: NamePath, options?: {}) => void;
|
|
149
|
-
setFieldsValue: (values: Record<string, any>) => void;
|
|
150
|
-
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
140
|
+
clearValidate: (name?: NamePath) => void;
|
|
141
|
+
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
142
|
+
getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
143
|
+
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
144
|
+
scrollToField: (name: NamePath, options?: any) => void;
|
|
145
|
+
getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
|
|
146
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
147
|
+
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
151
148
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
152
|
-
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
153
|
-
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
154
|
-
getInternalInstance: (mark: string) => {
|
|
155
|
-
registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
|
|
156
|
-
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
157
|
-
} | undefined;
|
|
158
149
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
|
|
159
150
|
layout: string;
|
|
160
151
|
colon: boolean;
|
|
@@ -191,28 +182,19 @@ declare function __VLS_template(): {
|
|
|
191
182
|
hideRequiredMark: boolean;
|
|
192
183
|
validateOnRuleChange: boolean;
|
|
193
184
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
194
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "
|
|
185
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl") | "setFieldsValue" | "getInternalInstance" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed"> & ShallowUnwrapRef<{
|
|
186
|
+
setFieldsValue: (fields: Partial<any>) => void;
|
|
187
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
195
188
|
resetFields: () => Promise<void>;
|
|
196
|
-
clearValidate: (name?: NamePath
|
|
197
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
[key: string]: any;
|
|
205
|
-
}> | undefined;
|
|
206
|
-
scrollToField: (name: NamePath, options?: {}) => void;
|
|
207
|
-
setFieldsValue: (values: Record<string, any>) => void;
|
|
208
|
-
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
189
|
+
clearValidate: (name?: NamePath) => void;
|
|
190
|
+
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
191
|
+
getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
192
|
+
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
193
|
+
scrollToField: (name: NamePath, options?: any) => void;
|
|
194
|
+
getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
|
|
195
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
196
|
+
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
209
197
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
210
|
-
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
211
|
-
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
212
|
-
getInternalInstance: (mark: string) => {
|
|
213
|
-
registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
|
|
214
|
-
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
215
|
-
} | undefined;
|
|
216
198
|
}> & {} & ComponentCustomProperties & {} & {
|
|
217
199
|
$slots: {
|
|
218
200
|
default?(_: {}): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),c=require("@aplus-frontend/antdv");require("../ap-form.vue.js");require("../../hooks/index.js");const U=require("../../utils/slot.js");require("../../config-provider/index.js");const g=require("lodash-unified"),j=require("../../utils/index.js"),E=require("../../hooks/useControllableValue.js"),D=require("../../config-provider/hooks/use-locale.js"),I=require("../../config-provider/hooks/use-namespace.js"),$=require("../ap-form.vue2.js");function k(f){return typeof f=="function"||Object.prototype.toString.call(f)==="[object Object]"&&!t.isVNode(f)}const A=t.defineComponent({__name:"index",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},onFieldsChange:{},onFinishFailed:{},onValidate:{},initialValues:{},onValuesChange:{},syncToUrl:{type:[Boolean,Function]},syncToUrlPriority:{type:Boolean},open:{type:Boolean,default:void 0},"onUpdate:open":{},drawerProps:{default:()=>({})},title:{},width:{default:378},onFinish:{},submitter:{type:[Boolean,Object],default:()=>({resetButtonProps:!1})},showCancel:{type:Boolean,default:!0},submitTimeout:{},resize:{type:[Object,Boolean],default:!1}},emits:["update:open"],setup(f,{expose:x,emit:T}){const i=f,v=t.useSlots(),N=T,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),c=require("@aplus-frontend/antdv");require("../ap-form.vue.js");require("../../hooks/index.js");const U=require("../../utils/slot.js");require("../../config-provider/index.js");const g=require("lodash-unified"),j=require("../../utils/index.js"),E=require("../../hooks/useControllableValue.js"),D=require("../../config-provider/hooks/use-locale.js"),I=require("../../config-provider/hooks/use-namespace.js"),$=require("../ap-form.vue2.js");function k(f){return typeof f=="function"||Object.prototype.toString.call(f)==="[object Object]"&&!t.isVNode(f)}const A=t.defineComponent({__name:"index",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},onFieldsChange:{},onFinishFailed:{},onValidate:{},initialValues:{},onValuesChange:{},syncToUrl:{type:[Boolean,Function]},syncToUrlPriority:{type:Boolean},open:{type:Boolean,default:void 0},"onUpdate:open":{},drawerProps:{default:()=>({})},title:{},width:{default:378},onFinish:{},submitter:{type:[Boolean,Object],default:()=>({resetButtonProps:!1})},showCancel:{type:Boolean,default:!0},submitTimeout:{},resize:{type:[Object,Boolean],default:!1}},emits:["update:open"],setup(f,{expose:x,emit:T}){const i=f,v=t.useSlots(),N=T,r=t.ref(),p=t.ref(),u=t.ref(!1),{value:y,updateValue:h}=E.useControllableValue(i,N,{valuePropName:"open",defaultValue:!1}),d=t.computed(()=>{var n,o,a,s;const e={onResize:()=>{},minWidth:300,maxWidth:window.innerWidth*.8,resizeOnOpen:!0};return g.isBoolean(i.resize)?i.resize?e:{}:{minWidth:((n=i.resize)==null?void 0:n.minWidth)??e.minWidth,maxWidth:((o=i.resize)==null?void 0:o.maxWidth)??e.maxWidth,onResize:((a=i.resize)==null?void 0:a.onResize)??e.onResize,resizeOnOpen:g.isUndefined((s=i.resize)==null?void 0:s.resizeOnOpen)?e.onResize:i.resize.resizeOnOpen}}),m=t.ref(F()),{t:b}=D.useLocale(),{e:O,em:V}=I.useNamespace("ap-form-drawer-form"),P=t.computed(()=>[O("resize-bar"),{[V("resize-bar","min-disabled")]:t.unref(m)===t.unref(d).minWidth},{[V("resize-bar","max-disabled")]:t.unref(m)===t.unref(d).maxWidth}]);t.watch(()=>r.value,e=>{var n;e&&p.value&&((n=e.setFieldsValue)==null||n.call(e,p.value),p.value=void 0)}),t.watch(()=>t.unref(y),e=>{var n;e&&(n=t.unref(d))!=null&&n.resizeOnOpen&&(m.value=F())});function F(){var n;const e=(n=t.unref(d))==null?void 0:n.minWidth;return!e||e&&e<i.width?i.width:e}const C=U.getSingleVNode(v.trigger),w=C?t.cloneVNode(C,{onClick:()=>{h(!0)}}):null,R=t.computed(()=>{var n,o,a,s;const e=[];if(i.submitter===!1)return null;if(i.showCancel){let l;e.push(t.createVNode(c.Button,{onClick:W,disabled:u.value},k(l=b("ap.common.cancelText"))?l:{default:()=>[l]}))}return((n=i.submitter)==null?void 0:n.resetButtonProps)!==!1&&e.push(t.createVNode(c.Button,t.mergeProps(((o=i.submitter)==null?void 0:o.resetButtonProps)||{},{key:"submit",disabled:u.value,onClick:q}),{default:()=>{var l;return[((l=i.submitter)==null?void 0:l.resetText)||b("ap.common.resetText")]}})),((a=i.submitter)==null?void 0:a.submitButtonProps)!==!1&&e.push(t.createVNode(c.Button,t.mergeProps({type:"primary",key:"submit"},((s=i.submitter)==null?void 0:s.submitButtonProps)||{},{loading:u.value,onClick:S}),{default:()=>{var l;return[((l=i.submitter)==null?void 0:l.submitText)||b("ap.common.okText")]}})),t.createVNode(c.Flex,{justify:"flex-end"},{default:()=>[v.submitter?v.submitter(e):t.createVNode(c.Space,null,k(e)?e:{default:()=>[e]})]})});function _(){var e,n;(n=(e=d.value)==null?void 0:e.onResize)==null||n.call(e),document.addEventListener("mousemove",B),document.addEventListener("mouseup",z)}function B(e){const n=t.unref(d),o=(document.body.offsetWidth||1e3)-(e.clientX-document.body.offsetLeft),a=(n==null?void 0:n.minWidth)??(i.width||800),s=(n==null?void 0:n.maxWidth)??window.innerWidth*.8;let l=o;o<a&&(l=a),o>s&&(l=s),m.value=l}function z(){document.removeEventListener("mousemove",B),document.removeEventListener("mouseup",z)}function q(){var e,n,o;i.submitter!==!1&&((e=r.value)==null||e.resetFields(),(o=(n=i.submitter)==null?void 0:n.onReset)==null||o.call(n))}async function S(){var e,n,o,a;if(i.submitter!==!1)try{const s=await((e=r.value)==null?void 0:e.validateFieldsReturnTransformed());(o=(n=i.submitter)==null?void 0:n.onSubmit)==null||o.call(n),u.value=!0;const l=(a=i.onFinish)==null?void 0:a.call(i,j.convertReactiveToRaw(s));if(i.submitTimeout&&l instanceof Promise){const L=setTimeout(()=>u.value=!1,i.submitTimeout);l.finally(()=>{clearTimeout(L),u.value=!1})}await l&&h(!1)}finally{u.value=!1}}function W(){t.unref(u)||h(!1)}function M(e){!e&&t.unref(u)||h(e)}return x({resetFields:()=>{var e;(e=r.value)==null||e.resetFields()},clearValidate:e=>{var n;(n=r.value)==null||n.clearValidate(e)},validateFields:(e,n)=>{var o;return(o=r.value)==null?void 0:o.validateFields(e,n)},getFieldsValue:e=>{var n;return(n=r.value)==null?void 0:n.getFieldsValue(e)},validate:(e,n)=>{var o;return(o=r.value)==null?void 0:o.validate(e,n)},scrollToField:(e,n={})=>{var o;(o=r.value)==null||o.scrollToField(e,n)},setFieldValue:(e,n)=>{var o,a;(a=(o=r.value)==null?void 0:o.setFieldValue)==null||a.call(o,e,n)},setFieldsValue:e=>{var n,o;if(!r.value){p.value=e;return}(o=(n=r.value)==null?void 0:n.setFieldsValue)==null||o.call(n,e)},getInternalInstance:e=>{var n;return(n=r.value)==null?void 0:n.getInternalInstance(e)}}),(e,n)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(t.unref(c.Drawer),t.mergeProps(e.drawerProps,{open:t.unref(y),width:m.value,"onUpdate:open":M,onCancel:W}),{title:t.withCtx(()=>[t.renderSlot(e.$slots,"title",{},()=>[t.createTextVNode(t.toDisplayString(i.title),1)])]),footer:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(R.value)))]),default:t.withCtx(()=>[t.createVNode($.default,t.mergeProps({ref_key:"formRef",ref:r},t.unref(g.omit)(i,["drawerProps","open","onUpdate:open","title","width","onFinish","submitter"])),{default:t.withCtx(()=>[t.renderSlot(e.$slots,"default")]),_:3},16),e.resize?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(P.value),onMousedown:t.withModifiers(_,["stop","prevent"])},null,34)):t.createCommentVNode("",!0)]),_:3},16,["open","width"]),t.unref(w)?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(w)),{key:0})):t.createCommentVNode("",!0)],64))}});exports.default=A;
|
|
@@ -10,6 +10,7 @@ import { default as ApFormSet } from './set/index.vue';
|
|
|
10
10
|
import { default as ApFormDrawerForm } from './drawer-form/index.vue';
|
|
11
11
|
import { default as ApFormControlRender } from './render/control.vue';
|
|
12
12
|
import { default as ApFormItemRender } from './render/item.vue';
|
|
13
|
+
import { default as ApFormProvider } from './provider/index.vue';
|
|
13
14
|
type ApFormMixedProps = typeof _ApForm & {
|
|
14
15
|
FormItem: typeof ApFormItem;
|
|
15
16
|
FormItemGroup: typeof ApFormItemGroup;
|
|
@@ -22,8 +23,9 @@ type ApFormMixedProps = typeof _ApForm & {
|
|
|
22
23
|
DrawerForm: typeof ApFormDrawerForm;
|
|
23
24
|
ControlRender: typeof ApFormControlRender;
|
|
24
25
|
ItemRender: typeof ApFormItemRender;
|
|
26
|
+
Provider: typeof ApFormProvider;
|
|
25
27
|
};
|
|
26
28
|
declare const ApForm: ApFormMixedProps;
|
|
27
29
|
export * from './items';
|
|
28
30
|
export * from './interface';
|
|
29
|
-
export { ApForm, ApFormItem, ApFormItemGroup, ApFormList, ApFormSearchForm, ApFormModalForm, ApFormDependency, ApFormSet, ApFormDrawerForm, ApFormControlRender, ApFormItemRender };
|
|
31
|
+
export { ApForm, ApFormItem, ApFormItemGroup, ApFormList, ApFormSearchForm, ApFormModalForm, ApFormDependency, ApFormSet, ApFormDrawerForm, ApFormControlRender, ApFormItemRender, ApFormProvider };
|
package/lib/src/ap-form/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./ap-form.vue.js");require("./item/index.vue2.js");require("./item-group/index.vue2.js");require("./list/index.vue2.js");require("./search-form/index.vue2.js");require("./modal-form/index.vue2.js");const s=require("./hooks/use-watch.js");require("./dependency/index.vue2.js");require("./set/index.vue2.js");require("./drawer-form/index.vue2.js");require("./render/control.vue2.js");require("./render/item.vue2.js");require("./items/index.js");require("./interface.js");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./ap-form.vue.js");require("./item/index.vue2.js");require("./item-group/index.vue2.js");require("./list/index.vue2.js");require("./search-form/index.vue2.js");require("./modal-form/index.vue2.js");const s=require("./hooks/use-watch.js");require("./dependency/index.vue2.js");require("./set/index.vue2.js");require("./drawer-form/index.vue2.js");require("./render/control.vue2.js");require("./render/item.vue2.js");require("./provider/index.vue2.js");require("./items/index.js");require("./interface.js");const c=require("./ap-form.vue2.js"),r=require("./item/index.vue.js"),t=require("./item-group/index.vue.js"),u=require("./list/index.vue.js"),_=require("./search-form/index.vue.js"),i=require("./modal-form/index.vue.js"),p=require("./dependency/index.vue.js"),o=require("./set/index.vue.js"),n=require("./drawer-form/index.vue.js"),a=require("./render/control.vue.js"),d=require("./render/item.vue.js"),l=require("./provider/index.vue.js"),e=c.default;e.FormItem=r.default;e.FormItemGroup=t.default;e.FormList=u.default;e.SearchForm=_.default;e.ModalForm=i.default;e.useWatch=s.default;e.Dependency=p.default;e.Set=o.default;e.DrawerForm=n.default;e.ControlRender=a.default;e.ItemRender=d.default;e.Provider=l.default;exports.ApFormItem=r.default;exports.ApFormItemGroup=t.default;exports.ApFormList=u.default;exports.ApFormSearchForm=_.default;exports.ApFormModalForm=i.default;exports.ApFormDependency=p.default;exports.ApFormSet=o.default;exports.ApFormDrawerForm=n.default;exports.ApFormControlRender=a.default;exports.ApFormItemRender=d.default;exports.ApFormProvider=l.default;exports.ApForm=e;
|
|
@@ -3,6 +3,7 @@ import { FormItemExpose } from '@aplus-frontend/antdv/es/form/FormItem';
|
|
|
3
3
|
import { InternalNamePath, NamePath, ValidateOptions } from '@aplus-frontend/antdv/es/form/interface';
|
|
4
4
|
import { Recordable } from '../type';
|
|
5
5
|
import { VNode } from 'vue';
|
|
6
|
+
export type { ApFormChangeInfo, ApFormFinishInfo } from './provider/interface';
|
|
6
7
|
export type ApFormColProps = Omit<ColProps, 'prefixCls'>;
|
|
7
8
|
export type ApFormItemTransformFn = (value: any) => any;
|
|
8
9
|
export type ApFormItemTransformType = ApFormItemTransformFn | {
|
|
@@ -71,7 +72,7 @@ export type ApFormExpose<ModelType = any> = {
|
|
|
71
72
|
* @param mark 内部使用的标记
|
|
72
73
|
* @returns
|
|
73
74
|
*/
|
|
74
|
-
getInternalInstance: (mark: string) => ApFormInternalInstance;
|
|
75
|
+
getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
|
|
75
76
|
/**
|
|
76
77
|
* 校验表单并返回转换后的数据
|
|
77
78
|
* @param nameList
|
|
@@ -85,6 +86,7 @@ export type ApFormExpose<ModelType = any> = {
|
|
|
85
86
|
* @returns
|
|
86
87
|
*/
|
|
87
88
|
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<ModelType> | undefined;
|
|
89
|
+
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
88
90
|
};
|
|
89
91
|
/**
|
|
90
92
|
* 被注册的表单项
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ApFormModalFormProps } from '../interface';
|
|
2
2
|
import { VNode, ComponentInternalInstance, ExtractPropTypes, PropType, HTMLAttributes, VNodeProps, AllowedComponentProps, ComponentCustomProps, Slot, ComponentPublicInstance, ComponentOptionsBase, ComponentOptionsMixin, GlobalComponents, GlobalDirectives, ComponentProvideOptions, DebuggerEvent, nextTick, WatchOptions, WatchStopHandle, ShallowUnwrapRef, ComponentCustomProperties, DefineComponent, PublicProps, CSSProperties } from 'vue';
|
|
3
3
|
import { InternalNamePath, NamePath, ValidateOptions, ValidateMessages, FormLabelAlign, FieldData, ValidateErrorEntity } from '@aplus-frontend/antdv/es/form/interface';
|
|
4
|
+
import { Recordable } from '../../type';
|
|
4
5
|
import { ButtonSize, ButtonType, ButtonShape } from '@aplus-frontend/antdv/es/button';
|
|
5
6
|
import { RequiredMark } from '@aplus-frontend/antdv/es/form/Form';
|
|
6
7
|
import { ColSize } from '@aplus-frontend/antdv/es/grid';
|
|
7
8
|
import { RuleObject } from '@aplus-frontend/antdv/es/form';
|
|
8
9
|
import { Options } from '../../../node_modules/scroll-into-view-if-needed';
|
|
9
|
-
import {
|
|
10
|
-
import { ApFormProps, WatchFunc, RegistedFieldType, ApFormInternalInstance, ApFormSubmitterConfig } from '..';
|
|
10
|
+
import { ApFormProps, ApFormInternalInstance, WatchFunc, ApFormSubmitterConfig } from '..';
|
|
11
11
|
import { OnCleanup } from '@vue/reactivity';
|
|
12
12
|
import { VueTypeValidableDef } from '../../../node_modules/vue-types';
|
|
13
13
|
import { LegacyButtonType, ButtonHTMLType } from '@aplus-frontend/antdv/es/button/buttonTypes';
|
|
@@ -135,27 +135,18 @@ declare function __VLS_template(): {
|
|
|
135
135
|
$emit: (event: string, ...args: any[]) => void;
|
|
136
136
|
$el: any;
|
|
137
137
|
$options: ComponentOptionsBase<Readonly< ApFormProps> & Readonly<{}>, {
|
|
138
|
+
setFieldsValue: (fields: Partial<any>) => void;
|
|
139
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
138
140
|
resetFields: () => Promise<void>;
|
|
139
|
-
clearValidate: (name?: NamePath
|
|
140
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
[key: string]: any;
|
|
148
|
-
}> | undefined;
|
|
149
|
-
scrollToField: (name: NamePath, options?: {}) => void;
|
|
150
|
-
setFieldsValue: (values: Record<string, any>) => void;
|
|
151
|
-
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
141
|
+
clearValidate: (name?: NamePath) => void;
|
|
142
|
+
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
143
|
+
getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
144
|
+
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
145
|
+
scrollToField: (name: NamePath, options?: any) => void;
|
|
146
|
+
getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
|
|
147
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
148
|
+
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
152
149
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
153
|
-
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
154
|
-
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
155
|
-
getInternalInstance: (mark: string) => {
|
|
156
|
-
registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
|
|
157
|
-
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
158
|
-
} | undefined;
|
|
159
150
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
|
|
160
151
|
layout: string;
|
|
161
152
|
colon: boolean;
|
|
@@ -192,28 +183,19 @@ declare function __VLS_template(): {
|
|
|
192
183
|
hideRequiredMark: boolean;
|
|
193
184
|
validateOnRuleChange: boolean;
|
|
194
185
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
195
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "
|
|
186
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl") | "setFieldsValue" | "getInternalInstance" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed"> & ShallowUnwrapRef<{
|
|
187
|
+
setFieldsValue: (fields: Partial<any>) => void;
|
|
188
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
196
189
|
resetFields: () => Promise<void>;
|
|
197
|
-
clearValidate: (name?: NamePath
|
|
198
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
[key: string]: any;
|
|
206
|
-
}> | undefined;
|
|
207
|
-
scrollToField: (name: NamePath, options?: {}) => void;
|
|
208
|
-
setFieldsValue: (values: Record<string, any>) => void;
|
|
209
|
-
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
190
|
+
clearValidate: (name?: NamePath) => void;
|
|
191
|
+
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
192
|
+
getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
193
|
+
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
194
|
+
scrollToField: (name: NamePath, options?: any) => void;
|
|
195
|
+
getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
|
|
196
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
197
|
+
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
210
198
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
211
|
-
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
212
|
-
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
213
|
-
getInternalInstance: (mark: string) => {
|
|
214
|
-
registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
|
|
215
|
-
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
216
|
-
} | undefined;
|
|
217
199
|
}> & {} & ComponentCustomProperties & {} & {
|
|
218
200
|
$slots: {
|
|
219
201
|
default?(_: {}): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("@aplus-frontend/antdv");require("../ap-form.vue.js");require("../../hooks/index.js");const S=require("../../utils/slot.js");require("../../config-provider/index.js");const M=require("lodash-unified");require("../item/index.vue2.js");const j=require("../../hooks/useControllableValue.js"),O=require("../../config-provider/hooks/use-locale.js"),R=require("../../config-provider/hooks/use-global-config.js"),U=require("../../config-provider/hooks/use-namespace.js"),z=require("../ap-form.vue2.js"),D=require("../item/index.vue.js");function F(c){return typeof c=="function"||Object.prototype.toString.call(c)==="[object Object]"&&!e.isVNode(c)}const E=e.defineComponent({__name:"index",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},onFieldsChange:{},onFinishFailed:{},onValidate:{},initialValues:{},onValuesChange:{},syncToUrl:{type:[Boolean,Function]},syncToUrlPriority:{type:Boolean},open:{type:Boolean,default:void 0},"onUpdate:open":{},modalProps:{default:()=>({})},title:{},width:{default:800},onFinish:{},submitter:{type:[Boolean,Object],default:()=>({resetButtonProps:!1})},showCancel:{type:Boolean,default:!0},submitTimeout:{}},emits:["update:open"],setup(c,{expose:C,emit:B}){const a=c,m=e.useSlots(),_=B,n=e.ref(),f=e.ref(),r=e.ref(!1),{value:T,updateValue:p}=j.useControllableValue(a,_,{valuePropName:"open",defaultValue:!1}),{t:b}=O.useLocale(),v=R.useGlobalConfig("uiMode","aplus"),{b:N,e:y}=U.useNamespace("ap-form-modal-form");e.watch(()=>n.value,t=>{var l;t&&f.value&&((l=t.setFieldsValue)==null||l.call(t,f.value),f.value=void 0)});const g=S.getSingleVNode(m.trigger),h=g?e.cloneVNode(g,{onClick:()=>{p(!0)}}):null,k=e.computed(()=>{var l,o,u,i;const t=[];if(a.submitter===!1)return null;if(a.showCancel){let s;t.push(e.createVNode(d.Button,{onClick:V,disabled:r.value},F(s=b("ap.common.cancelText"))?s:{default:()=>[s]}))}return((l=a.submitter)==null?void 0:l.resetButtonProps)!==!1&&t.push(e.createVNode(d.Button,e.mergeProps(((o=a.submitter)==null?void 0:o.resetButtonProps)||{},{key:"reset",disabled:r.value,onClick:P,htmlType:"reset"}),{default:()=>{var s;return[((s=a.submitter)==null?void 0:s.resetText)||b("ap.common.resetText")]}})),((u=a.submitter)==null?void 0:u.submitButtonProps)!==!1&&t.push(e.createVNode(d.Button,e.mergeProps({type:"primary",key:"submit",htmlType:"submit"},((i=a.submitter)==null?void 0:i.submitButtonProps)||{},{loading:r.value}),{default:()=>{var s;return[((s=a.submitter)==null?void 0:s.submitText)||b("ap.common.okText")]}})),e.createVNode(d.Flex,{justify:"flex-end",class:y(e.unref(v)==="admin"?"footer-admin":"footer")},{default:()=>[m.submitter?m.submitter(t):e.createVNode(d.Space,null,F(t)?t:{default:()=>[t]})]})});function P(){var t,l,o;a.submitter!==!1&&((t=n.value)==null||t.resetFields(),(o=(l=a.submitter)==null?void 0:l.onReset)==null||o.call(l))}async function q(t){var l,o,u;if(a.submitter!==!1)try{(o=(l=a.submitter)==null?void 0:l.onSubmit)==null||o.call(l),r.value=!0;const i=(u=a.onFinish)==null?void 0:u.call(a,t);if(a.submitTimeout&&i instanceof Promise){const x=setTimeout(()=>r.value=!1,a.submitTimeout);i.finally(()=>{clearTimeout(x),r.value=!1})}await i&&p(!1)}finally{r.value=!1}}function V(){e.unref(r)||p(!1)}function w(t){!t&&e.unref(r)||p(t)}return C({resetFields:()=>{var t;(t=n.value)==null||t.resetFields()},clearValidate:t=>{var l;(l=n.value)==null||l.clearValidate(t)},validateFields:(t,l)=>{var o;return(o=n.value)==null?void 0:o.validateFields(t,l)},getFieldsValue:t=>{var l;return(l=n.value)==null?void 0:l.getFieldsValue(t)},validate:(t,l)=>{var o;return(o=n.value)==null?void 0:o.validate(t,l)},scrollToField:(t,l={})=>{var o;(o=n.value)==null||o.scrollToField(t,l)},setFieldValue:(t,l)=>{var o,u;(u=(o=n.value)==null?void 0:o.setFieldValue)==null||u.call(o,t,l)},setFieldsValue:t=>{var l,o;if(!n.value){f.value=t;return}(o=(l=n.value)==null?void 0:l.setFieldsValue)==null||o.call(l,t)},getInternalInstance:t=>{var l;return(l=n.value)==null?void 0:l.getInternalInstance(t)}}),(t,l)=>{var o;return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(d.Modal),e.mergeProps(t.modalProps,{open:e.unref(T),footer:null,width:t.width,class:e.unref(N)(),"body-style":{...((o=t.modalProps)==null?void 0:o.bodyStyle)||{},padding:e.unref(v)==="admin"?"0px !important":"20px !important"},"onUpdate:open":w,onCancel:V}),{title:e.withCtx(()=>[e.renderSlot(t.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(a.title),1)])]),default:e.withCtx(()=>[e.createVNode(z.default,e.mergeProps({ref_key:"formRef",ref:n},e.unref(M.omit)(a,["modalProps","open","onUpdate:open","title","width","onFinish","submitter"]),{onFinish:q}),{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(e.unref(y)(e.unref(v)==="admin"?"content-admin":"content"))},[e.renderSlot(t.$slots,"default")],2),e.createVNode(D.default,null,{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value)))]),_:1})]),_:3},16)]),_:3},16,["open","width","class","body-style"]),e.unref(h)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(h)),{key:0})):e.createCommentVNode("",!0)],64)}}});exports.default=E;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),e=Symbol("InternalContextProps"),t=o=>{r.provide(e,o)},i={triggerFormChange:()=>{},triggerFormFinish:()=>{},registerForm:()=>{},unregisterForm:()=>{}},n=()=>r.inject(e,i);exports.useInjectFormProvider=n;exports.useProvideFormProvider=t;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ApFormProviderProps } from './interface';
|
|
2
|
+
import { DefineComponent, ComponentOptionsMixin, PublicProps, ComponentProvideOptions } from 'vue';
|
|
3
|
+
declare function __VLS_template(): {
|
|
4
|
+
attrs: Partial<{}>;
|
|
5
|
+
slots: {
|
|
6
|
+
default?(_: {}): any;
|
|
7
|
+
};
|
|
8
|
+
refs: {};
|
|
9
|
+
rootEl: any;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
12
|
+
declare const __VLS_component: DefineComponent<ApFormProviderProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ApFormProviderProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
13
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
14
|
+
export default _default;
|
|
15
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
16
|
+
new (): {
|
|
17
|
+
$slots: S;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("vue"),u=require("./context.js"),F=s.defineComponent({__name:"index",props:{onFormChange:{type:Function},onFormFinish:{type:Function}},setup(t){const o=t,n=s.ref({}),r=u.useInjectFormProvider();return u.useProvideFormProvider({triggerFormChange(e,i){o!=null&&o.onFormChange&&o.onFormChange(e,{changedFields:i,forms:n.value}),r==null||r.triggerFormChange(e,i)},triggerFormFinish:(e,i)=>{o!=null&&o.onFormFinish&&o.onFormFinish(e,{values:i,forms:n.value}),r==null||r.triggerFormFinish(e,i)},registerForm:(e,i)=>{e&&(n.value={...n.value,[e]:i}),r==null||r.registerForm(e,i)},unregisterForm:e=>{const i={...n.value};delete i[e],n.value=i,r==null||r.unregisterForm(e)}}),(e,i)=>s.renderSlot(e.$slots,"default")}});exports.default=F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index.vue.js");exports.default=e.default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Store } from '@aplus-frontend/antdv/es/form/interface';
|
|
2
|
+
import { ApFormExpose } from '../interface';
|
|
3
|
+
export type ApFormInstance = ApFormExpose;
|
|
4
|
+
export type Forms = Record<string, ApFormInstance>;
|
|
5
|
+
export interface ApFormChangeInfo {
|
|
6
|
+
changedFields: any;
|
|
7
|
+
forms: Forms;
|
|
8
|
+
}
|
|
9
|
+
export interface ApFormFinishInfo {
|
|
10
|
+
values: Store;
|
|
11
|
+
forms: Forms;
|
|
12
|
+
}
|
|
13
|
+
export type ApFormProviderProps = {
|
|
14
|
+
onFormChange?: (name: string, info: ApFormChangeInfo) => void;
|
|
15
|
+
onFormFinish?: (name: string, info: ApFormFinishInfo) => void;
|
|
16
|
+
};
|
|
17
|
+
export interface InternalFormProviderContext {
|
|
18
|
+
triggerFormChange: (name: string, changedFields: any) => void;
|
|
19
|
+
triggerFormFinish: (name: string, values: Store) => void;
|
|
20
|
+
registerForm: (name: string, form: ApFormInstance) => void;
|
|
21
|
+
unregisterForm: (name: string) => void;
|
|
22
|
+
}
|
|
@@ -7,7 +7,7 @@ import { ColSize } from '@aplus-frontend/antdv/es/grid';
|
|
|
7
7
|
import { RuleObject } from '@aplus-frontend/antdv/es/form';
|
|
8
8
|
import { Options } from '../../../node_modules/scroll-into-view-if-needed';
|
|
9
9
|
import { Recordable } from '../../type';
|
|
10
|
-
import { ApFormProps,
|
|
10
|
+
import { ApFormProps, ApFormInternalInstance, WatchFunc } from '..';
|
|
11
11
|
import { OnCleanup } from '@vue/reactivity';
|
|
12
12
|
declare function __VLS_template(): {
|
|
13
13
|
attrs: Partial<{}>;
|
|
@@ -131,27 +131,18 @@ declare function __VLS_template(): {
|
|
|
131
131
|
$emit: (event: string, ...args: any[]) => void;
|
|
132
132
|
$el: any;
|
|
133
133
|
$options: ComponentOptionsBase<Readonly< ApFormProps> & Readonly<{}>, {
|
|
134
|
+
setFieldsValue: (fields: Partial<any>) => void;
|
|
135
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
134
136
|
resetFields: () => Promise<void>;
|
|
135
|
-
clearValidate: (name?: NamePath
|
|
136
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
[key: string]: any;
|
|
144
|
-
}> | undefined;
|
|
145
|
-
scrollToField: (name: NamePath, options?: {}) => void;
|
|
146
|
-
setFieldsValue: (values: Record<string, any>) => void;
|
|
147
|
-
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
137
|
+
clearValidate: (name?: NamePath) => void;
|
|
138
|
+
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
139
|
+
getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
140
|
+
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
141
|
+
scrollToField: (name: NamePath, options?: any) => void;
|
|
142
|
+
getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
|
|
143
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
144
|
+
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
148
145
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
149
|
-
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
150
|
-
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
151
|
-
getInternalInstance: (mark: string) => {
|
|
152
|
-
registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
|
|
153
|
-
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
154
|
-
} | undefined;
|
|
155
146
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
|
|
156
147
|
layout: string;
|
|
157
148
|
colon: boolean;
|
|
@@ -188,28 +179,19 @@ declare function __VLS_template(): {
|
|
|
188
179
|
hideRequiredMark: boolean;
|
|
189
180
|
validateOnRuleChange: boolean;
|
|
190
181
|
syncToUrl: boolean | ((values: Recordable, type: "get" | "set") => Recordable);
|
|
191
|
-
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | "
|
|
182
|
+
}> & Omit<Readonly< ApFormProps> & Readonly<{}>, "validate" | "resetFields" | "clearValidate" | "validateFields" | "getFieldsValue" | "scrollToField" | "registerWatch" | "setFieldValue" | ("layout" | "colon" | "labelAlign" | "validateTrigger" | "hideRequiredMark" | "validateOnRuleChange" | "syncToUrl") | "setFieldsValue" | "getInternalInstance" | "validateFieldsReturnTransformed" | "getFieldsValueTransformed"> & ShallowUnwrapRef<{
|
|
183
|
+
setFieldsValue: (fields: Partial<any>) => void;
|
|
184
|
+
setFieldValue: (name: NamePath, value: any, triggerChange?: boolean) => void;
|
|
192
185
|
resetFields: () => Promise<void>;
|
|
193
|
-
clearValidate: (name?: NamePath
|
|
194
|
-
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
[key: string]: any;
|
|
202
|
-
}> | undefined;
|
|
203
|
-
scrollToField: (name: NamePath, options?: {}) => void;
|
|
204
|
-
setFieldsValue: (values: Record<string, any>) => void;
|
|
205
|
-
setFieldValue: (name: NamePath, newValue: any, triggerChange?: boolean) => void;
|
|
186
|
+
clearValidate: (name?: NamePath) => void;
|
|
187
|
+
validateFields: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
188
|
+
getFieldsValue: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
189
|
+
validate: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
190
|
+
scrollToField: (name: NamePath, options?: any) => void;
|
|
191
|
+
getInternalInstance: (mark: string) => ApFormInternalInstance | undefined;
|
|
192
|
+
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<Partial<any>> | undefined;
|
|
193
|
+
getFieldsValueTransformed: (nameList?: true | InternalNamePath[]) => Partial<any> | undefined;
|
|
206
194
|
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
207
|
-
validateFieldsReturnTransformed: (nameList?: NamePath[] | string, options?: ValidateOptions) => Promise<any>;
|
|
208
|
-
getFieldsValueTransformed: (nameList?: InternalNamePath[] | true) => any;
|
|
209
|
-
getInternalInstance: (mark: string) => {
|
|
210
|
-
registerField: ({ initialValue, name, transform }: RegistedFieldType) => void;
|
|
211
|
-
registerWatch: (callback: WatchFunc, inner: boolean) => () => void;
|
|
212
|
-
} | undefined;
|
|
213
195
|
}> & {} & ComponentCustomProperties & {} & {
|
|
214
196
|
$slots: {
|
|
215
197
|
default?(_: {}): any;
|