@opengeoweb/core 8.4.0 → 8.4.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
@@ -11,7 +11,7 @@ import { jsx } from 'react/jsx-runtime';
11
11
  import Box$3 from '@mui/material/Box';
12
12
  import Typography$1 from '@mui/material/Typography';
13
13
  import Grid$1 from '@mui/material/Grid';
14
- import { LegendLayout, MapControlButton, ZoomControls, CanvasComponent, MapView, MapViewLayer, LegendDialog, emptyGeoJSON, MapControls, publicLayers } from '@opengeoweb/webmap-react';
14
+ import { LegendLayout, MapControlButton, ZoomControls, CanvasComponent, MapView, MapViewLayer, LegendDialog, SearchDialog, emptyGeoJSON, MapControls, publicLayers } from '@opengeoweb/webmap-react';
15
15
  import _, { isEqual as isEqual$1, debounce, groupBy, throttle as throttle$1, range } from 'lodash';
16
16
  import { ReactHookFormProvider, defaultFormOptions, ReactHookFormTextField } from '@opengeoweb/form-fields';
17
17
  import { useFormContext } from 'react-hook-form';
@@ -14277,7 +14277,7 @@ var ServiceChip = function ServiceChip(_ref) {
14277
14277
  title: (service === null || service === void 0 ? void 0 : service["abstract"]) ? "Abstract: ".concat(service["abstract"]) : ''
14278
14278
  }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(CustomToggleButton, {
14279
14279
  variant: "boxed",
14280
- selected: isSelected,
14280
+ selected: Boolean(isSelected),
14281
14281
  tabIndex: 0,
14282
14282
  "data-testid": all ? 'serviceChipAll' : 'serviceChip',
14283
14283
  onClick: function onClick() {
@@ -14291,92 +14291,66 @@ var ServiceChip = function ServiceChip(_ref) {
14291
14291
  }, service ? service.serviceName : 'All')));
14292
14292
  };
14293
14293
 
