@transferwise/components 46.71.8 → 46.72.1

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 (55) hide show
  1. package/build/alert/Alert.js +52 -49
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +53 -50
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/avatar/Avatar.js +2 -2
  6. package/build/avatar/Avatar.js.map +1 -1
  7. package/build/avatar/Avatar.mjs +2 -2
  8. package/build/avatar/Avatar.mjs.map +1 -1
  9. package/build/avatarWrapper/AvatarWrapper.js +2 -8
  10. package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
  11. package/build/avatarWrapper/AvatarWrapper.mjs +1 -7
  12. package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
  13. package/build/{avatar/colors → common}/colors.js +3 -3
  14. package/build/common/colors.js.map +1 -0
  15. package/build/{avatar/colors → common}/colors.mjs +3 -3
  16. package/build/common/colors.mjs.map +1 -0
  17. package/build/common/initials.js +12 -0
  18. package/build/common/initials.js.map +1 -0
  19. package/build/common/initials.mjs +10 -0
  20. package/build/common/initials.mjs.map +1 -0
  21. package/build/display/Display.js +1 -1
  22. package/build/display/Display.js.map +1 -1
  23. package/build/display/Display.mjs +1 -1
  24. package/build/display/Display.mjs.map +1 -1
  25. package/build/types/alert/Alert.d.ts +3 -1
  26. package/build/types/alert/Alert.d.ts.map +1 -1
  27. package/build/types/avatar/Avatar.d.ts.map +1 -1
  28. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  29. package/build/types/common/colors.d.ts +4 -0
  30. package/build/types/common/colors.d.ts.map +1 -0
  31. package/build/types/common/index.d.ts +2 -0
  32. package/build/types/common/initials.d.ts +2 -0
  33. package/build/types/common/initials.d.ts.map +1 -0
  34. package/package.json +5 -5
  35. package/src/alert/Alert.spec.tsx +20 -0
  36. package/src/alert/Alert.story.tsx +50 -2
  37. package/src/alert/Alert.tsx +57 -50
  38. package/src/avatar/Avatar.tsx +2 -3
  39. package/src/avatarWrapper/AvatarWrapper.tsx +8 -15
  40. package/src/{avatar/colors → common}/colors.ts +5 -5
  41. package/src/common/index.js +2 -0
  42. package/src/common/initials.ts +13 -0
  43. package/src/display/Display.tsx +1 -1
  44. package/src/promoCard/__snapshots__/PromoCard.spec.tsx.snap +1 -1
  45. package/src/promoCard/__snapshots__/PromoCardGroup.spec.tsx.snap +2 -2
  46. package/src/test-utils/assets/avatar-rectangle-fox.webp +0 -0
  47. package/src/test-utils/assets/avatar-square-dude.webp +0 -0
  48. package/src/test-utils/assets/tapestry-01.png +0 -0
  49. package/build/avatar/colors/colors.js.map +0 -1
  50. package/build/avatar/colors/colors.mjs.map +0 -1
  51. package/build/types/avatar/colors/colors.d.ts +0 -4
  52. package/build/types/avatar/colors/colors.d.ts.map +0 -1
  53. package/build/types/avatar/colors/index.d.ts +0 -2
  54. package/build/types/avatar/colors/index.d.ts.map +0 -1
  55. package/src/avatar/colors/index.ts +0 -1
@@ -5,7 +5,7 @@
5
5
  * Changing this array will change the assignment between seeds.
6
6
  * Do not change this array.
7
7
  */
8
- const avatarColors = ['--color-bright-blue', '--color-bright-yellow', '--color-bright-pink', '--color-bright-orange'];
8
+ const avatarColors = ['var(--color-bright-blue)', 'var(--color-bright-yellow)', 'var(--color-bright-pink)', 'var(--color-bright-orange)'];
9
9
  /*
10
10
  * Takes in a "seed" string and spits out an index for the color we should use.
11
11
  * This implementation has been synced across all three clients so that we consistently
@@ -23,9 +23,9 @@ const hashSeed = seed => {
23
23
  }
24
24
  return hashValue;
25
25
  };
26
- const getAvatarColorFromSeed = seed => {
26
+ const getBrandColorFromSeed = seed => {
27
27
  return avatarColors[hashSeed(seed)];
28
28
  };
29
29
 
30
- exports.getAvatarColorFromSeed = getAvatarColorFromSeed;
30
+ exports.getBrandColorFromSeed = getBrandColorFromSeed;
31
31
  //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sources":["../../src/common/colors.ts"],"sourcesContent":["/*\n * The colors we support generating an Avatar background color from a \"seed\" for.\n * Changing this array will change the assignment between seeds.\n * Do not change this array.\n */\nconst avatarColors = [\n 'var(--color-bright-blue)',\n 'var(--color-bright-yellow)',\n 'var(--color-bright-pink)',\n 'var(--color-bright-orange)',\n] as const;\n\n/*\n * Takes in a \"seed\" string and spits out an index for the color we should use.\n * This implementation has been synced across all three clients so that we consistently\n * generate branded avatar colors when rendering a list of Avatars.\n * Do not change this implementation.\n */\nconst hashSeed = (seed: string): number => {\n const base = 31;\n const modulo = avatarColors.length;\n\n let hashValue = 0;\n let basePow = 1;\n\n for (let i = 0; i < seed.length; i += 1) {\n hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;\n basePow = (basePow * base) % modulo;\n }\n\n return hashValue;\n};\n\nexport const getBrandColorFromSeed = (seed: string): (typeof avatarColors)[number] => {\n return avatarColors[hashSeed(seed)];\n};\n"],"names":["avatarColors","hashSeed","seed","base","modulo","length","hashValue","basePow","i","charCodeAt","getBrandColorFromSeed"],"mappings":";;AAAA;;;;AAIG;AACH,MAAMA,YAAY,GAAG,CACnB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,CACpB,CAAA;AAEV;;;;;AAKG;AACH,MAAMC,QAAQ,GAAIC,IAAY,IAAY;EACxC,MAAMC,IAAI,GAAG,EAAE,CAAA;AACf,EAAA,MAAMC,MAAM,GAAGJ,YAAY,CAACK,MAAM,CAAA;EAElC,IAAIC,SAAS,GAAG,CAAC,CAAA;EACjB,IAAIC,OAAO,GAAG,CAAC,CAAA;AAEf,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,IAAI,CAACG,MAAM,EAAEG,CAAC,IAAI,CAAC,EAAE;AACvCF,IAAAA,SAAS,GAAG,CAACA,SAAS,GAAGJ,IAAI,CAACO,UAAU,CAACD,CAAC,CAAC,GAAGD,OAAO,IAAIH,MAAM,CAAA;AAC/DG,IAAAA,OAAO,GAAIA,OAAO,GAAGJ,IAAI,GAAIC,MAAM,CAAA;AACrC,GAAA;AAEA,EAAA,OAAOE,SAAS,CAAA;AAClB,CAAC,CAAA;AAEYI,MAAAA,qBAAqB,GAAIR,IAAY,IAAmC;AACnF,EAAA,OAAOF,YAAY,CAACC,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAA;AACrC;;;;"}
