@studiometa/ui-mapbox 0.0.1 → 1.10.0-beta.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 (117) hide show
  1. package/AbstractMapboxControl.d.ts +53 -0
  2. package/AbstractMapboxControl.js +70 -0
  3. package/AbstractMapboxControl.js.map +1 -0
  4. package/AbstractMapboxMapChild.d.ts +229 -0
  5. package/AbstractMapboxMapChild.js +336 -0
  6. package/AbstractMapboxMapChild.js.map +1 -0
  7. package/LICENSE.md +110 -0
  8. package/MapboxCluster.d.ts +208 -0
  9. package/MapboxCluster.js +418 -0
  10. package/MapboxCluster.js.map +1 -0
  11. package/MapboxClusterItem.d.ts +130 -0
  12. package/MapboxClusterItem.js +182 -0
  13. package/MapboxClusterItem.js.map +1 -0
  14. package/MapboxFullscreenControl.d.ts +21 -0
  15. package/MapboxFullscreenControl.js +21 -0
  16. package/MapboxFullscreenControl.js.map +1 -0
  17. package/MapboxGeocoder.d.ts +64 -0
  18. package/MapboxGeocoder.js +80 -0
  19. package/MapboxGeocoder.js.map +1 -0
  20. package/MapboxGeolocateControl.d.ts +23 -0
  21. package/MapboxGeolocateControl.js +31 -0
  22. package/MapboxGeolocateControl.js.map +1 -0
  23. package/MapboxImage.d.ts +49 -0
  24. package/MapboxImage.js +83 -0
  25. package/MapboxImage.js.map +1 -0
  26. package/MapboxImages.d.ts +66 -0
  27. package/MapboxImages.js +95 -0
  28. package/MapboxImages.js.map +1 -0
  29. package/MapboxLayer.d.ts +99 -0
  30. package/MapboxLayer.js +148 -0
  31. package/MapboxLayer.js.map +1 -0
  32. package/MapboxMap.d.ts +64 -0
  33. package/MapboxMap.js +131 -0
  34. package/MapboxMap.js.map +1 -0
  35. package/MapboxMarker.d.ts +56 -0
  36. package/MapboxMarker.js +73 -0
  37. package/MapboxMarker.js.map +1 -0
  38. package/MapboxNavigationControl.d.ts +27 -0
  39. package/MapboxNavigationControl.js +28 -0
  40. package/MapboxNavigationControl.js.map +1 -0
  41. package/MapboxPopup.d.ts +51 -0
  42. package/MapboxPopup.js +76 -0
  43. package/MapboxPopup.js.map +1 -0
  44. package/MapboxSource.d.ts +68 -0
  45. package/MapboxSource.js +104 -0
  46. package/MapboxSource.js.map +1 -0
  47. package/README.md +85 -0
  48. package/StoreLocator.d.ts +323 -0
  49. package/StoreLocator.js +538 -0
  50. package/StoreLocator.js.map +1 -0
  51. package/catalog.d.ts +7 -0
  52. package/catalog.js +68 -0
  53. package/catalog.js.map +1 -0
  54. package/dependencies.d.ts +85 -0
  55. package/dependencies.js +84 -0
  56. package/dependencies.js.map +1 -0
  57. package/index.d.ts +18 -0
  58. package/index.js +19 -0
  59. package/index.js.map +1 -0
  60. package/manifest.d.ts +6 -0
  61. package/manifest.js +133 -0
  62. package/manifest.js.map +1 -0
  63. package/package.json +43 -3
  64. package/utils.d.ts +112 -0
  65. package/utils.js +143 -0
  66. package/utils.js.map +1 -0
  67. package/Claude-of-Duty/node_modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
  68. package/alfred-projects-cache.tsv +0 -137
  69. package/claude-501/-Users-titouanmathis--dotfiles/298a49f7-c4b3-4a50-9707-a9c0d0733e95/scratchpad/pptest/config.json +0 -1
  70. package/claude-501/-Users-titouanmathis--dotfiles/298a49f7-c4b3-4a50-9707-a9c0d0733e95/scratchpad/pptest/stub/herdr +0 -8
  71. package/claude-501/-Users-titouanmathis--dotfiles/7d127a50-a71a-411a-bc1f-15b070f909f9/tasks/bg1cckto6.output +0 -4
  72. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/after.toml +0 -298
  73. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/before.toml +0 -298
  74. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/extracted.txt +0 -36
  75. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/final.log +0 -496
  76. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/guard.sh +0 -18
  77. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/lock.check +0 -917
  78. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/mise-registry.json +0 -3827
  79. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/mise.lock.before +0 -917
  80. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/misetest/.config/mise/conf.d/extra.toml +0 -2
  81. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/misetest/.config/mise/mise.lock +0 -47
  82. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/misetest/mise.lock +0 -47
  83. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/misetest/mise.toml +0 -2
  84. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/.github/workflows/mise-check.yml +0 -188
  85. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/.github/workflows/renovate.yml +0 -62
  86. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/mise.lock +0 -917
  87. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/mise.toml +0 -291
  88. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/probe.log +0 -4974
  89. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/probe2.log +0 -22
  90. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/probe3.log +0 -4916
  91. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/probe/renovate.json +0 -62
  92. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/renovate-local.log +0 -670
  93. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/symtest/link/mise.lock +0 -47
  94. package/claude-501/-Users-titouanmathis--dotfiles/dd4cd328-df52-4522-a502-48fa24b7b142/scratchpad/symtest/real/source.toml +0 -4
  95. package/claude-501/-Users-titouanmathis-Lab--studiometa-automations/d6c27f69-577a-468b-9bb3-a45c03a66143/scratchpad/cookie.txt +0 -1
  96. package/gitlab-docs-read.md +0 -8
  97. package/gitlab-instance-limits.txt +0 -8
  98. package/piab-501/piab-devops-019fcbcc991d-59c77b27-fresh-47da8bd318.config +0 -1
  99. package/pins-new.txt +0 -36
  100. package/pins-old.txt +0 -36
  101. package/reply +0 -0
  102. package/zsh0IBbcP +0 -0
  103. package/zsh2LqT39 +0 -0
  104. package/zsh6KJGTP +0 -0
  105. package/zshN1hNdy +0 -0
  106. package/zshNjWSYH +0 -11
  107. package/zshNvB745 +0 -0
  108. package/zshOXC0uH +0 -0
  109. package/zshPG9CFU +0 -0
  110. package/zshVOeZsK +0 -0
  111. package/zshVqIgQS +0 -0
  112. package/zshXTrFg8 +0 -0
  113. package/zshaUGubs +0 -11
  114. package/zshbzOT6d +0 -1
  115. package/zshnbtbGK +0 -0
  116. package/zshpQi1EI +0 -2
  117. package/zshwhMjOD +0 -1
@@ -0,0 +1,323 @@
1
+ import { MapboxMap } from "./MapboxMap.js";
2
+ import { MapboxClusterItem } from "./MapboxClusterItem.js";
3
+ import { MapboxCluster } from "./MapboxCluster.js";
4
+ import { MapboxGeocoder } from "./MapboxGeocoder.js";
5
+ import { Base, BaseConfig, BaseProps } from "@studiometa/js-toolkit";
6
+ import { LngLatBoundsLike, Map, Popup } from "mapbox-gl";
7
+
8
+ //#region StoreLocator.d.ts
9
+ interface StoreLocatorProps extends BaseProps {
10
+ $options: {
11
+ itemZoomLevel: number;
12
+ noSort: boolean;
13
+ fitOnUpdate: boolean;
14
+ popupOptions: Record<string, unknown>;
15
+ };
16
+ }
17
+ /**
18
+ * Coordinate a "find a store near you" experience on top of a `MapboxMap`.
19
+ *
20
+ * `StoreLocator` is a thin **orchestrator**: it owns no map rendering and no item
21
+ * registry of its own. It wraps a `MapboxMap` containing a
22
+ * [`MapboxCluster`](./MapboxCluster.js) of
23
+ * [`MapboxClusterItem`](./MapboxClusterItem.js)s (the declarative clustered map +
24
+ * list source driver) plus an optional
25
+ * [`MapboxGeocoder`](./MapboxGeocoder.js), and layers the search UX on top:
26
+ * selection, viewport filtering and address search. The cluster keeps owning the
27
+ * data (it derives the source from the registered items); the orchestrator only
28
+ * reads that item set and reacts to it.
29
+ *
30
+ * Each store has three independent states, each with its own source of truth:
31
+ *
32
+ * 1. **Registered** — the item exists in the DOM. Owned by the `MapboxCluster`,
33
+ * it drives the **map data** and only changes when the item set changes (e.g.
34
+ * a `Fetch` swaps the list). The orchestrator is notified through the
35
+ * cluster's `map-update` event.
36
+ * 2. **In bounds** — the item's `lngLat` is inside the current viewport. Drives
37
+ * **list visibility + distance sort only**, recomputed on map `moveend`, and
38
+ * never touches the map data.
39
+ * 3. **Selected** — the chosen item. Drives fly-to, the popup, `active` styling
40
+ * and the `map-select` event.
41
+ *
42
+ * The orchestrator requires its `MapboxCluster` (and `MapboxMap`) to live within
43
+ * its own subtree; it resolves them with `$query`, retries a few ticks for
44
+ * asynchronously-mounted children, and — like the map children — subscribes to
45
+ * the `MAPBOX_MAP_CONNECTED` / `MAPBOX_CLUSTER_CONNECTED` events so a late or
46
+ * replaced map/cluster (re)binds instead of stranding the orchestrator on a
47
+ * destroyed instance, and to the map's own `remove` event so a removed map is
48
+ * never called into. Register each component independently (e.g. with
49
+ * `registerComponent`, optionally behind a lazy `importWhen*` helper):
50
+ * `StoreLocator`, `MapboxMap`, `MapboxCluster` and `MapboxClusterItem`.
51
+ * Registration order does not matter because children resolve their map through
52
+ * the connected-event retry, and the orchestrator declares no child components
53
+ * so nothing is ever double-mounted.
54
+ *
55
+ * @see https://ui.studiometa.dev/reference/items/MapboxMap/
56
+ */
57
+ declare class StoreLocator<T extends BaseProps = BaseProps> extends Base<T & StoreLocatorProps> {
58
+ /**
59
+ * Config.
60
+ *
61
+ * No child components are declared: `MapboxMap`, `MapboxCluster`,
62
+ * `MapboxClusterItem` and `MapboxGeocoder` are each registered independently
63
+ * (e.g. with `registerComponent`, optionally behind a lazy `importWhen*`
64
+ * helper) and mount on their own. The orchestrator discovers them through
65
+ * `$query` once available — declaring them here would double-mount them.
66
+ */
67
+ static config: BaseConfig;
68
+ /**
69
+ * Whether the underlying map has finished loading.
70
+ */
71
+ isLoaded: boolean;
72
+ /**
73
+ * The Mapbox `Map` instance cached at load, so every listener and teardown
74
+ * path reaches it without a fresh `$query` (which returns nothing once the
75
+ * element is detached).
76
+ * @private
77
+ */
78
+ __map?: Map;
79
+ /**
80
+ * The child `MapboxCluster`, cached at wire-time for detach-safe teardown.
81
+ * @private
82
+ */
83
+ __cluster?: MapboxCluster;
84
+ /**
85
+ * The optional child `MapboxGeocoder`, cached at wire-time.
86
+ * @private
87
+ */
88
+ __geocoder?: MapboxGeocoder;
89
+ /**
90
+ * The currently selected item, if any.
91
+ * @private
92
+ */
93
+ __selected?: MapboxClusterItem;
94
+ /**
95
+ * The popup opened for the selected item, created lazily.
96
+ * @private
97
+ */
98
+ __popup?: Popup;
99
+ /**
100
+ * Unsubscribe callbacks for the `MapboxCluster` listeners, flushed both on
101
+ * destroy and when the cluster is replaced (so the orchestrator re-wires onto
102
+ * the new instance rather than staying subscribed to the destroyed one).
103
+ * @private
104
+ */
105
+ __offCluster: Array<() => void>;
106
+ /**
107
+ * Unsubscribe callbacks for the `MapboxGeocoder` listeners, flushed on destroy.
108
+ * @private
109
+ */
110
+ __offGeocoder: Array<() => void>;
111
+ /**
112
+ * Off handle for the pending `map-load` subscription.
113
+ * @private
114
+ */
115
+ __offMapLoad?: () => void;
116
+ /**
117
+ * Off handle for the ready map's own `remove` subscription, used to drop the
118
+ * cached map the moment it is removed so no listener/teardown ever calls a
119
+ * method on a dead map.
120
+ * @private
121
+ */
122
+ __offMapRemove?: () => void;
123
+ /**
124
+ * Off handle for the standing document-level `MAPBOX_MAP_CONNECTED` retry
125
+ * subscription, so a map that mounts (or a replacement that mounts after the
126
+ * previous was removed) rebinds the orchestrator.
127
+ * @private
128
+ */
129
+ __offMapConnected?: () => void;
130
+ /**
131
+ * Off handle for the standing document-level `MAPBOX_CLUSTER_CONNECTED` retry
132
+ * subscription, so a cluster that mounts late — or replaces the wired one — is
133
+ * (re)wired instead of stranding the orchestrator on a destroyed instance.
134
+ * @private
135
+ */
136
+ __offClusterConnected?: () => void;
137
+ /**
138
+ * Whether the `MapboxCluster` listeners are already attached.
139
+ * @private
140
+ */
141
+ __clusterWired: boolean;
142
+ /**
143
+ * Whether the `MapboxGeocoder` `map-result` listener is already attached.
144
+ * @private
145
+ */
146
+ __geocoderWired: boolean;
147
+ /**
148
+ * The closest child `MapboxMap` component.
149
+ */
150
+ get mapboxMap(): MapboxMap<BaseProps>;
151
+ /**
152
+ * The child `MapboxCluster`, discovered in the subtree.
153
+ */
154
+ get cluster(): MapboxCluster | undefined;
155
+ /**
156
+ * The optional child `MapboxGeocoder`, discovered in the subtree.
157
+ */
158
+ get geocoder(): MapboxGeocoder | undefined;
159
+ /**
160
+ * The Mapbox `Map` instance. Only valid once the map has loaded.
161
+ */
162
+ get map(): Map;
163
+ /**
164
+ * The registered items, read from the cluster (their single source of truth).
165
+ */
166
+ get items(): readonly MapboxClusterItem[];
167
+ /**
168
+ * Select an item: deactivate the previous one, fly to the item, open its
169
+ * popup, mark it active and emit a `map-select` event.
170
+ * @param {MapboxClusterItem} item
171
+ */
172
+ selectItem(item: MapboxClusterItem): void;
173
+ /**
174
+ * Clear the current selection, close the popup and emit a `map-deselect` event.
175
+ */
176
+ deselect(): void;
177
+ /**
178
+ * Open (or move) the selection popup on the given item, using its popup
179
+ * content. A content-less item closes any open popup instead.
180
+ *
181
+ * NOTE: closing this popup through Mapbox's own close-button UI does NOT clear
182
+ * the selection — `data-active`/`aria-current`/`__selected` stay set by design.
183
+ * Popup visibility and selection are independent: dismissing the popup does not
184
+ * deselect the store. Call `deselect()` explicitly to clear the selection.
185
+ * @private
186
+ * @param {MapboxClusterItem} item
187
+ */
188
+ __openPopup(item: MapboxClusterItem): void;
189
+ /**
190
+ * Fit the map to the whole item set (when `fitOnUpdate`) then recompute the
191
+ * in-view list. Runs on an item-set change (the cluster's `map-update` event) and
192
+ * when the cluster is first wired.
193
+ * @private
194
+ */
195
+ __refresh(): void;
196
+ /**
197
+ * Compute the bounding box of the whole registered item set as a
198
+ * `[[minLng, minLat], [maxLng, maxLat]]` tuple.
199
+ * @private
200
+ * @returns {LngLatBoundsLike}
201
+ */
202
+ __getItemsBounds(): LngLatBoundsLike;
203
+ /**
204
+ * Recompute the visible/sorted list = registered ∩ in-bounds, distance-sorted.
205
+ *
206
+ * Reflects the in-bounds state on every item, reorders the in-view items in
207
+ * their shared parent list (so DOM order matches distance) and emits `map-filter`
208
+ * with the in-view items. Never touches the map data.
209
+ * @private
210
+ */
211
+ __filterItemsInView(): void;
212
+ /**
213
+ * Reorder the in-view items so their DOM order matches the distance sort.
214
+ * Appending a connected node moves it, keeping the list free of duplicates.
215
+ * Items are reordered inside their own shared parent — the sidebar list
216
+ * element — which is resolved per item so no `list` ref is required (a ref
217
+ * declared on the sidebar would not bind anyway: the items live inside the
218
+ * nested `MapboxCluster`, outside this orchestrator's ref scope).
219
+ * @private
220
+ * @param {MapboxClusterItem[]} items
221
+ */
222
+ __reorderList(items: MapboxClusterItem[]): void;
223
+ /**
224
+ * Handle the cluster's `map-item-click`: select the item behind the clicked
225
+ * unclustered point, if one was resolved.
226
+ * @private
227
+ */
228
+ __handleItemClick: (event: Event) => void;
229
+ /**
230
+ * Handle a click anywhere in the sidebar: resolve the nearest
231
+ * `MapboxClusterItem` element back to its instance and select it. Delegated on
232
+ * the root so it survives `Fetch`/facet list swaps.
233
+ * @private
234
+ */
235
+ __handleListClick: (event: Event) => void;
236
+ /**
237
+ * Handle the cluster's `map-update` (the item set changed): re-fit and re-filter.
238
+ * Drops a stale selection whose item is no longer registered.
239
+ * @private
240
+ */
241
+ __handleClusterUpdate: () => void;
242
+ /**
243
+ * Handle a `MapboxGeocoder` `map-result`: frame the map on the geocoded location.
244
+ * @private
245
+ */
246
+ __handleGeocoderResult: (event: Event) => void;
247
+ /**
248
+ * Recompute the in-view list whenever the viewport settles.
249
+ * @private
250
+ */
251
+ __handleMoveEnd: () => void;
252
+ /**
253
+ * React to the map being ready: cache it, subscribe to its `remove`, bind the
254
+ * viewport listener and wire the children.
255
+ *
256
+ * Idempotent for the same map (a re-entrant `map-load` or connected event does
257
+ * not double-bind `moveend`), and rebinds cleanly onto a replacement map.
258
+ * @private
259
+ */
260
+ __handleMapLoad: () => void;
261
+ /**
262
+ * Subscribe once to the ready map's own `remove` event so a map removed while
263
+ * the orchestrator stays mounted drops the cached (now dead) map instead of
264
+ * calling `flyTo`/`getBounds`/`fitBounds`/`off` on it. A replacement map
265
+ * announces itself through `MAPBOX_MAP_CONNECTED` and rebinds the orchestrator.
266
+ * @private
267
+ * @param {Map} map
268
+ */
269
+ __bindMapRemove(map: Map): void;
270
+ /**
271
+ * Resolve the child `MapboxMap` and bind to it — now if it is already loaded,
272
+ * otherwise once on `map-load`. When none exists yet the standing
273
+ * `MAPBOX_MAP_CONNECTED` subscription rebinds later.
274
+ * @private
275
+ */
276
+ __bindMap(): void;
277
+ /**
278
+ * Subscribe once to `MAPBOX_MAP_CONNECTED` and (re)bind when a `MapboxMap`
279
+ * inside this orchestrator connects — a late-mounted map, or a replacement for
280
+ * one that was removed. Ignores maps outside this subtree (several independent
281
+ * locators/maps can share a page).
282
+ * @private
283
+ */
284
+ __waitForConnectedMap(): void;
285
+ /**
286
+ * Subscribe once to `MAPBOX_CLUSTER_CONNECTED` and (re)wire when a
287
+ * `MapboxCluster` inside this orchestrator connects. A cluster that replaces
288
+ * the wired one drops the stale wiring and re-wires onto the new instance, so
289
+ * list clicks, viewport filtering and selection keep working after a swap.
290
+ * @private
291
+ */
292
+ __waitForConnectedCluster(): void;
293
+ /**
294
+ * Detach the current cluster listeners and reset the wiring flag so
295
+ * `__wireChildren` binds afresh onto a replacement cluster.
296
+ * @private
297
+ */
298
+ __unwireCluster(): void;
299
+ /**
300
+ * Attach the `MapboxCluster`/`MapboxGeocoder` listeners once those children
301
+ * are available. Both mount asynchronously (the geocoder even lazy-imports its
302
+ * module), so we poll a bounded number of ticks until *each* is wired — the
303
+ * cluster is required, the geocoder optional. A locator missing the geocoder
304
+ * simply polls to the attempt cap (bounded and harmless). The standing
305
+ * connected-event subscriptions cover anything that mounts after the cap.
306
+ * @private
307
+ * @param {number} attempt
308
+ */
309
+ __wireChildren(attempt?: number): void;
310
+ /**
311
+ * Mounted hook: bind the delegated sidebar click, resolve and bind the map,
312
+ * and install the standing connected-event subscriptions so a late or replaced
313
+ * map/cluster (re)binds instead of stranding the orchestrator.
314
+ */
315
+ mounted(): void;
316
+ /**
317
+ * Destroyed hook: detach every listener, close the popup and clear the cached
318
+ * references — even when the element has already been detached from the DOM.
319
+ */
320
+ destroyed(): void;
321
+ }
322
+ //#endregion
323
+ export { StoreLocator, StoreLocator as default, StoreLocatorProps };