office-ui-fabric-react
Version:
Reusable React components for building experiences for Office 365.
59 lines • 4.65 kB
JavaScript
define(["require", "exports", "tslib", "react", "../../Utilities", "../../Tooltip", "./PersonaCoin", "./Persona.types", "./PersonaConsts", "./Persona.scss"], function (require, exports, tslib_1, React, Utilities_1, Tooltip_1, PersonaCoin_1, Persona_types_1, PersonaConsts_1, stylesImport) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var styles = stylesImport;
var PersonaBase = /** @class */ (function (_super) {
tslib_1.__extends(PersonaBase, _super);
function PersonaBase(props) {
return _super.call(this, props) || this;
}
PersonaBase.prototype.render = function () {
var _a = this.props, hidePersonaDetails = _a.hidePersonaDetails, onRenderPrimaryText = _a.onRenderPrimaryText, onRenderSecondaryText = _a.onRenderSecondaryText, onRenderTertiaryText = _a.onRenderTertiaryText, onRenderOptionalText = _a.onRenderOptionalText;
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, className = _b.className, coinProps = _b.coinProps, coinSize = _b.coinSize, imageUrl = _b.imageUrl, imageAlt = _b.imageAlt, imageInitials = _b.imageInitials, initialsColor = _b.initialsColor, presence = _b.presence, primaryText = _b.primaryText, imageShouldFadeIn = _b.imageShouldFadeIn, imageShouldStartVisible = _b.imageShouldStartVisible, showSecondaryText = _b.showSecondaryText, onPhotoLoadingStateChange = _b.onPhotoLoadingStateChange, onRenderCoin = _b.onRenderCoin;
var personaCoinProps = {
coinProps: coinProps,
coinSize: coinSize,
imageUrl: imageUrl,
imageAlt: imageAlt,
imageInitials: imageInitials,
initialsColor: initialsColor,
presence: presence,
primaryText: primaryText,
imageShouldFadeIn: imageShouldFadeIn,
imageShouldStartVisible: imageShouldStartVisible,
size: size,
onPhotoLoadingStateChange: onPhotoLoadingStateChange,
onRenderCoin: onRenderCoin
};
var divProps = Utilities_1.getNativeProps(this.props, Utilities_1.divProperties);
var personaDetails = (React.createElement("div", { className: Utilities_1.css('ms-Persona-details', styles.details) },
this._renderElement(this.props.primaryText, Utilities_1.css('ms-Persona-primaryText', styles.primaryText), onRenderPrimaryText),
this._renderElement(this.props.secondaryText, Utilities_1.css('ms-Persona-secondaryText', styles.secondaryText), onRenderSecondaryText),
this._renderElement(this.props.tertiaryText, Utilities_1.css('ms-Persona-tertiaryText', styles.tertiaryText), onRenderTertiaryText),
this._renderElement(this.props.optionalText, Utilities_1.css('ms-Persona-optionalText', styles.optionalText), onRenderOptionalText),
this.props.children));
return (React.createElement("div", tslib_1.__assign({}, divProps, { className: Utilities_1.css('ms-Persona', styles.root, className, PersonaConsts_1.PERSONA_SIZE[size], PersonaConsts_1.PERSONA_PRESENCE[presence], showSecondaryText && styles.showSecondaryText), 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));
};
PersonaBase.prototype._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))));
};
PersonaBase.defaultProps = {
primaryText: '',
size: Persona_types_1.PersonaSize.size48,
presence: Persona_types_1.PersonaPresence.none,
imageAlt: ''
};
tslib_1.__decorate([
Utilities_1.autobind
], PersonaBase.prototype, "_renderElement", null);
return PersonaBase;
}(Utilities_1.BaseComponent));
exports.PersonaBase = PersonaBase;
});
//# sourceMappingURL=Persona.base.js.map