@dfds-ui/google-places 2.2.0-alpha.e010e72f → 2.2.0-alpha.eae7bbcd
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 +2 -2
- package/GooglePlaces.d.ts +1 -1
- package/cjs/AddressSelect.d.ts +2 -2
- package/cjs/AddressSelect.js +37 -56
- package/cjs/GooglePlaces.d.ts +1 -1
- package/cjs/GooglePlaces.js +11 -25
- package/cjs/index.js +4 -4
- package/package.json +9 -9
package/AddressSelect.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { ILocation, IPrediction } from './GooglePlaces';
|
|
3
3
|
export declare type AddressSelectProps = {
|
|
4
4
|
components?: any;
|
|
@@ -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/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/cjs/AddressSelect.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { ILocation, IPrediction } from './GooglePlaces';
|
|
3
3
|
export declare type AddressSelectProps = {
|
|
4
4
|
components?: any;
|
|
@@ -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/cjs/AddressSelect.js
CHANGED
|
@@ -9,64 +9,45 @@ 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
|
-
const _excluded = ["name", "disabled", "error", "size", "types", "onFocus", "onBlur", "onChange", "location", "radius", "countries"];
|
|
13
12
|
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
|
|
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); }
|
|
15
14
|
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
|
-
|
|
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
|
-
|
|
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
|
-
}();
|
|
15
|
+
const AddressSelect = ({
|
|
16
|
+
name,
|
|
17
|
+
disabled,
|
|
18
|
+
error,
|
|
19
|
+
size = 'medium',
|
|
20
|
+
types,
|
|
21
|
+
onFocus,
|
|
22
|
+
onBlur,
|
|
23
|
+
onChange,
|
|
24
|
+
location,
|
|
25
|
+
radius,
|
|
26
|
+
countries = [],
|
|
27
|
+
...rest
|
|
28
|
+
}) => {
|
|
29
|
+
const [predictions, setPredictions] = (0, _react.useState)([]);
|
|
30
|
+
const {
|
|
31
|
+
available,
|
|
32
|
+
getPlacePredictions
|
|
33
|
+
} = (0, _GooglePlaces.useAddressPredictions)('', {
|
|
34
|
+
types,
|
|
35
|
+
location,
|
|
36
|
+
radius,
|
|
37
|
+
components: {
|
|
38
|
+
countries
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const loadOptions = async (input, callback) => {
|
|
42
|
+
const placePredictions = await getPlacePredictions(input);
|
|
43
|
+
setPredictions(placePredictions);
|
|
44
|
+
const options = placePredictions.map(prediction => ({
|
|
45
|
+
value: prediction.description,
|
|
46
|
+
label: prediction.description,
|
|
47
|
+
prediction
|
|
48
|
+
}));
|
|
49
|
+
callback(options);
|
|
50
|
+
};
|
|
70
51
|
const handleChange = value => {
|
|
71
52
|
if (onChange) {
|
|
72
53
|
onChange(value, predictions);
|
package/cjs/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/cjs/GooglePlaces.js
CHANGED
|
@@ -7,13 +7,9 @@ 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 _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function
|
|
11
|
-
|
|
12
|
-
|
|
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" />
|
|
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
|
+
|
|
17
13
|
const GooglePlacesAPIContext = /*#__PURE__*/(0, _react.createContext)({
|
|
18
14
|
available: false
|
|
19
15
|
});
|
|
@@ -24,12 +20,11 @@ const GooglePlacesAPIProvider = ({
|
|
|
24
20
|
language,
|
|
25
21
|
libraries = 'places'
|
|
26
22
|
}) => {
|
|
27
|
-
var _window, _window$google;
|
|
28
23
|
// On SSR window does not exist.
|
|
29
24
|
const hasWindow = typeof window !== 'undefined';
|
|
30
25
|
|
|
31
26
|
// We want to prevent the google maps api to be loaded more than once
|
|
32
|
-
const isGoogleMapsDefined = hasWindow && Boolean(
|
|
27
|
+
const isGoogleMapsDefined = hasWindow && Boolean(window?.google?.maps);
|
|
33
28
|
const languageParam = language ? `&language=${language}` : '';
|
|
34
29
|
// NOTE: Google Maps API requires a callback when ran asynchronously. See https://developers.google.com/maps/documentation/javascript/url-params#required_parameters
|
|
35
30
|
// Dummy callback to satisfy Google Maps API.
|
|
@@ -40,14 +35,8 @@ const GooglePlacesAPIProvider = ({
|
|
|
40
35
|
if (hasWindow) window.dummyCallback = dummyCallback;
|
|
41
36
|
const callback = hasWindow ? `&callback=dummyCallback` : '';
|
|
42
37
|
const scriptUrl = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${libraries}${languageParam}${callback}`;
|
|
43
|
-
const
|
|
44
|
-
|
|
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];
|
|
38
|
+
const [loaded, error] = (0, _hooks.useScript)(scriptUrl, isGoogleMapsDefined);
|
|
39
|
+
const [available, setAvailable] = (0, _react.useState)(false);
|
|
51
40
|
(0, _react.useEffect)(() => {
|
|
52
41
|
setAvailable(loaded && !error);
|
|
53
42
|
if (error) {
|
|
@@ -75,12 +64,10 @@ const useAddressPredictions = (input, {
|
|
|
75
64
|
radius,
|
|
76
65
|
components
|
|
77
66
|
}) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const _useGooglePlacesAPI = useGooglePlacesAPI(),
|
|
83
|
-
available = _useGooglePlacesAPI.available;
|
|
67
|
+
const [predictions, setPredictions] = (0, _react.useState)([]);
|
|
68
|
+
const {
|
|
69
|
+
available
|
|
70
|
+
} = useGooglePlacesAPI();
|
|
84
71
|
const autocomplete = (0, _react.useRef)();
|
|
85
72
|
if (!autocomplete.current && available && typeof window !== 'undefined') {
|
|
86
73
|
autocomplete.current = new google.maps.places.AutocompleteService();
|
|
@@ -99,8 +86,7 @@ const useAddressPredictions = (input, {
|
|
|
99
86
|
country: components.countries
|
|
100
87
|
}
|
|
101
88
|
}, predictions => {
|
|
102
|
-
|
|
103
|
-
predictions = (_predictions = predictions) !== null && _predictions !== void 0 ? _predictions : [];
|
|
89
|
+
predictions = predictions ?? [];
|
|
104
90
|
setPredictions(predictions);
|
|
105
91
|
resolve(predictions);
|
|
106
92
|
});
|
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 () {
|
|
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 () {
|
|
23
23
|
return _GooglePlaces[key];
|
|
24
24
|
}
|
|
25
25
|
});
|
|
@@ -31,9 +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 () {
|
|
35
35
|
return _AddressSelect[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function
|
|
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.0-alpha.
|
|
6
|
+
"version": "2.2.0-alpha.eae7bbcd",
|
|
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": ">=
|
|
14
|
-
"react-dom": ">=
|
|
13
|
+
"react": ">= 18.3.1",
|
|
14
|
+
"react-dom": ">= 18.3.1"
|
|
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.eae7bbcd",
|
|
18
|
+
"@dfds-ui/hooks": "2.2.0-alpha.eae7bbcd",
|
|
19
|
+
"@dfds-ui/icons": "2.2.0-alpha.eae7bbcd",
|
|
20
|
+
"@dfds-ui/react-components": "2.2.0-alpha.eae7bbcd",
|
|
21
21
|
"@types/googlemaps": "3.43.3",
|
|
22
|
-
"@types/lodash.debounce": "^4.0.
|
|
22
|
+
"@types/lodash.debounce": "^4.0.9",
|
|
23
23
|
"lodash.debounce": "^4.0.8"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "eae7bbcd0c1bf58cb5af83776b44c10afde89654",
|
|
26
26
|
"publishConfig": {
|
|
27
27
|
"access": "public"
|
|
28
28
|
}
|