@fluentui/react-persona 9.1.0-beta.3 → 9.1.0-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +87 -1
- package/CHANGELOG.md +28 -2
- package/dist/index.d.ts +16 -8
- package/lib/Persona.js.map +1 -1
- package/lib/components/Persona/Persona.js.map +1 -1
- package/lib/components/Persona/Persona.types.js.map +1 -1
- package/lib/components/Persona/index.js.map +1 -1
- package/lib/components/Persona/renderPersona.js.map +1 -1
- package/lib/components/Persona/usePersona.js +35 -49
- package/lib/components/Persona/usePersona.js.map +1 -1
- package/lib/components/Persona/usePersonaStyles.js +104 -85
- package/lib/components/Persona/usePersonaStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Persona.js.map +1 -1
- package/lib-commonjs/components/Persona/Persona.js.map +1 -1
- package/lib-commonjs/components/Persona/index.js.map +1 -1
- package/lib-commonjs/components/Persona/renderPersona.js.map +1 -1
- package/lib-commonjs/components/Persona/usePersona.js +35 -49
- package/lib-commonjs/components/Persona/usePersona.js.map +1 -1
- package/lib-commonjs/components/Persona/usePersonaStyles.js +104 -85
- package/lib-commonjs/components/Persona/usePersonaStyles.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +7 -8
- package/MIGRATION.md +0 -44
- package/Spec.md +0 -213
@@ -9,25 +9,25 @@ export const personaClassNames = {
|
|
9
9
|
tertiaryText: 'fui-Persona__tertiaryText',
|
10
10
|
quaternaryText: 'fui-Persona__quaternaryText'
|
11
11
|
};
|
12
|
+
const avatarSpacing = `--fui-Persona__avatar--spacing`;
|
12
13
|
/**
|
13
14
|
* Styles for the root slot
|
14
15
|
*/
|
15
16
|
|
16
17
|
const useStyles = /*#__PURE__*/__styles({
|
17
|
-
"
|
18
|
+
"base": {
|
18
19
|
"mc9l5x": "fwk3njj",
|
19
|
-
"t4k1zu": "f4wu0r3",
|
20
20
|
"v29qe6": "fvtn1bl"
|
21
21
|
},
|
22
22
|
"after": {
|
23
23
|
"Bxotwcr": "f1u07yai",
|
24
24
|
"B7hvi0a": "f1m2n5bn",
|
25
|
-
"
|
25
|
+
"Budl1dq": "f1c1ms5d"
|
26
26
|
},
|
27
27
|
"before": {
|
28
28
|
"Bxotwcr": "f1u07yai",
|
29
29
|
"B7hvi0a": "f1tll2w5",
|
30
|
-
"
|
30
|
+
"Budl1dq": "ffvkwdr"
|
31
31
|
},
|
32
32
|
"below": {
|
33
33
|
"B7hvi0a": "f1oiokrs"
|
@@ -35,14 +35,64 @@ const useStyles = /*#__PURE__*/__styles({
|
|
35
35
|
"coin": {
|
36
36
|
"Ijaq50": "f1hek2iy"
|
37
37
|
},
|
38
|
-
"
|
38
|
+
"start": {
|
39
39
|
"qb2dma": "f9h729m"
|
40
40
|
},
|
41
|
-
"
|
41
|
+
"center": {
|
42
42
|
"qb2dma": "f7nlbp4"
|
43
|
+
},
|
44
|
+
"afterAlignToPrimary": {
|
45
|
+
"qb2dma": "f7nlbp4",
|
46
|
+
"Ijaq50": "f1rnkkuc",
|
47
|
+
"Bw0ie65": "f1warjpf"
|
48
|
+
},
|
49
|
+
"beforeAlignToPrimary": {
|
50
|
+
"qb2dma": "f7nlbp4",
|
51
|
+
"Ijaq50": "f1rnkkuc",
|
52
|
+
"Br312pm": "fwu52yu"
|
43
53
|
}
|
44
54
|
}, {
|
45
|
-
"d": [".fwk3njj{display:inline-grid;}", ".
|
55
|
+
"d": [".fwk3njj{display:inline-grid;}", ".fvtn1bl{grid-auto-rows:max-content;}", ".f1u07yai{grid-auto-flow:column;}", ".f1m2n5bn{justify-items:start;}", ".f1c1ms5d{grid-template-columns:max-content [middle] auto;}", ".f1tll2w5{justify-items:end;}", ".ffvkwdr{grid-template-columns:auto [middle] max-content;}", ".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;}", ".f1rnkkuc{grid-row-start:unset;}", ".f1warjpf{grid-column-end:middle;}", ".fwu52yu{grid-column-start:middle;}"]
|
56
|
+
});
|
57
|
+
|
58
|
+
const useAvatarSpacingStyles = /*#__PURE__*/__styles({
|
59
|
+
"extra-small": {
|
60
|
+
"Bs1gm4r": "f1e48tse"
|
61
|
+
},
|
62
|
+
"small": {
|
63
|
+
"Bs1gm4r": "f18q9vkd"
|
64
|
+
},
|
65
|
+
"medium": {
|
66
|
+
"Bs1gm4r": "f18q9vkd"
|
67
|
+
},
|
68
|
+
"large": {
|
69
|
+
"Bs1gm4r": "fx34bi6"
|
70
|
+
},
|
71
|
+
"extra-large": {
|
72
|
+
"Bs1gm4r": "fx34bi6"
|
73
|
+
},
|
74
|
+
"huge": {
|
75
|
+
"Bs1gm4r": "f1o96qtm"
|
76
|
+
},
|
77
|
+
"after": {
|
78
|
+
"t21cq0": ["f103ycu4", "f1tao51"]
|
79
|
+
},
|
80
|
+
"below": {
|
81
|
+
"jrapky": "fbo7acy"
|
82
|
+
},
|
83
|
+
"before": {
|
84
|
+
"Frg6f3": ["f1tao51", "f103ycu4"]
|
85
|
+
}
|
86
|
+
}, {
|
87
|
+
"d": [".f1e48tse{--fui-Persona__avatar--spacing:var(--spacingHorizontalSNudge);}", ".f18q9vkd{--fui-Persona__avatar--spacing:var(--spacingHorizontalS);}", ".fx34bi6{--fui-Persona__avatar--spacing:var(--spacingHorizontalMNudge);}", ".f1o96qtm{--fui-Persona__avatar--spacing:var(--spacingHorizontalM);}", ".f103ycu4{margin-right:var(--fui-Persona__avatar--spacing);}", ".f1tao51{margin-left:var(--fui-Persona__avatar--spacing);}", ".fbo7acy{margin-bottom:var(--fui-Persona__avatar--spacing);}"]
|
88
|
+
});
|
89
|
+
|
90
|
+
const usePresenceSpacingStyles = /*#__PURE__*/__styles({
|
91
|
+
"small": {
|
92
|
+
"Bs1gm4r": "f1e48tse"
|
93
|
+
}
|
94
|
+
}, {
|
95
|
+
"d": [".f1e48tse{--fui-Persona__avatar--spacing:var(--spacingHorizontalSNudge);}"]
|
46
96
|
});
|
47
97
|
/**
|
48
98
|
* Apply styling to the Persona slots based on the state
|
@@ -51,22 +101,29 @@ const useStyles = /*#__PURE__*/__styles({
|
|
51
101
|
|
52
102
|
export const usePersonaStyles_unstable = state => {
|
53
103
|
const {
|
54
|
-
|
104
|
+
presenceOnly,
|
105
|
+
size,
|
106
|
+
textAlignment,
|
55
107
|
textPosition
|
56
108
|
} = state;
|
57
|
-
const
|
109
|
+
const alignToPrimary = presenceOnly && textAlignment === 'start' && size !== 'extra-large' && size !== 'huge';
|
58
110
|
const {
|
59
111
|
primaryTextClassName,
|
60
112
|
optionalTextClassName
|
61
|
-
} = useTextClassNames(state);
|
62
|
-
|
113
|
+
} = useTextClassNames(state, alignToPrimary);
|
114
|
+
const styles = useStyles();
|
115
|
+
const avatarSpacingStyles = useAvatarSpacingStyles();
|
116
|
+
const presenceSpacingStyles = { ...avatarSpacingStyles,
|
117
|
+
...usePresenceSpacingStyles()
|
118
|
+
};
|
119
|
+
state.root.className = mergeClasses(personaClassNames.root, styles.base, styles[textPosition], state.root.className);
|
63
120
|
|
64
121
|
if (state.avatar) {
|
65
|
-
state.avatar.className = mergeClasses(personaClassNames.avatar, styles.coin,
|
122
|
+
state.avatar.className = mergeClasses(personaClassNames.avatar, styles.coin, styles[textAlignment], avatarSpacingStyles[size], avatarSpacingStyles[textPosition], state.avatar.className);
|
66
123
|
}
|
67
124
|
|
68
125
|
if (state.presence) {
|
69
|
-
state.presence.className = mergeClasses(personaClassNames.presence, styles.coin,
|
126
|
+
state.presence.className = mergeClasses(personaClassNames.presence, styles.coin, styles[textAlignment], presenceSpacingStyles[size], presenceSpacingStyles[textPosition], textPosition === 'after' && alignToPrimary && styles.afterAlignToPrimary, textPosition === 'before' && alignToPrimary && styles.beforeAlignToPrimary, state.presence.className);
|
70
127
|
}
|
71
128
|
|
72
129
|
if (state.primaryText) {
|
@@ -98,6 +155,12 @@ const useTextStyles = /*#__PURE__*/__styles({
|
|
98
155
|
"optionalText": {
|
99
156
|
"sj55zd": "fkfq4zb"
|
100
157
|
},
|
158
|
+
"beforeAlignToPrimary": {
|
159
|
+
"Bw0ie65": "f1warjpf"
|
160
|
+
},
|
161
|
+
"afterAlignToPrimary": {
|
162
|
+
"Br312pm": "fwu52yu"
|
163
|
+
},
|
101
164
|
"body1": {
|
102
165
|
"Bahqtrf": "fk6fouc",
|
103
166
|
"Be2twd7": "fkhj508",
|
@@ -115,94 +178,50 @@ const useTextStyles = /*#__PURE__*/__styles({
|
|
115
178
|
"Be2twd7": "fod5ikn",
|
116
179
|
"Bhrd7zp": "fl43uef",
|
117
180
|
"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
181
|
}
|
137
182
|
}, {
|
138
|
-
"d": [".ftgm304{display:block;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".fkfq4zb{color:var(--colorNeutralForeground2);}", ".
|
183
|
+
"d": [".ftgm304{display:block;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".fkfq4zb{color:var(--colorNeutralForeground2);}", ".f1warjpf{grid-column-end:middle;}", ".fwu52yu{grid-column-start:middle;}", ".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);}"]
|
139
184
|
});
|
140
185
|
|
141
|
-
const useTextClassNames = state => {
|
186
|
+
const useTextClassNames = (state, alignToPrimary) => {
|
142
187
|
const {
|
143
|
-
|
144
|
-
|
145
|
-
|
188
|
+
presenceOnly,
|
189
|
+
size,
|
190
|
+
textPosition
|
146
191
|
} = state;
|
147
192
|
const textStyles = useTextStyles();
|
148
193
|
let primaryTextSize;
|
149
|
-
let
|
150
|
-
|
151
|
-
if (
|
152
|
-
if (
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
} else if (
|
164
|
-
|
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;
|
194
|
+
let alignToPrimaryClassName;
|
195
|
+
|
196
|
+
if (presenceOnly) {
|
197
|
+
if (size === 'extra-small') {
|
198
|
+
primaryTextSize = state.numTextLines > 1 ? textStyles.body1 : textStyles.caption1;
|
199
|
+
} else if (size === 'extra-large' || size === 'huge') {
|
200
|
+
primaryTextSize = textStyles.subtitle2;
|
201
|
+
} else {
|
202
|
+
primaryTextSize = textStyles.body1;
|
203
|
+
}
|
204
|
+
|
205
|
+
if (alignToPrimary) {
|
206
|
+
if (textPosition === 'before') {
|
207
|
+
alignToPrimaryClassName = textStyles.beforeAlignToPrimary;
|
208
|
+
} else if (textPosition === 'after') {
|
209
|
+
alignToPrimaryClassName = textStyles.afterAlignToPrimary;
|
191
210
|
}
|
192
211
|
}
|
193
212
|
} else {
|
194
|
-
if (
|
195
|
-
primaryTextSize = textStyles.
|
213
|
+
if (size === 'huge') {
|
214
|
+
primaryTextSize = textStyles.subtitle2;
|
215
|
+
} else if (size === 'extra-large') {
|
216
|
+
primaryTextSize = textStyles.subtitle2;
|
196
217
|
} else {
|
197
|
-
primaryTextSize = textStyles.
|
218
|
+
primaryTextSize = textStyles.body1;
|
198
219
|
}
|
199
|
-
|
200
|
-
optionalTextSize = textStyles.caption1;
|
201
220
|
}
|
202
221
|
|
203
222
|
return {
|
204
|
-
primaryTextClassName: mergeClasses(textStyles.base, textStyles.primaryText, primaryTextSize),
|
205
|
-
optionalTextClassName: mergeClasses(textStyles.base, textStyles.optionalText,
|
223
|
+
primaryTextClassName: mergeClasses(textStyles.base, textStyles.primaryText, primaryTextSize, alignToPrimaryClassName),
|
224
|
+
optionalTextClassName: mergeClasses(textStyles.base, textStyles.optionalText, !presenceOnly && size === 'huge' ? textStyles.body1 : textStyles.caption1, alignToPrimaryClassName)
|
206
225
|
};
|
207
226
|
};
|
208
227
|
//# sourceMappingURL=usePersonaStyles.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/Persona/usePersonaStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,QAAyC,gBAAzC;AACA,SAAS,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AgB,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":"../src/"}
|
1
|
+
{"version":3,"sources":["packages/react-components/react-persona/src/components/Persona/usePersonaStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,QAAyC,gBAAzC;AACA,SAAS,MAAT,EAAiB,gBAAjB,QAAyC,uBAAzC;AAIA,OAAO,MAAM,iBAAiB,GAAiC;EAC7D,IAAI,EAAE,aADuD;EAE7D,MAAM,EAAE,qBAFqD;EAG7D,QAAQ,EAAE,uBAHmD;EAI7D,WAAW,EAAE,0BAJgD;EAK7D,aAAa,EAAE,4BAL8C;EAM7D,YAAY,EAAE,2BAN+C;EAO7D,cAAc,EAAE;AAP6C,CAAxD;AAUP,MAAM,aAAa,GAAG,gCAAtB;AAEA;;AAEG;;AACH,MAAM,SAAS,gBAAG;EAA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;IACL,IAAI,IAAI,KAAK,MAAb,EAAqB;MACnB,eAAe,GAAG,UAAU,CAAC,SAA7B;IACD,CAFD,MAEO,IAAI,IAAI,KAAK,aAAb,EAA4B;MACjC,eAAe,GAAG,UAAU,CAAC,SAA7B;IACD,CAFM,MAEA;MACL,eAAe,GAAG,UAAU,CAAC,KAA7B;IACD;EACF;;EAED,OAAO;IACL,oBAAoB,EAAE,YAAY,CAChC,UAAU,CAAC,IADqB,EAEhC,UAAU,CAAC,WAFqB,EAGhC,eAHgC,EAIhC,uBAJgC,CAD7B;IAOL,qBAAqB,EAAE,YAAY,CACjC,UAAU,CAAC,IADsB,EAEjC,UAAU,CAAC,YAFsB,EAGjC,CAAC,YAAD,IAAiB,IAAI,KAAK,MAA1B,GAAmC,UAAU,CAAC,KAA9C,GAAsD,UAAU,CAAC,QAHhC,EAIjC,uBAJiC;EAP9B,CAAP;AAcD,CArDD","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\nconst avatarSpacing = `--fui-Persona__avatar--spacing`;\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n base: {\n display: 'inline-grid',\n gridAutoRows: 'max-content',\n },\n\n after: {\n gridAutoFlow: 'column',\n justifyItems: 'start',\n gridTemplateColumns: 'max-content [middle] auto',\n },\n before: {\n gridAutoFlow: 'column',\n justifyItems: 'end',\n gridTemplateColumns: 'auto [middle] max-content',\n },\n below: {\n justifyItems: 'center',\n },\n coin: {\n gridRowStart: 'span 5',\n },\n\n start: {\n alignSelf: 'start',\n },\n center: {\n alignSelf: 'center',\n },\n\n afterAlignToPrimary: {\n alignSelf: 'center',\n gridRowStart: 'unset',\n gridColumnEnd: 'middle',\n },\n beforeAlignToPrimary: {\n alignSelf: 'center',\n gridRowStart: 'unset',\n gridColumnStart: 'middle',\n },\n});\n\nconst useAvatarSpacingStyles = makeStyles({\n 'extra-small': {\n [avatarSpacing]: tokens.spacingHorizontalSNudge,\n },\n small: {\n [avatarSpacing]: tokens.spacingHorizontalS,\n },\n medium: {\n [avatarSpacing]: tokens.spacingHorizontalS,\n },\n large: {\n [avatarSpacing]: tokens.spacingHorizontalMNudge,\n },\n 'extra-large': {\n [avatarSpacing]: tokens.spacingHorizontalMNudge,\n },\n huge: {\n [avatarSpacing]: tokens.spacingHorizontalM,\n },\n after: {\n marginRight: `var(${avatarSpacing})`,\n },\n below: {\n marginBottom: `var(${avatarSpacing})`,\n },\n before: {\n marginLeft: `var(${avatarSpacing})`,\n },\n});\n\nconst usePresenceSpacingStyles = makeStyles({\n small: {\n [avatarSpacing]: tokens.spacingHorizontalSNudge,\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 { presenceOnly, size, textAlignment, textPosition } = state;\n\n const alignToPrimary = presenceOnly && textAlignment === 'start' && size !== 'extra-large' && size !== 'huge';\n const { primaryTextClassName, optionalTextClassName } = useTextClassNames(state, alignToPrimary);\n\n const styles = useStyles();\n const avatarSpacingStyles = useAvatarSpacingStyles();\n const presenceSpacingStyles = { ...avatarSpacingStyles, ...usePresenceSpacingStyles() };\n\n state.root.className = mergeClasses(personaClassNames.root, styles.base, styles[textPosition], state.root.className);\n\n if (state.avatar) {\n state.avatar.className = mergeClasses(\n personaClassNames.avatar,\n styles.coin,\n styles[textAlignment],\n avatarSpacingStyles[size],\n avatarSpacingStyles[textPosition],\n state.avatar.className,\n );\n }\n\n if (state.presence) {\n state.presence.className = mergeClasses(\n personaClassNames.presence,\n styles.coin,\n styles[textAlignment],\n presenceSpacingStyles[size],\n presenceSpacingStyles[textPosition],\n textPosition === 'after' && alignToPrimary && styles.afterAlignToPrimary,\n textPosition === 'before' && alignToPrimary && styles.beforeAlignToPrimary,\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 beforeAlignToPrimary: {\n gridColumnEnd: 'middle',\n },\n afterAlignToPrimary: {\n gridColumnStart: 'middle',\n },\n\n body1: typographyStyles.body1,\n caption1: typographyStyles.caption1,\n subtitle2: typographyStyles.subtitle2,\n});\n\nconst useTextClassNames = (\n state: PersonaState,\n alignToPrimary: boolean,\n): {\n primaryTextClassName: string;\n optionalTextClassName: string;\n} => {\n const { presenceOnly, size, textPosition } = state;\n const textStyles = useTextStyles();\n\n let primaryTextSize;\n let alignToPrimaryClassName;\n\n if (presenceOnly) {\n if (size === 'extra-small') {\n primaryTextSize = state.numTextLines > 1 ? textStyles.body1 : textStyles.caption1;\n } else if (size === 'extra-large' || size === 'huge') {\n primaryTextSize = textStyles.subtitle2;\n } else {\n primaryTextSize = textStyles.body1;\n }\n\n if (alignToPrimary) {\n if (textPosition === 'before') {\n alignToPrimaryClassName = textStyles.beforeAlignToPrimary;\n } else if (textPosition === 'after') {\n alignToPrimaryClassName = textStyles.afterAlignToPrimary;\n }\n }\n } else {\n if (size === 'huge') {\n primaryTextSize = textStyles.subtitle2;\n } else if (size === 'extra-large') {\n primaryTextSize = textStyles.subtitle2;\n } else {\n primaryTextSize = textStyles.body1;\n }\n }\n\n return {\n primaryTextClassName: mergeClasses(\n textStyles.base,\n textStyles.primaryText,\n primaryTextSize,\n alignToPrimaryClassName,\n ),\n optionalTextClassName: mergeClasses(\n textStyles.base,\n textStyles.optionalText,\n !presenceOnly && size === 'huge' ? textStyles.body1 : textStyles.caption1,\n alignToPrimaryClassName,\n ),\n };\n};\n"],"sourceRoot":"../src/"}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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":"../src/"}
|
1
|
+
{"version":3,"sources":["packages/react-components/react-persona/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":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Persona.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Persona/index';\n"],"sourceRoot":"../src/"}
|
1
|
+
{"version":3,"sources":["packages/react-components/react-persona/src/Persona.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Persona/index';\n"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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":"../src/"}
|
1
|
+
{"version":3,"sources":["packages/react-components/react-persona/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":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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":"../src/"}
|
1
|
+
{"version":3,"sources":["packages/react-components/react-persona/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":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["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":"../src/"}
|
1
|
+
{"version":3,"sources":["packages/react-components/react-persona/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":"../src/"}
|
@@ -23,9 +23,11 @@ const react_badge_1 = /*#__PURE__*/require("@fluentui/react-badge");
|
|
23
23
|
|
24
24
|
const usePersona_unstable = (props, ref) => {
|
25
25
|
const {
|
26
|
+
name,
|
26
27
|
presenceOnly = false,
|
27
|
-
|
28
|
-
|
28
|
+
size = 'medium',
|
29
|
+
textAlignment = 'start',
|
30
|
+
textPosition = 'after'
|
29
31
|
} = props;
|
30
32
|
const primaryText = react_utilities_1.resolveShorthand(props.primaryText, {
|
31
33
|
required: true,
|
@@ -37,54 +39,11 @@ const usePersona_unstable = (props, ref) => {
|
|
37
39
|
const tertiaryText = react_utilities_1.resolveShorthand(props.tertiaryText);
|
38
40
|
const quaternaryText = react_utilities_1.resolveShorthand(props.quaternaryText);
|
39
41
|
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
42
|
return {
|
85
|
-
fixed,
|
86
43
|
numTextLines,
|
87
44
|
presenceOnly,
|
45
|
+
size,
|
46
|
+
textAlignment,
|
88
47
|
textPosition,
|
89
48
|
components: {
|
90
49
|
root: 'div',
|
@@ -100,8 +59,19 @@ const usePersona_unstable = (props, ref) => {
|
|
100
59
|
},
|
101
60
|
/* excludedPropNames */
|
102
61
|
['name']),
|
103
|
-
avatar,
|
104
|
-
|
62
|
+
avatar: !presenceOnly ? react_utilities_1.resolveShorthand(props.avatar, {
|
63
|
+
required: true,
|
64
|
+
defaultProps: {
|
65
|
+
name,
|
66
|
+
badge: props.presence,
|
67
|
+
size: avatarSizes[size]
|
68
|
+
}
|
69
|
+
}) : undefined,
|
70
|
+
presence: presenceOnly ? react_utilities_1.resolveShorthand(props.presence, {
|
71
|
+
defaultProps: {
|
72
|
+
size: presenceSizes[size]
|
73
|
+
}
|
74
|
+
}) : undefined,
|
105
75
|
primaryText,
|
106
76
|
secondaryText,
|
107
77
|
tertiaryText,
|
@@ -110,4 +80,20 @@ const usePersona_unstable = (props, ref) => {
|
|
110
80
|
};
|
111
81
|
|
112
82
|
exports.usePersona_unstable = usePersona_unstable;
|
83
|
+
const presenceSizes = {
|
84
|
+
'extra-small': 'tiny',
|
85
|
+
small: 'extra-small',
|
86
|
+
medium: 'small',
|
87
|
+
large: 'medium',
|
88
|
+
'extra-large': 'large',
|
89
|
+
huge: 'large'
|
90
|
+
};
|
91
|
+
const avatarSizes = {
|
92
|
+
'extra-small': 20,
|
93
|
+
small: 28,
|
94
|
+
medium: 32,
|
95
|
+
large: 36,
|
96
|
+
'extra-large': 40,
|
97
|
+
huge: 56
|
98
|
+
};
|
113
99
|
//# sourceMappingURL=usePersona.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["components/Persona/usePersona.ts"],"names":[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react';\nimport { Avatar } from '@fluentui/react-avatar';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport type { PersonaProps, PersonaState } from './Persona.types';\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 { name, presenceOnly = false, size = 'medium', textAlignment = 'start', textPosition = 'after' } = 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 return {\n numTextLines,\n presenceOnly,\n size,\n textAlignment,\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: !presenceOnly\n ? resolveShorthand(props.avatar, {\n required: true,\n defaultProps: {\n name,\n badge: props.presence,\n size: avatarSizes[size],\n },\n })\n : undefined,\n presence: presenceOnly\n ? resolveShorthand(props.presence, {\n defaultProps: {\n size: presenceSizes[size],\n },\n })\n : undefined,\n primaryText,\n secondaryText,\n tertiaryText,\n quaternaryText,\n };\n};\n\nconst presenceSizes = {\n 'extra-small': 'tiny',\n small: 'extra-small',\n medium: 'small',\n large: 'medium',\n 'extra-large': 'large',\n huge: 'large',\n} as const;\n\nconst avatarSizes = {\n 'extra-small': 20,\n small: 28,\n medium: 32,\n large: 36,\n 'extra-large': 40,\n huge: 56,\n} as const;\n"],"sourceRoot":"../src/"}
|