@transferwise/components 46.80.0 → 46.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/avatar/Avatar.js +3 -0
- package/build/avatar/Avatar.js.map +1 -1
- package/build/avatar/Avatar.mjs +3 -0
- package/build/avatar/Avatar.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +175 -0
- package/build/avatarView/AvatarView.js.map +1 -0
- package/build/avatarView/AvatarView.mjs +173 -0
- package/build/avatarView/AvatarView.mjs.map +1 -0
- package/build/avatarView/NotificationDot.js +59 -0
- package/build/avatarView/NotificationDot.js.map +1 -0
- package/build/avatarView/NotificationDot.mjs +57 -0
- package/build/avatarView/NotificationDot.mjs.map +1 -0
- package/build/avatarWrapper/AvatarWrapper.js +10 -4
- package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.mjs +10 -4
- package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
- package/build/badge/Badge.js +16 -4
- package/build/badge/Badge.js.map +1 -1
- package/build/badge/Badge.mjs +15 -3
- package/build/badge/Badge.mjs.map +1 -1
- package/build/badge/BadgeAssets.js +60 -0
- package/build/badge/BadgeAssets.js.map +1 -0
- package/build/badge/BadgeAssets.mjs +58 -0
- package/build/badge/BadgeAssets.mjs.map +1 -0
- package/build/common/circle/Circle.js +19 -1
- package/build/common/circle/Circle.js.map +1 -1
- package/build/common/circle/Circle.mjs +19 -1
- package/build/common/circle/Circle.mjs.map +1 -1
- package/build/i18n/en.json +5 -0
- package/build/i18n/en.json.js +5 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +5 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/i18n/zh-HK.json +5 -0
- package/build/i18n/zh-HK.json.js +5 -0
- package/build/i18n/zh-HK.json.js.map +1 -1
- package/build/i18n/zh-HK.json.mjs +5 -0
- package/build/i18n/zh-HK.json.mjs.map +1 -1
- package/build/index.js +18 -13
- package/build/index.js.map +1 -1
- package/build/index.mjs +10 -7
- package/build/index.mjs.map +1 -1
- package/build/main.css +348 -5
- package/build/money/Money.js +5 -2
- package/build/money/Money.js.map +1 -1
- package/build/money/Money.mjs +5 -2
- package/build/money/Money.mjs.map +1 -1
- package/build/styles/avatarView/AvatarView.css +36 -0
- package/build/styles/avatarView/NotificationDot.css +20 -0
- package/build/styles/badge/Badge.css +6 -5
- package/build/styles/common/circle/Circle.css +32 -0
- package/build/styles/main.css +348 -5
- package/build/styles/table/Table.css +274 -0
- package/build/types/avatar/Avatar.d.ts +3 -0
- package/build/types/avatar/Avatar.d.ts.map +1 -1
- package/build/types/avatarView/AvatarView.d.ts +26 -0
- package/build/types/avatarView/AvatarView.d.ts.map +1 -0
- package/build/types/avatarView/NotificationDot.d.ts +8 -0
- package/build/types/avatarView/NotificationDot.d.ts.map +1 -0
- package/build/types/avatarView/index.d.ts +3 -0
- package/build/types/avatarView/index.d.ts.map +1 -0
- package/build/types/avatarWrapper/AvatarWrapper.d.ts +3 -0
- package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
- package/build/types/badge/Badge.d.ts +9 -4
- package/build/types/badge/Badge.d.ts.map +1 -1
- package/build/types/badge/BadgeAssets.d.ts +14 -0
- package/build/types/badge/BadgeAssets.d.ts.map +1 -0
- package/build/types/badge/index.d.ts +2 -0
- package/build/types/badge/index.d.ts.map +1 -1
- package/build/types/common/circle/Circle.d.ts +2 -0
- package/build/types/common/circle/Circle.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/money/Money.d.ts +2 -1
- package/build/types/money/Money.d.ts.map +1 -1
- package/build/types/table/Table.d.ts +23 -0
- package/build/types/table/Table.d.ts.map +1 -0
- package/build/types/table/Table.messages.d.ts +24 -0
- package/build/types/table/Table.messages.d.ts.map +1 -0
- package/build/types/table/TableCell.d.ts +40 -0
- package/build/types/table/TableCell.d.ts.map +1 -0
- package/build/types/table/TableHeader.d.ts +13 -0
- package/build/types/table/TableHeader.d.ts.map +1 -0
- package/build/types/table/TableRow.d.ts +17 -0
- package/build/types/table/TableRow.d.ts.map +1 -0
- package/build/types/table/TableStatusText.d.ts +10 -0
- package/build/types/table/TableStatusText.d.ts.map +1 -0
- package/build/types/table/index.d.ts +6 -0
- package/build/types/table/index.d.ts.map +1 -0
- package/build/types/test-utils/index.d.ts +10 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/avatar/Avatar.tsx +3 -0
- package/src/avatarView/AvatarView.css +36 -0
- package/src/avatarView/AvatarView.less +27 -0
- package/src/avatarView/AvatarView.story.tsx +467 -0
- package/src/avatarView/AvatarView.tsx +171 -0
- package/src/avatarView/NotificationDot.css +20 -0
- package/src/avatarView/NotificationDot.less +24 -0
- package/src/avatarView/NotificationDot.tsx +35 -0
- package/src/avatarView/index.ts +2 -0
- package/src/avatarWrapper/AvatarWrapper.story.tsx +19 -0
- package/src/avatarWrapper/AvatarWrapper.tsx +3 -0
- package/src/badge/Badge.css +6 -5
- package/src/badge/Badge.less +4 -3
- package/src/badge/Badge.tsx +20 -6
- package/src/badge/BadgeAssets.tsx +61 -0
- package/src/badge/index.ts +3 -0
- package/src/circularButton/CircularButton.spec.tsx +0 -36
- package/src/common/circle/Circle.css +32 -0
- package/src/common/circle/Circle.less +35 -0
- package/src/common/circle/Circle.tsx +24 -1
- package/src/flowNavigation/FlowNavigation.story.tsx +19 -52
- package/src/i18n/en.json +5 -0
- package/src/i18n/zh-HK.json +5 -0
- package/src/index.ts +3 -0
- package/src/listItem/ListItem.story.tsx +5 -47
- package/src/main.css +348 -5
- package/src/main.less +2 -0
- package/src/money/Money.tsx +9 -2
- package/src/overlayHeader/OverlayHeader.story.tsx +6 -14
- package/src/table/Table.css +274 -0
- package/src/table/Table.less +334 -0
- package/src/table/Table.messages.ts +24 -0
- package/src/table/Table.spec.tsx +82 -0
- package/src/table/Table.story.tsx +356 -0
- package/src/table/Table.tsx +167 -0
- package/src/table/TableCell.spec.tsx +298 -0
- package/src/table/TableCell.tsx +149 -0
- package/src/table/TableHeader.spec.tsx +50 -0
- package/src/table/TableHeader.tsx +74 -0
- package/src/table/TableRow.spec.tsx +112 -0
- package/src/table/TableRow.tsx +70 -0
- package/src/table/TableStatusText.spec.tsx +53 -0
- package/src/table/TableStatusText.tsx +40 -0
- package/src/table/index.ts +11 -0
- package/src/circularButton/__snapshots__/CircularButton.spec.tsx.snap +0 -381
package/build/avatar/Avatar.js
CHANGED
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;
|
|
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,CA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B;AAC9Be,MAAAA,KAAK,EAAE;QACLlB,eAAe,EAAEA,eAAe,IAAIW,uBAAAA;OACpC;AAAAT,MAAAA,QAAA,EAEDA,QAAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV;;;;"}
|
package/build/avatar/Avatar.mjs
CHANGED
|
@@ -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,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;
|
|
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,I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CAAA;AAEV;;;;"}
|
|
@@ -0,0 +1,175 @@
|
|
|
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,
|
|
46
|
+
profileName,
|
|
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: /*#__PURE__*/jsxRuntime.jsx(AvatarViewContent, {
|
|
75
|
+
imgSrc,
|
|
76
|
+
profileType,
|
|
77
|
+
profileName,
|
|
78
|
+
children: children
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** Size of badge depends on size of avatar */
|
|
85
|
+
const MAP_BADGE_ASSET_SIZE = {
|
|
86
|
+
16: 16,
|
|
87
|
+
24: 16,
|
|
88
|
+
32: 16,
|
|
89
|
+
40: 16,
|
|
90
|
+
48: 16,
|
|
91
|
+
56: 24,
|
|
92
|
+
72: 24
|
|
93
|
+
};
|
|
94
|
+
/** Certain sizes of AvatarView has a custom offset for badge */
|
|
95
|
+
const MAP_BADGE_POSITION = {
|
|
96
|
+
24: -6,
|
|
97
|
+
32: -4
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Adds build-in badges to AvatarView
|
|
101
|
+
*/
|
|
102
|
+
function Badges({
|
|
103
|
+
children,
|
|
104
|
+
avatar,
|
|
105
|
+
'aria-label': ariaLabel,
|
|
106
|
+
asset: customBadge,
|
|
107
|
+
...badgeAssets
|
|
108
|
+
}) {
|
|
109
|
+
const {
|
|
110
|
+
size = 48,
|
|
111
|
+
selected,
|
|
112
|
+
notification
|
|
113
|
+
} = avatar;
|
|
114
|
+
const anyBadge = Object.values({
|
|
115
|
+
customBadge,
|
|
116
|
+
...badgeAssets
|
|
117
|
+
}).filter(Boolean).length > 0;
|
|
118
|
+
if ((anyBadge || selected) && size > 16) {
|
|
119
|
+
const badgeSize = MAP_BADGE_ASSET_SIZE[size];
|
|
120
|
+
return /*#__PURE__*/jsxRuntime.jsx(Badge, {
|
|
121
|
+
"aria-label": ariaLabel,
|
|
122
|
+
size: badgeSize,
|
|
123
|
+
badge: customBadge ? /*#__PURE__*/jsxRuntime.jsx(Circle, {
|
|
124
|
+
fixedSize: true,
|
|
125
|
+
size: badgeSize,
|
|
126
|
+
children: customBadge
|
|
127
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(BadgeAssets, {
|
|
128
|
+
...(selected ? {
|
|
129
|
+
status: 'positive'
|
|
130
|
+
} : badgeAssets),
|
|
131
|
+
size: badgeSize
|
|
132
|
+
}),
|
|
133
|
+
style: {
|
|
134
|
+
// @ts-expect-error CSS custom props allowed
|
|
135
|
+
'--badge-content-position': `${MAP_BADGE_POSITION[size] ?? 0}px`
|
|
136
|
+
},
|
|
137
|
+
children: children
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (notification) {
|
|
141
|
+
return /*#__PURE__*/jsxRuntime.jsx(NotificationDot, {
|
|
142
|
+
avatarSize: size,
|
|
143
|
+
children: children
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return children;
|
|
147
|
+
}
|
|
148
|
+
function AvatarViewContent({
|
|
149
|
+
children,
|
|
150
|
+
imgSrc,
|
|
151
|
+
profileName: name,
|
|
152
|
+
profileType: type
|
|
153
|
+
}) {
|
|
154
|
+
const [tryLoadImage, setTryLoadImage] = React.useState(true);
|
|
155
|
+
if (children === undefined) {
|
|
156
|
+
if (imgSrc && tryLoadImage) {
|
|
157
|
+
return /*#__PURE__*/jsxRuntime.jsx(Image.default, {
|
|
158
|
+
src: imgSrc,
|
|
159
|
+
alt: "",
|
|
160
|
+
onError: () => setTryLoadImage(false)
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (type) {
|
|
164
|
+
return type === profileType.ProfileType.BUSINESS ? /*#__PURE__*/jsxRuntime.jsx(icons.Briefcase, {}) : /*#__PURE__*/jsxRuntime.jsx(icons.Profile, {});
|
|
165
|
+
}
|
|
166
|
+
if (name) {
|
|
167
|
+
return initials.getInitials(name);
|
|
168
|
+
}
|
|
169
|
+
return /*#__PURE__*/jsxRuntime.jsx(icons.Profile, {});
|
|
170
|
+
}
|
|
171
|
+
return children;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = AvatarView;
|
|
175
|
+
//# 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,\n profileName,\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 <AvatarViewContent {...{ imgSrc, profileType, profileName }}>\n {children}\n </AvatarViewContent>\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 for 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 children,\n imgSrc,\n profileName: name,\n profileType: type,\n}: PropsWithChildren<Pick<Props, 'imgSrc' | 'profileName' | 'profileType'>>) {\n const [tryLoadImage, setTryLoadImage] = useState(true);\n if (children === undefined) {\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 return children;\n}\n\nexport default AvatarView;\n"],"names":["AvatarView","children","undefined","size","selected","notification","badge","interactive","className","style","imgSrc","profileType","profileName","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","name","type","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;EACNC,WAAW;EACXC,WAAW;EACX,GAAGC,SAAAA;AACG,CAAA,EAAA;EACN,oBACEC,cAAA,CAACC,MAAM,EAAA;AACLZ,IAAAA,IAAI,EAAEA,IAAK;IACXa,SAAS,EAAA,IAAA;IACTR,SAAS,EAAES,SAAI,CACb,gBAAgB,EAChBV,WAAW,GAAG,4BAA4B,GAAG,gCAAgC,EAC7E;AAAE,MAAA,yBAAyB,EAAEH,QAAAA;KAAU,EACvCI,SAAS,CACT;AAAA,IAAA,GACEK,SAAS;IAAAZ,QAAA,eAEba,cAAA,CAACI,MAAM,EAAA;AAACC,MAAAA,MAAM,EAAE;QAAEhB,IAAI;QAAEE,YAAY;AAAED,QAAAA,QAAAA;OAAW;AAAA,MAAA,GAAKE,KAAK;MAAAL,QAAA,eACzDa,cAAA,CAACC,MAAM,EAAA;AACLZ,QAAAA,IAAI,EAAEA,IAAK;QACXa,SAAS,EAAA,IAAA;AACTR,QAAAA,SAAS,EAAES,SAAI,CAAC,wBAAwB,CAAE;AAC1CG,QAAAA,YAAY,EAAE,CAACb,WAAW,IAAIH,QAAS;AACvCK,QAAAA,KAAK,EAAE;AACL,UAAA,IAAIL,QAAQ,IAAI;AAAE,YAAA,uBAAuB,EAAE,kCAAA;WAAoC,CAAC;UAChF,GAAGK,KAAAA;SACH;QAAAR,QAAA,eAEFa,cAAA,CAACO,iBAAiB,EAAA;UAAOX,MAAM;UAAEC,WAAW;UAAEC,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AC7E,KAAA;AACA,IAAA,IAAIF,IAAI,EAAE;AACR,MAAA,OAAOA,IAAI,KAAKQ,uBAAW,CAACC,QAAQ,gBAAGpC,cAAA,CAACqC,eAAmB,EAAA,EAAA,CAAG,gBAAGrC,cAAA,CAACsC,aAAmB,IAAA,CAAG,CAAA;AAC1F,KAAA;AACA,IAAA,IAAIZ,IAAI,EAAE;MACR,OAAOa,oBAAW,CAACb,IAAI,CAAC,CAAA;AAC1B,KAAA;AACA,IAAA,oBAAO1B,cAAA,CAACsC,aAAmB,EAAA,GAAG,CAAA;AAChC,GAAA;AACA,EAAA,OAAOnD,QAAQ,CAAA;AACjB;;;;"}
|
|
@@ -0,0 +1,173 @@
|
|
|
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,
|
|
44
|
+
profileName,
|
|
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: /*#__PURE__*/jsx(AvatarViewContent, {
|
|
73
|
+
imgSrc,
|
|
74
|
+
profileType,
|
|
75
|
+
profileName,
|
|
76
|
+
children: children
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** Size of badge depends on size of avatar */
|
|
83
|
+
const MAP_BADGE_ASSET_SIZE = {
|
|
84
|
+
16: 16,
|
|
85
|
+
24: 16,
|
|
86
|
+
32: 16,
|
|
87
|
+
40: 16,
|
|
88
|
+
48: 16,
|
|
89
|
+
56: 24,
|
|
90
|
+
72: 24
|
|
91
|
+
};
|
|
92
|
+
/** Certain sizes of AvatarView has a custom offset for badge */
|
|
93
|
+
const MAP_BADGE_POSITION = {
|
|
94
|
+
24: -6,
|
|
95
|
+
32: -4
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Adds build-in badges to AvatarView
|
|
99
|
+
*/
|
|
100
|
+
function Badges({
|
|
101
|
+
children,
|
|
102
|
+
avatar,
|
|
103
|
+
'aria-label': ariaLabel,
|
|
104
|
+
asset: customBadge,
|
|
105
|
+
...badgeAssets
|
|
106
|
+
}) {
|
|
107
|
+
const {
|
|
108
|
+
size = 48,
|
|
109
|
+
selected,
|
|
110
|
+
notification
|
|
111
|
+
} = avatar;
|
|
112
|
+
const anyBadge = Object.values({
|
|
113
|
+
customBadge,
|
|
114
|
+
...badgeAssets
|
|
115
|
+
}).filter(Boolean).length > 0;
|
|
116
|
+
if ((anyBadge || selected) && size > 16) {
|
|
117
|
+
const badgeSize = MAP_BADGE_ASSET_SIZE[size];
|
|
118
|
+
return /*#__PURE__*/jsx(Badge, {
|
|
119
|
+
"aria-label": ariaLabel,
|
|
120
|
+
size: badgeSize,
|
|
121
|
+
badge: customBadge ? /*#__PURE__*/jsx(Circle, {
|
|
122
|
+
fixedSize: true,
|
|
123
|
+
size: badgeSize,
|
|
124
|
+
children: customBadge
|
|
125
|
+
}) : /*#__PURE__*/jsx(BadgeAssets, {
|
|
126
|
+
...(selected ? {
|
|
127
|
+
status: 'positive'
|
|
128
|
+
} : badgeAssets),
|
|
129
|
+
size: badgeSize
|
|
130
|
+
}),
|
|
131
|
+
style: {
|
|
132
|
+
// @ts-expect-error CSS custom props allowed
|
|
133
|
+
'--badge-content-position': `${MAP_BADGE_POSITION[size] ?? 0}px`
|
|
134
|
+
},
|
|
135
|
+
children: children
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (notification) {
|
|
139
|
+
return /*#__PURE__*/jsx(NotificationDot, {
|
|
140
|
+
avatarSize: size,
|
|
141
|
+
children: children
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return children;
|
|
145
|
+
}
|
|
146
|
+
function AvatarViewContent({
|
|
147
|
+
children,
|
|
148
|
+
imgSrc,
|
|
149
|
+
profileName: name,
|
|
150
|
+
profileType: type
|
|
151
|
+
}) {
|
|
152
|
+
const [tryLoadImage, setTryLoadImage] = useState(true);
|
|
153
|
+
if (children === undefined) {
|
|
154
|
+
if (imgSrc && tryLoadImage) {
|
|
155
|
+
return /*#__PURE__*/jsx(Image, {
|
|
156
|
+
src: imgSrc,
|
|
157
|
+
alt: "",
|
|
158
|
+
onError: () => setTryLoadImage(false)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (type) {
|
|
162
|
+
return type === ProfileType.BUSINESS ? /*#__PURE__*/jsx(Briefcase, {}) : /*#__PURE__*/jsx(Profile, {});
|
|
163
|
+
}
|
|
164
|
+
if (name) {
|
|
165
|
+
return getInitials(name);
|
|
166
|
+
}
|
|
167
|
+
return /*#__PURE__*/jsx(Profile, {});
|
|
168
|
+
}
|
|
169
|
+
return children;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export { AvatarView as default };
|
|
173
|
+
//# 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,\n profileName,\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 <AvatarViewContent {...{ imgSrc, profileType, profileName }}>\n {children}\n </AvatarViewContent>\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 for 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 children,\n imgSrc,\n profileName: name,\n profileType: type,\n}: PropsWithChildren<Pick<Props, 'imgSrc' | 'profileName' | 'profileType'>>) {\n const [tryLoadImage, setTryLoadImage] = useState(true);\n if (children === undefined) {\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 return children;\n}\n\nexport default AvatarView;\n"],"names":["AvatarView","children","undefined","size","selected","notification","badge","interactive","className","style","imgSrc","profileType","profileName","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","name","type","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;EACNC,WAAW;EACXC,WAAW;EACX,GAAGC,SAAAA;AACG,CAAA,EAAA;EACN,oBACEC,GAAA,CAACC,MAAM,EAAA;AACLZ,IAAAA,IAAI,EAAEA,IAAK;IACXa,SAAS,EAAA,IAAA;IACTR,SAAS,EAAES,IAAI,CACb,gBAAgB,EAChBV,WAAW,GAAG,4BAA4B,GAAG,gCAAgC,EAC7E;AAAE,MAAA,yBAAyB,EAAEH,QAAAA;KAAU,EACvCI,SAAS,CACT;AAAA,IAAA,GACEK,SAAS;IAAAZ,QAAA,eAEba,GAAA,CAACI,MAAM,EAAA;AAACC,MAAAA,MAAM,EAAE;QAAEhB,IAAI;QAAEE,YAAY;AAAED,QAAAA,QAAAA;OAAW;AAAA,MAAA,GAAKE,KAAK;MAAAL,QAAA,eACzDa,GAAA,CAACC,MAAM,EAAA;AACLZ,QAAAA,IAAI,EAAEA,IAAK;QACXa,SAAS,EAAA,IAAA;AACTR,QAAAA,SAAS,EAAES,IA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,CAAC,CAAA;EACtD,IAAI3C,QAAQ,KAAKC,SAAS,EAAE;IAC1B,IAAIQ,MAAM,IAAIgC,YAAY,EAAE;MAC1B,oBAAO5B,GAAA,CAAC+B,KAAK,EAAA;AAACC,QAAAA,GAAG,EAAEpC,MAAO;AAACqC,QAAAA,GAAG,EAAC,EAAE;AAACC,QAAAA,OAAO,EAAEA,MAAML,eAAe,CAAC,KAAK,CAAA;AAAE,OAAA,CAAG,CAAA;AAC7E,KAAA;AACA,IAAA,IAAIF,IAAI,EAAE;AACR,MAAA,OAAOA,IAAI,KAAKQ,WAAW,CAACC,QAAQ,gBAAGpC,GAAA,CAACqC,SAAmB,EAAA,EAAA,CAAG,gBAAGrC,GAAA,CAACsC,OAAmB,IAAA,CAAG,CAAA;AAC1F,KAAA;AACA,IAAA,IAAIZ,IAAI,EAAE;MACR,OAAOa,WAAW,CAACb,IAAI,CAAC,CAAA;AAC1B,KAAA;AACA,IAAA,oBAAO1B,GAAA,CAACsC,OAAmB,EAAA,GAAG,CAAA;AAChC,GAAA;AACA,EAAA,OAAOnD,QAAQ,CAAA;AACjB;;;;"}
|
|
@@ -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,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,IAAA,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,GAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,2BAAA;KACf,CAAA,eAAAE,GAAA,CAAA,KAAA,EAAA;AAAKF,MAAAA,SAAS,EAAC,0BAA0B;AAAAH,MAAAA,QAAA,EAAEA,QAAAA;AAAQ,KAAM,CAC3D,CAAA;AAAA,GAAK,CAAC,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,
|