@fluentui/react-persona 0.0.0-nightly-20221007-1237.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/CHANGELOG.json +127 -0
  2. package/CHANGELOG.md +53 -0
  3. package/LICENSE +15 -0
  4. package/MIGRATION.md +42 -0
  5. package/README.md +29 -0
  6. package/Spec.md +213 -0
  7. package/dist/index.d.ts +114 -0
  8. package/lib/Persona.js +2 -0
  9. package/lib/Persona.js.map +1 -0
  10. package/lib/components/Persona/Persona.js +16 -0
  11. package/lib/components/Persona/Persona.js.map +1 -0
  12. package/lib/components/Persona/Persona.types.js +2 -0
  13. package/lib/components/Persona/Persona.types.js.map +1 -0
  14. package/lib/components/Persona/index.js +6 -0
  15. package/lib/components/Persona/index.js.map +1 -0
  16. package/lib/components/Persona/renderPersona.js +26 -0
  17. package/lib/components/Persona/renderPersona.js.map +1 -0
  18. package/lib/components/Persona/usePersona.js +101 -0
  19. package/lib/components/Persona/usePersona.js.map +1 -0
  20. package/lib/components/Persona/usePersonaStyles.js +208 -0
  21. package/lib/components/Persona/usePersonaStyles.js.map +1 -0
  22. package/lib/index.js +2 -0
  23. package/lib/index.js.map +1 -0
  24. package/lib-commonjs/Persona.js +10 -0
  25. package/lib-commonjs/Persona.js.map +1 -0
  26. package/lib-commonjs/components/Persona/Persona.js +27 -0
  27. package/lib-commonjs/components/Persona/Persona.js.map +1 -0
  28. package/lib-commonjs/components/Persona/Persona.types.js +6 -0
  29. package/lib-commonjs/components/Persona/Persona.types.js.map +1 -0
  30. package/lib-commonjs/components/Persona/index.js +18 -0
  31. package/lib-commonjs/components/Persona/index.js.map +1 -0
  32. package/lib-commonjs/components/Persona/renderPersona.js +37 -0
  33. package/lib-commonjs/components/Persona/renderPersona.js.map +1 -0
  34. package/lib-commonjs/components/Persona/usePersona.js +113 -0
  35. package/lib-commonjs/components/Persona/usePersona.js.map +1 -0
  36. package/lib-commonjs/components/Persona/usePersonaStyles.js +219 -0
  37. package/lib-commonjs/components/Persona/usePersonaStyles.js.map +1 -0
  38. package/lib-commonjs/index.js +40 -0
  39. package/lib-commonjs/index.js.map +1 -0
  40. package/package.json +49 -0
