@vunk/form 2.13.2 → 2.14.1
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/fieldset/index.cjs +6 -2
- package/components/fieldset/index.mjs +6 -2
- package/components/input-array/index.cjs +287 -0
- package/components/input-array/index.css +14 -0
- package/components/input-array/index.d.ts +5 -0
- package/components/input-array/index.mjs +280 -0
- package/components/input-array/src/ctx.d.ts +129 -0
- package/components/input-array/src/form-template.vue.d.ts +867 -0
- package/components/input-array/src/index.vue.d.ts +855 -0
- package/components/input-array/src/types.d.ts +7 -0
- package/index.css +15 -0
- package/package.json +9 -1
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var vue = require('vue');
|
|
6
6
|
var elementPlus = require('element-plus');
|
|
7
|
+
var _function = require('@vunk/shared/function');
|
|
7
8
|
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
8
9
|
|
|
9
10
|
const props = {
|
|
@@ -73,7 +74,10 @@ var _sfc_main = vue.defineComponent({
|
|
|
73
74
|
props,
|
|
74
75
|
emits,
|
|
75
76
|
setup(props2) {
|
|
76
|
-
const
|
|
77
|
+
const backupFormContext = {
|
|
78
|
+
addField: _function.noop
|
|
79
|
+
};
|
|
80
|
+
const formContext = vue.inject(elementPlus.formContextKey, backupFormContext);
|
|
77
81
|
const labelWidth = vue.computed(() => {
|
|
78
82
|
return props2.labelWidth ?? formContext.labelWidth;
|
|
79
83
|
});
|
|
@@ -83,7 +87,7 @@ var _sfc_main = vue.defineComponent({
|
|
|
83
87
|
vue.provide(
|
|
84
88
|
elementPlus.formContextKey,
|
|
85
89
|
vue.reactive({
|
|
86
|
-
...vue.toRefs(formContext),
|
|
90
|
+
...formContext === backupFormContext ? backupFormContext : vue.toRefs(formContext),
|
|
87
91
|
labelWidth,
|
|
88
92
|
labelPosition,
|
|
89
93
|
...useFormLabelWidth()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ref, computed, defineComponent, inject, provide, reactive, toRefs, openBlock, createElementBlock, renderSlot } from 'vue';
|
|
2
2
|
import { formContextKey } from 'element-plus';
|
|
3
|
+
import { noop } from '@vunk/shared/function';
|
|
3
4
|
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
4
5
|
|
|
5
6
|
const props = {
|
|
@@ -69,7 +70,10 @@ var _sfc_main = defineComponent({
|
|
|
69
70
|
props,
|
|
70
71
|
emits,
|
|
71
72
|
setup(props2) {
|
|
72
|
-
const
|
|
73
|
+
const backupFormContext = {
|
|
74
|
+
addField: noop
|
|
75
|
+
};
|
|
76
|
+
const formContext = inject(formContextKey, backupFormContext);
|
|
73
77
|
const labelWidth = computed(() => {
|
|
74
78
|
return props2.labelWidth ?? formContext.labelWidth;
|
|
75
79
|
});
|
|
@@ -79,7 +83,7 @@ var _sfc_main = defineComponent({
|
|
|
79
83
|
provide(
|
|
80
84
|
formContextKey,
|
|
81
85
|
reactive({
|
|
82
|
-
...toRefs(formContext),
|
|
86
|
+
...formContext === backupFormContext ? backupFormContext : toRefs(formContext),
|
|
83
87
|
labelWidth,
|
|
84
88
|
labelPosition,
|
|
85
89
|
...useFormLabelWidth()
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
var formItem = require('@vunk/form/components/form-item');
|
|
7
|
+
var elementPlus = require('element-plus');
|
|
8
|
+
var index = require('../index.cjs');
|
|
9
|
+
var composables = require('@vunk/form/composables');
|
|
10
|
+
var formItemRenderer = require('@vunk/form/components/form-item-renderer');
|
|
11
|
+
var templateInstancesProvider = require('@vunk/form/components/template-instances-provider');
|
|
12
|
+
var templatesDefault = require('@vunk/form/components/templates-default');
|
|
13
|
+
var fieldset = require('@vunk/form/components/fieldset');
|
|
14
|
+
var core = require('@vunk/core');
|
|
15
|
+
var rendererData = require('@vunk/form/components/renderer-data');
|
|
16
|
+
var avatar = require('@vunk/plus/components/avatar');
|
|
17
|
+
var cloneDeep = require('../cloneDeep.cjs');
|
|
18
|
+
var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
|
|
19
|
+
var formItemRendererTemplate = require('@vunk/form/components/form-item-renderer-template');
|
|
20
|
+
require('../isObject.cjs');
|
|
21
|
+
|
|
22
|
+
const props = {
|
|
23
|
+
...formItem._VkfFormItemCtx.props,
|
|
24
|
+
modelValue: {
|
|
25
|
+
type: Array,
|
|
26
|
+
default: void 0
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* @description 是否可以 splice, 添加
|
|
30
|
+
*/
|
|
31
|
+
splicable: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: true
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* @description 开启 form-item 的 label 上的操作区域, 在labelPosition为top时生效
|
|
37
|
+
*/
|
|
38
|
+
labelActions: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
defaultItemValue: null,
|
|
43
|
+
source: {
|
|
44
|
+
type: Object,
|
|
45
|
+
default: () => ({})
|
|
46
|
+
},
|
|
47
|
+
defaultModelValue: {
|
|
48
|
+
type: Array,
|
|
49
|
+
default: void 0
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* @description 保留最后一行
|
|
53
|
+
*/
|
|
54
|
+
keepLastRow: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: true
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const emits = {
|
|
60
|
+
"update:modelValue": null
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var _sfc_main$1 = /* @__PURE__ */vue.defineComponent({
|
|
64
|
+
...{
|
|
65
|
+
name: "VkfInputArray"
|
|
66
|
+
},
|
|
67
|
+
__name: "index",
|
|
68
|
+
props: props,
|
|
69
|
+
emits,
|
|
70
|
+
setup(__props, {
|
|
71
|
+
expose: __expose,
|
|
72
|
+
emit: __emit
|
|
73
|
+
}) {
|
|
74
|
+
__expose();
|
|
75
|
+
const props = __props;
|
|
76
|
+
const emit = __emit;
|
|
77
|
+
const formItemBindProps = formItem._VkfFormItemCtx.createBindProps(props);
|
|
78
|
+
const readonly = composables.useComputedReadonly(props);
|
|
79
|
+
const addToFirst = () => {
|
|
80
|
+
emit("update:modelValue", [cloneDeep.cloneDeep(props.defaultItemValue), ...(props.modelValue ?? [])]);
|
|
81
|
+
};
|
|
82
|
+
if (props.modelValue === void 0 && props.defaultModelValue) {
|
|
83
|
+
emit("update:modelValue", props.defaultModelValue);
|
|
84
|
+
}
|
|
85
|
+
const hasMinus = vue.computed(() => {
|
|
86
|
+
if (!props.keepLastRow) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return (props.modelValue ?? []).length > 1;
|
|
90
|
+
});
|
|
91
|
+
const formData = vue.computed(() => {
|
|
92
|
+
if (!props.prop || props.prop.length === 0) {
|
|
93
|
+
return props.modelValue;
|
|
94
|
+
}
|
|
95
|
+
const data = {};
|
|
96
|
+
core.ensetData(data, {
|
|
97
|
+
k: props.prop,
|
|
98
|
+
v: props.modelValue
|
|
99
|
+
});
|
|
100
|
+
return data;
|
|
101
|
+
});
|
|
102
|
+
const formItems = vue.computed(() => {
|
|
103
|
+
return props.modelValue?.map((v, index$1) => {
|
|
104
|
+
const prop = [props.prop ?? [], index$1, props.source.prop ?? []].flat();
|
|
105
|
+
return {
|
|
106
|
+
...props.source,
|
|
107
|
+
prop,
|
|
108
|
+
formItemSlots: {
|
|
109
|
+
...props.source.formItemSlots,
|
|
110
|
+
after: () => hasMinus.value && vue.createVNode(avatar.VkAvatar, vue.mergeProps({
|
|
111
|
+
"icon": index.delete_default,
|
|
112
|
+
"class": "vkf-input-array-delete",
|
|
113
|
+
"color": "var(--el-color-danger)"
|
|
114
|
+
}, {
|
|
115
|
+
onClick: () => handleMinus(index$1)
|
|
116
|
+
}), null)
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
function handleMinus(index) {
|
|
122
|
+
const data = cloneDeep.cloneDeep(props.modelValue) ?? [];
|
|
123
|
+
data.splice(index, 1);
|
|
124
|
+
emit("update:modelValue", data);
|
|
125
|
+
}
|
|
126
|
+
const handleFormSetData = e => {
|
|
127
|
+
const data = cloneDeep.cloneDeep(formData.value);
|
|
128
|
+
core.ensetData(data, e);
|
|
129
|
+
emit("update:modelValue", core.getValue(data, props.prop));
|
|
130
|
+
};
|
|
131
|
+
const __returned__ = {
|
|
132
|
+
props,
|
|
133
|
+
emit,
|
|
134
|
+
formItemBindProps,
|
|
135
|
+
readonly,
|
|
136
|
+
addToFirst,
|
|
137
|
+
hasMinus,
|
|
138
|
+
formData,
|
|
139
|
+
formItems,
|
|
140
|
+
handleMinus,
|
|
141
|
+
handleFormSetData,
|
|
142
|
+
get VkfFormItem() {
|
|
143
|
+
return formItem.VkfFormItem;
|
|
144
|
+
},
|
|
145
|
+
get ElButton() {
|
|
146
|
+
return elementPlus.ElButton;
|
|
147
|
+
},
|
|
148
|
+
get Plus() {
|
|
149
|
+
return index.plus_default;
|
|
150
|
+
},
|
|
151
|
+
get VkfFormItemRenderer() {
|
|
152
|
+
return formItemRenderer.VkfFormItemRenderer;
|
|
153
|
+
},
|
|
154
|
+
get VkfTemplateInstancesProvider() {
|
|
155
|
+
return templateInstancesProvider.VkfTemplateInstancesProvider;
|
|
156
|
+
},
|
|
157
|
+
get VkfTemplatesDefault() {
|
|
158
|
+
return templatesDefault.VkfTemplatesDefault;
|
|
159
|
+
},
|
|
160
|
+
get VkfFieldset() {
|
|
161
|
+
return fieldset.VkfFieldset;
|
|
162
|
+
},
|
|
163
|
+
get VkfRendererData() {
|
|
164
|
+
return rendererData.VkfRendererData;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
168
|
+
enumerable: false,
|
|
169
|
+
value: true
|
|
170
|
+
});
|
|
171
|
+
return __returned__;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const _hoisted_1 = {
|
|
176
|
+
key: 0,
|
|
177
|
+
class: "vkf-input-array-options"
|
|
178
|
+
};
|
|
179
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
180
|
+
return vue.openBlock(), vue.createBlock(
|
|
181
|
+
$setup["VkfFormItem"],
|
|
182
|
+
vue.normalizeProps(vue.guardReactiveProps($setup.formItemBindProps)),
|
|
183
|
+
vue.createSlots({
|
|
184
|
+
default: vue.withCtx(() => [
|
|
185
|
+
!$setup.readonly && _ctx.splicable && !_ctx.labelActions ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
186
|
+
vue.createVNode($setup["ElButton"], {
|
|
187
|
+
type: "primary",
|
|
188
|
+
onClick: $setup.addToFirst
|
|
189
|
+
}, {
|
|
190
|
+
default: vue.withCtx(() => _cache[1] || (_cache[1] = [
|
|
191
|
+
vue.createTextVNode(" \u6DFB\u52A0 ")
|
|
192
|
+
])),
|
|
193
|
+
_: 1,
|
|
194
|
+
__: [1]
|
|
195
|
+
})
|
|
196
|
+
])) : vue.createCommentVNode("v-if", true),
|
|
197
|
+
vue.createVNode($setup["VkfRendererData"], {
|
|
198
|
+
data: $setup.formData,
|
|
199
|
+
onSetData: $setup.handleFormSetData
|
|
200
|
+
}, {
|
|
201
|
+
default: vue.withCtx(() => [
|
|
202
|
+
vue.createVNode($setup["VkfTemplateInstancesProvider"], null, {
|
|
203
|
+
placeholder: vue.withCtx(() => [
|
|
204
|
+
vue.createVNode($setup["VkfTemplatesDefault"])
|
|
205
|
+
]),
|
|
206
|
+
default: vue.withCtx(() => [
|
|
207
|
+
vue.createVNode($setup["VkfFieldset"], { class: "vkf-input-array-fieldset" }, {
|
|
208
|
+
default: vue.withCtx(() => [
|
|
209
|
+
vue.createVNode($setup["VkfFormItemRenderer"], { source: $setup.formItems }, null, 8, ["source"])
|
|
210
|
+
]),
|
|
211
|
+
_: 1
|
|
212
|
+
/* STABLE */
|
|
213
|
+
})
|
|
214
|
+
]),
|
|
215
|
+
_: 1
|
|
216
|
+
/* STABLE */
|
|
217
|
+
})
|
|
218
|
+
]),
|
|
219
|
+
_: 1
|
|
220
|
+
/* STABLE */
|
|
221
|
+
}, 8, ["data"])
|
|
222
|
+
]),
|
|
223
|
+
_: 2
|
|
224
|
+
/* DYNAMIC */
|
|
225
|
+
}, [
|
|
226
|
+
!$setup.readonly && _ctx.splicable && _ctx.labelActions ? {
|
|
227
|
+
name: "labelActions",
|
|
228
|
+
fn: vue.withCtx(() => [
|
|
229
|
+
vue.createVNode($setup["ElButton"], {
|
|
230
|
+
size: "small",
|
|
231
|
+
icon: $setup.Plus,
|
|
232
|
+
onClick: $setup.addToFirst
|
|
233
|
+
}, {
|
|
234
|
+
default: vue.withCtx(() => _cache[0] || (_cache[0] = [
|
|
235
|
+
vue.createTextVNode(" \u6DFB\u52A0 ")
|
|
236
|
+
])),
|
|
237
|
+
_: 1,
|
|
238
|
+
__: [0]
|
|
239
|
+
}, 8, ["icon"])
|
|
240
|
+
]),
|
|
241
|
+
key: "0"
|
|
242
|
+
} : void 0
|
|
243
|
+
]),
|
|
244
|
+
1040
|
|
245
|
+
/* FULL_PROPS, DYNAMIC_SLOTS */
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
var VkfInputArray = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-array/src/index.vue"]]);
|
|
249
|
+
|
|
250
|
+
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
251
|
+
__name: "form-template",
|
|
252
|
+
setup(__props, { expose: __expose }) {
|
|
253
|
+
__expose();
|
|
254
|
+
const __returned__ = { get VkfFormItemRendererTemplate() {
|
|
255
|
+
return formItemRendererTemplate.VkfFormItemRendererTemplate;
|
|
256
|
+
}, Core: VkfInputArray };
|
|
257
|
+
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
258
|
+
return __returned__;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
263
|
+
return vue.openBlock(), vue.createBlock($setup["VkfFormItemRendererTemplate"], { type: "VkfInputArray" }, {
|
|
264
|
+
default: vue.withCtx(({ input, value, props }) => [
|
|
265
|
+
vue.createVNode($setup["Core"], vue.mergeProps(props, {
|
|
266
|
+
"model-value": value,
|
|
267
|
+
"onUpdate:modelValue": input
|
|
268
|
+
}), null, 16, ["model-value", "onUpdate:modelValue"])
|
|
269
|
+
]),
|
|
270
|
+
_: 1
|
|
271
|
+
/* STABLE */
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
var formTemplate = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-array/src/form-template.vue"]]);
|
|
275
|
+
|
|
276
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
277
|
+
__proto__: null
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
VkfInputArray.install = (app) => {
|
|
281
|
+
app.component(VkfInputArray.name || "VkfInputArray", VkfInputArray);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
exports.VkfInputArray = VkfInputArray;
|
|
285
|
+
exports.VkfInputArrayFormTemplate = formTemplate;
|
|
286
|
+
exports.__VkfInputArray = types;
|
|
287
|
+
exports.default = VkfInputArray;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.vkf-input-array-delete{
|
|
2
|
+
cursor: pointer;
|
|
3
|
+
}
|
|
4
|
+
.vkf-input-array-options{
|
|
5
|
+
width: 100%;
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: flex-end;
|
|
8
|
+
}
|
|
9
|
+
.vkf-input-array-fieldset > .el-form-item:not(:last-child) {
|
|
10
|
+
margin-bottom: 8px;
|
|
11
|
+
}
|
|
12
|
+
.vkf-input-array-fieldset .el-form-item__content{
|
|
13
|
+
flex-wrap: initial;
|
|
14
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { defineComponent, computed, createVNode, mergeProps, openBlock, createBlock, normalizeProps, guardReactiveProps, createSlots, withCtx, createElementBlock, createTextVNode, createCommentVNode } from 'vue';
|
|
2
|
+
import { _VkfFormItemCtx, VkfFormItem } from '@vunk/form/components/form-item';
|
|
3
|
+
import { ElButton } from 'element-plus';
|
|
4
|
+
import { d as delete_default, p as plus_default } from '../index.mjs';
|
|
5
|
+
import { useComputedReadonly } from '@vunk/form/composables';
|
|
6
|
+
import { VkfFormItemRenderer } from '@vunk/form/components/form-item-renderer';
|
|
7
|
+
import { VkfTemplateInstancesProvider } from '@vunk/form/components/template-instances-provider';
|
|
8
|
+
import { VkfTemplatesDefault } from '@vunk/form/components/templates-default';
|
|
9
|
+
import { VkfFieldset } from '@vunk/form/components/fieldset';
|
|
10
|
+
import { ensetData, getValue } from '@vunk/core';
|
|
11
|
+
import { VkfRendererData } from '@vunk/form/components/renderer-data';
|
|
12
|
+
import { VkAvatar } from '@vunk/plus/components/avatar';
|
|
13
|
+
import { c as cloneDeep } from '../cloneDeep.mjs';
|
|
14
|
+
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
15
|
+
import { VkfFormItemRendererTemplate } from '@vunk/form/components/form-item-renderer-template';
|
|
16
|
+
import '../isObject.mjs';
|
|
17
|
+
|
|
18
|
+
const props = {
|
|
19
|
+
..._VkfFormItemCtx.props,
|
|
20
|
+
modelValue: {
|
|
21
|
+
type: Array,
|
|
22
|
+
default: void 0
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* @description 是否可以 splice, 添加
|
|
26
|
+
*/
|
|
27
|
+
splicable: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: true
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* @description 开启 form-item 的 label 上的操作区域, 在labelPosition为top时生效
|
|
33
|
+
*/
|
|
34
|
+
labelActions: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
defaultItemValue: null,
|
|
39
|
+
source: {
|
|
40
|
+
type: Object,
|
|
41
|
+
default: () => ({})
|
|
42
|
+
},
|
|
43
|
+
defaultModelValue: {
|
|
44
|
+
type: Array,
|
|
45
|
+
default: void 0
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* @description 保留最后一行
|
|
49
|
+
*/
|
|
50
|
+
keepLastRow: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: true
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const emits = {
|
|
56
|
+
"update:modelValue": null
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var _sfc_main$1 = /* @__PURE__ */defineComponent({
|
|
60
|
+
...{
|
|
61
|
+
name: "VkfInputArray"
|
|
62
|
+
},
|
|
63
|
+
__name: "index",
|
|
64
|
+
props: props,
|
|
65
|
+
emits,
|
|
66
|
+
setup(__props, {
|
|
67
|
+
expose: __expose,
|
|
68
|
+
emit: __emit
|
|
69
|
+
}) {
|
|
70
|
+
__expose();
|
|
71
|
+
const props = __props;
|
|
72
|
+
const emit = __emit;
|
|
73
|
+
const formItemBindProps = _VkfFormItemCtx.createBindProps(props);
|
|
74
|
+
const readonly = useComputedReadonly(props);
|
|
75
|
+
const addToFirst = () => {
|
|
76
|
+
emit("update:modelValue", [cloneDeep(props.defaultItemValue), ...(props.modelValue ?? [])]);
|
|
77
|
+
};
|
|
78
|
+
if (props.modelValue === void 0 && props.defaultModelValue) {
|
|
79
|
+
emit("update:modelValue", props.defaultModelValue);
|
|
80
|
+
}
|
|
81
|
+
const hasMinus = computed(() => {
|
|
82
|
+
if (!props.keepLastRow) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return (props.modelValue ?? []).length > 1;
|
|
86
|
+
});
|
|
87
|
+
const formData = computed(() => {
|
|
88
|
+
if (!props.prop || props.prop.length === 0) {
|
|
89
|
+
return props.modelValue;
|
|
90
|
+
}
|
|
91
|
+
const data = {};
|
|
92
|
+
ensetData(data, {
|
|
93
|
+
k: props.prop,
|
|
94
|
+
v: props.modelValue
|
|
95
|
+
});
|
|
96
|
+
return data;
|
|
97
|
+
});
|
|
98
|
+
const formItems = computed(() => {
|
|
99
|
+
return props.modelValue?.map((v, index) => {
|
|
100
|
+
const prop = [props.prop ?? [], index, props.source.prop ?? []].flat();
|
|
101
|
+
return {
|
|
102
|
+
...props.source,
|
|
103
|
+
prop,
|
|
104
|
+
formItemSlots: {
|
|
105
|
+
...props.source.formItemSlots,
|
|
106
|
+
after: () => hasMinus.value && createVNode(VkAvatar, mergeProps({
|
|
107
|
+
"icon": delete_default,
|
|
108
|
+
"class": "vkf-input-array-delete",
|
|
109
|
+
"color": "var(--el-color-danger)"
|
|
110
|
+
}, {
|
|
111
|
+
onClick: () => handleMinus(index)
|
|
112
|
+
}), null)
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
function handleMinus(index) {
|
|
118
|
+
const data = cloneDeep(props.modelValue) ?? [];
|
|
119
|
+
data.splice(index, 1);
|
|
120
|
+
emit("update:modelValue", data);
|
|
121
|
+
}
|
|
122
|
+
const handleFormSetData = e => {
|
|
123
|
+
const data = cloneDeep(formData.value);
|
|
124
|
+
ensetData(data, e);
|
|
125
|
+
emit("update:modelValue", getValue(data, props.prop));
|
|
126
|
+
};
|
|
127
|
+
const __returned__ = {
|
|
128
|
+
props,
|
|
129
|
+
emit,
|
|
130
|
+
formItemBindProps,
|
|
131
|
+
readonly,
|
|
132
|
+
addToFirst,
|
|
133
|
+
hasMinus,
|
|
134
|
+
formData,
|
|
135
|
+
formItems,
|
|
136
|
+
handleMinus,
|
|
137
|
+
handleFormSetData,
|
|
138
|
+
get VkfFormItem() {
|
|
139
|
+
return VkfFormItem;
|
|
140
|
+
},
|
|
141
|
+
get ElButton() {
|
|
142
|
+
return ElButton;
|
|
143
|
+
},
|
|
144
|
+
get Plus() {
|
|
145
|
+
return plus_default;
|
|
146
|
+
},
|
|
147
|
+
get VkfFormItemRenderer() {
|
|
148
|
+
return VkfFormItemRenderer;
|
|
149
|
+
},
|
|
150
|
+
get VkfTemplateInstancesProvider() {
|
|
151
|
+
return VkfTemplateInstancesProvider;
|
|
152
|
+
},
|
|
153
|
+
get VkfTemplatesDefault() {
|
|
154
|
+
return VkfTemplatesDefault;
|
|
155
|
+
},
|
|
156
|
+
get VkfFieldset() {
|
|
157
|
+
return VkfFieldset;
|
|
158
|
+
},
|
|
159
|
+
get VkfRendererData() {
|
|
160
|
+
return VkfRendererData;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
Object.defineProperty(__returned__, "__isScriptSetup", {
|
|
164
|
+
enumerable: false,
|
|
165
|
+
value: true
|
|
166
|
+
});
|
|
167
|
+
return __returned__;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
const _hoisted_1 = {
|
|
172
|
+
key: 0,
|
|
173
|
+
class: "vkf-input-array-options"
|
|
174
|
+
};
|
|
175
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
176
|
+
return openBlock(), createBlock(
|
|
177
|
+
$setup["VkfFormItem"],
|
|
178
|
+
normalizeProps(guardReactiveProps($setup.formItemBindProps)),
|
|
179
|
+
createSlots({
|
|
180
|
+
default: withCtx(() => [
|
|
181
|
+
!$setup.readonly && _ctx.splicable && !_ctx.labelActions ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
182
|
+
createVNode($setup["ElButton"], {
|
|
183
|
+
type: "primary",
|
|
184
|
+
onClick: $setup.addToFirst
|
|
185
|
+
}, {
|
|
186
|
+
default: withCtx(() => _cache[1] || (_cache[1] = [
|
|
187
|
+
createTextVNode(" \u6DFB\u52A0 ")
|
|
188
|
+
])),
|
|
189
|
+
_: 1,
|
|
190
|
+
__: [1]
|
|
191
|
+
})
|
|
192
|
+
])) : createCommentVNode("v-if", true),
|
|
193
|
+
createVNode($setup["VkfRendererData"], {
|
|
194
|
+
data: $setup.formData,
|
|
195
|
+
onSetData: $setup.handleFormSetData
|
|
196
|
+
}, {
|
|
197
|
+
default: withCtx(() => [
|
|
198
|
+
createVNode($setup["VkfTemplateInstancesProvider"], null, {
|
|
199
|
+
placeholder: withCtx(() => [
|
|
200
|
+
createVNode($setup["VkfTemplatesDefault"])
|
|
201
|
+
]),
|
|
202
|
+
default: withCtx(() => [
|
|
203
|
+
createVNode($setup["VkfFieldset"], { class: "vkf-input-array-fieldset" }, {
|
|
204
|
+
default: withCtx(() => [
|
|
205
|
+
createVNode($setup["VkfFormItemRenderer"], { source: $setup.formItems }, null, 8, ["source"])
|
|
206
|
+
]),
|
|
207
|
+
_: 1
|
|
208
|
+
/* STABLE */
|
|
209
|
+
})
|
|
210
|
+
]),
|
|
211
|
+
_: 1
|
|
212
|
+
/* STABLE */
|
|
213
|
+
})
|
|
214
|
+
]),
|
|
215
|
+
_: 1
|
|
216
|
+
/* STABLE */
|
|
217
|
+
}, 8, ["data"])
|
|
218
|
+
]),
|
|
219
|
+
_: 2
|
|
220
|
+
/* DYNAMIC */
|
|
221
|
+
}, [
|
|
222
|
+
!$setup.readonly && _ctx.splicable && _ctx.labelActions ? {
|
|
223
|
+
name: "labelActions",
|
|
224
|
+
fn: withCtx(() => [
|
|
225
|
+
createVNode($setup["ElButton"], {
|
|
226
|
+
size: "small",
|
|
227
|
+
icon: $setup.Plus,
|
|
228
|
+
onClick: $setup.addToFirst
|
|
229
|
+
}, {
|
|
230
|
+
default: withCtx(() => _cache[0] || (_cache[0] = [
|
|
231
|
+
createTextVNode(" \u6DFB\u52A0 ")
|
|
232
|
+
])),
|
|
233
|
+
_: 1,
|
|
234
|
+
__: [0]
|
|
235
|
+
}, 8, ["icon"])
|
|
236
|
+
]),
|
|
237
|
+
key: "0"
|
|
238
|
+
} : void 0
|
|
239
|
+
]),
|
|
240
|
+
1040
|
|
241
|
+
/* FULL_PROPS, DYNAMIC_SLOTS */
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
var VkfInputArray = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-array/src/index.vue"]]);
|
|
245
|
+
|
|
246
|
+
var _sfc_main = /* @__PURE__ */ defineComponent({
|
|
247
|
+
__name: "form-template",
|
|
248
|
+
setup(__props, { expose: __expose }) {
|
|
249
|
+
__expose();
|
|
250
|
+
const __returned__ = { get VkfFormItemRendererTemplate() {
|
|
251
|
+
return VkfFormItemRendererTemplate;
|
|
252
|
+
}, Core: VkfInputArray };
|
|
253
|
+
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
254
|
+
return __returned__;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
259
|
+
return openBlock(), createBlock($setup["VkfFormItemRendererTemplate"], { type: "VkfInputArray" }, {
|
|
260
|
+
default: withCtx(({ input, value, props }) => [
|
|
261
|
+
createVNode($setup["Core"], mergeProps(props, {
|
|
262
|
+
"model-value": value,
|
|
263
|
+
"onUpdate:modelValue": input
|
|
264
|
+
}), null, 16, ["model-value", "onUpdate:modelValue"])
|
|
265
|
+
]),
|
|
266
|
+
_: 1
|
|
267
|
+
/* STABLE */
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
var formTemplate = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-array/src/form-template.vue"]]);
|
|
271
|
+
|
|
272
|
+
var types = /*#__PURE__*/Object.freeze({
|
|
273
|
+
__proto__: null
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
VkfInputArray.install = (app) => {
|
|
277
|
+
app.component(VkfInputArray.name || "VkfInputArray", VkfInputArray);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
export { VkfInputArray, formTemplate as VkfInputArrayFormTemplate, types as __VkfInputArray, VkfInputArray as default };
|