@florasync/leaflet-geokit 0.8.3 → 0.9.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +140 -11
  3. package/dist/django/index.js +8993 -5090
  4. package/dist/django/index.js.map +1 -1
  5. package/dist/leaflet-geokit.es.js +21536 -5994
  6. package/dist/leaflet-geokit.es.js.map +1 -1
  7. package/dist/leaflet-geokit.external.es.js +18006 -2461
  8. package/dist/leaflet-geokit.external.es.js.map +1 -1
  9. package/dist/leaflet-geokit.umd.js +263 -60
  10. package/dist/leaflet-geokit.umd.js.map +1 -1
  11. package/dist/preact/index-DCKj0r6a.js +8545 -0
  12. package/dist/preact/index-DCKj0r6a.js.map +1 -0
  13. package/dist/preact/index.js +1 -1
  14. package/dist/preact-bundled/index.js +9002 -5089
  15. package/dist/preact-bundled/index.js.map +1 -1
  16. package/dist/react/index-DCKj0r6a.js +8545 -0
  17. package/dist/react/index-DCKj0r6a.js.map +1 -0
  18. package/dist/react/index.js +1 -1
  19. package/dist/react-bundled/index.js +9040 -5127
  20. package/dist/react-bundled/index.js.map +1 -1
  21. package/dist/types/components/LeafletDrawMapElement.d.ts +40 -1
  22. package/dist/types/external.d.ts +6 -0
  23. package/dist/types/index.d.ts +6 -0
  24. package/dist/types/lib/LayerRegistry.d.ts +19 -0
  25. package/dist/types/lib/MapController.d.ts +91 -1
  26. package/dist/types/lib/draw/L.Draw.Move.d.ts +1 -0
  27. package/dist/types/lib/draw/move-pointer.d.ts +12 -0
  28. package/dist/types/lib/layer-cake/LayerCakeManager.d.ts +9 -1
  29. package/dist/types/lib/layer-style-panel.d.ts +3 -0
  30. package/dist/types/lib/providers.d.ts +64 -0
  31. package/dist/types/lib/snapping.d.ts +30 -0
  32. package/dist/types/lib/tool-buttons.d.ts +2 -0
  33. package/dist/types/lib/tool-capabilities.d.ts +27 -0
  34. package/dist/types/lib/toolbar-accessibility.d.ts +3 -0
  35. package/dist/types/lib/toolbar-layout.d.ts +14 -0
  36. package/dist/types/lib/toolbar-styles.d.ts +2 -0
  37. package/dist/types/types/events.d.ts +14 -0
  38. package/dist/types/types/layers.d.ts +65 -0
  39. package/dist/types/types/public.d.ts +157 -2
  40. package/dist/types/utils/geojson-pipeline.d.ts +51 -0
  41. package/dist/types/utils/geojson.d.ts +15 -2
  42. package/dist/types/utils/grower-geometry.d.ts +107 -0
  43. package/docs/accessibility.md +142 -0
  44. package/docs/geojson-pipelines.md +145 -0
  45. package/docs/google-maps-adapter-spike.md +77 -0
  46. package/docs/grower-geometry.md +237 -0
  47. package/docs/layers.md +136 -0
  48. package/docs/providers.md +191 -0
  49. package/docs/snapping-and-measurements.md +42 -0
  50. package/docs/tool-capabilities.md +131 -0
  51. package/docs/tool-lifecycle.md +124 -0
  52. package/docs/toolbar-styling.md +118 -0
  53. package/package.json +23 -2
  54. package/dist/preact/index-BMfJn-mD.js +0 -4632
  55. package/dist/preact/index-BMfJn-mD.js.map +0 -1
  56. package/dist/react/index-BMfJn-mD.js +0 -4632
  57. package/dist/react/index-BMfJn-mD.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.9.0 - 2026-10-02
