@defra/interactive-map 0.0.3-alpha → 0.0.5-alpha
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/README.md +16 -57
- package/dist/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api/button-definition.md +176 -0
- package/docs/api/context.md +124 -0
- package/docs/api/control-definition.md +72 -0
- package/docs/api/icon-definition.md +28 -0
- package/docs/api/map-style-config.md +76 -0
- package/docs/api/marker-config.md +51 -0
- package/docs/api/panel-definition.md +117 -0
- package/docs/api/slots.md +25 -0
- package/docs/api.md +721 -0
- package/docs/architecture.md +139 -0
- package/docs/building-a-plugin.md +149 -0
- package/docs/getting-started.md +46 -0
- package/docs/govuk-prototype.md +0 -0
- package/docs/plugins/interact.md +205 -0
- package/docs/plugins/map-styles.md +84 -0
- package/docs/plugins/plugin-context.md +67 -0
- package/docs/plugins/plugin-descriptor.md +71 -0
- package/docs/plugins/plugin-manifest.md +118 -0
- package/docs/plugins/scale-bar.md +62 -0
- package/docs/plugins/search.md +162 -0
- package/docs/plugins.md +116 -0
- package/govuk-prototype-kit.config.json +7 -7
- package/package.json +16 -2
- package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +2 -0
- package/plugins/beta/datasets/dist/esm/index.js +2 -0
- package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +2 -0
- package/plugins/beta/datasets/dist/umd/index.js +2 -0
- package/plugins/beta/datasets/src/datasets.js +113 -0
- package/plugins/beta/datasets/src/fetch/createDynamicSource.js +206 -0
- package/plugins/beta/datasets/src/fetch/fetchGeoJSON.js +38 -0
- package/plugins/{datasets → beta/datasets}/src/handleSetMapStyle.js +8 -1
- package/plugins/{datasets → beta/datasets}/src/manifest.js +1 -1
- package/plugins/{datasets → beta/datasets}/src/mapLayers.js +42 -4
- package/plugins/{datasets → beta/datasets}/src/panels/Key.jsx +1 -1
- package/plugins/beta/datasets/src/utils/bbox.js +115 -0
- package/plugins/beta/draw-ml/dist/css/index.css +1 -0
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -0
- package/plugins/beta/draw-ml/dist/esm/index.js +2 -0
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -0
- package/plugins/beta/draw-ml/dist/umd/index.js +2 -0
- package/plugins/beta/draw-ml/src/api/addFeature.js +27 -0
- package/plugins/{draw-ml → beta/draw-ml}/src/api/editFeature.js +17 -6
- package/plugins/beta/draw-ml/src/api/merge.js +9 -0
- package/plugins/beta/draw-ml/src/api/newLine.js +68 -0
- package/plugins/beta/draw-ml/src/api/newPolygon.js +68 -0
- package/plugins/beta/draw-ml/src/api/split.js +81 -0
- package/plugins/{draw-ml → beta/draw-ml}/src/defaults.js +3 -0
- package/plugins/beta/draw-ml/src/draw.scss +32 -0
- package/plugins/beta/draw-ml/src/events.js +171 -0
- package/plugins/beta/draw-ml/src/manifest.js +132 -0
- package/plugins/{draw-ml → beta/draw-ml}/src/mapboxDraw.js +51 -2
- package/plugins/{draw-ml → beta/draw-ml}/src/mapboxSnap.js +18 -12
- package/plugins/beta/draw-ml/src/modes/createDrawMode.js +497 -0
- package/plugins/beta/draw-ml/src/modes/drawLineMode.js +18 -0
- package/plugins/beta/draw-ml/src/modes/drawPolygonMode.js +16 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/geometryHelpers.js +135 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/helpers.js +2 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +134 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/undoHandlers.js +133 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +141 -0
- package/plugins/beta/draw-ml/src/modes/editVertex/vertexQueries.js +121 -0
- package/plugins/beta/draw-ml/src/modes/editVertexMode.js +437 -0
- package/plugins/{draw-ml → beta/draw-ml}/src/reducer.js +30 -2
- package/plugins/{draw-ml → beta/draw-ml}/src/styles.js +66 -36
- package/plugins/beta/draw-ml/src/undoStack.js +50 -0
- package/plugins/beta/draw-ml/src/utils/debounce.js +16 -0
- package/plugins/beta/draw-ml/src/utils/flattenStyleProperties.js +49 -0
- package/plugins/beta/draw-ml/src/utils/spatial.js +258 -0
- package/plugins/beta/frame/dist/esm/im-frame-plugin.js +1 -0
- package/plugins/beta/frame/dist/esm/index.js +2 -0
- package/plugins/beta/frame/dist/umd/im-frame-plugin.js +1 -0
- package/plugins/beta/frame/dist/umd/index.js +2 -0
- package/plugins/{frame → beta/frame}/src/Frame.jsx +1 -1
- package/plugins/{map-styles → beta/map-styles}/dist/css/index.css +1 -1
- package/plugins/beta/map-styles/dist/esm/im-map-styles-plugin.js +1 -0
- package/plugins/beta/map-styles/dist/esm/index.js +2 -0
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -0
- package/plugins/beta/map-styles/dist/umd/index.js +2 -0
- package/plugins/{map-styles → beta/map-styles}/src/MapStyles.jsx +1 -1
- package/plugins/{map-styles → beta/map-styles}/src/manifest.js +8 -10
- package/plugins/{map-styles → beta/map-styles}/src/mapStyles.scss +4 -1
- package/plugins/beta/scale-bar/dist/esm/im-scale-bar-plugin.js +1 -0
- package/plugins/beta/scale-bar/dist/esm/index.js +2 -0
- package/plugins/beta/scale-bar/dist/umd/im-scale-bar-plugin.js +1 -0
- package/plugins/beta/scale-bar/dist/umd/index.js +2 -0
- package/plugins/beta/use-location/dist/esm/im-use-location-plugin.js +1 -0
- package/plugins/beta/use-location/dist/esm/index.js +2 -0
- package/plugins/beta/use-location/dist/umd/im-use-location-plugin.js +1 -0
- package/plugins/beta/use-location/dist/umd/index.js +2 -0
- package/plugins/interact/dist/css/index.css +1 -1
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/esm/index.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +1 -1
- package/plugins/interact/src/InteractInit.test.js +97 -0
- package/plugins/interact/src/api/clear.test.js +18 -0
- package/plugins/interact/src/api/disable.test.js +12 -0
- package/plugins/interact/src/api/enable.test.js +48 -0
- package/plugins/interact/src/api/selectFeature.test.js +33 -0
- package/plugins/interact/src/api/unselectFeature.test.js +33 -0
- package/plugins/interact/src/defaults.js +2 -0
- package/plugins/interact/src/events.js +37 -52
- package/plugins/interact/src/events.test.js +186 -0
- package/plugins/interact/src/hooks/useHighlightSync.js +1 -1
- package/plugins/interact/src/hooks/useHighlightSync.test.js +212 -0
- package/plugins/interact/src/hooks/useInteractionHandlers.js +80 -41
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +316 -0
- package/plugins/interact/src/index.test.js +22 -0
- package/plugins/interact/src/interact.scss +6 -0
- package/plugins/interact/src/manifest.js +1 -1
- package/plugins/interact/src/manifest.test.js +94 -0
- package/plugins/interact/src/reducer.js +28 -21
- package/plugins/interact/src/reducer.test.js +155 -0
- package/plugins/interact/src/utils/buildStylesMap.test.js +57 -0
- package/plugins/interact/src/utils/featureQueries.js +2 -2
- package/plugins/interact/src/utils/featureQueries.test.js +56 -0
- package/plugins/interact/src/utils/spatial.js +95 -0
- package/plugins/interact/src/utils/spatial.test.js +93 -0
- package/plugins/search/dist/css/index.css +1 -1
- package/plugins/search/dist/esm/im-search-plugin.js +1 -1
- package/plugins/search/dist/esm/index.js +1 -1
- package/plugins/search/dist/umd/im-search-plugin.js +1 -1
- package/plugins/search/dist/umd/index.js +1 -1
- package/plugins/search/src/Search.jsx +2 -2
- package/plugins/search/src/components/Form/Form.jsx +1 -1
- package/plugins/search/src/components/Suggestions/Suggestions.jsx +5 -5
- package/plugins/search/src/datasets.js +1 -1
- package/plugins/search/src/defaults.js +3 -0
- package/plugins/search/src/events/fetchSuggestions.js +48 -53
- package/plugins/search/src/events/formHandlers.js +3 -2
- package/plugins/search/src/events/index.js +1 -1
- package/plugins/search/src/events/inputHandlers.js +3 -1
- package/plugins/search/src/events/suggestionHandlers.js +12 -3
- package/plugins/search/src/search.scss +4 -1
- package/plugins/search/src/utils/parseOsNamesResults.js +15 -19
- package/providers/{esri → beta/esri}/src/esriProvider.js +1 -1
- package/providers/{esri → beta/esri}/src/index.js +1 -1
- package/providers/{esri → beta/esri}/src/mapEvents.js +2 -2
- package/providers/beta/open-names/dist/esm/im-reverse-geocode.js +2 -0
- package/providers/beta/open-names/dist/esm/index.js +2 -0
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js +2 -0
- package/providers/beta/open-names/dist/umd/im-reverse-geocode.js.LICENSE.txt +1 -0
- package/providers/beta/open-names/dist/umd/index.js +2 -0
- package/providers/beta/open-names/dist/umd/index.js.LICENSE.txt +1 -0
- package/providers/maplibre/dist/esm/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-framework.js.LICENSE.txt +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/esm/index.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-framework.js.LICENSE.txt +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/defaults.js +3 -2
- package/providers/maplibre/src/index.js +36 -20
- package/providers/maplibre/src/maplibreProvider.js +140 -11
- package/providers/maplibre/src/utils/detectWebgl.js +1 -2
- package/providers/maplibre/src/utils/highlightFeatures.js +78 -67
- package/providers/maplibre/src/utils/labels.js +174 -120
- package/providers/maplibre/src/utils/maplibreFixes.js +2 -2
- package/providers/maplibre/src/utils/queryFeatures.js +146 -0
- package/providers/maplibre/src/utils/spatial.js +14 -17
- package/sonar-project.properties +40 -3
- package/src/App/components/Actions/Actions.jsx +2 -2
- package/src/App/components/Actions/Actions.module.scss +2 -2
- package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +3 -1
- package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +9 -0
- package/src/App/components/Logo/Logo.jsx +1 -1
- package/src/App/components/MapButton/MapButton.jsx +217 -41
- package/src/App/components/MapButton/MapButton.module.scss +32 -21
- package/src/App/components/MapButton/MapButton.test.jsx +128 -84
- package/src/App/components/Markers/Markers.jsx +1 -1
- package/src/App/components/Markers/Markers.module.scss +0 -5
- package/src/App/components/Panel/Panel.jsx +75 -45
- package/src/App/components/Panel/Panel.module.scss +18 -24
- package/src/App/components/Panel/Panel.test.jsx +18 -0
- package/src/App/components/PopupMenu/PopupMenu.jsx +246 -0
- package/src/App/components/PopupMenu/PopupMenu.module.scss +70 -0
- package/src/App/components/PopupMenu/PopupMenu.test.jsx +304 -0
- package/src/App/components/Tooltip/Tooltip.jsx +4 -2
- package/src/App/components/Tooltip/getTooltipPosition.js +1 -1
- package/src/App/components/Viewport/MapController.jsx +1 -1
- package/src/App/components/Viewport/MapStatus.jsx +1 -1
- package/src/App/components/Viewport/Viewport.jsx +2 -2
- package/src/App/components/Viewport/Viewport.module.scss +2 -2
- package/src/App/controls/keyboardActions.js +3 -2
- package/src/App/controls/keyboardShortcuts.js +4 -2
- package/src/App/hooks/useButtonStateEvaluator.js +58 -45
- package/src/App/hooks/useButtonStateEvaluator.test.js +36 -3
- package/src/App/hooks/useCrossHairAPI.js +49 -47
- package/src/App/hooks/useFocusVisible.js +2 -2
- package/src/App/hooks/useInterfaceAPI.js +36 -1
- package/src/App/hooks/useKeyboardHint.js +1 -1
- package/src/App/hooks/useKeyboardShortcuts.js +4 -2
- package/src/App/hooks/useMapAnnouncements.js +34 -32
- package/src/App/hooks/useMapEvents.js +12 -1
- package/src/App/hooks/useMapProviderOverrides.js +3 -3
- package/src/App/hooks/useMapStateSync.js +7 -1
- package/src/App/hooks/useMapURLSync.js +6 -1
- package/src/App/hooks/useMarkersAPI.js +88 -50
- package/src/App/hooks/useMediaQueryDispatch.test.js +48 -0
- package/src/App/hooks/useModalPanelBehaviour.js +46 -40
- package/src/App/hooks/useResizeObserver.js +2 -2
- package/src/App/initialiseApp.js +45 -38
- package/src/App/layout/Layout.jsx +6 -4
- package/src/App/layout/layout.module.scss +13 -17
- package/src/App/registry/keyboardShortcutRegistry.js +12 -2
- package/src/App/registry/keyboardShortcutRegistry.test.js +28 -0
- package/src/App/registry/mergeManifests.js +1 -1
- package/src/App/registry/panelRegistry.js +1 -1
- package/src/App/registry/panelRegistry.test.js +30 -1
- package/src/App/registry/pluginRegistry.js +14 -51
- package/src/App/registry/pluginRegistry.test.js +54 -6
- package/src/App/renderer/HtmlElementHost.jsx +186 -0
- package/src/App/renderer/HtmlElementHost.test.jsx +231 -0
- package/src/App/renderer/mapButtons.js +12 -9
- package/src/App/renderer/mapButtons.test.js +6 -4
- package/src/App/renderer/mapControls.js +6 -0
- package/src/App/renderer/mapControls.test.js +10 -2
- package/src/App/renderer/mapPanels.js +39 -26
- package/src/App/renderer/mapPanels.test.js +29 -0
- package/src/App/renderer/pluginWrapper.test.js +28 -0
- package/src/App/renderer/slotHelpers.js +60 -0
- package/src/App/renderer/slotHelpers.test.js +82 -0
- package/src/App/store/AppProvider.jsx +3 -0
- package/src/App/store/AppProvider.test.jsx +40 -0
- package/src/App/store/PluginProvider.jsx +7 -5
- package/src/App/store/appActionsMap.js +46 -1
- package/src/App/store/appActionsMap.test.js +21 -0
- package/src/App/store/appReducer.js +1 -0
- package/src/App/store/mapActionsMap.js +12 -24
- package/src/App/store/mapReducer.js +1 -1
- package/src/InteractiveMap/InteractiveMap.js +194 -13
- package/src/InteractiveMap/InteractiveMap.test.js +164 -2
- package/src/InteractiveMap/behaviourController.js +12 -2
- package/src/InteractiveMap/behaviourController.test.js +82 -1
- package/src/InteractiveMap/deviceChecker.js +1 -1
- package/src/InteractiveMap/deviceChecker.test.js +2 -2
- package/src/InteractiveMap/historyManager.js +41 -5
- package/src/InteractiveMap/historyManager.test.js +37 -6
- package/src/InteractiveMap/polyfills.js +39 -0
- package/src/InteractiveMap/polyfills.test.js +127 -0
- package/src/config/appConfig.js +5 -5
- package/src/config/appConfig.test.js +107 -42
- package/src/config/defaults.js +30 -20
- package/src/config/events.js +110 -4
- package/src/index.js +5 -2
- package/src/index.umd.js +1 -1
- package/src/scss/main.scss +1 -0
- package/src/scss/settings/_dimensions.scss +6 -2
- package/src/scss/tools/_border-focus.scss +20 -4
- package/src/services/eventBus.test.js +24 -1
- package/src/test-utils.js +1 -0
- package/src/types.js +590 -0
- package/src/utils/detectBreakpoint.js +78 -77
- package/src/utils/detectBreakpoint.test.js +50 -4
- package/src/utils/detectInterfaceType.js +4 -4
- package/src/utils/getIsFullscreen.js +3 -1
- package/src/utils/getSafeZoneInset.js +23 -7
- package/src/utils/getSafeZoneInset.test.js +18 -0
- package/src/utils/mapStateSync.js +3 -3
- package/src/utils/queryString.js +1 -1
- package/src/utils/stringToKebab.js +1 -1
- package/src/utils/toggleInertElements.js +37 -12
- package/webpack.dev.mjs +3 -4
- package/webpack.esm.mjs +8 -8
- package/webpack.umd.mjs +8 -8
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +0 -1
- package/plugins/datasets/dist/esm/index.js +0 -2
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +0 -1
- package/plugins/datasets/dist/umd/index.js +0 -2
- package/plugins/datasets/src/datasets.js +0 -60
- package/plugins/datasets/src/utils/bbox.js +0 -4
- package/plugins/draw-ml/dist/css/index.css +0 -1
- package/plugins/draw-ml/dist/esm/im-draw-ml-plugin.js +0 -1
- package/plugins/draw-ml/dist/esm/index.js +0 -2
- package/plugins/draw-ml/dist/umd/im-draw-ml-plugin.js +0 -1
- package/plugins/draw-ml/dist/umd/index.js +0 -2
- package/plugins/draw-ml/src/api/addFeature.js +0 -15
- package/plugins/draw-ml/src/api/newPolygon.js +0 -43
- package/plugins/draw-ml/src/draw.scss +0 -9
- package/plugins/draw-ml/src/events.js +0 -127
- package/plugins/draw-ml/src/manifest.js +0 -100
- package/plugins/draw-ml/src/modes/drawVertexMode.js +0 -275
- package/plugins/draw-ml/src/modes/editVertexMode.js +0 -426
- package/plugins/draw-ml/src/utils.js +0 -102
- package/plugins/frame/dist/esm/im-frame-plugin.js +0 -1
- package/plugins/frame/dist/esm/index.js +0 -2
- package/plugins/frame/dist/umd/im-frame-plugin.js +0 -1
- package/plugins/frame/dist/umd/index.js +0 -2
- package/plugins/map-styles/dist/esm/im-map-styles-plugin.js +0 -1
- package/plugins/map-styles/dist/esm/index.js +0 -2
- package/plugins/map-styles/dist/umd/im-map-styles-plugin.js +0 -1
- package/plugins/map-styles/dist/umd/index.js +0 -2
- package/plugins/scale-bar/dist/esm/im-scale-bar-plugin.js +0 -1
- package/plugins/scale-bar/dist/esm/index.js +0 -2
- package/plugins/scale-bar/dist/umd/im-scale-bar-plugin.js +0 -1
- package/plugins/scale-bar/dist/umd/index.js +0 -2
- package/plugins/search/src/utils/fetchDataset.js +0 -23
- package/plugins/use-location/dist/esm/im-use-location-plugin.js +0 -1
- package/plugins/use-location/dist/esm/index.js +0 -2
- package/plugins/use-location/dist/umd/im-use-location-plugin.js +0 -1
- package/plugins/use-location/dist/umd/index.js +0 -2
- package/providers/maplibre/dist/esm/im-maplibre-legacy-framework.js +0 -1
- package/providers/maplibre/dist/umd/im-maplibre-legacy-framework.js +0 -1
- package/providers/open-names/dist/esm/im-reverse-geocode.js +0 -2
- package/providers/open-names/dist/esm/index.js +0 -2
- package/providers/open-names/dist/umd/im-reverse-geocode.js +0 -2
- package/providers/open-names/dist/umd/index.js +0 -2
- /package/docs/architecture/{ARCHITECTURE_DIAGRAMS.md → architecture-diagrams.md} +0 -0
- /package/plugins/{datasets → beta/datasets}/dist/css/index.css +0 -0
- /package/plugins/{datasets/dist/esm/index.js.LICENSE.txt → beta/datasets/dist/esm/im-datasets-plugin.js.LICENSE.txt} +0 -0
- /package/plugins/{datasets/dist/umd → beta/datasets/dist/esm}/index.js.LICENSE.txt +0 -0
- /package/plugins/{draw-ml/dist/esm/index.js.LICENSE.txt → beta/datasets/dist/umd/im-datasets-plugin.js.LICENSE.txt} +0 -0
- /package/plugins/{draw-ml → beta/datasets}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{datasets → beta/datasets}/src/DatasetsInit.jsx +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/addDataset.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/hideDataset.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/hideFeatures.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/removeDataset.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/showDataset.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/api/showFeatures.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/datasets.scss +0 -0
- /package/plugins/{datasets → beta/datasets}/src/defaults.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/index.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/panels/Key.module.scss +0 -0
- /package/plugins/{datasets → beta/datasets}/src/panels/Layers.jsx +0 -0
- /package/plugins/{datasets → beta/datasets}/src/panels/Layers.module.scss +0 -0
- /package/plugins/{datasets → beta/datasets}/src/reducer.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/utils/debounce.js +0 -0
- /package/plugins/{datasets → beta/datasets}/src/utils/filters.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/DrawInit.jsx +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/api/addFeature.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/api/deleteFeature.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/api/editFeature.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/api/newPolygon.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/events.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/graphic.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/index.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/manifest.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/reducer.js +0 -0
- /package/plugins/{draw-es → beta/draw-es}/src/sketchViewModel.js +0 -0
- /package/plugins/{frame → beta/draw-ml}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/plugins/{frame → beta/draw-ml}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{draw-ml → beta/draw-ml}/src/DrawInit.jsx +0 -0
- /package/plugins/{draw-ml → beta/draw-ml}/src/api/deleteFeature.js +0 -0
- /package/plugins/{draw-ml → beta/draw-ml}/src/index.js +0 -0
- /package/plugins/{draw-ml → beta/draw-ml}/src/modes/disabledMode.js +0 -0
- /package/plugins/{draw-ml/src → beta/draw-ml/src/utils}/snapHelpers.js +0 -0
- /package/plugins/{frame → beta/frame}/dist/css/index.css +0 -0
- /package/plugins/{map-styles → beta/frame}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/plugins/{map-styles → beta/frame}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{frame → beta/frame}/package.json +0 -0
- /package/plugins/{frame → beta/frame}/src/FrameInit.jsx +0 -0
- /package/plugins/{frame → beta/frame}/src/api/addFrame.js +0 -0
- /package/plugins/{frame → beta/frame}/src/api/editFeature.js +0 -0
- /package/plugins/{frame → beta/frame}/src/config.js +0 -0
- /package/plugins/{frame → beta/frame}/src/frame.scss +0 -0
- /package/plugins/{frame → beta/frame}/src/index.js +0 -0
- /package/plugins/{frame → beta/frame}/src/manifest.js +0 -0
- /package/plugins/{frame → beta/frame}/src/reducer.js +0 -0
- /package/plugins/{frame → beta/frame}/src/utils.js +0 -0
- /package/plugins/{scale-bar → beta/map-styles}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/plugins/{scale-bar → beta/map-styles}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{map-styles → beta/map-styles}/src/MapStylesInit.jsx +0 -0
- /package/plugins/{map-styles → beta/map-styles}/src/config.js +0 -0
- /package/plugins/{map-styles → beta/map-styles}/src/index.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/dist/css/index.css +0 -0
- /package/plugins/{use-location → beta/scale-bar}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/plugins/{use-location → beta/scale-bar}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/package.json +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/ScaleBar.jsx +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/ScaleBar.test.jsx +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/index.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/index.test.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/manifest.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/scaleBar.scss +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/utils.js +0 -0
- /package/plugins/{scale-bar → beta/scale-bar}/src/utils.test.js +0 -0
- /package/{providers/open-names → plugins/beta/use-location}/dist/esm/index.js.LICENSE.txt +0 -0
- /package/{providers/open-names → plugins/beta/use-location}/dist/umd/index.js.LICENSE.txt +0 -0
- /package/plugins/{use-location → beta/use-location}/src/UseLocation.jsx +0 -0
- /package/plugins/{use-location → beta/use-location}/src/UseLocationInit.jsx +0 -0
- /package/plugins/{use-location → beta/use-location}/src/defaults.js +0 -0
- /package/plugins/{use-location → beta/use-location}/src/events.js +0 -0
- /package/plugins/{use-location → beta/use-location}/src/index.js +0 -0
- /package/plugins/{use-location → beta/use-location}/src/manifest.js +0 -0
- /package/plugins/{use-location → beta/use-location}/src/reducer.js +0 -0
- /package/providers/{esri → beta/esri}/src/appEvents.js +0 -0
- /package/providers/{esri → beta/esri}/src/defaults.js +0 -0
- /package/providers/{esri → beta/esri}/src/esriProvider.scss +0 -0
- /package/providers/{esri → beta/esri}/src/utils/coords.js +0 -0
- /package/providers/{esri → beta/esri}/src/utils/detectWebGL.js +0 -0
- /package/providers/{esri → beta/esri}/src/utils/esriFixes.js +0 -0
- /package/providers/{esri → beta/esri}/src/utils/query.js +0 -0
- /package/providers/{esri → beta/esri}/src/utils/spatial.js +0 -0
- /package/providers/{open-names → beta/open-names}/dist/esm/im-reverse-geocode.js.LICENSE.txt +0 -0
- /package/providers/{open-names/dist/umd/im-reverse-geocode.js.LICENSE.txt → beta/open-names/dist/esm/index.js.LICENSE.txt} +0 -0
- /package/providers/{open-names → beta/open-names}/src/index.js +0 -0
- /package/providers/{open-names → beta/open-names}/src/reverseGeocode.js +0 -0
- /package/providers/{open-names → beta/open-names}/src/utils/mapToLocationModel.js +0 -0
|
@@ -26,23 +26,25 @@
|
|
|
26
26
|
$type: button
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
align-items: center;
|
|
29
|
+
display: flex;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
align-items: center;
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
padding-left: var(--button-padding);
|
|
34
|
+
padding-right: var(--button-padding);
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
pointer-events: auto;
|
|
37
|
+
color: var(--foreground-color);
|
|
38
|
+
background-color: var(--button-background-color);
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
min-height: var(--button-size);
|
|
41
|
+
min-width: var(--button-size);
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
user-select: none;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
|
|
46
|
+
&--primary[aria-disabled="true"], &--tertiary[aria-disabled="true"] {
|
|
47
|
+
opacity: var(--disabled-button-opacity);
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -66,9 +68,7 @@
|
|
|
66
68
|
transition: background-color var(--duration) ease;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
background-color: var(--button-hover-color);
|
|
71
|
-
}
|
|
71
|
+
background-color: var(--button-hover-color);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -134,6 +134,14 @@
|
|
|
134
134
|
@include tools.border-focus-corner-override($corners: 'top');
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
.im-c-button-wrapper--group-middle .im-c-map-button {
|
|
138
|
+
@include tools.border-focus-corner-override($corners: 'none');
|
|
139
|
+
|
|
140
|
+
&::before {
|
|
141
|
+
clip-path: inset(0 -20px 0 -20px);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
137
145
|
.im-c-button-wrapper--group-end .im-c-map-button {
|
|
138
146
|
margin-top: 0;
|
|
139
147
|
@include tools.border-focus-corner-override($corners: 'bottom');
|
|
@@ -150,6 +158,14 @@
|
|
|
150
158
|
@include tools.border-focus-corner-override($corners: 'left');
|
|
151
159
|
}
|
|
152
160
|
|
|
161
|
+
.im-c-button-wrapper--group-middle .im-c-map-button {
|
|
162
|
+
@include tools.border-focus-corner-override($corners: 'none');
|
|
163
|
+
|
|
164
|
+
&::before {
|
|
165
|
+
clip-path: inset(-20px 0 -20px 0);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
153
169
|
.im-c-button-wrapper--group-end .im-c-map-button {
|
|
154
170
|
@include tools.border-focus-corner-override($corners: 'right');
|
|
155
171
|
}
|
|
@@ -162,11 +178,6 @@
|
|
|
162
178
|
}
|
|
163
179
|
}
|
|
164
180
|
|
|
165
|
-
.im-c-map-button {
|
|
166
|
-
&--primary[aria-disabled="true"], &--tertiary[aria-disabled="true"] {
|
|
167
|
-
opacity: var(--disabled-button-opacity);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
181
|
|
|
171
182
|
.im-o-app__actions .im-c-map-button[aria-pressed="true"] {
|
|
172
183
|
color: var(--pressed-button-foreground-color);
|
|
@@ -3,55 +3,57 @@ import { render, screen, fireEvent } from '@testing-library/react'
|
|
|
3
3
|
import { MapButton } from './MapButton'
|
|
4
4
|
|
|
5
5
|
jest.mock('../../../utils/stringToKebab', () => ({
|
|
6
|
-
stringToKebab: (str) => str ? str.replace(/\s+/g, '-').toLowerCase() : ''
|
|
6
|
+
stringToKebab: (str) => (str ? str.replace(/\s+/g, '-').toLowerCase() : '')
|
|
7
7
|
}))
|
|
8
8
|
|
|
9
9
|
jest.mock('../Tooltip/Tooltip', () => ({
|
|
10
|
-
Tooltip: ({ content, children }) =>
|
|
10
|
+
Tooltip: ({ content, children }) => (
|
|
11
|
+
<div data-testid='tooltip' data-content={content}>{children}</div>
|
|
12
|
+
)
|
|
11
13
|
}))
|
|
12
14
|
|
|
13
15
|
jest.mock('../Icon/Icon', () => ({
|
|
14
|
-
Icon: ({ id, svgContent }) =>
|
|
16
|
+
Icon: ({ id, svgContent }) => (
|
|
17
|
+
<svg data-testid={id || 'custom-icon'} data-svg={svgContent} aria-hidden='true' />
|
|
18
|
+
)
|
|
15
19
|
}))
|
|
16
20
|
|
|
17
21
|
jest.mock('../../renderer/SlotRenderer', () => ({
|
|
18
22
|
SlotRenderer: ({ slot }) => <div data-testid='slot' data-slot={slot} />
|
|
19
23
|
}))
|
|
20
24
|
|
|
21
|
-
jest.mock('
|
|
22
|
-
|
|
25
|
+
jest.mock('../PopupMenu/PopupMenu', () => ({
|
|
26
|
+
PopupMenu: ({ startPos, items }) => {
|
|
27
|
+
let selectedIndex = -1
|
|
28
|
+
if (startPos === 'first' && items?.length > 0) {
|
|
29
|
+
selectedIndex = 0
|
|
30
|
+
}
|
|
31
|
+
if (startPos === 'last' && items?.length > 0) {
|
|
32
|
+
selectedIndex = items.length - 1
|
|
33
|
+
}
|
|
34
|
+
return <div data-testid='popup-menu' data-start-pos={String(startPos)} data-selected-index={String(selectedIndex)}>{items?.map((item, i) => <div key={i} data-testid={`menu-item-${i}`}>{item.label}</div>)}</div>
|
|
35
|
+
}
|
|
23
36
|
}))
|
|
24
37
|
|
|
38
|
+
jest.mock('../../store/configContext', () => ({ useConfig: () => ({ id: 'app' }) }))
|
|
39
|
+
|
|
25
40
|
const mockButtonRefs = { current: {} }
|
|
26
|
-
jest.mock('../../store/appContext', () => ({
|
|
27
|
-
useApp: () => ({ buttonRefs: mockButtonRefs })
|
|
28
|
-
}))
|
|
41
|
+
jest.mock('../../store/appContext', () => ({ useApp: () => ({ buttonRefs: mockButtonRefs }) }))
|
|
29
42
|
|
|
30
43
|
describe('MapButton', () => {
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
mockButtonRefs.current = {}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const renderButton = (props = {}) =>
|
|
36
|
-
render(<MapButton buttonId='Test' iconId='icon' label='Label' {...props} />)
|
|
44
|
+
beforeEach(() => { mockButtonRefs.current = {} })
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const button = screen.getByRole('button', { name: 'Label' })
|
|
41
|
-
expect(button).toHaveClass('im-c-map-button', 'im-c-map-button--my-button', 'im-c-map-button--primary', 'im-c-map-button--with-label')
|
|
42
|
-
expect(screen.getByTestId('icon')).toBeInTheDocument()
|
|
43
|
-
expect(screen.getByText('Label')).toBeInTheDocument()
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('renders Icon with svgContent when provided', () => {
|
|
47
|
-
renderButton({ iconId: null, iconSvgContent: '<circle />' })
|
|
48
|
-
expect(screen.getByTestId('custom-icon')).toHaveAttribute('data-svg', '<circle />')
|
|
49
|
-
})
|
|
46
|
+
const renderButton = (props = {}) => render(<MapButton buttonId='Test' iconId='icon' label='Label' {...props} />)
|
|
47
|
+
const getButton = () => screen.getByRole('button')
|
|
50
48
|
|
|
51
|
-
it(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
it.each([
|
|
50
|
+
[{ buttonId: 'My Button', variant: 'primary', showLabel: true }, ['im-c-map-button', 'im-c-map-button--my-button', 'im-c-map-button--primary', 'im-c-map-button--with-label']],
|
|
51
|
+
[{ iconId: null, iconSvgContent: '<circle />' }, []]
|
|
52
|
+
])('renders button variations and classes', (props, expectedClasses) => {
|
|
53
|
+
renderButton(props)
|
|
54
|
+
const button = getButton()
|
|
55
|
+
expectedClasses.forEach(cls => expect(button).toHaveClass(cls))
|
|
56
|
+
if (props.iconSvgContent) expect(screen.getByTestId('custom-icon')).toHaveAttribute('data-svg', props.iconSvgContent)
|
|
55
57
|
})
|
|
56
58
|
|
|
57
59
|
it('wraps in Tooltip when showLabel is false', () => {
|
|
@@ -59,7 +61,7 @@ describe('MapButton', () => {
|
|
|
59
61
|
expect(screen.getByTestId('tooltip')).toHaveAttribute('data-content', 'Label')
|
|
60
62
|
})
|
|
61
63
|
|
|
62
|
-
it('hides wrapper when isHidden
|
|
64
|
+
it('hides wrapper when isHidden', () => {
|
|
63
65
|
const { container } = renderButton({ isHidden: true })
|
|
64
66
|
expect(container.firstChild).toHaveStyle('display: none')
|
|
65
67
|
})
|
|
@@ -68,89 +70,131 @@ describe('MapButton', () => {
|
|
|
68
70
|
['groupStart', 'im-c-button-wrapper--group-start'],
|
|
69
71
|
['groupMiddle', 'im-c-button-wrapper--group-middle'],
|
|
70
72
|
['groupEnd', 'im-c-button-wrapper--group-end']
|
|
71
|
-
])('applies %s class', (prop, className) => {
|
|
73
|
+
])('applies wrapper %s class', (prop, className) => {
|
|
72
74
|
const { container } = renderButton({ [prop]: true })
|
|
73
75
|
expect(container.firstChild).toHaveClass(className)
|
|
74
76
|
})
|
|
75
77
|
|
|
76
|
-
it('
|
|
77
|
-
renderButton({ panelId: 'Settings', idPrefix: 'prefix', isDisabled: true,
|
|
78
|
-
const button =
|
|
78
|
+
it('handles panelId aria attributes', () => {
|
|
79
|
+
renderButton({ panelId: 'Settings', idPrefix: 'prefix', isDisabled: true, isPanelOpen: false })
|
|
80
|
+
const button = getButton()
|
|
79
81
|
expect(button).toHaveAttribute('aria-disabled', 'true')
|
|
80
|
-
expect(button).toHaveAttribute('aria-expanded', '
|
|
81
|
-
expect(button).toHaveAttribute('aria-pressed'
|
|
82
|
+
expect(button).toHaveAttribute('aria-expanded', 'false')
|
|
83
|
+
expect(button).not.toHaveAttribute('aria-pressed')
|
|
82
84
|
expect(button).toHaveAttribute('aria-controls', 'prefix-panel-settings')
|
|
83
85
|
expect(screen.getByTestId('slot')).toHaveAttribute('data-slot', 'test-button')
|
|
84
86
|
})
|
|
85
87
|
|
|
86
|
-
it(
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
it.each([
|
|
89
|
+
[{ isPressed: true }, 'true'],
|
|
90
|
+
[{ isPressed: 'true' }, undefined]
|
|
91
|
+
])('sets aria-pressed correctly', (props, expected) => {
|
|
92
|
+
renderButton(props)
|
|
93
|
+
const button = getButton()
|
|
94
|
+
if (expected) expect(button).toHaveAttribute('aria-pressed', expected)
|
|
95
|
+
else expect(button).not.toHaveAttribute('aria-pressed')
|
|
89
96
|
})
|
|
90
97
|
|
|
91
|
-
it('
|
|
92
|
-
renderButton({
|
|
93
|
-
expect(
|
|
98
|
+
it('sets aria-expanded when no panelId and isExpanded', () => {
|
|
99
|
+
renderButton({ isExpanded: true })
|
|
100
|
+
expect(getButton()).toHaveAttribute('aria-expanded', 'true')
|
|
94
101
|
})
|
|
95
102
|
|
|
96
|
-
it('
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
it('handles click events', () => {
|
|
104
|
+
const onClick = jest.fn()
|
|
105
|
+
renderButton({ onClick })
|
|
106
|
+
fireEvent.click(getButton())
|
|
107
|
+
expect(onClick).toHaveBeenCalled()
|
|
99
108
|
})
|
|
100
109
|
|
|
101
|
-
it('
|
|
102
|
-
const
|
|
103
|
-
renderButton({
|
|
104
|
-
fireEvent.click(
|
|
105
|
-
expect(
|
|
110
|
+
it('does not fire onClick or open popup when disabled', () => {
|
|
111
|
+
const onClick = jest.fn()
|
|
112
|
+
renderButton({ isDisabled: true, menuItems: [{ label: 'Item' }], onClick })
|
|
113
|
+
fireEvent.click(getButton())
|
|
114
|
+
expect(onClick).not.toHaveBeenCalled()
|
|
115
|
+
expect(screen.queryByTestId('popup-menu')).not.toBeInTheDocument()
|
|
106
116
|
})
|
|
107
117
|
|
|
108
|
-
it('stores button
|
|
118
|
+
it('stores button refs correctly', () => {
|
|
109
119
|
renderButton({ buttonId: 'TestButton' })
|
|
110
|
-
expect(mockButtonRefs.current.TestButton).toBe(
|
|
120
|
+
expect(mockButtonRefs.current.TestButton).toBe(getButton())
|
|
111
121
|
})
|
|
112
122
|
|
|
113
|
-
it('does not store ref
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// Should not throw
|
|
123
|
+
it('does not store ref if buttonId falsy', () => {
|
|
124
|
+
render(<MapButton buttonId={null} iconId='icon' label='Label' />)
|
|
125
|
+
expect(mockButtonRefs.current).toEqual({})
|
|
117
126
|
})
|
|
118
127
|
|
|
119
|
-
it('
|
|
120
|
-
renderButton({
|
|
121
|
-
const
|
|
122
|
-
expect(
|
|
123
|
-
expect(
|
|
124
|
-
expect(link).toHaveAttribute('target', '_blank')
|
|
128
|
+
it('handles popup aria attributes', () => {
|
|
129
|
+
renderButton({ idPrefix: 'prefix', menuItems: [{ label: 'Item' }] })
|
|
130
|
+
const button = getButton()
|
|
131
|
+
expect(button).toHaveAttribute('aria-controls', 'prefix-popup-test')
|
|
132
|
+
expect(button).toHaveAttribute('aria-haspopup', 'true')
|
|
125
133
|
})
|
|
126
134
|
|
|
127
|
-
it
|
|
128
|
-
renderButton({
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
it('toggles popup aria-expanded and startPos', () => {
|
|
136
|
+
renderButton({ menuItems: [{ label: 'Item' }] })
|
|
137
|
+
const button = getButton()
|
|
138
|
+
|
|
139
|
+
expect(button).toHaveAttribute('aria-expanded', 'false')
|
|
140
|
+
|
|
141
|
+
fireEvent.click(button)
|
|
142
|
+
expect(button).toHaveAttribute('aria-expanded', 'true')
|
|
143
|
+
expect(screen.getByTestId('popup-menu')).toHaveAttribute('data-start-pos', 'null')
|
|
144
|
+
|
|
145
|
+
fireEvent.click(button)
|
|
146
|
+
expect(button).toHaveAttribute('aria-expanded', 'false')
|
|
133
147
|
})
|
|
134
148
|
|
|
135
|
-
it(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
it.each([
|
|
150
|
+
['ArrowDown', 'first', 0],
|
|
151
|
+
['ArrowUp', 'last', 1]
|
|
152
|
+
])('keyboard menu navigation %s', (key, expectedPos, expectedIndex) => {
|
|
153
|
+
renderButton({ menuItems: [{ label: 'One' }, { label: 'Two' }] })
|
|
154
|
+
fireEvent.keyUp(getButton(), { key })
|
|
155
|
+
const menu = screen.getByTestId('popup-menu')
|
|
156
|
+
expect(menu).toHaveAttribute('data-start-pos', expectedPos)
|
|
157
|
+
expect(menu).toHaveAttribute('data-selected-index', String(expectedIndex))
|
|
141
158
|
})
|
|
142
159
|
|
|
143
|
-
it('does
|
|
160
|
+
it('does nothing for arrow keys when no menu', () => {
|
|
161
|
+
renderButton()
|
|
162
|
+
fireEvent.keyUp(getButton(), { key: 'ArrowDown' })
|
|
163
|
+
expect(screen.queryByTestId('popup-menu')).not.toBeInTheDocument()
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
it('does nothing for unrelated keys', () => {
|
|
167
|
+
renderButton({ menuItems: [{ label: 'Item' }] })
|
|
168
|
+
fireEvent.keyUp(getButton(), { key: 'Enter' })
|
|
169
|
+
expect(screen.queryByTestId('popup-menu')).not.toBeInTheDocument()
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
it.each([
|
|
173
|
+
['https://example.com', 'A'],
|
|
174
|
+
[null, 'BUTTON']
|
|
175
|
+
])('renders as anchor or button', (href, tag) => {
|
|
176
|
+
renderButton({ href })
|
|
177
|
+
const el = getButton()
|
|
178
|
+
expect(el.tagName).toBe(tag)
|
|
179
|
+
if (href) {
|
|
180
|
+
expect(el).toHaveAttribute('href', href)
|
|
181
|
+
expect(el).toHaveAttribute('target', '_blank')
|
|
182
|
+
} else expect(el).toHaveAttribute('type', 'button')
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it.each([[' '], ['Spacebar']])('triggers click on anchor key %s', (key) => {
|
|
144
186
|
renderButton({ href: 'https://example.com' })
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
187
|
+
const el = getButton()
|
|
188
|
+
const spy = jest.spyOn(el, 'click')
|
|
189
|
+
fireEvent.keyUp(el, { key })
|
|
190
|
+
expect(spy).toHaveBeenCalled()
|
|
148
191
|
})
|
|
149
192
|
|
|
150
|
-
it('
|
|
151
|
-
renderButton()
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
193
|
+
it('does not trigger click for other keys on anchor', () => {
|
|
194
|
+
renderButton({ href: 'https://example.com' })
|
|
195
|
+
const el = getButton()
|
|
196
|
+
const spy = jest.spyOn(el, 'click')
|
|
197
|
+
fireEvent.keyUp(el, { key: 'Enter' })
|
|
198
|
+
expect(spy).not.toHaveBeenCalled()
|
|
155
199
|
})
|
|
156
200
|
})
|
|
@@ -6,9 +6,58 @@ import { useModalPanelBehaviour } from '../../hooks/useModalPanelBehaviour.js'
|
|
|
6
6
|
import { useIsScrollable } from '../../hooks/useIsScrollable.js'
|
|
7
7
|
import { Icon } from '../Icon/Icon'
|
|
8
8
|
|
|
9
|
+
const computePanelState = (bpConfig, triggeringElement) => {
|
|
10
|
+
const isAside = bpConfig.slot === 'side' && bpConfig.initiallyOpen && !bpConfig.modal
|
|
11
|
+
const isDialog = !isAside && bpConfig.dismissable
|
|
12
|
+
const isModal = bpConfig.modal === true
|
|
13
|
+
const isDismissable = bpConfig.dismissable !== false
|
|
14
|
+
const shouldFocus = Boolean(isModal || triggeringElement)
|
|
15
|
+
const buttonContainerEl = bpConfig.slot.endsWith('button') ? triggeringElement?.parentNode : undefined
|
|
16
|
+
return { isAside, isDialog, isModal, isDismissable, shouldFocus, buttonContainerEl }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const getPanelRole = (isDialog, isDismissable) => {
|
|
20
|
+
if (isDialog) {
|
|
21
|
+
return 'dialog'
|
|
22
|
+
}
|
|
23
|
+
if (isDismissable) {
|
|
24
|
+
return 'complementary'
|
|
25
|
+
}
|
|
26
|
+
return 'region'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const buildPanelClassNames = (slot, showLabel) => [
|
|
30
|
+
'im-c-panel',
|
|
31
|
+
`im-c-panel--${slot}`,
|
|
32
|
+
!showLabel && 'im-c-panel--no-heading'
|
|
33
|
+
].filter(Boolean).join(' ')
|
|
34
|
+
|
|
35
|
+
const buildPanelBodyClassNames = (showLabel, isDismissable) => [
|
|
36
|
+
'im-c-panel__body',
|
|
37
|
+
!showLabel && isDismissable && 'im-c-panel__body--offset'
|
|
38
|
+
].filter(Boolean).join(' ')
|
|
39
|
+
|
|
40
|
+
const buildPanelProps = ({ elementId, shouldFocus, isDialog, isDismissable, isModal, width, panelClass }) => ({
|
|
41
|
+
id: elementId,
|
|
42
|
+
'aria-labelledby': `${elementId}-label`,
|
|
43
|
+
tabIndex: shouldFocus ? -1 : undefined, // nosonar
|
|
44
|
+
role: getPanelRole(isDialog, isDismissable),
|
|
45
|
+
'aria-modal': isDialog && isModal ? 'true' : undefined,
|
|
46
|
+
style: width ? { width } : undefined,
|
|
47
|
+
className: panelClass
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const buildBodyProps = ({ bodyRef, panelBodyClass, isBodyScrollable, elementId }) => ({
|
|
51
|
+
ref: bodyRef,
|
|
52
|
+
className: panelBodyClass,
|
|
53
|
+
tabIndex: isBodyScrollable ? 0 : undefined, // nosonar
|
|
54
|
+
role: isBodyScrollable ? 'region' : undefined,
|
|
55
|
+
'aria-labelledby': isBodyScrollable ? `${elementId}-label` : undefined
|
|
56
|
+
})
|
|
57
|
+
|
|
9
58
|
// eslint-disable-next-line camelcase, react/jsx-pascal-case
|
|
10
59
|
// sonarjs/disable-next-line function-name
|
|
11
|
-
export const Panel = ({ panelId, panelConfig, props, WrappedChild, label, html, children }) => {
|
|
60
|
+
export const Panel = ({ panelId, panelConfig, props, WrappedChild, label, html, children, isOpen = true, rootRef }) => {
|
|
12
61
|
const { id } = useConfig()
|
|
13
62
|
const { dispatch, breakpoint, layoutRefs } = useApp()
|
|
14
63
|
|
|
@@ -16,54 +65,48 @@ export const Panel = ({ panelId, panelConfig, props, WrappedChild, label, html,
|
|
|
16
65
|
const bpConfig = panelConfig[breakpoint]
|
|
17
66
|
const elementId = `${id}-panel-${stringToKebab(panelId)}`
|
|
18
67
|
|
|
19
|
-
const isAside
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const shouldFocus = Boolean(isModal || props?.triggeringElement)
|
|
68
|
+
const { isAside, isDialog, isModal, isDismissable, shouldFocus, buttonContainerEl } = computePanelState(bpConfig, props?.triggeringElement)
|
|
69
|
+
|
|
70
|
+
// For persistent panels, gate modal behaviour on open state
|
|
71
|
+
const isModalActive = isModal && isOpen
|
|
24
72
|
|
|
25
|
-
const buttonContainerEl = bpConfig.slot.endsWith('button') ? props?.triggeringElement?.parentNode : undefined
|
|
26
73
|
const mainRef = layoutRefs.mainRef
|
|
27
|
-
const
|
|
74
|
+
const internalPanelRef = useRef(null)
|
|
28
75
|
const bodyRef = useRef(null)
|
|
76
|
+
const prevIsOpenRef = useRef(isOpen)
|
|
29
77
|
const isBodyScrollable = useIsScrollable(bodyRef)
|
|
30
78
|
|
|
79
|
+
// Merge internal ref with optional external rootRef
|
|
80
|
+
const panelRef = rootRef || internalPanelRef
|
|
81
|
+
|
|
31
82
|
const handleClose = () => {
|
|
32
83
|
requestAnimationFrame(() => { (props?.triggeringElement || layoutRefs.viewportRef.current).focus?.() })
|
|
33
84
|
dispatch({ type: 'CLOSE_PANEL', payload: panelId })
|
|
34
85
|
}
|
|
35
86
|
|
|
36
|
-
useModalPanelBehaviour({ mainRef, panelRef, isModal, isAside, rootEl, buttonContainerEl, handleClose })
|
|
87
|
+
useModalPanelBehaviour({ mainRef, panelRef, isModal: isModalActive, isAside, rootEl, buttonContainerEl, handleClose })
|
|
37
88
|
|
|
38
89
|
useEffect(() => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, [])
|
|
90
|
+
// Focus on initial mount (non-persistent) or when isOpen transitions to true (persistent)
|
|
91
|
+
const justOpened = isOpen && !prevIsOpenRef.current
|
|
92
|
+
prevIsOpenRef.current = isOpen
|
|
43
93
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
].filter(Boolean).join(' ')
|
|
49
|
-
|
|
50
|
-
const panelBodyClass = [
|
|
51
|
-
'im-c-panel__body',
|
|
52
|
-
!panelConfig.showLabel && isDismissable && 'im-c-panel__body--offset'
|
|
53
|
-
].filter(Boolean).join(' ')
|
|
94
|
+
if (shouldFocus && (justOpened || isOpen)) {
|
|
95
|
+
panelRef.current?.focus()
|
|
96
|
+
}
|
|
97
|
+
}, [isOpen])
|
|
54
98
|
|
|
99
|
+
const panelClass = buildPanelClassNames(bpConfig.slot, panelConfig.showLabel)
|
|
100
|
+
const panelBodyClass = buildPanelBodyClassNames(panelConfig.showLabel, isDismissable)
|
|
55
101
|
const innerHtmlProp = useMemo(() => html ? { __html: html } : null, [html])
|
|
56
102
|
|
|
103
|
+
const panelProps = buildPanelProps({ elementId, shouldFocus, isDialog, isDismissable, isModal, width: bpConfig.width, panelClass })
|
|
104
|
+
const bodyProps = buildBodyProps({ bodyRef, panelBodyClass, isBodyScrollable, elementId })
|
|
105
|
+
|
|
57
106
|
return (
|
|
58
107
|
<div // nosonar
|
|
59
108
|
ref={panelRef}
|
|
60
|
-
|
|
61
|
-
aria-labelledby={`${elementId}-label`}
|
|
62
|
-
tabIndex={shouldFocus ? -1 : undefined} // nosonar
|
|
63
|
-
role={isDialog ? 'dialog' : (isDismissable && 'complementary') || 'region'}
|
|
64
|
-
aria-modal={isDialog && isModal ? 'true' : undefined}
|
|
65
|
-
style={bpConfig.width ? { width: bpConfig.width } : undefined}
|
|
66
|
-
className={panelClass}
|
|
109
|
+
{...panelProps}
|
|
67
110
|
>
|
|
68
111
|
<h2
|
|
69
112
|
id={`${elementId}-label`}
|
|
@@ -83,22 +126,9 @@ export const Panel = ({ panelId, panelConfig, props, WrappedChild, label, html,
|
|
|
83
126
|
)}
|
|
84
127
|
|
|
85
128
|
{innerHtmlProp
|
|
86
|
-
?
|
|
87
|
-
<div // nosonar
|
|
88
|
-
ref={bodyRef}
|
|
89
|
-
className={panelBodyClass}
|
|
90
|
-
tabIndex={isBodyScrollable ? 0 : undefined} // nosonar
|
|
91
|
-
dangerouslySetInnerHTML={innerHtmlProp}
|
|
92
|
-
/>
|
|
93
|
-
)
|
|
129
|
+
? <div {...bodyProps} dangerouslySetInnerHTML={innerHtmlProp} /> // nosonar
|
|
94
130
|
: (
|
|
95
|
-
<div
|
|
96
|
-
ref={bodyRef}
|
|
97
|
-
className={panelBodyClass}
|
|
98
|
-
tabIndex={isBodyScrollable ? 0 : undefined} // nosonar
|
|
99
|
-
role={isBodyScrollable ? 'region' : undefined}
|
|
100
|
-
aria-labelledby={isBodyScrollable ? `${elementId}-label` : undefined}
|
|
101
|
-
>
|
|
131
|
+
<div {...bodyProps}> {/* nosonar */}
|
|
102
132
|
{WrappedChild ? <WrappedChild {...props} /> : children}
|
|
103
133
|
</div>
|
|
104
134
|
)}
|
|
@@ -11,14 +11,12 @@
|
|
|
11
11
|
$type: panel
|
|
12
12
|
);
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
background-color: var(--background-color);
|
|
21
|
-
}
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
max-height: 100vh;
|
|
17
|
+
min-width: var(--min-panel-width);
|
|
18
|
+
pointer-events: auto;
|
|
19
|
+
background-color: var(--background-color);
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
// 2. Elements
|
|
@@ -39,22 +37,20 @@
|
|
|
39
37
|
$type: button
|
|
40
38
|
);
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
right: var(--panel-close-button-gap);
|
|
40
|
+
border: 0;
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: var(--panel-close-button-gap);
|
|
43
|
+
right: var(--panel-close-button-gap);
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
padding-left: var(--button-padding);
|
|
46
|
+
padding-right: var(--button-padding);
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
min-height: var(--button-size);
|
|
49
|
+
min-width: var(--button-size);
|
|
53
50
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
51
|
+
color: var(--foreground-color);
|
|
52
|
+
background-color: transparent;
|
|
53
|
+
cursor: pointer;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
.im-c-panel__body {
|
|
@@ -77,9 +73,7 @@
|
|
|
77
73
|
transition: background-color var(--duration) ease;
|
|
78
74
|
}
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
background-color: var(--button-hover-color);
|
|
82
|
-
}
|
|
76
|
+
background-color: var(--button-hover-color);
|
|
83
77
|
}
|
|
84
78
|
|
|
85
79
|
// 3. Modifiers
|
|
@@ -4,6 +4,7 @@ import { render, screen, fireEvent } from '@testing-library/react'
|
|
|
4
4
|
import { Panel } from './Panel'
|
|
5
5
|
import { useConfig } from '../../store/configContext'
|
|
6
6
|
import { useApp } from '../../store/appContext'
|
|
7
|
+
import { useIsScrollable } from '../../hooks/useIsScrollable.js'
|
|
7
8
|
|
|
8
9
|
jest.mock('../../store/configContext', () => ({ useConfig: jest.fn() }))
|
|
9
10
|
jest.mock('../../store/appContext', () => ({ useApp: jest.fn() }))
|
|
@@ -61,6 +62,23 @@ describe('Panel', () => {
|
|
|
61
62
|
renderPanel({ desktop: { slot: 'side', dismissable: true, initiallyOpen: true, width: '300px' } })
|
|
62
63
|
expect(screen.getByRole('complementary')).toHaveStyle({ width: '300px' })
|
|
63
64
|
})
|
|
65
|
+
|
|
66
|
+
it('adds scrollable attributes to body when content overflows', () => {
|
|
67
|
+
// 1. Force the mock to true ONLY for this test
|
|
68
|
+
useIsScrollable.mockReturnValue(true)
|
|
69
|
+
|
|
70
|
+
const { container } = renderPanel()
|
|
71
|
+
|
|
72
|
+
// 2. Target by class to avoid role collision with the parent panel
|
|
73
|
+
const body = container.querySelector('.im-c-panel__body')
|
|
74
|
+
|
|
75
|
+
expect(body).toHaveAttribute('tabIndex', '0')
|
|
76
|
+
expect(body).toHaveAttribute('role', 'region')
|
|
77
|
+
expect(body).toHaveAttribute('aria-labelledby', 'app-panel-settings-label')
|
|
78
|
+
|
|
79
|
+
// 3. IMPORTANT: Reset to false so other tests don't see two regions
|
|
80
|
+
useIsScrollable.mockReturnValue(false)
|
|
81
|
+
})
|
|
64
82
|
})
|
|
65
83
|
|
|
66
84
|
describe('role and aria attributes', () => {
|