react-native-blitzllama
Version:
Blitzllama React Native Library
37 lines (36 loc) • 2 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheckBox = void 0;
/* eslint-disable react-hooks/exhaustive-deps */
const React = __importStar(require("react"));
const react_native_1 = require("react-native");
const utils_1 = require("./utils");
// Create an animated version of Pressable
const AnimatedPressable = react_native_1.Animated.createAnimatedComponent(react_native_1.Pressable);
const CheckBox = ({ isChecked, isDisabled = false, onPress, ...styleProps }) => {
const animRef = React.useRef(new react_native_1.Animated.Value(1)).current;
const { containerStyle, checkMarkStyle } = (0, utils_1.getCheckBoxStyles)(styleProps, animRef);
return (<AnimatedPressable onPress={onPress} disabled={isDisabled} style={[containerStyle, isDisabled && { opacity: 0.2 }]} onPressIn={() => (0, utils_1.handleAnimation)(animRef, styleProps.animationType, 'PRESS_IN')} onPressOut={() => (0, utils_1.handleAnimation)(animRef, styleProps.animationType, 'PRESS_OUT')} hitSlop={8}>
{isChecked && <react_native_1.View style={checkMarkStyle}/>}
</AnimatedPressable>);
};
exports.CheckBox = CheckBox;