@florasync/leaflet-geokit 0.9.0 → 0.10.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 (61) hide show
  1. package/ARCHITECTURE.md +195 -0
  2. package/CHANGELOG.md +5 -0
  3. package/README.md +7 -1
  4. package/custom-toolbar.html +165 -0
  5. package/dist/django/index.js +734 -734
  6. package/dist/django/index.js.map +1 -1
  7. package/dist/leaflet-geokit.es.js +1704 -1704
  8. package/dist/leaflet-geokit.es.js.map +1 -1
  9. package/dist/leaflet-geokit.external.es.js +1501 -1496
  10. package/dist/leaflet-geokit.external.es.js.map +1 -1
  11. package/dist/leaflet-geokit.umd.js +11 -14
  12. package/dist/leaflet-geokit.umd.js.map +1 -1
  13. package/dist/preact/{index-DCKj0r6a.js → index-Z22Un5Tg.js} +474 -469
  14. package/dist/preact/index-Z22Un5Tg.js.map +1 -0
  15. package/dist/preact/index.js +1 -1
  16. package/dist/preact-bundled/index.js +731 -731
  17. package/dist/preact-bundled/index.js.map +1 -1
  18. package/dist/react/{index-DCKj0r6a.js → index-Z22Un5Tg.js} +474 -469
  19. package/dist/react/index-Z22Un5Tg.js.map +1 -0
  20. package/dist/react/index.js +1 -1
  21. package/dist/react-bundled/index.js +731 -731
  22. package/dist/react-bundled/index.js.map +1 -1
  23. package/dist/types/components/LeafletDrawMapElement.d.ts +6 -6
  24. package/dist/types/django/index.d.ts +2 -2
  25. package/dist/types/external.d.ts +9 -9
  26. package/dist/types/index.d.ts +9 -9
  27. package/dist/types/lib/FeatureStore.d.ts +2 -2
  28. package/dist/types/lib/LayerRegistry.d.ts +1 -1
  29. package/dist/types/lib/MapController.d.ts +8 -8
  30. package/dist/types/lib/layer-cake/LayerCakeManager.d.ts +2 -2
  31. package/dist/types/lib/layer-style-panel.d.ts +1 -1
  32. package/dist/types/lib/marker-icons.d.ts +1 -1
  33. package/dist/types/lib/providers.d.ts +1 -1
  34. package/dist/types/lib/snapping.d.ts +1 -1
  35. package/dist/types/lib/tool-buttons.d.ts +1 -1
  36. package/dist/types/lib/tool-capabilities.d.ts +1 -1
  37. package/dist/types/lib/toolbar-layout.d.ts +1 -1
  38. package/dist/types/preact/core.d.ts +2 -2
  39. package/dist/types/preact/index.d.ts +2 -2
  40. package/dist/types/preact-bundled/index.d.ts +3 -3
  41. package/dist/types/react/core.d.ts +2 -2
  42. package/dist/types/react/index.d.ts +2 -2
  43. package/dist/types/react-bundled/index.d.ts +3 -3
  44. package/dist/types/types/events.d.ts +1 -1
  45. package/dist/types/types/public.d.ts +6 -6
  46. package/dist/types/utils/geojson-pipeline.d.ts +1 -1
  47. package/dist/types/utils/geojson.d.ts +1 -1
  48. package/docs/api-reference.md +249 -0
  49. package/docs/custom-toolbar.md +168 -0
  50. package/docs/diagnostics.md +216 -0
  51. package/docs/grower-measurement.md +23 -0
  52. package/docs/integration-recipes.md +301 -0
  53. package/docs/release-verification.md +75 -0
  54. package/docs/shims/django.md +102 -0
  55. package/docs/shims/preact.md +98 -0
  56. package/docs/shims/react.md +98 -0
  57. package/docs/toolbar-layout.md +158 -0
  58. package/docs/toolbar-styling.md +2 -2
  59. package/package.json +15 -4
  60. package/dist/preact/index-DCKj0r6a.js.map +0 -1
  61. package/dist/react/index-DCKj0r6a.js.map +0 -1
