office-ui-fabric-react
Version: 
Reusable React components for building experiences for Office 365.
64 lines (62 loc) • 3.42 kB
JavaScript
define(["require", "exports", "tslib", "react", "office-ui-fabric-react/lib/Button", "office-ui-fabric-react/lib/FocusTrapZone", "office-ui-fabric-react/lib/Link", "office-ui-fabric-react/lib/TextField", "office-ui-fabric-react/lib/Toggle", "./FocusTrapZone.Box.Example.scss"], function (require, exports, tslib_1, React, Button_1, FocusTrapZone_1, Link_1, TextField_1, Toggle_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var BoxExample = (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(Button_1.DefaultButton, { description: 'Focuses inside the FocusTrapZone', onClick: this._onButtonClickHandler.bind(this), text: 'Go to Trap Zone' }),
                (function () {
                    if (isChecked) {
                        return (React.createElement(FocusTrapZone_1.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_1.TextField, { label: 'Default TextField', placeholder: 'Input inside Focus Trap Zone', className: '' }),
                React.createElement(Link_1.Link, { href: '', className: '' }, "Hyperlink inside FocusTrapZone"),
                React.createElement("br", null),
                React.createElement("br", null),
                React.createElement(Toggle_1.Toggle, { componentRef: function (toggle) { return _this._toggle = toggle; }, checked: isChecked, onChanged: this._onFocusTrapZoneToggleChanged.bind(this), label: 'Focus Trap Zone', onText: 'On', offText: 'Off' }),
                (function () {
                    if (isChecked) {
                        return (React.createElement(Button_1.DefaultButton, { description: 'Exit Focus Trap Zone', onClick: _this._onExitButtonClickHandler.bind(_this), 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(); });
        };
        return BoxExample;
    }(React.Component));
    exports.default = BoxExample;
});
//# sourceMappingURL=FocusTrapZone.Box.Example.js.map