@vunk/form 0.0.1-alpha.10 → 0.0.1-alpha.11
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-item-renderer/index.js +15 -1
- package/components/form-item-renderer/src/types.d.ts +2 -0
- package/components/form-item-renderer-template-default/index.js +23 -18
- package/components/form-item-renderer-template-layout/index.js +19 -10
- package/components/form-item-renderer-template-layout/src/ctx.d.ts +3 -2
- package/components/form-item-renderer-template-layout/src/ctx.js +1 -1
- package/components/form-item-renderer-template-layout/src/index.vue.d.ts +14 -2
- package/package.json +1 -1
- package/shared/types/basic-source/index.d.ts +5 -0
- package/shared/types/basic-source/index.js +1 -0
- package/shared/types/layout-source/index.d.ts +4 -3
- package/shared/types/renderer-source/compoent.d.ts +2 -0
- package/shared/types/renderer-source/date-picker.d.ts +3 -2
- package/shared/types/renderer-source/index.d.ts +1 -1
- package/shared/types/renderer-source/input-number.d.ts +3 -2
- package/shared/types/renderer-source/input.d.ts +3 -2
- package/shared/types/renderer-source/select.d.ts +3 -2
- package/shared/types/renderer-source/switch.d.ts +3 -2
|
@@ -65,11 +65,25 @@ const VkfFormItemRenderer = defineComponent({
|
|
|
65
65
|
const slotData = __spreadValues({}, c);
|
|
66
66
|
Reflect.deleteProperty(slotData, "templateType");
|
|
67
67
|
Reflect.deleteProperty(slotData, "templateSlots");
|
|
68
|
+
Reflect.deleteProperty(slotData, "templateIf");
|
|
69
|
+
const createIsShow = () => {
|
|
70
|
+
if (typeof c.templateIf === "boolean") {
|
|
71
|
+
const flag = c.templateIf;
|
|
72
|
+
return () => flag;
|
|
73
|
+
} else if (typeof c.templateIf === "string") {
|
|
74
|
+
const templateIf = new Function("data", c.templateIf);
|
|
75
|
+
return templateIf;
|
|
76
|
+
} else if (typeof c.templateIf === "function") {
|
|
77
|
+
return c.templateIf;
|
|
78
|
+
}
|
|
79
|
+
return () => true;
|
|
80
|
+
};
|
|
68
81
|
const nodes = (_b = (_a2 = templateInstances[c.templateType].slots).default) == null ? void 0 : _b.call(_a2, {
|
|
69
82
|
data: slotData,
|
|
70
83
|
raw: c,
|
|
71
84
|
Renderer,
|
|
72
|
-
k: currentK
|
|
85
|
+
k: currentK,
|
|
86
|
+
isShow: createIsShow()
|
|
73
87
|
});
|
|
74
88
|
nodes && a.push(nodes);
|
|
75
89
|
} else if ((_c = c.templateSlots) == null ? void 0 : _c.default) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, resolveComponent, openBlock, createElementBlock, Fragment, createVNode, withCtx, mergeProps,
|
|
1
|
+
import { defineComponent, resolveComponent, openBlock, createElementBlock, Fragment, createVNode, withCtx, createBlock, mergeProps, createCommentVNode, resolveDynamicComponent, normalizeProps } from 'vue';
|
|
2
2
|
import { VkfFormItemRendererTemplate } from '@vunk/form/components/form-item-renderer-template';
|
|
3
3
|
import { VkfInput } from '@vunk/form/components/input';
|
|
4
4
|
import { VkfSwitch } from '@vunk/form/components/switch';
|
|
@@ -47,68 +47,73 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
47
47
|
const _component_VkfInputNumber = resolveComponent("VkfInputNumber");
|
|
48
48
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
49
49
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "VkfInput" }, {
|
|
50
|
-
default: withCtx(({ data: sourceData }) => [
|
|
51
|
-
|
|
50
|
+
default: withCtx(({ data: sourceData, isShow }) => [
|
|
51
|
+
isShow(_ctx.data) ? (openBlock(), createBlock(_component_VkfInput, mergeProps({
|
|
52
|
+
key: 0,
|
|
52
53
|
modelValue: _ctx.getValue(_ctx.data, sourceData.prop),
|
|
53
54
|
"onUpdate:modelValue": ($event) => _ctx.$emit("setData", {
|
|
54
55
|
k: sourceData.prop,
|
|
55
56
|
v: $event
|
|
56
57
|
})
|
|
57
|
-
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])
|
|
58
|
+
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])) : createCommentVNode("v-if", true)
|
|
58
59
|
]),
|
|
59
60
|
_: 1
|
|
60
61
|
}),
|
|
61
62
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "VkfSwitch" }, {
|
|
62
|
-
default: withCtx(({ data: sourceData }) => [
|
|
63
|
-
|
|
63
|
+
default: withCtx(({ data: sourceData, isShow }) => [
|
|
64
|
+
isShow(_ctx.data) ? (openBlock(), createBlock(_component_VkfSwitch, mergeProps({
|
|
65
|
+
key: 0,
|
|
64
66
|
modelValue: _ctx.getValue(_ctx.data, sourceData.prop),
|
|
65
67
|
"onUpdate:modelValue": ($event) => _ctx.$emit("setData", {
|
|
66
68
|
k: sourceData.prop,
|
|
67
69
|
v: $event
|
|
68
70
|
})
|
|
69
|
-
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])
|
|
71
|
+
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])) : createCommentVNode("v-if", true)
|
|
70
72
|
]),
|
|
71
73
|
_: 1
|
|
72
74
|
}),
|
|
73
75
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "VkfSelect" }, {
|
|
74
|
-
default: withCtx(({ data: sourceData }) => [
|
|
75
|
-
|
|
76
|
+
default: withCtx(({ data: sourceData, isShow }) => [
|
|
77
|
+
isShow(_ctx.data) ? (openBlock(), createBlock(_component_VkfSelect, mergeProps({
|
|
78
|
+
key: 0,
|
|
76
79
|
modelValue: _ctx.getValue(_ctx.data, sourceData.prop),
|
|
77
80
|
"onUpdate:modelValue": ($event) => _ctx.$emit("setData", {
|
|
78
81
|
k: sourceData.prop,
|
|
79
82
|
v: $event
|
|
80
83
|
})
|
|
81
|
-
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])
|
|
84
|
+
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])) : createCommentVNode("v-if", true)
|
|
82
85
|
]),
|
|
83
86
|
_: 1
|
|
84
87
|
}),
|
|
85
88
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "VkfDatePicker" }, {
|
|
86
|
-
default: withCtx(({ data: sourceData }) => [
|
|
87
|
-
|
|
89
|
+
default: withCtx(({ data: sourceData, isShow }) => [
|
|
90
|
+
isShow(_ctx.data) ? (openBlock(), createBlock(_component_VkfDatePicker, mergeProps({
|
|
91
|
+
key: 0,
|
|
88
92
|
modelValue: _ctx.getValue(_ctx.data, sourceData.prop),
|
|
89
93
|
"onUpdate:modelValue": ($event) => _ctx.$emit("setData", {
|
|
90
94
|
k: sourceData.prop,
|
|
91
95
|
v: $event
|
|
92
96
|
})
|
|
93
|
-
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])
|
|
97
|
+
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])) : createCommentVNode("v-if", true)
|
|
94
98
|
]),
|
|
95
99
|
_: 1
|
|
96
100
|
}),
|
|
97
101
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "VkfInputNumber" }, {
|
|
98
|
-
default: withCtx(({ data: sourceData }) => [
|
|
99
|
-
|
|
102
|
+
default: withCtx(({ data: sourceData, isShow }) => [
|
|
103
|
+
isShow(_ctx.data) ? (openBlock(), createBlock(_component_VkfInputNumber, mergeProps({
|
|
104
|
+
key: 0,
|
|
100
105
|
modelValue: _ctx.getValue(_ctx.data, sourceData.prop),
|
|
101
106
|
"onUpdate:modelValue": ($event) => _ctx.$emit("setData", {
|
|
102
107
|
k: sourceData.prop,
|
|
103
108
|
v: $event
|
|
104
109
|
})
|
|
105
|
-
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])
|
|
110
|
+
}, sourceData), null, 16, ["modelValue", "onUpdate:modelValue"])) : createCommentVNode("v-if", true)
|
|
106
111
|
]),
|
|
107
112
|
_: 1
|
|
108
113
|
}),
|
|
109
114
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "Component" }, {
|
|
110
|
-
default: withCtx(({ data, raw }) => [
|
|
111
|
-
(openBlock(), createBlock(resolveDynamicComponent(typeof data.is === "function" ? data.is(raw) : data.is), normalizeProps(
|
|
115
|
+
default: withCtx(({ data, raw, isShow }) => [
|
|
116
|
+
isShow(data) ? (openBlock(), createBlock(resolveDynamicComponent(typeof data.is === "function" ? data.is(raw) : data.is), normalizeProps(mergeProps({ key: 0 }, _ctx.pickObject(data, { excludes: ["is"] }))), null, 16)) : createCommentVNode("v-if", true)
|
|
112
117
|
]),
|
|
113
118
|
_: 1
|
|
114
119
|
})
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { defineComponent, resolveComponent, openBlock, createElementBlock, Fragment, createVNode, withCtx,
|
|
1
|
+
import { defineComponent, resolveComponent, openBlock, createElementBlock, Fragment, createVNode, withCtx, createBlock, normalizeProps, mergeProps, resolveDynamicComponent, createCommentVNode } from 'vue';
|
|
2
2
|
import { VkfFormItemRendererTemplate } from '@vunk/form/components/form-item-renderer-template';
|
|
3
3
|
import { ElRow, ElCol } from 'element-plus';
|
|
4
4
|
import { pickObject } from '@vunk/core/shared/utils-object';
|
|
5
5
|
|
|
6
|
+
const props = {
|
|
7
|
+
data: {
|
|
8
|
+
type: Object,
|
|
9
|
+
default: () => ({})
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
6
13
|
var script = defineComponent({
|
|
7
14
|
name: "VkfFormItemRendererTemplateLayout",
|
|
15
|
+
props,
|
|
8
16
|
components: {
|
|
9
17
|
ElRow,
|
|
10
18
|
ElCol,
|
|
@@ -23,8 +31,8 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
23
31
|
const _component_ElCol = resolveComponent("ElCol");
|
|
24
32
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
25
33
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "ElRow" }, {
|
|
26
|
-
default: withCtx(({ data, Renderer, raw, k }) => [
|
|
27
|
-
|
|
34
|
+
default: withCtx(({ data: props, Renderer, raw, k, isShow }) => [
|
|
35
|
+
isShow(_ctx.data) ? (openBlock(), createBlock(_component_ElRow, normalizeProps(mergeProps({ key: 0 }, props)), {
|
|
28
36
|
default: withCtx(() => [
|
|
29
37
|
(openBlock(), createBlock(resolveDynamicComponent(Renderer), {
|
|
30
38
|
source: raw.templateSlots,
|
|
@@ -32,13 +40,13 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
32
40
|
}, null, 8, ["source", "k"]))
|
|
33
41
|
]),
|
|
34
42
|
_: 2
|
|
35
|
-
}, 1040)
|
|
43
|
+
}, 1040)) : createCommentVNode("v-if", true)
|
|
36
44
|
]),
|
|
37
45
|
_: 1
|
|
38
46
|
}),
|
|
39
47
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "ElCol" }, {
|
|
40
|
-
default: withCtx(({ data, Renderer, raw, k }) => [
|
|
41
|
-
|
|
48
|
+
default: withCtx(({ data, Renderer, raw, k, isShow }) => [
|
|
49
|
+
isShow(data) ? (openBlock(), createBlock(_component_ElCol, normalizeProps(mergeProps({ key: 0 }, data)), {
|
|
42
50
|
default: withCtx(() => [
|
|
43
51
|
(openBlock(), createBlock(resolveDynamicComponent(Renderer), {
|
|
44
52
|
source: raw.templateSlots,
|
|
@@ -46,13 +54,14 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
46
54
|
}, null, 8, ["source", "k"]))
|
|
47
55
|
]),
|
|
48
56
|
_: 2
|
|
49
|
-
}, 1040)
|
|
57
|
+
}, 1040)) : createCommentVNode("v-if", true)
|
|
50
58
|
]),
|
|
51
59
|
_: 1
|
|
52
60
|
}),
|
|
53
61
|
createVNode(_component_VkfFormItemRendererTemplate, { type: "VkfFlex" }, {
|
|
54
|
-
default: withCtx(({ data, Renderer, raw, k }) => [
|
|
55
|
-
|
|
62
|
+
default: withCtx(({ data, Renderer, raw, k, isShow }) => [
|
|
63
|
+
isShow(data) ? (openBlock(), createElementBlock("div", mergeProps({
|
|
64
|
+
key: 0,
|
|
56
65
|
class: "vkf-flex",
|
|
57
66
|
style: {
|
|
58
67
|
"justify-content": data.justify,
|
|
@@ -70,7 +79,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
70
79
|
source: raw.templateSlots,
|
|
71
80
|
k: [...k, "templateSlots"]
|
|
72
81
|
}, null, 8, ["source", "k"]))
|
|
73
|
-
], 16)
|
|
82
|
+
], 16)) : createCommentVNode("v-if", true)
|
|
74
83
|
]),
|
|
75
84
|
_: 1
|
|
76
85
|
})
|
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<{
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
data: {
|
|
3
|
+
type: import("vue").PropType<import("@vunk/core").NormalObject>;
|
|
4
|
+
default: () => {};
|
|
5
|
+
};
|
|
6
|
+
}, {
|
|
2
7
|
pickObject: <T extends import("@vunk/core").NormalObject, EX extends (keyof T)[] | undefined, KI extends keyof T>(data: T, opts?: {
|
|
3
8
|
excludes?: EX | undefined;
|
|
4
9
|
includes?: KI[] | undefined;
|
|
5
10
|
} | undefined) => { [P in EX extends (infer KE)[] ? Exclude<KI, KE> : KI]: T[P]; };
|
|
6
|
-
},
|
|
11
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
|
+
data: {
|
|
13
|
+
type: import("vue").PropType<import("@vunk/core").NormalObject>;
|
|
14
|
+
default: () => {};
|
|
15
|
+
};
|
|
16
|
+
}>>, {
|
|
17
|
+
data: import("@vunk/core").NormalObject;
|
|
18
|
+
}>;
|
|
7
19
|
export default _default;
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { VueComponentPropsType } from '@vunk/core';
|
|
2
2
|
import { ElCol, ElRow } from 'element-plus';
|
|
3
|
-
|
|
3
|
+
import { BasicSource } from '@vunk/form/shared/types/basic-source';
|
|
4
|
+
export interface ElRowSource<S> extends VueComponentPropsType<typeof ElRow>, BasicSource {
|
|
4
5
|
templateType: 'ElRow';
|
|
5
6
|
templateSlots: S[];
|
|
6
7
|
}
|
|
7
|
-
export interface ElColSource<S> extends VueComponentPropsType<typeof ElCol
|
|
8
|
+
export interface ElColSource<S> extends VueComponentPropsType<typeof ElCol>, BasicSource {
|
|
8
9
|
templateType: 'ElCol';
|
|
9
10
|
templateSlots: S[];
|
|
10
11
|
}
|
|
@@ -22,7 +23,7 @@ interface VkfFlexItem {
|
|
|
22
23
|
basis?: string | IntrinsicSizing | GlobalValues | 'revert' | 'revert-layer' | 'content';
|
|
23
24
|
overflow?: 'hidden' | 'visible' | 'scroll' | 'auto' | string;
|
|
24
25
|
}
|
|
25
|
-
export interface VkfFlexSource<S> extends VkfFlex, VkfFlexItem {
|
|
26
|
+
export interface VkfFlexSource<S> extends VkfFlex, VkfFlexItem, BasicSource {
|
|
26
27
|
templateType: 'VkfFlex';
|
|
27
28
|
templateSlots?: S[];
|
|
28
29
|
[s: string]: any;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { VkfDatePicker } from '@vunk/form/components/date-picker';
|
|
2
2
|
import type { Merge, VueComponentPropsType } from '@vunk/core';
|
|
3
|
+
import { BasicSource } from '@vunk/form/shared/types/basic-source';
|
|
3
4
|
export declare type VkfDatePickerProps<T = undefined> = Merge<VueComponentPropsType<typeof VkfDatePicker>, T>;
|
|
4
|
-
export
|
|
5
|
+
export interface VkfDatePickerSource<P extends string = string> extends VkfDatePickerProps, BasicSource {
|
|
5
6
|
prop: P;
|
|
6
7
|
templateType: 'VkfDatePicker';
|
|
7
|
-
}
|
|
8
|
+
}
|
|
@@ -10,4 +10,4 @@ export * from './input';
|
|
|
10
10
|
export * from './select';
|
|
11
11
|
export * from './switch';
|
|
12
12
|
export * from './input-number';
|
|
13
|
-
export declare type FormItemRendererSource<P = string> = VkfInputSource<P> | VkfSwitchSource<P> | VkfSelectSource<P> | VkfDatePickerSource<P> | VkfInputNumberSource<P> | ComponentSource;
|
|
13
|
+
export declare type FormItemRendererSource<P extends string = string> = VkfInputSource<P> | VkfSwitchSource<P> | VkfSelectSource<P> | VkfDatePickerSource<P> | VkfInputNumberSource<P> | ComponentSource;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { VkfInputNumber } from '@vunk/form/components/input-number';
|
|
2
2
|
import type { Merge, VueComponentPropsType } from '@vunk/core';
|
|
3
|
+
import { BasicSource } from '@vunk/form/shared/types/basic-source';
|
|
3
4
|
export declare type VkfInputNumberProps<T = undefined> = Merge<VueComponentPropsType<typeof VkfInputNumber>, T>;
|
|
4
|
-
export
|
|
5
|
+
export interface VkfInputNumberSource<P extends string = string> extends VkfInputNumberProps, BasicSource {
|
|
5
6
|
prop: P;
|
|
6
7
|
templateType: 'VkfInputNumber';
|
|
7
|
-
}
|
|
8
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { VkfInput } from '@vunk/form/components/input';
|
|
2
2
|
import type { Merge, VueComponentPropsType } from '@vunk/core';
|
|
3
|
+
import { BasicSource } from '@vunk/form/shared/types/basic-source';
|
|
3
4
|
export declare type VkfInputProps<T = undefined> = Merge<VueComponentPropsType<typeof VkfInput>, T>;
|
|
4
|
-
export
|
|
5
|
+
export interface VkfInputSource<P extends string = string> extends VkfInputProps, BasicSource {
|
|
5
6
|
prop: P;
|
|
6
7
|
templateType: 'VkfInput';
|
|
7
|
-
}
|
|
8
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { VkfSelect } from '@vunk/form/components/select';
|
|
2
2
|
import type { Merge, VueComponentPropsType } from '@vunk/core';
|
|
3
|
+
import { BasicSource } from '@vunk/form/shared/types/basic-source';
|
|
3
4
|
export declare type VkfSelectProps<T = undefined> = Merge<VueComponentPropsType<typeof VkfSelect>, T>;
|
|
4
|
-
export
|
|
5
|
+
export interface VkfSelectSource<P extends string = string> extends VkfSelectProps, BasicSource {
|
|
5
6
|
prop: P;
|
|
6
7
|
templateType: 'VkfSelect';
|
|
7
|
-
}
|
|
8
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { VkfSwitch } from '@vunk/form/components/switch';
|
|
2
2
|
import type { Merge, VueComponentPropsType } from '@vunk/core';
|
|
3
|
+
import { BasicSource } from '@vunk/form/shared/types/basic-source';
|
|
3
4
|
export declare type VkfSwitchProps<T = undefined> = Merge<VueComponentPropsType<typeof VkfSwitch>, T>;
|
|
4
|
-
export
|
|
5
|
+
export interface VkfSwitchSource<P extends string = string> extends VkfSwitchProps, BasicSource {
|
|
5
6
|
prop: P;
|
|
6
7
|
templateType: 'VkfSwitch';
|
|
7
|
-
}
|
|
8
|
+
}
|