2024-08-14 17:01:21 +02:00
|
|
|
{"version":3,"file":"index-CFVANc-Z.js","sources":["../../node_modules/@mdx-js/react/lib/index.js"],"sourcesContent":["/**\n * @typedef {import('mdx/types.js').MDXComponents} MDXComponents\n * @typedef {import('react').Component<{}, {}, unknown>} Component\n * @typedef {import('react').ReactNode} ReactNode\n */\n\n/**\n * @callback MergeComponents\n * Custom merge function.\n * @param {Readonly<MDXComponents>} currentComponents\n * Current components from the context.\n * @returns {MDXComponents}\n * Additional components.\n *\n * @typedef Props\n * Configuration for `MDXProvider`.\n * @property {ReactNode | null | undefined} [children]\n * Children (optional).\n * @property {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]\n * Additional components to use or a function that creates them (optional).\n * @property {boolean | null | undefined} [disableParentContext=false]\n * Turn off outer component context (default: `false`).\n */\n\nimport React from 'react'\n\n/** @type {Readonly<MDXComponents>} */\nconst emptyComponents = {}\n\nconst MDXContext = React.createContext(emptyComponents)\n\n/**\n * Get current components from the MDX Context.\n *\n * @param {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]\n * Additional components to use or a function that creates them (optional).\n * @returns {MDXComponents}\n * Current components.\n */\nexport function useMDXComponents(components) {\n const contextComponents = React.useContext(MDXContext)\n\n // Memoize to avoid unnecessary top-level context changes\n return React.useMemo(\n function () {\n // Custom merge via a function prop\n if (typeof components === 'function') {\n return components(contextComponents)\n }\n\n return {...contextComponents, ...components}\n },\n [contextComponents, components]\n )\n}\n\n/**\n * Provider for MDX context.\n *\n * @param {Readonly<Props>} properties\n * Properties.\n * @returns {JSX.Element}\n * Element.\n * @satisfies {Component}\n */\nexport function MDXProvider(properties) {\n /** @type {Readonly<MDXComponents>} */\n let allComponents\n\n if (properties.disableParentContext) {\n allComponents =\n typeof properties.components === 'function'\n ? properties.components(emptyComponents)\n : properties.components || emptyComponents\n } else {\n allComponents = useMDXComponents(properties.components)\n }\n\n return React.createElement(\n MDXContext.Provider,\n {value: allComponents},\n properties.children\n )\n}\n"],"names":["emptyComponents","MDXContext","React","useMDXComponents","components","contextComponents","MDXProvider","properties","allComponents"],"mappings":"yCA2BA,MAAMA,EAAkB,CAAE,EAEpBC,EAAaC,EAAM,cAAcF,CAAe,EAU/C,SAASG,EAAiBC,EAAY,CAC3C,MAAMC,EAAoBH,EAAM,WAAWD,CAAU,EAGrD,OAAOC,EAAM,QACX,UAAY,CAEV,OAAI,OAAOE,GAAe,WACjBA,EAAWC,CAAiB,EAG9B,CAAC,GAAGA,EAAmB,GAAGD,CAAU,CAC5C,EACD,CAACC,EAAmBD,CAAU,CAC/B,CACH,CAWO,SAASE,EAAYC,EAAY,CAEtC,IAAIC,EAEJ,OAAID,EAAW,qBACbC,EACE,OAAOD,EAAW,YAAe,WAC7BA,EAAW,WAAWP,CAAe,EACrCO,EAAW,YAAcP,EAE/BQ,EAAgBL,EAAiBI,EAAW,UAAU,EAGjDL,EAAM,cACXD,EAAW,SACX,CAAC,MAAOO,CAAa,EACrBD,EAAW,QACZ,CACH","x_google_ignoreList":[0]}
|