@mapcairn/map 0.0.0-stage → 0.1.0-rc.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/LICENSE +661 -0
- package/README.md +167 -2
- package/dist/chrome/Attribution/Attribution.js +304 -0
- package/dist/chrome/Attribution/Attribution.js.map +1 -0
- package/dist/chrome/Attribution/Attribution.styles.js +10 -0
- package/dist/chrome/Attribution/Attribution.styles.js.map +1 -0
- package/dist/chrome/Attribution/AttributionSkeleton.js +29 -0
- package/dist/chrome/Attribution/AttributionSkeleton.js.map +1 -0
- package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js +83 -0
- package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js.map +1 -0
- package/dist/chrome/EndStack/EndStack.js +157 -0
- package/dist/chrome/EndStack/EndStack.js.map +1 -0
- package/dist/chrome/EndStack/EndStack.styles.js +12 -0
- package/dist/chrome/EndStack/EndStack.styles.js.map +1 -0
- package/dist/chrome/EndStack/EndStackSkeleton.js +78 -0
- package/dist/chrome/EndStack/EndStackSkeleton.js.map +1 -0
- package/dist/chrome/EndStack/endStackHeight.js +22 -0
- package/dist/chrome/EndStack/endStackHeight.js.map +1 -0
- package/dist/chrome/MapChrome/MapChrome.js +488 -0
- package/dist/chrome/MapChrome/MapChrome.js.map +1 -0
- package/dist/chrome/MapChrome/MapChrome.styles.js +15 -0
- package/dist/chrome/MapChrome/MapChrome.styles.js.map +1 -0
- package/dist/chrome/MapChrome/chromeSurface.js +18 -0
- package/dist/chrome/MapChrome/chromeSurface.js.map +1 -0
- package/dist/chrome/MapChrome/chromeVars.js +71 -0
- package/dist/chrome/MapChrome/chromeVars.js.map +1 -0
- package/dist/chrome/MapChrome/mapKeyPlacement.js +41 -0
- package/dist/chrome/MapChrome/mapKeyPlacement.js.map +1 -0
- package/dist/chrome/MapChrome/sharesWidth.js +13 -0
- package/dist/chrome/MapChrome/sharesWidth.js.map +1 -0
- package/dist/chrome/MapReadout/MapReadout.js +199 -0
- package/dist/chrome/MapReadout/MapReadout.js.map +1 -0
- package/dist/chrome/MapReadout/MapReadout.styles.js +14 -0
- package/dist/chrome/MapReadout/MapReadout.styles.js.map +1 -0
- package/dist/chrome/Sheet/Sheet.js +412 -0
- package/dist/chrome/Sheet/Sheet.js.map +1 -0
- package/dist/chrome/Sheet/Sheet.styles.js +14 -0
- package/dist/chrome/Sheet/Sheet.styles.js.map +1 -0
- package/dist/chrome/focusRegistry.js +76 -0
- package/dist/chrome/focusRegistry.js.map +1 -0
- package/dist/chrome/layoutContext.js +30 -0
- package/dist/chrome/layoutContext.js.map +1 -0
- package/dist/chrome/useScrollEdges.js +53 -0
- package/dist/chrome/useScrollEdges.js.map +1 -0
- package/dist/host/MapContext.js +16 -0
- package/dist/host/MapContext.js.map +1 -0
- package/dist/host/MapView.js +189 -0
- package/dist/host/MapView.js.map +1 -0
- package/dist/host/MapView.styles.js +16 -0
- package/dist/host/MapView.styles.js.map +1 -0
- package/dist/host/overlays/AccuracyCircle.js +36 -0
- package/dist/host/overlays/AccuracyCircle.js.map +1 -0
- package/dist/host/overlays/CentreCrosshair.js +40 -0
- package/dist/host/overlays/CentreCrosshair.js.map +1 -0
- package/dist/host/overlays/DrawOverlay.js +221 -0
- package/dist/host/overlays/DrawOverlay.js.map +1 -0
- package/dist/host/overlays/MapOverlayLayer.js +27 -0
- package/dist/host/overlays/MapOverlayLayer.js.map +1 -0
- package/dist/host/overlays/MeasureOverlay.js +87 -0
- package/dist/host/overlays/MeasureOverlay.js.map +1 -0
- package/dist/host/overlays/PinMarker.js +40 -0
- package/dist/host/overlays/PinMarker.js.map +1 -0
- package/dist/host/overlays/geometry.js +41 -0
- package/dist/host/overlays/geometry.js.map +1 -0
- package/dist/host/overlays/overlays.styles.js +27 -0
- package/dist/host/overlays/overlays.styles.js.map +1 -0
- package/dist/host/pointerTargets.js +22 -0
- package/dist/host/pointerTargets.js.map +1 -0
- package/dist/host/useLongPress.js +102 -0
- package/dist/host/useLongPress.js.map +1 -0
- package/dist/host/useMapEngine.js +352 -0
- package/dist/host/useMapEngine.js.map +1 -0
- package/dist/host/usePointerPosition.js +60 -0
- package/dist/host/usePointerPosition.js.map +1 -0
- package/dist/index.d.ts +3845 -0
- package/dist/index.js +89 -0
- package/dist/layers/CatalogueStatus.js +138 -0
- package/dist/layers/CatalogueStatus.js.map +1 -0
- package/dist/layers/DateTimeControl.js +101 -0
- package/dist/layers/DateTimeControl.js.map +1 -0
- package/dist/layers/FeatureCard.js +147 -0
- package/dist/layers/FeatureCard.js.map +1 -0
- package/dist/layers/FeatureChoices.js +101 -0
- package/dist/layers/FeatureChoices.js.map +1 -0
- package/dist/layers/FeatureGlyph.js +56 -0
- package/dist/layers/FeatureGlyph.js.map +1 -0
- package/dist/layers/IdentifyStatus.js +36 -0
- package/dist/layers/IdentifyStatus.js.map +1 -0
- package/dist/layers/LayerItem.js +321 -0
- package/dist/layers/LayerItem.js.map +1 -0
- package/dist/layers/LayerKey.js +36 -0
- package/dist/layers/LayerKey.js.map +1 -0
- package/dist/layers/Layers.styles.js +50 -0
- package/dist/layers/Layers.styles.js.map +1 -0
- package/dist/layers/LayersSection.js +267 -0
- package/dist/layers/LayersSection.js.map +1 -0
- package/dist/layers/MapDataLayers.js +261 -0
- package/dist/layers/MapDataLayers.js.map +1 -0
- package/dist/layers/MapKey.js +131 -0
- package/dist/layers/MapKey.js.map +1 -0
- package/dist/layers/MapKey.styles.js +16 -0
- package/dist/layers/MapKey.styles.js.map +1 -0
- package/dist/layers/MarkerGlyph.js +84 -0
- package/dist/layers/MarkerGlyph.js.map +1 -0
- package/dist/layers/SelectionProvider.js +27 -0
- package/dist/layers/SelectionProvider.js.map +1 -0
- package/dist/layers/ShapeGlyph.js +122 -0
- package/dist/layers/ShapeGlyph.js.map +1 -0
- package/dist/layers/TurnOffActions.js +147 -0
- package/dist/layers/TurnOffActions.js.map +1 -0
- package/dist/layers/answersTap.js +16 -0
- package/dist/layers/answersTap.js.map +1 -0
- package/dist/layers/catalogueNotice.js +65 -0
- package/dist/layers/catalogueNotice.js.map +1 -0
- package/dist/layers/catalogueReconcile.js +55 -0
- package/dist/layers/catalogueReconcile.js.map +1 -0
- package/dist/layers/catalogueView.js +32 -0
- package/dist/layers/catalogueView.js.map +1 -0
- package/dist/layers/featureTitle.js +14 -0
- package/dist/layers/featureTitle.js.map +1 -0
- package/dist/layers/identifyFeedback.js +30 -0
- package/dist/layers/identifyFeedback.js.map +1 -0
- package/dist/layers/identifyRun.js +148 -0
- package/dist/layers/identifyRun.js.map +1 -0
- package/dist/layers/layerStatus.js +13 -0
- package/dist/layers/layerStatus.js.map +1 -0
- package/dist/layers/loadOutcome.js +107 -0
- package/dist/layers/loadOutcome.js.map +1 -0
- package/dist/layers/loadReport.js +33 -0
- package/dist/layers/loadReport.js.map +1 -0
- package/dist/layers/loadRequests.js +73 -0
- package/dist/layers/loadRequests.js.map +1 -0
- package/dist/layers/mapFeatures.js +307 -0
- package/dist/layers/mapFeatures.js.map +1 -0
- package/dist/layers/mapKeyBlocks.js +24 -0
- package/dist/layers/mapKeyBlocks.js.map +1 -0
- package/dist/layers/reveal.js +119 -0
- package/dist/layers/reveal.js.map +1 -0
- package/dist/layers/selectionMessages.js +53 -0
- package/dist/layers/selectionMessages.js.map +1 -0
- package/dist/layers/selectionResolve.js +111 -0
- package/dist/layers/selectionResolve.js.map +1 -0
- package/dist/layers/useDataLayers.js +940 -0
- package/dist/layers/useDataLayers.js.map +1 -0
- package/dist/layers/useFeatureSelection.js +179 -0
- package/dist/layers/useFeatureSelection.js.map +1 -0
- package/dist/layers/useScrolls.js +37 -0
- package/dist/layers/useScrolls.js.map +1 -0
- package/dist/panels/BasemapPicker/BasemapPicker.js +169 -0
- package/dist/panels/BasemapPicker/BasemapPicker.js.map +1 -0
- package/dist/panels/BasemapPicker/BasemapPicker.styles.js +42 -0
- package/dist/panels/BasemapPicker/BasemapPicker.styles.js.map +1 -0
- package/dist/panels/ExportSection/ExportSection.js +91 -0
- package/dist/panels/ExportSection/ExportSection.js.map +1 -0
- package/dist/panels/HelpSection/HelpSection.js +163 -0
- package/dist/panels/HelpSection/HelpSection.js.map +1 -0
- package/dist/panels/HelpSection/HelpSection.styles.js +9 -0
- package/dist/panels/HelpSection/HelpSection.styles.js.map +1 -0
- package/dist/panels/PinSection/PinSection.js +39 -0
- package/dist/panels/PinSection/PinSection.js.map +1 -0
- package/dist/panels/Section/Section.js +43 -0
- package/dist/panels/Section/Section.js.map +1 -0
- package/dist/panels/Section/Section.styles.js +13 -0
- package/dist/panels/Section/Section.styles.js.map +1 -0
- package/dist/panels/SettingsSection/LanguageField.js +126 -0
- package/dist/panels/SettingsSection/LanguageField.js.map +1 -0
- package/dist/panels/SettingsSection/SettingsSection.js +175 -0
- package/dist/panels/SettingsSection/SettingsSection.js.map +1 -0
- package/dist/panels/SettingsSection/SettingsSection.styles.js +9 -0
- package/dist/panels/SettingsSection/SettingsSection.styles.js.map +1 -0
- package/dist/panels/ShapesSection/ShapesSection.js +229 -0
- package/dist/panels/ShapesSection/ShapesSection.js.map +1 -0
- package/dist/panels/ShapesSection/ShapesSection.styles.js +7 -0
- package/dist/panels/ShapesSection/ShapesSection.styles.js.map +1 -0
- package/dist/panels/SheetContent/SheetContent.js +92 -0
- package/dist/panels/SheetContent/SheetContent.js.map +1 -0
- package/dist/panels/SheetContent/SheetContent.styles.js +6 -0
- package/dist/panels/SheetContent/SheetContent.styles.js.map +1 -0
- package/dist/services/ServicesProvider.js +42 -0
- package/dist/services/ServicesProvider.js.map +1 -0
- package/dist/services/activeMessages.js +140 -0
- package/dist/services/activeMessages.js.map +1 -0
- package/dist/services/basemapAvailability.js +78 -0
- package/dist/services/basemapAvailability.js.map +1 -0
- package/dist/services/englishMessages.js +10 -0
- package/dist/services/englishMessages.js.map +1 -0
- package/dist/services/hooks.js +214 -0
- package/dist/services/hooks.js.map +1 -0
- package/dist/styles.css +2866 -0
- package/dist/styles.css.d.ts +1 -0
- package/dist/tools/Directions/Directions.styles.js +25 -0
- package/dist/tools/Directions/Directions.styles.js.map +1 -0
- package/dist/tools/Directions/DirectionsOverlay.js +46 -0
- package/dist/tools/Directions/DirectionsOverlay.js.map +1 -0
- package/dist/tools/Directions/DirectionsPanel.js +428 -0
- package/dist/tools/Directions/DirectionsPanel.js.map +1 -0
- package/dist/tools/Directions/MapDirections.js +84 -0
- package/dist/tools/Directions/MapDirections.js.map +1 -0
- package/dist/tools/Directions/useDirections.js +226 -0
- package/dist/tools/Directions/useDirections.js.map +1 -0
- package/dist/tools/Directions/useFreeCentre.js +30 -0
- package/dist/tools/Directions/useFreeCentre.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawMapBindings.js +34 -0
- package/dist/tools/DrawToolbar/DrawMapBindings.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawToolbar.js +296 -0
- package/dist/tools/DrawToolbar/DrawToolbar.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawToolbar.styles.js +21 -0
- package/dist/tools/DrawToolbar/DrawToolbar.styles.js.map +1 -0
- package/dist/tools/DrawToolbar/imageDrawing.js +24 -0
- package/dist/tools/DrawToolbar/imageDrawing.js.map +1 -0
- package/dist/tools/DrawToolbar/useDraw.js +543 -0
- package/dist/tools/DrawToolbar/useDraw.js.map +1 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.js +116 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.js.map +1 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js +12 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js.map +1 -0
- package/dist/tools/MeasureToolbar/useMeasure.js +75 -0
- package/dist/tools/MeasureToolbar/useMeasure.js.map +1 -0
- package/dist/tools/PinCard/PinCard.js +174 -0
- package/dist/tools/PinCard/PinCard.js.map +1 -0
- package/dist/tools/PinCard/PinCard.styles.js +16 -0
- package/dist/tools/PinCard/PinCard.styles.js.map +1 -0
- package/dist/tools/PinCard/useReverseAddress.js +77 -0
- package/dist/tools/PinCard/useReverseAddress.js.map +1 -0
- package/dist/tools/SearchPill/SearchPill.js +292 -0
- package/dist/tools/SearchPill/SearchPill.js.map +1 -0
- package/dist/tools/SearchPill/SearchPill.styles.js +16 -0
- package/dist/tools/SearchPill/SearchPill.styles.js.map +1 -0
- package/dist/tools/SearchPill/SearchPillSkeleton.js +41 -0
- package/dist/tools/SearchPill/SearchPillSkeleton.js.map +1 -0
- package/dist/tools/SearchPill/useSearch.js +143 -0
- package/dist/tools/SearchPill/useSearch.js.map +1 -0
- package/dist/tools/SearchPill/useSuggestions.js +105 -0
- package/dist/tools/SearchPill/useSuggestions.js.map +1 -0
- package/dist/tools/Tour/TourCard.js +156 -0
- package/dist/tools/Tour/TourCard.js.map +1 -0
- package/dist/tools/Tour/TourCard.styles.js +10 -0
- package/dist/tools/Tour/TourCard.styles.js.map +1 -0
- package/dist/tools/Tour/useTour.js +110 -0
- package/dist/tools/Tour/useTour.js.map +1 -0
- package/dist/tools/locate/useLocate.js +94 -0
- package/dist/tools/locate/useLocate.js.map +1 -0
- package/dist/ui/Button/Button.js +36 -0
- package/dist/ui/Button/Button.js.map +1 -0
- package/dist/ui/Button/Button.styles.js +17 -0
- package/dist/ui/Button/Button.styles.js.map +1 -0
- package/dist/ui/Chip/Chip.js +37 -0
- package/dist/ui/Chip/Chip.js.map +1 -0
- package/dist/ui/Chip/Chip.styles.js +29 -0
- package/dist/ui/Chip/Chip.styles.js.map +1 -0
- package/dist/ui/ControlGroup/ControlGroup.js +23 -0
- package/dist/ui/ControlGroup/ControlGroup.js.map +1 -0
- package/dist/ui/ControlGroup/ControlGroup.styles.js +6 -0
- package/dist/ui/ControlGroup/ControlGroup.styles.js.map +1 -0
- package/dist/ui/EmptyState/EmptyState.js +37 -0
- package/dist/ui/EmptyState/EmptyState.js.map +1 -0
- package/dist/ui/EmptyState/EmptyState.styles.js +10 -0
- package/dist/ui/EmptyState/EmptyState.styles.js.map +1 -0
- package/dist/ui/Icon/Icon.js +28 -0
- package/dist/ui/Icon/Icon.js.map +1 -0
- package/dist/ui/Icon/Icon.styles.js +8 -0
- package/dist/ui/Icon/Icon.styles.js.map +1 -0
- package/dist/ui/IconButton/IconButton.js +47 -0
- package/dist/ui/IconButton/IconButton.js.map +1 -0
- package/dist/ui/IconButton/IconButton.styles.js +27 -0
- package/dist/ui/IconButton/IconButton.styles.js.map +1 -0
- package/dist/ui/Isolate/Isolate.js +26 -0
- package/dist/ui/Isolate/Isolate.js.map +1 -0
- package/dist/ui/Isolate/fillSlots.js +27 -0
- package/dist/ui/Isolate/fillSlots.js.map +1 -0
- package/dist/ui/ListRow/ListRow.js +59 -0
- package/dist/ui/ListRow/ListRow.js.map +1 -0
- package/dist/ui/ListRow/ListRow.styles.js +30 -0
- package/dist/ui/ListRow/ListRow.styles.js.map +1 -0
- package/dist/ui/LiveRegion/LiveRegion.js +88 -0
- package/dist/ui/LiveRegion/LiveRegion.js.map +1 -0
- package/dist/ui/LiveRegion/announcer.js +114 -0
- package/dist/ui/LiveRegion/announcer.js.map +1 -0
- package/dist/ui/SegmentedControl/SegmentedControl.js +55 -0
- package/dist/ui/SegmentedControl/SegmentedControl.js.map +1 -0
- package/dist/ui/SegmentedControl/SegmentedControl.styles.js +9 -0
- package/dist/ui/SegmentedControl/SegmentedControl.styles.js.map +1 -0
- package/dist/ui/SkipLink/SkipLink.js +35 -0
- package/dist/ui/SkipLink/SkipLink.js.map +1 -0
- package/dist/ui/SkipLink/SkipLink.styles.js +6 -0
- package/dist/ui/SkipLink/SkipLink.styles.js.map +1 -0
- package/dist/ui/Slider/Slider.js +68 -0
- package/dist/ui/Slider/Slider.js.map +1 -0
- package/dist/ui/Slider/Slider.styles.js +13 -0
- package/dist/ui/Slider/Slider.styles.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessage.js +124 -0
- package/dist/ui/StatusMessage/StatusMessage.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessage.styles.js +28 -0
- package/dist/ui/StatusMessage/StatusMessage.styles.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessageFocus.js +30 -0
- package/dist/ui/StatusMessage/StatusMessageFocus.js.map +1 -0
- package/dist/ui/Surface/Surface.js +22 -0
- package/dist/ui/Surface/Surface.js.map +1 -0
- package/dist/ui/Surface/Surface.styles.js +27 -0
- package/dist/ui/Surface/Surface.styles.js.map +1 -0
- package/dist/ui/Switch/Switch.js +58 -0
- package/dist/ui/Switch/Switch.js.map +1 -0
- package/dist/ui/Switch/Switch.styles.js +13 -0
- package/dist/ui/Switch/Switch.styles.js.map +1 -0
- package/dist/ui/Tooltip/Tooltip.js +66 -0
- package/dist/ui/Tooltip/Tooltip.js.map +1 -0
- package/dist/ui/Tooltip/Tooltip.styles.js +6 -0
- package/dist/ui/Tooltip/Tooltip.styles.js.map +1 -0
- package/dist/ui/Tooltip/inheritColours.js +27 -0
- package/dist/ui/Tooltip/inheritColours.js.map +1 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.js +16 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js +6 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { useMessages } from "../../services/hooks.js";
|
|
2
|
+
import { IconButton } from "../../ui/IconButton/IconButton.js";
|
|
3
|
+
import { useAnnounce } from "../../ui/LiveRegion/LiveRegion.js";
|
|
4
|
+
import { useChromeLayout } from "../layoutContext.js";
|
|
5
|
+
import { useChromeSurface } from "../MapChrome/chromeSurface.js";
|
|
6
|
+
import { brand, close, content, grabber, handle, header, sentinel, surface, title } from "./Sheet.styles.js";
|
|
7
|
+
import { announceDetent, clampHeight, computeDetentHeights, cycleDetent, inlineDistanceToFarEdge, nextDetent, resolveSnap } from "@mapcairn/core";
|
|
8
|
+
import { X } from "lucide-react";
|
|
9
|
+
import { useEffect, useId, useLayoutEffect, useMemo, useRef } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useLatestRef } from "@mapcairn/react";
|
|
12
|
+
// src/chrome/Sheet/Sheet.tsx
|
|
13
|
+
/** How far, in px, a press may move before it counts as a drag rather than a tap. */
|
|
14
|
+
var DRAG_SLOP_PX = 4;
|
|
15
|
+
/** The window, in ms, over which release velocity is measured. */
|
|
16
|
+
var VELOCITY_WINDOW_MS = 100;
|
|
17
|
+
/**
|
|
18
|
+
* Everything that can take keyboard focus inside the sheet, in tab order,
|
|
19
|
+
* apart from the focus sentinels.
|
|
20
|
+
*/
|
|
21
|
+
var TABBABLE = [
|
|
22
|
+
"a[href]",
|
|
23
|
+
"button:not([disabled])",
|
|
24
|
+
"input:not([disabled])",
|
|
25
|
+
"select:not([disabled])",
|
|
26
|
+
"textarea:not([disabled])",
|
|
27
|
+
"[tabindex]:not([tabindex=\"-1\"]):not([data-focus-sentinel])"
|
|
28
|
+
].join(", ");
|
|
29
|
+
/** The way an arrow key moves the sheet from its handle, or null for any other key. */
|
|
30
|
+
function handleDirection(key) {
|
|
31
|
+
if (key === "ArrowUp") return "up";
|
|
32
|
+
return key === "ArrowDown" ? "down" : null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Velocity in px/s from the oldest sample in the last
|
|
36
|
+
* {@link VELOCITY_WINDOW_MS} to the release; positive when expanding. A
|
|
37
|
+
* pointer held still for longer than the window releases at zero.
|
|
38
|
+
*/
|
|
39
|
+
function releaseVelocity(samples, release) {
|
|
40
|
+
const first = samples.reduce((oldest, sample) => release.time - sample.time <= VELOCITY_WINDOW_MS && sample.time < oldest.time ? sample : oldest, release);
|
|
41
|
+
const elapsed = release.time - first.time;
|
|
42
|
+
return elapsed > 0 ? (first.y - release.y) / elapsed * 1e3 : 0;
|
|
43
|
+
}
|
|
44
|
+
/** The controls in the sheet that Tab can reach, in order. */
|
|
45
|
+
function tabbableIn(container) {
|
|
46
|
+
return [...container.querySelectorAll(TABBABLE)];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Moves Tab and Shift+Tab around the ends of the sheet, so focus cannot
|
|
50
|
+
* leave it. Returns true when it moved focus.
|
|
51
|
+
*/
|
|
52
|
+
function loopFocus(container, backwards) {
|
|
53
|
+
const tabbable = tabbableIn(container);
|
|
54
|
+
const first = tabbable[0];
|
|
55
|
+
const last = tabbable[tabbable.length - 1];
|
|
56
|
+
if (!first || !last) return false;
|
|
57
|
+
const index = tabbable.indexOf(container.ownerDocument.activeElement);
|
|
58
|
+
if (backwards && index <= 0) {
|
|
59
|
+
last.focus();
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (!backwards && (index === -1 || index === tabbable.length - 1)) {
|
|
63
|
+
first.focus();
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Focuses the first or last control in the sheet. A focus sentinel calls it
|
|
70
|
+
* when it receives focus.
|
|
71
|
+
*/
|
|
72
|
+
function focusEnd(container, end) {
|
|
73
|
+
if (!container) return;
|
|
74
|
+
const tabbable = tabbableIn(container);
|
|
75
|
+
(end === "first" ? tabbable[0] : tabbable[tabbable.length - 1])?.focus();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* An empty element at one end of the modal sheet that is in the Tab order
|
|
79
|
+
* only to catch focus about to leave the sheet. It never keeps focus: the
|
|
80
|
+
* start sentinel hands it to the last control and the end sentinel to the
|
|
81
|
+
* first. It is a `span` because Safari's default Tab skips buttons.
|
|
82
|
+
*/
|
|
83
|
+
function FocusSentinel({ at, sheetRef }) {
|
|
84
|
+
return /* @__PURE__ */ jsx("span", {
|
|
85
|
+
tabIndex: 0,
|
|
86
|
+
"data-focus-sentinel": at,
|
|
87
|
+
className: sentinel,
|
|
88
|
+
onFocus: () => focusEnd(sheetRef.current, at === "start" ? "last" : "first")
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The map options surface: a bottom sheet with peek, half and full detents on
|
|
93
|
+
* narrow screens, and a floating side panel in the panel layout. Rendered by
|
|
94
|
+
* the app into `MapChrome`'s `sheet` slot, outside the inert wrapper.
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* Sheet layout: a `dialog` labelled by its heading. It is non-modal at peek
|
|
98
|
+
* and half, so the map stays usable. At full it sets `aria-modal`, reports
|
|
99
|
+
* `onModalChange(true)` (the app makes the rest of the chrome inert) and
|
|
100
|
+
* loops Tab inside itself. Safari's default Tab skips links and buttons, so
|
|
101
|
+
* the keydown loop cannot see focus reach the last control there; at full
|
|
102
|
+
* the sheet also has an empty focus sentinel at each end, and the browser's
|
|
103
|
+
* own Tab landing on one sends focus round to the other end. The handle is a "Resize panel" button: Enter or
|
|
104
|
+
* Space cycles detents, the arrow keys step them, and the handle and header
|
|
105
|
+
* can be dragged, with rubber-banding past the ends and a velocity-aware
|
|
106
|
+
* snap on release. Detent changes are announced. The top edge and detent are
|
|
107
|
+
* published for the bottom slots, once per animation frame while dragging.
|
|
108
|
+
*
|
|
109
|
+
* Panel layout: a `complementary` region labelled by its heading, never
|
|
110
|
+
* modal, with no handle. It publishes its right edge so bottom-start can move
|
|
111
|
+
* clear of it.
|
|
112
|
+
*
|
|
113
|
+
* Both: focus moves to the heading on open; Escape and Close call `onClose`;
|
|
114
|
+
* `restoreFocus` runs after closing. One element serves both layouts (its
|
|
115
|
+
* role and `data-layout` change) so content stays mounted across a rotation.
|
|
116
|
+
* The detent heights take no bottom safe-area inset; the content pads for it.
|
|
117
|
+
*/
|
|
118
|
+
function Sheet({ id, open, title: title$1, onClose, detent, onDetentChange, onModalChange, restoreFocus, testId, brand: brand$1, children }) {
|
|
119
|
+
const { layout, viewport, publishSheetTop } = useChromeLayout();
|
|
120
|
+
const { publishSheetDetent, publishPanelEdge } = useChromeSurface();
|
|
121
|
+
const announce = useAnnounce();
|
|
122
|
+
const { t } = useMessages();
|
|
123
|
+
const titleId = useId();
|
|
124
|
+
const sheetRef = useRef(null);
|
|
125
|
+
const titleRef = useRef(null);
|
|
126
|
+
const handleRef = useRef(null);
|
|
127
|
+
const dragRef = useRef(null);
|
|
128
|
+
const frameRef = useRef(null);
|
|
129
|
+
const suppressClickRef = useRef(false);
|
|
130
|
+
const isSheet = layout === "sheet";
|
|
131
|
+
const modal = open && isSheet && detent === "full";
|
|
132
|
+
const heights = useMemo(() => computeDetentHeights({
|
|
133
|
+
viewportHeight: viewport.height,
|
|
134
|
+
insetBottom: 0
|
|
135
|
+
}), [viewport.height]);
|
|
136
|
+
const latest = useLatestRef({
|
|
137
|
+
onModalChange,
|
|
138
|
+
restoreFocus,
|
|
139
|
+
publishSheetTop
|
|
140
|
+
});
|
|
141
|
+
/** Places the sheet so `height` px of it shows. Transform only. */
|
|
142
|
+
const applyHeight = (height) => {
|
|
143
|
+
sheetRef.current?.style.setProperty("--sheet-offset", `${heights.full - height}px`);
|
|
144
|
+
};
|
|
145
|
+
useLayoutEffect(() => {
|
|
146
|
+
const sheet = sheetRef.current;
|
|
147
|
+
if (!sheet || !isSheet) return;
|
|
148
|
+
sheet.style.setProperty("--sheet-full-height", `${heights.full}px`);
|
|
149
|
+
sheet.style.setProperty("--sheet-offset", `${heights.full - heights[detent]}px`);
|
|
150
|
+
}, [
|
|
151
|
+
isSheet,
|
|
152
|
+
heights,
|
|
153
|
+
detent
|
|
154
|
+
]);
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (open && isSheet) {
|
|
157
|
+
publishSheetTop(viewport.height - heights[detent]);
|
|
158
|
+
publishSheetDetent(detent);
|
|
159
|
+
} else {
|
|
160
|
+
publishSheetTop(null);
|
|
161
|
+
publishSheetDetent(null);
|
|
162
|
+
}
|
|
163
|
+
}, [
|
|
164
|
+
open,
|
|
165
|
+
isSheet,
|
|
166
|
+
detent,
|
|
167
|
+
heights,
|
|
168
|
+
viewport.height,
|
|
169
|
+
publishSheetTop,
|
|
170
|
+
publishSheetDetent
|
|
171
|
+
]);
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
const panel = sheetRef.current;
|
|
174
|
+
if (!panel || !open || isSheet) {
|
|
175
|
+
publishPanelEdge(null);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const publish = () => {
|
|
179
|
+
publishPanelEdge(inlineDistanceToFarEdge({
|
|
180
|
+
offsetLeft: panel.offsetLeft,
|
|
181
|
+
offsetWidth: panel.offsetWidth,
|
|
182
|
+
containerWidth: panel.offsetParent?.clientWidth ?? 0,
|
|
183
|
+
direction: getComputedStyle(panel).direction === "rtl" ? "rtl" : "ltr"
|
|
184
|
+
}));
|
|
185
|
+
};
|
|
186
|
+
publish();
|
|
187
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(publish);
|
|
188
|
+
observer?.observe(panel);
|
|
189
|
+
return () => {
|
|
190
|
+
observer?.disconnect();
|
|
191
|
+
};
|
|
192
|
+
}, [
|
|
193
|
+
open,
|
|
194
|
+
isSheet,
|
|
195
|
+
publishPanelEdge
|
|
196
|
+
]);
|
|
197
|
+
useEffect(() => () => {
|
|
198
|
+
latest.current.publishSheetTop(null);
|
|
199
|
+
publishSheetDetent(null);
|
|
200
|
+
publishPanelEdge(null);
|
|
201
|
+
if (frameRef.current !== null) cancelAnimationFrame(frameRef.current);
|
|
202
|
+
}, [
|
|
203
|
+
latest,
|
|
204
|
+
publishSheetDetent,
|
|
205
|
+
publishPanelEdge
|
|
206
|
+
]);
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
latest.current.onModalChange?.(modal);
|
|
209
|
+
}, [latest, modal]);
|
|
210
|
+
const wasOpen = useRef(open);
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
if (open && !wasOpen.current) titleRef.current?.focus();
|
|
213
|
+
if (!open && wasOpen.current) latest.current.restoreFocus?.();
|
|
214
|
+
wasOpen.current = open;
|
|
215
|
+
}, [latest, open]);
|
|
216
|
+
useEffect(() => {
|
|
217
|
+
if (wasOpen.current) titleRef.current?.focus();
|
|
218
|
+
}, []);
|
|
219
|
+
const announcedDetent = useRef(null);
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
if (!open || !isSheet) {
|
|
222
|
+
announcedDetent.current = null;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (announcedDetent.current !== null && announcedDetent.current !== detent) announce(announceDetent(detent));
|
|
226
|
+
announcedDetent.current = detent;
|
|
227
|
+
}, [
|
|
228
|
+
open,
|
|
229
|
+
isSheet,
|
|
230
|
+
detent,
|
|
231
|
+
announce
|
|
232
|
+
]);
|
|
233
|
+
const schedulePublish = () => {
|
|
234
|
+
if (frameRef.current !== null) return;
|
|
235
|
+
frameRef.current = requestAnimationFrame(() => {
|
|
236
|
+
frameRef.current = null;
|
|
237
|
+
const drag = dragRef.current;
|
|
238
|
+
if (drag) latest.current.publishSheetTop(viewport.height - drag.height);
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
const endDrag = (drag) => {
|
|
242
|
+
dragRef.current = null;
|
|
243
|
+
sheetRef.current?.removeAttribute("data-dragging");
|
|
244
|
+
if (drag.capture.hasPointerCapture?.(drag.pointerId)) drag.capture.releasePointerCapture(drag.pointerId);
|
|
245
|
+
};
|
|
246
|
+
const onPointerDown = (event) => {
|
|
247
|
+
const target = event.target;
|
|
248
|
+
const fromHandle = handleRef.current?.contains(target) === true;
|
|
249
|
+
const onOtherButton = target.closest("button") !== null && !fromHandle;
|
|
250
|
+
if (!isSheet || !open || dragRef.current !== null || onOtherButton || event.pointerType === "mouse" && event.button !== 0) return;
|
|
251
|
+
target.setPointerCapture(event.pointerId);
|
|
252
|
+
dragRef.current = {
|
|
253
|
+
pointerId: event.pointerId,
|
|
254
|
+
capture: target,
|
|
255
|
+
fromHandle,
|
|
256
|
+
startY: event.clientY,
|
|
257
|
+
startHeight: heights[detent],
|
|
258
|
+
height: heights[detent],
|
|
259
|
+
moved: false,
|
|
260
|
+
samples: [{
|
|
261
|
+
time: performance.now(),
|
|
262
|
+
y: event.clientY
|
|
263
|
+
}]
|
|
264
|
+
};
|
|
265
|
+
suppressClickRef.current = false;
|
|
266
|
+
sheetRef.current?.setAttribute("data-dragging", "true");
|
|
267
|
+
};
|
|
268
|
+
const onPointerMove = (event) => {
|
|
269
|
+
const drag = dragRef.current;
|
|
270
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
271
|
+
const time = performance.now();
|
|
272
|
+
const delta = drag.startY - event.clientY;
|
|
273
|
+
drag.moved ||= Math.abs(delta) > DRAG_SLOP_PX;
|
|
274
|
+
drag.height = clampHeight(drag.startHeight + delta, heights);
|
|
275
|
+
drag.samples = [...drag.samples.filter((sample) => time - sample.time <= 200), {
|
|
276
|
+
time,
|
|
277
|
+
y: event.clientY
|
|
278
|
+
}];
|
|
279
|
+
applyHeight(drag.height);
|
|
280
|
+
schedulePublish();
|
|
281
|
+
};
|
|
282
|
+
const onPointerUp = (event) => {
|
|
283
|
+
const drag = dragRef.current;
|
|
284
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
285
|
+
endDrag(drag);
|
|
286
|
+
if (!drag.moved) {
|
|
287
|
+
applyHeight(heights[detent]);
|
|
288
|
+
publishSheetTop(viewport.height - heights[detent]);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
suppressClickRef.current = drag.fromHandle;
|
|
292
|
+
const snapped = resolveSnap({
|
|
293
|
+
heights,
|
|
294
|
+
currentHeight: drag.height,
|
|
295
|
+
velocityPxPerSecond: releaseVelocity(drag.samples, {
|
|
296
|
+
time: performance.now(),
|
|
297
|
+
y: event.clientY
|
|
298
|
+
})
|
|
299
|
+
});
|
|
300
|
+
applyHeight(heights[snapped]);
|
|
301
|
+
publishSheetTop(viewport.height - heights[snapped]);
|
|
302
|
+
if (snapped !== detent) onDetentChange(snapped);
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Abandons a live drag and settles back on the current detent. Used for
|
|
306
|
+
* `pointercancel` and for `lostpointercapture`, which also follows every
|
|
307
|
+
* normal release (by then there is no live drag, so it does nothing).
|
|
308
|
+
*/
|
|
309
|
+
const onPointerCancel = (event) => {
|
|
310
|
+
const drag = dragRef.current;
|
|
311
|
+
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
312
|
+
endDrag(drag);
|
|
313
|
+
applyHeight(heights[detent]);
|
|
314
|
+
publishSheetTop(viewport.height - heights[detent]);
|
|
315
|
+
};
|
|
316
|
+
const onHandleClick = (event) => {
|
|
317
|
+
const suppress = suppressClickRef.current;
|
|
318
|
+
suppressClickRef.current = false;
|
|
319
|
+
if (suppress && event.detail !== 0) return;
|
|
320
|
+
onDetentChange(cycleDetent(detent));
|
|
321
|
+
};
|
|
322
|
+
const onHandleKeyDown = (event) => {
|
|
323
|
+
const direction = handleDirection(event.key);
|
|
324
|
+
if (!direction) return;
|
|
325
|
+
event.preventDefault();
|
|
326
|
+
const next = nextDetent(detent, direction);
|
|
327
|
+
if (next !== detent) onDetentChange(next);
|
|
328
|
+
};
|
|
329
|
+
const onKeyDown = (event) => {
|
|
330
|
+
if (!open) return;
|
|
331
|
+
if (event.key === "Escape") {
|
|
332
|
+
event.preventDefault();
|
|
333
|
+
onClose();
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (event.key === "Tab" && modal && loopFocus(event.currentTarget, event.shiftKey)) event.preventDefault();
|
|
337
|
+
};
|
|
338
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
339
|
+
ref: sheetRef,
|
|
340
|
+
id,
|
|
341
|
+
role: isSheet ? "dialog" : "complementary",
|
|
342
|
+
"aria-labelledby": titleId,
|
|
343
|
+
"aria-modal": modal ? true : void 0,
|
|
344
|
+
inert: !open,
|
|
345
|
+
"data-chrome": "sheet",
|
|
346
|
+
"data-testid": testId ?? id,
|
|
347
|
+
"data-layout": layout,
|
|
348
|
+
"data-state": open ? "open" : "closed",
|
|
349
|
+
"data-detent": isSheet ? detent : void 0,
|
|
350
|
+
className: surface,
|
|
351
|
+
onKeyDown,
|
|
352
|
+
children: [
|
|
353
|
+
modal ? /* @__PURE__ */ jsx(FocusSentinel, {
|
|
354
|
+
at: "start",
|
|
355
|
+
sheetRef
|
|
356
|
+
}) : null,
|
|
357
|
+
/* @__PURE__ */ jsxs("div", {
|
|
358
|
+
className: header,
|
|
359
|
+
onPointerDown,
|
|
360
|
+
onPointerMove,
|
|
361
|
+
onPointerUp,
|
|
362
|
+
onPointerCancel,
|
|
363
|
+
onLostPointerCapture: onPointerCancel,
|
|
364
|
+
children: [
|
|
365
|
+
isSheet ? /* @__PURE__ */ jsx("button", {
|
|
366
|
+
ref: handleRef,
|
|
367
|
+
type: "button",
|
|
368
|
+
"aria-label": t("chrome.sheet.resize", {}),
|
|
369
|
+
className: handle,
|
|
370
|
+
onClick: onHandleClick,
|
|
371
|
+
onKeyDown: onHandleKeyDown,
|
|
372
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
373
|
+
className: grabber,
|
|
374
|
+
"aria-hidden": "true"
|
|
375
|
+
})
|
|
376
|
+
}) : null,
|
|
377
|
+
brand$1 == null ? null : /* @__PURE__ */ jsx("div", {
|
|
378
|
+
"aria-hidden": "true",
|
|
379
|
+
className: brand,
|
|
380
|
+
"data-testid": "sheet-brand",
|
|
381
|
+
children: brand$1
|
|
382
|
+
}),
|
|
383
|
+
/* @__PURE__ */ jsx("h2", {
|
|
384
|
+
ref: titleRef,
|
|
385
|
+
id: titleId,
|
|
386
|
+
tabIndex: -1,
|
|
387
|
+
className: title,
|
|
388
|
+
children: title$1
|
|
389
|
+
}),
|
|
390
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
391
|
+
label: t("chrome.sheet.close", {}),
|
|
392
|
+
icon: X,
|
|
393
|
+
size: "compact",
|
|
394
|
+
className: close,
|
|
395
|
+
onClick: onClose
|
|
396
|
+
})
|
|
397
|
+
]
|
|
398
|
+
}),
|
|
399
|
+
/* @__PURE__ */ jsx("div", {
|
|
400
|
+
className: content,
|
|
401
|
+
children
|
|
402
|
+
}),
|
|
403
|
+
modal ? /* @__PURE__ */ jsx(FocusSentinel, {
|
|
404
|
+
at: "end",
|
|
405
|
+
sheetRef
|
|
406
|
+
}) : null
|
|
407
|
+
]
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
export { Sheet };
|
|
411
|
+
|
|
412
|
+
//# sourceMappingURL=Sheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sheet.js","names":["styles.sentinel","styles.surface","styles.header","styles.handle","styles.grabber","brand","styles.brand","styles.title","title","styles.close","styles.content"],"sources":["../../../src/chrome/Sheet/Sheet.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n announceDetent,\n clampHeight,\n computeDetentHeights,\n cycleDetent,\n type DetentHeights,\n inlineDistanceToFarEdge,\n nextDetent,\n resolveSnap,\n type SheetDetent,\n} from \"@mapcairn/core\";\nimport { useLatestRef } from \"@mapcairn/react\";\nimport { X } from \"lucide-react\";\nimport {\n type KeyboardEvent,\n type MouseEvent,\n type PointerEvent,\n type ReactNode,\n type RefObject,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { useMessages } from \"../../services\";\nimport { IconButton, useAnnounce } from \"../../ui\";\nimport { useChromeLayout } from \"../layoutContext\";\nimport { useChromeSurface } from \"../MapChrome/chromeSurface\";\nimport * as styles from \"./Sheet.css\";\n\n/** How far, in px, a press may move before it counts as a drag rather than a tap. */\nconst DRAG_SLOP_PX = 4;\n\n/** The window, in ms, over which release velocity is measured. */\nconst VELOCITY_WINDOW_MS = 100;\n\n/**\n * Everything that can take keyboard focus inside the sheet, in tab order,\n * apart from the focus sentinels.\n */\nconst TABBABLE = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n '[tabindex]:not([tabindex=\"-1\"]):not([data-focus-sentinel])',\n].join(\", \");\n\n/** Props for {@link Sheet}. */\nexport interface SheetProps {\n /** The element id, for `aria-controls` on the control that opens it. */\n readonly id: string;\n readonly open: boolean;\n /** The heading text, which also names the dialog or region. */\n readonly title: string;\n /** The app's single close action (Close button and Escape). */\n readonly onClose: () => void;\n /** The current detent. Used only in the sheet layout. */\n readonly detent: SheetDetent;\n readonly onDetentChange: (detent: SheetDetent) => void;\n /**\n * Called with true while the sheet is modal (open at the full detent in the\n * sheet layout), and false otherwise. The app passes it on to `MapChrome`'s\n * `modal`, which makes everything else `inert`.\n */\n readonly onModalChange?: (modal: boolean) => void;\n /** Called after the sheet closes, to put focus back where it came from. */\n readonly restoreFocus?: () => void;\n /** Sets `data-testid`. Defaults to the id. */\n readonly testId?: string;\n /**\n * A decorative brand (a host's mark and name) shown in a row above the\n * title. It is `aria-hidden`, so the title stays the accessible name; pass\n * nothing for no row. In the sheet layout the row is left out at the peek\n * detent, where there is no room for it.\n */\n readonly brand?: ReactNode;\n readonly children: ReactNode;\n}\n\ninterface Sample {\n readonly time: number;\n readonly y: number;\n}\n\ninterface Drag {\n readonly pointerId: number;\n /**\n * The element that was pressed, which holds pointer capture. Capturing on\n * the pressed element rather than the header keeps the press and the\n * release on one element, so the browser sends the click that ends a mouse\n * press to the handle and not to the header.\n */\n readonly capture: Element;\n /** Whether the press started on the handle, which receives the click after it. */\n readonly fromHandle: boolean;\n readonly startY: number;\n readonly startHeight: number;\n height: number;\n moved: boolean;\n samples: Sample[];\n}\n\n/** The way an arrow key moves the sheet from its handle, or null for any other key. */\nfunction handleDirection(key: string): \"up\" | \"down\" | null {\n if (key === \"ArrowUp\") {\n return \"up\";\n }\n return key === \"ArrowDown\" ? \"down\" : null;\n}\n\n/**\n * Velocity in px/s from the oldest sample in the last\n * {@link VELOCITY_WINDOW_MS} to the release; positive when expanding. A\n * pointer held still for longer than the window releases at zero.\n */\nfunction releaseVelocity(samples: readonly Sample[], release: Sample): number {\n const first = samples.reduce(\n (oldest, sample) =>\n release.time - sample.time <= VELOCITY_WINDOW_MS &&\n sample.time < oldest.time\n ? sample\n : oldest,\n release,\n );\n const elapsed = release.time - first.time;\n return elapsed > 0 ? ((first.y - release.y) / elapsed) * 1000 : 0;\n}\n\n/** The controls in the sheet that Tab can reach, in order. */\nfunction tabbableIn(container: HTMLElement): HTMLElement[] {\n return [...container.querySelectorAll<HTMLElement>(TABBABLE)];\n}\n\n/**\n * Moves Tab and Shift+Tab around the ends of the sheet, so focus cannot\n * leave it. Returns true when it moved focus.\n */\nfunction loopFocus(container: HTMLElement, backwards: boolean): boolean {\n const tabbable = tabbableIn(container);\n const first = tabbable[0];\n const last = tabbable[tabbable.length - 1];\n if (!first || !last) {\n return false;\n }\n const index = tabbable.indexOf(\n container.ownerDocument.activeElement as HTMLElement,\n );\n if (backwards && index <= 0) {\n last.focus();\n return true;\n }\n if (!backwards && (index === -1 || index === tabbable.length - 1)) {\n first.focus();\n return true;\n }\n return false;\n}\n\n/**\n * Focuses the first or last control in the sheet. A focus sentinel calls it\n * when it receives focus.\n */\nfunction focusEnd(container: HTMLElement | null, end: \"first\" | \"last\"): void {\n if (!container) {\n return;\n }\n const tabbable = tabbableIn(container);\n (end === \"first\" ? tabbable[0] : tabbable[tabbable.length - 1])?.focus();\n}\n\n/**\n * An empty element at one end of the modal sheet that is in the Tab order\n * only to catch focus about to leave the sheet. It never keeps focus: the\n * start sentinel hands it to the last control and the end sentinel to the\n * first. It is a `span` because Safari's default Tab skips buttons.\n */\nfunction FocusSentinel({\n at,\n sheetRef,\n}: {\n readonly at: \"start\" | \"end\";\n readonly sheetRef: RefObject<HTMLDivElement | null>;\n}) {\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: it only forwards focus, at once, to a real control.\n // biome-ignore lint/a11y/noNoninteractiveElementInteractions: it only forwards focus, at once, to a real control.\n <span\n // biome-ignore lint/a11y/noNoninteractiveTabindex: a focus sentinel must be in the Tab order to catch focus leaving the modal sheet.\n tabIndex={0}\n data-focus-sentinel={at}\n className={styles.sentinel}\n onFocus={() =>\n focusEnd(sheetRef.current, at === \"start\" ? \"last\" : \"first\")\n }\n />\n );\n}\n\n/**\n * The map options surface: a bottom sheet with peek, half and full detents on\n * narrow screens, and a floating side panel in the panel layout. Rendered by\n * the app into `MapChrome`'s `sheet` slot, outside the inert wrapper.\n *\n * @remarks\n * Sheet layout: a `dialog` labelled by its heading. It is non-modal at peek\n * and half, so the map stays usable. At full it sets `aria-modal`, reports\n * `onModalChange(true)` (the app makes the rest of the chrome inert) and\n * loops Tab inside itself. Safari's default Tab skips links and buttons, so\n * the keydown loop cannot see focus reach the last control there; at full\n * the sheet also has an empty focus sentinel at each end, and the browser's\n * own Tab landing on one sends focus round to the other end. The handle is a \"Resize panel\" button: Enter or\n * Space cycles detents, the arrow keys step them, and the handle and header\n * can be dragged, with rubber-banding past the ends and a velocity-aware\n * snap on release. Detent changes are announced. The top edge and detent are\n * published for the bottom slots, once per animation frame while dragging.\n *\n * Panel layout: a `complementary` region labelled by its heading, never\n * modal, with no handle. It publishes its right edge so bottom-start can move\n * clear of it.\n *\n * Both: focus moves to the heading on open; Escape and Close call `onClose`;\n * `restoreFocus` runs after closing. One element serves both layouts (its\n * role and `data-layout` change) so content stays mounted across a rotation.\n * The detent heights take no bottom safe-area inset; the content pads for it.\n */\nexport function Sheet({\n id,\n open,\n title,\n onClose,\n detent,\n onDetentChange,\n onModalChange,\n restoreFocus,\n testId,\n brand,\n children,\n}: SheetProps) {\n const { layout, viewport, publishSheetTop } = useChromeLayout();\n const { publishSheetDetent, publishPanelEdge } = useChromeSurface();\n const announce = useAnnounce();\n const { t } = useMessages();\n const titleId = useId();\n const sheetRef = useRef<HTMLDivElement>(null);\n const titleRef = useRef<HTMLHeadingElement>(null);\n const handleRef = useRef<HTMLButtonElement>(null);\n const dragRef = useRef<Drag | null>(null);\n const frameRef = useRef<number | null>(null);\n const suppressClickRef = useRef(false);\n\n const isSheet = layout === \"sheet\";\n const modal = open && isSheet && detent === \"full\";\n const heights: DetentHeights = useMemo(\n () =>\n computeDetentHeights({\n viewportHeight: viewport.height,\n insetBottom: 0,\n }),\n [viewport.height],\n );\n\n const latest = useLatestRef({\n onModalChange,\n restoreFocus,\n publishSheetTop,\n });\n\n /** Places the sheet so `height` px of it shows. Transform only. */\n const applyHeight = (height: number) => {\n sheetRef.current?.style.setProperty(\n \"--sheet-offset\",\n `${heights.full - height}px`,\n );\n };\n\n // Size and place the sheet for the detent (also re-run after a drag ends,\n // since the detent may not have changed).\n useLayoutEffect(() => {\n const sheet = sheetRef.current;\n if (!sheet || !isSheet) {\n return;\n }\n sheet.style.setProperty(\"--sheet-full-height\", `${heights.full}px`);\n sheet.style.setProperty(\n \"--sheet-offset\",\n `${heights.full - heights[detent]}px`,\n );\n }, [isSheet, heights, detent]);\n\n // Publish the edges the bottom slots ride above or beside.\n useEffect(() => {\n if (open && isSheet) {\n publishSheetTop(viewport.height - heights[detent]);\n publishSheetDetent(detent);\n } else {\n publishSheetTop(null);\n publishSheetDetent(null);\n }\n }, [\n open,\n isSheet,\n detent,\n heights,\n viewport.height,\n publishSheetTop,\n publishSheetDetent,\n ]);\n\n useEffect(() => {\n const panel = sheetRef.current;\n if (!panel || !open || isSheet) {\n publishPanelEdge(null);\n return;\n }\n const publish = () => {\n publishPanelEdge(\n inlineDistanceToFarEdge({\n offsetLeft: panel.offsetLeft,\n offsetWidth: panel.offsetWidth,\n containerWidth: panel.offsetParent?.clientWidth ?? 0,\n direction:\n getComputedStyle(panel).direction === \"rtl\" ? \"rtl\" : \"ltr\",\n }),\n );\n };\n publish();\n const observer =\n typeof ResizeObserver === \"undefined\"\n ? null\n : new ResizeObserver(publish);\n observer?.observe(panel);\n return () => {\n observer?.disconnect();\n };\n }, [open, isSheet, publishPanelEdge]);\n\n // Clear everything this sheet published when it unmounts.\n useEffect(\n () => () => {\n latest.current.publishSheetTop(null);\n publishSheetDetent(null);\n publishPanelEdge(null);\n if (frameRef.current !== null) {\n cancelAnimationFrame(frameRef.current);\n }\n },\n [latest, publishSheetDetent, publishPanelEdge],\n );\n\n useEffect(() => {\n latest.current.onModalChange?.(modal);\n }, [latest, modal]);\n\n // Focus the heading on open; hand focus back after close.\n const wasOpen = useRef(open);\n useEffect(() => {\n if (open && !wasOpen.current) {\n titleRef.current?.focus();\n }\n if (!open && wasOpen.current) {\n latest.current.restoreFocus?.();\n }\n wasOpen.current = open;\n }, [latest, open]);\n // The first render may already be open.\n useEffect(() => {\n if (wasOpen.current) {\n titleRef.current?.focus();\n }\n }, []);\n\n // Announce detent changes, but not the detent the sheet opened at.\n const announcedDetent = useRef<SheetDetent | null>(null);\n useEffect(() => {\n if (!open || !isSheet) {\n announcedDetent.current = null;\n return;\n }\n if (\n announcedDetent.current !== null &&\n announcedDetent.current !== detent\n ) {\n announce(announceDetent(detent));\n }\n announcedDetent.current = detent;\n }, [open, isSheet, detent, announce]);\n\n const schedulePublish = () => {\n if (frameRef.current !== null) {\n return;\n }\n frameRef.current = requestAnimationFrame(() => {\n frameRef.current = null;\n const drag = dragRef.current;\n if (drag) {\n latest.current.publishSheetTop(viewport.height - drag.height);\n }\n });\n };\n\n const endDrag = (drag: Drag) => {\n dragRef.current = null;\n sheetRef.current?.removeAttribute(\"data-dragging\");\n if (drag.capture.hasPointerCapture?.(drag.pointerId)) {\n drag.capture.releasePointerCapture(drag.pointerId);\n }\n };\n\n const onPointerDown = (event: PointerEvent<HTMLDivElement>) => {\n const target = event.target as Element;\n const fromHandle = handleRef.current?.contains(target) === true;\n const onOtherButton = target.closest(\"button\") !== null && !fromHandle;\n if (\n !isSheet ||\n !open ||\n dragRef.current !== null ||\n onOtherButton ||\n (event.pointerType === \"mouse\" && event.button !== 0)\n ) {\n return;\n }\n // Capture on the pressed element, not the header: see `Drag.capture`.\n // Moves and the release still bubble to the header's handlers.\n target.setPointerCapture(event.pointerId);\n dragRef.current = {\n pointerId: event.pointerId,\n capture: target,\n fromHandle,\n startY: event.clientY,\n startHeight: heights[detent],\n height: heights[detent],\n moved: false,\n samples: [{ time: performance.now(), y: event.clientY }],\n };\n suppressClickRef.current = false;\n sheetRef.current?.setAttribute(\"data-dragging\", \"true\");\n };\n\n const onPointerMove = (event: PointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (!drag || drag.pointerId !== event.pointerId) {\n return;\n }\n const time = performance.now();\n const delta = drag.startY - event.clientY;\n drag.moved ||= Math.abs(delta) > DRAG_SLOP_PX;\n drag.height = clampHeight(drag.startHeight + delta, heights);\n drag.samples = [\n ...drag.samples.filter(\n (sample) => time - sample.time <= VELOCITY_WINDOW_MS * 2,\n ),\n { time, y: event.clientY },\n ];\n applyHeight(drag.height);\n schedulePublish();\n };\n\n const onPointerUp = (event: PointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (!drag || drag.pointerId !== event.pointerId) {\n return;\n }\n endDrag(drag);\n if (!drag.moved) {\n // The wobble under the slop already moved the sheet; put it back.\n applyHeight(heights[detent]);\n publishSheetTop(viewport.height - heights[detent]);\n return;\n }\n // Only the handle gets a click after a drag; a flag set for a drag from\n // the heading would never be consumed.\n suppressClickRef.current = drag.fromHandle;\n const snapped = resolveSnap({\n heights,\n currentHeight: drag.height,\n velocityPxPerSecond: releaseVelocity(drag.samples, {\n time: performance.now(),\n y: event.clientY,\n }),\n });\n applyHeight(heights[snapped]);\n publishSheetTop(viewport.height - heights[snapped]);\n if (snapped !== detent) {\n onDetentChange(snapped);\n }\n };\n\n /**\n * Abandons a live drag and settles back on the current detent. Used for\n * `pointercancel` and for `lostpointercapture`, which also follows every\n * normal release (by then there is no live drag, so it does nothing).\n */\n const onPointerCancel = (event: PointerEvent<HTMLDivElement>) => {\n const drag = dragRef.current;\n if (!drag || drag.pointerId !== event.pointerId) {\n return;\n }\n endDrag(drag);\n applyHeight(heights[detent]);\n publishSheetTop(viewport.height - heights[detent]);\n };\n\n const onHandleClick = (event: MouseEvent<HTMLButtonElement>) => {\n const suppress = suppressClickRef.current;\n suppressClickRef.current = false;\n // A click with no pointer press (detail 0, from Enter or Space) always\n // cycles, even when a drag left the flag set because no click followed it.\n if (suppress && event.detail !== 0) {\n return;\n }\n onDetentChange(cycleDetent(detent));\n };\n\n const onHandleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n const direction = handleDirection(event.key);\n if (!direction) {\n return;\n }\n event.preventDefault();\n const next = nextDetent(detent, direction);\n if (next !== detent) {\n onDetentChange(next);\n }\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (!open) {\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n onClose();\n return;\n }\n if (\n event.key === \"Tab\" &&\n modal &&\n loopFocus(event.currentTarget, event.shiftKey)\n ) {\n event.preventDefault();\n }\n };\n\n return (\n // biome-ignore lint/a11y/noStaticElementInteractions: Escape and the focus loop are handled for the whole surface (a dialog or complementary region).\n // biome-ignore lint/a11y/noNoninteractiveElementInteractions: Escape and the focus loop are handled for the whole surface (a dialog or complementary region).\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: the role is chosen per layout and both dialog and complementary take aria-labelledby.\n <div\n ref={sheetRef}\n id={id}\n role={isSheet ? \"dialog\" : \"complementary\"}\n aria-labelledby={titleId}\n aria-modal={modal ? true : undefined}\n inert={!open}\n data-chrome=\"sheet\"\n data-testid={testId ?? id}\n data-layout={layout}\n data-state={open ? \"open\" : \"closed\"}\n data-detent={isSheet ? detent : undefined}\n className={styles.surface}\n onKeyDown={onKeyDown}\n >\n {modal ? <FocusSentinel at=\"start\" sheetRef={sheetRef} /> : null}\n <div\n className={styles.header}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerCancel}\n onLostPointerCapture={onPointerCancel}\n >\n {isSheet ? (\n <button\n ref={handleRef}\n type=\"button\"\n aria-label={t(\"chrome.sheet.resize\", {})}\n className={styles.handle}\n onClick={onHandleClick}\n onKeyDown={onHandleKeyDown}\n >\n <span className={styles.grabber} aria-hidden=\"true\" />\n </button>\n ) : null}\n {brand == null ? null : (\n <div\n aria-hidden=\"true\"\n className={styles.brand}\n data-testid=\"sheet-brand\"\n >\n {brand}\n </div>\n )}\n <h2 ref={titleRef} id={titleId} tabIndex={-1} className={styles.title}>\n {title}\n </h2>\n <IconButton\n label={t(\"chrome.sheet.close\", {})}\n icon={X}\n size=\"compact\"\n className={styles.close}\n onClick={onClose}\n />\n </div>\n <div className={styles.content}>{children}</div>\n {modal ? <FocusSentinel at=\"end\" sheetRef={sheetRef} /> : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,IAAM,eAAe;;AAGrB,IAAM,qBAAqB;;;;;AAM3B,IAAM,WAAW;CACf;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,IAAI;;AA0DX,SAAS,gBAAgB,KAAmC;CAC1D,IAAI,QAAQ,WACV,OAAO;CAET,OAAO,QAAQ,cAAc,SAAS;AACxC;;;;;;AAOA,SAAS,gBAAgB,SAA4B,SAAyB;CAC5E,MAAM,QAAQ,QAAQ,QACnB,QAAQ,WACP,QAAQ,OAAO,OAAO,QAAQ,sBAC9B,OAAO,OAAO,OAAO,OACjB,SACA,QACN,OACF;CACA,MAAM,UAAU,QAAQ,OAAO,MAAM;CACrC,OAAO,UAAU,KAAM,MAAM,IAAI,QAAQ,KAAK,UAAW,MAAO;AAClE;;AAGA,SAAS,WAAW,WAAuC;CACzD,OAAO,CAAC,GAAG,UAAU,iBAA8B,QAAQ,CAAC;AAC9D;;;;;AAMA,SAAS,UAAU,WAAwB,WAA6B;CACtE,MAAM,WAAW,WAAW,SAAS;CACrC,MAAM,QAAQ,SAAS;CACvB,MAAM,OAAO,SAAS,SAAS,SAAS;CACxC,IAAI,CAAC,SAAS,CAAC,MACb,OAAO;CAET,MAAM,QAAQ,SAAS,QACrB,UAAU,cAAc,aAC1B;CACA,IAAI,aAAa,SAAS,GAAG;EAC3B,KAAK,MAAM;EACX,OAAO;CACT;CACA,IAAI,CAAC,cAAc,UAAU,MAAM,UAAU,SAAS,SAAS,IAA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WC;OAAgB,eAAY;MAAQ,CAAA;KAC/C,CAAA,IACN;KACHC,WAAS,OAAO,OACf,oBAAC,OAAD;MACE,eAAY;MACZ,WAAWC;MACX,eAAY;MAEX,UAAAD;KACE,CAAA;KAEP,oBAAC,MAAD;MAAI,KAAK;MAAU,IAAI;MAAS,UAAU;MAAI,WAAWE;MACtD,UAAAC;KACC,CAAA;KACJ,oBAAC,YAAD;MACE,OAAO,EAAE,sBAAsB,CAAC,CAAC;MACjC,MAAM;MACN,MAAK;MACL,WAAWC;MACX,SAAS;KACV,CAAA;IACE;;GACL,oBAAC,OAAD;IAAK,WAAWC;IAAiB;GAAc,CAAA;GAC9C,QAAQ,oBAAC,eAAD;IAAe,IAAG;IAAgB;GAAW,CAAA,IAAI;EACvD;;AAET"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
// src/chrome/Sheet/Sheet.css.ts
|
|
3
|
+
var surface = "_1hcgav70";
|
|
4
|
+
var header = "_1hcgav71";
|
|
5
|
+
var handle = "_1hcgav72";
|
|
6
|
+
var grabber = "_1hcgav73";
|
|
7
|
+
var brand = "_1hcgav74";
|
|
8
|
+
var title = "_1hcgav75";
|
|
9
|
+
var close = "_1hcgav76";
|
|
10
|
+
var content = "_1hcgav77";
|
|
11
|
+
var sentinel = "_1hcgav78";
|
|
12
|
+
export { brand, close, content, grabber, handle, header, sentinel, surface, title };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=Sheet.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sheet.styles.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createContext, useCallback, useContext, useMemo, useRef } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useLatestRef } from "@mapcairn/react";
|
|
4
|
+
// src/chrome/focusRegistry.tsx
|
|
5
|
+
var FocusRegistryContext = createContext(null);
|
|
6
|
+
/**
|
|
7
|
+
* Remembers the elements that open surfaces, so closing a surface can put
|
|
8
|
+
* focus back on the control that opened it, or on the map when that control is
|
|
9
|
+
* gone. Safari does not focus buttons on click, so focus is always moved with
|
|
10
|
+
* an explicit `focus()` call.
|
|
11
|
+
*/
|
|
12
|
+
function FocusRegistryProvider({ focusMap, children }) {
|
|
13
|
+
const elements = useRef(/* @__PURE__ */ new Map());
|
|
14
|
+
const focusMapRef = useLatestRef(focusMap);
|
|
15
|
+
const register = useCallback((name, target) => {
|
|
16
|
+
if (target) elements.current.set(name, target);
|
|
17
|
+
else elements.current.delete(name);
|
|
18
|
+
}, []);
|
|
19
|
+
const restore = useCallback((name) => {
|
|
20
|
+
const element = name ? elements.current.get(name) : void 0;
|
|
21
|
+
if (element?.isConnected) {
|
|
22
|
+
element.focus();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
focusMapRef.current();
|
|
26
|
+
}, [focusMapRef]);
|
|
27
|
+
const element = useCallback((name) => {
|
|
28
|
+
const found = elements.current.get(name);
|
|
29
|
+
return found?.isConnected ? found : null;
|
|
30
|
+
}, []);
|
|
31
|
+
const value = useMemo(() => ({
|
|
32
|
+
register,
|
|
33
|
+
restore,
|
|
34
|
+
element
|
|
35
|
+
}), [
|
|
36
|
+
register,
|
|
37
|
+
restore,
|
|
38
|
+
element
|
|
39
|
+
]);
|
|
40
|
+
return /* @__PURE__ */ jsx(FocusRegistryContext.Provider, {
|
|
41
|
+
value,
|
|
42
|
+
children
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function useRegistry() {
|
|
46
|
+
const value = useContext(FocusRegistryContext);
|
|
47
|
+
if (!value) throw new Error("Focus registry hooks must be used inside a FocusRegistryProvider.");
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns a ref callback to put on the control that opens a surface, so focus
|
|
52
|
+
* can come back to it: `<IconButton ref={useFocusTarget("map-options")} />`.
|
|
53
|
+
*/
|
|
54
|
+
function useFocusTarget(name) {
|
|
55
|
+
const { register } = useRegistry();
|
|
56
|
+
return useCallback((element) => {
|
|
57
|
+
register(name, element);
|
|
58
|
+
}, [register, name]);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns `restore(name)`, which focuses the registered control, or the map
|
|
62
|
+
* region when the name is null or the control is no longer in the document.
|
|
63
|
+
*/
|
|
64
|
+
function useFocusReturn() {
|
|
65
|
+
return useRegistry().restore;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns `element(name)`, the registered control in the document, or null.
|
|
69
|
+
* Read-only: the first-visit tour uses it to ring the control a step names.
|
|
70
|
+
*/
|
|
71
|
+
function useFocusElement() {
|
|
72
|
+
return useRegistry().element;
|
|
73
|
+
}
|
|
74
|
+
export { FocusRegistryProvider, useFocusElement, useFocusReturn, useFocusTarget };
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=focusRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusRegistry.js","names":[],"sources":["../../src/chrome/focusRegistry.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport type { FocusTarget } from \"@mapcairn/core\";\nimport { useLatestRef } from \"@mapcairn/react\";\nimport {\n createContext,\n type ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n} from \"react\";\n\n/** The controls focus can return to when a surface closes. */\nexport type FocusName = FocusTarget;\n\ninterface FocusRegistryValue {\n register(name: FocusName, element: HTMLElement | null): void;\n restore(name: FocusName | null): void;\n element(name: FocusName): HTMLElement | null;\n}\n\nconst FocusRegistryContext = createContext<FocusRegistryValue | null>(null);\n\n/** Props for {@link FocusRegistryProvider}. */\nexport interface FocusRegistryProviderProps {\n /** Focuses the map region. Used when the control that opened a surface no longer exists. */\n readonly focusMap: () => void;\n readonly children: ReactNode;\n}\n\n/**\n * Remembers the elements that open surfaces, so closing a surface can put\n * focus back on the control that opened it, or on the map when that control is\n * gone. Safari does not focus buttons on click, so focus is always moved with\n * an explicit `focus()` call.\n */\nexport function FocusRegistryProvider({\n focusMap,\n children,\n}: FocusRegistryProviderProps) {\n const elements = useRef(new Map<FocusName, HTMLElement>());\n const focusMapRef = useLatestRef(focusMap);\n\n const register = useCallback(\n (name: FocusName, target: HTMLElement | null) => {\n if (target) {\n elements.current.set(name, target);\n } else {\n elements.current.delete(name);\n }\n },\n [],\n );\n\n const restore = useCallback(\n (name: FocusName | null) => {\n const element = name ? elements.current.get(name) : undefined;\n if (element?.isConnected) {\n element.focus();\n return;\n }\n focusMapRef.current();\n },\n [focusMapRef],\n );\n\n const element = useCallback((name: FocusName) => {\n const found = elements.current.get(name);\n return found?.isConnected ? found : null;\n }, []);\n\n const value = useMemo(\n () => ({ register, restore, element }),\n [register, restore, element],\n );\n return (\n <FocusRegistryContext.Provider value={value}>\n {children}\n </FocusRegistryContext.Provider>\n );\n}\n\nfunction useRegistry(): FocusRegistryValue {\n const value = useContext(FocusRegistryContext);\n if (!value) {\n throw new Error(\n \"Focus registry hooks must be used inside a FocusRegistryProvider.\",\n );\n }\n return value;\n}\n\n/**\n * Returns a ref callback to put on the control that opens a surface, so focus\n * can come back to it: `<IconButton ref={useFocusTarget(\"map-options\")} />`.\n */\nexport function useFocusTarget(\n name: FocusName,\n): (element: HTMLElement | null) => void {\n const { register } = useRegistry();\n return useCallback(\n (element: HTMLElement | null) => {\n register(name, element);\n },\n [register, name],\n );\n}\n\n/**\n * Returns `restore(name)`, which focuses the registered control, or the map\n * region when the name is null or the control is no longer in the document.\n */\nexport function useFocusReturn(): (name: FocusName | null) => void {\n return useRegistry().restore;\n}\n\n/**\n * Returns `element(name)`, the registered control in the document, or null.\n * Read-only: the first-visit tour uses it to ring the control a step names.\n */\nexport function useFocusElement(): (name: FocusName) => HTMLElement | null {\n return useRegistry().element;\n}\n"],"mappings":";;;;AAsBA,IAAM,uBAAuB,cAAyC,IAAI;;;;;;;AAe1E,SAAgB,sBA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tsx
|
|
4
|
+
var ChromeLayoutContext = createContext({
|
|
5
|
+
layout: "sheet",
|
|
6
|
+
viewport: {
|
|
7
|
+
width: 0,
|
|
8
|
+
height: 0
|
|
9
|
+
},
|
|
10
|
+
finePointer: true,
|
|
11
|
+
panelEdge: null,
|
|
12
|
+
publishSheetTop() {}
|
|
13
|
+
});
|
|
14
|
+
/** Provides layout facts and the edge-publishing callbacks. Only `MapChrome` mounts this. */
|
|
15
|
+
function ChromeLayoutProvider({ value, children }) {
|
|
16
|
+
return /* @__PURE__ */ jsx(ChromeLayoutContext.Provider, {
|
|
17
|
+
value,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reads the chrome layout. Outside a `MapChrome` it returns a harmless default
|
|
23
|
+
* (sheet layout, no-op publishers) so a component can be tested on its own.
|
|
24
|
+
*/
|
|
25
|
+
function useChromeLayout() {
|
|
26
|
+
return useContext(ChromeLayoutContext);
|
|
27
|
+
}
|
|
28
|
+
export { ChromeLayoutProvider, useChromeLayout };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=layoutContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layoutContext.js","names":[],"sources":["../../src/chrome/layoutContext.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport type { ChromeLayout } from \"@mapcairn/core\";\nimport { createContext, type ReactNode, useContext } from \"react\";\n\n/** What {@link MapChrome} tells the surfaces and slots inside it. */\nexport interface ChromeLayoutValue {\n /** Bottom sheet on narrow, tall screens; side panel from 768px wide or under 500px tall. */\n readonly layout: ChromeLayout;\n /** The size of the chrome container, in CSS pixels. */\n readonly viewport: { readonly width: number; readonly height: number };\n /** The primary input is a fine pointer, so zoom buttons and keyboard help make sense by default. */\n readonly finePointer: boolean;\n /** The distance from inline-start to the open panel's far edge, in px. Null in the sheet layout or before measurement. */\n readonly panelEdge: number | null;\n /**\n * Distance from the map's bottom edge to the top of the visible map key.\n * Null while the key is absent or has given way.\n */\n readonly mapKeyClearance?: number | null;\n /**\n * The sheet publishes its current top edge (px from the top of the chrome\n * container) so the bottom slots can ride above it. Pass null when closed.\n */\n publishSheetTop(px: number | null): void;\n}\n\n/** Used outside a `MapChrome`, for example in unit tests of a single component. */\nconst defaultValue: ChromeLayoutValue = {\n layout: \"sheet\",\n viewport: { width: 0, height: 0 },\n finePointer: true,\n panelEdge: null,\n publishSheetTop() {},\n};\n\nconst ChromeLayoutContext = createContext<ChromeLayoutValue>(defaultValue);\n\n/** Props for {@link ChromeLayoutProvider}. */\nexport interface ChromeLayoutProviderProps {\n readonly value: ChromeLayoutValue;\n readonly children: ReactNode;\n}\n\n/** Provides layout facts and the edge-publishing callbacks. Only `MapChrome` mounts this. */\nexport function ChromeLayoutProvider({\n value,\n children,\n}: ChromeLayoutProviderProps) {\n return (\n <ChromeLayoutContext.Provider value={value}>\n {children}\n </ChromeLayoutContext.Provider>\n );\n}\n\n/**\n * Reads the chrome layout. Outside a `MapChrome` it returns a harmless default\n * (sheet layout, no-op publishers) so a component can be tested on its own.\n */\nexport function useChromeLayout(): ChromeLayoutValue {\n return useContext(ChromeLayoutContext);\n}\n"],"mappings":";;;AAoCA,IAAM,sBAAsB,cAAiC;CAP3D,QAAQ;CACR,UAAU;EAAE,OAAO;EAAG,QAAQ;CAAE;CAChC,aAAa;CACb,WAAW;CACX,kBAAkB,CAAC;AAGwC,CAAY;;AASzE,SAAgB,qBAAqB,EACnC,OACA,YAC4B;CAC5B,OACE,oBAAC,oBAAoB,UAArB;EAAqC;EAClC;CAC2B,CAAA;AAElC;;;;;AAMA,SAAgB,kBAAqC;CACnD,OAAO,WAAW,mBAAmB;AACvC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
2
|
+
// src/chrome/useScrollEdges.ts
|
|
3
|
+
/** How far from an edge counts as being at it, for fractional scroll positions. */
|
|
4
|
+
var EDGE_SLACK_PX = 1;
|
|
5
|
+
/**
|
|
6
|
+
* What is left to scroll to in `element`: `below` while the end is out of
|
|
7
|
+
* sight, `above` once it has scrolled away from the start, `both` in between,
|
|
8
|
+
* `none` when everything fits.
|
|
9
|
+
*/
|
|
10
|
+
function scrollMoreOf(element) {
|
|
11
|
+
const above = element.scrollTop > EDGE_SLACK_PX;
|
|
12
|
+
const below = element.scrollTop + element.clientHeight < element.scrollHeight - EDGE_SLACK_PX;
|
|
13
|
+
if (above && below) return "both";
|
|
14
|
+
if (above) return "above";
|
|
15
|
+
return below ? "below" : "none";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Keeps `data-scroll-more` on a scroll container up to date with
|
|
19
|
+
* {@link scrollMoreOf}, so its style can fade the edge that has more behind it
|
|
20
|
+
* (`scrollFade`) and a test can read it. It is set directly on the element, not
|
|
21
|
+
* through state, because it changes on every scroll.
|
|
22
|
+
*
|
|
23
|
+
* @param ref - The scroll container.
|
|
24
|
+
* @remarks It is read again after every render of the caller (the content
|
|
25
|
+
* changes with them), when the container or one of its children resizes, and
|
|
26
|
+
* on scroll. Where there is no `ResizeObserver`, the render and the scroll
|
|
27
|
+
* still keep it current.
|
|
28
|
+
*/
|
|
29
|
+
function useScrollEdges(ref) {
|
|
30
|
+
useLayoutEffect(() => {
|
|
31
|
+
const element = ref.current;
|
|
32
|
+
if (element) element.dataset.scrollMore = scrollMoreOf(element);
|
|
33
|
+
});
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const element = ref.current;
|
|
36
|
+
if (!element) return;
|
|
37
|
+
const update = () => {
|
|
38
|
+
element.dataset.scrollMore = scrollMoreOf(element);
|
|
39
|
+
};
|
|
40
|
+
element.addEventListener("scroll", update, { passive: true });
|
|
41
|
+
if (typeof ResizeObserver === "undefined") return () => element.removeEventListener("scroll", update);
|
|
42
|
+
const observer = new ResizeObserver(update);
|
|
43
|
+
observer.observe(element);
|
|
44
|
+
for (const child of element.children) observer.observe(child);
|
|
45
|
+
return () => {
|
|
46
|
+
element.removeEventListener("scroll", update);
|
|
47
|
+
observer.disconnect();
|
|
48
|
+
};
|
|
49
|
+
}, [ref]);
|
|
50
|
+
}
|
|
51
|
+
export { scrollMoreOf, useScrollEdges };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=useScrollEdges.js.map
|