@janiscommerce/ui-web 0.36.0 → 0.38.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/dist/index.umd.js CHANGED
@@ -515,7 +515,7 @@
515
515
 
516
516
  var isCallable$j = isCallable$k;
517
517
 
518
- var isObject$d = function (it) {
518
+ var isObject$c = function (it) {
519
519
  return typeof it == 'object' ? it !== null : isCallable$j(it);
520
520
  };
521
521
 
@@ -640,7 +640,7 @@
640
640
  var global$L = global$T;
641
641
  var call$f = functionCall;
642
642
  var isCallable$f = isCallable$k;
643
- var isObject$c = isObject$d;
643
+ var isObject$b = isObject$c;
644
644
 
645
645
  var TypeError$k = global$L.TypeError;
646
646
 
@@ -648,9 +648,9 @@
648
648
  // https://tc39.es/ecma262/#sec-ordinarytoprimitive
649
649
  var ordinaryToPrimitive$1 = function (input, pref) {
650
650
  var fn, val;
651
- if (pref === 'string' && isCallable$f(fn = input.toString) && !isObject$c(val = call$f(fn, input))) return val;
652
- if (isCallable$f(fn = input.valueOf) && !isObject$c(val = call$f(fn, input))) return val;
653
- if (pref !== 'string' && isCallable$f(fn = input.toString) && !isObject$c(val = call$f(fn, input))) return val;
651
+ if (pref === 'string' && isCallable$f(fn = input.toString) && !isObject$b(val = call$f(fn, input))) return val;
652
+ if (isCallable$f(fn = input.valueOf) && !isObject$b(val = call$f(fn, input))) return val;
653
+ if (pref !== 'string' && isCallable$f(fn = input.toString) && !isObject$b(val = call$f(fn, input))) return val;
654
654
  throw TypeError$k("Can't convert object to primitive value");
655
655
  };
656
656
 
@@ -750,7 +750,7 @@
750
750
 
751
751
  var global$G = global$T;
752
752
  var call$e = functionCall;
753
- var isObject$b = isObject$d;
753
+ var isObject$a = isObject$c;
754
754
  var isSymbol$2 = isSymbol$3;
755
755
  var getMethod$4 = getMethod$5;
756
756
  var ordinaryToPrimitive = ordinaryToPrimitive$1;
@@ -762,13 +762,13 @@
762
762
  // `ToPrimitive` abstract operation
763
763
  // https://tc39.es/ecma262/#sec-toprimitive
764
764
  var toPrimitive$2 = function (input, pref) {
765
- if (!isObject$b(input) || isSymbol$2(input)) return input;
765
+ if (!isObject$a(input) || isSymbol$2(input)) return input;
766
766
  var exoticToPrim = getMethod$4(input, TO_PRIMITIVE);
767
767
  var result;
768
768
  if (exoticToPrim) {
769
769
  if (pref === undefined) pref = 'default';
770
770
  result = call$e(exoticToPrim, input, pref);
771
- if (!isObject$b(result) || isSymbol$2(result)) return result;
771
+ if (!isObject$a(result) || isSymbol$2(result)) return result;
772
772
  throw TypeError$j("Can't convert object to primitive value");
773
773
  }
774
774
  if (pref === undefined) pref = 'number';
@@ -786,11 +786,11 @@
786
786
  };
787
787
 
788
788
  var global$F = global$T;
789
- var isObject$a = isObject$d;
789
+ var isObject$9 = isObject$c;
790
790
 
791
791
  var document$3 = global$F.document;
792
792
  // typeof document.createElement is 'object' in old IE
793
- var EXISTS$1 = isObject$a(document$3) && isObject$a(document$3.createElement);
793
+ var EXISTS$1 = isObject$9(document$3) && isObject$9(document$3.createElement);
794
794
 
795
795
  var documentCreateElement$2 = function (it) {
796
796
  return EXISTS$1 ? document$3.createElement(it) : {};
@@ -847,14 +847,14 @@
847
847
  });
848
848
 
849
849
  var global$E = global$T;
850
- var isObject$9 = isObject$d;
850
+ var isObject$8 = isObject$c;
851
851
 
852
852
  var String$4 = global$E.String;
853
853
  var TypeError$i = global$E.TypeError;
854
854
 
855
855
  // `Assert: Type(argument) is Object`
856
856
  var anObject$h = function (argument) {
857
- if (isObject$9(argument)) return argument;
857
+ if (isObject$8(argument)) return argument;
858
858
  throw TypeError$i(String$4(argument) + ' is not an object');
859
859
  };
860
860
 
@@ -953,7 +953,7 @@
953
953
  var NATIVE_WEAK_MAP = nativeWeakMap;
954
954
  var global$B = global$T;
955
955
  var uncurryThis$o = functionUncurryThis;
956
- var isObject$8 = isObject$d;
956
+ var isObject$7 = isObject$c;
957
957
  var createNonEnumerableProperty$6 = createNonEnumerableProperty$7;
958
958
  var hasOwn$a = hasOwnProperty_1;
959
959
  var shared$1 = sharedStore;
@@ -972,7 +972,7 @@
972
972
  var getterFor = function (TYPE) {
973
973
  return function (it) {
974
974
  var state;
975
- if (!isObject$8(it) || (state = get(it)).type !== TYPE) {
975
+ if (!isObject$7(it) || (state = get(it)).type !== TYPE) {
976
976
  throw TypeError$g('Incompatible receiver, ' + TYPE + ' required');
977
977
  } return state;
978
978
  };
@@ -1437,7 +1437,7 @@
1437
1437
  var global$x = global$T;
1438
1438
  var isArray$2 = isArray$3;
1439
1439
  var isConstructor$2 = isConstructor$3;
1440
- var isObject$7 = isObject$d;
1440
+ var isObject$6 = isObject$c;
1441
1441
  var wellKnownSymbol$i = wellKnownSymbol$m;
1442
1442
 
1443
1443
  var SPECIES$5 = wellKnownSymbol$i('species');
@@ -1451,7 +1451,7 @@
1451
1451
  C = originalArray.constructor;
1452
1452
  // cross-realm fallback
1453
1453
  if (isConstructor$2(C) && (C === Array$3 || isArray$2(C.prototype))) C = undefined;
1454
- else if (isObject$7(C)) {
1454
+ else if (isObject$6(C)) {
1455
1455
  C = C[SPECIES$5];
1456
1456
  if (C === null) C = undefined;
1457
1457
  }
@@ -1490,7 +1490,7 @@
1490
1490
  var global$w = global$T;
1491
1491
  var fails$g = fails$q;
1492
1492
  var isArray$1 = isArray$3;
1493
- var isObject$6 = isObject$d;
1493
+ var isObject$5 = isObject$c;
1494
1494
  var toObject$7 = toObject$9;
1495
1495
  var lengthOfArrayLike$7 = lengthOfArrayLike$9;
1496
1496
  var createProperty$2 = createProperty$3;
@@ -1516,7 +1516,7 @@
1516
1516
  var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport$1('concat');
1517
1517
 
1518
1518
  var isConcatSpreadable = function (O) {
1519
- if (!isObject$6(O)) return false;
1519
+ if (!isObject$5(O)) return false;
1520
1520
  var spreadable = O[IS_CONCAT_SPREADABLE];
1521
1521
  return spreadable !== undefined ? !!spreadable : isArray$1(O);
1522
1522
  };
@@ -3129,7 +3129,7 @@
3129
3129
  var bind$7 = functionBindContext;
3130
3130
  var classof$2 = classof$8;
3131
3131
  var anObject$5 = anObject$h;
3132
- var isObject$5 = isObject$d;
3132
+ var isObject$4 = isObject$c;
3133
3133
  var $toString$2 = toString$9;
3134
3134
  var create = objectCreate;
3135
3135
  var createPropertyDescriptor = createPropertyDescriptor$5;
@@ -3232,7 +3232,7 @@
3232
3232
  this.url = null;
3233
3233
 
3234
3234
  if (init !== undefined) {
3235
- if (isObject$5(init)) this.parseObject(init);
3235
+ if (isObject$4(init)) this.parseObject(init);
3236
3236
  else this.parseQuery(typeof init == 'string' ? charAt$1(init, 0) === '?' ? stringSlice$2(init, 1) : init : $toString$2(init));
3237
3237
  }
3238
3238
  };
@@ -3449,7 +3449,7 @@
3449
3449
  var headersSet = uncurryThis$d(HeadersPrototype.set);
3450
3450
 
3451
3451
  var wrapRequestOptions = function (init) {
3452
- if (isObject$5(init)) {
3452
+ if (isObject$4(init)) {
3453
3453
  var body = init.body;
3454
3454
  var headers;
3455
3455
  if (classof$2(body) === URL_SEARCH_PARAMS) {
@@ -4548,7 +4548,7 @@
4548
4548
  return call$3.apply(apply$2, arguments);
4549
4549
  });
4550
4550
 
4551
- var isObject$4 = isObject$d;
4551
+ var isObject$3 = isObject$c;
4552
4552
  var classof$1 = classofRaw$1;
4553
4553
  var wellKnownSymbol$5 = wellKnownSymbol$m;
4554
4554
 
@@ -4558,7 +4558,7 @@
4558
4558
  // https://tc39.es/ecma262/#sec-isregexp
4559
4559
  var isRegexp = function (it) {
4560
4560
  var isRegExp;
4561
- return isObject$4(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$1(it) == 'RegExp');
4561
+ return isObject$3(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$1(it) == 'RegExp');
4562
4562
  };
4563
4563
 
4564
4564
  var global$f = global$T;
@@ -4983,7 +4983,7 @@
4983
4983
  });
4984
4984
 
4985
4985
  var isCallable$2 = isCallable$k;
4986
- var isObject$3 = isObject$d;
4986
+ var isObject$2 = isObject$c;
4987
4987
  var setPrototypeOf$1 = objectSetPrototypeOf;
4988
4988
 
4989
4989
  // makes subclassing work correct for wrapped built-ins
@@ -4995,7 +4995,7 @@
4995
4995
  // we haven't completely correct pre-ES6 way for getting `new.target`, so use this
4996
4996
  isCallable$2(NewTarget = dummy.constructor) &&
4997
4997
  NewTarget !== Wrapper &&
4998
- isObject$3(NewTargetPrototype = NewTarget.prototype) &&
4998
+ isObject$2(NewTargetPrototype = NewTarget.prototype) &&
4999
4999
  NewTargetPrototype !== Wrapper.prototype
5000
5000
  ) setPrototypeOf$1($this, NewTargetPrototype);
5001
5001
  return $this;
@@ -5651,9 +5651,9 @@
5651
5651
  Svg: styled__default["default"].svg.withConfig({
5652
5652
  displayName: "styles__Svg",
5653
5653
  componentId: "sc-jf3e5i-0"
5654
- })(["fill:", ";", " ", ";"], function (props) {
5654
+ })(["fill:", ";", " ", ";", ";"], function (props) {
5655
5655
  return getColor(props.color);
5656
- }, mediaBreaks.onlyPrint(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n\t\t\tfill: ", ";\n\t\t"])), palette.darkGrey), function (props) {
5656
+ }, mediaBreaks.onlyPrint(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral(["\n\t\t\tfill: ", ";\n\t\t"])), palette.darkGrey), mixins.transition('fill'), function (props) {
5657
5657
  return props.styles;
5658
5658
  }),
