@janiscommerce/ui-web 0.29.0 → 0.30.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
@@ -7092,7 +7092,7 @@
7092
7092
  });
7093
7093
  }
7094
7094
 
7095
- var _excluded$9 = ["color", "name", "size", "styles", "pathStyles", "width", "height", "viewBox"];
7095
+ var _excluded$a = ["color", "name", "size", "styles", "pathStyles", "width", "height", "viewBox"];
7096
7096
 
7097
7097
  var Icon = function Icon(_ref) {
7098
7098
  var color = _ref.color,
@@ -7103,7 +7103,7 @@
7103
7103
  width = _ref.width,
7104
7104
  height = _ref.height,
7105
7105
  viewBox = _ref.viewBox,
7106
- props = _objectWithoutProperties(_ref, _excluded$9);
7106
+ props = _objectWithoutProperties(_ref, _excluded$a);
7107
7107
 
7108
7108
  if (!icons[name]) return null;
7109
7109
  var _icons$name = icons[name],
@@ -7191,7 +7191,7 @@
7191
7191
  })(["text-overflow:ellipsis;overflow:hidden;"])
7192
7192
  };
7193
7193
 
7194
- var _excluded$8 = ["backgroundColor", "borderColor", "children", "disabled", "icon", "iconColor", "onClick", "onDelete", "selected", "textColor", "variant", "hasLink"];
7194
+ var _excluded$9 = ["backgroundColor", "borderColor", "children", "disabled", "icon", "iconColor", "onClick", "onDelete", "selected", "textColor", "variant", "hasLink"];
7195
7195
 
7196
7196
  var Chip = function Chip(_ref) {
7197
7197
  var backgroundColor = _ref.backgroundColor,
@@ -7206,7 +7206,7 @@
7206
7206
  textColor = _ref.textColor,
7207
7207
  variant = _ref.variant,
7208
7208
  hasLink = _ref.hasLink,
7209
- props = _objectWithoutProperties(_ref, _excluded$8);
7209
+ props = _objectWithoutProperties(_ref, _excluded$9);
7210
7210
 
7211
7211
  if (!children && !icon) return null;
7212
7212
  return /*#__PURE__*/React__default["default"].createElement(styled$d.Chip, _extends$1({
@@ -7511,7 +7511,7 @@
7511
7511
  })
7512
7512
  };
7513
7513
 
7514
- var _excluded$7 = ["children", "color", "hideLabel", "icon", "iconColor", "iconSize", "fontColor", "rounded", "styles", "variant", "disabled"];
7514
+ var _excluded$8 = ["children", "color", "hideLabel", "icon", "iconColor", "iconSize", "fontColor", "rounded", "styles", "variant", "disabled"];
7515
7515
 
7516
7516
  var Button = function Button(_ref) {
7517
7517
  var children = _ref.children,
@@ -7525,7 +7525,7 @@
7525
7525
  styles = _ref.styles,
7526
7526
  variant = _ref.variant,
7527
7527
  disabled = _ref.disabled,
7528
- props = _objectWithoutProperties(_ref, _excluded$7);
7528
+ props = _objectWithoutProperties(_ref, _excluded$8);
7529
7529
 
7530
7530
  return /*#__PURE__*/React__default["default"].createElement(styled$b.Button, _extends$1({
7531
7531
  color: color,
@@ -7574,7 +7574,7 @@
7574
7574
  })
7575
7575
  };
7576
7576
 
7577
- var _excluded$6 = ["autoComplete", "disabled", "defaultChecked", "onChange", "rounded", "styles", "value"];
7577
+ var _excluded$7 = ["autoComplete", "disabled", "defaultChecked", "onChange", "rounded", "styles", "value"];
7578
7578
 
7579
7579
  var Checkbox = function Checkbox(_ref) {
7580
7580
  var autoComplete = _ref.autoComplete,
@@ -7584,7 +7584,7 @@
7584
7584
  rounded = _ref.rounded,
7585
7585
  styles = _ref.styles,
7586
7586
  value = _ref.value,
7587
- props = _objectWithoutProperties(_ref, _excluded$6);
7587
+ props = _objectWithoutProperties(_ref, _excluded$7);
7588
7588
 
7589
7589
  var _useState = React.useState(!!value || defaultChecked),
7590
7590
  _useState2 = _slicedToArray(_useState, 2),
@@ -7700,7 +7700,7 @@
7700
7700
  iconCheckStyles: iconCheckStyles
7701
7701
  };
7702
7702
 
7703
- var _excluded$5 = ["autoComplete", "defaultChecked", "disabled", "id", "name", "onChange", "value"];
7703
+ var _excluded$6 = ["autoComplete", "defaultChecked", "disabled", "id", "name", "onChange", "value"];
7704
7704
 
7705
7705
  var Switch = function Switch(_ref) {
7706
7706
  var autoComplete = _ref.autoComplete,
@@ -7710,7 +7710,7 @@
7710
7710
  name = _ref.name,
7711
7711
  onChange = _ref.onChange,
7712
7712
  value = _ref.value,
7713
- props = _objectWithoutProperties(_ref, _excluded$5);
7713
+ props = _objectWithoutProperties(_ref, _excluded$6);
7714
7714
 
7715
7715
  var _useState = React.useState(!!value || defaultChecked),
7716
7716
  _useState2 = _slicedToArray(_useState, 2),
@@ -7882,7 +7882,7 @@
7882
7882
  })(["position:absolute;flex-shrink:0;flex-grow:0;margin-right:8px;height:100%;"])
7883
7883
  };
