@fluentui/react-avatar 9.2.6 → 9.2.7

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 (78) hide show
  1. package/CHANGELOG.json +54 -1
  2. package/CHANGELOG.md +16 -2
  3. package/dist/index.d.ts +35 -4
  4. package/lib-amd/Avatar.js +6 -0
  5. package/lib-amd/Avatar.js.map +1 -0
  6. package/lib-amd/AvatarGroup.js +6 -0
  7. package/lib-amd/AvatarGroup.js.map +1 -0
  8. package/lib-amd/AvatarGroupItem.js +6 -0
  9. package/lib-amd/AvatarGroupItem.js.map +1 -0
  10. package/lib-amd/AvatarGroupPopover.js +6 -0
  11. package/lib-amd/AvatarGroupPopover.js.map +1 -0
  12. package/lib-amd/components/Avatar/Avatar.js +12 -0
  13. package/lib-amd/components/Avatar/Avatar.js.map +1 -0
  14. package/lib-amd/components/Avatar/Avatar.types.js +5 -0
  15. package/lib-amd/components/Avatar/Avatar.types.js.map +1 -0
  16. package/lib-amd/components/Avatar/index.js +10 -0
  17. package/lib-amd/components/Avatar/index.js.map +1 -0
  18. package/lib-amd/components/Avatar/renderAvatar.js +16 -0
  19. package/lib-amd/components/Avatar/renderAvatar.js.map +1 -0
  20. package/lib-amd/components/Avatar/useAvatar.js +175 -0
  21. package/lib-amd/components/Avatar/useAvatar.js.map +1 -0
  22. package/lib-amd/components/Avatar/useAvatarStyles.js +390 -0
  23. package/lib-amd/components/Avatar/useAvatarStyles.js.map +1 -0
  24. package/lib-amd/components/AvatarGroup/AvatarGroup.js +17 -0
  25. package/lib-amd/components/AvatarGroup/AvatarGroup.js.map +1 -0
  26. package/lib-amd/components/AvatarGroup/AvatarGroup.types.js +5 -0
  27. package/lib-amd/components/AvatarGroup/AvatarGroup.types.js.map +1 -0
  28. package/lib-amd/components/AvatarGroup/index.js +11 -0
  29. package/lib-amd/components/AvatarGroup/index.js.map +1 -0
  30. package/lib-amd/components/AvatarGroup/renderAvatarGroup.js +15 -0
  31. package/lib-amd/components/AvatarGroup/renderAvatarGroup.js.map +1 -0
  32. package/lib-amd/components/AvatarGroup/useAvatarGroup.js +29 -0
  33. package/lib-amd/components/AvatarGroup/useAvatarGroup.js.map +1 -0
  34. package/lib-amd/components/AvatarGroup/useAvatarGroupContextValues.js +15 -0
  35. package/lib-amd/components/AvatarGroup/useAvatarGroupContextValues.js.map +1 -0
  36. package/lib-amd/components/AvatarGroup/useAvatarGroupStyles.js +36 -0
  37. package/lib-amd/components/AvatarGroup/useAvatarGroupStyles.js.map +1 -0
  38. package/lib-amd/components/AvatarGroupItem/AvatarGroupItem.js +16 -0
  39. package/lib-amd/components/AvatarGroupItem/AvatarGroupItem.js.map +1 -0
  40. package/lib-amd/components/AvatarGroupItem/AvatarGroupItem.types.js +5 -0
  41. package/lib-amd/components/AvatarGroupItem/AvatarGroupItem.types.js.map +1 -0
  42. package/lib-amd/components/AvatarGroupItem/index.js +10 -0
  43. package/lib-amd/components/AvatarGroupItem/index.js.map +1 -0
  44. package/lib-amd/components/AvatarGroupItem/renderAvatarGroupItem.js +16 -0
  45. package/lib-amd/components/AvatarGroupItem/renderAvatarGroupItem.js.map +1 -0
  46. package/lib-amd/components/AvatarGroupItem/useAvatarGroupItem.js +58 -0
  47. package/lib-amd/components/AvatarGroupItem/useAvatarGroupItem.js.map +1 -0
  48. package/lib-amd/components/AvatarGroupItem/useAvatarGroupItemStyles.js +206 -0
  49. package/lib-amd/components/AvatarGroupItem/useAvatarGroupItemStyles.js.map +1 -0
  50. package/lib-amd/components/AvatarGroupPopover/AvatarGroupPopover.js +17 -0
  51. package/lib-amd/components/AvatarGroupPopover/AvatarGroupPopover.js.map +1 -0
  52. package/lib-amd/components/AvatarGroupPopover/AvatarGroupPopover.types.js +5 -0
  53. package/lib-amd/components/AvatarGroupPopover/AvatarGroupPopover.types.js.map +1 -0
  54. package/lib-amd/components/AvatarGroupPopover/index.js +10 -0
  55. package/lib-amd/components/AvatarGroupPopover/index.js.map +1 -0
  56. package/lib-amd/components/AvatarGroupPopover/renderAvatarGroupPopover.js +20 -0
  57. package/lib-amd/components/AvatarGroupPopover/renderAvatarGroupPopover.js.map +1 -0
  58. package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopover.js +86 -0
  59. package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopover.js.map +1 -0
  60. package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopoverContextValues.js +14 -0
  61. package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopoverContextValues.js.map +1 -0
  62. package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopoverStyles.js +136 -0
  63. package/lib-amd/components/AvatarGroupPopover/useAvatarGroupPopoverStyles.js.map +1 -0
  64. package/lib-amd/contexts/AvatarContext.js +17 -0
  65. package/lib-amd/contexts/AvatarContext.js.map +1 -0
  66. package/lib-amd/contexts/AvatarGroupContext.js +20 -0
  67. package/lib-amd/contexts/AvatarGroupContext.js.map +1 -0
  68. package/lib-amd/contexts/index.js +7 -0
  69. package/lib-amd/contexts/index.js.map +1 -0
  70. package/lib-amd/index.js +33 -0
  71. package/lib-amd/index.js.map +1 -0
  72. package/lib-amd/utils/getInitials.js +87 -0
  73. package/lib-amd/utils/getInitials.js.map +1 -0
  74. package/lib-amd/utils/index.js +8 -0
  75. package/lib-amd/utils/index.js.map +1 -0
  76. package/lib-amd/utils/partitionAvatarGroupItems.js +32 -0
  77. package/lib-amd/utils/partitionAvatarGroupItems.js.map +1 -0
  78. package/package.json +7 -7
