@cashub/ui 0.18.5 → 0.19.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.
@@ -114,11 +114,13 @@ var Month = function Month(_ref) {
114
114
  return !(minDate1st <= date);
115
115
  } else if (maxDate && !minDate) {
116
116
  maxDate1st.setDate(1);
117
+ maxDate1st.setHours(23, 59, 59, 0);
117
118
  return !(maxDate1st >= date);
118
119
  } else if (minDate && maxDate) {
120
+ minDate1st.setDate(1);
119
121
  minDate1st.setHours(0, 0, 0, 0);
120
122
  maxDate1st.setDate(1);
121
- minDate1st.setDate(1);
123
+ maxDate1st.setHours(23, 59, 59, 0);
122
124
  return !(minDate1st <= date && maxDate1st >= date);
123
125
  }
124
126
  }, [fixedYear, maxDate, minDate, selectedDate]);
@@ -0,0 +1,352 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _react = require("react");
11
+
12
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
13
+
14
+ var _reactWrapper = require("@googlemaps/react-wrapper");
15
+
16
+ var _GoogleMapContainer = _interopRequireDefault(require("../map/subComponent/GoogleMapContainer"));
17
+
18
+ var _Searchbox = _interopRequireDefault(require("../form/Searchbox"));
19
+
20
+ var _map_icon = _interopRequireDefault(require("../assets/icons/map_icon4.png"));
21
+
22
+ var _jsxRuntime = require("react/jsx-runtime");
23
+
24
+ var _templateObject;
25
+
26
+ var _excluded = ["apiKey", "onError"];
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
31
+
32
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
+
34
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
35
+
36
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
+
38
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
39
+
40
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
41
+
42
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
43
+
44
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
45
+
46
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
47
+
48
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
49
+
50
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
51
+
52
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
53
+
54
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
55
+
56
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
57
+
58
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
59
+
60
+ var GoogleReverseGeolocation = function GoogleReverseGeolocation(_ref) {
61
+ var apiKey = _ref.apiKey,
62
+ children = _ref.children,
63
+ defaultLatlng = _ref.defaultLatlng,
64
+ changeLatlng = _ref.changeLatlng,
65
+ onChoose = _ref.onChoose,
66
+ onSearch = _ref.onSearch,
67
+ onError = _ref.onError;
68
+
69
+ var _useState = (0, _react.useState)(defaultLatlng),
70
+ _useState2 = _slicedToArray(_useState, 2),
71
+ markerLatLng = _useState2[0],
72
+ setMarkerLatLng = _useState2[1];
73
+
74
+ var handleChangeLatlng = function handleChangeLatlng(latlng) {
75
+ setMarkerLatLng(latlng);
76
+ changeLatlng(latlng);
77
+ };
78
+
79
+ var confirmChooseLocation = /*#__PURE__*/function () {
80
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(callback) {
81
+ var address;
82
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
83
+ while (1) {
84
+ switch (_context.prev = _context.next) {
85
+ case 0:
86
+ if (!(markerLatLng.lat && markerLatLng.lng)) {
87
+ _context.next = 13;
88
+ break;
89
+ }
90
+
91
+ _context.prev = 1;
92
+ _context.next = 4;
93
+ return onChoose(markerLatLng);
94
+
95
+ case 4:
96
+ address = _context.sent;
97
+
98
+ if (address) {
99
+ callback({
100
+ address: address
101
+ });
102
+ } else {
103
+ callback({
104
+ error: 'ReverseGeo'
105
+ });
106
+ }
107
+
108
+ _context.next = 11;
109
+ break;
110
+
111
+ case 8:
112
+ _context.prev = 8;
113
+ _context.t0 = _context["catch"](1);
114
+ callback(_context.t0);
115
+
116
+ case 11:
117
+ _context.next = 14;
118
+ break;
119
+
120
+ case 13:
121
+ callback({
122
+ error: 'PleaseChooseLocation'
123
+ });
124
+
125
+ case 14:
126
+ case "end":
127
+ return _context.stop();
128
+ }
129
+ }
130
+ }, _callee, null, [[1, 8]]);
131
+ }));
132
+
133
+ return function confirmChooseLocation(_x) {
134
+ return _ref2.apply(this, arguments);
135
+ };
136
+ }();
137
+
138
+ var Map = /*#__PURE__*/(0, _jsxRuntime.jsx)(MapWrapper, {
139
+ apiKey: apiKey,
140
+ height: 512,
141
+ zoom: 3,
142
+ markerLatLng: markerLatLng,
143
+ handleChangeLatlng: handleChangeLatlng,
144
+ onSearch: onSearch,
145
+ onError: onError
146
+ });
147
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
148
+ children: children(Map, confirmChooseLocation)
149
+ });
150
+ };
151
+
152
+ var MapWrapper = function MapWrapper(_ref3) {
153
+ var apiKey = _ref3.apiKey,
154
+ onError = _ref3.onError,
155
+ props = _objectWithoutProperties(_ref3, _excluded);
156
+
157
+ var render = function render(status) {
158
+ switch (status) {
159
+ case _reactWrapper.Status.LOADING:
160
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
161
+
162
+ case _reactWrapper.Status.FAILURE:
163
+ onError(status);
164
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
165
+
166
+ case _reactWrapper.Status.SUCCESS:
167
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Map, _objectSpread(_objectSpread({}, props), {}, {
168
+ onError: onError
169
+ }));
170
+
171
+ default:
172
+ break;
173
+ }
174
+ };
175
+
176
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactWrapper.Wrapper, {
177
+ apiKey: apiKey,
178
+ render: render,
179
+ style: {
180
+ position: 'relative'
181
+ }
182
+ });
183
+ };
184
+
185
+ var Map = function Map(_ref4) {
186
+ var height = _ref4.height,
187
+ zoom = _ref4.zoom,
188
+ markerLatLng = _ref4.markerLatLng,
189
+ handleChangeLatlng = _ref4.handleChangeLatlng,
190
+ onSearch = _ref4.onSearch,
191
+ onError = _ref4.onError;
192
+ var ref = (0, _react.useRef)(null);
193
+
194
+ var _useState3 = (0, _react.useState)(),
195
+ _useState4 = _slicedToArray(_useState3, 2),
196
+ map = _useState4[0],
197
+ setMap = _useState4[1];
198
+
199
+ var _useState5 = (0, _react.useState)({
200
+ lat: 1,
201
+ lng: 1
202
+ }),
203
+ _useState6 = _slicedToArray(_useState5, 2),
204
+ center = _useState6[0],
205
+ setCenter = _useState6[1];
206
+
207
+ var options = (0, _react.useMemo)(function () {
208
+ return {
209
+ zoom: zoom,
210
+ center: center,
211
+ scrollwheel: true,
212
+ zoomControl: true,
213
+ zoomControlOptions: {
214
+ position: window.google.maps.ControlPosition.LEFT_TOP
215
+ },
216
+ mapTypeControl: false,
217
+ scaleControl: false,
218
+ streetViewControl: false,
219
+ rotateControl: false,
220
+ fullscreenControl: false,
221
+ minZoom: 3,
222
+ restriction: {
223
+ latLngBounds: {
224
+ east: 179.9999,
225
+ north: 85,
226
+ south: -85,
227
+ west: -179.9999
228
+ },
229
+ strictBounds: true
230
+ }
231
+ };
232
+ }, [zoom, center]);
233
+
234
+ var handleError = function handleError(errorCode) {
235
+ if (onError) {
236
+ onError(errorCode);
237
+ }
238
+ };
239
+
240
+ var handleSearch = /*#__PURE__*/function () {
241
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(address) {
242
+ var latlng;
243
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
244
+ while (1) {
245
+ switch (_context2.prev = _context2.next) {
246
+ case 0:
247
+ _context2.prev = 0;
248
+ _context2.next = 3;
249
+ return onSearch(address);
250
+
251
+ case 3:
252
+ latlng = _context2.sent;
253
+
254
+ if (latlng) {
255
+ map.panTo(latlng, 15);
256
+ handleChangeLatlng(latlng);
257
+ } else {
258
+ handleError('NO_RESULT');
259
+ }
260
+
261
+ _context2.next = 10;
262
+ break;
263
+
264
+ case 7:
265
+ _context2.prev = 7;
266
+ _context2.t0 = _context2["catch"](0);
267
+ handleError(_context2.t0.message);
268
+
269
+ case 10:
270
+ case "end":
271
+ return _context2.stop();
272
+ }
273
+ }
274
+ }, _callee2, null, [[0, 7]]);
275
+ }));
276
+
277
+ return function handleSearch(_x2) {
278
+ return _ref5.apply(this, arguments);
279
+ };
280
+ }(); // setup map
281
+
282
+
283
+ (0, _react.useEffect)(function () {
284
+ if (map) {
285
+ map.setOptions(options);
286
+ map.addListener('click', function (event) {
287
+ handleChangeLatlng(event.latLng);
288
+ });
289
+ map.addListener('idle', function () {
290
+ setCenter(map.getCenter());
291
+ });
292
+ return function () {
293
+ window.google.maps.event.clearListeners(map, 'click');
294
+ window.google.maps.event.clearListeners(map, 'idle');
295
+ };
296
+ }
297
+ }, [map, options, handleChangeLatlng]); // render marker cluster
298
+
299
+ (0, _react.useEffect)(function () {
300
+ if (map && markerLatLng.lat && markerLatLng.lng) {
301
+ var marker = new window.google.maps.Marker({
302
+ icon: {
303
+ url: _map_icon.default,
304
+ scaledSize: new window.google.maps.Size(40, 50)
305
+ },
306
+ position: markerLatLng
307
+ });
308
+ marker.setMap(map);
309
+ return function () {
310
+ marker.setMap(null);
311
+ };
312
+ }
313
+ }, [map, markerLatLng]);
314
+ (0, _react.useEffect)(function () {
315
+ if (ref.current && !map) {
316
+ setMap(new window.google.maps.Map(ref.current, {}));
317
+ }
318
+ }, [map, options]);
319
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
320
+ style: {
321
+ position: 'relative'
322
+ },
323
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(MapSearchBoxControl, {
324
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Searchbox.default, {
325
+ onSearch: handleSearch,
326
+ autoFocus: true
327
+ })
328
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GoogleMapContainer.default, {
329
+ ref: ref,
330
+ height: height,
331
+ tabIndex: "0",
332
+ onClick: function onClick(event) {
333
+ event.target.focus();
334
+ },
335
+ onFocus: function onFocus() {
336
+ map.setOptions({
337
+ scrollwheel: true
338
+ });
339
+ },
340
+ onBlur: function onBlur() {
341
+ map.setOptions({
342
+ scrollwheel: false
343
+ });
344
+ }
345
+ })]
346
+ });
347
+ };
348
+
349
+ var MapSearchBoxControl = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: var(--spacing-s);\n right: var(--spacing-s);\n z-index: 1;\n"])));
350
+
351
+ var _default = GoogleReverseGeolocation;
352
+ exports.default = _default;
@@ -13,7 +13,7 @@ var _leaflet = _interopRequireDefault(require("leaflet"));
13
13
 
