@janiscommerce/ui-web 0.29.1 → 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,
@@ -17037,6 +17037,10 @@
17037
17037
  });
17038
17038
 
17039
17039
  var LIBRARIES = ['geometry', 'drawing', 'places'];
17040
+ var DEFAULT_CENTER = {
17041
+ lat: 0,
17042
+ lng: 0
17043
+ };
17040
17044
  var INITIAL_CONTROLS_POSITION = {
17041
17045
  zoom: 13,
17042
17046
  fullScreen: 0
@@ -17061,36 +17065,38 @@
17061
17065
  water: 'water',
17062
17066
  _default: 'poi'
17063
17067
  };
17068
+ var DEFAULT_MAP_OPTIONS = {
17069
+ mapTypeControl: false,
17070
+ streetViewControl: false,
17071
+ zoomControl: true,
17072
+ clickableIcons: false
17073
+ };
17064
17074
 
17065
17075
  /**
17066
17076
  * Parses configuration for map styles and controls based on the provided options.
17067
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
17068
17079
  * @param {Object} controlsPositions An object specifying the positions of map controls.
17069
17080
  * @param {number} controlsPositions.zoom The position of the zoom control on the map.
17070
17081
  * @param {number} controlsPositions.fullScreen The position of the fullscreen control on the map.
17071
17082
  * @returns {Object} An object containing the parsed map options, including styles and control settings.
17072
17083
  */
17073
17084
 
17074
- var getMapOptions = (function () {
17075
- var showPOI = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
17085
+ var getMapOptions = (function (options) {
17076
17086
  var controlsPositions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17077
17087
  var poi = MAP_FEATURE_TYPES.poi,
17078
17088
  transit = MAP_FEATURE_TYPES.transit;
17079
- var hideFeaturesRules = !showPOI && [poi, transit];
17080
- var mapStyleOptions = getMapStylers(hideFeaturesRules);
17081
- return {
17082
- mapTypeControl: false,
17083
- streetViewControl: false,
17084
- 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), {}, {
17085
17092
  zoomControlOptions: {
17086
17093
  position: controlsPositions.zoom
17087
17094
  },
17088
17095
  fullscreenControlOptions: {
17089
17096
  position: controlsPositions.fullScreen
17090
17097
  },
17091
- clickableIcons: false,
17092
17098
  styles: mapStyleOptions
17093
- };
17099
+ });
17094
17100
  });
17095
17101
 
17096
17102
  var $forEach = arrayIteration.forEach;
@@ -17131,20 +17137,34 @@
17131
17137
  /**
17132
17138
  * Returns the list of stylers based on the provided rules.
17133
17139
  * @param {Array} rules Array of rules
17140
+ * @param {Array} poiRules Array of poiRules
17134
17141
  * @returns Returns the list of stylers
17135
17142
  */
17136
17143
 