package/CHANGELOG.json CHANGED
@@ -2,7 +2,60 @@
2
2
  "name": "@fluentui/react-avatar",
3
3
  "entries": [
4
4
  {
5
- "date": "Fri, 11 Nov 2022 14:53:39 GMT",
5
+ "date": "Thu, 17 Nov 2022 23:02:31 GMT",
6
+ "tag": "@fluentui/react-avatar_v9.2.7",
7
+ "version": "9.2.7",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "author": "martinhochel@microsoft.com",
12
+ "package": "@fluentui/react-avatar",
13
+ "commit": "ea768501802d65d63ddc63fff3816fb6b5008ae4",
14
+ "comment": "chore: update package scaffold"
15
+ }
16
+ ],
17
+ "patch": [
18
+ {
19
+ "author": "beachball",
20
+ "package": "@fluentui/react-avatar",
21
+ "comment": "Bump @fluentui/react-badge to v9.0.13",
22
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
23
+ },
24
+ {
25
+ "author": "beachball",
26
+ "package": "@fluentui/react-avatar",
27
+ "comment": "Bump @fluentui/react-context-selector to v9.1.2",
28
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
29
+ },
30
+ {
31
+ "author": "beachball",
32
+ "package": "@fluentui/react-avatar",
33
+ "comment": "Bump @fluentui/react-popover to v9.3.2",
34
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
35
+ },
36
+ {
37
+ "author": "beachball",
38
+ "package": "@fluentui/react-avatar",
39
+ "comment": "Bump @fluentui/react-tabster to v9.3.1",
40
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
41
+ },
42
+ {
43
+ "author": "beachball",
44
+ "package": "@fluentui/react-avatar",
45
+ "comment": "Bump @fluentui/react-tooltip to v9.1.2",
46
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
47
+ },
48
+ {
49
+ "author": "beachball",
50
+ "package": "@fluentui/react-avatar",
51
+ "comment": "Bump @fluentui/react-utilities to v9.2.2",
52
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
53
+ }
54
+ ]
55
+ }
56
+ },
57
+ {
58
+ "date": "Fri, 11 Nov 2022 14:57:52 GMT",
6
59
  "tag": "@fluentui/react-avatar_v9.2.6",
7
60
  "version": "9.2.6",
8
61
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,26 @@
1
1
  # Change Log - @fluentui/react-avatar
2
2
 
3
- This log was last generated on Fri, 11 Nov 2022 14:53:39 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 17 Nov 2022 23:02:31 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.2.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-avatar_v9.2.7)
8
+
9
+ Thu, 17 Nov 2022 23:02:31 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-avatar_v9.2.6..@fluentui/react-avatar_v9.2.7)
11
+
12
+ ### Patches
13
+
14
+ - Bump @fluentui/react-badge to v9.0.13 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
15
+ - Bump @fluentui/react-context-selector to v9.1.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
16
+ - Bump @fluentui/react-popover to v9.3.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
17
+ - Bump @fluentui/react-tabster to v9.3.1 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
18
+ - Bump @fluentui/react-tooltip to v9.1.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
19
+ - Bump @fluentui/react-utilities to v9.2.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
20
+
7
21
  ## [9.2.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-avatar_v9.2.6)
8
22
 
9
- Fri, 11 Nov 2022 14:53:39 GMT
23
+ Fri, 11 Nov 2022 14:57:52 GMT
10
24
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-avatar_v9.2.5..@fluentui/react-avatar_v9.2.6)
11
25
 
