office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
80 lines • 5.3 kB
JavaScript
define(["require", "exports", "tslib", "react", "../../Utilities", "../../Tooltip", "./PersonaCoin/PersonaCoin", "./Persona.types"], function (require, exports, tslib_1, React, Utilities_1, Tooltip_1, PersonaCoin_1, Persona_types_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var getClassNames = Utilities_1.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(Tooltip_1.TooltipHost, { content: text, overflowMode: Tooltip_1.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 = Utilities_1.getNativeProps(this.props, Utilities_1.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_1.PersonaCoin, tslib_1.__assign({}, personaCoinProps)),
(!hidePersonaDetails || (size === Persona_types_1.PersonaSize.size10 || size === Persona_types_1.PersonaSize.tiny)) && personaDetails));
};
/**
* Deprecation helper for getting text.
*/
PersonaBase.prototype._getText = function () {
return this.props.text || this.props.primaryText || '';
};
PersonaBase.defaultProps = {
size: Persona_types_1.PersonaSize.size48,
presence: Persona_types_1.PersonaPresence.none,
imageAlt: ''
};
PersonaBase = tslib_1.__decorate([
Utilities_1.customizable('Persona', ['theme'])
], PersonaBase);
return PersonaBase;
}(Utilities_1.BaseComponent));
exports.PersonaBase = PersonaBase;
});
//# sourceMappingURL=Persona.base.js.map