@vunk/form 2.14.14 → 2.14.16

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.
@@ -60,6 +60,24 @@ const props = {
60
60
  defaultItemValue: {
61
61
  type: Object,
62
62
  default: () => ({})
63
+ },
64
+ /**
65
+ * @description 保留最后一个不被删除
66
+ */
67
+ keepLast: {
68
+ type: Boolean,
69
+ default: false
70
+ },
71
+ /**
72
+ * @description 是否开启顶部的添加按钮
73
+ */
74
+ topSplicable: {
75
+ type: Boolean,
76
+ default: true
77
+ },
78
+ slots: {
79
+ type: Object,
80
+ default: () => ({})
63
81
  }
64
82
  };
65
83
  const emits = {
@@ -67,12 +85,11 @@ const emits = {
67
85
  };
68
86
 
69
87
  const ROW_KEY = "_row_key";
70
- var _sfc_main = /* @__PURE__ */vue.defineComponent({
88
+ var _sfc_main$1 = /* @__PURE__ */vue.defineComponent({
71
89
  ...{
72
- name: "VkfInputCollection",
73
90
  inheritAttrs: false
74
91
  },
75
- __name: "index",
92
+ __name: "core",
76
93
  props: props,
77
94
  emits,
78
95
  setup(__props, {
@@ -178,6 +195,7 @@ var _sfc_main = /* @__PURE__ */vue.defineComponent({
178
195
  "type": "primary",
179
196
  "link": true,
180
197
  "circle": true,
198
+ "disabled": props.modelValue.length <= 1 && props.keepLast,
181
199
  "onClick": () => handleMinus($index)
182
200
  }, null)])
183
201
  }));
@@ -195,6 +213,9 @@ var _sfc_main = /* @__PURE__ */vue.defineComponent({
195
213
  setExpandRowKeys([]);
196
214
  }
197
215
  function handleMinus(index) {
216
+ if (props.keepLast && props.modelValue.length <= 1) {
217
+ return;
218
+ }
198
219
  const data = cloneDeep.cloneDeep(props.modelValue);
199
220
  data.splice(index, 1);
200
221
  emit("update:modelValue", data);
@@ -308,31 +329,31 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
308
329
  vue.createVNode($setup["VkfTemplatesDefault"])
309
330
  ]),
310
331
  default: vue.withCtx(() => [
311
- vue.createVNode($setup["VkfRendererData"], {
312
- data: $setup.formData,
313
- onSetData: $setup.handleFormSetData
314
- }, {
315
- default: vue.withCtx(() => [
316
- vue.createVNode(
317
- $setup["VkfFormItem"],
318
- vue.normalizeProps(vue.guardReactiveProps({
319
- ...$setup.formItemBindProps,
320
- ..._ctx.$attrs
321
- })),
322
- vue.createSlots({
332
+ vue.createVNode(
333
+ $setup["VkfFormItem"],
334
+ vue.normalizeProps(vue.guardReactiveProps({
335
+ ...$setup.formItemBindProps,
336
+ ..._ctx.$attrs
337
+ })),
338
+ vue.createSlots({
339
+ default: vue.withCtx(() => [
340
+ !$setup.readonly && _ctx.splicable && !_ctx.labelActions && _ctx.topSplicable ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
341
+ vue.createVNode($setup["ElButton"], {
342
+ type: "primary",
343
+ onClick: $setup.addToFirst
344
+ }, {
345
+ default: vue.withCtx(() => _cache[1] || (_cache[1] = [
346
+ vue.createTextVNode(" \u6DFB\u52A0 ")
347
+ ])),
348
+ _: 1,
349
+ __: [1]
350
+ })
351
+ ])) : vue.createCommentVNode("v-if", true),
352
+ vue.createVNode($setup["VkfRendererData"], {
353
+ data: $setup.formData,
354
+ onSetData: $setup.handleFormSetData
355
+ }, {
323
356
  default: vue.withCtx(() => [
324
- !$setup.readonly && _ctx.splicable && !_ctx.labelActions ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
325
- vue.createVNode($setup["ElButton"], {
326
- type: "primary",
327
- onClick: $setup.addToFirst
328
- }, {
329
- default: vue.withCtx(() => _cache[1] || (_cache[1] = [
330
- vue.createTextVNode(" \u6DFB\u52A0 ")
331
- ])),
332
- _: 1,
333
- __: [1]
334
- })
335
- ])) : vue.createCommentVNode("v-if", true),
336
357
  vue.createVNode($setup["ElTable"], {
337
358
  data: $setup.tableData,
338
359
  class: "vkf-input-collection-table",
@@ -348,42 +369,60 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
348
369
  /* STABLE */
349
370
  }, 8, ["data", "expand-row-keys"])
350
371
  ]),
351
- _: 2
352
- /* DYNAMIC */
353
- }, [
354
- !$setup.readonly && _ctx.splicable && _ctx.labelActions ? {
355
- name: "labelActions",
356
- fn: vue.withCtx(() => [
357
- vue.renderSlot(_ctx.$slots, "labelActions"),
358
- vue.createVNode($setup["ElButton"], {
359
- size: "small",
360
- icon: $setup.Plus,
361
- onClick: $setup.addToFirst
362
- }, {
363
- default: vue.withCtx(() => _cache[0] || (_cache[0] = [
364
- vue.createTextVNode(" \u6DFB\u52A0 ")
365
- ])),
366
- _: 1,
367
- __: [0]
368
- }, 8, ["icon"])
369
- ]),
370
- key: "0"
371
- } : void 0
372
+ _: 1
373
+ /* STABLE */
374
+ }, 8, ["data"])
375
+ ]),
376
+ _: 2
377
+ /* DYNAMIC */
378
+ }, [
379
+ _ctx.labelActions ? {
380
+ name: "labelActions",
381
+ fn: vue.withCtx(() => [
382
+ vue.renderSlot(_ctx.$slots, "labelActions"),
383
+ !$setup.readonly && _ctx.splicable && _ctx.topSplicable ? (vue.openBlock(), vue.createBlock($setup["ElButton"], {
384
+ key: 0,
385
+ size: "small",
386
+ icon: $setup.Plus,
387
+ onClick: $setup.addToFirst
388
+ }, {
389
+ default: vue.withCtx(() => _cache[0] || (_cache[0] = [
390
+ vue.createTextVNode(" \u6DFB\u52A0 ")
391
+ ])),
392
+ _: 1,
393
+ __: [0]
394
+ }, 8, ["icon"])) : vue.createCommentVNode("v-if", true)
372
395
  ]),
373
- 1040
374
- /* FULL_PROPS, DYNAMIC_SLOTS */
375
- )
396
+ key: "0"
397
+ } : void 0
376
398
  ]),
377
- _: 3
378
- /* FORWARDED */
379
- }, 8, ["data"]),
399
+ 1040
400
+ /* FULL_PROPS, DYNAMIC_SLOTS */
401
+ ),
380
402
  vue.renderSlot(_ctx.$slots, "default")
381
403
  ]),
