-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MenuItem
: Refactor to TypeScript (#53132)
* - Add new type props, combine with WordPressComponentProps - Convert menu-item.js to tsx - Update JSDoc * * Update ChangeLog
- Loading branch information
Showing
5 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { ReactNode } from 'react'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { ButtonAsButtonProps } from '../button/types'; | ||
|
||
export type MenuItemProps = ButtonAsButtonProps & { | ||
/** | ||
* A CSS `class` to give to the container element. | ||
*/ | ||
className?: string; | ||
/** | ||
* The children elements. | ||
*/ | ||
children?: ReactNode; | ||
/** | ||
* Text to use as description for button text. | ||
*/ | ||
info?: string; | ||
/** | ||
* The icon to render. Supported values are: Dashicons (specified as | ||
* strings), functions, Component instances and `null`. | ||
* | ||
* @default null | ||
*/ | ||
icon?: JSX.Element | null; | ||
/** | ||
* Determines where to display the provided `icon`. | ||
*/ | ||
iconPosition?: ButtonAsButtonProps[ 'iconPosition' ]; | ||
/** | ||
* Whether or not the menu item is currently selected. | ||
*/ | ||
isSelected?: boolean; | ||
/** | ||
* If shortcut is a string, it is expecting the display text. If shortcut is an object, | ||
* it will accept the properties of `display` (string) and `ariaLabel` (string). | ||
*/ | ||
shortcut?: string | { display: string; ariaLabel: string }; | ||
/** | ||
* If you need to have selectable menu items use menuitemradio for single select, | ||
* and menuitemcheckbox for multiselect. | ||
* | ||
* @default 'menuitem' | ||
*/ | ||
role?: string; | ||
/** | ||
* Allows for markup other than icons or shortcuts to be added to the menu item. | ||
* | ||
*/ | ||
suffix?: ReactNode; | ||
/** | ||
* Human-readable label for item. | ||
*/ | ||
label?: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters