@vunk/form 0.0.0-alpha.1 → 0.0.0-alpha.5

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 (119) hide show
  1. package/components/config/src/ctx.d.ts +1 -1
  2. package/components/config-renderer/src/ctx.d.ts +1 -1
  3. package/components/confirm-input/index.css +9 -9
  4. package/components/confirm-input/index.js +3 -3
  5. package/components/confirm-input/src/ctx.d.ts +79 -37
  6. package/components/confirm-input/src/index.vue.d.ts +210 -131
  7. package/components/drop-wrapper/index.js +2 -2
  8. package/components/drop-wrapper/src/index.vue.d.ts +2 -2
  9. package/components/form/index.js +39 -4
  10. package/components/form/src/ctx.d.ts +21 -16
  11. package/components/form/src/index.vue.d.ts +51 -43
  12. package/components/form-item/index.d.ts +5 -0
  13. package/components/form-item/index.js +71 -0
  14. package/components/form-item/src/ctx.d.ts +44 -0
  15. package/components/form-item/src/index.vue.d.ts +102 -0
  16. package/components/form-item/src/types.d.ts +6 -0
  17. package/components/ground/index.css +64 -26
  18. package/components/ground/index.js +461 -104
  19. package/components/ground/src/ground-config/src/index.vue.d.ts +4 -1
  20. package/components/ground/src/ground-main/src/editing-wrapper.vue.d.ts +35 -5
  21. package/components/ground/src/ground-main/src/index.vue.d.ts +19 -5
  22. package/components/ground/src/ground-widget/src/form-item-widget/src/index.vue.d.ts +994 -138
  23. package/components/ground/src/ground-widget/src/index.vue.d.ts +21 -5
  24. package/components/ground/src/ground-widget/src/static.d.ts +2 -2
  25. package/components/ground/src/index.vue.d.ts +41 -8
  26. package/components/input/index.js +12 -32
  27. package/components/input/src/ctx.d.ts +81 -43
  28. package/components/input/src/index.vue.d.ts +209 -136
  29. package/components/input/src/types.d.ts +1 -6
  30. package/components/input-config/index.js +102 -23
  31. package/components/input-config/src/ctx.d.ts +19 -15
  32. package/components/input-config/src/index.vue.d.ts +70 -50
  33. package/components/rules-config/index.d.ts +3 -0
  34. package/components/rules-config/index.js +63 -0
  35. package/components/rules-config/src/ctx.d.ts +38 -0
  36. package/components/rules-config/src/index.vue.d.ts +113 -0
  37. package/components/select/index.d.ts +4 -0
  38. package/components/select/index.js +89 -0
  39. package/components/select/src/ctx.d.ts +193 -0
  40. package/components/select/src/index.vue.d.ts +589 -0
  41. package/components/select/src/types.d.ts +5 -0
  42. package/components/select-config/index.d.ts +4 -0
  43. package/components/select-config/index.js +43 -0
  44. package/components/select-config/src/ctx.d.ts +11 -0
  45. package/components/select-config/src/index.vue.d.ts +18 -0
  46. package/components/select-config/src/types.d.ts +3 -0
  47. package/components/switch/index.d.ts +4 -0
  48. package/components/switch/index.js +61 -0
  49. package/components/switch/src/ctx.d.ts +62 -0
  50. package/components/switch/src/index.vue.d.ts +184 -0
  51. package/components/switch/src/types.d.ts +3 -0
  52. package/full-entry/main.d.ts +6 -0
  53. package/index.css +73 -35
  54. package/index.d.ts +34 -23
  55. package/index.esm.js +6 -0
  56. package/package.json +1 -1
  57. package/shared/element-plus/ctx/index.d.ts +8 -4
  58. package/shared/element-plus/ctx/index.js +1267 -2
  59. package/shared/element-plus/instances/select.d.ts +91 -0
  60. package/shared/element-plus/instances/select.js +1264 -0
  61. package/shared/helper/index.d.ts +2 -2
  62. package/shared/helper/index.js +1 -1
  63. package/shared/types/drag/index.d.ts +7 -0
  64. package/shared/types/drag/index.js +1 -0
  65. package/shared/types/form-item/index.d.ts +2 -0
  66. package/shared/types/form-item/select.d.ts +8 -0
  67. package/shared/types/form-item/select.js +1 -0
  68. package/shared/types/form-item/switch.d.ts +8 -0
  69. package/shared/types/form-item/switch.js +1 -0
  70. package/shared/types/index.d.ts +2 -2
  71. package/shared/types/shared/index.d.ts +5 -0
  72. package/types/components/config/src/ctx.d.ts +1 -1
  73. package/types/components/config-renderer/src/ctx.d.ts +1 -1
  74. package/types/components/confirm-input/src/ctx.d.ts +79 -37
  75. package/types/components/confirm-input/src/index.vue.d.ts +210 -131
  76. package/types/components/drop-wrapper/src/index.vue.d.ts +2 -2
  77. package/types/components/form/src/ctx.d.ts +21 -16
  78. package/types/components/form/src/index.vue.d.ts +51 -43
  79. package/types/components/form-item/index.d.ts +5 -0
  80. package/types/components/form-item/src/ctx.d.ts +44 -0
  81. package/types/components/form-item/src/index.vue.d.ts +102 -0
  82. package/types/components/form-item/src/types.d.ts +6 -0
  83. package/types/components/ground/src/ground-config/src/index.vue.d.ts +4 -1
  84. package/types/components/ground/src/ground-main/src/editing-wrapper.vue.d.ts +35 -5
  85. package/types/components/ground/src/ground-main/src/index.vue.d.ts +19 -5
  86. package/types/components/ground/src/ground-widget/src/form-item-widget/src/index.vue.d.ts +994 -138
  87. package/types/components/ground/src/ground-widget/src/index.vue.d.ts +21 -5
  88. package/types/components/ground/src/ground-widget/src/static.d.ts +2 -2
  89. package/types/components/ground/src/index.vue.d.ts +41 -8
  90. package/types/components/input/src/ctx.d.ts +81 -43
  91. package/types/components/input/src/index.vue.d.ts +209 -136
  92. package/types/components/input/src/types.d.ts +1 -6
  93. package/types/components/input-config/src/ctx.d.ts +19 -15
  94. package/types/components/input-config/src/index.vue.d.ts +70 -50
  95. package/types/components/rules-config/index.d.ts +3 -0
  96. package/types/components/rules-config/src/ctx.d.ts +38 -0
  97. package/types/components/rules-config/src/index.vue.d.ts +113 -0
  98. package/types/components/select/index.d.ts +4 -0
  99. package/types/components/select/src/ctx.d.ts +193 -0
  100. package/types/components/select/src/index.vue.d.ts +589 -0
  101. package/types/components/select/src/types.d.ts +5 -0
  102. package/types/components/select-config/index.d.ts +4 -0
  103. package/types/components/select-config/src/ctx.d.ts +11 -0
  104. package/types/components/select-config/src/index.vue.d.ts +18 -0
  105. package/types/components/select-config/src/types.d.ts +3 -0
  106. package/types/components/switch/index.d.ts +4 -0
  107. package/types/components/switch/src/ctx.d.ts +62 -0
  108. package/types/components/switch/src/index.vue.d.ts +184 -0
  109. package/types/components/switch/src/types.d.ts +3 -0
  110. package/types/full-entry/main.d.ts +6 -0
  111. package/types/shared/element-plus/ctx/index.d.ts +8 -4
  112. package/types/shared/element-plus/instances/select.d.ts +91 -0
  113. package/types/shared/helper/index.d.ts +2 -2
  114. package/types/shared/types/drag/index.d.ts +7 -0
  115. package/types/shared/types/form-item/index.d.ts +2 -0
  116. package/types/shared/types/form-item/select.d.ts +8 -0
  117. package/types/shared/types/form-item/switch.d.ts +8 -0
  118. package/types/shared/types/index.d.ts +2 -2
  119. package/types/shared/types/shared/index.d.ts +5 -0
