-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex-MYIS1n96.js
More file actions
91 lines (80 loc) · 2.54 KB
/
index-MYIS1n96.js
File metadata and controls
91 lines (80 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { e as export_default } from './WithTooltip-V3YHNWJZ-D9vTq7wS.js';
import './index-CuLW5E_r.js';
import './index-Kjm4kNkQ.js';
/**
* @typedef {import('react').ReactNode} ReactNode
* @typedef {import('mdx/types.js').MDXComponents} Components
*
* @typedef Props
* Configuration.
* @property {Components | MergeComponents | null | undefined} [components]
* Mapping of names for JSX components to React components.
* @property {boolean | null | undefined} [disableParentContext=false]
* Turn off outer component context.
* @property {ReactNode | null | undefined} [children]
* Children.
*
* @callback MergeComponents
* Custom merge function.
* @param {Components} currentComponents
* Current components from the context.
* @returns {Components}
* Merged components.
*/
/**
* @type {import('react').Context<Components>}
* @deprecated
* This export is marked as a legacy feature.
* That means it’s no longer recommended for use as it might be removed
* in a future major release.
*
* Please use `useMDXComponents` to get context based components and
* `MDXProvider` to set context based components instead.
*/
const MDXContext = export_default.createContext({});
/**
* Get current components from the MDX Context.
*
* @param {Components | MergeComponents | null | undefined} [components]
* Additional components to use or a function that takes the current
* components and filters/merges/changes them.
* @returns {Components}
* Current components.
*/
function useMDXComponents(components) {
const contextComponents = export_default.useContext(MDXContext);
// Memoize to avoid unnecessary top-level context changes
return export_default.useMemo(() => {
// Custom merge via a function prop
if (typeof components === 'function') {
return components(contextComponents)
}
return {...contextComponents, ...components}
}, [contextComponents, components])
}
/** @type {Components} */
const emptyObject = {};
/**
* Provider for MDX context
*
* @param {Props} props
* @returns {JSX.Element}
*/
function MDXProvider({components, children, disableParentContext}) {
/** @type {Components} */
let allComponents;
if (disableParentContext) {
allComponents =
typeof components === 'function'
? components({})
: components || emptyObject;
} else {
allComponents = useMDXComponents(components);
}
return export_default.createElement(
MDXContext.Provider,
{value: allComponents},
children
)
}
export { MDXContext, MDXProvider, useMDXComponents };