UNPKG

@wordpress/widget-dashboard

Version:

Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.

30 lines (29 loc) • 1.18 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let __merge_widget_actions_ts = require("./merge-widget-actions.cjs"); // packages/widget-dashboard/src/utils/split-widget-actions.ts /** * Splits a widget's actions across the chrome surfaces: the footer takes * `relevance: 'high'` and `'medium'`, the More menu the rest. Full-bleed * widgets have no footer, so every action stays in the menu. * * @param {WidgetType | undefined} widgetType The widget type. * @param {WidgetRuntimeAction[]} runtimeActions The instance's actions. */ function splitWidgetActions(widgetType, runtimeActions = []) { const actions = (0, __merge_widget_actions_ts.mergeWidgetActions)(widgetType?.actions ?? [], runtimeActions); if (widgetType?.presentation === "full-bleed") return { footer: [], menu: actions }; const isPromoted = (action) => action.relevance === "high" || action.relevance === "medium"; return { footer: actions.filter(isPromoted), menu: actions.filter((action) => !isPromoted(action)) }; } exports.splitWidgetActions = splitWidgetActions; //# sourceMappingURL=split-widget-actions.cjs.map