@metamask-previews/design-system-react 0.3.0-preview.022dda1 → 0.3.1-preview.374d60e
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 +9 -1
- package/dist/components/temp-components/Blockies/Blockies.cjs +4 -1
- package/dist/components/temp-components/Blockies/Blockies.cjs.map +1 -1
- package/dist/components/temp-components/Blockies/Blockies.d.cts.map +1 -1
- package/dist/components/temp-components/Blockies/Blockies.d.mts.map +1 -1
- package/dist/components/temp-components/Blockies/Blockies.mjs +4 -1
- package/dist/components/temp-components/Blockies/Blockies.mjs.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.cjs +35 -46
- package/dist/components/temp-components/Jazzicon/Jazzicon.cjs.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.d.cts.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.d.mts.map +1 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.mjs +35 -46
- package/dist/components/temp-components/Jazzicon/Jazzicon.mjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.cjs +14 -6
- package/dist/components/temp-components/Maskicon/Maskicon.cjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.d.cts +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.d.cts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.d.mts +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.d.mts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.mjs +15 -7
- package/dist/components/temp-components/Maskicon/Maskicon.mjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.cjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.d.cts +6 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.d.cts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.d.mts +6 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.d.mts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.types.mjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.cjs +6 -81
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.cjs.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.d.cts +0 -26
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.d.cts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.d.mts +0 -26
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.d.mts.map +1 -1
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.mjs +5 -77
- package/dist/components/temp-components/Maskicon/Maskicon.utilities.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.cjs +0 -67
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.cjs.map +0 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.cts +0 -24
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.cts.map +0 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.mts +0 -24
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.d.mts.map +0 -1
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.mjs +0 -61
- package/dist/components/temp-components/Jazzicon/Jazzicon.utilities.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.1]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Removed DOMPurify dependency from Maskicon component ([#812](https://github.com/MetaMask/metamask-design-system/pull/812))
|
|
15
|
+
- Aligned React peer dependencies with MetaMask extension React 17 ([#809](https://github.com/MetaMask/metamask-design-system/pull/809))
|
|
16
|
+
|
|
10
17
|
## [0.3.0]
|
|
11
18
|
|
|
12
19
|
### Added
|
|
@@ -62,7 +69,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
62
69
|
- Full TypeScript support with type definitions and enums
|
|
63
70
|
- Tailwind CSS integration with design token support
|
|
64
71
|
|
|
65
|
-
[Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.3.
|
|
72
|
+
[Unreleased]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.3.1...HEAD
|
|
73
|
+
[0.3.1]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.3.0...@metamask/design-system-react@0.3.1
|
|
66
74
|
[0.3.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.2.0...@metamask/design-system-react@0.3.0
|
|
67
75
|
[0.2.0]: https://github.com/MetaMask/metamask-design-system/compare/@metamask/design-system-react@0.1.0...@metamask/design-system-react@0.2.0
|
|
68
76
|
[0.1.0]: https://github.com/MetaMask/metamask-design-system/releases/tag/@metamask/design-system-react@0.1.0
|
|
@@ -4,10 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Blockies = void 0;
|
|
7
|
+
const design_system_shared_1 = require("@metamask-previews/design-system-shared");
|
|
7
8
|
const blo_1 = require("blo");
|
|
8
9
|
const react_1 = __importDefault(require("react"));
|
|
9
10
|
const Blockies = ({ address, size = 32, ...props }) => {
|
|
10
|
-
|
|
11
|
+
// Extract the account address from CAIP-10 format if needed
|
|
12
|
+
const accountAddress = (0, design_system_shared_1.extractAccountAddress)(address);
|
|
13
|
+
return (react_1.default.createElement("img", { src: (0, blo_1.blo)(accountAddress), height: size, width: size, alt: `Blockies for ${address}`, ...props }));
|
|
11
14
|
};
|
|
12
15
|
exports.Blockies = Blockies;
|
|
13
16
|
exports.Blockies.displayName = 'Blockies';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockies.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Blockies/Blockies.tsx"],"names":[],"mappings":";;;;;;AAAA,6BAA0B;AAC1B,kDAA0B;AAInB,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,KAAK,EAAiB,EAAE,EAAE;IAC1E,OAAO,CACL,uCACE,GAAG,EAAE,IAAA,SAAG,EAAC,
|
|
1
|
+
{"version":3,"file":"Blockies.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Blockies/Blockies.tsx"],"names":[],"mappings":";;;;;;AAAA,kFAAgF;AAChF,6BAA0B;AAC1B,kDAA0B;AAInB,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,KAAK,EAAiB,EAAE,EAAE;IAC1E,4DAA4D;IAC5D,MAAM,cAAc,GAAG,IAAA,4CAAqB,EAAC,OAAO,CAAC,CAAC;IAEtD,OAAO,CACL,uCACE,GAAG,EAAE,IAAA,SAAG,EAAC,cAA+B,CAAC,EACzC,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,IAAI,EACX,GAAG,EAAE,gBAAgB,OAAO,EAAE,KAC1B,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,QAAQ,YAanB;AAEF,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import { extractAccountAddress } from '@metamask-previews/design-system-shared';\nimport { blo } from 'blo';\nimport React from 'react';\n\nimport type { BlockiesProps } from './Blockies.types';\n\nexport const Blockies = ({ address, size = 32, ...props }: BlockiesProps) => {\n // Extract the account address from CAIP-10 format if needed\n const accountAddress = extractAccountAddress(address);\n\n return (\n <img\n src={blo(accountAddress as `0x${string}`)}\n height={size}\n width={size}\n alt={`Blockies for ${address}`} // TODO: Add localization for this\n {...props}\n />\n );\n};\n\nBlockies.displayName = 'Blockies';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockies.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Blockies/Blockies.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Blockies.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Blockies/Blockies.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,cAAc;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAEtD,eAAO,MAAM,QAAQ;kCAAsC,aAAa;;CAavE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockies.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Blockies/Blockies.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Blockies.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Blockies/Blockies.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,cAAc;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAEtD,eAAO,MAAM,QAAQ;kCAAsC,aAAa;;CAavE,CAAC"}
|
|
@@ -4,11 +4,14 @@ function $importDefault(module) {
|
|
|
4
4
|
}
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
|
+
import { extractAccountAddress } from "@metamask-previews/design-system-shared";
|
|
7
8
|
import { blo } from "blo";
|
|
8
9
|
import $React from "react";
|
|
9
10
|
const React = $importDefault($React);
|
|
10
11
|
export const Blockies = ({ address, size = 32, ...props }) => {
|
|
11
|
-
|
|
12
|
+
// Extract the account address from CAIP-10 format if needed
|
|
13
|
+
const accountAddress = extractAccountAddress(address);
|
|
14
|
+
return (React.createElement("img", { src: blo(accountAddress), height: size, width: size, alt: `Blockies for ${address}`, ...props }));
|
|
12
15
|
};
|
|
13
16
|
Blockies.displayName = 'Blockies';
|
|
14
17
|
//# sourceMappingURL=Blockies.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Blockies.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Blockies/Blockies.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,YAAY;AAC1B,OAAO,MAAK,cAAc;;AAI1B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,KAAK,EAAiB,EAAE,EAAE;IAC1E,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"Blockies.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Blockies/Blockies.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,qBAAqB,EAAE,gDAAgD;AAChF,OAAO,EAAE,GAAG,EAAE,YAAY;AAC1B,OAAO,MAAK,cAAc;;AAI1B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,KAAK,EAAiB,EAAE,EAAE;IAC1E,4DAA4D;IAC5D,MAAM,cAAc,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAEtD,OAAO,CACL,6BACE,GAAG,EAAE,GAAG,CAAC,cAA+B,CAAC,EACzC,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,IAAI,EACX,GAAG,EAAE,gBAAgB,OAAO,EAAE,KAC1B,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import { extractAccountAddress } from '@metamask-previews/design-system-shared';\nimport { blo } from 'blo';\nimport React from 'react';\n\nimport type { BlockiesProps } from './Blockies.types';\n\nexport const Blockies = ({ address, size = 32, ...props }: BlockiesProps) => {\n // Extract the account address from CAIP-10 format if needed\n const accountAddress = extractAccountAddress(address);\n\n return (\n <img\n src={blo(accountAddress as `0x${string}`)}\n height={size}\n width={size}\n alt={`Blockies for ${address}`} // TODO: Add localization for this\n {...props}\n />\n );\n};\n\nBlockies.displayName = 'Blockies';\n"]}
|
|
@@ -27,11 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Jazzicon = void 0;
|
|
30
|
+
const design_system_shared_1 = require("@metamask-previews/design-system-shared");
|
|
30
31
|
const jazzicon_1 = __importDefault(require("@metamask/jazzicon"));
|
|
31
|
-
const utils_1 = require("@metamask/utils");
|
|
32
32
|
const react_1 = __importStar(require("react"));
|
|
33
33
|
const tw_merge_1 = require("../../../utils/tw-merge.cjs");
|
|
34
|
-
const Jazzicon_utilities_1 = require("./Jazzicon.utilities.cjs");
|
|
35
34
|
/**
|
|
36
35
|
* Cache for storing generated SVG elements by `address:diameter` so
|
|
37
36
|
* we don't regenerate them repeatedly.
|
|
@@ -40,53 +39,43 @@ const iconCache = {};
|
|
|
40
39
|
const Jazzicon = ({ address, size = 32, className, ...props }) => {
|
|
41
40
|
const containerRef = (0, react_1.useRef)(null);
|
|
42
41
|
(0, react_1.useEffect)(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
if (!containerRef.current) {
|
|
43
|
+
return () => {
|
|
44
|
+
// No cleanup needed if container ref was null
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Clear any existing content
|
|
48
|
+
while (containerRef.current.firstChild) {
|
|
49
|
+
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
50
|
+
}
|
|
51
|
+
// Check the cache
|
|
52
|
+
const cacheKey = `${address.toLowerCase()}:${size}`;
|
|
53
|
+
if (iconCache[cacheKey]) {
|
|
54
|
+
// If cached, just append a clone
|
|
55
|
+
const clone = iconCache[cacheKey].cloneNode(true);
|
|
56
|
+
containerRef.current.appendChild(clone);
|
|
57
|
+
return () => {
|
|
58
|
+
if (containerRef.current) {
|
|
59
|
+
while (containerRef.current.firstChild) {
|
|
60
|
+
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
// Create Jazzicon
|
|
76
|
-
const newIcon = (0, jazzicon_1.default)(size, seed);
|
|
77
|
-
// Cache it
|
|
78
|
-
iconCache[cacheKey] = newIcon;
|
|
79
|
-
// Append a fresh clone
|
|
80
|
-
if (!isCancelled && containerRef.current) {
|
|
81
|
-
containerRef.current.appendChild(newIcon.cloneNode(true));
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
generateJazzicon().catch(() => {
|
|
85
|
-
// Silently ignore errors during async generation
|
|
86
|
-
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Extract the account address from CAIP-10 format if needed
|
|
66
|
+
const accountAddress = (0, design_system_shared_1.extractAccountAddress)(address);
|
|
67
|
+
// Generate appropriate seed based on address format
|
|
68
|
+
const seed = (0, design_system_shared_1.generateIconSeed)(accountAddress);
|
|
69
|
+
// Create Jazzicon
|
|
70
|
+
const newIcon = (0, jazzicon_1.default)(size, seed);
|
|
71
|
+
// Cache it
|
|
72
|
+
iconCache[cacheKey] = newIcon;
|
|
73
|
+
// Append a fresh clone
|
|
74
|
+
if (containerRef.current) {
|
|
75
|
+
containerRef.current.appendChild(newIcon.cloneNode(true));
|
|
76
|
+
}
|
|
87
77
|
// Cleanup
|
|
88
78
|
return () => {
|
|
89
|
-
isCancelled = true;
|
|
90
79
|
if (containerRef.current) {
|
|
91
80
|
while (containerRef.current.firstChild) {
|
|
92
81
|
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAC1C
|
|
1
|
+
{"version":3,"file":"Jazzicon.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kFAGiD;AACjD,kEAA0C;AAC1C,+CAAiD;AAEjD,0DAAkD;AAIlD;;;GAGG;AACH,MAAM,SAAS,GAAmC,EAAE,CAAC;AAE9C,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,SAAS,EACT,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,YAAY,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAElD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YACzB,OAAO,GAAG,EAAE;gBACV,8CAA8C;YAChD,CAAC,CAAC;SACH;QAED,6BAA6B;QAC7B,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE;YACtC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SACnE;QAED,kBAAkB;QAClB,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC;QACpD,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE;YACvB,iCAAiC;YACjC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,IAAI,CAAmB,CAAC;YACpE,YAAY,CAAC,OAAO,CAAC,W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","sourcesContent":["import {\n extractAccountAddress,\n generateIconSeed,\n} from '@metamask-previews/design-system-shared';\nimport jazzicon from '@metamask/jazzicon';\nimport React, { useEffect, useRef } from 'react';\n\nimport { twMerge } from '../../../utils/tw-merge';\n\nimport type { JazziconProps } from './Jazzicon.types';\n\n/**\n * Cache for storing generated SVG elements by `address:diameter` so\n * we don't regenerate them repeatedly.\n */\nconst iconCache: Record<string, HTMLDivElement> = {};\n\nexport const Jazzicon = ({\n address,\n size = 32,\n className,\n ...props\n}: JazziconProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!containerRef.current) {\n return () => {\n // No cleanup needed if container ref was null\n };\n }\n\n // Clear any existing content\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n\n // Check the cache\n const cacheKey = `${address.toLowerCase()}:${size}`;\n if (iconCache[cacheKey]) {\n // If cached, just append a clone\n const clone = iconCache[cacheKey].cloneNode(true) as HTMLDivElement;\n containerRef.current.appendChild(clone);\n return () => {\n if (containerRef.current) {\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n }\n };\n }\n\n // Extract the account address from CAIP-10 format if needed\n const accountAddress = extractAccountAddress(address);\n\n // Generate appropriate seed based on address format\n const seed = generateIconSeed(accountAddress);\n\n // Create Jazzicon\n const newIcon = jazzicon(size, seed) as HTMLDivElement;\n\n // Cache it\n iconCache[cacheKey] = newIcon as HTMLDivElement;\n\n // Append a fresh clone\n if (containerRef.current) {\n containerRef.current.appendChild(newIcon.cloneNode(true));\n }\n\n // Cleanup\n return () => {\n if (containerRef.current) {\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n }\n };\n }, [address, size]);\n\n return (\n <div\n ref={containerRef}\n className={twMerge('flex [&>div]:!rounded-none', className)}\n {...props}\n />\n );\n};\n\nJazzicon.displayName = 'Jazzicon';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Jazzicon.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4B,cAAc;AAIjD,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAQtD,eAAO,MAAM,QAAQ;6CAKlB,aAAa;;CAgEf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Jazzicon.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4B,cAAc;AAIjD,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAQtD,eAAO,MAAM,QAAQ;6CAKlB,aAAa;;CAgEf,CAAC"}
|
|
@@ -4,13 +4,12 @@ function $importDefault(module) {
|
|
|
4
4
|
}
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
|
+
import { extractAccountAddress, generateIconSeed } from "@metamask-previews/design-system-shared";
|
|
7
8
|
import $jazzicon from "@metamask/jazzicon";
|
|
8
9
|
const jazzicon = $importDefault($jazzicon);
|
|
9
|
-
import { KnownCaipNamespace } from "@metamask/utils";
|
|
10
10
|
import $React, { useEffect, useRef } from "react";
|
|
11
11
|
const React = $importDefault($React);
|
|
12
12
|
import { twMerge } from "../../../utils/tw-merge.mjs";
|
|
13
|
-
import { generateSeedEthereum, generateSeedNonEthereum, getCaipNamespaceFromAddress } from "./Jazzicon.utilities.mjs";
|
|
14
13
|
/**
|
|
15
14
|
* Cache for storing generated SVG elements by `address:diameter` so
|
|
16
15
|
* we don't regenerate them repeatedly.
|
|
@@ -19,53 +18,43 @@ const iconCache = {};
|
|
|
19
18
|
export const Jazzicon = ({ address, size = 32, className, ...props }) => {
|
|
20
19
|
const containerRef = useRef(null);
|
|
21
20
|
useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
if (!containerRef.current) {
|
|
22
|
+
return () => {
|
|
23
|
+
// No cleanup needed if container ref was null
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// Clear any existing content
|
|
27
|
+
while (containerRef.current.firstChild) {
|
|
28
|
+
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
29
|
+
}
|
|
30
|
+
// Check the cache
|
|
31
|
+
const cacheKey = `${address.toLowerCase()}:${size}`;
|
|
32
|
+
if (iconCache[cacheKey]) {
|
|
33
|
+
// If cached, just append a clone
|
|
34
|
+
const clone = iconCache[cacheKey].cloneNode(true);
|
|
35
|
+
containerRef.current.appendChild(clone);
|
|
36
|
+
return () => {
|
|
37
|
+
if (containerRef.current) {
|
|
38
|
+
while (containerRef.current.firstChild) {
|
|
39
|
+
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
40
|
+
}
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
// Create Jazzicon
|
|
55
|
-
const newIcon = jazzicon(size, seed);
|
|
56
|
-
// Cache it
|
|
57
|
-
iconCache[cacheKey] = newIcon;
|
|
58
|
-
// Append a fresh clone
|
|
59
|
-
if (!isCancelled && containerRef.current) {
|
|
60
|
-
containerRef.current.appendChild(newIcon.cloneNode(true));
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
generateJazzicon().catch(() => {
|
|
64
|
-
// Silently ignore errors during async generation
|
|
65
|
-
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
// Extract the account address from CAIP-10 format if needed
|
|
45
|
+
const accountAddress = extractAccountAddress(address);
|
|
46
|
+
// Generate appropriate seed based on address format
|
|
47
|
+
const seed = generateIconSeed(accountAddress);
|
|
48
|
+
// Create Jazzicon
|
|
49
|
+
const newIcon = jazzicon(size, seed);
|
|
50
|
+
// Cache it
|
|
51
|
+
iconCache[cacheKey] = newIcon;
|
|
52
|
+
// Append a fresh clone
|
|
53
|
+
if (containerRef.current) {
|
|
54
|
+
containerRef.current.appendChild(newIcon.cloneNode(true));
|
|
55
|
+
}
|
|
66
56
|
// Cleanup
|
|
67
57
|
return () => {
|
|
68
|
-
isCancelled = true;
|
|
69
58
|
if (containerRef.current) {
|
|
70
59
|
while (containerRef.current.firstChild) {
|
|
71
60
|
containerRef.current.removeChild(containerRef.current.firstChild);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Jazzicon.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Jazzicon.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Jazzicon/Jazzicon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EACjB,gDAAgD;AACjD,OAAO,SAAQ,2BAA2B;;AAC1C,OAAO,QAAO,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc;;AAEjD,OAAO,EAAE,OAAO,EAAE,oCAAgC;AAIlD;;;GAGG;AACH,MAAM,SAAS,GAAmC,EAAE,CAAC;AAErD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,G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B,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3D;QAED,UAAU;QACV,OAAO,GAAG,EAAE;YACV,IAAI,YAAY,CAAC,OAAO,EAAE;gBACxB,OAAO,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE;oBACtC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;iBACnE;aACF;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpB,OAAO,CACL,6BACE,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,OAAO,CAAC,4BAA4B,EAAE,SAAS,CAAC,KACvD,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import {\n extractAccountAddress,\n generateIconSeed,\n} from '@metamask-previews/design-system-shared';\nimport jazzicon from '@metamask/jazzicon';\nimport React, { useEffect, useRef } from 'react';\n\nimport { twMerge } from '../../../utils/tw-merge';\n\nimport type { JazziconProps } from './Jazzicon.types';\n\n/**\n * Cache for storing generated SVG elements by `address:diameter` so\n * we don't regenerate them repeatedly.\n */\nconst iconCache: Record<string, HTMLDivElement> = {};\n\nexport const Jazzicon = ({\n address,\n size = 32,\n className,\n ...props\n}: JazziconProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (!containerRef.current) {\n return () => {\n // No cleanup needed if container ref was null\n };\n }\n\n // Clear any existing content\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n\n // Check the cache\n const cacheKey = `${address.toLowerCase()}:${size}`;\n if (iconCache[cacheKey]) {\n // If cached, just append a clone\n const clone = iconCache[cacheKey].cloneNode(true) as HTMLDivElement;\n containerRef.current.appendChild(clone);\n return () => {\n if (containerRef.current) {\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n }\n };\n }\n\n // Extract the account address from CAIP-10 format if needed\n const accountAddress = extractAccountAddress(address);\n\n // Generate appropriate seed based on address format\n const seed = generateIconSeed(accountAddress);\n\n // Create Jazzicon\n const newIcon = jazzicon(size, seed) as HTMLDivElement;\n\n // Cache it\n iconCache[cacheKey] = newIcon as HTMLDivElement;\n\n // Append a fresh clone\n if (containerRef.current) {\n containerRef.current.appendChild(newIcon.cloneNode(true));\n }\n\n // Cleanup\n return () => {\n if (containerRef.current) {\n while (containerRef.current.firstChild) {\n containerRef.current.removeChild(containerRef.current.firstChild);\n }\n }\n };\n }, [address, size]);\n\n return (\n <div\n ref={containerRef}\n className={twMerge('flex [&>div]:!rounded-none', className)}\n {...props}\n />\n );\n};\n\nJazzicon.displayName = 'Jazzicon';\n"]}
|
|
@@ -24,11 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Maskicon = void 0;
|
|
27
|
-
const dompurify = __importStar(require("dompurify"));
|
|
28
27
|
const react_1 = __importStar(require("react"));
|
|
29
28
|
const Maskicon_utilities_1 = require("./Maskicon.utilities.cjs");
|
|
30
|
-
const
|
|
31
|
-
const Maskicon = ({ address, size = 32, style, ...props }) => {
|
|
29
|
+
const Maskicon = ({ address, size = 32, className, ...props }) => {
|
|
32
30
|
const [svgString, setSvgString] = (0, react_1.useState)('');
|
|
33
31
|
(0, react_1.useEffect)(() => {
|
|
34
32
|
let cancelled = false;
|
|
@@ -43,10 +41,20 @@ const Maskicon = ({ address, size = 32, style, ...props }) => {
|
|
|
43
41
|
cancelled = true;
|
|
44
42
|
};
|
|
45
43
|
}, [address, size]);
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const dataUri = (0, react_1.useMemo)(() => {
|
|
45
|
+
if (!svgString) {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
// Normalize whitespace and encode the SVG for safe data URI usage
|
|
49
|
+
const cleanedSvg = svgString.replace(/\s+/gu, ' ').trim();
|
|
50
|
+
const encoded = encodeURIComponent(cleanedSvg);
|
|
51
|
+
return `data:image/svg+xml,${encoded}`;
|
|
52
|
+
}, [svgString]);
|
|
53
|
+
if (!dataUri) {
|
|
54
|
+
// Return an img element with transparent placeholder to maintain consistent typing
|
|
55
|
+
return (react_1.default.createElement("img", { alt: "maskicon", width: size, height: size, className: className, src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E", ...props }));
|
|
48
56
|
}
|
|
49
|
-
return (react_1.default.createElement("
|
|
57
|
+
return (react_1.default.createElement("img", { alt: "maskicon", width: size, height: size, className: className, src: dataUri, ...props }));
|
|
50
58
|
};
|
|
51
59
|
exports.Maskicon = Maskicon;
|
|
52
60
|
exports.Maskicon.displayName = 'Maskicon';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"Maskicon.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA4D;AAG5D,iEAAsD;AAE/C,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,SAAS,EACT,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAC;IAE/C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,mCAAmC;QACnC,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,MAAM,GAAG,MAAM,IAAA,mCAAc,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACnD,IAAI,CAAC,SAAS,EAAE;gBACd,YAAY,CAAC,MAAM,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAEpB,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC3B,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,EAAE,CAAC;SACX;QACD,kEAAkE;QAClE,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC/C,OAAO,sBAAsB,OAAO,EAAE,CAAC;IACzC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,IAAI,CAAC,OAAO,EAAE;QACZ,mFAAmF;QACnF,OAAO,CACL,uCACE,GAAG,EAAC,UAAU,EACd,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,SAAS,EACpB,GAAG,EAAC,kEAAkE,KAClE,KAAK,GACT,CACH,CAAC;KACH;IAED,OAAO,CACL,uCACE,GAAG,EAAC,UAAU,EACd,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,OAAO,KACR,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAxDW,QAAA,QAAQ,YAwDnB;AAEF,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\n\nimport type { MaskiconProps } from './Maskicon.types';\nimport { getMaskiconSVG } from './Maskicon.utilities';\n\nexport const Maskicon = ({\n address,\n size = 32,\n className,\n ...props\n}: MaskiconProps) => {\n const [svgString, setSvgString] = useState('');\n\n useEffect(() => {\n let cancelled = false;\n // eslint-disable-next-line no-void\n void (async () => {\n const newSvg = await getMaskiconSVG(address, size);\n if (!cancelled) {\n setSvgString(newSvg);\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [address, size]);\n\n const dataUri = useMemo(() => {\n if (!svgString) {\n return '';\n }\n // Normalize whitespace and encode the SVG for safe data URI usage\n const cleanedSvg = svgString.replace(/\\s+/gu, ' ').trim();\n const encoded = encodeURIComponent(cleanedSvg);\n return `data:image/svg+xml,${encoded}`;\n }, [svgString]);\n\n if (!dataUri) {\n // Return an img element with transparent placeholder to maintain consistent typing\n return (\n <img\n alt=\"maskicon\"\n width={size}\n height={size}\n className={className}\n src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E\"\n {...props}\n />\n );\n }\n\n return (\n <img\n alt=\"maskicon\"\n width={size}\n height={size}\n className={className}\n src={dataUri}\n {...props}\n />\n );\n};\n\nMaskicon.displayName = 'Maskicon';\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { MaskiconProps } from "./Maskicon.types.cjs";
|
|
3
3
|
export declare const Maskicon: {
|
|
4
|
-
({ address, size,
|
|
4
|
+
({ address, size, className, ...props }: MaskiconProps): React.JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=Maskicon.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Maskicon.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,cAAc;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAGtD,eAAO,MAAM,QAAQ;6CAKlB,aAAa;;CAmDf,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { MaskiconProps } from "./Maskicon.types.mjs";
|
|
3
3
|
export declare const Maskicon: {
|
|
4
|
-
({ address, size,
|
|
4
|
+
({ address, size, className, ...props }: MaskiconProps): React.JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=Maskicon.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Maskicon.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,cAAc;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAGtD,eAAO,MAAM,QAAQ;6CAKlB,aAAa;;CAmDf,CAAC"}
|
|
@@ -4,12 +4,10 @@ function $importDefault(module) {
|
|
|
4
4
|
}
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
|
-
import
|
|
8
|
-
import $React, { useEffect, useState } from "react";
|
|
7
|
+
import $React, { useEffect, useMemo, useState } from "react";
|
|
9
8
|
const React = $importDefault($React);
|
|
10
9
|
import { getMaskiconSVG } from "./Maskicon.utilities.mjs";
|
|
11
|
-
const
|
|
12
|
-
export const Maskicon = ({ address, size = 32, style, ...props }) => {
|
|
10
|
+
export const Maskicon = ({ address, size = 32, className, ...props }) => {
|
|
13
11
|
const [svgString, setSvgString] = useState('');
|
|
14
12
|
useEffect(() => {
|
|
15
13
|
let cancelled = false;
|
|
@@ -24,10 +22,20 @@ export const Maskicon = ({ address, size = 32, style, ...props }) => {
|
|
|
24
22
|
cancelled = true;
|
|
25
23
|
};
|
|
26
24
|
}, [address, size]);
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const dataUri = useMemo(() => {
|
|
26
|
+
if (!svgString) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
// Normalize whitespace and encode the SVG for safe data URI usage
|
|
30
|
+
const cleanedSvg = svgString.replace(/\s+/gu, ' ').trim();
|
|
31
|
+
const encoded = encodeURIComponent(cleanedSvg);
|
|
32
|
+
return `data:image/svg+xml,${encoded}`;
|
|
33
|
+
}, [svgString]);
|
|
34
|
+
if (!dataUri) {
|
|
35
|
+
// Return an img element with transparent placeholder to maintain consistent typing
|
|
36
|
+
return (React.createElement("img", { alt: "maskicon", width: size, height: size, className: className, src: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E", ...props }));
|
|
29
37
|
}
|
|
30
|
-
return (React.createElement("
|
|
38
|
+
return (React.createElement("img", { alt: "maskicon", width: size, height: size, className: className, src: dataUri, ...props }));
|
|
31
39
|
};
|
|
32
40
|
Maskicon.displayName = 'Maskicon';
|
|
33
41
|
//# sourceMappingURL=Maskicon.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Maskicon.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,QAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc;;AAG5D,OAAO,EAAE,cAAc,EAAE,iCAA6B;AAEtD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,SAAS,EACT,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,CAAC,SAAS,EA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F,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import React, { useEffect, useMemo, useState } from 'react';\n\nimport type { MaskiconProps } from './Maskicon.types';\nimport { getMaskiconSVG } from './Maskicon.utilities';\n\nexport const Maskicon = ({\n address,\n size = 32,\n className,\n ...props\n}: MaskiconProps) => {\n const [svgString, setSvgString] = useState('');\n\n useEffect(() => {\n let cancelled = false;\n // eslint-disable-next-line no-void\n void (async () => {\n const newSvg = await getMaskiconSVG(address, size);\n if (!cancelled) {\n setSvgString(newSvg);\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [address, size]);\n\n const dataUri = useMemo(() => {\n if (!svgString) {\n return '';\n }\n // Normalize whitespace and encode the SVG for safe data URI usage\n const cleanedSvg = svgString.replace(/\\s+/gu, ' ').trim();\n const encoded = encodeURIComponent(cleanedSvg);\n return `data:image/svg+xml,${encoded}`;\n }, [svgString]);\n\n if (!dataUri) {\n // Return an img element with transparent placeholder to maintain consistent typing\n return (\n <img\n alt=\"maskicon\"\n width={size}\n height={size}\n className={className}\n src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E\"\n {...props}\n />\n );\n }\n\n return (\n <img\n alt=\"maskicon\"\n width={size}\n height={size}\n className={className}\n src={dataUri}\n {...props}\n />\n );\n};\n\nMaskicon.displayName = 'Maskicon';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.types.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\n/**\n * Maskicon component props.\n */\nexport type MaskiconProps = ComponentProps<'
|
|
1
|
+
{"version":3,"file":"Maskicon.types.cjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\n/**\n * Maskicon component props.\n */\nexport type MaskiconProps = Omit<ComponentProps<'img'>, 'width' | 'height'> & {\n /**\n * Required address used as a unique identifier to generate the Maskicon.\n */\n address: string;\n /**\n * Optional prop to control the size of the Maskicon.\n * This will set both width and height.\n */\n size?: number;\n /**\n * Optional CSS class name to apply to the Maskicon.\n */\n className?: string;\n /**\n * Optional prop to add a test id to the icon\n */\n 'data-testid'?: string;\n};\n"]}
|
|
@@ -2,15 +2,20 @@ import type { ComponentProps } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* Maskicon component props.
|
|
4
4
|
*/
|
|
5
|
-
export type MaskiconProps = ComponentProps<'
|
|
5
|
+
export type MaskiconProps = Omit<ComponentProps<'img'>, 'width' | 'height'> & {
|
|
6
6
|
/**
|
|
7
7
|
* Required address used as a unique identifier to generate the Maskicon.
|
|
8
8
|
*/
|
|
9
9
|
address: string;
|
|
10
10
|
/**
|
|
11
11
|
* Optional prop to control the size of the Maskicon.
|
|
12
|
+
* This will set both width and height.
|
|
12
13
|
*/
|
|
13
14
|
size?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Optional CSS class name to apply to the Maskicon.
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
14
19
|
/**
|
|
15
20
|
* Optional prop to add a test id to the icon
|
|
16
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.types.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"Maskicon.types.d.cts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,GAAG;IAC5E;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
|
@@ -2,15 +2,20 @@ import type { ComponentProps } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* Maskicon component props.
|
|
4
4
|
*/
|
|
5
|
-
export type MaskiconProps = ComponentProps<'
|
|
5
|
+
export type MaskiconProps = Omit<ComponentProps<'img'>, 'width' | 'height'> & {
|
|
6
6
|
/**
|
|
7
7
|
* Required address used as a unique identifier to generate the Maskicon.
|
|
8
8
|
*/
|
|
9
9
|
address: string;
|
|
10
10
|
/**
|
|
11
11
|
* Optional prop to control the size of the Maskicon.
|
|
12
|
+
* This will set both width and height.
|
|
12
13
|
*/
|
|
13
14
|
size?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Optional CSS class name to apply to the Maskicon.
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
14
19
|
/**
|
|
15
20
|
* Optional prop to add a test id to the icon
|
|
16
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.types.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"Maskicon.types.d.mts","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,GAAG;IAC5E;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Maskicon.types.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\n/**\n * Maskicon component props.\n */\nexport type MaskiconProps = ComponentProps<'
|
|
1
|
+
{"version":3,"file":"Maskicon.types.mjs","sourceRoot":"","sources":["../../../../src/components/temp-components/Maskicon/Maskicon.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps } from 'react';\n\n/**\n * Maskicon component props.\n */\nexport type MaskiconProps = Omit<ComponentProps<'img'>, 'width' | 'height'> & {\n /**\n * Required address used as a unique identifier to generate the Maskicon.\n */\n address: string;\n /**\n * Optional prop to control the size of the Maskicon.\n * This will set both width and height.\n */\n size?: number;\n /**\n * Optional CSS class name to apply to the Maskicon.\n */\n className?: string;\n /**\n * Optional prop to add a test id to the icon\n */\n 'data-testid'?: string;\n};\n"]}
|