@vunk/form 1.0.1 → 1.1.2

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 (38) hide show
  1. package/components/geoinput/index.d.ts +4 -0
  2. package/components/geoinput/index.js +94 -0
  3. package/components/geoinput/src/ctx.d.ts +218 -0
  4. package/components/geoinput/src/ctx.js +39 -0
  5. package/components/geoinput/src/index.vue.d.ts +608 -0
  6. package/components/geoinput/src/types.d.ts +12 -0
  7. package/components/geoinput/src/types.js +1 -0
  8. package/components/geoinput-read/index.css +9 -0
  9. package/components/geoinput-read/index.d.ts +5 -0
  10. package/components/geoinput-read/index.js +355 -0
  11. package/components/geoinput-read/src/append.vue.d.ts +6 -0
  12. package/components/geoinput-read/src/core.vue.d.ts +457 -0
  13. package/components/geoinput-read/src/ctx.d.ts +205 -0
  14. package/components/geoinput-read/src/ctx.js +62 -0
  15. package/components/geoinput-read/src/index.vue.d.ts +486 -0
  16. package/components/geoinput-read/src/types.d.ts +3 -0
  17. package/components/geoinput-read/src/types.js +1 -0
  18. package/components/geoinput-update/index.css +44 -0
  19. package/components/geoinput-update/index.d.ts +5 -0
  20. package/components/geoinput-update/index.js +982 -0
  21. package/components/geoinput-update/src/append.vue.d.ts +20 -0
  22. package/components/geoinput-update/src/ctx.d.ts +211 -0
  23. package/components/geoinput-update/src/ctx.js +85 -0
  24. package/components/geoinput-update/src/index.vue.d.ts +483 -0
  25. package/components/geoinput-update/src/types.d.ts +6 -0
  26. package/components/geoinput-update/src/types.js +1 -0
  27. package/components/input-link/index.js +1 -1
  28. package/components/templates-mapbox/index.d.ts +4 -0
  29. package/components/templates-mapbox/index.js +64 -0
  30. package/components/templates-mapbox/src/ctx.d.ts +11 -0
  31. package/components/templates-mapbox/src/ctx.js +11 -0
  32. package/components/templates-mapbox/src/index.vue.d.ts +20 -0
  33. package/components/templates-mapbox/src/types.d.ts +3 -0
  34. package/components/templates-mapbox/src/types.js +1 -0
  35. package/index.css +55 -0
  36. package/package.json +1 -1
  37. package/shared/types/form/radio.d.ts +1 -1
  38. package/shared/types/source/index.d.ts +2 -1
