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