@kne/file-system-view 1.0.0
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/README.md +290 -0
- package/dist/index.css +125 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +1907 -0
- package/dist/index.js.map +1 -0
- package/dist/index.modern.js +1909 -0
- package/dist/index.modern.js.map +1 -0
- package/dist/locale/en-US.js +6 -0
- package/dist/locale/en-US.js.map +1 -0
- package/dist/locale/en-US.modern.js +6 -0
- package/dist/locale/en-US.modern.js.map +1 -0
- package/dist/locale/zh-CN.js +6 -0
- package/dist/locale/zh-CN.js.map +1 -0
- package/dist/locale/zh-CN.modern.js +6 -0
- package/dist/locale/zh-CN.modern.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,1909 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { createContext, useContext, useEffect, forwardRef, useMemo, useCallback, useRef, useState } from 'react';
|
|
3
|
+
import { Dropdown, Button, Tree } from 'antd';
|
|
4
|
+
import { createWithIntlProvider, useIntl } from '@kne/react-intl';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
const locale$1 = {
|
|
8
|
+
empty: '暂无文件'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const locale = {
|
|
12
|
+
empty: 'No files'
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const withLocale = createWithIntlProvider({
|
|
16
|
+
defaultLocale: 'zh-CN',
|
|
17
|
+
messages: {
|
|
18
|
+
'zh-CN': locale$1,
|
|
19
|
+
'en-US': locale
|
|
20
|
+
},
|
|
21
|
+
namespace: 'file-system-view'
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
var style = {"file-system-view":"_qMhn9","tree-node":"_t015K","action-btn":"_mLgqh","node-icon":"_dgomj","node-title":"_r6Ngq","node-name":"_st428","node-ext":"_POSao","empty":"_4zeDm"};
|
|
25
|
+
|
|
26
|
+
const IconContext = /*#__PURE__*/createContext({});
|
|
27
|
+
var Context = IconContext;
|
|
28
|
+
|
|
29
|
+
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
30
|
+
|
|
31
|
+
// 36 Hex to reduce the size of the file
|
|
32
|
+
var presetColors = {
|
|
33
|
+
aliceblue: '9ehhb',
|
|
34
|
+
antiquewhite: '9sgk7',
|
|
35
|
+
aqua: '1ekf',
|
|
36
|
+
aquamarine: '4zsno',
|
|
37
|
+
azure: '9eiv3',
|
|
38
|
+
beige: '9lhp8',
|
|
39
|
+
bisque: '9zg04',
|
|
40
|
+
black: '0',
|
|
41
|
+
blanchedalmond: '9zhe5',
|
|
42
|
+
blue: '73',
|
|
43
|
+
blueviolet: '5e31e',
|
|
44
|
+
brown: '6g016',
|
|
45
|
+
burlywood: '8ouiv',
|
|
46
|
+
cadetblue: '3qba8',
|
|
47
|
+
chartreuse: '4zshs',
|
|
48
|
+
chocolate: '87k0u',
|
|
49
|
+
coral: '9yvyo',
|
|
50
|
+
cornflowerblue: '3xael',
|
|
51
|
+
cornsilk: '9zjz0',
|
|
52
|
+
crimson: '8l4xo',
|
|
53
|
+
cyan: '1ekf',
|
|
54
|
+
darkblue: '3v',
|
|
55
|
+
darkcyan: 'rkb',
|
|
56
|
+
darkgoldenrod: '776yz',
|
|
57
|
+
darkgray: '6mbhl',
|
|
58
|
+
darkgreen: 'jr4',
|
|
59
|
+
darkgrey: '6mbhl',
|
|
60
|
+
darkkhaki: '7ehkb',
|
|
61
|
+
darkmagenta: '5f91n',
|
|
62
|
+
darkolivegreen: '3bzfz',
|
|
63
|
+
darkorange: '9yygw',
|
|
64
|
+
darkorchid: '5z6x8',
|
|
65
|
+
darkred: '5f8xs',
|
|
66
|
+
darksalmon: '9441m',
|
|
67
|
+
darkseagreen: '5lwgf',
|
|
68
|
+
darkslateblue: '2th1n',
|
|
69
|
+
darkslategray: '1ugcv',
|
|
70
|
+
darkslategrey: '1ugcv',
|
|
71
|
+
darkturquoise: '14up',
|
|
72
|
+
darkviolet: '5rw7n',
|
|
73
|
+
deeppink: '9yavn',
|
|
74
|
+
deepskyblue: '11xb',
|
|
75
|
+
dimgray: '442g9',
|
|
76
|
+
dimgrey: '442g9',
|
|
77
|
+
dodgerblue: '16xof',
|
|
78
|
+
firebrick: '6y7tu',
|
|
79
|
+
floralwhite: '9zkds',
|
|
80
|
+
forestgreen: '1cisi',
|
|
81
|
+
fuchsia: '9y70f',
|
|
82
|
+
gainsboro: '8m8kc',
|
|
83
|
+
ghostwhite: '9pq0v',
|
|
84
|
+
goldenrod: '8j4f4',
|
|
85
|
+
gold: '9zda8',
|
|
86
|
+
gray: '50i2o',
|
|
87
|
+
green: 'pa8',
|
|
88
|
+
greenyellow: '6senj',
|
|
89
|
+
grey: '50i2o',
|
|
90
|
+
honeydew: '9eiuo',
|
|
91
|
+
hotpink: '9yrp0',
|
|
92
|
+
indianred: '80gnw',
|
|
93
|
+
indigo: '2xcoy',
|
|
94
|
+
ivory: '9zldc',
|
|
95
|
+
khaki: '9edu4',
|
|
96
|
+
lavenderblush: '9ziet',
|
|
97
|
+
lavender: '90c8q',
|
|
98
|
+
lawngreen: '4vk74',
|
|
99
|
+
lemonchiffon: '9zkct',
|
|
100
|
+
lightblue: '6s73a',
|
|
101
|
+
lightcoral: '9dtog',
|
|
102
|
+
lightcyan: '8s1rz',
|
|
103
|
+
lightgoldenrodyellow: '9sjiq',
|
|
104
|
+
lightgray: '89jo3',
|
|
105
|
+
lightgreen: '5nkwg',
|
|
106
|
+
lightgrey: '89jo3',
|
|
107
|
+
lightpink: '9z6wx',
|
|
108
|
+
lightsalmon: '9z2ii',
|
|
109
|
+
lightseagreen: '19xgq',
|
|
110
|
+
lightskyblue: '5arju',
|
|
111
|
+
lightslategray: '4nwk9',
|
|
112
|
+
lightslategrey: '4nwk9',
|
|
113
|
+
lightsteelblue: '6wau6',
|
|
114
|
+
lightyellow: '9zlcw',
|
|
115
|
+
lime: '1edc',
|
|
116
|
+
limegreen: '1zcxe',
|
|
117
|
+
linen: '9shk6',
|
|
118
|
+
magenta: '9y70f',
|
|
119
|
+
maroon: '4zsow',
|
|
120
|
+
mediumaquamarine: '40eju',
|
|
121
|
+
mediumblue: '5p',
|
|
122
|
+
mediumorchid: '79qkz',
|
|
123
|
+
mediumpurple: '5r3rv',
|
|
124
|
+
mediumseagreen: '2d9ip',
|
|
125
|
+
mediumslateblue: '4tcku',
|
|
126
|
+
mediumspringgreen: '1di2',
|
|
127
|
+
mediumturquoise: '2uabw',
|
|
128
|
+
mediumvioletred: '7rn9h',
|
|
129
|
+
midnightblue: 'z980',
|
|
130
|
+
mintcream: '9ljp6',
|
|
131
|
+
mistyrose: '9zg0x',
|
|
132
|
+
moccasin: '9zfzp',
|
|
133
|
+
navajowhite: '9zest',
|
|
134
|
+
navy: '3k',
|
|
135
|
+
oldlace: '9wq92',
|
|
136
|
+
olive: '50hz4',
|
|
137
|
+
olivedrab: '472ub',
|
|
138
|
+
orange: '9z3eo',
|
|
139
|
+
orangered: '9ykg0',
|
|
140
|
+
orchid: '8iu3a',
|
|
141
|
+
palegoldenrod: '9bl4a',
|
|
142
|
+
palegreen: '5yw0o',
|
|
143
|
+
paleturquoise: '6v4ku',
|
|
144
|
+
palevioletred: '8k8lv',
|
|
145
|
+
papayawhip: '9zi6t',
|
|
146
|
+
peachpuff: '9ze0p',
|
|
147
|
+
peru: '80oqn',
|
|
148
|
+
pink: '9z8wb',
|
|
149
|
+
plum: '8nba5',
|
|
150
|
+
powderblue: '6wgdi',
|
|
151
|
+
purple: '4zssg',
|
|
152
|
+
rebeccapurple: '3zk49',
|
|
153
|
+
red: '9y6tc',
|
|
154
|
+
rosybrown: '7cv4f',
|
|
155
|
+
royalblue: '2jvtt',
|
|
156
|
+
saddlebrown: '5fmkz',
|
|
157
|
+
salmon: '9rvci',
|
|
158
|
+
sandybrown: '9jn1c',
|
|
159
|
+
seagreen: '1tdnb',
|
|
160
|
+
seashell: '9zje6',
|
|
161
|
+
sienna: '6973h',
|
|
162
|
+
silver: '7ir40',
|
|
163
|
+
skyblue: '5arjf',
|
|
164
|
+
slateblue: '45e4t',
|
|
165
|
+
slategray: '4e100',
|
|
166
|
+
slategrey: '4e100',
|
|
167
|
+
snow: '9zke2',
|
|
168
|
+
springgreen: '1egv',
|
|
169
|
+
steelblue: '2r1kk',
|
|
170
|
+
tan: '87yx8',
|
|
171
|
+
teal: 'pds',
|
|
172
|
+
thistle: '8ggk8',
|
|
173
|
+
tomato: '9yqfb',
|
|
174
|
+
turquoise: '2j4r4',
|
|
175
|
+
violet: '9b10u',
|
|
176
|
+
wheat: '9ld4j',
|
|
177
|
+
white: '9zldr',
|
|
178
|
+
whitesmoke: '9lhpx',
|
|
179
|
+
yellow: '9zl6o',
|
|
180
|
+
yellowgreen: '61fzm'
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const round = Math.round;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Support format, alpha unit will check the % mark:
|
|
187
|
+
* - rgba(102, 204, 255, .5) -> [102, 204, 255, 0.5]
|
|
188
|
+
* - rgb(102 204 255 / .5) -> [102, 204, 255, 0.5]
|
|
189
|
+
* - rgb(100%, 50%, 0% / 50%) -> [255, 128, 0, 0.5]
|
|
190
|
+
* - hsl(270, 60, 40, .5) -> [270, 60, 40, 0.5]
|
|
191
|
+
* - hsl(270deg 60% 40% / 50%) -> [270, 60, 40, 0.5]
|
|
192
|
+
*
|
|
193
|
+
* When `base` is provided, the percentage value will be divided by `base`.
|
|
194
|
+
*/
|
|
195
|
+
function splitColorStr(str, parseNum) {
|
|
196
|
+
const match = str
|
|
197
|
+
// Remove str before `(`
|
|
198
|
+
.replace(/^[^(]*\((.*)/, '$1')
|
|
199
|
+
// Remove str after `)`
|
|
200
|
+
.replace(/\).*/, '').match(/\d*\.?\d+%?/g) || [];
|
|
201
|
+
const numList = match.map(item => parseFloat(item));
|
|
202
|
+
for (let i = 0; i < 3; i += 1) {
|
|
203
|
+
numList[i] = parseNum(numList[i] || 0, match[i] || '', i);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// For alpha. 50% should be 0.5
|
|
207
|
+
if (match[3]) {
|
|
208
|
+
numList[3] = match[3].includes('%') ? numList[3] / 100 : numList[3];
|
|
209
|
+
} else {
|
|
210
|
+
// By default, alpha is 1
|
|
211
|
+
numList[3] = 1;
|
|
212
|
+
}
|
|
213
|
+
return numList;
|
|
214
|
+
}
|
|
215
|
+
const parseHSVorHSL = (num, _, index) => index === 0 ? num : num / 100;
|
|
216
|
+
|
|
217
|
+
/** round and limit number to integer between 0-255 */
|
|
218
|
+
function limitRange(value, max) {
|
|
219
|
+
const mergedMax = max || 255;
|
|
220
|
+
if (value > mergedMax) {
|
|
221
|
+
return mergedMax;
|
|
222
|
+
}
|
|
223
|
+
if (value < 0) {
|
|
224
|
+
return 0;
|
|
225
|
+
}
|
|
226
|
+
return value;
|
|
227
|
+
}
|
|
228
|
+
class FastColor {
|
|
229
|
+
/**
|
|
230
|
+
* All FastColor objects are valid. So isValid is always true. This property is kept to be compatible with TinyColor.
|
|
231
|
+
*/
|
|
232
|
+
isValid = true;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Red, R in RGB
|
|
236
|
+
*/
|
|
237
|
+
r = 0;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Green, G in RGB
|
|
241
|
+
*/
|
|
242
|
+
g = 0;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Blue, B in RGB
|
|
246
|
+
*/
|
|
247
|
+
b = 0;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Alpha/Opacity, A in RGBA/HSLA
|
|
251
|
+
*/
|
|
252
|
+
a = 1;
|
|
253
|
+
|
|
254
|
+
// HSV privates
|
|
255
|
+
_h;
|
|
256
|
+
_hsl_s;
|
|
257
|
+
_hsv_s;
|
|
258
|
+
_l;
|
|
259
|
+
_v;
|
|
260
|
+
|
|
261
|
+
// intermediate variables to calculate HSL/HSV
|
|
262
|
+
_max;
|
|
263
|
+
_min;
|
|
264
|
+
_brightness;
|
|
265
|
+
constructor(input) {
|
|
266
|
+
/**
|
|
267
|
+
* Always check 3 char in the object to determine the format.
|
|
268
|
+
* We not use function in check to save bundle size.
|
|
269
|
+
* e.g. 'rgb' -> { r: 0, g: 0, b: 0 }.
|
|
270
|
+
*/
|
|
271
|
+
function matchFormat(str) {
|
|
272
|
+
return str[0] in input && str[1] in input && str[2] in input;
|
|
273
|
+
}
|
|
274
|
+
if (!input) ; else if (typeof input === 'string') {
|
|
275
|
+
const trimStr = input.trim();
|
|
276
|
+
function matchPrefix(prefix) {
|
|
277
|
+
return trimStr.startsWith(prefix);
|
|
278
|
+
}
|
|
279
|
+
if (/^#?[A-F\d]{3,8}$/i.test(trimStr)) {
|
|
280
|
+
this.fromHexString(trimStr);
|
|
281
|
+
} else if (matchPrefix('rgb')) {
|
|
282
|
+
this.fromRgbString(trimStr);
|
|
283
|
+
} else if (matchPrefix('hsl')) {
|
|
284
|
+
this.fromHslString(trimStr);
|
|
285
|
+
} else if (matchPrefix('hsv') || matchPrefix('hsb')) {
|
|
286
|
+
this.fromHsvString(trimStr);
|
|
287
|
+
} else {
|
|
288
|
+
// From preset color
|
|
289
|
+
const presetColor = presetColors[trimStr.toLowerCase()];
|
|
290
|
+
if (presetColor) {
|
|
291
|
+
this.fromHexString(
|
|
292
|
+
// Convert 36 hex to 16 hex
|
|
293
|
+
parseInt(presetColor, 36).toString(16).padStart(6, '0'));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
} else if (input instanceof FastColor) {
|
|
297
|
+
this.r = input.r;
|
|
298
|
+
this.g = input.g;
|
|
299
|
+
this.b = input.b;
|
|
300
|
+
this.a = input.a;
|
|
301
|
+
this._h = input._h;
|
|
302
|
+
this._hsl_s = input._hsl_s;
|
|
303
|
+
this._hsv_s = input._hsv_s;
|
|
304
|
+
this._l = input._l;
|
|
305
|
+
this._v = input._v;
|
|
306
|
+
} else if (matchFormat('rgb')) {
|
|
307
|
+
this.r = limitRange(input.r);
|
|
308
|
+
this.g = limitRange(input.g);
|
|
309
|
+
this.b = limitRange(input.b);
|
|
310
|
+
this.a = typeof input.a === 'number' ? limitRange(input.a, 1) : 1;
|
|
311
|
+
} else if (matchFormat('hsl')) {
|
|
312
|
+
this.fromHsl(input);
|
|
313
|
+
} else if (matchFormat('hsv')) {
|
|
314
|
+
this.fromHsv(input);
|
|
315
|
+
} else {
|
|
316
|
+
throw new Error('@ant-design/fast-color: unsupported input ' + JSON.stringify(input));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// ======================= Setter =======================
|
|
321
|
+
|
|
322
|
+
setR(value) {
|
|
323
|
+
return this._sc('r', value);
|
|
324
|
+
}
|
|
325
|
+
setG(value) {
|
|
326
|
+
return this._sc('g', value);
|
|
327
|
+
}
|
|
328
|
+
setB(value) {
|
|
329
|
+
return this._sc('b', value);
|
|
330
|
+
}
|
|
331
|
+
setA(value) {
|
|
332
|
+
return this._sc('a', value, 1);
|
|
333
|
+
}
|
|
334
|
+
setHue(value) {
|
|
335
|
+
const hsv = this.toHsv();
|
|
336
|
+
hsv.h = value;
|
|
337
|
+
return this._c(hsv);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// ======================= Getter =======================
|
|
341
|
+
/**
|
|
342
|
+
* Returns the perceived luminance of a color, from 0-1.
|
|
343
|
+
* @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
|
344
|
+
*/
|
|
345
|
+
getLuminance() {
|
|
346
|
+
function adjustGamma(raw) {
|
|
347
|
+
const val = raw / 255;
|
|
348
|
+
return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4);
|
|
349
|
+
}
|
|
350
|
+
const R = adjustGamma(this.r);
|
|
351
|
+
const G = adjustGamma(this.g);
|
|
352
|
+
const B = adjustGamma(this.b);
|
|
353
|
+
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
354
|
+
}
|
|
355
|
+
getHue() {
|
|
356
|
+
if (typeof this._h === 'undefined') {
|
|
357
|
+
const delta = this.getMax() - this.getMin();
|
|
358
|
+
if (delta === 0) {
|
|
359
|
+
this._h = 0;
|
|
360
|
+
} else {
|
|
361
|
+
this._h = round(60 * (this.r === this.getMax() ? (this.g - this.b) / delta + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / delta + 2 : (this.r - this.g) / delta + 4));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return this._h;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* @deprecated should use getHSVSaturation or getHSLSaturation instead
|
|
369
|
+
*/
|
|
370
|
+
getSaturation() {
|
|
371
|
+
return this.getHSVSaturation();
|
|
372
|
+
}
|
|
373
|
+
getHSVSaturation() {
|
|
374
|
+
if (typeof this._hsv_s === 'undefined') {
|
|
375
|
+
const delta = this.getMax() - this.getMin();
|
|
376
|
+
if (delta === 0) {
|
|
377
|
+
this._hsv_s = 0;
|
|
378
|
+
} else {
|
|
379
|
+
this._hsv_s = delta / this.getMax();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return this._hsv_s;
|
|
383
|
+
}
|
|
384
|
+
getHSLSaturation() {
|
|
385
|
+
if (typeof this._hsl_s === 'undefined') {
|
|
386
|
+
const delta = this.getMax() - this.getMin();
|
|
387
|
+
if (delta === 0) {
|
|
388
|
+
this._hsl_s = 0;
|
|
389
|
+
} else {
|
|
390
|
+
const l = this.getLightness();
|
|
391
|
+
this._hsl_s = delta / 255 / (1 - Math.abs(2 * l - 1));
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return this._hsl_s;
|
|
395
|
+
}
|
|
396
|
+
getLightness() {
|
|
397
|
+
if (typeof this._l === 'undefined') {
|
|
398
|
+
this._l = (this.getMax() + this.getMin()) / 510;
|
|
399
|
+
}
|
|
400
|
+
return this._l;
|
|
401
|
+
}
|
|
402
|
+
getValue() {
|
|
403
|
+
if (typeof this._v === 'undefined') {
|
|
404
|
+
this._v = this.getMax() / 255;
|
|
405
|
+
}
|
|
406
|
+
return this._v;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Returns the perceived brightness of the color, from 0-255.
|
|
411
|
+
* Note: this is not the b of HSB
|
|
412
|
+
* @see http://www.w3.org/TR/AERT#color-contrast
|
|
413
|
+
*/
|
|
414
|
+
getBrightness() {
|
|
415
|
+
if (typeof this._brightness === 'undefined') {
|
|
416
|
+
this._brightness = (this.r * 299 + this.g * 587 + this.b * 114) / 1000;
|
|
417
|
+
}
|
|
418
|
+
return this._brightness;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// ======================== Func ========================
|
|
422
|
+
|
|
423
|
+
darken(amount = 10) {
|
|
424
|
+
const h = this.getHue();
|
|
425
|
+
const s = this.getSaturation();
|
|
426
|
+
let l = this.getLightness() - amount / 100;
|
|
427
|
+
if (l < 0) {
|
|
428
|
+
l = 0;
|
|
429
|
+
}
|
|
430
|
+
return this._c({
|
|
431
|
+
h,
|
|
432
|
+
s,
|
|
433
|
+
l,
|
|
434
|
+
a: this.a
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
lighten(amount = 10) {
|
|
438
|
+
const h = this.getHue();
|
|
439
|
+
const s = this.getSaturation();
|
|
440
|
+
let l = this.getLightness() + amount / 100;
|
|
441
|
+
if (l > 1) {
|
|
442
|
+
l = 1;
|
|
443
|
+
}
|
|
444
|
+
return this._c({
|
|
445
|
+
h,
|
|
446
|
+
s,
|
|
447
|
+
l,
|
|
448
|
+
a: this.a
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Mix the current color a given amount with another color, from 0 to 100.
|
|
454
|
+
* 0 means no mixing (return current color).
|
|
455
|
+
*/
|
|
456
|
+
mix(input, amount = 50) {
|
|
457
|
+
const color = this._c(input);
|
|
458
|
+
const p = amount / 100;
|
|
459
|
+
const calc = key => (color[key] - this[key]) * p + this[key];
|
|
460
|
+
const rgba = {
|
|
461
|
+
r: round(calc('r')),
|
|
462
|
+
g: round(calc('g')),
|
|
463
|
+
b: round(calc('b')),
|
|
464
|
+
a: round(calc('a') * 100) / 100
|
|
465
|
+
};
|
|
466
|
+
return this._c(rgba);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Mix the color with pure white, from 0 to 100.
|
|
471
|
+
* Providing 0 will do nothing, providing 100 will always return white.
|
|
472
|
+
*/
|
|
473
|
+
tint(amount = 10) {
|
|
474
|
+
return this.mix({
|
|
475
|
+
r: 255,
|
|
476
|
+
g: 255,
|
|
477
|
+
b: 255,
|
|
478
|
+
a: 1
|
|
479
|
+
}, amount);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Mix the color with pure black, from 0 to 100.
|
|
484
|
+
* Providing 0 will do nothing, providing 100 will always return black.
|
|
485
|
+
*/
|
|
486
|
+
shade(amount = 10) {
|
|
487
|
+
return this.mix({
|
|
488
|
+
r: 0,
|
|
489
|
+
g: 0,
|
|
490
|
+
b: 0,
|
|
491
|
+
a: 1
|
|
492
|
+
}, amount);
|
|
493
|
+
}
|
|
494
|
+
onBackground(background) {
|
|
495
|
+
const bg = this._c(background);
|
|
496
|
+
const alpha = this.a + bg.a * (1 - this.a);
|
|
497
|
+
const calc = key => {
|
|
498
|
+
return round((this[key] * this.a + bg[key] * bg.a * (1 - this.a)) / alpha);
|
|
499
|
+
};
|
|
500
|
+
return this._c({
|
|
501
|
+
r: calc('r'),
|
|
502
|
+
g: calc('g'),
|
|
503
|
+
b: calc('b'),
|
|
504
|
+
a: alpha
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// ======================= Status =======================
|
|
509
|
+
isDark() {
|
|
510
|
+
return this.getBrightness() < 128;
|
|
511
|
+
}
|
|
512
|
+
isLight() {
|
|
513
|
+
return this.getBrightness() >= 128;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// ======================== MISC ========================
|
|
517
|
+
equals(other) {
|
|
518
|
+
return this.r === other.r && this.g === other.g && this.b === other.b && this.a === other.a;
|
|
519
|
+
}
|
|
520
|
+
clone() {
|
|
521
|
+
return this._c(this);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
// ======================= Format =======================
|
|
525
|
+
toHexString() {
|
|
526
|
+
let hex = '#';
|
|
527
|
+
const rHex = (this.r || 0).toString(16);
|
|
528
|
+
hex += rHex.length === 2 ? rHex : '0' + rHex;
|
|
529
|
+
const gHex = (this.g || 0).toString(16);
|
|
530
|
+
hex += gHex.length === 2 ? gHex : '0' + gHex;
|
|
531
|
+
const bHex = (this.b || 0).toString(16);
|
|
532
|
+
hex += bHex.length === 2 ? bHex : '0' + bHex;
|
|
533
|
+
if (typeof this.a === 'number' && this.a >= 0 && this.a < 1) {
|
|
534
|
+
const aHex = round(this.a * 255).toString(16);
|
|
535
|
+
hex += aHex.length === 2 ? aHex : '0' + aHex;
|
|
536
|
+
}
|
|
537
|
+
return hex;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/** CSS support color pattern */
|
|
541
|
+
toHsl() {
|
|
542
|
+
return {
|
|
543
|
+
h: this.getHue(),
|
|
544
|
+
s: this.getHSLSaturation(),
|
|
545
|
+
l: this.getLightness(),
|
|
546
|
+
a: this.a
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/** CSS support color pattern */
|
|
551
|
+
toHslString() {
|
|
552
|
+
const h = this.getHue();
|
|
553
|
+
const s = round(this.getHSLSaturation() * 100);
|
|
554
|
+
const l = round(this.getLightness() * 100);
|
|
555
|
+
return this.a !== 1 ? `hsla(${h},${s}%,${l}%,${this.a})` : `hsl(${h},${s}%,${l}%)`;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** Same as toHsb */
|
|
559
|
+
toHsv() {
|
|
560
|
+
return {
|
|
561
|
+
h: this.getHue(),
|
|
562
|
+
s: this.getHSVSaturation(),
|
|
563
|
+
v: this.getValue(),
|
|
564
|
+
a: this.a
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
toRgb() {
|
|
568
|
+
return {
|
|
569
|
+
r: this.r,
|
|
570
|
+
g: this.g,
|
|
571
|
+
b: this.b,
|
|
572
|
+
a: this.a
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
toRgbString() {
|
|
576
|
+
return this.a !== 1 ? `rgba(${this.r},${this.g},${this.b},${this.a})` : `rgb(${this.r},${this.g},${this.b})`;
|
|
577
|
+
}
|
|
578
|
+
toString() {
|
|
579
|
+
return this.toRgbString();
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// ====================== Privates ======================
|
|
583
|
+
/** Return a new FastColor object with one channel changed */
|
|
584
|
+
_sc(rgb, value, max) {
|
|
585
|
+
const clone = this.clone();
|
|
586
|
+
clone[rgb] = limitRange(value, max);
|
|
587
|
+
return clone;
|
|
588
|
+
}
|
|
589
|
+
_c(input) {
|
|
590
|
+
return new this.constructor(input);
|
|
591
|
+
}
|
|
592
|
+
getMax() {
|
|
593
|
+
if (typeof this._max === 'undefined') {
|
|
594
|
+
this._max = Math.max(this.r, this.g, this.b);
|
|
595
|
+
}
|
|
596
|
+
return this._max;
|
|
597
|
+
}
|
|
598
|
+
getMin() {
|
|
599
|
+
if (typeof this._min === 'undefined') {
|
|
600
|
+
this._min = Math.min(this.r, this.g, this.b);
|
|
601
|
+
}
|
|
602
|
+
return this._min;
|
|
603
|
+
}
|
|
604
|
+
fromHexString(trimStr) {
|
|
605
|
+
const withoutPrefix = trimStr.replace('#', '');
|
|
606
|
+
function connectNum(index1, index2) {
|
|
607
|
+
return parseInt(withoutPrefix[index1] + withoutPrefix[index2 || index1], 16);
|
|
608
|
+
}
|
|
609
|
+
if (withoutPrefix.length < 6) {
|
|
610
|
+
// #rgb or #rgba
|
|
611
|
+
this.r = connectNum(0);
|
|
612
|
+
this.g = connectNum(1);
|
|
613
|
+
this.b = connectNum(2);
|
|
614
|
+
this.a = withoutPrefix[3] ? connectNum(3) / 255 : 1;
|
|
615
|
+
} else {
|
|
616
|
+
// #rrggbb or #rrggbbaa
|
|
617
|
+
this.r = connectNum(0, 1);
|
|
618
|
+
this.g = connectNum(2, 3);
|
|
619
|
+
this.b = connectNum(4, 5);
|
|
620
|
+
this.a = withoutPrefix[6] ? connectNum(6, 7) / 255 : 1;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
fromHsl({
|
|
624
|
+
h: _h,
|
|
625
|
+
s,
|
|
626
|
+
l,
|
|
627
|
+
a
|
|
628
|
+
}) {
|
|
629
|
+
const h = (_h % 360 + 360) % 360;
|
|
630
|
+
this._h = h;
|
|
631
|
+
this._hsl_s = s;
|
|
632
|
+
this._l = l;
|
|
633
|
+
this.a = typeof a === 'number' ? a : 1;
|
|
634
|
+
if (s <= 0) {
|
|
635
|
+
const rgb = round(l * 255);
|
|
636
|
+
this.r = rgb;
|
|
637
|
+
this.g = rgb;
|
|
638
|
+
this.b = rgb;
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
let r = 0,
|
|
642
|
+
g = 0,
|
|
643
|
+
b = 0;
|
|
644
|
+
const huePrime = h / 60;
|
|
645
|
+
const chroma = (1 - Math.abs(2 * l - 1)) * s;
|
|
646
|
+
const secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
647
|
+
if (huePrime >= 0 && huePrime < 1) {
|
|
648
|
+
r = chroma;
|
|
649
|
+
g = secondComponent;
|
|
650
|
+
} else if (huePrime >= 1 && huePrime < 2) {
|
|
651
|
+
r = secondComponent;
|
|
652
|
+
g = chroma;
|
|
653
|
+
} else if (huePrime >= 2 && huePrime < 3) {
|
|
654
|
+
g = chroma;
|
|
655
|
+
b = secondComponent;
|
|
656
|
+
} else if (huePrime >= 3 && huePrime < 4) {
|
|
657
|
+
g = secondComponent;
|
|
658
|
+
b = chroma;
|
|
659
|
+
} else if (huePrime >= 4 && huePrime < 5) {
|
|
660
|
+
r = secondComponent;
|
|
661
|
+
b = chroma;
|
|
662
|
+
} else if (huePrime >= 5 && huePrime < 6) {
|
|
663
|
+
r = chroma;
|
|
664
|
+
b = secondComponent;
|
|
665
|
+
}
|
|
666
|
+
const lightnessModification = l - chroma / 2;
|
|
667
|
+
this.r = round((r + lightnessModification) * 255);
|
|
668
|
+
this.g = round((g + lightnessModification) * 255);
|
|
669
|
+
this.b = round((b + lightnessModification) * 255);
|
|
670
|
+
}
|
|
671
|
+
fromHsv({
|
|
672
|
+
h: _h,
|
|
673
|
+
s,
|
|
674
|
+
v,
|
|
675
|
+
a
|
|
676
|
+
}) {
|
|
677
|
+
const h = (_h % 360 + 360) % 360;
|
|
678
|
+
this._h = h;
|
|
679
|
+
this._hsv_s = s;
|
|
680
|
+
this._v = v;
|
|
681
|
+
this.a = typeof a === 'number' ? a : 1;
|
|
682
|
+
const vv = round(v * 255);
|
|
683
|
+
this.r = vv;
|
|
684
|
+
this.g = vv;
|
|
685
|
+
this.b = vv;
|
|
686
|
+
if (s <= 0) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
const hh = h / 60;
|
|
690
|
+
const i = Math.floor(hh);
|
|
691
|
+
const ff = hh - i;
|
|
692
|
+
const p = round(v * (1.0 - s) * 255);
|
|
693
|
+
const q = round(v * (1.0 - s * ff) * 255);
|
|
694
|
+
const t = round(v * (1.0 - s * (1.0 - ff)) * 255);
|
|
695
|
+
switch (i) {
|
|
696
|
+
case 0:
|
|
697
|
+
this.g = t;
|
|
698
|
+
this.b = p;
|
|
699
|
+
break;
|
|
700
|
+
case 1:
|
|
701
|
+
this.r = q;
|
|
702
|
+
this.b = p;
|
|
703
|
+
break;
|
|
704
|
+
case 2:
|
|
705
|
+
this.r = p;
|
|
706
|
+
this.b = t;
|
|
707
|
+
break;
|
|
708
|
+
case 3:
|
|
709
|
+
this.r = p;
|
|
710
|
+
this.g = q;
|
|
711
|
+
break;
|
|
712
|
+
case 4:
|
|
713
|
+
this.r = t;
|
|
714
|
+
this.g = p;
|
|
715
|
+
break;
|
|
716
|
+
case 5:
|
|
717
|
+
default:
|
|
718
|
+
this.g = p;
|
|
719
|
+
this.b = q;
|
|
720
|
+
break;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
fromHsvString(trimStr) {
|
|
724
|
+
const cells = splitColorStr(trimStr, parseHSVorHSL);
|
|
725
|
+
this.fromHsv({
|
|
726
|
+
h: cells[0],
|
|
727
|
+
s: cells[1],
|
|
728
|
+
v: cells[2],
|
|
729
|
+
a: cells[3]
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
fromHslString(trimStr) {
|
|
733
|
+
const cells = splitColorStr(trimStr, parseHSVorHSL);
|
|
734
|
+
this.fromHsl({
|
|
735
|
+
h: cells[0],
|
|
736
|
+
s: cells[1],
|
|
737
|
+
l: cells[2],
|
|
738
|
+
a: cells[3]
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
fromRgbString(trimStr) {
|
|
742
|
+
const cells = splitColorStr(trimStr, (num, txt) =>
|
|
743
|
+
// Convert percentage to number. e.g. 50% -> 128
|
|
744
|
+
txt.includes('%') ? round(num / 100 * 255) : num);
|
|
745
|
+
this.r = cells[0];
|
|
746
|
+
this.g = cells[1];
|
|
747
|
+
this.b = cells[2];
|
|
748
|
+
this.a = cells[3];
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
const hueStep = 2; // 色相阶梯
|
|
753
|
+
const saturationStep = 0.16; // 饱和度阶梯,浅色部分
|
|
754
|
+
const saturationStep2 = 0.05; // 饱和度阶梯,深色部分
|
|
755
|
+
const brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
|
|
756
|
+
const brightnessStep2 = 0.15; // 亮度阶梯,深色部分
|
|
757
|
+
const lightColorCount = 5; // 浅色数量,主色上
|
|
758
|
+
const darkColorCount = 4; // 深色数量,主色下
|
|
759
|
+
|
|
760
|
+
// 暗色主题颜色映射关系表
|
|
761
|
+
const darkColorMap = [{
|
|
762
|
+
index: 7,
|
|
763
|
+
amount: 15
|
|
764
|
+
}, {
|
|
765
|
+
index: 6,
|
|
766
|
+
amount: 25
|
|
767
|
+
}, {
|
|
768
|
+
index: 5,
|
|
769
|
+
amount: 30
|
|
770
|
+
}, {
|
|
771
|
+
index: 5,
|
|
772
|
+
amount: 45
|
|
773
|
+
}, {
|
|
774
|
+
index: 5,
|
|
775
|
+
amount: 65
|
|
776
|
+
}, {
|
|
777
|
+
index: 5,
|
|
778
|
+
amount: 85
|
|
779
|
+
}, {
|
|
780
|
+
index: 4,
|
|
781
|
+
amount: 90
|
|
782
|
+
}, {
|
|
783
|
+
index: 3,
|
|
784
|
+
amount: 95
|
|
785
|
+
}, {
|
|
786
|
+
index: 2,
|
|
787
|
+
amount: 97
|
|
788
|
+
}, {
|
|
789
|
+
index: 1,
|
|
790
|
+
amount: 98
|
|
791
|
+
}];
|
|
792
|
+
function getHue(hsv, i, light) {
|
|
793
|
+
let hue;
|
|
794
|
+
// 根据色相不同,色相转向不同
|
|
795
|
+
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
|
|
796
|
+
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
|
|
797
|
+
} else {
|
|
798
|
+
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
|
|
799
|
+
}
|
|
800
|
+
if (hue < 0) {
|
|
801
|
+
hue += 360;
|
|
802
|
+
} else if (hue >= 360) {
|
|
803
|
+
hue -= 360;
|
|
804
|
+
}
|
|
805
|
+
return hue;
|
|
806
|
+
}
|
|
807
|
+
function getSaturation(hsv, i, light) {
|
|
808
|
+
// grey color don't change saturation
|
|
809
|
+
if (hsv.h === 0 && hsv.s === 0) {
|
|
810
|
+
return hsv.s;
|
|
811
|
+
}
|
|
812
|
+
let saturation;
|
|
813
|
+
if (light) {
|
|
814
|
+
saturation = hsv.s - saturationStep * i;
|
|
815
|
+
} else if (i === darkColorCount) {
|
|
816
|
+
saturation = hsv.s + saturationStep;
|
|
817
|
+
} else {
|
|
818
|
+
saturation = hsv.s + saturationStep2 * i;
|
|
819
|
+
}
|
|
820
|
+
// 边界值修正
|
|
821
|
+
if (saturation > 1) {
|
|
822
|
+
saturation = 1;
|
|
823
|
+
}
|
|
824
|
+
// 第一格的 s 限制在 0.06-0.1 之间
|
|
825
|
+
if (light && i === lightColorCount && saturation > 0.1) {
|
|
826
|
+
saturation = 0.1;
|
|
827
|
+
}
|
|
828
|
+
if (saturation < 0.06) {
|
|
829
|
+
saturation = 0.06;
|
|
830
|
+
}
|
|
831
|
+
return Math.round(saturation * 100) / 100;
|
|
832
|
+
}
|
|
833
|
+
function getValue(hsv, i, light) {
|
|
834
|
+
let value;
|
|
835
|
+
if (light) {
|
|
836
|
+
value = hsv.v + brightnessStep1 * i;
|
|
837
|
+
} else {
|
|
838
|
+
value = hsv.v - brightnessStep2 * i;
|
|
839
|
+
}
|
|
840
|
+
// Clamp value between 0 and 1
|
|
841
|
+
value = Math.max(0, Math.min(1, value));
|
|
842
|
+
return Math.round(value * 100) / 100;
|
|
843
|
+
}
|
|
844
|
+
function generate$1(color, opts = {}) {
|
|
845
|
+
const patterns = [];
|
|
846
|
+
const pColor = new FastColor(color);
|
|
847
|
+
const hsv = pColor.toHsv();
|
|
848
|
+
for (let i = lightColorCount; i > 0; i -= 1) {
|
|
849
|
+
const c = new FastColor({
|
|
850
|
+
h: getHue(hsv, i, true),
|
|
851
|
+
s: getSaturation(hsv, i, true),
|
|
852
|
+
v: getValue(hsv, i, true)
|
|
853
|
+
});
|
|
854
|
+
patterns.push(c);
|
|
855
|
+
}
|
|
856
|
+
patterns.push(pColor);
|
|
857
|
+
for (let i = 1; i <= darkColorCount; i += 1) {
|
|
858
|
+
const c = new FastColor({
|
|
859
|
+
h: getHue(hsv, i),
|
|
860
|
+
s: getSaturation(hsv, i),
|
|
861
|
+
v: getValue(hsv, i)
|
|
862
|
+
});
|
|
863
|
+
patterns.push(c);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// dark theme patterns
|
|
867
|
+
if (opts.theme === 'dark') {
|
|
868
|
+
return darkColorMap.map(({
|
|
869
|
+
index,
|
|
870
|
+
amount
|
|
871
|
+
}) => new FastColor(opts.backgroundColor || '#141414').mix(patterns[index], amount).toHexString());
|
|
872
|
+
}
|
|
873
|
+
return patterns.map(c => c.toHexString());
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
// Generated by script. Do NOT modify!
|
|
877
|
+
const blue = ["#e6f4ff", "#bae0ff", "#91caff", "#69b1ff", "#4096ff", "#1677ff", "#0958d9", "#003eb3", "#002c8c", "#001d66"];
|
|
878
|
+
blue.primary = blue[5];
|
|
879
|
+
|
|
880
|
+
function canUseDom() {
|
|
881
|
+
return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function contains(root, n) {
|
|
885
|
+
if (!root) {
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// Use native if support
|
|
890
|
+
if (root.contains) {
|
|
891
|
+
return root.contains(n);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// `document.contains` not support with IE11
|
|
895
|
+
let node = n;
|
|
896
|
+
while (node) {
|
|
897
|
+
if (node === root) {
|
|
898
|
+
return true;
|
|
899
|
+
}
|
|
900
|
+
node = node.parentNode;
|
|
901
|
+
}
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
const APPEND_ORDER = 'data-rc-order';
|
|
906
|
+
const APPEND_PRIORITY = 'data-rc-priority';
|
|
907
|
+
const MARK_KEY = `rc-util-key`;
|
|
908
|
+
const containerCache = new Map();
|
|
909
|
+
function getMark({
|
|
910
|
+
mark
|
|
911
|
+
} = {}) {
|
|
912
|
+
if (mark) {
|
|
913
|
+
return mark.startsWith('data-') ? mark : `data-${mark}`;
|
|
914
|
+
}
|
|
915
|
+
return MARK_KEY;
|
|
916
|
+
}
|
|
917
|
+
function getContainer(option) {
|
|
918
|
+
if (option.attachTo) {
|
|
919
|
+
return option.attachTo;
|
|
920
|
+
}
|
|
921
|
+
const head = document.querySelector('head');
|
|
922
|
+
return head || document.body;
|
|
923
|
+
}
|
|
924
|
+
function getOrder(prepend) {
|
|
925
|
+
if (prepend === 'queue') {
|
|
926
|
+
return 'prependQueue';
|
|
927
|
+
}
|
|
928
|
+
return prepend ? 'prepend' : 'append';
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Find style which inject by rc-util
|
|
933
|
+
*/
|
|
934
|
+
function findStyles(container) {
|
|
935
|
+
return Array.from((containerCache.get(container) || container).children).filter(node => node.tagName === 'STYLE');
|
|
936
|
+
}
|
|
937
|
+
function injectCSS(css, option = {}) {
|
|
938
|
+
if (!canUseDom()) {
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
const {
|
|
942
|
+
csp,
|
|
943
|
+
prepend,
|
|
944
|
+
priority = 0
|
|
945
|
+
} = option;
|
|
946
|
+
const mergedOrder = getOrder(prepend);
|
|
947
|
+
const isPrependQueue = mergedOrder === 'prependQueue';
|
|
948
|
+
const styleNode = document.createElement('style');
|
|
949
|
+
styleNode.setAttribute(APPEND_ORDER, mergedOrder);
|
|
950
|
+
if (isPrependQueue && priority) {
|
|
951
|
+
styleNode.setAttribute(APPEND_PRIORITY, `${priority}`);
|
|
952
|
+
}
|
|
953
|
+
if (csp?.nonce) {
|
|
954
|
+
styleNode.nonce = csp?.nonce;
|
|
955
|
+
}
|
|
956
|
+
styleNode.innerHTML = css;
|
|
957
|
+
const container = getContainer(option);
|
|
958
|
+
const {
|
|
959
|
+
firstChild
|
|
960
|
+
} = container;
|
|
961
|
+
if (prepend) {
|
|
962
|
+
// If is queue `prepend`, it will prepend first style and then append rest style
|
|
963
|
+
if (isPrependQueue) {
|
|
964
|
+
const existStyle = (option.styles || findStyles(container)).filter(node => {
|
|
965
|
+
// Ignore style which not injected by rc-util with prepend
|
|
966
|
+
if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
// Ignore style which priority less then new style
|
|
971
|
+
const nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0);
|
|
972
|
+
return priority >= nodePriority;
|
|
973
|
+
});
|
|
974
|
+
if (existStyle.length) {
|
|
975
|
+
container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);
|
|
976
|
+
return styleNode;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// Use `insertBefore` as `prepend`
|
|
981
|
+
container.insertBefore(styleNode, firstChild);
|
|
982
|
+
} else {
|
|
983
|
+
container.appendChild(styleNode);
|
|
984
|
+
}
|
|
985
|
+
return styleNode;
|
|
986
|
+
}
|
|
987
|
+
function findExistNode(key, option = {}) {
|
|
988
|
+
let {
|
|
989
|
+
styles
|
|
990
|
+
} = option;
|
|
991
|
+
styles ||= findStyles(getContainer(option));
|
|
992
|
+
return styles.find(node => node.getAttribute(getMark(option)) === key);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* qiankun will inject `appendChild` to insert into other
|
|
997
|
+
*/
|
|
998
|
+
function syncRealContainer(container, option) {
|
|
999
|
+
const cachedRealContainer = containerCache.get(container);
|
|
1000
|
+
|
|
1001
|
+
// Find real container when not cached or cached container removed
|
|
1002
|
+
if (!cachedRealContainer || !contains(document, cachedRealContainer)) {
|
|
1003
|
+
const placeholderStyle = injectCSS('', option);
|
|
1004
|
+
const {
|
|
1005
|
+
parentNode
|
|
1006
|
+
} = placeholderStyle;
|
|
1007
|
+
containerCache.set(container, parentNode);
|
|
1008
|
+
container.removeChild(placeholderStyle);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
function updateCSS(css, key, originOption = {}) {
|
|
1012
|
+
const container = getContainer(originOption);
|
|
1013
|
+
const styles = findStyles(container);
|
|
1014
|
+
const option = {
|
|
1015
|
+
...originOption,
|
|
1016
|
+
styles
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
// Sync real parent
|
|
1020
|
+
syncRealContainer(container, option);
|
|
1021
|
+
const existNode = findExistNode(key, option);
|
|
1022
|
+
if (existNode) {
|
|
1023
|
+
if (option.csp?.nonce && existNode.nonce !== option.csp?.nonce) {
|
|
1024
|
+
existNode.nonce = option.csp?.nonce;
|
|
1025
|
+
}
|
|
1026
|
+
if (existNode.innerHTML !== css) {
|
|
1027
|
+
existNode.innerHTML = css;
|
|
1028
|
+
}
|
|
1029
|
+
return existNode;
|
|
1030
|
+
}
|
|
1031
|
+
const newNode = injectCSS(css, option);
|
|
1032
|
+
newNode.setAttribute(getMark(option), key);
|
|
1033
|
+
return newNode;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
function getRoot(ele) {
|
|
1037
|
+
return ele?.getRootNode?.();
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Check if is in shadowRoot
|
|
1042
|
+
*/
|
|
1043
|
+
function inShadow(ele) {
|
|
1044
|
+
return getRoot(ele) instanceof ShadowRoot;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Return shadowRoot if possible
|
|
1049
|
+
*/
|
|
1050
|
+
function getShadowRoot(ele) {
|
|
1051
|
+
return inShadow(ele) ? getRoot(ele) : null;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/* eslint-disable no-console */
|
|
1055
|
+
let warned = {};
|
|
1056
|
+
const preWarningFns = [];
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Pre warning enable you to parse content before console.error.
|
|
1060
|
+
* Modify to null will prevent warning.
|
|
1061
|
+
*/
|
|
1062
|
+
const preMessage = fn => {
|
|
1063
|
+
preWarningFns.push(fn);
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Warning if condition not match.
|
|
1068
|
+
* @param valid Condition
|
|
1069
|
+
* @param message Warning message
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```js
|
|
1072
|
+
* warning(false, 'some error'); // print some error
|
|
1073
|
+
* warning(true, 'some error'); // print nothing
|
|
1074
|
+
* warning(1 === 2, 'some error'); // print some error
|
|
1075
|
+
* ```
|
|
1076
|
+
*/
|
|
1077
|
+
function warning$1(valid, message) {
|
|
1078
|
+
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
1079
|
+
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? '', 'warning'), message);
|
|
1080
|
+
if (finalMessage) {
|
|
1081
|
+
console.error(`Warning: ${finalMessage}`);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/** @see Similar to {@link warning} */
|
|
1087
|
+
function note(valid, message) {
|
|
1088
|
+
if (process.env.NODE_ENV !== 'production' && !valid && console !== undefined) {
|
|
1089
|
+
const finalMessage = preWarningFns.reduce((msg, preMessageFn) => preMessageFn(msg ?? '', 'note'), message);
|
|
1090
|
+
if (finalMessage) {
|
|
1091
|
+
console.warn(`Note: ${finalMessage}`);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
function resetWarned() {
|
|
1096
|
+
warned = {};
|
|
1097
|
+
}
|
|
1098
|
+
function call(method, valid, message) {
|
|
1099
|
+
if (!valid && !warned[message]) {
|
|
1100
|
+
method(false, message);
|
|
1101
|
+
warned[message] = true;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/** @see Same as {@link warning}, but only warn once for the same message */
|
|
1106
|
+
function warningOnce(valid, message) {
|
|
1107
|
+
call(warning$1, valid, message);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/** @see Same as {@link warning}, but only warn once for the same message */
|
|
1111
|
+
function noteOnce(valid, message) {
|
|
1112
|
+
call(note, valid, message);
|
|
1113
|
+
}
|
|
1114
|
+
warningOnce.preMessage = preMessage;
|
|
1115
|
+
warningOnce.resetWarned = resetWarned;
|
|
1116
|
+
warningOnce.noteOnce = noteOnce;
|
|
1117
|
+
|
|
1118
|
+
function camelCase(input) {
|
|
1119
|
+
return input.replace(/-(.)/g, (match, g) => g.toUpperCase());
|
|
1120
|
+
}
|
|
1121
|
+
function warning(valid, message) {
|
|
1122
|
+
warningOnce(valid, `[@ant-design/icons] ${message}`);
|
|
1123
|
+
}
|
|
1124
|
+
function isIconDefinition(target) {
|
|
1125
|
+
return typeof target === 'object' && typeof target.name === 'string' && typeof target.theme === 'string' && (typeof target.icon === 'object' || typeof target.icon === 'function');
|
|
1126
|
+
}
|
|
1127
|
+
function normalizeAttrs(attrs = {}) {
|
|
1128
|
+
return Object.keys(attrs).reduce((acc, key) => {
|
|
1129
|
+
const val = attrs[key];
|
|
1130
|
+
switch (key) {
|
|
1131
|
+
case 'class':
|
|
1132
|
+
acc.className = val;
|
|
1133
|
+
delete acc.class;
|
|
1134
|
+
break;
|
|
1135
|
+
default:
|
|
1136
|
+
delete acc[key];
|
|
1137
|
+
acc[camelCase(key)] = val;
|
|
1138
|
+
}
|
|
1139
|
+
return acc;
|
|
1140
|
+
}, {});
|
|
1141
|
+
}
|
|
1142
|
+
function generate(node, key, rootProps) {
|
|
1143
|
+
if (!rootProps) {
|
|
1144
|
+
return /*#__PURE__*/React__default.createElement(node.tag, {
|
|
1145
|
+
key,
|
|
1146
|
+
...normalizeAttrs(node.attrs)
|
|
1147
|
+
}, (node.children || []).map((child, index) => generate(child, `${key}-${node.tag}-${index}`)));
|
|
1148
|
+
}
|
|
1149
|
+
return /*#__PURE__*/React__default.createElement(node.tag, {
|
|
1150
|
+
key,
|
|
1151
|
+
...normalizeAttrs(node.attrs),
|
|
1152
|
+
...rootProps
|
|
1153
|
+
}, (node.children || []).map((child, index) => generate(child, `${key}-${node.tag}-${index}`)));
|
|
1154
|
+
}
|
|
1155
|
+
function getSecondaryColor(primaryColor) {
|
|
1156
|
+
// choose the second color
|
|
1157
|
+
return generate$1(primaryColor)[0];
|
|
1158
|
+
}
|
|
1159
|
+
function normalizeTwoToneColors(twoToneColor) {
|
|
1160
|
+
if (!twoToneColor) {
|
|
1161
|
+
return [];
|
|
1162
|
+
}
|
|
1163
|
+
return Array.isArray(twoToneColor) ? twoToneColor : [twoToneColor];
|
|
1164
|
+
}
|
|
1165
|
+
const iconStyles = `
|
|
1166
|
+
.anticon {
|
|
1167
|
+
display: inline-flex;
|
|
1168
|
+
align-items: center;
|
|
1169
|
+
color: inherit;
|
|
1170
|
+
font-style: normal;
|
|
1171
|
+
line-height: 0;
|
|
1172
|
+
text-align: center;
|
|
1173
|
+
text-transform: none;
|
|
1174
|
+
vertical-align: -0.125em;
|
|
1175
|
+
text-rendering: optimizeLegibility;
|
|
1176
|
+
-webkit-font-smoothing: antialiased;
|
|
1177
|
+
-moz-osx-font-smoothing: grayscale;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
.anticon > * {
|
|
1181
|
+
line-height: 1;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
.anticon svg {
|
|
1185
|
+
display: inline-block;
|
|
1186
|
+
vertical-align: inherit;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
.anticon::before {
|
|
1190
|
+
display: none;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
.anticon .anticon-icon {
|
|
1194
|
+
display: block;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
.anticon[tabindex] {
|
|
1198
|
+
cursor: pointer;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
.anticon-spin::before,
|
|
1202
|
+
.anticon-spin {
|
|
1203
|
+
display: inline-block;
|
|
1204
|
+
-webkit-animation: loadingCircle 1s infinite linear;
|
|
1205
|
+
animation: loadingCircle 1s infinite linear;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
@-webkit-keyframes loadingCircle {
|
|
1209
|
+
100% {
|
|
1210
|
+
-webkit-transform: rotate(360deg);
|
|
1211
|
+
transform: rotate(360deg);
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
@keyframes loadingCircle {
|
|
1216
|
+
100% {
|
|
1217
|
+
-webkit-transform: rotate(360deg);
|
|
1218
|
+
transform: rotate(360deg);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
`;
|
|
1222
|
+
const useInsertStyles = eleRef => {
|
|
1223
|
+
const {
|
|
1224
|
+
csp,
|
|
1225
|
+
prefixCls,
|
|
1226
|
+
layer
|
|
1227
|
+
} = useContext(Context);
|
|
1228
|
+
let mergedStyleStr = iconStyles;
|
|
1229
|
+
if (prefixCls) {
|
|
1230
|
+
mergedStyleStr = mergedStyleStr.replace(/anticon/g, prefixCls);
|
|
1231
|
+
}
|
|
1232
|
+
if (layer) {
|
|
1233
|
+
mergedStyleStr = `@layer ${layer} {\n${mergedStyleStr}\n}`;
|
|
1234
|
+
}
|
|
1235
|
+
useEffect(() => {
|
|
1236
|
+
const ele = eleRef.current;
|
|
1237
|
+
const shadowRoot = getShadowRoot(ele);
|
|
1238
|
+
updateCSS(mergedStyleStr, '@ant-design-icons', {
|
|
1239
|
+
prepend: !layer,
|
|
1240
|
+
csp,
|
|
1241
|
+
attachTo: shadowRoot
|
|
1242
|
+
});
|
|
1243
|
+
}, []);
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
const twoToneColorPalette = {
|
|
1247
|
+
primaryColor: '#333',
|
|
1248
|
+
secondaryColor: '#E6E6E6',
|
|
1249
|
+
calculated: false
|
|
1250
|
+
};
|
|
1251
|
+
function setTwoToneColors({
|
|
1252
|
+
primaryColor,
|
|
1253
|
+
secondaryColor
|
|
1254
|
+
}) {
|
|
1255
|
+
twoToneColorPalette.primaryColor = primaryColor;
|
|
1256
|
+
twoToneColorPalette.secondaryColor = secondaryColor || getSecondaryColor(primaryColor);
|
|
1257
|
+
twoToneColorPalette.calculated = !!secondaryColor;
|
|
1258
|
+
}
|
|
1259
|
+
function getTwoToneColors() {
|
|
1260
|
+
return {
|
|
1261
|
+
...twoToneColorPalette
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
const IconBase$1 = props => {
|
|
1265
|
+
const {
|
|
1266
|
+
icon,
|
|
1267
|
+
className,
|
|
1268
|
+
onClick,
|
|
1269
|
+
style,
|
|
1270
|
+
primaryColor,
|
|
1271
|
+
secondaryColor,
|
|
1272
|
+
...restProps
|
|
1273
|
+
} = props;
|
|
1274
|
+
const svgRef = React.useRef(null);
|
|
1275
|
+
let colors = twoToneColorPalette;
|
|
1276
|
+
if (primaryColor) {
|
|
1277
|
+
colors = {
|
|
1278
|
+
primaryColor,
|
|
1279
|
+
secondaryColor: secondaryColor || getSecondaryColor(primaryColor)
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
useInsertStyles(svgRef);
|
|
1283
|
+
warning(isIconDefinition(icon), `icon should be icon definiton, but got ${icon}`);
|
|
1284
|
+
if (!isIconDefinition(icon)) {
|
|
1285
|
+
return null;
|
|
1286
|
+
}
|
|
1287
|
+
let target = icon;
|
|
1288
|
+
if (target && typeof target.icon === 'function') {
|
|
1289
|
+
target = {
|
|
1290
|
+
...target,
|
|
1291
|
+
icon: target.icon(colors.primaryColor, colors.secondaryColor)
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
return generate(target.icon, `svg-${target.name}`, {
|
|
1295
|
+
className,
|
|
1296
|
+
onClick,
|
|
1297
|
+
style,
|
|
1298
|
+
'data-icon': target.name,
|
|
1299
|
+
width: '1em',
|
|
1300
|
+
height: '1em',
|
|
1301
|
+
fill: 'currentColor',
|
|
1302
|
+
'aria-hidden': 'true',
|
|
1303
|
+
...restProps,
|
|
1304
|
+
ref: svgRef
|
|
1305
|
+
});
|
|
1306
|
+
};
|
|
1307
|
+
IconBase$1.displayName = 'IconReact';
|
|
1308
|
+
IconBase$1.getTwoToneColors = getTwoToneColors;
|
|
1309
|
+
IconBase$1.setTwoToneColors = setTwoToneColors;
|
|
1310
|
+
var ReactIcon = IconBase$1;
|
|
1311
|
+
|
|
1312
|
+
function setTwoToneColor(twoToneColor) {
|
|
1313
|
+
const [primaryColor, secondaryColor] = normalizeTwoToneColors(twoToneColor);
|
|
1314
|
+
return ReactIcon.setTwoToneColors({
|
|
1315
|
+
primaryColor,
|
|
1316
|
+
secondaryColor
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
function getTwoToneColor() {
|
|
1320
|
+
const colors = ReactIcon.getTwoToneColors();
|
|
1321
|
+
if (!colors.calculated) {
|
|
1322
|
+
return colors.primaryColor;
|
|
1323
|
+
}
|
|
1324
|
+
return [colors.primaryColor, colors.secondaryColor];
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function _extends$2() { _extends$2 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
|
|
1328
|
+
// Initial setting
|
|
1329
|
+
// should move it to antd main repo?
|
|
1330
|
+
setTwoToneColor(blue.primary);
|
|
1331
|
+
|
|
1332
|
+
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757#issuecomment-488848720
|
|
1333
|
+
|
|
1334
|
+
const Icon = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
1335
|
+
const {
|
|
1336
|
+
// affect outter <i>...</i>
|
|
1337
|
+
className,
|
|
1338
|
+
// affect inner <svg>...</svg>
|
|
1339
|
+
icon,
|
|
1340
|
+
spin,
|
|
1341
|
+
rotate,
|
|
1342
|
+
tabIndex,
|
|
1343
|
+
onClick,
|
|
1344
|
+
// other
|
|
1345
|
+
twoToneColor,
|
|
1346
|
+
...restProps
|
|
1347
|
+
} = props;
|
|
1348
|
+
const {
|
|
1349
|
+
prefixCls = 'anticon',
|
|
1350
|
+
rootClassName
|
|
1351
|
+
} = React.useContext(Context);
|
|
1352
|
+
const classString = clsx(rootClassName, prefixCls, {
|
|
1353
|
+
[`${prefixCls}-${icon.name}`]: !!icon.name,
|
|
1354
|
+
[`${prefixCls}-spin`]: !!spin || icon.name === 'loading'
|
|
1355
|
+
}, className);
|
|
1356
|
+
let iconTabIndex = tabIndex;
|
|
1357
|
+
if (iconTabIndex === undefined && onClick) {
|
|
1358
|
+
iconTabIndex = -1;
|
|
1359
|
+
}
|
|
1360
|
+
const svgStyle = rotate ? {
|
|
1361
|
+
msTransform: `rotate(${rotate}deg)`,
|
|
1362
|
+
transform: `rotate(${rotate}deg)`
|
|
1363
|
+
} : undefined;
|
|
1364
|
+
const [primaryColor, secondaryColor] = normalizeTwoToneColors(twoToneColor);
|
|
1365
|
+
return /*#__PURE__*/React.createElement("span", _extends$2({
|
|
1366
|
+
role: "img",
|
|
1367
|
+
"aria-label": icon.name
|
|
1368
|
+
}, restProps, {
|
|
1369
|
+
ref: ref,
|
|
1370
|
+
tabIndex: iconTabIndex,
|
|
1371
|
+
onClick: onClick,
|
|
1372
|
+
className: classString
|
|
1373
|
+
}), /*#__PURE__*/React.createElement(ReactIcon, {
|
|
1374
|
+
icon: icon,
|
|
1375
|
+
primaryColor: primaryColor,
|
|
1376
|
+
secondaryColor: secondaryColor,
|
|
1377
|
+
style: svgStyle
|
|
1378
|
+
}));
|
|
1379
|
+
});
|
|
1380
|
+
Icon.getTwoToneColor = getTwoToneColor;
|
|
1381
|
+
Icon.setTwoToneColor = setTwoToneColor;
|
|
1382
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1383
|
+
Icon.displayName = 'AntdIcon';
|
|
1384
|
+
}
|
|
1385
|
+
var AntdIcon = Icon;
|
|
1386
|
+
|
|
1387
|
+
// This icon file is generated automatically.
|
|
1388
|
+
var MoreOutlined$2 = { "icon": { "tag": "svg", "attrs": { "viewBox": "64 64 896 896", "focusable": "false" }, "children": [{ "tag": "path", "attrs": { "d": "M456 231a56 56 0 10112 0 56 56 0 10-112 0zm0 280a56 56 0 10112 0 56 56 0 10-112 0zm0 280a56 56 0 10112 0 56 56 0 10-112 0z" } }] }, "name": "more", "theme": "outlined" };
|
|
1389
|
+
var MoreOutlinedSvg = MoreOutlined$2;
|
|
1390
|
+
|
|
1391
|
+
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
1392
|
+
const MoreOutlined = (props, ref) => /*#__PURE__*/React.createElement(AntdIcon, _extends$1({}, props, {
|
|
1393
|
+
ref: ref,
|
|
1394
|
+
icon: MoreOutlinedSvg
|
|
1395
|
+
}));
|
|
1396
|
+
|
|
1397
|
+
/** */
|
|
1398
|
+
const RefIcon = /*#__PURE__*/React.forwardRef(MoreOutlined);
|
|
1399
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1400
|
+
RefIcon.displayName = 'MoreOutlined';
|
|
1401
|
+
}
|
|
1402
|
+
var MoreOutlined$1 = RefIcon;
|
|
1403
|
+
|
|
1404
|
+
function _extends() {
|
|
1405
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
1406
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
1407
|
+
var t = arguments[e];
|
|
1408
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
1409
|
+
}
|
|
1410
|
+
return n;
|
|
1411
|
+
}, _extends.apply(null, arguments);
|
|
1412
|
+
}
|
|
1413
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
1414
|
+
if (null == r) return {};
|
|
1415
|
+
var t = {};
|
|
1416
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
1417
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
1418
|
+
t[n] = r[n];
|
|
1419
|
+
}
|
|
1420
|
+
return t;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
const _excluded = ["size", "color", "children"];
|
|
1424
|
+
const IconBase = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
1425
|
+
let {
|
|
1426
|
+
size = '1em',
|
|
1427
|
+
color = 'currentColor',
|
|
1428
|
+
children
|
|
1429
|
+
} = _ref,
|
|
1430
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1431
|
+
return /*#__PURE__*/jsx("svg", _extends({
|
|
1432
|
+
ref: ref,
|
|
1433
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1434
|
+
width: size,
|
|
1435
|
+
height: size,
|
|
1436
|
+
fill: color,
|
|
1437
|
+
viewBox: "0 0 256 256"
|
|
1438
|
+
}, props, {
|
|
1439
|
+
children: children
|
|
1440
|
+
}));
|
|
1441
|
+
});
|
|
1442
|
+
IconBase.displayName = 'IconBase';
|
|
1443
|
+
|
|
1444
|
+
// Helper to create icon component
|
|
1445
|
+
const createIcon = (path, displayName) => {
|
|
1446
|
+
const Icon = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/jsx(IconBase, _extends({
|
|
1447
|
+
ref: ref
|
|
1448
|
+
}, props, {
|
|
1449
|
+
children: /*#__PURE__*/jsx("path", {
|
|
1450
|
+
d: path
|
|
1451
|
+
})
|
|
1452
|
+
})));
|
|
1453
|
+
Icon.displayName = displayName;
|
|
1454
|
+
return Icon;
|
|
1455
|
+
};
|
|
1456
|
+
|
|
1457
|
+
// Folder icons
|
|
1458
|
+
const Folder = createIcon('M216,72H131.31L104,44.69A15.86,15.86,0,0,0,92.69,40H40A16,16,0,0,0,24,56V200.62A15.4,15.4,0,0,0,39.38,216H216.89A15.13,15.13,0,0,0,232,200.89V88A16,16,0,0,0,216,72ZM40,56H92.69l16,16H40ZM216,200H40V88H216Z', 'Folder');
|
|
1459
|
+
const FolderOpen = createIcon('M245,110.64A16,16,0,0,0,232,104H216V88a16,16,0,0,0-16-16H130.67L102.94,51.2a16.14,16.14,0,0,0-9.6-3.2H40A16,16,0,0,0,24,64V208h0a8,8,0,0,0,8,8H211.1a8,8,0,0,0,7.59-5.47l28.49-85.47A16.05,16.05,0,0,0,245,110.64ZM93.34,64,123.2,86.4A8,8,0,0,0,128,88h72v16H69.77a16,16,0,0,0-15.18,10.94L40,158.7V64Zm112,136H43.1l26.67-80H232Z', 'FolderOpen');
|
|
1460
|
+
|
|
1461
|
+
// File icons
|
|
1462
|
+
const File = createIcon('M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z', 'File');
|
|
1463
|
+
const FileText = createIcon('M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z', 'FileText');
|
|
1464
|
+
const FilePdf = createIcon('M224,152a8,8,0,0,1-8,8H192v16h16a8,8,0,0,1,0,16H192v16a8,8,0,0,1-16,0V152a8,8,0,0,1,8-8h32A8,8,0,0,1,224,152ZM92,172a28,28,0,0,1-28,28H56v8a8,8,0,0,1-16,0V152a8,8,0,0,1,8-8H64A28,28,0,0,1,92,172Zm-16,0a12,12,0,0,0-12-12H56v24h8A12,12,0,0,0,76,172Zm88,8a36,36,0,0,1-36,36H112a8,8,0,0,1-8-8V152a8,8,0,0,1,8-8h16A36,36,0,0,1,164,180Zm-16,0a20,20,0,0,0-20-20h-8v40h8A20,20,0,0,0,148,180ZM40,112V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0ZM160,80h28.69L160,51.31Z', 'FilePdf');
|
|
1465
|
+
const FileDoc = createIcon('M52,144H36a8,8,0,0,0-8,8v56a8,8,0,0,0,8,8H52a36,36,0,0,0,0-72Zm0,56H44V160h8a20,20,0,0,1,0,40Zm169.53-4.91a8,8,0,0,1,.25,11.31A30.06,30.06,0,0,1,200,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30.06,30.06,0,0,1,21.78,9.6,8,8,0,0,1-11.56,11.06A14.24,14.24,0,0,0,200,160c-8.82,0-16,9-16,20s7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,0,1,221.53,195.09ZM128,144c-17.65,0-32,16.15-32,36s14.35,36,32,36,32-16.15,32-36S145.65,144,128,144Zm0,56c-8.82,0-16-9-16-20s7.18-20,16-20,16,9,16,20S136.82,200,128,200ZM48,120a8,8,0,0,0,8-8V40h88V88a8,8,0,0,0,8,8h48v16a8,8,0,0,0,16,0V88a8,8,0,0,0-2.34-5.66l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72A8,8,0,0,0,48,120ZM160,51.31,188.69,80H160Z', 'FileDoc');
|
|
1466
|
+
const FileXls = createIcon('M156,208a8,8,0,0,1-8,8H120a8,8,0,0,1-8-8V152a8,8,0,0,1,16,0v48h20A8,8,0,0,1,156,208ZM92.65,145.49a8,8,0,0,0-11.16,1.86L68,166.24,54.51,147.35a8,8,0,1,0-13,9.3L58.17,180,41.49,203.35a8,8,0,0,0,13,9.3L68,193.76l13.49,18.89a8,8,0,0,0,13-9.3L77.83,180l16.68-23.35A8,8,0,0,0,92.65,145.49Zm98.94,25.82c-4-1.16-8.14-2.35-10.45-3.84-1.25-.82-1.23-1-1.12-1.9a4.54,4.54,0,0,1,2-3.67c4.6-3.12,15.34-1.72,19.82-.56a8,8,0,0,0,4.07-15.48c-2.11-.55-21-5.22-32.83,2.76a20.58,20.58,0,0,0-8.95,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.33-2.15,3.93-4.6,3.06-15.16,1.55-19.54.35A8,8,0,0,0,173.93,214a60.63,60.63,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.81,20.81,0,0,0,9.18-15.23C218,179,201.48,174.17,191.59,171.31ZM40,112V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88v24a8,8,0,1,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0ZM160,80h28.68L160,51.31Z', 'FileXls');
|
|
1467
|
+
const FilePng = createIcon('M60,144H44a8,8,0,0,0-8,8v56a8,8,0,0,0,16,0v-8h8a28,28,0,0,0,0-56Zm0,40H52V160h8a12,12,0,0,1,0,24Zm164,16.87a8,8,0,0,1-2.22,5.53A30.06,30.06,0,0,1,200,216c-17.64,0-32-16.15-32-36s14.36-36,32-36a29.45,29.45,0,0,1,16.48,5.11,8,8,0,0,1-9,13.27A13.21,13.21,0,0,0,200,160c-8.82,0-16,9-16,20s7.18,20,16,20a13.57,13.57,0,0,0,8-2.72V192a8,8,0,0,1,0-16h8a8,8,0,0,1,8,8ZM156,152v56a8,8,0,0,1-5.56,7.62A7.91,7.91,0,0,1,148,216a8,8,0,0,1-6.51-3.35L116,177v31a8,8,0,0,1-16,0V152a8,8,0,0,1,14.51-4.65L140,183V152a8,8,0,0,1,16,0ZM48,120a8,8,0,0,0,8-8V40h88V88a8,8,0,0,0,8,8h48v16a8,8,0,0,0,16,0V88a8,8,0,0,0-2.34-5.66l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72A8,8,0,0,0,48,120ZM160,51.31,188.69,80H160Z', 'FilePng');
|
|
1468
|
+
const FileJpg = createIcon('M120,144H104a8,8,0,0,0-8,8v56a8,8,0,0,0,16,0v-8h8a28,28,0,0,0,0-56Zm0,40h-8V160h8a12,12,0,0,1,0,24Zm96,0v16.87a8,8,0,0,1-2.22,5.53A30.06,30.06,0,0,1,192,216c-17.64,0-32-16.15-32-36s14.36-36,32-36a29.38,29.38,0,0,1,16.48,5.12,8,8,0,0,1-9,13.26A13.21,13.21,0,0,0,192,160c-8.82,0-16,9-16,20s7.18,20,16,20a13.63,13.63,0,0,0,8-2.71V192a8,8,0,0,1,0-16h8A8,8,0,0,1,216,184ZM80,152v38a26,26,0,0,1-52,0,8,8,0,0,1,16,0,10,10,0,0,0,20,0V152a8,8,0,0,1,16,0ZM213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48v16a8,8,0,0,0,16,0V88A8,8,0,0,0,213.66,82.34ZM160,80V51.31L188.69,80Z', 'FileJpg');
|
|
1469
|
+
const FileSvg = createIcon('M87.82,196.31a20.82,20.82,0,0,1-9.19,15.23C73.44,215,67,216,61.14,216A61.23,61.23,0,0,1,46,214a8,8,0,0,1,4.3-15.41c4.38,1.2,14.95,2.7,19.55-.36.88-.59,1.83-1.52,2.14-3.93.35-2.67-.71-4.1-12.78-7.59-9.35-2.7-25-7.23-23-23.11a20.55,20.55,0,0,1,9-14.95c11.84-8,30.72-3.31,32.83-2.76a8,8,0,0,1-4.07,15.48c-4.48-1.17-15.23-2.56-19.83.56a4.54,4.54,0,0,0-2,3.67c-.11.9-.14,1.09,1.12,1.9,2.31,1.49,6.44,2.68,10.45,3.84C73.5,174.17,90.06,179,87.82,196.31ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,1,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.65,2.34l56,56A8,8,0,0,1,216,88Zm-56-8h28.69L160,51.31Zm-13.3,64.47a8,8,0,0,0-10.23,4.84L124,184.21l-12.47-34.9a8,8,0,1,0-15.06,5.38l20,56a8,8,0,0,0,15.07,0l20-56A8,8,0,0,0,146.7,144.47ZM208,176h-8a8,8,0,0,0,0,16v5.29a13.38,13.38,0,0,1-8,2.71c-8.82,0-16-9-16-20s7.18-20,16-20a13.27,13.27,0,0,1,7.53,2.38,8,8,0,0,0,8.95-13.26A29.38,29.38,0,0,0,192,144c-17.64,0-32,16.15-32,36s14.36,36,32,36a30.06,30.06,0,0,0,21.78-9.6,8,8,0,0,0,2.22-5.53V184A8,8,0,0,0,208,176Z', 'FileSvg');
|
|
1470
|
+
const FileGif = createIcon('M144,72V184a8,8,0,0,1-16,0V72a8,8,0,0,1,16,0Zm88-8H176a8,8,0,0,0-8,8V184a8,8,0,0,0,16,0V136h40a8,8,0,0,0,0-16H184V80h48a8,8,0,0,0,0-16ZM96,120H72a8,8,0,0,0,0,16H88v16a24,24,0,0,1-48,0V104A24,24,0,0,1,64,80c11.19,0,21.61,7.74,24.25,18a8,8,0,0,0,15.5-4C99.27,76.62,82.56,64,64,64a40,40,0,0,0-40,40v48a40,40,0,0,0,80,0V128A8,8,0,0,0,96,120Z', 'FileGif');
|
|
1471
|
+
const FileVideo = createIcon('M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48V216h-8a8,8,0,0,0,0,16h8a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM155.88,145a8,8,0,0,0-8.12.22l-19.95,12.46A16,16,0,0,0,112,144H48a16,16,0,0,0-16,16v48a16,16,0,0,0,16,16h64a16,16,0,0,0,15.81-13.68l19.95,12.46A8,8,0,0,0,160,216V152A8,8,0,0,0,155.88,145ZM112,208H48V160h64v48Zm32-6.43-16-10V176.43l16-10Z', 'FileVideo');
|
|
1472
|
+
const FileAudio = createIcon('M99.06,128.61a8,8,0,0,0-8.72,1.73L68.69,152H48a8,8,0,0,0-8,8v40a8,8,0,0,0,8,8H68.69l21.65,21.66A8,8,0,0,0,104,224V136A8,8,0,0,0,99.06,128.61ZM88,204.69,77.66,194.34A8,8,0,0,0,72,192H56V168H72a8,8,0,0,0,5.66-2.34L88,155.31ZM152,180a40.55,40.55,0,0,1-20,34.91A8,8,0,0,1,124,201.09a24.49,24.49,0,0,0,0-42.18A8,8,0,0,1,132,145.09,40.55,40.55,0,0,1,152,180Zm61.66-97.66-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v80a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48V216H168a8,8,0,0,0,0,16h32a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160Z', 'FileAudio');
|
|
1473
|
+
const FileCode = createIcon('M181.66,146.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32Zm-72-24a8,8,0,0,0-11.32,0l-24,24a8,8,0,0,0,0,11.32l24,24a8,8,0,0,0,11.32-11.32L91.31,152l18.35-18.34A8,8,0,0,0,109.66,122.34ZM216,88V216a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-56-8h28.69L160,51.31Zm40,136V96H152a8,8,0,0,1-8-8V40H56V216H200Z', 'FileCode');
|
|
1474
|
+
const FileZip = createIcon('M184,144H168a8,8,0,0,0-8,8v56a8,8,0,0,0,16,0v-8h8a28,28,0,0,0,0-56Zm0,40h-8V160h8a12,12,0,0,1,0,24Zm-48-32v56a8,8,0,0,1-16,0V152a8,8,0,0,1,16,0ZM96,208a8,8,0,0,1-8,8H56a8,8,0,0,1-7-12l25.16-44H56a8,8,0,0,1,0-16H88a8,8,0,0,1,7,12L69.79,200H88A8,8,0,0,1,96,208ZM213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48v16a8,8,0,0,0,16,0V88A8,8,0,0,0,213.66,82.34ZM160,80V51.31L188.69,80Z', 'FileZip');
|
|
1475
|
+
const FileMarkdown = createIcon('M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48V224a8,8,0,0,0,16,0V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM144,144H128a8,8,0,0,0-8,8v56a8,8,0,0,0,8,8h16a36,36,0,0,0,0-72Zm0,56h-8V160h8a20,20,0,0,1,0,40Zm-40-48v56a8,8,0,0,1-16,0V177.38L74.55,196.59a8,8,0,0,1-13.1,0L48,177.38V208a8,8,0,0,1-16,0V152a8,8,0,0,1,14.55-4.59L68,178.05l21.45-30.64A8,8,0,0,1,104,152Z', 'FileMarkdown');
|
|
1476
|
+
const FileJs = createIcon('M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48V216H176a8,8,0,0,0,0,16h24a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160Zm-12.19,145a20.82,20.82,0,0,1-9.19,15.23C133.43,215,127,216,121.13,216A61.14,61.14,0,0,1,106,214a8,8,0,1,1,4.3-15.41c4.38,1.2,15,2.7,19.55-.36.88-.59,1.83-1.52,2.14-3.93.35-2.67-.71-4.1-12.78-7.59-9.35-2.7-25-7.23-23-23.11a20.56,20.56,0,0,1,9-14.95c11.84-8,30.71-3.31,32.83-2.76a8,8,0,0,1-4.07,15.48c-4.49-1.17-15.23-2.56-19.83.56a4.54,4.54,0,0,0-2,3.67c-.12.9-.14,1.09,1.11,1.9,2.31,1.49,6.45,2.68,10.45,3.84C133.49,174.17,150.05,179,147.81,196.31ZM80,152v38a26,26,0,0,1-52,0,8,8,0,0,1,16,0,10,10,0,0,0,20,0V152a8,8,0,0,1,16,0Z', 'FileJs');
|
|
1477
|
+
const FileJsx = createIcon('M147.81,196.31a20.82,20.82,0,0,1-9.19,15.23C133.43,215,127,216,121.13,216a60.63,60.63,0,0,1-15.19-2,8,8,0,0,1,4.31-15.41c4.38,1.21,15,2.71,19.55-.35.88-.6,1.83-1.52,2.14-3.93.34-2.67-.72-4.1-12.78-7.59-9.35-2.7-25-7.23-23-23.11a20.58,20.58,0,0,1,9-14.95c11.85-8,30.72-3.31,32.84-2.76a8,8,0,0,1-4.07,15.48c-4.49-1.17-15.23-2.56-19.83.56a4.54,4.54,0,0,0-2,3.67c-.12.9-.14,1.08,1.11,1.9,2.31,1.49,6.45,2.68,10.45,3.84C133.49,174.17,150,179,147.81,196.31ZM72,144a8,8,0,0,0-8,8v38a10,10,0,0,1-20,0,8,8,0,0,0-16,0,26,26,0,0,0,52,0V152A8,8,0,0,0,72,144Zm140.65,1.49a8,8,0,0,0-11.16,1.86L188,166.24l-13.49-18.89a8,8,0,0,0-13,9.3L178.17,180l-16.68,23.35a8,8,0,0,0,13,9.3L188,193.76l13.49,18.89a8,8,0,0,0,13-9.3L197.83,180l16.68-23.35A8,8,0,0,0,212.65,145.49ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z', 'FileJsx');
|
|
1478
|
+
const FileTs = createIcon('M147.81,196.31a20.82,20.82,0,0,1-9.19,15.23C133.43,215,127,216,121.13,216a61.34,61.34,0,0,1-15.19-2,8,8,0,0,1,4.31-15.41c4.38,1.2,15,2.7,19.55-.36.88-.59,1.83-1.52,2.14-3.93.34-2.67-.71-4.1-12.78-7.59-9.35-2.7-25-7.23-23-23.11a20.56,20.56,0,0,1,9-14.95c11.84-8,30.71-3.31,32.83-2.76a8,8,0,0,1-4.07,15.48c-4.49-1.17-15.23-2.56-19.83.56a4.54,4.54,0,0,0-2,3.67c-.12.9-.14,1.09,1.11,1.9,2.31,1.49,6.45,2.68,10.45,3.84C133.49,174.17,150.05,179,147.81,196.31ZM216,88V216a16,16,0,0,1-16,16H176a8,8,0,0,1,0-16h24V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-56-8h28.69L160,51.31ZM80,144H40a8,8,0,0,0,0,16H52v48a8,8,0,0,0,16,0V160H80a8,8,0,0,0,0-16Z', 'FileTs');
|
|
1479
|
+
const FileTsx = createIcon('M214.51,156.65,197.83,180l16.68,23.35a8,8,0,0,1-13,9.3L188,193.76l-13.49,18.89a8,8,0,1,1-13-9.3L178.17,180l-16.68-23.35a8,8,0,0,1,13-9.3L188,166.24l13.49-18.89a8,8,0,0,1,13,9.3ZM123.6,171.31c-4-1.16-8.14-2.35-10.45-3.84-1.25-.82-1.23-1-1.11-1.9a4.54,4.54,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.83-.56A8,8,0,0,0,138,145.86c-2.12-.55-21-5.22-32.84,2.76a20.58,20.58,0,0,0-9,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.33-2.14,3.93-4.6,3.06-15.17,1.56-19.55.35A8,8,0,0,0,105.94,214a60.63,60.63,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.82,20.82,0,0,0,9.19-15.23C150,179,133.49,174.17,123.6,171.31ZM80,144H40a8,8,0,0,0,0,16H52v48a8,8,0,0,0,16,0V160H80a8,8,0,0,0,0-16ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z', 'FileTsx');
|
|
1480
|
+
const FileCss = createIcon('M48,180c0,11,7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,1,1,85.77,206.4,30,30,0,0,1,64,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30,30,0,0,1,21.77,9.6,8,8,0,1,1-11.55,11.06A14.24,14.24,0,0,0,64,160C55.18,160,48,169,48,180Zm79.6-8.69c-4-1.16-8.14-2.35-10.45-3.84-1.26-.81-1.23-1-1.12-1.9a4.54,4.54,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.83-.56a8,8,0,0,0,4.07-15.48c-2.12-.55-21-5.22-32.83,2.76a20.55,20.55,0,0,0-9,14.95c-2,15.88,13.64,20.41,23,23.11,12.07,3.49,13.13,4.92,12.78,7.59-.31,2.41-1.26,3.34-2.14,3.93-4.6,3.06-15.17,1.56-19.55.36a8,8,0,0,0-4.3,15.41,61.23,61.23,0,0,0,15.18,2c5.83,0,12.3-1,17.49-4.46a20.82,20.82,0,0,0,9.19-15.23C154,179,137.48,174.17,127.6,171.31Zm64,0c-4-1.16-8.14-2.35-10.45-3.84-1.25-.81-1.23-1-1.12-1.9a4.54,4.54,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.82-.56a8,8,0,0,0,4.07-15.48c-2.11-.55-21-5.22-32.83,2.76a20.58,20.58,0,0,0-8.95,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.34-2.15,3.93-4.6,3.06-15.16,1.56-19.54.36A8,8,0,0,0,173.93,214a61.34,61.34,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.81,20.81,0,0,0,9.18-15.23C218,179,201.48,174.17,191.59,171.31ZM40,112V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88v24a8,8,0,1,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0ZM160,80h28.68L160,51.31Z', 'FileCss');
|
|
1481
|
+
const FileHtml = createIcon('M216,120V88a8,8,0,0,0-2.34-5.66l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v80a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48v24a8,8,0,0,0,16,0ZM160,51.31,188.69,80H160ZM68,160v48a8,8,0,0,1-16,0V192H32v16a8,8,0,0,1-16,0V160a8,8,0,0,1,16,0v16H52V160a8,8,0,0,1,16,0Zm56,0a8,8,0,0,1-8,8h-8v40a8,8,0,0,1-16,0V168H84a8,8,0,0,1,0-16h32A8,8,0,0,1,124,160Zm72,0v48a8,8,0,0,1-16,0V184l-9.6,12.8a8,8,0,0,1-12.8,0L148,184v24a8,8,0,0,1-16,0V160a8,8,0,0,1,14.4-4.8L164,178.67l17.6-23.47A8,8,0,0,1,196,160Zm56,48a8,8,0,0,1-8,8H216a8,8,0,0,1-8-8V160a8,8,0,0,1,16,0v40h20A8,8,0,0,1,252,208Z', 'FileHtml');
|
|
1482
|
+
const FileVue = createIcon('M87.54,154.69l-20,56a8,8,0,0,1-15.07,0l-20-56a8,8,0,0,1,15.07-5.38L60,184.21l12.47-34.9a8,8,0,0,1,15.07,5.38ZM208,160a8,8,0,0,0,0-16H176a8,8,0,0,0-8,8v56a8,8,0,0,0,8,8h32a8,8,0,0,0,0-16H184V188h16a8,8,0,0,0,0-16H184V160Zm-64-16a8,8,0,0,0-8,8v38a10,10,0,0,1-20,0V152a8,8,0,0,0-16,0v38a26,26,0,0,0,52,0V152A8,8,0,0,0,144,144Zm72-56v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z', 'FileVue');
|
|
1483
|
+
const FilePy = createIcon('M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48V216H168a8,8,0,0,0,0,16h32a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM64,144H48a8,8,0,0,0-8,8v56a8,8,0,0,0,16,0v-8h8a28,28,0,0,0,0-56Zm0,40H56V160h8a12,12,0,0,1,0,24Zm90.78-27.76-18.78,30V208a8,8,0,0,1-16,0V186.29l-18.78-30a8,8,0,1,1,13.56-8.48L128,168.91l13.22-21.15a8,8,0,1,1,13.56,8.48Z', 'FilePy');
|
|
1484
|
+
const FileRs = createIcon('M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48V216H184a8,8,0,0,0,0,16h16a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM64,144H48a8,8,0,0,0-8,8v56a8,8,0,0,0,16,0v-8h8a28.48,28.48,0,0,0,5.73-.59L77.09,212A8,8,0,0,0,90.91,204L83.8,191.78A28,28,0,0,0,64,144Zm-8,40V160h8a12,12,0,0,1,0,24Zm99.81,12.31a20.82,20.82,0,0,1-9.19,15.23C141.43,215,135,216,129.13,216a61.34,61.34,0,0,1-15.19-2,8,8,0,0,1,4.31-15.41c4.38,1.2,14.95,2.7,19.55-.36.88-.59,1.83-1.52,2.14-3.93.34-2.67-.71-4.1-12.78-7.59-9.35-2.7-25-7.23-23-23.11a20.56,20.56,0,0,1,9-14.95c11.84-8,30.71-3.31,32.83-2.76a8,8,0,0,1-4.07,15.48c-4.49-1.17-15.23-2.56-19.83.56a4.54,4.54,0,0,0-2,3.67c-.12.9-.14,1.09,1.11,1.9,2.31,1.49,6.45,2.68,10.45,3.84C141.49,174.17,158.05,179,155.81,196.31Z', 'FileRs');
|
|
1485
|
+
const FileArchive = createIcon('M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40v72a8,8,0,0,0,16,0V40h88V88a8,8,0,0,0,8,8h48V216H112V200h8a8,8,0,0,0,0-16h-8V168h8a8,8,0,0,0,0-16h-8v-8a8,8,0,0,0-16,0v8H88a8,8,0,0,0,0,16h8v16H88a8,8,0,0,0,0,16h8v16H56V40h88V88a8,8,0,0,0,8,8h48V216Z', 'FileArchive');
|
|
1486
|
+
|
|
1487
|
+
// 文件类型图标映射(图标 + 颜色)
|
|
1488
|
+
const fileTypeIcons = {
|
|
1489
|
+
// 文档类型
|
|
1490
|
+
md: {
|
|
1491
|
+
icon: FileMarkdown,
|
|
1492
|
+
color: '#083fa6'
|
|
1493
|
+
},
|
|
1494
|
+
txt: {
|
|
1495
|
+
icon: FileText,
|
|
1496
|
+
color: '#6b7280'
|
|
1497
|
+
},
|
|
1498
|
+
pdf: {
|
|
1499
|
+
icon: FilePdf,
|
|
1500
|
+
color: '#d32f2f'
|
|
1501
|
+
},
|
|
1502
|
+
doc: {
|
|
1503
|
+
icon: FileDoc,
|
|
1504
|
+
color: '#2b579a'
|
|
1505
|
+
},
|
|
1506
|
+
docx: {
|
|
1507
|
+
icon: FileDoc,
|
|
1508
|
+
color: '#2b579a'
|
|
1509
|
+
},
|
|
1510
|
+
xls: {
|
|
1511
|
+
icon: FileXls,
|
|
1512
|
+
color: '#217346'
|
|
1513
|
+
},
|
|
1514
|
+
xlsx: {
|
|
1515
|
+
icon: FileXls,
|
|
1516
|
+
color: '#217346'
|
|
1517
|
+
},
|
|
1518
|
+
// 图片类型
|
|
1519
|
+
png: {
|
|
1520
|
+
icon: FilePng,
|
|
1521
|
+
color: '#a855f7'
|
|
1522
|
+
},
|
|
1523
|
+
jpg: {
|
|
1524
|
+
icon: FileJpg,
|
|
1525
|
+
color: '#f97316'
|
|
1526
|
+
},
|
|
1527
|
+
jpeg: {
|
|
1528
|
+
icon: FileJpg,
|
|
1529
|
+
color: '#f97316'
|
|
1530
|
+
},
|
|
1531
|
+
gif: {
|
|
1532
|
+
icon: FileGif,
|
|
1533
|
+
color: '#ec4899'
|
|
1534
|
+
},
|
|
1535
|
+
svg: {
|
|
1536
|
+
icon: FileSvg,
|
|
1537
|
+
color: '#fbbf24'
|
|
1538
|
+
},
|
|
1539
|
+
webp: {
|
|
1540
|
+
icon: FilePng,
|
|
1541
|
+
color: '#22c55e'
|
|
1542
|
+
},
|
|
1543
|
+
// 视频类型
|
|
1544
|
+
mp4: {
|
|
1545
|
+
icon: FileVideo,
|
|
1546
|
+
color: '#ef4444'
|
|
1547
|
+
},
|
|
1548
|
+
avi: {
|
|
1549
|
+
icon: FileVideo,
|
|
1550
|
+
color: '#ef4444'
|
|
1551
|
+
},
|
|
1552
|
+
mov: {
|
|
1553
|
+
icon: FileVideo,
|
|
1554
|
+
color: '#ef4444'
|
|
1555
|
+
},
|
|
1556
|
+
wmv: {
|
|
1557
|
+
icon: FileVideo,
|
|
1558
|
+
color: '#ef4444'
|
|
1559
|
+
},
|
|
1560
|
+
mkv: {
|
|
1561
|
+
icon: FileVideo,
|
|
1562
|
+
color: '#ef4444'
|
|
1563
|
+
},
|
|
1564
|
+
webm: {
|
|
1565
|
+
icon: FileVideo,
|
|
1566
|
+
color: '#ef4444'
|
|
1567
|
+
},
|
|
1568
|
+
flv: {
|
|
1569
|
+
icon: FileVideo,
|
|
1570
|
+
color: '#ef4444'
|
|
1571
|
+
},
|
|
1572
|
+
// 音频类型
|
|
1573
|
+
mp3: {
|
|
1574
|
+
icon: FileAudio,
|
|
1575
|
+
color: '#8b5cf6'
|
|
1576
|
+
},
|
|
1577
|
+
wav: {
|
|
1578
|
+
icon: FileAudio,
|
|
1579
|
+
color: '#8b5cf6'
|
|
1580
|
+
},
|
|
1581
|
+
flac: {
|
|
1582
|
+
icon: FileAudio,
|
|
1583
|
+
color: '#8b5cf6'
|
|
1584
|
+
},
|
|
1585
|
+
aac: {
|
|
1586
|
+
icon: FileAudio,
|
|
1587
|
+
color: '#8b5cf6'
|
|
1588
|
+
},
|
|
1589
|
+
ogg: {
|
|
1590
|
+
icon: FileAudio,
|
|
1591
|
+
color: '#8b5cf6'
|
|
1592
|
+
},
|
|
1593
|
+
wma: {
|
|
1594
|
+
icon: FileAudio,
|
|
1595
|
+
color: '#8b5cf6'
|
|
1596
|
+
},
|
|
1597
|
+
// 代码类型
|
|
1598
|
+
js: {
|
|
1599
|
+
icon: FileJs,
|
|
1600
|
+
color: '#f7df1e'
|
|
1601
|
+
},
|
|
1602
|
+
jsx: {
|
|
1603
|
+
icon: FileJsx,
|
|
1604
|
+
color: '#61dafb'
|
|
1605
|
+
},
|
|
1606
|
+
ts: {
|
|
1607
|
+
icon: FileTs,
|
|
1608
|
+
color: '#3178c6'
|
|
1609
|
+
},
|
|
1610
|
+
tsx: {
|
|
1611
|
+
icon: FileTsx,
|
|
1612
|
+
color: '#3178c6'
|
|
1613
|
+
},
|
|
1614
|
+
json: {
|
|
1615
|
+
icon: FileCode,
|
|
1616
|
+
color: '#cbcb41'
|
|
1617
|
+
},
|
|
1618
|
+
css: {
|
|
1619
|
+
icon: FileCss,
|
|
1620
|
+
color: '#264de4'
|
|
1621
|
+
},
|
|
1622
|
+
scss: {
|
|
1623
|
+
icon: FileCss,
|
|
1624
|
+
color: '#cc6699'
|
|
1625
|
+
},
|
|
1626
|
+
less: {
|
|
1627
|
+
icon: FileCss,
|
|
1628
|
+
color: '#1d365d'
|
|
1629
|
+
},
|
|
1630
|
+
html: {
|
|
1631
|
+
icon: FileHtml,
|
|
1632
|
+
color: '#e34f26'
|
|
1633
|
+
},
|
|
1634
|
+
vue: {
|
|
1635
|
+
icon: FileVue,
|
|
1636
|
+
color: '#42b883'
|
|
1637
|
+
},
|
|
1638
|
+
py: {
|
|
1639
|
+
icon: FilePy,
|
|
1640
|
+
color: '#3776ab'
|
|
1641
|
+
},
|
|
1642
|
+
java: {
|
|
1643
|
+
icon: FileCode,
|
|
1644
|
+
color: '#ed8b00'
|
|
1645
|
+
},
|
|
1646
|
+
go: {
|
|
1647
|
+
icon: FileCode,
|
|
1648
|
+
color: '#00add8'
|
|
1649
|
+
},
|
|
1650
|
+
rs: {
|
|
1651
|
+
icon: FileRs,
|
|
1652
|
+
color: '#dea584'
|
|
1653
|
+
},
|
|
1654
|
+
// 压缩文件
|
|
1655
|
+
zip: {
|
|
1656
|
+
icon: FileZip,
|
|
1657
|
+
color: '#78909c'
|
|
1658
|
+
},
|
|
1659
|
+
rar: {
|
|
1660
|
+
icon: FileArchive,
|
|
1661
|
+
color: '#5c6bc0'
|
|
1662
|
+
},
|
|
1663
|
+
'7z': {
|
|
1664
|
+
icon: FileArchive,
|
|
1665
|
+
color: '#5c6bc0'
|
|
1666
|
+
},
|
|
1667
|
+
tar: {
|
|
1668
|
+
icon: FileArchive,
|
|
1669
|
+
color: '#8d6e63'
|
|
1670
|
+
},
|
|
1671
|
+
gz: {
|
|
1672
|
+
icon: FileArchive,
|
|
1673
|
+
color: '#8d6e63'
|
|
1674
|
+
}
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
// 获取文件图标和颜色
|
|
1678
|
+
const getFileIcon = (name, isDirectory, expanded) => {
|
|
1679
|
+
var _name$split$pop;
|
|
1680
|
+
if (isDirectory) {
|
|
1681
|
+
return {
|
|
1682
|
+
icon: expanded ? FolderOpen : Folder,
|
|
1683
|
+
color: '#e8a838'
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
const ext = ((_name$split$pop = name.split('.').pop()) == null ? void 0 : _name$split$pop.toLowerCase()) || '';
|
|
1687
|
+
return fileTypeIcons[ext] || {
|
|
1688
|
+
icon: File,
|
|
1689
|
+
color: '#6b7280'
|
|
1690
|
+
};
|
|
1691
|
+
};
|
|
1692
|
+
|
|
1693
|
+
// 分离文件名和扩展名
|
|
1694
|
+
const splitFileName = (name, isDirectory) => {
|
|
1695
|
+
if (isDirectory) {
|
|
1696
|
+
return {
|
|
1697
|
+
name,
|
|
1698
|
+
ext: ''
|
|
1699
|
+
};
|
|
1700
|
+
}
|
|
1701
|
+
const lastDotIndex = name.lastIndexOf('.');
|
|
1702
|
+
if (lastDotIndex === -1 || lastDotIndex === 0) {
|
|
1703
|
+
return {
|
|
1704
|
+
name,
|
|
1705
|
+
ext: ''
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
return {
|
|
1709
|
+
name: name.substring(0, lastDotIndex),
|
|
1710
|
+
ext: name.substring(lastDotIndex)
|
|
1711
|
+
};
|
|
1712
|
+
};
|
|
1713
|
+
|
|
1714
|
+
// 将扁平数据转换为树形结构
|
|
1715
|
+
const convertToTreeData = (data, parentPath = '') => {
|
|
1716
|
+
if (!Array.isArray(data)) return [];
|
|
1717
|
+
return data.map((item, index) => {
|
|
1718
|
+
var _item$children, _item$children2;
|
|
1719
|
+
const key = parentPath ? `${parentPath}/${item.name}` : item.name;
|
|
1720
|
+
const isDirectory = item.type === 'directory' || ((_item$children = item.children) == null ? void 0 : _item$children.length) > 0;
|
|
1721
|
+
const node = {
|
|
1722
|
+
key,
|
|
1723
|
+
title: item.name,
|
|
1724
|
+
isDirectory,
|
|
1725
|
+
isLeaf: !isDirectory,
|
|
1726
|
+
data: item
|
|
1727
|
+
};
|
|
1728
|
+
if (isDirectory && ((_item$children2 = item.children) == null ? void 0 : _item$children2.length) > 0) {
|
|
1729
|
+
node.children = convertToTreeData(item.children, key);
|
|
1730
|
+
}
|
|
1731
|
+
return node;
|
|
1732
|
+
});
|
|
1733
|
+
};
|
|
1734
|
+
|
|
1735
|
+
const TreeNode = ({
|
|
1736
|
+
node,
|
|
1737
|
+
menuItems,
|
|
1738
|
+
expandedKeys,
|
|
1739
|
+
onToggle,
|
|
1740
|
+
onFileClick,
|
|
1741
|
+
rootRef
|
|
1742
|
+
}) => {
|
|
1743
|
+
const {
|
|
1744
|
+
key,
|
|
1745
|
+
title,
|
|
1746
|
+
isDirectory,
|
|
1747
|
+
isLeaf,
|
|
1748
|
+
data
|
|
1749
|
+
} = node;
|
|
1750
|
+
const isExpanded = expandedKeys.includes(key);
|
|
1751
|
+
const {
|
|
1752
|
+
icon: IconComponent,
|
|
1753
|
+
color
|
|
1754
|
+
} = getFileIcon(title, isDirectory, isExpanded);
|
|
1755
|
+
const {
|
|
1756
|
+
name: fileName,
|
|
1757
|
+
ext
|
|
1758
|
+
} = splitFileName(title, isDirectory);
|
|
1759
|
+
const menu = useMemo(() => {
|
|
1760
|
+
if (!menuItems || menuItems.length === 0) return null;
|
|
1761
|
+
return {
|
|
1762
|
+
items: menuItems.map((item, index) => ({
|
|
1763
|
+
key: index,
|
|
1764
|
+
label: item.label,
|
|
1765
|
+
icon: item.icon,
|
|
1766
|
+
onClick: () => item.onClick == null ? void 0 : item.onClick(data, key),
|
|
1767
|
+
danger: item.danger,
|
|
1768
|
+
disabled: item.disabled == null ? void 0 : item.disabled(data, key)
|
|
1769
|
+
}))
|
|
1770
|
+
};
|
|
1771
|
+
}, [menuItems, data, key]);
|
|
1772
|
+
const handleMenuClick = useCallback(e => {
|
|
1773
|
+
e.stopPropagation();
|
|
1774
|
+
}, []);
|
|
1775
|
+
const handleNodeClick = useCallback(() => {
|
|
1776
|
+
if (isDirectory) {
|
|
1777
|
+
onToggle == null || onToggle(key, isExpanded);
|
|
1778
|
+
} else {
|
|
1779
|
+
onFileClick == null || onFileClick(data, key);
|
|
1780
|
+
}
|
|
1781
|
+
}, [isDirectory, onToggle, onFileClick, key, isExpanded, data]);
|
|
1782
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1783
|
+
className: style['tree-node'],
|
|
1784
|
+
onClick: handleNodeClick,
|
|
1785
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
1786
|
+
className: style['node-icon'],
|
|
1787
|
+
style: {
|
|
1788
|
+
color
|
|
1789
|
+
},
|
|
1790
|
+
children: /*#__PURE__*/jsx(IconComponent, {})
|
|
1791
|
+
}), /*#__PURE__*/jsxs("span", {
|
|
1792
|
+
className: style['node-title'],
|
|
1793
|
+
title: title,
|
|
1794
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
1795
|
+
className: style['node-name'],
|
|
1796
|
+
children: fileName
|
|
1797
|
+
}), ext && /*#__PURE__*/jsx("span", {
|
|
1798
|
+
className: style['node-ext'],
|
|
1799
|
+
children: ext
|
|
1800
|
+
})]
|
|
1801
|
+
}), menu && /*#__PURE__*/jsx(Dropdown, {
|
|
1802
|
+
menu: menu,
|
|
1803
|
+
popupRender: menu => /*#__PURE__*/jsx("div", {
|
|
1804
|
+
onClick: handleMenuClick,
|
|
1805
|
+
children: menu
|
|
1806
|
+
}),
|
|
1807
|
+
trigger: ['click'],
|
|
1808
|
+
placement: "bottomRight",
|
|
1809
|
+
getPopupContainer: () => rootRef.current,
|
|
1810
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
1811
|
+
type: "text",
|
|
1812
|
+
size: "small",
|
|
1813
|
+
className: style['action-btn'],
|
|
1814
|
+
icon: /*#__PURE__*/jsx(MoreOutlined$1, {}),
|
|
1815
|
+
onClick: handleMenuClick
|
|
1816
|
+
})
|
|
1817
|
+
})]
|
|
1818
|
+
});
|
|
1819
|
+
};
|
|
1820
|
+
|
|
1821
|
+
const FileSystemView = withLocale(({
|
|
1822
|
+
data,
|
|
1823
|
+
menuItems,
|
|
1824
|
+
defaultExpandAll,
|
|
1825
|
+
expandedKeys: controlledExpandedKeys,
|
|
1826
|
+
onExpand,
|
|
1827
|
+
onFileClick
|
|
1828
|
+
}) => {
|
|
1829
|
+
const rootRef = useRef(null);
|
|
1830
|
+
const {
|
|
1831
|
+
formatMessage
|
|
1832
|
+
} = useIntl();
|
|
1833
|
+
const [internalExpandedKeys, setInternalExpandedKeys] = useState([]);
|
|
1834
|
+
const expandedKeys = controlledExpandedKeys != null ? controlledExpandedKeys : internalExpandedKeys;
|
|
1835
|
+
const treeData = useMemo(() => convertToTreeData(data), [data]);
|
|
1836
|
+
const handleExpand = useCallback((keys, info) => {
|
|
1837
|
+
if (!controlledExpandedKeys) {
|
|
1838
|
+
setInternalExpandedKeys(keys);
|
|
1839
|
+
}
|
|
1840
|
+
onExpand == null || onExpand(keys, info);
|
|
1841
|
+
}, [controlledExpandedKeys, onExpand]);
|
|
1842
|
+
const handleToggle = useCallback((key, isExpanded) => {
|
|
1843
|
+
const newKeys = isExpanded ? expandedKeys.filter(k => k !== key) : [...expandedKeys, key];
|
|
1844
|
+
handleExpand(newKeys, {
|
|
1845
|
+
node: {
|
|
1846
|
+
key
|
|
1847
|
+
},
|
|
1848
|
+
expanded: !isExpanded
|
|
1849
|
+
});
|
|
1850
|
+
}, [expandedKeys, handleExpand]);
|
|
1851
|
+
|
|
1852
|
+
// 默认展开所有目录
|
|
1853
|
+
const initialExpandedKeys = useMemo(() => {
|
|
1854
|
+
if (defaultExpandAll) {
|
|
1855
|
+
const keys = [];
|
|
1856
|
+
const traverse = nodes => {
|
|
1857
|
+
nodes.forEach(node => {
|
|
1858
|
+
if (node.isDirectory) {
|
|
1859
|
+
keys.push(node.key);
|
|
1860
|
+
if (node.children) {
|
|
1861
|
+
traverse(node.children);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
});
|
|
1865
|
+
};
|
|
1866
|
+
traverse(treeData);
|
|
1867
|
+
return keys;
|
|
1868
|
+
}
|
|
1869
|
+
return [];
|
|
1870
|
+
}, [treeData, defaultExpandAll]);
|
|
1871
|
+
|
|
1872
|
+
// 初始化展开状态
|
|
1873
|
+
useMemo(() => {
|
|
1874
|
+
if (defaultExpandAll && initialExpandedKeys.length > 0 && !controlledExpandedKeys) {
|
|
1875
|
+
setInternalExpandedKeys(initialExpandedKeys);
|
|
1876
|
+
}
|
|
1877
|
+
}, [defaultExpandAll, initialExpandedKeys, controlledExpandedKeys]);
|
|
1878
|
+
const renderTreeNode = useCallback(node => /*#__PURE__*/jsx(TreeNode, {
|
|
1879
|
+
rootRef: rootRef,
|
|
1880
|
+
node: node,
|
|
1881
|
+
menuItems: menuItems,
|
|
1882
|
+
expandedKeys: expandedKeys,
|
|
1883
|
+
onToggle: handleToggle,
|
|
1884
|
+
onFileClick: onFileClick
|
|
1885
|
+
}), [menuItems, expandedKeys, handleToggle, onFileClick]);
|
|
1886
|
+
if (!data || data.length === 0) {
|
|
1887
|
+
return /*#__PURE__*/jsx("div", {
|
|
1888
|
+
className: style['empty'],
|
|
1889
|
+
children: formatMessage({
|
|
1890
|
+
id: 'empty'
|
|
1891
|
+
})
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
return /*#__PURE__*/jsx("div", {
|
|
1895
|
+
className: style['file-system-view'],
|
|
1896
|
+
ref: rootRef,
|
|
1897
|
+
children: /*#__PURE__*/jsx(Tree, {
|
|
1898
|
+
treeData: treeData,
|
|
1899
|
+
expandedKeys: expandedKeys,
|
|
1900
|
+
onExpand: handleExpand,
|
|
1901
|
+
selectable: false,
|
|
1902
|
+
blockNode: true,
|
|
1903
|
+
titleRender: renderTreeNode
|
|
1904
|
+
})
|
|
1905
|
+
});
|
|
1906
|
+
});
|
|
1907
|
+
|
|
1908
|
+
export { FileSystemView as default };
|
|
1909
|
+
//# sourceMappingURL=index.modern.js.map
|