UNPKG

@lyra/form-builder

Version:
45 lines (37 loc) 1.04 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require('react'); var _react2 = _interopRequireDefault(_react); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /*:: import type {Path} from '../../typedefs/path'*/ // A simple focus path manager /*:: type Props = { path: ?any, onFocus: () => {}, onBlur: () => {}, children: () => any }*/ /*:: type State = { focusPath: Array<*> }*/ class SimpleFocusManager extends _react2.default.Component /*:: <Props, State>*/ { constructor(...args) { var _temp; return _temp = super(...args), this.state = { focusPath: [] }, this.handleFocus = (path /*: Path*/) => { this.setState({ focusPath: path }); }, this.handleBlur = () => { // do nothing }, _temp; } render() { return this.props.children({ onBlur: this.handleBlur, onFocus: this.handleFocus, focusPath: this.state.focusPath }); } } exports.default = SimpleFocusManager;