Skip to content

Commit 5ee89ce

Browse files
authored
docs: remove userInputAs prop reference (#115)
* docs: remove `userInputAs` prop reference The closing comment of #106 states that `userInputAs` prop will be not implemented
1 parent 3d7290f commit 5ee89ce

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

readme.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ import type { Option } from 'svelte-multiselect'
9797
allowUserOptions: boolean | 'append' = false
9898
```
9999

100-
Whether users are allowed to enter values not in the dropdown list. `true` means add user-defined options to the selected list only, `'append'` means add to both options and selected.
100+
Whether users can enter values that are not in the dropdown list. `true` means add user-defined options to the selected list only, `'append'` means add to both options and selected.
101+
If `allowUserOptions` is `true` or `'append'` then the type `object | number | string` of entered value is determined from the first option of the list to keep type homogeneity.
101102

102103
1. ```ts
103104
autocomplete: string = `off`
@@ -286,13 +287,6 @@ import type { Option } from 'svelte-multiselect'
286287

287288
Default behavior is to render selected items in the order they were chosen. `sortSelected={true}` uses default JS array sorting. A compare function enables custom logic for sorting selected options. See the [`/sort-selected`](https://svelte-multiselect.netlify.app/sort-selected) example.
288289

289-
1. ```ts
290-
userInputAs: 'string' | 'number' | 'object' =
291-
options.length > 0 ? (typeof options[0] as 'object' | 'string' | 'number') : 'string'
292-
```
293-
294-
What type new options created from user text input should be. Only relevant if `allowUserOptions=true | 'append'`. If not explicitly set, we default `userInputAs` to the type of the 1st option (if available, else `string`) to keep type homogeneity. E.g. if MultiSelect already contains at least one option and it's an object, new options from user-entered text will take the shape `{label: userText, value: userText}`. Likewise if the 1st existing option is a number of string. If MultiSelect starts out empty but you still want user-created custom options to be objects, pass `userInputAs='object'`.
295-
296290
## Slots
297291

298292
`MultiSelect.svelte` has 3 named slots:

0 commit comments

Comments
 (0)