@vunk/form 2.13.2 → 2.14.0

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.
Files changed (206) hide show
  1. package/components/fieldset/index.cjs +6 -2
  2. package/components/fieldset/index.mjs +6 -2
  3. package/components/input-array/index.cjs +287 -0
  4. package/components/input-array/index.css +14 -0
  5. package/components/input-array/index.mjs +280 -0
  6. package/index.css +15 -0
  7. package/package.json +9 -1
  8. package/components/api-tables-select/index.d.ts +0 -4
  9. package/components/api-tables-select/src/ctx.d.ts +0 -374
  10. package/components/api-tables-select/src/index.vue.d.ts +0 -1335
  11. package/components/api-tables-select/src/types.d.ts +0 -19
  12. package/components/button/index.d.ts +0 -4
  13. package/components/button/src/ctx.d.ts +0 -185
  14. package/components/button/src/index.vue.d.ts +0 -813
  15. package/components/button/src/types.d.ts +0 -13
  16. package/components/card-input-collection/index.d.ts +0 -4
  17. package/components/card-input-collection/src/ctx.d.ts +0 -114
  18. package/components/card-input-collection/src/index.vue.d.ts +0 -1029
  19. package/components/card-input-collection/src/types.d.ts +0 -10
  20. package/components/cascader/index.d.ts +0 -6
  21. package/components/cascader/src/ctx.d.ts +0 -285
  22. package/components/cascader/src/index.vue.d.ts +0 -627
  23. package/components/cascader/src/types.d.ts +0 -19
  24. package/components/cascader/src/use.d.ts +0 -5
  25. package/components/checkbox/index.d.ts +0 -5
  26. package/components/checkbox/src/ctx.d.ts +0 -146
  27. package/components/checkbox/src/index.vue.d.ts +0 -1353
  28. package/components/checkbox/src/types.d.ts +0 -8
  29. package/components/color-picker/index.d.ts +0 -4
  30. package/components/color-picker/src/ctx.d.ts +0 -164
  31. package/components/color-picker/src/index.vue.d.ts +0 -366
  32. package/components/color-picker/src/types.d.ts +0 -7
  33. package/components/date-picker/index.d.ts +0 -5
  34. package/components/date-picker/src/ctx.d.ts +0 -321
  35. package/components/date-picker/src/index.vue.d.ts +0 -1423
  36. package/components/date-picker/src/types.d.ts +0 -20
  37. package/components/date-picker-range/index.d.ts +0 -4
  38. package/components/date-picker-range/src/ctx.d.ts +0 -329
  39. package/components/date-picker-range/src/index.vue.d.ts +0 -720
  40. package/components/date-picker-range/src/types.d.ts +0 -12
  41. package/components/dialog-input-collection/index.d.ts +0 -4
  42. package/components/dialog-input-collection/src/ctx.d.ts +0 -140
  43. package/components/dialog-input-collection/src/dialog-form.vue.d.ts +0 -1782
  44. package/components/dialog-input-collection/src/index.vue.d.ts +0 -3100
  45. package/components/dialog-input-collection/src/layout.vue.d.ts +0 -85
  46. package/components/dialog-input-collection/src/types.d.ts +0 -28
  47. package/components/download-plus/index.d.ts +0 -4
  48. package/components/download-plus/src/api.d.ts +0 -13
  49. package/components/download-plus/src/const.d.ts +0 -9
  50. package/components/download-plus/src/ctx.d.ts +0 -124
  51. package/components/download-plus/src/index.vue.d.ts +0 -1453
  52. package/components/download-plus/src/types.d.ts +0 -17
  53. package/components/editable-text/index.d.ts +0 -4
  54. package/components/editable-text/src/ctx.d.ts +0 -127
  55. package/components/editable-text/src/index.vue.d.ts +0 -3385
  56. package/components/editable-text/src/types.d.ts +0 -1
  57. package/components/esri-input-geojson/index.d.ts +0 -6
  58. package/components/esri-input-geojson/src/append.vue.d.ts +0 -1179
  59. package/components/esri-input-geojson/src/const.d.ts +0 -12
  60. package/components/esri-input-geojson/src/ctx.d.ts +0 -344
  61. package/components/esri-input-geojson/src/default-view.vue.d.ts +0 -133
  62. package/components/esri-input-geojson/src/index.vue.d.ts +0 -1471
  63. package/components/esri-input-geojson/src/types.d.ts +0 -22
  64. package/components/esri-input-geojson/src/viewer.vue.d.ts +0 -427
  65. package/components/fieldset/index.d.ts +0 -4
  66. package/components/fieldset/src/ctx.d.ts +0 -12
  67. package/components/fieldset/src/index.vue.d.ts +0 -23
  68. package/components/fieldset/src/types.d.ts +0 -1
  69. package/components/fieldset/src/use.d.ts +0 -5
  70. package/components/form/index.d.ts +0 -5
  71. package/components/form/src/ctx.d.ts +0 -139
  72. package/components/form/src/index.vue.d.ts +0 -1182
  73. package/components/form/src/types.d.ts +0 -25
  74. package/components/form/src/utils.d.ts +0 -15
  75. package/components/form-item/index.d.ts +0 -5
  76. package/components/form-item/src/core.vue.d.ts +0 -1847
  77. package/components/form-item/src/ctx.d.ts +0 -102
  78. package/components/form-item/src/index.vue.d.ts +0 -211
  79. package/components/form-item/src/types.d.ts +0 -10
  80. package/components/form-item-renderer/index.d.ts +0 -4
  81. package/components/form-item-renderer/src/core.vue.d.ts +0 -38
  82. package/components/form-item-renderer/src/ctx.d.ts +0 -16
  83. package/components/form-item-renderer/src/index.vue.d.ts +0 -93
  84. package/components/form-item-renderer/src/types.d.ts +0 -5
  85. package/components/form-item-renderer/src/utils.d.ts +0 -5
  86. package/components/form-item-renderer-template/index.d.ts +0 -4
  87. package/components/form-item-renderer-template/src/ctx.d.ts +0 -7
  88. package/components/form-item-renderer-template/src/index.vue.d.ts +0 -16
  89. package/components/form-item-renderer-template/src/types.d.ts +0 -55
  90. package/components/forms-provider/index.d.ts +0 -6
  91. package/components/forms-provider/src/core.d.ts +0 -6
  92. package/components/forms-provider/src/index.vue.d.ts +0 -2
  93. package/components/forms-provider/src/segment.vue.d.ts +0 -9
  94. package/components/forms-provider/src/types.d.ts +0 -10
  95. package/components/forms-provider/src/view.vue.d.ts +0 -7
  96. package/components/information/index.d.ts +0 -4
  97. package/components/information/src/ctx.d.ts +0 -13
  98. package/components/information/src/index.vue.d.ts +0 -23
  99. package/components/information/src/types.d.ts +0 -3
  100. package/components/information-collection/index.d.ts +0 -4
  101. package/components/information-collection/src/ctx.d.ts +0 -142
  102. package/components/information-collection/src/index.vue.d.ts +0 -293
  103. package/components/information-collection/src/types.d.ts +0 -6
  104. package/components/information-renderer/index.d.ts +0 -73
  105. package/components/information-tag/index.d.ts +0 -4
  106. package/components/information-tag/src/ctx.d.ts +0 -64
  107. package/components/information-tag/src/index.vue.d.ts +0 -134
  108. package/components/information-tag/src/types.d.ts +0 -1
  109. package/components/information-templates-default/index.d.ts +0 -4
  110. package/components/information-templates-default/src/ctx.d.ts +0 -2
  111. package/components/information-templates-default/src/index.vue.d.ts +0 -2
  112. package/components/information-templates-default/src/types.d.ts +0 -1
  113. package/components/input/index.d.ts +0 -5
  114. package/components/input/src/ctx.d.ts +0 -273
  115. package/components/input/src/index.vue.d.ts +0 -1234
  116. package/components/input/src/types.d.ts +0 -13
  117. package/components/input-collection/index.d.ts +0 -4
  118. package/components/input-collection/src/ctx.d.ts +0 -132
  119. package/components/input-collection/src/index.vue.d.ts +0 -1127
  120. package/components/input-collection/src/types.d.ts +0 -29
  121. package/components/input-link/index.d.ts +0 -4
  122. package/components/input-link/src/ctx.d.ts +0 -277
  123. package/components/input-link/src/index.vue.d.ts +0 -587
  124. package/components/input-link/src/types.d.ts +0 -7
  125. package/components/input-number/index.d.ts +0 -4
  126. package/components/input-number/src/ctx.d.ts +0 -211
  127. package/components/input-number/src/index.vue.d.ts +0 -852
  128. package/components/input-number/src/types.d.ts +0 -12
  129. package/components/input-tag/index.d.ts +0 -5
  130. package/components/input-tag/src/ctx.d.ts +0 -227
  131. package/components/input-tag/src/index.vue.d.ts +0 -947
  132. package/components/input-tag/src/types.d.ts +0 -22
  133. package/components/monaco-editor/index.d.ts +0 -4
  134. package/components/monaco-editor/src/ctx.d.ts +0 -110
  135. package/components/monaco-editor/src/index.vue.d.ts +0 -294
  136. package/components/monaco-editor/src/types.d.ts +0 -7
  137. package/components/radio/index.d.ts +0 -4
  138. package/components/radio/src/ctx.d.ts +0 -157
  139. package/components/radio/src/index.vue.d.ts +0 -1302
  140. package/components/radio/src/types.d.ts +0 -8
  141. package/components/renderer-data/index.d.ts +0 -4
  142. package/components/renderer-data/src/ctx.d.ts +0 -12
  143. package/components/renderer-data/src/index.vue.d.ts +0 -20
  144. package/components/renderer-data/src/types.d.ts +0 -1
  145. package/components/select/index.d.ts +0 -5
  146. package/components/select/src/ctx.d.ts +0 -220
  147. package/components/select/src/index.vue.d.ts +0 -1034
  148. package/components/select/src/types.d.ts +0 -11
  149. package/components/slider/index.d.ts +0 -4
  150. package/components/slider/src/ctx.d.ts +0 -248
  151. package/components/slider/src/index.vue.d.ts +0 -579
  152. package/components/slider/src/types.d.ts +0 -7
  153. package/components/switch/index.d.ts +0 -4
  154. package/components/switch/src/ctx.d.ts +0 -203
  155. package/components/switch/src/index.vue.d.ts +0 -886
  156. package/components/switch/src/types.d.ts +0 -8
  157. package/components/tables-select/index.d.ts +0 -5
  158. package/components/tables-select/src/ctx.d.ts +0 -420
  159. package/components/tables-select/src/index.vue.d.ts +0 -5411
  160. package/components/tables-select/src/types.d.ts +0 -9
  161. package/components/template-instances-provider/index.d.ts +0 -3
  162. package/components/template-instances-provider/src/index.vue.d.ts +0 -6
  163. package/components/templates-default/index.d.ts +0 -4
  164. package/components/templates-default/src/ctx.d.ts +0 -19
  165. package/components/templates-default/src/index.vue.d.ts +0 -187
  166. package/components/templates-default/src/types.d.ts +0 -55
  167. package/components/templates-element-plus/index.d.ts +0 -4
  168. package/components/templates-element-plus/src/ctx.d.ts +0 -9
  169. package/components/templates-element-plus/src/index.vue.d.ts +0 -301
  170. package/components/templates-element-plus/src/types.d.ts +0 -13
  171. package/components/templates-esri/index.d.ts +0 -4
  172. package/components/templates-esri/src/ctx.d.ts +0 -11
  173. package/components/templates-esri/src/index.vue.d.ts +0 -43
  174. package/components/templates-esri/src/types.d.ts +0 -2
  175. package/components/templates-layout/index.d.ts +0 -4
  176. package/components/templates-layout/src/ctx.d.ts +0 -9
  177. package/components/templates-layout/src/index.vue.d.ts +0 -446
  178. package/components/templates-layout/src/types.d.ts +0 -32
  179. package/components/templates-variant/index.d.ts +0 -4
  180. package/components/templates-variant/src/ctx.d.ts +0 -11
  181. package/components/templates-variant/src/index.vue.d.ts +0 -43
  182. package/components/templates-variant/src/types.d.ts +0 -2
  183. package/components/upload/index.d.ts +0 -5
  184. package/components/upload/src/ctx.d.ts +0 -289
  185. package/components/upload/src/file.vue.d.ts +0 -492
  186. package/components/upload/src/index.vue.d.ts +0 -1926
  187. package/components/upload/src/types.d.ts +0 -13
  188. package/components/upload-plus/index.d.ts +0 -6
  189. package/components/upload-plus/src/api.d.ts +0 -38
  190. package/components/upload-plus/src/const.d.ts +0 -9
  191. package/components/upload-plus/src/ctx.d.ts +0 -143
  192. package/components/upload-plus/src/index.vue.d.ts +0 -1770
  193. package/components/upload-plus/src/types.d.ts +0 -32
  194. package/components/van-cascader/index.d.ts +0 -4
  195. package/components/van-cascader/src/ctx.d.ts +0 -272
  196. package/components/van-cascader/src/index.vue.d.ts +0 -2093
  197. package/components/van-cascader/src/types.d.ts +0 -1
  198. package/components/var-datetime-picker/index.d.ts +0 -4
  199. package/components/var-datetime-picker/src/const.d.ts +0 -10
  200. package/components/var-datetime-picker/src/ctx.d.ts +0 -107
  201. package/components/var-datetime-picker/src/index.vue.d.ts +0 -1485
  202. package/components/var-datetime-picker/src/types.d.ts +0 -22
  203. package/components/vditor/index.d.ts +0 -4
  204. package/components/vditor/src/ctx.d.ts +0 -117
  205. package/components/vditor/src/index.vue.d.ts +0 -409
  206. package/components/vditor/src/types.d.ts +0 -7
