@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,175 @@
|
|
|
1
|
+
import { useLanguages, useMessages, usePreferences, useSaveData, useSettings, useTheme } from "../../services/hooks.js";
|
|
2
|
+
import { Icon } from "../../ui/Icon/Icon.js";
|
|
3
|
+
import { useAnnounce } from "../../ui/LiveRegion/LiveRegion.js";
|
|
4
|
+
import { SegmentedControl } from "../../ui/SegmentedControl/SegmentedControl.js";
|
|
5
|
+
import { Switch } from "../../ui/Switch/Switch.js";
|
|
6
|
+
import { Section, Subheading, nextHeadingLevel } from "../Section/Section.js";
|
|
7
|
+
import { link, note, noteIcon, prose, subsection } from "../Section/Section.styles.js";
|
|
8
|
+
import { LanguageField } from "./LanguageField.js";
|
|
9
|
+
import { field, fieldLabel } from "./SettingsSection.styles.js";
|
|
10
|
+
import { announceProjection } from "@mapcairn/core";
|
|
11
|
+
import { Info } from "lucide-react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
// src/panels/SettingsSection/SettingsSection.tsx
|
|
14
|
+
function themeOptions(t) {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
value: "system",
|
|
18
|
+
label: t("settings.theme.system", {})
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: "light",
|
|
22
|
+
label: t("settings.theme.light", {})
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: "dark",
|
|
26
|
+
label: t("settings.theme.dark", {})
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
function unitOptions(t) {
|
|
31
|
+
return [{
|
|
32
|
+
value: "metric",
|
|
33
|
+
label: t("settings.units.metric", {})
|
|
34
|
+
}, {
|
|
35
|
+
value: "imperial",
|
|
36
|
+
label: t("settings.units.imperial", {})
|
|
37
|
+
}];
|
|
38
|
+
}
|
|
39
|
+
function projectionOptions(t) {
|
|
40
|
+
return [{
|
|
41
|
+
value: "flat",
|
|
42
|
+
label: t("settings.mapShape.flat", {})
|
|
43
|
+
}, {
|
|
44
|
+
value: "globe",
|
|
45
|
+
label: t("settings.mapShape.globe", {})
|
|
46
|
+
}];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The settings: theme, units, map shape (flat or globe), language (only when
|
|
50
|
+
* the host offers more than one; see {@link LanguageField}), zoom buttons and
|
|
51
|
+
* Save data, a note when changes will not be remembered, and a short privacy
|
|
52
|
+
* statement (the host's, or the catalogue's `settings.privacy.default`) with a
|
|
53
|
+
* link to the policy.
|
|
54
|
+
* @remarks The zoom switch shows the stored choice, or the device default
|
|
55
|
+
* (on with a mouse, off on touch) while nothing is stored. Toggling it stores
|
|
56
|
+
* an explicit boolean, so a person who turns it on keeps it on everywhere.
|
|
57
|
+
* The Save data switch works the same way: its default is the device's
|
|
58
|
+
* signal (a data saver or a very slow connection, where the browser reports
|
|
59
|
+
* one), and a person's own choice always wins.
|
|
60
|
+
*/
|
|
61
|
+
function SettingsSection({ headingLevel = 3, privacyHref = "/privacy", privacyNote, headingRef }) {
|
|
62
|
+
const { choice, setChoice } = useTheme();
|
|
63
|
+
const { settings, update, persistent } = useSettings();
|
|
64
|
+
const { finePointer } = usePreferences();
|
|
65
|
+
const saveData = useSaveData();
|
|
66
|
+
const announce = useAnnounce();
|
|
67
|
+
const { t } = useMessages();
|
|
68
|
+
const offersLanguages = (useLanguages()?.languages.length ?? 0) > 1;
|
|
69
|
+
const subLevel = nextHeadingLevel(headingLevel);
|
|
70
|
+
const privacyStatement = privacyNote === void 0 ? t("settings.privacy.default", {}) : privacyNote;
|
|
71
|
+
const themeLabel = t("settings.theme.label", {});
|
|
72
|
+
const unitsLabel = t("settings.units.label", {});
|
|
73
|
+
const mapShapeLabel = t("settings.mapShape.label", {});
|
|
74
|
+
return /* @__PURE__ */ jsxs(Section, {
|
|
75
|
+
title: t("settings.title", {}),
|
|
76
|
+
headingLevel,
|
|
77
|
+
headingRef,
|
|
78
|
+
"data-testid": "sheet-section-settings",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsxs("div", {
|
|
81
|
+
className: field,
|
|
82
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
83
|
+
className: fieldLabel,
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
children: themeLabel
|
|
86
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
87
|
+
label: themeLabel,
|
|
88
|
+
options: themeOptions(t),
|
|
89
|
+
value: choice,
|
|
90
|
+
onValueChange: (next) => setChoice(next),
|
|
91
|
+
"data-testid": "theme-option"
|
|
92
|
+
})]
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ jsxs("div", {
|
|
95
|
+
className: field,
|
|
96
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
97
|
+
className: fieldLabel,
|
|
98
|
+
"aria-hidden": "true",
|
|
99
|
+
children: unitsLabel
|
|
100
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
101
|
+
label: unitsLabel,
|
|
102
|
+
options: unitOptions(t),
|
|
103
|
+
value: settings.units,
|
|
104
|
+
onValueChange: (next) => update({ units: next }),
|
|
105
|
+
"data-testid": "units-option"
|
|
106
|
+
})]
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ jsxs("div", {
|
|
109
|
+
className: field,
|
|
110
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
111
|
+
className: fieldLabel,
|
|
112
|
+
"aria-hidden": "true",
|
|
113
|
+
children: mapShapeLabel
|
|
114
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
115
|
+
label: mapShapeLabel,
|
|
116
|
+
options: projectionOptions(t),
|
|
117
|
+
value: settings.projection,
|
|
118
|
+
onValueChange: (next) => {
|
|
119
|
+
update({ projection: next });
|
|
120
|
+
announce(announceProjection(next));
|
|
121
|
+
},
|
|
122
|
+
"data-testid": "projection-option"
|
|
123
|
+
})]
|
|
124
|
+
}),
|
|
125
|
+
offersLanguages ? /* @__PURE__ */ jsx(LanguageField, {}) : null,
|
|
126
|
+
/* @__PURE__ */ jsx(Switch, {
|
|
127
|
+
label: t("settings.zoomButtons.label", {}),
|
|
128
|
+
description: t("settings.zoomButtons.description", {}),
|
|
129
|
+
checked: settings.zoomButtons ?? finePointer,
|
|
130
|
+
onCheckedChange: (next) => update({ zoomButtons: next }),
|
|
131
|
+
"data-testid": "zoom-buttons-switch"
|
|
132
|
+
}),
|
|
133
|
+
/* @__PURE__ */ jsx(Switch, {
|
|
134
|
+
label: t("settings.saveData.label", {}),
|
|
135
|
+
description: t("settings.saveData.description", {}),
|
|
136
|
+
checked: saveData,
|
|
137
|
+
onCheckedChange: (next) => update({ saveData: next }),
|
|
138
|
+
"data-testid": "save-data-switch"
|
|
139
|
+
}),
|
|
140
|
+
persistent ? null : /* @__PURE__ */ jsxs("p", {
|
|
141
|
+
className: note,
|
|
142
|
+
"data-testid": "settings-not-saved",
|
|
143
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
144
|
+
icon: Info,
|
|
145
|
+
className: noteIcon
|
|
146
|
+
}), t("settings.notSaved", {})]
|
|
147
|
+
}),
|
|
148
|
+
/* @__PURE__ */ jsxs("div", {
|
|
149
|
+
className: subsection,
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ jsx(Subheading, {
|
|
152
|
+
level: subLevel,
|
|
153
|
+
children: t("settings.privacy.heading", {})
|
|
154
|
+
}),
|
|
155
|
+
/* @__PURE__ */ jsx("p", {
|
|
156
|
+
className: prose,
|
|
157
|
+
"data-testid": "settings-privacy-note",
|
|
158
|
+
children: privacyStatement
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ jsx("p", {
|
|
161
|
+
className: prose,
|
|
162
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
163
|
+
className: link,
|
|
164
|
+
href: privacyHref,
|
|
165
|
+
children: t("settings.privacy.link", {})
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
export { SettingsSection };
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=SettingsSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SettingsSection.js","names":[],"sources":["../../../src/panels/SettingsSection/SettingsSection.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n announceProjection,\n type MapProjection,\n type MessageCatalogue,\n type ThemeChoice,\n type UnitSystem,\n} from \"@mapcairn/core\";\nimport { Info } from \"lucide-react\";\nimport type { ReactNode, Ref } from \"react\";\nimport {\n useLanguages,\n useMessages,\n usePreferences,\n useSaveData,\n useSettings,\n useTheme,\n} from \"../../services\";\nimport { Icon } from \"../../ui/Icon\";\nimport { useAnnounce } from \"../../ui/LiveRegion\";\nimport { SegmentedControl } from \"../../ui/SegmentedControl\";\nimport { Switch } from \"../../ui/Switch\";\nimport {\n type HeadingLevel,\n nextHeadingLevel,\n Section,\n Subheading,\n} from \"../Section\";\nimport {\n link,\n note,\n noteIcon,\n prose,\n subsection,\n} from \"../Section/Section.css\";\nimport { LanguageField } from \"./LanguageField\";\nimport { field, fieldLabel } from \"./SettingsSection.css\";\n\nfunction themeOptions(\n t: MessageCatalogue[\"t\"],\n): readonly { value: ThemeChoice; label: string }[] {\n return [\n { value: \"system\", label: t(\"settings.theme.system\", {}) },\n { value: \"light\", label: t(\"settings.theme.light\", {}) },\n { value: \"dark\", label: t(\"settings.theme.dark\", {}) },\n ];\n}\n\nfunction unitOptions(\n t: MessageCatalogue[\"t\"],\n): readonly { value: UnitSystem; label: string }[] {\n return [\n { value: \"metric\", label: t(\"settings.units.metric\", {}) },\n { value: \"imperial\", label: t(\"settings.units.imperial\", {}) },\n ];\n}\n\nfunction projectionOptions(\n t: MessageCatalogue[\"t\"],\n): readonly { value: MapProjection; label: string }[] {\n return [\n { value: \"flat\", label: t(\"settings.mapShape.flat\", {}) },\n { value: \"globe\", label: t(\"settings.mapShape.globe\", {}) },\n ];\n}\n\n/** Props for {@link SettingsSection}. */\nexport interface SettingsSectionProps {\n /** The heading level. Defaults to 3, below the sheet's h2 title. */\n readonly headingLevel?: HeadingLevel;\n /** Where the privacy policy is. Defaults to `/privacy`. */\n readonly privacyHref?: string;\n /**\n * The host's privacy statement, shown under the Privacy heading. Defaults to\n * the catalogue's `settings.privacy.default`, which names no provider because\n * the SDK does not know which services a host uses. A host names its own\n * providers here and says what it sends to each. `null` or an empty string\n * shows no statement. Phrasing content only: it sits inside a paragraph.\n */\n readonly privacyNote?: ReactNode;\n /** Receives the heading, so the sheet can focus it. */\n readonly headingRef?: Ref<HTMLHeadingElement>;\n}\n\n/**\n * The settings: theme, units, map shape (flat or globe), language (only when\n * the host offers more than one; see {@link LanguageField}), zoom buttons and\n * Save data, a note when changes will not be remembered, and a short privacy\n * statement (the host's, or the catalogue's `settings.privacy.default`) with a\n * link to the policy.\n * @remarks The zoom switch shows the stored choice, or the device default\n * (on with a mouse, off on touch) while nothing is stored. Toggling it stores\n * an explicit boolean, so a person who turns it on keeps it on everywhere.\n * The Save data switch works the same way: its default is the device's\n * signal (a data saver or a very slow connection, where the browser reports\n * one), and a person's own choice always wins.\n */\nexport function SettingsSection({\n headingLevel = 3,\n privacyHref = \"/privacy\",\n privacyNote,\n headingRef,\n}: SettingsSectionProps) {\n const { choice, setChoice } = useTheme();\n const { settings, update, persistent } = useSettings();\n const { finePointer } = usePreferences();\n const saveData = useSaveData();\n const announce = useAnnounce();\n const { t } = useMessages();\n const offersLanguages = (useLanguages()?.languages.length ?? 0) > 1;\n const subLevel = nextHeadingLevel(headingLevel);\n const privacyStatement =\n privacyNote === undefined ? t(\"settings.privacy.default\", {}) : privacyNote;\n const themeLabel = t(\"settings.theme.label\", {});\n const unitsLabel = t(\"settings.units.label\", {});\n const mapShapeLabel = t(\"settings.mapShape.label\", {});\n return (\n <Section\n title={t(\"settings.title\", {})}\n headingLevel={headingLevel}\n headingRef={headingRef}\n data-testid=\"sheet-section-settings\"\n >\n <div className={field}>\n <p className={fieldLabel} aria-hidden=\"true\">\n {themeLabel}\n </p>\n <SegmentedControl\n label={themeLabel}\n options={themeOptions(t)}\n value={choice}\n onValueChange={(next) => setChoice(next as ThemeChoice)}\n data-testid=\"theme-option\"\n />\n </div>\n <div className={field}>\n <p className={fieldLabel} aria-hidden=\"true\">\n {unitsLabel}\n </p>\n <SegmentedControl\n label={unitsLabel}\n options={unitOptions(t)}\n value={settings.units}\n onValueChange={(next) => update({ units: next as UnitSystem })}\n data-testid=\"units-option\"\n />\n </div>\n <div className={field}>\n <p className={fieldLabel} aria-hidden=\"true\">\n {mapShapeLabel}\n </p>\n <SegmentedControl\n label={mapShapeLabel}\n options={projectionOptions(t)}\n value={settings.projection}\n onValueChange={(next) => {\n update({ projection: next as MapProjection });\n announce(announceProjection(next as MapProjection));\n }}\n data-testid=\"projection-option\"\n />\n </div>\n {offersLanguages ? <LanguageField /> : null}\n <Switch\n label={t(\"settings.zoomButtons.label\", {})}\n description={t(\"settings.zoomButtons.description\", {})}\n checked={settings.zoomButtons ?? finePointer}\n onCheckedChange={(next) => update({ zoomButtons: next })}\n data-testid=\"zoom-buttons-switch\"\n />\n <Switch\n label={t(\"settings.saveData.label\", {})}\n description={t(\"settings.saveData.description\", {})}\n checked={saveData}\n onCheckedChange={(next) => update({ saveData: next })}\n data-testid=\"save-data-switch\"\n />\n {persistent ? null : (\n <p className={note} data-testid=\"settings-not-saved\">\n <Icon icon={Info} className={noteIcon} />\n {t(\"settings.notSaved\", {})}\n </p>\n )}\n <div className={subsection}>\n <Subheading level={subLevel}>\n {t(\"settings.privacy.heading\", {})}\n </Subheading>\n <p className={prose} data-testid=\"settings-privacy-note\">\n {privacyStatement}\n </p>\n <p className={prose}>\n <a className={link} href={privacyHref}>\n {t(\"settings.privacy.link\", {})}\n </a>\n </p>\n </div>\n </Section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAuCA,SAAS,aACP,GACkD;CAClD,OAAO;EACL;GAAE,OAAO;GAAU,OAAO,EAAE,yBAAyB,CAAC,CAAC;EAAE;EACzD;GAAE,OAAO;GAAS,OAAO,EAAE,wBAAwB,CAAC,CAAC;EAAE;EACvD;GAAE,OAAO;GAAQ,OAAO,EAAE,uBAAuB,CAAC,CAAC;EAAE;CACvD;AACF;AAEA,SAAS,YACP,GACiD;CACjD,OAAO,CACL;EAAE,OAAO;EAAU,OAAO,EAAE,yBAAyB,CAAC,CAAC;CAAE,GACzD;EAAE,OAAO;EAAY,OAAO,EAAE,2BAA2B,CAAC,CAAC;CAAE,CAC/D;AACF;AAEA,SAAS,kBACP,GACoD;CACpD,OAAO,CACL;EAAE,OAAO;EAAQ,OAAO,EAAE,0BAA0B,CAAC,CAAC;CAAE,GACxD;EAAE,OAAO;EAAS,OAAO,EAAE,2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 @@
|
|
|
1
|
+
/* empty css */
|
|
2
|
+
// src/panels/SettingsSection/SettingsSection.css.ts
|
|
3
|
+
var field = "r8c4wk0";
|
|
4
|
+
var fieldLabel = "r8c4wk1";
|
|
5
|
+
var languageStatus = "r8c4wk2";
|
|
6
|
+
var languageStatusError = "r8c4wk3";
|
|
7
|
+
export { field, fieldLabel, languageStatus, languageStatusError };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=SettingsSection.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SettingsSection.styles.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { useChromeLayout } from "../../chrome/layoutContext.js";
|
|
2
|
+
import { MapContext } from "../../host/MapContext.js";
|
|
3
|
+
import { dateInput, field } from "../../layers/Layers.styles.js";
|
|
4
|
+
import { fitPadding } from "../../layers/reveal.js";
|
|
5
|
+
import { useFileOpener, useMessages, useSettings } from "../../services/hooks.js";
|
|
6
|
+
import { Button } from "../../ui/Button/Button.js";
|
|
7
|
+
import { Icon } from "../../ui/Icon/Icon.js";
|
|
8
|
+
import { ListRow } from "../../ui/ListRow/ListRow.js";
|
|
9
|
+
import { Section, Subheading } from "../Section/Section.js";
|
|
10
|
+
import { note, noteIcon, prose, subsection } from "../Section/Section.styles.js";
|
|
11
|
+
import { actions, list } from "./ShapesSection.styles.js";
|
|
12
|
+
import { formatShapeMeasure } from "@mapcairn/core";
|
|
13
|
+
import { CircleCheck, Download, FileSpreadsheet, FileText, FileUp, Link, Trash2, TriangleAlert } from "lucide-react";
|
|
14
|
+
import { useContext, useRef } from "react";
|
|
15
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
|
+
import { useReadingDirection } from "@mapcairn/react";
|
|
17
|
+
// src/panels/ShapesSection/ShapesSection.tsx
|
|
18
|
+
/** The button that reads the offered file in the other WKT axis order, by the order it offers. */
|
|
19
|
+
var REREAD_KEYS = {
|
|
20
|
+
"lat-lng": "panels.shapes.axisReread.lat-lng",
|
|
21
|
+
"lng-lat": "panels.shapes.axisReread.lng-lat"
|
|
22
|
+
};
|
|
23
|
+
/** The outcome of an import, export or copy, in words with an icon. */
|
|
24
|
+
function Feedback({ feedback, testId }) {
|
|
25
|
+
if (!feedback) return null;
|
|
26
|
+
return /* @__PURE__ */ jsxs("p", {
|
|
27
|
+
className: note,
|
|
28
|
+
"data-testid": testId,
|
|
29
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
30
|
+
icon: feedback.kind === "error" ? TriangleAlert : CircleCheck,
|
|
31
|
+
className: noteIcon
|
|
32
|
+
}), /* @__PURE__ */ jsx("span", { children: feedback.text })]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fits the map to imported shapes in the part the sheet or side panel leaves
|
|
37
|
+
* free, as Show on map does for a feature.
|
|
38
|
+
*/
|
|
39
|
+
function useFitToImport() {
|
|
40
|
+
const adapter = useContext(MapContext)?.adapter ?? null;
|
|
41
|
+
const { layout, viewport, panelEdge } = useChromeLayout();
|
|
42
|
+
const direction = useReadingDirection();
|
|
43
|
+
return (bounds) => {
|
|
44
|
+
if (!adapter) return;
|
|
45
|
+
adapter.fitBounds(bounds, {
|
|
46
|
+
maxZoom: 16,
|
|
47
|
+
padding: fitPadding({
|
|
48
|
+
layout,
|
|
49
|
+
viewport,
|
|
50
|
+
panelEdge,
|
|
51
|
+
direction
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The shapes the person has drawn: a list where each row selects a shape (so
|
|
58
|
+
* it can be edited with the keyboard from the draw tool), buttons to delete
|
|
59
|
+
* the selected shape or all of them, an import from a GeoJSON, CSV or WKT file
|
|
60
|
+
* (when the host supplies a file opener),
|
|
61
|
+
* and the export buttons. Shapes are saved to a file or into a link only when
|
|
62
|
+
* a button is pressed, a file is read only on this device, and the note says
|
|
63
|
+
* so. The map fits to what an import added.
|
|
64
|
+
*/
|
|
65
|
+
function ShapesSection({ draw, headingLevel = 3, headingRef }) {
|
|
66
|
+
const { settings } = useSettings();
|
|
67
|
+
const messages = useMessages();
|
|
68
|
+
const { t } = messages;
|
|
69
|
+
const { shapes, selection, feedback, importFeedback } = draw;
|
|
70
|
+
const subLevel = headingLevel + 1;
|
|
71
|
+
const fitToImport = useFitToImport();
|
|
72
|
+
const canImport = useFileOpener() !== void 0;
|
|
73
|
+
const readAs = importFeedback?.readAs;
|
|
74
|
+
const orderRef = useRef(null);
|
|
75
|
+
const importFile = () => {
|
|
76
|
+
draw.importFile().then((bounds) => {
|
|
77
|
+
if (bounds) fitToImport(bounds);
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const reread = (order) => {
|
|
81
|
+
orderRef.current?.focus();
|
|
82
|
+
const bounds = draw.rereadImport(order);
|
|
83
|
+
if (bounds) fitToImport(bounds);
|
|
84
|
+
};
|
|
85
|
+
return /* @__PURE__ */ jsxs(Section, {
|
|
86
|
+
title: t("panels.shapes.title", {}),
|
|
87
|
+
headingLevel,
|
|
88
|
+
headingRef,
|
|
89
|
+
"data-testid": "sheet-section-shapes",
|
|
90
|
+
children: [
|
|
91
|
+
shapes.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
92
|
+
className: prose,
|
|
93
|
+
"data-testid": "shapes-empty",
|
|
94
|
+
children: t("panels.shapes.empty", {})
|
|
95
|
+
}) : /* @__PURE__ */ jsx("ul", {
|
|
96
|
+
className: list,
|
|
97
|
+
"aria-label": t("panels.shapes.listLabel", {}),
|
|
98
|
+
"data-testid": "shapes-list",
|
|
99
|
+
children: shapes.map((shape) => /* @__PURE__ */ jsx(ListRow, {
|
|
100
|
+
label: shape.done ? shape.label : t("panels.shapes.unfinished", { label: shape.label }),
|
|
101
|
+
secondary: formatShapeMeasure(shape, settings.units, messages) || void 0,
|
|
102
|
+
selected: selection?.shapeId === shape.id,
|
|
103
|
+
"data-testid": "shapes-row",
|
|
104
|
+
onClick: () => draw.select(shape.id)
|
|
105
|
+
}, shape.id))
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ jsxs("div", {
|
|
108
|
+
className: actions,
|
|
109
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
110
|
+
variant: "secondary",
|
|
111
|
+
icon: Trash2,
|
|
112
|
+
disabled: selection === null,
|
|
113
|
+
"data-testid": "shapes-delete",
|
|
114
|
+
onClick: draw.deleteSelected,
|
|
115
|
+
children: t("panels.shapes.deleteSelected", {})
|
|
116
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
117
|
+
variant: "secondary",
|
|
118
|
+
icon: Trash2,
|
|
119
|
+
disabled: shapes.length === 0,
|
|
120
|
+
"data-testid": "shapes-clear",
|
|
121
|
+
onClick: draw.clear,
|
|
122
|
+
children: t("panels.shapes.deleteAll", {})
|
|
123
|
+
})]
|
|
124
|
+
}),
|
|
125
|
+
canImport ? /* @__PURE__ */ jsxs("div", {
|
|
126
|
+
className: subsection,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ jsx(Subheading, {
|
|
129
|
+
level: subLevel,
|
|
130
|
+
children: t("panels.shapes.importHeading", {})
|
|
131
|
+
}),
|
|
132
|
+
/* @__PURE__ */ jsxs("label", {
|
|
133
|
+
className: field,
|
|
134
|
+
children: [t("panels.shapes.axisOrderLabel", {}), /* @__PURE__ */ jsxs("select", {
|
|
135
|
+
ref: orderRef,
|
|
136
|
+
className: dateInput,
|
|
137
|
+
value: draw.wktAxisOrder,
|
|
138
|
+
"data-testid": "shapes-axis-order",
|
|
139
|
+
onChange: (event) => draw.setWktAxisOrder(event.target.value),
|
|
140
|
+
children: [/* @__PURE__ */ jsx("option", {
|
|
141
|
+
value: "lng-lat",
|
|
142
|
+
children: t("panels.shapes.axisOrder.lng-lat", {})
|
|
143
|
+
}), /* @__PURE__ */ jsx("option", {
|
|
144
|
+
value: "lat-lng",
|
|
145
|
+
children: t("panels.shapes.axisOrder.lat-lng", {})
|
|
146
|
+
})]
|
|
147
|
+
})]
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ jsx("div", {
|
|
150
|
+
className: actions,
|
|
151
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
152
|
+
variant: "secondary",
|
|
153
|
+
icon: FileUp,
|
|
154
|
+
"data-testid": "shapes-import",
|
|
155
|
+
onClick: importFile,
|
|
156
|
+
children: t("panels.shapes.import", {})
|
|
157
|
+
})
|
|
158
|
+
}),
|
|
159
|
+
/* @__PURE__ */ jsx(Feedback, {
|
|
160
|
+
feedback: importFeedback,
|
|
161
|
+
testId: "shapes-import-feedback"
|
|
162
|
+
}),
|
|
163
|
+
readAs ? /* @__PURE__ */ jsx("div", {
|
|
164
|
+
className: actions,
|
|
165
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
166
|
+
variant: "secondary",
|
|
167
|
+
"data-testid": "shapes-import-reread",
|
|
168
|
+
onClick: () => reread(readAs),
|
|
169
|
+
children: t(REREAD_KEYS[readAs], {})
|
|
170
|
+
})
|
|
171
|
+
}) : null
|
|
172
|
+
]
|
|
173
|
+
}) : null,
|
|
174
|
+
/* @__PURE__ */ jsxs("div", {
|
|
175
|
+
className: subsection,
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ jsx(Subheading, {
|
|
178
|
+
level: subLevel,
|
|
179
|
+
children: t("panels.shapes.exportHeading", {})
|
|
180
|
+
}),
|
|
181
|
+
/* @__PURE__ */ jsxs("div", {
|
|
182
|
+
className: actions,
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ jsx(Button, {
|
|
185
|
+
variant: "secondary",
|
|
186
|
+
icon: Download,
|
|
187
|
+
"data-testid": "shapes-export-geojson",
|
|
188
|
+
onClick: () => void draw.exportGeoJson(),
|
|
189
|
+
children: t("panels.shapes.downloadGeoJson", {})
|
|
190
|
+
}),
|
|
191
|
+
/* @__PURE__ */ jsx(Button, {
|
|
192
|
+
variant: "secondary",
|
|
193
|
+
icon: FileSpreadsheet,
|
|
194
|
+
"data-testid": "shapes-export-csv",
|
|
195
|
+
onClick: () => void draw.exportCsv(),
|
|
196
|
+
children: t("panels.shapes.downloadCsv", {})
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ jsx(Button, {
|
|
199
|
+
variant: "secondary",
|
|
200
|
+
icon: FileText,
|
|
201
|
+
"data-testid": "shapes-export-wkt",
|
|
202
|
+
onClick: () => void draw.exportWkt(),
|
|
203
|
+
children: t("panels.shapes.downloadWkt", {})
|
|
204
|
+
}),
|
|
205
|
+
/* @__PURE__ */ jsx(Button, {
|
|
206
|
+
variant: "secondary",
|
|
207
|
+
icon: Link,
|
|
208
|
+
"data-testid": "shapes-copy-link",
|
|
209
|
+
onClick: () => void draw.copyLink(),
|
|
210
|
+
children: t("panels.shapes.copyLink", {})
|
|
211
|
+
})
|
|
212
|
+
]
|
|
213
|
+
}),
|
|
214
|
+
/* @__PURE__ */ jsx(Feedback, {
|
|
215
|
+
feedback,
|
|
216
|
+
testId: "shapes-feedback"
|
|
217
|
+
}),
|
|
218
|
+
/* @__PURE__ */ jsx("p", {
|
|
219
|
+
className: prose,
|
|
220
|
+
children: t("panels.shapes.storageNote", {})
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
})
|
|
224
|
+
]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
export { ShapesSection };
|
|
228
|
+
|
|
229
|
+
//# sourceMappingURL=ShapesSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShapesSection.js","names":[],"sources":["../../../src/panels/ShapesSection/ShapesSection.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n type Bounds,\n formatShapeMeasure,\n type MessageKey,\n type WktAxisOrder,\n} from \"@mapcairn/core\";\nimport { useReadingDirection } from \"@mapcairn/react\";\nimport {\n CircleCheck,\n Download,\n FileSpreadsheet,\n FileText,\n FileUp,\n Link,\n Trash2,\n TriangleAlert,\n} from \"lucide-react\";\nimport { type Ref, useContext, useRef } from \"react\";\nimport { useChromeLayout } from \"../../chrome/layoutContext\";\nimport { MapContext } from \"../../host\";\nimport { dateInput, field } from \"../../layers/Layers.css\";\nimport { FIT_MAX_ZOOM, fitPadding } from \"../../layers/reveal\";\nimport { useFileOpener, useMessages, useSettings } from \"../../services\";\nimport type { DrawFeedback, UseDraw } from \"../../tools/DrawToolbar\";\nimport { Button } from \"../../ui/Button\";\nimport { Icon } from \"../../ui/Icon\";\nimport { ListRow } from \"../../ui/ListRow\";\nimport { type HeadingLevel, Section, Subheading } from \"../Section\";\nimport { note, noteIcon, prose, subsection } from \"../Section/Section.css\";\nimport { actions, list } from \"./ShapesSection.css\";\n\n/** Props for {@link ShapesSection}. */\nexport interface ShapesSectionProps {\n /** The drawing state from `useDraw`. */\n readonly draw: UseDraw;\n /** The heading level. Defaults to 3, below the sheet's h2 title. */\n readonly headingLevel?: HeadingLevel;\n /** Receives the heading, so the sheet can focus it. */\n readonly headingRef?: Ref<HTMLHeadingElement>;\n}\n\n/** The button that reads the offered file in the other WKT axis order, by the order it offers. */\nconst REREAD_KEYS = {\n \"lat-lng\": \"panels.shapes.axisReread.lat-lng\",\n \"lng-lat\": \"panels.shapes.axisReread.lng-lat\",\n} as const satisfies Readonly<Record<WktAxisOrder, MessageKey>>;\n\n/** The outcome of an import, export or copy, in words with an icon. */\nfunction Feedback({\n feedback,\n testId,\n}: {\n readonly feedback: DrawFeedback | null;\n readonly testId: string;\n}) {\n if (!feedback) {\n return null;\n }\n return (\n <p className={note} data-testid={testId}>\n <Icon\n icon={feedback.kind === \"error\" ? TriangleAlert : CircleCheck}\n className={noteIcon}\n />\n <span>{feedback.text}</span>\n </p>\n );\n}\n\n/**\n * Fits the map to imported shapes in the part the sheet or side panel leaves\n * free, as Show on map does for a feature.\n */\nfunction useFitToImport(): (bounds: Bounds) => void {\n const adapter = useContext(MapContext)?.adapter ?? null;\n const { layout, viewport, panelEdge } = useChromeLayout();\n const direction = useReadingDirection();\n return (bounds) => {\n if (!adapter) {\n return;\n }\n adapter.fitBounds(bounds, {\n maxZoom: FIT_MAX_ZOOM,\n padding: fitPadding({ layout, viewport, panelEdge, direction }),\n });\n };\n}\n\n/**\n * The shapes the person has drawn: a list where each row selects a shape (so\n * it can be edited with the keyboard from the draw tool), buttons to delete\n * the selected shape or all of them, an import from a GeoJSON, CSV or WKT file\n * (when the host supplies a file opener),\n * and the export buttons. Shapes are saved to a file or into a link only when\n * a button is pressed, a file is read only on this device, and the note says\n * so. The map fits to what an import added.\n */\nexport function ShapesSection({\n draw,\n headingLevel = 3,\n headingRef,\n}: ShapesSectionProps) {\n const { settings } = useSettings();\n const messages = useMessages();\n const { t } = messages;\n const { shapes, selection, feedback, importFeedback } = draw;\n const subLevel = (headingLevel + 1) as HeadingLevel;\n const fitToImport = useFitToImport();\n const canImport = useFileOpener() !== undefined;\n const readAs = importFeedback?.readAs;\n const orderRef = useRef<HTMLSelectElement>(null);\n const importFile = () => {\n // Called straight from the press, so the browser shows the picker.\n void draw.importFile().then((bounds) => {\n if (bounds) {\n fitToImport(bounds);\n }\n });\n };\n const reread = (order: WktAxisOrder) => {\n // The button that was pressed goes with the offer, so focus moves to the control it set.\n orderRef.current?.focus();\n const bounds = draw.rereadImport(order);\n if (bounds) {\n fitToImport(bounds);\n }\n };\n return (\n <Section\n title={t(\"panels.shapes.title\", {})}\n headingLevel={headingLevel}\n headingRef={headingRef}\n data-testid=\"sheet-section-shapes\"\n >\n {shapes.length === 0 ? (\n <p className={prose} data-testid=\"shapes-empty\">\n {t(\"panels.shapes.empty\", {})}\n </p>\n ) : (\n <ul\n className={list}\n aria-label={t(\"panels.shapes.listLabel\", {})}\n data-testid=\"shapes-list\"\n >\n {shapes.map((shape) => (\n <ListRow\n key={shape.id}\n label={\n shape.done\n ? shape.label\n : t(\"panels.shapes.unfinished\", { label: shape.label })\n }\n secondary={\n formatShapeMeasure(shape, settings.units, messages) || undefined\n }\n selected={selection?.shapeId === shape.id}\n data-testid=\"shapes-row\"\n onClick={() => draw.select(shape.id)}\n />\n ))}\n </ul>\n )}\n <div className={actions}>\n <Button\n variant=\"secondary\"\n icon={Trash2}\n disabled={selection === null}\n data-testid=\"shapes-delete\"\n onClick={draw.deleteSelected}\n >\n {t(\"panels.shapes.deleteSelected\", {})}\n </Button>\n <Button\n variant=\"secondary\"\n icon={Trash2}\n disabled={shapes.length === 0}\n data-testid=\"shapes-clear\"\n onClick={draw.clear}\n >\n {t(\"panels.shapes.deleteAll\", {})}\n </Button>\n </div>\n {canImport ? (\n <div className={subsection}>\n <Subheading level={subLevel}>\n {t(\"panels.shapes.importHeading\", {})}\n </Subheading>\n <label className={field}>\n {t(\"panels.shapes.axisOrderLabel\", {})}\n <select\n ref={orderRef}\n className={dateInput}\n value={draw.wktAxisOrder}\n data-testid=\"shapes-axis-order\"\n onChange={(event) =>\n draw.setWktAxisOrder(event.target.value as WktAxisOrder)\n }\n >\n <option value=\"lng-lat\">\n {t(\"panels.shapes.axisOrder.lng-lat\", {})}\n </option>\n <option value=\"lat-lng\">\n {t(\"panels.shapes.axisOrder.lat-lng\", {})}\n </option>\n </select>\n </label>\n <div className={actions}>\n <Button\n variant=\"secondary\"\n icon={FileUp}\n data-testid=\"shapes-import\"\n onClick={importFile}\n >\n {t(\"panels.shapes.import\", {})}\n </Button>\n </div>\n <Feedback feedback={importFeedback} testId=\"shapes-import-feedback\" />\n {readAs ? (\n <div className={actions}>\n <Button\n variant=\"secondary\"\n data-testid=\"shapes-import-reread\"\n onClick={() => reread(readAs)}\n >\n {t(REREAD_KEYS[readAs], {})}\n </Button>\n </div>\n ) : null}\n </div>\n ) : null}\n <div className={subsection}>\n <Subheading level={subLevel}>\n {t(\"panels.shapes.exportHeading\", {})}\n </Subheading>\n <div className={actions}>\n <Button\n variant=\"secondary\"\n icon={Download}\n data-testid=\"shapes-export-geojson\"\n onClick={() => void draw.exportGeoJson()}\n >\n {t(\"panels.shapes.downloadGeoJson\", {})}\n </Button>\n <Button\n variant=\"secondary\"\n icon={FileSpreadsheet}\n data-testid=\"shapes-export-csv\"\n onClick={() => void draw.exportCsv()}\n >\n {t(\"panels.shapes.downloadCsv\", {})}\n </Button>\n <Button\n variant=\"secondary\"\n icon={FileText}\n data-testid=\"shapes-export-wkt\"\n onClick={() => void draw.exportWkt()}\n >\n {t(\"panels.shapes.downloadWkt\", {})}\n </Button>\n <Button\n variant=\"secondary\"\n icon={Link}\n data-testid=\"shapes-copy-link\"\n onClick={() => void draw.copyLink()}\n >\n {t(\"panels.shapes.copyLink\", {})}\n </Button>\n </div>\n <Feedback feedback={feedback} testId=\"shapes-feedback\" />\n <p className={prose}>{t(\"panels.shapes.storageNote\", {})}</p>\n </div>\n </Section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4CA,IAAM,cAAc;CAClB,WAAW;CACX,WAAW;AACb;;AAGA,SAAS,SAAS,EAChB,UACA,UAIC;CACD,IAAI,CAAC,UACH,OAAO;CAET,OACE,qBAAC,KAAD;EAAG,WAAW;EAAM,eAAa;EAAjC,UAAA,CACE,oBAAC,MAAD;GACE,MAAM,SAAS,SAAS,UAAU,gBAAgB;GAClD,WAAW;EACZ,CAAA,GACD,oBAAC,QAAD,EAAA,UAAO,SAAS,KAAW,CAAA,CAC1B;;AAEP;;;;;AAMA,SAAS,iBAA2C;CAClD,MAAM,UAAU,WAAW,UAAU,CAAC,EAAE,WAAW;CACnD,MAAM,EAAE,QAAQ,UAAU,cAAc,gBAAgB;CACxD,MAAM,YAAY,oBAAoB;CACtC,QAAQ,WAAW;EACjB,IAAI,CAAC,SACH;EAEF,QAAQ,UAAU,QAAQ;GACxB,SAAA;GACA,SAAS,WAAW;IAAE;IAAQ;IAAU;IAAW;GAAU,CAAC;EAChE,CAAC;CACH;AACF;;;;;;;;;;AAWA,SAAgB,cAAc,EAC5B,MACA,eAAe,GACf,cACqB;CACrB,MAAM,EAAE,aAAa,YAAY;CACjC,MAAM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OAAD;MAAK,WAAW;MAAhB,UAAA;OACE,oBAAC,QAAD;QACE,SAAQ;QACR,MAAM;QACN,eAAY;QACZ,eAAe,KAAK,KAAK,cAAc;QAEtC,UAAA,EAAE,iCAAiC,CAAC,CAAC;OAChC,CAAA;OACR,oBAAC,QAAD;QACE,SAAQ;QACR,MAAM;QACN,eAAY;QACZ,eAAe,KAAK,KAAK,UAAU;QAElC,UAAA,EAAE,6BAA6B,CAAC,CAAC;OAC5B,CAAA;OACR,oBAAC,QAAD;QACE,SAAQ;QACR,MAAM;QACN,eAAY;QACZ,eAAe,KAAK,KAAK,UAAU;QAElC,UAAA,EAAE,6BAA6B,CAAC,CAAC;OAC5B,CAAA;OACR,oBAAC,QAAD;QACE,SAAQ;QACR,MAAM;QACN,eAAY;QACZ,eAAe,KAAK,KAAK,SAAS;QAEjC,UAAA,EAAE,0BAA0B,CAAC,CAAC;OACzB,CAAA;MACL;;KACL,oBAAC,UAAD;MAAoB;MAAU,QAAO;KAAmB,CAAA;KACxD,oBAAC,KAAD;MAAG,WAAW;MAAQ,UAAA,EAAE,6BAA6B,CAAC,CAAC;KAAK,CAAA;IACzD;;EACE;;AAEb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShapesSection.styles.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { LayersSection } from "../../layers/LayersSection.js";
|
|
2
|
+
import { useMessages, usePreferences } from "../../services/hooks.js";
|
|
3
|
+
import { drawingForImage } from "../../tools/DrawToolbar/imageDrawing.js";
|
|
4
|
+
import { BasemapPicker } from "../BasemapPicker/BasemapPicker.js";
|
|
5
|
+
import { ExportSection } from "../ExportSection/ExportSection.js";
|
|
6
|
+
import { HelpSection } from "../HelpSection/HelpSection.js";
|
|
7
|
+
import { PinSection } from "../PinSection/PinSection.js";
|
|
8
|
+
import { Section } from "../Section/Section.js";
|
|
9
|
+
import { SettingsSection } from "../SettingsSection/SettingsSection.js";
|
|
10
|
+
import { ShapesSection } from "../ShapesSection/ShapesSection.js";
|
|
11
|
+
import { content } from "./SheetContent.styles.js";
|
|
12
|
+
import { isSettingsSection } from "@mapcairn/core";
|
|
13
|
+
import { useEffect, useRef } from "react";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { useLatestRef } from "@mapcairn/react";
|
|
16
|
+
// src/panels/SheetContent/SheetContent.tsx
|
|
17
|
+
/**
|
|
18
|
+
* Everything inside the sheet, under its own h2 title, each part a `section`
|
|
19
|
+
* named by an h3. For the `settings` and `help` sections that is Settings
|
|
20
|
+
* and Help. Otherwise it is Basemap, Pin, Layers (only when the host has
|
|
21
|
+
* layers or a catalogue that loads), Shapes (only when the host offers drawing) and Save image.
|
|
22
|
+
*/
|
|
23
|
+
function SheetContent({ basemapId, onBasemapChange, hasPin, onDropPin, section, pinCard, layers, draw, onShowOnMap, showTurnOffAll, intro, imageCredits, privacyHref, privacyNote, onStartTour, about }) {
|
|
24
|
+
const { reducedMotion } = usePreferences();
|
|
25
|
+
const { t } = useMessages();
|
|
26
|
+
const headings = useRef({});
|
|
27
|
+
const reducedMotionRef = useLatestRef(reducedMotion);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const heading = section ? headings.current[section] : null;
|
|
30
|
+
if (!heading) return;
|
|
31
|
+
heading.focus({ preventScroll: true });
|
|
32
|
+
heading.scrollIntoView({
|
|
33
|
+
block: "start",
|
|
34
|
+
behavior: reducedMotionRef.current ? "auto" : "smooth"
|
|
35
|
+
});
|
|
36
|
+
}, [section, reducedMotionRef]);
|
|
37
|
+
const headingRef = (target) => (element) => {
|
|
38
|
+
headings.current[target] = element;
|
|
39
|
+
};
|
|
40
|
+
if (isSettingsSection(section ?? null)) return /* @__PURE__ */ jsxs("div", {
|
|
41
|
+
className: content,
|
|
42
|
+
"data-testid": "sheet-content",
|
|
43
|
+
children: [/* @__PURE__ */ jsx(SettingsSection, {
|
|
44
|
+
privacyHref,
|
|
45
|
+
privacyNote,
|
|
46
|
+
headingRef: headingRef("settings")
|
|
47
|
+
}), /* @__PURE__ */ jsx(HelpSection, {
|
|
48
|
+
headingRef: headingRef("help"),
|
|
49
|
+
onStartTour,
|
|
50
|
+
about
|
|
51
|
+
})]
|
|
52
|
+
});
|
|
53
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
54
|
+
className: content,
|
|
55
|
+
"data-testid": "sheet-content",
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsx(Section, {
|
|
58
|
+
title: t("panels.basemap.title", {}),
|
|
59
|
+
headingRef: headingRef("basemap"),
|
|
60
|
+
"data-testid": "sheet-section-basemap",
|
|
61
|
+
children: /* @__PURE__ */ jsx(BasemapPicker, {
|
|
62
|
+
value: basemapId,
|
|
63
|
+
onChange: onBasemapChange
|
|
64
|
+
})
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ jsx(PinSection, {
|
|
67
|
+
hasPin,
|
|
68
|
+
onDropPin,
|
|
69
|
+
headingRef: headingRef("pin"),
|
|
70
|
+
children: pinCard
|
|
71
|
+
}),
|
|
72
|
+
layers ? /* @__PURE__ */ jsx(LayersSection, {
|
|
73
|
+
layers,
|
|
74
|
+
headingRef: headingRef("layers"),
|
|
75
|
+
onShowOnMap,
|
|
76
|
+
showTurnOffAll,
|
|
77
|
+
intro
|
|
78
|
+
}) : null,
|
|
79
|
+
draw ? /* @__PURE__ */ jsx(ShapesSection, {
|
|
80
|
+
draw,
|
|
81
|
+
headingRef: headingRef("shapes")
|
|
82
|
+
}) : null,
|
|
83
|
+
/* @__PURE__ */ jsx(ExportSection, {
|
|
84
|
+
credits: imageCredits,
|
|
85
|
+
drawing: draw ? drawingForImage(draw.shapes) : void 0
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export { SheetContent };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=SheetContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetContent.js","names":[],"sources":["../../../src/panels/SheetContent/SheetContent.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport { isSettingsSection, type SheetSection } from \"@mapcairn/core\";\nimport { useLatestRef } from \"@mapcairn/react\";\nimport { type ReactNode, useEffect, useRef } from \"react\";\nimport { type DataLayers, LayersSection } from \"../../layers\";\nimport { useMessages, usePreferences } from \"../../services\";\nimport { drawingForImage, type UseDraw } from \"../../tools/DrawToolbar\";\nimport { BasemapPicker } from \"../BasemapPicker\";\nimport { ExportSection } from \"../ExportSection\";\nimport { type HelpAbout, HelpSection } from \"../HelpSection\";\nimport { PinSection } from \"../PinSection\";\nimport { Section } from \"../Section\";\nimport { SettingsSection } from \"../SettingsSection\";\nimport { ShapesSection } from \"../ShapesSection\";\nimport { content } from \"./SheetContent.css\";\n\n/** Props for {@link SheetContent}. */\nexport interface SheetContentProps {\n /** The chosen basemap id. */\n readonly basemapId: string;\n /** Called with the basemap id the user chose. */\n readonly onBasemapChange: (id: string) => void;\n /** Whether a pin is on the map. */\n readonly hasPin: boolean;\n /** Drops a pin at the centre of the map. */\n readonly onDropPin: () => void;\n /**\n * The section to bring into view, which also picks what the sheet holds:\n * Settings and Help for `settings` and `help`, and Basemap, Pin, Layers,\n * Shapes and Save image for any other section or none. When it changes, the\n * section scrolls to the top of the sheet and its heading takes focus.\n * Choosing the same section again while this component stays mounted does\n * nothing, so the caller should unmount the content when the sheet closes.\n */\n readonly section?: SheetSection;\n /** The pin's details, shown inside the Pin section. */\n readonly pinCard?: ReactNode;\n /**\n * The data layers, from `useDataLayers`. Without it, or for a host whose\n * catalogue was ready with no layers at mount, there is no Layers section;\n * a catalogue that loads shows its state there (loading, failed, empty).\n */\n readonly layers?: DataLayers;\n /**\n * The drawing, from `useDraw`. Without it there is no Shapes section.\n */\n readonly draw?: UseDraw;\n /** Called after \"Show on map\" in the Layers section, so the host can make room for the map. */\n readonly onShowOnMap?: () => void;\n /** Whether the Layers section offers \"Turn off all layers\" and the Undo after it. Defaults to true. */\n readonly showTurnOffAll?: boolean;\n /** The line above the layers, in place of \"Open data from public providers\", for a host whose layers are not that. */\n readonly intro?: string;\n /** The credits drawn into a saved map image (see `creditsLine`). */\n readonly imageCredits?: string;\n /** Where the privacy policy is. Defaults to `/privacy`. */\n readonly privacyHref?: string;\n /** The host's privacy statement for Settings, shown in place of the default. */\n readonly privacyNote?: ReactNode;\n /** Starts the first-visit tour from Help. Without it Help offers no tour. */\n readonly onStartTour?: () => void;\n /**\n * The host's About block for Help. Without it Help has none. Its link\n * address must be a trusted http or https one that the host supplies.\n */\n readonly about?: HelpAbout;\n}\n\n/**\n * Everything inside the sheet, under its own h2 title, each part a `section`\n * named by an h3. For the `settings` and `help` sections that is Settings\n * and Help. Otherwise it is Basemap, Pin, Layers (only when the host has\n * layers or a catalogue that loads), Shapes (only when the host offers drawing) and Save image.\n */\nexport function SheetContent({\n basemapId,\n onBasemapChange,\n hasPin,\n onDropPin,\n section,\n pinCard,\n layers,\n draw,\n onShowOnMap,\n showTurnOffAll,\n intro,\n imageCredits,\n privacyHref,\n privacyNote,\n onStartTour,\n about,\n}: SheetContentProps) {\n const { reducedMotion } = usePreferences();\n const { t } = useMessages();\n const headings = useRef<Partial<Record<SheetSection, HTMLElement | null>>>(\n {},\n );\n\n // Only a change of section moves focus and scroll, not a change in motion\n // preference, so it is read through the render that ran it.\n const reducedMotionRef = useLatestRef(reducedMotion);\n useEffect(() => {\n const heading = section ? headings.current[section] : null;\n if (!heading) {\n return;\n }\n heading.focus({ preventScroll: true });\n heading.scrollIntoView({\n block: \"start\",\n behavior: reducedMotionRef.current ? \"auto\" : \"smooth\",\n });\n }, [section, reducedMotionRef]);\n\n const headingRef =\n (target: SheetSection) => (element: HTMLElement | null) => {\n headings.current[target] = element;\n };\n\n if (isSettingsSection(section ?? null)) {\n return (\n <div className={content} data-testid=\"sheet-content\">\n <SettingsSection\n privacyHref={privacyHref}\n privacyNote={privacyNote}\n headingRef={headingRef(\"settings\")}\n />\n <HelpSection\n headingRef={headingRef(\"help\")}\n onStartTour={onStartTour}\n about={about}\n />\n </div>\n );\n }\n\n return (\n <div className={content} data-testid=\"sheet-content\">\n <Section\n title={t(\"panels.basemap.title\", {})}\n headingRef={headingRef(\"basemap\")}\n data-testid=\"sheet-section-basemap\"\n >\n <BasemapPicker value={basemapId} onChange={onBasemapChange} />\n </Section>\n <PinSection\n hasPin={hasPin}\n onDropPin={onDropPin}\n headingRef={headingRef(\"pin\")}\n >\n {pinCard}\n </PinSection>\n {layers ? (\n <LayersSection\n layers={layers}\n headingRef={headingRef(\"layers\")}\n onShowOnMap={onShowOnMap}\n showTurnOffAll={showTurnOffAll}\n intro={intro}\n />\n ) : null}\n {draw ? (\n <ShapesSection draw={draw} headingRef={headingRef(\"shapes\")} />\n ) : null}\n <ExportSection\n credits={imageCredits}\n drawing={draw ? drawingForImage(draw.shapes) : undefined}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2EA,SAAgB,aAAa,EAC3B,WACA,iBACA,QACA,WACA,SACA,SACA,QACA,MACA,aACA,gBACA,OACA,cACA,aACA,aACA,aACA,SACoB;CACpB,MAAM,EAAE,kBAAkB,eAAe;CACzC,MAAM,EAAE,MAAM,YAAY;CAC1B,MAAM,WAAW,OACf,CAAC,CACH;CAIA,MAAM,mBAAmB,aAAa,aAAa;CACnD,gBAAgB;EACd,MAAM,UAAU,UAAU,SAAS,QAAQ,WAAW;EACtD,IAAI,CAAC,SACH;EAEF,QAAQ,MAAM,EAAE,eAAe,KAAK,CAAC;EACrC,QAAQ,eAAe;GACrB,OAAO;GACP,UAAU,iBAAiB,UAAU,SAAS;EAChD,CAAC;CACH,GAAG,CAAC,SAAS,gBAAgB,CAAC;CAE9B,MAAM,cACH,YAA0B,YAAgC;EACzD,SAAS,QAAQ,UAAU;CAC7B;CAEF,IAAI,kBAAkB,WAAW,IAAI,GACnC,OACE,qBAAC,OAAD;EAAK,WAAW;EAAS,eAAY;EAArC,UAAA,CACE,oBAAC,iBAAD;GACe;GACA;GACb,YAAY,WAAW,UAAU;EAClC,CAAA,GACD,oBAAC,aAAD;GACE,YAAY,WAAW,MAAM;GAChB;GACN;EACR,CAAA,CACE;;CAIT,OACE,qBAAC,OAAD;EAAK,WAAW;EAAS,eAAY;EAArC,UAAA;GACE,oBAAC,SAAD;IACE,OAAO,EAAE,wBAAwB,CAAC,CAAC;IACnC,YAAY,WAAW,SAAS;IAChC,eAAY;IAEZ,UAAA,oBAAC,eAAD;KAAe,OAAO;KAAW,UAAU;IAAkB,CAAA;GACtD,CAAA;GACT,oBAAC,YAAD;IACU;IACG;IACX,YAAY,WAAW,KAAK;IAE3B,UAAA;GACS,CAAA;GACX,SACC,oBAAC,eAAD;IACU;IACR,YAAY,WAAW,QAAQ;IAClB;IACG;IACT;GACR,CAAA,IACC;GACH,OACC,oBAAC,eAAD;IAAqB;IAAM,YAAY,WAAW,QAAQ;GAAI,CAAA,IAC5D;GACJ,oBAAC,eAAD;IACE,SAAS;IACT,SAAS,OAAO,gBAAgB,KAAK,MAAM,IAAI,KAAA;GAChD,CAAA;EACE;;AAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetContent.styles.js","names":[],"sources":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ActiveMessagesProvider } from "./activeMessages.js";
|
|
2
|
+
import { BasemapAvailabilityProvider } from "./basemapAvailability.js";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/services/ServicesProvider.tsx
|
|
6
|
+
var ServicesContext = createContext(null);
|
|
7
|
+
/**
|
|
8
|
+
* Makes the app's services available to every component below it. This is the
|
|
9
|
+
* only way components reach adapters, browser services or map engines, so tests
|
|
10
|
+
* can swap in fakes by wrapping a tree in this provider. It also keeps which
|
|
11
|
+
* basemaps are not working (see `useBasemapAvailability`) and the active
|
|
12
|
+
* message catalogue (see `useMessages`).
|
|
13
|
+
*/
|
|
14
|
+
function ServicesProvider({ services, children }) {
|
|
15
|
+
return /* @__PURE__ */ jsx(ServicesContext.Provider, {
|
|
16
|
+
value: services,
|
|
17
|
+
children: /* @__PURE__ */ jsx(ActiveMessagesProvider, {
|
|
18
|
+
services,
|
|
19
|
+
children: /* @__PURE__ */ jsx(BasemapAvailabilityProvider, { children })
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the services. Throws when called outside a {@link ServicesProvider},
|
|
25
|
+
* because a missing provider is a wiring bug, not a runtime condition.
|
|
26
|
+
*/
|
|
27
|
+
function useServices() {
|
|
28
|
+
const services = useContext(ServicesContext);
|
|
29
|
+
if (!services) throw new Error("useServices must be used inside a ServicesProvider.");
|
|
30
|
+
return services;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the services, or null outside a {@link ServicesProvider}. For the
|
|
34
|
+
* few pieces, such as the live regions, that must still work when a test or
|
|
35
|
+
* a host mounts them without one.
|
|
36
|
+
*/
|
|
37
|
+
function useOptionalServices() {
|
|
38
|
+
return useContext(ServicesContext);
|
|
39
|
+
}
|
|
40
|
+
export { ServicesProvider, useOptionalServices, useServices };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=ServicesProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServicesProvider.js","names":[],"sources":["../../src/services/ServicesProvider.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport type { Services } from \"@mapcairn/core\";\nimport { createContext, type ReactNode, useContext } from \"react\";\nimport { ActiveMessagesProvider } from \"./activeMessages\";\nimport { BasemapAvailabilityProvider } from \"./basemapAvailability\";\n\nconst ServicesContext = createContext<Services | null>(null);\n\n/** Props for {@link ServicesProvider}. */\nexport interface ServicesProviderProps {\n /** Built once by the composition root, or by `createFakeServices` in tests. */\n readonly services: Services;\n readonly children: ReactNode;\n}\n\n/**\n * Makes the app's services available to every component below it. This is the\n * only way components reach adapters, browser services or map engines, so tests\n * can swap in fakes by wrapping a tree in this provider. It also keeps which\n * basemaps are not working (see `useBasemapAvailability`) and the active\n * message catalogue (see `useMessages`).\n */\nexport function ServicesProvider({\n services,\n children,\n}: ServicesProviderProps) {\n return (\n <ServicesContext.Provider value={services}>\n <ActiveMessagesProvider services={services}>\n <BasemapAvailabilityProvider>{children}</BasemapAvailabilityProvider>\n </ActiveMessagesProvider>\n </ServicesContext.Provider>\n );\n}\n\n/**\n * Returns the services. Throws when called outside a {@link ServicesProvider},\n * because a missing provider is a wiring bug, not a runtime condition.\n */\nexport function useServices(): Services {\n const services = useContext(ServicesContext);\n if (!services) {\n throw new Error(\"useServices must be used inside a ServicesProvider.\");\n }\n return services;\n}\n\n/**\n * Returns the services, or null outside a {@link ServicesProvider}. For the\n * few pieces, such as the live regions, that must still work when a test or\n * a host mounts them without one.\n */\nexport function useOptionalServices(): Services | null {\n return useContext(ServicesContext);\n}\n"],"mappings":";;;;;AAOA,IAAM,kBAAkB,cAA+B,IAAI;;;;;;;;AAgB3D,SAAgB,iBAAiB,EAC/B,UACA,YACwB;CACxB,OACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAC/B,UAAA,oBAAC,wBAAD;GAAkC;GAChC,UAAA,oBAAC,6BAAD,EAA8B,SAAsC,CAAA;EAC9C,CAAA;CACA,CAAA;AAE9B;;;;;AAMA,SAAgB,cAAwB;CACtC,MAAM,WAAW,WAAW,eAAe;CAC3C,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,qDAAqD;CAEvE,OAAO;AACT;;;;;;AAOA,SAAgB,sBAAuC;CACrD,OAAO,WAAW,eAAe;AACnC"}
|