@fluentui-react-native/experimental-avatar 0.14.30 → 0.14.33

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 (43) hide show
  1. package/CHANGELOG.json +88 -1
  2. package/CHANGELOG.md +33 -2
  3. package/lib/JSAvatar.js +2 -2
  4. package/lib/JSAvatar.js.map +1 -1
  5. package/lib/JSAvatar.styling.d.ts.map +1 -1
  6. package/lib/JSAvatar.styling.js +17 -15
  7. package/lib/JSAvatar.styling.js.map +1 -1
  8. package/lib/JSAvatar.types.d.ts +9 -11
  9. package/lib/JSAvatar.types.d.ts.map +1 -1
  10. package/lib/JSAvatarTokens.d.ts.map +1 -1
  11. package/lib/JSAvatarTokens.js +13 -26
  12. package/lib/JSAvatarTokens.js.map +1 -1
  13. package/lib/JSAvatarTokens.win32.d.ts.map +1 -1
  14. package/lib/JSAvatarTokens.win32.js +13 -26
  15. package/lib/JSAvatarTokens.win32.js.map +1 -1
  16. package/lib/useAvatar.d.ts.map +1 -1
  17. package/lib/useAvatar.js +0 -1
  18. package/lib/useAvatar.js.map +1 -1
  19. package/lib-commonjs/JSAvatar.js +2 -2
  20. package/lib-commonjs/JSAvatar.js.map +1 -1
  21. package/lib-commonjs/JSAvatar.styling.d.ts.map +1 -1
  22. package/lib-commonjs/JSAvatar.styling.js +17 -15
  23. package/lib-commonjs/JSAvatar.styling.js.map +1 -1
  24. package/lib-commonjs/JSAvatar.types.d.ts +9 -11
  25. package/lib-commonjs/JSAvatar.types.d.ts.map +1 -1
  26. package/lib-commonjs/JSAvatarTokens.d.ts.map +1 -1
  27. package/lib-commonjs/JSAvatarTokens.js +13 -26
  28. package/lib-commonjs/JSAvatarTokens.js.map +1 -1
  29. package/lib-commonjs/JSAvatarTokens.win32.d.ts.map +1 -1
  30. package/lib-commonjs/JSAvatarTokens.win32.js +13 -26
  31. package/lib-commonjs/JSAvatarTokens.win32.js.map +1 -1
  32. package/lib-commonjs/useAvatar.d.ts.map +1 -1
  33. package/lib-commonjs/useAvatar.js +0 -1
  34. package/lib-commonjs/useAvatar.js.map +1 -1
  35. package/package.json +7 -7
  36. package/src/JSAvatar.styling.ts +18 -16
  37. package/src/JSAvatar.tsx +2 -2
  38. package/src/JSAvatar.types.ts +10 -12
  39. package/src/JSAvatarTokens.ts +13 -26
  40. package/src/JSAvatarTokens.win32.ts +13 -26
  41. package/src/__tests__/JSAvatar.test.jsx +5 -3
  42. package/src/__tests__/__snapshots__/JSAvatar.test.jsx.snap +1 -1
  43. package/src/useAvatar.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/experimental-avatar",
3
- "version": "0.14.30",
3
+ "version": "0.14.33",
4
4
  "description": "A cross-platform Avatar component using the Fluent Design System. Currently only implemented on iOS",
5
5
  "license": "MIT",
6
6
  "author": "Microsoft <fluentuinativeowners@microsoft.com>",
@@ -26,13 +26,13 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@fluentui-react-native/adapters": "^0.8.5",
29
- "@fluentui-react-native/badge": "^0.0.36",
29
+ "@fluentui-react-native/badge": "^0.0.38",
30
30
  "@fluentui-react-native/component-cache": "^1.3.2",
