@metamask-previews/design-system-react 0.28.0-preview.55a2d71 → 0.28.0-preview.ba3ace4e

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.
Files changed (59) hide show
  1. package/dist/components/BannerAlert/BannerAlert.cjs +1 -4
  2. package/dist/components/BannerAlert/BannerAlert.cjs.map +1 -1
  3. package/dist/components/BannerAlert/BannerAlert.constants.cjs +4 -7
  4. package/dist/components/BannerAlert/BannerAlert.constants.cjs.map +1 -1
  5. package/dist/components/BannerAlert/BannerAlert.constants.d.cts +1 -2
  6. package/dist/components/BannerAlert/BannerAlert.constants.d.cts.map +1 -1
  7. package/dist/components/BannerAlert/BannerAlert.constants.d.mts +1 -2
  8. package/dist/components/BannerAlert/BannerAlert.constants.d.mts.map +1 -1
  9. package/dist/components/BannerAlert/BannerAlert.constants.mjs +4 -7
  10. package/dist/components/BannerAlert/BannerAlert.constants.mjs.map +1 -1
  11. package/dist/components/BannerAlert/BannerAlert.d.cts.map +1 -1
  12. package/dist/components/BannerAlert/BannerAlert.d.mts.map +1 -1
  13. package/dist/components/BannerAlert/BannerAlert.mjs +2 -5
  14. package/dist/components/BannerAlert/BannerAlert.mjs.map +1 -1
  15. package/dist/components/BannerBase/BannerBase.cjs +5 -5
  16. package/dist/components/BannerBase/BannerBase.cjs.map +1 -1
  17. package/dist/components/BannerBase/BannerBase.d.cts.map +1 -1
  18. package/dist/components/BannerBase/BannerBase.d.mts.map +1 -1
  19. package/dist/components/BannerBase/BannerBase.mjs +6 -6
  20. package/dist/components/BannerBase/BannerBase.mjs.map +1 -1
  21. package/dist/components/Icon/Icon.cjs +30 -8
  22. package/dist/components/Icon/Icon.cjs.map +1 -1
  23. package/dist/components/Icon/Icon.d.cts.map +1 -1
  24. package/dist/components/Icon/Icon.d.mts.map +1 -1
  25. package/dist/components/Icon/Icon.mjs +8 -6
  26. package/dist/components/Icon/Icon.mjs.map +1 -1
  27. package/dist/components/Icon/Icon.registry.cjs +74 -0
  28. package/dist/components/Icon/Icon.registry.cjs.map +1 -0
  29. package/dist/components/Icon/Icon.registry.d.cts +46 -0
  30. package/dist/components/Icon/Icon.registry.d.cts.map +1 -0
  31. package/dist/components/Icon/Icon.registry.d.mts +46 -0
  32. package/dist/components/Icon/Icon.registry.d.mts.map +1 -0
  33. package/dist/components/Icon/Icon.registry.mjs +67 -0
  34. package/dist/components/Icon/Icon.registry.mjs.map +1 -0
  35. package/dist/components/Icon/icons/index.cjs +303 -587
  36. package/dist/components/Icon/icons/index.cjs.map +1 -1
  37. package/dist/components/Icon/icons/index.d.cts +14 -296
  38. package/dist/components/Icon/icons/index.d.cts.map +1 -1
  39. package/dist/components/Icon/icons/index.d.mts +14 -296
  40. package/dist/components/Icon/icons/index.d.mts.map +1 -1
  41. package/dist/components/Icon/icons/index.mjs +301 -583
  42. package/dist/components/Icon/icons/index.mjs.map +1 -1
  43. package/dist/components/Icon/index.cjs +3 -1
  44. package/dist/components/Icon/index.cjs.map +1 -1
  45. package/dist/components/Icon/index.d.cts +1 -0
  46. package/dist/components/Icon/index.d.cts.map +1 -1
  47. package/dist/components/Icon/index.d.mts +1 -0
  48. package/dist/components/Icon/index.d.mts.map +1 -1
  49. package/dist/components/Icon/index.mjs +1 -0
  50. package/dist/components/Icon/index.mjs.map +1 -1
  51. package/dist/components/index.cjs +3 -2
  52. package/dist/components/index.cjs.map +1 -1
  53. package/dist/components/index.d.cts +1 -1
  54. package/dist/components/index.d.cts.map +1 -1
  55. package/dist/components/index.d.mts +1 -1
  56. package/dist/components/index.d.mts.map +1 -1
  57. package/dist/components/index.mjs +1 -1
  58. package/dist/components/index.mjs.map +1 -1
  59. package/package.json +4 -4
