@dfds-ui/google-places 2.2.1 → 3.0.0-alpha.24ead756

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.
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { ILocation, IPrediction } from './GooglePlaces';
3
- export declare type AddressSelectProps = {
3
+ export type AddressSelectProps = {
4
4
  components?: any;
5
5
  name: string;
6
6
  disabled?: boolean;
@@ -25,5 +25,5 @@ export declare type AddressSelectProps = {
25
25
  */
26
26
  className?: string;
27
27
  };
28
- declare const AddressSelect: ({ name, disabled, error, size, types, onFocus, onBlur, onChange, location, radius, countries, ...rest }: AddressSelectProps) => JSX.Element;
28
+ declare const AddressSelect: ({ name, disabled, error, size, types, onFocus, onBlur, onChange, location, radius, countries, ...rest }: AddressSelectProps) => React.JSX.Element;
29
29
  export default AddressSelect;
package/AddressSelect.js CHANGED
@@ -1,22 +1,27 @@
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 (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) { if (n.call(e, o)) return next.value = e[o], next.done = !1, next; } return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) { r.push(n); } return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) { "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); } }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
7
+ 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); }
8
+ 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 }; })(); }
9
+ 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); }
10
+ 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); }
11
+ 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); }); }; }
12
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
13
  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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
11
- 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(arr) { if (Array.isArray(arr)) return arr; }
13
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
14
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
14
+ 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; } }
15
+ 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; }
16
+ 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; } }
17
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
18
+ 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; }
19
+ 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
20
  import React, { useState } from 'react';
16
21
  import { AsyncSearchableSelect } from '@dfds-ui/react-components';
17
22
  import debounce from 'lodash.debounce';
18
23
  import { useAddressPredictions } from './GooglePlaces';
