@florasync/leaflet-geokit 0.8.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +262 -3
  3. package/dist/django/index.js +4670 -3554
  4. package/dist/django/index.js.map +1 -1
  5. package/dist/leaflet-geokit.es.js +4512 -3396
  6. package/dist/leaflet-geokit.es.js.map +1 -1
  7. package/dist/leaflet-geokit.external.es.js +2200 -1084
  8. package/dist/leaflet-geokit.external.es.js.map +1 -1
  9. package/dist/leaflet-geokit.umd.js +17 -17
  10. package/dist/leaflet-geokit.umd.js.map +1 -1
  11. package/dist/preact/{index-CudTfo4O.js → index-x8CrGR_z.js} +2172 -1056
  12. package/dist/preact/index-x8CrGR_z.js.map +1 -0
  13. package/dist/preact/index.js +34 -32
  14. package/dist/preact/index.js.map +1 -1
  15. package/dist/preact-bundled/index.js +4732 -3614
  16. package/dist/preact-bundled/index.js.map +1 -1
  17. package/dist/react/{index-CudTfo4O.js → index-x8CrGR_z.js} +2172 -1056
  18. package/dist/react/index-x8CrGR_z.js.map +1 -0
  19. package/dist/react/index.js +35 -33
  20. package/dist/react/index.js.map +1 -1
  21. package/dist/react-bundled/index.js +4741 -3623
  22. package/dist/react-bundled/index.js.map +1 -1
  23. package/dist/types/{src/components → components}/LeafletDrawMapElement.d.ts +24 -2
  24. package/dist/types/{src/django → django}/index.d.ts +2 -2
  25. package/dist/types/external.d.ts +4 -0
  26. package/dist/types/index.d.ts +4 -0
  27. package/dist/types/{src/lib → lib}/FeatureStore.d.ts +2 -2
  28. package/dist/types/{src/lib → lib}/MapController.d.ts +41 -3
  29. package/dist/types/{src/lib → lib}/layer-cake/LayerCakeManager.d.ts +1 -1
  30. package/dist/types/lib/marker-icons.d.ts +27 -0
  31. package/dist/types/lib/tool-buttons.d.ts +11 -0
  32. package/dist/types/{src/preact → preact}/core.d.ts +6 -2
  33. package/dist/types/{src/preact → preact}/index.d.ts +1 -1
  34. package/dist/types/{src/preact-bundled → preact-bundled}/index.d.ts +3 -3
  35. package/dist/types/{src/react → react}/core.d.ts +6 -2
  36. package/dist/types/{src/react → react}/index.d.ts +1 -1
  37. package/dist/types/{src/react-bundled → react-bundled}/index.d.ts +3 -3
  38. package/dist/types/{src/types → types}/public.d.ts +115 -1
  39. package/package.json +6 -3
  40. package/dist/preact/index-CudTfo4O.js.map +0 -1
  41. package/dist/react/index-CudTfo4O.js.map +0 -1
  42. package/dist/types/e2e/component.spec.d.ts +0 -1
  43. package/dist/types/e2e/dummy.spec.d.ts +0 -1
  44. package/dist/types/e2e/tool-events-harness.spec.d.ts +0 -1
  45. package/dist/types/e2e/tool-hooks.spec.d.ts +0 -1
  46. package/dist/types/src/external.d.ts +0 -4
  47. package/dist/types/src/index.d.ts +0 -4
  48. package/dist/types/tests/bbox-more.spec.d.ts +0 -1
  49. package/dist/types/tests/component-api-more.spec.d.ts +0 -1
  50. package/dist/types/tests/component-branch-coverage.spec.d.ts +0 -1
  51. package/dist/types/tests/component-delegation.spec.d.ts +0 -1
  52. package/dist/types/tests/component-events.spec.d.ts +0 -1
  53. package/dist/types/tests/component-io.spec.d.ts +0 -1
  54. package/dist/types/tests/component-tile-provider.spec.d.ts +0 -1
  55. package/dist/types/tests/django-shim.spec.d.ts +0 -1
  56. package/dist/types/tests/draw-cake.spec.d.ts +0 -1
  57. package/dist/types/tests/draw-move.spec.d.ts +0 -1
  58. package/dist/types/tests/eachcoord.spec.d.ts +0 -1
  59. package/dist/types/tests/element.spec.d.ts +0 -1
  60. package/dist/types/tests/ensure-element.spec.d.ts +0 -1
  61. package/dist/types/tests/external-entry.spec.d.ts +0 -1
  62. package/dist/types/tests/featureStore-more.spec.d.ts +0 -1
  63. package/dist/types/tests/featureStore.spec.d.ts +0 -1
  64. package/dist/types/tests/framework-runtime-externalization.spec.d.ts +0 -1
  65. package/dist/types/tests/geodesic.spec.d.ts +0 -1
  66. package/dist/types/tests/geojson-merge.spec.d.ts +0 -1
  67. package/dist/types/tests/geojson-more.spec.d.ts +0 -1
  68. package/dist/types/tests/geojson.spec.d.ts +0 -1
  69. package/dist/types/tests/layer-cake-baker.spec.d.ts +0 -1
  70. package/dist/types/tests/layer-cake-controls.spec.d.ts +0 -1
  71. package/dist/types/tests/layer-cake-editing.spec.d.ts +0 -1
  72. package/dist/types/tests/layer-cake-manager.spec.d.ts +0 -1
  73. package/dist/types/tests/leaflet-assets.spec.d.ts +0 -1
  74. package/dist/types/tests/leaflet-draw-circle-resize-patch.spec.d.ts +0 -1
  75. package/dist/types/tests/leaflet-guards.spec.d.ts +0 -1
  76. package/dist/types/tests/logger-more.spec.d.ts +0 -1
  77. package/dist/types/tests/logger.spec.d.ts +0 -1
  78. package/dist/types/tests/map-controller.spec.d.ts +0 -1
  79. package/dist/types/tests/mapcontroller-merge.spec.d.ts +0 -1
  80. package/dist/types/tests/preact-bundled-shim.spec.d.ts +0 -1
  81. package/dist/types/tests/preact-shim.spec.d.ts +0 -1
  82. package/dist/types/tests/react-bundled-shim.spec.d.ts +0 -1
  83. package/dist/types/tests/react-shim.spec.d.ts +0 -1
  84. package/dist/types/tests/ruler.spec.d.ts +0 -1
  85. package/dist/types/tests/tile-provider-factory.spec.d.ts +0 -1
  86. package/dist/types/vite.config.d.ts +0 -2
  87. package/dist/types/vite.config.external.d.ts +0 -2
  88. package/dist/types/vite.config.preact-bundled.d.ts +0 -2
  89. package/dist/types/vite.config.preact.d.ts +0 -2
  90. package/dist/types/vite.config.react-bundled.d.ts +0 -2
  91. package/dist/types/vite.config.react.d.ts +0 -2
  92. /package/dist/types/{src/lib → lib}/TileProviderFactory.d.ts +0 -0
  93. /package/dist/types/{src/lib → lib}/draw/L.Draw.Cake.d.ts +0 -0
  94. /package/dist/types/{src/lib → lib}/draw/L.Draw.Move.d.ts +0 -0
  95. /package/dist/types/{src/lib → lib}/draw/toolbar-patch.d.ts +0 -0
  96. /package/dist/types/{src/lib → lib}/layer-cake/CakeBaker.d.ts +0 -0
  97. /package/dist/types/{src/lib → lib}/layer-cake/bindCakeControls.d.ts +0 -0
  98. /package/dist/types/{src/lib → lib}/layer-cake/ensureCircleEditable.d.ts +0 -0
  99. /package/dist/types/{src/lib → lib}/leaflet-assets.d.ts +0 -0
  100. /package/dist/types/{src/shims → shims}/ensure-element.d.ts +0 -0
  101. /package/dist/types/{src/state → state}/types.d.ts +0 -0
  102. /package/dist/types/{src/types → types}/events.d.ts +0 -0
  103. /package/dist/types/{src/utils → utils}/geodesic.d.ts +0 -0
  104. /package/dist/types/{src/utils → utils}/geojson.d.ts +0 -0
  105. /package/dist/types/{src/utils → utils}/leaflet-guards.d.ts +0 -0
  106. /package/dist/types/{src/utils → utils}/logger.d.ts +0 -0
  107. /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, IntegratedToolEventEmitter, IntegratedToolHooks, MeasurementSystem } from "@src/types/public";
3
- import { type LogLevel } from "@src/utils/logger";
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;
@@ -32,6 +32,11 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
32
32
  private _leafletInstance;
33
33
  private _toolHooks;
34
34
  private _toolEventEmitter;
35
+ private _markerIconConfig;
36
+ private _toolButtonConfig;
37
+ private _toolbarGroups;
38
+ private _externalToolTriggerListener;
39
+ private _externalToolDeactivateListener;
35
40
  constructor();
36
41
  private _controlsFromAttributes;
37
42
  private _mapConfig;
@@ -42,6 +47,13 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
42
47
  private _updateTileLayer;
43
48
  private _handleTileProviderError;
44
49
  private _emitTileProviderChanged;
50
+ private _isMarkerIconAttribute;
51
+ private _effectiveMarkerIconConfig;
52
+ private _syncMarkerIconConfig;
53
+ private _effectiveToolButtonConfig;
54
+ private _syncToolButtonConfig;
55
+ private _effectiveToolbarGroups;
56
+ private _syncToolbarGroups;
45
57
  get latitude(): number;
46
58
  set latitude(v: number);
47
59
  get longitude(): number;
@@ -74,6 +86,12 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
74
86
  set useExternalLeaflet(v: boolean);
75
87
  get skipLeafletStyles(): boolean;
76
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);
77
95
  get leafletInstance(): typeof LeafletNS | undefined;
78
96
  set leafletInstance(v: typeof LeafletNS | undefined);
79
97
  get toolHooks(): IntegratedToolHooks | undefined;
@@ -103,10 +121,14 @@ export declare class LeafletDrawMapElement extends HTMLElement implements Leafle
103
121
  properties?: Record<string, any>;
104
122
  }): Promise<string | null>;
105
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>;
106
127
  loadGeoJSONFromUrl(url: string): Promise<void>;
107
128
  loadGeoJSONFromText(text: string): Promise<void>;
108
129
  private _currentConfig;
109
130
  private _applyThemeStyles;
131
+ private _emitToolTriggerResult;
110
132
  private _syncApiKeyFromAttributes;
111
133
  private _normalizeText;
112
134
  private _resolveTileProviderErrorCode;
@@ -1,5 +1,5 @@
1
- import "@src/index";
2
- import type { LeafletDrawMapElement } from "@src/components/LeafletDrawMapElement";
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;
@@ -0,0 +1,4 @@
1
+ import { LeafletDrawMapElement } from "./components/LeafletDrawMapElement";
2
+ export { LeafletDrawMapElement };
3
+ export * from "./types/public";
4
+ export * from "./types/events";
@@ -0,0 +1,4 @@
1
+ import { LeafletDrawMapElement } from "./components/LeafletDrawMapElement";
2
+ export { LeafletDrawMapElement };
3
+ export * from "./types/public";
4
+ export * from "./types/events";
@@ -1,6 +1,6 @@
1
1
  import type { Feature, FeatureCollection } from "geojson";
2
- import { type BoundsPair } from "@src/utils/geojson";
3
- import { type Logger } from "@src/utils/logger";
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, IntegratedToolEventEmitter, IntegratedToolHooks } from "@src/types/public";
6
- import { type Logger } from "@src/utils/logger";
7
- import type { TileURLTemplate } from "@src/lib/TileProviderFactory";
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;
@@ -42,6 +45,12 @@ export interface MapControllerOptions {
42
45
  toolHooks?: IntegratedToolHooks;
43
46
  /** Optional event emitter for integrated tool lifecycle/events. */
44
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;
45
54
  }
