{"version":3,"file":"actions-menu.mjs","names":[],"sources":["../../../src/components/actions-menu/actions-menu.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\t// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of IconButton.\n\tIconButton,\n\t// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135.\n\tMenu,\n\tTooltip,\n} from '@wordpress/ui';\n\nexport interface ActionsMenuItem {\n\tlabel: string;\n\tonClick: () => void;\n\tdisabled?: boolean;\n\t/**\n\t * Shown on hover when the item is disabled (for example, to explain\n\t * why the action is unavailable).\n\t */\n\tdisabledTooltip?: string;\n}\n\ninterface ActionsMenuProps {\n\titems: ActionsMenuItem[];\n}\n\nfunction ActionsMenuEntry( { item }: { item: ActionsMenuItem } ) {\n\tconst showDisabledTooltip = item.disabled && item.disabledTooltip;\n\n\tconst menuItem = (\n\t\t<Menu.Item disabled={ item.disabled } onClick={ item.onClick }>\n\t\t\t<Menu.ItemLabel>{ item.label }</Menu.ItemLabel>\n\t\t</Menu.Item>\n\t);\n\n\tif ( ! showDisabledTooltip ) {\n\t\treturn menuItem;\n\t}\n\n\treturn (\n\t\t<Tooltip.Root>\n\t\t\t<Menu.Item\n\t\t\t\tnativeButton\n\t\t\t\tdisabled={ item.disabled }\n\t\t\t\tonClick={ item.onClick }\n\t\t\t\trender={ <Tooltip.Trigger /> }\n\t\t\t>\n\t\t\t\t<Menu.ItemLabel>{ item.label }</Menu.ItemLabel>\n\t\t\t</Menu.Item>\n\t\t\t<Tooltip.Popup positioner={ <Tooltip.Positioner side=\"bottom\" /> }>\n\t\t\t\t{ item.disabledTooltip }\n\t\t\t</Tooltip.Popup>\n\t\t</Tooltip.Root>\n\t);\n}\n\n/**\n * Renders the dashboard's overflow menu: a three-dots trigger surfacing\n * secondary actions. Returns `null` when there are no items.\n *\n * @param {ActionsMenuProps} props Component props.\n */\nexport function ActionsMenu( { items }: ActionsMenuProps ): React.ReactNode {\n\tif ( items.length === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Menu.Root>\n\t\t\t<Menu.Trigger\n\t\t\t\trender={\n\t\t\t\t\t<IconButton\n\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Menu.Popup>\n\t\t\t\t<Tooltip.Provider delay={ 0 }>\n\t\t\t\t\t<Menu.Group>\n\t\t\t\t\t\t{ items.map( ( item, index ) => (\n\t\t\t\t\t\t\t<ActionsMenuEntry key={ index } item={ item } />\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Menu.Group>\n\t\t\t\t</Tooltip.Provider>\n\t\t\t</Menu.Popup>\n\t\t</Menu.Root>\n\t);\n}\n"],"mappings":";;;;;AAyBA,SAAS,iBAAkB,EAAE,QAAoC;CAChE,MAAM,sBAAsB,KAAK,YAAY,KAAK;CAElD,MAAM,WACL,oBAAC,KAAK,MAAN;EAAW,UAAW,KAAK;EAAW,SAAU,KAAK;EACpD,UAAA,oBAAC,KAAK,WAAN,EAAA,UAAkB,KAAK,MAAuB,CAAA;CACpC,CAAA;CAGZ,IAAK,CAAE,qBACN,OAAO;CAGR,OACC,qBAAC,QAAQ,MAAT,EAAA,UAAA,CACC,oBAAC,KAAK,MAAN;EACC,cAAA;EACA,UAAW,KAAK;EAChB,SAAU,KAAK;EACf,QAAS,oBAAC,QAAQ,SAAT,CAAkB,CAAA;EAE3B,UAAA,oBAAC,KAAK,WAAN,EAAA,UAAkB,KAAK,MAAuB,CAAA;CACpC,CAAA,GACX,oBAAC,QAAQ,OAAT;EAAe,YAAa,oBAAC,QAAQ,YAAT,EAAoB,MAAK,SAAU,CAAA;EAC5D,UAAA,KAAK;CAC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