├── .gitignore ├── LICENSE ├── README.md ├── build └── rollup.config.js ├── dist ├── vue-dynamic-select.esm.js ├── vue-dynamic-select.min.js └── vue-dynamic-select.umd.js ├── package.json └── src ├── DynamicSelect.vue ├── images └── dynamic-select.png └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Silas Montgomery 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-dynamic-select 2 | A VueJS plugin that provides a searchable and reactive select list component with no dependencies. 3 | 4 | ![alt text](https://raw.githubusercontent.com/silasmontgomery/vue-dynamic-select/master/src/images/dynamic-select.png "vue-dynamic-select screenshot") 5 | 6 | [View Online Demos Here](http://demos.reticent.net/vue-dynamic-select) 7 | 8 | ### Installation 9 | ``` 10 | npm install vue-dynamic-select --save 11 | ``` 12 | 13 | ### Import 14 | ```javascript 15 | import DynamicSelect from 'vue-dynamic-select' 16 | 17 | Vue.use(DynamicSelect) 18 | ``` 19 | 20 | ### Usage 21 | ```javascript 22 | // Static options source (array) 23 | 29 | 30 | // Dynamic options source (ajax, etc) 31 | 38 | ``` 39 | 40 | NOTE: For more detailed usage see the examples folder. 41 | 42 | ### Properties 43 | | Name | Type | Default | Description | 44 | | ------------ | ------ | ------- | ------------------------------------------------------------------- | 45 | | options | Array | [ ] | Array of objects that will create the select list options | 46 | | option-value | String | id | The object property used for the value of the select options | 47 | | option-text | String | name | The object property used for the display text of the select options | 48 | | v-model | Object | null | Object containing the the selected object | 49 | | placeholder | String | search | String containing the text to be used as a placeholder | 50 | 51 | ### Events 52 | | Name | Description | 53 | | ------ | --------------------------------------------------------------------------- | 54 | | search | Triggered whenever search text changes. Value is the current search string. | 55 | | input | Triggered whenever an option is selected. | 56 | -------------------------------------------------------------------------------- /build/rollup.config.js: -------------------------------------------------------------------------------- 1 | import vue from 'rollup-plugin-vue'; // Handle .vue SFC files 2 | import buble from 'rollup-plugin-buble'; // Transpile/polyfill with reasonable browser support 3 | import commonjs from 'rollup-plugin-commonjs'; 4 | 5 | export default { 6 | input: 'src/index.js', // Path relative to package.json 7 | output: { 8 | name: 'DynamicSelect', 9 | exports: 'named', 10 | }, 11 | plugins: [ 12 | vue({ 13 | css: true, // Dynamically inject css as a \n"]}, media: undefined }); 414 | 415 | }; 416 | /* scoped */ 417 | var __vue_scope_id__ = "data-v-24d1f392"; 418 | /* module identifier */ 419 | var __vue_module_identifier__ = undefined; 420 | /* functional template */ 421 | var __vue_is_functional_template__ = false; 422 | /* style inject SSR */ 423 | 424 | 425 | 426 | var DynamicSelect = normalizeComponent_1( 427 | { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, 428 | __vue_inject_styles__, 429 | __vue_script__, 430 | __vue_scope_id__, 431 | __vue_is_functional_template__, 432 | __vue_module_identifier__, 433 | browser, 434 | undefined 435 | ) 436 | 437 | // Declare install function executed by Vue.use() 438 | function install(Vue) { 439 | if (install.installed) { return; } 440 | install.installed = true; 441 | Vue.component('DynamicSelect', DynamicSelect); 442 | } 443 | 444 | // Create module definition for Vue.use() 445 | var plugin = { 446 | install: install, 447 | }; 448 | 449 | // Auto-install when vue is found (eg. in browser via \n\n\n"]}, media: undefined }); 417 | 418 | }; 419 | /* scoped */ 420 | var __vue_scope_id__ = "data-v-24d1f392"; 421 | /* module identifier */ 422 | var __vue_module_identifier__ = undefined; 423 | /* functional template */ 424 | var __vue_is_functional_template__ = false; 425 | /* style inject SSR */ 426 | 427 | 428 | 429 | var DynamicSelect = normalizeComponent_1( 430 | { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, 431 | __vue_inject_styles__, 432 | __vue_script__, 433 | __vue_scope_id__, 434 | __vue_is_functional_template__, 435 | __vue_module_identifier__, 436 | browser, 437 | undefined 438 | ) 439 | 440 | // Declare install function executed by Vue.use() 441 | function install(Vue) { 442 | if (install.installed) { return; } 443 | install.installed = true; 444 | Vue.component('DynamicSelect', DynamicSelect); 445 | } 446 | 447 | // Create module definition for Vue.use() 448 | var plugin = { 449 | install: install, 450 | }; 451 | 452 | // Auto-install when vue is found (eg. in browser via \n\n\n"]}, media: undefined }); 420 | 421 | }; 422 | /* scoped */ 423 | var __vue_scope_id__ = "data-v-24d1f392"; 424 | /* module identifier */ 425 | var __vue_module_identifier__ = undefined; 426 | /* functional template */ 427 | var __vue_is_functional_template__ = false; 428 | /* style inject SSR */ 429 | 430 | 431 | 432 | var DynamicSelect = normalizeComponent_1( 433 | { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, 434 | __vue_inject_styles__, 435 | __vue_script__, 436 | __vue_scope_id__, 437 | __vue_is_functional_template__, 438 | __vue_module_identifier__, 439 | browser, 440 | undefined 441 | ) 442 | 443 | // Declare install function executed by Vue.use() 444 | function install(Vue) { 445 | if (install.installed) { return; } 446 | install.installed = true; 447 | Vue.component('DynamicSelect', DynamicSelect); 448 | } 449 | 450 | // Create module definition for Vue.use() 451 | var plugin = { 452 | install: install, 453 | }; 454 | 455 | // Auto-install when vue is found (eg. in browser via 169 | 170 | 224 | -------------------------------------------------------------------------------- /src/images/dynamic-select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/silasmontgomery/vue-dynamic-select/4bf42eacd1068ea2c77879fd371081b281c3132e/src/images/dynamic-select.png -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import DynamicSelect from './DynamicSelect.vue' 2 | 3 | // Declare install function executed by Vue.use() 4 | export function install(Vue) { 5 | if (install.installed) return; 6 | install.installed = true; 7 | Vue.component('DynamicSelect', DynamicSelect); 8 | } 9 | 10 | // Create module definition for Vue.use() 11 | const plugin = { 12 | install, 13 | }; 14 | 15 | // Auto-install when vue is found (eg. in browser via