@@ -0,0 +1,26 @@
1
+ import * as React from 'react';
2
+ import { getSlots } from '@fluentui/react-utilities';
3
+ /**
4
+ * Render the final JSX of Persona
5
+ */
6
+
7
+ export const renderPersona_unstable = state => {
8
+ const {
9
+ presenceOnly,
10
+ textPosition
11
+ } = state;
12
+ const {
13
+ slots,
14
+ slotProps
15
+ } = getSlots(state);
16
+ const coin = presenceOnly ? slots.presence && /*#__PURE__*/React.createElement(slots.presence, { ...slotProps.presence
17
+ }) : slots.avatar && /*#__PURE__*/React.createElement(slots.avatar, { ...slotProps.avatar
18
+ });
19
+ return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
20
+ }, (textPosition === 'after' || textPosition === 'below') && coin, slots.primaryText && /*#__PURE__*/React.createElement(slots.primaryText, { ...slotProps.primaryText
21
+ }), slots.secondaryText && /*#__PURE__*/React.createElement(slots.secondaryText, { ...slotProps.secondaryText
22
+ }), slots.tertiaryText && /*#__PURE__*/React.createElement(slots.tertiaryText, { ...slotProps.tertiaryText
23
+ }), slots.quaternaryText && /*#__PURE__*/React.createElement(slots.quaternaryText, { ...slotProps.quaternaryText
24
+ }), textPosition === 'before' && coin);
25
+ };
26
+ //# sourceMappingURL=renderPersona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Persona/renderPersona.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,sBAAsB,GAAI,KAAD,IAAwB;EAC5D,MAAM;IAAE,YAAF;IAAgB;EAAhB,IAAiC,KAAvC;EACA,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAAe,KAAf,CAArC;EAEA,MAAM,IAAI,GAAG,YAAY,GACrB,KAAK,CAAC,QAAN,iBAAkB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,QAAP,EAAe,EAAA,GAAK,SAAS,CAAC;EAAf,CAAf,CADG,GAErB,KAAK,CAAC,MAAN,iBAAgB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,MAAP,EAAa,EAAA,GAAK,SAAS,CAAC;EAAf,CAAb,CAFpB;EAIA,oBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,CAAC,YAAY,KAAK,OAAjB,IAA4B,YAAY,KAAK,OAA9C,KAA0D,IAD7D,EAEG,KAAK,CAAC,WAAN,iBAAqB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,WAAP,EAAkB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAlB,CAFxB,EAGG,KAAK,CAAC,aAAN,iBAAuB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,aAAP,EAAoB,EAAA,GAAK,SAAS,CAAC;EAAf,CAApB,CAH1B,EAIG,KAAK,CAAC,YAAN,iBAAsB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,YAAP,EAAmB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAnB,CAJzB,EAKG,KAAK,CAAC,cAAN,iBAAwB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,cAAP,EAAqB,EAAA,GAAK,SAAS,CAAC;EAAf,CAArB,CAL3B,EAMG,YAAY,KAAK,QAAjB,IAA6B,IANhC,CADF;AAUD,CAlBM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { PersonaState, PersonaSlots } from './Persona.types';\n\n/**\n * Render the final JSX of Persona\n */\nexport const renderPersona_unstable = (state: PersonaState) => {\n const { presenceOnly, textPosition } = state;\n const { slots, slotProps } = getSlots<PersonaSlots>(state);\n\n const coin = presenceOnly\n ? slots.presence && <slots.presence {...slotProps.presence} />\n : slots.avatar && <slots.avatar {...slotProps.avatar} />;\n\n return (\n <slots.root {...slotProps.root}>\n {(textPosition === 'after' || textPosition === 'below') && coin}\n {slots.primaryText && <slots.primaryText {...slotProps.primaryText} />}\n {slots.secondaryText && <slots.secondaryText {...slotProps.secondaryText} />}\n {slots.tertiaryText && <slots.tertiaryText {...slotProps.tertiaryText} />}\n {slots.quaternaryText && <slots.quaternaryText {...slotProps.quaternaryText} />}\n {textPosition === 'before' && coin}\n </slots.root>\n );\n};\n"],"sourceRoot":""}
@@ -0,0 +1,101 @@
1
+ import { Avatar } from '@fluentui/react-avatar';
2
+ import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';
3
+ import { PresenceBadge } from '@fluentui/react-badge';
4
+ /**
5
+ * Create the state required to render Persona.
6
+ *
7
+ * The returned state can be modified with hooks such as usePersonaStyles_unstable,
8
+ * before being passed to renderPersona_unstable.
9
+ *
10
+ * @param props - props from this instance of Persona
11
+ * @param ref - reference to root HTMLElement of Persona
12
+ */
13
+
14
+ export const usePersona_unstable = (props, ref) => {
15
+ const {
16
+ presenceOnly = false,
17
+ textPosition = 'after',
18
+ name
19
+ } = props;
20
+ const primaryText = resolveShorthand(props.primaryText, {
21
+ required: true,
22
+ defaultProps: {
23
+ children: name
24
+ }
25
+ });
26
+ const secondaryText = resolveShorthand(props.secondaryText);
27
+ const tertiaryText = resolveShorthand(props.tertiaryText);
28
+ const quaternaryText = resolveShorthand(props.quaternaryText);
29
+ const numTextLines = [primaryText, secondaryText, tertiaryText, quaternaryText].filter(Boolean).length;
30
+ let fixed = false;
31
+
32
+ if (!presenceOnly && props.avatar) {
33
+ fixed = !!props.avatar.size;
34
+ } else if (props.presence && props.presence) {
35
+ fixed = !!props.presence.size;
36
+ }
37
+
38
+ let avatarSize = undefined;
39
+ let presenceSize = undefined;
40
+
41
+ if (presenceOnly && !fixed) {
42
+ if (numTextLines === 1) {
43
+ presenceSize = 'small';
44
+ } else if (numTextLines === 2) {
45
+ presenceSize = 'large';
46
+ } else {
47
+ presenceSize = 'extra-large';
48
+ }
49
+ } else if (!fixed) {
50
+ if (numTextLines === 1) {
51
+ avatarSize = 16;
52
+ } else if (numTextLines === 2) {
53
+ avatarSize = 32;
54
+ } else if (numTextLines === 3) {
55
+ avatarSize = 56;
56
+ } else {
57
+ avatarSize = 72;
58
+ }
59
+ }
60
+
61
+ const avatar = !presenceOnly ? resolveShorthand(props.avatar, {
62
+ required: true,
63
+ defaultProps: {
64
+ name,
65
+ badge: props.presence,
66
+ size: avatarSize
67
+ }
68
+ }) : undefined;
69
+ const presence = presenceOnly ? resolveShorthand(props.presence, {
70
+ defaultProps: {
71
+ size: presenceSize
72
+ }
73
+ }) : undefined;
74
+ return {
75
+ fixed,
76
+ numTextLines,
77
+ presenceOnly,
78
+ textPosition,
79
+ components: {
80
+ root: 'div',
81
+ avatar: Avatar,
82
+ presence: PresenceBadge,
83
+ primaryText: 'span',
84
+ secondaryText: 'span',
85
+ tertiaryText: 'span',
86
+ quaternaryText: 'span'
87
+ },
88
+ root: getNativeElementProps('div', { ...props,
89
+ ref
90
+ },
91
+ /* excludedPropNames */
92
+ ['name']),
93
+ avatar,
94
+ presence,
95
+ primaryText,
96
+ secondaryText,
97
+ tertiaryText,
98
+ quaternaryText
99
+ };
100
+ };
101
+ //# sourceMappingURL=usePersona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Persona/usePersona.ts"],"names":[],"mappings":"AACA,SAAS,MAAT,QAAuB,wBAAvB;AACA,SAAS,qBAAT,EAAgC,gBAAhC,QAAwD,2BAAxD;AACA,SAAS,aAAT,QAA8B,uBAA9B;AAKA;;;;;;;;AAQG;;AACH,OAAO,MAAM,mBAAmB,GAAG,CAAC,KAAD,EAAsB,GAAtB,KAAmE;EACpG,MAAM;IAAE,YAAY,GAAG,KAAjB;IAAwB,YAAY,GAAG,OAAvC;IAAgD;EAAhD,IAAyD,KAA/D;EAEA,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,WAAP,EAAoB;IACtD,QAAQ,EAAE,IAD4C;I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,EAAb;IACD;EACF;;EAED,MAAM,MAAM,GAA2B,CAAC,YAAD,GACnC,gBAAgB,CAAC,KAAK,CAAC,MAAP,EAAe;IAC7B,QAAQ,EAAE,IADmB;IAE7B,YAAY,EAAE;MACZ,IADY;MAEZ,KAAK,EAAE,KAAK,CAAC,QAFD;MAGZ,IAAI,EAAE;IAHM;EAFe,CAAf,CADmB,GASnC,SATJ;EAWA,MAAM,QAAQ,GAA6B,YAAY,GACnD,gBAAgB,CAAC,KAAK,CAAC,QAAP,EAAiB;IAC/B,YAAY,EAAE;MACZ,IAAI,EAAE;IADM;EADiB,CAAjB,CADmC,GAMnD,SANJ;EAQA,OAAO;IACL,KADK;IAEL,YAFK;IAGL,YAHK;IAIL,YAJK;IAML,UAAU,EAAE;MACV,IAAI,EAAE,KADI;MAEV,MAAM,EAAE,MAFE;MAGV,QAAQ,EAAE,aAHA;MAIV,WAAW,EAAE,MAJH;MAKV,aAAa,EAAE,MALL;MAMV,YAAY,EAAE,MANJ;MAOV,cAAc,EAAE;IAPN,CANP;IAgBL,IAAI,EAAE,qBAAqB,CACzB,KADyB,EAEzB,EACE,GAAG,KADL;MAEE;IAFF,CAFyB;IAMzB;IAAwB,CAAC,MAAD,CANC,CAhBtB;IAwBL,MAxBK;IAyBL,QAzBK;IA0BL,WA1BK;IA2BL,aA3BK;IA4BL,YA5BK;IA6BL;EA7BK,CAAP;AA+BD,CA9FM","sourcesContent":["import * as React from 'react';\nimport { Avatar } from '@fluentui/react-avatar';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport type { AvatarProps } from '@fluentui/react-avatar';\nimport type { PersonaProps, PersonaState } from './Persona.types';\nimport type { PresenceBadgeProps } from '@fluentui/react-badge';\n\n/**\n * Create the state required to render Persona.\n *\n * The returned state can be modified with hooks such as usePersonaStyles_unstable,\n * before being passed to renderPersona_unstable.\n *\n * @param props - props from this instance of Persona\n * @param ref - reference to root HTMLElement of Persona\n */\nexport const usePersona_unstable = (props: PersonaProps, ref: React.Ref<HTMLElement>): PersonaState => {\n const { presenceOnly = false, textPosition = 'after', name } = props;\n\n const primaryText = resolveShorthand(props.primaryText, {\n required: true,\n defaultProps: {\n children: name,\n },\n });\n const secondaryText = resolveShorthand(props.secondaryText);\n const tertiaryText = resolveShorthand(props.tertiaryText);\n const quaternaryText = resolveShorthand(props.quaternaryText);\n\n const numTextLines = [primaryText, secondaryText, tertiaryText, quaternaryText].filter(Boolean).length;\n\n let fixed = false;\n if (!presenceOnly && props.avatar) {\n fixed = !!(props.avatar as AvatarProps).size;\n } else if (props.presence && props.presence) {\n fixed = !!(props.presence as PresenceBadgeProps).size;\n }\n\n let avatarSize: AvatarProps['size'] = undefined;\n let presenceSize: PresenceBadgeProps['size'] = undefined;\n if (presenceOnly && !fixed) {\n if (numTextLines === 1) {\n presenceSize = 'small';\n } else if (numTextLines === 2) {\n presenceSize = 'large';\n } else {\n presenceSize = 'extra-large';\n }\n } else if (!fixed) {\n if (numTextLines === 1) {\n avatarSize = 16;\n } else if (numTextLines === 2) {\n avatarSize = 32;\n } else if (numTextLines === 3) {\n avatarSize = 56;\n } else {\n avatarSize = 72;\n }\n }\n\n const avatar: PersonaState['avatar'] = !presenceOnly\n ? resolveShorthand(props.avatar, {\n required: true,\n defaultProps: {\n name,\n badge: props.presence,\n size: avatarSize,\n },\n })\n : undefined;\n\n const presence: PersonaState['presence'] = presenceOnly\n ? resolveShorthand(props.presence, {\n defaultProps: {\n size: presenceSize,\n },\n })\n : undefined;\n\n return {\n fixed,\n numTextLines,\n presenceOnly,\n textPosition,\n\n components: {\n root: 'div',\n avatar: Avatar,\n presence: PresenceBadge,\n primaryText: 'span',\n secondaryText: 'span',\n tertiaryText: 'span',\n quaternaryText: 'span',\n },\n\n root: getNativeElementProps(\n 'div',\n {\n ...props,\n ref,\n },\n /* excludedPropNames */ ['name'],\n ),\n avatar,\n presence,\n primaryText,\n secondaryText,\n tertiaryText,\n quaternaryText,\n };\n};\n"],"sourceRoot":""}
@@ -0,0 +1,208 @@
1
+ import { __styles, mergeClasses } from '@griffel/react';
2
+ import { tokens, typographyStyles } from '@fluentui/react-theme';
3
+ export const personaClassNames = {
4
+ root: 'fui-Persona',
5
+ avatar: 'fui-Persona__avatar',
6
+ presence: 'fui-Persona__presence',
7
+ primaryText: 'fui-Persona__primaryText',
8
+ secondaryText: 'fui-Persona__secondaryText',
9
+ tertiaryText: 'fui-Persona__tertiaryText',
10
+ quaternaryText: 'fui-Persona__quaternaryText'
11
+ };
12
+ /**
13
+ * Styles for the root slot
14
+ */
15
+
16
+ const useStyles = /*#__PURE__*/__styles({
17
+ "root": {
18
+ "mc9l5x": "fwk3njj",
19
+ "t4k1zu": "f4wu0r3",
20
+ "v29qe6": "fvtn1bl"
21
+ },
22
+ "after": {
23
+ "Bxotwcr": "f1u07yai",
24
+ "B7hvi0a": "f1m2n5bn",
25
+ "i8kkvl": "f4px1ci"
26
+ },
27
+ "before": {
28
+ "Bxotwcr": "f1u07yai",
29
+ "B7hvi0a": "f1tll2w5",
30
+ "i8kkvl": "f4px1ci"
31
+ },
32
+ "below": {
33
+ "B7hvi0a": "f1oiokrs"
34
+ },
35
+ "coin": {
36
+ "Ijaq50": "f1hek2iy"
37
+ },
38
+ "fixed": {
39
+ "qb2dma": "f9h729m"
40
+ },
41
+ "scaled": {
42
+ "qb2dma": "f7nlbp4"
43
+ }
44
+ }, {
45
+ "d": [".fwk3njj{display:inline-grid;}", ".f4wu0r3{grid-auto-columns:max-content;}", ".fvtn1bl{grid-auto-rows:max-content;}", ".f1u07yai{grid-auto-flow:column;}", ".f1m2n5bn{justify-items:start;}", ".f4px1ci{-webkit-column-gap:8px;column-gap:8px;}", ".f1tll2w5{justify-items:end;}", ".f1oiokrs{justify-items:center;}", ".f1hek2iy{grid-row-start:span 5;}", ".f9h729m{-webkit-align-self:start;-ms-flex-item-align:start;align-self:start;}", ".f7nlbp4{-webkit-align-self:center;-ms-flex-item-align:center;align-self:center;}"]
46
+ });
47
+ /**
48
+ * Apply styling to the Persona slots based on the state
49
+ */
50
+
51
+
52
+ export const usePersonaStyles_unstable = state => {
53
+ const {
54
+ fixed,
55
+ textPosition
56
+ } = state;
57
+ const styles = useStyles();
58
+ const {
59
+ primaryTextClassName,
60
+ optionalTextClassName
61
+ } = useTextClassNames(state);
62
+ state.root.className = mergeClasses(personaClassNames.root, styles.root, styles[textPosition], state.root.className);
63
+
64
+ if (state.avatar) {
65
+ state.avatar.className = mergeClasses(personaClassNames.avatar, styles.coin, fixed ? styles.fixed : styles.scaled, state.avatar.className);
66
+ }
67
+
68
+ if (state.presence) {
69
+ state.presence.className = mergeClasses(personaClassNames.presence, styles.coin, fixed ? styles.fixed : styles.scaled, state.presence.className);
70
+ }
71
+
72
+ if (state.primaryText) {
73
+ state.primaryText.className = mergeClasses(personaClassNames.primaryText, primaryTextClassName, state.primaryText.className);
74
+ }
75
+
76
+ if (state.secondaryText) {
77
+ state.secondaryText.className = mergeClasses(personaClassNames.secondaryText, optionalTextClassName, state.secondaryText.className);
78
+ }
79
+
80
+ if (state.tertiaryText) {
81
+ state.tertiaryText.className = mergeClasses(personaClassNames.tertiaryText, optionalTextClassName, state.tertiaryText.className);
82
+ }
83
+
84
+ if (state.quaternaryText) {
85
+ state.quaternaryText.className = mergeClasses(personaClassNames.quaternaryText, optionalTextClassName, state.quaternaryText.className);
86
+ }
87
+
88
+ return state;
89
+ };
90
+
91
+ const useTextStyles = /*#__PURE__*/__styles({
92
+ "base": {
93
+ "mc9l5x": "ftgm304"
94
+ },
95
+ "primaryText": {
96
+ "sj55zd": "f19n0e5"
97
+ },
98
+ "optionalText": {
99
+ "sj55zd": "fkfq4zb"
100
+ },
101
+ "body1": {
102
+ "Bahqtrf": "fk6fouc",
103
+ "Be2twd7": "fkhj508",
104
+ "Bhrd7zp": "figsok6",
105
+ "Bg96gwp": "f1i3iumi"
106
+ },
107
+ "caption1": {
108
+ "Bahqtrf": "fk6fouc",
109
+ "Be2twd7": "fy9rknc",
110
+ "Bhrd7zp": "figsok6",
111
+ "Bg96gwp": "fwrc4pm"
112
+ },
113
+ "subtitle2": {
114
+ "Bahqtrf": "fk6fouc",
115
+ "Be2twd7": "fod5ikn",
116
+ "Bhrd7zp": "fl43uef",
117
+ "Bg96gwp": "faaz57k"
118
+ },
119
+ "subtitle1": {
120
+ "Bahqtrf": "fk6fouc",
121
+ "Be2twd7": "f1pp30po",
122
+ "Bhrd7zp": "fl43uef",
123
+ "Bg96gwp": "f106mvju"
124
+ },
125
+ "title2": {
126
+ "Bahqtrf": "fk6fouc",
127
+ "Be2twd7": "fojgt09",
128
+ "Bhrd7zp": "fl43uef",
129
+ "Bg96gwp": "fcen8rp"
130
+ },
131
+ "title3": {
132
+ "Bahqtrf": "fk6fouc",
133
+ "Be2twd7": "f1x0m3f5",
134
+ "Bhrd7zp": "fl43uef",
135
+ "Bg96gwp": "fb86gi6"
136
+ }
137
+ }, {
138
+ "d": [".ftgm304{display:block;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".fkfq4zb{color:var(--colorNeutralForeground2);}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".figsok6{font-weight:var(--fontWeightRegular);}", ".f1i3iumi{line-height:var(--lineHeightBase300);}", ".fy9rknc{font-size:var(--fontSizeBase200);}", ".fwrc4pm{line-height:var(--lineHeightBase200);}", ".fod5ikn{font-size:var(--fontSizeBase400);}", ".fl43uef{font-weight:var(--fontWeightSemibold);}", ".faaz57k{line-height:var(--lineHeightBase400);}", ".f1pp30po{font-size:var(--fontSizeBase500);}", ".f106mvju{line-height:var(--lineHeightBase500);}", ".fojgt09{font-size:var(--fontSizeHero700);}", ".fcen8rp{line-height:var(--lineHeightHero700);}", ".f1x0m3f5{font-size:var(--fontSizeBase600);}", ".fb86gi6{line-height:var(--lineHeightBase600);}"]
139
+ });
140
+
141
+ const useTextClassNames = state => {
142
+ const {
143
+ fixed,
144
+ numTextLines,
145
+ presenceOnly
146
+ } = state;
147
+ const textStyles = useTextStyles();
148
+ let primaryTextSize;
149
+ let optionalTextSize;
150
+
151
+ if (fixed) {
152
+ if (state.avatar && state.avatar.size) {
153
+ const {
154
+ size
155
+ } = state.avatar;
156
+
157
+ if (size < 40) {
158
+ primaryTextSize = textStyles.body1;
159
+ optionalTextSize = textStyles.caption1;
160
+ } else if (size < 64) {
161
+ primaryTextSize = textStyles.subtitle2;
162
+ optionalTextSize = textStyles.body1;
163
+ } else if (size < 96) {
164
+ primaryTextSize = textStyles.subtitle1;
165
+ optionalTextSize = textStyles.caption1;
166
+ } else {
167
+ if (numTextLines > 1) {
168
+ primaryTextSize = textStyles.title3;
169
+ } else {
170
+ primaryTextSize = textStyles.title2;
171
+ }
172
+
173
+ optionalTextSize = textStyles.body1;
174
+ }
175
+ } else if (presenceOnly && state.presence) {
176
+ const {
177
+ size
178
+ } = state.presence;
179
+
180
+ if (size === 'extra-small' || size === 'tiny') {
181
+ if (numTextLines > 1) {
182
+ primaryTextSize = textStyles.body1;
183
+ } else {
184
+ primaryTextSize = textStyles.caption1;
185
+ }
186
+
187
+ optionalTextSize = textStyles.caption1;
188
+ } else {
189
+ primaryTextSize = textStyles.body1;
190
+ optionalTextSize = textStyles.caption1;
191
+ }
192
+ }
193
+ } else {
194
+ if (numTextLines > 1) {
195
+ primaryTextSize = textStyles.body1;
196
+ } else {
197
+ primaryTextSize = textStyles.caption1;
198
+ }
199
+
200
+ optionalTextSize = textStyles.caption1;
201
+ }
202
+
203
+ return {
204
+ primaryTextClassName: mergeClasses(textStyles.base, textStyles.primaryText, primaryTextSize),
205
+ optionalTextClassName: mergeClasses(textStyles.base, textStyles.optionalText, optionalTextSize)
206
+ };
207
+ };
208
+ //# sourceMappingURL=usePersonaStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Persona/usePersonaStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,QAAyC,gBAAzC;AACA,SAA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BAAgB,GAAG,UAAU,CAAC,QAA9B;MACD,CAPD,MAOO;QACL,eAAe,GAAG,UAAU,CAAC,KAA7B;QACA,gBAAgB,GAAG,UAAU,CAAC,QAA9B;MACD;IACF;EACF,CApCD,MAoCO;IACL,IAAI,YAAY,GAAG,CAAnB,EAAsB;MACpB,eAAe,GAAG,UAAU,CAAC,KAA7B;IACD,CAFD,MAEO;MACL,eAAe,GAAG,UAAU,CAAC,QAA7B;IACD;;IACD,gBAAgB,GAAG,UAAU,CAAC,QAA9B;EACD;;EAED,OAAO;IACL,oBAAoB,EAAE,YAAY,CAAC,UAAU,CAAC,IAAZ,EAAkB,UAAU,CAAC,WAA7B,EAA0C,eAA1C,CAD7B;IAEL,qBAAqB,EAAE,YAAY,CAAC,UAAU,CAAC,IAAZ,EAAkB,UAAU,CAAC,YAA7B,EAA2C,gBAA3C;EAF9B,CAAP;AAID,CA5DD","sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport type { PersonaSlots, PersonaState } from './Persona.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const personaClassNames: SlotClassNames<PersonaSlots> = {\n root: 'fui-Persona',\n avatar: 'fui-Persona__avatar',\n presence: 'fui-Persona__presence',\n primaryText: 'fui-Persona__primaryText',\n secondaryText: 'fui-Persona__secondaryText',\n tertiaryText: 'fui-Persona__tertiaryText',\n quaternaryText: 'fui-Persona__quaternaryText',\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n display: 'inline-grid',\n gridAutoColumns: 'max-content',\n gridAutoRows: 'max-content',\n },\n after: {\n gridAutoFlow: 'column',\n justifyItems: 'start',\n columnGap: '8px',\n },\n before: {\n gridAutoFlow: 'column',\n justifyItems: 'end',\n columnGap: '8px',\n },\n below: {\n justifyItems: 'center',\n },\n coin: {\n gridRowStart: 'span 5',\n },\n\n fixed: {\n alignSelf: 'start',\n },\n scaled: {\n alignSelf: 'center',\n },\n});\n\n/**\n * Apply styling to the Persona slots based on the state\n */\nexport const usePersonaStyles_unstable = (state: PersonaState): PersonaState => {\n const { fixed, textPosition } = state;\n const styles = useStyles();\n const { primaryTextClassName, optionalTextClassName } = useTextClassNames(state);\n\n state.root.className = mergeClasses(personaClassNames.root, styles.root, styles[textPosition], state.root.className);\n\n if (state.avatar) {\n state.avatar.className = mergeClasses(\n personaClassNames.avatar,\n styles.coin,\n fixed ? styles.fixed : styles.scaled,\n state.avatar.className,\n );\n }\n\n if (state.presence) {\n state.presence.className = mergeClasses(\n personaClassNames.presence,\n styles.coin,\n fixed ? styles.fixed : styles.scaled,\n state.presence.className,\n );\n }\n\n if (state.primaryText) {\n state.primaryText.className = mergeClasses(\n personaClassNames.primaryText,\n primaryTextClassName,\n state.primaryText.className,\n );\n }\n\n if (state.secondaryText) {\n state.secondaryText.className = mergeClasses(\n personaClassNames.secondaryText,\n optionalTextClassName,\n state.secondaryText.className,\n );\n }\n\n if (state.tertiaryText) {\n state.tertiaryText.className = mergeClasses(\n personaClassNames.tertiaryText,\n optionalTextClassName,\n state.tertiaryText.className,\n );\n }\n\n if (state.quaternaryText) {\n state.quaternaryText.className = mergeClasses(\n personaClassNames.quaternaryText,\n optionalTextClassName,\n state.quaternaryText.className,\n );\n }\n\n return state;\n};\n\nconst useTextStyles = makeStyles({\n base: {\n display: 'block',\n },\n primaryText: {\n color: tokens.colorNeutralForeground1,\n },\n optionalText: {\n color: tokens.colorNeutralForeground2,\n },\n\n body1: typographyStyles.body1,\n caption1: typographyStyles.caption1,\n subtitle2: typographyStyles.subtitle2,\n subtitle1: typographyStyles.subtitle1,\n title2: typographyStyles.title2,\n title3: typographyStyles.title3,\n});\n\nconst useTextClassNames = (\n state: PersonaState,\n): {\n primaryTextClassName: string;\n optionalTextClassName: string;\n} => {\n const { fixed, numTextLines, presenceOnly } = state;\n const textStyles = useTextStyles();\n let primaryTextSize;\n let optionalTextSize;\n\n if (fixed) {\n if (state.avatar && state.avatar.size) {\n const { size } = state.avatar;\n\n if (size < 40) {\n primaryTextSize = textStyles.body1;\n optionalTextSize = textStyles.caption1;\n } else if (size < 64) {\n primaryTextSize = textStyles.subtitle2;\n optionalTextSize = textStyles.body1;\n } else if (size < 96) {\n primaryTextSize = textStyles.subtitle1;\n optionalTextSize = textStyles.caption1;\n } else {\n if (numTextLines > 1) {\n primaryTextSize = textStyles.title3;\n } else {\n primaryTextSize = textStyles.title2;\n }\n optionalTextSize = textStyles.body1;\n }\n } else if (presenceOnly && state.presence) {\n const { size } = state.presence;\n\n if (size === 'extra-small' || size === 'tiny') {\n if (numTextLines > 1) {\n primaryTextSize = textStyles.body1;\n } else {\n primaryTextSize = textStyles.caption1;\n }\n optionalTextSize = textStyles.caption1;\n } else {\n primaryTextSize = textStyles.body1;\n optionalTextSize = textStyles.caption1;\n }\n }\n } else {\n if (numTextLines > 1) {\n primaryTextSize = textStyles.body1;\n } else {\n primaryTextSize = textStyles.caption1;\n }\n optionalTextSize = textStyles.caption1;\n }\n\n return {\n primaryTextClassName: mergeClasses(textStyles.base, textStyles.primaryText, primaryTextSize),\n optionalTextClassName: mergeClasses(textStyles.base, textStyles.optionalText, optionalTextSize),\n };\n};\n"],"sourceRoot":""}
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Persona, personaClassNames, renderPersona_unstable, usePersonaStyles_unstable, usePersona_unstable } from './Persona';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SACE,OADF,EAEE,iBAFF,EAGE,sBAHF,EAIE,yBAJF,EAKE,mBALF,QAMO,WANP","sourcesContent":["export {\n Persona,\n personaClassNames,\n renderPersona_unstable,\n usePersonaStyles_unstable,\n usePersona_unstable,\n} from './Persona';\nexport type { PersonaProps, PersonaSlots, PersonaState } from './Persona';\n"],"sourceRoot":""}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./components/Persona/index"), exports);
10
+ //# sourceMappingURL=Persona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Persona.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Persona/index';\n"],"sourceRoot":""}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Persona = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const renderPersona_1 = /*#__PURE__*/require("./renderPersona");
11
+
12
+ const usePersona_1 = /*#__PURE__*/require("./usePersona");
13
+
14
+ const usePersonaStyles_1 = /*#__PURE__*/require("./usePersonaStyles");
15
+ /**
16
+ * A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,
17
+ * or an Avatar with a PresenceBadge.
18
+ */
19
+
20
+
21
+ exports.Persona = /*#__PURE__*/React.forwardRef((props, ref) => {
22
+ const state = usePersona_1.usePersona_unstable(props, ref);
23
+ usePersonaStyles_1.usePersonaStyles_unstable(state);
24
+ return renderPersona_1.renderPersona_unstable(state);
25
+ });
26
+ exports.Persona.displayName = 'Persona';
27
+ //# sourceMappingURL=Persona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Persona/Persona.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,iBAAA,CAAA;;AACA,MAAA,YAAA,gBAAA,OAAA,CAAA,cAAA,CAAA;;AACA,MAAA,kBAAA,gBAAA,OAAA,CAAA,oBAAA,CAAA;AAIA;;;AAGG;;;AACU,OAAA,CAAA,OAAA,gBAA6C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EACxF,MAAM,KAAK,GAAG,YAAA,CAAA,mBAAA,CAAoB,KAApB,EAA2B,GAA3B,CAAd;EAEA,kBAAA,CAAA,yBAAA,CAA0B,KAA1B;EACA,OAAO,eAAA,CAAA,sBAAA,CAAuB,KAAvB,CAAP;AACD,CALyD,CAA7C;AAOb,OAAA,CAAA,OAAA,CAAQ,WAAR,GAAsB,SAAtB","sourcesContent":["import * as React from 'react';\nimport { renderPersona_unstable } from './renderPersona';\nimport { usePersona_unstable } from './usePersona';\nimport { usePersonaStyles_unstable } from './usePersonaStyles';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport type { PersonaProps } from './Persona.types';\n\n/**\n * A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,\n * or an Avatar with a PresenceBadge.\n */\nexport const Persona: ForwardRefComponent<PersonaProps> = React.forwardRef((props, ref) => {\n const state = usePersona_unstable(props, ref);\n\n usePersonaStyles_unstable(state);\n return renderPersona_unstable(state);\n});\n\nPersona.displayName = 'Persona';\n"],"sourceRoot":""}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=Persona.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ const tslib_1 = /*#__PURE__*/require("tslib");
8
+
9
+ tslib_1.__exportStar(require("./Persona"), exports);
10
+
11
+ tslib_1.__exportStar(require("./Persona.types"), exports);
12
+
13
+ tslib_1.__exportStar(require("./renderPersona"), exports);
14
+
15
+ tslib_1.__exportStar(require("./usePersona"), exports);
16
+
17
+ tslib_1.__exportStar(require("./usePersonaStyles"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Persona/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,WAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Persona';\nexport * from './Persona.types';\nexport * from './renderPersona';\nexport * from './usePersona';\nexport * from './usePersonaStyles';\n"],"sourceRoot":""}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderPersona_unstable = void 0;
7
+
8
+ const React = /*#__PURE__*/require("react");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+ /**
12
+ * Render the final JSX of Persona
13
+ */
14
+
15
+
16
+ const renderPersona_unstable = state => {
17
+ const {
18
+ presenceOnly,
19
+ textPosition
20
+ } = state;
21
+ const {
22
+ slots,
23
+ slotProps
24
+ } = react_utilities_1.getSlots(state);
25
+ const coin = presenceOnly ? slots.presence && React.createElement(slots.presence, { ...slotProps.presence
26
+ }) : slots.avatar && React.createElement(slots.avatar, { ...slotProps.avatar
27
+ });
28
+ return React.createElement(slots.root, { ...slotProps.root
29
+ }, (textPosition === 'after' || textPosition === 'below') && coin, slots.primaryText && React.createElement(slots.primaryText, { ...slotProps.primaryText
30
+ }), slots.secondaryText && React.createElement(slots.secondaryText, { ...slotProps.secondaryText
31
+ }), slots.tertiaryText && React.createElement(slots.tertiaryText, { ...slotProps.tertiaryText
32
+ }), slots.quaternaryText && React.createElement(slots.quaternaryText, { ...slotProps.quaternaryText
33
+ }), textPosition === 'before' && coin);
34
+ };
35
+
36
+ exports.renderPersona_unstable = renderPersona_unstable;
37
+ //# sourceMappingURL=renderPersona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Persona/renderPersona.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,sBAAsB,GAAI,KAAD,IAAwB;EAC5D,MAAM;IAAE,YAAF;IAAgB;EAAhB,IAAiC,KAAvC;EACA,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAAuB,KAAvB,CAA7B;EAEA,MAAM,IAAI,GAAG,YAAY,GACrB,KAAK,CAAC,QAAN,IAAkB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,QAAP,EAAe,EAAA,GAAK,SAAS,CAAC;EAAf,CAAf,CADG,GAErB,KAAK,CAAC,MAAN,IAAgB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,MAAP,EAAa,EAAA,GAAK,SAAS,CAAC;EAAf,CAAb,CAFpB;EAIA,OACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,CAAC,YAAY,KAAK,OAAjB,IAA4B,YAAY,KAAK,OAA9C,KAA0D,IAD7D,EAEG,KAAK,CAAC,WAAN,IAAqB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,WAAP,EAAkB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAlB,CAFxB,EAGG,KAAK,CAAC,aAAN,IAAuB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,aAAP,EAAoB,EAAA,GAAK,SAAS,CAAC;EAAf,CAApB,CAH1B,EAIG,KAAK,CAAC,YAAN,IAAsB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,YAAP,EAAmB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAnB,CAJzB,EAKG,KAAK,CAAC,cAAN,IAAwB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,cAAP,EAAqB,EAAA,GAAK,SAAS,CAAC;EAAf,CAArB,CAL3B,EAMG,YAAY,KAAK,QAAjB,IAA6B,IANhC,CADF;AAUD,CAlBM;;AAAM,OAAA,CAAA,sBAAA,GAAsB,sBAAtB","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { PersonaState, PersonaSlots } from './Persona.types';\n\n/**\n * Render the final JSX of Persona\n */\nexport const renderPersona_unstable = (state: PersonaState) => {\n const { presenceOnly, textPosition } = state;\n const { slots, slotProps } = getSlots<PersonaSlots>(state);\n\n const coin = presenceOnly\n ? slots.presence && <slots.presence {...slotProps.presence} />\n : slots.avatar && <slots.avatar {...slotProps.avatar} />;\n\n return (\n <slots.root {...slotProps.root}>\n {(textPosition === 'after' || textPosition === 'below') && coin}\n {slots.primaryText && <slots.primaryText {...slotProps.primaryText} />}\n {slots.secondaryText && <slots.secondaryText {...slotProps.secondaryText} />}\n {slots.tertiaryText && <slots.tertiaryText {...slotProps.tertiaryText} />}\n {slots.quaternaryText && <slots.quaternaryText {...slotProps.quaternaryText} />}\n {textPosition === 'before' && coin}\n </slots.root>\n );\n};\n"],"sourceRoot":""}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.usePersona_unstable = void 0;
7
+
8
+ const react_avatar_1 = /*#__PURE__*/require("@fluentui/react-avatar");
9
+
10
+ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
+
12
+ const react_badge_1 = /*#__PURE__*/require("@fluentui/react-badge");
13
+ /**
14
+ * Create the state required to render Persona.
15
+ *
16
+ * The returned state can be modified with hooks such as usePersonaStyles_unstable,
17
+ * before being passed to renderPersona_unstable.
18
+ *
19
+ * @param props - props from this instance of Persona
20
+ * @param ref - reference to root HTMLElement of Persona
21
+ */
22
+
23
+
24
+ const usePersona_unstable = (props, ref) => {
25
+ const {
26
+ presenceOnly = false,
27
+ textPosition = 'after',
28
+ name
29
+ } = props;
30
+ const primaryText = react_utilities_1.resolveShorthand(props.primaryText, {
31
+ required: true,
32
+ defaultProps: {
33
+ children: name
34
+ }
35
+ });
36
+ const secondaryText = react_utilities_1.resolveShorthand(props.secondaryText);
37
+ const tertiaryText = react_utilities_1.resolveShorthand(props.tertiaryText);
38
+ const quaternaryText = react_utilities_1.resolveShorthand(props.quaternaryText);
39
+ const numTextLines = [primaryText, secondaryText, tertiaryText, quaternaryText].filter(Boolean).length;
40
+ let fixed = false;
41
+
42
+ if (!presenceOnly && props.avatar) {
43
+ fixed = !!props.avatar.size;
44
+ } else if (props.presence && props.presence) {
45
+ fixed = !!props.presence.size;
46
+ }
47
+
48
+ let avatarSize = undefined;
49
+ let presenceSize = undefined;
50
+
51
+ if (presenceOnly && !fixed) {
52
+ if (numTextLines === 1) {
53
+ presenceSize = 'small';
54
+ } else if (numTextLines === 2) {
55
+ presenceSize = 'large';
56
+ } else {
57
+ presenceSize = 'extra-large';
58
+ }
59
+ } else if (!fixed) {
60
+ if (numTextLines === 1) {
61
+ avatarSize = 16;
62
+ } else if (numTextLines === 2) {
63
+ avatarSize = 32;
64
+ } else if (numTextLines === 3) {
65
+ avatarSize = 56;
66
+ } else {
67
+ avatarSize = 72;
68
+ }
69
+ }
70
+
71
+ const avatar = !presenceOnly ? react_utilities_1.resolveShorthand(props.avatar, {
72
+ required: true,
73
+ defaultProps: {
74
+ name,
75
+ badge: props.presence,
76
+ size: avatarSize
77
+ }
78
+ }) : undefined;
79
+ const presence = presenceOnly ? react_utilities_1.resolveShorthand(props.presence, {
80
+ defaultProps: {
81
+ size: presenceSize
82
+ }
83
+ }) : undefined;
84
+ return {
85
+ fixed,
86
+ numTextLines,
87
+ presenceOnly,
88
+ textPosition,
89
+ components: {
90
+ root: 'div',
91
+ avatar: react_avatar_1.Avatar,
92
+ presence: react_badge_1.PresenceBadge,
93
+ primaryText: 'span',
94
+ secondaryText: 'span',
95
+ tertiaryText: 'span',
96
+ quaternaryText: 'span'
97
+ },
98
+ root: react_utilities_1.getNativeElementProps('div', { ...props,
99
+ ref
100
+ },
101
+ /* excludedPropNames */
102
+ ['name']),
103
+ avatar,
104
+ presence,
105
+ primaryText,
106
+ secondaryText,
107
+ tertiaryText,
108
+ quaternaryText
109
+ };
110
+ };
111
+
112
+ exports.usePersona_unstable = usePersona_unstable;
113
+ //# sourceMappingURL=usePersona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/Persona/usePersona.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;AAKA;;;;;;;;AAQG;;;AACI,MAAM,mBAAmB,GAAG,CAAC,KAAD,EAAsB,GAAtB,KAAmE;EACpG,MAAM;IAAE,YAAY,GAAG,KAAjB;IAAwB,YAAY,GAAG,OAAvC;IAAgD;EAAhD,IAAyD,KAA/D;EAEA,MAAM,WAAW,GAAG,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,WAAvB,EAAoC;IACtD,QAAQ,EAAE,IAD4C;IAEtD,YAAY,EAAE;MACZ,QAAQ,EAAE;IADE;EAFwC,CAApC,CAApB;EAMA,MAAM,aAAa,GAAG,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,aAAvB,CAAtB;EACA,MAAM,YAAY,GAAG,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,YAAvB,CAArB;EACA,MAAM,cAAc,GAAG,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,cAAvB,CAAvB;EAEA,MAAM,YAAY,GAAG,CAAC,WAAD,EAAc,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YAAY,GACnD,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,QAAvB,EAAiC;IAC/B,YAAY,EAAE;MACZ,IAAI,EAAE;IADM;EADiB,CAAjC,CADmD,GAMnD,SANJ;EAQA,OAAO;IACL,KADK;IAEL,YAFK;IAGL,YAHK;IAIL,YAJK;IAML,UAAU,EAAE;MACV,IAAI,EAAE,KADI;MAEV,MAAM,EAAE,cAAA,CAAA,MAFE;MAGV,QAAQ,EAAE,aAAA,CAAA,aAHA;MAIV,WAAW,EAAE,MAJH;MAKV,aAAa,EAAE,MALL;MAMV,YAAY,EAAE,MANJ;MAOV,cAAc,EAAE;IAPN,CANP;IAgBL,IAAI,EAAE,iBAAA,CAAA,qBAAA,CACJ,KADI,EAEJ,EACE,GAAG,KADL;MAEE;IAFF,CAFI;IAMJ;IAAwB,CAAC,MAAD,CANpB,CAhBD;IAwBL,MAxBK;IAyBL,QAzBK;IA0BL,WA1BK;IA2BL,aA3BK;IA4BL,YA5BK;IA6BL;EA7BK,CAAP;AA+BD,CA9FM;;AAAM,OAAA,CAAA,mBAAA,GAAmB,mBAAnB","sourcesContent":["import * as React from 'react';\nimport { Avatar } from '@fluentui/react-avatar';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport type { AvatarProps } from '@fluentui/react-avatar';\nimport type { PersonaProps, PersonaState } from './Persona.types';\nimport type { PresenceBadgeProps } from '@fluentui/react-badge';\n\n/**\n * Create the state required to render Persona.\n *\n * The returned state can be modified with hooks such as usePersonaStyles_unstable,\n * before being passed to renderPersona_unstable.\n *\n * @param props - props from this instance of Persona\n * @param ref - reference to root HTMLElement of Persona\n */\nexport const usePersona_unstable = (props: PersonaProps, ref: React.Ref<HTMLElement>): PersonaState => {\n const { presenceOnly = false, textPosition = 'after', name } = props;\n\n const primaryText = resolveShorthand(props.primaryText, {\n required: true,\n defaultProps: {\n children: name,\n },\n });\n const secondaryText = resolveShorthand(props.secondaryText);\n const tertiaryText = resolveShorthand(props.tertiaryText);\n const quaternaryText = resolveShorthand(props.quaternaryText);\n\n const numTextLines = [primaryText, secondaryText, tertiaryText, quaternaryText].filter(Boolean).length;\n\n let fixed = false;\n if (!presenceOnly && props.avatar) {\n fixed = !!(props.avatar as AvatarProps).size;\n } else if (props.presence && props.presence) {\n fixed = !!(props.presence as PresenceBadgeProps).size;\n }\n\n let avatarSize: AvatarProps['size'] = undefined;\n let presenceSize: PresenceBadgeProps['size'] = undefined;\n if (presenceOnly && !fixed) {\n if (numTextLines === 1) {\n presenceSize = 'small';\n } else if (numTextLines === 2) {\n presenceSize = 'large';\n } else {\n presenceSize = 'extra-large';\n }\n } else if (!fixed) {\n if (numTextLines === 1) {\n avatarSize = 16;\n } else if (numTextLines === 2) {\n avatarSize = 32;\n } else if (numTextLines === 3) {\n avatarSize = 56;\n } else {\n avatarSize = 72;\n }\n }\n\n const avatar: PersonaState['avatar'] = !presenceOnly\n ? resolveShorthand(props.avatar, {\n required: true,\n defaultProps: {\n name,\n badge: props.presence,\n size: avatarSize,\n },\n })\n : undefined;\n\n const presence: PersonaState['presence'] = presenceOnly\n ? resolveShorthand(props.presence, {\n defaultProps: {\n size: presenceSize,\n },\n })\n : undefined;\n\n return {\n fixed,\n numTextLines,\n presenceOnly,\n textPosition,\n\n components: {\n root: 'div',\n avatar: Avatar,\n presence: PresenceBadge,\n primaryText: 'span',\n secondaryText: 'span',\n tertiaryText: 'span',\n quaternaryText: 'span',\n },\n\n root: getNativeElementProps(\n 'div',\n {\n ...props,\n ref,\n },\n /* excludedPropNames */ ['name'],\n ),\n avatar,\n presence,\n primaryText,\n secondaryText,\n tertiaryText,\n quaternaryText,\n };\n};\n"],"sourceRoot":""}