one
Version:
One is a React framework for web, iOS, and Android apps.
42 lines (40 loc) • 1.3 kB
JavaScript
const OVERLAY_PRESENTATIONS = [
"modal",
"transparentModal",
"fullScreenModal",
"formSheet",
"pageSheet",
"containedModal",
"containedTransparentModal"
];
function isOverlayPresentation(options) {
const presentation = options?.presentation;
if (!presentation) return false;
return OVERLAY_PRESENTATIONS.includes(presentation);
}
function isTransparentOverlay(options) {
const presentation = options?.presentation;
return presentation === "transparentModal" || presentation === "containedTransparentModal";
}
function convertStackStateToNonOverlayState(state, descriptors, isOverlay = isOverlayPresentation) {
const lastNonOverlay = findLastNonOverlayIndex(state, descriptors, isOverlay);
const routes = state.routes.slice(0, lastNonOverlay + 1);
let index = state.index;
if (index >= routes.length) {
index = routes.length > 0 ? routes.length - 1 : 0;
}
return {
routes,
index
};
}
function findLastNonOverlayIndex(state, descriptors, isOverlay = isOverlayPresentation) {
for (let i = state.index; i >= 0; i--) {
if (!isOverlay(descriptors[state.routes[i].key]?.options)) {
return i;
}
}
return -1;
}
export { convertStackStateToNonOverlayState, findLastNonOverlayIndex, isOverlayPresentation, isTransparentOverlay };
//# sourceMappingURL=stackStateUtils.mjs.map