46
55
  interface TileLayerCallbacks {
47
56
  onTileError?: (error: unknown) => void;
@@ -69,15 +78,29 @@ export declare class MapController {
69
78
  private detachPolygonFinishPatch;
70
79
  private vertexMenuEl;
71
80
  private vertexMenuCleanup;
81
+ private vertexEditSurfaceCleanup;
72
82
  private activeCakeSession;
73
83
  private moveConfirmationUI;
74
84
  private activeMoveHandler;
85
+ private markerIconConfig;
86
+ private markerIcon;
87
+ private toolButtonConfig;
88
+ private toolbarGroups;
75
89
  private emitToolEvent;
76
90
  constructor(opts: MapControllerOptions);
77
91
  setToolObservers(options: {
78
92
  toolHooks?: IntegratedToolHooks;
79
93
  toolEventEmitter?: IntegratedToolEventEmitter;
80
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;
81
104
  private resolveLeaflet;
82
105
  init(): Promise<void>;
83
106
  destroy(): Promise<void>;
@@ -104,6 +127,19 @@ export declare class MapController {
104
127
  }): Promise<string | null>;
105
128
  setRulerUnits(system: MeasurementSystem): void;
106
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;
107
143
  private applyLayerCakeToolbarIcon;
108
144
  private applyMoveToolbarIcon;
109
145
  private addRulerControl;
@@ -126,6 +162,8 @@ export declare class MapController {
126
162
  private patchLeafletDrawBugs;
127
163
  private bindDrawEvents;
128
164
  private _error;
165
+ private installVertexEditSurfaceMenu;
166
+ private openNearestEditableVertexMenuFromDomEvent;
129
167
  private installVertexContextMenu;
130
168
  private openVertexMenu;
131
169
  private showVertexMenu;
@@ -1,5 +1,5 @@
1
1
  import * as L from "leaflet";
2
- import type { MeasurementSystem } from "@src/types/public";
2
+ import type { MeasurementSystem } from "../../types/public";
3
3
  export declare class LayerCakeManager {
4
4
  private map;
5
5
  private layers;
@@ -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,5 +1,5 @@
1
- import type { LeafletDrawMapElement } from "@src/components/LeafletDrawMapElement";
2
- import type { IntegratedToolEventEmitter, IntegratedToolHooks } from "@src/types/public";
1
+ import type { LeafletDrawMapElement } from "../components/LeafletDrawMapElement";
2
+ import type { IntegratedToolEventEmitter, IntegratedToolHooks, ToolButtonConfig, ToolToolbarGroupConfig } from "../types/public";
3
3
  type Primitive = string | number | boolean | null | undefined;
4
4
  type LeafletMode = "external" | "bundled";
5
5
  export interface PreactLeafletGeoKitProps {
@@ -22,6 +22,10 @@ export interface PreactLeafletGeoKitProps {
22
22
  toolHooks?: IntegratedToolHooks;
23
23
  /** Optional integrated tool event emitter. */
24
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;
25
29
  /** Initial GeoJSON text to load once on ready. */
26
30
  initialGeoJSONText?: string;
27
31
  /** Called whenever draw/edit/delete/merge occurs, with latest serialized FeatureCollection. */
@@ -1,4 +1,4 @@
1
- import { type PreactLeafletGeoKitProps } from "@src/preact/core";
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 "@src/index";
2
- import { type PreactLeafletGeoKitProps } from "@src/preact/core";
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("@src/index").LeafletDrawMapElement | null>;
5
+ ref: import("preact/hooks").MutableRef<import("../index").LeafletDrawMapElement | null>;
6
6
  className: string | undefined;
7
7
  style: string;
8
8
  }>;
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
- import type { LeafletDrawMapElement } from "@src/components/LeafletDrawMapElement";
3
- import type { IntegratedToolEventEmitter, IntegratedToolHooks } from "@src/types/public";
2
+ import type { LeafletDrawMapElement } from "../components/LeafletDrawMapElement";
3
+ import type { IntegratedToolEventEmitter, IntegratedToolHooks, ToolButtonConfig, ToolToolbarGroupConfig } from "../types/public";
4
4
  type Primitive = string | number | boolean | null | undefined;
5
5
  type LeafletMode = "external" | "bundled";
6
6
  export interface ReactLeafletGeoKitProps {
@@ -23,6 +23,10 @@ export interface ReactLeafletGeoKitProps {
23
23
  toolHooks?: IntegratedToolHooks;
24
24
  /** Optional integrated tool event emitter. */
25
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;
26
30
  /** Initial GeoJSON text to load once on ready. */
27
31
  initialGeoJSONText?: string;
28
32
  /** Called whenever draw/edit/delete/merge occurs, with latest serialized FeatureCollection. */
@@ -1,4 +1,4 @@
1
- import { type ReactLeafletGeoKitProps } from "@src/react/core";
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 "@src/index";
2
- import { type ReactLeafletGeoKitProps } from "@src/react/core";
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("@src/index").LeafletDrawMapElement | null>;
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 "@src/utils/logger";
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,93 @@ 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
+ }
34
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";
35
122
  export type IntegratedToolHooks = Partial<Record<IntegratedToolEventName, (detail: unknown) => void>>;
36
123
  export interface IntegratedToolEventEmitter {
@@ -126,6 +213,21 @@ export interface LeafletDrawMapElementAPI {
126
213
  useExternalLeaflet?: boolean;
127
214
  /** Disable our CSS/icon injection when host supplies styles. */
128
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;
129
231
  /** Optional injection of a pre-existing Leaflet namespace to use instead of bundled import. */
130
232
  leafletInstance?: typeof Leaflet;
131
233
  /** Optional per-tool hooks keyed by integrated tool event name. */
@@ -172,5 +274,17 @@ export interface LeafletDrawMapElementAPI {
172
274
  * Change the measurement system for the Leaflet ruler tool.
173
275
  */
174
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>;
175
289
  }
176
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.8.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/src/external.d.ts",
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"