@fluentui-react-native/experimental-avatar 0.14.29 → 0.14.32

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 (44) hide show
  1. package/CHANGELOG.json +118 -7
  2. package/CHANGELOG.md +37 -2
  3. package/SPEC.md +310 -0
  4. package/lib/JSAvatar.js +2 -2
  5. package/lib/JSAvatar.js.map +1 -1
  6. package/lib/JSAvatar.styling.d.ts.map +1 -1
  7. package/lib/JSAvatar.styling.js +17 -15
  8. package/lib/JSAvatar.styling.js.map +1 -1
  9. package/lib/JSAvatar.types.d.ts +21 -13
  10. package/lib/JSAvatar.types.d.ts.map +1 -1
  11. package/lib/JSAvatarTokens.d.ts.map +1 -1
  12. package/lib/JSAvatarTokens.js +13 -26
  13. package/lib/JSAvatarTokens.js.map +1 -1
  14. package/lib/JSAvatarTokens.win32.d.ts.map +1 -1
  15. package/lib/JSAvatarTokens.win32.js +13 -26
  16. package/lib/JSAvatarTokens.win32.js.map +1 -1
  17. package/lib/useAvatar.d.ts.map +1 -1
  18. package/lib/useAvatar.js +0 -1
  19. package/lib/useAvatar.js.map +1 -1
  20. package/lib-commonjs/JSAvatar.js +2 -2
  21. package/lib-commonjs/JSAvatar.js.map +1 -1
  22. package/lib-commonjs/JSAvatar.styling.d.ts.map +1 -1
  23. package/lib-commonjs/JSAvatar.styling.js +17 -15
  24. package/lib-commonjs/JSAvatar.styling.js.map +1 -1
  25. package/lib-commonjs/JSAvatar.types.d.ts +21 -13
  26. package/lib-commonjs/JSAvatar.types.d.ts.map +1 -1
  27. package/lib-commonjs/JSAvatarTokens.d.ts.map +1 -1
  28. package/lib-commonjs/JSAvatarTokens.js +13 -26
  29. package/lib-commonjs/JSAvatarTokens.js.map +1 -1
  30. package/lib-commonjs/JSAvatarTokens.win32.d.ts.map +1 -1
  31. package/lib-commonjs/JSAvatarTokens.win32.js +13 -26
  32. package/lib-commonjs/JSAvatarTokens.win32.js.map +1 -1
  33. package/lib-commonjs/useAvatar.d.ts.map +1 -1
  34. package/lib-commonjs/useAvatar.js +0 -1
  35. package/lib-commonjs/useAvatar.js.map +1 -1
  36. package/package.json +7 -7
  37. package/src/JSAvatar.styling.ts +18 -16
  38. package/src/JSAvatar.tsx +2 -2
  39. package/src/JSAvatar.types.ts +24 -14
  40. package/src/JSAvatarTokens.ts +13 -26
  41. package/src/JSAvatarTokens.win32.ts +13 -26
  42. package/src/__tests__/JSAvatar.test.jsx +5 -3
  43. package/src/__tests__/__snapshots__/JSAvatar.test.jsx.snap +1 -1
  44. package/src/useAvatar.ts +0 -1
@@ -62,7 +62,7 @@ export type AvatarNamedColor = typeof AvatarColors[number];
62
62
 
63
63
  export type AvatarShape = 'circular' | 'square';
64
64
  export type AvatarActive = 'active' | 'inactive' | 'unset';
65
- export type AvatarActiveAppearance = 'ring' | 'shadow' | 'glow' | 'ring-shadow' | 'ring-glow';
65
+ export type AvatarActiveAppearance = 'ring';
66
66
  export type AvatarColor = 'neutral' | 'brand' | 'colorful' | AvatarNamedColor;
67
67
  export type IconAlignment = 'start' | 'center' | 'end';
68
68
 
