@arcblock/ux 2.9.3 → 2.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/DID/index.js +3 -4
- package/es/Util/index.js +13 -0
- package/lib/DID/index.js +1 -2
- package/lib/Util/index.js +16 -1
- package/package.json +4 -4
- package/src/DID/index.jsx +3 -13
- package/src/Util/index.js +23 -0
package/es/DID/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { getDIDMotifInfo
|
|
3
|
+
import { getDIDMotifInfo } from '@arcblock/did-motif';
|
|
4
4
|
import Address from '../Address';
|
|
5
5
|
import Avatar from '../Avatar';
|
|
6
|
-
import { isEthereumDid, getFontSize } from '../Util';
|
|
6
|
+
import { isEthereumDid, getFontSize, getDIDColor } from '../Util';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
const DIDPropTypes = {
|
|
9
9
|
did: PropTypes.string.isRequired,
|
|
@@ -21,8 +21,7 @@ const DIDPropTypes = {
|
|
|
21
21
|
};
|
|
22
22
|
const getFontColor = (did, didMotifInfo, isEthDid) => {
|
|
23
23
|
if (isEthDid) {
|
|
24
|
-
|
|
25
|
-
return colors[index];
|
|
24
|
+
return getDIDColor(did);
|
|
26
25
|
}
|
|
27
26
|
return didMotifInfo.color;
|
|
28
27
|
};
|
package/es/Util/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-bitwise */
|
|
2
2
|
import padStart from 'lodash/padStart';
|
|
3
|
+
import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
|
|
3
4
|
let dateTool = null;
|
|
4
5
|
export function parseQuery(str) {
|
|
5
6
|
return str.replace(/^\?/, '').split('&').map(x => x.split('=')).filter(([key]) => !!key).reduce((memo, x) => {
|
|
@@ -316,4 +317,16 @@ export const setVisitorId = value => {
|
|
|
316
317
|
} else {
|
|
317
318
|
localStorage.setItem(visitorIdKey, value);
|
|
318
319
|
}
|
|
320
|
+
};
|
|
321
|
+
export const getDIDColor = did => {
|
|
322
|
+
if (isEthereumDid(did)) {
|
|
323
|
+
const index = Uint8Array.from(did.slice(2).match(/.{1,2}/g).map(pair => parseInt(pair, 16))).slice(0, 8).reduce((acc, val) => acc + val, 0) % colors.length;
|
|
324
|
+
return colors[index];
|
|
325
|
+
}
|
|
326
|
+
try {
|
|
327
|
+
const didMotifInfo = getDIDMotifInfo(did);
|
|
328
|
+
return didMotifInfo?.color;
|
|
329
|
+
} catch {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
319
332
|
};
|
package/lib/DID/index.js
CHANGED
|
@@ -38,8 +38,7 @@ const DIDPropTypes = {
|
|
|
38
38
|
};
|
|
39
39
|
const getFontColor = (did, didMotifInfo, isEthDid) => {
|
|
40
40
|
if (isEthDid) {
|
|
41
|
-
|
|
42
|
-
return _didMotif.colors[index];
|
|
41
|
+
return (0, _Util.getDIDColor)(did);
|
|
43
42
|
}
|
|
44
43
|
return didMotifInfo.color;
|
|
45
44
|
};
|
package/lib/Util/index.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.formatToDatetime = formatToDatetime;
|
|
|
10
10
|
exports.getColor = exports.getBackground = exports.formatUptime = void 0;
|
|
11
11
|
exports.getCookieOptions = getCookieOptions;
|
|
12
12
|
exports.getCopyright = getCopyright;
|
|
13
|
+
exports.getDIDColor = void 0;
|
|
13
14
|
exports.getDateTool = getDateTool;
|
|
14
15
|
exports.isUrl = exports.isEthereumDid = exports.getVisitorId = exports.getUserAvatar = exports.getTimezone = exports.getFontSize = void 0;
|
|
15
16
|
exports.mergeProps = mergeProps;
|
|
@@ -19,6 +20,7 @@ exports.setDateTool = setDateTool;
|
|
|
19
20
|
exports.str2color = exports.sleep = exports.setVisitorId = void 0;
|
|
20
21
|
exports.stringifyQuery = stringifyQuery;
|
|
21
22
|
var _padStart = _interopRequireDefault(require("lodash/padStart"));
|
|
23
|
+
var _didMotif = require("@arcblock/did-motif");
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
/* eslint-disable no-bitwise */
|
|
24
26
|
|
|
@@ -365,4 +367,17 @@ const setVisitorId = value => {
|
|
|
365
367
|
localStorage.setItem(visitorIdKey, value);
|
|
366
368
|
}
|
|
367
369
|
};
|
|
368
|
-
exports.setVisitorId = setVisitorId;
|
|
370
|
+
exports.setVisitorId = setVisitorId;
|
|
371
|
+
const getDIDColor = did => {
|
|
372
|
+
if (isEthereumDid(did)) {
|
|
373
|
+
const index = Uint8Array.from(did.slice(2).match(/.{1,2}/g).map(pair => parseInt(pair, 16))).slice(0, 8).reduce((acc, val) => acc + val, 0) % _didMotif.colors.length;
|
|
374
|
+
return _didMotif.colors[index];
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
const didMotifInfo = (0, _didMotif.getDIDMotifInfo)(did);
|
|
378
|
+
return didMotifInfo === null || didMotifInfo === void 0 ? void 0 : didMotifInfo.color;
|
|
379
|
+
} catch (_unused2) {
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
exports.getDIDColor = getDIDColor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.5",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -340,11 +340,11 @@
|
|
|
340
340
|
"peerDependencies": {
|
|
341
341
|
"react": ">=18.1.0"
|
|
342
342
|
},
|
|
343
|
-
"gitHead": "
|
|
343
|
+
"gitHead": "3905a2012e1aab17ab95cdf30d561bcd9f439bfe",
|
|
344
344
|
"dependencies": {
|
|
345
345
|
"@arcblock/did-motif": "^1.1.13",
|
|
346
|
-
"@arcblock/icons": "^2.9.
|
|
347
|
-
"@arcblock/react-hooks": "^2.9.
|
|
346
|
+
"@arcblock/icons": "^2.9.5",
|
|
347
|
+
"@arcblock/react-hooks": "^2.9.5",
|
|
348
348
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
349
349
|
"@emotion/react": "^11.10.4",
|
|
350
350
|
"@emotion/styled": "^11.10.4",
|
package/src/DID/index.jsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { getDIDMotifInfo
|
|
3
|
+
import { getDIDMotifInfo } from '@arcblock/did-motif';
|
|
4
4
|
|
|
5
5
|
import Address from '../Address';
|
|
6
6
|
import Avatar from '../Avatar';
|
|
7
7
|
|
|
8
|
-
import { isEthereumDid, getFontSize } from '../Util';
|
|
8
|
+
import { isEthereumDid, getFontSize, getDIDColor } from '../Util';
|
|
9
9
|
|
|
10
10
|
const DIDPropTypes = {
|
|
11
11
|
did: PropTypes.string.isRequired,
|
|
@@ -24,17 +24,7 @@ const DIDPropTypes = {
|
|
|
24
24
|
|
|
25
25
|
const getFontColor = (did, didMotifInfo, isEthDid) => {
|
|
26
26
|
if (isEthDid) {
|
|
27
|
-
|
|
28
|
-
Uint8Array.from(
|
|
29
|
-
did
|
|
30
|
-
.slice(2)
|
|
31
|
-
.match(/.{1,2}/g)
|
|
32
|
-
.map((pair) => parseInt(pair, 16))
|
|
33
|
-
)
|
|
34
|
-
.slice(0, 8)
|
|
35
|
-
.reduce((acc, val) => acc + val, 0) % colors.length;
|
|
36
|
-
|
|
37
|
-
return colors[index];
|
|
27
|
+
return getDIDColor(did);
|
|
38
28
|
}
|
|
39
29
|
|
|
40
30
|
return didMotifInfo.color;
|
package/src/Util/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-bitwise */
|
|
2
2
|
import padStart from 'lodash/padStart';
|
|
3
|
+
import { getDIDMotifInfo, colors } from '@arcblock/did-motif';
|
|
3
4
|
|
|
4
5
|
let dateTool = null;
|
|
5
6
|
|
|
@@ -349,3 +350,25 @@ export const setVisitorId = (value) => {
|
|
|
349
350
|
localStorage.setItem(visitorIdKey, value);
|
|
350
351
|
}
|
|
351
352
|
};
|
|
353
|
+
|
|
354
|
+
export const getDIDColor = (did) => {
|
|
355
|
+
if (isEthereumDid(did)) {
|
|
356
|
+
const index =
|
|
357
|
+
Uint8Array.from(
|
|
358
|
+
did
|
|
359
|
+
.slice(2)
|
|
360
|
+
.match(/.{1,2}/g)
|
|
361
|
+
.map((pair) => parseInt(pair, 16))
|
|
362
|
+
)
|
|
363
|
+
.slice(0, 8)
|
|
364
|
+
.reduce((acc, val) => acc + val, 0) % colors.length;
|
|
365
|
+
|
|
366
|
+
return colors[index];
|
|
367
|
+
}
|
|
368
|
+
try {
|
|
369
|
+
const didMotifInfo = getDIDMotifInfo(did);
|
|
370
|
+
return didMotifInfo?.color;
|
|
371
|
+
} catch {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
};
|