@@ -1,10 +1,10 @@
1
- import { defineComponent, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, createElementBlock, Fragment, renderList, toDisplayString, ref, createVNode, withDirectives, vShow, createTextVNode, withModifiers, renderSlot, computed, createCommentVNode, resolveDynamicComponent, normalizeClass, mergeProps, toHandlers } from 'vue';
1
+ import { defineComponent, resolveComponent, openBlock, createBlock, withCtx, createElementVNode, createElementBlock, Fragment, renderList, toDisplayString, ref, createVNode, withDirectives, renderSlot, vShow, createTextVNode, computed, createCommentVNode, resolveDynamicComponent, normalizeClass, mergeProps, toHandlers, unref, getCurrentScope, onScopeDispose, watch } from 'vue';
2
2
  import { VkTabGroup, VkTabItem, VkCard, VkBoxHandler } from 'vunk';
3
3
  import { VkFloatBlock } from 'vunk/gsap/components/float-block';
4
- import { ElCollapseItem, ElScrollbar, ElCollapse, ElIcon, ElMessage } from 'element-plus';
4
+ import { ElCollapseItem, ElScrollbar, ElCollapse, ElIcon, ElButton, ElMessage, ElMessageBox } from 'element-plus';
5
5
  import { VkfDragWrapper } from '@vunk/form/components/drag-wrapper';
6
6
  import 'vunk/gsap/components/float-block/index.css';
7
- import { _VkfFormUtils, VkfForm } from '@vunk/form/components/form';
7
+ import { VkfForm, _VkfFormUtils } from '@vunk/form/components/form';
8
8
  import { VkfDropWrapper, DragoverClasses } from '@vunk/form/components/drop-wrapper';
9
9
  import { VkfFormItemRendererTemplate } from '@vunk/form/components/form-item-renderer-template';
10
10
  import { setData, unsetData } from 'vunk/shared/helper';
@@ -25,6 +25,24 @@ var script$5 = defineComponent({
25
25
  prop: "",
26
26
  label: "inputLabel"
27
27
  }
28
+ },
29
+ {
30
+ label: "select",
31
+ value: "VkfSelect",
32
+ defaultOptions: {
33
+ templateType: "VkfSelect",
34
+ prop: "",
35
+ label: "label"
36
+ }
37
+ },
38
+ {
39
+ label: "switch",
40
+ value: "VkfSwitch",
41
+ defaultOptions: {
42
+ templateType: "VkfSwitch",
43
+ prop: "",
44
+ label: "label"
45
+ }
28
46
  }
29
47
  ];
30
48
  return {
@@ -33,23 +51,24 @@ var script$5 = defineComponent({
33
51
  }
34
52
  });
35
53
 
36
- const _hoisted_1$5 = { class: "vkf-ground-widget-ul" };
54
+ const _hoisted_1$6 = { class: "vkf-ground-widget-ul" };
37
55
  function render$5(_ctx, _cache, $props, $setup, $data, $options) {
38
56
  const _component_VkfDragWrapper = resolveComponent("VkfDragWrapper");
39
57
  const _component_ElCollapseItem = resolveComponent("ElCollapseItem");
40
58
  return openBlock(), createBlock(_component_ElCollapseItem, { title: "FormItems" }, {
41
59
  default: withCtx(() => [
42
- createElementVNode("ul", _hoisted_1$5, [
60
+ createElementVNode("ul", _hoisted_1$6, [
43
61
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.data, (item) => {
44
62
  return openBlock(), createBlock(_component_VkfDragWrapper, {
45
63
  key: item.value,
46
- data: JSON.stringify(item.defaultOptions)
64
+ title: JSON.stringify({ source: item.defaultOptions }),
65
+ data: JSON.stringify({ source: item.defaultOptions })
47
66
  }, {
48
67
  default: withCtx(() => [
49
68
  createElementVNode("li", null, toDisplayString(item.label), 1)
50
69
  ]),
51
70
  _: 2
52
- }, 1032, ["data"]);
71
+ }, 1032, ["title", "data"]);
53
72
  }), 128))
54
73
  ])
55
74
  ]),