6
+
7
+ - Added host-controlled toolbar capabilities, lifecycle events, keyboard accessibility, responsive layout, and extensible styling for polished custom map controls.
8
+ - Added named layer registration, visibility and style management, provider adapters, and a layer-manager harness for application-owned layer workflows.
9
+ - Added GeoJSON validation and transformation pipelines, snapping and measurement primitives, grower-oriented geometry utilities, and public type coverage for the new APIs.
10
+ - Hardened pointer-driven feature movement and expanded unit and Playwright coverage across tool activation, touch geometry, accessibility, providers, layers, snapping, and consumer-facing contracts.
11
+ - Documented the new toolbar, layer, provider, GeoJSON, geometry, snapping, measurement, and Google Maps adapter surfaces.
12
+
5
13
  ## 0.8.3 - 2026-08-28
6
14
 
7
15
  - Upgraded `uuid` to a patched release so consumer audits no longer inherit GHSA-w5hq-g745-h8pq through GeoKit.
package/README.md CHANGED
@@ -14,7 +14,13 @@ Primary sources
14
14
 
15
15
  Documentation quick-links
16
16
 
17
+ - Provider v2 contracts, diagnostics, MapLibre/PMTiles shim and security: [docs/providers.md](docs/providers.md)
18
+ - Optional Google Maps adapter spike: [docs/google-maps-adapter-spike.md](docs/google-maps-adapter-spike.md)
19
+ - Validated GeoJSON adapters, metadata round trips, diff/patch: [docs/geojson-pipelines.md](docs/geojson-pipelines.md)
17
20
  - Architecture overview: [ARCHITECTURE.md](ARCHITECTURE.md)
21
+ - Public tool lifecycle: [docs/tool-lifecycle.md](docs/tool-lifecycle.md)
22
+ - Tool availability, disabled reasons and external button binding: [docs/tool-capabilities.md](docs/tool-capabilities.md)
23
+ - Named map layers, host-rendered styles and cake sessions: [docs/layers.md](docs/layers.md); run `npm run dev` and open `/layer-manager.html` for the live sidebar harness.
18
24
  - Dev harness (example): [index.html](index.html)
19
25
  - Unit tests: [tests/element.spec.ts](tests/element.spec.ts)
20
26
  - Vitest config: [vitest.config.ts](vitest.config.ts)
@@ -552,7 +558,7 @@ map!.toolbarGroups = toolbarGroups;
552
558
  Supported tool keys are `polygon`, `polyline`, `rectangle`, `circle`, `marker`,
553
559
  `layerCake`, `move`, `select`, `edit`, `delete`, `ruler`,
554
560
  `measurementSettings`, `layerStyle`, and `save`. `select` disables active draw/edit
555
- handlers; `layerStyle` emits a public trigger event for host-owned style panels;
561
+ handlers; `layerStyle` opens a preset panel (cancel `leaflet-geokit:layer-style-request` to render a host-owned panel instead);
556
562
  `save` emits `leaflet-draw:export` with the current editable GeoJSON for host
557
563
  persistence.
558
564
 
@@ -561,6 +567,79 @@ persistence.
561
567
  property to `undefined` to return to the attribute, or `null` to clear the
562
568
  programmatic config while keeping stable `data-geokit-tool` hooks.
563
569
 
