Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+1611
View File
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
@fluentui/react-persona
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
+19
View File
@@ -0,0 +1,19 @@
# @fluentui/react-persona
**React Persona components for [Fluent UI React](https://react.fluentui.dev/)**
## Usage
To import Persona:
```js
import { Persona } from '@fluentui/react-components';
```
### Examples
```jsx
const PersonaExample = () => {
return <Persona name="Kevin Sturgis" secondaryText="Software Engineer" />;
};
```
+122
View File
@@ -0,0 +1,122 @@
/// <reference types="react" />
import { Avatar } from '@fluentui/react-avatar';
import type { ComponentProps } from '@fluentui/react-utilities';
import type { ComponentState } from '@fluentui/react-utilities';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import { PresenceBadge } from '@fluentui/react-badge';
import * as React_2 from 'react';
import type { Slot } from '@fluentui/react-utilities';
import type { SlotClassNames } from '@fluentui/react-utilities';
/**
* A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,
* or an Avatar with a PresenceBadge.
*/
export declare const Persona: ForwardRefComponent<PersonaProps>;
export declare const personaClassNames: SlotClassNames<PersonaSlots>;
/**
* Persona Props
*/
export declare type PersonaProps = ComponentProps<PersonaSlots> & {
/**
* The name of the person or entity represented by the Persona.
*
* When `primaryText` is not provided, this will be used as the default value for `primaryText`.
*/
name?: string;
/**
* Whether to display only the presence.
*
* @default false
*/
presenceOnly?: boolean;
/**
* The size of a Persona and its text.
*
* @default medium
*/
size?: 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | 'huge';
/**
* The position of the text relative to the avatar/presence.
*
* @default after
*/
textPosition?: 'after' | 'before' | 'below';
/**
* The vertical alignment of the text relative to the avatar/presence.
*
* @default start
*/
textAlignment?: 'center' | 'start';
};
export declare type PersonaSlots = {
root: NonNullable<Slot<'div'>>;
/**
* Avatar to display.
*
* If a PresenceBadge and an Avatar are provided, the Avatar will display the PresenceBadge as its presence.
*/
avatar?: Slot<typeof Avatar>;
/**
* PresenceBadge to display.
*
* If `presenceOnly` is true, the PresenceBadge will be displayed instead of the Avatar.
*/
presence?: Slot<typeof PresenceBadge>;
/**
* The first line of text in the Persona, larger than the rest of the lines.
*
* `primaryText` defaults to the `name` prop. We recomend to only use `name`, use `primaryText` when the text is
* different than the `name` prop.
*/
primaryText?: Slot<'span'>;
/**
* The second line of text in the Persona.
*/
secondaryText?: Slot<'span'>;
/**
* The third line of text in the Persona.
*/
tertiaryText?: Slot<'span'>;
/**
* The fourth line of text in the Persona.
*/
quaternaryText?: Slot<'span'>;
};
/**
* State used in rendering Persona
*/
export declare type PersonaState = ComponentState<PersonaSlots> & Required<Pick<PersonaProps, 'presenceOnly' | 'size' | 'textAlignment' | 'textPosition'>> & {
/**
* The number of text lines used.
*/
numTextLines: number;
};
/**
* Render the final JSX of Persona
*/
export declare const renderPersona_unstable: (state: PersonaState) => JSX.Element;
/**
* Create the state required to render Persona.
*
* The returned state can be modified with hooks such as usePersonaStyles_unstable,
* before being passed to renderPersona_unstable.
*
* @param props - props from this instance of Persona
* @param ref - reference to root HTMLElement of Persona
*/
export declare const usePersona_unstable: (props: PersonaProps, ref: React_2.Ref<HTMLElement>) => PersonaState;
/**
* Apply styling to the Persona slots based on the state
*/
export declare const usePersonaStyles_unstable: (state: PersonaState) => PersonaState;
export { }
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
Persona: function() {
return _index.Persona;
},
personaClassNames: function() {
return _index.personaClassNames;
},
renderPersona_unstable: function() {
return _index.renderPersona_unstable;
},
usePersonaStyles_unstable: function() {
return _index.usePersonaStyles_unstable;
},
usePersona_unstable: function() {
return _index.usePersona_unstable;
}
});
const _index = require("./components/Persona/index");
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../src/Persona.ts"],"sourcesContent":["export type { PersonaProps, PersonaSlots, PersonaState } from './components/Persona/index';\nexport {\n Persona,\n personaClassNames,\n renderPersona_unstable,\n usePersonaStyles_unstable,\n usePersona_unstable,\n} from './components/Persona/index';\n"],"names":["Persona","personaClassNames","renderPersona_unstable","usePersonaStyles_unstable","usePersona_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAEEA,OAAO;eAAPA,cAAO;;IACPC,iBAAiB;eAAjBA,wBAAiB;;IACjBC,sBAAsB;eAAtBA,6BAAsB;;IACtBC,yBAAyB;eAAzBA,gCAAyB;;IACzBC,mBAAmB;eAAnBA,0BAAmB;;;uBACd"}
@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Persona", {
enumerable: true,
get: function() {
return Persona;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _renderPersona = require("./renderPersona");
const _usePersona = require("./usePersona");
const _usePersonaStylesstyles = require("./usePersonaStyles.styles");
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
const Persona = /*#__PURE__*/ _react.forwardRef((props, ref)=>{
const state = (0, _usePersona.usePersona_unstable)(props, ref);
(0, _usePersonaStylesstyles.usePersonaStyles_unstable)(state);
(0, _reactsharedcontexts.useCustomStyleHook_unstable)('usePersonaStyles_unstable')(state);
return (0, _renderPersona.renderPersona_unstable)(state);
});
Persona.displayName = 'Persona';
@@ -0,0 +1 @@
{"version":3,"sources":["../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.styles';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport type { PersonaProps } from './Persona.types';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\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\n useCustomStyleHook_unstable('usePersonaStyles_unstable')(state);\n\n return renderPersona_unstable(state);\n});\n\nPersona.displayName = 'Persona';\n"],"names":["Persona","React","forwardRef","props","ref","state","usePersona_unstable","usePersonaStyles_unstable","useCustomStyleHook_unstable","renderPersona_unstable","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAYaA;;;eAAAA;;;;iEAZU;+BACgB;4BACH;wCACM;qCAGE;AAMrC,MAAMA,UAAAA,WAAAA,GAA6CC,OAAMC,UAAU,CAAC,CAACC,OAAOC;IACjF,MAAMC,QAAQC,IAAAA,+BAAAA,EAAoBH,OAAOC;IAEzCG,IAAAA,iDAAAA,EAA0BF;IAE1BG,IAAAA,gDAAAA,EAA4B,6BAA6BH;IAEzD,OAAOI,IAAAA,qCAAAA,EAAuBJ;AAChC;AAEAL,QAAQU,WAAW,GAAG"}
@@ -0,0 +1,6 @@
/**
* State used in rendering Persona
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Persona/Persona.types.ts"],"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"],"names":[],"rangeMappings":";;","mappings":"AAqFA;;CAEC"}
@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
Persona: function() {
return _Persona.Persona;
},
personaClassNames: function() {
return _usePersonaStylesstyles.personaClassNames;
},
renderPersona_unstable: function() {
return _renderPersona.renderPersona_unstable;
},
usePersonaStyles_unstable: function() {
return _usePersonaStylesstyles.usePersonaStyles_unstable;
},
usePersona_unstable: function() {
return _usePersona.usePersona_unstable;
}
});
const _Persona = require("./Persona");
const _renderPersona = require("./renderPersona");
const _usePersona = require("./usePersona");
const _usePersonaStylesstyles = require("./usePersonaStyles.styles");
@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Persona/index.ts"],"sourcesContent":["export { Persona } from './Persona';\nexport type { PersonaProps, PersonaSlots, PersonaState } from './Persona.types';\nexport { renderPersona_unstable } from './renderPersona';\nexport { usePersona_unstable } from './usePersona';\nexport { personaClassNames, usePersonaStyles_unstable } from './usePersonaStyles.styles';\n"],"names":["Persona","personaClassNames","renderPersona_unstable","usePersonaStyles_unstable","usePersona_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAASA,OAAO;eAAPA,gBAAO;;IAIPC,iBAAiB;eAAjBA,yCAAiB;;IAFjBC,sBAAsB;eAAtBA,qCAAsB;;IAEHC,yBAAyB;eAAzBA,iDAAyB;;IAD5CC,mBAAmB;eAAnBA,+BAAmB;;;yBAHJ;+BAEe;4BACH;wCACyB"}
@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "renderPersona_unstable", {
enumerable: true,
get: function() {
return renderPersona_unstable;
}
});
const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
const _reactutilities = require("@fluentui/react-utilities");
const renderPersona_unstable = (state)=>{
const { presenceOnly, textPosition } = state;
(0, _reactutilities.assertSlots)(state);
const coin = presenceOnly ? state.presence && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.presence, {}) : state.avatar && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.avatar, {});
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.root, {
children: [
(textPosition === 'after' || textPosition === 'below') && coin,
state.primaryText && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.primaryText, {}),
state.secondaryText && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.secondaryText, {}),
state.tertiaryText && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.tertiaryText, {}),
state.quaternaryText && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.quaternaryText, {}),
textPosition === 'before' && coin
]
});
};
@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Persona/renderPersona.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } 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 assertSlots<PersonaSlots>(state);\n\n const coin = presenceOnly ? state.presence && <state.presence /> : state.avatar && <state.avatar />;\n\n return (\n <state.root>\n {(textPosition === 'after' || textPosition === 'below') && coin}\n {state.primaryText && <state.primaryText />}\n {state.secondaryText && <state.secondaryText />}\n {state.tertiaryText && <state.tertiaryText />}\n {state.quaternaryText && <state.quaternaryText />}\n {textPosition === 'before' && coin}\n </state.root>\n );\n};\n"],"names":["renderPersona_unstable","state","presenceOnly","textPosition","assertSlots","coin","presence","_jsx","avatar","_jsxs","root","primaryText","secondaryText","tertiaryText","quaternaryText"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BASaA;;;eAAAA;;;4BARb;gCAE4B;AAMrB,MAAMA,yBAAyB,CAACC;IACrC,MAAM,EAAEC,YAAY,EAAEC,YAAY,EAAE,GAAGF;IACvCG,IAAAA,2BAAAA,EAA0BH;IAE1B,MAAMI,OAAOH,eAAeD,MAAMK,QAAQ,IAAA,WAAA,GAAIC,IAAAA,eAAA,EAACN,MAAMK,QAAQ,EAAA,CAAA,KAAML,MAAMO,MAAM,IAAA,WAAA,GAAID,IAAAA,eAAA,EAACN,MAAMO,MAAM,EAAA,CAAA;IAEhG,OAAA,WAAA,GACEC,IAAAA,gBAAA,EAACR,MAAMS,IAAI,EAAA;;YACPP,CAAAA,iBAAiB,WAAWA,iBAAiB,OAAA,KAAYE;YAC1DJ,MAAMU,WAAW,IAAA,WAAA,GAAIJ,IAAAA,eAAA,EAACN,MAAMU,WAAW,EAAA,CAAA;YACvCV,MAAMW,aAAa,IAAA,WAAA,GAAIL,IAAAA,eAAA,EAACN,MAAMW,aAAa,EAAA,CAAA;YAC3CX,MAAMY,YAAY,IAAA,WAAA,GAAIN,IAAAA,eAAA,EAACN,MAAMY,YAAY,EAAA,CAAA;YACzCZ,MAAMa,cAAc,IAAA,WAAA,GAAIP,IAAAA,eAAA,EAACN,MAAMa,cAAc,EAAA,CAAA;YAC7CX,iBAAiB,YAAYE;;;AAGpC"}
@@ -0,0 +1,102 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "usePersona_unstable", {
enumerable: true,
get: function() {
return usePersona_unstable;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _reactavatar = require("@fluentui/react-avatar");
const _reactutilities = require("@fluentui/react-utilities");
const _reactbadge = require("@fluentui/react-badge");
const usePersona_unstable = (props, ref)=>{
const { name, presenceOnly = false, size = 'medium', textAlignment = 'start', textPosition = 'after' } = props;
const primaryText = _reactutilities.slot.optional(props.primaryText, {
renderByDefault: true,
defaultProps: {
children: name
},
elementType: 'span'
});
const secondaryText = _reactutilities.slot.optional(props.secondaryText, {
elementType: 'span'
});
const tertiaryText = _reactutilities.slot.optional(props.tertiaryText, {
elementType: 'span'
});
const quaternaryText = _reactutilities.slot.optional(props.quaternaryText, {
elementType: 'span'
});
const numTextLines = [
primaryText,
secondaryText,
tertiaryText,
quaternaryText
].filter(Boolean).length;
return {
numTextLines,
presenceOnly,
size,
textAlignment,
textPosition,
components: {
root: 'div',
avatar: _reactavatar.Avatar,
presence: _reactbadge.PresenceBadge,
primaryText: 'span',
secondaryText: 'span',
tertiaryText: 'span',
quaternaryText: 'span'
},
root: _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', {
...props,
// FIXME:
// `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
// but since it would be a breaking change to fix it, we are casting ref to it's proper type
ref: ref
}, /* excludedPropNames */ [
'name'
]), {
elementType: 'div'
}),
avatar: !presenceOnly ? _reactutilities.slot.optional(props.avatar, {
renderByDefault: true,
defaultProps: {
name,
badge: props.presence,
size: avatarSizes[size]
},
elementType: _reactavatar.Avatar
}) : undefined,
presence: presenceOnly ? _reactutilities.slot.optional(props.presence, {
defaultProps: {
size: presenceSizes[size]
},
elementType: _reactbadge.PresenceBadge
}) : undefined,
primaryText,
secondaryText,
tertiaryText,
quaternaryText
};
};
const presenceSizes = {
'extra-small': 'tiny',
small: 'extra-small',
medium: 'small',
large: 'medium',
'extra-large': 'large',
huge: 'large'
};
const avatarSizes = {
'extra-small': 20,
small: 28,
medium: 32,
large: 36,
'extra-large': 40,
huge: 56
};
File diff suppressed because one or more lines are too long
@@ -0,0 +1,273 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
personaClassNames: function() {
return personaClassNames;
},
usePersonaStyles_unstable: function() {
return usePersonaStyles_unstable;
}
});
const _react = require("@griffel/react");
const personaClassNames = {
root: 'fui-Persona',
avatar: 'fui-Persona__avatar',
presence: 'fui-Persona__presence',
primaryText: 'fui-Persona__primaryText',
secondaryText: 'fui-Persona__secondaryText',
tertiaryText: 'fui-Persona__tertiaryText',
quaternaryText: 'fui-Persona__quaternaryText'
};
const avatarSpacing = `--fui-Persona__avatar--spacing`;
const useRootClassName = /*#__PURE__*/ (0, _react.__resetStyles)("rlroi9i", null, [
".rlroi9i{display:inline-grid;grid-auto-rows:max-content;grid-auto-flow:column;justify-items:start;grid-template-columns:max-content [middle] auto;}"
]);
/**
* Styles for the root slot
*/ const useStyles = /*#__PURE__*/ (0, _react.__styles)({
beforeAfterCenter: {
wkccdc: "f1iantul"
},
after: {},
before: {
B7hvi0a: "f1tll2w5",
Budl1dq: "ffvkwdr"
},
below: {
Bxotwcr: "f1nkeedh",
B7hvi0a: "f1oiokrs",
Budl1dq: "f1emgwh2"
},
media: {
Ijaq50: "f1hek2iy"
},
mediaBeforeAfterCenter: {
Ijaq50: "fa4dipu"
},
start: {
qb2dma: "f9h729m"
},
center: {
qb2dma: "f7nlbp4"
},
afterAlignToPrimary: {
qb2dma: "f7nlbp4",
Ijaq50: "f1rnkkuc",
Bw0ie65: "f1warjpf"
},
beforeAlignToPrimary: {
qb2dma: "f7nlbp4",
Ijaq50: "f1rnkkuc",
Br312pm: "fwu52yu"
},
secondLineSpacing: {
B6of3ja: "f1ryq6si"
},
primary: {
Ijaq50: "f1q3ipgb"
},
secondary: {
Ijaq50: "f3drtdk"
},
tertiary: {
Ijaq50: "fa1o6s1"
},
quaternary: {
Ijaq50: "f1tuwaia"
}
}, {
d: [
".f1iantul{grid-template-rows:1fr [primary] max-content [secondary] max-content [tertiary] max-content [quaternary] max-content 1fr;}",
".f1tll2w5{justify-items:end;}",
".ffvkwdr{grid-template-columns:auto [middle] max-content;}",
".f1nkeedh{grid-auto-flow:unset;}",
".f1oiokrs{justify-items:center;}",
".f1emgwh2{grid-template-columns:unset;}",
".f1hek2iy{grid-row-start:span 5;}",
".fa4dipu{grid-row-start:span 6;}",
".f9h729m{align-self:start;}",
".f7nlbp4{align-self:center;}",
".f1rnkkuc{grid-row-start:unset;}",
".f1warjpf{grid-column-end:middle;}",
".fwu52yu{grid-column-start:middle;}",
".f1ryq6si{margin-top:-2px;}",
".f1q3ipgb{grid-row-start:primary;}",
".f3drtdk{grid-row-start:secondary;}",
".fa1o6s1{grid-row-start:tertiary;}",
".f1tuwaia{grid-row-start:quaternary;}"
]
});
const useAvatarSpacingStyles = /*#__PURE__*/ (0, _react.__styles)({
"extra-small": {
Bs1gm4r: "f1e48tse"
},
small: {
Bs1gm4r: "f18q9vkd"
},
medium: {
Bs1gm4r: "f18q9vkd"
},
large: {
Bs1gm4r: "fx34bi6"
},
"extra-large": {
Bs1gm4r: "fx34bi6"
},
huge: {
Bs1gm4r: "f1o96qtm"
},
after: {
t21cq0: [
"f103ycu4",
"f1tao51"
]
},
below: {
jrapky: "fbo7acy"
},
before: {
Frg6f3: [
"f1tao51",
"f103ycu4"
]
}
}, {
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);}"
]
});
const usePresenceSpacingStyles = /*#__PURE__*/ (0, _react.__styles)({
small: {
Bs1gm4r: "f1e48tse"
}
}, {
d: [
".f1e48tse{--fui-Persona__avatar--spacing:var(--spacingHorizontalSNudge);}"
]
});
const usePersonaStyles_unstable = (state)=>{
'use no memo';
const { presenceOnly, size, textAlignment, textPosition } = state;
const alignToPrimary = presenceOnly && textAlignment === 'start' && size !== 'extra-large' && size !== 'huge';
const alignBeforeAfterCenter = textPosition !== 'below' && textAlignment === 'center';
const { primaryTextClassName, optionalTextClassName } = useTextClassNames(state, alignToPrimary);
const rootClassName = useRootClassName();
const styles = useStyles();
const avatarSpacingStyles = useAvatarSpacingStyles();
const presenceSpacingStyles = {
...avatarSpacingStyles,
...usePresenceSpacingStyles()
};
state.root.className = (0, _react.mergeClasses)(personaClassNames.root, rootClassName, alignBeforeAfterCenter && styles.beforeAfterCenter, styles[textPosition], state.root.className);
if (state.avatar) {
state.avatar.className = (0, _react.mergeClasses)(personaClassNames.avatar, textPosition !== 'below' && styles.media, alignBeforeAfterCenter && styles.mediaBeforeAfterCenter, styles[textAlignment], avatarSpacingStyles[size], avatarSpacingStyles[textPosition], state.avatar.className);
}
if (state.presence) {
state.presence.className = (0, _react.mergeClasses)(personaClassNames.presence, textPosition !== 'below' && styles.media, alignBeforeAfterCenter && styles.mediaBeforeAfterCenter, styles[textAlignment], presenceSpacingStyles[size], presenceSpacingStyles[textPosition], textPosition === 'after' && alignToPrimary && styles.afterAlignToPrimary, textPosition === 'before' && alignToPrimary && styles.beforeAlignToPrimary, state.presence.className);
}
if (state.primaryText) {
state.primaryText.className = (0, _react.mergeClasses)(personaClassNames.primaryText, alignBeforeAfterCenter && styles.primary, primaryTextClassName, state.primaryText.className);
}
if (state.secondaryText) {
state.secondaryText.className = (0, _react.mergeClasses)(personaClassNames.secondaryText, alignBeforeAfterCenter && styles.secondary, optionalTextClassName, styles.secondLineSpacing, state.secondaryText.className);
}
if (state.tertiaryText) {
state.tertiaryText.className = (0, _react.mergeClasses)(personaClassNames.tertiaryText, alignBeforeAfterCenter && styles.tertiary, optionalTextClassName, state.tertiaryText.className);
}
if (state.quaternaryText) {
state.quaternaryText.className = (0, _react.mergeClasses)(personaClassNames.quaternaryText, alignBeforeAfterCenter && styles.quaternary, optionalTextClassName, state.quaternaryText.className);
}
return state;
};
const usePrimaryTextBaseClassName = /*#__PURE__*/ (0, _react.__resetStyles)("rvj41k9", null, [
".rvj41k9{display:block;color:var(--colorNeutralForeground1);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase300);}"
]);
const useOptionalTextBaseClassName = /*#__PURE__*/ (0, _react.__resetStyles)("rp1pf9e", null, [
".rp1pf9e{display:block;color:var(--colorNeutralForeground2);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase200);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase200);}"
]);
const useTextStyles = /*#__PURE__*/ (0, _react.__styles)({
beforeAlignToPrimary: {
Bw0ie65: "f1warjpf"
},
afterAlignToPrimary: {
Br312pm: "fwu52yu"
},
body1: {
Bahqtrf: "fk6fouc",
Be2twd7: "fkhj508",
Bhrd7zp: "figsok6",
Bg96gwp: "f1i3iumi"
},
caption1: {
Bahqtrf: "fk6fouc",
Be2twd7: "fy9rknc",
Bhrd7zp: "figsok6",
Bg96gwp: "fwrc4pm"
},
subtitle2: {
Bahqtrf: "fk6fouc",
Be2twd7: "fod5ikn",
Bhrd7zp: "fl43uef",
Bg96gwp: "faaz57k"
}
}, {
d: [
".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);}"
]
});
const useTextClassNames = (state, alignToPrimary)=>{
const { presenceOnly, size, textPosition } = state;
const primaryTextBaseClassName = usePrimaryTextBaseClassName();
const optionalTextBaseClassName = useOptionalTextBaseClassName();
const textStyles = useTextStyles();
let primaryTextSize;
let alignToPrimaryClassName;
if (presenceOnly) {
if (size === 'extra-small') {
primaryTextSize = state.numTextLines <= 1 && textStyles.caption1;
} else if (size === 'extra-large' || size === 'huge') {
primaryTextSize = textStyles.subtitle2;
}
if (alignToPrimary) {
if (textPosition === 'before') {
alignToPrimaryClassName = textStyles.beforeAlignToPrimary;
} else if (textPosition === 'after') {
alignToPrimaryClassName = textStyles.afterAlignToPrimary;
}
}
} else {
if (size === 'huge') {
primaryTextSize = textStyles.subtitle2;
} else if (size === 'extra-large') {
primaryTextSize = textStyles.subtitle2;
}
}
return {
primaryTextClassName: (0, _react.mergeClasses)(primaryTextBaseClassName, primaryTextSize, alignToPrimaryClassName),
optionalTextClassName: (0, _react.mergeClasses)(optionalTextBaseClassName, !presenceOnly && size === 'huge' && textStyles.body1, alignToPrimaryClassName)
};
};
File diff suppressed because one or more lines are too long
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
Persona: function() {
return _Persona.Persona;
},
personaClassNames: function() {
return _Persona.personaClassNames;
},
renderPersona_unstable: function() {
return _Persona.renderPersona_unstable;
},
usePersonaStyles_unstable: function() {
return _Persona.usePersonaStyles_unstable;
},
usePersona_unstable: function() {
return _Persona.usePersona_unstable;
}
});
const _Persona = require("./Persona");
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../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"],"names":["Persona","personaClassNames","renderPersona_unstable","usePersonaStyles_unstable","usePersona_unstable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IACEA,OAAO;eAAPA,gBAAO;;IACPC,iBAAiB;eAAjBA,0BAAiB;;IACjBC,sBAAsB;eAAtBA,+BAAsB;;IACtBC,yBAAyB;eAAzBA,kCAAyB;;IACzBC,mBAAmB;eAAnBA,4BAAmB;;;yBACd"}
+1
View File
@@ -0,0 +1 @@
export { Persona, personaClassNames, renderPersona_unstable, usePersonaStyles_unstable, usePersona_unstable } from './components/Persona/index';
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../src/Persona.ts"],"sourcesContent":["export type { PersonaProps, PersonaSlots, PersonaState } from './components/Persona/index';\nexport {\n Persona,\n personaClassNames,\n renderPersona_unstable,\n usePersonaStyles_unstable,\n usePersona_unstable,\n} from './components/Persona/index';\n"],"names":["Persona","personaClassNames","renderPersona_unstable","usePersonaStyles_unstable","usePersona_unstable"],"rangeMappings":"","mappings":"AACA,SACEA,OAAO,EACPC,iBAAiB,EACjBC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,6BAA6B"}
+15
View File
@@ -0,0 +1,15 @@
import * as React from 'react';
import { renderPersona_unstable } from './renderPersona';
import { usePersona_unstable } from './usePersona';
import { usePersonaStyles_unstable } from './usePersonaStyles.styles';
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
/**
* A Persona is a visual representation of a person or status that showcases an Avatar, PresenceBadge,
* or an Avatar with a PresenceBadge.
*/ export const Persona = /*#__PURE__*/ React.forwardRef((props, ref)=>{
const state = usePersona_unstable(props, ref);
usePersonaStyles_unstable(state);
useCustomStyleHook_unstable('usePersonaStyles_unstable')(state);
return renderPersona_unstable(state);
});
Persona.displayName = 'Persona';
@@ -0,0 +1 @@
{"version":3,"sources":["../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.styles';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport type { PersonaProps } from './Persona.types';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\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\n useCustomStyleHook_unstable('usePersonaStyles_unstable')(state);\n\n return renderPersona_unstable(state);\n});\n\nPersona.displayName = 'Persona';\n"],"names":["React","renderPersona_unstable","usePersona_unstable","usePersonaStyles_unstable","useCustomStyleHook_unstable","Persona","forwardRef","props","ref","state","displayName"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,mBAAmB,QAAQ,eAAe;AACnD,SAASC,yBAAyB,QAAQ,4BAA4B;AAGtE,SAASC,2BAA2B,QAAQ,kCAAkC;AAE9E;;;CAGC,GACD,OAAO,MAAMC,wBAA6CL,MAAMM,UAAU,CAAC,CAACC,OAAOC;IACjF,MAAMC,QAAQP,oBAAoBK,OAAOC;IAEzCL,0BAA0BM;IAE1BL,4BAA4B,6BAA6BK;IAEzD,OAAOR,uBAAuBQ;AAChC,GAAG;AAEHJ,QAAQK,WAAW,GAAG"}
@@ -0,0 +1,3 @@
/**
* State used in rendering Persona
*/ export { };
@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Persona/Persona.types.ts"],"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"],"names":[],"rangeMappings":";;","mappings":"AAqFA;;CAEC,GACD,WAMI"}
+4
View File
@@ -0,0 +1,4 @@
export { Persona } from './Persona';
export { renderPersona_unstable } from './renderPersona';
export { usePersona_unstable } from './usePersona';
export { personaClassNames, usePersonaStyles_unstable } from './usePersonaStyles.styles';
@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Persona/index.ts"],"sourcesContent":["export { Persona } from './Persona';\nexport type { PersonaProps, PersonaSlots, PersonaState } from './Persona.types';\nexport { renderPersona_unstable } from './renderPersona';\nexport { usePersona_unstable } from './usePersona';\nexport { personaClassNames, usePersonaStyles_unstable } from './usePersonaStyles.styles';\n"],"names":["Persona","renderPersona_unstable","usePersona_unstable","personaClassNames","usePersonaStyles_unstable"],"rangeMappings":";;;","mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AAEpC,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,mBAAmB,QAAQ,eAAe;AACnD,SAASC,iBAAiB,EAAEC,yBAAyB,QAAQ,4BAA4B"}
@@ -0,0 +1,19 @@
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
import { assertSlots } from '@fluentui/react-utilities';
/**
* Render the final JSX of Persona
*/ export const renderPersona_unstable = (state)=>{
const { presenceOnly, textPosition } = state;
assertSlots(state);
const coin = presenceOnly ? state.presence && /*#__PURE__*/ _jsx(state.presence, {}) : state.avatar && /*#__PURE__*/ _jsx(state.avatar, {});
return /*#__PURE__*/ _jsxs(state.root, {
children: [
(textPosition === 'after' || textPosition === 'below') && coin,
state.primaryText && /*#__PURE__*/ _jsx(state.primaryText, {}),
state.secondaryText && /*#__PURE__*/ _jsx(state.secondaryText, {}),
state.tertiaryText && /*#__PURE__*/ _jsx(state.tertiaryText, {}),
state.quaternaryText && /*#__PURE__*/ _jsx(state.quaternaryText, {}),
textPosition === 'before' && coin
]
});
};
@@ -0,0 +1 @@
{"version":3,"sources":["../src/components/Persona/renderPersona.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } 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 assertSlots<PersonaSlots>(state);\n\n const coin = presenceOnly ? state.presence && <state.presence /> : state.avatar && <state.avatar />;\n\n return (\n <state.root>\n {(textPosition === 'after' || textPosition === 'below') && coin}\n {state.primaryText && <state.primaryText />}\n {state.secondaryText && <state.secondaryText />}\n {state.tertiaryText && <state.tertiaryText />}\n {state.quaternaryText && <state.quaternaryText />}\n {textPosition === 'before' && coin}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderPersona_unstable","state","presenceOnly","textPosition","coin","presence","avatar","root","primaryText","secondaryText","tertiaryText","quaternaryText"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD;;CAEC,GACD,OAAO,MAAMC,yBAAyB,CAACC;IACrC,MAAM,EAAEC,YAAY,EAAEC,YAAY,EAAE,GAAGF;IACvCF,YAA0BE;IAE1B,MAAMG,OAAOF,eAAeD,MAAMI,QAAQ,kBAAI,KAACJ,MAAMI,QAAQ,QAAMJ,MAAMK,MAAM,kBAAI,KAACL,MAAMK,MAAM;IAEhG,qBACE,MAACL,MAAMM,IAAI;;YACPJ,CAAAA,iBAAiB,WAAWA,iBAAiB,OAAM,KAAMC;YAC1DH,MAAMO,WAAW,kBAAI,KAACP,MAAMO,WAAW;YACvCP,MAAMQ,aAAa,kBAAI,KAACR,MAAMQ,aAAa;YAC3CR,MAAMS,YAAY,kBAAI,KAACT,MAAMS,YAAY;YACzCT,MAAMU,cAAc,kBAAI,KAACV,MAAMU,cAAc;YAC7CR,iBAAiB,YAAYC;;;AAGpC,EAAE"}
@@ -0,0 +1,99 @@
import * as React from 'react';
import { Avatar } from '@fluentui/react-avatar';
import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
import { PresenceBadge } from '@fluentui/react-badge';
/**
* Create the state required to render Persona.
*
* The returned state can be modified with hooks such as usePersonaStyles_unstable,
* before being passed to renderPersona_unstable.
*
* @param props - props from this instance of Persona
* @param ref - reference to root HTMLElement of Persona
*/ export const usePersona_unstable = (props, ref)=>{
const { name, presenceOnly = false, size = 'medium', textAlignment = 'start', textPosition = 'after' } = props;
const primaryText = slot.optional(props.primaryText, {
renderByDefault: true,
defaultProps: {
children: name
},
elementType: 'span'
});
const secondaryText = slot.optional(props.secondaryText, {
elementType: 'span'
});
const tertiaryText = slot.optional(props.tertiaryText, {
elementType: 'span'
});
const quaternaryText = slot.optional(props.quaternaryText, {
elementType: 'span'
});
const numTextLines = [
primaryText,
secondaryText,
tertiaryText,
quaternaryText
].filter(Boolean).length;
return {
numTextLines,
presenceOnly,
size,
textAlignment,
textPosition,
components: {
root: 'div',
avatar: Avatar,
presence: PresenceBadge,
primaryText: 'span',
secondaryText: 'span',
tertiaryText: 'span',
quaternaryText: 'span'
},
root: slot.always(getIntrinsicElementProps('div', {
...props,
// FIXME:
// `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
// but since it would be a breaking change to fix it, we are casting ref to it's proper type
ref: ref
}, /* excludedPropNames */ [
'name'
]), {
elementType: 'div'
}),
avatar: !presenceOnly ? slot.optional(props.avatar, {
renderByDefault: true,
defaultProps: {
name,
badge: props.presence,
size: avatarSizes[size]
},
elementType: Avatar
}) : undefined,
presence: presenceOnly ? slot.optional(props.presence, {
defaultProps: {
size: presenceSizes[size]
},
elementType: PresenceBadge
}) : undefined,
primaryText,
secondaryText,
tertiaryText,
quaternaryText
};
};
const presenceSizes = {
'extra-small': 'tiny',
small: 'extra-small',
medium: 'small',
large: 'medium',
'extra-large': 'large',
huge: 'large'
};
const avatarSizes = {
'extra-small': 20,
small: 28,
medium: 32,
large: 36,
'extra-large': 40,
huge: 56
};
File diff suppressed because one or more lines are too long
@@ -0,0 +1,220 @@
import { __resetStyles, __styles, mergeClasses } from '@griffel/react';
import { tokens, typographyStyles } from '@fluentui/react-theme';
export const personaClassNames = {
root: 'fui-Persona',
avatar: 'fui-Persona__avatar',
presence: 'fui-Persona__presence',
primaryText: 'fui-Persona__primaryText',
secondaryText: 'fui-Persona__secondaryText',
tertiaryText: 'fui-Persona__tertiaryText',
quaternaryText: 'fui-Persona__quaternaryText'
};
const avatarSpacing = `--fui-Persona__avatar--spacing`;
const useRootClassName = /*#__PURE__*/__resetStyles("rlroi9i", null, [".rlroi9i{display:inline-grid;grid-auto-rows:max-content;grid-auto-flow:column;justify-items:start;grid-template-columns:max-content [middle] auto;}"]);
/**
* Styles for the root slot
*/
const useStyles = /*#__PURE__*/__styles({
beforeAfterCenter: {
wkccdc: "f1iantul"
},
after: {},
before: {
B7hvi0a: "f1tll2w5",
Budl1dq: "ffvkwdr"
},
below: {
Bxotwcr: "f1nkeedh",
B7hvi0a: "f1oiokrs",
Budl1dq: "f1emgwh2"
},
media: {
Ijaq50: "f1hek2iy"
},
mediaBeforeAfterCenter: {
Ijaq50: "fa4dipu"
},
start: {
qb2dma: "f9h729m"
},
center: {
qb2dma: "f7nlbp4"
},
afterAlignToPrimary: {
qb2dma: "f7nlbp4",
Ijaq50: "f1rnkkuc",
Bw0ie65: "f1warjpf"
},
beforeAlignToPrimary: {
qb2dma: "f7nlbp4",
Ijaq50: "f1rnkkuc",
Br312pm: "fwu52yu"
},
secondLineSpacing: {
B6of3ja: "f1ryq6si"
},
primary: {
Ijaq50: "f1q3ipgb"
},
secondary: {
Ijaq50: "f3drtdk"
},
tertiary: {
Ijaq50: "fa1o6s1"
},
quaternary: {
Ijaq50: "f1tuwaia"
}
}, {
d: [".f1iantul{grid-template-rows:1fr [primary] max-content [secondary] max-content [tertiary] max-content [quaternary] max-content 1fr;}", ".f1tll2w5{justify-items:end;}", ".ffvkwdr{grid-template-columns:auto [middle] max-content;}", ".f1nkeedh{grid-auto-flow:unset;}", ".f1oiokrs{justify-items:center;}", ".f1emgwh2{grid-template-columns:unset;}", ".f1hek2iy{grid-row-start:span 5;}", ".fa4dipu{grid-row-start:span 6;}", ".f9h729m{align-self:start;}", ".f7nlbp4{align-self:center;}", ".f1rnkkuc{grid-row-start:unset;}", ".f1warjpf{grid-column-end:middle;}", ".fwu52yu{grid-column-start:middle;}", ".f1ryq6si{margin-top:-2px;}", ".f1q3ipgb{grid-row-start:primary;}", ".f3drtdk{grid-row-start:secondary;}", ".fa1o6s1{grid-row-start:tertiary;}", ".f1tuwaia{grid-row-start:quaternary;}"]
});
const useAvatarSpacingStyles = /*#__PURE__*/__styles({
"extra-small": {
Bs1gm4r: "f1e48tse"
},
small: {
Bs1gm4r: "f18q9vkd"
},
medium: {
Bs1gm4r: "f18q9vkd"
},
large: {
Bs1gm4r: "fx34bi6"
},
"extra-large": {
Bs1gm4r: "fx34bi6"
},
huge: {
Bs1gm4r: "f1o96qtm"
},
after: {
t21cq0: ["f103ycu4", "f1tao51"]
},
below: {
jrapky: "fbo7acy"
},
before: {
Frg6f3: ["f1tao51", "f103ycu4"]
}
}, {
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);}"]
});
const usePresenceSpacingStyles = /*#__PURE__*/__styles({
small: {
Bs1gm4r: "f1e48tse"
}
}, {
d: [".f1e48tse{--fui-Persona__avatar--spacing:var(--spacingHorizontalSNudge);}"]
});
/**
* Apply styling to the Persona slots based on the state
*/
export const usePersonaStyles_unstable = state => {
'use no memo';
const {
presenceOnly,
size,
textAlignment,
textPosition
} = state;
const alignToPrimary = presenceOnly && textAlignment === 'start' && size !== 'extra-large' && size !== 'huge';
const alignBeforeAfterCenter = textPosition !== 'below' && textAlignment === 'center';
const {
primaryTextClassName,
optionalTextClassName
} = useTextClassNames(state, alignToPrimary);
const rootClassName = useRootClassName();
const styles = useStyles();
const avatarSpacingStyles = useAvatarSpacingStyles();
const presenceSpacingStyles = {
...avatarSpacingStyles,
...usePresenceSpacingStyles()
};
state.root.className = mergeClasses(personaClassNames.root, rootClassName, alignBeforeAfterCenter && styles.beforeAfterCenter, styles[textPosition], state.root.className);
if (state.avatar) {
state.avatar.className = mergeClasses(personaClassNames.avatar, textPosition !== 'below' && styles.media, alignBeforeAfterCenter && styles.mediaBeforeAfterCenter, styles[textAlignment], avatarSpacingStyles[size], avatarSpacingStyles[textPosition], state.avatar.className);
}
if (state.presence) {
state.presence.className = mergeClasses(personaClassNames.presence, textPosition !== 'below' && styles.media, alignBeforeAfterCenter && styles.mediaBeforeAfterCenter, styles[textAlignment], presenceSpacingStyles[size], presenceSpacingStyles[textPosition], textPosition === 'after' && alignToPrimary && styles.afterAlignToPrimary, textPosition === 'before' && alignToPrimary && styles.beforeAlignToPrimary, state.presence.className);
}
if (state.primaryText) {
state.primaryText.className = mergeClasses(personaClassNames.primaryText, alignBeforeAfterCenter && styles.primary, primaryTextClassName, state.primaryText.className);
}
if (state.secondaryText) {
state.secondaryText.className = mergeClasses(personaClassNames.secondaryText, alignBeforeAfterCenter && styles.secondary, optionalTextClassName, styles.secondLineSpacing, state.secondaryText.className);
}
if (state.tertiaryText) {
state.tertiaryText.className = mergeClasses(personaClassNames.tertiaryText, alignBeforeAfterCenter && styles.tertiary, optionalTextClassName, state.tertiaryText.className);
}
if (state.quaternaryText) {
state.quaternaryText.className = mergeClasses(personaClassNames.quaternaryText, alignBeforeAfterCenter && styles.quaternary, optionalTextClassName, state.quaternaryText.className);
}
return state;
};
const usePrimaryTextBaseClassName = /*#__PURE__*/__resetStyles("rvj41k9", null, [".rvj41k9{display:block;color:var(--colorNeutralForeground1);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase300);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase300);}"]);
const useOptionalTextBaseClassName = /*#__PURE__*/__resetStyles("rp1pf9e", null, [".rp1pf9e{display:block;color:var(--colorNeutralForeground2);font-family:var(--fontFamilyBase);font-size:var(--fontSizeBase200);font-weight:var(--fontWeightRegular);line-height:var(--lineHeightBase200);}"]);
const useTextStyles = /*#__PURE__*/__styles({
beforeAlignToPrimary: {
Bw0ie65: "f1warjpf"
},
afterAlignToPrimary: {
Br312pm: "fwu52yu"
},
body1: {
Bahqtrf: "fk6fouc",
Be2twd7: "fkhj508",
Bhrd7zp: "figsok6",
Bg96gwp: "f1i3iumi"
},
caption1: {
Bahqtrf: "fk6fouc",
Be2twd7: "fy9rknc",
Bhrd7zp: "figsok6",
Bg96gwp: "fwrc4pm"
},
subtitle2: {
Bahqtrf: "fk6fouc",
Be2twd7: "fod5ikn",
Bhrd7zp: "fl43uef",
Bg96gwp: "faaz57k"
}
}, {
d: [".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);}"]
});
const useTextClassNames = (state, alignToPrimary) => {
const {
presenceOnly,
size,
textPosition
} = state;
const primaryTextBaseClassName = usePrimaryTextBaseClassName();
const optionalTextBaseClassName = useOptionalTextBaseClassName();
const textStyles = useTextStyles();
let primaryTextSize;
let alignToPrimaryClassName;
if (presenceOnly) {
if (size === 'extra-small') {
primaryTextSize = state.numTextLines <= 1 && textStyles.caption1;
} else if (size === 'extra-large' || size === 'huge') {
primaryTextSize = textStyles.subtitle2;
}
if (alignToPrimary) {
if (textPosition === 'before') {
alignToPrimaryClassName = textStyles.beforeAlignToPrimary;
} else if (textPosition === 'after') {
alignToPrimaryClassName = textStyles.afterAlignToPrimary;
}
}
} else {
if (size === 'huge') {
primaryTextSize = textStyles.subtitle2;
} else if (size === 'extra-large') {
primaryTextSize = textStyles.subtitle2;
}
}
return {
primaryTextClassName: mergeClasses(primaryTextBaseClassName, primaryTextSize, alignToPrimaryClassName),
optionalTextClassName: mergeClasses(optionalTextBaseClassName, !presenceOnly && size === 'huge' && textStyles.body1, alignToPrimaryClassName)
};
};
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
export { Persona, personaClassNames, renderPersona_unstable, usePersonaStyles_unstable, usePersona_unstable } from './Persona';
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../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"],"names":["Persona","personaClassNames","renderPersona_unstable","usePersonaStyles_unstable","usePersona_unstable"],"rangeMappings":"","mappings":"AAAA,SACEA,OAAO,EACPC,iBAAiB,EACjBC,sBAAsB,EACtBC,yBAAyB,EACzBC,mBAAmB,QACd,YAAY"}
+57
View File
@@ -0,0 +1,57 @@
{
"name": "@fluentui/react-persona",
"version": "9.3.0",
"description": "React components for building web experiences",
"main": "lib-commonjs/index.js",
"module": "lib/index.js",
"typings": "./dist/index.d.ts",
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/microsoft/fluentui"
},
"license": "MIT",
"devDependencies": {
"@fluentui/eslint-plugin": "*",
"@fluentui/react-conformance": "*",
"@fluentui/react-conformance-griffel": "*",
"@fluentui/scripts-api-extractor": "*"
},
"dependencies": {
"@fluentui/react-avatar": "^9.7.0",
"@fluentui/react-badge": "^9.2.50",
"@fluentui/react-shared-contexts": "^9.21.2",
"@fluentui/react-theme": "^9.1.24",
"@fluentui/react-utilities": "^9.18.20",
"@fluentui/react-jsx-runtime": "^9.0.50",
"@griffel/react": "^1.5.22",
"@swc/helpers": "^0.5.1"
},
"peerDependencies": {
"@types/react": ">=16.14.0 <19.0.0",
"@types/react-dom": ">=16.9.0 <19.0.0",
"react": ">=16.14.0 <19.0.0",
"react-dom": ">=16.14.0 <19.0.0"
},
"beachball": {
"disallowedChangeTypes": [
"major",
"prerelease"
]
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"node": "./lib-commonjs/index.js",
"import": "./lib/index.js",
"require": "./lib-commonjs/index.js"
},
"./package.json": "./package.json"
},
"files": [
"*.md",
"dist/*.d.ts",
"lib",
"lib-commonjs"
]
}