5659
5659
  Path: styled__default["default"].path.withConfig({
@@ -7154,7 +7154,7 @@
7154
7154
  Chip: styled__default["default"].button.withConfig({
7155
7155
  displayName: "styles__Chip",
7156
7156
  componentId: "sc-1vnh4co-0"
7157
- })(["padding:", ";cursor:", ";font-size:13px;color:", ";height:", ";width:", ";min-width:36px;max-width:150px;border-radius:", ";display:inline-flex;justify-content:center;align-items:center;pointer-events:", ";white-space:nowrap;", ";.chip-icon{", ";", ";}", ";", " ", " ", " ", ""], function (props) {
7157
+ })(["padding:", ";cursor:", ";font-size:13px;color:", ";height:", ";width:", ";min-width:36px;max-width:150px;border-radius:", ";display:inline-flex;justify-content:center;align-items:center;pointer-events:", ";white-space:nowrap;.chip-icon{", ";}", ";", ";", " ", " ", " ", ""], function (props) {
7158
7158
  return !props.onlyIcon ? '0 12px' : '0';
7159
7159
  }, function (props) {
7160
7160
  return props.clickable ? 'pointer' : 'default';
@@ -7166,12 +7166,10 @@
7166
7166
  return !props.onlyIcon ? '50px' : '50%';
7167
7167
  }, function (props) {
7168
7168
  return props.clickable || props.hasLink ? 'auto' : 'none';
7169
- }, function (props) {
7170
- return getChipVariant(props);
7171
7169
  }, function (props) {
7172
7170
  return !props.onlyIcon && 'margin-right: 8px';
7173
7171
  }, function (props) {
7174
- return props.iconColor && "fill: ".concat(getColor(props.iconColor));
7172
+ return getChipVariant(props);
7175
7173
  }, function (props) {
7176
7174
  return props.styles;
7177
7175
  }, function (props) {
@@ -7181,12 +7179,10 @@
7181
7179
  }, function (props) {
7182
7180
  return props.textColor && "color: ".concat(getColor(props.textColor), ";");
7183
7181
  }, mediaBreaks.onlyPrint(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n\t\t\tborder: 1px solid ", ";\n\t\t"])), palette.darkGrey)),
7184
- iconPathStyles: styled$g.css(["", ";"], mixins.transition('fill')),
7185
7182
  DeleteButton: styled__default["default"].button.withConfig({
7186
7183
  displayName: "styles__DeleteButton",
7187
7184
  componentId: "sc-1vnh4co-1"
7188
7185
  })(["width:16px;height:16px;margin-left:12px;"]),
7189
- deleteButtonPathStyles: styled$g.css(["", ";"], mixins.transition('fill')),
7190
7186
  Children: styled__default["default"].div.withConfig({
7191
7187
  displayName: "styles__Children",
7192
7188
  componentId: "sc-1vnh4co-2"
@@ -7223,21 +7219,18 @@
7223
7219
  selected: selected,
7224
7220
  textColor: textColor,
7225
7221
  variant: variant,
7226
- iconColor: iconColor,
7227
7222
  hasLink: hasLink,
7228
7223
  onlyIcon: !children && icon
7229
7224
  }, props), icon && /*#__PURE__*/React__default["default"].createElement(Icon, {
7230
7225
  className: "chip-icon",
7231
7226
  name: icon,
7232
7227
  color: iconColor,
7233
- size: iconSize,
7234
- pathStyles: styled$d.iconPathStyles
7228
+ size: iconSize
7235
7229
  }), children && /*#__PURE__*/React__default["default"].createElement(styled$d.Children, null, children), onDelete && /*#__PURE__*/React__default["default"].createElement(styled$d.DeleteButton, {
7236
7230
  type: "button",
7237
7231
  onClick: onDelete
7238
7232
  }, /*#__PURE__*/React__default["default"].createElement(Icon, {
7239
7233
  color: "black",
7240
- pathStyles: styled$d.deleteButtonPathStyles,
7241
7234
  className: "delete-button",
7242
7235
  name: "cross_circle_flat",
7243
7236
  size: 16
@@ -17090,40 +17083,6 @@
17090
17083
  return getBounds(markersFlatted);
17091
17084
  });
17092
17085
 
17093
- /**
17094
- * Sets the map center based on the provided markers or a default center value.
17095
- * @param {Object} center A default center object with latitude and longitude values.
17096
- * @param {number} center.lat The latitude value of the default center.
17097
- * @param {number} center.lng The longitude value of the default center.
17098
- */
17099
-
17100
- var getCenterByGeolocationOrCenter = (function () {
17101
- var center = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17102
- if (validateCoordinates(center)) return center;
17103
- return getGeolocationCoordinates();
17104
- });
17105
-
17106
- /**
17107
- * Retrieves the current geolocation of the user and updates the map's center coordinates.
17108
- */
17109
- var getGeolocationCoordinates = (function () {
17110
- try {
17111
- navigator.geolocation.getCurrentPosition(function () {
17112
- var pos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17113
- var _pos$coords = pos.coords,
17114
- lat = _pos$coords.latitude,
17115
- lng = _pos$coords.longitude;
17116
- return {
17117
- lat: lat,
17118
- lng: lng
17119
- };
17120
- });
17121
- } catch (error) {
17122
- console.log(error);
17123
- return {};
17124
- }
17125
- });
17126
-
17127
17086
  var LIBRARIES = ['geometry', 'drawing', 'places'];
17128
17087
  var DEFAULT_CENTER = {
17129
17088
  lat: 0,
@@ -17302,15 +17261,6 @@
17302
17261
  });
17303
17262
  });
17304
17263
 
17305
- /**
17306
- * Function to check if a value is an object
17307
- * @param {*} value Value to check if it is an object
17308
- * @returns Returns true if the value is an object
17309
- */
17310
- var isObject$2 = function isObject(value) {
17311
- return _typeof(value) === 'object' && !Array.isArray(value) && value instanceof Object;
17312
- };
17313
-
17314
17264
  var global$7 = global$T;
17315
17265
 
17316
17266
  var nativePromiseConstructor = global$7.Promise;
@@ -17643,7 +17593,7 @@
17643
17593
  };
17644
17594
 
17645
17595
  var anObject = anObject$h;
17646
- var isObject$1 = isObject$d;
17596
+ var isObject$1 = isObject$c;
17647
17597
  var newPromiseCapability$1 = newPromiseCapability$2;
17648
17598
 
17649
17599
  var promiseResolve$1 = function (C, x) {
@@ -17710,7 +17660,7 @@
17710
17660
  var setSpecies = setSpecies$1;
17711
17661
  var aCallable = aCallable$7;
17712
17662
  var isCallable = isCallable$k;
17713
- var isObject = isObject$d;
17663
+ var isObject = isObject$c;
17714
17664
  var anInstance = anInstance$3;
17715
17665
  var inspectSource = inspectSource$4;
17716
17666
  var iterate = iterate$1;
@@ -35430,28 +35380,6 @@
35430
35380
  }, _objectSpread2({}, parsedData));
35431
35381
  });
35432
35382
 
35433
- /**
35434
- * @function validateCoordinates
35435
- * @description return true or false is region has latitude and longitude keys and type number
35436
- * @param {object} coordinates - object with latitude and longitude
35437
- * @param {number} coordinates.lng - longitude
35438
- * @param {number} coordinates.lat - latitude
35439
- * @returns {boolean}
35440
- * @example isValidRegionData({latitude: -345345, longitude: -345435345}) => true
35441
- * @example isValidRegionData({latitude: -345345, longitude: '3453453453'}) => false
35442
- * @example isValidRegionData({latitude: -345345}) => false
35443
- */
35444
-
35445
- var validateCoordinates = (function () {
35446
- var coordinates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35447
- if (!isObject$2(coordinates) || !Object.keys(coordinates).length) return false;
35448
- var lng = coordinates.lng,
35449
- lat = coordinates.lat;
35450
- if (!lng || !lat) return false;
35451
- if (!lodash.exports.isNumber(lng) || !lodash.exports.isNumber(lat)) return false;
35452
- return true;
35453
- });
35454
-
35455
35383
  var styled = {
35456
35384
  LoadingElement: styled__default["default"].div.withConfig({
35457
35385
  displayName: "styles__LoadingElement",
@@ -35519,8 +35447,7 @@
35519
35447
  };
35520
35448
 
35521
35449
  var _excluded = ["googleMapsApiKey", "width", "height", "center", "zoom", "markers", "markerOptions", "options", "callbackOnSuccessDirections", "callbackOnErrorDirections"];
35522
-
35523
- var Map$1 = function Map(_ref) {
35450
+ var Map$1 = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
35524
35451
  var _mapRef$current;
35525
35452
 
35526
35453
  var _ref$googleMapsApiKey = _ref.googleMapsApiKey,
@@ -35529,8 +35456,7 @@
35529
35456
  width = _ref$width === void 0 ? '800px' : _ref$width,
35530
35457
  _ref$height = _ref.height,
35531
35458
  height = _ref$height === void 0 ? '400px' : _ref$height,
35532
- _ref$center = _ref.center,
35533
- center = _ref$center === void 0 ? DEFAULT_CENTER : _ref$center,
35459
+ center = _ref.center,
35534
35460
  _ref$zoom = _ref.zoom,
35535
35461
  zoom = _ref$zoom === void 0 ? 13 : _ref$zoom,
35536
35462
  _ref$markers = _ref.markers,
@@ -35573,7 +35499,7 @@
35573
35499
  mapRef.current.panTo(newCenter);
35574
35500
  };
35575
35501
 
35576
- var onLoad = React.useCallback(function (map) {
35502
+ var onLoad = function onLoad(map) {
35577
35503
  if (!map) return;
35578
35504
  mapRef.current = map;
35579
35505
  mapRef.current.setOptions({
@@ -35582,10 +35508,22 @@
35582
35508
  var fullScreenPos = mapOptions.showSearchBar ? 'RIGHT_BOTTOM' : 'RIGHT_TOP';
35583
35509
  handlePositions('fullScreen', window.google.maps.ControlPosition[fullScreenPos]);
35584
35510
  handlePositions('zoom', window.google.maps.ControlPosition.RIGHT_BOTTOM);
35585
- if (!(markers !== null && markers !== void 0 && markers.length)) mapRef.current.setCenter(getCenterByGeolocationOrCenter(center || DEFAULT_CENTER));
35586
- if (markers !== null && markers !== void 0 && markers.length) mapRef.current.fitBounds(getBoundsFromMarkers(markers));
35587
- mapRef.current.setZoom(zoom);
35588
- }, [center, markers, options, zoom]);
35511
+ if (!(markers !== null && markers !== void 0 && markers.length)) mapRef.current.setCenter(center || DEFAULT_CENTER);
35512
+ mapRef.current.setZoom(!center ? 2 : zoom);
35513
+ };
35514
+
35515
+ React.useImperativeHandle(ref, function () {
35516
+ return {
35517
+ setZoom: function setZoom(zoom) {
35518
+ return mapRef.current.setZoom(zoom);
35519
+ }
35520
+ };
35521
+ });
35522
+ React.useEffect(function () {
35523
+ if (mapRef.current && markers !== null && markers !== void 0 && markers.length) {
35524
+ mapRef.current.fitBounds(getBoundsFromMarkers(markers));
35525
+ }
35526
+ }, [mapRef.current, markers]);
35589
35527
  if (!isLoaded) return null;
35590
35528
  return /*#__PURE__*/React__default["default"].createElement(GoogleMap, _extends$1({
35591
35529
  className: "google-map-component",
@@ -35595,7 +35533,7 @@
35595
35533
  width: width
35596
35534
  },
35597
35535
  options: mapOptions,
35598
- center: (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.center
35536
+ center: (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.getCenter()
35599
35537
  }, props), mapOptions.showSearchBar && /*#__PURE__*/React__default["default"].createElement(SearchBox, {
35600
35538
  updateMarker: updateMarker,
35601
35539
  className: "google-map-component__search-box"
@@ -35607,7 +35545,8 @@
35607
35545
  callbackOnErrorDirections: callbackOnErrorDirections,
35608
35546
  googleMapsApiKey: googleMapsApiKey
35609
35547
  }));
35610
- };
35548
+ });
35549
+ Map$1.displayName = 'Map';
35611
35550
 
35612
35551
  var rotate = styled$g.keyframes(["to{transform:rotate(360deg);}"]);
35613
35552
  var Spinner$1 = styled__default["default"].div.withConfig({