570
+ #### Toolbar styling contract (v2)
571
+
572
+ See the [keyboard and accessibility contract](docs/accessibility.md) for toolbar
573
+ navigation, save/cancel commands, focus handling, announcements, contrast/motion
574
+ tokens, and the limits of the current touch verification.
575
+
576
+ Managed `toolbarGroups` use normal CSS rules, not inline `!important` visual
577
+ styles. Defaults are 44px buttons with visible hover, focus, active and disabled
578
+ states. Existing `toolButtonConfig`, `toolbarGroups`, `data-geokit-tool`,
579
+ `themeCss` and `theme-url` APIs remain supported in bundled and external runtimes.
580
+
581
+ Public parts: `host` and `map` (the internal map-sized surface), `toolbar-group`,
582
+ `toolbar-button`, `icon`, `popover`, `active`, `disabled`, `badge`, `tooltip`.
583
+ Style the actual element box with `leaflet-geokit`, and internals via `::part`:
584
+
585
+ ```css
586
+ /* Pure CSS overrides for existing configured groups. */
587
+ leaflet-geokit {
588
+ --geokit-tool-size: 48px;
589
+ --geokit-tool-radius: 8px;
590
+ --geokit-tool-background: #edf6ee;
591
+ --geokit-toolbar-gap: 10px;
592
+ --geokit-icon-size: 24px;
593
+ }
594
+ leaflet-geokit::part(toolbar-group) {
595
+ border: 2px solid #246b45;
596
+ }
597
+ leaflet-geokit::part(toolbar-button):focus-visible {
598
+ outline: 3px solid #246b45;
599
+ }
600
+ leaflet-geokit::part(active) {
601
+ color: #124124;
602
+ }
603
+ ```
604
+
605
+ ```ts
606
+ // JS config only: no custom stylesheet required.
607
+ map.toolbarGroups = [
608
+ {
609
+ id: "care",
610
+ tools: ["polygon", "save"],
611
+ position: "bottomleft",
612
+ offset: [16, 24],
613
+ orientation: "horizontal",
614
+ gap: 12,
615
+ hideDefaultToolbar: true,
616
+ },
617
+ ];
618
+ map.toolButtonConfig = {
619
+ polygon: { title: "Draw growing space", iconSize: [28, 28] },
620
+ save: { title: "Save", ariaLabel: "Save 2 growing spaces", badge: "2" },
621
+ };
622
+ ```
623
+
624
+ For mixed CSS + config, combine those examples: public tokens override config's
625
+ visual defaults (including gap and icon size); placement and behavior stay in JS.
626
+ Per-group/per-tool overrides belong in `themeCss` or `theme-url`:
627
+
628
+ ```ts
629
+ map.themeCss = `
630
+ [data-geokit-managed-toolbar][data-geokit-toolbar-group="care"] {
631
+ --geokit-toolbar-gap: 14px;
632
+ --geokit-tool-background: #edf6ee;
633
+ }
634
+ button[data-geokit-tool="save"] { --geokit-tool-radius: 50%; }
635
+ `;
636
+ ```
637
+
638
+ The [complete styling contract](docs/toolbar-styling.md)
639
+ documents all tokens/defaults, slots, state semantics, native-control boundaries,
640
+ and placement/visibility behavior. Try the default/CSS/config/mixed selector in
641
+ `irrigation-draw-mode.html`. Responsive zones and overflow are a separate slice.
642
+
564
643
  #### External Tool Triggers
565
644
 
566
645
  Outside DOM controls can activate any configured tool through the public custom
@@ -598,14 +677,31 @@ code to reach into Leaflet.draw toolbar internals. The legacy
598
677
  `{ action: "deactivate" }` or `{ active: false }` in its detail to use it as a
599
678
  deactivate request.
600
679
 
