mh-rn-component
Version:
65 lines (63 loc) • 1.77 kB
JavaScript
import React from 'react';
import { View, Text, StyleSheet, TouchableWithoutFeedback } from 'react-native';
import Icon from '../Icon';
const Checkbox = _ref => {
let {
onPress,
onChange,
disabled,
activeIcon,
inactiveIcon,
rightIcon,
checkedColor = "#2376b7",
iconSize = 20,
...rest
} = _ref;
return /*#__PURE__*/React.createElement(TouchableWithoutFeedback, {
disabled: disabled,
testID: "Radio",
onPress: onPress && (() => onPress(rest.value || '')) || onChange && (() => onChange(!rest.checked))
}, /*#__PURE__*/React.createElement(View, {
style: [styles.radio, disabled && styles.disabled, rest.style]
}, rightIcon && /*#__PURE__*/React.createElement(Text, {
style: styles.ml4
}, rest.children || rest.label), /*#__PURE__*/React.createElement(View, null, !rest.checked ? inactiveIcon ? inactiveIcon : /*#__PURE__*/React.createElement(Text, {
style: [styles.checkBox, {
width: iconSize,
height: iconSize,
borderRadius: iconSize / 2
}]
}) : activeIcon ? activeIcon : /*#__PURE__*/React.createElement(Text, {
style: {
width: iconSize,
height: iconSize
}
}, /*#__PURE__*/React.createElement(Icon, {
name: "checkcircle",
size: iconSize,
color: checkedColor
}))), !rightIcon && /*#__PURE__*/React.createElement(Text, {
style: styles.ml4
}, rest.children || rest.label)));
};
const styles = StyleSheet.create({
radio: {
flexDirection: 'row',
alignItems: 'center',
minWidth: 80,
paddingBottom: 8
},
checkBox: {
borderWidth: 2,
borderColor: '#333',
overflow: 'hidden'
},
disabled: {
opacity: 0.5
},
ml4: {
marginLeft: 4
}
});
export default Checkbox;
//# sourceMappingURL=index.js.map