@janiscommerce/ui-web 0.37.0 → 0.39.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.39.0] - 2025-05-13
11
+
12
+ ### Added
13
+
14
+ - Enhanced map markers with animation support, including the ability to specify animation duration for each marker. Markers now animate automatically when added to the map.
15
+
16
+ ## [0.38.0] - 2025-05-08
17
+
18
+ ### ADDED
19
+
20
+ - forwardRef, useImperativeHandle and useEffect for set bounds and zoom in Map component
21
+
22
+ ### REMOVED
23
+
24
+ - getCenterByGeolocationOrCenter, getGeolocationCoordinates map utils
25
+
10
26
  ## [0.37.0] - 2025-05-02
11
27
 
12
28
  ### Removed
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useState, useEffect, useRef, PureComponent, useMemo, useCallback, useLayoutEffect, createContext } from 'react';
2
+ import React__default, { useState, useEffect, useRef, PureComponent, useMemo, useCallback, useLayoutEffect, createContext, forwardRef, useImperativeHandle } from 'react';
3
3
  import styled$g, { css, keyframes } from 'styled-components';
4
4
  import * as ReactDOM from 'react-dom';
5
5
  import ReactDOM__default from 'react-dom';
@@ -4717,6 +4717,166 @@ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNa
4717
4717
  ];
4718
4718
  }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
4719
4719
 
