places-autocomplete-svelte 2.1.5 → 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 -2
- package/dist/interfaces.d.ts +2 -1
- 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',
|
|
@@ -161,8 +162,10 @@
|
|
|
161
162
|
* Initialize the Google Maps JavaScript API Loader.
|
|
162
163
|
*/
|
|
163
164
|
onMount(async (): Promise<void> => {
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
if(autofocus) {
|
|
166
|
+
// focus on the input
|
|
167
|
+
inputRef.focus();
|
|
168
|
+
}
|
|
166
169
|
|
|
167
170
|
// load the Google Maps API
|
|
168
171
|
try {
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -41,8 +41,9 @@ 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
|
+
classes?: ComponentClasses;
|
|
46
47
|
requestParams?: RequestParams;
|
|
47
48
|
onResponse: (e: Event) => void;
|
|
48
49
|
onError: (error: string) => void;
|
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",
|