[react-native] update/add new accessibility properties (#36636)

* add new accessibilitystate and role values

* add accessibleState property

* Update ver to 0.60, use @depreacted in comments
This commit is contained in:
Andy Himberger 2019-07-05 00:48:06 -07:00 committed by Eloy Durán
parent 29ca96dcfe
commit 3c784e7f76
2 changed files with 59 additions and 5 deletions

View File

@ -1,4 +1,4 @@
// Type definitions for react-native 0.57
// Type definitions for react-native 0.60
// Project: https://github.com/facebook/react-native
// Definitions by: Eloy Durán <https://github.com/alloy>
// HuHuanming <https://github.com/huhuanming>
@ -2033,16 +2033,52 @@ export interface AccessibilityProps extends AccessibilityPropsAndroid, Accessibi
accessibilityRole?: AccessibilityRole;
/**
* Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on.
* @deprecated: accessibilityState available in 0.60+
*/
accessibilityStates?: AccessibilityState[];
accessibilityStates?: AccessibilityStates[];
/**
* Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on.
*/
accessibilityState?: AccessibilityState;
/**
* An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not obvious from the accessibility label.
*/
accessibilityHint?: string;
}
export type AccessibilityState = "selected" | "disabled";
// @deprecated: use AccessibilityState available in 0.60+
export type AccessibilityStates =
| "disabled"
| "selected"
| "checked"
| "unchecked"
| "busy"
| "expanded"
| "collapsed"
| "hasPopup";
export interface AccessibilityState {
/**
* When true, informs accessible tools if the element is disabled
*/
disabled?: boolean;
/**
* When true, informs accessible tools if the element is selected
*/
selected?: boolean;
/**
* For items like Checkboxes and Toggle switches, reports their state to accessible tools
*/
checked?: boolean | "mixed";
/**
* When present, informs accessible tools if the element is busy
*/
busy?: boolean;
/**
* When present, informs accessible tools the element is expanded or collapsed
*/
expanded?: boolean;
}
export type AccessibilityRole =
| "none"
@ -2053,9 +2089,26 @@ export type AccessibilityRole =
| "keyboardkey"
| "text"
| "adjustable"
| "imagebutton"
| "header"
| "summary"
| "imagebutton";
| "alert"
| "checkbox"
| "combobox"
| "menu"
| "menubar"
| "menuitem"
| "progressbar"
| "radio"
| "radiogroup"
| "scrollbar"
| "spinbutton"
| "switch"
| "tab"
| "tablist"
| "timer"
| "toolbar";
export interface AccessibilityPropsAndroid {
/**

View File

@ -778,6 +778,7 @@ class AccessibilityTest extends React.Component {
onAccessibilityTap={() => {}}
accessibilityRole="header"
accessibilityStates={["selected"]}
accessibilityState={{checked: true}}
accessibilityHint="Very importent header"
>
<Text accessibilityTraits={["key", "text"]} accessibilityIgnoresInvertColors>