@wordpress/widget-dashboard
Version:
Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.
31 lines (30 loc) • 1.01 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_element = require("@wordpress/element");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/widget-dashboard/src/context/widget-context.tsx
const WidgetContext = (0, _wordpress_element.createContext)(null);
/**
* Provides the current widget's identity to its render subtree.
*
* @param {ProviderProps} props Component props.
*/
function WidgetContextProvider({ value, children }) {
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WidgetContext.Provider, {
value,
children
});
}
/**
* Returns the current widget's identity (`uuid`, `name`, `index`). Returns
* `null` when called outside a widget render subtree.
*/
function useWidgetContext() {
return (0, _wordpress_element.useContext)(WidgetContext);
}
exports.WidgetContextProvider = WidgetContextProvider;
exports.useWidgetContext = useWidgetContext;
//# sourceMappingURL=widget-context.cjs.map