@@ -3,7 +3,7 @@
3
3
  * Changing this array will change the assignment between seeds.
4
4
  * Do not change this array.
5
5
  */
6
- const avatarColors = ['--color-bright-blue', '--color-bright-yellow', '--color-bright-pink', '--color-bright-orange'];
6
+ const avatarColors = ['var(--color-bright-blue)', 'var(--color-bright-yellow)', 'var(--color-bright-pink)', 'var(--color-bright-orange)'];
7
7
  /*
8
8
  * Takes in a "seed" string and spits out an index for the color we should use.
9
9
  * This implementation has been synced across all three clients so that we consistently
@@ -21,9 +21,9 @@ const hashSeed = seed => {
21
21
  }
22
22
  return hashValue;
23
23
  };
24
- const getAvatarColorFromSeed = seed => {
24
+ const getBrandColorFromSeed = seed => {
25
25
  return avatarColors[hashSeed(seed)];
26
26
  };
27
27
 
28
- export { getAvatarColorFromSeed };
28
+ export { getBrandColorFromSeed };
29
29
  //# sourceMappingURL=colors.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.mjs","sources":["../../src/common/colors.ts"],"sourcesContent":["/*\n * The colors we support generating an Avatar background color from a \"seed\" for.\n * Changing this array will change the assignment between seeds.\n * Do not change this array.\n */\nconst avatarColors = [\n 'var(--color-bright-blue)',\n 'var(--color-bright-yellow)',\n 'var(--color-bright-pink)',\n 'var(--color-bright-orange)',\n] as const;\n\n/*\n * Takes in a \"seed\" string and spits out an index for the color we should use.\n * This implementation has been synced across all three clients so that we consistently\n * generate branded avatar colors when rendering a list of Avatars.\n * Do not change this implementation.\n */\nconst hashSeed = (seed: string): number => {\n const base = 31;\n const modulo = avatarColors.length;\n\n let hashValue = 0;\n let basePow = 1;\n\n for (let i = 0; i < seed.length; i += 1) {\n hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;\n basePow = (basePow * base) % modulo;\n }\n\n return hashValue;\n};\n\nexport const getBrandColorFromSeed = (seed: string): (typeof avatarColors)[number] => {\n return avatarColors[hashSeed(seed)];\n};\n"],"names":["avatarColors","hashSeed","seed","base","modulo","length","hashValue","basePow","i","charCodeAt","getBrandColorFromSeed"],"mappings":"AAAA;;;;AAIG;AACH,MAAMA,YAAY,GAAG,CACnB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,CACpB,CAAA;AAEV;;;;;AAKG;AACH,MAAMC,QAAQ,GAAIC,IAAY,IAAY;EACxC,MAAMC,IAAI,GAAG,EAAE,CAAA;AACf,EAAA,MAAMC,MAAM,GAAGJ,YAAY,CAACK,MAAM,CAAA;EAElC,IAAIC,SAAS,GAAG,CAAC,CAAA;EACjB,IAAIC,OAAO,GAAG,CAAC,CAAA;AAEf,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,IAAI,CAACG,MAAM,EAAEG,CAAC,IAAI,CAAC,EAAE;AACvCF,IAAAA,SAAS,GAAG,CAACA,SAAS,GAAGJ,IAAI,CAACO,UAAU,CAACD,CAAC,CAAC,GAAGD,OAAO,IAAIH,MAAM,CAAA;AAC/DG,IAAAA,OAAO,GAAIA,OAAO,GAAGJ,IAAI,GAAIC,MAAM,CAAA;AACrC,GAAA;AAEA,EAAA,OAAOE,SAAS,CAAA;AAClB,CAAC,CAAA;AAEYI,MAAAA,qBAAqB,GAAIR,IAAY,IAAmC;AACnF,EAAA,OAAOF,YAAY,CAACC,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAA;AACrC;;;;"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ function getInitials(name) {
4
+ const allInitials = name.split(' ').map(part => part[0]).join('').toUpperCase();
5
+ if (allInitials.length === 1) {
6
+ return allInitials[0];
7
+ }
8
+ return allInitials[0] + allInitials.slice(-1);
9
+ }
10
+
11
+ exports.getInitials = getInitials;
12
+ //# sourceMappingURL=initials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initials.js","sources":["../../src/common/initials.ts"],"sourcesContent":["export function getInitials(name: string) {\n const allInitials = name\n .split(' ')\n .map((part) => part[0])\n .join('')\n .toUpperCase();\n\n if (allInitials.length === 1) {\n return allInitials[0];\n }\n\n return allInitials[0] + allInitials.slice(-1);\n}\n"],"names":["getInitials","name","allInitials","split","map","part","join","toUpperCase","length","slice"],"mappings":";;AAAM,SAAUA,WAAWA,CAACC,IAAY,EAAA;EACtC,MAAMC,WAAW,GAAGD,IAAI,CACrBE,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAAC,CAAC,CAAC,CAAC,CACtBC,IAAI,CAAC,EAAE,CAAC,CACRC,WAAW,EAAE,CAAA;AAEhB,EAAA,IAAIL,WAAW,CAACM,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAON,WAAW,CAAC,CAAC,CAAC,CAAA;AACvB,GAAA;EAEA,OAAOA,WAAW,CAAC,CAAC,CAAC,GAAGA,WAAW,CAACO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/C;;;;"}
@@ -0,0 +1,10 @@
1
+ function getInitials(name) {
2
+ const allInitials = name.split(' ').map(part => part[0]).join('').toUpperCase();
3
+ if (allInitials.length === 1) {
4
+ return allInitials[0];
5
+ }
6
+ return allInitials[0] + allInitials.slice(-1);
7
+ }
8
+
9
+ export { getInitials };
10
+ //# sourceMappingURL=initials.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initials.mjs","sources":["../../src/common/initials.ts"],"sourcesContent":["export function getInitials(name: string) {\n const allInitials = name\n .split(' ')\n .map((part) => part[0])\n .join('')\n .toUpperCase();\n\n if (allInitials.length === 1) {\n return allInitials[0];\n }\n\n return allInitials[0] + allInitials.slice(-1);\n}\n"],"names":["getInitials","name","allInitials","split","map","part","join","toUpperCase","length","slice"],"mappings":"AAAM,SAAUA,WAAWA,CAACC,IAAY,EAAA;EACtC,MAAMC,WAAW,GAAGD,IAAI,CACrBE,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAAC,CAAC,CAAC,CAAC,CACtBC,IAAI,CAAC,EAAE,CAAC,CACRC,WAAW,EAAE,CAAA;AAEhB,EAAA,IAAIL,WAAW,CAACM,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAON,WAAW,CAAC,CAAC,CAAC,CAAA;AACvB,GAAA;EAEA,OAAOA,WAAW,CAAC,CAAC,CAAC,GAAGA,WAAW,CAACO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/C;;;;"}
@@ -13,7 +13,7 @@ function Display({
13
13
  }) {
14
14
  return /*#__PURE__*/jsxRuntime.jsx(Heading, {
15
15
  id: id,
16
- className: clsx.clsx(`np-text-${type}`, 'text-primary', className),
16
+ className: clsx.clsx('np-display', `np-text-${type}`, 'text-primary', className),
17
17
  children: children
18
18
  });
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Display.js","sources":["../../src/display/Display.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { PropsWithChildren } from 'react';\n\nimport { DisplayTypes, Typography } from '../common';\n\ntype Props = PropsWithChildren<{\n as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n id?: string;\n type?: DisplayTypes;\n className?: string;\n}>;\n\nfunction Display({\n as: Heading = 'h1',\n type = Typography.DISPLAY_LARGE,\n children,\n className,\n id,\n}: Props) {\n return (\n <Heading id={id} className={clsx(`np-text-${type}`, 'text-primary', className)}>\n {children}\n </Heading>\n );\n}\n\nexport default Display;\n"],"names":["Display","as","Heading","type","Typography","DISPLAY_LARGE","children","className","id","_jsx","clsx"],"mappings":";;;;;;AAYA,SAASA,OAAOA,CAAC;EACfC,EAAE,EAAEC,OAAO,GAAG,IAAI;EAClBC,IAAI,GAAGC,qBAAU,CAACC,aAAa;EAC/BC,QAAQ;EACRC,SAAS;AACTC,EAAAA,EAAAA;AACM,CAAA,EAAA;EACN,oBACEC,cAAA,CAACP,OAAO,EAAA;AAACM,IAAAA,EAAE,EAAEA,EAAG;IAACD,SAAS,EAAEG,SAAI,CAAC,CAAWP,QAAAA,EAAAA,IAAI,EAAE,EAAE,cAAc,EAAEI,SAAS,CAAE;AAAAD,IAAAA,QAAA,EAC5EA,QAAAA;AAAQ,GACF,CAAC,CAAA;AAEd;;;;"}
1
+ {"version":3,"file":"Display.js","sources":["../../src/display/Display.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { PropsWithChildren } from 'react';\n\nimport { DisplayTypes, Typography } from '../common';\n\ntype Props = PropsWithChildren<{\n as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n id?: string;\n type?: DisplayTypes;\n className?: string;\n}>;\n\nfunction Display({\n as: Heading = 'h1',\n type = Typography.DISPLAY_LARGE,\n children,\n className,\n id,\n}: Props) {\n return (\n <Heading id={id} className={clsx('np-display', `np-text-${type}`, 'text-primary', className)}>\n {children}\n </Heading>\n );\n}\n\nexport default Display;\n"],"names":["Display","as","Heading","type","Typography","DISPLAY_LARGE","children","className","id","_jsx","clsx"],"mappings":";;;;;;AAYA,SAASA,OAAOA,CAAC;EACfC,EAAE,EAAEC,OAAO,GAAG,IAAI;EAClBC,IAAI,GAAGC,qBAAU,CAACC,aAAa;EAC/BC,QAAQ;EACRC,SAAS;AACTC,EAAAA,EAAAA;AACM,CAAA,EAAA;EACN,oBACEC,cAAA,CAACP,OAAO,EAAA;AAACM,IAAAA,EAAE,EAAEA,EAAG;AAACD,IAAAA,SAAS,EAAEG,SAAI,CAAC,YAAY,EAAE,CAAA,QAAA,EAAWP,IAAI,CAAA,CAAE,EAAE,cAAc,EAAEI,SAAS,CAAE;AAAAD,IAAAA,QAAA,EAC1FA,QAAAA;AAAQ,GACF,CAAC,CAAA;AAEd;;;;"}
@@ -11,7 +11,7 @@ function Display({
11
11
  }) {
12
12
  return /*#__PURE__*/jsx(Heading, {
13
13
  id: id,
14
- className: clsx(`np-text-${type}`, 'text-primary', className),
14
+ className: clsx('np-display', `np-text-${type}`, 'text-primary', className),
15
15
  children: children
16
16
  });
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Display.mjs","sources":["../../src/display/Display.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { PropsWithChildren } from 'react';\n\nimport { DisplayTypes, Typography } from '../common';\n\ntype Props = PropsWithChildren<{\n as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n id?: string;\n type?: DisplayTypes;\n className?: string;\n}>;\n\nfunction Display({\n as: Heading = 'h1',\n type = Typography.DISPLAY_LARGE,\n children,\n className,\n id,\n}: Props) {\n return (\n <Heading id={id} className={clsx(`np-text-${type}`, 'text-primary', className)}>\n {children}\n </Heading>\n );\n}\n\nexport default Display;\n"],"names":["Display","as","Heading","type","Typography","DISPLAY_LARGE","children","className","id","_jsx","clsx"],"mappings":";;;;AAYA,SAASA,OAAOA,CAAC;EACfC,EAAE,EAAEC,OAAO,GAAG,IAAI;EAClBC,IAAI,GAAGC,UAAU,CAACC,aAAa;EAC/BC,QAAQ;EACRC,SAAS;AACTC,EAAAA,EAAAA;AACM,CAAA,EAAA;EACN,oBACEC,GAAA,CAACP,OAAO,EAAA;AAACM,IAAAA,EAAE,EAAEA,EAAG;IAACD,SAAS,EAAEG,IAAI,CAAC,CAAWP,QAAAA,EAAAA,IAAI,EAAE,EAAE,cAAc,EAAEI,SAAS,CAAE;AAAAD,IAAAA,QAAA,EAC5EA,QAAAA;AAAQ,GACF,CAAC,CAAA;AAEd;;;;"}
1
+ {"version":3,"file":"Display.mjs","sources":["../../src/display/Display.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { PropsWithChildren } from 'react';\n\nimport { DisplayTypes, Typography } from '../common';\n\ntype Props = PropsWithChildren<{\n as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n id?: string;\n type?: DisplayTypes;\n className?: string;\n}>;\n\nfunction Display({\n as: Heading = 'h1',\n type = Typography.DISPLAY_LARGE,\n children,\n className,\n id,\n}: Props) {\n return (\n <Heading id={id} className={clsx('np-display', `np-text-${type}`, 'text-primary', className)}>\n {children}\n </Heading>\n );\n}\n\nexport default Display;\n"],"names":["Display","as","Heading","type","Typography","DISPLAY_LARGE","children","className","id","_jsx","clsx"],"mappings":";;;;AAYA,SAASA,OAAOA,CAAC;EACfC,EAAE,EAAEC,OAAO,GAAG,IAAI;EAClBC,IAAI,GAAGC,UAAU,CAACC,aAAa;EAC/BC,QAAQ;EACRC,SAAS;AACTC,EAAAA,EAAAA;AACM,CAAA,EAAA;EACN,oBACEC,GAAA,CAACP,OAAO,EAAA;AAACM,IAAAA,EAAE,EAAEA,EAAG;AAACD,IAAAA,SAAS,EAAEG,IAAI,CAAC,YAAY,EAAE,CAAA,QAAA,EAAWP,IAAI,CAAA,CAAE,EAAE,cAAc,EAAEI,SAAS,CAAE;AAAAD,IAAAA,QAAA,EAC1FA,QAAAA;AAAQ,GACF,CAAC,CAAA;AAEd;;;;"}
@@ -33,6 +33,8 @@ export interface AlertProps {
33
33
  /** The type dictates which icon and colour will be used */
34
34
  type?: AlertType;
35
35
  variant?: `${Variant}`;
36
+ /** Controls rendering of the Alert component. <br /> Toggle this prop instead using conditional rendering and logical AND (&&) operator, to make the component work with screen readers. */
37
+ active?: boolean;
36
38
  /** @deprecated Use `InlineAlert` instead. */
37
39
  arrow?: `${AlertArrowPosition}`;
38
40
  /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */
@@ -42,6 +44,6 @@ export interface AlertProps {
42
44
  /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */
43
45
  size?: `${Size}`;
44
46
  }
45
- export default function Alert({ arrow, action, children, className, dismissible, icon, onDismiss, message, size, title, type, variant, }: AlertProps): import("react").JSX.Element;
47
+ export default function Alert({ arrow, action, children, className, dismissible, icon, onDismiss, message, size, title, type, variant, active, }: AlertProps): import("react").JSX.Element;
46
48
  export {};
47
49
  //# sourceMappingURL=Alert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../src/alert/Alert.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAc,OAAO,EAAE,MAAM,WAAW,CAAC;AASjE,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,kDAAkD;AAClD,KAAK,mBAAmB,GAAG,GAAG,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC;AACrF,KAAK,iBAAiB,GAAG,GACrB,SAAS,CAAC,QAAQ,GAClB,SAAS,CAAC,OAAO,GACjB,SAAS,CAAC,OAAO,GACjB,SAAS,CAAC,QAAQ,EAAE,CAAC;AACzB,MAAM,MAAM,SAAS,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAEhE,oBAAY,kBAAkB;IAC5B,QAAQ,YAAY;IACpB,GAAG,cAAc;IACjB,SAAS,aAAa;IACtB,WAAW,cAAc;IACzB,MAAM,gBAAgB;IACtB,YAAY,eAAe;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,yIAAyI;IACzI,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wGAAwG;IACxG,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kGAAkG;IAClG,OAAO,CA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EACnB,MAAa,GACd,EAAE,UAAU,+BAyGZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../src/avatar/Avatar.tsx"],"names":[],"mappings":"AAQA,KAAK,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEhD,KAAK,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAErE,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAkBD,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4CjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../src/avatar/Avatar.tsx"],"names":[],"mappings":"AAOA,KAAK,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAEhD,KAAK,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAA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CAAC;CAC5B,GACD;IACE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB,CACJ,CAAC;AAEF,QAAA,MAAM,aAAa,sIAWhB,kBAAkB,gCAoDpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,4 @@
1
+ declare const avatarColors: readonly ["var(--color-bright-blue)", "var(--color-bright-yellow)", "var(--color-bright-pink)", "var(--color-bright-orange)"];
2
+ export declare const getBrandColorFromSeed: (seed: string) => (typeof avatarColors)[number];
3
+ export {};
4
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/common/colors.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,YAAY,+HAKR,CAAC;AAuBX,eAAO,MAAM,qBAAqB,SAAU,MAAM,KAAG,CAAC,OAAO,YAAY,EAAE,MAAM,CAEhF,CAAC"}
@@ -12,6 +12,8 @@ export * from "./propsValues/profileType";
12
12
  export * from "./propsValues/scroll";
13
13
  export * from "./locale";
14
14
  export * from "./commonProps";
15
+ export * from "./initials";
16
+ export * from "./colors";
15
17
  export { Breakpoint } from "./propsValues/breakpoint";
16
18
  export { Type } from "./propsValues/type";
17
19
  export { DateMode } from "./propsValues/dateMode";
@@ -0,0 +1,2 @@
1
+ export declare function getInitials(name: string): string;
2
+ //# sourceMappingURL=initials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initials.d.ts","sourceRoot":"","sources":["../../../src/common/initials.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,UAYvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.71.8",
3
+ "version": "46.72.1",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -79,7 +79,7 @@
79
79
  "@types/react": "^18.3.11",
80
80
  "@types/react-dom": "^18.3.1",
81
81
  "@types/react-transition-group": "4.4.10",
82
- "@wise/art": "^2.7.0",
82
+ "@wise/art": "^2.16.3",
83
83
  "babel-plugin-formatjs": "^10.5.16",
84
84
  "babel-plugin-inline-react-svg": "^2.0.2",
85
85
  "enzyme": "^3.11.0",
@@ -91,14 +91,14 @@
91
91
  "rollup": "^4.18.1",
92
92
  "rollup-preserve-directives": "^1.1.1",
93
93
  "storybook": "^8.2.2",
94
+ "@transferwise/less-config": "3.1.0",
94
95
  "@transferwise/neptune-css": "14.19.1",
95
- "@wise/components-theming": "1.6.1",
96
- "@transferwise/less-config": "3.1.0"
96
+ "@wise/components-theming": "1.6.1"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "@transferwise/icons": "^3.13.1",
100
100
  "@transferwise/neptune-css": "^14.9.6",
101
- "@wise/art": "^2.7.0",
101
+ "@wise/art": "^2.16",
102
102
  "@wise/components-theming": "^1.0.0",
103
103
  "react": ">=18",
104
104
  "react-dom": ">=18",
@@ -467,4 +467,24 @@ describe('Alert', () => {
467
467
  expect(screen.getByTestId('status-icon')).toBeInTheDocument();
468
468
  });
469
469
  });
470
+
471
+ describe('`active` prop', () => {
472
+ it('should render wrapper and alert if `active` is unset', () => {
473
+ render(<Alert message={message} />);
474
+ expect(screen.getByRole('status')).toBeInTheDocument();
475
+ expect(screen.getByText(message)).toBeInTheDocument();
476
+ });
477
+
478
+ it('should render wrapper and alert if `active={false}', () => {
479
+ render(<Alert message={message} active={false} />);
480
+ expect(screen.getByRole('status')).toBeInTheDocument();
481
+ expect(screen.queryByText(message)).not.toBeInTheDocument();
482
+ });
483
+
484
+ it('should render wrapper and alert if `active` is set', () => {
485
+ render(<Alert message={message} />);
486
+ expect(screen.getByRole('status')).toBeInTheDocument();
487
+ expect(screen.getByText(message)).toBeInTheDocument();
488
+ });
489
+ });
470
490
  });
