@wordpress/block-editor
Version:
8 lines (7 loc) • 1.61 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/block-context/index.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createContext, useContext, useMemo } from '@wordpress/element';\n\n/** @typedef {import('react').ReactNode} ReactNode */\n\n/**\n * @typedef BlockContextProviderProps\n *\n * @property {Record<string,*>} value Context value to merge with current\n * value.\n * @property {ReactNode} children Component children.\n */\n\n/** @type {import('react').Context<Record<string,*>>} */\nconst Context = createContext( {} );\nContext.displayName = 'BlockContext';\n\n/**\n * Component which merges passed value with current consumed block context.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md\n *\n * @param {BlockContextProviderProps} props\n */\nexport function BlockContextProvider( { value, children } ) {\n\tconst context = useContext( Context );\n\tconst nextValue = useMemo(\n\t\t() => ( { ...context, ...value } ),\n\t\t[ context, value ]\n\t);\n\n\treturn <Context.Provider value={ nextValue } children={ children } />;\n}\n\nexport default Context;\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAmD;AA8B3C;AAjBR,IAAM,cAAU,8BAAe,CAAC,CAAE;AAClC,QAAQ,cAAc;AASf,SAAS,qBAAsB,EAAE,OAAO,SAAS,GAAI;AAC3D,QAAM,cAAU,2BAAY,OAAQ;AACpC,QAAM,gBAAY;AAAA,IACjB,OAAQ,EAAE,GAAG,SAAS,GAAG,MAAM;AAAA,IAC/B,CAAE,SAAS,KAAM;AAAA,EAClB;AAEA,SAAO,4CAAC,QAAQ,UAAR,EAAiB,OAAQ,WAAY,UAAsB;AACpE;AAEA,IAAO,wBAAQ;",
"names": []
}