@mapcomponents/react-maplibre 1.3.0 → 1.3.2

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,22 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.3.1]
4
+
5
+ ## Changed
6
+ - 3f6b50c: Upgrade to maplibre to 5.5.0 (from 5.3.0) (#223)
7
+
8
+ ## [v1.3.0]
9
+
10
+ ## Changed
11
+ - UI design/ogc in MlSketchTool and MlOgcApiFeatures
12
+
13
+ ## Fixed
14
+ - fix MlMarker and improve performance by using a maplibre marker instead of an absolute positioned HTML element
15
+ - fix Storybook demos: MlLayerSwitcher, useCameraFollowPath, MlVectorTileLayer, MlPdfForm, MlThreeJsLayer, MlNavigationCompass
16
+
17
+ ## Removed
18
+ - remove MlComponentTemplate from storybook
19
+
3
20
  ## [v1.2.0]
4
21
 
5
22
  ## Changed
package/dist/index.cjs.js CHANGED
@@ -127,7 +127,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
127
127
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
128
128
  PERFORMANCE OF THIS SOFTWARE.
129
129
  ***************************************************************************** */
130
- /* global Reflect, Promise, SuppressedError, Symbol */
130
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
131
131
 
132
132
 
133
133
  var __assign = function() {
@@ -164,8 +164,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
164
164
  }
165
165
 
166
166
  function __generator(thisArg, body) {
167
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
168
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
167
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
168
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
169
169
  function verb(n) { return function (v) { return step([n, v]); }; }
170
170
  function step(op) {
171
171
  if (f) throw new TypeError("Generator is already executing.");
@@ -2092,8 +2092,7 @@ function featureEditorStyle() {
2092
2092
  },
2093
2093
  paint: {
2094
2094
  'line-color': '#009EE0',
2095
- 'line-width': 10,
2096
- 'line-opacity': 0.2,
2095
+ 'line-width': 4,
2097
2096
  },
2098
2097
  },
2099
2098
  {
@@ -2658,7 +2657,7 @@ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
2658
2657
  // 'fill-color': 'rgba(10,240,256,0.6)',
2659
2658
  // 'fill-outline-color': 'rgba(20,230,256,0.8)',
2660
2659
  'fill-color': '#009EE0',
2661
- 'fill-outline-color': '#009EE0',
2660
+ 'fill-outline-color': '#009EE0'
2662
2661
  };
2663
2662
  case 'line':
2664
2663
  if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.line) {
@@ -2670,7 +2669,7 @@ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
2670
2669
  // 'line-width': 5,
2671
2670
  // 'line-blur': 0,
2672
2671
  'line-color': '#009EE0',
2673
- 'line-width': 5,
2672
+ 'line-width': 4,
2674
2673
  'line-blur': 0,
2675
2674
  };
2676
2675
  case 'circle':
@@ -4387,6 +4386,23 @@ MlLayerSwipe.defaultProps = {
4387
4386
  buttonStyle: {},
4388
4387
  };
4389
4388
 
4389
+ function _arrayLikeToArray(r, a) {
4390
+ (null == a || a > r.length) && (a = r.length);
4391
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4392
+ return n;
4393
+ }
4394
+ function _arrayWithoutHoles(r) {
4395
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
4396
+ }
4397
+ function _iterableToArray(r) {
4398
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
4399
+ }
4400
+ function _nonIterableSpread() {
4401
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4402
+ }
4403
+ function _toConsumableArray(r) {
4404
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
4405
+ }
4390
4406
  function _typeof(o) {
4391
4407
  "@babel/helpers - typeof";
4392
4408
 
@@ -4396,33 +4412,15 @@ function _typeof(o) {
4396
4412
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
4397
4413
  }, _typeof(o);
4398
4414
  }
4399
- function _toConsumableArray(arr) {
4400
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
4401
- }
4402
- function _arrayWithoutHoles(arr) {
4403
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
4404
- }
4405
- function _iterableToArray(iter) {
4406
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
4407
- }
4408
- function _unsupportedIterableToArray(o, minLen) {
4409
- if (!o) return;
4410
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
4411
- var n = Object.prototype.toString.call(o).slice(8, -1);
4412
- if (n === "Object" && o.constructor) n = o.constructor.name;
4413
- if (n === "Map" || n === "Set") return Array.from(o);
4414
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
4415
- }
4416
- function _arrayLikeToArray(arr, len) {
4417
- if (len == null || len > arr.length) len = arr.length;
4418
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
4419
- return arr2;
4420
- }
4421
- function _nonIterableSpread() {
4422
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4415
+ function _unsupportedIterableToArray(r, a) {
4416
+ if (r) {
4417
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
4418
+ var t = {}.toString.call(r).slice(8, -1);
4419
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
4420
+ }
4423
4421
  }
4424
4422
 
4425
- var _showNextTransitionSegment = function _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson) {
4423
+ var _showNextTransitionSegment2 = function _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson) {
4426
4424
  var _arguments = arguments;
4427
4425
  if (typeof transitionGeojsonDataRef.current[currentTransitionStepRef.current] !== "undefined") {
4428
4426
  // if at last transition step set to target geojson
@@ -4435,7 +4433,7 @@ var _showNextTransitionSegment = function _showNextTransitionSegment(props, map,
4435
4433
  currentTransitionStepRef.current++;
4436
4434
  if (transitionInProgressRef.current && currentTransitionStepRef.current < transitionGeojsonDataRef.current.length) {
4437
4435
  transitionTimeoutRef.current = setTimeout(function () {
4438
- return _showNextTransitionSegment.apply(void 0, _toConsumableArray(_arguments));
4436
+ return _showNextTransitionSegment2.apply(void 0, _toConsumableArray(_arguments));
4439
4437
  }, msPerStep);
4440
4438
  } else {
4441
4439
  if (typeof props.onTransitionEnd === "function") {
@@ -4525,7 +4523,7 @@ var _transitionToGeojson = function _transitionToGeojson(props, transitionGeojso
4525
4523
  currentTransitionStepRef.current = 1;
4526
4524
  transitionInProgressRef.current = true;
4527
4525
  transitionTimeoutRef.current = setTimeout(function () {
4528
- return _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson);
4526
+ return _showNextTransitionSegment2(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson);
4529
4527
  }, msPerStep);
4530
4528
  };
4531
4529
  var createTransitionSteps = function createTransitionSteps(linestringCoordinates, perStepDistance, stepCnt) {
@@ -7067,6 +7065,10 @@ var MlSketchTool = function (props) {
7067
7065
  : undefined });
7068
7066
  });
7069
7067
  };
7068
+ var handleCheckboxChange = function (event) {
7069
+ var _a;
7070
+ (_a = props.onShowInstructionChange) === null || _a === void 0 ? void 0 : _a.call(props, event.target.checked);
7071
+ };
7070
7072
  var SketchToolButtons = function () {
7071
7073
  return (React.createElement(React.Fragment, null, sketchTools.map(function (el) {
7072
7074
  var stateColor = function (theme) {
@@ -7098,6 +7100,9 @@ var MlSketchTool = function (props) {
7098
7100
  } },
7099
7101
  React.createElement(ButtonGroup, null,
7100
7102
  React.createElement(SketchToolButtons, null))),
7103
+ React.createElement(system.Box, { sx: { marginTop: '10px' } },
7104
+ React.createElement(material.FormGroup, null,
7105
+ React.createElement(material.FormControlLabel, { control: React.createElement(material.Checkbox, { size: "small", checked: props.showInstruction, onChange: handleCheckboxChange }), label: "Show instructions" }))),
7101
7106
  sketchState.drawMode && (React.createElement(MlFeatureEditor, { mode: sketchState.drawMode, geojson: sketchState.selectedGeoJson, onChange: function (feature) {
7102
7107
  console.log(feature);
7103
7108
  if (!(feature === null || feature === void 0 ? void 0 : feature[0]))
@@ -7142,70 +7147,112 @@ var MlSketchTool = function (props) {
7142
7147
  setSketchState(function (_sketchState) { return (__assign(__assign({}, _sketchState), { drawMode: undefined, activeGeometryIndex: undefined, selectedGeoJson: undefined })); });
7143
7148
  } })),
7144
7149
  React.createElement(List, { sx: { zIndex: 105, marginBottom: '-10px' } },
7145
- sketchState.geometries.map(function (el) { return (React.createElement(React.Fragment, null,
7146
- React.createElement(system.Box, { key: el.id, sx: { display: 'flex', flexDirection: 'column' } },
7147
- React.createElement("br", null),
7148
- React.createElement(system.Box, { flexDirection: 'row', sx: {
7149
- '&:hover': {
7150
- backgroundColor: 'rgb(177, 177, 177, 0.2)',
7151
- },
7152
- marginTop: '25px',
7153
- }, onMouseOver: function () {
7154
- setHoveredGeometry(el);
7155
- }, onMouseLeave: function () {
7156
- setHoveredGeometry(undefined);
7157
- } },
7158
- React.createElement(LayerListItem, { listItemSx: buttonStyle, configurable: true, layerComponent: React.createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: el, layerId: String(el.id), defaultPaintOverrides: {
7159
- fill: { 'fill-opacity': 0.5 },
7160
- } }), type: 'layer', name: String(el.id), description: el.geometry.type }),
7161
- React.createElement(system.Box, { sx: {
7162
- padding: '3px 30px',
7150
+ sketchState.geometries.map(function (el, index) {
7151
+ var _a, _b, _c;
7152
+ return (React.createElement(React.Fragment, null,
7153
+ React.createElement(system.Box, { key: el.id, sx: { display: 'flex', flexDirection: 'column' } },
7154
+ React.createElement("br", null),
7155
+ React.createElement(system.Box, { flexDirection: 'row', sx: {
7156
+ '&:hover': {
7157
+ backgroundColor: 'rgb(177, 177, 177, 0.2)',
7158
+ },
7159
+ marginTop: '25px',
7160
+ }, onMouseOver: function () {
7161
+ setHoveredGeometry(el);
7162
+ }, onMouseLeave: function () {
7163
+ setHoveredGeometry(undefined);
7163
7164
  } },
7164
- React.createElement(ButtonGroup, { size: "small" },
7165
- React.createElement(Tooltip, { title: "Center" },
7166
- React.createElement(material.Button, { sx: __assign({ color: function (theme) { return theme.palette.primary.main; }, backgroundColor: function (theme) { return theme.palette.navigation.navColor; } }, buttonStyle), onClick: function () {
7167
- var _a;
7168
- (_a = mapHook === null || mapHook === void 0 ? void 0 : mapHook.map) === null || _a === void 0 ? void 0 : _a.map.setCenter(el.geometry.type === 'Point'
7169
- ? el.geometry.coordinates
7170
- : turf__namespace.centerOfMass(el).geometry.coordinates);
7171
- } },
7172
- React.createElement(GpsFixedIcon, null))),
7173
- React.createElement(Tooltip, { title: "Edit" },
7174
- React.createElement(material.Button, { sx: __assign({ color: function (theme) {
7175
- var _a;
7176
- if (sketchState.drawMode === 'simple_select' &&
7177
- ((_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id) {
7178
- return theme.palette.navigation.navColor;
7179
- }
7180
- else {
7181
- return theme.palette.primary.main;
7182
- }
7183
- }, backgroundColor: function (theme) {
7184
- var _a;
7185
- if (sketchState.drawMode === 'simple_select' &&
7186
- ((_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id) {
7187
- return theme.palette.primary.main;
7188
- }
7189
- else {
7190
- return theme.palette.navigation.navColor;
7191
- }
7192
- } }, buttonStyle), onClick: function () {
7193
- setSketchState(function (_sketchState) {
7165
+ !((_a = el.properties) === null || _a === void 0 ? void 0 : _a.customName) && (React.createElement("input", { type: "text", value: ((_b = el.properties) === null || _b === void 0 ? void 0 : _b.name) || '', placeholder: "Assign name", onChange: function (e) {
7166
+ var newName = e.target.value;
7167
+ setSketchState(function (_sketchState) {
7168
+ var updatedGeometries = __spreadArray([], _sketchState.geometries, true);
7169
+ if (!updatedGeometries[index].properties) {
7170
+ updatedGeometries[index].properties = {};
7171
+ }
7172
+ updatedGeometries[index].properties.name = newName;
7173
+ return __assign(__assign({}, _sketchState), { geometries: updatedGeometries });
7174
+ });
7175
+ }, style: {
7176
+ padding: '5px',
7177
+ border: '1px solid #ccc',
7178
+ borderRadius: '4px',
7179
+ outline: 'none',
7180
+ }, onFocus: function (e) { return (e.target.style.borderColor = '#009ee0'); }, onBlur: function (e) {
7181
+ e.target.style.borderColor = '#ccc';
7182
+ setSketchState(function (_sketchState) {
7183
+ var updatedGeometries = __spreadArray([], _sketchState.geometries, true);
7184
+ if (!updatedGeometries[index].properties) {
7185
+ updatedGeometries[index].properties = {};
7186
+ }
7187
+ updatedGeometries[index].properties.customName = true;
7188
+ return __assign(__assign({}, _sketchState), { geometries: updatedGeometries });
7189
+ });
7190
+ } })),
7191
+ React.createElement(LayerListItem, { listItemSx: buttonStyle, configurable: true, layerComponent: React.createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: el, layerId: String(el.id), defaultPaintOverrides: {
7192
+ fill: { 'fill-opacity': 0.5 },
7193
+ } }), type: 'layer', name: React.createElement(material.Typography, { onClick: function () {
7194
+ setSketchState(function (_sketchState) {
7195
+ var updatedGeometries = __spreadArray([], _sketchState.geometries, true);
7196
+ if (!updatedGeometries[index].properties) {
7197
+ updatedGeometries[index].properties = {};
7198
+ }
7199
+ updatedGeometries[index].properties.customName = false;
7200
+ return __assign(__assign({}, _sketchState), { geometries: updatedGeometries });
7201
+ });
7202
+ }, sx: {
7203
+ cursor: 'pointer',
7204
+ overflow: 'hidden',
7205
+ whiteSpace: 'nowrap',
7206
+ } }, ((_c = el.properties) === null || _c === void 0 ? void 0 : _c.name) || String(el.id)), description: el.geometry.type }),
7207
+ React.createElement(system.Box, { sx: {
7208
+ padding: '3px 30px',
7209
+ } },
7210
+ React.createElement(ButtonGroup, { size: "small" },
7211
+ React.createElement(Tooltip, { title: "Center" },
7212
+ React.createElement(material.Button, { sx: __assign({ color: function (theme) { return theme.palette.primary.main; }, backgroundColor: function (theme) { return theme.palette.navigation.navColor; } }, buttonStyle), onClick: function () {
7194
7213
  var _a;
7195
- var newDrawMode = _sketchState.drawMode === 'simple_select' &&
7196
- ((_a = _sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id
7197
- ? undefined
7198
- : 'simple_select';
7199
- return __assign(__assign({}, _sketchState), { selectedGeoJson: el, activeGeometryIndex: _sketchState.geometries.indexOf(el), drawMode: newDrawMode });
7200
- });
7201
- } },
7202
- React.createElement(EditIcon, null))),
7203
- React.createElement(Tooltip, { title: "Delete" },
7204
- React.createElement(material.Button, { sx: __assign({ color: function (theme) { return theme.palette.primary.main; }, backgroundColor: function (theme) { return theme.palette.navigation.navColor; } }, buttonStyle), onClick: function () {
7205
- removeGeoJson(el);
7206
- setHoveredGeometry(undefined);
7207
- } },
7208
- React.createElement(DeleteIcon, null))))))))); }),
7214
+ (_a = mapHook === null || mapHook === void 0 ? void 0 : mapHook.map) === null || _a === void 0 ? void 0 : _a.map.setCenter(el.geometry.type === 'Point'
7215
+ ? el.geometry.coordinates
7216
+ : turf__namespace.centerOfMass(el).geometry.coordinates);
7217
+ } },
7218
+ React.createElement(GpsFixedIcon, null))),
7219
+ React.createElement(Tooltip, { title: "Edit" },
7220
+ React.createElement(material.Button, { sx: __assign({ color: function (theme) {
7221
+ var _a;
7222
+ if (sketchState.drawMode === 'simple_select' &&
7223
+ ((_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id) {
7224
+ return theme.palette.navigation.navColor;
7225
+ }
7226
+ else {
7227
+ return theme.palette.primary.main;
7228
+ }
7229
+ }, backgroundColor: function (theme) {
7230
+ var _a;
7231
+ if (sketchState.drawMode === 'simple_select' &&
7232
+ ((_a = sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id) {
7233
+ return theme.palette.primary.main;
7234
+ }
7235
+ else {
7236
+ return theme.palette.navigation.navColor;
7237
+ }
7238
+ } }, buttonStyle), onClick: function () {
7239
+ setSketchState(function (_sketchState) {
7240
+ var _a;
7241
+ var newDrawMode = _sketchState.drawMode === 'simple_select' &&
7242
+ ((_a = _sketchState.selectedGeoJson) === null || _a === void 0 ? void 0 : _a.id) === el.id
7243
+ ? undefined
7244
+ : 'simple_select';
7245
+ return __assign(__assign({}, _sketchState), { selectedGeoJson: el, activeGeometryIndex: _sketchState.geometries.indexOf(el), drawMode: newDrawMode });
7246
+ });
7247
+ } },
7248
+ React.createElement(EditIcon, null))),
7249
+ React.createElement(Tooltip, { title: "Delete" },
7250
+ React.createElement(material.Button, { sx: __assign({ color: function (theme) { return theme.palette.primary.main; }, backgroundColor: function (theme) { return theme.palette.navigation.navColor; } }, buttonStyle), onClick: function () {
7251
+ removeGeoJson(el);
7252
+ setHoveredGeometry(undefined);
7253
+ } },
7254
+ React.createElement(DeleteIcon, null)))))))));
7255
+ }),
7209
7256
  hoveredGeometry && (React.createElement(MlGeoJsonLayer, { mapId: props.mapId, geojson: { type: 'FeatureCollection', features: [hoveredGeometry] }, layerId: 'highlightBorder', defaultPaintOverrides: {
7210
7257
  circle: {
7211
7258
  'circle-color': '#000000',