UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

32 lines 1.78 kB
import * as tslib_1 from "tslib"; import * as React from 'react'; import { BaseComponent, anchorProperties, autobind, buttonProperties, css, getNativeProps } from '../../Utilities'; import * as stylesImport from './Link.scss'; var styles = stylesImport; var Link = /** @class */ (function (_super) { tslib_1.__extends(Link, _super); function Link() { return _super !== null && _super.apply(this, arguments) || this; } Link.prototype.render = function () { var _a = this.props, disabled = _a.disabled, children = _a.children, className = _a.className, href = _a.href; return (href ? (React.createElement("a", tslib_1.__assign({}, getNativeProps(this.props, anchorProperties), { className: css('ms-Link', styles.root, className, disabled && ('is-disabled ' + styles.isDisabled), !disabled && styles.isEnabled), onClick: this._onClick, ref: this._resolveRef('_link'), target: this.props.target, "aria-disabled": disabled }), children)) : (React.createElement("button", tslib_1.__assign({}, getNativeProps(this.props, buttonProperties), { className: css('ms-Link', styles.root, className, disabled && ('is-disabled ' + styles.isDisabled), !disabled && styles.isEnabled), onClick: this._onClick, ref: this._resolveRef('_link'), "aria-disabled": disabled }), children))); }; Link.prototype.focus = function () { if (this._link) { this._link.focus(); } }; Link.prototype._onClick = function (ev) { var onClick = this.props.onClick; if (onClick) { onClick(ev); } }; tslib_1.__decorate([ autobind ], Link.prototype, "_onClick", null); return Link; }(BaseComponent)); export { Link }; //# sourceMappingURL=Link.js.map