@fluentui/react-persona 9.1.0-beta.7 → 9.1.1
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 +26 -2
- package/README.md +0 -10
- package/lib/components/Persona/Persona.js +0 -1
- package/lib/components/Persona/Persona.js.map +1 -1
- package/lib/components/Persona/renderPersona.js +14 -8
- package/lib/components/Persona/renderPersona.js.map +1 -1
- package/lib/components/Persona/usePersona.js +3 -5
- package/lib/components/Persona/usePersona.js.map +1 -1
- package/lib/components/Persona/usePersonaStyles.js +83 -99
- package/lib/components/Persona/usePersonaStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-amd/Persona.js +6 -0
- package/lib-amd/Persona.js.map +1 -0
- package/lib-amd/components/Persona/Persona.js +16 -0
- package/lib-amd/components/Persona/Persona.js.map +1 -0
- package/lib-amd/components/Persona/Persona.types.js +5 -0
- package/lib-amd/components/Persona/Persona.types.js.map +1 -0
- package/lib-amd/components/Persona/index.js +10 -0
- package/lib-amd/components/Persona/index.js.map +1 -0
- package/lib-amd/components/Persona/renderPersona.js +24 -0
- package/lib-amd/components/Persona/renderPersona.js.map +1 -0
- package/lib-amd/components/Persona/usePersona.js +84 -0
- package/lib-amd/components/Persona/usePersona.js.map +1 -0
- package/lib-amd/components/Persona/usePersonaStyles.js +184 -0
- package/lib-amd/components/Persona/usePersonaStyles.js.map +1 -0
- package/lib-amd/index.js +11 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-commonjs/Persona.js +0 -2
- package/lib-commonjs/Persona.js.map +1 -1
- package/lib-commonjs/components/Persona/Persona.js +0 -6
- package/lib-commonjs/components/Persona/Persona.js.map +1 -1
- package/lib-commonjs/components/Persona/Persona.types.js.map +1 -1
- package/lib-commonjs/components/Persona/index.js +0 -6
- package/lib-commonjs/components/Persona/index.js.map +1 -1
- package/lib-commonjs/components/Persona/renderPersona.js +14 -12
- package/lib-commonjs/components/Persona/renderPersona.js.map +1 -1
- package/lib-commonjs/components/Persona/usePersona.js +3 -10
- package/lib-commonjs/components/Persona/usePersona.js.map +1 -1
- package/lib-commonjs/components/Persona/usePersonaStyles.js +83 -103
- package/lib-commonjs/components/Persona/usePersonaStyles.js.map +1 -1
- package/lib-commonjs/index.js +0 -2
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +8 -10
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,93 @@
|
|
2
2
|
"name": "@fluentui/react-persona",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Mon, 09 Jan 2023 14:31:49 GMT",
|
6
|
+
"tag": "@fluentui/react-persona_v9.1.1",
|
7
|
+
"version": "9.1.1",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"author": "beachball",
|
12
|
+
"package": "@fluentui/react-persona",
|
13
|
+
"comment": "Bump @fluentui/react-avatar to v9.2.12",
|
14
|
+
"commit": "26f0364b3837056ee8e0df42a7932c298c68290e"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"author": "beachball",
|
18
|
+
"package": "@fluentui/react-persona",
|
19
|
+
"comment": "Bump @fluentui/react-badge to v9.0.18",
|
20
|
+
"commit": "26f0364b3837056ee8e0df42a7932c298c68290e"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"author": "beachball",
|
24
|
+
"package": "@fluentui/react-persona",
|
25
|
+
"comment": "Bump @fluentui/react-utilities to v9.4.0",
|
26
|
+
"commit": "26f0364b3837056ee8e0df42a7932c298c68290e"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"date": "Wed, 04 Jan 2023 01:40:15 GMT",
|
33
|
+
"tag": "@fluentui/react-persona_v9.1.0",
|
34
|
+
"version": "9.1.0",
|
35
|
+
"comments": {
|
36
|
+
"none": [
|
37
|
+
{
|
38
|
+
"author": "olfedias@microsoft.com",
|
39
|
+
"package": "@fluentui/react-persona",
|
40
|
+
"commit": "2c38f1e4ae07b2b60df596efe11015a68f166dbf",
|
41
|
+
"comment": "chore: Update Griffel to latest version"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"author": "martinhochel@microsoft.com",
|
45
|
+
"package": "@fluentui/react-persona",
|
46
|
+
"commit": "4ec2b998b294d6d9c3196d3d82893bdd97d0c105",
|
47
|
+
"comment": "chore(scripts): move index.ts to to follow sub-folder domain packaging"
|
48
|
+
},
|
49
|
+
{
|
50
|
+
"author": "martinhochel@microsoft.com",
|
51
|
+
"package": "@fluentui/react-persona",
|
52
|
+
"commit": "194b0cf0cc27c1c1233aa945f09b3ad29778d8ca",
|
53
|
+
"comment": "chore(scripts): use for @fluentui/scripts version within all package.json"
|
54
|
+
}
|
55
|
+
],
|
56
|
+
"minor": [
|
57
|
+
{
|
58
|
+
"author": "esteban.230@hotmail.com",
|
59
|
+
"package": "@fluentui/react-persona",
|
60
|
+
"commit": "3e322d15529451be153e97298873253e21af4082",
|
61
|
+
"comment": "feat: Moving Persona to stable."
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"author": "beachball",
|
65
|
+
"package": "@fluentui/react-persona",
|
66
|
+
"comment": "Bump @fluentui/react-avatar to v9.2.11",
|
67
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"author": "beachball",
|
71
|
+
"package": "@fluentui/react-persona",
|
72
|
+
"comment": "Bump @fluentui/react-badge to v9.0.17",
|
73
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"author": "beachball",
|
77
|
+
"package": "@fluentui/react-persona",
|
78
|
+
"comment": "Bump @fluentui/react-utilities to v9.3.1",
|
79
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"author": "beachball",
|
83
|
+
"package": "@fluentui/react-persona",
|
84
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.19",
|
85
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
86
|
+
}
|
87
|
+
]
|
88
|
+
}
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"date": "Wed, 21 Dec 2022 10:20:33 GMT",
|
6
92
|
"tag": "@fluentui/react-persona_v9.1.0-beta.7",
|
7
93
|
"version": "9.1.0-beta.7",
|
8
94
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,36 @@
|
|
1
1
|
# Change Log - @fluentui/react-persona
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Mon, 09 Jan 2023 14:31:49 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.1.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-persona_v9.1.1)
|
8
|
+
|
9
|
+
Mon, 09 Jan 2023 14:31:49 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-persona_v9.1.0..@fluentui/react-persona_v9.1.1)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- Bump @fluentui/react-avatar to v9.2.12 ([PR #26257](https://github.com/microsoft/fluentui/pull/26257) by beachball)
|
15
|
+
- Bump @fluentui/react-badge to v9.0.18 ([PR #26257](https://github.com/microsoft/fluentui/pull/26257) by beachball)
|
16
|
+
- Bump @fluentui/react-utilities to v9.4.0 ([PR #26257](https://github.com/microsoft/fluentui/pull/26257) by beachball)
|
17
|
+
|
18
|
+
## [9.1.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-persona_v9.1.0)
|
19
|
+
|
20
|
+
Wed, 04 Jan 2023 01:40:15 GMT
|
21
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-persona_v9.1.0-beta.7..@fluentui/react-persona_v9.1.0)
|
22
|
+
|
23
|
+
### Minor changes
|
24
|
+
|
25
|
+
- feat: Moving Persona to stable. ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by esteban.230@hotmail.com)
|
26
|
+
- Bump @fluentui/react-avatar to v9.2.11 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
27
|
+
- Bump @fluentui/react-badge to v9.0.17 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
28
|
+
- Bump @fluentui/react-utilities to v9.3.1 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
29
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.19 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
30
|
+
|
7
31
|
## [9.1.0-beta.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-persona_v9.1.0-beta.7)
|
8
32
|
|
9
|
-
Wed, 21 Dec 2022 10:
|
33
|
+
Wed, 21 Dec 2022 10:20:33 GMT
|
10
34
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-persona_v9.1.0-beta.6..@fluentui/react-persona_v9.1.0-beta.7)
|
11
35
|
|
12
36
|
### Changes
|
package/README.md
CHANGED
@@ -2,20 +2,10 @@
|
|
2
2
|
|
3
3
|
**React Persona components for [Fluent UI React](https://react.fluentui.dev/)**
|
4
4
|
|
5
|
-
## STATUS: WIP 🚧
|
6
|
-
|
7
|
-
These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
|
8
|
-
|
9
5
|
## Usage
|
10
6
|
|
11
7
|
To import Persona:
|
12
8
|
|
13
|
-
```js
|
14
|
-
import { Persona } from '@fluentui/react-persona';
|
15
|
-
```
|
16
|
-
|
17
|
-
Once the Persona component graduates to a production release, the component will be available at:
|
18
|
-
|
19
9
|
```js
|
20
10
|
import { Persona } from '@fluentui/react-components';
|
21
11
|
```
|
@@ -6,7 +6,6 @@ import { usePersonaStyles_unstable } from './usePersonaStyles';
|
|
6
6
|
* A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,
|
7
7
|
* or an Avatar with a PresenceBadge.
|
8
8
|
*/
|
9
|
-
|
10
9
|
export const Persona = /*#__PURE__*/React.forwardRef((props, ref) => {
|
11
10
|
const state = usePersona_unstable(props, ref);
|
12
11
|
usePersonaStyles_unstable(state);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,mBAAmB,QAAQ,cAAc;AAClD,SAASC,yBAAyB,QAAQ,oBAAoB;AAI9D;;;;AAIA,OAAO,MAAMC,OAAO,gBAAsCJ,KAAK,CAACK,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EACxF,MAAMC,KAAK,GAAGN,mBAAmB,CAACI,KAAK,EAAEC,GAAG,CAAC;EAE7CJ,yBAAyB,CAACK,KAAK,CAAC;EAChC,OAAOP,sBAAsB,CAACO,KAAK,CAAC;AACtC,CAAC,CAAC;AAEFJ,OAAO,CAACK,WAAW,GAAG,SAAS","names":["React","renderPersona_unstable","usePersona_unstable","usePersonaStyles_unstable","Persona","forwardRef","props","ref","state","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-persona/src/components/Persona/Persona.tsx"],"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"]}
|
@@ -3,7 +3,6 @@ import { getSlots } from '@fluentui/react-utilities';
|
|
3
3
|
/**
|
4
4
|
* Render the final JSX of Persona
|
5
5
|
*/
|
6
|
-
|
7
6
|
export const renderPersona_unstable = state => {
|
8
7
|
const {
|
9
8
|
presenceOnly,
|
@@ -13,14 +12,21 @@ export const renderPersona_unstable = state => {
|
|
13
12
|
slots,
|
14
13
|
slotProps
|
15
14
|
} = getSlots(state);
|
16
|
-
const coin = presenceOnly ? slots.presence && /*#__PURE__*/React.createElement(slots.presence, {
|
17
|
-
|
15
|
+
const coin = presenceOnly ? slots.presence && /*#__PURE__*/React.createElement(slots.presence, {
|
16
|
+
...slotProps.presence
|
17
|
+
}) : slots.avatar && /*#__PURE__*/React.createElement(slots.avatar, {
|
18
|
+
...slotProps.avatar
|
18
19
|
});
|
19
|
-
return /*#__PURE__*/React.createElement(slots.root, {
|
20
|
-
|
21
|
-
}), slots.
|
22
|
-
|
23
|
-
}), slots.
|
20
|
+
return /*#__PURE__*/React.createElement(slots.root, {
|
21
|
+
...slotProps.root
|
22
|
+
}, (textPosition === 'after' || textPosition === 'below') && coin, slots.primaryText && /*#__PURE__*/React.createElement(slots.primaryText, {
|
23
|
+
...slotProps.primaryText
|
24
|
+
}), slots.secondaryText && /*#__PURE__*/React.createElement(slots.secondaryText, {
|
25
|
+
...slotProps.secondaryText
|
26
|
+
}), slots.tertiaryText && /*#__PURE__*/React.createElement(slots.tertiaryText, {
|
27
|
+
...slotProps.tertiaryText
|
28
|
+
}), slots.quaternaryText && /*#__PURE__*/React.createElement(slots.quaternaryText, {
|
29
|
+
...slotProps.quaternaryText
|
24
30
|
}), textPosition === 'before' && coin);
|
25
31
|
};
|
26
32
|
//# sourceMappingURL=renderPersona.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,QAAQ,2BAA2B;AAGpD;;;AAGA,OAAO,MAAMC,sBAAsB,GAAIC,KAAmB,IAAI;EAC5D,MAAM;IAAEC,YAAY;IAAEC;EAAY,CAAE,GAAGF,KAAK;EAC5C,MAAM;IAAEG,KAAK;IAAEC;EAAS,CAAE,GAAGN,QAAQ,CAAeE,KAAK,CAAC;EAE1D,MAAMK,IAAI,GAAGJ,YAAY,GACrBE,KAAK,CAACG,QAAQ,iBAAIT,oBAACM,KAAK,CAACG,QAAQ;IAAA,GAAKF,SAAS,CAACE;EAAQ,EAAI,GAC5DH,KAAK,CAACI,MAAM,iBAAIV,oBAACM,KAAK,CAACI,MAAM;IAAA,GAAKH,SAAS,CAACG;EAAM,EAAI;EAE1D,oBACEV,oBAACM,KAAK,CAACK,IAAI;IAAA,GAAKJ,SAAS,CAACI;EAAI,GAC3B,CAACN,YAAY,KAAK,OAAO,IAAIA,YAAY,KAAK,OAAO,KAAKG,IAAI,EAC9DF,KAAK,CAACM,WAAW,iBAAIZ,oBAACM,KAAK,CAACM,WAAW;IAAA,GAAKL,SAAS,CAACK;EAAW,EAAI,EACrEN,KAAK,CAACO,aAAa,iBAAIb,oBAACM,KAAK,CAACO,aAAa;IAAA,GAAKN,SAAS,CAACM;EAAa,EAAI,EAC3EP,KAAK,CAACQ,YAAY,iBAAId,oBAACM,KAAK,CAACQ,YAAY;IAAA,GAAKP,SAAS,CAACO;EAAY,EAAI,EACxER,KAAK,CAACS,cAAc,iBAAIf,oBAACM,KAAK,CAACS,cAAc;IAAA,GAAKR,SAAS,CAACQ;EAAc,EAAI,EAC9EV,YAAY,KAAK,QAAQ,IAAIG,IAAI,CACvB;AAEjB,CAAC","names":["React","getSlots","renderPersona_unstable","state","presenceOnly","textPosition","slots","slotProps","coin","presence","avatar","root","primaryText","secondaryText","tertiaryText","quaternaryText"],"sourceRoot":"../src/","sources":["packages/react-components/react-persona/src/components/Persona/renderPersona.tsx"],"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"]}
|
@@ -10,7 +10,6 @@ import { PresenceBadge } from '@fluentui/react-badge';
|
|
10
10
|
* @param props - props from this instance of Persona
|
11
11
|
* @param ref - reference to root HTMLElement of Persona
|
12
12
|
*/
|
13
|
-
|
14
13
|
export const usePersona_unstable = (props, ref) => {
|
15
14
|
const {
|
16
15
|
name,
|
@@ -44,11 +43,10 @@ export const usePersona_unstable = (props, ref) => {
|
|
44
43
|
tertiaryText: 'span',
|
45
44
|
quaternaryText: 'span'
|
46
45
|
},
|
47
|
-
root: getNativeElementProps('div', {
|
46
|
+
root: getNativeElementProps('div', {
|
47
|
+
...props,
|
48
48
|
ref
|
49
|
-
},
|
50
|
-
/* excludedPropNames */
|
51
|
-
['name']),
|
49
|
+
}, /* excludedPropNames */['name']),
|
52
50
|
avatar: !presenceOnly ? resolveShorthand(props.avatar, {
|
53
51
|
required: true,
|
54
52
|
defaultProps: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"AACA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,qBAAqB,EAAEC,gBAAgB,QAAQ,2BAA2B;AACnF,SAASC,aAAa,QAAQ,uBAAuB;AAGrD;;;;;;;;;AASA,OAAO,MAAMC,mBAAmB,GAAG,CAACC,KAAmB,EAAEC,GAA2B,KAAkB;EACpG,MAAM;IAAEC,IAAI;IAAEC,YAAY,GAAG,KAAK;IAAE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gB,CAACG,KAAK,CAACqB,QAAQ,EAAE;MAC/BZ,YAAY,EAAE;QACZL,IAAI,EAAEqB,aAAa,CAACrB,IAAI;;KAE3B,CAAC,GACFoB,SAAS;IACbjB,WAAW;IACXI,aAAa;IACbC,YAAY;IACZC;GACD;AACH,CAAC;AAED,MAAMY,aAAa,GAAG;EACpB,aAAa,EAAE,MAAM;EACrBC,KAAK,EAAE,aAAa;EACpBC,MAAM,EAAE,OAAO;EACfC,KAAK,EAAE,QAAQ;EACf,aAAa,EAAE,OAAO;EACtBC,IAAI,EAAE;CACE;AAEV,MAAMN,WAAW,GAAG;EAClB,aAAa,EAAE,EAAE;EACjBG,KAAK,EAAE,EAAE;EACTC,MAAM,EAAE,EAAE;EACVC,KAAK,EAAE,EAAE;EACT,aAAa,EAAE,EAAE;EACjBC,IAAI,EAAE;CACE","names":["Avatar","getNativeElementProps","resolveShorthand","PresenceBadge","usePersona_unstable","props","ref","name","presenceOnly","size","textAlignment","textPosition","primaryText","required","defaultProps","children","secondaryText","tertiaryText","quaternaryText","numTextLines","filter","Boolean","length","components","root","avatar","presence","badge","avatarSizes","undefined","presenceSizes","small","medium","large","huge"],"sourceRoot":"../src/","sources":["packages/react-components/react-persona/src/components/Persona/usePersona.ts"],"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 { 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"]}
|
@@ -13,92 +13,87 @@ const avatarSpacing = `--fui-Persona__avatar--spacing`;
|
|
13
13
|
/**
|
14
14
|
* Styles for the root slot
|
15
15
|
*/
|
16
|
-
|
17
16
|
const useStyles = /*#__PURE__*/__styles({
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
base: {
|
18
|
+
mc9l5x: "fwk3njj",
|
19
|
+
v29qe6: "fvtn1bl"
|
21
20
|
},
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
after: {
|
22
|
+
Bxotwcr: "f1u07yai",
|
23
|
+
B7hvi0a: "f1m2n5bn",
|
24
|
+
Budl1dq: "f1c1ms5d"
|
26
25
|
},
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
before: {
|
27
|
+
Bxotwcr: "f1u07yai",
|
28
|
+
B7hvi0a: "f1tll2w5",
|
29
|
+
Budl1dq: "ffvkwdr"
|
31
30
|
},
|
32
|
-
|
33
|
-
|
31
|
+
below: {
|
32
|
+
B7hvi0a: "f1oiokrs"
|
34
33
|
},
|
35
|
-
|
36
|
-
|
34
|
+
coin: {
|
35
|
+
Ijaq50: "f1hek2iy"
|
37
36
|
},
|
38
|
-
|
39
|
-
|
37
|
+
start: {
|
38
|
+
qb2dma: "f9h729m"
|
40
39
|
},
|
41
|
-
|
42
|
-
|
40
|
+
center: {
|
41
|
+
qb2dma: "f7nlbp4"
|
43
42
|
},
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
afterAlignToPrimary: {
|
44
|
+
qb2dma: "f7nlbp4",
|
45
|
+
Ijaq50: "f1rnkkuc",
|
46
|
+
Bw0ie65: "f1warjpf"
|
48
47
|
},
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
beforeAlignToPrimary: {
|
49
|
+
qb2dma: "f7nlbp4",
|
50
|
+
Ijaq50: "f1rnkkuc",
|
51
|
+
Br312pm: "fwu52yu"
|
53
52
|
}
|
54
53
|
}, {
|
55
|
-
|
54
|
+
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
55
|
});
|
57
|
-
|
58
56
|
const useAvatarSpacingStyles = /*#__PURE__*/__styles({
|
59
57
|
"extra-small": {
|
60
|
-
|
58
|
+
Bs1gm4r: "f1e48tse"
|
61
59
|
},
|
62
|
-
|
63
|
-
|
60
|
+
small: {
|
61
|
+
Bs1gm4r: "f18q9vkd"
|
64
62
|
},
|
65
|
-
|
66
|
-
|
63
|
+
medium: {
|
64
|
+
Bs1gm4r: "f18q9vkd"
|
67
65
|
},
|
68
|
-
|
69
|
-
|
66
|
+
large: {
|
67
|
+
Bs1gm4r: "fx34bi6"
|
70
68
|
},
|
71
69
|
"extra-large": {
|
72
|
-
|
70
|
+
Bs1gm4r: "fx34bi6"
|
73
71
|
},
|
74
|
-
|
75
|
-
|
72
|
+
huge: {
|
73
|
+
Bs1gm4r: "f1o96qtm"
|
76
74
|
},
|
77
|
-
|
78
|
-
|
75
|
+
after: {
|
76
|
+
t21cq0: ["f103ycu4", "f1tao51"]
|
79
77
|
},
|
80
|
-
|
81
|
-
|
78
|
+
below: {
|
79
|
+
jrapky: "fbo7acy"
|
82
80
|
},
|
83
|
-
|
84
|
-
|
81
|
+
before: {
|
82
|
+
Frg6f3: ["f1tao51", "f103ycu4"]
|
85
83
|
}
|
86
84
|
}, {
|
87
|
-
|
85
|
+
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
86
|
});
|
89
|
-
|
90
87
|
const usePresenceSpacingStyles = /*#__PURE__*/__styles({
|
91
|
-
|
92
|
-
|
88
|
+
small: {
|
89
|
+
Bs1gm4r: "f1e48tse"
|
93
90
|
}
|
94
91
|
}, {
|
95
|
-
|
92
|
+
d: [".f1e48tse{--fui-Persona__avatar--spacing:var(--spacingHorizontalSNudge);}"]
|
96
93
|
});
|
97
94
|
/**
|
98
95
|
* Apply styling to the Persona slots based on the state
|
99
96
|
*/
|
100
|
-
|
101
|
-
|
102
97
|
export const usePersonaStyles_unstable = state => {
|
103
98
|
const {
|
104
99
|
presenceOnly,
|
@@ -113,76 +108,68 @@ export const usePersonaStyles_unstable = state => {
|
|
113
108
|
} = useTextClassNames(state, alignToPrimary);
|
114
109
|
const styles = useStyles();
|
115
110
|
const avatarSpacingStyles = useAvatarSpacingStyles();
|
116
|
-
const presenceSpacingStyles = {
|
111
|
+
const presenceSpacingStyles = {
|
112
|
+
...avatarSpacingStyles,
|
117
113
|
...usePresenceSpacingStyles()
|
118
114
|
};
|
119
115
|
state.root.className = mergeClasses(personaClassNames.root, styles.base, styles[textPosition], state.root.className);
|
120
|
-
|
121
116
|
if (state.avatar) {
|
122
117
|
state.avatar.className = mergeClasses(personaClassNames.avatar, styles.coin, styles[textAlignment], avatarSpacingStyles[size], avatarSpacingStyles[textPosition], state.avatar.className);
|
123
118
|
}
|
124
|
-
|
125
119
|
if (state.presence) {
|
126
120
|
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);
|
127
121
|
}
|
128
|
-
|
129
122
|
if (state.primaryText) {
|
130
123
|
state.primaryText.className = mergeClasses(personaClassNames.primaryText, primaryTextClassName, state.primaryText.className);
|
131
124
|
}
|
132
|
-
|
133
125
|
if (state.secondaryText) {
|
134
126
|
state.secondaryText.className = mergeClasses(personaClassNames.secondaryText, optionalTextClassName, state.secondaryText.className);
|
135
127
|
}
|
136
|
-
|
137
128
|
if (state.tertiaryText) {
|
138
129
|
state.tertiaryText.className = mergeClasses(personaClassNames.tertiaryText, optionalTextClassName, state.tertiaryText.className);
|
139
130
|
}
|
140
|
-
|
141
131
|
if (state.quaternaryText) {
|
142
132
|
state.quaternaryText.className = mergeClasses(personaClassNames.quaternaryText, optionalTextClassName, state.quaternaryText.className);
|
143
133
|
}
|
144
|
-
|
145
134
|
return state;
|
146
135
|
};
|
147
|
-
|
148
136
|
const useTextStyles = /*#__PURE__*/__styles({
|
149
|
-
|
150
|
-
|
151
|
-
},
|
152
|
-
|
153
|
-
|
154
|
-
},
|
155
|
-
|
156
|
-
|
157
|
-
},
|
158
|
-
|
159
|
-
|
160
|
-
},
|
161
|
-
|
162
|
-
|
163
|
-
},
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
},
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
},
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
137
|
+
base: {
|
138
|
+
mc9l5x: "ftgm304"
|
139
|
+
},
|
140
|
+
primaryText: {
|
141
|
+
sj55zd: "f19n0e5"
|
142
|
+
},
|
143
|
+
optionalText: {
|
144
|
+
sj55zd: "fkfq4zb"
|
145
|
+
},
|
146
|
+
beforeAlignToPrimary: {
|
147
|
+
Bw0ie65: "f1warjpf"
|
148
|
+
},
|
149
|
+
afterAlignToPrimary: {
|
150
|
+
Br312pm: "fwu52yu"
|
151
|
+
},
|
152
|
+
body1: {
|
153
|
+
Bahqtrf: "fk6fouc",
|
154
|
+
Be2twd7: "fkhj508",
|
155
|
+
Bhrd7zp: "figsok6",
|
156
|
+
Bg96gwp: "f1i3iumi"
|
157
|
+
},
|
158
|
+
caption1: {
|
159
|
+
Bahqtrf: "fk6fouc",
|
160
|
+
Be2twd7: "fy9rknc",
|
161
|
+
Bhrd7zp: "figsok6",
|
162
|
+
Bg96gwp: "fwrc4pm"
|
163
|
+
},
|
164
|
+
subtitle2: {
|
165
|
+
Bahqtrf: "fk6fouc",
|
166
|
+
Be2twd7: "fod5ikn",
|
167
|
+
Bhrd7zp: "fl43uef",
|
168
|
+
Bg96gwp: "faaz57k"
|
181
169
|
}
|
182
170
|
}, {
|
183
|
-
|
171
|
+
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);}"]
|
184
172
|
});
|
185
|
-
|
186
173
|
const useTextClassNames = (state, alignToPrimary) => {
|
187
174
|
const {
|
188
175
|
presenceOnly,
|
@@ -192,7 +179,6 @@ const useTextClassNames = (state, alignToPrimary) => {
|
|
192
179
|
const textStyles = useTextStyles();
|
193
180
|
let primaryTextSize;
|
194
181
|
let alignToPrimaryClassName;
|
195
|
-
|
196
182
|
if (presenceOnly) {
|
197
183
|
if (size === 'extra-small') {
|
198
184
|
primaryTextSize = state.numTextLines > 1 ? textStyles.body1 : textStyles.caption1;
|
@@ -201,7 +187,6 @@ const useTextClassNames = (state, alignToPrimary) => {
|
|
201
187
|
} else {
|
202
188
|
primaryTextSize = textStyles.body1;
|
203
189
|
}
|
204
|
-
|
205
190
|
if (alignToPrimary) {
|
206
191
|
if (textPosition === 'before') {
|
207
192
|
alignToPrimaryClassName = textStyles.beforeAlignToPrimary;
|
@@ -218,7 +203,6 @@ const useTextClassNames = (state, alignToPrimary) => {
|
|
218
203
|
primaryTextSize = textStyles.body1;
|
219
204
|
}
|
220
205
|
}
|
221
|
-
|
222
206
|
return {
|
223
207
|
primaryTextClassName: mergeClasses(textStyles.base, textStyles.primaryText, primaryTextSize, alignToPrimaryClassName),
|
224
208
|
optionalTextClassName: mergeClasses(textStyles.base, textStyles.optionalText, !presenceOnly && size === 'huge' ? textStyles.body1 : textStyles.caption1, alignToPrimaryClassName)
|
@@ -1 +1 @@
|
|
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;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAAlB;;AA0CA,MAAM,sBAAsB,gBAAG;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAA/B;;AA8BA,MAAM,wBAAwB,gB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U,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/"}
|
1
|
+
{"version":3,"mappings":"AAAA,mBAAqBA,YAAY,QA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AAK,GAAGJ,UAAU,CAACK,QAAQ;KAClF,MAAM,IAAIrB,IAAI,KAAK,aAAa,IAAIA,IAAI,KAAK,MAAM,EAAE;MACpDiB,eAAe,GAAGD,UAAU,CAACM,SAAS;KACvC,MAAM;MACLL,eAAe,GAAGD,UAAU,CAACI,KAAK;;IAGpC,IAAIjB,cAAc,EAAE;MAClB,IAAID,YAAY,KAAK,QAAQ,EAAE;QAC7BgB,uBAAuB,GAAGF,UAAU,CAACF,oBAAoB;OAC1D,MAAM,IAAIZ,YAAY,KAAK,OAAO,EAAE;QACnCgB,uBAAuB,GAAGF,UAAU,CAACH,mBAAmB;;;GAG7D,MAAM;IACL,IAAIb,IAAI,KAAK,MAAM,EAAE;MACnBiB,eAAe,GAAGD,UAAU,CAACM,SAAS;KACvC,MAAM,IAAItB,IAAI,KAAK,aAAa,EAAE;MACjCiB,eAAe,GAAGD,UAAU,CAACM,SAAS;KACvC,MAAM;MACLL,eAAe,GAAGD,UAAU,CAACI,KAAK;;;EAItC,OAAO;IACLhB,oBAAoB,EAAEtB,YAAY,CAChCkC,UAAU,CAACL,IAAI,EACfK,UAAU,CAAC3B,WAAW,EACtB4B,eAAe,EACfC,uBAAuB,CACxB;IACDb,qBAAqB,EAAEvB,YAAY,CACjCkC,UAAU,CAACL,IAAI,EACfK,UAAU,CAACO,YAAY,EACvB,CAACxB,YAAY,IAAIC,IAAI,KAAK,MAAM,GAAGgB,UAAU,CAACI,KAAK,GAAGJ,UAAU,CAACK,QAAQ,EACzEH,uBAAuB;GAE1B;AACH,CAAC","names":["mergeClasses","tokens","typographyStyles","personaClassNames","root","avatar","presence","primaryText","secondaryText","tertiaryText","quaternaryText","avatarSpacing","useStyles","useAvatarSpacingStyles","usePresenceSpacingStyles","usePersonaStyles_unstable","state","presenceOnly","size","textAlignment","textPosition","alignToPrimary","primaryTextClassName","optionalTextClassName","useTextClassNames","styles","avatarSpacingStyles","presenceSpacingStyles","className","base","coin","afterAlignToPrimary","beforeAlignToPrimary","useTextStyles","textStyles","primaryTextSize","alignToPrimaryClassName","numTextLines","body1","caption1","subtitle2","optionalText"],"sourceRoot":"../src/","sources":["packages/react-components/react-persona/src/components/Persona/usePersonaStyles.ts"],"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"]}
|