UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

82 lines 4.91 kB
import * as tslib_1 from "tslib"; import * as React from 'react'; import { BaseComponent, classNamesFunction, customizable, divProperties, getNativeProps, } from '../../Utilities'; import { TooltipHost, TooltipOverflowMode } from '../../Tooltip'; import { PersonaCoin } from './PersonaCoin/PersonaCoin'; import { PersonaPresence as PersonaPresenceEnum, PersonaSize, } from './Persona.types'; var getClassNames = classNamesFunction(); /** * Persona with no default styles. * [Use the `styles` API to add your own styles.](https://github.com/OfficeDev/office-ui-fabric-react/wiki/Styling) */ var PersonaBase = /** @class */ (function (_super) { tslib_1.__extends(PersonaBase, _super); function PersonaBase(props) { var _this = _super.call(this, props) || this; _this._renderElement = function (text, className, render) { return (React.createElement("div", { className: className }, render ? render(_this.props) : text && (React.createElement(TooltipHost, { content: text, overflowMode: TooltipOverflowMode.Parent, directionalHint: 0 /* topLeftEdge */ }, text)))); }; _this._warnDeprecations({ 'primaryText': 'text' }); return _this; } PersonaBase.prototype.render = function () { var _a = this.props, hidePersonaDetails = _a.hidePersonaDetails, onRenderOptionalText = _a.onRenderOptionalText, onRenderPrimaryText = _a.onRenderPrimaryText, onRenderSecondaryText = _a.onRenderSecondaryText, onRenderTertiaryText = _a.onRenderTertiaryText; var size = this.props.size; // These properties are to be explicitly passed into PersonaCoin because they are the only props directly used var _b = this.props, allowPhoneInitials = _b.allowPhoneInitials, className = _b.className, coinProps = _b.coinProps, showUnknownPersonaCoin = _b.showUnknownPersonaCoin, coinSize = _b.coinSize, styles = _b.styles, imageAlt = _b.imageAlt, imageInitials = _b.imageInitials, imageShouldFadeIn = _b.imageShouldFadeIn, imageShouldStartVisible = _b.imageShouldStartVisible, imageUrl = _b.imageUrl, initialsColor = _b.initialsColor, onPhotoLoadingStateChange = _b.onPhotoLoadingStateChange, onRenderCoin = _b.onRenderCoin, onRenderInitials = _b.onRenderInitials, presence = _b.presence, showSecondaryText = _b.showSecondaryText, theme = _b.theme; var personaCoinProps = { allowPhoneInitials: allowPhoneInitials, coinProps: coinProps, showUnknownPersonaCoin: showUnknownPersonaCoin, coinSize: coinSize, imageAlt: imageAlt, imageInitials: imageInitials, imageShouldFadeIn: imageShouldFadeIn, imageShouldStartVisible: imageShouldStartVisible, imageUrl: imageUrl, initialsColor: initialsColor, onPhotoLoadingStateChange: onPhotoLoadingStateChange, onRenderCoin: onRenderCoin, onRenderInitials: onRenderInitials, presence: presence, size: size, text: this._getText() }; var classNames = getClassNames(styles, { theme: theme, className: className, showSecondaryText: showSecondaryText, presence: presence, size: size, }); var divProps = getNativeProps(this.props, divProperties); var personaDetails = (React.createElement("div", { className: classNames.details }, this._renderElement(this._getText(), classNames.primaryText, onRenderPrimaryText), this._renderElement(this.props.secondaryText, classNames.secondaryText, onRenderSecondaryText), this._renderElement(this.props.tertiaryText, classNames.tertiaryText, onRenderTertiaryText), this._renderElement(this.props.optionalText, classNames.optionalText, onRenderOptionalText), this.props.children)); return (React.createElement("div", tslib_1.__assign({}, divProps, { className: classNames.root, style: coinSize ? { height: coinSize, minWidth: coinSize } : undefined }), React.createElement(PersonaCoin, tslib_1.__assign({}, personaCoinProps)), (!hidePersonaDetails || (size === PersonaSize.size10 || size === PersonaSize.tiny)) && personaDetails)); }; /** * Deprecation helper for getting text. */ PersonaBase.prototype._getText = function () { return this.props.text || this.props.primaryText || ''; }; PersonaBase.defaultProps = { size: PersonaSize.size48, presence: PersonaPresenceEnum.none, imageAlt: '' }; PersonaBase = tslib_1.__decorate([ customizable('Persona', ['theme']) ], PersonaBase); return PersonaBase; }(BaseComponent)); export { PersonaBase }; //# sourceMappingURL=Persona.base.js.map