@eslam-elmeniawy/react-native-common-components
Version:
Common `ReactNative` components packed in library for usage in projects.
96 lines (92 loc) • 3.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _reactNativePaper = require("react-native-paper");
var _tinycolor = _interopRequireDefault(require("tinycolor2"));
var _CompoundButtonStyles = _interopRequireDefault(require("./CompoundButton.styles.js"));
var _index = require("../Text/index.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
// External imports.
// Types imports.
// Internal imports.
const RadioButton = /*#__PURE__*/React.memo(props => {
const {
text,
checked,
onPress,
disabled,
checkedColor,
uncheckedColor,
textProps,
contentAlign,
style,
theme,
...other
} = props;
const {
style: textStyle,
...rest
} = textProps ?? {};
const _checkedColor = checkedColor ?? theme.colors.primary;
const _rippleColor = (0, _tinycolor.default)(_checkedColor).setAlpha(0.25).toHex8String();
const _flattenStyle = _reactNative.StyleSheet.flatten(style ?? {});
const {
padding,
paddingHorizontal,
paddingVertical,
paddingTop,
paddingBottom,
paddingStart,
paddingEnd,
paddingRight,
paddingLeft
} = _flattenStyle;
const _borderRadius = (theme.isV3 ? 5 : 1) * theme.roundness;
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: _reactNative.StyleSheet.flatten([_CompoundButtonStyles.default.container, {
borderRadius: _borderRadius
}, style, _CompoundButtonStyles.default.noPadding]),
...other,
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativePaper.TouchableRipple, {
onPress: onPress,
disabled: disabled,
rippleColor: _rippleColor,
underlayColor: _rippleColor,
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
style: _reactNative.StyleSheet.flatten([_CompoundButtonStyles.default.rippleView, {
padding,
paddingHorizontal,
paddingVertical,
paddingTop,
paddingBottom,
paddingStart,
paddingEnd,
paddingRight,
paddingLeft,
alignItems: contentAlign ?? 'center'
}]),
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativePaper.RadioButton.Android, {
value: text ?? 'radio',
status: checked ? 'checked' : 'unchecked',
onPress: onPress,
color: _checkedColor,
uncheckedColor: uncheckedColor,
disabled: disabled
}), Boolean(text) && Boolean(text?.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Text, {
style: _reactNative.StyleSheet.flatten([_CompoundButtonStyles.default.text, textStyle]),
...rest,
children: text
})]
})
})
});
});
var _default = exports.default = (0, _reactNativePaper.withTheme)(RadioButton);
//# sourceMappingURL=RadioButton.js.map