Skip to content

Commit 06921c1

Browse files
committed
v3 work in progress
1 parent 147f477 commit 06921c1

15 files changed

+1444
-930
lines changed

documentation/MultiselectExample.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ div
1111
:limit="3",
1212
@tag="onTagging"
1313
)
14-
template(slot="option", slot-scope="props")
15-
span.badge__name {{ props.option.name }}
16-
img.badge__img(:src="props.option.img", :alt="props.option.name")
17-
span(slot="noResult").
18-
Badge not found. Suggest a badge <a class="typo__link" href="https://github.com/monterail/vue-multiselect/issues" target="_blank">here</a>.
14+
.multiselect__content-wrapper(slot="options", slot-scope="props")
15+
ul.multiselect__content(v-if="props.isOpen")
16+
li.multiselect__element(
17+
v-for="(option, index) of props.filteredOptions",
18+
:key="index"
19+
)
20+
span.multiselect__option(@click="props.select(option)")
21+
| {{ option.name }}
1922
</template>
2023

2124
<script>

documentation/index.pug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ html(lang="en")
1717
body
1818
#app
1919
include ./_mixins
20-
include ./partials/_start
20+
//- include ./partials/_start
2121
2222
.grid__row.docs
2323
.grid__columns.grid__unit--sm-3.small--hidden
24-
include ./partials/_nav
24+
//- include ./partials/_nav
2525
.grid__columns.grid__unit--sm-12.grid__unit--md-9
2626
include ./partials/_getting-started
2727

documentation/partials/examples/SingleSelectObject.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ div
1111
:searchable="false",
1212
:allow-empty="false"
1313
)
14-
template(slot="singleLabel", slot-scope="{ option }")
15-
strong {{ option.name }}
16-
| is written in
17-
strong {{ option.language }}
14+
//- template(slot="singleLabel", slot-scope="{ option }")
15+
//- strong {{ option.name }}
16+
//- | is written in
17+
//- strong {{ option.language }}
1818
pre.language-json
1919
code.
2020
{{ value }}

documentation/partials/examples/SingleSelectPrimitive.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ div
44
multiselect(
55
v-model="value",
66
:options="options",
7-
:searchable="false",
7+
:searchable="true",
8+
:multiple="true",
89
:close-on-select="false",
910
:show-labels="false"
1011
placeholder="Pick a value"
@@ -23,8 +24,22 @@ export default {
2324
},
2425
data () {
2526
return {
26-
value: '',
27-
options: ['Select option', 'options', 'selected', 'mulitple', 'label', 'searchable', 'clearOnSelect', 'hideSelected', 'maxHeight', 'allowEmpty', 'showLabels', 'onChange', 'touched']
27+
value: [],
28+
options: [
29+
'Select option',
30+
'options',
31+
'selected',
32+
'mulitple',
33+
'label',
34+
'searchable',
35+
'clearOnSelect',
36+
'hideSelected',
37+
'maxHeight',
38+
'allowEmpty',
39+
'showLabels',
40+
'onChange',
41+
'touched'
42+
]
2843
}
2944
}
3045
}

