@vunk/form 1.4.8 → 1.4.9

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.
@@ -25,7 +25,14 @@ const props = {
25
25
  type: String,
26
26
  default: ""
27
27
  },
28
- defaultModelValue: null
28
+ defaultModelValue: null,
29
+ /**
30
+ * multiple模式下,是否将选中的值转为字符串
31
+ */
32
+ stringify: {
33
+ type: Boolean,
34
+ default: false
35
+ }
29
36
  };
30
37
  const emits = {
31
38
  ...elementPlus.selectEmits
@@ -43,8 +50,32 @@ var _sfc_main = vue.defineComponent({
43
50
  setup(props2, { emit }) {
44
51
  const formItemBindProps = formItem._VkfFormItemCtx.createBindProps(props2);
45
52
  const selectBindProps = elementPlus.createSelectBindProps(props2, ["disabled", "modelValue"]);
46
- const selectOnEmits = elementPlus.createSelectOnEmits(emit);
53
+ const selectOnEmits = elementPlus.createSelectOnEmits(emit, ["update:modelValue"]);
47
54
  const readonly = composables.useComputedReadonly(props2);
55
+ const theModelValue = vue.computed({
56
+ get: () => {
57
+ if (props2.multiple && props2.stringify && typeof props2.modelValue === "string") {
58
+ return props2.modelValue ? props2.modelValue.split(",") : [];
59
+ }
60
+ return props2.modelValue ?? props2.defaultModelValue;
61
+ },
62
+ set: (modelValue) => {
63
+ if (props2.multiple && props2.stringify && Array.isArray(modelValue)) {
64
+ const value = modelValue.reduce((a, v) => {
65
+ if (typeof v === "string") {
66
+ a.push(v);
67
+ } else if (utilsObject.isNotEmptyObject(v) && v[props2.valueKey] !== void 0) {
68
+ a.push(v[props2.valueKey]);
69
+ }
70
+ return a;
71
+ }, []).join(",");
72
+ emit("update:modelValue", value);
73
+ return;
74
+ }
75
+ emit("update:modelValue", modelValue);
76
+ }
77
+ });
78
+ props2.modelValue === void 0 && props2.defaultModelValue && theModelValue.value === props2.defaultModelValue;
48
79
  const optionsFromUrl = vue.ref([]);
49
80
  const rUrlOptions = (url) => {
50
81
  if (url) {
@@ -89,7 +120,8 @@ var _sfc_main = vue.defineComponent({
89
120
  selectOnEmits,
90
121
  selectOptions,
91
122
  reshow,
92
- readonly
123
+ readonly,
124
+ theModelValue
93
125
  };
94
126
  }
95
127
  });
@@ -104,7 +136,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
104
136
  {
105
137
  default: vue.withCtx(() => [
106
138
  _ctx.reshow ? (vue.openBlock(), vue.createBlock(_component_ElSelect, vue.mergeProps({ key: 0 }, _ctx.selectBindProps, {
107
- "model-value": _ctx.defaultModelValue ?? _ctx.modelValue,
139
+ modelValue: _ctx.theModelValue,
140
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.theModelValue = $event),
108
141
  disabled: _ctx.readonly || _ctx.disabled,
109
142
  class: {
110
143
  "is-readonly": _ctx.readonly
@@ -140,7 +173,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
140
173
  ])
141
174
  };
142
175
  })
143
- ]), 1040, ["model-value", "disabled", "class"])) : vue.createCommentVNode("v-if", true),
176
+ ]), 1040, ["modelValue", "disabled", "class"])) : vue.createCommentVNode("v-if", true),
144
177
  vue.renderSlot(_ctx.$slots, "default")
145
178
  ]),
146
179
  _: 3
@@ -1,8 +1,8 @@
1
1
  import { _VkfFormItemCtx, VkfFormItem } from '@vunk/form/components/form-item';
