UNPKG

2.1 kBJavaScriptView Raw
1// @flow
2
3import type { WebMercatorViewport } from 'viewport-mercator-project';
4import type {
5 Feature,
6 ImmutableFeatureCollection,
7 PointerMoveEvent,
8 EditAction,
9 Pick,
10 ClickEvent,
11 ScreenCoordinates
12} from '@nebula.gl/edit-modes';
13
14import { RENDER_STATE, MODES, GEOJSON_TYPE } from './constants';
15
16export type Id = string | number;
17
18export type Mode = $Keys<typeof MODES>;
19export type RenderState = $Values<typeof RENDER_STATE>;
20export type GeoJsonType = $Values<typeof GEOJSON_TYPE>;
21
22// TODO extend from nebula
23export type ModeProps<TData> = {
24 // The data being edited, this can be an array or an object
25 data: TData,
26
27 // Additional configuration for this mode
28 modeConfig: any,
29
30 viewport: ?WebMercatorViewport,
31
32 // The indexes of the selected features
33 selectedIndexes: number[],
34
35 // The cursor type, as a [CSS Cursor](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor)
36 cursor: ?string,
37
38 // The last pointer move event that occurred
39 lastPointerMoveEvent: PointerMoveEvent,
40
41 // Callback used to notify applications of an edit action
42 onEdit: (editAction: EditAction<TData>) => void,
43
44 // Callback used to update cursor
45 onUpdateCursor: (cursor: ?string) => void
46};
47
48export 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
62export 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
78export type BaseEvent = ClickEvent;
79
80export type SelectAction = {
81 selectedFeature: ?Feature,
82 selectedFeatureIndex?: ?number,
83 selectedEditHandleIndex?: ?number,
84 screenCoords: ?ScreenCoordinates,
85 mapCoords: ?Position
86};