@@ -0,0 +1,158 @@
1
+ # Responsive toolbar layout
2
+
3
+ The layout API is opt-in. Existing groups using `topleft`, `topright`,
4
+ `bottomleft`, `bottomright` (or no position) keep their absolute corner placement,
5
+ orientation, gap, and exact offsets. Existing styling tokens, parts, named icon /
6
+ badge / tooltip slots and tool events continue to work.
7
+
8
+ ## Configuration
9
+
10
+ ```ts
11
+ map.toolbarGroups = [
12
+ {
13
+ id: "draw",
14
+ tools: ["polygon", "rectangle", "marker", "select"],
15
+ preset: "responsive",
16
+ position: "topright",
17
+ orientation: "vertical",
18
+ order: 0,
19
+ overflow: "wrap",
20
+ offset: [10, 10],
21
+ responsive: {
22
+ breakpoint: 600,
23
+ position: "bottom-end",
24
+ orientation: "horizontal",
25
+ overflow: "scroll",
26
+ },
27
+ },
28
+ { id: "save", tools: ["save"], preset: "responsive", order: 1 },
29
+ ];
30
+ ```
31
+
32
+ - `preset: "zones"` opts into collision-safe placement without automatic movement.
33
+ - `preset: "responsive"` uses the desktop position (default `topright`) at map
34
+ widths >= 600 CSS pixels; below that it becomes a horizontal bottom-end sheet.
35
+ - `responsive` also opts in and accepts `breakpoint`, `position`, `orientation`,
36
+ `order`, `overflow`, and `offset`. It overrides base configuration below the
37
+ breakpoint; omitted mobile position/orientation default to bottom-end/horizontal.
38
+ - Named positions opt in without a preset: `top-start`, `top-end`, `bottom-start`,
39
+ `bottom-end`, `center-end`. Legacy corner aliases work inside either preset.
40
+ - `order` defaults to 0 and sorts groups within their zone (ties keep config order).
41
+ It does not change the order of tools within a group.
42
+ - `overflow: "wrap"` (default) wraps along the configured flex direction;
43
+ `"scroll"` retains a single row/column with native scrollbars. Both are bounded.
44
+ - At map widths below 600, zones occupy separate rows in one column, groups span
45
+ that column, and touch targets default to 48px. `--geokit-tool-size` and direct
46
+ button parts still override that size. The one-column safety breakpoint is
47
+ fixed, independent of the configurable movement breakpoint.
48
+
49
+ ## Host CSS, including shadow DOM
50
+
51
+ Group ids produce a named part `toolbar-group-ID` in addition to `toolbar-group`.
52
+ Characters other than letters, digits, underscore and hyphen become hyphens; use
53
+ simple unique ids to avoid part-name collisions. Existing legacy groups retain
54
+ exactly `part="toolbar-group"`; use `[part~="toolbar-group"]` in tests/themes that
55
+ must match both modes.
56
+
57
+ ```css
58
+ /* Opt in via preset: "zones", then CSS controls placement. */
59
+ leaflet-geokit::part(toolbar-group-draw) {
60
+ --geokit-toolbar-zone: top-end;
61
+ --geokit-toolbar-order: 2;
62
+ --geokit-toolbar-direction: column;
63
+ --geokit-toolbar-wrap: wrap;
64
+ }
65
+ @media (max-width: 600px) {
66
+ leaflet-geokit::part(toolbar-group-draw) {
67
+ --geokit-toolbar-zone: bottom-end;
68
+ --geokit-toolbar-direction: row;
69
+ --geokit-toolbar-order: -1;
70
+ }
71
+ }
72
+ leaflet-geokit {
73
+ --geokit-zone-gap: 8px;
74
+ }
75
+ ```
76
+
77
+ Configuration responds to **map width**; this CSS media-query example responds to
78
+ **viewport width**. CSS zone and order win over configuration. No shadowRoot access
79
+ is needed. `className` continues to support selectors in `themeCss`/`theme-url`, or
80
+ ordinary document selectors for externally managed Leaflet containers. Layout
81
+ styles are installed through the same runtime-independent toolbar style path.
82
+ Changes to host classes/styles, theme styles, viewport size and container size
83
+ schedule a coalesced layout pass. CSSOM `insertRule()` changes that do not mutate
84
+ style nodes should be followed by a host class change or resize.
85
+
86
+ Additional parts: `toolbar-layout`, `toolbar-zone`, `zone-top-start`, `zone-top-end`,
87
+ `zone-center-end`, `zone-bottom-start`, `zone-bottom-end`. Use parts for visual
88
+ styling; overriding their positioning/overflow can invalidate collision safety.
89
+
90
+ ## Collision, insets and overflow contract
91
+
92
+ The layout measures visible native Leaflet controls and reserves full top/bottom
93
+ strips, including zoom and attribution. Separate CSS grid cells prevent opposing
94
+ zones colliding; flex stacks prevent same-zone groups colliding. Only occupied
95
+ rows consume space. This deliberately sacrifices some empty corner space to keep
96
+ placement deterministic. Multiple groups share their cell's bounded height and
97
+ scroll when needed. Narrow rows are weighted by their group counts. When the
98
+ available native-chrome-free height is below 100px per group, vertical margins
99
+ collapse and the default zone gap becomes 4px to preserve usable tool space.
100
+ Focused tools are scrolled fully into view, including tools
101
+ that the browser's default focus scrolling would leave partially clipped.
102
+
103
+ Safe areas use `env(safe-area-inset-top/right/bottom/left, 0px)` in addition to
104
+ native-control strips. Hosts can override `--geokit-safe-area-top`,
105
+ `--geokit-safe-area-right`, `--geokit-safe-area-bottom`, and
106
+ `--geokit-safe-area-left` for embedded layouts/testing. Use `viewport-fit=cover`
107
+ when appropriate for the host's mobile viewport policy.
108
+
109
+ In zone mode offsets are nonnegative spacing **inside the allocated zone**, not
110
+ absolute map coordinates. Each axis is capped at 10% of its available dimension
111
+ so oversized offsets cannot remove access. `--geokit-toolbar-offset-x/y` override
112
+ configuration. Legacy groups still use exact map-relative offsets, including
113
+ `bottomleft` / `[25, 35]` => `left: 25px; bottom: 35px`.
114
+
115
+ Use zone mode for **all groups** when requiring collision safety. Legacy absolute
116
+ groups intentionally remain outside this layout; mixing them with zones or
117
+ adding arbitrary absolute host overlays does not provide collision guarantees.
118
+ Native-control strips must leave usable map height, and the host must provide a
119
+ nonzero map size. Extremely crowded layouts can require scrolling both a zone
120
+ and an individual toolbar. Popovers/tooltips retain their existing behavior; they
121
+ are not new grid occupants, and bounded toolbar overflow can clip tooltips/badges
122
+ outside the group (accessible button labels and named slots remain available).
123
+
124
+ ## Lifecycle and identity
125
+
126
+ Responsive rearrangement moves existing group/button nodes; it does not recreate
127
+ icons, slots or tool listeners. Keyboard focus is restored if moving a group
128
+ between zones detaches the focused node. Group ids and existing tool-instance ids
129
+ (`group:tool:index`) remain stable. Configuration rerender retains the existing
130
+ renderer semantics: DOM nodes may be recreated, but the same group/tool/index has
131
+ the same logical identity. Reordering the tools changes their index-based ids.
132
+ The layout owner's disconnected callback removes its resize/mutation observers,
133
+ window resize listener, focus listener and queued animation frame. No controller,
134
+ event bus or irrigation-tool lifecycle is replaced.
135
+
136
+ ## Verification / real harness
137
+
138
+ Open `/irrigation-draw-mode.html` using the repository Vite server and set the
139
+ public `toolbarGroups` property as above. The automated harness uses that same
140
+ page, real synthetic map tiles, public configuration and actual button clicks.
141
+
142
+ ```sh
143
+ npm run test:unit:focused -- tests/toolbar-layout.spec.ts tests/toolbar-contract.spec.ts
144
+ npm run typecheck
145
+ npm run test:e2e -- --config=playwright.layout.config.ts --output="$PAPERCLIP_RUN_SCRATCH_DIR/playwright-layout"
146
+ npm run build
147
+ ```
148
+
149
+ Outside Paperclip, replace the output path with a user-writable directory. The
150
+ dedicated Playwright config owns port 5183, refuses to reuse somebody else's
151
+ preview and disables HMR so concurrent edits cannot reset test state. Playwright
152
+ starts/stops this finite server; no background preview is left running. The
153
+ layout browser suite measures map/group/zoom/attribution rectangles, exercises
154
+ configuration and CSS movement in both resize directions, same-zone order,
155
+ all five zones, narrow-width wrapping/scrolling and access to every tool,
156
+ post-movement polygon/save interaction, teardown and rerender. Styling-contract
157
+ regressions retain exact legacy placement assertions. Real device notches are
158
+ not emulated; safe-area overrides test the same inset arithmetic in Chromium.
@@ -26,8 +26,8 @@ Defaults include 44px buttons, hover background, a focus outline, inset active r
26
26
  and dashed disabled border plus opacity. Keep these affordances visible when
