@fluentui/react-avatar 9.0.0-alpha.83 → 9.0.0-alpha.84

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 (60) hide show
  1. package/CHANGELOG.json +67 -8
  2. package/CHANGELOG.md +24 -9
  3. package/lib/Avatar.js.map +1 -1
  4. package/lib/common/isConformant.js.map +1 -1
  5. package/lib/components/Avatar/Avatar.js.map +1 -1
  6. package/lib/components/Avatar/Avatar.types.js.map +1 -1
  7. package/lib/components/Avatar/index.js.map +1 -1
  8. package/lib/components/Avatar/renderAvatar.js.map +1 -1
  9. package/lib/components/Avatar/useAvatar.js +1 -0
  10. package/lib/components/Avatar/useAvatar.js.map +1 -1
  11. package/lib/components/Avatar/useAvatarStyles.js.map +1 -1
  12. package/lib/index.js.map +1 -1
  13. package/lib/utils/getInitials.js.map +1 -1
  14. package/lib/utils/index.js.map +1 -1
  15. package/lib-commonjs/Avatar.js.map +1 -1
  16. package/lib-commonjs/common/isConformant.js.map +1 -1
  17. package/lib-commonjs/components/Avatar/Avatar.js.map +1 -1
  18. package/lib-commonjs/components/Avatar/Avatar.types.js.map +1 -1
  19. package/lib-commonjs/components/Avatar/index.js.map +1 -1
  20. package/lib-commonjs/components/Avatar/renderAvatar.js.map +1 -1
  21. package/lib-commonjs/components/Avatar/useAvatar.js +1 -0
  22. package/lib-commonjs/components/Avatar/useAvatar.js.map +1 -1
  23. package/lib-commonjs/components/Avatar/useAvatarStyles.js.map +1 -1
  24. package/lib-commonjs/index.js.map +1 -1
  25. package/lib-commonjs/utils/getInitials.js.map +1 -1
  26. package/lib-commonjs/utils/index.js.map +1 -1
  27. package/package.json +8 -8
  28. package/lib-amd/Avatar.d.ts +0 -1
  29. package/lib-amd/Avatar.js +0 -6
  30. package/lib-amd/Avatar.js.map +0 -1
  31. package/lib-amd/common/isConformant.d.ts +0 -4
  32. package/lib-amd/common/isConformant.js +0 -16
  33. package/lib-amd/common/isConformant.js.map +0 -1
  34. package/lib-amd/components/Avatar/Avatar.d.ts +0 -15
  35. package/lib-amd/components/Avatar/Avatar.js +0 -12
  36. package/lib-amd/components/Avatar/Avatar.js.map +0 -1
  37. package/lib-amd/components/Avatar/Avatar.types.d.ts +0 -109
  38. package/lib-amd/components/Avatar/Avatar.types.js +0 -5
  39. package/lib-amd/components/Avatar/Avatar.types.js.map +0 -1
  40. package/lib-amd/components/Avatar/index.d.ts +0 -5
  41. package/lib-amd/components/Avatar/index.js +0 -10
  42. package/lib-amd/components/Avatar/index.js.map +0 -1
  43. package/lib-amd/components/Avatar/renderAvatar.d.ts +0 -2
  44. package/lib-amd/components/Avatar/renderAvatar.js +0 -15
  45. package/lib-amd/components/Avatar/renderAvatar.js.map +0 -1
  46. package/lib-amd/components/Avatar/useAvatar.d.ts +0 -7
  47. package/lib-amd/components/Avatar/useAvatar.js +0 -141
  48. package/lib-amd/components/Avatar/useAvatar.js.map +0 -1
  49. package/lib-amd/components/Avatar/useAvatarStyles.d.ts +0 -2
  50. package/lib-amd/components/Avatar/useAvatarStyles.js +0 -416
  51. package/lib-amd/components/Avatar/useAvatarStyles.js.map +0 -1
  52. package/lib-amd/index.d.ts +0 -1
  53. package/lib-amd/index.js +0 -6
  54. package/lib-amd/index.js.map +0 -1
  55. package/lib-amd/utils/getInitials.d.ts +0 -9
  56. package/lib-amd/utils/getInitials.js +0 -79
  57. package/lib-amd/utils/getInitials.js.map +0 -1
  58. package/lib-amd/utils/index.d.ts +0 -1
  59. package/lib-amd/utils/index.js +0 -7
  60. package/lib-amd/utils/index.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-avatar",
3
- "version": "9.0.0-alpha.83",
3
+ "version": "9.0.0-alpha.84",
4
4
  "description": "React components for building Microsoft web experiences.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -25,11 +25,11 @@
