Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
updated docs and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 3, 2017
1 parent c294231 commit c511e9e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 0.2.0 - UNRELEASED
## 0.2.0 - 2017-07-03

### Added

Expand All @@ -18,7 +18,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

* Remove the `is-selected` class to the suggestions on refresh.


## 0.1.0 - 2017-06-25

First version with basic features
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ As you can see, the constructor of the class `Suggestions` needs two arguments:

* `DatalistSource`: Get the source from the `<datalist>` element associated to the input.
* `AjaxSource`: Get the source from an ajax request returning a json with the data.
* `Source`: To assign the data by yourself.

Example with ajax:

Expand All @@ -107,35 +106,14 @@ const suggestions = new Suggestions(
);
```

Example assigning the data directly:

```js
import {Suggestions, Source} from 'pw-suggestions';

const suggestions = new Suggestions(
document.getElementById('my-input'),
new Source([
{
label: 'Option 1',
value: 'option-1',
},{
label: 'Option 2',
value: 'option-2',
}
])
);
```

All sources have the following options:

Name | Type | Description
-----|------|------------
**parent** | `Node` | The parent node in which the suggestions are inserted in the DOM. By default is `document.body` unless `DatalistSource` that uses the parent element of the `<datalist>` element.
**suggestions.render** | `function` | A function to customize the html of each suggestion.
**suggestions.search** | `function` | A function to generate the text used to filter the result.
**suggestions.label** | `string` | The object key used to generate the label of the suggestion. By default is `label`.
**suggestions.value** | `string` | The object key used to generate the value of the suggestion. By default is `value`.
**group.render** | `function` | A function to customize the html of each group of suggestions.
**group.label** | `string` | The object key used to generate the label of the group of suggestion. By default is `label`.

Example:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pw-suggestions",
"version": "0.1.0",
"version": "0.2.0",
"description": "Javascript to provide autocomplete/suggestions in inputs",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c511e9e

Please sign in to comment.