places-autocomplete-js 1.1.0 → 1.1.1
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 +35 -10
- package/dist/places-autocomplete.js +294 -317
- package/dist/places-autocomplete.js.map +1 -1
- package/dist/places-autocomplete.umd.cjs +2 -2
- package/dist/places-autocomplete.umd.cjs.map +1 -1
- package/package.json +28 -12
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[](https://badge.fury.io/js/places-autocomplete-js)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
A flexible and customizable vanilla JavaScript library leveraging the [Google Maps Places (New) Autocomplete API](https://developers.google.com/maps/documentation/javascript/place-autocomplete-overview). This library provides a user-friendly way to search for and retrieve detailed address information in any web application.
|
|
6
|
+
A flexible and customizable vanilla JavaScript library for frontend web applications, leveraging the [Google Maps Places (New) Autocomplete API](https://developers.google.com/maps/documentation/javascript/place-autocomplete-overview). This library provides a user-friendly way to search for and retrieve detailed address and location information in any web application.
|
|
7
7
|
|
|
8
8
|
It handles API loading, session tokens for cost-effective usage, fetching suggestions with debouncing, keyboard navigation, highlighting matched text, and requesting place details, allowing you to focus on integrating the results into your application.
|
|
9
9
|
|
|
@@ -22,17 +22,22 @@ See a more comprehensive live demo of the library in action: [pacservice.pages.
|
|
|
22
22
|
|
|
23
23
|
## Features
|
|
24
24
|
|
|
25
|
-
*
|
|
26
|
-
* Automatically handles **session tokens**
|
|
27
|
-
* **Debounced Input
|
|
28
|
-
* **Suggestion Highlighting
|
|
29
|
-
* **
|
|
30
|
-
* **Event Handling:** Provides `onResponse` and `onError` callbacks.
|
|
31
|
-
* **Configurable:**
|
|
32
|
-
* **
|
|
33
|
-
|
|
25
|
+
* **Seamless Google Places Integration:** Directly connects with the modern **Google Places (New) Autocomplete API** for accurate and up-to-date address suggestions.
|
|
26
|
+
* **Cost-Effective API Usage:** Automatically handles **session tokens** to optimize your Google Maps API costs per Google's guidelines.
|
|
27
|
+
* **Optimized User Experience:** Implements **Debounced Input** to limit API calls while the user is typing, ensuring a smooth and responsive search experience.
|
|
28
|
+
* **Enhanced Readability:** Provides **Suggestion Highlighting** to automatically bold the portion of text matching the user's input, making suggestions easier to scan.
|
|
29
|
+
* **Flexible Styling:** Offers **Customizable Styling** allowing you to easily override default styles or apply your own using CSS classes. Built with sensible defaults (Tailwind CSS utility classes by default but can be entirely replaced).
|
|
30
|
+
* **Robust Event Handling:** Provides `onResponse` and `onError` callbacks for comprehensive control over successful place selections and error scenarios.
|
|
31
|
+
* **Highly Configurable:** Allows you to control API parameters (`requestParams`) and component behavior/appearance (`options`) to fit your specific application needs.
|
|
32
|
+
* **Efficient API Loading:** Dynamically loads the Google Maps API script on demand, reducing initial page load times.
|
|
34
33
|
|
|
34
|
+
## Benefits
|
|
35
35
|
|
|
36
|
+
* **Accelerate Development:** Quickly integrate powerful address autocomplete functionality into your web application with minimal setup.
|
|
37
|
+
* **Improve User Experience:** Provide a fast, intuitive, and accurate address entry experience for your users.
|
|
38
|
+
* **Reduce API Costs:** Leverage automatic session token management to optimize your Google Maps API billing.
|
|
39
|
+
* **Maintain Brand Consistency:** Easily customize the look and feel of the autocomplete component to match your application's design system.
|
|
40
|
+
* **Future-Proof:** Built on the latest Google Places (New) Autocomplete API, ensuring compatibility and access to new features.
|
|
36
41
|
|
|
37
42
|
## Requirements
|
|
38
43
|
|
|
@@ -330,6 +335,26 @@ Instances of `PlacesAutocomplete` have the following public methods:
|
|
|
330
335
|
* The library uses **Session Tokens** automatically to group Autocomplete requests, which can lead to significant cost savings compared to per-request billing. See [Google's Session Token Pricing](https://developers.google.com/maps/documentation/places/web-service/usage-and-billing#session-pricing).
|
|
331
336
|
* Place Details requests (made when a suggestion is selected to get `displayName`, `formattedAddress`, etc.) are billed separately. The library currently fetches `displayName`, `formattedAddress`, and `addressComponents` by default. This can be expanded if needed, but be mindful of [Place Data Fields Pricing](https://developers.google.com/maps/documentation/javascript/usage-and-billing#data-pricing).
|
|
332
337
|
|
|
338
|
+
## Testing
|
|
339
|
+
|
|
340
|
+
This project includes both unit tests (using Vitest) and end-to-end tests (using Playwright).
|
|
341
|
+
|
|
342
|
+
### Unit Tests
|
|
343
|
+
|
|
344
|
+
Unit tests are located in the `tests/` directory and are run using Vitest. To execute the unit tests, use the following command:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
npm run test:vitest
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### End-to-End Tests
|
|
351
|
+
|
|
352
|
+
End-to-end tests are located in the `e2e/` directory and are run using Playwright. To execute the end-to-end tests, ensure your development server is running (e.g., `npm run dev`) and then use the following command:
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
npm run test:e2e
|
|
356
|
+
```
|
|
357
|
+
|
|
333
358
|
## Contributing
|
|
334
359
|
|
|
335
360
|
Contributions are welcome! Please feel free to open an issue or submit a pull request.
|