@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.esm.js
CHANGED
|
@@ -1510,6 +1510,11 @@ function getIndividualGlobal(variableName, _ref) {
|
|
|
1510
1510
|
return {
|
|
1511
1511
|
check: collectCoverage ? fakeCheckPermissions : checkPermissions
|
|
1512
1512
|
};
|
|
1513
|
+
|
|
1514
|
+
case "THEME":
|
|
1515
|
+
return {
|
|
1516
|
+
getTheme: collectCoverage ? () => "light" : getTheme
|
|
1517
|
+
};
|
|
1513
1518
|
}
|
|
1514
1519
|
}
|
|
1515
1520
|
|
|
@@ -1876,39 +1881,16 @@ function evaluate(raw) {
|
|
|
1876
1881
|
});
|
|
1877
1882
|
|
|
1878
1883
|
case "QUERY":
|
|
1879
|
-
return
|
|
1880
|
-
get(target, key) {
|
|
1881
|
-
return query.has(key) ? query.get(key) : undefined;
|
|
1882
|
-
},
|
|
1883
|
-
|
|
1884
|
-
ownKeys() {
|
|
1885
|
-
return Array.from(query.keys());
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
});
|
|
1884
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
|
|
1889
1885
|
|
|
1890
1886
|
case "QUERY_ARRAY":
|
|
1891
|
-
return
|
|
1892
|
-
get(target, key) {
|
|
1893
|
-
return query.has(key) ? query.getAll(key) : undefined;
|
|
1894
|
-
},
|
|
1895
|
-
|
|
1896
|
-
ownKeys() {
|
|
1897
|
-
return Array.from(query.keys());
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
});
|
|
1887
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
|
|
1901
1888
|
|
|
1902
1889
|
case "SEGUE":
|
|
1903
1890
|
return {
|
|
1904
1891
|
getUrl: getUrlBySegueFactory(app, segues)
|
|
1905
1892
|
};
|
|
1906
1893
|
|
|
1907
|
-
case "THEME":
|
|
1908
|
-
return {
|
|
1909
|
-
getTheme
|
|
1910
|
-
};
|
|
1911
|
-
|
|
1912
1894
|
case "SESSION_STORAGE":
|
|
1913
1895
|
return {
|
|
1914
1896
|
getItem: getItemFactory("session")
|
|
@@ -6191,6 +6173,892 @@ function _standaloneBootstrap() {
|
|
|
6191
6173
|
return _standaloneBootstrap.apply(this, arguments);
|
|
6192
6174
|
}
|
|
6193
6175
|
|
|
6176
|
+
/**
|
|
6177
|
+
* Take input from [0, n] and return it as [0, 1]
|
|
6178
|
+
* @hidden
|
|
6179
|
+
*/
|
|
6180
|
+
function bound01(n, max) {
|
|
6181
|
+
if (isOnePointZero(n)) {
|
|
6182
|
+
n = '100%';
|
|
6183
|
+
}
|
|
6184
|
+
var isPercent = isPercentage(n);
|
|
6185
|
+
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
|
|
6186
|
+
// Automatically convert percentage into number
|
|
6187
|
+
if (isPercent) {
|
|
6188
|
+
n = parseInt(String(n * max), 10) / 100;
|
|
6189
|
+
}
|
|
6190
|
+
// Handle floating point rounding errors
|
|
6191
|
+
if (Math.abs(n - max) < 0.000001) {
|
|
6192
|
+
return 1;
|
|
6193
|
+
}
|
|
6194
|
+
// Convert into [0, 1] range if it isn't already
|
|
6195
|
+
if (max === 360) {
|
|
6196
|
+
// If n is a hue given in degrees,
|
|
6197
|
+
// wrap around out-of-range values into [0, 360] range
|
|
6198
|
+
// then convert into [0, 1].
|
|
6199
|
+
n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
|
|
6200
|
+
}
|
|
6201
|
+
else {
|
|
6202
|
+
// If n not a hue given in degrees
|
|
6203
|
+
// Convert into [0, 1] range if it isn't already.
|
|
6204
|
+
n = (n % max) / parseFloat(String(max));
|
|
6205
|
+
}
|
|
6206
|
+
return n;
|
|
6207
|
+
}
|
|
6208
|
+
/**
|
|
6209
|
+
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
6210
|
+
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
6211
|
+
* @hidden
|
|
6212
|
+
*/
|
|
6213
|
+
function isOnePointZero(n) {
|
|
6214
|
+
return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
|
|
6215
|
+
}
|
|
6216
|
+
/**
|
|
6217
|
+
* Check to see if string passed in is a percentage
|
|
6218
|
+
* @hidden
|
|
6219
|
+
*/
|
|
6220
|
+
function isPercentage(n) {
|
|
6221
|
+
return typeof n === 'string' && n.indexOf('%') !== -1;
|
|
6222
|
+
}
|
|
6223
|
+
/**
|
|
6224
|
+
* Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
6225
|
+
* @hidden
|
|
6226
|
+
*/
|
|
6227
|
+
function boundAlpha(a) {
|
|
6228
|
+
a = parseFloat(a);
|
|
6229
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
6230
|
+
a = 1;
|
|
6231
|
+
}
|
|
6232
|
+
return a;
|
|
6233
|
+
}
|
|
6234
|
+
/**
|
|
6235
|
+
* Replace a decimal with it's percentage value
|
|
6236
|
+
* @hidden
|
|
6237
|
+
*/
|
|
6238
|
+
function convertToPercentage(n) {
|
|
6239
|
+
if (n <= 1) {
|
|
6240
|
+
return Number(n) * 100 + "%";
|
|
6241
|
+
}
|
|
6242
|
+
return n;
|
|
6243
|
+
}
|
|
6244
|
+
/**
|
|
6245
|
+
* Force a hex value to have 2 characters
|
|
6246
|
+
* @hidden
|
|
6247
|
+
*/
|
|
6248
|
+
function pad2(c) {
|
|
6249
|
+
return c.length === 1 ? '0' + c : String(c);
|
|
6250
|
+
}
|
|
6251
|
+
|
|
6252
|
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
6253
|
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
6254
|
+
/**
|
|
6255
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
6256
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
6257
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
6258
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
6259
|
+
*/
|
|
6260
|
+
function rgbToRgb(r, g, b) {
|
|
6261
|
+
return {
|
|
6262
|
+
r: bound01(r, 255) * 255,
|
|
6263
|
+
g: bound01(g, 255) * 255,
|
|
6264
|
+
b: bound01(b, 255) * 255,
|
|
6265
|
+
};
|
|
6266
|
+
}
|
|
6267
|
+
function hue2rgb(p, q, t) {
|
|
6268
|
+
if (t < 0) {
|
|
6269
|
+
t += 1;
|
|
6270
|
+
}
|
|
6271
|
+
if (t > 1) {
|
|
6272
|
+
t -= 1;
|
|
6273
|
+
}
|
|
6274
|
+
if (t < 1 / 6) {
|
|
6275
|
+
return p + (q - p) * (6 * t);
|
|
6276
|
+
}
|
|
6277
|
+
if (t < 1 / 2) {
|
|
6278
|
+
return q;
|
|
6279
|
+
}
|
|
6280
|
+
if (t < 2 / 3) {
|
|
6281
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
6282
|
+
}
|
|
6283
|
+
return p;
|
|
6284
|
+
}
|
|
6285
|
+
/**
|
|
6286
|
+
* Converts an HSL color value to RGB.
|
|
6287
|
+
*
|
|
6288
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
6289
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
6290
|
+
*/
|
|
6291
|
+
function hslToRgb(h, s, l) {
|
|
6292
|
+
var r;
|
|
6293
|
+
var g;
|
|
6294
|
+
var b;
|
|
6295
|
+
h = bound01(h, 360);
|
|
6296
|
+
s = bound01(s, 100);
|
|
6297
|
+
l = bound01(l, 100);
|
|
6298
|
+
if (s === 0) {
|
|
6299
|
+
// achromatic
|
|
6300
|
+
g = l;
|
|
6301
|
+
b = l;
|
|
6302
|
+
r = l;
|
|
6303
|
+
}
|
|
6304
|
+
else {
|
|
6305
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
6306
|
+
var p = 2 * l - q;
|
|
6307
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
6308
|
+
g = hue2rgb(p, q, h);
|
|
6309
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
6310
|
+
}
|
|
6311
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
6312
|
+
}
|
|
6313
|
+
/**
|
|
6314
|
+
* Converts an RGB color value to HSV
|
|
6315
|
+
*
|
|
6316
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
6317
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
6318
|
+
*/
|
|
6319
|
+
function rgbToHsv(r, g, b) {
|
|
6320
|
+
r = bound01(r, 255);
|
|
6321
|
+
g = bound01(g, 255);
|
|
6322
|
+
b = bound01(b, 255);
|
|
6323
|
+
var max = Math.max(r, g, b);
|
|
6324
|
+
var min = Math.min(r, g, b);
|
|
6325
|
+
var h = 0;
|
|
6326
|
+
var v = max;
|
|
6327
|
+
var d = max - min;
|
|
6328
|
+
var s = max === 0 ? 0 : d / max;
|
|
6329
|
+
if (max === min) {
|
|
6330
|
+
h = 0; // achromatic
|
|
6331
|
+
}
|
|
6332
|
+
else {
|
|
6333
|
+
switch (max) {
|
|
6334
|
+
case r:
|
|
6335
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
6336
|
+
break;
|
|
6337
|
+
case g:
|
|
6338
|
+
h = (b - r) / d + 2;
|
|
6339
|
+
break;
|
|
6340
|
+
case b:
|
|
6341
|
+
h = (r - g) / d + 4;
|
|
6342
|
+
break;
|
|
6343
|
+
}
|
|
6344
|
+
h /= 6;
|
|
6345
|
+
}
|
|
6346
|
+
return { h: h, s: s, v: v };
|
|
6347
|
+
}
|
|
6348
|
+
/**
|
|
6349
|
+
* Converts an HSV color value to RGB.
|
|
6350
|
+
*
|
|
6351
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
6352
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
6353
|
+
*/
|
|
6354
|
+
function hsvToRgb(h, s, v) {
|
|
6355
|
+
h = bound01(h, 360) * 6;
|
|
6356
|
+
s = bound01(s, 100);
|
|
6357
|
+
v = bound01(v, 100);
|
|
6358
|
+
var i = Math.floor(h);
|
|
6359
|
+
var f = h - i;
|
|
6360
|
+
var p = v * (1 - s);
|
|
6361
|
+
var q = v * (1 - f * s);
|
|
6362
|
+
var t = v * (1 - (1 - f) * s);
|
|
6363
|
+
var mod = i % 6;
|
|
6364
|
+
var r = [v, q, p, p, t, v][mod];
|
|
6365
|
+
var g = [t, v, v, q, p, p][mod];
|
|
6366
|
+
var b = [p, p, t, v, v, q][mod];
|
|
6367
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
6368
|
+
}
|
|
6369
|
+
/**
|
|
6370
|
+
* Converts an RGB color to hex
|
|
6371
|
+
*
|
|
6372
|
+
* Assumes r, g, and b are contained in the set [0, 255]
|
|
6373
|
+
* Returns a 3 or 6 character hex
|
|
6374
|
+
*/
|
|
6375
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
6376
|
+
var hex = [
|
|
6377
|
+
pad2(Math.round(r).toString(16)),
|
|
6378
|
+
pad2(Math.round(g).toString(16)),
|
|
6379
|
+
pad2(Math.round(b).toString(16)),
|
|
6380
|
+
];
|
|
6381
|
+
// Return a 3 character hex if possible
|
|
6382
|
+
if (allow3Char &&
|
|
6383
|
+
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
6384
|
+
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
6385
|
+
hex[2].startsWith(hex[2].charAt(1))) {
|
|
6386
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
6387
|
+
}
|
|
6388
|
+
return hex.join('');
|
|
6389
|
+
}
|
|
6390
|
+
/** Converts a hex value to a decimal */
|
|
6391
|
+
function convertHexToDecimal(h) {
|
|
6392
|
+
return parseIntFromHex(h) / 255;
|
|
6393
|
+
}
|
|
6394
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
6395
|
+
function parseIntFromHex(val) {
|
|
6396
|
+
return parseInt(val, 16);
|
|
6397
|
+
}
|
|
6398
|
+
|
|
6399
|
+
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
|
|
6400
|
+
/**
|
|
6401
|
+
* @hidden
|
|
6402
|
+
*/
|
|
6403
|
+
var names = {
|
|
6404
|
+
aliceblue: '#f0f8ff',
|
|
6405
|
+
antiquewhite: '#faebd7',
|
|
6406
|
+
aqua: '#00ffff',
|
|
6407
|
+
aquamarine: '#7fffd4',
|
|
6408
|
+
azure: '#f0ffff',
|
|
6409
|
+
beige: '#f5f5dc',
|
|
6410
|
+
bisque: '#ffe4c4',
|
|
6411
|
+
black: '#000000',
|
|
6412
|
+
blanchedalmond: '#ffebcd',
|
|
6413
|
+
blue: '#0000ff',
|
|
6414
|
+
blueviolet: '#8a2be2',
|
|
6415
|
+
brown: '#a52a2a',
|
|
6416
|
+
burlywood: '#deb887',
|
|
6417
|
+
cadetblue: '#5f9ea0',
|
|
6418
|
+
chartreuse: '#7fff00',
|
|
6419
|
+
chocolate: '#d2691e',
|
|
6420
|
+
coral: '#ff7f50',
|
|
6421
|
+
cornflowerblue: '#6495ed',
|
|
6422
|
+
cornsilk: '#fff8dc',
|
|
6423
|
+
crimson: '#dc143c',
|
|
6424
|
+
cyan: '#00ffff',
|
|
6425
|
+
darkblue: '#00008b',
|
|
6426
|
+
darkcyan: '#008b8b',
|
|
6427
|
+
darkgoldenrod: '#b8860b',
|
|
6428
|
+
darkgray: '#a9a9a9',
|
|
6429
|
+
darkgreen: '#006400',
|
|
6430
|
+
darkgrey: '#a9a9a9',
|
|
6431
|
+
darkkhaki: '#bdb76b',
|
|
6432
|
+
darkmagenta: '#8b008b',
|
|
6433
|
+
darkolivegreen: '#556b2f',
|
|
6434
|
+
darkorange: '#ff8c00',
|
|
6435
|
+
darkorchid: '#9932cc',
|
|
6436
|
+
darkred: '#8b0000',
|
|
6437
|
+
darksalmon: '#e9967a',
|
|
6438
|
+
darkseagreen: '#8fbc8f',
|
|
6439
|
+
darkslateblue: '#483d8b',
|
|
6440
|
+
darkslategray: '#2f4f4f',
|
|
6441
|
+
darkslategrey: '#2f4f4f',
|
|
6442
|
+
darkturquoise: '#00ced1',
|
|
6443
|
+
darkviolet: '#9400d3',
|
|
6444
|
+
deeppink: '#ff1493',
|
|
6445
|
+
deepskyblue: '#00bfff',
|
|
6446
|
+
dimgray: '#696969',
|
|
6447
|
+
dimgrey: '#696969',
|
|
6448
|
+
dodgerblue: '#1e90ff',
|
|
6449
|
+
firebrick: '#b22222',
|
|
6450
|
+
floralwhite: '#fffaf0',
|
|
6451
|
+
forestgreen: '#228b22',
|
|
6452
|
+
fuchsia: '#ff00ff',
|
|
6453
|
+
gainsboro: '#dcdcdc',
|
|
6454
|
+
ghostwhite: '#f8f8ff',
|
|
6455
|
+
goldenrod: '#daa520',
|
|
6456
|
+
gold: '#ffd700',
|
|
6457
|
+
gray: '#808080',
|
|
6458
|
+
green: '#008000',
|
|
6459
|
+
greenyellow: '#adff2f',
|
|
6460
|
+
grey: '#808080',
|
|
6461
|
+
honeydew: '#f0fff0',
|
|
6462
|
+
hotpink: '#ff69b4',
|
|
6463
|
+
indianred: '#cd5c5c',
|
|
6464
|
+
indigo: '#4b0082',
|
|
6465
|
+
ivory: '#fffff0',
|
|
6466
|
+
khaki: '#f0e68c',
|
|
6467
|
+
lavenderblush: '#fff0f5',
|
|
6468
|
+
lavender: '#e6e6fa',
|
|
6469
|
+
lawngreen: '#7cfc00',
|
|
6470
|
+
lemonchiffon: '#fffacd',
|
|
6471
|
+
lightblue: '#add8e6',
|
|
6472
|
+
lightcoral: '#f08080',
|
|
6473
|
+
lightcyan: '#e0ffff',
|
|
6474
|
+
lightgoldenrodyellow: '#fafad2',
|
|
6475
|
+
lightgray: '#d3d3d3',
|
|
6476
|
+
lightgreen: '#90ee90',
|
|
6477
|
+
lightgrey: '#d3d3d3',
|
|
6478
|
+
lightpink: '#ffb6c1',
|
|
6479
|
+
lightsalmon: '#ffa07a',
|
|
6480
|
+
lightseagreen: '#20b2aa',
|
|
6481
|
+
lightskyblue: '#87cefa',
|
|
6482
|
+
lightslategray: '#778899',
|
|
6483
|
+
lightslategrey: '#778899',
|
|
6484
|
+
lightsteelblue: '#b0c4de',
|
|
6485
|
+
lightyellow: '#ffffe0',
|
|
6486
|
+
lime: '#00ff00',
|
|
6487
|
+
limegreen: '#32cd32',
|
|
6488
|
+
linen: '#faf0e6',
|
|
6489
|
+
magenta: '#ff00ff',
|
|
6490
|
+
maroon: '#800000',
|
|
6491
|
+
mediumaquamarine: '#66cdaa',
|
|
6492
|
+
mediumblue: '#0000cd',
|
|
6493
|
+
mediumorchid: '#ba55d3',
|
|
6494
|
+
mediumpurple: '#9370db',
|
|
6495
|
+
mediumseagreen: '#3cb371',
|
|
6496
|
+
mediumslateblue: '#7b68ee',
|
|
6497
|
+
mediumspringgreen: '#00fa9a',
|
|
6498
|
+
mediumturquoise: '#48d1cc',
|
|
6499
|
+
mediumvioletred: '#c71585',
|
|
6500
|
+
midnightblue: '#191970',
|
|
6501
|
+
mintcream: '#f5fffa',
|
|
6502
|
+
mistyrose: '#ffe4e1',
|
|
6503
|
+
moccasin: '#ffe4b5',
|
|
6504
|
+
navajowhite: '#ffdead',
|
|
6505
|
+
navy: '#000080',
|
|
6506
|
+
oldlace: '#fdf5e6',
|
|
6507
|
+
olive: '#808000',
|
|
6508
|
+
olivedrab: '#6b8e23',
|
|
6509
|
+
orange: '#ffa500',
|
|
6510
|
+
orangered: '#ff4500',
|
|
6511
|
+
orchid: '#da70d6',
|
|
6512
|
+
palegoldenrod: '#eee8aa',
|
|
6513
|
+
palegreen: '#98fb98',
|
|
6514
|
+
paleturquoise: '#afeeee',
|
|
6515
|
+
palevioletred: '#db7093',
|
|
6516
|
+
papayawhip: '#ffefd5',
|
|
6517
|
+
peachpuff: '#ffdab9',
|
|
6518
|
+
peru: '#cd853f',
|
|
6519
|
+
pink: '#ffc0cb',
|
|
6520
|
+
plum: '#dda0dd',
|
|
6521
|
+
powderblue: '#b0e0e6',
|
|
6522
|
+
purple: '#800080',
|
|
6523
|
+
rebeccapurple: '#663399',
|
|
6524
|
+
red: '#ff0000',
|
|
6525
|
+
rosybrown: '#bc8f8f',
|
|
6526
|
+
royalblue: '#4169e1',
|
|
6527
|
+
saddlebrown: '#8b4513',
|
|
6528
|
+
salmon: '#fa8072',
|
|
6529
|
+
sandybrown: '#f4a460',
|
|
6530
|
+
seagreen: '#2e8b57',
|
|
6531
|
+
seashell: '#fff5ee',
|
|
6532
|
+
sienna: '#a0522d',
|
|
6533
|
+
silver: '#c0c0c0',
|
|
6534
|
+
skyblue: '#87ceeb',
|
|
6535
|
+
slateblue: '#6a5acd',
|
|
6536
|
+
slategray: '#708090',
|
|
6537
|
+
slategrey: '#708090',
|
|
6538
|
+
snow: '#fffafa',
|
|
6539
|
+
springgreen: '#00ff7f',
|
|
6540
|
+
steelblue: '#4682b4',
|
|
6541
|
+
tan: '#d2b48c',
|
|
6542
|
+
teal: '#008080',
|
|
6543
|
+
thistle: '#d8bfd8',
|
|
6544
|
+
tomato: '#ff6347',
|
|
6545
|
+
turquoise: '#40e0d0',
|
|
6546
|
+
violet: '#ee82ee',
|
|
6547
|
+
wheat: '#f5deb3',
|
|
6548
|
+
white: '#ffffff',
|
|
6549
|
+
whitesmoke: '#f5f5f5',
|
|
6550
|
+
yellow: '#ffff00',
|
|
6551
|
+
yellowgreen: '#9acd32',
|
|
6552
|
+
};
|
|
6553
|
+
|
|
6554
|
+
/**
|
|
6555
|
+
* Given a string or object, convert that input to RGB
|
|
6556
|
+
*
|
|
6557
|
+
* Possible string inputs:
|
|
6558
|
+
* ```
|
|
6559
|
+
* "red"
|
|
6560
|
+
* "#f00" or "f00"
|
|
6561
|
+
* "#ff0000" or "ff0000"
|
|
6562
|
+
* "#ff000000" or "ff000000"
|
|
6563
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
6564
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
6565
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
6566
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
6567
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
6568
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
6569
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
6570
|
+
* ```
|
|
6571
|
+
*/
|
|
6572
|
+
function inputToRGB(color) {
|
|
6573
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
|
6574
|
+
var a = 1;
|
|
6575
|
+
var s = null;
|
|
6576
|
+
var v = null;
|
|
6577
|
+
var l = null;
|
|
6578
|
+
var ok = false;
|
|
6579
|
+
var format = false;
|
|
6580
|
+
if (typeof color === 'string') {
|
|
6581
|
+
color = stringInputToObject(color);
|
|
6582
|
+
}
|
|
6583
|
+
if (typeof color === 'object') {
|
|
6584
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
6585
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
6586
|
+
ok = true;
|
|
6587
|
+
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
|
|
6588
|
+
}
|
|
6589
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
6590
|
+
s = convertToPercentage(color.s);
|
|
6591
|
+
v = convertToPercentage(color.v);
|
|
6592
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
6593
|
+
ok = true;
|
|
6594
|
+
format = 'hsv';
|
|
6595
|
+
}
|
|
6596
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
6597
|
+
s = convertToPercentage(color.s);
|
|
6598
|
+
l = convertToPercentage(color.l);
|
|
6599
|
+
rgb = hslToRgb(color.h, s, l);
|
|
6600
|
+
ok = true;
|
|
6601
|
+
format = 'hsl';
|
|
6602
|
+
}
|
|
6603
|
+
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
|
|
6604
|
+
a = color.a;
|
|
6605
|
+
}
|
|
6606
|
+
}
|
|
6607
|
+
a = boundAlpha(a);
|
|
6608
|
+
return {
|
|
6609
|
+
ok: ok,
|
|
6610
|
+
format: color.format || format,
|
|
6611
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
6612
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
6613
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
6614
|
+
a: a,
|
|
6615
|
+
};
|
|
6616
|
+
}
|
|
6617
|
+
// <http://www.w3.org/TR/css3-values/#integers>
|
|
6618
|
+
var CSS_INTEGER = '[-\\+]?\\d+%?';
|
|
6619
|
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
6620
|
+
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
|
6621
|
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
6622
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
6623
|
+
// Actual matching.
|
|
6624
|
+
// Parentheses and commas are optional, but not required.
|
|
6625
|
+
// Whitespace can take the place of commas or opening paren
|
|
6626
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
6627
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
6628
|
+
var matchers = {
|
|
6629
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
6630
|
+
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
|
|
6631
|
+
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
|
|
6632
|
+
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
|
|
6633
|
+
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
|
|
6634
|
+
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
|
|
6635
|
+
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
|
|
6636
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
6637
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
6638
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
6639
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
6640
|
+
};
|
|
6641
|
+
/**
|
|
6642
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
6643
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
6644
|
+
*/
|
|
6645
|
+
function stringInputToObject(color) {
|
|
6646
|
+
color = color.trim().toLowerCase();
|
|
6647
|
+
if (color.length === 0) {
|
|
6648
|
+
return false;
|
|
6649
|
+
}
|
|
6650
|
+
var named = false;
|
|
6651
|
+
if (names[color]) {
|
|
6652
|
+
color = names[color];
|
|
6653
|
+
named = true;
|
|
6654
|
+
}
|
|
6655
|
+
else if (color === 'transparent') {
|
|
6656
|
+
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
|
|
6657
|
+
}
|
|
6658
|
+
// Try to match string input using regular expressions.
|
|
6659
|
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
6660
|
+
// Just return an object and let the conversion functions handle that.
|
|
6661
|
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
6662
|
+
var match = matchers.rgb.exec(color);
|
|
6663
|
+
if (match) {
|
|
6664
|
+
return { r: match[1], g: match[2], b: match[3] };
|
|
6665
|
+
}
|
|
6666
|
+
match = matchers.rgba.exec(color);
|
|
6667
|
+
if (match) {
|
|
6668
|
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
6669
|
+
}
|
|
6670
|
+
match = matchers.hsl.exec(color);
|
|
6671
|
+
if (match) {
|
|
6672
|
+
return { h: match[1], s: match[2], l: match[3] };
|
|
6673
|
+
}
|
|
6674
|
+
match = matchers.hsla.exec(color);
|
|
6675
|
+
if (match) {
|
|
6676
|
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
6677
|
+
}
|
|
6678
|
+
match = matchers.hsv.exec(color);
|
|
6679
|
+
if (match) {
|
|
6680
|
+
return { h: match[1], s: match[2], v: match[3] };
|
|
6681
|
+
}
|
|
6682
|
+
match = matchers.hsva.exec(color);
|
|
6683
|
+
if (match) {
|
|
6684
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
6685
|
+
}
|
|
6686
|
+
match = matchers.hex8.exec(color);
|
|
6687
|
+
if (match) {
|
|
6688
|
+
return {
|
|
6689
|
+
r: parseIntFromHex(match[1]),
|
|
6690
|
+
g: parseIntFromHex(match[2]),
|
|
6691
|
+
b: parseIntFromHex(match[3]),
|
|
6692
|
+
a: convertHexToDecimal(match[4]),
|
|
6693
|
+
format: named ? 'name' : 'hex8',
|
|
6694
|
+
};
|
|
6695
|
+
}
|
|
6696
|
+
match = matchers.hex6.exec(color);
|
|
6697
|
+
if (match) {
|
|
6698
|
+
return {
|
|
6699
|
+
r: parseIntFromHex(match[1]),
|
|
6700
|
+
g: parseIntFromHex(match[2]),
|
|
6701
|
+
b: parseIntFromHex(match[3]),
|
|
6702
|
+
format: named ? 'name' : 'hex',
|
|
6703
|
+
};
|
|
6704
|
+
}
|
|
6705
|
+
match = matchers.hex4.exec(color);
|
|
6706
|
+
if (match) {
|
|
6707
|
+
return {
|
|
6708
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
6709
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
6710
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
6711
|
+
a: convertHexToDecimal(match[4] + match[4]),
|
|
6712
|
+
format: named ? 'name' : 'hex8',
|
|
6713
|
+
};
|
|
6714
|
+
}
|
|
6715
|
+
match = matchers.hex3.exec(color);
|
|
6716
|
+
if (match) {
|
|
6717
|
+
return {
|
|
6718
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
6719
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
6720
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
6721
|
+
format: named ? 'name' : 'hex',
|
|
6722
|
+
};
|
|
6723
|
+
}
|
|
6724
|
+
return false;
|
|
6725
|
+
}
|
|
6726
|
+
/**
|
|
6727
|
+
* Check to see if it looks like a CSS unit
|
|
6728
|
+
* (see `matchers` above for definition).
|
|
6729
|
+
*/
|
|
6730
|
+
function isValidCSSUnit(color) {
|
|
6731
|
+
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
6732
|
+
}
|
|
6733
|
+
|
|
6734
|
+
var hueStep = 2; // 色相阶梯
|
|
6735
|
+
|
|
6736
|
+
var saturationStep = 0.16; // 饱和度阶梯,浅色部分
|
|
6737
|
+
|
|
6738
|
+
var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
|
|
6739
|
+
|
|
6740
|
+
var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
|
|
6741
|
+
|
|
6742
|
+
var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
|
|
6743
|
+
|
|
6744
|
+
var lightColorCount = 5; // 浅色数量,主色上
|
|
6745
|
+
|
|
6746
|
+
var darkColorCount = 4; // 深色数量,主色下
|
|
6747
|
+
// 暗色主题颜色映射关系表
|
|
6748
|
+
|
|
6749
|
+
var darkColorMap = [{
|
|
6750
|
+
index: 7,
|
|
6751
|
+
opacity: 0.15
|
|
6752
|
+
}, {
|
|
6753
|
+
index: 6,
|
|
6754
|
+
opacity: 0.25
|
|
6755
|
+
}, {
|
|
6756
|
+
index: 5,
|
|
6757
|
+
opacity: 0.3
|
|
6758
|
+
}, {
|
|
6759
|
+
index: 5,
|
|
6760
|
+
opacity: 0.45
|
|
6761
|
+
}, {
|
|
6762
|
+
index: 5,
|
|
6763
|
+
opacity: 0.65
|
|
6764
|
+
}, {
|
|
6765
|
+
index: 5,
|
|
6766
|
+
opacity: 0.85
|
|
6767
|
+
}, {
|
|
6768
|
+
index: 4,
|
|
6769
|
+
opacity: 0.9
|
|
6770
|
+
}, {
|
|
6771
|
+
index: 3,
|
|
6772
|
+
opacity: 0.95
|
|
6773
|
+
}, {
|
|
6774
|
+
index: 2,
|
|
6775
|
+
opacity: 0.97
|
|
6776
|
+
}, {
|
|
6777
|
+
index: 1,
|
|
6778
|
+
opacity: 0.98
|
|
6779
|
+
}]; // Wrapper function ported from TinyColor.prototype.toHsv
|
|
6780
|
+
// Keep it here because of `hsv.h * 360`
|
|
6781
|
+
|
|
6782
|
+
function toHsv(_ref) {
|
|
6783
|
+
var r = _ref.r,
|
|
6784
|
+
g = _ref.g,
|
|
6785
|
+
b = _ref.b;
|
|
6786
|
+
var hsv = rgbToHsv(r, g, b);
|
|
6787
|
+
return {
|
|
6788
|
+
h: hsv.h * 360,
|
|
6789
|
+
s: hsv.s,
|
|
6790
|
+
v: hsv.v
|
|
6791
|
+
};
|
|
6792
|
+
} // Wrapper function ported from TinyColor.prototype.toHexString
|
|
6793
|
+
// Keep it here because of the prefix `#`
|
|
6794
|
+
|
|
6795
|
+
|
|
6796
|
+
function toHex(_ref2) {
|
|
6797
|
+
var r = _ref2.r,
|
|
6798
|
+
g = _ref2.g,
|
|
6799
|
+
b = _ref2.b;
|
|
6800
|
+
return "#".concat(rgbToHex(r, g, b, false));
|
|
6801
|
+
} // Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
|
|
6802
|
+
// Amount in range [0, 1]
|
|
6803
|
+
// Assume color1 & color2 has no alpha, since the following src code did so.
|
|
6804
|
+
|
|
6805
|
+
|
|
6806
|
+
function mix(rgb1, rgb2, amount) {
|
|
6807
|
+
var p = amount / 100;
|
|
6808
|
+
var rgb = {
|
|
6809
|
+
r: (rgb2.r - rgb1.r) * p + rgb1.r,
|
|
6810
|
+
g: (rgb2.g - rgb1.g) * p + rgb1.g,
|
|
6811
|
+
b: (rgb2.b - rgb1.b) * p + rgb1.b
|
|
6812
|
+
};
|
|
6813
|
+
return rgb;
|
|
6814
|
+
}
|
|
6815
|
+
|
|
6816
|
+
function getHue(hsv, i, light) {
|
|
6817
|
+
var hue; // 根据色相不同,色相转向不同
|
|
6818
|
+
|
|
6819
|
+
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
|
|
6820
|
+
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
|
|
6821
|
+
} else {
|
|
6822
|
+
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
|
|
6823
|
+
}
|
|
6824
|
+
|
|
6825
|
+
if (hue < 0) {
|
|
6826
|
+
hue += 360;
|
|
6827
|
+
} else if (hue >= 360) {
|
|
6828
|
+
hue -= 360;
|
|
6829
|
+
}
|
|
6830
|
+
|
|
6831
|
+
return hue;
|
|
6832
|
+
}
|
|
6833
|
+
|
|
6834
|
+
function getSaturation(hsv, i, light) {
|
|
6835
|
+
// grey color don't change saturation
|
|
6836
|
+
if (hsv.h === 0 && hsv.s === 0) {
|
|
6837
|
+
return hsv.s;
|
|
6838
|
+
}
|
|
6839
|
+
|
|
6840
|
+
var saturation;
|
|
6841
|
+
|
|
6842
|
+
if (light) {
|
|
6843
|
+
saturation = hsv.s - saturationStep * i;
|
|
6844
|
+
} else if (i === darkColorCount) {
|
|
6845
|
+
saturation = hsv.s + saturationStep;
|
|
6846
|
+
} else {
|
|
6847
|
+
saturation = hsv.s + saturationStep2 * i;
|
|
6848
|
+
} // 边界值修正
|
|
6849
|
+
|
|
6850
|
+
|
|
6851
|
+
if (saturation > 1) {
|
|
6852
|
+
saturation = 1;
|
|
6853
|
+
} // 第一格的 s 限制在 0.06-0.1 之间
|
|
6854
|
+
|
|
6855
|
+
|
|
6856
|
+
if (light && i === lightColorCount && saturation > 0.1) {
|
|
6857
|
+
saturation = 0.1;
|
|
6858
|
+
}
|
|
6859
|
+
|
|
6860
|
+
if (saturation < 0.06) {
|
|
6861
|
+
saturation = 0.06;
|
|
6862
|
+
}
|
|
6863
|
+
|
|
6864
|
+
return Number(saturation.toFixed(2));
|
|
6865
|
+
}
|
|
6866
|
+
|
|
6867
|
+
function getValue(hsv, i, light) {
|
|
6868
|
+
var value;
|
|
6869
|
+
|
|
6870
|
+
if (light) {
|
|
6871
|
+
value = hsv.v + brightnessStep1 * i;
|
|
6872
|
+
} else {
|
|
6873
|
+
value = hsv.v - brightnessStep2 * i;
|
|
6874
|
+
}
|
|
6875
|
+
|
|
6876
|
+
if (value > 1) {
|
|
6877
|
+
value = 1;
|
|
6878
|
+
}
|
|
6879
|
+
|
|
6880
|
+
return Number(value.toFixed(2));
|
|
6881
|
+
}
|
|
6882
|
+
|
|
6883
|
+
function generate(color) {
|
|
6884
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6885
|
+
var patterns = [];
|
|
6886
|
+
var pColor = inputToRGB(color);
|
|
6887
|
+
|
|
6888
|
+
for (var i = lightColorCount; i > 0; i -= 1) {
|
|
6889
|
+
var hsv = toHsv(pColor);
|
|
6890
|
+
var colorString = toHex(inputToRGB({
|
|
6891
|
+
h: getHue(hsv, i, true),
|
|
6892
|
+
s: getSaturation(hsv, i, true),
|
|
6893
|
+
v: getValue(hsv, i, true)
|
|
6894
|
+
}));
|
|
6895
|
+
patterns.push(colorString);
|
|
6896
|
+
}
|
|
6897
|
+
|
|
6898
|
+
patterns.push(toHex(pColor));
|
|
6899
|
+
|
|
6900
|
+
for (var _i = 1; _i <= darkColorCount; _i += 1) {
|
|
6901
|
+
var _hsv = toHsv(pColor);
|
|
6902
|
+
|
|
6903
|
+
var _colorString = toHex(inputToRGB({
|
|
6904
|
+
h: getHue(_hsv, _i),
|
|
6905
|
+
s: getSaturation(_hsv, _i),
|
|
6906
|
+
v: getValue(_hsv, _i)
|
|
6907
|
+
}));
|
|
6908
|
+
|
|
6909
|
+
patterns.push(_colorString);
|
|
6910
|
+
} // dark theme patterns
|
|
6911
|
+
|
|
6912
|
+
|
|
6913
|
+
if (opts.theme === 'dark') {
|
|
6914
|
+
return darkColorMap.map(function (_ref3) {
|
|
6915
|
+
var index = _ref3.index,
|
|
6916
|
+
opacity = _ref3.opacity;
|
|
6917
|
+
var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100));
|
|
6918
|
+
return darkColorString;
|
|
6919
|
+
});
|
|
6920
|
+
}
|
|
6921
|
+
|
|
6922
|
+
return patterns;
|
|
6923
|
+
}
|
|
6924
|
+
|
|
6925
|
+
var presetPrimaryColors = {
|
|
6926
|
+
red: '#F5222D',
|
|
6927
|
+
volcano: '#FA541C',
|
|
6928
|
+
orange: '#FA8C16',
|
|
6929
|
+
gold: '#FAAD14',
|
|
6930
|
+
yellow: '#FADB14',
|
|
6931
|
+
lime: '#A0D911',
|
|
6932
|
+
green: '#52C41A',
|
|
6933
|
+
cyan: '#13C2C2',
|
|
6934
|
+
blue: '#1890FF',
|
|
6935
|
+
geekblue: '#2F54EB',
|
|
6936
|
+
purple: '#722ED1',
|
|
6937
|
+
magenta: '#EB2F96',
|
|
6938
|
+
grey: '#666666'
|
|
6939
|
+
};
|
|
6940
|
+
var presetPalettes = {};
|
|
6941
|
+
var presetDarkPalettes = {};
|
|
6942
|
+
Object.keys(presetPrimaryColors).forEach(function (key) {
|
|
6943
|
+
presetPalettes[key] = generate(presetPrimaryColors[key]);
|
|
6944
|
+
presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes
|
|
6945
|
+
|
|
6946
|
+
presetDarkPalettes[key] = generate(presetPrimaryColors[key], {
|
|
6947
|
+
theme: 'dark',
|
|
6948
|
+
backgroundColor: '#141414'
|
|
6949
|
+
});
|
|
6950
|
+
presetDarkPalettes[key].primary = presetDarkPalettes[key][5];
|
|
6951
|
+
});
|
|
6952
|
+
presetPalettes.red;
|
|
6953
|
+
presetPalettes.volcano;
|
|
6954
|
+
presetPalettes.gold;
|
|
6955
|
+
presetPalettes.orange;
|
|
6956
|
+
presetPalettes.yellow;
|
|
6957
|
+
presetPalettes.lime;
|
|
6958
|
+
presetPalettes.green;
|
|
6959
|
+
presetPalettes.cyan;
|
|
6960
|
+
presetPalettes.blue;
|
|
6961
|
+
presetPalettes.geekblue;
|
|
6962
|
+
presetPalettes.purple;
|
|
6963
|
+
presetPalettes.magenta;
|
|
6964
|
+
presetPalettes.grey;
|
|
6965
|
+
|
|
6966
|
+
function getStyleByBaseColors(theme, baseColors, backgroundColor) {
|
|
6967
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByPalettes(generatePalettes(baseColors, theme, backgroundColor)));
|
|
6968
|
+
}
|
|
6969
|
+
function getStyleByBrandColor(theme, brandColor) {
|
|
6970
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByBrand(brandColor));
|
|
6971
|
+
}
|
|
6972
|
+
function getStyleByVariables(theme, variables) {
|
|
6973
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByVariables(variables));
|
|
6974
|
+
}
|
|
6975
|
+
|
|
6976
|
+
function getLightStyle(cssVariableDefinitions) {
|
|
6977
|
+
return ":root,\n[data-override-theme=\"light\"] {\n".concat(cssVariableDefinitions, "}");
|
|
6978
|
+
}
|
|
6979
|
+
|
|
6980
|
+
function getDarkStyle(cssVariableDefinitions) {
|
|
6981
|
+
return "html[data-theme=\"dark-v2\"],\n[data-override-theme=\"dark-v2\"] {\n".concat(cssVariableDefinitions, "}");
|
|
6982
|
+
}
|
|
6983
|
+
|
|
6984
|
+
function getCssVariableDefinitionsByPalettes(palettes) {
|
|
6985
|
+
return Object.entries(palettes).flatMap(_ref => {
|
|
6986
|
+
var [colorName, palette] = _ref;
|
|
6987
|
+
ensureBaseColorName(colorName);
|
|
6988
|
+
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.
|
|
6989
|
+
.concat("");
|
|
6990
|
+
}).join("\n");
|
|
6991
|
+
}
|
|
6992
|
+
|
|
6993
|
+
function generatePalettes(baseColors, theme, backgroundColor) {
|
|
6994
|
+
return Object.fromEntries(Object.entries(baseColors).map(_ref2 => {
|
|
6995
|
+
var [colorName, baseColor] = _ref2;
|
|
6996
|
+
return [colorName, generate(baseColor, theme === "dark" ? {
|
|
6997
|
+
theme,
|
|
6998
|
+
backgroundColor
|
|
6999
|
+
} : undefined)];
|
|
7000
|
+
}));
|
|
7001
|
+
}
|
|
7002
|
+
|
|
7003
|
+
function getCssVariableDefinitionsByBrand(color) {
|
|
7004
|
+
if (typeof color === "string") {
|
|
7005
|
+
return " --color-brand: ".concat(color, ";\n");
|
|
7006
|
+
}
|
|
7007
|
+
|
|
7008
|
+
return [" --color-brand: ".concat(color.default, ";"), " --color-brand-hover: ".concat(color.hover, ";"), " --color-brand-active: ".concat(color.active, ";"), ""].join("\n");
|
|
7009
|
+
}
|
|
7010
|
+
|
|
7011
|
+
function getCssVariableDefinitionsByVariables(variables) {
|
|
7012
|
+
return Object.entries(variables).map(_ref3 => {
|
|
7013
|
+
var [name, color] = _ref3;
|
|
7014
|
+
ensureCssVariableName(name);
|
|
7015
|
+
return " ".concat(name, ": ").concat(color, ";");
|
|
7016
|
+
}).concat("").join("\n");
|
|
7017
|
+
}
|
|
7018
|
+
|
|
7019
|
+
function ensureCssVariableName(name) {
|
|
7020
|
+
if (!/^--[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(name)) {
|
|
7021
|
+
throw new Error("Invalid css variable name: ".concat(JSON.stringify(name)));
|
|
7022
|
+
}
|
|
7023
|
+
}
|
|
7024
|
+
|
|
7025
|
+
function ensureBaseColorName(name) {
|
|
7026
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) {
|
|
7027
|
+
throw new Error("Invalid base color name: ".concat(JSON.stringify(name)));
|
|
7028
|
+
}
|
|
7029
|
+
}
|
|
7030
|
+
|
|
7031
|
+
function applyColorTheme(options) {
|
|
7032
|
+
var style = [];
|
|
7033
|
+
var themes = ["light", "dark"];
|
|
7034
|
+
themes.forEach(theme => {
|
|
7035
|
+
if (options[theme]) {
|
|
7036
|
+
switch (options.type) {
|
|
7037
|
+
case "brandColor":
|
|
7038
|
+
style.push(getStyleByBrandColor(theme, options[theme]));
|
|
7039
|
+
break;
|
|
7040
|
+
|
|
7041
|
+
case "baseColors":
|
|
7042
|
+
style.push(getStyleByBaseColors(theme, options[theme], options.backgroundColor));
|
|
7043
|
+
break;
|
|
7044
|
+
|
|
7045
|
+
case "variables":
|
|
7046
|
+
style.push(getStyleByVariables(theme, options[theme]));
|
|
7047
|
+
break;
|
|
7048
|
+
}
|
|
7049
|
+
}
|
|
7050
|
+
});
|
|
7051
|
+
|
|
7052
|
+
if (style.length > 0) {
|
|
7053
|
+
var element = document.createElement("style");
|
|
7054
|
+
element.textContent = style.join("\n\n");
|
|
7055
|
+
document.head.appendChild(element);
|
|
7056
|
+
return () => {
|
|
7057
|
+
element.remove();
|
|
7058
|
+
};
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
|
|
6194
7062
|
class Kernel {
|
|
6195
7063
|
constructor() {
|
|
6196
7064
|
_defineProperty$1(this, "mountPoints", void 0);
|
|
@@ -6240,6 +7108,8 @@ class Kernel {
|
|
|
6240
7108
|
var _this = this;
|
|
6241
7109
|
|
|
6242
7110
|
return _asyncToGenerator$4(function* () {
|
|
7111
|
+
var _this$bootstrapData$s, _this$bootstrapData$s2;
|
|
7112
|
+
|
|
6243
7113
|
_this.mountPoints = mountPoints;
|
|
6244
7114
|
yield Promise.all([_this.loadCheckLogin(), _this.loadMicroApps()]);
|
|
6245
7115
|
|
|
@@ -6247,6 +7117,8 @@ class Kernel {
|
|
|
6247
7117
|
throw new Error("No storyboard were found.");
|
|
6248
7118
|
}
|
|
6249
7119
|
|
|
7120
|
+
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);
|
|
7121
|
+
|
|
6250
7122
|
if (isLoggedIn()) {
|
|
6251
7123
|
_this.loadSharedData();
|
|
6252
7124
|
}
|
|
@@ -6801,9 +7673,9 @@ class Kernel {
|
|
|
6801
7673
|
}
|
|
6802
7674
|
|
|
6803
7675
|
getFeatureFlags() {
|
|
6804
|
-
var _this$bootstrapData, _this$bootstrapData$
|
|
7676
|
+
var _this$bootstrapData, _this$bootstrapData$s3;
|
|
6805
7677
|
|
|
6806
|
-
return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$
|
|
7678
|
+
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);
|
|
6807
7679
|
}
|
|
6808
7680
|
|
|
6809
7681
|
getStandaloneMenus(menuId) {
|
|
@@ -6872,6 +7744,24 @@ function loadScriptOfBricksOrTemplates(src) {
|
|
|
6872
7744
|
return loadScript(src, window.PUBLIC_ROOT);
|
|
6873
7745
|
}
|
|
6874
7746
|
|
|
7747
|
+
function generateColorTheme(theme) {
|
|
7748
|
+
if (!theme) {
|
|
7749
|
+
return;
|
|
7750
|
+
} else if (theme.brandColor) {
|
|
7751
|
+
applyColorTheme(_objectSpread({
|
|
7752
|
+
type: "brandColor"
|
|
7753
|
+
}, theme.brandColor));
|
|
7754
|
+
} else if (theme.baseColors) {
|
|
7755
|
+
applyColorTheme(_objectSpread({
|
|
7756
|
+
type: "baseColors"
|
|
7757
|
+
}, theme.baseColors));
|
|
7758
|
+
} else if (theme.variables) {
|
|
7759
|
+
applyColorTheme(_objectSpread({
|
|
7760
|
+
type: "variables"
|
|
7761
|
+
}, theme.variables));
|
|
7762
|
+
}
|
|
7763
|
+
}
|
|
7764
|
+
|
|
6875
7765
|
/*! (c) Andrea Giammarchi - ISC */
|
|
6876
7766
|
var self = {};
|
|
6877
7767
|
|
|
@@ -9186,15 +10076,25 @@ function registerMock(useMocks) {
|
|
|
9186
10076
|
|
|
9187
10077
|
if (useMocks) mocks = _objectSpread(_objectSpread({}, useMocks), {}, {
|
|
9188
10078
|
mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
9189
|
-
uri: item.uri.replace(/(easyops\.api\.)(
|
|
9190
|
-
return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)
|
|
9191
|
-
}).replace(/:\w+/g, "[
|
|
10079
|
+
uri: item.uri.replace(/(easyops\.api\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
|
|
10080
|
+
return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
|
|
10081
|
+
}).replace(/:\w+/g, "([^/]+)")
|
|
9192
10082
|
}))
|
|
9193
10083
|
});
|
|
9194
10084
|
}
|
|
9195
|
-
var
|
|
9196
|
-
|
|
9197
|
-
|
|
10085
|
+
var getMockInfo = requestUrl => {
|
|
10086
|
+
var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl));
|
|
10087
|
+
|
|
10088
|
+
if (item) {
|
|
10089
|
+
return {
|
|
10090
|
+
url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
|
|
10091
|
+
return "".concat(p1, "/").concat(p3);
|
|
10092
|
+
}).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
|
|
10093
|
+
mockId: mocks.mockId
|
|
10094
|
+
};
|
|
10095
|
+
}
|
|
10096
|
+
|
|
10097
|
+
return;
|
|
9198
10098
|
};
|
|
9199
10099
|
|
|
9200
10100
|
class Router {
|
|
@@ -9362,7 +10262,7 @@ class Router {
|
|
|
9362
10262
|
var _this3 = this;
|
|
9363
10263
|
|
|
9364
10264
|
return _asyncToGenerator$4(function* () {
|
|
9365
|
-
var _apiAnalyzer$getInsta;
|
|
10265
|
+
var _apiAnalyzer$getInsta, _currentApp$theme;
|
|
9366
10266
|
|
|
9367
10267
|
_this3.state = "initial";
|
|
9368
10268
|
_this3.renderId = uniqueId("render-id-");
|
|
@@ -9413,6 +10313,8 @@ class Router {
|
|
|
9413
10313
|
var legacy = currentApp ? currentApp.legacy : undefined;
|
|
9414
10314
|
_this3.kernel.nextApp = currentApp;
|
|
9415
10315
|
var layoutType = (currentApp === null || currentApp === void 0 ? void 0 : currentApp.layoutType) || "console";
|
|
10316
|
+
setTheme((_currentApp$theme = currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
|
|
10317
|
+
setMode("default");
|
|
9416
10318
|
devtoolsHookEmit("rendering");
|
|
9417
10319
|
unmountTree(mountPoints.bg);
|
|
9418
10320
|
|
|
@@ -9423,7 +10325,7 @@ class Router {
|
|
|
9423
10325
|
};
|
|
9424
10326
|
|
|
9425
10327
|
if (storyboard) {
|
|
9426
|
-
var _currentApp$breadcrum, _currentApp$breadcrum2
|
|
10328
|
+
var _currentApp$breadcrum, _currentApp$breadcrum2;
|
|
9427
10329
|
|
|
9428
10330
|
if (appChanged && currentApp.id && isLoggedIn()) {
|
|
9429
10331
|
var usedCustomApis = mapCustomApisToNameAndNamespace(scanCustomApisInStoryboard(storyboard));
|
|
@@ -9520,10 +10422,8 @@ class Router {
|
|
|
9520
10422
|
_this3.kernel.unsetBars({
|
|
9521
10423
|
appChanged,
|
|
9522
10424
|
legacy: actualLegacy
|
|
9523
|
-
});
|
|
10425
|
+
}); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
|
|
9524
10426
|
|
|
9525
|
-
setTheme((_currentApp$theme = currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
|
|
9526
|
-
setMode("default"); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
|
|
9527
10427
|
|
|
9528
10428
|
_this3.locationContext.handleBeforePageLoad();
|
|
9529
10429
|
|
|
@@ -11675,5 +12575,5 @@ var ModalElement = _decorate(null, function (_initialize, _UpdatingElement) {
|
|
|
11675
12575
|
};
|
|
11676
12576
|
}, UpdatingElement);
|
|
11677
12577
|
|
|
11678
|
-
export { BrickAsComponent, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ModalElement, SingleBrickAsComponent, StoryboardFunctionRegistryFactory, UpdatingElement, authenticate, checkIf, checkIfByTransform, createHistory, createRuntime, developHelper, doTransform, event, getAuth, getHistory,
|
|
12578
|
+
export { BrickAsComponent, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ModalElement, SingleBrickAsComponent, StoryboardFunctionRegistryFactory, UpdatingElement, authenticate, checkIf, checkIfByTransform, createHistory, createRuntime, developHelper, doTransform, event, getAuth, getHistory, getMockInfo, getRuntime, handleHttpError, httpErrorToString, i18nText, initI18n, isLoggedIn, logout, looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useRecentApps };
|
|
11679
12579
|
//# sourceMappingURL=index.esm.js.map
|