@transferwise/components 45.2.0 → 45.3.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.
@@ -0,0 +1,402 @@
1
+ [
2
+ {
3
+ "key": "053ac3c5-278a-449d-7c3e-42f20e8dd15d",
4
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
5
+ },
6
+ {
7
+ "key": "06aa058e-7ea7-4c6a-3318-da6b8fac6459",
8
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
9
+ },
10
+ {
11
+ "key": "0e9126e0-55f1-46b3-45a2-ecdb2ac58fae",
12
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
13
+ },
14
+ {
15
+ "key": "0e91272d-dfdf-44b9-885f-0e8f790f62b8",
16
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
17
+ },
18
+ {
19
+ "key": "0ea282b8-6240-4b8c-bbd8-8eea0d399408",
20
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
21
+ },
22
+ {
23
+ "key": "055330d2-231c-41f0-81d1-b609a6641d5c",
24
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
25
+ },
26
+ {
27
+ "key": "05ecbcc5-a7c8-43ce-7c13-87cee7104f7c",
28
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
29
+ },
30
+ {
31
+ "key": "05efbda4-5864-4764-b8d0-ca72746b6131",
32
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
33
+ },
34
+ {
35
+ "key": "05f17ce4-6c4f-4bc8-a46b-0dc9199b7ff7",
36
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
37
+ },
38
+ {
39
+ "key": "05f24097-b778-4e5d-c64f-219cbb8f3647",
40
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
41
+ },
42
+ {
43
+ "key": "05f4ab72-5f4b-40c1-77d5-c484ef507a3c",
44
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
45
+ },
46
+ {
47
+ "key": "05f4bb8d-958f-4b4c-8e48-3c2416b2e3bf",
48
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
49
+ },
50
+ {
51
+ "key": "05fa0101-6bed-4a05-b739-73481a260945",
52
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
53
+ },
54
+ {
55
+ "key": "05fa9193-2130-4e71-3e09-d99358cafb4c",
56
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
57
+ },
58
+ {
59
+ "key": "05faf014-f776-4ecc-df7a-c5fc834e4c4c",
60
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
61
+ },
62
+ {
63
+ "key": "05fc0932-eadd-43d6-256a-dcc0cde1370e",
64
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
65
+ },
66
+ {
67
+ "key": "06001a5b-197b-4ea1-72f9-e3d5305034d9",
68
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
69
+ },
70
+ {
71
+ "key": "06007098-aea2-4347-fe9f-3c44b69b1ce9",
72
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
73
+ },
74
+ {
75
+ "key": "0600725e-5f79-4f68-34ba-a5da5f15f92f",
76
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
77
+ },
78
+ {
79
+ "key": "066bfd1f-beb2-48dd-1611-0558276a2f2e",
80
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
81
+ },
82
+ {
83
+ "key": "066c6429-ad06-41eb-eba1-f79dc3912aeb",
84
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
85
+ },
86
+ {
87
+ "key": "06e8866a-a6e0-4241-268c-de9189182fab",
88
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
89
+ },
90
+ {
91
+ "key": "08119c02-d271-430e-53c1-ef1330889f9e",
92
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
93
+ },
94
+ {
95
+ "key": "0e84b8ae-7a05-4ff4-319e-8ae5e035190e",
96
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
97
+ },
98
+ {
99
+ "key": "0565f2aa-64f1-4ed6-8a93-a42654b9af9b",
100
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
101
+ },
102
+ {
103
+ "key": "0e913a98-5607-4f97-a0e9-fe7a9baa5a4e",
104
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
105
+ },
106
+ {
107
+ "key": "056ee99f-b0c0-4a21-7ab8-bae0822d431e",
108
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
109
+ },
110
+ {
111
+ "key": "060068ab-020a-4709-cee7-64594e871314",
112
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
113
+ },
114
+ {
115
+ "key": "07384a3a-9266-4742-1f26-95dbe371a6a1",
116
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
117
+ },
118
+ {
119
+ "key": "09103922-9228-4a65-230c-54952e0c070e",
120
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
121
+ },
122
+ {
123
+ "key": "0a2ada5d-4e7a-465e-7687-11c1cab00694",
124
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
125
+ },
126
+ {
127
+ "key": "0dc651ab-ce36-48fb-a10f-e55d0afc2221",
128
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
129
+ },
130
+ {
131
+ "key": "0e198e72-f693-4fe1-92cc-5fcb89bf43e1",
132
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
133
+ },
134
+ {
135
+ "key": "0e8127c8-aeac-458c-e720-ad8fbeaceb0e",
136
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
137
+ },
138
+ {
139
+ "key": "0e96d306-87a2-49ab-6dbf-30485be8709d",
140
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
141
+ },
142
+ {
143
+ "key": "0e997c88-bd69-40b2-e0d4-2e03b2c1f520",
144
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
145
+ },
146
+ {
147
+ "key": "0f3f2e8f-5978-4616-f053-13315c0ce0f5",
148
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
149
+ },
150
+ {
151
+ "key": "106bd544-81be-4543-3519-e95cf1f89c08",
152
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
153
+ },
154
+ {
155
+ "key": "1110f155-5649-4a83-d108-96b5f4546b95",
156
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
157
+ },
158
+ {
159
+ "key": "115c30d9-0764-4c9f-544b-2f84ef33cd23",
160
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
161
+ },
162
+ {
163
+ "key": "119854ba-7f68-46d6-ff6d-ceaae017363e",
164
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
165
+ },
166
+ {
167
+ "key": "143f754f-f160-4176-96a4-84e3d1203594",
168
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
169
+ },
170
+ {
171
+ "key": "18599338-3386-4d88-ef25-7033bbeacf14",
172
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
173
+ },
174
+ {
175
+ "key": "1aedaeef-6b83-4a2f-6100-7edd1ab04c6f",
176
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
177
+ },
178
+ {
179
+ "key": "05760298-a074-4eca-3584-a1f38811e6a5",
180
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
181
+ },
182
+ {
183
+ "key": "0695c47c-d09b-4114-3af2-ce4521323ba7",
184
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
185
+ },
186
+ {
187
+ "key": "0e905f00-926e-4086-5d56-4a4c294e1db8",
188
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
189
+ },
190
+ {
191
+ "key": "058ccaad-dcda-43ff-b3ce-4bce692245ba",
192
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
193
+ },
194
+ {
195
+ "key": "05c56667-0254-4785-b3d0-86a97450184b",
196
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
197
+ },
198
+ {
199
+ "key": "05dcdb91-44a0-4a78-152c-00eb6053fa11",
200
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
201
+ },
202
+ {
203
+ "key": 29265328,
204
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
205
+ },
206
+ {
207
+ "key": 22829930,
208
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
209
+ },
210
+ {
211
+ "key": 29309733,
212
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
213
+ },
214
+ {
215
+ "key": 22205092,
216
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
217
+ },
218
+ {
219
+ "key": 28339104,
220
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
221
+ },
222
+ {
223
+ "key": 28689366,
224
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
225
+ },
226
+ {
227
+ "key": 23904571,
228
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
229
+ },
230
+ {
231
+ "key": 29365025,
232
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
233
+ },
234
+ {
235
+ "key": 28720303,
236
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
237
+ },
238
+ {
239
+ "key": 27655166,
240
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
241
+ },
242
+ {
243
+ "key": 28720861,
244
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
245
+ },
246
+ {
247
+ "key": 25210117,
248
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
249
+ },
250
+ {
251
+ "key": 28948963,
252
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
253
+ },
254
+ {
255
+ "key": 13046135,
256
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
257
+ },
258
+ {
259
+ "key": 29143686,
260
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
261
+ },
262
+ {
263
+ "key": 29286514,
264
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
265
+ },
266
+ {
267
+ "key": 27922269,
268
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
269
+ },
270
+ {
271
+ "key": 10086066,
272
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
273
+ },
274
+ {
275
+ "key": 12196457,
276
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
277
+ },
278
+ {
279
+ "key": 28726465,
280
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
281
+ },
282
+ {
283
+ "key": 24544220,
284
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
285
+ },
286
+ {
287
+ "key": 26082288,
288
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
289
+ },
290
+ {
291
+ "key": 28290408,
292
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
293
+ },
294
+ {
295
+ "key": 24164757,
296
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
297
+ },
298
+ {
299
+ "key": 27118103,
300
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
301
+ },
302
+ {
303
+ "key": 26928719,
304
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
305
+ },
306
+ {
307
+ "key": 15192981,
308
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
309
+ },
310
+ {
311
+ "key": 19605650,
312
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
313
+ },
314
+ {
315
+ "key": 23089646,
316
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
317
+ },
318
+ {
319
+ "key": 13141760,
320
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
321
+ },
322
+ {
323
+ "key": 24893876,
324
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
325
+ },
326
+ {
327
+ "key": 13455263,
328
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
329
+ },
330
+ {
331
+ "key": 28782969,
332
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
333
+ },
334
+ {
335
+ "key": 23199819,
336
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
337
+ },
338
+ {
339
+ "key": 13445369,
340
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
341
+ },
342
+ {
343
+ "key": 107406,
344
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
345
+ },
346
+ {
347
+ "key": 16033881,
348
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
349
+ },
350
+ {
351
+ "key": 11131360,
352
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
353
+ },
354
+ {
355
+ "key": 17011507,
356
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
357
+ },
358
+ {
359
+ "key": 11308669,
360
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
361
+ },
362
+ {
363
+ "key": 12727894,
364
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
365
+ },
366
+ {
367
+ "key": 9717418,
368
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
369
+ },
370
+ {
371
+ "key": 6026704,
372
+ "color": { "hex": "#FFEB69", "token": "--color-bright-yellow" }
373
+ },
374
+ {
375
+ "key": 14866996,
376
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
377
+ },
378
+ {
379
+ "key": 14945713,
380
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
381
+ },
382
+ {
383
+ "key": 3049217,
384
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
385
+ },
386
+ {
387
+ "key": 16000036,
388
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
389
+ },
390
+ {
391
+ "key": 15951735,
392
+ "color": { "hex": "#A0E1E1", "token": "--color-bright-blue" }
393
+ },
394
+ {
395
+ "key": 13624716,
396
+ "color": { "hex": "#FFD7EF", "token": "--color-bright-pink" }
397
+ },
398
+ {
399
+ "key": 11288359,
400
+ "color": { "hex": "#FFC091", "token": "--color-bright-orange" }
401
+ }
402
+ ]
@@ -0,0 +1,10 @@
1
+ /*
2
+ * The colors we support generating an Avatar background color from a "seed" for.
3
+ * Changing this array will change the assignment between seeds.
4
+ * Do not change this array.
5
+ */var avatarColors=["--color-bright-blue","--color-bright-yellow","--color-bright-pink","--color-bright-orange"],hashSeed=function(a){for(var b=avatarColors.length,c=0,d=1,e=0;e<a.length;e++)c=(c+a.charCodeAt(e)*d)%b,d=d*31%b;return c};/*
6
+ * Takes in a "seed" string and spits out an index for the color we should use.
7
+ * This implementation has been synced across all three clients so that we consistently
8
+ * generate branded avatar colors when rendering a list of Avatars.
9
+ * Do not change this implementation.
10
+ */export var getAvatarColorFromSeed=function(a){return avatarColors[hashSeed(a)]};
@@ -0,0 +1 @@
1
+ export*from"./colors";
@@ -1 +1 @@
1
- import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["url","altText","statusIcon","children"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.slice.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{Person as ProfileIcon,Briefcase as BriefcaseIcon}from"@transferwise/icons";import PropTypes from"prop-types";import{useState,useEffect}from"react";import Avatar,{AvatarType}from"../avatar";import Badge from"../badge";import{ProfileType,Size,Sentiment}from"../common";import StatusIcon from"../statusIcon/StatusIcon";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var OptionalBadge=function(a){var b=a.url,c=a.altText,d=a.statusIcon,e=a.children,f=_objectWithoutProperties(a,_excluded);return b?/*#__PURE__*/_jsx(Badge,_objectSpread(_objectSpread({badge:/*#__PURE__*/_jsx("img",{src:b,alt:c})},f),{},{children:e})):d?/*#__PURE__*/_jsx(Badge,_objectSpread(_objectSpread({badge:/*#__PURE__*/_jsx(StatusIcon,{sentiment:d,size:Size.SMALL})},f),{},{children:e})):e};OptionalBadge.propTypes={url:PropTypes.string,altText:PropTypes.string,statusIcon:PropTypes.oneOf([Sentiment.POSITIVE,Sentiment.NEGATIVE,Sentiment.NEUTRAL,Sentiment.WARNING,Sentiment.PENDING]),children:PropTypes.node.isRequired},OptionalBadge.defaultProps={url:void 0,altText:void 0,statusIcon:void 0};var AvatarWrapper=function(a){var b=a.url,c=a.profileType,d=a.badgeUrl,e=a.badgeAltText,f=a.badgeStatusIcon,g=a.name,h=a.avatarProps,i=a.badgeProps,j=useState(!1),k=_slicedToArray(j,2),l=k[0],m=k[1],n=c===ProfileType.BUSINESS;useEffect(function(){return m(!1)},[b]);return/*#__PURE__*/_jsx(OptionalBadge,_objectSpread(_objectSpread({url:d,altText:e,statusIcon:f},i),{},{children:/*#__PURE__*/_jsx(Avatar,_objectSpread({size:Size.MEDIUM},function getAvatarProps(){return b&&!l?_objectSpread({type:AvatarType.THUMBNAIL,children:/*#__PURE__*/_jsx("img",{src:b,alt:"avatar",onError:function onError(){return m(!0)}})},h):c?_objectSpread({type:AvatarType.ICON,children:n?/*#__PURE__*/_jsx(BriefcaseIcon,{size:"24"}):/*#__PURE__*/_jsx(ProfileIcon,{size:"24"})},h):g?_objectSpread({type:AvatarType.INITIALS,children:/*#__PURE__*/_jsx(_Fragment,{children:getInitials(g)})},h):_objectSpread({type:AvatarType.ICON,children:/*#__PURE__*/_jsx(ProfileIcon,{size:"24"})},h)}()))}))};function getInitials(a){var b=a.split(" ").map(function(a){return a[0]}).join("").toUpperCase();return 1===b.length?b[0]:b[0]+b.slice(-1)}AvatarWrapper.defaultProps={url:void 0,profileType:void 0,badgeUrl:void 0,badgeAltText:void 0,badgeStatusIcon:void 0,name:void 0,avatarProps:{},badgeProps:{}},AvatarWrapper.propTypes={url:PropTypes.string,profileType:PropTypes.oneOf([ProfileType.PERSONAL,ProfileType.BUSINESS]),badgeUrl:PropTypes.string,badgeAltText:PropTypes.string,badgeStatusIcon:PropTypes.oneOf([Sentiment.POSITIVE,Sentiment.NEGATIVE,Sentiment.NEUTRAL,Sentiment.WARNING,Sentiment.PENDING]),name:PropTypes.string,avatarProps:PropTypes.shape({}),badgeProps:PropTypes.shape({})};export default AvatarWrapper;
1
+ import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["url","altText","statusIcon","children"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.slice.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import{Person as ProfileIcon,Briefcase as BriefcaseIcon}from"@transferwise/icons";import PropTypes from"prop-types";import{useState,useEffect}from"react";import Avatar,{AvatarType}from"../avatar";import Badge from"../badge";import{ProfileType,Size,Sentiment}from"../common";import StatusIcon from"../statusIcon/StatusIcon";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var OptionalBadge=function(a){var b=a.url,c=a.altText,d=a.statusIcon,e=a.children,f=_objectWithoutProperties(a,_excluded);return b?/*#__PURE__*/_jsx(Badge,_objectSpread(_objectSpread({badge:/*#__PURE__*/_jsx("img",{src:b,alt:c})},f),{},{children:e})):d?/*#__PURE__*/_jsx(Badge,_objectSpread(_objectSpread({badge:/*#__PURE__*/_jsx(StatusIcon,{sentiment:d,size:Size.SMALL})},f),{},{children:e})):e};OptionalBadge.propTypes={url:PropTypes.string,altText:PropTypes.string,statusIcon:PropTypes.oneOf([Sentiment.POSITIVE,Sentiment.NEGATIVE,Sentiment.NEUTRAL,Sentiment.WARNING,Sentiment.PENDING]),children:PropTypes.node.isRequired},OptionalBadge.defaultProps={url:void 0,altText:void 0,statusIcon:void 0};var AvatarWrapper=function(a){var b=a.url,c=a.profileType,d=a.profileId,e=a.badgeUrl,f=a.badgeAltText,g=a.badgeStatusIcon,h=a.name,i=a.avatarProps,j=a.badgeProps,k=useState(!1),l=_slicedToArray(k,2),m=l[0],n=l[1],o=c===ProfileType.BUSINESS;useEffect(function(){return n(!1)},[b]);return/*#__PURE__*/_jsx(OptionalBadge,_objectSpread(_objectSpread({url:e,altText:f,statusIcon:g},j),{},{children:/*#__PURE__*/_jsx(Avatar,_objectSpread({size:Size.MEDIUM},function getAvatarProps(){return b&&!m?_objectSpread({type:AvatarType.THUMBNAIL,children:/*#__PURE__*/_jsx("img",{src:b,alt:"avatar",onError:function onError(){return n(!0)}})},i):c?_objectSpread({type:AvatarType.ICON,children:o?/*#__PURE__*/_jsx(BriefcaseIcon,{size:"24"}):/*#__PURE__*/_jsx(ProfileIcon,{size:"24"})},i):h?_objectSpread({type:AvatarType.INITIALS,children:/*#__PURE__*/_jsx(_Fragment,{children:getInitials(h)}),backgroundColorSeed:null===d||void 0===d?void 0:d.toString()},i):_objectSpread({type:AvatarType.ICON,children:/*#__PURE__*/_jsx(ProfileIcon,{size:"24"})},i)}()))}))};function getInitials(a){var b=a.split(" ").map(function(a){return a[0]}).join("").toUpperCase();return 1===b.length?b[0]:b[0]+b.slice(-1)}AvatarWrapper.defaultProps={url:void 0,profileType:void 0,profileId:void 0,badgeUrl:void 0,badgeAltText:void 0,badgeStatusIcon:void 0,name:void 0,avatarProps:{},badgeProps:{}},AvatarWrapper.propTypes={url:PropTypes.string,profileType:PropTypes.oneOf([ProfileType.PERSONAL,ProfileType.BUSINESS]),profileId:PropTypes.number,badgeUrl:PropTypes.string,badgeAltText:PropTypes.string,badgeStatusIcon:PropTypes.oneOf([Sentiment.POSITIVE,Sentiment.NEGATIVE,Sentiment.NEUTRAL,Sentiment.WARNING,Sentiment.PENDING]),name:PropTypes.string,avatarProps:PropTypes.shape({}),badgeProps:PropTypes.shape({})};export default AvatarWrapper;