@@ -61,14 +80,14 @@ script$5.render = render$5;
61
80
  script$5.__file = "ground/src/ground-widget/src/form-item-widget/src/index.vue";
62
81
 
63
82
  var ComponentsType = /* @__PURE__ */ ((ComponentsType2) => {
64
- ComponentsType2[ComponentsType2["container"] = 0] = "container";
65
- ComponentsType2[ComponentsType2["formItems"] = 1] = "formItems";
83
+ ComponentsType2["container"] = "container";
84
+ ComponentsType2["formItems"] = "formItems";
66
85
  return ComponentsType2;
67
86
  })(ComponentsType || {});
68
87
 
69
88
  var WidgetTab = /* @__PURE__ */ ((WidgetTab2) => {
70
- WidgetTab2[WidgetTab2["components"] = 0] = "components";
71
- WidgetTab2[WidgetTab2["templates"] = 1] = "templates";
89
+ WidgetTab2["components"] = "components";
90
+ WidgetTab2["templates"] = "templates";
72
91
  return WidgetTab2;
73
92
  })(WidgetTab || {});
74
93
  var script$4 = defineComponent({
@@ -81,23 +100,30 @@ var script$4 = defineComponent({
81
100
  ElCollapse,
82
101
  FormItemWidget: script$5
83
102
  },
103
+ props: {
104
+ componentLibCollapseExpanded: {
105
+ type: Array,
106
+ default: () => [
107
+ ComponentsType.container,
108
+ ComponentsType.formItems
109
+ ]
110
+ }
111
+ },
112
+ emits: {
113
+ "update:componentLibCollapseExpanded": null
114
+ },
84
115
  setup() {
85
- const widgetTab = ref(0 /* components */);
86
- const componentsType = ref([
87
- ComponentsType.container,
88
- ComponentsType.formItems
89
- ]);
116
+ const widgetTab = ref("components" /* components */);
90
117
  return {
91
118
  WidgetTab,
92
119
  ComponentsType,
93
- widgetTab,
94
- componentsType
120
+ widgetTab
95
121
  };
96
122
  }
97
123
  });
98
124
 
99
- const _hoisted_1$4 = /* @__PURE__ */ createTextVNode(" \u7EC4\u4EF6\u5E93 ");
100
- const _hoisted_2$2 = /* @__PURE__ */ createTextVNode(" \u6A21\u677F\u5E93 ");
125
+ const _hoisted_1$5 = /* @__PURE__ */ createTextVNode(" \u7EC4\u4EF6\u5E93 ");
126
+ const _hoisted_2$4 = /* @__PURE__ */ createTextVNode(" \u6A21\u677F\u5E93 ");
101
127
  function render$4(_ctx, _cache, $props, $setup, $data, $options) {
102
128
  const _component_VkTabItem = resolveComponent("VkTabItem");
103
129
  const _component_VkFloatBlock = resolveComponent("VkFloatBlock");
@@ -115,18 +141,20 @@ function render$4(_ctx, _cache, $props, $setup, $data, $options) {
115
141
  }, {
116
142
  default: withCtx(() => [
117
143
  createVNode(_component_VkTabItem, {
118
- name: _ctx.WidgetTab.components
144
+ name: _ctx.WidgetTab.components,
145
+ clearable: false
119
146
  }, {
120
147
  default: withCtx(() => [
121
- _hoisted_1$4
148
+ _hoisted_1$5
122
149
  ]),
123
150
  _: 1
124
151
  }, 8, ["name"]),
125
152
  createVNode(_component_VkTabItem, {
126
- name: _ctx.WidgetTab.templates
153
+ name: _ctx.WidgetTab.templates,
154
+ clearable: false
127
155
  }, {
128
156
  default: withCtx(() => [
129
- _hoisted_2$2
157
+ _hoisted_2$4
130
158
  ]),
131
159
  _: 1
132
160
  }, 8, ["name"]),
@@ -139,23 +167,24 @@ function render$4(_ctx, _cache, $props, $setup, $data, $options) {
139
167
  createVNode(_component_ElScrollbar, null, {
140
168
  default: withCtx(() => [
141
169
  withDirectives(createVNode(_component_ElCollapse, {
142
- modelValue: _ctx.componentsType,
143
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.componentsType = $event)
170
+ modelValue: _ctx.componentLibCollapseExpanded,
171
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.$emit("update:componentLibCollapseExpanded", $event))
144
172
  }, {
145
173
  default: withCtx(() => [
146
174
  createVNode(_component_FormItemWidget, {
147
175
  name: _ctx.ComponentsType.formItems
148
- }, null, 8, ["name"])
176
+ }, null, 8, ["name"]),
177
+ renderSlot(_ctx.$slots, "componentLibCollapse")
149
178
  ]),
150
- _: 1
179
+ _: 3
151
180
  }, 8, ["modelValue"]), [
152
181
  [vShow, _ctx.widgetTab === _ctx.WidgetTab.components]
153
182
  ])
154
183
  ]),
155
- _: 1
184
+ _: 3
156
185
  })
157
186
  ]),
158
- _: 1
187
+ _: 3
159
188
  });
160
189
  }
161
190
 
@@ -170,6 +199,25 @@ var _export_sfc = (sfc, props) => {
170
199
  return target;
171
200
  };
172
201
 
202
+ const _sfc_main$1 = defineComponent({
203
+ name: "Delete"
204
+ });
205
+ const _hoisted_1$4 = {
206
+ viewBox: "0 0 1024 1024",
207
+ xmlns: "http://www.w3.org/2000/svg"
208
+ };
209
+ const _hoisted_2$3 = /* @__PURE__ */ createElementVNode("path", {
210
+ fill: "currentColor",
211
+ d: "M160 256H96a32 32 0 0 1 0-64h256V95.936a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V192h256a32 32 0 1 1 0 64h-64v672a32 32 0 0 1-32 32H192a32 32 0 0 1-32-32V256zm448-64v-64H416v64h192zM224 896h576V256H224v640zm192-128a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32zm192 0a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32z"
212
+ }, null, -1);
213
+ const _hoisted_3$2 = [
214
+ _hoisted_2$3
215
+ ];
216
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
217
+ return openBlock(), createElementBlock("svg", _hoisted_1$4, _hoisted_3$2);
218
+ }
219
+ var _delete = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
220
+
173
221
  const _sfc_main = defineComponent({
174
222
  name: "Sort"
175
223
  });
