mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7df3eea1a7
Summary: React Native components need a mechanism to specify their value to assistive technologies. This PR adds the notion of accessibilityValueDescription-- a property which either contains a textual description of a component's value, or for range-based components, such as sliders and progress bars, it contains range information (minimum, current, and maximum). On iOS, the range-based info if present is converted into a percentage and added to the accessibilityValue property of the UIView. If text is present as part of the accessibilityValueDescription, it is used instead of the range-based information. On Android, any range-based information in accessibilityValueDescription is exposed in the AccessibilityNodeInfo's RangeInfo. Text which is part of accessibilityValueDescription is appended to the content description. ## Changelog [GENERAL] [Change] - add accessibilityValuedescription property. Pull Request resolved: https://github.com/facebook/react-native/pull/26169 Test Plan: Added two new accessibility examples to RNTester, one which uses text and another which uses range-based info in accessibilityValueDescription. Verified that they both behave correctly on both Android and iOS. Differential Revision: D17444730 Pulled By: cpojer fbshipit-source-id: 1fb3252a90f88f7cafe1cbf7db08c03f14cc2321
87 lines
1.7 KiB
JavaScript
87 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow strict
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
|
|
|
|
// This must be kept in sync with the AccessibilityRolesMask in RCTViewManager.m
|
|
export type AccessibilityRole =
|
|
| 'none'
|
|
| 'button'
|
|
| 'link'
|
|
| 'search'
|
|
| 'image'
|
|
| 'keyboardkey'
|
|
| 'text'
|
|
| 'adjustable'
|
|
| 'imagebutton'
|
|
| 'header'
|
|
| 'summary'
|
|
| 'alert'
|
|
| 'checkbox'
|
|
| 'combobox'
|
|
| 'menu'
|
|
| 'menubar'
|
|
| 'menuitem'
|
|
| 'progressbar'
|
|
| 'radio'
|
|
| 'radiogroup'
|
|
| 'scrollbar'
|
|
| 'spinbutton'
|
|
| 'switch'
|
|
| 'tab'
|
|
| 'tablist'
|
|
| 'timer'
|
|
| 'toolbar';
|
|
|
|
// the info associated with an accessibility action
|
|
export type AccessibilityActionInfo = $ReadOnly<{
|
|
name: string,
|
|
label?: string,
|
|
}>;
|
|
|
|
// The info included in the event sent to onAccessibilityAction
|
|
export type AccessibilityActionEvent = SyntheticEvent<
|
|
$ReadOnly<{
|
|
actionName: string,
|
|
}>,
|
|
>;
|
|
|
|
export type AccessibilityState = {
|
|
disabled?: boolean,
|
|
selected?: boolean,
|
|
checked?: ?boolean | 'mixed',
|
|
busy?: boolean,
|
|
expanded?: boolean,
|
|
};
|
|
|
|
export type AccessibilityValue = $ReadOnly<{|
|
|
/**
|
|
* The minimum value of this component's range. (should be an integer)
|
|
*/
|
|
min?: number,
|
|
|
|
/**
|
|
* The maximum value of this component's range. (should be an integer)
|
|
*/
|
|
max?: number,
|
|
|
|
/**
|
|
* The current value of this component's range. (should be an integer)
|
|
*/
|
|
now?: number,
|
|
|
|
/**
|
|
* A textual description of this component's value. (will override minimum, current, and maximum if set)
|
|
*/
|
|
text?: string,
|
|
|}>;
|