@transferwise/components 0.0.0-experimental-e5e0684 → 0.0.0-experimental-37d8e2c

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 (151) hide show
  1. package/build/avatar/Avatar.js +4 -1
  2. package/build/avatar/Avatar.js.map +1 -1
  3. package/build/avatar/Avatar.mjs +4 -1
  4. package/build/avatar/Avatar.mjs.map +1 -1
  5. package/build/avatar/colors/colors.js +1 -1
  6. package/build/avatar/colors/colors.js.map +1 -1
  7. package/build/avatar/colors/colors.mjs +1 -1
  8. package/build/avatar/colors/colors.mjs.map +1 -1
  9. package/build/avatarView/AvatarView.js +207 -0
  10. package/build/avatarView/AvatarView.js.map +1 -0
  11. package/build/avatarView/AvatarView.mjs +205 -0
  12. package/build/avatarView/AvatarView.mjs.map +1 -0
  13. package/build/avatarWrapper/AvatarWrapper.js +6 -9
  14. package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
  15. package/build/avatarWrapper/AvatarWrapper.mjs +5 -8
  16. package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
  17. package/build/badge/Badge.js +6 -1
  18. package/build/badge/Badge.js.map +1 -1
  19. package/build/badge/Badge.mjs +6 -1
  20. package/build/badge/Badge.mjs.map +1 -1
  21. package/build/circularButton/CircularButton.js +4 -7
  22. package/build/circularButton/CircularButton.js.map +1 -1
  23. package/build/circularButton/CircularButton.mjs +4 -7
  24. package/build/circularButton/CircularButton.mjs.map +1 -1
  25. package/build/common/circle/Circle.js +24 -1
  26. package/build/common/circle/Circle.js.map +1 -1
  27. package/build/common/circle/Circle.mjs +24 -1
  28. package/build/common/circle/Circle.mjs.map +1 -1
  29. package/build/common/initials.js +12 -0
  30. package/build/common/initials.js.map +1 -0
  31. package/build/common/initials.mjs +10 -0
  32. package/build/common/initials.mjs.map +1 -0
  33. package/build/common/notificationDot/NotificationDot.js +16 -0
  34. package/build/common/notificationDot/NotificationDot.js.map +1 -0
  35. package/build/common/notificationDot/NotificationDot.mjs +14 -0
  36. package/build/common/notificationDot/NotificationDot.mjs.map +1 -0
  37. package/build/display/Display.js +1 -1
  38. package/build/display/Display.js.map +1 -1
  39. package/build/display/Display.mjs +1 -1
  40. package/build/display/Display.mjs.map +1 -1
  41. package/build/index.js +6 -0
  42. package/build/index.js.map +1 -1
  43. package/build/index.mjs +3 -0
  44. package/build/index.mjs.map +1 -1
  45. package/build/main.css +82 -41
  46. package/build/statusIcon/StatusIcon.js +4 -2
  47. package/build/statusIcon/StatusIcon.js.map +1 -1
  48. package/build/statusIcon/StatusIcon.mjs +4 -2
  49. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  50. package/build/styles/avatarGroup/AvatarGroup.css +28 -0
  51. package/build/styles/avatarView/AvatarView.css +22 -0
  52. package/build/styles/badge/Badge.css +5 -5
  53. package/build/styles/circularButton/CircularButton.css +0 -24
  54. package/build/styles/common/circle/Circle.css +17 -0
  55. package/build/styles/common/notificationDot/NotificationDot.css +10 -0
  56. package/build/styles/main.css +82 -41
  57. package/build/styles/statusIcon/StatusIcon.css +0 -12
  58. package/build/typeahead/util/highlight.js +14 -2
  59. package/build/typeahead/util/highlight.js.map +1 -1
  60. package/build/typeahead/util/highlight.mjs +15 -3
  61. package/build/typeahead/util/highlight.mjs.map +1 -1
  62. package/build/types/avatar/Avatar.d.ts +3 -0
  63. package/build/types/avatar/Avatar.d.ts.map +1 -1
  64. package/build/types/avatar/colors/colors.d.ts +1 -1
  65. package/build/types/avatar/colors/colors.d.ts.map +1 -1
  66. package/build/types/avatarGroup/AvatarGroup.d.ts +19 -0
  67. package/build/types/avatarGroup/AvatarGroup.d.ts.map +1 -0
  68. package/build/types/avatarGroup/index.d.ts +3 -0
  69. package/build/types/avatarGroup/index.d.ts.map +1 -0
  70. package/build/types/avatarView/AvatarView.d.ts +25 -0
  71. package/build/types/avatarView/AvatarView.d.ts.map +1 -0
  72. package/build/types/avatarView/index.d.ts +3 -0
  73. package/build/types/avatarView/index.d.ts.map +1 -0
  74. package/build/types/avatarWrapper/AvatarWrapper.d.ts +3 -0
  75. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  76. package/build/types/badge/Badge.d.ts +2 -1
  77. package/build/types/badge/Badge.d.ts.map +1 -1
  78. package/build/types/circularButton/CircularButton.d.ts.map +1 -1
  79. package/build/types/common/circle/Circle.d.ts +1 -1
  80. package/build/types/common/circle/Circle.d.ts.map +1 -1
  81. package/build/types/common/index.d.ts +1 -0
  82. package/build/types/common/initials.d.ts +2 -0
  83. package/build/types/common/initials.d.ts.map +1 -0
  84. package/build/types/common/notificationDot/NotificationDot.d.ts +8 -0
  85. package/build/types/common/notificationDot/NotificationDot.d.ts.map +1 -0
  86. package/build/types/index.d.ts +4 -1
  87. package/build/types/index.d.ts.map +1 -1
  88. package/build/types/statusIcon/StatusIcon.d.ts +6 -2
  89. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  90. package/build/types/typeahead/util/highlight.d.ts +1 -1
  91. package/build/types/typeahead/util/highlight.d.ts.map +1 -1
  92. package/build/types/uploadInput/UploadInput.d.ts +0 -9
  93. package/build/types/uploadInput/UploadInput.d.ts.map +1 -1
  94. package/build/types/uploadInput/uploadItem/UploadItem.d.ts +1 -3
  95. package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
  96. package/build/types/uploadInput/uploadItem/UploadItemLink.d.ts.map +1 -1
  97. package/build/uploadInput/UploadInput.js +51 -57
  98. package/build/uploadInput/UploadInput.js.map +1 -1
  99. package/build/uploadInput/UploadInput.mjs +51 -57
  100. package/build/uploadInput/UploadInput.mjs.map +1 -1
  101. package/build/uploadInput/uploadItem/UploadItem.js +3 -8
  102. package/build/uploadInput/uploadItem/UploadItem.js.map +1 -1
  103. package/build/uploadInput/uploadItem/UploadItem.mjs +3 -8
  104. package/build/uploadInput/uploadItem/UploadItem.mjs.map +1 -1
  105. package/build/uploadInput/uploadItem/UploadItemLink.js +0 -1
  106. package/build/uploadInput/uploadItem/UploadItemLink.js.map +1 -1
  107. package/build/uploadInput/uploadItem/UploadItemLink.mjs +0 -1
  108. package/build/uploadInput/uploadItem/UploadItemLink.mjs.map +1 -1
  109. package/package.json +3 -3
  110. package/src/avatar/Avatar.tsx +4 -1
  111. package/src/avatar/colors/colors.ts +4 -4
  112. package/src/avatarGroup/AvatarGroup.css +28 -0
  113. package/src/avatarGroup/AvatarGroup.less +32 -0
  114. package/src/avatarGroup/AvatarGroup.story.tsx +249 -0
  115. package/src/avatarGroup/AvatarGroup.tsx +78 -0
  116. package/src/avatarGroup/index.ts +2 -0
  117. package/src/avatarView/AvatarView.css +22 -0
  118. package/src/avatarView/AvatarView.less +24 -0
  119. package/src/avatarView/AvatarView.story.tsx +425 -0
  120. package/src/avatarView/AvatarView.tsx +217 -0
  121. package/src/avatarView/index.ts +2 -0
  122. package/src/avatarWrapper/AvatarWrapper.tsx +12 -16
  123. package/src/badge/Badge.css +5 -5
  124. package/src/badge/Badge.less +3 -3
  125. package/src/badge/Badge.tsx +10 -1
  126. package/src/circularButton/CircularButton.css +0 -24
  127. package/src/circularButton/CircularButton.less +15 -15
  128. package/src/circularButton/CircularButton.tsx +4 -5
  129. package/src/common/circle/Circle.css +17 -0
  130. package/src/common/circle/Circle.less +22 -0
  131. package/src/common/circle/Circle.tsx +33 -2
  132. package/src/common/index.js +1 -0
  133. package/src/common/initials.ts +13 -0
  134. package/src/common/notificationDot/NotificationDot.css +10 -0
  135. package/src/common/notificationDot/NotificationDot.less +7 -0
  136. package/src/common/notificationDot/NotificationDot.tsx +10 -0
  137. package/src/display/Display.tsx +1 -1
  138. package/src/index.ts +4 -0
  139. package/src/main.css +82 -41
  140. package/src/main.less +3 -0
  141. package/src/statusIcon/StatusIcon.css +0 -12
  142. package/src/statusIcon/StatusIcon.less +6 -6
  143. package/src/statusIcon/StatusIcon.story.tsx +32 -28
  144. package/src/statusIcon/StatusIcon.tsx +18 -4
  145. package/src/test-utils/avatar-img.webp +0 -0
  146. package/src/typeahead/typeaheadOption/TypeaheadOption.spec.js +7 -5
  147. package/src/typeahead/util/highlight.tsx +7 -2
  148. package/src/uploadInput/UploadInput.spec.tsx +6 -150
  149. package/src/uploadInput/UploadInput.tsx +60 -81
  150. package/src/uploadInput/uploadItem/UploadItem.tsx +6 -12
  151. package/src/uploadInput/uploadItem/UploadItemLink.tsx +1 -9