601
- GeoKit emits `leaflet-geokit:tool-trigger-requested`, then either
602
- `leaflet-geokit:tool-triggered` or
603
- `leaflet-geokit:tool-trigger-failed`. Event detail includes `tool`, `source`,
604
- `groupId`, `handled`, `timestamp`, and optional `error`.
605
-
606
- See `irrigation-draw-mode.html` for a working integration demo with custom
607
- icons, popovers, two toolbar groups, an external panel button, real polygon
608
- draw activation, and a custom save button.
680
+ The canonical public bus emits `leaflet-geokit:tool-command`,
681
+ `tool-commanded`, `tool-started`, `tool-completed`, `tool-cancelled`,
682
+ `tool-failed`, and `tool-state-changed`. Every phase uses exported
683
+ `ToolEventDetail` and preserves `source`, `groupId`, and `commandId`.
684
+ Committed geometry phases also contain feature ids and a GeoJSON snapshot.
685
+ All lifecycle events bubble and cross the component's Shadow DOM boundary.
686
+
687
+ Event-only hosts can dispatch `leaflet-geokit:tool-command` with
688
+ `{ tool, action?, source?, groupId?, commandId? }`. Activation is not
689
+ completion: interactive draw tools complete only when geometry is committed,
690
+ and LayerCake completes only when its manager saves. Action tools
691
+ (`save`, `layerStyle`, and `measurementSettings`) complete immediately
692
+ without replacing an active persistent tool.
693
+
694
+ The older `leaflet-geokit:tool-trigger-requested`,
695
+ `leaflet-geokit:tool-triggered`, and
696
+ `leaflet-geokit:tool-trigger-failed` events remain compatibility aliases and
697
+ now include `commandId` in addition to `tool`, `source`, `groupId`,
698
+ `handled`, `timestamp`, and optional `error`.
699
+
700
+ The [complete lifecycle contract](docs/tool-lifecycle.md) inventories all 14
701
+ tools, every activation path, ordering, switches/repeats, Escape/cancellation,
702
+ LayerCake continuation, and failure behavior. See
703
+ `irrigation-draw-mode.html` for outside start/stop/save/failure controls using
704
+ only public APIs.
609
705
 
610
706
  #### Programmatic Marker Icon Override
611
707
 
@@ -794,7 +890,9 @@ console.log("Imported features with IDs:", ids);
794
890
  ```javascript
795
891
  await map.loadGeoJSON({
796
892
  type: "FeatureCollection",
797
- features: [/* ... */],
893
+ features: [
894
+ /* ... */
895
+ ],
798
896
  });
799
897
  ```
800
898
 
@@ -830,7 +928,9 @@ await map.clearLayers();
830
928
  await map.updateFeature(featureId, {
831
929
  type: "Feature",
832
930
  properties: { name: "Updated" },
833
- geometry: {/* ... */},
931
+ geometry: {
932
+ /* ... */
933
+ },
834
934
  });
835
935
  ```
836
936
 
@@ -1489,6 +1589,35 @@ Versioning and releases
1489
1589
 
1490
1590
  ---
1491
1591
 
1592
+ ## Snapping, live measurements, and grower scale
1593
+
1594
+ The component keeps snapping backward-compatible by default: enable it explicitly
1595
+ with `snapping`. Modes are `vertex`, `edge`, `grid`, and `guide`; tolerance is
1596
+ measured in screen pixels. Grid spacing is physical WGS84 meters and
1597
+ `gridOrigin` is a fixed `[longitude, latitude]` anchor (default `[0, 0]`).
1598
+ Latitude nodes use ellipsoidal meridian distance and longitude nodes use the
1599
+ parallel scale at the snapped latitude. Grid snapping is supported inside
1600
+ ±89.9° latitude and is an editing/planning aid rather than survey accuracy.
1601
+ Guide candidates come from the current layer registry and must be visible.
1602
+
1603
+ ```ts
1604
+ map.snapping = {
1605
+ enabled: true,
1606
+ modes: ["vertex", "edge", "grid", "guide"],
1607
+ tolerancePx: 14,
1608
+ gridSizeMeters: 1,
1609
+ gridOrigin: [0, 0],
1610
+ };
1611
+ map.measurementOverlay = { enabled: true, autoScale: true };
1612
+ ```
1613
+
1614
+ The live overlay follows `setMeasurementUnits("metric" | "imperial")` and
1615
+ refreshes during draw/edit. Grower helpers and `GROWER_PRESETS` are exported from
1616
+ `src/index.ts` and `src/external.ts`; add generated guide features with
1617
+ `layer: { kind: "guide" }` to make them snap targets. Invalid helper operations
1618
+ return an actionable error result and do not alter existing layers. See
1619
+ [`docs/snapping-and-measurements.md`](docs/snapping-and-measurements.md).
1620
+
1492
1621
  ## License
1493
1622
 
1494
1623
  ## MIT