@react-form-fields/native-base
Version:
Native Base Form Fields
24 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var context_1 = require("./context");
var goNextEmpty = [function () { return false; }, false, null];
var useFieldFlow = function (_a, onFocusHandler) {
var flowIndex = _a.flowIndex, tabIndex = _a.tabIndex;
var index = React.useMemo(function () { return (flowIndex === undefined ? tabIndex : flowIndex); }, [flowIndex, tabIndex]);
var _b = React.useContext(context_1.default), registerPosition = _b.registerPosition, unregisterPosition = _b.unregisterPosition, goNext = _b.goNext;
React.useEffect(function () {
if (index === undefined || index === null) {
return function () { };
}
registerPosition(index, onFocusHandler);
return function () { return unregisterPosition(index); };
}, [index, onFocusHandler, registerPosition, unregisterPosition]);
return React.useMemo(function () {
if (index === undefined || index === null)
return goNextEmpty;
return [goNext, true, index];
}, [index, goNext]);
};
exports.default = useFieldFlow;
//# sourceMappingURL=index.js.map