places-autocomplete-svelte 2.1.4 → 2.1.6
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/README.md +11 -2
- package/dist/PlaceAutocomplete.svelte +5 -3
- package/dist/helpers.d.ts +1 -1
- package/dist/helpers.js +3 -0
- package/dist/interfaces.d.ts +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,9 +82,16 @@ const placeholder = 'Search...';
|
|
|
82
82
|
/**
|
|
83
83
|
* @type string optional
|
|
84
84
|
* The <input> HTML autocomplete attribute.
|
|
85
|
-
*
|
|
85
|
+
* default: 'off'
|
|
86
86
|
* */
|
|
87
87
|
const autocompete = 'off';
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @type boolean optional
|
|
91
|
+
* Boolean attribute indicating that an element should be focused on page load.
|
|
92
|
+
* default: false
|
|
93
|
+
* */
|
|
94
|
+
const autofocus = false;
|
|
88
95
|
/**
|
|
89
96
|
* @type object optional
|
|
90
97
|
* AutocompleteRequest properties
|
|
@@ -137,6 +144,7 @@ const fetchFields = ['formattedAddress', 'addressComponents'];
|
|
|
137
144
|
{requestParams}
|
|
138
145
|
{placeholder}
|
|
139
146
|
{autocompete}
|
|
147
|
+
{autofocus}
|
|
140
148
|
{fetchFields}
|
|
141
149
|
{classes}
|
|
142
150
|
/>
|
|
@@ -151,7 +159,8 @@ const fetchFields = ['formattedAddress', 'addressComponents'];
|
|
|
151
159
|
| `onResponse` | `CustomEvent` | Dispatched when a place is selected, containing the place details. | Yes | |
|
|
152
160
|
| `onError` | `CustomEvent` | Dispatched when an error occurs. | No | |
|
|
153
161
|
| `placeholder` | `String` | Placeholder text for the input field. | No | `"Search..."` |
|
|
154
|
-
| `autocomplete` | `string` | HTML `autocomplete` attribute for the input field. Set to "off" to disable browser autocomplete.
|
|
162
|
+
| `autocomplete` | `string` | HTML `autocomplete` attribute for the input field. Set to "off" to disable browser autocomplete.
|
|
163
|
+
| `autofocus` | `boolean` | The attribute indicating that an element should be focused on page load. | No | `false` |
|
|
155
164
|
| `requestParams` | `Object` | Object for additional request parameters (e.g., `types`, `bounds`). See [AutocompleteRequest](https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data#AutocompleteRequest). | No | `{}` |
|
|
156
165
|
| `fetchFields` | `Array` | Array of place data fields to return. See [Supported Fields](https://developers.google.com/maps/documentation/javascript/reference/places-service#PlaceResult) | No | `['formattedAddress', 'addressComponents']` |
|
|
157
166
|
| `classes` | `Object` | Object to override default Tailwind CSS classes applied to the component's elements (input, list, etc.). See the "Basic Usage" section for structure and default class names. | No | *Default Tailwind classes* |
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
fetchFields = $bindable(['formattedAddress', 'addressComponents']),
|
|
15
15
|
placeholder = 'Search...',
|
|
16
16
|
autocompete = 'off',
|
|
17
|
+
autofocus = false,
|
|
17
18
|
classes = {
|
|
18
19
|
section: '',
|
|
19
20
|
container: 'relative z-10 transform rounded-xl mt-4',
|
|
@@ -101,7 +102,6 @@
|
|
|
101
102
|
|
|
102
103
|
// set request input
|
|
103
104
|
request.input = target.value;
|
|
104
|
-
console.log(request);
|
|
105
105
|
|
|
106
106
|
// attempt to get autocomplete suggestions
|
|
107
107
|
try {
|
|
@@ -162,8 +162,10 @@
|
|
|
162
162
|
* Initialize the Google Maps JavaScript API Loader.
|
|
163
163
|
*/
|
|
164
164
|
onMount(async (): Promise<void> => {
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
if(autofocus) {
|
|
166
|
+
// focus on the input
|
|
167
|
+
inputRef.focus();
|
|
168
|
+
}
|
|
167
169
|
|
|
168
170
|
// load the Google Maps API
|
|
169
171
|
try {
|
package/dist/helpers.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export declare const requestParamsDefault: RequestParams;
|
|
|
4
4
|
* Validate and cast request parameters
|
|
5
5
|
* @param requestParams
|
|
6
6
|
*/
|
|
7
|
-
export declare const validateRequestParams: (requestParams: RequestParams) => RequestParams;
|
|
7
|
+
export declare const validateRequestParams: (requestParams: RequestParams | undefined) => RequestParams;
|
package/dist/helpers.js
CHANGED
package/dist/interfaces.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data
|
|
4
4
|
*/
|
|
5
5
|
export interface RequestParams {
|
|
6
|
-
input
|
|
6
|
+
input?: string;
|
|
7
7
|
includedPrimaryTypes?: string[];
|
|
8
8
|
includedRegionCodes?: string[];
|
|
9
9
|
inputOffset?: number;
|
|
@@ -41,9 +41,10 @@ export interface Props {
|
|
|
41
41
|
PUBLIC_GOOGLE_MAPS_API_KEY: string;
|
|
42
42
|
fetchFields?: string[];
|
|
43
43
|
placeholder?: string;
|
|
44
|
-
|
|
44
|
+
autofocus?: boolean;
|
|
45
45
|
autocompete?: AutoFill;
|
|
46
|
-
|
|
46
|
+
classes?: ComponentClasses;
|
|
47
|
+
requestParams?: RequestParams;
|
|
47
48
|
onResponse: (e: Event) => void;
|
|
48
49
|
onError: (error: string) => void;
|
|
49
50
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "places-autocomplete-svelte",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.6",
|
|
5
5
|
"description": "A lightweight and customizable Svelte component for easy integration of Google Maps Places (New) Autocomplete in your Svelte/SvelteKit applications. Provides accessible autocomplete suggestions and detailed address retrieval.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"svelte",
|