@sovereignsquad/gds-core 3.9.0 → 6.8.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.
- package/dist/GdsBadge-DqTdnomt.d.mts +417 -0
- package/dist/GdsBadge-DqTdnomt.d.ts +417 -0
- package/dist/PartnerDiscovery-As_-JKtb.d.ts +732 -0
- package/dist/PartnerDiscovery-Bwxixtka.d.mts +732 -0
- package/dist/QuickStartCard-CB7r-85z.d.ts +17500 -0
- package/dist/QuickStartCard-xIP1gbCL.d.mts +17500 -0
- package/dist/chunk-2AX4NCID.mjs +9 -0
- package/dist/chunk-2IUOZG4C.mjs +9 -0
- package/dist/chunk-2XZMNT7I.mjs +338 -0
- package/dist/chunk-3D7BVS7D.mjs +9 -0
- package/dist/chunk-4LG6EED4.mjs +338 -0
- package/dist/chunk-6LULEPIE.mjs +9 -0
- package/dist/chunk-6PBDLFSF.mjs +338 -0
- package/dist/{chunk-TQ7ZYMEA.mjs → chunk-BH2SMTND.mjs} +2258 -4014
- package/dist/chunk-BHR4A3C6.mjs +338 -0
- package/dist/chunk-CNTTKK3H.mjs +338 -0
- package/dist/chunk-GGDCO5HR.mjs +338 -0
- package/dist/chunk-GKNSUUUE.mjs +338 -0
- package/dist/chunk-GMK5GXWR.mjs +338 -0
- package/dist/chunk-H2QNW4D5.mjs +1768 -0
- package/dist/chunk-IHPZ7BNV.mjs +338 -0
- package/dist/chunk-J66ITCXC.mjs +473 -0
- package/dist/chunk-J6MXKFIM.mjs +9 -0
- package/dist/chunk-JTMPFTCK.mjs +338 -0
- package/dist/{chunk-BUC7QXRO.mjs → chunk-KFEPREUF.mjs} +13 -5
- package/dist/chunk-LNVLXOLI.mjs +9 -0
- package/dist/chunk-MAIU557K.mjs +9 -0
- package/dist/chunk-MPZFCWWS.mjs +210 -0
- package/dist/chunk-NWS7KJ2G.mjs +245 -0
- package/dist/chunk-OC3M4CZY.mjs +9 -0
- package/dist/chunk-QO653DAE.mjs +338 -0
- package/dist/chunk-RCLWUNMR.mjs +9 -0
- package/dist/chunk-SHQDVHGR.mjs +338 -0
- package/dist/{chunk-5AJJNRZF.mjs → chunk-TJ3WMH25.mjs} +1916 -2026
- package/dist/chunk-VU2JLVD3.mjs +89 -0
- package/dist/chunk-W5O2JSVK.mjs +20 -0
- package/dist/chunk-WNOWHB26.mjs +9 -0
- package/dist/chunk-XLPTCIXT.mjs +9 -0
- package/dist/chunk-ZCQXBKDM.mjs +24 -0
- package/dist/chunk-ZFGYQSNR.mjs +33 -0
- package/dist/client.d.mts +1296 -37
- package/dist/client.d.ts +1296 -37
- package/dist/client.js +11039 -6379
- package/dist/client.mjs +273 -58
- package/dist/en-Dd7uvXnv.d.mts +336 -0
- package/dist/en-Dd7uvXnv.d.ts +336 -0
- package/dist/index.d.mts +632 -5
- package/dist/index.d.ts +632 -5
- package/dist/index.js +21618 -14851
- package/dist/index.mjs +2138 -59
- package/dist/locales/lazy/all.d.mts +2 -0
- package/dist/locales/lazy/all.d.ts +2 -0
- package/dist/locales/lazy/all.js +1 -0
- package/dist/locales/lazy/all.mjs +24 -0
- package/dist/locales/lazy/ar.d.mts +2 -0
- package/dist/locales/lazy/ar.d.ts +2 -0
- package/dist/locales/lazy/ar.js +683 -0
- package/dist/locales/lazy/ar.mjs +4 -0
- package/dist/locales/lazy/de.d.mts +2 -0
- package/dist/locales/lazy/de.d.ts +2 -0
- package/dist/locales/lazy/de.js +683 -0
- package/dist/locales/lazy/de.mjs +4 -0
- package/dist/locales/lazy/es.d.mts +2 -0
- package/dist/locales/lazy/es.d.ts +2 -0
- package/dist/locales/lazy/es.js +683 -0
- package/dist/locales/lazy/es.mjs +4 -0
- package/dist/locales/lazy/fr.d.mts +2 -0
- package/dist/locales/lazy/fr.d.ts +2 -0
- package/dist/locales/lazy/fr.js +683 -0
- package/dist/locales/lazy/fr.mjs +4 -0
- package/dist/locales/lazy/he.d.mts +2 -0
- package/dist/locales/lazy/he.d.ts +2 -0
- package/dist/locales/lazy/he.js +683 -0
- package/dist/locales/lazy/he.mjs +4 -0
- package/dist/locales/lazy/hu.d.mts +2 -0
- package/dist/locales/lazy/hu.d.ts +2 -0
- package/dist/locales/lazy/hu.js +683 -0
- package/dist/locales/lazy/hu.mjs +4 -0
- package/dist/locales/lazy/index.d.mts +25 -0
- package/dist/locales/lazy/index.d.ts +25 -0
- package/dist/locales/lazy/index.js +384 -0
- package/dist/locales/lazy/index.mjs +9 -0
- package/dist/locales/lazy/it.d.mts +2 -0
- package/dist/locales/lazy/it.d.ts +2 -0
- package/dist/locales/lazy/it.js +683 -0
- package/dist/locales/lazy/it.mjs +4 -0
- package/dist/locales/lazy/ja.d.mts +2 -0
- package/dist/locales/lazy/ja.d.ts +2 -0
- package/dist/locales/lazy/ja.js +683 -0
- package/dist/locales/lazy/ja.mjs +4 -0
- package/dist/locales/lazy/ko.d.mts +2 -0
- package/dist/locales/lazy/ko.d.ts +2 -0
- package/dist/locales/lazy/ko.js +683 -0
- package/dist/locales/lazy/ko.mjs +4 -0
- package/dist/locales/lazy/ru.d.mts +2 -0
- package/dist/locales/lazy/ru.d.ts +2 -0
- package/dist/locales/lazy/ru.js +683 -0
- package/dist/locales/lazy/ru.mjs +4 -0
- package/dist/locales/lazy/zh.d.mts +2 -0
- package/dist/locales/lazy/zh.d.ts +2 -0
- package/dist/locales/lazy/zh.js +683 -0
- package/dist/locales/lazy/zh.mjs +4 -0
- package/dist/map.css +664 -0
- package/dist/map.d.mts +118 -0
- package/dist/map.d.ts +118 -0
- package/dist/map.js +777 -0
- package/dist/map.mjs +395 -0
- package/dist/reference-theme-explorer.d.mts +34 -0
- package/dist/reference-theme-explorer.d.ts +34 -0
- package/dist/reference-theme-explorer.js +8322 -0
- package/dist/reference-theme-explorer.mjs +1988 -0
- package/dist/rich-text-editor.d.mts +32 -0
- package/dist/rich-text-editor.d.ts +32 -0
- package/dist/rich-text-editor.js +469 -0
- package/dist/rich-text-editor.mjs +115 -0
- package/dist/server.d.mts +112 -248
- package/dist/server.d.ts +112 -248
- package/dist/server.js +6797 -1679
- package/dist/server.mjs +588 -55
- package/package.json +104 -9
- package/dist/AISearchCard-Bbnsd-yl.d.mts +0 -7786
- package/dist/AISearchCard-Bbnsd-yl.d.ts +0 -7786
package/dist/map.mjs
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GdsInlineLink
|
|
3
|
+
} from "./chunk-W5O2JSVK.mjs";
|
|
4
|
+
import {
|
|
5
|
+
GDS_PIN_APPROXIMATE_DASH,
|
|
6
|
+
GDS_PIN_EMPHASIS_STROKE,
|
|
7
|
+
GDS_PIN_SELECTED_SCALE
|
|
8
|
+
} from "./chunk-VU2JLVD3.mjs";
|
|
9
|
+
import {
|
|
10
|
+
GDS_PIN_SILHOUETTE_PATH,
|
|
11
|
+
StateBlock
|
|
12
|
+
} from "./chunk-MPZFCWWS.mjs";
|
|
13
|
+
import "./chunk-J66ITCXC.mjs";
|
|
14
|
+
|
|
15
|
+
// src/GdsMap.client.tsx
|
|
16
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
17
|
+
import { Box, Group, Stack, Text, UnstyledButton } from "@mantine/core";
|
|
18
|
+
import { useGdsTranslation, useGdsAmbientTheme, computeGdsThemeIdentity, resolveGdsAccentTokens } from "@sovereignsquad/gds-theme";
|
|
19
|
+
|
|
20
|
+
// src/map-tile-policy.ts
|
|
21
|
+
var GDS_OSM_TILE_SOURCE = Object.freeze({
|
|
22
|
+
url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
23
|
+
attributionText: "\xA9 OpenStreetMap contributors",
|
|
24
|
+
attributionHref: "https://www.openstreetmap.org/copyright",
|
|
25
|
+
maxZoom: 19
|
|
26
|
+
});
|
|
27
|
+
var GdsTileAttributionError = class extends Error {
|
|
28
|
+
constructor(message) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = "GdsTileAttributionError";
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function assertGdsTileSource(source) {
|
|
34
|
+
if (!source?.url?.trim()) throw new GdsTileAttributionError("Tile source has no URL.");
|
|
35
|
+
if (!source.attributionText?.trim()) {
|
|
36
|
+
throw new GdsTileAttributionError(
|
|
37
|
+
"Tile source has no attributionText. OpenStreetMap data is ODbL-licensed and its credit is a licence condition, not a design choice \u2014 a source cannot be used without one."
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (!source.attributionHref?.trim()) {
|
|
41
|
+
throw new GdsTileAttributionError("Tile source has no attributionHref; the credit must link to the licence or source.");
|
|
42
|
+
}
|
|
43
|
+
return source;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/GdsMap.client.tsx
|
|
47
|
+
import { createPortal } from "react-dom";
|
|
48
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
49
|
+
function classifyGdsTileFailure(onLine) {
|
|
50
|
+
return onLine ? "indeterminate" : "offline";
|
|
51
|
+
}
|
|
52
|
+
var GDS_TILE_FAILURE_THRESHOLD = 4;
|
|
53
|
+
var GDS_TILE_RETRY_DELAYS_MS = [4e3, 12e3];
|
|
54
|
+
var DEFAULT_VIEWPORT = { center: { lat: 51.505, lng: -0.09 }, zoom: 13 };
|
|
55
|
+
function GdsMap({
|
|
56
|
+
markers,
|
|
57
|
+
viewport,
|
|
58
|
+
defaultViewport,
|
|
59
|
+
fitBounds,
|
|
60
|
+
minZoom = 3,
|
|
61
|
+
maxZoom = 18,
|
|
62
|
+
maxBounds,
|
|
63
|
+
onViewportChange,
|
|
64
|
+
onMarkerSelect,
|
|
65
|
+
selectedMarkerId,
|
|
66
|
+
interactive = true,
|
|
67
|
+
// rem-based via --mantine-scale, not a fixed pixel count.
|
|
68
|
+
preset,
|
|
69
|
+
colorScheme,
|
|
70
|
+
label,
|
|
71
|
+
onStateChange,
|
|
72
|
+
height = "calc(26.25rem * var(--mantine-scale, 1))",
|
|
73
|
+
tileSource = GDS_OSM_TILE_SOURCE,
|
|
74
|
+
listPlacement = "below",
|
|
75
|
+
offline = false,
|
|
76
|
+
renderMarkerPreview
|
|
77
|
+
}) {
|
|
78
|
+
const containerRef = useRef(null);
|
|
79
|
+
const engineRef = useRef(null);
|
|
80
|
+
const [state, setState] = useState("initializing");
|
|
81
|
+
const regionId = useId();
|
|
82
|
+
const { t } = useGdsTranslation();
|
|
83
|
+
const ambient = useGdsAmbientTheme();
|
|
84
|
+
const activePreset = preset ?? ambient.preset;
|
|
85
|
+
const activeScheme = colorScheme ?? ambient.colorScheme;
|
|
86
|
+
const [tilesFailed, setTilesFailed] = useState(false);
|
|
87
|
+
const tileHealthRef = useRef({ loads: 0, errors: 0, autoRetries: 0 });
|
|
88
|
+
const tileLayerRef = useRef(null);
|
|
89
|
+
const retryTimerRef = useRef(null);
|
|
90
|
+
const popupHostsRef = useRef(/* @__PURE__ */ new Map());
|
|
91
|
+
const [openPopupMarkerId, setOpenPopupMarkerId] = useState(null);
|
|
92
|
+
const [dockPreview, setDockPreview] = useState(false);
|
|
93
|
+
const retryTiles = useCallback(() => {
|
|
94
|
+
tileHealthRef.current.loads = 0;
|
|
95
|
+
tileHealthRef.current.errors = 0;
|
|
96
|
+
setTilesFailed(false);
|
|
97
|
+
tileLayerRef.current?.redraw();
|
|
98
|
+
}, []);
|
|
99
|
+
useEffect(() => () => {
|
|
100
|
+
if (retryTimerRef.current) clearTimeout(retryTimerRef.current);
|
|
101
|
+
}, []);
|
|
102
|
+
const themeIdentity = computeGdsThemeIdentity({ preset: activePreset, colorScheme: activeScheme });
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
let disposed = false;
|
|
105
|
+
let map = null;
|
|
106
|
+
popupHostsRef.current.clear();
|
|
107
|
+
setOpenPopupMarkerId(null);
|
|
108
|
+
let resizeObserver;
|
|
109
|
+
(async () => {
|
|
110
|
+
try {
|
|
111
|
+
const L = (await import("leaflet")).default ?? await import("leaflet");
|
|
112
|
+
if (disposed || !containerRef.current) return;
|
|
113
|
+
const initial = viewport ?? defaultViewport ?? DEFAULT_VIEWPORT;
|
|
114
|
+
map = L.map(containerRef.current, {
|
|
115
|
+
center: [initial.center.lat, initial.center.lng],
|
|
116
|
+
zoom: initial.zoom,
|
|
117
|
+
minZoom,
|
|
118
|
+
maxZoom,
|
|
119
|
+
// Leaflet's default chrome is suppressed, not restyled; GDS controls replace it.
|
|
120
|
+
zoomControl: false,
|
|
121
|
+
attributionControl: false,
|
|
122
|
+
dragging: interactive,
|
|
123
|
+
scrollWheelZoom: interactive,
|
|
124
|
+
doubleClickZoom: interactive,
|
|
125
|
+
keyboard: interactive,
|
|
126
|
+
...maxBounds ? { maxBounds: [[maxBounds.south, maxBounds.west], [maxBounds.north, maxBounds.east]] } : {}
|
|
127
|
+
});
|
|
128
|
+
engineRef.current = map;
|
|
129
|
+
const source = assertGdsTileSource(tileSource);
|
|
130
|
+
if (!offline) {
|
|
131
|
+
const tiles = L.tileLayer(source.url, {
|
|
132
|
+
maxZoom: Math.min(maxZoom, source.maxZoom),
|
|
133
|
+
// Leaflet's attribution control is disabled; credit renders as GDS UI below instead.
|
|
134
|
+
attribution: ""
|
|
135
|
+
}).addTo(map);
|
|
136
|
+
tileLayerRef.current = tiles;
|
|
137
|
+
tiles.on("tileload", () => {
|
|
138
|
+
tileHealthRef.current.loads += 1;
|
|
139
|
+
if (tileHealthRef.current.errors > 0) tileHealthRef.current.errors = 0;
|
|
140
|
+
setTilesFailed(false);
|
|
141
|
+
});
|
|
142
|
+
tiles.on("tileerror", () => {
|
|
143
|
+
const health = tileHealthRef.current;
|
|
144
|
+
health.errors += 1;
|
|
145
|
+
if (health.loads === 0 && health.errors >= GDS_TILE_FAILURE_THRESHOLD) {
|
|
146
|
+
setTilesFailed(true);
|
|
147
|
+
if (health.autoRetries < GDS_TILE_RETRY_DELAYS_MS.length && !retryTimerRef.current) {
|
|
148
|
+
const base = GDS_TILE_RETRY_DELAYS_MS[health.autoRetries];
|
|
149
|
+
health.autoRetries += 1;
|
|
150
|
+
retryTimerRef.current = setTimeout(() => {
|
|
151
|
+
retryTimerRef.current = null;
|
|
152
|
+
tileHealthRef.current.loads = 0;
|
|
153
|
+
tileHealthRef.current.errors = 0;
|
|
154
|
+
setTilesFailed(false);
|
|
155
|
+
tileLayerRef.current?.redraw();
|
|
156
|
+
}, base + (Math.random() - 0.5) * base * 0.5);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const accentTokens = resolveGdsAccentTokens(void 0, activeScheme, activePreset);
|
|
162
|
+
const layer = L.layerGroup().addTo(map);
|
|
163
|
+
const placedById = /* @__PURE__ */ new Map();
|
|
164
|
+
for (const marker of orderedMarkers) {
|
|
165
|
+
const shade = marker.shade ?? "base";
|
|
166
|
+
const accentVar = `var(--gds-accent-${marker.accent}-${shade}, ${accentTokens[`--gds-accent-${marker.accent}-${shade}`] ?? "currentColor"})`;
|
|
167
|
+
const selected = marker.id === selectedMarkerId;
|
|
168
|
+
const stroke = selected ? GDS_PIN_EMPHASIS_STROKE : 1.75;
|
|
169
|
+
const dash = marker.approximate ? ` stroke-dasharray="${GDS_PIN_APPROXIMATE_DASH}"` : "";
|
|
170
|
+
const strokeColour = marker.approximate ? "var(--mantine-color-dark-7, #1f2937)" : accentVar;
|
|
171
|
+
const scale = selected ? ` transform:scale(${GDS_PIN_SELECTED_SCALE}); transform-origin:50% 100%;` : "";
|
|
172
|
+
const icon = L.divIcon({
|
|
173
|
+
className: "gds-map-pin",
|
|
174
|
+
// Glyph is aria-hidden; the marker's accessible name carries the meaning.
|
|
175
|
+
html: `<svg aria-hidden="true" viewBox="0 0 24 24" style="display:block;width:calc(var(--gds-space-sm, 0.75rem) * 2.5);height:calc(var(--gds-space-sm, 0.75rem) * 2.5);filter:drop-shadow(var(--gds-elevation-1, 0 1px 2px rgba(0,0,0,0.2)));${scale}"><path d="${GDS_PIN_SILHOUETTE_PATH}" fill="${accentVar}" stroke="${strokeColour}" stroke-width="${stroke}"${dash} stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="11" r="3" fill="var(--gds-text-on-inverse, var(--mantine-color-white, #ffffff))"/></svg>`,
|
|
176
|
+
iconSize: [30, 30],
|
|
177
|
+
// Tail tip (12, 21.4 of 24) is the geographic point; anchoring at box centre would
|
|
178
|
+
// offset ~9px north.
|
|
179
|
+
iconAnchor: [15, 27],
|
|
180
|
+
popupAnchor: [0, -28]
|
|
181
|
+
});
|
|
182
|
+
const placed = L.marker([marker.position.lat, marker.position.lng], { icon, title: marker.label, alt: marker.label, keyboard: interactive }).addTo(layer);
|
|
183
|
+
if (onMarkerSelect) placed.on("click", () => onMarkerSelect(marker.id));
|
|
184
|
+
if (renderMarkerPreview) {
|
|
185
|
+
const host = document.createElement("div");
|
|
186
|
+
host.setAttribute("data-gds-map-popup-host", marker.id);
|
|
187
|
+
host.style.width = "clamp(15rem, 18rem, 76vw)";
|
|
188
|
+
placed.bindPopup(host, { closeButton: false, minWidth: 200, maxWidth: 380, maxHeight: 300, className: "gds-map-popup" });
|
|
189
|
+
placed.on("popupopen", () => setOpenPopupMarkerId(marker.id));
|
|
190
|
+
placed.on("popupclose", () => setOpenPopupMarkerId((current) => current === marker.id ? null : current));
|
|
191
|
+
popupHostsRef.current.set(marker.id, host);
|
|
192
|
+
placedById.set(marker.id, placed);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (onViewportChange) {
|
|
196
|
+
map.on("moveend", () => {
|
|
197
|
+
const m = map;
|
|
198
|
+
const c = m.getCenter();
|
|
199
|
+
onViewportChange({ center: { lat: c.lat, lng: c.lng }, zoom: m.getZoom() }, "user");
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (fitBounds) {
|
|
203
|
+
map.fitBounds([[fitBounds.south, fitBounds.west], [fitBounds.north, fitBounds.east]]);
|
|
204
|
+
}
|
|
205
|
+
const engine = map;
|
|
206
|
+
const revalidate = () => {
|
|
207
|
+
try {
|
|
208
|
+
engine.invalidateSize({ animate: false });
|
|
209
|
+
} catch {
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
revalidate();
|
|
213
|
+
requestAnimationFrame(revalidate);
|
|
214
|
+
if (selectedMarkerId && renderMarkerPreview) {
|
|
215
|
+
requestAnimationFrame(() => {
|
|
216
|
+
if (disposed) return;
|
|
217
|
+
const width = containerRef.current?.getBoundingClientRect().width ?? 0;
|
|
218
|
+
if (width >= 480) placedById.get(selectedMarkerId)?.openPopup();
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const measureDock = () => {
|
|
222
|
+
if (containerRef.current) setDockPreview(containerRef.current.getBoundingClientRect().width < 480);
|
|
223
|
+
};
|
|
224
|
+
measureDock();
|
|
225
|
+
if (typeof ResizeObserver !== "undefined" && containerRef.current) {
|
|
226
|
+
resizeObserver = new ResizeObserver(() => {
|
|
227
|
+
revalidate();
|
|
228
|
+
measureDock();
|
|
229
|
+
});
|
|
230
|
+
resizeObserver.observe(containerRef.current);
|
|
231
|
+
}
|
|
232
|
+
if (!disposed) {
|
|
233
|
+
setState("ready");
|
|
234
|
+
onStateChange?.("ready");
|
|
235
|
+
}
|
|
236
|
+
} catch {
|
|
237
|
+
if (!disposed) {
|
|
238
|
+
setState("error");
|
|
239
|
+
onStateChange?.("error");
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
})();
|
|
243
|
+
return () => {
|
|
244
|
+
disposed = true;
|
|
245
|
+
resizeObserver?.disconnect();
|
|
246
|
+
try {
|
|
247
|
+
map?.remove();
|
|
248
|
+
} catch {
|
|
249
|
+
}
|
|
250
|
+
engineRef.current = null;
|
|
251
|
+
};
|
|
252
|
+
}, [themeIdentity, interactive, minZoom, maxZoom, markers, selectedMarkerId, activeScheme, activePreset, offline]);
|
|
253
|
+
const orderedMarkers = useMemo(
|
|
254
|
+
() => [...markers].sort((a, b) => a.label.localeCompare(b.label)),
|
|
255
|
+
[markers]
|
|
256
|
+
);
|
|
257
|
+
const [announcement, setAnnouncement] = useState("");
|
|
258
|
+
const announceTimer = useRef(null);
|
|
259
|
+
const announce = useCallback((message) => {
|
|
260
|
+
if (announceTimer.current) clearTimeout(announceTimer.current);
|
|
261
|
+
announceTimer.current = setTimeout(() => setAnnouncement(message), 600);
|
|
262
|
+
}, []);
|
|
263
|
+
useEffect(() => () => {
|
|
264
|
+
if (announceTimer.current) clearTimeout(announceTimer.current);
|
|
265
|
+
}, []);
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
announce(`${orderedMarkers.length} ${orderedMarkers.length === 1 ? "place" : "places"} in view.`);
|
|
268
|
+
}, [orderedMarkers.length, announce]);
|
|
269
|
+
const list = /* @__PURE__ */ jsxs(Stack, { gap: "4xs", component: "section", "aria-label": `${label} \u2014 list view`, children: [
|
|
270
|
+
/* @__PURE__ */ jsxs(Text, { size: "sm", fw: 600, children: [
|
|
271
|
+
label,
|
|
272
|
+
" \u2014 list view"
|
|
273
|
+
] }),
|
|
274
|
+
orderedMarkers.length === 0 ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No places in view." }) : /* @__PURE__ */ jsx(Stack, { gap: 2, component: "ul", style: { listStyle: "none", margin: 0, padding: 0 }, children: orderedMarkers.map((marker) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
275
|
+
UnstyledButton,
|
|
276
|
+
{
|
|
277
|
+
onClick: () => {
|
|
278
|
+
onMarkerSelect?.(marker.id);
|
|
279
|
+
announce(`${marker.label} selected.`);
|
|
280
|
+
},
|
|
281
|
+
"aria-pressed": selectedMarkerId === marker.id,
|
|
282
|
+
"data-gds-map-list-item": marker.id,
|
|
283
|
+
style: {
|
|
284
|
+
display: "block",
|
|
285
|
+
width: "100%",
|
|
286
|
+
padding: "var(--gds-space-2xs) var(--gds-space-xs)",
|
|
287
|
+
borderRadius: "var(--gds-radius-chip)",
|
|
288
|
+
// Visible border, not just background tint: under forced-colors mode a
|
|
289
|
+
// background alone would vanish.
|
|
290
|
+
border: `var(--gds-focus-ring-width) ${selectedMarkerId === marker.id ? "solid" : "dashed"} ${selectedMarkerId === marker.id ? "var(--gds-focus-ring-color)" : "transparent"}`,
|
|
291
|
+
background: selectedMarkerId === marker.id ? "var(--gds-badge-soft-info)" : "transparent",
|
|
292
|
+
color: selectedMarkerId === marker.id ? "var(--gds-badge-soft-info-fg)" : "var(--gds-text-body)"
|
|
293
|
+
},
|
|
294
|
+
children: /* @__PURE__ */ jsxs(Group, { gap: "2xs", wrap: "nowrap", children: [
|
|
295
|
+
/* @__PURE__ */ jsx(Text, { size: "sm", children: marker.label }),
|
|
296
|
+
marker.approximate ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "(approximate location)" }) : null,
|
|
297
|
+
selectedMarkerId === marker.id ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "\u2014 selected" }) : null
|
|
298
|
+
] })
|
|
299
|
+
}
|
|
300
|
+
) }, marker.id)) })
|
|
301
|
+
] });
|
|
302
|
+
return /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
303
|
+
listPlacement === "above" ? list : null,
|
|
304
|
+
/* @__PURE__ */ jsxs(Box, { style: { position: "relative" }, children: [
|
|
305
|
+
/* @__PURE__ */ jsx(
|
|
306
|
+
Box,
|
|
307
|
+
{
|
|
308
|
+
ref: containerRef,
|
|
309
|
+
role: "region",
|
|
310
|
+
"aria-label": label,
|
|
311
|
+
"aria-describedby": `${regionId}-state`,
|
|
312
|
+
"data-gds-map": "",
|
|
313
|
+
"data-gds-map-state": state,
|
|
314
|
+
"data-gds-theme-identity": themeIdentity,
|
|
315
|
+
style: {
|
|
316
|
+
height,
|
|
317
|
+
borderRadius: "var(--gds-radius-panel)",
|
|
318
|
+
overflow: "hidden",
|
|
319
|
+
background: "var(--gds-bg-surface)",
|
|
320
|
+
border: "1px solid var(--gds-border-card)"
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
dockPreview && renderMarkerPreview && selectedMarkerId ? /* @__PURE__ */ jsx(
|
|
325
|
+
Box,
|
|
326
|
+
{
|
|
327
|
+
"data-gds-map-preview-dock": "",
|
|
328
|
+
style: {
|
|
329
|
+
position: "absolute",
|
|
330
|
+
left: "var(--gds-space-2xs)",
|
|
331
|
+
right: "var(--gds-space-2xs)",
|
|
332
|
+
bottom: "var(--gds-space-2xs)",
|
|
333
|
+
maxHeight: "85%",
|
|
334
|
+
overflowY: "auto",
|
|
335
|
+
zIndex: 700,
|
|
336
|
+
borderRadius: "var(--gds-radius-panel)"
|
|
337
|
+
},
|
|
338
|
+
children: renderMarkerPreview(selectedMarkerId)
|
|
339
|
+
}
|
|
340
|
+
) : null
|
|
341
|
+
] }),
|
|
342
|
+
offline ? /* @__PURE__ */ jsx(
|
|
343
|
+
StateBlock,
|
|
344
|
+
{
|
|
345
|
+
variant: "empty",
|
|
346
|
+
compact: true,
|
|
347
|
+
title: t("gds.gdsMap.offlineTitle", "Map imagery is off"),
|
|
348
|
+
description: t("gds.gdsMap.offlineDescription", "This environment does not load map tiles. Every place still appears as a marker and in the list.")
|
|
349
|
+
}
|
|
350
|
+
) : tilesFailed ? /* @__PURE__ */ jsx(
|
|
351
|
+
StateBlock,
|
|
352
|
+
{
|
|
353
|
+
variant: "error",
|
|
354
|
+
compact: true,
|
|
355
|
+
title: t("gds.gdsMap.tilesFailedTitle", "Map imagery could not be loaded"),
|
|
356
|
+
description: classifyGdsTileFailure(typeof navigator === "undefined" ? true : navigator.onLine) === "offline" ? t("gds.gdsMap.tilesFailedOffline", "You appear to be offline. Every place still appears as a marker and in the list.") : t("gds.gdsMap.tilesFailedIndeterminate", "The tile host could not be reached \u2014 the browser cannot tell whether the cause is the network, a content security policy, or the host itself. Every place still appears as a marker and in the list."),
|
|
357
|
+
action: /* @__PURE__ */ jsx(
|
|
358
|
+
UnstyledButton,
|
|
359
|
+
{
|
|
360
|
+
type: "button",
|
|
361
|
+
"data-gds-map-tile-retry": true,
|
|
362
|
+
onClick: retryTiles,
|
|
363
|
+
style: {
|
|
364
|
+
padding: "var(--gds-space-2xs) var(--gds-space-sm)",
|
|
365
|
+
borderRadius: "var(--gds-radius-chip)",
|
|
366
|
+
border: "1px solid var(--gds-border-card)",
|
|
367
|
+
color: "var(--gds-text-body)"
|
|
368
|
+
},
|
|
369
|
+
children: t("gds.gdsMap.tilesRetryLabel", "Try loading imagery again")
|
|
370
|
+
}
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
) : null,
|
|
374
|
+
/* @__PURE__ */ jsx(Text, { id: `${regionId}-state`, size: "sm", c: "dimmed", role: "status", "aria-live": "polite", children: state === "ready" ? `${label}: ${markers.length} ${markers.length === 1 ? "marker" : "markers"}.` : state === "error" ? `${label} could not be loaded.` : `${label} is loading.` }),
|
|
375
|
+
listPlacement === "below" ? list : null,
|
|
376
|
+
/* @__PURE__ */ jsx(
|
|
377
|
+
Text,
|
|
378
|
+
{
|
|
379
|
+
"data-gds-map-announcer": "",
|
|
380
|
+
role: "status",
|
|
381
|
+
"aria-live": "polite",
|
|
382
|
+
style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap" },
|
|
383
|
+
children: announcement
|
|
384
|
+
}
|
|
385
|
+
),
|
|
386
|
+
renderMarkerPreview && openPopupMarkerId && popupHostsRef.current.get(openPopupMarkerId) ? createPortal(renderMarkerPreview(openPopupMarkerId), popupHostsRef.current.get(openPopupMarkerId)) : null,
|
|
387
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", "data-gds-map-attribution": "", children: /* @__PURE__ */ jsx(GdsInlineLink, { href: tileSource.attributionHref, external: true, children: tileSource.attributionText }) })
|
|
388
|
+
] });
|
|
389
|
+
}
|
|
390
|
+
export {
|
|
391
|
+
GDS_OSM_TILE_SOURCE,
|
|
392
|
+
GdsMap,
|
|
393
|
+
GdsTileAttributionError,
|
|
394
|
+
assertGdsTileSource
|
|
395
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { MantineThemeOverride } from '@mantine/core';
|
|
3
|
+
import { GdsThemePresetId, GdsFontLaneId } from '@sovereignsquad/gds-theme';
|
|
4
|
+
|
|
5
|
+
/** Id of a GDS theme preset (re-exported from the theme package). */
|
|
6
|
+
type ThemePresetId = GdsThemePresetId;
|
|
7
|
+
/** Color scheme selection for a preview: light, dark, or OS-driven auto. */
|
|
8
|
+
type ThemeSchemeId = 'light' | 'dark' | 'auto';
|
|
9
|
+
/** Current Theme Lab selection reported via `onSelectionChange`. */
|
|
10
|
+
interface ThemeExplorerSelection {
|
|
11
|
+
preset: ThemePresetId;
|
|
12
|
+
colorScheme: ThemeSchemeId;
|
|
13
|
+
/** Resolved Mantine theme for the selected preset and brand options. */
|
|
14
|
+
theme: MantineThemeOverride;
|
|
15
|
+
fontLane?: GdsFontLaneId;
|
|
16
|
+
/** Stable key identifying the current preview configuration. */
|
|
17
|
+
runtimeKey?: string;
|
|
18
|
+
/** Brand primary color, applied only when the `brand` preset is active. */
|
|
19
|
+
brandPrimary?: string;
|
|
20
|
+
brandFlatSurfaces?: boolean;
|
|
21
|
+
brandEditorialSerif?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interactive Theme Lab reference: selects a theme preset, color scheme, brand
|
|
25
|
+
* options, and font lane; previews governed surfaces (with optional side-by-side
|
|
26
|
+
* comparison), the shipped vibe gallery, and the token contract, reporting the
|
|
27
|
+
* live selection through `onSelectionChange`.
|
|
28
|
+
*/
|
|
29
|
+
declare function ReferenceThemeExplorer({ initialSelection, onSelectionChange, }: {
|
|
30
|
+
initialSelection?: ThemeExplorerSelection;
|
|
31
|
+
onSelectionChange?: (selection: ThemeExplorerSelection) => void;
|
|
32
|
+
}): react.JSX.Element;
|
|
33
|
+
|
|
34
|
+
export { ReferenceThemeExplorer, type ThemeExplorerSelection, type ThemePresetId, type ThemeSchemeId };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { MantineThemeOverride } from '@mantine/core';
|
|
3
|
+
import { GdsThemePresetId, GdsFontLaneId } from '@sovereignsquad/gds-theme';
|
|
4
|
+
|
|
5
|
+
/** Id of a GDS theme preset (re-exported from the theme package). */
|
|
6
|
+
type ThemePresetId = GdsThemePresetId;
|
|
7
|
+
/** Color scheme selection for a preview: light, dark, or OS-driven auto. */
|
|
8
|
+
type ThemeSchemeId = 'light' | 'dark' | 'auto';
|
|
9
|
+
/** Current Theme Lab selection reported via `onSelectionChange`. */
|
|
10
|
+
interface ThemeExplorerSelection {
|
|
11
|
+
preset: ThemePresetId;
|
|
12
|
+
colorScheme: ThemeSchemeId;
|
|
13
|
+
/** Resolved Mantine theme for the selected preset and brand options. */
|
|
14
|
+
theme: MantineThemeOverride;
|
|
15
|
+
fontLane?: GdsFontLaneId;
|
|
16
|
+
/** Stable key identifying the current preview configuration. */
|
|
17
|
+
runtimeKey?: string;
|
|
18
|
+
/** Brand primary color, applied only when the `brand` preset is active. */
|
|
19
|
+
brandPrimary?: string;
|
|
20
|
+
brandFlatSurfaces?: boolean;
|
|
21
|
+
brandEditorialSerif?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interactive Theme Lab reference: selects a theme preset, color scheme, brand
|
|
25
|
+
* options, and font lane; previews governed surfaces (with optional side-by-side
|
|
26
|
+
* comparison), the shipped vibe gallery, and the token contract, reporting the
|
|
27
|
+
* live selection through `onSelectionChange`.
|
|
28
|
+
*/
|
|
29
|
+
declare function ReferenceThemeExplorer({ initialSelection, onSelectionChange, }: {
|
|
30
|
+
initialSelection?: ThemeExplorerSelection;
|
|
31
|
+
onSelectionChange?: (selection: ThemeExplorerSelection) => void;
|
|
32
|
+
}): react.JSX.Element;
|
|
33
|
+
|
|
34
|
+
export { ReferenceThemeExplorer, type ThemeExplorerSelection, type ThemePresetId, type ThemeSchemeId };
|