4720
+ var $$d = _export;
4721
+
4722
+ // `Number.isNaN` method
4723
+ // https://tc39.es/ecma262/#sec-number.isnan
4724
+ $$d({ target: 'Number', stat: true }, {
4725
+ isNaN: function isNaN(number) {
4726
+ // eslint-disable-next-line no-self-compare -- NaN check
4727
+ return number != number;
4728
+ }
4729
+ });
4730
+
4731
+ var isCallable$2 = isCallable$k;
4732
+ var isObject$3 = isObject$d;
4733
+ var setPrototypeOf$1 = objectSetPrototypeOf;
4734
+
4735
+ // makes subclassing work correct for wrapped built-ins
4736
+ var inheritIfRequired$1 = function ($this, dummy, Wrapper) {
4737
+ var NewTarget, NewTargetPrototype;
4738
+ if (
4739
+ // it can work only with native `setPrototypeOf`
4740
+ setPrototypeOf$1 &&
4741
+ // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
4742
+ isCallable$2(NewTarget = dummy.constructor) &&
4743
+ NewTarget !== Wrapper &&
4744
+ isObject$3(NewTargetPrototype = NewTarget.prototype) &&
4745
+ NewTargetPrototype !== Wrapper.prototype
4746
+ ) setPrototypeOf$1($this, NewTargetPrototype);
4747
+ return $this;
4748
+ };
4749
+
4750
+ var uncurryThis$a = functionUncurryThis;
4751
+
4752
+ // `thisNumberValue` abstract operation
4753
+ // https://tc39.es/ecma262/#sec-thisnumbervalue
4754
+ var thisNumberValue$1 = uncurryThis$a(1.0.valueOf);
4755
+
4756
+ // a string of all valid unicode whitespaces
4757
+ var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
4758
+ '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
4759
+
4760
+ var uncurryThis$9 = functionUncurryThis;
4761
+ var requireObjectCoercible$2 = requireObjectCoercible$8;
4762
+ var toString$3 = toString$9;
4763
+ var whitespaces$1 = whitespaces$2;
4764
+
4765
+ var replace$1 = uncurryThis$9(''.replace);
4766
+ var whitespace = '[' + whitespaces$1 + ']';
4767
+ var ltrim = RegExp('^' + whitespace + whitespace + '*');
4768
+ var rtrim = RegExp(whitespace + whitespace + '*$');
4769
+
4770
+ // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
4771
+ var createMethod$2 = function (TYPE) {
4772
+ return function ($this) {
4773
+ var string = toString$3(requireObjectCoercible$2($this));
4774
+ if (TYPE & 1) string = replace$1(string, ltrim, '');
4775
+ if (TYPE & 2) string = replace$1(string, rtrim, '');
4776
+ return string;
4777
+ };
4778
+ };
4779
+
4780
+ var stringTrim = {
4781
+ // `String.prototype.{ trimLeft, trimStart }` methods
4782
+ // https://tc39.es/ecma262/#sec-string.prototype.trimstart
4783
+ start: createMethod$2(1),
4784
+ // `String.prototype.{ trimRight, trimEnd }` methods
4785
+ // https://tc39.es/ecma262/#sec-string.prototype.trimend
4786
+ end: createMethod$2(2),
4787
+ // `String.prototype.trim` method
4788
+ // https://tc39.es/ecma262/#sec-string.prototype.trim
4789
+ trim: createMethod$2(3)
4790
+ };
4791
+
4792
+ var DESCRIPTORS$2 = descriptors;
4793
+ var global$e = global$T;
4794
+ var uncurryThis$8 = functionUncurryThis;
4795
+ var isForced$1 = isForced_1;
4796
+ var redefine$2 = redefine$b.exports;
4797
+ var hasOwn$1 = hasOwnProperty_1;
4798
+ var inheritIfRequired = inheritIfRequired$1;
4799
+ var isPrototypeOf$2 = objectIsPrototypeOf;
4800
+ var isSymbol = isSymbol$3;
4801
+ var toPrimitive = toPrimitive$2;
4802
+ var fails$6 = fails$q;
4803
+ var getOwnPropertyNames = objectGetOwnPropertyNames.f;
4804
+ var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
4805
+ var defineProperty$1 = objectDefineProperty.f;
4806
+ var thisNumberValue = thisNumberValue$1;
4807
+ var trim$1 = stringTrim.trim;
4808
+
4809
+ var NUMBER = 'Number';
4810
+ var NativeNumber = global$e[NUMBER];
4811
+ var NumberPrototype = NativeNumber.prototype;
4812
+ var TypeError$6 = global$e.TypeError;
4813
+ var arraySlice$2 = uncurryThis$8(''.slice);
4814
+ var charCodeAt = uncurryThis$8(''.charCodeAt);
4815
+
4816
+ // `ToNumeric` abstract operation
4817
+ // https://tc39.es/ecma262/#sec-tonumeric
4818
+ var toNumeric = function (value) {
4819
+ var primValue = toPrimitive(value, 'number');
4820
+ return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
4821
+ };
4822
+
4823
+ // `ToNumber` abstract operation
4824
+ // https://tc39.es/ecma262/#sec-tonumber
4825
+ var toNumber = function (argument) {
4826
+ var it = toPrimitive(argument, 'number');
4827
+ var first, third, radix, maxCode, digits, length, index, code;
4828
+ if (isSymbol(it)) throw TypeError$6('Cannot convert a Symbol value to a number');
4829
+ if (typeof it == 'string' && it.length > 2) {
4830
+ it = trim$1(it);
4831
+ first = charCodeAt(it, 0);
4832
+ if (first === 43 || first === 45) {
4833
+ third = charCodeAt(it, 2);
4834
+ if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
4835
+ } else if (first === 48) {
4836
+ switch (charCodeAt(it, 1)) {
4837
+ case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
4838
+ case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
4839
+ default: return +it;
4840
+ }
4841
+ digits = arraySlice$2(it, 2);
4842
+ length = digits.length;
4843
+ for (index = 0; index < length; index++) {
4844
+ code = charCodeAt(digits, index);
4845
+ // parseInt parses a string to a first unavailable symbol
4846
+ // but ToNumber should return NaN if a string contains unavailable symbols
4847
+ if (code < 48 || code > maxCode) return NaN;
4848
+ } return parseInt(digits, radix);
4849
+ }
4850
+ } return +it;
4851
+ };
4852
+
4853
+ // `Number` constructor
4854
+ // https://tc39.es/ecma262/#sec-number-constructor
4855
+ if (isForced$1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
4856
+ var NumberWrapper = function Number(value) {
4857
+ var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
4858
+ var dummy = this;
4859
+ // check on 1..constructor(foo) case
4860
+ return isPrototypeOf$2(NumberPrototype, dummy) && fails$6(function () { thisNumberValue(dummy); })
4861
+ ? inheritIfRequired(Object(n), dummy, NumberWrapper) : n;
4862
+ };
4863
+ for (var keys = DESCRIPTORS$2 ? getOwnPropertyNames(NativeNumber) : (
4864
+ // ES3:
4865
+ 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
4866
+ // ES2015 (in case, if modules with ES2015 Number statics required before):
4867
+ 'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' +
4868
+ // ESNext
4869
+ 'fromString,range'
4870
+ ).split(','), j = 0, key$1; keys.length > j; j++) {
4871
+ if (hasOwn$1(NativeNumber, key$1 = keys[j]) && !hasOwn$1(NumberWrapper, key$1)) {
4872
+ defineProperty$1(NumberWrapper, key$1, getOwnPropertyDescriptor$1(NativeNumber, key$1));
4873
+ }
4874
+ }
4875
+ NumberWrapper.prototype = NumberPrototype;
4876
+ NumberPrototype.constructor = NumberWrapper;
4877
+ redefine$2(global$e, NUMBER, NumberWrapper);
4878
+ }
4879
+
4720
4880
  /**
4721
4881
  * Creates a debounced function that delays invoking func until after wait milliseconds have
4722
4882
  * elapsed since the last time the debounced function was invoked.
@@ -4745,6 +4905,12 @@ function debounce(fn, wait) {
4745
4905
 
4746
4906
  return debounced;
4747
4907
  }
4908
+ var isObject$2 = function isObject(value) {
4909
+ return _typeof(value) === 'object' && !Array.isArray(value) && value instanceof Object;
4910
+ };
4911
+ var isNumber = function isNumber(num) {
4912
+ return typeof num === 'number' && !Number.isNaN(Number(num));
4913
+ };
4748
4914
 
4749
4915
  var breakpoints = {
4750
4916
  values: {
@@ -4945,166 +5111,6 @@ var palette = {
4945
5111
  yellowPressed: '#FFBA0C'
4946
5112
  };
4947
5113
 
4948
- var $$d = _export;
4949
-
4950
- // `Number.isNaN` method
4951
- // https://tc39.es/ecma262/#sec-number.isnan
4952
- $$d({ target: 'Number', stat: true }, {
4953
- isNaN: function isNaN(number) {
4954
- // eslint-disable-next-line no-self-compare -- NaN check
4955
- return number != number;
4956
- }
4957
- });
4958
-
4959
- var isCallable$2 = isCallable$k;
4960
- var isObject$3 = isObject$d;
4961
- var setPrototypeOf$1 = objectSetPrototypeOf;
4962
-
4963
- // makes subclassing work correct for wrapped built-ins
4964
- var inheritIfRequired$1 = function ($this, dummy, Wrapper) {
4965
- var NewTarget, NewTargetPrototype;
4966
- if (
4967
- // it can work only with native `setPrototypeOf`
4968
- setPrototypeOf$1 &&
4969
- // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
4970
- isCallable$2(NewTarget = dummy.constructor) &&
4971
- NewTarget !== Wrapper &&
4972
- isObject$3(NewTargetPrototype = NewTarget.prototype) &&
4973
- NewTargetPrototype !== Wrapper.prototype
4974
- ) setPrototypeOf$1($this, NewTargetPrototype);
4975
- return $this;
4976
- };
4977
-
4978
- var uncurryThis$a = functionUncurryThis;
4979
-
4980
- // `thisNumberValue` abstract operation
4981
- // https://tc39.es/ecma262/#sec-thisnumbervalue
4982
- var thisNumberValue$1 = uncurryThis$a(1.0.valueOf);
4983
-
4984
- // a string of all valid unicode whitespaces
4985
- var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
4986
- '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
4987
-
4988
- var uncurryThis$9 = functionUncurryThis;
4989
- var requireObjectCoercible$2 = requireObjectCoercible$8;
4990
- var toString$3 = toString$9;
4991
- var whitespaces$1 = whitespaces$2;
4992
-
4993
- var replace$1 = uncurryThis$9(''.replace);
4994
- var whitespace = '[' + whitespaces$1 + ']';
4995
- var ltrim = RegExp('^' + whitespace + whitespace + '*');
4996
- var rtrim = RegExp(whitespace + whitespace + '*$');
4997
-
4998
- // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
4999
- var createMethod$2 = function (TYPE) {
5000
- return function ($this) {
5001
- var string = toString$3(requireObjectCoercible$2($this));
5002
- if (TYPE & 1) string = replace$1(string, ltrim, '');
5003
- if (TYPE & 2) string = replace$1(string, rtrim, '');
5004
- return string;
5005
- };
5006
- };
5007
-
5008
- var stringTrim = {
5009
- // `String.prototype.{ trimLeft, trimStart }` methods
5010
- // https://tc39.es/ecma262/#sec-string.prototype.trimstart
5011
- start: createMethod$2(1),
5012
- // `String.prototype.{ trimRight, trimEnd }` methods
5013
- // https://tc39.es/ecma262/#sec-string.prototype.trimend
5014
- end: createMethod$2(2),
5015
- // `String.prototype.trim` method
5016
- // https://tc39.es/ecma262/#sec-string.prototype.trim
5017
- trim: createMethod$2(3)
5018
- };
5019
-
5020
- var DESCRIPTORS$2 = descriptors;
5021
- var global$e = global$T;
5022
- var uncurryThis$8 = functionUncurryThis;
5023
- var isForced$1 = isForced_1;
5024
- var redefine$2 = redefine$b.exports;
5025
- var hasOwn$1 = hasOwnProperty_1;
5026
- var inheritIfRequired = inheritIfRequired$1;
5027
- var isPrototypeOf$2 = objectIsPrototypeOf;
5028
- var isSymbol = isSymbol$3;
5029
- var toPrimitive = toPrimitive$2;
5030
- var fails$6 = fails$q;
5031
- var getOwnPropertyNames = objectGetOwnPropertyNames.f;
5032
- var getOwnPropertyDescriptor$1 = objectGetOwnPropertyDescriptor.f;
5033
- var defineProperty$1 = objectDefineProperty.f;
5034
- var thisNumberValue = thisNumberValue$1;
5035
- var trim$1 = stringTrim.trim;
5036
-
5037
- var NUMBER = 'Number';
5038
- var NativeNumber = global$e[NUMBER];
5039
- var NumberPrototype = NativeNumber.prototype;
5040
- var TypeError$6 = global$e.TypeError;
5041
- var arraySlice$2 = uncurryThis$8(''.slice);
5042
- var charCodeAt = uncurryThis$8(''.charCodeAt);
5043
-
5044
- // `ToNumeric` abstract operation
5045
- // https://tc39.es/ecma262/#sec-tonumeric
5046
- var toNumeric = function (value) {
5047
- var primValue = toPrimitive(value, 'number');
5048
- return typeof primValue == 'bigint' ? primValue : toNumber(primValue);
5049
- };
5050
-
5051
- // `ToNumber` abstract operation
5052
- // https://tc39.es/ecma262/#sec-tonumber
5053
- var toNumber = function (argument) {
5054
- var it = toPrimitive(argument, 'number');
5055
- var first, third, radix, maxCode, digits, length, index, code;
5056
- if (isSymbol(it)) throw TypeError$6('Cannot convert a Symbol value to a number');
5057
- if (typeof it == 'string' && it.length > 2) {
5058
- it = trim$1(it);
5059
- first = charCodeAt(it, 0);
5060
- if (first === 43 || first === 45) {
5061
- third = charCodeAt(it, 2);
5062
- if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
5063
- } else if (first === 48) {
5064
- switch (charCodeAt(it, 1)) {
5065
- case 66: case 98: radix = 2; maxCode = 49; break; // fast equal of /^0b[01]+$/i
5066
- case 79: case 111: radix = 8; maxCode = 55; break; // fast equal of /^0o[0-7]+$/i
5067
- default: return +it;
5068
- }
5069
- digits = arraySlice$2(it, 2);
5070
- length = digits.length;
5071
- for (index = 0; index < length; index++) {
5072
- code = charCodeAt(digits, index);
5073
- // parseInt parses a string to a first unavailable symbol
5074
- // but ToNumber should return NaN if a string contains unavailable symbols
5075
- if (code < 48 || code > maxCode) return NaN;
5076
- } return parseInt(digits, radix);
5077
- }
5078
- } return +it;
5079
- };
5080
-
5081
- // `Number` constructor
5082
- // https://tc39.es/ecma262/#sec-number-constructor
5083
- if (isForced$1(NUMBER, !NativeNumber(' 0o1') || !NativeNumber('0b1') || NativeNumber('+0x1'))) {
5084
- var NumberWrapper = function Number(value) {
5085
- var n = arguments.length < 1 ? 0 : NativeNumber(toNumeric(value));
5086
- var dummy = this;
5087
- // check on 1..constructor(foo) case
5088
- return isPrototypeOf$2(NumberPrototype, dummy) && fails$6(function () { thisNumberValue(dummy); })
5089
- ? inheritIfRequired(Object(n), dummy, NumberWrapper) : n;
5090
- };
5091
- for (var keys = DESCRIPTORS$2 ? getOwnPropertyNames(NativeNumber) : (
5092
- // ES3:
5093
- 'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
5094
- // ES2015 (in case, if modules with ES2015 Number statics required before):
5095
- 'EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,' +
5096
- // ESNext
5097
- 'fromString,range'
5098
- ).split(','), j = 0, key$1; keys.length > j; j++) {
5099
- if (hasOwn$1(NativeNumber, key$1 = keys[j]) && !hasOwn$1(NumberWrapper, key$1)) {
5100
- defineProperty$1(NumberWrapper, key$1, getOwnPropertyDescriptor$1(NativeNumber, key$1));
5101
- }
5102
- }
5103
- NumberWrapper.prototype = NumberPrototype;
5104
- NumberPrototype.constructor = NumberWrapper;
5105
- redefine$2(global$e, NUMBER, NumberWrapper);
5106
- }
5107
-
5108
5114
  var uncurryThis$7 = functionUncurryThis;
5109
5115
  var requireObjectCoercible$1 = requireObjectCoercible$8;
5110
5116
  var toString$2 = toString$9;
@@ -15955,6 +15961,13 @@ var markerHasEqualPosition = function markerHasEqualPosition() {
15955
15961
  var hasEqualLng = (prevPosition === null || prevPosition === void 0 ? void 0 : prevPosition.lng) === (newPosition === null || newPosition === void 0 ? void 0 : newPosition.lng);
15956
15962
  return hasEqualLat && hasEqualLng;
15957
15963
  };
15964
+ var isValidAnimation = function isValidAnimation() {
15965
+ var _window$google, _window$google$maps;
15966
+
15967
+ var animation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15968
+ var validAnimations = (_window$google = window.google) === null || _window$google === void 0 ? void 0 : (_window$google$maps = _window$google.maps) === null || _window$google$maps === void 0 ? void 0 : _window$google$maps.Animation;
15969
+ return (animation === null || animation === void 0 ? void 0 : animation.name) && validAnimations && validAnimations[animation === null || animation === void 0 ? void 0 : animation.name] !== undefined;
15970
+ };
15958
15971
 
15959
15972
  var Marker = function Marker(_ref) {
15960
15973
  var _ref$markerData = _ref.markerData,
@@ -15972,6 +15985,7 @@ var Marker = function Marker(_ref) {
15972
15985
  var _ref2 = marker || {},
15973
15986
  icon = _ref2.icon,
15974
15987
  position = _ref2.position,
15988
+ animation = _ref2.animation,
15975
15989
  overlay = _ref2.overlay,
15976
15990
  infoWindowChildren = _ref2.infoWindowChildren,
15977
15991
  isDraggable = _ref2.isDraggable;
@@ -15988,6 +16002,7 @@ var Marker = function Marker(_ref) {
15988
16002
  _onDragEnd = _markerOptions$onDrag3 === void 0 ? function () {} : _markerOptions$onDrag3;
15989
16003
 
15990
16004
  var markerRef = useRef(null);
16005
+ var timeoutRef = useRef(null);
15991
16006
 
15992
16007
  var _useState3 = useState(false),
15993
16008
  _useState4 = _slicedToArray(_useState3, 2),
@@ -16036,6 +16051,29 @@ var Marker = function Marker(_ref) {
16036
16051
  };
16037
16052
  };
16038
16053
 
16054
+ var animate = function animate() {
16055
+ var _markerRef$current2, _markerRef$current2$m;
16056
+
16057
+ if (!markerRef.current) return;
16058
+ if (!isValidAnimation(animation)) return;
16059
+ (_markerRef$current2 = markerRef.current) === null || _markerRef$current2 === void 0 ? void 0 : (_markerRef$current2$m = _markerRef$current2.marker) === null || _markerRef$current2$m === void 0 ? void 0 : _markerRef$current2$m.setAnimation(window.google.maps.Animation[animation === null || animation === void 0 ? void 0 : animation.name]);
16060
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
16061
+
16062
+ if (animation !== null && animation !== void 0 && animation.duration && isNumber(animation === null || animation === void 0 ? void 0 : animation.duration)) {
16063
+ timeoutRef.current = setTimeout(function () {
16064
+ var _markerRef$current3, _markerRef$current3$m;
16065
+
16066
+ (_markerRef$current3 = markerRef.current) === null || _markerRef$current3 === void 0 ? void 0 : (_markerRef$current3$m = _markerRef$current3.marker) === null || _markerRef$current3$m === void 0 ? void 0 : _markerRef$current3$m.setAnimation(null);
16067
+ }, animation === null || animation === void 0 ? void 0 : animation.duration);
16068
+ }
16069
+ };
16070
+
16071
+ useEffect(function () {
16072
+ if (animation && isObject$2(animation)) animate();
16073
+ return function () {
16074
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
16075
+ };
16076
+ }, [animation]);
16039
16077
  var markerProps = {
16040
16078
  ref: markerRef,
16041
16079
  position: position,
@@ -17057,40 +17095,6 @@ var getBoundsFromMarkers = (function () {
17057
17095
  return getBounds(markersFlatted);
17058
17096
  });
17059
17097
 
17060
- /**
17061
- * Sets the map center based on the provided markers or a default center value.
17062
- * @param {Object} center A default center object with latitude and longitude values.
17063
- * @param {number} center.lat The latitude value of the default center.
17064
- * @param {number} center.lng The longitude value of the default center.
17065
- */
17066
-
17067
- var getCenterByGeolocationOrCenter = (function () {
17068
- var center = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17069
- if (validateCoordinates(center)) return center;
17070
- return getGeolocationCoordinates();
17071
- });
17072
-
17073
- /**
17074
- * Retrieves the current geolocation of the user and updates the map's center coordinates.
17075
- */
17076
- var getGeolocationCoordinates = (function () {
17077
- try {
17078
- navigator.geolocation.getCurrentPosition(function () {
17079
- var pos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17080
- var _pos$coords = pos.coords,
17081
- lat = _pos$coords.latitude,
17082
- lng = _pos$coords.longitude;
17083
- return {
17084
- lat: lat,
17085
- lng: lng
17086
- };
17087
- });
17088
- } catch (error) {
17089
- console.log(error);
17090
- return {};
17091
- }
17092
- });
17093
-
17094
17098
  var LIBRARIES = ['geometry', 'drawing', 'places'];
17095
17099
  var DEFAULT_CENTER = {
17096
17100
  lat: 0,
@@ -17269,15 +17273,6 @@ var getParsedComponents = (function () {
17269
17273
  });
17270
17274
  });
17271
17275
 
17272
- /**
17273
- * Function to check if a value is an object
17274
- * @param {*} value Value to check if it is an object
17275
- * @returns Returns true if the value is an object
17276
- */
17277
- var isObject$2 = function isObject(value) {
17278
- return _typeof(value) === 'object' && !Array.isArray(value) && value instanceof Object;
17279
- };
17280
-
17281
17276
  var global$7 = global$T;
17282
17277
 
17283
17278
  var nativePromiseConstructor = global$7.Promise;
@@ -35397,28 +35392,6 @@ var parsePlaces = (function (places, parsedData) {
35397
35392
  }, _objectSpread2({}, parsedData));
35398
35393
  });
35399
35394
 
35400
- /**
35401
- * @function validateCoordinates
35402
- * @description return true or false is region has latitude and longitude keys and type number
35403
- * @param {object} coordinates - object with latitude and longitude
35404
- * @param {number} coordinates.lng - longitude
35405
- * @param {number} coordinates.lat - latitude
35406
- * @returns {boolean}
35407
- * @example isValidRegionData({latitude: -345345, longitude: -345435345}) => true
35408
- * @example isValidRegionData({latitude: -345345, longitude: '3453453453'}) => false
35409
- * @example isValidRegionData({latitude: -345345}) => false
35410
- */
35411
-
35412
- var validateCoordinates = (function () {
35413
- var coordinates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35414
- if (!isObject$2(coordinates) || !Object.keys(coordinates).length) return false;
35415
- var lng = coordinates.lng,
35416
- lat = coordinates.lat;
35417
- if (!lng || !lat) return false;
35418
- if (!lodash.exports.isNumber(lng) || !lodash.exports.isNumber(lat)) return false;
35419
- return true;
35420
- });
35421
-
35422
35395
  var styled = {
35423
35396
  LoadingElement: styled$g.div.withConfig({
35424
35397
  displayName: "styles__LoadingElement",
@@ -35486,8 +35459,7 @@ var SearchBox = function SearchBox(_ref) {
35486
35459
  };
35487
35460
 
35488
35461
  var _excluded = ["googleMapsApiKey", "width", "height", "center", "zoom", "markers", "markerOptions", "options", "callbackOnSuccessDirections", "callbackOnErrorDirections"];
35489
-
35490
- var Map$1 = function Map(_ref) {
35462
+ var Map$1 = /*#__PURE__*/forwardRef(function (_ref, ref) {
35491
35463
  var _mapRef$current;
35492
35464
 
35493
35465
  var _ref$googleMapsApiKey = _ref.googleMapsApiKey,
@@ -35496,8 +35468,7 @@ var Map$1 = function Map(_ref) {
35496
35468
  width = _ref$width === void 0 ? '800px' : _ref$width,
35497
35469
  _ref$height = _ref.height,
35498
35470
  height = _ref$height === void 0 ? '400px' : _ref$height,
35499
- _ref$center = _ref.center,
35500
- center = _ref$center === void 0 ? DEFAULT_CENTER : _ref$center,
35471
+ center = _ref.center,
35501
35472
  _ref$zoom = _ref.zoom,
35502
35473
  zoom = _ref$zoom === void 0 ? 13 : _ref$zoom,
35503
35474
  _ref$markers = _ref.markers,
@@ -35540,7 +35511,7 @@ var Map$1 = function Map(_ref) {
35540
35511
  mapRef.current.panTo(newCenter);
35541
35512
  };
35542
35513
 
35543
- var onLoad = useCallback(function (map) {
35514
+ var onLoad = function onLoad(map) {
35544
35515
  if (!map) return;
35545
35516
  mapRef.current = map;
35546
35517
  mapRef.current.setOptions({
@@ -35549,10 +35520,22 @@ var Map$1 = function Map(_ref) {
35549
35520
  var fullScreenPos = mapOptions.showSearchBar ? 'RIGHT_BOTTOM' : 'RIGHT_TOP';
35550
35521
  handlePositions('fullScreen', window.google.maps.ControlPosition[fullScreenPos]);
35551
35522
  handlePositions('zoom', window.google.maps.ControlPosition.RIGHT_BOTTOM);
35552
- if (!(markers !== null && markers !== void 0 && markers.length)) mapRef.current.setCenter(getCenterByGeolocationOrCenter(center || DEFAULT_CENTER));
35553
- if (markers !== null && markers !== void 0 && markers.length) mapRef.current.fitBounds(getBoundsFromMarkers(markers));
35554
- mapRef.current.setZoom(zoom);
35555
- }, [center, markers, options, zoom]);
35523
+ if (!(markers !== null && markers !== void 0 && markers.length)) mapRef.current.setCenter(center || DEFAULT_CENTER);
35524
+ mapRef.current.setZoom(!center ? 2 : zoom);
35525
+ };
35526
+
35527
+ useImperativeHandle(ref, function () {
35528
+ return {
35529
+ setZoom: function setZoom(zoom) {
35530
+ return mapRef.current.setZoom(zoom);
35531
+ }
35532
+ };
35533
+ });
35534
+ useEffect(function () {
35535
+ if (mapRef.current && markers !== null && markers !== void 0 && markers.length) {
35536
+ mapRef.current.fitBounds(getBoundsFromMarkers(markers));
35537
+ }
35538
+ }, [mapRef.current, markers]);
35556
35539
  if (!isLoaded) return null;
35557
35540
  return /*#__PURE__*/React__default.createElement(GoogleMap, _extends$1({
35558
35541
  className: "google-map-component",
@@ -35562,7 +35545,7 @@ var Map$1 = function Map(_ref) {
35562
35545
  width: width
35563
35546
  },
35564
35547
  options: mapOptions,
35565
- center: (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.center
35548
+ center: (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.getCenter()
35566
35549
  }, props), mapOptions.showSearchBar && /*#__PURE__*/React__default.createElement(SearchBox, {
35567
35550
  updateMarker: updateMarker,
35568
35551
  className: "google-map-component__search-box"
@@ -35574,7 +35557,8 @@ var Map$1 = function Map(_ref) {
35574
35557
  callbackOnErrorDirections: callbackOnErrorDirections,
35575
35558
  googleMapsApiKey: googleMapsApiKey
35576
35559
  }));
35577
- };
35560
+ });
35561
+ Map$1.displayName = 'Map';
35578
35562
 
35579
35563
  var rotate = keyframes(["to{transform:rotate(360deg);}"]);
35580
35564
  var Spinner$1 = styled$g.div.withConfig({