31
- "@fluentui-react-native/framework": "0.7.28",
32
- "@fluentui-react-native/icon": "^0.11.23",
33
- "@fluentui-react-native/interactive-hooks": "^0.15.8",
34
- "@fluentui-react-native/theme-tokens": "^0.16.3",
35
- "@fluentui-react-native/tokens": "^0.12.2",
31
+ "@fluentui-react-native/framework": "0.7.30",
32
+ "@fluentui-react-native/icon": "^0.11.25",
33
+ "@fluentui-react-native/interactive-hooks": "^0.16.0",
34
+ "@fluentui-react-native/theme-tokens": "^0.18.0",
35
+ "@fluentui-react-native/tokens": "^0.14.0",
36
36
  "@fluentui-react-native/use-styling": "^0.8.3",
37
37
  "react-native-svg": "^12.3.0"
38
38
  },
@@ -20,6 +20,7 @@ export const avatarStates: (keyof JSAvatarTokens)[] = [
20
20
  'ringColor',
21
21
  'ringBackgroundColor',
22
22
  'iconColor',
23
+ 'size',
23
24
  ];
24
25
 
25
26
  export const stylingSettings: UseStylingOptions<JSAvatarProps, AvatarSlotProps, JSAvatarTokens> = {
@@ -28,12 +29,12 @@ export const stylingSettings: UseStylingOptions<JSAvatarProps, AvatarSlotProps,
28
29
  slotProps: {
29
30
  root: buildProps(
30
31
  (tokens: JSAvatarTokens) => {
31
- const { horizontalIconAlignment, verticalIconAlignment, width, height, avatarOpacity } = tokens;
32
+ const { horizontalIconAlignment, verticalIconAlignment, size, avatarOpacity } = tokens;
32
33
  return {
33
34
  style: {
34
35
  flexDirection: 'row',
35
- width: width,
36
- height: height,
36
+ width: size,
37
+ height: size,
37
38
  justifyContent: nameMap[horizontalIconAlignment || 'end'] as ViewStyle['justifyContent'],
38
39
  alignItems: nameMap[verticalIconAlignment || 'end'] as ViewStyle['alignItems'],
39
40
  horizontalIconAlignment,
@@ -42,7 +43,7 @@ export const stylingSettings: UseStylingOptions<JSAvatarProps, AvatarSlotProps,
42
43
  },
43
44
  };
44
45
  },
45
- ['horizontalIconAlignment', 'verticalIconAlignment', 'avatarOpacity', 'height', 'width'],
46
+ ['horizontalIconAlignment', 'verticalIconAlignment', 'avatarOpacity', 'size'],
46
47
  ),
47
48
  initials: buildProps(
48
49
  (tokens: JSAvatarTokens, theme: Theme) => {
@@ -58,13 +59,13 @@ export const stylingSettings: UseStylingOptions<JSAvatarProps, AvatarSlotProps,
58
59
  ),
59
60
  initialsBackground: buildProps(
60
61
  (tokens: JSAvatarTokens, theme: Theme) => {
61
- const { backgroundColor } = tokens;
62
+ const { backgroundColor, size } = tokens;
62
63
 
63
64
  return {
64
65
  style: {
65
66
  ...borderStyles.from(tokens, theme),
66
- width: tokens.width,
67
- height: tokens.height,
67
+ width: size,
68
+ height: size,
68
69
  flexGrow: 1,
69
70
  alignSelf: 'stretch',
70
71
  justifyContent: 'center',
@@ -75,21 +76,22 @@ export const stylingSettings: UseStylingOptions<JSAvatarProps, AvatarSlotProps,
75
76
  },
76
77
  };
77
78
  },
78
- ['backgroundColor', 'width', 'height', 'borderColor', 'borderWidth', ...borderStyles.keys],
79
+ ['backgroundColor', 'size', 'borderColor', 'borderWidth', ...borderStyles.keys],
79
80
  ),
80
81
  image: buildProps(
81
82
  (tokens: JSAvatarTokens) => {
83
+ const { borderRadius, size, borderWidth, borderColor } = tokens;
82
84
  return {
83
85
  style: {
84
- borderRadius: tokens.borderRadius,
85
- width: tokens.width,
86
- height: tokens.height,
87
- borderWidth: tokens.borderWidth,
88
- borderColor: tokens.borderColor,
86
+ borderRadius: borderRadius,
87
+ width: size,
88
+ height: size,
89
+ borderWidth: borderWidth,
90
+ borderColor: borderColor,
89
91
  },
90
92
  };
91
93
  },
92
- ['borderRadius', 'width', 'height', 'borderColor', 'borderWidth'],
94
+ ['borderRadius', 'size', 'borderColor', 'borderWidth'],
93
95
  ),
94
96
  icon: buildProps(
95
97
  (tokens: JSAvatarTokens) => {
@@ -106,7 +108,7 @@ export const stylingSettings: UseStylingOptions<JSAvatarProps, AvatarSlotProps,
106
108
  ),
107
109
  ring: buildProps(
108
110
  (tokens: JSAvatarTokens, theme: Theme) => {
109
- const ringConfig = getRingConfig(tokens.width);
111
+ const ringConfig = getRingConfig(tokens.size);
110
112
  return {
111
113
  style: {
112
114
  borderStyle: 'solid',
@@ -121,7 +123,7 @@ export const stylingSettings: UseStylingOptions<JSAvatarProps, AvatarSlotProps,
121
123
  },
122
124
  };
123
125
  },
124
- ['width', 'height', 'ringColor', ...borderStyles.keys],
126
+ ['size', 'ringColor', ...borderStyles.keys],
125
127
  ),
126
128
  badge: buildProps(
127
129
  (tokens: JSAvatarTokens) => {
package/src/JSAvatar.tsx CHANGED
@@ -18,7 +18,8 @@ import { SvgXml } from 'react-native-svg';
18
18
  * @returns Whether the styles that are assigned to the layer should be applied to the avatar
19
19
  */
20
20
  export const avatarLookup = (layer: string, state: JSAvatarState, userProps: JSAvatarProps): boolean => {
21
- const avatarSize = `size${userProps.size || 24}`;
21
+ const size = userProps.size;
22
+ const avatarSize = size ? `size${size}` : '';
22
23
  return (
23
24
  state[layer] ||
24
25
  userProps[layer] ||
@@ -27,7 +28,6 @@ export const avatarLookup = (layer: string, state: JSAvatarState, userProps: JSA
27
28
  layer === userProps['avatarColor'] ||
28
29
  (!userProps['avatarColor'] && layer === 'neutral') ||
29
30
  layer === avatarSize ||
30
- (!userProps['size'] && layer === 'size24') ||
31
31
  (userProps.active === 'inactive' && layer === 'inactive')
32
32
  );
33
33
  };
@@ -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 {
@@ -147,16 +157,6 @@ export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
147
157
  */
148
158
  name?: string;
149
159
 
150
- /**
151
- * Size of the avatar in pixels.
152
- *
153
- * Size is restricted to a limited set of supported values recommended for most uses (see `AvatarSizeValue`) and
154
- * based on design guidelines for the Avatar control.
155
- *
156
- * @defaultvalue 24
157
- */
158
- size?: AvatarSize;
159
-
160
160
  /**
161
161
  * The avatar can have a circular or square shape.
162
162
  * @defaultvalue circular
@@ -172,7 +172,6 @@ export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
172
172
  export interface JSAvatarTokens extends IBackgroundColorTokens, IForegroundColorTokens, AvatarConfigurableProps, IBorderTokens, FontTokens {
173
173
  iconColor?: ColorValue;
174
174
  iconSize?: number;
175
- height?: number;
176
175
  horizontalIconAlignment?: IconAlignment;
177
176
  verticalIconAlignment?: IconAlignment;
178
177
  circular?: JSAvatarTokens;
@@ -193,7 +192,6 @@ export interface JSAvatarTokens extends IBackgroundColorTokens, IForegroundColor
193
192
  size72?: JSAvatarTokens;
194
193
  size96?: JSAvatarTokens;
195
194
  size120?: JSAvatarTokens;
196
- width?: number;
197
195
  badgeSize?: BadgeSize;
198
196
  neutral?: JSAvatarTokens;
199
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(' ');