react-native-ios-utilities
Version:
Utilities for react-native + iOS and wrappers for using swift together with fabric/paper + JSI
45 lines (44 loc) • 2.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RNIDetachedViewContent = RNIDetachedViewContent;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _index = require("../../native_components/RNIWrapperView/index.js");
var _DetachedSubviewsMap = require("./DetachedSubviewsMap.js");
var _LibEnv = require("../../constants/LibEnv.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function RNIDetachedViewContent(props) {
const [viewID, setViewID] = React.useState();
const wrapperStyle = [props.shouldEnableDebugBackgroundColors && styles.wrapperViewDebug, props.contentContainerStyle];
const detachedSubviewEntry = (viewID != null ? props.detachedSubviewsMap?.[viewID] : undefined) ?? _DetachedSubviewsMap.DEFAULT_DETACHED_SUBVIEW_ENTRY;
const didDetach = (props.isParentDetached ?? false) || detachedSubviewEntry.didDetachFromOriginalParent;
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.RNIWrapperView, {
...props,
style: [...(_LibEnv.IS_USING_NEW_ARCH ? wrapperStyle : []), didDetach ? styles.wrapperViewDetached : styles.wrapperViewAttached, props.style],
onDidSetViewID: event => {
props.onDidSetViewID?.(event);
setViewID(event.nativeEvent.viewID);
props.onDidSetViewID?.(event);
event.stopPropagation();
},
children: _LibEnv.IS_USING_NEW_ARCH ? props.children : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
style: [styles.innerWrapperContainerForPaper, ...wrapperStyle],
children: props.children
})
});
}
;
const styles = _reactNative.StyleSheet.create({
wrapperViewAttached: {},
wrapperViewDetached: {},
wrapperViewDebug: {
backgroundColor: 'rgba(255,0,255,0.3)'
},
innerWrapperContainerForPaper: {
flex: 1
}
});
//# sourceMappingURL=RNIDetachedViewContent.js.map