@@ -1,10 +1,10 @@
1
- /* eslint-disable no-alert */
1
+ import { useState } from 'react';
2
2
  import { Meta, StoryObj } from '@storybook/react';
3
3
  import { action } from '@storybook/addon-actions';
4
4
  import { ClockBorderless } from '@transferwise/icons';
5
5
 
6
6
  import { Sentiment } from '../common';
7
-
7
+ import { Button } from '..';
8
8
  import Alert, { AlertArrowPosition } from './Alert';
9
9
 
10
10
  export default {
@@ -12,6 +12,7 @@ export default {
12
12
  title: 'Feedback/Alert',
13
13
  args: {
14
14
  type: Sentiment.POSITIVE,
15
+ active: true,
15
16
  message:
16
17
  'Payments sent to your bank details **today** might not arrive in time for the holidays.',
17
18
  },
@@ -103,3 +104,50 @@ export const WithTitle: Story = {
103
104
  onDismiss: () => {},
104
105
  },
105
106
  };
107
+
108
+ /**
109
+ * For ARIA live region to function correctly with screen readers,
110
+ * the container with an appropriate ARIA role (in the case of this
111
+ * component, it's `status` or `alert`) must be rendered first.
112
+ * Once present in the accessibility tree, its dynamic contents
113
+ * will be announced correctly.
114
+ *
115
+ * Because of that, using logical AND (&&) operator is discouraged
116
+ * and, instead, engineers should toggle the `active` prop which
117
+ * provides that logic internally.
118
+ */
119
+ export const ConditionallyRendered: Story = {
120
+ render: function Render(args) {
121
+ const [isActive, setIsActive] = useState(false);
122
+
123
+ return (
124
+ <>
125
+ <Button htmlType="button" onClick={() => setIsActive((value) => !value)}>
126
+ Trigger Alert
127
+ </Button>
128
+
129
+ <Alert {...args} active={isActive} className="m-t-5" />
130
+ </>
131
+ );
132
+ },
133
+ parameters: {
134
+ docs: {
135
+ source: {
136
+ code: `
137
+ function Render (args) {
138
+ const [isActive, setIsActive] = useState(false);
139
+
140
+ return (
141
+ <>
142
+ <Button htmlType="button" onClick={() => setIsActive(value => !value)}>
143
+ Trigger Alert
144
+ </Button>
145
+
146
+ <Alert {...args} active={isActive} className="m-t-5" />
147
+ </>
148
+ )
149
+ }`,
150
+ },
151
+ },
152
+ },
153
+ };
@@ -52,6 +52,8 @@ export interface AlertProps {
52
52
  /** The type dictates which icon and colour will be used */
53
53
  type?: AlertType;
54
54
  variant?: `${Variant}`;
55
+ /** Controls rendering of the Alert component. <br /> Toggle this prop instead using conditional rendering and logical AND (&&) operator, to make the component work with screen readers. */
56
+ active?: boolean;
55
57
  /** @deprecated Use `InlineAlert` instead. */
56
58
  arrow?: `${AlertArrowPosition}`;
57
59
  /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */
@@ -88,6 +90,7 @@ export default function Alert({
88
90
  title,
89
91
  type = 'neutral',
90
92
  variant = 'desktop',
93
+ active = true,
91
94
  }: AlertProps) {
92
95
  useEffect(() => {
93
96
  if (arrow !== undefined) {
@@ -133,59 +136,63 @@ export default function Alert({
133
136
  const closeButtonReference = useRef<HTMLButtonElement>(null);
134
137
 
135
138
  return (
136
- <div
137
- className={clsx(
138
- 'alert d-flex',
139
- `alert-${resolvedType}`,
140
- arrow != null && alertArrowClassNames(arrow),
141
- className,
142
- )}
143
- data-testid="alert"
144
- onTouchStart={() => setShouldFire(true)}
145
- onTouchEnd={(event) => {
146
- if (
147
- shouldFire &&
148
- action?.href &&
149
- // Check if current event is triggered from closeButton
150
- event.target instanceof Node &&
151
- closeButtonReference.current &&
152
- !closeButtonReference.current.contains(event.target)
153
- ) {
154
- if (action.target === '_blank') {
155
- window.top?.open(action.href);
156
- } else {
157
- window.top?.location.assign(action.href);
158
- }
159
- }
160
- setShouldFire(false);
161
- }}
162
- onTouchMove={() => setShouldFire(false)}
163
- >
164
- <div
165
- className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}
166
- data-testid={variant}
167
- >
168
- {icon ? (
169
- <div className="alert__icon">{icon}</div>
170
- ) : (
171
- <StatusIcon size={Size.LARGE} sentiment={resolvedType} />
172
- )}
173
- <div className="alert__message">
174
- <div role={Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status'}>
175
- {title && (
176
- <Title className="m-b-1" type={Typography.TITLE_BODY}>
177
- {title}
178
- </Title>
139
+ <div role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}>
140
+ {active && (
141
+ <div
142
+ className={clsx(
143
+ 'alert d-flex',
144
+ `alert-${resolvedType}`,
145
+ arrow != null && alertArrowClassNames(arrow),
146
+ className,
147
+ )}
148
+ data-testid="alert"
149
+ onTouchStart={() => setShouldFire(true)}
150
+ onTouchEnd={(event) => {
151
+ if (
152
+ shouldFire &&
153
+ action?.href &&
154
+ // Check if current event is triggered from closeButton
155
+ event.target instanceof Node &&
156
+ closeButtonReference.current &&
157
+ !closeButtonReference.current.contains(event.target)
158
+ ) {
159
+ if (action.target === '_blank') {
160
+ window.top?.open(action.href);
161
+ } else {
162
+ window.top?.location.assign(action.href);
163
+ }
164
+ }
165
+ setShouldFire(false);
166
+ }}
167
+ onTouchMove={() => setShouldFire(false)}
168
+ >
169
+ <div
170
+ className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}
171
+ data-testid={variant}
172
+ >
173
+ {icon ? (
174
+ <div className="alert__icon">{icon}</div>
175
+ ) : (
176
+ <StatusIcon size={Size.LARGE} sentiment={resolvedType} />
179
177
  )}
180
- <Body as="span" className="d-block" type={Typography.BODY_LARGE}>
181
- {children || <InlineMarkdown>{message}</InlineMarkdown>}
182
- </Body>
178
+ <div className="alert__message">
179
+ <div>
180
+ {title && (
181
+ <Title className="m-b-1" type={Typography.TITLE_BODY}>
182
+ {title}
183
+ </Title>
184
+ )}
185
+ <Body as="span" className="d-block" type={Typography.BODY_LARGE}>
186
+ {children || <InlineMarkdown>{message}</InlineMarkdown>}
187
+ </Body>
188
+ </div>
189
+ {action && <Action action={action} className="m-t-1" />}
190
+ </div>
183
191
  </div>
184
- {action && <Action action={action} className="m-t-1" />}
192
+ {onDismiss && (
193
+ <CloseButton ref={closeButtonReference} className="m-l-2" onClick={onDismiss} />
194
+ )}
185
195
  </div>
186
- </div>
187
- {onDismiss && (
188
- <CloseButton ref={closeButtonReference} className="m-l-2" onClick={onDismiss} />
189
196
  )}
190
197
  </div>
191
198
  );
@@ -1,9 +1,8 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { useMemo } from 'react';
3
3
 
4
- import { Theme } from '../common';
4
+ import { getBrandColorFromSeed, Theme } from '../common';
5
5
 
6
- import { getAvatarColorFromSeed } from './colors';
7
6
  import Circle from '../common/circle';
8
7
 
9
8
  type NumericAvatarSize = 24 | 40 | 48 | 56 | 72;
@@ -58,7 +57,7 @@ const Avatar: React.FC<AvatarProps> = ({
58
57
  const backgroundColorFromSeed = useMemo<string | undefined>(
59
58
  () =>
60
59
  !backgroundColor && backgroundColorSeed
61
- ? `var(${getAvatarColorFromSeed(backgroundColorSeed)})`
60
+ ? getBrandColorFromSeed(backgroundColorSeed)
62
61
  : undefined,
63
62
  [backgroundColor, backgroundColorSeed],
64
63
  );
@@ -3,7 +3,14 @@ import { useState, useEffect } from 'react';
3
3
 
4
4
  import Avatar, { AvatarProps, AvatarType } from '../avatar';
5
5
  import Badge, { BadgeProps } from '../badge';
6
- import { ProfileType, ProfileTypePersonal, ProfileTypeBusiness, Size, Sentiment } from '../common';
6
+ import {
7
+ ProfileType,
8
+ ProfileTypePersonal,
9
+ ProfileTypeBusiness,
10
+ Size,
11
+ Sentiment,
12
+ getInitials,
13
+ } from '../common';
7
14
  import StatusIcon from '../statusIcon/StatusIcon';
8
15
 
9
16
  interface OptionalBadgeProps extends Omit<BadgeProps, 'badge'> {
@@ -133,18 +140,4 @@ const AvatarWrapper = ({
133
140
  );
134
141
  };
135
142
 
136
- function getInitials(name: string) {
137
- const allInitials = name
138
- .split(' ')
139
- .map((part) => part[0])
140
- .join('')
141
- .toUpperCase();
142
-
143
- if (allInitials.length === 1) {
144
- return allInitials[0];
145
- }
146
-
147
- return allInitials[0] + allInitials.slice(-1);
148
- }
149
-
150
143
  export default AvatarWrapper;
@@ -4,10 +4,10 @@
4
4
  * Do not change this array.
5
5
  */
6
6
  const avatarColors = [
7
- '--color-bright-blue',
8
- '--color-bright-yellow',
9
- '--color-bright-pink',
10
- '--color-bright-orange',
7
+ 'var(--color-bright-blue)',
8
+ 'var(--color-bright-yellow)',
9
+ 'var(--color-bright-pink)',
10
+ 'var(--color-bright-orange)',
11
11
  ] as const;
12
12
 
13
13
  /*
@@ -31,6 +31,6 @@ const hashSeed = (seed: string): number => {
31
31
  return hashValue;
32
32
  };
33
33
 
34
- export const getAvatarColorFromSeed = (seed: string): (typeof avatarColors)[number] => {
34
+ export const getBrandColorFromSeed = (seed: string): (typeof avatarColors)[number] => {
35
35
  return avatarColors[hashSeed(seed)];
36
36
  };
@@ -23,3 +23,5 @@ export { MarkdownNodeType } from './propsValues/markdownNodeType';
23
23
  export { FileType } from './fileType';
24
24
  export * from './locale';
25
25
  export * from './commonProps';
26
+ export * from './initials';
27
+ export * from './colors';
@@ -0,0 +1,13 @@
1
+ export function getInitials(name: string) {
2
+ const allInitials = name
3
+ .split(' ')
4
+ .map((part) => part[0])
5
+ .join('')
6
+ .toUpperCase();
7
+
8
+ if (allInitials.length === 1) {
9
+ return allInitials[0];
10
+ }
11
+
12
+ return allInitials[0] + allInitials.slice(-1);
13
+ }
@@ -18,7 +18,7 @@ function Display({
18
18
  id,
19
19
  }: Props) {
20
20
  return (
21
- <Heading id={id} className={clsx(`np-text-${type}`, 'text-primary', className)}>
21
+ <Heading id={id} className={clsx('np-display', `np-text-${type}`, 'text-primary', className)}>
22
22
  {children}
23
23
  </Heading>
24
24
  );
@@ -7,7 +7,7 @@ exports[`PromoCard matches snapshot 1`] = `
7
7
  id="test-promo-card"
8
8
  >
9
9
  <h3
10
- class="np-text-display-small text-primary np-Card-title"
10
+ class="np-display np-text-display-small text-primary np-Card-title"
11
11
  id="test-promo-card-title"
12
12
  >
13
13
  Test Title
@@ -17,7 +17,7 @@ exports[`PromoCardGroup matches snapshot 1`] = `
17
17
  tabindex="0"
18
18
  >
19
19
  <h3
20
- class="np-text-display-small text-primary np-Card-title"
20
+ class="np-display np-text-display-small text-primary np-Card-title"
21
21
  id="radio-1-title"
22
22
  >
23
23
  Test Card
@@ -51,7 +51,7 @@ exports[`PromoCardGroup matches snapshot 1`] = `
51
51
  tabindex="0"
52
52
  >
53
53
  <h3
54
- class="np-text-display-small text-primary np-Card-title"
54
+ class="np-display np-text-display-small text-primary np-Card-title"
55
55
  id="radio-2-title"
56
56
  >
57
57
  Test Card
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.js","sources":["../../../src/avatar/colors/colors.ts"],"sourcesContent":["/*\n * The colors we support generating an Avatar background color from a \"seed\" for.\n * Changing this array will change the assignment between seeds.\n * Do not change this array.\n */\nconst avatarColors = [\n '--color-bright-blue',\n '--color-bright-yellow',\n '--color-bright-pink',\n '--color-bright-orange',\n] as const;\n\n/*\n * Takes in a \"seed\" string and spits out an index for the color we should use.\n * This implementation has been synced across all three clients so that we consistently\n * generate branded avatar colors when rendering a list of Avatars.\n * Do not change this implementation.\n */\nconst hashSeed = (seed: string): number => {\n const base = 31;\n const modulo = avatarColors.length;\n\n let hashValue = 0;\n let basePow = 1;\n\n for (let i = 0; i < seed.length; i += 1) {\n hashValue = (hashValue + seed.charCodeAt(i) * basePow) % modulo;\n basePow = (basePow * base) % modulo;\n }\n\n return hashValue;\n};\n\nexport const getAvatarColorFromSeed = (seed: string): (typeof avatarColors)[number] => {\n return avatarColors[hashSeed(seed)];\n};\n"],"names":["avatarColors","hashSeed","seed","base","modulo","length","hashValue","basePow","i","charCodeAt","getAvatarColorFromSeed"],"mappings":";;AAAA;;;;AAIG;AACH,MAAMA,YAAY,GAAG,CACnB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,uBAAuB,CACf,CAAA;AAEV;;;;;AAKG;AACH,MAAMC,QAAQ,GAAIC,IAAY,IAAY;EACxC,MAAMC,IAAI,GAAG,EAAE,CAAA;AACf,EAAA,MAAMC,MAAM,GAAGJ,YAAY,CAACK,MAAM,CAAA;EAElC,IAAIC,SAAS,GAAG,CAAC,CAAA;EACjB,IAAIC,OAAO,GAAG,CAAC,CAAA;AAEf,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,IAAI,CAACG,MAAM,EAAEG,CAAC,IAAI,CAAC,EAAE;AACvCF,IAAAA,SAAS,GAAG,CAACA,SAAS,GAAGJ,IAAI,CAACO,UAAU,CAACD,CAAC,CAAC,GAAGD,OAAO,IAAIH,MAAM,CAAA;AAC/DG,IAAAA,OAAO,GAAIA,OAAO,GAAGJ,IAAI,GAAIC,MAAM,CAAA;AACrC,GAAA;AAEA,EAAA,OAAOE,SAAS,CAAA;AAClB,CAAC,CAAA;AAEYI,MAAAA,sBAAsB,GAAIR,IAAY,IAAmC;AACpF,EAAA,OAAOF,YAAY,CAACC,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAA;AACrC;;;;"}