@opengeoweb/layer-select 10.0.0 → 10.2.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
@@ -7,7 +7,7 @@ import { Filter, LayersAdd, Add, Cached, Edit, Visibility, Delete, Close, Copy }
7
7
  import { uiTypes, serviceActions, selectorMemoizationOptions, serviceSelectors, uiActions, getUserAddedServices, setUserAddedServices, layerActions, uiSelectors, layerSelectors, useSetupDialog, mapSelectors, layerTypes } from '@opengeoweb/store';
8
8
  import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
9
9
  import { compact, countBy, partition } from 'lodash';
10
- import { Switch, Grid2, List, Box, Typography, Backdrop, CircularProgress, Button, ListItem, ListItemText, Dialog, DialogTitle, LinearProgress, DialogContent, InputAdornment, DialogActions } from '@mui/material';
10
+ import { Switch, Grid2, List, Box, Typography, useTheme, Backdrop, CircularProgress, Button, ListItem, ListItemText, Dialog, DialogTitle, LinearProgress, DialogContent, InputAdornment, DialogActions } from '@mui/material';
11
11
  import 'i18next';
12
12
  import { useTranslation } from 'react-i18next';
13
13
  import { FixedSizeList } from 'react-window';
@@ -622,7 +622,7 @@ var getFilteredLayers = createSelector([getEnabledServiceIds, serviceSelectors.g
622
622
  /**
623
623
  * Returns service popup details
624
624
  *
625
- * Example getActiveServices(store, 'server-id');
625
+ * Example getServicePopupDetails(store, 'server-id');
626
626
  * @param {object} store store: object - store object
627
627
  * @returns {object} returnType: object of active service
628
628
  */
@@ -630,6 +630,27 @@ var getServicePopupDetails = function getServicePopupDetails(store) {
630
630
  var _store$layerSelect3;
631
631
  return (store == null || (_store$layerSelect3 = store.layerSelect) == null ? void 0 : _store$layerSelect3.servicePopup) || initialServicePopupState;
632
632
  };
633
+ /**
634
+ * Returns service with active filtered layers from seaerch
635
+ *
636
+ * Example getFilteredActiveServices(store);
637
+ * @param {object} store store: object - store object
638
+ * @returns {object} returnType: object of active service
639
+ */
640
+ var getFilteredActiveServices = createSelector([getFilteredLayers, getActiveServices, getSearchFilter], function (layers, activeServices, searchResult) {
641
+ var servicesResult = searchResult.length ? layers.reduce(function (layers, _ref) {
642
+ var serviceName = _ref.serviceName;
643
+ return layers.includes(serviceName) ? layers : layers.concat(serviceName);
644
+ }, []) : [];
645
+ var updatedServices = Object.fromEntries(Object.entries(activeServices).map(function (_ref2) {
646
+ var key = _ref2[0],
647
+ service = _ref2[1];
648
+ return [key, Object.assign({}, service, {
649
+ isInSearch: servicesResult.includes(service.serviceId)
650
+ })];
651
+ }));
652
+ return updatedServices;
653
+ }, selectorMemoizationOptions);
633
654
 
634
655
  var selectors = /*#__PURE__*/Object.freeze({
635
656
  __proto__: null,
@@ -643,6 +664,7 @@ var selectors = /*#__PURE__*/Object.freeze({
643
664
  getCheckedFilterIds: getCheckedFilterIds,
644
665
  getEnabledServiceIds: getEnabledServiceIds,
645
666
  getFilterById: getFilterById,
667
+ getFilteredActiveServices: getFilteredActiveServices,
646
668
  getFilteredLayers: getFilteredLayers,
647
669
  getFilters: getFilters,
648
670
  getSearchFilter: getSearchFilter,
@@ -1936,9 +1958,12 @@ var ServiceChip = function ServiceChip(_ref) {
1936
1958
  service = _ref.service,
1937
1959
  isSelected = _ref.isSelected,
1938
1960
  isDisabled = _ref.isDisabled,
1939
- toggleChip = _ref.toggleChip;
1961
+ toggleChip = _ref.toggleChip,
1962
+ isInSearch = _ref.isInSearch;
1940
1963
  var _useLayerSelectTransl = useLayerSelectTranslation(),
1941
1964
  t = _useLayerSelectTransl.t;
1965
+ var _useTheme = useTheme(),
1966
+ geowebColors = _useTheme.palette.geowebColors;
1942
1967
  var chip = all ? 'all' : service && service.serviceUrl;
1943
1968
  return jsx(CustomTooltip, {
1944
1969
  title: service != null && service["abstract"] ? "Abstract: " + service["abstract"] : '',
@@ -1955,7 +1980,17 @@ var ServiceChip = function ServiceChip(_ref) {
1955
1980
  return toggleChip(chip);
1956
1981
  },
1957
1982
  disabled: isDisabled,
1958
- sx: style$1,
1983
+ sx: Object.assign({}, style$1, isInSearch && Object.assign({
1984
+ backgroundColor: geowebColors.chip.highlightDefault.rgba + "!important",
1985
+ '&:hover': {
1986
+ backgroundColor: geowebColors.chip.highlightDefaultMouseOver.rgba + "!important"
1987
+ }
1988
+ }, isSelected && {
1989
+ backgroundColor: geowebColors.chip.highlightActiveDefault.rgba + "!important",
1990
+ '&:hover': {
1991
+ backgroundColor: geowebColors.chip.highlightActiveMouseOver.rgba + "!important"
1992
+ }
1993
+ })),
1959
1994
  children: service ? service.serviceName : t('all')
1960
1995
  })
1961
1996
  })
@@ -1967,6 +2002,7 @@ var ServiceChipConnect = function ServiceChipConnect(_ref) {
1967
2002
  isAllSelected = _ref.isAllSelected;
1968
2003
  var dispatch = useDispatch();
1969
2004
  var serviceId = service.serviceId;
2005
+ var isInSearch = service.isInSearch || false;
1970
2006
  var toggleChip = function toggleChip() {
1971
2007
  if (service.enabled) {
1972
2008
  if (isAllSelected) {
@@ -1988,7 +2024,8 @@ var ServiceChipConnect = function ServiceChipConnect(_ref) {
1988
2024
  service: service,
1989
2025
  toggleChip: toggleChip,
1990
2026
  isSelected: isAllSelected ? false : service.enabled,
1991
- isDisabled: service.isLoading
2027
+ isDisabled: service.isLoading,
2028
+ isInSearch: isInSearch
1992
2029
  });
1993
2030
  };
1994
2031
  var AllChipConnect = function AllChipConnect(_ref2) {
@@ -2058,12 +2095,12 @@ var ServiceList = function ServiceList(_ref) {
2058
2095
 
2059
2096
  var ServiceListConnect = function ServiceListConnect(_ref) {
2060
2097
  var setHeight = _ref.setHeight;
2061
- var activeServices = useAppSelector(function (store) {
2062
- return getActiveServices(store);
2098
+ var filteredActiveServices = useAppSelector(function (store) {
2099
+ return getFilteredActiveServices(store);
2063
2100
  });
2064
2101
  return jsx(ServiceList, {
2065
2102
  setHeight: setHeight,
2066
- activeServicesById: sortByService(activeServices)
2103
+ activeServicesById: sortByService(filteredActiveServices)
2067
2104
  });
2068
2105
  };
2069
2106
 
@@ -2448,8 +2485,11 @@ var ServiceOptionsDialogConnect = function ServiceOptionsDialogConnect(_ref) {
2448
2485
  isUpdating: true
2449
2486
  })));
2450
2487
  }, [dispatch]);
2451
- var setServicePopupInfo = React.useCallback(function (payload) {
2452
- dispatch(layerSelectActions.toggleServicePopup(Object.assign({}, payload)));
2488
+ var setServicePopupInfo = React.useCallback(function (popupInfo) {
2489
+ var payload = Object.assign({}, popupInfo, {
2490
+ variant: popupInfo.variant || 'default'
2491
+ });
2492
+ dispatch(layerSelectActions.toggleServicePopup(payload));
2453
2493
  }, [dispatch]);
2454
2494
  var showSnackbar = React.useCallback(function (message) {
2455
2495
  dispatch(snackbarActions.openSnackbar(message));
@@ -2685,28 +2725,20 @@ var getTitleForVariant = function getTitleForVariant(t, variant) {
2685
2725
  return 'Service';
2686
2726
  }
2687
2727
  };
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
- };
2728
+ var FormFields;
2729
+ (function (FormFields) {
2730
+ FormFields["serviceUrl"] = "serviceUrl";
2731
+ FormFields["serviceName"] = "serviceName";
2732
+ FormFields["serviceAbstracts"] = "serviceAbstracts";
2733
+ })(FormFields || (FormFields = {}));
2702
2734
  var InitialValidationsTrigger = function InitialValidationsTrigger(_ref) {
2703
2735
  var trigger = _ref.trigger,
2704
2736
  getValues = _ref.getValues,
2705
2737
  onValidField = _ref.onValidField;
2706
2738
  React.useEffect(function () {
2707
- var value = getValues(fields.serviceUrl.name);
2739
+ var value = getValues(FormFields.serviceUrl);
2708
2740
  if (value) {
2709
- void trigger(fields.serviceUrl.name).then(function (isValid) {
2741
+ void trigger(FormFields.serviceUrl).then(function (isValid) {
2710
2742
  return isValid && onValidField(value);
2711
2743
  });
2712
2744
  }
@@ -2756,8 +2788,8 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2756
2788
  return loadWMSService(newServiceUrl, true);
2757
2789
  case 4:
2758
2790
  service = _context.sent;
2759
- setValue(fields.serviceName.name, service.name);
2760
- setValue(fields.serviceAbstracts.name, service["abstract"]);
2791
+ setValue(FormFields.serviceName, service.name);
2792
+ setValue(FormFields.serviceAbstracts, service["abstract"] || '');
2761
2793
  setIsLoading(false);
2762
2794
  setShouldForceReload(false);
2763
2795
  _context.next = 16;
@@ -2767,7 +2799,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2767
2799
  _context.t0 = _context["catch"](0);
2768
2800
  setIsLoading(false);
2769
2801
  setShouldForceReload(true);
2770
- setError(fields.serviceUrl.name, {
2802
+ setError(FormFields.serviceUrl, {
2771
2803
  message: t('validations-request-failed'),
2772
2804
  type: 'SYSTEM'
2773
2805
  });
@@ -2787,7 +2819,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2787
2819
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
2788
2820
  while (1) switch (_context2.prev = _context2.next) {
2789
2821
  case 0:
2790
- clearErrors(fields.serviceUrl.name);
2822
+ clearErrors(FormFields.serviceUrl);
2791
2823
  setIsLoading(true);
2792
2824
  _context2.prev = 2;
2793
2825
  _context2.next = 5;
@@ -2811,7 +2843,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2811
2843
  _context2.prev = 12;
2812
2844
  _context2.t0 = _context2["catch"](2);
2813
2845
  setIsLoading(false);
2814
- setError(fields.serviceUrl.name, {
2846
+ setError(FormFields.serviceUrl, {
2815
2847
  message: t('validations-request-failed'),
2816
2848
  type: 'SYSTEM'
2817
2849
  });
@@ -2829,16 +2861,16 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2829
2861
  return validateServiceUrl(t, value, services);
2830
2862
  };
2831
2863
  var onFocusServiceUrl = function onFocusServiceUrl() {
2832
- var hasValue = getValues(fields.serviceUrl.name);
2833
- if (!errors[fields.serviceUrl.name] && hasValue) {
2834
- void trigger(fields.serviceUrl.name);
2864
+ var hasValue = getValues(FormFields.serviceUrl);
2865
+ if (!errors[FormFields.serviceUrl] && hasValue) {
2866
+ void trigger(FormFields.serviceUrl);
2835
2867
  }
2836
2868
  };
2837
2869
  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));
2870
+ void trigger(FormFields.serviceUrl).then(function () {
2871
+ var hasValue = getValues(FormFields.serviceUrl);
2872
+ if (!errors[FormFields.serviceUrl] && hasValue) {
2873
+ void fetchServiceData(getValues(FormFields.serviceUrl));
2842
2874
  }
2843
2875
  });
2844
2876
  };
@@ -2851,8 +2883,8 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2851
2883
  return validateServiceName(t, value, services, serviceName);
2852
2884
  };
2853
2885
  var getFormAreRequiredFieldsEmpty = function getFormAreRequiredFieldsEmpty() {
2854
- var serviceNameField = watch(fields.serviceName.name);
2855
- var serviceUrlField = watch(fields.serviceUrl.name);
2886
+ var serviceNameField = watch(FormFields.serviceName);
2887
+ var serviceUrlField = watch(FormFields.serviceUrl);
2856
2888
  return serviceNameField === '' || serviceNameField === undefined || serviceUrlField === '' || serviceUrlField === undefined;
2857
2889
  };
2858
2890
  var getFormHasformErrors = function getFormHasformErrors() {
@@ -2882,7 +2914,9 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2882
2914
  }
2883
2915
  },
2884
2916
  children: jsxs("form", {
2885
- onSubmit: handleSubmit(addNewService),
2917
+ onSubmit: handleSubmit(function (formValues) {
2918
+ return addNewService(formValues);
2919
+ }),
2886
2920
  children: [jsxs(DialogTitle, {
2887
2921
  sx: {
2888
2922
  alignItems: 'center',
@@ -2937,7 +2971,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2937
2971
  padding: '8px 16px'
2938
2972
  },
2939
2973
  children: [jsx(ReactHookFormTextField, {
2940
- name: fields.serviceUrl.name,
2974
+ name: FormFields.serviceUrl,
2941
2975
  label: t('service-url-label'),
2942
2976
  onFocus: onFocusServiceUrl,
2943
2977
  autoFocus: !shouldDisableAutoFocus,
@@ -2971,7 +3005,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2971
3005
  },
2972
3006
  defaultValue: serviceUrl
2973
3007
  }), jsx(ReactHookFormTextField, {
2974
- name: fields.serviceName.name,
3008
+ name: FormFields.serviceName,
2975
3009
  label: t('service-name-label'),
2976
3010
  rules: {
2977
3011
  required: true,
@@ -2989,7 +3023,7 @@ var ServicePopupUnwrapped = function ServicePopupUnwrapped(_ref2) {
2989
3023
  }), jsx(ReactHookFormTextField, {
2990
3024
  multiline: true,
2991
3025
  rows: 4,
2992
- name: fields.serviceAbstracts.name,
3026
+ name: FormFields.serviceAbstracts,
2993
3027
  label: t('service-abstracts-label'),
2994
3028
  disabled: isShowPopup || isLoading,
2995
3029
  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.2.0",
4
4
  "description": "GeoWeb layer select library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -6,6 +6,7 @@ interface ServiceChipProps {
6
6
  isSelected?: boolean;
7
7
  isDisabled?: boolean;
8
8
  toggleChip?: (service: string) => void;
9
+ isInSearch?: boolean;
9
10
  }
10
11
  export declare const ServiceChip: React.FC<ServiceChipProps>;
11
12
  export {};
@@ -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;
@@ -90,8 +90,48 @@ export declare const getFilteredLayers: ((state: LayerSelectModuleState & import
90
90
  /**
91
91
  * Returns service popup details
92
92
  *
93
- * Example getActiveServices(store, 'server-id');
93
+ * Example getServicePopupDetails(store, 'server-id');
94
94
  * @param {object} store store: object - store object
95
95
  * @returns {object} returnType: object of active service
96
96
  */
97
97
  export declare const getServicePopupDetails: (store: LayerSelectModuleState) => ServicePopupObject;
98
+ /**
99
+ * Returns service with active filtered layers from seaerch
100
+ *
101
+ * Example getFilteredActiveServices(store);
102
+ * @param {object} store store: object - store object
103
+ * @returns {object} returnType: object of active service
104
+ */
105
+ export declare const getFilteredActiveServices: ((state: LayerSelectModuleState & import("@opengeoweb/store").CoreAppStore) => {
106
+ [k: string]: {
107
+ isInSearch: boolean;
108
+ serviceId?: string | undefined;
109
+ serviceName?: string | undefined;
110
+ serviceUrl?: string | undefined;
111
+ abstract?: string | undefined;
112
+ enabled?: boolean | undefined;
113
+ filterIds?: string[] | undefined;
114
+ scope?: import("dist/libs/store/src/store/map/types").ServiceScope | undefined;
115
+ isLoading?: boolean | undefined;
116
+ keywords?: string[] | undefined;
117
+ groups?: string[] | undefined;
118
+ };
119
+ }) & import("reselect").OutputSelectorFields<(args_0: LayerWithServiceName[], args_1: ActiveServiceObjectEntities, args_2: string) => {
120
+ [k: string]: {
121
+ isInSearch: boolean;
122
+ serviceId?: string | undefined;
123
+ serviceName?: string | undefined;
124
+ serviceUrl?: string | undefined;
125
+ abstract?: string | undefined;
126
+ enabled?: boolean | undefined;
127
+ filterIds?: string[] | undefined;
128
+ scope?: import("dist/libs/store/src/store/map/types").ServiceScope | undefined;
129
+ isLoading?: boolean | undefined;
130
+ keywords?: string[] | undefined;
131
+ groups?: string[] | undefined;
132
+ };
133
+ }, {
134
+ clearCache: () => void;
135
+ }> & {
136
+ clearCache: () => void;
137
+ };
@@ -15,6 +15,7 @@ export interface ActiveServiceObject {
15
15
  isLoading?: boolean;
16
16
  keywords?: string[];
17
17
  groups?: string[];
18
+ isInSearch?: boolean;
18
19
  }
19
20
  export type FilterType = 'keywords' | 'groups';
20
21
  export interface Filter {
@@ -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;