|
| 1 | +import * as React from 'react'; |
| 2 | + |
| 3 | +export type Axis = 'x' | 'y' | 'xy'; |
| 4 | + |
| 5 | +export type Offset = number | string; |
| 6 | + |
| 7 | +export interface SortStart { |
| 8 | + node: Element; |
| 9 | + index: number; |
| 10 | + collection: Offset; |
| 11 | +} |
| 12 | + |
| 13 | +export interface SortOver { |
| 14 | + index: number; |
| 15 | + oldIndex: number; |
| 16 | + newIndex: number; |
| 17 | + collection: Offset; |
| 18 | +} |
| 19 | + |
| 20 | +export interface SortEnd { |
| 21 | + oldIndex: number; |
| 22 | + newIndex: number; |
| 23 | + collection: Offset; |
| 24 | +} |
| 25 | + |
| 26 | +export type SortEvent = React.MouseEvent<any> | React.TouchEvent<any>; |
| 27 | + |
| 28 | +export type SortEventWithTag = SortEvent & { |
| 29 | + target: { |
| 30 | + tagName: string |
| 31 | + } |
| 32 | +}; |
| 33 | + |
| 34 | +export type SortStartHandler = (sort: SortStart, event: SortEvent) => void; |
| 35 | + |
| 36 | +export type SortMoveHandler = (event: SortEvent) => void; |
| 37 | + |
| 38 | +export type SortEndHandler = (sort: SortEnd, event: SortEvent) => void; |
| 39 | + |
| 40 | +export type SortOverHandler = (sort: SortOver, event: SortEvent) => void; |
| 41 | + |
| 42 | +export type ContainerGetter = (element: React.ReactElement<any>) => HTMLElement; |
| 43 | + |
| 44 | +export interface Dimensions { |
| 45 | + width: number; |
| 46 | + height: number; |
| 47 | +} |
| 48 | + |
| 49 | +export interface SortableContainerProps { |
| 50 | + axis?: Axis; |
| 51 | + lockAxis?: Axis; |
| 52 | + helperClass?: string; |
| 53 | + transitionDuration?: number; |
| 54 | + pressDelay?: number; |
| 55 | + pressThreshold?: number; |
| 56 | + distance?: number; |
| 57 | + shouldCancelStart?: (event: SortEvent | SortEventWithTag) => boolean; |
| 58 | + onSortStart?: SortStartHandler; |
| 59 | + onSortMove?: SortMoveHandler; |
| 60 | + onSortEnd?: SortEndHandler; |
| 61 | + onSortOver?: SortOverHandler; |
| 62 | + useDragHandle?: boolean; |
| 63 | + useWindowAsScrollContainer?: boolean; |
| 64 | + hideSortableGhost?: boolean; |
| 65 | + lockToContainerEdges?: boolean; |
| 66 | + lockOffset?: Offset | [Offset, Offset]; |
| 67 | + getContainer?: ContainerGetter; |
| 68 | + getHelperDimensions?: (sort: SortStart) => Dimensions; |
| 69 | +} |
| 70 | + |
| 71 | +export interface SortableElementProps { |
| 72 | + index: number; |
| 73 | + collection?: Offset; |
| 74 | + disabled?: boolean; |
| 75 | +} |
| 76 | + |
| 77 | +export interface Config { |
| 78 | + withRef: boolean; |
| 79 | +} |
| 80 | + |
| 81 | +export type WrappedComponentFactory<P> = (props: P) => JSX.Element; |
| 82 | + |
| 83 | +export type WrappedComponent<P> = React.ComponentClass<P> | WrappedComponentFactory<P>; |
| 84 | + |
| 85 | +export function SortableContainer<P>(wrappedComponent: WrappedComponent<P>, config?: Config): React.ComponentClass<P & SortableContainerProps>; |
| 86 | + |
| 87 | +export function SortableElement<P>(wrappedComponent: WrappedComponent<P>, config?: Config): React.ComponentClass<P & SortableElementProps>; |
| 88 | + |
| 89 | +export function SortableHandle<P>(wrappedComponent: WrappedComponent<P>, config?: Config): React.ComponentClass<P>; |
| 90 | + |
| 91 | +export const sortableContainer = SortableContainer; |
| 92 | + |
| 93 | +export const sortableElement = SortableElement; |
| 94 | + |
| 95 | +export const sortableHandle = SortableHandle; |
| 96 | + |
| 97 | +export function arrayMove<T>(collection: T[], previousIndex: number, newIndex: number): T[]; |
0 commit comments