@gx-design-vue/pro-utils 0.1.1 → 0.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.
@@ -0,0 +1,1044 @@
1
+ import { defineComponent, ref, computed, createVNode, isVNode, Fragment } from "vue";
2
+ import { createTypes } from "vue-types";
3
+ import { CloseOutlined, DownOutlined, InfoCircleOutlined } from "@ant-design/icons-vue";
4
+ import { cloneDeep } from "lodash-es";
5
+ import { Tooltip } from "ant-design-vue";
6
+ var config = "";
7
+ var antDesignTheme = "";
8
+ var antDesignVue = "";
9
+ var index$2 = "";
10
+ var proUtils = "";
11
+ var style = "";
12
+ var isServer = typeof window === "undefined";
13
+ const cacheStringFunction = (fn) => {
14
+ const cache = /* @__PURE__ */ Object.create(null);
15
+ return (str) => {
16
+ const hit = cache[str];
17
+ return hit || (cache[str] = fn(str));
18
+ };
19
+ };
20
+ const camelizeRE = /-(\w)/g;
21
+ const camelize = cacheStringFunction((str) => {
22
+ return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
23
+ });
24
+ const getStyle = function(element, styleName) {
25
+ var _a;
26
+ if (isServer)
27
+ return "";
28
+ if (!element || !styleName)
29
+ return "";
30
+ styleName = camelize(styleName);
31
+ if (styleName === "float") {
32
+ styleName = "cssFloat";
33
+ }
34
+ try {
35
+ const style2 = element.style[styleName];
36
+ if (style2)
37
+ return style2;
38
+ const computed2 = (_a = document == null ? void 0 : document.defaultView) == null ? void 0 : _a.getComputedStyle(element, "");
39
+ return computed2 ? computed2[styleName] : "";
40
+ } catch (e) {
41
+ return element.style[styleName];
42
+ }
43
+ };
44
+ const isScroll = (el, isVertical) => {
45
+ if (isServer)
46
+ return;
47
+ const determinedDirection = isVertical === null || isVertical === void 0;
48
+ const overflow = determinedDirection ? getStyle(el, "overflow") : isVertical ? getStyle(el, "overflow-y") : getStyle(el, "overflow-x");
49
+ return overflow.match(/(scroll|auto|overlay)/);
50
+ };
51
+ const getScrollContainer = (el, isVertical) => {
52
+ if (isServer)
53
+ return;
54
+ let parent = el;
55
+ while (parent) {
56
+ if ([window, document, document.documentElement].includes(parent)) {
57
+ return window;
58
+ }
59
+ if (isScroll(parent, isVertical)) {
60
+ return parent;
61
+ }
62
+ parent = parent.parentNode;
63
+ }
64
+ return parent;
65
+ };
66
+ const isInContainer = (el, container) => {
67
+ if (isServer || !el || !container)
68
+ return false;
69
+ const elRect = el.getBoundingClientRect();
70
+ let containerRect;
71
+ if ([window, document, document.documentElement, null, void 0].includes(container)) {
72
+ containerRect = {
73
+ top: 0,
74
+ right: window.innerWidth,
75
+ bottom: window.innerHeight,
76
+ left: 0
77
+ };
78
+ } else {
79
+ containerRect = container.getBoundingClientRect();
80
+ }
81
+ return elRect.top < containerRect.bottom && elRect.bottom > containerRect.top && elRect.right > containerRect.left && elRect.left < containerRect.right;
82
+ };
83
+ const toString = Object.prototype.toString;
84
+ function is(val, type) {
85
+ return toString.call(val) === `[object ${type}]`;
86
+ }
87
+ function isBoolean(val) {
88
+ return is(val, "Boolean");
89
+ }
90
+ function isNumber(val) {
91
+ return typeof val === "number";
92
+ }
93
+ function isArray(arg) {
94
+ if (typeof Array.isArray === "undefined") {
95
+ return Object.prototype.toString.call(arg) === "[object Array]";
96
+ }
97
+ return Array.isArray(arg);
98
+ }
99
+ function isObject(val) {
100
+ return val !== null && is(val, "Object");
101
+ }
102
+ function isString(value) {
103
+ return typeof value === "string" || value instanceof String;
104
+ }
105
+ function isFunction(func) {
106
+ return typeof func === "function" || Object.prototype.toString.call(func) === "[object Function]";
107
+ }
108
+ function classNames(...args) {
109
+ const classes = [];
110
+ for (let i = 0; i < args.length; i++) {
111
+ const value = args[i];
112
+ if (!value)
113
+ continue;
114
+ if (isString(value)) {
115
+ classes.push(value);
116
+ } else if (isArray(value)) {
117
+ for (let i2 = 0; i2 < value.length; i2++) {
118
+ const inner = classNames(value[i2]);
119
+ if (inner) {
120
+ classes.push(inner);
121
+ }
122
+ }
123
+ } else if (isObject(value)) {
124
+ for (const name in value) {
125
+ if (value[name]) {
126
+ classes.push(name);
127
+ }
128
+ }
129
+ }
130
+ }
131
+ return classes.filter((el) => el).join(" ");
132
+ }
133
+ let id = 0;
134
+ const ids = {};
135
+ function wrapperRaf(callback, delayFrames = 1) {
136
+ const myId = id++;
137
+ let restFrames = delayFrames;
138
+ function internalCallback() {
139
+ restFrames -= 1;
140
+ if (restFrames <= 0) {
141
+ callback();
142
+ delete ids[myId];
143
+ } else {
144
+ ids[myId] = requestAnimationFrame(internalCallback);
145
+ }
146
+ }
147
+ ids[myId] = requestAnimationFrame(internalCallback);
148
+ return myId;
149
+ }
150
+ wrapperRaf.cancel = function cancel(pid) {
151
+ if (pid === void 0)
152
+ return;
153
+ cancelAnimationFrame(ids[pid]);
154
+ delete ids[pid];
155
+ };
156
+ wrapperRaf.ids = ids;
157
+ function isWindow(obj) {
158
+ return obj !== null && obj !== void 0 && obj === obj.window;
159
+ }
160
+ function getScroll(target, top) {
161
+ var _a;
162
+ if (typeof window === "undefined") {
163
+ return 0;
164
+ }
165
+ const method = top ? "scrollTop" : "scrollLeft";
166
+ let result = 0;
167
+ if (isWindow(target)) {
168
+ result = target[top ? "pageYOffset" : "pageXOffset"];
169
+ } else if (target instanceof Document) {
170
+ result = target.documentElement[method];
171
+ } else if (target) {
172
+ result = target[method];
173
+ }
174
+ if (target && !isWindow(target) && typeof result !== "number") {
175
+ result = (_a = (target.ownerDocument || target).documentElement) == null ? void 0 : _a[method];
176
+ }
177
+ return result;
178
+ }
179
+ function easeInOutCubic(t, b, c, d) {
180
+ const cc = c - b;
181
+ t /= d / 2;
182
+ if (t < 1) {
183
+ return cc / 2 * t * t * t + b;
184
+ }
185
+ return cc / 2 * ((t -= 2) * t * t + 2) + b;
186
+ }
187
+ function scrollTo(y, options = {}) {
188
+ const { getContainer = () => window, callback, duration = 450 } = options;
189
+ const container = getContainer();
190
+ const scrollTop = getScroll(container, true);
191
+ const startTime = Date.now();
192
+ const frameFunc = () => {
193
+ const timestamp = Date.now();
194
+ const time = timestamp - startTime;
195
+ const nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration);
196
+ if (isWindow(container)) {
197
+ container.scrollTo(window.pageXOffset, nextScrollTop);
198
+ } else if (container instanceof HTMLDocument || container.constructor.name === "HTMLDocument") {
199
+ container.documentElement.scrollTop = nextScrollTop;
200
+ } else {
201
+ container.scrollTop = nextScrollTop;
202
+ }
203
+ if (time < duration) {
204
+ wrapperRaf(frameFunc);
205
+ } else if (typeof callback === "function") {
206
+ callback();
207
+ }
208
+ };
209
+ wrapperRaf(frameFunc);
210
+ }
211
+ function throttleByAnimationFrame(fn) {
212
+ let requestId;
213
+ const later = (args) => () => {
214
+ requestId = null;
215
+ fn(...args);
216
+ };
217
+ const throttled = (...args) => {
218
+ if (requestId == null) {
219
+ requestId = requestAnimationFrame(later(args));
220
+ }
221
+ };
222
+ throttled.cancel = () => cancelAnimationFrame(requestId);
223
+ return throttled;
224
+ }
225
+ var PropTypes = createTypes({
226
+ func: void 0,
227
+ bool: void 0,
228
+ string: void 0,
229
+ number: void 0,
230
+ array: void 0,
231
+ object: void 0,
232
+ integer: void 0
233
+ });
234
+ PropTypes.extend([{
235
+ name: "looseBool",
236
+ getter: true,
237
+ type: Boolean,
238
+ default: void 0
239
+ }, {
240
+ name: "style",
241
+ getter: true,
242
+ type: [String, Object],
243
+ default: void 0
244
+ }, {
245
+ name: "VueNode",
246
+ getter: true,
247
+ type: null
248
+ }]);
249
+ var PropTypes$1 = PropTypes;
250
+ var global = {
251
+ videoAllowType: [
252
+ "mp4",
253
+ "webm",
254
+ "ogg"
255
+ ],
256
+ audioAllowType: ["mp3"],
257
+ imageType: ["bmp", "png", "gif", "jpg", "jpeg", "psd", "tif"],
258
+ videoType: [
259
+ "mp4",
260
+ "swf",
261
+ "rmvb",
262
+ "avi",
263
+ "flv",
264
+ "mpg",
265
+ "rm",
266
+ "mov",
267
+ "asf",
268
+ "3gp",
269
+ "mkv",
270
+ "ts",
271
+ "f4v",
272
+ "webm",
273
+ "m4v",
274
+ "3g2",
275
+ "m3u8"
276
+ ],
277
+ audioType: ["mp3", "mpeg", "aac", "wav", "wma", "mp2", "flac", "midi", "ra", "ape", "aac", "cda"]
278
+ };
279
+ const getPrefixCls = ({ suffixCls, customizePrefixCls, isPor, className }) => {
280
+ const prefixCls = className || (isPor ? "gx-pro" : "gx");
281
+ if (customizePrefixCls)
282
+ return customizePrefixCls;
283
+ return suffixCls ? `${prefixCls}-${suffixCls}` : prefixCls;
284
+ };
285
+ const genColumnKey = (key, index2) => {
286
+ if (key)
287
+ return Array.isArray(key) ? key.join("-") : key.toString();
288
+ return `${index2}`;
289
+ };
290
+ function handleShowIndex(columns, { align, showIndex }) {
291
+ const columnsList = cloneDeep(columns);
292
+ if (showIndex && columns.length && columns.every((column) => column.dataIndex !== "sortIndex")) {
293
+ const firstColumsItem = columns[0];
294
+ columnsList.unshift({
295
+ title: "\u5E8F\u53F7",
296
+ align,
297
+ fixed: firstColumsItem.fixed,
298
+ width: 60,
299
+ uuid: getRandomNumber().uuid(15),
300
+ dataIndex: "sortIndex",
301
+ key: "sortIndex"
302
+ });
303
+ } else {
304
+ columnsList.filter((item) => item.dataIndex !== "sortIndex");
305
+ }
306
+ return columnsList;
307
+ }
308
+ function runFunction(valueEnum, ...rest) {
309
+ if (typeof valueEnum === "function") {
310
+ return valueEnum(...rest);
311
+ }
312
+ return valueEnum;
313
+ }
314
+ function deepCopy(data) {
315
+ return JSON.parse(JSON.stringify(data));
316
+ }
317
+ function handleCurrentPage(pageConfig, currentPage) {
318
+ if (isObject(pageConfig)) {
319
+ const { pageSize = 10, total = 0 } = pageConfig;
320
+ let { current = 1 } = pageConfig;
321
+ if (total - currentPage <= pageSize * (current - 1)) {
322
+ current = current - 1;
323
+ }
324
+ return current === 0 ? 1 : current;
325
+ }
326
+ return 1;
327
+ }
328
+ function getSortIndex(data = [], pageConfig, childrenKey = "children") {
329
+ function getChildSortIndex(parentSort, data2) {
330
+ return data2.map((item, index2) => {
331
+ const sortIndex = `${parentSort}-${index2 + 1}`;
332
+ if (item[childrenKey])
333
+ item[childrenKey] = getChildSortIndex(sortIndex, item[childrenKey]);
334
+ item.sortIndex = sortIndex;
335
+ return item;
336
+ });
337
+ }
338
+ return deepCopy(data).map((item, key) => {
339
+ let sortIndex = key;
340
+ const current = isObject(pageConfig) ? pageConfig.current || 1 : 1;
341
+ const pageSize = isObject(pageConfig) ? pageConfig.pageSize || 10 : 10;
342
+ sortIndex = current ? (current - 1) * pageSize + (key + 1) : key + 1;
343
+ if (item[childrenKey])
344
+ item[childrenKey] = getChildSortIndex(`${sortIndex}`, item[childrenKey]);
345
+ item.sortIndex = sortIndex;
346
+ return item;
347
+ });
348
+ }
349
+ function compareArray(obj1, obj2, key, sort) {
350
+ const val1 = obj1[key];
351
+ const val2 = obj2[key];
352
+ let result = 0;
353
+ if (val1 < val2) {
354
+ result = sort === 0 ? -1 : 0;
355
+ } else if (val1 > val2) {
356
+ result = sort === 0 ? 0 : -1;
357
+ }
358
+ return result;
359
+ }
360
+ function arrayRepeat(data) {
361
+ let array = deepCopy(data);
362
+ const set = new Set(array);
363
+ array = Array.from(set);
364
+ return array;
365
+ }
366
+ function hanndleField(str, customize) {
367
+ const stringNull = ["null", "undefined"];
368
+ let success = true;
369
+ if (str === 0) {
370
+ success = true;
371
+ } else if (stringNull.includes(str)) {
372
+ success = false;
373
+ } else if (!str) {
374
+ success = false;
375
+ }
376
+ if (success) {
377
+ return {
378
+ value: str,
379
+ success
380
+ };
381
+ }
382
+ return {
383
+ value: customize === "" ? customize : customize || "-",
384
+ success
385
+ };
386
+ }
387
+ function formatDuraton(time) {
388
+ let newTime = "";
389
+ if (time > -1) {
390
+ const hour = Math.floor(time / 3600);
391
+ const min = Math.floor(time / 60) % 60;
392
+ const sec = parseInt(String(time % 60));
393
+ if (hour < 10) {
394
+ newTime = "0" + hour + ":";
395
+ } else {
396
+ newTime = hour + ":";
397
+ }
398
+ if (min < 10) {
399
+ newTime += "0";
400
+ }
401
+ newTime += min + ":";
402
+ if (sec < 10) {
403
+ newTime += "0";
404
+ }
405
+ newTime += sec;
406
+ }
407
+ return newTime.split(":")[0] === "00" ? `${newTime.split(":")[1]}:${newTime.split(":")[2]}` : newTime;
408
+ }
409
+ function getRandomNumber() {
410
+ const CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
411
+ return {
412
+ uuid(len, rad) {
413
+ const chars = CHARS;
414
+ const uuid = [];
415
+ const radix = rad || chars.length;
416
+ let i;
417
+ let r;
418
+ if (len) {
419
+ for (i = 0; i < len; i += 1) {
420
+ uuid[i] = chars[parseInt(String(Math.random() * radix))];
421
+ }
422
+ } else {
423
+ uuid[8] = "-";
424
+ uuid[13] = "-";
425
+ uuid[18] = "-";
426
+ uuid[23] = "-";
427
+ uuid[14] = "4";
428
+ for (i = 0; i < 36; i += 1) {
429
+ if (!uuid[i]) {
430
+ r = Math.random() * 16;
431
+ uuid[i] = chars[i === 19 ? r && 3 || 8 : r];
432
+ }
433
+ }
434
+ }
435
+ return uuid.join("");
436
+ },
437
+ uuidFast() {
438
+ const chars = CHARS;
439
+ const uuid = new Array(36);
440
+ let rnd = 0;
441
+ let r;
442
+ let i;
443
+ for (i = 0; i < 36; i += 1) {
444
+ if (i === 8 || i === 13 || i === 18 || i === 23) {
445
+ uuid[i] = "-";
446
+ } else if (i === 14) {
447
+ uuid[i] = "4";
448
+ } else {
449
+ if (rnd <= 2) {
450
+ rnd = 33554432 + Math.random() * 16777216 || 0;
451
+ }
452
+ r = rnd && 15;
453
+ rnd = rnd > 4;
454
+ uuid[i] = chars[i === 19 ? r && 3 || 8 : r];
455
+ }
456
+ }
457
+ return uuid.join("");
458
+ },
459
+ uuidString() {
460
+ const str = this.uuidFast().replace(new RegExp("-", "g"), "");
461
+ return str;
462
+ },
463
+ uuidCompact() {
464
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
465
+ const r = Math.random() * 16 || 0;
466
+ const v = c === "x" ? r : r && 3 || 8;
467
+ return v.toString(16);
468
+ });
469
+ }
470
+ };
471
+ }
472
+ function getMaxFloor(treeData2 = []) {
473
+ let max = 0;
474
+ function each(data = [], floor) {
475
+ data.forEach((e) => {
476
+ e.floor = floor;
477
+ if (floor > max) {
478
+ max = floor;
479
+ }
480
+ if (e.children && e.children.length > 0) {
481
+ each(e.children, floor + 1);
482
+ }
483
+ });
484
+ }
485
+ each(treeData2, 1);
486
+ return max;
487
+ }
488
+ function getLevelData(data, filed = "children") {
489
+ let newData = [];
490
+ data.forEach((item) => {
491
+ newData.push(item);
492
+ if (item[filed] && item[filed].length > 0) {
493
+ newData = newData.concat(getLevelData(item[filed]));
494
+ }
495
+ });
496
+ return newData;
497
+ }
498
+ function treeData(source, id2, parentId, children, rootId) {
499
+ id2 = id2 || "id";
500
+ parentId = parentId || "parentId";
501
+ children = children || "children";
502
+ rootId = rootId || 0;
503
+ const cloneData = JSON.parse(JSON.stringify(source));
504
+ return cloneData.filter((father) => {
505
+ const branchArr = cloneData.filter((child) => father[id2] === child[parentId || "parentId"]);
506
+ branchArr.length > 0 ? father[children || "children"] = branchArr : delete father[children || "children"];
507
+ return father[parentId || "parentId"] === rootId;
508
+ });
509
+ }
510
+ function getBlobUrl(blob) {
511
+ return URL.createObjectURL(blob);
512
+ }
513
+ function getBase64(file) {
514
+ return new Promise((resolve, reject) => {
515
+ const reader = new FileReader();
516
+ reader.readAsDataURL(file);
517
+ reader.onload = () => resolve(reader.result);
518
+ reader.onerror = (error) => reject(error);
519
+ });
520
+ }
521
+ function dataURLtoBlob(dataurl) {
522
+ const arr = dataurl.split(",");
523
+ const mime = arr[0].match(/:(.*?);/)[1];
524
+ const bstr = atob(arr[1]);
525
+ let n = bstr.length;
526
+ const u8arr = new Uint8Array(n);
527
+ while (n--) {
528
+ u8arr[n] = bstr.charCodeAt(n);
529
+ }
530
+ return new Blob([u8arr], { type: mime });
531
+ }
532
+ function dataURLtoFile(dataurl, filename) {
533
+ const arr = dataurl.split(",");
534
+ const mime = arr[0].match(/:(.*?);/)[1];
535
+ const bstr = atob(arr[1]);
536
+ let n = bstr.length;
537
+ const u8arr = new Uint8Array(n);
538
+ while (n--) {
539
+ u8arr[n] = bstr.charCodeAt(n);
540
+ }
541
+ return new File([u8arr], filename, { type: mime });
542
+ }
543
+ function blobToDataURL(blob, fileName, fileType) {
544
+ return new window.File([blob], fileName, { type: fileType });
545
+ }
546
+ function getVideoFileUrl(url = "") {
547
+ const index2 = url.indexOf("?");
548
+ return index2 > 0 ? `${url.substring(0, index2)}` : url;
549
+ }
550
+ function getFileSuffix(url = "") {
551
+ url = getVideoFileUrl(url);
552
+ const index2 = url.lastIndexOf(".");
553
+ return index2 > 0 ? `${url.substring(index2).split("?")[0]}`.split(".")[1] : "";
554
+ }
555
+ function checkFileType(url, type) {
556
+ if (type)
557
+ return type;
558
+ if (!url)
559
+ return "4";
560
+ if (url === "data:")
561
+ return "4";
562
+ let fileType = "4";
563
+ if (isBase64(url)) {
564
+ if (url.includes("data:image/")) {
565
+ fileType = "png";
566
+ } else if (url.includes("data:video/")) {
567
+ fileType = "mp4";
568
+ } else if (url.includes("data:audio/")) {
569
+ fileType = "mp3";
570
+ }
571
+ } else if (url instanceof Blob) {
572
+ url = String(url);
573
+ if (url.includes("image")) {
574
+ fileType = "png";
575
+ } else if (url.includes("video")) {
576
+ fileType = "mp4";
577
+ } else if (url.includes("audio")) {
578
+ fileType = "mp3";
579
+ }
580
+ } else {
581
+ fileType = getFileSuffix(url).toLowerCase();
582
+ }
583
+ if (global.imageType.includes(fileType))
584
+ return "1";
585
+ if (global.videoType.includes(fileType))
586
+ return "3";
587
+ if (global.audioType.includes(fileType))
588
+ return "2";
589
+ return "4";
590
+ }
591
+ function getMediaInfos(mediaInfo) {
592
+ const { url = "", fileType = "1" } = mediaInfo;
593
+ let mediaUrl = "";
594
+ if (url instanceof File) {
595
+ mediaUrl = URL.createObjectURL(url);
596
+ } else if (isBase64(url)) {
597
+ mediaUrl = url;
598
+ } else if (url instanceof Blob) {
599
+ mediaUrl = URL.createObjectURL(url);
600
+ } else if (url.includes("https") || url.includes("http")) {
601
+ mediaUrl = fileType === "1" ? url : url;
602
+ }
603
+ return new Promise(function(resolve) {
604
+ let elememt;
605
+ if (fileType === "1") {
606
+ elememt = document.createElement("img");
607
+ elememt.src = mediaUrl;
608
+ } else if (fileType === "2") {
609
+ elememt = document.createElement("audio");
610
+ elememt.src = mediaUrl;
611
+ } else if (fileType === "3") {
612
+ elememt = document.createElement("video");
613
+ elememt.src = mediaUrl;
614
+ }
615
+ if (fileType === "1") {
616
+ elememt.onload = function() {
617
+ resolve({
618
+ play: true,
619
+ width: elememt.width || 0,
620
+ height: elememt.height || 0
621
+ });
622
+ elememt = null;
623
+ };
624
+ } else {
625
+ elememt.oncanplay = function() {
626
+ resolve({
627
+ play: true,
628
+ duration: elememt.duration,
629
+ width: (elememt == null ? void 0 : elememt.videoWidth) || 0,
630
+ height: (elememt == null ? void 0 : elememt.videoHeight) || 0
631
+ });
632
+ elememt = null;
633
+ };
634
+ }
635
+ elememt.onerror = function() {
636
+ resolve({
637
+ play: false
638
+ });
639
+ elememt = null;
640
+ };
641
+ });
642
+ }
643
+ async function getVideoCoverPicture(videoInfo) {
644
+ const { url = "", currentTime, videoSuffix = "", vidoeAllowPlay = false } = videoInfo;
645
+ let videoUrl = "";
646
+ let fileSuffix = videoSuffix;
647
+ let fileType = "1";
648
+ let videoPlayInfo;
649
+ if (url instanceof File) {
650
+ videoUrl = URL.createObjectURL(url);
651
+ fileSuffix = getFileSuffix(url.name);
652
+ fileType = checkFileType(url.name);
653
+ } else if (url instanceof Blob) {
654
+ videoUrl = URL.createObjectURL(url);
655
+ fileType = checkFileType(url);
656
+ } else if (isBase64(url)) {
657
+ videoUrl = url;
658
+ fileType = checkFileType(url);
659
+ } else if (url.includes("https") || url.includes("http")) {
660
+ videoUrl = url;
661
+ fileSuffix = getFileSuffix(url);
662
+ fileType = checkFileType(url);
663
+ }
664
+ const videoExplan = fileSuffix ? global.videoAllowType.includes(fileSuffix.toLowerCase()) : false;
665
+ if (videoExplan) {
666
+ if (vidoeAllowPlay) {
667
+ return generateVidoePicture(videoUrl, currentTime);
668
+ } else {
669
+ videoPlayInfo = await getMediaInfos({
670
+ url: videoUrl,
671
+ fileType
672
+ });
673
+ if (videoPlayInfo.play) {
674
+ return generateVidoePicture(videoUrl, currentTime);
675
+ } else {
676
+ return new Promise(function(resolve) {
677
+ resolve("");
678
+ });
679
+ }
680
+ }
681
+ } else {
682
+ return new Promise(function(resolve) {
683
+ resolve("");
684
+ });
685
+ }
686
+ }
687
+ async function generateVidoePicture(videoUrl, currentTime) {
688
+ let video = document.createElement("video");
689
+ video.style.display = "none";
690
+ video.controls = true;
691
+ video.muted = true;
692
+ if (currentTime) {
693
+ video.currentTime = currentTime;
694
+ }
695
+ video.setAttribute("src", videoUrl);
696
+ video.setAttribute("muted", String(true));
697
+ video.setAttribute("crossorigin", "anonymous");
698
+ video.setAttribute("autoplay", String(true));
699
+ const canvas = document.createElement("canvas");
700
+ const scale = 0.8;
701
+ const delay = 100;
702
+ const ctx = canvas.getContext("2d");
703
+ return new Promise(function(resolve) {
704
+ if (video) {
705
+ video.addEventListener("canplay", function() {
706
+ setTimeout(function() {
707
+ const w = (video == null ? void 0 : video.videoWidth) || 0 * scale;
708
+ const h = (video == null ? void 0 : video.videoHeight) || 0 * scale;
709
+ const space = 0;
710
+ canvas.width = (video == null ? void 0 : video.videoWidth) || 0 * scale;
711
+ canvas.height = (video == null ? void 0 : video.videoHeight) || 0 * scale;
712
+ ctx.drawImage(video, 0, 0, w + space, h + space);
713
+ video = null;
714
+ resolve(w === 0 || h === 0 ? "" : canvas.toDataURL("image/png", 1));
715
+ }, delay);
716
+ }, false);
717
+ }
718
+ });
719
+ }
720
+ function isBase64(str = "") {
721
+ const fileDataBase = [
722
+ "data:image/",
723
+ "data:video/",
724
+ "data:audio/"
725
+ ];
726
+ if (str && fileDataBase.find((item) => str.includes(item))) {
727
+ return true;
728
+ }
729
+ return false;
730
+ }
731
+ function on(element, event, handler, useCapture = false) {
732
+ if (element && event && handler) {
733
+ element.addEventListener(event, handler, useCapture);
734
+ }
735
+ }
736
+ function off(element, event, handler, useCapture = false) {
737
+ if (element && event && handler) {
738
+ element.removeEventListener(event, handler, useCapture);
739
+ }
740
+ }
741
+ var index$1 = "";
742
+ const FieldLabel = defineComponent({
743
+ props: {
744
+ id: PropTypes$1.string,
745
+ style: PropTypes$1.style,
746
+ size: {
747
+ type: String,
748
+ default: "middle"
749
+ },
750
+ label: Object,
751
+ placeholder: [Object, String],
752
+ class: String,
753
+ ellipsis: Boolean,
754
+ allowClear: {
755
+ type: Boolean,
756
+ default: true
757
+ },
758
+ bordered: Boolean,
759
+ expanded: Boolean,
760
+ disabled: Boolean,
761
+ onClear: Function,
762
+ onLabelClick: Function,
763
+ formatter: Function,
764
+ value: PropTypes$1.any
765
+ },
766
+ setup(props, {
767
+ expose
768
+ }) {
769
+ const prefixCls = getPrefixCls({
770
+ suffixCls: "core-field-label",
771
+ isPor: true
772
+ });
773
+ const labelRef = ref();
774
+ const clearRef = ref();
775
+ const allowClear = computed(() => props.allowClear || true);
776
+ expose({
777
+ labelRef,
778
+ clearRef
779
+ });
780
+ const formatterText = (aValue) => {
781
+ if (props.formatter) {
782
+ return props.formatter(aValue);
783
+ }
784
+ return Array.isArray(aValue) ? aValue.join(",") : String(aValue);
785
+ };
786
+ const getTextByValue = (aLabel, aValue) => {
787
+ var _a, _b;
788
+ if (aValue !== void 0 && aValue !== null && aValue !== "" && (!Array.isArray(aValue) || aValue.length)) {
789
+ const isValueNode = isVNode(aValue);
790
+ const prefix = aLabel ? createVNode("span", {
791
+ "onClick": props.onLabelClick,
792
+ "class": `${prefixCls}-text`
793
+ }, [aLabel, ": "]) : "";
794
+ const str = isValueNode ? "" : formatterText(aValue);
795
+ if (!props.ellipsis) {
796
+ return createVNode("span", {
797
+ "style": {
798
+ display: "inline-flex",
799
+ alignItems: "center"
800
+ }
801
+ }, [prefix, isValueNode ? aValue : formatterText(aValue)]);
802
+ }
803
+ const VALUE_MAX_LENGTH = 41;
804
+ const getText = () => {
805
+ const isArrayValue = Array.isArray(aValue) && aValue.length > 1;
806
+ const unitText = "\u9879";
807
+ if (typeof str === "string" && str.length > VALUE_MAX_LENGTH && isArrayValue) {
808
+ return `...${aValue.length}${unitText}`;
809
+ }
810
+ return "";
811
+ };
812
+ const tail = getText();
813
+ return createVNode("span", {
814
+ "title": isValueNode ? "" : str,
815
+ "style": {
816
+ display: "inline-flex",
817
+ alignItems: "center"
818
+ }
819
+ }, [prefix, createVNode("span", {
820
+ "style": {
821
+ paddingInlineStart: 4
822
+ }
823
+ }, [typeof str === "string" ? (_b = (_a = str == null ? void 0 : str.toString()) == null ? void 0 : _a.substr) == null ? void 0 : _b.call(_a, 0, VALUE_MAX_LENGTH) : aValue]), tail]);
824
+ }
825
+ return aLabel || props.placeholder;
826
+ };
827
+ return () => createVNode("span", {
828
+ "class": {
829
+ [`${prefixCls}`]: true,
830
+ [`${prefixCls}-${props.size}`]: props.size,
831
+ [`${prefixCls}-active`]: !!props.value || props.value === 0,
832
+ [`${prefixCls}-disabled`]: props.disabled,
833
+ [`${prefixCls}-bordered`]: props.bordered,
834
+ [`${prefixCls}-allow-clear`]: allowClear.value,
835
+ [`${props.class}`]: props.class
836
+ },
837
+ "style": props.style,
838
+ "ref": labelRef
839
+ }, [getTextByValue(props.label, props.value), (props.value || props.value === 0) && allowClear.value && createVNode(CloseOutlined, {
840
+ "role": "button",
841
+ "title": "\u6E05\u9664",
842
+ "class": [`${prefixCls}-icon`, `${prefixCls}-close`],
843
+ "onClick": (e) => {
844
+ if (props.onClear && !props.disabled) {
845
+ props.onClear();
846
+ }
847
+ e.stopPropagation();
848
+ },
849
+ "ref": clearRef
850
+ }, null), createVNode(DownOutlined, {
851
+ "class": [`${prefixCls}-icon`, `${prefixCls}-arrow`]
852
+ }, null)]);
853
+ }
854
+ });
855
+ var index = "";
856
+ const LabelIconTip = (props) => {
857
+ if (!props.tooltip && !props.subTitle) {
858
+ return createVNode(Fragment, null, [props.label]);
859
+ }
860
+ const className = getPrefixCls({
861
+ suffixCls: "core-label-tip",
862
+ isPor: true
863
+ });
864
+ const tooltipProps = typeof props.tooltip === "string" ? {
865
+ title: props.tooltip
866
+ } : props.tooltip;
867
+ const icon = (tooltipProps == null ? void 0 : tooltipProps.icon) || createVNode(InfoCircleOutlined, null, null);
868
+ return createVNode("div", {
869
+ "class": className,
870
+ "onMousedown": (e) => e.stopPropagation(),
871
+ "onMouseleave": (e) => e.stopPropagation(),
872
+ "onMousemove": (e) => e.stopPropagation()
873
+ }, [createVNode("div", {
874
+ "class": {
875
+ [`${className}-title`]: true,
876
+ [`${className}-title-ellipsis`]: props.ellipsis
877
+ }
878
+ }, [props.label]), props.subTitle && createVNode("div", {
879
+ "class": `${className}-subtitle`
880
+ }, [props.subTitle]), props.tooltip && createVNode(Tooltip, tooltipProps, {
881
+ default: () => [createVNode("span", {
882
+ "class": `${className}-icon`
883
+ }, [icon])]
884
+ })]);
885
+ };
886
+ const merge = (...rest) => {
887
+ const obj = {};
888
+ const il = rest.length;
889
+ let key;
890
+ let i = 0;
891
+ for (; i < il; i += 1) {
892
+ for (key in rest[i]) {
893
+ if (rest[i].hasOwnProperty(key)) {
894
+ if (typeof obj[key] === "object" && typeof rest[i][key] === "object" && obj[key] !== void 0 && obj[key] !== null && !Array.isArray(obj[key]) && !Array.isArray(rest[i][key])) {
895
+ obj[key] = {
896
+ ...obj[key],
897
+ ...rest[i][key]
898
+ };
899
+ } else {
900
+ obj[key] = rest[i][key];
901
+ }
902
+ }
903
+ }
904
+ }
905
+ return obj;
906
+ };
907
+ function isDeepEqualReact(a, b, ignoreKeys, debug) {
908
+ if (a === b)
909
+ return true;
910
+ if (a && b && typeof a === "object" && typeof b === "object") {
911
+ if (a.constructor !== b.constructor)
912
+ return false;
913
+ let length;
914
+ let i;
915
+ let keys;
916
+ if (Array.isArray(a)) {
917
+ length = a.length;
918
+ if (length != b.length)
919
+ return false;
920
+ for (i = length; i-- !== 0; ) {
921
+ if (!isDeepEqualReact(a[i], b[i], ignoreKeys, debug))
922
+ return false;
923
+ }
924
+ return true;
925
+ }
926
+ if (a instanceof Map && b instanceof Map) {
927
+ if (a.size !== b.size)
928
+ return false;
929
+ for (i of a.entries()) {
930
+ if (!b.has(i[0]))
931
+ return false;
932
+ }
933
+ for (i of a.entries()) {
934
+ if (!isDeepEqualReact(i[1], b.get(i[0]), ignoreKeys, debug))
935
+ return false;
936
+ }
937
+ return true;
938
+ }
939
+ if (a instanceof Set && b instanceof Set) {
940
+ if (a.size !== b.size)
941
+ return false;
942
+ for (i of a.entries()) {
943
+ if (!b.has(i[0]))
944
+ return false;
945
+ }
946
+ return true;
947
+ }
948
+ if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
949
+ length = a.length;
950
+ if (length != b.length)
951
+ return false;
952
+ for (i = length; i-- !== 0; ) {
953
+ if (a[i] !== b[i])
954
+ return false;
955
+ }
956
+ return true;
957
+ }
958
+ if (a.constructor === RegExp)
959
+ return a.source === b.source && a.flags === b.flags;
960
+ if (a.valueOf !== Object.prototype.valueOf && a.valueOf)
961
+ return a.valueOf() === b.valueOf();
962
+ if (a.toString !== Object.prototype.toString && a.toString)
963
+ return a.toString() === b.toString();
964
+ keys = Object.keys(a);
965
+ length = keys.length;
966
+ if (length !== Object.keys(b).length)
967
+ return false;
968
+ for (i = length; i-- !== 0; ) {
969
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
970
+ return false;
971
+ }
972
+ for (i = length; i-- !== 0; ) {
973
+ const key = keys[i];
974
+ if (ignoreKeys == null ? void 0 : ignoreKeys.includes(key))
975
+ continue;
976
+ if (key === "_owner" && a.$$typeof) {
977
+ continue;
978
+ }
979
+ if (!isDeepEqualReact(a[key], b[key], ignoreKeys, debug)) {
980
+ if (debug) {
981
+ console.log(key);
982
+ }
983
+ return false;
984
+ }
985
+ }
986
+ return true;
987
+ }
988
+ return a !== a && b !== b;
989
+ }
990
+ const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
991
+ const isBrowser = () => {
992
+ return typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.matchMedia !== "undefined" && !isNode;
993
+ };
994
+ const omitBoolean = (obj) => {
995
+ if (obj && obj !== true) {
996
+ return obj;
997
+ }
998
+ return void 0;
999
+ };
1000
+ const omitUndefined = (obj) => {
1001
+ const newObj = {};
1002
+ Object.keys(obj || {}).forEach((key) => {
1003
+ if (obj[key] !== void 0) {
1004
+ newObj[key] = obj[key];
1005
+ }
1006
+ });
1007
+ if (Object.keys(newObj).length < 1) {
1008
+ return void 0;
1009
+ }
1010
+ return newObj;
1011
+ };
1012
+ const isSlotFragment = (slots) => {
1013
+ return slots.length === 1 && (String(slots[0].type) === String(Symbol("Comment")) || String(slots[0].type) === String(Symbol("Fragment")) || String(slots[0].type) === String(Symbol()));
1014
+ };
1015
+ function getRealVNode(vnode) {
1016
+ if (isSlotFragment(vnode))
1017
+ return isVNode(vnode[0].children) ? vnode[0].children : vnode;
1018
+ return vnode;
1019
+ }
1020
+ function getSlot(slots, props, prop = "default") {
1021
+ if (props[prop] === false) {
1022
+ return false;
1023
+ }
1024
+ if (isBoolean(props[prop]) && props[prop])
1025
+ return (slots == null ? void 0 : slots[prop]) || props[prop];
1026
+ return props[prop] || slots[prop];
1027
+ }
1028
+ function getSlotVNode(slots, props, prop = "default") {
1029
+ var _a, _b;
1030
+ if (props[prop] === false) {
1031
+ return false;
1032
+ }
1033
+ if (isBoolean(props[prop]) && props[prop])
1034
+ return ((_a = slots == null ? void 0 : slots[prop]) == null ? void 0 : _a.call(slots)) || props[prop];
1035
+ return props[prop] || ((_b = slots[prop]) == null ? void 0 : _b.call(slots));
1036
+ }
1037
+ function getSlotsProps(data, slots, props) {
1038
+ const renderSlotsAndProps = {};
1039
+ data.forEach((name) => {
1040
+ renderSlotsAndProps[name] = getSlotVNode(slots, props, name);
1041
+ });
1042
+ return renderSlotsAndProps;
1043
+ }
1044
+ export { FieldLabel, LabelIconTip, arrayRepeat, blobToDataURL, checkFileType, classNames, compareArray, dataURLtoBlob, dataURLtoFile, deepCopy, formatDuraton, genColumnKey, generateVidoePicture, getBase64, getBlobUrl, getFileSuffix, getLevelData, getMaxFloor, getMediaInfos, getPrefixCls, getRandomNumber, getRealVNode, getScroll, getScrollContainer, getSlot, getSlotVNode, getSlotsProps, getSortIndex, getVideoCoverPicture, getVideoFileUrl, global as globalConfig, handleCurrentPage, handleShowIndex, hanndleField, is, isArray, isBase64, isBoolean, isBrowser, isDeepEqualReact, isFunction, isInContainer, isNumber, isObject, isScroll, isServer, isSlotFragment, isString, merge, off, omitBoolean, omitUndefined, on, runFunction, scrollTo, throttleByAnimationFrame, treeData };