@gechiui/block-editor
Version:
52 lines (44 loc) • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BlockContextProvider = BlockContextProvider;
exports.default = void 0;
var _element = require("@gechiui/element");
/**
* GeChiUI dependencies
*/
/** @typedef {import('react').ReactNode} ReactNode */
/**
* @typedef BlockContextProviderProps
*
* @property {Record<string,*>} value Context value to merge with current
* value.
* @property {ReactNode} children Component children.
*/
/** @type {import('react').Context<Record<string,*>>} */
const Context = (0, _element.createContext)({});
/**
* Component which merges passed value with current consumed block context.
*
* @see https://github.com/GeChiUI/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md
*
* @param {BlockContextProviderProps} props
*/
function BlockContextProvider(_ref) {
let {
value,
children
} = _ref;
const context = (0, _element.useContext)(Context);
const nextValue = (0, _element.useMemo)(() => ({ ...context,
...value
}), [context, value]);
return (0, _element.createElement)(Context.Provider, {
value: nextValue,
children: children
});
}
var _default = Context;
exports.default = _default;
//# sourceMappingURL=index.js.map