@selfcommunity/react-ui 0.10.2-alpha.3 → 0.10.2-alpha.4

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.
@@ -6,7 +6,6 @@ const material_1 = require("@mui/material");
6
6
  const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
7
7
  const styles_1 = require("@mui/material/styles");
8
8
  const system_1 = require("@mui/system");
9
- const api_1 = require("@react-google-maps/api");
10
9
  const types_1 = require("@selfcommunity/types");
11
10
  const axios_1 = tslib_1.__importDefault(require("axios"));
12
11
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
@@ -48,18 +47,8 @@ function EventAddress(inProps) {
48
47
  const [inputValue, setInputValue] = (0, react_1.useState)('');
49
48
  const [suggestions, setSuggestions] = (0, react_1.useState)([]);
50
49
  const [timeoutId, setTimeoutId] = (0, react_1.useState)(null);
51
- // PREFERENCES
52
- const { preferences } = (0, react_core_1.useSCPreferences)();
53
- // MEMO
54
- const geocodingApiKey = (0, react_1.useMemo)(() => {
55
- return preferences && react_core_1.SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY in preferences
56
- ? preferences[react_core_1.SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY].value
57
- : null;
58
- }, [preferences]);
59
- const { isLoaded } = (0, api_1.useLoadScript)({
60
- googleMapsApiKey: geocodingApiKey,
61
- libraries: ['places', 'geocoding']
62
- });
50
+ // HOOKS
51
+ const { isLoaded, geocodingApiKey } = (0, react_core_1.useSCGoogleApiLoader)();
63
52
  // HANDLERS
64
53
  const handleChange = (_event, newValue) => {
65
54
  setLocation(newValue);
@@ -15,7 +15,6 @@ const string_1 = require("../../utils/string");
15
15
  const Widget_1 = tslib_1.__importDefault(require("../Widget"));
16
16
  const constants_1 = require("./constants");
17
17
  const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
18
- const react_1 = require("react");
19
18
  const classes = {
20
19
  root: `${constants_1.PREFIX}-root`,
21
20
  title: `${constants_1.PREFIX}-title`,
@@ -67,18 +66,8 @@ function EventLocationWidget(inProps) {
67
66
  const { className, event, eventId } = props, rest = tslib_1.__rest(props, ["className", "event", "eventId"]);
68
67
  // STATE
69
68
  const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
70
- // PREFERENCES
71
- const { preferences } = (0, react_core_1.useSCPreferences)();
72
- // MEMO
73
- const geocodingApiKey = (0, react_1.useMemo)(() => {
74
- return preferences && react_core_1.SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY in preferences
75
- ? preferences[react_core_1.SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY].value
76
- : null;
77
- }, [preferences]);
78
- const { isLoaded } = (0, api_1.useLoadScript)({
79
- googleMapsApiKey: geocodingApiKey,
80
- libraries: ['maps']
81
- });
69
+ // HOOKS
70
+ const { isLoaded, geocodingApiKey } = (0, react_core_1.useSCGoogleApiLoader)();
82
71
  const mapOptions = {
83
72
  fullscreenControl: false,
84
73
  mapTypeControl: false,
@@ -4,16 +4,15 @@ import { Autocomplete, Box, InputAdornment, Tab, Tabs, TextField } from '@mui/ma
4
4
  import Icon from '@mui/material/Icon';
5
5
  import { styled } from '@mui/material/styles';
6
6
  import { useThemeProps } from '@mui/system';
7
- import { useLoadScript } from '@react-google-maps/api';
8
7
  import { SCEventLocationType } from '@selfcommunity/types';
9
8
  import axios from 'axios';
10
9
  import classNames from 'classnames';
11
- import { useEffect, useMemo, useState } from 'react';
10
+ import { useEffect, useState } from 'react';
12
11
  import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
13
12
  import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
14
13
  import UrlTextField from '../../shared/UrlTextField';
15
14
  import { PREFIX } from './constants';
16
- import { SCPreferences, useSCPreferences } from '@selfcommunity/react-core';
15
+ import { useSCGoogleApiLoader } from '@selfcommunity/react-core';
17
16
  const messages = defineMessages({
18
17
  virtualPlaceholder: {
19
18
  id: 'ui.eventForm.address.online.placeholder',
@@ -46,18 +45,8 @@ export default function EventAddress(inProps) {
46
45
  const [inputValue, setInputValue] = useState('');
47
46
  const [suggestions, setSuggestions] = useState([]);
48
47
  const [timeoutId, setTimeoutId] = useState(null);
49
- // PREFERENCES
50
- const { preferences } = useSCPreferences();
51
- // MEMO
52
- const geocodingApiKey = useMemo(() => {
53
- return preferences && SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY in preferences
54
- ? preferences[SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY].value
55
- : null;
56
- }, [preferences]);
57
- const { isLoaded } = useLoadScript({
58
- googleMapsApiKey: geocodingApiKey,
59
- libraries: ['places', 'geocoding']
60
- });
48
+ // HOOKS
49
+ const { isLoaded, geocodingApiKey } = useSCGoogleApiLoader();
61
50
  // HANDLERS
62
51
  const handleChange = (_event, newValue) => {
63
52
  setLocation(newValue);
@@ -3,8 +3,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Box, CardContent, Typography } from '@mui/material';
4
4
  import { styled } from '@mui/material/styles';
5
5
  import { useThemeProps } from '@mui/system';
6
- import { GoogleMap, MarkerF, useLoadScript } from '@react-google-maps/api';
7
- import { SCPreferences, useSCFetchEvent, useSCPreferences } from '@selfcommunity/react-core';
6
+ import { GoogleMap, MarkerF } from '@react-google-maps/api';
7
+ import { useSCGoogleApiLoader, useSCFetchEvent } from '@selfcommunity/react-core';
8
8
  import { SCEventLocationType } from '@selfcommunity/types';
9
9
  import classNames from 'classnames';
10
10
  import { FormattedMessage } from 'react-intl';
@@ -13,7 +13,6 @@ import { formatEventLocationGeolocation } from '../../utils/string';
13
13
  import Widget from '../Widget';
14
14
  import { PREFIX } from './constants';
15
15
  import EventLocationWidgetSkeleton from './Skeleton';
16
- import { useMemo } from 'react';
17
16
  const classes = {
18
17
  root: `${PREFIX}-root`,
19
18
  title: `${PREFIX}-title`,
@@ -65,18 +64,8 @@ export default function EventLocationWidget(inProps) {
65
64
  const { className, event, eventId } = props, rest = __rest(props, ["className", "event", "eventId"]);
66
65
  // STATE
67
66
  const { scEvent } = useSCFetchEvent({ id: eventId, event });
68
- // PREFERENCES
69
- const { preferences } = useSCPreferences();
70
- // MEMO
71
- const geocodingApiKey = useMemo(() => {
72
- return preferences && SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY in preferences
73
- ? preferences[SCPreferences.PROVIDERS_GOOGLE_GEOCODING_API_KEY].value
74
- : null;
75
- }, [preferences]);
76
- const { isLoaded } = useLoadScript({
77
- googleMapsApiKey: geocodingApiKey,
78
- libraries: ['maps']
79
- });
67
+ // HOOKS
68
+ const { isLoaded, geocodingApiKey } = useSCGoogleApiLoader();
80
69
  const mapOptions = {
81
70
  fullscreenControl: false,
82
71
  mapTypeControl: false,