UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

68 lines 3.3 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 BoxNoClickExample = /** @class */ (function (_super) { tslib_1.__extends(BoxNoClickExample, _super); function BoxNoClickExample(props) { var _this = _super.call(this, props) || this; _this._onButtonClickHandler = function () { _this.setState({ isToggled: true }); }; _this._onExitButtonClickHandler = function () { _this.setState({ isToggled: false }); }; _this._onFocusTrapZoneToggleChanged = function (ev, isToggled) { _this.setState({ isToggled: isToggled }, function () { return _this._toggle.focus(); }); }; _this._setRef = function (toggle) { _this._toggle = toggle; }; _this.state = { isToggled: false }; return _this; } BoxNoClickExample.prototype.render = function () { var _this = this; var isToggled = this.state.isToggled; return (React.createElement("div", null, React.createElement(DefaultButton, { secondaryText: "Focuses inside the FocusTrapZone", onClick: this._onButtonClickHandler, text: "Go to Trap Zone" }), (function () { if (isToggled) { return (React.createElement(FocusTrapZone, { isClickableOutsideFocusTrap: true, forceFocusInsideTrap: false }, _this._internalContents())); } else { return React.createElement("div", null, _this._internalContents()); } })())); }; BoxNoClickExample.prototype._internalContents = function () { var _this = this; var isToggled = this.state.isToggled; 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: isToggled, onChange: this._onFocusTrapZoneToggleChanged, label: "Focus Trap Zone", onText: "On", offText: "Off" }), (function () { if (isToggled) { return (React.createElement(DefaultButton, { secondaryText: "Exit Focus Trap Zone", onClick: _this._onExitButtonClickHandler, text: "Exit Focus Trap Zone" })); } })())); }; return BoxNoClickExample; }(React.Component)); export default BoxNoClickExample; //# sourceMappingURL=FocusTrapZone.Box.Click.Example.js.map