@opengeoweb/layer-select 9.22.0 → 9.23.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/index.esm.js CHANGED
@@ -4,12 +4,9 @@ import React__default from 'react';
4
4
  import { useSelector, useDispatch } from 'react-redux';
5
5
  import { CustomIconButton, ToolContainerDraggable, CustomAccordion, CustomToggleButton, CustomTooltip, SearchHighlight, SearchField, ToggleMenu } from '@opengeoweb/shared';
6
6
  import { Filter, LayersAdd, Add, Cached, Edit, Visibility, Delete, Close, Copy } from '@opengeoweb/theme';
7
- import { uiTypes, serviceActions, selectorMemoizationOptions, serviceSelectors, uiActions, uiSelectors, layerSelectors, layerActions, getUserAddedServices, setUserAddedServices, useSetupDialog, mapSelectors, layerTypes } from '@opengeoweb/store';
8
- import { createEntityAdapter, createSlice, createSelector } from '@reduxjs/toolkit';
7
+ import { uiTypes, serviceActions, selectorMemoizationOptions, serviceSelectors, uiActions, getUserAddedServices, setUserAddedServices, layerActions, uiSelectors, layerSelectors, useSetupDialog, mapSelectors, layerTypes } from '@opengeoweb/store';
8
+ import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
9
9
  import { compact, countBy, partition } from 'lodash';
10
- import { createStore } from '@redux-eggs/redux-toolkit';
11
- import { getSagaExtension } from '@redux-eggs/saga-extension';
12
- import { takeEvery, select, put, all } from 'redux-saga/effects';
13
10
  import { ListItem, ListItemIcon, Checkbox, Typography, ListItemSecondaryAction, Switch, Grid, List, Box, Backdrop, CircularProgress, Button, ListItemText, Dialog, DialogTitle, LinearProgress, DialogContent, InputAdornment, DialogActions } from '@mui/material';
14
11
  import i18n from 'i18next';
15
12
  import { useTranslation } from 'react-i18next';
@@ -60,41 +57,41 @@ var en = {
60
57
  };
