mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
Merge branch 'master' into mixins
# Conflicts: # src/components/Select.vue # src/mixins/pointerScroll.js
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
- Supports Vuex
|
- Supports Vuex
|
||||||
- Select Single/Multiple Options
|
- Select Single/Multiple Options
|
||||||
- Bootstrap Friendly Markup
|
- Bootstrap Friendly Markup
|
||||||
- +90% Test Coverage
|
- +95% Test Coverage
|
||||||
|
|
||||||
#### Upcoming/In Progress
|
#### Upcoming/In Progress
|
||||||
|
|
||||||
@@ -18,12 +18,13 @@
|
|||||||
- Rich Option Templating
|
- Rich Option Templating
|
||||||
- Asyncronous Option Loading
|
- Asyncronous Option Loading
|
||||||
|
|
||||||
## Demo
|
## Live Examples & Docs
|
||||||
[http://sagalbot.github.io/vue-select/](http://sagalbot.github.io/vue-select/)
|
[http://sagalbot.github.io/vue-select/](http://sagalbot.github.io/vue-select/)
|
||||||
|
|
||||||
## Install / Usage
|
## Install / Usage
|
||||||
|
vue-select is now published on npm, **huge thanks to [@onefriendaday](https://github.com/onefriendaday)** for changing ownership of [his package](https://github.com/onefriendaday/vue-select).
|
||||||
``` bash
|
``` bash
|
||||||
$ npm install sagalbot/vue-select
|
$ npm install vue-select
|
||||||
```
|
```
|
||||||
|
|
||||||
```html
|
```html
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-select",
|
"name": "vue-select",
|
||||||
"version": "1.1.1",
|
"version": "1.1.4",
|
||||||
"description": "A Vue.js project",
|
"description": "A Vue.js project",
|
||||||
"author": "Jeff Sagal <sagalbot@gmail.com>",
|
"author": "Jeff Sagal <sagalbot@gmail.com>",
|
||||||
"private": false,
|
"private": false,
|
||||||
|
|||||||
+20
-18
@@ -138,8 +138,8 @@
|
|||||||
v-model="search"
|
v-model="search"
|
||||||
@keydown.delete="maybeDeleteValue"
|
@keydown.delete="maybeDeleteValue"
|
||||||
@keyup.esc="onEscape"
|
@keyup.esc="onEscape"
|
||||||
@keyup.up.prevent="typeAheadUp"
|
@keydown.up.prevent="typeAheadUp"
|
||||||
@keyup.down.prevent="typeAheadDown"
|
@keydown.down.prevent="typeAheadDown"
|
||||||
@keyup.enter.prevent="typeAheadSelect"
|
@keyup.enter.prevent="typeAheadSelect"
|
||||||
@blur="open = false"
|
@blur="open = false"
|
||||||
@focus="open = true"
|
@focus="open = true"
|
||||||
@@ -265,6 +265,24 @@
|
|||||||
default: 'label'
|
default: 'label'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback to generate the label text. If {option}
|
||||||
|
* is an object, returns option[this.label] by default.
|
||||||
|
* @param {Object || String} option
|
||||||
|
* @return {String}
|
||||||
|
*/
|
||||||
|
getOptionLabel: {
|
||||||
|
type: Function,
|
||||||
|
default(option) {
|
||||||
|
if( typeof option === 'object' ) {
|
||||||
|
if( this.label && option[this.label] ) {
|
||||||
|
return option[this.label]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional callback function that is called each time the selected
|
* An optional callback function that is called each time the selected
|
||||||
* value(s) change. When integrating with Vuex, use this callback to trigger
|
* value(s) change. When integrating with Vuex, use this callback to trigger
|
||||||
@@ -419,22 +437,6 @@
|
|||||||
return this.value === option
|
return this.value === option
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate the option label text. If {option}
|
|
||||||
* is an object, return option[this.label].
|
|
||||||
*
|
|
||||||
* @param {Object || String} option
|
|
||||||
* @return {String}
|
|
||||||
*/
|
|
||||||
getOptionLabel( option ) {
|
|
||||||
if( typeof option === 'object' ) {
|
|
||||||
if( this.label && option[this.label] ) {
|
|
||||||
return option[this.label]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return option;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there is any text in the search input, remove it.
|
* If there is any text in the search input, remove it.
|
||||||
* Otherwise, blur the search input to close the dropdown.
|
* Otherwise, blur the search input to close the dropdown.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default {
|
module.exports = {
|
||||||
watch: {
|
watch: {
|
||||||
typeAheadPointer() {
|
typeAheadPointer() {
|
||||||
this.maybeAdjustScroll()
|
this.maybeAdjustScroll()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default {
|
module.exports = {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
typeAheadPointer: -1
|
typeAheadPointer: -1
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should move the pointer visually up the list on up arrow keyUp', () => {
|
it('should move the pointer visually up the list on up arrow keyDown', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :options="options"></v-select></div>',
|
template: '<div><v-select :options="options"></v-select></div>',
|
||||||
components: {vSelect},
|
components: {vSelect},
|
||||||
@@ -338,11 +338,11 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
vm.$children[0].typeAheadPointer = 1
|
vm.$children[0].typeAheadPointer = 1
|
||||||
|
|
||||||
trigger(vm.$children[0].$els.search, 'keyup', (e) => e.keyCode = 38)
|
trigger(vm.$children[0].$els.search, 'keydown', (e) => e.keyCode = 38)
|
||||||
expect(vm.$children[0].typeAheadPointer).toEqual(0)
|
expect(vm.$children[0].typeAheadPointer).toEqual(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should move the pointer visually down the list on down arrow keyUp', () => {
|
it('should move the pointer visually down the list on down arrow keyDown', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :options="options"></v-select></div>',
|
template: '<div><v-select :options="options"></v-select></div>',
|
||||||
components: {vSelect},
|
components: {vSelect},
|
||||||
@@ -352,7 +352,7 @@ describe('Select.vue', () => {
|
|||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
vm.$children[0].typeAheadPointer = 1
|
vm.$children[0].typeAheadPointer = 1
|
||||||
trigger(vm.$children[0].$els.search, 'keyup', (e) => e.keyCode = 40)
|
trigger(vm.$children[0].$els.search, 'keydown', (e) => e.keyCode = 40)
|
||||||
expect(vm.$children[0].typeAheadPointer).toEqual(2)
|
expect(vm.$children[0].typeAheadPointer).toEqual(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ describe('Select.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('Automatic Scrolling', () => {
|
describe('Automatic Scrolling', () => {
|
||||||
it('should check if the scroll position needs to be adjusted on up arrow keyUp', () => {
|
it('should check if the scroll position needs to be adjusted on up arrow keyDown', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :options="options"></v-select></div>',
|
template: '<div><v-select :options="options"></v-select></div>',
|
||||||
components: {vSelect},
|
components: {vSelect},
|
||||||
@@ -382,11 +382,11 @@ describe('Select.vue', () => {
|
|||||||
|
|
||||||
vm.$children[0].typeAheadPointer = 1
|
vm.$children[0].typeAheadPointer = 1
|
||||||
spyOn(vm.$children[0], 'maybeAdjustScroll')
|
spyOn(vm.$children[0], 'maybeAdjustScroll')
|
||||||
trigger(vm.$children[0].$els.search, 'keyup', (e) => e.keyCode = 38)
|
trigger(vm.$children[0].$els.search, 'keydown', (e) => e.keyCode = 38)
|
||||||
expect(vm.$children[0].maybeAdjustScroll).toHaveBeenCalled()
|
expect(vm.$children[0].maybeAdjustScroll).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should check if the scroll position needs to be adjusted on down arrow keyUp', () => {
|
it('should check if the scroll position needs to be adjusted on down arrow keyDown', () => {
|
||||||
const vm = new Vue({
|
const vm = new Vue({
|
||||||
template: '<div><v-select :options="options"></v-select></div>',
|
template: '<div><v-select :options="options"></v-select></div>',
|
||||||
components: {vSelect},
|
components: {vSelect},
|
||||||
@@ -396,7 +396,7 @@ describe('Select.vue', () => {
|
|||||||
}).$mount()
|
}).$mount()
|
||||||
|
|
||||||
spyOn(vm.$children[0], 'maybeAdjustScroll')
|
spyOn(vm.$children[0], 'maybeAdjustScroll')
|
||||||
trigger(vm.$children[0].$els.search, 'keyup', (e) => e.keyCode = 40)
|
trigger(vm.$children[0].$els.search, 'keydown', (e) => e.keyCode = 40)
|
||||||
expect(vm.$children[0].maybeAdjustScroll).toHaveBeenCalled()
|
expect(vm.$children[0].maybeAdjustScroll).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user