one
Version:
One is a new React Framework that makes Vite serve both native and web.
33 lines (32 loc) • 1.33 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.routes.length - 1; i >= 0; i--) {
if (!isOverlay(descriptors[state.routes[i].key]?.options)) {
return i;
}
}
return -1;
}
export { convertStackStateToNonOverlayState, findLastNonOverlayIndex, isOverlayPresentation, isTransparentOverlay };
//# sourceMappingURL=stackStateUtils.mjs.map