forked from bokuweb/react-rnd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js.flow
More file actions
executable file
·172 lines (152 loc) · 3.71 KB
/
index.js.flow
File metadata and controls
executable file
·172 lines (152 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* @flow */
import * as React from 'react';
import type { ResizeDirection, ResizeCallback, ResizeStartCallback } from 're-resizable';
export type Grid = [number, number];
export type Position = {
x: number,
y: number,
};
export type DraggableData = {
node: HTMLElement,
deltaX: number,
deltaY: number,
lastX: number,
lastY: number,
} & Position;
export type RndDragCallback = (e: Event, data: DraggableData) => void | false;
export type RndResizeStartCallback = (
e: SyntheticMouseEvent<HTMLDivElement> | SyntheticTouchEvent<HTMLDivElement>,
dir: ResizeDirection,
refToElement: React.ElementRef<'div'>,
) => void;
export type ResizableDelta = {
width: number,
height: number,
};
export type RndResizeCallback = (
e: MouseEvent | TouchEvent,
dir: ResizeDirection,
refToElement: React.ElementRef<'div'>,
delta: ResizableDelta,
position: Position,
) => void;
type Size = {
width: string | number,
height: string | number,
};
type State = {
original: Position,
bounds: {
top: number,
right: number,
bottom: number,
left: number,
},
maxWidth?: number | string,
maxHeight?: number | string,
};
export type ResizeEnable = {
bottom?: boolean,
bottomLeft?: boolean,
bottomRight?: boolean,
left?: boolean,
right?: boolean,
top?: boolean,
topLeft?: boolean,
topRight?: boolean,
};
export type HandleClasses = {
bottom?: string,
bottomLeft?: string,
bottomRight?: string,
left?: string,
right?: string,
top?: string,
topLeft?: string,
topRight?: string,
};
type Style = {
[key: string]: string | number,
};
export type HandleStyles = {
bottom?: Style,
bottomLeft?: Style,
bottomRight?: Style,
left?: Style,
right?: Style,
top?: Style,
topLeft?: Style,
topRight?: Style,
};
export type HandleComponent = {
top?: React.ReactElement<any>;
right?: React.ReactElement<any>;
bottom?: React.ReactElement<any>;
left?: React.ReactElement<any>;
topRight?: React.ReactElement<any>;
bottomRight?: React.ReactElement<any>;
bottomLeft?: React.ReactElement<any>;
topLeft?: React.ReactElement<any>;
}
export type PositionUnit = 'px' | '%';
export type Props = {
dragGrid?: Grid,
default?: {
x: number,
y: number,
} & Size,
position?: {
x: number,
y: number,
},
positionUnit?: PositionUnit,
size?: Size,
resizeGrid?: Grid,
bounds?: string,
onResizeStart?: RndResizeStartCallback,
onResize?: RndResizeCallback,
onResizeStop?: RndResizeCallback,
onDragStart?: RndDragCallback,
onDrag?: RndDragCallback,
onDragStop?: RndDragCallback,
className?: string,
style?: Style,
children?: React.Node,
enableResizing?: ResizeEnable,
extendsProps?: { [key: string]: any },
resizeHandleClasses?: HandleClasses,
resizeHandleStyles?: HandleStyles,
resizeHandleComponent?: HandleComponent,
resizeHandleWrapperClass?: string,
resizeHandleWrapperStyle?: Style,
lockAspectRatio?: boolean | number,
lockAspectRatioExtraWidth?: number,
lockAspectRatioExtraHeight?: number,
maxHeight?: number | string,
maxWidth?: number | string,
minHeight?: number | string,
minWidth?: number | string,
dragAxis?: 'x' | 'y' | 'both' | 'none',
dragHandleClassName?: string,
disableDragging?: boolean,
cancel?: boolean,
enableUserSelectHack?: boolean,
scale?: number,
};
export class Rnd extends React.Component<Props, State> {
static defaultProps = {
maxWidth: Number.MAX_SAFE_INTEGER,
maxHeight: Number.MAX_SAFE_INTEGER,
onResizeStart: () => {},
onResize: () => {},
onResizeStop: () => {},
onDragStart: () => {},
onDrag: () => {},
onDragStop: () => {},
scale: 1,
};
updateSize(size: { width: number | string, height: number | string }) {
}
updatePosition(position: Position) {
}
}