@@ -85,6 +85,16 @@ export interface AvatarConfigurableProps {
85
85
  */
86
86
  avatarColor?: AvatarColor;
87
87
  ring?: RingConfig;
88
+
89
+ /**
90
+ * Size of the avatar in pixels.
91
+ *
92
+ * Size is restricted to a limited set of supported values recommended for most uses (see `AvatarSizeValue`) and
93
+ * based on design guidelines for the Avatar control.
94
+ *
95
+ * @defaultvalue 24
96
+ */
97
+ size?: AvatarSize;
88
98
  }
89
99
 
90
100
  export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
@@ -104,6 +114,11 @@ export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
104
114
  * @defaultvalue ring
105
115
  */
106
116
  activeAppearance?: AvatarActiveAppearance;
117
+
118
+ /**
119
+ * Badge shows the avatar's presence status.
120
+ * Badge can be shown only if `active` prop is undefined or unset
121
+ */
107
122
  badge?: PresenceBadgeProps;
108
123
 
109
124
  /**
@@ -117,8 +132,11 @@ export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
117
132
  * Specify a string to be used instead of the name, to determine which color to use when color="colorful".
118
133
  * Use this when a name is not available, but there is another unique identifier that can be used instead.
119
134
  */
120
- idForColor?: string | undefined;
135
+ idForColor?: string;
121
136
 
137
+ /**
138
+ * The Avatar's image.
139
+ */
122
140
  image?: ImageProps;
123
141
 
124
142
  /**
@@ -139,28 +157,21 @@ export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
139
157
  */
140
158
  name?: string;
141
159
 
142
- /**
143
- * Size of the avatar in pixels.
144
- *
145
- * Size is restricted to a limited set of supported values recommended for most uses (see `AvatarSizeValue`) and
146
- * based on design guidelines for the Avatar control.
147
- *
148
- * @defaultvalue 24
149
- */
150
- size?: AvatarSize;
151
-
152
160
  /**
153
161
  * The avatar can have a circular or square shape.
154
162
  * @defaultvalue circular
155
163
  */
156
164
  shape?: AvatarShape;
165
+
166
+ /**
167
+ * Currently used for image URL, will be deprecated when image prop works
168
+ */
157
169
  src?: string;
158
170
  }
159
171
 
160
172
  export interface JSAvatarTokens extends IBackgroundColorTokens, IForegroundColorTokens, AvatarConfigurableProps, IBorderTokens, FontTokens {
161
173
  iconColor?: ColorValue;
162
174
  iconSize?: number;
163
- height?: number;
164
175
  horizontalIconAlignment?: IconAlignment;
165
176
  verticalIconAlignment?: IconAlignment;
166
177
  circular?: JSAvatarTokens;
@@ -181,7 +192,6 @@ export interface JSAvatarTokens extends IBackgroundColorTokens, IForegroundColor
181
192
  size72?: JSAvatarTokens;
182
193
  size96?: JSAvatarTokens;
183
194
  size120?: JSAvatarTokens;
184
- width?: number;
185
195
  badgeSize?: BadgeSize;
186
196
  neutral?: JSAvatarTokens;
187
197
  brand?: JSAvatarTokens;
@@ -13,8 +13,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
13
13
  fontFamily: t.typography.families.primary,
14
14
  fontWeight: globalTokens.font.weight.semibold,
15
15
  fontSize: globalTokens.font.size[200],
16
- width: 24,
17
- height: 24,
16
+ size: 24,
18
17
  iconSize: 16,
19
18
  iconColor: globalTokens.color.white,
20
19
  ringColor: t.colors.transparentStroke,
@@ -30,8 +29,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
30
29
  avatarOpacity: 0.8,
31
30
  },
32
31
  size20: {
33
- width: 20,
34
- height: 20,
32
+ size: 20,
35
33
  badgeSize: 'smallest',
36
34
  iconSize: 16,
37
35
  fontSize: globalTokens.font.size[100],
@@ -40,8 +38,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
40
38
  },
41
39
  },
42
40
  size24: {
43
- width: 24,
44
- height: 24,
41
+ size: 24,
45
42
  badgeSize: 'smallest',
46
43
  iconSize: 16,
47
44
  fontSize: globalTokens.font.size[100],
@@ -50,41 +47,35 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
50
47
  },
