RCTSingelineTextInputNativeComponent.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @flow strict-local
  8. * @format
  9. */
  10. 'use strict';
  11. import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
  12. import requireNativeComponent from '../../ReactNative/requireNativeComponent';
  13. import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
  14. import type {Int32} from '../../Types/CodegenTypes';
  15. import * as React from 'react';
  16. import type {TextInputNativeCommands} from './TextInputNativeCommands';
  17. import RCTSinglelineTextInputViewConfig from './RCTSinglelineTextInputViewConfig';
  18. const ReactNativeViewConfigRegistry = require('../../Renderer/shims/ReactNativeViewConfigRegistry');
  19. type NativeType = HostComponent<mixed>;
  20. type NativeCommands = TextInputNativeCommands<NativeType>;
  21. export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
  22. supportedCommands: ['focus', 'blur', 'setTextAndSelection'],
  23. });
  24. let SinglelineTextInputNativeComponent;
  25. if (global.RN$Bridgeless) {
  26. ReactNativeViewConfigRegistry.register('RCTSinglelineTextInputView', () => {
  27. return RCTSinglelineTextInputViewConfig;
  28. });
  29. SinglelineTextInputNativeComponent = 'RCTSinglelineTextInputView';
  30. } else {
  31. SinglelineTextInputNativeComponent = requireNativeComponent<mixed>(
  32. 'RCTSinglelineTextInputView',
  33. );
  34. }
  35. // flowlint-next-line unclear-type:off
  36. export default ((SinglelineTextInputNativeComponent: any): HostComponent<mixed>);