blixify-ui-web 1.2.120 → 1.2.122

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.
@@ -0,0 +1,8 @@
1
+ export type GoogleMapsLibrary = "maps" | "marker" | "places" | "geocoding" | "drawing" | "geometry";
2
+ export declare const handleLoadGoogleMaps: (libraries?: GoogleMapsLibrary[]) => Promise<boolean>;
3
+ export declare const GOOGLE_MAPS_WAIT_MS = 20000;
4
+ export declare const handleWaitForGoogleMaps: (libraries?: GoogleMapsLibrary[], { isCancelled, timeoutMs, }?: {
5
+ isCancelled?: () => boolean;
6
+ timeoutMs?: number;
7
+ }) => Promise<boolean>;
8
+ //# sourceMappingURL=googleMaps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"googleMaps.d.ts","sourceRoot":"","sources":["../../src/components/googleMaps.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,iBAAiB,GAC3B,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAC;AActE,eAAO,MAAM,oBAAoB,eACpB,iBAAiB,EAAE,KAC7B,OAAO,CAAC,OAAO,CAcjB,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAKzC,eAAO,MAAM,uBAAuB,eACvB,iBAAiB,EAAE,gCAI3B;IAAE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,KACrD,OAAO,CAAC,OAAO,CAQjB,CAAC"}
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ // INFO: the Google Maps JavaScript API is loaded by the host app, not by this library, and apps load
3
+ // it two ways:
4
+ // - a classic <script src=".../maps/api/js?libraries=..."> — window.google only appears once the
5
+ // whole API is loaded, but it may not be there yet when a component mounts (no onload hook);
6
+ // - Google's dynamic bootstrap (@googlemaps/js-api-loader / google.maps.importLibrary) —
7
+ // window.google.maps exists straight away and each library arrives later.
8
+ // Components ask here before touching google.maps, so neither loader can catch them half-loaded.
9
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ var __generator = (this && this.__generator) || function (thisArg, body) {
19
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
20
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
21
+ function verb(n) { return function (v) { return step([n, v]); }; }
22
+ function step(op) {
23
+ if (f) throw new TypeError("Generator is already executing.");
24
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
25
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
26
+ if (y = 0, t) op = [op[0] & 2, t.value];
27
+ switch (op[0]) {
28
+ case 0: case 1: t = op; break;
29
+ case 4: _.label++; return { value: op[1], done: false };
30
+ case 5: _.label++; y = op[1]; op = [0]; continue;
31
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
32
+ default:
33
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
34
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
35
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
36
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
37
+ if (t[2]) _.ops.pop();
38
+ _.trys.pop(); continue;
39
+ }
40
+ op = body.call(thisArg, _);
41
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
42
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
43
+ }
44
+ };
45
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
46
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
47
+ if (ar || !(i in from)) {
48
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
49
+ ar[i] = from[i];
50
+ }
51
+ }
52
+ return to.concat(ar || Array.prototype.slice.call(from));
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.handleWaitForGoogleMaps = exports.GOOGLE_MAPS_WAIT_MS = exports.handleLoadGoogleMaps = void 0;
56
+ // INFO: how to tell a library is already loaded (either loader fills in its google.maps namespace)
57
+ var LIBRARY_LOADED = {
58
+ maps: function (maps) { return typeof maps.Map === "function"; },
59
+ marker: function (maps) { return typeof maps.Marker === "function"; },
60
+ places: function (maps) { var _a; return typeof ((_a = maps.places) === null || _a === void 0 ? void 0 : _a.Autocomplete) === "function"; },
61
+ geocoding: function (maps) { return typeof maps.Geocoder === "function"; },
62
+ drawing: function (maps) { return !!maps.drawing; },
63
+ geometry: function (maps) { return !!maps.geometry; },
64
+ };
65
+ // INFO: true once the named libraries can be used; false when Maps is not there (not loaded,
66
+ // blocked, bad key) or a library fails to load
67
+ var handleLoadGoogleMaps = function () {
68
+ var args_1 = [];
69
+ for (var _i = 0; _i < arguments.length; _i++) {
70
+ args_1[_i] = arguments[_i];
71
+ }
72
+ return __awaiter(void 0, __spreadArray([], args_1, true), void 0, function (libraries) {
73
+ var maps, missing, _a;
74
+ var _b;
75
+ if (libraries === void 0) { libraries = ["maps"]; }
76
+ return __generator(this, function (_c) {
77
+ switch (_c.label) {
78
+ case 0:
79
+ maps = (_b = window.google) === null || _b === void 0 ? void 0 : _b.maps;
80
+ if (!maps)
81
+ return [2 /*return*/, false];
82
+ missing = libraries.filter(function (library) { return !LIBRARY_LOADED[library](maps); });
83
+ if (missing.length === 0)
84
+ return [2 /*return*/, true];
85
+ if (typeof maps.importLibrary !== "function")
86
+ return [2 /*return*/, false];
87
+ _c.label = 1;
88
+ case 1:
89
+ _c.trys.push([1, 3, , 4]);
90
+ return [4 /*yield*/, Promise.all(missing.map(function (library) { return maps.importLibrary(library); }))];
91
+ case 2:
92
+ _c.sent();
93
+ return [2 /*return*/, true];
94
+ case 3:
95
+ _a = _c.sent();
96
+ return [2 /*return*/, false];
97
+ case 4: return [2 /*return*/];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ exports.handleLoadGoogleMaps = handleLoadGoogleMaps;
103
+ exports.GOOGLE_MAPS_WAIT_MS = 20000;
104
+ var GOOGLE_MAPS_POLL_MS = 100;
105
+ // INFO: as handleLoadGoogleMaps, but first waits for window.google.maps to appear (a classic script
106
+ // still loading when the component mounted). isCancelled stops the wait once the caller unmounts.
107
+ var handleWaitForGoogleMaps = function () {
108
+ var args_1 = [];
109
+ for (var _i = 0; _i < arguments.length; _i++) {
110
+ args_1[_i] = arguments[_i];
111
+ }
112
+ return __awaiter(void 0, __spreadArray([], args_1, true), void 0, function (libraries, _a) {
113
+ var deadline;
114
+ var _b;
115
+ if (libraries === void 0) { libraries = ["maps"]; }
116
+ var _c = _a === void 0 ? {} : _a, _d = _c.isCancelled, isCancelled = _d === void 0 ? function () { return false; } : _d, _e = _c.timeoutMs, timeoutMs = _e === void 0 ? exports.GOOGLE_MAPS_WAIT_MS : _e;
117
+ return __generator(this, function (_f) {
118
+ switch (_f.label) {
119
+ case 0:
120
+ deadline = Date.now() + timeoutMs;
121
+ _f.label = 1;
122
+ case 1:
123
+ if (!!((_b = window.google) === null || _b === void 0 ? void 0 : _b.maps)) return [3 /*break*/, 3];
124
+ if (isCancelled() || Date.now() >= deadline)
125
+ return [2 /*return*/, false];
126
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, GOOGLE_MAPS_POLL_MS); })];
127
+ case 2:
128
+ _f.sent();
129
+ return [3 /*break*/, 1];
130
+ case 3:
131
+ if (isCancelled())
132
+ return [2 /*return*/, false];
133
+ return [2 /*return*/, (0, exports.handleLoadGoogleMaps)(libraries)];
134
+ }
135
+ });
136
+ });
137
+ };
138
+ exports.handleWaitForGoogleMaps = handleWaitForGoogleMaps;
139
+ //# sourceMappingURL=googleMaps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"googleMaps.js","sourceRoot":"","sources":["../../src/components/googleMaps.ts"],"names":[],"mappings":";AAAA,qGAAqG;AACrG,eAAe;AACf,mGAAmG;AACnG,iGAAiG;AACjG,2FAA2F;AAC3F,8EAA8E;AAC9E,iGAAiG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKjG,mGAAmG;AACnG,IAAM,cAAc,GAAsD;IACxE,IAAI,EAAE,UAAC,IAAI,IAAK,OAAA,OAAO,IAAI,CAAC,GAAG,KAAK,UAAU,EAA9B,CAA8B;IAC9C,MAAM,EAAE,UAAC,IAAI,IAAK,OAAA,OAAO,IAAI,CAAC,MAAM,KAAK,UAAU,EAAjC,CAAiC;IACnD,MAAM,EAAE,UAAC,IAAI,YAAK,OAAA,OAAO,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,YAAY,CAAA,KAAK,UAAU,CAAA,EAAA;IACjE,SAAS,EAAE,UAAC,IAAI,IAAK,OAAA,OAAO,IAAI,CAAC,QAAQ,KAAK,UAAU,EAAnC,CAAmC;IACxD,OAAO,EAAE,UAAC,IAAI,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,OAAO,EAAd,CAAc;IACjC,QAAQ,EAAE,UAAC,IAAI,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAf,CAAe;CACpC,CAAC;AAEF,6FAA6F;AAC7F,+CAA+C;AACxC,IAAM,oBAA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AC,MAAM,0CAAE,IAAI,CAAA;oBAClC,IAAI,WAAW,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ;wBAAE,sBAAO,KAAK,EAAC;oBAC1D,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,mBAAmB,CAAC,EAAxC,CAAwC,CAAC,EAAA;;oBAAxE,SAAwE,CAAC;;;oBAE3E,IAAI,WAAW,EAAE;wBAAE,sBAAO,KAAK,EAAC;oBAChC,sBAAO,IAAA,4BAAoB,EAAC,SAAS,CAAC,EAAC;;;;CACxC,CAAC;AAdW,QAAA,uBAAuB,2BAclC"}
@@ -57,6 +57,8 @@ export declare class Address extends Component<Props> {
57
57
  placeService: any;
58
58
  state: State;
59
59
  setAsyncState: (newState: any) => Promise<unknown>;
60
+ isUnmounted: boolean;
61
+ componentWillUnmount(): void;
60
62
  componentDidMount(): void;
61
63
  componentDidUpdate: (prevProps: Readonly<Props>) => void;
62
64
  handleGetSafeValue: () => AddressClass;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/input/address/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,YAAY,EAAa,MAAM,OAAO,CAAC;AAOlE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAg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BAAmB,EAAE,GAAG,CAAQ;IAChC,yBAAyB,EAAE,GAAG,CAAQ;IACtC,YAAY,EAAE,GAAG,CAAQ;IACzB,KAAK,EAAE,KAAK,CAOV;IAEF,aAAa,sCACqD;IAElE,WAAW,UAAS;IAEpB,oBAAoB;IAIpB,iBAAiB;IAqEjB,kBAAkB,cAAe,QAAQ,CAAC,KAAK,CAAC,KAAG,IAAI,CAWrD;IAKF,kBAAkB,QAAO,YAAY,CAUnC;IAEF,YAAY,yBAmBV;IAEF,yBAAyB,0BAA2B,GAAG,UA4CrD;IAEF,cAAc,MAAO,GAAG,UAatB;IAEF,gBAAgB,aAMd;IAEF,WAAW,aAST;IAEF,iBAAiB,aAMf;IAEF,kBAAkB,sBAwEhB;IAEF,wBAAwB,aA0CtB;IAEF,mBAAmB,MAAO,GAAG,UAI3B;IAEF,kBAAkB,aAIhB;IAEF,iBAAiB,0BA2Ef;IAEF,cAAc,0BAsDZ;IAEF,MAAM;CA+LP"}
@@ -94,6 +94,7 @@ var infoWindow_1 = require("../../advanced/infoWindow");
94
94
  var modal_1 = require("../../display/modal");
95
95
  var form_1 = require("../form");
96
96
  var textInput_1 = require("../textInput");
97
+ var googleMaps_1 = require("../../googleMaps");
97
98
  var Address = /** @class */ (function (_super) {
98
99
  __extends(Address, _super);
99
100
  function Address() {
@@ -115,6 +116,7 @@ var Address = /** @class */ (function (_super) {
115
116
  _this.setAsyncState = function (newState) {
116
117
  return new Promise(function (resolve) { return _this.setState(newState, resolve); });
117
118
  };
119
+ _this.isUnmounted = false;
118
120
  _this.componentDidUpdate = function (prevProps) {
119
121
  if (JSON.stringify(prevProps.value) !== JSON.stringify(_this.props.value)) {
120
122
  if (_this.props.value) {
@@ -256,71 +258,84 @@ var Address = /** @class */ (function (_super) {
256
258
  _this.handleSubmitLatLng = function () { return __awaiter(_this, void 0, void 0, function () {
257
259
  var initialAddress;
258
260
  var _this = this;
259
- var _a, _b;
260
- return __generator(this, function (_c) {
261
- switch (_c.label) {
262
- case 0: return [4 /*yield*/, new Promise(function (resolve) {
263
- var geocoder = new window.google.maps.Geocoder();
264
- var latlng = {
265
- lat: Number(_this.state.lat),
266
- lng: Number(_this.state.lng),
267
- };
268
- geocoder.geocode({ location: latlng }, function (results, status) {
269
- var _a, _b, _c, _d, _e, _f;
270
- if (status === "OK") {
271
- if (results[0]) {
272
- var initialAddress_1 = {
273
- name: "",
274
- lat: 0,
275
- lng: 0,
276
- district: "",
277
- state: "",
278
- country: "",
279
- poi: _this.props.value.poi || "",
280
- };
281
- if (results[0].address_components) {
282
- results[0].address_components.map(function (eachAddress) {
283
- var _a, _b, _c;
284
- if (eachAddress.types.includes("country")) {
285
- initialAddress_1["country"] = (_a = eachAddress.long_name) !== null && _a !== void 0 ? _a : "";
286
- }
287
- else if (eachAddress.types.includes("administrative_area_level_1")) {
288
- initialAddress_1["state"] = (_b = eachAddress.long_name) !== null && _b !== void 0 ? _b : "";
289
- }
290
- else if (eachAddress.types.includes("locality")) {
291
- initialAddress_1["district"] = (_c = eachAddress.long_name) !== null && _c !== void 0 ? _c : "";
292
- }
293
- return "";
261
+ var _a, _b, _c, _d, _e, _f, _g;
262
+ return __generator(this, function (_h) {
263
+ switch (_h.label) {
264
+ case 0: return [4 /*yield*/, (0, googleMaps_1.handleLoadGoogleMaps)(["geocoding"])];
265
+ case 1:
266
+ // INFO: without Maps the typed coordinates are still kept, just not named by the geocoder
267
+ if (!(_h.sent())) {
268
+ (_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, {
269
+ name: (_d = (_c = this.props.value) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "",
270
+ lat: Number(this.state.lat),
271
+ lng: Number(this.state.lng),
272
+ poi: ((_e = this.props.value) === null || _e === void 0 ? void 0 : _e.poi) || "",
273
+ });
274
+ this.setState({ modalVisible: false });
275
+ return [2 /*return*/];
276
+ }
277
+ return [4 /*yield*/, new Promise(function (resolve) {
278
+ var geocoder = new window.google.maps.Geocoder();
279
+ var latlng = {
280
+ lat: Number(_this.state.lat),
281
+ lng: Number(_this.state.lng),
282
+ };
283
+ geocoder.geocode({ location: latlng }, function (results, status) {
284
+ var _a, _b, _c, _d, _e, _f;
285
+ if (status === "OK") {
286
+ if (results[0]) {
287
+ var initialAddress_1 = {
288
+ name: "",
289
+ lat: 0,
290
+ lng: 0,
291
+ district: "",
292
+ state: "",
293
+ country: "",
294
+ poi: _this.props.value.poi || "",
295
+ };
296
+ if (results[0].address_components) {
297
+ results[0].address_components.map(function (eachAddress) {
298
+ var _a, _b, _c;
299
+ if (eachAddress.types.includes("country")) {
300
+ initialAddress_1["country"] = (_a = eachAddress.long_name) !== null && _a !== void 0 ? _a : "";
301
+ }
302
+ else if (eachAddress.types.includes("administrative_area_level_1")) {
303
+ initialAddress_1["state"] = (_b = eachAddress.long_name) !== null && _b !== void 0 ? _b : "";
304
+ }
305
+ else if (eachAddress.types.includes("locality")) {
306
+ initialAddress_1["district"] = (_c = eachAddress.long_name) !== null && _c !== void 0 ? _c : "";
307
+ }
308
+ return "";
309
+ });
310
+ }
311
+ initialAddress_1["name"] =
312
+ (_b = (_a = _this.props.value) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : results[0].formatted_address;
313
+ initialAddress_1["lat"] = Number(_this.state.lat);
314
+ initialAddress_1["lng"] = Number(_this.state.lng);
315
+ resolve(initialAddress_1);
316
+ }
317
+ else {
318
+ resolve({
319
+ name: (_d = (_c = _this.props.value) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "",
320
+ lat: Number(_this.state.lat),
321
+ lng: Number(_this.state.lng),
322
+ poi: _this.props.value.poi || "",
294
323
  });
295
324
  }
296
- initialAddress_1["name"] =
297
- (_b = (_a = _this.props.value) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : results[0].formatted_address;
298
- initialAddress_1["lat"] = Number(_this.state.lat);
299
- initialAddress_1["lng"] = Number(_this.state.lng);
300
- resolve(initialAddress_1);
301
325
  }
302
326
  else {
303
327
  resolve({
304
- name: (_d = (_c = _this.props.value) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : "",
328
+ name: (_f = (_e = _this.props.value) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : "",
305
329
  lat: Number(_this.state.lat),
306
330
  lng: Number(_this.state.lng),
307
331
  poi: _this.props.value.poi || "",
308
332
  });
309
333
  }
310
- }
311
- else {
312
- resolve({
313
- name: (_f = (_e = _this.props.value) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : "",
314
- lat: Number(_this.state.lat),
315
- lng: Number(_this.state.lng),
316
- poi: _this.props.value.poi || "",
317
- });
318
- }
319
- });
320
- })];
321
- case 1:
322
- initialAddress = _c.sent();
323
- (_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, initialAddress);
334
+ });
335
+ })];
336
+ case 2:
337
+ initialAddress = _h.sent();
338
+ (_g = (_f = this.props).onChange) === null || _g === void 0 ? void 0 : _g.call(_f, initialAddress);
324
339
  this.setState({
325
340
  modalVisible: false,
326
341
  });
@@ -330,41 +345,57 @@ var Address = /** @class */ (function (_super) {
330
345
  }); };
331
346
  _this.handleUseCurrentLocation = function () {
332
347
  try {
333
- navigator.geolocation.getCurrentPosition(function (position) {
334
- var lat = position.coords.latitude;
335
- var lng = position.coords.longitude;
336
- var geocoder = new window.google.maps.Geocoder();
337
- var latlng = { lat: lat, lng: lng };
338
- geocoder.geocode({ location: latlng }, function (results, status) {
339
- var _a, _b;
340
- var initialAddress = {
341
- name: "Current Location",
342
- lat: lat,
343
- lng: lng,
344
- district: "",
345
- state: "",
346
- country: "",
347
- };
348
- if (status === "OK" && results[0]) {
349
- initialAddress.name = results[0].formatted_address;
350
- if (results[0].address_components) {
351
- results[0].address_components.forEach(function (eachAddress) {
352
- var _a, _b, _c;
353
- if (eachAddress.types.includes("country")) {
354
- initialAddress.country = (_a = eachAddress.long_name) !== null && _a !== void 0 ? _a : "";
355
- }
356
- else if (eachAddress.types.includes("administrative_area_level_1")) {
357
- initialAddress.state = (_b = eachAddress.long_name) !== null && _b !== void 0 ? _b : "";
358
- }
359
- else if (eachAddress.types.includes("locality")) {
360
- initialAddress.district = (_c = eachAddress.long_name) !== null && _c !== void 0 ? _c : "";
348
+ navigator.geolocation.getCurrentPosition(function (position) { return __awaiter(_this, void 0, void 0, function () {
349
+ var lat, lng, geocoder, latlng;
350
+ var _this = this;
351
+ var _a, _b;
352
+ return __generator(this, function (_c) {
353
+ switch (_c.label) {
354
+ case 0:
355
+ lat = position.coords.latitude;
356
+ lng = position.coords.longitude;
357
+ return [4 /*yield*/, (0, googleMaps_1.handleLoadGoogleMaps)(["geocoding"])];
358
+ case 1:
359
+ // INFO: without Maps, keep the position under a plain name rather than throw
360
+ if (!(_c.sent())) {
361
+ (_b = (_a = this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, { name: "Current Location", lat: lat, lng: lng });
362
+ return [2 /*return*/];
363
+ }
364
+ geocoder = new window.google.maps.Geocoder();
365
+ latlng = { lat: lat, lng: lng };
366
+ geocoder.geocode({ location: latlng }, function (results, status) {
367
+ var _a, _b;
368
+ var initialAddress = {
369
+ name: "Current Location",
370
+ lat: lat,
371
+ lng: lng,
372
+ district: "",
373
+ state: "",
374
+ country: "",
375
+ };
376
+ if (status === "OK" && results[0]) {
377
+ initialAddress.name = results[0].formatted_address;
378
+ if (results[0].address_components) {
379
+ results[0].address_components.forEach(function (eachAddress) {
380
+ var _a, _b, _c;
381
+ if (eachAddress.types.includes("country")) {
382
+ initialAddress.country = (_a = eachAddress.long_name) !== null && _a !== void 0 ? _a : "";
383
+ }
384
+ else if (eachAddress.types.includes("administrative_area_level_1")) {
385
+ initialAddress.state = (_b = eachAddress.long_name) !== null && _b !== void 0 ? _b : "";
386
+ }
387
+ else if (eachAddress.types.includes("locality")) {
388
+ initialAddress.district = (_c = eachAddress.long_name) !== null && _c !== void 0 ? _c : "";
389
+ }
390
+ });
391
+ }
361
392
  }
393
+ (_b = (_a = _this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, initialAddress);
362
394
  });
363
- }
395
+ return [2 /*return*/];
364
396
  }
365
- (_b = (_a = _this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, initialAddress);
366
397
  });
367
- });
398
+ }); });
368
399
  }
369
400
  catch (err) { }
370
401
  };
@@ -406,87 +437,119 @@ var Address = /** @class */ (function (_super) {
406
437
  if (lat === 0 && lng === 0) {
407
438
  return (react_1.default.createElement("div", { className: "w-full h-24 flex items-center justify-center text-gray-500" }, "Enter an address to see its location on the map."));
408
439
  }
409
- setTimeout(function () {
410
- var mapContainer = document.getElementById("blixify-ui-mapview");
411
- if (mapContainer && window.google) {
412
- var map = new window.google.maps.Map(mapContainer, {
413
- center: { lat: lat, lng: lng },
414
- zoom: 15,
415
- });
416
- var marker = new window.google.maps.Marker({
417
- position: { lat: lat, lng: lng },
418
- map: map,
419
- draggable: true,
420
- });
421
- marker.addListener("dragend", function (event) {
422
- var newLat = event.latLng.lat();
423
- var newLng = event.latLng.lng();
424
- var geocoder = new window.google.maps.Geocoder();
425
- var latlng = { lat: newLat, lng: newLng };
426
- geocoder.geocode({ location: latlng }, function (results, status) {
427
- var newAddressName = _this.handleGetSafeValue().name;
428
- if (status === "OK" && results[0]) {
429
- newAddressName = results[0].formatted_address;
430
- }
431
- _this.setState({ lat: newLat, lng: newLng });
432
- if (_this.props.onChange) {
433
- _this.props.onChange({
434
- name: newAddressName,
435
- lat: newLat,
436
- lng: newLng,
440
+ setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
441
+ var mapContainer, _a, map, marker;
442
+ var _this = this;
443
+ return __generator(this, function (_b) {
444
+ switch (_b.label) {
445
+ case 0:
446
+ mapContainer = document.getElementById("blixify-ui-mapview");
447
+ _a = mapContainer;
448
+ if (!_a) return [3 /*break*/, 2];
449
+ return [4 /*yield*/, (0, googleMaps_1.handleLoadGoogleMaps)(["maps", "marker", "geocoding"])];
450
+ case 1:
451
+ _a = (_b.sent());
452
+ _b.label = 2;
453
+ case 2:
454
+ if (_a) {
455
+ map = new window.google.maps.Map(mapContainer, {
456
+ center: { lat: lat, lng: lng },
457
+ zoom: 15,
458
+ });
459
+ marker = new window.google.maps.Marker({
460
+ position: { lat: lat, lng: lng },
461
+ map: map,
462
+ draggable: true,
463
+ });
464
+ marker.addListener("dragend", function (event) {
465
+ var newLat = event.latLng.lat();
466
+ var newLng = event.latLng.lng();
467
+ var geocoder = new window.google.maps.Geocoder();
468
+ var latlng = { lat: newLat, lng: newLng };
469
+ geocoder.geocode({ location: latlng }, function (results, status) {
470
+ var newAddressName = _this.handleGetSafeValue().name;
471
+ if (status === "OK" && results[0]) {
472
+ newAddressName = results[0].formatted_address;
473
+ }
474
+ _this.setState({ lat: newLat, lng: newLng });
475
+ if (_this.props.onChange) {
476
+ _this.props.onChange({
477
+ name: newAddressName,
478
+ lat: newLat,
479
+ lng: newLng,
480
+ });
481
+ }
482
+ });
437
483
  });
438
484
  }
439
- });
440
- });
441
- }
442
- }, 100);
485
+ return [2 /*return*/];
486
+ }
487
+ });
488
+ }); }, 100);
443
489
  return (react_1.default.createElement("div", { className: "w-full h-[400px]" },
444
490
  react_1.default.createElement("div", { id: "blixify-ui-mapview", className: "w-full h-full" })));
445
491
  };
446
492
  return _this;
447
493
  }
494
+ Address.prototype.componentWillUnmount = function () {
495
+ this.isUnmounted = true;
496
+ };
448
497
  Address.prototype.componentDidMount = function () {
449
498
  var _this = this;
450
499
  var delayTimeout = this.props.delayInit ? 500 : 0;
451
- setTimeout(function () {
452
- if (window.google && _this.props.id) {
453
- // Initialize autocomplete for desktop input
454
- var desktopInput = document.getElementById(_this.props.id);
455
- if (desktopInput) {
456
- _this.autocompleteService = new window.google.maps.places.Autocomplete(desktopInput, {
457
- componentRestrictions: { country: ["my", "bn", "sg"] },
458
- fields: [
459
- "geometry",
460
- "formatted_address",
461
- "address_component",
462
- "types",
463
- "name",
464
- ],
465
- });
466
- _this.autocompleteService.addListener("place_changed", _this.handlePlaceChangeListener);
467
- }
468
- // Initialize autocomplete for mobile input if mobileView is enabled
469
- if (_this.props.mobileView) {
470
- var mobileInput = document.getElementById("".concat(_this.props.id, "-mobile"));
471
- if (mobileInput) {
472
- _this.mobileAutocompleteService =
473
- new window.google.maps.places.Autocomplete(mobileInput, {
474
- componentRestrictions: { country: ["my", "bn", "sg"] },
475
- fields: [
476
- "geometry",
477
- "formatted_address",
478
- "address_component",
479
- "types",
480
- "name",
481
- ],
482
- });
483
- _this.mobileAutocompleteService.addListener("place_changed", function () {
484
- return _this.handlePlaceChangeListener(_this.mobileAutocompleteService);
485
- });
486
- }
500
+ setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
501
+ var isReady, places, desktopInput, mobileInput;
502
+ var _this = this;
503
+ return __generator(this, function (_a) {
504
+ switch (_a.label) {
505
+ case 0: return [4 /*yield*/, (0, googleMaps_1.handleWaitForGoogleMaps)(["places"], {
506
+ isCancelled: function () { return _this.isUnmounted; },
507
+ })];
508
+ case 1:
509
+ isReady = _a.sent();
510
+ if (!isReady || this.isUnmounted)
511
+ return [2 /*return*/];
512
+ places = window.google.maps.places;
513
+ if (this.props.id) {
514
+ desktopInput = document.getElementById(this.props.id);
515
+ if (desktopInput) {
516
+ this.autocompleteService = new places.Autocomplete(desktopInput, {
517
+ componentRestrictions: { country: ["my", "bn", "sg"] },
518
+ fields: [
519
+ "geometry",
520
+ "formatted_address",
521
+ "address_component",
522
+ "types",
523
+ "name",
524
+ ],
525
+ });
526
+ this.autocompleteService.addListener("place_changed", this.handlePlaceChangeListener);
527
+ }
528
+ // Initialize autocomplete for mobile input if mobileView is enabled
529
+ if (this.props.mobileView) {
530
+ mobileInput = document.getElementById("".concat(this.props.id, "-mobile"));
531
+ if (mobileInput) {
532
+ this.mobileAutocompleteService =
533
+ new places.Autocomplete(mobileInput, {
534
+ componentRestrictions: { country: ["my", "bn", "sg"] },
535
+ fields: [
536
+ "geometry",
537
+ "formatted_address",
538
+ "address_component",
539
+ "types",
540
+ "name",
541
+ ],
542
+ });
543
+ this.mobileAutocompleteService.addListener("place_changed", function () {
544
+ return _this.handlePlaceChangeListener(_this.mobileAutocompleteService);
545
+ });
546
+ }
547
+ }
548
+ }
549
+ return [2 /*return*/];
487
550
  }
488
- }
489
- }, delayTimeout);
551
+ });
552
+ }); }, delayTimeout);
490
553
  if (this.props.value) {
491
554
  var safeValue = this.handleGetSafeValue();
492
555
  this.setState({