UNPKG

@eslam-elmeniawy/react-native-common-components

Version:

Common `ReactNative` components packed in library for usage in projects.

59 lines (55 loc) 1.92 kB
"use strict"; // External imports. import * as React from 'react'; import { StyleSheet } from 'react-native'; import { withTheme } from 'react-native-paper'; import { set, omit } from 'lodash'; // Types imports. // Internal imports. import styles from "./TextInput.styles.js"; import TopLabel from "./TopLabel.js"; import TextInputInput from "./TextInputInput.js"; import ErrorView from "./ErrorView.js"; /** * TextInputComponent (unwrapped, for testing) * @internal For testing purposes only. Do not use in production code. */ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; const TextInputComponent = /*#__PURE__*/React.memo(props => { const { topLabelProps, errorProps } = props; const { marginVertical, marginTop, marginBottom } = props.style ?? {}; let _inputStyle; if (topLabelProps && errorProps) { _inputStyle = StyleSheet.flatten([styles.noVerticalMargin, omit(props.style ?? {}, ['marginVertical', 'marginTop', 'marginBottom'])]); } else if (topLabelProps) { _inputStyle = StyleSheet.flatten([styles.noVerticalMargin, omit(props.style ?? {}, ['marginVertical', 'marginTop', 'marginBottom']), { marginBottom: marginVertical ?? marginBottom }]); } else if (errorProps) { _inputStyle = StyleSheet.flatten([styles.noVerticalMargin, omit(props.style ?? {}, ['marginVertical', 'marginTop', 'marginBottom']), { marginTop: marginVertical ?? marginTop }]); } else { _inputStyle = props.style; } return /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsx(TopLabel, { ...props }), /*#__PURE__*/_jsx(TextInputInput, { ...set(props, 'style', _inputStyle) }), /*#__PURE__*/_jsx(ErrorView, { ...props })] }); }); const TextInput = withTheme(TextInputComponent); export { TextInputComponent }; export default TextInput; //# sourceMappingURL=TextInput.js.map