61
58
  var fi = {
62
59
  "layer-select": "Layer Select",
63
- "select-all": "Ei käännetty",
64
- "groups-and-keywords-dialog-title": "Ei käännetty",
65
- only: "Ei käännetty",
66
- add: "Ei käännetty",
67
- remove: "Ei käännetty",
68
- "layer-list-results": "Ei käännetty",
69
- groups: "Ei käännetty",
70
- keywords: "Ei käännetty",
71
- "layer-select-button-tooltip": "Ei käännetty",
72
- all: "Ei käännetty",
73
- services: "Ei käännetty",
74
- "add-a-new-service": "Ei käännetty",
75
- "update-service-title": "Ei käännetty",
76
- "edit-service-title": "Ei käännetty",
77
- "save-service-title": "Ei käännetty",
78
- "show-service-title": "Ei käännetty",
79
- "service-has-active-layers-error": "Ei käännetty",
80
- "delete-service": "Ei käännetty",
81
- "copy-url-message": "Ei käännetty",
82
- "get-success-message": "Ei käännetty",
83
- "service-popup-helper-text": "Ei käännetty",
84
- close: "Ei käännetty",
85
- cancel: "Ei käännetty",
86
- save: "Ei käännetty",
87
- "validations-name-existing": "Ei käännetty",
88
- "validations-service-existing": "Ei käännetty",
89
- "validations-service-valid-url": "Ei käännetty",
90
- "validations-request-failed": "Ei käännetty",
91
- "validations-field-required": "Ei käännetty",
92
- "service-url-label": "Ei käännetty",
93
- "service-name-label": "Ei käännetty",
94
- "service-abstracts-label": "Ei käännetty",
95
- "service-successfully-updated": "Ei käännetty",
96
- "unable-to-update-service": "Ei käännetty",
97
- "service-has-been-deleted": "Ei käännetty"
60
+ "select-all": "Valitse kaikki",
61
+ "groups-and-keywords-dialog-title": "Ryhmät ja Avainsanat",
62
+ only: "Pelkästään",
63
+ add: "lisää",
64
+ remove: "poista",
65
+ "layer-list-results": "tulosta",
66
+ groups: "Ryhmät",
67
+ keywords: "Avainsanat",
68
+ "layer-select-button-tooltip": "Avaa Layer Select",
69
+ all: "Kaikki",
70
+ services: "Palvelut",
71
+ "add-a-new-service": "Lisää uusi pavelu",
72
+ "update-service-title": "Päivitä karttatasot WMS palvelusta",
73
+ "edit-service-title": "Muokkaa palvelua",
74
+ "save-service-title": "Tallenna palvelu",
75
+ "show-service-title": "Näytä palvelu",
76
+ "service-has-active-layers-error": "Palvelu sisältää aktiivisia karttatasoja. Palvelua ei voi poistaa",
77
+ "delete-service": "Poista palvelu",
78
+ "copy-url-message": "Palvelun osoite kopioitu leikepöydälle",
79
+ "get-success-message": "Palvelu \"{{serviceName}}\" tallennettu onnistuneesti",
80
+ "service-popup-helper-text": "Lyhyt kuvaus siitä mitä palvelu tekee",
81
+ close: "sulje",
82
+ cancel: "peruuta",
83
+ save: "tallenna",
84
+ "validations-name-existing": "Nimi on jo käytössä. Valitse toinen nimi.",
85
+ "validations-service-existing": "Osoite on jo käytössä.",
86
+ "validations-service-valid-url": "Epäkelpo URL-osoite",
87
+ "validations-request-failed": "Lataus epäonnistui. Tarkista URL-osoite",
88
+ "validations-field-required": "Kenttä tulee täyttää",
89
+ "service-url-label": "Tämä palvelu viittaa tähän URL-osoitteeseen",
90
+ "service-name-label": "Palvelun nimi",
91
+ "service-abstracts-label": "Tiivistelmä",
92
+ "service-successfully-updated": "Palvelu \"{{serviceName}}\" päivitetty onnistuunnesti",
93
+ "unable-to-update-service": "Palvelun päivitys epäonnistui. Syy: \"{{message}}\"",
94
+ "service-has-been-deleted": "Palvelu \"{{serviceName}}\" poistettu"
98
95
  };
