@placekit/autocomplete-js
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -1,2 +0,2 @@ | ||
/*! @placekit/autocomplete-js v1.3.1 | © placekit.io | MIT license | https://github.com/placekit/autocomplete-js#readme */ | ||
/*! @placekit/autocomplete-js v1.4.0 | © placekit.io | MIT license | https://github.com/placekit/autocomplete-js#readme */ | ||
import type { PKOptions, PKResult } from '@placekit/client-js'; | ||
@@ -13,2 +13,3 @@ | ||
freeForm: boolean; | ||
geolocation: boolean; | ||
}; | ||
@@ -28,7 +29,6 @@ | ||
on(event: 'freeForm', handler?: PKAHandlers['freeForm']): PKAClient; | ||
on(event: 'geolocation', handler?: PKAHandlers['geolocation']): PKAClient; | ||
on(event: 'state', handler?: PKAHandlers['state']): PKAClient; | ||
on(event: 'geolocation', handler?: PKAHandlers['geolocation']): PKAClient; | ||
readonly handlers: Partial<PKAHandlers>; | ||
readonly state: PKAState; | ||
readonly hasGeolocation: boolean; | ||
requestGeolocation(opts?: Object, cancelUpdate?: boolean): Promise<GeolocationPosition>; | ||
@@ -47,7 +47,7 @@ open(): PKAClient; | ||
error: (error: Object) => void; | ||
dirty: (dirty: boolean) => void; | ||
empty: (empty: boolean) => void; | ||
freeForm: (freeForm: boolean) => void; | ||
dirty: (bool: boolean) => void; | ||
empty: (bool: boolean) => void; | ||
freeForm: (bool: boolean) => void; | ||
geolocation: (bool: boolean, position?: GeolocationPosition) => void; | ||
state: (state: PKAState) => void; | ||
geolocation: (hasGeolocation: boolean, position?: GeolocationPosition) => void; | ||
}; | ||
@@ -54,0 +54,0 @@ |
{ | ||
"name": "@placekit/autocomplete-js", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"author": "PlaceKit <support@placekit.io>", | ||
@@ -5,0 +5,0 @@ "description": "PlaceKit Autocomplete JavaScript library", |
@@ -49,4 +49,4 @@ <h1 align="center"> | ||
```html | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@placekit/autocomplete-js@1.3.0/dist/placekit-autocomplete.min.css" /> | ||
<script src="https://cdn.jsdelivr.net/npm/@placekit/autocomplete-js@1.3.0"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@placekit/autocomplete-js@1.3.1/dist/placekit-autocomplete.min.css" /> | ||
<script src="https://cdn.jsdelivr.net/npm/@placekit/autocomplete-js@1.3.1"></script> | ||
``` | ||
@@ -118,3 +118,2 @@ | ||
- [`pka.requestGeolocation()`](#pkarequestGeolocation) | ||
- [`pka.hasGeolocation`](#pkahasGeolocation) | ||
- [`pka.open()`](#pkaopen) | ||
@@ -142,2 +141,4 @@ - [`pka.close()`](#pkaclose) | ||
⚠️ `target` must be set when instanciating `placekitAutocomplete`, all other options can be set later with [`pka.configure()`](#pkaconfigure). | ||
### `pka.input` | ||
@@ -218,6 +219,9 @@ | ||
Updates search parameters (only JS client options!). Returns the instance so you can chain methods. | ||
Updates all parameters (**except `target`**). Returns the instance so you can chain methods. | ||
```js | ||
pka.configure({ | ||
className: 'my-suggestions', | ||
flip: true, | ||
formatValue: (item) => `${item.name} ${item.city}`, | ||
language: 'fr', | ||
@@ -237,3 +241,3 @@ maxResults: 5, | ||
```js | ||
console.log(pka.state); // {dirty: false, empty: false, freeForm: true} | ||
console.log(pka.state); // {dirty: false, empty: false, freeForm: true, geolocation: false} | ||
@@ -248,2 +252,5 @@ // `true` after the user modifies the input value. | ||
console.log(pka.state.freeForm); // true or false | ||
// `true` if device geolocation has been granted. | ||
console.log(pka.state.geolocation); // true or false | ||
``` | ||
@@ -263,7 +270,7 @@ | ||
.on('error', (error) => {}) | ||
.on('dirty', (dirty) => {}) | ||
.on('empty', (empty) => {}) | ||
.on('freeForm', (freeForm) => {}) | ||
.on('dirty', (bool) => {}) | ||
.on('empty', (bool) => {}) | ||
.on('freeForm', (bool) => {}) | ||
.on('geolocation', (bool, position) => {}); | ||
.on('state', (state) => {}) | ||
.on('geolocation', (hasGeolocation, position) => {}); | ||
``` | ||
@@ -339,18 +346,18 @@ | ||
##### `state` | ||
##### `geolocation` | ||
Triggered when one of the input states changes. | ||
Triggered when `state.geolocation` value changes (a.k.a. when `pka.requestGeolocation` is called). | ||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| `state` | `object` | The current input state. | | ||
| `geolocation` | `boolean` | `true` if granted, `false` if denied. | | ||
| `position` | [`GeolocationPosition \| undefined`](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPosition) | Passed when `geolocation` is `true`. | | ||
##### `geolocation` | ||
##### `state` | ||
Triggered when `hasGeolocation` value changes (a.k.a. when `pka.requestGeolocation` is called). | ||
Triggered when one of the input states changes. | ||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| `hasGeolocation` | `boolean` | `true` if granted, `false` if denied. | | ||
| `position` | [`GeolocationPosition`](https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPosition) | Passed when `hasGeolocation` is `true`. | | ||
| `state` | `object` | The current input state. | | ||
@@ -381,10 +388,2 @@ ### `pka.handlers` | ||
### `pka.hasGeolocation` | ||
Reads if device geolocation is activated or not (read-only). | ||
```js | ||
console.log(pka.hasGeolocation); // true or false | ||
``` | ||
### `pka.open()` | ||
@@ -391,0 +390,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
275317
6830
453