51
48
  },
52
49
  size28: {
53
- width: 28,
54
- height: 28,
50
+ size: 28,
55
51
  badgeSize: 'smaller',
56
52
  iconSize: 20,
57
53
  fontWeight: globalTokens.font.weight.semibold,
58
54
  fontSize: globalTokens.font.size[100],
59
55
  },
60
56
  size32: {
61
- width: 32,
62
- height: 32,
57
+ size: 32,
63
58
  badgeSize: 'smaller',
64
59
  iconSize: 20,
65
60
  fontSize: globalTokens.font.size[100],
66
61
  },
67
62
  size36: {
68
- width: 36,
69
- height: 36,
63
+ size: 36,
70
64
  badgeSize: 'smaller',
71
65
  iconSize: 20,
72
66
  },
73
67
  size40: {
74
- width: 40,
75
- height: 40,
68
+ size: 40,
76
69
  badgeSize: 'small',
77
70
  iconSize: 20,
78
71
  },
79
72
  size48: {
80
- width: 48,
81
- height: 48,
73
+ size: 48,
82
74
  badgeSize: 'small',
83
75
  iconSize: 24,
84
76
  },
85
77
  size56: {
86
- width: 56,
87
- height: 56,
78
+ size: 56,
88
79
  badgeSize: 'medium',
89
80
  iconSize: 28,
90
81
  fontSize: globalTokens.font.size[400],
@@ -93,8 +84,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
93
84
  },
94
85
  },
95
86
  size64: {
96
- width: 64,
97
- height: 64,
87
+ size: 64,
98
88
  badgeSize: 'large',
99
89
  iconSize: 32,
100
90
  fontSize: globalTokens.font.size[500],
@@ -103,8 +93,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
103
93
  },
104
94
  },
105
95
  size72: {
106
- width: 72,
107
- height: 72,
96
+ size: 72,
108
97
  badgeSize: 'large',
109
98
  iconSize: 32,
110
99
  fontSize: globalTokens.font.size[500],
@@ -113,8 +102,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
113
102
  },
114
103
  },
115
104
  size96: {
116
- width: 96,
117
- height: 96,
105
+ size: 96,
118
106
  badgeSize: 'largest',
119
107
  iconSize: 48,
120
108
  fontWeight: globalTokens.font.weight.regular,
@@ -124,8 +112,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
124
112
  },
125
113
  },
126
114
  size120: {
127
- width: 120,
128
- height: 120,
115
+ size: 120,
129
116
  badgeSize: 'largest',
130
117
  iconSize: 48,
131
118
  fontWeight: globalTokens.font.weight.regular,
@@ -13,8 +13,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
13
13
  fontFamily: t.typography.families.primary,
14
14
  fontWeight: globalTokens.font.weight.semibold,
15
15
  fontSize: globalTokens.font.size[200],
16
- width: 24,
17
- height: 24,
16
+ size: 24,
18
17
  iconSize: 16,
19
18
  iconColor: globalTokens.color.white,
20
19
  ringColor: t.colors.transparentStroke,
@@ -30,8 +29,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
30
29
  avatarOpacity: 0.8,
31
30
  },
32
31
  size20: {
33
- width: 20,
34
- height: 20,
32
+ size: 20,
35
33
  badgeSize: 'smallest',
36
34
  iconSize: 16,
37
35
  fontSize: globalTokens.font.size[100],
@@ -40,8 +38,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
40
38
  },
41
39
  },
42
40
  size24: {
43
- width: 24,
44
- height: 24,
41
+ size: 24,
45
42
  badgeSize: 'smallest',
46
43
  iconSize: 16,
47
44
  fontSize: globalTokens.font.size[100],
@@ -50,41 +47,35 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
50
47
  },
51
48
  },
52
49
  size28: {
53
- width: 28,
54
- height: 28,
50
+ size: 28,
55
51
  badgeSize: 'smaller',
56
52
  iconSize: 20,
57
53
  fontWeight: globalTokens.font.weight.semibold,
58
54
  fontSize: globalTokens.font.size[100],
59
55
  },
