UNPKG

react-native-web-internals

Version:

React Native for Web

34 lines (33 loc) 1.23 kB
import UIManager from "../UIManager"; const TextInputState = { /** * Internal state */ _currentlyFocusedNode: null, /** * Returns the ID of the currently focused text field, if one exists * If no text field is focused it returns null */ currentlyFocusedField() { return document.activeElement !== this._currentlyFocusedNode && (this._currentlyFocusedNode = null), this._currentlyFocusedNode; }, /** * @param {Object} TextInputID id of the text field to focus * Focuses the specified text field * noop if the text field was already focused */ focusTextInput(textFieldNode) { textFieldNode !== null && (this._currentlyFocusedNode = textFieldNode, document.activeElement !== textFieldNode && UIManager.focus(textFieldNode)); }, /** * @param {Object} textFieldNode id of the text field to focus * Unfocuses the specified text field * noop if it wasn't focused */ blurTextInput(textFieldNode) { textFieldNode !== null && (this._currentlyFocusedNode = null, document.activeElement === textFieldNode && UIManager.blur(textFieldNode)); } }; var TextInputState_default = TextInputState; export { TextInputState_default as default }; //# sourceMappingURL=index.mjs.map