27
27
  replacing styles. Disabled native buttons skip Tab and cannot trigger actions.
28
28
  Tooltips and badges are decorative (`aria-hidden`): include essential information
29
- in `ariaLabel` or accessible popover content. This slice does not introduce modal
30
- focus trapping or responsive zones/overflow.
29
+ in `ariaLabel` or accessible popover content. Popovers do not trap focus.
30
+ For implemented responsive zones/overflow, see [toolbar layout](toolbar-layout.md).
31
31
 
32
32
  ## CSS custom properties
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@florasync/leaflet-geokit",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
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",
@@ -41,6 +41,15 @@
41
41
  "dist",
42
42
  "LICENSE",
43
43
  "README.md",
44
+ "ARCHITECTURE.md",
45
+ "docs/api-reference.md",
46
+ "docs/custom-toolbar.md",
47
+ "docs/diagnostics.md",
48
+ "docs/integration-recipes.md",
49
+ "docs/release-verification.md",
50
+ "docs/toolbar-layout.md",
51
+ "docs/shims",
52
+ "custom-toolbar.html",
44
53
  "docs/toolbar-styling.md",
45
54
  "docs/accessibility.md",
46
55
  "docs/geojson-pipelines.md",
@@ -50,6 +59,7 @@
50
59
  "docs/providers.md",
