UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

1 lines 2.78 kB
module.exports = "/* tslint:disable:no-unused-variable */\nimport * as React from 'react';\n/* tslint:enable:no-unused-variable */\n\nimport * as ReactDOM from 'react-dom';\nimport { FocusTrapZone } from '../../../../index';\nimport './FocusTrapZone.Box.Example.scss';\nimport {\n Button,\n Link,\n TextField,\n Toggle\n} from '../../../../index';\n\nexport interface IBoxNoClickExampleExampleState {\n isToggled: boolean;\n}\n\nexport default class BoxNoClickExample extends React.Component<React.HTMLProps<HTMLDivElement>, IBoxNoClickExampleExampleState> {\n public refs: {\n [key: string]: React.ReactInstance;\n toggle: HTMLElement;\n };\n constructor(props) {\n super(props);\n\n this.state = {\n isToggled: false,\n };\n }\n\n public render() {\n let { isToggled } = this.state;\n\n return (\n <div>\n <Button description='Focuses inside the FocusTrapZone' onClick={ this._onButtonClickHandler.bind(this) }>Go to Trap Zone</Button>\n\n {(() => {\n if (isToggled) {\n return (\n <FocusTrapZone isClickableOutsideFocusTrap={ true } forceFocusInsideTrap={ false }>\n { this._internalContents() }\n </FocusTrapZone>\n );\n } else {\n return (\n <div>\n { this._internalContents() }\n </div>\n );\n }\n })()}\n </div>\n );\n }\n\n private _internalContents() {\n let { isToggled } = this.state;\n\n return (\n <div className='ms-FocusTrapZoneBoxExample'>\n <TextField label='Default TextField' placeholder='Input inside Focus Trap Zone' className='' />\n <Link href='' className='' >Hyperlink inside FocusTrapZone</Link><br /><br />\n <Toggle\n ref='toggle'\n checked={ isToggled }\n onChanged={ this._onFocusTrapZoneToggleChanged.bind(this) }\n label='Focus Trap Zone'\n onText='On'\n offText='Off' />\n {(() => {\n if (isToggled) {\n return (\n <Button description='Exit Focus Trap Zone' onClick={ this._onExitButtonClickHandler.bind(this) }>Exit Focus Trap Zone</Button>\n );\n }\n })()}\n </div>\n );\n }\n\n private _onButtonClickHandler() {\n this.setState({\n isToggled: true\n });\n }\n\n private _onExitButtonClickHandler() {\n this.setState({\n isToggled: false\n });\n }\n\n private _onFocusTrapZoneToggleChanged(isToggled: boolean) {\n this.setState({\n isToggled: isToggled\n }, () => {\n let toggle = ReactDOM.findDOMNode(this.refs.toggle) as HTMLElement;\n\n if (toggle) {\n toggle.focus();\n }\n });\n }\n}";