@florasync/leaflet-geokit 0.7.0 → 0.8.1
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/CHANGELOG.md +13 -0
- package/README.md +384 -3
- package/dist/django/index.js +4758 -3546
- package/dist/django/index.js.map +1 -1
- package/dist/leaflet-geokit.es.js +4654 -3442
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +2294 -1082
- package/dist/leaflet-geokit.external.es.js.map +1 -1
- package/dist/leaflet-geokit.umd.js +17 -17
- package/dist/leaflet-geokit.umd.js.map +1 -1
- package/dist/preact/{index-DagV_wwR.js → index-x8CrGR_z.js} +2263 -1051
- package/dist/preact/index-x8CrGR_z.js.map +1 -0
- package/dist/preact/index.js +52 -48
- package/dist/preact/index.js.map +1 -1
- package/dist/preact-bundled/index.js +4808 -3592
- package/dist/preact-bundled/index.js.map +1 -1
- package/dist/react/{index-DagV_wwR.js → index-x8CrGR_z.js} +2263 -1051
- package/dist/react/index-x8CrGR_z.js.map +1 -0
- package/dist/react/index.js +40 -36
- package/dist/react/index.js.map +1 -1
- package/dist/react-bundled/index.js +4809 -3593
- package/dist/react-bundled/index.js.map +1 -1
- package/dist/types/{src/components → components}/LeafletDrawMapElement.d.ts +30 -2
- package/dist/types/{src/django → django}/index.d.ts +2 -2
- package/dist/types/external.d.ts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/{src/lib → lib}/FeatureStore.d.ts +2 -2
- package/dist/types/{src/lib → lib}/MapController.d.ts +50 -3
- package/dist/types/{src/lib → lib}/layer-cake/LayerCakeManager.d.ts +1 -1
- package/dist/types/lib/marker-icons.d.ts +27 -0
- package/dist/types/lib/tool-buttons.d.ts +11 -0
- package/dist/types/{src/preact → preact}/core.d.ts +10 -1
- package/dist/types/{src/preact → preact}/index.d.ts +1 -1
- package/dist/types/{src/preact-bundled → preact-bundled}/index.d.ts +3 -3
- package/dist/types/{src/react → react}/core.d.ts +10 -1
- package/dist/types/{src/react → react}/index.d.ts +1 -1
- package/dist/types/{src/react-bundled → react-bundled}/index.d.ts +3 -3
- package/dist/types/{src/types → types}/public.d.ts +125 -1
- package/package.json +6 -3
- package/dist/preact/index-DagV_wwR.js.map +0 -1
- package/dist/react/index-DagV_wwR.js.map +0 -1
- package/dist/types/e2e/component.spec.d.ts +0 -1
- package/dist/types/e2e/dummy.spec.d.ts +0 -1
- package/dist/types/src/external.d.ts +0 -4
- package/dist/types/src/index.d.ts +0 -4
- package/dist/types/tests/bbox-more.spec.d.ts +0 -1
- package/dist/types/tests/component-api-more.spec.d.ts +0 -1
- package/dist/types/tests/component-branch-coverage.spec.d.ts +0 -1
- package/dist/types/tests/component-delegation.spec.d.ts +0 -1
- package/dist/types/tests/component-events.spec.d.ts +0 -1
- package/dist/types/tests/component-io.spec.d.ts +0 -1
- package/dist/types/tests/component-tile-provider.spec.d.ts +0 -1
- package/dist/types/tests/django-shim.spec.d.ts +0 -1
- package/dist/types/tests/draw-cake.spec.d.ts +0 -1
- package/dist/types/tests/draw-move.spec.d.ts +0 -1
- package/dist/types/tests/eachcoord.spec.d.ts +0 -1
- package/dist/types/tests/element.spec.d.ts +0 -1
- package/dist/types/tests/ensure-element.spec.d.ts +0 -1
- package/dist/types/tests/external-entry.spec.d.ts +0 -1
- package/dist/types/tests/featureStore-more.spec.d.ts +0 -1
- package/dist/types/tests/featureStore.spec.d.ts +0 -1
- package/dist/types/tests/framework-runtime-externalization.spec.d.ts +0 -1
- package/dist/types/tests/geodesic.spec.d.ts +0 -1
- package/dist/types/tests/geojson-merge.spec.d.ts +0 -1
- package/dist/types/tests/geojson-more.spec.d.ts +0 -1
- package/dist/types/tests/geojson.spec.d.ts +0 -1
- package/dist/types/tests/layer-cake-baker.spec.d.ts +0 -1
- package/dist/types/tests/layer-cake-controls.spec.d.ts +0 -1
- package/dist/types/tests/layer-cake-editing.spec.d.ts +0 -1
- package/dist/types/tests/layer-cake-manager.spec.d.ts +0 -1
- package/dist/types/tests/leaflet-assets.spec.d.ts +0 -1
- package/dist/types/tests/leaflet-draw-circle-resize-patch.spec.d.ts +0 -1
- package/dist/types/tests/leaflet-guards.spec.d.ts +0 -1
- package/dist/types/tests/logger-more.spec.d.ts +0 -1
- package/dist/types/tests/logger.spec.d.ts +0 -1
- package/dist/types/tests/map-controller.spec.d.ts +0 -1
- package/dist/types/tests/mapcontroller-merge.spec.d.ts +0 -1
- package/dist/types/tests/preact-bundled-shim.spec.d.ts +0 -1
- package/dist/types/tests/preact-shim.spec.d.ts +0 -1
- package/dist/types/tests/react-bundled-shim.spec.d.ts +0 -1
- package/dist/types/tests/react-shim.spec.d.ts +0 -1
- package/dist/types/tests/ruler.spec.d.ts +0 -1
- package/dist/types/tests/tile-provider-factory.spec.d.ts +0 -1
- package/dist/types/vite.config.d.ts +0 -2
- package/dist/types/vite.config.external.d.ts +0 -2
- package/dist/types/vite.config.preact-bundled.d.ts +0 -2
- package/dist/types/vite.config.preact.d.ts +0 -2
- package/dist/types/vite.config.react-bundled.d.ts +0 -2
- package/dist/types/vite.config.react.d.ts +0 -2
- /package/dist/types/{src/lib → lib}/TileProviderFactory.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/draw/L.Draw.Cake.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/draw/L.Draw.Move.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/draw/toolbar-patch.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/layer-cake/CakeBaker.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/layer-cake/bindCakeControls.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/layer-cake/ensureCircleEditable.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/leaflet-assets.d.ts +0 -0
- /package/dist/types/{src/shims → shims}/ensure-element.d.ts +0 -0
- /package/dist/types/{src/state → state}/types.d.ts +0 -0
- /package/dist/types/{src/types → types}/events.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/geodesic.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/geojson.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/leaflet-guards.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/logger.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/ruler.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
-
import type { LeafletDrawMapElementAPI, MeasurementSystem } from "
|
|
3
|
-
import { type LogLevel } from "
|
|
2
|
+
import type { LeafletDrawMapElementAPI, IntegratedToolEventEmitter, IntegratedToolHooks, MarkerIconConfig, MeasurementSystem, ToolButtonConfig, ToolButtonName, ToolToolbarGroupConfig, ToolTriggerOptions } from "../types/public";
|
|
3
|
+
import { type LogLevel } from "../utils/logger";
|
|
4
4
|
import type * as LeafletNS from "leaflet";
|
|
5
5
|
export declare class LeafletDrawMapElement extends HTMLElement implements LeafletDrawMapElementAPI {
|
|
6
6
|
private _root;
|
|
@@ -30,6 +30,13 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
30
30
|
private _useExternalLeaflet;
|
|
31
31
|
private _skipLeafletStyles;
|
|
32
32
|
private _leafletInstance;
|
|
33
|
+
private _toolHooks;
|
|
34
|
+
private _toolEventEmitter;
|
|
35
|
+
private _markerIconConfig;
|
|
36
|
+
private _toolButtonConfig;
|
|
37
|
+
private _toolbarGroups;
|
|
38
|
+
private _externalToolTriggerListener;
|
|
39
|
+
private _externalToolDeactivateListener;
|
|
33
40
|
constructor();
|
|
34
41
|
private _controlsFromAttributes;
|
|
35
42
|
private _mapConfig;
|
|
@@ -40,6 +47,13 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
40
47
|
private _updateTileLayer;
|
|
41
48
|
private _handleTileProviderError;
|
|
42
49
|
private _emitTileProviderChanged;
|
|
50
|
+
private _isMarkerIconAttribute;
|
|
51
|
+
private _effectiveMarkerIconConfig;
|
|
52
|
+
private _syncMarkerIconConfig;
|
|
53
|
+
private _effectiveToolButtonConfig;
|
|
54
|
+
private _syncToolButtonConfig;
|
|
55
|
+
private _effectiveToolbarGroups;
|
|
56
|
+
private _syncToolbarGroups;
|
|
43
57
|
get latitude(): number;
|
|
44
58
|
set latitude(v: number);
|
|
45
59
|
get longitude(): number;
|
|
@@ -72,8 +86,18 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
72
86
|
set useExternalLeaflet(v: boolean);
|
|
73
87
|
get skipLeafletStyles(): boolean;
|
|
74
88
|
set skipLeafletStyles(v: boolean);
|
|
89
|
+
get markerIconConfig(): MarkerIconConfig | null | undefined;
|
|
90
|
+
set markerIconConfig(v: MarkerIconConfig | null | undefined);
|
|
91
|
+
get toolButtonConfig(): ToolButtonConfig | null | undefined;
|
|
92
|
+
set toolButtonConfig(v: ToolButtonConfig | null | undefined);
|
|
93
|
+
get toolbarGroups(): ToolToolbarGroupConfig[] | null | undefined;
|
|
94
|
+
set toolbarGroups(v: ToolToolbarGroupConfig[] | null | undefined);
|
|
75
95
|
get leafletInstance(): typeof LeafletNS | undefined;
|
|
76
96
|
set leafletInstance(v: typeof LeafletNS | undefined);
|
|
97
|
+
get toolHooks(): IntegratedToolHooks | undefined;
|
|
98
|
+
set toolHooks(v: IntegratedToolHooks | undefined);
|
|
99
|
+
get toolEventEmitter(): IntegratedToolEventEmitter | undefined;
|
|
100
|
+
set toolEventEmitter(v: IntegratedToolEventEmitter | undefined);
|
|
77
101
|
get themeCss(): string;
|
|
78
102
|
set themeCss(v: string);
|
|
79
103
|
getGeoJSON(): Promise<FeatureCollection>;
|
|
@@ -97,10 +121,14 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
|
|
|
97
121
|
properties?: Record<string, any>;
|
|
98
122
|
}): Promise<string | null>;
|
|
99
123
|
setMeasurementUnits(system: MeasurementSystem): Promise<void>;
|
|
124
|
+
activateTool(tool: ToolButtonName, options?: ToolTriggerOptions): Promise<boolean>;
|
|
125
|
+
triggerTool(tool: ToolButtonName, options?: ToolTriggerOptions): Promise<boolean>;
|
|
126
|
+
deactivateTool(options?: ToolTriggerOptions): Promise<boolean>;
|
|
100
127
|
loadGeoJSONFromUrl(url: string): Promise<void>;
|
|
101
128
|
loadGeoJSONFromText(text: string): Promise<void>;
|
|
102
129
|
private _currentConfig;
|
|
103
130
|
private _applyThemeStyles;
|
|
131
|
+
private _emitToolTriggerResult;
|
|
104
132
|
private _syncApiKeyFromAttributes;
|
|
105
133
|
private _normalizeText;
|
|
106
134
|
private _resolveTileProviderErrorCode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import type { LeafletDrawMapElement } from "
|
|
1
|
+
import "../index";
|
|
2
|
+
import type { LeafletDrawMapElement } from "../components/LeafletDrawMapElement";
|
|
3
3
|
export type DjangoShimPhase = "mount" | "parse" | "sync";
|
|
4
4
|
export interface DjangoShimErrorContext {
|
|
5
5
|
phase: DjangoShimPhase;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection } from "geojson";
|
|
2
|
-
import { type BoundsPair } from "
|
|
3
|
-
import { type Logger } from "
|
|
2
|
+
import { type BoundsPair } from "../utils/geojson";
|
|
3
|
+
import { type Logger } from "../utils/logger";
|
|
4
4
|
/**
|
|
5
5
|
* FeatureStore
|
|
6
6
|
* - Maintains a stable, id-centric in-memory FeatureCollection
|
|
@@ -2,9 +2,10 @@ import * as BundledL from "leaflet";
|
|
|
2
2
|
import "leaflet-draw";
|
|
3
3
|
import "leaflet-ruler";
|
|
4
4
|
import type { Feature, FeatureCollection } from "geojson";
|
|
5
|
-
import type { DrawControlsConfig, MapConfig, MeasurementSystem } from "
|
|
6
|
-
import { type Logger } from "
|
|
7
|
-
import type
|
|
5
|
+
import type { DrawControlsConfig, MapConfig, MeasurementSystem, IntegratedToolEventEmitter, IntegratedToolHooks, ToolButtonConfig, ToolButtonName, ToolToolbarGroupConfig, ToolTriggerEventDetail, ToolTriggerOptions } from "../types/public";
|
|
6
|
+
import { type Logger } from "../utils/logger";
|
|
7
|
+
import { type NormalizedMarkerIconConfig } from "../lib/marker-icons";
|
|
8
|
+
import type { TileURLTemplate } from "../lib/TileProviderFactory";
|
|
8
9
|
export interface MapControllerCallbacks {
|
|
9
10
|
onReady?: (detail: {
|
|
10
11
|
bounds?: [[number, number], [number, number]];
|
|
@@ -26,6 +27,8 @@ export interface MapControllerCallbacks {
|
|
|
26
27
|
message: string;
|
|
27
28
|
cause?: unknown;
|
|
28
29
|
}) => void;
|
|
30
|
+
onTileError?: (error: unknown) => void;
|
|
31
|
+
onToolTrigger?: (detail: ToolTriggerEventDetail) => void;
|
|
29
32
|
}
|
|
30
33
|
export interface MapControllerOptions {
|
|
31
34
|
container: HTMLElement;
|
|
@@ -38,6 +41,16 @@ export interface MapControllerOptions {
|
|
|
38
41
|
leaflet?: typeof BundledL;
|
|
39
42
|
/** Prefer external Leaflet if available (falls back to bundled if missing/invalid). */
|
|
40
43
|
useExternalLeaflet?: boolean;
|
|
44
|
+
/** Optional hooks for integrated tool lifecycle/events. */
|
|
45
|
+
toolHooks?: IntegratedToolHooks;
|
|
46
|
+
/** Optional event emitter for integrated tool lifecycle/events. */
|
|
47
|
+
toolEventEmitter?: IntegratedToolEventEmitter;
|
|
48
|
+
/** Optional normalized marker icon override. */
|
|
49
|
+
markerIconConfig?: NormalizedMarkerIconConfig | null;
|
|
50
|
+
/** Optional draw/ruler toolbar button customization. */
|
|
51
|
+
toolButtonConfig?: ToolButtonConfig | null;
|
|
52
|
+
/** Optional additional toolbar groups rendered over the map. */
|
|
53
|
+
toolbarGroups?: ToolToolbarGroupConfig[] | null;
|
|
41
54
|
}
|
|
42
55
|
interface TileLayerCallbacks {
|
|
43
56
|
onTileError?: (error: unknown) => void;
|
|
@@ -65,10 +78,29 @@ export declare class MapController {
|
|
|
65
78
|
private detachPolygonFinishPatch;
|
|
66
79
|
private vertexMenuEl;
|
|
67
80
|
private vertexMenuCleanup;
|
|
81
|
+
private vertexEditSurfaceCleanup;
|
|
68
82
|
private activeCakeSession;
|
|
69
83
|
private moveConfirmationUI;
|
|
70
84
|
private activeMoveHandler;
|
|
85
|
+
private markerIconConfig;
|
|
86
|
+
private markerIcon;
|
|
87
|
+
private toolButtonConfig;
|
|
88
|
+
private toolbarGroups;
|
|
89
|
+
private emitToolEvent;
|
|
71
90
|
constructor(opts: MapControllerOptions);
|
|
91
|
+
setToolObservers(options: {
|
|
92
|
+
toolHooks?: IntegratedToolHooks;
|
|
93
|
+
toolEventEmitter?: IntegratedToolEventEmitter;
|
|
94
|
+
}): void;
|
|
95
|
+
setMarkerIconConfig(config: NormalizedMarkerIconConfig | null, options?: {
|
|
96
|
+
reapplyExistingLayers?: boolean;
|
|
97
|
+
syncDrawControl?: boolean;
|
|
98
|
+
}): void;
|
|
99
|
+
setToolButtonConfig(config: ToolButtonConfig | null | undefined): void;
|
|
100
|
+
setToolbarGroups(groups: ToolToolbarGroupConfig[] | null | undefined): void;
|
|
101
|
+
activateTool(tool: ToolButtonName, options?: ToolTriggerOptions): boolean;
|
|
102
|
+
triggerTool(tool: ToolButtonName, options?: ToolTriggerOptions): boolean;
|
|
103
|
+
deactivateTool(options?: ToolTriggerOptions): boolean;
|
|
72
104
|
private resolveLeaflet;
|
|
73
105
|
init(): Promise<void>;
|
|
74
106
|
destroy(): Promise<void>;
|
|
@@ -95,6 +127,19 @@ export declare class MapController {
|
|
|
95
127
|
}): Promise<string | null>;
|
|
96
128
|
setRulerUnits(system: MeasurementSystem): void;
|
|
97
129
|
private buildDrawOptions;
|
|
130
|
+
private buildMarkerDrawOptions;
|
|
131
|
+
private createMarkerIcon;
|
|
132
|
+
private createDefaultMarkerIcon;
|
|
133
|
+
private createGeoJSONLayers;
|
|
134
|
+
private addGeoJSONLayersToDrawnItems;
|
|
135
|
+
private restoreVisibleLayersFromStore;
|
|
136
|
+
private syncDrawMarkerOptions;
|
|
137
|
+
private reapplyMarkerIconsToExistingLayers;
|
|
138
|
+
private applyToolButtonCustomizations;
|
|
139
|
+
private emitToolTrigger;
|
|
140
|
+
private findLeafletDrawHandler;
|
|
141
|
+
private disableActiveToolHandlers;
|
|
142
|
+
private triggerRulerTool;
|
|
98
143
|
private applyLayerCakeToolbarIcon;
|
|
99
144
|
private applyMoveToolbarIcon;
|
|
100
145
|
private addRulerControl;
|
|
@@ -117,6 +162,8 @@ export declare class MapController {
|
|
|
117
162
|
private patchLeafletDrawBugs;
|
|
118
163
|
private bindDrawEvents;
|
|
119
164
|
private _error;
|
|
165
|
+
private installVertexEditSurfaceMenu;
|
|
166
|
+
private openNearestEditableVertexMenuFromDomEvent;
|
|
120
167
|
private installVertexContextMenu;
|
|
121
168
|
private openVertexMenu;
|
|
122
169
|
private showVertexMenu;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { MarkerIconConfig, MarkerIconPoint } from "../types/public";
|
|
2
|
+
export declare const DEFAULT_MARKER_ICON_SIZE: MarkerIconPoint;
|
|
3
|
+
export declare const DEFAULT_MARKER_ICON_ANCHOR: MarkerIconPoint;
|
|
4
|
+
export declare const DEFAULT_MARKER_POPUP_ANCHOR: MarkerIconPoint;
|
|
5
|
+
export interface NormalizedMarkerIconConfig {
|
|
6
|
+
iconUrl: string;
|
|
7
|
+
iconRetinaUrl: string;
|
|
8
|
+
shadowUrl?: string;
|
|
9
|
+
iconSize: MarkerIconPoint;
|
|
10
|
+
iconAnchor: MarkerIconPoint;
|
|
11
|
+
popupAnchor: MarkerIconPoint;
|
|
12
|
+
}
|
|
13
|
+
interface NormalizationOptions {
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
reportError?: (message: string, cause?: unknown) => void;
|
|
16
|
+
}
|
|
17
|
+
interface MarkerIconAttributeValues {
|
|
18
|
+
iconUrl?: string | null;
|
|
19
|
+
iconRetinaUrl?: string | null;
|
|
20
|
+
shadowUrl?: string | null;
|
|
21
|
+
iconSize?: string | null;
|
|
22
|
+
iconAnchor?: string | null;
|
|
23
|
+
popupAnchor?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export declare function normalizeMarkerIconConfig(config: MarkerIconConfig | null | undefined, options?: NormalizationOptions): NormalizedMarkerIconConfig | null;
|
|
26
|
+
export declare function normalizeMarkerIconAttributes(attributes: MarkerIconAttributeValues, options?: NormalizationOptions): NormalizedMarkerIconConfig | null;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ToolButtonConfig, ToolButtonName, ToolToolbarGroupConfig } from "../types/public";
|
|
2
|
+
export interface ToolButtonTriggerContext {
|
|
3
|
+
source: "toolbar" | "leaflet-toolbar";
|
|
4
|
+
groupId?: string;
|
|
5
|
+
activate: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ApplyToolButtonOptions {
|
|
8
|
+
toolbarGroups?: ToolToolbarGroupConfig[] | null;
|
|
9
|
+
onTrigger?: (tool: ToolButtonName, context: ToolButtonTriggerContext) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function applyToolButtonConfig(container: HTMLElement, config: ToolButtonConfig | null | undefined, options?: ApplyToolButtonOptions): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { LeafletDrawMapElement } from "
|
|
1
|
+
import type { LeafletDrawMapElement } from "../components/LeafletDrawMapElement";
|
|
2
|
+
import type { IntegratedToolEventEmitter, IntegratedToolHooks, ToolButtonConfig, ToolToolbarGroupConfig } from "../types/public";
|
|
2
3
|
type Primitive = string | number | boolean | null | undefined;
|
|
3
4
|
type LeafletMode = "external" | "bundled";
|
|
4
5
|
export interface PreactLeafletGeoKitProps {
|
|
@@ -17,6 +18,14 @@ export interface PreactLeafletGeoKitProps {
|
|
|
17
18
|
externalLeaflet?: boolean;
|
|
18
19
|
/** Optional explicit Leaflet namespace (window.L equivalent). */
|
|
19
20
|
leafletInstance?: any;
|
|
21
|
+
/** Optional integrated tool hooks map. */
|
|
22
|
+
toolHooks?: IntegratedToolHooks;
|
|
23
|
+
/** Optional integrated tool event emitter. */
|
|
24
|
+
toolEventEmitter?: IntegratedToolEventEmitter;
|
|
25
|
+
/** Optional draw/ruler toolbar button customization. */
|
|
26
|
+
toolButtonConfig?: ToolButtonConfig | null;
|
|
27
|
+
/** Optional additional toolbar groups rendered over the map. */
|
|
28
|
+
toolbarGroups?: ToolToolbarGroupConfig[] | null;
|
|
20
29
|
/** Initial GeoJSON text to load once on ready. */
|
|
21
30
|
initialGeoJSONText?: string;
|
|
22
31
|
/** Called whenever draw/edit/delete/merge occurs, with latest serialized FeatureCollection. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PreactLeafletGeoKitProps } from "
|
|
1
|
+
import { type PreactLeafletGeoKitProps } from "../preact/core";
|
|
2
2
|
export type { PreactLeafletGeoKitProps };
|
|
3
3
|
export declare const PreactLeafletGeoKit: (props: PreactLeafletGeoKitProps) => import("preact").VNode<import("preact").Attributes & {
|
|
4
4
|
ref: import("preact/hooks").MutableRef<import("..").LeafletDrawMapElement | null>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { type PreactLeafletGeoKitProps } from "
|
|
1
|
+
import "../index";
|
|
2
|
+
import { type PreactLeafletGeoKitProps } from "../preact/core";
|
|
3
3
|
export type { PreactLeafletGeoKitProps };
|
|
4
4
|
export declare const PreactLeafletGeoKit: (props: PreactLeafletGeoKitProps) => import("preact").VNode<import("preact").Attributes & {
|
|
5
|
-
ref: import("preact/hooks").MutableRef<import("
|
|
5
|
+
ref: import("preact/hooks").MutableRef<import("../index").LeafletDrawMapElement | null>;
|
|
6
6
|
className: string | undefined;
|
|
7
7
|
style: string;
|
|
8
8
|
}>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { LeafletDrawMapElement } from "
|
|
2
|
+
import type { LeafletDrawMapElement } from "../components/LeafletDrawMapElement";
|
|
3
|
+
import type { IntegratedToolEventEmitter, IntegratedToolHooks, ToolButtonConfig, ToolToolbarGroupConfig } from "../types/public";
|
|
3
4
|
type Primitive = string | number | boolean | null | undefined;
|
|
4
5
|
type LeafletMode = "external" | "bundled";
|
|
5
6
|
export interface ReactLeafletGeoKitProps {
|
|
@@ -18,6 +19,14 @@ export interface ReactLeafletGeoKitProps {
|
|
|
18
19
|
externalLeaflet?: boolean;
|
|
19
20
|
/** Optional explicit Leaflet namespace (window.L equivalent). */
|
|
20
21
|
leafletInstance?: any;
|
|
22
|
+
/** Optional integrated tool hooks map. */
|
|
23
|
+
toolHooks?: IntegratedToolHooks;
|
|
24
|
+
/** Optional integrated tool event emitter. */
|
|
25
|
+
toolEventEmitter?: IntegratedToolEventEmitter;
|
|
26
|
+
/** Optional draw/ruler toolbar button customization. */
|
|
27
|
+
toolButtonConfig?: ToolButtonConfig | null;
|
|
28
|
+
/** Optional additional toolbar groups rendered over the map. */
|
|
29
|
+
toolbarGroups?: ToolToolbarGroupConfig[] | null;
|
|
21
30
|
/** Initial GeoJSON text to load once on ready. */
|
|
22
31
|
initialGeoJSONText?: string;
|
|
23
32
|
/** Called whenever draw/edit/delete/merge occurs, with latest serialized FeatureCollection. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactLeafletGeoKitProps } from "
|
|
1
|
+
import { type ReactLeafletGeoKitProps } from "../react/core";
|
|
2
2
|
export type { ReactLeafletGeoKitProps };
|
|
3
3
|
export declare const ReactLeafletGeoKit: (props: ReactLeafletGeoKitProps) => import("react").ReactElement<{
|
|
4
4
|
ref: import("react").MutableRefObject<import("..").LeafletDrawMapElement | null>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import { type ReactLeafletGeoKitProps } from "
|
|
1
|
+
import "../index";
|
|
2
|
+
import { type ReactLeafletGeoKitProps } from "../react/core";
|
|
3
3
|
export type { ReactLeafletGeoKitProps };
|
|
4
4
|
export declare const ReactLeafletGeoKit: (props: ReactLeafletGeoKitProps) => import("react").ReactElement<{
|
|
5
|
-
ref: import("react").MutableRefObject<import("
|
|
5
|
+
ref: import("react").MutableRefObject<import("../index").LeafletDrawMapElement | null>;
|
|
6
6
|
className: string | undefined;
|
|
7
7
|
}, string | import("react").JSXElementConstructor<any>>;
|
|
8
8
|
export default ReactLeafletGeoKit;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Feature, FeatureCollection, Geometry } from "geojson";
|
|
2
|
-
import type { LogLevel } from "
|
|
2
|
+
import type { LogLevel } from "../utils/logger";
|
|
3
3
|
import type * as Leaflet from "leaflet";
|
|
4
4
|
/**
|
|
5
5
|
* Basic map configuration derived from element attributes.
|
|
@@ -31,6 +31,99 @@ export interface MapConfig {
|
|
|
31
31
|
skipLeafletStyles?: boolean;
|
|
32
32
|
}
|
|
33
33
|
export type MeasurementSystem = "metric" | "imperial";
|
|
34
|
+
export type MarkerIconPoint = [number, number];
|
|
35
|
+
export interface MarkerIconConfig {
|
|
36
|
+
/** Required to activate a custom marker icon. Absolute, relative, data:, or blob: URL. */
|
|
37
|
+
iconUrl: string;
|
|
38
|
+
/** Optional high-DPI image URL. Falls back to iconUrl when omitted or invalid. */
|
|
39
|
+
iconRetinaUrl?: string;
|
|
40
|
+
/** Optional marker shadow image URL. Shadow is dropped when omitted or invalid. */
|
|
41
|
+
shadowUrl?: string;
|
|
42
|
+
/** Icon image size in CSS pixels: [width, height]. Defaults to [25, 41]. */
|
|
43
|
+
iconSize?: MarkerIconPoint;
|
|
44
|
+
/** Pixel coordinate in the icon image anchored to the map point: [x, y]. Defaults to [12, 41]. */
|
|
45
|
+
iconAnchor?: MarkerIconPoint;
|
|
46
|
+
/** Popup anchor relative to iconAnchor: [x, y]. Defaults to [1, -34]. */
|
|
47
|
+
popupAnchor?: MarkerIconPoint;
|
|
48
|
+
}
|
|
49
|
+
export type ToolButtonName = "polygon" | "polyline" | "rectangle" | "circle" | "marker" | "layerCake" | "move" | "select" | "edit" | "delete" | "ruler" | "measurementSettings" | "layerStyle";
|
|
50
|
+
export interface ToolButtonRenderContext {
|
|
51
|
+
tool: ToolButtonName;
|
|
52
|
+
groupId?: string;
|
|
53
|
+
button: HTMLElement;
|
|
54
|
+
}
|
|
55
|
+
export type ToolIconRenderer = (context: ToolButtonRenderContext) => HTMLElement | SVGElement | string | null | undefined;
|
|
56
|
+
export interface ToolPopoverRenderContext extends ToolButtonRenderContext {
|
|
57
|
+
popover: HTMLElement;
|
|
58
|
+
}
|
|
59
|
+
export interface ToolPopoverConfig {
|
|
60
|
+
/** Heading text rendered at the top of the popover. */
|
|
61
|
+
title?: string;
|
|
62
|
+
/** Plain body copy for point-of-action guidance. */
|
|
63
|
+
body?: string;
|
|
64
|
+
/** Trusted host-supplied HTML content. Use only with sanitized/static content. */
|
|
65
|
+
html?: string;
|
|
66
|
+
/** Accessible label for the popover dialog. Falls back to title. */
|
|
67
|
+
ariaLabel?: string;
|
|
68
|
+
/** Custom renderer for framework-owned popover content. */
|
|
69
|
+
render?: (context: ToolPopoverRenderContext) => HTMLElement | DocumentFragment | string | null | undefined;
|
|
70
|
+
/** Called after the popover is attached. */
|
|
71
|
+
onOpen?: (context: ToolPopoverRenderContext) => void;
|
|
72
|
+
/** Called after the popover is closed. */
|
|
73
|
+
onClose?: (context: ToolPopoverRenderContext) => void;
|
|
74
|
+
}
|
|
75
|
+
export interface ToolButtonStyleConfig {
|
|
76
|
+
/** URL for the icon rendered inside the Leaflet control button. */
|
|
77
|
+
iconUrl?: string;
|
|
78
|
+
/** Trusted inline SVG/HTML icon markup rendered inside the button. */
|
|
79
|
+
iconHtml?: string;
|
|
80
|
+
/** Programmatic icon renderer for framework-owned controls. */
|
|
81
|
+
renderIcon?: ToolIconRenderer;
|
|
82
|
+
/** Icon box size in CSS pixels. Defaults to [18, 18]. */
|
|
83
|
+
iconSize?: MarkerIconPoint;
|
|
84
|
+
/** Tooltip/title text for the button. */
|
|
85
|
+
title?: string;
|
|
86
|
+
/** Accessible label. Falls back to title when omitted. */
|
|
87
|
+
ariaLabel?: string;
|
|
88
|
+
/** Extra class name(s) added to the button for host theme CSS. */
|
|
89
|
+
className?: string;
|
|
90
|
+
/** Optional point-of-action guidance shown when the button is used. */
|
|
91
|
+
popover?: ToolPopoverConfig;
|
|
92
|
+
}
|
|
93
|
+
export type ToolButtonConfig = Partial<Record<ToolButtonName, ToolButtonStyleConfig>>;
|
|
94
|
+
export type ToolToolbarPosition = "topleft" | "topright" | "bottomleft" | "bottomright";
|
|
95
|
+
export interface ToolToolbarGroupConfig {
|
|
96
|
+
/** Stable group id used in events and DOM data attributes. */
|
|
97
|
+
id: string;
|
|
98
|
+
/** Tools rendered in this group, in order. */
|
|
99
|
+
tools: ToolButtonName[];
|
|
100
|
+
/** Leaflet-like map corner placement. Defaults to "topright". */
|
|
101
|
+
position?: ToolToolbarPosition;
|
|
102
|
+
/** Accessible toolbar label. */
|
|
103
|
+
ariaLabel?: string;
|
|
104
|
+
/** Extra class name(s) added to the toolbar group container. */
|
|
105
|
+
className?: string;
|
|
106
|
+
/** Pixel offset from the chosen map corner. Defaults to [10, 10]. */
|
|
107
|
+
offset?: MarkerIconPoint;
|
|
108
|
+
}
|
|
109
|
+
export interface ToolTriggerOptions {
|
|
110
|
+
/** Source label included in public trigger events. */
|
|
111
|
+
source?: "api" | "event" | "toolbar" | "leaflet-toolbar" | string;
|
|
112
|
+
/** Toolbar group id when triggered from a configured toolbar group. */
|
|
113
|
+
groupId?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface ToolTriggerEventDetail extends ToolTriggerOptions {
|
|
116
|
+
tool: ToolButtonName;
|
|
117
|
+
handled: boolean;
|
|
118
|
+
timestamp: number;
|
|
119
|
+
error?: string;
|
|
120
|
+
}
|
|
121
|
+
export type IntegratedToolEventName = "tool:polygon:created" | "tool:polyline:created" | "tool:rectangle:created" | "tool:circle:created" | "tool:marker:created" | "tool:layer-cake:session-started" | "tool:layer-cake:saved" | "tool:move:pending" | "tool:move:confirmed" | "tool:move:cancelled" | "tool:edit:applied" | "tool:delete:applied" | "tool:ruler:units-changed";
|
|
122
|
+
export type IntegratedToolHooks = Partial<Record<IntegratedToolEventName, (detail: unknown) => void>>;
|
|
123
|
+
export interface IntegratedToolEventEmitter {
|
|
124
|
+
emit?: (eventName: IntegratedToolEventName, detail: unknown) => void;
|
|
125
|
+
dispatchEvent?: (event: Event) => boolean;
|
|
126
|
+
}
|
|
34
127
|
/**
|
|
35
128
|
* Draw controls toggles (presence = true on the element).
|
|
36
129
|
*/
|
|
@@ -120,8 +213,27 @@ export interface LeafletDrawMapElementAPI {
|
|
|
120
213
|
useExternalLeaflet?: boolean;
|
|
121
214
|
/** Disable our CSS/icon injection when host supplies styles. */
|
|
122
215
|
skipLeafletStyles?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Programmatic marker icon override.
|
|
218
|
+
* `undefined` falls back to marker icon attributes, `null` forces default markers.
|
|
219
|
+
*/
|
|
220
|
+
markerIconConfig?: MarkerIconConfig | null;
|
|
221
|
+
/**
|
|
222
|
+
* Per-tool button customization for Leaflet.draw/ruler controls.
|
|
223
|
+
* `undefined` falls back to the `tool-button-config` attribute, `null` clears custom button config.
|
|
224
|
+
*/
|
|
225
|
+
toolButtonConfig?: ToolButtonConfig | null;
|
|
226
|
+
/**
|
|
227
|
+
* Additional toolbar groups rendered over the map.
|
|
228
|
+
* `undefined` falls back to the `toolbar-groups` attribute, `null` clears custom groups.
|
|
229
|
+
*/
|
|
230
|
+
toolbarGroups?: ToolToolbarGroupConfig[] | null;
|
|
123
231
|
/** Optional injection of a pre-existing Leaflet namespace to use instead of bundled import. */
|
|
124
232
|
leafletInstance?: typeof Leaflet;
|
|
233
|
+
/** Optional per-tool hooks keyed by integrated tool event name. */
|
|
234
|
+
toolHooks?: IntegratedToolHooks;
|
|
235
|
+
/** Optional emitter for integrated tool events. */
|
|
236
|
+
toolEventEmitter?: IntegratedToolEventEmitter;
|
|
125
237
|
/** Tile provider identifier (e.g., "osm", "here") */
|
|
126
238
|
tileProvider?: "osm" | "here" | string;
|
|
127
239
|
/** Provider-specific style (e.g., "lite.day" for HERE) */
|
|
@@ -162,5 +274,17 @@ export interface LeafletDrawMapElementAPI {
|
|
|
162
274
|
* Change the measurement system for the Leaflet ruler tool.
|
|
163
275
|
*/
|
|
164
276
|
setMeasurementUnits(system: MeasurementSystem): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Programmatically activate a map tool through the public web component API.
|
|
279
|
+
*/
|
|
280
|
+
activateTool(tool: ToolButtonName, options?: ToolTriggerOptions): Promise<boolean>;
|
|
281
|
+
/**
|
|
282
|
+
* Back-compat alias for activateTool.
|
|
283
|
+
*/
|
|
284
|
+
triggerTool(tool: ToolButtonName, options?: ToolTriggerOptions): Promise<boolean>;
|
|
285
|
+
/**
|
|
286
|
+
* Deactivate the active draw/edit tool and return the map to select mode.
|
|
287
|
+
*/
|
|
288
|
+
deactivateTool(options?: ToolTriggerOptions): Promise<boolean>;
|
|
165
289
|
}
|
|
166
290
|
export type { Feature, FeatureCollection, Geometry };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@florasync/leaflet-geokit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Framework-agnostic Leaflet + Leaflet.draw web component with TypeScript, verbose logging, and tests.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/leaflet-geokit.umd.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"import": "./dist/django/index.js"
|
|
18
18
|
},
|
|
19
19
|
"./external": {
|
|
20
|
-
"types": "./dist/types/
|
|
20
|
+
"types": "./dist/types/external.d.ts",
|
|
21
21
|
"import": "./dist/leaflet-geokit.external.es.js"
|
|
22
22
|
},
|
|
23
23
|
"./preact": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"homepage": "https://github.com/FloraSync/leaflet-geokit#readme",
|
|
60
60
|
"scripts": {
|
|
61
61
|
"dev": "vite",
|
|
62
|
-
"build": "tsc -p tsconfig.json --emitDeclarationOnly && vite build && vite build -c vite.config.external.ts && vite build -c vite.config.django.ts && vite build -c vite.config.preact.ts && vite build -c vite.config.preact-bundled.ts && vite build -c vite.config.react.ts && vite build -c vite.config.react-bundled.ts",
|
|
62
|
+
"build": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json --emitDeclarationOnly && tsc-alias -p tsconfig.build.json && vite build && vite build -c vite.config.external.ts && vite build -c vite.config.django.ts && vite build -c vite.config.preact.ts && vite build -c vite.config.preact-bundled.ts && vite build -c vite.config.react.ts && vite build -c vite.config.react-bundled.ts",
|
|
63
63
|
"build:analyze": "npm run build:analyze:main && npm run build:analyze:external && npm run build:analyze:django && npm run build:analyze:preact && npm run build:analyze:preact-bundled && npm run build:analyze:react && npm run build:analyze:react-bundled",
|
|
64
64
|
"build:analyze:main": "BUNDLE_ANALYZE=1 BUNDLE_ANALYZE_REPORT=dist/stats/main.html vite build",
|
|
65
65
|
"build:analyze:external": "BUNDLE_ANALYZE=1 BUNDLE_ANALYZE_REPORT=dist/stats/external.html vite build -c vite.config.external.ts",
|
|
@@ -76,8 +76,10 @@
|
|
|
76
76
|
"prettier:check": "prettier --check .",
|
|
77
77
|
"test": "npm run test:unit && npm run test:e2e",
|
|
78
78
|
"test:unit": "vitest run",
|
|
79
|
+
"test:unit:focused": "vitest run --coverage.enabled=false",
|
|
79
80
|
"test:unit:watch": "vitest",
|
|
80
81
|
"test:e2e": "playwright test",
|
|
82
|
+
"test:e2e:polling": "CHOKIDAR_USEPOLLING=true playwright test",
|
|
81
83
|
"e2e:install": "playwright install --with-deps",
|
|
82
84
|
"prepare": "husky",
|
|
83
85
|
"spec-kitty:init": "spec-kitty init . --ai claude",
|
|
@@ -150,6 +152,7 @@
|
|
|
150
152
|
"react": "^18.3.1",
|
|
151
153
|
"react-dom": "^18.3.1",
|
|
152
154
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
155
|
+
"tsc-alias": "^1.8.17",
|
|
153
156
|
"typescript": "^5.5.4",
|
|
154
157
|
"vite": "^7.1.4",
|
|
155
158
|
"vitest": "^4.0.18"
|