@eslam-elmeniawy/react-native-common-components
Version:
Common `ReactNative` components packed in library for usage in projects.
52 lines (49 loc) • 1.72 kB
JavaScript
;
// 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";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
const TextInput = /*#__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
})]
});
});
export default withTheme(TextInput);
//# sourceMappingURL=TextInput.js.map