From 88bfc6580357ad6337fc987e3db2cb699e0809c7 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Tue, 20 Sep 2022 10:57:58 -0700 Subject: [PATCH] Update Accessibility types for aria props Summary: Changelog: [Internal] - Update the base accessibility props to include the added aria props. See https://github.com/facebook/react-native/compare/0.70-stable...main for changes. Reviewed By: cipolleschi Differential Revision: D39633224 fbshipit-source-id: 6c08ab8540b8b6e2b57f066a35754376c5ae3d68 --- types/__typetests__/index.tsx | 41 +++++++++++++++++++++----------- types/index.d.ts | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/types/__typetests__/index.tsx b/types/__typetests__/index.tsx index f7e8c159e52..66b7cbf9116 100644 --- a/types/__typetests__/index.tsx +++ b/types/__typetests__/index.tsx @@ -112,6 +112,7 @@ import { TextStyle, TimePickerAndroid, TouchableNativeFeedback, + TouchableOpacity, UIManager, View, ViewPagerAndroid, @@ -1404,19 +1405,33 @@ const listViewDataSourceTest = new ListView.DataSource({ class AccessibilityTest extends React.Component { render() { return ( - {}} - accessibilityRole="header" - accessibilityState={{checked: true}} - accessibilityHint="Very important header" - accessibilityValue={{min: 60, max: 120, now: 80}} - onMagicTap={() => {}} - onAccessibilityEscape={() => {}}> - Text - - + <> + {}} + accessibilityRole="header" + accessibilityState={{checked: true}} + accessibilityHint="Very important header" + accessibilityValue={{min: 60, max: 120, now: 80}} + aria-label="Aria Label" + onMagicTap={() => {}} + onAccessibilityEscape={() => {}}> + Text + + + + + + ); } } diff --git a/types/index.d.ts b/types/index.d.ts index 760f537fd95..19ed72abd28 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2508,6 +2508,12 @@ export interface AccessibilityProps */ accessibilityLabel?: string | undefined; + /** + * Alias for accessibilityLabel https://reactnative.dev/docs/view#accessibilitylabel + * https://github.com/facebook/react-native/issues/34424 + */ + 'aria-label'?: string | undefined; + /** * Accessibility Role tells a person using either VoiceOver on iOS or TalkBack on Android the type of element that is focused on. */ @@ -2516,6 +2522,18 @@ export interface AccessibilityProps * Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on. */ accessibilityState?: AccessibilityState | undefined; + + /** + * alias for accessibilityState + * + * see https://reactnative.dev/docs/accessibility#accessibilitystate + */ + 'aria-busy'?: boolean | undefined; + 'aria-checked'?: boolean | undefined; + 'aria-disabled'?: boolean | undefined; + 'aria-expanded'?: boolean | undefined; + 'aria-selected'?: boolean | undefined; + /** * 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. */ @@ -2526,12 +2544,32 @@ export interface AccessibilityProps */ accessibilityValue?: AccessibilityValue | undefined; + 'aria-valuemax'?: AccessibilityValue['max']; + 'aria-valuemin'?: AccessibilityValue['min']; + 'aria-valuenow'?: AccessibilityValue['now']; + 'aria-valuetext'?: AccessibilityValue['text']; /** * When `accessible` is true, the system will try to invoke this function when the user performs an accessibility custom action. */ onAccessibilityAction?: | ((event: AccessibilityActionEvent) => void) | undefined; + + /** + * [Android] Controlling if a view fires accessibility events and if it is reported to accessibility services. + */ + importantForAccessibility?: + | ('auto' | 'yes' | 'no' | 'no-hide-descendants') + | undefined; + + /** + * A value indicating whether the accessibility elements contained within + * this accessibility element are hidden. + */ + 'aria-hidden'?: boolean | undefined; + + 'aria-live'?: ('polite' | 'assertive' | 'off') | undefined; + 'aria-modal'?: boolean | undefined; } export type AccessibilityActionInfo = Readonly<{ @@ -7712,6 +7750,8 @@ type AccessibilityAnnouncementFinishedEventHandler = ( event: AccessibilityAnnouncementFinishedEvent, ) => void; +type AccessibilityEventTypes = 'click' | 'focus'; + /** * @see https://reactnative.dev/docs/accessibilityinfo */ @@ -7791,6 +7831,10 @@ export interface AccessibilityInfoStatic { * @platform android */ getRecommendedTimeoutMillis: (originalTimeout: number) => Promise; + sendAccessibilityEvent: ( + handle: React.ElementRef>, + eventType: AccessibilityEventTypes, + ) => void; } /**