astraeus 0.6.0 → 0.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/CHANGELOG.md +192 -0
- package/README.md +205 -34
- package/package.json +5 -4
- package/src/api/AstraeusScene.d.ts +24 -6
- package/src/api/AstraeusScene.js +46 -19
- package/src/api/AstraeusScene.node.js +46 -19
- package/src/api/assembleScene.d.ts +36 -0
- package/src/api/assembleScene.js +175 -0
- package/src/api/bodySetChecks.d.ts +10 -0
- package/src/api/bodySetChecks.js +117 -0
- package/src/api/bodySetInput.d.ts +81 -0
- package/src/api/bodySetInput.js +1 -0
- package/src/api/containingBlock.d.ts +6 -0
- package/src/api/containingBlock.js +16 -0
- package/src/api/data.d.ts +17 -5
- package/src/api/data.js +28 -10
- package/src/api/definitionOf.d.ts +16 -0
- package/src/api/definitionOf.js +20 -0
- package/src/api/errors.d.ts +61 -1
- package/src/api/frozenCopy.d.ts +6 -0
- package/src/api/frozenCopy.js +26 -0
- package/src/api/group.d.ts +8 -2
- package/src/api/group.js +24 -5
- package/src/api/index.d.ts +19 -7
- package/src/api/index.js +2 -2
- package/src/api/index.node.js +2 -2
- package/src/api/listeners.d.ts +5 -0
- package/src/api/listeners.js +25 -0
- package/src/api/look.d.ts +47 -0
- package/src/api/look.js +1 -0
- package/src/api/lookInput.d.ts +3 -0
- package/src/api/lookInput.js +41 -0
- package/src/api/moonPanelInput.d.ts +60 -0
- package/src/api/moonPanelInput.js +1 -0
- package/src/api/mount.d.ts +10 -16
- package/src/api/mount.js +27 -11
- package/src/api/mount.node.js +27 -11
- package/src/api/pathProvenance.d.ts +15 -6
- package/src/api/pathProvenance.js +23 -11
- package/src/api/pickerInput.d.ts +25 -0
- package/src/api/pickerInput.js +1 -0
- package/src/api/planBodies.d.ts +72 -0
- package/src/api/planBodies.js +300 -0
- package/src/api/planBodySets.d.ts +68 -0
- package/src/api/planBodySets.js +234 -0
- package/src/api/planCamera.d.ts +83 -0
- package/src/api/planCamera.js +184 -0
- package/src/api/planGroups.d.ts +36 -0
- package/src/api/planGroups.js +103 -0
- package/src/api/planMoonPanel.d.ts +19 -0
- package/src/api/planMoonPanel.js +104 -0
- package/src/api/planPaths.d.ts +40 -0
- package/src/api/planPaths.js +212 -0
- package/src/api/planPicker.d.ts +12 -0
- package/src/api/planPicker.js +40 -0
- package/src/api/planPlaces.d.ts +16 -0
- package/src/api/planPlaces.js +99 -0
- package/src/api/planStory.d.ts +26 -0
- package/src/api/planStory.js +66 -0
- package/src/api/planTimeline.d.ts +27 -0
- package/src/api/planTimeline.js +68 -0
- package/src/api/planViews.d.ts +25 -0
- package/src/api/planViews.js +35 -0
- package/src/api/prepared.js +4 -1
- package/src/api/renamedInputs.d.ts +15 -0
- package/src/api/renamedInputs.js +39 -0
- package/src/api/scene.d.ts +176 -65
- package/src/api/scene.js +257 -725
- package/src/api/sceneFreeze.d.ts +4 -0
- package/src/api/sceneFreeze.js +10 -0
- package/src/api/sceneReads.d.ts +171 -0
- package/src/api/sceneReads.js +6 -0
- package/src/api/sphereOfInfluence.d.ts +20 -0
- package/src/api/sphereOfInfluence.js +48 -0
- package/src/api/story.d.ts +49 -19
- package/src/api/story.js +54 -22
- package/src/api/sunOrbit.js +9 -11
- package/src/api/time.d.ts +2 -1
- package/src/api/time.js +2 -1
- package/src/api/viewerCamera.d.ts +22 -0
- package/src/api/viewerCamera.js +84 -0
- package/src/api/viewerClock.d.ts +30 -0
- package/src/api/viewerClock.js +85 -0
- package/src/api/viewerFirstDraw.d.ts +14 -0
- package/src/api/viewerFirstDraw.js +26 -0
- package/src/api/viewerHandle.d.ts +79 -0
- package/src/api/viewerHandle.js +31 -0
- package/src/api/viewerLink.d.ts +91 -13
- package/src/api/viewerLink.js +111 -64
- package/src/api/viewerLooks.d.ts +19 -0
- package/src/api/viewerLooks.js +37 -0
- package/src/api/viewerPicker.d.ts +22 -0
- package/src/api/viewerPicker.js +49 -0
- package/src/api/viewerSelection.d.ts +25 -0
- package/src/api/viewerSelection.js +31 -0
- package/src/api/viewerViews.d.ts +10 -0
- package/src/api/viewerViews.js +18 -0
- package/src/api/viewerZones.d.ts +20 -0
- package/src/api/viewerZones.js +47 -0
- package/src/api/views.d.ts +41 -0
- package/src/api/views.js +82 -0
- package/src/app/App.d.ts +5 -3
- package/src/app/App.js +211 -75
- package/src/app/App.node.js +211 -75
- package/src/app/AstraeusScene.d.ts +19 -2
- package/src/app/AstraeusScene.js +4 -4
- package/src/app/BodyView.d.ts +4 -1
- package/src/app/BodyView.js +2 -2
- package/src/app/CameraController.d.ts +12 -0
- package/src/app/CameraController.js +3 -1
- package/src/app/DeveloperSettings.d.ts +1 -4
- package/src/app/DeveloperSettings.js +6 -10
- package/src/app/FeatureMarkers.d.ts +4 -3
- package/src/app/FeatureMarkers.js +8 -13
- package/src/app/FrameRateSection.js +2 -1
- package/src/app/OrbitSetView.js +1 -1
- package/src/app/SettingControls.d.ts +11 -3
- package/src/app/SettingControls.js +10 -2
- package/src/app/SkyView.d.ts +3 -10
- package/src/app/SkyView.js +6 -28
- package/src/app/StoryMarkers.d.ts +4 -1
- package/src/app/StoryMarkers.js +3 -2
- package/src/app/TrackedBodyView.d.ts +1 -1
- package/src/app/TrackedBodyView.js +20 -11
- package/src/app/address.d.ts +16 -0
- package/src/app/address.js +31 -0
- package/src/app/bodyDraw.d.ts +10 -7
- package/src/app/bodyDraw.js +12 -32
- package/src/app/bodyMetrics.js +2 -2
- package/src/app/bodySet.d.ts +4 -20
- package/src/app/bodySet.js +5 -16
- package/src/app/debugReadout.js +1 -1
- package/src/app/displaySwitches.d.ts +4 -0
- package/src/app/displaySwitches.js +6 -0
- package/src/app/experienceDefinition.d.ts +14 -23
- package/src/app/listSwitch.d.ts +8 -14
- package/src/app/listSwitch.js +3 -10
- package/src/app/liveLook.d.ts +39 -0
- package/src/app/liveLook.js +66 -0
- package/src/app/look.d.ts +36 -0
- package/src/app/look.js +61 -0
- package/src/app/mission.d.ts +16 -3
- package/src/app/mission.js +16 -1
- package/src/app/openClock.d.ts +3 -2
- package/src/app/openClock.js +3 -3
- package/src/app/sceneCamera.d.ts +2 -0
- package/src/app/sceneCamera.js +23 -0
- package/src/app/sceneFrame.d.ts +6 -4
- package/src/app/sceneFrame.js +55 -14
- package/src/app/sceneHooks.js +3 -2
- package/src/app/style.css +114 -139
- package/src/app/trackedMetrics.d.ts +10 -3
- package/src/app/trackedMetrics.js +22 -11
- package/src/app/viewHiding.d.ts +13 -0
- package/src/app/viewHiding.js +37 -0
- package/src/app/viewLink.d.ts +10 -32
- package/src/app/viewLink.js +10 -49
- package/src/app/viewerPort.d.ts +56 -0
- package/src/app/views.d.ts +32 -0
- package/src/app/views.js +2 -0
- package/src/assets/bodies/galileanMoons.js +1 -2
- package/src/assets/bodies/io.js +2 -2
- package/src/assets/bodies/listedMoons.d.ts +1 -1
- package/src/assets/bodies/listedMoons.js +2 -3
- package/src/assets/bodies/planetSystemMaps.js +2 -3
- package/src/assets/bodies/venus.js +2 -6
- package/src/assets/catalogue.js +1 -2
- package/src/assets/licence.d.ts +3 -3
- package/src/assets/licence.js +3 -3
- package/src/assets/pictures.d.ts +15 -12
- package/src/assets/pictures.js +24 -20
- package/src/assets/sky.d.ts +6 -5
- package/src/assets/sky.js +6 -9
- package/src/assets/visual.d.ts +4 -0
- package/src/core/bodies/index.d.ts +0 -4
- package/src/core/bodies/index.js +1 -6
- package/src/core/bodies/jupiterData.d.ts +0 -1
- package/src/core/bodies/jupiterData.js +2 -5
- package/src/core/bodies/moonSystem.d.ts +1 -1
- package/src/core/bodies/moonSystem.js +102 -55
- package/src/core/bodies/outerPlanetRingData.js +2 -2
- package/src/core/bodies/planetTrajectory.js +1 -1
- package/src/core/bodySetFamilies.d.ts +20 -0
- package/src/core/bodySetFamilies.js +14 -0
- package/src/core/chebyshevEphemeris.js +1 -1
- package/src/core/elementsBody.d.ts +8 -4
- package/src/core/elementsBody.js +32 -11
- package/src/core/elementsGroup.d.ts +27 -0
- package/src/core/elementsGroup.js +85 -0
- package/src/core/events.d.ts +2 -0
- package/src/core/events.js +2 -0
- package/src/core/illumination.js +1 -1
- package/src/core/listedOrbitGroup.d.ts +2 -0
- package/src/core/listedOrbitGroup.js +11 -7
- package/src/core/moonListText.d.ts +6 -0
- package/src/core/moonListText.js +19 -0
- package/src/core/moonTrajectory.js +1 -1
- package/src/core/pacing.d.ts +38 -3
- package/src/core/pacing.js +55 -4
- package/src/core/planetModels.js +2 -2
- package/src/core/planetSeries.d.ts +8 -0
- package/src/core/planetSeries.js +16 -2
- package/src/core/pointGroup.js +1 -1
- package/src/core/provenance.d.ts +2 -1
- package/src/core/provenance.js +2 -2
- package/src/core/referenceCenters.js +5 -5
- package/src/core/sampledTrajectory.js +1 -1
- package/src/core/scalePolicy.d.ts +1 -0
- package/src/core/startView.d.ts +19 -0
- package/src/core/startView.js +28 -0
- package/src/core/state.d.ts +6 -2
- package/src/core/state.js +3 -3
- package/src/core/storyPanels.d.ts +63 -0
- package/src/core/storyPanels.js +111 -0
- package/src/core/sunCentredSources.d.ts +4 -0
- package/src/core/sunCentredSources.js +9 -2
- package/src/core/timeInput.d.ts +4 -0
- package/src/core/timeInput.js +4 -0
- package/src/shell/AstraeusShell.d.ts +17 -3
- package/src/shell/AstraeusShell.js +60 -13
- package/src/shell/AstraeusShell.node.js +60 -13
- package/src/shell/Collapsible.d.ts +4 -3
- package/src/shell/Collapsible.js +5 -5
- package/src/shell/ControlsDrawer.d.ts +1 -1
- package/src/shell/ControlsDrawer.js +3 -1
- package/src/shell/DisplaySwitches.d.ts +18 -1
- package/src/shell/DisplaySwitches.js +20 -6
- package/src/shell/InfoPanel.d.ts +3 -1
- package/src/shell/InfoPanel.js +5 -4
- package/src/shell/MoonFamilyPanel.js +1 -1
- package/src/shell/ObjectControls.d.ts +3 -1
- package/src/shell/ObjectControls.js +2 -2
- package/src/shell/Sources.d.ts +5 -3
- package/src/shell/Sources.js +5 -5
- package/src/shell/StoryPanelView.d.ts +4 -3
- package/src/shell/StoryPanelView.js +8 -6
- package/src/shell/SwitchControl.d.ts +5 -11
- package/src/shell/SwitchControl.js +2 -20
- package/src/shell/TimelineBar.css +84 -66
- package/src/shell/TimelineBar.d.ts +5 -2
- package/src/shell/TimelineBar.js +37 -11
- package/src/shell/TimelineBar.node.js +37 -11
- package/src/shell/TopBar.css +22 -22
- package/src/shell/TopBar.d.ts +9 -3
- package/src/shell/TopBar.js +5 -5
- package/src/shell/TopBar.node.js +5 -5
- package/src/shell/bootLoader.d.ts +4 -10
- package/src/shell/bootLoader.js +6 -52
- package/src/shell/embedded.css +18 -18
- package/src/shell/experience.d.ts +1 -1
- package/src/shell/moonFamilies.d.ts +2 -6
- package/src/shell/moonFamilies.js +2 -18
- package/src/shell/phone.css +58 -58
- package/src/shell/storyPanels.d.ts +2 -53
- package/src/shell/storyPanels.js +1 -106
- package/src/shell/style.css +153 -134
- package/src/shell/timelineModel.d.ts +13 -0
- package/src/shell/timelineModel.js +25 -0
- package/src/shell/useDrawers.d.ts +3 -2
- package/src/shell/useDrawers.js +4 -3
- package/src/shell/viewCamera.d.ts +4 -0
- package/src/shell/viewCamera.js +13 -0
- package/src/shell/viewerKeys.d.ts +8 -0
- package/src/shell/viewerKeys.js +16 -0
- package/src/synthetic/syntheticDefinition.js +20 -24
- package/src/synthetic/syntheticJourneyScene.js +14 -4
- package/src/synthetic/syntheticProbeDefinition.js +2 -1
- package/src/synthetic/syntheticViewsDefinition.d.ts +3 -0
- package/src/synthetic/syntheticViewsDefinition.js +38 -0
- package/data/moons/jupiter.json +0 -3333
- package/data/moons/neptune.json +0 -555
- package/data/moons/pluto.json +0 -205
- package/data/moons/saturn.json +0 -8267
- package/data/moons/uranus.json +0 -887
- package/src/app/addressNavigation.d.ts +0 -17
- package/src/app/addressNavigation.js +0 -16
- package/src/assets/bodies/jupiterMoonCatalogue.d.ts +0 -3
- package/src/assets/bodies/jupiterMoonCatalogue.js +0 -4
- package/src/assets/bodies/outerPlanetCatalogues.d.ts +0 -7
- package/src/assets/bodies/outerPlanetCatalogues.js +0 -8
- package/src/assets/bodies/swiftTuttle.d.ts +0 -12
- package/src/assets/bodies/swiftTuttle.js +0 -13
- package/src/assets/moonCatalogue.d.ts +0 -49
- package/src/assets/moonCatalogue.js +0 -80
- package/src/core/bodies/outerPlanetData.d.ts +0 -4
- package/src/core/bodies/outerPlanetData.js +0 -13
- package/src/core/bodies/swiftTuttle.d.ts +0 -46
- package/src/core/bodies/swiftTuttle.js +0 -106
|
@@ -5,7 +5,8 @@ import type { TimelineGlowLook } from "./timelineGlow.js";
|
|
|
5
5
|
import type { ExperienceCameraPreset, ExperienceConfig } from "./experience.js";
|
|
6
6
|
import type { Metric } from "./metrics.js";
|
|
7
7
|
import { type PhoneLayoutSettings } from "./phoneLayout.js";
|
|
8
|
-
import type { DisplaySwitchItem } from "./DisplaySwitches.js";
|
|
8
|
+
import type { DisplaySwitchItem, ViewChoice } from "./DisplaySwitches.js";
|
|
9
|
+
import type { ViewCameraRule } from "../app/views.js";
|
|
9
10
|
import type { ExperienceSwitch } from "./SwitchControl.js";
|
|
10
11
|
import type { ScaleChoice, ScaleId } from "./scaleModel.js";
|
|
11
12
|
import "./controls.css";
|
|
@@ -14,6 +15,8 @@ import "./phone.css";
|
|
|
14
15
|
import "./embedded.css";
|
|
15
16
|
/** The object selected when the shell opens: the first one available at the clock time, else the first listed. */
|
|
16
17
|
export declare function initialObjectId(experience: ExperienceConfig, timeUtcMs: number): string;
|
|
18
|
+
/** Who moved the selection: the visitor, or a move of time or the view (named by whatever last moved them). */
|
|
19
|
+
export type SelectionOrigin = "visitor" | "move";
|
|
17
20
|
interface Props {
|
|
18
21
|
readonly experience: ExperienceConfig;
|
|
19
22
|
readonly snapshot: ClockSnapshot;
|
|
@@ -25,7 +28,10 @@ interface Props {
|
|
|
25
28
|
readonly paceAuto?: boolean | undefined;
|
|
26
29
|
readonly onSeek: (timeUtcMs: number) => void;
|
|
27
30
|
readonly onCameraRequest: (request: ExperienceCameraPreset["request"]) => void;
|
|
28
|
-
|
|
31
|
+
/** Holds the camera where it is, its target fixed in the scene (a view's `stay` rule); a later camera request replaces it. */
|
|
32
|
+
readonly onCameraHold?: () => void;
|
|
33
|
+
/** `origin` is required so a new selection path must say who chose: "visitor" (a menu choice, pick, preset or marker) or "move" (time or the view moved and the selection followed). */
|
|
34
|
+
readonly onSelectionChange: (objectId: string, origin: SelectionOrigin) => void;
|
|
29
35
|
readonly scaleId: ScaleId;
|
|
30
36
|
readonly onScaleChange: (id: ScaleId) => void;
|
|
31
37
|
readonly scaleChoices?: readonly ScaleChoice[];
|
|
@@ -33,8 +39,16 @@ interface Props {
|
|
|
33
39
|
readonly switcher?: ExperienceSwitch;
|
|
34
40
|
/** Display switches a story placed in the top bar or its switch panel (also in the phone drawer); absent or empty: none. */
|
|
35
41
|
readonly displaySwitches?: readonly DisplaySwitchItem[];
|
|
42
|
+
/** The views the scene names (T-219); absent: none. The experience this shell gets is already the current view's. */
|
|
43
|
+
readonly viewChoice?: ViewChoice;
|
|
44
|
+
/** The view showing and its camera rule (T-220): on a switch of `id`, a followed or focused object the new view does not show is handled by the rule; absent: no views. */
|
|
45
|
+
readonly viewCamera?: {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly rule: ViewCameraRule;
|
|
48
|
+
};
|
|
36
49
|
/** Live measurements for an object's info panel, from the app's own State; empty when it has none. */
|
|
37
50
|
readonly metricsFor?: (objectId: string, timeUtcMs: number) => readonly Metric[];
|
|
51
|
+
/** The Developer drawer's content; absent: the shell shows no Developer toggle and no drawer (the host did not ask for developer tools). */
|
|
38
52
|
readonly developerTools?: ReactNode;
|
|
39
53
|
/** The live story-panel settings (auto-open, pause length); absent: the experience's own defaults. */
|
|
40
54
|
readonly storyPanelSettings?: StoryPanelSettings;
|
|
@@ -69,5 +83,5 @@ interface Props {
|
|
|
69
83
|
readonly children: ReactNode;
|
|
70
84
|
}
|
|
71
85
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
72
|
-
export declare function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout, highlightedFamily, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }: Props): import("react").JSX.Element;
|
|
86
|
+
export declare function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout, highlightedFamily, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }: Props): import("react").JSX.Element;
|
|
73
87
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { lazy, Suspense, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { lazy, Suspense, useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { StoryPanelView } from "./StoryPanelView.js";
|
|
4
4
|
import { useDrawers } from "./useDrawers.js";
|
|
5
5
|
import { useStoryPanels } from "./useStoryPanels.js";
|
|
@@ -10,6 +10,7 @@ import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
|
|
|
10
10
|
import { ControlsDrawer } from "./ControlsDrawer.js";
|
|
11
11
|
import { isEmbedded } from "./embedded.js";
|
|
12
12
|
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
13
|
+
import { presetForViewRule } from "./viewCamera.js";
|
|
13
14
|
import { DeveloperToggle, TopBar } from "./TopBar.js";
|
|
14
15
|
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable } from "./objectModel.js";
|
|
15
16
|
import "./controls.css";
|
|
@@ -46,15 +47,34 @@ function ownStorySettings(storySet) {
|
|
|
46
47
|
function ShellTimeline({ hidden, ...bar }) {
|
|
47
48
|
return hidden ? null : _jsx(TimelineBar, { ...bar });
|
|
48
49
|
}
|
|
50
|
+
/** The Developer cog and its drawer; drawn only when the host gave the drawer's content (absent: neither, so an outside page never sees a developer cog). */
|
|
51
|
+
function DeveloperDrawer({ developerMode, onDeveloperModeChange, children }) {
|
|
52
|
+
const drawerId = `${useId()}-developer-tools`;
|
|
53
|
+
if (children === undefined)
|
|
54
|
+
return null;
|
|
55
|
+
return (_jsxs(_Fragment, { children: [_jsx(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, drawerId: drawerId }), _jsx("aside", { className: "developer-tools", id: drawerId, "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? children : null })] }));
|
|
56
|
+
}
|
|
49
57
|
/** The wide-screen moons toggle and the sheet it opens under the toolbar. */
|
|
50
58
|
function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
51
|
-
|
|
59
|
+
const sheetId = `${useId()}-moons-panel`;
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "moons-toggle ui-pill", "aria-expanded": open, "aria-controls": sheetId, onClick: onToggle, children: [planetLabel, " moons"] }), _jsx("aside", { id: sheetId, className: "moons-sheet", "data-open": open, "aria-label": "Moons by family", onKeyDown: (event) => { if (event.key === "Escape")
|
|
52
61
|
onClose(); }, children: children })] }));
|
|
53
62
|
}
|
|
54
63
|
/** The serial of a request that is asked again by sending a new one; absent request: undefined. */
|
|
55
64
|
function serialOf(request) {
|
|
56
65
|
return request?.serial;
|
|
57
66
|
}
|
|
67
|
+
/** Tells a switch of view from any other change of the experience: `takeSwitchRule` gives the new view's camera rule once after the view's id changed, else undefined. */
|
|
68
|
+
function useViewSwitch(viewCamera) {
|
|
69
|
+
const viewId = viewCamera?.id;
|
|
70
|
+
const last = useRef(viewId);
|
|
71
|
+
const takeSwitchRule = () => {
|
|
72
|
+
const switched = viewId !== last.current;
|
|
73
|
+
last.current = viewId;
|
|
74
|
+
return switched ? viewCamera?.rule : undefined;
|
|
75
|
+
};
|
|
76
|
+
return { viewId, takeSwitchRule };
|
|
77
|
+
}
|
|
58
78
|
function panelsOf(storySet) {
|
|
59
79
|
return storySet?.panels ?? [];
|
|
60
80
|
}
|
|
@@ -72,14 +92,15 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
|
|
|
72
92
|
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
73
93
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
74
94
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
75
|
-
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
95
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
96
|
+
const infoPanelId = `${useId()}-info-panel`;
|
|
76
97
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
77
98
|
const phone = usePhone();
|
|
78
99
|
/** Fixed for the page: a frame does not appear or vanish while the app runs. */
|
|
79
100
|
const [embedded] = useState(isEmbedded);
|
|
80
101
|
const root = useRef(null);
|
|
81
102
|
// The drawer (with the moons in it) and the bottom sheets want the same screen: the drawer, being the one just asked for, takes it.
|
|
82
|
-
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, () => {
|
|
103
|
+
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, root, () => {
|
|
83
104
|
if (experience.moonFamilies !== undefined) {
|
|
84
105
|
setInfo(null);
|
|
85
106
|
story.close();
|
|
@@ -120,20 +141,29 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
120
141
|
story.open(panel.id);
|
|
121
142
|
};
|
|
122
143
|
useEffect(() => {
|
|
123
|
-
onSelectionChange(selectedObjectId);
|
|
144
|
+
onSelectionChange(selectedObjectId, "visitor");
|
|
124
145
|
}, [onSelectionChange, selectedObjectId]);
|
|
146
|
+
// A view switch is told from other changes of the experience by the view's id changing.
|
|
147
|
+
const { viewId, takeSwitchRule } = useViewSwitch(viewCamera);
|
|
125
148
|
useEffect(() => {
|
|
149
|
+
const switchRule = takeSwitchRule();
|
|
126
150
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
127
151
|
if (selected === undefined || !isObjectAvailable(selected, snapshot.timeUtcMs)) {
|
|
128
152
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
129
153
|
setSelectedObjectId(fallbackId);
|
|
130
|
-
onSelectionChange(fallbackId);
|
|
154
|
+
onSelectionChange(fallbackId, "move");
|
|
155
|
+
// The card of an object the view took away closes with it.
|
|
156
|
+
if (switchRule !== undefined && selected === undefined)
|
|
157
|
+
setInfo((now) => (now?.kind === "object" ? null : now));
|
|
131
158
|
}
|
|
132
159
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
133
160
|
const activeRequest = active?.request;
|
|
134
161
|
if (activeRequest !== undefined && activeRequest.kind !== "overview") {
|
|
135
162
|
const target = experience.objects.find((object) => object.id === activeRequest.target);
|
|
136
|
-
if (
|
|
163
|
+
if (switchRule !== undefined && target === undefined) {
|
|
164
|
+
applyViewRule(switchRule);
|
|
165
|
+
}
|
|
166
|
+
else if (target === undefined || !isObjectAvailable(target, snapshot.timeUtcMs)) {
|
|
137
167
|
const overview = findCameraPreset(experience, "overview");
|
|
138
168
|
if (overview !== undefined) {
|
|
139
169
|
setActivePresetId(overview.id);
|
|
@@ -141,7 +171,24 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
141
171
|
}
|
|
142
172
|
}
|
|
143
173
|
}
|
|
144
|
-
|
|
174
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
175
|
+
}, [activePresetId, experience, onCameraRequest, onSelectionChange, selectedObjectId, snapshot.timeUtcMs, viewId]);
|
|
176
|
+
/** The view's camera rule for a followed or focused object the new view does not show: `stay` keeps the pose and stops following; otherwise the rule's framing is requested. */
|
|
177
|
+
const applyViewRule = (rule) => {
|
|
178
|
+
const asked = presetForViewRule(rule, experience);
|
|
179
|
+
const target = asked === undefined || asked.request.kind === "overview" ? undefined : availableObjectById(experience, asked.request.target, snapshot.timeUtcMs);
|
|
180
|
+
// A framing whose object is not available now falls back to the overview, like any other lost target.
|
|
181
|
+
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
182
|
+
if (target !== undefined) {
|
|
183
|
+
setSelectedObjectId(target.id);
|
|
184
|
+
onSelectionChange(target.id, "move"); // only the move-driven effect applies a view rule
|
|
185
|
+
}
|
|
186
|
+
setActivePresetId(preset?.id ?? null);
|
|
187
|
+
if (preset !== undefined)
|
|
188
|
+
onCameraRequest(preset.request);
|
|
189
|
+
else
|
|
190
|
+
onCameraHold?.();
|
|
191
|
+
};
|
|
145
192
|
const [moonsOpen, setMoonsOpen] = useState(false);
|
|
146
193
|
/** A moon chosen in the moon panel: flies to it (the same focus as the object picker) and opens its information. */
|
|
147
194
|
const chooseMoon = (id) => {
|
|
@@ -174,7 +221,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
174
221
|
if (object === undefined)
|
|
175
222
|
return;
|
|
176
223
|
setSelectedObjectId(id);
|
|
177
|
-
onSelectionChange(id);
|
|
224
|
+
onSelectionChange(id, "visitor");
|
|
178
225
|
setInfo({ kind: "object" });
|
|
179
226
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
180
227
|
if (active?.request.kind === "focus" || active?.request.kind === "follow") {
|
|
@@ -198,14 +245,14 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
198
245
|
if (target === undefined)
|
|
199
246
|
return;
|
|
200
247
|
setSelectedObjectId(target.id);
|
|
201
|
-
onSelectionChange(target.id);
|
|
248
|
+
onSelectionChange(target.id, "visitor");
|
|
202
249
|
}
|
|
203
250
|
setActivePresetId(preset.id);
|
|
204
251
|
onCameraRequest(preset.request);
|
|
205
252
|
};
|
|
206
253
|
const seekToEvent = (event) => {
|
|
207
254
|
seek(event.timeUtcMs);
|
|
208
|
-
// The event's own object, framed as the picker's Focus does (and `camera.
|
|
255
|
+
// The event's own object, framed as the picker's Focus does (and `camera.focus` opens): the event, never a default body, names it.
|
|
209
256
|
const object = event.object === undefined ? undefined : availableObjectById(experience, event.object, event.timeUtcMs);
|
|
210
257
|
if (object !== undefined)
|
|
211
258
|
activatePreset(focusPresetFor(experience, object), event.timeUtcMs);
|
|
@@ -227,7 +274,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
227
274
|
useEffect(() => { if (info !== null)
|
|
228
275
|
setMoonsOpen(false); }, [info]);
|
|
229
276
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
230
|
-
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches }));
|
|
277
|
+
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), infoPanelId: infoPanelId, scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
231
278
|
const moonPanel = experience.moonFamilies === undefined ? null : (_jsx(PanelLoadBoundary, { message: "The moon list could not load. Reload the page to try again.", children: _jsx(Suspense, { fallback: null, children: _jsx(MoonFamilyPanel, { list: experience.moonFamilies, highlightedFamily: highlightedFamily, onHighlight: (id) => onHighlightFamily?.(id), onSelectMoon: chooseMoon }) }) }));
|
|
232
|
-
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null) })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(
|
|
279
|
+
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(DeveloperDrawer, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, children: developerTools }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, paceAuto: paceAuto, onSeek: seek, panels: storyPanels, openPanelId: openPanelId, onPanelOpen: openPanelFromTimeline, onEventSeek: seekToEvent, onEventInfo: (event) => setInfo({ kind: "event", id: event.id }), onWindowSeek: seekToWindow, onWindowInfo: (window) => setInfo({ kind: "window", id: window.id }), glowLook: timelineGlow, infoPanelId: infoPanelId, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
233
280
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { lazy, Suspense, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { lazy, Suspense, useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { StoryPanelView } from "./StoryPanelView.js";
|
|
4
4
|
import { useDrawers } from "./useDrawers.js";
|
|
5
5
|
import { useStoryPanels } from "./useStoryPanels.js";
|
|
@@ -10,6 +10,7 @@ import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
|
|
|
10
10
|
import { ControlsDrawer } from "./ControlsDrawer.js";
|
|
11
11
|
import { isEmbedded } from "./embedded.js";
|
|
12
12
|
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
13
|
+
import { presetForViewRule } from "./viewCamera.js";
|
|
13
14
|
import { DeveloperToggle, TopBar } from "./TopBar.node.js";
|
|
14
15
|
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable } from "./objectModel.js";
|
|
15
16
|
/** Keeps `--timeline-space` at the distance from the screen's bottom to the top of the timeline bar, so a phone sheet can sit above it. */
|
|
@@ -42,15 +43,34 @@ function ownStorySettings(storySet) {
|
|
|
42
43
|
function ShellTimeline({ hidden, ...bar }) {
|
|
43
44
|
return hidden ? null : _jsx(TimelineBar, { ...bar });
|
|
44
45
|
}
|
|
46
|
+
/** The Developer cog and its drawer; drawn only when the host gave the drawer's content (absent: neither, so an outside page never sees a developer cog). */
|
|
47
|
+
function DeveloperDrawer({ developerMode, onDeveloperModeChange, children }) {
|
|
48
|
+
const drawerId = `${useId()}-developer-tools`;
|
|
49
|
+
if (children === undefined)
|
|
50
|
+
return null;
|
|
51
|
+
return (_jsxs(_Fragment, { children: [_jsx(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, drawerId: drawerId }), _jsx("aside", { className: "developer-tools", id: drawerId, "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? children : null })] }));
|
|
52
|
+
}
|
|
45
53
|
/** The wide-screen moons toggle and the sheet it opens under the toolbar. */
|
|
46
54
|
function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
47
|
-
|
|
55
|
+
const sheetId = `${useId()}-moons-panel`;
|
|
56
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "moons-toggle ui-pill", "aria-expanded": open, "aria-controls": sheetId, onClick: onToggle, children: [planetLabel, " moons"] }), _jsx("aside", { id: sheetId, className: "moons-sheet", "data-open": open, "aria-label": "Moons by family", onKeyDown: (event) => { if (event.key === "Escape")
|
|
48
57
|
onClose(); }, children: children })] }));
|
|
49
58
|
}
|
|
50
59
|
/** The serial of a request that is asked again by sending a new one; absent request: undefined. */
|
|
51
60
|
function serialOf(request) {
|
|
52
61
|
return request?.serial;
|
|
53
62
|
}
|
|
63
|
+
/** Tells a switch of view from any other change of the experience: `takeSwitchRule` gives the new view's camera rule once after the view's id changed, else undefined. */
|
|
64
|
+
function useViewSwitch(viewCamera) {
|
|
65
|
+
const viewId = viewCamera?.id;
|
|
66
|
+
const last = useRef(viewId);
|
|
67
|
+
const takeSwitchRule = () => {
|
|
68
|
+
const switched = viewId !== last.current;
|
|
69
|
+
last.current = viewId;
|
|
70
|
+
return switched ? viewCamera?.rule : undefined;
|
|
71
|
+
};
|
|
72
|
+
return { viewId, takeSwitchRule };
|
|
73
|
+
}
|
|
54
74
|
function panelsOf(storySet) {
|
|
55
75
|
return storySet?.panels ?? [];
|
|
56
76
|
}
|
|
@@ -68,14 +88,15 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
|
|
|
68
88
|
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
69
89
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
70
90
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
71
|
-
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
91
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
92
|
+
const infoPanelId = `${useId()}-info-panel`;
|
|
72
93
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
73
94
|
const phone = usePhone();
|
|
74
95
|
/** Fixed for the page: a frame does not appear or vanish while the app runs. */
|
|
75
96
|
const [embedded] = useState(isEmbedded);
|
|
76
97
|
const root = useRef(null);
|
|
77
98
|
// The drawer (with the moons in it) and the bottom sheets want the same screen: the drawer, being the one just asked for, takes it.
|
|
78
|
-
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, () => {
|
|
99
|
+
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, root, () => {
|
|
79
100
|
if (experience.moonFamilies !== undefined) {
|
|
80
101
|
setInfo(null);
|
|
81
102
|
story.close();
|
|
@@ -116,20 +137,29 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
116
137
|
story.open(panel.id);
|
|
117
138
|
};
|
|
118
139
|
useEffect(() => {
|
|
119
|
-
onSelectionChange(selectedObjectId);
|
|
140
|
+
onSelectionChange(selectedObjectId, "visitor");
|
|
120
141
|
}, [onSelectionChange, selectedObjectId]);
|
|
142
|
+
// A view switch is told from other changes of the experience by the view's id changing.
|
|
143
|
+
const { viewId, takeSwitchRule } = useViewSwitch(viewCamera);
|
|
121
144
|
useEffect(() => {
|
|
145
|
+
const switchRule = takeSwitchRule();
|
|
122
146
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
123
147
|
if (selected === undefined || !isObjectAvailable(selected, snapshot.timeUtcMs)) {
|
|
124
148
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
125
149
|
setSelectedObjectId(fallbackId);
|
|
126
|
-
onSelectionChange(fallbackId);
|
|
150
|
+
onSelectionChange(fallbackId, "move");
|
|
151
|
+
// The card of an object the view took away closes with it.
|
|
152
|
+
if (switchRule !== undefined && selected === undefined)
|
|
153
|
+
setInfo((now) => (now?.kind === "object" ? null : now));
|
|
127
154
|
}
|
|
128
155
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
129
156
|
const activeRequest = active?.request;
|
|
130
157
|
if (activeRequest !== undefined && activeRequest.kind !== "overview") {
|
|
131
158
|
const target = experience.objects.find((object) => object.id === activeRequest.target);
|
|
132
|
-
if (
|
|
159
|
+
if (switchRule !== undefined && target === undefined) {
|
|
160
|
+
applyViewRule(switchRule);
|
|
161
|
+
}
|
|
162
|
+
else if (target === undefined || !isObjectAvailable(target, snapshot.timeUtcMs)) {
|
|
133
163
|
const overview = findCameraPreset(experience, "overview");
|
|
134
164
|
if (overview !== undefined) {
|
|
135
165
|
setActivePresetId(overview.id);
|
|
@@ -137,7 +167,24 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
137
167
|
}
|
|
138
168
|
}
|
|
139
169
|
}
|
|
140
|
-
|
|
170
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
171
|
+
}, [activePresetId, experience, onCameraRequest, onSelectionChange, selectedObjectId, snapshot.timeUtcMs, viewId]);
|
|
172
|
+
/** The view's camera rule for a followed or focused object the new view does not show: `stay` keeps the pose and stops following; otherwise the rule's framing is requested. */
|
|
173
|
+
const applyViewRule = (rule) => {
|
|
174
|
+
const asked = presetForViewRule(rule, experience);
|
|
175
|
+
const target = asked === undefined || asked.request.kind === "overview" ? undefined : availableObjectById(experience, asked.request.target, snapshot.timeUtcMs);
|
|
176
|
+
// A framing whose object is not available now falls back to the overview, like any other lost target.
|
|
177
|
+
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
178
|
+
if (target !== undefined) {
|
|
179
|
+
setSelectedObjectId(target.id);
|
|
180
|
+
onSelectionChange(target.id, "move"); // only the move-driven effect applies a view rule
|
|
181
|
+
}
|
|
182
|
+
setActivePresetId(preset?.id ?? null);
|
|
183
|
+
if (preset !== undefined)
|
|
184
|
+
onCameraRequest(preset.request);
|
|
185
|
+
else
|
|
186
|
+
onCameraHold?.();
|
|
187
|
+
};
|
|
141
188
|
const [moonsOpen, setMoonsOpen] = useState(false);
|
|
142
189
|
/** A moon chosen in the moon panel: flies to it (the same focus as the object picker) and opens its information. */
|
|
143
190
|
const chooseMoon = (id) => {
|
|
@@ -170,7 +217,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
170
217
|
if (object === undefined)
|
|
171
218
|
return;
|
|
172
219
|
setSelectedObjectId(id);
|
|
173
|
-
onSelectionChange(id);
|
|
220
|
+
onSelectionChange(id, "visitor");
|
|
174
221
|
setInfo({ kind: "object" });
|
|
175
222
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
176
223
|
if (active?.request.kind === "focus" || active?.request.kind === "follow") {
|
|
@@ -194,14 +241,14 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
194
241
|
if (target === undefined)
|
|
195
242
|
return;
|
|
196
243
|
setSelectedObjectId(target.id);
|
|
197
|
-
onSelectionChange(target.id);
|
|
244
|
+
onSelectionChange(target.id, "visitor");
|
|
198
245
|
}
|
|
199
246
|
setActivePresetId(preset.id);
|
|
200
247
|
onCameraRequest(preset.request);
|
|
201
248
|
};
|
|
202
249
|
const seekToEvent = (event) => {
|
|
203
250
|
seek(event.timeUtcMs);
|
|
204
|
-
// The event's own object, framed as the picker's Focus does (and `camera.
|
|
251
|
+
// The event's own object, framed as the picker's Focus does (and `camera.focus` opens): the event, never a default body, names it.
|
|
205
252
|
const object = event.object === undefined ? undefined : availableObjectById(experience, event.object, event.timeUtcMs);
|
|
206
253
|
if (object !== undefined)
|
|
207
254
|
activatePreset(focusPresetFor(experience, object), event.timeUtcMs);
|
|
@@ -223,7 +270,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
223
270
|
useEffect(() => { if (info !== null)
|
|
224
271
|
setMoonsOpen(false); }, [info]);
|
|
225
272
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
226
|
-
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches }));
|
|
273
|
+
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), infoPanelId: infoPanelId, scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
227
274
|
const moonPanel = experience.moonFamilies === undefined ? null : (_jsx(PanelLoadBoundary, { message: "The moon list could not load. Reload the page to try again.", children: _jsx(Suspense, { fallback: null, children: _jsx(MoonFamilyPanel, { list: experience.moonFamilies, highlightedFamily: highlightedFamily, onHighlight: (id) => onHighlightFamily?.(id), onSelectMoon: chooseMoon }) }) }));
|
|
228
|
-
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null) })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(
|
|
275
|
+
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(DeveloperDrawer, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, children: developerTools }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, paceAuto: paceAuto, onSeek: seek, panels: storyPanels, openPanelId: openPanelId, onPanelOpen: openPanelFromTimeline, onEventSeek: seekToEvent, onEventInfo: (event) => setInfo({ kind: "event", id: event.id }), onWindowSeek: seekToWindow, onWindowInfo: (window) => setInfo({ kind: "window", id: window.id }), glowLook: timelineGlow, infoPanelId: infoPanelId, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
229
276
|
}
|
|
@@ -6,10 +6,11 @@ export declare function writeStoredOpen(storage: Pick<Storage, "setItem"> | unde
|
|
|
6
6
|
/**
|
|
7
7
|
* The one folding section (STYLE-07): a heading that is a real button with `aria-expanded`, over a body that is not drawn while closed.
|
|
8
8
|
* The body is named by its heading, so it is a labelled group for assistive technology. Open or closed is remembered per viewer in
|
|
9
|
-
* browser storage under `
|
|
9
|
+
* browser storage under `fold`, and works without it. `level` is the heading level; `nested` draws a lighter fold inside another.
|
|
10
10
|
*/
|
|
11
|
-
export declare function Collapsible({
|
|
12
|
-
|
|
11
|
+
export declare function Collapsible({ fold, title, defaultOpen, level, nested, className, remember, onOpenChange, children }: {
|
|
12
|
+
/** The fold's name: its storage key and its `data-fold` hook (not a DOM id). */
|
|
13
|
+
readonly fold: string;
|
|
13
14
|
readonly title: string;
|
|
14
15
|
readonly defaultOpen?: boolean;
|
|
15
16
|
readonly level?: 3 | 4;
|
package/src/shell/Collapsible.js
CHANGED
|
@@ -29,15 +29,15 @@ function browserStorage() {
|
|
|
29
29
|
/**
|
|
30
30
|
* The one folding section (STYLE-07): a heading that is a real button with `aria-expanded`, over a body that is not drawn while closed.
|
|
31
31
|
* The body is named by its heading, so it is a labelled group for assistive technology. Open or closed is remembered per viewer in
|
|
32
|
-
* browser storage under `
|
|
32
|
+
* browser storage under `fold`, and works without it. `level` is the heading level; `nested` draws a lighter fold inside another.
|
|
33
33
|
*/
|
|
34
|
-
export function Collapsible({
|
|
34
|
+
export function Collapsible({ fold, title, defaultOpen = false, level = 3, nested = false, className = "", remember = true, onOpenChange, children }) {
|
|
35
35
|
const uid = useId();
|
|
36
|
-
const [open, setOpen] = useState(() => (remember ? readStoredOpen(browserStorage(),
|
|
36
|
+
const [open, setOpen] = useState(() => (remember ? readStoredOpen(browserStorage(), fold, defaultOpen) : defaultOpen));
|
|
37
37
|
useEffect(() => { if (remember)
|
|
38
|
-
writeStoredOpen(browserStorage(),
|
|
38
|
+
writeStoredOpen(browserStorage(), fold, open); }, [fold, open, remember]);
|
|
39
39
|
const Heading = level === 3 ? "h3" : "h4";
|
|
40
40
|
const buttonId = `${uid}-toggle`;
|
|
41
41
|
const bodyId = `${uid}-body`;
|
|
42
|
-
return (_jsxs("section", { className: `collapsible${nested ? " collapsible-nested" : ""}${className === "" ? "" : ` ${className}`}`, "data-fold":
|
|
42
|
+
return (_jsxs("section", { className: `collapsible${nested ? " collapsible-nested" : ""}${className === "" ? "" : ` ${className}`}`, "data-fold": fold, children: [_jsx(Heading, { className: "collapsible-heading", children: _jsxs("button", { type: "button", id: buttonId, className: "ui-row collapsible-toggle", "data-fold-toggle": fold, "aria-expanded": open, "aria-controls": bodyId, onClick: () => { setOpen(!open); onOpenChange?.(!open); }, children: [_jsx("span", { children: title }), _jsx("svg", { width: "14", height: "14", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M2 4l4 4 4-4" }) })] }) }), _jsx("div", { id: bodyId, className: "collapsible-body", role: "group", "aria-labelledby": buttonId, hidden: !open, children: open ? children : null })] }));
|
|
43
43
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
2
3
|
import { ChevronIcon } from "./topBarIcons.js";
|
|
3
4
|
import { useDrawerSwipe } from "./useDrawerSwipe.js";
|
|
4
5
|
/**
|
|
@@ -6,11 +7,12 @@ import { useDrawerSwipe } from "./useDrawerSwipe.js";
|
|
|
6
7
|
* under it closes it by a tap or a swipe up. The controls stay mounted while it is closed (state survives) but are hidden from sight and focus.
|
|
7
8
|
*/
|
|
8
9
|
export function ControlsDrawer({ label, open, onOpenChange, swipeThresholdPx, children }) {
|
|
10
|
+
const drawerId = `${useId()}-controls-drawer`;
|
|
9
11
|
const opening = useDrawerSwipe({ thresholdPx: swipeThresholdPx, onTap: () => onOpenChange(true), onSwipe: (direction) => { if (direction === "down")
|
|
10
12
|
onOpenChange(true); } });
|
|
11
13
|
const closing = useDrawerSwipe({ thresholdPx: swipeThresholdPx, onTap: () => onOpenChange(false), onSwipe: (direction) => { if (direction === "up")
|
|
12
14
|
onOpenChange(false); } });
|
|
13
|
-
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "controls-pill ui-pill", "aria-label": `Show controls: ${label}`, "aria-expanded": open, "aria-controls":
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "controls-pill ui-pill", "aria-label": `Show controls: ${label}`, "aria-expanded": open, "aria-controls": drawerId, ...opening, children: [_jsx("span", { className: "controls-pill-name", children: label }), _jsx(ChevronIcon, {})] }), _jsxs("div", { id: drawerId, className: "controls-drawer", role: "region", "aria-label": "Controls", "data-open": open,
|
|
14
16
|
// A dropdown closes the drawer on its change, not on the tap that opens it (owner bug, 2026-10-18: the drawer shut as the picker opened).
|
|
15
17
|
onClick: (event) => { const closer = event.target.closest("[data-closes-drawer]"); if (closer !== null && closer.tagName !== "SELECT")
|
|
16
18
|
onOpenChange(false); }, onChange: (event) => { if (event.target.closest("[data-closes-drawer]") !== null)
|
|
@@ -7,10 +7,27 @@ export interface DisplaySwitchItem {
|
|
|
7
7
|
readonly on: boolean;
|
|
8
8
|
readonly onToggle: () => void;
|
|
9
9
|
}
|
|
10
|
+
/** The views a scene names, as the bar shows them: one option each, exactly one active. Choosing never rebuilds the scene or touches the clock. */
|
|
11
|
+
export interface ViewChoice {
|
|
12
|
+
readonly place: "top-bar" | "panel";
|
|
13
|
+
readonly options: readonly {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly active: boolean;
|
|
17
|
+
}[];
|
|
18
|
+
readonly onSelect: (id: string) => void;
|
|
19
|
+
}
|
|
20
|
+
/** The view choice as a button group in the bar (and the phone drawer's grid), with the look of the experience switch's options. Fewer than two views: nothing to choose. */
|
|
21
|
+
export declare function ViewButtons({ choice }: {
|
|
22
|
+
readonly choice: ViewChoice;
|
|
23
|
+
}): import("react").JSX.Element | null;
|
|
24
|
+
/** Whether the switch panel has anything to show: a panel-placed switch or the view choice placed there. */
|
|
25
|
+
export declare function viewChoiceInPanel(choice: ViewChoice | undefined): choice is ViewChoice;
|
|
10
26
|
/**
|
|
11
27
|
* The switches a story placed. Top-bar ones are buttons in the bar (and in the phone drawer's grid); panel ones sit in one small panel opened by a "Display" button
|
|
12
28
|
* beside them. Nothing placed: nothing drawn, so the bar is exactly as it was. The panel closes on an outside press or Escape.
|
|
13
29
|
*/
|
|
14
|
-
export declare function DisplaySwitches({ switches }: {
|
|
30
|
+
export declare function DisplaySwitches({ switches, viewChoice }: {
|
|
15
31
|
readonly switches: readonly DisplaySwitchItem[];
|
|
32
|
+
readonly viewChoice?: ViewChoice;
|
|
16
33
|
}): import("react").JSX.Element | null;
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { keyIsForViewer } from "./viewerKeys.js";
|
|
3
4
|
import { ButtonText, OrbitIcon, SwitchesIcon } from "./topBarIcons.js";
|
|
5
|
+
/** The view choice as a button group in the bar (and the phone drawer's grid), with the look of the experience switch's options. Fewer than two views: nothing to choose. */
|
|
6
|
+
export function ViewButtons({ choice }) {
|
|
7
|
+
if (choice.place !== "top-bar" || choice.options.length < 2)
|
|
8
|
+
return null;
|
|
9
|
+
return (_jsx("section", { className: "switch-control view-choice", role: "group", "aria-label": "View", "data-view-choice": "", children: choice.options.map((option) => (_jsx("button", { type: "button", className: `switch-option top-bar-button ${option.active ? "ui-accent" : ""}`, "aria-pressed": option.active, "data-view-id": option.id, onClick: () => { if (!option.active)
|
|
10
|
+
choice.onSelect(option.id); }, children: _jsx("span", { children: option.label }) }, option.id))) }));
|
|
11
|
+
}
|
|
12
|
+
/** Whether the switch panel has anything to show: a panel-placed switch or the view choice placed there. */
|
|
13
|
+
export function viewChoiceInPanel(choice) {
|
|
14
|
+
return choice !== undefined && choice.place === "panel" && choice.options.length > 1;
|
|
15
|
+
}
|
|
4
16
|
/**
|
|
5
17
|
* The switches a story placed. Top-bar ones are buttons in the bar (and in the phone drawer's grid); panel ones sit in one small panel opened by a "Display" button
|
|
6
18
|
* beside them. Nothing placed: nothing drawn, so the bar is exactly as it was. The panel closes on an outside press or Escape.
|
|
7
19
|
*/
|
|
8
|
-
export function DisplaySwitches({ switches }) {
|
|
20
|
+
export function DisplaySwitches({ switches, viewChoice }) {
|
|
9
21
|
const barSwitches = switches.filter((item) => item.place === "top-bar");
|
|
10
22
|
const panelSwitches = switches.filter((item) => item.place === "panel");
|
|
11
|
-
|
|
23
|
+
const viewsInPanel = viewChoiceInPanel(viewChoice) ? viewChoice : undefined;
|
|
24
|
+
if (switches.length === 0 && viewsInPanel === undefined)
|
|
12
25
|
return null;
|
|
13
|
-
return (_jsxs("section", { className: "display-switches", role: "group", "aria-label": "Display switches", children: [barSwitches.map((item) => (_jsxs("button", { type: "button", className: "display-switch top-bar-button ui-icon", "aria-label": item.label, title: item.label, "aria-pressed": item.on, "data-display-switch": item.id, "data-closes-drawer": "", onClick: item.onToggle, children: [item.id === "orbitLines" ? _jsx(OrbitIcon, {}) : _jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: item.label })] }, item.id))), panelSwitches.length > 0 && _jsx(SwitchPanel, { switches: panelSwitches })] }));
|
|
26
|
+
return (_jsxs("section", { className: "display-switches", role: "group", "aria-label": "Display switches", children: [barSwitches.map((item) => (_jsxs("button", { type: "button", className: "display-switch top-bar-button ui-icon", "aria-label": item.label, title: item.label, "aria-pressed": item.on, "data-display-switch": item.id, "data-closes-drawer": "", onClick: item.onToggle, children: [item.id === "orbitLines" ? _jsx(OrbitIcon, {}) : _jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: item.label })] }, item.id))), (panelSwitches.length > 0 || viewsInPanel !== undefined) && _jsx(SwitchPanel, { switches: panelSwitches, viewChoice: viewsInPanel })] }));
|
|
14
27
|
}
|
|
15
|
-
function SwitchPanel({ switches }) {
|
|
28
|
+
function SwitchPanel({ switches, viewChoice }) {
|
|
16
29
|
const [open, setOpen] = useState(false);
|
|
17
30
|
const panelId = useId();
|
|
18
31
|
const root = useRef(null);
|
|
@@ -21,11 +34,12 @@ function SwitchPanel({ switches }) {
|
|
|
21
34
|
return undefined;
|
|
22
35
|
const outside = (event) => { if (!root.current?.contains(event.target))
|
|
23
36
|
setOpen(false); };
|
|
24
|
-
const escape = (event) => { if (!event.defaultPrevented && event.key === "Escape")
|
|
37
|
+
const escape = (event) => { if (!event.defaultPrevented && event.key === "Escape" && keyIsForViewer(event, root.current))
|
|
25
38
|
setOpen(false); };
|
|
26
39
|
document.addEventListener("pointerdown", outside);
|
|
27
40
|
document.addEventListener("keydown", escape);
|
|
28
41
|
return () => { document.removeEventListener("pointerdown", outside); document.removeEventListener("keydown", escape); };
|
|
29
42
|
}, [open]);
|
|
30
|
-
return (_jsxs("div", { className: "switch-panel-host", ref: root, children: [_jsxs("button", { type: "button", className: "switch-panel-toggle top-bar-button ui-icon", "aria-label": "Switch panel", title: "Switch panel", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen(!open), children: [_jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: "Display" })] }),
|
|
43
|
+
return (_jsxs("div", { className: "switch-panel-host", ref: root, children: [_jsxs("button", { type: "button", className: "switch-panel-toggle top-bar-button ui-icon", "aria-label": "Switch panel", title: "Switch panel", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen(!open), children: [_jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: "Display" })] }), _jsxs("div", { id: panelId, className: "switch-panel", role: "group", "aria-label": "Switches in the panel", hidden: !open, children: [viewChoice?.options.map((option) => (_jsx("button", { type: "button", className: "switch-panel-row ui-row", "aria-pressed": option.active, "data-view-id": option.id, onClick: () => { if (!option.active)
|
|
44
|
+
viewChoice.onSelect(option.id); }, children: option.label }, `view-${option.id}`))), switches.map((item) => (_jsx("button", { type: "button", className: "switch-panel-row ui-row", "aria-pressed": item.on, "data-display-switch": item.id, onClick: item.onToggle, children: item.label }, item.id)))] })] }));
|
|
31
45
|
}
|
package/src/shell/InfoPanel.d.ts
CHANGED
|
@@ -4,10 +4,12 @@ interface Props {
|
|
|
4
4
|
readonly view: InfoView;
|
|
5
5
|
readonly metrics: readonly Metric[];
|
|
6
6
|
readonly onClose: () => void;
|
|
7
|
+
/** The panel's id, made once per viewer by the shell so the buttons that open it can name it. */
|
|
8
|
+
readonly id: string;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* On-demand detail for one object or event; on a phone a bottom sheet with swipe to dismiss. Non-modal: the canvas and controls stay usable around it, and
|
|
10
12
|
* focus stays where the viewer is (choosing in the object picker must not jump into the panel).
|
|
11
13
|
*/
|
|
12
|
-
export declare function InfoPanel({ view, metrics, onClose }: Props): import("react").JSX.Element;
|
|
14
|
+
export declare function InfoPanel({ view, metrics, onClose, id }: Props): import("react").JSX.Element;
|
|
13
15
|
export {};
|
package/src/shell/InfoPanel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
2
|
+
import { useId, useRef } from "react";
|
|
3
3
|
import { MetricVisual } from "./MetricVisual.js";
|
|
4
4
|
import { ProvenanceBadge } from "./ProvenanceBadge.js";
|
|
5
5
|
import { useSwipeToDismiss } from "./useSwipeToDismiss.js";
|
|
@@ -7,14 +7,15 @@ import { useSwipeToDismiss } from "./useSwipeToDismiss.js";
|
|
|
7
7
|
* On-demand detail for one object or event; on a phone a bottom sheet with swipe to dismiss. Non-modal: the canvas and controls stay usable around it, and
|
|
8
8
|
* focus stays where the viewer is (choosing in the object picker must not jump into the panel).
|
|
9
9
|
*/
|
|
10
|
-
export function InfoPanel({ view, metrics, onClose }) {
|
|
10
|
+
export function InfoPanel({ view, metrics, onClose, id }) {
|
|
11
|
+
const titleId = `${useId()}-title`;
|
|
11
12
|
const targetKey = `${view.target.kind}:${view.target.id}`;
|
|
12
13
|
const sheet = useRef(null);
|
|
13
14
|
useSwipeToDismiss(sheet, onClose);
|
|
14
|
-
return (_jsxs("aside", { id:
|
|
15
|
+
return (_jsxs("aside", { id: id, className: "info-panel", ref: sheet, "aria-labelledby": titleId, "data-info-kind": view.target.kind, "data-info-id": view.target.id, onKeyDown: (event) => {
|
|
15
16
|
if (event.key !== "Escape")
|
|
16
17
|
return;
|
|
17
18
|
event.stopPropagation();
|
|
18
19
|
onClose();
|
|
19
|
-
}, children: [_jsx("div", { className: "sheet-handle", "aria-hidden": "true" }), _jsxs("header", { className: "info-panel-header", children: [_jsx("h2", { id:
|
|
20
|
+
}, children: [_jsx("div", { className: "sheet-handle", "aria-hidden": "true" }), _jsxs("header", { className: "info-panel-header", children: [_jsx("h2", { id: titleId, children: view.title }), _jsx("button", { type: "button", className: "info-panel-close ui-pill", "aria-label": "Close information", onClick: onClose, children: "Close" })] }), view.subtitle !== undefined && _jsx("p", { className: "info-panel-subtitle", children: _jsx("span", { className: "info-panel-badge", children: view.subtitle }) }), view.provenance !== null && _jsx(ProvenanceBadge, { provenance: view.provenance }, targetKey), view.description !== undefined && _jsx("p", { className: "info-panel-description", children: view.description }), view.facts !== undefined && (_jsx("dl", { className: "info-panel-facts", children: view.facts.map((fact) => _jsxs("div", { className: "info-panel-fact", children: [_jsx("dt", { children: fact.label }), _jsx("dd", { children: fact.value })] }, fact.label)) })), metrics.length > 0 && (_jsx("div", { className: "info-panel-metrics", children: metrics.map((metric) => _jsx(MetricVisual, { metric: metric }, metric.id)) }))] }));
|
|
20
21
|
}
|