UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

84 lines 3.74 kB
import * as tslib_1 from "tslib"; /* tslint:disable:no-unused-variable */ import * as React from 'react'; /* tslint:enable:no-unused-variable */ import { autobind } from '../../../Utilities'; import { DefaultButton } from 'office-ui-fabric-react/lib/Button'; import { FocusTrapZone } from 'office-ui-fabric-react/lib/FocusTrapZone'; import { Link } from 'office-ui-fabric-react/lib/Link'; import { TextField } from 'office-ui-fabric-react/lib/TextField'; import { Toggle } from 'office-ui-fabric-react/lib/Toggle'; import './FocusTrapZone.Box.Example.scss'; var BoxExample = /** @class */ (function (_super) { tslib_1.__extends(BoxExample, _super); function BoxExample(props) { var _this = _super.call(this, props) || this; _this.state = { isChecked: false, }; return _this; } BoxExample.prototype.render = function () { var _this = this; var isChecked = this.state.isChecked; return (React.createElement("div", null, React.createElement(DefaultButton, { description: 'Focuses inside the FocusTrapZone', onClick: this._onButtonClickHandler, text: 'Go to Trap Zone' }), (function () { if (isChecked) { return (React.createElement(FocusTrapZone, null, _this._internalContents())); } else { return (React.createElement("div", null, _this._internalContents())); } })())); }; BoxExample.prototype._internalContents = function () { var _this = this; var isChecked = this.state.isChecked; return (React.createElement("div", { className: 'ms-FocusTrapZoneBoxExample' }, React.createElement(TextField, { label: 'Default TextField', placeholder: 'Input inside Focus Trap Zone', className: '' }), React.createElement(Link, { href: '', className: '' }, "Hyperlink inside FocusTrapZone"), React.createElement("br", null), React.createElement("br", null), React.createElement(Toggle, { componentRef: this._setRef, checked: isChecked, onChanged: this._onFocusTrapZoneToggleChanged, label: 'Focus Trap Zone', onText: 'On', offText: 'Off' }), (function () { if (isChecked) { return (React.createElement(DefaultButton, { description: 'Exit Focus Trap Zone', onClick: _this._onExitButtonClickHandler, text: 'Exit Focus Trap Zone' })); } })())); }; BoxExample.prototype._onButtonClickHandler = function () { this.setState({ isChecked: true }); }; BoxExample.prototype._onExitButtonClickHandler = function () { this.setState({ isChecked: false }); }; BoxExample.prototype._onFocusTrapZoneToggleChanged = function (isChecked) { var _this = this; this.setState({ isChecked: isChecked }, function () { return _this._toggle.focus(); }); }; BoxExample.prototype._setRef = function (toggle) { this._toggle = toggle; }; tslib_1.__decorate([ autobind ], BoxExample.prototype, "_onButtonClickHandler", null); tslib_1.__decorate([ autobind ], BoxExample.prototype, "_onExitButtonClickHandler", null); tslib_1.__decorate([ autobind ], BoxExample.prototype, "_onFocusTrapZoneToggleChanged", null); tslib_1.__decorate([ autobind ], BoxExample.prototype, "_setRef", null); return BoxExample; }(React.Component)); export default BoxExample; //# sourceMappingURL=FocusTrapZone.Box.Example.js.map