@vunk/form 1.4.11 → 2.0.0
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/form/index.cjs +34 -6
- package/components/form/index.mjs +35 -7
- package/components/form/src/ctx.d.ts +8 -1
- package/components/form/src/index.vue.d.ts +31 -0
- package/components/form-item-renderer/index.cjs +39 -22
- package/components/form-item-renderer/index.d.ts +0 -1
- package/components/form-item-renderer/index.mjs +41 -22
- package/components/form-item-renderer/src/index.vue.d.ts +4 -4
- package/components/form-item-renderer/src/types.d.ts +0 -1
- package/components/form-item-renderer-template/index.cjs +2 -2
- package/components/form-item-renderer-template/index.mjs +3 -3
- package/components/form-item-renderer-template/src/types.d.ts +44 -0
- package/components/input-collection/index.cjs +56 -40
- package/components/input-collection/index.mjs +57 -41
- package/components/input-collection/src/ctx.d.ts +7 -0
- package/components/input-collection/src/index.vue.d.ts +20 -0
- package/components/input-number/src/ctx.d.ts +1 -1
- package/components/input-number/src/index.vue.d.ts +2 -2
- package/components/renderer-data/index.cjs +41 -0
- package/components/renderer-data/index.d.ts +4 -0
- package/components/renderer-data/index.mjs +35 -0
- package/components/{templates-mapbox → renderer-data}/src/ctx.d.ts +3 -2
- package/components/renderer-data/src/index.vue.d.ts +20 -0
- package/components/renderer-data/src/types.d.ts +1 -0
- package/components/select/index.css +5 -0
- package/components/slider/src/index.vue.d.ts +1 -1
- package/components/template-instances-provider/index.cjs +16 -6
- package/components/template-instances-provider/index.mjs +17 -7
- package/components/template-instances-provider/src/index.vue.d.ts +14 -2
- package/components/templates-default/index.cjs +40 -146
- package/components/templates-default/index.mjs +41 -147
- package/components/templates-default/src/index.vue.d.ts +0 -2
- package/components/templates-element-plus/index.cjs +8 -8
- package/components/templates-element-plus/index.mjs +9 -9
- package/components/templates-esri/index.cjs +5 -5
- package/components/templates-esri/index.mjs +6 -6
- package/components/templates-variant/index.cjs +7 -7
- package/components/templates-variant/index.mjs +8 -8
- package/composables/index.cjs +46 -0
- package/composables/index.d.ts +3 -0
- package/composables/index.mjs +44 -2
- package/composables/useComputedReadonly.d.ts +4 -0
- package/composables/useForm.d.ts +1 -4
- package/composables/useRendererData.d.ts +13 -0
- package/composables/useTemplateInstances.d.ts +3 -0
- package/index.css +5 -9
- package/package.json +6 -19
- package/components/form-item-renderer/src/symbols.d.ts +0 -3
- package/components/geoinput/index.cjs +0 -95
- package/components/geoinput/index.d.ts +0 -4
- package/components/geoinput/index.mjs +0 -89
- package/components/geoinput/src/ctx.d.ts +0 -240
- package/components/geoinput/src/index.vue.d.ts +0 -546
- package/components/geoinput/src/types.d.ts +0 -12
- package/components/geoinput-read/index.cjs +0 -304
- package/components/geoinput-read/index.css +0 -8
- package/components/geoinput-read/index.d.ts +0 -5
- package/components/geoinput-read/index.mjs +0 -297
- package/components/geoinput-read/src/append.vue.d.ts +0 -341
- package/components/geoinput-read/src/core.vue.d.ts +0 -667
- package/components/geoinput-read/src/ctx.d.ts +0 -211
- package/components/geoinput-read/src/index.vue.d.ts +0 -1219
- package/components/geoinput-read/src/types.d.ts +0 -3
- package/components/templates-mapbox/index.cjs +0 -65
- package/components/templates-mapbox/index.d.ts +0 -4
- package/components/templates-mapbox/index.mjs +0 -59
- package/components/templates-mapbox/src/index.vue.d.ts +0 -43
- package/components/templates-mapbox/src/types.d.ts +0 -3
- package/shared/const/index.d.ts +0 -4
- package/shared/element-plus/ctx.d.ts +0 -26
- package/shared/element-plus/index.d.ts +0 -3
- package/shared/element-plus/instances.d.ts +0 -202
- package/shared/element-plus/version.d.ts +0 -1
- package/shared/form/index.d.ts +0 -18
- package/shared/helper/index.d.ts +0 -4
- package/shared/index.d.ts +0 -2
- package/shared/infer-prop/index.d.ts +0 -17
- package/shared/progress-it/index.d.ts +0 -16
- package/shared/rules/index.d.ts +0 -35
- package/shared/types/form/checkbox.d.ts +0 -13
- package/shared/types/form/index.d.ts +0 -2
- package/shared/types/form/radio.d.ts +0 -8
- package/shared/types/index.d.ts +0 -2
- package/shared/types/source/index.d.ts +0 -21
- package/shared/types/source-manager/index.d.ts +0 -6
- package/shared/upload/index.d.ts +0 -7
|
@@ -13,6 +13,8 @@ var templatesDefault = require('@vunk/form/components/templates-default');
|
|
|
13
13
|
var templatesLayout = require('@vunk/form/components/templates-layout');
|
|
14
14
|
var utilsObject = require('@vunk/core/shared/utils-object');
|
|
15
15
|
var form = require('@vunk/form/shared/form');
|
|
16
|
+
var templateInstancesProvider = require('@vunk/form/components/template-instances-provider');
|
|
17
|
+
var rendererData = require('@vunk/form/components/renderer-data');
|
|
16
18
|
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
17
19
|
|
|
18
20
|
const props = {
|
|
@@ -56,6 +58,13 @@ const props = {
|
|
|
56
58
|
colSource: {
|
|
57
59
|
type: Object,
|
|
58
60
|
default: () => ({})
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* 是否继承父级模板
|
|
64
|
+
*/
|
|
65
|
+
inheritTemplates: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false
|
|
59
68
|
}
|
|
60
69
|
};
|
|
61
70
|
const createBindProps = utilsVue.bindPropsFactory(props);
|
|
@@ -112,6 +121,8 @@ const genRowItem = (defaultItem, options = {}) => {
|
|
|
112
121
|
var _sfc_main = vue.defineComponent({
|
|
113
122
|
name: "VkfForm",
|
|
114
123
|
components: {
|
|
124
|
+
VkfTemplateInstancesProvider: templateInstancesProvider.VkfTemplateInstancesProvider,
|
|
125
|
+
VkfRendererData: rendererData.VkfRendererData,
|
|
115
126
|
ElForm: elementPlus.ElForm,
|
|
116
127
|
VkfFormItemRenderer: formItemRenderer.VkfFormItemRenderer,
|
|
117
128
|
VkfTemplatesDefault: templatesDefault.VkfTemplatesDefault,
|
|
@@ -177,6 +188,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
177
188
|
const _component_VkfTemplatesDefault = vue.resolveComponent("VkfTemplatesDefault");
|
|
178
189
|
const _component_VkfTemplatesLayout = vue.resolveComponent("VkfTemplatesLayout");
|
|
179
190
|
const _component_VkfFormItemRenderer = vue.resolveComponent("VkfFormItemRenderer");
|
|
191
|
+
const _component_VkfRendererData = vue.resolveComponent("VkfRendererData");
|
|
192
|
+
const _component_VkfTemplateInstancesProvider = vue.resolveComponent("VkfTemplateInstancesProvider");
|
|
180
193
|
const _component_ElForm = vue.resolveComponent("ElForm");
|
|
181
194
|
return vue.openBlock(), vue.createBlock(_component_ElForm, vue.mergeProps(_ctx.formProps, {
|
|
182
195
|
ref: _ctx.getRef,
|
|
@@ -186,18 +199,33 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
186
199
|
model: _ctx.model || _ctx.data
|
|
187
200
|
}, vue.toHandlers(_ctx.formEmits), { onSubmit: _ctx.handleSubmit }), {
|
|
188
201
|
default: vue.withCtx(() => [
|
|
189
|
-
vue.createVNode(
|
|
202
|
+
vue.createVNode(_component_VkfTemplateInstancesProvider, { "inherit-templates": _ctx.inheritTemplates }, {
|
|
190
203
|
default: vue.withCtx(() => [
|
|
191
|
-
vue.
|
|
204
|
+
!_ctx.inheritTemplates ? (vue.openBlock(), vue.createElementBlock(
|
|
205
|
+
vue.Fragment,
|
|
206
|
+
{ key: 0 },
|
|
207
|
+
[
|
|
208
|
+
vue.createVNode(_component_VkfTemplatesDefault),
|
|
209
|
+
vue.createVNode(_component_VkfTemplatesLayout),
|
|
210
|
+
vue.renderSlot(_ctx.$slots, "rendererTemplate")
|
|
211
|
+
],
|
|
212
|
+
64
|
|
213
|
+
/* STABLE_FRAGMENT */
|
|
214
|
+
)) : vue.createCommentVNode("v-if", true),
|
|
215
|
+
vue.createVNode(_component_VkfRendererData, {
|
|
192
216
|
data: _ctx.data,
|
|
193
217
|
onSetData: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("setData", $event))
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
|
|
218
|
+
}, {
|
|
219
|
+
default: vue.withCtx(() => [
|
|
220
|
+
vue.createVNode(_component_VkfFormItemRenderer, { source: _ctx.rendererSource }, null, 8, ["source"])
|
|
221
|
+
]),
|
|
222
|
+
_: 1
|
|
223
|
+
/* STABLE */
|
|
224
|
+
}, 8, ["data"])
|
|
197
225
|
]),
|
|
198
226
|
_: 3
|
|
199
227
|
/* FORWARDED */
|
|
200
|
-
}, 8, ["
|
|
228
|
+
}, 8, ["inherit-templates"]),
|
|
201
229
|
vue.renderSlot(_ctx.$slots, "default")
|
|
202
230
|
]),
|
|
203
231
|
_: 3
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formProps, formEmits, ElForm } from 'element-plus';
|
|
2
2
|
import { bindPropsFactory, onEmitsFactory } from '@vunk/core/shared/utils-vue';
|
|
3
3
|
import { NOOP } from '@vunk/core/shared/utils-function';
|
|
4
|
-
import { defineComponent, shallowRef, getCurrentInstance, provide, computed, resolveComponent, openBlock, createBlock, mergeProps, toHandlers, withCtx, createVNode, renderSlot } from 'vue';
|
|
4
|
+
import { defineComponent, shallowRef, getCurrentInstance, provide, computed, resolveComponent, openBlock, createBlock, mergeProps, toHandlers, withCtx, createVNode, createElementBlock, Fragment, renderSlot, createCommentVNode } from 'vue';
|
|
5
5
|
import { VkfFormItemRenderer } from '@vunk/form/components/form-item-renderer';
|
|
6
6
|
import { createFormBindProps, createFormOnEmits } from '@vunk/form/shared/element-plus';
|
|
7
7
|
import { getValue } from '@vunk/core/shared/helper';
|
|
@@ -9,6 +9,8 @@ import { VkfTemplatesDefault } from '@vunk/form/components/templates-default';
|
|
|
9
9
|
import { VkfTemplatesLayout } from '@vunk/form/components/templates-layout';
|
|
10
10
|
import { pickObject } from '@vunk/core/shared/utils-object';
|
|
11
11
|
import { genTemplateIfFunc } from '@vunk/form/shared/form';
|
|
12
|
+
import { VkfTemplateInstancesProvider } from '@vunk/form/components/template-instances-provider';
|
|
13
|
+
import { VkfRendererData } from '@vunk/form/components/renderer-data';
|
|
12
14
|
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
13
15
|
|
|
14
16
|
const props = {
|
|
@@ -52,6 +54,13 @@ const props = {
|
|
|
52
54
|
colSource: {
|
|
53
55
|
type: Object,
|
|
54
56
|
default: () => ({})
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* 是否继承父级模板
|
|
60
|
+
*/
|
|
61
|
+
inheritTemplates: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
55
64
|
}
|
|
56
65
|
};
|
|
57
66
|
const createBindProps = bindPropsFactory(props);
|
|
@@ -108,6 +117,8 @@ const genRowItem = (defaultItem, options = {}) => {
|
|
|
108
117
|
var _sfc_main = defineComponent({
|
|
109
118
|
name: "VkfForm",
|
|
110
119
|
components: {
|
|
120
|
+
VkfTemplateInstancesProvider,
|
|
121
|
+
VkfRendererData,
|
|
111
122
|
ElForm,
|
|
112
123
|
VkfFormItemRenderer,
|
|
113
124
|
VkfTemplatesDefault,
|
|
@@ -173,6 +184,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
173
184
|
const _component_VkfTemplatesDefault = resolveComponent("VkfTemplatesDefault");
|
|
174
185
|
const _component_VkfTemplatesLayout = resolveComponent("VkfTemplatesLayout");
|
|
175
186
|
const _component_VkfFormItemRenderer = resolveComponent("VkfFormItemRenderer");
|
|
187
|
+
const _component_VkfRendererData = resolveComponent("VkfRendererData");
|
|
188
|
+
const _component_VkfTemplateInstancesProvider = resolveComponent("VkfTemplateInstancesProvider");
|
|
176
189
|
const _component_ElForm = resolveComponent("ElForm");
|
|
177
190
|
return openBlock(), createBlock(_component_ElForm, mergeProps(_ctx.formProps, {
|
|
178
191
|
ref: _ctx.getRef,
|
|
@@ -182,18 +195,33 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
182
195
|
model: _ctx.model || _ctx.data
|
|
183
196
|
}, toHandlers(_ctx.formEmits), { onSubmit: _ctx.handleSubmit }), {
|
|
184
197
|
default: withCtx(() => [
|
|
185
|
-
createVNode(
|
|
198
|
+
createVNode(_component_VkfTemplateInstancesProvider, { "inherit-templates": _ctx.inheritTemplates }, {
|
|
186
199
|
default: withCtx(() => [
|
|
187
|
-
|
|
200
|
+
!_ctx.inheritTemplates ? (openBlock(), createElementBlock(
|
|
201
|
+
Fragment,
|
|
202
|
+
{ key: 0 },
|
|
203
|
+
[
|
|
204
|
+
createVNode(_component_VkfTemplatesDefault),
|
|
205
|
+
createVNode(_component_VkfTemplatesLayout),
|
|
206
|
+
renderSlot(_ctx.$slots, "rendererTemplate")
|
|
207
|
+
],
|
|
208
|
+
64
|
|
209
|
+
/* STABLE_FRAGMENT */
|
|
210
|
+
)) : createCommentVNode("v-if", true),
|
|
211
|
+
createVNode(_component_VkfRendererData, {
|
|
188
212
|
data: _ctx.data,
|
|
189
213
|
onSetData: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("setData", $event))
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
|
|
214
|
+
}, {
|
|
215
|
+
default: withCtx(() => [
|
|
216
|
+
createVNode(_component_VkfFormItemRenderer, { source: _ctx.rendererSource }, null, 8, ["source"])
|
|
217
|
+
]),
|
|
218
|
+
_: 1
|
|
219
|
+
/* STABLE */
|
|
220
|
+
}, 8, ["data"])
|
|
193
221
|
]),
|
|
194
222
|
_: 3
|
|
195
223
|
/* FORWARDED */
|
|
196
|
-
}, 8, ["
|
|
224
|
+
}, 8, ["inherit-templates"]),
|
|
197
225
|
renderSlot(_ctx.$slots, "default")
|
|
198
226
|
]),
|
|
199
227
|
_: 3
|
|
@@ -43,6 +43,13 @@ export declare const props: {
|
|
|
43
43
|
type: PropType<Partial<ColItem>>;
|
|
44
44
|
default: () => ColItem;
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* 是否继承父级模板
|
|
48
|
+
*/
|
|
49
|
+
inheritTemplates: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: boolean;
|
|
52
|
+
};
|
|
46
53
|
model: ObjectConstructor;
|
|
47
54
|
rules: {
|
|
48
55
|
readonly type: import("vue").PropType<Partial<Record<string, import("element-plus/es/utils").Arrayable<import("element-plus").FormItemRule>>>>;
|
|
@@ -75,7 +82,7 @@ export declare const props: {
|
|
|
75
82
|
};
|
|
76
83
|
disabled: BooleanConstructor;
|
|
77
84
|
};
|
|
78
|
-
export declare const createBindProps: <T2 extends import("@vunk/core").NormalObject, EX extends (Extract<"size", keyof T2> | Extract<"disabled", keyof T2> | Extract<"data", keyof T2> | Extract<"elRef", keyof T2> | Extract<"inline", keyof T2> | Extract<"readonly", keyof T2> | Extract<"labelWidth", keyof T2> | Extract<"labelPosition", keyof T2> | Extract<"rules", keyof T2> | Extract<"inlineMessage", keyof T2> | Extract<"showMessage", keyof T2> | Extract<"model", keyof T2> | Extract<"requireAsteriskPosition", keyof T2> | Extract<"labelSuffix", keyof T2> | Extract<"statusIcon", keyof T2> | Extract<"validateOnRuleChange", keyof T2> | Extract<"hideRequiredAsterisk", keyof T2> | Extract<"scrollToError", keyof T2> | Extract<"scrollIntoViewOptions", keyof T2> | Extract<"formItems", keyof T2> | Extract<"layout", keyof T2> | Extract<"rowSource", keyof T2> | Extract<"colSource", keyof T2>)[]>(propsArg: T2, excludes?: EX) => import("vue").ComputedRef<{ [P in EX extends (infer KE)[] ? Exclude<Extract<"size" | "disabled" | "data" | "elRef" | "inline" | "readonly" | "labelWidth" | "labelPosition" | "rules" | "inlineMessage" | "showMessage" | "model" | "requireAsteriskPosition" | "labelSuffix" | "statusIcon" | "validateOnRuleChange" | "hideRequiredAsterisk" | "scrollToError" | "scrollIntoViewOptions" | "formItems" | "layout" | "rowSource" | "colSource", keyof T2>, KE> : Extract<"size" | "disabled" | "data" | "elRef" | "inline" | "readonly" | "labelWidth" | "labelPosition" | "rules" | "inlineMessage" | "showMessage" | "model" | "requireAsteriskPosition" | "labelSuffix" | "statusIcon" | "validateOnRuleChange" | "hideRequiredAsterisk" | "scrollToError" | "scrollIntoViewOptions" | "formItems" | "layout" | "rowSource" | "colSource", keyof T2>]: { [k in Extract<"size" | "disabled" | "data" | "elRef" | "inline" | "readonly" | "labelWidth" | "labelPosition" | "rules" | "inlineMessage" | "showMessage" | "model" | "requireAsteriskPosition" | "labelSuffix" | "statusIcon" | "validateOnRuleChange" | "hideRequiredAsterisk" | "scrollToError" | "scrollIntoViewOptions" | "formItems" | "layout" | "rowSource" | "colSource", keyof T2>]: T2[k]; }[P]; }>;
|
|
85
|
+
export declare const createBindProps: <T2 extends import("@vunk/core").NormalObject, EX extends (Extract<"size", keyof T2> | Extract<"disabled", keyof T2> | Extract<"data", keyof T2> | Extract<"elRef", keyof T2> | Extract<"inline", keyof T2> | Extract<"readonly", keyof T2> | Extract<"labelWidth", keyof T2> | Extract<"labelPosition", keyof T2> | Extract<"rules", keyof T2> | Extract<"inlineMessage", keyof T2> | Extract<"showMessage", keyof T2> | Extract<"model", keyof T2> | Extract<"requireAsteriskPosition", keyof T2> | Extract<"labelSuffix", keyof T2> | Extract<"statusIcon", keyof T2> | Extract<"validateOnRuleChange", keyof T2> | Extract<"hideRequiredAsterisk", keyof T2> | Extract<"scrollToError", keyof T2> | Extract<"scrollIntoViewOptions", keyof T2> | Extract<"formItems", keyof T2> | Extract<"layout", keyof T2> | Extract<"rowSource", keyof T2> | Extract<"colSource", keyof T2> | Extract<"inheritTemplates", keyof T2>)[]>(propsArg: T2, excludes?: EX) => import("vue").ComputedRef<{ [P in EX extends (infer KE)[] ? Exclude<Extract<"size" | "disabled" | "data" | "elRef" | "inline" | "readonly" | "labelWidth" | "labelPosition" | "rules" | "inlineMessage" | "showMessage" | "model" | "requireAsteriskPosition" | "labelSuffix" | "statusIcon" | "validateOnRuleChange" | "hideRequiredAsterisk" | "scrollToError" | "scrollIntoViewOptions" | "formItems" | "layout" | "rowSource" | "colSource" | "inheritTemplates", keyof T2>, KE> : Extract<"size" | "disabled" | "data" | "elRef" | "inline" | "readonly" | "labelWidth" | "labelPosition" | "rules" | "inlineMessage" | "showMessage" | "model" | "requireAsteriskPosition" | "labelSuffix" | "statusIcon" | "validateOnRuleChange" | "hideRequiredAsterisk" | "scrollToError" | "scrollIntoViewOptions" | "formItems" | "layout" | "rowSource" | "colSource" | "inheritTemplates", keyof T2>]: { [k in Extract<"size" | "disabled" | "data" | "elRef" | "inline" | "readonly" | "labelWidth" | "labelPosition" | "rules" | "inlineMessage" | "showMessage" | "model" | "requireAsteriskPosition" | "labelSuffix" | "statusIcon" | "validateOnRuleChange" | "hideRequiredAsterisk" | "scrollToError" | "scrollIntoViewOptions" | "formItems" | "layout" | "rowSource" | "colSource" | "inheritTemplates", keyof T2>]: T2[k]; }[P]; }>;
|
|
79
86
|
export declare const emits: {
|
|
80
87
|
setData: (e: SetDataEvent) => SetDataEvent;
|
|
81
88
|
validate: any;
|
|
@@ -28,6 +28,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
28
28
|
type: import("vue").PropType<Partial<import("./types").ColItem>>;
|
|
29
29
|
default: () => import("./types").ColItem;
|
|
30
30
|
};
|
|
31
|
+
inheritTemplates: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
default: boolean;
|
|
34
|
+
};
|
|
31
35
|
model: ObjectConstructor;
|
|
32
36
|
rules: {
|
|
33
37
|
readonly type: import("vue").PropType<Partial<Record<string, import("element-plus/es/utils").Arrayable<import("element-plus").FormItemRule>>>>;
|
|
@@ -115,6 +119,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
115
119
|
type: import("vue").PropType<Partial<import("./types").ColItem>>;
|
|
116
120
|
default: () => import("./types").ColItem;
|
|
117
121
|
};
|
|
122
|
+
inheritTemplates: {
|
|
123
|
+
type: BooleanConstructor;
|
|
124
|
+
default: boolean;
|
|
125
|
+
};
|
|
118
126
|
model: ObjectConstructor;
|
|
119
127
|
rules: {
|
|
120
128
|
readonly type: import("vue").PropType<Partial<Record<string, import("element-plus/es/utils").Arrayable<import("element-plus").FormItemRule>>>>;
|
|
@@ -353,7 +361,30 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
353
361
|
layout: boolean;
|
|
354
362
|
rowSource: Partial<RowItem>;
|
|
355
363
|
colSource: Partial<import("./types").ColItem>;
|
|
364
|
+
inheritTemplates: boolean;
|
|
356
365
|
}, {}, {
|
|
366
|
+
VkfTemplateInstancesProvider: {
|
|
367
|
+
new (...args: any[]): any;
|
|
368
|
+
__isFragment?: never;
|
|
369
|
+
__isTeleport?: never;
|
|
370
|
+
__isSuspense?: never;
|
|
371
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<Record<string | symbol, any>>>, Record<string | symbol, any>, any, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
372
|
+
[x: string]: any;
|
|
373
|
+
[x: symbol]: any;
|
|
374
|
+
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
375
|
+
install(app: import("vue").App): void;
|
|
376
|
+
};
|
|
377
|
+
VkfRendererData: {
|
|
378
|
+
new (...args: any[]): any;
|
|
379
|
+
__isFragment?: never;
|
|
380
|
+
__isTeleport?: never;
|
|
381
|
+
__isSuspense?: never;
|
|
382
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<Record<string | symbol, any>>>, Record<string | symbol, any>, any, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
383
|
+
[x: string]: any;
|
|
384
|
+
[x: symbol]: any;
|
|
385
|
+
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
386
|
+
install(app: import("vue").App): void;
|
|
387
|
+
};
|
|
357
388
|
ElForm: import("element-plus/es/utils").SFCWithInstall<{
|
|
358
389
|
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
359
390
|
readonly model: ObjectConstructor;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var vue = require('vue');
|
|
6
6
|
var form = require('@vunk/form/shared/form');
|
|
7
|
+
var composables = require('@vunk/form/composables');
|
|
7
8
|
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
8
9
|
|
|
9
10
|
const props = {
|
|
@@ -22,18 +23,24 @@ const props = {
|
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
25
|
|
|
25
|
-
const S_TEMPLATE_INSTANCES = Symbol("templateInstances");
|
|
26
|
-
const parentTemplateInstancesSymbol = Symbol("parentTemplateInstancesSymbol");
|
|
27
|
-
|
|
28
26
|
const VkfFormItemRenderer$1 = vue.defineComponent({
|
|
29
27
|
name: "VkfFormItemRenderer",
|
|
30
28
|
props: props,
|
|
31
29
|
setup(props, ctx) {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const parentTemplateInstance = composables.useTemplateInstances();
|
|
31
|
+
const {
|
|
32
|
+
emitSetData,
|
|
33
|
+
data: rendererData,
|
|
34
|
+
getDataValue
|
|
35
|
+
} = composables.useRendererData();
|
|
36
|
+
const templateInstances = props.templateInstances ?? parentTemplateInstance ?? vue.shallowReactive({});
|
|
37
|
+
vue.provide("vkTemplateInstances", templateInstances);
|
|
38
|
+
const Renderer = (props2) => {
|
|
39
|
+
return vue.h(VkfFormItemRenderer$1, {
|
|
40
|
+
templateInstances,
|
|
41
|
+
...props2
|
|
42
|
+
});
|
|
43
|
+
};
|
|
37
44
|
const renderFormItems = (data, pK = []) => {
|
|
38
45
|
return data.reduce((a, c, index) => {
|
|
39
46
|
c.key = c.key ?? (Array.isArray(c.prop) ? c.prop.join() : c.prop);
|
|
@@ -41,31 +48,43 @@ const VkfFormItemRenderer$1 = vue.defineComponent({
|
|
|
41
48
|
const validateTemplateType = () => {
|
|
42
49
|
vue.nextTick(() => {
|
|
43
50
|
if (c.templateType && !templateInstances[c.templateType]) {
|
|
44
|
-
console.warn(
|
|
51
|
+
console.warn(
|
|
52
|
+
c.templateType,
|
|
53
|
+
"templateType\u4E0D\u5B58\u5728\u5C06\u8DF3\u8FC7"
|
|
54
|
+
);
|
|
45
55
|
}
|
|
46
56
|
});
|
|
47
57
|
};
|
|
48
58
|
if (c.templateType && templateInstances[c.templateType]) {
|
|
59
|
+
const templateIf = form.genTemplateIfFunc(c.templateIf);
|
|
60
|
+
const preTemplateVisible = rendererData ? templateIf(rendererData.value) : true;
|
|
61
|
+
if (!preTemplateVisible) return a;
|
|
49
62
|
const slotData = { ...c };
|
|
50
63
|
Reflect.deleteProperty(slotData, "templateType");
|
|
51
|
-
Reflect.deleteProperty(slotData, "templateSlots");
|
|
52
64
|
Reflect.deleteProperty(slotData, "templateIf");
|
|
65
|
+
const nodeKey = currentK.join(",") + "-" + c.templateType + "-" + (c.prop || "no-prop");
|
|
66
|
+
const modelValue = vue.computed({
|
|
67
|
+
get: () => c.prop && getDataValue?.(c.prop),
|
|
68
|
+
set: (v) => emitSetData?.({
|
|
69
|
+
k: c.prop,
|
|
70
|
+
v
|
|
71
|
+
})
|
|
72
|
+
});
|
|
53
73
|
const nodes = templateInstances[c.templateType].slots.default?.({
|
|
74
|
+
// for legacy
|
|
54
75
|
data: slotData,
|
|
55
76
|
raw: c,
|
|
56
|
-
|
|
77
|
+
props: slotData,
|
|
57
78
|
k: currentK,
|
|
58
|
-
key:
|
|
59
|
-
|
|
79
|
+
key: nodeKey,
|
|
80
|
+
value: modelValue.value,
|
|
81
|
+
input: (v) => modelValue.value = v,
|
|
82
|
+
templateIf,
|
|
83
|
+
Renderer,
|
|
84
|
+
getDataValue,
|
|
85
|
+
emitSetData
|
|
60
86
|
});
|
|
61
87
|
nodes && a.push(nodes);
|
|
62
|
-
} else if (c.templateSlots?.default) {
|
|
63
|
-
validateTemplateType();
|
|
64
|
-
currentK.push("templateSlots", "default");
|
|
65
|
-
if (Array.isArray(c.templateSlots?.default)) {
|
|
66
|
-
const subNode = renderFormItems(c.templateSlots.default, currentK);
|
|
67
|
-
a = a.concat(subNode);
|
|
68
|
-
}
|
|
69
88
|
} else {
|
|
70
89
|
validateTemplateType();
|
|
71
90
|
}
|
|
@@ -92,8 +111,6 @@ VkfFormItemRenderer.install = (app) => {
|
|
|
92
111
|
app.component(VkfFormItemRenderer.name, VkfFormItemRenderer);
|
|
93
112
|
};
|
|
94
113
|
|
|
95
|
-
exports.S_TEMPLATE_INSTANCES = S_TEMPLATE_INSTANCES;
|
|
96
114
|
exports.VkfFormItemRenderer = VkfFormItemRenderer;
|
|
97
115
|
exports.__VkfFormItemRenderer = types;
|
|
98
116
|
exports.default = VkfFormItemRenderer;
|
|
99
|
-
exports.parentTemplateInstancesSymbol = parentTemplateInstancesSymbol;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { defineComponent,
|
|
1
|
+
import { defineComponent, shallowReactive, provide, computed, h, nextTick } from 'vue';
|
|
2
2
|
import { genTemplateIfFunc } from '@vunk/form/shared/form';
|
|
3
|
+
import { useTemplateInstances, useRendererData } from '@vunk/form/composables';
|
|
3
4
|
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
4
5
|
|
|
5
6
|
const props = {
|
|
@@ -18,18 +19,24 @@ const props = {
|
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
const S_TEMPLATE_INSTANCES = Symbol("templateInstances");
|
|
22
|
-
const parentTemplateInstancesSymbol = Symbol("parentTemplateInstancesSymbol");
|
|
23
|
-
|
|
24
22
|
const VkfFormItemRenderer$1 = defineComponent({
|
|
25
23
|
name: "VkfFormItemRenderer",
|
|
26
24
|
props: props,
|
|
27
25
|
setup(props, ctx) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const parentTemplateInstance = useTemplateInstances();
|
|
27
|
+
const {
|
|
28
|
+
emitSetData,
|
|
29
|
+
data: rendererData,
|
|
30
|
+
getDataValue
|
|
31
|
+
} = useRendererData();
|
|
32
|
+
const templateInstances = props.templateInstances ?? parentTemplateInstance ?? shallowReactive({});
|
|
33
|
+
provide("vkTemplateInstances", templateInstances);
|
|
34
|
+
const Renderer = (props2) => {
|
|
35
|
+
return h(VkfFormItemRenderer$1, {
|
|
36
|
+
templateInstances,
|
|
37
|
+
...props2
|
|
38
|
+
});
|
|
39
|
+
};
|
|
33
40
|
const renderFormItems = (data, pK = []) => {
|
|
34
41
|
return data.reduce((a, c, index) => {
|
|
35
42
|
c.key = c.key ?? (Array.isArray(c.prop) ? c.prop.join() : c.prop);
|
|
@@ -37,31 +44,43 @@ const VkfFormItemRenderer$1 = defineComponent({
|
|
|
37
44
|
const validateTemplateType = () => {
|
|
38
45
|
nextTick(() => {
|
|
39
46
|
if (c.templateType && !templateInstances[c.templateType]) {
|
|
40
|
-
console.warn(
|
|
47
|
+
console.warn(
|
|
48
|
+
c.templateType,
|
|
49
|
+
"templateType\u4E0D\u5B58\u5728\u5C06\u8DF3\u8FC7"
|
|
50
|
+
);
|
|
41
51
|
}
|
|
42
52
|
});
|
|
43
53
|
};
|
|
44
54
|
if (c.templateType && templateInstances[c.templateType]) {
|
|
55
|
+
const templateIf = genTemplateIfFunc(c.templateIf);
|
|
56
|
+
const preTemplateVisible = rendererData ? templateIf(rendererData.value) : true;
|
|
57
|
+
if (!preTemplateVisible) return a;
|
|
45
58
|
const slotData = { ...c };
|
|
46
59
|
Reflect.deleteProperty(slotData, "templateType");
|
|
47
|
-
Reflect.deleteProperty(slotData, "templateSlots");
|
|
48
60
|
Reflect.deleteProperty(slotData, "templateIf");
|
|
61
|
+
const nodeKey = currentK.join(",") + "-" + c.templateType + "-" + (c.prop || "no-prop");
|
|
62
|
+
const modelValue = computed({
|
|
63
|
+
get: () => c.prop && getDataValue?.(c.prop),
|
|
64
|
+
set: (v) => emitSetData?.({
|
|
65
|
+
k: c.prop,
|
|
66
|
+
v
|
|
67
|
+
})
|
|
68
|
+
});
|
|
49
69
|
const nodes = templateInstances[c.templateType].slots.default?.({
|
|
70
|
+
// for legacy
|
|
50
71
|
data: slotData,
|
|
51
72
|
raw: c,
|
|
52
|
-
|
|
73
|
+
props: slotData,
|
|
53
74
|
k: currentK,
|
|
54
|
-
key:
|
|
55
|
-
|
|
75
|
+
key: nodeKey,
|
|
76
|
+
value: modelValue.value,
|
|
77
|
+
input: (v) => modelValue.value = v,
|
|
78
|
+
templateIf,
|
|
79
|
+
Renderer,
|
|
80
|
+
getDataValue,
|
|
81
|
+
emitSetData
|
|
56
82
|
});
|
|
57
83
|
nodes && a.push(nodes);
|
|
58
|
-
} else if (c.templateSlots?.default) {
|
|
59
|
-
validateTemplateType();
|
|
60
|
-
currentK.push("templateSlots", "default");
|
|
61
|
-
if (Array.isArray(c.templateSlots?.default)) {
|
|
62
|
-
const subNode = renderFormItems(c.templateSlots.default, currentK);
|
|
63
|
-
a = a.concat(subNode);
|
|
64
|
-
}
|
|
65
84
|
} else {
|
|
66
85
|
validateTemplateType();
|
|
67
86
|
}
|
|
@@ -88,4 +107,4 @@ VkfFormItemRenderer.install = (app) => {
|
|
|
88
107
|
app.component(VkfFormItemRenderer.name, VkfFormItemRenderer);
|
|
89
108
|
};
|
|
90
109
|
|
|
91
|
-
export {
|
|
110
|
+
export { VkfFormItemRenderer, types as __VkfFormItemRenderer, VkfFormItemRenderer as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VNode } from 'vue';
|
|
2
2
|
import { RendererTreeData } from './types';
|
|
3
3
|
declare const VkfFormItemRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
4
|
source: {
|
|
@@ -6,7 +6,7 @@ declare const VkfFormItemRenderer: import("vue").DefineComponent<import("vue").E
|
|
|
6
6
|
default: () => any[];
|
|
7
7
|
};
|
|
8
8
|
templateInstances: {
|
|
9
|
-
type: import("vue").PropType<Record<string, ComponentInternalInstance>>;
|
|
9
|
+
type: import("vue").PropType<Record<string, import("vue").ComponentInternalInstance>>;
|
|
10
10
|
default: any;
|
|
11
11
|
};
|
|
12
12
|
k: {
|
|
@@ -23,7 +23,7 @@ declare const VkfFormItemRenderer: import("vue").DefineComponent<import("vue").E
|
|
|
23
23
|
default: () => any[];
|
|
24
24
|
};
|
|
25
25
|
templateInstances: {
|
|
26
|
-
type: import("vue").PropType<Record<string, ComponentInternalInstance>>;
|
|
26
|
+
type: import("vue").PropType<Record<string, import("vue").ComponentInternalInstance>>;
|
|
27
27
|
default: any;
|
|
28
28
|
};
|
|
29
29
|
k: {
|
|
@@ -31,8 +31,8 @@ declare const VkfFormItemRenderer: import("vue").DefineComponent<import("vue").E
|
|
|
31
31
|
default: () => any[];
|
|
32
32
|
};
|
|
33
33
|
}>> & Readonly<{}>, {
|
|
34
|
-
templateInstances: Record<string, ComponentInternalInstance>;
|
|
35
34
|
source: RendererTreeData[];
|
|
35
|
+
templateInstances: Record<string, import("vue").ComponentInternalInstance>;
|
|
36
36
|
k: (string | number)[];
|
|
37
37
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
38
38
|
export default VkfFormItemRenderer;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var composables = require('@vunk/form/composables');
|
|
5
6
|
var vue = require('vue');
|
|
6
|
-
var formItemRenderer = require('@vunk/form/components/form-item-renderer');
|
|
7
7
|
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
8
8
|
|
|
9
9
|
const props = {
|
|
@@ -18,7 +18,7 @@ var _sfc_main = vue.defineComponent({
|
|
|
18
18
|
name: "VkfFormItemRendererTemplate",
|
|
19
19
|
props,
|
|
20
20
|
setup(props2) {
|
|
21
|
-
const templateInstances =
|
|
21
|
+
const templateInstances = composables.useTemplateInstances();
|
|
22
22
|
if (!templateInstances) throw new Error();
|
|
23
23
|
const vm = vue.getCurrentInstance();
|
|
24
24
|
const oVm = templateInstances[props2.type];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useTemplateInstances } from '@vunk/form/composables';
|
|
2
|
+
import { defineComponent, getCurrentInstance, onUnmounted } from 'vue';
|
|
3
3
|
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
4
4
|
|
|
5
5
|
const props = {
|
|
@@ -14,7 +14,7 @@ var _sfc_main = defineComponent({
|
|
|
14
14
|
name: "VkfFormItemRendererTemplate",
|
|
15
15
|
props,
|
|
16
16
|
setup(props2) {
|
|
17
|
-
const templateInstances =
|
|
17
|
+
const templateInstances = useTemplateInstances();
|
|
18
18
|
if (!templateInstances) throw new Error();
|
|
19
19
|
const vm = getCurrentInstance();
|
|
20
20
|
const oVm = templateInstances[props2.type];
|
|
@@ -1 +1,45 @@
|
|
|
1
|
+
import { __VkfFormItemRenderer } from '@vunk/form/components/form-item-renderer';
|
|
2
|
+
import { NormalObject } from '@vunk/shared';
|
|
3
|
+
import type { VkfFormItemRenderer } from '@vunk/form/components/form-item-renderer';
|
|
4
|
+
import { MaybeArray, SetDataEvent } from '@vunk/core';
|
|
5
|
+
type RendererTreeData = __VkfFormItemRenderer.RendererTreeData;
|
|
6
|
+
export interface DefaultSlotArguments {
|
|
7
|
+
raw: RendererTreeData;
|
|
8
|
+
/**
|
|
9
|
+
* 根据 templateIf 生成的控制显隐事件
|
|
10
|
+
*/
|
|
11
|
+
templateIf: (e?: NormalObject) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use props
|
|
14
|
+
*/
|
|
15
|
+
data: Omit<RendererTreeData, 'templateType' | 'templateIf'>;
|
|
16
|
+
/**
|
|
17
|
+
* 当前表单项的数据,排除渲染占用字段
|
|
18
|
+
*/
|
|
19
|
+
props: Omit<RendererTreeData, 'templateType' | 'templateIf'>;
|
|
20
|
+
/**
|
|
21
|
+
* 当前表单项,在整个 formItems 中的位置
|
|
22
|
+
*/
|
|
23
|
+
k: (string | number)[];
|
|
24
|
+
/**
|
|
25
|
+
* FormItemRenderer 便于子组件使用
|
|
26
|
+
*/
|
|
27
|
+
Renderer: typeof VkfFormItemRenderer;
|
|
28
|
+
/**
|
|
29
|
+
* 对应的表单数据(如果formItem提供prop)
|
|
30
|
+
*/
|
|
31
|
+
value?: never;
|
|
32
|
+
/**
|
|
33
|
+
* 更新表单数据(如果formItem提供prop)
|
|
34
|
+
*/
|
|
35
|
+
input?: (v: any) => void;
|
|
36
|
+
/**
|
|
37
|
+
* 从表单数据中获取对应的值
|
|
38
|
+
*/
|
|
39
|
+
getDataValue: (key: MaybeArray<number | string>) => any;
|
|
40
|
+
/**
|
|
41
|
+
* 更新表单数据
|
|
42
|
+
*/
|
|
43
|
+
emitSetData: (e: SetDataEvent) => void;
|
|
44
|
+
}
|
|
1
45
|
export {};
|