@cashub/ui 0.19.0 → 0.19.1
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/map/GoogleMap.js
CHANGED
|
@@ -365,6 +365,13 @@ var Map = function Map(_ref3) {
|
|
|
365
365
|
|
|
366
366
|
if (edit) {
|
|
367
367
|
circle.addListener('radius_changed', function () {
|
|
368
|
+
var radius = circle.getRadius();
|
|
369
|
+
|
|
370
|
+
if (geoFenceOptions.minRadius && radius < geoFenceOptions.minRadius) {
|
|
371
|
+
circle.setRadius(geoFenceOptions.minRadius);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
|
|
368
375
|
edit(circle.getRadius());
|
|
369
376
|
});
|
|
370
377
|
}
|
|
@@ -383,7 +390,7 @@ var Map = function Map(_ref3) {
|
|
|
383
390
|
window.google.maps.event.clearListeners(circle, 'center_changed');
|
|
384
391
|
};
|
|
385
392
|
}
|
|
386
|
-
}, [map, geoFence, geoFenceOptions.latitude, geoFenceOptions.longitude, geoFenceOptions.radius, geoFenceOptions.editable, geoFenceOptions.eventHandlers]);
|
|
393
|
+
}, [map, geoFence, geoFenceOptions.latitude, geoFenceOptions.longitude, geoFenceOptions.radius, geoFenceOptions.minRadius, geoFenceOptions.editable, geoFenceOptions.eventHandlers]);
|
|
387
394
|
(0, _react.useEffect)(function () {
|
|
388
395
|
if (ref.current && !map) {
|
|
389
396
|
setMap(new window.google.maps.Map(ref.current, {}));
|
package/map/LeafletMap.js
CHANGED
|
@@ -19,6 +19,8 @@ require("react-leaflet-markercluster/dist/styles.min.css");
|
|
|
19
19
|
|
|
20
20
|
var _LeafletMapContainer = _interopRequireDefault(require("./subComponent/LeafletMapContainer"));
|
|
21
21
|
|
|
22
|
+
var _LeafletDrawControl = _interopRequireDefault(require("./subComponent/LeafletDrawControl"));
|
|
23
|
+
|
|
22
24
|
var _map_icon = _interopRequireDefault(require("../assets/icons/map_icon1.png"));
|
|
23
25
|
|
|
24
26
|
var _map_icon2 = _interopRequireDefault(require("../assets/icons/map_icon4.png"));
|
|
@@ -50,6 +52,10 @@ var LeafletMap = function LeafletMap(_ref) {
|
|
|
50
52
|
position: null,
|
|
51
53
|
locations: []
|
|
52
54
|
} : _ref$data,
|
|
55
|
+
_ref$geoFence = _ref.geoFence,
|
|
56
|
+
geoFence = _ref$geoFence === void 0 ? false : _ref$geoFence,
|
|
57
|
+
_ref$geoFenceOptions = _ref.geoFenceOptions,
|
|
58
|
+
geoFenceOptions = _ref$geoFenceOptions === void 0 ? {} : _ref$geoFenceOptions,
|
|
53
59
|
onError = _ref.onError,
|
|
54
60
|
customPopup = _ref.customPopup,
|
|
55
61
|
checkPrimaryLocation = _ref.checkPrimaryLocation,
|
|
@@ -75,11 +81,46 @@ var LeafletMap = function LeafletMap(_ref) {
|
|
|
75
81
|
markers = _useState8[0],
|
|
76
82
|
setMarkers = _useState8[1];
|
|
77
83
|
|
|
84
|
+
var drawControlRef = (0, _react.useRef)();
|
|
78
85
|
var handleError = (0, _react.useCallback)(function (errorCode) {
|
|
79
86
|
if (onError) {
|
|
80
87
|
onError(errorCode);
|
|
81
88
|
}
|
|
82
89
|
}, [onError]);
|
|
90
|
+
var handleMountedDrawControl = (0, _react.useCallback)(function (control) {
|
|
91
|
+
drawControlRef.current = control;
|
|
92
|
+
|
|
93
|
+
if (geoFenceOptions.editable) {
|
|
94
|
+
drawControlRef.current.enableEdit();
|
|
95
|
+
}
|
|
96
|
+
}, [geoFenceOptions.editable]);
|
|
97
|
+
var handleEditResizeDraw = (0, _react.useCallback)(function (event) {
|
|
98
|
+
var minRadius = geoFenceOptions.minRadius,
|
|
99
|
+
eventHandlers = geoFenceOptions.eventHandlers;
|
|
100
|
+
var radius = event.layer.getRadius();
|
|
101
|
+
|
|
102
|
+
if (minRadius && radius < minRadius) {
|
|
103
|
+
event.layer.setRadius(minRadius);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
var tooltips = event.target._panes.popupPane.getElementsByClassName('leaflet-draw-tooltip');
|
|
108
|
+
|
|
109
|
+
for (var index = 0; index < tooltips.length; index += 1) {
|
|
110
|
+
tooltips[index].textContent = "Radius: ".concat(parseInt(radius, 10));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (eventHandlers.edit) {
|
|
114
|
+
eventHandlers.edit(radius);
|
|
115
|
+
}
|
|
116
|
+
}, [geoFenceOptions]);
|
|
117
|
+
var handleEditMoveDraw = (0, _react.useCallback)(function (event) {
|
|
118
|
+
var eventHandlers = geoFenceOptions.eventHandlers;
|
|
119
|
+
|
|
120
|
+
if (eventHandlers.drag) {
|
|
121
|
+
eventHandlers.drag(event.layer.getLatLng());
|
|
122
|
+
}
|
|
123
|
+
}, [geoFenceOptions]);
|
|
83
124
|
(0, _react.useEffect)(function () {
|
|
84
125
|
var defaultPosition = data.defaultPosition,
|
|
85
126
|
position = data.position,
|
|
@@ -144,6 +185,11 @@ var LeafletMap = function LeafletMap(_ref) {
|
|
|
144
185
|
setValidBound(bounds);
|
|
145
186
|
setMarkers(markers);
|
|
146
187
|
}, [data, handleError, customPopup, checkPrimaryLocation]);
|
|
188
|
+
(0, _react.useEffect)(function () {
|
|
189
|
+
if (drawControlRef.current && geoFenceOptions.editable) {
|
|
190
|
+
drawControlRef.current.enableEdit();
|
|
191
|
+
}
|
|
192
|
+
}, [geoFenceOptions.editable]);
|
|
147
193
|
|
|
148
194
|
if (!hasError) {
|
|
149
195
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_LeafletMapContainer.default, {
|
|
@@ -176,6 +222,25 @@ var LeafletMap = function LeafletMap(_ref) {
|
|
|
176
222
|
});
|
|
177
223
|
},
|
|
178
224
|
children: markers
|
|
225
|
+
}), geoFence && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactLeaflet.FeatureGroup, {
|
|
226
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_LeafletDrawControl.default, {
|
|
227
|
+
draw: false,
|
|
228
|
+
edit: {
|
|
229
|
+
edit: false,
|
|
230
|
+
remove: false
|
|
231
|
+
},
|
|
232
|
+
onMounted: handleMountedDrawControl,
|
|
233
|
+
onEditResize: handleEditResizeDraw,
|
|
234
|
+
onEditMove: handleEditMoveDraw
|
|
235
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactLeaflet.Circle, {
|
|
236
|
+
center: [geoFenceOptions.latitude, geoFenceOptions.longitude],
|
|
237
|
+
radius: geoFenceOptions.radius,
|
|
238
|
+
pathOptions: {
|
|
239
|
+
stroke: false,
|
|
240
|
+
fillColor: 'var(--color-primary)',
|
|
241
|
+
fillOpacity: 0.5
|
|
242
|
+
}
|
|
243
|
+
})]
|
|
179
244
|
}), children]
|
|
180
245
|
});
|
|
181
246
|
}
|
|
@@ -62,7 +62,7 @@ _leaflet.default.drawLocal.edit.handlers.edit.tooltip = {
|
|
|
62
62
|
subtext: null
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
var
|
|
65
|
+
var LeafletDrawControl = function LeafletDrawControl(props) {
|
|
66
66
|
var _useLeafletContext = (0, _core.useLeafletContext)(),
|
|
67
67
|
map = _useLeafletContext.map,
|
|
68
68
|
layerContainer = _useLeafletContext.layerContainer;
|
|
@@ -160,5 +160,5 @@ var createDrawElement = function createDrawElement(props, layerContainer) {
|
|
|
160
160
|
return new _leaflet.Control.Draw(options);
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
var _default =
|
|
163
|
+
var _default = LeafletDrawControl;
|
|
164
164
|
exports.default = _default;
|