@next-core/brick-kit 2.99.2 → 2.101.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/dist/index.bundle.js +939 -39
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +939 -39
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/Kernel.d.ts.map +1 -1
- package/dist/types/core/MockRegistry.d.ts +4 -1
- package/dist/types/core/MockRegistry.d.ts.map +1 -1
- package/dist/types/core/Router.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +6 -0
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/internal/applyColorTheme.d.ts +20 -0
- package/dist/types/internal/applyColorTheme.d.ts.map +1 -0
- package/dist/types/internal/evaluate.d.ts.map +1 -1
- package/dist/types/internal/getGeneralGlobals.d.ts.map +1 -1
- package/package.json +6 -5
package/dist/index.bundle.js
CHANGED
|
@@ -1527,6 +1527,11 @@
|
|
|
1527
1527
|
return {
|
|
1528
1528
|
check: collectCoverage ? fakeCheckPermissions : checkPermissions
|
|
1529
1529
|
};
|
|
1530
|
+
|
|
1531
|
+
case "THEME":
|
|
1532
|
+
return {
|
|
1533
|
+
getTheme: collectCoverage ? () => "light" : getTheme
|
|
1534
|
+
};
|
|
1530
1535
|
}
|
|
1531
1536
|
}
|
|
1532
1537
|
|
|
@@ -1893,39 +1898,16 @@
|
|
|
1893
1898
|
});
|
|
1894
1899
|
|
|
1895
1900
|
case "QUERY":
|
|
1896
|
-
return
|
|
1897
|
-
get(target, key) {
|
|
1898
|
-
return query.has(key) ? query.get(key) : undefined;
|
|
1899
|
-
},
|
|
1900
|
-
|
|
1901
|
-
ownKeys() {
|
|
1902
|
-
return Array.from(query.keys());
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
});
|
|
1901
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
|
|
1906
1902
|
|
|
1907
1903
|
case "QUERY_ARRAY":
|
|
1908
|
-
return
|
|
1909
|
-
get(target, key) {
|
|
1910
|
-
return query.has(key) ? query.getAll(key) : undefined;
|
|
1911
|
-
},
|
|
1912
|
-
|
|
1913
|
-
ownKeys() {
|
|
1914
|
-
return Array.from(query.keys());
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
});
|
|
1904
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
|
|
1918
1905
|
|
|
1919
1906
|
case "SEGUE":
|
|
1920
1907
|
return {
|
|
1921
1908
|
getUrl: getUrlBySegueFactory(app, segues)
|
|
1922
1909
|
};
|
|
1923
1910
|
|
|
1924
|
-
case "THEME":
|
|
1925
|
-
return {
|
|
1926
|
-
getTheme
|
|
1927
|
-
};
|
|
1928
|
-
|
|
1929
1911
|
case "SESSION_STORAGE":
|
|
1930
1912
|
return {
|
|
1931
1913
|
getItem: getItemFactory("session")
|
|
@@ -6208,6 +6190,892 @@
|
|
|
6208
6190
|
return _standaloneBootstrap.apply(this, arguments);
|
|
6209
6191
|
}
|
|
6210
6192
|
|
|
6193
|
+
/**
|
|
6194
|
+
* Take input from [0, n] and return it as [0, 1]
|
|
6195
|
+
* @hidden
|
|
6196
|
+
*/
|
|
6197
|
+
function bound01(n, max) {
|
|
6198
|
+
if (isOnePointZero(n)) {
|
|
6199
|
+
n = '100%';
|
|
6200
|
+
}
|
|
6201
|
+
var isPercent = isPercentage(n);
|
|
6202
|
+
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
|
|
6203
|
+
// Automatically convert percentage into number
|
|
6204
|
+
if (isPercent) {
|
|
6205
|
+
n = parseInt(String(n * max), 10) / 100;
|
|
6206
|
+
}
|
|
6207
|
+
// Handle floating point rounding errors
|
|
6208
|
+
if (Math.abs(n - max) < 0.000001) {
|
|
6209
|
+
return 1;
|
|
6210
|
+
}
|
|
6211
|
+
// Convert into [0, 1] range if it isn't already
|
|
6212
|
+
if (max === 360) {
|
|
6213
|
+
// If n is a hue given in degrees,
|
|
6214
|
+
// wrap around out-of-range values into [0, 360] range
|
|
6215
|
+
// then convert into [0, 1].
|
|
6216
|
+
n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
|
|
6217
|
+
}
|
|
6218
|
+
else {
|
|
6219
|
+
// If n not a hue given in degrees
|
|
6220
|
+
// Convert into [0, 1] range if it isn't already.
|
|
6221
|
+
n = (n % max) / parseFloat(String(max));
|
|
6222
|
+
}
|
|
6223
|
+
return n;
|
|
6224
|
+
}
|
|
6225
|
+
/**
|
|
6226
|
+
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
6227
|
+
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
6228
|
+
* @hidden
|
|
6229
|
+
*/
|
|
6230
|
+
function isOnePointZero(n) {
|
|
6231
|
+
return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
|
|
6232
|
+
}
|
|
6233
|
+
/**
|
|
6234
|
+
* Check to see if string passed in is a percentage
|
|
6235
|
+
* @hidden
|
|
6236
|
+
*/
|
|
6237
|
+
function isPercentage(n) {
|
|
6238
|
+
return typeof n === 'string' && n.indexOf('%') !== -1;
|
|
6239
|
+
}
|
|
6240
|
+
/**
|
|
6241
|
+
* Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
6242
|
+
* @hidden
|
|
6243
|
+
*/
|
|
6244
|
+
function boundAlpha(a) {
|
|
6245
|
+
a = parseFloat(a);
|
|
6246
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
6247
|
+
a = 1;
|
|
6248
|
+
}
|
|
6249
|
+
return a;
|
|
6250
|
+
}
|
|
6251
|
+
/**
|
|
6252
|
+
* Replace a decimal with it's percentage value
|
|
6253
|
+
* @hidden
|
|
6254
|
+
*/
|
|
6255
|
+
function convertToPercentage(n) {
|
|
6256
|
+
if (n <= 1) {
|
|
6257
|
+
return Number(n) * 100 + "%";
|
|
6258
|
+
}
|
|
6259
|
+
return n;
|
|
6260
|
+
}
|
|
6261
|
+
/**
|
|
6262
|
+
* Force a hex value to have 2 characters
|
|
6263
|
+
* @hidden
|
|
6264
|
+
*/
|
|
6265
|
+
function pad2(c) {
|
|
6266
|
+
return c.length === 1 ? '0' + c : String(c);
|
|
6267
|
+
}
|
|
6268
|
+
|
|
6269
|
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
6270
|
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
6271
|
+
/**
|
|
6272
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
6273
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
6274
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
6275
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
6276
|
+
*/
|
|
6277
|
+
function rgbToRgb(r, g, b) {
|
|
6278
|
+
return {
|
|
6279
|
+
r: bound01(r, 255) * 255,
|
|
6280
|
+
g: bound01(g, 255) * 255,
|
|
6281
|
+
b: bound01(b, 255) * 255,
|
|
6282
|
+
};
|
|
6283
|
+
}
|
|
6284
|
+
function hue2rgb(p, q, t) {
|
|
6285
|
+
if (t < 0) {
|
|
6286
|
+
t += 1;
|
|
6287
|
+
}
|
|
6288
|
+
if (t > 1) {
|
|
6289
|
+
t -= 1;
|
|
6290
|
+
}
|
|
6291
|
+
if (t < 1 / 6) {
|
|
6292
|
+
return p + (q - p) * (6 * t);
|
|
6293
|
+
}
|
|
6294
|
+
if (t < 1 / 2) {
|
|
6295
|
+
return q;
|
|
6296
|
+
}
|
|
6297
|
+
if (t < 2 / 3) {
|
|
6298
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
6299
|
+
}
|
|
6300
|
+
return p;
|
|
6301
|
+
}
|
|
6302
|
+
/**
|
|
6303
|
+
* Converts an HSL color value to RGB.
|
|
6304
|
+
*
|
|
6305
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
6306
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
6307
|
+
*/
|
|
6308
|
+
function hslToRgb(h, s, l) {
|
|
6309
|
+
var r;
|
|
6310
|
+
var g;
|
|
6311
|
+
var b;
|
|
6312
|
+
h = bound01(h, 360);
|
|
6313
|
+
s = bound01(s, 100);
|
|
6314
|
+
l = bound01(l, 100);
|
|
6315
|
+
if (s === 0) {
|
|
6316
|
+
// achromatic
|
|
6317
|
+
g = l;
|
|
6318
|
+
b = l;
|
|
6319
|
+
r = l;
|
|
6320
|
+
}
|
|
6321
|
+
else {
|
|
6322
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
6323
|
+
var p = 2 * l - q;
|
|
6324
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
6325
|
+
g = hue2rgb(p, q, h);
|
|
6326
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
6327
|
+
}
|
|
6328
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
6329
|
+
}
|
|
6330
|
+
/**
|
|
6331
|
+
* Converts an RGB color value to HSV
|
|
6332
|
+
*
|
|
6333
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
6334
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
6335
|
+
*/
|
|
6336
|
+
function rgbToHsv(r, g, b) {
|
|
6337
|
+
r = bound01(r, 255);
|
|
6338
|
+
g = bound01(g, 255);
|
|
6339
|
+
b = bound01(b, 255);
|
|
6340
|
+
var max = Math.max(r, g, b);
|
|
6341
|
+
var min = Math.min(r, g, b);
|
|
6342
|
+
var h = 0;
|
|
6343
|
+
var v = max;
|
|
6344
|
+
var d = max - min;
|
|
6345
|
+
var s = max === 0 ? 0 : d / max;
|
|
6346
|
+
if (max === min) {
|
|
6347
|
+
h = 0; // achromatic
|
|
6348
|
+
}
|
|
6349
|
+
else {
|
|
6350
|
+
switch (max) {
|
|
6351
|
+
case r:
|
|
6352
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
6353
|
+
break;
|
|
6354
|
+
case g:
|
|
6355
|
+
h = (b - r) / d + 2;
|
|
6356
|
+
break;
|
|
6357
|
+
case b:
|
|
6358
|
+
h = (r - g) / d + 4;
|
|
6359
|
+
break;
|
|
6360
|
+
}
|
|
6361
|
+
h /= 6;
|
|
6362
|
+
}
|
|
6363
|
+
return { h: h, s: s, v: v };
|
|
6364
|
+
}
|
|
6365
|
+
/**
|
|
6366
|
+
* Converts an HSV color value to RGB.
|
|
6367
|
+
*
|
|
6368
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
6369
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
6370
|
+
*/
|
|
6371
|
+
function hsvToRgb(h, s, v) {
|
|
6372
|
+
h = bound01(h, 360) * 6;
|
|
6373
|
+
s = bound01(s, 100);
|
|
6374
|
+
v = bound01(v, 100);
|
|
6375
|
+
var i = Math.floor(h);
|
|
6376
|
+
var f = h - i;
|
|
6377
|
+
var p = v * (1 - s);
|
|
6378
|
+
var q = v * (1 - f * s);
|
|
6379
|
+
var t = v * (1 - (1 - f) * s);
|
|
6380
|
+
var mod = i % 6;
|
|
6381
|
+
var r = [v, q, p, p, t, v][mod];
|
|
6382
|
+
var g = [t, v, v, q, p, p][mod];
|
|
6383
|
+
var b = [p, p, t, v, v, q][mod];
|
|
6384
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
6385
|
+
}
|
|
6386
|
+
/**
|
|
6387
|
+
* Converts an RGB color to hex
|
|
6388
|
+
*
|
|
6389
|
+
* Assumes r, g, and b are contained in the set [0, 255]
|
|
6390
|
+
* Returns a 3 or 6 character hex
|
|
6391
|
+
*/
|
|
6392
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
6393
|
+
var hex = [
|
|
6394
|
+
pad2(Math.round(r).toString(16)),
|
|
6395
|
+
pad2(Math.round(g).toString(16)),
|
|
6396
|
+
pad2(Math.round(b).toString(16)),
|
|
6397
|
+
];
|
|
6398
|
+
// Return a 3 character hex if possible
|
|
6399
|
+
if (allow3Char &&
|
|
6400
|
+
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
6401
|
+
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
6402
|
+
hex[2].startsWith(hex[2].charAt(1))) {
|
|
6403
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
6404
|
+
}
|
|
6405
|
+
return hex.join('');
|
|
6406
|
+
}
|
|
6407
|
+
/** Converts a hex value to a decimal */
|
|
6408
|
+
function convertHexToDecimal(h) {
|
|
6409
|
+
return parseIntFromHex(h) / 255;
|
|
6410
|
+
}
|
|
6411
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
6412
|
+
function parseIntFromHex(val) {
|
|
6413
|
+
return parseInt(val, 16);
|
|
6414
|
+
}
|
|
6415
|
+
|
|
6416
|
+
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
|
|
6417
|
+
/**
|
|
6418
|
+
* @hidden
|
|
6419
|
+
*/
|
|
6420
|
+
var names = {
|
|
6421
|
+
aliceblue: '#f0f8ff',
|
|
6422
|
+
antiquewhite: '#faebd7',
|
|
6423
|
+
aqua: '#00ffff',
|
|
6424
|
+
aquamarine: '#7fffd4',
|
|
6425
|
+
azure: '#f0ffff',
|
|
6426
|
+
beige: '#f5f5dc',
|
|
6427
|
+
bisque: '#ffe4c4',
|
|
6428
|
+
black: '#000000',
|
|
6429
|
+
blanchedalmond: '#ffebcd',
|
|
6430
|
+
blue: '#0000ff',
|
|
6431
|
+
blueviolet: '#8a2be2',
|
|
6432
|
+
brown: '#a52a2a',
|
|
6433
|
+
burlywood: '#deb887',
|
|
6434
|
+
cadetblue: '#5f9ea0',
|
|
6435
|
+
chartreuse: '#7fff00',
|
|
6436
|
+
chocolate: '#d2691e',
|
|
6437
|
+
coral: '#ff7f50',
|
|
6438
|
+
cornflowerblue: '#6495ed',
|
|
6439
|
+
cornsilk: '#fff8dc',
|
|
6440
|
+
crimson: '#dc143c',
|
|
6441
|
+
cyan: '#00ffff',
|
|
6442
|
+
darkblue: '#00008b',
|
|
6443
|
+
darkcyan: '#008b8b',
|
|
6444
|
+
darkgoldenrod: '#b8860b',
|
|
6445
|
+
darkgray: '#a9a9a9',
|
|
6446
|
+
darkgreen: '#006400',
|
|
6447
|
+
darkgrey: '#a9a9a9',
|
|
6448
|
+
darkkhaki: '#bdb76b',
|
|
6449
|
+
darkmagenta: '#8b008b',
|
|
6450
|
+
darkolivegreen: '#556b2f',
|
|
6451
|
+
darkorange: '#ff8c00',
|
|
6452
|
+
darkorchid: '#9932cc',
|
|
6453
|
+
darkred: '#8b0000',
|
|
6454
|
+
darksalmon: '#e9967a',
|
|
6455
|
+
darkseagreen: '#8fbc8f',
|
|
6456
|
+
darkslateblue: '#483d8b',
|
|
6457
|
+
darkslategray: '#2f4f4f',
|
|
6458
|
+
darkslategrey: '#2f4f4f',
|
|
6459
|
+
darkturquoise: '#00ced1',
|
|
6460
|
+
darkviolet: '#9400d3',
|
|
6461
|
+
deeppink: '#ff1493',
|
|
6462
|
+
deepskyblue: '#00bfff',
|
|
6463
|
+
dimgray: '#696969',
|
|
6464
|
+
dimgrey: '#696969',
|
|
6465
|
+
dodgerblue: '#1e90ff',
|
|
6466
|
+
firebrick: '#b22222',
|
|
6467
|
+
floralwhite: '#fffaf0',
|
|
6468
|
+
forestgreen: '#228b22',
|
|
6469
|
+
fuchsia: '#ff00ff',
|
|
6470
|
+
gainsboro: '#dcdcdc',
|
|
6471
|
+
ghostwhite: '#f8f8ff',
|
|
6472
|
+
goldenrod: '#daa520',
|
|
6473
|
+
gold: '#ffd700',
|
|
6474
|
+
gray: '#808080',
|
|
6475
|
+
green: '#008000',
|
|
6476
|
+
greenyellow: '#adff2f',
|
|
6477
|
+
grey: '#808080',
|
|
6478
|
+
honeydew: '#f0fff0',
|
|
6479
|
+
hotpink: '#ff69b4',
|
|
6480
|
+
indianred: '#cd5c5c',
|
|
6481
|
+
indigo: '#4b0082',
|
|
6482
|
+
ivory: '#fffff0',
|
|
6483
|
+
khaki: '#f0e68c',
|
|
6484
|
+
lavenderblush: '#fff0f5',
|
|
6485
|
+
lavender: '#e6e6fa',
|
|
6486
|
+
lawngreen: '#7cfc00',
|
|
6487
|
+
lemonchiffon: '#fffacd',
|
|
6488
|
+
lightblue: '#add8e6',
|
|
6489
|
+
lightcoral: '#f08080',
|
|
6490
|
+
lightcyan: '#e0ffff',
|
|
6491
|
+
lightgoldenrodyellow: '#fafad2',
|
|
6492
|
+
lightgray: '#d3d3d3',
|
|
6493
|
+
lightgreen: '#90ee90',
|
|
6494
|
+
lightgrey: '#d3d3d3',
|
|
6495
|
+
lightpink: '#ffb6c1',
|
|
6496
|
+
lightsalmon: '#ffa07a',
|
|
6497
|
+
lightseagreen: '#20b2aa',
|
|
6498
|
+
lightskyblue: '#87cefa',
|
|
6499
|
+
lightslategray: '#778899',
|
|
6500
|
+
lightslategrey: '#778899',
|
|
6501
|
+
lightsteelblue: '#b0c4de',
|
|
6502
|
+
lightyellow: '#ffffe0',
|
|
6503
|
+
lime: '#00ff00',
|
|
6504
|
+
limegreen: '#32cd32',
|
|
6505
|
+
linen: '#faf0e6',
|
|
6506
|
+
magenta: '#ff00ff',
|
|
6507
|
+
maroon: '#800000',
|
|
6508
|
+
mediumaquamarine: '#66cdaa',
|
|
6509
|
+
mediumblue: '#0000cd',
|
|
6510
|
+
mediumorchid: '#ba55d3',
|
|
6511
|
+
mediumpurple: '#9370db',
|
|
6512
|
+
mediumseagreen: '#3cb371',
|
|
6513
|
+
mediumslateblue: '#7b68ee',
|
|
6514
|
+
mediumspringgreen: '#00fa9a',
|
|
6515
|
+
mediumturquoise: '#48d1cc',
|
|
6516
|
+
mediumvioletred: '#c71585',
|
|
6517
|
+
midnightblue: '#191970',
|
|
6518
|
+
mintcream: '#f5fffa',
|
|
6519
|
+
mistyrose: '#ffe4e1',
|
|
6520
|
+
moccasin: '#ffe4b5',
|
|
6521
|
+
navajowhite: '#ffdead',
|
|
6522
|
+
navy: '#000080',
|
|
6523
|
+
oldlace: '#fdf5e6',
|
|
6524
|
+
olive: '#808000',
|
|
6525
|
+
olivedrab: '#6b8e23',
|
|
6526
|
+
orange: '#ffa500',
|
|
6527
|
+
orangered: '#ff4500',
|
|
6528
|
+
orchid: '#da70d6',
|
|
6529
|
+
palegoldenrod: '#eee8aa',
|
|
6530
|
+
palegreen: '#98fb98',
|
|
6531
|
+
paleturquoise: '#afeeee',
|
|
6532
|
+
palevioletred: '#db7093',
|
|
6533
|
+
papayawhip: '#ffefd5',
|
|
6534
|
+
peachpuff: '#ffdab9',
|
|
6535
|
+
peru: '#cd853f',
|
|
6536
|
+
pink: '#ffc0cb',
|
|
6537
|
+
plum: '#dda0dd',
|
|
6538
|
+
powderblue: '#b0e0e6',
|
|
6539
|
+
purple: '#800080',
|
|
6540
|
+
rebeccapurple: '#663399',
|
|
6541
|
+
red: '#ff0000',
|
|
6542
|
+
rosybrown: '#bc8f8f',
|
|
6543
|
+
royalblue: '#4169e1',
|
|
6544
|
+
saddlebrown: '#8b4513',
|
|
6545
|
+
salmon: '#fa8072',
|
|
6546
|
+
sandybrown: '#f4a460',
|
|
6547
|
+
seagreen: '#2e8b57',
|
|
6548
|
+
seashell: '#fff5ee',
|
|
6549
|
+
sienna: '#a0522d',
|
|
6550
|
+
silver: '#c0c0c0',
|
|
6551
|
+
skyblue: '#87ceeb',
|
|
6552
|
+
slateblue: '#6a5acd',
|
|
6553
|
+
slategray: '#708090',
|
|
6554
|
+
slategrey: '#708090',
|
|
6555
|
+
snow: '#fffafa',
|
|
6556
|
+
springgreen: '#00ff7f',
|
|
6557
|
+
steelblue: '#4682b4',
|
|
6558
|
+
tan: '#d2b48c',
|
|
6559
|
+
teal: '#008080',
|
|
6560
|
+
thistle: '#d8bfd8',
|
|
6561
|
+
tomato: '#ff6347',
|
|
6562
|
+
turquoise: '#40e0d0',
|
|
6563
|
+
violet: '#ee82ee',
|
|
6564
|
+
wheat: '#f5deb3',
|
|
6565
|
+
white: '#ffffff',
|
|
6566
|
+
whitesmoke: '#f5f5f5',
|
|
6567
|
+
yellow: '#ffff00',
|
|
6568
|
+
yellowgreen: '#9acd32',
|
|
6569
|
+
};
|
|
6570
|
+
|
|
6571
|
+
/**
|
|
6572
|
+
* Given a string or object, convert that input to RGB
|
|
6573
|
+
*
|
|
6574
|
+
* Possible string inputs:
|
|
6575
|
+
* ```
|
|
6576
|
+
* "red"
|
|
6577
|
+
* "#f00" or "f00"
|
|
6578
|
+
* "#ff0000" or "ff0000"
|
|
6579
|
+
* "#ff000000" or "ff000000"
|
|
6580
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
6581
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
6582
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
6583
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
6584
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
6585
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
6586
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
6587
|
+
* ```
|
|
6588
|
+
*/
|
|
6589
|
+
function inputToRGB(color) {
|
|
6590
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
|
6591
|
+
var a = 1;
|
|
6592
|
+
var s = null;
|
|
6593
|
+
var v = null;
|
|
6594
|
+
var l = null;
|
|
6595
|
+
var ok = false;
|
|
6596
|
+
var format = false;
|
|
6597
|
+
if (typeof color === 'string') {
|
|
6598
|
+
color = stringInputToObject(color);
|
|
6599
|
+
}
|
|
6600
|
+
if (typeof color === 'object') {
|
|
6601
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
6602
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
6603
|
+
ok = true;
|
|
6604
|
+
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
|
|
6605
|
+
}
|
|
6606
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
6607
|
+
s = convertToPercentage(color.s);
|
|
6608
|
+
v = convertToPercentage(color.v);
|
|
6609
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
6610
|
+
ok = true;
|
|
6611
|
+
format = 'hsv';
|
|
6612
|
+
}
|
|
6613
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
6614
|
+
s = convertToPercentage(color.s);
|
|
6615
|
+
l = convertToPercentage(color.l);
|
|
6616
|
+
rgb = hslToRgb(color.h, s, l);
|
|
6617
|
+
ok = true;
|
|
6618
|
+
format = 'hsl';
|
|
6619
|
+
}
|
|
6620
|
+
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
|
|
6621
|
+
a = color.a;
|
|
6622
|
+
}
|
|
6623
|
+
}
|
|
6624
|
+
a = boundAlpha(a);
|
|
6625
|
+
return {
|
|
6626
|
+
ok: ok,
|
|
6627
|
+
format: color.format || format,
|
|
6628
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
6629
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
6630
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
6631
|
+
a: a,
|
|
6632
|
+
};
|
|
6633
|
+
}
|
|
6634
|
+
// <http://www.w3.org/TR/css3-values/#integers>
|
|
6635
|
+
var CSS_INTEGER = '[-\\+]?\\d+%?';
|
|
6636
|
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
6637
|
+
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
|
6638
|
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
6639
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
6640
|
+
// Actual matching.
|
|
6641
|
+
// Parentheses and commas are optional, but not required.
|
|
6642
|
+
// Whitespace can take the place of commas or opening paren
|
|
6643
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
6644
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
6645
|
+
var matchers = {
|
|
6646
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
6647
|
+
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
|
|
6648
|
+
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
|
|
6649
|
+
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
|
|
6650
|
+
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
|
|
6651
|
+
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
|
|
6652
|
+
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
|
|
6653
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
6654
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
6655
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
6656
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
6657
|
+
};
|
|
6658
|
+
/**
|
|
6659
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
6660
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
6661
|
+
*/
|
|
6662
|
+
function stringInputToObject(color) {
|
|
6663
|
+
color = color.trim().toLowerCase();
|
|
6664
|
+
if (color.length === 0) {
|
|
6665
|
+
return false;
|
|
6666
|
+
}
|
|
6667
|
+
var named = false;
|
|
6668
|
+
if (names[color]) {
|
|
6669
|
+
color = names[color];
|
|
6670
|
+
named = true;
|
|
6671
|
+
}
|
|
6672
|
+
else if (color === 'transparent') {
|
|
6673
|
+
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
|
|
6674
|
+
}
|
|
6675
|
+
// Try to match string input using regular expressions.
|
|
6676
|
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
6677
|
+
// Just return an object and let the conversion functions handle that.
|
|
6678
|
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
6679
|
+
var match = matchers.rgb.exec(color);
|
|
6680
|
+
if (match) {
|
|
6681
|
+
return { r: match[1], g: match[2], b: match[3] };
|
|
6682
|
+
}
|
|
6683
|
+
match = matchers.rgba.exec(color);
|
|
6684
|
+
if (match) {
|
|
6685
|
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
6686
|
+
}
|
|
6687
|
+
match = matchers.hsl.exec(color);
|
|
6688
|
+
if (match) {
|
|
6689
|
+
return { h: match[1], s: match[2], l: match[3] };
|
|
6690
|
+
}
|
|
6691
|
+
match = matchers.hsla.exec(color);
|
|
6692
|
+
if (match) {
|
|
6693
|
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
6694
|
+
}
|
|
6695
|
+
match = matchers.hsv.exec(color);
|
|
6696
|
+
if (match) {
|
|
6697
|
+
return { h: match[1], s: match[2], v: match[3] };
|
|
6698
|
+
}
|
|
6699
|
+
match = matchers.hsva.exec(color);
|
|
6700
|
+
if (match) {
|
|
6701
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
6702
|
+
}
|
|
6703
|
+
match = matchers.hex8.exec(color);
|
|
6704
|
+
if (match) {
|
|
6705
|
+
return {
|
|
6706
|
+
r: parseIntFromHex(match[1]),
|
|
6707
|
+
g: parseIntFromHex(match[2]),
|
|
6708
|
+
b: parseIntFromHex(match[3]),
|
|
6709
|
+
a: convertHexToDecimal(match[4]),
|
|
6710
|
+
format: named ? 'name' : 'hex8',
|
|
6711
|
+
};
|
|
6712
|
+
}
|
|
6713
|
+
match = matchers.hex6.exec(color);
|
|
6714
|
+
if (match) {
|
|
6715
|
+
return {
|
|
6716
|
+
r: parseIntFromHex(match[1]),
|
|
6717
|
+
g: parseIntFromHex(match[2]),
|
|
6718
|
+
b: parseIntFromHex(match[3]),
|
|
6719
|
+
format: named ? 'name' : 'hex',
|
|
6720
|
+
};
|
|
6721
|
+
}
|
|
6722
|
+
match = matchers.hex4.exec(color);
|
|
6723
|
+
if (match) {
|
|
6724
|
+
return {
|
|
6725
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
6726
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
6727
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
6728
|
+
a: convertHexToDecimal(match[4] + match[4]),
|
|
6729
|
+
format: named ? 'name' : 'hex8',
|
|
6730
|
+
};
|
|
6731
|
+
}
|
|
6732
|
+
match = matchers.hex3.exec(color);
|
|
6733
|
+
if (match) {
|
|
6734
|
+
return {
|
|
6735
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
6736
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
6737
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
6738
|
+
format: named ? 'name' : 'hex',
|
|
6739
|
+
};
|
|
6740
|
+
}
|
|
6741
|
+
return false;
|
|
6742
|
+
}
|
|
6743
|
+
/**
|
|
6744
|
+
* Check to see if it looks like a CSS unit
|
|
6745
|
+
* (see `matchers` above for definition).
|
|
6746
|
+
*/
|
|
6747
|
+
function isValidCSSUnit(color) {
|
|
6748
|
+
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
6749
|
+
}
|
|
6750
|
+
|
|
6751
|
+
var hueStep = 2; // 色相阶梯
|
|
6752
|
+
|
|
6753
|
+
var saturationStep = 0.16; // 饱和度阶梯,浅色部分
|
|
6754
|
+
|
|
6755
|
+
var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
|
|
6756
|
+
|
|
6757
|
+
var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
|
|
6758
|
+
|
|
6759
|
+
var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
|
|
6760
|
+
|
|
6761
|
+
var lightColorCount = 5; // 浅色数量,主色上
|
|
6762
|
+
|
|
6763
|
+
var darkColorCount = 4; // 深色数量,主色下
|
|
6764
|
+
// 暗色主题颜色映射关系表
|
|
6765
|
+
|
|
6766
|
+
var darkColorMap = [{
|
|
6767
|
+
index: 7,
|
|
6768
|
+
opacity: 0.15
|
|
6769
|
+
}, {
|
|
6770
|
+
index: 6,
|
|
6771
|
+
opacity: 0.25
|
|
6772
|
+
}, {
|
|
6773
|
+
index: 5,
|
|
6774
|
+
opacity: 0.3
|
|
6775
|
+
}, {
|
|
6776
|
+
index: 5,
|
|
6777
|
+
opacity: 0.45
|
|
6778
|
+
}, {
|
|
6779
|
+
index: 5,
|
|
6780
|
+
opacity: 0.65
|
|
6781
|
+
}, {
|
|
6782
|
+
index: 5,
|
|
6783
|
+
opacity: 0.85
|
|
6784
|
+
}, {
|
|
6785
|
+
index: 4,
|
|
6786
|
+
opacity: 0.9
|
|
6787
|
+
}, {
|
|
6788
|
+
index: 3,
|
|
6789
|
+
opacity: 0.95
|
|
6790
|
+
}, {
|
|
6791
|
+
index: 2,
|
|
6792
|
+
opacity: 0.97
|
|
6793
|
+
}, {
|
|
6794
|
+
index: 1,
|
|
6795
|
+
opacity: 0.98
|
|
6796
|
+
}]; // Wrapper function ported from TinyColor.prototype.toHsv
|
|
6797
|
+
// Keep it here because of `hsv.h * 360`
|
|
6798
|
+
|
|
6799
|
+
function toHsv(_ref) {
|
|
6800
|
+
var r = _ref.r,
|
|
6801
|
+
g = _ref.g,
|
|
6802
|
+
b = _ref.b;
|
|
6803
|
+
var hsv = rgbToHsv(r, g, b);
|
|
6804
|
+
return {
|
|
6805
|
+
h: hsv.h * 360,
|
|
6806
|
+
s: hsv.s,
|
|
6807
|
+
v: hsv.v
|
|
6808
|
+
};
|
|
6809
|
+
} // Wrapper function ported from TinyColor.prototype.toHexString
|
|
6810
|
+
// Keep it here because of the prefix `#`
|
|
6811
|
+
|
|
6812
|
+
|
|
6813
|
+
function toHex(_ref2) {
|
|
6814
|
+
var r = _ref2.r,
|
|
6815
|
+
g = _ref2.g,
|
|
6816
|
+
b = _ref2.b;
|
|
6817
|
+
return "#".concat(rgbToHex(r, g, b, false));
|
|
6818
|
+
} // Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
|
|
6819
|
+
// Amount in range [0, 1]
|
|
6820
|
+
// Assume color1 & color2 has no alpha, since the following src code did so.
|
|
6821
|
+
|
|
6822
|
+
|
|
6823
|
+
function mix(rgb1, rgb2, amount) {
|
|
6824
|
+
var p = amount / 100;
|
|
6825
|
+
var rgb = {
|
|
6826
|
+
r: (rgb2.r - rgb1.r) * p + rgb1.r,
|
|
6827
|
+
g: (rgb2.g - rgb1.g) * p + rgb1.g,
|
|
6828
|
+
b: (rgb2.b - rgb1.b) * p + rgb1.b
|
|
6829
|
+
};
|
|
6830
|
+
return rgb;
|
|
6831
|
+
}
|
|
6832
|
+
|
|
6833
|
+
function getHue(hsv, i, light) {
|
|
6834
|
+
var hue; // 根据色相不同,色相转向不同
|
|
6835
|
+
|
|
6836
|
+
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
|
|
6837
|
+
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
|
|
6838
|
+
} else {
|
|
6839
|
+
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
|
|
6840
|
+
}
|
|
6841
|
+
|
|
6842
|
+
if (hue < 0) {
|
|
6843
|
+
hue += 360;
|
|
6844
|
+
} else if (hue >= 360) {
|
|
6845
|
+
hue -= 360;
|
|
6846
|
+
}
|
|
6847
|
+
|
|
6848
|
+
return hue;
|
|
6849
|
+
}
|
|
6850
|
+
|
|
6851
|
+
function getSaturation(hsv, i, light) {
|
|
6852
|
+
// grey color don't change saturation
|
|
6853
|
+
if (hsv.h === 0 && hsv.s === 0) {
|
|
6854
|
+
return hsv.s;
|
|
6855
|
+
}
|
|
6856
|
+
|
|
6857
|
+
var saturation;
|
|
6858
|
+
|
|
6859
|
+
if (light) {
|
|
6860
|
+
saturation = hsv.s - saturationStep * i;
|
|
6861
|
+
} else if (i === darkColorCount) {
|
|
6862
|
+
saturation = hsv.s + saturationStep;
|
|
6863
|
+
} else {
|
|
6864
|
+
saturation = hsv.s + saturationStep2 * i;
|
|
6865
|
+
} // 边界值修正
|
|
6866
|
+
|
|
6867
|
+
|
|
6868
|
+
if (saturation > 1) {
|
|
6869
|
+
saturation = 1;
|
|
6870
|
+
} // 第一格的 s 限制在 0.06-0.1 之间
|
|
6871
|
+
|
|
6872
|
+
|
|
6873
|
+
if (light && i === lightColorCount && saturation > 0.1) {
|
|
6874
|
+
saturation = 0.1;
|
|
6875
|
+
}
|
|
6876
|
+
|
|
6877
|
+
if (saturation < 0.06) {
|
|
6878
|
+
saturation = 0.06;
|
|
6879
|
+
}
|
|
6880
|
+
|
|
6881
|
+
return Number(saturation.toFixed(2));
|
|
6882
|
+
}
|
|
6883
|
+
|
|
6884
|
+
function getValue(hsv, i, light) {
|
|
6885
|
+
var value;
|
|
6886
|
+
|
|
6887
|
+
if (light) {
|
|
6888
|
+
value = hsv.v + brightnessStep1 * i;
|
|
6889
|
+
} else {
|
|
6890
|
+
value = hsv.v - brightnessStep2 * i;
|
|
6891
|
+
}
|
|
6892
|
+
|
|
6893
|
+
if (value > 1) {
|
|
6894
|
+
value = 1;
|
|
6895
|
+
}
|
|
6896
|
+
|
|
6897
|
+
return Number(value.toFixed(2));
|
|
6898
|
+
}
|
|
6899
|
+
|
|
6900
|
+
function generate(color) {
|
|
6901
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6902
|
+
var patterns = [];
|
|
6903
|
+
var pColor = inputToRGB(color);
|
|
6904
|
+
|
|
6905
|
+
for (var i = lightColorCount; i > 0; i -= 1) {
|
|
6906
|
+
var hsv = toHsv(pColor);
|
|
6907
|
+
var colorString = toHex(inputToRGB({
|
|
6908
|
+
h: getHue(hsv, i, true),
|
|
6909
|
+
s: getSaturation(hsv, i, true),
|
|
6910
|
+
v: getValue(hsv, i, true)
|
|
6911
|
+
}));
|
|
6912
|
+
patterns.push(colorString);
|
|
6913
|
+
}
|
|
6914
|
+
|
|
6915
|
+
patterns.push(toHex(pColor));
|
|
6916
|
+
|
|
6917
|
+
for (var _i = 1; _i <= darkColorCount; _i += 1) {
|
|
6918
|
+
var _hsv = toHsv(pColor);
|
|
6919
|
+
|
|
6920
|
+
var _colorString = toHex(inputToRGB({
|
|
6921
|
+
h: getHue(_hsv, _i),
|
|
6922
|
+
s: getSaturation(_hsv, _i),
|
|
6923
|
+
v: getValue(_hsv, _i)
|
|
6924
|
+
}));
|
|
6925
|
+
|
|
6926
|
+
patterns.push(_colorString);
|
|
6927
|
+
} // dark theme patterns
|
|
6928
|
+
|
|
6929
|
+
|
|
6930
|
+
if (opts.theme === 'dark') {
|
|
6931
|
+
return darkColorMap.map(function (_ref3) {
|
|
6932
|
+
var index = _ref3.index,
|
|
6933
|
+
opacity = _ref3.opacity;
|
|
6934
|
+
var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100));
|
|
6935
|
+
return darkColorString;
|
|
6936
|
+
});
|
|
6937
|
+
}
|
|
6938
|
+
|
|
6939
|
+
return patterns;
|
|
6940
|
+
}
|
|
6941
|
+
|
|
6942
|
+
var presetPrimaryColors = {
|
|
6943
|
+
red: '#F5222D',
|
|
6944
|
+
volcano: '#FA541C',
|
|
6945
|
+
orange: '#FA8C16',
|
|
6946
|
+
gold: '#FAAD14',
|
|
6947
|
+
yellow: '#FADB14',
|
|
6948
|
+
lime: '#A0D911',
|
|
6949
|
+
green: '#52C41A',
|
|
6950
|
+
cyan: '#13C2C2',
|
|
6951
|
+
blue: '#1890FF',
|
|
6952
|
+
geekblue: '#2F54EB',
|
|
6953
|
+
purple: '#722ED1',
|
|
6954
|
+
magenta: '#EB2F96',
|
|
6955
|
+
grey: '#666666'
|
|
6956
|
+
};
|
|
6957
|
+
var presetPalettes = {};
|
|
6958
|
+
var presetDarkPalettes = {};
|
|
6959
|
+
Object.keys(presetPrimaryColors).forEach(function (key) {
|
|
6960
|
+
presetPalettes[key] = generate(presetPrimaryColors[key]);
|
|
6961
|
+
presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes
|
|
6962
|
+
|
|
6963
|
+
presetDarkPalettes[key] = generate(presetPrimaryColors[key], {
|
|
6964
|
+
theme: 'dark',
|
|
6965
|
+
backgroundColor: '#141414'
|
|
6966
|
+
});
|
|
6967
|
+
presetDarkPalettes[key].primary = presetDarkPalettes[key][5];
|
|
6968
|
+
});
|
|
6969
|
+
presetPalettes.red;
|
|
6970
|
+
presetPalettes.volcano;
|
|
6971
|
+
presetPalettes.gold;
|
|
6972
|
+
presetPalettes.orange;
|
|
6973
|
+
presetPalettes.yellow;
|
|
6974
|
+
presetPalettes.lime;
|
|
6975
|
+
presetPalettes.green;
|
|
6976
|
+
presetPalettes.cyan;
|
|
6977
|
+
presetPalettes.blue;
|
|
6978
|
+
presetPalettes.geekblue;
|
|
6979
|
+
presetPalettes.purple;
|
|
6980
|
+
presetPalettes.magenta;
|
|
6981
|
+
presetPalettes.grey;
|
|
6982
|
+
|
|
6983
|
+
function getStyleByBaseColors(theme, baseColors, backgroundColor) {
|
|
6984
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByPalettes(generatePalettes(baseColors, theme, backgroundColor)));
|
|
6985
|
+
}
|
|
6986
|
+
function getStyleByBrandColor(theme, brandColor) {
|
|
6987
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByBrand(brandColor));
|
|
6988
|
+
}
|
|
6989
|
+
function getStyleByVariables(theme, variables) {
|
|
6990
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByVariables(variables));
|
|
6991
|
+
}
|
|
6992
|
+
|
|
6993
|
+
function getLightStyle(cssVariableDefinitions) {
|
|
6994
|
+
return ":root,\n[data-override-theme=\"light\"] {\n".concat(cssVariableDefinitions, "}");
|
|
6995
|
+
}
|
|
6996
|
+
|
|
6997
|
+
function getDarkStyle(cssVariableDefinitions) {
|
|
6998
|
+
return "html[data-theme=\"dark-v2\"],\n[data-override-theme=\"dark-v2\"] {\n".concat(cssVariableDefinitions, "}");
|
|
6999
|
+
}
|
|
7000
|
+
|
|
7001
|
+
function getCssVariableDefinitionsByPalettes(palettes) {
|
|
7002
|
+
return Object.entries(palettes).flatMap(_ref => {
|
|
7003
|
+
var [colorName, palette] = _ref;
|
|
7004
|
+
ensureBaseColorName(colorName);
|
|
7005
|
+
return palette.map((color, index) => " --palette-".concat(colorName, "-").concat(index + 1, ": ").concat(color, ";")) // Concat an empty string to make a double-line-break for each group of color name.
|
|
7006
|
+
.concat("");
|
|
7007
|
+
}).join("\n");
|
|
7008
|
+
}
|
|
7009
|
+
|
|
7010
|
+
function generatePalettes(baseColors, theme, backgroundColor) {
|
|
7011
|
+
return Object.fromEntries(Object.entries(baseColors).map(_ref2 => {
|
|
7012
|
+
var [colorName, baseColor] = _ref2;
|
|
7013
|
+
return [colorName, generate(baseColor, theme === "dark" ? {
|
|
7014
|
+
theme,
|
|
7015
|
+
backgroundColor
|
|
7016
|
+
} : undefined)];
|
|
7017
|
+
}));
|
|
7018
|
+
}
|
|
7019
|
+
|
|
7020
|
+
function getCssVariableDefinitionsByBrand(color) {
|
|
7021
|
+
if (typeof color === "string") {
|
|
7022
|
+
return " --color-brand: ".concat(color, ";\n");
|
|
7023
|
+
}
|
|
7024
|
+
|
|
7025
|
+
return [" --color-brand: ".concat(color.default, ";"), " --color-brand-hover: ".concat(color.hover, ";"), " --color-brand-active: ".concat(color.active, ";"), ""].join("\n");
|
|
7026
|
+
}
|
|
7027
|
+
|
|
7028
|
+
function getCssVariableDefinitionsByVariables(variables) {
|
|
7029
|
+
return Object.entries(variables).map(_ref3 => {
|
|
7030
|
+
var [name, color] = _ref3;
|
|
7031
|
+
ensureCssVariableName(name);
|
|
7032
|
+
return " ".concat(name, ": ").concat(color, ";");
|
|
7033
|
+
}).concat("").join("\n");
|
|
7034
|
+
}
|
|
7035
|
+
|
|
7036
|
+
function ensureCssVariableName(name) {
|
|
7037
|
+
if (!/^--[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(name)) {
|
|
7038
|
+
throw new Error("Invalid css variable name: ".concat(JSON.stringify(name)));
|
|
7039
|
+
}
|
|
7040
|
+
}
|
|
7041
|
+
|
|
7042
|
+
function ensureBaseColorName(name) {
|
|
7043
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) {
|
|
7044
|
+
throw new Error("Invalid base color name: ".concat(JSON.stringify(name)));
|
|
7045
|
+
}
|
|
7046
|
+
}
|
|
7047
|
+
|
|
7048
|
+
function applyColorTheme(options) {
|
|
7049
|
+
var style = [];
|
|
7050
|
+
var themes = ["light", "dark"];
|
|
7051
|
+
themes.forEach(theme => {
|
|
7052
|
+
if (options[theme]) {
|
|
7053
|
+
switch (options.type) {
|
|
7054
|
+
case "brandColor":
|
|
7055
|
+
style.push(getStyleByBrandColor(theme, options[theme]));
|
|
7056
|
+
break;
|
|
7057
|
+
|
|
7058
|
+
case "baseColors":
|
|
7059
|
+
style.push(getStyleByBaseColors(theme, options[theme], options.backgroundColor));
|
|
7060
|
+
break;
|
|
7061
|
+
|
|
7062
|
+
case "variables":
|
|
7063
|
+
style.push(getStyleByVariables(theme, options[theme]));
|
|
7064
|
+
break;
|
|
7065
|
+
}
|
|
7066
|
+
}
|
|
7067
|
+
});
|
|
7068
|
+
|
|
7069
|
+
if (style.length > 0) {
|
|
7070
|
+
var element = document.createElement("style");
|
|
7071
|
+
element.textContent = style.join("\n\n");
|
|
7072
|
+
document.head.appendChild(element);
|
|
7073
|
+
return () => {
|
|
7074
|
+
element.remove();
|
|
7075
|
+
};
|
|
7076
|
+
}
|
|
7077
|
+
}
|
|
7078
|
+
|
|
6211
7079
|
class Kernel {
|
|
6212
7080
|
constructor() {
|
|
6213
7081
|
_defineProperty__default["default"](this, "mountPoints", void 0);
|
|
@@ -6257,6 +7125,8 @@
|
|
|
6257
7125
|
var _this = this;
|
|
6258
7126
|
|
|
6259
7127
|
return _asyncToGenerator__default["default"](function* () {
|
|
7128
|
+
var _this$bootstrapData$s, _this$bootstrapData$s2;
|
|
7129
|
+
|
|
6260
7130
|
_this.mountPoints = mountPoints;
|
|
6261
7131
|
yield Promise.all([_this.loadCheckLogin(), _this.loadMicroApps()]);
|
|
6262
7132
|
|
|
@@ -6264,6 +7134,8 @@
|
|
|
6264
7134
|
throw new Error("No storyboard were found.");
|
|
6265
7135
|
}
|
|
6266
7136
|
|
|
7137
|
+
generateColorTheme((_this$bootstrapData$s = _this.bootstrapData.settings) === null || _this$bootstrapData$s === void 0 ? void 0 : (_this$bootstrapData$s2 = _this$bootstrapData$s.misc) === null || _this$bootstrapData$s2 === void 0 ? void 0 : _this$bootstrapData$s2.theme);
|
|
7138
|
+
|
|
6267
7139
|
if (isLoggedIn()) {
|
|
6268
7140
|
_this.loadSharedData();
|
|
6269
7141
|
}
|
|
@@ -6818,9 +7690,9 @@
|
|
|
6818
7690
|
}
|
|
6819
7691
|
|
|
6820
7692
|
getFeatureFlags() {
|
|
6821
|
-
var _this$bootstrapData, _this$bootstrapData$
|
|
7693
|
+
var _this$bootstrapData, _this$bootstrapData$s3;
|
|
6822
7694
|
|
|
6823
|
-
return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$
|
|
7695
|
+
return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$s3 = _this$bootstrapData.settings) === null || _this$bootstrapData$s3 === void 0 ? void 0 : _this$bootstrapData$s3.featureFlags);
|
|
6824
7696
|
}
|
|
6825
7697
|
|
|
6826
7698
|
getStandaloneMenus(menuId) {
|
|
@@ -6889,6 +7761,24 @@
|
|
|
6889
7761
|
return brickUtils.loadScript(src, window.PUBLIC_ROOT);
|
|
6890
7762
|
}
|
|
6891
7763
|
|
|
7764
|
+
function generateColorTheme(theme) {
|
|
7765
|
+
if (!theme) {
|
|
7766
|
+
return;
|
|
7767
|
+
} else if (theme.brandColor) {
|
|
7768
|
+
applyColorTheme(_objectSpread__default["default"]({
|
|
7769
|
+
type: "brandColor"
|
|
7770
|
+
}, theme.brandColor));
|
|
7771
|
+
} else if (theme.baseColors) {
|
|
7772
|
+
applyColorTheme(_objectSpread__default["default"]({
|
|
7773
|
+
type: "baseColors"
|
|
7774
|
+
}, theme.baseColors));
|
|
7775
|
+
} else if (theme.variables) {
|
|
7776
|
+
applyColorTheme(_objectSpread__default["default"]({
|
|
7777
|
+
type: "variables"
|
|
7778
|
+
}, theme.variables));
|
|
7779
|
+
}
|
|
7780
|
+
}
|
|
7781
|
+
|
|
6892
7782
|
/*! (c) Andrea Giammarchi - ISC */
|
|
6893
7783
|
var self = {};
|
|
6894
7784
|
|
|
@@ -9203,15 +10093,25 @@
|
|
|
9203
10093
|
|
|
9204
10094
|
if (useMocks) mocks = _objectSpread__default["default"](_objectSpread__default["default"]({}, useMocks), {}, {
|
|
9205
10095
|
mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => _objectSpread__default["default"](_objectSpread__default["default"]({}, item), {}, {
|
|
9206
|
-
uri: item.uri.replace(/(easyops\.api\.)(
|
|
9207
|
-
return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)
|
|
9208
|
-
}).replace(/:\w+/g, "[
|
|
10096
|
+
uri: item.uri.replace(/(easyops\.api\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
|
|
10097
|
+
return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
|
|
10098
|
+
}).replace(/:\w+/g, "([^/]+)")
|
|
9209
10099
|
}))
|
|
9210
10100
|
});
|
|
9211
10101
|
}
|
|
9212
|
-
var
|
|
9213
|
-
|
|
9214
|
-
|
|
10102
|
+
var getMockInfo = requestUrl => {
|
|
10103
|
+
var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl));
|
|
10104
|
+
|
|
10105
|
+
if (item) {
|
|
10106
|
+
return {
|
|
10107
|
+
url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
|
|
10108
|
+
return "".concat(p1, "/").concat(p3);
|
|
10109
|
+
}).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
|
|
10110
|
+
mockId: mocks.mockId
|
|
10111
|
+
};
|
|
10112
|
+
}
|
|
10113
|
+
|
|
10114
|
+
return;
|
|
9215
10115
|
};
|
|
9216
10116
|
|
|
9217
10117
|
class Router {
|
|
@@ -9379,7 +10279,7 @@
|
|
|
9379
10279
|
var _this3 = this;
|
|
9380
10280
|
|
|
9381
10281
|
return _asyncToGenerator__default["default"](function* () {
|
|
9382
|
-
var _apiAnalyzer$getInsta;
|
|
10282
|
+
var _apiAnalyzer$getInsta, _currentApp$theme;
|
|
9383
10283
|
|
|
9384
10284
|
_this3.state = "initial";
|
|
9385
10285
|
_this3.renderId = lodash.uniqueId("render-id-");
|
|
@@ -9430,6 +10330,8 @@
|
|
|
9430
10330
|
var legacy = currentApp ? currentApp.legacy : undefined;
|
|
9431
10331
|
_this3.kernel.nextApp = currentApp;
|
|
9432
10332
|
var layoutType = (currentApp === null || currentApp === void 0 ? void 0 : currentApp.layoutType) || "console";
|
|
10333
|
+
setTheme((_currentApp$theme = currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
|
|
10334
|
+
setMode("default");
|
|
9433
10335
|
devtoolsHookEmit("rendering");
|
|
9434
10336
|
unmountTree(mountPoints.bg);
|
|
9435
10337
|
|
|
@@ -9440,7 +10342,7 @@
|
|
|
9440
10342
|
};
|
|
9441
10343
|
|
|
9442
10344
|
if (storyboard) {
|
|
9443
|
-
var _currentApp$breadcrum, _currentApp$breadcrum2
|
|
10345
|
+
var _currentApp$breadcrum, _currentApp$breadcrum2;
|
|
9444
10346
|
|
|
9445
10347
|
if (appChanged && currentApp.id && isLoggedIn()) {
|
|
9446
10348
|
var usedCustomApis = brickUtils.mapCustomApisToNameAndNamespace(brickUtils.scanCustomApisInStoryboard(storyboard));
|
|
@@ -9537,10 +10439,8 @@
|
|
|
9537
10439
|
_this3.kernel.unsetBars({
|
|
9538
10440
|
appChanged,
|
|
9539
10441
|
legacy: actualLegacy
|
|
9540
|
-
});
|
|
10442
|
+
}); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
|
|
9541
10443
|
|
|
9542
|
-
setTheme((_currentApp$theme = currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
|
|
9543
|
-
setMode("default"); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
|
|
9544
10444
|
|
|
9545
10445
|
_this3.locationContext.handleBeforePageLoad();
|
|
9546
10446
|
|
|
@@ -11713,7 +12613,7 @@
|
|
|
11713
12613
|
exports.event = event;
|
|
11714
12614
|
exports.getAuth = getAuth;
|
|
11715
12615
|
exports.getHistory = getHistory;
|
|
11716
|
-
exports.
|
|
12616
|
+
exports.getMockInfo = getMockInfo;
|
|
11717
12617
|
exports.getRuntime = getRuntime;
|
|
11718
12618
|
exports.handleHttpError = handleHttpError;
|
|
11719
12619
|
exports.httpErrorToString = httpErrorToString;
|