@fluentui/react-persona 9.1.0-beta.6 → 9.1.0
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 +9 -11
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-persona/src/index.ts"],"
|
1
|
+
{"version":3,"mappings":"AAAA,SACEA,OAAO,EACPC,iBAAiB,EACjBC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,WAAW","names":["Persona","personaClassNames","renderPersona_unstable","usePersonaStyles_unstable","usePersona_unstable"],"sourceRoot":"../src/","sources":["packages/react-components/react-persona/src/index.ts"],"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"]}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
define(["require", "exports", "tslib", "./components/Persona/index"], function (require, exports, tslib_1, index_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
tslib_1.__exportStar(index_1, exports);
|
5
|
+
});
|
6
|
+
//# sourceMappingURL=Persona.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Persona.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-persona/src/Persona.ts"],"names":[],"mappings":";;;IAAA,uCAA2C","sourcesContent":["export * from './components/Persona/index';\n"]}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
define(["require", "exports", "react", "./renderPersona", "./usePersona", "./usePersonaStyles"], function (require, exports, React, renderPersona_1, usePersona_1, usePersonaStyles_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.Persona = void 0;
|
5
|
+
/**
|
6
|
+
* A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,
|
7
|
+
* or an Avatar with a PresenceBadge.
|
8
|
+
*/
|
9
|
+
exports.Persona = React.forwardRef(function (props, ref) {
|
10
|
+
var state = usePersona_1.usePersona_unstable(props, ref);
|
11
|
+
usePersonaStyles_1.usePersonaStyles_unstable(state);
|
12
|
+
return renderPersona_1.renderPersona_unstable(state);
|
13
|
+
});
|
14
|
+
exports.Persona.displayName = 'Persona';
|
15
|
+
});
|
16
|
+
//# sourceMappingURL=Persona.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Persona.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-persona/src/components/Persona/Persona.tsx"],"names":[],"mappings":";;;;IAOA;;;OAGG;IACU,QAAA,OAAO,GAAsC,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;QACpF,IAAM,KAAK,GAAG,gCAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE9C,4CAAyB,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,sCAAsB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,eAAO,CAAC,WAAW,GAAG,SAAS,CAAC","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"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Persona.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-persona/src/components/Persona/Persona.types.ts"],"names":[],"mappings":"","sourcesContent":["import { Avatar } from '@fluentui/react-avatar';\nimport { PresenceBadge } from '@fluentui/react-badge';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type PersonaSlots = {\n root: NonNullable<Slot<'div'>>;\n\n /**\n * Avatar to display.\n *\n * If a PresenceBadge and an Avatar are provided, the Avatar will display the PresenceBadge as its presence.\n */\n avatar?: Slot<typeof Avatar>;\n\n /**\n * PresenceBadge to display.\n *\n * If `presenceOnly` is true, the PresenceBadge will be displayed instead of the Avatar.\n */\n presence?: Slot<typeof PresenceBadge>;\n\n /**\n * The first line of text in the Persona, larger than the rest of the lines.\n *\n * `primaryText` defaults to the `name` prop. We recomend to only use `name`, use `primaryText` when the text is\n * different than the `name` prop.\n */\n primaryText?: Slot<'span'>;\n\n /**\n * The second line of text in the Persona.\n */\n secondaryText?: Slot<'span'>;\n\n /**\n * The third line of text in the Persona.\n */\n tertiaryText?: Slot<'span'>;\n\n /**\n * The fourth line of text in the Persona.\n */\n quaternaryText?: Slot<'span'>;\n};\n\n/**\n * Persona Props\n */\nexport type PersonaProps = ComponentProps<PersonaSlots> & {\n /**\n * The name of the person or entity represented by the Persona.\n *\n * When `primaryText` is not provided, this will be used as the default value for `primaryText`.\n */\n name?: string;\n\n /**\n * Whether to display only the presence.\n *\n * @default false\n */\n presenceOnly?: boolean;\n\n /**\n * The size of a Persona and its text.\n *\n * @default medium\n */\n size?: 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | 'huge';\n\n /**\n * The position of the text relative to the avatar/presence.\n *\n * @default after\n */\n textPosition?: 'after' | 'before' | 'below';\n\n /**\n * The vertical alignment of the text relative to the avatar/presence.\n *\n * @default start\n */\n textAlignment?: 'center' | 'start';\n};\n\n/**\n * State used in rendering Persona\n */\nexport type PersonaState = ComponentState<PersonaSlots> &\n Required<Pick<PersonaProps, 'presenceOnly' | 'size' | 'textAlignment' | 'textPosition'>> & {\n /**\n * The number of text lines used.\n */\n numTextLines: number;\n };\n"]}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
define(["require", "exports", "tslib", "./Persona", "./Persona.types", "./renderPersona", "./usePersona", "./usePersonaStyles"], function (require, exports, tslib_1, Persona_1, Persona_types_1, renderPersona_1, usePersona_1, usePersonaStyles_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
tslib_1.__exportStar(Persona_1, exports);
|
5
|
+
tslib_1.__exportStar(Persona_types_1, exports);
|
6
|
+
tslib_1.__exportStar(renderPersona_1, exports);
|
7
|
+
tslib_1.__exportStar(usePersona_1, exports);
|
8
|
+
tslib_1.__exportStar(usePersonaStyles_1, exports);
|
9
|
+
});
|
10
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-persona/src/components/Persona/index.ts"],"names":[],"mappings":";;;IAAA,yCAA0B;IAC1B,+CAAgC;IAChC,+CAAgC;IAChC,4CAA6B;IAC7B,kDAAmC","sourcesContent":["export * from './Persona';\nexport * from './Persona.types';\nexport * from './renderPersona';\nexport * from './usePersona';\nexport * from './usePersonaStyles';\n"]}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
define(["require", "exports", "tslib", "react", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_utilities_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.renderPersona_unstable = void 0;
|
5
|
+
/**
|
6
|
+
* Render the final JSX of Persona
|
7
|
+
*/
|
8
|
+
var renderPersona_unstable = function (state) {
|
9
|
+
var presenceOnly = state.presenceOnly, textPosition = state.textPosition;
|
10
|
+
var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
|
11
|
+
var coin = presenceOnly
|
12
|
+
? slots.presence && React.createElement(slots.presence, tslib_1.__assign({}, slotProps.presence))
|
13
|
+
: slots.avatar && React.createElement(slots.avatar, tslib_1.__assign({}, slotProps.avatar));
|
14
|
+
return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
|
15
|
+
(textPosition === 'after' || textPosition === 'below') && coin,
|
16
|
+
slots.primaryText && React.createElement(slots.primaryText, tslib_1.__assign({}, slotProps.primaryText)),
|
17
|
+
slots.secondaryText && React.createElement(slots.secondaryText, tslib_1.__assign({}, slotProps.secondaryText)),
|
18
|
+
slots.tertiaryText && React.createElement(slots.tertiaryText, tslib_1.__assign({}, slotProps.tertiaryText)),
|
19
|
+
slots.quaternaryText && React.createElement(slots.quaternaryText, tslib_1.__assign({}, slotProps.quaternaryText)),
|
20
|
+
textPosition === 'before' && coin));
|
21
|
+
};
|
22
|
+
exports.renderPersona_unstable = renderPersona_unstable;
|
23
|
+
});
|
24
|
+
//# sourceMappingURL=renderPersona.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"renderPersona.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-persona/src/components/Persona/renderPersona.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,sBAAsB,GAAG,UAAC,KAAmB;QAChD,IAAA,YAAY,GAAmB,KAAK,aAAxB,EAAE,YAAY,GAAK,KAAK,aAAV,CAAW;QACvC,IAAA,KAAuB,0BAAQ,CAAe,KAAK,CAAC,EAAlD,KAAK,WAAA,EAAE,SAAS,eAAkC,CAAC;QAE3D,IAAM,IAAI,GAAG,YAAY;YACvB,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,oBAAC,KAAK,CAAC,QAAQ,uBAAK,SAAS,CAAC,QAAQ,EAAI;YAC9D,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,oBAAC,KAAK,CAAC,MAAM,uBAAK,SAAS,CAAC,MAAM,EAAI,CAAC;QAE3D,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC3B,CAAC,YAAY,KAAK,OAAO,IAAI,YAAY,KAAK,OAAO,CAAC,IAAI,IAAI;YAC9D,KAAK,CAAC,WAAW,IAAI,oBAAC,KAAK,CAAC,WAAW,uBAAK,SAAS,CAAC,WAAW,EAAI;YACrE,KAAK,CAAC,aAAa,IAAI,oBAAC,KAAK,CAAC,aAAa,uBAAK,SAAS,CAAC,aAAa,EAAI;YAC3E,KAAK,CAAC,YAAY,IAAI,oBAAC,KAAK,CAAC,YAAY,uBAAK,SAAS,CAAC,YAAY,EAAI;YACxE,KAAK,CAAC,cAAc,IAAI,oBAAC,KAAK,CAAC,cAAc,uBAAK,SAAS,CAAC,cAAc,EAAI;YAC9E,YAAY,KAAK,QAAQ,IAAI,IAAI,CACvB,CACd,CAAC;IACJ,CAAC,CAAC;IAlBW,QAAA,sBAAsB,0BAkBjC","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"]}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
define(["require", "exports", "tslib", "@fluentui/react-avatar", "@fluentui/react-utilities", "@fluentui/react-badge"], function (require, exports, tslib_1, react_avatar_1, react_utilities_1, react_badge_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.usePersona_unstable = void 0;
|
5
|
+
/**
|
6
|
+
* Create the state required to render Persona.
|
7
|
+
*
|
8
|
+
* The returned state can be modified with hooks such as usePersonaStyles_unstable,
|
9
|
+
* before being passed to renderPersona_unstable.
|
10
|
+
*
|
11
|
+
* @param props - props from this instance of Persona
|
12
|
+
* @param ref - reference to root HTMLElement of Persona
|
13
|
+
*/
|
14
|
+
var usePersona_unstable = function (props, ref) {
|
15
|
+
var name = props.name, _a = props.presenceOnly, presenceOnly = _a === void 0 ? false : _a, _b = props.size, size = _b === void 0 ? 'medium' : _b, _c = props.textAlignment, textAlignment = _c === void 0 ? 'start' : _c, _d = props.textPosition, textPosition = _d === void 0 ? 'after' : _d;
|
16
|
+
var primaryText = react_utilities_1.resolveShorthand(props.primaryText, {
|
17
|
+
required: true,
|
18
|
+
defaultProps: {
|
19
|
+
children: name,
|
20
|
+
},
|
21
|
+
});
|
22
|
+
var secondaryText = react_utilities_1.resolveShorthand(props.secondaryText);
|
23
|
+
var tertiaryText = react_utilities_1.resolveShorthand(props.tertiaryText);
|
24
|
+
var quaternaryText = react_utilities_1.resolveShorthand(props.quaternaryText);
|
25
|
+
var numTextLines = [primaryText, secondaryText, tertiaryText, quaternaryText].filter(Boolean).length;
|
26
|
+
return {
|
27
|
+
numTextLines: numTextLines,
|
28
|
+
presenceOnly: presenceOnly,
|
29
|
+
size: size,
|
30
|
+
textAlignment: textAlignment,
|
31
|
+
textPosition: textPosition,
|
32
|
+
components: {
|
33
|
+
root: 'div',
|
34
|
+
avatar: react_avatar_1.Avatar,
|
35
|
+
presence: react_badge_1.PresenceBadge,
|
36
|
+
primaryText: 'span',
|
37
|
+
secondaryText: 'span',
|
38
|
+
tertiaryText: 'span',
|
39
|
+
quaternaryText: 'span',
|
40
|
+
},
|
41
|
+
root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign(tslib_1.__assign({}, props), { ref: ref }),
|
42
|
+
/* excludedPropNames */ ['name']),
|
43
|
+
avatar: !presenceOnly
|
44
|
+
? react_utilities_1.resolveShorthand(props.avatar, {
|
45
|
+
required: true,
|
46
|
+
defaultProps: {
|
47
|
+
name: name,
|
48
|
+
badge: props.presence,
|
49
|
+
size: avatarSizes[size],
|
50
|
+
},
|
51
|
+
})
|
52
|
+
: undefined,
|
53
|
+
presence: presenceOnly
|
54
|
+
? react_utilities_1.resolveShorthand(props.presence, {
|
55
|
+
defaultProps: {
|
56
|
+
size: presenceSizes[size],
|
57
|
+
},
|
58
|
+
})
|
59
|
+
: undefined,
|
60
|
+
primaryText: primaryText,
|
61
|
+
secondaryText: secondaryText,
|
62
|
+
tertiaryText: tertiaryText,
|
63
|
+
quaternaryText: quaternaryText,
|
64
|
+
};
|
65
|
+
};
|
66
|
+
exports.usePersona_unstable = usePersona_unstable;
|
67
|
+
var presenceSizes = {
|
68
|
+
'extra-small': 'tiny',
|
69
|
+
small: 'extra-small',
|
70
|
+
medium: 'small',
|
71
|
+
large: 'medium',
|
72
|
+
'extra-large': 'large',
|
73
|
+
huge: 'large',
|
74
|
+
};
|
75
|
+
var avatarSizes = {
|
76
|
+
'extra-small': 20,
|
77
|
+
small: 28,
|
78
|
+
medium: 32,
|
79
|
+
large: 36,
|
80
|
+
'extra-large': 40,
|
81
|
+
huge: 56,
|
82
|
+
};
|
83
|
+
});
|
84
|
+
//# sourceMappingURL=usePersona.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"usePersona.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-persona/src/components/Persona/usePersona.ts"],"names":[],"mappings":";;;;IAMA;;;;;;;;OAQG;IACI,IAAM,mBAAmB,GAAG,UAAC,KAAmB,EAAE,GAA2B;QAC1E,IAAA,IAAI,GAA6F,KAAK,KAAlG,EAAE,KAA2F,KAAK,aAA5E,EAApB,YAAY,mBAAG,KAAK,KAAA,EAAE,KAAqE,KAAK,KAA3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KAAK,CAAC,QAAQ;wBACrB,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;qBACxB;iBACF,CAAC;gBACJ,CAAC,CAAC,SAAS;YACb,QAAQ,EAAE,YAAY;gBACpB,CAAC,CAAC,kCAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE;oBAC/B,YAAY,EAAE;wBACZ,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC;qBAC1B;iBACF,CAAC;gBACJ,CAAC,CAAC,SAAS;YACb,WAAW,aAAA;YACX,aAAa,eAAA;YACb,YAAY,cAAA;YACZ,cAAc,gBAAA;SACf,CAAC;IACJ,CAAC,CAAC;IA9DW,QAAA,mBAAmB,uBA8D9B;IAEF,IAAM,aAAa,GAAG;QACpB,aAAa,EAAE,MAAM;QACrB,KAAK,EAAE,aAAa;QACpB,MAAM,EAAE,OAAO;QACf,KAAK,EAAE,QAAQ;QACf,aAAa,EAAE,OAAO;QACtB,IAAI,EAAE,OAAO;KACL,CAAC;IAEX,IAAM,WAAW,GAAG;QAClB,aAAa,EAAE,EAAE;QACjB,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,aAAa,EAAE,EAAE;QACjB,IAAI,EAAE,EAAE;KACA,CAAC","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"]}
|
@@ -0,0 +1,184 @@
|
|
1
|
+
define(["require", "exports", "tslib", "@griffel/react", "@fluentui/react-theme"], function (require, exports, tslib_1, react_1, react_theme_1) {
|
2
|
+
"use strict";
|
3
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5
|
+
exports.usePersonaStyles_unstable = exports.personaClassNames = void 0;
|
6
|
+
exports.personaClassNames = {
|
7
|
+
root: 'fui-Persona',
|
8
|
+
avatar: 'fui-Persona__avatar',
|
9
|
+
presence: 'fui-Persona__presence',
|
10
|
+
primaryText: 'fui-Persona__primaryText',
|
11
|
+
secondaryText: 'fui-Persona__secondaryText',
|
12
|
+
tertiaryText: 'fui-Persona__tertiaryText',
|
13
|
+
quaternaryText: 'fui-Persona__quaternaryText',
|
14
|
+
};
|
15
|
+
var avatarSpacing = "--fui-Persona__avatar--spacing";
|
16
|
+
/**
|
17
|
+
* Styles for the root slot
|
18
|
+
*/
|
19
|
+
var useStyles = react_1.makeStyles({
|
20
|
+
base: {
|
21
|
+
display: 'inline-grid',
|
22
|
+
gridAutoRows: 'max-content',
|
23
|
+
},
|
24
|
+
after: {
|
25
|
+
gridAutoFlow: 'column',
|
26
|
+
justifyItems: 'start',
|
27
|
+
gridTemplateColumns: 'max-content [middle] auto',
|
28
|
+
},
|
29
|
+
before: {
|
30
|
+
gridAutoFlow: 'column',
|
31
|
+
justifyItems: 'end',
|
32
|
+
gridTemplateColumns: 'auto [middle] max-content',
|
33
|
+
},
|
34
|
+
below: {
|
35
|
+
justifyItems: 'center',
|
36
|
+
},
|
37
|
+
coin: {
|
38
|
+
gridRowStart: 'span 5',
|
39
|
+
},
|
40
|
+
start: {
|
41
|
+
alignSelf: 'start',
|
42
|
+
},
|
43
|
+
center: {
|
44
|
+
alignSelf: 'center',
|
45
|
+
},
|
46
|
+
afterAlignToPrimary: {
|
47
|
+
alignSelf: 'center',
|
48
|
+
gridRowStart: 'unset',
|
49
|
+
gridColumnEnd: 'middle',
|
50
|
+
},
|
51
|
+
beforeAlignToPrimary: {
|
52
|
+
alignSelf: 'center',
|
53
|
+
gridRowStart: 'unset',
|
54
|
+
gridColumnStart: 'middle',
|
55
|
+
},
|
56
|
+
});
|
57
|
+
var useAvatarSpacingStyles = react_1.makeStyles({
|
58
|
+
'extra-small': (_a = {},
|
59
|
+
_a[avatarSpacing] = react_theme_1.tokens.spacingHorizontalSNudge,
|
60
|
+
_a),
|
61
|
+
small: (_b = {},
|
62
|
+
_b[avatarSpacing] = react_theme_1.tokens.spacingHorizontalS,
|
63
|
+
_b),
|
64
|
+
medium: (_c = {},
|
65
|
+
_c[avatarSpacing] = react_theme_1.tokens.spacingHorizontalS,
|
66
|
+
_c),
|
67
|
+
large: (_d = {},
|
68
|
+
_d[avatarSpacing] = react_theme_1.tokens.spacingHorizontalMNudge,
|
69
|
+
_d),
|
70
|
+
'extra-large': (_e = {},
|
71
|
+
_e[avatarSpacing] = react_theme_1.tokens.spacingHorizontalMNudge,
|
72
|
+
_e),
|
73
|
+
huge: (_f = {},
|
74
|
+
_f[avatarSpacing] = react_theme_1.tokens.spacingHorizontalM,
|
75
|
+
_f),
|
76
|
+
after: {
|
77
|
+
marginRight: "var(" + avatarSpacing + ")",
|
78
|
+
},
|
79
|
+
below: {
|
80
|
+
marginBottom: "var(" + avatarSpacing + ")",
|
81
|
+
},
|
82
|
+
before: {
|
83
|
+
marginLeft: "var(" + avatarSpacing + ")",
|
84
|
+
},
|
85
|
+
});
|
86
|
+
var usePresenceSpacingStyles = react_1.makeStyles({
|
87
|
+
small: (_g = {},
|
88
|
+
_g[avatarSpacing] = react_theme_1.tokens.spacingHorizontalSNudge,
|
89
|
+
_g),
|
90
|
+
});
|
91
|
+
/**
|
92
|
+
* Apply styling to the Persona slots based on the state
|
93
|
+
*/
|
94
|
+
var usePersonaStyles_unstable = function (state) {
|
95
|
+
var presenceOnly = state.presenceOnly, size = state.size, textAlignment = state.textAlignment, textPosition = state.textPosition;
|
96
|
+
var alignToPrimary = presenceOnly && textAlignment === 'start' && size !== 'extra-large' && size !== 'huge';
|
97
|
+
var _a = useTextClassNames(state, alignToPrimary), primaryTextClassName = _a.primaryTextClassName, optionalTextClassName = _a.optionalTextClassName;
|
98
|
+
var styles = useStyles();
|
99
|
+
var avatarSpacingStyles = useAvatarSpacingStyles();
|
100
|
+
var presenceSpacingStyles = tslib_1.__assign(tslib_1.__assign({}, avatarSpacingStyles), usePresenceSpacingStyles());
|
101
|
+
state.root.className = react_1.mergeClasses(exports.personaClassNames.root, styles.base, styles[textPosition], state.root.className);
|
102
|
+
if (state.avatar) {
|
103
|
+
state.avatar.className = react_1.mergeClasses(exports.personaClassNames.avatar, styles.coin, styles[textAlignment], avatarSpacingStyles[size], avatarSpacingStyles[textPosition], state.avatar.className);
|
104
|
+
}
|
105
|
+
if (state.presence) {
|
106
|
+
state.presence.className = react_1.mergeClasses(exports.personaClassNames.presence, styles.coin, styles[textAlignment], presenceSpacingStyles[size], presenceSpacingStyles[textPosition], textPosition === 'after' && alignToPrimary && styles.afterAlignToPrimary, textPosition === 'before' && alignToPrimary && styles.beforeAlignToPrimary, state.presence.className);
|
107
|
+
}
|
108
|
+
if (state.primaryText) {
|
109
|
+
state.primaryText.className = react_1.mergeClasses(exports.personaClassNames.primaryText, primaryTextClassName, state.primaryText.className);
|
110
|
+
}
|
111
|
+
if (state.secondaryText) {
|
112
|
+
state.secondaryText.className = react_1.mergeClasses(exports.personaClassNames.secondaryText, optionalTextClassName, state.secondaryText.className);
|
113
|
+
}
|
114
|
+
if (state.tertiaryText) {
|
115
|
+
state.tertiaryText.className = react_1.mergeClasses(exports.personaClassNames.tertiaryText, optionalTextClassName, state.tertiaryText.className);
|
116
|
+
}
|
117
|
+
if (state.quaternaryText) {
|
118
|
+
state.quaternaryText.className = react_1.mergeClasses(exports.personaClassNames.quaternaryText, optionalTextClassName, state.quaternaryText.className);
|
119
|
+
}
|
120
|
+
return state;
|
121
|
+
};
|
122
|
+
exports.usePersonaStyles_unstable = usePersonaStyles_unstable;
|
123
|
+
var useTextStyles = react_1.makeStyles({
|
124
|
+
base: {
|
125
|
+
display: 'block',
|
126
|
+
},
|
127
|
+
primaryText: {
|
128
|
+
color: react_theme_1.tokens.colorNeutralForeground1,
|
129
|
+
},
|
130
|
+
optionalText: {
|
131
|
+
color: react_theme_1.tokens.colorNeutralForeground2,
|
132
|
+
},
|
133
|
+
beforeAlignToPrimary: {
|
134
|
+
gridColumnEnd: 'middle',
|
135
|
+
},
|
136
|
+
afterAlignToPrimary: {
|
137
|
+
gridColumnStart: 'middle',
|
138
|
+
},
|
139
|
+
body1: react_theme_1.typographyStyles.body1,
|
140
|
+
caption1: react_theme_1.typographyStyles.caption1,
|
141
|
+
subtitle2: react_theme_1.typographyStyles.subtitle2,
|
142
|
+
});
|
143
|
+
var useTextClassNames = function (state, alignToPrimary) {
|
144
|
+
var presenceOnly = state.presenceOnly, size = state.size, textPosition = state.textPosition;
|
145
|
+
var textStyles = useTextStyles();
|
146
|
+
var primaryTextSize;
|
147
|
+
var alignToPrimaryClassName;
|
148
|
+
if (presenceOnly) {
|
149
|
+
if (size === 'extra-small') {
|
150
|
+
primaryTextSize = state.numTextLines > 1 ? textStyles.body1 : textStyles.caption1;
|
151
|
+
}
|
152
|
+
else if (size === 'extra-large' || size === 'huge') {
|
153
|
+
primaryTextSize = textStyles.subtitle2;
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
primaryTextSize = textStyles.body1;
|
157
|
+
}
|
158
|
+
if (alignToPrimary) {
|
159
|
+
if (textPosition === 'before') {
|
160
|
+
alignToPrimaryClassName = textStyles.beforeAlignToPrimary;
|
161
|
+
}
|
162
|
+
else if (textPosition === 'after') {
|
163
|
+
alignToPrimaryClassName = textStyles.afterAlignToPrimary;
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}
|
167
|
+
else {
|
168
|
+
if (size === 'huge') {
|
169
|
+
primaryTextSize = textStyles.subtitle2;
|
170
|
+
}
|
171
|
+
else if (size === 'extra-large') {
|
172
|
+
primaryTextSize = textStyles.subtitle2;
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
primaryTextSize = textStyles.body1;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
return {
|
179
|
+
primaryTextClassName: react_1.mergeClasses(textStyles.base, textStyles.primaryText, primaryTextSize, alignToPrimaryClassName),
|
180
|
+
optionalTextClassName: react_1.mergeClasses(textStyles.base, textStyles.optionalText, !presenceOnly && size === 'huge' ? textStyles.body1 : textStyles.caption1, alignToPrimaryClassName),
|
181
|
+
};
|
182
|
+
};
|
183
|
+
});
|
184
|
+
//# sourceMappingURL=usePersonaStyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"usePersonaStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-persona/src/components/Persona/usePersonaStyles.ts"],"names":[],"mappings":";;;;;IAKa,QAAA,iBAAiB,GAAiC;QAC7D,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,qBAAqB;QAC7B,QAAQ,EAAE,uBAAuB;QACjC,WAAW,EAAE,0BAA0B;QACvC,aAAa,EAAE,4BAA4B;QAC3C,YAAY,EAAE,2BAA2B;QACzC,cAAc,EAAE,6BAA6B;KAC9C,CAAC;IAEF,IAAM,aAAa,GAAG,gCAAgC,CAAC;IAEvD;;OAEG;IACH,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI,EAAE;YACJ,OAAO,EAAE,aAAa;YACtB,YAAY,EAAE,aAAa;SAC5B;QAED,KAAK,EAAE;YACL,YAAY,EAAE,QAAQ;YACtB,YAAY,EAAE,OAAO;YACrB,mBAAmB,EAAE,2BAA2B;SACjD;QACD,MAAM,EAAE;YACN,YAAY,EAAE,QAAQ;YACtB,YAAY,EAAE,KAAK;YACnB,mBAAmB,EAAE,2BAA2B;SACjD;QACD,KAAK,EAAE;YACL,YAAY,EAAE,QAAQ;SACvB;QACD,IAAI,EAAE;YACJ,YAAY,EAAE,QAAQ;SACvB;QAED,KAAK,EAAE;YACL,SAAS,EAAE,OAAO;SACnB;QACD,MAAM,EAAE;YACN,SAAS,EAAE,QAAQ;SACpB;QAED,mBAAmB,EAAE;YACnB,SAAS,EAAE,QAAQ;YACnB,YAAY,EAAE,OAAO;YACrB,aAAa,EAAE,QAAQ;SACxB;QACD,oBAAoB,EAAE;YACpB,SAAS,EAAE,QAAQ;YACnB,YAAY,EAAE,OAAO;YACrB,eAAe,EAAE,QAAQ;SAC1B;KACF,CAAC,CAAC;IAEH,IAAM,sBAAsB,GAAG,kBAAU,CAAC;QACxC,aAAa;YACX,GAAC,aAAa,IAAG,oBAAM,CAAC,u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CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;aACnF;iBAAM,IAAI,IAAI,KAAK,aAAa,IAAI,IAAI,KAAK,MAAM,EAAE;gBACpD,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC;aACxC;iBAAM;gBACL,eAAe,GAAG,UAAU,CAAC,KAAK,CAAC;aACpC;YAED,IAAI,cAAc,EAAE;gBAClB,IAAI,YAAY,KAAK,QAAQ,EAAE;oBAC7B,uBAAuB,GAAG,UAAU,CAAC,oBAAoB,CAAC;iBAC3D;qBAAM,IAAI,YAAY,KAAK,OAAO,EAAE;oBACnC,uBAAuB,GAAG,UAAU,CAAC,mBAAmB,CAAC;iBAC1D;aACF;SACF;aAAM;YACL,IAAI,IAAI,KAAK,MAAM,EAAE;gBACnB,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC;aACxC;iBAAM,IAAI,IAAI,KAAK,aAAa,EAAE;gBACjC,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC;aACxC;iBAAM;gBACL,eAAe,GAAG,UAAU,CAAC,KAAK,CAAC;aACpC;SACF;QAED,OAAO;YACL,oBAAoB,EAAE,oBAAY,CAChC,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,WAAW,EACtB,eAAe,EACf,uBAAuB,CACxB;YACD,qBAAqB,EAAE,oBAAY,CACjC,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,YAAY,EACvB,CAAC,YAAY,IAAI,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EACzE,uBAAuB,CACxB;SACF,CAAC;IACJ,CAAC,CAAC","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"]}
|
package/lib-amd/index.js
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
define(["require", "exports", "./Persona"], function (require, exports, Persona_1) {
|
2
|
+
"use strict";
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
+
exports.usePersona_unstable = exports.usePersonaStyles_unstable = exports.renderPersona_unstable = exports.personaClassNames = exports.Persona = void 0;
|
5
|
+
Object.defineProperty(exports, "Persona", { enumerable: true, get: function () { return Persona_1.Persona; } });
|
6
|
+
Object.defineProperty(exports, "personaClassNames", { enumerable: true, get: function () { return Persona_1.personaClassNames; } });
|
7
|
+
Object.defineProperty(exports, "renderPersona_unstable", { enumerable: true, get: function () { return Persona_1.renderPersona_unstable; } });
|
8
|
+
Object.defineProperty(exports, "usePersonaStyles_unstable", { enumerable: true, get: function () { return Persona_1.usePersonaStyles_unstable; } });
|
9
|
+
Object.defineProperty(exports, "usePersona_unstable", { enumerable: true, get: function () { return Persona_1.usePersona_unstable; } });
|
10
|
+
});
|
11
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-persona/src/index.ts"],"names":[],"mappings":";;;;IACE,kGAAA,OAAO,OAAA;IACP,4GAAA,iBAAiB,OAAA;IACjB,iHAAA,sBAAsB,OAAA;IACtB,oHAAA,yBAAyB,OAAA;IACzB,8GAAA,mBAAmB,OAAA","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"]}
|
package/lib-commonjs/Persona.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-persona/src/Persona.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-persona/src/Persona.ts"],"sourcesContent":["export * from './components/Persona/index';\n"]}
|
@@ -4,20 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.Persona = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const renderPersona_1 = /*#__PURE__*/require("./renderPersona");
|
11
|
-
|
12
9
|
const usePersona_1 = /*#__PURE__*/require("./usePersona");
|
13
|
-
|
14
10
|
const usePersonaStyles_1 = /*#__PURE__*/require("./usePersonaStyles");
|
15
11
|
/**
|
16
12
|
* A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,
|
17
13
|
* or an Avatar with a PresenceBadge.
|
18
14
|
*/
|
19
|
-
|
20
|
-
|
21
15
|
exports.Persona = /*#__PURE__*/React.forwardRef((props, ref) => {
|
22
16
|
const state = usePersona_1.usePersona_unstable(props, ref);
|
23
17
|
usePersonaStyles_1.usePersonaStyles_unstable(state);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAIA;;;;AAIaA,eAAO,gBAAsCC,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EACxF,MAAMC,KAAK,GAAGC,gCAAmB,CAACH,KAAK,EAAEC,GAAG,CAAC;EAE7CG,4CAAyB,CAACF,KAAK,CAAC;EAChC,OAAOG,sCAAsB,CAACH,KAAK,CAAC;AACtC,CAAC,CAAC;AAEFL,eAAO,CAACS,WAAW,GAAG,SAAS","names":["exports","React","forwardRef","props","ref","state","usePersona_1","usePersonaStyles_1","renderPersona_1","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"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
@@ -3,16 +3,10 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
8
|
-
|
9
7
|
tslib_1.__exportStar(require("./Persona"), exports);
|
10
|
-
|
11
8
|
tslib_1.__exportStar(require("./Persona.types"), exports);
|
12
|
-
|
13
9
|
tslib_1.__exportStar(require("./renderPersona"), exports);
|
14
|
-
|
15
10
|
tslib_1.__exportStar(require("./usePersona"), exports);
|
16
|
-
|
17
11
|
tslib_1.__exportStar(require("./usePersonaStyles"), exports);
|
18
12
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-persona/src/components/Persona/index.ts"],"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-persona/src/components/Persona/index.ts"],"sourcesContent":["export * from './Persona';\nexport * from './Persona.types';\nexport * from './renderPersona';\nexport * from './usePersona';\nexport * from './usePersonaStyles';\n"]}
|
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.renderPersona_unstable = void 0;
|
7
|
-
|
8
7
|
const React = /*#__PURE__*/require("react");
|
9
|
-
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
9
|
/**
|
12
10
|
* Render the final JSX of Persona
|
13
11
|
*/
|
14
|
-
|
15
|
-
|
16
12
|
const renderPersona_unstable = state => {
|
17
13
|
const {
|
18
14
|
presenceOnly,
|
@@ -22,16 +18,22 @@ const renderPersona_unstable = state => {
|
|
22
18
|
slots,
|
23
19
|
slotProps
|
24
20
|
} = react_utilities_1.getSlots(state);
|
25
|
-
const coin = presenceOnly ? slots.presence && React.createElement(slots.presence, {
|
26
|
-
|
21
|
+
const coin = presenceOnly ? slots.presence && React.createElement(slots.presence, {
|
22
|
+
...slotProps.presence
|
23
|
+
}) : slots.avatar && React.createElement(slots.avatar, {
|
24
|
+
...slotProps.avatar
|
27
25
|
});
|
28
|
-
return React.createElement(slots.root, {
|
29
|
-
|
30
|
-
}), slots.
|
31
|
-
|
32
|
-
}), slots.
|
26
|
+
return React.createElement(slots.root, {
|
27
|
+
...slotProps.root
|
28
|
+
}, (textPosition === 'after' || textPosition === 'below') && coin, slots.primaryText && React.createElement(slots.primaryText, {
|
29
|
+
...slotProps.primaryText
|
30
|
+
}), slots.secondaryText && React.createElement(slots.secondaryText, {
|
31
|
+
...slotProps.secondaryText
|
32
|
+
}), slots.tertiaryText && React.createElement(slots.tertiaryText, {
|
33
|
+
...slotProps.tertiaryText
|
34
|
+
}), slots.quaternaryText && React.createElement(slots.quaternaryText, {
|
35
|
+
...slotProps.quaternaryText
|
33
36
|
}), textPosition === 'before' && coin);
|
34
37
|
};
|
35
|
-
|
36
38
|
exports.renderPersona_unstable = renderPersona_unstable;
|
37
39
|
//# sourceMappingURL=renderPersona.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;AAGO,MAAMA,sBAAsB,GAAIC,KAAmB,IAAI;EAC5D,MAAM;IAAEC,YAAY;IAAEC;EAAY,CAAE,GAAGF,KAAK;EAC5C,MAAM;IAAEG,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAeL,KAAK,CAAC;EAE1D,MAAMM,IAAI,GAAGL,YAAY,GACrBE,KAAK,CAACI,QAAQ,IAAIC,oBAACL,KAAK,CAACI,QAAQ;IAAA,GAAKH,SAAS,CAACG;EAAQ,EAAI,GAC5DJ,KAAK,CAACM,MAAM,IAAID,oBAACL,KAAK,CAACM,MAAM;IAAA,GAAKL,SAAS,CAACK;EAAM,EAAI;EAE1D,OACED,oBAACL,KAAK,CAACO,IAAI;IAAA,GAAKN,SAAS,CAACM;EAAI,GAC3B,CAACR,YAAY,KAAK,OAAO,IAAIA,YAAY,KAAK,OAAO,KAAKI,IAAI,EAC9DH,KAAK,CAACQ,WAAW,IAAIH,oBAACL,KAAK,CAACQ,WAAW;IAAA,GAAKP,SAAS,CAACO;EAAW,EAAI,EACrER,KAAK,CAACS,aAAa,IAAIJ,oBAACL,KAAK,CAACS,aAAa;IAAA,GAAKR,SAAS,CAACQ;EAAa,EAAI,EAC3ET,KAAK,CAACU,YAAY,IAAIL,oBAACL,KAAK,CAACU,YAAY;IAAA,GAAKT,SAAS,CAACS;EAAY,EAAI,EACxEV,KAAK,CAACW,cAAc,IAAIN,oBAACL,KAAK,CAACW,cAAc;IAAA,GAAKV,SAAS,CAACU;EAAc,EAAI,EAC9EZ,YAAY,KAAK,QAAQ,IAAII,IAAI,CACvB;AAEjB,CAAC;AAlBYS,8BAAsB","names":["renderPersona_unstable","state","presenceOnly","textPosition","slots","slotProps","react_utilities_1","coin","presence","React","avatar","root","primaryText","secondaryText","tertiaryText","quaternaryText","exports"],"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"]}
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.usePersona_unstable = void 0;
|
7
|
-
|
8
7
|
const react_avatar_1 = /*#__PURE__*/require("@fluentui/react-avatar");
|
9
|
-
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
|
-
|
12
9
|
const react_badge_1 = /*#__PURE__*/require("@fluentui/react-badge");
|
13
10
|
/**
|
14
11
|
* Create the state required to render Persona.
|
@@ -19,8 +16,6 @@ const react_badge_1 = /*#__PURE__*/require("@fluentui/react-badge");
|
|
19
16
|
* @param props - props from this instance of Persona
|
20
17
|
* @param ref - reference to root HTMLElement of Persona
|
21
18
|
*/
|
22
|
-
|
23
|
-
|
24
19
|
const usePersona_unstable = (props, ref) => {
|
25
20
|
const {
|
26
21
|
name,
|
@@ -54,11 +49,10 @@ const usePersona_unstable = (props, ref) => {
|
|
54
49
|
tertiaryText: 'span',
|
55
50
|
quaternaryText: 'span'
|
56
51
|
},
|
57
|
-
root: react_utilities_1.getNativeElementProps('div', {
|
52
|
+
root: react_utilities_1.getNativeElementProps('div', {
|
53
|
+
...props,
|
58
54
|
ref
|
59
|
-
},
|
60
|
-
/* excludedPropNames */
|
61
|
-
['name']),
|
55
|
+
}, /* excludedPropNames */['name']),
|
62
56
|
avatar: !presenceOnly ? react_utilities_1.resolveShorthand(props.avatar, {
|
63
57
|
required: true,
|
64
58
|
defaultProps: {
|
@@ -78,7 +72,6 @@ const usePersona_unstable = (props, ref) => {
|
|
78
72
|
quaternaryText
|
79
73
|
};
|
80
74
|
};
|
81
|
-
|
82
75
|
exports.usePersona_unstable = usePersona_unstable;
|
83
76
|
const presenceSizes = {
|
84
77
|
'extra-small': 'tiny',
|