UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

31 lines (30 loc) 1.34 kB
"use client"; require("../../_virtual/_rolldown/runtime.cjs"); const require_get_default_z_index = require("../../core/utils/get-default-z-index/get-default-z-index.cjs"); let react = require("react"); let react_jsx_runtime = require("react/jsx-runtime"); //#region packages/@mantine/core/src/components/Drawer/DrawerStack.tsx const DrawerStackContext = (0, react.createContext)(null); function DrawerStack({ children }) { const [stack, setStack] = (0, react.useState)([]); const [maxZIndex, setMaxZIndex] = (0, react.useState)(require_get_default_z_index.getDefaultZIndex("modal")); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DrawerStackContext, { value: { stack, addModal: (id, zIndex) => { setStack((current) => [...new Set([...current, id])]); setMaxZIndex((current) => typeof zIndex === "number" && typeof current === "number" ? Math.max(current, zIndex) : current); }, removeModal: (id) => setStack((current) => current.filter((currentId) => currentId !== id)), getZIndex: (id) => `calc(${maxZIndex} + ${stack.indexOf(id)} + 1)`, currentId: stack[stack.length - 1], maxZIndex }, children }); } DrawerStack.displayName = "@mantine/core/DrawerStack"; //#endregion exports.DrawerStack = DrawerStack; exports.DrawerStackContext = DrawerStackContext; //# sourceMappingURL=DrawerStack.cjs.map