UNPKG

react95-native

Version:

Refreshed Windows 95 style UI components for your React Native app

61 lines (54 loc) 1.98 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import { View, StyleSheet, TextInput as NativeTextInput } from 'react-native'; import { withTheme } from '../../core/theming'; import { blockSizes, builtTextStyles } from '../../styles/styles'; import { Border } from '../../styles/styleElements'; // TODO: implement scrollbars in TextInput const TextInput = ({ defaultValue, disabled, style = {}, theme, value, variant = 'default', ...rest }) => { const hasValue = !!(value || defaultValue); const isFlat = variant === 'flat'; const getBackgroundColor = () => { if (isFlat) { return disabled ? theme.flatLight : 'transparent'; } return disabled ? theme.material : theme.canvas; }; const textStyles = builtTextStyles(theme); return /*#__PURE__*/React.createElement(View, { style: [styles.wrapper, { padding: isFlat ? 2 : 4 }, style] }, /*#__PURE__*/React.createElement(Border, { theme: theme, variant: isFlat ? 'flat' : 'cutout' }), /*#__PURE__*/React.createElement(NativeTextInput, _extends({ style: [styles.input, { backgroundColor: getBackgroundColor() }, textStyles.regular, disabled && hasValue ? textStyles.disabled : textStyles.default], placeholderTextColor: theme.materialTextDisabled, defaultValue: defaultValue, value: value, editable: !disabled // eslint-disable-next-line react/jsx-props-no-spreading }, rest))); }; const styles = StyleSheet.create({ wrapper: { minHeight: blockSizes.md, justifyContent: 'center' }, input: { flex: 1, paddingHorizontal: 4 } }); export default withTheme(TextInput); //# sourceMappingURL=TextInput.js.map