@xgis/xgis-components 0.3.23 → 0.3.35
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 +18 -31
- package/dist/components/Navigation/CompassButtons.d.ts +1 -1
- package/dist/components/Navigation/HistoryButtons.d.ts +1 -1
- package/dist/components/Navigation/LocationButtons.d.ts +1 -1
- package/dist/components/Navigation/ZoomButtons.d.ts +1 -1
- package/dist/components/Navigation/geolocationUtils.d.ts +1 -1
- package/dist/components/Search/SearchComponent.d.ts +2 -0
- package/dist/components/Search/SearchView.d.ts +2 -0
- package/dist/components/Search/index.d.ts +1 -0
- package/dist/components/TopicList/TopicRow.d.ts +6 -4
- package/dist/components/TopicList/externalApps.d.ts +9 -0
- package/dist/components/TopicList/topicEntries.d.ts +16 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +252 -108
- package/dist/index.js.map +1 -1
- package/dist/style.css +36 -15
- package/package.json +4 -4
- package/dist/components/TopicList/topicSearch.d.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useMapViewStore, modeForSide, useBasemapStore, useBasemapTree, useComponentTranslate, BASEMAP_COMPONENT_ID, useTranslate, resolveActiveBasemapNode, useBasemapAvailability, basemapNodeIcon, BaseMapErrors, layerKey, SLOTS, useLayoutStore, Slot, SIDEPANEL_COMPONENT_ID, useUiStore, useTopicStore, useLayerStore, LAYERPANEL_COMPONENT_ID, MAPSWITCH_COMPONENT_ID, useConfigStore, wrapToRange, RADIANS_TO_DEGREES, useCapability, NAVIGATION_COMPONENT_ID, useParallelViewSync, activeEngine, useNavigationHistoryStore, extentCenter, selectSyncedGroup, wgs84ToEpsg3301, containsPoint, clampPointToBounds, epsg3301ToWgs84, translate, componentKey, DEGREES_TO_RADIANS, useGeolocationStore, useMapBusEmit, useUserMarkerStore, useZoomFloor, MAX_ZOOM, useMapBusEvent, NOTIFICATION_COMPONENT_ID, TOPICLIST_COMPONENT_ID } from '@xgis/xgis-common';
|
|
1
|
+
import { useMapViewStore, modeForSide, useBasemapStore, useBasemapTree, useComponentTranslate, BASEMAP_COMPONENT_ID, useTranslate, resolveActiveBasemapNode, useBasemapAvailability, basemapNodeIcon, BaseMapErrors, layerKey, SLOTS, useLayoutStore, Slot, SIDEPANEL_COMPONENT_ID, useUiStore, useTopicStore, useLayerStore, LAYERPANEL_COMPONENT_ID, MAPSWITCH_COMPONENT_ID, useConfigStore, wrapToRange, RADIANS_TO_DEGREES, useCapability, NAVIGATION_COMPONENT_ID, useParallelViewSync, useComponentSettingsStore, TOP_DOWN_PITCH, activeEngine, useNavigationHistoryStore, extentCenter, selectSyncedGroup, wgs84ToEpsg3301, containsPoint, clampPointToBounds, epsg3301ToWgs84, translate, componentKey, DEGREES_TO_RADIANS, useGeolocationStore, useMapBusEmit, useUserMarkerStore, useZoomFloor, MAX_ZOOM, useMapBusEvent, NOTIFICATION_COMPONENT_ID, SEARCH_COMPONENT_ID, useI18nStore, TOPICLIST_COMPONENT_ID, isSafeExternalUrl, openExternalUrl, EXTERNAL_LINK_REL } from '@xgis/xgis-common';
|
|
2
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { Tabs, Toggle, ButtonGroup, Button, Icon, Text, sendNotification, ToastContainer,
|
|
3
|
+
import { Tabs, Toggle, ButtonGroup, Button, Icon, Text, sendNotification, ToastContainer, InputGroup, Input, Search, Suffix, Card, CardButton, Collapse, TextField, Row, Col, Select } from '@tedi-design-system/react/tedi';
|
|
4
4
|
import { BaseMapSelection, MapAccordion, MapButton, ButtonGroup as ButtonGroup$1 } from '@tedi-design-system/react/community';
|
|
5
5
|
import { useState, useEffect, useCallback, useRef, useMemo } from 'react';
|
|
6
6
|
|
|
@@ -23,14 +23,14 @@ function BasemapIcon({ src, alt }) {
|
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function optionTooltip(status,
|
|
26
|
+
function optionTooltip(status, t) {
|
|
27
|
+
if (status?.reason === BaseMapErrors.SCALE) {
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
27
30
|
if (status?.reason) {
|
|
28
31
|
return t(`unavailable.${status.reason}`);
|
|
29
32
|
}
|
|
30
|
-
|
|
31
|
-
return t(`unavailable.${BaseMapErrors.SERVICE}`);
|
|
32
|
-
}
|
|
33
|
-
return "";
|
|
33
|
+
return void 0;
|
|
34
34
|
}
|
|
35
35
|
function nodeTitle(node, t) {
|
|
36
36
|
const key = node.kind === "folder" ? `${node.id}.label` : layerKey(node.id, "name.label");
|
|
@@ -44,13 +44,10 @@ function BasemapView({ componentId }) {
|
|
|
44
44
|
const activeBasemap3d = useBasemapStore((s) => s.activeBasemap3d);
|
|
45
45
|
const opacity2d = useBasemapStore((s) => s.opacity2d);
|
|
46
46
|
const opacity3d = useBasemapStore((s) => s.opacity3d);
|
|
47
|
-
const failedBasemap2d = useBasemapStore((s) => s.failedBasemap2d);
|
|
48
|
-
const failedBasemap3d = useBasemapStore((s) => s.failedBasemap3d);
|
|
49
47
|
const engine = activeMap === "parallel" ? activeParallellMap : activeMap;
|
|
50
48
|
const tree = useBasemapTree(engine, componentId);
|
|
51
49
|
const activeBasemap = engine === "3d" ? activeBasemap3d : activeBasemap2d;
|
|
52
50
|
const basemapOpacity = engine === "3d" ? opacity3d : opacity2d;
|
|
53
|
-
const failedBasemap = engine === "3d" ? failedBasemap3d : failedBasemap2d;
|
|
54
51
|
const setActiveBasemap = useBasemapStore((s) => s.setActiveBasemap);
|
|
55
52
|
const setBasemapOpacity = useBasemapStore((s) => s.setBasemapOpacity);
|
|
56
53
|
const t = useComponentTranslate(BASEMAP_COMPONENT_ID);
|
|
@@ -70,7 +67,6 @@ function BasemapView({ componentId }) {
|
|
|
70
67
|
onTransparencyChange: handleOpacityChange,
|
|
71
68
|
id: "basemap-button",
|
|
72
69
|
title: t("title"),
|
|
73
|
-
multiple: tree.length > 1,
|
|
74
70
|
showTransparency: true,
|
|
75
71
|
content: /* @__PURE__ */ jsx(
|
|
76
72
|
BasemapIcon,
|
|
@@ -83,7 +79,7 @@ function BasemapView({ componentId }) {
|
|
|
83
79
|
const id = node.id;
|
|
84
80
|
const status = availability.get(id);
|
|
85
81
|
const disabled = Boolean(status && !status.available && !status.pending);
|
|
86
|
-
const tooltip = optionTooltip(status,
|
|
82
|
+
const tooltip = optionTooltip(status, t);
|
|
87
83
|
const title = nodeTitle(node, tRoot);
|
|
88
84
|
return /* @__PURE__ */ jsx(
|
|
89
85
|
BaseMapSelection.Option,
|
|
@@ -92,7 +88,6 @@ function BasemapView({ componentId }) {
|
|
|
92
88
|
title,
|
|
93
89
|
id,
|
|
94
90
|
disabled,
|
|
95
|
-
multiple: node.kind === "folder",
|
|
96
91
|
selected: id === activeBasemap,
|
|
97
92
|
tooltipText: tooltip,
|
|
98
93
|
tooltipType: "error",
|
|
@@ -108,30 +103,26 @@ function BasemapView({ componentId }) {
|
|
|
108
103
|
}
|
|
109
104
|
|
|
110
105
|
const title$1 = "Base maps";
|
|
111
|
-
const enMessages$
|
|
106
|
+
const enMessages$6 = {
|
|
112
107
|
title: title$1,
|
|
113
108
|
"unavailable.crsUnsupported": "Not available in 3D",
|
|
114
109
|
"unavailable.capabilitiesFailed": "Base map service is unavailable",
|
|
115
|
-
"unavailable.outOfScale": "Unavailable at the current zoom level",
|
|
116
110
|
"unavailable.layerUnavailable": "Base map could not be loaded",
|
|
117
|
-
"unavailable.serviceError": "Map service has errors",
|
|
118
111
|
};
|
|
119
112
|
|
|
120
113
|
const title = "Aluskaardid";
|
|
121
|
-
const etMessages$
|
|
114
|
+
const etMessages$6 = {
|
|
122
115
|
title,
|
|
123
116
|
"unavailable.crsUnsupported": "Aluskaart ei toeta 3D vaadet",
|
|
124
117
|
"unavailable.capabilitiesFailed": "Kaarditeenus ei ole kättesaadav",
|
|
125
|
-
"unavailable.outOfScale": "Aluskaart ei ole nähtavusulatuses",
|
|
126
118
|
"unavailable.layerUnavailable": "Aluskaardi laadimine ebaõnnestus",
|
|
127
|
-
"unavailable.serviceError": "Kaarditeenuses esineb tõrkeid",
|
|
128
119
|
};
|
|
129
120
|
|
|
130
121
|
const BasemapComponent = {
|
|
131
122
|
id: BASEMAP_COMPONENT_ID,
|
|
132
123
|
messages: {
|
|
133
|
-
et: etMessages$
|
|
134
|
-
en: enMessages$
|
|
124
|
+
et: etMessages$6,
|
|
125
|
+
en: enMessages$6
|
|
135
126
|
},
|
|
136
127
|
ui: {
|
|
137
128
|
[SLOTS.BASEMAPS]: { Component: BasemapView }
|
|
@@ -168,12 +159,12 @@ const styles$3 = {
|
|
|
168
159
|
panel: panel
|
|
169
160
|
};
|
|
170
161
|
|
|
171
|
-
const enMessages$
|
|
162
|
+
const enMessages$5 = {
|
|
172
163
|
"tabs.aria": "Layer views",
|
|
173
164
|
"tabs.topic": "Theme map",
|
|
174
165
|
};
|
|
175
166
|
|
|
176
|
-
const etMessages$
|
|
167
|
+
const etMessages$5 = {
|
|
177
168
|
"tabs.aria": "Kihtide vaated",
|
|
178
169
|
"tabs.topic": "Teemakaart",
|
|
179
170
|
};
|
|
@@ -198,8 +189,8 @@ const SIDE_PANEL_SLOTS = {
|
|
|
198
189
|
const SidePanelComponent = {
|
|
199
190
|
id: SIDEPANEL_COMPONENT_ID,
|
|
200
191
|
messages: {
|
|
201
|
-
et: etMessages$
|
|
202
|
-
en: enMessages$
|
|
192
|
+
et: etMessages$5,
|
|
193
|
+
en: enMessages$5
|
|
203
194
|
},
|
|
204
195
|
ui: {
|
|
205
196
|
[SLOTS.SIDE_PANEL]: { Component: SidePanelView }
|
|
@@ -234,12 +225,12 @@ function MobileSidePanel() {
|
|
|
234
225
|
}
|
|
235
226
|
|
|
236
227
|
const layers$1 = "Layers";
|
|
237
|
-
const enMessages$
|
|
228
|
+
const enMessages$4 = {
|
|
238
229
|
layers: layers$1,
|
|
239
230
|
};
|
|
240
231
|
|
|
241
232
|
const layers = "Kihid";
|
|
242
|
-
const etMessages$
|
|
233
|
+
const etMessages$4 = {
|
|
243
234
|
layers,
|
|
244
235
|
};
|
|
245
236
|
|
|
@@ -294,8 +285,8 @@ function LayerPanelView(_props) {
|
|
|
294
285
|
const LayerPanelComponent = {
|
|
295
286
|
id: LAYERPANEL_COMPONENT_ID,
|
|
296
287
|
messages: {
|
|
297
|
-
et: etMessages$
|
|
298
|
-
en: enMessages$
|
|
288
|
+
et: etMessages$4,
|
|
289
|
+
en: enMessages$4
|
|
299
290
|
},
|
|
300
291
|
contributions: [{ target: SIDE_PANEL_SLOTS.LAYERS, Component: LayerPanelView }],
|
|
301
292
|
bookmark: {
|
|
@@ -306,7 +297,7 @@ const LayerPanelComponent = {
|
|
|
306
297
|
|
|
307
298
|
const ariaLabel$1 = "Map mode";
|
|
308
299
|
const parallel$1 = "Parallel view";
|
|
309
|
-
const enMessages$
|
|
300
|
+
const enMessages$3 = {
|
|
310
301
|
ariaLabel: ariaLabel$1,
|
|
311
302
|
"2d": "2D",
|
|
312
303
|
"3d": "3D",
|
|
@@ -315,7 +306,7 @@ const enMessages$2 = {
|
|
|
315
306
|
|
|
316
307
|
const ariaLabel = "Kaardirežiim";
|
|
317
308
|
const parallel = "Paralleelvaade";
|
|
318
|
-
const etMessages$
|
|
309
|
+
const etMessages$3 = {
|
|
319
310
|
ariaLabel,
|
|
320
311
|
"2d": "2D",
|
|
321
312
|
"3d": "3D",
|
|
@@ -383,8 +374,8 @@ function MapSwitchButtons({ layout }) {
|
|
|
383
374
|
const MapSwitchComponent = {
|
|
384
375
|
id: MAPSWITCH_COMPONENT_ID,
|
|
385
376
|
messages: {
|
|
386
|
-
et: etMessages$
|
|
387
|
-
en: enMessages$
|
|
377
|
+
et: etMessages$3,
|
|
378
|
+
en: enMessages$3
|
|
388
379
|
},
|
|
389
380
|
ui: {
|
|
390
381
|
[SLOTS.MAP_SWITCH]: { Component: MapSwitchButtons }
|
|
@@ -445,13 +436,18 @@ const styles$1 = {
|
|
|
445
436
|
};
|
|
446
437
|
|
|
447
438
|
const NORTH_ROTATION = 0;
|
|
448
|
-
const TOP_DOWN_PITCH = -Math.PI / 2;
|
|
449
439
|
const NORTH_ICON_REST_ROTATION_DEG = compassIconRotationDegrees(0);
|
|
450
440
|
function CompassButtons(_props) {
|
|
451
441
|
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
452
442
|
const rotation = useLiveRotation();
|
|
453
443
|
const defaultView = useMapViewStore((s) => s.defaultView);
|
|
444
|
+
const rotationAllowed = useMapViewStore((s) => s.rotationAllowed);
|
|
454
445
|
const { available, coupled, toggle } = useParallelViewSync();
|
|
446
|
+
const settings = useComponentSettingsStore(
|
|
447
|
+
(s) => s.getComponentSettings(NAVIGATION_COMPONENT_ID)
|
|
448
|
+
);
|
|
449
|
+
const showDefaultView = settings?.reset === true;
|
|
450
|
+
const showCompass = settings?.positioningCompass !== false && rotationAllowed;
|
|
455
451
|
const compassDeg = rotationToCompassDegrees(rotation);
|
|
456
452
|
const restoreInitialView = () => {
|
|
457
453
|
const { rotation: rotation2, pitch } = defaultView;
|
|
@@ -504,14 +500,17 @@ function CompassButtons(_props) {
|
|
|
504
500
|
onClick: toggle
|
|
505
501
|
}
|
|
506
502
|
] : void 0;
|
|
503
|
+
if (!showDefaultView && !showCompass) {
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
507
506
|
return /* @__PURE__ */ jsxs(
|
|
508
507
|
ButtonGroup$1,
|
|
509
508
|
{
|
|
510
509
|
direction: "vertical",
|
|
511
510
|
ariaLabel: t("orientationControls"),
|
|
512
|
-
suffix: `${compassDeg}
|
|
511
|
+
suffix: showCompass ? `${compassDeg}°` : void 0,
|
|
513
512
|
children: [
|
|
514
|
-
/* @__PURE__ */ jsx(
|
|
513
|
+
showDefaultView && /* @__PURE__ */ jsx(
|
|
515
514
|
MapButton,
|
|
516
515
|
{
|
|
517
516
|
size: "small",
|
|
@@ -522,7 +521,7 @@ function CompassButtons(_props) {
|
|
|
522
521
|
children: t("defaultView")
|
|
523
522
|
}
|
|
524
523
|
),
|
|
525
|
-
/* @__PURE__ */ jsx(
|
|
524
|
+
showCompass && /* @__PURE__ */ jsx(
|
|
526
525
|
MapButton,
|
|
527
526
|
{
|
|
528
527
|
size: "small",
|
|
@@ -591,6 +590,12 @@ function useNavigationHistory() {
|
|
|
591
590
|
function HistoryButtons(_props) {
|
|
592
591
|
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
593
592
|
const { canGoBack, canGoForward, back, forward } = useNavigationHistory();
|
|
593
|
+
const settings = useComponentSettingsStore(
|
|
594
|
+
(s) => s.getComponentSettings(NAVIGATION_COMPONENT_ID)
|
|
595
|
+
);
|
|
596
|
+
if (settings?.history === false) {
|
|
597
|
+
return null;
|
|
598
|
+
}
|
|
594
599
|
return /* @__PURE__ */ jsxs(ButtonGroup$1, { direction: "vertical", ariaLabel: t("historyControls"), children: [
|
|
595
600
|
/* @__PURE__ */ jsx(
|
|
596
601
|
MapButton,
|
|
@@ -639,7 +644,7 @@ const locationRationaleTooltip$1 = "Find your location";
|
|
|
639
644
|
const restoreNorth$1 = "Restore north";
|
|
640
645
|
const coupleViews$1 = "Lock map views";
|
|
641
646
|
const decoupleViews$1 = "Unlock";
|
|
642
|
-
const enMessages$
|
|
647
|
+
const enMessages$2 = {
|
|
643
648
|
zoomIn: zoomIn$1,
|
|
644
649
|
zoomOut: zoomOut$1,
|
|
645
650
|
back: back$3,
|
|
@@ -682,7 +687,7 @@ const locationRationaleTooltip = "Positsioneeri";
|
|
|
682
687
|
const restoreNorth = "Taasta põhjasuund";
|
|
683
688
|
const coupleViews = "Lukusta kaardivaated";
|
|
684
689
|
const decoupleViews = "Lukusta lahti";
|
|
685
|
-
const etMessages$
|
|
690
|
+
const etMessages$2 = {
|
|
686
691
|
zoomIn,
|
|
687
692
|
zoomOut,
|
|
688
693
|
back: back$2,
|
|
@@ -710,8 +715,8 @@ const MOVEMENT_THRESHOLD = 1e-4;
|
|
|
710
715
|
function hasMovedEnough(previous, next) {
|
|
711
716
|
return !previous || Math.abs(previous.lon - next.lon) > MOVEMENT_THRESHOLD || Math.abs(previous.lat - next.lat) > MOVEMENT_THRESHOLD;
|
|
712
717
|
}
|
|
713
|
-
function
|
|
714
|
-
return
|
|
718
|
+
function headingToRadians(headingDegrees) {
|
|
719
|
+
return headingDegrees * DEGREES_TO_RADIANS;
|
|
715
720
|
}
|
|
716
721
|
function geolocationErrorMessage(error) {
|
|
717
722
|
const key = error.code === PERMISSION_DENIED ? "locationDenied" : "locationError";
|
|
@@ -750,6 +755,7 @@ function useGeolocation() {
|
|
|
750
755
|
const emit = useMapBusEmit();
|
|
751
756
|
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
752
757
|
const setMarker = useUserMarkerStore((s) => s.setMarker);
|
|
758
|
+
const setHeading = useUserMarkerStore((s) => s.setHeading);
|
|
753
759
|
const trackingOutsideBounds = useRef(false);
|
|
754
760
|
const resolvePosition = useCallback(
|
|
755
761
|
(position) => {
|
|
@@ -781,10 +787,11 @@ function useGeolocation() {
|
|
|
781
787
|
stopWatch();
|
|
782
788
|
useGeolocationStore.getState().setPrevPosition(null);
|
|
783
789
|
setMarker(null);
|
|
790
|
+
setHeading(null);
|
|
784
791
|
useNavigationHistoryStore.getState().setExternalControl(false);
|
|
785
792
|
useGeolocationStore.getState().setLocated(false);
|
|
786
793
|
useGeolocationStore.getState().setTracking(false);
|
|
787
|
-
}, [setMarker, stopWatch]);
|
|
794
|
+
}, [setHeading, setMarker, stopWatch]);
|
|
788
795
|
const locate = useCallback(() => {
|
|
789
796
|
showRationaleOnce();
|
|
790
797
|
navigator.geolocation.getCurrentPosition(
|
|
@@ -809,22 +816,16 @@ function useGeolocation() {
|
|
|
809
816
|
const prevPosition = useGeolocationStore.getState().prevPosition;
|
|
810
817
|
const moved = hasMovedEnough(prevPosition, position);
|
|
811
818
|
const hasHeading = coords.heading !== null && !Number.isNaN(coords.heading);
|
|
812
|
-
if (!moved && !hasHeading) {
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
const next = {};
|
|
816
|
-
if (moved) {
|
|
817
|
-
next.flyToPositionIntent = { position: bounded, zoom: LOCATE_ZOOM };
|
|
818
|
-
}
|
|
819
819
|
if (hasHeading) {
|
|
820
|
-
|
|
820
|
+
setHeading(headingToRadians(coords.heading));
|
|
821
821
|
}
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
useGeolocationStore.getState().setPrevPosition(position);
|
|
822
|
+
if (!moved) {
|
|
823
|
+
return;
|
|
825
824
|
}
|
|
825
|
+
useMapViewStore.setState({ flyToPositionIntent: { position: bounded, zoom: LOCATE_ZOOM } });
|
|
826
|
+
useGeolocationStore.getState().setPrevPosition(position);
|
|
826
827
|
},
|
|
827
|
-
[resolvePosition, setMarker]
|
|
828
|
+
[resolvePosition, setHeading, setMarker]
|
|
828
829
|
);
|
|
829
830
|
const startTracking = useCallback(() => {
|
|
830
831
|
showRationaleOnce();
|
|
@@ -835,9 +836,10 @@ function useGeolocation() {
|
|
|
835
836
|
}, [handleTrackingPosition, showRationaleOnce]);
|
|
836
837
|
const stopTracking = useCallback(() => {
|
|
837
838
|
stopWatch();
|
|
839
|
+
setHeading(null);
|
|
838
840
|
useNavigationHistoryStore.getState().setExternalControl(false);
|
|
839
841
|
useGeolocationStore.getState().setTracking(false);
|
|
840
|
-
}, [stopWatch]);
|
|
842
|
+
}, [setHeading, stopWatch]);
|
|
841
843
|
const toggleTracking = useCallback(() => {
|
|
842
844
|
if (isTracking) {
|
|
843
845
|
stopTracking();
|
|
@@ -857,6 +859,12 @@ function useGeolocation() {
|
|
|
857
859
|
function LocationButtons(_props) {
|
|
858
860
|
const t = useComponentTranslate(NAVIGATION_COMPONENT_ID);
|
|
859
861
|
const { isLocated, isTracking, locate, toggleTracking, deactivate } = useGeolocation();
|
|
862
|
+
const settings = useComponentSettingsStore(
|
|
863
|
+
(s) => s.getComponentSettings(NAVIGATION_COMPONENT_ID)
|
|
864
|
+
);
|
|
865
|
+
if (settings?.positioning === false) {
|
|
866
|
+
return null;
|
|
867
|
+
}
|
|
860
868
|
return /* @__PURE__ */ jsxs(ButtonGroup$1, { direction: "vertical", ariaLabel: t("locationControls"), children: [
|
|
861
869
|
/* @__PURE__ */ jsx(
|
|
862
870
|
MapButton,
|
|
@@ -867,6 +875,7 @@ function LocationButtons(_props) {
|
|
|
867
875
|
tooltipContent: t("locationRationaleTooltip"),
|
|
868
876
|
isActive: isLocated,
|
|
869
877
|
onClick: isLocated ? deactivate : locate,
|
|
878
|
+
"data-testid": "nav-locate",
|
|
870
879
|
children: t("myLocation")
|
|
871
880
|
}
|
|
872
881
|
),
|
|
@@ -878,6 +887,7 @@ function LocationButtons(_props) {
|
|
|
878
887
|
icon: "emergency_share",
|
|
879
888
|
isActive: isTracking,
|
|
880
889
|
onClick: toggleTracking,
|
|
890
|
+
"data-testid": "nav-track",
|
|
881
891
|
children: t("trackLocation")
|
|
882
892
|
}
|
|
883
893
|
)
|
|
@@ -889,6 +899,12 @@ function ZoomButtons(_props) {
|
|
|
889
899
|
const zoom = useMapViewStore((s) => s.zoom);
|
|
890
900
|
const setZoom = useMapViewStore((s) => s.setZoom);
|
|
891
901
|
const zoomFloor = useZoomFloor();
|
|
902
|
+
const settings = useComponentSettingsStore(
|
|
903
|
+
(s) => s.getComponentSettings(NAVIGATION_COMPONENT_ID)
|
|
904
|
+
);
|
|
905
|
+
if (settings?.zoominout === false) {
|
|
906
|
+
return null;
|
|
907
|
+
}
|
|
892
908
|
return /* @__PURE__ */ jsxs(ButtonGroup$1, { direction: "vertical", ariaLabel: t("zoomControls"), children: [
|
|
893
909
|
/* @__PURE__ */ jsx(
|
|
894
910
|
MapButton,
|
|
@@ -920,8 +936,8 @@ function ZoomButtons(_props) {
|
|
|
920
936
|
const NavigationComponent = {
|
|
921
937
|
id: NAVIGATION_COMPONENT_ID,
|
|
922
938
|
messages: {
|
|
923
|
-
et: etMessages$
|
|
924
|
-
en: enMessages$
|
|
939
|
+
et: etMessages$2,
|
|
940
|
+
en: enMessages$2
|
|
925
941
|
},
|
|
926
942
|
ui: {
|
|
927
943
|
[SLOTS.NAVIGATION_ZOOM]: { Component: ZoomButtons },
|
|
@@ -958,6 +974,45 @@ const NotificationComponent = {
|
|
|
958
974
|
}
|
|
959
975
|
};
|
|
960
976
|
|
|
977
|
+
const search$1 = "Search";
|
|
978
|
+
const enMessages$1 = {
|
|
979
|
+
search: search$1,
|
|
980
|
+
};
|
|
981
|
+
|
|
982
|
+
const search = "Otsi";
|
|
983
|
+
const etMessages$1 = {
|
|
984
|
+
search,
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
function SearchView({ layout }) {
|
|
988
|
+
const t = useComponentTranslate(SEARCH_COMPONENT_ID);
|
|
989
|
+
const isDesktop = layout === "desktop";
|
|
990
|
+
return /* @__PURE__ */ jsxs(InputGroup, { id: "mocksearchgroup", label: "", children: [
|
|
991
|
+
/* @__PURE__ */ jsx(Input, { children: /* @__PURE__ */ jsx("div", { style: { maxWidth: 372, minWidth: 150 }, children: /* @__PURE__ */ jsx(Search, { id: "mocksearch", placeholder: t("search") }) }) }),
|
|
992
|
+
/* @__PURE__ */ jsx(Suffix, { children: /* @__PURE__ */ jsxs(Text, { color: "brand", children: [
|
|
993
|
+
/* @__PURE__ */ jsx(Icon, { name: "directions", display: "inline" }),
|
|
994
|
+
isDesktop && /* @__PURE__ */ jsx("span", { children: "Juhised" })
|
|
995
|
+
] }) }),
|
|
996
|
+
/* @__PURE__ */ jsx(Suffix, { children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
997
|
+
isDesktop && /* @__PURE__ */ jsx("span", { children: "Täpsem otsing " }),
|
|
998
|
+
/* @__PURE__ */ jsx(Icon, { name: "keyboard_arrow_down", display: "inline" })
|
|
999
|
+
] }) })
|
|
1000
|
+
] });
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
const SearchComponent = {
|
|
1004
|
+
id: SEARCH_COMPONENT_ID,
|
|
1005
|
+
messages: {
|
|
1006
|
+
et: etMessages$1,
|
|
1007
|
+
en: enMessages$1
|
|
1008
|
+
},
|
|
1009
|
+
contributions: [{ target: SLOTS.SEARCH, Component: SearchView }],
|
|
1010
|
+
bookmark: {
|
|
1011
|
+
serialize: () => ({ render: true }),
|
|
1012
|
+
deserialize: () => void 0
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
|
|
961
1016
|
const label$1 = "Theme map";
|
|
962
1017
|
const readMore$1 = "Read more";
|
|
963
1018
|
const readLess$1 = "Close";
|
|
@@ -986,17 +1041,91 @@ const etMessages = {
|
|
|
986
1041
|
back,
|
|
987
1042
|
};
|
|
988
1043
|
|
|
989
|
-
const
|
|
990
|
-
const
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1044
|
+
const TOKEN_PATTERN = /\$([a-z]+)\$/gi;
|
|
1045
|
+
const TOKEN_RESOLVERS = {
|
|
1046
|
+
bbox: (bbox) => bbox.map(Math.round).join(",")
|
|
1047
|
+
};
|
|
1048
|
+
function resolveExternalAppLink(link, bbox) {
|
|
1049
|
+
return link.replace(TOKEN_PATTERN, (match, token) => {
|
|
1050
|
+
const resolve = TOKEN_RESOLVERS[token.toLowerCase()];
|
|
1051
|
+
if (!resolve) {
|
|
1052
|
+
return match;
|
|
1053
|
+
}
|
|
1054
|
+
return resolve(bbox);
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
function localizedName(app, locale) {
|
|
1058
|
+
return app[`name_${locale}`] || app.name_et || app.name_en;
|
|
1059
|
+
}
|
|
1060
|
+
function useExternalApps() {
|
|
1061
|
+
const locale = useI18nStore((s) => s.locale);
|
|
1062
|
+
const settings = useComponentSettingsStore(
|
|
1063
|
+
(s) => s.getComponentSettings(TOPICLIST_COMPONENT_ID)
|
|
1064
|
+
);
|
|
1065
|
+
const apps = settings?.externalApps;
|
|
1066
|
+
return useMemo(() => {
|
|
1067
|
+
if (!apps?.length) {
|
|
1068
|
+
return [];
|
|
1069
|
+
}
|
|
1070
|
+
return apps.filter((app) => isSafeExternalUrl(app.link)).map((app) => ({
|
|
1071
|
+
link: app.link,
|
|
1072
|
+
name: localizedName(app, locale),
|
|
1073
|
+
target: app.target
|
|
1074
|
+
}));
|
|
1075
|
+
}, [apps, locale]);
|
|
1076
|
+
}
|
|
1077
|
+
function openExternalAppAtCurrentView(app) {
|
|
1078
|
+
const { bbox } = useMapViewStore.getState();
|
|
1079
|
+
openExternalUrl(resolveExternalAppLink(app.link, bbox), app.target);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
const EXTERNAL_ENTRY_PREFIX = "external:";
|
|
1083
|
+
function mergeTopicEntries(topics, apps, locale) {
|
|
1084
|
+
const entries = [
|
|
1085
|
+
...topics.map((topic) => ({
|
|
1086
|
+
kind: "topic",
|
|
1087
|
+
id: topic.id,
|
|
1088
|
+
label: topic.title,
|
|
1089
|
+
topic
|
|
1090
|
+
})),
|
|
1091
|
+
...apps.map((app, index) => ({
|
|
1092
|
+
kind: "externalApp",
|
|
1093
|
+
id: `${EXTERNAL_ENTRY_PREFIX}${index}:${app.link}`,
|
|
1094
|
+
label: app.name,
|
|
1095
|
+
app
|
|
1096
|
+
}))
|
|
1097
|
+
];
|
|
1098
|
+
const collator = new Intl.Collator(locale);
|
|
1099
|
+
return entries.sort((a, b) => collator.compare(a.label, b.label));
|
|
1100
|
+
}
|
|
1101
|
+
function filterTopicEntries(entries, query) {
|
|
1102
|
+
const needle = query.trim().toLowerCase();
|
|
1103
|
+
if (!needle) {
|
|
1104
|
+
return [...entries];
|
|
1105
|
+
}
|
|
1106
|
+
return entries.filter((entry) => entry.label.toLowerCase().includes(needle));
|
|
1107
|
+
}
|
|
1108
|
+
function useTopicEntries(query) {
|
|
1109
|
+
const topics = useTopicStore((s) => s.topics);
|
|
1110
|
+
const apps = useExternalApps();
|
|
1111
|
+
const locale = useI18nStore((s) => s.locale);
|
|
1112
|
+
return useMemo(
|
|
1113
|
+
() => filterTopicEntries(mergeTopicEntries(topics, apps, locale), query),
|
|
1114
|
+
[topics, apps, locale, query]
|
|
1115
|
+
);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
const menuPortal = "_menuPortal_4myfw_1";
|
|
1119
|
+
const trigger = "_trigger_4myfw_5";
|
|
1120
|
+
const picker = "_picker_4myfw_9";
|
|
1121
|
+
const pickerList = "_pickerList_4myfw_16";
|
|
1122
|
+
const pickerSearch = "_pickerSearch_4myfw_22";
|
|
1123
|
+
const pickerEmpty = "_pickerEmpty_4myfw_26";
|
|
1124
|
+
const row = "_row_4myfw_30";
|
|
1125
|
+
const rowActive = "_rowActive_4myfw_35";
|
|
1126
|
+
const rowOpenNotActive = "_rowOpenNotActive_4myfw_39";
|
|
1127
|
+
const rowDescription = "_rowDescription_4myfw_64";
|
|
1128
|
+
const pickerFooter = "_pickerFooter_4myfw_68";
|
|
1000
1129
|
const styles = {
|
|
1001
1130
|
menuPortal: menuPortal,
|
|
1002
1131
|
trigger: trigger,
|
|
@@ -1032,54 +1161,63 @@ function rowClassName(isActive, isOpen) {
|
|
|
1032
1161
|
}
|
|
1033
1162
|
return styles.row;
|
|
1034
1163
|
}
|
|
1035
|
-
function TopicRow({
|
|
1036
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
1164
|
+
function TopicRow({ entry, activeTopicId, isOpen, onSelect, onToggle }) {
|
|
1037
1165
|
const t = useComponentTranslate(TOPICLIST_COMPONENT_ID);
|
|
1166
|
+
const isActive = entry.kind === "topic" && entry.topic.id === activeTopicId;
|
|
1167
|
+
const description = entry.kind === "topic" ? entry.topic.description : void 0;
|
|
1038
1168
|
const background = rowBackground(isActive, isOpen);
|
|
1039
|
-
const textColor = isActive ? "white" : "primary";
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
|
|
1169
|
+
const textColor = isActive ? "white" : isOpen ? "info" : "primary";
|
|
1170
|
+
const card = /* @__PURE__ */ jsx(Card, { borderless: true, background, children: /* @__PURE__ */ jsx(Card.Content, { padding: { vertical: 0.75, horizontal: 1 }, background, children: /* @__PURE__ */ jsx(Text, { color: textColor, children: entry.label }) }) });
|
|
1171
|
+
const title = entry.kind === "externalApp" ? /* @__PURE__ */ jsx(
|
|
1172
|
+
CardButton,
|
|
1173
|
+
{
|
|
1174
|
+
as: "a",
|
|
1175
|
+
href: entry.app.link,
|
|
1176
|
+
target: entry.app.target,
|
|
1177
|
+
rel: EXTERNAL_LINK_REL,
|
|
1178
|
+
onClick: (event) => {
|
|
1179
|
+
event.preventDefault();
|
|
1180
|
+
openExternalAppAtCurrentView(entry.app);
|
|
1181
|
+
},
|
|
1182
|
+
children: card
|
|
1183
|
+
}
|
|
1184
|
+
) : /* @__PURE__ */ jsx(CardButton, { onClick: () => onSelect(entry.topic.id), children: card });
|
|
1185
|
+
if (!description) {
|
|
1186
|
+
return /* @__PURE__ */ jsx("div", { className: rowClassName(isActive, false), "data-topic-id": entry.id, children: title });
|
|
1043
1187
|
}
|
|
1044
|
-
return /* @__PURE__ */ jsx("div", { className: rowClassName(isActive, isOpen), "data-topic-id":
|
|
1188
|
+
return /* @__PURE__ */ jsx("div", { className: rowClassName(isActive, isOpen), "data-topic-id": entry.id, children: /* @__PURE__ */ jsx(
|
|
1045
1189
|
Collapse,
|
|
1046
1190
|
{
|
|
1047
|
-
id: `topic-description-${
|
|
1191
|
+
id: `topic-description-${entry.id}`,
|
|
1048
1192
|
title,
|
|
1049
1193
|
open: isOpen,
|
|
1050
|
-
onToggle
|
|
1194
|
+
onToggle,
|
|
1051
1195
|
openText: t("readMore"),
|
|
1052
1196
|
closeText: t("readLess"),
|
|
1053
1197
|
inverted: isActive,
|
|
1054
1198
|
underline: false,
|
|
1055
1199
|
size: "small",
|
|
1056
|
-
children: /* @__PURE__ */ jsx("div", { className: styles.rowDescription, children: /* @__PURE__ */ jsx(Text, { color: textColor, modifiers: "small", children:
|
|
1200
|
+
children: /* @__PURE__ */ jsx("div", { className: styles.rowDescription, children: /* @__PURE__ */ jsx(Text, { color: textColor, modifiers: "small", children: description }) })
|
|
1057
1201
|
}
|
|
1058
1202
|
) });
|
|
1059
1203
|
}
|
|
1060
1204
|
|
|
1061
|
-
function filterTopics(topics, query) {
|
|
1062
|
-
const needle = query.trim().toLowerCase();
|
|
1063
|
-
if (!needle) {
|
|
1064
|
-
return [...topics];
|
|
1065
|
-
}
|
|
1066
|
-
return topics.filter((topic) => topic.title.toLowerCase().includes(needle));
|
|
1067
|
-
}
|
|
1068
|
-
function useFilteredTopics(query) {
|
|
1069
|
-
const topics = useTopicStore((s) => s.topics);
|
|
1070
|
-
return useMemo(() => filterTopics(topics, query), [topics, query]);
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
1205
|
function TopicPicker() {
|
|
1074
1206
|
const [query, setQuery] = useState("");
|
|
1207
|
+
const [openEntryId, setOpenEntryId] = useState(null);
|
|
1075
1208
|
const activeTopicId = useTopicStore((s) => s.activeTopicId);
|
|
1076
1209
|
const setActiveTopicId = useTopicStore((s) => s.setActiveTopicId);
|
|
1077
1210
|
const setTopicPickerOpen = useUiStore((s) => s.setTopicPickerOpen);
|
|
1211
|
+
const setLayersSheetOpen = useUiStore((s) => s.setLayersSheetOpen);
|
|
1078
1212
|
const t = useComponentTranslate(TOPICLIST_COMPONENT_ID);
|
|
1079
|
-
const
|
|
1213
|
+
const entries = useTopicEntries(query);
|
|
1080
1214
|
function handleSelect(topicId) {
|
|
1081
1215
|
setActiveTopicId(topicId);
|
|
1082
|
-
|
|
1216
|
+
setOpenEntryId(null);
|
|
1217
|
+
setLayersSheetOpen(false);
|
|
1218
|
+
}
|
|
1219
|
+
function handleToggle(entryId, open) {
|
|
1220
|
+
setOpenEntryId(open ? entryId : null);
|
|
1083
1221
|
}
|
|
1084
1222
|
return /* @__PURE__ */ jsxs("div", { className: styles.picker, "data-testid": "topic-picker", children: [
|
|
1085
1223
|
/* @__PURE__ */ jsx("div", { className: styles.pickerSearch, children: /* @__PURE__ */ jsx(
|
|
@@ -1096,15 +1234,17 @@ function TopicPicker() {
|
|
|
1096
1234
|
}
|
|
1097
1235
|
) }),
|
|
1098
1236
|
/* @__PURE__ */ jsxs("div", { className: styles.pickerList, children: [
|
|
1099
|
-
|
|
1100
|
-
|
|
1237
|
+
entries.length === 0 && /* @__PURE__ */ jsx(Text, { color: "secondary", className: styles.pickerEmpty, children: t("search.empty") }),
|
|
1238
|
+
entries.map((entry) => /* @__PURE__ */ jsx(
|
|
1101
1239
|
TopicRow,
|
|
1102
1240
|
{
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1241
|
+
entry,
|
|
1242
|
+
activeTopicId,
|
|
1243
|
+
isOpen: entry.id === openEntryId,
|
|
1244
|
+
onSelect: handleSelect,
|
|
1245
|
+
onToggle: (open) => handleToggle(entry.id, open)
|
|
1106
1246
|
},
|
|
1107
|
-
|
|
1247
|
+
entry.id
|
|
1108
1248
|
))
|
|
1109
1249
|
] }),
|
|
1110
1250
|
/* @__PURE__ */ jsx("div", { className: styles.pickerFooter, children: /* @__PURE__ */ jsx(Button, { visualType: "link", iconLeft: "arrow_back", onClick: () => setTopicPickerOpen(false), children: t("back") }) })
|
|
@@ -1112,17 +1252,13 @@ function TopicPicker() {
|
|
|
1112
1252
|
}
|
|
1113
1253
|
|
|
1114
1254
|
function TopicSelect() {
|
|
1115
|
-
const topics = useTopicStore((s) => s.topics);
|
|
1116
1255
|
const activeTopicId = useTopicStore((s) => s.activeTopicId);
|
|
1117
1256
|
const setActiveTopicId = useTopicStore((s) => s.setActiveTopicId);
|
|
1118
1257
|
const t = useComponentTranslate(TOPICLIST_COMPONENT_ID);
|
|
1258
|
+
const entries = useTopicEntries("");
|
|
1119
1259
|
const options = useMemo(
|
|
1120
|
-
() =>
|
|
1121
|
-
|
|
1122
|
-
label: item.title,
|
|
1123
|
-
customData: item
|
|
1124
|
-
})),
|
|
1125
|
-
[topics]
|
|
1260
|
+
() => entries.map((entry) => ({ value: entry.id, label: entry.label, customData: entry })),
|
|
1261
|
+
[entries]
|
|
1126
1262
|
);
|
|
1127
1263
|
const selectedOption = useMemo(
|
|
1128
1264
|
() => options.find((option) => option.value === activeTopicId) ?? null,
|
|
@@ -1132,8 +1268,15 @@ function TopicSelect() {
|
|
|
1132
1268
|
if (!selected) {
|
|
1133
1269
|
return;
|
|
1134
1270
|
}
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1271
|
+
const { customData } = selected;
|
|
1272
|
+
if (!customData) {
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
if (customData.kind === "externalApp") {
|
|
1276
|
+
openExternalAppAtCurrentView(customData.app);
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
setActiveTopicId(customData.topic.id);
|
|
1137
1280
|
}
|
|
1138
1281
|
return /* @__PURE__ */ jsx(Card, { borderless: true, children: /* @__PURE__ */ jsx(Card.Content, { padding: 0.5, children: /* @__PURE__ */ jsx(Row, { gutterY: 2, children: /* @__PURE__ */ jsxs(Col, { children: [
|
|
1139
1282
|
/* @__PURE__ */ jsx(Text, { color: "secondary", children: t("label") }),
|
|
@@ -1189,11 +1332,12 @@ const XGIS_COMPONENTS = [
|
|
|
1189
1332
|
SidePanelComponent,
|
|
1190
1333
|
LayerPanelComponent,
|
|
1191
1334
|
MapSwitchComponent,
|
|
1335
|
+
SearchComponent,
|
|
1192
1336
|
NavigationComponent,
|
|
1193
1337
|
TopicListComponent,
|
|
1194
1338
|
BasemapComponent,
|
|
1195
1339
|
NotificationComponent
|
|
1196
1340
|
];
|
|
1197
1341
|
|
|
1198
|
-
export { BasemapComponent, LayerPanelComponent, MapSwitchComponent, NavigationComponent, NotificationComponent, SIDE_PANEL_SLOTS, SidePanelComponent, TopicListComponent, XGIS_COMPONENTS };
|
|
1342
|
+
export { BasemapComponent, LayerPanelComponent, MapSwitchComponent, NavigationComponent, NotificationComponent, SIDE_PANEL_SLOTS, SearchComponent, SidePanelComponent, TopicListComponent, XGIS_COMPONENTS };
|
|
1199
1343
|
//# sourceMappingURL=index.js.map
|