14294
+ /* *
14295
+ * Licensed under the Apache License, Version 2.0 (the "License");
14296
+ * you may not use this file except in compliance with the License.
14297
+ * You may obtain a copy of the License at
14298
+ *
14299
+ * http://www.apache.org/licenses/LICENSE-2.0
14300
+ *
14301
+ * Unless required by applicable law or agreed to in writing, software
14302
+ * distributed under the License is distributed on an "AS IS" BASIS,
14303
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14304
+ * See the License for the specific language governing permissions and
14305
+ * limitations under the License.
14306
+ *
14307
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
14308
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
14309
+ * */
14294
14310
  var ServiceChipConnect = function ServiceChipConnect(_ref) {
14295
- var _ref$all = _ref.all,
14296
- all = _ref$all === void 0 ? false : _ref$all,
14297
- serviceId = _ref.serviceId,
14298
- service = _ref.service,
14299
- isSelected = _ref.isSelected,
14300
- isAllSelected = _ref.isAllSelected,
14301
- isDisabled = _ref.isDisabled;
14311
+ var service = _ref.service,
14312
+ isAllSelected = _ref.isAllSelected;
14302
14313
  var dispatch = useDispatch();
14303
- var activeServices = useSelector(function (store) {
14304
- return layerSelectSelectors.getActiveServices(store);
14305
- });
14306
- var setAllServicesEnabled = function setAllServicesEnabled(allServicesEnabled) {
14307
- dispatch(layerSelectActions.setAllServicesEnabled({
14308
- allServicesEnabled: allServicesEnabled
14309
- }));
14310
- };
14311
- var hasSelectedStyle = !isAllSelected && isSelected || isAllSelected && (service === null || service === void 0 ? void 0 : service.serviceName) === 'all';
14312
- var toggleChip = function toggleChip(service) {
14313
- if (service === 'all') {
14314
- if (isSelected) {
14315
- setAllServicesEnabled(false);
14316
- Object.entries(activeServices).forEach(function (_ref2) {
14317
- var _ref3 = _slicedToArray(_ref2, 2),
14318
- serviceID = _ref3[0],
14319
- service = _ref3[1];
14320
- if (service.enabled) {
14321
- dispatch(layerSelectActions.disableActiveService({
14322
- serviceId: serviceID,
14323
- filters: service.filterIds
14324
- }));
14325
- }
14326
- });
14327
- } else {
14328
- setAllServicesEnabled(true);
14329
- Object.entries(activeServices).forEach(function (_ref4) {
14330
- var _ref5 = _slicedToArray(_ref4, 2),
14331
- serviceID = _ref5[0],
14332
- service = _ref5[1];
14333
- if (!service.enabled) {
14334
- dispatch(layerSelectActions.enableActiveService({
14335
- serviceId: serviceID,
14336
- filters: service.filterIds
14337
- }));
14338
- }
14339
- });
14340
- }
14341
- } else if (isSelected) {
14314
+ var serviceId = service.serviceId;
14315
+ var toggleChip = function toggleChip() {
14316
+ if (service.enabled) {
14342
14317
  if (isAllSelected) {
14343
- setAllServicesEnabled(false);
14344
- Object.entries(activeServices).forEach(function (_ref6) {
14345
- var _ref7 = _slicedToArray(_ref6, 2),
14346
- serviceID = _ref7[0],
14347
- service = _ref7[1];
14348
- var shouldDisable = service.enabled && serviceID !== serviceId;
14349
- if (shouldDisable) {
14350
- dispatch(layerSelectActions.disableActiveService({
14351
- serviceId: serviceID,
14352
- filters: service.filterIds
14353
- }));
14354
- }
14355
- });
14356
- } else {
14357
- dispatch(layerSelectActions.disableActiveService({
14358
- serviceId: serviceId,
14359
- filters: activeServices[serviceId].filterIds
14318
+ dispatch(layerSelectActions.onlyThisServiceEnabled({
14319
+ serviceId: serviceId
14360
14320
  }));
14321
+ return;
14361
14322
  }
14362
- } else {
14363
- dispatch(layerSelectActions.enableActiveService({
14364
- serviceId: serviceId,
14365
- filters: activeServices[serviceId].filterIds
14323
+ dispatch(layerSelectActions.disableActiveService({
14324
+ serviceId: serviceId
14366
14325
  }));
14326
+ return;
14367
14327
  }
14328
+ dispatch(layerSelectActions.enableActiveService({
14329
+ serviceId: serviceId
14330
+ }));
14368
14331
  };
14369
14332
  return /*#__PURE__*/React.createElement(ServiceChip, {
14370
14333
  service: service,
14371
- all: all,
14372
14334
  toggleChip: toggleChip,
14373
- isSelected: hasSelectedStyle,
14374
- isDisabled: isDisabled
14335
+ isSelected: isAllSelected ? false : service.enabled,
14336
+ isDisabled: service.isLoading
14337
+ });
14338
+ };
14339
+ var AllChipConnect = function AllChipConnect(_ref2) {
14340
+ var isAllSelected = _ref2.isAllSelected;
14341
+ var dispatch = useDispatch();
14342
+ return /*#__PURE__*/React.createElement(ServiceChip, {
14343
+ toggleChip: function toggleChip() {
14344
+ if (!isAllSelected) {
14345
+ dispatch(layerSelectActions.enableAllActiveServices());
14346
+ }
14347
+ },
14348
+ isSelected: isAllSelected
14375
14349
  });
14376
14350
  };
14377
14351
 
14378
14352
  var ServiceList = function ServiceList(_ref) {
14379
- var activeServices = _ref.activeServices,
14353
+ var activeServicesById = _ref.activeServicesById,
14380
14354
  setHeight = _ref.setHeight;
14381
14355
  var ref = React.useRef(null);
14382
14356
  var _React$useState = React.useState(0),
@@ -14388,11 +14362,13 @@ var ServiceList = function ServiceList(_ref) {
14388
14362
  if (ref && ref.current && ref.current.clientHeight) {
14389
14363
  setServiceListHeight(ref.current.clientHeight);
14390
14364
  }
14391
- }, [activeServices, clientHeight]);
14365
+ }, [activeServicesById, clientHeight]);
14392
14366
  React.useEffect(function () {
14393
14367
  setHeight(serviceListHeight);
14394
14368
  }, [serviceListHeight, setHeight]);
14395
- var isAllSelected = Object.values(activeServices).every(function (activeService) {
14369
+ var activeServicesIds = Object.keys(activeServicesById);
14370
+ var activeServices = Object.values(activeServicesById);
14371
+ var isAllSelected = activeServices.every(function (activeService) {
14396
14372
  return activeService.enabled;
14397
14373
  });
14398
14374
  return /*#__PURE__*/React.createElement(Box$2, {
@@ -14414,20 +14390,13 @@ var ServiceList = function ServiceList(_ref) {
14414
14390
  fontSize: '0.875rem'
14415
14391
  },
14416
14392
  ref: ref
14417
- }, activeServices && Object.keys(activeServices) && Object.keys(activeServices).length > 0 && /*#__PURE__*/React.createElement(ServiceChipConnect, {
14418
- key: "All",
14419
- all: true,
14420
- isSelected: isAllSelected
14421
- }), Object.keys(activeServices).map(function (serviceId) {
14422
- var _a, _b;
14423
- var service = activeServices[serviceId];
14393
+ }, (activeServicesIds === null || activeServicesIds === void 0 ? void 0 : activeServicesIds.length) && /*#__PURE__*/React.createElement(AllChipConnect, {
14394
+ isAllSelected: isAllSelected
14395
+ }), activeServices.map(function (service) {
14424
14396
  return /*#__PURE__*/React.createElement(ServiceChipConnect, {
14425
- key: serviceId,
14426
- serviceId: serviceId,
14397
+ key: service.serviceUrl,
14427
14398
  service: service,
14428
- isSelected: (_a = activeServices[serviceId]) === null || _a === void 0 ? void 0 : _a.enabled,
14429
- isAllSelected: isAllSelected,
14430
- isDisabled: activeServices[serviceId] === undefined || ((_b = activeServices[serviceId]) === null || _b === void 0 ? void 0 : _b.isLoading) === true
14399
+ isAllSelected: isAllSelected
14431
14400
  });
14432
14401
  })));
14433
14402
  };
@@ -14455,7 +14424,7 @@ var ServiceListConnect = function ServiceListConnect(_ref) {
14455
14424
  });
14456
14425
  return /*#__PURE__*/React.createElement(ServiceList, {
14457
14426
  setHeight: setHeight,
14458
- activeServices: sortByService(activeServices)
14427
+ activeServicesById: sortByService(activeServices)
14459
14428
  });
14460
14429
  };
14461
14430
 
@@ -24069,6 +24038,77 @@ var GetFeatureInfoButtonConnect = function GetFeatureInfoButtonConnect(_ref) {
24069
24038
  }, /*#__PURE__*/React.createElement(Info, null));
24070
24039
  };
24071
24040
 
24041
+ /* *
24042
+ * Licensed under the Apache License, Version 2.0 (the "License");
24043
+ * you may not use this file except in compliance with the License.
24044
+ * You may obtain a copy of the License at
24045
+ *
24046
+ * http://www.apache.org/licenses/LICENSE-2.0
24047
+ *
24048
+ * Unless required by applicable law or agreed to in writing, software
24049
+ * distributed under the License is distributed on an "AS IS" BASIS,
24050
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24051
+ * See the License for the specific language governing permissions and
24052
+ * limitations under the License.
24053
+ *
24054
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
24055
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
24056
+ * */
24057
+ var SearchControlButtonConnect = function SearchControlButtonConnect(_ref) {
24058
+ var mapId = _ref.mapId,
24059
+ _ref$source = _ref.source,
24060
+ source = _ref$source === void 0 ? 'app' : _ref$source;
24061
+ var dispatch = useDispatch();
24062
+ var dialogType = "".concat(uiTypes.DialogTypes.Search, "-").concat(mapId);
24063
+ var currentActiveMapId = useSelector(function (store) {
24064
+ return uiSelectors.getDialogMapId(store, dialogType);
24065
+ });
24066
+ var isOpenInStore = useSelector(function (store) {
24067
+ return uiSelectors.getisDialogOpen(store, dialogType);
24068
+ });
24069
+ var openSearchDialog = React__default.useCallback(function () {
24070
+ dispatch(uiActions.setActiveMapIdForDialog({
24071
+ type: dialogType,
24072
+ mapId: mapId,
24073
+ setOpen: currentActiveMapId !== mapId ? true : !isOpenInStore,
24074
+ source: source
24075
+ }));
24076
+ }, [currentActiveMapId, dialogType, dispatch, isOpenInStore, mapId, source]);
24077
+ return /*#__PURE__*/React__default.createElement(MapControlButton, {
24078
+ onClick: openSearchDialog,
24079
+ title: "Search",
24080
+ "aria-label": "Map search"
24081
+ }, /*#__PURE__*/React__default.createElement(Search, null));
24082
+ };
24083
+
24084
+ /* *
24085
+ * Licensed under the Apache License, Version 2.0 (the "License");
24086
+ * you may not use this file except in compliance with the License.
24087
+ * You may obtain a copy of the License at
24088
+ *
24089
+ * http://www.apache.org/licenses/LICENSE-2.0
24090
+ *
24091
+ * Unless required by applicable law or agreed to in writing, software
24092
+ * distributed under the License is distributed on an "AS IS" BASIS,
24093
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24094
+ * See the License for the specific language governing permissions and
24095
+ * limitations under the License.
24096
+ *
24097
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
24098
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
24099
+ * */
24100
+ var SearchControlConnect = function SearchControlConnect(_ref) {
24101
+ var mapId = _ref.mapId;
24102
+ var dialogType = "".concat(uiTypes.DialogTypes.Search, "-").concat(mapId);
24103
+ var _useSetupDialog = useSetupDialog(dialogType),
24104
+ isDialogOpen = _useSetupDialog.isDialogOpen,
24105
+ onCloseDialog = _useSetupDialog.onCloseDialog;
24106
+ return /*#__PURE__*/React__default.createElement(SearchDialog, {
24107
+ isOpen: isDialogOpen,
24108
+ onClose: onCloseDialog
24109
+ });
24110
+ };
24111
+
24072
24112
  var titleStyle = function titleStyle(theme) {
24073
24113
  return {
24074
24114
  position: 'absolute',
@@ -24128,9 +24168,11 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
24128
24168
  displayGetFeatureInfoButtonInMap = _a$displayGetFeatureI === void 0 ? false : _a$displayGetFeatureI,
24129
24169
  _a$shouldDisplayDrawC = _a.shouldDisplayDrawControls,
24130
24170
  shouldDisplayDrawControls = _a$shouldDisplayDrawC === void 0 ? false : _a$shouldDisplayDrawC,
24171
+ _a$displaySearchButto = _a.displaySearchButtonInMap,
24172
+ displaySearchButtonInMap = _a$displaySearchButto === void 0 ? false : _a$displaySearchButto,
24131
24173
  mapControls = _a.mapControls,
24132
24174
  children = _a.children,
24133
- props = __rest(_a, ["id", "dockedLayerManagerSize", "title", "layers", "dimensions", "shouldAutoUpdate", "shouldAnimate", "bbox", "srs", "shouldShowZoomControls", "displayMapPin", "showTimeSlider", "disableTimeSlider", "displayTimeInMap", "displayLayerManagerAndLegendButtonInMap", "displayDimensionSelectButtonInMap", "multiLegend", "shouldShowLayerManager", "shouldShowDockedLayerManager", "showClock", "displayGetFeatureInfoButtonInMap", "shouldDisplayDrawControls", "mapControls", "children"]);
24175
+ props = __rest(_a, ["id", "dockedLayerManagerSize", "title", "layers", "dimensions", "shouldAutoUpdate", "shouldAnimate", "bbox", "srs", "shouldShowZoomControls", "displayMapPin", "showTimeSlider", "disableTimeSlider", "displayTimeInMap", "displayLayerManagerAndLegendButtonInMap", "displayDimensionSelectButtonInMap", "multiLegend", "shouldShowLayerManager", "shouldShowDockedLayerManager", "showClock", "displayGetFeatureInfoButtonInMap", "shouldDisplayDrawControls", "displaySearchButtonInMap", "mapControls", "children"]);
24134
24176
  var dispatch = useDispatch();
24135
24177
  var mapId = React__default.useRef(id || webmapUtils.generateMapId()).current;
24136
24178
  React__default.useEffect(function () {
@@ -24211,7 +24253,9 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
24211
24253
  style: {
24212
24254
  top: mapControlsPositionTop
24213
24255
  }
24214
- }, /*#__PURE__*/React__default.createElement(ZoomControlConnect, {
24256
+ }, displaySearchButtonInMap && /*#__PURE__*/React__default.createElement(SearchControlButtonConnect, {
24257
+ mapId: mapId
24258
+ }), /*#__PURE__*/React__default.createElement(ZoomControlConnect, {
24215
24259
  mapId: id
24216
24260
  }), displayLayerManagerAndLegendButtonInMap && /*#__PURE__*/React__default.createElement(LayerManagerMapButtonConnect, {
24217
24261
  mapId: mapId
@@ -24242,6 +24286,8 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_a) {
24242
24286
  showMapId: true,
24243
24287
  mapId: mapId,
24244
24288
  multiLegend: multiLegend
24289
+ }), /*#__PURE__*/React__default.createElement(SearchControlConnect, {
24290
+ mapId: mapId
24245
24291
  }), showClock && /*#__PURE__*/React__default.createElement(TimeSliderClockConnect, {
24246
24292
  mapId: mapId
24247
24293
  }), displayGetFeatureInfoButtonInMap && /*#__PURE__*/React__default.createElement(GetFeatureInfoConnect, {
@@ -24582,12 +24628,14 @@ var componentsLookUp = function componentsLookUp(_ref) {
24582
24628
  {
24583
24629
  var mapPreset = initialProps.mapPreset,
24584
24630
  mapControls = initialProps.mapControls,
24585
- shouldDisplayDrawControls = initialProps.shouldDisplayDrawControls;
24631
+ shouldDisplayDrawControls = initialProps.shouldDisplayDrawControls,
24632
+ displaySearchButtonInMap = initialProps.displaySearchButtonInMap;
24586
24633
  return /*#__PURE__*/React__default.createElement(ConfigurableMapConnect, Object.assign({}, mapPreset, {
24587
24634
  id: id,
24588
24635
  "data-testid": "coreConfigurableMapConnect",
24589
24636
  displayGetFeatureInfoButtonInMap: true,
24590
24637
  shouldDisplayDrawControls: shouldDisplayDrawControls,
24638
+ displaySearchButtonInMap: displaySearchButtonInMap,
24591
24639
  mapControls: mapControls
24592
24640
  }));
24593
24641
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/core",
3
- "version": "8.4.0",
3
+ "version": "8.4.1",
4
4
  "description": "GeoWeb Core library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,13 +14,13 @@
14
14
  "peerDependencies": {
15
15
  "@mui/material": "5.12.0",
16
16
  "@mui/system": "5.14.14",
17
- "@opengeoweb/api": "8.4.0",
18
- "@opengeoweb/form-fields": "8.4.0",
19
- "@opengeoweb/shared": "8.4.0",
20
- "@opengeoweb/store": "8.4.0",
21
- "@opengeoweb/theme": "8.4.0",
22
- "@opengeoweb/webmap": "8.4.0",
23
- "@opengeoweb/webmap-react": "8.4.0",
17
+ "@opengeoweb/api": "8.4.1",
18
+ "@opengeoweb/form-fields": "8.4.1",
19
+ "@opengeoweb/shared": "8.4.1",
20
+ "@opengeoweb/store": "8.4.1",
21
+ "@opengeoweb/theme": "8.4.1",
22
+ "@opengeoweb/webmap": "8.4.1",
23
+ "@opengeoweb/webmap-react": "8.4.1",
24
24
  "@redux-eggs/redux-toolkit": "2.2.0",
25
25
  "@redux-eggs/saga-extension": "2.2.0",
26
26
  "@reduxjs/toolkit": "1.9.7",
@@ -12,6 +12,7 @@ export interface InitialMapProps {
12
12
  syncGroupsIds: string[];
13
13
  mapControls?: React.ReactNode;
14
14
  shouldDisplayDrawControls?: boolean;
15
+ displaySearchButtonInMap?: boolean;
15
16
  }
16
17
  interface InitialSliderProps {
17
18
  sliderPreset: {
@@ -36,6 +36,7 @@ export interface ConfigurableMapConnectProps {
36
36
  showClock?: boolean;
37
37
  displayGetFeatureInfoButtonInMap?: boolean;
38
38
  shouldDisplayDrawControls?: boolean;
39
+ displaySearchButtonInMap?: boolean;
39
40
  children?: React.ReactNode;
40
41
  mapControls?: React.ReactNode;
41
42
  }
@@ -1,12 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { layerSelectTypes } from '@opengeoweb/store';
3
3
  export interface ServiceChipConnectProps {
4
- all?: boolean;
5
- serviceId?: string;
6
- service?: layerSelectTypes.ActiveServiceObject;
7
- isSelected?: boolean;
8
- isAllSelected?: boolean;
9
- isDisabled?: boolean;
4
+ service: layerSelectTypes.ActiveServiceObject;
5
+ isAllSelected: boolean;
10
6
  }
11
- declare const ServiceChipConnect: React.FC<ServiceChipConnectProps>;
12
- export default ServiceChipConnect;
7
+ export declare const ServiceChipConnect: React.FC<ServiceChipConnectProps>;
8
+ export declare const AllChipConnect: React.FC<{
9
+ isAllSelected: boolean;
10
+ }>;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { layerSelectTypes } from '@opengeoweb/store';
3
3
  interface ServiceListProps {
4
- activeServices: layerSelectTypes.ActiveServiceObjectEntities;
4
+ activeServicesById: layerSelectTypes.ActiveServiceObjectEntities;
5
5
  setHeight: (height: number) => void;
6
6
  }
7
7
  declare const ServiceList: React.FC<ServiceListProps>;
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ declare const _default: {
3
+ title: string;
4
+ };
5
+ export default _default;
6
+ export declare const SearchControlConnectStoryLight: {
7
+ (): React.ReactElement;
8
+ storyName: string;
9
+ };
10
+ export declare const SearchControlConnectStoryDark: {
11
+ (): React.ReactElement;
12
+ storyName: string;
13
+ };
@@ -0,0 +1,8 @@
1
+ import { CustomIconProps } from '@opengeoweb/shared';
2
+ import { uiTypes } from '@opengeoweb/store';
3
+ import React from 'react';
4
+ export interface SearchControlButtonConnectProps extends CustomIconProps {
5
+ mapId: string;
6
+ source?: uiTypes.Source;
7
+ }
8
+ export declare const SearchControlButtonConnect: React.FC<SearchControlButtonConnectProps>;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export interface SearchControlConnectProps {
3
+ mapId?: string;
4
+ }
5
+ export declare const SearchControlConnect: React.FC<SearchControlConnectProps>;
@@ -0,0 +1,2 @@
1
+ export { SearchControlButtonConnect } from './SearchControlButtonConnect';
2
+ export { SearchControlConnect } from './SearchControlConnect';