svelte-select
Advanced tools
Comparing version 1.2.0 to 1.3.0
16
index.js
@@ -953,4 +953,4 @@ (function (global, factory) { | ||
} | ||
function filteredItems({items, filterText, groupBy, groupFilter, getOptionLabel, isMulti, selectedValue, optionIdentifier}) { | ||
const filteredItems = items.filter(item => { | ||
function filteredItems({items, filterText, groupBy, groupFilter, getOptionLabel, isMulti, selectedValue, optionIdentifier, loadOptions}) { | ||
const filteredItems = loadOptions ? items : items.filter(item => { | ||
let keepItem = true; | ||
@@ -1014,5 +1014,6 @@ | ||
isSearchable: true, | ||
isDisabled: false, | ||
optionIdentifier: 'value', | ||
groupBy: undefined, | ||
getOptions: undefined, | ||
loadOptions: undefined, | ||
loadOptionsInterval: 200, | ||
@@ -1042,3 +1043,3 @@ noOptionsMessage: 'No options', | ||
handleKeyDown(e) { | ||
let {isFocused, listOpen, selectedValue, filterText, isMulti, activeSelectedValue} = this.get(); | ||
let {isFocused, listOpen, selectedValue, filterText, isMulti, activeSelectedValue, list} = this.get(); | ||
if (!isFocused) return; | ||
@@ -1065,3 +1066,5 @@ | ||
case 'ArrowLeft': | ||
if (list) list.set({ hoverItemIndex: -1}); | ||
if (!isMulti || filterText.length > 0) return; | ||
if (activeSelectedValue === undefined) { | ||
@@ -1075,2 +1078,3 @@ activeSelectedValue = selectedValue.length - 1; | ||
case 'ArrowRight': | ||
if (list) list.set({ hoverItemIndex: -1}); | ||
if (!isMulti || filterText.length > 0 || activeSelectedValue === undefined) return; | ||
@@ -1685,3 +1689,3 @@ if (activeSelectedValue === selectedValue.length - 1) { | ||
this._recompute({ isMulti: 1, isDisabled: 1, isFocused: 1, selectedValue: 1, filterText: 1, placeholder: 1, items: 1, groupBy: 1, groupFilter: 1, getOptionLabel: 1, optionIdentifier: 1 }, this._state); | ||
this._recompute({ isMulti: 1, isDisabled: 1, isFocused: 1, selectedValue: 1, filterText: 1, placeholder: 1, items: 1, groupBy: 1, groupFilter: 1, getOptionLabel: 1, optionIdentifier: 1, loadOptions: 1 }, this._state); | ||
this._intro = true; | ||
@@ -1728,3 +1732,3 @@ | ||
if (changed.items || changed.filterText || changed.groupBy || changed.groupFilter || changed.getOptionLabel || changed.isMulti || changed.selectedValue || changed.optionIdentifier) { | ||
if (changed.items || changed.filterText || changed.groupBy || changed.groupFilter || changed.getOptionLabel || changed.isMulti || changed.selectedValue || changed.optionIdentifier || changed.loadOptions) { | ||
if (this._differs(state.filteredItems, (state.filteredItems = filteredItems(state)))) changed.filteredItems = true; | ||
@@ -1731,0 +1735,0 @@ } |
{ | ||
"name": "svelte-select", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"repository": "https://bob-bea-fre@github.com/bob-bea-fre/svelte-select.git", | ||
@@ -5,0 +5,0 @@ "description": "A <Select> component for Svelte apps", |
@@ -36,26 +36,29 @@ # svelte-select ([demo](https://stackblitz.com/edit/svelte-rhbzxj)) | ||
</script> | ||
``` | ||
## API | ||
* `items` - array of items | ||
* `filterText` - text to filter list labels by | ||
* `placeholder` - placeholder text | ||
* `optionIdentifier` - Override default identifier ('value') | ||
* `listOpen` - open/close list | ||
* `containerStyles` - add/override container styles | ||
* `selectedValue` - Selected value(s) | ||
* `groupBy` - Function to group list items | ||
* `isClearable` - Defaults true set to false to disable clear all | ||
* `isDisabled` - Disable select | ||
* `isMulti` - Enable multi select | ||
* `isSearchable` - Defaults true set to false to disable search/filtering | ||
* `groupFilter` - Override default groupFilter function | ||
* `getOptionLabel` - Override default getOptionLabel function | ||
* `Item` - Override default item component | ||
* `Selection` - Override default selection component | ||
* `MultiSelection` - Override default multi selection component | ||
* `getOptions` - Methods that returns a Promise that updates items | ||
* `noOptionsMessage` - Message to display when there are no items | ||
| Prop | Type | Default | Description | | ||
|------|------|---------|-------------| | ||
| items | String | - | array of items | ||
| filterText | String | - | text to filter list labels by | ||
| placeholder | String | - | placeholder text | ||
| optionIdentifier | String | 'value' | override default identifier | ||
| listOpen | Boolean | false | open/close list | ||
| containerStyles | String | - | add/override container styles | ||
| selectedValue | - | - | Selected value(s) | ||
| groupBy | Function | - | Function to group list items | ||
| isClearable | Boolean | false | Disable clear all | ||
| isDisabled | Boolean | false | Disable select | ||
| isMulti | Boolean | false | Enable multi select | ||
| isSearchable | Boolean | true | Disable search/filtering | ||
| groupFilter | Function | (groups) => groups | group filter function | ||
| getOptionLabel | Function | (option) => option.label | get option label function | ||
| getSelectionLabel | Function | (option) => option.label | get selection label function | ||
| Item | Component | Item | item component | ||
| Selection | Component | Selection | selection component | ||
| MultiSelection | Component | MultiSelection | multi selection component | ||
| loadOptions | Promise | - | Method that returns a Promise that updates items | ||
| noOptionsMessage | String | 'No options' | Message to display when there are no items | ||
@@ -73,3 +76,2 @@ | ||
## Configuring webpack | ||
@@ -76,0 +78,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124632
2874
85