UNPKG

@wordpress/widget-dashboard

Version:

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

8 lines (7 loc) • 1.14 kB
{ "version": 3, "sources": ["../../../src/components/widget-actions/get-action-route.ts"], "sourcesContent": ["import type {\n\tWidgetAction,\n\tWidgetHostLinks,\n} from '@wordpress/widget-primitives';\n\n/**\n * Resolves the in-app route path of a link action. `download` (any value\n * but `false`) and `openInNewTab` keep the plain anchor: both mean a new\n * document.\n *\n * @param {WidgetHostLinks | undefined} links The host's `links` capability.\n * @param {WidgetAction} action The action whose target to resolve.\n * @return {string | null} The in-app route path, or `null`.\n */\nexport function getActionRoute(\n\tlinks: WidgetHostLinks | undefined,\n\taction: WidgetAction\n): string | null {\n\tconst isDownload =\n\t\taction.download !== undefined && action.download !== false;\n\n\tif ( ! links || isDownload || action.openInNewTab ) {\n\t\treturn null;\n\t}\n\n\treturn links.match( action.href );\n}\n"], "mappings": ";AAcO,SAAS,eACf,OACA,QACgB;AAChB,QAAM,aACL,OAAO,aAAa,UAAa,OAAO,aAAa;AAEtD,MAAK,CAAE,SAAS,cAAc,OAAO,cAAe;AACnD,WAAO;AAAA,EACR;AAEA,SAAO,MAAM,MAAO,OAAO,IAAK;AACjC;", "names": [] }