{"version":3,"file":"OptionalPortal.cjs","names":["factory","useMantineEnv","Portal"],"sources":["../../../src/components/Portal/OptionalPortal.tsx"],"sourcesContent":["import { factory, Factory, useMantineEnv } from '../../core';\nimport { Portal, PortalProps } from './Portal';\n\nexport interface OptionalPortalProps extends PortalProps {\n  /**\n   * Determines whether children should be rendered inside Portal.\n   * When false, children are rendered as regular React children.\n   *\n   * Note: In test environment, Portal is always disabled regardless of this value.\n   *\n   * @default true\n   */\n  withinPortal?: boolean;\n}\n\nexport type OptionalPortalFactory = Factory<{\n  props: OptionalPortalProps;\n  ref: HTMLDivElement;\n}>;\n\nexport const OptionalPortal = factory<OptionalPortalFactory>(\n  ({ withinPortal = true, children, ...others }) => {\n    const env = useMantineEnv();\n\n    if (env === 'test' || !withinPortal) {\n      return <>{children}</>;\n    }\n\n    return <Portal {...others}>{children}</Portal>;\n  }\n);\n\nOptionalPortal.displayName = '@mantine/core/OptionalPortal';\n"],"mappings":";;;;;;;AAoBA,MAAa,iBAAiBA,gBAAAA,SAC3B,EAAE,eAAe,MAAM,UAAU,GAAG,aAAa;AAGhD,KAFYC,wBAAAA,eAAe,KAEf,UAAU,CAAC,aACrB,QAAO,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAG,UAAY,CAAA;AAGxB,QAAO,iBAAA,GAAA,kBAAA,KAACC,eAAAA,QAAD;EAAQ,GAAI;EAAS;EAAkB,CAAA;EAEjD;AAED,eAAe,cAAc"}