@fluentui-react-native/experimental-avatar 0.14.36 → 0.14.39

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 (50) hide show
  1. package/CHANGELOG.json +64 -1
  2. package/CHANGELOG.md +29 -2
  3. package/MIGRATION.md +158 -0
  4. package/SPEC.md +2 -7
  5. package/lib/JSAvatar.d.ts.map +1 -1
  6. package/lib/JSAvatar.js +2 -3
  7. package/lib/JSAvatar.js.map +1 -1
  8. package/lib/JSAvatar.styling.d.ts.map +1 -1
  9. package/lib/JSAvatar.styling.js +11 -7
  10. package/lib/JSAvatar.styling.js.map +1 -1
  11. package/lib/JSAvatar.types.d.ts +10 -9
  12. package/lib/JSAvatar.types.d.ts.map +1 -1
  13. package/lib/JSAvatar.types.js +4 -0
  14. package/lib/JSAvatar.types.js.map +1 -1
  15. package/lib/JSAvatarTokens.d.ts.map +1 -1
  16. package/lib/JSAvatarTokens.js +6 -3
  17. package/lib/JSAvatarTokens.js.map +1 -1
  18. package/lib/JSAvatarTokens.win32.d.ts.map +1 -1
  19. package/lib/JSAvatarTokens.win32.js +3 -0
  20. package/lib/JSAvatarTokens.win32.js.map +1 -1
  21. package/lib/useAvatar.d.ts.map +1 -1
  22. package/lib/useAvatar.js +3 -6
  23. package/lib/useAvatar.js.map +1 -1
  24. package/lib-commonjs/JSAvatar.d.ts.map +1 -1
  25. package/lib-commonjs/JSAvatar.js +2 -3
  26. package/lib-commonjs/JSAvatar.js.map +1 -1
  27. package/lib-commonjs/JSAvatar.styling.d.ts.map +1 -1
  28. package/lib-commonjs/JSAvatar.styling.js +10 -6
  29. package/lib-commonjs/JSAvatar.styling.js.map +1 -1
  30. package/lib-commonjs/JSAvatar.types.d.ts +10 -9
  31. package/lib-commonjs/JSAvatar.types.d.ts.map +1 -1
  32. package/lib-commonjs/JSAvatar.types.js +5 -1
  33. package/lib-commonjs/JSAvatar.types.js.map +1 -1
  34. package/lib-commonjs/JSAvatarTokens.d.ts.map +1 -1
  35. package/lib-commonjs/JSAvatarTokens.js +6 -3
  36. package/lib-commonjs/JSAvatarTokens.js.map +1 -1
  37. package/lib-commonjs/JSAvatarTokens.win32.d.ts.map +1 -1
  38. package/lib-commonjs/JSAvatarTokens.win32.js +3 -0
  39. package/lib-commonjs/JSAvatarTokens.win32.js.map +1 -1
  40. package/lib-commonjs/useAvatar.d.ts.map +1 -1
  41. package/lib-commonjs/useAvatar.js +3 -6
  42. package/lib-commonjs/useAvatar.js.map +1 -1
  43. package/package.json +4 -4
  44. package/src/JSAvatar.styling.ts +24 -7
  45. package/src/JSAvatar.tsx +6 -8
  46. package/src/JSAvatar.types.ts +12 -9
  47. package/src/JSAvatarTokens.ts +6 -3
  48. package/src/JSAvatarTokens.win32.ts +3 -0
  49. package/src/__tests__/__snapshots__/JSAvatar.test.jsx.snap +4 -0
  50. package/src/useAvatar.ts +18 -8
@@ -56,18 +56,22 @@ export const AvatarColors = [
56
56
  'mink',
57
57
  'platinum',
58
58
  'anchor',
59
+ 'burgundy',
60
+ 'hotPink',
61
+ 'orchid',
59
62
  ] as const;
63
+ export const ColorSchemes = ['neutral', 'brand', 'colorful'] as const;
60
64
  export type AvatarSize = typeof AvatarSizes[number];
61
65
  export type AvatarNamedColor = typeof AvatarColors[number];
66
+ export type AvatarColorSchemes = typeof ColorSchemes[number];
62
67
 
63
68
  export type AvatarShape = 'circular' | 'square';
64
69
  export type AvatarActive = 'active' | 'inactive' | 'unset';
65
70
  export type AvatarActiveAppearance = 'ring';
66
- export type AvatarColor = 'neutral' | 'brand' | 'colorful' | AvatarNamedColor;
71
+ export type AvatarColor = AvatarColorSchemes | AvatarNamedColor | ColorValue;
67
72
  export type IconAlignment = 'start' | 'center' | 'end';
68
73
 
