andoncloud-map-widget 1.0.4 → 1.0.6

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/dist/index.css CHANGED
@@ -1,6 +1,20 @@
1
1
  @import '~leaflet/dist/leaflet.css';
2
2
  @import '~leaflet-draw/dist/leaflet.draw.css';
3
3
 
4
+ @keyframes pulse {
5
+ 0% {
6
+ stroke: #155ed1;
7
+ }
8
+
9
+ 70% {
10
+ stroke: transparent;
11
+ }
12
+
13
+ 100% {
14
+ stroke: #155ed1;
15
+ }
16
+ }
17
+
4
18
  .leaflet-container {
5
19
  height: 100%;
6
20
  }
@@ -66,8 +80,15 @@
66
80
  padding: 0.5em 1em;
67
81
  font-weight: 600;
68
82
  color: white;
69
- border-radius: 1em;
70
- background: #333333;
83
+ box-shadow: none;
84
+ text-shadow: 0px 0px 6px rgba(0, 0, 0, 1);
85
+ border: none;
86
+ background: transparent;
87
+ }
88
+
89
+ .leaflet-path-draggable {
90
+ stroke-dasharray: 10;
91
+ animation: pulse 2s infinite;
71
92
  }
72
93
 
73
94
  .leaflet-contextmenu {
@@ -1 +1 @@
1
- {"version":3,"sources":["index.css","leaflet.contextmenu.css"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,6CAA6C;;AAE7C;EACE,YAAY;AACd;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,4BAA4B;EAC5B,cAAc;EACd,sCAAsC;EACtC,sBAAsB;AACxB;;AAEA;EACE,cAAc;EACd,sBAAsB;EACtB,oBAAoB;AACtB;;AAEA;EACE,aAAa;EACb,UAAU;EACV,YAAY;EACZ,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;EACpB,yBAAyB;AAC3B;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,aAAa;EACb,mBAAmB;AACrB;;AAEA;EACE,SAAS;EACT,gBAAgB;EAChB,aAAa;AACf;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,6BAA6B;AAC/B;;AAEA;EACE,gBAAgB;EAChB,6BAA6B;AAC/B;;AAEA;EACE,kBAAkB;EAClB,gBAAgB;EAChB,YAAY;EACZ,kBAAkB;EAClB,mBAAmB;AACrB;;ACtEA;IACI,aAAa;IACb,qCAAqC;IAErC,kBAAkB;IAClB,cAAc;IACd,sBAAsB;IACtB,eAAe;IACf,yBAAyB;IACzB,sBAAsB;IACtB,iBAAiB;AACrB;;AAEA;IACI,cAAc;IACd,WAAW;IACX,eAAe;IACf,iBAAiB;IACjB,qBAAqB;IACrB,eAAe;IACf,iCAAiC;IACjC,oCAAoC;IACpC,eAAe;IACf,aAAa;AACjB;;AAEA;IACI,YAAY;AAChB;;AAEA;IACI,yBAAyB;IACzB,6BAA6B;IAC7B,gCAAgC;AACpC;;AAEA;IACI,yBAAyB;IACzB,iCAAiC;IACjC,oCAAoC;AACxC;;AAEA;IACI,mBAAmB;IACnB,WAAW;IACX,YAAY;IACZ,WAAW;IACX,SAAS;AACb;;AAEA;IACI,6BAA6B;IAC7B,aAAa;AACjB","file":"index.css","sourcesContent":["@import '~leaflet/dist/leaflet.css';\n@import '~leaflet-draw/dist/leaflet.draw.css';\n\n.leaflet-container {\n height: 100%;\n}\n\n.leaflet-touch .leaflet-bar {\n border: none;\n}\n\n.leaflet-bar a {\n line-height: 27px !important;\n color: #333333;\n border: 0.5px solid rgba(0, 0, 0, 0.1);\n background-color: #ccc;\n}\n\n.leaflet-bar a:hover {\n color: #333333;\n background-color: #ccc;\n filter: opacity(0.9);\n}\n\n.leaflet-top {\n display: flex;\n width: 50%;\n height: 50px;\n background: #333333;\n}\n\n.leaflet-right {\n display: inline-flex;\n justify-content: flex-end;\n}\n\n.leaflet-control-attribution.leaflet-control {\n display: none;\n}\n\n.leaflet-draw {\n height: 100vh;\n background: #333333;\n}\n\n.leaflet-draw.leaflet-control {\n margin: 0;\n margin-top: 50px;\n padding: 10px;\n}\n\n.leaflet-control-zoom {\n display: inline-flex;\n}\n\n.leaflet-control-zoom-in {\n border-radius: 2px !important;\n}\n\n.leaflet-control-zoom-out {\n margin-left: 2px;\n border-radius: 2px !important;\n}\n\n.leaflet-tooltip {\n padding: 0.5em 1em;\n font-weight: 600;\n color: white;\n border-radius: 1em;\n background: #333333;\n}\n",".leaflet-contextmenu {\n display: none;\n box-shadow: 0 1px 7px rgba(0,0,0,0.4);\n -webkit-border-radius: 4px;\n border-radius: 4px;\n padding: 4px 0;\n background-color: #fff;\n cursor: default;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n\n.leaflet-contextmenu a.leaflet-contextmenu-item {\n display: block;\n color: #222;\n font-size: 12px;\n line-height: 20px;\n text-decoration: none;\n padding: 0 12px;\n border-top: 1px solid transparent;\n border-bottom: 1px solid transparent;\n cursor: default;\n outline: none;\n}\n\n.leaflet-contextmenu a.leaflet-contextmenu-item-disabled {\n opacity: 0.5;\n}\n\n.leaflet-contextmenu a.leaflet-contextmenu-item.over {\n background-color: #f4f4f4;\n border-top: 1px solid #f0f0f0;\n border-bottom: 1px solid #f0f0f0;\n}\n\n.leaflet-contextmenu a.leaflet-contextmenu-item-disabled.over {\n background-color: inherit;\n border-top: 1px solid transparent;\n border-bottom: 1px solid transparent;\n}\n\n.leaflet-contextmenu-icon {\n margin: 2px 8px 0 0;\n width: 16px;\n height: 16px;\n float: left;\n border: 0;\n}\n\n.leaflet-contextmenu-separator {\n border-bottom: 1px solid #ccc;\n margin: 5px 0;\n}\n"]}
1
+ {"version":3,"sources":["index.css","leaflet.contextmenu.css"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,6CAA6C;;AAE7C;CACC;IACG,eAAe;CAClB;;CAEA;IACG,mBAAmB;CACtB;;CAEA;IACG,eAAe;CAClB;AACD;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,4BAA4B;EAC5B,cAAc;EACd,sCAAsC;EACtC,sBAAsB;AACxB;;AAEA;EACE,cAAc;EACd,sBAAsB;EACtB,oBAAoB;AACtB;;AAEA;EACE,aAAa;EACb,UAAU;EACV,YAAY;EACZ,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;EACpB,yBAAyB;AAC3B;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,aAAa;EACb,mBAAmB;AACrB;;AAEA;EACE,SAAS;EACT,gBAAgB;EAChB,aAAa;AACf;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,6BAA6B;AAC/B;;AAEA;EACE,gBAAgB;EAChB,6BAA6B;AAC/B;;AAEA;EACE,kBAAkB;EAClB,gBAAgB;EAChB,YAAY;EACZ,gBAAgB;EAChB,yCAAyC;EACzC,YAAY;EACZ,uBAAuB;AACzB;;AAEA;EACE,oBAAoB;EACpB,4BAA4B;AAC9B;;AC3FA;IACI,aAAa;IACb,qCAAqC;IAErC,kBAAkB;IAClB,cAAc;IACd,sBAAsB;IACtB,eAAe;IACf,yBAAyB;IACzB,sBAAsB;IACtB,iBAAiB;AACrB;;AAEA;IACI,cAAc;IACd,WAAW;IACX,eAAe;IACf,iBAAiB;IACjB,qBAAqB;IACrB,eAAe;IACf,iCAAiC;IACjC,oCAAoC;IACpC,eAAe;IACf,aAAa;AACjB;;AAEA;IACI,YAAY;AAChB;;AAEA;IACI,yBAAyB;IACzB,6BAA6B;IAC7B,gCAAgC;AACpC;;AAEA;IACI,yBAAyB;IACzB,iCAAiC;IACjC,oCAAoC;AACxC;;AAEA;IACI,mBAAmB;IACnB,WAAW;IACX,YAAY;IACZ,WAAW;IACX,SAAS;AACb;;AAEA;IACI,6BAA6B;IAC7B,aAAa;AACjB","file":"index.css","sourcesContent":["@import '~leaflet/dist/leaflet.css';\n@import '~leaflet-draw/dist/leaflet.draw.css';\n\n@keyframes pulse {\n\t0% {\n stroke: #155ed1;\n\t}\n\n\t70% {\n stroke: transparent;\n\t}\n\n\t100% {\n stroke: #155ed1;\n\t}\n}\n\n.leaflet-container {\n height: 100%;\n}\n\n.leaflet-touch .leaflet-bar {\n border: none;\n}\n\n.leaflet-bar a {\n line-height: 27px !important;\n color: #333333;\n border: 0.5px solid rgba(0, 0, 0, 0.1);\n background-color: #ccc;\n}\n\n.leaflet-bar a:hover {\n color: #333333;\n background-color: #ccc;\n filter: opacity(0.9);\n}\n\n.leaflet-top {\n display: flex;\n width: 50%;\n height: 50px;\n background: #333333;\n}\n\n.leaflet-right {\n display: inline-flex;\n justify-content: flex-end;\n}\n\n.leaflet-control-attribution.leaflet-control {\n display: none;\n}\n\n.leaflet-draw {\n height: 100vh;\n background: #333333;\n}\n\n.leaflet-draw.leaflet-control {\n margin: 0;\n margin-top: 50px;\n padding: 10px;\n}\n\n.leaflet-control-zoom {\n display: inline-flex;\n}\n\n.leaflet-control-zoom-in {\n border-radius: 2px !important;\n}\n\n.leaflet-control-zoom-out {\n margin-left: 2px;\n border-radius: 2px !important;\n}\n\n.leaflet-tooltip {\n padding: 0.5em 1em;\n font-weight: 600;\n color: white;\n box-shadow: none;\n text-shadow: 0px 0px 6px rgba(0, 0, 0, 1);\n border: none;\n background: transparent;\n}\n\n.leaflet-path-draggable {\n stroke-dasharray: 10;\n animation: pulse 2s infinite;\n}\n",".leaflet-contextmenu {\n display: none;\n box-shadow: 0 1px 7px rgba(0,0,0,0.4);\n -webkit-border-radius: 4px;\n border-radius: 4px;\n padding: 4px 0;\n background-color: #fff;\n cursor: default;\n -webkit-user-select: none;\n -moz-user-select: none;\n user-select: none;\n}\n\n.leaflet-contextmenu a.leaflet-contextmenu-item {\n display: block;\n color: #222;\n font-size: 12px;\n line-height: 20px;\n text-decoration: none;\n padding: 0 12px;\n border-top: 1px solid transparent;\n border-bottom: 1px solid transparent;\n cursor: default;\n outline: none;\n}\n\n.leaflet-contextmenu a.leaflet-contextmenu-item-disabled {\n opacity: 0.5;\n}\n\n.leaflet-contextmenu a.leaflet-contextmenu-item.over {\n background-color: #f4f4f4;\n border-top: 1px solid #f0f0f0;\n border-bottom: 1px solid #f0f0f0;\n}\n\n.leaflet-contextmenu a.leaflet-contextmenu-item-disabled.over {\n background-color: inherit;\n border-top: 1px solid transparent;\n border-bottom: 1px solid transparent;\n}\n\n.leaflet-contextmenu-icon {\n margin: 2px 8px 0 0;\n width: 16px;\n height: 16px;\n float: left;\n border: 0;\n}\n\n.leaflet-contextmenu-separator {\n border-bottom: 1px solid #ccc;\n margin: 5px 0;\n}\n"]}
package/dist/index.js CHANGED
@@ -614,11 +614,7 @@ function Trans(_ref) {
614
614
  defaultNSFromContext = _ref2.defaultNS;
615
615
 
616
616
  var i18n = i18nFromProps || i18nFromContext || getI18n();
617
-
618
- var t = tFromProps || i18n.t.bind(i18n) || function (k) {
619
- return k;
620
- };
621
-
617
+ var t = tFromProps || i18n && i18n.t.bind(i18n);
622
618
  return Trans$1(_objectSpread$9({
623
619
  children: children,
624
620
  count: count,
@@ -629,7 +625,7 @@ function Trans(_ref) {
629
625
  values: values,
630
626
  defaults: defaults,
631
627
  components: components,
632
- ns: ns || t.ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS,
628
+ ns: ns || t && t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
633
629
  i18n: i18n,
634
630
  t: tFromProps,
635
631
  shouldUnescape: shouldUnescape
@@ -2298,6 +2294,7 @@ var Interpolator = function () {
2298
2294
  while (match = this.nestingRegexp.exec(str)) {
2299
2295
  var formatters = [];
2300
2296
  clonedOptions = _objectSpread$3({}, options);
2297
+ clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
2301
2298
  clonedOptions.applyPostProcessor = false;
2302
2299
  delete clonedOptions.defaultValue;
2303
2300
  var doReduce = false;
@@ -3154,7 +3151,14 @@ var I18n = function (_EventEmitter) {
3154
3151
  options.ns = options.ns || fixedT.ns;
3155
3152
  options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
3156
3153
  var keySeparator = _this5.options.keySeparator || '.';
3157
- var resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
3154
+ var resultKey;
3155
+ if (options.keyPrefix && Array.isArray(key)) {
3156
+ resultKey = key.map(function (k) {
3157
+ return "".concat(options.keyPrefix).concat(keySeparator).concat(k);
3158
+ });
3159
+ } else {
3160
+ resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
3161
+ }
3158
3162
  return _this5.t(resultKey, options);
3159
3163
  };
3160
3164
  if (typeof lng === 'string') {
@@ -4324,7 +4328,7 @@ function hasMultilineItems(maybeArray) {
4324
4328
  return maybeArray != null && maybeArray.some(isMultiline);
4325
4329
  }
4326
4330
 
4327
- var LIBRARY_VERSION = '1.0.4';
4331
+ var LIBRARY_VERSION = '1.0.6';
4328
4332
 
4329
4333
  var SettingsFormContent = function SettingsFormContent(_ref) {
4330
4334
  var _data$floorPlans;
@@ -22251,6 +22255,9 @@ var Map$1 = function Map(_ref) {
22251
22255
  var _useState4 = React.useState(null),
22252
22256
  activeLayer = _useState4[0],
22253
22257
  setActiveLayer = _useState4[1];
22258
+ var _useState5 = React.useState(false),
22259
+ viewChanged = _useState5[0],
22260
+ setViewChanged = _useState5[1];
22254
22261
  // use refs to provide current values to callbacks
22255
22262
  var updateFeatureRef = React.useRef();
22256
22263
  var onDrawCreatedRef = React.useRef();
@@ -22260,6 +22267,15 @@ var Map$1 = function Map(_ref) {
22260
22267
  var editModeRef = React.useRef(!!editMode);
22261
22268
  var _useTranslation = useTranslation(),
22262
22269
  t = _useTranslation.t;
22270
+ if (mapRef.current) {
22271
+ var map = mapRef.current;
22272
+ map.on('zoomend', function () {
22273
+ setViewChanged(true);
22274
+ });
22275
+ map.on('moveend', function () {
22276
+ setViewChanged(true);
22277
+ });
22278
+ }
22263
22279
  var createFeature = React.useCallback(function (feature) {
22264
22280
  try {
22265
22281
  var _temp2 = function () {
@@ -22405,7 +22421,10 @@ var Map$1 = function Map(_ref) {
22405
22421
  }, [data == null ? void 0 : data.workplaces]);
22406
22422
  var setControlsDisplay = React.useCallback(function (value) {
22407
22423
  if (featureGroup) {
22408
- document.getElementsByClassName('leaflet-control-container')[0].style['display'] = value ? 'block' : 'none';
22424
+ var containers = document.getElementsByClassName('leaflet-control-container');
22425
+ Array.from(containers).forEach(function (container) {
22426
+ container.style['display'] = value ? 'block' : 'none';
22427
+ });
22409
22428
  }
22410
22429
  }, [featureGroup]);
22411
22430
  var onDrawCreated = React.useCallback(function (layer) {
@@ -22481,15 +22500,9 @@ var Map$1 = function Map(_ref) {
22481
22500
  featureGroup == null ? void 0 : featureGroup.eachLayer(function (layer) {
22482
22501
  var tooltip = layer.getTooltip();
22483
22502
  if (layer === activeLayer) {
22484
- layer.setStyle({
22485
- color: '#155ed1'
22486
- });
22487
22503
  // @ts-ignore no typings
22488
22504
  layer.dragging.enable();
22489
22505
  } else {
22490
- layer.setStyle({
22491
- color: layer.options.fillColor
22492
- });
22493
22506
  // @ts-ignore no typings
22494
22507
  layer.dragging.disable();
22495
22508
  if (tooltip) {
@@ -22621,14 +22634,15 @@ var Map$1 = function Map(_ref) {
22621
22634
  };
22622
22635
  var saveMapView = function saveMapView() {
22623
22636
  try {
22624
- var map = mapRef.current;
22637
+ var _map = mapRef.current;
22625
22638
  var _temp16 = function () {
22626
- if (map && updateSettings) {
22639
+ if (_map && updateSettings) {
22627
22640
  return Promise.resolve(updateSettings({
22628
- zoom: map.getZoom(),
22629
- center: map.getCenter()
22641
+ zoom: _map.getZoom(),
22642
+ center: _map.getCenter()
22630
22643
  })).then(function () {
22631
22644
  setActiveLayer(null);
22645
+ setViewChanged(false);
22632
22646
  });
22633
22647
  }
22634
22648
  }();
@@ -22667,15 +22681,19 @@ var Map$1 = function Map(_ref) {
22667
22681
  }, workplace.name);
22668
22682
  })), React__default["default"].createElement(MapContainer, {
22669
22683
  ref: mapRef,
22670
- bounds: [[height, 0], [0, width]],
22671
22684
  center: (settings == null ? void 0 : settings.center) || [width / 2, height / 2],
22685
+ minZoom: 1,
22686
+ maxZoom: 5,
22672
22687
  zoom: (settings == null ? void 0 : settings.zoom) || 1,
22688
+ zoomSnap: 0.1,
22689
+ zoomDelta: 0.1,
22690
+ wheelPxPerZoomLevel: 600,
22673
22691
  zoomControl: false,
22674
22692
  doubleClickZoom: false,
22675
22693
  touchZoom: false
22676
- }, imageUrl && imageDimensions && React__default["default"].createElement(ImageOverlay, {
22694
+ }, mapRef.current && imageUrl && imageDimensions && React__default["default"].createElement(ImageOverlay, {
22677
22695
  url: imageUrl,
22678
- bounds: [[height, 0], [0, height * (imageDimensions.height / imageDimensions.width)]]
22696
+ bounds: new leafletSrc.LatLngBounds(mapRef.current.unproject([0, imageDimensions.height], 2), mapRef.current.unproject([imageDimensions.width, 0], 2))
22679
22697
  }), React__default["default"].createElement(FeatureGroup, {
22680
22698
  ref: function ref(featureGroup) {
22681
22699
  if (featureGroup) onFeatureGroupReady(featureGroup);
@@ -22741,7 +22759,8 @@ var Map$1 = function Map(_ref) {
22741
22759
  color: "primary",
22742
22760
  onClick: function onClick() {
22743
22761
  return saveMapView();
22744
- }
22762
+ },
22763
+ disabled: !viewChanged
22745
22764
  }, React__default["default"].createElement(Trans, {
22746
22765
  t: t
22747
22766
  }, "Freeze")))));
@@ -22832,7 +22851,8 @@ var Widget = function Widget(_ref) {
22832
22851
  data: widgetData,
22833
22852
  WidgetView: WidgetView,
22834
22853
  SettingsFormContent: SettingsFormContent,
22835
- version: LIBRARY_VERSION
22854
+ version: LIBRARY_VERSION,
22855
+ "data-testid": "map-widget"
22836
22856
  }, widgetProps));
22837
22857
  };
22838
22858