bm-admin-ui 1.0.0-alpha → 1.0.1-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 +9 -9
- package/es/components/button/index.js +1 -1
- package/es/components/button/src/button.vue.d.ts +9 -9
- package/es/components/float-table/index.d.ts +5 -0
- package/es/components/float-table/index.js +448 -0
- package/es/components/float-table/src/float-table.vue.d.ts +500 -0
- package/es/components/flow-designer/index.js +1 -1
- package/es/components/form-designer/index.js +1 -1
- package/es/components/index.d.ts +7 -0
- package/es/components/index.js +7 -0
- package/es/components/multi-cascader-compose/index.d.ts +135 -0
- package/es/components/multi-cascader-compose/index.js +1699 -0
- package/es/components/multi-cascader-compose/src/multi-cascader-compose.vue.d.ts +135 -0
- package/es/components/multi-cascader-compose/src/props.d.ts +32 -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 +117 -0
- package/es/components/over-tooltips/src/over-tooltips.vue.d.ts +34 -0
- package/es/components/search-filter/index.d.ts +1 -1
- package/es/components/search-filter/index.js +593 -29
- package/es/components/search-filter/src/search-filter.vue.d.ts +1 -1
- package/es/components/shops-filter/index.d.ts +99 -0
- package/es/components/shops-filter/index.js +1614 -0
- 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 +82 -0
- package/es/components/staffs-selector/index.js +1991 -0
- package/es/components/staffs-selector/src/multipleCmp.vue.d.ts +79 -0
- package/es/components/staffs-selector/src/radioCmp.vue.d.ts +31 -0
- package/es/components/staffs-selector/src/staffs-selector.vue.d.ts +81 -0
- package/es/components/staffs-selector/src/variedCmp.vue.d.ts +62 -0
- package/es/components/timeline/index.d.ts +93 -0
- package/es/components/timeline/index.js +164 -0
- package/es/components/timeline/src/props.d.ts +20 -0
- package/es/components/timeline/src/timeline-item.vue.d.ts +51 -0
- package/es/components/timeline/src/timeline.vue.d.ts +42 -0
- package/es/components/upload/index.d.ts +126 -0
- package/es/components/upload/index.js +1839 -0
- package/es/components/upload/src/icons.d.ts +13 -0
- package/es/components/upload/src/upload.vue.d.ts +125 -0
- package/es/components/upload/utils/index.d.ts +7 -0
- package/index.esm.js +62925 -1235
- package/index.js +63078 -1380
- package/lib/components/button/index.d.ts +9 -9
- package/lib/components/button/index.js +1 -1
- package/lib/components/button/src/button.vue.d.ts +9 -9
- package/lib/components/float-table/index.d.ts +5 -0
- package/lib/components/float-table/index.js +459 -0
- package/lib/components/float-table/src/float-table.vue.d.ts +500 -0
- package/lib/components/flow-designer/index.js +1 -1
- package/lib/components/form-designer/index.js +1 -1
- package/lib/components/index.d.ts +7 -0
- package/lib/components/index.js +49 -0
- package/lib/components/multi-cascader-compose/index.d.ts +135 -0
- package/lib/components/multi-cascader-compose/index.js +1704 -0
- package/lib/components/multi-cascader-compose/src/multi-cascader-compose.vue.d.ts +135 -0
- package/lib/components/multi-cascader-compose/src/props.d.ts +32 -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 +122 -0
- package/lib/components/over-tooltips/src/over-tooltips.vue.d.ts +34 -0
- package/lib/components/search-filter/index.d.ts +1 -1
- package/lib/components/search-filter/index.js +592 -28
- package/lib/components/search-filter/src/search-filter.vue.d.ts +1 -1
- package/lib/components/shops-filter/index.d.ts +99 -0
- package/lib/components/shops-filter/index.js +1626 -0
- 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 +82 -0
- package/lib/components/staffs-selector/index.js +2005 -0
- package/lib/components/staffs-selector/src/multipleCmp.vue.d.ts +79 -0
- package/lib/components/staffs-selector/src/radioCmp.vue.d.ts +31 -0
- package/lib/components/staffs-selector/src/staffs-selector.vue.d.ts +81 -0
- package/lib/components/staffs-selector/src/variedCmp.vue.d.ts +62 -0
- package/lib/components/timeline/index.d.ts +93 -0
- package/lib/components/timeline/index.js +170 -0
- package/lib/components/timeline/src/props.d.ts +20 -0
- package/lib/components/timeline/src/timeline-item.vue.d.ts +51 -0
- package/lib/components/timeline/src/timeline.vue.d.ts +42 -0
- package/lib/components/upload/index.d.ts +126 -0
- package/lib/components/upload/index.js +1844 -0
- package/lib/components/upload/src/icons.d.ts +13 -0
- package/lib/components/upload/src/upload.vue.d.ts +125 -0
- package/lib/components/upload/utils/index.d.ts +7 -0
- package/package.json +6 -3
- package/theme-chalk/button.css +1 -1
- package/theme-chalk/float-table.css +1 -0
- package/theme-chalk/floating-vue.css +1 -0
- package/theme-chalk/flow-designer.css +1 -1
- package/theme-chalk/index.css +1 -1
- package/theme-chalk/multi-cascader-compose.css +1 -0
- package/theme-chalk/over-tooltips.css +1 -0
- package/theme-chalk/search-filter.css +1 -1
- package/theme-chalk/shops-filter.css +1 -0
- package/theme-chalk/staffs-selector.css +1 -0
- package/theme-chalk/timeline.css +1 -0
- package/theme-chalk/upload.css +1 -0
- package/types/components/button/index.d.ts +9 -9
- package/types/components/button/src/button.vue.d.ts +9 -9
- package/types/components/float-table/index.d.ts +5 -0
- package/types/components/float-table/src/float-table.vue.d.ts +500 -0
- package/types/components/index.d.ts +7 -0
- package/types/components/multi-cascader-compose/index.d.ts +135 -0
- package/types/components/multi-cascader-compose/src/multi-cascader-compose.vue.d.ts +135 -0
- package/types/components/multi-cascader-compose/src/props.d.ts +32 -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 +1 -1
- package/types/components/search-filter/src/search-filter.vue.d.ts +1 -1
- 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 +82 -0
- package/types/components/staffs-selector/src/multipleCmp.vue.d.ts +79 -0
- package/types/components/staffs-selector/src/radioCmp.vue.d.ts +31 -0
- package/types/components/staffs-selector/src/staffs-selector.vue.d.ts +81 -0
- package/types/components/staffs-selector/src/variedCmp.vue.d.ts +62 -0
- package/types/components/timeline/index.d.ts +93 -0
- package/types/components/timeline/src/props.d.ts +20 -0
- package/types/components/timeline/src/timeline-item.vue.d.ts +51 -0
- package/types/components/timeline/src/timeline.vue.d.ts +42 -0
- package/types/components/upload/index.d.ts +126 -0
- package/types/components/upload/src/icons.d.ts +13 -0
- package/types/components/upload/src/upload.vue.d.ts +125 -0
- package/types/components/upload/utils/index.d.ts +7 -0
|
@@ -0,0 +1,1991 @@
|
|
|
1
|
+
import { withInstall } from 'bm-admin-ui/es/utils/with-install';
|
|
2
|
+
import AModal from 'ant-design-vue/lib/modal';
|
|
3
|
+
import { h, nextTick, createVNode, defineComponent, reactive, watch, onMounted, toRefs, resolveComponent, openBlock, createElementBlock, createElementVNode, withCtx, Fragment, withDirectives, vShow, renderList, createTextVNode, toDisplayString, createBlock, createCommentVNode, withModifiers, ref, computed, readonly, normalizeClass } from 'vue';
|
|
4
|
+
import Empty from 'ant-design-vue/lib/empty';
|
|
5
|
+
import AInput from 'ant-design-vue/lib/input';
|
|
6
|
+
import Checkbox from 'ant-design-vue/lib/checkbox';
|
|
7
|
+
import ATree from 'ant-design-vue/lib/tree';
|
|
8
|
+
import ARadio, { Group } from 'ant-design-vue/lib/radio';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Take input from [0, n] and return it as [0, 1]
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
function bound01(n, max) {
|
|
15
|
+
if (isOnePointZero(n)) {
|
|
16
|
+
n = '100%';
|
|
17
|
+
}
|
|
18
|
+
var isPercent = isPercentage(n);
|
|
19
|
+
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
|
|
20
|
+
// Automatically convert percentage into number
|
|
21
|
+
if (isPercent) {
|
|
22
|
+
n = parseInt(String(n * max), 10) / 100;
|
|
23
|
+
}
|
|
24
|
+
// Handle floating point rounding errors
|
|
25
|
+
if (Math.abs(n - max) < 0.000001) {
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
// Convert into [0, 1] range if it isn't already
|
|
29
|
+
if (max === 360) {
|
|
30
|
+
// If n is a hue given in degrees,
|
|
31
|
+
// wrap around out-of-range values into [0, 360] range
|
|
32
|
+
// then convert into [0, 1].
|
|
33
|
+
n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// If n not a hue given in degrees
|
|
37
|
+
// Convert into [0, 1] range if it isn't already.
|
|
38
|
+
n = (n % max) / parseFloat(String(max));
|
|
39
|
+
}
|
|
40
|
+
return n;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
44
|
+
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
47
|
+
function isOnePointZero(n) {
|
|
48
|
+
return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Check to see if string passed in is a percentage
|
|
52
|
+
* @hidden
|
|
53
|
+
*/
|
|
54
|
+
function isPercentage(n) {
|
|
55
|
+
return typeof n === 'string' && n.indexOf('%') !== -1;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
59
|
+
* @hidden
|
|
60
|
+
*/
|
|
61
|
+
function boundAlpha(a) {
|
|
62
|
+
a = parseFloat(a);
|
|
63
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
64
|
+
a = 1;
|
|
65
|
+
}
|
|
66
|
+
return a;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Replace a decimal with it's percentage value
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
function convertToPercentage(n) {
|
|
73
|
+
if (n <= 1) {
|
|
74
|
+
return Number(n) * 100 + "%";
|
|
75
|
+
}
|
|
76
|
+
return n;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Force a hex value to have 2 characters
|
|
80
|
+
* @hidden
|
|
81
|
+
*/
|
|
82
|
+
function pad2(c) {
|
|
83
|
+
return c.length === 1 ? '0' + c : String(c);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
87
|
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
88
|
+
/**
|
|
89
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
90
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
91
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
92
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
93
|
+
*/
|
|
94
|
+
function rgbToRgb(r, g, b) {
|
|
95
|
+
return {
|
|
96
|
+
r: bound01(r, 255) * 255,
|
|
97
|
+
g: bound01(g, 255) * 255,
|
|
98
|
+
b: bound01(b, 255) * 255,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function hue2rgb(p, q, t) {
|
|
102
|
+
if (t < 0) {
|
|
103
|
+
t += 1;
|
|
104
|
+
}
|
|
105
|
+
if (t > 1) {
|
|
106
|
+
t -= 1;
|
|
107
|
+
}
|
|
108
|
+
if (t < 1 / 6) {
|
|
109
|
+
return p + (q - p) * (6 * t);
|
|
110
|
+
}
|
|
111
|
+
if (t < 1 / 2) {
|
|
112
|
+
return q;
|
|
113
|
+
}
|
|
114
|
+
if (t < 2 / 3) {
|
|
115
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
116
|
+
}
|
|
117
|
+
return p;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Converts an HSL color value to RGB.
|
|
121
|
+
*
|
|
122
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
123
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
124
|
+
*/
|
|
125
|
+
function hslToRgb(h, s, l) {
|
|
126
|
+
var r;
|
|
127
|
+
var g;
|
|
128
|
+
var b;
|
|
129
|
+
h = bound01(h, 360);
|
|
130
|
+
s = bound01(s, 100);
|
|
131
|
+
l = bound01(l, 100);
|
|
132
|
+
if (s === 0) {
|
|
133
|
+
// achromatic
|
|
134
|
+
g = l;
|
|
135
|
+
b = l;
|
|
136
|
+
r = l;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
140
|
+
var p = 2 * l - q;
|
|
141
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
142
|
+
g = hue2rgb(p, q, h);
|
|
143
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
144
|
+
}
|
|
145
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Converts an RGB color value to HSV
|
|
149
|
+
*
|
|
150
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
151
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
152
|
+
*/
|
|
153
|
+
function rgbToHsv(r, g, b) {
|
|
154
|
+
r = bound01(r, 255);
|
|
155
|
+
g = bound01(g, 255);
|
|
156
|
+
b = bound01(b, 255);
|
|
157
|
+
var max = Math.max(r, g, b);
|
|
158
|
+
var min = Math.min(r, g, b);
|
|
159
|
+
var h = 0;
|
|
160
|
+
var v = max;
|
|
161
|
+
var d = max - min;
|
|
162
|
+
var s = max === 0 ? 0 : d / max;
|
|
163
|
+
if (max === min) {
|
|
164
|
+
h = 0; // achromatic
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
switch (max) {
|
|
168
|
+
case r:
|
|
169
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
170
|
+
break;
|
|
171
|
+
case g:
|
|
172
|
+
h = (b - r) / d + 2;
|
|
173
|
+
break;
|
|
174
|
+
case b:
|
|
175
|
+
h = (r - g) / d + 4;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
h /= 6;
|
|
179
|
+
}
|
|
180
|
+
return { h: h, s: s, v: v };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Converts an HSV color value to RGB.
|
|
184
|
+
*
|
|
185
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
186
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
187
|
+
*/
|
|
188
|
+
function hsvToRgb(h, s, v) {
|
|
189
|
+
h = bound01(h, 360) * 6;
|
|
190
|
+
s = bound01(s, 100);
|
|
191
|
+
v = bound01(v, 100);
|
|
192
|
+
var i = Math.floor(h);
|
|
193
|
+
var f = h - i;
|
|
194
|
+
var p = v * (1 - s);
|
|
195
|
+
var q = v * (1 - f * s);
|
|
196
|
+
var t = v * (1 - (1 - f) * s);
|
|
197
|
+
var mod = i % 6;
|
|
198
|
+
var r = [v, q, p, p, t, v][mod];
|
|
199
|
+
var g = [t, v, v, q, p, p][mod];
|
|
200
|
+
var b = [p, p, t, v, v, q][mod];
|
|
201
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Converts an RGB color to hex
|
|
205
|
+
*
|
|
206
|
+
* Assumes r, g, and b are contained in the set [0, 255]
|
|
207
|
+
* Returns a 3 or 6 character hex
|
|
208
|
+
*/
|
|
209
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
210
|
+
var hex = [
|
|
211
|
+
pad2(Math.round(r).toString(16)),
|
|
212
|
+
pad2(Math.round(g).toString(16)),
|
|
213
|
+
pad2(Math.round(b).toString(16)),
|
|
214
|
+
];
|
|
215
|
+
// Return a 3 character hex if possible
|
|
216
|
+
if (allow3Char &&
|
|
217
|
+
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
218
|
+
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
219
|
+
hex[2].startsWith(hex[2].charAt(1))) {
|
|
220
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
221
|
+
}
|
|
222
|
+
return hex.join('');
|
|
223
|
+
}
|
|
224
|
+
/** Converts a hex value to a decimal */
|
|
225
|
+
function convertHexToDecimal(h) {
|
|
226
|
+
return parseIntFromHex(h) / 255;
|
|
227
|
+
}
|
|
228
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
229
|
+
function parseIntFromHex(val) {
|
|
230
|
+
return parseInt(val, 16);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
|
|
234
|
+
/**
|
|
235
|
+
* @hidden
|
|
236
|
+
*/
|
|
237
|
+
var names = {
|
|
238
|
+
aliceblue: '#f0f8ff',
|
|
239
|
+
antiquewhite: '#faebd7',
|
|
240
|
+
aqua: '#00ffff',
|
|
241
|
+
aquamarine: '#7fffd4',
|
|
242
|
+
azure: '#f0ffff',
|
|
243
|
+
beige: '#f5f5dc',
|
|
244
|
+
bisque: '#ffe4c4',
|
|
245
|
+
black: '#000000',
|
|
246
|
+
blanchedalmond: '#ffebcd',
|
|
247
|
+
blue: '#0000ff',
|
|
248
|
+
blueviolet: '#8a2be2',
|
|
249
|
+
brown: '#a52a2a',
|
|
250
|
+
burlywood: '#deb887',
|
|
251
|
+
cadetblue: '#5f9ea0',
|
|
252
|
+
chartreuse: '#7fff00',
|
|
253
|
+
chocolate: '#d2691e',
|
|
254
|
+
coral: '#ff7f50',
|
|
255
|
+
cornflowerblue: '#6495ed',
|
|
256
|
+
cornsilk: '#fff8dc',
|
|
257
|
+
crimson: '#dc143c',
|
|
258
|
+
cyan: '#00ffff',
|
|
259
|
+
darkblue: '#00008b',
|
|
260
|
+
darkcyan: '#008b8b',
|
|
261
|
+
darkgoldenrod: '#b8860b',
|
|
262
|
+
darkgray: '#a9a9a9',
|
|
263
|
+
darkgreen: '#006400',
|
|
264
|
+
darkgrey: '#a9a9a9',
|
|
265
|
+
darkkhaki: '#bdb76b',
|
|
266
|
+
darkmagenta: '#8b008b',
|
|
267
|
+
darkolivegreen: '#556b2f',
|
|
268
|
+
darkorange: '#ff8c00',
|
|
269
|
+
darkorchid: '#9932cc',
|
|
270
|
+
darkred: '#8b0000',
|
|
271
|
+
darksalmon: '#e9967a',
|
|
272
|
+
darkseagreen: '#8fbc8f',
|
|
273
|
+
darkslateblue: '#483d8b',
|
|
274
|
+
darkslategray: '#2f4f4f',
|
|
275
|
+
darkslategrey: '#2f4f4f',
|
|
276
|
+
darkturquoise: '#00ced1',
|
|
277
|
+
darkviolet: '#9400d3',
|
|
278
|
+
deeppink: '#ff1493',
|
|
279
|
+
deepskyblue: '#00bfff',
|
|
280
|
+
dimgray: '#696969',
|
|
281
|
+
dimgrey: '#696969',
|
|
282
|
+
dodgerblue: '#1e90ff',
|
|
283
|
+
firebrick: '#b22222',
|
|
284
|
+
floralwhite: '#fffaf0',
|
|
285
|
+
forestgreen: '#228b22',
|
|
286
|
+
fuchsia: '#ff00ff',
|
|
287
|
+
gainsboro: '#dcdcdc',
|
|
288
|
+
ghostwhite: '#f8f8ff',
|
|
289
|
+
goldenrod: '#daa520',
|
|
290
|
+
gold: '#ffd700',
|
|
291
|
+
gray: '#808080',
|
|
292
|
+
green: '#008000',
|
|
293
|
+
greenyellow: '#adff2f',
|
|
294
|
+
grey: '#808080',
|
|
295
|
+
honeydew: '#f0fff0',
|
|
296
|
+
hotpink: '#ff69b4',
|
|
297
|
+
indianred: '#cd5c5c',
|
|
298
|
+
indigo: '#4b0082',
|
|
299
|
+
ivory: '#fffff0',
|
|
300
|
+
khaki: '#f0e68c',
|
|
301
|
+
lavenderblush: '#fff0f5',
|
|
302
|
+
lavender: '#e6e6fa',
|
|
303
|
+
lawngreen: '#7cfc00',
|
|
304
|
+
lemonchiffon: '#fffacd',
|
|
305
|
+
lightblue: '#add8e6',
|
|
306
|
+
lightcoral: '#f08080',
|
|
307
|
+
lightcyan: '#e0ffff',
|
|
308
|
+
lightgoldenrodyellow: '#fafad2',
|
|
309
|
+
lightgray: '#d3d3d3',
|
|
310
|
+
lightgreen: '#90ee90',
|
|
311
|
+
lightgrey: '#d3d3d3',
|
|
312
|
+
lightpink: '#ffb6c1',
|
|
313
|
+
lightsalmon: '#ffa07a',
|
|
314
|
+
lightseagreen: '#20b2aa',
|
|
315
|
+
lightskyblue: '#87cefa',
|
|
316
|
+
lightslategray: '#778899',
|
|
317
|
+
lightslategrey: '#778899',
|
|
318
|
+
lightsteelblue: '#b0c4de',
|
|
319
|
+
lightyellow: '#ffffe0',
|
|
320
|
+
lime: '#00ff00',
|
|
321
|
+
limegreen: '#32cd32',
|
|
322
|
+
linen: '#faf0e6',
|
|
323
|
+
magenta: '#ff00ff',
|
|
324
|
+
maroon: '#800000',
|
|
325
|
+
mediumaquamarine: '#66cdaa',
|
|
326
|
+
mediumblue: '#0000cd',
|
|
327
|
+
mediumorchid: '#ba55d3',
|
|
328
|
+
mediumpurple: '#9370db',
|
|
329
|
+
mediumseagreen: '#3cb371',
|
|
330
|
+
mediumslateblue: '#7b68ee',
|
|
331
|
+
mediumspringgreen: '#00fa9a',
|
|
332
|
+
mediumturquoise: '#48d1cc',
|
|
333
|
+
mediumvioletred: '#c71585',
|
|
334
|
+
midnightblue: '#191970',
|
|
335
|
+
mintcream: '#f5fffa',
|
|
336
|
+
mistyrose: '#ffe4e1',
|
|
337
|
+
moccasin: '#ffe4b5',
|
|
338
|
+
navajowhite: '#ffdead',
|
|
339
|
+
navy: '#000080',
|
|
340
|
+
oldlace: '#fdf5e6',
|
|
341
|
+
olive: '#808000',
|
|
342
|
+
olivedrab: '#6b8e23',
|
|
343
|
+
orange: '#ffa500',
|
|
344
|
+
orangered: '#ff4500',
|
|
345
|
+
orchid: '#da70d6',
|
|
346
|
+
palegoldenrod: '#eee8aa',
|
|
347
|
+
palegreen: '#98fb98',
|
|
348
|
+
paleturquoise: '#afeeee',
|
|
349
|
+
palevioletred: '#db7093',
|
|
350
|
+
papayawhip: '#ffefd5',
|
|
351
|
+
peachpuff: '#ffdab9',
|
|
352
|
+
peru: '#cd853f',
|
|
353
|
+
pink: '#ffc0cb',
|
|
354
|
+
plum: '#dda0dd',
|
|
355
|
+
powderblue: '#b0e0e6',
|
|
356
|
+
purple: '#800080',
|
|
357
|
+
rebeccapurple: '#663399',
|
|
358
|
+
red: '#ff0000',
|
|
359
|
+
rosybrown: '#bc8f8f',
|
|
360
|
+
royalblue: '#4169e1',
|
|
361
|
+
saddlebrown: '#8b4513',
|
|
362
|
+
salmon: '#fa8072',
|
|
363
|
+
sandybrown: '#f4a460',
|
|
364
|
+
seagreen: '#2e8b57',
|
|
365
|
+
seashell: '#fff5ee',
|
|
366
|
+
sienna: '#a0522d',
|
|
367
|
+
silver: '#c0c0c0',
|
|
368
|
+
skyblue: '#87ceeb',
|
|
369
|
+
slateblue: '#6a5acd',
|
|
370
|
+
slategray: '#708090',
|
|
371
|
+
slategrey: '#708090',
|
|
372
|
+
snow: '#fffafa',
|
|
373
|
+
springgreen: '#00ff7f',
|
|
374
|
+
steelblue: '#4682b4',
|
|
375
|
+
tan: '#d2b48c',
|
|
376
|
+
teal: '#008080',
|
|
377
|
+
thistle: '#d8bfd8',
|
|
378
|
+
tomato: '#ff6347',
|
|
379
|
+
turquoise: '#40e0d0',
|
|
380
|
+
violet: '#ee82ee',
|
|
381
|
+
wheat: '#f5deb3',
|
|
382
|
+
white: '#ffffff',
|
|
383
|
+
whitesmoke: '#f5f5f5',
|
|
384
|
+
yellow: '#ffff00',
|
|
385
|
+
yellowgreen: '#9acd32',
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Given a string or object, convert that input to RGB
|
|
390
|
+
*
|
|
391
|
+
* Possible string inputs:
|
|
392
|
+
* ```
|
|
393
|
+
* "red"
|
|
394
|
+
* "#f00" or "f00"
|
|
395
|
+
* "#ff0000" or "ff0000"
|
|
396
|
+
* "#ff000000" or "ff000000"
|
|
397
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
398
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
399
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
400
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
401
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
402
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
403
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
404
|
+
* ```
|
|
405
|
+
*/
|
|
406
|
+
function inputToRGB(color) {
|
|
407
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
|
408
|
+
var a = 1;
|
|
409
|
+
var s = null;
|
|
410
|
+
var v = null;
|
|
411
|
+
var l = null;
|
|
412
|
+
var ok = false;
|
|
413
|
+
var format = false;
|
|
414
|
+
if (typeof color === 'string') {
|
|
415
|
+
color = stringInputToObject(color);
|
|
416
|
+
}
|
|
417
|
+
if (typeof color === 'object') {
|
|
418
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
419
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
420
|
+
ok = true;
|
|
421
|
+
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
|
|
422
|
+
}
|
|
423
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
424
|
+
s = convertToPercentage(color.s);
|
|
425
|
+
v = convertToPercentage(color.v);
|
|
426
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
427
|
+
ok = true;
|
|
428
|
+
format = 'hsv';
|
|
429
|
+
}
|
|
430
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
431
|
+
s = convertToPercentage(color.s);
|
|
432
|
+
l = convertToPercentage(color.l);
|
|
433
|
+
rgb = hslToRgb(color.h, s, l);
|
|
434
|
+
ok = true;
|
|
435
|
+
format = 'hsl';
|
|
436
|
+
}
|
|
437
|
+
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
|
|
438
|
+
a = color.a;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
a = boundAlpha(a);
|
|
442
|
+
return {
|
|
443
|
+
ok: ok,
|
|
444
|
+
format: color.format || format,
|
|
445
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
446
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
447
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
448
|
+
a: a,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
// <http://www.w3.org/TR/css3-values/#integers>
|
|
452
|
+
var CSS_INTEGER = '[-\\+]?\\d+%?';
|
|
453
|
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
454
|
+
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
|
455
|
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
456
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
457
|
+
// Actual matching.
|
|
458
|
+
// Parentheses and commas are optional, but not required.
|
|
459
|
+
// Whitespace can take the place of commas or opening paren
|
|
460
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
461
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
462
|
+
var matchers = {
|
|
463
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
464
|
+
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
|
|
465
|
+
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
|
|
466
|
+
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
|
|
467
|
+
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
|
|
468
|
+
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
|
|
469
|
+
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
|
|
470
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
471
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
472
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
473
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
474
|
+
};
|
|
475
|
+
/**
|
|
476
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
477
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
478
|
+
*/
|
|
479
|
+
function stringInputToObject(color) {
|
|
480
|
+
color = color.trim().toLowerCase();
|
|
481
|
+
if (color.length === 0) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
var named = false;
|
|
485
|
+
if (names[color]) {
|
|
486
|
+
color = names[color];
|
|
487
|
+
named = true;
|
|
488
|
+
}
|
|
489
|
+
else if (color === 'transparent') {
|
|
490
|
+
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
|
|
491
|
+
}
|
|
492
|
+
// Try to match string input using regular expressions.
|
|
493
|
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
494
|
+
// Just return an object and let the conversion functions handle that.
|
|
495
|
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
496
|
+
var match = matchers.rgb.exec(color);
|
|
497
|
+
if (match) {
|
|
498
|
+
return { r: match[1], g: match[2], b: match[3] };
|
|
499
|
+
}
|
|
500
|
+
match = matchers.rgba.exec(color);
|
|
501
|
+
if (match) {
|
|
502
|
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
503
|
+
}
|
|
504
|
+
match = matchers.hsl.exec(color);
|
|
505
|
+
if (match) {
|
|
506
|
+
return { h: match[1], s: match[2], l: match[3] };
|
|
507
|
+
}
|
|
508
|
+
match = matchers.hsla.exec(color);
|
|
509
|
+
if (match) {
|
|
510
|
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
511
|
+
}
|
|
512
|
+
match = matchers.hsv.exec(color);
|
|
513
|
+
if (match) {
|
|
514
|
+
return { h: match[1], s: match[2], v: match[3] };
|
|
515
|
+
}
|
|
516
|
+
match = matchers.hsva.exec(color);
|
|
517
|
+
if (match) {
|
|
518
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
519
|
+
}
|
|
520
|
+
match = matchers.hex8.exec(color);
|
|
521
|
+
if (match) {
|
|
522
|
+
return {
|
|
523
|
+
r: parseIntFromHex(match[1]),
|
|
524
|
+
g: parseIntFromHex(match[2]),
|
|
525
|
+
b: parseIntFromHex(match[3]),
|
|
526
|
+
a: convertHexToDecimal(match[4]),
|
|
527
|
+
format: named ? 'name' : 'hex8',
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
match = matchers.hex6.exec(color);
|
|
531
|
+
if (match) {
|
|
532
|
+
return {
|
|
533
|
+
r: parseIntFromHex(match[1]),
|
|
534
|
+
g: parseIntFromHex(match[2]),
|
|
535
|
+
b: parseIntFromHex(match[3]),
|
|
536
|
+
format: named ? 'name' : 'hex',
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
match = matchers.hex4.exec(color);
|
|
540
|
+
if (match) {
|
|
541
|
+
return {
|
|
542
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
543
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
544
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
545
|
+
a: convertHexToDecimal(match[4] + match[4]),
|
|
546
|
+
format: named ? 'name' : 'hex8',
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
match = matchers.hex3.exec(color);
|
|
550
|
+
if (match) {
|
|
551
|
+
return {
|
|
552
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
553
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
554
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
555
|
+
format: named ? 'name' : 'hex',
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Check to see if it looks like a CSS unit
|
|
562
|
+
* (see `matchers` above for definition).
|
|
563
|
+
*/
|
|
564
|
+
function isValidCSSUnit(color) {
|
|
565
|
+
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
var hueStep = 2; // 色相阶梯
|
|
569
|
+
|
|
570
|
+
var saturationStep = 0.16; // 饱和度阶梯,浅色部分
|
|
571
|
+
|
|
572
|
+
var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
|
|
573
|
+
|
|
574
|
+
var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
|
|
575
|
+
|
|
576
|
+
var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
|
|
577
|
+
|
|
578
|
+
var lightColorCount = 5; // 浅色数量,主色上
|
|
579
|
+
|
|
580
|
+
var darkColorCount = 4; // 深色数量,主色下
|
|
581
|
+
// 暗色主题颜色映射关系表
|
|
582
|
+
|
|
583
|
+
var darkColorMap = [{
|
|
584
|
+
index: 7,
|
|
585
|
+
opacity: 0.15
|
|
586
|
+
}, {
|
|
587
|
+
index: 6,
|
|
588
|
+
opacity: 0.25
|
|
589
|
+
}, {
|
|
590
|
+
index: 5,
|
|
591
|
+
opacity: 0.3
|
|
592
|
+
}, {
|
|
593
|
+
index: 5,
|
|
594
|
+
opacity: 0.45
|
|
595
|
+
}, {
|
|
596
|
+
index: 5,
|
|
597
|
+
opacity: 0.65
|
|
598
|
+
}, {
|
|
599
|
+
index: 5,
|
|
600
|
+
opacity: 0.85
|
|
601
|
+
}, {
|
|
602
|
+
index: 4,
|
|
603
|
+
opacity: 0.9
|
|
604
|
+
}, {
|
|
605
|
+
index: 3,
|
|
606
|
+
opacity: 0.95
|
|
607
|
+
}, {
|
|
608
|
+
index: 2,
|
|
609
|
+
opacity: 0.97
|
|
610
|
+
}, {
|
|
611
|
+
index: 1,
|
|
612
|
+
opacity: 0.98
|
|
613
|
+
}]; // Wrapper function ported from TinyColor.prototype.toHsv
|
|
614
|
+
// Keep it here because of `hsv.h * 360`
|
|
615
|
+
|
|
616
|
+
function toHsv(_ref) {
|
|
617
|
+
var r = _ref.r,
|
|
618
|
+
g = _ref.g,
|
|
619
|
+
b = _ref.b;
|
|
620
|
+
var hsv = rgbToHsv(r, g, b);
|
|
621
|
+
return {
|
|
622
|
+
h: hsv.h * 360,
|
|
623
|
+
s: hsv.s,
|
|
624
|
+
v: hsv.v
|
|
625
|
+
};
|
|
626
|
+
} // Wrapper function ported from TinyColor.prototype.toHexString
|
|
627
|
+
// Keep it here because of the prefix `#`
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
function toHex(_ref2) {
|
|
631
|
+
var r = _ref2.r,
|
|
632
|
+
g = _ref2.g,
|
|
633
|
+
b = _ref2.b;
|
|
634
|
+
return "#".concat(rgbToHex(r, g, b, false));
|
|
635
|
+
} // Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
|
|
636
|
+
// Amount in range [0, 1]
|
|
637
|
+
// Assume color1 & color2 has no alpha, since the following src code did so.
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
function mix(rgb1, rgb2, amount) {
|
|
641
|
+
var p = amount / 100;
|
|
642
|
+
var rgb = {
|
|
643
|
+
r: (rgb2.r - rgb1.r) * p + rgb1.r,
|
|
644
|
+
g: (rgb2.g - rgb1.g) * p + rgb1.g,
|
|
645
|
+
b: (rgb2.b - rgb1.b) * p + rgb1.b
|
|
646
|
+
};
|
|
647
|
+
return rgb;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function getHue(hsv, i, light) {
|
|
651
|
+
var hue; // 根据色相不同,色相转向不同
|
|
652
|
+
|
|
653
|
+
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
|
|
654
|
+
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
|
|
655
|
+
} else {
|
|
656
|
+
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (hue < 0) {
|
|
660
|
+
hue += 360;
|
|
661
|
+
} else if (hue >= 360) {
|
|
662
|
+
hue -= 360;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
return hue;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function getSaturation(hsv, i, light) {
|
|
669
|
+
// grey color don't change saturation
|
|
670
|
+
if (hsv.h === 0 && hsv.s === 0) {
|
|
671
|
+
return hsv.s;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
var saturation;
|
|
675
|
+
|
|
676
|
+
if (light) {
|
|
677
|
+
saturation = hsv.s - saturationStep * i;
|
|
678
|
+
} else if (i === darkColorCount) {
|
|
679
|
+
saturation = hsv.s + saturationStep;
|
|
680
|
+
} else {
|
|
681
|
+
saturation = hsv.s + saturationStep2 * i;
|
|
682
|
+
} // 边界值修正
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
if (saturation > 1) {
|
|
686
|
+
saturation = 1;
|
|
687
|
+
} // 第一格的 s 限制在 0.06-0.1 之间
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
if (light && i === lightColorCount && saturation > 0.1) {
|
|
691
|
+
saturation = 0.1;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
if (saturation < 0.06) {
|
|
695
|
+
saturation = 0.06;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return Number(saturation.toFixed(2));
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
function getValue(hsv, i, light) {
|
|
702
|
+
var value;
|
|
703
|
+
|
|
704
|
+
if (light) {
|
|
705
|
+
value = hsv.v + brightnessStep1 * i;
|
|
706
|
+
} else {
|
|
707
|
+
value = hsv.v - brightnessStep2 * i;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
if (value > 1) {
|
|
711
|
+
value = 1;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
return Number(value.toFixed(2));
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
function generate$1(color) {
|
|
718
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
719
|
+
var patterns = [];
|
|
720
|
+
var pColor = inputToRGB(color);
|
|
721
|
+
|
|
722
|
+
for (var i = lightColorCount; i > 0; i -= 1) {
|
|
723
|
+
var hsv = toHsv(pColor);
|
|
724
|
+
var colorString = toHex(inputToRGB({
|
|
725
|
+
h: getHue(hsv, i, true),
|
|
726
|
+
s: getSaturation(hsv, i, true),
|
|
727
|
+
v: getValue(hsv, i, true)
|
|
728
|
+
}));
|
|
729
|
+
patterns.push(colorString);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
patterns.push(toHex(pColor));
|
|
733
|
+
|
|
734
|
+
for (var _i = 1; _i <= darkColorCount; _i += 1) {
|
|
735
|
+
var _hsv = toHsv(pColor);
|
|
736
|
+
|
|
737
|
+
var _colorString = toHex(inputToRGB({
|
|
738
|
+
h: getHue(_hsv, _i),
|
|
739
|
+
s: getSaturation(_hsv, _i),
|
|
740
|
+
v: getValue(_hsv, _i)
|
|
741
|
+
}));
|
|
742
|
+
|
|
743
|
+
patterns.push(_colorString);
|
|
744
|
+
} // dark theme patterns
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
if (opts.theme === 'dark') {
|
|
748
|
+
return darkColorMap.map(function (_ref3) {
|
|
749
|
+
var index = _ref3.index,
|
|
750
|
+
opacity = _ref3.opacity;
|
|
751
|
+
var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100));
|
|
752
|
+
return darkColorString;
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
return patterns;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
var presetPrimaryColors = {
|
|
760
|
+
red: '#F5222D',
|
|
761
|
+
volcano: '#FA541C',
|
|
762
|
+
orange: '#FA8C16',
|
|
763
|
+
gold: '#FAAD14',
|
|
764
|
+
yellow: '#FADB14',
|
|
765
|
+
lime: '#A0D911',
|
|
766
|
+
green: '#52C41A',
|
|
767
|
+
cyan: '#13C2C2',
|
|
768
|
+
blue: '#1890FF',
|
|
769
|
+
geekblue: '#2F54EB',
|
|
770
|
+
purple: '#722ED1',
|
|
771
|
+
magenta: '#EB2F96',
|
|
772
|
+
grey: '#666666'
|
|
773
|
+
};
|
|
774
|
+
var presetPalettes = {};
|
|
775
|
+
var presetDarkPalettes = {};
|
|
776
|
+
Object.keys(presetPrimaryColors).forEach(function (key) {
|
|
777
|
+
presetPalettes[key] = generate$1(presetPrimaryColors[key]);
|
|
778
|
+
presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes
|
|
779
|
+
|
|
780
|
+
presetDarkPalettes[key] = generate$1(presetPrimaryColors[key], {
|
|
781
|
+
theme: 'dark',
|
|
782
|
+
backgroundColor: '#141414'
|
|
783
|
+
});
|
|
784
|
+
presetDarkPalettes[key].primary = presetDarkPalettes[key][5];
|
|
785
|
+
});
|
|
786
|
+
presetPalettes.red;
|
|
787
|
+
presetPalettes.volcano;
|
|
788
|
+
presetPalettes.gold;
|
|
789
|
+
presetPalettes.orange;
|
|
790
|
+
presetPalettes.yellow;
|
|
791
|
+
presetPalettes.lime;
|
|
792
|
+
presetPalettes.green;
|
|
793
|
+
presetPalettes.cyan;
|
|
794
|
+
presetPalettes.blue;
|
|
795
|
+
presetPalettes.geekblue;
|
|
796
|
+
presetPalettes.purple;
|
|
797
|
+
presetPalettes.magenta;
|
|
798
|
+
presetPalettes.grey;
|
|
799
|
+
|
|
800
|
+
// https://github.com/substack/insert-css
|
|
801
|
+
var containers = []; // will store container HTMLElement references
|
|
802
|
+
|
|
803
|
+
var styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement}
|
|
804
|
+
|
|
805
|
+
var usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).';
|
|
806
|
+
|
|
807
|
+
function createStyleElement() {
|
|
808
|
+
var styleElement = document.createElement('style');
|
|
809
|
+
styleElement.setAttribute('type', 'text/css');
|
|
810
|
+
return styleElement;
|
|
811
|
+
} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
function insertCss(css, options) {
|
|
815
|
+
options = options || {};
|
|
816
|
+
|
|
817
|
+
if (css === undefined) {
|
|
818
|
+
throw new Error(usage);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
var position = options.prepend === true ? 'prepend' : 'append';
|
|
822
|
+
var container = options.container !== undefined ? options.container : document.querySelector('head');
|
|
823
|
+
var containerId = containers.indexOf(container); // first time we see this container, create the necessary entries
|
|
824
|
+
|
|
825
|
+
if (containerId === -1) {
|
|
826
|
+
containerId = containers.push(container) - 1;
|
|
827
|
+
styleElements[containerId] = {};
|
|
828
|
+
} // try to get the correponding container + position styleElement, create it otherwise
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
var styleElement;
|
|
832
|
+
|
|
833
|
+
if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) {
|
|
834
|
+
styleElement = styleElements[containerId][position];
|
|
835
|
+
} else {
|
|
836
|
+
styleElement = styleElements[containerId][position] = createStyleElement();
|
|
837
|
+
|
|
838
|
+
if (position === 'prepend') {
|
|
839
|
+
container.insertBefore(styleElement, container.childNodes[0]);
|
|
840
|
+
} else {
|
|
841
|
+
container.appendChild(styleElement);
|
|
842
|
+
}
|
|
843
|
+
} // strip potential UTF-8 BOM if css was read from a file
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
if (css.charCodeAt(0) === 0xfeff) {
|
|
847
|
+
css = css.substr(1, css.length);
|
|
848
|
+
} // actually add the stylesheet
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
if (styleElement.styleSheet) {
|
|
852
|
+
styleElement.styleSheet.cssText += css;
|
|
853
|
+
} else {
|
|
854
|
+
styleElement.textContent += css;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
return styleElement;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
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; }
|
|
861
|
+
|
|
862
|
+
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; }
|
|
863
|
+
function warn(valid, message) {
|
|
864
|
+
// Support uglify
|
|
865
|
+
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
866
|
+
console.error("Warning: ".concat(message));
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
function warning(valid, message) {
|
|
870
|
+
warn(valid, "[@ant-design/icons-vue] ".concat(message));
|
|
871
|
+
} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
872
|
+
|
|
873
|
+
function isIconDefinition(target) {
|
|
874
|
+
return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
|
|
875
|
+
}
|
|
876
|
+
function generate(node, key, rootProps) {
|
|
877
|
+
if (!rootProps) {
|
|
878
|
+
return h(node.tag, _objectSpread$3({
|
|
879
|
+
key: key
|
|
880
|
+
}, node.attrs), (node.children || []).map(function (child, index) {
|
|
881
|
+
return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
|
|
882
|
+
}));
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
return h(node.tag, _objectSpread$3({
|
|
886
|
+
key: key
|
|
887
|
+
}, rootProps, node.attrs), (node.children || []).map(function (child, index) {
|
|
888
|
+
return generate(child, "".concat(key, "-").concat(node.tag, "-").concat(index));
|
|
889
|
+
}));
|
|
890
|
+
}
|
|
891
|
+
function getSecondaryColor(primaryColor) {
|
|
892
|
+
// choose the second color
|
|
893
|
+
return generate$1(primaryColor)[0];
|
|
894
|
+
}
|
|
895
|
+
function normalizeTwoToneColors(twoToneColor) {
|
|
896
|
+
if (!twoToneColor) {
|
|
897
|
+
return [];
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];
|
|
901
|
+
} // These props make sure that the SVG behaviours like general text.
|
|
902
|
+
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";
|
|
903
|
+
var cssInjectedFlag = false;
|
|
904
|
+
var useInsertStyles = function useInsertStyles() {
|
|
905
|
+
var styleStr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : iconStyles;
|
|
906
|
+
nextTick(function () {
|
|
907
|
+
if (!cssInjectedFlag) {
|
|
908
|
+
if (typeof window !== 'undefined' && window.document && window.document.documentElement) {
|
|
909
|
+
insertCss(styleStr, {
|
|
910
|
+
prepend: true
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
cssInjectedFlag = true;
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
};
|
|
918
|
+
|
|
919
|
+
var _excluded$1 = ["icon", "primaryColor", "secondaryColor"];
|
|
920
|
+
|
|
921
|
+
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; }
|
|
922
|
+
|
|
923
|
+
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; }
|
|
924
|
+
|
|
925
|
+
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; }
|
|
926
|
+
|
|
927
|
+
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; }
|
|
928
|
+
var twoToneColorPalette = {
|
|
929
|
+
primaryColor: '#333',
|
|
930
|
+
secondaryColor: '#E6E6E6',
|
|
931
|
+
calculated: false
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
function setTwoToneColors(_ref) {
|
|
935
|
+
var primaryColor = _ref.primaryColor,
|
|
936
|
+
secondaryColor = _ref.secondaryColor;
|
|
937
|
+
twoToneColorPalette.primaryColor = primaryColor;
|
|
938
|
+
twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor);
|
|
939
|
+
twoToneColorPalette.calculated = !!secondaryColor;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
function getTwoToneColors() {
|
|
943
|
+
return _objectSpread$2({}, twoToneColorPalette);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
var IconBase = function IconBase(props, context) {
|
|
947
|
+
var _props$context$attrs = _objectSpread$2({}, props, context.attrs),
|
|
948
|
+
icon = _props$context$attrs.icon,
|
|
949
|
+
primaryColor = _props$context$attrs.primaryColor,
|
|
950
|
+
secondaryColor = _props$context$attrs.secondaryColor,
|
|
951
|
+
restProps = _objectWithoutProperties$1(_props$context$attrs, _excluded$1);
|
|
952
|
+
|
|
953
|
+
var colors = twoToneColorPalette;
|
|
954
|
+
|
|
955
|
+
if (primaryColor) {
|
|
956
|
+
colors = {
|
|
957
|
+
primaryColor: primaryColor,
|
|
958
|
+
secondaryColor: secondaryColor || getSecondaryColor(primaryColor)
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
useInsertStyles();
|
|
963
|
+
warning(isIconDefinition(icon), "icon should be icon definiton, but got ".concat(icon));
|
|
964
|
+
|
|
965
|
+
if (!isIconDefinition(icon)) {
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
var target = icon;
|
|
970
|
+
|
|
971
|
+
if (target && typeof target.icon === 'function') {
|
|
972
|
+
target = _objectSpread$2({}, target, {
|
|
973
|
+
icon: target.icon(colors.primaryColor, colors.secondaryColor)
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
return generate(target.icon, "svg-".concat(target.name), _objectSpread$2({}, restProps, {
|
|
978
|
+
'data-icon': target.name,
|
|
979
|
+
width: '1em',
|
|
980
|
+
height: '1em',
|
|
981
|
+
fill: 'currentColor',
|
|
982
|
+
'aria-hidden': 'true'
|
|
983
|
+
})); // },
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
IconBase.props = {
|
|
987
|
+
icon: Object,
|
|
988
|
+
primaryColor: String,
|
|
989
|
+
secondaryColor: String,
|
|
990
|
+
focusable: String
|
|
991
|
+
};
|
|
992
|
+
IconBase.inheritAttrs = false;
|
|
993
|
+
IconBase.displayName = 'IconBase';
|
|
994
|
+
IconBase.getTwoToneColors = getTwoToneColors;
|
|
995
|
+
IconBase.setTwoToneColors = setTwoToneColors;
|
|
996
|
+
var VueIcon = IconBase;
|
|
997
|
+
|
|
998
|
+
function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1(); }
|
|
999
|
+
|
|
1000
|
+
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."); }
|
|
1001
|
+
|
|
1002
|
+
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); }
|
|
1003
|
+
|
|
1004
|
+
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; }
|
|
1005
|
+
|
|
1006
|
+
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; }
|
|
1007
|
+
|
|
1008
|
+
function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
|
|
1009
|
+
function setTwoToneColor(twoToneColor) {
|
|
1010
|
+
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
|
|
1011
|
+
_normalizeTwoToneColo2 = _slicedToArray$1(_normalizeTwoToneColo, 2),
|
|
1012
|
+
primaryColor = _normalizeTwoToneColo2[0],
|
|
1013
|
+
secondaryColor = _normalizeTwoToneColo2[1];
|
|
1014
|
+
|
|
1015
|
+
return VueIcon.setTwoToneColors({
|
|
1016
|
+
primaryColor: primaryColor,
|
|
1017
|
+
secondaryColor: secondaryColor
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
function getTwoToneColor() {
|
|
1021
|
+
var colors = VueIcon.getTwoToneColors();
|
|
1022
|
+
|
|
1023
|
+
if (!colors.calculated) {
|
|
1024
|
+
return colors.primaryColor;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
return [colors.primaryColor, colors.secondaryColor];
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
var _excluded = ["class", "icon", "spin", "rotate", "tabindex", "twoToneColor", "onClick"];
|
|
1031
|
+
|
|
1032
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
1033
|
+
|
|
1034
|
+
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."); }
|
|
1035
|
+
|
|
1036
|
+
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); }
|
|
1037
|
+
|
|
1038
|
+
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; }
|
|
1039
|
+
|
|
1040
|
+
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; }
|
|
1041
|
+
|
|
1042
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1043
|
+
|
|
1044
|
+
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; }
|
|
1045
|
+
|
|
1046
|
+
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; }
|
|
1047
|
+
|
|
1048
|
+
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; }
|
|
1049
|
+
|
|
1050
|
+
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; }
|
|
1051
|
+
|
|
1052
|
+
setTwoToneColor('#1890ff');
|
|
1053
|
+
|
|
1054
|
+
var Icon = function Icon(props, context) {
|
|
1055
|
+
var _classObj;
|
|
1056
|
+
|
|
1057
|
+
var _props$context$attrs = _objectSpread$1({}, props, context.attrs),
|
|
1058
|
+
cls = _props$context$attrs["class"],
|
|
1059
|
+
icon = _props$context$attrs.icon,
|
|
1060
|
+
spin = _props$context$attrs.spin,
|
|
1061
|
+
rotate = _props$context$attrs.rotate,
|
|
1062
|
+
tabindex = _props$context$attrs.tabindex,
|
|
1063
|
+
twoToneColor = _props$context$attrs.twoToneColor,
|
|
1064
|
+
onClick = _props$context$attrs.onClick,
|
|
1065
|
+
restProps = _objectWithoutProperties(_props$context$attrs, _excluded);
|
|
1066
|
+
|
|
1067
|
+
var classObj = (_classObj = {
|
|
1068
|
+
anticon: true
|
|
1069
|
+
}, _defineProperty$1(_classObj, "anticon-".concat(icon.name), Boolean(icon.name)), _defineProperty$1(_classObj, cls, cls), _classObj);
|
|
1070
|
+
var svgClassString = spin === '' || !!spin || icon.name === 'loading' ? 'anticon-spin' : '';
|
|
1071
|
+
var iconTabIndex = tabindex;
|
|
1072
|
+
|
|
1073
|
+
if (iconTabIndex === undefined && onClick) {
|
|
1074
|
+
iconTabIndex = -1;
|
|
1075
|
+
restProps.tabindex = iconTabIndex;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
var svgStyle = rotate ? {
|
|
1079
|
+
msTransform: "rotate(".concat(rotate, "deg)"),
|
|
1080
|
+
transform: "rotate(".concat(rotate, "deg)")
|
|
1081
|
+
} : undefined;
|
|
1082
|
+
|
|
1083
|
+
var _normalizeTwoToneColo = normalizeTwoToneColors(twoToneColor),
|
|
1084
|
+
_normalizeTwoToneColo2 = _slicedToArray(_normalizeTwoToneColo, 2),
|
|
1085
|
+
primaryColor = _normalizeTwoToneColo2[0],
|
|
1086
|
+
secondaryColor = _normalizeTwoToneColo2[1];
|
|
1087
|
+
|
|
1088
|
+
return createVNode("span", _objectSpread$1({
|
|
1089
|
+
"role": "img",
|
|
1090
|
+
"aria-label": icon.name
|
|
1091
|
+
}, restProps, {
|
|
1092
|
+
"onClick": onClick,
|
|
1093
|
+
"class": classObj
|
|
1094
|
+
}), [createVNode(VueIcon, {
|
|
1095
|
+
"class": svgClassString,
|
|
1096
|
+
"icon": icon,
|
|
1097
|
+
"primaryColor": primaryColor,
|
|
1098
|
+
"secondaryColor": secondaryColor,
|
|
1099
|
+
"style": svgStyle
|
|
1100
|
+
}, null)]);
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
Icon.props = {
|
|
1104
|
+
spin: Boolean,
|
|
1105
|
+
rotate: Number,
|
|
1106
|
+
icon: Object,
|
|
1107
|
+
twoToneColor: String
|
|
1108
|
+
};
|
|
1109
|
+
Icon.displayName = 'AntdIcon';
|
|
1110
|
+
Icon.inheritAttrs = false;
|
|
1111
|
+
Icon.getTwoToneColor = getTwoToneColor;
|
|
1112
|
+
Icon.setTwoToneColor = setTwoToneColor;
|
|
1113
|
+
var AntdIcon = Icon;
|
|
1114
|
+
|
|
1115
|
+
// This icon file is generated automatically.
|
|
1116
|
+
var CloseCircleFilled$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z" } }] }, "name": "close-circle", "theme": "filled" };
|
|
1117
|
+
var CloseCircleFilledSvg = CloseCircleFilled$2;
|
|
1118
|
+
|
|
1119
|
+
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; }
|
|
1120
|
+
|
|
1121
|
+
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; }
|
|
1122
|
+
|
|
1123
|
+
var CloseCircleFilled = function CloseCircleFilled(props, context) {
|
|
1124
|
+
var p = _objectSpread({}, props, context.attrs);
|
|
1125
|
+
|
|
1126
|
+
return createVNode(AntdIcon, _objectSpread({}, p, {
|
|
1127
|
+
"icon": CloseCircleFilledSvg
|
|
1128
|
+
}), null);
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
CloseCircleFilled.displayName = 'CloseCircleFilled';
|
|
1132
|
+
CloseCircleFilled.inheritAttrs = false;
|
|
1133
|
+
var CloseCircleFilled$1 = CloseCircleFilled;
|
|
1134
|
+
|
|
1135
|
+
var _export_sfc = (sfc, props) => {
|
|
1136
|
+
const target = sfc.__vccOpts || sfc;
|
|
1137
|
+
for (const [key, val] of props) {
|
|
1138
|
+
target[key] = val;
|
|
1139
|
+
}
|
|
1140
|
+
return target;
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
const _sfc_main$3 = defineComponent({
|
|
1144
|
+
components: { CloseCircleFilled: CloseCircleFilled$1, Empty, AInput, Checkbox, ATree },
|
|
1145
|
+
props: {
|
|
1146
|
+
limit: {
|
|
1147
|
+
type: Number,
|
|
1148
|
+
default: 0
|
|
1149
|
+
},
|
|
1150
|
+
list: {
|
|
1151
|
+
type: Array,
|
|
1152
|
+
default: () => []
|
|
1153
|
+
},
|
|
1154
|
+
selected: {
|
|
1155
|
+
type: Array,
|
|
1156
|
+
default: () => []
|
|
1157
|
+
},
|
|
1158
|
+
dataMap: {
|
|
1159
|
+
type: Map,
|
|
1160
|
+
default: () => /* @__PURE__ */ new Map()
|
|
1161
|
+
},
|
|
1162
|
+
isTree: {
|
|
1163
|
+
type: Boolean,
|
|
1164
|
+
default: false
|
|
1165
|
+
},
|
|
1166
|
+
curlistKeys: {
|
|
1167
|
+
type: Set,
|
|
1168
|
+
default: () => /* @__PURE__ */ new Set()
|
|
1169
|
+
}
|
|
1170
|
+
},
|
|
1171
|
+
emits: ["fetchList", "update:selected"],
|
|
1172
|
+
setup(props, { emit }) {
|
|
1173
|
+
const state = reactive({
|
|
1174
|
+
searchVal: "",
|
|
1175
|
+
selectAll: false,
|
|
1176
|
+
indeterminate: false,
|
|
1177
|
+
emptyPic: Empty.PRESENTED_IMAGE_SIMPLE,
|
|
1178
|
+
listChecked: {},
|
|
1179
|
+
isFulfill: false,
|
|
1180
|
+
departmentChecked: {}
|
|
1181
|
+
});
|
|
1182
|
+
const methods = {
|
|
1183
|
+
changeAllOption() {
|
|
1184
|
+
let status = state.selectAll;
|
|
1185
|
+
let length = props.selected.length;
|
|
1186
|
+
props.list.forEach((item) => {
|
|
1187
|
+
if (status && props.limit > 0 && length++ >= props.limit)
|
|
1188
|
+
return;
|
|
1189
|
+
state.listChecked[item.key] = status;
|
|
1190
|
+
});
|
|
1191
|
+
},
|
|
1192
|
+
search() {
|
|
1193
|
+
let data = state.searchVal ? { searchVal: state.searchVal } : false;
|
|
1194
|
+
emit("fetchList", data);
|
|
1195
|
+
},
|
|
1196
|
+
setState() {
|
|
1197
|
+
let indeterminate = false;
|
|
1198
|
+
let selectAll = true;
|
|
1199
|
+
props.list.forEach((item) => {
|
|
1200
|
+
if (!state.listChecked[item.key]) {
|
|
1201
|
+
selectAll = false;
|
|
1202
|
+
} else {
|
|
1203
|
+
indeterminate = true;
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
state.selectAll = selectAll;
|
|
1207
|
+
state.indeterminate = selectAll ? false : indeterminate;
|
|
1208
|
+
},
|
|
1209
|
+
deleteOption(key) {
|
|
1210
|
+
if (props.isTree) {
|
|
1211
|
+
let list = [].concat(state.departmentChecked);
|
|
1212
|
+
let result = [];
|
|
1213
|
+
list.forEach((item) => {
|
|
1214
|
+
if (!(item === key || props.dataMap.get(item) && key === props.dataMap.get(item)["parent"])) {
|
|
1215
|
+
result.push(item);
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
state.departmentChecked = Array.from(new Set(result));
|
|
1219
|
+
} else {
|
|
1220
|
+
state.listChecked[key] = false;
|
|
1221
|
+
}
|
|
1222
|
+
},
|
|
1223
|
+
getSelectName(key) {
|
|
1224
|
+
let data = props.dataMap.get(String(key)) || null;
|
|
1225
|
+
return data ? data.title : "\u672A\u77E5";
|
|
1226
|
+
}
|
|
1227
|
+
};
|
|
1228
|
+
watch(() => state.listChecked, () => {
|
|
1229
|
+
let list = [];
|
|
1230
|
+
for (let [key, value] of Object.entries(state.listChecked)) {
|
|
1231
|
+
value && list.push(key);
|
|
1232
|
+
}
|
|
1233
|
+
if (props.limit > 0 && list.length >= props.limit)
|
|
1234
|
+
state.isFulfill = true;
|
|
1235
|
+
else
|
|
1236
|
+
state.isFulfill = false;
|
|
1237
|
+
methods.setState();
|
|
1238
|
+
emit("update:selected", list);
|
|
1239
|
+
}, { deep: true });
|
|
1240
|
+
watch(() => state.departmentChecked, () => {
|
|
1241
|
+
let flatMap = props.dataMap;
|
|
1242
|
+
let curlistKeys = props.curlistKeys;
|
|
1243
|
+
let hadselected = new Set(props.selected);
|
|
1244
|
+
let curselect = new Set(state.departmentChecked);
|
|
1245
|
+
for (let key of hadselected) {
|
|
1246
|
+
if (curlistKeys.has(key) && (!curselect.has(key) || curselect.has(key) && curselect.has(flatMap.get(key)["parent"]))) {
|
|
1247
|
+
hadselected.delete(key);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
for (let key of curselect) {
|
|
1251
|
+
let obj = flatMap.get(key);
|
|
1252
|
+
if (obj && !curselect.has(obj["parent"])) {
|
|
1253
|
+
hadselected.add(key);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
emit("update:selected", Array.from(hadselected));
|
|
1257
|
+
}, { deep: true });
|
|
1258
|
+
watch(() => props.list, () => {
|
|
1259
|
+
!props.isTree && methods.setState();
|
|
1260
|
+
});
|
|
1261
|
+
onMounted(() => {
|
|
1262
|
+
let list = props.selected;
|
|
1263
|
+
list && list.forEach((key) => {
|
|
1264
|
+
state.listChecked[key] = true;
|
|
1265
|
+
});
|
|
1266
|
+
});
|
|
1267
|
+
return {
|
|
1268
|
+
...toRefs(state),
|
|
1269
|
+
...methods
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
const _hoisted_1$3 = { class: "multiple-selector" };
|
|
1274
|
+
const _hoisted_2$2 = { class: "__selector-modal-panel" };
|
|
1275
|
+
const _hoisted_3$2 = { class: "__search-panel" };
|
|
1276
|
+
const _hoisted_4$2 = { class: "__selector-modal-options" };
|
|
1277
|
+
const _hoisted_5$2 = { class: "__selector-modal-options-item fixed-option" };
|
|
1278
|
+
const _hoisted_6$1 = /* @__PURE__ */ createTextVNode("\u5168\u9009");
|
|
1279
|
+
const _hoisted_7$1 = { class: "department-option-item" };
|
|
1280
|
+
const _hoisted_8$1 = {
|
|
1281
|
+
key: 0,
|
|
1282
|
+
class: "department-desc"
|
|
1283
|
+
};
|
|
1284
|
+
const _hoisted_9$1 = {
|
|
1285
|
+
key: 2,
|
|
1286
|
+
class: "noData",
|
|
1287
|
+
style: { "height": "280px" }
|
|
1288
|
+
};
|
|
1289
|
+
const _hoisted_10$1 = { style: { "color": "#9393a3", "font-size": "12px", "font-weight": "400" } };
|
|
1290
|
+
const _hoisted_11$1 = { class: "__selector-chosen-panel" };
|
|
1291
|
+
const _hoisted_12$1 = { class: "__chosen-panel-tip" };
|
|
1292
|
+
const _hoisted_13$1 = {
|
|
1293
|
+
key: 0,
|
|
1294
|
+
class: "__limit-tip"
|
|
1295
|
+
};
|
|
1296
|
+
const _hoisted_14$1 = { class: "__chosen-panel-list" };
|
|
1297
|
+
const _hoisted_15$1 = { class: "__tiem-title" };
|
|
1298
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1299
|
+
const _component_search_outlined = resolveComponent("search-outlined");
|
|
1300
|
+
const _component_AInput = resolveComponent("AInput");
|
|
1301
|
+
const _component_Checkbox = resolveComponent("Checkbox");
|
|
1302
|
+
const _component_ATree = resolveComponent("ATree");
|
|
1303
|
+
const _component_Empty = resolveComponent("Empty");
|
|
1304
|
+
const _component_CloseCircleFilled = resolveComponent("CloseCircleFilled");
|
|
1305
|
+
return openBlock(), createElementBlock("div", _hoisted_1$3, [
|
|
1306
|
+
createElementVNode("div", _hoisted_2$2, [
|
|
1307
|
+
createElementVNode("div", _hoisted_3$2, [
|
|
1308
|
+
createVNode(_component_AInput, {
|
|
1309
|
+
value: _ctx.searchVal,
|
|
1310
|
+
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.searchVal = $event),
|
|
1311
|
+
placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D\u6216\u7F16\u53F7",
|
|
1312
|
+
onChange: _ctx.search
|
|
1313
|
+
}, {
|
|
1314
|
+
suffix: withCtx(() => [
|
|
1315
|
+
createVNode(_component_search_outlined, { style: { color: "#9393A3" } })
|
|
1316
|
+
]),
|
|
1317
|
+
_: 1
|
|
1318
|
+
}, 8, ["value", "onChange"]),
|
|
1319
|
+
createElementVNode("div", _hoisted_4$2, [
|
|
1320
|
+
!_ctx.isTree ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
1321
|
+
createElementVNode("div", _hoisted_5$2, [
|
|
1322
|
+
withDirectives(createVNode(_component_Checkbox, {
|
|
1323
|
+
checked: _ctx.selectAll,
|
|
1324
|
+
"onUpdate:checked": _cache[1] || (_cache[1] = ($event) => _ctx.selectAll = $event),
|
|
1325
|
+
indeterminate: _ctx.indeterminate,
|
|
1326
|
+
onChange: _ctx.changeAllOption
|
|
1327
|
+
}, {
|
|
1328
|
+
default: withCtx(() => [
|
|
1329
|
+
_hoisted_6$1
|
|
1330
|
+
]),
|
|
1331
|
+
_: 1
|
|
1332
|
+
}, 8, ["checked", "indeterminate", "onChange"]), [
|
|
1333
|
+
[vShow, _ctx.list.length]
|
|
1334
|
+
])
|
|
1335
|
+
]),
|
|
1336
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (item) => {
|
|
1337
|
+
return openBlock(), createElementBlock("div", {
|
|
1338
|
+
key: item.key,
|
|
1339
|
+
class: "__selector-modal-options-item"
|
|
1340
|
+
}, [
|
|
1341
|
+
createVNode(_component_Checkbox, {
|
|
1342
|
+
checked: _ctx.listChecked[item.key],
|
|
1343
|
+
"onUpdate:checked": ($event) => _ctx.listChecked[item.key] = $event,
|
|
1344
|
+
class: "__selector-modal-option-check",
|
|
1345
|
+
disabled: _ctx.isFulfill
|
|
1346
|
+
}, {
|
|
1347
|
+
default: withCtx(() => [
|
|
1348
|
+
createTextVNode(toDisplayString(item.title), 1)
|
|
1349
|
+
]),
|
|
1350
|
+
_: 2
|
|
1351
|
+
}, 1032, ["checked", "onUpdate:checked", "disabled"])
|
|
1352
|
+
]);
|
|
1353
|
+
}), 128))
|
|
1354
|
+
], 64)) : _ctx.isTree ? (openBlock(), createBlock(_component_ATree, {
|
|
1355
|
+
key: 1,
|
|
1356
|
+
checkedKeys: _ctx.departmentChecked,
|
|
1357
|
+
"onUpdate:checkedKeys": _cache[2] || (_cache[2] = ($event) => _ctx.departmentChecked = $event),
|
|
1358
|
+
checkable: "",
|
|
1359
|
+
"tree-data": _ctx.list
|
|
1360
|
+
}, {
|
|
1361
|
+
title: withCtx(({ title, description }) => [
|
|
1362
|
+
createElementVNode("div", _hoisted_7$1, [
|
|
1363
|
+
createElementVNode("span", null, toDisplayString(title), 1),
|
|
1364
|
+
description ? (openBlock(), createElementBlock("p", _hoisted_8$1, toDisplayString(description), 1)) : createCommentVNode("v-if", true)
|
|
1365
|
+
])
|
|
1366
|
+
]),
|
|
1367
|
+
_: 1
|
|
1368
|
+
}, 8, ["checkedKeys", "tree-data"])) : createCommentVNode("v-if", true),
|
|
1369
|
+
_ctx.list && !_ctx.list.length ? (openBlock(), createElementBlock("div", _hoisted_9$1, [
|
|
1370
|
+
createVNode(_component_Empty, { image: _ctx.emptyPic }, {
|
|
1371
|
+
description: withCtx(() => [
|
|
1372
|
+
createElementVNode("span", _hoisted_10$1, toDisplayString(!!_ctx.searchVal ? "\u6682\u65E0\u6570\u636E" : "\u8BF7\u5148\u641C\u7D22\u4EBA\u5458\u5173\u952E\u5B57"), 1)
|
|
1373
|
+
]),
|
|
1374
|
+
_: 1
|
|
1375
|
+
}, 8, ["image"])
|
|
1376
|
+
])) : createCommentVNode("v-if", true)
|
|
1377
|
+
])
|
|
1378
|
+
])
|
|
1379
|
+
]),
|
|
1380
|
+
createElementVNode("div", _hoisted_11$1, [
|
|
1381
|
+
createElementVNode("div", _hoisted_12$1, [
|
|
1382
|
+
createElementVNode("span", null, "\u5DF2\u9009\u62E9" + toDisplayString(_ctx.selected && _ctx.selected.length || 0) + "\u4EBA", 1),
|
|
1383
|
+
_ctx.limit ? (openBlock(), createElementBlock("span", _hoisted_13$1, "\u6700\u591A\u9009\u62E9" + toDisplayString(_ctx.limit) + "\u4EBA", 1)) : createCommentVNode("v-if", true)
|
|
1384
|
+
]),
|
|
1385
|
+
createElementVNode("div", _hoisted_14$1, [
|
|
1386
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.selected, (item) => {
|
|
1387
|
+
return openBlock(), createElementBlock("div", {
|
|
1388
|
+
key: item + "checked",
|
|
1389
|
+
class: "__chosen-panel-list-item"
|
|
1390
|
+
}, [
|
|
1391
|
+
createElementVNode("span", _hoisted_15$1, toDisplayString(_ctx.getSelectName(item)), 1),
|
|
1392
|
+
createVNode(_component_CloseCircleFilled, {
|
|
1393
|
+
style: { "color": "#ced1d9" },
|
|
1394
|
+
onMousedown: withModifiers(($event) => _ctx.deleteOption(item), ["stop"])
|
|
1395
|
+
}, null, 8, ["onMousedown"])
|
|
1396
|
+
]);
|
|
1397
|
+
}), 128))
|
|
1398
|
+
])
|
|
1399
|
+
])
|
|
1400
|
+
]);
|
|
1401
|
+
}
|
|
1402
|
+
var multipleCmp = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__file", "multipleCmp.vue"]]);
|
|
1403
|
+
|
|
1404
|
+
const _sfc_main$2 = defineComponent({
|
|
1405
|
+
name: "RadioCmp",
|
|
1406
|
+
components: { ARadio, AInput, ARadioGroup: Group },
|
|
1407
|
+
props: {
|
|
1408
|
+
list: {
|
|
1409
|
+
type: Array,
|
|
1410
|
+
default: () => []
|
|
1411
|
+
},
|
|
1412
|
+
selected: {
|
|
1413
|
+
type: String || Number || Object,
|
|
1414
|
+
default: ""
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
emits: ["fetchList", "update:selected"],
|
|
1418
|
+
setup(_, { emit }) {
|
|
1419
|
+
const searchVal = ref("");
|
|
1420
|
+
const emptyPic = Empty.PRESENTED_IMAGE_SIMPLE;
|
|
1421
|
+
function search() {
|
|
1422
|
+
let data = searchVal.value ? { searchVal: searchVal.value } : false;
|
|
1423
|
+
emit("fetchList", data);
|
|
1424
|
+
}
|
|
1425
|
+
function radioChange(e) {
|
|
1426
|
+
emit("update:selected", e.target.value);
|
|
1427
|
+
}
|
|
1428
|
+
return {
|
|
1429
|
+
searchVal,
|
|
1430
|
+
emptyPic,
|
|
1431
|
+
search,
|
|
1432
|
+
radioChange
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
const _hoisted_1$2 = { class: "radio-selector-panel" };
|
|
1437
|
+
const _hoisted_2$1 = { class: "__search-panel withoutpad" };
|
|
1438
|
+
const _hoisted_3$1 = {
|
|
1439
|
+
key: 0,
|
|
1440
|
+
class: "__selector-modal-options __radio-panel"
|
|
1441
|
+
};
|
|
1442
|
+
const _hoisted_4$1 = {
|
|
1443
|
+
key: 1,
|
|
1444
|
+
class: "noData"
|
|
1445
|
+
};
|
|
1446
|
+
const _hoisted_5$1 = { style: { "color": "#9393a3", "font-size": "12px", "font-weight": "400" } };
|
|
1447
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1448
|
+
const _component_search_outlined = resolveComponent("search-outlined");
|
|
1449
|
+
const _component_a_input = resolveComponent("a-input");
|
|
1450
|
+
const _component_ARadio = resolveComponent("ARadio");
|
|
1451
|
+
const _component_ARadioGroup = resolveComponent("ARadioGroup");
|
|
1452
|
+
const _component_Empty = resolveComponent("Empty");
|
|
1453
|
+
return openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
1454
|
+
createElementVNode("div", _hoisted_2$1, [
|
|
1455
|
+
createVNode(_component_a_input, {
|
|
1456
|
+
value: _ctx.searchVal,
|
|
1457
|
+
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.searchVal = $event),
|
|
1458
|
+
placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D\u6216\u7F16\u53F7",
|
|
1459
|
+
onChange: _ctx.search
|
|
1460
|
+
}, {
|
|
1461
|
+
suffix: withCtx(() => [
|
|
1462
|
+
createVNode(_component_search_outlined, { style: { color: "#9393A3" } })
|
|
1463
|
+
]),
|
|
1464
|
+
_: 1
|
|
1465
|
+
}, 8, ["value", "onChange"]),
|
|
1466
|
+
_ctx.list && _ctx.list.length ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
|
|
1467
|
+
createVNode(_component_ARadioGroup, {
|
|
1468
|
+
value: _ctx.selected,
|
|
1469
|
+
style: { width: "100%" },
|
|
1470
|
+
onChange: _ctx.radioChange
|
|
1471
|
+
}, {
|
|
1472
|
+
default: withCtx(() => [
|
|
1473
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (item) => {
|
|
1474
|
+
return openBlock(), createBlock(_component_ARadio, {
|
|
1475
|
+
key: item.key,
|
|
1476
|
+
class: "__radio-option",
|
|
1477
|
+
value: item.key
|
|
1478
|
+
}, {
|
|
1479
|
+
default: withCtx(() => [
|
|
1480
|
+
createTextVNode(toDisplayString(item.title), 1)
|
|
1481
|
+
]),
|
|
1482
|
+
_: 2
|
|
1483
|
+
}, 1032, ["value"]);
|
|
1484
|
+
}), 128))
|
|
1485
|
+
]),
|
|
1486
|
+
_: 1
|
|
1487
|
+
}, 8, ["value", "onChange"])
|
|
1488
|
+
])) : createCommentVNode("v-if", true),
|
|
1489
|
+
_ctx.list && !_ctx.list.length ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
|
|
1490
|
+
createVNode(_component_Empty, { image: _ctx.emptyPic }, {
|
|
1491
|
+
description: withCtx(() => [
|
|
1492
|
+
createElementVNode("span", _hoisted_5$1, toDisplayString(!!_ctx.searchVal ? "\u6682\u65E0\u6570\u636E" : "\u8BF7\u5148\u641C\u7D22\u4EBA\u5458\u5173\u952E\u5B57"), 1)
|
|
1493
|
+
]),
|
|
1494
|
+
_: 1
|
|
1495
|
+
}, 8, ["image"])
|
|
1496
|
+
])) : createCommentVNode("v-if", true)
|
|
1497
|
+
])
|
|
1498
|
+
]);
|
|
1499
|
+
}
|
|
1500
|
+
var radioCmp = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__file", "radioCmp.vue"]]);
|
|
1501
|
+
|
|
1502
|
+
const _sfc_main$1 = defineComponent({
|
|
1503
|
+
name: "VariedCmp",
|
|
1504
|
+
components: { CloseCircleFilled: CloseCircleFilled$1, AInput, Checkbox, ATree },
|
|
1505
|
+
props: {
|
|
1506
|
+
list: {
|
|
1507
|
+
type: Array,
|
|
1508
|
+
default: () => []
|
|
1509
|
+
},
|
|
1510
|
+
selected: {
|
|
1511
|
+
type: Array,
|
|
1512
|
+
default: () => []
|
|
1513
|
+
},
|
|
1514
|
+
dataMap: {
|
|
1515
|
+
type: Map,
|
|
1516
|
+
default: () => /* @__PURE__ */ new Map()
|
|
1517
|
+
},
|
|
1518
|
+
curlistKeys: {
|
|
1519
|
+
type: Set,
|
|
1520
|
+
default: () => /* @__PURE__ */ new Set()
|
|
1521
|
+
}
|
|
1522
|
+
},
|
|
1523
|
+
emits: ["fetchList", "update:selected"],
|
|
1524
|
+
setup(props, { emit }) {
|
|
1525
|
+
const emptyPic = Empty.PRESENTED_IMAGE_SIMPLE;
|
|
1526
|
+
const activeKey = ref(0);
|
|
1527
|
+
const searchVal = ref("");
|
|
1528
|
+
const staffsChecked = ref({});
|
|
1529
|
+
const groupChecked = ref({});
|
|
1530
|
+
const departmentChecked = ref([]);
|
|
1531
|
+
const shopChecked = ref({});
|
|
1532
|
+
const inputPlaceHolder = computed(() => {
|
|
1533
|
+
if (activeKey.value === 2) {
|
|
1534
|
+
return "\u8BF7\u8F93\u5165\u90E8\u95E8\u641C\u7D22";
|
|
1535
|
+
} else if (activeKey.value === 3) {
|
|
1536
|
+
return "\u8BF7\u8F93\u5165\u5DE5\u4F5C\u7EC4\u641C\u7D22";
|
|
1537
|
+
} else if (activeKey.value === 4) {
|
|
1538
|
+
return "\u8BF7\u8F93\u5165\u5E97\u94FA\u641C\u7D22";
|
|
1539
|
+
}
|
|
1540
|
+
return "\u8BF7\u8F93\u5165\u4EBA\u540D\u641C\u7D22";
|
|
1541
|
+
});
|
|
1542
|
+
const areas = readonly([
|
|
1543
|
+
{ title: "\u6210\u5458", key: 0, paramStr: "staff" },
|
|
1544
|
+
{ title: "\u90E8\u95E8", key: 1, paramStr: "department" },
|
|
1545
|
+
{ title: "\u5DE5\u4F5C\u7EC4", key: 2, paramStr: "group" },
|
|
1546
|
+
{ title: "\u5E97\u94FA", key: 3, paramStr: "shop" }
|
|
1547
|
+
]);
|
|
1548
|
+
const methods = {
|
|
1549
|
+
deleteOption(key) {
|
|
1550
|
+
let object = new Object();
|
|
1551
|
+
if (object.hasOwnProperty.call(staffsChecked.value, key)) {
|
|
1552
|
+
staffsChecked.value[key] = false;
|
|
1553
|
+
} else if (object.hasOwnProperty.call(shopChecked.value, key)) {
|
|
1554
|
+
shopChecked.value[key] = false;
|
|
1555
|
+
} else if (object.hasOwnProperty.call(groupChecked.value, key)) {
|
|
1556
|
+
groupChecked.value[key] = false;
|
|
1557
|
+
} else {
|
|
1558
|
+
let list = [].concat(departmentChecked.value);
|
|
1559
|
+
let result = [];
|
|
1560
|
+
list.forEach((item) => {
|
|
1561
|
+
if (!(item === key || props.dataMap.get(item) && key === props.dataMap.get(item)["parent"])) {
|
|
1562
|
+
result.push(item);
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
departmentChecked.value = Array.from(new Set(result));
|
|
1566
|
+
}
|
|
1567
|
+
},
|
|
1568
|
+
changeArea(item) {
|
|
1569
|
+
activeKey.value = item.key;
|
|
1570
|
+
searchVal.value = "";
|
|
1571
|
+
if (activeKey.value === 1) {
|
|
1572
|
+
methods.search();
|
|
1573
|
+
} else
|
|
1574
|
+
emit("fetchList", false);
|
|
1575
|
+
},
|
|
1576
|
+
search() {
|
|
1577
|
+
emit("fetchList", {
|
|
1578
|
+
searchVal: searchVal.value,
|
|
1579
|
+
area: areas[activeKey.value].paramStr
|
|
1580
|
+
});
|
|
1581
|
+
},
|
|
1582
|
+
getSelectName(key) {
|
|
1583
|
+
let data = props.dataMap.get(String(key)) || null;
|
|
1584
|
+
return data ? data.title : "\u672A\u77E5";
|
|
1585
|
+
}
|
|
1586
|
+
};
|
|
1587
|
+
watch(() => departmentChecked, () => {
|
|
1588
|
+
let flatMap = props.dataMap;
|
|
1589
|
+
let curlistKeys = props.curlistKeys;
|
|
1590
|
+
let hadselected = new Set(props.selected);
|
|
1591
|
+
let curselect = new Set(departmentChecked.value);
|
|
1592
|
+
for (let key of hadselected) {
|
|
1593
|
+
if (curlistKeys.has(key) && (!curselect.has(key) || curselect.has(key) && curselect.has(flatMap.get(key)["parent"]))) {
|
|
1594
|
+
hadselected.delete(key);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
for (let key of curselect) {
|
|
1598
|
+
let obj = flatMap.get(key);
|
|
1599
|
+
if (obj && !curselect.has(obj["parent"])) {
|
|
1600
|
+
hadselected.add(key);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
emit("update:selected", Array.from(hadselected));
|
|
1604
|
+
}, { deep: true });
|
|
1605
|
+
watch(() => staffsChecked, () => {
|
|
1606
|
+
let set = new Set(props.selected.length ? props.selected : null);
|
|
1607
|
+
for (let [key, value] of Object.entries(staffsChecked.value)) {
|
|
1608
|
+
if (value) {
|
|
1609
|
+
set.add(key);
|
|
1610
|
+
} else {
|
|
1611
|
+
set.has(key) && set.delete(key);
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
emit("update:selected", Array.from(set));
|
|
1615
|
+
}, { deep: true });
|
|
1616
|
+
watch(() => shopChecked, () => {
|
|
1617
|
+
let set = new Set(props.selected.length ? props.selected : null);
|
|
1618
|
+
for (let [key, value] of Object.entries(shopChecked.value)) {
|
|
1619
|
+
if (value) {
|
|
1620
|
+
set.add(key);
|
|
1621
|
+
} else {
|
|
1622
|
+
set.has(key) && set.delete(key);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
emit("update:selected", Array.from(set));
|
|
1626
|
+
}, { deep: true });
|
|
1627
|
+
watch(() => groupChecked, () => {
|
|
1628
|
+
let set = new Set(props.selected.length ? props.selected : null);
|
|
1629
|
+
for (let [key, value] of Object.entries(groupChecked.value)) {
|
|
1630
|
+
if (value) {
|
|
1631
|
+
set.add(key);
|
|
1632
|
+
} else {
|
|
1633
|
+
set.has(key) && set.delete(key);
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
emit("update:selected", Array.from(set));
|
|
1637
|
+
}, { deep: true });
|
|
1638
|
+
onMounted(() => {
|
|
1639
|
+
let list = props.selected;
|
|
1640
|
+
list && list.forEach((key) => {
|
|
1641
|
+
staffsChecked.value[key] = true;
|
|
1642
|
+
groupChecked.value[key] = true;
|
|
1643
|
+
shopChecked.value[key] = true;
|
|
1644
|
+
departmentChecked.value.push(key);
|
|
1645
|
+
});
|
|
1646
|
+
});
|
|
1647
|
+
return {
|
|
1648
|
+
emptyPic,
|
|
1649
|
+
activeKey,
|
|
1650
|
+
searchVal,
|
|
1651
|
+
staffsChecked,
|
|
1652
|
+
groupChecked,
|
|
1653
|
+
departmentChecked,
|
|
1654
|
+
shopChecked,
|
|
1655
|
+
inputPlaceHolder,
|
|
1656
|
+
areas,
|
|
1657
|
+
...methods
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1661
|
+
const _hoisted_1$1 = { class: "varied-selector-panel" };
|
|
1662
|
+
const _hoisted_2 = { class: "__selector-modal-panel-withGroup" };
|
|
1663
|
+
const _hoisted_3 = { class: "varied-area-tabs" };
|
|
1664
|
+
const _hoisted_4 = ["onClick"];
|
|
1665
|
+
const _hoisted_5 = { class: "area-panel" };
|
|
1666
|
+
const _hoisted_6 = {
|
|
1667
|
+
key: 0,
|
|
1668
|
+
class: "noData"
|
|
1669
|
+
};
|
|
1670
|
+
const _hoisted_7 = { style: { "color": "#9393a3", "font-size": "12px", "font-weight": "400" } };
|
|
1671
|
+
const _hoisted_8 = {
|
|
1672
|
+
key: 0,
|
|
1673
|
+
class: "__selector-modal-options"
|
|
1674
|
+
};
|
|
1675
|
+
const _hoisted_9 = {
|
|
1676
|
+
key: 1,
|
|
1677
|
+
class: "__selector-modal-options"
|
|
1678
|
+
};
|
|
1679
|
+
const _hoisted_10 = { class: "department-option-item" };
|
|
1680
|
+
const _hoisted_11 = {
|
|
1681
|
+
key: 0,
|
|
1682
|
+
class: "department-desc"
|
|
1683
|
+
};
|
|
1684
|
+
const _hoisted_12 = {
|
|
1685
|
+
key: 2,
|
|
1686
|
+
class: "__selector-modal-options"
|
|
1687
|
+
};
|
|
1688
|
+
const _hoisted_13 = {
|
|
1689
|
+
key: 3,
|
|
1690
|
+
class: "__selector-modal-options"
|
|
1691
|
+
};
|
|
1692
|
+
const _hoisted_14 = { class: "__selector-chosen-panel" };
|
|
1693
|
+
const _hoisted_15 = { class: "__chosen-panel-list" };
|
|
1694
|
+
const _hoisted_16 = { class: "__tiem-title" };
|
|
1695
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1696
|
+
const _component_search_outlined = resolveComponent("search-outlined");
|
|
1697
|
+
const _component_a_input = resolveComponent("a-input");
|
|
1698
|
+
const _component_Empty = resolveComponent("Empty");
|
|
1699
|
+
const _component_Checkbox = resolveComponent("Checkbox");
|
|
1700
|
+
const _component_a_tree = resolveComponent("a-tree");
|
|
1701
|
+
const _component_CloseCircleFilled = resolveComponent("CloseCircleFilled");
|
|
1702
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
1703
|
+
createElementVNode("div", _hoisted_2, [
|
|
1704
|
+
createElementVNode("div", _hoisted_3, [
|
|
1705
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.areas, (item) => {
|
|
1706
|
+
return openBlock(), createElementBlock("div", {
|
|
1707
|
+
key: item.key,
|
|
1708
|
+
class: normalizeClass(["area-tabs-item", { active: item.key === _ctx.activeKey }]),
|
|
1709
|
+
onClick: withModifiers(($event) => _ctx.changeArea(item), ["stop"])
|
|
1710
|
+
}, toDisplayString(item.title), 11, _hoisted_4);
|
|
1711
|
+
}), 128))
|
|
1712
|
+
]),
|
|
1713
|
+
createVNode(_component_a_input, {
|
|
1714
|
+
value: _ctx.searchVal,
|
|
1715
|
+
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.searchVal = $event),
|
|
1716
|
+
placeholder: _ctx.inputPlaceHolder,
|
|
1717
|
+
onChange: _ctx.search
|
|
1718
|
+
}, {
|
|
1719
|
+
suffix: withCtx(() => [
|
|
1720
|
+
createVNode(_component_search_outlined, { style: { color: "#9393A3" } })
|
|
1721
|
+
]),
|
|
1722
|
+
_: 1
|
|
1723
|
+
}, 8, ["value", "placeholder", "onChange"]),
|
|
1724
|
+
createElementVNode("div", _hoisted_5, [
|
|
1725
|
+
_ctx.list && !_ctx.list.length ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
1726
|
+
createVNode(_component_Empty, { image: _ctx.emptyPic }, {
|
|
1727
|
+
description: withCtx(() => [
|
|
1728
|
+
createElementVNode("span", _hoisted_7, toDisplayString(!!_ctx.searchVal ? "\u6682\u65E0\u6570\u636E" : "\u8BF7\u5148\u641C\u7D22\u4EBA\u5458\u5173\u952E\u5B57"), 1)
|
|
1729
|
+
]),
|
|
1730
|
+
_: 1
|
|
1731
|
+
}, 8, ["image"])
|
|
1732
|
+
])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
1733
|
+
_ctx.activeKey === 0 ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
|
1734
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (item) => {
|
|
1735
|
+
return openBlock(), createElementBlock("div", {
|
|
1736
|
+
key: item.key,
|
|
1737
|
+
class: "__selector-modal-options-item"
|
|
1738
|
+
}, [
|
|
1739
|
+
createVNode(_component_Checkbox, {
|
|
1740
|
+
checked: _ctx.staffsChecked[item.key],
|
|
1741
|
+
"onUpdate:checked": ($event) => _ctx.staffsChecked[item.key] = $event,
|
|
1742
|
+
class: "__selector-modal-option-check"
|
|
1743
|
+
}, {
|
|
1744
|
+
default: withCtx(() => [
|
|
1745
|
+
createTextVNode(toDisplayString(item.title), 1)
|
|
1746
|
+
]),
|
|
1747
|
+
_: 2
|
|
1748
|
+
}, 1032, ["checked", "onUpdate:checked"])
|
|
1749
|
+
]);
|
|
1750
|
+
}), 128))
|
|
1751
|
+
])) : _ctx.activeKey === 1 ? (openBlock(), createElementBlock("div", _hoisted_9, [
|
|
1752
|
+
createVNode(_component_a_tree, {
|
|
1753
|
+
checkedKeys: _ctx.departmentChecked,
|
|
1754
|
+
"onUpdate:checkedKeys": _cache[1] || (_cache[1] = ($event) => _ctx.departmentChecked = $event),
|
|
1755
|
+
"default-expand-all": _ctx.searchVal === "",
|
|
1756
|
+
checkable: "",
|
|
1757
|
+
"tree-data": _ctx.list
|
|
1758
|
+
}, {
|
|
1759
|
+
title: withCtx(({ title, description }) => [
|
|
1760
|
+
createElementVNode("div", _hoisted_10, [
|
|
1761
|
+
createElementVNode("span", null, toDisplayString(title), 1),
|
|
1762
|
+
description ? (openBlock(), createElementBlock("p", _hoisted_11, toDisplayString(description), 1)) : createCommentVNode("v-if", true)
|
|
1763
|
+
])
|
|
1764
|
+
]),
|
|
1765
|
+
_: 1
|
|
1766
|
+
}, 8, ["checkedKeys", "default-expand-all", "tree-data"])
|
|
1767
|
+
])) : _ctx.activeKey === 2 ? (openBlock(), createElementBlock("div", _hoisted_12, [
|
|
1768
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (item) => {
|
|
1769
|
+
return openBlock(), createElementBlock("div", {
|
|
1770
|
+
key: item.key,
|
|
1771
|
+
class: "__selector-modal-options-item"
|
|
1772
|
+
}, [
|
|
1773
|
+
createVNode(_component_Checkbox, {
|
|
1774
|
+
checked: _ctx.groupChecked[item.key],
|
|
1775
|
+
"onUpdate:checked": ($event) => _ctx.groupChecked[item.key] = $event,
|
|
1776
|
+
class: "__selector-modal-option-check"
|
|
1777
|
+
}, {
|
|
1778
|
+
default: withCtx(() => [
|
|
1779
|
+
createTextVNode(toDisplayString(item.title), 1)
|
|
1780
|
+
]),
|
|
1781
|
+
_: 2
|
|
1782
|
+
}, 1032, ["checked", "onUpdate:checked"])
|
|
1783
|
+
]);
|
|
1784
|
+
}), 128))
|
|
1785
|
+
])) : _ctx.activeKey === 3 ? (openBlock(), createElementBlock("div", _hoisted_13, [
|
|
1786
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (item) => {
|
|
1787
|
+
return openBlock(), createElementBlock("div", {
|
|
1788
|
+
key: item.key,
|
|
1789
|
+
class: "__selector-modal-options-item"
|
|
1790
|
+
}, [
|
|
1791
|
+
createVNode(_component_Checkbox, {
|
|
1792
|
+
checked: _ctx.shopChecked[item.key],
|
|
1793
|
+
"onUpdate:checked": ($event) => _ctx.shopChecked[item.key] = $event,
|
|
1794
|
+
class: "__selector-modal-option-check"
|
|
1795
|
+
}, {
|
|
1796
|
+
default: withCtx(() => [
|
|
1797
|
+
createTextVNode(toDisplayString(item.title), 1)
|
|
1798
|
+
]),
|
|
1799
|
+
_: 2
|
|
1800
|
+
}, 1032, ["checked", "onUpdate:checked"])
|
|
1801
|
+
]);
|
|
1802
|
+
}), 128))
|
|
1803
|
+
])) : createCommentVNode("v-if", true)
|
|
1804
|
+
], 2112))
|
|
1805
|
+
])
|
|
1806
|
+
]),
|
|
1807
|
+
createElementVNode("div", _hoisted_14, [
|
|
1808
|
+
createElementVNode("div", _hoisted_15, [
|
|
1809
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.selected, (item) => {
|
|
1810
|
+
return openBlock(), createElementBlock("div", {
|
|
1811
|
+
key: item + "checked",
|
|
1812
|
+
class: "__chosen-panel-list-item"
|
|
1813
|
+
}, [
|
|
1814
|
+
createElementVNode("span", _hoisted_16, toDisplayString(_ctx.getSelectName(item)), 1),
|
|
1815
|
+
createVNode(_component_CloseCircleFilled, {
|
|
1816
|
+
onMousedown: withModifiers(($event) => _ctx.deleteOption(item), ["stop"])
|
|
1817
|
+
}, null, 8, ["onMousedown"])
|
|
1818
|
+
]);
|
|
1819
|
+
}), 128))
|
|
1820
|
+
])
|
|
1821
|
+
])
|
|
1822
|
+
]);
|
|
1823
|
+
}
|
|
1824
|
+
var VariedCmp = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__file", "variedCmp.vue"]]);
|
|
1825
|
+
|
|
1826
|
+
const MODE = {
|
|
1827
|
+
RADIO: "radio",
|
|
1828
|
+
MULTIPLE: "multiple",
|
|
1829
|
+
VARIED: "varied"
|
|
1830
|
+
};
|
|
1831
|
+
const _sfc_main = defineComponent({
|
|
1832
|
+
name: "BmStaffsSelector",
|
|
1833
|
+
components: { AModal, multipleCmp, radioCmp, VariedCmp },
|
|
1834
|
+
props: {
|
|
1835
|
+
visible: {
|
|
1836
|
+
type: Boolean,
|
|
1837
|
+
default: false
|
|
1838
|
+
},
|
|
1839
|
+
mode: {
|
|
1840
|
+
type: String,
|
|
1841
|
+
default: MODE.MULTIPLE
|
|
1842
|
+
},
|
|
1843
|
+
limit: {
|
|
1844
|
+
type: Number,
|
|
1845
|
+
default: 0
|
|
1846
|
+
},
|
|
1847
|
+
title: {
|
|
1848
|
+
type: String,
|
|
1849
|
+
default: "\u4EBA\u5458\u9009\u62E9\u5668"
|
|
1850
|
+
},
|
|
1851
|
+
load: {
|
|
1852
|
+
type: Function,
|
|
1853
|
+
default: () => {
|
|
1854
|
+
return Promise.resolve([]);
|
|
1855
|
+
}
|
|
1856
|
+
},
|
|
1857
|
+
select: {
|
|
1858
|
+
type: Array || Object,
|
|
1859
|
+
defualt: () => []
|
|
1860
|
+
},
|
|
1861
|
+
forceStatic: {
|
|
1862
|
+
type: Boolean,
|
|
1863
|
+
default: false
|
|
1864
|
+
}
|
|
1865
|
+
},
|
|
1866
|
+
emits: ["update:visible", "update:select"],
|
|
1867
|
+
setup(props, { emit }) {
|
|
1868
|
+
const methods = {
|
|
1869
|
+
modalCancel() {
|
|
1870
|
+
emit("update:visible", !props.visible);
|
|
1871
|
+
},
|
|
1872
|
+
fetch(params) {
|
|
1873
|
+
if (typeof params === "boolean") {
|
|
1874
|
+
state.list = [];
|
|
1875
|
+
} else {
|
|
1876
|
+
props.load(params).then((data) => {
|
|
1877
|
+
state.list = data.map((item) => {
|
|
1878
|
+
return item;
|
|
1879
|
+
});
|
|
1880
|
+
state.dataMap = methods.flatListFunc(data);
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
},
|
|
1884
|
+
flatListFunc(list) {
|
|
1885
|
+
let queue = [...list];
|
|
1886
|
+
let map = new Map(state.dataMap);
|
|
1887
|
+
let curlistKeys = /* @__PURE__ */ new Set();
|
|
1888
|
+
let treedata = false;
|
|
1889
|
+
while (queue.length) {
|
|
1890
|
+
let curnode = queue.shift();
|
|
1891
|
+
map.set(curnode.key, curnode);
|
|
1892
|
+
curlistKeys.add(curnode.key);
|
|
1893
|
+
let children = curnode.children;
|
|
1894
|
+
if (children) {
|
|
1895
|
+
children = children.map((obj) => {
|
|
1896
|
+
treedata = true;
|
|
1897
|
+
obj["parent"] = curnode && curnode.key || null;
|
|
1898
|
+
return obj;
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
queue = queue.concat(children || []);
|
|
1902
|
+
}
|
|
1903
|
+
state.multipTree = props.forceStatic ? false : treedata;
|
|
1904
|
+
state.curlistKeys = curlistKeys;
|
|
1905
|
+
return map;
|
|
1906
|
+
},
|
|
1907
|
+
summitSelect() {
|
|
1908
|
+
if (typeof state.selected === "string") {
|
|
1909
|
+
emit("update:select", state.dataMap.get(state.selected));
|
|
1910
|
+
} else if (state.selected instanceof Array) {
|
|
1911
|
+
emit("update:select", state.selected.map((item) => state.dataMap.get(item)));
|
|
1912
|
+
}
|
|
1913
|
+
state.list = [];
|
|
1914
|
+
methods.modalCancel();
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
const state = reactive({
|
|
1918
|
+
list: [],
|
|
1919
|
+
selected: props.mode === "radio" ? "" : [],
|
|
1920
|
+
dataMap: /* @__PURE__ */ new Map(),
|
|
1921
|
+
curlistKeys: /* @__PURE__ */ new Set(),
|
|
1922
|
+
multipTree: false,
|
|
1923
|
+
width: computed(() => {
|
|
1924
|
+
if (props.mode === MODE.MULTIPLE) {
|
|
1925
|
+
return 648;
|
|
1926
|
+
} else if (props.mode === MODE.RADIO) {
|
|
1927
|
+
return 480;
|
|
1928
|
+
}
|
|
1929
|
+
return 648;
|
|
1930
|
+
})
|
|
1931
|
+
});
|
|
1932
|
+
return {
|
|
1933
|
+
...methods,
|
|
1934
|
+
...toRefs(state)
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
const _hoisted_1 = { class: "selector-content" };
|
|
1939
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
1940
|
+
const _component_radioCmp = resolveComponent("radioCmp");
|
|
1941
|
+
const _component_VariedCmp = resolveComponent("VariedCmp");
|
|
1942
|
+
const _component_multipleCmp = resolveComponent("multipleCmp");
|
|
1943
|
+
const _component_AModal = resolveComponent("AModal");
|
|
1944
|
+
return openBlock(), createBlock(_component_AModal, {
|
|
1945
|
+
class: "staffs-selector-modal",
|
|
1946
|
+
title: _ctx.title,
|
|
1947
|
+
visible: _ctx.visible,
|
|
1948
|
+
width: _ctx.width,
|
|
1949
|
+
"ok-text": "\u786E\u5B9A",
|
|
1950
|
+
"cancel-text": "\u53D6\u6D88",
|
|
1951
|
+
"destroy-on-close": true,
|
|
1952
|
+
onCancel: _ctx.modalCancel,
|
|
1953
|
+
onOk: _ctx.summitSelect
|
|
1954
|
+
}, {
|
|
1955
|
+
default: withCtx(() => [
|
|
1956
|
+
createElementVNode("div", _hoisted_1, [
|
|
1957
|
+
_ctx.mode === "radio" ? (openBlock(), createBlock(_component_radioCmp, {
|
|
1958
|
+
key: 0,
|
|
1959
|
+
selected: _ctx.selected,
|
|
1960
|
+
"onUpdate:selected": _cache[0] || (_cache[0] = ($event) => _ctx.selected = $event),
|
|
1961
|
+
list: _ctx.list,
|
|
1962
|
+
onFetchList: _ctx.fetch
|
|
1963
|
+
}, null, 8, ["selected", "list", "onFetchList"])) : _ctx.mode === "varied" ? (openBlock(), createBlock(_component_VariedCmp, {
|
|
1964
|
+
key: 1,
|
|
1965
|
+
selected: _ctx.selected,
|
|
1966
|
+
"onUpdate:selected": _cache[1] || (_cache[1] = ($event) => _ctx.selected = $event),
|
|
1967
|
+
list: _ctx.list,
|
|
1968
|
+
"curlist-keys": _ctx.curlistKeys,
|
|
1969
|
+
"data-map": _ctx.dataMap,
|
|
1970
|
+
onFetchList: _ctx.fetch
|
|
1971
|
+
}, null, 8, ["selected", "list", "curlist-keys", "data-map", "onFetchList"])) : (openBlock(), createBlock(_component_multipleCmp, {
|
|
1972
|
+
key: 2,
|
|
1973
|
+
selected: _ctx.selected,
|
|
1974
|
+
"onUpdate:selected": _cache[2] || (_cache[2] = ($event) => _ctx.selected = $event),
|
|
1975
|
+
limit: _ctx.limit,
|
|
1976
|
+
list: _ctx.list,
|
|
1977
|
+
"curlist-keys": _ctx.curlistKeys,
|
|
1978
|
+
"is-tree": _ctx.multipTree,
|
|
1979
|
+
"data-map": _ctx.dataMap,
|
|
1980
|
+
onFetchList: _ctx.fetch
|
|
1981
|
+
}, null, 8, ["selected", "limit", "list", "curlist-keys", "is-tree", "data-map", "onFetchList"]))
|
|
1982
|
+
])
|
|
1983
|
+
]),
|
|
1984
|
+
_: 1
|
|
1985
|
+
}, 8, ["title", "visible", "width", "onCancel", "onOk"]);
|
|
1986
|
+
}
|
|
1987
|
+
var staffsSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "staffs-selector.vue"]]);
|
|
1988
|
+
|
|
1989
|
+
const BmStaffsSelector = withInstall(staffsSelector);
|
|
1990
|
+
|
|
1991
|
+
export { BmStaffsSelector, BmStaffsSelector as default };
|