17137
17144
  var getMapStylers = (function () {
17138
17145
  var rules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
17146
+ var poiRules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
17139
17147
  var styleRules = [];
17140
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;
17141
17152
  allRules.forEach(function (rule) {
17142
- var featureType = MAP_FEATURE_TYPES[rule] || MAP_FEATURE_TYPES._default; // eslint-disable-line no-underscore-dangle
17143
-
17144
- var _MAP_STYLERS$_default = MAP_STYLERS._default,
17145
- styler = _MAP_STYLERS$_default.styler,
17146
- 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
+ }
17147
17166
 
17167
+ styleRules.push.apply(styleRules, _toConsumableArray(poiRules));
17148
17168
  var ruleObj = {
17149
17169
  featureType: featureType,
17150
17170
  stylers: [_defineProperty({}, styler, value)]
@@ -35355,7 +35375,7 @@
35355
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)
35356
35376
  };
35357
35377
 
35358
- var _excluded = ["formattedAddress"];
35378
+ var _excluded$1 = ["formattedAddress"];
35359
35379
 
35360
35380
  var SearchBox = function SearchBox(_ref) {
35361
35381
  var updateMarker = _ref.updateMarker;
@@ -35376,7 +35396,7 @@
35376
35396
 
35377
35397
  case 4:
35378
35398
  addressData = _context.sent;
35379
- formattedAddress = addressData.formattedAddress, addressComponents = _objectWithoutProperties(addressData, _excluded);
35399
+ formattedAddress = addressData.formattedAddress, addressComponents = _objectWithoutProperties(addressData, _excluded$1);
35380
35400
  if (updateMarker) updateMarker({
35381
35401
  lat: newLat(),
35382
35402
  lng: newLng(),
@@ -35405,12 +35425,16 @@
35405
35425
  onPlacesChanged: onPlacesChanged,
35406
35426
  onLoad: onLoad
35407
35427
  }, /*#__PURE__*/React__default["default"].createElement(styled.SearchBoxWrapper, null, /*#__PURE__*/React__default["default"].createElement(Input, {
35408
- placeholder: "search",
35428
+ placeholder: "Search",
35409
35429
  hasFloatingLabel: false
35410
35430
  })));
35411
35431
  };
35412
35432
 
35433
+ var _excluded = ["googleMapsApiKey", "width", "height", "center", "zoom", "markers", "options", "callbackOnSuccessDirections", "callbackOnErrorDirections"];
35434
+
35413
35435
  var Map$1 = function Map(_ref) {
35436
+ var _mapRef$current;
35437
+
35414
35438
  var _ref$googleMapsApiKey = _ref.googleMapsApiKey,
35415
35439
  googleMapsApiKey = _ref$googleMapsApiKey === void 0 ? '' : _ref$googleMapsApiKey,
35416
35440
  _ref$width = _ref.width,
@@ -35418,21 +35442,18 @@
35418
35442
  _ref$height = _ref.height,
35419
35443
  height = _ref$height === void 0 ? '400px' : _ref$height,
35420
35444
  _ref$center = _ref.center,
35421
- center = _ref$center === void 0 ? {} : _ref$center,
35445
+ center = _ref$center === void 0 ? DEFAULT_CENTER : _ref$center,
35422
35446
  _ref$zoom = _ref.zoom,
35423
35447
  zoom = _ref$zoom === void 0 ? 13 : _ref$zoom,
35424
35448
  _ref$markers = _ref.markers,
35425
35449
  markers = _ref$markers === void 0 ? [] : _ref$markers,
35426
- _ref$showSearchBar = _ref.showSearchBar,
35427
- showSearchBar = _ref$showSearchBar === void 0 ? false : _ref$showSearchBar,
35428
- _ref$readOnly = _ref.readOnly,
35429
- readOnly = _ref$readOnly === void 0 ? true : _ref$readOnly,
35430
- _ref$showPOI = _ref.showPOI,
35431
- showPOI = _ref$showPOI === void 0 ? false : _ref$showPOI,
35450
+ _ref$options = _ref.options,
35451
+ options = _ref$options === void 0 ? {} : _ref$options,
35432
35452
  _ref$callbackOnSucces = _ref.callbackOnSuccessDirections,
35433
35453
  callbackOnSuccessDirections = _ref$callbackOnSucces === void 0 ? function () {} : _ref$callbackOnSucces,
35434
35454
  _ref$callbackOnErrorD = _ref.callbackOnErrorDirections,
35435
- callbackOnErrorDirections = _ref$callbackOnErrorD === void 0 ? function () {} : _ref$callbackOnErrorD;
35455
+ callbackOnErrorDirections = _ref$callbackOnErrorD === void 0 ? function () {} : _ref$callbackOnErrorD,
35456
+ props = _objectWithoutProperties(_ref, _excluded);
35436
35457
 
35437
35458
  var _useJsApiLoader = useJsApiLoader({
35438
35459
  googleMapsApiKey: googleMapsApiKey,
@@ -35448,10 +35469,6 @@
35448
35469
  setControlsPositions = _useState2[1];
35449
35470
 
35450
35471
  var validMarkersExist = Array.isArray(markers) && markers.length;
35451
- var defaultMapCenter = {
35452
- lat: 0,
35453
- lng: 0
35454
- };
35455
35472
 
35456
35473
  var handlePositions = function handlePositions(key, value) {
35457
35474
  setControlsPositions(function (prev) {
@@ -35459,38 +35476,46 @@
35459
35476
  });
35460
35477
  };
35461
35478
 
35462
- 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
+
35463
35486
  var onLoad = React.useCallback(function (map) {
35464
35487
  if (!map) return;
35465
35488
  mapRef.current = map;
35466
35489
  mapRef.current.setOptions({
35467
35490
  gestureHandling: 'greedy'
35468
35491
  });
35469
- var fullScreenPos = showSearchBar ? 'RIGHT_BOTTOM' : 'RIGHT_TOP';
35492
+ var fullScreenPos = mapOptions.showSearchBar ? 'RIGHT_BOTTOM' : 'RIGHT_TOP';
35470
35493
  handlePositions('fullScreen', window.google.maps.ControlPosition[fullScreenPos]);
35471
35494
  handlePositions('zoom', window.google.maps.ControlPosition.RIGHT_BOTTOM);
35472
- if (!(markers !== null && markers !== void 0 && markers.length)) mapRef.current.setCenter(getCenterByGeolocationOrCenter(center || defaultMapCenter));
35495
+ if (!(markers !== null && markers !== void 0 && markers.length)) mapRef.current.setCenter(getCenterByGeolocationOrCenter(center || DEFAULT_CENTER));
35473
35496
  if (markers !== null && markers !== void 0 && markers.length) mapRef.current.fitBounds(getBoundsFromMarkers(markers));
35474
35497
  mapRef.current.setZoom(zoom);
35475
- }, []);
35498
+ }, [center, markers, options, zoom]);
35476
35499
  if (!isLoaded) return null;
35477
- return /*#__PURE__*/React__default["default"].createElement(GoogleMap, {
35500
+ return /*#__PURE__*/React__default["default"].createElement(GoogleMap, _extends$1({
35478
35501
  className: "google-map-component",
35479
35502
  onLoad: onLoad,
35480
35503
  mapContainerStyle: {
35481
35504
  height: height,
35482
35505
  width: width
35483
35506
  },
35484
- options: mapOptions
35485
- }, /*#__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,
35486
35511
  className: "google-map-component__search-box"
35487
35512
  }), validMarkersExist && /*#__PURE__*/React__default["default"].createElement(MarkersDrawer, {
35488
35513
  markers: markers,
35489
- readOnly: readOnly,
35514
+ readOnly: mapOptions.readOnly,
35490
35515
  callbackOnSuccessDirections: callbackOnSuccessDirections,
35491
35516
  callbackOnErrorDirections: callbackOnErrorDirections,
35492
35517
  googleMapsApiKey: googleMapsApiKey
35493
- })));
35518
+ }));
35494
35519
  };
35495
35520
 
35496
35521
  exports.Avatar = Avatar;