react-native-trays
Version:
Production-grade, Family inspired, React Native Tray System library
45 lines (44 loc) • 1.34 kB
JavaScript
;
/**
* TrayStackRenderer.tsx
*
* Renders the active tray in a given stack, handling safe area insets and dynamic tray resolution.
*/
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { TrayRenderer } from "./TrayRenderer.js";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
/**
* TrayStackRenderer
*
* Renders the top-most (active) tray in the provided stack using the given configuration and tray registry.
*
* @template T - The tray registry type.
* @param stack - The current stack of trays.
* @param config - Tray stack configuration.
* @param trays - Registry mapping tray keys to tray components.
*/
export const TrayStackRenderer = ({
stack,
config,
trays
}) => {
const insets = useSafeAreaInsets();
const activeTray = stack[stack.length - 1];
if (!activeTray) return null;
const TrayComponent = trays[activeTray.tray]?.component;
return /*#__PURE__*/_jsx(_Fragment, {
children: TrayComponent && /*#__PURE__*/_jsx(TrayRenderer, {
trayKey: activeTray.id,
trayProps: activeTray.props,
config: config,
TrayComponent: TrayComponent,
insets: config.ignoreSafeArea ? {
top: 0,
bottom: 0,
left: 0,
right: 0
} : insets
})
});
};
//# sourceMappingURL=TrayStackRenderer.js.map