|
1 | 1 | <template>
|
2 | 2 | <div id="app">
|
| 3 | + <sandbox hide-help> |
| 4 | + <template slot-scope="config"> |
3 | 5 |
|
4 |
| - <div id="config"> |
5 |
| - <div class="form-control"> |
6 |
| - <label for="multiple"> |
7 |
| - <input id="multiple" type="checkbox" v-model="configuration.multiple"> |
8 |
| - <code>multiple</code> |
9 |
| - </label> |
10 |
| - </div> |
| 6 | + <v-select v-bind="config" /> |
11 | 7 |
|
12 |
| - <div class="form-control"> |
13 |
| - <label for="disabled"> |
14 |
| - <input id="disabled" type="checkbox" v-model="configuration.disabled"> |
15 |
| - <code>disabled</code> |
16 |
| - </label> |
17 |
| - </div> |
18 |
| - |
19 |
| - <div class="form-control"> |
20 |
| - <label for="rtl"> |
21 |
| - <input id="rtl" type="radio" v-model="configuration.dir" value="rtl"> |
22 |
| - <code>dir="rtl"</code> |
23 |
| - </label> |
24 |
| - <label for="ltr"> |
25 |
| - <input id="ltr" type="radio" v-model="configuration.dir" value="ltr"> |
26 |
| - <code>dir="ltr"</code> |
27 |
| - </label> |
28 |
| - </div> |
29 |
| - |
30 |
| - <div class="form-control"> |
31 |
| - <label for="taggable"> |
32 |
| - <input id="taggable" type="checkbox" v-model="configuration.taggable"> |
33 |
| - <code>taggable</code> |
34 |
| - </label> |
35 |
| - </div> |
36 |
| - |
37 |
| - <div class="form-control"> |
38 |
| - <label for="noDrop"> |
39 |
| - <input id="noDrop" type="checkbox" v-model="configuration.noDrop"> |
40 |
| - <code>no-drop</code> |
41 |
| - </label> |
42 |
| - </div> |
43 |
| - |
44 |
| - <div class="form-control"> |
45 |
| - <label for="pushTags"> |
46 |
| - <input id="pushTags" type="checkbox" v-model="configuration.pushTags"> |
47 |
| - <code>push-tags</code> |
48 |
| - </label> |
49 |
| - </div> |
50 |
| - |
51 |
| - <div class="form-control"> |
52 |
| - <label for="selectOnTab"> |
53 |
| - <input id="selectOnTab" type="checkbox" v-model="configuration.selectOnTab"> |
54 |
| - <code>select-on-tab</code> |
55 |
| - </label> |
56 |
| - </div> |
57 |
| - |
58 |
| - <div class="form-control"> |
59 |
| - <label for="clearable"> |
60 |
| - <input id="clearable" type="checkbox" v-model="configuration.clearable"> |
61 |
| - <code>clearable</code> |
62 |
| - </label> |
63 |
| - </div> |
64 |
| - |
65 |
| - <div class="form-control"> |
66 |
| - <label for="searchable"> |
67 |
| - <input id="searchable" type="checkbox" v-model="configuration.searchable"> |
68 |
| - <code>searchable</code> |
69 |
| - </label> |
70 |
| - </div> |
71 |
| - |
72 |
| - <div class="form-control"> |
73 |
| - <label for="closeOnSelect"> |
74 |
| - <input id="closeOnSelect" type="checkbox" v-model="configuration.closeOnSelect"> |
75 |
| - <code>close-on-select</code> |
76 |
| - </label> |
77 |
| - </div> |
78 |
| - </div> |
79 |
| - |
80 |
| - <div id="sandbox"> |
81 |
| - |
82 |
| - <div class="example"> |
83 |
| - <v-select v-bind="configuration" placeholder="country objects"></v-select> |
84 |
| - </div> |
85 |
| - |
86 |
| - <div class="example"> |
87 |
| - <v-select v-bind="configuration" placeholder="country objects, using option scoped slots"> |
88 |
| - <template slot="selected-option" slot-scope="{ label, value }"> |
89 |
| - {{ label }} -- {{ value }} |
90 |
| - </template> |
91 |
| - <template slot="option" slot-scope="{ label, value }"> |
92 |
| - {{ label }} ({{ value }}) |
93 |
| - </template> |
94 |
| - </v-select> |
95 |
| - </div> |
96 |
| - |
97 |
| - <div class="example"> |
98 |
| - <v-select v-bind="configuration" :options="['cat', 'dog', 'bear']" placeholder="string options, option slots"> |
99 |
| - <template slot="selected-option" slot-scope="{ label }"> |
100 |
| - {{ label }} |
101 |
| - </template> |
102 |
| - <template slot="option" slot-scope="{ label }"> |
103 |
| - {{ label }} |
104 |
| - </template> |
105 |
| - </v-select> |
106 |
| - </div> |
107 |
| - |
108 |
| - <div class="example"> |
109 |
| - <v-select v-bind="configuration" options="[1,5,10]" placeholder="options=[1,5,10]"></v-select> |
110 |
| - </div> |
111 |
| - |
112 |
| - <div class="example"> |
113 |
| - <v-select v-bind="configuration" label="title" :options="optionDataSets.books" :filter="fuseSearch" placeholder="advanced filtering w/ fuse.js + scoped slots"> |
114 |
| - <template slot="option" slot-scope="option"> |
115 |
| - <strong>{{ option.title }}</strong><br> |
116 |
| - <em>{{ `${option.author.firstName} ${option.author.lastName}` }}</em> |
117 |
| - </template> |
118 |
| - </v-select> |
119 |
| - </div> |
120 |
| - |
121 |
| - <div class="example"> |
122 |
| - <v-select v-bind="configuration" :options="[]" placeholder=":options=[]"></v-select> |
123 |
| - </div> |
124 |
| - </div> |
125 |
| - |
126 |
| - |
127 |
| - <!--<v-select placeholder="search github.." label="full_name" @search="search" :options="ajaxRes"></v-select>--> |
128 |
| - |
129 |
| - |
130 |
| - <!--<v-select multiple placeholder="custom label template" :options="options">--> |
131 |
| - <!--<span--> |
132 |
| - <!--slot="selected-option-container"--> |
133 |
| - <!--slot-scope="props"--> |
134 |
| - <!--class="selected-tag"--> |
135 |
| - <!-->--> |
136 |
| - <!--{{ props.option.label }} ({{ props.option.value }})--> |
137 |
| - <!--<button v-if="props.multiple" @click="props.deselect(props.option)" type="button" class="close" aria-label="Remove option">--> |
138 |
| - <!--<span aria-hidden="true">×</span>--> |
139 |
| - <!--</button>--> |
140 |
| - <!--</span>--> |
141 |
| - <!--</v-select>--> |
142 |
| - <!--<v-select placeholder="filterable=false, @search=searchPeople" label="first_name" :filterable="false" @search="searchPeople" :options="people"></v-select>--> |
| 8 | + </template> |
| 9 | + </sandbox> |
143 | 10 | </div>
|
144 | 11 | </template>
|
145 | 12 |
|
146 | 13 | <script>
|
147 |
| -import Fuse from 'fuse.js'; |
148 |
| -import debounce from 'lodash/debounce'; |
149 |
| -import vSelect from '../src/components/Select.vue'; |
150 |
| -import countries from './data/countryCodes'; |
151 |
| -import books from './data/books'; |
152 |
| -
|
153 |
| -const defaultConfig = () => ({ |
154 |
| - options: countries, |
155 |
| - multiple: false, |
156 |
| - dir: 'ltr', |
157 |
| - clearable: true, |
158 |
| - searchable: true, |
159 |
| - noDrop: false, |
160 |
| - closeOnSelect: true, |
161 |
| - disabled: false, |
162 |
| - selectOntab: false, |
163 |
| - placeholder: 'placeholder', |
164 |
| -}); |
| 14 | +import vSelect from '../src/components/Select'; |
| 15 | +import Sandbox from '../docs/.vuepress/components/Sandbox'; |
| 16 | +// import countries from '../docs/.vuepress/data/countryCodes'; |
| 17 | +// import books from '../docs/.vuepress/data/books'; |
165 | 18 |
|
166 | 19 | export default {
|
167 |
| - components: {vSelect}, |
168 |
| - data () { |
169 |
| - return { |
170 |
| - configuration: defaultConfig(), |
171 |
| - value: null, |
172 |
| - ajaxRes: [], |
173 |
| - people: [], |
174 |
| - optionDataSet: 'countries', |
175 |
| - optionDataSets: { |
176 |
| - countries, |
177 |
| - books, |
178 |
| - }, |
179 |
| - }; |
180 |
| - }, |
181 |
| - methods: { |
182 |
| - search (search, loading) { |
183 |
| - loading(true); |
184 |
| - this.getRepositories(search, loading, this); |
185 |
| - }, |
186 |
| - searchPeople (search, loading) { |
187 |
| - loading(true); |
188 |
| - this.getPeople(loading, this); |
189 |
| - }, |
190 |
| - getPeople: debounce((loading, vm) => { |
191 |
| - vm.$http.get(`https://reqres.in/api/users?per_page=10`).then(res => { |
192 |
| - vm.people = res.data.data; |
193 |
| - loading(false); |
194 |
| - }); |
195 |
| - }, 250), |
196 |
| - getRepositories: debounce((search, loading, vm) => { |
197 |
| - vm.$http |
198 |
| - .get(`https://api.github.com/search/repositories?q=${search}`) |
199 |
| - .then(res => { |
200 |
| - vm.ajaxRes = res.data.items; |
201 |
| - loading(false); |
202 |
| - }); |
203 |
| - }, 250), |
204 |
| - fuseSearch (options, search) { |
205 |
| - return new Fuse(options, { |
206 |
| - keys: ['title', 'author.firstName', 'author.lastName'], |
207 |
| - }).search(search); |
208 |
| - }, |
209 |
| - }, |
| 20 | + components: {Sandbox, vSelect}, |
210 | 21 | };
|
211 | 22 | </script>
|
212 | 23 |
|
213 | 24 | <style>
|
214 |
| - /*@import "https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.1/css/foundation.min.css";*/ |
215 |
| - /*@import "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.2/css/bulma.min.css";*/ |
216 |
| - /*@import "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css";*/ |
217 |
| - /*@import "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css";*/ |
218 |
| -
|
219 |
| - body, |
220 |
| - html { |
| 25 | + html, |
| 26 | + body { |
221 | 27 | margin: 0;
|
222 | 28 | height: 100%;
|
223 | 29 | font-family: -apple-system, sans-serif;
|
224 | 30 | }
|
225 |
| -
|
226 |
| - #app { |
227 |
| - min-height: 100%; |
228 |
| - display: grid; |
229 |
| - grid-template-columns: 25% 75%; |
230 |
| - grid-template-rows: 100%; |
231 |
| - } |
232 |
| -
|
233 |
| - #config { |
234 |
| - border-right: 1px solid #d9d9d9; |
235 |
| - display: flex; |
236 |
| - flex-direction: column; |
237 |
| - justify-content: center; |
238 |
| - } |
239 |
| -
|
240 |
| - #sandbox { |
241 |
| - display: flex; |
242 |
| - flex-direction: column; |
243 |
| - justify-content: center; |
244 |
| - align-items: center; |
245 |
| - } |
246 |
| -
|
247 |
| - .form-control { |
248 |
| - margin-bottom: 1rem; |
249 |
| - padding: 1rem 1rem 0; |
250 |
| - } |
251 |
| -
|
252 |
| - .form-control:not(:first-child) { |
253 |
| - border-top: 1px solid #d9d9d9; |
254 |
| - } |
255 |
| -
|
256 |
| - .example { |
257 |
| - margin-bottom: 2rem; |
258 |
| - } |
259 |
| -
|
260 |
| - .v-select { |
261 |
| - width: 25em; |
262 |
| - } |
263 | 31 | </style>
|
0 commit comments