diff --git a/docs/.vuepress/components/CountrySelect.vue b/docs/.vuepress/components/CountrySelect.vue new file mode 100644 index 0000000..bbebdff --- /dev/null +++ b/docs/.vuepress/components/CountrySelect.vue @@ -0,0 +1,18 @@ + + + + + diff --git a/docs/.vuepress/components/ReducerNestedValue.vue b/docs/.vuepress/components/ReducerNestedValue.vue new file mode 100644 index 0000000..a752bc6 --- /dev/null +++ b/docs/.vuepress/components/ReducerNestedValue.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index fe0f561..2dc7e65 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -74,19 +74,19 @@ module.exports = { title: 'Getting Started', collapsable: false, children: [ - ['getting-started/install', 'Installation'], - ['getting-started/options', 'Dropdown Options'], - ['getting-started/values', 'Selecting Values'], - ['getting-started/localization', 'Localization'], + ['guide/install', 'Installation'], + ['guide/options', 'Dropdown Options'], + ['guide/values', 'Selecting Values'], + ['guide/localization', 'Localization'], ], }, { title: 'Digging Deeper', collapsable: false, children: [ - ['digging-deeper/templating', 'Templating & Slots'], - ['digging-deeper/vuex', 'Vuex'], - ['digging-deeper/ajax', 'AJAX'], + ['guide/templating', 'Templating & Slots'], + ['guide/vuex', 'Vuex'], + ['guide/ajax', 'AJAX'], ], }, { diff --git a/docs/getting-started/values.md b/docs/getting-started/values.md deleted file mode 100644 index 91d054f..0000000 --- a/docs/getting-started/values.md +++ /dev/null @@ -1,79 +0,0 @@ -## Getting / Setting - -### `v-model` - -The most common use case for `vue-select` is to have the chosen value synced with a parent component. `vue-select` -takes advantage of the `v-model` syntax to sync values with a parent. - -```html - -``` - -### `value` prop & `input` event - -If you don't require the `value` to be synced, but you need to preselect a value, you can use the `value` prop. It will -accept strings, numbers or objects. If you're using a `multiple` v-select, you'll want to pass an array. - -```html - -``` - -The `value` prop is very useful when using a state management tool, like Vuex. `vue-select` will emit an `input` event -any time a value changes. - -```html - -``` - -```js -methods: { - setSelected(value) { - // do something with selected value - } -} -``` -## Transforming Selections - -When the `options` array contains objects, `vue-select` returns the whole object as dropdown value upon selection. - -If you need to return a single key, or transform the data before it is synced, `vue-select` provides a `reduce` callback - that allows you to transform a selected option before it is passed to the `@input` event. Consider this data structure: - - ```js - let options = [{code: 'CA', country: 'Canada'}, ...]; - ``` - - If we want to display the `country`, but return the `code` to `v-model`, we can use the `reduce` prop to receive - only the data that's required. - - ```html - - ``` - -The `reduce` property also works well when you have a deeply nested value: - - ``` - { - country: 'canada', - meta: { - id: '1', - code: 'ca' - } - } - ``` - - ```html - - ``` - -## Single/Multiple Selection - -By default, `vue-select` supports choosing a single value. If you need multiple values, use the `multiple` boolean prop, -much the same way you would on a native `` element. When `multiple` is true, `v-model` or `value` should be +arrays. + + +```html + +``` + diff --git a/docs/digging-deeper/vuex.md b/docs/guide/vuex.md similarity index 100% rename from docs/digging-deeper/vuex.md rename to docs/guide/vuex.md