@optimum-intelligence/opti-ui 0.6.2 → 0.7.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/CHANGELOG.md +31 -0
- package/README.md +45 -1
- package/dist/components/map/Map.d.ts +374 -0
- package/dist/components/map/Map.js +2032 -0
- package/dist/components/map/Map.js.map +1 -0
- package/dist/components/map/colors.d.ts +16 -0
- package/dist/components/map/colors.js +99 -0
- package/dist/components/map/colors.js.map +1 -0
- package/dist/components/map/worker.d.ts +6 -0
- package/dist/components/map/worker.js +12 -0
- package/dist/components/map/worker.js.map +1 -0
- package/dist/components.json +481 -2
- package/dist/index.js +3 -2
- package/dist/llms-full.txt +278 -0
- package/dist/llms.txt +7 -0
- package/dist/map/index.d.ts +3 -0
- package/dist/map/index.js +4 -0
- package/dist/map.css +3 -0
- package/dist/opti-ui.css +427 -6
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/series.d.ts +9 -0
- package/dist/theme/series.js +17 -0
- package/dist/theme/series.js.map +1 -0
- package/dist/vendor/maplibre-gl/dist/maplibre-gl-worker.mjs_raw.js +7 -0
- package/dist/vendor/maplibre-gl/dist/maplibre-gl-worker.mjs_raw.js.map +1 -0
- package/package.json +9 -2
|
@@ -0,0 +1,2032 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../../utils/cx.js";
|
|
3
|
+
import { seriesColor } from "../../theme/series.js";
|
|
4
|
+
import { EyeIcon, EyeOffIcon } from "../../icons/index.js";
|
|
5
|
+
import { SegmentedControl } from "../toggle/Toggle.js";
|
|
6
|
+
import { useResolvedColors } from "./colors.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { createPortal } from "react-dom";
|
|
11
|
+
import { AttributionControl, Layer, Map, Marker, NavigationControl, Popup, Source, useControl } from "@vis.gl/react-maplibre";
|
|
12
|
+
//#region src/components/map/Map.tsx
|
|
13
|
+
/**
|
|
14
|
+
* Loads MapLibre and points it at its worker, once, on the first map mount. The worker source is inlined
|
|
15
|
+
* in `./worker` at library build time and started from a blob URL, so apps need no bundler config (a
|
|
16
|
+
* strict Content-Security-Policy needs `worker-src blob:`). Both are dynamic imports so apps without a
|
|
17
|
+
* mounted map never load them.
|
|
18
|
+
*/
|
|
19
|
+
var mapLib;
|
|
20
|
+
function loadMapLib() {
|
|
21
|
+
mapLib ??= Promise.all([import("maplibre-gl"), import("./worker.js")]).then(([lib, worker]) => {
|
|
22
|
+
lib.setWorkerUrl(URL.createObjectURL(new Blob([worker.default], { type: "text/javascript" })));
|
|
23
|
+
return lib;
|
|
24
|
+
});
|
|
25
|
+
return mapLib;
|
|
26
|
+
}
|
|
27
|
+
var defaultLabels = {
|
|
28
|
+
zoomIn: "Zoom in",
|
|
29
|
+
zoomOut: "Zoom out",
|
|
30
|
+
showAll: "Show all",
|
|
31
|
+
hideAll: "Hide all",
|
|
32
|
+
show: "Show",
|
|
33
|
+
hide: "Hide",
|
|
34
|
+
depot: "Depot",
|
|
35
|
+
noData: "No data to show",
|
|
36
|
+
expand: "Expand map",
|
|
37
|
+
collapse: "Exit expanded map"
|
|
38
|
+
};
|
|
39
|
+
var MapContext = React.createContext(null);
|
|
40
|
+
function useMapContext(part) {
|
|
41
|
+
const ctx = React.use(MapContext);
|
|
42
|
+
if (!ctx) throw new Error(`${part} must be used inside Map.Root`);
|
|
43
|
+
return ctx;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Builds a MapLibre style from a raster tile URL template (`{z}`, `{x}`, `{y}`), for `MapBaseLayer.style`.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* const satellite = rasterStyle('https://tiles.example.com/{z}/{x}/{y}.jpg', '© Example');
|
|
50
|
+
*/
|
|
51
|
+
function rasterStyle(tiles, attribution, tileSize = 256) {
|
|
52
|
+
return {
|
|
53
|
+
version: 8,
|
|
54
|
+
sources: { raster: {
|
|
55
|
+
type: "raster",
|
|
56
|
+
tiles: Array.isArray(tiles) ? tiles : [tiles],
|
|
57
|
+
tileSize,
|
|
58
|
+
attribution
|
|
59
|
+
} },
|
|
60
|
+
layers: [{
|
|
61
|
+
id: "raster",
|
|
62
|
+
type: "raster",
|
|
63
|
+
source: "raster"
|
|
64
|
+
}]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** True when `coords` nests at least `min` positions and every one is a finite `[lng, lat]`. */
|
|
68
|
+
function hasValidPositions(coords, min) {
|
|
69
|
+
let count = 0;
|
|
70
|
+
const check = (value) => {
|
|
71
|
+
if (!Array.isArray(value) || value.length === 0) return false;
|
|
72
|
+
if (typeof value[0] !== "object") {
|
|
73
|
+
count++;
|
|
74
|
+
return value.length >= 2 && Number.isFinite(value[0]) && Number.isFinite(value[1]);
|
|
75
|
+
}
|
|
76
|
+
return value.every(check);
|
|
77
|
+
};
|
|
78
|
+
return check(coords) && count >= min;
|
|
79
|
+
}
|
|
80
|
+
/** Grows `bounds` by every `[lng, lat]` pair nested in `coords`. */
|
|
81
|
+
function extend(bounds, coords) {
|
|
82
|
+
if (!Array.isArray(coords)) return bounds;
|
|
83
|
+
if (typeof coords[0] === "number") {
|
|
84
|
+
const [x, y] = coords;
|
|
85
|
+
return bounds ? [
|
|
86
|
+
Math.min(bounds[0], x),
|
|
87
|
+
Math.min(bounds[1], y),
|
|
88
|
+
Math.max(bounds[2], x),
|
|
89
|
+
Math.max(bounds[3], y)
|
|
90
|
+
] : [
|
|
91
|
+
x,
|
|
92
|
+
y,
|
|
93
|
+
x,
|
|
94
|
+
y
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
return coords.reduce(extend, bounds);
|
|
98
|
+
}
|
|
99
|
+
var toneColors = {
|
|
100
|
+
neutral: {
|
|
101
|
+
solid: "var(--oui-color-text-muted)",
|
|
102
|
+
fill: "var(--oui-color-border-subtle)",
|
|
103
|
+
line: "var(--oui-color-border)"
|
|
104
|
+
},
|
|
105
|
+
accent: {
|
|
106
|
+
solid: "var(--oui-color-accent)",
|
|
107
|
+
fill: "var(--oui-color-accent-subtle)",
|
|
108
|
+
line: "var(--oui-color-info-border)"
|
|
109
|
+
},
|
|
110
|
+
success: {
|
|
111
|
+
solid: "var(--oui-color-success)",
|
|
112
|
+
fill: "var(--oui-color-success-subtle)",
|
|
113
|
+
line: "var(--oui-color-success-border)"
|
|
114
|
+
},
|
|
115
|
+
warning: {
|
|
116
|
+
solid: "var(--oui-color-warning)",
|
|
117
|
+
fill: "var(--oui-color-warning-subtle)",
|
|
118
|
+
line: "var(--oui-color-warning-border)"
|
|
119
|
+
},
|
|
120
|
+
danger: {
|
|
121
|
+
solid: "var(--oui-color-danger)",
|
|
122
|
+
fill: "var(--oui-color-danger-subtle)",
|
|
123
|
+
line: "var(--oui-color-danger-border)"
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var SELECTED = [
|
|
127
|
+
"boolean",
|
|
128
|
+
["feature-state", "selected"],
|
|
129
|
+
false
|
|
130
|
+
];
|
|
131
|
+
var HOVER = [
|
|
132
|
+
"boolean",
|
|
133
|
+
["feature-state", "hover"],
|
|
134
|
+
false
|
|
135
|
+
];
|
|
136
|
+
var ACTIVE = [
|
|
137
|
+
"any",
|
|
138
|
+
SELECTED,
|
|
139
|
+
HOVER
|
|
140
|
+
];
|
|
141
|
+
/** Full opacity for selected or hovered items, `dim` for the rest while anything is selected. */
|
|
142
|
+
var dimmed = (hasSelection, dim) => hasSelection ? [
|
|
143
|
+
"case",
|
|
144
|
+
ACTIVE,
|
|
145
|
+
1,
|
|
146
|
+
dim
|
|
147
|
+
] : 1;
|
|
148
|
+
/**
|
|
149
|
+
* Shared wiring of the data parts: registers layers and bounds with the root, routes events back,
|
|
150
|
+
* and keeps the `selected` feature state in sync (also after a style switch re-adds the source).
|
|
151
|
+
*/
|
|
152
|
+
function useDataPart(partName, sourceId, options) {
|
|
153
|
+
const $ = c(36);
|
|
154
|
+
const ctx = useMapContext(partName);
|
|
155
|
+
const { items, selectedIds: t0, layerIds, coordinates, minPositions: t1, onItemClick, onItemHover } = options;
|
|
156
|
+
let t2;
|
|
157
|
+
if ($[0] !== t0) {
|
|
158
|
+
t2 = t0 === void 0 ? [] : t0;
|
|
159
|
+
$[0] = t0;
|
|
160
|
+
$[1] = t2;
|
|
161
|
+
} else t2 = $[1];
|
|
162
|
+
const selectedIds = t2;
|
|
163
|
+
const minPositions = t1 === void 0 ? 1 : t1;
|
|
164
|
+
const { register, setHandlers, map } = ctx;
|
|
165
|
+
const selected = new Set(selectedIds);
|
|
166
|
+
let t3;
|
|
167
|
+
if ($[2] !== selectedIds) {
|
|
168
|
+
t3 = selectedIds.join("\0");
|
|
169
|
+
$[2] = selectedIds;
|
|
170
|
+
$[3] = t3;
|
|
171
|
+
} else t3 = $[3];
|
|
172
|
+
const selectedKey = t3;
|
|
173
|
+
let t4;
|
|
174
|
+
if ($[4] !== coordinates || $[5] !== minPositions) {
|
|
175
|
+
t4 = (item) => hasValidPositions(coordinates(item), minPositions);
|
|
176
|
+
$[4] = coordinates;
|
|
177
|
+
$[5] = minPositions;
|
|
178
|
+
$[6] = t4;
|
|
179
|
+
} else t4 = $[6];
|
|
180
|
+
const valid = new Set(items.filter(t4));
|
|
181
|
+
const invalidIds = items.filter((item_0) => !valid.has(item_0)).map(_temp).join(", ");
|
|
182
|
+
let t5;
|
|
183
|
+
let t6;
|
|
184
|
+
if ($[7] !== invalidIds || $[8] !== partName) {
|
|
185
|
+
t5 = () => {
|
|
186
|
+
if (invalidIds && process.env.NODE_ENV !== "production") console.warn(`${partName}: skipped items with invalid coordinates: ${invalidIds}`);
|
|
187
|
+
};
|
|
188
|
+
t6 = [partName, invalidIds];
|
|
189
|
+
$[7] = invalidIds;
|
|
190
|
+
$[8] = partName;
|
|
191
|
+
$[9] = t5;
|
|
192
|
+
$[10] = t6;
|
|
193
|
+
} else {
|
|
194
|
+
t5 = $[9];
|
|
195
|
+
t6 = $[10];
|
|
196
|
+
}
|
|
197
|
+
React.useEffect(t5, t6);
|
|
198
|
+
let bounds = null;
|
|
199
|
+
let selectedBounds = null;
|
|
200
|
+
for (const item_2 of valid) {
|
|
201
|
+
bounds = extend(bounds, coordinates(item_2));
|
|
202
|
+
if (selected.has(item_2.id)) selectedBounds = extend(selectedBounds, coordinates(item_2));
|
|
203
|
+
}
|
|
204
|
+
const boundsKey = `${bounds}|${selectedBounds}|${layerIds}`;
|
|
205
|
+
let t7;
|
|
206
|
+
if ($[11] !== bounds || $[12] !== layerIds || $[13] !== register || $[14] !== selectedBounds || $[15] !== sourceId) {
|
|
207
|
+
t7 = () => {
|
|
208
|
+
register(sourceId, {
|
|
209
|
+
layerIds,
|
|
210
|
+
bounds,
|
|
211
|
+
selectedBounds
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
$[11] = bounds;
|
|
215
|
+
$[12] = layerIds;
|
|
216
|
+
$[13] = register;
|
|
217
|
+
$[14] = selectedBounds;
|
|
218
|
+
$[15] = sourceId;
|
|
219
|
+
$[16] = t7;
|
|
220
|
+
} else t7 = $[16];
|
|
221
|
+
let t8;
|
|
222
|
+
if ($[17] !== boundsKey || $[18] !== register || $[19] !== sourceId) {
|
|
223
|
+
t8 = [
|
|
224
|
+
register,
|
|
225
|
+
sourceId,
|
|
226
|
+
boundsKey
|
|
227
|
+
];
|
|
228
|
+
$[17] = boundsKey;
|
|
229
|
+
$[18] = register;
|
|
230
|
+
$[19] = sourceId;
|
|
231
|
+
$[20] = t8;
|
|
232
|
+
} else t8 = $[20];
|
|
233
|
+
React.useEffect(t7, t8);
|
|
234
|
+
let t10;
|
|
235
|
+
let t9;
|
|
236
|
+
if ($[21] !== register || $[22] !== sourceId) {
|
|
237
|
+
t9 = () => () => register(sourceId, null);
|
|
238
|
+
t10 = [register, sourceId];
|
|
239
|
+
$[21] = register;
|
|
240
|
+
$[22] = sourceId;
|
|
241
|
+
$[23] = t10;
|
|
242
|
+
$[24] = t9;
|
|
243
|
+
} else {
|
|
244
|
+
t10 = $[23];
|
|
245
|
+
t9 = $[24];
|
|
246
|
+
}
|
|
247
|
+
React.useEffect(t9, t10);
|
|
248
|
+
let t11;
|
|
249
|
+
if ($[25] !== items || $[26] !== onItemClick || $[27] !== onItemHover || $[28] !== setHandlers || $[29] !== sourceId) {
|
|
250
|
+
t11 = () => {
|
|
251
|
+
const byId = (id) => items.find((item_3) => item_3.id === id);
|
|
252
|
+
setHandlers(sourceId, {
|
|
253
|
+
onClick: (id_0, event) => {
|
|
254
|
+
const item_4 = byId(id_0);
|
|
255
|
+
if (item_4) onItemClick?.(item_4, event);
|
|
256
|
+
},
|
|
257
|
+
onHover: (id_1, event_0) => onItemHover?.(id_1 == null ? null : byId(id_1) ?? null, event_0)
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
$[25] = items;
|
|
261
|
+
$[26] = onItemClick;
|
|
262
|
+
$[27] = onItemHover;
|
|
263
|
+
$[28] = setHandlers;
|
|
264
|
+
$[29] = sourceId;
|
|
265
|
+
$[30] = t11;
|
|
266
|
+
} else t11 = $[30];
|
|
267
|
+
React.useEffect(t11);
|
|
268
|
+
let t12;
|
|
269
|
+
let t13;
|
|
270
|
+
if ($[31] !== setHandlers || $[32] !== sourceId) {
|
|
271
|
+
t12 = () => () => setHandlers(sourceId, null);
|
|
272
|
+
t13 = [setHandlers, sourceId];
|
|
273
|
+
$[31] = setHandlers;
|
|
274
|
+
$[32] = sourceId;
|
|
275
|
+
$[33] = t12;
|
|
276
|
+
$[34] = t13;
|
|
277
|
+
} else {
|
|
278
|
+
t12 = $[33];
|
|
279
|
+
t13 = $[34];
|
|
280
|
+
}
|
|
281
|
+
React.useEffect(t12, t13);
|
|
282
|
+
let t14;
|
|
283
|
+
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
|
|
284
|
+
t14 = /* @__PURE__ */ new Set();
|
|
285
|
+
$[35] = t14;
|
|
286
|
+
} else t14 = $[35];
|
|
287
|
+
const applied = React.useRef(t14);
|
|
288
|
+
React.useEffect(() => {
|
|
289
|
+
const instance = map?.getMap();
|
|
290
|
+
if (!instance) return;
|
|
291
|
+
const drawn = new Set([...valid].map(_temp2));
|
|
292
|
+
const target = new Set((selectedKey ? selectedKey.split("\0") : []).filter((id_2) => drawn.has(id_2)));
|
|
293
|
+
const sync = () => {
|
|
294
|
+
if (!instance.getSource(sourceId)) return;
|
|
295
|
+
const prev = applied.current;
|
|
296
|
+
for (const id_3 of prev) if (!target.has(id_3)) instance.setFeatureState({
|
|
297
|
+
source: sourceId,
|
|
298
|
+
id: id_3
|
|
299
|
+
}, { selected: false });
|
|
300
|
+
for (const id_4 of target) if (!prev.has(id_4)) instance.setFeatureState({
|
|
301
|
+
source: sourceId,
|
|
302
|
+
id: id_4
|
|
303
|
+
}, { selected: true });
|
|
304
|
+
applied.current = target;
|
|
305
|
+
};
|
|
306
|
+
sync();
|
|
307
|
+
const onData = (e) => {
|
|
308
|
+
if (e.sourceId !== sourceId || e.sourceDataType !== "metadata") return;
|
|
309
|
+
applied.current = /* @__PURE__ */ new Set();
|
|
310
|
+
sync();
|
|
311
|
+
};
|
|
312
|
+
instance.on("sourcedata", onData);
|
|
313
|
+
return () => {
|
|
314
|
+
instance.off("sourcedata", onData);
|
|
315
|
+
};
|
|
316
|
+
}, [
|
|
317
|
+
map,
|
|
318
|
+
sourceId,
|
|
319
|
+
valid,
|
|
320
|
+
selectedKey
|
|
321
|
+
]);
|
|
322
|
+
return {
|
|
323
|
+
colors: ctx.colors,
|
|
324
|
+
hasSelection: selectedIds.length > 0,
|
|
325
|
+
valid
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/** A source id that is safe in MapLibre layer ids. */
|
|
329
|
+
function _temp2(item_5) {
|
|
330
|
+
return item_5.id;
|
|
331
|
+
}
|
|
332
|
+
function _temp(item_1) {
|
|
333
|
+
return item_1.id;
|
|
334
|
+
}
|
|
335
|
+
function usePartId(prefix) {
|
|
336
|
+
const $ = c(3);
|
|
337
|
+
const t0 = React.useId();
|
|
338
|
+
let t1;
|
|
339
|
+
if ($[0] !== t0) {
|
|
340
|
+
let t2;
|
|
341
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
342
|
+
t2 = /[^\w-]/g;
|
|
343
|
+
$[2] = t2;
|
|
344
|
+
} else t2 = $[2];
|
|
345
|
+
t1 = t0.replace(t2, "");
|
|
346
|
+
$[0] = t0;
|
|
347
|
+
$[1] = t1;
|
|
348
|
+
} else t1 = $[1];
|
|
349
|
+
return `oui-${prefix}-${t1}`;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* A MapLibre map styled and themed with the library tokens. Holds the base layer state and routes clicks
|
|
353
|
+
* and hovers to the data parts inside it. `Map.Root` › data parts (`Map.Areas`, `Map.Routes`,
|
|
354
|
+
* `Map.Points`) and `Map.Marker`s, with `Map.Overlay`s for legends, switches and cards on top.
|
|
355
|
+
* Needs `@optimum-intelligence/opti-ui/map.css` imported. MapLibre's worker is bundled and runs from a blob URL, so a
|
|
356
|
+
* strict Content-Security-Policy needs `worker-src blob:`.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* <Map.Root
|
|
360
|
+
* baseLayers={[{ id: 'streets', label: 'Streets', style: 'https://tiles.openfreemap.org/styles/bright' }]}
|
|
361
|
+
* initialView={{ longitude: 19.04, latitude: 47.5, zoom: 10 }}
|
|
362
|
+
* >
|
|
363
|
+
* <Map.Routes
|
|
364
|
+
* items={[{ id: 'trip-1', coordinates: [[19.0, 47.48], [19.08, 47.52]] }]}
|
|
365
|
+
* selectedIds={selected}
|
|
366
|
+
* onItemClick={(trip) => setSelected([trip.id])}
|
|
367
|
+
* />
|
|
368
|
+
* <Map.Marker kind="depot" position={[19.0, 47.48]} />
|
|
369
|
+
* </Map.Root>
|
|
370
|
+
*/
|
|
371
|
+
function MapRoot(t0) {
|
|
372
|
+
const $ = c(82);
|
|
373
|
+
let baseLayer;
|
|
374
|
+
let baseLayers;
|
|
375
|
+
let children;
|
|
376
|
+
let className;
|
|
377
|
+
let defaultBaseLayer;
|
|
378
|
+
let initialView;
|
|
379
|
+
let labels;
|
|
380
|
+
let onBaseLayerChange;
|
|
381
|
+
let onClick;
|
|
382
|
+
let onMouseMove;
|
|
383
|
+
let onMouseOut;
|
|
384
|
+
let props;
|
|
385
|
+
let ref;
|
|
386
|
+
let style;
|
|
387
|
+
let t1;
|
|
388
|
+
let t2;
|
|
389
|
+
let t3;
|
|
390
|
+
if ($[0] !== t0) {
|
|
391
|
+
({ref, baseLayers, baseLayer, defaultBaseLayer, onBaseLayerChange, initialView, fit: t1, labels, controlsPosition: t2, expandable: t3, className, style, children, onClick, onMouseMove, onMouseOut, ...props} = t0);
|
|
392
|
+
$[0] = t0;
|
|
393
|
+
$[1] = baseLayer;
|
|
394
|
+
$[2] = baseLayers;
|
|
395
|
+
$[3] = children;
|
|
396
|
+
$[4] = className;
|
|
397
|
+
$[5] = defaultBaseLayer;
|
|
398
|
+
$[6] = initialView;
|
|
399
|
+
$[7] = labels;
|
|
400
|
+
$[8] = onBaseLayerChange;
|
|
401
|
+
$[9] = onClick;
|
|
402
|
+
$[10] = onMouseMove;
|
|
403
|
+
$[11] = onMouseOut;
|
|
404
|
+
$[12] = props;
|
|
405
|
+
$[13] = ref;
|
|
406
|
+
$[14] = style;
|
|
407
|
+
$[15] = t1;
|
|
408
|
+
$[16] = t2;
|
|
409
|
+
$[17] = t3;
|
|
410
|
+
} else {
|
|
411
|
+
baseLayer = $[1];
|
|
412
|
+
baseLayers = $[2];
|
|
413
|
+
children = $[3];
|
|
414
|
+
className = $[4];
|
|
415
|
+
defaultBaseLayer = $[5];
|
|
416
|
+
initialView = $[6];
|
|
417
|
+
labels = $[7];
|
|
418
|
+
onBaseLayerChange = $[8];
|
|
419
|
+
onClick = $[9];
|
|
420
|
+
onMouseMove = $[10];
|
|
421
|
+
onMouseOut = $[11];
|
|
422
|
+
props = $[12];
|
|
423
|
+
ref = $[13];
|
|
424
|
+
style = $[14];
|
|
425
|
+
t1 = $[15];
|
|
426
|
+
t2 = $[16];
|
|
427
|
+
t3 = $[17];
|
|
428
|
+
}
|
|
429
|
+
const fit = t1 === void 0 ? "data" : t1;
|
|
430
|
+
const controlsPosition = t2 === void 0 ? "top-right" : t2;
|
|
431
|
+
const expandable = t3 === void 0 ? false : t3;
|
|
432
|
+
const [element, setElement] = React.useState(null);
|
|
433
|
+
const [map, setMap] = React.useState(null);
|
|
434
|
+
let t4;
|
|
435
|
+
if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
|
|
436
|
+
t4 = {};
|
|
437
|
+
$[18] = t4;
|
|
438
|
+
} else t4 = $[18];
|
|
439
|
+
const [parts, setParts] = React.useState(t4);
|
|
440
|
+
const [internalLayer, setInternalLayer] = React.useState(defaultBaseLayer ?? baseLayers[0]?.id ?? "");
|
|
441
|
+
const [cursor, setCursor] = React.useState("");
|
|
442
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
443
|
+
let t5;
|
|
444
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
445
|
+
t5 = {};
|
|
446
|
+
$[19] = t5;
|
|
447
|
+
} else t5 = $[19];
|
|
448
|
+
const handlers = React.useRef(t5);
|
|
449
|
+
const hovered = React.useRef(null);
|
|
450
|
+
const colors = useResolvedColors(element);
|
|
451
|
+
let t6;
|
|
452
|
+
if ($[20] !== labels) {
|
|
453
|
+
t6 = {
|
|
454
|
+
...defaultLabels,
|
|
455
|
+
...labels
|
|
456
|
+
};
|
|
457
|
+
$[20] = labels;
|
|
458
|
+
$[21] = t6;
|
|
459
|
+
} else t6 = $[21];
|
|
460
|
+
const text = t6;
|
|
461
|
+
const currentId = baseLayer ?? internalLayer;
|
|
462
|
+
let t7;
|
|
463
|
+
if ($[22] !== baseLayers || $[23] !== currentId) {
|
|
464
|
+
t7 = baseLayers.find((l) => l.id === currentId) ?? baseLayers[0];
|
|
465
|
+
$[22] = baseLayers;
|
|
466
|
+
$[23] = currentId;
|
|
467
|
+
$[24] = t7;
|
|
468
|
+
} else t7 = $[24];
|
|
469
|
+
const current = t7;
|
|
470
|
+
const mapStyle = colors.dark && current?.darkStyle ? current.darkStyle : current?.style;
|
|
471
|
+
let t8;
|
|
472
|
+
if ($[25] !== onBaseLayerChange) {
|
|
473
|
+
t8 = (id) => {
|
|
474
|
+
setInternalLayer(id);
|
|
475
|
+
onBaseLayerChange?.(id);
|
|
476
|
+
};
|
|
477
|
+
$[25] = onBaseLayerChange;
|
|
478
|
+
$[26] = t8;
|
|
479
|
+
} else t8 = $[26];
|
|
480
|
+
const setBaseLayer = t8;
|
|
481
|
+
let t9;
|
|
482
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
483
|
+
t9 = (partId, part) => {
|
|
484
|
+
setParts((prev) => {
|
|
485
|
+
const next = { ...prev };
|
|
486
|
+
if (part) next[partId] = part;
|
|
487
|
+
else delete next[partId];
|
|
488
|
+
return next;
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
$[27] = t9;
|
|
492
|
+
} else t9 = $[27];
|
|
493
|
+
const register = t9;
|
|
494
|
+
let t10;
|
|
495
|
+
if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
|
|
496
|
+
t10 = (partId_0, value) => {
|
|
497
|
+
if (value) handlers.current[partId_0] = value;
|
|
498
|
+
else delete handlers.current[partId_0];
|
|
499
|
+
};
|
|
500
|
+
$[28] = t10;
|
|
501
|
+
} else t10 = $[28];
|
|
502
|
+
const setHandlers = t10;
|
|
503
|
+
let dataKey;
|
|
504
|
+
let empty;
|
|
505
|
+
let interactiveLayerIds;
|
|
506
|
+
let ownerOf;
|
|
507
|
+
let t11;
|
|
508
|
+
if ($[29] !== fit || $[30] !== parts) {
|
|
509
|
+
const entries = Object.entries(parts);
|
|
510
|
+
interactiveLayerIds = entries.flatMap(_temp3);
|
|
511
|
+
ownerOf = (layerId) => entries.find((t12) => {
|
|
512
|
+
const [, part_1] = t12;
|
|
513
|
+
return part_1.layerIds.includes(layerId);
|
|
514
|
+
})?.[0];
|
|
515
|
+
empty = entries.length > 0 && entries.every(_temp4);
|
|
516
|
+
const corners = _temp5;
|
|
517
|
+
const boundsKey = _temp7;
|
|
518
|
+
dataKey = fit === "none" ? "" : boundsKey(extend(null, entries.map((t13) => {
|
|
519
|
+
const [, part_3] = t13;
|
|
520
|
+
return corners(part_3.bounds);
|
|
521
|
+
})));
|
|
522
|
+
t11 = fit === "selected" ? boundsKey(extend(null, entries.map((t14) => {
|
|
523
|
+
const [, part_4] = t14;
|
|
524
|
+
return corners(part_4.selectedBounds);
|
|
525
|
+
}))) : "";
|
|
526
|
+
$[29] = fit;
|
|
527
|
+
$[30] = parts;
|
|
528
|
+
$[31] = dataKey;
|
|
529
|
+
$[32] = empty;
|
|
530
|
+
$[33] = interactiveLayerIds;
|
|
531
|
+
$[34] = ownerOf;
|
|
532
|
+
$[35] = t11;
|
|
533
|
+
} else {
|
|
534
|
+
dataKey = $[31];
|
|
535
|
+
empty = $[32];
|
|
536
|
+
interactiveLayerIds = $[33];
|
|
537
|
+
ownerOf = $[34];
|
|
538
|
+
t11 = $[35];
|
|
539
|
+
}
|
|
540
|
+
const selectionKey = t11;
|
|
541
|
+
const userMoved = React.useRef(false);
|
|
542
|
+
let t12;
|
|
543
|
+
let t13;
|
|
544
|
+
if ($[36] !== map) {
|
|
545
|
+
t12 = () => {
|
|
546
|
+
const instance = map?.getMap();
|
|
547
|
+
if (!instance) return;
|
|
548
|
+
const onMoveStart = (event) => {
|
|
549
|
+
if (event.originalEvent) userMoved.current = true;
|
|
550
|
+
};
|
|
551
|
+
instance.on("movestart", onMoveStart);
|
|
552
|
+
return () => {
|
|
553
|
+
instance.off("movestart", onMoveStart);
|
|
554
|
+
};
|
|
555
|
+
};
|
|
556
|
+
t13 = [map];
|
|
557
|
+
$[36] = map;
|
|
558
|
+
$[37] = t12;
|
|
559
|
+
$[38] = t13;
|
|
560
|
+
} else {
|
|
561
|
+
t12 = $[37];
|
|
562
|
+
t13 = $[38];
|
|
563
|
+
}
|
|
564
|
+
React.useEffect(t12, t13);
|
|
565
|
+
let t14;
|
|
566
|
+
if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
|
|
567
|
+
t14 = {
|
|
568
|
+
data: "",
|
|
569
|
+
selection: ""
|
|
570
|
+
};
|
|
571
|
+
$[39] = t14;
|
|
572
|
+
} else t14 = $[39];
|
|
573
|
+
const fitted = React.useRef(t14);
|
|
574
|
+
let t15;
|
|
575
|
+
let t16;
|
|
576
|
+
if ($[40] !== dataKey || $[41] !== map || $[42] !== selectionKey) {
|
|
577
|
+
t15 = () => {
|
|
578
|
+
if (!map) return;
|
|
579
|
+
const prev_0 = fitted.current;
|
|
580
|
+
fitted.current = {
|
|
581
|
+
data: dataKey,
|
|
582
|
+
selection: selectionKey
|
|
583
|
+
};
|
|
584
|
+
const selectionChanged = selectionKey !== prev_0.selection;
|
|
585
|
+
const dataChanged = dataKey !== prev_0.data && !userMoved.current;
|
|
586
|
+
const key = selectionKey || dataKey;
|
|
587
|
+
if (!key || !(selectionChanged || dataChanged)) return;
|
|
588
|
+
const [w, s, e, n_0] = key.split(",").map(Number);
|
|
589
|
+
map.fitBounds([[w, s], [e, n_0]], {
|
|
590
|
+
padding: 48,
|
|
591
|
+
maxZoom: 15,
|
|
592
|
+
duration: 400
|
|
593
|
+
});
|
|
594
|
+
};
|
|
595
|
+
t16 = [
|
|
596
|
+
map,
|
|
597
|
+
dataKey,
|
|
598
|
+
selectionKey
|
|
599
|
+
];
|
|
600
|
+
$[40] = dataKey;
|
|
601
|
+
$[41] = map;
|
|
602
|
+
$[42] = selectionKey;
|
|
603
|
+
$[43] = t15;
|
|
604
|
+
$[44] = t16;
|
|
605
|
+
} else {
|
|
606
|
+
t15 = $[43];
|
|
607
|
+
t16 = $[44];
|
|
608
|
+
}
|
|
609
|
+
React.useEffect(t15, t16);
|
|
610
|
+
let t17;
|
|
611
|
+
if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
|
|
612
|
+
t17 = (next_0, event_0) => {
|
|
613
|
+
const prev_1 = hovered.current;
|
|
614
|
+
const key_0 = _temp8;
|
|
615
|
+
if (key_0(prev_1) === key_0(next_0)) return;
|
|
616
|
+
const instance_0 = event_0.target;
|
|
617
|
+
if (prev_1) {
|
|
618
|
+
if (instance_0.getSource(prev_1.source)) instance_0.setFeatureState(prev_1, { hover: false });
|
|
619
|
+
handlers.current[prev_1.source]?.onHover?.(null, event_0);
|
|
620
|
+
}
|
|
621
|
+
if (next_0) {
|
|
622
|
+
instance_0.setFeatureState(next_0, { hover: true });
|
|
623
|
+
handlers.current[next_0.source]?.onHover?.(String(next_0.id), event_0);
|
|
624
|
+
}
|
|
625
|
+
hovered.current = next_0;
|
|
626
|
+
setCursor(next_0 ? "pointer" : "");
|
|
627
|
+
};
|
|
628
|
+
$[45] = t17;
|
|
629
|
+
} else t17 = $[45];
|
|
630
|
+
const setHover = t17;
|
|
631
|
+
let t18;
|
|
632
|
+
let t19;
|
|
633
|
+
if ($[46] !== expanded) {
|
|
634
|
+
t18 = () => {
|
|
635
|
+
if (!expanded) return;
|
|
636
|
+
const onKeyDown = (event_1) => {
|
|
637
|
+
if (event_1.key === "Escape" && !event_1.defaultPrevented) setExpanded(false);
|
|
638
|
+
};
|
|
639
|
+
document.addEventListener("keydown", onKeyDown);
|
|
640
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
641
|
+
};
|
|
642
|
+
t19 = [expanded];
|
|
643
|
+
$[46] = expanded;
|
|
644
|
+
$[47] = t18;
|
|
645
|
+
$[48] = t19;
|
|
646
|
+
} else {
|
|
647
|
+
t18 = $[47];
|
|
648
|
+
t19 = $[48];
|
|
649
|
+
}
|
|
650
|
+
React.useEffect(t18, t19);
|
|
651
|
+
let t20;
|
|
652
|
+
if ($[49] !== initialView) {
|
|
653
|
+
t20 = initialView && "bounds" in initialView ? {
|
|
654
|
+
bounds: initialView.bounds,
|
|
655
|
+
fitBoundsOptions: { padding: 48 }
|
|
656
|
+
} : initialView;
|
|
657
|
+
$[49] = initialView;
|
|
658
|
+
$[50] = t20;
|
|
659
|
+
} else t20 = $[50];
|
|
660
|
+
const initialViewState = t20;
|
|
661
|
+
let t21;
|
|
662
|
+
if ($[51] !== className) {
|
|
663
|
+
t21 = cx("oui-map", className);
|
|
664
|
+
$[51] = className;
|
|
665
|
+
$[52] = t21;
|
|
666
|
+
} else t21 = $[52];
|
|
667
|
+
const t22 = expanded || void 0;
|
|
668
|
+
let t23;
|
|
669
|
+
if ($[53] !== baseLayers || $[54] !== children || $[55] !== colors || $[56] !== controlsPosition || $[57] !== current?.attribution || $[58] !== current?.id || $[59] !== cursor || $[60] !== element || $[61] !== empty || $[62] !== expandable || $[63] !== expanded || $[64] !== initialViewState || $[65] !== interactiveLayerIds || $[66] !== map || $[67] !== mapStyle || $[68] !== onClick || $[69] !== onMouseMove || $[70] !== onMouseOut || $[71] !== ownerOf || $[72] !== props || $[73] !== ref || $[74] !== setBaseLayer || $[75] !== text) {
|
|
670
|
+
t23 = element && /* @__PURE__ */ jsx(Map, {
|
|
671
|
+
...props,
|
|
672
|
+
mapLib: loadMapLib(),
|
|
673
|
+
ref: (instance_1) => {
|
|
674
|
+
setMap(instance_1);
|
|
675
|
+
if (typeof ref === "function") ref(instance_1);
|
|
676
|
+
else if (ref) ref.current = instance_1;
|
|
677
|
+
},
|
|
678
|
+
mapStyle,
|
|
679
|
+
initialViewState,
|
|
680
|
+
interactiveLayerIds,
|
|
681
|
+
cursor,
|
|
682
|
+
attributionControl: false,
|
|
683
|
+
locale: {
|
|
684
|
+
"NavigationControl.ZoomIn": text.zoomIn,
|
|
685
|
+
"NavigationControl.ZoomOut": text.zoomOut
|
|
686
|
+
},
|
|
687
|
+
onClick: (event_2) => {
|
|
688
|
+
const feature = event_2.features?.[0];
|
|
689
|
+
const owner = feature && ownerOf(feature.layer.id);
|
|
690
|
+
if (feature && owner && feature.id != null) handlers.current[owner]?.onClick?.(String(feature.id), event_2);
|
|
691
|
+
onClick?.(event_2);
|
|
692
|
+
},
|
|
693
|
+
onMouseMove: (event_3) => {
|
|
694
|
+
const feature_0 = event_3.features?.[0];
|
|
695
|
+
const owner_0 = feature_0 && ownerOf(feature_0.layer.id);
|
|
696
|
+
setHover(feature_0 && owner_0 && feature_0.id != null ? {
|
|
697
|
+
source: owner_0,
|
|
698
|
+
id: feature_0.id
|
|
699
|
+
} : null, event_3);
|
|
700
|
+
onMouseMove?.(event_3);
|
|
701
|
+
},
|
|
702
|
+
onMouseOut: (event_4) => {
|
|
703
|
+
setHover(null, event_4);
|
|
704
|
+
onMouseOut?.(event_4);
|
|
705
|
+
},
|
|
706
|
+
children: /* @__PURE__ */ jsxs(MapContext, {
|
|
707
|
+
value: {
|
|
708
|
+
map,
|
|
709
|
+
colors,
|
|
710
|
+
labels: text,
|
|
711
|
+
baseLayers,
|
|
712
|
+
baseLayer: current?.id ?? "",
|
|
713
|
+
setBaseLayer,
|
|
714
|
+
register,
|
|
715
|
+
setHandlers
|
|
716
|
+
},
|
|
717
|
+
children: [
|
|
718
|
+
controlsPosition && /* @__PURE__ */ jsx(NavigationControl, {
|
|
719
|
+
position: controlsPosition,
|
|
720
|
+
showCompass: false
|
|
721
|
+
}),
|
|
722
|
+
expandable && /* @__PURE__ */ jsx(ExpandControl, {
|
|
723
|
+
position: controlsPosition || "top-right",
|
|
724
|
+
expanded,
|
|
725
|
+
label: expanded ? text.collapse : text.expand,
|
|
726
|
+
onToggle: () => setExpanded(_temp9)
|
|
727
|
+
}),
|
|
728
|
+
/* @__PURE__ */ jsx(AttributionControl, {
|
|
729
|
+
compact: true,
|
|
730
|
+
customAttribution: current?.attribution
|
|
731
|
+
}, current?.id),
|
|
732
|
+
children,
|
|
733
|
+
empty && /* @__PURE__ */ jsx("div", {
|
|
734
|
+
className: "oui-map__empty",
|
|
735
|
+
children: text.noData
|
|
736
|
+
})
|
|
737
|
+
]
|
|
738
|
+
})
|
|
739
|
+
});
|
|
740
|
+
$[53] = baseLayers;
|
|
741
|
+
$[54] = children;
|
|
742
|
+
$[55] = colors;
|
|
743
|
+
$[56] = controlsPosition;
|
|
744
|
+
$[57] = current?.attribution;
|
|
745
|
+
$[58] = current?.id;
|
|
746
|
+
$[59] = cursor;
|
|
747
|
+
$[60] = element;
|
|
748
|
+
$[61] = empty;
|
|
749
|
+
$[62] = expandable;
|
|
750
|
+
$[63] = expanded;
|
|
751
|
+
$[64] = initialViewState;
|
|
752
|
+
$[65] = interactiveLayerIds;
|
|
753
|
+
$[66] = map;
|
|
754
|
+
$[67] = mapStyle;
|
|
755
|
+
$[68] = onClick;
|
|
756
|
+
$[69] = onMouseMove;
|
|
757
|
+
$[70] = onMouseOut;
|
|
758
|
+
$[71] = ownerOf;
|
|
759
|
+
$[72] = props;
|
|
760
|
+
$[73] = ref;
|
|
761
|
+
$[74] = setBaseLayer;
|
|
762
|
+
$[75] = text;
|
|
763
|
+
$[76] = t23;
|
|
764
|
+
} else t23 = $[76];
|
|
765
|
+
let t24;
|
|
766
|
+
if ($[77] !== style || $[78] !== t21 || $[79] !== t22 || $[80] !== t23) {
|
|
767
|
+
t24 = /* @__PURE__ */ jsx("div", {
|
|
768
|
+
ref: setElement,
|
|
769
|
+
className: t21,
|
|
770
|
+
style,
|
|
771
|
+
"data-expanded": t22,
|
|
772
|
+
children: t23
|
|
773
|
+
});
|
|
774
|
+
$[77] = style;
|
|
775
|
+
$[78] = t21;
|
|
776
|
+
$[79] = t22;
|
|
777
|
+
$[80] = t23;
|
|
778
|
+
$[81] = t24;
|
|
779
|
+
} else t24 = $[81];
|
|
780
|
+
return t24;
|
|
781
|
+
}
|
|
782
|
+
/** The expand button as a MapLibre control, so it stacks with the zoom buttons in the same corner. */
|
|
783
|
+
function _temp9(value_0) {
|
|
784
|
+
return !value_0;
|
|
785
|
+
}
|
|
786
|
+
function _temp8(h) {
|
|
787
|
+
return h ? `${h.source}|${h.id}` : "";
|
|
788
|
+
}
|
|
789
|
+
function _temp7(b_0) {
|
|
790
|
+
return b_0?.map(_temp6).join(",") ?? "";
|
|
791
|
+
}
|
|
792
|
+
function _temp6(n) {
|
|
793
|
+
return n.toFixed(5);
|
|
794
|
+
}
|
|
795
|
+
function _temp5(b) {
|
|
796
|
+
return b && [b.slice(0, 2), b.slice(2)];
|
|
797
|
+
}
|
|
798
|
+
function _temp4(t0) {
|
|
799
|
+
const [, part_2] = t0;
|
|
800
|
+
return !part_2.bounds;
|
|
801
|
+
}
|
|
802
|
+
function _temp3(t0) {
|
|
803
|
+
const [, part_0] = t0;
|
|
804
|
+
return part_0.layerIds;
|
|
805
|
+
}
|
|
806
|
+
function ExpandControl(t0) {
|
|
807
|
+
const $ = c(12);
|
|
808
|
+
const { position, expanded, label, onToggle } = t0;
|
|
809
|
+
const [host] = React.useState(_temp0);
|
|
810
|
+
let t1;
|
|
811
|
+
if ($[0] !== host) {
|
|
812
|
+
t1 = () => ({
|
|
813
|
+
onAdd: () => host,
|
|
814
|
+
onRemove: () => host.remove()
|
|
815
|
+
});
|
|
816
|
+
$[0] = host;
|
|
817
|
+
$[1] = t1;
|
|
818
|
+
} else t1 = $[1];
|
|
819
|
+
let t2;
|
|
820
|
+
if ($[2] !== position) {
|
|
821
|
+
t2 = { position };
|
|
822
|
+
$[2] = position;
|
|
823
|
+
$[3] = t2;
|
|
824
|
+
} else t2 = $[3];
|
|
825
|
+
useControl(t1, t2);
|
|
826
|
+
let t3;
|
|
827
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
828
|
+
t3 = /* @__PURE__ */ jsx("span", {
|
|
829
|
+
className: "maplibregl-ctrl-icon",
|
|
830
|
+
"aria-hidden": "true"
|
|
831
|
+
});
|
|
832
|
+
$[4] = t3;
|
|
833
|
+
} else t3 = $[4];
|
|
834
|
+
let t4;
|
|
835
|
+
if ($[5] !== expanded || $[6] !== label || $[7] !== onToggle) {
|
|
836
|
+
t4 = /* @__PURE__ */ jsx("button", {
|
|
837
|
+
type: "button",
|
|
838
|
+
className: "oui-map__expand",
|
|
839
|
+
"aria-label": label,
|
|
840
|
+
title: label,
|
|
841
|
+
"aria-pressed": expanded,
|
|
842
|
+
onClick: onToggle,
|
|
843
|
+
children: t3
|
|
844
|
+
});
|
|
845
|
+
$[5] = expanded;
|
|
846
|
+
$[6] = label;
|
|
847
|
+
$[7] = onToggle;
|
|
848
|
+
$[8] = t4;
|
|
849
|
+
} else t4 = $[8];
|
|
850
|
+
let t5;
|
|
851
|
+
if ($[9] !== host || $[10] !== t4) {
|
|
852
|
+
t5 = createPortal(t4, host);
|
|
853
|
+
$[9] = host;
|
|
854
|
+
$[10] = t4;
|
|
855
|
+
$[11] = t5;
|
|
856
|
+
} else t5 = $[11];
|
|
857
|
+
return t5;
|
|
858
|
+
}
|
|
859
|
+
function _temp0() {
|
|
860
|
+
const element = document.createElement("div");
|
|
861
|
+
element.className = "maplibregl-ctrl maplibregl-ctrl-group";
|
|
862
|
+
return element;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Lines such as trips or tracks, drawn as one source with a casing, a solid and a dashed layer. Selected
|
|
866
|
+
* routes get a halo in the surface colour; hover and selection use feature state, so they never rebuild
|
|
867
|
+
* the data. Colours come from `color` or the chart palette.
|
|
868
|
+
*
|
|
869
|
+
* @example
|
|
870
|
+
* <Map.Routes
|
|
871
|
+
* items={trips.map((t) => ({ id: t.id, coordinates: t.path, dashed: t.planned }))}
|
|
872
|
+
* selectedIds={selected}
|
|
873
|
+
* onItemClick={(trip) => setSelected([trip.id])}
|
|
874
|
+
* />
|
|
875
|
+
*/
|
|
876
|
+
function MapRoutes(t0) {
|
|
877
|
+
const $ = c(68);
|
|
878
|
+
const { items, selectedIds, onItemClick, onItemHover } = t0;
|
|
879
|
+
const sourceId = usePartId("routes");
|
|
880
|
+
const t1 = `${sourceId}-casing`;
|
|
881
|
+
const t2 = `${sourceId}-solid`;
|
|
882
|
+
const t3 = `${sourceId}-dashed`;
|
|
883
|
+
let t4;
|
|
884
|
+
if ($[0] !== t1 || $[1] !== t2 || $[2] !== t3) {
|
|
885
|
+
t4 = {
|
|
886
|
+
casing: t1,
|
|
887
|
+
solid: t2,
|
|
888
|
+
dashed: t3
|
|
889
|
+
};
|
|
890
|
+
$[0] = t1;
|
|
891
|
+
$[1] = t2;
|
|
892
|
+
$[2] = t3;
|
|
893
|
+
$[3] = t4;
|
|
894
|
+
} else t4 = $[3];
|
|
895
|
+
const ids = t4;
|
|
896
|
+
let t5;
|
|
897
|
+
if ($[4] !== ids.dashed || $[5] !== ids.solid) {
|
|
898
|
+
t5 = [ids.solid, ids.dashed];
|
|
899
|
+
$[4] = ids.dashed;
|
|
900
|
+
$[5] = ids.solid;
|
|
901
|
+
$[6] = t5;
|
|
902
|
+
} else t5 = $[6];
|
|
903
|
+
let t6;
|
|
904
|
+
if ($[7] !== items || $[8] !== onItemClick || $[9] !== onItemHover || $[10] !== selectedIds || $[11] !== t5) {
|
|
905
|
+
t6 = {
|
|
906
|
+
items,
|
|
907
|
+
selectedIds,
|
|
908
|
+
layerIds: t5,
|
|
909
|
+
coordinates: _temp1,
|
|
910
|
+
minPositions: 2,
|
|
911
|
+
onItemClick,
|
|
912
|
+
onItemHover
|
|
913
|
+
};
|
|
914
|
+
$[7] = items;
|
|
915
|
+
$[8] = onItemClick;
|
|
916
|
+
$[9] = onItemHover;
|
|
917
|
+
$[10] = selectedIds;
|
|
918
|
+
$[11] = t5;
|
|
919
|
+
$[12] = t6;
|
|
920
|
+
} else t6 = $[12];
|
|
921
|
+
const { colors, hasSelection, valid } = useDataPart("Map.Routes", sourceId, t6);
|
|
922
|
+
let t7;
|
|
923
|
+
if ($[13] !== colors || $[14] !== items || $[15] !== valid) {
|
|
924
|
+
let t8;
|
|
925
|
+
if ($[17] !== colors || $[18] !== valid) {
|
|
926
|
+
t8 = (item_0, index) => valid.has(item_0) ? [{
|
|
927
|
+
type: "Feature",
|
|
928
|
+
properties: {
|
|
929
|
+
id: item_0.id,
|
|
930
|
+
dashed: !!item_0.dashed,
|
|
931
|
+
color: colors.color(item_0.color ?? seriesColor(item_0.colorIndex ?? index))
|
|
932
|
+
},
|
|
933
|
+
geometry: {
|
|
934
|
+
type: "LineString",
|
|
935
|
+
coordinates: item_0.coordinates
|
|
936
|
+
}
|
|
937
|
+
}] : [];
|
|
938
|
+
$[17] = colors;
|
|
939
|
+
$[18] = valid;
|
|
940
|
+
$[19] = t8;
|
|
941
|
+
} else t8 = $[19];
|
|
942
|
+
t7 = items.flatMap(t8);
|
|
943
|
+
$[13] = colors;
|
|
944
|
+
$[14] = items;
|
|
945
|
+
$[15] = valid;
|
|
946
|
+
$[16] = t7;
|
|
947
|
+
} else t7 = $[16];
|
|
948
|
+
let t8;
|
|
949
|
+
if ($[20] !== t7) {
|
|
950
|
+
t8 = {
|
|
951
|
+
type: "FeatureCollection",
|
|
952
|
+
features: t7
|
|
953
|
+
};
|
|
954
|
+
$[20] = t7;
|
|
955
|
+
$[21] = t8;
|
|
956
|
+
} else t8 = $[21];
|
|
957
|
+
const data = t8;
|
|
958
|
+
const weight = colors.number("--oui-map-route-weight", 4);
|
|
959
|
+
let t9;
|
|
960
|
+
let width;
|
|
961
|
+
if ($[22] !== colors || $[23] !== hasSelection || $[24] !== weight) {
|
|
962
|
+
const dim = colors.number("--oui-map-dim-opacity", .35);
|
|
963
|
+
const t10 = weight + 1.5;
|
|
964
|
+
let t11;
|
|
965
|
+
if ($[27] !== t10 || $[28] !== weight) {
|
|
966
|
+
t11 = [
|
|
967
|
+
"case",
|
|
968
|
+
HOVER,
|
|
969
|
+
t10,
|
|
970
|
+
weight
|
|
971
|
+
];
|
|
972
|
+
$[27] = t10;
|
|
973
|
+
$[28] = weight;
|
|
974
|
+
$[29] = t11;
|
|
975
|
+
} else t11 = $[29];
|
|
976
|
+
width = t11;
|
|
977
|
+
t9 = dimmed(hasSelection, dim);
|
|
978
|
+
$[22] = colors;
|
|
979
|
+
$[23] = hasSelection;
|
|
980
|
+
$[24] = weight;
|
|
981
|
+
$[25] = t9;
|
|
982
|
+
$[26] = width;
|
|
983
|
+
} else {
|
|
984
|
+
t9 = $[25];
|
|
985
|
+
width = $[26];
|
|
986
|
+
}
|
|
987
|
+
const opacity = t9;
|
|
988
|
+
let t10;
|
|
989
|
+
if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
|
|
990
|
+
t10 = {
|
|
991
|
+
"line-join": "round",
|
|
992
|
+
"line-cap": "round"
|
|
993
|
+
};
|
|
994
|
+
$[30] = t10;
|
|
995
|
+
} else t10 = $[30];
|
|
996
|
+
const layout = t10;
|
|
997
|
+
const t11 = ids.casing;
|
|
998
|
+
let t12;
|
|
999
|
+
if ($[31] !== colors) {
|
|
1000
|
+
t12 = colors.color("var(--oui-map-casing-color)");
|
|
1001
|
+
$[31] = colors;
|
|
1002
|
+
$[32] = t12;
|
|
1003
|
+
} else t12 = $[32];
|
|
1004
|
+
const t13 = weight + 4;
|
|
1005
|
+
let t14;
|
|
1006
|
+
if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1007
|
+
t14 = [
|
|
1008
|
+
"case",
|
|
1009
|
+
SELECTED,
|
|
1010
|
+
1,
|
|
1011
|
+
0
|
|
1012
|
+
];
|
|
1013
|
+
$[33] = t14;
|
|
1014
|
+
} else t14 = $[33];
|
|
1015
|
+
let t15;
|
|
1016
|
+
if ($[34] !== t12 || $[35] !== t13) {
|
|
1017
|
+
t15 = {
|
|
1018
|
+
"line-color": t12,
|
|
1019
|
+
"line-width": t13,
|
|
1020
|
+
"line-opacity": t14
|
|
1021
|
+
};
|
|
1022
|
+
$[34] = t12;
|
|
1023
|
+
$[35] = t13;
|
|
1024
|
+
$[36] = t15;
|
|
1025
|
+
} else t15 = $[36];
|
|
1026
|
+
let t16;
|
|
1027
|
+
if ($[37] !== ids.casing || $[38] !== t15) {
|
|
1028
|
+
t16 = {
|
|
1029
|
+
id: t11,
|
|
1030
|
+
type: "line",
|
|
1031
|
+
layout,
|
|
1032
|
+
paint: t15
|
|
1033
|
+
};
|
|
1034
|
+
$[37] = ids.casing;
|
|
1035
|
+
$[38] = t15;
|
|
1036
|
+
$[39] = t16;
|
|
1037
|
+
} else t16 = $[39];
|
|
1038
|
+
let t17;
|
|
1039
|
+
if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1040
|
+
t17 = [
|
|
1041
|
+
"!=",
|
|
1042
|
+
["get", "dashed"],
|
|
1043
|
+
true
|
|
1044
|
+
];
|
|
1045
|
+
$[40] = t17;
|
|
1046
|
+
} else t17 = $[40];
|
|
1047
|
+
let t18;
|
|
1048
|
+
if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1049
|
+
t18 = ["get", "color"];
|
|
1050
|
+
$[41] = t18;
|
|
1051
|
+
} else t18 = $[41];
|
|
1052
|
+
let t19;
|
|
1053
|
+
if ($[42] !== opacity || $[43] !== width) {
|
|
1054
|
+
t19 = {
|
|
1055
|
+
"line-color": t18,
|
|
1056
|
+
"line-width": width,
|
|
1057
|
+
"line-opacity": opacity
|
|
1058
|
+
};
|
|
1059
|
+
$[42] = opacity;
|
|
1060
|
+
$[43] = width;
|
|
1061
|
+
$[44] = t19;
|
|
1062
|
+
} else t19 = $[44];
|
|
1063
|
+
let t20;
|
|
1064
|
+
if ($[45] !== ids.solid || $[46] !== t19) {
|
|
1065
|
+
t20 = {
|
|
1066
|
+
id: ids.solid,
|
|
1067
|
+
type: "line",
|
|
1068
|
+
filter: t17,
|
|
1069
|
+
layout,
|
|
1070
|
+
paint: t19
|
|
1071
|
+
};
|
|
1072
|
+
$[45] = ids.solid;
|
|
1073
|
+
$[46] = t19;
|
|
1074
|
+
$[47] = t20;
|
|
1075
|
+
} else t20 = $[47];
|
|
1076
|
+
let t21;
|
|
1077
|
+
let t22;
|
|
1078
|
+
let t23;
|
|
1079
|
+
if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1080
|
+
t21 = [
|
|
1081
|
+
"==",
|
|
1082
|
+
["get", "dashed"],
|
|
1083
|
+
true
|
|
1084
|
+
];
|
|
1085
|
+
t22 = {
|
|
1086
|
+
"line-join": "round",
|
|
1087
|
+
"line-cap": "butt"
|
|
1088
|
+
};
|
|
1089
|
+
t23 = ["get", "color"];
|
|
1090
|
+
$[48] = t21;
|
|
1091
|
+
$[49] = t22;
|
|
1092
|
+
$[50] = t23;
|
|
1093
|
+
} else {
|
|
1094
|
+
t21 = $[48];
|
|
1095
|
+
t22 = $[49];
|
|
1096
|
+
t23 = $[50];
|
|
1097
|
+
}
|
|
1098
|
+
let t24;
|
|
1099
|
+
if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1100
|
+
t24 = [2, 1.5];
|
|
1101
|
+
$[51] = t24;
|
|
1102
|
+
} else t24 = $[51];
|
|
1103
|
+
let t25;
|
|
1104
|
+
if ($[52] !== opacity || $[53] !== width) {
|
|
1105
|
+
t25 = {
|
|
1106
|
+
"line-color": t23,
|
|
1107
|
+
"line-width": width,
|
|
1108
|
+
"line-opacity": opacity,
|
|
1109
|
+
"line-dasharray": t24
|
|
1110
|
+
};
|
|
1111
|
+
$[52] = opacity;
|
|
1112
|
+
$[53] = width;
|
|
1113
|
+
$[54] = t25;
|
|
1114
|
+
} else t25 = $[54];
|
|
1115
|
+
let t26;
|
|
1116
|
+
if ($[55] !== ids.dashed || $[56] !== t25) {
|
|
1117
|
+
t26 = {
|
|
1118
|
+
id: ids.dashed,
|
|
1119
|
+
type: "line",
|
|
1120
|
+
filter: t21,
|
|
1121
|
+
layout: t22,
|
|
1122
|
+
paint: t25
|
|
1123
|
+
};
|
|
1124
|
+
$[55] = ids.dashed;
|
|
1125
|
+
$[56] = t25;
|
|
1126
|
+
$[57] = t26;
|
|
1127
|
+
} else t26 = $[57];
|
|
1128
|
+
let t27;
|
|
1129
|
+
if ($[58] !== t16 || $[59] !== t20 || $[60] !== t26) {
|
|
1130
|
+
t27 = [
|
|
1131
|
+
t16,
|
|
1132
|
+
t20,
|
|
1133
|
+
t26
|
|
1134
|
+
];
|
|
1135
|
+
$[58] = t16;
|
|
1136
|
+
$[59] = t20;
|
|
1137
|
+
$[60] = t26;
|
|
1138
|
+
$[61] = t27;
|
|
1139
|
+
} else t27 = $[61];
|
|
1140
|
+
const layers = t27;
|
|
1141
|
+
let t28;
|
|
1142
|
+
if ($[62] !== layers) {
|
|
1143
|
+
t28 = layers.map(_temp10);
|
|
1144
|
+
$[62] = layers;
|
|
1145
|
+
$[63] = t28;
|
|
1146
|
+
} else t28 = $[63];
|
|
1147
|
+
let t29;
|
|
1148
|
+
if ($[64] !== data || $[65] !== sourceId || $[66] !== t28) {
|
|
1149
|
+
t29 = /* @__PURE__ */ jsx(Source, {
|
|
1150
|
+
id: sourceId,
|
|
1151
|
+
type: "geojson",
|
|
1152
|
+
data,
|
|
1153
|
+
promoteId: "id",
|
|
1154
|
+
children: t28
|
|
1155
|
+
});
|
|
1156
|
+
$[64] = data;
|
|
1157
|
+
$[65] = sourceId;
|
|
1158
|
+
$[66] = t28;
|
|
1159
|
+
$[67] = t29;
|
|
1160
|
+
} else t29 = $[67];
|
|
1161
|
+
return t29;
|
|
1162
|
+
}
|
|
1163
|
+
function _temp10(layer) {
|
|
1164
|
+
return /* @__PURE__ */ jsx(Layer, { ...layer }, layer.id);
|
|
1165
|
+
}
|
|
1166
|
+
function _temp1(item) {
|
|
1167
|
+
return item.coordinates;
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Polygons such as fields, zones or service areas, as one fill and one outline layer. Selected and
|
|
1171
|
+
* hovered areas get a heavier outline.
|
|
1172
|
+
*
|
|
1173
|
+
* @example
|
|
1174
|
+
* <Map.Areas items={fields.map((f) => ({ id: f.id, geometry: f.shape, tone: f.late ? 'warning' : 'success' }))} />
|
|
1175
|
+
*/
|
|
1176
|
+
function MapAreas(t0) {
|
|
1177
|
+
const $ = c(38);
|
|
1178
|
+
const { items, selectedIds, onItemClick, onItemHover } = t0;
|
|
1179
|
+
const sourceId = usePartId("areas");
|
|
1180
|
+
const t1 = `${sourceId}-fill`;
|
|
1181
|
+
const t2 = `${sourceId}-line`;
|
|
1182
|
+
let t3;
|
|
1183
|
+
if ($[0] !== t1 || $[1] !== t2) {
|
|
1184
|
+
t3 = {
|
|
1185
|
+
fill: t1,
|
|
1186
|
+
line: t2
|
|
1187
|
+
};
|
|
1188
|
+
$[0] = t1;
|
|
1189
|
+
$[1] = t2;
|
|
1190
|
+
$[2] = t3;
|
|
1191
|
+
} else t3 = $[2];
|
|
1192
|
+
const ids = t3;
|
|
1193
|
+
let t4;
|
|
1194
|
+
if ($[3] !== ids.fill) {
|
|
1195
|
+
t4 = [ids.fill];
|
|
1196
|
+
$[3] = ids.fill;
|
|
1197
|
+
$[4] = t4;
|
|
1198
|
+
} else t4 = $[4];
|
|
1199
|
+
let t5;
|
|
1200
|
+
if ($[5] !== items || $[6] !== onItemClick || $[7] !== onItemHover || $[8] !== selectedIds || $[9] !== t4) {
|
|
1201
|
+
t5 = {
|
|
1202
|
+
items,
|
|
1203
|
+
selectedIds,
|
|
1204
|
+
layerIds: t4,
|
|
1205
|
+
coordinates: _temp11,
|
|
1206
|
+
onItemClick,
|
|
1207
|
+
onItemHover
|
|
1208
|
+
};
|
|
1209
|
+
$[5] = items;
|
|
1210
|
+
$[6] = onItemClick;
|
|
1211
|
+
$[7] = onItemHover;
|
|
1212
|
+
$[8] = selectedIds;
|
|
1213
|
+
$[9] = t4;
|
|
1214
|
+
$[10] = t5;
|
|
1215
|
+
} else t5 = $[10];
|
|
1216
|
+
const { colors, hasSelection, valid } = useDataPart("Map.Areas", sourceId, t5);
|
|
1217
|
+
let t6;
|
|
1218
|
+
if ($[11] !== valid) {
|
|
1219
|
+
t6 = [...valid];
|
|
1220
|
+
$[11] = valid;
|
|
1221
|
+
$[12] = t6;
|
|
1222
|
+
} else t6 = $[12];
|
|
1223
|
+
let t7;
|
|
1224
|
+
if ($[13] !== colors || $[14] !== t6) {
|
|
1225
|
+
t7 = {
|
|
1226
|
+
type: "FeatureCollection",
|
|
1227
|
+
features: t6.map((item_0) => {
|
|
1228
|
+
const tone = toneColors[item_0.tone ?? "neutral"];
|
|
1229
|
+
return {
|
|
1230
|
+
type: "Feature",
|
|
1231
|
+
properties: {
|
|
1232
|
+
id: item_0.id,
|
|
1233
|
+
fill: colors.color(tone.fill),
|
|
1234
|
+
line: colors.color(tone.line)
|
|
1235
|
+
},
|
|
1236
|
+
geometry: item_0.geometry
|
|
1237
|
+
};
|
|
1238
|
+
})
|
|
1239
|
+
};
|
|
1240
|
+
$[13] = colors;
|
|
1241
|
+
$[14] = t6;
|
|
1242
|
+
$[15] = t7;
|
|
1243
|
+
} else t7 = $[15];
|
|
1244
|
+
const data = t7;
|
|
1245
|
+
let t8;
|
|
1246
|
+
if ($[16] !== colors || $[17] !== hasSelection) {
|
|
1247
|
+
t8 = dimmed(hasSelection, colors.number("--oui-map-dim-opacity", .35));
|
|
1248
|
+
$[16] = colors;
|
|
1249
|
+
$[17] = hasSelection;
|
|
1250
|
+
$[18] = t8;
|
|
1251
|
+
} else t8 = $[18];
|
|
1252
|
+
const opacity = t8;
|
|
1253
|
+
let t9;
|
|
1254
|
+
if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1255
|
+
t9 = ["get", "fill"];
|
|
1256
|
+
$[19] = t9;
|
|
1257
|
+
} else t9 = $[19];
|
|
1258
|
+
let t10;
|
|
1259
|
+
if ($[20] !== opacity) {
|
|
1260
|
+
t10 = {
|
|
1261
|
+
"fill-color": t9,
|
|
1262
|
+
"fill-opacity": opacity
|
|
1263
|
+
};
|
|
1264
|
+
$[20] = opacity;
|
|
1265
|
+
$[21] = t10;
|
|
1266
|
+
} else t10 = $[21];
|
|
1267
|
+
let t11;
|
|
1268
|
+
if ($[22] !== ids.fill || $[23] !== t10) {
|
|
1269
|
+
t11 = /* @__PURE__ */ jsx(Layer, {
|
|
1270
|
+
id: ids.fill,
|
|
1271
|
+
type: "fill",
|
|
1272
|
+
paint: t10
|
|
1273
|
+
});
|
|
1274
|
+
$[22] = ids.fill;
|
|
1275
|
+
$[23] = t10;
|
|
1276
|
+
$[24] = t11;
|
|
1277
|
+
} else t11 = $[24];
|
|
1278
|
+
let t12;
|
|
1279
|
+
let t13;
|
|
1280
|
+
let t14;
|
|
1281
|
+
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1282
|
+
t12 = { "line-join": "round" };
|
|
1283
|
+
t13 = ["get", "line"];
|
|
1284
|
+
t14 = [
|
|
1285
|
+
"case",
|
|
1286
|
+
ACTIVE,
|
|
1287
|
+
2.5,
|
|
1288
|
+
1.25
|
|
1289
|
+
];
|
|
1290
|
+
$[25] = t12;
|
|
1291
|
+
$[26] = t13;
|
|
1292
|
+
$[27] = t14;
|
|
1293
|
+
} else {
|
|
1294
|
+
t12 = $[25];
|
|
1295
|
+
t13 = $[26];
|
|
1296
|
+
t14 = $[27];
|
|
1297
|
+
}
|
|
1298
|
+
let t15;
|
|
1299
|
+
if ($[28] !== opacity) {
|
|
1300
|
+
t15 = {
|
|
1301
|
+
"line-color": t13,
|
|
1302
|
+
"line-width": t14,
|
|
1303
|
+
"line-opacity": opacity
|
|
1304
|
+
};
|
|
1305
|
+
$[28] = opacity;
|
|
1306
|
+
$[29] = t15;
|
|
1307
|
+
} else t15 = $[29];
|
|
1308
|
+
let t16;
|
|
1309
|
+
if ($[30] !== ids.line || $[31] !== t15) {
|
|
1310
|
+
t16 = /* @__PURE__ */ jsx(Layer, {
|
|
1311
|
+
id: ids.line,
|
|
1312
|
+
type: "line",
|
|
1313
|
+
layout: t12,
|
|
1314
|
+
paint: t15
|
|
1315
|
+
});
|
|
1316
|
+
$[30] = ids.line;
|
|
1317
|
+
$[31] = t15;
|
|
1318
|
+
$[32] = t16;
|
|
1319
|
+
} else t16 = $[32];
|
|
1320
|
+
let t17;
|
|
1321
|
+
if ($[33] !== data || $[34] !== sourceId || $[35] !== t11 || $[36] !== t16) {
|
|
1322
|
+
t17 = /* @__PURE__ */ jsxs(Source, {
|
|
1323
|
+
id: sourceId,
|
|
1324
|
+
type: "geojson",
|
|
1325
|
+
data,
|
|
1326
|
+
promoteId: "id",
|
|
1327
|
+
children: [t11, t16]
|
|
1328
|
+
});
|
|
1329
|
+
$[33] = data;
|
|
1330
|
+
$[34] = sourceId;
|
|
1331
|
+
$[35] = t11;
|
|
1332
|
+
$[36] = t16;
|
|
1333
|
+
$[37] = t17;
|
|
1334
|
+
} else t17 = $[37];
|
|
1335
|
+
return t17;
|
|
1336
|
+
}
|
|
1337
|
+
function _temp11(item) {
|
|
1338
|
+
return item.geometry.coordinates;
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Many simple points (sensors, stops, events) as one circle layer. For a few dozen styled pins with HTML
|
|
1342
|
+
* content, use `Map.Marker` instead.
|
|
1343
|
+
*
|
|
1344
|
+
* @example
|
|
1345
|
+
* <Map.Points items={sensors.map((s) => ({ id: s.id, coordinates: s.position, tone: s.ok ? 'success' : 'danger' }))} />
|
|
1346
|
+
*/
|
|
1347
|
+
function MapPoints(t0) {
|
|
1348
|
+
const $ = c(34);
|
|
1349
|
+
const { items, selectedIds, onItemClick, onItemHover } = t0;
|
|
1350
|
+
const sourceId = usePartId("points");
|
|
1351
|
+
const circleId = `${sourceId}-circle`;
|
|
1352
|
+
let t1;
|
|
1353
|
+
if ($[0] !== circleId) {
|
|
1354
|
+
t1 = [circleId];
|
|
1355
|
+
$[0] = circleId;
|
|
1356
|
+
$[1] = t1;
|
|
1357
|
+
} else t1 = $[1];
|
|
1358
|
+
let t2;
|
|
1359
|
+
if ($[2] !== items || $[3] !== onItemClick || $[4] !== onItemHover || $[5] !== selectedIds || $[6] !== t1) {
|
|
1360
|
+
t2 = {
|
|
1361
|
+
items,
|
|
1362
|
+
selectedIds,
|
|
1363
|
+
layerIds: t1,
|
|
1364
|
+
coordinates: _temp12,
|
|
1365
|
+
onItemClick,
|
|
1366
|
+
onItemHover
|
|
1367
|
+
};
|
|
1368
|
+
$[2] = items;
|
|
1369
|
+
$[3] = onItemClick;
|
|
1370
|
+
$[4] = onItemHover;
|
|
1371
|
+
$[5] = selectedIds;
|
|
1372
|
+
$[6] = t1;
|
|
1373
|
+
$[7] = t2;
|
|
1374
|
+
} else t2 = $[7];
|
|
1375
|
+
const { colors, hasSelection, valid } = useDataPart("Map.Points", sourceId, t2);
|
|
1376
|
+
let t3;
|
|
1377
|
+
if ($[8] !== colors || $[9] !== items || $[10] !== valid) {
|
|
1378
|
+
let t4;
|
|
1379
|
+
if ($[12] !== colors || $[13] !== valid) {
|
|
1380
|
+
t4 = (item_0, index) => valid.has(item_0) ? [{
|
|
1381
|
+
type: "Feature",
|
|
1382
|
+
properties: {
|
|
1383
|
+
id: item_0.id,
|
|
1384
|
+
color: colors.color(item_0.color ?? (item_0.tone ? toneColors[item_0.tone].solid : seriesColor(item_0.colorIndex ?? index)))
|
|
1385
|
+
},
|
|
1386
|
+
geometry: {
|
|
1387
|
+
type: "Point",
|
|
1388
|
+
coordinates: item_0.coordinates
|
|
1389
|
+
}
|
|
1390
|
+
}] : [];
|
|
1391
|
+
$[12] = colors;
|
|
1392
|
+
$[13] = valid;
|
|
1393
|
+
$[14] = t4;
|
|
1394
|
+
} else t4 = $[14];
|
|
1395
|
+
t3 = items.flatMap(t4);
|
|
1396
|
+
$[8] = colors;
|
|
1397
|
+
$[9] = items;
|
|
1398
|
+
$[10] = valid;
|
|
1399
|
+
$[11] = t3;
|
|
1400
|
+
} else t3 = $[11];
|
|
1401
|
+
let t4;
|
|
1402
|
+
if ($[15] !== t3) {
|
|
1403
|
+
t4 = {
|
|
1404
|
+
type: "FeatureCollection",
|
|
1405
|
+
features: t3
|
|
1406
|
+
};
|
|
1407
|
+
$[15] = t3;
|
|
1408
|
+
$[16] = t4;
|
|
1409
|
+
} else t4 = $[16];
|
|
1410
|
+
const data = t4;
|
|
1411
|
+
let t5;
|
|
1412
|
+
if ($[17] !== colors || $[18] !== hasSelection) {
|
|
1413
|
+
t5 = dimmed(hasSelection, colors.number("--oui-map-dim-opacity", .35));
|
|
1414
|
+
$[17] = colors;
|
|
1415
|
+
$[18] = hasSelection;
|
|
1416
|
+
$[19] = t5;
|
|
1417
|
+
} else t5 = $[19];
|
|
1418
|
+
const opacity = t5;
|
|
1419
|
+
let t6;
|
|
1420
|
+
let t7;
|
|
1421
|
+
if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1422
|
+
t6 = ["get", "color"];
|
|
1423
|
+
t7 = [
|
|
1424
|
+
"case",
|
|
1425
|
+
ACTIVE,
|
|
1426
|
+
7,
|
|
1427
|
+
5
|
|
1428
|
+
];
|
|
1429
|
+
$[20] = t6;
|
|
1430
|
+
$[21] = t7;
|
|
1431
|
+
} else {
|
|
1432
|
+
t6 = $[20];
|
|
1433
|
+
t7 = $[21];
|
|
1434
|
+
}
|
|
1435
|
+
let t8;
|
|
1436
|
+
if ($[22] !== colors) {
|
|
1437
|
+
t8 = colors.color("var(--oui-map-casing-color)");
|
|
1438
|
+
$[22] = colors;
|
|
1439
|
+
$[23] = t8;
|
|
1440
|
+
} else t8 = $[23];
|
|
1441
|
+
let t9;
|
|
1442
|
+
if ($[24] !== opacity || $[25] !== t8) {
|
|
1443
|
+
t9 = {
|
|
1444
|
+
"circle-color": t6,
|
|
1445
|
+
"circle-radius": t7,
|
|
1446
|
+
"circle-stroke-color": t8,
|
|
1447
|
+
"circle-stroke-width": 1.5,
|
|
1448
|
+
"circle-opacity": opacity,
|
|
1449
|
+
"circle-stroke-opacity": opacity
|
|
1450
|
+
};
|
|
1451
|
+
$[24] = opacity;
|
|
1452
|
+
$[25] = t8;
|
|
1453
|
+
$[26] = t9;
|
|
1454
|
+
} else t9 = $[26];
|
|
1455
|
+
let t10;
|
|
1456
|
+
if ($[27] !== circleId || $[28] !== t9) {
|
|
1457
|
+
t10 = /* @__PURE__ */ jsx(Layer, {
|
|
1458
|
+
id: circleId,
|
|
1459
|
+
type: "circle",
|
|
1460
|
+
paint: t9
|
|
1461
|
+
});
|
|
1462
|
+
$[27] = circleId;
|
|
1463
|
+
$[28] = t9;
|
|
1464
|
+
$[29] = t10;
|
|
1465
|
+
} else t10 = $[29];
|
|
1466
|
+
let t11;
|
|
1467
|
+
if ($[30] !== data || $[31] !== sourceId || $[32] !== t10) {
|
|
1468
|
+
t11 = /* @__PURE__ */ jsx(Source, {
|
|
1469
|
+
id: sourceId,
|
|
1470
|
+
type: "geojson",
|
|
1471
|
+
data,
|
|
1472
|
+
promoteId: "id",
|
|
1473
|
+
children: t10
|
|
1474
|
+
});
|
|
1475
|
+
$[30] = data;
|
|
1476
|
+
$[31] = sourceId;
|
|
1477
|
+
$[32] = t10;
|
|
1478
|
+
$[33] = t11;
|
|
1479
|
+
} else t11 = $[33];
|
|
1480
|
+
return t11;
|
|
1481
|
+
}
|
|
1482
|
+
function _temp12(item) {
|
|
1483
|
+
return item.coordinates;
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* An HTML pin at one position: numbered stops, depots, vehicles. Each marker is a DOM element, so use it
|
|
1487
|
+
* for dozens of pins, not thousands (use `Map.Points` for those).
|
|
1488
|
+
*
|
|
1489
|
+
* @example
|
|
1490
|
+
* <Map.Marker kind="stop" sequence={3} position={[19.05, 47.5]} color={seriesColor(0)} />
|
|
1491
|
+
*/
|
|
1492
|
+
function MapMarker(t0) {
|
|
1493
|
+
const $ = c(25);
|
|
1494
|
+
const { position, kind: t1, sequence, color, tone, label, selected, dimmed, onClick, children, className } = t0;
|
|
1495
|
+
const kind = t1 === void 0 ? "stop" : t1;
|
|
1496
|
+
const { labels } = useMapContext("Map.Marker");
|
|
1497
|
+
const name = label ?? (kind === "depot" ? labels.depot : void 0);
|
|
1498
|
+
const pinColor = color ?? (tone ? toneColors[tone].solid : void 0);
|
|
1499
|
+
const t2 = position[0];
|
|
1500
|
+
const t3 = position[1];
|
|
1501
|
+
let t4;
|
|
1502
|
+
if ($[0] !== onClick) {
|
|
1503
|
+
t4 = (event) => {
|
|
1504
|
+
event.originalEvent.stopPropagation();
|
|
1505
|
+
onClick?.();
|
|
1506
|
+
};
|
|
1507
|
+
$[0] = onClick;
|
|
1508
|
+
$[1] = t4;
|
|
1509
|
+
} else t4 = $[1];
|
|
1510
|
+
let t5;
|
|
1511
|
+
if ($[2] !== className) {
|
|
1512
|
+
t5 = cx("oui-map__marker", className);
|
|
1513
|
+
$[2] = className;
|
|
1514
|
+
$[3] = t5;
|
|
1515
|
+
} else t5 = $[3];
|
|
1516
|
+
const t6 = selected || void 0;
|
|
1517
|
+
const t7 = dimmed || void 0;
|
|
1518
|
+
const t8 = onClick ? "" : void 0;
|
|
1519
|
+
const t9 = name ? "img" : void 0;
|
|
1520
|
+
let t10;
|
|
1521
|
+
if ($[4] !== pinColor) {
|
|
1522
|
+
t10 = pinColor ? { "--_pin-color": pinColor } : void 0;
|
|
1523
|
+
$[4] = pinColor;
|
|
1524
|
+
$[5] = t10;
|
|
1525
|
+
} else t10 = $[5];
|
|
1526
|
+
let t11;
|
|
1527
|
+
if ($[6] !== children || $[7] !== kind || $[8] !== sequence) {
|
|
1528
|
+
t11 = children ?? (kind === "stop" && sequence != null ? sequence : kind === "depot" ? /* @__PURE__ */ jsx(DepotGlyph, {}) : null);
|
|
1529
|
+
$[6] = children;
|
|
1530
|
+
$[7] = kind;
|
|
1531
|
+
$[8] = sequence;
|
|
1532
|
+
$[9] = t11;
|
|
1533
|
+
} else t11 = $[9];
|
|
1534
|
+
let t12;
|
|
1535
|
+
if ($[10] !== kind || $[11] !== name || $[12] !== t10 || $[13] !== t11 || $[14] !== t5 || $[15] !== t6 || $[16] !== t7 || $[17] !== t8 || $[18] !== t9) {
|
|
1536
|
+
t12 = /* @__PURE__ */ jsx("div", {
|
|
1537
|
+
className: t5,
|
|
1538
|
+
"data-kind": kind,
|
|
1539
|
+
"data-selected": t6,
|
|
1540
|
+
"data-dimmed": t7,
|
|
1541
|
+
"data-interactive": t8,
|
|
1542
|
+
role: t9,
|
|
1543
|
+
"aria-label": name,
|
|
1544
|
+
title: name,
|
|
1545
|
+
style: t10,
|
|
1546
|
+
children: t11
|
|
1547
|
+
});
|
|
1548
|
+
$[10] = kind;
|
|
1549
|
+
$[11] = name;
|
|
1550
|
+
$[12] = t10;
|
|
1551
|
+
$[13] = t11;
|
|
1552
|
+
$[14] = t5;
|
|
1553
|
+
$[15] = t6;
|
|
1554
|
+
$[16] = t7;
|
|
1555
|
+
$[17] = t8;
|
|
1556
|
+
$[18] = t9;
|
|
1557
|
+
$[19] = t12;
|
|
1558
|
+
} else t12 = $[19];
|
|
1559
|
+
let t13;
|
|
1560
|
+
if ($[20] !== position[0] || $[21] !== position[1] || $[22] !== t12 || $[23] !== t4) {
|
|
1561
|
+
t13 = /* @__PURE__ */ jsx(Marker, {
|
|
1562
|
+
longitude: t2,
|
|
1563
|
+
latitude: t3,
|
|
1564
|
+
anchor: "center",
|
|
1565
|
+
onClick: t4,
|
|
1566
|
+
children: t12
|
|
1567
|
+
});
|
|
1568
|
+
$[20] = position[0];
|
|
1569
|
+
$[21] = position[1];
|
|
1570
|
+
$[22] = t12;
|
|
1571
|
+
$[23] = t4;
|
|
1572
|
+
$[24] = t13;
|
|
1573
|
+
} else t13 = $[24];
|
|
1574
|
+
return t13;
|
|
1575
|
+
}
|
|
1576
|
+
function DepotGlyph() {
|
|
1577
|
+
const $ = c(1);
|
|
1578
|
+
let t0;
|
|
1579
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1580
|
+
t0 = /* @__PURE__ */ jsxs("svg", {
|
|
1581
|
+
viewBox: "0 0 24 24",
|
|
1582
|
+
width: "1em",
|
|
1583
|
+
height: "1em",
|
|
1584
|
+
fill: "none",
|
|
1585
|
+
stroke: "currentColor",
|
|
1586
|
+
strokeWidth: 2.2,
|
|
1587
|
+
"aria-hidden": true,
|
|
1588
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
1589
|
+
d: "M3 10.5 12 4l9 6.5V20H3z",
|
|
1590
|
+
strokeLinejoin: "round"
|
|
1591
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
1592
|
+
d: "M9 20v-6h6v6",
|
|
1593
|
+
strokeLinejoin: "round"
|
|
1594
|
+
})]
|
|
1595
|
+
});
|
|
1596
|
+
$[0] = t0;
|
|
1597
|
+
} else t0 = $[0];
|
|
1598
|
+
return t0;
|
|
1599
|
+
}
|
|
1600
|
+
/**
|
|
1601
|
+
* A popup anchored to a position, styled as a library card. Render it while something is selected and
|
|
1602
|
+
* close it from `onClose`.
|
|
1603
|
+
*
|
|
1604
|
+
* @example
|
|
1605
|
+
* {picked && (
|
|
1606
|
+
* <Map.Popup position={picked.position} onClose={() => setPicked(null)}>
|
|
1607
|
+
* <strong>{picked.name}</strong>
|
|
1608
|
+
* </Map.Popup>
|
|
1609
|
+
* )}
|
|
1610
|
+
*/
|
|
1611
|
+
function MapPopup(t0) {
|
|
1612
|
+
const $ = c(15);
|
|
1613
|
+
let className;
|
|
1614
|
+
let position;
|
|
1615
|
+
let props;
|
|
1616
|
+
let t1;
|
|
1617
|
+
let t2;
|
|
1618
|
+
if ($[0] !== t0) {
|
|
1619
|
+
({position, className, offset: t1, maxWidth: t2, ...props} = t0);
|
|
1620
|
+
$[0] = t0;
|
|
1621
|
+
$[1] = className;
|
|
1622
|
+
$[2] = position;
|
|
1623
|
+
$[3] = props;
|
|
1624
|
+
$[4] = t1;
|
|
1625
|
+
$[5] = t2;
|
|
1626
|
+
} else {
|
|
1627
|
+
className = $[1];
|
|
1628
|
+
position = $[2];
|
|
1629
|
+
props = $[3];
|
|
1630
|
+
t1 = $[4];
|
|
1631
|
+
t2 = $[5];
|
|
1632
|
+
}
|
|
1633
|
+
const offset = t1 === void 0 ? 14 : t1;
|
|
1634
|
+
const maxWidth = t2 === void 0 ? "20rem" : t2;
|
|
1635
|
+
const t3 = position[0];
|
|
1636
|
+
const t4 = position[1];
|
|
1637
|
+
let t5;
|
|
1638
|
+
if ($[6] !== className) {
|
|
1639
|
+
t5 = cx("oui-map__popup", className);
|
|
1640
|
+
$[6] = className;
|
|
1641
|
+
$[7] = t5;
|
|
1642
|
+
} else t5 = $[7];
|
|
1643
|
+
let t6;
|
|
1644
|
+
if ($[8] !== maxWidth || $[9] !== offset || $[10] !== position[0] || $[11] !== position[1] || $[12] !== props || $[13] !== t5) {
|
|
1645
|
+
t6 = /* @__PURE__ */ jsx(Popup, {
|
|
1646
|
+
longitude: t3,
|
|
1647
|
+
latitude: t4,
|
|
1648
|
+
offset,
|
|
1649
|
+
maxWidth,
|
|
1650
|
+
className: t5,
|
|
1651
|
+
...props
|
|
1652
|
+
});
|
|
1653
|
+
$[8] = maxWidth;
|
|
1654
|
+
$[9] = offset;
|
|
1655
|
+
$[10] = position[0];
|
|
1656
|
+
$[11] = position[1];
|
|
1657
|
+
$[12] = props;
|
|
1658
|
+
$[13] = t5;
|
|
1659
|
+
$[14] = t6;
|
|
1660
|
+
} else t6 = $[14];
|
|
1661
|
+
return t6;
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Hover content: a popup without a close button that stays open on map clicks. Show it from
|
|
1665
|
+
* `onItemHover` and hide it when the item is `null`.
|
|
1666
|
+
*
|
|
1667
|
+
* @example
|
|
1668
|
+
* {hovered && <Map.Tooltip position={hovered.position}>{hovered.name}</Map.Tooltip>}
|
|
1669
|
+
*/
|
|
1670
|
+
function MapTooltip(t0) {
|
|
1671
|
+
const $ = c(13);
|
|
1672
|
+
let className;
|
|
1673
|
+
let position;
|
|
1674
|
+
let props;
|
|
1675
|
+
let t1;
|
|
1676
|
+
if ($[0] !== t0) {
|
|
1677
|
+
({position, className, offset: t1, ...props} = t0);
|
|
1678
|
+
$[0] = t0;
|
|
1679
|
+
$[1] = className;
|
|
1680
|
+
$[2] = position;
|
|
1681
|
+
$[3] = props;
|
|
1682
|
+
$[4] = t1;
|
|
1683
|
+
} else {
|
|
1684
|
+
className = $[1];
|
|
1685
|
+
position = $[2];
|
|
1686
|
+
props = $[3];
|
|
1687
|
+
t1 = $[4];
|
|
1688
|
+
}
|
|
1689
|
+
const offset = t1 === void 0 ? 10 : t1;
|
|
1690
|
+
const t2 = position[0];
|
|
1691
|
+
const t3 = position[1];
|
|
1692
|
+
let t4;
|
|
1693
|
+
if ($[5] !== className) {
|
|
1694
|
+
t4 = cx("oui-map__popup oui-map__tooltip", className);
|
|
1695
|
+
$[5] = className;
|
|
1696
|
+
$[6] = t4;
|
|
1697
|
+
} else t4 = $[6];
|
|
1698
|
+
let t5;
|
|
1699
|
+
if ($[7] !== offset || $[8] !== position[0] || $[9] !== position[1] || $[10] !== props || $[11] !== t4) {
|
|
1700
|
+
t5 = /* @__PURE__ */ jsx(Popup, {
|
|
1701
|
+
longitude: t2,
|
|
1702
|
+
latitude: t3,
|
|
1703
|
+
offset,
|
|
1704
|
+
closeButton: false,
|
|
1705
|
+
closeOnClick: false,
|
|
1706
|
+
className: t4,
|
|
1707
|
+
...props
|
|
1708
|
+
});
|
|
1709
|
+
$[7] = offset;
|
|
1710
|
+
$[8] = position[0];
|
|
1711
|
+
$[9] = position[1];
|
|
1712
|
+
$[10] = props;
|
|
1713
|
+
$[11] = t4;
|
|
1714
|
+
$[12] = t5;
|
|
1715
|
+
} else t5 = $[12];
|
|
1716
|
+
return t5;
|
|
1717
|
+
}
|
|
1718
|
+
/** Content floating over a corner of the map: stat cards, selects, a legend or `Map.BaseLayerSwitch`. */
|
|
1719
|
+
function MapOverlay(t0) {
|
|
1720
|
+
const $ = c(12);
|
|
1721
|
+
let className;
|
|
1722
|
+
let props;
|
|
1723
|
+
let ref;
|
|
1724
|
+
let t1;
|
|
1725
|
+
if ($[0] !== t0) {
|
|
1726
|
+
({position: t1, className, ref, ...props} = t0);
|
|
1727
|
+
$[0] = t0;
|
|
1728
|
+
$[1] = className;
|
|
1729
|
+
$[2] = props;
|
|
1730
|
+
$[3] = ref;
|
|
1731
|
+
$[4] = t1;
|
|
1732
|
+
} else {
|
|
1733
|
+
className = $[1];
|
|
1734
|
+
props = $[2];
|
|
1735
|
+
ref = $[3];
|
|
1736
|
+
t1 = $[4];
|
|
1737
|
+
}
|
|
1738
|
+
const position = t1 === void 0 ? "top-left" : t1;
|
|
1739
|
+
let t2;
|
|
1740
|
+
if ($[5] !== className) {
|
|
1741
|
+
t2 = cx("oui-map__overlay", className);
|
|
1742
|
+
$[5] = className;
|
|
1743
|
+
$[6] = t2;
|
|
1744
|
+
} else t2 = $[6];
|
|
1745
|
+
let t3;
|
|
1746
|
+
if ($[7] !== position || $[8] !== props || $[9] !== ref || $[10] !== t2) {
|
|
1747
|
+
t3 = /* @__PURE__ */ jsx("div", {
|
|
1748
|
+
ref,
|
|
1749
|
+
className: t2,
|
|
1750
|
+
"data-position": position,
|
|
1751
|
+
...props
|
|
1752
|
+
});
|
|
1753
|
+
$[7] = position;
|
|
1754
|
+
$[8] = props;
|
|
1755
|
+
$[9] = ref;
|
|
1756
|
+
$[10] = t2;
|
|
1757
|
+
$[11] = t3;
|
|
1758
|
+
} else t3 = $[11];
|
|
1759
|
+
return t3;
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* The key to a map's colours, with optional selection and show/hide per entry. Plain DOM, so it also
|
|
1763
|
+
* works outside the map; inside `Map.Root` it takes the root's labels. Put it in a `Map.Overlay`.
|
|
1764
|
+
*
|
|
1765
|
+
* @example
|
|
1766
|
+
* <Map.Legend
|
|
1767
|
+
* items={trips.map((t, i) => ({ id: t.id, label: t.name, color: seriesColor(i), visible: !hidden.includes(t.id) }))}
|
|
1768
|
+
* selectionMode="multi"
|
|
1769
|
+
* selectedIds={selected}
|
|
1770
|
+
* onSelectedIdsChange={setSelected}
|
|
1771
|
+
* onVisibilityChange={(ids, visible) => setHidden((h) => (visible ? h.filter((id) => !ids.includes(id)) : [...h, ...ids]))}
|
|
1772
|
+
* showAllToggle
|
|
1773
|
+
* />
|
|
1774
|
+
*/
|
|
1775
|
+
function MapLegend(t0) {
|
|
1776
|
+
const $ = c(48);
|
|
1777
|
+
let className;
|
|
1778
|
+
let items;
|
|
1779
|
+
let onSelectedIdsChange;
|
|
1780
|
+
let onVisibilityChange;
|
|
1781
|
+
let props;
|
|
1782
|
+
let ref;
|
|
1783
|
+
let t1;
|
|
1784
|
+
let t2;
|
|
1785
|
+
let t3;
|
|
1786
|
+
if ($[0] !== t0) {
|
|
1787
|
+
({items, selectionMode: t1, selectedIds: t2, onSelectedIdsChange, onVisibilityChange, showAllToggle: t3, className, ref, ...props} = t0);
|
|
1788
|
+
$[0] = t0;
|
|
1789
|
+
$[1] = className;
|
|
1790
|
+
$[2] = items;
|
|
1791
|
+
$[3] = onSelectedIdsChange;
|
|
1792
|
+
$[4] = onVisibilityChange;
|
|
1793
|
+
$[5] = props;
|
|
1794
|
+
$[6] = ref;
|
|
1795
|
+
$[7] = t1;
|
|
1796
|
+
$[8] = t2;
|
|
1797
|
+
$[9] = t3;
|
|
1798
|
+
} else {
|
|
1799
|
+
className = $[1];
|
|
1800
|
+
items = $[2];
|
|
1801
|
+
onSelectedIdsChange = $[3];
|
|
1802
|
+
onVisibilityChange = $[4];
|
|
1803
|
+
props = $[5];
|
|
1804
|
+
ref = $[6];
|
|
1805
|
+
t1 = $[7];
|
|
1806
|
+
t2 = $[8];
|
|
1807
|
+
t3 = $[9];
|
|
1808
|
+
}
|
|
1809
|
+
const selectionMode = t1 === void 0 ? "none" : t1;
|
|
1810
|
+
let t4;
|
|
1811
|
+
if ($[10] !== t2) {
|
|
1812
|
+
t4 = t2 === void 0 ? [] : t2;
|
|
1813
|
+
$[10] = t2;
|
|
1814
|
+
$[11] = t4;
|
|
1815
|
+
} else t4 = $[11];
|
|
1816
|
+
const selectedIds = t4;
|
|
1817
|
+
const showAllToggle = t3 === void 0 ? false : t3;
|
|
1818
|
+
const labels = React.use(MapContext)?.labels ?? defaultLabels;
|
|
1819
|
+
let t5;
|
|
1820
|
+
if ($[12] !== items) {
|
|
1821
|
+
t5 = items.every(_temp13);
|
|
1822
|
+
$[12] = items;
|
|
1823
|
+
$[13] = t5;
|
|
1824
|
+
} else t5 = $[13];
|
|
1825
|
+
const allVisible = t5;
|
|
1826
|
+
let t6;
|
|
1827
|
+
if ($[14] !== onSelectedIdsChange || $[15] !== selectedIds || $[16] !== selectionMode) {
|
|
1828
|
+
t6 = (id) => {
|
|
1829
|
+
const on = selectedIds.includes(id);
|
|
1830
|
+
if (selectionMode === "single") onSelectedIdsChange?.(on ? [] : [id]);
|
|
1831
|
+
else onSelectedIdsChange?.(on ? selectedIds.filter((s) => s !== id) : [...selectedIds, id]);
|
|
1832
|
+
};
|
|
1833
|
+
$[14] = onSelectedIdsChange;
|
|
1834
|
+
$[15] = selectedIds;
|
|
1835
|
+
$[16] = selectionMode;
|
|
1836
|
+
$[17] = t6;
|
|
1837
|
+
} else t6 = $[17];
|
|
1838
|
+
const toggle = t6;
|
|
1839
|
+
let t7;
|
|
1840
|
+
if ($[18] !== className) {
|
|
1841
|
+
t7 = cx("oui-map-legend", className);
|
|
1842
|
+
$[18] = className;
|
|
1843
|
+
$[19] = t7;
|
|
1844
|
+
} else t7 = $[19];
|
|
1845
|
+
let t8;
|
|
1846
|
+
if ($[20] !== allVisible || $[21] !== items || $[22] !== labels || $[23] !== onVisibilityChange || $[24] !== showAllToggle) {
|
|
1847
|
+
t8 = onVisibilityChange && showAllToggle && /* @__PURE__ */ jsx("button", {
|
|
1848
|
+
type: "button",
|
|
1849
|
+
className: "oui-map-legend__toggle-all",
|
|
1850
|
+
onClick: () => onVisibilityChange(items.map(_temp14), !allVisible),
|
|
1851
|
+
children: allVisible ? labels.hideAll : labels.showAll
|
|
1852
|
+
});
|
|
1853
|
+
$[20] = allVisible;
|
|
1854
|
+
$[21] = items;
|
|
1855
|
+
$[22] = labels;
|
|
1856
|
+
$[23] = onVisibilityChange;
|
|
1857
|
+
$[24] = showAllToggle;
|
|
1858
|
+
$[25] = t8;
|
|
1859
|
+
} else t8 = $[25];
|
|
1860
|
+
let t9;
|
|
1861
|
+
if ($[26] !== items || $[27] !== labels || $[28] !== onVisibilityChange || $[29] !== selectedIds || $[30] !== selectionMode || $[31] !== toggle) {
|
|
1862
|
+
let t10;
|
|
1863
|
+
if ($[33] !== labels || $[34] !== onVisibilityChange || $[35] !== selectedIds || $[36] !== selectionMode || $[37] !== toggle) {
|
|
1864
|
+
t10 = (item_1) => {
|
|
1865
|
+
const selected = selectedIds.includes(item_1.id);
|
|
1866
|
+
const visible = item_1.visible !== false;
|
|
1867
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1868
|
+
/* @__PURE__ */ jsx("span", {
|
|
1869
|
+
className: "oui-map-legend__swatch",
|
|
1870
|
+
style: { "--_swatch": item_1.color }
|
|
1871
|
+
}),
|
|
1872
|
+
/* @__PURE__ */ jsx("span", {
|
|
1873
|
+
className: "oui-map-legend__label",
|
|
1874
|
+
children: item_1.label
|
|
1875
|
+
}),
|
|
1876
|
+
item_1.count != null && /* @__PURE__ */ jsx("span", {
|
|
1877
|
+
className: "oui-map-legend__count",
|
|
1878
|
+
children: item_1.count
|
|
1879
|
+
})
|
|
1880
|
+
] });
|
|
1881
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
1882
|
+
className: "oui-map-legend__item",
|
|
1883
|
+
"data-selected": selected || void 0,
|
|
1884
|
+
"data-hidden": visible ? void 0 : "",
|
|
1885
|
+
children: [selectionMode === "none" ? /* @__PURE__ */ jsx("span", {
|
|
1886
|
+
className: "oui-map-legend__entry",
|
|
1887
|
+
children: content
|
|
1888
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
1889
|
+
type: "button",
|
|
1890
|
+
className: "oui-map-legend__entry",
|
|
1891
|
+
"aria-pressed": selected,
|
|
1892
|
+
onClick: () => toggle(item_1.id),
|
|
1893
|
+
children: content
|
|
1894
|
+
}), onVisibilityChange && /* @__PURE__ */ jsx("button", {
|
|
1895
|
+
type: "button",
|
|
1896
|
+
className: "oui-map-legend__visibility",
|
|
1897
|
+
"aria-label": `${visible ? labels.hide : labels.show} ${typeof item_1.label === "string" ? item_1.label : item_1.id}`,
|
|
1898
|
+
onClick: () => onVisibilityChange([item_1.id], !visible),
|
|
1899
|
+
children: visible ? /* @__PURE__ */ jsx(EyeIcon, {}) : /* @__PURE__ */ jsx(EyeOffIcon, {})
|
|
1900
|
+
})]
|
|
1901
|
+
}, item_1.id);
|
|
1902
|
+
};
|
|
1903
|
+
$[33] = labels;
|
|
1904
|
+
$[34] = onVisibilityChange;
|
|
1905
|
+
$[35] = selectedIds;
|
|
1906
|
+
$[36] = selectionMode;
|
|
1907
|
+
$[37] = toggle;
|
|
1908
|
+
$[38] = t10;
|
|
1909
|
+
} else t10 = $[38];
|
|
1910
|
+
t9 = items.map(t10);
|
|
1911
|
+
$[26] = items;
|
|
1912
|
+
$[27] = labels;
|
|
1913
|
+
$[28] = onVisibilityChange;
|
|
1914
|
+
$[29] = selectedIds;
|
|
1915
|
+
$[30] = selectionMode;
|
|
1916
|
+
$[31] = toggle;
|
|
1917
|
+
$[32] = t9;
|
|
1918
|
+
} else t9 = $[32];
|
|
1919
|
+
let t10;
|
|
1920
|
+
if ($[39] !== t9) {
|
|
1921
|
+
t10 = /* @__PURE__ */ jsx("ul", {
|
|
1922
|
+
className: "oui-map-legend__list",
|
|
1923
|
+
children: t9
|
|
1924
|
+
});
|
|
1925
|
+
$[39] = t9;
|
|
1926
|
+
$[40] = t10;
|
|
1927
|
+
} else t10 = $[40];
|
|
1928
|
+
let t11;
|
|
1929
|
+
if ($[41] !== props || $[42] !== ref || $[43] !== selectionMode || $[44] !== t10 || $[45] !== t7 || $[46] !== t8) {
|
|
1930
|
+
t11 = /* @__PURE__ */ jsxs("div", {
|
|
1931
|
+
ref,
|
|
1932
|
+
className: t7,
|
|
1933
|
+
"data-selection-mode": selectionMode,
|
|
1934
|
+
...props,
|
|
1935
|
+
children: [t8, t10]
|
|
1936
|
+
});
|
|
1937
|
+
$[41] = props;
|
|
1938
|
+
$[42] = ref;
|
|
1939
|
+
$[43] = selectionMode;
|
|
1940
|
+
$[44] = t10;
|
|
1941
|
+
$[45] = t7;
|
|
1942
|
+
$[46] = t8;
|
|
1943
|
+
$[47] = t11;
|
|
1944
|
+
} else t11 = $[47];
|
|
1945
|
+
return t11;
|
|
1946
|
+
}
|
|
1947
|
+
function _temp14(item_0) {
|
|
1948
|
+
return item_0.id;
|
|
1949
|
+
}
|
|
1950
|
+
function _temp13(item) {
|
|
1951
|
+
return item.visible !== false;
|
|
1952
|
+
}
|
|
1953
|
+
/** Segmented switch between the root's `baseLayers` (e.g. streets and satellite). Put it in a `Map.Overlay`. */
|
|
1954
|
+
function MapBaseLayerSwitch(t0) {
|
|
1955
|
+
const $ = c(11);
|
|
1956
|
+
let props;
|
|
1957
|
+
let t1;
|
|
1958
|
+
if ($[0] !== t0) {
|
|
1959
|
+
({size: t1, ...props} = t0);
|
|
1960
|
+
$[0] = t0;
|
|
1961
|
+
$[1] = props;
|
|
1962
|
+
$[2] = t1;
|
|
1963
|
+
} else {
|
|
1964
|
+
props = $[1];
|
|
1965
|
+
t1 = $[2];
|
|
1966
|
+
}
|
|
1967
|
+
const size = t1 === void 0 ? "sm" : t1;
|
|
1968
|
+
const { baseLayers, baseLayer, setBaseLayer } = useMapContext("Map.BaseLayerSwitch");
|
|
1969
|
+
let t2;
|
|
1970
|
+
if ($[3] !== baseLayers) {
|
|
1971
|
+
t2 = baseLayers.map(_temp15);
|
|
1972
|
+
$[3] = baseLayers;
|
|
1973
|
+
$[4] = t2;
|
|
1974
|
+
} else t2 = $[4];
|
|
1975
|
+
let t3;
|
|
1976
|
+
if ($[5] !== baseLayer || $[6] !== props || $[7] !== setBaseLayer || $[8] !== size || $[9] !== t2) {
|
|
1977
|
+
t3 = /* @__PURE__ */ jsx(SegmentedControl, {
|
|
1978
|
+
size,
|
|
1979
|
+
options: t2,
|
|
1980
|
+
value: baseLayer,
|
|
1981
|
+
onValueChange: setBaseLayer,
|
|
1982
|
+
...props
|
|
1983
|
+
});
|
|
1984
|
+
$[5] = baseLayer;
|
|
1985
|
+
$[6] = props;
|
|
1986
|
+
$[7] = setBaseLayer;
|
|
1987
|
+
$[8] = size;
|
|
1988
|
+
$[9] = t2;
|
|
1989
|
+
$[10] = t3;
|
|
1990
|
+
} else t3 = $[10];
|
|
1991
|
+
return t3;
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Map components on MapLibre, from `@optimum-intelligence/opti-ui/map`. `Map.Root` holds the map; inside
|
|
1995
|
+
* it, `Map.Areas`, `Map.Routes` and `Map.Points` draw arrays of items as single GeoJSON layers,
|
|
1996
|
+
* `Map.Marker` adds HTML pins, `Map.Popup` and `Map.Tooltip` show content at a position, and
|
|
1997
|
+
* `Map.Overlay` floats `Map.Legend`, `Map.BaseLayerSwitch` or cards over a corner.
|
|
1998
|
+
*
|
|
1999
|
+
* @example
|
|
2000
|
+
* <Map.Root baseLayers={baseLayers} fit="selected">
|
|
2001
|
+
* <Map.Areas items={zones} />
|
|
2002
|
+
* <Map.Routes items={trips} selectedIds={selected} onItemClick={(t) => setSelected([t.id])} />
|
|
2003
|
+
* <Map.Overlay position="top-left">
|
|
2004
|
+
* <Map.Legend items={legend} selectionMode="single" selectedIds={selected} onSelectedIdsChange={setSelected} />
|
|
2005
|
+
* </Map.Overlay>
|
|
2006
|
+
* <Map.Overlay position="bottom-left">
|
|
2007
|
+
* <Map.BaseLayerSwitch />
|
|
2008
|
+
* </Map.Overlay>
|
|
2009
|
+
* </Map.Root>
|
|
2010
|
+
*/
|
|
2011
|
+
function _temp15(layer) {
|
|
2012
|
+
return {
|
|
2013
|
+
value: layer.id,
|
|
2014
|
+
label: layer.label
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
var Map$1 = {
|
|
2018
|
+
Root: MapRoot,
|
|
2019
|
+
Routes: MapRoutes,
|
|
2020
|
+
Areas: MapAreas,
|
|
2021
|
+
Points: MapPoints,
|
|
2022
|
+
Marker: MapMarker,
|
|
2023
|
+
Popup: MapPopup,
|
|
2024
|
+
Tooltip: MapTooltip,
|
|
2025
|
+
Overlay: MapOverlay,
|
|
2026
|
+
Legend: MapLegend,
|
|
2027
|
+
BaseLayerSwitch: MapBaseLayerSwitch
|
|
2028
|
+
};
|
|
2029
|
+
//#endregion
|
|
2030
|
+
export { Map$1 as Map, rasterStyle };
|
|
2031
|
+
|
|
2032
|
+
//# sourceMappingURL=Map.js.map
|