@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 @@
|
|
|
1
|
+
{"version":3,"file":"selectionMessages.js","names":[],"sources":["../../src/layers/selectionMessages.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n announceFeatureDeselected,\n announceFeatureSelected,\n announceFeaturesDeselected,\n announceFeaturesSelected,\n announceSelectionCleared,\n announceSelectionFull,\n type FeatureRef,\n featureRefKey,\n type Message,\n} from \"@mapcairn/core\";\nimport type { AnnounceOptions } from \"../ui/LiveRegion\";\n\n/** What to say about one change to the selection, and how urgently. */\nexport interface SelectionAnnouncement {\n readonly message: Message;\n readonly options: AnnounceOptions;\n}\n\n/** The title to say for a reference, or null when it has none to give (it is not shown). */\nexport type TitleOf = (ref: FeatureRef) => string | null;\n\nfunction keysOf(refs: readonly FeatureRef[]): ReadonlySet<string> {\n return new Set(refs.map(featureRefKey));\n}\n\n/** The references of `refs` whose keys are not in `held`. */\nfunction missingFrom(\n held: ReadonlySet<string>,\n refs: readonly FeatureRef[],\n): readonly FeatureRef[] {\n return refs.filter((ref) => !held.has(featureRefKey(ref)));\n}\n\n/**\n * What an addition did, from the set before and after it: one message with\n * the new total when something was added, naming the feature when exactly one\n * was and it has a title. When nothing was added but `requested` held a\n * reference that was not already selected, the store refused the batch for\n * its `limit`, which is announced assertively, as a refused import is, so a\n * later polite message cannot replace it. When every reference was already\n * selected nothing changed, and nothing is said.\n */\nexport function addedAnnouncement(\n requested: readonly FeatureRef[],\n before: readonly FeatureRef[],\n after: readonly FeatureRef[],\n limit: number,\n titleOf: TitleOf,\n): SelectionAnnouncement | null {\n const held = keysOf(before);\n const added = missingFrom(held, after);\n if (added.length === 0) {\n return missingFrom(held, requested).length > 0\n ? {\n message: announceSelectionFull(limit),\n options: { priority: \"assertive\" },\n }\n : null;\n }\n const [only] = added;\n const title = added.length === 1 && only ? titleOf(only) : null;\n return {\n message:\n title === null\n ? announceFeaturesSelected(added.length, after.length)\n : announceFeatureSelected(title, after.length),\n options: { priority: \"polite\" },\n };\n}\n\n/** What a removal did, from the set before and after it: one message with the new total, or null when nothing was removed. */\nexport function removedAnnouncement(\n before: readonly FeatureRef[],\n after: readonly FeatureRef[],\n titleOf: TitleOf,\n): SelectionAnnouncement | null {\n const removed = missingFrom(keysOf(after), before);\n if (removed.length === 0) {\n return null;\n }\n const [only] = removed;\n const title = removed.length === 1 && only ? titleOf(only) : null;\n return {\n message:\n title === null\n ? announceFeaturesDeselected(removed.length, after.length)\n : announceFeatureDeselected(title, after.length),\n options: { priority: \"polite\" },\n };\n}\n\n/** What emptying the set did: \"Selection cleared.\", or null when it was already empty. */\nexport function clearedAnnouncement(\n before: readonly FeatureRef[],\n): SelectionAnnouncement | null {\n return before.length === 0\n ? null\n : { message: announceSelectionCleared(), options: { priority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
|
+
import { featureRefKey, isFeedLayer } from "@mapcairn/core";
|
|
2
|
+
// src/layers/selectionResolve.ts
|
|
3
|
+
/**
|
|
4
|
+
* The references whose layer is a feed layer in the list, whether it is on or
|
|
5
|
+
* not: the only ones a person can select. A reference to a tile, heatmap or
|
|
6
|
+
* vector tile layer, or to a layer not in the list, is dropped.
|
|
7
|
+
*/
|
|
8
|
+
function selectableRefs(refs, layers) {
|
|
9
|
+
const selectable = new Set(layers.filter((layer) => isFeedLayer(layer.definition)).map((layer) => layer.definition.id));
|
|
10
|
+
return refs.filter((ref) => selectable.has(ref.layerId));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Each features array indexed by feature id, once. The array a layer holds
|
|
14
|
+
* keeps its identity until the layer loads again, so a map move, which makes
|
|
15
|
+
* new layer states but not new features, indexes nothing.
|
|
16
|
+
*/
|
|
17
|
+
var indexes = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
function indexOf(features) {
|
|
19
|
+
let index = indexes.get(features);
|
|
20
|
+
if (!index) {
|
|
21
|
+
index = new Map(features.map((feature) => [feature.id, feature]));
|
|
22
|
+
indexes.set(features, index);
|
|
23
|
+
}
|
|
24
|
+
return index;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A lookup from a reference to what an enabled, selectable layer holds for it,
|
|
28
|
+
* or null when its layer is not in the list, is off or is not a feed layer.
|
|
29
|
+
*/
|
|
30
|
+
function lookupIn(layers) {
|
|
31
|
+
const byId = new Map(layers.map((layer) => [layer.definition.id, layer]));
|
|
32
|
+
return (ref) => {
|
|
33
|
+
const layer = byId.get(ref.layerId);
|
|
34
|
+
if (!layer?.enabled || !isFeedLayer(layer.definition)) return null;
|
|
35
|
+
return {
|
|
36
|
+
definition: layer.definition,
|
|
37
|
+
loaded: indexOf(layer.features).get(ref.featureId)
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Whether two entries are for the same reference and show the same feature of the same definition, or both show nothing. */
|
|
42
|
+
function sameEntry(previous, next) {
|
|
43
|
+
if (previous.status !== next.status || featureRefKey(previous.ref) !== featureRefKey(next.ref)) return false;
|
|
44
|
+
return previous.status === "not-shown" || next.status === "shown" && previous.feature === next.feature && previous.definition === next.definition;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The selected references resolved against the layers, in selection order. A
|
|
48
|
+
* reference shows its layer's loaded feature, else the snapshot kept for it,
|
|
49
|
+
* but only while its layer is on and selectable: a layer that is off, absent
|
|
50
|
+
* or not a feed layer leaves it not shown, whatever snapshot there is.
|
|
51
|
+
*
|
|
52
|
+
* Pass the `previous` result to keep what did not change: an entry that
|
|
53
|
+
* resolves to the same feature of the same definition is the previous entry
|
|
54
|
+
* itself, and when every entry is, so is the array. A map move makes new layer
|
|
55
|
+
* states with the same features, and the selection's consumers must not render
|
|
56
|
+
* for it.
|
|
57
|
+
*/
|
|
58
|
+
function resolveSelection(refs, layers, snapshots, previous = []) {
|
|
59
|
+
const lookup = lookupIn(layers);
|
|
60
|
+
const next = refs.map((ref, position) => {
|
|
61
|
+
const found = lookup(ref);
|
|
62
|
+
const feature = found?.loaded ?? snapshots.get(featureRefKey(ref));
|
|
63
|
+
const entry = found && feature ? {
|
|
64
|
+
status: "shown",
|
|
65
|
+
ref,
|
|
66
|
+
definition: found.definition,
|
|
67
|
+
feature
|
|
68
|
+
} : {
|
|
69
|
+
status: "not-shown",
|
|
70
|
+
ref
|
|
71
|
+
};
|
|
72
|
+
const kept = previous[position];
|
|
73
|
+
return kept && sameEntry(kept, entry) ? kept : entry;
|
|
74
|
+
});
|
|
75
|
+
return next.length === previous.length && next.every((entry, position) => entry === previous[position]) ? previous : next;
|
|
76
|
+
}
|
|
77
|
+
function sameSnapshots(left, right) {
|
|
78
|
+
if (left.size !== right.size) return false;
|
|
79
|
+
for (const [key, feature] of left) if (right.get(key) !== feature) return false;
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The snapshots for the selected references, given the layers as they are
|
|
84
|
+
* now: each reference's loaded feature when its layer lists one (taking the
|
|
85
|
+
* snapshot, or refreshing it), else the snapshot it had, so a feature a query
|
|
86
|
+
* layer stops listing, or a layer that is turned off, leaves it as it was. A
|
|
87
|
+
* reference no longer selected loses its snapshot. Returns `previous` itself
|
|
88
|
+
* when nothing changed, so storing the result in state causes no render.
|
|
89
|
+
*/
|
|
90
|
+
function reconcileSnapshots(previous, refs, layers) {
|
|
91
|
+
const lookup = lookupIn(layers);
|
|
92
|
+
const next = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const ref of refs) {
|
|
94
|
+
const key = featureRefKey(ref);
|
|
95
|
+
const feature = lookup(ref)?.loaded ?? previous.get(key);
|
|
96
|
+
if (feature) next.set(key, feature);
|
|
97
|
+
}
|
|
98
|
+
return sameSnapshots(previous, next) ? previous : next;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The references whose layer was in the catalogue's list `before` and is not
|
|
102
|
+
* in it `now`: the layers that were removed. A reference to a layer that was
|
|
103
|
+
* never in `before` is kept, because nothing was removed for it; it is a
|
|
104
|
+
* reference a store held before the list was known, or hydrated afterwards.
|
|
105
|
+
*/
|
|
106
|
+
function refsOfRemovedLayers(refs, before, now) {
|
|
107
|
+
return refs.filter((ref) => before.has(ref.layerId) && !now.has(ref.layerId));
|
|
108
|
+
}
|
|
109
|
+
export { reconcileSnapshots, refsOfRemovedLayers, resolveSelection, selectableRefs };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=selectionResolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionResolve.js","names":[],"sources":["../../src/layers/selectionResolve.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n type FeatureRef,\n featureRefKey,\n isFeedLayer,\n type LayerDefinition,\n type LayerFeature,\n} from \"@mapcairn/core\";\nimport type { DataLayerState } from \"./useDataLayers\";\n\n/** A selected reference whose feature can be shown, with the definition of the layer that holds it. */\nexport interface ShownSelection {\n readonly status: \"shown\";\n readonly ref: FeatureRef;\n readonly definition: LayerDefinition;\n readonly feature: LayerFeature;\n}\n\n/**\n * A selected reference with nothing to show: its layer is off, still loading,\n * not in the catalogue or not selectable. It stays selected and counts.\n */\nexport interface HiddenSelection {\n readonly status: \"not-shown\";\n readonly ref: FeatureRef;\n}\n\n/** One selected reference, resolved against the layers as they are now. */\nexport type SelectedEntry = ShownSelection | HiddenSelection;\n\n/** The features kept for selected references, by {@link featureRefKey}. */\nexport type SelectionSnapshots = ReadonlyMap<string, LayerFeature>;\n\n/**\n * The references whose layer is a feed layer in the list, whether it is on or\n * not: the only ones a person can select. A reference to a tile, heatmap or\n * vector tile layer, or to a layer not in the list, is dropped.\n */\nexport function selectableRefs(\n refs: readonly FeatureRef[],\n layers: readonly DataLayerState[],\n): readonly FeatureRef[] {\n const selectable = new Set(\n layers\n .filter((layer) => isFeedLayer(layer.definition))\n .map((layer) => layer.definition.id),\n );\n return refs.filter((ref) => selectable.has(ref.layerId));\n}\n\n/** What the layers hold for a reference: its layer's definition, and its loaded feature if the layer has it. */\ninterface Found {\n readonly definition: LayerDefinition;\n readonly loaded: LayerFeature | undefined;\n}\n\n/**\n * Each features array indexed by feature id, once. The array a layer holds\n * keeps its identity until the layer loads again, so a map move, which makes\n * new layer states but not new features, indexes nothing.\n */\nconst indexes = new WeakMap<\n readonly LayerFeature[],\n ReadonlyMap<string, LayerFeature>\n>();\n\nfunction indexOf(\n features: readonly LayerFeature[],\n): ReadonlyMap<string, LayerFeature> {\n let index = indexes.get(features);\n if (!index) {\n index = new Map(features.map((feature) => [feature.id, feature]));\n indexes.set(features, index);\n }\n return index;\n}\n\n/**\n * A lookup from a reference to what an enabled, selectable layer holds for it,\n * or null when its layer is not in the list, is off or is not a feed layer.\n */\nfunction lookupIn(\n layers: readonly DataLayerState[],\n): (ref: FeatureRef) => Found | null {\n const byId = new Map(layers.map((layer) => [layer.definition.id, layer]));\n return (ref) => {\n const layer = byId.get(ref.layerId);\n if (!layer?.enabled || !isFeedLayer(layer.definition)) {\n return null;\n }\n return {\n definition: layer.definition,\n loaded: indexOf(layer.features).get(ref.featureId),\n };\n };\n}\n\n/** Whether two entries are for the same reference and show the same feature of the same definition, or both show nothing. */\nfunction sameEntry(previous: SelectedEntry, next: SelectedEntry): boolean {\n if (\n previous.status !== next.status ||\n featureRefKey(previous.ref) !== featureRefKey(next.ref)\n ) {\n return false;\n }\n return (\n previous.status === \"not-shown\" ||\n (next.status === \"shown\" &&\n previous.feature === next.feature &&\n previous.definition === next.definition)\n );\n}\n\n/**\n * The selected references resolved against the layers, in selection order. A\n * reference shows its layer's loaded feature, else the snapshot kept for it,\n * but only while its layer is on and selectable: a layer that is off, absent\n * or not a feed layer leaves it not shown, whatever snapshot there is.\n *\n * Pass the `previous` result to keep what did not change: an entry that\n * resolves to the same feature of the same definition is the previous entry\n * itself, and when every entry is, so is the array. A map move makes new layer\n * states with the same features, and the selection's consumers must not render\n * for it.\n */\nexport function resolveSelection(\n refs: readonly FeatureRef[],\n layers: readonly DataLayerState[],\n snapshots: SelectionSnapshots,\n previous: readonly SelectedEntry[] = [],\n): readonly SelectedEntry[] {\n const lookup = lookupIn(layers);\n const next = refs.map((ref, position): SelectedEntry => {\n const found = lookup(ref);\n const feature = found?.loaded ?? snapshots.get(featureRefKey(ref));\n const entry: SelectedEntry =\n found && feature\n ? { status: \"shown\", ref, definition: found.definition, feature }\n : { status: \"not-shown\", ref };\n const kept = previous[position];\n return kept && sameEntry(kept, entry) ? kept : entry;\n });\n return next.length === previous.length &&\n next.every((entry, position) => entry === previous[position])\n ? previous\n : next;\n}\n\nfunction sameSnapshots(\n left: SelectionSnapshots,\n right: SelectionSnapshots,\n): boolean {\n if (left.size !== right.size) {\n return false;\n }\n for (const [key, feature] of left) {\n if (right.get(key) !== feature) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * The snapshots for the selected references, given the layers as they are\n * now: each reference's loaded feature when its layer lists one (taking the\n * snapshot, or refreshing it), else the snapshot it had, so a feature a query\n * layer stops listing, or a layer that is turned off, leaves it as it was. A\n * reference no longer selected loses its snapshot. Returns `previous` itself\n * when nothing changed, so storing the result in state causes no render.\n */\nexport function reconcileSnapshots(\n previous: SelectionSnapshots,\n refs: readonly FeatureRef[],\n layers: readonly DataLayerState[],\n): SelectionSnapshots {\n const lookup = lookupIn(layers);\n const next = new Map<string, LayerFeature>();\n for (const ref of refs) {\n const key = featureRefKey(ref);\n const feature = lookup(ref)?.loaded ?? previous.get(key);\n if (feature) {\n next.set(key, feature);\n }\n }\n return sameSnapshots(previous, next) ? previous : next;\n}\n\n/**\n * The references whose layer was in the catalogue's list `before` and is not\n * in it `now`: the layers that were removed. A reference to a layer that was\n * never in `before` is kept, because nothing was removed for it; it is a\n * reference a store held before the list was known, or hydrated afterwards.\n */\nexport function refsOfRemovedLayers(\n refs: readonly FeatureRef[],\n before: ReadonlySet<string>,\n now: ReadonlySet<string>,\n): readonly FeatureRef[] {\n return refs.filter((ref) => before.has(ref.layerId) && !now.has(ref.layerId));\n}\n"],"mappings":";;;;;;;AAuCA,SAAgB,eACd,MACA,QACuB;CACvB,MAAM,aAAa,IAAI,IACrB,OACG,QAAQ,UAAU,YAAY,MAAM,UAAU,CAAC,CAAC,CAChD,KAAK,UAAU,MAAM,WAAW,EAAE,CACvC;CACA,OAAO,KAAK,QAAQ,QAAQ,WAAW,IAAI,IAAI,OAAO,CAAC;AACzD;;;;;;AAaA,IAAM,0BAAU,IAAI,QAGlB;AAEF,SAAS,QACP,UACmC;CACnC,IAAI,QAAQ,QAAQ,IAAI,QAAQ;CAChC,IAAI,CAAC,OAAO;EACV,QAAQ,IAAI,IAAI,SAAS,KAAK,YAAY,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC;EAChE,QAAQ,IAAI,UAAU,KAAK;CAC7B;CACA,OAAO;AACT;;;;;AAMA,SAAS,SACP,QACmC;CACnC,MAAM,OAAO,IA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