@das-fed/ui 7.0.4-test.3 → 7.0.5-test.1

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 (41) hide show
  1. package/package.json +5 -6
  2. package/packages/business-components/currency-page/index.d.ts +1 -3
  3. package/packages/business-components/currency-page/index.js +35 -40
  4. package/packages/business-components/currency-page/index.js.gz +0 -0
  5. package/packages/business-components/currency-page/src/index.vue.d.ts +1 -3
  6. package/packages/business-components/currency-page/src/type.d.ts +0 -6
  7. package/packages/business-components/currency-page/style.css +1 -1
  8. package/packages/components/edit-table/index.d.ts +15 -15
  9. package/packages/components/edit-table/src/index.vue.d.ts +4 -4
  10. package/packages/components/image-upload/index.d.ts +0 -1
  11. package/packages/components/image-upload/index.js +114 -767
  12. package/packages/components/image-upload/index.js.gz +0 -0
  13. package/packages/components/image-upload/src/Index.vue.d.ts +0 -1
  14. package/packages/components/image-upload/src/type.d.ts +0 -3
  15. package/packages/components/image-upload/style.css +1 -1
  16. package/packages/components/image-upload/style.css.gz +0 -0
  17. package/packages/components/image-viewer/index.d.ts +0 -1
  18. package/packages/components/image-viewer/index.js +434 -1086
  19. package/packages/components/image-viewer/index.js.gz +0 -0
  20. package/packages/components/image-viewer/src/Index.vue.d.ts +0 -1
  21. package/packages/components/image-viewer/src/type.d.ts +0 -3
  22. package/packages/components/image-viewer/style.css +1 -1
  23. package/packages/components/image-viewer/style.css.gz +0 -0
  24. package/packages/components/menu-header/index.d.ts +0 -6
  25. package/packages/components/menu-header/index.js +31 -26
  26. package/packages/components/menu-header/index.js.gz +0 -0
  27. package/packages/components/menu-header/src/Index.vue.d.ts +0 -2
  28. package/packages/components/menu-header/src/type.d.ts +1 -6
  29. package/packages/components/menu-header/style.css +1 -1
  30. package/packages/components/menu-header/style.css.gz +0 -0
  31. package/packages/components/select-list/index.d.ts +10 -10
  32. package/packages/components/select-list/src/Index.vue.d.ts +8 -8
  33. package/packages/components/tree-table/index.js +263 -291
  34. package/packages/components/tree-table/index.js.gz +0 -0
  35. package/packages/components/tree-table/src/type.d.ts +1 -1
  36. package/packages/components/tree-table/style.css +1 -1
  37. package/packages/components/tree-table/style.css.gz +0 -0
  38. package/packages/components/image-upload/src/hooks/use-compress-image.d.ts +0 -1
  39. package/packages/components/image-viewer/src/hooks/use-compress-image.d.ts +0 -1
  40. package/packages/components/tree-table/src/hooks/use-five.d.ts +0 -4
  41. package/packages/components/tree-table/src/hooks/use-four.d.ts +0 -4
@@ -1,723 +1,71 @@
1
1
  import '@das-fed/ui/packages/components/image-upload/style.css';
2
- import { withInstall as Ie } from "@das-fed/utils/with-install/index";
3
- import { currentLang as ge, i18n as ve, t as G, setI18nRule as Pe } from "@das-fed/web/packages/i18n/index";
4
- import { getVar as L, setThemeRule as Se } from "@das-fed/web/packages/theme/index";
5
- import { computed as X, defineComponent as je, createElementBlock as Le, openBlock as _e, createCommentVNode as ye, withDirectives as K, createVNode as O, unref as v, normalizeClass as Ne, withCtx as R, createElementVNode as z, toDisplayString as Y, vShow as q, createTextVNode as We } from "vue";
6
- import { UploadDragger as He, Upload as Ve } from "ant-design-vue";
2
+ import { withInstall as O } from "@das-fed/utils/with-install/index";
3
+ import { currentLang as T, i18n as V, t as w, setI18nRule as R } from "@das-fed/web/packages/i18n/index";
4
+ import { getVar as x, setThemeRule as K } from "@das-fed/web/packages/theme/index";
5
+ import { computed as z, defineComponent as W, createElementBlock as P, openBlock as H, createCommentVNode as B, withDirectives as N, createVNode as g, unref as o, normalizeClass as L, withCtx as f, createElementVNode as v, toDisplayString as D, vShow as S, createTextVNode as q } from "vue";
6
+ import { UploadDragger as G, Upload as J } from "ant-design-vue";
7
7
  import "ant-design-vue/es/upload/style/css";
8
- import { DasSpin as $e } from "@das-fed/ui/packages/components/spin/index";
9
- import { DasButton as Ge } from "@das-fed/ui/packages/components/button/index";
10
- import { DasIconAddto as Xe } from "@das-fed/ui/packages/icons/addto/index";
11
- import { DasIconWarning as Ke } from "@das-fed/ui/packages/icons/warning/index";
12
- import { DasMessage as be } from "@das-fed/ui/packages/components/message/index";
13
- import { getFileExtension as Ye } from "@das-fed/utils/common-tools";
14
- import { useModelValue as we } from "@das-fed/utils/vue";
8
+ import { DasSpin as Q } from "@das-fed/ui/packages/components/spin/index";
9
+ import { DasButton as X } from "@das-fed/ui/packages/components/button/index";
10
+ import { DasIconAddto as Y } from "@das-fed/ui/packages/icons/addto/index";
11
+ import { DasIconWarning as Z } from "@das-fed/ui/packages/icons/warning/index";
12
+ import { DasMessage as U } from "@das-fed/ui/packages/components/message/index";
13
+ import { getFileExtension as ee } from "@das-fed/utils/common-tools";
14
+ import { useModelValue as ae } from "@das-fed/utils/vue";
15
15
  import "@das-fed/ui/packages/global/theme";
