@vunk/form 1.1.84 → 1.2.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 (52) hide show
  1. package/components/_plugin-vue_export-helper.cjs +11 -0
  2. package/components/button/index.cjs +112 -0
  3. package/components/cascader/index.cjs +130 -0
  4. package/components/checkbox/index.cjs +153 -0
  5. package/components/color-picker/index.cjs +80 -0
  6. package/components/date-picker/index.cjs +120 -0
  7. package/components/date-picker-range/index.cjs +170 -0
  8. package/components/download-plus/index.cjs +445 -0
  9. package/components/esri-input-geojson/index.cjs +1120 -0
  10. package/components/form/index.cjs +220 -0
  11. package/components/form-item/index.cjs +162 -0
  12. package/components/form-item-renderer/index.cjs +103 -0
  13. package/components/form-item-renderer-template/index.cjs +47 -0
  14. package/components/geoinput/index.cjs +95 -0
  15. package/components/geoinput-read/index.cjs +304 -0
  16. package/components/geoinput-update/index.cjs +406 -0
  17. package/components/index.cjs +13 -0
  18. package/components/index2.cjs +323 -0
  19. package/components/index3.cjs +486 -0
  20. package/components/input/index.cjs +119 -0
  21. package/components/input-link/index.cjs +157 -0
  22. package/components/input-number/index.cjs +100 -0
  23. package/components/radio/index.cjs +142 -0
  24. package/components/select/index.cjs +165 -0
  25. package/components/slider/index.cjs +89 -0
  26. package/components/switch/index.cjs +92 -0
  27. package/components/templates-default/index.cjs +308 -0
  28. package/components/templates-element-plus/index.cjs +112 -0
  29. package/components/templates-esri/index.cjs +65 -0
  30. package/components/templates-layout/index.cjs +137 -0
  31. package/components/templates-mapbox/index.cjs +65 -0
  32. package/components/templates-variant/index.cjs +70 -0
  33. package/components/upload/index.cjs +508 -0
  34. package/components/upload-plus/index.cjs +18658 -0
  35. package/components/van-cascader/index.cjs +128 -0
  36. package/components/var-datetime-picker/index.cjs +330 -0
  37. package/components/vditor/index.cjs +451 -0
  38. package/composables/index.cjs +89 -0
  39. package/package.json +97 -49
  40. package/shared/const/index.cjs +59 -0
  41. package/shared/element-plus/index.cjs +317 -0
  42. package/shared/form/index.cjs +33 -0
  43. package/shared/helper/index.cjs +11 -0
  44. package/shared/index.cjs +8 -0
  45. package/shared/infer-prop/index.cjs +36 -0
  46. package/shared/progress-it/index.cjs +40 -0
  47. package/shared/rules/index.cjs +56 -0
  48. package/shared/types/form/index.cjs +2 -0
  49. package/shared/types/index.cjs +2 -0
  50. package/shared/types/source/index.cjs +2 -0
  51. package/shared/types/source-manager/index.cjs +2 -0
  52. package/shared/upload/index.cjs +774 -0
