@opengeoweb/layer-select 9.37.0 → 10.1.0

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 CHANGED
@@ -5,3 +5,7 @@ This library was generated with [Nx](https://nx.dev).
5
5
  ## Running unit tests
6
6
 
7
7
  Run `nx test layer-select` to execute the unit tests via [Jest](https://jestjs.io).
8
+
9
+ ### TypeScript Documentation
10
+
11
+ - [TypeScript Docs](https://opengeoweb.gitlab.io/opengeoweb/typescript-docs/layer-select/)
package/index.esm.js CHANGED
@@ -12,7 +12,7 @@ import 'i18next';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import { FixedSizeList } from 'react-window';
14
14
  import { getDimensionsList, LayerInfoButton } from '@opengeoweb/webmap-react';
15
- import { webmapUtils, LayerType, WMGetServiceFromStore, getCapabilities, clearImageCacheForAllMaps } from '@opengeoweb/webmap';
15
+ import { webmapUtils, LayerType, getWMSServiceId, queryWMSServiceInfo, queryWMSLayers, invalidateWMSGetCapabilities, clearImageCacheForAllMaps } from '@opengeoweb/webmap';
16
16
  import { snackbarTypes, snackbarActions } from '@opengeoweb/snackbar';
17
17
  import { ReactHookFormProvider, defaultFormOptions, ReactHookFormTextField } from '@opengeoweb/form-fields';
18
18
  import { useFormContext } from 'react-hook-form';
@@ -2373,20 +2373,30 @@ var loadWMSService = /*#__PURE__*/function () {
2373
2373
  if (forceReload === void 0) {
2374
2374
  forceReload = false;
2375
2375
  }
2376
- _context.next = 3;
2377
- return getCapabilities.getLayersFlattenedFromService(serviceUrl, forceReload);
2378
- case 3:
2376
+ if (!forceReload) {
2377
+ _context.next = 4;
2378
+ break;
2379
+ }
2380
+ _context.next = 4;
2381
+ return invalidateWMSGetCapabilities(serviceUrl);
2382
+ case 4:
2383
+ _context.next = 6;
2384
+ return queryWMSLayers(serviceUrl);
2385
+ case 6:
2379
2386
  layers = _context.sent;
2380
- service = WMGetServiceFromStore(serviceUrl);
2387
+ _context.next = 9;
2388
+ return queryWMSServiceInfo(serviceUrl);
2389
+ case 9:
2390
+ service = _context.sent;
2381
2391
  return _context.abrupt("return", {
2382
- id: service.id,
2392
+ id: service.id || getWMSServiceId(serviceUrl),
2383
2393
  name: service.title,
2384
2394
  serviceUrl: serviceUrl,
2385
2395
  "abstract": service["abstract"],
2386
2396
  layers: layers,
2387
2397
  scope: 'user'
2388
2398
  });
2389
- case 6:
2399
+ case 11:
2390
2400
  case "end":
2391
2401
  return _context.stop();
2392
2402
  }
@@ -2438,8 +2448,11 @@ var ServiceOptionsDialogConnect = function ServiceOptionsDialogConnect(_ref) {
2438
2448
  isUpdating: true
2439
2449
  })));
2440
2450
  }, [dispatch]);
