@vunk/form 2.14.7 → 2.14.8

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.
@@ -54,6 +54,13 @@ const props = {
54
54
  keepLastRow: {
55
55
  type: Boolean,
56
56
  default: true
57
+ },
58
+ /**
59
+ * @description 顶部按钮添加元素的方式是 push 还是 unshift
60
+ */
61
+ buttonAdd: {
62
+ type: String,
63
+ default: "unshift"
57
64
  }
58
65
  };
59
66
  const emits = {
@@ -77,7 +84,13 @@ var _sfc_main$1 = /* @__PURE__ */vue.defineComponent({
77
84
  const formItemBindProps = formItem._VkfFormItemCtx.createBindProps(props);
78
85
  const readonly = composables.useComputedReadonly(props);
79
86
  const addToFirst = () => {
80
- emit("update:modelValue", [cloneDeep.cloneDeep(props.defaultItemValue), ...(props.modelValue ?? [])]);
87
+ const data = props.modelValue ? [...props.modelValue] : [];
88
+ if (props.buttonAdd === "push") {
89
+ data.push(cloneDeep.cloneDeep(props.defaultItemValue));
90
+ } else {
91
+ data.unshift(cloneDeep.cloneDeep(props.defaultItemValue));
92
+ }
93
+ emit("update:modelValue", data);
81
94
  };
82
95
  if (props.modelValue === void 0 && props.defaultModelValue) {
83
96
  emit("update:modelValue", props.defaultModelValue);
@@ -50,6 +50,13 @@ const props = {
50
50
  keepLastRow: {
51
51
  type: Boolean,
52
52
  default: true
53
+ },
54
+ /**
55
+ * @description 顶部按钮添加元素的方式是 push 还是 unshift
56
+ */
57
+ buttonAdd: {
58
+ type: String,
59
+ default: "unshift"
53
60
  }
54
61
  };
55
62
  const emits = {
@@ -73,7 +80,13 @@ var _sfc_main$1 = /* @__PURE__ */defineComponent({
73
80
  const formItemBindProps = _VkfFormItemCtx.createBindProps(props);
74
81
  const readonly = useComputedReadonly(props);
75
82
  const addToFirst = () => {
76
- emit("update:modelValue", [cloneDeep(props.defaultItemValue), ...(props.modelValue ?? [])]);
83
+ const data = props.modelValue ? [...props.modelValue] : [];
84
+ if (props.buttonAdd === "push") {
85
+ data.push(cloneDeep(props.defaultItemValue));
86
+ } else {
87
+ data.unshift(cloneDeep(props.defaultItemValue));
88
+ }
89
+ emit("update:modelValue", data);
77
90
  };
78
91
  if (props.modelValue === void 0 && props.defaultModelValue) {
79
92
  emit("update:modelValue", props.defaultModelValue);
@@ -34,6 +34,13 @@ export declare const props: {
34
34
  type: BooleanConstructor;
35
35
  default: boolean;
36
36
  };
37
+ /**
38
+ * @description 顶部按钮添加元素的方式是 push 还是 unshift
39
+ */
40
+ buttonAdd: {
41
+ type: PropType<"push" | "unshift">;
42
+ default: string;
43
+ };
37
44
  required: {
38
45
  readonly type: PropType<boolean>;
39
46
  readonly required: false;
@@ -36,6 +36,10 @@ declare const _default: import("vue").DefineComponent<{}, {
36
36
  type: BooleanConstructor;
37
37
  default: boolean;
38
38
  };
39
+ buttonAdd: {
40
+ type: import("vue").PropType<"push" | "unshift">;
41
+ default: string;
42
+ };
39
43
  required: {
40
44
  readonly type: import("vue").PropType<boolean>;
41
45
  readonly required: false;
@@ -152,6 +156,10 @@ declare const _default: import("vue").DefineComponent<{}, {
152
156
  type: BooleanConstructor;
153
157
  default: boolean;
154
158
  };
159
+ buttonAdd: {
160
+ type: import("vue").PropType<"push" | "unshift">;
161
+ default: string;
162
+ };
155
163
  required: {
156
164
  readonly type: import("vue").PropType<boolean>;
157
165
  readonly required: false;
@@ -749,6 +757,10 @@ declare const _default: import("vue").DefineComponent<{}, {
749
757
  type: BooleanConstructor;
750
758
  default: boolean;
751
759
  };
760
+ buttonAdd: {
761
+ type: import("vue").PropType<"push" | "unshift">;
762
+ default: string;
763
+ };
752
764
  required: {
753
765
  readonly type: import("vue").PropType<boolean>;
754
766
  readonly required: false;
@@ -862,6 +874,7 @@ declare const _default: import("vue").DefineComponent<{}, {
862
874
  defaultItemValue: any;
863
875
  source: Record<string, any>;
864
876
  keepLastRow: boolean;
877
+ buttonAdd: "push" | "unshift";
865
878
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
866
879
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
867
880
  export default _default;
@@ -25,6 +25,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
25
25
  type: BooleanConstructor;
26
26
  default: boolean;
27
27
  };
28
+ buttonAdd: {
29
+ type: import("vue").PropType<"push" | "unshift">;
30
+ default: string;
31
+ };
28
32
  required: {
29
33
  readonly type: import("vue").PropType<boolean>;
30
34
  readonly required: false;
@@ -141,6 +145,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
141
145
  type: BooleanConstructor;
142
146
  default: boolean;
143
147
  };
148
+ buttonAdd: {
149
+ type: import("vue").PropType<"push" | "unshift">;
150
+ default: string;
151
+ };
144
152
  required: {
145
153
  readonly type: import("vue").PropType<boolean>;
146
154
  readonly required: false;
@@ -738,6 +746,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
738
746
  type: BooleanConstructor;
739
747
  default: boolean;
740
748
  };
749
+ buttonAdd: {
750
+ type: import("vue").PropType<"push" | "unshift">;
751
+ default: string;
752
+ };
741
753
  required: {
742
754
  readonly type: import("vue").PropType<boolean>;
743
755
  readonly required: false;
@@ -851,5 +863,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
851
863
  defaultItemValue: any;
852
864
  source: Record<string, any>;
853
865
  keepLastRow: boolean;
866
+ buttonAdd: "push" | "unshift";
854
867
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
855
868
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "2.14.7",
3
+ "version": "2.14.8",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {