@florasync/leaflet-geokit 0.8.3 → 0.9.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/ARCHITECTURE.md +195 -0
- package/CHANGELOG.md +8 -0
- package/README.md +146 -11
- package/custom-toolbar.html +165 -0
- package/dist/django/index.js +8993 -5090
- package/dist/django/index.js.map +1 -1
- package/dist/leaflet-geokit.es.js +21536 -5994
- package/dist/leaflet-geokit.es.js.map +1 -1
- package/dist/leaflet-geokit.external.es.js +18006 -2461
- package/dist/leaflet-geokit.external.es.js.map +1 -1
- package/dist/leaflet-geokit.umd.js +263 -60
- package/dist/leaflet-geokit.umd.js.map +1 -1
- package/dist/preact/index-DCKj0r6a.js +8545 -0
- package/dist/preact/index-DCKj0r6a.js.map +1 -0
- package/dist/preact/index.js +1 -1
- package/dist/preact-bundled/index.js +9002 -5089
- package/dist/preact-bundled/index.js.map +1 -1
- package/dist/react/index-DCKj0r6a.js +8545 -0
- package/dist/react/index-DCKj0r6a.js.map +1 -0
- package/dist/react/index.js +1 -1
- package/dist/react-bundled/index.js +9040 -5127
- package/dist/react-bundled/index.js.map +1 -1
- package/dist/types/components/LeafletDrawMapElement.d.ts +42 -3
- package/dist/types/django/index.d.ts +2 -2
- package/dist/types/external.d.ts +9 -3
- package/dist/types/index.d.ts +9 -3
- package/dist/types/lib/FeatureStore.d.ts +2 -2
- package/dist/types/lib/LayerRegistry.d.ts +19 -0
- package/dist/types/lib/MapController.d.ts +95 -5
- package/dist/types/lib/draw/L.Draw.Move.d.ts +1 -0
- package/dist/types/lib/draw/move-pointer.d.ts +12 -0
- package/dist/types/lib/layer-cake/LayerCakeManager.d.ts +10 -2
- package/dist/types/lib/layer-style-panel.d.ts +3 -0
- package/dist/types/lib/marker-icons.d.ts +1 -1
- package/dist/types/lib/providers.d.ts +64 -0
- package/dist/types/lib/snapping.d.ts +30 -0
- package/dist/types/lib/tool-buttons.d.ts +3 -1
- package/dist/types/lib/tool-capabilities.d.ts +27 -0
- package/dist/types/lib/toolbar-accessibility.d.ts +3 -0
- package/dist/types/lib/toolbar-layout.d.ts +14 -0
- package/dist/types/lib/toolbar-styles.d.ts +2 -0
- package/dist/types/preact/core.d.ts +2 -2
- package/dist/types/preact/index.d.ts +2 -2
- package/dist/types/preact-bundled/index.d.ts +3 -3
- package/dist/types/react/core.d.ts +2 -2
- package/dist/types/react/index.d.ts +2 -2
- package/dist/types/react-bundled/index.d.ts +3 -3
- package/dist/types/types/events.d.ts +15 -1
- package/dist/types/types/layers.d.ts +65 -0
- package/dist/types/types/public.d.ts +160 -5
- package/dist/types/utils/geojson-pipeline.d.ts +51 -0
- package/dist/types/utils/geojson.d.ts +15 -2
- package/dist/types/utils/grower-geometry.d.ts +107 -0
- package/docs/accessibility.md +142 -0
- package/docs/api-reference.md +249 -0
- package/docs/custom-toolbar.md +168 -0
- package/docs/diagnostics.md +216 -0
- package/docs/geojson-pipelines.md +145 -0
- package/docs/google-maps-adapter-spike.md +77 -0
- package/docs/grower-geometry.md +237 -0
- package/docs/grower-measurement.md +23 -0
- package/docs/integration-recipes.md +301 -0
- package/docs/layers.md +136 -0
- package/docs/providers.md +191 -0
- package/docs/release-verification.md +75 -0
- package/docs/shims/django.md +102 -0
- package/docs/shims/preact.md +98 -0
- package/docs/shims/react.md +98 -0
- package/docs/snapping-and-measurements.md +42 -0
- package/docs/tool-capabilities.md +131 -0
- package/docs/tool-lifecycle.md +124 -0
- package/docs/toolbar-layout.md +158 -0
- package/docs/toolbar-styling.md +118 -0
- package/package.json +35 -3
- package/dist/preact/index-BMfJn-mD.js +0 -4632
- package/dist/preact/index-BMfJn-mD.js.map +0 -1
- package/dist/react/index-BMfJn-mD.js +0 -4632
- package/dist/react/index-BMfJn-mD.js.map +0 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Toolbar styling contract v2
|
|
2
|
+
|
|
3
|
+
Managed `toolbarGroups` support host-native styling without shadowRoot access or
|
|
4
|
+
positional Leaflet selectors. See README for pure CSS, JS-only and mixed examples,
|
|
5
|
+
and `irrigation-draw-mode.html` for live examples. Existing APIs remain supported.
|
|
6
|
+
|
|
7
|
+
## Parts and states
|
|
8
|
+
|
|
9
|
+
| Part | Surface |
|
|
10
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
11
|
+
| `host`, `map` | Both name the internal map-sized surface. Style the actual custom-element box with `leaflet-geokit` itself. |
|
|
12
|
+
| `toolbar-group` | Each configured toolbar container. |
|
|
13
|
+
| `toolbar-button` | Tool buttons (also exposed on discovered native Leaflet controls). Full visual replacement applies to managed group buttons. |
|
|
14
|
+
| `icon` | Custom/fallback icon wrapper; inherits color for currentColor SVGs. |
|
|
15
|
+
| `popover` | Open guidance dialog; position follows the trigger. |
|
|
16
|
+
| `active` | Additional part on managed draw/edit mode buttons while active, reset on completion/cancel/deactivation. |
|
|
17
|
+
| `disabled` | Additional part on managed buttons configured with disabled: true. |
|
|
18
|
+
| `badge`, `tooltip` | Decorative badge and visible hover/focus tooltip wrappers. |
|
|
19
|
+
|
|
20
|
+
Native Leaflet sprite/visibility compatibility rules are retained. Disabled config
|
|
21
|
+
applies only to managed buttons, not the imperative `activateTool` API. Actions
|
|
22
|
+
such as Save are not persistent selected modes. Active represents draw/edit modes;
|
|
23
|
+
ruler and host-owned panels retain their own existing state/behavior.
|
|
24
|
+
|
|
25
|
+
Defaults include 44px buttons, hover background, a focus outline, inset active ring,
|
|
26
|
+
and dashed disabled border plus opacity. Keep these affordances visible when
|
|
27
|
+
replacing styles. Disabled native buttons skip Tab and cannot trigger actions.
|
|
28
|
+
Tooltips and badges are decorative (`aria-hidden`): include essential information
|
|
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
|
+
|
|
32
|
+
## CSS custom properties
|
|
33
|
+
|
|
34
|
+
Tokens inherit from the custom element. Lengths accept CSS units. Internal
|
|
35
|
+
`--_geokit-*` config fallbacks are private, not theme APIs. Public tokens override
|
|
36
|
+
JS visual defaults; `::part` rules can replace properties outright. `themeCss`
|
|
37
|
+
and `theme-url` can scope tokens via stable data attributes. No managed button,
|
|
38
|
+
group or popover visual declaration uses `!important`.
|
|
39
|
+
|
|
40
|
+
| Public token(s) | Default |
|
|
41
|
+
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
42
|
+
| `--geokit-tool-size`, `--geokit-tool-radius` | `44px`, `12px` |
|
|
43
|
+
| `--geokit-tool-background`, `--geokit-tool-color` | `#fff`, `#1f5134` |
|
|
44
|
+
| `--geokit-tool-border`, `--geokit-tool-shadow` | `1px solid rgba(15,23,18,.18)`, `0 2px 6px rgba(15,23,18,.16)` |
|
|
45
|
+
| `--geokit-tool-hover-background` | `#f0f8ed` |
|
|
46
|
+
| `--geokit-tool-active-background`, `--geokit-tool-active-color` | `#dceddf`, `#16452b` |
|
|
47
|
+
| `--geokit-tool-disabled-opacity`, `--geokit-tool-focus-ring` | `.5`, `2px solid #2f8f5f` |
|
|
48
|
+
| `--geokit-toolbar-gap`, `--geokit-toolbar-direction` | group gap or `6px`; group orientation mapped to `row`/`column` |
|
|
49
|
+
| `--geokit-toolbar-offset-x`, `--geokit-toolbar-offset-y` | group offset or `10px` each |
|
|
50
|
+
| `--geokit-toolbar-padding`, `--geokit-toolbar-radius` | `6px`, `16px` |
|
|
51
|
+
| `--geokit-toolbar-background`, `--geokit-toolbar-border` | `rgba(255,255,255,.94)`, `1px solid rgba(15,23,18,.16)` |
|
|
52
|
+
| `--geokit-toolbar-shadow`, `--geokit-toolbar-z-index` | `0 1px 5px rgba(0,0,0,.35)`, `1000` |
|
|
53
|
+
| `--geokit-icon-size` | configured iconSize (width/height), otherwise `20px` managed / `18px` custom native icons |
|
|
54
|
+
| `--geokit-popover-background`, `--geokit-popover-color` | `#fff`, `#163323` |
|
|
55
|
+
| `--geokit-popover-border`, `--geokit-popover-radius` | `1px solid rgba(0,0,0,.22)`, `8px` |
|
|
56
|
+
| `--geokit-popover-shadow`, `--geokit-popover-z-index` | `0 8px 24px rgba(0,0,0,.24)`, `10001` |
|
|
57
|
+
| `--geokit-popover-padding`, `--geokit-popover-max-width`, `--geokit-popover-font` | `10px 12px`, `260px`, `13px system-ui, sans-serif` |
|
|
58
|
+
| `--geokit-badge-background`, `--geokit-badge-color`, `--geokit-badge-radius` | `#1f5134`, `#fff`, `8px` |
|
|
59
|
+
| `--geokit-tooltip-background`, `--geokit-tooltip-color`, `--geokit-tooltip-radius` | `#163323`, `#fff`, `4px` |
|
|
60
|
+
|
|
61
|
+
## Placement and data attributes
|
|
62
|
+
|
|
63
|
+
`position` supports `topleft`, `topright`, `bottomleft`, `bottomright`.
|
|
64
|
+
`orientation` is `vertical` (default) or `horizontal`; `gap` is a finite,
|
|
65
|
+
nonnegative pixel value. Offsets are `[x,y]` nonnegative pixels. Each group has
|
|
66
|
+
independent settings. CSS direction overrides visual flow only; use config for
|
|
67
|
+
semantic orientation too.
|
|
68
|
+
|
|
69
|
+
Native draw/ruler controls hide if **any** group leaves `hideDefaultToolbar`
|
|
70
|
+
true/default; set it false on **all** groups to retain native controls. Removing
|
|
71
|
+
groups restores their previous display styles.
|
|
72
|
+
|
|
73
|
+
Stable data hooks:
|
|
74
|
+
|
|
75
|
+
- Groups: `data-geokit-managed-toolbar`, `data-geokit-toolbar-group`,
|
|
76
|
+
`data-geokit-toolbar-position`, `data-geokit-toolbar-orientation`.
|
|
77
|
+
- Managed buttons: `data-geokit-tool`, `data-geokit-toolbar-group`,
|
|
78
|
+
`data-geokit-toolbar-position`, `data-geokit-tool-instance`,
|
|
79
|
+
`data-geokit-active`, `data-geokit-disabled`.
|
|
80
|
+
- Popovers: `data-geokit-tool-popover`, `data-geokit-tool`,
|
|
81
|
+
`data-geokit-toolbar-group`, `data-geokit-tool-instance`.
|
|
82
|
+
|
|
83
|
+
Tool data names keep the existing kebab-case mapping (`layer-cake`, `layer-style`,
|
|
84
|
+
`measurement-settings`). `::part` cannot select descendants or filter by these
|
|
85
|
+
attributes: use a host selector for whole instances, and `themeCss`/`theme-url`
|
|
86
|
+
for per-group/per-tool rules. Config setters rerender managed groups; public parts
|
|
87
|
+
and tokens remain effective after rerender.
|
|
88
|
+
|
|
89
|
+
## Named slots
|
|
90
|
+
|
|
91
|
+
Managed buttons provide `{groupId}-{toolKey}-{zeroBasedIndex}-icon`, `-badge`,
|
|
92
|
+
and `-tooltip`. Tool keys use config spelling (`layerStyle`, not `layer-style`).
|
|
93
|
+
For `{ id: "care", tools: ["polygon", "save"] }`:
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<leaflet-geokit>
|
|
97
|
+
<span slot="care-save-1-icon" aria-hidden="true">S</span>
|
|
98
|
+
<span slot="care-save-1-badge">2</span>
|
|
99
|
+
<span slot="care-save-1-tooltip">Save growing spaces</span>
|
|
100
|
+
</leaflet-geokit>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Slots replace configured/default content, not the button or its accessible label.
|
|
104
|
+
Use noninteractive decorative content only. Keep group IDs unique; indices allow
|
|
105
|
+
duplicate tools to have independent content. Reordering tools changes slot names.
|
|
106
|
+
Framework hosts may still use `renderIcon` and popover renderers instead.
|
|
107
|
+
|
|
108
|
+
## Verification
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
npm run test:unit:focused -- tests/toolbar-contract.spec.ts tests/element.spec.ts tests/component-events.spec.ts tests/map-controller.spec.ts
|
|
112
|
+
npm run test:e2e -- --project=chromium e2e/toolbar-contract.spec.ts e2e/irrigation-draw-mode.spec.ts
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The current project is `chromium`, not the historical `leaflet` name. Use a
|
|
116
|
+
user-writable `--output` directory if existing Playwright artifacts belong to
|
|
117
|
+
another user. The focused unit command disables repo-wide coverage thresholds;
|
|
118
|
+
it does not replace the full coverage gate for a release.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@florasync/leaflet-geokit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|
|
@@ -41,6 +41,26 @@
|
|
|
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",
|
|
53
|
+
"docs/toolbar-styling.md",
|
|
54
|
+
"docs/accessibility.md",
|
|
55
|
+
"docs/geojson-pipelines.md",
|
|
56
|
+
"docs/tool-lifecycle.md",
|
|
57
|
+
"docs/tool-capabilities.md",
|
|
58
|
+
"docs/layers.md",
|
|
59
|
+
"docs/providers.md",
|
|
60
|
+
"docs/google-maps-adapter-spike.md",
|
|
61
|
+
"docs/grower-geometry.md",
|
|
62
|
+
"docs/grower-measurement.md",
|
|
63
|
+
"docs/snapping-and-measurements.md",
|
|
44
64
|
"CHANGELOG.md"
|
|
45
65
|
],
|
|
46
66
|
"sideEffects": [
|
|
@@ -59,7 +79,7 @@
|
|
|
59
79
|
"homepage": "https://github.com/FloraSync/leaflet-geokit#readme",
|
|
60
80
|
"scripts": {
|
|
61
81
|
"dev": "vite",
|
|
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",
|
|
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",
|
|
63
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",
|
|
64
84
|
"build:analyze:main": "BUNDLE_ANALYZE=1 BUNDLE_ANALYZE_REPORT=dist/stats/main.html vite build",
|
|
65
85
|
"build:analyze:external": "BUNDLE_ANALYZE=1 BUNDLE_ANALYZE_REPORT=dist/stats/external.html vite build -c vite.config.external.ts",
|
|
@@ -86,7 +106,9 @@
|
|
|
86
106
|
"spec-kitty:doctor": "spec-kitty doctor",
|
|
87
107
|
"prepack": "npm run build",
|
|
88
108
|
"pack:dry": "npm pack --dry-run",
|
|
89
|
-
"
|
|
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",
|
|
111
|
+
"test:e2e:snapping": "playwright test --config=playwright.snapping.config.ts"
|
|
90
112
|
},
|
|
91
113
|
"keywords": [
|
|
92
114
|
"leaflet",
|
|
@@ -104,6 +126,16 @@
|
|
|
104
126
|
"npm": ">=9"
|
|
105
127
|
},
|
|
106
128
|
"dependencies": {
|
|
129
|
+
"@turf/area": "^7.4.0",
|
|
130
|
+
"@turf/bbox": "^7.4.0",
|
|
131
|
+
"@turf/boolean-valid": "^7.4.0",
|
|
132
|
+
"@turf/buffer": "^7.4.0",
|
|
133
|
+
"@turf/centroid": "^7.4.0",
|
|
134
|
+
"@turf/kinks": "^7.4.0",
|
|
135
|
+
"@turf/line-offset": "^7.4.0",
|
|
136
|
+
"@turf/line-split": "^7.4.0",
|
|
137
|
+
"@turf/simplify": "^7.4.0",
|
|
138
|
+
"@turf/union": "^7.4.0",
|
|
107
139
|
"leaflet": "^1.9.4",
|
|
108
140
|
"leaflet-draw": "^1.0.4",
|
|
109
141
|
"leaflet-ruler": "^1.0.0",
|