7884
7884
 
7885
- var _excluded$4 = ["icon", "error", "disabled", "placeholder", "errorMessage", "autoComplete", "hasFloatingLabel", "value", "isTranslateActive", "defaultValue"];
7885
+ var _excluded$5 = ["icon", "error", "disabled", "placeholder", "errorMessage", "autoComplete", "hasFloatingLabel", "value", "isTranslateActive", "defaultValue"];
7886
7886
 
7887
7887
  var Input = /*#__PURE__*/function (_PureComponent) {
7888
7888
  _inherits$2(Input, _PureComponent);
@@ -7978,7 +7978,7 @@
7978
7978
  value = _this$props$value === void 0 ? stateValue : _this$props$value,
7979
7979
  isTranslateActive = _this$props.isTranslateActive;
7980
7980
  _this$props.defaultValue;
7981
- var props = _objectWithoutProperties(_this$props, _excluded$4);
7981
+ var props = _objectWithoutProperties(_this$props, _excluded$5);
7982
7982
 
7983
7983
  var autoCompleteOff = props.type === 'password' ? 'new-password' : 'off';
7984
7984
  var isFloating = isFocused || !!value.toString();
@@ -8091,7 +8091,7 @@
8091
8091
  })(["color:", ";font-size:12px;line-height:14px;display:block;word-break:break-word;"], palette.statusRed)
8092
8092
  };
8093
8093
 
8094
- var _excluded$3 = ["label", "error", "disabled", "placeholder", "autoComplete", "errorMessage", "hasFloatingLabel", "isTranslateActive", "value", "defaultValue"];
8094
+ var _excluded$4 = ["label", "error", "disabled", "placeholder", "autoComplete", "errorMessage", "hasFloatingLabel", "isTranslateActive", "value", "defaultValue"];
8095
8095
 
8096
8096
  var Textarea = /*#__PURE__*/function (_PureComponent) {
8097
8097
  _inherits$2(Textarea, _PureComponent);
@@ -8193,7 +8193,7 @@
8193
8193
  _this$props$value = _this$props.value,
8194
8194
  value = _this$props$value === void 0 ? stateValue : _this$props$value;
8195
8195
  _this$props.defaultValue;
8196
- var props = _objectWithoutProperties(_this$props, _excluded$3);
8196
+ var props = _objectWithoutProperties(_this$props, _excluded$4);
8197
8197
 
8198
8198
  var isFloating = isFocused || !!value;
8199
8199
  return /*#__PURE__*/React__default["default"].createElement(styled$6.Container, {
@@ -9722,14 +9722,14 @@
9722
9722
  })(["margin-right:8px;"])
9723
9723
  };