69
74
  export interface RingConfig {
70
- accent?: boolean;
71
75
  transparent?: boolean;
72
76
  ringThickness?: number;
73
77
  innerGap?: number;
@@ -84,6 +88,7 @@ export interface AvatarConfigurableProps {
84
88
  * @defaultvalue neutral
85
89
  */
86
90
  avatarColor?: AvatarColor;
91
+ initialsColor?: ColorValue;
87
92
  ring?: RingConfig;
88
93
 
89
94
  /**
@@ -134,11 +139,6 @@ export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
134
139
  */
135
140
  idForColor?: string;
136
141
 
137
- /**
138
- * The Avatar's image.
139
- */
140
- image?: ImageProps;
141
-
142
142
  /**
143
143
  * (optional) Custom initials.
144
144
  *
@@ -164,9 +164,9 @@ export interface JSAvatarProps extends IViewProps, AvatarConfigurableProps {
164
164
  shape?: AvatarShape;
165
165
 
166
166
  /**
167
- * Currently used for image URL, will be deprecated when image prop works
167
+ * Shorthand for passing image URL instead of using `image` prop
168
168
  */
169
- src?: string;
169
+ imageUrl?: string;
170
170
  }
171
171
 
172
172
  export interface JSAvatarTokens extends IBackgroundColorTokens, IForegroundColorTokens, AvatarConfigurableProps, IBorderTokens, FontTokens {
@@ -225,6 +225,9 @@ export interface JSAvatarTokens extends IBackgroundColorTokens, IForegroundColor
225
225
  mink?: JSAvatarTokens;
226
226
  platinum?: JSAvatarTokens;
227
227
  anchor?: JSAvatarTokens;
228
+ burgundy?: JSAvatarTokens;
229
+ hotPink?: JSAvatarTokens;
230
+ orchid?: JSAvatarTokens;
228
231
  }
229
232
 
230
233
  export interface AvatarSlotProps {
@@ -7,15 +7,15 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
7
7
  ({
8
8
  horizontalIconAlignment: 'end',
9
9
  verticalIconAlignment: 'end',
10
- color: globalTokens.color.white,
11
- backgroundColor: globalTokens.color.cornflower.primary,
10
+ color: t.colors.neutralForeground3,
11
+ backgroundColor: t.colors.neutralBackground6,
12
12
  avatarOpacity: 1,
13
13
  fontFamily: t.typography.families.primary,
14
14
  fontWeight: globalTokens.font.weight.semibold,
15
15
  fontSize: globalTokens.font.size[200],
16
16
  size: 24,
17
17
  iconSize: 16,
18
- iconColor: globalTokens.color.white,
18
+ iconColor: t.colors.neutralForeground3,
19
19
  ringColor: t.colors.transparentStroke,
20
20
  borderColor: globalTokens.color.white,
21
21
  borderWidth: t.host.appearance === 'highContrast' ? 1 : 0,
@@ -163,6 +163,9 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
163
163
  mink: getColorProps('mink', t),
164
164
  platinum: getColorProps('platinum', t),
165
165
  anchor: getColorProps('anchor', t),
166
+ burgundy: getColorProps('burgundy', t),
167
+ hotPink: getColorProps('hotPink', t),
168
+ orchid: getColorProps('orchid', t),
166
169
  } as JSAvatarTokens);
167
170
 
168
171
  /**
@@ -163,6 +163,9 @@ export const defaultJSAvatarTokens: TokenSettings<JSAvatarTokens, Theme> = (t: T
163
163
  mink: getColorProps('mink', t),
164
164
  platinum: getColorProps('platinum', t),
165
165
  anchor: getColorProps('anchor', t),
166
+ burgundy: getColorProps('burgundy', t),
167
+ hotPink: getColorProps('hotPink', t),
168
+ orchid: getColorProps('orchid', t),
166
169
  } as JSAvatarTokens);
167
170
 
168
171
  /**
@@ -2,6 +2,9 @@
2
2
 
3
3
  exports[`Avatar rendering renders Avatar 1`] = `
4
4
  <View
5
+ accessibilityLabel=""
6
+ accessibilityRole="image"
7
+ accessible={true}
5
8
  shape="circular"
6
9
  style={
7
10
  Object {
@@ -17,6 +20,7 @@ exports[`Avatar rendering renders Avatar 1`] = `
17
20
  }
18
21
  >
19
22
  <View
23
+ accessible={false}
20
24
  style={
21
25
  Object {
22
26
  "alignItems": "center",
package/src/useAvatar.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { JSAvatarProps, AvatarInfo, JSAvatarState, AvatarColors } from './JSAvatar.types';
2
- import { ImageProps, ImageSourcePropType } from 'react-native';
3
2
  import { PresenceBadgeProps } from '@fluentui-react-native/badge';
4
3
  import { titles } from './titles';
5
4
  import { getHashCodeWeb } from './getHashCode';
@@ -11,16 +10,25 @@ import { getHashCodeWeb } from './getHashCode';
11
10
  * @returns configured props and state for FURN Avatar
12
11
  */
13
12
  export const useAvatar = (props: JSAvatarProps): AvatarInfo => {
14
- const { avatarColor, active, accessibilityLabel, activeAppearance, badge, idForColor, initials, name, src, ring, shape, ...rest } = props;
13
+ const {
14
+ avatarColor,
15
+ active,
16
+ accessibilityLabel,
17
+ accessibilityRole,
18
+ activeAppearance,
19
+ badge,
20
+ idForColor,
21
+ initials,
22
+ name,
23
+ ring,
24
+ shape,
25
+ ...rest
26
+ } = props;
15
27
 
16
28
  const showRing = active === 'active' && activeAppearance === 'ring';
17
29
  const transparentRing = !!ring?.transparent;
18
30
  const showBadge = (!active || active === 'unset') && !!badge && !!badge.status;
19
-
20
- const imageProps: ImageProps = {
21
- accessibilityLabel,
22
- source: src ? ({ uri: src } as ImageSourcePropType) : undefined,
23
- };
31
+ const accessibilityText = `${name || ''}${showBadge ? `, ${badge.status}` : ''}`;
24
32
 
25
33
  const badgeProps: PresenceBadgeProps = {
26
34
  size: 'small',
@@ -39,12 +47,14 @@ export const useAvatar = (props: JSAvatarProps): AvatarInfo => {
39
47
 
40
48
  return {
41
49
  props: {
50
+ accessible: true,
51
+ accessibilityLabel: accessibilityLabel || accessibilityText,
52
+ accessibilityRole: accessibilityRole ?? 'image',
42
53
  avatarColor: _avatarColor,
43
54
  shape: shape || 'circular',
44
55
  ...rest,
45
56
  active,
46
57
  activeAppearance,
47
- image: imageProps,
48
58
  badge: badgeProps,
49
59
  initials: _initials,
50
60
  },