@arpitbhalla/rneui-base-dev
Version:
Cross Platform React Native UI Toolkit
84 lines (83 loc) • 4.21 kB
JavaScript
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Overlay = void 0;
var react_1 = __importDefault(require("react"));
var react_native_1 = require("react-native");
var color_1 = __importDefault(require("color"));
var helpers_1 = require("../helpers");
var Overlay = function (_a) {
var _b;
var children = _a.children, backdropStyle = _a.backdropStyle, overlayStyle = _a.overlayStyle, _c = _a.onBackdropPress, onBackdropPress = _c === void 0 ? function () { return null; } : _c, _d = _a.fullScreen, fullScreen = _d === void 0 ? false : _d, _e = _a.ModalComponent, ModalComponent = _e === void 0 ? react_native_1.Modal : _e, isVisible = _a.isVisible, pressableProps = _a.pressableProps, onPressOut = _a.onPressOut, onPressIn = _a.onPressIn, onLongPress = _a.onLongPress, theme = _a.theme, rest = __rest(_a, ["children", "backdropStyle", "overlayStyle", "onBackdropPress", "fullScreen", "ModalComponent", "isVisible", "pressableProps", "onPressOut", "onPressIn", "onLongPress", "theme"]);
return (react_1.default.createElement(ModalComponent, __assign({ visible: isVisible, onRequestClose: onBackdropPress, transparent: true }, rest),
react_1.default.createElement(react_native_1.Pressable, __assign({ style: react_native_1.StyleSheet.flatten([styles.backdrop, backdropStyle]), onPress: onBackdropPress, testID: "RNE__Overlay__backdrop" }, pressableProps, { onPressOut: onPressOut, onPressIn: onPressIn, onLongPress: onLongPress })),
react_1.default.createElement(react_native_1.KeyboardAvoidingView, { testID: "RNE__Overlay__Container", style: styles.container, pointerEvents: "box-none", behavior: helpers_1.getBehaviorType },
react_1.default.createElement(react_native_1.View, { testID: "RNE__Overlay", style: react_native_1.StyleSheet.flatten([
styles.overlay,
fullScreen && styles.fullscreen,
{
backgroundColor: (0, color_1.default)((_b = theme === null || theme === void 0 ? void 0 : theme.colors) === null || _b === void 0 ? void 0 : _b.white)
.lighten(10)
.rgb()
.toString(),
},
overlayStyle,
]) }, children))));
};
exports.Overlay = Overlay;
var styles = react_native_1.StyleSheet.create({
backdrop: {
position: 'absolute',
top: 0,
left: 0,
width: '100%',
height: '100%',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(0, 0, 0, .4)',
},
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
fullscreen: {
width: '100%',
height: '100%',
},
overlay: __assign({ backgroundColor: 'white', borderRadius: 3, padding: 10 }, react_native_1.Platform.select({
android: {
elevation: 2,
},
default: {
shadowColor: 'rgba(0, 0, 0, .3)',
shadowOffset: { width: 0, height: 1 },
shadowRadius: 4,
},
})),
});
exports.Overlay.displayName = 'Overlay';