UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

42 lines 2.04 kB
import * as tslib_1 from "tslib"; import * as React from 'react'; import { anchorProperties, autobind, BaseComponent, buttonProperties, classNamesFunction, customizable, getNativeProps } from '../../Utilities'; var getClassNames = classNamesFunction(); var LinkBase = /** @class */ (function (_super) { tslib_1.__extends(LinkBase, _super); function LinkBase() { return _super !== null && _super.apply(this, arguments) || this; } LinkBase.prototype.render = function () { var _a = this.props, disabled = _a.disabled, children = _a.children, className = _a.className, href = _a.href, theme = _a.theme, getStyles = _a.getStyles; var classNames = getClassNames(getStyles, { className: className, isButton: !href, isDisabled: disabled, theme: theme }); var anchorElement = (React.createElement("a", tslib_1.__assign({}, getNativeProps(this.props, anchorProperties), { className: classNames.root, onClick: this._onClick, ref: this._resolveRef('_link'), target: this.props.target, "aria-disabled": disabled }), children)); var buttonElement = (React.createElement("button", tslib_1.__assign({}, getNativeProps(this.props, buttonProperties), { className: classNames.root, onClick: this._onClick, ref: this._resolveRef('_link'), "aria-disabled": disabled }), children)); return href ? anchorElement : buttonElement; }; LinkBase.prototype.focus = function () { if (this._link) { this._link.focus(); } }; LinkBase.prototype._onClick = function (ev) { var onClick = this.props.onClick; if (onClick) { onClick(ev); } }; tslib_1.__decorate([ autobind ], LinkBase.prototype, "_onClick", null); LinkBase = tslib_1.__decorate([ customizable('Link', ['theme', 'getStyles']) ], LinkBase); return LinkBase; }(BaseComponent)); export { LinkBase }; //# sourceMappingURL=Link.base.js.map