UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

68 lines 3.18 kB
import * as tslib_1 from "tslib"; import * as React from 'react'; 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._onButtonClickHandler = function () { _this.setState({ isChecked: true }); }; _this._onExitButtonClickHandler = function () { _this.setState({ isChecked: false }); }; _this._onFocusTrapZoneToggleChanged = function (ev, isChecked) { _this.setState({ isChecked: isChecked }, function () { return _this._toggle.focus(); }); }; _this._setRef = function (toggle) { _this._toggle = toggle; }; _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, { secondaryText: "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, onChange: this._onFocusTrapZoneToggleChanged, label: "Focus Trap Zone", onText: "On", offText: "Off" }), (function () { if (isChecked) { return (React.createElement(DefaultButton, { secondaryText: "Exit Focus Trap Zone", onClick: _this._onExitButtonClickHandler, text: "Exit Focus Trap Zone" })); } })())); }; return BoxExample; }(React.Component)); export default BoxExample; //# sourceMappingURL=FocusTrapZone.Box.Example.js.map