14
14
  var _reactLeaflet = require("react-leaflet");
15
15
 
16
- var _CustomLeafletMapContainer = _interopRequireDefault(require("../map/CustomLeafletMapContainer"));
16
+ var _LeafletMapContainer = _interopRequireDefault(require("../map/subComponent/LeafletMapContainer"));
17
17
 
18
18
  var _MapInteractor = _interopRequireDefault(require("./MapInteractor"));
19
19
 
@@ -43,7 +43,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
43
43
 
44
44
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
45
45
 
46
- var ReverseGeolocation = function ReverseGeolocation(_ref) {
46
+ var LeafletReverseGeolocation = function LeafletReverseGeolocation(_ref) {
47
47
  var children = _ref.children,
48
48
  defaultLatlng = _ref.defaultLatlng,
49
49
  changeLatlng = _ref.changeLatlng,
@@ -127,7 +127,7 @@ var ReverseGeolocation = function ReverseGeolocation(_ref) {
127
127
  };
128
128
  }();
129
129
 
130
- var Map = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CustomLeafletMapContainer.default, {
130
+ var Map = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_LeafletMapContainer.default, {
131
131
  height: 500,
132
132
  center: [1, 1],
133
133
  zoom: 10,
@@ -156,5 +156,5 @@ var ReverseGeolocation = function ReverseGeolocation(_ref) {
156
156
  });
157
157
  };
158
158
 
159
- var _default = ReverseGeolocation;
159
+ var _default = LeafletReverseGeolocation;
160
160
  exports.default = _default;
@@ -3,21 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "MapInteractor", {
6
+ Object.defineProperty(exports, "GoogleReverseGeolocation", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _MapInteractor.default;
9
+ return _GoogleReverseGeolocation.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "ReverseGeolocation", {
12
+ Object.defineProperty(exports, "LeafletReverseGeolocation", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
- return _ReverseGeolocation.default;
15
+ return _LeafletReverseGeolocation.default;
16
16
  }
17
17
  });
18
18
 
19
- var _MapInteractor = _interopRequireDefault(require("./MapInteractor"));
19
+ var _LeafletReverseGeolocation = _interopRequireDefault(require("./LeafletReverseGeolocation"));
20
20
 
21
- var _ReverseGeolocation = _interopRequireDefault(require("./ReverseGeolocation"));
21
+ var _GoogleReverseGeolocation = _interopRequireDefault(require("./GoogleReverseGeolocation"));
22
22
 
23
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,413 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _server = require("react-dom/server");
11
+
12
+ var _reactWrapper = require("@googlemaps/react-wrapper");
13
+
14
+ var _markerclusterer = require("@googlemaps/markerclusterer");
15
+
16
+ var _GoogleMapContainer = _interopRequireDefault(require("./subComponent/GoogleMapContainer"));
17
+
18
+ var _GoogleMapPopup = _interopRequireDefault(require("./subComponent/GoogleMapPopup"));
19
+
20
+ var _map_icon = _interopRequireDefault(require("../assets/icons/map_icon1.png"));
21
+
22
+ var _map_icon2 = _interopRequireDefault(require("../assets/icons/map_icon4.png"));
23
+
24
+ var _jsxRuntime = require("react/jsx-runtime");
25
+
26
+ var _excluded = ["apiKey", "onError"];
27
+
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+
30
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
31
+
32
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
33
+
34
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
35
+
36
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
37
+
38
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
39
+
40
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
41
+
42
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
+
44
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
+
46
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
47
+
48
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
49
+
50
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
51
+
52
+ var GoogleMap = function GoogleMap(_ref) {
53
+ var apiKey = _ref.apiKey,
54
+ _ref$height = _ref.height,
55
+ height = _ref$height === void 0 ? 512 : _ref$height,
56
+ _ref$zoom = _ref.zoom,
57
+ zoom = _ref$zoom === void 0 ? 10 : _ref$zoom,
58
+ _ref$data = _ref.data,
59
+ data = _ref$data === void 0 ? {
60
+ defaultPosition: null,
61
+ position: null,
62
+ locations: []
63
+ } : _ref$data,
64
+ _ref$geoFence = _ref.geoFence,
65
+ geoFence = _ref$geoFence === void 0 ? false : _ref$geoFence,
66
+ _ref$geoFenceOptions = _ref.geoFenceOptions,
67
+ geoFenceOptions = _ref$geoFenceOptions === void 0 ? {} : _ref$geoFenceOptions,
68
+ onError = _ref.onError,
69
+ customPopup = _ref.customPopup,
70
+ checkPrimaryLocation = _ref.checkPrimaryLocation;
71
+
72
+ var _useState = (0, _react.useState)(true),
73
+ _useState2 = _slicedToArray(_useState, 2),
74
+ hasError = _useState2[0],
75
+ setHasError = _useState2[1];
76
+
77
+ var _useState3 = (0, _react.useState)([]),
78
+ _useState4 = _slicedToArray(_useState3, 2),
79
+ validLocations = _useState4[0],
80
+ setValidLocations = _useState4[1];
81
+
82
+ var _useState5 = (0, _react.useState)([]),
83
+ _useState6 = _slicedToArray(_useState5, 2),
84
+ validBounds = _useState6[0],
85
+ setValidBounds = _useState6[1];
86
+
87
+ var handleError = (0, _react.useCallback)(function (errorCode) {
88
+ if (onError) {
89
+ onError(errorCode);
90
+ }
91
+ }, [onError]);
92
+ (0, _react.useEffect)(function () {
93
+ var defaultPosition = data.defaultPosition,
94
+ position = data.position,
95
+ locations = data.locations;
96
+ var validLocations = [];
97
+ var bounds = [];
98
+
99
+ if (!position && !defaultPosition) {
100
+ handleError('NO_COORDINATES');
101
+ setHasError(true);
102
+ return;
103
+ }
104
+
105
+ locations.forEach(function (location) {
106
+ var latitude = location.latitude,
107
+ longitude = location.longitude;
108
+
109
+ if (!latitude && latitude !== 0 || !longitude && longitude !== 0 || latitude === 0 && longitude === 0 || latitude === '0' && longitude === '0') {
110
+ return;
111
+ } // make sure coordinate in number type
112
+
113
+
114
+ latitude = Number(latitude);
115
+ longitude = Number(longitude);
116
+
117
+ if (Number.isNaN(latitude) || Number.isNaN(longitude)) {
118
+ return;
119
+ } // prevent duplicate LatLngBounds
120
+
121
+
122
+ if (!bounds.some(function (LatLng) {
123
+ return latitude === LatLng.lat && longitude === LatLng.lng;
124
+ })) {
125
+ bounds.push({
126
+ lat: latitude,
127
+ lng: longitude
128
+ });
129
+ }
130
+
131
+ validLocations.push(_objectSpread(_objectSpread({}, location), {}, {
132
+ latitude: latitude,
133
+ longitude: longitude
134
+ }));
135
+ }); // pass all checking
136
+
137
+ setHasError(false);
138
+ setValidLocations(validLocations);
139
+ setValidBounds(bounds);
140
+ }, [data, handleError]);
141
+
142
+ if (!hasError) {
143
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(MapWrapper, {
144
+ apiKey: apiKey,
145
+ height: height,
146
+ zoom: zoom,
147
+ defaultPosition: data.defaultPosition,
148
+ position: data.position,
149
+ locations: validLocations,
150
+ bounds: validBounds,
151
+ geoFence: geoFence,
152
+ geoFenceOptions: geoFenceOptions,
153
+ onError: handleError,
154
+ customPopup: customPopup,
155
+ checkPrimaryLocation: checkPrimaryLocation
156
+ });
157
+ }
158
+
159
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
160
+ };
161
+
162
+ var MapWrapper = function MapWrapper(_ref2) {
163
+ var apiKey = _ref2.apiKey,
164
+ onError = _ref2.onError,
165
+ props = _objectWithoutProperties(_ref2, _excluded);
166
+
167
+ var render = function render(status) {
168
+ switch (status) {
169
+ case _reactWrapper.Status.LOADING:
170
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
171
+
172
+ case _reactWrapper.Status.FAILURE:
173
+ onError(status);
174
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
175
+
176
+ case _reactWrapper.Status.SUCCESS:
177
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Map, _objectSpread({}, props));
178
+
179
+ default:
180
+ break;
181
+ }
182
+ };
183
+
184
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactWrapper.Wrapper, {
185
+ apiKey: apiKey,
186
+ render: render
187
+ });
188
+ };
189
+
190
+ var Map = function Map(_ref3) {
191
+ var height = _ref3.height,
192
+ zoom = _ref3.zoom,
193
+ defaultPosition = _ref3.defaultPosition,
194
+ position = _ref3.position,
195
+ locations = _ref3.locations,
196
+ bounds = _ref3.bounds,
197
+ geoFence = _ref3.geoFence,
198
+ geoFenceOptions = _ref3.geoFenceOptions,
199
+ customPopup = _ref3.customPopup,
200
+ checkPrimaryLocation = _ref3.checkPrimaryLocation;
201
+ var ref = (0, _react.useRef)(null);
202
+
203
+ var _useState7 = (0, _react.useState)(),
204
+ _useState8 = _slicedToArray(_useState7, 2),
205
+ map = _useState8[0],
206
+ setMap = _useState8[1];
207
+
208
+ var options = (0, _react.useMemo)(function () {
209
+ return {
210
+ zoom: zoom,
211
+ center: {
212
+ lat: 1,
213
+ lng: 1
214
+ },
215
+ scrollwheel: false,
216
+ zoomControl: true,
217
+ zoomControlOptions: {
218
+ position: window.google.maps.ControlPosition.LEFT_TOP
219
+ },
220
+ mapTypeControl: false,
221
+ scaleControl: false,
222
+ streetViewControl: false,
223
+ rotateControl: false,
224
+ fullscreenControl: false,
225
+ minZoom: 3,
226
+ restriction: {
227
+ latLngBounds: {
228
+ east: 179.9999,
229
+ north: 85,
230
+ south: -85,
231
+ west: -179.9999
232
+ },
233
+ strictBounds: true
234
+ }
235
+ };
236
+ }, [zoom]); // setup map
237
+
238
+ (0, _react.useEffect)(function () {
239
+ if (map) {
240
+ map.setOptions(options);
241
+ window.google.maps.event.addListenerOnce(map, 'idle', function () {
242
+ if (bounds.length === 1) {
243
+ // there is only one location, locate it
244
+ map.setCenter(bounds[0]);
245
+ } else if (locations.length > 0) {
246
+ // locate to the center of all coordinates on first load
247
+ var latLngBounds = new window.google.maps.LatLngBounds();
248
+ bounds.forEach(function (bound) {
249
+ latLngBounds.extend(bound);
250
+ });
251
+ map.fitBounds(latLngBounds);
252
+ var found = locations.find(function (location) {
253
+ return latLngBounds.contains({
254
+ lat: location.latitude,
255
+ lng: location.longitude
256
+ });
257
+ }); // if center no contain any marker then locate to first location
258
+
259
+ if (!found) {
260
+ map.setCenter(bounds[0]);
261
+ }
262
+ } else {
263
+ map.setCenter({
264
+ lat: position && position.latitude || defaultPosition.latitude,
265
+ lng: position && position.longitude || defaultPosition.longitude
266
+ });
267
+ }
268
+ });
269
+ return function () {
270
+ window.google.maps.event.clearListeners(map, 'click');
271
+ };
272
+ }
273
+ }, [map, options, locations, bounds, defaultPosition, position]); // render marker cluster
274
+
275
+ (0, _react.useEffect)(function () {
276
+ if (map && locations.length > 0) {
277
+ var markers = []; // set up popup
278
+
279
+ var popup = new _GoogleMapPopup.default({
280
+ maxWidth: 400,
281
+ offset: 36
282
+ });
283
+ map.addListener('click', function () {
284
+ popup.setMap(null);
285
+ });
286
+ locations.forEach(function (location) {
287
+ var latitude = location.latitude,
288
+ longitude = location.longitude;
289
+ var icon;
290
+
291
+ if (checkPrimaryLocation && checkPrimaryLocation(location)) {
292
+ icon = {
293
+ url: _map_icon.default,
294
+ scaledSize: new window.google.maps.Size(40, 50)
295
+ };
296
+ } else {
297
+ icon = {
298
+ url: _map_icon2.default,
299
+ scaledSize: new window.google.maps.Size(40, 50)
300
+ };
301
+ }
302
+
303
+ var marker = new window.google.maps.Marker({
304
+ icon: icon,
305
+ position: {
306
+ lat: latitude,
307
+ lng: longitude
308
+ }
309
+ });
310
+
311
+ if (customPopup) {
312
+ marker.addListener('click', function (event) {
313
+ event.stop();
314
+ var coordinate = {
315
+ lat: latitude,
316
+ lng: longitude
317
+ };
318
+ map.panTo(coordinate);
319
+ popup.setMap(map);
320
+ popup.setPosition(coordinate);
321
+ popup.setContent((0, _server.renderToString)(customPopup(location)));
322
+ popup.draw();
323
+ });
324
+ }
325
+
326
+ markers.push(marker);
327
+ });
328
+ new _markerclusterer.MarkerClusterer({
329
+ map: map,
330
+ markers: markers,
331
+ algorithm: new _markerclusterer.SuperClusterAlgorithm({
332
+ radius: 120
333
+ })
334
+ });
335
+ }
336
+ }, [map, locations, checkPrimaryLocation, customPopup]); // geofencing
337
+
338
+ (0, _react.useEffect)(function () {
339
+ if (map && geoFence) {
340
+ var circle = new window.google.maps.Circle({
341
+ strokeColor: '#597EF7',
342
+ strokeOpacity: 0,
343
+ strokeWeight: 0,
344
+ fillColor: '#597EF7',
345
+ fillOpacity: 0.5,
346
+ center: {
347
+ lat: geoFenceOptions.latitude,
348
+ lng: geoFenceOptions.longitude
349
+ },
350
+ radius: geoFenceOptions.radius,
351
+ editable: geoFenceOptions.editable,
352
+ draggable: geoFenceOptions.editable
353
+ });
354
+ circle.setMap(map); // add event listener
355
+
356
+ if (geoFenceOptions.eventHandlers) {
357
+ var _geoFenceOptions$even = geoFenceOptions.eventHandlers,
358
+ click = _geoFenceOptions$even.click,
359
+ edit = _geoFenceOptions$even.edit,
360
+ drag = _geoFenceOptions$even.drag;
361
+
362
+ if (click) {
363
+ window.google.maps.event.addListener(circle, 'click', click);
364
+ }
365
+
366
+ if (edit) {
367
+ circle.addListener('radius_changed', function () {
368
+ edit(circle.getRadius());
369
+ });
370
+ }
371
+
372
+ if (drag) {
373
+ circle.addListener('center_changed', function () {
374
+ drag(circle.getCenter());
375
+ });
376
+ }
377
+ }
378
+
379
+ return function () {
380
+ circle.setMap(null);
381
+ window.google.maps.event.clearListeners(circle, 'click');
382
+ window.google.maps.event.clearListeners(circle, 'radius_changed');
383
+ window.google.maps.event.clearListeners(circle, 'center_changed');
384
+ };
385
+ }
386
+ }, [map, geoFence, geoFenceOptions.latitude, geoFenceOptions.longitude, geoFenceOptions.radius, geoFenceOptions.editable, geoFenceOptions.eventHandlers]);
387
+ (0, _react.useEffect)(function () {
388
+ if (ref.current && !map) {
389
+ setMap(new window.google.maps.Map(ref.current, {}));
390
+ }
391
+ }, [map, options]);
392
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_GoogleMapContainer.default, {
393
+ ref: ref,
394
+ height: height,
395
+ tabIndex: "0",
396
+ onClick: function onClick(event) {
397
+ event.target.focus();
398
+ },
399
+ onFocus: function onFocus() {
400
+ map.setOptions({
401
+ scrollwheel: true
402
+ });
403
+ },
404
+ onBlur: function onBlur() {
405
+ map.setOptions({
406
+ scrollwheel: false
407
+ });
408
+ }
409
+ });
410
+ };
411
+
412
+ var _default = GoogleMap;
413
+ exports.default = _default;
package/map/LeafletMap.js CHANGED
@@ -17,7 +17,7 @@ require("leaflet/dist/leaflet.css");
17
17
 