@@ -0,0 +1,982 @@
1
+ import { _VkfInputCtx, VkfInput } from '@vunk/form/components/input';
2
+ import { EMPTY_FEATURE_COLLECTION } from '@vumap/core/shared/static';
3
+ import { bindPropsFactory, onEmitsFactory } from '@vunk/core/shared/utils-vue';
4
+ import { openBlock, createElementBlock, createElementVNode, defineComponent, resolveComponent, createBlock, withCtx, createVNode, normalizeClass, createCommentVNode, computed, shallowRef, ref, onMounted, nextTick, mergeProps, toHandlers, withModifiers, renderSlot, resolveDynamicComponent, withDirectives, vShow } from 'vue';
5
+ import { ElButton, ElIcon, ElButtonGroup, ElUpload, ElDialog, ElMessage } from 'element-plus';
6
+ import { VmMap } from '@vumap/core';
7
+ import { VmTdtLayers } from '@vumap/core/components/tdt-layers';
8
+ import { VmControlDraw } from '@vumap/core/components/control-draw';
9
+ import { Deferred } from '@vunk/core/shared/utils-promise';
10
+ import { VkAsyncTeleport } from '@vunk/core';
11
+ import { VmControlDrawUi } from '@vumap/core/components/control-draw-ui';
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __defProps = Object.defineProperties;
15
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
16
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
17
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
18
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
19
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
20
+ var __spreadValues = (a, b) => {
21
+ for (var prop in b || (b = {}))
22
+ if (__hasOwnProp.call(b, prop))
23
+ __defNormalProp(a, prop, b[prop]);
24
+ if (__getOwnPropSymbols)
25
+ for (var prop of __getOwnPropSymbols(b)) {
26
+ if (__propIsEnum.call(b, prop))
27
+ __defNormalProp(a, prop, b[prop]);
28
+ }
29
+ return a;
30
+ };
31
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
32
+ const props = __spreadProps(__spreadValues({}, _VkfInputCtx.props), {
33
+ showMap: {
34
+ type: Boolean,
35
+ default: false
36
+ },
37
+ dialogEdit: {
38
+ type: Boolean,
39
+ default: true
40
+ },
41
+ dialogEditFullscreen: {
42
+ type: Boolean,
43
+ default: true
44
+ },
45
+ dialogEditTitle: {
46
+ type: String,
47
+ default: "\u7ED8\u5236\u56FE\u6591"
48
+ },
49
+ modelValue: {
50
+ type: Object,
51
+ default: () => EMPTY_FEATURE_COLLECTION
52
+ },
53
+ editControls: {
54
+ type: Array,
55
+ default: () => ["trash"]
56
+ },
57
+ editTypes: {
58
+ type: [Array, String],
59
+ default: () => "polygon"
60
+ },
61
+ multiple: {
62
+ type: Boolean,
63
+ default: true
64
+ },
65
+ mapTo: {
66
+ type: [Object, String],
67
+ default: void 0
68
+ },
69
+ mapCenter: {
70
+ type: [Object, Array],
71
+ default: [120, 30]
72
+ },
73
+ editStyles: {
74
+ type: Array,
75
+ default: () => []
76
+ },
77
+ slots: {
78
+ type: Object,
79
+ default: () => ({})
80
+ },
81
+ spikSave: {
82
+ type: Boolean,
83
+ default: false
84
+ }
85
+ });
86
+ const createBindProps = bindPropsFactory(props);
87
+ const emits = __spreadProps(__spreadValues({}, _VkfInputCtx.emits), {
88
+ "update:modelValue": (e) => e,
89
+ "editUpdate": (e) => e
90
+ });
91
+ const createOnEmits = onEmitsFactory(emits);
92
+
93
+ var ctx = /*#__PURE__*/Object.freeze({
94
+ __proto__: null,
95
+ props: props,
96
+ createBindProps: createBindProps,
97
+ emits: emits,
98
+ createOnEmits: createOnEmits
99
+ });
100
+
101
+ /*! Element Plus Icons Vue v2.1.0 */
102
+
103
+ // unplugin-vue:/plugin-vue/export-helper
104
+ var export_helper_default = (sfc, props) => {
105
+ let target = sfc.__vccOpts || sfc;
106
+ for (let [key, val] of props)
107
+ target[key] = val;
108
+ return target;
109
+ };
110
+
111
+ // unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/checked.vue?vue&type=script&lang.ts
112
+ var checked_vue_vue_type_script_lang_default = {
113
+ name: "Checked"
114
+ };
115
+ var _hoisted_144 = {
116
+ xmlns: "http://www.w3.org/2000/svg",
117
+ viewBox: "0 0 1024 1024"
118
+ }, _hoisted_244 = /* @__PURE__ */ createElementVNode(
119
+ "path",
120
+ {
121
+ fill: "currentColor",
122
+ d: "M704 192h160v736H160V192h160.064v64H704v-64zM311.616 537.28l-45.312 45.248L447.36 763.52l316.8-316.8-45.312-45.184L447.36 673.024 311.616 537.28zM384 192V96h256v96H384z"
123
+ },
124
+ null,
125
+ -1
126
+ /* HOISTED */
127
+ ), _hoisted_343 = [
128
+ _hoisted_244
129
+ ];
130
+ function _sfc_render44(_ctx, _cache, $props, $setup, $data, $options) {
131
+ return openBlock(), createElementBlock("svg", _hoisted_144, _hoisted_343);
132
+ }
133
+ var checked_default = /* @__PURE__ */ export_helper_default(checked_vue_vue_type_script_lang_default, [["render", _sfc_render44], ["__file", "checked.vue"]]);
134
+
135
+ // unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/edit.vue?vue&type=script&lang.ts
136
+ var edit_vue_vue_type_script_lang_default = {
137
+ name: "Edit"
138
+ };
139
+ var _hoisted_194 = {
140
+ xmlns: "http://www.w3.org/2000/svg",
141
+ viewBox: "0 0 1024 1024"
142
+ }, _hoisted_294 = /* @__PURE__ */ createElementVNode(
143
+ "path",
144
+ {
145
+ fill: "currentColor",
146
+ d: "M832 512a32 32 0 1 1 64 0v352a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V160a32 32 0 0 1 32-32h352a32 32 0 0 1 0 64H192v640h640V512z"
147
+ },
148
+ null,
149
+ -1
150
+ /* HOISTED */
151
+ ), _hoisted_393 = /* @__PURE__ */ createElementVNode(
152
+ "path",
153
+ {
154
+ fill: "currentColor",
155
+ d: "m469.952 554.24 52.8-7.552L847.104 222.4a32 32 0 1 0-45.248-45.248L477.44 501.44l-7.552 52.8zm422.4-422.4a96 96 0 0 1 0 135.808l-331.84 331.84a32 32 0 0 1-18.112 9.088L436.8 623.68a32 32 0 0 1-36.224-36.224l15.104-105.6a32 32 0 0 1 9.024-18.112l331.904-331.84a96 96 0 0 1 135.744 0z"
156
+ },
157
+ null,
158
+ -1
159
+ /* HOISTED */
160
+ ), _hoisted_431 = [
161
+ _hoisted_294,
162
+ _hoisted_393
163
+ ];
164
+ function _sfc_render94(_ctx, _cache, $props, $setup, $data, $options) {
165
+ return openBlock(), createElementBlock("svg", _hoisted_194, _hoisted_431);
166
+ }
167
+ var edit_default = /* @__PURE__ */ export_helper_default(edit_vue_vue_type_script_lang_default, [["render", _sfc_render94], ["__file", "edit.vue"]]);
168
+
169
+ // unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/upload.vue?vue&type=script&lang.ts
170
+ var upload_vue_vue_type_script_lang_default = {
171
+ name: "Upload"
172
+ };
173
+ var _hoisted_1275 = {
174
+ xmlns: "http://www.w3.org/2000/svg",
175
+ viewBox: "0 0 1024 1024"
176
+ }, _hoisted_2275 = /* @__PURE__ */ createElementVNode(
177
+ "path",
178
+ {
179
+ fill: "currentColor",
180
+ d: "M160 832h704a32 32 0 1 1 0 64H160a32 32 0 1 1 0-64zm384-578.304V704h-64V247.296L237.248 490.048 192 444.8 508.8 128l316.8 316.8-45.312 45.248L544 253.696z"
181
+ },
182
+ null,
183
+ -1
184
+ /* HOISTED */
185
+ ), _hoisted_3274 = [
186
+ _hoisted_2275
187
+ ];
188
+ function _sfc_render275(_ctx, _cache, $props, $setup, $data, $options) {
189
+ return openBlock(), createElementBlock("svg", _hoisted_1275, _hoisted_3274);
190
+ }
191
+ var upload_default = /* @__PURE__ */ export_helper_default(upload_vue_vue_type_script_lang_default, [["render", _sfc_render275], ["__file", "upload.vue"]]);
192
+
193
+ var _export_sfc = (sfc, props) => {
194
+ const target = sfc.__vccOpts || sfc;
195
+ for (const [key, val] of props) {
196
+ target[key] = val;
197
+ }
198
+ return target;
199
+ };
200
+
201
+ const _sfc_main$1 = defineComponent({
202
+ components: {
203
+ ElButton,
204
+ ElIcon,
205
+ ElButtonGroup,
206
+ Upload: upload_default,
207
+ Edit: edit_default,
208
+ ElUpload
209
+ },
210
+ props: {
211
+ disabled: Boolean,
212
+ dialog: Boolean
213
+ },
214
+ emits: {
215
+ upload: (e) => e,
216
+ edit: null
217
+ },
218
+ methods: {
219
+ getFile(file) {
220
+ this.$emit("upload", file);
221
+ }
222
+ }
223
+ });
224
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
225
+ const _component_Upload = resolveComponent("Upload");
226
+ const _component_ElIcon = resolveComponent("ElIcon");
227
+ const _component_ElUpload = resolveComponent("ElUpload");
228
+ const _component_ElButton = resolveComponent("ElButton");
229
+ const _component_Edit = resolveComponent("Edit");
230
+ const _component_ElButtonGroup = resolveComponent("ElButtonGroup");
231
+ return openBlock(), createBlock(_component_ElButtonGroup, null, {
232
+ default: withCtx(() => [
233
+ createVNode(_component_ElButton, { class: "vk-geoinput-upload-x" }, {
234
+ default: withCtx(() => [
235
+ createVNode(_component_ElUpload, {
236
+ class: normalizeClass("vk-geoinput-upload"),
237
+ action: "",
238
+ accept: "file",
239
+ multiple: false,
240
+ "show-file-list": false,
241
+ "auto-upload": false,
242
+ "on-change": _ctx.getFile,
243
+ disabled: _ctx.disabled
244
+ }, {
245
+ default: withCtx(() => [
246
+ createVNode(_component_ElIcon, { color: "var(--el-color-primary)" }, {
247
+ default: withCtx(() => [
248
+ createVNode(_component_Upload)
249
+ ]),
250
+ _: 1
251
+ }, 8, ["color"])
252
+ ]),
253
+ _: 1
254
+ }, 8, ["on-change", "disabled"])
255
+ ]),
256
+ _: 1
257
+ }),
258
+ _ctx.dialog ? (openBlock(), createBlock(_component_ElButton, {
259
+ key: 0,
260
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("edit")),
261
+ disabled: _ctx.disabled
262
+ }, {
263
+ default: withCtx(() => [
264
+ createVNode(_component_ElIcon, { color: "var(--el-color-primary)" }, {
265
+ default: withCtx(() => [
266
+ createVNode(_component_Edit)
267
+ ]),
268
+ _: 1
269
+ }, 8, ["color"])
270
+ ]),
271
+ _: 1
272
+ }, 8, ["disabled"])) : createCommentVNode("v-if", true)
273
+ ]),
274
+ _: 1
275
+ });
276
+ }
277
+ var AppendVue = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__file", "append.vue"]]);
278
+
279
+ function array_cancel() {
280
+ this._array = null;
281
+ return Promise.resolve();
282
+ }
283
+
284
+ function array_read() {
285
+ var array = this._array;
286
+ this._array = null;
287
+ return Promise.resolve(array ? {done: false, value: array} : {done: true, value: undefined});
288
+ }
289
+
290
+ function array(array) {
291
+ return new ArraySource(array instanceof Uint8Array ? array : new Uint8Array(array));
292
+ }
293
+
294
+ function ArraySource(array) {
295
+ this._array = array;
296
+ }
297
+
298
+ ArraySource.prototype.read = array_read;
299
+ ArraySource.prototype.cancel = array_cancel;
300
+
301
+ function fetchPath(url) {
302
+ return fetch(url).then(function(response) {
303
+ return response.body && response.body.getReader
304
+ ? response.body.getReader()
305
+ : response.arrayBuffer().then(array);
306
+ });
307
+ }
308
+
309
+ function requestPath(url) {
310
+ return new Promise(function(resolve, reject) {
311
+ var request = new XMLHttpRequest;
312
+ request.responseType = "arraybuffer";
313
+ request.onload = function() { resolve(array(request.response)); };
314
+ request.onerror = reject;
315
+ request.ontimeout = reject;
316
+ request.open("GET", url, true);
317
+ request.send();
318
+ });
319
+ }
320
+
321
+ function path(path) {
322
+ return (typeof fetch === "function" ? fetchPath : requestPath)(path);
323
+ }
324
+
325
+ function stream(source) {
326
+ return typeof source.read === "function" ? source : source.getReader();
327
+ }
328
+
329
+ var empty = new Uint8Array(0);
330
+
331
+ function slice_cancel() {
332
+ return this._source.cancel();
333
+ }
334
+
335
+ function concat$1(a, b) {
336
+ if (!a.length) return b;
337
+ if (!b.length) return a;
338
+ var c = new Uint8Array(a.length + b.length);
339
+ c.set(a);
340
+ c.set(b, a.length);
341
+ return c;
342
+ }
343
+
344
+ function slice_read() {
345
+ var that = this, array = that._array.subarray(that._index);
346
+ return that._source.read().then(function(result) {
347
+ that._array = empty;
348
+ that._index = 0;
349
+ return result.done ? (array.length > 0
350
+ ? {done: false, value: array}
351
+ : {done: true, value: undefined})
352
+ : {done: false, value: concat$1(array, result.value)};
353
+ });
354
+ }
355
+
356
+ function slice_slice(length) {
357
+ if ((length |= 0) < 0) throw new Error("invalid length");
358
+ var that = this, index = this._array.length - this._index;
359
+
360
+ // If the request fits within the remaining buffer, resolve it immediately.
361
+ if (this._index + length <= this._array.length) {
362
+ return Promise.resolve(this._array.subarray(this._index, this._index += length));
363
+ }
364
+
365
+ // Otherwise, read chunks repeatedly until the request is fulfilled.
366
+ var array = new Uint8Array(length);
367
+ array.set(this._array.subarray(this._index));
368
+ return (function read() {
369
+ return that._source.read().then(function(result) {
370
+
371
+ // When done, it’s possible the request wasn’t fully fullfilled!
372
+ // If so, the pre-allocated array is too big and needs slicing.
373
+ if (result.done) {
374
+ that._array = empty;
375
+ that._index = 0;
376
+ return index > 0 ? array.subarray(0, index) : null;
377
+ }
378
+
379
+ // If this chunk fulfills the request, return the resulting array.
380
+ if (index + result.value.length >= length) {
381
+ that._array = result.value;
382
+ that._index = length - index;
383
+ array.set(result.value.subarray(0, length - index), index);
384
+ return array;
385
+ }
386
+
387
+ // Otherwise copy this chunk into the array, then read the next chunk.
388
+ array.set(result.value, index);
389
+ index += result.value.length;
390
+ return read();
391
+ });
392
+ })();
393
+ }
394
+
395
+ function slice(source) {
396
+ return typeof source.slice === "function" ? source :
397
+ new SliceSource(typeof source.read === "function" ? source
398
+ : source.getReader());
399
+ }
400
+
401
+ function SliceSource(source) {
402
+ this._source = source;
403
+ this._array = empty;
404
+ this._index = 0;
405
+ }
406
+
407
+ SliceSource.prototype.read = slice_read;
408
+ SliceSource.prototype.slice = slice_slice;
409
+ SliceSource.prototype.cancel = slice_cancel;
410
+
411
+ function dbf_cancel() {
412
+ return this._source.cancel();
413
+ }
414
+
415
+ function readBoolean(value) {
416
+ return /^[nf]$/i.test(value) ? false
417
+ : /^[yt]$/i.test(value) ? true
418
+ : null;
419
+ }
420
+
421
+ function readDate(value) {
422
+ return new Date(+value.substring(0, 4), value.substring(4, 6) - 1, +value.substring(6, 8));
423
+ }
424
+
425
+ function readNumber(value) {
426
+ return !(value = value.trim()) || isNaN(value = +value) ? null : value;
427
+ }
428
+
429
+ function readString(value) {
430
+ return value.trim() || null;
431
+ }
432
+
433
+ var types$1 = {
434
+ B: readNumber,
435
+ C: readString,
436
+ D: readDate,
437
+ F: readNumber,
438
+ L: readBoolean,
439
+ M: readNumber,
440
+ N: readNumber
441
+ };
442
+
443
+ function dbf_read() {
444
+ var that = this, i = 1;
445
+ return that._source.slice(that._recordLength).then(function(value) {
446
+ return value && (value[0] !== 0x1a) ? {done: false, value: that._fields.reduce(function(p, f) {
447
+ p[f.name] = types$1[f.type](that._decode(value.subarray(i, i += f.length)));
448
+ return p;
449
+ }, {})} : {done: true, value: undefined};
450
+ });
451
+ }
452
+
453
+ function view(array) {
454
+ return new DataView(array.buffer, array.byteOffset, array.byteLength);
455
+ }
456
+
457
+ function dbf(source, decoder) {
458
+ source = slice(source);
459
+ return source.slice(32).then(function(array) {
460
+ var head = view(array);
461
+ return source.slice(head.getUint16(8, true) - 32).then(function(array) {
462
+ return new Dbf(source, decoder, head, view(array));
463
+ });
464
+ });
465
+ }
466
+
467
+ function Dbf(source, decoder, head, body) {
468
+ this._source = source;
469
+ this._decode = decoder.decode.bind(decoder);
470
+ this._recordLength = head.getUint16(10, true);
471
+ this._fields = [];
472
+ for (var n = 0; body.getUint8(n) !== 0x0d; n += 32) {
473
+ for (var j = 0; j < 11; ++j) if (body.getUint8(n + j) === 0) break;
474
+ this._fields.push({
475
+ name: this._decode(new Uint8Array(body.buffer, body.byteOffset + n, j)),
476
+ type: String.fromCharCode(body.getUint8(n + 11)),
477
+ length: body.getUint8(n + 16)
478
+ });
479
+ }
480
+ }
481
+
482
+ var prototype$2 = Dbf.prototype;
483
+ prototype$2.read = dbf_read;
484
+ prototype$2.cancel = dbf_cancel;
485
+
486
+ function cancel() {
487
+ return this._source.cancel();
488
+ }
489
+
490
+ function parseMultiPoint(record) {
491
+ var i = 40, j, n = record.getInt32(36, true), coordinates = new Array(n);
492
+ for (j = 0; j < n; ++j, i += 16) coordinates[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
493
+ return {type: "MultiPoint", coordinates: coordinates};
494
+ }
495
+
496
+ function parseNull() {
497
+ return null;
498
+ }
499
+
500
+ function parsePoint(record) {
501
+ return {type: "Point", coordinates: [record.getFloat64(4, true), record.getFloat64(12, true)]};
502
+ }
503
+
504
+ function parsePolygon(record) {
505
+ var i = 44, j, n = record.getInt32(36, true), m = record.getInt32(40, true), parts = new Array(n), points = new Array(m), polygons = [], holes = [];
506
+ for (j = 0; j < n; ++j, i += 4) parts[j] = record.getInt32(i, true);
507
+ for (j = 0; j < m; ++j, i += 16) points[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
508
+
509
+ parts.forEach(function(i, j) {
510
+ var ring = points.slice(i, parts[j + 1]);
511
+ if (ringClockwise(ring)) polygons.push([ring]);
512
+ else holes.push(ring);
513
+ });
514
+
515
+ holes.forEach(function(hole) {
516
+ polygons.some(function(polygon) {
517
+ if (ringContainsSome(polygon[0], hole)) {
518
+ polygon.push(hole);
519
+ return true;
520
+ }
521
+ }) || polygons.push([hole]);
522
+ });
523
+
524
+ return polygons.length === 1
525
+ ? {type: "Polygon", coordinates: polygons[0]}
526
+ : {type: "MultiPolygon", coordinates: polygons};
527
+ }
528
+ function ringClockwise(ring) {
529
+ if ((n = ring.length) < 4) return false;
530
+ var i = 0, n, area = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1];
531
+ while (++i < n) area += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1];
532
+ return area >= 0;
533
+ }
534
+
535
+ function ringContainsSome(ring, hole) {
536
+ var i = -1, n = hole.length, c;
537
+ while (++i < n) {
538
+ if (c = ringContains(ring, hole[i])) {
539
+ return c > 0;
540
+ }
541
+ }
542
+ return false;
543
+ }
544
+
545
+ function ringContains(ring, point) {
546
+ var x = point[0], y = point[1], contains = -1;
547
+ for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) {
548
+ var pi = ring[i], xi = pi[0], yi = pi[1],
549
+ pj = ring[j], xj = pj[0], yj = pj[1];
550
+ if (segmentContains(pi, pj, point)) {
551
+ return 0;
552
+ }
553
+ if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) {
554
+ contains = -contains;
555
+ }
556
+ }
557
+ return contains;
558
+ }
559
+
560
+ function segmentContains(p0, p1, p2) {
561
+ var x20 = p2[0] - p0[0], y20 = p2[1] - p0[1];
562
+ if (x20 === 0 && y20 === 0) return true;
563
+ var x10 = p1[0] - p0[0], y10 = p1[1] - p0[1];
564
+ if (x10 === 0 && y10 === 0) return false;
565
+ var t = (x20 * x10 + y20 * y10) / (x10 * x10 + y10 * y10);
566
+ return t < 0 || t > 1 ? false : t === 0 || t === 1 ? true : t * x10 === x20 && t * y10 === y20;
567
+ }
568
+
569
+ function parsePolyLine(record) {
570
+ var i = 44, j, n = record.getInt32(36, true), m = record.getInt32(40, true), parts = new Array(n), points = new Array(m);
571
+ for (j = 0; j < n; ++j, i += 4) parts[j] = record.getInt32(i, true);
572
+ for (j = 0; j < m; ++j, i += 16) points[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
573
+ return n === 1
574
+ ? {type: "LineString", coordinates: points}
575
+ : {type: "MultiLineString", coordinates: parts.map(function(i, j) { return points.slice(i, parts[j + 1]); })};
576
+ }
577
+
578
+ function concat(a, b) {
579
+ var ab = new Uint8Array(a.length + b.length);
580
+ ab.set(a, 0);
581
+ ab.set(b, a.length);
582
+ return ab;
583
+ }
584
+
585
+ function shp_read() {
586
+ var that = this;
587
+ ++that._index;
588
+ return that._source.slice(12).then(function(array) {
589
+ if (array == null) return {done: true, value: undefined};
590
+ var header = view(array);
591
+
592
+ // If the record starts with an invalid shape type (see #36), scan ahead in
593
+ // four-byte increments to find the next valid record, identified by the
594
+ // expected index, a non-empty content length and a valid shape type.
595
+ function skip() {
596
+ return that._source.slice(4).then(function(chunk) {
597
+ if (chunk == null) return {done: true, value: undefined};
598
+ header = view(array = concat(array.slice(4), chunk));
599
+ return header.getInt32(0, false) !== that._index ? skip() : read();
600
+ });
601
+ }
602
+
603
+ // All records should have at least four bytes (for the record shape type),
604
+ // so an invalid content length indicates corruption.
605
+ function read() {
606
+ var length = header.getInt32(4, false) * 2 - 4, type = header.getInt32(8, true);
607
+ return length < 0 || (type && type !== that._type) ? skip() : that._source.slice(length).then(function(chunk) {
608
+ return {done: false, value: type ? that._parse(view(concat(array.slice(8), chunk))) : null};
609
+ });
610
+ }
611
+
612
+ return read();
613
+ });
614
+ }
615
+
616
+ var parsers = {
617
+ 0: parseNull,
618
+ 1: parsePoint,
619
+ 3: parsePolyLine,
620
+ 5: parsePolygon,
621
+ 8: parseMultiPoint,
622
+ 11: parsePoint, // PointZ
623
+ 13: parsePolyLine, // PolyLineZ
624
+ 15: parsePolygon, // PolygonZ
625
+ 18: parseMultiPoint, // MultiPointZ
626
+ 21: parsePoint, // PointM
627
+ 23: parsePolyLine, // PolyLineM
628
+ 25: parsePolygon, // PolygonM
629
+ 28: parseMultiPoint // MultiPointM
630
+ };
631
+
632
+ function shp(source) {
633
+ source = slice(source);
634
+ return source.slice(100).then(function(array) {
635
+ return new Shp(source, view(array));
636
+ });
637
+ }
638
+ function Shp(source, header) {
639
+ var type = header.getInt32(32, true);
640
+ if (!(type in parsers)) throw new Error("unsupported shape type: " + type);
641
+ this._source = source;
642
+ this._type = type;
643
+ this._index = 0;
644
+ this._parse = parsers[type];
645
+ this.bbox = [header.getFloat64(36, true), header.getFloat64(44, true), header.getFloat64(52, true), header.getFloat64(60, true)];
646
+ }
647
+
648
+ var prototype$1 = Shp.prototype;
649
+ prototype$1.read = shp_read;
650
+ prototype$1.cancel = cancel;
651
+
652
+ function noop() {}
653
+
654
+ function shapefile_cancel() {
655
+ return Promise.all([
656
+ this._dbf && this._dbf.cancel(),
657
+ this._shp.cancel()
658
+ ]).then(noop);
659
+ }
660
+
661
+ function shapefile_read() {
662
+ var that = this;
663
+ return Promise.all([
664
+ that._dbf ? that._dbf.read() : {value: {}},
665
+ that._shp.read()
666
+ ]).then(function(results) {
667
+ var dbf = results[0], shp = results[1];
668
+ return shp.done ? shp : {
669
+ done: false,
670
+ value: {
671
+ type: "Feature",
672
+ properties: dbf.value,
673
+ geometry: shp.value
674
+ }
675
+ };
676
+ });
677
+ }
678
+
679
+ function shapefile(shpSource, dbfSource, decoder) {
680
+ return Promise.all([
681
+ shp(shpSource),
682
+ dbfSource && dbf(dbfSource, decoder)
683
+ ]).then(function(sources) {
684
+ return new Shapefile(sources[0], sources[1]);
685
+ });
686
+ }
687
+
688
+ function Shapefile(shp, dbf) {
689
+ this._shp = shp;
690
+ this._dbf = dbf;
691
+ this.bbox = shp.bbox;
692
+ }
693
+
694
+ var prototype = Shapefile.prototype;
695
+ prototype.read = shapefile_read;
696
+ prototype.cancel = shapefile_cancel;
697
+
698
+ function open(shp, dbf, options) {
699
+ if (typeof dbf === "string") {
700
+ if (!/\.dbf$/.test(dbf)) dbf += ".dbf";
701
+ dbf = path(dbf);
702
+ } else if (dbf instanceof ArrayBuffer || dbf instanceof Uint8Array) {
703
+ dbf = array(dbf);
704
+ } else if (dbf != null) {
705
+ dbf = stream(dbf);
706
+ }
707
+ if (typeof shp === "string") {
708
+ if (!/\.shp$/.test(shp)) shp += ".shp";
709
+ if (dbf === undefined) dbf = path(shp.substring(0, shp.length - 4) + ".dbf").catch(function() {});
710
+ shp = path(shp);
711
+ } else if (shp instanceof ArrayBuffer || shp instanceof Uint8Array) {
712
+ shp = array(shp);
713
+ } else {
714
+ shp = stream(shp);
715
+ }
716
+ return Promise.all([shp, dbf]).then(function(sources) {
717
+ var shp = sources[0], dbf = sources[1], encoding = "windows-1252";
718
+ if (options && options.encoding != null) encoding = options.encoding;
719
+ return shapefile(shp, dbf, dbf && new TextDecoder(encoding));
720
+ });
721
+ }
722
+
723
+ const shpToGeojson = (file) => {
724
+ return new Promise((resolve, reject) => {
725
+ const reader = new FileReader();
726
+ reader.readAsArrayBuffer(file);
727
+ const data = {
728
+ type: "FeatureCollection",
729
+ features: []
730
+ };
731
+ reader.onload = function() {
732
+ open(this.result).then((source) => source.read().then(
733
+ function log(result) {
734
+ if (!result.done) {
735
+ data.features.push(result.value);
736
+ source.read().then(log);
737
+ } else {
738
+ if (result.value) {
739
+ data.features.push(result.value);
740
+ }
741
+ resolve(data);
742
+ }
743
+ }
744
+ )).catch(reject);
745
+ };
746
+ });
747
+ };
748
+
749
+ const toGeojson = (file) => {
750
+ const actions = {
751
+ shp: shpToGeojson
752
+ };
753
+ return new Promise((resolve, reject) => {
754
+ const suffix = file.name.split(".").pop();
755
+ if (suffix && actions[suffix]) {
756
+ resolve(actions[suffix](file));
757
+ } else {
758
+ reject(new Error(`Can't resolve the .${suffix} file`));
759
+ }
760
+ });
761
+ };
762
+
763
+ var _sfc_main = defineComponent({
764
+ name: "VkfGeoinputUpdate",
765
+ components: {
766
+ VkfInput,
767
+ ElDialog,
768
+ VmMap,
769
+ VmTdtLayers,
770
+ VmControlDraw,
771
+ VkAsyncTeleport,
772
+ VmControlDrawUi,
773
+ ElIcon,
774
+ Checked: checked_default
775
+ },
776
+ emits,
777
+ props,
778
+ setup(props2, { emit }) {
779
+ const inputBindProps = _VkfInputCtx.createBindProps(props2, [
780
+ "inputSlots",
781
+ "readonly",
782
+ "modelValue"
783
+ ]);
784
+ const inputOnEmits = _VkfInputCtx.createOnEmits(emit, ["update:modelValue"]);
785
+ const mapOptions = computed(() => {
786
+ return {
787
+ center: props2.mapCenter
788
+ };
789
+ });
790
+ const geoInputMapDialogNode = shallowRef();
791
+ const geoInputMapXNode = shallowRef();
792
+ const editPlayground = ref(geoInputMapXNode.value);
793
+ onMounted(() => {
794
+ editPlayground.value = geoInputMapXNode.value;
795
+ });
796
+ const mapTo = computed(() => {
797
+ var _a;
798
+ return editPlayground.value === geoInputMapDialogNode.value ? geoInputMapDialogNode.value : (_a = props2.mapTo) != null ? _a : editPlayground.value;
799
+ });
800
+ const mapControls = computed(() => {
801
+ return props2.readonly ? [] : typeof props2.editTypes === "string" ? [props2.editTypes, ...props2.editControls] : [...props2.editTypes, ...props2.editControls];
802
+ });
803
+ const currentDrawCacheValue = ref(props2.modelValue);
804
+ const currentDrawValue = computed(() => {
805
+ return props2.spikSave ? props2.modelValue : currentDrawCacheValue.value;
806
+ });
807
+ const setCurrentDrawValue = (value) => {
808
+ if (props2.spikSave) {
809
+ emit("update:modelValue", value);
810
+ } else {
811
+ currentDrawCacheValue.value = value;
812
+ }
813
+ };
814
+ const doSave = () => {
815
+ emit("update:modelValue", currentDrawCacheValue.value);
816
+ ElMessage({
817
+ message: "\u4FDD\u5B58\u6210\u529F",
818
+ type: "success"
819
+ });
820
+ dialogShow.value = false;
821
+ };
822
+ const dialogShow = ref(false);
823
+ const mapDef = new Deferred();
824
+ const dialogOnOpen = async () => {
825
+ await nextTick();
826
+ editPlayground.value = geoInputMapDialogNode.value;
827
+ await nextTick();
828
+ const map = await mapDef.promise;
829
+ currentDrawCacheValue.value = props2.modelValue;
830
+ map.resize();
831
+ };
832
+ const dialogOnClose = async () => {
833
+ editPlayground.value = geoInputMapXNode.value;
834
+ const map = await mapDef.promise;
835
+ map.resize();
836
+ };
837
+ const append = () => /* @__PURE__ */ React.createElement(AppendVue, {
838
+ dialog: props2.dialogEdit,
839
+ disabled: props2.disabled,
840
+ onUpload,
841
+ onEdit
842
+ });
843
+ async function onUpload(e) {
844
+ if (!e.raw)
845
+ return;
846
+ toGeojson(e.raw).then((res) => {
847
+ emit("update:modelValue", res);
848
+ });
849
+ }
850
+ function onEdit() {
851
+ dialogShow.value = true;
852
+ }
853
+ return {
854
+ inputBindProps,
855
+ inputOnEmits,
856
+ append,
857
+ dialogShow,
858
+ mapDef,
859
+ dialogOnOpen,
860
+ dialogOnClose,
861
+ mapOptions,
862
+ geoInputMapDialogNode,
863
+ geoInputMapXNode,
864
+ mapTo,
865
+ mapControls,
866
+ doSave,
867
+ currentDrawValue,
868
+ setCurrentDrawValue
869
+ };
870
+ }
871
+ });
872
+
873
+ const _hoisted_1 = { class: "vkf-form-item" };
874
+ const _hoisted_2 = {
875
+ class: "geoinput-map-dialog",
876
+ ref: "geoInputMapDialogNode"
877
+ };
878
+ const _hoisted_3 = {
879
+ class: "geoinput-map-x",
880
+ ref: "geoInputMapXNode"
881
+ };
882
+
883
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
884
+ const _component_VkfInput = resolveComponent("VkfInput");
885
+ const _component_VmTdtLayers = resolveComponent("VmTdtLayers");
886
+ const _component_Checked = resolveComponent("Checked");
887
+ const _component_ElIcon = resolveComponent("ElIcon");
888
+ const _component_VmControlDrawUi = resolveComponent("VmControlDrawUi");
889
+ const _component_VmControlDraw = resolveComponent("VmControlDraw");
890
+ const _component_VmMap = resolveComponent("VmMap");
891
+ const _component_VkAsyncTeleport = resolveComponent("VkAsyncTeleport");
892
+ const _component_ElDialog = resolveComponent("ElDialog");
893
+
894
+ return (openBlock(), createElementBlock("div", _hoisted_1, [
895
+ createVNode(_component_VkfInput, mergeProps({
896
+ readonly: true,
897
+ modelValue: JSON.stringify(_ctx.modelValue)
898
+ }, _ctx.inputBindProps, toHandlers(_ctx.inputOnEmits), {
899
+ inputSlots: _ctx.readonly ? {} : {
900
+ append: _ctx.append
901
+ }
902
+ }), null, 16 /* FULL_PROPS */, ["modelValue", "inputSlots"]),
903
+ createVNode(_component_VkAsyncTeleport, { to: _ctx.mapTo }, {
904
+ default: withCtx(() => [
905
+ createVNode(_component_VmMap, {
906
+ defaultOptions: _ctx.mapOptions,
907
+ class: "vk-geoinput-edit-map",
908
+ onLoad: _cache[1] || (_cache[1] = $event => (_ctx.mapDef.resolve($event.map)))
909
+ }, {
910
+ default: withCtx(() => [
911
+ createVNode(_component_VmTdtLayers),
912
+ createVNode(_component_VmControlDraw, {
913
+ styles: _ctx.editStyles,
914
+ modelValue: _ctx.currentDrawValue,
915
+ "onUpdate:modelValue": _ctx.setCurrentDrawValue,
916
+ onUpdate: _cache[0] || (_cache[0] = $event => (_ctx.$emit('editUpdate', $event))),
917
+ controls: _ctx.mapControls,
918
+ multiple: _ctx.multiple
919
+ }, {
920
+ default: withCtx(() => [
921
+ (!_ctx.spikSave)
922
+ ? (openBlock(), createBlock(_component_VmControlDrawUi, {
923
+ key: 0,
924
+ onClick: withModifiers(_ctx.doSave, ["prevent"])
925
+ }, {
926
+ default: withCtx(() => [
927
+ createVNode(_component_ElIcon, null, {
928
+ default: withCtx(() => [
929
+ createVNode(_component_Checked)
930
+ ]),
931
+ _: 1 /* STABLE */
932
+ })
933
+ ]),
934
+ _: 1 /* STABLE */
935
+ }, 8 /* PROPS */, ["onClick"]))
936
+ : createCommentVNode("v-if", true)
937
+ ]),
938
+ _: 1 /* STABLE */
939
+ }, 8 /* PROPS */, ["styles", "modelValue", "onUpdate:modelValue", "controls", "multiple"]),
940
+ renderSlot(_ctx.$slots, "map"),
941
+ (_ctx.slots.map)
942
+ ? (openBlock(), createBlock(resolveDynamicComponent(typeof _ctx.slots.map === 'function' ? _ctx.slots.map() : _ctx.slots.map), { key: 0 }))
943
+ : createCommentVNode("v-if", true)
944
+ ]),
945
+ _: 3 /* FORWARDED */
946
+ }, 8 /* PROPS */, ["defaultOptions"])
947
+ ]),
948
+ _: 3 /* FORWARDED */
949
+ }, 8 /* PROPS */, ["to"]),
950
+ createVNode(_component_ElDialog, {
951
+ modelValue: _ctx.dialogShow,
952
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = $event => ((_ctx.dialogShow) = $event)),
953
+ title: _ctx.dialogEditTitle,
954
+ fullscreen: _ctx.dialogEditFullscreen,
955
+ modalClass: "vk-geoinput-edit-dialog-x",
956
+ appendToBody: true,
957
+ onOpen: _ctx.dialogOnOpen,
958
+ onClose: _ctx.dialogOnClose,
959
+ closeOnClickModal: false,
960
+ draggable: true
961
+ }, {
962
+ default: withCtx(() => [
963
+ createElementVNode("div", _hoisted_2, null, 512 /* NEED_PATCH */)
964
+ ]),
965
+ _: 1 /* STABLE */
966
+ }, 8 /* PROPS */, ["modelValue", "title", "fullscreen", "onOpen", "onClose"]),
967
+ withDirectives(createElementVNode("div", _hoisted_3, null, 512 /* NEED_PATCH */), [
968
+ [vShow, _ctx.showMap]
969
+ ])
970
+ ]))
971
+ }
972
+ var VkfGeoinputUpdate = /*#__PURE__*/_export_sfc(_sfc_main, [['render',_sfc_render],['__file',"index.vue"]]);
973
+
974
+ var types = /*#__PURE__*/Object.freeze({
975
+ __proto__: null
976
+ });
977
+
978
+ VkfGeoinputUpdate.install = (app) => {
979
+ app.component(VkfGeoinputUpdate.name, VkfGeoinputUpdate);
980
+ };
981
+
982
+ export { VkfGeoinputUpdate, ctx as _VkfGeoinputUpdateCtx, types as __VkfGeoinputUpdate, VkfGeoinputUpdate as default };