UNPKG

@ffsm/native-ui

Version:

UI Components for React Native

34 lines (33 loc) 1.31 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 { Pressable, StyleSheet, View } from 'react-native'; import { flattenStyle } from '../flatten-style'; import { AsText } from '../as-text'; function AdornmentBase(props, ref) { const { children, style, pressable } = props, rest = __rest(props, ["children", "style", "pressable"]); const Component = pressable ? Pressable : View; return (<Component {...rest} ref={ref} style={flattenStyle([styles.container, style])}> {typeof children === 'function' ? ((state) => (<AsText> {children(state)} </AsText>)) : (<AsText> {children} </AsText>)} </Component>); } const styles = StyleSheet.create({ container: { height: '100%', paddingHorizontal: 8, }, }); export const Adornment = forwardRef(AdornmentBase);