ordering-components-external 13.2.17 → 13.2.18

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.
Files changed (18) hide show
  1. package/_bundles/{7.ordering-component.7ec1e035382ea280a237.js → 7.ordering-component.eda1dc4602f12077abd7.js} +1 -1
  2. package/_bundles/{ordering-component.7ec1e035382ea280a237.js → ordering-component.eda1dc4602f12077abd7.js} +2 -2
  3. package/_modules/components/GoogleAutocompleteInput/index.js +1 -1
  4. package/_modules/components/GoogleMaps/index.js +30 -6
  5. package/_modules/components/GpsButton/index.js +34 -3
  6. package/package.json +1 -1
  7. package/src/components/GoogleAutocompleteInput/index.js +3 -3
  8. package/src/components/GoogleMaps/index.js +29 -5
  9. package/src/components/GpsButton/index.js +28 -2
  10. /package/_bundles/{0.ordering-component.7ec1e035382ea280a237.js → 0.ordering-component.eda1dc4602f12077abd7.js} +0 -0
  11. /package/_bundles/{1.ordering-component.7ec1e035382ea280a237.js → 1.ordering-component.eda1dc4602f12077abd7.js} +0 -0
  12. /package/_bundles/{2.ordering-component.7ec1e035382ea280a237.js → 2.ordering-component.eda1dc4602f12077abd7.js} +0 -0
  13. /package/_bundles/{4.ordering-component.7ec1e035382ea280a237.js → 4.ordering-component.eda1dc4602f12077abd7.js} +0 -0
  14. /package/_bundles/{5.ordering-component.7ec1e035382ea280a237.js → 5.ordering-component.eda1dc4602f12077abd7.js} +0 -0
  15. /package/_bundles/{6.ordering-component.7ec1e035382ea280a237.js → 6.ordering-component.eda1dc4602f12077abd7.js} +0 -0
  16. /package/_bundles/{7.ordering-component.7ec1e035382ea280a237.js.LICENSE.txt → 7.ordering-component.eda1dc4602f12077abd7.js.LICENSE.txt} +0 -0
  17. /package/_bundles/{8.ordering-component.7ec1e035382ea280a237.js → 8.ordering-component.eda1dc4602f12077abd7.js} +0 -0
  18. /package/_bundles/{ordering-component.7ec1e035382ea280a237.js.LICENSE.txt → ordering-component.eda1dc4602f12077abd7.js.LICENSE.txt} +0 -0