@@ -0,0 +1,508 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var formItem = require('@vunk/form/components/form-item');
6
+ var utilsVue = require('@vunk/core/shared/utils-vue');
7
+ var elementPlus = require('element-plus');
8
+ var vue = require('vue');
9
+ var utilsObject = require('@vunk/core/shared/utils-object');
10
+ var elementPlus$1 = require('@vunk/form/shared/element-plus');
11
+ var index = require('../index2.cjs');
12
+ var utilsFunction = require('@vunk/core/shared/utils-function');
13
+ var utilsFetch = require('@vunk/core/shared/utils-fetch');
14
+ var _pluginVue_exportHelper = require('../_plugin-vue_export-helper.cjs');
15
+ var composables = require('@vunk/form/composables');
16
+ var progress = require('@vunk/form/shared/progress-it');
17
+
18
+ const props = {
19
+ ...formItem._VkfFormItemCtx.props,
20
+ ...elementPlus.uploadProps,
21
+ tip: {
22
+ type: String,
23
+ default: ""
24
+ },
25
+ preview: {
26
+ type: Boolean,
27
+ default: false
28
+ },
29
+ beforeUpload: {
30
+ type: Function,
31
+ default: void 0
32
+ },
33
+ onDownload: {
34
+ type: Function,
35
+ default: void 0
36
+ }
37
+ };
38
+ const createBindProps = utilsVue.bindPropsFactory(props);
39
+ const emits = {
40
+ "update:fileList": null,
41
+ "remove": (e) => e
42
+ };
43
+ const createOnEmits = utilsVue.onEmitsFactory(emits);
44
+
45
+ var ctx = /*#__PURE__*/Object.freeze({
46
+ __proto__: null,
47
+ createBindProps: createBindProps,
48
+ createOnEmits: createOnEmits,
49
+ emits: emits,
50
+ props: props
51
+ });
52
+
53
+ const restFetch = new utilsFetch.RestFetch({
54
+ baseURL: ""
55
+ });
56
+ var _sfc_main$1 = vue.defineComponent({
57
+ components: {
58
+ ElProgress: elementPlus.ElProgress,
59
+ ElIcon: elementPlus.ElIcon,
60
+ Check: index.check_default,
61
+ ZoomIn: index.zoom_in_default,
62
+ Delete: index.delete_default,
63
+ Close: index.close_default,
64
+ CircleCheck: index.circle_check_default,
65
+ Document: index.document_default,
66
+ Download: index.download_default
67
+ },
68
+ props: {
69
+ listType: {
70
+ type: String,
71
+ default: "text"
72
+ },
73
+ file: {
74
+ type: Object,
75
+ default: () => ({})
76
+ },
77
+ disabled: {
78
+ type: Boolean,
79
+ default: false
80
+ },
81
+ onPreview: {
82
+ type: Function,
83
+ default: () => utilsFunction.NOOP
84
+ },
85
+ onDownload: {
86
+ type: Function,
87
+ default: void 0
88
+ },
89
+ preview: {
90
+ type: Boolean,
91
+ default: false
92
+ }
93
+ },
94
+ emits: {
95
+ "remove": (e) => e
96
+ },
97
+ setup(props, { emit }) {
98
+ const nsUpload = elementPlus.useNamespace("upload");
99
+ const nsIcon = elementPlus.useNamespace("icon");
100
+ const { t } = elementPlus.useLocale();
101
+ const handleRemove = (file = props.file) => {
102
+ emit("remove", file);
103
+ };
104
+ const handleDownload = (file = props.file) => {
105
+ if (props.onDownload) {
106
+ props.onDownload(file);
107
+ return;
108
+ }
109
+ let url = "";
110
+ if (file.url) {
111
+ url = file.url;
112
+ } else if (file.raw) {
113
+ url = window.URL.createObjectURL(file.raw);
114
+ }
115
+ url && restFetch.download({
116
+ url,
117
+ fileName: file.name
118
+ }, {
119
+ method: "GET"
120
+ });
121
+ };
122
+ return {
123
+ handleRemove,
124
+ t,
125
+ nsIcon,
126
+ nsUpload,
127
+ handleDownload
128
+ };
129
+ }
130
+ });
131
+
132
+ const _hoisted_1$1 = ["src"];
133
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
134
+ const _component_Document = vue.resolveComponent("Document");
135
+ const _component_el_icon = vue.resolveComponent("el-icon");
136
+ const _component_Download = vue.resolveComponent("Download");
137
+ const _component_el_progress = vue.resolveComponent("el-progress");
138
+ const _component_circle_check = vue.resolveComponent("circle-check");
139
+ const _component_Check = vue.resolveComponent("Check");
140
+ const _component_Close = vue.resolveComponent("Close");
141
+ const _component_zoom_in = vue.resolveComponent("zoom-in");
142
+ const _component_Delete = vue.resolveComponent("Delete");
143
+ return vue.openBlock(), vue.createElementBlock(
144
+ vue.Fragment,
145
+ null,
146
+ [
147
+ vue.createCommentVNode(" picture "),
148
+ _ctx.listType === "picture" || _ctx.file.status !== "uploading" && _ctx.listType === "picture-card" ? (vue.openBlock(), vue.createElementBlock(
149
+ vue.Fragment,
150
+ { key: 0 },
151
+ [
152
+ /\.(svg|png|jpg|jpeg)$/.test(_ctx.file.name) ? (vue.openBlock(), vue.createElementBlock("img", {
153
+ key: 0,
154
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-thumbnail")),
155
+ src: _ctx.file.url,
156
+ alt: ""
157
+ }, null, 10, _hoisted_1$1)) : (vue.openBlock(), vue.createBlock(_component_Document, { key: 1 }))
158
+ ],
159
+ 64
160
+ /* STABLE_FRAGMENT */
161
+ )) : vue.createCommentVNode("v-if", true),
162
+ vue.createCommentVNode(" text "),
163
+ _ctx.listType !== "picture" && (_ctx.file.status === "uploading" || _ctx.listType !== "picture-card") ? (vue.openBlock(), vue.createElementBlock(
164
+ "div",
165
+ {
166
+ key: 1,
167
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-info"))
168
+ },
169
+ [
170
+ vue.createElementVNode(
171
+ "a",
172
+ {
173
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-name")),
174
+ onClick: _cache[1] || (_cache[1] = vue.withModifiers(($event) => _ctx.onPreview(_ctx.file), ["prevent"]))
175
+ },
176
+ [
177
+ vue.createVNode(_component_el_icon, {
178
+ class: vue.normalizeClass(_ctx.nsIcon.m("document"))
179
+ }, {
180
+ default: vue.withCtx(() => [
181
+ vue.createVNode(_component_Document)
182
+ ]),
183
+ _: 1
184
+ /* STABLE */
185
+ }, 8, ["class"]),
186
+ vue.createVNode(_component_el_icon, {
187
+ class: vue.normalizeClass([
188
+ _ctx.nsIcon.m("download"),
189
+ _ctx.nsIcon.m("download-primary")
190
+ ]),
191
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.handleDownload(_ctx.file))
192
+ }, {
193
+ default: vue.withCtx(() => [
194
+ vue.createVNode(_component_Download)
195
+ ]),
196
+ _: 1
197
+ /* STABLE */
198
+ }, 8, ["class"]),
199
+ vue.createElementVNode(
200
+ "span",
201
+ {
202
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-file-name"))
203
+ },
204
+ vue.toDisplayString(_ctx.file.name),
205
+ 3
206
+ /* TEXT, CLASS */
207
+ )
208
+ ],
209
+ 2
210
+ /* CLASS */
211
+ ),
212
+ _ctx.file.status === "uploading" ? (vue.openBlock(), vue.createBlock(_component_el_progress, {
213
+ key: 0,
214
+ type: _ctx.listType === "picture-card" ? "circle" : "line",
215
+ "stroke-width": _ctx.listType === "picture-card" ? 6 : 2,
216
+ percentage: Number(_ctx.file.percentage),
217
+ style: vue.normalizeStyle(_ctx.listType === "picture-card" ? "" : "margin-top: 0.5rem")
218
+ }, null, 8, ["type", "stroke-width", "percentage", "style"])) : vue.createCommentVNode("v-if", true)
219
+ ],
220
+ 2
221
+ /* CLASS */
222
+ )) : vue.createCommentVNode("v-if", true),
223
+ vue.createElementVNode(
224
+ "label",
225
+ {
226
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-status-label"))
227
+ },
228
+ [
229
+ _ctx.listType === "text" ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
230
+ key: 0,
231
+ class: vue.normalizeClass([
232
+ _ctx.nsIcon.m("upload-success"),
233
+ _ctx.nsIcon.m("circle-check")
234
+ ])
235
+ }, {
236
+ default: vue.withCtx(() => [
237
+ vue.createVNode(_component_circle_check)
238
+ ]),
239
+ _: 1
240
+ /* STABLE */
241
+ }, 8, ["class"])) : ["picture-card", "picture"].includes(_ctx.listType) ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
242
+ key: 1,
243
+ class: vue.normalizeClass([_ctx.nsIcon.m("upload-success"), _ctx.nsIcon.m("check")])
244
+ }, {
245
+ default: vue.withCtx(() => [
246
+ vue.createVNode(_component_Check)
247
+ ]),
248
+ _: 1
249
+ /* STABLE */
250
+ }, 8, ["class"])) : vue.createCommentVNode("v-if", true)
251
+ ],
252
+ 2
253
+ /* CLASS */
254
+ ),
255
+ !_ctx.disabled ? (vue.openBlock(), vue.createBlock(_component_el_icon, {
256
+ key: 2,
257
+ class: vue.normalizeClass(_ctx.nsIcon.m("close")),
258
+ onClick: _cache[2] || (_cache[2] = ($event) => _ctx.handleRemove(_ctx.file))
259
+ }, {
260
+ default: vue.withCtx(() => [
261
+ vue.createVNode(_component_Close)
262
+ ]),
263
+ _: 1
264
+ /* STABLE */
265
+ }, 8, ["class"])) : vue.createCommentVNode("v-if", true),
266
+ vue.createCommentVNode(" Due to close btn only appears when li gets focused disappears after li gets blurred, thus keyboard navigation can never reach close btn"),
267
+ vue.createCommentVNode(" This is a bug which needs to be fixed "),
268
+ vue.createCommentVNode(" TODO: Fix the incorrect navigation interaction "),
269
+ vue.createCommentVNode(` <i v-if="!disabled" :class="nsIcon.m('close-tip')">{{
270
+ t('el.upload.deleteTip')
271
+ }}</i> `),
272
+ vue.createCommentVNode(" picture-card "),
273
+ _ctx.listType === "picture-card" ? (vue.openBlock(), vue.createElementBlock(
274
+ "span",
275
+ {
276
+ key: 3,
277
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-actions"))
278
+ },
279
+ [
280
+ _ctx.preview ? (vue.openBlock(), vue.createElementBlock(
281
+ "span",
282
+ {
283
+ key: 0,
284
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-preview")),
285
+ onClick: _cache[3] || (_cache[3] = ($event) => _ctx.onPreview(_ctx.file))
286
+ },
287
+ [
288
+ vue.createVNode(_component_el_icon, {
289
+ class: vue.normalizeClass(_ctx.nsIcon.m("zoom-in"))
290
+ }, {
291
+ default: vue.withCtx(() => [
292
+ vue.createVNode(_component_zoom_in)
293
+ ]),
294
+ _: 1
295
+ /* STABLE */
296
+ }, 8, ["class"])
297
+ ],
298
+ 2
299
+ /* CLASS */
300
+ )) : vue.createCommentVNode("v-if", true),
301
+ vue.createCommentVNode(" \u4E0B\u8F7D "),
302
+ vue.createElementVNode(
303
+ "span",
304
+ {
305
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-download")),
306
+ onClick: _cache[4] || (_cache[4] = ($event) => _ctx.handleDownload(_ctx.file))
307
+ },
308
+ [
309
+ vue.createVNode(_component_el_icon, {
310
+ class: vue.normalizeClass(_ctx.nsIcon.m("download"))
311
+ }, {
312
+ default: vue.withCtx(() => [
313
+ vue.createVNode(_component_Download)
314
+ ]),
315
+ _: 1
316
+ /* STABLE */
317
+ }, 8, ["class"])
318
+ ],
319
+ 2
320
+ /* CLASS */
321
+ ),
322
+ !_ctx.disabled ? (vue.openBlock(), vue.createElementBlock(
323
+ "span",
324
+ {
325
+ key: 1,
326
+ class: vue.normalizeClass(_ctx.nsUpload.be("list", "item-delete")),
327
+ onClick: _cache[5] || (_cache[5] = ($event) => _ctx.handleRemove(_ctx.file))
328
+ },
329
+ [
330
+ vue.createVNode(_component_el_icon, {
331
+ class: vue.normalizeClass(_ctx.nsIcon.m("delete"))
332
+ }, {
333
+ default: vue.withCtx(() => [
334
+ vue.createVNode(_component_Delete)
335
+ ]),
336
+ _: 1
337
+ /* STABLE */
338
+ }, 8, ["class"])
339
+ ],
340
+ 2
341
+ /* CLASS */
342
+ )) : vue.createCommentVNode("v-if", true)
343
+ ],
344
+ 2
345
+ /* CLASS */
346
+ )) : vue.createCommentVNode("v-if", true)
347
+ ],
348
+ 64
349
+ /* STABLE_FRAGMENT */
350
+ );
351
+ }
352
+ var FileVue = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/upload/src/file.vue"]]);
353
+
354
+ var _sfc_main = vue.defineComponent({
355
+ name: "VkfUpload",
356
+ components: {
357
+ VkfFormItem: formItem.VkfFormItem,
358
+ ElUpload: elementPlus.ElUpload,
359
+ FileVue,
360
+ ElLink: elementPlus.ElLink
361
+ },
362
+ props,
363
+ emits,
364
+ setup(props2, { emit }) {
365
+ const formItemBindProps = formItem._VkfFormItemCtx.createBindProps(props2);
366
+ const coreBindProps = elementPlus$1.createUploadBindProps(props2, ["disabled", "fileList", "beforeUpload", "onSuccess"]);
367
+ const uploadRef = vue.shallowRef();
368
+ const handleRemove = (file) => {
369
+ uploadRef.value?.handleRemove(file);
370
+ uploadRef.value?.abort(file);
371
+ emit("update:fileList", props2.fileList);
372
+ };
373
+ const readonly = composables.useComputedReadonly(props2);
374
+ const onSuccess = (response, uploadFile, uploadFiles) => {
375
+ const raw = uploadFile.raw;
376
+ raw.progress(true);
377
+ uploadFile.percentage = 100;
378
+ uploadFile.status = "success";
379
+ props2.onSuccess?.(response, uploadFile, uploadFiles);
380
+ };
381
+ const beforeUpload = async (rawFile) => {
382
+ const effect = (e, s) => {
383
+ const file = props2.fileList.find((item) => item.uid === rawFile.uid);
384
+ if (file) {
385
+ file.percentage = Number((e * 100).toFixed(2));
386
+ if (s === false) {
387
+ file.status = "uploading";
388
+ }
389
+ }
390
+ };
391
+ rawFile.progress = progress(effect)(false);
392
+ if (props2.beforeUpload) {
393
+ const res = await props2.beforeUpload?.(rawFile);
394
+ return res;
395
+ }
396
+ return true;
397
+ };
398
+ return {
399
+ formItemBindProps,
400
+ pickObject: utilsObject.pickObject,
401
+ coreBindProps,
402
+ uploadRef,
403
+ handleRemove,
404
+ readonly,
405
+ onSuccess,
406
+ // onProgress,
407
+ beforeUpload
408
+ };
409
+ }
410
+ });
411
+
412
+ const _hoisted_1 = { class: "el-upload__tip" };
413
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
414
+ const _component_ElLink = vue.resolveComponent("ElLink");
415
+ const _component_FileVue = vue.resolveComponent("FileVue");
416
+ const _component_ElUpload = vue.resolveComponent("ElUpload");
417
+ const _component_VkfFormItem = vue.resolveComponent("VkfFormItem");
418
+ return vue.openBlock(), vue.createBlock(
419
+ _component_VkfFormItem,
420
+ vue.normalizeProps(vue.guardReactiveProps(_ctx.formItemBindProps)),
421
+ {
422
+ default: vue.withCtx(() => [
423
+ vue.createVNode(_component_ElUpload, vue.mergeProps(_ctx.coreBindProps, {
424
+ ref: "uploadRef",
425
+ class: ["vkf-upload", {
426
+ "is-readonly": _ctx.readonly,
427
+ "is-empty": _ctx.fileList?.length === 0,
428
+ "is-limit": _ctx.limit && _ctx.fileList?.length >= _ctx.limit
429
+ }],
430
+ "file-list": _ctx.fileList ?? [],
431
+ "on-success": _ctx.onSuccess,
432
+ "before-upload": _ctx.beforeUpload,
433
+ disabled: _ctx.readonly || _ctx.disabled,
434
+ "onUpdate:fileList": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:fileList", $event))
435
+ }), vue.createSlots({
436
+ file: vue.withCtx(({ file }) => [
437
+ vue.createVNode(_component_FileVue, {
438
+ file,
439
+ "list-type": _ctx.listType,
440
+ disabled: _ctx.readonly || _ctx.disabled,
441
+ "on-preview": _ctx.onPreview,
442
+ preview: _ctx.preview,
443
+ "on-download": _ctx.onDownload,
444
+ onRemove: _ctx.handleRemove
445
+ }, null, 8, ["file", "list-type", "disabled", "on-preview", "preview", "on-download", "onRemove"])
446
+ ]),
447
+ default: vue.withCtx(() => [
448
+ vue.renderSlot(_ctx.$slots, "default", {}, () => [
449
+ vue.createVNode(_component_ElLink, { type: "primary" }, {
450
+ default: vue.withCtx(() => [
451
+ vue.createTextVNode(" + \u9009\u62E9\u6587\u4EF6 ")
452
+ ]),
453
+ _: 1
454
+ /* STABLE */
455
+ })
456
+ ])
457
+ ]),
458
+ _: 2
459
+ /* DYNAMIC */
460
+ }, [
461
+ _ctx.tip ? {
462
+ name: "tip",
463
+ fn: vue.withCtx(() => [
464
+ vue.createElementVNode(
465
+ "div",
466
+ _hoisted_1,
467
+ vue.toDisplayString(_ctx.tip),
468
+ 1
469
+ /* TEXT */
470
+ )
471
+ ]),
472
+ key: "0"
473
+ } : void 0
474
+ ]), 1040, ["class", "file-list", "on-success", "before-upload", "disabled"]),
475
+ vue.createElementVNode(
476
+ "span",
477
+ {
478
+ class: vue.normalizeClass(["vkf-upload-empty-tip", {
479
+ "is-readonly": _ctx.readonly,
480
+ "is-empty": _ctx.fileList?.length === 0
481
+ }])
482
+ },
483
+ "\u6682\u65E0",
484
+ 2
485
+ /* CLASS */
486
+ )
487
+ ]),
488
+ _: 3
489
+ /* FORWARDED */
490
+ },
491
+ 16
492
+ /* FULL_PROPS */
493
+ );
494
+ }
495
+ var VkfUpload = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/private-vunk-form/private-vunk-form/packages/components/upload/src/index.vue"]]);
496
+
497
+ var types = /*#__PURE__*/Object.freeze({
498
+ __proto__: null
499
+ });
500
+
501
+ VkfUpload.install = (app) => {
502
+ app.component(VkfUpload.name, VkfUpload);
503
+ };
504
+
505
+ exports.VkfUpload = VkfUpload;
506
+ exports._VkfUploadCtx = ctx;
507
+ exports.__VkfUpload = types;
508
+ exports.default = VkfUpload;