we-insights-react-native
Version:
[we-insights] is a powerful utility library designed to streamline data collection processes for WeApp employees. It simplifies the process of gathering, storing, and managing data within WeApp projects, making it an invaluable tool for enhancing efficien
66 lines • 1.66 kB
JavaScript
import React, { useState } from 'react';
import { TextInput, StyleSheet, View, Text } from 'react-native';
export const Input = ({
multiline = false,
numberOfLines = 1,
placeholder = '',
onChangeText,
value,
style = {}
}) => {
const [isFocused, setIsFocused] = useState(false);
const inputStyle = {
backgroundColor: style.backgroundColor,
color: style.textColor,
borderColor: style.borderColor,
fontFamily: style.fontFamily,
...styles.input,
...(multiline && styles.textArea),
fontSize: 16
};
return /*#__PURE__*/React.createElement(View, {
style: styles.inputContainer
}, /*#__PURE__*/React.createElement(View, {
style: styles.placeholderContainer
}, (value || isFocused) && /*#__PURE__*/React.createElement(Text, {
style: [styles.placeholder, {
color: style.textColor
}]
}, placeholder), /*#__PURE__*/React.createElement(TextInput, {
multiline: multiline,
numberOfLines: numberOfLines,
placeholder: isFocused ? '' : placeholder,
onChangeText: onChangeText,
value: value,
style: inputStyle,
placeholderTextColor: style.textColor,
onFocus: () => setIsFocused(true),
onBlur: () => setIsFocused(false)
})));
};
const styles = StyleSheet.create({
inputContainer: {
position: 'relative'
},
input: {
borderWidth: 1,
padding: 10,
marginBottom: 10,
borderRadius: 4
},
textArea: {
height: 100
},
placeholderContainer: {
position: 'relative'
},
placeholder: {
position: 'absolute',
top: 4,
left: 10,
color: '#ffffff',
fontSize: 10,
zIndex: 999
}
});
//# sourceMappingURL=Input.js.map