mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
8cdc9e7f04
Summary: React Native's TS definitions are currently mostly stored in one monolithic file. This change splits the definitions up to correspond to the source files they came from, and are placed next to the source files. I think this should help inform, and make it easy to update the TS declarations when touching the Flow file. I noticed as part of the change that the typings have not yet removed many APIs that were removed from RN. This is bad, since it means using the removed/non-functional API doesn't cause typechecker errors. Locating typings next to source should prevent that from being able to happen. The organization here means individual TS declarations can declare what will be in the RN entrypoint, which is a little confusing. Seems like a good potential next refactor, beyond the literal translation I did. Changelog: [General][Changed] - Place TS Declarations Alongside Source Files Reviewed By: lunaleaps, rshest Differential Revision: D39796598 fbshipit-source-id: b36366466fd1976bdd2d4c8f7a4104a33c457a07
91 lines
3.5 KiB
TypeScript
91 lines
3.5 KiB
TypeScript
/**
|
|
* 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 'Utilities';
|
|
import {GestureResponderEvent} from '../../Types/CoreEventTypes';
|
|
|
|
/**
|
|
* //FIXME: need to find documentation on which component is a TTouchable and can implement that interface
|
|
* @see React.DOMAtributes
|
|
*/
|
|
export interface Touchable {
|
|
onTouchStart?: ((event: GestureResponderEvent) => void) | undefined;
|
|
onTouchMove?: ((event: GestureResponderEvent) => void) | undefined;
|
|
onTouchEnd?: ((event: GestureResponderEvent) => void) | undefined;
|
|
onTouchCancel?: ((event: GestureResponderEvent) => void) | undefined;
|
|
onTouchEndCapture?: ((event: GestureResponderEvent) => void) | undefined;
|
|
}
|
|
|
|
export const Touchable: {
|
|
TOUCH_TARGET_DEBUG: boolean;
|
|
renderDebugView: (config: {
|
|
color: string | number;
|
|
hitSlop?: Insets | undefined;
|
|
}) => React.ReactElement | null;
|
|
};
|
|
|
|
/**
|
|
* @see https://github.com/facebook/react-native/blob/0.34-stable\Libraries\Components\Touchable\Touchable.js
|
|
*/
|
|
interface TouchableMixin {
|
|
/**
|
|
* Invoked when the item should be highlighted. Mixers should implement this
|
|
* to visually distinguish the `VisualRect` so that the user knows that
|
|
* releasing a touch will result in a "selection" (analog to click).
|
|
*/
|
|
touchableHandleActivePressIn(e: GestureResponderEvent): void;
|
|
|
|
/**
|
|
* Invoked when the item is "active" (in that it is still eligible to become
|
|
* a "select") but the touch has left the `PressRect`. Usually the mixer will
|
|
* want to unhighlight the `VisualRect`. If the user (while pressing) moves
|
|
* back into the `PressRect` `touchableHandleActivePressIn` will be invoked
|
|
* again and the mixer should probably highlight the `VisualRect` again. This
|
|
* event will not fire on an `touchEnd/mouseUp` event, only move events while
|
|
* the user is depressing the mouse/touch.
|
|
*/
|
|
touchableHandleActivePressOut(e: GestureResponderEvent): void;
|
|
|
|
/**
|
|
* Invoked when the item is "selected" - meaning the interaction ended by
|
|
* letting up while the item was either in the state
|
|
* `RESPONDER_ACTIVE_PRESS_IN` or `RESPONDER_INACTIVE_PRESS_IN`.
|
|
*/
|
|
touchableHandlePress(e: GestureResponderEvent): void;
|
|
|
|
/**
|
|
* Invoked when the item is long pressed - meaning the interaction ended by
|
|
* letting up while the item was in `RESPONDER_ACTIVE_LONG_PRESS_IN`. If
|
|
* `touchableHandleLongPress` is *not* provided, `touchableHandlePress` will
|
|
* be called as it normally is. If `touchableHandleLongPress` is provided, by
|
|
* default any `touchableHandlePress` callback will not be invoked. To
|
|
* override this default behavior, override `touchableLongPressCancelsPress`
|
|
* to return false. As a result, `touchableHandlePress` will be called when
|
|
* lifting up, even if `touchableHandleLongPress` has also been called.
|
|
*/
|
|
touchableHandleLongPress(e: GestureResponderEvent): void;
|
|
|
|
/**
|
|
* Returns the amount to extend the `HitRect` into the `PressRect`. Positive
|
|
* numbers mean the size expands outwards.
|
|
*/
|
|
touchableGetPressRectOffset(): Insets;
|
|
|
|
/**
|
|
* Returns the number of millis to wait before triggering a highlight.
|
|
*/
|
|
touchableGetHighlightDelayMS(): number;
|
|
|
|
// These methods are undocumented but still being used by TouchableMixin internals
|
|
touchableGetLongPressDelayMS(): number;
|
|
touchableGetPressOutDelayMS(): number;
|
|
touchableGetHitSlop(): Insets;
|
|
}
|