UNPKG

@ffsm/native-ui

Version:

UI Components for React Native

33 lines (32 loc) 1.67 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { forwardRef } from 'react'; import { StyleSheet, View } from 'react-native'; import { InputLabel } from '../input-label'; import { HelperText } from '../helper-text'; import { flattenStyle } from '../flatten-style'; export const InputWrapper = forwardRef(function InputWrapper(props, ref) { const { children, label, style, styles = {}, asterisk, required, hideAsterisk, labelInnerProps, error, helperText } = props, rest = __rest(props, ["children", "label", "style", "styles", "asterisk", "required", "hideAsterisk", "labelInnerProps", "error", "helperText"]); return (<View {...rest} ref={ref} style={flattenStyle(_styles.root, style)}> {label !== undefined && (<InputLabel style={styles.label} innerProps={labelInnerProps} asterisk={asterisk} required={required} hideAsterisk={hideAsterisk} styles={styles}> {label} </InputLabel>)} {children} {!!error && (<HelperText error style={styles.error}>{error}</HelperText>)} {!!helperText && (<HelperText style={styles.helperText}>{helperText}</HelperText>)} </View>); }); const _styles = StyleSheet.create({ root: { width: '100%', }, });