bm-admin-ui 1.0.28-alpha → 1.0.29-alpha
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.
- package/es/components/button/index.d.ts +307 -0
- package/es/components/button/src/button.d.ts +12 -0
- package/es/components/button/src/button.vue.d.ts +308 -0
- package/es/components/feedback/index.d.ts +1037 -0
- package/es/components/feedback/index.js +1306 -25
- package/es/components/feedback/src/bmAlert.vue.d.ts +193 -0
- package/es/components/feedback/src/bmModal.vue.d.ts +839 -0
- package/es/components/float-table/index.d.ts +70 -0
- package/es/components/float-table/index.js +28 -37
- package/es/components/float-table/src/float-table.vue.d.ts +69 -0
- package/es/components/flow-designer/index.d.ts +7 -0
- package/es/components/flow-designer/src/flow-designer.vue.d.ts +6 -0
- package/es/components/form-designer/index.d.ts +9 -0
- package/es/components/form-designer/index.js +9 -4182
- package/es/components/form-designer/src/form-designer.vue.d.ts +8 -0
- package/es/components/index.d.ts +13 -0
- package/es/components/index.js +0 -1
- package/es/components/input-tags-display/index.d.ts +113 -0
- package/es/components/input-tags-display/index.js +1187 -27
- package/es/components/input-tags-display/src/input-tags-display.vue.d.ts +110 -0
- package/es/components/multi-cascader-compose/index.d.ts +164 -0
- package/es/components/multi-cascader-compose/index.js +1199 -31
- package/es/components/multi-cascader-compose/src/multi-cascader-compose.vue.d.ts +164 -0
- package/es/components/multi-cascader-compose/src/props.d.ts +40 -0
- package/es/components/multi-cascader-compose/types.d.ts +10 -0
- package/es/components/over-tooltips/index.d.ts +35 -0
- package/es/components/over-tooltips/index.js +20 -27
- package/es/components/over-tooltips/src/over-tooltips.vue.d.ts +34 -0
- package/es/components/search-filter/index.d.ts +223 -0
- package/es/components/search-filter/index.js +1291 -71
- package/es/components/search-filter/src/search-filter.d.ts +81 -0
- package/es/components/search-filter/src/search-filter.vue.d.ts +222 -0
- package/es/components/search-filter/src/search-reset-btn.vue.d.ts +106 -0
- package/es/components/shops-filter/index.d.ts +99 -0
- package/es/components/shops-filter/index.js +1182 -24
- package/es/components/shops-filter/src/shops-filter.d.ts +25 -0
- package/es/components/shops-filter/src/shops-filter.vue.d.ts +98 -0
- package/es/components/staffs-selector/index.d.ts +109 -0
- package/es/components/staffs-selector/index.js +1241 -131
- package/es/components/staffs-selector/src/multipleCmp.vue.d.ts +97 -0
- package/es/components/staffs-selector/src/radioCmp.vue.d.ts +31 -0
- package/es/components/staffs-selector/src/staffs-selector.vue.d.ts +108 -0
- package/es/components/staffs-selector/src/variedCmp.vue.d.ts +62 -0
- package/es/components/timeline/index.d.ts +118 -0
- package/es/components/timeline/index.js +15 -12
- package/es/components/timeline/src/props.d.ts +27 -0
- package/es/components/timeline/src/timeline-item.vue.d.ts +66 -0
- package/es/components/timeline/src/timeline.vue.d.ts +52 -0
- package/es/components/upload/index.d.ts +137 -0
- package/es/components/upload/index.js +1365 -104
- package/es/components/upload/src/icons.d.ts +13 -0
- package/es/components/upload/src/upload.vue.d.ts +136 -0
- package/es/components/upload/utils/index.d.ts +7 -0
- package/es/index.d.ts +6 -0
- package/es/utils/bm-admin-ui-resolver.d.ts +9 -0
- package/es/utils/vxe-table.d.ts +6 -0
- package/es/utils/vxe-table.js +3 -4
- package/es/utils/with-install.d.ts +3 -0
- package/index.esm.js +47099 -0
- package/index.js +47129 -0
- package/lib/components/button/index.d.ts +307 -0
- package/lib/components/button/src/button.d.ts +12 -0
- package/lib/components/button/src/button.vue.d.ts +308 -0
- package/lib/components/feedback/index.d.ts +1037 -0
- package/lib/components/feedback/index.js +1304 -23
- package/lib/components/feedback/src/bmAlert.vue.d.ts +193 -0
- package/lib/components/feedback/src/bmModal.vue.d.ts +839 -0
- package/lib/components/float-table/index.d.ts +70 -0
- package/lib/components/float-table/index.js +28 -37
- package/lib/components/float-table/src/float-table.vue.d.ts +69 -0
- package/lib/components/flow-designer/index.d.ts +7 -0
- package/lib/components/flow-designer/src/flow-designer.vue.d.ts +6 -0
- package/lib/components/form-designer/index.d.ts +9 -0
- package/lib/components/form-designer/index.js +8 -4187
- package/lib/components/form-designer/src/form-designer.vue.d.ts +8 -0
- package/lib/components/index.d.ts +13 -0
- package/lib/components/index.js +0 -7
- package/lib/components/input-tags-display/index.d.ts +113 -0
- package/lib/components/input-tags-display/index.js +1187 -27
- package/lib/components/input-tags-display/src/input-tags-display.vue.d.ts +110 -0
- package/lib/components/multi-cascader-compose/index.d.ts +164 -0
- package/lib/components/multi-cascader-compose/index.js +1198 -30
- package/lib/components/multi-cascader-compose/src/multi-cascader-compose.vue.d.ts +164 -0
- package/lib/components/multi-cascader-compose/src/props.d.ts +40 -0
- package/lib/components/multi-cascader-compose/types.d.ts +10 -0
- package/lib/components/over-tooltips/index.d.ts +35 -0
- package/lib/components/over-tooltips/index.js +20 -27
- package/lib/components/over-tooltips/src/over-tooltips.vue.d.ts +34 -0
- package/lib/components/search-filter/index.d.ts +223 -0
- package/lib/components/search-filter/index.js +1290 -70
- package/lib/components/search-filter/src/search-filter.d.ts +81 -0
- package/lib/components/search-filter/src/search-filter.vue.d.ts +222 -0
- package/lib/components/search-filter/src/search-reset-btn.vue.d.ts +106 -0
- package/lib/components/shops-filter/index.d.ts +99 -0
- package/lib/components/shops-filter/index.js +1181 -23
- package/lib/components/shops-filter/src/shops-filter.d.ts +25 -0
- package/lib/components/shops-filter/src/shops-filter.vue.d.ts +98 -0
- package/lib/components/staffs-selector/index.d.ts +109 -0
- package/lib/components/staffs-selector/index.js +1240 -130
- package/lib/components/staffs-selector/src/multipleCmp.vue.d.ts +97 -0
- package/lib/components/staffs-selector/src/radioCmp.vue.d.ts +31 -0
- package/lib/components/staffs-selector/src/staffs-selector.vue.d.ts +108 -0
- package/lib/components/staffs-selector/src/variedCmp.vue.d.ts +62 -0
- package/lib/components/timeline/index.d.ts +118 -0
- package/lib/components/timeline/index.js +15 -12
- package/lib/components/timeline/src/props.d.ts +27 -0
- package/lib/components/timeline/src/timeline-item.vue.d.ts +66 -0
- package/lib/components/timeline/src/timeline.vue.d.ts +52 -0
- package/lib/components/upload/index.d.ts +137 -0
- package/lib/components/upload/index.js +1364 -103
- package/lib/components/upload/src/icons.d.ts +13 -0
- package/lib/components/upload/src/upload.vue.d.ts +136 -0
- package/lib/components/upload/utils/index.d.ts +7 -0
- package/lib/index.d.ts +6 -0
- package/lib/utils/bm-admin-ui-resolver.d.ts +9 -0
- package/lib/utils/vxe-table.d.ts +6 -0
- package/lib/utils/vxe-table.js +2 -3
- package/lib/utils/with-install.d.ts +3 -0
- package/package.json +4 -9
- package/theme-chalk/button.css +1 -1
- package/theme-chalk/feedback.css +1 -1
- package/theme-chalk/float-table.css +1 -1
- package/theme-chalk/floating-vue.css +1 -1
- package/theme-chalk/flow-designer.css +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/input-tags-display.css +1 -1
- package/theme-chalk/modal.css +1 -1
- package/theme-chalk/multi-cascader-compose.css +1 -1
- package/theme-chalk/over-tooltips.css +1 -1
- package/theme-chalk/search-filter.css +1 -1
- package/theme-chalk/staffs-selector.css +1 -1
- package/theme-chalk/timeline.css +1 -1
- package/theme-chalk/upload.css +1 -1
- package/types/components/button/index.d.ts +307 -0
- package/types/components/button/src/button.d.ts +12 -0
- package/types/components/button/src/button.vue.d.ts +308 -0
- package/types/components/feedback/index.d.ts +1037 -0
- package/types/components/feedback/src/bmAlert.vue.d.ts +193 -0
- package/types/components/feedback/src/bmModal.vue.d.ts +839 -0
- package/types/components/float-table/index.d.ts +70 -0
- package/types/components/float-table/src/float-table.vue.d.ts +69 -0
- package/types/components/flow-designer/index.d.ts +7 -0
- package/types/components/flow-designer/src/flow-designer.vue.d.ts +6 -0
- package/types/components/form-designer/index.d.ts +9 -0
- package/types/components/form-designer/src/form-designer.vue.d.ts +8 -0
- package/types/components/index.d.ts +13 -0
- package/types/components/input-tags-display/index.d.ts +113 -0
- package/types/components/input-tags-display/src/input-tags-display.vue.d.ts +110 -0
- package/types/components/multi-cascader-compose/index.d.ts +164 -0
- package/types/components/multi-cascader-compose/src/multi-cascader-compose.vue.d.ts +164 -0
- package/types/components/multi-cascader-compose/src/props.d.ts +40 -0
- package/types/components/multi-cascader-compose/types.d.ts +10 -0
- package/types/components/over-tooltips/index.d.ts +35 -0
- package/types/components/over-tooltips/src/over-tooltips.vue.d.ts +34 -0
- package/types/components/search-filter/index.d.ts +223 -0
- package/types/components/search-filter/src/search-filter.d.ts +81 -0
- package/types/components/search-filter/src/search-filter.vue.d.ts +222 -0
- package/types/components/search-filter/src/search-reset-btn.vue.d.ts +106 -0
- package/types/components/shops-filter/index.d.ts +99 -0
- package/types/components/shops-filter/src/shops-filter.d.ts +25 -0
- package/types/components/shops-filter/src/shops-filter.vue.d.ts +98 -0
- package/types/components/staffs-selector/index.d.ts +109 -0
- package/types/components/staffs-selector/src/multipleCmp.vue.d.ts +97 -0
- package/types/components/staffs-selector/src/radioCmp.vue.d.ts +31 -0
- package/types/components/staffs-selector/src/staffs-selector.vue.d.ts +108 -0
- package/types/components/staffs-selector/src/variedCmp.vue.d.ts +62 -0
- package/types/components/timeline/index.d.ts +118 -0
- package/types/components/timeline/src/props.d.ts +27 -0
- package/types/components/timeline/src/timeline-item.vue.d.ts +66 -0
- package/types/components/timeline/src/timeline.vue.d.ts +52 -0
- package/types/components/upload/index.d.ts +137 -0
- package/types/components/upload/src/icons.d.ts +13 -0
- package/types/components/upload/src/upload.vue.d.ts +136 -0
- package/types/components/upload/utils/index.d.ts +7 -0
- package/types/index.d.ts +6 -0
- package/types/utils/bm-admin-ui-resolver.d.ts +9 -0
- package/types/utils/vxe-table.d.ts +6 -0
- package/types/utils/with-install.d.ts +3 -0
- package/es/components/form-create/index.js +0 -2769
- package/es/utils/uniqueId.js +0 -5
- package/lib/components/form-create/index.js +0 -2781
- package/lib/utils/uniqueId.js +0 -8
- package/theme-chalk/form-create.css +0 -1
- package/theme-chalk/form-designer.css +0 -1
|
@@ -1,6 +1,1150 @@
|
|
|
1
1
|
import { withInstall } from 'bm-admin-ui/es/utils/with-install';
|
|
2
|
-
import { reactive, onBeforeUnmount, ref, watch,
|
|
3
|
-
|
|
2
|
+
import { h, nextTick, createVNode, reactive, onBeforeUnmount, ref, watch, toRefs, resolveComponent, openBlock, createBlock, withCtx, renderSlot, createElementVNode, normalizeStyle, normalizeClass, createTextVNode, toDisplayString, computed, watchEffect, createElementBlock, Fragment, renderList, createCommentVNode, mergeProps } from 'vue';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Take input from [0, n] and return it as [0, 1]
|
|
6
|
+
* @hidden
|
|
7
|
+
*/
|
|
8
|
+
function bound01(n, max) {
|
|
9
|
+
if (isOnePointZero(n)) {
|
|
10
|
+
n = '100%';
|
|
11
|
+
}
|
|
12
|
+
var isPercent = isPercentage(n);
|
|
13
|
+
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
|
|
14
|
+
// Automatically convert percentage into number
|
|
15
|
+
if (isPercent) {
|
|
16
|
+
n = parseInt(String(n * max), 10) / 100;
|
|
17
|
+
}
|
|
18
|
+
// Handle floating point rounding errors
|
|
19
|
+
if (Math.abs(n - max) < 0.000001) {
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
// Convert into [0, 1] range if it isn't already
|
|
23
|
+
if (max === 360) {
|
|
24
|
+
// If n is a hue given in degrees,
|
|
25
|
+
// wrap around out-of-range values into [0, 360] range
|
|
26
|
+
// then convert into [0, 1].
|
|
27
|
+
n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// If n not a hue given in degrees
|
|
31
|
+
// Convert into [0, 1] range if it isn't already.
|
|
32
|
+
n = (n % max) / parseFloat(String(max));
|
|
33
|
+
}
|
|
34
|
+
return n;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
38
|
+
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
function isOnePointZero(n) {
|
|
42
|
+
return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check to see if string passed in is a percentage
|
|
46
|
+
* @hidden
|
|
47
|
+
*/
|
|
48
|
+
function isPercentage(n) {
|
|
49
|
+
return typeof n === 'string' && n.indexOf('%') !== -1;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
function boundAlpha(a) {
|
|
56
|
+
a = parseFloat(a);
|
|
57
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
58
|
+
a = 1;
|
|
59
|
+
}
|
|
60
|
+
return a;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Replace a decimal with it's percentage value
|
|
64
|
+
* @hidden
|
|
65
|
+
*/
|
|
66
|
+
function convertToPercentage(n) {
|
|
67
|
+
if (n <= 1) {
|
|
68
|
+
return Number(n) * 100 + "%";
|
|
69
|
+
}
|
|
70
|
+
return n;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Force a hex value to have 2 characters
|
|
74
|
+
* @hidden
|
|
75
|
+
*/
|
|
76
|
+
function pad2(c) {
|
|
77
|
+
return c.length === 1 ? '0' + c : String(c);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
81
|
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
82
|
+
/**
|
|
83
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
84
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
85
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
86
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
87
|
+
*/
|
|
88
|
+
function rgbToRgb(r, g, b) {
|
|
89
|
+
return {
|
|
90
|
+
r: bound01(r, 255) * 255,
|
|
91
|
+
g: bound01(g, 255) * 255,
|
|
92
|
+
b: bound01(b, 255) * 255,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function hue2rgb(p, q, t) {
|
|
96
|
+
if (t < 0) {
|
|
97
|
+
t += 1;
|
|
98
|
+
}
|
|
99
|
+
if (t > 1) {
|
|
100
|
+
t -= 1;
|
|
101
|
+
}
|
|
102
|
+
if (t < 1 / 6) {
|
|
103
|
+
return p + (q - p) * (6 * t);
|
|
104
|
+
}
|
|
105
|
+
if (t < 1 / 2) {
|
|
106
|
+
return q;
|
|
107
|
+
}
|
|
108
|
+
if (t < 2 / 3) {
|
|
109
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
110
|
+
}
|
|
111
|
+
return p;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Converts an HSL color value to RGB.
|
|
115
|
+
*
|
|
116
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
117
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
118
|
+
*/
|
|
119
|
+
function hslToRgb(h, s, l) {
|
|
120
|
+
var r;
|
|
121
|
+
var g;
|
|
122
|
+
var b;
|
|
123
|
+
h = bound01(h, 360);
|
|
124
|
+
s = bound01(s, 100);
|
|
125
|
+
l = bound01(l, 100);
|
|
126
|
+
if (s === 0) {
|
|
127
|
+
// achromatic
|
|
128
|
+
g = l;
|
|
129
|
+
b = l;
|
|
130
|
+
r = l;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
134
|
+
var p = 2 * l - q;
|
|
135
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
136
|
+
g = hue2rgb(p, q, h);
|
|
137
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
138
|
+
}
|
|
139
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Converts an RGB color value to HSV
|
|
143
|
+
*
|
|
144
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
145
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
146
|
+
*/
|
|
147
|
+
function rgbToHsv(r, g, b) {
|
|
148
|
+
r = bound01(r, 255);
|
|
149
|
+
g = bound01(g, 255);
|
|
150
|
+
b = bound01(b, 255);
|
|
151
|
+
var max = Math.max(r, g, b);
|
|
152
|
+
var min = Math.min(r, g, b);
|
|
153
|
+
var h = 0;
|
|
154
|
+
var v = max;
|
|
155
|
+
var d = max - min;
|
|
156
|
+
var s = max === 0 ? 0 : d / max;
|
|
157
|
+
if (max === min) {
|
|
158
|
+
h = 0; // achromatic
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
switch (max) {
|
|
162
|
+
case r:
|
|
163
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
164
|
+
break;
|
|
165
|
+
case g:
|
|
166
|
+
h = (b - r) / d + 2;
|
|
167
|
+
break;
|
|
168
|
+
case b:
|
|
169
|
+
h = (r - g) / d + 4;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
h /= 6;
|
|
173
|
+
}
|
|
174
|
+
return { h: h, s: s, v: v };
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Converts an HSV color value to RGB.
|
|
178
|
+
*
|
|
179
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
180
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
181
|
+
*/
|
|
182
|
+
function hsvToRgb(h, s, v) {
|
|
183
|
+
h = bound01(h, 360) * 6;
|
|
184
|
+
s = bound01(s, 100);
|
|
185
|
+
v = bound01(v, 100);
|
|
186
|
+
var i = Math.floor(h);
|
|
187
|
+
var f = h - i;
|
|
188
|
+
var p = v * (1 - s);
|
|
189
|
+
var q = v * (1 - f * s);
|
|
190
|
+
var t = v * (1 - (1 - f) * s);
|
|
191
|
+
var mod = i % 6;
|
|
192
|
+
var r = [v, q, p, p, t, v][mod];
|
|
193
|
+
var g = [t, v, v, q, p, p][mod];
|
|
194
|
+
var b = [p, p, t, v, v, q][mod];
|
|
195
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Converts an RGB color to hex
|
|
199
|
+
*
|
|
200
|
+
* Assumes r, g, and b are contained in the set [0, 255]
|
|
201
|
+
* Returns a 3 or 6 character hex
|
|
202
|
+
*/
|
|
203
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
204
|
+
var hex = [
|
|
205
|
+
pad2(Math.round(r).toString(16)),
|
|
206
|
+
pad2(Math.round(g).toString(16)),
|
|
207
|
+
pad2(Math.round(b).toString(16)),
|
|
208
|
+
];
|
|
209
|
+
// Return a 3 character hex if possible
|
|
210
|
+
if (allow3Char &&
|
|
211
|
+
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
212
|
+
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
213
|
+
hex[2].startsWith(hex[2].charAt(1))) {
|
|
214
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
215
|
+
}
|
|
216
|
+
return hex.join('');
|
|
217
|
+
}
|
|
218
|
+
/** Converts a hex value to a decimal */
|
|
219
|
+
function convertHexToDecimal(h) {
|
|
220
|
+
return parseIntFromHex(h) / 255;
|
|
221
|
+
}
|
|
222
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
223
|
+
function parseIntFromHex(val) {
|
|
224
|
+
return parseInt(val, 16);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
|
|
228
|
+
/**
|
|
229
|
+
* @hidden
|
|
230
|
+
*/
|
|
231
|
+
var names = {
|
|
232
|
+
aliceblue: '#f0f8ff',
|
|
233
|
+
antiquewhite: '#faebd7',
|
|
234
|
+
aqua: '#00ffff',
|
|
235
|
+
aquamarine: '#7fffd4',
|
|
236
|
+
azure: '#f0ffff',
|
|
237
|
+
beige: '#f5f5dc',
|
|
238
|
+
bisque: '#ffe4c4',
|
|
239
|
+
black: '#000000',
|
|
240
|
+
blanchedalmond: '#ffebcd',
|
|
241
|
+
blue: '#0000ff',
|
|
242
|
+
blueviolet: '#8a2be2',
|
|
243
|
+
brown: '#a52a2a',
|
|
244
|
+
burlywood: '#deb887',
|
|
245
|
+
cadetblue: '#5f9ea0',
|
|
246
|
+
chartreuse: '#7fff00',
|
|
247
|
+
chocolate: '#d2691e',
|
|
248
|
+
coral: '#ff7f50',
|
|
249
|
+
cornflowerblue: '#6495ed',
|
|
250
|
+
cornsilk: '#fff8dc',
|
|
251
|
+
crimson: '#dc143c',
|
|
252
|
+
cyan: '#00ffff',
|
|
253
|
+
darkblue: '#00008b',
|
|
254
|
+
darkcyan: '#008b8b',
|
|
255
|
+
darkgoldenrod: '#b8860b',
|
|
256
|
+
darkgray: '#a9a9a9',
|
|
257
|
+
darkgreen: '#006400',
|
|
258
|
+
darkgrey: '#a9a9a9',
|
|
259
|
+
darkkhaki: '#bdb76b',
|
|
260
|
+
darkmagenta: '#8b008b',
|
|
261
|
+
darkolivegreen: '#556b2f',
|
|
262
|
+
darkorange: '#ff8c00',
|
|
263
|
+
darkorchid: '#9932cc',
|
|
264
|
+
darkred: '#8b0000',
|
|
265
|
+
darksalmon: '#e9967a',
|
|
266
|
+
darkseagreen: '#8fbc8f',
|
|
267
|
+
darkslateblue: '#483d8b',
|
|
268
|
+
darkslategray: '#2f4f4f',
|
|
269
|
+
darkslategrey: '#2f4f4f',
|
|
270
|
+
darkturquoise: '#00ced1',
|
|
271
|
+
darkviolet: '#9400d3',
|
|
272
|
+
deeppink: '#ff1493',
|
|
273
|
+
deepskyblue: '#00bfff',
|
|
274
|
+
dimgray: '#696969',
|
|
275
|
+
dimgrey: '#696969',
|
|
276
|
+
dodgerblue: '#1e90ff',
|
|
277
|
+
firebrick: '#b22222',
|
|
278
|
+
floralwhite: '#fffaf0',
|
|
279
|
+
forestgreen: '#228b22',
|
|
280
|
+
fuchsia: '#ff00ff',
|
|
281
|
+
gainsboro: '#dcdcdc',
|
|
282
|
+
ghostwhite: '#f8f8ff',
|
|
283
|
+
goldenrod: '#daa520',
|
|
284
|
+
gold: '#ffd700',
|
|
285
|
+
gray: '#808080',
|
|
286
|
+
green: '#008000',
|
|
287
|
+
greenyellow: '#adff2f',
|
|
288
|
+
grey: '#808080',
|
|
289
|
+
honeydew: '#f0fff0',
|
|
290
|
+
hotpink: '#ff69b4',
|
|
291
|
+
indianred: '#cd5c5c',
|
|
292
|
+
indigo: '#4b0082',
|
|
293
|
+
ivory: '#fffff0',
|
|
294
|
+
khaki: '#f0e68c',
|
|
295
|
+
lavenderblush: '#fff0f5',
|
|
296
|
+
lavender: '#e6e6fa',
|
|
297
|
+
lawngreen: '#7cfc00',
|
|
298
|
+
lemonchiffon: '#fffacd',
|
|
299
|
+
lightblue: '#add8e6',
|
|
300
|
+
lightcoral: '#f08080',
|
|
301
|
+
lightcyan: '#e0ffff',
|
|
302
|
+
lightgoldenrodyellow: '#fafad2',
|
|
303
|
+
lightgray: '#d3d3d3',
|
|
304
|
+
lightgreen: '#90ee90',
|
|
305
|
+
lightgrey: '#d3d3d3',
|
|
306
|
+
lightpink: '#ffb6c1',
|
|
307
|
+
lightsalmon: '#ffa07a',
|
|
308
|
+
lightseagreen: '#20b2aa',
|
|
309
|
+
lightskyblue: '#87cefa',
|
|
310
|
+
lightslategray: '#778899',
|
|
311
|
+
lightslategrey: '#778899',
|
|
312
|
+
lightsteelblue: '#b0c4de',
|
|
313
|
+
lightyellow: '#ffffe0',
|
|
314
|
+
lime: '#00ff00',
|
|
315
|
+
limegreen: '#32cd32',
|
|
316
|
+
linen: '#faf0e6',
|
|
317
|
+
magenta: '#ff00ff',
|
|
318
|
+
maroon: '#800000',
|
|
319
|
+
mediumaquamarine: '#66cdaa',
|
|
320
|
+
mediumblue: '#0000cd',
|
|
321
|
+
mediumorchid: '#ba55d3',
|
|
322
|
+
mediumpurple: '#9370db',
|
|
323
|
+
mediumseagreen: '#3cb371',
|
|
324
|
+
mediumslateblue: '#7b68ee',
|
|
325
|
+
mediumspringgreen: '#00fa9a',
|
|
326
|
+
mediumturquoise: '#48d1cc',
|
|
327
|
+
mediumvioletred: '#c71585',
|
|
328
|
+
midnightblue: '#191970',
|
|
329
|
+
mintcream: '#f5fffa',
|
|
330
|
+
mistyrose: '#ffe4e1',
|
|
331
|
+
moccasin: '#ffe4b5',
|
|
332
|
+
navajowhite: '#ffdead',
|
|
333
|
+
navy: '#000080',
|
|
334
|
+
oldlace: '#fdf5e6',
|
|
335
|
+
olive: '#808000',
|
|
336
|
+
olivedrab: '#6b8e23',
|
|
337
|
+
orange: '#ffa500',
|
|
338
|
+
orangered: '#ff4500',
|
|
339
|
+
orchid: '#da70d6',
|
|
340
|
+
palegoldenrod: '#eee8aa',
|
|
341
|
+
palegreen: '#98fb98',
|
|
342
|
+
paleturquoise: '#afeeee',
|
|
343
|
+
palevioletred: '#db7093',
|
|
344
|
+
papayawhip: '#ffefd5',
|
|
345
|
+
peachpuff: '#ffdab9',
|
|
346
|
+
peru: '#cd853f',
|
|
347
|
+
pink: '#ffc0cb',
|
|
348
|
+
plum: '#dda0dd',
|
|
349
|
+
powderblue: '#b0e0e6',
|
|
350
|
+
purple: '#800080',
|
|
351
|
+
rebeccapurple: '#663399',
|
|
352
|
+
red: '#ff0000',
|
|
353
|
+
rosybrown: '#bc8f8f',
|
|
354
|
+
royalblue: '#4169e1',
|
|
355
|
+
saddlebrown: '#8b4513',
|
|
356
|
+
salmon: '#fa8072',
|
|
357
|
+
sandybrown: '#f4a460',
|
|
358
|
+
seagreen: '#2e8b57',
|
|
359
|
+
seashell: '#fff5ee',
|
|
360
|
+
sienna: '#a0522d',
|
|
361
|
+
silver: '#c0c0c0',
|
|
362
|
+
skyblue: '#87ceeb',
|
|
363
|
+
slateblue: '#6a5acd',
|
|
364
|
+
slategray: '#708090',
|
|
365
|
+
slategrey: '#708090',
|
|
366
|
+
snow: '#fffafa',
|
|
367
|
+
springgreen: '#00ff7f',
|
|
368
|
+
steelblue: '#4682b4',
|
|
369
|
+
tan: '#d2b48c',
|
|
370
|
+
teal: '#008080',
|
|
371
|
+
thistle: '#d8bfd8',
|
|
372
|
+
tomato: '#ff6347',
|
|
373
|
+
turquoise: '#40e0d0',
|
|
374
|
+
violet: '#ee82ee',
|
|
375
|
+
wheat: '#f5deb3',
|
|
376
|
+
white: '#ffffff',
|
|
377
|
+
whitesmoke: '#f5f5f5',
|
|
378
|
+
yellow: '#ffff00',
|
|
379
|
+
yellowgreen: '#9acd32',
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Given a string or object, convert that input to RGB
|
|
384
|
+
*
|
|
385
|
+
* Possible string inputs:
|
|
386
|
+
* ```
|
|
387
|
+
* "red"
|
|
388
|
+
* "#f00" or "f00"
|
|
389
|
+
* "#ff0000" or "ff0000"
|
|
390
|
+
* "#ff000000" or "ff000000"
|
|
391
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
392
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
393
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
394
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
395
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
396
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
397
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
function inputToRGB(color) {
|
|
401
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
|
402
|
+
var a = 1;
|
|
403
|
+
var s = null;
|
|
404
|
+
var v = null;
|
|
405
|
+
var l = null;
|
|
406
|
+
var ok = false;
|
|
407
|
+
var format = false;
|
|
408
|
+
if (typeof color === 'string') {
|
|
409
|
+
color = stringInputToObject(color);
|
|
410
|
+
}
|
|
411
|
+
if (typeof color === 'object') {
|
|
412
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
413
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
414
|
+
ok = true;
|
|
415
|
+
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
|
|
416
|
+
}
|
|
417
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
418
|
+
s = convertToPercentage(color.s);
|
|
419
|
+
v = convertToPercentage(color.v);
|
|
420
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
421
|
+
ok = true;
|
|
422
|
+
format = 'hsv';
|
|
423
|
+
}
|
|
424
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
425
|
+
s = convertToPercentage(color.s);
|
|
426
|
+
l = convertToPercentage(color.l);
|
|
427
|
+
rgb = hslToRgb(color.h, s, l);
|
|
428
|
+
ok = true;
|
|
429
|
+
format = 'hsl';
|
|
430
|
+
}
|
|
431
|
+
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
|
|
432
|
+
a = color.a;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
a = boundAlpha(a);
|
|
436
|
+
return {
|
|
437
|
+
ok: ok,
|
|
438
|
+
format: color.format || format,
|
|
439
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
440
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
441
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
442
|
+
a: a,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
// <http://www.w3.org/TR/css3-values/#integers>
|
|
446
|
+
var CSS_INTEGER = '[-\\+]?\\d+%?';
|
|
447
|
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
448
|
+
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
|
449
|
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
450
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
451
|
+
// Actual matching.
|
|
452
|
+
// Parentheses and commas are optional, but not required.
|
|
453
|
+
// Whitespace can take the place of commas or opening paren
|
|
454
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
455
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
456
|
+
var matchers = {
|
|
457
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
458
|
+
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
|
|
459
|
+
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
|
|
460
|
+
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
|
|
461
|
+
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
|
|
462
|
+
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
|
|
463
|
+
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
|
|
464
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
465
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
466
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
467
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
471
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
472
|
+
*/
|
|
473
|
+
function stringInputToObject(color) {
|
|
474
|
+
color = color.trim().toLowerCase();
|
|
475
|
+
if (color.length === 0) {
|
|
476
|
+
return false;
|
|
477
|
+
}
|
|
478
|
+
var named = false;
|
|
479
|
+
if (names[color]) {
|
|
480
|
+
color = names[color];
|
|
481
|
+
named = true;
|
|
482
|
+
}
|
|
483
|
+
else if (color === 'transparent') {
|
|
484
|
+
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
|
|
485
|
+
}
|
|
486
|
+
// Try to match string input using regular expressions.
|
|
487
|
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
488
|
+
// Just return an object and let the conversion functions handle that.
|
|
489
|
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
490
|
+
var match = matchers.rgb.exec(color);
|
|
491
|
+
if (match) {
|
|
492
|
+
return { r: match[1], g: match[2], b: match[3] };
|
|
493
|
+
}
|
|
494
|
+
match = matchers.rgba.exec(color);
|
|
495
|
+
if (match) {
|
|
496
|
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
497
|
+
}
|
|
498
|
+
match = matchers.hsl.exec(color);
|
|
499
|
+
if (match) {
|
|
500
|
+
return { h: match[1], s: match[2], l: match[3] };
|
|
501
|
+
}
|
|
502
|
+
match = matchers.hsla.exec(color);
|
|
503
|
+
if (match) {
|
|
504
|
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
505
|
+
}
|
|
506
|
+
match = matchers.hsv.exec(color);
|
|
507
|
+
if (match) {
|
|
508
|
+
return { h: match[1], s: match[2], v: match[3] };
|
|
509
|
+
}
|
|
510
|
+
match = matchers.hsva.exec(color);
|
|
511
|
+
if (match) {
|
|
512
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
513
|
+
}
|
|
514
|
+
match = matchers.hex8.exec(color);
|
|
515
|
+
if (match) {
|
|
516
|
+
return {
|
|
517
|
+
r: parseIntFromHex(match[1]),
|
|
518
|
+
g: parseIntFromHex(match[2]),
|
|
519
|
+
b: parseIntFromHex(match[3]),
|
|
520
|
+
a: convertHexToDecimal(match[4]),
|
|
521
|
+
format: named ? 'name' : 'hex8',
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
match = matchers.hex6.exec(color);
|
|
525
|
+
if (match) {
|
|
526
|
+
return {
|
|
527
|
+
r: parseIntFromHex(match[1]),
|
|
528
|
+
g: parseIntFromHex(match[2]),
|
|
529
|
+
b: parseIntFromHex(match[3]),
|
|
530
|
+
format: named ? 'name' : 'hex',
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
match = matchers.hex4.exec(color);
|
|
534
|
+
if (match) {
|
|
535
|
+
return {
|
|
536
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
537
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
538
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
539
|
+
a: convertHexToDecimal(match[4] + match[4]),
|
|
540
|
+
format: named ? 'name' : 'hex8',
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
match = matchers.hex3.exec(color);
|
|
544
|
+
if (match) {
|
|
545
|
+
return {
|
|
546
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
547
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
548
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
549
|
+
format: named ? 'name' : 'hex',
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Check to see if it looks like a CSS unit
|
|
556
|
+
* (see `matchers` above for definition).
|
|
557
|
+
*/
|
|
558
|
+
function isValidCSSUnit(color) {
|
|
559
|
+
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
var hueStep = 2; // 色相阶梯
|
|
563
|
+
|
|
564
|
+
var saturationStep = 0.16; // 饱和度阶梯,浅色部分
|
|
565
|
+
|
|
566
|
+
var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
|
|
567
|
+
|
|
568
|
+
var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
|
|
569
|
+
|
|
570
|
+
var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
|
|
571
|
+
|
|
572
|
+
var lightColorCount = 5; // 浅色数量,主色上
|
|
573
|
+
|
|
574
|
+
var darkColorCount = 4; // 深色数量,主色下
|
|
575
|
+
// 暗色主题颜色映射关系表
|
|
576
|
+
|
|
577
|
+
var darkColorMap = [{
|
|
578
|
+
index: 7,
|
|
579
|
+
opacity: 0.15
|
|
580
|
+
}, {
|
|
581
|
+
index: 6,
|
|
582
|
+
opacity: 0.25
|
|
583
|
+
}, {
|
|
584
|
+
index: 5,
|
|
585
|
+
opacity: 0.3
|
|
586
|
+
}, {
|
|
587
|
+
index: 5,
|
|
588
|
+
opacity: 0.45
|
|
589
|
+
}, {
|
|
590
|
+
index: 5,
|
|
591
|
+
opacity: 0.65
|
|
592
|
+
}, {
|
|
593
|
+
index: 5,
|
|
594
|
+
opacity: 0.85
|
|
595
|
+
}, {
|
|
596
|
+
index: 4,
|
|
597
|
+
opacity: 0.9
|
|
598
|
+
}, {
|
|
599
|
+
index: 3,
|
|
600
|
+
opacity: 0.95
|
|
601
|
+
}, {
|
|
602
|
+
index: 2,
|
|
603
|
+
opacity: 0.97
|
|
604
|
+
}, {
|
|
605
|
+
index: 1,
|
|
606
|
+
opacity: 0.98
|
|
607
|
+
}]; // Wrapper function ported from TinyColor.prototype.toHsv
|
|
608
|
+
// Keep it here because of `hsv.h * 360`
|
|
609
|
+
|
|
610
|
+
function toHsv(_ref) {
|
|
611
|
+
var r = _ref.r,
|
|
612
|
+
g = _ref.g,
|
|
613
|
+
b = _ref.b;
|
|
614
|
+
var hsv = rgbToHsv(r, g, b);
|
|
615
|
+
return {
|
|
616
|
+
h: hsv.h * 360,
|
|
617
|
+
s: hsv.s,
|
|
618
|
+
v: hsv.v
|
|
619
|
+
};
|
|
620
|
+
} // Wrapper function ported from TinyColor.prototype.toHexString
|
|
621
|
+
// Keep it here because of the prefix `#`
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
function toHex(_ref2) {
|
|
625
|
+
var r = _ref2.r,
|
|
626
|
+
g = _ref2.g,
|
|
627
|
+
b = _ref2.b;
|
|
628
|
+
return "#".concat(rgbToHex(r, g, b, false));
|
|
629
|
+
} // Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
|
|
630
|
+
// Amount in range [0, 1]
|
|
631
|
+
// Assume color1 & color2 has no alpha, since the following src code did so.
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
function mix(rgb1, rgb2, amount) {
|
|
635
|
+
var p = amount / 100;
|
|
636
|
+
var rgb = {
|
|
637
|
+
r: (rgb2.r - rgb1.r) * p + rgb1.r,
|
|
638
|
+
g: (rgb2.g - rgb1.g) * p + rgb1.g,
|
|
639
|
+
b: (rgb2.b - rgb1.b) * p + rgb1.b
|
|
640
|
+
};
|
|
641
|
+
return rgb;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function getHue(hsv, i, light) {
|
|
645
|
+
var hue; // 根据色相不同,色相转向不同
|
|
646
|
+
|
|
647
|
+
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
|
|
648
|
+
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
|
|
649
|
+
} else {
|
|
650
|
+
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (hue < 0) {
|
|
654
|
+
hue += 360;
|
|
655
|
+
} else if (hue >= 360) {
|
|
656
|
+
hue -= 360;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
return hue;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
function getSaturation(hsv, i, light) {
|
|
663
|
+
// grey color don't change saturation
|
|
664
|
+
if (hsv.h === 0 && hsv.s === 0) {
|
|
665
|
+
return hsv.s;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
var saturation;
|
|
669
|
+
|
|
670
|
+
if (light) {
|
|
671
|
+
saturation = hsv.s - saturationStep * i;
|
|
672
|
+
} else if (i === darkColorCount) {
|
|
673
|
+
saturation = hsv.s + saturationStep;
|
|
674
|
+
} else {
|
|
675
|
+
saturation = hsv.s + saturationStep2 * i;
|
|
676
|
+
} // 边界值修正
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
if (saturation > 1) {
|
|
680
|
+
saturation = 1;
|
|
681
|
+
} // 第一格的 s 限制在 0.06-0.1 之间
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
if (light && i === lightColorCount && saturation > 0.1) {
|
|
685
|
+
saturation = 0.1;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if (saturation < 0.06) {
|
|
689
|
+
saturation = 0.06;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
return Number(saturation.toFixed(2));
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function getValue(hsv, i, light) {
|
|
696
|
+
var value;
|
|
697
|
+
|
|
698
|
+
if (light) {
|
|
699
|
+
value = hsv.v + brightnessStep1 * i;
|
|
700
|
+
} else {
|
|
701
|
+
value = hsv.v - brightnessStep2 * i;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (value > 1) {
|
|
705
|
+
value = 1;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return Number(value.toFixed(2));
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function generate$1(color) {
|
|
712
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
713
|
+
var patterns = [];
|
|
714
|
+
var pColor = inputToRGB(color);
|
|
715
|
+
|
|
716
|
+
for (var i = lightColorCount; i > 0; i -= 1) {
|
|
717
|
+
var hsv = toHsv(pColor);
|
|
718
|
+
var colorString = toHex(inputToRGB({
|
|
719
|
+
h: getHue(hsv, i, true),
|
|
720
|
+
s: getSaturation(hsv, i, true),
|
|
721
|
+
v: getValue(hsv, i, true)
|
|
722
|
+
}));
|
|
723
|
+
patterns.push(colorString);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
patterns.push(toHex(pColor));
|
|
727
|
+
|
|
728
|
+
for (var _i = 1; _i <= darkColorCount; _i += 1) {
|
|
729
|
+
var _hsv = toHsv(pColor);
|
|
730
|
+
|
|
731
|
+
var _colorString = toHex(inputToRGB({
|
|
732
|
+
h: getHue(_hsv, _i),
|
|
733
|
+
s: getSaturation(_hsv, _i),
|
|
734
|
+
v: getValue(_hsv, _i)
|
|
735
|
+
}));
|
|
736
|
+
|
|
737
|
+
patterns.push(_colorString);
|
|
738
|
+
} // dark theme patterns
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
if (opts.theme === 'dark') {
|
|
742
|
+
return darkColorMap.map(function (_ref3) {
|
|
743
|
+
var index = _ref3.index,
|
|
744
|
+
opacity = _ref3.opacity;
|
|
745
|
+
var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100));
|
|
746
|
+
return darkColorString;
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
return patterns;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
var presetPrimaryColors = {
|
|
754
|
+
red: '#F5222D',
|
|
755
|
+
volcano: '#FA541C',
|
|
756
|
+
orange: '#FA8C16',
|
|
757
|
+
gold: '#FAAD14',
|
|
758
|
+
yellow: '#FADB14',
|
|
759
|
+
lime: '#A0D911',
|
|
760
|
+
green: '#52C41A',
|
|
761
|
+
cyan: '#13C2C2',
|
|
762
|
+
blue: '#1890FF',
|
|
763
|
+
geekblue: '#2F54EB',
|
|
764
|
+
purple: '#722ED1',
|
|
765
|
+
magenta: '#EB2F96',
|
|
766
|
+
grey: '#666666'
|
|
767
|
+
};
|
|
768
|
+
var presetPalettes = {};
|
|
769
|
+
var presetDarkPalettes = {};
|
|
770
|
+
Object.keys(presetPrimaryColors).forEach(function (key) {
|
|
771
|
+
presetPalettes[key] = generate$1(presetPrimaryColors[key]);
|
|
772
|
+
presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes
|
|
773
|
+
|
|
774
|
+
presetDarkPalettes[key] = generate$1(presetPrimaryColors[key], {
|
|
775
|
+
theme: 'dark',
|
|
776
|
+
backgroundColor: '#141414'
|
|
777
|
+
});
|
|
778
|
+
presetDarkPalettes[key].primary = presetDarkPalettes[key][5];
|
|
779
|
+
});
|
|
780
|
+
presetPalettes.red;
|
|
781
|
+
presetPalettes.volcano;
|
|
782
|
+
presetPalettes.gold;
|
|
783
|
+
presetPalettes.orange;
|
|
784
|
+
presetPalettes.yellow;
|
|
785
|
+
presetPalettes.lime;
|
|
786
|
+
presetPalettes.green;
|
|
787
|
+
presetPalettes.cyan;
|
|
788
|
+
presetPalettes.blue;
|
|
789
|
+
presetPalettes.geekblue;
|
|
790
|
+
presetPalettes.purple;
|
|
791
|
+
presetPalettes.magenta;
|
|
792
|
+
presetPalettes.grey;
|
|
793
|
+
|
|
794
|
+
// https://github.com/substack/insert-css
|
|
795
|
+
var containers = []; // will store container HTMLElement references
|
|
796
|
+
|
|
797
|
+
var styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement}
|
|
798
|
+
|
|
799
|
+
var usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).';
|
|
800
|
+
|
|
801
|
+
function createStyleElement() {
|
|
802
|
+
var styleElement = document.createElement('style');
|
|
803
|
+
styleElement.setAttribute('type', 'text/css');
|
|
804
|
+
return styleElement;
|
|
805
|
+
} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
function insertCss(css, options) {
|
|
809
|
+
options = options || {};
|
|
810
|
+
|
|
811
|
+
if (css === undefined) {
|
|
812
|
+
throw new Error(usage);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
var position = options.prepend === true ? 'prepend' : 'append';
|
|
816
|
+
var container = options.container !== undefined ? options.container : document.querySelector('head');
|
|
817
|
+
var containerId = containers.indexOf(container); // first time we see this container, create the necessary entries
|
|
818
|
+
|
|
819
|
+
if (containerId === -1) {
|
|
820
|
+
containerId = containers.push(container) - 1;
|
|
821
|
+
styleElements[containerId] = {};
|
|
822
|
+
} // try to get the correponding container + position styleElement, create it otherwise
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
var styleElement;
|
|
826
|
+
|
|
827
|
+
if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) {
|
|
828
|
+
styleElement = styleElements[containerId][position];
|
|
829
|
+
} else {
|
|
830
|
+
styleElement = styleElements[containerId][position] = createStyleElement();
|
|
831
|
+
|
|
832
|
+
if (position === 'prepend') {
|
|
833
|
+
container.insertBefore(styleElement, container.childNodes[0]);
|
|
834
|
+
} else {
|
|
835
|
+
container.appendChild(styleElement);
|
|
836
|
+
}
|
|
837
|
+
} // strip potential UTF-8 BOM if css was read from a file
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
if (css.charCodeAt(0) === 0xfeff) {
|
|
841
|
+
css = css.substr(1, css.length);
|
|
842
|
+
} // actually add the stylesheet
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
if (styleElement.styleSheet) {
|
|
846
|
+
styleElement.styleSheet.cssText += css;
|
|
847
|
+
} else {
|
|
848
|
+
styleElement.textContent += css;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
return styleElement;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$4(target, key, source[key]); }); } return target; }
|
|
855
|
+
|
|
856
|
+
function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
857
|
+
function warn(valid, message) {
|
|
858
|
+
// Support uglify
|
|
859
|
+
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
860
|
+
console.error("Warning: ".concat(message));
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
function warning(valid, message) {
|
|
864
|
+
warn(valid, "[@ant-design/icons-vue] ".concat(message));
|
|
865
|
+
} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
866
|
+
|
|
867
|
+
function isIconDefinition(target) {
|
|
868
|
+
return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
|
|
869
|
+
}
|
|
870
|
+
function generate(node, key, rootProps) {
|
|
871
|
+
if (!rootProps) {
|
|
872
|
+
return h(node.tag, _objectSpread$4({
|
|
873
|
+
key: key
|
|
874
|
+
}, node.attrs), (node.children || []).map(function (child, index) {
|
|
875
|
+
return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
|
|
876
|
+
}));
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
return h(node.tag, _objectSpread$4({
|
|
880
|
+
key: key
|
|
881
|
+
}, rootProps, node.attrs), (node.children || []).map(function (child, index) {
|
|
882
|
+
return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
|
|
883
|
+
}));
|
|
884
|
+
}
|
|
885
|
+
function getSecondaryColor(primaryColor) {
|
|
886
|
+
// choose the second color
|
|
887
|
+
return generate$1(primaryColor)[0];
|
|
888
|
+
}
|
|
889
|
+
function normalizeTwoToneColors(twoToneColor) {
|
|
890
|
+
if (!twoToneColor) {
|
|
891
|
+
return [];
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];
|
|
895
|
+
} // These props make sure that the SVG behaviours like general text.
|
|
896
|
+
var iconStyles = "\n.anticon {\n display: inline-block;\n color: inherit;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -0.125em;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\n.anticon > * {\n line-height: 1;\n}\n\n.anticon svg {\n display: inline-block;\n}\n\n.anticon::before {\n display: none;\n}\n\n.anticon .anticon-icon {\n display: block;\n}\n\n.anticon[tabindex] {\n cursor: pointer;\n}\n\n.anticon-spin::before,\n.anticon-spin {\n display: inline-block;\n -webkit-animation: loadingCircle 1s infinite linear;\n animation: loadingCircle 1s infinite linear;\n}\n\n@-webkit-keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n\n@keyframes loadingCircle {\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n";
|
|
897
|
+
var cssInjectedFlag = false;
|
|
898
|
+
var useInsertStyles = function useInsertStyles() {
|
|
899
|
+
var styleStr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : iconStyles;
|
|
900
|
+
nextTick(function () {
|
|
901
|
+
if (!cssInjectedFlag) {
|
|
902
|
+
if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
|
|
903
|
+
insertCss(styleStr, {
|
|
904
|
+
prepend: true
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
cssInjectedFlag = true;
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
var _excluded$1 = ["icon", "primaryColor", "secondaryColor"];
|
|
914
|
+
|
|
915
|
+
function _objectWithoutProperties$1(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$1(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
916
|
+
|
|
917
|
+
function _objectWithoutPropertiesLoose$1(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
918
|
+
|
|
919
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$3(target, key, source[key]); }); } return target; }
|
|
920
|
+
|
|
921
|
+
function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
922
|
+
var twoToneColorPalette = {
|
|
923
|
+
primaryColor: '#333',
|
|
924
|
+
secondaryColor: '#E6E6E6',
|
|
925
|
+
calculated: false
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
function setTwoToneColors(_ref) {
|
|
929
|
+
var primaryColor = _ref.primaryColor,
|
|
930
|
+
secondaryColor = _ref.secondaryColor;
|
|
931
|
+
twoToneColorPalette.primaryColor = primaryColor;
|
|
932
|
+
twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor);
|
|
933
|
+
twoToneColorPalette.calculated = !!secondaryColor;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
function getTwoToneColors() {
|
|
937
|
+
return _objectSpread$3({}, twoToneColorPalette);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
var IconBase = function IconBase(props, context) {
|
|
941
|
+
var _props$context$attrs = _objectSpread$3({}, props, context.attrs),
|
|
942
|
+
icon = _props$context$attrs.icon,
|
|
943
|
+
primaryColor = _props$context$attrs.primaryColor,
|
|
944
|
+
secondaryColor = _props$context$attrs.secondaryColor,
|
|
945
|
+
restProps = _objectWithoutProperties$1(_props$context$attrs, _excluded$1);
|
|
946
|
+
|
|
947
|
+
var colors = twoToneColorPalette;
|
|
948
|
+
|
|
949
|
+
if (primaryColor) {
|
|
950
|
+
colors = {
|
|
951
|
+
primaryColor: primaryColor,
|
|
952
|
+
secondaryColor: secondaryColor || getSecondaryColor(primaryColor)
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
useInsertStyles();
|
|
957
|
+
warning(isIconDefinition(icon), "icon should be icon definiton, but got ".concat(icon));
|
|
958
|
+
|
|
959
|
+
if (!isIconDefinition(icon)) {
|
|
960
|
+
return null;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
var target = icon;
|
|
964
|
+
|
|
965
|
+
if (target && typeof target.icon === 'function') {
|
|
966
|
+
target = _objectSpread$3({}, target, {
|
|
967
|
+
icon: target.icon(colors.primaryColor, colors.secondaryColor)
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
return generate(target.icon, "svg-".concat(target.name), _objectSpread$3({}, restProps, {
|
|
972
|
+
'data-icon': target.name,
|
|
973
|
+
width: '1em',
|
|
974
|
+
height: '1em',
|
|
975
|
+
fill: 'currentColor',
|
|
976
|
+
'aria-hidden': 'true'
|
|
977
|
+
})); // },
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
IconBase.props = {
|
|
981
|
+
icon: Object,
|
|
982
|
+
primaryColor: String,
|
|
983
|
+
secondaryColor: String,
|
|
984
|
+
focusable: String
|
|
985
|
+
};
|
|
986
|
+
IconBase.inheritAttrs = false;
|
|
987
|
+
IconBase.displayName = 'IconBase';
|
|
988
|
+
IconBase.getTwoToneColors = getTwoToneColors;
|
|
989
|
+
IconBase.setTwoToneColors = setTwoToneColors;
|
|
990
|
+
var VueIcon = IconBase;
|
|
991
|
+
|
|
992
|
+
function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1(); }
|
|
993
|
+
|
|
994
|
+
function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
995
|
+
|
|
996
|
+
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
997
|
+
|
|
998
|
+
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
999
|
+
|
|
1000
|
+
function _iterableToArrayLimit$1(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
1001
|
+
|
|
1002
|
+
function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
|
|
1003
|
+
function setTwoToneColor(twoToneColor) {
|
|
1004
|
+
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
|
|
1005
|
+
_normalizeTwoToneColo2 = _slicedToArray$1(_normalizeTwoToneColo, 2),
|
|
1006
|
+
primaryColor = _normalizeTwoToneColo2[0],
|
|
1007
|
+
secondaryColor = _normalizeTwoToneColo2[1];
|
|
1008
|
+
|
|
1009
|
+
return VueIcon.setTwoToneColors({
|
|
1010
|
+
primaryColor: primaryColor,
|
|
1011
|
+
secondaryColor: secondaryColor
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
function getTwoToneColor() {
|
|
1015
|
+
var colors = VueIcon.getTwoToneColors();
|
|
1016
|
+
|
|
1017
|
+
if (!colors.calculated) {
|
|
1018
|
+
return colors.primaryColor;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
return [colors.primaryColor, colors.secondaryColor];
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
var _excluded = ["class", "icon", "spin", "rotate", "tabindex", "twoToneColor", "onClick"];
|
|
1025
|
+
|
|
1026
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
1027
|
+
|
|
1028
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
1029
|
+
|
|
1030
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
1031
|
+
|
|
1032
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
1033
|
+
|
|
1034
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
1035
|
+
|
|
1036
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1037
|
+
|
|
1038
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } return target; }
|
|
1039
|
+
|
|
1040
|
+
function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1041
|
+
|
|
1042
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
1043
|
+
|
|
1044
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1045
|
+
|
|
1046
|
+
setTwoToneColor('#1890ff');
|
|
1047
|
+
|
|
1048
|
+
var Icon = function Icon(props, context) {
|
|
1049
|
+
var _classObj;
|
|
1050
|
+
|
|
1051
|
+
var _props$context$attrs = _objectSpread$2({}, props, context.attrs),
|
|
1052
|
+
cls = _props$context$attrs["class"],
|
|
1053
|
+
icon = _props$context$attrs.icon,
|
|
1054
|
+
spin = _props$context$attrs.spin,
|
|
1055
|
+
rotate = _props$context$attrs.rotate,
|
|
1056
|
+
tabindex = _props$context$attrs.tabindex,
|
|
1057
|
+
twoToneColor = _props$context$attrs.twoToneColor,
|
|
1058
|
+
onClick = _props$context$attrs.onClick,
|
|
1059
|
+
restProps = _objectWithoutProperties(_props$context$attrs, _excluded);
|
|
1060
|
+
|
|
1061
|
+
var classObj = (_classObj = {
|
|
1062
|
+
anticon: true
|
|
1063
|
+
}, _defineProperty$2(_classObj, "anticon-".concat(icon.name), Boolean(icon.name)), _defineProperty$2(_classObj, cls, cls), _classObj);
|
|
1064
|
+
var svgClassString = spin === '' || !!spin || icon.name === 'loading' ? 'anticon-spin' : '';
|
|
1065
|
+
var iconTabIndex = tabindex;
|
|
1066
|
+
|
|
1067
|
+
if (iconTabIndex === undefined && onClick) {
|
|
1068
|
+
iconTabIndex = -1;
|
|
1069
|
+
restProps.tabindex = iconTabIndex;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
var svgStyle = rotate ? {
|
|
1073
|
+
msTransform: "rotate(".concat(rotate, "deg)"),
|
|
1074
|
+
transform: "rotate(".concat(rotate, "deg)")
|
|
1075
|
+
} : undefined;
|
|
1076
|
+
|
|
1077
|
+
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
|
|
1078
|
+
_normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2),
|
|
1079
|
+
primaryColor = _normalizeTwoToneColo2[0],
|
|
1080
|
+
secondaryColor = _normalizeTwoToneColo2[1];
|
|
1081
|
+
|
|
1082
|
+
return createVNode("span", _objectSpread$2({
|
|
1083
|
+
"role": "img",
|
|
1084
|
+
"aria-label": icon.name
|
|
1085
|
+
}, restProps, {
|
|
1086
|
+
"onClick": onClick,
|
|
1087
|
+
"class": classObj
|
|
1088
|
+
}), [createVNode(VueIcon, {
|
|
1089
|
+
"class": svgClassString,
|
|
1090
|
+
"icon": icon,
|
|
1091
|
+
"primaryColor": primaryColor,
|
|
1092
|
+
"secondaryColor": secondaryColor,
|
|
1093
|
+
"style": svgStyle
|
|
1094
|
+
}, null)]);
|
|
1095
|
+
};
|
|
1096
|
+
|
|
1097
|
+
Icon.props = {
|
|
1098
|
+
spin: Boolean,
|
|
1099
|
+
rotate: Number,
|
|
1100
|
+
icon: Object,
|
|
1101
|
+
twoToneColor: String
|
|
1102
|
+
};
|
|
1103
|
+
Icon.displayName = 'AntdIcon';
|
|
1104
|
+
Icon.inheritAttrs = false;
|
|
1105
|
+
Icon.getTwoToneColor = getTwoToneColor;
|
|
1106
|
+
Icon.setTwoToneColor = setTwoToneColor;
|
|
1107
|
+
var AntdIcon = Icon;
|
|
1108
|
+
|
|
1109
|
+
// This icon file is generated automatically.
|
|
1110
|
+
var PlusOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "defs", "attrs": {}, "children": [{ "tag": "style", "attrs": {} }] }, { "tag": "path", "attrs": { "d": "M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z" } }, { "tag": "path", "attrs": { "d": "M176 474h672q8 0 8 8v60q0 8-8 8H176q-8 0-8-8v-60q0-8 8-8z" } }] }, "name": "plus", "theme": "outlined" };
|
|
1111
|
+
var PlusOutlinedSvg = PlusOutlined$2;
|
|
1112
|
+
|
|
1113
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } return target; }
|
|
1114
|
+
|
|
1115
|
+
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1116
|
+
|
|
1117
|
+
var PlusOutlined = function PlusOutlined(props, context) {
|
|
1118
|
+
var p = _objectSpread$1({}, props, context.attrs);
|
|
1119
|
+
|
|
1120
|
+
return createVNode(AntdIcon, _objectSpread$1({}, p, {
|
|
1121
|
+
"icon": PlusOutlinedSvg
|
|
1122
|
+
}), null);
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
PlusOutlined.displayName = 'PlusOutlined';
|
|
1126
|
+
PlusOutlined.inheritAttrs = false;
|
|
1127
|
+
var PlusOutlined$1 = PlusOutlined;
|
|
1128
|
+
|
|
1129
|
+
// This icon file is generated automatically.
|
|
1130
|
+
var UploadOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M400 317.7h73.9V656c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V317.7H624c6.7 0 10.4-7.7 6.3-12.9L518.3 163a8 8 0 00-12.6 0l-112 141.7c-4.1 5.3-.4 13 6.3 13zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z" } }] }, "name": "upload", "theme": "outlined" };
|
|
1131
|
+
var UploadOutlinedSvg = UploadOutlined$2;
|
|
1132
|
+
|
|
1133
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? Object(arguments[i]) : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
1134
|
+
|
|
1135
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1136
|
+
|
|
1137
|
+
var UploadOutlined = function UploadOutlined(props, context) {
|
|
1138
|
+
var p = _objectSpread({}, props, context.attrs);
|
|
1139
|
+
|
|
1140
|
+
return createVNode(AntdIcon, _objectSpread({}, p, {
|
|
1141
|
+
"icon": UploadOutlinedSvg
|
|
1142
|
+
}), null);
|
|
1143
|
+
};
|
|
1144
|
+
|
|
1145
|
+
UploadOutlined.displayName = 'UploadOutlined';
|
|
1146
|
+
UploadOutlined.inheritAttrs = false;
|
|
1147
|
+
var UploadOutlined$1 = UploadOutlined;
|
|
4
1148
|
|
|
5
1149
|
var _export_sfc = (sfc, props) => {
|
|
6
1150
|
const target = sfc.__vccOpts || sfc;
|
|
@@ -40,19 +1184,16 @@ const _sfc_main$1 = {
|
|
|
40
1184
|
isShow: false,
|
|
41
1185
|
openShow: false
|
|
42
1186
|
});
|
|
43
|
-
const observer = new IntersectionObserver(
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
threshold: 0.3
|
|
54
|
-
}
|
|
55
|
-
);
|
|
1187
|
+
const observer = new IntersectionObserver((entries) => {
|
|
1188
|
+
entries.forEach((item) => {
|
|
1189
|
+
if (item.intersectionRatio > 0.3) {
|
|
1190
|
+
observerDom();
|
|
1191
|
+
observer.disconnect();
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
}, {
|
|
1195
|
+
threshold: 0.3
|
|
1196
|
+
});
|
|
56
1197
|
function observerDom() {
|
|
57
1198
|
if (props.line === 1) {
|
|
58
1199
|
if (mySelf.value.scrollWidth > mySelf.value.clientWidth) {
|
|
@@ -68,20 +1209,16 @@ const _sfc_main$1 = {
|
|
|
68
1209
|
observer.disconnect();
|
|
69
1210
|
});
|
|
70
1211
|
let mySelf = ref();
|
|
71
|
-
watch(
|
|
72
|
-
()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
mySelf.value && observer.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
immediate: true
|
|
83
|
-
}
|
|
84
|
-
);
|
|
1212
|
+
watch(() => props.showAlways, function(showAlways) {
|
|
1213
|
+
if (showAlways)
|
|
1214
|
+
state.openShow = showAlways;
|
|
1215
|
+
mySelf.value && observer.unobserve(mySelf.value);
|
|
1216
|
+
nextTick(function() {
|
|
1217
|
+
mySelf.value && observer.observe(mySelf.value);
|
|
1218
|
+
});
|
|
1219
|
+
}, {
|
|
1220
|
+
immediate: true
|
|
1221
|
+
});
|
|
85
1222
|
const handleVisibleChange = (val) => {
|
|
86
1223
|
state.isShow = !state.openShow ? false : val;
|
|
87
1224
|
};
|
|
@@ -168,7 +1305,7 @@ var icons = {
|
|
|
168
1305
|
const CLOUND_PRE = "/cloudStorage/read";
|
|
169
1306
|
const _sfc_main = {
|
|
170
1307
|
name: "BmUpload",
|
|
171
|
-
components: { PlusOutlined, OverTooltips, UploadOutlined },
|
|
1308
|
+
components: { PlusOutlined: PlusOutlined$1, OverTooltips, UploadOutlined: UploadOutlined$1 },
|
|
172
1309
|
props: {
|
|
173
1310
|
uploadProps: {
|
|
174
1311
|
type: Object,
|
|
@@ -196,6 +1333,16 @@ const _sfc_main = {
|
|
|
196
1333
|
cloudReadUrl: {
|
|
197
1334
|
type: String,
|
|
198
1335
|
default: ""
|
|
1336
|
+
},
|
|
1337
|
+
holdProgress: {
|
|
1338
|
+
type: Number,
|
|
1339
|
+
default: 0
|
|
1340
|
+
},
|
|
1341
|
+
customErrors: {
|
|
1342
|
+
type: Object,
|
|
1343
|
+
default() {
|
|
1344
|
+
return void 0;
|
|
1345
|
+
}
|
|
199
1346
|
}
|
|
200
1347
|
},
|
|
201
1348
|
emits: [
|
|
@@ -205,23 +1352,38 @@ const _sfc_main = {
|
|
|
205
1352
|
"previewFile",
|
|
206
1353
|
"successFile",
|
|
207
1354
|
"deleteFile",
|
|
208
|
-
"error"
|
|
1355
|
+
"error",
|
|
1356
|
+
"updateDisabledStatus",
|
|
1357
|
+
"updateIsUploadingStatus"
|
|
209
1358
|
],
|
|
210
1359
|
setup(props, { emit }) {
|
|
211
1360
|
let acceptList = [
|
|
212
1361
|
".xlsx",
|
|
1362
|
+
".XLSX",
|
|
213
1363
|
".pdf",
|
|
1364
|
+
".PDF",
|
|
214
1365
|
".doc",
|
|
1366
|
+
".DOC",
|
|
215
1367
|
".docx",
|
|
1368
|
+
".DOCX",
|
|
216
1369
|
".jpg",
|
|
217
|
-
".jpeg",
|
|
218
1370
|
".JPG",
|
|
1371
|
+
".jpeg",
|
|
1372
|
+
".JPEG",
|
|
219
1373
|
".png",
|
|
1374
|
+
".PNG",
|
|
1375
|
+
".gif",
|
|
1376
|
+
".GIF",
|
|
220
1377
|
".rar",
|
|
1378
|
+
".RAR",
|
|
221
1379
|
".zip",
|
|
1380
|
+
".ZIP",
|
|
222
1381
|
".ppt",
|
|
1382
|
+
".PPT",
|
|
223
1383
|
".pptx",
|
|
224
|
-
".
|
|
1384
|
+
".PPTX",
|
|
1385
|
+
".mp4",
|
|
1386
|
+
".MP4"
|
|
225
1387
|
];
|
|
226
1388
|
const state = reactive({
|
|
227
1389
|
uploadBarColor: "#4DA0FF",
|
|
@@ -257,19 +1419,15 @@ const _sfc_main = {
|
|
|
257
1419
|
disabled: false,
|
|
258
1420
|
async customRequest({ file, fileField, data }) {
|
|
259
1421
|
if (file.size > state.extraConfigs.maxSize * 1024 * 1024) {
|
|
260
|
-
return methods.uploadError(
|
|
261
|
-
new Error(`\u4E0D\u80FD\u4E0A\u4F20\u5927\u4E8E${state.extraConfigs.maxSize}M\u7684\u6587\u4EF6`)
|
|
262
|
-
);
|
|
1422
|
+
return methods.uploadError(new Error(props.customErrors?.maxSize || `\u4E0D\u80FD\u4E0A\u4F20\u5927\u4E8E${state.extraConfigs.maxSize}M\u7684\u6587\u4EF6`));
|
|
263
1423
|
}
|
|
264
1424
|
if (Object.keys(state.fileList).length >= state.extraConfigs.maxCount) {
|
|
265
|
-
return methods.uploadError(
|
|
266
|
-
new Error(`\u4E0D\u80FD\u4E0A\u4F20\u591A\u4E8E${state.extraConfigs.maxCount}\u4E2A\u6587\u4EF6`)
|
|
267
|
-
);
|
|
1425
|
+
return methods.uploadError(new Error(props.customErrors?.maxCount || `\u4E0D\u80FD\u4E0A\u4F20\u591A\u4E8E${state.extraConfigs.maxCount}\u4E2A\u6587\u4EF6`));
|
|
268
1426
|
}
|
|
269
1427
|
let name = file.name;
|
|
270
1428
|
let fileFormat = name.split(".").pop();
|
|
271
1429
|
if (!state.uploadConfigs.accept.includes(`.${fileFormat}`)) {
|
|
272
|
-
return methods.uploadError(new Error(`\u4E0D\u80FD\u4E0A\u4F20\u8BE5\u7C7B\u578B\u6587\u4EF6`));
|
|
1430
|
+
return methods.uploadError(new Error(props.customErrors?.format || `\u4E0D\u80FD\u4E0A\u4F20\u8BE5\u7C7B\u578B\u6587\u4EF6`));
|
|
273
1431
|
}
|
|
274
1432
|
state.fileList[file.uid] = {
|
|
275
1433
|
uid: file.uid,
|
|
@@ -288,17 +1446,26 @@ const _sfc_main = {
|
|
|
288
1446
|
}
|
|
289
1447
|
});
|
|
290
1448
|
const methods = {
|
|
1449
|
+
updateUploadProgress(file, progress) {
|
|
1450
|
+
if (methods.fileIsDelete(file)) {
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
state.fileList[file.uid] = {
|
|
1454
|
+
...state.fileList[file.uid],
|
|
1455
|
+
progress
|
|
1456
|
+
};
|
|
1457
|
+
},
|
|
291
1458
|
customUploadRequest(file) {
|
|
292
1459
|
props.uploadRequest?.(file, {
|
|
293
1460
|
onUploadProgress: (e) => {
|
|
294
1461
|
let progress = Math.round(e.loaded / e.total * 100);
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
1462
|
+
if (props.holdProgress) {
|
|
1463
|
+
progress = progress > props.holdProgress ? props.holdProgress : progress;
|
|
1464
|
+
}
|
|
1465
|
+
methods.updateUploadProgress(file, progress);
|
|
299
1466
|
}
|
|
300
1467
|
}).then(function(data) {
|
|
301
|
-
|
|
1468
|
+
methods.updateUploadProgress(file, 100);
|
|
302
1469
|
methods.uploadSuccess(data, file);
|
|
303
1470
|
}).catch(function(error) {
|
|
304
1471
|
console.error(error);
|
|
@@ -308,13 +1475,21 @@ const _sfc_main = {
|
|
|
308
1475
|
methods.uploadError(error, file);
|
|
309
1476
|
});
|
|
310
1477
|
},
|
|
1478
|
+
fileIsDelete(file) {
|
|
1479
|
+
return !state.fileList[file.uid];
|
|
1480
|
+
},
|
|
311
1481
|
uploadSuccess(data, file) {
|
|
1482
|
+
if (methods.fileIsDelete(file)) {
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
312
1485
|
emit("successFile", data);
|
|
1486
|
+
state.fileList[file.uid].status = "success";
|
|
313
1487
|
let uri = data?.url;
|
|
314
1488
|
let item = state.extraConfigs.fileDetail ? {
|
|
315
1489
|
name: file.name,
|
|
316
1490
|
size: file.size,
|
|
317
1491
|
type: file.type,
|
|
1492
|
+
uid: file.uid,
|
|
318
1493
|
url: uri
|
|
319
1494
|
} : uri;
|
|
320
1495
|
state.uploadedList.push(item);
|
|
@@ -322,16 +1497,17 @@ const _sfc_main = {
|
|
|
322
1497
|
emit("success", state.uploadedList);
|
|
323
1498
|
emit("update", state.uploadedList);
|
|
324
1499
|
},
|
|
325
|
-
uploadError(error, file
|
|
326
|
-
if (file
|
|
1500
|
+
uploadError(error, file) {
|
|
1501
|
+
if (file) {
|
|
1502
|
+
if (methods.fileIsDelete(file)) {
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
327
1505
|
state.fileList[file.uid].status = "error";
|
|
328
1506
|
}
|
|
329
1507
|
emit("error", error);
|
|
330
1508
|
},
|
|
331
1509
|
async deleteFile(uid) {
|
|
332
|
-
const index = state.uploadedList.findIndex(
|
|
333
|
-
(ele) => state.extraConfigs.fileDetail ? ele === state.fileList[uid].url : ele.url === state.fileList[uid].url
|
|
334
|
-
);
|
|
1510
|
+
const index = state.uploadedList.findIndex((ele) => state.extraConfigs.fileDetail ? ele === state.fileList[uid].url : ele.url === state.fileList[uid].url);
|
|
335
1511
|
emit("deleteFile", state.fileList[uid]);
|
|
336
1512
|
state.uploadedList.splice(index, 1);
|
|
337
1513
|
delete state.fileList[uid];
|
|
@@ -345,9 +1521,21 @@ const _sfc_main = {
|
|
|
345
1521
|
state.onepViewImageHover[uid] = false;
|
|
346
1522
|
},
|
|
347
1523
|
viewOnePicture(item) {
|
|
348
|
-
if ([
|
|
349
|
-
|
|
350
|
-
|
|
1524
|
+
if ([
|
|
1525
|
+
"img",
|
|
1526
|
+
"image",
|
|
1527
|
+
"png",
|
|
1528
|
+
"PNG",
|
|
1529
|
+
"image/png",
|
|
1530
|
+
"jpg",
|
|
1531
|
+
"JPG",
|
|
1532
|
+
"jpeg",
|
|
1533
|
+
"JPEG",
|
|
1534
|
+
"image/jpeg",
|
|
1535
|
+
"gif",
|
|
1536
|
+
"GIF",
|
|
1537
|
+
"image/gif"
|
|
1538
|
+
].includes(item.type.toLowerCase())) {
|
|
351
1539
|
state.previewVisible = true;
|
|
352
1540
|
state.onepViewImage = item;
|
|
353
1541
|
return;
|
|
@@ -397,50 +1585,55 @@ const _sfc_main = {
|
|
|
397
1585
|
data: state.uploadConfigs.data
|
|
398
1586
|
});
|
|
399
1587
|
}
|
|
1588
|
+
},
|
|
1589
|
+
handleReject(e) {
|
|
1590
|
+
return methods.uploadError(new Error(props.customErrors?.format || `\u4E0D\u80FD\u4E0A\u4F20\u8BE5\u7C7B\u578B\u6587\u4EF6`));
|
|
400
1591
|
}
|
|
401
1592
|
};
|
|
402
|
-
watch(
|
|
403
|
-
()
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
1593
|
+
watch(() => props.defaultList, function(list) {
|
|
1594
|
+
if (list?.length) {
|
|
1595
|
+
list.forEach((item) => {
|
|
1596
|
+
if (!item.uid) {
|
|
1597
|
+
item.uid = utils.getuid();
|
|
1598
|
+
}
|
|
1599
|
+
});
|
|
1600
|
+
list.forEach(function(item) {
|
|
1601
|
+
let uid = item.uid || utils.getuid();
|
|
1602
|
+
if (!item.url.includes("http") && !item.url.includes(CLOUND_PRE))
|
|
1603
|
+
item.url = props.cloudReadUrl + item.url;
|
|
1604
|
+
state.fileList[uid] = {
|
|
1605
|
+
uid,
|
|
1606
|
+
name: item.name,
|
|
1607
|
+
url: item.url,
|
|
1608
|
+
type: item.type || "png",
|
|
1609
|
+
progress: 100,
|
|
1610
|
+
isDoneDeloy: true
|
|
1611
|
+
};
|
|
1612
|
+
if (!state.uploadedList.find((item2) => item2.uid === uid)) {
|
|
418
1613
|
state.uploadedList.push(item);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
);
|
|
426
|
-
watch(
|
|
427
|
-
[() => props.uploadProps, () => props.extraProps],
|
|
428
|
-
function([config, extra]) {
|
|
429
|
-
state.uploadConfigs = {
|
|
430
|
-
...state.uploadConfigs,
|
|
431
|
-
...config,
|
|
432
|
-
showUploadList: false
|
|
433
|
-
};
|
|
434
|
-
state.extraConfigs = {
|
|
435
|
-
...state.extraConfigs,
|
|
436
|
-
...extra
|
|
437
|
-
};
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
immediate: true,
|
|
441
|
-
deep: true
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
} else {
|
|
1617
|
+
state.fileList = {};
|
|
1618
|
+
state.uploadedList = [];
|
|
442
1619
|
}
|
|
443
|
-
|
|
1620
|
+
}, {
|
|
1621
|
+
immediate: true
|
|
1622
|
+
});
|
|
1623
|
+
watch([() => props.uploadProps, () => props.extraProps], function([config, extra]) {
|
|
1624
|
+
state.uploadConfigs = {
|
|
1625
|
+
...state.uploadConfigs,
|
|
1626
|
+
...config,
|
|
1627
|
+
showUploadList: false
|
|
1628
|
+
};
|
|
1629
|
+
state.extraConfigs = {
|
|
1630
|
+
...state.extraConfigs,
|
|
1631
|
+
...extra
|
|
1632
|
+
};
|
|
1633
|
+
}, {
|
|
1634
|
+
immediate: true,
|
|
1635
|
+
deep: true
|
|
1636
|
+
});
|
|
444
1637
|
const uploadDisabled = computed(() => {
|
|
445
1638
|
if (Object.keys(state.fileList).length >= state.extraConfigs.maxCount) {
|
|
446
1639
|
return true;
|
|
@@ -450,6 +1643,26 @@ const _sfc_main = {
|
|
|
450
1643
|
watchEffect(() => {
|
|
451
1644
|
state.uploadConfigs.disabled = uploadDisabled.value;
|
|
452
1645
|
});
|
|
1646
|
+
watch(() => uploadDisabled.value, (value) => {
|
|
1647
|
+
emit("updateDisabledStatus", value);
|
|
1648
|
+
}, {
|
|
1649
|
+
immediate: true
|
|
1650
|
+
});
|
|
1651
|
+
const isUploading = computed(() => {
|
|
1652
|
+
let ret = false;
|
|
1653
|
+
let fileList = state.fileList || {};
|
|
1654
|
+
Object.keys(fileList).forEach((uid) => {
|
|
1655
|
+
if (fileList[uid]?.progress && fileList[uid].progress < 100) {
|
|
1656
|
+
ret = true;
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
return ret;
|
|
1660
|
+
});
|
|
1661
|
+
watch(() => isUploading.value, (value) => {
|
|
1662
|
+
emit("updateIsUploadingStatus", value);
|
|
1663
|
+
}, {
|
|
1664
|
+
immediate: true
|
|
1665
|
+
});
|
|
453
1666
|
return {
|
|
454
1667
|
...toRefs(state),
|
|
455
1668
|
icons,
|
|
@@ -528,7 +1741,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
528
1741
|
const _component_a_modal = resolveComponent("a-modal");
|
|
529
1742
|
return openBlock(), createElementBlock("div", {
|
|
530
1743
|
class: normalizeClass(["bm-upload", {
|
|
531
|
-
"bm-upload--text": _ctx.uploadConfigs.listType === "text"
|
|
1744
|
+
"bm-upload--text": _ctx.uploadConfigs.listType === "text",
|
|
1745
|
+
"bm-upload--picture-card--has-tips": !($setup.uploadDisabled && _ctx.extraConfigs?.hideDisabledBtn) && !_ctx.extraConfigs.myBtn && _ctx.uploadConfigs.listType === "picture-card" && _ctx.extraConfigs.tips && _ctx.extraConfigs.showTips
|
|
532
1746
|
}])
|
|
533
1747
|
}, [
|
|
534
1748
|
_ctx.uploadConfigs.listType === "picture-card" ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.fileList, (item) => {
|
|
@@ -556,27 +1770,59 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
556
1770
|
onMouseleave: ($event) => _ctx.pictureHoverLeave(item.uid),
|
|
557
1771
|
onClick: _cache[0] || (_cache[0] = (e) => e.stopPropagation())
|
|
558
1772
|
}, [
|
|
559
|
-
|
|
1773
|
+
["pdf", "PDF", "application/pdf"].includes(item.type) ? (openBlock(), createElementBlock("img", {
|
|
560
1774
|
key: 0,
|
|
561
1775
|
class: "bm-upload__picture-result__image",
|
|
562
1776
|
src: $setup.icons.pdf,
|
|
563
1777
|
alt: "avatar"
|
|
564
|
-
}, null, 8, _hoisted_4)) :
|
|
1778
|
+
}, null, 8, _hoisted_4)) : [
|
|
1779
|
+
"xlsx",
|
|
1780
|
+
"XLSX",
|
|
1781
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
1782
|
+
].includes(item.type) ? (openBlock(), createElementBlock("img", {
|
|
565
1783
|
key: 1,
|
|
566
1784
|
class: "bm-upload__picture-result__image",
|
|
567
1785
|
src: $setup.icons.excel,
|
|
568
1786
|
alt: "avatar"
|
|
569
|
-
}, null, 8, _hoisted_5)) :
|
|
1787
|
+
}, null, 8, _hoisted_5)) : [
|
|
1788
|
+
"ppt",
|
|
1789
|
+
"PPT",
|
|
1790
|
+
"application/vnd.ms-powerpoint",
|
|
1791
|
+
"pptx",
|
|
1792
|
+
"PPTX",
|
|
1793
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
1794
|
+
].includes(item.type) ? (openBlock(), createElementBlock("img", {
|
|
570
1795
|
key: 2,
|
|
571
1796
|
class: "bm-upload__picture-result__image",
|
|
572
1797
|
src: $setup.icons.ppt,
|
|
573
1798
|
alt: "avatar"
|
|
574
|
-
}, null, 8, _hoisted_6)) : [
|
|
1799
|
+
}, null, 8, _hoisted_6)) : [
|
|
1800
|
+
"doc",
|
|
1801
|
+
"DOC",
|
|
1802
|
+
"application/msword",
|
|
1803
|
+
"docx",
|
|
1804
|
+
"DOCX",
|
|
1805
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
1806
|
+
].includes(item.type) ? (openBlock(), createElementBlock("img", {
|
|
575
1807
|
key: 3,
|
|
576
1808
|
class: "bm-upload__picture-result__image",
|
|
577
1809
|
src: $setup.icons.doc,
|
|
578
1810
|
alt: "avatar"
|
|
579
|
-
}, null, 8, _hoisted_7)) : [
|
|
1811
|
+
}, null, 8, _hoisted_7)) : [
|
|
1812
|
+
"img",
|
|
1813
|
+
"image",
|
|
1814
|
+
"png",
|
|
1815
|
+
"PNG",
|
|
1816
|
+
"image/png",
|
|
1817
|
+
"jpg",
|
|
1818
|
+
"JPG",
|
|
1819
|
+
"jpeg",
|
|
1820
|
+
"JPEG",
|
|
1821
|
+
"image/jpeg",
|
|
1822
|
+
"gif",
|
|
1823
|
+
"GIF",
|
|
1824
|
+
"image/gif"
|
|
1825
|
+
].includes(item.type) ? (openBlock(), createElementBlock("img", {
|
|
580
1826
|
key: 4,
|
|
581
1827
|
class: "bm-upload__picture-result__image",
|
|
582
1828
|
src: item.url,
|
|
@@ -603,7 +1849,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
603
1849
|
key: 1,
|
|
604
1850
|
file: item
|
|
605
1851
|
})
|
|
606
|
-
],
|
|
1852
|
+
], 2112)) : createCommentVNode("v-if", true),
|
|
607
1853
|
createCommentVNode(" \u56FE\u7247\u9519\u8BEF\u5C55\u793A "),
|
|
608
1854
|
item.status === "error" ? (openBlock(), createElementBlock("div", {
|
|
609
1855
|
key: 2,
|
|
@@ -628,7 +1874,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
628
1874
|
], 2);
|
|
629
1875
|
}), 128)) : createCommentVNode("v-if", true),
|
|
630
1876
|
!($setup.uploadDisabled && _ctx.extraConfigs?.hideDisabledBtn) ? (openBlock(), createBlock(_component_a_upload, mergeProps({ key: 1 }, _ctx.uploadConfigs, {
|
|
631
|
-
class: { "bm--upload__custom-button": _ctx.extraConfigs.myBtn }
|
|
1877
|
+
class: { "bm--upload__custom-button": _ctx.extraConfigs.myBtn },
|
|
1878
|
+
onReject: _ctx.handleReject
|
|
632
1879
|
}), {
|
|
633
1880
|
default: withCtx(() => [
|
|
634
1881
|
_ctx.extraConfigs.myBtn ? renderSlot(_ctx.$slots, "myBtn", { key: 0 }) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
@@ -649,10 +1896,10 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
649
1896
|
}, 8, ["class", "disabled"]),
|
|
650
1897
|
_ctx.extraConfigs.tips && _ctx.extraConfigs.showTips ? (openBlock(), createElementBlock("div", _hoisted_23, toDisplayString(_ctx.extraConfigs.tips), 1)) : createCommentVNode("v-if", true)
|
|
651
1898
|
])) : createCommentVNode("v-if", true)
|
|
652
|
-
],
|
|
1899
|
+
], 2112))
|
|
653
1900
|
]),
|
|
654
1901
|
_: 3
|
|
655
|
-
}, 16, ["class"])) : createCommentVNode("v-if", true),
|
|
1902
|
+
}, 16, ["class", "onReject"])) : createCommentVNode("v-if", true),
|
|
656
1903
|
_ctx.uploadConfigs.listType === "text" && !_ctx.uploadConfigs.showSlotList ? (openBlock(), createElementBlock("div", _hoisted_24, [
|
|
657
1904
|
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.fileList, (item) => {
|
|
658
1905
|
return openBlock(), createElementBlock("div", {
|
|
@@ -703,7 +1950,21 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
703
1950
|
}, {
|
|
704
1951
|
default: withCtx(() => [
|
|
705
1952
|
createElementVNode("div", _hoisted_32, [
|
|
706
|
-
[
|
|
1953
|
+
[
|
|
1954
|
+
"img",
|
|
1955
|
+
"image",
|
|
1956
|
+
"png",
|
|
1957
|
+
"PNG",
|
|
1958
|
+
"image/png",
|
|
1959
|
+
"jpg",
|
|
1960
|
+
"JPG",
|
|
1961
|
+
"jpeg",
|
|
1962
|
+
"JPEG",
|
|
1963
|
+
"image/jpeg",
|
|
1964
|
+
"gif",
|
|
1965
|
+
"GIF",
|
|
1966
|
+
"image/gif"
|
|
1967
|
+
].includes(_ctx.onepViewImage.type) ? (openBlock(), createElementBlock("img", {
|
|
707
1968
|
key: 0,
|
|
708
1969
|
style: { "width": "100%" },
|
|
709
1970
|
src: _ctx.onepViewImage.url,
|