2441
- var setServicePopupInfo = React.useCallback(function (payload) {
2442
- dispatch(layerSelectActions.toggleServicePopup(Object.assign({}, payload)));
2451
+ var setServicePopupInfo = React.useCallback(function (popupInfo) {
2452
+ var payload = Object.assign({}, popupInfo, {
2453
+ variant: popupInfo.variant || 'default'
2454
+ });
2455
+ dispatch(layerSelectActions.toggleServicePopup(payload));
2443
2456
  }, [dispatch]);
2444
2457
  var showSnackbar = React.useCallback(function (message) {
2445
2458
  dispatch(snackbarActions.openSnackbar(message));
@@ -2675,28 +2688,20 @@ var getTitleForVariant = function getTitleForVariant(t, variant) {
2675
2688
  return 'Service';
2676
2689
  }
2677
2690
  };
2678
- var fields = {
2679
- serviceUrl: {
2680
- name: 'serviceUrl',
2681
- label: 'This service refers to this URL'
2682
- },
2683
- serviceName: {
2684
- name: 'serviceName',
2685
- label: 'Service name'
2686
- },
2687
- serviceAbstracts: {
2688
- name: 'serviceAbstracts',
2689
- label: 'Abstracts'
2690
- }
2691
- };
2691
+ var FormFields;
2692
+ (function (FormFields) {
2693
+ FormFields["serviceUrl"] = "serviceUrl";
2694
+ FormFields["serviceName"] = "serviceName";
2695
+ FormFields["serviceAbstracts"] = "serviceAbstracts";
2696
+ })(FormFields || (FormFields = {}));
2692
2697
  var InitialValidationsTrigger = function InitialValidationsTrigger(_ref) {
2693
2698
  var trigger = _ref.trigger,
2694
2699
  getValues = _ref.getValues,
2695
2700
  onValidField = _ref.onValidField;
2696
2701
  React.useEffect(function () {
2697
- var value = getValues(fields.serviceUrl.name);
2702
+ var value = getValues(FormFields.serviceUrl);
2698
2703
  if (value) {
2699
- void trigger(fields.serviceUrl.name).then(function (isValid) {
2704
+ void trigger(FormFields.serviceUrl).then(function (isValid) {
2700
2705
  return isValid && onValidField(value);
2701
2706
  });
2702
2707
  }
@@ -2746,8 +2751,8 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2746
2751
  return loadWMSService(newServiceUrl, true);
2747
2752
  case 4:
2748
2753
  service = _context.sent;
2749
- setValue(fields.serviceName.name, service.name);
2750
- setValue(fields.serviceAbstracts.name, service["abstract"]);
2754
+ setValue(FormFields.serviceName, service.name);
2755
+ setValue(FormFields.serviceAbstracts, service["abstract"] || '');
2751
2756
  setIsLoading(false);
2752
2757
  setShouldForceReload(false);
2753
2758
  _context.next = 16;
@@ -2757,7 +2762,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2757
2762
  _context.t0 = _context["catch"](0);
2758
2763
  setIsLoading(false);
2759
2764
  setShouldForceReload(true);
2760
- setError(fields.serviceUrl.name, {
2765
+ setError(FormFields.serviceUrl, {
2761
2766
  message: t('validations-request-failed'),
2762
2767
  type: 'SYSTEM'
2763
2768
  });
@@ -2777,7 +2782,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2777
2782
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2778
2783
  while (1) switch (_context2.prev = _context2.next) {
2779
2784
  case 0:
2780
- clearErrors(fields.serviceUrl.name);
2785
+ clearErrors(FormFields.serviceUrl);
2781
2786
  setIsLoading(true);
2782
2787
  _context2.prev = 2;
2783
2788
  _context2.next = 5;
@@ -2801,7 +2806,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2801
2806
  _context2.prev = 12;
2802
2807
  _context2.t0 = _context2["catch"](2);
2803
2808
  setIsLoading(false);
2804
- setError(fields.serviceUrl.name, {
2809
+ setError(FormFields.serviceUrl, {
2805
2810
  message: t('validations-request-failed'),
2806
2811
  type: 'SYSTEM'
2807
2812
  });
@@ -2819,16 +2824,16 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2819
2824
  return validateServiceUrl(t, value, services);
2820
2825
  };
2821
2826
  var onFocusServiceUrl = function onFocusServiceUrl() {
2822
- var hasValue = getValues(fields.serviceUrl.name);
2823
- if (!errors[fields.serviceUrl.name] && hasValue) {
2824
- void trigger(fields.serviceUrl.name);
2827
+ var hasValue = getValues(FormFields.serviceUrl);
2828
+ if (!errors[FormFields.serviceUrl] && hasValue) {
2829
+ void trigger(FormFields.serviceUrl);
2825
2830
  }
2826
2831
  };
2827
2832
  var onBlurServiceUrl = function onBlurServiceUrl() {
2828
- void trigger(fields.serviceUrl.name).then(function () {
2829
- var hasValue = getValues(fields.serviceUrl.name);
2830
- if (!errors[fields.serviceUrl.name] && hasValue) {
2831
- void fetchServiceData(getValues(fields.serviceUrl.name));
2833
+ void trigger(FormFields.serviceUrl).then(function () {
2834
+ var hasValue = getValues(FormFields.serviceUrl);
2835
+ if (!errors[FormFields.serviceUrl] && hasValue) {
2836
+ void fetchServiceData(getValues(FormFields.serviceUrl));
2832
2837
  }
2833
2838
  });
2834
2839
  };
@@ -2841,8 +2846,8 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2841
2846
  return validateServiceName(t, value, services, serviceName);
2842
2847
  };
2843
2848
  var getFormAreRequiredFieldsEmpty = function getFormAreRequiredFieldsEmpty() {
2844
- var serviceNameField = watch(fields.serviceName.name);
2845
- var serviceUrlField = watch(fields.serviceUrl.name);
2849
+ var serviceNameField = watch(FormFields.serviceName);
2850
+ var serviceUrlField = watch(FormFields.serviceUrl);
2846
2851
  return serviceNameField === '' || serviceNameField === undefined || serviceUrlField === '' || serviceUrlField === undefined;
2847
2852
  };
2848
2853
  var getFormHasformErrors = function getFormHasformErrors() {
@@ -2872,7 +2877,9 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2872
2877
  }
2873
2878
  },
2874
2879
  children: jsxs("form", {
2875
- onSubmit: handleSubmit(addNewService),
2880
+ onSubmit: handleSubmit(function (formValues) {
2881
+ return addNewService(formValues);
2882
+ }),
2876
2883
  children: [jsxs(DialogTitle, {
2877
2884
  sx: {
2878
2885
  alignItems: 'center',
@@ -2927,7 +2934,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2927
2934
  padding: '8px 16px'
2928
2935
  },
2929
2936
  children: [jsx(ReactHookFormTextField, {
2930
- name: fields.serviceUrl.name,
2937
+ name: FormFields.serviceUrl,
2931
2938
  label: t('service-url-label'),
2932
2939
  onFocus: onFocusServiceUrl,
2933
2940
  autoFocus: !shouldDisableAutoFocus,
@@ -2961,7 +2968,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2961
2968
  },
2962
2969
  defaultValue: serviceUrl
2963
2970
  }), jsx(ReactHookFormTextField, {
2964
- name: fields.serviceName.name,
2971
+ name: FormFields.serviceName,
2965
2972
  label: t('service-name-label'),
2966
2973
  rules: {
2967
2974
  required: true,
@@ -2979,7 +2986,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2979
2986
  }), jsx(ReactHookFormTextField, {
2980
2987
  multiline: true,
2981
2988
  rows: 4,
2982
- name: fields.serviceAbstracts.name,
2989
+ name: FormFields.serviceAbstracts,
2983
2990
  label: t('service-abstracts-label'),
2984
2991
  disabled: isShowPopup || isLoading,
2985
2992
  isReadOnly: isShowPopup,
@@ -3154,4 +3161,4 @@ var LayerSelectConnect = function LayerSelectConnect(_ref) {
3154
3161
  });
3155
3162
  };
3156
3163
 
3157
- export { AllChipConnect, KeywordFilterButtonConnect, KeywordFilterResults, KeywordFilterResultsConnect, KeywordFilterResultsListItemConnect, KeywordFilterSelectAllSwitchConnect, LAYER_SELECT_NAMESPACE, LayerAddRemoveButton, LayerList, LayerListConnect, LayerListDimensions, LayerListRow, LayerSelectButtonConnect, LayerSelectConnect, SearchFieldConnect, ServiceChip, ServiceChipConnect, ServiceList, ServiceListConnect, ServiceOptionsButton, ServiceOptionsDialog, ServiceOptionsDialogConnect, ServicePopup, ServicePopupConnect, ServicePopupDialogConnect, getServiceFailedUpdateMessage, getServiceSuccesUpdateMessage, getSuccesMessage, isUserAddedService, layerSelectActions, layerSelectConfig, initialState as layerSelectInitialState, reducer as layerSelectReducer, selectors as layerSelectSelectors, layerSelectTranslations, types as layerSelectTypes, useAppSelector };
3164
+ export { AllChipConnect, KeywordFilterButtonConnect, KeywordFilterResults, KeywordFilterResultsConnect, KeywordFilterResultsListItemConnect, KeywordFilterSelectAllSwitchConnect, LAYER_SELECT_NAMESPACE, LayerAddRemoveButton, LayerList, LayerListConnect, LayerListDimensions, LayerListRow, LayerSelectButtonConnect, LayerSelectConnect, SearchFieldConnect, ServiceChip, ServiceChipConnect, ServiceList, ServiceListConnect, ServiceOptionsButton, ServiceOptionsDialog, ServiceOptionsDialogConnect, ServicePopup, ServicePopupConnect, ServicePopupDialogConnect, getServiceFailedUpdateMessage, getServiceSuccesUpdateMessage, getSuccesMessage, isUserAddedService, layerSelectActions, layerSelectConfig, initialState as layerSelectInitialState, layerSelectListener, reducer as layerSelectReducer, selectors as layerSelectSelectors, layerSelectTranslations, types as layerSelectTypes, useAppSelector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/layer-select",
3
- "version": "9.37.0",
3
+ "version": "10.1.0",
4
4
  "description": "GeoWeb layer select library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -13,7 +13,7 @@ export interface ServicePopupInfo {
13
13
  isOpen: boolean;
14
14
  serviceId?: string;
15
15
  serviceUrl?: string;
16
- variant?: layerSelectTypes.PopupVariant;
16
+ variant: layerSelectTypes.PopupVariant;
17
17
  }
18
18
  export declare const ServiceOptionsDialog: React.FC<ServiceOptionsDialogProps>;
19
19
  export {};
@@ -4,3 +4,4 @@ export { useAppSelector } from './selectors';
4
4
  export * as layerSelectTypes from './types';
5
5
  export * from './config';
6
6
  export { isUserAddedService } from './utils';
7
+ export { layerSelectListener } from './listeners';
@@ -82,7 +82,7 @@ export declare const isAllFiltersChecked: ((state: LayerSelectModuleState) => bo
82
82
  * @param {object} store store: object - object from which the service state will be extracted
83
83
  * @returns {array} returnType: LayerWithServiceName - an array of all filtered activelayers
84
84
  */
85
- export declare const getFilteredLayers: ((state: LayerSelectModuleState & import("@opengeoweb/store").CoreAppStore) => LayerWithServiceName[]) & import("reselect").OutputSelectorFields<(args_0: string[], args_1: import("dist/libs/store/src/store/mapStore/types").Services, args_2: string[], args_3: boolean, args_4: string) => LayerWithServiceName[], {
85
+ export declare const getFilteredLayers: ((state: LayerSelectModuleState & import("@opengeoweb/store").CoreAppStore) => LayerWithServiceName[]) & import("reselect").OutputSelectorFields<(args_0: string[], args_1: import("dist/libs/store/src/store/map/types").Services, args_2: string[], args_3: boolean, args_4: string) => LayerWithServiceName[], {
86
86
  clearCache: () => void;
87
87
  }> & {
88
88
  clearCache: () => void;
@@ -1,4 +1,4 @@
1
1
  import { Store } from '@reduxjs/toolkit';
2
2
  import { uiTypes, WebMapStateModuleState } from '@opengeoweb/store';
3
3
  import { LayerSelectModuleState } from '../store/types';
4
- export declare const createMockStore: (mockState: LayerSelectModuleState & uiTypes.UIModuleState & WebMapStateModuleState) => Store;
4
+ export declare const createMockStore: (mockState?: LayerSelectModuleState & uiTypes.UIModuleState & WebMapStateModuleState) => Store;