Skip to content

Commit ff86862

Browse files
author
Damian Dulisz
committed
Further improvements
* Renamed CSS classes 'dropdown' => 'multiselect` * Add support for async options with callback on search * Added `closeOnSelect` and `resetAfter` props * `resetAfter` requires further tests
1 parent 225744f commit ff86862

File tree

6 files changed

+1290
-121
lines changed

6 files changed

+1290
-121
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"dev": "node build/dev-server.js",
99
"build": "node build/build.js",
1010
"unit": "karma start test/unit/karma.conf.js --single-run",
11+
"unit-watch": "karma start test/unit/karma.conf.js --watch",
1112
"e2e": "node test/e2e/runner.js",
1213
"test": "npm run unit && npm run e2e",
1314
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"

src/App.vue

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
<template>
22
<div id="app">
33
<h1><img class="logo" src="./assets/logo.png"> Vue-multiselect</h1>
4-
<multiselect
4+
<!-- <multiselect
55
:options="options"
66
:selected="selected"
77
:multiple="multiple"
88
:searchable="searchable"
99
:placeholder="placeholder"
1010
>
11+
<span slot="noResult">
12+
Oops! No elements found. Consider changing the search query.
13+
</span>
14+
</multiselect> -->
15+
16+
<multiselect
17+
:options="countries"
18+
:selected="selectedCountries"
19+
:multiple="multiple"
20+
:searchable="searchable"
21+
:placeholder="placeholder"
22+
:on-search-change="asyncFind"
23+
label="name"
24+
>
25+
<span slot="noResult">
26+
Oops! No elements found. Consider changing the search query.
27+
</span>
1128
</multiselect>
1229

1330
<h2>Config</h2>
@@ -27,6 +44,7 @@
2744
:searchable="true"
2845
:placeholder="placeholder"
2946
label="name"
47+
:close-on-select="false"
3048
>
3149
</multiselect>
3250

@@ -35,6 +53,7 @@
3553

3654
<script>
3755
import Multiselect from './components/Multiselect'
56+
import countries from './data/countries.json'
3857
3958
export default {
4059
components: {
@@ -48,7 +67,18 @@ export default {
4867
searchable: true,
4968
placeholder: 'Select props',
5069
source: [{ name: '1' }, { name: '2' }, { name: '3' }],
51-
value: []
70+
value: [],
71+
countries: [],
72+
selectedCountries: []
73+
}
74+
},
75+
methods: {
76+
asyncFind (query) {
77+
setTimeout(() => {
78+
this.countries = countries.filter((element, index, array) => {
79+
return element.name.toLowerCase().includes(query.toLowerCase())
80+
})
81+
}, 1500)
5282
}
5383
}
5484
}
@@ -70,7 +100,7 @@ body {
70100
71101
#app {
72102
margin-top: -100px;
73-
width: 500px;
103+
width: 450px;
74104
max-width: 500px;
75105
font-family: 'Lato', Helvetica, sans-serif;
76106
text-align: center;

src/assets/_functions.sass

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,35 @@
1919
$rem-list: append($rem-list, to-rem(nth($values, $i)))
2020

2121
@return $rem-list
22+
23+
@mixin spinner($size: 16px, $color: #333, $border-width: 2px)
24+
width: rem($size)
25+
26+
&:before,
27+
&:after
28+
position: absolute
29+
content: ''
30+
top: 50%
31+
left: 50%
32+
margin: rem($size / -2 0 0 $size / -2)
33+
width: rem($size)
34+
height: rem($size)
35+
border-radius: 100%
36+
border-color: $color transparent transparent
37+
border-style: solid
38+
border-width: $border-width
39+
box-shadow: 0 0 0 1px transparent
40+
41+
&:before
42+
animation: spinning 1.8s cubic-bezier(0.41, 0.26, 0.2, 0.62)
43+
animation-iteration-count: infinite
44+
45+
&:after
46+
animation: spinning 1.8s cubic-bezier(0.51, 0.09, 0.21, 0.8)
47+
animation-iteration-count: infinite
48+
49+
@keyframes spinning
50+
0%
51+
transform: rotate3d(0, 0, 1, 0)
52+
100%
53+
transform: rotate3d(0, 0, 1, 720deg)

0 commit comments

Comments
 (0)