@kinloom/ui 0.0.0-stage → 0.1.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/dist/KinloomApp.d.ts +22 -0
- package/dist/KinloomApp.d.ts.map +1 -0
- package/dist/KinloomApp.js +88 -0
- package/dist/KinloomApp.js.map +1 -0
- package/dist/adapters/httpWikiDataSource.d.ts +151 -0
- package/dist/adapters/httpWikiDataSource.d.ts.map +1 -0
- package/dist/adapters/httpWikiDataSource.js +361 -0
- package/dist/adapters/httpWikiDataSource.js.map +1 -0
- package/dist/adapters/staticDemoDataSource.d.ts +22 -0
- package/dist/adapters/staticDemoDataSource.d.ts.map +1 -0
- package/dist/adapters/staticDemoDataSource.js +81 -0
- package/dist/adapters/staticDemoDataSource.js.map +1 -0
- package/dist/components/AppErrorBoundary.d.ts +20 -0
- package/dist/components/AppErrorBoundary.d.ts.map +1 -0
- package/dist/components/AppErrorBoundary.js +61 -0
- package/dist/components/AppErrorBoundary.js.map +1 -0
- package/dist/components/ArchivalMarkdown.d.ts +25 -0
- package/dist/components/ArchivalMarkdown.d.ts.map +1 -0
- package/dist/components/ArchivalMarkdown.js +159 -0
- package/dist/components/ArchivalMarkdown.js.map +1 -0
- package/dist/components/Atoms.d.ts +35 -0
- package/dist/components/Atoms.d.ts.map +1 -0
- package/dist/components/Atoms.js +265 -0
- package/dist/components/Atoms.js.map +1 -0
- package/dist/components/BlankScreenWatchdog.d.ts +3 -0
- package/dist/components/BlankScreenWatchdog.d.ts.map +1 -0
- package/dist/components/BlankScreenWatchdog.js +46 -0
- package/dist/components/BlankScreenWatchdog.js.map +1 -0
- package/dist/components/ExplorerTopBar.d.ts +3 -0
- package/dist/components/ExplorerTopBar.d.ts.map +1 -0
- package/dist/components/ExplorerTopBar.js +76 -0
- package/dist/components/ExplorerTopBar.js.map +1 -0
- package/dist/components/GlobalSearchModal.d.ts +3 -0
- package/dist/components/GlobalSearchModal.d.ts.map +1 -0
- package/dist/components/GlobalSearchModal.js +146 -0
- package/dist/components/GlobalSearchModal.js.map +1 -0
- package/dist/components/KinloomFooter.d.ts +6 -0
- package/dist/components/KinloomFooter.d.ts.map +1 -0
- package/dist/components/KinloomFooter.js +10 -0
- package/dist/components/KinloomFooter.js.map +1 -0
- package/dist/components/LocalSurveyMap.d.ts +11 -0
- package/dist/components/LocalSurveyMap.d.ts.map +1 -0
- package/dist/components/LocalSurveyMap.js +115 -0
- package/dist/components/LocalSurveyMap.js.map +1 -0
- package/dist/components/MediaPlayer.d.ts +15 -0
- package/dist/components/MediaPlayer.d.ts.map +1 -0
- package/dist/components/MediaPlayer.js +85 -0
- package/dist/components/MediaPlayer.js.map +1 -0
- package/dist/components/MilestoneStoryCard.d.ts +13 -0
- package/dist/components/MilestoneStoryCard.d.ts.map +1 -0
- package/dist/components/MilestoneStoryCard.js +21 -0
- package/dist/components/MilestoneStoryCard.js.map +1 -0
- package/dist/components/ScrollMemory.d.ts +3 -0
- package/dist/components/ScrollMemory.d.ts.map +1 -0
- package/dist/components/ScrollMemory.js +25 -0
- package/dist/components/ScrollMemory.js.map +1 -0
- package/dist/components/SourceInspectorDrawer.d.ts +3 -0
- package/dist/components/SourceInspectorDrawer.d.ts.map +1 -0
- package/dist/components/SourceInspectorDrawer.js +77 -0
- package/dist/components/SourceInspectorDrawer.js.map +1 -0
- package/dist/components/SourceReaderDrawer.d.ts +3 -0
- package/dist/components/SourceReaderDrawer.d.ts.map +1 -0
- package/dist/components/SourceReaderDrawer.js +221 -0
- package/dist/components/SourceReaderDrawer.js.map +1 -0
- package/dist/components/wiki/AuthStatusBanner.d.ts +8 -0
- package/dist/components/wiki/AuthStatusBanner.d.ts.map +1 -0
- package/dist/components/wiki/AuthStatusBanner.js +22 -0
- package/dist/components/wiki/AuthStatusBanner.js.map +1 -0
- package/dist/components/wiki/ConflictMergeDialog.d.ts +17 -0
- package/dist/components/wiki/ConflictMergeDialog.d.ts.map +1 -0
- package/dist/components/wiki/ConflictMergeDialog.js +10 -0
- package/dist/components/wiki/ConflictMergeDialog.js.map +1 -0
- package/dist/components/wiki/CreateEntityModal.d.ts +12 -0
- package/dist/components/wiki/CreateEntityModal.d.ts.map +1 -0
- package/dist/components/wiki/CreateEntityModal.js +201 -0
- package/dist/components/wiki/CreateEntityModal.js.map +1 -0
- package/dist/components/wiki/EntityEditDrawer.d.ts +16 -0
- package/dist/components/wiki/EntityEditDrawer.d.ts.map +1 -0
- package/dist/components/wiki/EntityEditDrawer.js +284 -0
- package/dist/components/wiki/EntityEditDrawer.js.map +1 -0
- package/dist/components/wiki/MediaUploaderModal.d.ts +11 -0
- package/dist/components/wiki/MediaUploaderModal.d.ts.map +1 -0
- package/dist/components/wiki/MediaUploaderModal.js +107 -0
- package/dist/components/wiki/MediaUploaderModal.js.map +1 -0
- package/dist/components/wiki/PrivateArchiveGate.d.ts +7 -0
- package/dist/components/wiki/PrivateArchiveGate.d.ts.map +1 -0
- package/dist/components/wiki/PrivateArchiveGate.js +45 -0
- package/dist/components/wiki/PrivateArchiveGate.js.map +1 -0
- package/dist/components/wiki/RevisionDiffView.d.ts +16 -0
- package/dist/components/wiki/RevisionDiffView.d.ts.map +1 -0
- package/dist/components/wiki/RevisionDiffView.js +42 -0
- package/dist/components/wiki/RevisionDiffView.js.map +1 -0
- package/dist/components/wiki/RevisionHistoryPanel.d.ts +10 -0
- package/dist/components/wiki/RevisionHistoryPanel.d.ts.map +1 -0
- package/dist/components/wiki/RevisionHistoryPanel.js +76 -0
- package/dist/components/wiki/RevisionHistoryPanel.js.map +1 -0
- package/dist/components/wiki/SignInModal.d.ts +8 -0
- package/dist/components/wiki/SignInModal.d.ts.map +1 -0
- package/dist/components/wiki/SignInModal.js +45 -0
- package/dist/components/wiki/SignInModal.js.map +1 -0
- package/dist/components/wiki/TalkPanel.d.ts +10 -0
- package/dist/components/wiki/TalkPanel.d.ts.map +1 -0
- package/dist/components/wiki/TalkPanel.js +87 -0
- package/dist/components/wiki/TalkPanel.js.map +1 -0
- package/dist/components/wiki/WikiActionBar.d.ts +18 -0
- package/dist/components/wiki/WikiActionBar.d.ts.map +1 -0
- package/dist/components/wiki/WikiActionBar.js +29 -0
- package/dist/components/wiki/WikiActionBar.js.map +1 -0
- package/dist/components/wiki/WikiBadges.d.ts +29 -0
- package/dist/components/wiki/WikiBadges.d.ts.map +1 -0
- package/dist/components/wiki/WikiBadges.js +34 -0
- package/dist/components/wiki/WikiBadges.js.map +1 -0
- package/dist/context/ArchiveDataContext.d.ts +68 -0
- package/dist/context/ArchiveDataContext.d.ts.map +1 -0
- package/dist/context/ArchiveDataContext.js +363 -0
- package/dist/context/ArchiveDataContext.js.map +1 -0
- package/dist/context/ArchiveProvider.d.ts +8 -0
- package/dist/context/ArchiveProvider.d.ts.map +1 -0
- package/dist/context/ArchiveProvider.js +7 -0
- package/dist/context/ArchiveProvider.js.map +1 -0
- package/dist/context/ArchiveUiContext.d.ts +27 -0
- package/dist/context/ArchiveUiContext.d.ts.map +1 -0
- package/dist/context/ArchiveUiContext.js +104 -0
- package/dist/context/ArchiveUiContext.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/clientTelemetry.d.ts +21 -0
- package/dist/lib/clientTelemetry.d.ts.map +1 -0
- package/dist/lib/clientTelemetry.js +268 -0
- package/dist/lib/clientTelemetry.js.map +1 -0
- package/dist/lib/ohmStyle.d.ts +13 -0
- package/dist/lib/ohmStyle.d.ts.map +1 -0
- package/dist/lib/ohmStyle.js +158 -0
- package/dist/lib/ohmStyle.js.map +1 -0
- package/dist/lib/scrollMemory.d.ts +2 -0
- package/dist/lib/scrollMemory.d.ts.map +1 -0
- package/dist/lib/scrollMemory.js +7 -0
- package/dist/lib/scrollMemory.js.map +1 -0
- package/dist/lib/searchNavigation.d.ts +5 -0
- package/dist/lib/searchNavigation.d.ts.map +1 -0
- package/dist/lib/searchNavigation.js +16 -0
- package/dist/lib/searchNavigation.js.map +1 -0
- package/dist/lib/sourceReaderNav.d.ts +6 -0
- package/dist/lib/sourceReaderNav.d.ts.map +1 -0
- package/dist/lib/sourceReaderNav.js +17 -0
- package/dist/lib/sourceReaderNav.js.map +1 -0
- package/dist/lib/timelineScroll.d.ts +20 -0
- package/dist/lib/timelineScroll.d.ts.map +1 -0
- package/dist/lib/timelineScroll.js +60 -0
- package/dist/lib/timelineScroll.js.map +1 -0
- package/dist/lib/treeGestures.d.ts +55 -0
- package/dist/lib/treeGestures.d.ts.map +1 -0
- package/dist/lib/treeGestures.js +96 -0
- package/dist/lib/treeGestures.js.map +1 -0
- package/dist/lib/treeNodeDisplay.d.ts +8 -0
- package/dist/lib/treeNodeDisplay.d.ts.map +1 -0
- package/dist/lib/treeNodeDisplay.js +66 -0
- package/dist/lib/treeNodeDisplay.js.map +1 -0
- package/dist/machines/authSessionMachine.d.ts +665 -0
- package/dist/machines/authSessionMachine.d.ts.map +1 -0
- package/dist/machines/authSessionMachine.js +620 -0
- package/dist/machines/authSessionMachine.js.map +1 -0
- package/dist/machines/entityEditorMachine.d.ts +334 -0
- package/dist/machines/entityEditorMachine.d.ts.map +1 -0
- package/dist/machines/entityEditorMachine.js +534 -0
- package/dist/machines/entityEditorMachine.js.map +1 -0
- package/dist/machines/index.d.ts +7 -0
- package/dist/machines/index.d.ts.map +1 -0
- package/dist/machines/index.js +4 -0
- package/dist/machines/index.js.map +1 -0
- package/dist/machines/mediaUploadMachine.d.ts +161 -0
- package/dist/machines/mediaUploadMachine.d.ts.map +1 -0
- package/dist/machines/mediaUploadMachine.js +473 -0
- package/dist/machines/mediaUploadMachine.js.map +1 -0
- package/dist/pages/AdminPage.d.ts +26 -0
- package/dist/pages/AdminPage.d.ts.map +1 -0
- package/dist/pages/AdminPage.js +165 -0
- package/dist/pages/AdminPage.js.map +1 -0
- package/dist/pages/EvidencePage.d.ts +3 -0
- package/dist/pages/EvidencePage.d.ts.map +1 -0
- package/dist/pages/EvidencePage.js +304 -0
- package/dist/pages/EvidencePage.js.map +1 -0
- package/dist/pages/IndexPage.d.ts +3 -0
- package/dist/pages/IndexPage.d.ts.map +1 -0
- package/dist/pages/IndexPage.js +173 -0
- package/dist/pages/IndexPage.js.map +1 -0
- package/dist/pages/KinshipPage.d.ts +3 -0
- package/dist/pages/KinshipPage.d.ts.map +1 -0
- package/dist/pages/KinshipPage.js +101 -0
- package/dist/pages/KinshipPage.js.map +1 -0
- package/dist/pages/MapPage.d.ts +4 -0
- package/dist/pages/MapPage.d.ts.map +1 -0
- package/dist/pages/MapPage.js +885 -0
- package/dist/pages/MapPage.js.map +1 -0
- package/dist/pages/PersonPage.d.ts +3 -0
- package/dist/pages/PersonPage.d.ts.map +1 -0
- package/dist/pages/PersonPage.js +524 -0
- package/dist/pages/PersonPage.js.map +1 -0
- package/dist/pages/PlacePage.d.ts +3 -0
- package/dist/pages/PlacePage.d.ts.map +1 -0
- package/dist/pages/PlacePage.js +227 -0
- package/dist/pages/PlacePage.js.map +1 -0
- package/dist/pages/PlacesIndexPage.d.ts +3 -0
- package/dist/pages/PlacesIndexPage.d.ts.map +1 -0
- package/dist/pages/PlacesIndexPage.js +76 -0
- package/dist/pages/PlacesIndexPage.js.map +1 -0
- package/dist/pages/RecentChangesPage.d.ts +7 -0
- package/dist/pages/RecentChangesPage.d.ts.map +1 -0
- package/dist/pages/RecentChangesPage.js +154 -0
- package/dist/pages/RecentChangesPage.js.map +1 -0
- package/dist/pages/TimePage.d.ts +3 -0
- package/dist/pages/TimePage.d.ts.map +1 -0
- package/dist/pages/TimePage.js +148 -0
- package/dist/pages/TimePage.js.map +1 -0
- package/dist/pages/TreePage.d.ts +3 -0
- package/dist/pages/TreePage.d.ts.map +1 -0
- package/dist/pages/TreePage.js +698 -0
- package/dist/pages/TreePage.js.map +1 -0
- package/dist/plugins/PluginContext.d.ts +28 -0
- package/dist/plugins/PluginContext.d.ts.map +1 -0
- package/dist/plugins/PluginContext.js +65 -0
- package/dist/plugins/PluginContext.js.map +1 -0
- package/dist/plugins/types.d.ts +40 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +2 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/styles/archival.css +6127 -0
- package/package.json +44 -4
- package/README.md +0 -3
|
@@ -0,0 +1,885 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Side-effect CSS import: the standard Vite pattern for loading library styles.
|
|
3
|
+
// oxlint-disable-next-line import/no-unassigned-import
|
|
4
|
+
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
5
|
+
import { AttributionControl, Map as MapLibreMap, setMaxParallelImageRequests, setWorkerCount, setWorkerUrl, } from 'maplibre-gl';
|
|
6
|
+
import { DEFAULT_MIGRATION_ERAS, buildMigrationSegments, buildMigrationStops, buildPerPersonMigrationSegments, computeStopsBounds, journeyNext, journeyPlayToggle, journeyPrev, journeyReset, journeyScrub, journeyTick, } from '@kinloom/core';
|
|
7
|
+
import { Link, useSearchParams } from 'react-router-dom';
|
|
8
|
+
import { OHM_STYLE_URL, OVERVIEW_REFERENCE_YEAR, PAPER_LAND_LAYER_ID, loadArchivalOhmStyle, } from '../lib/ohmStyle.js';
|
|
9
|
+
import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
10
|
+
import { ExplorerTopBar } from '../components/ExplorerTopBar.js';
|
|
11
|
+
import { filterByDate } from '@openhistoricalmap/maplibre-gl-dates';
|
|
12
|
+
import maplibreWorkerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?url';
|
|
13
|
+
import { useArchiveData } from '../context/ArchiveDataContext.js';
|
|
14
|
+
let maplibreConfigured = false;
|
|
15
|
+
function ensureMapLibreConfigured() {
|
|
16
|
+
if (maplibreConfigured || typeof window === 'undefined') {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
maplibreConfigured = true;
|
|
20
|
+
setWorkerUrl(maplibreWorkerUrl);
|
|
21
|
+
const workerCount = Math.min(6, Math.max(2, navigator.hardwareConcurrency || 4));
|
|
22
|
+
setWorkerCount(workerCount);
|
|
23
|
+
setMaxParallelImageRequests(16);
|
|
24
|
+
}
|
|
25
|
+
const MODERN_BASEMAP_LAYERS = ['land', 'ohm_landcover_hillshade'];
|
|
26
|
+
function setPeriodBasemap(map) {
|
|
27
|
+
for (const layerId of MODERN_BASEMAP_LAYERS) {
|
|
28
|
+
if (!map.getLayer(layerId)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
map.setLayoutProperty(layerId, 'visibility', 'none');
|
|
32
|
+
}
|
|
33
|
+
if (map.getLayer(PAPER_LAND_LAYER_ID) || !map.getSource('osm_land')) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const beforeId = map.getLayer('water_areas_ne') ? 'water_areas_ne' : undefined;
|
|
37
|
+
map.addLayer({
|
|
38
|
+
id: PAPER_LAND_LAYER_ID,
|
|
39
|
+
type: 'fill',
|
|
40
|
+
source: 'osm_land',
|
|
41
|
+
'source-layer': 'land',
|
|
42
|
+
paint: { 'fill-color': '#EFE4C8' },
|
|
43
|
+
}, beforeId);
|
|
44
|
+
}
|
|
45
|
+
const SOURCE_ID = 'kinloom-migration';
|
|
46
|
+
const STOP_LAYER_ID = 'migration-stops';
|
|
47
|
+
const FALLBACK_ERA_COLORS = [
|
|
48
|
+
'#1B2A41',
|
|
49
|
+
'#2F5245',
|
|
50
|
+
'#7A4612',
|
|
51
|
+
'#8F2D24',
|
|
52
|
+
'#1D4E89',
|
|
53
|
+
'#5A4B3C',
|
|
54
|
+
];
|
|
55
|
+
const PAPER_STYLE = {
|
|
56
|
+
version: 8,
|
|
57
|
+
name: 'paper',
|
|
58
|
+
glyphs: 'https://www.openhistoricalmap.org/map-styles/fonts/{fontstack}/{range}.pbf',
|
|
59
|
+
sources: {},
|
|
60
|
+
layers: [
|
|
61
|
+
{
|
|
62
|
+
id: 'paper',
|
|
63
|
+
type: 'background',
|
|
64
|
+
paint: { 'background-color': '#ece4d2' },
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
function getFitOptions(hasSelectedStop) {
|
|
69
|
+
const isMobile = typeof window !== 'undefined' && window.innerWidth <= 767;
|
|
70
|
+
if (isMobile) {
|
|
71
|
+
return {
|
|
72
|
+
padding: { top: 68, right: 58, bottom: hasSelectedStop ? 188 : 108, left: 16 },
|
|
73
|
+
duration: 0,
|
|
74
|
+
maxZoom: 6.5,
|
|
75
|
+
absolutePadding: true,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
padding: { top: 86, right: hasSelectedStop ? 336 : 56, bottom: 108, left: 28 },
|
|
80
|
+
duration: 0,
|
|
81
|
+
maxZoom: 6.5,
|
|
82
|
+
absolutePadding: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const pointerBound = new WeakSet();
|
|
86
|
+
function routeArc(from, to) {
|
|
87
|
+
const startLng = from.lng;
|
|
88
|
+
const startLat = from.lat;
|
|
89
|
+
const endLng = to.lng;
|
|
90
|
+
const endLat = to.lat;
|
|
91
|
+
const span = Math.hypot(endLng - startLng, endLat - startLat);
|
|
92
|
+
const bow = Math.min(7, Math.max(0.4, span * 0.14));
|
|
93
|
+
const controlLng = (startLng + endLng) / 2;
|
|
94
|
+
const controlLat = (startLat + endLat) / 2 + bow;
|
|
95
|
+
const steps = 32;
|
|
96
|
+
const coordinates = [];
|
|
97
|
+
for (let step = 0; step <= steps; step += 1) {
|
|
98
|
+
const t = step / steps;
|
|
99
|
+
const u = 1 - t;
|
|
100
|
+
coordinates.push([
|
|
101
|
+
u * u * startLng + 2 * u * t * controlLng + t * t * endLng,
|
|
102
|
+
u * u * startLat + 2 * u * t * controlLat + t * t * endLat,
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
return coordinates;
|
|
106
|
+
}
|
|
107
|
+
function wantsLabel(index, count, stopId, selectedStopId, personFilter) {
|
|
108
|
+
if (stopId === selectedStopId) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
if (personFilter !== 'all') {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return index === 0 || index === count - 1;
|
|
115
|
+
}
|
|
116
|
+
function buildFamilyOverlay(input) {
|
|
117
|
+
const features = [];
|
|
118
|
+
const stepping = input.stepIndex >= 0;
|
|
119
|
+
if (stepping) {
|
|
120
|
+
for (const segment of input.allSegments) {
|
|
121
|
+
features.push({
|
|
122
|
+
type: 'Feature',
|
|
123
|
+
properties: { kind: 'guide' },
|
|
124
|
+
geometry: {
|
|
125
|
+
type: 'LineString',
|
|
126
|
+
coordinates: routeArc(segment.from.place, segment.to.place),
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
for (const stop of input.stops.slice(input.visibleStops.length)) {
|
|
131
|
+
features.push({
|
|
132
|
+
type: 'Feature',
|
|
133
|
+
properties: { kind: 'future', id: stop.id },
|
|
134
|
+
geometry: { type: 'Point', coordinates: [stop.place.lng, stop.place.lat] },
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
for (const [index, segment] of input.segments.entries()) {
|
|
139
|
+
features.push({
|
|
140
|
+
type: 'Feature',
|
|
141
|
+
properties: {
|
|
142
|
+
kind: 'route',
|
|
143
|
+
dashed: segment.distanceMiles > 2000,
|
|
144
|
+
latest: stepping && index === input.segments.length - 1,
|
|
145
|
+
},
|
|
146
|
+
geometry: {
|
|
147
|
+
type: 'LineString',
|
|
148
|
+
coordinates: routeArc(segment.from.place, segment.to.place),
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
for (const [index, stop] of input.visibleStops.entries()) {
|
|
153
|
+
features.push({
|
|
154
|
+
type: 'Feature',
|
|
155
|
+
properties: {
|
|
156
|
+
kind: 'stop',
|
|
157
|
+
id: stop.id,
|
|
158
|
+
color: input.stageColors.get(stop.lineageStage) ?? '#1B2A41',
|
|
159
|
+
label: `${stop.year} · ${stop.place.name}`,
|
|
160
|
+
selected: stop.id === input.selectedStopId,
|
|
161
|
+
showLabel: wantsLabel(index, input.visibleStops.length, stop.id, input.selectedStopId, input.personFilter),
|
|
162
|
+
},
|
|
163
|
+
geometry: { type: 'Point', coordinates: [stop.place.lng, stop.place.lat] },
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return { type: 'FeatureCollection', features };
|
|
167
|
+
}
|
|
168
|
+
function bindStopClicks(map, onSelect) {
|
|
169
|
+
if (pointerBound.has(map)) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
pointerBound.add(map);
|
|
173
|
+
const canvas = map.getCanvas();
|
|
174
|
+
map.on('mouseenter', STOP_LAYER_ID, () => {
|
|
175
|
+
canvas.style.cursor = 'pointer';
|
|
176
|
+
});
|
|
177
|
+
map.on('mouseleave', STOP_LAYER_ID, () => {
|
|
178
|
+
canvas.style.cursor = '';
|
|
179
|
+
});
|
|
180
|
+
map.on('click', (event) => {
|
|
181
|
+
if (!map.getLayer(STOP_LAYER_ID)) {
|
|
182
|
+
onSelect(null);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const hits = map.queryRenderedFeatures(event.point, { layers: [STOP_LAYER_ID] });
|
|
186
|
+
const raw = hits[0]?.properties?.id;
|
|
187
|
+
onSelect(typeof raw === 'string' ? raw : null);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
function addFamilyLayers(map) {
|
|
191
|
+
map.addLayer({
|
|
192
|
+
id: 'migration-guide',
|
|
193
|
+
type: 'line',
|
|
194
|
+
source: SOURCE_ID,
|
|
195
|
+
filter: ['==', ['get', 'kind'], 'guide'],
|
|
196
|
+
layout: { 'line-cap': 'round', 'line-join': 'round' },
|
|
197
|
+
paint: {
|
|
198
|
+
'line-color': '#7A4612',
|
|
199
|
+
'line-width': 1.2,
|
|
200
|
+
'line-opacity': 0.32,
|
|
201
|
+
'line-dasharray': [1.4, 1.2],
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
map.addLayer({
|
|
205
|
+
id: 'migration-future',
|
|
206
|
+
type: 'circle',
|
|
207
|
+
source: SOURCE_ID,
|
|
208
|
+
filter: ['==', ['get', 'kind'], 'future'],
|
|
209
|
+
paint: {
|
|
210
|
+
'circle-radius': 3.8,
|
|
211
|
+
'circle-color': '#736857',
|
|
212
|
+
'circle-opacity': 0.78,
|
|
213
|
+
'circle-stroke-width': 1,
|
|
214
|
+
'circle-stroke-color': '#5C5344',
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
map.addLayer({
|
|
218
|
+
id: 'migration-route',
|
|
219
|
+
type: 'line',
|
|
220
|
+
source: SOURCE_ID,
|
|
221
|
+
filter: ['all', ['==', ['get', 'kind'], 'route'], ['==', ['get', 'dashed'], false], ['==', ['get', 'latest'], false]],
|
|
222
|
+
layout: { 'line-cap': 'round', 'line-join': 'round' },
|
|
223
|
+
paint: {
|
|
224
|
+
'line-color': '#7A4612',
|
|
225
|
+
'line-width': 1.8,
|
|
226
|
+
'line-opacity': 0.78,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
map.addLayer({
|
|
230
|
+
id: 'migration-route-latest',
|
|
231
|
+
type: 'line',
|
|
232
|
+
source: SOURCE_ID,
|
|
233
|
+
filter: ['all', ['==', ['get', 'kind'], 'route'], ['==', ['get', 'dashed'], false], ['==', ['get', 'latest'], true]],
|
|
234
|
+
layout: { 'line-cap': 'round', 'line-join': 'round' },
|
|
235
|
+
paint: {
|
|
236
|
+
'line-color': '#8F2D24',
|
|
237
|
+
'line-width': 2.6,
|
|
238
|
+
'line-opacity': 0.95,
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
map.addLayer({
|
|
242
|
+
id: 'migration-route-dash',
|
|
243
|
+
type: 'line',
|
|
244
|
+
source: SOURCE_ID,
|
|
245
|
+
filter: ['all', ['==', ['get', 'kind'], 'route'], ['==', ['get', 'dashed'], true], ['==', ['get', 'latest'], false]],
|
|
246
|
+
layout: { 'line-cap': 'round', 'line-join': 'round' },
|
|
247
|
+
paint: {
|
|
248
|
+
'line-color': '#7A4612',
|
|
249
|
+
'line-width': 1.8,
|
|
250
|
+
'line-opacity': 0.78,
|
|
251
|
+
'line-dasharray': [2, 1.4],
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
map.addLayer({
|
|
255
|
+
id: 'migration-route-dash-latest',
|
|
256
|
+
type: 'line',
|
|
257
|
+
source: SOURCE_ID,
|
|
258
|
+
filter: ['all', ['==', ['get', 'kind'], 'route'], ['==', ['get', 'dashed'], true], ['==', ['get', 'latest'], true]],
|
|
259
|
+
layout: { 'line-cap': 'round', 'line-join': 'round' },
|
|
260
|
+
paint: {
|
|
261
|
+
'line-color': '#8F2D24',
|
|
262
|
+
'line-width': 2.6,
|
|
263
|
+
'line-opacity': 0.95,
|
|
264
|
+
'line-dasharray': [2, 1.4],
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
map.addLayer({
|
|
268
|
+
id: 'migration-stop-halo',
|
|
269
|
+
type: 'circle',
|
|
270
|
+
source: SOURCE_ID,
|
|
271
|
+
filter: ['all', ['==', ['get', 'kind'], 'stop'], ['==', ['get', 'selected'], true]],
|
|
272
|
+
paint: {
|
|
273
|
+
'circle-radius': 18,
|
|
274
|
+
'circle-color': '#7A4612',
|
|
275
|
+
'circle-opacity': 0.55,
|
|
276
|
+
'circle-stroke-width': 2,
|
|
277
|
+
'circle-stroke-color': '#F4E2B8',
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
map.addLayer({
|
|
281
|
+
id: STOP_LAYER_ID,
|
|
282
|
+
type: 'circle',
|
|
283
|
+
source: SOURCE_ID,
|
|
284
|
+
filter: ['==', ['get', 'kind'], 'stop'],
|
|
285
|
+
paint: {
|
|
286
|
+
'circle-radius': ['case', ['==', ['get', 'selected'], true], 9, 5],
|
|
287
|
+
'circle-color': ['coalesce', ['get', 'color'], '#1B2A41'],
|
|
288
|
+
'circle-stroke-width': 1.5,
|
|
289
|
+
'circle-stroke-color': '#FCF9F2',
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
map.addLayer({
|
|
293
|
+
id: 'migration-labels',
|
|
294
|
+
type: 'symbol',
|
|
295
|
+
source: SOURCE_ID,
|
|
296
|
+
filter: [
|
|
297
|
+
'all',
|
|
298
|
+
['==', ['get', 'kind'], 'stop'],
|
|
299
|
+
['==', ['get', 'showLabel'], true],
|
|
300
|
+
['==', ['get', 'selected'], false],
|
|
301
|
+
],
|
|
302
|
+
layout: {
|
|
303
|
+
'text-field': ['coalesce', ['get', 'label'], ''],
|
|
304
|
+
'text-font': ['OpenHistorical'],
|
|
305
|
+
'text-size': 12,
|
|
306
|
+
'text-offset': [0.75, 0],
|
|
307
|
+
'text-anchor': 'left',
|
|
308
|
+
'text-allow-overlap': false,
|
|
309
|
+
'text-padding': 4,
|
|
310
|
+
'text-optional': true,
|
|
311
|
+
},
|
|
312
|
+
paint: {
|
|
313
|
+
'text-color': '#1B2A41',
|
|
314
|
+
'text-halo-color': '#FCF9F2',
|
|
315
|
+
'text-halo-width': 1.4,
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
map.addLayer({
|
|
319
|
+
id: 'migration-label-selected',
|
|
320
|
+
type: 'symbol',
|
|
321
|
+
source: SOURCE_ID,
|
|
322
|
+
filter: ['all', ['==', ['get', 'kind'], 'stop'], ['==', ['get', 'selected'], true]],
|
|
323
|
+
layout: {
|
|
324
|
+
'text-field': ['coalesce', ['get', 'label'], ''],
|
|
325
|
+
'text-font': ['OpenHistorical Bold'],
|
|
326
|
+
'text-size': 12.5,
|
|
327
|
+
'text-offset': [0.8, 0],
|
|
328
|
+
'text-anchor': 'left',
|
|
329
|
+
'text-allow-overlap': false,
|
|
330
|
+
'text-ignore-placement': false,
|
|
331
|
+
'text-padding': 4,
|
|
332
|
+
},
|
|
333
|
+
paint: {
|
|
334
|
+
'text-color': '#1B2A41',
|
|
335
|
+
'text-halo-color': '#FCF9F2',
|
|
336
|
+
'text-halo-width': 1.6,
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
function isGeoJsonSource(source) {
|
|
341
|
+
return source?.type === 'geojson';
|
|
342
|
+
}
|
|
343
|
+
function syncFamilyOverlay(map, data, onSelect) {
|
|
344
|
+
const source = map.getSource(SOURCE_ID);
|
|
345
|
+
if (isGeoJsonSource(source)) {
|
|
346
|
+
void source.setData(data);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
map.addSource(SOURCE_ID, { type: 'geojson', data });
|
|
350
|
+
addFamilyLayers(map);
|
|
351
|
+
bindStopClicks(map, onSelect);
|
|
352
|
+
}
|
|
353
|
+
export const MapPage = () => {
|
|
354
|
+
const { siteConfig, bundle, peopleById, placesById, placesBySlug, loading, error } = useArchiveData();
|
|
355
|
+
const [searchParams] = useSearchParams();
|
|
356
|
+
const mapHostRef = useRef(null);
|
|
357
|
+
const mapRef = useRef(null);
|
|
358
|
+
const styleLoadedRef = useRef(false);
|
|
359
|
+
const historicalFailedRef = useRef(false);
|
|
360
|
+
const pendingBoundsRef = useRef(null);
|
|
361
|
+
const programmaticMoveRef = useRef(false);
|
|
362
|
+
const lastAppliedDateRef = useRef(null);
|
|
363
|
+
const [selectedPersonId, setSelectedPersonId] = useState('all');
|
|
364
|
+
const [selectedEraId, setSelectedEraId] = useState('all');
|
|
365
|
+
const [routeMode, setRouteMode] = useState('per-person');
|
|
366
|
+
const [drawerExpanded, setDrawerExpanded] = useState(false);
|
|
367
|
+
const prevFilterKeyRef = useRef('all:all');
|
|
368
|
+
const [stepIndex, setStepIndex] = useState(-1);
|
|
369
|
+
const [playing, setPlaying] = useState(false);
|
|
370
|
+
const [selectedStopId, setSelectedStopId] = useState(null);
|
|
371
|
+
const [historicalMap, setHistoricalMap] = useState({ kind: 'pending' });
|
|
372
|
+
const [cardSide, setCardSide] = useState('right');
|
|
373
|
+
const cardRef = useRef(null);
|
|
374
|
+
const migrationEras = useMemo(() => (siteConfig.migrationEras.length > 0 ? siteConfig.migrationEras : DEFAULT_MIGRATION_ERAS), [siteConfig.migrationEras]);
|
|
375
|
+
const stageColorMap = useMemo(() => {
|
|
376
|
+
const map = new Map();
|
|
377
|
+
migrationEras.forEach((era, idx) => {
|
|
378
|
+
map.set(era.id, era.color ?? FALLBACK_ERA_COLORS[idx % FALLBACK_ERA_COLORS.length]);
|
|
379
|
+
});
|
|
380
|
+
return map;
|
|
381
|
+
}, [migrationEras]);
|
|
382
|
+
const stageLabelMap = useMemo(() => {
|
|
383
|
+
const map = new Map();
|
|
384
|
+
for (const era of migrationEras) {
|
|
385
|
+
map.set(era.id, era.label);
|
|
386
|
+
}
|
|
387
|
+
return map;
|
|
388
|
+
}, [migrationEras]);
|
|
389
|
+
const selectablePeople = useMemo(() => {
|
|
390
|
+
if (!bundle) {
|
|
391
|
+
return [];
|
|
392
|
+
}
|
|
393
|
+
return bundle.people
|
|
394
|
+
.filter((person) => !person.is_living || person.full_name !== 'Living')
|
|
395
|
+
.filter((person) => (person.event_count || 0) >= 2)
|
|
396
|
+
.toSorted((a, b) => (b.event_count || 0) - (a.event_count || 0) || a.full_name.localeCompare(b.full_name));
|
|
397
|
+
}, [bundle]);
|
|
398
|
+
const allStopsForPerson = useMemo(() => {
|
|
399
|
+
if (!bundle) {
|
|
400
|
+
return [];
|
|
401
|
+
}
|
|
402
|
+
return buildMigrationStops(bundle, placesById, peopleById, {
|
|
403
|
+
personIdFilter: selectedPersonId === 'all' ? null : selectedPersonId,
|
|
404
|
+
migrationEras,
|
|
405
|
+
});
|
|
406
|
+
}, [bundle, placesById, peopleById, selectedPersonId, migrationEras]);
|
|
407
|
+
const stops = useMemo(() => {
|
|
408
|
+
if (selectedEraId === 'all') {
|
|
409
|
+
return allStopsForPerson;
|
|
410
|
+
}
|
|
411
|
+
return allStopsForPerson.filter((stop) => stop.lineageStage === selectedEraId);
|
|
412
|
+
}, [allStopsForPerson, selectedEraId]);
|
|
413
|
+
const eraStopCounts = useMemo(() => {
|
|
414
|
+
const counts = new Map();
|
|
415
|
+
for (const stop of allStopsForPerson) {
|
|
416
|
+
counts.set(stop.lineageStage, (counts.get(stop.lineageStage) ?? 0) + 1);
|
|
417
|
+
}
|
|
418
|
+
return counts;
|
|
419
|
+
}, [allStopsForPerson]);
|
|
420
|
+
const visibleStops = useMemo(() => {
|
|
421
|
+
if (stepIndex < 0 || stepIndex >= stops.length) {
|
|
422
|
+
return stops;
|
|
423
|
+
}
|
|
424
|
+
return stops.slice(0, stepIndex + 1);
|
|
425
|
+
}, [stops, stepIndex]);
|
|
426
|
+
const usePerPersonSegments = selectedPersonId === 'all' && routeMode === 'per-person';
|
|
427
|
+
const allSegments = useMemo(() => usePerPersonSegments
|
|
428
|
+
? buildPerPersonMigrationSegments(stops, 18)
|
|
429
|
+
: buildMigrationSegments(stops, 18), [stops, usePerPersonSegments]);
|
|
430
|
+
const segments = useMemo(() => usePerPersonSegments
|
|
431
|
+
? buildPerPersonMigrationSegments(visibleStops, 18)
|
|
432
|
+
: buildMigrationSegments(visibleStops, 18), [visibleStops, usePerPersonSegments]);
|
|
433
|
+
const selectedStop = selectedStopId
|
|
434
|
+
? stops.find((stop) => stop.id === selectedStopId) ?? null
|
|
435
|
+
: null;
|
|
436
|
+
const stopIds = useMemo(() => stops.map((stop) => stop.id), [stops]);
|
|
437
|
+
const journey = { stepIndex, playing, selectedStopId };
|
|
438
|
+
const journeyRef = useRef(journey);
|
|
439
|
+
const stopIdsRef = useRef(stopIds);
|
|
440
|
+
useEffect(() => {
|
|
441
|
+
journeyRef.current = journey;
|
|
442
|
+
stopIdsRef.current = stopIds;
|
|
443
|
+
});
|
|
444
|
+
const applyJourney = useCallback((next) => {
|
|
445
|
+
setStepIndex(next.stepIndex);
|
|
446
|
+
setPlaying(next.playing);
|
|
447
|
+
setSelectedStopId(next.selectedStopId);
|
|
448
|
+
}, []);
|
|
449
|
+
const eraYear = selectedStop?.year ?? (stepIndex >= 0 ? stops[stepIndex]?.year : null);
|
|
450
|
+
const overlay = useMemo(() => buildFamilyOverlay({
|
|
451
|
+
stops,
|
|
452
|
+
visibleStops,
|
|
453
|
+
segments,
|
|
454
|
+
allSegments,
|
|
455
|
+
stepIndex,
|
|
456
|
+
selectedStopId: selectedStop?.id ?? null,
|
|
457
|
+
personFilter: selectedPersonId,
|
|
458
|
+
stageColors: stageColorMap,
|
|
459
|
+
}), [stops, visibleStops, segments, allSegments, stepIndex, selectedStop?.id, selectedPersonId, stageColorMap]);
|
|
460
|
+
const overlayRef = useRef(overlay);
|
|
461
|
+
useLayoutEffect(() => {
|
|
462
|
+
overlayRef.current = overlay;
|
|
463
|
+
});
|
|
464
|
+
const defaultBounds = useMemo(() => {
|
|
465
|
+
const computed = computeStopsBounds(allStopsForPerson, siteConfig.mapDefaults);
|
|
466
|
+
if (computed) {
|
|
467
|
+
return computed;
|
|
468
|
+
}
|
|
469
|
+
const { centerLng, centerLat, minSpanDeg } = siteConfig.mapDefaults;
|
|
470
|
+
const span = Math.max(4, minSpanDeg * 4);
|
|
471
|
+
return [
|
|
472
|
+
[centerLng - span, centerLat - span],
|
|
473
|
+
[centerLng + span, centerLat + span],
|
|
474
|
+
];
|
|
475
|
+
}, [allStopsForPerson, siteConfig.mapDefaults]);
|
|
476
|
+
const fitCameraBounds = useCallback((bounds, hasSelectedStop) => {
|
|
477
|
+
const map = mapRef.current;
|
|
478
|
+
if (!map) {
|
|
479
|
+
pendingBoundsRef.current = bounds;
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
pendingBoundsRef.current = null;
|
|
483
|
+
programmaticMoveRef.current = true;
|
|
484
|
+
map.fitBounds(bounds, getFitOptions(hasSelectedStop));
|
|
485
|
+
window.setTimeout(() => {
|
|
486
|
+
programmaticMoveRef.current = false;
|
|
487
|
+
}, 60);
|
|
488
|
+
}, []);
|
|
489
|
+
useEffect(() => {
|
|
490
|
+
if (loading || !bundle) {
|
|
491
|
+
return undefined;
|
|
492
|
+
}
|
|
493
|
+
const host = mapHostRef.current;
|
|
494
|
+
if (!host) {
|
|
495
|
+
return undefined;
|
|
496
|
+
}
|
|
497
|
+
ensureMapLibreConfigured();
|
|
498
|
+
let cancelled = false;
|
|
499
|
+
styleLoadedRef.current = false;
|
|
500
|
+
historicalFailedRef.current = false;
|
|
501
|
+
lastAppliedDateRef.current = null;
|
|
502
|
+
let activeMap = null;
|
|
503
|
+
const mountMap = (initialStyle, isFallback) => {
|
|
504
|
+
if (cancelled) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (isFallback) {
|
|
508
|
+
historicalFailedRef.current = true;
|
|
509
|
+
setHistoricalMap({ kind: 'failed' });
|
|
510
|
+
}
|
|
511
|
+
let map;
|
|
512
|
+
try {
|
|
513
|
+
map = new MapLibreMap({
|
|
514
|
+
container: host,
|
|
515
|
+
style: initialStyle,
|
|
516
|
+
bounds: defaultBounds,
|
|
517
|
+
fitBoundsOptions: getFitOptions(false),
|
|
518
|
+
attributionControl: false,
|
|
519
|
+
dragRotate: false,
|
|
520
|
+
pitchWithRotate: false,
|
|
521
|
+
touchPitch: false,
|
|
522
|
+
maxPitch: 0,
|
|
523
|
+
minZoom: 1.4,
|
|
524
|
+
maxZoom: 12,
|
|
525
|
+
maxTileCacheSize: 240,
|
|
526
|
+
renderWorldCopies: false,
|
|
527
|
+
fadeDuration: 0,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
catch {
|
|
531
|
+
historicalFailedRef.current = true;
|
|
532
|
+
setHistoricalMap({ kind: 'failed' });
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
activeMap = map;
|
|
536
|
+
map.addControl(new AttributionControl({
|
|
537
|
+
compact: true,
|
|
538
|
+
customAttribution: [
|
|
539
|
+
'<a href="https://www.openhistoricalmap.org/" target="_blank" rel="noopener noreferrer">OpenHistoricalMap</a>',
|
|
540
|
+
'<a href="https://maplibre.org/" target="_blank" rel="noopener noreferrer">MapLibre</a>',
|
|
541
|
+
],
|
|
542
|
+
}), 'bottom-left');
|
|
543
|
+
mapRef.current = map;
|
|
544
|
+
host.kinloomMigrationMap = map;
|
|
545
|
+
map.getCanvas().setAttribute('aria-label', `${siteConfig.site.familyName} migration map`);
|
|
546
|
+
const onStyle = () => {
|
|
547
|
+
if (cancelled) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
styleLoadedRef.current = true;
|
|
551
|
+
setPeriodBasemap(map);
|
|
552
|
+
if (!historicalFailedRef.current) {
|
|
553
|
+
lastAppliedDateRef.current = OVERVIEW_REFERENCE_YEAR;
|
|
554
|
+
}
|
|
555
|
+
setHistoricalMap(historicalFailedRef.current ? { kind: 'failed' } : { kind: 'ready' });
|
|
556
|
+
syncFamilyOverlay(map, overlayRef.current, (id) => {
|
|
557
|
+
if (!cancelled) {
|
|
558
|
+
setSelectedStopId(id);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
};
|
|
562
|
+
const onError = (event) => {
|
|
563
|
+
if (cancelled || styleLoadedRef.current || historicalFailedRef.current) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
if (!event.error?.message?.includes(OHM_STYLE_URL)) {
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
historicalFailedRef.current = true;
|
|
570
|
+
setHistoricalMap({ kind: 'failed' });
|
|
571
|
+
window.setTimeout(() => {
|
|
572
|
+
if (cancelled || mapRef.current !== map || styleLoadedRef.current) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
map.setStyle(PAPER_STYLE);
|
|
576
|
+
}, 0);
|
|
577
|
+
};
|
|
578
|
+
map.on('style.load', onStyle);
|
|
579
|
+
map.on('error', onError);
|
|
580
|
+
if (pendingBoundsRef.current) {
|
|
581
|
+
const bounds = pendingBoundsRef.current;
|
|
582
|
+
pendingBoundsRef.current = null;
|
|
583
|
+
programmaticMoveRef.current = true;
|
|
584
|
+
map.fitBounds(bounds, getFitOptions(false));
|
|
585
|
+
window.setTimeout(() => {
|
|
586
|
+
programmaticMoveRef.current = false;
|
|
587
|
+
}, 60);
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
void loadArchivalOhmStyle(OVERVIEW_REFERENCE_YEAR)
|
|
591
|
+
.then((archivalStyle) => {
|
|
592
|
+
mountMap(archivalStyle, false);
|
|
593
|
+
})
|
|
594
|
+
.catch(() => {
|
|
595
|
+
mountMap(PAPER_STYLE, true);
|
|
596
|
+
});
|
|
597
|
+
return () => {
|
|
598
|
+
cancelled = true;
|
|
599
|
+
styleLoadedRef.current = false;
|
|
600
|
+
historicalFailedRef.current = false;
|
|
601
|
+
lastAppliedDateRef.current = null;
|
|
602
|
+
delete host.kinloomMigrationMap;
|
|
603
|
+
if (activeMap) {
|
|
604
|
+
activeMap.remove();
|
|
605
|
+
activeMap = null;
|
|
606
|
+
}
|
|
607
|
+
mapRef.current = null;
|
|
608
|
+
};
|
|
609
|
+
}, [loading, bundle, defaultBounds, siteConfig.site.familyName]);
|
|
610
|
+
useEffect(() => {
|
|
611
|
+
const map = mapRef.current;
|
|
612
|
+
if (!map || !styleLoadedRef.current) {
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
syncFamilyOverlay(map, overlay, (id) => {
|
|
616
|
+
setSelectedStopId(id);
|
|
617
|
+
});
|
|
618
|
+
}, [overlay]);
|
|
619
|
+
useEffect(() => {
|
|
620
|
+
const map = mapRef.current;
|
|
621
|
+
if (!map || historicalMap.kind !== 'ready') {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
setPeriodBasemap(map);
|
|
625
|
+
let targetDate = OVERVIEW_REFERENCE_YEAR;
|
|
626
|
+
if (eraYear !== null) {
|
|
627
|
+
targetDate = playing ? String(Math.floor(eraYear / 10) * 10) : String(eraYear);
|
|
628
|
+
}
|
|
629
|
+
if (lastAppliedDateRef.current === targetDate) {
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
lastAppliedDateRef.current = targetDate;
|
|
633
|
+
filterByDate(map, targetDate);
|
|
634
|
+
}, [eraYear, playing, historicalMap]);
|
|
635
|
+
useEffect(() => {
|
|
636
|
+
const map = mapRef.current;
|
|
637
|
+
if (!map || !selectedStop || !styleLoadedRef.current) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const canvas = map.getCanvas().getBoundingClientRect();
|
|
641
|
+
if (canvas.width === 0 || canvas.height === 0) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const point = map.project([selectedStop.place.lng, selectedStop.place.lat]);
|
|
645
|
+
const isMobile = window.innerWidth <= 767;
|
|
646
|
+
const marginTop = isMobile ? 64 : 76;
|
|
647
|
+
const marginBottom = isMobile ? 186 : 108;
|
|
648
|
+
const marginLeft = 28;
|
|
649
|
+
const marginRight = 56;
|
|
650
|
+
const outOfView = point.x < marginLeft ||
|
|
651
|
+
point.x > canvas.width - marginRight ||
|
|
652
|
+
point.y < marginTop ||
|
|
653
|
+
point.y > canvas.height - marginBottom;
|
|
654
|
+
if (!outOfView) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
programmaticMoveRef.current = true;
|
|
658
|
+
map.easeTo({
|
|
659
|
+
center: [selectedStop.place.lng, selectedStop.place.lat],
|
|
660
|
+
padding: getFitOptions(true).padding,
|
|
661
|
+
duration: playing ? 360 : 260,
|
|
662
|
+
});
|
|
663
|
+
window.setTimeout(() => {
|
|
664
|
+
programmaticMoveRef.current = false;
|
|
665
|
+
}, 420);
|
|
666
|
+
}, [selectedStop, playing]);
|
|
667
|
+
useLayoutEffect(() => {
|
|
668
|
+
const map = mapRef.current;
|
|
669
|
+
const card = cardRef.current;
|
|
670
|
+
if (!selectedStop) {
|
|
671
|
+
setCardSide('right');
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
if (window.innerWidth <= 767) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
if (!map || !card || !styleLoadedRef.current) {
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
const point = map.project([selectedStop.place.lng, selectedStop.place.lat]);
|
|
681
|
+
const canvas = map.getCanvas().getBoundingClientRect();
|
|
682
|
+
const box = card.getBoundingClientRect();
|
|
683
|
+
const x = canvas.left + point.x;
|
|
684
|
+
const y = canvas.top + point.y;
|
|
685
|
+
const covered = x >= box.left && x <= box.right && y >= box.top && y <= box.bottom;
|
|
686
|
+
if (!covered) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
setCardSide((side) => (side === 'right' ? 'left' : 'right'));
|
|
690
|
+
}, [selectedStop, cardSide, historicalMap]);
|
|
691
|
+
useEffect(() => {
|
|
692
|
+
if (!bundle) {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
const personSlug = searchParams.get('person');
|
|
696
|
+
const targetPerson = personSlug
|
|
697
|
+
? bundle.people.find((person) => person.slug === personSlug && (!person.is_living || person.full_name !== 'Living'))
|
|
698
|
+
: undefined;
|
|
699
|
+
if (targetPerson) {
|
|
700
|
+
setSelectedPersonId(targetPerson.id);
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
const placeSlug = searchParams.get('place');
|
|
704
|
+
const targetPlace = placeSlug ? placesBySlug.get(placeSlug) : undefined;
|
|
705
|
+
if (targetPlace) {
|
|
706
|
+
const match = allStopsForPerson.find((stop) => stop.place.id === targetPlace.id);
|
|
707
|
+
if (match) {
|
|
708
|
+
setSelectedStopId(match.id);
|
|
709
|
+
}
|
|
710
|
+
const span = Math.max(1.5, siteConfig.mapDefaults.minSpanDeg);
|
|
711
|
+
fitCameraBounds([
|
|
712
|
+
[targetPlace.lng - span, targetPlace.lat - span],
|
|
713
|
+
[targetPlace.lng + span, targetPlace.lat + span],
|
|
714
|
+
], match !== undefined);
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
fitCameraBounds(defaultBounds, false);
|
|
718
|
+
}
|
|
719
|
+
}, [bundle, fitCameraBounds, allStopsForPerson, searchParams, placesBySlug, defaultBounds, siteConfig.mapDefaults.minSpanDeg]);
|
|
720
|
+
useEffect(() => {
|
|
721
|
+
const key = `${selectedPersonId}:${selectedEraId}`;
|
|
722
|
+
if (prevFilterKeyRef.current === key) {
|
|
723
|
+
return;
|
|
724
|
+
}
|
|
725
|
+
prevFilterKeyRef.current = key;
|
|
726
|
+
const nextStopId = selectedPersonId === 'all' && selectedEraId === 'all' ? null : (stops[0]?.id ?? null);
|
|
727
|
+
setPlaying(false);
|
|
728
|
+
setStepIndex(-1);
|
|
729
|
+
setDrawerExpanded(false);
|
|
730
|
+
setSelectedStopId(nextStopId);
|
|
731
|
+
const bounds = computeStopsBounds(stops, siteConfig.mapDefaults) ?? defaultBounds;
|
|
732
|
+
fitCameraBounds(bounds, nextStopId !== null);
|
|
733
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps -- stops and defaultBounds are read when the filter key changes
|
|
734
|
+
}, [selectedPersonId, selectedEraId]);
|
|
735
|
+
useEffect(() => {
|
|
736
|
+
if (!playing || stops.length === 0) {
|
|
737
|
+
return undefined;
|
|
738
|
+
}
|
|
739
|
+
let cancelled = false;
|
|
740
|
+
let tickTimer = null;
|
|
741
|
+
let renderFallbackTimer = null;
|
|
742
|
+
let activeRenderListener = null;
|
|
743
|
+
const waitForNextTick = () => {
|
|
744
|
+
if (cancelled) {
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
const scheduleAdvance = () => {
|
|
748
|
+
if (cancelled) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
tickTimer = window.setTimeout(() => {
|
|
752
|
+
if (cancelled) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
const next = journeyTick(journeyRef.current, stopIdsRef.current);
|
|
756
|
+
applyJourney(next);
|
|
757
|
+
if (next.playing) {
|
|
758
|
+
waitForNextTick();
|
|
759
|
+
}
|
|
760
|
+
}, 950);
|
|
761
|
+
};
|
|
762
|
+
const map = mapRef.current;
|
|
763
|
+
if (!map) {
|
|
764
|
+
scheduleAdvance();
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
let fired = false;
|
|
768
|
+
const onReady = () => {
|
|
769
|
+
if (fired || cancelled) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
fired = true;
|
|
773
|
+
activeRenderListener = null;
|
|
774
|
+
if (renderFallbackTimer !== null) {
|
|
775
|
+
window.clearTimeout(renderFallbackTimer);
|
|
776
|
+
renderFallbackTimer = null;
|
|
777
|
+
}
|
|
778
|
+
scheduleAdvance();
|
|
779
|
+
};
|
|
780
|
+
activeRenderListener = onReady;
|
|
781
|
+
map.once('render', onReady);
|
|
782
|
+
renderFallbackTimer = window.setTimeout(onReady, 350);
|
|
783
|
+
};
|
|
784
|
+
waitForNextTick();
|
|
785
|
+
return () => {
|
|
786
|
+
cancelled = true;
|
|
787
|
+
const map = mapRef.current;
|
|
788
|
+
if (map && activeRenderListener) {
|
|
789
|
+
map.off('render', activeRenderListener);
|
|
790
|
+
}
|
|
791
|
+
if (tickTimer !== null) {
|
|
792
|
+
window.clearTimeout(tickTimer);
|
|
793
|
+
}
|
|
794
|
+
if (renderFallbackTimer !== null) {
|
|
795
|
+
window.clearTimeout(renderFallbackTimer);
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
}, [playing, stops.length, applyJourney]);
|
|
799
|
+
useEffect(() => {
|
|
800
|
+
const onKeyDown = (event) => {
|
|
801
|
+
const { target } = event;
|
|
802
|
+
if (target instanceof HTMLInputElement ||
|
|
803
|
+
target instanceof HTMLSelectElement ||
|
|
804
|
+
target instanceof HTMLTextAreaElement) {
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
if (event.key === 'Escape' && selectedStopId) {
|
|
808
|
+
setPlaying(false);
|
|
809
|
+
setSelectedStopId(null);
|
|
810
|
+
setDrawerExpanded(false);
|
|
811
|
+
}
|
|
812
|
+
else if (event.key === 'ArrowRight') {
|
|
813
|
+
event.preventDefault();
|
|
814
|
+
applyJourney(journeyNext(journeyRef.current, stopIdsRef.current));
|
|
815
|
+
}
|
|
816
|
+
else if (event.key === 'ArrowLeft') {
|
|
817
|
+
event.preventDefault();
|
|
818
|
+
applyJourney(journeyPrev(journeyRef.current, stopIdsRef.current));
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
window.addEventListener('keydown', onKeyDown);
|
|
822
|
+
return () => {
|
|
823
|
+
window.removeEventListener('keydown', onKeyDown);
|
|
824
|
+
};
|
|
825
|
+
}, [selectedStopId, applyJourney]);
|
|
826
|
+
const totalMiles = useMemo(() => segments.reduce((sum, segment) => sum + segment.distanceMiles, 0), [segments]);
|
|
827
|
+
const handleFitClick = useCallback(() => {
|
|
828
|
+
const bounds = computeStopsBounds(stops, siteConfig.mapDefaults) ?? defaultBounds;
|
|
829
|
+
fitCameraBounds(bounds, selectedStopId !== null);
|
|
830
|
+
}, [stops, siteConfig.mapDefaults, defaultBounds, fitCameraBounds, selectedStopId]);
|
|
831
|
+
const sliderIndex = stepIndex < 0 ? Math.max(0, stops.length - 1) : stepIndex;
|
|
832
|
+
const sliderStop = stops[sliderIndex];
|
|
833
|
+
const sliderValueText = sliderStop
|
|
834
|
+
? `Stop ${sliderIndex + 1} of ${stops.length}: ${sliderStop.year}, ${sliderStop.place.name}`
|
|
835
|
+
: 'No stops';
|
|
836
|
+
const yearSpanLabel = visibleStops.length > 0
|
|
837
|
+
? `${visibleStops[0].year}–${visibleStops.at(-1)?.year}`
|
|
838
|
+
: '—';
|
|
839
|
+
const metricLabel = usePerPersonSegments
|
|
840
|
+
? `${visibleStops.length} ${visibleStops.length === 1 ? 'stop' : 'stops'}`
|
|
841
|
+
: `${totalMiles.toLocaleString()} mi`;
|
|
842
|
+
if (error) {
|
|
843
|
+
return (_jsxs("div", { className: "map-shell", children: [_jsx(ExplorerTopBar, {}), _jsx("main", { className: "index-page", children: _jsxs("div", { className: "archive-error-box", role: "alert", children: [_jsx("h2", { children: "Unable to load migration map" }), _jsx("p", { children: error }), _jsx("button", { type: "button", className: "pill-btn active", onClick: () => {
|
|
844
|
+
window.location.reload();
|
|
845
|
+
}, children: "Reload archive" })] }) })] }));
|
|
846
|
+
}
|
|
847
|
+
if (loading || !bundle) {
|
|
848
|
+
return (_jsxs("div", { className: "map-shell", children: [_jsx(ExplorerTopBar, {}), _jsx("main", { className: "index-page", children: _jsxs("output", { className: "archive-loading-shell", "aria-live": "polite", children: [_jsx("span", { className: "archive-loading-spinner", "aria-hidden": "true" }), _jsx("span", { children: "Loading archival migration map\u2026" })] }) })] }));
|
|
849
|
+
}
|
|
850
|
+
return (_jsxs("div", { className: "map-shell", children: [_jsx(ExplorerTopBar, {}), _jsxs("main", { className: "tree-page map-page", children: [_jsx("div", { ref: mapHostRef, className: "map-canvas", style: { position: 'absolute', inset: 0 } }), historicalMap.kind === 'failed' && (_jsx("output", { className: "map-style-note", children: "Showing offline paper basemap." })), _jsxs("div", { className: "map-overlay map-toolbar", children: [_jsxs("label", { className: "map-trace-label", children: [_jsx("span", { children: "Trace:" }), _jsxs("select", { className: "pill-btn", "aria-label": "Filter migration map by person", value: selectedPersonId, onChange: (event) => {
|
|
851
|
+
setSelectedPersonId(event.target.value);
|
|
852
|
+
}, children: [_jsxs("option", { value: "all", children: ["Full ", siteConfig.site.familyName, " Lineage (", allStopsForPerson.length, " stops)"] }), selectablePeople.map((person) => (_jsxs("option", { value: person.id, children: [person.full_name, " (", person.birth_year || '?', "\u2013", person.death_year || '?', ")"] }, person.id)))] })] }), _jsxs("fieldset", { className: "map-toolbar-presets", "aria-label": "Filter migration map by era", children: [_jsxs("button", { type: "button", className: `pill-btn map-bordered-btn ${selectedEraId === 'all' ? 'active' : ''}`, "aria-pressed": selectedEraId === 'all', onClick: () => {
|
|
853
|
+
setSelectedEraId('all');
|
|
854
|
+
}, children: ["All Eras (", allStopsForPerson.length, ")"] }), migrationEras
|
|
855
|
+
.filter((era) => (eraStopCounts.get(era.id) ?? 0) > 0)
|
|
856
|
+
.map((era) => (_jsxs("button", { type: "button", className: `pill-btn map-bordered-btn ${selectedEraId === era.id ? 'active' : ''}`, "aria-pressed": selectedEraId === era.id, onClick: () => {
|
|
857
|
+
setSelectedEraId(era.id);
|
|
858
|
+
}, children: [era.label, " (", eraStopCounts.get(era.id) ?? 0, ")"] }, era.id)))] }), selectedPersonId === 'all' && (_jsxs("fieldset", { className: "map-route-mode", "aria-label": "Full lineage route mode", children: [_jsx("button", { type: "button", className: `pill-btn map-bordered-btn ${routeMode === 'per-person' ? 'active' : ''}`, "aria-pressed": routeMode === 'per-person', onClick: () => {
|
|
859
|
+
setRouteMode('per-person');
|
|
860
|
+
}, children: "By person" }), _jsx("button", { type: "button", className: `pill-btn map-bordered-btn ${routeMode === 'chronological' ? 'active' : ''}`, "aria-pressed": routeMode === 'chronological', onClick: () => {
|
|
861
|
+
setRouteMode('chronological');
|
|
862
|
+
}, children: "Chronological" })] }))] }), _jsx("aside", { className: "map-overlay map-stage-legend", "aria-label": "Migration stage color legend", children: migrationEras.map((era) => (_jsxs("span", { className: "map-legend-item", children: [_jsx("span", { className: "map-legend-swatch", style: { backgroundColor: stageColorMap.get(era.id) ?? '#1B2A41' }, "aria-hidden": "true" }), era.label] }, era.id))) }), _jsxs("div", { className: `map-bottom-dock${selectedStop ? ' has-stop' : ''}`, children: [_jsx("div", { className: "map-drawer-handle", "aria-hidden": "true" }), selectedStop && (_jsxs("section", { ref: cardRef, className: `map-overlay tree-popover map-stop-popover${cardSide === 'left' ? ' is-left' : ''}${drawerExpanded ? ' is-expanded' : ''}`, "aria-label": "Selected stop details", "aria-live": "polite", children: [_jsxs("div", { className: "map-stop-header", children: [_jsxs("div", { className: "map-stop-meta", children: [_jsxs("span", { className: "map-stop-eyebrow", style: { color: stageColorMap.get(selectedStop.lineageStage) ?? '#1B2A41' }, children: [_jsx("span", { children: selectedStop.displayDate }), _jsx("span", { className: "map-stop-stage", children: (stageLabelMap.get(selectedStop.lineageStage) ?? selectedStop.lineageStage).toUpperCase() })] }), _jsx("h2", { className: "map-stop-title", children: selectedStop.place.full_name })] }), _jsxs("div", { className: "map-stop-header-actions", children: [_jsx("button", { type: "button", className: "pill-btn map-bordered-btn map-drawer-toggle", "aria-expanded": drawerExpanded, onClick: () => {
|
|
863
|
+
setDrawerExpanded((open) => !open);
|
|
864
|
+
}, children: drawerExpanded ? 'Hide ▾' : 'Details ▴' }), _jsx("button", { type: "button", className: "pill-btn map-bordered-btn map-close-btn", onClick: () => {
|
|
865
|
+
setPlaying(false);
|
|
866
|
+
setSelectedStopId(null);
|
|
867
|
+
setDrawerExpanded(false);
|
|
868
|
+
}, "aria-label": "Close stop details", children: "\u2715" })] })] }), _jsxs("div", { className: "map-stop-details", children: [_jsx("p", { className: "map-stop-summary", children: selectedStop.title }), _jsxs("div", { className: "map-stop-coords", children: [selectedStop.place.lat.toFixed(2), "\u00B0", selectedStop.place.lat >= 0 ? 'N' : 'S', ",", ' ', Math.abs(selectedStop.place.lng).toFixed(2), "\u00B0", selectedStop.place.lng >= 0 ? 'E' : 'W'] }), _jsxs("div", { className: "map-stop-links", children: [_jsx(Link, { to: `/place/${selectedStop.place.slug}`, className: "pill-btn active", style: { textDecoration: 'none' }, children: "Place Dossier \u2192" }), selectedStop.personSlugs.slice(0, 2).map((personSlug, index) => (_jsxs(Link, { to: `/person/${personSlug}?event=${selectedStop.eventId}`, className: "pill-btn map-bordered-btn", style: { textDecoration: 'none' }, children: [selectedStop.personNames[index], " \u2192"] }, personSlug)))] })] })] })), _jsxs("div", { className: "map-overlay map-playback-bar", children: [_jsxs("div", { className: "map-playback-buttons", children: [_jsx("button", { type: "button", className: `pill-btn map-bordered-btn ${playing ? 'active' : ''}`, "aria-pressed": playing, onClick: () => {
|
|
869
|
+
applyJourney(journeyPlayToggle(journey, stopIds));
|
|
870
|
+
}, children: playing ? '❚❚ Pause' : '▶ Play Route' }), _jsx("button", { type: "button", className: "pill-btn map-bordered-btn", disabled: stops.length === 0 || stepIndex === 0, onClick: () => {
|
|
871
|
+
applyJourney(journeyPrev(journey, stopIds));
|
|
872
|
+
}, children: "\u2190 Prev" }), _jsx("button", { type: "button", className: "pill-btn map-bordered-btn", disabled: stops.length === 0 || stepIndex >= stops.length - 1, onClick: () => {
|
|
873
|
+
applyJourney(journeyNext(journey, stopIds));
|
|
874
|
+
}, children: "Next \u2192" }), _jsxs("button", { type: "button", className: `pill-btn map-bordered-btn ${stepIndex < 0 ? 'active' : ''}`, onClick: () => {
|
|
875
|
+
setDrawerExpanded(false);
|
|
876
|
+
applyJourney(journeyReset(journey));
|
|
877
|
+
}, children: ["All (", stops.length, ")"] })] }), _jsxs("div", { className: "map-playback-slider", children: [_jsx("input", { type: "range", min: 0, max: Math.max(0, stops.length - 1), value: sliderIndex, onChange: (event) => {
|
|
878
|
+
applyJourney(journeyScrub(journey, Number(event.target.value), stopIds));
|
|
879
|
+
}, "aria-label": "Scrub migration timeline stop", "aria-valuetext": sliderValueText, className: "map-range-input" }), _jsxs("span", { className: "map-playback-stat", children: [yearSpanLabel, " \u00B7 ", metricLabel] })] })] })] }), _jsxs("div", { className: "map-overlay tree-controls map-zoom-controls", children: [_jsx("button", { type: "button", className: "pill-btn", "aria-label": "Zoom in map", onClick: () => {
|
|
880
|
+
mapRef.current?.zoomIn({ duration: 180 });
|
|
881
|
+
}, children: "+" }), _jsx("button", { type: "button", className: "pill-btn", "aria-label": "Zoom out map", onClick: () => {
|
|
882
|
+
mapRef.current?.zoomOut({ duration: 180 });
|
|
883
|
+
}, children: "\u2212" }), _jsx("button", { type: "button", className: "pill-btn", onClick: handleFitClick, children: "Fit" })] })] })] }));
|
|
884
|
+
};
|
|
885
|
+
//# sourceMappingURL=MapPage.js.map
|