382
404
  _: 3
383
405
  /* FORWARDED */
384
406
  });
385
407
  }
386
- var VkfInputCollection = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-collection/src/index.vue"]]);
408
+ var Core = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-collection/src/core.vue"]]);
409
+
410
+ var _sfc_main = vue.defineComponent({
411
+ name: "VkfInputCollection",
412
+ props,
413
+ emits,
414
+ setup(props2, { emit, slots }) {
415
+ return () => vue.h(Core, {
416
+ ...props2,
417
+ "onUpdate:modelValue": (v) => emit("update:modelValue", v)
418
+ }, {
419
+ ...props2.slots,
420
+ ...slots
421
+ });
422
+ }
423
+ });
424
+
425
+ var VkfInputCollection = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-collection/src/index.vue"]]);
387
426
 
388
427
  var types = /*#__PURE__*/Object.freeze({
389
428
  __proto__: null
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, createVNode, Fragment, ref, openBlock, createBlock, withCtx, normalizeProps, guardReactiveProps, createSlots, createElementBlock, createTextVNode, createCommentVNode, renderSlot } from 'vue';
1
+ import { defineComponent, computed, createVNode, Fragment, ref, openBlock, createBlock, withCtx, normalizeProps, guardReactiveProps, createSlots, createElementBlock, createTextVNode, createCommentVNode, renderSlot, h } from 'vue';
2
2
  import { p as plus_default, g as minus_default } from '../index.mjs';
3
3
  import { ensetData, getValue } from '@vunk/core';
4
4
  import { VkfFieldset } from '@vunk/form/components/fieldset';
@@ -56,6 +56,24 @@ const props = {
56
56
  defaultItemValue: {
57
57
  type: Object,
58
58
  default: () => ({})
59
+ },
60
+ /**
61
+ * @description 保留最后一个不被删除
62
+ */
63
+ keepLast: {
64
+ type: Boolean,
65
+ default: false
66
+ },
67
+ /**
68
+ * @description 是否开启顶部的添加按钮
69
+ */
70
+ topSplicable: {
71
+ type: Boolean,
72
+ default: true
73
+ },
74
+ slots: {
75
+ type: Object,
76
+ default: () => ({})
59
77
  }
60
78
  };
61
79
  const emits = {
@@ -63,12 +81,11 @@ const emits = {
63
81
  };
64
82
 
65
83
  const ROW_KEY = "_row_key";
66
- var _sfc_main = /* @__PURE__ */defineComponent({
84
+ var _sfc_main$1 = /* @__PURE__ */defineComponent({
67
85
  ...{
68
- name: "VkfInputCollection",
69
86
  inheritAttrs: false
70
87
  },
71
- __name: "index",
88
+ __name: "core",
72
89
  props: props,
73
90
  emits,
74
91
  setup(__props, {
@@ -174,6 +191,7 @@ var _sfc_main = /* @__PURE__ */defineComponent({
174
191
  "type": "primary",
175
192
  "link": true,
176
193
  "circle": true,
194
+ "disabled": props.modelValue.length <= 1 && props.keepLast,
177
195
  "onClick": () => handleMinus($index)
178
196
  }, null)])
179
197
  }));
@@ -191,6 +209,9 @@ var _sfc_main = /* @__PURE__ */defineComponent({
191
209
  setExpandRowKeys([]);
192
210
  }
193
211
  function handleMinus(index) {
212
+ if (props.keepLast && props.modelValue.length <= 1) {
213
+ return;
214
+ }
194
215
  const data = cloneDeep(props.modelValue);
195
216
  data.splice(index, 1);
196
217
  emit("update:modelValue", data);
@@ -304,31 +325,31 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
304
325
  createVNode($setup["VkfTemplatesDefault"])
305
326
  ]),
306
327
  default: withCtx(() => [
307
- createVNode($setup["VkfRendererData"], {
308
- data: $setup.formData,
309
- onSetData: $setup.handleFormSetData
310
- }, {
311
- default: withCtx(() => [
312
- createVNode(
313
- $setup["VkfFormItem"],
314
- normalizeProps(guardReactiveProps({
315
- ...$setup.formItemBindProps,
316
- ..._ctx.$attrs
317
- })),
318
- createSlots({
328
+ createVNode(
329
+ $setup["VkfFormItem"],
330
+ normalizeProps(guardReactiveProps({
331
+ ...$setup.formItemBindProps,
332
+ ..._ctx.$attrs
333
+ })),
334
+ createSlots({
335
+ default: withCtx(() => [
336
+ !$setup.readonly && _ctx.splicable && !_ctx.labelActions && _ctx.topSplicable ? (openBlock(), createElementBlock("div", _hoisted_1, [
337
+ createVNode($setup["ElButton"], {
338
+ type: "primary",
339
+ onClick: $setup.addToFirst
340
+ }, {
341
+ default: withCtx(() => _cache[1] || (_cache[1] = [
342
+ createTextVNode(" \u6DFB\u52A0 ")
343
+ ])),
344
+ _: 1,
345
+ __: [1]
346
+ })
347
+ ])) : createCommentVNode("v-if", true),
348
+ createVNode($setup["VkfRendererData"], {
349
+ data: $setup.formData,
350
+ onSetData: $setup.handleFormSetData
351
+ }, {
319
352
  default: withCtx(() => [
320
- !$setup.readonly && _ctx.splicable && !_ctx.labelActions ? (openBlock(), createElementBlock("div", _hoisted_1, [
321
- createVNode($setup["ElButton"], {
322
- type: "primary",
323
- onClick: $setup.addToFirst
324
- }, {
325
- default: withCtx(() => _cache[1] || (_cache[1] = [
326
- createTextVNode(" \u6DFB\u52A0 ")
327
- ])),
328
- _: 1,
329
- __: [1]
330
- })
331
- ])) : createCommentVNode("v-if", true),
332
353
  createVNode($setup["ElTable"], {
333
354
  data: $setup.tableData,
334
355
  class: "vkf-input-collection-table",
@@ -344,42 +365,60 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
344
365
  /* STABLE */
345
366
  }, 8, ["data", "expand-row-keys"])
346
367
  ]),
347
- _: 2
348
- /* DYNAMIC */
349
- }, [
350
- !$setup.readonly && _ctx.splicable && _ctx.labelActions ? {
351
- name: "labelActions",
352
- fn: withCtx(() => [
353
- renderSlot(_ctx.$slots, "labelActions"),
354
- createVNode($setup["ElButton"], {
355
- size: "small",
356
- icon: $setup.Plus,
357
- onClick: $setup.addToFirst
358
- }, {
359
- default: withCtx(() => _cache[0] || (_cache[0] = [
360
- createTextVNode(" \u6DFB\u52A0 ")
361
- ])),
362
- _: 1,
363
- __: [0]
364
- }, 8, ["icon"])
365
- ]),
366
- key: "0"
367
- } : void 0
368
+ _: 1
369
+ /* STABLE */
370
+ }, 8, ["data"])
371
+ ]),
372
+ _: 2
373
+ /* DYNAMIC */
374
+ }, [
375
+ _ctx.labelActions ? {
376
+ name: "labelActions",
377
+ fn: withCtx(() => [
378
+ renderSlot(_ctx.$slots, "labelActions"),
379
+ !$setup.readonly && _ctx.splicable && _ctx.topSplicable ? (openBlock(), createBlock($setup["ElButton"], {
380
+ key: 0,
381
+ size: "small",
382
+ icon: $setup.Plus,
383
+ onClick: $setup.addToFirst
384
+ }, {
385
+ default: withCtx(() => _cache[0] || (_cache[0] = [
386
+ createTextVNode(" \u6DFB\u52A0 ")
387
+ ])),
388
+ _: 1,
389
+ __: [0]
390
+ }, 8, ["icon"])) : createCommentVNode("v-if", true)
368
391
  ]),
369
- 1040
370
- /* FULL_PROPS, DYNAMIC_SLOTS */
371
- )
392
+ key: "0"
393
+ } : void 0
372
394
  ]),
373
- _: 3
374
- /* FORWARDED */
375
- }, 8, ["data"]),
395
+ 1040
396
+ /* FULL_PROPS, DYNAMIC_SLOTS */
397
+ ),
376
398
  renderSlot(_ctx.$slots, "default")
377
399
  ]),
378
400
  _: 3
379
401
  /* FORWARDED */
380
402
  });
381
403
  }
382
- var VkfInputCollection = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-collection/src/index.vue"]]);
404
+ var Core = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-collection/src/core.vue"]]);
405
+
406
+ var _sfc_main = defineComponent({
407
+ name: "VkfInputCollection",
408
+ props,
409
+ emits,
410
+ setup(props2, { emit, slots }) {
411
+ return () => h(Core, {
412
+ ...props2,
413
+ "onUpdate:modelValue": (v) => emit("update:modelValue", v)
414
+ }, {
415
+ ...props2.slots,
416
+ ...slots
417
+ });
418
+ }
419
+ });
420
+
421
+ var VkfInputCollection = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/input-collection/src/index.vue"]]);
383
422
 
384
423
  var types = /*#__PURE__*/Object.freeze({
385
424
  __proto__: null