diff --git a/packages/dataviews/src/item-actions.js b/packages/dataviews/src/item-actions.tsx similarity index 71% rename from packages/dataviews/src/item-actions.js rename to packages/dataviews/src/item-actions.tsx index 60a120a2b5c60d..580ecaa6b2c534 100644 --- a/packages/dataviews/src/item-actions.js +++ b/packages/dataviews/src/item-actions.tsx @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import type { MouseEventHandler, ReactElement } from 'react'; + /** * WordPress dependencies */ @@ -15,6 +20,7 @@ import { moreVertical } from '@wordpress/icons'; * Internal dependencies */ import { unlock } from './lock-unlock'; +import type { Action, ActionModal as ActionModalType, Item } from './types'; const { DropdownMenuV2: DropdownMenu, @@ -24,7 +30,48 @@ const { kebabCase, } = unlock( componentsPrivateApis ); -function ButtonTrigger( { action, onClick } ) { +interface ButtonTriggerProps { + action: Action; + onClick: MouseEventHandler; +} + +interface DropdownMenuItemTriggerProps { + action: Action; + onClick: MouseEventHandler; +} + +interface ActionModalProps { + action: ActionModalType; + items: Item[]; + closeModal?: () => void; + onActionStart?: ( items: Item[] ) => void; + onActionPerformed?: ( items: Item[] ) => void; +} + +interface ActionWithModalProps extends ActionModalProps { + ActionTrigger: ( + props: ButtonTriggerProps | DropdownMenuItemTriggerProps + ) => ReactElement; + isBusy?: boolean; +} + +interface ActionsDropdownMenuGroupProps { + actions: Action[]; + item: Item; +} + +interface ItemActionsProps { + item: Item; + actions: Action[]; + isCompact: boolean; +} + +interface CompactItemActionsProps { + item: Item; + actions: Action[]; +} + +function ButtonTrigger( { action, onClick }: ButtonTriggerProps ) { return (