2
2
  import { selectProps, selectEmits, createSelectBindProps, createSelectOnEmits } from '@vunk/form/shared/element-plus';
3
- import { defineComponent, ref, watch, computed, nextTick, resolveComponent, openBlock, createBlock, normalizeProps, guardReactiveProps, withCtx, mergeProps, toHandlers, createSlots, createElementBlock, Fragment, renderList, resolveDynamicComponent, createCommentVNode, renderSlot } from 'vue';
3
+ import { defineComponent, computed, ref, watch, nextTick, resolveComponent, openBlock, createBlock, normalizeProps, guardReactiveProps, withCtx, mergeProps, toHandlers, createSlots, createElementBlock, Fragment, renderList, resolveDynamicComponent, createCommentVNode, renderSlot } from 'vue';
4
4
  import { ElSelect, ElOption } from 'element-plus';
5
- import { isPlainObject } from '@vunk/core/shared/utils-object';
5
+ import { isNotEmptyObject, isPlainObject } from '@vunk/core/shared/utils-object';
6
6
  import { useComputedReadonly } from '@vunk/form/composables';
7
7
  import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
8
8
 
@@ -21,7 +21,14 @@ const props = {
21
21
  type: String,
22
22
  default: ""
23
23
  },
24
- defaultModelValue: null
24
+ defaultModelValue: null,
25
+ /**
26
+ * multiple模式下,是否将选中的值转为字符串
27
+ */
28
+ stringify: {
29
+ type: Boolean,
30
+ default: false
31
+ }
25
32
  };
26
33
  const emits = {
27
34
  ...selectEmits
@@ -39,8 +46,32 @@ var _sfc_main = defineComponent({
39
46
  setup(props2, { emit }) {
40
47
  const formItemBindProps = _VkfFormItemCtx.createBindProps(props2);
41
48
  const selectBindProps = createSelectBindProps(props2, ["disabled", "modelValue"]);
42
- const selectOnEmits = createSelectOnEmits(emit);
49
+ const selectOnEmits = createSelectOnEmits(emit, ["update:modelValue"]);
43
50
  const readonly = useComputedReadonly(props2);
51
+ const theModelValue = computed({
52
+ get: () => {
53
+ if (props2.multiple && props2.stringify && typeof props2.modelValue === "string") {
54
+ return props2.modelValue ? props2.modelValue.split(",") : [];
55
+ }
56
+ return props2.modelValue ?? props2.defaultModelValue;
57
+ },
58
+ set: (modelValue) => {
59
+ if (props2.multiple && props2.stringify && Array.isArray(modelValue)) {
60
+ const value = modelValue.reduce((a, v) => {
61
+ if (typeof v === "string") {
62
+ a.push(v);
63
+ } else if (isNotEmptyObject(v) && v[props2.valueKey] !== void 0) {
64
+ a.push(v[props2.valueKey]);
65
+ }
66
+ return a;
67
+ }, []).join(",");
68
+ emit("update:modelValue", value);
69
+ return;
70
+ }
71
+ emit("update:modelValue", modelValue);
72
+ }
73
+ });
74
+ props2.modelValue === void 0 && props2.defaultModelValue && theModelValue.value === props2.defaultModelValue;
44
75
  const optionsFromUrl = ref([]);
45
76
  const rUrlOptions = (url) => {
46
77
  if (url) {
@@ -85,7 +116,8 @@ var _sfc_main = defineComponent({
85
116
  selectOnEmits,
86
117
  selectOptions,
87
118
  reshow,
88
- readonly
119
+ readonly,
120
+ theModelValue
89
121
  };
90
122
  }
91
123
  });
@@ -100,7 +132,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
100
132
  {
101
133
  default: withCtx(() => [
102
134
  _ctx.reshow ? (openBlock(), createBlock(_component_ElSelect, mergeProps({ key: 0 }, _ctx.selectBindProps, {
103
- "model-value": _ctx.defaultModelValue ?? _ctx.modelValue,
135
+ modelValue: _ctx.theModelValue,
136
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.theModelValue = $event),
104
137
  disabled: _ctx.readonly || _ctx.disabled,
105
138
  class: {
106
139
  "is-readonly": _ctx.readonly
@@ -136,7 +169,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
136
169
  ])
137
170
  };
138
171
  })
139
- ]), 1040, ["model-value", "disabled", "class"])) : createCommentVNode("v-if", true),
172
+ ]), 1040, ["modelValue", "disabled", "class"])) : createCommentVNode("v-if", true),
140
173
  renderSlot(_ctx.$slots, "default")