@@ -82,7 +82,7 @@ var AutocompleteInput = function AutocompleteInput(props) {
82
82
  if (addressType === 'locality') {
83
83
  addressObj.locality = component.long_name;
84
84
  }
85
- if (((_component$types = component.types) === null || _component$types === void 0 ? void 0 : _component$types.includes('sublocality')) === 'sublocality') {
85
+ if ((_component$types = component.types) !== null && _component$types !== void 0 && _component$types.includes('sublocality')) {
86
86
  addressObj.sublocality = component.long_name;
87
87
  }
88
88
  if (addressType === 'country') {
@@ -189,18 +189,43 @@ var GoogleMaps = exports.GoogleMaps = function GoogleMaps(props) {
189
189
  latLng: pos
190
190
  }, function (results) {
191
191
  var _results$;
192
- var zipcode = null;
193
192
  if (results && results.length > 0 && results !== null && results !== void 0 && (_results$ = results[0]) !== null && _results$ !== void 0 && _results$.address_components) {
194
193
  var _address$location, _address$location2;
194
+ var addressObj = {};
195
195
  var _iterator2 = _createForOfIteratorHelper(results[0].address_components),
196
196
  _step2;
197
197
  try {
198
198
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
199
+ var _component$types;
199
200
  var component = _step2.value;
200
201
  var addressType = component.types[0];
201
202
  if (addressType === 'postal_code') {
202
- zipcode = component.short_name;
203
- break;
203
+ addressObj.zipcode = component.short_name;
204
+ }
205
+ if (addressType === 'street_number') {
206
+ addressObj.street_number = component.long_name;
207
+ }
208
+ if (addressType === 'neighborhood') {
209
+ addressObj.neighborhood = component.long_name;
210
+ }
211
+ if (addressType === 'route') {
212
+ addressObj.route = component.short_name;
213
+ }
214
+ if (addressType === 'locality') {
215
+ addressObj.locality = component.long_name;
216
+ }
217
+ if ((_component$types = component.types) !== null && _component$types !== void 0 && _component$types.includes('sublocality')) {
218
+ addressObj.sublocality = component.long_name;
219
+ }
220
+ if (addressType === 'country') {
221
+ addressObj.country = component.long_name;
222
+ addressObj.country_code = component.short_name;
223
+ }
224
+ if (addressType === 'administrative_area_level_1') {
225
+ addressObj.state = component.long_name;
226
+ }
227
+ if (addressType === 'administrative_area_level_2') {
228
+ addressObj.city = component.long_name;
204
229
  }
205
230
  }
206
231
  } catch (err) {
@@ -208,14 +233,13 @@ var GoogleMaps = exports.GoogleMaps = function GoogleMaps(props) {
208
233
  } finally {
209
234
  _iterator2.f();
210
235
  }
211
- var address = {
236
+ var address = _objectSpread({
212
237
  address: results[0].formatted_address,
213
238
  location: {
214
239
  lat: pos === null || pos === void 0 ? void 0 : pos.lat(),
215
240
  lng: pos === null || pos === void 0 ? void 0 : pos.lng()
216
241
  }
217
- };
218
- if (zipcode) address.zipcode = zipcode;
242
+ }, addressObj);
219
243
  handleChangeAddressMap && handleChangeAddressMap(address);
220
244
  center.lat = (_address$location = address.location) === null || _address$location === void 0 ? void 0 : _address$location.lat;
221
245
  center.lng = (_address$location2 = address.location) === null || _address$location2 === void 0 ? void 0 : _address$location2.lng;
@@ -13,6 +13,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
13
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
21
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
17
22
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
18
23
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -60,16 +65,42 @@ var GpsButton = exports.GpsButton = function GpsButton(props) {
60
65
  var _results$;
61
66
  setIsLoading(false);
62
67
  var postalCode = null;
68
+ var addressObj = {};
63
69
  if (results !== null && results !== void 0 && (_results$ = results[0]) !== null && _results$ !== void 0 && _results$.address_components) {
64
70
  var _iterator = _createForOfIteratorHelper(results[0].address_components),
65
71
  _step;
66
72
  try {
67
73
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
74
+ var _component$types;
68
75
  var component = _step.value;
69
76
  var addressType = component.types[0];
70
77
  if (addressType === 'postal_code') {
71
78
  postalCode = component.short_name;
72
- break;
79
+ }
80
+ if (addressType === 'street_number') {
81
+ addressObj.street_number = component.long_name;
82
+ }
83
+ if (addressType === 'neighborhood') {
84
+ addressObj.neighborhood = component.long_name;
85
+ }
86
+ if (addressType === 'route') {
87
+ addressObj.route = component.short_name;
88
+ }
89
+ if (addressType === 'locality') {
90
+ addressObj.locality = component.long_name;
91
+ }
92
+ if ((_component$types = component.types) !== null && _component$types !== void 0 && _component$types.includes('sublocality')) {
93
+ addressObj.sublocality = component.long_name;
94
+ }
95
+ if (addressType === 'country') {
96
+ addressObj.country = component.long_name;
97
+ addressObj.country_code = component.short_name;
98
+ }
99
+ if (addressType === 'administrative_area_level_1') {
100
+ addressObj.state = component.long_name;
101
+ }
102
+ if (addressType === 'administrative_area_level_2') {
103
+ addressObj.city = component.long_name;
73
104
  }
74
105
  }
75
106
  } catch (err) {
@@ -78,7 +109,7 @@ var GpsButton = exports.GpsButton = function GpsButton(props) {
78
109
  _iterator.f();
79
110
  }
80
111
  if (status === 'OK') {
81
- onAddress({
112
+ onAddress(_objectSpread({
82
113
  address: results[0].formatted_address,
83
114
  location: location,
84
115
  utc_offset: new Date().getTimezoneOffset(),
@@ -87,7 +118,7 @@ var GpsButton = exports.GpsButton = function GpsButton(props) {
87
118
  library: 'google',
88
119
  place_id: results[0].place_id
89
120
  }
90
- });
121
+ }, addressObj));
91
122
  } else {
92
123
  onError && onError(t('ERROR_GPS_BUTTON', 'Error to get result with gps button'));
93
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-components-external",
3
- "version": "13.2.17",
3
+ "version": "13.2.18",
4
4
  "description": "Ordering Internal Dashboard",
5
5
  "main": "./_modules/index.js",
6
6
  "scripts": {
@@ -27,8 +27,8 @@ const AutocompleteInput = (props) => {
27
27
  })
28
28
 
29
29
  const options = {
30
- types: types,
31
- fields: fields
30
+ types,
31
+ fields
32
32
  }
33
33
 
34
34
  if (countryCode !== '*') {
@@ -61,7 +61,7 @@ const AutocompleteInput = (props) => {
61
61
  if (addressType === 'locality') {
62
62
  addressObj.locality = component.long_name
63
63
  }
64
- if (component.types?.includes('sublocality') === 'sublocality') {
64
+ if (component.types?.includes('sublocality')) {
65
65
  addressObj.sublocality = component.long_name
66
66
  }
67
67
  if (addressType === 'country') {
@@ -130,20 +130,44 @@ export const GoogleMaps = (props) => {
130
130
  const geocoder = new window.google.maps.Geocoder()
131
131
 
132
132
  geocoder.geocode({ latLng: pos }, (results) => {
133
- let zipcode = null
134
133
  if (results && results.length > 0 && results?.[0]?.address_components) {
134
+ const addressObj = {}
135
135
  for (const component of results[0].address_components) {
136
136
  const addressType = component.types[0]
137
137
  if (addressType === 'postal_code') {
138
- zipcode = component.short_name
139
- break
138
+ addressObj.zipcode = component.short_name
139
+ }
140
+ if (addressType === 'street_number') {
141
+ addressObj.street_number = component.long_name
142
+ }
143
+ if (addressType === 'neighborhood') {
144
+ addressObj.neighborhood = component.long_name
145
+ }
146
+ if (addressType === 'route') {
147
+ addressObj.route = component.short_name
148
+ }
149
+ if (addressType === 'locality') {
150
+ addressObj.locality = component.long_name
151
+ }
152
+ if (component.types?.includes('sublocality')) {
153
+ addressObj.sublocality = component.long_name
154
+ }
155
+ if (addressType === 'country') {
156
+ addressObj.country = component.long_name
157
+ addressObj.country_code = component.short_name
158
+ }
159
+ if (addressType === 'administrative_area_level_1') {
160
+ addressObj.state = component.long_name
161
+ }
162
+ if (addressType === 'administrative_area_level_2') {
163
+ addressObj.city = component.long_name
140
164
  }
141
165
  }
142
166
  const address = {
143
167
  address: results[0].formatted_address,
144
- location: { lat: pos?.lat(), lng: pos?.lng() }
168
+ location: { lat: pos?.lat(), lng: pos?.lng() },
169
+ ...addressObj
145
170
  }
146
- if (zipcode) address.zipcode = zipcode
147
171
 
148
172
  handleChangeAddressMap && handleChangeAddressMap(address)
149
173
 
@@ -38,12 +38,37 @@ export const GpsButton = (props) => {
38
38
  geocoder.geocode({ location }, (results, status) => {
39
39
  setIsLoading(false)
40
40
  let postalCode = null
41
+ const addressObj = {}
41
42
  if (results?.[0]?.address_components) {
42
43
  for (const component of results[0].address_components) {
43
44
  const addressType = component.types[0]
44
45
  if (addressType === 'postal_code') {
45
46
  postalCode = component.short_name
46
- break
47
+ }
48
+ if (addressType === 'street_number') {
49
+ addressObj.street_number = component.long_name
50
+ }
51
+ if (addressType === 'neighborhood') {
52
+ addressObj.neighborhood = component.long_name
53
+ }
54
+ if (addressType === 'route') {
55
+ addressObj.route = component.short_name
56
+ }
57
+ if (addressType === 'locality') {
58
+ addressObj.locality = component.long_name
59
+ }
60
+ if (component.types?.includes('sublocality')) {
61
+ addressObj.sublocality = component.long_name
62
+ }
63
+ if (addressType === 'country') {
64
+ addressObj.country = component.long_name
65
+ addressObj.country_code = component.short_name
66
+ }
67
+ if (addressType === 'administrative_area_level_1') {
68
+ addressObj.state = component.long_name
69
+ }
70
+ if (addressType === 'administrative_area_level_2') {
71
+ addressObj.city = component.long_name
47
72
  }
48
73
  }
49
74
  if (status === 'OK') {
@@ -55,7 +80,8 @@ export const GpsButton = (props) => {
55
80
  map_data: {
56
81
  library: 'google',
57
82
  place_id: results[0].place_id
58
- }
83
+ },
84
+ ...addressObj
59
85
  })
60
86
  } else {
61
87
  onError && onError(t('ERROR_GPS_BUTTON', 'Error to get result with gps button'))