@selfcommunity/react-core 0.7.0-mui7.33 → 0.7.0-react-17.0.1.7
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/lib/cjs/hooks/useSCGoogleApiLoader.d.ts +1 -4
- package/lib/cjs/hooks/useSCGoogleApiLoader.js +7 -6
- package/lib/cjs/utils/hooks/usePreviousValue.d.ts +1 -1
- package/lib/cjs/utils/hooks/usePreviousValue.js +1 -1
- package/lib/esm/hooks/useSCGoogleApiLoader.d.ts +1 -4
- package/lib/esm/hooks/useSCGoogleApiLoader.js +7 -6
- package/lib/esm/utils/hooks/usePreviousValue.d.ts +1 -1
- package/lib/esm/utils/hooks/usePreviousValue.js +1 -1
- package/lib/umd/0.js +2 -0
- package/lib/umd/0.js.LICENSE.txt +18 -0
- package/lib/umd/react-core.js +1 -1
- package/package.json +13 -13
- package/lib/umd/18.js +0 -2
- package/lib/umd/18.js.LICENSE.txt +0 -3
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
/// <reference types="google.maps" />
|
|
2
1
|
declare const useSCGoogleApiLoader: () => {
|
|
3
2
|
isLoaded: boolean;
|
|
4
|
-
|
|
3
|
+
loadError: Error;
|
|
5
4
|
geocodingApiKey: any;
|
|
6
|
-
libraries: string[];
|
|
7
|
-
placesLibrary: google.maps.PlacesLibrary;
|
|
8
5
|
};
|
|
9
6
|
export default useSCGoogleApiLoader;
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const api_1 = require("@react-google-maps/api");
|
|
6
6
|
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
7
7
|
const SCPreferences = tslib_1.__importStar(require("../constants/Preferences"));
|
|
8
|
+
const GOOGLE_MAPS_LIBRARIES = ['places', 'geocoding', 'maps'];
|
|
8
9
|
const useSCGoogleApiLoader = () => {
|
|
9
10
|
const { preferences } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
10
|
-
const isLoaded = (0, react_google_maps_1.useApiIsLoaded)();
|
|
11
|
-
const status = (0, react_google_maps_1.useApiLoadingStatus)();
|
|
12
|
-
const placesLibrary = (0, react_google_maps_1.useMapsLibrary)('places');
|
|
13
|
-
const libraries = ['places', 'geocoding', 'maps'];
|
|
14
11
|
const geocodingApiKey = (0, react_1.useMemo)(() => {
|
|
15
12
|
return preferences && SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY in preferences
|
|
16
13
|
? preferences[SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY].value
|
|
17
14
|
: null;
|
|
18
15
|
}, [preferences]);
|
|
19
|
-
|
|
16
|
+
const { isLoaded, loadError } = (0, api_1.useLoadScript)({
|
|
17
|
+
googleMapsApiKey: geocodingApiKey,
|
|
18
|
+
libraries: GOOGLE_MAPS_LIBRARIES,
|
|
19
|
+
});
|
|
20
|
+
return { isLoaded, loadError, geocodingApiKey };
|
|
20
21
|
};
|
|
21
22
|
exports.default = useSCGoogleApiLoader;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
/// <reference types="google.maps" />
|
|
2
1
|
declare const useSCGoogleApiLoader: () => {
|
|
3
2
|
isLoaded: boolean;
|
|
4
|
-
|
|
3
|
+
loadError: Error;
|
|
5
4
|
geocodingApiKey: any;
|
|
6
|
-
libraries: string[];
|
|
7
|
-
placesLibrary: google.maps.PlacesLibrary;
|
|
8
5
|
};
|
|
9
6
|
export default useSCGoogleApiLoader;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useLoadScript } from '@react-google-maps/api';
|
|
3
3
|
import { useSCPreferences } from '../components/provider/SCPreferencesProvider';
|
|
4
4
|
import * as SCPreferences from '../constants/Preferences';
|
|
5
|
+
const GOOGLE_MAPS_LIBRARIES = ['places', 'geocoding', 'maps'];
|
|
5
6
|
const useSCGoogleApiLoader = () => {
|
|
6
7
|
const { preferences } = useSCPreferences();
|
|
7
|
-
const isLoaded = useApiIsLoaded();
|
|
8
|
-
const status = useApiLoadingStatus();
|
|
9
|
-
const placesLibrary = useMapsLibrary('places');
|
|
10
|
-
const libraries = ['places', 'geocoding', 'maps'];
|
|
11
8
|
const geocodingApiKey = useMemo(() => {
|
|
12
9
|
return preferences && SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY in preferences
|
|
13
10
|
? preferences[SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY].value
|
|
14
11
|
: null;
|
|
15
12
|
}, [preferences]);
|
|
16
|
-
|
|
13
|
+
const { isLoaded, loadError } = useLoadScript({
|
|
14
|
+
googleMapsApiKey: geocodingApiKey,
|
|
15
|
+
libraries: GOOGLE_MAPS_LIBRARIES,
|
|
16
|
+
});
|
|
17
|
+
return { isLoaded, loadError, geocodingApiKey };
|
|
17
18
|
};
|
|
18
19
|
export default useSCGoogleApiLoader;
|