Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@types/react] Upgrade types for React 16.4; add Pointer Events support (wip, awaiting feedback) #26363

Merged
merged 3 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 1 addition & 9 deletions types/react-pointable/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for react-pointable 1.1
// Type definitions for react-pointable 1.2
// Project: https://github.com/MilllerTime/react-pointable
// Definitions by: Stefan Fochler <https://github.com/istefo>
// Dibyo Majumdar <https://github.com/mdibyo>
Expand All @@ -13,14 +13,6 @@ export interface PointableProps extends React.HTMLAttributes<Element>, React.SVG
tagName?: keyof ElementTagNameMap;
touchAction?: TouchAction;
elementRef?(el: HTMLElement|SVGElement): void;
onPointerMove?(evt: PointerEvent): void;
onPointerDown?(evt: PointerEvent): void;
onPointerUp?(evt: PointerEvent): void;
onPointerOver?(evt: PointerEvent): void;
onPointerOut?(evt: PointerEvent): void;
onPointerEnter?(evt: PointerEvent): void;
onPointerLeave?(evt: PointerEvent): void;
onPointerCancel?(evt: PointerEvent): void;
}

export default class Pointable extends React.Component<PointableProps> {
Expand Down
2 changes: 1 addition & 1 deletion types/react-pointable/react-pointable-tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Pointable from 'react-pointable';

class Test extends React.Component<object, object> {
elementRef(el: HTMLElement) {}
somePointerEvent(evt: PointerEvent) {}
somePointerEvent(evt: React.PointerEvent) {}

render() {
return (
Expand Down
1 change: 1 addition & 0 deletions types/react/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface FocusEvent extends Event { }
interface KeyboardEvent extends Event { }
interface MouseEvent extends Event { }
interface TouchEvent extends Event { }
interface PointerEvent extends Event { }
interface TransitionEvent extends Event { }
interface UIEvent extends Event { }
interface WheelEvent extends Event { }
Expand Down
38 changes: 37 additions & 1 deletion types/react/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for React 16.3
// Type definitions for React 16.4
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>
// AssureSign <http://www.assuresign.com>
Expand Down Expand Up @@ -31,6 +31,7 @@ type NativeFocusEvent = FocusEvent;
type NativeKeyboardEvent = KeyboardEvent;
type NativeMouseEvent = MouseEvent;
type NativeTouchEvent = TouchEvent;
type NativePointerEvent = PointerEvent;
type NativeTransitionEvent = TransitionEvent;
type NativeUIEvent = UIEvent;
type NativeWheelEvent = WheelEvent;
Expand Down Expand Up @@ -590,6 +591,18 @@ declare namespace React {
nativeEvent: NativeDragEvent;
}

interface PointerEvent<T = Element> extends MouseEvent<T> {
pointerId: number;
pressure: number;
tiltX: number;
tiltY: number;
width: number;
height: number;
pointerType: 'mouse' | 'pen' | 'touch';
isPrimary: boolean;
nativeEvent: NativePointerEvent;
}

interface FocusEvent<T = Element> extends SyntheticEvent<T> {
nativeEvent: NativeFocusEvent;
relatedTarget: EventTarget;
Expand Down Expand Up @@ -711,6 +724,7 @@ declare namespace React {
type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
type PointerEventHandler<T = Element> = EventHandler<PointerEvent<T>>;
type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
Expand Down Expand Up @@ -898,6 +912,28 @@ declare namespace React {
onTouchStart?: TouchEventHandler<T>;
onTouchStartCapture?: TouchEventHandler<T>;

// Pointer Events
onPointerDown?: PointerEventHandler<T>;
onPointerDownCapture?: PointerEventHandler<T>;
onPointerMove?: PointerEventHandler<T>;
onPointerMoveCapture?: PointerEventHandler<T>;
onPointerUp?: PointerEventHandler<T>;
onPointerUpCapture?: PointerEventHandler<T>;
onPointerCancel?: PointerEventHandler<T>;
onPointerCancelCapture?: PointerEventHandler<T>;
onPointerEnter?: PointerEventHandler<T>;
onPointerEnterCapture?: PointerEventHandler<T>;
onPointerLeave?: PointerEventHandler<T>;
onPointerLeaveCapture?: PointerEventHandler<T>;
onPointerOver?: PointerEventHandler<T>;
onPointerOverCapture?: PointerEventHandler<T>;
onPointerOut?: PointerEventHandler<T>;
onPointerOutCapture?: PointerEventHandler<T>;
onGotPointerCapture?: PointerEventHandler<T>;
onGotPointerCaptureCapture?: PointerEventHandler<T>;
onLostPointerCapture?: PointerEventHandler<T>;
onLostPointerCaptureCapture?: PointerEventHandler<T>;

// UI Events
onScroll?: UIEventHandler<T>;
onScrollCapture?: UIEventHandler<T>;
Expand Down