25
25
  "storybook": "start-storybook"
26
26
  },
27
27
  "devDependencies": {
28
- "@fluentui/babel-make-styles": "9.0.0-alpha.51",
28
+ "@fluentui/babel-make-styles": "9.0.0-alpha.52",
29
29
  "@fluentui/eslint-plugin": "*",
30
- "@fluentui/jest-serializer-make-styles": "9.0.0-alpha.44",
30
+ "@fluentui/jest-serializer-make-styles": "9.0.0-alpha.45",
31
31
  "@fluentui/react-conformance": "*",
32
- "@fluentui/react-conformance-make-styles": "9.0.0-alpha.13",
32
+ "@fluentui/react-conformance-make-styles": "9.0.0-alpha.14",
33
33
  "@fluentui/scripts": "^1.0.0",
34
34
  "@types/enzyme": "3.10.3",
35
35
  "@types/enzyme-adapter-react-16": "1.0.3",
@@ -44,11 +44,11 @@
44
44
  "react-test-renderer": "^16.3.0"
45
45
  },
46
46
  "dependencies": {
47
- "@fluentui/react-badge": "9.0.0-alpha.83",
48
- "@fluentui/react-icons": "^1.1.136",
49
- "@fluentui/react-make-styles": "9.0.0-alpha.69",
47
+ "@fluentui/react-badge": "9.0.0-alpha.84",
48
+ "@fluentui/react-icons": "^1.1.140",
49
+ "@fluentui/react-make-styles": "9.0.0-alpha.70",
50
50
  "@fluentui/react-theme": "9.0.0-alpha.23",
51
- "@fluentui/react-utilities": "9.0.0-alpha.49",
51
+ "@fluentui/react-utilities": "9.0.0-alpha.50",
52
52
  "tslib": "^2.1.0"
53
53
  },