@@ -0,0 +1,46 @@
1
+ import type { IconName } from "@metamask-previews/design-system-shared";
2
+ import type { LazyExoticComponent } from "react";
3
+ import type { IconComponentType } from "./icons/index.cjs";
4
+ import { isIconName } from "./icons/index.cjs";
5
+ /**
6
+ * Preloads all icon modules for the Jest test environment.
7
+ * Icons are cached as synchronous components so tests can query the DOM
8
+ * immediately without waiting for React.lazy resolution.
9
+ *
10
+ * @returns A promise that resolves when all icons are cached.
11
+ */
12
+ export declare function preloadIconsForTests(): Promise<void>;
13
+ /**
14
+ * Returns a cached React.lazy wrapper for the given icon name.
15
+ * Each icon is loaded on demand via dynamic import, enabling per-icon
16
+ * code splitting instead of bundling all ~291 icons upfront.
17
+ *
18
+ * @param name - The icon name to resolve.
19
+ * @returns A lazy-loaded icon component.
20
+ */
21
+ export declare function getLazyIcon(name: IconName): LazyExoticComponent<IconComponentType>;
22
+ type GetIconComponentOptions = {
23
+ useTestCache?: boolean;
24
+ };
25
+ /**
26
+ * Resolves an icon component for rendering.
27
+ * Returns a synchronously cached component when present in the test preload
28
+ * cache (populated by preloadIconsForTests()). Otherwise returns a React.lazy
29
+ * wrapper for per-icon code splitting.
30
+ *
31
+ * @param name - The icon name to resolve.
32
+ * @param options - Optional resolver configuration.
33
+ * @param options.useTestCache - When false, skips the test preload cache.
34
+ * @returns The icon component to render.
35
+ */
36
+ export declare function getIconComponent(name: IconName, options?: GetIconComponentOptions): IconComponentType | LazyExoticComponent<IconComponentType>;
37
+ /**
38
+ * Preloads an icon module so it is available synchronously on the next render.
39
+ * Useful for warming commonly used icons before they appear on screen.
40
+ *
41
+ * @param name - The icon name to preload.
42
+ * @returns A promise that resolves when the icon module has loaded.
43
+ */
44
+ export declare function preloadIcon(name: IconName): Promise<void>;
45
+ export { isIconName };
46
+ //# sourceMappingURL=Icon.registry.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.registry.d.cts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gDAAgD;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc;AAGjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAAgB;AACjD,OAAO,EAAe,UAAU,EAAE,0BAAgB;AAWlD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CASpD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,QAAQ,GACb,mBAAmB,CAAC,iBAAiB,CAAC,CASxC;AAED,KAAK,uBAAuB,GAAG;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,EACd,OAAO,CAAC,EAAE,uBAAuB,GAChC,iBAAiB,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAU5D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { IconName } from "@metamask-previews/design-system-shared";
2
+ import type { LazyExoticComponent } from "react";
3
+ import type { IconComponentType } from "./icons/index.mjs";
4
+ import { isIconName } from "./icons/index.mjs";
5
+ /**
6
+ * Preloads all icon modules for the Jest test environment.
7
+ * Icons are cached as synchronous components so tests can query the DOM
8
+ * immediately without waiting for React.lazy resolution.
9
+ *
10
+ * @returns A promise that resolves when all icons are cached.
11
+ */
12
+ export declare function preloadIconsForTests(): Promise<void>;
13
+ /**
14
+ * Returns a cached React.lazy wrapper for the given icon name.
15
+ * Each icon is loaded on demand via dynamic import, enabling per-icon
16
+ * code splitting instead of bundling all ~291 icons upfront.
17
+ *
18
+ * @param name - The icon name to resolve.
19
+ * @returns A lazy-loaded icon component.
20
+ */
21
+ export declare function getLazyIcon(name: IconName): LazyExoticComponent<IconComponentType>;
22
+ type GetIconComponentOptions = {
23
+ useTestCache?: boolean;
24
+ };
25
+ /**
26
+ * Resolves an icon component for rendering.
27
+ * Returns a synchronously cached component when present in the test preload
28
+ * cache (populated by preloadIconsForTests()). Otherwise returns a React.lazy
29
+ * wrapper for per-icon code splitting.
30
+ *
31
+ * @param name - The icon name to resolve.
32
+ * @param options - Optional resolver configuration.
33
+ * @param options.useTestCache - When false, skips the test preload cache.
34
+ * @returns The icon component to render.
35
+ */
36
+ export declare function getIconComponent(name: IconName, options?: GetIconComponentOptions): IconComponentType | LazyExoticComponent<IconComponentType>;
37
+ /**
38
+ * Preloads an icon module so it is available synchronously on the next render.
39
+ * Useful for warming commonly used icons before they appear on screen.
40
+ *
41
+ * @param name - The icon name to preload.
42
+ * @returns A promise that resolves when the icon module has loaded.
43
+ */
44
+ export declare function preloadIcon(name: IconName): Promise<void>;
45
+ export { isIconName };
46
+ //# sourceMappingURL=Icon.registry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.registry.d.mts","sourceRoot":"","sources":["../../../src/components/Icon/Icon.registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gDAAgD;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc;AAGjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,0BAAgB;AACjD,OAAO,EAAe,UAAU,EAAE,0BAAgB;AAWlD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CASpD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,QAAQ,GACb,mBAAmB,CAAC,iBAAiB,CAAC,CASxC;AAED,KAAK,uBAAuB,GAAG;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,QAAQ,EACd,OAAO,CAAC,EAAE,uBAAuB,GAChC,iBAAiB,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,CAU5D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { lazy } from "react";
2
+ import { iconLoaders, isIconName } from "./icons/index.mjs";
3
+ const lazyIconCache = new Map();
4
+ const testIconCache = new Map();
5
+ let testPreloadPromise;
6
+ /**
7
+ * Preloads all icon modules for the Jest test environment.
8
+ * Icons are cached as synchronous components so tests can query the DOM
9
+ * immediately without waiting for React.lazy resolution.
10
+ *
11
+ * @returns A promise that resolves when all icons are cached.
12
+ */
13
+ export function preloadIconsForTests() {
14
+ testPreloadPromise ?? (testPreloadPromise = Promise.all(Object.entries(iconLoaders).map(async ([name, loader]) => {
15
+ const mod = await loader();
16
+ testIconCache.set(name, mod.default);
17
+ })).then(() => undefined));
18
+ return testPreloadPromise;
19
+ }
20
+ /**
21
+ * Returns a cached React.lazy wrapper for the given icon name.
22
+ * Each icon is loaded on demand via dynamic import, enabling per-icon
23
+ * code splitting instead of bundling all ~291 icons upfront.
24
+ *
25
+ * @param name - The icon name to resolve.
26
+ * @returns A lazy-loaded icon component.
27
+ */
28
+ export function getLazyIcon(name) {
29
+ let lazyIcon = lazyIconCache.get(name);
30
+ if (!lazyIcon) {
31
+ lazyIcon = lazy(iconLoaders[name]);
32
+ lazyIconCache.set(name, lazyIcon);
33
+ }
34
+ return lazyIcon;
35
+ }
36
+ /**
37
+ * Resolves an icon component for rendering.
38
+ * Returns a synchronously cached component when present in the test preload
39
+ * cache (populated by preloadIconsForTests()). Otherwise returns a React.lazy
40
+ * wrapper for per-icon code splitting.
41
+ *
42
+ * @param name - The icon name to resolve.
43
+ * @param options - Optional resolver configuration.
44
+ * @param options.useTestCache - When false, skips the test preload cache.
45
+ * @returns The icon component to render.
46
+ */
47
+ export function getIconComponent(name, options) {
48
+ if (options?.useTestCache !== false) {
49
+ const cachedTestIcon = testIconCache.get(name);
50
+ if (cachedTestIcon) {
51
+ return cachedTestIcon;
52
+ }
53
+ }
54
+ return getLazyIcon(name);
55
+ }
56
+ /**
57
+ * Preloads an icon module so it is available synchronously on the next render.
58
+ * Useful for warming commonly used icons before they appear on screen.
59
+ *
60
+ * @param name - The icon name to preload.
61
+ * @returns A promise that resolves when the icon module has loaded.
62
+ */
63
+ export function preloadIcon(name) {
64
+ return iconLoaders[name]().then(() => undefined);
65
+ }
66
+ export { isIconName };
67
+ //# sourceMappingURL=Icon.registry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Icon.registry.mjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.registry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,cAAc;AAG7B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,0BAAgB;AAElD,MAAM,aAAa,GAAG,IAAI,GAAG,EAG1B,CAAC;AAEJ,MAAM,aAAa,GAAG,IAAI,GAAG,EAA+B,CAAC;AAE7D,IAAI,kBAA6C,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB;IAClC,kBAAkB,KAAlB,kBAAkB,GAAK,OAAO,CAAC,GAAG,CAChC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE;QACvD,MAAM,GAAG,GAAG,MAAM,MAAM,EAAE,CAAC;QAC3B,aAAa,CAAC,GAAG,CAAC,IAAgB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC,CAAC,CACH,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,EAAC;IAExB,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,IAAc;IAEd,IAAI,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,aAAa,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KACnC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAMD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAc,EACd,OAAiC;IAEjC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE;QACnC,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE/C,IAAI,cAAc,EAAE;YAClB,OAAO,cAAc,CAAC;SACvB;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,IAAc;IACxC,OAAO,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AACnD,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import type { IconName } from '@metamask-previews/design-system-shared';\nimport type { LazyExoticComponent } from 'react';\nimport { lazy } from 'react';\n\nimport type { IconComponentType } from './icons';\nimport { iconLoaders, isIconName } from './icons';\n\nconst lazyIconCache = new Map<\n IconName,\n LazyExoticComponent<IconComponentType>\n>();\n\nconst testIconCache = new Map<IconName, IconComponentType>();\n\nlet testPreloadPromise: Promise<void> | undefined;\n\n/**\n * Preloads all icon modules for the Jest test environment.\n * Icons are cached as synchronous components so tests can query the DOM\n * immediately without waiting for React.lazy resolution.\n *\n * @returns A promise that resolves when all icons are cached.\n */\nexport function preloadIconsForTests(): Promise<void> {\n testPreloadPromise ??= Promise.all(\n Object.entries(iconLoaders).map(async ([name, loader]) => {\n const mod = await loader();\n testIconCache.set(name as IconName, mod.default);\n }),\n ).then(() => undefined);\n\n return testPreloadPromise;\n}\n\n/**\n * Returns a cached React.lazy wrapper for the given icon name.\n * Each icon is loaded on demand via dynamic import, enabling per-icon\n * code splitting instead of bundling all ~291 icons upfront.\n *\n * @param name - The icon name to resolve.\n * @returns A lazy-loaded icon component.\n */\nexport function getLazyIcon(\n name: IconName,\n): LazyExoticComponent<IconComponentType> {\n let lazyIcon = lazyIconCache.get(name);\n\n if (!lazyIcon) {\n lazyIcon = lazy(iconLoaders[name]);\n lazyIconCache.set(name, lazyIcon);\n }\n\n return lazyIcon;\n}\n\ntype GetIconComponentOptions = {\n useTestCache?: boolean;\n};\n\n/**\n * Resolves an icon component for rendering.\n * Returns a synchronously cached component when present in the test preload\n * cache (populated by preloadIconsForTests()). Otherwise returns a React.lazy\n * wrapper for per-icon code splitting.\n *\n * @param name - The icon name to resolve.\n * @param options - Optional resolver configuration.\n * @param options.useTestCache - When false, skips the test preload cache.\n * @returns The icon component to render.\n */\nexport function getIconComponent(\n name: IconName,\n options?: GetIconComponentOptions,\n): IconComponentType | LazyExoticComponent<IconComponentType> {\n if (options?.useTestCache !== false) {\n const cachedTestIcon = testIconCache.get(name);\n\n if (cachedTestIcon) {\n return cachedTestIcon;\n }\n }\n\n return getLazyIcon(name);\n}\n\n/**\n * Preloads an icon module so it is available synchronously on the next render.\n * Useful for warming commonly used icons before they appear on screen.\n *\n * @param name - The icon name to preload.\n * @returns A promise that resolves when the icon module has loaded.\n */\nexport function preloadIcon(name: IconName): Promise<void> {\n return iconLoaders[name]().then(() => undefined);\n}\n\nexport { isIconName };\n"]}