@transferwise/components 0.0.0-experimental-76bb7cd → 0.0.0-experimental-54cbbb2

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 (99) hide show
  1. package/build/avatar/Avatar.js +3 -0
  2. package/build/avatar/Avatar.js.map +1 -1
  3. package/build/avatar/Avatar.mjs +3 -0
  4. package/build/avatar/Avatar.mjs.map +1 -1
  5. package/build/avatarView/AvatarView.js +170 -0
  6. package/build/avatarView/AvatarView.js.map +1 -0
  7. package/build/avatarView/AvatarView.mjs +168 -0
  8. package/build/avatarView/AvatarView.mjs.map +1 -0
  9. package/build/avatarView/NotificationDot.js +59 -0
  10. package/build/avatarView/NotificationDot.js.map +1 -0
  11. package/build/avatarView/NotificationDot.mjs +57 -0
  12. package/build/avatarView/NotificationDot.mjs.map +1 -0
  13. package/build/avatarWrapper/AvatarWrapper.js +10 -4
  14. package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
  15. package/build/avatarWrapper/AvatarWrapper.mjs +10 -4
  16. package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
  17. package/build/badge/Badge.js +16 -4
  18. package/build/badge/Badge.js.map +1 -1
  19. package/build/badge/Badge.mjs +15 -3
  20. package/build/badge/Badge.mjs.map +1 -1
  21. package/build/badge/BadgeAssets.js +60 -0
  22. package/build/badge/BadgeAssets.js.map +1 -0
  23. package/build/badge/BadgeAssets.mjs +58 -0
  24. package/build/badge/BadgeAssets.mjs.map +1 -0
  25. package/build/common/circle/Circle.js +17 -1
  26. package/build/common/circle/Circle.js.map +1 -1
  27. package/build/common/circle/Circle.mjs +17 -1
  28. package/build/common/circle/Circle.mjs.map +1 -1
  29. package/build/index.js +20 -13
  30. package/build/index.js.map +1 -1
  31. package/build/index.mjs +11 -7
  32. package/build/index.mjs.map +1 -1
  33. package/build/main.css +109 -5
  34. package/build/styles/avatarGroup/AvatarGroup.css +29 -0
  35. package/build/styles/avatarView/AvatarView.css +42 -0
  36. package/build/styles/avatarView/NotificationDot.css +20 -0
  37. package/build/styles/badge/Badge.css +6 -5
  38. package/build/styles/common/circle/Circle.css +32 -0
  39. package/build/styles/main.css +109 -5
  40. package/build/types/avatar/Avatar.d.ts +3 -0
  41. package/build/types/avatar/Avatar.d.ts.map +1 -1
  42. package/build/types/avatarGroup/AvatarGroup.d.ts +18 -0
  43. package/build/types/avatarGroup/AvatarGroup.d.ts.map +1 -0
  44. package/build/types/avatarGroup/index.d.ts +3 -0
  45. package/build/types/avatarGroup/index.d.ts.map +1 -0
  46. package/build/types/avatarView/AvatarView.d.ts +26 -0
  47. package/build/types/avatarView/AvatarView.d.ts.map +1 -0
  48. package/build/types/avatarView/NotificationDot.d.ts +8 -0
  49. package/build/types/avatarView/NotificationDot.d.ts.map +1 -0
  50. package/build/types/avatarView/index.d.ts +3 -0
  51. package/build/types/avatarView/index.d.ts.map +1 -0
  52. package/build/types/avatarWrapper/AvatarWrapper.d.ts +3 -0
  53. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  54. package/build/types/badge/Badge.d.ts +9 -4
  55. package/build/types/badge/Badge.d.ts.map +1 -1
  56. package/build/types/badge/BadgeAssets.d.ts +14 -0
  57. package/build/types/badge/BadgeAssets.d.ts.map +1 -0
  58. package/build/types/badge/index.d.ts +2 -0
  59. package/build/types/badge/index.d.ts.map +1 -1
  60. package/build/types/common/circle/Circle.d.ts +2 -0
  61. package/build/types/common/circle/Circle.d.ts.map +1 -1
  62. package/build/types/index.d.ts +3 -1
  63. package/build/types/index.d.ts.map +1 -1
  64. package/package.json +3 -3
  65. package/src/avatar/Avatar.tsx +3 -0
  66. package/src/avatarGroup/AvatarGroup.css +29 -0
  67. package/src/avatarGroup/AvatarGroup.less +42 -0
  68. package/src/avatarGroup/AvatarGroup.story.tsx +284 -0
  69. package/src/avatarGroup/AvatarGroup.tsx +117 -0
  70. package/src/avatarGroup/index.ts +2 -0
  71. package/src/avatarView/AvatarView.css +42 -0
  72. package/src/avatarView/AvatarView.less +33 -0
  73. package/src/avatarView/AvatarView.story.tsx +482 -0
  74. package/src/avatarView/AvatarView.tsx +169 -0
  75. package/src/avatarView/NotificationDot.css +20 -0
  76. package/src/avatarView/NotificationDot.less +24 -0
  77. package/src/avatarView/NotificationDot.tsx +35 -0
  78. package/src/avatarView/index.ts +2 -0
  79. package/src/avatarWrapper/AvatarWrapper.tsx +3 -0
  80. package/src/badge/Badge.css +6 -5
  81. package/src/badge/Badge.less +4 -3
  82. package/src/badge/Badge.tsx +20 -6
  83. package/src/badge/BadgeAssets.tsx +61 -0
  84. package/src/badge/index.ts +3 -0
  85. package/src/common/circle/Circle.css +32 -0
  86. package/src/common/circle/Circle.less +35 -0
  87. package/src/common/circle/Circle.tsx +22 -1
  88. package/src/decision/Decision.story.tsx +10 -46
  89. package/src/flowNavigation/FlowNavigation.story.tsx +10 -48
  90. package/src/index.ts +4 -0
  91. package/src/listItem/ListItem.story.tsx +5 -43
  92. package/src/main.css +109 -5
  93. package/src/main.less +2 -0
  94. package/src/navigationOption/NavigationOption.story.tsx +14 -65
  95. package/src/overlayHeader/OverlayHeader.story.tsx +5 -10
  96. package/src/radio/Radio.story.tsx +5 -5
  97. package/src/radioGroup/RadioGroup.story.tsx +3 -3
  98. package/src/selectOption/SelectOption.story.tsx +31 -30
  99. package/src/tile/Tile.story.tsx +2 -6
@@ -39,6 +39,9 @@ const backwardsCompatibleSize = size => {
39
39
  return size;
40
40
  }
41
41
  };
