@studiometa/ui-mapbox 2.0.0-alpha.0 → 2.0.0-alpha.2
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/README.md +22 -16
- package/dist/MapboxGeocoder.d.ts +48 -5
- package/dist/MapboxGeocoder.js +73 -15
- package/dist/MapboxGeocoder.js.map +1 -1
- package/dist/MapboxMap.js +1 -0
- package/dist/MapboxMap.js.map +1 -1
- package/dist/StoreLocator.js +1 -0
- package/dist/StoreLocator.js.map +1 -1
- package/dist/catalog.js +22 -11
- package/dist/catalog.js.map +1 -1
- package/dist/manifest.js +11 -11
- package/dist/manifest.js.map +1 -1
- package/dist/scripts/manifest-types.d.ts +5 -2
- package/package.json +7 -2
- package/skills/studiometa-ui-mapbox/SKILL.md +71 -0
- package/skills/studiometa-ui-mapbox/references/index.md +8 -0
- package/skills/studiometa-ui-mapbox/references/items/MapboxMap/examples.md +481 -0
- package/skills/studiometa-ui-mapbox/references/items/MapboxMap/index.md +102 -0
- package/skills/studiometa-ui-mapbox/references/items/MapboxMap/js-api.md +957 -0
- package/skills/studiometa-ui-mapbox/references/items/StoreLocator/examples.md +647 -0
- package/skills/studiometa-ui-mapbox/references/items/StoreLocator/index.md +135 -0
- package/skills/studiometa-ui-mapbox/references/items/StoreLocator/js-api.md +160 -0
package/dist/manifest.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
//#region src/manifest.ts
|
|
2
2
|
const manifest = {
|
|
3
3
|
MapboxCluster: {
|
|
4
|
-
mountStrategy: "
|
|
4
|
+
mountStrategy: "eager",
|
|
5
5
|
load: () => import("./MapboxCluster.js").then(({ MapboxCluster }) => MapboxCluster)
|
|
6
6
|
},
|
|
7
7
|
MapboxClusterItem: {
|
|
8
|
-
mountStrategy: "
|
|
8
|
+
mountStrategy: "eager",
|
|
9
9
|
load: () => import("./MapboxClusterItem.js").then(({ MapboxClusterItem }) => MapboxClusterItem)
|
|
10
10
|
},
|
|
11
11
|
MapboxFullscreenControl: {
|
|
12
|
-
mountStrategy: "
|
|
12
|
+
mountStrategy: "eager",
|
|
13
13
|
load: () => import("./MapboxFullscreenControl.js").then(({ MapboxFullscreenControl }) => MapboxFullscreenControl)
|
|
14
14
|
},
|
|
15
15
|
MapboxGeocoder: {
|
|
@@ -17,19 +17,19 @@ const manifest = {
|
|
|
17
17
|
load: () => import("./MapboxGeocoder.js").then(({ MapboxGeocoder }) => MapboxGeocoder)
|
|
18
18
|
},
|
|
19
19
|
MapboxGeolocateControl: {
|
|
20
|
-
mountStrategy: "
|
|
20
|
+
mountStrategy: "eager",
|
|
21
21
|
load: () => import("./MapboxGeolocateControl.js").then(({ MapboxGeolocateControl }) => MapboxGeolocateControl)
|
|
22
22
|
},
|
|
23
23
|
MapboxImage: {
|
|
24
|
-
mountStrategy: "
|
|
24
|
+
mountStrategy: "eager",
|
|
25
25
|
load: () => import("./MapboxImage.js").then(({ MapboxImage }) => MapboxImage)
|
|
26
26
|
},
|
|
27
27
|
MapboxImages: {
|
|
28
|
-
mountStrategy: "
|
|
28
|
+
mountStrategy: "eager",
|
|
29
29
|
load: () => import("./MapboxImages.js").then(({ MapboxImages }) => MapboxImages)
|
|
30
30
|
},
|
|
31
31
|
MapboxLayer: {
|
|
32
|
-
mountStrategy: "
|
|
32
|
+
mountStrategy: "eager",
|
|
33
33
|
load: () => import("./MapboxLayer.js").then(({ MapboxLayer }) => MapboxLayer)
|
|
34
34
|
},
|
|
35
35
|
MapboxMap: {
|
|
@@ -37,19 +37,19 @@ const manifest = {
|
|
|
37
37
|
load: () => import("./MapboxMap.js").then(({ MapboxMap }) => MapboxMap)
|
|
38
38
|
},
|
|
39
39
|
MapboxMarker: {
|
|
40
|
-
mountStrategy: "
|
|
40
|
+
mountStrategy: "eager",
|
|
41
41
|
load: () => import("./MapboxMarker.js").then(({ MapboxMarker }) => MapboxMarker)
|
|
42
42
|
},
|
|
43
43
|
MapboxNavigationControl: {
|
|
44
|
-
mountStrategy: "
|
|
44
|
+
mountStrategy: "eager",
|
|
45
45
|
load: () => import("./MapboxNavigationControl.js").then(({ MapboxNavigationControl }) => MapboxNavigationControl)
|
|
46
46
|
},
|
|
47
47
|
MapboxPopup: {
|
|
48
|
-
mountStrategy: "
|
|
48
|
+
mountStrategy: "eager",
|
|
49
49
|
load: () => import("./MapboxPopup.js").then(({ MapboxPopup }) => MapboxPopup)
|
|
50
50
|
},
|
|
51
51
|
MapboxSource: {
|
|
52
|
-
mountStrategy: "
|
|
52
|
+
mountStrategy: "eager",
|
|
53
53
|
load: () => import("./MapboxSource.js").then(({ MapboxSource }) => MapboxSource)
|
|
54
54
|
},
|
|
55
55
|
StoreLocator: {
|
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.ts"],"sourcesContent":["// This file is generated by scripts/generate-manifests.ts. Do not edit.\nimport type { ComponentManifest } from '@studiometa/js-toolkit';\n\nexport const manifest: ComponentManifest = {\n MapboxCluster: {\n mountStrategy: '
|
|
1
|
+
{"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.ts"],"sourcesContent":["// This file is generated by scripts/generate-manifests.ts. Do not edit.\nimport type { ComponentManifest } from '@studiometa/js-toolkit';\n\nexport const manifest: ComponentManifest = {\n MapboxCluster: {\n mountStrategy: 'eager',\n load: () => import('./MapboxCluster.js').then(({ MapboxCluster }) => MapboxCluster),\n },\n MapboxClusterItem: {\n mountStrategy: 'eager',\n load: () => import('./MapboxClusterItem.js').then(({ MapboxClusterItem }) => MapboxClusterItem),\n },\n MapboxFullscreenControl: {\n mountStrategy: 'eager',\n load: () =>\n import('./MapboxFullscreenControl.js').then(\n ({ MapboxFullscreenControl }) => MapboxFullscreenControl,\n ),\n },\n MapboxGeocoder: {\n mountStrategy: 'visible',\n load: () => import('./MapboxGeocoder.js').then(({ MapboxGeocoder }) => MapboxGeocoder),\n },\n MapboxGeolocateControl: {\n mountStrategy: 'eager',\n load: () =>\n import('./MapboxGeolocateControl.js').then(\n ({ MapboxGeolocateControl }) => MapboxGeolocateControl,\n ),\n },\n MapboxImage: {\n mountStrategy: 'eager',\n load: () => import('./MapboxImage.js').then(({ MapboxImage }) => MapboxImage),\n },\n MapboxImages: {\n mountStrategy: 'eager',\n load: () => import('./MapboxImages.js').then(({ MapboxImages }) => MapboxImages),\n },\n MapboxLayer: {\n mountStrategy: 'eager',\n load: () => import('./MapboxLayer.js').then(({ MapboxLayer }) => MapboxLayer),\n },\n MapboxMap: {\n mountStrategy: 'visible',\n load: () => import('./MapboxMap.js').then(({ MapboxMap }) => MapboxMap),\n },\n MapboxMarker: {\n mountStrategy: 'eager',\n load: () => import('./MapboxMarker.js').then(({ MapboxMarker }) => MapboxMarker),\n },\n MapboxNavigationControl: {\n mountStrategy: 'eager',\n load: () =>\n import('./MapboxNavigationControl.js').then(\n ({ MapboxNavigationControl }) => MapboxNavigationControl,\n ),\n },\n MapboxPopup: {\n mountStrategy: 'eager',\n load: () => import('./MapboxPopup.js').then(({ MapboxPopup }) => MapboxPopup),\n },\n MapboxSource: {\n mountStrategy: 'eager',\n load: () => import('./MapboxSource.js').then(({ MapboxSource }) => MapboxSource),\n },\n StoreLocator: {\n mountStrategy: 'visible',\n load: () => import('./StoreLocator.js').then(({ StoreLocator }) => StoreLocator),\n },\n};\n"],"mappings":";AAGA,MAAa,WAA8B;CACzC,eAAe;EACb,eAAe;EACf,YAAY,OAAO,sBAAsB,MAAM,EAAE,oBAAoB,cAAc;EACpF;CACD,mBAAmB;EACjB,eAAe;EACf,YAAY,OAAO,0BAA0B,MAAM,EAAE,wBAAwB,kBAAkB;EAChG;CACD,yBAAyB;EACvB,eAAe;EACf,YACE,OAAO,gCAAgC,MACpC,EAAE,8BAA8B,wBAClC;EACJ;CACD,gBAAgB;EACd,eAAe;EACf,YAAY,OAAO,uBAAuB,MAAM,EAAE,qBAAqB,eAAe;EACvF;CACD,wBAAwB;EACtB,eAAe;EACf,YACE,OAAO,+BAA+B,MACnC,EAAE,6BAA6B,uBACjC;EACJ;CACD,aAAa;EACX,eAAe;EACf,YAAY,OAAO,oBAAoB,MAAM,EAAE,kBAAkB,YAAY;EAC9E;CACD,cAAc;EACZ,eAAe;EACf,YAAY,OAAO,qBAAqB,MAAM,EAAE,mBAAmB,aAAa;EACjF;CACD,aAAa;EACX,eAAe;EACf,YAAY,OAAO,oBAAoB,MAAM,EAAE,kBAAkB,YAAY;EAC9E;CACD,WAAW;EACT,eAAe;EACf,YAAY,OAAO,kBAAkB,MAAM,EAAE,gBAAgB,UAAU;EACxE;CACD,cAAc;EACZ,eAAe;EACf,YAAY,OAAO,qBAAqB,MAAM,EAAE,mBAAmB,aAAa;EACjF;CACD,yBAAyB;EACvB,eAAe;EACf,YACE,OAAO,gCAAgC,MACpC,EAAE,8BAA8B,wBAClC;EACJ;CACD,aAAa;EACX,eAAe;EACf,YAAY,OAAO,oBAAoB,MAAM,EAAE,kBAAkB,YAAY;EAC9E;CACD,cAAc;EACZ,eAAe;EACf,YAAY,OAAO,qBAAqB,MAAM,EAAE,mBAAmB,aAAa;EACjF;CACD,cAAc;EACZ,eAAe;EACf,YAAY,OAAO,qBAAqB,MAAM,EAAE,mBAAmB,aAAa;EACjF;CACF"}
|
|
@@ -11,7 +11,8 @@ import { MountStrategy } from "@studiometa/js-toolkit";
|
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* Curated authoring metadata for a single component, consumed by the manifest generator. The
|
|
14
|
-
* `subpath` and `exportName` default to the `token` when omitted
|
|
14
|
+
* `subpath` and `exportName` default to the `token` when omitted, and `strategy` defaults to the
|
|
15
|
+
* one the catalog declares for the whole package.
|
|
15
16
|
*/
|
|
16
17
|
interface CuratedComponentMetadata {
|
|
17
18
|
token: string;
|
|
@@ -21,10 +22,12 @@ interface CuratedComponentMetadata {
|
|
|
21
22
|
integrations?: readonly string[];
|
|
22
23
|
subpath?: string;
|
|
23
24
|
exportName?: string;
|
|
25
|
+
strategy?: MountStrategy;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* The authoring catalog for a component package: the list of its components, the default strategy
|
|
27
|
-
*
|
|
29
|
+
* a component inherits when it declares none of its own, and the abstract exports that are
|
|
30
|
+
* intentionally excluded from the manifest.
|
|
28
31
|
*/
|
|
29
32
|
interface ComponentCatalog {
|
|
30
33
|
packageName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiometa/ui-mapbox",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
4
|
"description": "Vanilla js-toolkit components to build Mapbox GL maps declaratively",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -119,7 +119,8 @@
|
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
"scripts": {
|
|
122
|
-
"build": "node scripts/build.js"
|
|
122
|
+
"build": "node scripts/build.js && npm run build:skills",
|
|
123
|
+
"build:skills": "node ../../scripts/build-skills.ts"
|
|
123
124
|
},
|
|
124
125
|
"repository": {
|
|
125
126
|
"type": "git",
|
|
@@ -158,7 +159,11 @@
|
|
|
158
159
|
},
|
|
159
160
|
"files": [
|
|
160
161
|
"dist",
|
|
162
|
+
"skills",
|
|
161
163
|
"README.md",
|
|
162
164
|
"LICENSE.md"
|
|
165
|
+
],
|
|
166
|
+
"skills": [
|
|
167
|
+
"npm:@studiometa/js-toolkit"
|
|
163
168
|
]
|
|
164
169
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: studiometa-ui-mapbox
|
|
3
|
+
description: Build Mapbox GL maps declaratively with @studiometa/ui-mapbox v2 — MapboxMap, MapboxMarker, MapboxPopup, MapboxSource, MapboxLayer, controls, MapboxGeocoder and StoreLocator on @studiometa/js-toolkit v4. Use when code imports @studiometa/ui-mapbox, when markup uses data-component="MapboxMap" or another Mapbox* component, or when a page needs an interactive map or a store locator.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @studiometa/ui-mapbox
|
|
7
|
+
|
|
8
|
+
`@studiometa/ui-mapbox` builds Mapbox GL maps from HTML. `MapboxMap` owns the map. Child components (markers, popups, sources, layers, controls) configure it from their attributes. `StoreLocator` is a complete store locator.
|
|
9
|
+
|
|
10
|
+
This skill matches the installed package version. Read the references in this folder before the online docs.
|
|
11
|
+
|
|
12
|
+
## References
|
|
13
|
+
|
|
14
|
+
- [references/index.md](references/index.md): the items of the package.
|
|
15
|
+
- `references/items/MapboxMap/`: the map and all its child components. `js-api.md` documents each component in one page.
|
|
16
|
+
- `references/items/StoreLocator/`: the store locator.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @studiometa/ui-mapbox mapbox-gl
|
|
22
|
+
# Only for MapboxGeocoder:
|
|
23
|
+
npm install @mapbox/mapbox-gl-geocoder
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Include the `mapbox-gl` stylesheet, or the map does not render correctly.
|
|
27
|
+
|
|
28
|
+
## Register and author
|
|
29
|
+
|
|
30
|
+
Register each component the page uses. The order does not matter: each child finds its parent map.
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { registerComponents } from '@studiometa/js-toolkit';
|
|
34
|
+
import { MapboxMap, MapboxMarker, MapboxPopup } from '@studiometa/ui-mapbox';
|
|
35
|
+
|
|
36
|
+
registerComponents(MapboxMap, MapboxMarker, MapboxPopup);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<div
|
|
41
|
+
data-component="MapboxMap"
|
|
42
|
+
data-option-access-token="pk.your-access-token"
|
|
43
|
+
data-option-zoom="10"
|
|
44
|
+
data-option-center="[2.3522, 48.8566]">
|
|
45
|
+
<div data-ref="container" class="h-96 w-full"></div>
|
|
46
|
+
<div hidden data-component="MapboxMarker" data-option-lng-lat="[2.3522, 48.8566]"></div>
|
|
47
|
+
</div>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- Coordinates are `[lng, lat]` JSON arrays, as in Mapbox GL.
|
|
51
|
+
- Put `hidden` on child components that render nothing (markers, sources, layers). Do not put `hidden` on `MapboxGeocoder`: a hidden element never loads with the autoloader.
|
|
52
|
+
- `MapboxMap` re-emits the map events with a `map-` prefix. Handle them in a parent with `onMapboxMapMapClick`, `onMapboxMapMapLoad`…
|
|
53
|
+
- The `@studiometa/ui-mapbox/autoload` entry registers all components and loads them on demand. `MapboxMap`, `StoreLocator` and `MapboxGeocoder` wait until they are near the viewport.
|
|
54
|
+
|
|
55
|
+
## Loading mapbox-gl
|
|
56
|
+
|
|
57
|
+
`mapbox-gl` (about 230 kB gzipped) loads with a dynamic `import()` when the first map mounts. Do not import it in the main bundle. To use a specific build (a CSP-safe worker, an import map, a CDN), inject it once before the components mount:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import mapboxgl from 'mapbox-gl';
|
|
61
|
+
import { provideMapboxGl } from '@studiometa/ui-mapbox';
|
|
62
|
+
|
|
63
|
+
provideMapboxGl(mapboxgl);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`provideMapboxGeocoder()` does the same for `@mapbox/mapbox-gl-geocoder`.
|
|
67
|
+
|
|
68
|
+
## Related skills
|
|
69
|
+
|
|
70
|
+
- `studiometa-ui`: `Action`, `Fetch`, the `Data*` components and the shared markup rules.
|
|
71
|
+
- `studiometa-js-toolkit`: the `Base` class and the component lifecycle.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# @studiometa/ui-mapbox reference
|
|
2
|
+
|
|
3
|
+
Each item folder holds `index.md` (usage), `js-api.md` or `twig-api.md` (API) and `examples.md` when the docs have them.
|
|
4
|
+
|
|
5
|
+
| Item | Kind | Summary |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| [MapboxMap](items/MapboxMap/index.md) | component | Compose declarative Mapbox maps from maps, controls, data, markers, and clusters. |
|
|
8
|
+
| [StoreLocator](items/StoreLocator/index.md) | component | Orchestrate a Mapbox cluster into a searchable, selectable store locator. |
|