@popsure/dirty-swan 0.54.13 → 0.54.14

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,4 +1,4 @@
1
- import { Address } from '@popsure/public-models';
1
+ import { Address, Alpha2CountryCode } from '@popsure/public-models';
2
2
  export interface AutocompleteAddressProps {
3
3
  apiKey: string;
4
4
  address?: Partial<Address>;
@@ -32,6 +32,7 @@ export interface AutocompleteAddressProps {
32
32
  preText?: string;
33
33
  cta?: string;
34
34
  };
35
+ countryCode: Alpha2CountryCode;
35
36
  }
36
- declare const AutocompleteAddress: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, inputProps, }: AutocompleteAddressProps) => JSX.Element;
37
+ declare const AutocompleteAddress: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, inputProps, countryCode }: AutocompleteAddressProps) => JSX.Element;
37
38
  export { AutocompleteAddress };
@@ -1,7 +1,7 @@
1
1
  import { AutocompleteAddressProps } from '.';
2
2
  declare const story: {
3
3
  title: string;
4
- component: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, inputProps, }: AutocompleteAddressProps) => JSX.Element;
4
+ component: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, inputProps, countryCode }: AutocompleteAddressProps) => JSX.Element;
5
5
  argTypes: {
6
6
  address: {
7
7
  description: string;
@@ -79,19 +79,19 @@ var loadGoogleMapsApiDynamically = function (callback, apiKey) {
79
79
  };
80
80
  var AutocompleteAddress = function (_a) {
81
81
  var _b;
82
- var apiKey = _a.apiKey, initialAddress = _a.address, onAddressChange = _a.onAddressChange, placeholders = _a.placeholders, manualAddressEntryTexts = _a.manualAddressEntryTexts, inputProps = _a.inputProps;
83
- var _c = useState(false), manualAddressEntry = _c[0], setManualAddressEntry = _c[1];
84
- var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
82
+ var apiKey = _a.apiKey, initialAddress = _a.address, onAddressChange = _a.onAddressChange, placeholders = _a.placeholders, manualAddressEntryTexts = _a.manualAddressEntryTexts, inputProps = _a.inputProps, _c = _a.countryCode, countryCode = _c === void 0 ? GERMANY_ALPHA_CODE : _c;
83
+ var _d = useState(false), manualAddressEntry = _d[0], setManualAddressEntry = _d[1];
84
+ var _e = useState(false), isLoading = _e[0], setIsLoading = _e[1];
85
85
  var autocomplete = useRef(null);
86
86
  var autocompleteElement = useRef(null);
87
87
  var map = useRef(null);
88
88
  var marker = useRef(null);
89
- var _e = useState(initialAddress), address = _e[0], setAddress = _e[1];
90
- var _f = useState(window.google !== undefined), hasLoadedGoogleAPI = _f[0], setHasLoadedGoogleAPI = _f[1];
89
+ var _f = useState(initialAddress), address = _f[0], setAddress = _f[1];
90
+ var _g = useState(window.google !== undefined), hasLoadedGoogleAPI = _g[0], setHasLoadedGoogleAPI = _g[1];
91
91
  loadGoogleMapsApiDynamically(function () {
92
92
  setHasLoadedGoogleAPI(true);
93
93
  }, apiKey);
94
- var _g = useState(null), place = _g[0], setPlace = _g[1];
94
+ var _h = useState(null), place = _h[0], setPlace = _h[1];
95
95
  useEffect(function () {
96
96
  if (address) {
97
97
  if (autocompleteElement.current && address.street) {
@@ -107,7 +107,7 @@ var AutocompleteAddress = function (_a) {
107
107
  var reference = document.getElementById('autocomplete');
108
108
  autocomplete.current = new google.maps.places.Autocomplete(reference, {
109
109
  types: ['address'],
110
- componentRestrictions: { country: GERMANY_ALPHA_CODE },
110
+ componentRestrictions: { country: countryCode },
111
111
  });
112
112
  autocomplete.current.addListener('place_changed', onPlaceChanged);
113
113
  map.current = new google.maps.Map(document.getElementById('map'), MAP_CONFIG_OBJ);
@@ -171,7 +171,7 @@ var AutocompleteAddress = function (_a) {
171
171
  var _b = _a === void 0 ? { updatePlace: true } : _a, updatePlace = _b.updatePlace;
172
172
  return function (e) {
173
173
  var _a;
174
- var newAddress = __assign(__assign({}, address), (_a = {}, _a[e.target.name] = e.target.value, _a.country = GERMANY_ALPHA_CODE, _a));
174
+ var newAddress = __assign(__assign({}, address), (_a = {}, _a[e.target.name] = e.target.value, _a.country = countryCode, _a));
175
175
  setAddress(newAddress);
176
176
  onAddressChange(newAddress);
177
177
  if (updatePlace) {