documentation/partials/examples/_examples.pug

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -13,103 +13,103 @@
1313
+subsection('Single select (object)')
1414
:markdown-it
1515
When working with objects, you must provide additional props: `label` and `track-by`.
16-
16+
1717
`track-by` is used to identify the option within the options list thus it’s value has to be unique. In this example the `name` property is unique across all options, so it can be used as `track-by` value.
18-
18+
1919
`label` is used to display the option.
20-
20+
2121
#### Optional configuration flags:
2222
- `:searchable="false"` – disables the search functionality
2323
- `:allow-empty="false"` – once there is a value it can’t be deselected
2424
- `deselect-label="Can't remove this value"` – when highlighted, the already selected option will have the _Can't remove this value_ helper label. Useful for single selects that don’t allow empty selection.
2525
+example('SingleSelectObject')
26-
+subsection('Select with search')
27-
:markdown-it
28-
By default `searchable` is set to true, thus using search doesn’t require any prop.
29-
30-
The internal search engine is based on the `label` prop. In other words – when searching, vue-multiselect only compares the option labels with the current search query. If you want to search inside other object properties look at the [ajax search example](#sub-asynchronous-select).
31-
32-
`custom-label` accepts a function with the `option` object as the first param. It should return a string which is then used to display a custom label.
33-
+example('SingleSelectSearch')
34-
+subsection('Multiple select')
35-
:markdown-it
36-
To allow multiple selections pass the `:multiple="true"` prop.
37-
38-
#### Optional configuration flags:
39-
- `:close-on-select="false"` – the dropdown stays open after selecting an option
40-
- `:hide-selected="true"` – already selected options will not be displayed in the dropdown
41-
- `:clear-on-select="false"` – the search query stays the same after selecting an option
42-
#### New in v2.0.0 stable:
43-
- You can now pass `<template slot="tag" slot-scope="props"><Your code></template>` to use a different markup for selected options (tags)
44-
+example('MultiSelect')
45-
+subsection('Asynchronous select')
46-
:markdown-it
47-
Vue-Multiselect supports changing the option list on the fly, thus can be also used a type-a-head search box.
48-
49-
To react to the search query changes, set a handler function on the `@search-change` event. It receives the `searchQuery` as the first param, which can be used to make an asynchronous API call.
50-
51-
It is convenient to set the `:loading` prop to `true`, whenever a request is in progress. Look at the provided `asyncFind` method for an example usage.
52-
53-
#### Optional configuration flags:
54-
- `:internal-search="false"` – disables the multiselect’s internal search engine. If you do that, you have to manually update the available `:options`.
55-
- `:limit="3"` – limits the visible results to 3.
56-
- `:limit-text="limitText"` – function that receives the current selected options count and should return a string to show when the `:limit` count is exceed
57-
- `:options-limit="300"` – limits the displayed options to `300`. Useful for optimisations purposes.
58-
59-
#### New in v2.0.0 stable:
60-
- `id="ajax"` – every event is emitted with this as the second param. Useful for identification which component instance triggered the method (in loops for example). NEW: Can also be used for pointing with `<label :for="id">`.
61-
- `open-direction="bottom"` – forces the multiselect to always open below. Use `top` or `above` to always open above. By default the multiselect will open whereever there is more space once there is not enough space below to open at `maxHeight`.
62-
+example('AjaxSearch')
63-
+subsection('Tagging')
64-
:markdown-it
65-
To add tagging functionality to single/multiple selects, set the `:taggable` prop to `true`. This will add an additional option at the beginning of the options list whenever you type a phrase that doesn’t have an exact match in the available options. Selecting this temporary option will emit the `@tag` event with the current typed search query as the first param. The event handler should add the received **tag** to both the options list and the value.
66-
67-
Remember that when working with objects as options, you have to transform the received tag string to an object that matches the objects structure of the options list. In this example, the `addTag` method generates an object with a unique `code` property.
68-
69-
#### Optional configuration flags:
70-
- `tag-placeholder="Add this as new tag"` – A helper label that will be displayed when highlighting the just typed tag suggestion.
71-
- `tag-position="bottom"` – By default the tag position will be set to 'top' and new tags will appear above the search results. Changing the tag positon to 'bottom' will revert this behaviour and will prioritize the search results.
72-
+example('Tagging')
73-
+subsection('Custom option template')
74-
:markdown-it
75-
You can use `option` [scoped slot](https://vuejs.org/v2/guide/components.html#Scoped-Slots) to provide a custom option template. The available `props` include `props.option` and `props.search`. Look at the provided example for more details.
76-
77-
To ensure the keyboard navigation works properly, remember to set the `:option-height` so it equals the height of the option template. By default, the component assumes an option height of 40px.
78-
79-
#### Optional configuration flags:
80-
- `:option-height="104"` – The height of the custom option template.
81-
+example('CustomOption')
82-
+subsection('Option groups')
83-
:markdown-it
84-
The options list can also contain groups. It requires passing 3 additional props: `group-label`, `group-values` and `group-select`. `group-label` is used to locate the group label. `group-values` should point to the group’s option list. `group-select` is used to define if selecting the group label should select/unselect all values in the group, or do nothing.
85-
86-
Despite that the available options are grouped, the selected options are stored as a flat array of objects.
87-
88-
Please look at the provided example for a example options list structure.
89-
+example('Groups')
90-
+subsection('Vuex support')
91-
:markdown-it
92-
Due to the one-way data-flow enforced by Vuex you should not be using `v-model` for manipulating the currently selected value.
93-
Because Vue-Multiselect always uses it’s own internal copy of the value it never mutates the `:value` by itself, which means it can can safely used with Vuex or even Redux.
94-
95-
In Vue 2.0 `v-model` is just a syntax sugar for `:value` and `@input`. Because of this we can use the `@input` event to trigger Vuex actions or mutations. Whenever we mutate the `:value` in Vuex, Multiselect’s internal value will update.
96-
+example('VuexActions')
97-
+subsection('Action dispatcher')
98-
:markdown-it
99-
The component may also act as dispatcher for different actions/methods. In this case there is no need for the `:value` prop.
100-
Instead of `@input` you can listen on the `@select` event. The difference between the two is that `@select` only receives the currently selected value instead of the whole list of selected values (if select is multiple).
101-
102-
#### Optional configuration flags:
103-
- `:reset-after="true"` – Resets the internal value after each select action inside the component.
104-
+example('ActionDispatcher')
105-
+subsection('Custom configuration')
106-
:markdown-it
107-
Shows error when touched, but nothing is selected.
108-
109-
#### Optional configuration flags:
110-
- `:max-height="150"` – Set the dropdown height to 150px
111-
- `:max="3"` – Set the maximal number of selections
112-
- `:allow-empty="false"` – Doesn’t allow to remove the last option if it exists
113-
- `:block-keys="['Tab', 'Enter']"` – Block the `Tab` and `Enter` keys from triggering their default behaviour
114-
- `@close="onTouch"` – Event emitted when closing the dropdown
115-
+example('CustomConfig')
26+
//- +subsection('Select with search')
27+
//- :markdown-it
28+
//- By default `searchable` is set to true, thus using search doesn’t require any prop.
29+
//-
30+
//- The internal search engine is based on the `label` prop. In other words – when searching, vue-multiselect only compares the option labels with the current search query. If you want to search inside other object properties look at the [ajax search example](#sub-asynchronous-select).
31+
//-
32+
//- `custom-label` accepts a function with the `option` object as the first param. It should return a string which is then used to display a custom label.
33+
//- +example('SingleSelectSearch')
34+
//- +subsection('Multiple select')
35+
//- :markdown-it
36+
//- To allow multiple selections pass the `:multiple="true"` prop.
37+
//-
38+
//- #### Optional configuration flags:
39+
//- - `:close-on-select="false"` – the dropdown stays open after selecting an option
40+
//- - `:hide-selected="true"` – already selected options will not be displayed in the dropdown
41+
//- - `:clear-on-select="false"` – the search query stays the same after selecting an option
42+
//- #### New in v2.0.0 stable:
43+
//- - You can now pass `<template slot="tag" slot-scope="props"><Your code></template>` to use a different markup for selected options (tags)
44+
//- +example('MultiSelect')
45+
//- +subsection('Asynchronous select')
46+
//- :markdown-it
47+
//- Vue-Multiselect supports changing the option list on the fly, thus can be also used a type-a-head search box.
48+
//-
49+
//- To react to the search query changes, set a handler function on the `@search-change` event. It receives the `searchQuery` as the first param, which can be used to make an asynchronous API call.
50+
//-
51+
//- It is convenient to set the `:loading` prop to `true`, whenever a request is in progress. Look at the provided `asyncFind` method for an example usage.
52+
//-
53+
//- #### Optional configuration flags:
54+
//- - `:internal-search="false"` – disables the multiselect’s internal search engine. If you do that, you have to manually update the available `:options`.
55+
//- - `:limit="3"` – limits the visible results to 3.
56+
//- - `:limit-text="limitText"` – function that receives the current selected options count and should return a string to show when the `:limit` count is exceed
57+
//- - `:options-limit="300"` – limits the displayed options to `300`. Useful for optimisations purposes.
58+
//-
59+
//- #### New in v2.0.0 stable:
60+
//- - `id="ajax"` – every event is emitted with this as the second param. Useful for identification which component instance triggered the method (in loops for example). NEW: Can also be used for pointing with `<label :for="id">`.
61+
//- - `open-direction="bottom"` – forces the multiselect to always open below. Use `top` or `above` to always open above. By default the multiselect will open whereever there is more space once there is not enough space below to open at `maxHeight`.
62+
//- +example('AjaxSearch')
63+
//- +subsection('Tagging')
64+
//- :markdown-it
65+
//- To add tagging functionality to single/multiple selects, set the `:taggable` prop to `true`. This will add an additional option at the beginning of the options list whenever you type a phrase that doesn’t have an exact match in the available options. Selecting this temporary option will emit the `@tag` event with the current typed search query as the first param. The event handler should add the received **tag** to both the options list and the value.
66+
//-
67+
//- Remember that when working with objects as options, you have to transform the received tag string to an object that matches the objects structure of the options list. In this example, the `addTag` method generates an object with a unique `code` property.
68+
//-
69+
//- #### Optional configuration flags:
70+
//- - `tag-placeholder="Add this as new tag"` – A helper label that will be displayed when highlighting the just typed tag suggestion.
71+
//- - `tag-position="bottom"` – By default the tag position will be set to 'top' and new tags will appear above the search results. Changing the tag positon to 'bottom' will revert this behaviour and will prioritize the search results.
72+
//- +example('Tagging')
73+
//- +subsection('Custom option template')
74+
//- :markdown-it
75+
//- You can use `option` [scoped slot](https://vuejs.org/v2/guide/components.html#Scoped-Slots) to provide a custom option template. The available `props` include `props.option` and `props.search`. Look at the provided example for more details.
76+
//-
77+
//- To ensure the keyboard navigation works properly, remember to set the `:option-height` so it equals the height of the option template. By default, the component assumes an option height of 40px.
78+
//-
79+
//- #### Optional configuration flags:
80+
//- - `:option-height="104"` – The height of the custom option template.
81+
//- +example('CustomOption')
82+
//- +subsection('Option groups')
83+
//- :markdown-it
84+
//- The options list can also contain groups. It requires passing 3 additional props: `group-label`, `group-values` and `group-select`. `group-label` is used to locate the group label. `group-values` should point to the group’s option list. `group-select` is used to define if selecting the group label should select/unselect all values in the group, or do nothing.
85+
//-
86+
//- Despite that the available options are grouped, the selected options are stored as a flat array of objects.
87+
//-
88+
//- Please look at the provided example for a example options list structure.
89+
//- +example('Groups')
90+
//- +subsection('Vuex support')
91+
//- :markdown-it
92+
//- Due to the one-way data-flow enforced by Vuex you should not be using `v-model` for manipulating the currently selected value.
93+
//- Because Vue-Multiselect always uses it’s own internal copy of the value it never mutates the `:value` by itself, which means it can can safely used with Vuex or even Redux.
94+
//-
95+
//- In Vue 2.0 `v-model` is just a syntax sugar for `:value` and `@input`. Because of this we can use the `@input` event to trigger Vuex actions or mutations. Whenever we mutate the `:value` in Vuex, Multiselect’s internal value will update.
96+
//- +example('VuexActions')
97+
//- +subsection('Action dispatcher')
98+
//- :markdown-it
99+
//- The component may also act as dispatcher for different actions/methods. In this case there is no need for the `:value` prop.
100+
//- Instead of `@input` you can listen on the `@select` event. The difference between the two is that `@select` only receives the currently selected value instead of the whole list of selected values (if select is multiple).
101+
//-
102+
//- #### Optional configuration flags:
103+
//- - `:reset-after="true"` – Resets the internal value after each select action inside the component.
104+
//- +example('ActionDispatcher')
105+
//- +subsection('Custom configuration')
106+
//- :markdown-it
107+
//- Shows error when touched, but nothing is selected.
108+
//-
109+
//- #### Optional configuration flags:
110+
//- - `:max-height="150"` – Set the dropdown height to 150px
111+
//- - `:max="3"` – Set the maximal number of selections
112+
//- - `:allow-empty="false"` – Doesn’t allow to remove the last option if it exists
113+
//- - `:block-keys="['Tab', 'Enter']"` – Block the `Tab` and `Enter` keys from triggering their default behaviour
114+
//- - `@close="onTouch"` – Event emitted when closing the dropdown
115+
//- +example('CustomConfig')

0 commit comments

Comments
 (0)