leaflet-tual 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +256 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +559 -0
- package/dist/index.d.ts +559 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +4 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +823 -0
- package/dist/react.d.ts +823 -0
- package/dist/react.js +4 -0
- package/dist/react.js.map +1 -0
- package/package.json +124 -6
- package/index.js +0 -1
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,823 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import L from 'leaflet';
|
|
4
|
+
|
|
5
|
+
type GeoPoint = {
|
|
6
|
+
lat: number;
|
|
7
|
+
lng: number;
|
|
8
|
+
};
|
|
9
|
+
type ScreenPoint = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
type ArrowStyle = 'linear' | 'curved' | 'bi' | 'elbow' | 's-curve';
|
|
14
|
+
type ShapeKind = 'square' | 'circle' | 'star' | 'actor' | 'triangle' | 'diamond' | 'hexagon' | 'marker';
|
|
15
|
+
type CanvasTool = 'select' | 'freedraw' | 'arrow-linear' | 'arrow-curved' | 'arrow-bi' | 'arrow-elbow' | 'arrow-s-curve' | 'shape' | 'ruler' | 'note' | 'text';
|
|
16
|
+
type ToolbarToolGroupId = 'select' | 'freedraw' | 'arrow' | 'shape' | 'ruler' | 'note' | 'text';
|
|
17
|
+
type ArrowHeadStyle = 'triangle' | 'open' | 'both' | 'none';
|
|
18
|
+
interface ArrowItem {
|
|
19
|
+
id: string;
|
|
20
|
+
type: 'arrow';
|
|
21
|
+
arrowStyle: ArrowStyle;
|
|
22
|
+
start: GeoPoint;
|
|
23
|
+
end: GeoPoint;
|
|
24
|
+
controlPoint?: GeoPoint;
|
|
25
|
+
color: string;
|
|
26
|
+
strokeWidth: number;
|
|
27
|
+
dashed?: boolean;
|
|
28
|
+
headStyle?: ArrowHeadStyle;
|
|
29
|
+
label?: string;
|
|
30
|
+
labelMode?: boolean;
|
|
31
|
+
hasLabelMode?: boolean;
|
|
32
|
+
createdAt: number;
|
|
33
|
+
}
|
|
34
|
+
interface FreeDrawItem {
|
|
35
|
+
id: string;
|
|
36
|
+
type: 'freedraw';
|
|
37
|
+
points: GeoPoint[];
|
|
38
|
+
color: string;
|
|
39
|
+
strokeWidth: number;
|
|
40
|
+
dashed?: boolean;
|
|
41
|
+
createdAt: number;
|
|
42
|
+
}
|
|
43
|
+
interface ShapeItem {
|
|
44
|
+
id: string;
|
|
45
|
+
type: 'shape';
|
|
46
|
+
shape: ShapeKind;
|
|
47
|
+
start: GeoPoint;
|
|
48
|
+
end: GeoPoint;
|
|
49
|
+
color: string;
|
|
50
|
+
fillColor?: string;
|
|
51
|
+
filled?: boolean;
|
|
52
|
+
strokeWidth: number;
|
|
53
|
+
dashed?: boolean;
|
|
54
|
+
label?: string;
|
|
55
|
+
labelMode?: boolean;
|
|
56
|
+
hasLabelMode?: boolean;
|
|
57
|
+
createdAt: number;
|
|
58
|
+
}
|
|
59
|
+
type NoteCollapseState = 'expanded' | 'collapsed' | 'compact';
|
|
60
|
+
interface NoteItem {
|
|
61
|
+
id: string;
|
|
62
|
+
type: 'note';
|
|
63
|
+
position: GeoPoint;
|
|
64
|
+
title?: string;
|
|
65
|
+
text: string;
|
|
66
|
+
backgroundColor: string;
|
|
67
|
+
textColor: string;
|
|
68
|
+
width?: number;
|
|
69
|
+
height?: number;
|
|
70
|
+
minimized?: boolean | 'compact';
|
|
71
|
+
collapseState?: NoteCollapseState;
|
|
72
|
+
createdAt: number;
|
|
73
|
+
}
|
|
74
|
+
interface TextItem {
|
|
75
|
+
id: string;
|
|
76
|
+
type: 'text';
|
|
77
|
+
position: GeoPoint;
|
|
78
|
+
text: string;
|
|
79
|
+
color: string;
|
|
80
|
+
initialFontSize?: number;
|
|
81
|
+
baseZoom?: number;
|
|
82
|
+
fontWeight?: 'normal' | 'bold';
|
|
83
|
+
backgroundColor?: string;
|
|
84
|
+
createdAt: number;
|
|
85
|
+
}
|
|
86
|
+
interface RulerItem {
|
|
87
|
+
id: string;
|
|
88
|
+
type: 'ruler';
|
|
89
|
+
start: GeoPoint;
|
|
90
|
+
end: GeoPoint;
|
|
91
|
+
color: string;
|
|
92
|
+
strokeWidth: number;
|
|
93
|
+
dashed?: boolean;
|
|
94
|
+
label?: string;
|
|
95
|
+
unit?: 'metric' | 'imperial';
|
|
96
|
+
createdAt: number;
|
|
97
|
+
}
|
|
98
|
+
type CanvasItem = ArrowItem | FreeDrawItem | ShapeItem | NoteItem | TextItem | RulerItem;
|
|
99
|
+
|
|
100
|
+
type ToolbarPosition = 'top' | 'bottom' | 'left' | 'right' | 'top-center' | 'bottom-center' | 'left-center' | 'right-center';
|
|
101
|
+
type ToolbarOrientation = 'horizontal' | 'vertical';
|
|
102
|
+
interface CanvasLabels {
|
|
103
|
+
select?: string;
|
|
104
|
+
freedraw?: string;
|
|
105
|
+
arrowGroup?: string;
|
|
106
|
+
arrowLinear?: string;
|
|
107
|
+
arrowCurved?: string;
|
|
108
|
+
arrowBi?: string;
|
|
109
|
+
arrowElbow?: string;
|
|
110
|
+
arrowSCurve?: string;
|
|
111
|
+
shapesGroup?: string;
|
|
112
|
+
shapesModalTitle?: string;
|
|
113
|
+
shapeSquare?: string;
|
|
114
|
+
shapeCircle?: string;
|
|
115
|
+
shapeStar?: string;
|
|
116
|
+
shapeActor?: string;
|
|
117
|
+
shapeTriangle?: string;
|
|
118
|
+
shapeDiamond?: string;
|
|
119
|
+
shapeHexagon?: string;
|
|
120
|
+
shapeMarker?: string;
|
|
121
|
+
ruler?: string;
|
|
122
|
+
note?: string;
|
|
123
|
+
text?: string;
|
|
124
|
+
undo?: string;
|
|
125
|
+
redo?: string;
|
|
126
|
+
delete?: string;
|
|
127
|
+
clear?: string;
|
|
128
|
+
color?: string;
|
|
129
|
+
width?: string;
|
|
130
|
+
dashed?: string;
|
|
131
|
+
filled?: string;
|
|
132
|
+
arrowStylePrefix?: string;
|
|
133
|
+
arrowLabelPlaceholder?: string;
|
|
134
|
+
shapeLabelPlaceholder?: string;
|
|
135
|
+
noteTheme?: string;
|
|
136
|
+
noteDefaultTitle?: string;
|
|
137
|
+
noteTitlePlaceholder?: string;
|
|
138
|
+
noteTextPlaceholder?: string;
|
|
139
|
+
noteExpand?: string;
|
|
140
|
+
noteCollapse?: string;
|
|
141
|
+
noteCompact?: string;
|
|
142
|
+
noteDelete?: string;
|
|
143
|
+
noteResize?: string;
|
|
144
|
+
fontSize?: string;
|
|
145
|
+
textPlaceholder?: string;
|
|
146
|
+
textEmptyFallback?: string;
|
|
147
|
+
textEdit?: string;
|
|
148
|
+
textDone?: string;
|
|
149
|
+
textBold?: string;
|
|
150
|
+
textDecreaseSize?: string;
|
|
151
|
+
textIncreaseSize?: string;
|
|
152
|
+
textDelete?: string;
|
|
153
|
+
collapseToolbar?: string;
|
|
154
|
+
expandToolbar?: string;
|
|
155
|
+
}
|
|
156
|
+
interface CanvasAnnotationTheme {
|
|
157
|
+
selectionGlowColor?: string;
|
|
158
|
+
selectionGlowWidth?: number;
|
|
159
|
+
guideLineDash?: readonly number[];
|
|
160
|
+
guideLineColor?: string;
|
|
161
|
+
guideLineWidth?: number;
|
|
162
|
+
endpointHandleColor?: string;
|
|
163
|
+
controlHandleColor?: string;
|
|
164
|
+
handleFillColor?: string;
|
|
165
|
+
handleRadius?: number;
|
|
166
|
+
handleStrokeWidth?: number;
|
|
167
|
+
shadowColor?: string;
|
|
168
|
+
shadowBlur?: number;
|
|
169
|
+
shadowOffsetY?: number;
|
|
170
|
+
labelBackgroundColor?: string;
|
|
171
|
+
labelTextColor?: string;
|
|
172
|
+
labelFont?: string;
|
|
173
|
+
labelBorderColor?: string;
|
|
174
|
+
labelBorderWidth?: number;
|
|
175
|
+
labelBorderRadius?: number;
|
|
176
|
+
labelPaddingX?: number;
|
|
177
|
+
labelPaddingY?: number;
|
|
178
|
+
labelShadowColor?: string;
|
|
179
|
+
labelShadowBlur?: number;
|
|
180
|
+
shapeDefaultFillOpacity?: number;
|
|
181
|
+
shapeBorderRadius?: number;
|
|
182
|
+
labelMinShapeSize?: number;
|
|
183
|
+
labelMaxTextWidth?: number;
|
|
184
|
+
fitLabelsToShape?: boolean;
|
|
185
|
+
}
|
|
186
|
+
type ArrowRenderTheme = CanvasAnnotationTheme;
|
|
187
|
+
interface LeafletCanvasClassNames {
|
|
188
|
+
overlay?: string;
|
|
189
|
+
canvas?: string;
|
|
190
|
+
drawingSurface?: string;
|
|
191
|
+
itemsContainer?: string;
|
|
192
|
+
toolbar?: string;
|
|
193
|
+
toolbarPrimary?: string;
|
|
194
|
+
toolbarSecondary?: string;
|
|
195
|
+
toolButton?: string;
|
|
196
|
+
toolButtonActive?: string;
|
|
197
|
+
arrowGroupWrapper?: string;
|
|
198
|
+
arrowDropdownMenu?: string;
|
|
199
|
+
arrowDropdownItem?: string;
|
|
200
|
+
arrowDropdownItemActive?: string;
|
|
201
|
+
shapesGroupWrapper?: string;
|
|
202
|
+
shapesModal?: string;
|
|
203
|
+
shapesModalHeader?: string;
|
|
204
|
+
shapesModalGrid?: string;
|
|
205
|
+
shapesModalItem?: string;
|
|
206
|
+
shapesModalItemActive?: string;
|
|
207
|
+
toolbarDivider?: string;
|
|
208
|
+
toolbarCollapseButton?: string;
|
|
209
|
+
toolbarCollapsed?: string;
|
|
210
|
+
actionButton?: string;
|
|
211
|
+
actionButtonDisabled?: string;
|
|
212
|
+
deleteButton?: string;
|
|
213
|
+
swatchButton?: string;
|
|
214
|
+
swatchButtonActive?: string;
|
|
215
|
+
toolbarInput?: string;
|
|
216
|
+
toolbarSelect?: string;
|
|
217
|
+
noteCard?: string;
|
|
218
|
+
noteCardSelected?: string;
|
|
219
|
+
noteCollapsed?: string;
|
|
220
|
+
noteCompact?: string;
|
|
221
|
+
noteHeader?: string;
|
|
222
|
+
noteTitleInput?: string;
|
|
223
|
+
noteHeaderActions?: string;
|
|
224
|
+
noteHeaderButton?: string;
|
|
225
|
+
noteDeleteButton?: string;
|
|
226
|
+
noteBody?: string;
|
|
227
|
+
noteTextarea?: string;
|
|
228
|
+
noteResizeHandle?: string;
|
|
229
|
+
textWrapper?: string;
|
|
230
|
+
textWrapperSelected?: string;
|
|
231
|
+
textCompact?: string;
|
|
232
|
+
textControls?: string;
|
|
233
|
+
textControlButton?: string;
|
|
234
|
+
textControlButtonActive?: string;
|
|
235
|
+
textInput?: string;
|
|
236
|
+
textDisplay?: string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
interface DraftArrowState {
|
|
240
|
+
arrowStyle: ArrowStyle;
|
|
241
|
+
startGeo: GeoPoint;
|
|
242
|
+
currentGeo: GeoPoint;
|
|
243
|
+
}
|
|
244
|
+
interface DraftShapeState {
|
|
245
|
+
shape: ShapeKind;
|
|
246
|
+
startGeo: GeoPoint;
|
|
247
|
+
currentGeo: GeoPoint;
|
|
248
|
+
}
|
|
249
|
+
interface DraftRulerState {
|
|
250
|
+
startGeo: GeoPoint;
|
|
251
|
+
currentGeo: GeoPoint;
|
|
252
|
+
}
|
|
253
|
+
interface CanvasOverlayOptions {
|
|
254
|
+
interactive?: boolean;
|
|
255
|
+
readOnly?: boolean;
|
|
256
|
+
zIndex?: number;
|
|
257
|
+
defaultColor?: string;
|
|
258
|
+
defaultStrokeWidth?: number;
|
|
259
|
+
defaultNoteColor?: string;
|
|
260
|
+
defaultFontSize?: number;
|
|
261
|
+
defaultShape?: ShapeKind;
|
|
262
|
+
}
|
|
263
|
+
interface UseLeafletCanvasOptions extends CanvasOverlayOptions {
|
|
264
|
+
initialItems?: CanvasItem[];
|
|
265
|
+
items?: CanvasItem[];
|
|
266
|
+
maxHistory?: number;
|
|
267
|
+
onItemsChange?: (items: CanvasItem[]) => void;
|
|
268
|
+
onChange?: (items: CanvasItem[]) => void;
|
|
269
|
+
onChangeComplete?: (items: CanvasItem[], targetItem?: CanvasItem | null) => void;
|
|
270
|
+
onItemsChangeComplete?: (items: CanvasItem[], targetItem?: CanvasItem | null) => void;
|
|
271
|
+
onEditEnd?: (items: CanvasItem[], targetItem?: CanvasItem | null) => void;
|
|
272
|
+
onEditComplete?: (items: CanvasItem[], targetItem?: CanvasItem | null) => void;
|
|
273
|
+
onItemSelect?: (item: CanvasItem | null) => void;
|
|
274
|
+
onItemCreate?: (item: CanvasItem) => void;
|
|
275
|
+
onItemChange?: (item: CanvasItem) => void;
|
|
276
|
+
onItemDelete?: (id: string) => void;
|
|
277
|
+
onItemChangeComplete?: (item: CanvasItem) => void;
|
|
278
|
+
initialTool?: CanvasTool;
|
|
279
|
+
onToolChange?: (tool: CanvasTool) => void;
|
|
280
|
+
}
|
|
281
|
+
type LeafletCanvasOptions = UseLeafletCanvasOptions;
|
|
282
|
+
interface LeafletCanvasController {
|
|
283
|
+
items: CanvasItem[];
|
|
284
|
+
activeTool: CanvasTool;
|
|
285
|
+
setActiveTool: (tool: CanvasTool) => void;
|
|
286
|
+
readOnly: boolean;
|
|
287
|
+
setReadOnly: (readOnly: boolean) => void;
|
|
288
|
+
activeShape: ShapeKind;
|
|
289
|
+
setActiveShape: (shape: ShapeKind) => void;
|
|
290
|
+
shapeFilled: boolean;
|
|
291
|
+
setShapeFilled: (filled: boolean) => void;
|
|
292
|
+
selectedId: string | null;
|
|
293
|
+
setSelectedId: (id: string | null) => void;
|
|
294
|
+
selectedItem: CanvasItem | null;
|
|
295
|
+
isEditingLabel?: boolean;
|
|
296
|
+
setEditingLabel?: (editing: boolean) => void;
|
|
297
|
+
labelEditMode?: boolean;
|
|
298
|
+
setLabelEditMode?: (editing: boolean) => void;
|
|
299
|
+
activeColor: string;
|
|
300
|
+
setActiveColor: (color: string) => void;
|
|
301
|
+
strokeWidth: number;
|
|
302
|
+
setStrokeWidth: (width: number) => void;
|
|
303
|
+
dashed: boolean;
|
|
304
|
+
setDashed: (dashed: boolean) => void;
|
|
305
|
+
noteColor: string;
|
|
306
|
+
setNoteColor: (color: string) => void;
|
|
307
|
+
fontSize: number;
|
|
308
|
+
setFontSize: (size: number) => void;
|
|
309
|
+
fontWeight: 'normal' | 'bold';
|
|
310
|
+
setFontWeight: (weight: 'normal' | 'bold') => void;
|
|
311
|
+
addItem: (item: CanvasItem) => void;
|
|
312
|
+
updateItem: (id: string, patch: Partial<CanvasItem>) => void;
|
|
313
|
+
removeItem: (id: string) => void;
|
|
314
|
+
deleteSelected: () => void;
|
|
315
|
+
clearAll: () => void;
|
|
316
|
+
clear: () => void;
|
|
317
|
+
deleteItem: (id: string) => void;
|
|
318
|
+
setTool: (tool: CanvasTool) => void;
|
|
319
|
+
selectItem: (id: string | null) => void;
|
|
320
|
+
undo: () => void;
|
|
321
|
+
redo: () => void;
|
|
322
|
+
canUndo: boolean;
|
|
323
|
+
canRedo: boolean;
|
|
324
|
+
notifyChangeComplete: (targetItem?: CanvasItem | null) => void;
|
|
325
|
+
exportJSON: () => string;
|
|
326
|
+
importJSON: (json: string) => boolean;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
declare const TOOL_TO_ARROW_STYLE: Record<string, ArrowStyle | undefined>;
|
|
330
|
+
declare const STROKE_COLORS: readonly ["#000000", "#4b5563", "#2563eb", "#dc2626", "#16a34a", "#d97706", "#9333ea", "#0891b2"];
|
|
331
|
+
interface NoteColorTheme {
|
|
332
|
+
name: string;
|
|
333
|
+
bg: string;
|
|
334
|
+
border: string;
|
|
335
|
+
header: string;
|
|
336
|
+
text: string;
|
|
337
|
+
}
|
|
338
|
+
declare const NOTE_COLOR_THEMES: readonly NoteColorTheme[];
|
|
339
|
+
declare const DEFAULT_STROKE_COLOR = "#000000";
|
|
340
|
+
declare const DEFAULT_STROKE_WIDTH = 2;
|
|
341
|
+
declare const DEFAULT_STROKE_WIDTH_OPTIONS: readonly number[];
|
|
342
|
+
declare const STROKE_WIDTH_OPTIONS: readonly number[];
|
|
343
|
+
declare const DEFAULT_NOTE_BG = "#fef9c3";
|
|
344
|
+
declare const DEFAULT_NOTE_TEXT = "#422006";
|
|
345
|
+
declare const DEFAULT_FONT_SIZE = 16;
|
|
346
|
+
declare const DEFAULT_FONT_SIZE_OPTIONS: readonly number[];
|
|
347
|
+
declare const FONT_SIZE_OPTIONS: readonly number[];
|
|
348
|
+
/**
|
|
349
|
+
* Super simple unified annotation default theme matching basic HTML element appearance.
|
|
350
|
+
*/
|
|
351
|
+
declare const DEFAULT_ANNOTATION_THEME: Readonly<CanvasAnnotationTheme>;
|
|
352
|
+
|
|
353
|
+
declare function createId(prefix?: string): string;
|
|
354
|
+
declare function geoToScreen(map: L.Map, point: GeoPoint): ScreenPoint;
|
|
355
|
+
declare function screenToGeo(map: L.Map, point: ScreenPoint): GeoPoint;
|
|
356
|
+
declare function constrainToAspectRatio(anchor: ScreenPoint, target: ScreenPoint, aspectRatio?: number): ScreenPoint;
|
|
357
|
+
declare function constrainAngleTo45Degrees(anchor: ScreenPoint, target: ScreenPoint): ScreenPoint;
|
|
358
|
+
declare function computeDefaultControlGeoPoint(start: GeoPoint, end: GeoPoint, curvature?: number): GeoPoint;
|
|
359
|
+
declare function getQuadraticBezierPoint(p0: ScreenPoint, p1: ScreenPoint, p2: ScreenPoint, t: number): ScreenPoint;
|
|
360
|
+
declare function getQuadraticEndAngle(p0: ScreenPoint, p1: ScreenPoint, p2: ScreenPoint): number;
|
|
361
|
+
declare function distanceToSegment(p: ScreenPoint, v: ScreenPoint, w: ScreenPoint): number;
|
|
362
|
+
declare function distanceToQuadraticBezier(p: ScreenPoint, p0: ScreenPoint, p1: ScreenPoint, p2: ScreenPoint, steps?: number): number;
|
|
363
|
+
declare function getMapDimensions(map: L.Map | null | undefined): {
|
|
364
|
+
width: number;
|
|
365
|
+
height: number;
|
|
366
|
+
} | null;
|
|
367
|
+
declare function truncateCanvasText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string;
|
|
368
|
+
declare function calculateZoomFontSize(initialFontSize: number | undefined, currentZoom: number | null, baseZoom?: number, options?: {
|
|
369
|
+
min?: number;
|
|
370
|
+
max?: number;
|
|
371
|
+
scaleFactor?: number;
|
|
372
|
+
}): number;
|
|
373
|
+
declare function calculateGeodesicDistance(p1: GeoPoint, p2: GeoPoint): number;
|
|
374
|
+
declare function formatRealWorldDistance(meters: number, unit?: 'metric' | 'imperial'): string;
|
|
375
|
+
declare function calculateLineDistance(points: GeoPoint[]): number;
|
|
376
|
+
|
|
377
|
+
declare function drawCanvasHandle(ctx: CanvasRenderingContext2D, pt: ScreenPoint, strokeColor: string, fillColor: string, radius: number, strokeWidth?: number): void;
|
|
378
|
+
declare function drawCanvasLabelPill(ctx: CanvasRenderingContext2D, label: string, midX: number, midY: number, strokeColor: string, maxAllowedBoxWidth: number, theme?: CanvasAnnotationTheme): void;
|
|
379
|
+
|
|
380
|
+
type ArrowHandleType = 'start' | 'end' | 'control';
|
|
381
|
+
interface ProjectedArrow {
|
|
382
|
+
start: ScreenPoint;
|
|
383
|
+
end: ScreenPoint;
|
|
384
|
+
control: ScreenPoint;
|
|
385
|
+
}
|
|
386
|
+
declare function projectArrow(map: L.Map, arrow: ArrowItem): ProjectedArrow;
|
|
387
|
+
declare function renderArrowOnCanvas(ctx: CanvasRenderingContext2D, projected: ProjectedArrow, arrow: Pick<ArrowItem, 'arrowStyle' | 'color' | 'strokeWidth' | 'dashed' | 'headStyle' | 'label'>, options?: {
|
|
388
|
+
isSelected?: boolean;
|
|
389
|
+
isPreview?: boolean;
|
|
390
|
+
theme?: ArrowRenderTheme;
|
|
391
|
+
}): void;
|
|
392
|
+
declare function hitTestArrowHandle(point: ScreenPoint, projected: ProjectedArrow, arrow: ArrowItem, tolerance?: number): ArrowHandleType | null;
|
|
393
|
+
declare function hitTestArrow(point: ScreenPoint, projected: ProjectedArrow, arrow: ArrowItem, tolerance?: number): boolean;
|
|
394
|
+
|
|
395
|
+
declare function drawArrowHead(ctx: CanvasRenderingContext2D, tip: ScreenPoint, angle: number, size: number, color: string, filled?: boolean): void;
|
|
396
|
+
declare function traceArrowPath(ctx: CanvasRenderingContext2D, projected: ProjectedArrow, arrowStyle: ArrowItem['arrowStyle']): void;
|
|
397
|
+
|
|
398
|
+
declare function projectFreeDraw(map: L.Map, item: Pick<FreeDrawItem, 'points'>): ScreenPoint[];
|
|
399
|
+
declare function renderFreeDrawOnCanvas(ctx: CanvasRenderingContext2D, screenPoints: ScreenPoint[], item: Pick<FreeDrawItem, 'color' | 'strokeWidth' | 'dashed'>, options?: {
|
|
400
|
+
isSelected?: boolean;
|
|
401
|
+
isPreview?: boolean;
|
|
402
|
+
theme?: CanvasAnnotationTheme;
|
|
403
|
+
}): void;
|
|
404
|
+
declare function hitTestFreeDraw(point: ScreenPoint, screenPoints: ScreenPoint[], item: FreeDrawItem, tolerance?: number): boolean;
|
|
405
|
+
|
|
406
|
+
type ShapeHandleType = 'start' | 'end';
|
|
407
|
+
interface ProjectedShape {
|
|
408
|
+
start: ScreenPoint;
|
|
409
|
+
end: ScreenPoint;
|
|
410
|
+
minX: number;
|
|
411
|
+
minY: number;
|
|
412
|
+
maxX: number;
|
|
413
|
+
maxY: number;
|
|
414
|
+
width: number;
|
|
415
|
+
height: number;
|
|
416
|
+
cx: number;
|
|
417
|
+
cy: number;
|
|
418
|
+
}
|
|
419
|
+
declare function projectShape(map: L.Map, shape: ShapeItem): ProjectedShape;
|
|
420
|
+
declare function renderShapeOnCanvas(ctx: CanvasRenderingContext2D, projected: ProjectedShape, shape: Pick<ShapeItem, 'shape' | 'color' | 'fillColor' | 'filled' | 'strokeWidth' | 'dashed' | 'label'>, options?: {
|
|
421
|
+
isSelected?: boolean;
|
|
422
|
+
isPreview?: boolean;
|
|
423
|
+
theme?: CanvasAnnotationTheme;
|
|
424
|
+
}): void;
|
|
425
|
+
declare function hitTestShapeHandle(point: ScreenPoint, projected: ProjectedShape, tolerance?: number): ShapeHandleType | null;
|
|
426
|
+
declare function hitTestShape(point: ScreenPoint, projected: ProjectedShape, tolerance?: number): boolean;
|
|
427
|
+
|
|
428
|
+
declare function tracePolygonShape(ctx: CanvasRenderingContext2D, proj: ProjectedShape, kind: ShapeKind, theme?: CanvasAnnotationTheme): void;
|
|
429
|
+
|
|
430
|
+
type RulerHandleType = 'start' | 'end';
|
|
431
|
+
interface ProjectedRuler {
|
|
432
|
+
start: ScreenPoint;
|
|
433
|
+
end: ScreenPoint;
|
|
434
|
+
mid: ScreenPoint;
|
|
435
|
+
lengthPx: number;
|
|
436
|
+
angle: number;
|
|
437
|
+
}
|
|
438
|
+
declare function projectRuler(map: L.Map, ruler: Pick<RulerItem, 'start' | 'end'>): ProjectedRuler;
|
|
439
|
+
declare function renderRulerOnCanvas(ctx: CanvasRenderingContext2D, projected: ProjectedRuler, ruler: Pick<RulerItem, 'start' | 'end' | 'color' | 'strokeWidth' | 'dashed' | 'label' | 'unit'>, options?: {
|
|
440
|
+
isSelected?: boolean;
|
|
441
|
+
isPreview?: boolean;
|
|
442
|
+
theme?: CanvasAnnotationTheme;
|
|
443
|
+
}): void;
|
|
444
|
+
declare function hitTestRulerHandle(point: ScreenPoint, projected: ProjectedRuler, tolerance?: number): RulerHandleType | null;
|
|
445
|
+
declare function hitTestRuler(point: ScreenPoint, projected: ProjectedRuler, ruler: RulerItem, tolerance?: number): boolean;
|
|
446
|
+
|
|
447
|
+
interface ResolvedNoteTheme {
|
|
448
|
+
name: string;
|
|
449
|
+
bg: string;
|
|
450
|
+
border: string;
|
|
451
|
+
header: string;
|
|
452
|
+
text: string;
|
|
453
|
+
}
|
|
454
|
+
declare function resolveNoteTheme(backgroundColor: string): ResolvedNoteTheme;
|
|
455
|
+
declare function clampNotePosition(map: L.Map, screenPos: ScreenPoint, item: NoteItem, isCompact: boolean, isDragging: boolean, clampToViewport?: boolean): ScreenPoint;
|
|
456
|
+
|
|
457
|
+
declare function clampTextPosition(map: L.Map, screenPos: ScreenPoint, item: TextItem, dynamicFontSize: number, isCompact: boolean, isDragging: boolean, clampToViewport?: boolean): ScreenPoint;
|
|
458
|
+
|
|
459
|
+
declare function startFreeDrawDrag(map: L.Map, mapContainer: HTMLElement, pt: ScreenPoint, geo: GeoPoint, activeColor: string, strokeWidth: number, dashed: boolean, draftFreeDrawRef: {
|
|
460
|
+
current: {
|
|
461
|
+
screenPoints: ScreenPoint[];
|
|
462
|
+
geoPoints: GeoPoint[];
|
|
463
|
+
} | null;
|
|
464
|
+
}, rafIdRef: {
|
|
465
|
+
current: number | null;
|
|
466
|
+
}, paintCanvas: () => void, addItem: (item: FreeDrawItem) => void, setActiveTool: (tool: 'select') => void): void;
|
|
467
|
+
|
|
468
|
+
declare function createDraftNote(geo: GeoPoint, noteColor: string, defaultTitle?: string): NoteItem;
|
|
469
|
+
declare function createDraftText(geo: GeoPoint, activeColor: string, fontSize: number, fontWeight: 'normal' | 'bold', currentZoom: number): TextItem;
|
|
470
|
+
|
|
471
|
+
declare function startShapeDrag(map: L.Map, mapContainer: HTMLElement, startScreen: ScreenPoint, startGeo: GeoPoint, activeShape: ShapeKind, activeColor: string, shapeFilled: boolean, strokeWidth: number, dashed: boolean, setDraftShape: (draft: DraftShapeState | null) => void, addItem: (item: ShapeItem) => void, setActiveTool: (tool: 'select') => void): void;
|
|
472
|
+
declare function buildArrowItem(arrowStyle: ArrowStyle, startGeo: GeoPoint, endGeo: GeoPoint, activeColor: string, strokeWidth: number, dashed: boolean): ArrowItem;
|
|
473
|
+
declare function startArrowDrag(map: L.Map, mapContainer: HTMLElement, startScreen: ScreenPoint, startGeo: GeoPoint, arrowStyle: ArrowStyle, activeColor: string, strokeWidth: number, dashed: boolean, setDraftArrow: (draft: DraftArrowState | null) => void, addItem: (item: ArrowItem) => void, setActiveTool: (tool: 'select') => void): void;
|
|
474
|
+
declare function buildRulerItem(startGeo: GeoPoint, endGeo: GeoPoint, activeColor: string, strokeWidth: number, dashed: boolean): RulerItem;
|
|
475
|
+
declare function startRulerDrag(map: L.Map, mapContainer: HTMLElement, startScreen: ScreenPoint, startGeo: GeoPoint, activeColor: string, strokeWidth: number, dashed: boolean, setDraftRuler: (draft: DraftRulerState | null) => void, addItem: (item: RulerItem) => void, setActiveTool: (tool: 'select') => void): void;
|
|
476
|
+
|
|
477
|
+
declare function startArrowHandleDrag(map: L.Map, arrow: ArrowItem, projected: ProjectedArrow, handle: ArrowHandleType, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<ArrowItem>) => void): void;
|
|
478
|
+
declare function startShapeHandleDrag(map: L.Map, shape: ShapeItem, projected: ProjectedShape, handle: ShapeHandleType, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<ShapeItem>) => void): void;
|
|
479
|
+
declare function startArrowBodyDrag(map: L.Map, arrow: ArrowItem, projected: ProjectedArrow, originPt: ScreenPoint, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<ArrowItem>) => void): void;
|
|
480
|
+
declare function startShapeBodyDrag(map: L.Map, shape: ShapeItem, projected: ProjectedShape, originPt: ScreenPoint, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<ShapeItem>) => void): void;
|
|
481
|
+
declare function startFreeDrawBodyDrag(map: L.Map, fd: FreeDrawItem, initialScreenPts: ScreenPoint[], originPt: ScreenPoint, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<FreeDrawItem>) => void): void;
|
|
482
|
+
declare function startRulerHandleDrag(map: L.Map, ruler: RulerItem, projected: ProjectedRuler, handle: RulerHandleType, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<RulerItem>) => void): void;
|
|
483
|
+
declare function startRulerBodyDrag(map: L.Map, ruler: RulerItem, projected: ProjectedRuler, originPt: ScreenPoint, getLocalPoint: (e: PointerEvent) => ScreenPoint, updateItem: (id: string, patch: Partial<RulerItem>) => void): void;
|
|
484
|
+
|
|
485
|
+
interface PaintLeafletCanvasOptions {
|
|
486
|
+
map: L.Map | null;
|
|
487
|
+
canvas: HTMLCanvasElement | null;
|
|
488
|
+
width: number;
|
|
489
|
+
height: number;
|
|
490
|
+
arrowItems: ArrowItem[];
|
|
491
|
+
shapeItems: ShapeItem[];
|
|
492
|
+
freeDrawItems: FreeDrawItem[];
|
|
493
|
+
rulerItems: RulerItem[];
|
|
494
|
+
selectedId: string | null;
|
|
495
|
+
draftShape: DraftShapeState | null;
|
|
496
|
+
draftArrow: DraftArrowState | null;
|
|
497
|
+
draftRuler?: DraftRulerState | null;
|
|
498
|
+
draftFreeDraw?: {
|
|
499
|
+
screenPoints: ScreenPoint[];
|
|
500
|
+
geoPoints: GeoPoint[];
|
|
501
|
+
} | null;
|
|
502
|
+
activeColor: string;
|
|
503
|
+
strokeWidth: number;
|
|
504
|
+
dashed: boolean;
|
|
505
|
+
shapeFilled: boolean;
|
|
506
|
+
annotationTheme?: CanvasAnnotationTheme;
|
|
507
|
+
arrowTheme?: ArrowRenderTheme;
|
|
508
|
+
isReadOnly: boolean;
|
|
509
|
+
}
|
|
510
|
+
declare function paintLeafletCanvas({ map, canvas, width, height, arrowItems, shapeItems, freeDrawItems, rulerItems, selectedId, draftShape, draftArrow, draftRuler, draftFreeDraw, activeColor, strokeWidth, dashed, shapeFilled, annotationTheme, arrowTheme, isReadOnly, }: PaintLeafletCanvasOptions): void;
|
|
511
|
+
|
|
512
|
+
interface MapViewportDimensions {
|
|
513
|
+
width: number;
|
|
514
|
+
height: number;
|
|
515
|
+
}
|
|
516
|
+
declare function bindLeafletSync(map: L.Map, onSync: (dimensions: MapViewportDimensions) => void): () => void;
|
|
517
|
+
declare function bindBlockMapDblClick(map: L.Map): () => void;
|
|
518
|
+
|
|
519
|
+
interface LeafletCanvasStore extends LeafletCanvasController {
|
|
520
|
+
subscribe: (listener: (controller: LeafletCanvasController) => void) => () => void;
|
|
521
|
+
getState: () => LeafletCanvasController;
|
|
522
|
+
destroy: () => void;
|
|
523
|
+
}
|
|
524
|
+
declare function createLeafletCanvasController(options?: UseLeafletCanvasOptions): LeafletCanvasStore;
|
|
525
|
+
declare const createLeafletTualController: typeof createLeafletCanvasController;
|
|
526
|
+
|
|
527
|
+
interface CreateLeafletCanvasOptions extends UseLeafletCanvasOptions {
|
|
528
|
+
controller?: LeafletCanvasStore;
|
|
529
|
+
annotationTheme?: CanvasAnnotationTheme;
|
|
530
|
+
arrowTheme?: ArrowRenderTheme;
|
|
531
|
+
labels?: CanvasLabels;
|
|
532
|
+
}
|
|
533
|
+
interface LeafletCanvasInstance {
|
|
534
|
+
controller: LeafletCanvasStore;
|
|
535
|
+
container: HTMLDivElement;
|
|
536
|
+
canvas: HTMLCanvasElement;
|
|
537
|
+
repaint: () => void;
|
|
538
|
+
destroy: () => void;
|
|
539
|
+
}
|
|
540
|
+
declare function createLeafletCanvas(map: L.Map, options?: CreateLeafletCanvasOptions): LeafletCanvasInstance;
|
|
541
|
+
declare const createLeafletTual: typeof createLeafletCanvas;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* leaflet-tual — core (framework-agnostic)
|
|
545
|
+
*
|
|
546
|
+
* Interactive canvas and annotation toolkit for Leaflet maps — draw vector
|
|
547
|
+
* arrows, geometric shapes, freehand sketches, rulers, sticky notes, and text
|
|
548
|
+
* overlays that stay geographically synchronized with Leaflet across panning
|
|
549
|
+
* and zooming.
|
|
550
|
+
*
|
|
551
|
+
* This module is the entire framework-agnostic public surface. It has zero
|
|
552
|
+
* dependency on React or any UI framework, so it can be used directly from
|
|
553
|
+
* vanilla JavaScript, TypeScript, Vue, Svelte, Angular, or a plain `<script>` tag.
|
|
554
|
+
*
|
|
555
|
+
* React users: see `leaflet-tual/react` for `<LeafletCanvas>`, `<CanvasToolbar>`,
|
|
556
|
+
* `useLeafletCanvas`, and `useLeafletSync`.
|
|
557
|
+
*/
|
|
558
|
+
|
|
559
|
+
declare const VERSION: string;
|
|
560
|
+
|
|
561
|
+
interface CanvasIcons {
|
|
562
|
+
select?: React__default.ReactNode;
|
|
563
|
+
freedraw?: React__default.ReactNode;
|
|
564
|
+
arrowGroup?: React__default.ReactNode;
|
|
565
|
+
arrowLinear?: React__default.ReactNode;
|
|
566
|
+
arrowCurved?: React__default.ReactNode;
|
|
567
|
+
arrowBi?: React__default.ReactNode;
|
|
568
|
+
arrowElbow?: React__default.ReactNode;
|
|
569
|
+
arrowSCurve?: React__default.ReactNode;
|
|
570
|
+
shapesGroup?: React__default.ReactNode;
|
|
571
|
+
shapeSquare?: React__default.ReactNode;
|
|
572
|
+
shapeCircle?: React__default.ReactNode;
|
|
573
|
+
shapeStar?: React__default.ReactNode;
|
|
574
|
+
shapeActor?: React__default.ReactNode;
|
|
575
|
+
shapeTriangle?: React__default.ReactNode;
|
|
576
|
+
shapeDiamond?: React__default.ReactNode;
|
|
577
|
+
shapeHexagon?: React__default.ReactNode;
|
|
578
|
+
shapeMarker?: React__default.ReactNode;
|
|
579
|
+
dropdownChevron?: React__default.ReactNode;
|
|
580
|
+
ruler?: React__default.ReactNode;
|
|
581
|
+
note?: React__default.ReactNode;
|
|
582
|
+
text?: React__default.ReactNode;
|
|
583
|
+
undo?: React__default.ReactNode;
|
|
584
|
+
redo?: React__default.ReactNode;
|
|
585
|
+
delete?: React__default.ReactNode;
|
|
586
|
+
clear?: React__default.ReactNode;
|
|
587
|
+
noteExpand?: React__default.ReactNode;
|
|
588
|
+
noteCollapse?: React__default.ReactNode;
|
|
589
|
+
noteCompact?: React__default.ReactNode;
|
|
590
|
+
noteDelete?: React__default.ReactNode;
|
|
591
|
+
noteResize?: React__default.ReactNode;
|
|
592
|
+
textEdit?: React__default.ReactNode;
|
|
593
|
+
textDone?: React__default.ReactNode;
|
|
594
|
+
textBold?: React__default.ReactNode;
|
|
595
|
+
textDecreaseSize?: React__default.ReactNode;
|
|
596
|
+
textIncreaseSize?: React__default.ReactNode;
|
|
597
|
+
textDelete?: React__default.ReactNode;
|
|
598
|
+
collapseToolbar?: React__default.ReactNode;
|
|
599
|
+
expandToolbar?: React__default.ReactNode;
|
|
600
|
+
}
|
|
601
|
+
type LeafletCanvasStyles = {
|
|
602
|
+
[K in keyof LeafletCanvasClassNames]?: React__default.CSSProperties;
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
interface CustomToolbarItem {
|
|
606
|
+
id: string;
|
|
607
|
+
label?: string;
|
|
608
|
+
title?: string;
|
|
609
|
+
icon?: React__default.ReactNode;
|
|
610
|
+
isActive?: boolean;
|
|
611
|
+
disabled?: boolean;
|
|
612
|
+
onClick?: (controller: LeafletCanvasController) => void;
|
|
613
|
+
render?: (controller: LeafletCanvasController) => React__default.ReactNode;
|
|
614
|
+
}
|
|
615
|
+
interface DragHandleTriggerProps {
|
|
616
|
+
onPointerDown: (e: React__default.PointerEvent<HTMLElement>) => void;
|
|
617
|
+
style: React__default.CSSProperties;
|
|
618
|
+
}
|
|
619
|
+
interface RenderNoteProps {
|
|
620
|
+
item: NoteItem;
|
|
621
|
+
screenPos: ScreenPoint;
|
|
622
|
+
isSelected: boolean;
|
|
623
|
+
isDragging: boolean;
|
|
624
|
+
readOnly?: boolean;
|
|
625
|
+
isCompact?: boolean;
|
|
626
|
+
dragHandleProps: DragHandleTriggerProps;
|
|
627
|
+
resizeHandleProps?: DragHandleTriggerProps;
|
|
628
|
+
onSelect: () => void;
|
|
629
|
+
onUpdate: (patch: Partial<NoteItem>) => void;
|
|
630
|
+
onDelete: () => void;
|
|
631
|
+
}
|
|
632
|
+
interface RenderTextProps {
|
|
633
|
+
item: TextItem;
|
|
634
|
+
screenPos: ScreenPoint;
|
|
635
|
+
isSelected: boolean;
|
|
636
|
+
isEditing: boolean;
|
|
637
|
+
isDragging: boolean;
|
|
638
|
+
readOnly?: boolean;
|
|
639
|
+
isCompact?: boolean;
|
|
640
|
+
dynamicFontSize?: number;
|
|
641
|
+
setIsEditing: (editing: boolean) => void;
|
|
642
|
+
dragHandleProps: DragHandleTriggerProps;
|
|
643
|
+
onSelect: () => void;
|
|
644
|
+
onUpdate: (patch: Partial<TextItem>) => void;
|
|
645
|
+
onDelete: () => void;
|
|
646
|
+
}
|
|
647
|
+
interface LeafletCanvasProps extends UseLeafletCanvasOptions {
|
|
648
|
+
map?: L.Map | null;
|
|
649
|
+
controller?: LeafletCanvasController;
|
|
650
|
+
readOnly?: boolean;
|
|
651
|
+
showToolbar?: boolean;
|
|
652
|
+
toolbarPosition?: ToolbarPosition;
|
|
653
|
+
toolbarOrientation?: ToolbarOrientation;
|
|
654
|
+
orientation?: ToolbarOrientation;
|
|
655
|
+
collapsible?: boolean;
|
|
656
|
+
defaultCollapsed?: boolean;
|
|
657
|
+
collapsed?: boolean;
|
|
658
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
659
|
+
showCollapseButton?: boolean;
|
|
660
|
+
enabledTools?: readonly ToolbarToolGroupId[];
|
|
661
|
+
customTools?: readonly CustomToolbarItem[];
|
|
662
|
+
showHistoryControls?: boolean;
|
|
663
|
+
showDeleteButton?: boolean;
|
|
664
|
+
showClearButton?: boolean;
|
|
665
|
+
showToolLabels?: boolean;
|
|
666
|
+
labels?: CanvasLabels;
|
|
667
|
+
icons?: CanvasIcons;
|
|
668
|
+
unstyled?: boolean;
|
|
669
|
+
classNames?: LeafletCanvasClassNames;
|
|
670
|
+
styles?: LeafletCanvasStyles;
|
|
671
|
+
annotationTheme?: CanvasAnnotationTheme;
|
|
672
|
+
arrowTheme?: ArrowRenderTheme;
|
|
673
|
+
strokeColors?: readonly string[];
|
|
674
|
+
strokeWidthOptions?: readonly number[];
|
|
675
|
+
fontSizeOptions?: readonly number[];
|
|
676
|
+
renderToolbar?: (controller: LeafletCanvasController) => React__default.ReactNode;
|
|
677
|
+
renderNote?: (props: RenderNoteProps) => React__default.ReactNode;
|
|
678
|
+
renderText?: (props: RenderTextProps) => React__default.ReactNode;
|
|
679
|
+
clampOverlaysToViewport?: boolean;
|
|
680
|
+
autoMinimizeNotesZoom?: number;
|
|
681
|
+
autoMinimizeTextZoom?: number;
|
|
682
|
+
className?: string;
|
|
683
|
+
style?: React__default.CSSProperties;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
interface InlineShapeLabelEditorProps {
|
|
687
|
+
shape: ShapeItem;
|
|
688
|
+
map: L.Map;
|
|
689
|
+
labels?: CanvasLabels;
|
|
690
|
+
onUpdate: (id: string, patch: Partial<ShapeItem>) => void;
|
|
691
|
+
onClose: () => void;
|
|
692
|
+
}
|
|
693
|
+
declare function InlineShapeLabelEditor({ shape, map, labels, onUpdate, onClose, }: InlineShapeLabelEditorProps): React.JSX.Element;
|
|
694
|
+
|
|
695
|
+
interface NoteOverlayProps {
|
|
696
|
+
item: NoteItem;
|
|
697
|
+
screenPos: ScreenPoint;
|
|
698
|
+
isSelected: boolean;
|
|
699
|
+
map: L.Map;
|
|
700
|
+
readOnly?: boolean;
|
|
701
|
+
labels?: CanvasLabels;
|
|
702
|
+
icons?: CanvasIcons;
|
|
703
|
+
unstyled?: boolean;
|
|
704
|
+
classNames?: LeafletCanvasClassNames;
|
|
705
|
+
styles?: LeafletCanvasStyles;
|
|
706
|
+
clampToViewport?: boolean;
|
|
707
|
+
autoMinimizeZoomThreshold?: number;
|
|
708
|
+
renderNote?: (props: RenderNoteProps) => React__default.ReactNode;
|
|
709
|
+
onSelect: (id: string) => void;
|
|
710
|
+
onUpdate: (id: string, patch: Partial<NoteItem>) => void;
|
|
711
|
+
onDelete: (id: string) => void;
|
|
712
|
+
onComplete?: () => void;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
declare const NoteOverlay: React__default.NamedExoticComponent<NoteOverlayProps>;
|
|
716
|
+
|
|
717
|
+
interface TextOverlayProps {
|
|
718
|
+
item: TextItem;
|
|
719
|
+
screenPos: ScreenPoint;
|
|
720
|
+
isSelected: boolean;
|
|
721
|
+
isEditingLabel?: boolean;
|
|
722
|
+
map: L.Map;
|
|
723
|
+
readOnly?: boolean;
|
|
724
|
+
labels?: CanvasLabels;
|
|
725
|
+
icons?: CanvasIcons;
|
|
726
|
+
unstyled?: boolean;
|
|
727
|
+
classNames?: LeafletCanvasClassNames;
|
|
728
|
+
styles?: LeafletCanvasStyles;
|
|
729
|
+
clampToViewport?: boolean;
|
|
730
|
+
autoMinimizeZoomThreshold?: number;
|
|
731
|
+
renderText?: (props: RenderTextProps) => React__default.ReactNode;
|
|
732
|
+
onSelect: (id: string) => void;
|
|
733
|
+
onUpdate: (id: string, patch: Partial<TextItem>) => void;
|
|
734
|
+
onDelete: (id: string) => void;
|
|
735
|
+
onComplete?: () => void;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
declare const TextOverlay: React__default.NamedExoticComponent<TextOverlayProps>;
|
|
739
|
+
|
|
740
|
+
interface MapViewportState {
|
|
741
|
+
width: number;
|
|
742
|
+
height: number;
|
|
743
|
+
tick: number;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Synchronizes React state and canvas redraws with a Leaflet map's pan, zoom, and resize events.
|
|
747
|
+
*/
|
|
748
|
+
declare function useLeafletSync(map: L.Map | null): MapViewportState;
|
|
749
|
+
|
|
750
|
+
declare function useLeafletCanvas(options?: UseLeafletCanvasOptions): LeafletCanvasController;
|
|
751
|
+
declare const useLeafletTual: typeof useLeafletCanvas;
|
|
752
|
+
|
|
753
|
+
interface CanvasToolbarProps {
|
|
754
|
+
controller: LeafletCanvasController;
|
|
755
|
+
position?: ToolbarPosition;
|
|
756
|
+
orientation?: ToolbarOrientation;
|
|
757
|
+
collapsible?: boolean;
|
|
758
|
+
defaultCollapsed?: boolean;
|
|
759
|
+
collapsed?: boolean;
|
|
760
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
761
|
+
showCollapseButton?: boolean;
|
|
762
|
+
readOnly?: boolean;
|
|
763
|
+
enabledTools?: readonly ToolbarToolGroupId[];
|
|
764
|
+
customTools?: readonly CustomToolbarItem[];
|
|
765
|
+
showHistoryControls?: boolean;
|
|
766
|
+
showDeleteButton?: boolean;
|
|
767
|
+
showClearButton?: boolean;
|
|
768
|
+
showToolLabels?: boolean;
|
|
769
|
+
labels?: CanvasLabels;
|
|
770
|
+
icons?: CanvasIcons;
|
|
771
|
+
unstyled?: boolean;
|
|
772
|
+
classNames?: LeafletCanvasClassNames;
|
|
773
|
+
styles?: LeafletCanvasStyles;
|
|
774
|
+
strokeColors?: readonly string[];
|
|
775
|
+
strokeWidthOptions?: readonly number[];
|
|
776
|
+
fontSizeOptions?: readonly number[];
|
|
777
|
+
className?: string;
|
|
778
|
+
style?: React__default.CSSProperties;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
declare function CanvasToolbar({ controller, position, orientation: propOrientation, collapsible, defaultCollapsed, collapsed: propCollapsed, onCollapsedChange, showCollapseButton, readOnly: propReadOnly, enabledTools, customTools, showHistoryControls, showDeleteButton, showClearButton, showToolLabels: explicitShowToolLabels, labels, icons, unstyled, classNames, styles, strokeColors, strokeWidthOptions, fontSizeOptions, className, style, }: CanvasToolbarProps): React.JSX.Element;
|
|
782
|
+
|
|
783
|
+
interface PixelSelectProps {
|
|
784
|
+
/** Visible label and accessible name. */
|
|
785
|
+
label: string;
|
|
786
|
+
/** Currently applied value in pixels. */
|
|
787
|
+
value: number;
|
|
788
|
+
/** Preset pixel values. The current value is merged in if missing. */
|
|
789
|
+
options: readonly number[];
|
|
790
|
+
onChange: (value: number) => void;
|
|
791
|
+
/** Optional data attribute to distinguish multiple selects. */
|
|
792
|
+
control?: string;
|
|
793
|
+
unstyled?: boolean;
|
|
794
|
+
classNames?: LeafletCanvasClassNames;
|
|
795
|
+
styles?: LeafletCanvasStyles;
|
|
796
|
+
icons?: CanvasIcons;
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Labeled `<select>` listing pixel values (e.g. `1px`, `2px`, ...).
|
|
800
|
+
* Styled via the `toolbarSelect` slot and `rlc-toolbar-select` class.
|
|
801
|
+
*/
|
|
802
|
+
declare function PixelSelect({ label, value, options, onChange, control, unstyled, classNames, styles, icons, }: PixelSelectProps): React.JSX.Element;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Returns rotation transform for dropdown indicator chevron (base shape: points down `v`).
|
|
806
|
+
* When closed: points towards the opening direction.
|
|
807
|
+
* When open: flips 180 degrees.
|
|
808
|
+
*/
|
|
809
|
+
declare function getDropdownChevronRotation(isOpen: boolean, position?: ToolbarPosition, orientation?: ToolbarOrientation): string;
|
|
810
|
+
/**
|
|
811
|
+
* Returns rotation transform for collapse button chevron (base shape: points up `^`).
|
|
812
|
+
* Points towards the screen edge the toolbar collapses into.
|
|
813
|
+
*/
|
|
814
|
+
declare function getCollapseChevronRotation(position?: ToolbarPosition, orientation?: ToolbarOrientation): string;
|
|
815
|
+
/**
|
|
816
|
+
* Returns rotation transform for expand button chevron (base shape: points down `v`).
|
|
817
|
+
* Points towards the map interior where the toolbar will expand into.
|
|
818
|
+
*/
|
|
819
|
+
declare function getExpandChevronRotation(position?: ToolbarPosition, orientation?: ToolbarOrientation): string;
|
|
820
|
+
|
|
821
|
+
declare function LeafletCanvas(props: LeafletCanvasProps): React.JSX.Element;
|
|
822
|
+
|
|
823
|
+
export { type ArrowHandleType, type ArrowHeadStyle, type ArrowItem, type ArrowRenderTheme, type ArrowStyle, type CanvasAnnotationTheme, type CanvasIcons, type CanvasItem, type CanvasLabels, type CanvasOverlayOptions, type CanvasTool, CanvasToolbar, type CanvasToolbarProps, type CreateLeafletCanvasOptions, type CustomToolbarItem, DEFAULT_ANNOTATION_THEME, DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE_OPTIONS, DEFAULT_NOTE_BG, DEFAULT_NOTE_TEXT, DEFAULT_STROKE_COLOR, DEFAULT_STROKE_WIDTH, DEFAULT_STROKE_WIDTH_OPTIONS, type DraftArrowState, type DraftRulerState, type DraftShapeState, type DragHandleTriggerProps, FONT_SIZE_OPTIONS, type FreeDrawItem, type GeoPoint, InlineShapeLabelEditor, type InlineShapeLabelEditorProps, LeafletCanvas, type LeafletCanvasClassNames, type LeafletCanvasController, type LeafletCanvasInstance, type LeafletCanvasOptions, type LeafletCanvasProps, type LeafletCanvasStore, type LeafletCanvasStyles, type MapViewportDimensions, type MapViewportState, NOTE_COLOR_THEMES, type NoteCollapseState, type NoteColorTheme, type NoteItem, NoteOverlay, type NoteOverlayProps, type PaintLeafletCanvasOptions, PixelSelect, type PixelSelectProps, type ProjectedArrow, type ProjectedRuler, type ProjectedShape, type RenderNoteProps, type RenderTextProps, type ResolvedNoteTheme, type RulerHandleType, type RulerItem, STROKE_COLORS, STROKE_WIDTH_OPTIONS, type ScreenPoint, type ShapeHandleType, type ShapeItem, type ShapeKind, TOOL_TO_ARROW_STYLE, type TextItem, TextOverlay, type TextOverlayProps, type ToolbarOrientation, type ToolbarPosition, type ToolbarToolGroupId, type UseLeafletCanvasOptions, VERSION, bindBlockMapDblClick, bindLeafletSync, buildArrowItem, buildRulerItem, calculateGeodesicDistance, calculateLineDistance, calculateZoomFontSize, clampNotePosition, clampTextPosition, computeDefaultControlGeoPoint, constrainAngleTo45Degrees, constrainToAspectRatio, createDraftNote, createDraftText, createId, createLeafletCanvas, createLeafletCanvasController, createLeafletTual, createLeafletTualController, distanceToQuadraticBezier, distanceToSegment, drawArrowHead, drawCanvasHandle, drawCanvasLabelPill, formatRealWorldDistance, geoToScreen, getCollapseChevronRotation, getDropdownChevronRotation, getExpandChevronRotation, getMapDimensions, getQuadraticBezierPoint, getQuadraticEndAngle, hitTestArrow, hitTestArrowHandle, hitTestFreeDraw, hitTestRuler, hitTestRulerHandle, hitTestShape, hitTestShapeHandle, paintLeafletCanvas, projectArrow, projectFreeDraw, projectRuler, projectShape, renderArrowOnCanvas, renderFreeDrawOnCanvas, renderRulerOnCanvas, renderShapeOnCanvas, resolveNoteTheme, screenToGeo, startArrowBodyDrag, startArrowDrag, startArrowHandleDrag, startFreeDrawBodyDrag, startFreeDrawDrag, startRulerBodyDrag, startRulerDrag, startRulerHandleDrag, startShapeBodyDrag, startShapeDrag, startShapeHandleDrag, traceArrowPath, tracePolygonShape, truncateCanvasText, useLeafletCanvas, useLeafletSync, useLeafletTual };
|