UNPKG

@fruits-chain/react-native-xiaoshu

Version:
57 lines (56 loc) • 1.5 kB
"use strict"; import React from 'react'; import { TouchableWithoutFeedback, View } from 'react-native'; import { attachPropertiesToComponent } from "../helpers/index.js"; import FlexItem from "./flex-item.js"; import { jsx as _jsx } from "react/jsx-runtime"; const Flex = props => { const { style, direction = 'row', wrap = 'nowrap', justify = 'start', align = 'center', children, ...restProps } = props; const transferConst = [justify, align]; const transferConstStyle = transferConst.map(tc => { switch (tc) { case 'start': return 'flex-start'; case 'end': return 'flex-end'; case 'between': return 'space-between'; case 'around': return 'space-around'; default: return tc; } }); const flexStyle = { flexDirection: direction, flexWrap: wrap, justifyContent: transferConstStyle[0], alignItems: transferConstStyle[1] }; const inner = /*#__PURE__*/_jsx(View, { style: [flexStyle, style], ...restProps, children: children }); const shouldWrapInTouchableComponent = restProps.onPress || restProps.onLongPress || restProps.onPressIn || restProps.onPressOut; if (shouldWrapInTouchableComponent) { return /*#__PURE__*/_jsx(TouchableWithoutFeedback, { ...restProps, children: inner }); } else { return inner; } }; export default attachPropertiesToComponent(Flex, { Item: FlexItem }); //# sourceMappingURL=index.js.map