12
26
  ### Patches
package/dist/index.d.ts CHANGED
@@ -19,9 +19,17 @@ export declare const Avatar: ForwardRefComponent<AvatarProps>;
19
19
 
20
20
  export declare const avatarClassNames: SlotClassNames<AvatarSlots>;
21
21
 
22
- /* Excluded from this release type: AvatarContextProvider */
22
+ /**
23
+ * @internal
24
+ */
25
+ export declare const AvatarContextProvider: React_2.Provider<AvatarContextValue | undefined>;
23
26
 
24
- /* Excluded from this release type: AvatarContextValue */
27
+ /**
28
+ * @internal
29
+ */
30
+ export declare interface AvatarContextValue {
31
+ size?: AvatarSizes;
32
+ }
25
33
 
26
34
  /**
27
35
  * The AvatarGroup component represents a group of multiple people or entities by taking care of the arrangement
@@ -280,7 +288,27 @@ export declare type AvatarState = ComponentState<AvatarSlots> & Required<Pick<Av
280
288
  activeAriaLabelElement?: JSX.Element;
281
289
  };
282
290
 
283
- /* Excluded from this release type: getInitials */
291
+ /**
292
+ * Regular expressions matching characters to ignore when calculating the initials.
293
+ */
294
+ /**
295
+ * Get (up to 2 characters) initials based on display name of the persona.
296
+ *
297
+ * @param displayName - The full name of the person or entity
298
+ * @param isRtl - Whether the display is in RTL
299
+ * @param options - Extra options to control the behavior of getInitials
300
+ *
301
+ * @returns The 1 or 2 character initials based on the name. Or an empty string if no initials
302
+ * could be derived from the name.
303
+ *
304
+ * @internal
305
+ */
306
+ export declare function getInitials(displayName: string | undefined | null, isRtl: boolean, options?: {
307
+ /** Should initials be generated from phone numbers (default false) */
308
+ allowPhoneInitials?: boolean;
309
+ /** Returns only the first initial */
310
+ firstInitialOnly?: boolean;
311
+ }): string;
284
312
 