18
18
  require("react-leaflet-markercluster/dist/styles.min.css");
19
19
 
20
- var _CustomLeafletMapContainer = _interopRequireDefault(require("./CustomLeafletMapContainer"));
20
+ var _LeafletMapContainer = _interopRequireDefault(require("./subComponent/LeafletMapContainer"));
21
21
 
22
22
  var _map_icon = _interopRequireDefault(require("../assets/icons/map_icon1.png"));
23
23
 
@@ -146,7 +146,7 @@ var LeafletMap = function LeafletMap(_ref) {
146
146
  }, [data, handleError, customPopup, checkPrimaryLocation]);
147
147
 
148
148
  if (!hasError) {
149
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_CustomLeafletMapContainer.default, {
149
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_LeafletMapContainer.default, {
150
150
  height: height,
151
151
  center: [1, 1],
152
152
  zoom: zoom,
package/map/index.js CHANGED
@@ -3,16 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "CustomLeafletMapContainer", {
6
+ Object.defineProperty(exports, "DrawControl", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _CustomLeafletMapContainer.default;
9
+ return _DrawControl.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "DrawControl", {
12
+ Object.defineProperty(exports, "GoogleMap", {
13
13
  enumerable: true,
14
14
  get: function get() {
15
- return _DrawControl.default;
15
+ return _GoogleMap.default;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "LeafletMap", {
@@ -22,10 +22,10 @@ Object.defineProperty(exports, "LeafletMap", {
22
22
  }
23
23
  });
24
24
 
25
- var _CustomLeafletMapContainer = _interopRequireDefault(require("./CustomLeafletMapContainer"));
26
-
27
25
  var _LeafletMap = _interopRequireDefault(require("./LeafletMap"));
28
26
 
29
27
  var _DrawControl = _interopRequireDefault(require("./DrawControl"));
30
28
 
29
+ var _GoogleMap = _interopRequireDefault(require("./GoogleMap"));
30
+
31
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+
10
+ var _templateObject;
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
15
+
16
+ var GoogleMapContainer = _styledComponents.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: ", "px;\n border: 1px solid transparent;\n border-radius: var(--border-radius);\n\n &:focus {\n border-color: var(--border-color);\n box-shadow: var(--box-shadow);\n }\n\n .google-popup-content-wrapper {\n position: absolute;\n transform: translate(-50%, -100%);\n }\n"])), function (_ref) {
17
+ var height = _ref.height;
18
+ return height;
19
+ });
20
+
21
+ var _default = GoogleMapContainer;
22
+ exports.default = _default;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
9
+
10
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
+
12
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
13
+
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
+
16
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
17
+
18
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19
+
20
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
21
+
22
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
23
+
24
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
+
26
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
+
28
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
29
+
30
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
+
32
+ // custom popup
33
+ // https://developers.google.com/maps/documentation/javascript/examples/overlay-popup
34
+ var GoogleMapPopup = /*#__PURE__*/function (_window$google$maps$O) {
35
+ _inherits(GoogleMapPopup, _window$google$maps$O);
36
+
37
+ var _super = _createSuper(GoogleMapPopup);
38
+
39
+ function GoogleMapPopup() {
40
+ var _this;
41
+
42
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
43
+ maxWidth = _ref.maxWidth,
44
+ offset = _ref.offset;
45
+
46
+ _classCallCheck(this, GoogleMapPopup);
47
+
48
+ _this = _super.call(this); // This zero-height div is positioned at the bottom of the tip.
49
+
50
+ _defineProperty(_assertThisInitialized(_this), "position", void 0);
51
+
52
+ _defineProperty(_assertThisInitialized(_this), "containerDiv", void 0);
53
+
54
+ _defineProperty(_assertThisInitialized(_this), "offset", 16);
55
+
56
+ _this.containerDiv = document.createElement('div');
57
+
58
+ _this.containerDiv.classList.add('google-popup-content-wrapper');
59
+
60
+ if (maxWidth) {
61
+ _this.containerDiv.style.maxWidth = "".concat(maxWidth, "px");
62
+ }
63
+
64
+ if (offset) {
65
+ _this.offset = offset;
66
+ } // Optionally stop clicks, etc., from bubbling up to the map.
67
+
68
+
69
+ GoogleMapPopup.preventMapHitsAndGesturesFrom(_this.containerDiv);
70
+ return _this;
71
+ }
72
+ /** Called when the popup is added to the map. */
73
+
74
+
75
+ _createClass(GoogleMapPopup, [{
76
+ key: "onAdd",
77
+ value: function onAdd() {
78
+ this.getPanes().floatPane.appendChild(this.containerDiv);
79
+ }
80
+ /** Called when the popup is removed from the map. */
81
+
82
+ }, {
83
+ key: "onRemove",
84
+ value: function onRemove() {
85
+ if (this.containerDiv.parentElement) {
86
+ this.containerDiv.parentElement.removeChild(this.containerDiv);
87
+ }
88
+ }
89
+ /** Called each frame when the popup needs to draw itself. */
90
+
91
+ }, {
92
+ key: "draw",
93
+ value: function draw() {
94
+ if (this.position) {
95
+ var divPosition = this.getProjection().fromLatLngToDivPixel(this.position);
96
+ this.containerDiv.style.left = "".concat(divPosition.x, "px");
97
+ this.containerDiv.style.top = "".concat(divPosition.y - this.offset, "px");
98
+ }
99
+ }
100
+ }, {
101
+ key: "setPosition",
102
+ value: function setPosition(position) {
103
+ this.position = position;
104
+ }
105
+ }, {
106
+ key: "setContent",
107
+ value: function setContent(content) {
108
+ if (!content) return;
109
+
110
+ if (_typeof(content) === 'object') {
111
+ this.containerDiv.replaceChildren(content);
112
+ } else {
113
+ this.containerDiv.innerHTML = content;
114
+ }
115
+ }
116
+ }]);
117
+
118
+ return GoogleMapPopup;
119
+ }(window.google.maps.OverlayView);
120
+
121
+ var _default = GoogleMapPopup;
122
+ exports.default = _default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
+
10
+ var _reactLeaflet = require("react-leaflet");
11
+
12
+ var _templateObject;
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
17
+
18
+ var LeafletMapContainer = (0, _styledComponents.default)(_reactLeaflet.MapContainer)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n height: ", "px;\n border: 1px solid transparent;\n border-radius: var(--border-radius);\n z-index: 1;\n\n &:focus {\n border-color: var(--border-color);\n box-shadow: var(--box-shadow);\n }\n\n .leaflet-control-container {\n .leaflet-control-zoom {\n box-shadow: var(--box-shadow);\n border-radius: var(--border-radius);\n\n a {\n background: transparent;\n border-bottom: 1px solid var(--border-color);\n color: var(--font-on-background);\n\n &:last-child {\n border-bottom: none;\n }\n\n &.leaflet-disabled {\n opacity: 0.5;\n }\n }\n }\n\n .leaflet-draw {\n box-shadow: var(--box-shadow);\n border-radius: var(--border-radius);\n\n a {\n background-color: var(--color-background1);\n }\n\n .leaflet-draw-draw-polyline {\n background-position: -3px -3px;\n }\n\n .leaflet-draw-draw-polygon {\n background-position: -32px -3px;\n }\n\n .leaflet-draw-draw-rectangle {\n background-position: -63px -3px;\n }\n\n .leaflet-draw-draw-circle {\n background-position: -93px -3px;\n }\n\n .leaflet-draw-draw-marker {\n background-position: -123px -3px;\n }\n\n .leaflet-draw-draw-circlemarker {\n background-position: -273px -3px;\n }\n\n .leaflet-draw-edit-edit {\n background-position: -213px -3px;\n }\n\n .leaflet-draw-edit-remove {\n background-position: -243px -3px;\n }\n }\n\n .leaflet-left .leaflet-control {\n margin-left: var(--spacing-s);\n }\n\n .leaflet-right .leaflet-control {\n margin-right: var(--spacing-s);\n }\n\n .leaflet-top .leaflet-control {\n margin-top: var(--spacing-s);\n }\n\n .leaflet-control {\n font-weight: bold;\n background: var(--color-background1);\n\n &.leaflet-control-attribution {\n background: var(--color-white);\n color: var(--color-dark);\n margin: 0;\n }\n }\n }\n\n .leaflet-edit-move {\n border-radius: 50px;\n border-color: var(--border-color);\n }\n\n .leaflet-edit-resize {\n border-radius: 50px;\n border-color: var(--border-color);\n }\n\n &.leaflet-touch {\n .leaflet-bar {\n border: none;\n\n a {\n width: 24px;\n height: 24px;\n line-height: 24px;\n }\n }\n\n .leaflet-left .leaflet-control {\n margin-left: var(--spacing-s);\n }\n\n .leaflet-right .leaflet-control {\n margin-right: var(--spacing-s);\n }\n\n .leaflet-top .leaflet-control {\n margin-top: var(--spacing-s);\n }\n }\n\n .marker-cluster {\n background: var(--color-primary) a1;\n\n div {\n background: var(--color-primary);\n color: var(--font-on-primary);\n }\n }\n\n .leaflet-popup-content-wrapper {\n background: transparent;\n box-shadow: unset;\n }\n\n .leaflet-popup-content p {\n margin: 0;\n margin-bottom: var(--spacing-s);\n }\n\n .leaflet-popup-tip {\n display: none;\n }\n\n .sr-only {\n display: none;\n }\n"])), function (_ref) {
19
+ var height = _ref.height;
20
+ return height;
21
+ });
22
+ var _default = LeafletMapContainer;
23
+ exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cashub/ui",
3
- "version": "0.18.5",
3
+ "version": "0.19.0",
4
4
  "private": false,
5
5
  "author": "CASHUB Team",
6
6
  "description": "CASHUB UI components library",
@@ -12,6 +12,8 @@
12
12
  "dependencies": {
13
13
  "@cashub/hooks": "^0.3.1",
14
14
  "@cashub/utils": "^0.5.0",
15
+ "@googlemaps/markerclusterer": "^2.5.1",
16
+ "@googlemaps/react-wrapper": "^1.1.35",
15
17
  "@popperjs/core": "^2.11.5",
16
18
  "@yaireo/tagify": "^4.12.0",
17
19
  "brace": "^0.11.1",
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _styledComponents = _interopRequireDefault(require("styled-components"));
9
-
10
- var _reactLeaflet = require("react-leaflet");
11
-
12
- var _templateObject;
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
17
-
18
- var CustomLeafletMapContainer = (0, _styledComponents.default)(_reactLeaflet.MapContainer)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n height: ", "px;\n border: 1px solid transparent;\n border-radius: var(--border-radius);\n z-index: 1;\n\n &:focus {\n border-color: var(--border-color);\n box-shadow: var(--box-shadow);\n }\n\n .leaflet-control-container {\n .leaflet-control-zoom {\n box-shadow: var(--box-shadow);\n border-radius: var(--border-radius);\n\n a {\n background: transparent;\n border-bottom: 1px solid var(--border-color);\n color: var(--font-on-background);\n\n &:last-child {\n border-bottom: none;\n }\n\n &.leaflet-disabled {\n opacity: 0.5;\n }\n }\n }\n\n .leaflet-draw {\n box-shadow: var(--box-shadow);\n border-radius: var(--border-radius);\n\n a {\n background-color: var(--color-background1);\n }\n\n .leaflet-draw-draw-polyline {\n background-position: -3px -3px;\n }\n\n .leaflet-draw-draw-polygon {\n background-position: -32px -3px;\n }\n\n .leaflet-draw-draw-rectangle {\n background-position: -63px -3px;\n }\n\n .leaflet-draw-draw-circle {\n background-position: -93px -3px;\n }\n\n .leaflet-draw-draw-marker {\n background-position: -123px -3px;\n }\n\n .leaflet-draw-draw-circlemarker {\n background-position: -273px -3px;\n }\n\n .leaflet-draw-edit-edit {\n background-position: -213px -3px;\n }\n\n .leaflet-draw-edit-remove {\n background-position: -243px -3px;\n }\n }\n\n .leaflet-left .leaflet-control {\n margin-left: var(--spacing-s);\n }\n\n .leaflet-right .leaflet-control {\n margin-right: var(--spacing-s);\n }\n\n .leaflet-top .leaflet-control {\n margin-top: var(--spacing-s);\n }\n\n .leaflet-control {\n font-weight: bold;\n background: var(--color-background1);\n\n &.leaflet-control-attribution {\n background: var(--color-white);\n color: var(--color-dark);\n margin: 0;\n }\n }\n }\n\n .leaflet-edit-move {\n border-radius: 50px;\n border-color: var(--border-color);\n }\n\n .leaflet-edit-resize {\n border-radius: 50px;\n border-color: var(--border-color);\n }\n\n &.leaflet-touch {\n .leaflet-bar {\n border: none;\n\n a {\n width: 24px;\n height: 24px;\n line-height: 24px;\n }\n }\n\n .leaflet-left .leaflet-control {\n margin-left: var(--spacing-s);\n }\n\n .leaflet-right .leaflet-control {\n margin-right: var(--spacing-s);\n }\n\n .leaflet-top .leaflet-control {\n margin-top: var(--spacing-s);\n }\n }\n\n .marker-cluster {\n background: var(--color-primary) a1;\n\n div {\n background: var(--color-primary);\n color: var(--font-on-primary);\n }\n }\n\n .leaflet-popup-content-wrapper {\n background: transparent;\n box-shadow: unset;\n }\n\n .leaflet-popup-tip {\n display: none;\n }\n\n .sr-only {\n display: none;\n }\n"])), function (_ref) {
19
- var height = _ref.height;
20
- return height;
21
- });
22
- var _default = CustomLeafletMapContainer;
23
- exports.default = _default;