16
- const qe = () => ({ size2B: (e) => {
17
- isNaN(Number(e)) ? e = e.toString() : e = e + "M";
18
- const a = Number(e.slice(0, -1)), r = e[e.length - 1].toUpperCase(), i = 1024, o = {
19
- M: i * i,
20
- K: i,
16
+ const oe = () => ({ size2B: (t) => {
17
+ isNaN(Number(t)) ? t = t.toString() : t = t + "M";
18
+ const i = Number(t.slice(0, -1)), n = t[t.length - 1].toUpperCase(), l = 1024, C = {
19
+ M: l * l,
20
+ K: l,
21
21
  B: 1
22
22
  };
23
- return { finalSize: a * o[r], sizeText: e };
24
- } });
25
- /*!
26
- * Compressor.js v1.2.1
27
- * https://fengyuanchen.github.io/compressorjs
28
- *
29
- * Copyright 2018-present Chen Fengyuan
30
- * Released under the MIT license
31
- *
32
- * Date: 2023-02-28T14:09:41.732Z
33
- */
34
- function xe(t, e) {
35
- var a = Object.keys(t);
36
- if (Object.getOwnPropertySymbols) {
37
- var r = Object.getOwnPropertySymbols(t);
38
- e && (r = r.filter(function(i) {
39
- return Object.getOwnPropertyDescriptor(t, i).enumerable;
40
- })), a.push.apply(a, r);
41
- }
42
- return a;
43
- }
44
- function j(t) {
45
- for (var e = 1; e < arguments.length; e++) {
46
- var a = arguments[e] != null ? arguments[e] : {};
47
- e % 2 ? xe(Object(a), !0).forEach(function(r) {
48
- Ze(t, r, a[r]);
49
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(a)) : xe(Object(a)).forEach(function(r) {
50
- Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(a, r));
51
- });
52
- }
53
- return t;
54
- }
55
- function Je(t, e) {
56
- if (!(t instanceof e))
57
- throw new TypeError("Cannot call a class as a function");
58
- }
59
- function Ce(t, e) {
60
- for (var a = 0; a < e.length; a++) {
61
- var r = e[a];
62
- r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(t, De(r.key), r);
63
- }
64
- }
65
- function Qe(t, e, a) {
66
- return e && Ce(t.prototype, e), a && Ce(t, a), Object.defineProperty(t, "prototype", {
67
- writable: !1
68
- }), t;
69
- }
70
- function Ze(t, e, a) {
71
- return e = De(e), e in t ? Object.defineProperty(t, e, {
72
- value: a,
73
- enumerable: !0,
74
- configurable: !0,
75
- writable: !0
76
- }) : t[e] = a, t;
77
- }
78
- function _() {
79
- return _ = Object.assign ? Object.assign.bind() : function(t) {
80
- for (var e = 1; e < arguments.length; e++) {
81
- var a = arguments[e];
82
- for (var r in a)
83
- Object.prototype.hasOwnProperty.call(a, r) && (t[r] = a[r]);
84
- }
85
- return t;
86
- }, _.apply(this, arguments);
87
- }
88
- function et(t, e) {
89
- if (typeof t != "object" || t === null) return t;
90
- var a = t[Symbol.toPrimitive];
91
- if (a !== void 0) {
92
- var r = a.call(t, e);
93
- if (typeof r != "object") return r;
94
- throw new TypeError("@@toPrimitive must return a primitive value.");
95
- }
96
- return String(t);
97
- }
98
- function De(t) {
99
- var e = et(t, "string");
100
- return typeof e == "symbol" ? e : String(e);
101
- }
102
- var Te = { exports: {} };
103
- (function(t) {
104
- typeof window > "u" || function(e) {
105
- var a = e.HTMLCanvasElement && e.HTMLCanvasElement.prototype, r = e.Blob && function() {
106
- try {
107
- return !!new Blob();
108
- } catch {
109
- return !1;
110
- }
111
- }(), i = r && e.Uint8Array && function() {
112
- try {
113
- return new Blob([new Uint8Array(100)]).size === 100;
114
- } catch {
115
- return !1;
116
- }
117
- }(), o = e.BlobBuilder || e.WebKitBlobBuilder || e.MozBlobBuilder || e.MSBlobBuilder, m = /^data:((.*?)(;charset=.*?)?)(;base64)?,/, n = (r || o) && e.atob && e.ArrayBuffer && e.Uint8Array && function(c) {
118
- var u, f, s, h, p, l, w, g, y;
119
- if (u = c.match(m), !u)
120
- throw new Error("invalid data URI");
121
- for (f = u[2] ? u[1] : "text/plain" + (u[3] || ";charset=US-ASCII"), s = !!u[4], h = c.slice(u[0].length), s ? p = atob(h) : p = decodeURIComponent(h), l = new ArrayBuffer(p.length), w = new Uint8Array(l), g = 0; g < p.length; g += 1)
122
- w[g] = p.charCodeAt(g);
123
- return r ? new Blob([i ? w : l], {
124
- type: f
125
- }) : (y = new o(), y.append(l), y.getBlob(f));
126
- };
127
- e.HTMLCanvasElement && !a.toBlob && (a.mozGetAsFile ? a.toBlob = function(c, u, f) {
128
- var s = this;
129
- setTimeout(function() {
130
- f && a.toDataURL && n ? c(n(s.toDataURL(u, f))) : c(s.mozGetAsFile("blob", u));
131
- });
132
- } : a.toDataURL && n && (a.msToBlob ? a.toBlob = function(c, u, f) {
133
- var s = this;
134
- setTimeout(function() {
135
- (u && u !== "image/png" || f) && a.toDataURL && n ? c(n(s.toDataURL(u, f))) : c(s.msToBlob(u));
136
- });
137
- } : a.toBlob = function(c, u, f) {
138
- var s = this;
139
- setTimeout(function() {
140
- c(n(s.toDataURL(u, f)));
141
- });
142
- })), t.exports ? t.exports = n : e.dataURLtoBlob = n;
143
- }(window);
144
- })(Te);
145
- var Be = Te.exports, tt = function(e) {
146
- return typeof Blob > "u" ? !1 : e instanceof Blob || Object.prototype.toString.call(e) === "[object Blob]";
147
- }, Ae = {
148
- /**
149
- * Indicates if output the original image instead of the compressed one
150
- * when the size of the compressed image is greater than the original one's
151
- * @type {boolean}
152
- */
153
- strict: !0,
154
- /**
155
- * Indicates if read the image's Exif Orientation information,
156
- * and then rotate or flip the image automatically.
157
- * @type {boolean}
158
- */
159
- checkOrientation: !0,
160
- /**
161
- * Indicates if retain the image's Exif information after compressed.
162
- * @type {boolean}
163
- */
164
- retainExif: !1,
165
- /**
166
- * The max width of the output image.
167
- * @type {number}
168
- */
169
- maxWidth: 1 / 0,
170
- /**
171
- * The max height of the output image.
172
- * @type {number}
173
- */
174
- maxHeight: 1 / 0,
175
- /**
176
- * The min width of the output image.
177
- * @type {number}
178
- */
179
- minWidth: 0,
180
- /**
181
- * The min height of the output image.
182
- * @type {number}
183
- */
184
- minHeight: 0,
185
- /**
186
- * The width of the output image.
187
- * If not specified, the natural width of the source image will be used.
188
- * @type {number}
189
- */
190
- width: void 0,
191
- /**
192
- * The height of the output image.
193
- * If not specified, the natural height of the source image will be used.
194
- * @type {number}
195
- */
196
- height: void 0,
197
- /**
198
- * Sets how the size of the image should be resized to the container
199
- * specified by the `width` and `height` options.
200
- * @type {string}
201
- */
202
- resize: "none",
203
- /**
204
- * The quality of the output image.
205
- * It must be a number between `0` and `1`,
206
- * and only available for `image/jpeg` and `image/webp` images.
207
- * Check out {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob canvas.toBlob}.
208
- * @type {number}
209
- */
210
- quality: 0.8,
211
- /**
212
- * The mime type of the output image.
213
- * By default, the original mime type of the source image file will be used.
214
- * @type {string}
215
- */
216
- mimeType: "auto",
217
- /**
218
- * Files whose file type is included in this list,
219
- * and whose file size exceeds the `convertSize` value will be converted to JPEGs.
220
- * @type {string|Array}
221
- */
222
- convertTypes: ["image/png"],
223
- /**
224
- * PNG files over this size (5 MB by default) will be converted to JPEGs.
225
- * To disable this, just set the value to `Infinity`.
226
- * @type {number}
227
- */
228
- convertSize: 5e6,
229
- /**
230
- * The hook function to execute before draw the image into the canvas for compression.
231
- * @type {Function}
232
- * @param {CanvasRenderingContext2D} context - The 2d rendering context of the canvas.
233
- * @param {HTMLCanvasElement} canvas - The canvas for compression.
234
- * @example
235
- * function (context, canvas) {
236
- * context.fillStyle = '#fff';
237
- * }
238
- */
239
- beforeDraw: null,
240
- /**
241
- * The hook function to execute after drew the image into the canvas for compression.
242
- * @type {Function}
243
- * @param {CanvasRenderingContext2D} context - The 2d rendering context of the canvas.
244
- * @param {HTMLCanvasElement} canvas - The canvas for compression.
245
- * @example
246
- * function (context, canvas) {
247
- * context.filter = 'grayscale(100%)';
248
- * }
249
- */
250
- drew: null,
251
- /**
252
- * The hook function to execute when success to compress the image.
253
- * @type {Function}
254
- * @param {File} file - The compressed image File object.
255
- * @example
256
- * function (file) {
257
- * console.log(file);
258
- * }
259
- */
260
- success: null,
261
- /**
262
- * The hook function to execute when fail to compress the image.
263
- * @type {Function}
264
- * @param {Error} err - An Error object.
265
- * @example
266
- * function (err) {
267
- * console.log(err.message);
268
- * }
269
- */
270
- error: null
271
- }, at = typeof window < "u" && typeof window.document < "u", U = at ? window : {}, N = function(e) {
272
- return e > 0 && e < 1 / 0;
273
- }, rt = Array.prototype.slice;
274
- function Z(t) {
275
- return Array.from ? Array.from(t) : rt.call(t);
276
- }
277
- var it = /^image\/.+$/;
278
- function Q(t) {
279
- return it.test(t);
280
- }
281
- function ot(t) {
282
- var e = Q(t) ? t.substr(6) : "";
283
- return e === "jpeg" && (e = "jpg"), ".".concat(e);
284
- }
285
- var Oe = String.fromCharCode;
286
- function nt(t, e, a) {
287
- var r = "", i;
288
- for (a += e, i = e; i < a; i += 1)
289
- r += Oe(t.getUint8(i));
290
- return r;
291
- }
292
- var st = U.btoa;
293
- function ke(t, e) {
294
- for (var a = [], r = 8192, i = new Uint8Array(t); i.length > 0; )
295
- a.push(Oe.apply(null, Z(i.subarray(0, r)))), i = i.subarray(r);
296
- return "data:".concat(e, ";base64,").concat(st(a.join("")));
297
- }
298
- function lt(t) {
299
- var e = new DataView(t), a;
300
- try {
301
- var r, i, o;
302
- if (e.getUint8(0) === 255 && e.getUint8(1) === 216)
303
- for (var m = e.byteLength, n = 2; n + 1 < m; ) {
304
- if (e.getUint8(n) === 255 && e.getUint8(n + 1) === 225) {
305
- i = n;
306
- break;
307
- }
308
- n += 1;
309
- }
310
- if (i) {
311
- var c = i + 4, u = i + 10;
312
- if (nt(e, c, 4) === "Exif") {
313
- var f = e.getUint16(u);
314
- if (r = f === 18761, (r || f === 19789) && e.getUint16(u + 2, r) === 42) {
315
- var s = e.getUint32(u + 4, r);
316
- s >= 8 && (o = u + s);
317
- }
318
- }
319
- }
320
- if (o) {
321
- var h = e.getUint16(o, r), p, l;
322
- for (l = 0; l < h; l += 1)
323
- if (p = o + l * 12 + 2, e.getUint16(p, r) === 274) {
324
- p += 8, a = e.getUint16(p, r), e.setUint16(p, 1, r);
325
- break;
326
- }
327
- }
328
- } catch {
329
- a = 1;
330
- }
331
- return a;
332
- }
333
- function ct(t) {
334
- var e = 0, a = 1, r = 1;
335
- switch (t) {
336
- case 2:
337
- a = -1;
338
- break;
339
- case 3:
340
- e = -180;
341
- break;
342
- case 4:
343
- r = -1;
344
- break;
345
- case 5:
346
- e = 90, r = -1;
347
- break;
348
- case 6:
349
- e = 90;
350
- break;
351
- case 7:
352
- e = 90, a = -1;
353
- break;
354
- case 8:
355
- e = -90;
356
- break;
357
- }
358
- return {
359
- rotate: e,
360
- scaleX: a,
361
- scaleY: r
362
- };
363
- }
364
- var ut = /\.\d*(?:0|9){12}\d*$/;
365
- function Ee(t) {
366
- var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1e11;
367
- return ut.test(t) ? Math.round(t * e) / e : t;
368
- }
369
- function I(t) {
370
- var e = t.aspectRatio, a = t.height, r = t.width, i = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "none", o = N(r), m = N(a);
371
- if (o && m) {
372
- var n = a * e;
373
- (i === "contain" || i === "none") && n > r || i === "cover" && n < r ? a = r / e : r = a * e;
374
- } else o ? a = r / e : m && (r = a * e);
375
- return {
376
- width: r,
377
- height: a
378
- };
379
- }
380
- function mt(t) {
381
- for (var e = Z(new Uint8Array(t)), a = e.length, r = [], i = 0; i + 3 < a; ) {
382
- var o = e[i], m = e[i + 1];
383
- if (o === 255 && m === 218)
384
- break;
385
- if (o === 255 && m === 216)
386
- i += 2;
387
- else {
388
- var n = e[i + 2] * 256 + e[i + 3], c = i + n + 2, u = e.slice(i, c);
389
- r.push(u), i = c;
390
- }
391
- }
392
- return r.reduce(function(f, s) {
393
- return s[0] === 255 && s[1] === 225 ? f.concat(s) : f;
394
- }, []);
395
- }
396
- function ft(t, e) {
397
- var a = Z(new Uint8Array(t));
398
- if (a[2] !== 255 || a[3] !== 224)
399
- return t;
400
- var r = a[4] * 256 + a[5], i = [255, 216].concat(e, a.slice(4 + r));
401
- return new Uint8Array(i);
402
- }
403
- var dt = U.ArrayBuffer, J = U.FileReader, D = U.URL || U.webkitURL, pt = /\.\w+$/, ht = U.Compressor, gt = /* @__PURE__ */ function() {
404
- function t(e, a) {
405
- Je(this, t), this.file = e, this.exif = [], this.image = new Image(), this.options = j(j({}, Ae), a), this.aborted = !1, this.result = null, this.init();
406
- }
407
- return Qe(t, [{
408
- key: "init",
409
- value: function() {
410
- var a = this, r = this.file, i = this.options;
411
- if (!tt(r)) {
412
- this.fail(new Error("The first argument must be a File or Blob object."));
413
- return;
414
- }
415
- var o = r.type;
416
- if (!Q(o)) {
417
- this.fail(new Error("The first argument must be an image File or Blob object."));
418
- return;
419
- }
420
- if (!D || !J) {
421
- this.fail(new Error("The current browser does not support image compression."));
422
- return;
423
- }
424
- dt || (i.checkOrientation = !1, i.retainExif = !1);
425
- var m = o === "image/jpeg", n = m && i.checkOrientation, c = m && i.retainExif;
426
- if (D && !n && !c)
427
- this.load({
428
- url: D.createObjectURL(r)
429
- });
430
- else {
431
- var u = new J();
432
- this.reader = u, u.onload = function(f) {
433
- var s = f.target, h = s.result, p = {}, l = 1;
434
- n && (l = lt(h), l > 1 && _(p, ct(l))), c && (a.exif = mt(h)), n || c ? !D || l > 1 ? p.url = ke(h, o) : p.url = D.createObjectURL(r) : p.url = h, a.load(p);
435
- }, u.onabort = function() {
436
- a.fail(new Error("Aborted to read the image with FileReader."));
437
- }, u.onerror = function() {
438
- a.fail(new Error("Failed to read the image with FileReader."));
439
- }, u.onloadend = function() {
440
- a.reader = null;
441
- }, n || c ? u.readAsArrayBuffer(r) : u.readAsDataURL(r);
23
+ return { finalSize: i * C[n], sizeText: t };
24
+ } }), te = (a, t) => {
25
+ const i = ae(a, "status"), { size2B: n } = oe(), l = [".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".mpeg", ".webm"], C = [".mp3", ".wav", ".aac", ".flac", ".ogg", ".alff", ".wma", ".m4a"], s = z(() => {
26
+ var c;
27
+ let e = a.accept ? (c = a.accept) == null ? void 0 : c.split(",") : [];
28
+ return e.includes("image/jpg") && !e.includes("image/jpeg") && e.push("image/jpeg"), e.includes(".jpg") && !e.includes(".jpeg") && e.push(".jpeg"), a.acceptVideo && (e = [...e, ...l]), a.acceptAudio && (e = [...e, ...C]), e.join(",");
29
+ }), y = z(() => i.value === "uploading"), k = z(() => i.value === "error");
30
+ return { isAccept: s, uploadStatus: i, loading: y, errored: k, beforeupload: (e) => {
31
+ var _, F, I;
32
+ if (a.maxSize) {
33
+ const { finalSize: d, sizeText: u } = n(a.maxSize);
34
+ if (e.size > d) {
35
+ const h = a.acceptAudio || a.acceptVideo ? "das-ui-import-upload-key4" : "das-ui-import-upload-key3", p = T.value === "zh-CN" ? "、" : ", ", b = V(
36
+ h,
37
+ u,
38
+ ((I = (F = (_ = s.value) == null ? void 0 : _.toUpperCase()) == null ? void 0 : F.replaceAll(".", "")) == null ? void 0 : I.replaceAll(",", p)) ?? ""
39
+ ).value, A = a.errorMessage || b;
40
+ return U.warning(A), t("update:status", "normal"), i.value = "normal", !1;
442
41
  }
443
42
  }
444
- }, {
445
- key: "load",
446
- value: function(a) {
447
- var r = this, i = this.file, o = this.image;
448
- o.onload = function() {
449
- r.draw(j(j({}, a), {}, {
450
- naturalWidth: o.naturalWidth,
451
- naturalHeight: o.naturalHeight
452
- }));
453
- }, o.onabort = function() {
454
- r.fail(new Error("Aborted to load the image."));
455
- }, o.onerror = function() {
456
- r.fail(new Error("Failed to load the image."));
457
- }, U.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(U.navigator.userAgent) && (o.crossOrigin = "anonymous"), o.alt = i.name, o.src = a.url;
458
- }
459
- }, {
460
- key: "draw",
461
- value: function(a) {
462
- var r = this, i = a.naturalWidth, o = a.naturalHeight, m = a.rotate, n = m === void 0 ? 0 : m, c = a.scaleX, u = c === void 0 ? 1 : c, f = a.scaleY, s = f === void 0 ? 1 : f, h = this.file, p = this.image, l = this.options, w = document.createElement("canvas"), g = w.getContext("2d"), y = Math.abs(n) % 180 === 90, C = (l.resize === "contain" || l.resize === "cover") && N(l.width) && N(l.height), x = Math.max(l.maxWidth, 0) || 1 / 0, B = Math.max(l.maxHeight, 0) || 1 / 0, A = Math.max(l.minWidth, 0) || 0, k = Math.max(l.minHeight, 0) || 0, E = i / o, b = l.width, d = l.height;
463
- if (y) {
464
- var P = [B, x];
465
- x = P[0], B = P[1];
466
- var S = [k, A];
467
- A = S[0], k = S[1];
468
- var ee = [d, b];
469
- b = ee[0], d = ee[1];
470
- }
471
- C && (E = b / d);
472
- var te = I({
473
- aspectRatio: E,
474
- width: x,
475
- height: B
476
- }, "contain");
477
- x = te.width, B = te.height;
478
- var ae = I({
479
- aspectRatio: E,
480
- width: A,
481
- height: k
482
- }, "cover");
483
- if (A = ae.width, k = ae.height, C) {
484
- var re = I({
485
- aspectRatio: E,
486
- width: b,
487
- height: d
488
- }, l.resize);
489
- b = re.width, d = re.height;
490
- } else {
491
- var ie = I({
492
- aspectRatio: E,
493
- width: b,
494
- height: d
495
- }), oe = ie.width;
496
- b = oe === void 0 ? i : oe;
497
- var ne = ie.height;
498
- d = ne === void 0 ? o : ne;
499
- }
500
- b = Math.floor(Ee(Math.min(Math.max(b, A), x))), d = Math.floor(Ee(Math.min(Math.max(d, k), B)));
501
- var Re = -b / 2, Me = -d / 2, Fe = b, ze = d, W = [];
502
- if (C) {
503
- var se = 0, le = 0, H = i, V = o, ce = I({
504
- aspectRatio: E,
505
- width: i,
506
- height: o
507
- }, {
508
- contain: "cover",
509
- cover: "contain"
510
- }[l.resize]);
511
- H = ce.width, V = ce.height, se = (i - H) / 2, le = (o - V) / 2, W.push(se, le, H, V);
512
- }
513
- if (W.push(Re, Me, Fe, ze), y) {
514
- var ue = [d, b];
515
- b = ue[0], d = ue[1];
516
- }
517
- w.width = b, w.height = d, Q(l.mimeType) || (l.mimeType = h.type);
518
- var me = "transparent";
519
- h.size > l.convertSize && l.convertTypes.indexOf(l.mimeType) >= 0 && (l.mimeType = "image/jpeg");
520
- var fe = l.mimeType === "image/jpeg";
521
- if (fe && (me = "#fff"), g.fillStyle = me, g.fillRect(0, 0, b, d), l.beforeDraw && l.beforeDraw.call(this, g, w), !this.aborted && (g.save(), g.translate(b / 2, d / 2), g.rotate(n * Math.PI / 180), g.scale(u, s), g.drawImage.apply(g, [p].concat(W)), g.restore(), l.drew && l.drew.call(this, g, w), !this.aborted)) {
522
- var de = function(M) {
523
- if (!r.aborted) {
524
- var pe = function(F) {
525
- return r.done({
526
- naturalWidth: i,
527
- naturalHeight: o,
528
- result: F
529
- });
530
- };
531
- if (M && fe && l.retainExif && r.exif && r.exif.length > 0) {
532
- var he = function(F) {
533
- return pe(Be(ke(ft(F, r.exif), l.mimeType)));
534
- };
535
- if (M.arrayBuffer)
536
- M.arrayBuffer().then(he).catch(function() {
537
- r.fail(new Error("Failed to read the compressed image with Blob.arrayBuffer()."));
538
- });
539
- else {
540
- var T = new J();
541
- r.reader = T, T.onload = function($) {
542
- var F = $.target;
543
- he(F.result);
544
- }, T.onabort = function() {
545
- r.fail(new Error("Aborted to read the compressed image with FileReader."));
546
- }, T.onerror = function() {
547
- r.fail(new Error("Failed to read the compressed image with FileReader."));
548
- }, T.onloadend = function() {
549
- r.reader = null;
550
- }, T.readAsArrayBuffer(M);
551
- }
552
- } else
553
- pe(M);
554
- }
555
- };
556
- w.toBlob ? w.toBlob(de, l.mimeType, l.quality) : de(Be(w.toDataURL(l.mimeType, l.quality)));
557
- }
558
- }
559
- }, {
560
- key: "done",
561
- value: function(a) {
562
- var r = a.naturalWidth, i = a.naturalHeight, o = a.result, m = this.file, n = this.image, c = this.options;
563
- if (D && n.src.indexOf("blob:") === 0 && D.revokeObjectURL(n.src), o)
564
- if (c.strict && !c.retainExif && o.size > m.size && c.mimeType === m.type && !(c.width > r || c.height > i || c.minWidth > r || c.minHeight > i || c.maxWidth < r || c.maxHeight < i))
565
- o = m;
566
- else {
567
- var u = /* @__PURE__ */ new Date();
568
- o.lastModified = u.getTime(), o.lastModifiedDate = u, o.name = m.name, o.name && o.type !== m.type && (o.name = o.name.replace(pt, ot(o.type)));
569
- }
570
- else
571
- o = m;
572
- this.result = o, c.success && c.success.call(this, o);
573
- }
574
- }, {
575
- key: "fail",
576
- value: function(a) {
577
- var r = this.options;
578
- if (r.error)
579
- r.error.call(this, a);
580
- else
581
- throw a;
582
- }
583
- }, {
584
- key: "abort",
585
- value: function() {
586
- this.aborted || (this.aborted = !0, this.reader ? this.reader.abort() : this.image.complete ? this.fail(new Error("The compression process has been aborted.")) : (this.image.onload = null, this.image.onabort()));
587
- }
588
- /**
589
- * Get the no conflict compressor class.
590
- * @returns {Compressor} The compressor class.
591
- */
592
- }], [{
593
- key: "noConflict",
594
- value: function() {
595
- return window.Compressor = ht, t;
596
- }
597
- /**
598
- * Change the default options.
599
- * @param {Object} options - The new default options.
600
- */
601
- }, {
602
- key: "setDefaults",
603
- value: function(a) {
604
- _(Ae, a);
605
- }
606
- }]), t;
607
- }();
608
- const vt = (t, e) => new Promise((a, r) => {
609
- if (t.size <= e)
610
- return t;
611
- const i = e / t.size, o = Math.max(0.5, Math.min(0.9, 0.8 * i)), m = Math.max(800, Math.min(1920, 1920 * Math.sqrt(i)));
612
- Ue(t, o, m, m, (n) => {
613
- n.size <= e ? a(n) : Ue(
614
- n,
615
- Math.max(0.4, o - 0.2),
616
- // 降低质量
617
- Math.max(640, m * 0.8),
618
- // 缩小尺寸
619
- Math.max(640, m * 0.8),
620
- a,
621
- r,
622
- t
623
- // 传递原始文件用于错误处理
624
- );
625
- }, r, t);
626
- }), Ue = (t, e, a, r, i, o, m) => {
627
- new gt(t, {
628
- quality: e,
629
- maxWidth: a,
630
- maxHeight: r,
631
- convertSize: 1 / 0,
632
- success(n) {
633
- try {
634
- const c = new File([n], t.name, {
635
- type: n.type || t.type,
636
- lastModified: Date.now()
637
- });
638
- i(c);
639
- } catch (c) {
640
- o({
641
- message: "文件转换失败",
642
- error: c,
643
- original: m || t
644
- });
645
- }
646
- },
647
- error(n) {
648
- o({
649
- message: "图片压缩失败",
650
- error: n,
651
- original: m || t
652
- });
653
- }
654
- });
655
- }, yt = (t, e) => {
656
- const a = we(t, "status"), { size2B: r } = qe(), i = we(t, "isOverMaxLimitCompressImg"), o = [".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".mpeg", ".webm"], m = [".mp3", ".wav", ".aac", ".flac", ".ogg", ".alff", ".wma", ".m4a"], n = X(() => {
657
- var h;
658
- let s = t.accept ? (h = t.accept) == null ? void 0 : h.split(",") : [];
659
- return s.includes("image/jpg") && !s.includes("image/jpeg") && s.push("image/jpeg"), s.includes(".jpg") && !s.includes(".jpeg") && s.push(".jpeg"), t.acceptVideo && (s = [...s, ...o]), t.acceptAudio && (s = [...s, ...m]), s.join(",");
660
- }), c = X(() => a.value === "uploading"), u = X(() => a.value === "error");
661
- return { isAccept: n, uploadStatus: a, loading: c, errored: u, beforeupload: (s) => {
662
- var l, w, g;
663
- if (t.maxSize) {
664
- const { finalSize: y, sizeText: C } = r(t.maxSize);
665
- if (s.size > y && !i.value) {
666
- const x = t.acceptAudio || t.acceptVideo ? "das-ui-import-upload-key4" : "das-ui-import-upload-key3", B = ge.value === "zh-CN" ? "、" : ", ", A = ve(
667
- x,
668
- C,
669
- ((g = (w = (l = n.value) == null ? void 0 : l.toUpperCase()) == null ? void 0 : w.replaceAll(".", "")) == null ? void 0 : g.replaceAll(",", B)) ?? ""
670
- ).value, k = t.errorMessage || A;
671
- return be.warning(k), e("update:status", "normal"), a.value = "normal", !1;
672
- }
673
- }
674
- const h = [
675
- "image/jpeg",
676
- "image/png",
677
- "image/webp",
678
- "image/gif",
679
- "image/bmp",
680
- "image/tiff",
681
- "image/svg+xml"
682
- ], p = async () => {
683
- a.value = "uploading";
684
- let y = s;
685
- if (t.maxSize) {
686
- const { finalSize: C } = r(t.maxSize);
687
- if (s.size > C && i.value && h.includes(s.type))
688
- try {
689
- y = await vt(s, C);
690
- } catch (x) {
691
- y = (x == null ? void 0 : x.original) || s;
692
- }
693
- }
694
- return e("update:status", "uploading"), e("image-upload", y), !1;
695
- };
696
- if (t.customCheck) {
697
- const y = t.customCheck(s);
698
- if (y instanceof Promise)
699
- return new Promise(async (C, x) => {
700
- let B;
43
+ const c = () => (i.value = "uploading", t("update:status", "uploading"), t("image-upload", e), !1);
44
+ if (a.customCheck) {
45
+ const d = a.customCheck(e);
46
+ if (d instanceof Promise)
47
+ return new Promise(async (u, h) => {
48
+ let p;
701
49
  try {
702
- B = await y.then();
50
+ p = await d.then();
703
51
  } catch {
704
- B = !1;
52
+ p = !1;
705
53
  }
706
- B ? p() : x(!1);
54
+ p ? c() : h(!1);
707
55
  });
708
- if (!y)
709
- return e("update:status", "normal"), a.value = "normal", !1;
710
- } else if (n.value) {
711
- const y = n.value.split(",").filter((d) => d.trim().startsWith(".")).map((d) => d.trim()), C = n.value.split(",").filter((d) => !d.trim().startsWith(".")).map((d) => d.trim()), x = Ye(s.name), B = y.includes(x);
712
- let A = C.includes("image/*") && s.type.split("/")[0].trim() === "image", k = C.includes("video/*") && s.type.split("/")[0].trim() === "video", E = C.includes("audio/*") && s.type.split("/")[0].trim() === "audio", b = C.includes(s.type) || A || k || E;
713
- if (!B && !b) {
714
- const d = t.acceptAudio || t.acceptVideo ? "das-ui-import-upload-key2" : "das-ui-import-upload-key1", P = ge.value === "zh-CN" ? "、" : ", ", S = t.errorMessage || ve(d, n.value.toUpperCase().replaceAll(".", "").replaceAll(",", P)).value;
715
- return be.warning(S), !1;
56
+ if (!d)
57
+ return t("update:status", "normal"), i.value = "normal", !1;
58
+ } else if (s.value) {
59
+ const d = s.value.split(",").filter((r) => r.trim().startsWith(".")).map((r) => r.trim()), u = s.value.split(",").filter((r) => !r.trim().startsWith(".")).map((r) => r.trim()), h = ee(e.name), p = d.includes(h);
60
+ let b = u.includes("image/*") && e.type.split("/")[0].trim() === "image", A = u.includes("video/*") && e.type.split("/")[0].trim() === "video", $ = u.includes("audio/*") && e.type.split("/")[0].trim() === "audio", M = u.includes(e.type) || b || A || $;
61
+ if (!p && !M) {
62
+ const r = a.acceptAudio || a.acceptVideo ? "das-ui-import-upload-key2" : "das-ui-import-upload-key1", j = T.value === "zh-CN" ? "、" : ", ", E = a.errorMessage || V(r, s.value.toUpperCase().replaceAll(".", "").replaceAll(",", j)).value;
63
+ return U.warning(E), !1;
716
64
  }
717
65
  }
718
- return p();
66
+ return c();
719
67
  } };
720
- }, bt = { class: "das-ui-image-upload" }, wt = { class: "das-ui-image-upload-dragger-context" }, xt = { class: "text" }, Ct = { class: "das-ui-image-upload-error-container" }, Bt = { class: "tips-container" }, At = { class: "text" }, kt = /* @__PURE__ */ je({
68
+ }, ie = { class: "das-ui-image-upload" }, le = { class: "das-ui-image-upload-dragger-context" }, se = { class: "text" }, re = { class: "das-ui-image-upload-error-container" }, ne = { class: "tips-container" }, ce = { class: "text" }, de = /* @__PURE__ */ W({
721
69
  __name: "Index",
722
70
  props: {
723
71
  maxCount: { default: 1 },
@@ -730,40 +78,39 @@ const vt = (t, e) => new Promise((a, r) => {
730
78
  maxSize: {},
731
79
  customCheck: {},
732
80
  autoContentType: { type: Boolean },
733
- openFileDialogOnClick: { type: Boolean, default: !0 },
734
- isOverMaxLimitCompressImg: { type: Boolean, default: !1 }
81
+ openFileDialogOnClick: { type: Boolean, default: !0 }
735
82
  },
736
83
  emits: ["update:status", "image-upload"],
737
- setup(t, { emit: e }) {
738
- const a = t, r = e, { isAccept: i, uploadStatus: o, loading: m, errored: n, beforeupload: c } = yt(a, r);
739
- return (u, f) => (_e(), Le("div", bt, [
740
- ye(" 图片上传组件 "),
741
- K(O(v($e), {
742
- class: Ne([{ "loading-border": v(m) }]),
84
+ setup(a, { emit: t }) {
85
+ const i = a, n = t, { isAccept: l, uploadStatus: C, loading: s, errored: y, beforeupload: k } = te(i, n);
86
+ return (m, e) => (H(), P("div", ie, [
87
+ B(" 图片上传组件 "),
88
+ N(g(o(Q), {
89
+ class: L([{ "loading-border": o(s) }]),
743
90
  type: "component",
744
- spinning: v(m)
91
+ spinning: o(s)
745
92
  }, {
746
- default: R(() => [
747
- O(v(He), {
93
+ default: f(() => [
94
+ g(o(G), {
748
95
  class: "das-ui-image-upload-dragger",
749
- accept: v(i),
750
- "max-count": u.maxCount,
751
- "before-upload": v(c),
752
- openFileDialogOnClick: u.openFileDialogOnClick
96
+ accept: o(l),
97
+ "max-count": m.maxCount,
98
+ "before-upload": o(k),
99
+ openFileDialogOnClick: m.openFileDialogOnClick
753
100
  }, {
754
- itemRender: R(({ file: s, actions: h }) => f[0] || (f[0] = [])),
755
- default: R(() => [
756
- K(z(
101
+ itemRender: f(({ file: c, actions: _ }) => e[0] || (e[0] = [])),
102
+ default: f(() => [
103
+ N(v(
757
104
  "div",
758
- wt,
105
+ le,
759
106
  [
760
- O(v(Xe), {
761
- iconColor: v(L)("--das-ui-color-secondary")
107
+ g(o(Y), {
108
+ iconColor: o(x)("--das-ui-color-secondary")
762
109
  }, null, 8, ["iconColor"]),
763
- z(
110
+ v(
764
111
  "div",
765
- xt,
766
- Y(u.message || v(G)("das-image-upload-text")),
112
+ se,
113
+ D(m.message || o(w)("das-image-upload-text")),
767
114
  1
768
115
  /* TEXT */
769
116
  )
@@ -771,7 +118,7 @@ const vt = (t, e) => new Promise((a, r) => {
771
118
  512
772
119
  /* NEED_PATCH */
773
120
  ), [
774
- [q, v(o) === "normal"]
121
+ [S, o(C) === "normal"]
775
122
  ])
776
123
  ]),
777
124
  _: 1
@@ -781,41 +128,41 @@ const vt = (t, e) => new Promise((a, r) => {
781
128
  _: 1
782
129
  /* STABLE */
783
130
  }, 8, ["class", "spinning"]), [
784
- [q, !v(n)]
131
+ [S, !o(y)]
785
132
  ]),
786
- ye(" 错误状态 "),
787
- K(z(
133
+ B(" 错误状态 "),
134
+ N(v(
788
135
  "div",
789
- Ct,
136
+ re,
790
137
  [
791
- z("div", Bt, [
792
- O(v(Ke), {
793
- iconColor: v(L)("--das-ui-color-danger"),
138
+ v("div", ne, [
139
+ g(o(Z), {
140
+ iconColor: o(x)("--das-ui-color-danger"),
794
141
  size: "small"
795
142
  }, null, 8, ["iconColor"]),
796
- z(
143
+ v(
797
144
  "div",
798
- At,
799
- Y(v(G)("das-image-upload-fail")),
145
+ ce,
146
+ D(o(w)("das-image-upload-fail")),
800
147
  1
801
148
  /* TEXT */
802
149
  )
803
150
  ]),
804
- O(v(Ve), {
805
- accept: v(i),
806
- "before-upload": v(c),
807
- "max-count": u.maxCount,
808
- openFileDialogOnClick: u.openFileDialogOnClick
151
+ g(o(J), {
152
+ accept: o(l),
153
+ "before-upload": o(k),
154
+ "max-count": m.maxCount,
155
+ openFileDialogOnClick: m.openFileDialogOnClick
809
156
  }, {
810
- itemRender: R(({ file: s, actions: h }) => f[1] || (f[1] = [])),
811
- default: R(() => [
812
- O(v(Ge), {
157
+ itemRender: f(({ file: c, actions: _ }) => e[1] || (e[1] = [])),
158
+ default: f(() => [
159
+ g(o(X), {
813
160
  "btn-type": "primary-text",
814
161
  block: ""
815
162
  }, {
816
- default: R(() => [
817
- We(
818
- Y(v(G)("das-image-upload-reupload")),
163
+ default: f(() => [
164
+ q(
165
+ D(o(w)("das-image-upload-reupload")),
819
166
  1
820
167
  /* TEXT */
821
168
  )
@@ -831,16 +178,16 @@ const vt = (t, e) => new Promise((a, r) => {
831
178
  512
832
179
  /* NEED_PATCH */
833
180
  ), [
834
- [q, v(n)]
181
+ [S, o(y)]
835
182
  ])
836
183
  ]));
837
184
  }
838
- }), Et = (t, e) => {
839
- const a = t.__vccOpts || t;
840
- for (const [r, i] of e)
841
- a[r] = i;
842
- return a;
843
- }, Ut = /* @__PURE__ */ Et(kt, [["__scopeId", "data-v-29473013"]]), Dt = {
185
+ }), ue = (a, t) => {
186
+ const i = a.__vccOpts || a;
187
+ for (const [n, l] of t)
188
+ i[n] = l;
189
+ return i;
190
+ }, pe = /* @__PURE__ */ ue(de, [["__scopeId", "data-v-1159eda2"]]), me = {
844
191
  "das-ui-import-upload-key1": {
845
192
  "zh-CN": "上传的图片格式只能是$0",
846
193
  en: "The uploaded picture format can only be $0",
@@ -864,16 +211,16 @@ const vt = (t, e) => new Promise((a, r) => {
864
211
  "das-image-upload-text": { "zh-CN": "上传图片", en: "Upload Image", _appCode: "framework" },
865
212
  "das-image-upload-reupload": { "zh-CN": "重新上传", en: "Re-upload", _appCode: "framework" },
866
213
  "das-image-upload-fail": { "zh-CN": "上传失败", en: "Uploaded Failed", _appCode: "framework" }
867
- }, Tt = {
214
+ }, ge = {
868
215
  "--das-ui-image-upload-bgcolor": { light: "#FAFAFA" },
869
216
  "--das-ui-image-upload-border-color": { light: "#E5E5E5" },
870
- "--das-ui-image-upload-bgcolor-hover": { light: L("--das-ui-color-primary-level1") },
217
+ "--das-ui-image-upload-bgcolor-hover": { light: x("--das-ui-color-primary-level1") },
871
218
  "--das-ui-image-upload-border-color-hover": { light: "#5582F3" },
872
- "--das-ui-image-upload-border-color-error": { light: L("--das-ui-color-danger-level2") }
873
- }, $t = Ie(Ut);
874
- Pe(Dt);
875
- Se(Tt);
219
+ "--das-ui-image-upload-border-color-error": { light: x("--das-ui-color-danger-level2") }
220
+ }, Se = O(pe);
221
+ R(me);
222
+ K(ge);
876
223
  export {
877
- $t as DasImageUpload,
878
- $t as default
224
+ Se as DasImageUpload,
225
+ Se as default
879
226
  };