UNPKG

@wordpress/widget-dashboard

Version:

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

25 lines (24 loc) • 1 kB
import { mergeWidgetActions } from "./merge-widget-actions.mjs"; // 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 = 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)) }; } export { splitWidgetActions }; //# sourceMappingURL=split-widget-actions.mjs.map