/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format * @flow strict-local */ 'use strict'; import type { RNTesterModule, RNTesterModuleExample, } from '../../types/RNTesterTypes'; import ExampleTextInput from './ExampleTextInput'; import TextInputSharedExamples from './TextInputSharedExamples'; import React from 'react'; import {StyleSheet, Text, View} from 'react-native'; const ToggleDefaultPaddingExample = (): React.Node => { const [hasPadding, setHasPadding] = React.useState(false); return ( setHasPadding(!hasPadding)}>Toggle padding ); }; const styles = StyleSheet.create({ multiline: { height: 60, fontSize: 16, }, singleLine: { fontSize: 16, }, singleLineWithHeightTextInput: { height: 30, }, wrappedText: { maxWidth: 300, }, }); const examples: Array = [ ...TextInputSharedExamples, { title: 'Colors and text inputs', render: function (): React.Node { return ( Darker backgroundColor ); }, }, { title: 'Font Weight', render: function (): React.Node { return ( {[ 'normal', 'bold', '900', 800, '700', '600', '500', '400', '300', '200', '100', ].map(fontWeight => ( ))} ); }, }, { title: 'Text input, themes and heights', render: function (): React.Node { return ( ); }, }, { title: 'letterSpacing', render: function (): React.Node { return ( ); }, }, { title: 'Passwords', render: function (): React.Node { return ( ); }, }, { title: 'Editable', render: function (): React.Node { return ( ); }, }, { title: 'Multiline', render: function (): React.Node { return ( multiline with children, aligned bottom-right ); }, }, { title: 'Editable and Read only', render: function (): React.Node { return ( ); }, }, { title: 'Fixed number of lines', platform: 'android', render: function (): React.Node { return ( ); }, }, { title: 'Text Auto Complete', render: function (): React.Node { return ( ); }, }, { title: 'Return key', render: function (): React.Node { const returnKeyTypes = [ 'none', 'go', 'search', 'send', 'done', 'previous', 'next', ]; const returnKeyLabels = ['Compile', 'React Native']; const returnKeyExamples = returnKeyTypes.map(type => { return ( ); }); const types = returnKeyLabels.map(type => { return ( ); }); return ( {returnKeyExamples} {types} ); }, }, { title: 'Inline Images', render: function (): React.Node { return ( ); }, }, { title: 'Toggle Default Padding', render: function (): React.Node { return ; }, }, ]; module.exports = ({ displayName: (undefined: ?string), title: 'TextInput', documentationURL: 'https://reactnative.dev/docs/textinput', category: 'Basic', description: 'Single and multi-line text inputs.', examples, }: RNTesterModule);