@mdx-js/react
Advanced tools
| export { MDXProvider, useMDXComponents } from "./lib/index.js"; |
+1
| export {MDXProvider, useMDXComponents} from './lib/index.js' |
| /** | ||
| * Get current components from the MDX Context. | ||
| * | ||
| * @param {Readonly<MDXComponents> | MergeComponents | null | undefined} [components] | ||
| * Additional components to use or a function that creates them (optional). | ||
| * @returns {MDXComponents} | ||
| * Current components. | ||
| */ | ||
| export function useMDXComponents(components?: Readonly<MDXComponents> | MergeComponents | null | undefined): MDXComponents; | ||
| /** | ||
| * Provider for MDX context. | ||
| * | ||
| * @param {Readonly<Props>} props | ||
| * Props. | ||
| * @returns {JSX.Element} | ||
| * Element. | ||
| * @satisfies {Component} | ||
| */ | ||
| export function MDXProvider(props: Readonly<Props>): JSX.Element; | ||
| export type MDXComponents = import('mdx/types.js').MDXComponents; | ||
| export type Component = import('react').Component<{}, {}, unknown>; | ||
| export type ReactNode = import('react').ReactNode; | ||
| /** | ||
| * Custom merge function. | ||
| */ | ||
| export type MergeComponents = (currentComponents: Readonly<MDXComponents>) => MDXComponents; | ||
| /** | ||
| * Configuration for `MDXProvider`. | ||
| */ | ||
| export type Props = { | ||
| /** | ||
| * Children (optional). | ||
| */ | ||
| children?: ReactNode | null | undefined; | ||
| /** | ||
| * Additional components to use or a function that creates them (optional). | ||
| */ | ||
| components?: Readonly<MDXComponents> | MergeComponents | null | undefined; | ||
| /** | ||
| * Turn off outer component context (default: `false`). | ||
| */ | ||
| disableParentContext?: boolean | null | undefined; | ||
| }; |
+84
| /** | ||
| * @typedef {import('mdx/types.js').MDXComponents} MDXComponents | ||
| * @typedef {import('react').Component<{}, {}, unknown>} Component | ||
| * @typedef {import('react').ReactNode} ReactNode | ||
| */ | ||
| /** | ||
| * @callback MergeComponents | ||
| * Custom merge function. | ||
| * @param {Readonly<MDXComponents>} currentComponents | ||
| * Current components from the context. | ||
| * @returns {MDXComponents} | ||
| * Additional components. | ||
| * | ||
| * @typedef Props | ||
| * Configuration for `MDXProvider`. | ||
| * @property {ReactNode | null | undefined} [children] | ||
| * Children (optional). | ||
| * @property {Readonly<MDXComponents> | MergeComponents | null | undefined} [components] | ||
| * Additional components to use or a function that creates them (optional). | ||
| * @property {boolean | null | undefined} [disableParentContext=false] | ||
| * Turn off outer component context (default: `false`). | ||
| */ | ||
| import React from 'react' | ||
| /** @type {Readonly<MDXComponents>} */ | ||
| const emptyComponents = {} | ||
| const MDXContext = React.createContext(emptyComponents) | ||
| /** | ||
| * Get current components from the MDX Context. | ||
| * | ||
| * @param {Readonly<MDXComponents> | MergeComponents | null | undefined} [components] | ||
| * Additional components to use or a function that creates them (optional). | ||
| * @returns {MDXComponents} | ||
| * Current components. | ||
| */ | ||
| export function useMDXComponents(components) { | ||
| const contextComponents = React.useContext(MDXContext) | ||
| // Memoize to avoid unnecessary top-level context changes | ||
| return React.useMemo( | ||
| function () { | ||
| // Custom merge via a function prop | ||
| if (typeof components === 'function') { | ||
| return components(contextComponents) | ||
| } | ||
| return {...contextComponents, ...components} | ||
| }, | ||
| [contextComponents, components] | ||
| ) | ||
| } | ||
| /** | ||
| * Provider for MDX context. | ||
| * | ||
| * @param {Readonly<Props>} props | ||
| * Props. | ||
| * @returns {JSX.Element} | ||
| * Element. | ||
| * @satisfies {Component} | ||
| */ | ||
| export function MDXProvider(props) { | ||
| /** @type {Readonly<MDXComponents>} */ | ||
| let allComponents | ||
| if (props.disableParentContext) { | ||
| allComponents = | ||
| typeof props.components === 'function' | ||
| ? props.components(emptyComponents) | ||
| : props.components || emptyComponents | ||
| } else { | ||
| allComponents = useMDXComponents(props.components) | ||
| } | ||
| return React.createElement( | ||
| MDXContext.Provider, | ||
| {value: allComponents}, | ||
| props.children | ||
| ) | ||
| } |
+54
-20
| { | ||
| "name": "@mdx-js/react", | ||
| "version": "1.6.22", | ||
| "description": "React implementation for MDX", | ||
| "repository": "mdx-js/mdx", | ||
| "version": "3.0.0", | ||
| "description": "React context for MDX", | ||
| "license": "MIT", | ||
| "keywords": [ | ||
| "jsx", | ||
| "markdown", | ||
| "mdx", | ||
| "react", | ||
| "remark" | ||
| ], | ||
| "homepage": "https://mdxjs.com", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/mdx-js/mdx", | ||
| "directory": "packages/react/" | ||
| }, | ||
| "bugs": "https://github.com/mdx-js/mdx/issues", | ||
@@ -12,28 +24,50 @@ "funding": { | ||
| }, | ||
| "author": "John Otander <johnotander@gmail.com> (http://johnotander.com)", | ||
| "author": "John Otander <johnotander@gmail.com> (https://johno.com)", | ||
| "contributors": [ | ||
| "John Otander <johnotander@gmail.com> (http://johnotander.com)", | ||
| "John Otander <johnotander@gmail.com> (https://johno.com)", | ||
| "Tim Neutkens <tim@vercel.com>", | ||
| "Matija Marohnić <matija.marohnic@gmail.com>", | ||
| "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)", | ||
| "JounQin <admin@1stg.me> (https://www.1stg.me)" | ||
| "JounQin <admin@1stg.me> (https://www.1stg.me)", | ||
| "Christian Murphy <christian.murphy.42@gmail.com>" | ||
| ], | ||
| "license": "MIT", | ||
| "main": "dist/cjs.js", | ||
| "module": "dist/esm.js", | ||
| "type": "module", | ||
| "sideEffects": false, | ||
| "exports": "./index.js", | ||
| "files": [ | ||
| "dist" | ||
| "lib/", | ||
| "index.d.ts", | ||
| "index.js" | ||
| ], | ||
| "keywords": [ | ||
| "mdx", | ||
| "markdown", | ||
| "react", | ||
| "jsx", | ||
| "remark", | ||
| "mdxast" | ||
| ], | ||
| "dependencies": { | ||
| "@types/mdx": "^2.0.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": "^16.13.1 || ^17.0.0" | ||
| "@types/react": ">=16", | ||
| "react": ">=16" | ||
| }, | ||
| "gitHead": "510bae2580958598ae29047bf755b1a2ea26cf7e" | ||
| "devDependencies": {}, | ||
| "scripts": { | ||
| "test": "npm run test-coverage", | ||
| "test-api": "node --conditions development --loader=../../script/jsx-loader.js test/index.jsx", | ||
| "test-coverage": "c8 --100 --reporter lcov npm run test-api" | ||
| }, | ||
| "xo": { | ||
| "overrides": [ | ||
| { | ||
| "extends": "xo-react", | ||
| "files": [ | ||
| "**/*.jsx" | ||
| ], | ||
| "rules": { | ||
| "react/jsx-no-bind": "off", | ||
| "react/react-in-jsx-scope": "off" | ||
| } | ||
| } | ||
| ], | ||
| "prettier": true, | ||
| "rules": { | ||
| "n/file-extension-in-import": "off" | ||
| } | ||
| } | ||
| } |
+236
-43
| # `@mdx-js/react` | ||
| [![Build Status][build-badge]][build] | ||
| [![lerna][lerna-badge]][lerna] | ||
| [![Build][build-badge]][build] | ||
| [![Coverage][coverage-badge]][coverage] | ||
| [![Downloads][downloads-badge]][downloads] | ||
| [![Size][size-badge]][size] | ||
| [![Sponsors][sponsors-badge]][collective] | ||
| [![Backers][backers-badge]][collective] | ||
| [![Chat][chat-badge]][chat] | ||
| Map components to HTML elements based on the Markdown syntax. | ||
| Serves as the React implementation for [MDX][]. | ||
| React context for MDX. | ||
| ## Installation | ||
| <!-- more --> | ||
| [npm][]: | ||
| ## Contents | ||
| * [What is this?](#what-is-this) | ||
| * [When should I use this?](#when-should-i-use-this) | ||
| * [Install](#install) | ||
| * [Use](#use) | ||
| * [API](#api) | ||
| * [`MDXProvider(props?)`](#mdxproviderprops) | ||
| * [`useMDXComponents(components?)`](#usemdxcomponentscomponents) | ||
| * [`MergeComponents`](#mergecomponents) | ||
| * [`Props`](#props) | ||
| * [Types](#types) | ||
| * [Compatibility](#compatibility) | ||
| * [Security](#security) | ||
| * [Contribute](#contribute) | ||
| * [License](#license) | ||
| ## What is this? | ||
| This package is a *context* based components provider for combining React with | ||
| MDX. | ||
| ## When should I use this? | ||
| This package is **not needed** for MDX to work with React. | ||
| See [¶ MDX provider in § Using MDX][use-provider] for when and how to use an MDX | ||
| provider. | ||
| If you use Next.js, **do not use this**. | ||
| Add an `mdx-components.tsx` (in `src/` or `/`) file instead. | ||
| See [Configuring MDX on `nextjs.org`][next-configuring-mdx] for more info. | ||
| ## Install | ||
| This package is [ESM only][esm]. | ||
| In Node.js (version 16+), install with [npm][]: | ||
| ```sh | ||
| npm install --save @mdx-js/react | ||
| npm install @mdx-js/react | ||
| ``` | ||
| ## Usage | ||
| In Deno with [`esm.sh`][esmsh]: | ||
| ```md | ||
| <!-- helloworld.md --> | ||
| ```tsx | ||
| import {MDXProvider} from 'https://esm.sh/@mdx-js/react@2' | ||
| ``` | ||
| # Hello, World! | ||
| In browsers with [`esm.sh`][esmsh]: | ||
| ```html | ||
| <script type="module"> | ||
| import {MDXProvider} from 'https://esm.sh/@mdx-js/react@2?bundle' | ||
| </script> | ||
| ``` | ||
| ```jsx | ||
| import React from 'react' | ||
| ## Use | ||
| ```tsx | ||
| import {MDXProvider} from '@mdx-js/react' | ||
| import {renderToString} from 'react-dom/server' | ||
| import Post from './post.mdx' | ||
| // ^-- Assumes an integration is used to compile MDX to JS, such as | ||
| // `@mdx-js/esbuild`, `@mdx-js/loader`, `@mdx-js/node-loader`, or | ||
| // `@mdx-js/rollup`, and that it is configured with | ||
| // `options.providerImportSource: '@mdx-js/react'`. | ||
| import HelloWorld from './helloworld.md' | ||
| /** @type {import('mdx/types.js').MDXComponents} */ | ||
| const components = { | ||
| em(props) { | ||
| return <i {...props} /> | ||
| } | ||
| } | ||
| const H1 = props => <h1 style={{color: 'tomato'}} {...props} /> | ||
| console.log( | ||
| renderToString( | ||
| <MDXProvider components={{h1: H1}}> | ||
| <HelloWorld /> | ||
| </MDXProvider> | ||
| ) | ||
| <MDXProvider components={components}> | ||
| <Post /> | ||
| </MDXProvider> | ||
| ) | ||
| ``` | ||
| Yields: | ||
| > 👉 **Note**: you don’t have to use `MDXProvider` and can pass components | ||
| > directly: | ||
| > | ||
| > ```diff | ||
| > -<MDXProvider components={components}> | ||
| > - <Post /> | ||
| > -</MDXProvider> | ||
| > +<Post components={components} /> | ||
| > ``` | ||
| ```html | ||
| <h1 style="color:tomato">Hello, world!</h1> | ||
| ``` | ||
| See [¶ React in § Getting started][start-react] for how to get started with MDX | ||
| and React. | ||
| See [¶ MDX provider in § Using MDX][use-provider] for how to use an MDX | ||
| provider. | ||
| ## API | ||
| This package exports the identifiers [`MDXProvider`][api-mdx-provider] and | ||
| [`useMDXComponents`][api-use-mdx-components]. | ||
| There is no default export. | ||
| ### `MDXProvider(props?)` | ||
| Provider for MDX context. | ||
| ###### Parameters | ||
| * `props` ([`Props`][api-props]) | ||
| — configuration | ||
| ##### Returns | ||
| Element (`JSX.Element`). | ||
| ### `useMDXComponents(components?)` | ||
| Get current components from the MDX Context. | ||
| ###### Parameters | ||
| * `components` ([`MDXComponents` from `mdx/types.js`][mdx-types-components] | ||
| or [`MergeComponents`][api-merge-components], optional) | ||
| — additional components to use or a function that creates them | ||
| ###### Returns | ||
| Current components ([`MDXComponents` from | ||
| `mdx/types.js`][mdx-types-components]). | ||
| ### `MergeComponents` | ||
| Custom merge function (TypeScript type). | ||
| ###### Parameters | ||
| * `components` ([`MDXComponents` from `mdx/types.js`][mdx-types-components]) | ||
| — current components from the context | ||
| ###### Returns | ||
| Additional components ([`MDXComponents` from | ||
| `mdx/types.js`][mdx-types-components]). | ||
| ### `Props` | ||
| Configuration for `MDXProvider` (TypeScript type). | ||
| ###### Fields | ||
| * `children` ([`ReactNode` from `react`][react-node], | ||
| optional) | ||
| — children | ||
| * `components` ([`MDXComponents` from `mdx/types.js`][mdx-types-components] | ||
| or [`MergeComponents`][api-merge-components], optional) | ||
| — additional components to use or a function that creates them | ||
| * `disableParentContext` (`boolean`, default: `false`) | ||
| — turn off outer component context | ||
| ## Types | ||
| This package is fully typed with [TypeScript][]. | ||
| It exports the additional types [`MergeComponents`][api-merge-components] and | ||
| [`Props`][api-props]. | ||
| For types to work, make sure the TypeScript `JSX` namespace is typed. | ||
| This is done by installing and using the types of your framework, as in | ||
| [`@types/react`](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react). | ||
| ## Compatibility | ||
| Projects maintained by the unified collective are compatible with maintained | ||
| versions of Node.js. | ||
| When we cut a new major release, we drop support for unmaintained versions of | ||
| Node. | ||
| This means we try to keep the current release line, `@mdx-js/react@^3`, | ||
| compatible with Node.js 16. | ||
| ## Security | ||
| See [§ Security][security] on our website for information. | ||
| ## Contribute | ||
| See the [Support][] and [Contributing][] guidelines on the MDX website for ways | ||
| to (get) help. | ||
| See [§ Contribute][contribute] on our website for ways to get started. | ||
| See [§ Support][support] for ways to get help. | ||
| This project has a [Code of Conduct][coc]. | ||
| By interacting with this repository, organisation, or community you agree to | ||
| This project has a [code of conduct][coc]. | ||
| By interacting with this repository, organization, or community you agree to | ||
| abide by its terms. | ||
@@ -61,19 +207,66 @@ | ||
| [MIT][] © [Compositor][] and [Vercel][] | ||
| [MIT][] © Compositor and [Vercel][] | ||
| <!-- Definitions --> | ||
| [build-badge]: https://github.com/mdx-js/mdx/workflows/main/badge.svg | ||
| [build]: https://travis-ci.com/mdx-js/mdx | ||
| [build-badge]: https://travis-ci.com/mdx-js/mdx.svg?branch=master | ||
| [lerna]: https://lerna.js.org/ | ||
| [lerna-badge]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg | ||
| [build]: https://github.com/mdx-js/mdx/actions | ||
| [coverage-badge]: https://img.shields.io/codecov/c/github/mdx-js/mdx/main.svg | ||
| [coverage]: https://codecov.io/github/mdx-js/mdx | ||
| [downloads-badge]: https://img.shields.io/npm/dm/@mdx-js/react.svg | ||
| [downloads]: https://www.npmjs.com/package/@mdx-js/react | ||
| [size-badge]: https://img.shields.io/bundlejs/size/@mdx-js/react | ||
| [size]: https://bundlejs.com/?q=@mdx-js/react | ||
| [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
| [backers-badge]: https://opencollective.com/unified/backers/badge.svg | ||
| [collective]: https://opencollective.com/unified | ||
| [chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg | ||
| [chat]: https://github.com/mdx-js/mdx/discussions | ||
| [contributing]: https://mdxjs.com/contributing | ||
| [support]: https://mdxjs.com/support | ||
| [coc]: https://github.com/mdx-js/.github/blob/master/code-of-conduct.md | ||
| [mit]: license | ||
| [compositor]: https://compositor.io | ||
| [npm]: https://docs.npmjs.com/cli/install | ||
| [contribute]: https://mdxjs.com/community/contribute/ | ||
| [support]: https://mdxjs.com/community/support/ | ||
| [coc]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md | ||
| [mit]: https://github.com/mdx-js/mdx/blob/main/packages/react/license | ||
| [vercel]: https://vercel.com | ||
| [mdx]: https://github.com/mdx-js/mdx | ||
| [npm]: https://docs.npmjs.com/cli/install | ||
| [start-react]: https://mdxjs.com/getting-started/#react | ||
| [use-provider]: https://mdxjs.com/docs/using-mdx/#mdx-provider | ||
| [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
| [esmsh]: https://esm.sh | ||
| [security]: https://mdxjs.com/getting-started/#security | ||
| [typescript]: https://www.typescriptlang.org | ||
| [mdx-types-components]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/HEAD/types/mdx/types.d.ts#L65 | ||
| [react-node]: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/HEAD/types/react/index.d.ts#L244 | ||
| [next-configuring-mdx]: https://nextjs.org/docs/pages/building-your-application/configuring/mdx | ||
| [api-mdx-provider]: #mdxproviderprops | ||
| [api-merge-components]: #mergecomponents | ||
| [api-props]: #props | ||
| [api-use-mdx-components]: #usemdxcomponentscomponents |
-210
| 'use strict'; | ||
| Object.defineProperty(exports, '__esModule', { value: true }); | ||
| var React = require('react'); | ||
| function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
| var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
| function _defineProperty(obj, key, value) { | ||
| if (key in obj) { | ||
| Object.defineProperty(obj, key, { | ||
| value: value, | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true | ||
| }); | ||
| } else { | ||
| obj[key] = value; | ||
| } | ||
| return obj; | ||
| } | ||
| function _extends() { | ||
| _extends = Object.assign || function (target) { | ||
| for (var i = 1; i < arguments.length; i++) { | ||
| var source = arguments[i]; | ||
| for (var key in source) { | ||
| if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
| target[key] = source[key]; | ||
| } | ||
| } | ||
| } | ||
| return target; | ||
| }; | ||
| return _extends.apply(this, arguments); | ||
| } | ||
| function ownKeys(object, enumerableOnly) { | ||
| var keys = Object.keys(object); | ||
| if (Object.getOwnPropertySymbols) { | ||
| var symbols = Object.getOwnPropertySymbols(object); | ||
| if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
| return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
| }); | ||
| keys.push.apply(keys, symbols); | ||
| } | ||
| return keys; | ||
| } | ||
| function _objectSpread2(target) { | ||
| for (var i = 1; i < arguments.length; i++) { | ||
| var source = arguments[i] != null ? arguments[i] : {}; | ||
| if (i % 2) { | ||
| ownKeys(Object(source), true).forEach(function (key) { | ||
| _defineProperty(target, key, source[key]); | ||
| }); | ||
| } else if (Object.getOwnPropertyDescriptors) { | ||
| Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
| } else { | ||
| ownKeys(Object(source)).forEach(function (key) { | ||
| Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
| }); | ||
| } | ||
| } | ||
| return target; | ||
| } | ||
| function _objectWithoutPropertiesLoose(source, excluded) { | ||
| if (source == null) return {}; | ||
| var target = {}; | ||
| var sourceKeys = Object.keys(source); | ||
| var key, i; | ||
| for (i = 0; i < sourceKeys.length; i++) { | ||
| key = sourceKeys[i]; | ||
| if (excluded.indexOf(key) >= 0) continue; | ||
| target[key] = source[key]; | ||
| } | ||
| return target; | ||
| } | ||
| function _objectWithoutProperties(source, excluded) { | ||
| if (source == null) return {}; | ||
| var target = _objectWithoutPropertiesLoose(source, excluded); | ||
| var key, i; | ||
| if (Object.getOwnPropertySymbols) { | ||
| var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
| for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
| key = sourceSymbolKeys[i]; | ||
| if (excluded.indexOf(key) >= 0) continue; | ||
| if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
| target[key] = source[key]; | ||
| } | ||
| } | ||
| return target; | ||
| } | ||
| var isFunction = function isFunction(obj) { | ||
| return typeof obj === 'function'; | ||
| }; | ||
| var MDXContext = /*#__PURE__*/React__default['default'].createContext({}); | ||
| var withMDXComponents = function withMDXComponents(Component) { | ||
| return function (props) { | ||
| var allComponents = useMDXComponents(props.components); | ||
| return /*#__PURE__*/React__default['default'].createElement(Component, _extends({}, props, { | ||
| components: allComponents | ||
| })); | ||
| }; | ||
| }; | ||
| var useMDXComponents = function useMDXComponents(components) { | ||
| var contextComponents = React__default['default'].useContext(MDXContext); | ||
| var allComponents = contextComponents; | ||
| if (components) { | ||
| allComponents = isFunction(components) ? components(contextComponents) : _objectSpread2(_objectSpread2({}, contextComponents), components); | ||
| } | ||
| return allComponents; | ||
| }; | ||
| var MDXProvider = function MDXProvider(props) { | ||
| var allComponents = useMDXComponents(props.components); | ||
| return /*#__PURE__*/React__default['default'].createElement(MDXContext.Provider, { | ||
| value: allComponents | ||
| }, props.children); | ||
| }; | ||
| var TYPE_PROP_NAME = 'mdxType'; | ||
| var DEFAULTS = { | ||
| inlineCode: 'code', | ||
| wrapper: function wrapper(_ref) { | ||
| var children = _ref.children; | ||
| return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, {}, children); | ||
| } | ||
| }; | ||
| var MDXCreateElement = /*#__PURE__*/React__default['default'].forwardRef(function (props, ref) { | ||
| var propComponents = props.components, | ||
| mdxType = props.mdxType, | ||
| originalType = props.originalType, | ||
| parentName = props.parentName, | ||
| etc = _objectWithoutProperties(props, ["components", "mdxType", "originalType", "parentName"]); | ||
| var components = useMDXComponents(propComponents); | ||
| var type = mdxType; | ||
| var Component = components["".concat(parentName, ".").concat(type)] || components[type] || DEFAULTS[type] || originalType; | ||
| if (propComponents) { | ||
| return /*#__PURE__*/React__default['default'].createElement(Component, _objectSpread2(_objectSpread2({ | ||
| ref: ref | ||
| }, etc), {}, { | ||
| components: propComponents | ||
| })); | ||
| } | ||
| return /*#__PURE__*/React__default['default'].createElement(Component, _objectSpread2({ | ||
| ref: ref | ||
| }, etc)); | ||
| }); | ||
| MDXCreateElement.displayName = 'MDXCreateElement'; | ||
| function createElement (type, props) { | ||
| var args = arguments; | ||
| var mdxType = props && props.mdxType; | ||
| if (typeof type === 'string' || mdxType) { | ||
| var argsLength = args.length; | ||
| var createElementArgArray = new Array(argsLength); | ||
| createElementArgArray[0] = MDXCreateElement; | ||
| var newProps = {}; | ||
| for (var key in props) { | ||
| if (hasOwnProperty.call(props, key)) { | ||
| newProps[key] = props[key]; | ||
| } | ||
| } | ||
| newProps.originalType = type; | ||
| newProps[TYPE_PROP_NAME] = typeof type === 'string' ? type : mdxType; | ||
| createElementArgArray[1] = newProps; | ||
| for (var i = 2; i < argsLength; i++) { | ||
| createElementArgArray[i] = args[i]; | ||
| } | ||
| return React__default['default'].createElement.apply(null, createElementArgArray); | ||
| } | ||
| return React__default['default'].createElement.apply(null, args); | ||
| } | ||
| exports.MDXContext = MDXContext; | ||
| exports.MDXProvider = MDXProvider; | ||
| exports.mdx = createElement; | ||
| exports.useMDXComponents = useMDXComponents; | ||
| exports.withMDXComponents = withMDXComponents; |
-198
| import React from 'react'; | ||
| function _defineProperty(obj, key, value) { | ||
| if (key in obj) { | ||
| Object.defineProperty(obj, key, { | ||
| value: value, | ||
| enumerable: true, | ||
| configurable: true, | ||
| writable: true | ||
| }); | ||
| } else { | ||
| obj[key] = value; | ||
| } | ||
| return obj; | ||
| } | ||
| function _extends() { | ||
| _extends = Object.assign || function (target) { | ||
| for (var i = 1; i < arguments.length; i++) { | ||
| var source = arguments[i]; | ||
| for (var key in source) { | ||
| if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
| target[key] = source[key]; | ||
| } | ||
| } | ||
| } | ||
| return target; | ||
| }; | ||
| return _extends.apply(this, arguments); | ||
| } | ||
| function ownKeys(object, enumerableOnly) { | ||
| var keys = Object.keys(object); | ||
| if (Object.getOwnPropertySymbols) { | ||
| var symbols = Object.getOwnPropertySymbols(object); | ||
| if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
| return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
| }); | ||
| keys.push.apply(keys, symbols); | ||
| } | ||
| return keys; | ||
| } | ||
| function _objectSpread2(target) { | ||
| for (var i = 1; i < arguments.length; i++) { | ||
| var source = arguments[i] != null ? arguments[i] : {}; | ||
| if (i % 2) { | ||
| ownKeys(Object(source), true).forEach(function (key) { | ||
| _defineProperty(target, key, source[key]); | ||
| }); | ||
| } else if (Object.getOwnPropertyDescriptors) { | ||
| Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
| } else { | ||
| ownKeys(Object(source)).forEach(function (key) { | ||
| Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
| }); | ||
| } | ||
| } | ||
| return target; | ||
| } | ||
| function _objectWithoutPropertiesLoose(source, excluded) { | ||
| if (source == null) return {}; | ||
| var target = {}; | ||
| var sourceKeys = Object.keys(source); | ||
| var key, i; | ||
| for (i = 0; i < sourceKeys.length; i++) { | ||
| key = sourceKeys[i]; | ||
| if (excluded.indexOf(key) >= 0) continue; | ||
| target[key] = source[key]; | ||
| } | ||
| return target; | ||
| } | ||
| function _objectWithoutProperties(source, excluded) { | ||
| if (source == null) return {}; | ||
| var target = _objectWithoutPropertiesLoose(source, excluded); | ||
| var key, i; | ||
| if (Object.getOwnPropertySymbols) { | ||
| var sourceSymbolKeys = Object.getOwnPropertySymbols(source); | ||
| for (i = 0; i < sourceSymbolKeys.length; i++) { | ||
| key = sourceSymbolKeys[i]; | ||
| if (excluded.indexOf(key) >= 0) continue; | ||
| if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; | ||
| target[key] = source[key]; | ||
| } | ||
| } | ||
| return target; | ||
| } | ||
| var isFunction = function isFunction(obj) { | ||
| return typeof obj === 'function'; | ||
| }; | ||
| var MDXContext = /*#__PURE__*/React.createContext({}); | ||
| var withMDXComponents = function withMDXComponents(Component) { | ||
| return function (props) { | ||
| var allComponents = useMDXComponents(props.components); | ||
| return /*#__PURE__*/React.createElement(Component, _extends({}, props, { | ||
| components: allComponents | ||
| })); | ||
| }; | ||
| }; | ||
| var useMDXComponents = function useMDXComponents(components) { | ||
| var contextComponents = React.useContext(MDXContext); | ||
| var allComponents = contextComponents; | ||
| if (components) { | ||
| allComponents = isFunction(components) ? components(contextComponents) : _objectSpread2(_objectSpread2({}, contextComponents), components); | ||
| } | ||
| return allComponents; | ||
| }; | ||
| var MDXProvider = function MDXProvider(props) { | ||
| var allComponents = useMDXComponents(props.components); | ||
| return /*#__PURE__*/React.createElement(MDXContext.Provider, { | ||
| value: allComponents | ||
| }, props.children); | ||
| }; | ||
| var TYPE_PROP_NAME = 'mdxType'; | ||
| var DEFAULTS = { | ||
| inlineCode: 'code', | ||
| wrapper: function wrapper(_ref) { | ||
| var children = _ref.children; | ||
| return /*#__PURE__*/React.createElement(React.Fragment, {}, children); | ||
| } | ||
| }; | ||
| var MDXCreateElement = /*#__PURE__*/React.forwardRef(function (props, ref) { | ||
| var propComponents = props.components, | ||
| mdxType = props.mdxType, | ||
| originalType = props.originalType, | ||
| parentName = props.parentName, | ||
| etc = _objectWithoutProperties(props, ["components", "mdxType", "originalType", "parentName"]); | ||
| var components = useMDXComponents(propComponents); | ||
| var type = mdxType; | ||
| var Component = components["".concat(parentName, ".").concat(type)] || components[type] || DEFAULTS[type] || originalType; | ||
| if (propComponents) { | ||
| return /*#__PURE__*/React.createElement(Component, _objectSpread2(_objectSpread2({ | ||
| ref: ref | ||
| }, etc), {}, { | ||
| components: propComponents | ||
| })); | ||
| } | ||
| return /*#__PURE__*/React.createElement(Component, _objectSpread2({ | ||
| ref: ref | ||
| }, etc)); | ||
| }); | ||
| MDXCreateElement.displayName = 'MDXCreateElement'; | ||
| function createElement (type, props) { | ||
| var args = arguments; | ||
| var mdxType = props && props.mdxType; | ||
| if (typeof type === 'string' || mdxType) { | ||
| var argsLength = args.length; | ||
| var createElementArgArray = new Array(argsLength); | ||
| createElementArgArray[0] = MDXCreateElement; | ||
| var newProps = {}; | ||
| for (var key in props) { | ||
| if (hasOwnProperty.call(props, key)) { | ||
| newProps[key] = props[key]; | ||
| } | ||
| } | ||
| newProps.originalType = type; | ||
| newProps[TYPE_PROP_NAME] = typeof type === 'string' ? type : mdxType; | ||
| createElementArgArray[1] = newProps; | ||
| for (var i = 2; i < argsLength; i++) { | ||
| createElementArgArray[i] = args[i]; | ||
| } | ||
| return React.createElement.apply(null, createElementArgArray); | ||
| } | ||
| return React.createElement.apply(null, args); | ||
| } | ||
| export { MDXContext, MDXProvider, createElement as mdx, useMDXComponents, withMDXComponents }; |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
7
40%272
244.3%0
-100%Yes
NaN13784
-11.09%3
200%119
-64.16%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed