first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,241 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format strict-local
*/
import type {AnyAttributeType} from '../../Renderer/shims/ReactNativeTypes';
import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
import processAspectRatio from '../../StyleSheet/processAspectRatio';
import processBackgroundImage from '../../StyleSheet/processBackgroundImage';
import processBackgroundPosition from '../../StyleSheet/processBackgroundPosition';
import processBackgroundRepeat from '../../StyleSheet/processBackgroundRepeat';
import processBackgroundSize from '../../StyleSheet/processBackgroundSize';
import processBoxShadow from '../../StyleSheet/processBoxShadow';
import processColor from '../../StyleSheet/processColor';
import processFilter from '../../StyleSheet/processFilter';
import processFontVariant from '../../StyleSheet/processFontVariant';
import processTransform from '../../StyleSheet/processTransform';
import processTransformOrigin from '../../StyleSheet/processTransformOrigin';
import sizesDiffer from '../../Utilities/differ/sizesDiffer';
const colorAttributes = {process: processColor};
const ReactNativeStyleAttributes: {[string]: AnyAttributeType, ...} = {
/**
* Layout
*/
alignContent: true,
alignItems: true,
alignSelf: true,
aspectRatio: {process: processAspectRatio},
borderBottomWidth: true,
borderEndWidth: true,
borderLeftWidth: true,
borderRightWidth: true,
borderStartWidth: true,
borderTopWidth: true,
boxSizing: true,
columnGap: true,
borderWidth: true,
bottom: true,
direction: true,
display: true,
end: true,
flex: true,
flexBasis: true,
flexDirection: true,
flexGrow: true,
flexShrink: true,
flexWrap: true,
gap: true,
height: true,
inset: true,
insetBlock: true,
insetBlockEnd: true,
insetBlockStart: true,
insetInline: true,
insetInlineEnd: true,
insetInlineStart: true,
justifyContent: true,
left: true,
margin: true,
marginBlock: true,
marginBlockEnd: true,
marginBlockStart: true,
marginBottom: true,
marginEnd: true,
marginHorizontal: true,
marginInline: true,
marginInlineEnd: true,
marginInlineStart: true,
marginLeft: true,
marginRight: true,
marginStart: true,
marginTop: true,
marginVertical: true,
maxHeight: true,
maxWidth: true,
minHeight: true,
minWidth: true,
overflow: true,
padding: true,
paddingBlock: true,
paddingBlockEnd: true,
paddingBlockStart: true,
paddingBottom: true,
paddingEnd: true,
paddingHorizontal: true,
paddingInline: true,
paddingInlineEnd: true,
paddingInlineStart: true,
paddingLeft: true,
paddingRight: true,
paddingStart: true,
paddingTop: true,
paddingVertical: true,
position: true,
right: true,
rowGap: true,
start: true,
top: true,
width: true,
zIndex: true,
/**
* Shadow
*/
elevation: true,
shadowColor: colorAttributes,
shadowOffset: {diff: sizesDiffer},
shadowOpacity: true,
shadowRadius: true,
/**
* Transform
*/
transform: {process: processTransform},
transformOrigin: {process: processTransformOrigin},
/**
* Filter
*/
filter: ReactNativeFeatureFlags.enableNativeCSSParsing()
? true
: {process: processFilter},
/**
* MixBlendMode
*/
mixBlendMode: true,
/**
* Isolation
*/
isolation: true,
/*
* BoxShadow
*/
boxShadow: ReactNativeFeatureFlags.enableNativeCSSParsing()
? true
: {process: processBoxShadow},
/**
* BackgroundImage
*/
experimental_backgroundImage: {process: processBackgroundImage},
/**
* BackgroundSize
*/
experimental_backgroundSize: {process: processBackgroundSize},
/**
* BackgroundPosition
*/
experimental_backgroundPosition: {process: processBackgroundPosition},
/**
* BackgroundRepeat
*/
experimental_backgroundRepeat: {process: processBackgroundRepeat},
/**
* View
*/
backfaceVisibility: true,
backgroundColor: colorAttributes,
borderBlockColor: colorAttributes,
borderBlockEndColor: colorAttributes,
borderBlockStartColor: colorAttributes,
borderBottomColor: colorAttributes,
borderBottomEndRadius: true,
borderBottomLeftRadius: true,
borderBottomRightRadius: true,
borderBottomStartRadius: true,
borderColor: colorAttributes,
borderCurve: true,
borderEndColor: colorAttributes,
borderEndEndRadius: true,
borderEndStartRadius: true,
borderLeftColor: colorAttributes,
borderRadius: true,
borderRightColor: colorAttributes,
borderStartColor: colorAttributes,
borderStartEndRadius: true,
borderStartStartRadius: true,
borderStyle: true,
borderTopColor: colorAttributes,
borderTopEndRadius: true,
borderTopLeftRadius: true,
borderTopRightRadius: true,
borderTopStartRadius: true,
cursor: true,
opacity: true,
outlineColor: colorAttributes,
outlineOffset: true,
outlineStyle: true,
outlineWidth: true,
pointerEvents: true,
/**
* Text
*/
color: colorAttributes,
fontFamily: true,
fontSize: true,
fontStyle: true,
fontVariant: {process: processFontVariant},
fontWeight: true,
includeFontPadding: true,
letterSpacing: true,
lineHeight: true,
textAlign: true,
textAlignVertical: true,
textDecorationColor: colorAttributes,
textDecorationLine: true,
textDecorationStyle: true,
textShadowColor: colorAttributes,
textShadowOffset: true,
textShadowRadius: true,
textTransform: true,
userSelect: true,
verticalAlign: true,
writingDirection: true,
/**
* Image
*/
overlayColor: colorAttributes,
resizeMode: true,
tintColor: colorAttributes,
objectFit: true,
};
export default ReactNativeStyleAttributes;

View File

@@ -0,0 +1,60 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
'use strict';
import ReactNativeStyleAttributes from './ReactNativeStyleAttributes';
const UIView = {
pointerEvents: true,
accessible: true,
accessibilityActions: true,
accessibilityLabel: true,
accessibilityLiveRegion: true,
accessibilityRole: true,
accessibilityState: true,
accessibilityValue: true,
accessibilityHint: true,
accessibilityLanguage: true,
accessibilityShowsLargeContentViewer: true,
accessibilityLargeContentTitle: true,
importantForAccessibility: true,
nativeID: true,
testID: true,
renderToHardwareTextureAndroid: true,
shouldRasterizeIOS: true,
onLayout: true,
onAccessibilityAction: true,
onAccessibilityTap: true,
onMagicTap: true,
onAccessibilityEscape: true,
collapsable: true,
collapsableChildren: true,
needsOffscreenAlphaCompositing: true,
style: ReactNativeStyleAttributes,
role: true,
};
const RCTView = {
...UIView,
// This is a special performance property exposed by RCTView and useful for
// scrolling content when there are many subviews, most of which are offscreen.
// For this property to be effective, it must be applied to a view that contains
// many subviews that extend outside its bound. The subviews must also have
// overflow: hidden, as should the containing view (or one of its superviews).
removeClippedSubviews: true,
};
const ReactNativeViewAttributes = {
UIView: UIView,
RCTView: RCTView,
};
export default ReactNativeViewAttributes;

View File

@@ -0,0 +1,29 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import type * as React from 'react';
import {Constructor} from '../../../types/private/Utilities';
import {ViewProps} from './ViewPropTypes';
import {HostInstance} from '../../../types/public/ReactNativeTypes';
/**
* The most fundamental component for building UI, View is a container that supports layout with flexbox, style, some touch handling,
* and accessibility controls, and is designed to be nested inside other views and to have 0 to many children of any type.
* View maps directly to the native view equivalent on whatever platform React is running on,
* whether that is a UIView, <div>, android.view, etc.
*/
declare class ViewComponent extends React.Component<ViewProps> {}
declare const ViewBase: Constructor<HostInstance> & typeof ViewComponent;
export class View extends ViewBase {
/**
* Is 3D Touch / Force Touch available (i.e. will touch events include `force`)
* @platform ios
*/
static forceTouchAvailable: boolean;
}

View File

@@ -0,0 +1,133 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {ViewProps} from './ViewPropTypes';
import TextAncestorContext from '../../Text/TextAncestorContext';
import ViewNativeComponent from './ViewNativeComponent';
import * as React from 'react';
import {use} from 'react';
/**
* The most fundamental component for building a UI, View is a container that
* supports layout with flexbox, style, some touch handling, and accessibility
* controls.
*
* @see https://reactnative.dev/docs/view
*/
component View(
ref?: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
...props: ViewProps
) {
const hasTextAncestor = use(TextAncestorContext);
const {
accessibilityState,
accessibilityValue,
'aria-busy': ariaBusy,
'aria-checked': ariaChecked,
'aria-disabled': ariaDisabled,
'aria-expanded': ariaExpanded,
'aria-hidden': ariaHidden,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
'aria-live': ariaLive,
'aria-selected': ariaSelected,
'aria-valuemax': ariaValueMax,
'aria-valuemin': ariaValueMin,
'aria-valuenow': ariaValueNow,
'aria-valuetext': ariaValueText,
id,
tabIndex,
...otherProps
} = props;
// Since we destructured props, we can now treat it as mutable
const processedProps = otherProps as {...ViewProps};
const parsedAriaLabelledBy = ariaLabelledBy?.split(/\s*,\s*/g);
if (parsedAriaLabelledBy !== undefined) {
processedProps.accessibilityLabelledBy = parsedAriaLabelledBy;
}
if (ariaLabel !== undefined) {
processedProps.accessibilityLabel = ariaLabel;
}
if (ariaLive !== undefined) {
processedProps.accessibilityLiveRegion =
ariaLive === 'off' ? 'none' : ariaLive;
}
if (ariaHidden !== undefined) {
processedProps.accessibilityElementsHidden = ariaHidden;
if (ariaHidden === true) {
processedProps.importantForAccessibility = 'no-hide-descendants';
}
}
if (id !== undefined) {
processedProps.nativeID = id;
}
if (tabIndex !== undefined) {
processedProps.focusable = !tabIndex;
}
if (
accessibilityState != null ||
ariaBusy != null ||
ariaChecked != null ||
ariaDisabled != null ||
ariaExpanded != null ||
ariaSelected != null
) {
processedProps.accessibilityState = {
busy: ariaBusy ?? accessibilityState?.busy,
checked: ariaChecked ?? accessibilityState?.checked,
disabled: ariaDisabled ?? accessibilityState?.disabled,
expanded: ariaExpanded ?? accessibilityState?.expanded,
selected: ariaSelected ?? accessibilityState?.selected,
};
}
if (
accessibilityValue != null ||
ariaValueMax != null ||
ariaValueMin != null ||
ariaValueNow != null ||
ariaValueText != null
) {
processedProps.accessibilityValue = {
max: ariaValueMax ?? accessibilityValue?.max,
min: ariaValueMin ?? accessibilityValue?.min,
now: ariaValueNow ?? accessibilityValue?.now,
text: ariaValueText ?? accessibilityValue?.text,
};
}
const actualView =
ref == null ? (
<ViewNativeComponent {...processedProps} />
) : (
<ViewNativeComponent {...processedProps} ref={ref} />
);
if (hasTextAncestor) {
return (
<TextAncestorContext value={false}>{actualView}</TextAncestorContext>
);
}
return actualView;
}
View.displayName = 'View';
export default View;

View File

@@ -0,0 +1,419 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {NativeSyntheticEvent} from '../../Types/CoreEventTypes';
/**
* @see https://reactnative.dev/docs/accessibility#accessibility-properties
*/
export interface AccessibilityProps
extends AccessibilityPropsAndroid,
AccessibilityPropsIOS {
/**
* When true, indicates that the view is an accessibility element.
* By default, all the touchable elements are accessible.
*/
accessible?: boolean | undefined;
/**
* Provides an array of custom actions available for accessibility.
*/
accessibilityActions?: ReadonlyArray<AccessibilityActionInfo> | undefined;
/**
* Overrides the text that's read by the screen reader when the user interacts with the element. By default, the
* label is constructed by traversing all the children and accumulating all the Text nodes separated by space.
*/
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.
*/
accessibilityRole?: AccessibilityRole | undefined;
/**
* 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 | 'mixed' | 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.
*/
accessibilityHint?: string | undefined;
/**
* Represents the current value of a component. It can be 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).
*/
accessibilityValue?: AccessibilityValue | undefined;
'aria-valuemax'?: AccessibilityValue['max'] | undefined;
'aria-valuemin'?: AccessibilityValue['min'] | undefined;
'aria-valuenow'?: AccessibilityValue['now'] | undefined;
'aria-valuetext'?: AccessibilityValue['text'] | undefined;
/**
* 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-modal'?: boolean | undefined;
/**
* Indicates to accessibility services to treat UI component like a specific role.
*/
role?: Role | undefined;
}
export type AccessibilityActionInfo = Readonly<{
name: AccessibilityActionName | string;
label?: string | undefined;
}>;
export type AccessibilityActionName =
/**
* Generated when a screen reader user double taps the component.
*/
| 'activate'
/**
* Generated when a screen reader user increments an adjustable component.
*/
| 'increment'
/**
* Generated when a screen reader user decrements an adjustable component.
*/
| 'decrement'
/**
* Generated when a TalkBack user places accessibility focus on the component and double taps and holds one finger on the screen.
* @platform android
*/
| 'longpress'
/**
* Generated when a VoiceOver user places focus on or inside the component and double taps with two fingers.
* @platform ios
* */
| 'magicTap'
/**
* Generated when a VoiceOver user places focus on or inside the component and performs a two finger scrub gesture (left, right, left).
* @platform ios
* */
| 'escape';
export type AccessibilityActionEvent = NativeSyntheticEvent<
Readonly<{
actionName: string;
}>
>;
export interface AccessibilityState {
/**
* When true, informs accessible tools if the element is disabled
*/
disabled?: boolean | undefined;
/**
* When true, informs accessible tools if the element is selected
*/
selected?: boolean | undefined;
/**
* For items like Checkboxes and Toggle switches, reports their state to accessible tools
*/
checked?: boolean | 'mixed' | undefined;
/**
* When present, informs accessible tools if the element is busy
*/
busy?: boolean | undefined;
/**
* When present, informs accessible tools the element is expanded or collapsed
*/
expanded?: boolean | undefined;
}
export interface AccessibilityValue {
/**
* The minimum value of this component's range. (should be an integer)
*/
min?: number | undefined;
/**
* The maximum value of this component's range. (should be an integer)
*/
max?: number | undefined;
/**
* The current value of this component's range. (should be an integer)
*/
now?: number | undefined;
/**
* A textual description of this component's value. (will override minimum, current, and maximum if set)
*/
text?: string | undefined;
}
export type AccessibilityRole =
| 'none'
| 'button'
| 'togglebutton'
| 'link'
| 'search'
| 'image'
| 'keyboardkey'
| 'text'
| 'adjustable'
| 'imagebutton'
| 'header'
| 'summary'
| 'alert'
| 'checkbox'
| 'combobox'
| 'menu'
| 'menubar'
| 'menuitem'
| 'progressbar'
| 'radio'
| 'radiogroup'
| 'scrollbar'
| 'spinbutton'
| 'switch'
| 'tab'
| 'tabbar'
| 'tablist'
| 'timer'
| 'list'
| 'toolbar';
export interface AccessibilityPropsAndroid {
/**
* Identifies the element that labels the element it is applied to. When the assistive technology focuses on the component with this props,
* the text is read aloud. The value should should match the nativeID of the related element.
*
* @platform android
*/
accessibilityLabelledBy?: string | string[] | undefined;
/**
* Identifies the element that labels the element it is applied to. When the assistive technology focuses on the component with this props,
* the text is read aloud. The value should should match the nativeID of the related element.
*
* @platform android
*/
'aria-labelledby'?: string | undefined;
/**
* Indicates to accessibility services whether the user should be notified
* when this view changes. Works for Android API >= 19 only.
*
* @platform android
*
* See https://reactnative.dev/docs/view#accessibilityliveregion
*/
accessibilityLiveRegion?: 'none' | 'polite' | 'assertive' | undefined;
/**
* Indicates to accessibility services whether the user should be notified
* when this view changes. Works for Android API >= 19 only.
*
* @platform android
*
* See https://reactnative.dev/docs/view#accessibilityliveregion
*/
'aria-live'?: ('polite' | 'assertive' | 'off') | undefined;
/**
* Controls how view is important for accessibility which is if it fires accessibility events
* and if it is reported to accessibility services that query the screen.
* Works for Android only. See http://developer.android.com/reference/android/R.attr.html#importantForAccessibility for references.
*
* Possible values:
* 'auto' - The system determines whether the view is important for accessibility - default (recommended).
* 'yes' - The view is important for accessibility.
* 'no' - The view is not important for accessibility.
* 'no-hide-descendants' - The view is not important for accessibility, nor are any of its descendant views.
*
* @platform android
*/
importantForAccessibility?:
| 'auto'
| 'yes'
| 'no'
| 'no-hide-descendants'
| undefined;
/**
* Enables the view to be screen reader focusable, not keyboard focusable.
*
* @platform android
*/
screenReaderFocusable?: boolean | undefined;
}
export interface AccessibilityPropsIOS {
/**
* A Boolean value indicating whether the accessibility elements contained within this accessibility element
* are hidden to the screen reader.
* @platform ios
*/
accessibilityElementsHidden?: boolean | undefined;
/**
* A Boolean value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver.
* @platform ios
*/
accessibilityViewIsModal?: boolean | undefined;
/**
* When accessible is true, the system will invoke this function when the user performs the escape gesture (scrub with two fingers).
* @platform ios
*/
onAccessibilityEscape?: (() => void) | undefined;
/**
* When `accessible` is true, the system will try to invoke this function when the user performs accessibility tap gesture.
* @platform ios
*/
onAccessibilityTap?: (() => void) | undefined;
/**
* When accessible is true, the system will invoke this function when the user performs the magic tap gesture.
* @platform ios
*/
onMagicTap?: (() => void) | undefined;
/**
* https://reactnative.dev/docs/accessibility#accessibilityignoresinvertcolorsios
* @platform ios
*/
accessibilityIgnoresInvertColors?: boolean | undefined;
/**
* By using the accessibilityLanguage property, the screen reader will understand which language to use while reading the element's label, value and hint. The provided string value must follow the BCP 47 specification (https://www.rfc-editor.org/info/bcp47).
* https://reactnative.dev/docs/accessibility#accessibilitylanguage-ios
* @platform ios
*/
accessibilityLanguage?: string | undefined;
/**
* A Boolean value that indicates whether or not to show the item in the large content viewer.
* Available on iOS 13.0+
* https://reactnative.dev/docs/accessibility#accessibilityshowslargecontentviewer
* @platform ios
*/
accessibilityShowsLargeContentViewer?: boolean | undefined;
/**
* When `accessibilityShowsLargeContentViewer` is set, this string will be used as title for the large content viewer.
* https://reactnative.dev/docs/accessibility#accessibilitylargecontenttitle
* @platform ios
*/
accessibilityLargeContentTitle?: string | undefined;
/**
* Blocks the user from interacting with the component through keyboard while still allowing
* screen reader to interact with it if this View is still accessible.
*
* @platform ios
*/
accessibilityRespondsToUserInteraction?: boolean | undefined;
}
export type Role =
| 'alert'
| 'alertdialog'
| 'application'
| 'article'
| 'banner'
| 'button'
| 'cell'
| 'checkbox'
| 'columnheader'
| 'combobox'
| 'complementary'
| 'contentinfo'
| 'definition'
| 'dialog'
| 'directory'
| 'document'
| 'feed'
| 'figure'
| 'form'
| 'grid'
| 'group'
| 'heading'
| 'img'
| 'link'
| 'list'
| 'listitem'
| 'log'
| 'main'
| 'marquee'
| 'math'
| 'menu'
| 'menubar'
| 'menuitem'
| 'meter'
| 'navigation'
| 'none'
| 'note'
| 'option'
| 'presentation'
| 'progressbar'
| 'radio'
| 'radiogroup'
| 'region'
| 'row'
| 'rowgroup'
| 'rowheader'
| 'scrollbar'
| 'searchbox'
| 'separator'
| 'slider'
| 'spinbutton'
| 'status'
| 'summary'
| 'switch'
| 'tab'
| 'table'
| 'tablist'
| 'tabpanel'
| 'term'
| 'timer'
| 'toolbar'
| 'tooltip'
| 'tree'
| 'treegrid'
| 'treeitem';

View File

@@ -0,0 +1,424 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
'use strict';
import type {NativeSyntheticEvent} from '../../Types/CoreEventTypes';
// This must be kept in sync with the AccessibilityRolesMask in RCTViewManager.m
export type AccessibilityRole =
| 'none'
| 'button'
| 'dropdownlist'
| 'togglebutton'
| 'link'
| 'search'
| 'image'
| 'keyboardkey'
| 'text'
| 'adjustable'
| 'imagebutton'
| 'header'
| 'summary'
| 'alert'
| 'checkbox'
| 'combobox'
| 'menu'
| 'menubar'
| 'menuitem'
| 'progressbar'
| 'radio'
| 'radiogroup'
| 'scrollbar'
| 'spinbutton'
| 'switch'
| 'tab'
| 'tabbar'
| 'tablist'
| 'timer'
| 'list'
| 'toolbar'
| 'grid'
| 'pager'
| 'scrollview'
| 'horizontalscrollview'
| 'viewgroup'
| 'webview'
| 'drawerlayout'
| 'slidingdrawer'
| 'iconmenu'
| string;
// Role types for web
export type Role =
| 'alert'
| 'alertdialog'
| 'application'
| 'article'
| 'banner'
| 'button'
| 'cell'
| 'checkbox'
| 'columnheader'
| 'combobox'
| 'complementary'
| 'contentinfo'
| 'definition'
| 'dialog'
| 'directory'
| 'document'
| 'feed'
| 'figure'
| 'form'
| 'grid'
| 'group'
| 'heading'
| 'img'
| 'link'
| 'list'
| 'listitem'
| 'log'
| 'main'
| 'marquee'
| 'math'
| 'menu'
| 'menubar'
| 'menuitem'
| 'meter'
| 'navigation'
| 'none'
| 'note'
| 'option'
| 'presentation'
| 'progressbar'
| 'radio'
| 'radiogroup'
| 'region'
| 'row'
| 'rowgroup'
| 'rowheader'
| 'scrollbar'
| 'searchbox'
| 'separator'
| 'slider'
| 'spinbutton'
| 'status'
| 'summary'
| 'switch'
| 'tab'
| 'table'
| 'tablist'
| 'tabpanel'
| 'term'
| 'timer'
| 'toolbar'
| 'tooltip'
| 'tree'
| 'treegrid'
| 'treeitem';
export type AccessibilityActionName =
/**
* Generated when a screen reader user double taps the component.
*/
| 'activate'
/**
* Generated when a screen reader user increments an adjustable component.
*/
| 'increment'
/**
* Generated when a screen reader user decrements an adjustable component.
*/
| 'decrement'
/**
* Generated when a TalkBack user places accessibility focus on the component and double taps and holds one finger on the screen.
* @platform android
*/
| 'longpress'
/**
* Generated when a VoiceOver user places focus on or inside the component and double taps with two fingers.
* @platform ios
* */
| 'magicTap'
/**
* Generated when a VoiceOver user places focus on or inside the component and performs a two finger scrub gesture (left, right, left).
* @platform ios
* */
| 'escape';
// the info associated with an accessibility action
export type AccessibilityActionInfo = $ReadOnly<{
name: AccessibilityActionName | string,
label?: string,
...
}>;
// The info included in the event sent to onAccessibilityAction
export type AccessibilityActionEvent = NativeSyntheticEvent<
$ReadOnly<{actionName: string, ...}>,
>;
export type 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 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?: Stringish,
}>;
export type AccessibilityPropsAndroid = $ReadOnly<{
/**
* Identifies the element that labels the element it is applied to. When the assistive technology focuses on the component with this props,
* the text is read aloud. The value should should match the nativeID of the related element.
*
* @platform android
*/
accessibilityLabelledBy?: ?string | ?Array<string>,
/**
* Identifies the element that labels the element it is applied to. When the assistive technology focuses on the component with this props,
* the text is read aloud. The value should should match the nativeID of the related element.
*
* @platform android
*/
'aria-labelledby'?: ?string,
/**
* Indicates to accessibility services whether the user should be notified
* when this view changes. Works for Android API >= 19 only.
*
* @platform android
*
* See https://reactnative.dev/docs/view#accessibilityliveregion
*/
accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'),
/**
* Indicates to accessibility services whether the user should be notified
* when this view changes. Works for Android API >= 19 only.
*
* @platform android
*
* See https://reactnative.dev/docs/view#accessibilityliveregion
*/
'aria-live'?: ?('polite' | 'assertive' | 'off'),
/**
* Controls how view is important for accessibility which is if it
* fires accessibility events and if it is reported to accessibility services
* that query the screen. Works for Android only.
*
* @platform android
*
* See https://reactnative.dev/docs/view#importantforaccessibility
*/
importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'),
/**
* Enables the view to be screen reader focusable, not keyboard focusable. This has lower priority
* than focusable or accessible props.
*
* @platform android
*/
screenReaderFocusable?: boolean,
}>;
export type AccessibilityPropsIOS = $ReadOnly<{
/**
* Prevents view from being inverted if set to true and color inversion is turned on.
*
* @platform ios
*/
accessibilityIgnoresInvertColors?: ?boolean,
/**
* A value indicating whether VoiceOver should ignore the elements
* within views that are siblings of the receiver.
* Default is `false`.
*
* @platform ios
*
* See https://reactnative.dev/docs/view#accessibilityviewismodal
*/
accessibilityViewIsModal?: ?boolean,
/**
* @platform ios
*
* See https://reactnative.dev/docs/view#accessibilityshowslargecontentviewer
*/
accessibilityShowsLargeContentViewer?: ?boolean,
/**
* @platform ios
*
* See https://reactnative.dev/docs/view#accessibilitylargecontenttitle
*/
accessibilityLargeContentTitle?: ?string,
/**
* The aria-modal attribute indicates content contained within a modal with aria-modal="true"
* should be accessible to the user.
* Default is `false`.
*
* @platform ios
*/
'aria-modal'?: ?boolean,
/**
* A value indicating whether the accessibility elements contained within
* this accessibility element are hidden.
*
* @platform ios
*
* See https://reactnative.dev/docs/view#accessibilityElementsHidden
*/
accessibilityElementsHidden?: ?boolean,
/**
* Indicates to the accessibility services that the UI component is in
* a specific language. The provided string should be formatted following
* the BCP 47 specification (https://www.rfc-editor.org/info/bcp47).
*
* @platform ios
*/
accessibilityLanguage?: ?Stringish,
/**
* Blocks the user from interacting with the component through keyboard while still allowing
* screen reader to interact with it if this View is still accessible.
*
* @platform ios
*/
accessibilityRespondsToUserInteraction?: ?boolean,
}>;
export type AccessibilityProps = $ReadOnly<{
...AccessibilityPropsAndroid,
...AccessibilityPropsIOS,
/**
* When `true`, indicates that the view is an accessibility element.
* By default, all the touchable elements are accessible.
*
* See https://reactnative.dev/docs/view#accessible
*/
accessible?: ?boolean,
/**
* Overrides the text that's read by the screen reader when the user interacts
* with the element. By default, the label is constructed by traversing all
* the children and accumulating all the `Text` nodes separated by space.
*
* See https://reactnative.dev/docs/view#accessibilitylabel
*/
accessibilityLabel?: ?Stringish,
/**
* 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.
*
*
* See https://reactnative.dev/docs/view#accessibilityHint
*/
accessibilityHint?: ?Stringish,
/**
* Alias for accessibilityLabel https://reactnative.dev/docs/view#accessibilitylabel
* https://github.com/facebook/react-native/issues/34424
*/
'aria-label'?: ?Stringish,
/**
* Indicates to accessibility services to treat UI component like a specific role.
*/
accessibilityRole?: ?AccessibilityRole,
/**
* Alias for accessibilityRole
*/
role?: ?Role,
/**
* Indicates to accessibility services that UI Component is in a specific State.
*/
accessibilityState?: ?AccessibilityState,
accessibilityValue?: ?AccessibilityValue,
/**
* alias for accessibilityState
* It represents textual description of a component's value, or for range-based components, such as sliders and progress bars.
*/
'aria-valuemax'?: ?AccessibilityValue['max'],
'aria-valuemin'?: ?AccessibilityValue['min'],
'aria-valuenow'?: ?AccessibilityValue['now'],
'aria-valuetext'?: ?AccessibilityValue['text'],
/**
* Provides an array of custom actions available for accessibility.
*
*/
accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
/**
* alias for accessibilityState
*
* see https://reactnative.dev/docs/accessibility#accessibilitystate
*/
'aria-busy'?: ?boolean,
'aria-checked'?: ?boolean | 'mixed',
'aria-disabled'?: ?boolean,
'aria-expanded'?: ?boolean,
'aria-selected'?: ?boolean,
/** A value indicating whether the accessibility elements contained within
* this accessibility element are hidden.
*
* See https://reactnative.dev/docs/view#aria-hidden
*/
'aria-hidden'?: ?boolean,
}>;

View File

@@ -0,0 +1,46 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {HostComponent} from '../../../src/private/types/HostComponent';
import type {HostInstance} from '../../../src/private/types/HostInstance';
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import {type ViewProps as Props} from './ViewPropTypes';
const ViewNativeComponent: HostComponent<Props> =
NativeComponentRegistry.get<Props>('RCTView', () => ({
uiViewClassName: 'RCTView',
}));
interface NativeCommands {
+focus: (viewRef: HostInstance) => void;
+blur: (viewRef: HostInstance) => void;
+hotspotUpdate: (viewRef: HostInstance, x: number, y: number) => void;
+setPressed: (viewRef: HostInstance, pressed: boolean) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: ['focus', 'blur', 'hotspotUpdate', 'setPressed'],
});
/**
* `ViewNativeComponent` is an internal React Native host component, and is
* exported to provide lower-level access for libraries.
*
* @warning `<unstable_NativeView>` provides no semver guarantees and is not
* intended to be used in app code. Please use
* [`<View>`](https://reactnative.dev/docs/view) instead.
*/
// Additional note: Our long term plan is to reduce the overhead of the <Text>
// and <View> wrappers so that we no longer have any reason to export these APIs.
export default ViewNativeComponent;
export type ViewNativeComponentType = HostComponent<Props>;

View File

@@ -0,0 +1,237 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import type * as React from 'react';
import {Insets} from '../../../types/public/Insets';
import {GestureResponderHandlers} from '../../../types/public/ReactNativeRenderer';
import {StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {
BlurEvent,
FocusEvent,
LayoutChangeEvent,
PointerEvents,
} from '../../Types/CoreEventTypes';
import {Touchable} from '../Touchable/Touchable';
import {AccessibilityProps} from './ViewAccessibility';
/**
* @deprecated These properties are not implemented natively.
*/
export interface TVViewPropsIOS {
/**
* *(Apple TV only)* When set to true, this view will be focusable
* and navigable using the Apple TV remote.
*
* @platform ios
*/
isTVSelectable?: boolean | undefined;
/**
* *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view.
*
* @platform ios
* @deprecated Use `focusable` instead
*/
hasTVPreferredFocus?: boolean | undefined;
/**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
*
* @platform ios
*/
tvParallaxShiftDistanceX?: number | undefined;
/**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
*
* @platform ios
*/
tvParallaxShiftDistanceY?: number | undefined;
/**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05.
*
* @platform ios
*/
tvParallaxTiltAngle?: number | undefined;
/**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0.
*
* @platform ios
*/
tvParallaxMagnification?: number | undefined;
}
export interface ViewPropsIOS extends TVViewPropsIOS {
/**
* Whether this view should be rendered as a bitmap before compositing.
*
* On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children;
* for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view
* and quickly composite it during each frame.
*
* Rasterization incurs an off-screen drawing pass and the bitmap consumes memory.
* Test and measure when using this property.
*/
shouldRasterizeIOS?: boolean | undefined;
}
export interface ViewPropsAndroid {
/**
* Callback that is called when the view is blurred.
*
* Note: This will only be called if the view is focusable.
*/
onBlur?: ((e: BlurEvent) => void) | null | undefined;
/**
* Callback that is called when the view is focused.
*
* Note: This will only be called if the view is focusable.
*/
onFocus?: ((e: FocusEvent) => void) | null | undefined;
/**
* Whether this view should render itself (and all of its children) into a single hardware texture on the GPU.
*
* On Android, this is useful for animations and interactions that only modify opacity, rotation, translation, and/or scale:
* in those cases, the view doesn't have to be redrawn and display lists don't need to be re-executed. The texture can just be
* re-used and re-composited with different parameters. The downside is that this can use up limited video memory, so this prop should be set back to false at the end of the interaction/animation.
*/
renderToHardwareTextureAndroid?: boolean | undefined;
/**
* Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
*/
focusable?: boolean | undefined;
/**
* Indicates whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
* for more details.
*
* Supports the following values:
* - 0 (View is focusable)
* - -1 (View is not focusable)
*/
tabIndex?: 0 | -1 | undefined;
}
/**
* @see https://reactnative.dev/docs/view#props
*/
export interface ViewProps
extends ViewPropsAndroid,
ViewPropsIOS,
GestureResponderHandlers,
Touchable,
PointerEvents,
AccessibilityProps {
children?: React.ReactNode | undefined;
/**
* This defines how far a touch event can start away from the view.
* Typical interface guidelines recommend touch targets that are at least
* 30 - 40 points/density-independent pixels. If a Touchable view has
* a height of 20 the touchable height can be extended to 40 with
* hitSlop={{top: 10, bottom: 10, left: 0, right: 0}}
* NOTE The touch area never extends past the parent view bounds and
* the Z-index of sibling views always takes precedence if a touch
* hits two overlapping views.
*/
hitSlop?: null | Insets | number | undefined;
/**
* Used to reference react managed views from native code.
*/
id?: string | undefined;
/**
* Whether this view needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior.
* The default (false) falls back to drawing the component and its children
* with an alpha applied to the paint used to draw each element instead of rendering the full component offscreen and compositing it back with an alpha value.
* This default may be noticeable and undesired in the case where the View you are setting an opacity on
* has multiple overlapping elements (e.g. multiple overlapping Views, or text and a background).
*
* Rendering offscreen to preserve correct alpha behavior is extremely expensive
* and hard to debug for non-native developers, which is why it is not turned on by default.
* If you do need to enable this property for an animation,
* consider combining it with renderToHardwareTextureAndroid if the view contents are static (i.e. it doesn't need to be redrawn each frame).
* If that property is enabled, this View will be rendered off-screen once,
* saved in a hardware texture, and then composited onto the screen with an alpha each frame without having to switch rendering targets on the GPU.
*/
needsOffscreenAlphaCompositing?: boolean | undefined;
/**
* Invoked on mount and layout changes with
*
* {nativeEvent: { layout: {x, y, width, height}}}.
*/
onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
/**
*
* In the absence of auto property, none is much like CSS's none value. box-none is as if you had applied the CSS class:
*
* .box-none {
* pointer-events: none;
* }
* .box-none * {
* pointer-events: all;
* }
*
* box-only is the equivalent of
*
* .box-only {
* pointer-events: all;
* }
* .box-only * {
* pointer-events: none;
* }
*
* But since pointerEvents does not affect layout/appearance, and we are already deviating from the spec by adding additional modes,
* we opt to not include pointerEvents on style. On some platforms, we would need to implement it as a className anyways. Using style or not is an implementation detail of the platform.
*/
pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto' | undefined;
/**
*
* This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews,
* most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound.
* The subviews must also have overflow: hidden, as should the containing view (or one of its superviews).
*/
removeClippedSubviews?: boolean | undefined;
style?: StyleProp<ViewStyle> | undefined;
/**
* Used to locate this view in end-to-end tests.
*/
testID?: string | undefined;
/**
* Used to reference react managed views from native code.
*/
nativeID?: string | undefined;
/**
* Views that are only used to layout their children or otherwise don't draw anything
* may be automatically removed from the native hierarchy as an optimization.
* Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy.
*/
collapsable?: boolean | undefined;
/**
* Setting to false prevents direct children of the view from being removed
* from the native view hierarchy, similar to the effect of setting
* `collapsable={false}` on each child.
*/
collapsableChildren?: boolean | undefined;
}

View File

@@ -0,0 +1,513 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
'use strict';
import type {EdgeInsetsOrSizeProp} from '../../StyleSheet/EdgeInsetsPropType';
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {
BlurEvent,
FocusEvent,
GestureResponderEvent,
LayoutChangeEvent,
LayoutRectangle,
MouseEvent,
PointerEvent,
} from '../../Types/CoreEventTypes';
import type {
AccessibilityActionEvent,
AccessibilityProps,
} from './ViewAccessibility';
import * as React from 'react';
export type ViewLayout = LayoutRectangle;
export type ViewLayoutEvent = LayoutChangeEvent;
type DirectEventProps = $ReadOnly<{
/**
* When `accessible` is true, the system will try to invoke this function
* when the user performs an accessibility custom action.
*
*/
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
/**
* When `accessible` is true, the system will try to invoke this function
* when the user performs accessibility tap gesture.
*
* See https://reactnative.dev/docs/view#onaccessibilitytap
*/
onAccessibilityTap?: ?() => mixed,
/**
* Invoked on mount and layout changes with:
*
* `{nativeEvent: { layout: {x, y, width, height}}}`
*
* This event is fired immediately once the layout has been calculated, but
* the new layout may not yet be reflected on the screen at the time the
* event is received, especially if a layout animation is in progress.
*
* See https://reactnative.dev/docs/view#onlayout
*/
onLayout?: ?(event: LayoutChangeEvent) => mixed,
/**
* When `accessible` is `true`, the system will invoke this function when the
* user performs the magic tap gesture.
*
* See https://reactnative.dev/docs/view#onmagictap
*/
onMagicTap?: ?() => mixed,
/**
* When `accessible` is `true`, the system will invoke this function when the
* user performs the escape gesture.
*
* See https://reactnative.dev/docs/view#onaccessibilityescape
*/
onAccessibilityEscape?: ?() => mixed,
}>;
type MouseEventProps = $ReadOnly<{
onMouseEnter?: ?(event: MouseEvent) => void,
onMouseLeave?: ?(event: MouseEvent) => void,
}>;
// Experimental/Work in Progress Pointer Event Callbacks (not yet ready for use)
type PointerEventProps = $ReadOnly<{
onClick?: ?(event: PointerEvent) => void,
onClickCapture?: ?(event: PointerEvent) => void,
onPointerEnter?: ?(event: PointerEvent) => void,
onPointerEnterCapture?: ?(event: PointerEvent) => void,
onPointerLeave?: ?(event: PointerEvent) => void,
onPointerLeaveCapture?: ?(event: PointerEvent) => void,
onPointerMove?: ?(event: PointerEvent) => void,
onPointerMoveCapture?: ?(event: PointerEvent) => void,
onPointerCancel?: ?(e: PointerEvent) => void,
onPointerCancelCapture?: ?(e: PointerEvent) => void,
onPointerDown?: ?(e: PointerEvent) => void,
onPointerDownCapture?: ?(e: PointerEvent) => void,
onPointerUp?: ?(e: PointerEvent) => void,
onPointerUpCapture?: ?(e: PointerEvent) => void,
onPointerOver?: ?(e: PointerEvent) => void,
onPointerOverCapture?: ?(e: PointerEvent) => void,
onPointerOut?: ?(e: PointerEvent) => void,
onPointerOutCapture?: ?(e: PointerEvent) => void,
onGotPointerCapture?: ?(e: PointerEvent) => void,
onGotPointerCaptureCapture?: ?(e: PointerEvent) => void,
onLostPointerCapture?: ?(e: PointerEvent) => void,
onLostPointerCaptureCapture?: ?(e: PointerEvent) => void,
}>;
type FocusEventProps = $ReadOnly<{
onBlur?: ?(event: BlurEvent) => void,
onBlurCapture?: ?(event: BlurEvent) => void,
onFocus?: ?(event: FocusEvent) => void,
onFocusCapture?: ?(event: FocusEvent) => void,
}>;
type TouchEventProps = $ReadOnly<{
onTouchCancel?: ?(e: GestureResponderEvent) => void,
onTouchCancelCapture?: ?(e: GestureResponderEvent) => void,
onTouchEnd?: ?(e: GestureResponderEvent) => void,
onTouchEndCapture?: ?(e: GestureResponderEvent) => void,
onTouchMove?: ?(e: GestureResponderEvent) => void,
onTouchMoveCapture?: ?(e: GestureResponderEvent) => void,
onTouchStart?: ?(e: GestureResponderEvent) => void,
onTouchStartCapture?: ?(e: GestureResponderEvent) => void,
}>;
/**
* For most touch interactions, you'll simply want to wrap your component in
* `TouchableHighlight` or `TouchableOpacity`. Check out `Touchable.js`,
* `ScrollResponder.js` and `ResponderEventPlugin.js` for more discussion.
*/
export type GestureResponderHandlers = $ReadOnly<{
/**
* Does this view want to "claim" touch responsiveness? This is called for
* every touch move on the `View` when it is not the responder.
*
* `View.props.onMoveShouldSetResponder: (event) => [true | false]`, where
* `event` is a synthetic touch event as described above.
*
* See https://reactnative.dev/docs/view#onmoveshouldsetresponder
*/
onMoveShouldSetResponder?: ?(e: GestureResponderEvent) => boolean,
/**
* If a parent `View` wants to prevent a child `View` from becoming responder
* on a move, it should have this handler which returns `true`.
*
* `View.props.onMoveShouldSetResponderCapture: (event) => [true | false]`,
* where `event` is a synthetic touch event as described above.
*
* See https://reactnative.dev/docs/view#onMoveShouldsetrespondercapture
*/
onMoveShouldSetResponderCapture?: ?(e: GestureResponderEvent) => boolean,
/**
* The View is now responding for touch events. This is the time to highlight
* and show the user what is happening.
*
* `View.props.onResponderGrant: (event) => {}`, where `event` is a synthetic
* touch event as described above.
*
* Return true from this callback to prevent any other native components from
* becoming responder until this responder terminates (Android-only).
*
* See https://reactnative.dev/docs/view#onrespondergrant
*/
onResponderGrant?: ?(e: GestureResponderEvent) => void | boolean,
/**
* The user is moving their finger.
*
* `View.props.onResponderMove: (event) => {}`, where `event` is a synthetic
* touch event as described above.
*
* See https://reactnative.dev/docs/view#onrespondermove
*/
onResponderMove?: ?(e: GestureResponderEvent) => void,
/**
* Another responder is already active and will not release it to that `View`
* asking to be the responder.
*
* `View.props.onResponderReject: (event) => {}`, where `event` is a
* synthetic touch event as described above.
*
* See https://reactnative.dev/docs/view#onresponderreject
*/
onResponderReject?: ?(e: GestureResponderEvent) => void,
/**
* Fired at the end of the touch.
*
* `View.props.onResponderRelease: (event) => {}`, where `event` is a
* synthetic touch event as described above.
*
* See https://reactnative.dev/docs/view#onresponderrelease
*/
onResponderRelease?: ?(e: GestureResponderEvent) => void,
onResponderStart?: ?(e: GestureResponderEvent) => void,
onResponderEnd?: ?(e: GestureResponderEvent) => void,
/**
* The responder has been taken from the `View`. Might be taken by other
* views after a call to `onResponderTerminationRequest`, or might be taken
* by the OS without asking (e.g., happens with control center/ notification
* center on iOS)
*
* `View.props.onResponderTerminate: (event) => {}`, where `event` is a
* synthetic touch event as described above.
*
* See https://reactnative.dev/docs/view#onresponderterminate
*/
onResponderTerminate?: ?(e: GestureResponderEvent) => void,
/**
* Some other `View` wants to become responder and is asking this `View` to
* release its responder. Returning `true` allows its release.
*
* `View.props.onResponderTerminationRequest: (event) => {}`, where `event`
* is a synthetic touch event as described above.
*
* See https://reactnative.dev/docs/view#onresponderterminationrequest
*/
onResponderTerminationRequest?: ?(e: GestureResponderEvent) => boolean,
/**
* Does this view want to become responder on the start of a touch?
*
* `View.props.onStartShouldSetResponder: (event) => [true | false]`, where
* `event` is a synthetic touch event as described above.
*
* See https://reactnative.dev/docs/view#onstartshouldsetresponder
*/
onStartShouldSetResponder?: ?(e: GestureResponderEvent) => boolean,
/**
* If a parent `View` wants to prevent a child `View` from becoming responder
* on a touch start, it should have this handler which returns `true`.
*
* `View.props.onStartShouldSetResponderCapture: (event) => [true | false]`,
* where `event` is a synthetic touch event as described above.
*
* See https://reactnative.dev/docs/view#onstartshouldsetrespondercapture
*/
onStartShouldSetResponderCapture?: ?(e: GestureResponderEvent) => boolean,
}>;
type AndroidDrawableThemeAttr = $ReadOnly<{
type: 'ThemeAttrAndroid',
attribute: string,
}>;
type AndroidDrawableRipple = $ReadOnly<{
type: 'RippleAndroid',
color?: ?number,
borderless?: ?boolean,
rippleRadius?: ?number,
}>;
type AndroidDrawable = AndroidDrawableThemeAttr | AndroidDrawableRipple;
export type ViewPropsAndroid = $ReadOnly<{
nativeBackgroundAndroid?: ?AndroidDrawable,
nativeForegroundAndroid?: ?AndroidDrawable,
/**
* Whether this `View` should render itself (and all of its children) into a
* single hardware texture on the GPU.
*
* @platform android
*
* See https://reactnative.dev/docs/view#rendertohardwaretextureandroid
*/
renderToHardwareTextureAndroid?: ?boolean,
/**
* Whether to force the Android TV focus engine to move focus to this view.
*
* @platform android
* @deprecated Use `focusable` instead
*/
hasTVPreferredFocus?: ?boolean,
/**
* TV next focus down (see documentation for the View component).
*
* @platform android
*/
nextFocusDown?: ?number,
/**
* TV next focus forward (see documentation for the View component).
*
* @platform android
*/
nextFocusForward?: ?number,
/**
* TV next focus left (see documentation for the View component).
*
* @platform android
*/
nextFocusLeft?: ?number,
/**
* TV next focus right (see documentation for the View component).
*
* @platform android
*/
nextFocusRight?: ?number,
/**
* TV next focus up (see documentation for the View component).
*
* @platform android
*/
nextFocusUp?: ?number,
/**
* Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
*
* @platform android
*/
focusable?: ?boolean,
/**
* Indicates whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
* for more details.
*
* Supports the following values:
* - 0 (View is focusable)
* - -1 (View is not focusable)
*
* @platform android
*/
tabIndex?: 0 | -1,
/**
* The action to perform when this `View` is clicked on by a non-touch click, eg. enter key on a hardware keyboard.
*
* @platform android
*/
onClick?: ?(event: GestureResponderEvent) => mixed,
}>;
export type TVViewPropsIOS = $ReadOnly<{
/**
* *(Apple TV only)* When set to true, this view will be focusable
* and navigable using the Apple TV remote.
*
* @platform ios
*/
isTVSelectable?: boolean,
/**
* *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view.
*
* @platform ios
*/
hasTVPreferredFocus?: boolean,
/**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
*
* @platform ios
*/
tvParallaxShiftDistanceX?: number,
/**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
*
* @platform ios
*/
tvParallaxShiftDistanceY?: number,
/**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05.
*
* @platform ios
*/
tvParallaxTiltAngle?: number,
/**
* *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0.
*
* @platform ios
*/
tvParallaxMagnification?: number,
}>;
export type ViewPropsIOS = $ReadOnly<{
/**
* Whether this `View` should be rendered as a bitmap before compositing.
*
* @platform ios
*
* See https://reactnative.dev/docs/view#shouldrasterizeios
*/
shouldRasterizeIOS?: ?boolean,
}>;
type ViewBaseProps = $ReadOnly<{
children?: React.Node,
style?: ?ViewStyleProp,
/**
* Views that are only used to layout their children or otherwise don't draw
* anything may be automatically removed from the native hierarchy as an
* optimization. Set this property to `false` to disable this optimization and
* ensure that this `View` exists in the native view hierarchy.
*
* See https://reactnative.dev/docs/view#collapsable
*/
collapsable?: ?boolean,
/**
* Setting to false prevents direct children of the view from being removed
* from the native view hierarchy, similar to the effect of setting
* `collapsable={false}` on each child.
*/
collapsableChildren?: ?boolean,
/**
* Used to locate this view from native classes. Has precedence over `nativeID` prop.
*
* > This disables the 'layout-only view removal' optimization for this view!
*
* See https://reactnative.dev/docs/view#id
*/
id?: string,
/**
* Used to locate this view in end-to-end tests.
*
* > This disables the 'layout-only view removal' optimization for this view!
*
* See https://reactnative.dev/docs/view#testid
*/
testID?: ?string,
/**
* Used to locate this view from native classes.
*
* > This disables the 'layout-only view removal' optimization for this view!
*
* See https://reactnative.dev/docs/view#nativeid
*/
nativeID?: ?string,
/**
* Whether this `View` needs to rendered offscreen and composited with an
* alpha in order to preserve 100% correct colors and blending behavior.
*
* See https://reactnative.dev/docs/view#needsoffscreenalphacompositing
*/
needsOffscreenAlphaCompositing?: ?boolean,
/**
* This defines how far a touch event can start away from the view.
* Typical interface guidelines recommend touch targets that are at least
* 30 - 40 points/density-independent pixels.
*
* > The touch area never extends past the parent view bounds and the Z-index
* > of sibling views always takes precedence if a touch hits two overlapping
* > views.
*
* See https://reactnative.dev/docs/view#hitslop
*/
hitSlop?: ?EdgeInsetsOrSizeProp,
/**
* Controls whether the `View` can be the target of touch events.
*
* See https://reactnative.dev/docs/view#pointerevents
*/
pointerEvents?: ?('auto' | 'box-none' | 'box-only' | 'none'),
/**
* This is a special performance property exposed by `RCTView` and is useful
* for scrolling content when there are many subviews, most of which are
* offscreen. For this property to be effective, it must be applied to a
* view that contains many subviews that extend outside its bound. The
* subviews must also have `overflow: hidden`, as should the containing view
* (or one of its superviews).
*
* See https://reactnative.dev/docs/view#removeclippedsubviews
*/
removeClippedSubviews?: ?boolean,
/**
* Defines the order in which descendant elements receive accessibility focus.
* The elements in the array represent nativeID values for the respective
* descendant elements.
*/
experimental_accessibilityOrder?: ?Array<string>,
}>;
export type ViewProps = $ReadOnly<{
...DirectEventProps,
...GestureResponderHandlers,
...MouseEventProps,
...PointerEventProps,
...FocusEventProps,
...TouchEventProps,
...ViewPropsAndroid,
...ViewPropsIOS,
...AccessibilityProps,
...ViewBaseProps,
}>;