@vunk/form 2.14.2 → 2.14.4

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.
@@ -11,13 +11,15 @@ var templatesDefault = require('@vunk/form/components/templates-default');
11
11
  var templateInstancesProvider = require('@vunk/form/components/template-instances-provider');
12
12
  var formItemRenderer = require('@vunk/form/components/form-item-renderer');
13
13
  var rendererData = require('@vunk/form/components/renderer-data');
14
+ var _function = require('@vunk/shared/function');
15
+ var index = require('../index.cjs');
14
16
  var cloneDeep = require('../cloneDeep.cjs');
15
17
  var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
16
18
  require('../isObject.cjs');
17
19
 
18
20
  const props = {
19
21
  ...formItem._VkfFormItemCtx.props,
20
- formItems: {
22
+ columns: {
21
23
  type: Array,
22
24
  default: () => []
23
25
  },
@@ -30,7 +32,7 @@ const props = {
30
32
  default: void 0
31
33
  },
32
34
  /**
33
- * @description 是否可以splice
35
+ * @description 是否可以添加或删除
34
36
  */
35
37
  splicable: {
36
38
  type: Boolean,
@@ -39,9 +41,39 @@ const props = {
39
41
  slots: {
40
42
  type: Object,
41
43
  default: () => ({})
44
+ },
45
+ /**
46
+ * @description 保留最后一个不被删除
47
+ */
48
+ keepLast: {
49
+ type: Boolean,
50
+ default: false
51
+ },
52
+ /**
53
+ * @description 开启 form-item 的 label 上的操作区域, 在labelPosition为top时生效
54
+ */
55
+ labelActions: {
56
+ type: Boolean,
57
+ default: false
58
+ },
59
+ /**
60
+ * @description 添加记录时的默认值
61
+ */
62
+ defaultItemValue: {
63
+ type: Object,
64
+ default: () => ({})
65
+ },
66
+ /**
67
+ * @description 是否开启顶部的添加按钮
68
+ */
69
+ topSplicable: {
70
+ type: Boolean,
71
+ default: true
42
72
  }
43
73
  };
44
- const emits = {};
74
+ const emits = {
75
+ "update:modelValue": null
76
+ };
45
77
 
46
78
  var _sfc_main = /* @__PURE__ */ vue.defineComponent({
47
79
  ...{
@@ -69,7 +101,11 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
69
101
  });
70
102
  function handlePlus(index) {
71
103
  const data = cloneDeep.cloneDeep(props.modelValue);
72
- data.splice(index + 1, 0, {});
104
+ data.splice(
105
+ index + 1,
106
+ 0,
107
+ cloneDeep.cloneDeep(props.defaultItemValue)
108
+ );
73
109
  emit("update:modelValue", data);
74
110
  }
75
111
  function handleMinus(index) {
@@ -77,31 +113,43 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
77
113
  data.splice(index, 1);
78
114
  emit("update:modelValue", data);
79
115
  }
80
- const addToFirst = () => {
81
- emit("update:modelValue", [
82
- {},
83
- ...props.modelValue ?? []
84
- ]);
85
- };
86
116
  const handleFormSetData = (e) => {
87
117
  const data = cloneDeep.cloneDeep(formData.value);
88
118
  core.ensetData(data, e);
89
119
  emit("update:modelValue", core.getValue(data, props.prop));
90
120
  };
91
121
  function createTheFormItems(index) {
92
- return props.formItems.map((formItem) => {
93
- return {
122
+ return props.columns.map((formItem) => {
123
+ const parentProp = [
124
+ props.prop ?? [],
125
+ index
126
+ ].flat();
127
+ const prop = [parentProp, formItem.prop].flat();
128
+ const formItemProps = {
94
129
  readonly: readonly.value,
95
130
  ...formItem,
96
- prop: [
97
- props.prop ?? [],
98
- index,
99
- formItem.prop
100
- ].flat()
131
+ prop
101
132
  };
133
+ Reflect.deleteProperty(formItemProps, "createTemplateProps");
134
+ if (_function.isCallable(formItem.templateProps)) {
135
+ formItemProps.templateProps = () => {
136
+ return formItem.templateProps(
137
+ core.getValue(formData.value, parentProp)
138
+ );
139
+ };
140
+ }
141
+ const extraProps = formItem.createTemplateProps?.(
142
+ {
143
+ $index: index,
144
+ row: core.getValue(formData.value, parentProp)
145
+ },
146
+ formItemProps
147
+ ) ?? {};
148
+ Object.assign(formItemProps, extraProps);
149
+ return formItemProps;
102
150
  });
103
151
  }
104
- const __returned__ = { props, emit, formItemBindProps, readonly, formData, handlePlus, handleMinus, addToFirst, handleFormSetData, createTheFormItems, get VkfFormItem() {
152
+ const __returned__ = { props, emit, formItemBindProps, readonly, formData, handlePlus, handleMinus, handleFormSetData, createTheFormItems, get VkfFormItem() {
105
153
  return formItem.VkfFormItem;
106
154
  }, get ElButton() {
107
155
  return elementPlus.ElButton;
@@ -117,13 +165,18 @@ var _sfc_main = /* @__PURE__ */ vue.defineComponent({
117
165
  return formItemRenderer.VkfFormItemRenderer;
118
166
  }, get VkfRendererData() {
119
167
  return rendererData.VkfRendererData;
168
+ }, get Plus() {
169
+ return index.plus_default;
120
170
  } };
121
171
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
122
172
  return __returned__;
123
173
  }
124
174
  });
125
175
 
126
- const _hoisted_1 = { class: "vkf-card-input-collection-options" };
176
+ const _hoisted_1 = {
177
+ key: 0,
178
+ class: "vkf-card-input-collection-options"
179
+ };
127
180
  const _hoisted_2 = { class: "vkf-card-input-collection-card__footer" };
128
181
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
129
182
  return vue.openBlock(), vue.createBlock($setup["VkfTemplateInstancesProvider"], null, {
@@ -139,29 +192,25 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
139
192
  vue.createVNode(
140
193
  $setup["VkfFormItem"],
141
194
  vue.mergeProps($setup.formItemBindProps, { class: "vkf-card-input-collection" }),
142
- {
195
+ vue.createSlots({
143
196
  default: vue.withCtx(() => [
144
- vue.createElementVNode("div", _hoisted_1, [
145
- vue.renderSlot(_ctx.$slots, "options", {}, () => [
146
- _ctx.slots.options ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.slots.options), { key: 0 })) : vue.createCommentVNode("v-if", true)
147
- ]),
148
- !$setup.readonly && _ctx.splicable ? (vue.openBlock(), vue.createBlock($setup["ElButton"], {
149
- key: 0,
197
+ !$setup.readonly && _ctx.splicable && !_ctx.labelActions && _ctx.topSplicable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
198
+ vue.createVNode($setup["ElButton"], {
150
199
  type: "primary",
151
- onClick: $setup.addToFirst
200
+ onClick: _cache[1] || (_cache[1] = ($event) => $setup.handlePlus(-1))
152
201
  }, {
153
- default: vue.withCtx(() => _cache[0] || (_cache[0] = [
202
+ default: vue.withCtx(() => _cache[3] || (_cache[3] = [
154
203
  vue.createTextVNode(" \u6DFB\u52A0 ")
155
204
  ])),
156
205
  _: 1,
157
- __: [0]
158
- })) : vue.createCommentVNode("v-if", true)
159
- ]),
206
+ __: [3]
207
+ })
208
+ ])) : vue.createCommentVNode("v-if", true),
160
209
  !_ctx.modelValue?.length ? (vue.openBlock(), vue.createBlock($setup["ElEmpty"], {
161
- key: 0,
210
+ key: 1,
162
211
  class: "vkf-card-input-collection-empty"
163
212
  }, {
164
- image: vue.withCtx(() => _cache[1] || (_cache[1] = [
213
+ image: vue.withCtx(() => _cache[4] || (_cache[4] = [
165
214
  vue.createTextVNode(vue.toDisplayString(""))
166
215
  ])),
167
216
  _: 1
@@ -170,7 +219,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
170
219
  (vue.openBlock(true), vue.createElementBlock(
171
220
  vue.Fragment,
172
221
  null,
173
- vue.renderList(_ctx.modelValue, (item, index) => {
222
+ vue.renderList(_ctx.modelValue, (_, index) => {
174
223
  return vue.openBlock(), vue.createBlock(
175
224
  $setup["ElCard"],
176
225
  {
@@ -195,22 +244,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
195
244
  type: "primary",
196
245
  onClick: () => $setup.handlePlus(index)
197
246
  }, {
198
- default: vue.withCtx(() => [..._cache[2] || (_cache[2] = [
247
+ default: vue.withCtx(() => [..._cache[5] || (_cache[5] = [
199
248
  vue.createTextVNode(" \u6DFB\u52A0 ")
200
249
  ])]),
201
250
  _: 2,
202
- __: [2]
251
+ __: [5]
203
252
  }, 1032, ["onClick"]),
204
253
  vue.createVNode($setup["ElButton"], {
205
254
  type: "danger",
255
+ disabled: _ctx.modelValue.length <= 1 && $setup.props.keepLast,
206
256
  onClick: () => $setup.handleMinus(index)
207
257
  }, {
208
- default: vue.withCtx(() => [..._cache[3] || (_cache[3] = [
258
+ default: vue.withCtx(() => [..._cache[6] || (_cache[6] = [
209
259
  vue.createTextVNode(" \u5220\u9664 ")
210
260
  ])]),
211
261
  _: 2,
212
- __: [3]
213
- }, 1032, ["onClick"])
262
+ __: [6]
263
+ }, 1032, ["disabled", "onClick"])
214
264
  ])
215
265
  ]),
216
266
  key: "0"
@@ -224,11 +274,31 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
224
274
  /* KEYED_FRAGMENT */
225
275
  ))
226
276
  ]),
227
- _: 3
228
- /* FORWARDED */
229
- },
230
- 16
231
- /* FULL_PROPS */
277
+ _: 2
278
+ /* DYNAMIC */
279
+ }, [
280
+ _ctx.labelActions ? {
281
+ name: "labelActions",
282
+ fn: vue.withCtx(() => [
283
+ vue.renderSlot(_ctx.$slots, "labelActions"),
284
+ !$setup.readonly && _ctx.splicable && _ctx.topSplicable ? (vue.openBlock(), vue.createBlock($setup["ElButton"], {
285
+ key: 0,
286
+ size: "small",
287
+ icon: $setup.Plus,
288
+ onClick: _cache[0] || (_cache[0] = ($event) => $setup.handlePlus(-1))
289
+ }, {
290
+ default: vue.withCtx(() => _cache[2] || (_cache[2] = [
291
+ vue.createTextVNode(" \u6DFB\u52A0 ")
292
+ ])),
293
+ _: 1,
294
+ __: [2]
295
+ }, 8, ["icon"])) : vue.createCommentVNode("v-if", true)
296
+ ]),
297
+ key: "0"
298
+ } : void 0
299
+ ]),
300
+ 1040
301
+ /* FULL_PROPS, DYNAMIC_SLOTS */
232
302
  )
233
303
  ]),
234
304
  _: 3
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, openBlock, createBlock, withCtx, createVNode, mergeProps, createElementVNode, renderSlot, resolveDynamicComponent, createCommentVNode, createTextVNode, toDisplayString, createElementBlock, Fragment, renderList, createSlots } from 'vue';
1
+ import { defineComponent, computed, openBlock, createBlock, withCtx, createVNode, mergeProps, createSlots, createElementBlock, createTextVNode, createCommentVNode, toDisplayString, Fragment, renderList, createElementVNode, renderSlot } from 'vue';
2
2
  import { _VkfFormItemCtx, VkfFormItem } from '@vunk/form/components/form-item';
3
3
  import { useComputedReadonly } from '@vunk/form/composables';
4
4
  import { ElButton, ElCard, ElEmpty } from 'element-plus';
@@ -7,13 +7,15 @@ import { VkfTemplatesDefault } from '@vunk/form/components/templates-default';
7
7
  import { VkfTemplateInstancesProvider } from '@vunk/form/components/template-instances-provider';
8
8
  import { VkfFormItemRenderer } from '@vunk/form/components/form-item-renderer';
9
9
  import { VkfRendererData } from '@vunk/form/components/renderer-data';
10
+ import { isCallable } from '@vunk/shared/function';
11
+ import { p as plus_default } from '../index.mjs';
10
12
  import { c as cloneDeep } from '../cloneDeep.mjs';
11
13
  import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
12
14
  import '../isObject.mjs';
13
15
 
14
16
  const props = {
15
17
  ..._VkfFormItemCtx.props,
16
- formItems: {
18
+ columns: {
17
19
  type: Array,
18
20
  default: () => []
19
21
  },
@@ -26,7 +28,7 @@ const props = {
26
28
  default: void 0
27
29
  },
28
30
  /**
29
- * @description 是否可以splice
31
+ * @description 是否可以添加或删除
30
32
  */
31
33
  splicable: {
32
34
  type: Boolean,
@@ -35,9 +37,39 @@ const props = {
35
37
  slots: {
36
38
  type: Object,
37
39
  default: () => ({})
40
+ },
41
+ /**
42
+ * @description 保留最后一个不被删除
43
+ */
44
+ keepLast: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ /**
49
+ * @description 开启 form-item 的 label 上的操作区域, 在labelPosition为top时生效
50
+ */
51
+ labelActions: {
52
+ type: Boolean,
53
+ default: false
54
+ },
55
+ /**
56
+ * @description 添加记录时的默认值
57
+ */
58
+ defaultItemValue: {
59
+ type: Object,
60
+ default: () => ({})
61
+ },
62
+ /**
63
+ * @description 是否开启顶部的添加按钮
64
+ */
65
+ topSplicable: {
66
+ type: Boolean,
67
+ default: true
38
68
  }
39
69
  };
40
- const emits = {};
70
+ const emits = {
71
+ "update:modelValue": null
72
+ };
41
73
 
42
74
  var _sfc_main = /* @__PURE__ */ defineComponent({
43
75
  ...{
@@ -65,7 +97,11 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
65
97
  });
66
98
  function handlePlus(index) {
67
99
  const data = cloneDeep(props.modelValue);
68
- data.splice(index + 1, 0, {});
100
+ data.splice(
101
+ index + 1,
102
+ 0,
103
+ cloneDeep(props.defaultItemValue)
104
+ );
69
105
  emit("update:modelValue", data);
70
106
  }
71
107
  function handleMinus(index) {
@@ -73,31 +109,43 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
73
109
  data.splice(index, 1);
74
110
  emit("update:modelValue", data);
75
111
  }
76
- const addToFirst = () => {
77
- emit("update:modelValue", [
78
- {},
79
- ...props.modelValue ?? []
80
- ]);
81
- };
82
112
  const handleFormSetData = (e) => {
83
113
  const data = cloneDeep(formData.value);
84
114
  ensetData(data, e);
85
115
  emit("update:modelValue", getValue(data, props.prop));
86
116
  };
87
117
  function createTheFormItems(index) {
88
- return props.formItems.map((formItem) => {
89
- return {
118
+ return props.columns.map((formItem) => {
119
+ const parentProp = [
120
+ props.prop ?? [],
121
+ index
122
+ ].flat();
123
+ const prop = [parentProp, formItem.prop].flat();
124
+ const formItemProps = {
90
125
  readonly: readonly.value,
91
126
  ...formItem,
92
- prop: [
93
- props.prop ?? [],
94
- index,
95
- formItem.prop
96
- ].flat()
127
+ prop
97
128
  };
129
+ Reflect.deleteProperty(formItemProps, "createTemplateProps");
130
+ if (isCallable(formItem.templateProps)) {
131
+ formItemProps.templateProps = () => {
132
+ return formItem.templateProps(
133
+ getValue(formData.value, parentProp)
134
+ );
135
+ };
136
+ }
137
+ const extraProps = formItem.createTemplateProps?.(
138
+ {
139
+ $index: index,
140
+ row: getValue(formData.value, parentProp)
141
+ },
142
+ formItemProps
143
+ ) ?? {};
144
+ Object.assign(formItemProps, extraProps);
145
+ return formItemProps;
98
146
  });
99
147
  }
100
- const __returned__ = { props, emit, formItemBindProps, readonly, formData, handlePlus, handleMinus, addToFirst, handleFormSetData, createTheFormItems, get VkfFormItem() {
148
+ const __returned__ = { props, emit, formItemBindProps, readonly, formData, handlePlus, handleMinus, handleFormSetData, createTheFormItems, get VkfFormItem() {
101
149
  return VkfFormItem;
102
150
  }, get ElButton() {
103
151
  return ElButton;
@@ -113,13 +161,18 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
113
161
  return VkfFormItemRenderer;
114
162
  }, get VkfRendererData() {
115
163
  return VkfRendererData;
164
+ }, get Plus() {
165
+ return plus_default;
116
166
  } };
117
167
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
118
168
  return __returned__;
119
169
  }
120
170
  });
121
171
 
122
- const _hoisted_1 = { class: "vkf-card-input-collection-options" };
172
+ const _hoisted_1 = {
173
+ key: 0,
174
+ class: "vkf-card-input-collection-options"
175
+ };
123
176
  const _hoisted_2 = { class: "vkf-card-input-collection-card__footer" };
124
177
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
125
178
  return openBlock(), createBlock($setup["VkfTemplateInstancesProvider"], null, {
@@ -135,29 +188,25 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
135
188
  createVNode(
136
189
  $setup["VkfFormItem"],
137
190
  mergeProps($setup.formItemBindProps, { class: "vkf-card-input-collection" }),
138
- {
191
+ createSlots({
139
192
  default: withCtx(() => [
140
- createElementVNode("div", _hoisted_1, [
141
- renderSlot(_ctx.$slots, "options", {}, () => [
142
- _ctx.slots.options ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.slots.options), { key: 0 })) : createCommentVNode("v-if", true)
143
- ]),
144
- !$setup.readonly && _ctx.splicable ? (openBlock(), createBlock($setup["ElButton"], {
145
- key: 0,
193
+ !$setup.readonly && _ctx.splicable && !_ctx.labelActions && _ctx.topSplicable ? (openBlock(), createElementBlock("div", _hoisted_1, [
194
+ createVNode($setup["ElButton"], {
146
195
  type: "primary",
147
- onClick: $setup.addToFirst
196
+ onClick: _cache[1] || (_cache[1] = ($event) => $setup.handlePlus(-1))
148
197
  }, {
149
- default: withCtx(() => _cache[0] || (_cache[0] = [
198
+ default: withCtx(() => _cache[3] || (_cache[3] = [
150
199
  createTextVNode(" \u6DFB\u52A0 ")
151
200
  ])),
152
201
  _: 1,
153
- __: [0]
154
- })) : createCommentVNode("v-if", true)
155
- ]),
202
+ __: [3]
203
+ })
204
+ ])) : createCommentVNode("v-if", true),
156
205
  !_ctx.modelValue?.length ? (openBlock(), createBlock($setup["ElEmpty"], {
157
- key: 0,
206
+ key: 1,
158
207
  class: "vkf-card-input-collection-empty"
159
208
  }, {
160
- image: withCtx(() => _cache[1] || (_cache[1] = [
209
+ image: withCtx(() => _cache[4] || (_cache[4] = [
161
210
  createTextVNode(toDisplayString(""))
162
211
  ])),
163
212
  _: 1
@@ -166,7 +215,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
166
215
  (openBlock(true), createElementBlock(
167
216
  Fragment,
168
217
  null,
169
- renderList(_ctx.modelValue, (item, index) => {
218
+ renderList(_ctx.modelValue, (_, index) => {
170
219
  return openBlock(), createBlock(
171
220
  $setup["ElCard"],
172
221
  {
@@ -191,22 +240,23 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
191
240
  type: "primary",
192
241
  onClick: () => $setup.handlePlus(index)
193
242
  }, {
194
- default: withCtx(() => [..._cache[2] || (_cache[2] = [
243
+ default: withCtx(() => [..._cache[5] || (_cache[5] = [
195
244
  createTextVNode(" \u6DFB\u52A0 ")
196
245
  ])]),
197
246
  _: 2,
198
- __: [2]
247
+ __: [5]
199
248
  }, 1032, ["onClick"]),
200
249
  createVNode($setup["ElButton"], {
201
250
  type: "danger",
251
+ disabled: _ctx.modelValue.length <= 1 && $setup.props.keepLast,
202
252
  onClick: () => $setup.handleMinus(index)
203
253
  }, {
204
- default: withCtx(() => [..._cache[3] || (_cache[3] = [
254
+ default: withCtx(() => [..._cache[6] || (_cache[6] = [
205
255
  createTextVNode(" \u5220\u9664 ")
206
256
  ])]),
207
257
  _: 2,
208
- __: [3]
209
- }, 1032, ["onClick"])
258
+ __: [6]
259
+ }, 1032, ["disabled", "onClick"])
210
260
  ])
211
261
  ]),
212
262
  key: "0"
@@ -220,11 +270,31 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
220
270
  /* KEYED_FRAGMENT */
221
271
  ))
222
272
  ]),
223
- _: 3
224
- /* FORWARDED */
225
- },
226
- 16
227
- /* FULL_PROPS */
273
+ _: 2
274
+ /* DYNAMIC */
275
+ }, [
276
+ _ctx.labelActions ? {
277
+ name: "labelActions",
278
+ fn: withCtx(() => [
279
+ renderSlot(_ctx.$slots, "labelActions"),
280
+ !$setup.readonly && _ctx.splicable && _ctx.topSplicable ? (openBlock(), createBlock($setup["ElButton"], {
281
+ key: 0,
282
+ size: "small",
283
+ icon: $setup.Plus,
284
+ onClick: _cache[0] || (_cache[0] = ($event) => $setup.handlePlus(-1))
285
+ }, {
286
+ default: withCtx(() => _cache[2] || (_cache[2] = [
287
+ createTextVNode(" \u6DFB\u52A0 ")
288
+ ])),
289
+ _: 1,
290
+ __: [2]
291
+ }, 8, ["icon"])) : createCommentVNode("v-if", true)
292
+ ]),
293
+ key: "0"
294
+ } : void 0
295
+ ]),
296
+ 1040
297
+ /* FULL_PROPS, DYNAMIC_SLOTS */
228
298
  )
229
299
  ]),
230
300
  _: 3
@@ -2,7 +2,7 @@ import { PropType } from 'vue';
2
2
  import { NormalObject } from '@vunk/shared';
3
3
  import { Slots } from './types';
4
4
  export declare const props: {
5
- formItems: {
5
+ columns: {
6
6
  type: PropType<any[]>;
7
7
  default: () => any[];
8
8
  };
@@ -15,7 +15,7 @@ export declare const props: {
15
15
  default: any;
16
16
  };
17
17
  /**
18
- * @description 是否可以splice
18
+ * @description 是否可以添加或删除
19
19
  */
20
20
  splicable: {
21
21
  type: BooleanConstructor;
@@ -25,6 +25,34 @@ export declare const props: {
25
25
  type: PropType<Slots>;
26
26
  default: () => {};
27
27
  };
28
+ /**
29
+ * @description 保留最后一个不被删除
30
+ */
31
+ keepLast: {
32
+ type: BooleanConstructor;
33
+ default: boolean;
34
+ };
35
+ /**
36
+ * @description 开启 form-item 的 label 上的操作区域, 在labelPosition为top时生效
37
+ */
38
+ labelActions: {
39
+ type: BooleanConstructor;
40
+ default: boolean;
41
+ };
42
+ /**
43
+ * @description 添加记录时的默认值
44
+ */
45
+ defaultItemValue: {
46
+ type: PropType<NormalObject>;
47
+ default: () => {};
48
+ };
49
+ /**
50
+ * @description 是否开启顶部的添加按钮
51
+ */
52
+ topSplicable: {
53
+ type: BooleanConstructor;
54
+ default: boolean;
55
+ };
28
56
  required: {
29
57
  readonly type: PropType<boolean>;
30
58
  readonly required: false;
@@ -111,4 +139,6 @@ export declare const props: {
111
139
  readonly default: true;
112
140
  };
113
141
  };
114
- export declare const emits: {};
142
+ export declare const emits: {
143
+ 'update:modelValue': any;
144
+ };
@@ -1,7 +1,7 @@
1
1
  import { NormalObject } from '@vunk/shared';
2
2
  import { SetDataEvent } from '@vunk/core';
3
3
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
- formItems: {
4
+ columns: {
5
5
  type: import("vue").PropType<any[]>;
6
6
  default: () => any[];
7
7
  };
@@ -21,6 +21,22 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
21
21
  type: import("vue").PropType<import("./types").Slots>;
22
22
  default: () => {};
23
23
  };
24
+ keepLast: {
25
+ type: BooleanConstructor;
26
+ default: boolean;
27
+ };
28
+ labelActions: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
32
+ defaultItemValue: {
33
+ type: import("vue").PropType<NormalObject>;
34
+ default: () => {};
35
+ };
36
+ topSplicable: {
37
+ type: BooleanConstructor;
38
+ default: boolean;
39
+ };
24
40
  required: {
25
41
  readonly type: import("vue").PropType<boolean>;
26
42
  readonly required: false;
@@ -108,7 +124,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
108
124
  };
109
125
  }>, {
110
126
  props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
111
- formItems: {
127
+ columns: {
112
128
  type: import("vue").PropType<any[]>;
113
129
  default: () => any[];
114
130
  };
@@ -128,6 +144,22 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
128
144
  type: import("vue").PropType<import("./types").Slots>;
129
145
  default: () => {};
130
146
  };
147
+ keepLast: {
148
+ type: BooleanConstructor;
149
+ default: boolean;
150
+ };
151
+ labelActions: {
152
+ type: BooleanConstructor;
153
+ default: boolean;
154
+ };
155
+ defaultItemValue: {
156
+ type: import("vue").PropType<NormalObject>;
157
+ default: () => {};
158
+ };
159
+ topSplicable: {
160
+ type: BooleanConstructor;
161
+ default: boolean;
162
+ };
131
163
  required: {
132
164
  readonly type: import("vue").PropType<boolean>;
133
165
  readonly required: false;
@@ -213,14 +245,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
213
245
  } & {
214
246
  readonly default: true;
215
247
  };
216
- }>> & Readonly<{}> & {}>;
217
- emit: (event: string, ...args: any[]) => void;
248
+ }>> & Readonly<{
249
+ "onUpdate:modelValue"?: (...args: any[] | unknown[]) => any;
250
+ }> & {}>;
251
+ emit: ((event: "update:modelValue", ...args: unknown[]) => void) & ((event: "update:modelValue", ...args: any) => void) & ((event: "update:modelValue", ...args: any[]) => void);
218
252
  formItemBindProps: import("vue").ComputedRef<{}>;
219
253
  readonly: import("vue").ComputedRef<boolean>;
220
254
  formData: import("vue").ComputedRef<NormalObject | NormalObject[]>;
221
255
  handlePlus: (index: number) => void;
222
256
  handleMinus: (index: number) => void;
223
- addToFirst: () => void;
224
257
  handleFormSetData: (e: SetDataEvent) => void;
225
258
  createTheFormItems: (index: number) => any[];
226
259
  readonly VkfFormItem: {
@@ -900,8 +933,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
900
933
  }, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
901
934
  install(app: import("vue").App): void;
902
935
  };
903
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
904
- formItems: {
936
+ readonly Plus: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
937
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
938
+ 'update:modelValue': any;
939
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
940
+ columns: {
905
941
  type: import("vue").PropType<any[]>;
906
942
  default: () => any[];
907
943
  };
@@ -921,6 +957,22 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
921
957
  type: import("vue").PropType<import("./types").Slots>;
922
958
  default: () => {};
923
959
  };
960
+ keepLast: {
961
+ type: BooleanConstructor;
962
+ default: boolean;
963
+ };
964
+ labelActions: {
965
+ type: BooleanConstructor;
966
+ default: boolean;
967
+ };
968
+ defaultItemValue: {
969
+ type: import("vue").PropType<NormalObject>;
970
+ default: () => {};
971
+ };
972
+ topSplicable: {
973
+ type: BooleanConstructor;
974
+ default: boolean;
975
+ };
924
976
  required: {
925
977
  readonly type: import("vue").PropType<boolean>;
926
978
  readonly required: false;
@@ -1006,7 +1058,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
1006
1058
  } & {
1007
1059
  readonly default: true;
1008
1060
  };
1009
- }>> & Readonly<{}>, {
1061
+ }>> & Readonly<{
1062
+ "onUpdate:modelValue"?: (...args: any[] | unknown[]) => any;
1063
+ }>, {
1010
1064
  required: boolean;
1011
1065
  formItemSize: "default" | "small" | "large";
1012
1066
  formItemSlots: import("@vunk/form/components/form-item/src/types").FormItemSlots;
@@ -1023,7 +1077,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
1023
1077
  showMessage: boolean;
1024
1078
  slots: import("./types").Slots;
1025
1079
  modelValue: NormalObject[];
1026
- formItems: any[];
1080
+ columns: any[];
1081
+ labelActions: boolean;
1027
1082
  splicable: boolean;
1083
+ keepLast: boolean;
1084
+ defaultItemValue: NormalObject;
1085
+ topSplicable: boolean;
1028
1086
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1029
1087
  export default _default;
@@ -1,10 +1,17 @@
1
- import { AnyFunc, VueComponentPropsType } from '@vunk/shared';
1
+ import { AnyFunc, Keyof, NormalObject, VueComponentPropsType } from '@vunk/shared';
2
2
  import Core from './index.vue';
3
3
  import { BasicSource } from '@vunk/form/shared';
4
+ import { __VkfTemplatesDefault } from '@vunk/form';
4
5
  export interface Source<P = string> extends VueComponentPropsType<typeof Core>, BasicSource {
5
6
  prop?: P;
6
7
  templateType: 'VkfCardInputCollection';
7
8
  }
9
+ export type Column<R extends NormalObject = NormalObject, SourceType extends NormalObject = __VkfTemplatesDefault.CoreSource<Keyof<R>>> = SourceType & {
10
+ createTemplateProps?: (columnSlotEvent: {
11
+ row: R;
12
+ $index: number;
13
+ }, formItemProps: SourceType) => Partial<SourceType>;
14
+ };
8
15
  export interface Slots {
9
16
  options: AnyFunc;
10
17
  }
@@ -859,8 +859,8 @@ declare const _default: import("vue").DefineComponent<{}, {
859
859
  labelActions: boolean;
860
860
  defaultModelValue: any[];
861
861
  splicable: boolean;
862
- source: Record<string, any>;
863
862
  defaultItemValue: any;
863
+ source: Record<string, any>;
864
864
  keepLastRow: boolean;
865
865
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
866
866
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -848,8 +848,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
848
848
  labelActions: boolean;
849
849
  defaultModelValue: any[];
850
850
  splicable: boolean;
851
- source: Record<string, any>;
852
851
  defaultItemValue: any;
852
+ source: Record<string, any>;
853
853
  keepLastRow: boolean;
854
854
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
855
855
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "2.14.2",
3
+ "version": "2.14.4",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {