From 973d6bcdefe553e1803d110af2aa9aca0d1094ed Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Fri, 16 Feb 2018 15:10:50 -0600 Subject: [PATCH] [react-beautiful-dnd] update to 4.0.1 --- types/react-beautiful-dnd/index.d.ts | 42 +++++++++++++++---- .../react-beautiful-dnd-tests.tsx | 17 +++----- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/types/react-beautiful-dnd/index.d.ts b/types/react-beautiful-dnd/index.d.ts index b405c481c4..2bf9c7cfc2 100644 --- a/types/react-beautiful-dnd/index.d.ts +++ b/types/react-beautiful-dnd/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-beautiful-dnd 3.0 +// Type definitions for react-beautiful-dnd 4.0.1 // Project: https://github.com/atlassian/react-beautiful-dnd // Definitions by: varHarrie // Bradley Ayers @@ -8,12 +8,10 @@ import * as React from 'react'; export type Id = string; - export type DraggableId = Id; - export type DroppableId = Id; - export type TypeId = Id; +export type ZIndex = number | string; export interface DraggableLocation { droppableId: DroppableId; @@ -71,9 +69,33 @@ export class Droppable extends React.Component {} * Draggable */ -export type DraggableStyle = any; +export interface NotDraggingStyle { + transform: null | string, + transition: null | 'none', +} -export interface DragHandleProps { +export interface DraggingStyle { + pointerEvents: 'none', + position: 'fixed', + width: number, + height: number, + boxSizing: 'border-box', + top: number, + left: number, + margin: 0, + transform: null | string, + transition: 'none', + zIndex: ZIndex, +} + +export interface DraggableProvidedDraggableProps { + // inline style + style: null | DraggingStyle | NotDraggingStyle, + // used for shared global styles + 'data-react-beautiful-dnd-draggable': string, +} + +export interface DraggableProvidedDragHandleProps { onMouseDown: React.MouseEventHandler; onKeyDown: React.KeyboardEventHandler; onClick: React.MouseEventHandler; @@ -85,9 +107,11 @@ export interface DragHandleProps { } export interface DraggableProvided { + draggableProps: DraggableProvidedDraggableProps | null; + dragHandleProps: DraggableProvidedDragHandleProps | null; + + // will be removed after move to react 16 innerRef(element?: HTMLElement | null): any; - draggableStyle?: DraggableStyle | null; - dragHandleProps?: DragHandleProps | null; placeholder?: React.ReactElement | null; } @@ -97,7 +121,7 @@ export interface DraggableStateSnapshot { export interface DraggableProps { draggableId: DroppableId; - type?: TypeId; + index: number; isDragDisabled?: boolean; disableInteractiveElementBlocking?: boolean; children(provided: DraggableProvided, snapshot: DraggableStateSnapshot): React.ReactElement; diff --git a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx index 8f961e0c7a..b05ff46550 100644 --- a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx +++ b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx @@ -24,7 +24,7 @@ const reorder = (list: any[], startIndex: number, endIndex: number) => { return result; }; -const getItemStyle = (draggableStyle: any, isDragging: any) => ({ +const getItemStyle = (isDragging: boolean, draggableStyle: any) => ({ userSelect: 'none', background: isDragging ? 'lightgreen' : 'grey', ...draggableStyle @@ -68,21 +68,16 @@ class App extends React.Component<{}, AppState> { {(provided, snapshot) => ( -
- {this.state.items.map(item => ( - +
+ {this.state.items.map((item, index) => ( + {(provided, snapshot) => (
{item.content}