19
- import { jsx as ___EmotionJSX } from "@emotion/react";
24
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
20
25
  var AddressSelect = function AddressSelect(_ref) {
21
26
  var name = _ref.name,
22
27
  disabled = _ref.disabled,
@@ -47,29 +52,26 @@ var AddressSelect = function AddressSelect(_ref) {
47
52
  available = _useAddressPrediction.available,
48
53
  getPlacePredictions = _useAddressPrediction.getPlacePredictions;
49
54
  var loadOptions = /*#__PURE__*/function () {
50
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input, callback) {
55
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input, callback) {
51
56
  var placePredictions, options;
52
- return _regeneratorRuntime().wrap(function _callee$(_context) {
53
- while (1) {
54
- switch (_context.prev = _context.next) {
55
- case 0:
56
- _context.next = 2;
57
- return getPlacePredictions(input);
58
- case 2:
59
- placePredictions = _context.sent;
60
- setPredictions(placePredictions);
61
- options = placePredictions.map(function (prediction) {
62
- return {
63
- value: prediction.description,
64
- label: prediction.description,
65
- prediction: prediction
66
- };
67
- });
68
- callback(options);
69
- case 6:
70
- case "end":
71
- return _context.stop();
72
- }
57
+ return _regenerator().w(function (_context) {
58
+ while (1) switch (_context.n) {
59
+ case 0:
60
+ _context.n = 1;
61
+ return getPlacePredictions(input);
62
+ case 1:
63
+ placePredictions = _context.v;
64
+ setPredictions(placePredictions);
65
+ options = placePredictions.map(function (prediction) {
66
+ return {
67
+ value: prediction.description,
68
+ label: prediction.description,
69
+ prediction: prediction
70
+ };
71
+ });
72
+ callback(options);
73
+ case 2:
74
+ return _context.a(2);
73
75
  }
74
76
  }, _callee);
75
77
  }));
@@ -82,7 +84,7 @@ var AddressSelect = function AddressSelect(_ref) {
82
84
  onChange(value, predictions);
83
85
  }
84
86
  };
85
- return ___EmotionJSX(AsyncSearchableSelect, _extends({
87
+ return _jsx(AsyncSearchableSelect, _objectSpread({
86
88
  disabled: disabled || !available,
87
89
  name: name,
88
90
  error: error,
package/GooglePlaces.d.ts CHANGED
@@ -42,7 +42,7 @@ export interface IGooglePlacesAPIProviderProps {
42
42
  language?: string;
43
43
  libraries?: string;
44
44
  }
45
- export declare const GooglePlacesAPIProvider: ({ children, apiKey, language, libraries, }: IGooglePlacesAPIProviderProps) => JSX.Element;
45
+ export declare const GooglePlacesAPIProvider: ({ children, apiKey, language, libraries, }: IGooglePlacesAPIProviderProps) => React.JSX.Element;
46
46
  export declare const useGooglePlacesAPI: () => {
47
47
  available: boolean;
48
48
  };
package/GooglePlaces.js CHANGED
@@ -1,18 +1,18 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
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(arr) { if (Array.isArray(arr)) return arr; }
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
+ 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(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';
10
- import { jsx as ___EmotionJSX } from "@emotion/react";
10
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
11
11
  export var GooglePlacesAPIContext = /*#__PURE__*/createContext({
12
12
  available: false
13
13
  });
14
14
  export var GooglePlacesAPIProvider = function GooglePlacesAPIProvider(_ref) {
15
- var _window, _window$google;
15
+ var _window;
16
16
  var children = _ref.children,
17
17
  apiKey = _ref.apiKey,
18
18
  language = _ref.language,
@@ -22,7 +22,7 @@ export var GooglePlacesAPIProvider = function GooglePlacesAPIProvider(_ref) {
22
22
  var hasWindow = typeof window !== 'undefined';
23
23
 
24
24
  // We want to prevent the google maps api to be loaded more than once
25
- var 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);
25
+ var isGoogleMapsDefined = hasWindow && Boolean((_window = window) === null || _window === void 0 || (_window = _window.google) === null || _window === void 0 ? void 0 : _window.maps);
26
26
  var languageParam = language ? "&language=".concat(language) : '';
27
27
  // NOTE: Google Maps API requires a callback when ran asynchronously. See https://developers.google.com/maps/documentation/javascript/url-params#required_parameters
28
28
  // Dummy callback to satisfy Google Maps API.
@@ -47,11 +47,12 @@ export var GooglePlacesAPIProvider = function GooglePlacesAPIProvider(_ref) {
47
47
  throw new Error('Google Places API script failed to load');
48
48
  }
49
49
  }, [loaded, error]);
50
- return ___EmotionJSX(GooglePlacesAPIContext.Provider, {
50
+ return _jsx(GooglePlacesAPIContext.Provider, {
51
51
  value: {
52
52
  available: available
53
- }
54
- }, children);
53
+ },
54
+ children: children
55
+ });
55
56
  };
56
57
  export var useGooglePlacesAPI = function useGooglePlacesAPI() {
57
58
  var context = useContext(GooglePlacesAPIContext);
@@ -71,7 +72,7 @@ export var useAddressPredictions = function useAddressPredictions(input, _ref2)
71
72
  setPredictions = _useState4[1];
72
73
  var _useGooglePlacesAPI = useGooglePlacesAPI(),
73
74
  available = _useGooglePlacesAPI.available;
74
- var autocomplete = useRef();
75
+ var autocomplete = useRef(undefined);
75
76
  if (!autocomplete.current && available && typeof window !== 'undefined') {
76
77
  autocomplete.current = new google.maps.places.AutocompleteService();
77
78
  }
@@ -93,8 +94,7 @@ export var useAddressPredictions = function useAddressPredictions(input, _ref2)
93
94
  country: components.countries
94
95
  }
95
96
  }, function (predictions) {
96
- var _predictions;
97
- predictions = (_predictions = predictions) !== null && _predictions !== void 0 ? _predictions : [];
97
+ predictions = predictions !== null && predictions !== void 0 ? predictions : [];
98
98
  setPredictions(predictions);
99
99
  resolve(predictions);
100
100
  });
@@ -104,7 +104,7 @@ export var useAddressPredictions = function useAddressPredictions(input, _ref2)
104
104
  if (input !== '') {
105
105
  void getPlacePredictions(input);
106
106
  }
107
- // eslint-disable-next-line react-hooks/exhaustive-deps
107
+ // eslint-disable-next-line @eslint-react/exhaustive-deps
108
108
  }, [input]);
109
109
  return {
110
110
  available: available,
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { ILocation, IPrediction } from './GooglePlaces';
3
- export declare type AddressSelectProps = {
3
+ export type AddressSelectProps = {
4
4
  components?: any;
5
5
  name: string;
6
6
  disabled?: boolean;
@@ -25,5 +25,5 @@ export declare type AddressSelectProps = {
25
25
  */
26
26
  className?: string;
27
27
  };
28
- declare const AddressSelect: ({ name, disabled, error, size, types, onFocus, onBlur, onChange, location, radius, countries, ...rest }: AddressSelectProps) => JSX.Element;
28
+ declare const AddressSelect: ({ name, disabled, error, size, types, onFocus, onBlur, onChange, location, radius, countries, ...rest }: AddressSelectProps) => React.JSX.Element;
29
29
  export default AddressSelect;
@@ -8,72 +8,51 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactComponents = require("@dfds-ui/react-components");
9
9
  var _lodash = _interopRequireDefault(require("lodash.debounce"));
10
10
  var _GooglePlaces = require("./GooglePlaces");
11
- var _react2 = require("@emotion/react");
12
- const _excluded = ["name", "disabled", "error", "size", "types", "onFocus", "onBlur", "onChange", "location", "radius", "countries"];
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- 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); }
15
- 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; }
16
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
18
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
19
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
20
- 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."); }
21
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
22
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
23
- 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; } }
24
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
26
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
27
- const AddressSelect = _ref => {
28
- let name = _ref.name,
29
- disabled = _ref.disabled,
30
- error = _ref.error,
31
- _ref$size = _ref.size,
32
- size = _ref$size === void 0 ? 'medium' : _ref$size,
33
- types = _ref.types,
34
- onFocus = _ref.onFocus,
35
- onBlur = _ref.onBlur,
36
- onChange = _ref.onChange,
37
- location = _ref.location,
38
- radius = _ref.radius,
39
- _ref$countries = _ref.countries,
40
- countries = _ref$countries === void 0 ? [] : _ref$countries,
41
- rest = _objectWithoutProperties(_ref, _excluded);
42
- const _useState = (0, _react.useState)([]),
43
- _useState2 = _slicedToArray(_useState, 2),
44
- predictions = _useState2[0],
45
- setPredictions = _useState2[1];
46
- const _useAddressPrediction = (0, _GooglePlaces.useAddressPredictions)('', {
47
- types,
48
- location,
49
- radius,
50
- components: {
51
- countries
52
- }
53
- }),
54
- available = _useAddressPrediction.available,
55
- getPlacePredictions = _useAddressPrediction.getPlacePredictions;
56
- const loadOptions = /*#__PURE__*/function () {
57
- var _ref2 = _asyncToGenerator(function* (input, callback) {
58
- const placePredictions = yield getPlacePredictions(input);
59
- setPredictions(placePredictions);
60
- const options = placePredictions.map(prediction => ({
61
- value: prediction.description,
62
- label: prediction.description,
63
- prediction
64
- }));
65
- callback(options);
66
- });
67
- return function loadOptions(_x, _x2) {
68
- return _ref2.apply(this, arguments);
69
- };
70
- }();
11
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (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); }
14
+ const AddressSelect = ({
15
+ name,
16
+ disabled,
17
+ error,
18
+ size = 'medium',
19
+ types,
20
+ onFocus,
21
+ onBlur,
22
+ onChange,
23
+ location,
24
+ radius,
25
+ countries = [],
26
+ ...rest
27
+ }) => {
28
+ const [predictions, setPredictions] = (0, _react.useState)([]);
29
+ const {
30
+ available,
31
+ getPlacePredictions
32
+ } = (0, _GooglePlaces.useAddressPredictions)('', {
33
+ types,
34
+ location,
35
+ radius,
36
+ components: {
37
+ countries
38
+ }
39
+ });
40
+ const loadOptions = async (input, callback) => {
41
+ const placePredictions = await getPlacePredictions(input);
42
+ setPredictions(placePredictions);
43
+ const options = placePredictions.map(prediction => ({
44
+ value: prediction.description,
45
+ label: prediction.description,
46
+ prediction
47
+ }));
48
+ callback(options);
49
+ };
71
50
  const handleChange = value => {
72
51
  if (onChange) {
73
52
  onChange(value, predictions);
74
53
  }
75
54
  };
76
- return (0, _react2.jsx)(_reactComponents.AsyncSearchableSelect, _extends({
55
+ return (0, _jsxRuntime.jsx)(_reactComponents.AsyncSearchableSelect, {
77
56
  disabled: disabled || !available,
78
57
  name: name,
79
58
  error: error,
@@ -81,8 +60,8 @@ const AddressSelect = _ref => {
81
60
  onChange: handleChange,
82
61
  loadOptions: (0, _lodash.default)(loadOptions, 500),
83
62
  onFocus: onFocus,
84
- onBlur: onBlur
85
- }, rest));
63
+ onBlur: onBlur,
64
+ ...rest
65
+ });
86
66
  };
87
- var _default = AddressSelect;
88
- exports.default = _default;
67
+ var _default = exports.default = AddressSelect;
@@ -42,7 +42,7 @@ export interface IGooglePlacesAPIProviderProps {
42
42
  language?: string;
43
43
  libraries?: string;
44
44
  }
45
- export declare const GooglePlacesAPIProvider: ({ children, apiKey, language, libraries, }: IGooglePlacesAPIProviderProps) => JSX.Element;
45
+ export declare const GooglePlacesAPIProvider: ({ children, apiKey, language, libraries, }: IGooglePlacesAPIProviderProps) => React.JSX.Element;
46
46
  export declare const useGooglePlacesAPI: () => {
47
47
  available: boolean;
48
48
  };
@@ -6,31 +6,24 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useGooglePlacesAPI = exports.useAddressPredictions = exports.GooglePlacesAPIProvider = exports.GooglePlacesAPIContext = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _hooks = require("@dfds-ui/hooks");
9
- var _react2 = require("@emotion/react");
10
- 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); }
11
- 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; }
12
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
- 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."); }
14
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16
- 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; } }
17
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /// <reference types="@types/googlemaps" />
18
- const GooglePlacesAPIContext = /*#__PURE__*/(0, _react.createContext)({
9
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (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
+ /// <reference types="@types/googlemaps" />
12
+
13
+ const GooglePlacesAPIContext = exports.GooglePlacesAPIContext = /*#__PURE__*/(0, _react.createContext)({
19
14
  available: false
20
15
  });
21
- exports.GooglePlacesAPIContext = GooglePlacesAPIContext;
22
16
  const GooglePlacesAPIProvider = ({
23
17
  children,
24
18
  apiKey,
25
19
  language,
26
20
  libraries = 'places'
27
21
  }) => {
28
- var _window, _window$google;
29
22
  // On SSR window does not exist.
30
23
  const hasWindow = typeof window !== 'undefined';
31
24
 
32
25
  // We want to prevent the google maps api to be loaded more than once
33
- 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);
26
+ const isGoogleMapsDefined = hasWindow && Boolean(window?.google?.maps);
34
27
  const languageParam = language ? `&language=${language}` : '';
35
28
  // NOTE: Google Maps API requires a callback when ran asynchronously. See https://developers.google.com/maps/documentation/javascript/url-params#required_parameters
36
29
  // Dummy callback to satisfy Google Maps API.
@@ -41,25 +34,20 @@ const GooglePlacesAPIProvider = ({
41
34
  if (hasWindow) window.dummyCallback = dummyCallback;
42
35
  const callback = hasWindow ? `&callback=dummyCallback` : '';
43
36
  const scriptUrl = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${libraries}${languageParam}${callback}`;
44
- const _useScript = (0, _hooks.useScript)(scriptUrl, isGoogleMapsDefined),
45
- _useScript2 = _slicedToArray(_useScript, 2),
46
- loaded = _useScript2[0],
47
- error = _useScript2[1];
48
- const _useState = (0, _react.useState)(false),
49
- _useState2 = _slicedToArray(_useState, 2),
50
- available = _useState2[0],
51
- setAvailable = _useState2[1];
37
+ const [loaded, error] = (0, _hooks.useScript)(scriptUrl, isGoogleMapsDefined);
38
+ const [available, setAvailable] = (0, _react.useState)(false);
52
39
  (0, _react.useEffect)(() => {
53
40
  setAvailable(loaded && !error);
54
41
  if (error) {
55
42
  throw new Error('Google Places API script failed to load');
56
43
  }
57
44
  }, [loaded, error]);
58
- return (0, _react2.jsx)(GooglePlacesAPIContext.Provider, {
45
+ return (0, _jsxRuntime.jsx)(GooglePlacesAPIContext.Provider, {
59
46
  value: {
60
47
  available
61
- }
62
- }, children);
48
+ },
49
+ children: children
50
+ });
63
51
  };
64
52
  exports.GooglePlacesAPIProvider = GooglePlacesAPIProvider;
65
53
  const useGooglePlacesAPI = () => {
@@ -76,13 +64,11 @@ const useAddressPredictions = (input, {
76
64
  radius,
77
65
  components
78
66
  }) => {
79
- const _useState3 = (0, _react.useState)([]),
80
- _useState4 = _slicedToArray(_useState3, 2),
81
- predictions = _useState4[0],
82
- setPredictions = _useState4[1];
83
- const _useGooglePlacesAPI = useGooglePlacesAPI(),
84
- available = _useGooglePlacesAPI.available;
85
- const autocomplete = (0, _react.useRef)();
67
+ const [predictions, setPredictions] = (0, _react.useState)([]);
68
+ const {
69
+ available
70
+ } = useGooglePlacesAPI();
71
+ const autocomplete = (0, _react.useRef)(undefined);
86
72
  if (!autocomplete.current && available && typeof window !== 'undefined') {
87
73
  autocomplete.current = new google.maps.places.AutocompleteService();
88
74
  }
@@ -100,8 +86,7 @@ const useAddressPredictions = (input, {
100
86
  country: components.countries
101
87
  }
102
88
  }, predictions => {
103
- var _predictions;
104
- predictions = (_predictions = predictions) !== null && _predictions !== void 0 ? _predictions : [];
89
+ predictions = predictions ?? [];
105
90
  setPredictions(predictions);
106
91
  resolve(predictions);
107
92
  });
@@ -111,7 +96,7 @@ const useAddressPredictions = (input, {
111
96
  if (input !== '') {
112
97
  void getPlacePredictions(input);
113
98
  }
114
- // eslint-disable-next-line react-hooks/exhaustive-deps
99
+ // eslint-disable-next-line @eslint-react/exhaustive-deps
115
100
  }, [input]);
116
101
  return {
117
102
  available,
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 get() {
11
+ get: function () {
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 get() {
22
+ get: function () {
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 get() {
34
+ get: function () {
35
35
  return _AddressSelect[key];
36
36
  }
37
37
  });
38
38
  });
39
- 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); }
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 (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,26 +3,26 @@
3
3
  "description": "Components using Google places",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "2.2.1",
6
+ "version": "3.0.0-alpha.24ead756",
7
7
  "sideEffects": false,
8
8
  "main": "./cjs/index.js",
9
9
  "module": "./index.js",
10
10
  "esnext": "./index.js",
11
11
  "typings": "./index.d.ts",
12
12
  "peerDependencies": {
13
- "react": ">= 17.0.2",
14
- "react-dom": ">= 17.0.2"
13
+ "react": ">= 19.0.0",
14
+ "react-dom": ">= 19.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@dfds-ui/colors": "2.2.1",
18
- "@dfds-ui/hooks": "2.2.1",
19
- "@dfds-ui/icons": "2.2.1",
20
- "@dfds-ui/react-components": "2.2.1",
17
+ "@dfds-ui/colors": "3.0.0-alpha.24ead756",
18
+ "@dfds-ui/hooks": "3.0.0-alpha.24ead756",
19
+ "@dfds-ui/icons": "3.0.0-alpha.24ead756",
20
+ "@dfds-ui/react-components": "3.0.0-alpha.24ead756",
21
21
  "@types/googlemaps": "3.43.3",
22
- "@types/lodash.debounce": "^4.0.7",
22
+ "@types/lodash.debounce": "^4.0.9",
23
23
  "lodash.debounce": "^4.0.8"
24
24
  },
25
- "gitHead": "ff968cd26c278c656e617042759efdea213c0661",
25
+ "gitHead": "24ead756072e49cc98e27ca4bbe679cc54eaf0ae",
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  }