9724
9724
 
9725
- var _excluded$2 = ["href", "children", "target", "icon"];
9725
+ var _excluded$3 = ["href", "children", "target", "icon"];
9726
9726
 
9727
9727
  var Link = function Link(_ref) {
9728
9728
  var href = _ref.href,
9729
9729
  children = _ref.children,
9730
9730
  target = _ref.target,
9731
9731
  icon = _ref.icon,
9732
- props = _objectWithoutProperties(_ref, _excluded$2);
9732
+ props = _objectWithoutProperties(_ref, _excluded$3);
9733
9733
 
9734
9734
  var renderIcon = function renderIcon() {
9735
9735
  return icon ? /*#__PURE__*/React__default["default"].createElement(styled$2.StyledIcon, {
@@ -9853,7 +9853,7 @@
9853
9853
  Overlay: Overlay
9854
9854
  };
9855
9855
 
9856
- var _excluded$1 = ["open", "position", "handleClose", "transitionDuration", "fullScreen", "closeOnClickAway", "children"];
9856
+ var _excluded$2 = ["open", "position", "handleClose", "transitionDuration", "fullScreen", "closeOnClickAway", "children"];
9857
9857
 
9858
9858
  var Drawer = function Drawer(_ref) {
9859
9859
  var open = _ref.open,
@@ -9863,7 +9863,7 @@
9863
9863
  fullScreen = _ref.fullScreen,
9864
9864
  closeOnClickAway = _ref.closeOnClickAway,
9865
9865
  children = _ref.children,
9866
- props = _objectWithoutProperties(_ref, _excluded$1);
9866
+ props = _objectWithoutProperties(_ref, _excluded$2);
9867
9867
 
9868
9868
  var drawerRef = React.useRef(null);
9869
9869
  return /*#__PURE__*/React__default["default"].createElement(ClickAwayListener, {
@@ -16094,7 +16094,7 @@
16094
16094
  var _ref$markers = _ref.markers,
16095
16095
  markers = _ref$markers === void 0 ? [] : _ref$markers,
16096
16096
  _ref$readOnly = _ref.readOnly,
16097
- readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
16097
+ readOnly = _ref$readOnly === void 0 ? true : _ref$readOnly,
16098
16098
  _ref$setMarker = _ref.setMarker,
16099
16099
  setMarker = _ref$setMarker === void 0 ? function () {} : _ref$setMarker,
16100
16100
  _ref$callbackOnSucces = _ref.callbackOnSuccessDirections,
@@ -17011,10 +17011,7 @@
17011
17011
 
17012
17012
  var getCenterByGeolocationOrCenter = (function () {
17013
17013
  var center = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17014
- if (validateCoordinates(center)) return {
17015
- lat: center.lat,
17016
- lng: center.lng
17017
- };
17014
+ if (validateCoordinates(center)) return center;
17018
17015
  return getGeolocationCoordinates();
17019
17016
  });
17020
17017
 
@@ -17040,6 +17037,10 @@
17040
17037
  });
17041
17038
 
17042
17039
  var LIBRARIES = ['geometry', 'drawing', 'places'];
17040
+ var DEFAULT_CENTER = {
17041
+ lat: 0,
17042
+ lng: 0
17043
+ };
17043
17044
  var INITIAL_CONTROLS_POSITION = {
17044
17045
  zoom: 13,
17045
17046
  fullScreen: 0
@@ -17064,36 +17065,38 @@
17064
17065
  water: 'water',
17065
17066
  _default: 'poi'
17066
17067
  };
17068
+ var DEFAULT_MAP_OPTIONS = {
17069
+ mapTypeControl: false,
17070
+ streetViewControl: false,
17071
+ zoomControl: true,
17072
+ clickableIcons: false
17073
+ };
17067
17074
 
17068
17075
  /**
17069
17076
  * Parses configuration for map styles and controls based on the provided options.
17070
17077
  * @param {boolean} showPOI Determines whether Points of Interest (POI) should be displayed on the map.
17078
+ * @param {Object} options An object specifying the options to control map display
17071
17079
  * @param {Object} controlsPositions An object specifying the positions of map controls.
17072
17080
  * @param {number} controlsPositions.zoom The position of the zoom control on the map.
17073
17081
  * @param {number} controlsPositions.fullScreen The position of the fullscreen control on the map.
17074
17082
  * @returns {Object} An object containing the parsed map options, including styles and control settings.
17075
17083
  */
17076
17084
 
17077
- var getMapOptions = (function () {
17078
- var showPOI = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
17085
+ var getMapOptions = (function (options) {
17079
17086
  var controlsPositions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17080
17087
  var poi = MAP_FEATURE_TYPES.poi,
17081
17088
  transit = MAP_FEATURE_TYPES.transit;
17082
- var hideFeaturesRules = !showPOI && [poi, transit];
17083
- var mapStyleOptions = getMapStylers(hideFeaturesRules);
17084
- return {
17085
- mapTypeControl: false,
17086
- streetViewControl: false,
17087
- zoomControl: true,
17089
+ var hideFeaturesRules = !options.showPOI ? [poi, transit] : [];
17090
+ var mapStyleOptions = getMapStylers(hideFeaturesRules, options.poiRules);
17091
+ return _objectSpread2(_objectSpread2(_objectSpread2({}, DEFAULT_MAP_OPTIONS), options), {}, {
17088
17092
  zoomControlOptions: {
17089
17093
  position: controlsPositions.zoom
17090
17094
  },
17091
17095
  fullscreenControlOptions: {
17092
17096
  position: controlsPositions.fullScreen
17093
17097
  },
17094
- clickableIcons: false,
17095
17098
  styles: mapStyleOptions
17096
- };
17099
+ });
17097
17100
  });
17098
17101
 
17099
17102
  var $forEach = arrayIteration.forEach;
@@ -17134,20 +17137,34 @@
17134
17137
  /**
17135
17138
  * Returns the list of stylers based on the provided rules.
17136
17139
  * @param {Array} rules Array of rules
17140
+ * @param {Array} poiRules Array of poiRules
17137
17141
  * @returns Returns the list of stylers
17138
17142
  */
17139
17143
 
17140
17144
  var getMapStylers = (function () {
17141
17145
  var rules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
17146
+ var poiRules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
17142
17147
  var styleRules = [];
17143
17148
  var allRules = Array.isArray(rules) ? rules : [rules];
17149
+ var _MAP_STYLERS$_default = MAP_STYLERS._default,
17150
+ styler = _MAP_STYLERS$_default.styler,
17151
+ value = _MAP_STYLERS$_default.value;
17144
17152
  allRules.forEach(function (rule) {
17145
- var featureType = MAP_FEATURE_TYPES[rule] || MAP_FEATURE_TYPES._default; // eslint-disable-line no-underscore-dangle
17146
-
17147
- var _MAP_STYLERS$_default = MAP_STYLERS._default,
17148
- styler = _MAP_STYLERS$_default.styler,
17149
- value = _MAP_STYLERS$_default.value; // eslint-disable-line no-underscore-dangle
17153
+ var featureType = MAP_FEATURE_TYPES[rule] || MAP_FEATURE_TYPES._default;
17154
+
17155
+ if (rule === 'route') {
17156
+ styleRules.push({
17157
+ featureType: 'all',
17158
+ stylers: [{
17159
+ visibility: 'on'
17160
+ }, {
17161
+ weight: 3
17162
+ }]
17163
+ });
17164
+ return;
17165
+ }
17150
17166
 
17167
+ styleRules.push.apply(styleRules, _toConsumableArray(poiRules));
17151
17168
  var ruleObj = {
17152
17169
  featureType: featureType,
17153
17170
  stylers: [_defineProperty({}, styler, value)]
@@ -35358,7 +35375,7 @@
35358
35375
  })(["z-index:0;position:relative;right:0px;top:0px;background:", ";margin:10px;padding:4px 8px 6px;border-radius:2px;width:auto;box-shadow:rgba(0,0,0,0.3) 0px 1px 4px -1px;"], palette.white)
35359
35376
  };
35360
35377
 
35361
- var _excluded = ["formattedAddress"];
35378
+ var _excluded$1 = ["formattedAddress"];
35362
35379
 
35363
35380
  var SearchBox = function SearchBox(_ref) {
35364
35381
  var updateMarker = _ref.updateMarker;
@@ -35379,7 +35396,7 @@
35379
35396
 
35380
35397
  case 4:
35381
35398
  addressData = _context.sent;
35382
- formattedAddress = addressData.formattedAddress, addressComponents = _objectWithoutProperties(addressData, _excluded);
35399
+ formattedAddress = addressData.formattedAddress, addressComponents = _objectWithoutProperties(addressData, _excluded$1);
35383
35400
  if (updateMarker) updateMarker({
35384
35401
  lat: newLat(),
35385
35402
  lng: newLng(),
@@ -35408,12 +35425,16 @@
35408
35425
  onPlacesChanged: onPlacesChanged,
35409
35426
  onLoad: onLoad
35410
35427
  }, /*#__PURE__*/React__default["default"].createElement(styled.SearchBoxWrapper, null, /*#__PURE__*/React__default["default"].createElement(Input, {
35411
- placeholder: "search",
35428
+ placeholder: "Search",
35412
35429
  hasFloatingLabel: false
35413
35430
  })));
35414
35431
  };
35415
35432
 
35433
+ var _excluded = ["googleMapsApiKey", "width", "height", "center", "zoom", "markers", "options", "callbackOnSuccessDirections", "callbackOnErrorDirections"];
35434
+
35416
35435
  var Map$1 = function Map(_ref) {
35436
+ var _mapRef$current;
35437
+
35417
35438
  var _ref$googleMapsApiKey = _ref.googleMapsApiKey,
35418
35439
  googleMapsApiKey = _ref$googleMapsApiKey === void 0 ? '' : _ref$googleMapsApiKey,
35419
35440
  _ref$width = _ref.width,
@@ -35421,21 +35442,18 @@
35421
35442
  _ref$height = _ref.height,
35422
35443
  height = _ref$height === void 0 ? '400px' : _ref$height,
35423
35444
  _ref$center = _ref.center,
35424
- center = _ref$center === void 0 ? {} : _ref$center,
35445
+ center = _ref$center === void 0 ? DEFAULT_CENTER : _ref$center,
35425
35446
  _ref$zoom = _ref.zoom,
35426
35447
  zoom = _ref$zoom === void 0 ? 13 : _ref$zoom,
35427
35448
  _ref$markers = _ref.markers,
35428
35449
  markers = _ref$markers === void 0 ? [] : _ref$markers,
35429
- _ref$showSearchBar = _ref.showSearchBar,
35430
- showSearchBar = _ref$showSearchBar === void 0 ? false : _ref$showSearchBar,
35431
- _ref$readOnly = _ref.readOnly,
35432
- readOnly = _ref$readOnly === void 0 ? true : _ref$readOnly,
35433
- _ref$showPOI = _ref.showPOI,
35434
- showPOI = _ref$showPOI === void 0 ? false : _ref$showPOI,
35450
+ _ref$options = _ref.options,
35451
+ options = _ref$options === void 0 ? {} : _ref$options,
35435
35452
  _ref$callbackOnSucces = _ref.callbackOnSuccessDirections,
35436
35453
  callbackOnSuccessDirections = _ref$callbackOnSucces === void 0 ? function () {} : _ref$callbackOnSucces,
35437
35454
  _ref$callbackOnErrorD = _ref.callbackOnErrorDirections,
35438
- callbackOnErrorDirections = _ref$callbackOnErrorD === void 0 ? function () {} : _ref$callbackOnErrorD;
35455
+ callbackOnErrorDirections = _ref$callbackOnErrorD === void 0 ? function () {} : _ref$callbackOnErrorD,
35456
+ props = _objectWithoutProperties(_ref, _excluded);
35439
35457
 
35440
35458
  var _useJsApiLoader = useJsApiLoader({
35441
35459
  googleMapsApiKey: googleMapsApiKey,
@@ -35451,13 +35469,6 @@
35451
35469
  setControlsPositions = _useState2[1];
35452
35470
 
35453
35471
  var validMarkersExist = Array.isArray(markers) && markers.length;
35454
- var defaultMapCenter = {
35455
- center: {
35456
- lat: 0,
35457
- lng: 0
35458
- },
35459
- zoom: zoom
35460
- };
35461
35472
 
35462
35473
  var handlePositions = function handlePositions(key, value) {
35463
35474
  setControlsPositions(function (prev) {
@@ -35465,37 +35476,46 @@
35465
35476
  });
35466
35477
  };
35467
35478
 
35468
- var mapOptions = getMapOptions(showPOI, controlsPositions);
35479
+ var mapOptions = getMapOptions(options, controlsPositions);
35480
+
35481
+ var updateMarker = function updateMarker(newCenter) {
35482
+ if (!mapRef.current) return;
35483
+ mapRef.current.panTo(newCenter);
35484
+ };
35485
+
35469
35486
  var onLoad = React.useCallback(function (map) {
35470
35487
  if (!map) return;
35471
35488
  mapRef.current = map;
35472
- map.setOptions({
35489
+ mapRef.current.setOptions({
35473
35490
  gestureHandling: 'greedy'
35474
35491
  });
35475
- var fullScreenPos = showSearchBar ? 'RIGHT_BOTTOM' : 'RIGHT_TOP';
35492
+ var fullScreenPos = mapOptions.showSearchBar ? 'RIGHT_BOTTOM' : 'RIGHT_TOP';
35476
35493
  handlePositions('fullScreen', window.google.maps.ControlPosition[fullScreenPos]);
35477
35494
  handlePositions('zoom', window.google.maps.ControlPosition.RIGHT_BOTTOM);
35478
- if (!(markers !== null && markers !== void 0 && markers.length)) return map.setCenter(getCenterByGeolocationOrCenter(center));
35479
- map.fitBounds(getBoundsFromMarkers(markers));
35495
+ if (!(markers !== null && markers !== void 0 && markers.length)) mapRef.current.setCenter(getCenterByGeolocationOrCenter(center || DEFAULT_CENTER));
35496
+ if (markers !== null && markers !== void 0 && markers.length) mapRef.current.fitBounds(getBoundsFromMarkers(markers));
35480
35497
  mapRef.current.setZoom(zoom);
35481
- }, []);
35482
- return isLoaded ? /*#__PURE__*/React__default["default"].createElement(GoogleMap, _extends$1({
35498
+ }, [center, markers, options, zoom]);
35499
+ if (!isLoaded) return null;
35500
+ return /*#__PURE__*/React__default["default"].createElement(GoogleMap, _extends$1({
35483
35501
  className: "google-map-component",
35484
35502
  onLoad: onLoad,
35485
35503
  mapContainerStyle: {
35486
35504
  height: height,
35487
35505
  width: width
35488
35506
  },
35489
- options: mapOptions
35490
- }, defaultMapCenter), /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, showSearchBar && /*#__PURE__*/React__default["default"].createElement(SearchBox, {
35507
+ options: mapOptions,
35508
+ center: (_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.center
35509
+ }, props), mapOptions.showSearchBar && /*#__PURE__*/React__default["default"].createElement(SearchBox, {
35510
+ updateMarker: updateMarker,
35491
35511
  className: "google-map-component__search-box"
35492
35512
  }), validMarkersExist && /*#__PURE__*/React__default["default"].createElement(MarkersDrawer, {
35493
35513
  markers: markers,
35494
- readOnly: readOnly,
35514
+ readOnly: mapOptions.readOnly,
35495
35515
  callbackOnSuccessDirections: callbackOnSuccessDirections,
35496
35516
  callbackOnErrorDirections: callbackOnErrorDirections,
35497
35517
  googleMapsApiKey: googleMapsApiKey
35498
- }))) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null);
35518
+ }));
35499
35519
  };
35500
35520
 
35501
35521
  exports.Avatar = Avatar;