99
96
  var no = {
100
97
  "layer-select": "Lagvalg",
@@ -2798,117 +2795,137 @@ var types = /*#__PURE__*/Object.freeze({
2798
2795
  __proto__: null
2799
2796
  });
2800
2797
 
2801
- function* layerSelectCloseInfoDialogSaga({
2802
- type,
2803
- payload
2804
- }) {
2805
- switch (type) {
2806
- case uiActions.setToggleOpenDialog.type:
2807
- {
2808
- const togglePayload = payload;
2809
- if (!togglePayload.setOpen && togglePayload.type === uiTypes.DialogTypes.LayerSelect) {
2810
- yield put(layerActions.hideLayerInfo());
2811
- }
2812
- break;
2813
- }
2814
- case uiActions.setActiveMapIdForDialog.type:
2815
- {
2816
- const activeMapIdPayload = payload;
2817
- if (!activeMapIdPayload.setOpen) {
2818
- const isLayerInfoDialogOpen = yield select(uiSelectors.getisDialogOpen, uiTypes.DialogTypes.LayerInfo);
2819
- if (isLayerInfoDialogOpen) {
2820
- yield put(layerActions.hideLayerInfo());
2821
- }
2822
- }
2823
- break;
2824
- }
2825
- default:
2826
- {
2827
- const isLayerInfoDialogOpen = yield select(uiSelectors.getisDialogOpen, uiTypes.DialogTypes.LayerInfo);
2828
- if (isLayerInfoDialogOpen) {
2829
- const filteredLayers = yield select(getFilteredLayers);
2830
- const dialogInfo = yield select(layerSelectors.getActiveLayerInfo);
2831
- const layerWithData = yield select(serviceSelectors.getLayerFromService, dialogInfo.serviceUrl, dialogInfo.layerName);
2832
- if (!filteredLayers.map(layer => layer.title).includes(layerWithData.title)) {
2833
- yield put(layerActions.hideLayerInfo());
2834
- }
2835
- }
2836
- }
2837
- }
2838
- }
2839
- function* layerSelectRemoveServiceSaga(capturedAction) {
2840
- const removedService = capturedAction.payload;
2841
- const {
2842
- serviceId,
2843
- serviceUrl
2844
- } = removedService;
2845
- const results = yield select(getActiveServices);
2846
- const services = results;
2847
- const servicesEnabled = Object.values(services).find(service => service === null || service === void 0 ? void 0 : service.enabled);
2848
- if (servicesEnabled === undefined) {
2849
- yield all(Object.entries(services).map(([serviceId]) => {
2850
- return put(layerSelectActions.enableActiveService({
2851
- serviceId
2852
- }));
2798
+ /******************************************************************************
2799
+ Copyright (c) Microsoft Corporation.
2800
+
2801
+ Permission to use, copy, modify, and/or distribute this software for any
2802
+ purpose with or without fee is hereby granted.
2803
+
2804
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2805
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2806
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2807
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2808
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2809
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2810
+ PERFORMANCE OF THIS SOFTWARE.
2811
+ ***************************************************************************** */
2812
+ /* global Reflect, Promise, SuppressedError, Symbol */
2813
+
2814
+
2815
+ function __rest(s, e) {
2816
+ var t = {};
2817
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2818
+ t[p] = s[p];
2819
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
2820
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2821
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2822
+ t[p[i]] = s[p[i]];
2823
+ }
2824
+ return t;
2825
+ }
2826
+
2827
+ function __awaiter(thisArg, _arguments, P, generator) {
2828
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2829
+ return new (P || (P = Promise))(function (resolve, reject) {
2830
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2831
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2832
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2833
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
2834
+ });
2835
+ }
2836
+
2837
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
2838
+ var e = new Error(message);
2839
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
2840
+ };
2841
+
2842
+ const layerSelectListener = createListenerMiddleware();
2843
+ layerSelectListener.startListening({
2844
+ actionCreator: serviceActions.mapStoreRemoveService,
2845
+ effect: action => __awaiter(void 0, void 0, void 0, function* () {
2846
+ const {
2847
+ serviceUrl
2848
+ } = action.payload;
2849
+ const localStorageServices = getUserAddedServices();
2850
+ delete localStorageServices[serviceUrl];
2851
+ setUserAddedServices(localStorageServices);
2852
+ })
2853
+ });
2854
+ layerSelectListener.startListening({
2855
+ actionCreator: layerSelectActions.layerSelectRemoveService,
2856
+ effect: (action, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
2857
+ const removedService = action.payload;
2858
+ const {
2859
+ serviceId,
2860
+ serviceUrl
2861
+ } = removedService;
2862
+ const services = getActiveServices(listenerApi.getState());
2863
+ const servicesEnabled = Object.values(services).find(service => service === null || service === void 0 ? void 0 : service.enabled);
2864
+ if (servicesEnabled === undefined) {
2865
+ Object.entries(services).map(([entryServiceId]) => {
2866
+ return listenerApi.dispatch(layerSelectActions.enableActiveService({
2867
+ serviceId: entryServiceId
2868
+ }));
2869
+ });
2870
+ }
2871
+ listenerApi.dispatch(serviceActions.mapStoreRemoveService({
2872
+ id: serviceId,
2873
+ serviceUrl: serviceUrl
2853
2874
  }));
2854
- }
2855
- yield put(serviceActions.mapStoreRemoveService({
2856
- id: serviceId,
2857
- serviceUrl: serviceUrl
2858
- }));
2859
- }
2860
- function addServiceToLocalStorageSaga({
2861
- payload
2862
- }) {
2863
- const {
2864
- scope,
2865
- name,
2866
- serviceUrl,
2867
- abstract
2868
- } = payload;
2869
- if (!isUserAddedService(scope)) {
2870
- return;
2871
- }
2872
- const localStorageServices = getUserAddedServices();
2873
- setUserAddedServices(Object.assign(Object.assign({}, localStorageServices), {
2874
- [serviceUrl]: {
2875
+ })
2876
+ });
2877
+ layerSelectListener.startListening({
2878
+ actionCreator: serviceActions.serviceSetLayers,
2879
+ effect: action => __awaiter(void 0, void 0, void 0, function* () {
2880
+ const {
2881
+ scope,
2875
2882
  name,
2876
- url: serviceUrl,
2883
+ serviceUrl,
2877
2884
  abstract
2885
+ } = action.payload;
2886
+ if (isUserAddedService(scope)) {
2887
+ const localStorageServices = getUserAddedServices();
2888
+ setUserAddedServices(Object.assign(Object.assign({}, localStorageServices), {
2889
+ [serviceUrl]: {
2890
+ name,
2891
+ url: serviceUrl,
2892
+ abstract
2893
+ }
2894
+ }));
2878
2895
  }
2879
- }));
2880
- }
2881
- function removeServiceFromLocalStorageSaga({
2882
- payload
2883
- }) {
2884
- const {
2885
- serviceUrl
2886
- } = payload;
2887
- const localStorageServices = getUserAddedServices();
2888
- if (!localStorageServices[serviceUrl]) {
2889
- return;
2890
- }
2891
- const updatedServices = Object.assign({}, localStorageServices);
2892
- delete updatedServices[serviceUrl];
2893
- setUserAddedServices(updatedServices);
2894
- }
2895
- function* rootSaga() {
2896
- yield takeEvery(layerSelectActions.layerSelectRemoveService.type, layerSelectRemoveServiceSaga);
2897
- yield takeEvery(serviceActions.serviceSetLayers.type, addServiceToLocalStorageSaga);
2898
- yield takeEvery(serviceActions.mapStoreRemoveService.type, removeServiceFromLocalStorageSaga);
2899
- yield takeEvery([uiActions.setToggleOpenDialog.type, uiActions.setActiveMapIdForDialog.type, layerSelectActions.disableActiveService.type, layerSelectActions.toggleFilter.type, layerSelectActions.setSearchFilter.type], layerSelectCloseInfoDialogSaga);
2900
- }
2901
-
2902
- // TODO: This fixes typecheck errors but maybe there is a better way to do that
2903
- createStore({
2904
- extensions: [getSagaExtension()]
2896
+ })
2905
2897
  });
2898
+ layerSelectListener.startListening({
2899
+ matcher: isAnyOf(uiActions.setToggleOpenDialog, uiActions.setActiveMapIdForDialog),
2900
+ effect: (action, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
2901
+ const {
2902
+ payload
2903
+ } = action;
2904
+ if (!payload.setOpen && payload.type === uiTypes.DialogTypes.LayerSelect) {
2905
+ listenerApi.dispatch(layerActions.hideLayerInfo());
2906
+ }
2907
+ })
2908
+ });
2909
+ layerSelectListener.startListening({
2910
+ matcher: isAnyOf(layerSelectActions.disableActiveService, layerSelectActions.onlyThisServiceEnabled, layerSelectActions.toggleFilter, layerSelectActions.setSearchFilter),
2911
+ effect: (action, listenerApi) => __awaiter(void 0, void 0, void 0, function* () {
2912
+ if (uiSelectors.getisDialogOpen(listenerApi.getState(), uiTypes.DialogTypes.LayerInfo)) {
2913
+ const filteredLayers = getFilteredLayers(listenerApi.getState());
2914
+ const dialogInfo = layerSelectors.getActiveLayerInfo(listenerApi.getState());
2915
+ const layerWithData = dialogInfo && serviceSelectors.getLayerFromService(listenerApi.getState(), dialogInfo.serviceUrl, dialogInfo.layerName);
2916
+ if (!filteredLayers.map(layer => layer.title).includes((layerWithData === null || layerWithData === void 0 ? void 0 : layerWithData.title) || '')) {
2917
+ listenerApi.dispatch(layerActions.hideLayerInfo());
2918
+ }
2919
+ }
2920
+ })
2921
+ });
2922
+
2906
2923
  const layerSelectConfig = {
2907
2924
  id: 'layerSelect-module',
2908
2925
  reducersMap: {
2909
2926
  layerSelect: reducer
2910
2927
  },
2911
- sagas: [rootSaga]
2928
+ middlewares: [layerSelectListener.middleware]
2912
2929
  };
2913
2930
 
2914
2931
  const KeywordFilterButtonConnect = ({
@@ -3911,50 +3928,6 @@ const ServiceListConnect = ({
3911
3928
  });
3912
3929
  };
3913
3930
 
3914
- /******************************************************************************
3915
- Copyright (c) Microsoft Corporation.
3916
-
3917
- Permission to use, copy, modify, and/or distribute this software for any
3918
- purpose with or without fee is hereby granted.
3919
-
3920
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3921
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3922
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3923
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3924
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3925
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3926
- PERFORMANCE OF THIS SOFTWARE.
3927
- ***************************************************************************** */
3928
- /* global Reflect, Promise, SuppressedError, Symbol */
3929
-
3930
-
3931
- function __rest(s, e) {
3932
- var t = {};
3933
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3934
- t[p] = s[p];
3935
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
3936
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3937
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3938
- t[p[i]] = s[p[i]];
3939
- }
3940
- return t;
3941
- }
3942
-
3943
- function __awaiter(thisArg, _arguments, P, generator) {
3944
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3945
- return new (P || (P = Promise))(function (resolve, reject) {
3946
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3947
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3948
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3949
- step((generator = generator.apply(thisArg, _arguments || [])).next());
3950
- });
3951
- }
3952
-
3953
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
3954
- var e = new Error(message);
3955
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
3956
- };
3957
-
3958
3931
  const styles = {
3959
3932
  servicesContainer: {
3960
3933
  width: '360px',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/layer-select",
3
- "version": "9.22.0",
3
+ "version": "9.23.1",
4
4
  "description": "GeoWeb layer select library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -21,10 +21,7 @@
21
21
  "react-hook-form": "^7.50.1",
22
22
  "@reduxjs/toolkit": "^1.9.7",
23
23
  "@redux-eggs/core": "^2.2.0",
24
- "@redux-eggs/redux-toolkit": "^2.2.0",
25
- "@redux-eggs/saga-extension": "^2.2.0",
26
24
  "lodash": "^4.17.21",
27
- "redux-saga": "^1.2.3",
28
25
  "i18next": "^23.11.5",
29
26
  "react-i18next": "^14.1.2"
30
27
  },
@@ -0,0 +1,2 @@
1
+ import { RootState } from './types';
2
+ export declare const layerSelectListener: import("@reduxjs/toolkit").ListenerMiddlewareInstance<RootState, import("@reduxjs/toolkit").ThunkDispatch<RootState, unknown, import("redux").AnyAction>, unknown>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +0,0 @@
1
- import { SagaIterator } from 'redux-saga';
2
- import { serviceActions, uiActions } from '@opengeoweb/store';
3
- import { layerSelectActions, LayerSelectActions } from './reducer';
4
- export declare function layerSelectCloseInfoDialogSaga({ type, payload, }: ReturnType<typeof uiActions.setToggleOpenDialog | typeof uiActions.setActiveMapIdForDialog | typeof layerSelectActions.disableActiveService | typeof layerSelectActions.toggleFilter | typeof layerSelectActions.setSearchFilter>): SagaIterator;
5
- export declare function layerSelectRemoveServiceSaga(capturedAction: LayerSelectActions): SagaIterator;
6
- export declare function addServiceToLocalStorageSaga({ payload, }: ReturnType<typeof serviceActions.serviceSetLayers>): void;
7
- export declare function removeServiceFromLocalStorageSaga({ payload, }: ReturnType<typeof serviceActions.mapStoreRemoveService>): void;
8
- export declare function rootSaga(): SagaIterator;