@ffsm/native-ui
Version:
UI Components for React Native
38 lines (37 loc) • 1.59 kB
JavaScript
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, Text, View } from 'react-native';
import { AsText } from '../as-text';
import { DEFAULT_NATIVEUI_THEME } from '../theme';
import { flattenStyle } from '../flatten-style';
export const InputLabel = forwardRef(function InputLabel(props, ref) {
const { asterisk = '*', required, hideAsterisk, innerProps, children, style, styles = {} } = props, rest = __rest(props, ["asterisk", "required", "hideAsterisk", "innerProps", "children", "style", "styles"]);
return (<View {...rest} ref={ref} style={flattenStyle([_styles.root, style])}>
<AsText {...innerProps} style={styles.labelText}>{children}</AsText>
{required && !hideAsterisk && (<Text style={styles.asterisk}>
{asterisk}
</Text>)}
</View>);
});
const _styles = StyleSheet.create({
root: {
flexDirection: 'row',
marginBottom: 1,
fontWeight: 'bold',
fontSize: 14,
color: DEFAULT_NATIVEUI_THEME.colors.slate[800],
},
asterisk: {
color: DEFAULT_NATIVEUI_THEME.colors.red[700],
},
});