51
60
  "docs/google-maps-adapter-spike.md",
52
61
  "docs/grower-geometry.md",
62
+ "docs/grower-measurement.md",
53
63
  "docs/snapping-and-measurements.md",
54
64
  "CHANGELOG.md"
55
65
  ],
@@ -69,7 +79,7 @@
69
79
  "homepage": "https://github.com/FloraSync/leaflet-geokit#readme",
70
80
  "scripts": {
71
81
  "dev": "vite",
72
- "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",
82
+ "build": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json --emitDeclarationOnly && tsc-alias -p tsconfig.build.json && node scripts/resolve-declaration-imports.mjs && 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",
73
83
  "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",
74
84
  "build:analyze:main": "BUNDLE_ANALYZE=1 BUNDLE_ANALYZE_REPORT=dist/stats/main.html vite build",
75
85
  "build:analyze:external": "BUNDLE_ANALYZE=1 BUNDLE_ANALYZE_REPORT=dist/stats/external.html vite build -c vite.config.external.ts",
@@ -96,7 +106,8 @@
96
106
  "spec-kitty:doctor": "spec-kitty doctor",
97
107
  "prepack": "npm run build",
98
108
  "pack:dry": "npm pack --dry-run",
99
- "release:dry": "npm run typecheck && npm run test:unit && npm run build && npm pack --dry-run",
109
+ "test:consumer": "node scripts/verify-package.mjs",
110
+ "release:dry": "npm run typecheck && npm run test:unit && npm run build && npm pack --dry-run && npm run test:consumer",
100
111
  "test:e2e:snapping": "playwright test --config=playwright.snapping.config.ts"
101
112
  },
102
113
  "keywords": [
@@ -167,7 +178,7 @@
167
178
  "globals": "^17.3.0",
168
179
  "happy-dom": "^20.6.3",
169
180
  "husky": "^9.1.7",
170
- "lint-staged": "^15.2.10",
181
+ "lint-staged": "^16.4.0",
171
182
  "preact": "^10.28.3",
172
183
  "prettier": "^3.3.2",
173
184
  "react": "^18.3.1",