60
56
  size32: {
61
- width: 32,
62
- height: 32,
57
+ size: 32,
63
58
  badgeSize: 'smaller',
64
59
  iconSize: 20,
65
60
  fontSize: globalTokens.font.size[100],
66
61
  },
67
62
  size36: {
68
- width: 36,
69
- height: 36,
63
+ size: 36,
70
64
  badgeSize: 'smaller',
71
65
  iconSize: 20,
72
66
  },
73
67
  size40: {
74
- width: 40,
75
- height: 40,
68
+ size: 40,
76
69
  badgeSize: 'small',
77
70
  iconSize: 20,
78
71
  },
79
72
  size48: {
80
- width: 48,
81
- height: 48,
73
+ size: 48,
82
74
  badgeSize: 'small',
83
75
  iconSize: 24,
84
76
  },
85
77
  size56: {
86
- width: 56,
87
- height: 56,
78
+ size: 56,
88
79
  badgeSize: 'medium',
89
80
  iconSize: 28,
90
81
  fontSize: globalTokens.font.size[400],
@@ -93,8 +84,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
93
84
  },
94
85
  },
95
86
  size64: {
96
- width: 64,
97
- height: 64,
87
+ size: 64,
98
88
  badgeSize: 'large',
99
89
  iconSize: 32,
100
90
  fontSize: globalTokens.font.size[500],
@@ -103,8 +93,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
103
93
  },
104
94
  },
105
95
  size72: {
106
- width: 72,
107
- height: 72,
96
+ size: 72,
108
97
  badgeSize: 'large',
109
98
  iconSize: 32,
110
99
  fontSize: globalTokens.font.size[500],
@@ -113,8 +102,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
113
102
  },
114
103
  },
115
104
  size96: {
116
- width: 96,
117
- height: 96,
105
+ size: 96,
118
106
  badgeSize: 'largest',
119
107
  iconSize: 48,
120
108
  fontWeight: globalTokens.font.weight.regular,
@@ -124,8 +112,7 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
124
112
  },
125
113
  },
126
114
  size120: {
127
- width: 120,
128
- height: 120,
115
+ size: 120,
129
116
  badgeSize: 'largest',
130
117
  iconSize: 48,
131
118
  fontWeight: globalTokens.font.weight.regular,
@@ -22,9 +22,11 @@ const otherTestNames = ['(206) 123-4567', '耿盈盈']; // will return this case
22
22
  const namesWithTitles = ['Mr Feynman', 'Dr Richard Feynman'];
23
23
  const initialsForNameWithTitles = ['F', 'RF'];
24
24
 
25
- it('renders Avatar', () => {
26
- const tree = renderer.create(<JSAvatar />).toJSON();
27
- expect(tree).toMatchSnapshot();
25
+ describe('Avatar rendering', () => {
26
+ it('renders Avatar', () => {
27
+ const tree = renderer.create(<JSAvatar />).toJSON();
28
+ expect(tree).toMatchSnapshot();
29
+ });
28
30
  });
29
31
 
30
32
  describe('validateAlphabeticalCharacters method', () => {
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`renders Avatar 1`] = `
3
+ exports[`Avatar rendering renders Avatar 1`] = `
4
4
  <View
5
5
  shape="circular"
6
6
  style={
package/src/useAvatar.ts CHANGED
@@ -62,7 +62,6 @@ export const getInitials = (name: string): string => {
62
62
  if (!name && !validateAlphabeticalCharacters(name)) {
63
63
  return '';
64
64
  }
65
- // prettier-ignore
66
65
  const nonWordRegExp = new RegExp('\\W+(?<!\\S-)', 'g');
67
66
  const wordsInBracesRegExp = new RegExp('(\\(|\\[|\\{)\\w+(\\)|\\]|\\})', 'g');
68
67
  let words = name.replace(wordsInBracesRegExp, ' ').replace(nonWordRegExp, ' ').trim().split(' ');