42
+ /**
43
+ * @deprecated Use `AvatarView` component instead
44
+ */
42
45
  const Avatar = ({
43
46
  backgroundColor = null,
44
47
  backgroundColorSeed = null,
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","sources":["../../src/avatar/Avatar.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useMemo } from 'react';\n\nimport { getBrandColorFromSeed, Theme } from '../common';\n\nimport Circle from '../common/circle';\n\ntype NumericAvatarSize = 24 | 40 | 48 | 56 | 72;\n\ntype LegacyAvatarSize = 'sm' | 'md' | 'lg';\n\nexport type AvatarSize = NumericAvatarSize | LegacyAvatarSize;\n\nexport type AvatarTheme = 'light' | 'dark';\n\nexport type AvatarType = 'thumbnail' | 'icon' | 'emoji' | 'initials';\n\nexport interface AvatarProps {\n backgroundColor?: string;\n backgroundColorSeed?: string;\n children?: React.ReactNode;\n className?: string;\n outlined?: boolean;\n size?: AvatarSize;\n theme?: AvatarTheme;\n type?: AvatarType;\n 'aria-label'?: string;\n}\n\nconst backwardsCompatibleSize = (size: AvatarSize): NumericAvatarSize => {\n switch (size) {\n case 'sm':\n return 24;\n\n case 'md':\n return 48;\n\n case 'lg':\n return 72;\n\n default:\n return size;\n }\n};\n\nconst Avatar: React.FC<AvatarProps> = ({\n backgroundColor = null,\n backgroundColorSeed = null,\n children = null,\n className,\n outlined = false,\n size: sizeFromProps = 48,\n theme = Theme.LIGHT,\n type = 'thumbnail',\n 'aria-label': ariaLabel,\n}) => {\n const backgroundColorFromSeed = useMemo<string | undefined>(\n () =>\n !backgroundColor && backgroundColorSeed\n ? getBrandColorFromSeed(backgroundColorSeed)\n : undefined,\n [backgroundColor, backgroundColorSeed],\n );\n\n const size = backwardsCompatibleSize(sizeFromProps);\n\n return (\n <div\n className={clsx('tw-avatar', className, `tw-avatar--${size}`, `tw-avatar--${type}`, {\n 'tw-avatar--outlined': outlined,\n 'tw-avatar--branded': Boolean(backgroundColorFromSeed),\n 'np-text-title-body': type === 'initials',\n })}\n aria-label={ariaLabel}\n >\n <div\n className=\"tw-avatar__content\"\n style={{\n backgroundColor: backgroundColor || backgroundColorFromSeed,\n }}\n >\n {children}\n </div>\n </div>\n );\n};\n\nexport default Avatar;\n"],"names":["backwardsCompatibleSize","size","Avatar","backgroundColor","backgroundColorSeed","children","className","outlined","sizeFromProps","theme","Theme","LIGHT","type","ariaLabel","backgroundColorFromSeed","useMemo","getBrandColorFromSeed","undefined","_jsx","clsx","Boolean","style"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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YAAA,EAAYC,SAAU;AAAAR,IAAAA,QAAA,eAEtBa,cAAA,CAAA,KAAA,EAAA;AACEZ,MAAAA,SAAS,EAAC,oBAAoB;AAC9Be,MAAAA,KAAK,EAAE;QACLlB,eAAe,EAAEA,eAAe,IAAIW,uBAAAA;OACpC;AAAAT,MAAAA,QAAA,EAEDA,QAAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
1
+ {"version":3,"file":"Avatar.js","sources":["../../src/avatar/Avatar.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useMemo } from 'react';\n\nimport { getBrandColorFromSeed, Theme } from '../common';\n\nimport Circle from '../common/circle';\n\ntype NumericAvatarSize = 24 | 40 | 48 | 56 | 72;\n\ntype LegacyAvatarSize = 'sm' | 'md' | 'lg';\n\nexport type AvatarSize = NumericAvatarSize | LegacyAvatarSize;\n\nexport type AvatarTheme = 'light' | 'dark';\n\nexport type AvatarType = 'thumbnail' | 'icon' | 'emoji' | 'initials';\n\nexport interface AvatarProps {\n backgroundColor?: string;\n backgroundColorSeed?: string;\n children?: React.ReactNode;\n className?: string;\n outlined?: boolean;\n size?: AvatarSize;\n theme?: AvatarTheme;\n type?: AvatarType;\n 'aria-label'?: string;\n}\n\nconst backwardsCompatibleSize = (size: AvatarSize): NumericAvatarSize => {\n switch (size) {\n case 'sm':\n return 24;\n\n case 'md':\n return 48;\n\n case 'lg':\n return 72;\n\n default:\n return size;\n }\n};\n\n/**\n * @deprecated Use `AvatarView` component instead\n */\nconst Avatar: React.FC<AvatarProps> = ({\n backgroundColor = null,\n backgroundColorSeed = null,\n children = null,\n className,\n outlined = false,\n size: sizeFromProps = 48,\n theme = Theme.LIGHT,\n type = 'thumbnail',\n 'aria-label': ariaLabel,\n}) => {\n const backgroundColorFromSeed = useMemo<string | undefined>(\n () =>\n !backgroundColor && backgroundColorSeed\n ? getBrandColorFromSeed(backgroundColorSeed)\n : undefined,\n [backgroundColor, backgroundColorSeed],\n );\n\n const size = backwardsCompatibleSize(sizeFromProps);\n\n return (\n <div\n className={clsx('tw-avatar', className, `tw-avatar--${size}`, `tw-avatar--${type}`, {\n 'tw-avatar--outlined': outlined,\n 'tw-avatar--branded': Boolean(backgroundColorFromSeed),\n 'np-text-title-body': type === 'initials',\n })}\n aria-label={ariaLabel}\n >\n <div\n className=\"tw-avatar__content\"\n style={{\n backgroundColor: backgroundColor || backgroundColorFromSeed,\n }}\n >\n {children}\n </div>\n </div>\n );\n};\n\nexport default Avatar;\n"],"names":["backwardsCompatibleSize","size","Avatar","backgroundColor","backgroundColorSeed","children","className","outlined","sizeFromProps","theme","Theme","LIGHT","type","ariaLabel","backgroundColorFromSeed","useMemo","getBrandColorFromSeed","undefined","_jsx","clsx","Boolean","style"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAMA,uBAAuB,GAAIC,IAAgB,IAAuB;AACtE,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,IAAI;AACP,MAAA,OAAO,EAAE,CAAA;AAEX,IAAA,KAAK,IAAI;AACP,MAAA,OAAO,EAAE,CAAA;AAEX,IAAA,KAAK,IAAI;AACP,MAAA,OAAO,EAAE,CAAA;AAEX,IAAA;AACE,MAAA,OAAOA,IAAI,CAAA;AACf,GAAA;AACF,CAAC,CAAA;AAED;;AAEG;AACGC,MAAAA,MAAM,GAA0BA,CAAC;AACrCC,EAAAA,eAAe,GAAG,IAAI;AACtBC,EAAAA,mBAAmB,GAAG,IAAI;AAC1BC,EAAAA,QAAQ,GAAG,IAAI;EACfC,SAAS;AACTC,EAAAA,QAAQ,GAAG,KAAK;EAChBN,IAAI,EAAEO,aAAa,GAAG,EAAE;SACxBC,OAAK,GAAGC,WAAK,CAACC,KAAK;AACnBC,EAAAA,IAAI,GAAG,WAAW;AAClB,EAAA,YAAY,EAAEC,SAAAA;AAAS,CACxB,KAAI;EACH,MAAMC,uBAAuB,GAAGC,aAAO,CACrC,MACE,CAACZ,eAAe,IAAIC,mBAAmB,GACnCY,4BAAqB,CAACZ,mBAAmB,CAAC,GAC1Ca,SAAS,EACf,CAACd,eAAe,EAAEC,mBAAmB,CAAC,CACvC,CAAA;AAED,EAAA,MAAMH,IAAI,GAAGD,uBAAuB,CAACQ,aAAa,CAAC,CAAA;AAEnD,EAAA,oBACEU,cAAA,CAAA,KAAA,EAAA;AACEZ,IAAAA,SAAS,EAAEa,SAAI,CAAC,WAAW,EAAEb,SAAS,EAAE,CAAcL,WAAAA,EAAAA,IAAI,CAAE,CAAA,EAAE,CAAcW,WAAAA,EAAAA,IAAI,EAAE,EAAE;AAClF,MAAA,qBAAqB,EAAEL,QAAQ;AAC/B,MAAA,oBAAoB,EAAEa,OAAO,CAACN,uBAAuB,CAAC;MACtD,oBAAoB,EAAEF,IAAI,KAAK,UAAA;AAChC,KAAA,CAAE;AACH,IAAA,YAAA,EAAYC,SAAU;AAAAR,IAAAA,QAAA,eAEtBa,cAAA,CAAA,KAAA,EAAA;AACEZ,MAAAA,SAAS,EAAC,oBAAoB;AAC9Be,MAAAA,KAAK,EAAE;QACLlB,eAAe,EAAEA,eAAe,IAAIW,uBAAAA;OACpC;AAAAT,MAAAA,QAAA,EAEDA,QAAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
@@ -37,6 +37,9 @@ const backwardsCompatibleSize = size => {
37
37
  return size;
38
38
  }
39
39
  };
40
+ /**
41
+ * @deprecated Use `AvatarView` component instead
42
+ */
40
43
  const Avatar = ({
41
44
  backgroundColor = null,
42
45
  backgroundColorSeed = null,
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.mjs","sources":["../../src/avatar/Avatar.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useMemo } from 'react';\n\nimport { getBrandColorFromSeed, Theme } from '../common';\n\nimport Circle from '../common/circle';\n\ntype NumericAvatarSize = 24 | 40 | 48 | 56 | 72;\n\ntype LegacyAvatarSize = 'sm' | 'md' | 'lg';\n\nexport type AvatarSize = NumericAvatarSize | LegacyAvatarSize;\n\nexport type AvatarTheme = 'light' | 'dark';\n\nexport type AvatarType = 'thumbnail' | 'icon' | 'emoji' | 'initials';\n\nexport interface AvatarProps {\n backgroundColor?: string;\n backgroundColorSeed?: string;\n children?: React.ReactNode;\n className?: string;\n outlined?: boolean;\n size?: AvatarSize;\n theme?: AvatarTheme;\n type?: AvatarType;\n 'aria-label'?: string;\n}\n\nconst backwardsCompatibleSize = (size: AvatarSize): NumericAvatarSize => {\n switch (size) {\n case 'sm':\n return 24;\n\n case 'md':\n return 48;\n\n case 'lg':\n return 72;\n\n default:\n return size;\n }\n};\n\nconst Avatar: React.FC<AvatarProps> = ({\n backgroundColor = null,\n backgroundColorSeed = null,\n children = null,\n className,\n outlined = false,\n size: sizeFromProps = 48,\n theme = Theme.LIGHT,\n type = 'thumbnail',\n 'aria-label': ariaLabel,\n}) => {\n const backgroundColorFromSeed = useMemo<string | undefined>(\n () =>\n !backgroundColor && backgroundColorSeed\n ? getBrandColorFromSeed(backgroundColorSeed)\n : undefined,\n [backgroundColor, backgroundColorSeed],\n );\n\n const size = backwardsCompatibleSize(sizeFromProps);\n\n return (\n <div\n className={clsx('tw-avatar', className, `tw-avatar--${size}`, `tw-avatar--${type}`, {\n 'tw-avatar--outlined': outlined,\n 'tw-avatar--branded': Boolean(backgroundColorFromSeed),\n 'np-text-title-body': type === 'initials',\n })}\n aria-label={ariaLabel}\n >\n <div\n className=\"tw-avatar__content\"\n style={{\n backgroundColor: backgroundColor || backgroundColorFromSeed,\n }}\n >\n {children}\n </div>\n </div>\n );\n};\n\nexport default Avatar;\n"],"names":["backwardsCompatibleSize","size","Avatar","backgroundColor","backgroundColorSeed","children","className","outlined","sizeFromProps","theme","Theme","LIGHT","type","ariaLabel","backgroundColorFromSeed","useMemo","getBrandColorFromSeed","undefined","_jsx","clsx","Boolean","style"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAMA,uBAAuB,GAAIC,IAAgB,IAAuB;AACtE,EAAA,Q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AAA,KAAA,EAAA;AACEZ,MAAAA,SAAS,EAAC,oBAAoB;AAC9Be,MAAAA,KAAK,EAAE;QACLlB,eAAe,EAAEA,eAAe,IAAIW,uBAAAA;OACpC;AAAAT,MAAAA,QAAA,EAEDA,QAAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
1
+ {"version":3,"file":"Avatar.mjs","sources":["../../src/avatar/Avatar.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useMemo } from 'react';\n\nimport { getBrandColorFromSeed, Theme } from '../common';\n\nimport Circle from '../common/circle';\n\ntype NumericAvatarSize = 24 | 40 | 48 | 56 | 72;\n\ntype LegacyAvatarSize = 'sm' | 'md' | 'lg';\n\nexport type AvatarSize = NumericAvatarSize | LegacyAvatarSize;\n\nexport type AvatarTheme = 'light' | 'dark';\n\nexport type AvatarType = 'thumbnail' | 'icon' | 'emoji' | 'initials';\n\nexport interface AvatarProps {\n backgroundColor?: string;\n backgroundColorSeed?: string;\n children?: React.ReactNode;\n className?: string;\n outlined?: boolean;\n size?: AvatarSize;\n theme?: AvatarTheme;\n type?: AvatarType;\n 'aria-label'?: string;\n}\n\nconst backwardsCompatibleSize = (size: AvatarSize): NumericAvatarSize => {\n switch (size) {\n case 'sm':\n return 24;\n\n case 'md':\n return 48;\n\n case 'lg':\n return 72;\n\n default:\n return size;\n }\n};\n\n/**\n * @deprecated Use `AvatarView` component instead\n */\nconst Avatar: React.FC<AvatarProps> = ({\n backgroundColor = null,\n backgroundColorSeed = null,\n children = null,\n className,\n outlined = false,\n size: sizeFromProps = 48,\n theme = Theme.LIGHT,\n type = 'thumbnail',\n 'aria-label': ariaLabel,\n}) => {\n const backgroundColorFromSeed = useMemo<string | undefined>(\n () =>\n !backgroundColor && backgroundColorSeed\n ? getBrandColorFromSeed(backgroundColorSeed)\n : undefined,\n [backgroundColor, backgroundColorSeed],\n );\n\n const size = backwardsCompatibleSize(sizeFromProps);\n\n return (\n <div\n className={clsx('tw-avatar', className, `tw-avatar--${size}`, `tw-avatar--${type}`, {\n 'tw-avatar--outlined': outlined,\n 'tw-avatar--branded': Boolean(backgroundColorFromSeed),\n 'np-text-title-body': type === 'initials',\n })}\n aria-label={ariaLabel}\n >\n <div\n className=\"tw-avatar__content\"\n style={{\n backgroundColor: backgroundColor || backgroundColorFromSeed,\n }}\n >\n {children}\n </div>\n </div>\n );\n};\n\nexport default Avatar;\n"],"names":["backwardsCompatibleSize","size","Avatar","backgroundColor","backgroundColorSeed","children","className","outlined","sizeFromProps","theme","Theme","LIGHT","type","ariaLabel","backgroundColorFromSeed","useMemo","getBrandColorFromSeed","undefined","_jsx","clsx","Boolean","style"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAMA,uBAAuB,GAAIC,IAAgB,IAAuB;AACtE,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,IAAI;AACP,MAAA,OAAO,EAAE,CAAA;AAEX,IAAA,KAAK,IAAI;AACP,MAAA,OAAO,EAAE,CAAA;AAEX,IAAA,KAAK,IAAI;AACP,MAAA,OAAO,EAAE,CAAA;AAEX,IAAA;AACE,MAAA,OAAOA,IAAI,CAAA;AACf,GAAA;AACF,CAAC,CAAA;AAED;;AAEG;AACGC,MAAAA,MAAM,GAA0BA,CAAC;AACrCC,EAAAA,eAAe,GAAG,IAAI;AACtBC,EAAAA,mBAAmB,GAAG,IAAI;AAC1BC,EAAAA,QAAQ,GAAG,IAAI;EACfC,SAAS;AACTC,EAAAA,QAAQ,GAAG,KAAK;EAChBN,IAAI,EAAEO,aAAa,GAAG,EAAE;EACxBC,KAAK,GAAGC,KAAK,CAACC,KAAK;AACnBC,EAAAA,IAAI,GAAG,WAAW;AAClB,EAAA,YAAY,EAAEC,SAAAA;AAAS,CACxB,KAAI;EACH,MAAMC,uBAAuB,GAAGC,OAAO,CACrC,MACE,CAACZ,eAAe,IAAIC,mBAAmB,GACnCY,qBAAqB,CAACZ,mBAAmB,CAAC,GAC1Ca,SAAS,EACf,CAACd,eAAe,EAAEC,mBAAmB,CAAC,CACvC,CAAA;AAED,EAAA,MAAMH,IAAI,GAAGD,uBAAuB,CAACQ,aAAa,CAAC,CAAA;AAEnD,EAAA,oBACEU,GAAA,CAAA,KAAA,EAAA;AACEZ,IAAAA,SAAS,EAAEa,IAAI,CAAC,WAAW,EAAEb,SAAS,EAAE,CAAcL,WAAAA,EAAAA,IAAI,CAAE,CAAA,EAAE,CAAcW,WAAAA,EAAAA,IAAI,EAAE,EAAE;AAClF,MAAA,qBAAqB,EAAEL,QAAQ;AAC/B,MAAA,oBAAoB,EAAEa,OAAO,CAACN,uBAAuB,CAAC;MACtD,oBAAoB,EAAEF,IAAI,KAAK,UAAA;AAChC,KAAA,CAAE;AACH,IAAA,YAAA,EAAYC,SAAU;AAAAR,IAAAA,QAAA,eAEtBa,GAAA,CAAA,KAAA,EAAA;AACEZ,MAAAA,SAAS,EAAC,oBAAoB;AAC9Be,MAAAA,KAAK,EAAE;QACLlB,eAAe,EAAEA,eAAe,IAAIW,uBAAAA;OACpC;AAAAT,MAAAA,QAAA,EAEDA,QAAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
@@ -0,0 +1,170 @@
1
+ 'use strict';
2
+
3
+ var Badge = require('../badge/Badge.js');
4
+ var BadgeAssets = require('../badge/BadgeAssets.js');
5
+ var NotificationDot = require('./NotificationDot.js');
6
+ var Circle = require('../common/circle/Circle.js');
7
+ var Image = require('../image/Image.js');
8
+ var React = require('react');
9
+ var clsx = require('clsx');
10
+ require('../common/theme.js');
11
+ require('../common/direction.js');
12
+ require('../common/propsValues/control.js');
13
+ require('../common/propsValues/breakpoint.js');
14
+ require('../common/propsValues/size.js');
15
+ require('../common/propsValues/typography.js');
16
+ require('../common/propsValues/width.js');
17
+ require('../common/propsValues/type.js');
18
+ require('../common/propsValues/dateMode.js');
19
+ require('../common/propsValues/monthFormat.js');
20
+ require('../common/propsValues/position.js');
21
+ require('../common/propsValues/layouts.js');
22
+ require('../common/propsValues/status.js');
23
+ require('../common/propsValues/sentiment.js');
24
+ var profileType = require('../common/propsValues/profileType.js');
25
+ require('../common/propsValues/variant.js');
26
+ require('../common/propsValues/scroll.js');
27
+ require('../common/propsValues/markdownNodeType.js');
28
+ require('../common/fileType.js');
29
+ var initials = require('../common/initials.js');
30
+ var icons = require('@transferwise/icons');
31
+ require('react-intl');
32
+ require('../common/closeButton/CloseButton.messages.js');
33
+ var jsxRuntime = require('react/jsx-runtime');
34
+
35
+ function AvatarView({
36
+ children = undefined,
37
+ size = 48,
38
+ selected,
39
+ notification,
40
+ badge,
41
+ interactive = false,
42
+ className,
43
+ style,
44
+ imgSrc,
45
+ profileType: type,
46
+ profileName: name,
47
+ ...restProps
48
+ }) {
49
+ return /*#__PURE__*/jsxRuntime.jsx(Circle, {
50
+ size: size,
51
+ fixedSize: true,
52
+ className: clsx.clsx('np-avatar-view', interactive ? 'np-avatar-view-interactive' : 'np-avatar-view-non-interactive', {
53
+ 'np-avatar-view-selected': selected
54
+ }, className),
55
+ ...restProps,
56
+ children: /*#__PURE__*/jsxRuntime.jsx(Badges, {
57
+ avatar: {
58
+ size,
59
+ notification,
60
+ selected
61
+ },
62
+ ...badge,
63
+ children: /*#__PURE__*/jsxRuntime.jsx(Circle, {
64
+ size: size,
65
+ fixedSize: true,
66
+ className: clsx.clsx('np-avatar-view-content'),
67
+ enableBorder: !interactive || selected,
68
+ style: {
69
+ ...(selected && {
70
+ '--circle-border-color': 'var(--color-interactive-primary)'
71
+ }),
72
+ ...style
73
+ },
74
+ children: children === undefined ? /*#__PURE__*/jsxRuntime.jsx(AvatarViewContent, {
75
+ imgSrc,
76
+ profileType: type,
77
+ profileName: name
78
+ }) : children
79
+ })
80
+ })
81
+ });
82
+ }
83
+ /** Size of badge depends on size of avatar */
84
+ const MAP_BADGE_ASSET_SIZE = {
85
+ 16: 16,
86
+ 24: 16,
87
+ 32: 16,
88
+ 40: 16,
89
+ 48: 16,
90
+ 56: 24,
91
+ 72: 24
92
+ };
93
+ /** Certain sizes of AvatarView has a custom offset of Badge */
94
+ const MAP_BADGE_POSITION = {
95
+ 24: -6,
96
+ 32: -4
97
+ };
98
+ /**
99
+ * Adds build-in badges to AvatarView
100
+ */
101
+ function Badges({
102
+ children,
103
+ avatar,
104
+ 'aria-label': ariaLabel,
105
+ asset: customBadge,
106
+ ...badgeAssets
107
+ }) {
108
+ const {
109
+ size = 48,
110
+ selected,
111
+ notification
112
+ } = avatar;
113
+ const anyBadge = Object.values({
114
+ customBadge,
115
+ ...badgeAssets
116
+ }).filter(Boolean).length > 0;
117
+ if ((anyBadge || selected) && size > 16) {
118
+ const badgeSize = MAP_BADGE_ASSET_SIZE[size];
119
+ return /*#__PURE__*/jsxRuntime.jsx(Badge, {
120
+ "aria-label": ariaLabel,
121
+ size: badgeSize,
122
+ badge: customBadge ? /*#__PURE__*/jsxRuntime.jsx(Circle, {
123
+ fixedSize: true,
124
+ size: badgeSize,
125
+ children: customBadge
126
+ }) : /*#__PURE__*/jsxRuntime.jsx(BadgeAssets, {
127
+ ...(selected ? {
128
+ status: 'positive'
129
+ } : badgeAssets),
130
+ size: badgeSize
131
+ }),
132
+ style: {
133
+ // @ts-expect-error CSS custom props allowed
134
+ '--badge-content-position': `${MAP_BADGE_POSITION[size] ?? 0}px`
135
+ },
136
+ children: children
137
+ });
138
+ }
139
+ if (notification) {
140
+ return /*#__PURE__*/jsxRuntime.jsx(NotificationDot, {
141
+ avatarSize: size,
142
+ children: children
143
+ });
144
+ }
145
+ return children;
146
+ }
147
+ function AvatarViewContent({
148
+ imgSrc,
149
+ profileName: name,
150
+ profileType: type
151
+ }) {
152
+ const [tryLoadImage, setTryLoadImage] = React.useState(true);
153
+ if (imgSrc && tryLoadImage) {
154
+ return /*#__PURE__*/jsxRuntime.jsx(Image.default, {
155
+ src: imgSrc,
156
+ alt: "",
157
+ onError: () => setTryLoadImage(false)
158
+ });
159
+ }
160
+ if (type) {
161
+ return type === profileType.ProfileType.BUSINESS ? /*#__PURE__*/jsxRuntime.jsx(icons.Briefcase, {}) : /*#__PURE__*/jsxRuntime.jsx(icons.Profile, {});
162
+ }
163
+ if (name) {
164
+ return initials.getInitials(name);
165
+ }
166
+ return /*#__PURE__*/jsxRuntime.jsx(icons.Profile, {});
167
+ }
168
+
169
+ module.exports = AvatarView;
170
+ //# sourceMappingURL=AvatarView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvatarView.js","sources":["../../src/avatarView/AvatarView.tsx"],"sourcesContent":["import Badge, { BadgeAssets, BadgeProps, BadgeAssetsProps } from '../badge';\nimport NotificationDot from './NotificationDot';\nimport Circle from '../common/circle';\nimport Image from '../image';\nimport { HTMLAttributes, PropsWithChildren, useState } from 'react';\nimport { clsx } from 'clsx';\nimport { getInitials, ProfileType, ProfileTypeBusiness, ProfileTypePersonal } from '../common';\nimport {\n Briefcase as BusinessProfileIcon,\n Profile as PersonalProfileIcon,\n} from '@transferwise/icons';\n\nexport type AvatarViewBadgeProps = BadgeAssetsProps &\n Pick<BadgeProps, 'aria-label'> & {\n /**\n * Custom badge content\n */\n asset?: React.ReactNode;\n };\n\nexport type Props = {\n imgSrc?: string | null;\n /**\n * Entity name (person (profile or recipient) or business name), it will be boilded down to 1 or 2 chars (initials)\n */\n profileName?: string | null;\n profileType?: ProfileTypeBusiness | ProfileTypePersonal;\n size?: 16 | 24 | 32 | 40 | 48 | 56 | 72;\n notification?: boolean;\n badge?: AvatarViewBadgeProps;\n interactive?: boolean;\n selected?: boolean;\n style?: Pick<React.CSSProperties, 'border' | 'backgroundColor' | 'color'>;\n} & Pick<\n HTMLAttributes<HTMLDivElement>,\n 'className' | 'children' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-hidden'\n>;\n\nfunction AvatarView({\n children = undefined,\n size = 48,\n selected,\n notification,\n badge,\n interactive = false,\n className,\n style,\n imgSrc,\n profileType: type,\n profileName: name,\n ...restProps\n}: Props) {\n return (\n <Circle\n size={size}\n fixedSize\n className={clsx(\n 'np-avatar-view',\n interactive ? 'np-avatar-view-interactive' : 'np-avatar-view-non-interactive',\n { 'np-avatar-view-selected': selected },\n className,\n )}\n {...restProps}\n >\n <Badges avatar={{ size, notification, selected }} {...badge}>\n <Circle\n size={size}\n fixedSize\n className={clsx('np-avatar-view-content')}\n enableBorder={!interactive || selected}\n style={{\n ...(selected && { '--circle-border-color': 'var(--color-interactive-primary)' }),\n ...style,\n }}\n >\n {children === undefined ? (\n <AvatarViewContent {...{ imgSrc, profileType: type, profileName: name }} />\n ) : (\n children\n )}\n </Circle>\n </Badges>\n </Circle>\n );\n}\n\n/** Size of badge depends on size of avatar */\nconst MAP_BADGE_ASSET_SIZE = {\n 16: 16,\n 24: 16,\n 32: 16,\n 40: 16,\n 48: 16,\n 56: 24,\n 72: 24,\n} satisfies Record<number, BadgeAssetsProps['size']>;\n\n/** Certain sizes of AvatarView has a custom offset of Badge */\nconst MAP_BADGE_POSITION = {\n 24: -6,\n 32: -4,\n};\n\ntype BadgesProps = AvatarViewBadgeProps &\n PropsWithChildren<{\n avatar: Pick<Props, 'selected' | 'size' | 'notification'>;\n }>;\n\n/**\n * Adds build-in badges to AvatarView\n */\nfunction Badges({\n children,\n avatar,\n 'aria-label': ariaLabel,\n asset: customBadge,\n ...badgeAssets\n}: BadgesProps) {\n const { size = 48, selected, notification } = avatar;\n const anyBadge = Object.values({ customBadge, ...badgeAssets }).filter(Boolean).length > 0;\n if ((anyBadge || selected) && size > 16) {\n const badgeSize: BadgeAssetsProps['size'] = MAP_BADGE_ASSET_SIZE[size];\n return (\n <Badge\n aria-label={ariaLabel}\n size={badgeSize}\n badge={\n customBadge ? (\n <Circle fixedSize size={badgeSize}>\n {customBadge}\n </Circle>\n ) : (\n <BadgeAssets {...(selected ? { status: 'positive' } : badgeAssets)} size={badgeSize} />\n )\n }\n style={{\n // @ts-expect-error CSS custom props allowed\n '--badge-content-position': `${MAP_BADGE_POSITION[size] ?? 0}px`,\n }}\n >\n {children}\n </Badge>\n );\n }\n if (notification) {\n return <NotificationDot avatarSize={size}>{children}</NotificationDot>;\n }\n return children;\n}\n\nfunction AvatarViewContent({\n imgSrc,\n profileName: name,\n profileType: type,\n}: Pick<Props, 'imgSrc' | 'name' | 'type'>) {\n const [tryLoadImage, setTryLoadImage] = useState(true);\n if (imgSrc && tryLoadImage) {\n return <Image src={imgSrc} alt=\"\" onError={() => setTryLoadImage(false)} />;\n }\n if (type) {\n return type === ProfileType.BUSINESS ? <BusinessProfileIcon /> : <PersonalProfileIcon />;\n }\n if (name) {\n return getInitials(name);\n }\n return <PersonalProfileIcon />;\n}\n\nexport default AvatarView;\n"],"names":["AvatarView","children","undefined","size","selected","notification","badge","interactive","className","style","imgSrc","profileType","type","profileName","name","restProps","_jsx","Circle","fixedSize","clsx","Badges","avatar","enableBorder","AvatarViewContent","MAP_BADGE_ASSET_SIZE","MAP_BADGE_POSITION","ariaLabel","asset","customBadge","badgeAssets","anyBadge","Object","values","filter","Boolean","length","badgeSize","Badge","BadgeAssets","status","NotificationDot","avatarSize","tryLoadImage","setTryLoadImage","useState","Image","src","alt","onError","ProfileType","BUSINESS","BusinessProfileIcon","PersonalProfileIcon","getInitials"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAASA,UAAUA,CAAC;AAClBC,EAAAA,QAAQ,GAAGC,SAAS;AACpBC,EAAAA,IAAI,GAAG,EAAE;EACTC,QAAQ;EACRC,YAAY;EACZC,KAAK;AACLC,EAAAA,WAAW,GAAG,KAAK;EACnBC,SAAS;EACTC,KAAK;EACLC,MAAM;AACNC,EAAAA,WAAW,EAAEC,IAAI;AACjBC,EAAAA,WAAW,EAAEC,IAAI;EACjB,GAAGC,SAAAA;AACG,CAAA,EAAA;EACN,oBACEC,cAAA,CAACC,MAAM,EAAA;AACLd,IAAAA,IAAI,EAAEA,IAAK;IACXe,SAAS,EAAA,IAAA;IACTV,SAAS,EAAEW,SAAI,CACb,gBAAgB,EAChBZ,WAAW,GAAG,4BAA4B,GA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AA;AAEZ,GAAA;AACA,EAAA,IAAII,YAAY,EAAE;IAChB,oBAAOW,cAAA,CAACwB,eAAe,EAAA;AAACC,MAAAA,UAAU,EAAEtC,IAAK;AAAAF,MAAAA,QAAA,EAAEA,QAAAA;AAAQ,KAAkB,CAAC,CAAA;AACxE,GAAA;AACA,EAAA,OAAOA,QAAQ,CAAA;AACjB,CAAA;AAEA,SAASsB,iBAAiBA,CAAC;EACzBb,MAAM;AACNG,EAAAA,WAAW,EAAEC,IAAI;AACjBH,EAAAA,WAAW,EAAEC,IAAAA;AAC2B,CAAA,EAAA;EACxC,MAAM,CAAC8B,YAAY,EAAEC,eAAe,CAAC,GAAGC,cAAQ,CAAC,IAAI,CAAC,CAAA;EACtD,IAAIlC,MAAM,IAAIgC,YAAY,EAAE;IAC1B,oBAAO1B,cAAA,CAAC6B,aAAK,EAAA;AAACC,MAAAA,GAAG,EAAEpC,MAAO;AAACqC,MAAAA,GAAG,EAAC,EAAE;AAACC,MAAAA,OAAO,EAAEA,MAAML,eAAe,CAAC,KAAK,CAAA;AAAE,KAAA,CAAG,CAAA;AAC7E,GAAA;AACA,EAAA,IAAI/B,IAAI,EAAE;AACR,IAAA,OAAOA,IAAI,KAAKqC,uBAAW,CAACC,QAAQ,gBAAGlC,cAAA,CAACmC,eAAmB,EAAA,EAAA,CAAG,gBAAGnC,cAAA,CAACoC,aAAmB,IAAA,CAAG,CAAA;AAC1F,GAAA;AACA,EAAA,IAAItC,IAAI,EAAE;IACR,OAAOuC,oBAAW,CAACvC,IAAI,CAAC,CAAA;AAC1B,GAAA;AACA,EAAA,oBAAOE,cAAA,CAACoC,aAAmB,EAAA,GAAG,CAAA;AAChC;;;;"}
@@ -0,0 +1,168 @@
1
+ import Badge from '../badge/Badge.mjs';
2
+ import BadgeAssets from '../badge/BadgeAssets.mjs';
3
+ import NotificationDot from './NotificationDot.mjs';
4
+ import Circle from '../common/circle/Circle.mjs';
5
+ import Image from '../image/Image.mjs';
6
+ import { useState } from 'react';
7
+ import { clsx } from 'clsx';
8
+ import '../common/theme.mjs';
9
+ import '../common/direction.mjs';
10
+ import '../common/propsValues/control.mjs';
11
+ import '../common/propsValues/breakpoint.mjs';
12
+ import '../common/propsValues/size.mjs';
13
+ import '../common/propsValues/typography.mjs';
14
+ import '../common/propsValues/width.mjs';
15
+ import '../common/propsValues/type.mjs';
16
+ import '../common/propsValues/dateMode.mjs';
17
+ import '../common/propsValues/monthFormat.mjs';
18
+ import '../common/propsValues/position.mjs';
19
+ import '../common/propsValues/layouts.mjs';
20
+ import '../common/propsValues/status.mjs';
21
+ import '../common/propsValues/sentiment.mjs';
22
+ import { ProfileType } from '../common/propsValues/profileType.mjs';
23
+ import '../common/propsValues/variant.mjs';
24
+ import '../common/propsValues/scroll.mjs';
25
+ import '../common/propsValues/markdownNodeType.mjs';
26
+ import '../common/fileType.mjs';
27
+ import { getInitials } from '../common/initials.mjs';
28
+ import { Briefcase, Profile } from '@transferwise/icons';
29
+ import 'react-intl';
30
+ import '../common/closeButton/CloseButton.messages.mjs';
31
+ import { jsx } from 'react/jsx-runtime';
32
+
33
+ function AvatarView({
34
+ children = undefined,
35
+ size = 48,
36
+ selected,
37
+ notification,
38
+ badge,
39
+ interactive = false,
40
+ className,
41
+ style,
42
+ imgSrc,
43
+ profileType: type,
44
+ profileName: name,
45
+ ...restProps
46
+ }) {
47
+ return /*#__PURE__*/jsx(Circle, {
48
+ size: size,
49
+ fixedSize: true,
50
+ className: clsx('np-avatar-view', interactive ? 'np-avatar-view-interactive' : 'np-avatar-view-non-interactive', {
51
+ 'np-avatar-view-selected': selected
52
+ }, className),
53
+ ...restProps,
54
+ children: /*#__PURE__*/jsx(Badges, {
55
+ avatar: {
56
+ size,
57
+ notification,
58
+ selected
59
+ },
60
+ ...badge,
61
+ children: /*#__PURE__*/jsx(Circle, {
62
+ size: size,
63
+ fixedSize: true,
64
+ className: clsx('np-avatar-view-content'),
65
+ enableBorder: !interactive || selected,
66
+ style: {
67
+ ...(selected && {
68
+ '--circle-border-color': 'var(--color-interactive-primary)'
69
+ }),
70
+ ...style
71
+ },
72
+ children: children === undefined ? /*#__PURE__*/jsx(AvatarViewContent, {
73
+ imgSrc,
74
+ profileType: type,
75
+ profileName: name
76
+ }) : children
77
+ })
78
+ })
79
+ });
80
+ }
81
+ /** Size of badge depends on size of avatar */
82
+ const MAP_BADGE_ASSET_SIZE = {
83
+ 16: 16,
84
+ 24: 16,
85
+ 32: 16,
86
+ 40: 16,
87
+ 48: 16,
88
+ 56: 24,
89
+ 72: 24
90
+ };
91
+ /** Certain sizes of AvatarView has a custom offset of Badge */
92
+ const MAP_BADGE_POSITION = {
93
+ 24: -6,
94
+ 32: -4
95
+ };
96
+ /**
97
+ * Adds build-in badges to AvatarView
98
+ */
99
+ function Badges({
100
+ children,
101
+ avatar,
102
+ 'aria-label': ariaLabel,
103
+ asset: customBadge,
104
+ ...badgeAssets
105
+ }) {
106
+ const {
107
+ size = 48,
108
+ selected,
109
+ notification
110
+ } = avatar;
111
+ const anyBadge = Object.values({
112
+ customBadge,
113
+ ...badgeAssets
114
+ }).filter(Boolean).length > 0;
115
+ if ((anyBadge || selected) && size > 16) {
116
+ const badgeSize = MAP_BADGE_ASSET_SIZE[size];
117
+ return /*#__PURE__*/jsx(Badge, {
118
+ "aria-label": ariaLabel,
119
+ size: badgeSize,
120
+ badge: customBadge ? /*#__PURE__*/jsx(Circle, {
121
+ fixedSize: true,
122
+ size: badgeSize,
123
+ children: customBadge
124
+ }) : /*#__PURE__*/jsx(BadgeAssets, {
125
+ ...(selected ? {
126
+ status: 'positive'
127
+ } : badgeAssets),
128
+ size: badgeSize
129
+ }),
130
+ style: {
131
+ // @ts-expect-error CSS custom props allowed
132
+ '--badge-content-position': `${MAP_BADGE_POSITION[size] ?? 0}px`
133
+ },
134
+ children: children
135
+ });
136
+ }
137
+ if (notification) {
138
+ return /*#__PURE__*/jsx(NotificationDot, {
139
+ avatarSize: size,
140
+ children: children
141
+ });
142
+ }
143
+ return children;
144
+ }
145
+ function AvatarViewContent({
146
+ imgSrc,
147
+ profileName: name,
148
+ profileType: type
149
+ }) {
150
+ const [tryLoadImage, setTryLoadImage] = useState(true);
151
+ if (imgSrc && tryLoadImage) {
152
+ return /*#__PURE__*/jsx(Image, {
153
+ src: imgSrc,
154
+ alt: "",
155
+ onError: () => setTryLoadImage(false)
156
+ });
157
+ }
158
+ if (type) {
159
+ return type === ProfileType.BUSINESS ? /*#__PURE__*/jsx(Briefcase, {}) : /*#__PURE__*/jsx(Profile, {});
160
+ }
161
+ if (name) {
162
+ return getInitials(name);
163
+ }
164
+ return /*#__PURE__*/jsx(Profile, {});
165
+ }
166
+
167
+ export { AvatarView as default };
168
+ //# sourceMappingURL=AvatarView.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvatarView.mjs","sources":["../../src/avatarView/AvatarView.tsx"],"sourcesContent":["import Badge, { BadgeAssets, BadgeProps, BadgeAssetsProps } from '../badge';\nimport NotificationDot from './NotificationDot';\nimport Circle from '../common/circle';\nimport Image from '../image';\nimport { HTMLAttributes, PropsWithChildren, useState } from 'react';\nimport { clsx } from 'clsx';\nimport { getInitials, ProfileType, ProfileTypeBusiness, ProfileTypePersonal } from '../common';\nimport {\n Briefcase as BusinessProfileIcon,\n Profile as PersonalProfileIcon,\n} from '@transferwise/icons';\n\nexport type AvatarViewBadgeProps = BadgeAssetsProps &\n Pick<BadgeProps, 'aria-label'> & {\n /**\n * Custom badge content\n */\n asset?: React.ReactNode;\n };\n\nexport type Props = {\n imgSrc?: string | null;\n /**\n * Entity name (person (profile or recipient) or business name), it will be boilded down to 1 or 2 chars (initials)\n */\n profileName?: string | null;\n profileType?: ProfileTypeBusiness | ProfileTypePersonal;\n size?: 16 | 24 | 32 | 40 | 48 | 56 | 72;\n notification?: boolean;\n badge?: AvatarViewBadgeProps;\n interactive?: boolean;\n selected?: boolean;\n style?: Pick<React.CSSProperties, 'border' | 'backgroundColor' | 'color'>;\n} & Pick<\n HTMLAttributes<HTMLDivElement>,\n 'className' | 'children' | 'role' | 'aria-label' | 'aria-labelledby' | 'aria-hidden'\n>;\n\nfunction AvatarView({\n children = undefined,\n size = 48,\n selected,\n notification,\n badge,\n interactive = false,\n className,\n style,\n imgSrc,\n profileType: type,\n profileName: name,\n ...restProps\n}: Props) {\n return (\n <Circle\n size={size}\n fixedSize\n className={clsx(\n 'np-avatar-view',\n interactive ? 'np-avatar-view-interactive' : 'np-avatar-view-non-interactive',\n { 'np-avatar-view-selected': selected },\n className,\n )}\n {...restProps}\n >\n <Badges avatar={{ size, notification, selected }} {...badge}>\n <Circle\n size={size}\n fixedSize\n className={clsx('np-avatar-view-content')}\n enableBorder={!interactive || selected}\n style={{\n ...(selected && { '--circle-border-color': 'var(--color-interactive-primary)' }),\n ...style,\n }}\n >\n {children === undefined ? (\n <AvatarViewContent {...{ imgSrc, profileType: type, profileName: name }} />\n ) : (\n children\n )}\n </Circle>\n </Badges>\n </Circle>\n );\n}\n\n/** Size of badge depends on size of avatar */\nconst MAP_BADGE_ASSET_SIZE = {\n 16: 16,\n 24: 16,\n 32: 16,\n 40: 16,\n 48: 16,\n 56: 24,\n 72: 24,\n} satisfies Record<number, BadgeAssetsProps['size']>;\n\n/** Certain sizes of AvatarView has a custom offset of Badge */\nconst MAP_BADGE_POSITION = {\n 24: -6,\n 32: -4,\n};\n\ntype BadgesProps = AvatarViewBadgeProps &\n PropsWithChildren<{\n avatar: Pick<Props, 'selected' | 'size' | 'notification'>;\n }>;\n\n/**\n * Adds build-in badges to AvatarView\n */\nfunction Badges({\n children,\n avatar,\n 'aria-label': ariaLabel,\n asset: customBadge,\n ...badgeAssets\n}: BadgesProps) {\n const { size = 48, selected, notification } = avatar;\n const anyBadge = Object.values({ customBadge, ...badgeAssets }).filter(Boolean).length > 0;\n if ((anyBadge || selected) && size > 16) {\n const badgeSize: BadgeAssetsProps['size'] = MAP_BADGE_ASSET_SIZE[size];\n return (\n <Badge\n aria-label={ariaLabel}\n size={badgeSize}\n badge={\n customBadge ? (\n <Circle fixedSize size={badgeSize}>\n {customBadge}\n </Circle>\n ) : (\n <BadgeAssets {...(selected ? { status: 'positive' } : badgeAssets)} size={badgeSize} />\n )\n }\n style={{\n // @ts-expect-error CSS custom props allowed\n '--badge-content-position': `${MAP_BADGE_POSITION[size] ?? 0}px`,\n }}\n >\n {children}\n </Badge>\n );\n }\n if (notification) {\n return <NotificationDot avatarSize={size}>{children}</NotificationDot>;\n }\n return children;\n}\n\nfunction AvatarViewContent({\n imgSrc,\n profileName: name,\n profileType: type,\n}: Pick<Props, 'imgSrc' | 'name' | 'type'>) {\n const [tryLoadImage, setTryLoadImage] = useState(true);\n if (imgSrc && tryLoadImage) {\n return <Image src={imgSrc} alt=\"\" onError={() => setTryLoadImage(false)} />;\n }\n if (type) {\n return type === ProfileType.BUSINESS ? <BusinessProfileIcon /> : <PersonalProfileIcon />;\n }\n if (name) {\n return getInitials(name);\n }\n return <PersonalProfileIcon />;\n}\n\nexport default AvatarView;\n"],"names":["AvatarView","children","undefined","size","selected","notification","badge","interactive","className","style","imgSrc","profileType","type","profileName","name","restProps","_jsx","Circle","fixedSize","clsx","Badges","avatar","enableBorder","AvatarViewContent","MAP_BADGE_ASSET_SIZE","MAP_BADGE_POSITION","ariaLabel","asset","customBadge","badgeAssets","anyBadge","Object","values","filter","Boolean","length","badgeSize","Badge","BadgeAssets","status","NotificationDot","avatarSize","tryLoadImage","setTryLoadImage","useState","Image","src","alt","onError","ProfileType","BUSINESS","BusinessProfileIcon","PersonalProfileIcon","getInitials"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAASA,UAAUA,CAAC;AAClBC,EAAAA,QAAQ,GAAGC,SAAS;AACpBC,EAAAA,IAAI,GAAG,EAAE;EACTC,QAAQ;EACRC,YAAY;EACZC,KAAK;AACLC,EAAAA,WAAW,GAAG,KAAK;EACnBC,SAAS;EACTC,KAAK;EACLC,MAAM;AACNC,EAAAA,WAAW,EAAEC,IAAI;AACjB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C,OAAmB,EAAA,GAAG,CAAA;AAChC;;;;"}
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+
5
+ /**
6
+ * Depending on avatar size, notifcation dot size and offset are different
7
+ */
8
+ const MAP_STYLE_CONFIG = {
9
+ 16: {
10
+ size: 6,
11
+ offset: 1
12
+ },
13
+ 24: {
14
+ size: 8,
15
+ offset: 2
16
+ },
17
+ 32: {
18
+ size: 10,
19
+ offset: 2
20
+ },
21
+ 40: {
22
+ size: 10,
23
+ offset: 2
24
+ },
25
+ 48: {
26
+ size: 14,
27
+ offset: 2
28
+ },
29
+ 56: {
30
+ size: 16,
31
+ offset: 3
32
+ },
33
+ 72: {
34
+ size: 20,
35
+ offset: 3
36
+ }
37
+ };
38
+ function NotificationDot({
39
+ children,
40
+ avatarSize = 48
41
+ }) {
42
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
43
+ className: "np-notification-dot",
44
+ style: {
45
+ // @ts-expect-error CSS custom props allowed
46
+ '--np-notification-dot-size': `${MAP_STYLE_CONFIG[avatarSize].size}px`,
47
+ '--np-notification-dot-offset': `${MAP_STYLE_CONFIG[avatarSize].offset}px`
48
+ },
49
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
50
+ className: "np-notification-dot-badge"
51
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
52
+ className: "np-notification-dot-mask",
53
+ children: children
54
+ })]
55
+ });
56
+ }
57
+
58
+ module.exports = NotificationDot;
59
+ //# sourceMappingURL=NotificationDot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationDot.js","sources":["../../src/avatarView/NotificationDot.tsx"],"sourcesContent":["import { HTMLAttributes } from 'react';\nimport { Props as AvatarViewProps } from './AvatarView';\n\ntype Props = Pick<HTMLAttributes<HTMLDivElement>, 'children'> & {\n avatarSize?: AvatarViewProps['size'];\n};\n\n/**\n * Depending on avatar size, notifcation dot size and offset are different\n */\nconst MAP_STYLE_CONFIG = {\n 16: { size: 6, offset: 1 },\n 24: { size: 8, offset: 2 },\n 32: { size: 10, offset: 2 },\n 40: { size: 10, offset: 2 },\n 48: { size: 14, offset: 2 },\n 56: { size: 16, offset: 3 },\n 72: { size: 20, offset: 3 },\n};\n\nexport default function NotificationDot({ children, avatarSize = 48 }: Props) {\n return (\n <div\n className=\"np-notification-dot\"\n style={{\n // @ts-expect-error CSS custom props allowed\n '--np-notification-dot-size': `${MAP_STYLE_CONFIG[avatarSize].size}px`,\n '--np-notification-dot-offset': `${MAP_STYLE_CONFIG[avatarSize].offset}px`,\n }}\n >\n <div className=\"np-notification-dot-badge\" />\n <div className=\"np-notification-dot-mask\">{children}</div>\n </div>\n );\n}\n"],"names":["MAP_STYLE_CONFIG","size","offset","NotificationDot","children","avatarSize","_jsxs","className","style","_jsx"],"mappings":";;;;AAOA;;AAEG;AACH,MAAMA,gBAAgB,GAAG;AACvB,EAAA,EAAE,EAAE;AAAEC,IAAAA,IAAI,EAAE,CAAC;AAAEC,IAAAA,MAAM,EAAE,CAAA;GAAG;AAC1B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,CAAC;AAAEC,IAAAA,MAAM,EAAE,CAAA;GAAG;AAC1B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE,CAAA;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE,CAAA;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE,CAAA;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE,CAAA;GAAG;AAC3B,EAAA,EAAE,EAAE;AAAED,IAAAA,IAAI,EAAE,EAAE;AAAEC,IAAAA,MAAM,EAAE,CAAA;AAAG,GAAA;CAC5B,CAAA;AAEa,SAAUC,eAAeA,CAAC;EAAEC,QAAQ;AAAEC,EAAAA,UAAU,GAAG,EAAA;AAAW,CAAA,EAAA;AAC1E,EAAA,oBACEC,eAAA,CAAA,KAAA,EAAA;AACEC,IAAAA,SAAS,EAAC,qBAAqB;AAC/BC,IAAAA,KAAK,EAAE;AACL;MACA,4BAA4B,EAAE,GAAGR,gBAAgB,CAACK,UAAU,CAAC,CAACJ,IAAI,CAAI,EAAA,CAAA;AACtE,MAAA,8BAA8B,EAAE,CAAGD,EAAAA,gBAAgB,CAACK,UAAU,CAAC,CAACH,MAAM,CAAA,EAAA,CAAA;KACtE;AAAAE,IAAAA,QAAA,gBAEFK,cAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,2BAAA;KACf,CAAA,eAAAE,cAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,0BAA0B;AAAAH,MAAAA,QAAA,EAAEA,QAAAA;AAAQ,KAAM,CAC3D,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV;;;;"}
@@ -0,0 +1,57 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+
3
+ /**
4
+ * Depending on avatar size, notifcation dot size and offset are different
5
+ */
6
+ const MAP_STYLE_CONFIG = {
7
+ 16: {
8
+ size: 6,
9
+ offset: 1
10
+ },
11
+ 24: {
12
+ size: 8,
13
+ offset: 2
14
+ },
15
+ 32: {
16
+ size: 10,
17
+ offset: 2
18
+ },
19
+ 40: {
20
+ size: 10,
21
+ offset: 2
22
+ },
23
+ 48: {
24
+ size: 14,
25
+ offset: 2
26
+ },
27
+ 56: {
28
+ size: 16,
29
+ offset: 3
30
+ },
31
+ 72: {
32
+ size: 20,
33
+ offset: 3
34
+ }
35
+ };
36
+ function NotificationDot({
37
+ children,
38
+ avatarSize = 48
39
+ }) {
40
+ return /*#__PURE__*/jsxs("div", {
41
+ className: "np-notification-dot",
42
+ style: {
43
+ // @ts-expect-error CSS custom props allowed
44
+ '--np-notification-dot-size': `${MAP_STYLE_CONFIG[avatarSize].size}px`,
45
+ '--np-notification-dot-offset': `${MAP_STYLE_CONFIG[avatarSize].offset}px`
46
+ },
47
+ children: [/*#__PURE__*/jsx("div", {
48
+ className: "np-notification-dot-badge"
49
+ }), /*#__PURE__*/jsx("div", {
50
+ className: "np-notification-dot-mask",
51
+ children: children
52
+ })]
53
+ });
54
+ }
55
+
56
+ export { NotificationDot as default };
57
+ //# sourceMappingURL=NotificationDot.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationDot.mjs","sources":["../../src/avatarView/NotificationDot.tsx"],"sourcesContent":["import { HTMLAttributes } from 'react';\nimport { Props as AvatarViewProps } from './AvatarView';\n\ntype Props = Pick<HTMLAttributes<HTMLDivElement>, 'children'> & {\n avatarSize?: AvatarViewProps['size'];\n};\n\n/**\n * Depending on avatar size, notifcation dot size and offset are different\n */\nconst MAP_STYLE_CONFIG = {\n 16: { size: 6, offset: 1 },\n 24: { size: 8, offset: 2 },\n 32: { size: 10, offset: 2 },\n 40: { size: 10, offset: 2 },\n 48: { size: 14, offset: 2 },\n 56: { size: 16, offset: 3 },\n 72: { size: 20, offset: 3 },\n};\n\nexport default function NotificationDot({ children, avatarSize = 48 }: Props) {\n return (\n <div\n className=\"np-notification-dot\"\n style={{\n // @ts-expect-error CSS custom props allowed\n '--np-notification-dot-size': `${MAP_STYLE_CONFIG[avatarSize].size}px`,\n '--np-notification-dot-offset': `${MAP_STYLE_CONFIG[avatarSize].offset}px`,\n }}\n >\n <div className=\"np-notification-dot-badge\" />\n <div className=\"np-notification-dot-mask\">{children}</div>\n </div>\n );\n}\n"],"names":["MAP_STYLE_CONFIG","size","offset","NotificationDot","children","avatarSize","_jsxs","className","style","_jsx"],"mappings":";;AAOA;;AAEG;AACH,MAAMA,gBAAgB,GAAG;AACvB,EAAA,EAAE,EAAE;AAAEC,IAAAA,IAAI,EAAE,CAAC;AAAEC,IAAAA,MAAM,EAAE,C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,CAAA;AAEV;;;;"}
@@ -5,10 +5,16 @@ var React = require('react');
5
5
  var avatarTypes = require('../avatar/avatarTypes.js');
6
6
  var Avatar = require('../avatar/Avatar.js');
7
7
  var Badge = require('../badge/Badge.js');
8
+ var StatusIcon = require('../statusIcon/StatusIcon.js');
9
+ require('@wise/art');
10
+ require('clsx');
11
+ require('../common/propsValues/breakpoint.js');
12
+ var jsxRuntime = require('react/jsx-runtime');
13
+ require('@transferwise/neptune-validation');
14
+ require('../provider/direction/DirectionProvider.js');
8
15
  require('../common/theme.js');
9
16
  require('../common/direction.js');
10
17
  require('../common/propsValues/control.js');
11
- require('../common/propsValues/breakpoint.js');
12
18
  var size = require('../common/propsValues/size.js');
13
19
  require('../common/propsValues/typography.js');
14
20
  require('../common/propsValues/width.js');
@@ -25,11 +31,8 @@ require('../common/propsValues/scroll.js');
25
31
  require('../common/propsValues/markdownNodeType.js');
26
32
  require('../common/fileType.js');
27
33
  var initials = require('../common/initials.js');
28
- require('clsx');
29
34
  require('react-intl');
30
35
  require('../common/closeButton/CloseButton.messages.js');
31
- var jsxRuntime = require('react/jsx-runtime');
32
- var StatusIcon = require('../statusIcon/StatusIcon.js');
33
36
 
34
37
  const OptionalBadge = ({
35
38
  url,
@@ -65,6 +68,9 @@ const OptionalBadge = ({
65
68
  children: children
66
69
  });
67
70
  };
71
+ /**
72
+ * @deprecated Use `AvatarView` component instead
73
+ */
68
74
  const AvatarWrapper = ({
69
75
  url,
70
76
  'aria-label': ariaLabel,