70 lines
3.0 KiB
JavaScript
70 lines
3.0 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (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 () {
|
|
var ownKeys = function(o) {
|
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
var ar = [];
|
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
return ar;
|
|
};
|
|
return ownKeys(o);
|
|
};
|
|
return function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.Slot = void 0;
|
|
const react_slot_1 = require("@radix-ui/react-slot");
|
|
const react_1 = __importStar(require("react"));
|
|
const react_native_1 = require("react-native");
|
|
/**
|
|
* RadixUI has special logic to handle the merging of `style` and `className` props.
|
|
* On the web styles are not allowed so Radix does not handle this scenario.
|
|
* This could be fixed upstream (PR open), but it may not as RN is not their target
|
|
* platform.
|
|
*
|
|
* This shim calls `StyleSheet.flatten` on the styles before we render the <Slot />
|
|
*
|
|
* @see https://github.com/expo/expo/issues/31352
|
|
* @see https://github.com/radix-ui/primitives/issues/3107
|
|
* @param Component
|
|
* @returns
|
|
*/
|
|
function ShimSlotForReactNative(Component) {
|
|
return (0, react_1.forwardRef)(function RNSlotHOC({ style, ...props }, ref) {
|
|
style = (0, react_1.useMemo)(() => react_native_1.StyleSheet.flatten(style), [style]);
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
if (react_1.default.isValidElement(props.children)) {
|
|
if (typeof props.children.props === 'object' &&
|
|
props.children.props !== null &&
|
|
'style' in props.children.props &&
|
|
Array.isArray(props.children.props.style)) {
|
|
throw new Error(`[expo-router]: You are passing an array of styles to a child of <Slot>. Consider flattening the styles with StyleSheet.flatten before passing them to the child component.`);
|
|
}
|
|
}
|
|
}
|
|
return <Component ref={ref} {...props} style={style}/>;
|
|
});
|
|
}
|
|
exports.Slot = ShimSlotForReactNative(react_slot_1.Slot);
|
|
//# sourceMappingURL=Slot.js.map
|