@vunk/form 2.19.12 → 2.19.13
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/components/collapse/index.cjs +1 -0
- package/components/collapse/index.d.ts +4 -0
- package/components/collapse/index.mjs +45 -0
- package/components/collapse/src/index.vue.d.ts +15 -0
- package/components/collapse/src/set-attrs.vue.d.ts +23 -0
- package/components/collapse-item/index.cjs +1 -0
- package/components/collapse-item/index.d.ts +6 -0
- package/components/collapse-item/index.mjs +56 -0
- package/components/collapse-item/src/ctx.d.ts +7 -0
- package/components/collapse-item/src/index.vue.d.ts +30 -0
- package/components/collapse-item/src/types.d.ts +1 -0
- package/components/collapse-item/src/use.d.ts +13 -0
- package/components/form/index.cjs +1 -1
- package/components/form/index.d.ts +1 -0
- package/components/form/index.mjs +115 -80
- package/components/form/src/index.vue.d.ts +1 -1
- package/components/form/src/types.d.ts +2 -1
- package/components/form/src/use.d.ts +206 -0
- package/components/form-item/index.cjs +1 -1
- package/components/form-item/index.mjs +92 -75
- package/components/form-item/src/core.vue.d.ts +2 -0
- package/composables/form-mitt/index.cjs +1 -0
- package/composables/form-mitt/index.d.ts +37 -0
- package/composables/form-mitt/index.mjs +41 -0
- package/composables/index.cjs +1 -1
- package/composables/index.d.ts +1 -0
- package/composables/index.mjs +16 -14
- package/package.json +19 -1
- package/shared/element-plus/ctx.d.ts +1 -0
- package/shared/element-plus/index.cjs +1 -1
- package/shared/element-plus/index.mjs +57 -56
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),a=require("element-plus"),l=e.defineComponent({__name:"set-attrs",props:{accordion:{type:Boolean}},setup(n){const o=n,c=e.inject(a.collapseContextKey,null);return e.provide(a.collapseContextKey,{...c,accordion:e.computed(()=>o.accordion)}),(t,d)=>e.renderSlot(t.$slots,"default")}}),u=e.defineComponent({name:"VkfCollapse",props:{accordion:{type:Boolean}},setup(n,{slots:o,attrs:c}){return()=>e.h(a.ElCollapse,{accordion:n.accordion,...c},{...o,default:()=>e.h(l,{accordion:n.accordion},{default:()=>{var t;return(t=o.default)==null?void 0:t.call(o)}})})}}),r=u;exports.VkfCollapse=r;exports.default=r;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineComponent as r, inject as p, provide as d, computed as l, renderSlot as i, h as a } from "vue";
|
|
2
|
+
import { collapseContextKey as t, ElCollapse as f } from "element-plus";
|
|
3
|
+
const u = /* @__PURE__ */ r({
|
|
4
|
+
__name: "set-attrs",
|
|
5
|
+
props: {
|
|
6
|
+
accordion: {
|
|
7
|
+
type: Boolean
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
setup(e) {
|
|
11
|
+
const o = e, c = p(t, null);
|
|
12
|
+
return d(t, {
|
|
13
|
+
...c,
|
|
14
|
+
// provider to collapse-item,
|
|
15
|
+
accordion: l(() => o.accordion)
|
|
16
|
+
}), (n, m) => i(n.$slots, "default");
|
|
17
|
+
}
|
|
18
|
+
}), s = r({
|
|
19
|
+
name: "VkfCollapse",
|
|
20
|
+
props: {
|
|
21
|
+
accordion: {
|
|
22
|
+
type: Boolean
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
setup(e, { slots: o, attrs: c }) {
|
|
26
|
+
return () => a(f, {
|
|
27
|
+
accordion: e.accordion,
|
|
28
|
+
...c
|
|
29
|
+
}, {
|
|
30
|
+
...o,
|
|
31
|
+
default: () => a(u, {
|
|
32
|
+
accordion: e.accordion
|
|
33
|
+
}, {
|
|
34
|
+
default: () => {
|
|
35
|
+
var n;
|
|
36
|
+
return (n = o.default) == null ? void 0 : n.call(o);
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}), x = s;
|
|
42
|
+
export {
|
|
43
|
+
x as VkfCollapse,
|
|
44
|
+
x as default
|
|
45
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
accordion: {
|
|
5
|
+
type: BooleanConstructor;
|
|
6
|
+
};
|
|
7
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
10
|
+
accordion: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
};
|
|
13
|
+
}>> & Readonly<{}>, {
|
|
14
|
+
accordion: boolean;
|
|
15
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
6
|
+
accordion: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
};
|
|
9
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
10
|
+
accordion: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
};
|
|
13
|
+
}>> & Readonly<{}>, {
|
|
14
|
+
accordion: boolean;
|
|
15
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
16
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
17
|
+
declare const _default: typeof __VLS_export;
|
|
18
|
+
export default _default;
|
|
19
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
20
|
+
new (): {
|
|
21
|
+
$slots: S;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),o=require("element-plus"),d=require("@vunk/form/shared/element-plus"),c={...o.collapseItemProps},f={},C=Object.freeze(Object.defineProperty({__proto__:null,emits:f,props:c},Symbol.toStringTag,{value:"Module"})),i=Symbol("vkfCollapseItemContextKey");function I(l){const t=e.inject(o.collapseContextKey,null),s=e.reactive({activeNames:t==null?void 0:t.activeNames,handleItemClick:t==null?void 0:t.handleItemClick,name:e.computed(()=>e.unref(l.name)),accordion:t==null?void 0:t.accordion});e.provide(i,s)}function _(){return e.inject(i,null)}const u=e.defineComponent({name:"VkfCollapseItem",__name:"index",props:c,setup(l){const t=l,s=d.createCollapseItemBindProps(t),{namespace:m}=o.useNamespace("collapse"),r=o.useIdInjection(),p=`${m.value}-id-${r.prefix}-${r.current++}`,a=e.computed(()=>t.name??p);return I({name:a}),(n,k)=>(e.openBlock(),e.createBlock(e.unref(o.ElCollapseItem),e.mergeProps(e.unref(s),{name:a.value,title:n.title}),e.createSlots({default:e.withCtx(()=>[e.renderSlot(n.$slots,"default")]),_:2},[n.$slots.title?{name:"title",fn:e.withCtx(()=>[e.renderSlot(n.$slots,"title")]),key:"0"}:void 0]),1040,["name","title"]))}}),v=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.VkfCollapseItem=u;exports._VkfCollapseItemCtx=C;exports.__VkfCollapseItem=v;exports.default=u;exports.useCollapseItemContext=_;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { inject as m, reactive as I, computed as i, unref as l, provide as C, defineComponent as _, openBlock as k, createBlock as v, mergeProps as y, createSlots as b, withCtx as r, renderSlot as c } from "vue";
|
|
2
|
+
import { collapseItemProps as j, collapseContextKey as S, useNamespace as P, useIdInjection as $, ElCollapseItem as g } from "element-plus";
|
|
3
|
+
import { createCollapseItemBindProps as h } from "@vunk/form/shared/element-plus";
|
|
4
|
+
const p = {
|
|
5
|
+
...j
|
|
6
|
+
}, O = {}, z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
7
|
+
__proto__: null,
|
|
8
|
+
emits: O,
|
|
9
|
+
props: p
|
|
10
|
+
}, Symbol.toStringTag, { value: "Module" })), u = Symbol("vkfCollapseItemContextKey");
|
|
11
|
+
function V(o) {
|
|
12
|
+
const e = m(S, null), n = I({
|
|
13
|
+
activeNames: e == null ? void 0 : e.activeNames,
|
|
14
|
+
handleItemClick: e == null ? void 0 : e.handleItemClick,
|
|
15
|
+
name: i(() => l(o.name)),
|
|
16
|
+
accordion: e == null ? void 0 : e.accordion
|
|
17
|
+
});
|
|
18
|
+
C(u, n);
|
|
19
|
+
}
|
|
20
|
+
function M() {
|
|
21
|
+
return m(u, null);
|
|
22
|
+
}
|
|
23
|
+
const T = /* @__PURE__ */ _({
|
|
24
|
+
name: "VkfCollapseItem",
|
|
25
|
+
__name: "index",
|
|
26
|
+
props: p,
|
|
27
|
+
setup(o) {
|
|
28
|
+
const e = o, n = h(e), { namespace: d } = P("collapse"), a = $(), f = `${d.value}-id-${a.prefix}-${a.current++}`, s = i(() => e.name ?? f);
|
|
29
|
+
return V({ name: s }), (t, x) => (k(), v(l(g), y(l(n), {
|
|
30
|
+
name: s.value,
|
|
31
|
+
title: t.title
|
|
32
|
+
}), b({
|
|
33
|
+
default: r(() => [
|
|
34
|
+
c(t.$slots, "default")
|
|
35
|
+
]),
|
|
36
|
+
_: 2
|
|
37
|
+
}, [
|
|
38
|
+
t.$slots.title ? {
|
|
39
|
+
name: "title",
|
|
40
|
+
fn: r(() => [
|
|
41
|
+
c(t.$slots, "title")
|
|
42
|
+
]),
|
|
43
|
+
key: "0"
|
|
44
|
+
} : void 0
|
|
45
|
+
]), 1040, ["name", "title"]));
|
|
46
|
+
}
|
|
47
|
+
}), w = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
48
|
+
__proto__: null
|
|
49
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
50
|
+
export {
|
|
51
|
+
T as VkfCollapseItem,
|
|
52
|
+
z as _VkfCollapseItemCtx,
|
|
53
|
+
w as __VkfCollapseItem,
|
|
54
|
+
T as default,
|
|
55
|
+
M as useCollapseItemContext
|
|
56
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const props: {
|
|
2
|
+
title: import("element-plus/es/utils/index.mjs").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
3
|
+
name: import("element-plus/es/utils/index.mjs").EpPropFinalized<(new (...args: any[]) => string | number) | (() => import("element-plus").CollapseActiveName) | (((new (...args: any[]) => string | number) | (() => import("element-plus").CollapseActiveName)) | null)[], unknown, unknown, undefined, boolean>;
|
|
4
|
+
icon: import("element-plus/es/utils/index.mjs").EpPropFinalized<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | (((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component)) | null)[], unknown, unknown, import("vue").DefineComponent<{}, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, boolean>;
|
|
5
|
+
disabled: BooleanConstructor;
|
|
6
|
+
};
|
|
7
|
+
export declare const emits: {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare var __VLS_9: {}, __VLS_11: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
title?: (props: typeof __VLS_9) => any;
|
|
4
|
+
} & {
|
|
5
|
+
default?: (props: typeof __VLS_11) => any;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
|
+
title: import("element-plus/es/utils/index.mjs").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
9
|
+
name: import("element-plus/es/utils/index.mjs").EpPropFinalized<(new (...args: any[]) => string | number) | (() => import("element-plus").CollapseActiveName) | (((new (...args: any[]) => string | number) | (() => import("element-plus").CollapseActiveName)) | null)[], unknown, unknown, undefined, boolean>;
|
|
10
|
+
icon: import("element-plus/es/utils/index.mjs").EpPropFinalized<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | (((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component)) | null)[], unknown, unknown, import("vue").DefineComponent<{}, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, boolean>;
|
|
11
|
+
disabled: BooleanConstructor;
|
|
12
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
13
|
+
title: import("element-plus/es/utils/index.mjs").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;
|
|
14
|
+
name: import("element-plus/es/utils/index.mjs").EpPropFinalized<(new (...args: any[]) => string | number) | (() => import("element-plus").CollapseActiveName) | (((new (...args: any[]) => string | number) | (() => import("element-plus").CollapseActiveName)) | null)[], unknown, unknown, undefined, boolean>;
|
|
15
|
+
icon: import("element-plus/es/utils/index.mjs").EpPropFinalized<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | (((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component)) | null)[], unknown, unknown, import("vue").DefineComponent<{}, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, boolean>;
|
|
16
|
+
disabled: BooleanConstructor;
|
|
17
|
+
}>> & Readonly<{}>, {
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
icon: import("element-plus/es/utils/index.mjs").EpPropMergeType<(new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | ((new (...args: any[]) => (string | import("vue").Component) & {}) | (() => string | import("vue").Component) | null)[], unknown, unknown>;
|
|
20
|
+
name: import("element-plus/es/utils/index.mjs").EpPropMergeType<(new (...args: any[]) => string | number) | (() => import("element-plus").CollapseActiveName) | ((new (...args: any[]) => string | number) | (() => import("element-plus").CollapseActiveName) | null)[], unknown, unknown>;
|
|
21
|
+
title: string;
|
|
22
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
23
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
export default _default;
|
|
26
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
27
|
+
new (): {
|
|
28
|
+
$slots: S;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MaybeRef } from 'vue';
|
|
2
|
+
export interface CollapseItemContext {
|
|
3
|
+
/** Unwrapped value of ElCollapse's activeNames: a string in accordion mode,
|
|
4
|
+
* an array otherwise. Mutating it drives the native collapse. */
|
|
5
|
+
activeNames: (string | number)[];
|
|
6
|
+
handleItemClick: (name: string | number) => void;
|
|
7
|
+
name: string | number;
|
|
8
|
+
accordion?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function initCollapseItemContext(props: {
|
|
11
|
+
name: MaybeRef<string | number>;
|
|
12
|
+
}): void;
|
|
13
|
+
export declare function useCollapseItemContext(): CollapseItemContext | null;
|
|
@@ -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 d=require("element-plus"),_=require("@vunk/core/shared/utils-vue"),R=require("@vunk/core/shared/utils-function"),t=require("vue"),C=require("@vunk/form/components/form-item-renderer"),P=require("@vunk/form/shared/element-plus"),k=require("@vunk/core/shared/helper"),w=require("@vunk/form/components/templates-default"),E=require("@vunk/form/components/templates-layout"),h=require("@vunk/core/shared/utils-object"),q=require("@vunk/form/shared/form"),O=require("@vunk/form/components/renderer-data"),I=require("@vunk/shared/object"),T=require("@vunk/form/components/forms-provider"),j=require("@vunk/shared/function"),g=require("@vunk/form/composables/form-mitt"),D=require("../_plugin-vue_export-helper-BHFhmbuH.js"),y={...d.formProps,labelPosition:{type:String,default:void 0},data:{type:Object,default:()=>({})},formItems:{type:Array,default:()=>[]},readonly:{type:Boolean},elRef:{type:Function,default:()=>R.NOOP},layout:{type:Boolean,default:!1},rowSource:{type:Object,default:()=>({})},colSource:{type:Object,default:()=>({})},segmentAttrs:{type:Object,default:()=>({})}},L=_.bindPropsFactory(y),F={...d.formEmits,setData:e=>e,validate:null,submit:null},$=_.onEmitsFactory(F),M=Object.freeze(Object.defineProperty({__proto__:null,createBindProps:L,createOnEmits:$,emits:F,props:y},Symbol.toStringTag,{value:"Module"})),N=e=>24-e.templateSlots.reduce((o,r)=>{if(!r.span)throw new Error("ElColSource span is required");return o+r.span},0),A=(e,o={})=>{const r=e.span??o.span;if(r==null)throw new Error("genColItem ElColSource span is required");return{...o,templateType:"ElCol",span:r,templateSlots:[h.pickObject(e,{excludes:["span"]})]}},B=(e,o={})=>({...o,templateType:"ElRow",templateSlots:e?[e]:[]}),z=t.defineComponent({__name:"provide-label-postion",props:{labelPosition:null},setup(e){const o=e,r={addField:j.noop},n=t.inject(d.formContextKey,r),f=t.computed(()=>o.labelPosition??n.labelPosition);return t.provide(d.formContextKey,t.reactive({...n===r?r:t.toRefs(n),labelPosition:f})),(s,m)=>t.renderSlot(s.$slots,"default")}});function H(e){const o=t.shallowRef(),r=n=>{if(n){const f=n.validate;n.validate=s=>{const m=f.call(n);return m&&typeof m.then=="function"?m.then(u=>{var i;return(i=e.onAfterValidate)==null||i.call(e,!0),s==null||s(!0),u},u=>{var i;throw(i=e.onAfterValidate)==null||i.call(e,!1,u),s==null||s(!1,u),u}):m}}o.value=n,e.elRef(n)};return t.provide("elFormRef",o),{setFormRef:r,formRef:o}}const K=t.defineComponent({name:"VkfForm",components:{VkfRendererData:O.VkfRendererData,ElForm:d.ElForm,VkfFormItemRenderer:C.VkfFormItemRenderer,VkfTemplatesDefault:w.VkfTemplatesDefault,VkfTemplatesLayout:E.VkfTemplatesLayout,VkfFormsSegment:T.VkfFormsSegment,ProvideLabelPostion:z},props:y,emits:F,setup(e,{emit:o}){const r=P.createFormBindProps(e,["model","labelPosition"]),n=P.createFormOnEmits(o),f=g.initFormMitt(),{setFormRef:s}=H({elRef:e.elRef,onAfterValidate:(l,a)=>{f.emit("afterValidate",{isValid:l,invalidFields:a})}}),m=t.getCurrentInstance();t.provide("vkfFormVm",m);const u=t.computed(()=>e.layout?e.formItems.reduce((l,a)=>{var S;const c=l.findLast(b=>b.templateType==="ElRow"),p=a.span??e.colSource.span;if(!p)return l.push(a),l;if(!((S=a.templateLayout)!=null&&S.allowEmpty)&&Reflect.has(a,"templateIf")&&!q.genTemplateIfFunc(a.templateIf)(e.data))return l;const V=A(a,I.pickObject({...e.colSource,...a.templateLayout},{excludes:["allowEmpty"]}));return!c||N(c)<p?l.push(B(V,e.rowSource)):c.templateSlots.push(V),l},[]):e.formItems),i=l=>{l.preventDefault(),o("submit",l)};return{formProps:r,formEmits:n,getValue:k.getValue,setFormRef:s,computed:t.computed,rendererSource:u,handleSubmit:i}}});function x(e,o,r,n,f,s){const m=t.resolveComponent("VkfFormsSegment"),u=t.resolveComponent("VkfTemplatesDefault"),i=t.resolveComponent("VkfTemplatesLayout"),l=t.resolveComponent("VkfFormItemRenderer"),a=t.resolveComponent("VkfRendererData"),c=t.resolveComponent("ProvideLabelPostion"),p=t.resolveComponent("ElForm");return t.openBlock(),t.createBlock(p,t.mergeProps(e.formProps,{ref:e.setFormRef,class:{"is-readonly":e.readonly},model:e.model||e.data},t.toHandlers(e.formEmits),{onSubmit:e.handleSubmit}),{default:t.withCtx(()=>[t.createVNode(c,{"label-position":e.labelPosition},{default:t.withCtx(()=>[t.createVNode(a,{data:e.data,onSetData:o[0]||(o[0]=V=>e.$emit("setData",V))},{default:t.withCtx(()=>[t.createVNode(m,t.mergeProps({data:e.data},e.segmentAttrs),null,16,["data"]),t.createVNode(l,{source:e.rendererSource},{placeholder:t.withCtx(()=>[t.createVNode(u),t.createVNode(i)]),default:t.withCtx(()=>[t.renderSlot(e.$slots,"rendererTemplate")]),_:3},8,["source"]),t.renderSlot(e.$slots,"default")]),_:3},8,["data"])]),_:3},8,["label-position"])]),_:3},16,["class","model","onSubmit"])}const v=D._export_sfc(K,[["render",x]]),G=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));Object.defineProperty(exports,"useFormMitt",{enumerable:!0,get:()=>g.useFormMitt});exports.VkfForm=v;exports._VkfFormCtx=M;exports.__VkfForm=G;exports.default=v;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { formProps as
|
|
2
|
-
import { bindPropsFactory as
|
|
3
|
-
import { NOOP as
|
|
4
|
-
import { defineComponent as
|
|
5
|
-
import { VkfFormItemRenderer as
|
|
1
|
+
import { formProps as v, formEmits as h, formContextKey as E, ElForm as O } from "element-plus";
|
|
2
|
+
import { bindPropsFactory as I, onEmitsFactory as C } from "@vunk/core/shared/utils-vue";
|
|
3
|
+
import { NOOP as T } from "@vunk/core/shared/utils-function";
|
|
4
|
+
import { defineComponent as w, inject as j, computed as F, provide as V, reactive as D, toRefs as L, renderSlot as b, shallowRef as $, getCurrentInstance as A, resolveComponent as i, openBlock as B, createBlock as M, mergeProps as k, toHandlers as q, withCtx as c, createVNode as p } from "vue";
|
|
5
|
+
import { VkfFormItemRenderer as z } from "@vunk/form/components/form-item-renderer";
|
|
6
6
|
import { createFormBindProps as N, createFormOnEmits as H } from "@vunk/form/shared/element-plus";
|
|
7
7
|
import { getValue as K } from "@vunk/core/shared/helper";
|
|
8
8
|
import { VkfTemplatesDefault as G } from "@vunk/form/components/templates-default";
|
|
@@ -13,9 +13,11 @@ import { VkfRendererData as W } from "@vunk/form/components/renderer-data";
|
|
|
13
13
|
import { pickObject as X } from "@vunk/shared/object";
|
|
14
14
|
import { VkfFormsSegment as Y } from "@vunk/form/components/forms-provider";
|
|
15
15
|
import { noop as Z } from "@vunk/shared/function";
|
|
16
|
-
import {
|
|
16
|
+
import { initFormMitt as x } from "@vunk/form/composables/form-mitt";
|
|
17
|
+
import { useFormMitt as je } from "@vunk/form/composables/form-mitt";
|
|
18
|
+
import { _ as ee } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
17
19
|
const _ = {
|
|
18
|
-
...
|
|
20
|
+
...v,
|
|
19
21
|
labelPosition: {
|
|
20
22
|
type: String,
|
|
21
23
|
default: void 0
|
|
@@ -33,7 +35,7 @@ const _ = {
|
|
|
33
35
|
},
|
|
34
36
|
elRef: {
|
|
35
37
|
type: Function,
|
|
36
|
-
default: () =>
|
|
38
|
+
default: () => T
|
|
37
39
|
},
|
|
38
40
|
/**
|
|
39
41
|
* 是否开启布局模式
|
|
@@ -67,133 +69,165 @@ const _ = {
|
|
|
67
69
|
type: Object,
|
|
68
70
|
default: () => ({})
|
|
69
71
|
}
|
|
70
|
-
},
|
|
71
|
-
...
|
|
72
|
+
}, te = I(_), P = {
|
|
73
|
+
...h,
|
|
72
74
|
setData: (e) => e,
|
|
73
75
|
validate: null,
|
|
74
76
|
submit: null
|
|
75
|
-
},
|
|
77
|
+
}, oe = C(P), he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
76
78
|
__proto__: null,
|
|
77
|
-
createBindProps:
|
|
78
|
-
createOnEmits:
|
|
79
|
-
emits:
|
|
79
|
+
createBindProps: te,
|
|
80
|
+
createOnEmits: oe,
|
|
81
|
+
emits: P,
|
|
80
82
|
props: _
|
|
81
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
82
|
-
if (!
|
|
83
|
+
}, Symbol.toStringTag, { value: "Module" })), re = (e) => 24 - e.templateSlots.reduce((t, o) => {
|
|
84
|
+
if (!o.span)
|
|
83
85
|
throw new Error("ElColSource span is required");
|
|
84
|
-
return t +
|
|
85
|
-
}, 0),
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
86
|
+
return t + o.span;
|
|
87
|
+
}, 0), ne = (e, t = {}) => {
|
|
88
|
+
const o = e.span ?? t.span;
|
|
89
|
+
if (o == null)
|
|
88
90
|
throw new Error("genColItem ElColSource span is required");
|
|
89
91
|
return {
|
|
90
92
|
...t,
|
|
91
93
|
templateType: "ElCol",
|
|
92
|
-
span:
|
|
94
|
+
span: o,
|
|
93
95
|
templateSlots: [
|
|
94
96
|
Q(e, {
|
|
95
97
|
excludes: ["span"]
|
|
96
98
|
})
|
|
97
99
|
]
|
|
98
100
|
};
|
|
99
|
-
},
|
|
101
|
+
}, ae = (e, t = {}) => ({
|
|
100
102
|
...t,
|
|
101
103
|
templateType: "ElRow",
|
|
102
104
|
templateSlots: e ? [
|
|
103
105
|
e
|
|
104
106
|
] : []
|
|
105
|
-
}),
|
|
107
|
+
}), me = /* @__PURE__ */ w({
|
|
106
108
|
__name: "provide-label-postion",
|
|
107
109
|
props: {
|
|
108
110
|
labelPosition: null
|
|
109
111
|
},
|
|
110
112
|
setup(e) {
|
|
111
|
-
const t = e,
|
|
113
|
+
const t = e, o = {
|
|
112
114
|
addField: Z
|
|
113
|
-
},
|
|
114
|
-
return
|
|
115
|
-
|
|
115
|
+
}, r = j(E, o), u = F(() => t.labelPosition ?? r.labelPosition);
|
|
116
|
+
return V(
|
|
117
|
+
E,
|
|
116
118
|
D({
|
|
117
|
-
...
|
|
118
|
-
labelPosition:
|
|
119
|
+
...r === o ? o : L(r),
|
|
120
|
+
labelPosition: u
|
|
119
121
|
})
|
|
120
|
-
), (
|
|
122
|
+
), (a, l) => b(a.$slots, "default");
|
|
121
123
|
}
|
|
122
|
-
})
|
|
124
|
+
});
|
|
125
|
+
function le(e) {
|
|
126
|
+
const t = $(), o = (r) => {
|
|
127
|
+
if (r) {
|
|
128
|
+
const u = r.validate;
|
|
129
|
+
r.validate = (a) => {
|
|
130
|
+
const l = u.call(r);
|
|
131
|
+
return l && typeof l.then == "function" ? l.then(
|
|
132
|
+
(s) => {
|
|
133
|
+
var f;
|
|
134
|
+
return (f = e.onAfterValidate) == null || f.call(e, !0), a == null || a(!0), s;
|
|
135
|
+
},
|
|
136
|
+
(s) => {
|
|
137
|
+
var f;
|
|
138
|
+
throw (f = e.onAfterValidate) == null || f.call(e, !1, s), a == null || a(!1, s), s;
|
|
139
|
+
}
|
|
140
|
+
) : l;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
t.value = r, e.elRef(r);
|
|
144
|
+
};
|
|
145
|
+
return V("elFormRef", t), {
|
|
146
|
+
setFormRef: o,
|
|
147
|
+
formRef: t
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const se = w({
|
|
123
151
|
name: "VkfForm",
|
|
124
152
|
components: {
|
|
125
153
|
VkfRendererData: W,
|
|
126
|
-
ElForm:
|
|
127
|
-
VkfFormItemRenderer:
|
|
154
|
+
ElForm: O,
|
|
155
|
+
VkfFormItemRenderer: z,
|
|
128
156
|
VkfTemplatesDefault: G,
|
|
129
157
|
VkfTemplatesLayout: J,
|
|
130
158
|
VkfFormsSegment: Y,
|
|
131
|
-
ProvideLabelPostion:
|
|
159
|
+
ProvideLabelPostion: me
|
|
132
160
|
},
|
|
133
161
|
props: _,
|
|
134
|
-
emits:
|
|
162
|
+
emits: P,
|
|
135
163
|
setup(e, { emit: t }) {
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
164
|
+
const o = N(e, ["model", "labelPosition"]), r = H(t), u = x(), { setFormRef: a } = le({
|
|
165
|
+
elRef: e.elRef,
|
|
166
|
+
onAfterValidate: (n, m) => {
|
|
167
|
+
u.emit("afterValidate", {
|
|
168
|
+
isValid: n,
|
|
169
|
+
invalidFields: m
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}), l = A();
|
|
173
|
+
V("vkfFormVm", l);
|
|
174
|
+
const s = F(() => e.layout ? e.formItems.reduce((n, m) => {
|
|
175
|
+
var R;
|
|
176
|
+
const d = n.findLast((g) => g.templateType === "ElRow"), y = m.span ?? e.colSource.span;
|
|
177
|
+
if (!y)
|
|
178
|
+
return n.push(m), n;
|
|
179
|
+
if (!((R = m.templateLayout) != null && R.allowEmpty) && Reflect.has(m, "templateIf") && !U(m.templateIf)(e.data))
|
|
180
|
+
return n;
|
|
181
|
+
const S = ne(m, X({
|
|
148
182
|
...e.colSource,
|
|
149
|
-
...
|
|
183
|
+
...m.templateLayout
|
|
150
184
|
}, {
|
|
151
185
|
excludes: ["allowEmpty"]
|
|
152
186
|
}));
|
|
153
|
-
return !
|
|
187
|
+
return !d || re(d) < y ? n.push(ae(S, e.rowSource)) : d.templateSlots.push(S), n;
|
|
154
188
|
}, []) : e.formItems);
|
|
155
189
|
return {
|
|
156
|
-
formProps:
|
|
157
|
-
formEmits:
|
|
190
|
+
formProps: o,
|
|
191
|
+
formEmits: r,
|
|
158
192
|
getValue: K,
|
|
159
|
-
|
|
160
|
-
computed:
|
|
161
|
-
rendererSource:
|
|
162
|
-
handleSubmit: (
|
|
163
|
-
|
|
193
|
+
setFormRef: a,
|
|
194
|
+
computed: F,
|
|
195
|
+
rendererSource: s,
|
|
196
|
+
handleSubmit: (n) => {
|
|
197
|
+
n.preventDefault(), t("submit", n);
|
|
164
198
|
}
|
|
165
199
|
};
|
|
166
200
|
}
|
|
167
201
|
});
|
|
168
|
-
function
|
|
169
|
-
const
|
|
170
|
-
return
|
|
171
|
-
ref: e.
|
|
202
|
+
function fe(e, t, o, r, u, a) {
|
|
203
|
+
const l = i("VkfFormsSegment"), s = i("VkfTemplatesDefault"), f = i("VkfTemplatesLayout"), n = i("VkfFormItemRenderer"), m = i("VkfRendererData"), d = i("ProvideLabelPostion"), y = i("ElForm");
|
|
204
|
+
return B(), M(y, k(e.formProps, {
|
|
205
|
+
ref: e.setFormRef,
|
|
172
206
|
class: {
|
|
173
207
|
"is-readonly": e.readonly
|
|
174
208
|
},
|
|
175
209
|
model: e.model || e.data
|
|
176
|
-
},
|
|
177
|
-
default:
|
|
178
|
-
|
|
179
|
-
default:
|
|
180
|
-
|
|
210
|
+
}, q(e.formEmits), { onSubmit: e.handleSubmit }), {
|
|
211
|
+
default: c(() => [
|
|
212
|
+
p(d, { "label-position": e.labelPosition }, {
|
|
213
|
+
default: c(() => [
|
|
214
|
+
p(m, {
|
|
181
215
|
data: e.data,
|
|
182
|
-
onSetData: t[0] || (t[0] = (
|
|
216
|
+
onSetData: t[0] || (t[0] = (S) => e.$emit("setData", S))
|
|
183
217
|
}, {
|
|
184
|
-
default:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
placeholder:
|
|
188
|
-
s
|
|
189
|
-
|
|
218
|
+
default: c(() => [
|
|
219
|
+
p(l, k({ data: e.data }, e.segmentAttrs), null, 16, ["data"]),
|
|
220
|
+
p(n, { source: e.rendererSource }, {
|
|
221
|
+
placeholder: c(() => [
|
|
222
|
+
p(s),
|
|
223
|
+
p(f)
|
|
190
224
|
]),
|
|
191
|
-
default:
|
|
192
|
-
|
|
225
|
+
default: c(() => [
|
|
226
|
+
b(e.$slots, "rendererTemplate")
|
|
193
227
|
]),
|
|
194
228
|
_: 3
|
|
195
229
|
}, 8, ["source"]),
|
|
196
|
-
|
|
230
|
+
b(e.$slots, "default")
|
|
197
231
|
]),
|
|
198
232
|
_: 3
|
|
199
233
|
}, 8, ["data"])
|
|
@@ -204,12 +238,13 @@ function se(e, t, r, l, m, i) {
|
|
|
204
238
|
_: 3
|
|
205
239
|
}, 16, ["class", "model", "onSubmit"]);
|
|
206
240
|
}
|
|
207
|
-
const
|
|
241
|
+
const Oe = /* @__PURE__ */ ee(se, [["render", fe]]), Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
208
242
|
__proto__: null
|
|
209
243
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
210
244
|
export {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
245
|
+
Oe as VkfForm,
|
|
246
|
+
he as _VkfFormCtx,
|
|
247
|
+
Ie as __VkfForm,
|
|
248
|
+
Oe as default,
|
|
249
|
+
je as useFormMitt
|
|
215
250
|
};
|
|
@@ -81,7 +81,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
81
81
|
}>;
|
|
82
82
|
formEmits: {};
|
|
83
83
|
getValue: (obj: any, k: any, intoUndefined?: import("@vunk/core").IntoUndefined, safe?: boolean) => any;
|
|
84
|
-
|
|
84
|
+
setFormRef: (e: any) => void;
|
|
85
85
|
computed: typeof import("@vue/reactivity").computed;
|
|
86
86
|
rendererSource: import("vue").ComputedRef<any>;
|
|
87
87
|
handleSubmit: (e: Event) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __VkfTemplatesDefault } from '@vunk/form/components/templates-default';
|
|
2
2
|
import { __VkfTemplatesLayout } from '@vunk/form/components/templates-layout';
|
|
3
3
|
import { VueComponentPropsType } from '@vunk/shared';
|
|
4
|
-
import { ElCol } from 'element-plus';
|
|
4
|
+
import { ElCol, FormItemProp } from 'element-plus';
|
|
5
|
+
export type OnValidate = (prop: FormItemProp, isValid: boolean, message: string) => any;
|
|
5
6
|
export type LayoutProps = {
|
|
6
7
|
/**
|
|
7
8
|
* 如果开启 props.layout,那么
|