@opengeoweb/layer-select 10.0.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/index.esm.js CHANGED
@@ -2448,8 +2448,11 @@ var ServiceOptionsDialogConnect = function ServiceOptionsDialogConnect(_ref) {
2448
2448
  isUpdating: true
2449
2449
  })));
2450
2450
  }, [dispatch]);
2451
- var setServicePopupInfo = React.useCallback(function (payload) {
2452
- 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));
2453
2456
  }, [dispatch]);
2454
2457
  var showSnackbar = React.useCallback(function (message) {
2455
2458
  dispatch(snackbarActions.openSnackbar(message));
@@ -2685,28 +2688,20 @@ var getTitleForVariant = function getTitleForVariant(t, variant) {
2685
2688
  return 'Service';
2686
2689
  }
2687
2690
  };
2688
- var fields = {
2689
- serviceUrl: {
2690
- name: 'serviceUrl',
2691
- label: 'This service refers to this URL'
2692
- },
2693
- serviceName: {
2694
- name: 'serviceName',
2695
- label: 'Service name'
2696
- },
2697
- serviceAbstracts: {
2698
- name: 'serviceAbstracts',
2699
- label: 'Abstracts'
2700
- }
2701
- };
2691
+ var FormFields;
2692
+ (function (FormFields) {
2693
+ FormFields["serviceUrl"] = "serviceUrl";
2694
+ FormFields["serviceName"] = "serviceName";
2695
+ FormFields["serviceAbstracts"] = "serviceAbstracts";
2696
+ })(FormFields || (FormFields = {}));
2702
2697
  var InitialValidationsTrigger = function InitialValidationsTrigger(_ref) {
2703
2698
  var trigger = _ref.trigger,
2704
2699
  getValues = _ref.getValues,
2705
2700
  onValidField = _ref.onValidField;
2706
2701
  React.useEffect(function () {
2707
- var value = getValues(fields.serviceUrl.name);
2702
+ var value = getValues(FormFields.serviceUrl);
2708
2703
  if (value) {
2709
- void trigger(fields.serviceUrl.name).then(function (isValid) {
2704
+ void trigger(FormFields.serviceUrl).then(function (isValid) {
2710
2705
  return isValid && onValidField(value);
2711
2706
  });
2712
2707
  }
@@ -2756,8 +2751,8 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2756
2751
  return loadWMSService(newServiceUrl, true);
2757
2752
  case 4:
2758
2753
  service = _context.sent;
2759
- setValue(fields.serviceName.name, service.name);
2760
- setValue(fields.serviceAbstracts.name, service["abstract"]);
2754
+ setValue(FormFields.serviceName, service.name);
2755
+ setValue(FormFields.serviceAbstracts, service["abstract"] || '');
2761
2756
  setIsLoading(false);
2762
2757
  setShouldForceReload(false);
2763
2758
  _context.next = 16;
@@ -2767,7 +2762,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2767
2762
  _context.t0 = _context["catch"](0);
2768
2763
  setIsLoading(false);
2769
2764
  setShouldForceReload(true);
2770
- setError(fields.serviceUrl.name, {
2765
+ setError(FormFields.serviceUrl, {
2771
2766
  message: t('validations-request-failed'),
2772
2767
  type: 'SYSTEM'
2773
2768
  });
@@ -2787,7 +2782,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2787
2782
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2788
2783
  while (1) switch (_context2.prev = _context2.next) {
2789
2784
  case 0:
2790
- clearErrors(fields.serviceUrl.name);
2785
+ clearErrors(FormFields.serviceUrl);
2791
2786
  setIsLoading(true);
2792
2787
  _context2.prev = 2;
2793
2788
  _context2.next = 5;
@@ -2811,7 +2806,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2811
2806
  _context2.prev = 12;
2812
2807
  _context2.t0 = _context2["catch"](2);
2813
2808
  setIsLoading(false);
2814
- setError(fields.serviceUrl.name, {
2809
+ setError(FormFields.serviceUrl, {
2815
2810
  message: t('validations-request-failed'),
2816
2811
  type: 'SYSTEM'
2817
2812
  });
@@ -2829,16 +2824,16 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2829
2824
  return validateServiceUrl(t, value, services);
2830
2825
  };
2831
2826
  var onFocusServiceUrl = function onFocusServiceUrl() {
2832
- var hasValue = getValues(fields.serviceUrl.name);
2833
- if (!errors[fields.serviceUrl.name] && hasValue) {
2834
- void trigger(fields.serviceUrl.name);
2827
+ var hasValue = getValues(FormFields.serviceUrl);
2828
+ if (!errors[FormFields.serviceUrl] && hasValue) {
2829
+ void trigger(FormFields.serviceUrl);
2835
2830
  }
2836
2831
  };
2837
2832
  var onBlurServiceUrl = function onBlurServiceUrl() {
2838
- void trigger(fields.serviceUrl.name).then(function () {
2839
- var hasValue = getValues(fields.serviceUrl.name);
2840
- if (!errors[fields.serviceUrl.name] && hasValue) {
2841
- 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));
2842
2837
  }
2843
2838
  });
2844
2839
  };
@@ -2851,8 +2846,8 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2851
2846
  return validateServiceName(t, value, services, serviceName);
2852
2847
  };
2853
2848
  var getFormAreRequiredFieldsEmpty = function getFormAreRequiredFieldsEmpty() {
2854
- var serviceNameField = watch(fields.serviceName.name);
2855
- var serviceUrlField = watch(fields.serviceUrl.name);
2849
+ var serviceNameField = watch(FormFields.serviceName);
2850
+ var serviceUrlField = watch(FormFields.serviceUrl);
2856
2851
  return serviceNameField === '' || serviceNameField === undefined || serviceUrlField === '' || serviceUrlField === undefined;
2857
2852
  };
2858
2853
  var getFormHasformErrors = function getFormHasformErrors() {
@@ -2882,7 +2877,9 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2882
2877
  }
2883
2878
  },
2884
2879
  children: jsxs("form", {
2885
- onSubmit: handleSubmit(addNewService),
2880
+ onSubmit: handleSubmit(function (formValues) {
2881
+ return addNewService(formValues);
2882
+ }),
2886
2883
  children: [jsxs(DialogTitle, {
2887
2884
  sx: {
2888
2885
  alignItems: 'center',
@@ -2937,7 +2934,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2937
2934
  padding: '8px 16px'
2938
2935
  },
2939
2936
  children: [jsx(ReactHookFormTextField, {
2940
- name: fields.serviceUrl.name,
2937
+ name: FormFields.serviceUrl,
2941
2938
  label: t('service-url-label'),
2942
2939
  onFocus: onFocusServiceUrl,
2943
2940
  autoFocus: !shouldDisableAutoFocus,
@@ -2971,7 +2968,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2971
2968
  },
2972
2969
  defaultValue: serviceUrl
2973
2970
  }), jsx(ReactHookFormTextField, {
2974
- name: fields.serviceName.name,
2971
+ name: FormFields.serviceName,
2975
2972
  label: t('service-name-label'),
2976
2973
  rules: {
2977
2974
  required: true,
@@ -2989,7 +2986,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2989
2986
  }), jsx(ReactHookFormTextField, {
2990
2987
  multiline: true,
2991
2988
  rows: 4,
2992
- name: fields.serviceAbstracts.name,
2989
+ name: FormFields.serviceAbstracts,
2993
2990
  label: t('service-abstracts-label'),
2994
2991
  disabled: isShowPopup || isLoading,
2995
2992
  isReadOnly: isShowPopup,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/layer-select",
3
- "version": "10.0.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 {};
@@ -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;