@@ -0,0 +1,249 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import AvatarGroup from './AvatarGroup';
3
+ import { Bank, Briefcase } from '@transferwise/icons';
4
+ import Title from '../title';
5
+ import { Flag } from '@wise/art';
6
+ import { storyConfig } from '../test-utils';
7
+ import RadioOption from '../radioOption';
8
+
9
+ export default {
10
+ title: 'Content/AvatarGroup',
11
+ } satisfies Meta<typeof AvatarGroup>;
12
+
13
+ type Story = StoryObj<typeof AvatarGroup>;
14
+
15
+ export const Basic: Story = storyConfig(
16
+ {
17
+ render: () => (
18
+ <>
19
+ <RadioOption
20
+ id="test"
21
+ name="foo"
22
+ title="Personal account"
23
+ showMediaCircle={false}
24
+ media={
25
+ <AvatarGroup
26
+ size={48}
27
+ orientation="diagonal"
28
+ avatars={[
29
+ { asset: 'AA', type: 'text' },
30
+ { asset: 'BB', type: 'text' },
31
+ ]}
32
+ />
33
+ }
34
+ onChange={() => {}}
35
+ />
36
+ <Title type="title-subsection">Diagonal</Title>
37
+ <table border="0" cellPadding="0" cellSpacing="0">
38
+ <tr>
39
+ <td>24</td>
40
+ <td>48</td>
41
+ <td>72</td>
42
+ </tr>
43
+ <tr>
44
+ <td>
45
+ <AvatarGroup
46
+ size={24}
47
+ orientation="diagonal"
48
+ avatars={[
49
+ { asset: 'JJ', type: 'text' },
50
+ { asset: 'AA', type: 'text' },
51
+ ]}
52
+ />
53
+ </td>
54
+ <td>
55
+ <AvatarGroup
56
+ orientation="diagonal"
57
+ avatars={[
58
+ { asset: 'JJ', type: 'text' },
59
+ { asset: 'AA', type: 'text' },
60
+ ]}
61
+ />
62
+ </td>
63
+ <td>
64
+ <AvatarGroup
65
+ size={72}
66
+ orientation="diagonal"
67
+ avatars={[
68
+ { asset: 'JJ', type: 'text' },
69
+ { asset: 'AA', type: 'text' },
70
+ ]}
71
+ />
72
+ </td>
73
+ </tr>
74
+ <tr>
75
+ <td>
76
+ <AvatarGroup
77
+ size={24}
78
+ orientation="diagonal"
79
+ avatars={[
80
+ { asset: <Briefcase size="16" />, type: 'icon' },
81
+ { asset: <Bank size="16" />, type: 'icon' },
82
+ ]}
83
+ />
84
+ </td>
85
+ <td>
86
+ <AvatarGroup
87
+ size={48}
88
+ orientation="diagonal"
89
+ avatars={[
90
+ { asset: <Briefcase size="24" />, type: 'icon' },
91
+ { asset: <Bank size="24" />, type: 'icon' },
92
+ ]}
93
+ />
94
+ </td>
95
+ <td>
96
+ <AvatarGroup
97
+ size={72}
98
+ orientation="diagonal"
99
+ avatars={[
100
+ { asset: <Briefcase size="24" />, type: 'icon' },
101
+ { asset: <Bank size="24" />, type: 'icon' },
102
+ ]}
103
+ />
104
+ </td>
105
+ </tr>
106
+ <tr>
107
+ <td>
108
+ <AvatarGroup
109
+ size={24}
110
+ orientation="diagonal"
111
+ avatars={[
112
+ { asset: <Flag code="gb" />, type: 'image' },
113
+ { asset: <Flag code="jp" />, type: 'image' },
114
+ ]}
115
+ />
116
+ </td>
117
+ <td>
118
+ <AvatarGroup
119
+ size={48}
120
+ orientation="diagonal"
121
+ avatars={[
122
+ { asset: <Flag code="gb" />, type: 'image' },
123
+ { asset: <Flag code="jp" />, type: 'image' },
124
+ ]}
125
+ />
126
+ </td>
127
+ <td>
128
+ <AvatarGroup
129
+ size={72}
130
+ orientation="diagonal"
131
+ avatars={[
132
+ { asset: <Flag code="gb" />, type: 'image' },
133
+ { asset: <Flag code="jp" />, type: 'image' },
134
+ ]}
135
+ />
136
+ </td>
137
+ </tr>
138
+ </table>
139
+
140
+ <Title type="title-subsection" className="m-t-3">
141
+ Horizontal
142
+ </Title>
143
+ <table border="0" cellPadding="0" cellSpacing="0">
144
+ <tr>
145
+ <td>24</td>
146
+ <td>48</td>
147
+ <td>72</td>
148
+ </tr>
149
+ <tr>
150
+ <td>
151
+ <AvatarGroup
152
+ size={24}
153
+ orientation="horizontal"
154
+ avatars={[
155
+ { asset: 'JJ', type: 'text' },
156
+ { asset: 'AA', type: 'text' },
157
+ ]}
158
+ />
159
+ </td>
160
+ <td>
161
+ <AvatarGroup
162
+ orientation="horizontal"
163
+ avatars={[
164
+ { asset: 'JJ', type: 'text' },
165
+ { asset: 'AA', type: 'text' },
166
+ ]}
167
+ />
168
+ </td>
169
+ <td>
170
+ <AvatarGroup
171
+ size={72}
172
+ orientation="horizontal"
173
+ avatars={[
174
+ { asset: 'JJ', type: 'text' },
175
+ { asset: 'AA', type: 'text' },
176
+ ]}
177
+ />
178
+ </td>
179
+ </tr>
180
+ <tr>
181
+ <td>
182
+ <AvatarGroup
183
+ size={24}
184
+ orientation="horizontal"
185
+ avatars={[
186
+ { asset: <Briefcase size="16" />, type: 'icon' },
187
+ { asset: <Bank size="16" />, type: 'icon' },
188
+ ]}
189
+ />
190
+ </td>
191
+ <td>
192
+ <AvatarGroup
193
+ size={48}
194
+ orientation="horizontal"
195
+ avatars={[
196
+ { asset: <Briefcase size="24" />, type: 'icon' },
197
+ { asset: <Bank size="24" />, type: 'icon' },
198
+ ]}
199
+ />
200
+ </td>
201
+ <td>
202
+ <AvatarGroup
203
+ size={72}
204
+ orientation="horizontal"
205
+ avatars={[
206
+ { asset: <Briefcase size="24" />, type: 'icon' },
207
+ { asset: <Bank size="24" />, type: 'icon' },
208
+ ]}
209
+ />
210
+ </td>
211
+ </tr>
212
+ <tr>
213
+ <td>
214
+ <AvatarGroup
215
+ size={24}
216
+ orientation="horizontal"
217
+ avatars={[
218
+ { asset: <Flag code="gb" />, type: 'image' },
219
+ { asset: <Flag code="jp" />, type: 'image' },
220
+ ]}
221
+ />
222
+ </td>
223
+ <td>
224
+ <AvatarGroup
225
+ size={48}
226
+ orientation="horizontal"
227
+ avatars={[
228
+ { asset: <Flag code="gb" />, type: 'image' },
229
+ { asset: <Flag code="jp" />, type: 'image' },
230
+ ]}
231
+ />
232
+ </td>
233
+ <td>
234
+ <AvatarGroup
235
+ size={72}
236
+ orientation="horizontal"
237
+ avatars={[
238
+ { asset: <Flag code="gb" />, type: 'image' },
239
+ { asset: <Flag code="jp" />, type: 'image' },
240
+ ]}
241
+ />
242
+ </td>
243
+ </tr>
244
+ </table>
245
+ </>
246
+ ),
247
+ },
248
+ { variants: ['light', 'dark'] },
249
+ );
@@ -0,0 +1,78 @@
1
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
+ /* eslint-disable react/jsx-key */
3
+ import { clsx } from 'clsx';
4
+ import { CommonProps } from '../common';
5
+ import { ReactNode } from 'react';
6
+ import AvatarView, { AvatarViewProps } from '../avatarView';
7
+
8
+ type AvatarType = { asset: ReactNode } & Pick<
9
+ AvatarViewProps,
10
+ 'type' | 'backgroundColor' | 'borderColor' | 'className'
11
+ >;
12
+ type AvatarGroupOrientation = 'horizontal' | 'diagonal';
13
+ type AvatarGroupDiagonalSize = 24 | 32 | 40 | 48 | 56 | 72;
14
+ type AvatarGroupSize = 16 | AvatarGroupDiagonalSize;
15
+
16
+ /**
17
+ * Diagonal orientation uses custom sizes for avatars
18
+ */
19
+ const avatarGroupDiagonalSizeMap: Record<AvatarGroupDiagonalSize, number> = {
20
+ 24: 15,
21
+ 32: 20,
22
+ 40: 24,
23
+ 48: 30,
24
+ 56: 34,
25
+ 72: 44,
26
+ };
27
+
28
+ export type Props = {
29
+ 'aria-label'?: string;
30
+ avatars: AvatarType[];
31
+ orientation?: AvatarGroupOrientation;
32
+ size?: AvatarGroupSize;
33
+ interactive?: boolean;
34
+ } & CommonProps;
35
+
36
+ export default function AvatarGroup({
37
+ avatars,
38
+ orientation: orientationProp = 'horizontal',
39
+ size = 48,
40
+ 'aria-label': ariaLabel,
41
+ className,
42
+ interactive,
43
+ }: Props) {
44
+ const orientation =
45
+ orientationProp === 'diagonal' && size === 16 ? 'horizontal' : orientationProp;
46
+ const avatarSize = orientation === 'diagonal' ? avatarGroupDiagonalSizeMap[size] : size;
47
+ return (
48
+ <div
49
+ className={clsx('np-avatar-group', `np-avatar-group-${orientation}`, className)}
50
+ // @ts-expect-error `--np-avatar-group-size` exsits in styles of AvatarGroup
51
+ style={{ '--np-avatar-group-size': `${size}px`, '--np-avatar-size': `${avatarSize}px` }}
52
+ aria-label={ariaLabel}
53
+ >
54
+ {avatars.length > 1
55
+ ? avatars.map((avatar, index) => (
56
+ <AvatarView
57
+ key={index}
58
+ {...avatar}
59
+ className={clsx(
60
+ { [`np-avatar-group-${orientation}-child`]: index !== 0 },
61
+ { [`np-avatar-group-${orientation}-mask`]: index !== avatars.length - 1 },
62
+ avatar.className,
63
+ )}
64
+ style={{
65
+ // @ts-expect-error CSS custom props allowed
66
+ '--np-avatar-group-index': index,
67
+ '--circle-size': `${avatarSize}px`,
68
+ }}
69
+ size={avatarSize}
70
+ interactive={interactive}
71
+ >
72
+ {avatar.asset}
73
+ </AvatarView>
74
+ ))
75
+ : null}
76
+ </div>
77
+ );
78
+ }
@@ -0,0 +1,2 @@
1
+ export type { Props as AvatarGroupProps } from './AvatarGroup';
2
+ export { default } from './AvatarGroup';
@@ -0,0 +1,22 @@
1
+ .np-avatar-view {
2
+ border-radius: 9999px;
3
+ border-radius: var(--radius-full);
4
+ color: var(--color-interactive-primary);
5
+ height: -moz-fit-content;
6
+ height: fit-content;
7
+ width: -moz-fit-content;
8
+ width: fit-content;
9
+ }
10
+ .np-avatar-view .np-circle {
11
+ background-color: transparent;
12
+ border: var(--avatar-view-non-interactive-border-width) solid rgba(0,0,0,0.10196);
13
+ border: var(--avatar-view-non-interactive-border-width) solid var(--color-border-neutral);
14
+ }
15
+ .np-avatar-view-selected .np-circle {
16
+ border: var(--avatar-view-selected-border-width) solid var(--color-interactive-primary) !important;
17
+ }
18
+ .np-avatar-view-interactive .np-circle {
19
+ background-color: rgba(134,167,189,0.10196);
20
+ background-color: var(--color-background-neutral);
21
+ border: none;
22
+ }
@@ -0,0 +1,24 @@
1
+ .np-avatar-view {
2
+ border-radius: var(--radius-full);
3
+ color: var(--color-interactive-primary);
4
+ height: fit-content;
5
+ width: fit-content;
6
+
7
+ .np-circle {
8
+ background-color: transparent;
9
+ border: var(--avatar-view-non-interactive-border-width) solid var(--color-border-neutral);
10
+ }
11
+
12
+ &-selected {
13
+ .np-circle {
14
+ border: var(--avatar-view-selected-border-width) solid var(--color-interactive-primary) !important;
15
+ }
16
+ }
17
+
18
+ &-interactive {
19
+ .np-circle {
20
+ background-color: var(--color-background-neutral);
21
+ border: none;
22
+ }
23
+ }
24
+ }