@mapcomponents/react-maplibre 0.1.76 → 0.1.77

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.1.77] - 2023-04-05
4
+
5
+
6
+ ### Fixed
7
+ - 92bac5c: remove deprecated @mui/styles dependency; fixes npm compatibility
8
+
9
+ ### Added
10
+ - 6512e26: add name prop to MlWmsLoader
11
+
12
+ ### Changed
13
+ - 6512e26: make AddLayerPopup initial config state configurable
14
+ - 6512e26: make MlWmsLoader featureInfoActive controllable from parent component
15
+ - 6512e26: make LayerListItemFactory control featureInfoActive to always reflect the state in LayerConfig
16
+
17
+ ### Added
18
+
3
19
  ## [v0.1.76] - 2023-04-04
4
20
 
5
21
  ### Fixed
@@ -34,7 +34,10 @@ export interface MlWmsLoaderProps {
34
34
  zoomToExtent?: boolean;
35
35
  lngLat?: LngLat;
36
36
  idPrefix?: string;
37
+ name?: string;
37
38
  featureInfoEnabled?: boolean;
39
+ featureInfoActive?: boolean;
40
+ setFeatureInfoActive?: (val: boolean | ((current: boolean) => boolean)) => void;
38
41
  config?: WmsConfig;
39
42
  onConfigChange?: (config: WmsConfig | false) => void;
40
43
  setLayers?: (layers: LayerType[]) => void;
package/dist/index.esm.js CHANGED
@@ -6395,8 +6395,8 @@ var MlWmsLoader = function (props) {
6395
6395
  }, [_capabilities]);
6396
6396
  var name = React.useMemo(function () {
6397
6397
  var _a, _b;
6398
- return ((_a = props === null || props === void 0 ? void 0 : props.config) === null || _a === void 0 ? void 0 : _a.name) || ((_b = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Service) === null || _b === void 0 ? void 0 : _b.Title);
6399
- }, [(_f = props === null || props === void 0 ? void 0 : props.config) === null || _f === void 0 ? void 0 : _f.name, (_g = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Service) === null || _g === void 0 ? void 0 : _g.Title]);
6398
+ return (props === null || props === void 0 ? void 0 : props.name) || ((_a = props === null || props === void 0 ? void 0 : props.config) === null || _a === void 0 ? void 0 : _a.name) || ((_b = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Service) === null || _b === void 0 ? void 0 : _b.Title);
6399
+ }, [props === null || props === void 0 ? void 0 : props.name, (_f = props === null || props === void 0 ? void 0 : props.config) === null || _f === void 0 ? void 0 : _f.name, (_g = capabilities === null || capabilities === void 0 ? void 0 : capabilities.Service) === null || _g === void 0 ? void 0 : _g.Title]);
6400
6400
  var layers = React.useMemo(function () {
6401
6401
  var _a;
6402
6402
  if (!(props === null || props === void 0 ? void 0 : props.setLayers))
@@ -6490,10 +6490,11 @@ var MlWmsLoader = function (props) {
6490
6490
  .catch(function (error) { return console.log(error); });
6491
6491
  }, [capabilities, getFeatureInfoUrl, props, mapHook, layers]);
6492
6492
  var _featureInfoEventsEnabled = React.useMemo(function () {
6493
- return (featureInfoEventsEnabled &&
6493
+ return (((typeof (props === null || props === void 0 ? void 0 : props.featureInfoActive) !== 'undefined' && props.featureInfoActive) ||
6494
+ featureInfoEventsEnabled) &&
6494
6495
  (layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })) &&
6495
6496
  !!mapHook.map);
6496
- }, [featureInfoEventsEnabled, layers, mapHook.map]);
6497
+ }, [props === null || props === void 0 ? void 0 : props.featureInfoActive, featureInfoEventsEnabled, layers, mapHook.map]);
6497
6498
  React.useEffect(function () {
6498
6499
  if (!_featureInfoEventsEnabled) {
6499
6500
  resetFeatureInfo();
@@ -6572,7 +6573,14 @@ var MlWmsLoader = function (props) {
6572
6573
  return theme.palette.info.light;
6573
6574
  return theme.palette.grey[300];
6574
6575
  },
6575
- }, "aria-label": "featureinfo", onClick: function () { return setFeatureInfoEventsEnabled(function (current) { return !current; }); }, disabled: !(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })) },
6576
+ }, "aria-label": "featureinfo", onClick: function () {
6577
+ if (typeof (props === null || props === void 0 ? void 0 : props.setFeatureInfoActive) === 'function') {
6578
+ props.setFeatureInfoActive(function (current) { return !current; });
6579
+ }
6580
+ else {
6581
+ setFeatureInfoEventsEnabled(function (current) { return !current; });
6582
+ }
6583
+ }, disabled: !(layers === null || layers === void 0 ? void 0 : layers.some(function (layer) { return layer.visible && layer.queryable; })) },
6576
6584
  React__default["default"].createElement(InfoIcon__default["default"], null))),
