@next-core/brick-kit 2.100.0 → 2.102.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/CHANGELOG.md +53 -0
- package/dist/index.bundle.js +1023 -78
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +1023 -78
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/FlowApi.d.ts.map +1 -1
- package/dist/types/core/Kernel.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/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
|
@@ -495,6 +495,24 @@ var InstanceApi_postSearch = /*#__PURE__*/function () {
|
|
|
495
495
|
return _ref.apply(this, arguments);
|
|
496
496
|
};
|
|
497
497
|
}();
|
|
498
|
+
/**
|
|
499
|
+
* @description 搜索实例V3 (支持多属性排序)
|
|
500
|
+
* @endpoint POST /v3/object/:objectId/instance/_search
|
|
501
|
+
*/
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
var InstanceApi_postSearchV3 = /*#__PURE__*/function () {
|
|
505
|
+
var _ref = _asyncToGenerator$3(function* (objectId, data, options) {
|
|
506
|
+
return (
|
|
507
|
+
/**! @contract easyops.api.cmdb.instance.PostSearchV3 */
|
|
508
|
+
(yield http.post("api/gateway/cmdb.instance.PostSearchV3/v3/object/".concat(objectId, "/instance/_search"), data, options)).data
|
|
509
|
+
);
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
return function InstanceApi_postSearchV3(_x, _x2, _x3) {
|
|
513
|
+
return _ref.apply(this, arguments);
|
|
514
|
+
};
|
|
515
|
+
}();
|
|
498
516
|
|
|
499
517
|
function supply(attemptToVisitGlobals, providedGlobalVariables) {
|
|
500
518
|
var globalVariables = _objectSpread({}, providedGlobalVariables); // Allow limited browser builtin values.
|
|
@@ -1510,6 +1528,11 @@ function getIndividualGlobal(variableName, _ref) {
|
|
|
1510
1528
|
return {
|
|
1511
1529
|
check: collectCoverage ? fakeCheckPermissions : checkPermissions
|
|
1512
1530
|
};
|
|
1531
|
+
|
|
1532
|
+
case "THEME":
|
|
1533
|
+
return {
|
|
1534
|
+
getTheme: collectCoverage ? () => "light" : getTheme
|
|
1535
|
+
};
|
|
1513
1536
|
}
|
|
1514
1537
|
}
|
|
1515
1538
|
|
|
@@ -1876,39 +1899,16 @@ function evaluate(raw) {
|
|
|
1876
1899
|
});
|
|
1877
1900
|
|
|
1878
1901
|
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
|
-
});
|
|
1902
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
|
|
1889
1903
|
|
|
1890
1904
|
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
|
-
});
|
|
1905
|
+
return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
|
|
1901
1906
|
|
|
1902
1907
|
case "SEGUE":
|
|
1903
1908
|
return {
|
|
1904
1909
|
getUrl: getUrlBySegueFactory(app, segues)
|
|
1905
1910
|
};
|
|
1906
1911
|
|
|
1907
|
-
case "THEME":
|
|
1908
|
-
return {
|
|
1909
|
-
getTheme
|
|
1910
|
-
};
|
|
1911
|
-
|
|
1912
1912
|
case "SESSION_STORAGE":
|
|
1913
1913
|
return {
|
|
1914
1914
|
getItem: getItemFactory("session")
|
|
@@ -5019,6 +5019,39 @@ var ContractApi_searchSingleContract = /*#__PURE__*/function () {
|
|
|
5019
5019
|
};
|
|
5020
5020
|
}();
|
|
5021
5021
|
|
|
5022
|
+
var mocks = {
|
|
5023
|
+
mockId: null,
|
|
5024
|
+
mockList: []
|
|
5025
|
+
};
|
|
5026
|
+
function registerMock(useMocks) {
|
|
5027
|
+
var _useMocks$mockList;
|
|
5028
|
+
|
|
5029
|
+
if (useMocks) mocks = _objectSpread(_objectSpread({}, useMocks), {}, {
|
|
5030
|
+
mockList: (_useMocks$mockList = useMocks.mockList) === null || _useMocks$mockList === void 0 ? void 0 : _useMocks$mockList.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
5031
|
+
uri: item.uri.replace(/(easyops\.api\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
|
|
5032
|
+
return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
|
|
5033
|
+
}).replace(/:\w+/g, "([^/]+)")
|
|
5034
|
+
}))
|
|
5035
|
+
});
|
|
5036
|
+
}
|
|
5037
|
+
function getMockList() {
|
|
5038
|
+
return mocks.mockList;
|
|
5039
|
+
}
|
|
5040
|
+
var getMockInfo = requestUrl => {
|
|
5041
|
+
var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl));
|
|
5042
|
+
|
|
5043
|
+
if (item) {
|
|
5044
|
+
return {
|
|
5045
|
+
url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
|
|
5046
|
+
return "".concat(p1, "/").concat(p3);
|
|
5047
|
+
}).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
|
|
5048
|
+
mockId: mocks.mockId
|
|
5049
|
+
};
|
|
5050
|
+
}
|
|
5051
|
+
|
|
5052
|
+
return;
|
|
5053
|
+
};
|
|
5054
|
+
|
|
5022
5055
|
var flowApiDefinitionPromiseMap = new Map(); // Legacy Custom API: `${namespace}@${name}`
|
|
5023
5056
|
// Flow API: `${namespace}@${name}:${version}`
|
|
5024
5057
|
|
|
@@ -5138,25 +5171,59 @@ function _fetchFlowApiDefinition2() {
|
|
|
5138
5171
|
_fetchFlowApiDefinition2 = _asyncToGenerator$4(function* (provider) {
|
|
5139
5172
|
var [namespaceName, nameWithVersion] = provider.split("@");
|
|
5140
5173
|
var [name, version] = nameWithVersion.split(":");
|
|
5141
|
-
var
|
|
5142
|
-
contractData
|
|
5143
|
-
} = yield ContractApi_searchSingleContract({
|
|
5144
|
-
contractName: "".concat(namespaceName, ".").concat(name),
|
|
5145
|
-
version
|
|
5146
|
-
}); // return undefined if don't found contract
|
|
5174
|
+
var isUseMock = getMockList().find(item => item.provider === "".concat(namespaceName, "@").concat(name));
|
|
5147
5175
|
|
|
5148
|
-
if (
|
|
5149
|
-
var
|
|
5176
|
+
if (isUseMock) {
|
|
5177
|
+
var _list$;
|
|
5150
5178
|
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5179
|
+
var {
|
|
5180
|
+
list
|
|
5181
|
+
} = yield InstanceApi_postSearchV3("FLOW_BUILDER_API_CONTRACT@EASYOPS", {
|
|
5182
|
+
fields: ["name", "namespaceId", "endpoint", "response", "version"],
|
|
5183
|
+
query: {
|
|
5184
|
+
namespaceId: {
|
|
5185
|
+
$eq: namespaceName
|
|
5186
|
+
},
|
|
5187
|
+
name: {
|
|
5188
|
+
$eq: name
|
|
5189
|
+
}
|
|
5158
5190
|
}
|
|
5159
|
-
};
|
|
5191
|
+
});
|
|
5192
|
+
|
|
5193
|
+
if ((_list$ = list[0]) !== null && _list$ !== void 0 && _list$.instanceId) {
|
|
5194
|
+
var _list$2;
|
|
5195
|
+
|
|
5196
|
+
return {
|
|
5197
|
+
name: list[0].name,
|
|
5198
|
+
namespace: (_list$2 = list[0]) === null || _list$2 === void 0 ? void 0 : _list$2.namespaceId,
|
|
5199
|
+
version: list[0].version,
|
|
5200
|
+
contract: {
|
|
5201
|
+
endpoint: list[0].endpoint,
|
|
5202
|
+
response: list[0].response
|
|
5203
|
+
}
|
|
5204
|
+
};
|
|
5205
|
+
}
|
|
5206
|
+
} else {
|
|
5207
|
+
var {
|
|
5208
|
+
contractData
|
|
5209
|
+
} = yield ContractApi_searchSingleContract({
|
|
5210
|
+
contractName: "".concat(namespaceName, ".").concat(name),
|
|
5211
|
+
version
|
|
5212
|
+
}); // return undefined if don't found contract
|
|
5213
|
+
|
|
5214
|
+
if (contractData) {
|
|
5215
|
+
var _contractData$namespa, _contractData$namespa2;
|
|
5216
|
+
|
|
5217
|
+
return {
|
|
5218
|
+
name: contractData.name,
|
|
5219
|
+
namespace: (_contractData$namespa = contractData.namespace) === null || _contractData$namespa === void 0 ? void 0 : (_contractData$namespa2 = _contractData$namespa[0]) === null || _contractData$namespa2 === void 0 ? void 0 : _contractData$namespa2.name,
|
|
5220
|
+
version: contractData.version,
|
|
5221
|
+
contract: {
|
|
5222
|
+
endpoint: contractData.endpoint,
|
|
5223
|
+
response: contractData.response
|
|
5224
|
+
}
|
|
5225
|
+
};
|
|
5226
|
+
}
|
|
5160
5227
|
}
|
|
5161
5228
|
});
|
|
5162
5229
|
return _fetchFlowApiDefinition2.apply(this, arguments);
|
|
@@ -6191,6 +6258,892 @@ function _standaloneBootstrap() {
|
|
|
6191
6258
|
return _standaloneBootstrap.apply(this, arguments);
|
|
6192
6259
|
}
|
|
6193
6260
|
|
|
6261
|
+
/**
|
|
6262
|
+
* Take input from [0, n] and return it as [0, 1]
|
|
6263
|
+
* @hidden
|
|
6264
|
+
*/
|
|
6265
|
+
function bound01(n, max) {
|
|
6266
|
+
if (isOnePointZero(n)) {
|
|
6267
|
+
n = '100%';
|
|
6268
|
+
}
|
|
6269
|
+
var isPercent = isPercentage(n);
|
|
6270
|
+
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
|
|
6271
|
+
// Automatically convert percentage into number
|
|
6272
|
+
if (isPercent) {
|
|
6273
|
+
n = parseInt(String(n * max), 10) / 100;
|
|
6274
|
+
}
|
|
6275
|
+
// Handle floating point rounding errors
|
|
6276
|
+
if (Math.abs(n - max) < 0.000001) {
|
|
6277
|
+
return 1;
|
|
6278
|
+
}
|
|
6279
|
+
// Convert into [0, 1] range if it isn't already
|
|
6280
|
+
if (max === 360) {
|
|
6281
|
+
// If n is a hue given in degrees,
|
|
6282
|
+
// wrap around out-of-range values into [0, 360] range
|
|
6283
|
+
// then convert into [0, 1].
|
|
6284
|
+
n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
|
|
6285
|
+
}
|
|
6286
|
+
else {
|
|
6287
|
+
// If n not a hue given in degrees
|
|
6288
|
+
// Convert into [0, 1] range if it isn't already.
|
|
6289
|
+
n = (n % max) / parseFloat(String(max));
|
|
6290
|
+
}
|
|
6291
|
+
return n;
|
|
6292
|
+
}
|
|
6293
|
+
/**
|
|
6294
|
+
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
6295
|
+
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
6296
|
+
* @hidden
|
|
6297
|
+
*/
|
|
6298
|
+
function isOnePointZero(n) {
|
|
6299
|
+
return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
|
|
6300
|
+
}
|
|
6301
|
+
/**
|
|
6302
|
+
* Check to see if string passed in is a percentage
|
|
6303
|
+
* @hidden
|
|
6304
|
+
*/
|
|
6305
|
+
function isPercentage(n) {
|
|
6306
|
+
return typeof n === 'string' && n.indexOf('%') !== -1;
|
|
6307
|
+
}
|
|
6308
|
+
/**
|
|
6309
|
+
* Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
6310
|
+
* @hidden
|
|
6311
|
+
*/
|
|
6312
|
+
function boundAlpha(a) {
|
|
6313
|
+
a = parseFloat(a);
|
|
6314
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
6315
|
+
a = 1;
|
|
6316
|
+
}
|
|
6317
|
+
return a;
|
|
6318
|
+
}
|
|
6319
|
+
/**
|
|
6320
|
+
* Replace a decimal with it's percentage value
|
|
6321
|
+
* @hidden
|
|
6322
|
+
*/
|
|
6323
|
+
function convertToPercentage(n) {
|
|
6324
|
+
if (n <= 1) {
|
|
6325
|
+
return Number(n) * 100 + "%";
|
|
6326
|
+
}
|
|
6327
|
+
return n;
|
|
6328
|
+
}
|
|
6329
|
+
/**
|
|
6330
|
+
* Force a hex value to have 2 characters
|
|
6331
|
+
* @hidden
|
|
6332
|
+
*/
|
|
6333
|
+
function pad2(c) {
|
|
6334
|
+
return c.length === 1 ? '0' + c : String(c);
|
|
6335
|
+
}
|
|
6336
|
+
|
|
6337
|
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
6338
|
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
6339
|
+
/**
|
|
6340
|
+
* Handle bounds / percentage checking to conform to CSS color spec
|
|
6341
|
+
* <http://www.w3.org/TR/css3-color/>
|
|
6342
|
+
* *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
6343
|
+
* *Returns:* { r, g, b } in [0, 255]
|
|
6344
|
+
*/
|
|
6345
|
+
function rgbToRgb(r, g, b) {
|
|
6346
|
+
return {
|
|
6347
|
+
r: bound01(r, 255) * 255,
|
|
6348
|
+
g: bound01(g, 255) * 255,
|
|
6349
|
+
b: bound01(b, 255) * 255,
|
|
6350
|
+
};
|
|
6351
|
+
}
|
|
6352
|
+
function hue2rgb(p, q, t) {
|
|
6353
|
+
if (t < 0) {
|
|
6354
|
+
t += 1;
|
|
6355
|
+
}
|
|
6356
|
+
if (t > 1) {
|
|
6357
|
+
t -= 1;
|
|
6358
|
+
}
|
|
6359
|
+
if (t < 1 / 6) {
|
|
6360
|
+
return p + (q - p) * (6 * t);
|
|
6361
|
+
}
|
|
6362
|
+
if (t < 1 / 2) {
|
|
6363
|
+
return q;
|
|
6364
|
+
}
|
|
6365
|
+
if (t < 2 / 3) {
|
|
6366
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
6367
|
+
}
|
|
6368
|
+
return p;
|
|
6369
|
+
}
|
|
6370
|
+
/**
|
|
6371
|
+
* Converts an HSL color value to RGB.
|
|
6372
|
+
*
|
|
6373
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
6374
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
6375
|
+
*/
|
|
6376
|
+
function hslToRgb(h, s, l) {
|
|
6377
|
+
var r;
|
|
6378
|
+
var g;
|
|
6379
|
+
var b;
|
|
6380
|
+
h = bound01(h, 360);
|
|
6381
|
+
s = bound01(s, 100);
|
|
6382
|
+
l = bound01(l, 100);
|
|
6383
|
+
if (s === 0) {
|
|
6384
|
+
// achromatic
|
|
6385
|
+
g = l;
|
|
6386
|
+
b = l;
|
|
6387
|
+
r = l;
|
|
6388
|
+
}
|
|
6389
|
+
else {
|
|
6390
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
6391
|
+
var p = 2 * l - q;
|
|
6392
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
6393
|
+
g = hue2rgb(p, q, h);
|
|
6394
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
6395
|
+
}
|
|
6396
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
6397
|
+
}
|
|
6398
|
+
/**
|
|
6399
|
+
* Converts an RGB color value to HSV
|
|
6400
|
+
*
|
|
6401
|
+
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
6402
|
+
* *Returns:* { h, s, v } in [0,1]
|
|
6403
|
+
*/
|
|
6404
|
+
function rgbToHsv(r, g, b) {
|
|
6405
|
+
r = bound01(r, 255);
|
|
6406
|
+
g = bound01(g, 255);
|
|
6407
|
+
b = bound01(b, 255);
|
|
6408
|
+
var max = Math.max(r, g, b);
|
|
6409
|
+
var min = Math.min(r, g, b);
|
|
6410
|
+
var h = 0;
|
|
6411
|
+
var v = max;
|
|
6412
|
+
var d = max - min;
|
|
6413
|
+
var s = max === 0 ? 0 : d / max;
|
|
6414
|
+
if (max === min) {
|
|
6415
|
+
h = 0; // achromatic
|
|
6416
|
+
}
|
|
6417
|
+
else {
|
|
6418
|
+
switch (max) {
|
|
6419
|
+
case r:
|
|
6420
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
6421
|
+
break;
|
|
6422
|
+
case g:
|
|
6423
|
+
h = (b - r) / d + 2;
|
|
6424
|
+
break;
|
|
6425
|
+
case b:
|
|
6426
|
+
h = (r - g) / d + 4;
|
|
6427
|
+
break;
|
|
6428
|
+
}
|
|
6429
|
+
h /= 6;
|
|
6430
|
+
}
|
|
6431
|
+
return { h: h, s: s, v: v };
|
|
6432
|
+
}
|
|
6433
|
+
/**
|
|
6434
|
+
* Converts an HSV color value to RGB.
|
|
6435
|
+
*
|
|
6436
|
+
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
6437
|
+
* *Returns:* { r, g, b } in the set [0, 255]
|
|
6438
|
+
*/
|
|
6439
|
+
function hsvToRgb(h, s, v) {
|
|
6440
|
+
h = bound01(h, 360) * 6;
|
|
6441
|
+
s = bound01(s, 100);
|
|
6442
|
+
v = bound01(v, 100);
|
|
6443
|
+
var i = Math.floor(h);
|
|
6444
|
+
var f = h - i;
|
|
6445
|
+
var p = v * (1 - s);
|
|
6446
|
+
var q = v * (1 - f * s);
|
|
6447
|
+
var t = v * (1 - (1 - f) * s);
|
|
6448
|
+
var mod = i % 6;
|
|
6449
|
+
var r = [v, q, p, p, t, v][mod];
|
|
6450
|
+
var g = [t, v, v, q, p, p][mod];
|
|
6451
|
+
var b = [p, p, t, v, v, q][mod];
|
|
6452
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
6453
|
+
}
|
|
6454
|
+
/**
|
|
6455
|
+
* Converts an RGB color to hex
|
|
6456
|
+
*
|
|
6457
|
+
* Assumes r, g, and b are contained in the set [0, 255]
|
|
6458
|
+
* Returns a 3 or 6 character hex
|
|
6459
|
+
*/
|
|
6460
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
6461
|
+
var hex = [
|
|
6462
|
+
pad2(Math.round(r).toString(16)),
|
|
6463
|
+
pad2(Math.round(g).toString(16)),
|
|
6464
|
+
pad2(Math.round(b).toString(16)),
|
|
6465
|
+
];
|
|
6466
|
+
// Return a 3 character hex if possible
|
|
6467
|
+
if (allow3Char &&
|
|
6468
|
+
hex[0].startsWith(hex[0].charAt(1)) &&
|
|
6469
|
+
hex[1].startsWith(hex[1].charAt(1)) &&
|
|
6470
|
+
hex[2].startsWith(hex[2].charAt(1))) {
|
|
6471
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
6472
|
+
}
|
|
6473
|
+
return hex.join('');
|
|
6474
|
+
}
|
|
6475
|
+
/** Converts a hex value to a decimal */
|
|
6476
|
+
function convertHexToDecimal(h) {
|
|
6477
|
+
return parseIntFromHex(h) / 255;
|
|
6478
|
+
}
|
|
6479
|
+
/** Parse a base-16 hex value into a base-10 integer */
|
|
6480
|
+
function parseIntFromHex(val) {
|
|
6481
|
+
return parseInt(val, 16);
|
|
6482
|
+
}
|
|
6483
|
+
|
|
6484
|
+
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
|
|
6485
|
+
/**
|
|
6486
|
+
* @hidden
|
|
6487
|
+
*/
|
|
6488
|
+
var names = {
|
|
6489
|
+
aliceblue: '#f0f8ff',
|
|
6490
|
+
antiquewhite: '#faebd7',
|
|
6491
|
+
aqua: '#00ffff',
|
|
6492
|
+
aquamarine: '#7fffd4',
|
|
6493
|
+
azure: '#f0ffff',
|
|
6494
|
+
beige: '#f5f5dc',
|
|
6495
|
+
bisque: '#ffe4c4',
|
|
6496
|
+
black: '#000000',
|
|
6497
|
+
blanchedalmond: '#ffebcd',
|
|
6498
|
+
blue: '#0000ff',
|
|
6499
|
+
blueviolet: '#8a2be2',
|
|
6500
|
+
brown: '#a52a2a',
|
|
6501
|
+
burlywood: '#deb887',
|
|
6502
|
+
cadetblue: '#5f9ea0',
|
|
6503
|
+
chartreuse: '#7fff00',
|
|
6504
|
+
chocolate: '#d2691e',
|
|
6505
|
+
coral: '#ff7f50',
|
|
6506
|
+
cornflowerblue: '#6495ed',
|
|
6507
|
+
cornsilk: '#fff8dc',
|
|
6508
|
+
crimson: '#dc143c',
|
|
6509
|
+
cyan: '#00ffff',
|
|
6510
|
+
darkblue: '#00008b',
|
|
6511
|
+
darkcyan: '#008b8b',
|
|
6512
|
+
darkgoldenrod: '#b8860b',
|
|
6513
|
+
darkgray: '#a9a9a9',
|
|
6514
|
+
darkgreen: '#006400',
|
|
6515
|
+
darkgrey: '#a9a9a9',
|
|
6516
|
+
darkkhaki: '#bdb76b',
|
|
6517
|
+
darkmagenta: '#8b008b',
|
|
6518
|
+
darkolivegreen: '#556b2f',
|
|
6519
|
+
darkorange: '#ff8c00',
|
|
6520
|
+
darkorchid: '#9932cc',
|
|
6521
|
+
darkred: '#8b0000',
|
|
6522
|
+
darksalmon: '#e9967a',
|
|
6523
|
+
darkseagreen: '#8fbc8f',
|
|
6524
|
+
darkslateblue: '#483d8b',
|
|
6525
|
+
darkslategray: '#2f4f4f',
|
|
6526
|
+
darkslategrey: '#2f4f4f',
|
|
6527
|
+
darkturquoise: '#00ced1',
|
|
6528
|
+
darkviolet: '#9400d3',
|
|
6529
|
+
deeppink: '#ff1493',
|
|
6530
|
+
deepskyblue: '#00bfff',
|
|
6531
|
+
dimgray: '#696969',
|
|
6532
|
+
dimgrey: '#696969',
|
|
6533
|
+
dodgerblue: '#1e90ff',
|
|
6534
|
+
firebrick: '#b22222',
|
|
6535
|
+
floralwhite: '#fffaf0',
|
|
6536
|
+
forestgreen: '#228b22',
|
|
6537
|
+
fuchsia: '#ff00ff',
|
|
6538
|
+
gainsboro: '#dcdcdc',
|
|
6539
|
+
ghostwhite: '#f8f8ff',
|
|
6540
|
+
goldenrod: '#daa520',
|
|
6541
|
+
gold: '#ffd700',
|
|
6542
|
+
gray: '#808080',
|
|
6543
|
+
green: '#008000',
|
|
6544
|
+
greenyellow: '#adff2f',
|
|
6545
|
+
grey: '#808080',
|
|
6546
|
+
honeydew: '#f0fff0',
|
|
6547
|
+
hotpink: '#ff69b4',
|
|
6548
|
+
indianred: '#cd5c5c',
|
|
6549
|
+
indigo: '#4b0082',
|
|
6550
|
+
ivory: '#fffff0',
|
|
6551
|
+
khaki: '#f0e68c',
|
|
6552
|
+
lavenderblush: '#fff0f5',
|
|
6553
|
+
lavender: '#e6e6fa',
|
|
6554
|
+
lawngreen: '#7cfc00',
|
|
6555
|
+
lemonchiffon: '#fffacd',
|
|
6556
|
+
lightblue: '#add8e6',
|
|
6557
|
+
lightcoral: '#f08080',
|
|
6558
|
+
lightcyan: '#e0ffff',
|
|
6559
|
+
lightgoldenrodyellow: '#fafad2',
|
|
6560
|
+
lightgray: '#d3d3d3',
|
|
6561
|
+
lightgreen: '#90ee90',
|
|
6562
|
+
lightgrey: '#d3d3d3',
|
|
6563
|
+
lightpink: '#ffb6c1',
|
|
6564
|
+
lightsalmon: '#ffa07a',
|
|
6565
|
+
lightseagreen: '#20b2aa',
|
|
6566
|
+
lightskyblue: '#87cefa',
|
|
6567
|
+
lightslategray: '#778899',
|
|
6568
|
+
lightslategrey: '#778899',
|
|
6569
|
+
lightsteelblue: '#b0c4de',
|
|
6570
|
+
lightyellow: '#ffffe0',
|
|
6571
|
+
lime: '#00ff00',
|
|
6572
|
+
limegreen: '#32cd32',
|
|
6573
|
+
linen: '#faf0e6',
|
|
6574
|
+
magenta: '#ff00ff',
|
|
6575
|
+
maroon: '#800000',
|
|
6576
|
+
mediumaquamarine: '#66cdaa',
|
|
6577
|
+
mediumblue: '#0000cd',
|
|
6578
|
+
mediumorchid: '#ba55d3',
|
|
6579
|
+
mediumpurple: '#9370db',
|
|
6580
|
+
mediumseagreen: '#3cb371',
|
|
6581
|
+
mediumslateblue: '#7b68ee',
|
|
6582
|
+
mediumspringgreen: '#00fa9a',
|
|
6583
|
+
mediumturquoise: '#48d1cc',
|
|
6584
|
+
mediumvioletred: '#c71585',
|
|
6585
|
+
midnightblue: '#191970',
|
|
6586
|
+
mintcream: '#f5fffa',
|
|
6587
|
+
mistyrose: '#ffe4e1',
|
|
6588
|
+
moccasin: '#ffe4b5',
|
|
6589
|
+
navajowhite: '#ffdead',
|
|
6590
|
+
navy: '#000080',
|
|
6591
|
+
oldlace: '#fdf5e6',
|
|
6592
|
+
olive: '#808000',
|
|
6593
|
+
olivedrab: '#6b8e23',
|
|
6594
|
+
orange: '#ffa500',
|
|
6595
|
+
orangered: '#ff4500',
|
|
6596
|
+
orchid: '#da70d6',
|
|
6597
|
+
palegoldenrod: '#eee8aa',
|
|
6598
|
+
palegreen: '#98fb98',
|
|
6599
|
+
paleturquoise: '#afeeee',
|
|
6600
|
+
palevioletred: '#db7093',
|
|
6601
|
+
papayawhip: '#ffefd5',
|
|
6602
|
+
peachpuff: '#ffdab9',
|
|
6603
|
+
peru: '#cd853f',
|
|
6604
|
+
pink: '#ffc0cb',
|
|
6605
|
+
plum: '#dda0dd',
|
|
6606
|
+
powderblue: '#b0e0e6',
|
|
6607
|
+
purple: '#800080',
|
|
6608
|
+
rebeccapurple: '#663399',
|
|
6609
|
+
red: '#ff0000',
|
|
6610
|
+
rosybrown: '#bc8f8f',
|
|
6611
|
+
royalblue: '#4169e1',
|
|
6612
|
+
saddlebrown: '#8b4513',
|
|
6613
|
+
salmon: '#fa8072',
|
|
6614
|
+
sandybrown: '#f4a460',
|
|
6615
|
+
seagreen: '#2e8b57',
|
|
6616
|
+
seashell: '#fff5ee',
|
|
6617
|
+
sienna: '#a0522d',
|
|
6618
|
+
silver: '#c0c0c0',
|
|
6619
|
+
skyblue: '#87ceeb',
|
|
6620
|
+
slateblue: '#6a5acd',
|
|
6621
|
+
slategray: '#708090',
|
|
6622
|
+
slategrey: '#708090',
|
|
6623
|
+
snow: '#fffafa',
|
|
6624
|
+
springgreen: '#00ff7f',
|
|
6625
|
+
steelblue: '#4682b4',
|
|
6626
|
+
tan: '#d2b48c',
|
|
6627
|
+
teal: '#008080',
|
|
6628
|
+
thistle: '#d8bfd8',
|
|
6629
|
+
tomato: '#ff6347',
|
|
6630
|
+
turquoise: '#40e0d0',
|
|
6631
|
+
violet: '#ee82ee',
|
|
6632
|
+
wheat: '#f5deb3',
|
|
6633
|
+
white: '#ffffff',
|
|
6634
|
+
whitesmoke: '#f5f5f5',
|
|
6635
|
+
yellow: '#ffff00',
|
|
6636
|
+
yellowgreen: '#9acd32',
|
|
6637
|
+
};
|
|
6638
|
+
|
|
6639
|
+
/**
|
|
6640
|
+
* Given a string or object, convert that input to RGB
|
|
6641
|
+
*
|
|
6642
|
+
* Possible string inputs:
|
|
6643
|
+
* ```
|
|
6644
|
+
* "red"
|
|
6645
|
+
* "#f00" or "f00"
|
|
6646
|
+
* "#ff0000" or "ff0000"
|
|
6647
|
+
* "#ff000000" or "ff000000"
|
|
6648
|
+
* "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
6649
|
+
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
6650
|
+
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
6651
|
+
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
6652
|
+
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
6653
|
+
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
6654
|
+
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
6655
|
+
* ```
|
|
6656
|
+
*/
|
|
6657
|
+
function inputToRGB(color) {
|
|
6658
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
|
6659
|
+
var a = 1;
|
|
6660
|
+
var s = null;
|
|
6661
|
+
var v = null;
|
|
6662
|
+
var l = null;
|
|
6663
|
+
var ok = false;
|
|
6664
|
+
var format = false;
|
|
6665
|
+
if (typeof color === 'string') {
|
|
6666
|
+
color = stringInputToObject(color);
|
|
6667
|
+
}
|
|
6668
|
+
if (typeof color === 'object') {
|
|
6669
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
6670
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
6671
|
+
ok = true;
|
|
6672
|
+
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
|
|
6673
|
+
}
|
|
6674
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
6675
|
+
s = convertToPercentage(color.s);
|
|
6676
|
+
v = convertToPercentage(color.v);
|
|
6677
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
6678
|
+
ok = true;
|
|
6679
|
+
format = 'hsv';
|
|
6680
|
+
}
|
|
6681
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
6682
|
+
s = convertToPercentage(color.s);
|
|
6683
|
+
l = convertToPercentage(color.l);
|
|
6684
|
+
rgb = hslToRgb(color.h, s, l);
|
|
6685
|
+
ok = true;
|
|
6686
|
+
format = 'hsl';
|
|
6687
|
+
}
|
|
6688
|
+
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
|
|
6689
|
+
a = color.a;
|
|
6690
|
+
}
|
|
6691
|
+
}
|
|
6692
|
+
a = boundAlpha(a);
|
|
6693
|
+
return {
|
|
6694
|
+
ok: ok,
|
|
6695
|
+
format: color.format || format,
|
|
6696
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
6697
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
6698
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
6699
|
+
a: a,
|
|
6700
|
+
};
|
|
6701
|
+
}
|
|
6702
|
+
// <http://www.w3.org/TR/css3-values/#integers>
|
|
6703
|
+
var CSS_INTEGER = '[-\\+]?\\d+%?';
|
|
6704
|
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
6705
|
+
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
|
6706
|
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
6707
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
6708
|
+
// Actual matching.
|
|
6709
|
+
// Parentheses and commas are optional, but not required.
|
|
6710
|
+
// Whitespace can take the place of commas or opening paren
|
|
6711
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
6712
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
6713
|
+
var matchers = {
|
|
6714
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
6715
|
+
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
|
|
6716
|
+
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
|
|
6717
|
+
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
|
|
6718
|
+
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
|
|
6719
|
+
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
|
|
6720
|
+
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
|
|
6721
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
6722
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
6723
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
6724
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
6725
|
+
};
|
|
6726
|
+
/**
|
|
6727
|
+
* Permissive string parsing. Take in a number of formats, and output an object
|
|
6728
|
+
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
6729
|
+
*/
|
|
6730
|
+
function stringInputToObject(color) {
|
|
6731
|
+
color = color.trim().toLowerCase();
|
|
6732
|
+
if (color.length === 0) {
|
|
6733
|
+
return false;
|
|
6734
|
+
}
|
|
6735
|
+
var named = false;
|
|
6736
|
+
if (names[color]) {
|
|
6737
|
+
color = names[color];
|
|
6738
|
+
named = true;
|
|
6739
|
+
}
|
|
6740
|
+
else if (color === 'transparent') {
|
|
6741
|
+
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
|
|
6742
|
+
}
|
|
6743
|
+
// Try to match string input using regular expressions.
|
|
6744
|
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
6745
|
+
// Just return an object and let the conversion functions handle that.
|
|
6746
|
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
6747
|
+
var match = matchers.rgb.exec(color);
|
|
6748
|
+
if (match) {
|
|
6749
|
+
return { r: match[1], g: match[2], b: match[3] };
|
|
6750
|
+
}
|
|
6751
|
+
match = matchers.rgba.exec(color);
|
|
6752
|
+
if (match) {
|
|
6753
|
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
6754
|
+
}
|
|
6755
|
+
match = matchers.hsl.exec(color);
|
|
6756
|
+
if (match) {
|
|
6757
|
+
return { h: match[1], s: match[2], l: match[3] };
|
|
6758
|
+
}
|
|
6759
|
+
match = matchers.hsla.exec(color);
|
|
6760
|
+
if (match) {
|
|
6761
|
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
6762
|
+
}
|
|
6763
|
+
match = matchers.hsv.exec(color);
|
|
6764
|
+
if (match) {
|
|
6765
|
+
return { h: match[1], s: match[2], v: match[3] };
|
|
6766
|
+
}
|
|
6767
|
+
match = matchers.hsva.exec(color);
|
|
6768
|
+
if (match) {
|
|
6769
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
6770
|
+
}
|
|
6771
|
+
match = matchers.hex8.exec(color);
|
|
6772
|
+
if (match) {
|
|
6773
|
+
return {
|
|
6774
|
+
r: parseIntFromHex(match[1]),
|
|
6775
|
+
g: parseIntFromHex(match[2]),
|
|
6776
|
+
b: parseIntFromHex(match[3]),
|
|
6777
|
+
a: convertHexToDecimal(match[4]),
|
|
6778
|
+
format: named ? 'name' : 'hex8',
|
|
6779
|
+
};
|
|
6780
|
+
}
|
|
6781
|
+
match = matchers.hex6.exec(color);
|
|
6782
|
+
if (match) {
|
|
6783
|
+
return {
|
|
6784
|
+
r: parseIntFromHex(match[1]),
|
|
6785
|
+
g: parseIntFromHex(match[2]),
|
|
6786
|
+
b: parseIntFromHex(match[3]),
|
|
6787
|
+
format: named ? 'name' : 'hex',
|
|
6788
|
+
};
|
|
6789
|
+
}
|
|
6790
|
+
match = matchers.hex4.exec(color);
|
|
6791
|
+
if (match) {
|
|
6792
|
+
return {
|
|
6793
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
6794
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
6795
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
6796
|
+
a: convertHexToDecimal(match[4] + match[4]),
|
|
6797
|
+
format: named ? 'name' : 'hex8',
|
|
6798
|
+
};
|
|
6799
|
+
}
|
|
6800
|
+
match = matchers.hex3.exec(color);
|
|
6801
|
+
if (match) {
|
|
6802
|
+
return {
|
|
6803
|
+
r: parseIntFromHex(match[1] + match[1]),
|
|
6804
|
+
g: parseIntFromHex(match[2] + match[2]),
|
|
6805
|
+
b: parseIntFromHex(match[3] + match[3]),
|
|
6806
|
+
format: named ? 'name' : 'hex',
|
|
6807
|
+
};
|
|
6808
|
+
}
|
|
6809
|
+
return false;
|
|
6810
|
+
}
|
|
6811
|
+
/**
|
|
6812
|
+
* Check to see if it looks like a CSS unit
|
|
6813
|
+
* (see `matchers` above for definition).
|
|
6814
|
+
*/
|
|
6815
|
+
function isValidCSSUnit(color) {
|
|
6816
|
+
return Boolean(matchers.CSS_UNIT.exec(String(color)));
|
|
6817
|
+
}
|
|
6818
|
+
|
|
6819
|
+
var hueStep = 2; // 色相阶梯
|
|
6820
|
+
|
|
6821
|
+
var saturationStep = 0.16; // 饱和度阶梯,浅色部分
|
|
6822
|
+
|
|
6823
|
+
var saturationStep2 = 0.05; // 饱和度阶梯,深色部分
|
|
6824
|
+
|
|
6825
|
+
var brightnessStep1 = 0.05; // 亮度阶梯,浅色部分
|
|
6826
|
+
|
|
6827
|
+
var brightnessStep2 = 0.15; // 亮度阶梯,深色部分
|
|
6828
|
+
|
|
6829
|
+
var lightColorCount = 5; // 浅色数量,主色上
|
|
6830
|
+
|
|
6831
|
+
var darkColorCount = 4; // 深色数量,主色下
|
|
6832
|
+
// 暗色主题颜色映射关系表
|
|
6833
|
+
|
|
6834
|
+
var darkColorMap = [{
|
|
6835
|
+
index: 7,
|
|
6836
|
+
opacity: 0.15
|
|
6837
|
+
}, {
|
|
6838
|
+
index: 6,
|
|
6839
|
+
opacity: 0.25
|
|
6840
|
+
}, {
|
|
6841
|
+
index: 5,
|
|
6842
|
+
opacity: 0.3
|
|
6843
|
+
}, {
|
|
6844
|
+
index: 5,
|
|
6845
|
+
opacity: 0.45
|
|
6846
|
+
}, {
|
|
6847
|
+
index: 5,
|
|
6848
|
+
opacity: 0.65
|
|
6849
|
+
}, {
|
|
6850
|
+
index: 5,
|
|
6851
|
+
opacity: 0.85
|
|
6852
|
+
}, {
|
|
6853
|
+
index: 4,
|
|
6854
|
+
opacity: 0.9
|
|
6855
|
+
}, {
|
|
6856
|
+
index: 3,
|
|
6857
|
+
opacity: 0.95
|
|
6858
|
+
}, {
|
|
6859
|
+
index: 2,
|
|
6860
|
+
opacity: 0.97
|
|
6861
|
+
}, {
|
|
6862
|
+
index: 1,
|
|
6863
|
+
opacity: 0.98
|
|
6864
|
+
}]; // Wrapper function ported from TinyColor.prototype.toHsv
|
|
6865
|
+
// Keep it here because of `hsv.h * 360`
|
|
6866
|
+
|
|
6867
|
+
function toHsv(_ref) {
|
|
6868
|
+
var r = _ref.r,
|
|
6869
|
+
g = _ref.g,
|
|
6870
|
+
b = _ref.b;
|
|
6871
|
+
var hsv = rgbToHsv(r, g, b);
|
|
6872
|
+
return {
|
|
6873
|
+
h: hsv.h * 360,
|
|
6874
|
+
s: hsv.s,
|
|
6875
|
+
v: hsv.v
|
|
6876
|
+
};
|
|
6877
|
+
} // Wrapper function ported from TinyColor.prototype.toHexString
|
|
6878
|
+
// Keep it here because of the prefix `#`
|
|
6879
|
+
|
|
6880
|
+
|
|
6881
|
+
function toHex(_ref2) {
|
|
6882
|
+
var r = _ref2.r,
|
|
6883
|
+
g = _ref2.g,
|
|
6884
|
+
b = _ref2.b;
|
|
6885
|
+
return "#".concat(rgbToHex(r, g, b, false));
|
|
6886
|
+
} // Wrapper function ported from TinyColor.prototype.mix, not treeshakable.
|
|
6887
|
+
// Amount in range [0, 1]
|
|
6888
|
+
// Assume color1 & color2 has no alpha, since the following src code did so.
|
|
6889
|
+
|
|
6890
|
+
|
|
6891
|
+
function mix(rgb1, rgb2, amount) {
|
|
6892
|
+
var p = amount / 100;
|
|
6893
|
+
var rgb = {
|
|
6894
|
+
r: (rgb2.r - rgb1.r) * p + rgb1.r,
|
|
6895
|
+
g: (rgb2.g - rgb1.g) * p + rgb1.g,
|
|
6896
|
+
b: (rgb2.b - rgb1.b) * p + rgb1.b
|
|
6897
|
+
};
|
|
6898
|
+
return rgb;
|
|
6899
|
+
}
|
|
6900
|
+
|
|
6901
|
+
function getHue(hsv, i, light) {
|
|
6902
|
+
var hue; // 根据色相不同,色相转向不同
|
|
6903
|
+
|
|
6904
|
+
if (Math.round(hsv.h) >= 60 && Math.round(hsv.h) <= 240) {
|
|
6905
|
+
hue = light ? Math.round(hsv.h) - hueStep * i : Math.round(hsv.h) + hueStep * i;
|
|
6906
|
+
} else {
|
|
6907
|
+
hue = light ? Math.round(hsv.h) + hueStep * i : Math.round(hsv.h) - hueStep * i;
|
|
6908
|
+
}
|
|
6909
|
+
|
|
6910
|
+
if (hue < 0) {
|
|
6911
|
+
hue += 360;
|
|
6912
|
+
} else if (hue >= 360) {
|
|
6913
|
+
hue -= 360;
|
|
6914
|
+
}
|
|
6915
|
+
|
|
6916
|
+
return hue;
|
|
6917
|
+
}
|
|
6918
|
+
|
|
6919
|
+
function getSaturation(hsv, i, light) {
|
|
6920
|
+
// grey color don't change saturation
|
|
6921
|
+
if (hsv.h === 0 && hsv.s === 0) {
|
|
6922
|
+
return hsv.s;
|
|
6923
|
+
}
|
|
6924
|
+
|
|
6925
|
+
var saturation;
|
|
6926
|
+
|
|
6927
|
+
if (light) {
|
|
6928
|
+
saturation = hsv.s - saturationStep * i;
|
|
6929
|
+
} else if (i === darkColorCount) {
|
|
6930
|
+
saturation = hsv.s + saturationStep;
|
|
6931
|
+
} else {
|
|
6932
|
+
saturation = hsv.s + saturationStep2 * i;
|
|
6933
|
+
} // 边界值修正
|
|
6934
|
+
|
|
6935
|
+
|
|
6936
|
+
if (saturation > 1) {
|
|
6937
|
+
saturation = 1;
|
|
6938
|
+
} // 第一格的 s 限制在 0.06-0.1 之间
|
|
6939
|
+
|
|
6940
|
+
|
|
6941
|
+
if (light && i === lightColorCount && saturation > 0.1) {
|
|
6942
|
+
saturation = 0.1;
|
|
6943
|
+
}
|
|
6944
|
+
|
|
6945
|
+
if (saturation < 0.06) {
|
|
6946
|
+
saturation = 0.06;
|
|
6947
|
+
}
|
|
6948
|
+
|
|
6949
|
+
return Number(saturation.toFixed(2));
|
|
6950
|
+
}
|
|
6951
|
+
|
|
6952
|
+
function getValue(hsv, i, light) {
|
|
6953
|
+
var value;
|
|
6954
|
+
|
|
6955
|
+
if (light) {
|
|
6956
|
+
value = hsv.v + brightnessStep1 * i;
|
|
6957
|
+
} else {
|
|
6958
|
+
value = hsv.v - brightnessStep2 * i;
|
|
6959
|
+
}
|
|
6960
|
+
|
|
6961
|
+
if (value > 1) {
|
|
6962
|
+
value = 1;
|
|
6963
|
+
}
|
|
6964
|
+
|
|
6965
|
+
return Number(value.toFixed(2));
|
|
6966
|
+
}
|
|
6967
|
+
|
|
6968
|
+
function generate(color) {
|
|
6969
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
6970
|
+
var patterns = [];
|
|
6971
|
+
var pColor = inputToRGB(color);
|
|
6972
|
+
|
|
6973
|
+
for (var i = lightColorCount; i > 0; i -= 1) {
|
|
6974
|
+
var hsv = toHsv(pColor);
|
|
6975
|
+
var colorString = toHex(inputToRGB({
|
|
6976
|
+
h: getHue(hsv, i, true),
|
|
6977
|
+
s: getSaturation(hsv, i, true),
|
|
6978
|
+
v: getValue(hsv, i, true)
|
|
6979
|
+
}));
|
|
6980
|
+
patterns.push(colorString);
|
|
6981
|
+
}
|
|
6982
|
+
|
|
6983
|
+
patterns.push(toHex(pColor));
|
|
6984
|
+
|
|
6985
|
+
for (var _i = 1; _i <= darkColorCount; _i += 1) {
|
|
6986
|
+
var _hsv = toHsv(pColor);
|
|
6987
|
+
|
|
6988
|
+
var _colorString = toHex(inputToRGB({
|
|
6989
|
+
h: getHue(_hsv, _i),
|
|
6990
|
+
s: getSaturation(_hsv, _i),
|
|
6991
|
+
v: getValue(_hsv, _i)
|
|
6992
|
+
}));
|
|
6993
|
+
|
|
6994
|
+
patterns.push(_colorString);
|
|
6995
|
+
} // dark theme patterns
|
|
6996
|
+
|
|
6997
|
+
|
|
6998
|
+
if (opts.theme === 'dark') {
|
|
6999
|
+
return darkColorMap.map(function (_ref3) {
|
|
7000
|
+
var index = _ref3.index,
|
|
7001
|
+
opacity = _ref3.opacity;
|
|
7002
|
+
var darkColorString = toHex(mix(inputToRGB(opts.backgroundColor || '#141414'), inputToRGB(patterns[index]), opacity * 100));
|
|
7003
|
+
return darkColorString;
|
|
7004
|
+
});
|
|
7005
|
+
}
|
|
7006
|
+
|
|
7007
|
+
return patterns;
|
|
7008
|
+
}
|
|
7009
|
+
|
|
7010
|
+
var presetPrimaryColors = {
|
|
7011
|
+
red: '#F5222D',
|
|
7012
|
+
volcano: '#FA541C',
|
|
7013
|
+
orange: '#FA8C16',
|
|
7014
|
+
gold: '#FAAD14',
|
|
7015
|
+
yellow: '#FADB14',
|
|
7016
|
+
lime: '#A0D911',
|
|
7017
|
+
green: '#52C41A',
|
|
7018
|
+
cyan: '#13C2C2',
|
|
7019
|
+
blue: '#1890FF',
|
|
7020
|
+
geekblue: '#2F54EB',
|
|
7021
|
+
purple: '#722ED1',
|
|
7022
|
+
magenta: '#EB2F96',
|
|
7023
|
+
grey: '#666666'
|
|
7024
|
+
};
|
|
7025
|
+
var presetPalettes = {};
|
|
7026
|
+
var presetDarkPalettes = {};
|
|
7027
|
+
Object.keys(presetPrimaryColors).forEach(function (key) {
|
|
7028
|
+
presetPalettes[key] = generate(presetPrimaryColors[key]);
|
|
7029
|
+
presetPalettes[key].primary = presetPalettes[key][5]; // dark presetPalettes
|
|
7030
|
+
|
|
7031
|
+
presetDarkPalettes[key] = generate(presetPrimaryColors[key], {
|
|
7032
|
+
theme: 'dark',
|
|
7033
|
+
backgroundColor: '#141414'
|
|
7034
|
+
});
|
|
7035
|
+
presetDarkPalettes[key].primary = presetDarkPalettes[key][5];
|
|
7036
|
+
});
|
|
7037
|
+
presetPalettes.red;
|
|
7038
|
+
presetPalettes.volcano;
|
|
7039
|
+
presetPalettes.gold;
|
|
7040
|
+
presetPalettes.orange;
|
|
7041
|
+
presetPalettes.yellow;
|
|
7042
|
+
presetPalettes.lime;
|
|
7043
|
+
presetPalettes.green;
|
|
7044
|
+
presetPalettes.cyan;
|
|
7045
|
+
presetPalettes.blue;
|
|
7046
|
+
presetPalettes.geekblue;
|
|
7047
|
+
presetPalettes.purple;
|
|
7048
|
+
presetPalettes.magenta;
|
|
7049
|
+
presetPalettes.grey;
|
|
7050
|
+
|
|
7051
|
+
function getStyleByBaseColors(theme, baseColors, backgroundColor) {
|
|
7052
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByPalettes(generatePalettes(baseColors, theme, backgroundColor)));
|
|
7053
|
+
}
|
|
7054
|
+
function getStyleByBrandColor(theme, brandColor) {
|
|
7055
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByBrand(brandColor));
|
|
7056
|
+
}
|
|
7057
|
+
function getStyleByVariables(theme, variables) {
|
|
7058
|
+
return (theme === "dark" ? getDarkStyle : getLightStyle)(getCssVariableDefinitionsByVariables(variables));
|
|
7059
|
+
}
|
|
7060
|
+
|
|
7061
|
+
function getLightStyle(cssVariableDefinitions) {
|
|
7062
|
+
return ":root,\n[data-override-theme=\"light\"] {\n".concat(cssVariableDefinitions, "}");
|
|
7063
|
+
}
|
|
7064
|
+
|
|
7065
|
+
function getDarkStyle(cssVariableDefinitions) {
|
|
7066
|
+
return "html[data-theme=\"dark-v2\"],\n[data-override-theme=\"dark-v2\"] {\n".concat(cssVariableDefinitions, "}");
|
|
7067
|
+
}
|
|
7068
|
+
|
|
7069
|
+
function getCssVariableDefinitionsByPalettes(palettes) {
|
|
7070
|
+
return Object.entries(palettes).flatMap(_ref => {
|
|
7071
|
+
var [colorName, palette] = _ref;
|
|
7072
|
+
ensureBaseColorName(colorName);
|
|
7073
|
+
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.
|
|
7074
|
+
.concat("");
|
|
7075
|
+
}).join("\n");
|
|
7076
|
+
}
|
|
7077
|
+
|
|
7078
|
+
function generatePalettes(baseColors, theme, backgroundColor) {
|
|
7079
|
+
return Object.fromEntries(Object.entries(baseColors).map(_ref2 => {
|
|
7080
|
+
var [colorName, baseColor] = _ref2;
|
|
7081
|
+
return [colorName, generate(baseColor, theme === "dark" ? {
|
|
7082
|
+
theme,
|
|
7083
|
+
backgroundColor
|
|
7084
|
+
} : undefined)];
|
|
7085
|
+
}));
|
|
7086
|
+
}
|
|
7087
|
+
|
|
7088
|
+
function getCssVariableDefinitionsByBrand(color) {
|
|
7089
|
+
if (typeof color === "string") {
|
|
7090
|
+
return " --color-brand: ".concat(color, ";\n");
|
|
7091
|
+
}
|
|
7092
|
+
|
|
7093
|
+
return [" --color-brand: ".concat(color.default, ";"), " --color-brand-hover: ".concat(color.hover, ";"), " --color-brand-active: ".concat(color.active, ";"), ""].join("\n");
|
|
7094
|
+
}
|
|
7095
|
+
|
|
7096
|
+
function getCssVariableDefinitionsByVariables(variables) {
|
|
7097
|
+
return Object.entries(variables).map(_ref3 => {
|
|
7098
|
+
var [name, color] = _ref3;
|
|
7099
|
+
ensureCssVariableName(name);
|
|
7100
|
+
return " ".concat(name, ": ").concat(color, ";");
|
|
7101
|
+
}).concat("").join("\n");
|
|
7102
|
+
}
|
|
7103
|
+
|
|
7104
|
+
function ensureCssVariableName(name) {
|
|
7105
|
+
if (!/^--[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(name)) {
|
|
7106
|
+
throw new Error("Invalid css variable name: ".concat(JSON.stringify(name)));
|
|
7107
|
+
}
|
|
7108
|
+
}
|
|
7109
|
+
|
|
7110
|
+
function ensureBaseColorName(name) {
|
|
7111
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) {
|
|
7112
|
+
throw new Error("Invalid base color name: ".concat(JSON.stringify(name)));
|
|
7113
|
+
}
|
|
7114
|
+
}
|
|
7115
|
+
|
|
7116
|
+
function applyColorTheme(options) {
|
|
7117
|
+
var style = [];
|
|
7118
|
+
var themes = ["light", "dark"];
|
|
7119
|
+
themes.forEach(theme => {
|
|
7120
|
+
if (options[theme]) {
|
|
7121
|
+
switch (options.type) {
|
|
7122
|
+
case "brandColor":
|
|
7123
|
+
style.push(getStyleByBrandColor(theme, options[theme]));
|
|
7124
|
+
break;
|
|
7125
|
+
|
|
7126
|
+
case "baseColors":
|
|
7127
|
+
style.push(getStyleByBaseColors(theme, options[theme], options.backgroundColor));
|
|
7128
|
+
break;
|
|
7129
|
+
|
|
7130
|
+
case "variables":
|
|
7131
|
+
style.push(getStyleByVariables(theme, options[theme]));
|
|
7132
|
+
break;
|
|
7133
|
+
}
|
|
7134
|
+
}
|
|
7135
|
+
});
|
|
7136
|
+
|
|
7137
|
+
if (style.length > 0) {
|
|
7138
|
+
var element = document.createElement("style");
|
|
7139
|
+
element.textContent = style.join("\n\n");
|
|
7140
|
+
document.head.appendChild(element);
|
|
7141
|
+
return () => {
|
|
7142
|
+
element.remove();
|
|
7143
|
+
};
|
|
7144
|
+
}
|
|
7145
|
+
}
|
|
7146
|
+
|
|
6194
7147
|
class Kernel {
|
|
6195
7148
|
constructor() {
|
|
6196
7149
|
_defineProperty$1(this, "mountPoints", void 0);
|
|
@@ -6240,6 +7193,8 @@ class Kernel {
|
|
|
6240
7193
|
var _this = this;
|
|
6241
7194
|
|
|
6242
7195
|
return _asyncToGenerator$4(function* () {
|
|
7196
|
+
var _this$bootstrapData$s, _this$bootstrapData$s2;
|
|
7197
|
+
|
|
6243
7198
|
_this.mountPoints = mountPoints;
|
|
6244
7199
|
yield Promise.all([_this.loadCheckLogin(), _this.loadMicroApps()]);
|
|
6245
7200
|
|
|
@@ -6247,6 +7202,8 @@ class Kernel {
|
|
|
6247
7202
|
throw new Error("No storyboard were found.");
|
|
6248
7203
|
}
|
|
6249
7204
|
|
|
7205
|
+
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);
|
|
7206
|
+
|
|
6250
7207
|
if (isLoggedIn()) {
|
|
6251
7208
|
_this.loadSharedData();
|
|
6252
7209
|
}
|
|
@@ -6801,9 +7758,9 @@ class Kernel {
|
|
|
6801
7758
|
}
|
|
6802
7759
|
|
|
6803
7760
|
getFeatureFlags() {
|
|
6804
|
-
var _this$bootstrapData, _this$bootstrapData$
|
|
7761
|
+
var _this$bootstrapData, _this$bootstrapData$s3;
|
|
6805
7762
|
|
|
6806
|
-
return Object.assign({}, (_this$bootstrapData = this.bootstrapData) === null || _this$bootstrapData === void 0 ? void 0 : (_this$bootstrapData$
|
|
7763
|
+
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
7764
|
}
|
|
6808
7765
|
|
|
6809
7766
|
getStandaloneMenus(menuId) {
|
|
@@ -6872,6 +7829,24 @@ function loadScriptOfBricksOrTemplates(src) {
|
|
|
6872
7829
|
return loadScript(src, window.PUBLIC_ROOT);
|
|
6873
7830
|
}
|
|
6874
7831
|
|
|
7832
|
+
function generateColorTheme(theme) {
|
|
7833
|
+
if (!theme) {
|
|
7834
|
+
return;
|
|
7835
|
+
} else if (theme.brandColor) {
|
|
7836
|
+
applyColorTheme(_objectSpread({
|
|
7837
|
+
type: "brandColor"
|
|
7838
|
+
}, theme.brandColor));
|
|
7839
|
+
} else if (theme.baseColors) {
|
|
7840
|
+
applyColorTheme(_objectSpread({
|
|
7841
|
+
type: "baseColors"
|
|
7842
|
+
}, theme.baseColors));
|
|
7843
|
+
} else if (theme.variables) {
|
|
7844
|
+
applyColorTheme(_objectSpread({
|
|
7845
|
+
type: "variables"
|
|
7846
|
+
}, theme.variables));
|
|
7847
|
+
}
|
|
7848
|
+
}
|
|
7849
|
+
|
|
6875
7850
|
/*! (c) Andrea Giammarchi - ISC */
|
|
6876
7851
|
var self = {};
|
|
6877
7852
|
|
|
@@ -9177,36 +10152,6 @@ function shouldBeDefaultCollapsed(defaultCollapsed, defaultCollapsedBreakpoint)
|
|
|
9177
10152
|
return defaultCollapsed || defaultCollapsedBreakpoint && document.documentElement.clientWidth < defaultCollapsedBreakpoint;
|
|
9178
10153
|
}
|
|
9179
10154
|
|
|
9180
|
-
var mocks = {
|
|
9181
|
-
mockId: null,
|
|
9182
|
-
mockList: []
|
|
9183
|
-
};
|
|
9184
|
-
function registerMock(useMocks) {
|
|
9185
|
-
var _useMocks$mockList;
|
|
9186
|
-
|
|
9187
|
-
if (useMocks) mocks = _objectSpread(_objectSpread({}, useMocks), {}, {
|
|
9188
|
-
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\.)(.+?)\/(.+)/, (_match, p1, p2, p3) => {
|
|
9190
|
-
return "(".concat(p1, ")?").concat(p2, "(@\\d+\\.\\d+\\.\\d+)?/").concat(p3, "$");
|
|
9191
|
-
}).replace(/:\w+/g, "([^/]+)")
|
|
9192
|
-
}))
|
|
9193
|
-
});
|
|
9194
|
-
}
|
|
9195
|
-
var getMockInfo = requestUrl => {
|
|
9196
|
-
var item = mocks.mockList.find(item => new RegExp(item.uri).test(requestUrl));
|
|
9197
|
-
|
|
9198
|
-
if (item) {
|
|
9199
|
-
return {
|
|
9200
|
-
url: requestUrl.replace(/(api\/gateway\/.+?)(@\d+\.\d+\.\d+)?\/(.+)/, (_match, p1, _p2, p3) => {
|
|
9201
|
-
return "".concat(p1, "/").concat(p3);
|
|
9202
|
-
}).replace(/(api\/gateway)/, "api/gateway/mock_server.proxy.".concat(mocks.mockId)),
|
|
9203
|
-
mockId: mocks.mockId
|
|
9204
|
-
};
|
|
9205
|
-
}
|
|
9206
|
-
|
|
9207
|
-
return;
|
|
9208
|
-
};
|
|
9209
|
-
|
|
9210
10155
|
class Router {
|
|
9211
10156
|
constructor(kernel) {
|
|
9212
10157
|
_defineProperty$1(this, "defaultCollapsed", false);
|
|
@@ -9372,7 +10317,7 @@ class Router {
|
|
|
9372
10317
|
var _this3 = this;
|
|
9373
10318
|
|
|
9374
10319
|
return _asyncToGenerator$4(function* () {
|
|
9375
|
-
var _apiAnalyzer$getInsta;
|
|
10320
|
+
var _apiAnalyzer$getInsta, _currentApp$theme;
|
|
9376
10321
|
|
|
9377
10322
|
_this3.state = "initial";
|
|
9378
10323
|
_this3.renderId = uniqueId("render-id-");
|
|
@@ -9423,6 +10368,8 @@ class Router {
|
|
|
9423
10368
|
var legacy = currentApp ? currentApp.legacy : undefined;
|
|
9424
10369
|
_this3.kernel.nextApp = currentApp;
|
|
9425
10370
|
var layoutType = (currentApp === null || currentApp === void 0 ? void 0 : currentApp.layoutType) || "console";
|
|
10371
|
+
setTheme((_currentApp$theme = currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
|
|
10372
|
+
setMode("default");
|
|
9426
10373
|
devtoolsHookEmit("rendering");
|
|
9427
10374
|
unmountTree(mountPoints.bg);
|
|
9428
10375
|
|
|
@@ -9433,7 +10380,7 @@ class Router {
|
|
|
9433
10380
|
};
|
|
9434
10381
|
|
|
9435
10382
|
if (storyboard) {
|
|
9436
|
-
var _currentApp$breadcrum, _currentApp$breadcrum2
|
|
10383
|
+
var _currentApp$breadcrum, _currentApp$breadcrum2;
|
|
9437
10384
|
|
|
9438
10385
|
if (appChanged && currentApp.id && isLoggedIn()) {
|
|
9439
10386
|
var usedCustomApis = mapCustomApisToNameAndNamespace(scanCustomApisInStoryboard(storyboard));
|
|
@@ -9530,10 +10477,8 @@ class Router {
|
|
|
9530
10477
|
_this3.kernel.unsetBars({
|
|
9531
10478
|
appChanged,
|
|
9532
10479
|
legacy: actualLegacy
|
|
9533
|
-
});
|
|
10480
|
+
}); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
|
|
9534
10481
|
|
|
9535
|
-
setTheme((_currentApp$theme = currentApp.theme) !== null && _currentApp$theme !== void 0 ? _currentApp$theme : "light");
|
|
9536
|
-
setMode("default"); // There is a window to set theme and mode by `lifeCycle.onBeforePageLoad`.
|
|
9537
10482
|
|
|
9538
10483
|
_this3.locationContext.handleBeforePageLoad();
|
|
9539
10484
|
|