@@ -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 formContext = vue.inject(elementPlus.formContextKey);
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 formContext = inject(formContextKey);
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 };
package/index.css CHANGED
@@ -283,6 +283,21 @@
283
283
  user-select: text;
284
284
  }
285
285
 
286
+ .vkf-input-array-delete{
287
+ cursor: pointer;
288
+ }
289
+ .vkf-input-array-options{
290
+ width: 100%;
291
+ display: flex;
292
+ justify-content: flex-end;
293
+ }
294
+ .vkf-input-array-fieldset > .el-form-item:not(:last-child) {
295
+ margin-bottom: 8px;
296
+ }
297
+ .vkf-input-array-fieldset .el-form-item__content{
298
+ flex-wrap: initial;
299
+ }
300
+
286
301
  .vkf-input-collection-options{
287
302
  width: 100%;
288
303
  display: flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "2.13.2",
3
+ "version": "2.14.0",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {
@@ -200,6 +200,11 @@
200
200
  "types": "./components/input-collection/index.d.ts",
201
201
  "require": "./components/input-collection/index.cjs"
202
202
  },
203
+ "./components/input-array": {
204
+ "import": "./components/input-array/index.mjs",
205
+ "types": "./components/input-array/index.d.ts",
206
+ "require": "./components/input-array/index.cjs"
207
+ },
203
208
  "./components/input": {
204
209
  "import": "./components/input/index.mjs",
205
210
  "types": "./components/input/index.d.ts",
@@ -362,6 +367,9 @@
362
367
  "./components/input-collection/index.css": {
363
368
  "import": "./components/input-collection/index.css"
364
369
  },
370
+ "./components/input-array/index.css": {
371
+ "import": "./components/input-array/index.css"
372
+ },
365
373
  "./components/information-templates-default/index.css": {
366
374
  "import": "./components/information-templates-default/index.css"
367
375
  },
@@ -1,4 +0,0 @@
1
- import VkfApiTablesSelect from './src/index.vue';
2
- export * as __VkfApiTablesSelect from './src/types';
3
- export { VkfApiTablesSelect, };
4
- export default VkfApiTablesSelect;