@dfds-ui/google-places 2.2.0-alpha.8b995955 → 2.2.0-alpha.e010e72f
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/AddressSelect.d.ts +1 -1
- package/AddressSelect.js +19 -11
- package/GooglePlaces.js +4 -4
- package/cjs/AddressSelect.d.ts +1 -1
- package/cjs/AddressSelect.js +58 -40
- package/cjs/GooglePlaces.js +25 -12
- package/cjs/index.js +4 -5
- package/package.json +6 -6
package/AddressSelect.d.ts
CHANGED
package/AddressSelect.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
var _excluded = ["name", "disabled", "error", "size", "types", "onFocus", "onBlur", "onChange", "location", "radius", "countries"];
|
|
3
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
4
|
-
function _regeneratorRuntime() { "use strict";
|
|
5
|
-
function
|
|
6
|
-
function
|
|
7
|
-
function
|
|
3
|
+
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); }
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
5
|
+
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
|
|
6
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) { r.unshift(t); } return function e() { for (; r.length;) { if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; } return e.done = !0, e; }; }
|
|
7
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
8
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
9
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
10
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
11
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
12
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
13
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
14
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
15
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
16
|
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."); }
|
|
9
|
-
function _unsupportedIterableToArray(
|
|
10
|
-
function _arrayLikeToArray(
|
|
17
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
18
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
|
|
11
19
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(
|
|
13
|
-
function _objectWithoutProperties(
|
|
14
|
-
function _objectWithoutPropertiesLoose(
|
|
20
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
21
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) { o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } } return i; }
|
|
22
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) { if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } } return t; }
|
|
15
23
|
import React, { useState } from 'react';
|
|
16
24
|
import { AsyncSearchableSelect } from '@dfds-ui/react-components';
|
|
17
25
|
import debounce from 'lodash.debounce';
|
|
@@ -47,7 +55,7 @@ var AddressSelect = function AddressSelect(_ref) {
|
|
|
47
55
|
available = _useAddressPrediction.available,
|
|
48
56
|
getPlacePredictions = _useAddressPrediction.getPlacePredictions;
|
|
49
57
|
var loadOptions = /*#__PURE__*/function () {
|
|
50
|
-
var _ref2 = _asyncToGenerator(
|
|
58
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(input, callback) {
|
|
51
59
|
var placePredictions, options;
|
|
52
60
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
53
61
|
while (1) {
|
package/GooglePlaces.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
function _slicedToArray(
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
2
|
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."); }
|
|
3
|
-
function _unsupportedIterableToArray(
|
|
4
|
-
function _arrayLikeToArray(
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
-
function _arrayWithHoles(
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
7
|
/// <reference types="@types/googlemaps" />
|
|
8
8
|
import React, { createContext, useState, useContext, useRef, useEffect } from 'react';
|
|
9
9
|
import { useScript } from '@dfds-ui/hooks';
|
package/cjs/AddressSelect.d.ts
CHANGED
package/cjs/AddressSelect.js
CHANGED
|
@@ -9,46 +9,64 @@ var _reactComponents = require("@dfds-ui/react-components");
|
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash.debounce"));
|
|
10
10
|
var _GooglePlaces = require("./GooglePlaces");
|
|
11
11
|
var _react2 = require("@emotion/react");
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!
|
|
15
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
location,
|
|
37
|
-
radius,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
setPredictions
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
12
|
+
const _excluded = ["name", "disabled", "error", "size", "types", "onFocus", "onBlur", "onChange", "location", "radius", "countries"];
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
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 asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
17
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
18
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
19
|
+
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."); }
|
|
20
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
21
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
22
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
23
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
24
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
25
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
26
|
+
const AddressSelect = _ref => {
|
|
27
|
+
let name = _ref.name,
|
|
28
|
+
disabled = _ref.disabled,
|
|
29
|
+
error = _ref.error,
|
|
30
|
+
_ref$size = _ref.size,
|
|
31
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
32
|
+
types = _ref.types,
|
|
33
|
+
onFocus = _ref.onFocus,
|
|
34
|
+
onBlur = _ref.onBlur,
|
|
35
|
+
onChange = _ref.onChange,
|
|
36
|
+
location = _ref.location,
|
|
37
|
+
radius = _ref.radius,
|
|
38
|
+
_ref$countries = _ref.countries,
|
|
39
|
+
countries = _ref$countries === void 0 ? [] : _ref$countries,
|
|
40
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
+
const _useState = (0, _react.useState)([]),
|
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
+
predictions = _useState2[0],
|
|
44
|
+
setPredictions = _useState2[1];
|
|
45
|
+
const _useAddressPrediction = (0, _GooglePlaces.useAddressPredictions)('', {
|
|
46
|
+
types,
|
|
47
|
+
location,
|
|
48
|
+
radius,
|
|
49
|
+
components: {
|
|
50
|
+
countries
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
53
|
+
available = _useAddressPrediction.available,
|
|
54
|
+
getPlacePredictions = _useAddressPrediction.getPlacePredictions;
|
|
55
|
+
const loadOptions = /*#__PURE__*/function () {
|
|
56
|
+
var _ref2 = _asyncToGenerator(function* (input, callback) {
|
|
57
|
+
const placePredictions = yield getPlacePredictions(input);
|
|
58
|
+
setPredictions(placePredictions);
|
|
59
|
+
const options = placePredictions.map(prediction => ({
|
|
60
|
+
value: prediction.description,
|
|
61
|
+
label: prediction.description,
|
|
62
|
+
prediction
|
|
63
|
+
}));
|
|
64
|
+
callback(options);
|
|
65
|
+
});
|
|
66
|
+
return function loadOptions(_x, _x2) {
|
|
67
|
+
return _ref2.apply(this, arguments);
|
|
68
|
+
};
|
|
69
|
+
}();
|
|
52
70
|
const handleChange = value => {
|
|
53
71
|
if (onChange) {
|
|
54
72
|
onChange(value, predictions);
|
package/cjs/GooglePlaces.js
CHANGED
|
@@ -7,10 +7,13 @@ exports.useGooglePlacesAPI = exports.useAddressPredictions = exports.GooglePlace
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _hooks = require("@dfds-ui/hooks");
|
|
9
9
|
var _react2 = require("@emotion/react");
|
|
10
|
-
function
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
+
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."); }
|
|
13
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /// <reference types="@types/googlemaps" />
|
|
14
17
|
const GooglePlacesAPIContext = /*#__PURE__*/(0, _react.createContext)({
|
|
15
18
|
available: false
|
|
16
19
|
});
|
|
@@ -21,11 +24,12 @@ const GooglePlacesAPIProvider = ({
|
|
|
21
24
|
language,
|
|
22
25
|
libraries = 'places'
|
|
23
26
|
}) => {
|
|
27
|
+
var _window, _window$google;
|
|
24
28
|
// On SSR window does not exist.
|
|
25
29
|
const hasWindow = typeof window !== 'undefined';
|
|
26
30
|
|
|
27
31
|
// We want to prevent the google maps api to be loaded more than once
|
|
28
|
-
const isGoogleMapsDefined = hasWindow && Boolean(window
|
|
32
|
+
const isGoogleMapsDefined = hasWindow && Boolean((_window = window) === null || _window === void 0 ? void 0 : (_window$google = _window.google) === null || _window$google === void 0 ? void 0 : _window$google.maps);
|
|
29
33
|
const languageParam = language ? `&language=${language}` : '';
|
|
30
34
|
// NOTE: Google Maps API requires a callback when ran asynchronously. See https://developers.google.com/maps/documentation/javascript/url-params#required_parameters
|
|
31
35
|
// Dummy callback to satisfy Google Maps API.
|
|
@@ -36,8 +40,14 @@ const GooglePlacesAPIProvider = ({
|
|
|
36
40
|
if (hasWindow) window.dummyCallback = dummyCallback;
|
|
37
41
|
const callback = hasWindow ? `&callback=dummyCallback` : '';
|
|
38
42
|
const scriptUrl = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${libraries}${languageParam}${callback}`;
|
|
39
|
-
const
|
|
40
|
-
|
|
43
|
+
const _useScript = (0, _hooks.useScript)(scriptUrl, isGoogleMapsDefined),
|
|
44
|
+
_useScript2 = _slicedToArray(_useScript, 2),
|
|
45
|
+
loaded = _useScript2[0],
|
|
46
|
+
error = _useScript2[1];
|
|
47
|
+
const _useState = (0, _react.useState)(false),
|
|
48
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
49
|
+
available = _useState2[0],
|
|
50
|
+
setAvailable = _useState2[1];
|
|
41
51
|
(0, _react.useEffect)(() => {
|
|
42
52
|
setAvailable(loaded && !error);
|
|
43
53
|
if (error) {
|
|
@@ -65,10 +75,12 @@ const useAddressPredictions = (input, {
|
|
|
65
75
|
radius,
|
|
66
76
|
components
|
|
67
77
|
}) => {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
const _useState3 = (0, _react.useState)([]),
|
|
79
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
80
|
+
predictions = _useState4[0],
|
|
81
|
+
setPredictions = _useState4[1];
|
|
82
|
+
const _useGooglePlacesAPI = useGooglePlacesAPI(),
|
|
83
|
+
available = _useGooglePlacesAPI.available;
|
|
72
84
|
const autocomplete = (0, _react.useRef)();
|
|
73
85
|
if (!autocomplete.current && available && typeof window !== 'undefined') {
|
|
74
86
|
autocomplete.current = new google.maps.places.AutocompleteService();
|
|
@@ -87,7 +99,8 @@ const useAddressPredictions = (input, {
|
|
|
87
99
|
country: components.countries
|
|
88
100
|
}
|
|
89
101
|
}, predictions => {
|
|
90
|
-
|
|
102
|
+
var _predictions;
|
|
103
|
+
predictions = (_predictions = predictions) !== null && _predictions !== void 0 ? _predictions : [];
|
|
91
104
|
setPredictions(predictions);
|
|
92
105
|
resolve(predictions);
|
|
93
106
|
});
|
package/cjs/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var _exportNames = {
|
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "AddressSelect", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () {
|
|
11
|
+
get: function get() {
|
|
12
12
|
return _AddressSelect.default;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
@@ -19,7 +19,7 @@ Object.keys(_GooglePlaces).forEach(function (key) {
|
|
|
19
19
|
if (key in exports && exports[key] === _GooglePlaces[key]) return;
|
|
20
20
|
Object.defineProperty(exports, key, {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () {
|
|
22
|
+
get: function get() {
|
|
23
23
|
return _GooglePlaces[key];
|
|
24
24
|
}
|
|
25
25
|
});
|
|
@@ -31,10 +31,9 @@ Object.keys(_AddressSelect).forEach(function (key) {
|
|
|
31
31
|
if (key in exports && exports[key] === _AddressSelect[key]) return;
|
|
32
32
|
Object.defineProperty(exports, key, {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () {
|
|
34
|
+
get: function get() {
|
|
35
35
|
return _AddressSelect[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
-
function
|
|
40
|
-
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; }
|
|
39
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Components using Google places",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
|
-
"version": "2.2.0-alpha.
|
|
6
|
+
"version": "2.2.0-alpha.e010e72f",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"main": "./cjs/index.js",
|
|
9
9
|
"module": "./index.js",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"react-dom": ">= 17.0.2"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@dfds-ui/colors": "2.2.0-alpha.
|
|
18
|
-
"@dfds-ui/hooks": "2.2.0-alpha.
|
|
19
|
-
"@dfds-ui/icons": "2.2.0-alpha.
|
|
20
|
-
"@dfds-ui/react-components": "2.2.0-alpha.
|
|
17
|
+
"@dfds-ui/colors": "2.2.0-alpha.e010e72f",
|
|
18
|
+
"@dfds-ui/hooks": "2.2.0-alpha.e010e72f",
|
|
19
|
+
"@dfds-ui/icons": "2.2.0-alpha.e010e72f",
|
|
20
|
+
"@dfds-ui/react-components": "2.2.0-alpha.e010e72f",
|
|
21
21
|
"@types/googlemaps": "3.43.3",
|
|
22
22
|
"@types/lodash.debounce": "^4.0.7",
|
|
23
23
|
"lodash.debounce": "^4.0.8"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "e010e72fc63a082f93fa8023dc3c751d4fbf2016",
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
}
|