54
54
  "peerDependencies": {
@@ -1 +0,0 @@
1
- export * from './components/Avatar/index';
package/lib-amd/Avatar.js DELETED
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"Avatar.js","sourceRoot":"../src/","sources":["Avatar.ts"],"names":[],"mappings":";;;IAAA,uCAA0C","sourcesContent":["export * from './components/Avatar/index';\n"]}
@@ -1,4 +0,0 @@
1
- import type { IsConformantOptions } from '@fluentui/react-conformance';
2
- export declare function isConformant<TProps = {}>(testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & {
3
- componentPath?: string;
4
- }): void;
@@ -1,16 +0,0 @@
1
- define(["require", "exports", "@fluentui/react-conformance", "@fluentui/react-conformance-make-styles"], function (require, exports, react_conformance_1, react_conformance_make_styles_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.isConformant = void 0;
5
- function isConformant(testInfo) {
6
- var defaultOptions = {
7
- asPropHandlesRef: true,
8
- componentPath: module.parent.filename.replace('.test', ''),
9
- disabledTests: ['has-docblock'],
10
- extraTests: react_conformance_make_styles_1.default,
11
- };
12
- react_conformance_1.isConformant(defaultOptions, testInfo);
13
- }
14
- exports.isConformant = isConformant;
15
- });
16
- //# sourceMappingURL=isConformant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isConformant.js","sourceRoot":"../src/","sources":["common/isConformant.ts"],"names":[],"mappings":";;;;IAIA,SAAgB,YAAY,CAC1B,QAAyF;QAEzF,IAAM,cAAc,GAAyC;YAC3D,gBAAgB,EAAE,IAAI;YACtB,aAAa,EAAE,MAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5D,aAAa,EAAE,CAAC,cAAc,CAAC;YAC/B,UAAU,EAAE,uCAAqC;SAClD,CAAC;QAEF,gCAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAXD,oCAWC","sourcesContent":["import { isConformant as baseIsConformant } from '@fluentui/react-conformance';\nimport makeStylesTests from '@fluentui/react-conformance-make-styles';\nimport type { IsConformantOptions, TestObject } from '@fluentui/react-conformance';\n\nexport function isConformant<TProps = {}>(\n testInfo: Omit<IsConformantOptions<TProps>, 'componentPath'> & { componentPath?: string },\n) {\n const defaultOptions: Partial<IsConformantOptions<TProps>> = {\n asPropHandlesRef: true,\n componentPath: module!.parent!.filename.replace('.test', ''),\n disabledTests: ['has-docblock'],\n extraTests: makeStylesTests as TestObject<TProps>,\n };\n\n baseIsConformant(defaultOptions, testInfo);\n}\n"]}
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- export declare const Avatar: React.ForwardRefExoticComponent<import("@fluentui/react-utilities").ComponentPropsCompat & React.HTMLAttributes<HTMLElement> & {
3
- image?: import("@fluentui/react-utilities").ShorthandPropsCompat<React.ImgHTMLAttributes<HTMLImageElement>>;
4
- label?: import("@fluentui/react-utilities").ShorthandPropsCompat<React.HTMLAttributes<HTMLElement>>;
5
- icon?: import("@fluentui/react-utilities").ShorthandPropsCompat<React.HTMLAttributes<HTMLElement>>;
6
- badge?: number | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | React.ReactPortal | "available" | "away" | "busy" | "doNotDisturb" | "offline" | "outOfOffice" | import("@fluentui/react-utilities").ObjectShorthandPropsCompat<import("@fluentui/react-badge").PresenceBadgeProps> | null | undefined;
7
- name?: string | undefined;
8
- getInitials?: ((name: string, isRtl: boolean) => string) | undefined;
9
- size?: 20 | 24 | 28 | 32 | 36 | 40 | 48 | 56 | 64 | 72 | 96 | 120 | 128 | undefined;
10
- square?: boolean | undefined;
11
- active?: "unset" | "active" | "inactive" | undefined;
12
- activeDisplay?: "ring" | "ring-shadow" | "ring-glow" | "shadow" | "glow" | undefined;
13
- color?: "darkRed" | "cranberry" | "red" | "pumpkin" | "peach" | "marigold" | "gold" | "brass" | "brown" | "forest" | "seafoam" | "darkGreen" | "lightTeal" | "teal" | "steel" | "blue" | "royalBlue" | "cornflower" | "navy" | "lavender" | "purple" | "grape" | "lilac" | "pink" | "magenta" | "plum" | "beige" | "mink" | "platinum" | "anchor" | "neutral" | "brand" | "colorful" | undefined;
14
- idForColor?: string | undefined;
15
- } & React.RefAttributes<HTMLElement>>;
@@ -1,12 +0,0 @@
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(props, ref);
7
- useAvatarStyles_1.useAvatarStyles(state);
8
- return renderAvatar_1.renderAvatar(state);
9
- });
10
- exports.Avatar.displayName = 'Avatar';
11
- });
12
- //# sourceMappingURL=Avatar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Avatar.js","sourceRoot":"../src/","sources":["components/Avatar/Avatar.tsx"],"names":[],"mappings":";;;;IAMa,QAAA,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,UAAC,KAAkB,EAAE,GAA2B;QACrF,IAAM,KAAK,GAAG,qBAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAEpC,iCAAe,CAAC,KAAK,CAAC,CAAC;QAEvB,OAAO,2BAAY,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["import * as React from 'react';\nimport { renderAvatar } from './renderAvatar';\nimport { useAvatar } from './useAvatar';\nimport { useAvatarStyles } from './useAvatarStyles';\nimport type { AvatarProps } from './Avatar.types';\n\nexport const Avatar = React.forwardRef((props: AvatarProps, ref: React.Ref<HTMLElement>) => {\n const state = useAvatar(props, ref);\n\n useAvatarStyles(state);\n\n return renderAvatar(state);\n});\n\nAvatar.displayName = 'Avatar';\n"]}
@@ -1,109 +0,0 @@
1
- import * as React from 'react';
2
- import type { ComponentPropsCompat, ComponentStateCompat, ShorthandPropsCompat } from '@fluentui/react-utilities';
3
- import type { PresenceBadgeProps, PresenceBadgeStatus } from '@fluentui/react-badge';
4
- export declare type AvatarProps = ComponentPropsCompat & React.HTMLAttributes<HTMLElement> & {
5
- /**
6
- * The Avatar's image.
7
- */
8
- image?: ShorthandPropsCompat<React.ImgHTMLAttributes<HTMLImageElement>>;
9
- /**
10
- * The label shown when there's no image. Defaults to the initials derived from `name` using `getInitials`.
11
- */
12
- label?: ShorthandPropsCompat<React.HTMLAttributes<HTMLElement>>;
13
- /**
14
- * Icon to be displayed when the avatar doesn't have an image or name (or if getInitials returns an empty string).
15
- *
16
- * @defaultvalue `Person20Regular` (the default icon's size depends on the Avatar's size)
17
- */
18
- icon?: ShorthandPropsCompat<React.HTMLAttributes<HTMLElement>>;
19
- /**
20
- * Badge to show the avatar's presence status.
21
- * Can either be a string indicating the status ("busy", "away", etc.), or a PresenceBadgeProps object.
22
- */
23
- badge?: PresenceBadgeStatus | Exclude<ShorthandPropsCompat<PresenceBadgeProps>, string>;
24
- /**
25
- * The name used for displaying the initials of the avatar if the image is not provided
26
- */
27
- name?: string;
28
- /**
29
- * Custom method for generating the initials from the name property, which is shown if no image is provided.
30
- */
31
- getInitials?: (name: string, isRtl: boolean) => string;
32
- /**
33
- * Size of the avatar in pixels.
34
- *
35
- * Size is restricted to a limited set of supported values recommended for most uses (see `AvatarSizeValue`).
36
- *
37
- * If a non-supported size is neeeded, set `size` to the next-smaller supported size, and set `width` and `height`
38
- * to override the rendered size.
39
- *
40
- * For example, to set the avatar to 45px in size:
41
- * `<Avatar size={40} style={{ width: '45px', height: '45px' }} />`
42
- *
43
- * @defaultvalue 32
44
- */
45
- size?: AvatarSizeValue;
46
- /**
47
- * The avatar can have a square shape.
48
- */
49
- square?: boolean;
50
- /**
51
- * Optional activity indicator
52
- * * active: the avatar will be decorated according to activeDisplay
53
- * * inactive: the avatar will be reduced in size and partially transparent
54
- * * unset: normal display
55
- *
56
- * @defaultvalue unset
57
- */
58
- active?: 'active' | 'inactive' | 'unset';
59
- /**
60
- * The type of visual treatment to use when `active="active"`
61
- *
62
- * @defaultvalue ring
63
- */
64
- activeDisplay?: 'ring' | 'shadow' | 'glow' | 'ring-shadow' | 'ring-glow';
65
- /**
66
- * The color when displaying either an icon or initials.
67
- * * neutral (default): gray
68
- * * brand: color from the brand palette
69
- * * colorful: picks a color from a set of pre-defined colors, based on a hash of the name
70
- * (or idForColor if provided)
71
- * * [AvatarNamedColor]: a specific color from the theme
72
- *
73
- * @defaultvalue neutral
74
- */
75
- color?: 'neutral' | 'brand' | 'colorful' | AvatarNamedColor;
76
- /**
77
- * Specify a string to be used instead of the name, to determine which color to use when color="colorful".
78
- * Use this when a name is not available, but there is another unique identifier that can be used instead.
79
- */
80
- idForColor?: string;
81
- };
82
- /**
83
- * Sizes for the Avatar
84
- *
85
- * This is a restricted list based on design guidelines for the Avatar control.
86
- */
87
- export declare type AvatarSizeValue = 20 | 24 | 28 | 32 | 36 | 40 | 48 | 56 | 64 | 72 | 96 | 120 | 128;
88
- /**
89
- * A specific named color for the Avatar
90
- */
91
- export declare type AvatarNamedColor = 'darkRed' | 'cranberry' | 'red' | 'pumpkin' | 'peach' | 'marigold' | 'gold' | 'brass' | 'brown' | 'forest' | 'seafoam' | 'darkGreen' | 'lightTeal' | 'teal' | 'steel' | 'blue' | 'royalBlue' | 'cornflower' | 'navy' | 'lavender' | 'purple' | 'grape' | 'lilac' | 'pink' | 'magenta' | 'plum' | 'beige' | 'mink' | 'platinum' | 'anchor';
92
- /**
93
- * Names of the shorthand properties in AvatarProps
94
- */
95
- export declare type AvatarShorthandPropsCompat = 'label' | 'image' | 'badge' | 'icon';
96
- /**
97
- * Names of AvatarProps that have a default value in useAvatar
98
- */
99
- export declare type AvatarDefaultedProps = 'size' | 'color' | 'activeDisplay' | 'getInitials' | 'label' | 'icon';
100
- export declare type AvatarState = ComponentStateCompat<AvatarProps, AvatarShorthandPropsCompat, AvatarDefaultedProps> & {
101
- /**
102
- * Ref to the root element
103
- */
104
- ref: React.Ref<HTMLElement>;
105
- /**
106
- * True if the avatar has no label/initials and should render an icon
107
- */
108
- showIcon?: boolean;
109
- };
@@ -1,5 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- });
5
- //# sourceMappingURL=Avatar.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Avatar.types.js","sourceRoot":"../src/","sources":["components/Avatar/Avatar.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentPropsCompat, ComponentStateCompat, ShorthandPropsCompat } from '@fluentui/react-utilities';\nimport type { PresenceBadgeProps, PresenceBadgeStatus } from '@fluentui/react-badge';\n\nexport type AvatarProps = ComponentPropsCompat &\n React.HTMLAttributes<HTMLElement> & {\n /**\n * The Avatar's image.\n */\n image?: ShorthandPropsCompat<React.ImgHTMLAttributes<HTMLImageElement>>;\n\n /**\n * The label shown when there's no image. Defaults to the initials derived from `name` using `getInitials`.\n */\n label?: ShorthandPropsCompat<React.HTMLAttributes<HTMLElement>>;\n\n /**\n * Icon to be displayed when the avatar doesn't have an image or name (or if getInitials returns an empty string).\n *\n * @defaultvalue `Person20Regular` (the default icon's size depends on the Avatar's size)\n */\n icon?: ShorthandPropsCompat<React.HTMLAttributes<HTMLElement>>;\n\n /**\n * Badge to show the avatar's presence status.\n * Can either be a string indicating the status (\"busy\", \"away\", etc.), or a PresenceBadgeProps object.\n */\n badge?: PresenceBadgeStatus | Exclude<ShorthandPropsCompat<PresenceBadgeProps>, string>;\n\n /**\n * The name used for displaying the initials of the avatar if the image is not provided\n */\n name?: string;\n\n /**\n * Custom method for generating the initials from the name property, which is shown if no image is provided.\n */\n getInitials?: (name: string, isRtl: boolean) => string;\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`).\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 * @defaultvalue 32\n */\n size?: AvatarSizeValue;\n\n /**\n * The avatar can have a square shape.\n */\n square?: boolean;\n\n /**\n * Optional activity indicator\n * * active: the avatar will be decorated according to activeDisplay\n * * inactive: the avatar will be reduced in size and partially transparent\n * * unset: normal display\n *\n * @defaultvalue unset\n */\n active?: 'active' | 'inactive' | 'unset';\n\n /**\n * The type of visual treatment to use when `active=\"active\"`\n *\n * @defaultvalue ring\n */\n activeDisplay?: 'ring' | 'shadow' | 'glow' | 'ring-shadow' | 'ring-glow';\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\n * (or idForColor if provided)\n * * [AvatarNamedColor]: a specific color from the theme\n *\n * @defaultvalue 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;\n };\n\n/**\n * Sizes for the Avatar\n *\n * This is a restricted list based on design guidelines for the Avatar control.\n */\nexport type AvatarSizeValue = 20 | 24 | 28 | 32 | 36 | 40 | 48 | 56 | 64 | 72 | 96 | 120 | 128;\n\n/**\n * A specific named color for the Avatar\n */\nexport type AvatarNamedColor =\n | 'darkRed'\n | 'cranberry'\n | 'red'\n | 'pumpkin'\n | 'peach'\n | 'marigold'\n | 'gold'\n | 'brass'\n | 'brown'\n | 'forest'\n | 'seafoam'\n | 'darkGreen'\n | 'lightTeal'\n | 'teal'\n | 'steel'\n | 'blue'\n | 'royalBlue'\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 * Names of the shorthand properties in AvatarProps\n */\nexport type AvatarShorthandPropsCompat = 'label' | 'image' | 'badge' | 'icon';\n\n/**\n * Names of AvatarProps that have a default value in useAvatar\n */\nexport type AvatarDefaultedProps = 'size' | 'color' | 'activeDisplay' | 'getInitials' | 'label' | 'icon';\n\nexport type AvatarState = ComponentStateCompat<AvatarProps, AvatarShorthandPropsCompat, AvatarDefaultedProps> & {\n /**\n * Ref to the root element\n */\n ref: React.Ref<HTMLElement>;\n\n /**\n * True if the avatar has no label/initials and should render an icon\n */\n showIcon?: boolean;\n};\n"]}
@@ -1,5 +0,0 @@
1
- export * from './Avatar.types';
2
- export * from './Avatar';
3
- export * from './renderAvatar';
4
- export * from './useAvatar';
5
- export * from './useAvatarStyles';
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["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"]}
@@ -1,2 +0,0 @@
1
- import type { AvatarState } from './Avatar.types';
2
- export declare const renderAvatar: (state: AvatarState) => JSX.Element;
@@ -1,15 +0,0 @@
1
- define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "./useAvatar"], function (require, exports, tslib_1, React, react_utilities_1, useAvatar_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.renderAvatar = void 0;
5
- var renderAvatar = function (state) {
6
- var _a = react_utilities_1.getSlotsCompat(state, useAvatar_1.avatarShorthandPropsCompat), slots = _a.slots, slotProps = _a.slotProps;
7
- return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
8
- React.createElement(slots.label, tslib_1.__assign({}, slotProps.label)),
9
- state.showIcon && React.createElement(slots.icon, tslib_1.__assign({}, slotProps.icon)),
10
- React.createElement(slots.image, tslib_1.__assign({}, slotProps.image)),
11
- React.createElement(slots.badge, tslib_1.__assign({}, slotProps.badge))));
12
- };
13
- exports.renderAvatar = renderAvatar;
14
- });
15
- //# sourceMappingURL=renderAvatar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderAvatar.js","sourceRoot":"../src/","sources":["components/Avatar/renderAvatar.tsx"],"names":[],"mappings":";;;;IAKO,IAAM,YAAY,GAAG,UAAC,KAAkB;QACvC,IAAA,KAAuB,gCAAc,CAAC,KAAK,EAAE,sCAA0B,CAAC,EAAtE,KAAK,WAAA,EAAE,SAAS,eAAsD,CAAC;QAC/E,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC5B,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI;YACnC,KAAK,CAAC,QAAQ,IAAI,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI;YACrD,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI;YACpC,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI,CACzB,CACd,CAAC;IACJ,CAAC,CAAC;IAVW,QAAA,YAAY,gBAUvB","sourcesContent":["import * as React from 'react';\nimport { getSlotsCompat } from '@fluentui/react-utilities';\nimport { avatarShorthandPropsCompat } from './useAvatar';\nimport type { AvatarState } from './Avatar.types';\n\nexport const renderAvatar = (state: AvatarState) => {\n const { slots, slotProps } = getSlotsCompat(state, avatarShorthandPropsCompat);\n return (\n <slots.root {...slotProps.root}>\n <slots.label {...slotProps.label} />\n {state.showIcon && <slots.icon {...slotProps.icon} />}\n <slots.image {...slotProps.image} />\n <slots.badge {...slotProps.badge} />\n </slots.root>\n );\n};\n"]}
@@ -1,7 +0,0 @@
1
- import * as React from 'react';
2
- import type { AvatarProps, AvatarState, AvatarShorthandPropsCompat } from './Avatar.types';
3
- /**
4
- * Names of the shorthand properties in AvatarProps
5
- */
6
- export declare const avatarShorthandPropsCompat: AvatarShorthandPropsCompat[];
7
- export declare const useAvatar: (props: AvatarProps, ref: React.Ref<HTMLElement>, defaultProps?: AvatarProps | undefined) => AvatarState;
@@ -1,141 +0,0 @@
1
- define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "../../utils/index", "@fluentui/react-icons", "@fluentui/react-badge"], function (require, exports, tslib_1, React, react_utilities_1, index_1, react_icons_1, react_badge_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useAvatar = exports.avatarShorthandPropsCompat = void 0;
5
- /**
6
- * Names of the shorthand properties in AvatarProps
7
- */
8
- exports.avatarShorthandPropsCompat = ['label', 'image', 'badge', 'icon'];
9
- var mergeProps = react_utilities_1.makeMergeProps({ deepMerge: exports.avatarShorthandPropsCompat });
10
- var useAvatar = function (props, ref, defaultProps) {
11
- var state = mergeProps({
12
- as: 'span',
13
- label: { as: 'span' },
14
- icon: { as: 'span' },
15
- size: 32,
16
- color: 'neutral',
17
- activeDisplay: 'ring',
18
- getInitials: index_1.getInitials,
19
- ref: ref,
20
- }, defaultProps && resolveAvatarShorthandPropsCompat(defaultProps), resolveAvatarShorthandPropsCompat(props));
21
- var size = state.size, badge = state.badge, label = state.label, icon = state.icon;
22
- // If a label was not provided, use the initials and fall back to the icon if initials aren't available
23
- if (!label.children) {
24
- var initials = state.getInitials(state.name || '', /*isRtl: */ false);
25
- if (initials) {
26
- label.children = initials;
27
- }
28
- else {
29
- state.showIcon = true;
30
- if (!icon.children) {
31
- if (size <= 24) {
32
- icon.children = React.createElement(react_icons_1.Person16Regular, null);
33
- }
34
- else if (size <= 40) {
35
- icon.children = React.createElement(react_icons_1.Person20Regular, null);
36
- }
37
- else if (size <= 48) {
38
- icon.children = React.createElement(react_icons_1.Person24Regular, null);
39
- }
40
- else if (size <= 56) {
41
- icon.children = React.createElement(react_icons_1.Person28Regular, null);
42
- }
43
- else if (size <= 72) {
44
- icon.children = React.createElement(react_icons_1.Person32Regular, null);
45
- }
46
- else {
47
- icon.children = React.createElement(react_icons_1.Person48Regular, null);
48
- }
49
- }
50
- }
51
- }
52
- // Provide a default badge size based on the avatar size
53
- if (badge && badge.size === undefined) {
54
- if (size >= 96) {
55
- badge.size = 'larger';
56
- }
57
- else if (size >= 64) {
58
- badge.size = 'large';
59
- }
60
- else if (size >= 56) {
61
- badge.size = 'medium';
62
- }
63
- else if (size >= 40) {
64
- badge.size = 'small';
65
- }
66
- else if (size >= 28) {
67
- badge.size = 'smaller';
68
- }
69
- else {
70
- badge.size = 'smallest';
71
- }
72
- }
73
- if (state.color === 'colorful') {
74
- var value = state.idForColor || state.name;
75
- if (value) {
76
- state.color = avatarColors[getHashCode(value) % avatarColors.length];
77
- }
78
- }
79
- return state;
80
- };
81
- exports.useAvatar = useAvatar;
82
- /**
83
- * Avatar treats shorthand for the image and badge props differently. Rather than the string being
84
- * the child of those slots, they translate to the image's src and the badge's status prop.
85
- */
86
- var resolveAvatarShorthandPropsCompat = function (props) {
87
- var image = props.image, badge = props.badge;
88
- if (typeof image === 'string') {
89
- image = { as: 'img', src: image, children: null };
90
- }
91
- if (typeof badge === 'string') {
92
- badge = { as: react_badge_1.PresenceBadge, status: badge };
93
- }
94
- if (image !== props.image || badge !== props.badge) {
95
- props = tslib_1.__assign(tslib_1.__assign({}, props), { image: image, badge: badge });
96
- }
97
- return react_utilities_1.resolveShorthandProps(props, exports.avatarShorthandPropsCompat);
98
- };
99
- var avatarColors = [
100
- 'darkRed',
101
- 'cranberry',
102
- 'red',
103
- 'pumpkin',
104
- 'peach',
105
- 'marigold',
106
- 'gold',
107
- 'brass',
108
- 'brown',
109
- 'forest',
110
- 'seafoam',
111
- 'darkGreen',
112
- 'lightTeal',
113
- 'teal',
114
- 'steel',
115
- 'blue',
116
- 'royalBlue',
117
- 'cornflower',
118
- 'navy',
119
- 'lavender',
120
- 'purple',
121
- 'grape',
122
- 'lilac',
123
- 'pink',
124
- 'magenta',
125
- 'plum',
126
- 'beige',
127
- 'mink',
128
- 'platinum',
129
- 'anchor',
130
- ];
131
- var getHashCode = function (str) {
132
- var hashCode = 0;
133
- for (var len = str.length - 1; len >= 0; len--) {
134
- var ch = str.charCodeAt(len);
135
- var shift = len % 8;
136
- hashCode ^= (ch << shift) + (ch >> (8 - shift)); // eslint-disable-line no-bitwise
137
- }
138
- return hashCode;
139
- };
140
- });
141
- //# sourceMappingURL=useAvatar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAvatar.js","sourceRoot":"../src/","sources":["components/Avatar/useAvatar.tsx"],"names":[],"mappings":";;;;IAcA;;OAEG;IACU,QAAA,0BAA0B,GAAiC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAE5G,IAAM,UAAU,GAAG,gCAAc,CAAc,EAAE,SAAS,EAAE,kCAA0B,EAAE,CAAC,CAAC;IAEnF,IAAM,SAAS,GAAG,UAAC,KAAkB,EAAE,GAA2B,EAAE,YAA0B;QACnG,IAAM,KAAK,GAAG,UAAU,CACtB;YACE,EAAE,EAAE,MAAM;YACV,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACrB,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE;YACpB,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,SAAS;YAChB,aAAa,EAAE,MAAM;YACrB,WAAW,qBAAA;YACX,GAAG,KAAA;SACJ,EACD,YAAY,IAAI,iCAAiC,CAAC,YAAY,CAAC,EAC/D,iCAAiC,CAA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I,KAAK,KAAK,KAAK,CAAC,KAAK,EAAE;YAClD,KAAK,yCAAQ,KAAK,KAAE,KAAK,OAAA,EAAE,KAAK,OAAA,GAAE,CAAC;SACpC;QAED,OAAO,uCAAqB,CAAC,KAAK,EAAE,kCAA0B,CAAC,CAAC;IAClE,CAAC,CAAC;IAEF,IAAM,YAAY,GAAuB;QACvC,SAAS;QACT,WAAW;QACX,KAAK;QACL,SAAS;QACT,OAAO;QACP,UAAU;QACV,MAAM;QACN,OAAO;QACP,OAAO;QACP,QAAQ;QACR,SAAS;QACT,WAAW;QACX,WAAW;QACX,MAAM;QACN,OAAO;QACP,MAAM;QACN,WAAW;QACX,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 { makeMergeProps, resolveShorthandProps } from '@fluentui/react-utilities';\nimport { getInitials } from '../../utils/index';\nimport {\n Person16Regular,\n Person20Regular,\n Person24Regular,\n Person28Regular,\n Person32Regular,\n Person48Regular,\n} from '@fluentui/react-icons';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport type { AvatarProps, AvatarState, AvatarNamedColor, AvatarShorthandPropsCompat } from './Avatar.types';\n\n/**\n * Names of the shorthand properties in AvatarProps\n */\nexport const avatarShorthandPropsCompat: AvatarShorthandPropsCompat[] = ['label', 'image', 'badge', 'icon'];\n\nconst mergeProps = makeMergeProps<AvatarState>({ deepMerge: avatarShorthandPropsCompat });\n\nexport const useAvatar = (props: AvatarProps, ref: React.Ref<HTMLElement>, defaultProps?: AvatarProps): AvatarState => {\n const state = mergeProps(\n {\n as: 'span',\n label: { as: 'span' },\n icon: { as: 'span' },\n size: 32,\n color: 'neutral',\n activeDisplay: 'ring',\n getInitials,\n ref,\n },\n defaultProps && resolveAvatarShorthandPropsCompat(defaultProps),\n resolveAvatarShorthandPropsCompat(props),\n );\n\n const { size, badge, label, icon } = state;\n\n // If a label was not provided, use the initials and fall back to the icon if initials aren't available\n if (!label.children) {\n const initials = state.getInitials(state.name || '', /*isRtl: */ false);\n if (initials) {\n label.children = initials;\n } else {\n state.showIcon = true;\n if (!icon.children) {\n if (size <= 24) {\n icon.children = <Person16Regular />;\n } else if (size <= 40) {\n icon.children = <Person20Regular />;\n } else if (size <= 48) {\n icon.children = <Person24Regular />;\n } else if (size <= 56) {\n icon.children = <Person28Regular />;\n } else if (size <= 72) {\n icon.children = <Person32Regular />;\n } else {\n icon.children = <Person48Regular />;\n }\n }\n }\n }\n\n // Provide a default badge size based on the avatar size\n if (badge && badge.size === undefined) {\n if (size >= 96) {\n badge.size = 'larger';\n } else if (size >= 64) {\n badge.size = 'large';\n } else if (size >= 56) {\n badge.size = 'medium';\n } else if (size >= 40) {\n badge.size = 'small';\n } else if (size >= 28) {\n badge.size = 'smaller';\n } else {\n badge.size = 'smallest';\n }\n }\n\n if (state.color === 'colorful') {\n const value = state.idForColor || state.name;\n if (value) {\n state.color = avatarColors[getHashCode(value) % avatarColors.length];\n }\n }\n\n return state;\n};\n\n/**\n * Avatar treats shorthand for the image and badge props differently. Rather than the string being\n * the child of those slots, they translate to the image's src and the badge's status prop.\n */\nconst resolveAvatarShorthandPropsCompat = (props: AvatarProps) => {\n let { image, badge } = props;\n\n if (typeof image === 'string') {\n image = { as: 'img', src: image, children: null };\n }\n\n if (typeof badge === 'string') {\n badge = { as: PresenceBadge, status: badge };\n }\n\n if (image !== props.image || badge !== props.badge) {\n props = { ...props, image, badge };\n }\n\n return resolveShorthandProps(props, avatarShorthandPropsCompat);\n};\n\nconst avatarColors: AvatarNamedColor[] = [\n 'darkRed',\n 'cranberry',\n 'red',\n 'pumpkin',\n 'peach',\n 'marigold',\n 'gold',\n 'brass',\n 'brown',\n 'forest',\n 'seafoam',\n 'darkGreen',\n 'lightTeal',\n 'teal',\n 'steel',\n 'blue',\n 'royalBlue',\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"]}
@@ -1,2 +0,0 @@
1
- import type { AvatarState } from './Avatar.types';
2
- export declare const useAvatarStyles: (state: AvatarState) => AvatarState;