1 |
|
2 |
|
3 | import type { WebMercatorViewport } from 'viewport-mercator-project';
|
4 | import type {
|
5 | Feature,
|
6 | ImmutableFeatureCollection,
|
7 | PointerMoveEvent,
|
8 | EditAction,
|
9 | Pick,
|
10 | ClickEvent,
|
11 | ScreenCoordinates
|
12 | } from '@nebula.gl/edit-modes';
|
13 |
|
14 | import { RENDER_STATE, MODES, GEOJSON_TYPE } from './constants';
|
15 |
|
16 | export type Id = string | number;
|
17 |
|
18 | export type Mode = $Keys<typeof MODES>;
|
19 | export type RenderState = $Values<typeof RENDER_STATE>;
|
20 | export type GeoJsonType = $Values<typeof GEOJSON_TYPE>;
|
21 |
|
22 |
|
23 | export type ModeProps<TData> = {
|
24 |
|
25 | data: TData,
|
26 |
|
27 |
|
28 | modeConfig: any,
|
29 |
|
30 | viewport: ?WebMercatorViewport,
|
31 |
|
32 |
|
33 | selectedIndexes: number[],
|
34 |
|
35 |
|
36 | cursor: ?string,
|
37 |
|
38 |
|
39 | lastPointerMoveEvent: PointerMoveEvent,
|
40 |
|
41 |
|
42 | onEdit: (editAction: EditAction<TData>) => void,
|
43 |
|
44 |
|
45 | onUpdateCursor: (cursor: ?string) => void
|
46 | };
|
47 |
|
48 | export type EditorProps = {
|
49 | mode: Mode,
|
50 | style: ?Object,
|
51 | features: ?(Feature[]),
|
52 | selectedFeatureIndex: ?number,
|
53 | clickRadius: number,
|
54 | featureShape: Function | string,
|
55 | editHandleShape: Function | string,
|
56 | editHandleStyle: Function | any,
|
57 | featureStyle: Function | any,
|
58 | onUpdate: Function,
|
59 | onSelect: Function
|
60 | };
|
61 |
|
62 | export type EditorState = {
|
63 | featureCollection: ?ImmutableFeatureCollection,
|
64 |
|
65 | selectedFeatureIndex: ?number,
|
66 |
|
67 | hovered: ?Pick,
|
68 | lastPointerMoveEvent: PointerMoveEvent,
|
69 |
|
70 | isDragging: boolean,
|
71 | didDrag: boolean,
|
72 |
|
73 | pointerDownPicks: ?(Pick[]),
|
74 | pointerDownScreenCoords: ?ScreenCoordinates,
|
75 | pointerDownMapCoords: ?Position
|
76 | };
|
77 |
|
78 | export type BaseEvent = ClickEvent;
|
79 |
|
80 | export type SelectAction = {
|
81 | selectedFeature: ?Feature,
|
82 | selectedFeatureIndex?: ?number,
|
83 | selectedEditHandleIndex?: ?number,
|
84 | screenCoords: ?ScreenCoordinates,
|
85 | mapCoords: ?Position
|
86 | };
|