@wordpress/widget-dashboard
Version:
Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.
31 lines (30 loc) • 1.17 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_compose = require("@wordpress/compose");
// packages/widget-dashboard/src/utils/runtime-actions-map.ts
function createRuntimeActionsMap() {
return (0, _wordpress_compose.observableMap)();
}
/**
* Replaces what one render of an instance declares; an empty list clears it.
*
* @param {RuntimeActionsMap} map The dashboard's map.
* @param {string} uuid The instance.
* @param {string} renderId The render declaring.
* @param {WidgetRuntimeAction[]} actions The actions it declares.
*/
function declareRuntimeActions(map, uuid, renderId, actions) {
const declared = map.get(uuid);
if (actions.length === 0 && !declared?.has(renderId)) return;
const next = new Map(declared);
if (actions.length > 0) next.set(renderId, actions);
else next.delete(renderId);
if (next.size > 0) map.set(uuid, next);
else map.delete(uuid);
}
exports.createRuntimeActionsMap = createRuntimeActionsMap;
exports.declareRuntimeActions = declareRuntimeActions;
//# sourceMappingURL=runtime-actions-map.cjs.map