141
174
  ]),
142
175
  _: 3
@@ -16,6 +16,13 @@ export declare const props: {
16
16
  default: string;
17
17
  };
18
18
  defaultModelValue: any;
19
+ /**
20
+ * multiple模式下,是否将选中的值转为字符串
21
+ */
22
+ stringify: {
23
+ type: BooleanConstructor;
24
+ default: boolean;
25
+ };
19
26
  name: StringConstructor;
20
27
  id: StringConstructor;
21
28
  modelValue: {
@@ -13,6 +13,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
13
13
  default: string;
14
14
  };
15
15
  defaultModelValue: any;
16
+ stringify: {
17
+ type: BooleanConstructor;
18
+ default: boolean;
19
+ };
16
20
  name: StringConstructor;
17
21
  id: StringConstructor;
18
22
  modelValue: {
@@ -176,7 +180,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
176
180
  valueKey: string;
177
181
  fitInputWidth: boolean;
178
182
  }>;
179
- selectOnEmits: {};
183
+ selectOnEmits: {
184
+ clear: (...e: any[]) => void;
185
+ change: (...e: any[]) => void;
186
+ focus: (...e: any[]) => void;
187
+ blur: (...e: any[]) => void;
188
+ "visible-change": (...e: any[]) => void;
189
+ "remove-tag": (...e: any[]) => void;
190
+ };
180
191
  selectOptions: import("vue").ComputedRef<(import("@vunk/core").VueComponentPropsType<import("element-plus/es/utils").SFCWithInstall<import("vue").DefineComponent<{
181
192
  value: {
182
193
  required: true;
@@ -237,6 +248,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
237
248
  })[]>;
238
249
  reshow: import("vue").Ref<boolean, boolean>;
239
250
  readonly: import("vue").ComputedRef<boolean>;
251
+ theModelValue: import("vue").WritableComputedRef<any, any>;
240
252
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
241
253
  'update:modelValue': any;
242
254
  change: any;
@@ -259,6 +271,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
259
271
  default: string;
260
272
  };
261
273
  defaultModelValue: any;
274
+ stringify: {
275
+ type: BooleanConstructor;
276
+ default: boolean;
277
+ };
262
278
  name: StringConstructor;
263
279
  id: StringConstructor;
264
280
  modelValue: {
@@ -488,6 +504,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
488
504
  valueKey: string;
489
505
  fitInputWidth: boolean;
490
506
  selectSlots: import("./types").SelectSlots;
507
+ stringify: boolean;
491
508
  }, {}, {
492
509
  VkfFormItem: {
493
510
  new (...args: any[]): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {
@@ -137,7 +137,6 @@ const selectProps = {
137
137
  type: [String, Object],
138
138
  default: arrow_down_default
139
139
  },
140
- // eslint-disable-next-line vue/require-prop-types
141
140
  tagType: { ...elementPlus.tagProps.type, default: "info" }
142
141
  };
143
142
  const selectEmits = {
@@ -135,7 +135,6 @@ const selectProps = {
135
135
  type: [String, Object],
136
136
  default: arrow_down_default
137
137
  },
138
- // eslint-disable-next-line vue/require-prop-types
139
138
  tagType: { ...tagProps.type, default: "info" }
140
139
  };
141
140
  const selectEmits = {