Skip to content

Commit

Permalink
v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mskocik committed Oct 29, 2021
1 parent cb8d054 commit a65b8c0
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 6,502 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ See the latest changes on the [Releases](https://github.com/mskocik/svelecte/rel
- lazy dropdown rendering
- usable as custom element
- stylable
- reordable multi selection with addition of `svelte-dnd-action` ([example](https://svelte.dev/repl/da2de4b9ed13465d892b678eba07ed99?version=3.44.0))


## 🔧 Installation
Expand All @@ -35,11 +36,32 @@ npm install svelecte --save
import Svelecte from 'svelecte';
const list = [{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2'}, ...];
let myValue = null;
</script>

<Svelecte options={list}></Svelecte>
<Svelecte options={list} bind:value={myValue}></Svelecte>
```

<details>
<summary><strong>💭 Note about <code>value</code> and <code>readSelection</strong></code> property</summary>
<div>
Since v3.0 inner logic behind these properties has changed. Now `value` property reflects inner selection. By default it
returns `valueField` property (if not defined, Svelecte tries to guess which property is representing value). This also means
that if you want to set new value, you need to assign to it correct value. Let's take the example above:

```
myValue = 2;
```
This would select item with `id` property `2`.

Sometimes you want to work strictly with objects, like `myValue = {id: 2, name: 'Item 2'}`. You can set property `valueAsObject` which tells Svelecte to handle `value` property as object or array of object (if `multiple` is also set).

Property `readSelection` _always_ returns selected object or object array no matter if `valueAsObject` is set or not.
</div>
</details>

---

## 👀 Examples

👉 Examples with more detailed documentation can be found at [https://mskocik.github.io/svelecte/](https://mskocik.github.io/svelecte/).
Expand Down Expand Up @@ -89,6 +111,7 @@ class | string | `svelecte-control` | default css class
style | string | `null` | inline style
hasAnchor | bool | `null` | `internal`: when passing also existing select (for CE)
i18n | object | `null` | I18n object overriding default settings
dndzone | function | empty | Pass `dndzone` from `svelte-dnd-action`, if you want to support selection reordering. See the [example REPL](https://svelte.dev/repl/da2de4b9ed13465d892b678eba07ed99?version=3.44.0)

### Emitted events:

Expand Down
2 changes: 1 addition & 1 deletion dist/svelecte-element.mjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/svelecte.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/svelecte.mjs

Large diffs are not rendered by default.

Loading

0 comments on commit a65b8c0

Please sign in to comment.