285
313
  export declare type PartitionAvatarGroupItems<T> = {
286
314
  inlineItems: readonly T[];
@@ -321,7 +349,10 @@ export declare const renderAvatarGroupPopover_unstable: (state: AvatarGroupPopov
321
349
 
322
350
  export declare const useAvatar_unstable: (props: AvatarProps, ref: React_2.Ref<HTMLElement>) => AvatarState;
323
351
 
324
- /* Excluded from this release type: useAvatarContext */
352
+ /**
353
+ * @internal
354
+ */
355
+ export declare const useAvatarContext: () => AvatarContextValue;
325
356
 
326
357
  /**
327
358
  * Create the state required to render AvatarGroup.
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/Avatar/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=Avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-avatar/src/Avatar.ts"],"names":[],"mappings":";;;IAAA,uCAA0C","sourcesContent":["export * from './components/Avatar/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/AvatarGroup/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=AvatarGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvatarGroup.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-avatar/src/AvatarGroup.ts"],"names":[],"mappings":";;;IAAA,uCAA+C","sourcesContent":["export * from './components/AvatarGroup/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/AvatarGroupItem/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=AvatarGroupItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvatarGroupItem.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-avatar/src/AvatarGroupItem.ts"],"names":[],"mappings":";;;IAAA,uCAAmD","sourcesContent":["export * from './components/AvatarGroupItem/index';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/AvatarGroupPopover/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=AvatarGroupPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AvatarGroupPopover.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-avatar/src/AvatarGroupPopover.ts"],"names":[],"mappings":";;;IAAA,uCAAsD","sourcesContent":["export * from './components/AvatarGroupPopover/index';\n"]}
@@ -0,0 +1,12 @@
1
+ define(["require", "exports", "react", "./renderAvatar", "./useAvatar", "./useAvatarStyles"], function (require, exports, React, renderAvatar_1, useAvatar_1, useAvatarStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Avatar = void 0;
5
+ exports.Avatar = React.forwardRef(function (props, ref) {
6
+ var state = useAvatar_1.useAvatar_unstable(props, ref);
7
+ useAvatarStyles_1.useAvatarStyles_unstable(state);
8
+ return renderAvatar_1.renderAvatar_unstable(state);
9
+ });
10
+ exports.Avatar.displayName = 'Avatar';
11
+ });
12
+ //# sourceMappingURL=Avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-avatar/src/components/Avatar/Avatar.tsx"],"names":[],"mappings":";;;;IAOa,QAAA,MAAM,GAAqC,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;QAClF,IAAM,KAAK,GAAG,8BAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE7C,0CAAwB,CAAC,KAAK,CAAC,CAAC;QAEhC,OAAO,oCAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["import * as React from 'react';\nimport { renderAvatar_unstable } from './renderAvatar';\nimport { useAvatar_unstable } from './useAvatar';\nimport { useAvatarStyles_unstable } from './useAvatarStyles';\nimport type { AvatarProps } from './Avatar.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\nexport const Avatar: ForwardRefComponent<AvatarProps> = React.forwardRef((props, ref) => {\n const state = useAvatar_unstable(props, ref);\n\n useAvatarStyles_unstable(state);\n\n return renderAvatar_unstable(state);\n});\n\nAvatar.displayName = 'Avatar';\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=Avatar.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Avatar.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-avatar/src/components/Avatar/Avatar.types.ts"],"names":[],"mappings":"","sourcesContent":["import { PresenceBadge } from '@fluentui/react-badge';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Sizes for the avatar\n */\nexport type AvatarSizes = 16 | 20 | 24 | 28 | 32 | 36 | 40 | 48 | 56 | 64 | 72 | 96 | 120 | 128;\n\nexport type AvatarSlots = {\n root: Slot<'span'>;\n\n /**\n * The Avatar's image.\n *\n * Usage e.g.: `image={{ src: '...' }}`\n */\n image?: Slot<'img'>;\n\n /**\n * (optional) Custom initials.\n *\n * It is usually not necessary to specify custom initials; by default they will be derived from the `name` prop,\n * using the `getInitials` function.\n *\n * The initials are displayed when there is no image (including while the image is loading).\n */\n initials?: Slot<'span'>;\n\n /**\n * Icon to be displayed when the avatar doesn't have an image or initials.\n *\n * @default `PersonRegular` (the default icon's size depends on the Avatar's size)\n */\n icon?: Slot<'span'>;\n\n /**\n * Badge to show the avatar's presence status.\n */\n badge?: Slot<typeof PresenceBadge>;\n};\n\n/**\n * A specific named color for the Avatar\n */\nexport type AvatarNamedColor =\n | 'dark-red'\n | 'cranberry'\n | 'red'\n | 'pumpkin'\n | 'peach'\n | 'marigold'\n | 'gold'\n | 'brass'\n | 'brown'\n | 'forest'\n | 'seafoam'\n | 'dark-green'\n | 'light-teal'\n | 'teal'\n | 'steel'\n | 'blue'\n | 'royal-blue'\n | 'cornflower'\n | 'navy'\n | 'lavender'\n | 'purple'\n | 'grape'\n | 'lilac'\n | 'pink'\n | 'magenta'\n | 'plum'\n | 'beige'\n | 'mink'\n | 'platinum'\n | 'anchor';\n\n/**\n * Properties for Avatar\n */\nexport type AvatarProps = Omit<ComponentProps<AvatarSlots>, 'color'> & {\n /**\n * Optional activity indicator\n * * active: the avatar will be decorated according to activeAppearance\n * * inactive: the avatar will be reduced in size and partially transparent\n * * unset: normal display\n *\n * @default unset\n */\n active?: 'active' | 'inactive' | 'unset';\n\n /**\n * The appearance when `active=\"active\"`\n *\n * @default ring\n */\n activeAppearance?: 'ring' | 'shadow' | 'ring-shadow';\n\n /**\n * The color when displaying either an icon or initials.\n * * neutral (default): gray\n * * brand: color from the brand palette\n * * colorful: picks a color from a set of pre-defined colors, based on a hash of the name (or idForColor if provided)\n * * [AvatarNamedColor]: a specific color from the theme\n *\n * @default neutral\n */\n color?: 'neutral' | 'brand' | 'colorful' | AvatarNamedColor;\n\n /**\n * Specify a string to be used instead of the name, to determine which color to use when color=\"colorful\".\n * Use this when a name is not available, but there is another unique identifier that can be used instead.\n */\n idForColor?: string | undefined;\n\n /**\n * The name of the person or entity represented by this Avatar. This should always be provided if it is available.\n *\n * The name will be used to determine the initials displayed when there is no icon, as well as provided to\n * accessibility tools.\n */\n name?: string;\n\n /**\n * The avatar can have a circular or square shape.\n * @default circular\n */\n shape?: 'circular' | 'square';\n\n /**\n * Size of the avatar in pixels.\n *\n * Size is restricted to a limited set of supported values recommended for most uses (see `AvatarSizeValue`) and\n * based on design guidelines for the Avatar control.\n *\n * Note: At size 16, if initials are displayed, only the first initial will be rendered.\n *\n * If a non-supported size is neeeded, set `size` to the next-smaller supported size, and set `width` and `height`\n * to override the rendered size.\n *\n * For example, to set the avatar to 45px in size:\n * `<Avatar size={40} style={{ width: '45px', height: '45px' }} />`\n *\n * @default 32\n */\n size?: AvatarSizes;\n};\n\n/**\n * State used in rendering Avatar\n */\nexport type AvatarState = ComponentState<AvatarSlots> &\n Required<Pick<AvatarProps, 'active' | 'activeAppearance' | 'shape' | 'size'>> & {\n /**\n * The Avatar's color, it matches props.color but with `'colorful'` resolved to a named color\n */\n color: NonNullable<Exclude<AvatarProps['color'], 'colorful'>>;\n\n /**\n * Hidden span to render the active state label for the purposes of including in the aria-labelledby, if needed.\n */\n activeAriaLabelElement?: JSX.Element;\n };\n"]}
@@ -0,0 +1,10 @@
1
+ define(["require", "exports", "tslib", "./Avatar.types", "./Avatar", "./renderAvatar", "./useAvatar", "./useAvatarStyles"], function (require, exports, tslib_1, Avatar_types_1, Avatar_1, renderAvatar_1, useAvatar_1, useAvatarStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(Avatar_types_1, exports);
5
+ tslib_1.__exportStar(Avatar_1, exports);
6
+ tslib_1.__exportStar(renderAvatar_1, exports);
7
+ tslib_1.__exportStar(useAvatar_1, exports);
8
+ tslib_1.__exportStar(useAvatarStyles_1, exports);
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-avatar/src/components/Avatar/index.ts"],"names":[],"mappings":";;;IAAA,8CAA+B;IAC/B,wCAAyB;IACzB,8CAA+B;IAC/B,2CAA4B;IAC5B,iDAAkC","sourcesContent":["export * from './Avatar.types';\nexport * from './Avatar';\nexport * from './renderAvatar';\nexport * from './useAvatar';\nexport * from './useAvatarStyles';\n"]}
@@ -0,0 +1,16 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_utilities_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderAvatar_unstable = void 0;
5
+ var renderAvatar_unstable = function (state) {
6
+ var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
7
+ return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
8
+ slots.initials && React.createElement(slots.initials, tslib_1.__assign({}, slotProps.initials)),
9
+ slots.icon && React.createElement(slots.icon, tslib_1.__assign({}, slotProps.icon)),
10
+ slots.image && React.createElement(slots.image, tslib_1.__assign({}, slotProps.image)),
11
+ slots.badge && React.createElement(slots.badge, tslib_1.__assign({}, slotProps.badge)),
12
+ state.activeAriaLabelElement));
13
+ };
14
+ exports.renderAvatar_unstable = renderAvatar_unstable;
15
+ });
16
+ //# sourceMappingURL=renderAvatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderAvatar.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-avatar/src/components/Avatar/renderAvatar.tsx"],"names":[],"mappings":";;;;IAIO,IAAM,qBAAqB,GAAG,UAAC,KAAkB;QAChD,IAAA,KAAuB,0BAAQ,CAAc,KAAK,CAAC,EAAjD,KAAK,WAAA,EAAE,SAAS,eAAiC,CAAC;QAE1D,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC3B,KAAK,CAAC,QAAQ,IAAI,oBAAC,KAAK,CAAC,QAAQ,uBAAK,SAAS,CAAC,QAAQ,EAAI;YAC5D,KAAK,CAAC,IAAI,IAAI,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI;YAChD,KAAK,CAAC,KAAK,IAAI,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI;YACnD,KAAK,CAAC,KAAK,IAAI,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI;YACnD,KAAK,CAAC,sBAAsB,CAClB,CACd,CAAC;IACJ,CAAC,CAAC;IAZW,QAAA,qBAAqB,yBAYhC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { AvatarSlots, AvatarState } from './Avatar.types';\n\nexport const renderAvatar_unstable = (state: AvatarState) => {\n const { slots, slotProps } = getSlots<AvatarSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n {slots.initials && <slots.initials {...slotProps.initials} />}\n {slots.icon && <slots.icon {...slotProps.icon} />}\n {slots.image && <slots.image {...slotProps.image} />}\n {slots.badge && <slots.badge {...slotProps.badge} />}\n {state.activeAriaLabelElement}\n </slots.root>\n );\n};\n"]}
@@ -0,0 +1,175 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "../../utils/index", "@fluentui/react-icons", "@fluentui/react-badge", "@fluentui/react-shared-contexts", "../../contexts/AvatarContext"], function (require, exports, tslib_1, React, react_utilities_1, index_1, react_icons_1, react_badge_1, react_shared_contexts_1, AvatarContext_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useAvatar_unstable = exports.DEFAULT_STRINGS = void 0;
5
+ exports.DEFAULT_STRINGS = {
6
+ active: 'active',
7
+ inactive: 'inactive',
8
+ };
9
+ var useAvatar_unstable = function (props, ref) {
10
+ var _a;
11
+ var dir = react_shared_contexts_1.useFluent_unstable().dir;
12
+ var contextSize = AvatarContext_1.useAvatarContext().size;
13
+ var name = props.name, _b = props.size, size = _b === void 0 ? contextSize !== null && contextSize !== void 0 ? contextSize : 32 : _b, _c = props.shape, shape = _c === void 0 ? 'circular' : _c, _d = props.active, active = _d === void 0 ? 'unset' : _d, _e = props.activeAppearance, activeAppearance = _e === void 0 ? 'ring' : _e, idForColor = props.idForColor;
14
+ var _f = props.color, color = _f === void 0 ? 'neutral' : _f;
15
+ // Resolve 'colorful' to a specific color name
16
+ if (color === 'colorful') {
17
+ color = avatarColors[getHashCode((_a = idForColor !== null && idForColor !== void 0 ? idForColor : name) !== null && _a !== void 0 ? _a : '') % avatarColors.length];
18
+ }
19
+ var baseId = react_utilities_1.useId('avatar-');
20
+ var root = react_utilities_1.getNativeElementProps('span', tslib_1.__assign(tslib_1.__assign({ role: 'img', id: baseId }, props), { ref: ref }),
21
+ /* excludedPropNames: */ ['name']);
22
+ // Resolve the initials slot, defaulted to getInitials.
23
+ var initials = react_utilities_1.resolveShorthand(props.initials, {
24
+ required: true,
25
+ defaultProps: {
26
+ children: index_1.getInitials(name, dir === 'rtl', { firstInitialOnly: size <= 16 }),
27
+ id: baseId + '__initials',
28
+ },
29
+ });
30
+ // Render the icon slot *only if* there aren't any initials to display.
31
+ var icon = undefined;
32
+ if (!(initials === null || initials === void 0 ? void 0 : initials.children)) {
33
+ initials = undefined;
34
+ icon = react_utilities_1.resolveShorthand(props.icon, {
35
+ required: true,
36
+ defaultProps: {
37
+ children: React.createElement(react_icons_1.PersonRegular, null),
38
+ 'aria-hidden': true,
39
+ },
40
+ });
41
+ }
42
+ var _g = React.useState(undefined), imageHidden = _g[0], setImageHidden = _g[1];
43
+ var image = react_utilities_1.resolveShorthand(props.image, {
44
+ defaultProps: {
45
+ alt: '',
46
+ role: 'presentation',
47
+ 'aria-hidden': true,
48
+ hidden: imageHidden,
49
+ },
50
+ });
51
+ // Hide the image if it fails to load and restore it on a successful load
52
+ if (image) {
53
+ image.onError = react_utilities_1.mergeCallbacks(image.onError, function () { return setImageHidden(true); });
54
+ image.onLoad = react_utilities_1.mergeCallbacks(image.onLoad, function () { return setImageHidden(undefined); });
55
+ }
56
+ var badge = react_utilities_1.resolveShorthand(props.badge, {
57
+ defaultProps: {
58
+ size: getBadgeSize(size),
59
+ id: baseId + '__badge',
60
+ },
61
+ });
62
+ var activeAriaLabelElement;
63
+ // Resolve aria-label and/or aria-labelledby if not provided by the user
64
+ if (!root['aria-label'] && !root['aria-labelledby']) {
65
+ if (name) {
66
+ root['aria-label'] = name;
67
+ // Include the badge in labelledby if it exists
68
+ if (badge) {
69
+ root['aria-labelledby'] = root.id + ' ' + badge.id;
70
+ }
71
+ }
72
+ else if (initials) {
73
+ // root's aria-label should be the name, but fall back to being labelledby the initials if name is missing
74
+ root['aria-labelledby'] = initials.id + (badge ? ' ' + badge.id : '');
75
+ }
76
+ // Add the active state to the aria label
77
+ if (active === 'active' || active === 'inactive') {
78
+ var activeText = exports.DEFAULT_STRINGS[active];
79
+ if (root['aria-labelledby']) {
80
+ // If using aria-labelledby, render a hidden span and append it to the labelledby
81
+ var activeId = baseId + '__active';
82
+ root['aria-labelledby'] += ' ' + activeId;
83
+ activeAriaLabelElement = (React.createElement("span", { hidden: true, id: activeId }, activeText));
84
+ }
85
+ else if (root['aria-label']) {
86
+ // Otherwise, just append it to the aria-label
87
+ root['aria-label'] += ' ' + activeText;
88
+ }
89
+ }
90
+ }
91
+ return {
92
+ size: size,
93
+ shape: shape,
94
+ active: active,
95
+ activeAppearance: activeAppearance,
96
+ activeAriaLabelElement: activeAriaLabelElement,
97
+ color: color,
98
+ components: {
99
+ root: 'span',
100
+ initials: 'span',
101
+ icon: 'span',
102
+ image: 'img',
103
+ badge: react_badge_1.PresenceBadge,
104
+ },
105
+ root: root,
106
+ initials: initials,
107
+ icon: icon,
108
+ image: image,
109
+ badge: badge,
110
+ };
111
+ };
112
+ exports.useAvatar_unstable = useAvatar_unstable;
113
+ var getBadgeSize = function (size) {
114
+ if (size >= 96) {
115
+ return 'extra-large';
116
+ }
117
+ else if (size >= 64) {
118
+ return 'large';
119
+ }
120
+ else if (size >= 56) {
121
+ return 'medium';
122
+ }
123
+ else if (size >= 40) {
124
+ return 'small';
125
+ }
126
+ else if (size >= 28) {
127
+ return 'extra-small';
128
+ }
129
+ else {
130
+ return 'tiny';
131
+ }
132
+ };
133
+ var avatarColors = [
134
+ 'dark-red',
135
+ 'cranberry',
136
+ 'red',
137
+ 'pumpkin',
138
+ 'peach',
139
+ 'marigold',
140
+ 'gold',
141
+ 'brass',
142
+ 'brown',
143
+ 'forest',
144
+ 'seafoam',
145
+ 'dark-green',
146
+ 'light-teal',
147
+ 'teal',
148
+ 'steel',
149
+ 'blue',
150
+ 'royal-blue',
151
+ 'cornflower',
152
+ 'navy',
153
+ 'lavender',
154
+ 'purple',
155
+ 'grape',
156
+ 'lilac',
157
+ 'pink',
158
+ 'magenta',
159
+ 'plum',
160
+ 'beige',
161
+ 'mink',
162
+ 'platinum',
163
+ 'anchor',
164
+ ];
165
+ var getHashCode = function (str) {
166
+ var hashCode = 0;
167
+ for (var len = str.length - 1; len >= 0; len--) {
168
+ var ch = str.charCodeAt(len);
169
+ var shift = len % 8;
170
+ hashCode ^= (ch << shift) + (ch >> (8 - shift)); // eslint-disable-line no-bitwise
171
+ }
172
+ return hashCode;
173
+ };
174
+ });
175
+ //# sourceMappingURL=useAvatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAvatar.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-avatar/src/components/Avatar/useAvatar.tsx"],"names":[],"mappings":";;;;IASa,QAAA,eAAe,GAAG;QAC7B,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,UAAU;KACrB,CAAC;IAEK,IAAM,kBAAkB,GAAG,UAAC,KAAkB,EAAE,GAA2B;;QACxE,IAAA,GAAG,GAAK,0CAAS,EAAE,IAAhB,CAAiB;QACpB,IAAM,WAAW,GAAK,gCAAgB,EAAE,KAAvB,CAAwB;QAE/C,IAAA,IAAI,GAMF,KAAK,KANH,EACJ,KAKE,KAAK,KAL4B,EAAnC,IAAI,mBAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAK,EAAY,KAAA,EACnC,KAIE,KAAK,MAJW,EAAlB,KAAK,mBAAG,UAAU,KAAA,EAClB,KAGE,KAAK,OAHS,EAAhB,MAAM,mBAAG,OAAO,KAAA,EAChB,KAEE,KAAK,iBAFkB,EAAzB,gBAAgB,mBAAG,MAAM,KAAA,EACzB,UAAU,GACR,KAAK,WADG,CACF;QACJ,IAAA,KAAsB,KAAK,MAAV,EAAjB,KAAK,mBAAG,SAAS,KAAA,CAAW;QAElC,8CAA8C;QAC9C,IAAI,KAAK,KAAK,UAAU,EAAE;YACxB,KAAK,GAAG,YAAY,CAAC,WAAW,CAAC,MAAA,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,IAAI,mCAAI,EAAE,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;SACnF;QAED,IAAM,MAAM,GAAG,uBAAK,CAAC,SAAS,CAAC,CAAC;QAEhC,IAAM,IAAI,GAAwB,uCAAqB,CACrD,MAAM,sCAEJ,IAAI,EAAE,KAAK,EACX,EAAE,EAAE,MAAM,IAEP,KAAK,KACR,GAA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Y;QACZ,YAAY;QACZ,MAAM;QACN,UAAU;QACV,QAAQ;QACR,OAAO;QACP,OAAO;QACP,MAAM;QACN,SAAS;QACT,MAAM;QACN,OAAO;QACP,MAAM;QACN,UAAU;QACV,QAAQ;KACT,CAAC;IAEF,IAAM,WAAW,GAAG,UAAC,GAAW;QAC9B,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,KAAK,IAAI,GAAG,GAAW,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE;YACtD,IAAM,EAAE,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAM,KAAK,GAAG,GAAG,GAAG,CAAC,CAAC;YACtB,QAAQ,IAAI,CAAC,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,iCAAiC;SACnF;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, mergeCallbacks, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { getInitials } from '../../utils/index';\nimport type { AvatarNamedColor, AvatarProps, AvatarState } from './Avatar.types';\nimport { PersonRegular } from '@fluentui/react-icons';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useAvatarContext } from '../../contexts/AvatarContext';\n\nexport const DEFAULT_STRINGS = {\n active: 'active',\n inactive: 'inactive',\n};\n\nexport const useAvatar_unstable = (props: AvatarProps, ref: React.Ref<HTMLElement>): AvatarState => {\n const { dir } = useFluent();\n const { size: contextSize } = useAvatarContext();\n const {\n name,\n size = contextSize ?? (32 as const),\n shape = 'circular',\n active = 'unset',\n activeAppearance = 'ring',\n idForColor,\n } = props;\n let { color = 'neutral' } = props;\n\n // Resolve 'colorful' to a specific color name\n if (color === 'colorful') {\n color = avatarColors[getHashCode(idForColor ?? name ?? '') % avatarColors.length];\n }\n\n const baseId = useId('avatar-');\n\n const root: AvatarState['root'] = getNativeElementProps(\n 'span',\n {\n role: 'img',\n id: baseId,\n // aria-label and/or aria-labelledby are resolved below\n ...props,\n ref,\n },\n /* excludedPropNames: */ ['name'],\n );\n\n // Resolve the initials slot, defaulted to getInitials.\n let initials: AvatarState['initials'] = resolveShorthand(props.initials, {\n required: true,\n defaultProps: {\n children: getInitials(name, dir === 'rtl', { firstInitialOnly: size <= 16 }),\n id: baseId + '__initials',\n },\n });\n\n // Render the icon slot *only if* there aren't any initials to display.\n let icon: AvatarState['icon'] = undefined;\n if (!initials?.children) {\n initials = undefined;\n icon = resolveShorthand(props.icon, {\n required: true,\n defaultProps: {\n children: <PersonRegular />,\n 'aria-hidden': true,\n },\n });\n }\n\n const [imageHidden, setImageHidden] = React.useState<true | undefined>(undefined);\n const image: AvatarState['image'] = resolveShorthand(props.image, {\n defaultProps: {\n alt: '',\n role: 'presentation',\n 'aria-hidden': true,\n hidden: imageHidden,\n },\n });\n\n // Hide the image if it fails to load and restore it on a successful load\n if (image) {\n image.onError = mergeCallbacks(image.onError, () => setImageHidden(true));\n image.onLoad = mergeCallbacks(image.onLoad, () => setImageHidden(undefined));\n }\n\n const badge: AvatarState['badge'] = resolveShorthand(props.badge, {\n defaultProps: {\n size: getBadgeSize(size),\n id: baseId + '__badge',\n },\n });\n\n let activeAriaLabelElement: AvatarState['activeAriaLabelElement'];\n\n // Resolve aria-label and/or aria-labelledby if not provided by the user\n if (!root['aria-label'] && !root['aria-labelledby']) {\n if (name) {\n root['aria-label'] = name;\n\n // Include the badge in labelledby if it exists\n if (badge) {\n root['aria-labelledby'] = root.id + ' ' + badge.id;\n }\n } else if (initials) {\n // root's aria-label should be the name, but fall back to being labelledby the initials if name is missing\n root['aria-labelledby'] = initials.id + (badge ? ' ' + badge.id : '');\n }\n\n // Add the active state to the aria label\n if (active === 'active' || active === 'inactive') {\n const activeText = DEFAULT_STRINGS[active];\n if (root['aria-labelledby']) {\n // If using aria-labelledby, render a hidden span and append it to the labelledby\n const activeId = baseId + '__active';\n root['aria-labelledby'] += ' ' + activeId;\n activeAriaLabelElement = (\n <span hidden id={activeId}>\n {activeText}\n </span>\n );\n } else if (root['aria-label']) {\n // Otherwise, just append it to the aria-label\n root['aria-label'] += ' ' + activeText;\n }\n }\n }\n\n return {\n size,\n shape,\n active,\n activeAppearance,\n activeAriaLabelElement,\n color,\n\n components: {\n root: 'span',\n initials: 'span',\n icon: 'span',\n image: 'img',\n badge: PresenceBadge,\n },\n\n root,\n initials,\n icon,\n image,\n badge,\n };\n};\n\nconst getBadgeSize = (size: AvatarState['size']) => {\n if (size >= 96) {\n return 'extra-large';\n } else if (size >= 64) {\n return 'large';\n } else if (size >= 56) {\n return 'medium';\n } else if (size >= 40) {\n return 'small';\n } else if (size >= 28) {\n return 'extra-small';\n } else {\n return 'tiny';\n }\n};\n\nconst avatarColors: AvatarNamedColor[] = [\n 'dark-red',\n 'cranberry',\n 'red',\n 'pumpkin',\n 'peach',\n 'marigold',\n 'gold',\n 'brass',\n 'brown',\n 'forest',\n 'seafoam',\n 'dark-green',\n 'light-teal',\n 'teal',\n 'steel',\n 'blue',\n 'royal-blue',\n 'cornflower',\n 'navy',\n 'lavender',\n 'purple',\n 'grape',\n 'lilac',\n 'pink',\n 'magenta',\n 'plum',\n 'beige',\n 'mink',\n 'platinum',\n 'anchor',\n];\n\nconst getHashCode = (str: string): number => {\n let hashCode = 0;\n for (let len: number = str.length - 1; len >= 0; len--) {\n const ch = str.charCodeAt(len);\n const shift = len % 8;\n hashCode ^= (ch << shift) + (ch >> (8 - shift)); // eslint-disable-line no-bitwise\n }\n\n return hashCode;\n};\n"]}