@metamask-previews/design-system-react 0.3.0-preview.022dda1 → 0.3.1-preview.1775c68

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 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.0...HEAD
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
@@ -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 DOMPurify = dompurify.default;
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
- if (!svgString) {
47
- return react_1.default.createElement("div", { style: { width: size, height: size, ...style }, ...props });
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("div", { style: { width: size, height: size, ...style }, dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(svgString) }, ...props }));
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,qDAAuC;AACvC,+CAAmD;AAGnD,iEAAsD;AAEtD,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC;AAE7B,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,KAAK,EACL,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,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,uCAAK,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,KAAM,KAAK,GAAI,CAAC;KAC3E;IAED,OAAO,CACL,uCACE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAC9C,uBAAuB,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAC9D,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAjCW,QAAA,QAAQ,YAiCnB;AAEF,gBAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import * as dompurify from 'dompurify';\nimport React, { useEffect, useState } from 'react';\n\nimport type { MaskiconProps } from './Maskicon.types';\nimport { getMaskiconSVG } from './Maskicon.utilities';\n\nconst DOMPurify = dompurify.default;\n\nexport const Maskicon = ({\n address,\n size = 32,\n style,\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 if (!svgString) {\n return <div style={{ width: size, height: size, ...style }} {...props} />;\n }\n\n return (\n <div\n style={{ width: size, height: size, ...style }}\n dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(svgString) }}\n {...props}\n />\n );\n};\n\nMaskicon.displayName = 'Maskicon';\n"]}
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, style, ...props }: MaskiconProps): React.JSX.Element;
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":"AACA,OAAO,KAA8B,cAAc;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAKtD,eAAO,MAAM,QAAQ;yCAKlB,aAAa;;CA4Bf,CAAC"}
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, style, ...props }: MaskiconProps): React.JSX.Element;
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":"AACA,OAAO,KAA8B,cAAc;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,6BAAyB;AAKtD,eAAO,MAAM,QAAQ;yCAKlB,aAAa;;CA4Bf,CAAC"}
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 * as dompurify from "dompurify";
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 DOMPurify = dompurify.default;
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
- if (!svgString) {
28
- return React.createElement("div", { style: { width: size, height: size, ...style }, ...props });
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("div", { style: { width: size, height: size, ...style }, dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(svgString) }, ...props }));
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,KAAK,SAAS,kBAAkB;AACvC,OAAO,QAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc;;AAGnD,OAAO,EAAE,cAAc,EAAE,iCAA6B;AAEtD,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,EACP,IAAI,GAAG,EAAE,EACT,KAAK,EACL,GAAG,KAAK,EACM,EAAE,EAAE;IAClB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE/C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,mCAAmC;QACnC,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,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,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,6BAAK,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,KAAM,KAAK,GAAI,CAAC;KAC3E;IAED,OAAO,CACL,6BACE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAC9C,uBAAuB,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAC9D,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC","sourcesContent":["import * as dompurify from 'dompurify';\nimport React, { useEffect, useState } from 'react';\n\nimport type { MaskiconProps } from './Maskicon.types';\nimport { getMaskiconSVG } from './Maskicon.utilities';\n\nconst DOMPurify = dompurify.default;\n\nexport const Maskicon = ({\n address,\n size = 32,\n style,\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 if (!svgString) {\n return <div style={{ width: size, height: size, ...style }} {...props} />;\n }\n\n return (\n <div\n style={{ width: size, height: size, ...style }}\n dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(svgString) }}\n {...props}\n />\n );\n};\n\nMaskicon.displayName = 'Maskicon';\n"]}
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,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE/C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,mCAAmC;QACnC,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,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,OAAO,CAAC,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,6BACE,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,6BACE,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;AAEF,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<'div'> & {\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 */\n size?: number;\n /**\n * Optional prop to add a test id to the icon\n */\n 'data-testid'?: string;\n};\n"]}
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<'div'> & {
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;IAClD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
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<'div'> & {
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;IAClD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
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<'div'> & {\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 */\n size?: number;\n /**\n * Optional prop to add a test id to the icon\n */\n 'data-testid'?: string;\n};\n"]}
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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/design-system-react",
3
- "version": "0.3.0-preview.022dda1",
3
+ "version": "0.3.1-preview.1775c68",
4
4
  "description": "Design system react ui components",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -53,13 +53,12 @@
53
53
  "@metamask/jazzicon": "^2.0.0",
54
54
  "@radix-ui/react-slot": "^1.1.0",
55
55
  "blo": "^2.0.0",
56
- "dompurify": "^3.2.5",
57
56
  "tailwind-merge": "^2.0.0"
58
57
  },
59
58
  "devDependencies": {
60
59
  "@figma/code-connect": "^1.0.0",
61
60
  "@jest/globals": "^29.7.0",
62
- "@metamask-previews/design-system-tailwind-preset": "0.6.1-preview.022dda1",
61
+ "@metamask-previews/design-system-tailwind-preset": "0.6.1-preview.1775c68",
63
62
  "@metamask/auto-changelog": "^5.0.2",
64
63
  "@metamask/utils": "^11.4.2",
65
64
  "@solana/addresses": "^2.0.0",