@@ -177,12 +225,12 @@ const _hoisted_1$3 = {
177
225
  viewBox: "0 0 1024 1024",
178
226
  xmlns: "http://www.w3.org/2000/svg"
179
227
  };
180
- const _hoisted_2$1 = /* @__PURE__ */ createElementVNode("path", {
228
+ const _hoisted_2$2 = /* @__PURE__ */ createElementVNode("path", {
181
229
  fill: "currentColor",
182
230
  d: "M384 96a32 32 0 0 1 64 0v786.752a32 32 0 0 1-54.592 22.656L95.936 608a32 32 0 0 1 0-45.312h.128a32 32 0 0 1 45.184 0L384 805.632V96zm192 45.248a32 32 0 0 1 54.592-22.592L928.064 416a32 32 0 0 1 0 45.312h-.128a32 32 0 0 1-45.184 0L640 218.496V928a32 32 0 1 1-64 0V141.248z"
183
231
  }, null, -1);
184
232
  const _hoisted_3$1 = [
185
- _hoisted_2$1
233
+ _hoisted_2$2
186
234
  ];
187
235
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
188
236
  return openBlock(), createElementBlock("svg", _hoisted_1$3, _hoisted_3$1);
@@ -198,45 +246,49 @@ var script$3 = defineComponent({
198
246
  source: {
199
247
  type: Object,
200
248
  default: () => ({})
249
+ },
250
+ attributes: {
251
+ type: Object,
252
+ default: () => ({ k: [] })
201
253
  }
202
254
  },
255
+ emits: {
256
+ drop: (e, c, data) => e || c || data,
257
+ del: (e) => e
258
+ },
203
259
  components: {
204
260
  VkBoxHandler,
205
261
  ElIcon,
206
262
  Sort: sort,
263
+ Delete: _delete,
207
264
  VkfDragWrapper,
208
265
  VkfDropWrapper
209
- },
210
- setup() {
211
- const dragover = (e) => {
212
- };
213
- const drop = (e) => {
214
- };
215
- return {
216
- dragover,
217
- drop
218
- };
219
266
  }
220
267
  });
221
268
 
222
269
  const _hoisted_1$2 = /* @__PURE__ */ createTextVNode(" \u62D6\u52A8\u5355\u5143 ");
270
+ const _hoisted_2$1 = { class: "vkf-gmew-tools vkf-gmew-rb-x" };
223
271
  function render$3(_ctx, _cache, $props, $setup, $data, $options) {
224
272
  const _component_Sort = resolveComponent("Sort");
225
273
  const _component_el_icon = resolveComponent("el-icon");
226
274
  const _component_VkfDragWrapper = resolveComponent("VkfDragWrapper");
227
275
  const _component_VkBoxHandler = resolveComponent("VkBoxHandler");
276
+ const _component_Delete = resolveComponent("Delete");
228
277
  const _component_VkfDropWrapper = resolveComponent("VkfDropWrapper");
229
278
  return openBlock(), createBlock(_component_VkfDropWrapper, {
230
- onDragover: withModifiers(_ctx.dragover, ["stop"]),
279
+ onDrop: _cache[1] || (_cache[1] = (...arg) => _ctx.$emit("drop", ...arg, {
280
+ attributes: _ctx.attributes,
281
+ source: _ctx.source
282
+ })),
231
283
  class: "vkf-ground-main-editing-wrapper"
232
284
  }, {
233
285
  default: withCtx(() => [
234
286
  withDirectives(createVNode(_component_VkBoxHandler, null, {
235
287
  default: withCtx(() => [
236
288
  createVNode(_component_VkfDragWrapper, {
237
- title: JSON.stringify(_ctx.source),
238
- data: JSON.stringify(_ctx.source),
239
- class: "vkf-gmew-drag-wrapper"
289
+ title: JSON.stringify({ source: _ctx.source, attributes: _ctx.attributes }),
290
+ data: JSON.stringify({ source: _ctx.source, attributes: _ctx.attributes }),
291
+ class: "vkf-gmew-drag-wrapper vkf-gmew-tools"
240
292
  }, {
241
293
  default: withCtx(() => [
242
294
  createVNode(_component_el_icon, null, {
@@ -254,10 +306,22 @@ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
254
306
  }, 512), [
255
307
  [vShow, _ctx.active]
256
308
  ]),
309
+ withDirectives(createElementVNode("div", _hoisted_2$1, [
310
+ createVNode(_component_el_icon, {
311
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("del", { k: _ctx.attributes.k }))
312
+ }, {
313
+ default: withCtx(() => [
314
+ createVNode(_component_Delete)
315
+ ]),
316
+ _: 1
317
+ })
318
+ ], 512), [
319
+ [vShow, _ctx.active]
320
+ ]),
257
321
  renderSlot(_ctx.$slots, "default")
258
322
  ]),
259
323
  _: 3
260
- }, 8, ["onDragover"]);
324
+ });
261
325
  }
262
326
 
263
327
  script$3.render = render$3;
@@ -549,7 +613,12 @@ function uniqueId(prefix) {
549
613
  return toString(prefix) + id;
550
614
  }
551
615
 
552
- const createDefaultSlots = _VkfFormUtils._VkfFormItemRendererUtils.createDefaultSlots;
616
+ const createDefaultSlots = (e) => _VkfFormUtils._VkfFormItemRendererUtils.createDefaultSlots(e);
617
+ const addDefaultProp = (source) => {
618
+ if ("prop" in source) {
619
+ source.prop ||= uniqueId("from_widget_");
620
+ }
621
+ };
553
622
  var script$2 = defineComponent({
554
623
  components: {
555
624
  VkfDropWrapper,
@@ -567,12 +636,16 @@ var script$2 = defineComponent({
567
636
  prop: {
568
637
  type: String,
569
638
  default: ""
639
+ },
640
+ k: {
641
+ type: Array,
642
+ default: () => []
570
643
  }
571
644
  },
572
645
  emits: {
573
646
  "update:prop": (e) => e,
574
- setFormItems: null,
575
- unsetFormItems: null
647
+ "setData:formItems": null,
648
+ "unsetData:formItems": null
576
649
  },
577
650
  setup(props, { emit }) {
578
651
  const formData = ref({});
@@ -608,32 +681,82 @@ var script$2 = defineComponent({
608
681
  return;
609
682
  groundEndClassName.value = DragoverClasses.normal;
610
683
  const data = JSON.parse(e.dataTransfer.getData("text"));
611
- data.prop ||= uniqueId("from_widget_");
612
- if (data.templateType === "VkfEditingSelect") {
684
+ const source = data?.source;
685
+ if (!source)
686
+ return;
687
+ addDefaultProp(source);
688
+ if (source.templateType === "VkfEditingSelect") {
613
689
  const currentLength = props.formItems.length;
614
- data.templateSlots.default.forEach((v, i) => {
615
- emit("setFormItems", {
690
+ source.templateSlots.default.forEach((v, i) => {
691
+ emit("setData:formItems", {
616
692
  k: currentLength + i,
617
693
  v
618
694
  });
619
695
  });
620
- emit("unsetFormItems", {
621
- k: data.index
696
+ emit("unsetData:formItems", {
697
+ k: source.index
622
698
  });
623
699
  } else {
624
- emit("setFormItems", {
700
+ emit("setData:formItems", {
625
701
  k: props.formItems.length,
626
- v: data
702
+ v: source
627
703
  });
628
- emit("update:prop", data.prop);
704
+ emit("update:prop", source.prop);
629
705
  }
630
706
  }
631
- function editDrop(e) {
707
+ function editDrop(e, overClass, toData) {
708
+ e.stopPropagation();
632
709
  e.preventDefault();
633
710
  if (!e.dataTransfer)
634
711
  return;
635
- const data = JSON.parse(e.dataTransfer.getData("text"));
636
- console.log(data);
712
+ const fromData = JSON.parse(e.dataTransfer.getData("text"));
713
+ const fromSource = fromData?.source;
714
+ if (!fromSource)
715
+ return;
716
+ const fromK = fromData.attributes?.k ?? [];
717
+ let toK = toData.attributes.k;
718
+ let tkl = toK.at(-1);
719
+ if (typeof tkl === "number" && overClass === DragoverClasses["is-dragover-next"]) {
720
+ tkl++;
721
+ }
722
+ let itemSource = fromSource;
723
+ if (fromSource.templateType === "VkfEditingSelect") {
724
+ itemSource = fromSource.templateSlots.default[0];
725
+ }
726
+ if (!fromK.length) {
727
+ addDefaultProp(itemSource);
728
+ emit("setData:formItems", {
729
+ k: toK.map((v, index) => index === toK.length - 1 ? tkl : v),
730
+ v: itemSource,
731
+ insert: true
732
+ });
733
+ itemSource.prop && emit("update:prop", itemSource.prop);
734
+ return;
735
+ }
736
+ if (fromK.length === toK.length) {
737
+ const fkl = fromK.at(-1);
738
+ if (typeof fkl === "number" && typeof tkl === "number") {
739
+ if (overClass === DragoverClasses["is-dragover-prev"]) {
740
+ if (fkl + 1 === tkl)
741
+ return;
742
+ }
743
+ if (overClass === DragoverClasses["is-dragover-prev"]) {
744
+ if (tkl === fkl)
745
+ return;
746
+ }
747
+ emit("unsetData:formItems", {
748
+ k: fkl
749
+ });
750
+ if (fkl < tkl) {
751
+ tkl--;
752
+ }
753
+ emit("setData:formItems", {
754
+ k: tkl,
755
+ v: itemSource,
756
+ insert: true
757
+ });
758
+ }
759
+ }
637
760
  }
638
761
  return {
639
762
  groundEndClassName,
@@ -669,17 +792,17 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
669
792
  createCommentVNode(" \u5C06formItems\u6E32\u67D3 \u4E3A\u7F16\u8F91\u65F6\u7EC4\u4EF6 "),
670
793
  createVNode(_component_VkTabGroup, {
671
794
  modelValue: _ctx.prop,
672
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.$emit("update:prop", $event))
795
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.$emit("update:prop", $event))
673
796
  }, {
674
797
  default: withCtx(() => [
675
798
  createVNode(_component_VkfForm, {
676
799
  formItems: _ctx.formItemsWithWrapper,
677
800
  data: _ctx.formData,
678
- onSetData: _cache[0] || (_cache[0] = ($event) => _ctx.setData(_ctx.formData, $event))
801
+ onSetData: _cache[1] || (_cache[1] = ($event) => _ctx.setData(_ctx.formData, $event))
679
802
  }, {
680
803
  rendererTemplate: withCtx(() => [
681
804
  createVNode(_component_VkfFormItemRendererTemplate, { type: "VkfEditingSelect" }, {
682
- default: withCtx(({ data, Renderer, raw }) => [
805
+ default: withCtx(({ data, Renderer, raw, k }) => [
683
806
  createCommentVNode(" name is prop "),
684
807
  createVNode(_component_VkTabItem, {
685
808
  name: data.name,
@@ -687,11 +810,14 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
687
810
  class: "vkf-gm-form-item-x"
688
811
  }, {
689
812
  default: withCtx(({ isActive }) => [
690
- createCommentVNode(" \u62D6\u52A8\u65F6 \u6839\u636E source \u548C data.index "),
813
+ createCommentVNode(" \u62D6\u52A8\u65F6 \u6839\u636E source \u548C attributes\u786E\u5B9A\u4F4D\u7F6E "),
814
+ createCommentVNode(" [?] \u4E3A\u4EC0\u4E48\u5220\u9664\u4E86\u4E00\u4E2A\u6570\u636E\u540E\uFF0C\u5F53\u524D\u7684prop\u53D1\u751F\u4E86\u6539\u53D8\u3002 \u53EF\u80FD\u662F\u56E0\u4E3A\u6709\u4E2A isActive \u662F true \u88AB\u4F20\u8FDB\u53BB\u4E86 \uFF1F "),
691
815
  createVNode(_component_EditingWrapper, {
692
- onDrop: withModifiers(_ctx.editDrop, ["stop"]),
816
+ onDrop: _ctx.editDrop,
817
+ attributes: { k },
693
818
  active: isActive,
694
- source: raw
819
+ source: raw,
820
+ onDel: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("unsetData:formItems", $event))
695
821
  }, {
696
822
  default: withCtx(() => [
697
823
  (openBlock(), createBlock(resolveDynamicComponent(Renderer), {
@@ -699,25 +825,26 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
699
825
  }, null, 8, ["source"]))
700
826
  ]),
701
827
  _: 2
702
- }, 1032, ["onDrop", "active", "source"])
828
+ }, 1032, ["onDrop", "attributes", "active", "source"])
703
829
  ]),
704
830
  _: 2
705
831
  }, 1032, ["name"])
706
832
  ]),
707
833
  _: 1
708
- })
834
+ }),
835
+ renderSlot(_ctx.$slots, "rendererTemplate")
709
836
  ]),
710
- _: 1
837
+ _: 3
711
838
  }, 8, ["formItems", "data"])
712
839
  ]),
713
- _: 1
840
+ _: 3
714
841
  }, 8, ["modelValue"]),
715
842
  createElementVNode("div", {
716
843
  class: normalizeClass(["vkf-ground-end", _ctx.groundEndClassName]),
717
844
  ref: "endLineNode"
718
845
  }, null, 2)
719
846
  ]),
720
- _: 1
847
+ _: 3
721
848
  }, 8, ["onDrop", "onDragover", "onDragleave"]);
722
849
  }
723
850
 
@@ -746,15 +873,9 @@ var script$1 = defineComponent({
746
873
  setup(props, { emit }) {
747
874
  const configProps = _VkfConfigCtx.createBindProps(props, ["source"]);
748
875
  const configEmits = _VkfConfigCtx.createOnEmits(emit);
749
- const typeToConfigSource = {
750
- "VkfInput": {
751
- templateType: "VkfInput",
752
- propDisabled: false
753
- }
754
- };
755
876
  const source = computed(() => {
756
877
  return {
757
- ...typeToConfigSource[props.templateType],
878
+ templateType: props.templateType,
758
879
  propDisabled: props.propDisabled
759
880
  };
760
881
  });
@@ -777,31 +898,192 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
777
898
  return openBlock(), createBlock(_component_VkfConfig, mergeProps({
778
899
  source: _ctx.source,
779
900
  "onSetData:source": _ctx.setSource
780
- }, _ctx.configProps, toHandlers(_ctx.configEmits)), null, 16, ["source", "onSetData:source"]);
901
+ }, _ctx.configProps, toHandlers(_ctx.configEmits)), {
902
+ rendererTemplate: withCtx(() => [
903
+ renderSlot(_ctx.$slots, "rendererTemplate")
904
+ ]),
905
+ _: 3
906
+ }, 16, ["source", "onSetData:source"]);
781
907
  }
782
908
 
783
909
  script$1.render = render$1;
784
910
  script$1.__file = "ground/src/ground-config/src/index.vue";
785
911
 
912
+ function tryOnScopeDispose(fn) {
913
+ if (getCurrentScope()) {
914
+ onScopeDispose(fn);
915
+ return true;
916
+ }
917
+ return false;
918
+ }
919
+
920
+ const isClient = typeof window !== "undefined";
921
+ const isString = (val) => typeof val === "string";
922
+ const noop = () => {
923
+ };
924
+
925
+ function useTimeoutFn(cb, interval, options = {}) {
926
+ const {
927
+ immediate = true
928
+ } = options;
929
+ const isPending = ref(false);
930
+ let timer = null;
931
+ function clear() {
932
+ if (timer) {
933
+ clearTimeout(timer);
934
+ timer = null;
935
+ }
936
+ }
937
+ function stop() {
938
+ isPending.value = false;
939
+ clear();
940
+ }
941
+ function start(...args) {
942
+ clear();
943
+ isPending.value = true;
944
+ timer = setTimeout(() => {
945
+ isPending.value = false;
946
+ timer = null;
947
+ cb(...args);
948
+ }, unref(interval));
949
+ }
950
+ if (immediate) {
951
+ isPending.value = true;
952
+ if (isClient)
953
+ start();
954
+ }
955
+ tryOnScopeDispose(stop);
956
+ return {
957
+ isPending,
958
+ start,
959
+ stop
960
+ };
961
+ }
962
+
963
+ function unrefElement(elRef) {
964
+ var _a;
965
+ const plain = unref(elRef);
966
+ return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
967
+ }
968
+
969
+ const defaultWindow = isClient ? window : void 0;
970
+ isClient ? window.document : void 0;
971
+ const defaultNavigator = isClient ? window.navigator : void 0;
972
+ isClient ? window.location : void 0;
973
+
974
+ function useEventListener(...args) {
975
+ let target;
976
+ let event;
977
+ let listener;
978
+ let options;
979
+ if (isString(args[0])) {
980
+ [event, listener, options] = args;
981
+ target = defaultWindow;
982
+ } else {
983
+ [target, event, listener, options] = args;
984
+ }
985
+ if (!target)
986
+ return noop;
987
+ let cleanup = noop;
988
+ const stopWatch = watch(() => unrefElement(target), (el) => {
989
+ cleanup();
990
+ if (!el)
991
+ return;
992
+ el.addEventListener(event, listener, options);
993
+ cleanup = () => {
994
+ el.removeEventListener(event, listener, options);
995
+ cleanup = noop;
996
+ };
997
+ }, { immediate: true, flush: "post" });
998
+ const stop = () => {
999
+ stopWatch();
1000
+ cleanup();
1001
+ };
1002
+ tryOnScopeDispose(stop);
1003
+ return stop;
1004
+ }
1005
+
1006
+ function useClipboard(options = {}) {
1007
+ const {
1008
+ navigator = defaultNavigator,
1009
+ read = false,
1010
+ source,
1011
+ copiedDuring = 1500
1012
+ } = options;
1013
+ const events = ["copy", "cut"];
1014
+ const isSupported = Boolean(navigator && "clipboard" in navigator);
1015
+ const text = ref("");
1016
+ const copied = ref(false);
1017
+ const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
1018
+ function updateText() {
1019
+ navigator.clipboard.readText().then((value) => {
1020
+ text.value = value;
1021
+ });
1022
+ }
1023
+ if (isSupported && read) {
1024
+ for (const event of events)
1025
+ useEventListener(event, updateText);
1026
+ }
1027
+ async function copy(value = unref(source)) {
1028
+ if (isSupported && value != null) {
1029
+ await navigator.clipboard.writeText(value);
1030
+ text.value = value;
1031
+ copied.value = true;
1032
+ timeout.start();
1033
+ }
1034
+ }
1035
+ return {
1036
+ isSupported,
1037
+ text,
1038
+ copied,
1039
+ copy
1040
+ };
1041
+ }
1042
+
1043
+ const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1044
+ const globalKey = "__vueuse_ssr_handlers__";
1045
+ _global[globalKey] = _global[globalKey] || {};
1046
+ _global[globalKey];
1047
+
1048
+ var _a, _b;
1049
+ isClient && (window == null ? void 0 : window.navigator) && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.platform) && /iP(ad|hone|od)/.test((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.platform);
1050
+
786
1051
  var script = defineComponent({
787
1052
  name: "VkfGround",
788
1053
  components: {
789
1054
  VkfGroundWidget: script$4,
790
1055
  VkfGroundMain: script$2,
791
- VkfGroundConfig: script$1
1056
+ VkfGroundConfig: script$1,
1057
+ VkCard,
1058
+ ElButton
1059
+ },
1060
+ props: {
1061
+ componentLibCollapseExpanded: {
1062
+ type: Array,
1063
+ default: void 0
1064
+ },
1065
+ data: {
1066
+ type: Array,
1067
+ default: () => []
1068
+ }
1069
+ },
1070
+ emits: {
1071
+ "update:data": null,
1072
+ "setData": (e) => e,
1073
+ "unsetData": null,
1074
+ "update:componentLibCollapseExpanded": null
792
1075
  },
793
1076
  setup(props, { emit }) {
794
- const formItems = ref([]);
795
1077
  const editProp = ref("");
796
1078
  const propToFormItem = computed(() => {
797
- return formItems.value.reduce((a, c) => {
1079
+ return props.data.reduce((a, c) => {
798
1080
  if (c.prop) {
799
1081
  a[c.prop] = c;
800
1082
  }
801
1083
  return a;
802
1084
  }, {});
803
1085
  });
804
- const configPropDisabled = ref(false);
1086
+ const configPropDisabled = ref(true);
805
1087
  const setFormItem = (props2, e) => {
806
1088
  if (e.k === "prop") {
807
1089
  if (e.v === props2.prop) {
@@ -812,6 +1094,11 @@ var script = defineComponent({
812
1094
  type: "warning",
813
1095
  message: "\u5B58\u5728\u76F8\u540C\u7684prop, \u8BF7\u91CD\u65B0\u4FEE\u6539"
814
1096
  });
1097
+ } else if (!e.v) {
1098
+ ElMessage({
1099
+ type: "warning",
1100
+ message: "prop\u4E0D\u80FD\u4E3A\u7A7A"
1101
+ });
815
1102
  } else {
816
1103
  props2.prop = e.v;
817
1104
  editProp.value = e.v;
@@ -822,49 +1109,119 @@ var script = defineComponent({
822
1109
  setData(props2, e);
823
1110
  }
824
1111
  };
1112
+ const formItemStr = computed(() => JSON.stringify(props.data));
1113
+ const formItemClip = useClipboard({
1114
+ source: formItemStr
1115
+ });
1116
+ const inputJson = () => {
1117
+ ElMessageBox.prompt("\u8F93\u5165Json", "\u63D0\u793A", {
1118
+ confirmButtonText: "\u786E\u8BA4",
1119
+ cancelButtonText: "\u53D6\u6D88"
1120
+ }).then(({ value }) => {
1121
+ let obj = [];
1122
+ try {
1123
+ obj = JSON.parse(value);
1124
+ } catch (err) {
1125
+ ElMessage({
1126
+ type: "error",
1127
+ message: "Json\u89E3\u6790\u9519\u8BEF"
1128
+ });
1129
+ throw err;
1130
+ }
1131
+ return obj;
1132
+ }).then((obj) => {
1133
+ emit("update:data", obj);
1134
+ });
1135
+ };
825
1136
  return {
826
1137
  propToFormItem,
827
- formItems,
828
1138
  editProp,
829
1139
  setData,
830
1140
  unsetData,
831
1141
  setFormItem,
832
- configPropDisabled
1142
+ configPropDisabled,
1143
+ formItemClip,
1144
+ inputJson
833
1145
  };
834
1146
  }
835
1147
  });
836
1148
 
837
1149
  const _hoisted_1 = { class: "vkf-ground" };
838
1150
  const _hoisted_2 = { class: "vkf-ground-main-x" };
839
- const _hoisted_3 = { class: "vkf-ground-config-x" };
1151
+ const _hoisted_3 = { key: 0 };
1152
+ const _hoisted_4 = { key: 1 };
1153
+ const _hoisted_5 = /* @__PURE__ */ createTextVNode(" \u5BFC\u5165Json ");
1154
+ const _hoisted_6 = { class: "vkf-ground-config-x" };
840
1155
  function render(_ctx, _cache, $props, $setup, $data, $options) {
841
1156
  const _component_VkfGroundWidget = resolveComponent("VkfGroundWidget");
1157
+ const _component_ElButton = resolveComponent("ElButton");
842
1158
  const _component_VkfGroundMain = resolveComponent("VkfGroundMain");
1159
+ const _component_VkCard = resolveComponent("VkCard");
843
1160
  const _component_VkfGroundConfig = resolveComponent("VkfGroundConfig");
844
1161
  return openBlock(), createElementBlock("div", _hoisted_1, [
845
- createVNode(_component_VkfGroundWidget, { class: "vkf-ground-widget-x" }),
1162
+ createVNode(_component_VkfGroundWidget, {
1163
+ class: "vkf-ground-widget-x",
1164
+ componentLibCollapseExpanded: _ctx.componentLibCollapseExpanded,
1165
+ "onUpdate:componentLibCollapseExpanded": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:componentLibCollapseExpanded", $event))
1166
+ }, {
1167
+ componentLibCollapse: withCtx(() => [
1168
+ renderSlot(_ctx.$slots, "widgetComponentLibCollapse")
1169
+ ]),
1170
+ _: 3
1171
+ }, 8, ["componentLibCollapseExpanded"]),
846
1172
  createElementVNode("div", _hoisted_2, [
847
- createCommentVNode(" {{ formItems }} "),
848
- createVNode(_component_VkfGroundMain, {
849
- prop: _ctx.editProp,
850
- "onUpdate:prop": [
851
- _cache[0] || (_cache[0] = ($event) => _ctx.editProp = $event),
852
- _cache[1] || (_cache[1] = ($event) => _ctx.configPropDisabled = false)
853
- ],
854
- formItems: _ctx.formItems,
855
- onSetFormItems: _cache[2] || (_cache[2] = ($event) => _ctx.setData(_ctx.formItems, $event)),
856
- onUnsetFormItems: _cache[3] || (_cache[3] = ($event) => _ctx.unsetData(_ctx.formItems, $event))
857
- }, null, 8, ["prop", "formItems"])
1173
+ createVNode(_component_VkCard, {
1174
+ tag: "div",
1175
+ class: "vkf-ground-main-card"
1176
+ }, {
1177
+ title: withCtx(() => [
1178
+ createVNode(_component_ElButton, {
1179
+ onClick: _cache[1] || (_cache[1] = () => _ctx.formItemClip.copy())
1180
+ }, {
1181
+ default: withCtx(() => [
1182
+ !_ctx.formItemClip.copied.value ? (openBlock(), createElementBlock("span", _hoisted_3, "\u590D\u5236Json")) : (openBlock(), createElementBlock("span", _hoisted_4, "\u5DF2\u590D\u5236!"))
1183
+ ]),
1184
+ _: 1
1185
+ }),
1186
+ createVNode(_component_ElButton, { onClick: _ctx.inputJson }, {
1187
+ default: withCtx(() => [
1188
+ _hoisted_5
1189
+ ]),
1190
+ _: 1
1191
+ }, 8, ["onClick"])
1192
+ ]),
1193
+ default: withCtx(() => [
1194
+ createVNode(_component_VkfGroundMain, {
1195
+ prop: _ctx.editProp,
1196
+ "onUpdate:prop": _cache[2] || (_cache[2] = ($event) => _ctx.editProp = $event),
1197
+ formItems: _ctx.data,
1198
+ "onSetData:formItems": _cache[3] || (_cache[3] = ($event) => _ctx.$emit("setData", $event)),
1199
+ "onUnsetData:formItems": _cache[4] || (_cache[4] = ($event) => _ctx.$emit("unsetData", $event))
1200
+ }, {
1201
+ rendererTemplate: withCtx(() => [
1202
+ renderSlot(_ctx.$slots, "rendererTemplate")
1203
+ ]),
1204
+ _: 3
1205
+ }, 8, ["prop", "formItems"])
1206
+ ]),
1207
+ _: 3
1208
+ })
858
1209
  ]),
859
- createElementVNode("div", _hoisted_3, [
1210
+ createElementVNode("div", _hoisted_6, [
1211
+ createCommentVNode(" \u901A\u8FC7config \u4FEE\u6539\u6570\u636E\u6E90 \u5355\u9879\u7684\u5185\u5BB9 "),
860
1212
  _ctx.editProp && _ctx.propToFormItem[_ctx.editProp] ? (openBlock(), createBlock(_component_VkfGroundConfig, {
861
1213
  key: 0,
862
1214
  propDisabled: _ctx.configPropDisabled,
863
- "onUpdate:propDisabled": _cache[4] || (_cache[4] = ($event) => _ctx.configPropDisabled = $event),
1215
+ "onUpdate:propDisabled": _cache[5] || (_cache[5] = ($event) => _ctx.configPropDisabled = $event),
864
1216
  templateType: _ctx.propToFormItem[_ctx.editProp].templateType,
865
1217
  data: _ctx.propToFormItem[_ctx.editProp],
866
- onSetData: _cache[5] || (_cache[5] = ($event) => _ctx.setFormItem(_ctx.propToFormItem[_ctx.editProp], $event))
867
- }, null, 8, ["propDisabled", "templateType", "data"])) : createCommentVNode("v-if", true)
1218
+ onSetData: _cache[6] || (_cache[6] = ($event) => _ctx.setFormItem(_ctx.propToFormItem[_ctx.editProp], $event))
1219
+ }, {
1220
+ rendererTemplate: withCtx(() => [
1221
+ renderSlot(_ctx.$slots, "configRendererTemplate")
1222
+ ]),
1223
+ _: 3
1224
+ }, 8, ["propDisabled", "templateType", "data"])) : createCommentVNode("v-if", true)
868
1225
  ])
869
1226
  ]);
870
1227
  }