6577
6585
  React__default["default"].createElement(IconButton__default["default"], { edge: props.showDeleteButton ? false : 'end', sx: __assign({ padding: '4px', marginTop: '-3px' }, (props.showDeleteButton ? { marginRight: '4px' } : {})), "aria-label": "open", onClick: function () { return setOpen(function (current) { return !current; }); } }, open ? React__default["default"].createElement(iconsMaterial.ExpandLess, null) : React__default["default"].createElement(iconsMaterial.ExpandMore, null)),
6578
6586
  props.showDeleteButton && (React__default["default"].createElement(React__default["default"].Fragment, null,
@@ -7833,7 +7841,7 @@ function LayerListItemFactory(props) {
7833
7841
  layerContext.setBackgroundLayers(state === null || state === void 0 ? void 0 : state.layers);
7834
7842
  }, visible: true, configurable: true, type: "layer", name: "Background" })),
7835
7843
  props.layers.map(function (layer, idx) {
7836
- var _a;
7844
+ var _a, _b;
7837
7845
  if (!(layer === null || layer === void 0 ? void 0 : layer.id))
7838
7846
  return null;
7839
7847
  switch (layer.type) {
@@ -7866,6 +7874,16 @@ function LayerListItemFactory(props) {
7866
7874
  }
7867
7875
  return _layers;
7868
7876
  });
7877
+ }, featureInfoActive: ((_b = layer === null || layer === void 0 ? void 0 : layer.config) === null || _b === void 0 ? void 0 : _b.featureInfoActive) || false, setFeatureInfoActive: function (updateFunction) {
7878
+ var _a;
7879
+ (_a = props === null || props === void 0 ? void 0 : props.setLayers) === null || _a === void 0 ? void 0 : _a.call(props, function (current) {
7880
+ var _a;
7881
+ var _layers = __spreadArray([], current, true);
7882
+ if (typeof updateFunction === 'function') {
7883
+ _layers[idx].config.featureInfoActive = updateFunction(((_a = _layers[idx].config) === null || _a === void 0 ? void 0 : _a.featureInfoActive) || false);
7884
+ }
7885
+ return _layers;
7886
+ });
7869
7887
  }, showDeleteButton: true }))));
7870
7888
  default:
7871
7889
  return null;
@@ -7877,7 +7895,7 @@ function LayerListItemFactory(props) {
7877
7895
  }
7878
7896
  LayerListItemFactory.defaultProps = {
7879
7897
  mapId: undefined,
7880
- layers: []
7898
+ layers: [],
7881
7899
  };
7882
7900
 
7883
7901
  var types = [
@@ -7947,7 +7965,7 @@ function WmsLayerForm(props) {
7947
7965
  }
7948
7966
 
7949
7967
  var AddLayerPopup = function (props) {
7950
- var _a = React.useState(), layerConfig = _a[0], setLayerConfig = _a[1];
7968
+ var _a = React.useState(props === null || props === void 0 ? void 0 : props.config), layerConfig = _a[0], setLayerConfig = _a[1];
7951
7969
  var updateLayerType = function (type) {
7952
7970
  setLayerConfig({ type: type, config: {} });
7953
7971
  };