@arkyn/components 3.0.1-beta.100 → 3.0.1-beta.102
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/dist/bundle.js +1505 -1488
- package/dist/bundle.umd.cjs +17 -17
- package/dist/components/searchPlaces.d.ts +9 -8
- package/dist/components/searchPlaces.d.ts.map +1 -1
- package/dist/components/searchPlaces.js +24 -9
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { StandaloneSearchBoxProps } from "@react-google-maps/api";
|
|
2
|
+
import { JSX } from "react";
|
|
2
3
|
import { InputProps } from "./input";
|
|
3
4
|
/**
|
|
4
5
|
* Props for the SearchPlaces component.
|
|
@@ -8,14 +9,14 @@ import { InputProps } from "./input";
|
|
|
8
9
|
* @property {(place: PlaceData) => void} [onPlaceChanged] - Callback fired when a place is selected from the autocomplete suggestions
|
|
9
10
|
*/
|
|
10
11
|
type SearchPlacesProps = {
|
|
11
|
-
options?:
|
|
12
|
+
options?: StandaloneSearchBoxProps["options"];
|
|
12
13
|
onChange?: (e: string) => void;
|
|
13
14
|
onPlaceChanged?: (e: {
|
|
14
15
|
street: string;
|
|
15
16
|
city: string;
|
|
16
17
|
state: string;
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
neighborhood: string;
|
|
19
|
+
postalCode: string;
|
|
19
20
|
stateShortName: string;
|
|
20
21
|
streetNumber: string;
|
|
21
22
|
coordinates: {
|
|
@@ -29,7 +30,7 @@ type SearchPlacesProps = {
|
|
|
29
30
|
*
|
|
30
31
|
* This component integrates with Google Maps API to provide address autocomplete functionality.
|
|
31
32
|
* When a user selects a place from the suggestions, it extracts and returns structured address data
|
|
32
|
-
* including street, city, state,
|
|
33
|
+
* including street, city, state, neighborhood, postal code, and geographic coordinates.
|
|
33
34
|
*
|
|
34
35
|
* @component
|
|
35
36
|
* @example
|
|
@@ -43,8 +44,8 @@ type SearchPlacesProps = {
|
|
|
43
44
|
* // street: "Rua exemplo",
|
|
44
45
|
* // city: "São Paulo",
|
|
45
46
|
* // state: "São Paulo",
|
|
46
|
-
* //
|
|
47
|
-
* //
|
|
47
|
+
* // neighborhood: "Centro",
|
|
48
|
+
* // postalCode: "01310-100",
|
|
48
49
|
* // stateShortName: "SP",
|
|
49
50
|
* // streetNumber: "123",
|
|
50
51
|
* // coordinates: { lat: -23.5505, lng: -46.6333 }
|
|
@@ -65,6 +66,6 @@ type SearchPlacesProps = {
|
|
|
65
66
|
* @requires Google Maps JavaScript API with Places library loaded
|
|
66
67
|
* @requires @react-google-maps/api package
|
|
67
68
|
*/
|
|
68
|
-
declare function SearchPlaces(props: SearchPlacesProps):
|
|
69
|
+
declare function SearchPlaces(props: SearchPlacesProps): JSX.Element;
|
|
69
70
|
export { SearchPlaces };
|
|
70
71
|
//# sourceMappingURL=searchPlaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchPlaces.d.ts","sourceRoot":"","sources":["../../src/components/searchPlaces.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"searchPlaces.d.ts","sourceRoot":"","sources":["../../src/components/searchPlaces.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAE,GAAG,EAAY,MAAM,OAAO,CAAC;AACtC,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAY5C;;;;;;GAMG;AACH,KAAK,iBAAiB,GAAG;IACvB,OAAO,CAAC,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAC9C,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;KAC3C,KAAK,IAAI,CAAC;CACZ,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAmF3D;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { StandaloneSearchBox } from "@react-google-maps/api";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { Input } from "./input";
|
|
5
5
|
/**
|
|
@@ -7,7 +7,7 @@ import { Input } from "./input";
|
|
|
7
7
|
*
|
|
8
8
|
* This component integrates with Google Maps API to provide address autocomplete functionality.
|
|
9
9
|
* When a user selects a place from the suggestions, it extracts and returns structured address data
|
|
10
|
-
* including street, city, state,
|
|
10
|
+
* including street, city, state, neighborhood, postal code, and geographic coordinates.
|
|
11
11
|
*
|
|
12
12
|
* @component
|
|
13
13
|
* @example
|
|
@@ -21,8 +21,8 @@ import { Input } from "./input";
|
|
|
21
21
|
* // street: "Rua exemplo",
|
|
22
22
|
* // city: "São Paulo",
|
|
23
23
|
* // state: "São Paulo",
|
|
24
|
-
* //
|
|
25
|
-
* //
|
|
24
|
+
* // neighborhood: "Centro",
|
|
25
|
+
* // postalCode: "01310-100",
|
|
26
26
|
* // stateShortName: "SP",
|
|
27
27
|
* // streetNumber: "123",
|
|
28
28
|
* // coordinates: { lat: -23.5505, lng: -46.6333 }
|
|
@@ -63,22 +63,37 @@ function SearchPlaces(props) {
|
|
|
63
63
|
return data.short_name;
|
|
64
64
|
return "";
|
|
65
65
|
}
|
|
66
|
+
function findDataByMultipleTypes(keys) {
|
|
67
|
+
for (const key of keys) {
|
|
68
|
+
const data = address_components.find((item) => item.types.includes(key));
|
|
69
|
+
if (data)
|
|
70
|
+
return data.long_name;
|
|
71
|
+
}
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
66
74
|
if (place) {
|
|
67
75
|
const street = findData("route");
|
|
68
76
|
const streetNumber = findData("street_number");
|
|
69
|
-
const
|
|
77
|
+
const neighborhood = findDataByMultipleTypes([
|
|
78
|
+
"sublocality_level_1",
|
|
79
|
+
"sublocality",
|
|
80
|
+
"neighborhood",
|
|
81
|
+
]);
|
|
70
82
|
const city = findData("administrative_area_level_2");
|
|
71
83
|
const state = findData("administrative_area_level_1");
|
|
72
84
|
const stateShortName = findDataShort("administrative_area_level_1");
|
|
73
|
-
const
|
|
85
|
+
const postalCode = findDataByMultipleTypes([
|
|
86
|
+
"postal_code",
|
|
87
|
+
"postal_code_prefix",
|
|
88
|
+
]);
|
|
74
89
|
const lat = place.geometry?.location?.lat();
|
|
75
90
|
const lng = place.geometry?.location?.lng();
|
|
76
91
|
const sendPlace = {
|
|
77
92
|
street,
|
|
78
93
|
city,
|
|
79
94
|
state,
|
|
80
|
-
|
|
81
|
-
|
|
95
|
+
neighborhood,
|
|
96
|
+
postalCode,
|
|
82
97
|
streetNumber,
|
|
83
98
|
stateShortName,
|
|
84
99
|
coordinates: { lat, lng },
|
|
@@ -86,6 +101,6 @@ function SearchPlaces(props) {
|
|
|
86
101
|
onPlaceChanged && onPlaceChanged(sendPlace);
|
|
87
102
|
}
|
|
88
103
|
};
|
|
89
|
-
return (_jsx(
|
|
104
|
+
return (_jsx(StandaloneSearchBox, { onLoad: handleLoad, onPlacesChanged: handlePlacesChanged, options: options, children: _jsx(Input, { type: "text", autoComplete: "off", onChange: (e) => onChange && onChange(e.target.value), ...rest }) }));
|
|
90
105
|
}
|
|
91
106
|
export { SearchPlaces };
|